standalone.js 660 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362
  1. (function (global, factory) {
  2. typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
  3. typeof define === 'function' && define.amd ? define(factory) :
  4. (global.prettier = factory());
  5. }(this, (function () { 'use strict';
  6. var name = "prettier";
  7. var version$1 = "1.13.7";
  8. var description = "Prettier is an opinionated code formatter";
  9. var bin = {
  10. "prettier": "./bin/prettier.js"
  11. };
  12. var repository = "prettier/prettier";
  13. var homepage = "https://prettier.io";
  14. var author = "James Long";
  15. var license = "MIT";
  16. var main = "./index.js";
  17. var engines = {
  18. "node": ">=6"
  19. };
  20. var dependencies = {
  21. "@babel/code-frame": "7.0.0-beta.49",
  22. "@babel/parser": "7.0.0-beta.49",
  23. "@glimmer/syntax": "0.30.3",
  24. "camelcase": "4.1.0",
  25. "chalk": "2.1.0",
  26. "cjk-regex": "1.0.2",
  27. "cosmiconfig": "3.1.0",
  28. "dashify": "0.2.2",
  29. "dedent": "0.7.0",
  30. "diff": "3.2.0",
  31. "editorconfig": "0.15.0",
  32. "editorconfig-to-prettier": "0.0.6",
  33. "emoji-regex": "6.5.1",
  34. "escape-string-regexp": "1.0.5",
  35. "esutils": "2.0.2",
  36. "find-parent-dir": "0.3.0",
  37. "find-project-root": "1.1.1",
  38. "flow-parser": "0.75.0",
  39. "get-stream": "3.0.0",
  40. "globby": "6.1.0",
  41. "graphql": "0.13.2",
  42. "html-tag-names": "1.1.2",
  43. "ignore": "3.3.7",
  44. "jest-docblock": "22.2.2",
  45. "json-stable-stringify": "1.0.1",
  46. "leven": "2.1.0",
  47. "lodash.uniqby": "4.7.0",
  48. "mem": "1.1.0",
  49. "minimatch": "3.0.4",
  50. "minimist": "1.2.0",
  51. "parse5": "3.0.3",
  52. "postcss-less": "1.1.5",
  53. "postcss-media-query-parser": "0.2.3",
  54. "postcss-scss": "1.0.5",
  55. "postcss-selector-parser": "2.2.3",
  56. "postcss-values-parser": "1.5.0",
  57. "remark-parse": "5.0.0",
  58. "resolve": "1.5.0",
  59. "semver": "5.4.1",
  60. "string-width": "2.1.1",
  61. "typescript": "2.9.0-dev.20180421",
  62. "typescript-eslint-parser": "16.0.0",
  63. "unicode-regex": "1.0.1",
  64. "unified": "6.1.6"
  65. };
  66. var devDependencies = {
  67. "@babel/cli": "7.0.0-beta.49",
  68. "@babel/core": "7.0.0-beta.49",
  69. "@babel/preset-env": "7.0.0-beta.49",
  70. "builtin-modules": "2.0.0",
  71. "codecov": "2.2.0",
  72. "cross-env": "5.0.5",
  73. "eslint": "4.18.2",
  74. "eslint-config-prettier": "2.9.0",
  75. "eslint-friendly-formatter": "3.0.0",
  76. "eslint-plugin-import": "2.9.0",
  77. "eslint-plugin-prettier": "2.6.0",
  78. "eslint-plugin-react": "7.7.0",
  79. "jest": "21.1.0",
  80. "mkdirp": "0.5.1",
  81. "prettier": "1.13.4",
  82. "prettylint": "1.0.0",
  83. "rimraf": "2.6.2",
  84. "rollup": "0.47.6",
  85. "rollup-plugin-babel": "4.0.0-beta.4",
  86. "rollup-plugin-commonjs": "8.2.6",
  87. "rollup-plugin-json": "2.1.1",
  88. "rollup-plugin-node-builtins": "2.0.0",
  89. "rollup-plugin-node-globals": "1.1.0",
  90. "rollup-plugin-node-resolve": "2.0.0",
  91. "rollup-plugin-replace": "1.2.1",
  92. "rollup-plugin-uglify": "3.0.0",
  93. "shelljs": "0.8.1",
  94. "snapshot-diff": "0.2.2",
  95. "strip-ansi": "4.0.0",
  96. "tempy": "0.2.1",
  97. "webpack": "2.6.1"
  98. };
  99. var scripts = {
  100. "prepublishOnly": "echo \"Error: must publish from dist/\" && exit 1",
  101. "prepare-release": "yarn && yarn build && yarn test:dist",
  102. "test": "jest",
  103. "test:dist": "node ./scripts/test-dist.js",
  104. "test-integration": "jest tests_integration",
  105. "lint": "cross-env EFF_NO_LINK_RULES=true eslint . --format node_modules/eslint-friendly-formatter",
  106. "lint-docs": "prettylint {.,docs,website,website/blog}/*.md",
  107. "build": "node ./scripts/build/build.js",
  108. "build-docs": "node ./scripts/build-docs.js",
  109. "check-deps": "node ./scripts/check-deps.js"
  110. };
  111. var _package = {
  112. name: name,
  113. version: version$1,
  114. description: description,
  115. bin: bin,
  116. repository: repository,
  117. homepage: homepage,
  118. author: author,
  119. license: license,
  120. main: main,
  121. engines: engines,
  122. dependencies: dependencies,
  123. devDependencies: devDependencies,
  124. scripts: scripts
  125. };
  126. var _package$1 = Object.freeze({
  127. name: name,
  128. version: version$1,
  129. description: description,
  130. bin: bin,
  131. repository: repository,
  132. homepage: homepage,
  133. author: author,
  134. license: license,
  135. main: main,
  136. engines: engines,
  137. dependencies: dependencies,
  138. devDependencies: devDependencies,
  139. scripts: scripts,
  140. default: _package
  141. });
  142. var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
  143. function unwrapExports (x) {
  144. return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
  145. }
  146. function createCommonjsModule(fn, module) {
  147. return module = { exports: {} }, fn(module, module.exports), module.exports;
  148. }
  149. var base = createCommonjsModule(function (module, exports) {
  150. /*istanbul ignore start*/
  151. 'use strict';
  152. exports.__esModule = true;
  153. exports['default'] =
  154. /*istanbul ignore end*/
  155. Diff;
  156. function Diff() {}
  157. Diff.prototype = {
  158. /*istanbul ignore start*/
  159. /*istanbul ignore end*/
  160. diff: function diff(oldString, newString) {
  161. /*istanbul ignore start*/
  162. var
  163. /*istanbul ignore end*/
  164. options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];
  165. var callback = options.callback;
  166. if (typeof options === 'function') {
  167. callback = options;
  168. options = {};
  169. }
  170. this.options = options;
  171. var self = this;
  172. function done(value) {
  173. if (callback) {
  174. setTimeout(function () {
  175. callback(undefined, value);
  176. }, 0);
  177. return true;
  178. } else {
  179. return value;
  180. }
  181. } // Allow subclasses to massage the input prior to running
  182. oldString = this.castInput(oldString);
  183. newString = this.castInput(newString);
  184. oldString = this.removeEmpty(this.tokenize(oldString));
  185. newString = this.removeEmpty(this.tokenize(newString));
  186. var newLen = newString.length,
  187. oldLen = oldString.length;
  188. var editLength = 1;
  189. var maxEditLength = newLen + oldLen;
  190. var bestPath = [{
  191. newPos: -1,
  192. components: []
  193. }]; // Seed editLength = 0, i.e. the content starts with the same values
  194. var oldPos = this.extractCommon(bestPath[0], newString, oldString, 0);
  195. if (bestPath[0].newPos + 1 >= newLen && oldPos + 1 >= oldLen) {
  196. // Identity per the equality and tokenizer
  197. return done([{
  198. value: this.join(newString),
  199. count: newString.length
  200. }]);
  201. } // Main worker method. checks all permutations of a given edit length for acceptance.
  202. function execEditLength() {
  203. for (var diagonalPath = -1 * editLength; diagonalPath <= editLength; diagonalPath += 2) {
  204. var basePath =
  205. /*istanbul ignore start*/
  206. void 0;
  207. var addPath = bestPath[diagonalPath - 1],
  208. removePath = bestPath[diagonalPath + 1],
  209. _oldPos = (removePath ? removePath.newPos : 0) - diagonalPath;
  210. if (addPath) {
  211. // No one else is going to attempt to use this value, clear it
  212. bestPath[diagonalPath - 1] = undefined;
  213. }
  214. var canAdd = addPath && addPath.newPos + 1 < newLen,
  215. canRemove = removePath && 0 <= _oldPos && _oldPos < oldLen;
  216. if (!canAdd && !canRemove) {
  217. // If this path is a terminal then prune
  218. bestPath[diagonalPath] = undefined;
  219. continue;
  220. } // Select the diagonal that we want to branch from. We select the prior
  221. // path whose position in the new string is the farthest from the origin
  222. // and does not pass the bounds of the diff graph
  223. if (!canAdd || canRemove && addPath.newPos < removePath.newPos) {
  224. basePath = clonePath(removePath);
  225. self.pushComponent(basePath.components, undefined, true);
  226. } else {
  227. basePath = addPath; // No need to clone, we've pulled it from the list
  228. basePath.newPos++;
  229. self.pushComponent(basePath.components, true, undefined);
  230. }
  231. _oldPos = self.extractCommon(basePath, newString, oldString, diagonalPath); // If we have hit the end of both strings, then we are done
  232. if (basePath.newPos + 1 >= newLen && _oldPos + 1 >= oldLen) {
  233. return done(buildValues(self, basePath.components, newString, oldString, self.useLongestToken));
  234. } else {
  235. // Otherwise track this path as a potential candidate and continue.
  236. bestPath[diagonalPath] = basePath;
  237. }
  238. }
  239. editLength++;
  240. } // Performs the length of edit iteration. Is a bit fugly as this has to support the
  241. // sync and async mode which is never fun. Loops over execEditLength until a value
  242. // is produced.
  243. if (callback) {
  244. (function exec() {
  245. setTimeout(function () {
  246. // This should not happen, but we want to be safe.
  247. /* istanbul ignore next */
  248. if (editLength > maxEditLength) {
  249. return callback();
  250. }
  251. if (!execEditLength()) {
  252. exec();
  253. }
  254. }, 0);
  255. })();
  256. } else {
  257. while (editLength <= maxEditLength) {
  258. var ret = execEditLength();
  259. if (ret) {
  260. return ret;
  261. }
  262. }
  263. }
  264. },
  265. /*istanbul ignore start*/
  266. /*istanbul ignore end*/
  267. pushComponent: function pushComponent(components, added, removed) {
  268. var last = components[components.length - 1];
  269. if (last && last.added === added && last.removed === removed) {
  270. // We need to clone here as the component clone operation is just
  271. // as shallow array clone
  272. components[components.length - 1] = {
  273. count: last.count + 1,
  274. added: added,
  275. removed: removed
  276. };
  277. } else {
  278. components.push({
  279. count: 1,
  280. added: added,
  281. removed: removed
  282. });
  283. }
  284. },
  285. /*istanbul ignore start*/
  286. /*istanbul ignore end*/
  287. extractCommon: function extractCommon(basePath, newString, oldString, diagonalPath) {
  288. var newLen = newString.length,
  289. oldLen = oldString.length,
  290. newPos = basePath.newPos,
  291. oldPos = newPos - diagonalPath,
  292. commonCount = 0;
  293. while (newPos + 1 < newLen && oldPos + 1 < oldLen && this.equals(newString[newPos + 1], oldString[oldPos + 1])) {
  294. newPos++;
  295. oldPos++;
  296. commonCount++;
  297. }
  298. if (commonCount) {
  299. basePath.components.push({
  300. count: commonCount
  301. });
  302. }
  303. basePath.newPos = newPos;
  304. return oldPos;
  305. },
  306. /*istanbul ignore start*/
  307. /*istanbul ignore end*/
  308. equals: function equals(left, right) {
  309. return left === right;
  310. },
  311. /*istanbul ignore start*/
  312. /*istanbul ignore end*/
  313. removeEmpty: function removeEmpty(array) {
  314. var ret = [];
  315. for (var i = 0; i < array.length; i++) {
  316. if (array[i]) {
  317. ret.push(array[i]);
  318. }
  319. }
  320. return ret;
  321. },
  322. /*istanbul ignore start*/
  323. /*istanbul ignore end*/
  324. castInput: function castInput(value) {
  325. return value;
  326. },
  327. /*istanbul ignore start*/
  328. /*istanbul ignore end*/
  329. tokenize: function tokenize(value) {
  330. return value.split('');
  331. },
  332. /*istanbul ignore start*/
  333. /*istanbul ignore end*/
  334. join: function join(chars) {
  335. return chars.join('');
  336. }
  337. };
  338. function buildValues(diff, components, newString, oldString, useLongestToken) {
  339. var componentPos = 0,
  340. componentLen = components.length,
  341. newPos = 0,
  342. oldPos = 0;
  343. for (; componentPos < componentLen; componentPos++) {
  344. var component = components[componentPos];
  345. if (!component.removed) {
  346. if (!component.added && useLongestToken) {
  347. var value = newString.slice(newPos, newPos + component.count);
  348. value = value.map(function (value, i) {
  349. var oldValue = oldString[oldPos + i];
  350. return oldValue.length > value.length ? oldValue : value;
  351. });
  352. component.value = diff.join(value);
  353. } else {
  354. component.value = diff.join(newString.slice(newPos, newPos + component.count));
  355. }
  356. newPos += component.count; // Common case
  357. if (!component.added) {
  358. oldPos += component.count;
  359. }
  360. } else {
  361. component.value = diff.join(oldString.slice(oldPos, oldPos + component.count));
  362. oldPos += component.count; // Reverse add and remove so removes are output first to match common convention
  363. // The diffing algorithm is tied to add then remove output and this is the simplest
  364. // route to get the desired output with minimal overhead.
  365. if (componentPos && components[componentPos - 1].added) {
  366. var tmp = components[componentPos - 1];
  367. components[componentPos - 1] = components[componentPos];
  368. components[componentPos] = tmp;
  369. }
  370. }
  371. } // Special case handle for when one terminal is ignored. For this case we merge the
  372. // terminal into the prior string and drop the change.
  373. var lastComponent = components[componentLen - 1];
  374. if (componentLen > 1 && (lastComponent.added || lastComponent.removed) && diff.equals('', lastComponent.value)) {
  375. components[componentLen - 2].value += lastComponent.value;
  376. components.pop();
  377. }
  378. return components;
  379. }
  380. function clonePath(path) {
  381. return {
  382. newPos: path.newPos,
  383. components: path.components.slice(0)
  384. };
  385. }
  386. });
  387. unwrapExports(base);
  388. var character = createCommonjsModule(function (module, exports) {
  389. /*istanbul ignore start*/
  390. 'use strict';
  391. exports.__esModule = true;
  392. exports.characterDiff = undefined;
  393. exports.
  394. /*istanbul ignore end*/
  395. diffChars = diffChars;
  396. /*istanbul ignore start*/
  397. var _base2 = _interopRequireDefault(base);
  398. function _interopRequireDefault(obj) {
  399. return obj && obj.__esModule ? obj : {
  400. 'default': obj
  401. };
  402. }
  403. /*istanbul ignore end*/
  404. var characterDiff =
  405. /*istanbul ignore start*/
  406. exports.
  407. /*istanbul ignore end*/
  408. characterDiff = new
  409. /*istanbul ignore start*/
  410. _base2['default']();
  411. function diffChars(oldStr, newStr, callback) {
  412. return characterDiff.diff(oldStr, newStr, callback);
  413. }
  414. });
  415. unwrapExports(character);
  416. var params = createCommonjsModule(function (module, exports) {
  417. /*istanbul ignore start*/
  418. 'use strict';
  419. exports.__esModule = true;
  420. exports.
  421. /*istanbul ignore end*/
  422. generateOptions = generateOptions;
  423. function generateOptions(options, defaults) {
  424. if (typeof options === 'function') {
  425. defaults.callback = options;
  426. } else if (options) {
  427. for (var name in options) {
  428. /* istanbul ignore else */
  429. if (options.hasOwnProperty(name)) {
  430. defaults[name] = options[name];
  431. }
  432. }
  433. }
  434. return defaults;
  435. }
  436. });
  437. unwrapExports(params);
  438. var word = createCommonjsModule(function (module, exports) {
  439. /*istanbul ignore start*/
  440. 'use strict';
  441. exports.__esModule = true;
  442. exports.wordDiff = undefined;
  443. exports.
  444. /*istanbul ignore end*/
  445. diffWords = diffWords;
  446. /*istanbul ignore start*/
  447. exports.
  448. /*istanbul ignore end*/
  449. diffWordsWithSpace = diffWordsWithSpace;
  450. /*istanbul ignore start*/
  451. var _base2 = _interopRequireDefault(base);
  452. /*istanbul ignore end*/
  453. /*istanbul ignore start*/
  454. function _interopRequireDefault(obj) {
  455. return obj && obj.__esModule ? obj : {
  456. 'default': obj
  457. };
  458. }
  459. /*istanbul ignore end*/
  460. // Based on https://en.wikipedia.org/wiki/Latin_script_in_Unicode
  461. //
  462. // Ranges and exceptions:
  463. // Latin-1 Supplement, 0080–00FF
  464. // - U+00D7 × Multiplication sign
  465. // - U+00F7 ÷ Division sign
  466. // Latin Extended-A, 0100–017F
  467. // Latin Extended-B, 0180–024F
  468. // IPA Extensions, 0250–02AF
  469. // Spacing Modifier Letters, 02B0–02FF
  470. // - U+02C7 ˇ &#711; Caron
  471. // - U+02D8 ˘ &#728; Breve
  472. // - U+02D9 ˙ &#729; Dot Above
  473. // - U+02DA ˚ &#730; Ring Above
  474. // - U+02DB ˛ &#731; Ogonek
  475. // - U+02DC ˜ &#732; Small Tilde
  476. // - U+02DD ˝ &#733; Double Acute Accent
  477. // Latin Extended Additional, 1E00–1EFF
  478. var extendedWordChars = /^[A-Za-z\xC0-\u02C6\u02C8-\u02D7\u02DE-\u02FF\u1E00-\u1EFF]+$/;
  479. var reWhitespace = /\S/;
  480. var wordDiff =
  481. /*istanbul ignore start*/
  482. exports.
  483. /*istanbul ignore end*/
  484. wordDiff = new
  485. /*istanbul ignore start*/
  486. _base2['default']();
  487. wordDiff.equals = function (left, right) {
  488. return left === right || this.options.ignoreWhitespace && !reWhitespace.test(left) && !reWhitespace.test(right);
  489. };
  490. wordDiff.tokenize = function (value) {
  491. var tokens = value.split(/(\s+|\b)/); // Join the boundary splits that we do not consider to be boundaries. This is primarily the extended Latin character set.
  492. for (var i = 0; i < tokens.length - 1; i++) {
  493. // If we have an empty string in the next field and we have only word chars before and after, merge
  494. if (!tokens[i + 1] && tokens[i + 2] && extendedWordChars.test(tokens[i]) && extendedWordChars.test(tokens[i + 2])) {
  495. tokens[i] += tokens[i + 2];
  496. tokens.splice(i + 1, 2);
  497. i--;
  498. }
  499. }
  500. return tokens;
  501. };
  502. function diffWords(oldStr, newStr, callback) {
  503. var options =
  504. /*istanbul ignore start*/
  505. (0, params.generateOptions
  506. /*istanbul ignore end*/
  507. )(callback, {
  508. ignoreWhitespace: true
  509. });
  510. return wordDiff.diff(oldStr, newStr, options);
  511. }
  512. function diffWordsWithSpace(oldStr, newStr, callback) {
  513. return wordDiff.diff(oldStr, newStr, callback);
  514. }
  515. });
  516. unwrapExports(word);
  517. var line = createCommonjsModule(function (module, exports) {
  518. /*istanbul ignore start*/
  519. 'use strict';
  520. exports.__esModule = true;
  521. exports.lineDiff = undefined;
  522. exports.
  523. /*istanbul ignore end*/
  524. diffLines = diffLines;
  525. /*istanbul ignore start*/
  526. exports.
  527. /*istanbul ignore end*/
  528. diffTrimmedLines = diffTrimmedLines;
  529. /*istanbul ignore start*/
  530. var _base2 = _interopRequireDefault(base);
  531. /*istanbul ignore end*/
  532. /*istanbul ignore start*/
  533. function _interopRequireDefault(obj) {
  534. return obj && obj.__esModule ? obj : {
  535. 'default': obj
  536. };
  537. }
  538. /*istanbul ignore end*/
  539. var lineDiff =
  540. /*istanbul ignore start*/
  541. exports.
  542. /*istanbul ignore end*/
  543. lineDiff = new
  544. /*istanbul ignore start*/
  545. _base2['default']();
  546. lineDiff.tokenize = function (value) {
  547. var retLines = [],
  548. linesAndNewlines = value.split(/(\n|\r\n)/); // Ignore the final empty token that occurs if the string ends with a new line
  549. if (!linesAndNewlines[linesAndNewlines.length - 1]) {
  550. linesAndNewlines.pop();
  551. } // Merge the content and line separators into single tokens
  552. for (var i = 0; i < linesAndNewlines.length; i++) {
  553. var line = linesAndNewlines[i];
  554. if (i % 2 && !this.options.newlineIsToken) {
  555. retLines[retLines.length - 1] += line;
  556. } else {
  557. if (this.options.ignoreWhitespace) {
  558. line = line.trim();
  559. }
  560. retLines.push(line);
  561. }
  562. }
  563. return retLines;
  564. };
  565. function diffLines(oldStr, newStr, callback) {
  566. return lineDiff.diff(oldStr, newStr, callback);
  567. }
  568. function diffTrimmedLines(oldStr, newStr, callback) {
  569. var options =
  570. /*istanbul ignore start*/
  571. (0, params.generateOptions
  572. /*istanbul ignore end*/
  573. )(callback, {
  574. ignoreWhitespace: true
  575. });
  576. return lineDiff.diff(oldStr, newStr, options);
  577. }
  578. });
  579. unwrapExports(line);
  580. var sentence = createCommonjsModule(function (module, exports) {
  581. /*istanbul ignore start*/
  582. 'use strict';
  583. exports.__esModule = true;
  584. exports.sentenceDiff = undefined;
  585. exports.
  586. /*istanbul ignore end*/
  587. diffSentences = diffSentences;
  588. /*istanbul ignore start*/
  589. var _base2 = _interopRequireDefault(base);
  590. function _interopRequireDefault(obj) {
  591. return obj && obj.__esModule ? obj : {
  592. 'default': obj
  593. };
  594. }
  595. /*istanbul ignore end*/
  596. var sentenceDiff =
  597. /*istanbul ignore start*/
  598. exports.
  599. /*istanbul ignore end*/
  600. sentenceDiff = new
  601. /*istanbul ignore start*/
  602. _base2['default']();
  603. sentenceDiff.tokenize = function (value) {
  604. return value.split(/(\S.+?[.!?])(?=\s+|$)/);
  605. };
  606. function diffSentences(oldStr, newStr, callback) {
  607. return sentenceDiff.diff(oldStr, newStr, callback);
  608. }
  609. });
  610. unwrapExports(sentence);
  611. var css = createCommonjsModule(function (module, exports) {
  612. /*istanbul ignore start*/
  613. 'use strict';
  614. exports.__esModule = true;
  615. exports.cssDiff = undefined;
  616. exports.
  617. /*istanbul ignore end*/
  618. diffCss = diffCss;
  619. /*istanbul ignore start*/
  620. var _base2 = _interopRequireDefault(base);
  621. function _interopRequireDefault(obj) {
  622. return obj && obj.__esModule ? obj : {
  623. 'default': obj
  624. };
  625. }
  626. /*istanbul ignore end*/
  627. var cssDiff =
  628. /*istanbul ignore start*/
  629. exports.
  630. /*istanbul ignore end*/
  631. cssDiff = new
  632. /*istanbul ignore start*/
  633. _base2['default']();
  634. cssDiff.tokenize = function (value) {
  635. return value.split(/([{}:;,]|\s+)/);
  636. };
  637. function diffCss(oldStr, newStr, callback) {
  638. return cssDiff.diff(oldStr, newStr, callback);
  639. }
  640. });
  641. unwrapExports(css);
  642. function _typeof(obj) {
  643. if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
  644. _typeof = function (obj) {
  645. return typeof obj;
  646. };
  647. } else {
  648. _typeof = function (obj) {
  649. return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
  650. };
  651. }
  652. return _typeof(obj);
  653. }
  654. function _classCallCheck(instance, Constructor) {
  655. if (!(instance instanceof Constructor)) {
  656. throw new TypeError("Cannot call a class as a function");
  657. }
  658. }
  659. function _defineProperty(obj, key, value) {
  660. if (key in obj) {
  661. Object.defineProperty(obj, key, {
  662. value: value,
  663. enumerable: true,
  664. configurable: true,
  665. writable: true
  666. });
  667. } else {
  668. obj[key] = value;
  669. }
  670. return obj;
  671. }
  672. function _inherits(subClass, superClass) {
  673. if (typeof superClass !== "function" && superClass !== null) {
  674. throw new TypeError("Super expression must either be null or a function");
  675. }
  676. subClass.prototype = Object.create(superClass && superClass.prototype, {
  677. constructor: {
  678. value: subClass,
  679. writable: true,
  680. configurable: true
  681. }
  682. });
  683. if (superClass) _setPrototypeOf(subClass, superClass);
  684. }
  685. function _getPrototypeOf(o) {
  686. _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
  687. return o.__proto__ || Object.getPrototypeOf(o);
  688. };
  689. return _getPrototypeOf(o);
  690. }
  691. function _setPrototypeOf(o, p) {
  692. _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
  693. o.__proto__ = p;
  694. return o;
  695. };
  696. return _setPrototypeOf(o, p);
  697. }
  698. function isNativeReflectConstruct() {
  699. if (typeof Reflect === "undefined" || !Reflect.construct) return false;
  700. if (Reflect.construct.sham) return false;
  701. if (typeof Proxy === "function") return true;
  702. try {
  703. Date.prototype.toString.call(Reflect.construct(Date, [], function () {}));
  704. return true;
  705. } catch (e) {
  706. return false;
  707. }
  708. }
  709. function _construct(Parent, args, Class) {
  710. if (isNativeReflectConstruct()) {
  711. _construct = Reflect.construct;
  712. } else {
  713. _construct = function _construct(Parent, args, Class) {
  714. var a = [null];
  715. a.push.apply(a, args);
  716. var Constructor = Function.bind.apply(Parent, a);
  717. var instance = new Constructor();
  718. if (Class) _setPrototypeOf(instance, Class.prototype);
  719. return instance;
  720. };
  721. }
  722. return _construct.apply(null, arguments);
  723. }
  724. function _wrapNativeSuper(Class) {
  725. var _cache = typeof Map === "function" ? new Map() : undefined;
  726. _wrapNativeSuper = function _wrapNativeSuper(Class) {
  727. if (Class === null) return null;
  728. if (typeof Class !== "function") {
  729. throw new TypeError("Super expression must either be null or a function");
  730. }
  731. if (typeof _cache !== "undefined") {
  732. if (_cache.has(Class)) return _cache.get(Class);
  733. _cache.set(Class, Wrapper);
  734. }
  735. function Wrapper() {
  736. return _construct(Class, arguments, _getPrototypeOf(this).constructor);
  737. }
  738. Wrapper.prototype = Object.create(Class.prototype, {
  739. constructor: {
  740. value: Wrapper,
  741. enumerable: false,
  742. writable: true,
  743. configurable: true
  744. }
  745. });
  746. return _setPrototypeOf(Wrapper, Class);
  747. };
  748. return _wrapNativeSuper(Class);
  749. }
  750. function _assertThisInitialized(self) {
  751. if (self === void 0) {
  752. throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
  753. }
  754. return self;
  755. }
  756. function _possibleConstructorReturn(self, call) {
  757. if (call && (typeof call === "object" || typeof call === "function")) {
  758. return call;
  759. }
  760. return _assertThisInitialized(self);
  761. }
  762. function _taggedTemplateLiteral(strings, raw) {
  763. if (!raw) {
  764. raw = strings.slice(0);
  765. }
  766. return Object.freeze(Object.defineProperties(strings, {
  767. raw: {
  768. value: Object.freeze(raw)
  769. }
  770. }));
  771. }
  772. function _slicedToArray(arr, i) {
  773. return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest();
  774. }
  775. function _arrayWithHoles(arr) {
  776. if (Array.isArray(arr)) return arr;
  777. }
  778. function _iterableToArrayLimit(arr, i) {
  779. var _arr = [];
  780. var _n = true;
  781. var _d = false;
  782. var _e = undefined;
  783. try {
  784. for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
  785. _arr.push(_s.value);
  786. if (i && _arr.length === i) break;
  787. }
  788. } catch (err) {
  789. _d = true;
  790. _e = err;
  791. } finally {
  792. try {
  793. if (!_n && _i["return"] != null) _i["return"]();
  794. } finally {
  795. if (_d) throw _e;
  796. }
  797. }
  798. return _arr;
  799. }
  800. function _nonIterableRest() {
  801. throw new TypeError("Invalid attempt to destructure non-iterable instance");
  802. }
  803. var json = createCommonjsModule(function (module, exports) {
  804. /*istanbul ignore start*/
  805. 'use strict';
  806. exports.__esModule = true;
  807. exports.jsonDiff = undefined;
  808. var _typeof$$1 = typeof Symbol === "function" && _typeof(Symbol.iterator) === "symbol" ? function (obj) {
  809. return _typeof(obj);
  810. } : function (obj) {
  811. return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : _typeof(obj);
  812. };
  813. exports.
  814. /*istanbul ignore end*/
  815. diffJson = diffJson;
  816. /*istanbul ignore start*/
  817. exports.
  818. /*istanbul ignore end*/
  819. canonicalize = canonicalize;
  820. /*istanbul ignore start*/
  821. var _base2 = _interopRequireDefault$$1(base);
  822. /*istanbul ignore end*/
  823. /*istanbul ignore start*/
  824. function _interopRequireDefault$$1(obj) {
  825. return obj && obj.__esModule ? obj : {
  826. 'default': obj
  827. };
  828. }
  829. /*istanbul ignore end*/
  830. var objectPrototypeToString = Object.prototype.toString;
  831. var jsonDiff =
  832. /*istanbul ignore start*/
  833. exports.
  834. /*istanbul ignore end*/
  835. jsonDiff = new
  836. /*istanbul ignore start*/
  837. _base2['default'](); // Discriminate between two lines of pretty-printed, serialized JSON where one of them has a
  838. // dangling comma and the other doesn't. Turns out including the dangling comma yields the nicest output:
  839. jsonDiff.useLongestToken = true;
  840. jsonDiff.tokenize =
  841. /*istanbul ignore start*/
  842. line.lineDiff.
  843. /*istanbul ignore end*/
  844. tokenize;
  845. jsonDiff.castInput = function (value) {
  846. /*istanbul ignore start*/
  847. var
  848. /*istanbul ignore end*/
  849. undefinedReplacement = this.options.undefinedReplacement;
  850. return typeof value === 'string' ? value : JSON.stringify(canonicalize(value), function (k, v) {
  851. if (typeof v === 'undefined') {
  852. return undefinedReplacement;
  853. }
  854. return v;
  855. }, ' ');
  856. };
  857. jsonDiff.equals = function (left, right) {
  858. return (
  859. /*istanbul ignore start*/
  860. _base2['default'].
  861. /*istanbul ignore end*/
  862. prototype.equals(left.replace(/,([\r\n])/g, '$1'), right.replace(/,([\r\n])/g, '$1'))
  863. );
  864. };
  865. function diffJson(oldObj, newObj, options) {
  866. return jsonDiff.diff(oldObj, newObj, options);
  867. } // This function handles the presence of circular references by bailing out when encountering an
  868. // object that is already on the "stack" of items being processed.
  869. function canonicalize(obj, stack, replacementStack) {
  870. stack = stack || [];
  871. replacementStack = replacementStack || [];
  872. var i =
  873. /*istanbul ignore start*/
  874. void 0;
  875. for (i = 0; i < stack.length; i += 1) {
  876. if (stack[i] === obj) {
  877. return replacementStack[i];
  878. }
  879. }
  880. var canonicalizedObj =
  881. /*istanbul ignore start*/
  882. void 0;
  883. if ('[object Array]' === objectPrototypeToString.call(obj)) {
  884. stack.push(obj);
  885. canonicalizedObj = new Array(obj.length);
  886. replacementStack.push(canonicalizedObj);
  887. for (i = 0; i < obj.length; i += 1) {
  888. canonicalizedObj[i] = canonicalize(obj[i], stack, replacementStack);
  889. }
  890. stack.pop();
  891. replacementStack.pop();
  892. return canonicalizedObj;
  893. }
  894. if (obj && obj.toJSON) {
  895. obj = obj.toJSON();
  896. }
  897. if (
  898. /*istanbul ignore start*/
  899. (typeof
  900. /*istanbul ignore end*/
  901. obj === 'undefined' ? 'undefined' : _typeof$$1(obj)) === 'object' && obj !== null) {
  902. stack.push(obj);
  903. canonicalizedObj = {};
  904. replacementStack.push(canonicalizedObj);
  905. var sortedKeys = [],
  906. key =
  907. /*istanbul ignore start*/
  908. void 0;
  909. for (key in obj) {
  910. /* istanbul ignore else */
  911. if (obj.hasOwnProperty(key)) {
  912. sortedKeys.push(key);
  913. }
  914. }
  915. sortedKeys.sort();
  916. for (i = 0; i < sortedKeys.length; i += 1) {
  917. key = sortedKeys[i];
  918. canonicalizedObj[key] = canonicalize(obj[key], stack, replacementStack);
  919. }
  920. stack.pop();
  921. replacementStack.pop();
  922. } else {
  923. canonicalizedObj = obj;
  924. }
  925. return canonicalizedObj;
  926. }
  927. });
  928. unwrapExports(json);
  929. var array = createCommonjsModule(function (module, exports) {
  930. /*istanbul ignore start*/
  931. 'use strict';
  932. exports.__esModule = true;
  933. exports.arrayDiff = undefined;
  934. exports.
  935. /*istanbul ignore end*/
  936. diffArrays = diffArrays;
  937. /*istanbul ignore start*/
  938. var _base2 = _interopRequireDefault(base);
  939. function _interopRequireDefault(obj) {
  940. return obj && obj.__esModule ? obj : {
  941. 'default': obj
  942. };
  943. }
  944. /*istanbul ignore end*/
  945. var arrayDiff =
  946. /*istanbul ignore start*/
  947. exports.
  948. /*istanbul ignore end*/
  949. arrayDiff = new
  950. /*istanbul ignore start*/
  951. _base2['default']();
  952. arrayDiff.tokenize = arrayDiff.join = function (value) {
  953. return value.slice();
  954. };
  955. function diffArrays(oldArr, newArr, callback) {
  956. return arrayDiff.diff(oldArr, newArr, callback);
  957. }
  958. });
  959. unwrapExports(array);
  960. var parse = createCommonjsModule(function (module, exports) {
  961. /*istanbul ignore start*/
  962. 'use strict';
  963. exports.__esModule = true;
  964. exports.
  965. /*istanbul ignore end*/
  966. parsePatch = parsePatch;
  967. function parsePatch(uniDiff) {
  968. /*istanbul ignore start*/
  969. var
  970. /*istanbul ignore end*/
  971. options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
  972. var diffstr = uniDiff.split(/\r\n|[\n\v\f\r\x85]/),
  973. delimiters = uniDiff.match(/\r\n|[\n\v\f\r\x85]/g) || [],
  974. list = [],
  975. i = 0;
  976. function parseIndex() {
  977. var index = {};
  978. list.push(index); // Parse diff metadata
  979. while (i < diffstr.length) {
  980. var line = diffstr[i]; // File header found, end parsing diff metadata
  981. if (/^(\-\-\-|\+\+\+|@@)\s/.test(line)) {
  982. break;
  983. } // Diff index
  984. var header = /^(?:Index:|diff(?: -r \w+)+)\s+(.+?)\s*$/.exec(line);
  985. if (header) {
  986. index.index = header[1];
  987. }
  988. i++;
  989. } // Parse file headers if they are defined. Unified diff requires them, but
  990. // there's no technical issues to have an isolated hunk without file header
  991. parseFileHeader(index);
  992. parseFileHeader(index); // Parse hunks
  993. index.hunks = [];
  994. while (i < diffstr.length) {
  995. var _line = diffstr[i];
  996. if (/^(Index:|diff|\-\-\-|\+\+\+)\s/.test(_line)) {
  997. break;
  998. } else if (/^@@/.test(_line)) {
  999. index.hunks.push(parseHunk());
  1000. } else if (_line && options.strict) {
  1001. // Ignore unexpected content unless in strict mode
  1002. throw new Error('Unknown line ' + (i + 1) + ' ' + JSON.stringify(_line));
  1003. } else {
  1004. i++;
  1005. }
  1006. }
  1007. } // Parses the --- and +++ headers, if none are found, no lines
  1008. // are consumed.
  1009. function parseFileHeader(index) {
  1010. var headerPattern = /^(---|\+\+\+)\s+([\S ]*)(?:\t(.*?)\s*)?$/;
  1011. var fileHeader = headerPattern.exec(diffstr[i]);
  1012. if (fileHeader) {
  1013. var keyPrefix = fileHeader[1] === '---' ? 'old' : 'new';
  1014. index[keyPrefix + 'FileName'] = fileHeader[2];
  1015. index[keyPrefix + 'Header'] = fileHeader[3];
  1016. i++;
  1017. }
  1018. } // Parses a hunk
  1019. // This assumes that we are at the start of a hunk.
  1020. function parseHunk() {
  1021. var chunkHeaderIndex = i,
  1022. chunkHeaderLine = diffstr[i++],
  1023. chunkHeader = chunkHeaderLine.split(/@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/);
  1024. var hunk = {
  1025. oldStart: +chunkHeader[1],
  1026. oldLines: +chunkHeader[2] || 1,
  1027. newStart: +chunkHeader[3],
  1028. newLines: +chunkHeader[4] || 1,
  1029. lines: [],
  1030. linedelimiters: []
  1031. };
  1032. var addCount = 0,
  1033. removeCount = 0;
  1034. for (; i < diffstr.length; i++) {
  1035. // Lines starting with '---' could be mistaken for the "remove line" operation
  1036. // But they could be the header for the next file. Therefore prune such cases out.
  1037. if (diffstr[i].indexOf('--- ') === 0 && i + 2 < diffstr.length && diffstr[i + 1].indexOf('+++ ') === 0 && diffstr[i + 2].indexOf('@@') === 0) {
  1038. break;
  1039. }
  1040. var operation = diffstr[i][0];
  1041. if (operation === '+' || operation === '-' || operation === ' ' || operation === '\\') {
  1042. hunk.lines.push(diffstr[i]);
  1043. hunk.linedelimiters.push(delimiters[i] || '\n');
  1044. if (operation === '+') {
  1045. addCount++;
  1046. } else if (operation === '-') {
  1047. removeCount++;
  1048. } else if (operation === ' ') {
  1049. addCount++;
  1050. removeCount++;
  1051. }
  1052. } else {
  1053. break;
  1054. }
  1055. } // Handle the empty block count case
  1056. if (!addCount && hunk.newLines === 1) {
  1057. hunk.newLines = 0;
  1058. }
  1059. if (!removeCount && hunk.oldLines === 1) {
  1060. hunk.oldLines = 0;
  1061. } // Perform optional sanity checking
  1062. if (options.strict) {
  1063. if (addCount !== hunk.newLines) {
  1064. throw new Error('Added line count did not match for hunk at line ' + (chunkHeaderIndex + 1));
  1065. }
  1066. if (removeCount !== hunk.oldLines) {
  1067. throw new Error('Removed line count did not match for hunk at line ' + (chunkHeaderIndex + 1));
  1068. }
  1069. }
  1070. return hunk;
  1071. }
  1072. while (i < diffstr.length) {
  1073. parseIndex();
  1074. }
  1075. return list;
  1076. }
  1077. });
  1078. unwrapExports(parse);
  1079. var distanceIterator = createCommonjsModule(function (module, exports) {
  1080. /*istanbul ignore start*/
  1081. "use strict";
  1082. exports.__esModule = true;
  1083. exports["default"] =
  1084. /*istanbul ignore end*/
  1085. function (start, minLine, maxLine) {
  1086. var wantForward = true,
  1087. backwardExhausted = false,
  1088. forwardExhausted = false,
  1089. localOffset = 1;
  1090. return function iterator() {
  1091. if (wantForward && !forwardExhausted) {
  1092. if (backwardExhausted) {
  1093. localOffset++;
  1094. } else {
  1095. wantForward = false;
  1096. } // Check if trying to fit beyond text length, and if not, check it fits
  1097. // after offset location (or desired location on first iteration)
  1098. if (start + localOffset <= maxLine) {
  1099. return localOffset;
  1100. }
  1101. forwardExhausted = true;
  1102. }
  1103. if (!backwardExhausted) {
  1104. if (!forwardExhausted) {
  1105. wantForward = true;
  1106. } // Check if trying to fit before text beginning, and if not, check it fits
  1107. // before offset location
  1108. if (minLine <= start - localOffset) {
  1109. return -localOffset++;
  1110. }
  1111. backwardExhausted = true;
  1112. return iterator();
  1113. } // We tried to fit hunk before text beginning and beyond text lenght, then
  1114. // hunk can't fit on the text. Return undefined
  1115. };
  1116. };
  1117. });
  1118. unwrapExports(distanceIterator);
  1119. var apply = createCommonjsModule(function (module, exports) {
  1120. /*istanbul ignore start*/
  1121. 'use strict';
  1122. exports.__esModule = true;
  1123. exports.
  1124. /*istanbul ignore end*/
  1125. applyPatch = applyPatch;
  1126. /*istanbul ignore start*/
  1127. exports.
  1128. /*istanbul ignore end*/
  1129. applyPatches = applyPatches;
  1130. /*istanbul ignore start*/
  1131. var _distanceIterator2 = _interopRequireDefault(distanceIterator);
  1132. function _interopRequireDefault(obj) {
  1133. return obj && obj.__esModule ? obj : {
  1134. 'default': obj
  1135. };
  1136. }
  1137. /*istanbul ignore end*/
  1138. function applyPatch(source, uniDiff) {
  1139. /*istanbul ignore start*/
  1140. var
  1141. /*istanbul ignore end*/
  1142. options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];
  1143. if (typeof uniDiff === 'string') {
  1144. uniDiff =
  1145. /*istanbul ignore start*/
  1146. (0, parse.parsePatch
  1147. /*istanbul ignore end*/
  1148. )(uniDiff);
  1149. }
  1150. if (Array.isArray(uniDiff)) {
  1151. if (uniDiff.length > 1) {
  1152. throw new Error('applyPatch only works with a single input.');
  1153. }
  1154. uniDiff = uniDiff[0];
  1155. } // Apply the diff to the input
  1156. var lines = source.split(/\r\n|[\n\v\f\r\x85]/),
  1157. delimiters = source.match(/\r\n|[\n\v\f\r\x85]/g) || [],
  1158. hunks = uniDiff.hunks,
  1159. compareLine = options.compareLine || function (lineNumber, line, operation, patchContent)
  1160. /*istanbul ignore start*/
  1161. {
  1162. return (
  1163. /*istanbul ignore end*/
  1164. line === patchContent
  1165. );
  1166. },
  1167. errorCount = 0,
  1168. fuzzFactor = options.fuzzFactor || 0,
  1169. minLine = 0,
  1170. offset = 0,
  1171. removeEOFNL =
  1172. /*istanbul ignore start*/
  1173. void 0
  1174. /*istanbul ignore end*/
  1175. ,
  1176. addEOFNL =
  1177. /*istanbul ignore start*/
  1178. void 0;
  1179. /**
  1180. * Checks if the hunk exactly fits on the provided location
  1181. */
  1182. function hunkFits(hunk, toPos) {
  1183. for (var j = 0; j < hunk.lines.length; j++) {
  1184. var line = hunk.lines[j],
  1185. operation = line[0],
  1186. content = line.substr(1);
  1187. if (operation === ' ' || operation === '-') {
  1188. // Context sanity check
  1189. if (!compareLine(toPos + 1, lines[toPos], operation, content)) {
  1190. errorCount++;
  1191. if (errorCount > fuzzFactor) {
  1192. return false;
  1193. }
  1194. }
  1195. toPos++;
  1196. }
  1197. }
  1198. return true;
  1199. } // Search best fit offsets for each hunk based on the previous ones
  1200. for (var i = 0; i < hunks.length; i++) {
  1201. var hunk = hunks[i],
  1202. maxLine = lines.length - hunk.oldLines,
  1203. localOffset = 0,
  1204. toPos = offset + hunk.oldStart - 1;
  1205. var iterator =
  1206. /*istanbul ignore start*/
  1207. (0, _distanceIterator2['default']
  1208. /*istanbul ignore end*/
  1209. )(toPos, minLine, maxLine);
  1210. for (; localOffset !== undefined; localOffset = iterator()) {
  1211. if (hunkFits(hunk, toPos + localOffset)) {
  1212. hunk.offset = offset += localOffset;
  1213. break;
  1214. }
  1215. }
  1216. if (localOffset === undefined) {
  1217. return false;
  1218. } // Set lower text limit to end of the current hunk, so next ones don't try
  1219. // to fit over already patched text
  1220. minLine = hunk.offset + hunk.oldStart + hunk.oldLines;
  1221. } // Apply patch hunks
  1222. for (var _i = 0; _i < hunks.length; _i++) {
  1223. var _hunk = hunks[_i],
  1224. _toPos = _hunk.offset + _hunk.newStart - 1;
  1225. if (_hunk.newLines == 0) {
  1226. _toPos++;
  1227. }
  1228. for (var j = 0; j < _hunk.lines.length; j++) {
  1229. var line = _hunk.lines[j],
  1230. operation = line[0],
  1231. content = line.substr(1),
  1232. delimiter = _hunk.linedelimiters[j];
  1233. if (operation === ' ') {
  1234. _toPos++;
  1235. } else if (operation === '-') {
  1236. lines.splice(_toPos, 1);
  1237. delimiters.splice(_toPos, 1);
  1238. /* istanbul ignore else */
  1239. } else if (operation === '+') {
  1240. lines.splice(_toPos, 0, content);
  1241. delimiters.splice(_toPos, 0, delimiter);
  1242. _toPos++;
  1243. } else if (operation === '\\') {
  1244. var previousOperation = _hunk.lines[j - 1] ? _hunk.lines[j - 1][0] : null;
  1245. if (previousOperation === '+') {
  1246. removeEOFNL = true;
  1247. } else if (previousOperation === '-') {
  1248. addEOFNL = true;
  1249. }
  1250. }
  1251. }
  1252. } // Handle EOFNL insertion/removal
  1253. if (removeEOFNL) {
  1254. while (!lines[lines.length - 1]) {
  1255. lines.pop();
  1256. delimiters.pop();
  1257. }
  1258. } else if (addEOFNL) {
  1259. lines.push('');
  1260. delimiters.push('\n');
  1261. }
  1262. for (var _k = 0; _k < lines.length - 1; _k++) {
  1263. lines[_k] = lines[_k] + delimiters[_k];
  1264. }
  1265. return lines.join('');
  1266. } // Wrapper that supports multiple file patches via callbacks.
  1267. function applyPatches(uniDiff, options) {
  1268. if (typeof uniDiff === 'string') {
  1269. uniDiff =
  1270. /*istanbul ignore start*/
  1271. (0, parse.parsePatch
  1272. /*istanbul ignore end*/
  1273. )(uniDiff);
  1274. }
  1275. var currentIndex = 0;
  1276. function processIndex() {
  1277. var index = uniDiff[currentIndex++];
  1278. if (!index) {
  1279. return options.complete();
  1280. }
  1281. options.loadFile(index, function (err, data) {
  1282. if (err) {
  1283. return options.complete(err);
  1284. }
  1285. var updatedContent = applyPatch(data, index, options);
  1286. options.patched(index, updatedContent, function (err) {
  1287. if (err) {
  1288. return options.complete(err);
  1289. }
  1290. processIndex();
  1291. });
  1292. });
  1293. }
  1294. processIndex();
  1295. }
  1296. });
  1297. unwrapExports(apply);
  1298. var create = createCommonjsModule(function (module, exports) {
  1299. /*istanbul ignore start*/
  1300. 'use strict';
  1301. exports.__esModule = true;
  1302. exports.
  1303. /*istanbul ignore end*/
  1304. structuredPatch = structuredPatch;
  1305. /*istanbul ignore start*/
  1306. exports.
  1307. /*istanbul ignore end*/
  1308. createTwoFilesPatch = createTwoFilesPatch;
  1309. /*istanbul ignore start*/
  1310. exports.
  1311. /*istanbul ignore end*/
  1312. createPatch = createPatch;
  1313. /*istanbul ignore start*/
  1314. function _toConsumableArray(arr) {
  1315. if (Array.isArray(arr)) {
  1316. for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) {
  1317. arr2[i] = arr[i];
  1318. }
  1319. return arr2;
  1320. } else {
  1321. return Array.from(arr);
  1322. }
  1323. }
  1324. /*istanbul ignore end*/
  1325. function structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
  1326. if (!options) {
  1327. options = {};
  1328. }
  1329. if (typeof options.context === 'undefined') {
  1330. options.context = 4;
  1331. }
  1332. var diff =
  1333. /*istanbul ignore start*/
  1334. (0, line.diffLines
  1335. /*istanbul ignore end*/
  1336. )(oldStr, newStr, options);
  1337. diff.push({
  1338. value: '',
  1339. lines: []
  1340. }); // Append an empty value to make cleanup easier
  1341. function contextLines(lines) {
  1342. return lines.map(function (entry) {
  1343. return ' ' + entry;
  1344. });
  1345. }
  1346. var hunks = [];
  1347. var oldRangeStart = 0,
  1348. newRangeStart = 0,
  1349. curRange = [],
  1350. oldLine = 1,
  1351. newLine = 1;
  1352. /*istanbul ignore start*/
  1353. var _loop = function _loop(
  1354. /*istanbul ignore end*/
  1355. i) {
  1356. var current = diff[i],
  1357. lines = current.lines || current.value.replace(/\n$/, '').split('\n');
  1358. current.lines = lines;
  1359. if (current.added || current.removed) {
  1360. /*istanbul ignore start*/
  1361. var _curRange;
  1362. /*istanbul ignore end*/
  1363. // If we have previous context, start with that
  1364. if (!oldRangeStart) {
  1365. var prev = diff[i - 1];
  1366. oldRangeStart = oldLine;
  1367. newRangeStart = newLine;
  1368. if (prev) {
  1369. curRange = options.context > 0 ? contextLines(prev.lines.slice(-options.context)) : [];
  1370. oldRangeStart -= curRange.length;
  1371. newRangeStart -= curRange.length;
  1372. }
  1373. } // Output our changes
  1374. /*istanbul ignore start*/
  1375. (_curRange =
  1376. /*istanbul ignore end*/
  1377. curRange).push.
  1378. /*istanbul ignore start*/
  1379. apply
  1380. /*istanbul ignore end*/
  1381. (
  1382. /*istanbul ignore start*/
  1383. _curRange
  1384. /*istanbul ignore end*/
  1385. ,
  1386. /*istanbul ignore start*/
  1387. _toConsumableArray(
  1388. /*istanbul ignore end*/
  1389. lines.map(function (entry) {
  1390. return (current.added ? '+' : '-') + entry;
  1391. }))); // Track the updated file position
  1392. if (current.added) {
  1393. newLine += lines.length;
  1394. } else {
  1395. oldLine += lines.length;
  1396. }
  1397. } else {
  1398. // Identical context lines. Track line changes
  1399. if (oldRangeStart) {
  1400. // Close out any changes that have been output (or join overlapping)
  1401. if (lines.length <= options.context * 2 && i < diff.length - 2) {
  1402. /*istanbul ignore start*/
  1403. var _curRange2;
  1404. /*istanbul ignore end*/
  1405. // Overlapping
  1406. /*istanbul ignore start*/
  1407. (_curRange2 =
  1408. /*istanbul ignore end*/
  1409. curRange).push.
  1410. /*istanbul ignore start*/
  1411. apply
  1412. /*istanbul ignore end*/
  1413. (
  1414. /*istanbul ignore start*/
  1415. _curRange2
  1416. /*istanbul ignore end*/
  1417. ,
  1418. /*istanbul ignore start*/
  1419. _toConsumableArray(
  1420. /*istanbul ignore end*/
  1421. contextLines(lines)));
  1422. } else {
  1423. /*istanbul ignore start*/
  1424. var _curRange3;
  1425. /*istanbul ignore end*/
  1426. // end the range and output
  1427. var contextSize = Math.min(lines.length, options.context);
  1428. /*istanbul ignore start*/
  1429. (_curRange3 =
  1430. /*istanbul ignore end*/
  1431. curRange).push.
  1432. /*istanbul ignore start*/
  1433. apply
  1434. /*istanbul ignore end*/
  1435. (
  1436. /*istanbul ignore start*/
  1437. _curRange3
  1438. /*istanbul ignore end*/
  1439. ,
  1440. /*istanbul ignore start*/
  1441. _toConsumableArray(
  1442. /*istanbul ignore end*/
  1443. contextLines(lines.slice(0, contextSize))));
  1444. var hunk = {
  1445. oldStart: oldRangeStart,
  1446. oldLines: oldLine - oldRangeStart + contextSize,
  1447. newStart: newRangeStart,
  1448. newLines: newLine - newRangeStart + contextSize,
  1449. lines: curRange
  1450. };
  1451. if (i >= diff.length - 2 && lines.length <= options.context) {
  1452. // EOF is inside this hunk
  1453. var oldEOFNewline = /\n$/.test(oldStr);
  1454. var newEOFNewline = /\n$/.test(newStr);
  1455. if (lines.length == 0 && !oldEOFNewline) {
  1456. // special case: old has no eol and no trailing context; no-nl can end up before adds
  1457. curRange.splice(hunk.oldLines, 0, '\\ No newline at end of file');
  1458. } else if (!oldEOFNewline || !newEOFNewline) {
  1459. curRange.push('\\ No newline at end of file');
  1460. }
  1461. }
  1462. hunks.push(hunk);
  1463. oldRangeStart = 0;
  1464. newRangeStart = 0;
  1465. curRange = [];
  1466. }
  1467. }
  1468. oldLine += lines.length;
  1469. newLine += lines.length;
  1470. }
  1471. };
  1472. for (var i = 0; i < diff.length; i++) {
  1473. /*istanbul ignore start*/
  1474. _loop(
  1475. /*istanbul ignore end*/
  1476. i);
  1477. }
  1478. return {
  1479. oldFileName: oldFileName,
  1480. newFileName: newFileName,
  1481. oldHeader: oldHeader,
  1482. newHeader: newHeader,
  1483. hunks: hunks
  1484. };
  1485. }
  1486. function createTwoFilesPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
  1487. var diff = structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options);
  1488. var ret = [];
  1489. if (oldFileName == newFileName) {
  1490. ret.push('Index: ' + oldFileName);
  1491. }
  1492. ret.push('===================================================================');
  1493. ret.push('--- ' + diff.oldFileName + (typeof diff.oldHeader === 'undefined' ? '' : '\t' + diff.oldHeader));
  1494. ret.push('+++ ' + diff.newFileName + (typeof diff.newHeader === 'undefined' ? '' : '\t' + diff.newHeader));
  1495. for (var i = 0; i < diff.hunks.length; i++) {
  1496. var hunk = diff.hunks[i];
  1497. ret.push('@@ -' + hunk.oldStart + ',' + hunk.oldLines + ' +' + hunk.newStart + ',' + hunk.newLines + ' @@');
  1498. ret.push.apply(ret, hunk.lines);
  1499. }
  1500. return ret.join('\n') + '\n';
  1501. }
  1502. function createPatch(fileName, oldStr, newStr, oldHeader, newHeader, options) {
  1503. return createTwoFilesPatch(fileName, fileName, oldStr, newStr, oldHeader, newHeader, options);
  1504. }
  1505. });
  1506. unwrapExports(create);
  1507. var dmp = createCommonjsModule(function (module, exports) {
  1508. /*istanbul ignore start*/
  1509. "use strict";
  1510. exports.__esModule = true;
  1511. exports.
  1512. /*istanbul ignore end*/
  1513. convertChangesToDMP = convertChangesToDMP; // See: http://code.google.com/p/google-diff-match-patch/wiki/API
  1514. function convertChangesToDMP(changes) {
  1515. var ret = [],
  1516. change =
  1517. /*istanbul ignore start*/
  1518. void 0
  1519. /*istanbul ignore end*/
  1520. ,
  1521. operation =
  1522. /*istanbul ignore start*/
  1523. void 0;
  1524. for (var i = 0; i < changes.length; i++) {
  1525. change = changes[i];
  1526. if (change.added) {
  1527. operation = 1;
  1528. } else if (change.removed) {
  1529. operation = -1;
  1530. } else {
  1531. operation = 0;
  1532. }
  1533. ret.push([operation, change.value]);
  1534. }
  1535. return ret;
  1536. }
  1537. });
  1538. unwrapExports(dmp);
  1539. var xml = createCommonjsModule(function (module, exports) {
  1540. /*istanbul ignore start*/
  1541. 'use strict';
  1542. exports.__esModule = true;
  1543. exports.
  1544. /*istanbul ignore end*/
  1545. convertChangesToXML = convertChangesToXML;
  1546. function convertChangesToXML(changes) {
  1547. var ret = [];
  1548. for (var i = 0; i < changes.length; i++) {
  1549. var change = changes[i];
  1550. if (change.added) {
  1551. ret.push('<ins>');
  1552. } else if (change.removed) {
  1553. ret.push('<del>');
  1554. }
  1555. ret.push(escapeHTML(change.value));
  1556. if (change.added) {
  1557. ret.push('</ins>');
  1558. } else if (change.removed) {
  1559. ret.push('</del>');
  1560. }
  1561. }
  1562. return ret.join('');
  1563. }
  1564. function escapeHTML(s) {
  1565. var n = s;
  1566. n = n.replace(/&/g, '&amp;');
  1567. n = n.replace(/</g, '&lt;');
  1568. n = n.replace(/>/g, '&gt;');
  1569. n = n.replace(/"/g, '&quot;');
  1570. return n;
  1571. }
  1572. });
  1573. unwrapExports(xml);
  1574. var lib = createCommonjsModule(function (module, exports) {
  1575. /*istanbul ignore start*/
  1576. 'use strict';
  1577. exports.__esModule = true;
  1578. exports.canonicalize = exports.convertChangesToXML = exports.convertChangesToDMP = exports.parsePatch = exports.applyPatches = exports.applyPatch = exports.createPatch = exports.createTwoFilesPatch = exports.structuredPatch = exports.diffArrays = exports.diffJson = exports.diffCss = exports.diffSentences = exports.diffTrimmedLines = exports.diffLines = exports.diffWordsWithSpace = exports.diffWords = exports.diffChars = exports.Diff = undefined;
  1579. /*istanbul ignore end*/
  1580. /*istanbul ignore start*/
  1581. var _base2 = _interopRequireDefault(base);
  1582. /*istanbul ignore end*/
  1583. /*istanbul ignore start*/
  1584. function _interopRequireDefault(obj) {
  1585. return obj && obj.__esModule ? obj : {
  1586. 'default': obj
  1587. };
  1588. }
  1589. exports.
  1590. /*istanbul ignore end*/
  1591. Diff = _base2['default'];
  1592. /*istanbul ignore start*/
  1593. exports.
  1594. /*istanbul ignore end*/
  1595. diffChars = character.diffChars;
  1596. /*istanbul ignore start*/
  1597. exports.
  1598. /*istanbul ignore end*/
  1599. diffWords = word.diffWords;
  1600. /*istanbul ignore start*/
  1601. exports.
  1602. /*istanbul ignore end*/
  1603. diffWordsWithSpace = word.diffWordsWithSpace;
  1604. /*istanbul ignore start*/
  1605. exports.
  1606. /*istanbul ignore end*/
  1607. diffLines = line.diffLines;
  1608. /*istanbul ignore start*/
  1609. exports.
  1610. /*istanbul ignore end*/
  1611. diffTrimmedLines = line.diffTrimmedLines;
  1612. /*istanbul ignore start*/
  1613. exports.
  1614. /*istanbul ignore end*/
  1615. diffSentences = sentence.diffSentences;
  1616. /*istanbul ignore start*/
  1617. exports.
  1618. /*istanbul ignore end*/
  1619. diffCss = css.diffCss;
  1620. /*istanbul ignore start*/
  1621. exports.
  1622. /*istanbul ignore end*/
  1623. diffJson = json.diffJson;
  1624. /*istanbul ignore start*/
  1625. exports.
  1626. /*istanbul ignore end*/
  1627. diffArrays = array.diffArrays;
  1628. /*istanbul ignore start*/
  1629. exports.
  1630. /*istanbul ignore end*/
  1631. structuredPatch = create.structuredPatch;
  1632. /*istanbul ignore start*/
  1633. exports.
  1634. /*istanbul ignore end*/
  1635. createTwoFilesPatch = create.createTwoFilesPatch;
  1636. /*istanbul ignore start*/
  1637. exports.
  1638. /*istanbul ignore end*/
  1639. createPatch = create.createPatch;
  1640. /*istanbul ignore start*/
  1641. exports.
  1642. /*istanbul ignore end*/
  1643. applyPatch = apply.applyPatch;
  1644. /*istanbul ignore start*/
  1645. exports.
  1646. /*istanbul ignore end*/
  1647. applyPatches = apply.applyPatches;
  1648. /*istanbul ignore start*/
  1649. exports.
  1650. /*istanbul ignore end*/
  1651. parsePatch = parse.parsePatch;
  1652. /*istanbul ignore start*/
  1653. exports.
  1654. /*istanbul ignore end*/
  1655. convertChangesToDMP = dmp.convertChangesToDMP;
  1656. /*istanbul ignore start*/
  1657. exports.
  1658. /*istanbul ignore end*/
  1659. convertChangesToXML = xml.convertChangesToXML;
  1660. /*istanbul ignore start*/
  1661. exports.
  1662. /*istanbul ignore end*/
  1663. canonicalize = json.canonicalize;
  1664. /* See LICENSE file for terms of use */
  1665. /*
  1666. * Text diff implementation.
  1667. *
  1668. * This library supports the following APIS:
  1669. * JsDiff.diffChars: Character by character diff
  1670. * JsDiff.diffWords: Word (as defined by \b regex) diff which ignores whitespace
  1671. * JsDiff.diffLines: Line based diff
  1672. *
  1673. * JsDiff.diffCss: Diff targeted at CSS content
  1674. *
  1675. * These methods are based on the implementation proposed in
  1676. * "An O(ND) Difference Algorithm and its Variations" (Myers, 1986).
  1677. * http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.4.6927
  1678. */
  1679. });
  1680. unwrapExports(lib);
  1681. var ConfigError =
  1682. /*#__PURE__*/
  1683. function (_Error) {
  1684. _inherits(ConfigError, _Error);
  1685. function ConfigError() {
  1686. _classCallCheck(this, ConfigError);
  1687. return _possibleConstructorReturn(this, _getPrototypeOf(ConfigError).apply(this, arguments));
  1688. }
  1689. return ConfigError;
  1690. }(_wrapNativeSuper(Error));
  1691. var DebugError =
  1692. /*#__PURE__*/
  1693. function (_Error2) {
  1694. _inherits(DebugError, _Error2);
  1695. function DebugError() {
  1696. _classCallCheck(this, DebugError);
  1697. return _possibleConstructorReturn(this, _getPrototypeOf(DebugError).apply(this, arguments));
  1698. }
  1699. return DebugError;
  1700. }(_wrapNativeSuper(Error));
  1701. var UndefinedParserError$1 =
  1702. /*#__PURE__*/
  1703. function (_Error3) {
  1704. _inherits(UndefinedParserError, _Error3);
  1705. function UndefinedParserError() {
  1706. _classCallCheck(this, UndefinedParserError);
  1707. return _possibleConstructorReturn(this, _getPrototypeOf(UndefinedParserError).apply(this, arguments));
  1708. }
  1709. return UndefinedParserError;
  1710. }(_wrapNativeSuper(Error));
  1711. var errors = {
  1712. ConfigError: ConfigError,
  1713. DebugError: DebugError,
  1714. UndefinedParserError: UndefinedParserError$1
  1715. };
  1716. var global$1 = typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {};
  1717. // based off https://github.com/defunctzombie/node-process/blob/master/browser.js
  1718. function defaultSetTimout() {
  1719. throw new Error('setTimeout has not been defined');
  1720. }
  1721. function defaultClearTimeout() {
  1722. throw new Error('clearTimeout has not been defined');
  1723. }
  1724. var cachedSetTimeout = defaultSetTimout;
  1725. var cachedClearTimeout = defaultClearTimeout;
  1726. if (typeof global$1.setTimeout === 'function') {
  1727. cachedSetTimeout = setTimeout;
  1728. }
  1729. if (typeof global$1.clearTimeout === 'function') {
  1730. cachedClearTimeout = clearTimeout;
  1731. }
  1732. function runTimeout(fun) {
  1733. if (cachedSetTimeout === setTimeout) {
  1734. //normal enviroments in sane situations
  1735. return setTimeout(fun, 0);
  1736. } // if setTimeout wasn't available but was latter defined
  1737. if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
  1738. cachedSetTimeout = setTimeout;
  1739. return setTimeout(fun, 0);
  1740. }
  1741. try {
  1742. // when when somebody has screwed with setTimeout but no I.E. maddness
  1743. return cachedSetTimeout(fun, 0);
  1744. } catch (e) {
  1745. try {
  1746. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  1747. return cachedSetTimeout.call(null, fun, 0);
  1748. } catch (e) {
  1749. // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
  1750. return cachedSetTimeout.call(this, fun, 0);
  1751. }
  1752. }
  1753. }
  1754. function runClearTimeout(marker) {
  1755. if (cachedClearTimeout === clearTimeout) {
  1756. //normal enviroments in sane situations
  1757. return clearTimeout(marker);
  1758. } // if clearTimeout wasn't available but was latter defined
  1759. if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
  1760. cachedClearTimeout = clearTimeout;
  1761. return clearTimeout(marker);
  1762. }
  1763. try {
  1764. // when when somebody has screwed with setTimeout but no I.E. maddness
  1765. return cachedClearTimeout(marker);
  1766. } catch (e) {
  1767. try {
  1768. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  1769. return cachedClearTimeout.call(null, marker);
  1770. } catch (e) {
  1771. // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
  1772. // Some versions of I.E. have different rules for clearTimeout vs setTimeout
  1773. return cachedClearTimeout.call(this, marker);
  1774. }
  1775. }
  1776. }
  1777. var queue = [];
  1778. var draining = false;
  1779. var currentQueue;
  1780. var queueIndex = -1;
  1781. function cleanUpNextTick() {
  1782. if (!draining || !currentQueue) {
  1783. return;
  1784. }
  1785. draining = false;
  1786. if (currentQueue.length) {
  1787. queue = currentQueue.concat(queue);
  1788. } else {
  1789. queueIndex = -1;
  1790. }
  1791. if (queue.length) {
  1792. drainQueue();
  1793. }
  1794. }
  1795. function drainQueue() {
  1796. if (draining) {
  1797. return;
  1798. }
  1799. var timeout = runTimeout(cleanUpNextTick);
  1800. draining = true;
  1801. var len = queue.length;
  1802. while (len) {
  1803. currentQueue = queue;
  1804. queue = [];
  1805. while (++queueIndex < len) {
  1806. if (currentQueue) {
  1807. currentQueue[queueIndex].run();
  1808. }
  1809. }
  1810. queueIndex = -1;
  1811. len = queue.length;
  1812. }
  1813. currentQueue = null;
  1814. draining = false;
  1815. runClearTimeout(timeout);
  1816. }
  1817. function nextTick(fun) {
  1818. var args = new Array(arguments.length - 1);
  1819. if (arguments.length > 1) {
  1820. for (var i = 1; i < arguments.length; i++) {
  1821. args[i - 1] = arguments[i];
  1822. }
  1823. }
  1824. queue.push(new Item(fun, args));
  1825. if (queue.length === 1 && !draining) {
  1826. runTimeout(drainQueue);
  1827. }
  1828. } // v8 likes predictible objects
  1829. function Item(fun, array) {
  1830. this.fun = fun;
  1831. this.array = array;
  1832. }
  1833. Item.prototype.run = function () {
  1834. this.fun.apply(null, this.array);
  1835. };
  1836. var title = 'browser';
  1837. var platform = 'browser';
  1838. var browser = true;
  1839. var env = {};
  1840. var argv = [];
  1841. var version$2 = ''; // empty string to avoid regexp issues
  1842. var versions = {};
  1843. var release = {};
  1844. var config = {};
  1845. function noop() {}
  1846. var on = noop;
  1847. var addListener = noop;
  1848. var once = noop;
  1849. var off = noop;
  1850. var removeListener = noop;
  1851. var removeAllListeners = noop;
  1852. var emit = noop;
  1853. function binding(name) {
  1854. throw new Error('process.binding is not supported');
  1855. }
  1856. function cwd() {
  1857. return '/';
  1858. }
  1859. function chdir(dir) {
  1860. throw new Error('process.chdir is not supported');
  1861. }
  1862. function umask() {
  1863. return 0;
  1864. } // from https://github.com/kumavis/browser-process-hrtime/blob/master/index.js
  1865. var performance = global$1.performance || {};
  1866. var performanceNow = performance.now || performance.mozNow || performance.msNow || performance.oNow || performance.webkitNow || function () {
  1867. return new Date().getTime();
  1868. }; // generate timestamp or delta
  1869. // see http://nodejs.org/api/process.html#process_process_hrtime
  1870. function hrtime(previousTimestamp) {
  1871. var clocktime = performanceNow.call(performance) * 1e-3;
  1872. var seconds = Math.floor(clocktime);
  1873. var nanoseconds = Math.floor(clocktime % 1 * 1e9);
  1874. if (previousTimestamp) {
  1875. seconds = seconds - previousTimestamp[0];
  1876. nanoseconds = nanoseconds - previousTimestamp[1];
  1877. if (nanoseconds < 0) {
  1878. seconds--;
  1879. nanoseconds += 1e9;
  1880. }
  1881. }
  1882. return [seconds, nanoseconds];
  1883. }
  1884. var startTime = new Date();
  1885. function uptime() {
  1886. var currentTime = new Date();
  1887. var dif = currentTime - startTime;
  1888. return dif / 1000;
  1889. }
  1890. var process = {
  1891. nextTick: nextTick,
  1892. title: title,
  1893. browser: browser,
  1894. env: env,
  1895. argv: argv,
  1896. version: version$2,
  1897. versions: versions,
  1898. on: on,
  1899. addListener: addListener,
  1900. once: once,
  1901. off: off,
  1902. removeListener: removeListener,
  1903. removeAllListeners: removeAllListeners,
  1904. emit: emit,
  1905. binding: binding,
  1906. cwd: cwd,
  1907. chdir: chdir,
  1908. umask: umask,
  1909. hrtime: hrtime,
  1910. platform: platform,
  1911. release: release,
  1912. config: config,
  1913. uptime: uptime
  1914. };
  1915. var semver = createCommonjsModule(function (module, exports) {
  1916. exports = module.exports = SemVer; // The debug function is excluded entirely from the minified version.
  1917. /* nomin */
  1918. var debug;
  1919. /* nomin */
  1920. if (_typeof(process) === 'object' &&
  1921. /* nomin */
  1922. process.env &&
  1923. /* nomin */
  1924. process.env.NODE_DEBUG &&
  1925. /* nomin */
  1926. /\bsemver\b/i.test(process.env.NODE_DEBUG))
  1927. /* nomin */
  1928. debug = function debug() {
  1929. /* nomin */
  1930. var args = Array.prototype.slice.call(arguments, 0);
  1931. /* nomin */
  1932. args.unshift('SEMVER');
  1933. /* nomin */
  1934. console.log.apply(console, args);
  1935. /* nomin */
  1936. };
  1937. /* nomin */
  1938. else
  1939. /* nomin */
  1940. debug = function debug() {}; // Note: this is the semver.org version of the spec that it implements
  1941. // Not necessarily the package version of this code.
  1942. exports.SEMVER_SPEC_VERSION = '2.0.0';
  1943. var MAX_LENGTH = 256;
  1944. var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || 9007199254740991; // The actual regexps go on exports.re
  1945. var re = exports.re = [];
  1946. var src = exports.src = [];
  1947. var R = 0; // The following Regular Expressions can be used for tokenizing,
  1948. // validating, and parsing SemVer version strings.
  1949. // ## Numeric Identifier
  1950. // A single `0`, or a non-zero digit followed by zero or more digits.
  1951. var NUMERICIDENTIFIER = R++;
  1952. src[NUMERICIDENTIFIER] = '0|[1-9]\\d*';
  1953. var NUMERICIDENTIFIERLOOSE = R++;
  1954. src[NUMERICIDENTIFIERLOOSE] = '[0-9]+'; // ## Non-numeric Identifier
  1955. // Zero or more digits, followed by a letter or hyphen, and then zero or
  1956. // more letters, digits, or hyphens.
  1957. var NONNUMERICIDENTIFIER = R++;
  1958. src[NONNUMERICIDENTIFIER] = '\\d*[a-zA-Z-][a-zA-Z0-9-]*'; // ## Main Version
  1959. // Three dot-separated numeric identifiers.
  1960. var MAINVERSION = R++;
  1961. src[MAINVERSION] = '(' + src[NUMERICIDENTIFIER] + ')\\.' + '(' + src[NUMERICIDENTIFIER] + ')\\.' + '(' + src[NUMERICIDENTIFIER] + ')';
  1962. var MAINVERSIONLOOSE = R++;
  1963. src[MAINVERSIONLOOSE] = '(' + src[NUMERICIDENTIFIERLOOSE] + ')\\.' + '(' + src[NUMERICIDENTIFIERLOOSE] + ')\\.' + '(' + src[NUMERICIDENTIFIERLOOSE] + ')'; // ## Pre-release Version Identifier
  1964. // A numeric identifier, or a non-numeric identifier.
  1965. var PRERELEASEIDENTIFIER = R++;
  1966. src[PRERELEASEIDENTIFIER] = '(?:' + src[NUMERICIDENTIFIER] + '|' + src[NONNUMERICIDENTIFIER] + ')';
  1967. var PRERELEASEIDENTIFIERLOOSE = R++;
  1968. src[PRERELEASEIDENTIFIERLOOSE] = '(?:' + src[NUMERICIDENTIFIERLOOSE] + '|' + src[NONNUMERICIDENTIFIER] + ')'; // ## Pre-release Version
  1969. // Hyphen, followed by one or more dot-separated pre-release version
  1970. // identifiers.
  1971. var PRERELEASE = R++;
  1972. src[PRERELEASE] = '(?:-(' + src[PRERELEASEIDENTIFIER] + '(?:\\.' + src[PRERELEASEIDENTIFIER] + ')*))';
  1973. var PRERELEASELOOSE = R++;
  1974. src[PRERELEASELOOSE] = '(?:-?(' + src[PRERELEASEIDENTIFIERLOOSE] + '(?:\\.' + src[PRERELEASEIDENTIFIERLOOSE] + ')*))'; // ## Build Metadata Identifier
  1975. // Any combination of digits, letters, or hyphens.
  1976. var BUILDIDENTIFIER = R++;
  1977. src[BUILDIDENTIFIER] = '[0-9A-Za-z-]+'; // ## Build Metadata
  1978. // Plus sign, followed by one or more period-separated build metadata
  1979. // identifiers.
  1980. var BUILD = R++;
  1981. src[BUILD] = '(?:\\+(' + src[BUILDIDENTIFIER] + '(?:\\.' + src[BUILDIDENTIFIER] + ')*))'; // ## Full Version String
  1982. // A main version, followed optionally by a pre-release version and
  1983. // build metadata.
  1984. // Note that the only major, minor, patch, and pre-release sections of
  1985. // the version string are capturing groups. The build metadata is not a
  1986. // capturing group, because it should not ever be used in version
  1987. // comparison.
  1988. var FULL = R++;
  1989. var FULLPLAIN = 'v?' + src[MAINVERSION] + src[PRERELEASE] + '?' + src[BUILD] + '?';
  1990. src[FULL] = '^' + FULLPLAIN + '$'; // like full, but allows v1.2.3 and =1.2.3, which people do sometimes.
  1991. // also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty
  1992. // common in the npm registry.
  1993. var LOOSEPLAIN = '[v=\\s]*' + src[MAINVERSIONLOOSE] + src[PRERELEASELOOSE] + '?' + src[BUILD] + '?';
  1994. var LOOSE = R++;
  1995. src[LOOSE] = '^' + LOOSEPLAIN + '$';
  1996. var GTLT = R++;
  1997. src[GTLT] = '((?:<|>)?=?)'; // Something like "2.*" or "1.2.x".
  1998. // Note that "x.x" is a valid xRange identifer, meaning "any version"
  1999. // Only the first item is strictly required.
  2000. var XRANGEIDENTIFIERLOOSE = R++;
  2001. src[XRANGEIDENTIFIERLOOSE] = src[NUMERICIDENTIFIERLOOSE] + '|x|X|\\*';
  2002. var XRANGEIDENTIFIER = R++;
  2003. src[XRANGEIDENTIFIER] = src[NUMERICIDENTIFIER] + '|x|X|\\*';
  2004. var XRANGEPLAIN = R++;
  2005. src[XRANGEPLAIN] = '[v=\\s]*(' + src[XRANGEIDENTIFIER] + ')' + '(?:\\.(' + src[XRANGEIDENTIFIER] + ')' + '(?:\\.(' + src[XRANGEIDENTIFIER] + ')' + '(?:' + src[PRERELEASE] + ')?' + src[BUILD] + '?' + ')?)?';
  2006. var XRANGEPLAINLOOSE = R++;
  2007. src[XRANGEPLAINLOOSE] = '[v=\\s]*(' + src[XRANGEIDENTIFIERLOOSE] + ')' + '(?:\\.(' + src[XRANGEIDENTIFIERLOOSE] + ')' + '(?:\\.(' + src[XRANGEIDENTIFIERLOOSE] + ')' + '(?:' + src[PRERELEASELOOSE] + ')?' + src[BUILD] + '?' + ')?)?';
  2008. var XRANGE = R++;
  2009. src[XRANGE] = '^' + src[GTLT] + '\\s*' + src[XRANGEPLAIN] + '$';
  2010. var XRANGELOOSE = R++;
  2011. src[XRANGELOOSE] = '^' + src[GTLT] + '\\s*' + src[XRANGEPLAINLOOSE] + '$'; // Tilde ranges.
  2012. // Meaning is "reasonably at or greater than"
  2013. var LONETILDE = R++;
  2014. src[LONETILDE] = '(?:~>?)';
  2015. var TILDETRIM = R++;
  2016. src[TILDETRIM] = '(\\s*)' + src[LONETILDE] + '\\s+';
  2017. re[TILDETRIM] = new RegExp(src[TILDETRIM], 'g');
  2018. var tildeTrimReplace = '$1~';
  2019. var TILDE = R++;
  2020. src[TILDE] = '^' + src[LONETILDE] + src[XRANGEPLAIN] + '$';
  2021. var TILDELOOSE = R++;
  2022. src[TILDELOOSE] = '^' + src[LONETILDE] + src[XRANGEPLAINLOOSE] + '$'; // Caret ranges.
  2023. // Meaning is "at least and backwards compatible with"
  2024. var LONECARET = R++;
  2025. src[LONECARET] = '(?:\\^)';
  2026. var CARETTRIM = R++;
  2027. src[CARETTRIM] = '(\\s*)' + src[LONECARET] + '\\s+';
  2028. re[CARETTRIM] = new RegExp(src[CARETTRIM], 'g');
  2029. var caretTrimReplace = '$1^';
  2030. var CARET = R++;
  2031. src[CARET] = '^' + src[LONECARET] + src[XRANGEPLAIN] + '$';
  2032. var CARETLOOSE = R++;
  2033. src[CARETLOOSE] = '^' + src[LONECARET] + src[XRANGEPLAINLOOSE] + '$'; // A simple gt/lt/eq thing, or just "" to indicate "any version"
  2034. var COMPARATORLOOSE = R++;
  2035. src[COMPARATORLOOSE] = '^' + src[GTLT] + '\\s*(' + LOOSEPLAIN + ')$|^$';
  2036. var COMPARATOR = R++;
  2037. src[COMPARATOR] = '^' + src[GTLT] + '\\s*(' + FULLPLAIN + ')$|^$'; // An expression to strip any whitespace between the gtlt and the thing
  2038. // it modifies, so that `> 1.2.3` ==> `>1.2.3`
  2039. var COMPARATORTRIM = R++;
  2040. src[COMPARATORTRIM] = '(\\s*)' + src[GTLT] + '\\s*(' + LOOSEPLAIN + '|' + src[XRANGEPLAIN] + ')'; // this one has to use the /g flag
  2041. re[COMPARATORTRIM] = new RegExp(src[COMPARATORTRIM], 'g');
  2042. var comparatorTrimReplace = '$1$2$3'; // Something like `1.2.3 - 1.2.4`
  2043. // Note that these all use the loose form, because they'll be
  2044. // checked against either the strict or loose comparator form
  2045. // later.
  2046. var HYPHENRANGE = R++;
  2047. src[HYPHENRANGE] = '^\\s*(' + src[XRANGEPLAIN] + ')' + '\\s+-\\s+' + '(' + src[XRANGEPLAIN] + ')' + '\\s*$';
  2048. var HYPHENRANGELOOSE = R++;
  2049. src[HYPHENRANGELOOSE] = '^\\s*(' + src[XRANGEPLAINLOOSE] + ')' + '\\s+-\\s+' + '(' + src[XRANGEPLAINLOOSE] + ')' + '\\s*$'; // Star ranges basically just allow anything at all.
  2050. var STAR = R++;
  2051. src[STAR] = '(<|>)?=?\\s*\\*'; // Compile to actual regexp objects.
  2052. // All are flag-free, unless they were created above with a flag.
  2053. for (var i = 0; i < R; i++) {
  2054. debug(i, src[i]);
  2055. if (!re[i]) re[i] = new RegExp(src[i]);
  2056. }
  2057. exports.parse = parse;
  2058. function parse(version, loose) {
  2059. if (version instanceof SemVer) return version;
  2060. if (typeof version !== 'string') return null;
  2061. if (version.length > MAX_LENGTH) return null;
  2062. var r = loose ? re[LOOSE] : re[FULL];
  2063. if (!r.test(version)) return null;
  2064. try {
  2065. return new SemVer(version, loose);
  2066. } catch (er) {
  2067. return null;
  2068. }
  2069. }
  2070. exports.valid = valid;
  2071. function valid(version, loose) {
  2072. var v = parse(version, loose);
  2073. return v ? v.version : null;
  2074. }
  2075. exports.clean = clean;
  2076. function clean(version, loose) {
  2077. var s = parse(version.trim().replace(/^[=v]+/, ''), loose);
  2078. return s ? s.version : null;
  2079. }
  2080. exports.SemVer = SemVer;
  2081. function SemVer(version, loose) {
  2082. if (version instanceof SemVer) {
  2083. if (version.loose === loose) return version;else version = version.version;
  2084. } else if (typeof version !== 'string') {
  2085. throw new TypeError('Invalid Version: ' + version);
  2086. }
  2087. if (version.length > MAX_LENGTH) throw new TypeError('version is longer than ' + MAX_LENGTH + ' characters');
  2088. if (!(this instanceof SemVer)) return new SemVer(version, loose);
  2089. debug('SemVer', version, loose);
  2090. this.loose = loose;
  2091. var m = version.trim().match(loose ? re[LOOSE] : re[FULL]);
  2092. if (!m) throw new TypeError('Invalid Version: ' + version);
  2093. this.raw = version; // these are actually numbers
  2094. this.major = +m[1];
  2095. this.minor = +m[2];
  2096. this.patch = +m[3];
  2097. if (this.major > MAX_SAFE_INTEGER || this.major < 0) throw new TypeError('Invalid major version');
  2098. if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) throw new TypeError('Invalid minor version');
  2099. if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) throw new TypeError('Invalid patch version'); // numberify any prerelease numeric ids
  2100. if (!m[4]) this.prerelease = [];else this.prerelease = m[4].split('.').map(function (id) {
  2101. if (/^[0-9]+$/.test(id)) {
  2102. var num = +id;
  2103. if (num >= 0 && num < MAX_SAFE_INTEGER) return num;
  2104. }
  2105. return id;
  2106. });
  2107. this.build = m[5] ? m[5].split('.') : [];
  2108. this.format();
  2109. }
  2110. SemVer.prototype.format = function () {
  2111. this.version = this.major + '.' + this.minor + '.' + this.patch;
  2112. if (this.prerelease.length) this.version += '-' + this.prerelease.join('.');
  2113. return this.version;
  2114. };
  2115. SemVer.prototype.toString = function () {
  2116. return this.version;
  2117. };
  2118. SemVer.prototype.compare = function (other) {
  2119. debug('SemVer.compare', this.version, this.loose, other);
  2120. if (!(other instanceof SemVer)) other = new SemVer(other, this.loose);
  2121. return this.compareMain(other) || this.comparePre(other);
  2122. };
  2123. SemVer.prototype.compareMain = function (other) {
  2124. if (!(other instanceof SemVer)) other = new SemVer(other, this.loose);
  2125. return compareIdentifiers(this.major, other.major) || compareIdentifiers(this.minor, other.minor) || compareIdentifiers(this.patch, other.patch);
  2126. };
  2127. SemVer.prototype.comparePre = function (other) {
  2128. if (!(other instanceof SemVer)) other = new SemVer(other, this.loose); // NOT having a prerelease is > having one
  2129. if (this.prerelease.length && !other.prerelease.length) return -1;else if (!this.prerelease.length && other.prerelease.length) return 1;else if (!this.prerelease.length && !other.prerelease.length) return 0;
  2130. var i = 0;
  2131. do {
  2132. var a = this.prerelease[i];
  2133. var b = other.prerelease[i];
  2134. debug('prerelease compare', i, a, b);
  2135. if (a === undefined && b === undefined) return 0;else if (b === undefined) return 1;else if (a === undefined) return -1;else if (a === b) continue;else return compareIdentifiers(a, b);
  2136. } while (++i);
  2137. }; // preminor will bump the version up to the next minor release, and immediately
  2138. // down to pre-release. premajor and prepatch work the same way.
  2139. SemVer.prototype.inc = function (release$$1, identifier) {
  2140. switch (release$$1) {
  2141. case 'premajor':
  2142. this.prerelease.length = 0;
  2143. this.patch = 0;
  2144. this.minor = 0;
  2145. this.major++;
  2146. this.inc('pre', identifier);
  2147. break;
  2148. case 'preminor':
  2149. this.prerelease.length = 0;
  2150. this.patch = 0;
  2151. this.minor++;
  2152. this.inc('pre', identifier);
  2153. break;
  2154. case 'prepatch':
  2155. // If this is already a prerelease, it will bump to the next version
  2156. // drop any prereleases that might already exist, since they are not
  2157. // relevant at this point.
  2158. this.prerelease.length = 0;
  2159. this.inc('patch', identifier);
  2160. this.inc('pre', identifier);
  2161. break;
  2162. // If the input is a non-prerelease version, this acts the same as
  2163. // prepatch.
  2164. case 'prerelease':
  2165. if (this.prerelease.length === 0) this.inc('patch', identifier);
  2166. this.inc('pre', identifier);
  2167. break;
  2168. case 'major':
  2169. // If this is a pre-major version, bump up to the same major version.
  2170. // Otherwise increment major.
  2171. // 1.0.0-5 bumps to 1.0.0
  2172. // 1.1.0 bumps to 2.0.0
  2173. if (this.minor !== 0 || this.patch !== 0 || this.prerelease.length === 0) this.major++;
  2174. this.minor = 0;
  2175. this.patch = 0;
  2176. this.prerelease = [];
  2177. break;
  2178. case 'minor':
  2179. // If this is a pre-minor version, bump up to the same minor version.
  2180. // Otherwise increment minor.
  2181. // 1.2.0-5 bumps to 1.2.0
  2182. // 1.2.1 bumps to 1.3.0
  2183. if (this.patch !== 0 || this.prerelease.length === 0) this.minor++;
  2184. this.patch = 0;
  2185. this.prerelease = [];
  2186. break;
  2187. case 'patch':
  2188. // If this is not a pre-release version, it will increment the patch.
  2189. // If it is a pre-release it will bump up to the same patch version.
  2190. // 1.2.0-5 patches to 1.2.0
  2191. // 1.2.0 patches to 1.2.1
  2192. if (this.prerelease.length === 0) this.patch++;
  2193. this.prerelease = [];
  2194. break;
  2195. // This probably shouldn't be used publicly.
  2196. // 1.0.0 "pre" would become 1.0.0-0 which is the wrong direction.
  2197. case 'pre':
  2198. if (this.prerelease.length === 0) this.prerelease = [0];else {
  2199. var i = this.prerelease.length;
  2200. while (--i >= 0) {
  2201. if (typeof this.prerelease[i] === 'number') {
  2202. this.prerelease[i]++;
  2203. i = -2;
  2204. }
  2205. }
  2206. if (i === -1) // didn't increment anything
  2207. this.prerelease.push(0);
  2208. }
  2209. if (identifier) {
  2210. // 1.2.0-beta.1 bumps to 1.2.0-beta.2,
  2211. // 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0
  2212. if (this.prerelease[0] === identifier) {
  2213. if (isNaN(this.prerelease[1])) this.prerelease = [identifier, 0];
  2214. } else this.prerelease = [identifier, 0];
  2215. }
  2216. break;
  2217. default:
  2218. throw new Error('invalid increment argument: ' + release$$1);
  2219. }
  2220. this.format();
  2221. this.raw = this.version;
  2222. return this;
  2223. };
  2224. exports.inc = inc;
  2225. function inc(version, release$$1, loose, identifier) {
  2226. if (typeof loose === 'string') {
  2227. identifier = loose;
  2228. loose = undefined;
  2229. }
  2230. try {
  2231. return new SemVer(version, loose).inc(release$$1, identifier).version;
  2232. } catch (er) {
  2233. return null;
  2234. }
  2235. }
  2236. exports.diff = diff;
  2237. function diff(version1, version2) {
  2238. if (eq(version1, version2)) {
  2239. return null;
  2240. } else {
  2241. var v1 = parse(version1);
  2242. var v2 = parse(version2);
  2243. if (v1.prerelease.length || v2.prerelease.length) {
  2244. for (var key in v1) {
  2245. if (key === 'major' || key === 'minor' || key === 'patch') {
  2246. if (v1[key] !== v2[key]) {
  2247. return 'pre' + key;
  2248. }
  2249. }
  2250. }
  2251. return 'prerelease';
  2252. }
  2253. for (var key in v1) {
  2254. if (key === 'major' || key === 'minor' || key === 'patch') {
  2255. if (v1[key] !== v2[key]) {
  2256. return key;
  2257. }
  2258. }
  2259. }
  2260. }
  2261. }
  2262. exports.compareIdentifiers = compareIdentifiers;
  2263. var numeric = /^[0-9]+$/;
  2264. function compareIdentifiers(a, b) {
  2265. var anum = numeric.test(a);
  2266. var bnum = numeric.test(b);
  2267. if (anum && bnum) {
  2268. a = +a;
  2269. b = +b;
  2270. }
  2271. return anum && !bnum ? -1 : bnum && !anum ? 1 : a < b ? -1 : a > b ? 1 : 0;
  2272. }
  2273. exports.rcompareIdentifiers = rcompareIdentifiers;
  2274. function rcompareIdentifiers(a, b) {
  2275. return compareIdentifiers(b, a);
  2276. }
  2277. exports.major = major;
  2278. function major(a, loose) {
  2279. return new SemVer(a, loose).major;
  2280. }
  2281. exports.minor = minor;
  2282. function minor(a, loose) {
  2283. return new SemVer(a, loose).minor;
  2284. }
  2285. exports.patch = patch;
  2286. function patch(a, loose) {
  2287. return new SemVer(a, loose).patch;
  2288. }
  2289. exports.compare = compare;
  2290. function compare(a, b, loose) {
  2291. return new SemVer(a, loose).compare(new SemVer(b, loose));
  2292. }
  2293. exports.compareLoose = compareLoose;
  2294. function compareLoose(a, b) {
  2295. return compare(a, b, true);
  2296. }
  2297. exports.rcompare = rcompare;
  2298. function rcompare(a, b, loose) {
  2299. return compare(b, a, loose);
  2300. }
  2301. exports.sort = sort;
  2302. function sort(list, loose) {
  2303. return list.sort(function (a, b) {
  2304. return exports.compare(a, b, loose);
  2305. });
  2306. }
  2307. exports.rsort = rsort;
  2308. function rsort(list, loose) {
  2309. return list.sort(function (a, b) {
  2310. return exports.rcompare(a, b, loose);
  2311. });
  2312. }
  2313. exports.gt = gt;
  2314. function gt(a, b, loose) {
  2315. return compare(a, b, loose) > 0;
  2316. }
  2317. exports.lt = lt;
  2318. function lt(a, b, loose) {
  2319. return compare(a, b, loose) < 0;
  2320. }
  2321. exports.eq = eq;
  2322. function eq(a, b, loose) {
  2323. return compare(a, b, loose) === 0;
  2324. }
  2325. exports.neq = neq;
  2326. function neq(a, b, loose) {
  2327. return compare(a, b, loose) !== 0;
  2328. }
  2329. exports.gte = gte;
  2330. function gte(a, b, loose) {
  2331. return compare(a, b, loose) >= 0;
  2332. }
  2333. exports.lte = lte;
  2334. function lte(a, b, loose) {
  2335. return compare(a, b, loose) <= 0;
  2336. }
  2337. exports.cmp = cmp;
  2338. function cmp(a, op, b, loose) {
  2339. var ret;
  2340. switch (op) {
  2341. case '===':
  2342. if (_typeof(a) === 'object') a = a.version;
  2343. if (_typeof(b) === 'object') b = b.version;
  2344. ret = a === b;
  2345. break;
  2346. case '!==':
  2347. if (_typeof(a) === 'object') a = a.version;
  2348. if (_typeof(b) === 'object') b = b.version;
  2349. ret = a !== b;
  2350. break;
  2351. case '':
  2352. case '=':
  2353. case '==':
  2354. ret = eq(a, b, loose);
  2355. break;
  2356. case '!=':
  2357. ret = neq(a, b, loose);
  2358. break;
  2359. case '>':
  2360. ret = gt(a, b, loose);
  2361. break;
  2362. case '>=':
  2363. ret = gte(a, b, loose);
  2364. break;
  2365. case '<':
  2366. ret = lt(a, b, loose);
  2367. break;
  2368. case '<=':
  2369. ret = lte(a, b, loose);
  2370. break;
  2371. default:
  2372. throw new TypeError('Invalid operator: ' + op);
  2373. }
  2374. return ret;
  2375. }
  2376. exports.Comparator = Comparator;
  2377. function Comparator(comp, loose) {
  2378. if (comp instanceof Comparator) {
  2379. if (comp.loose === loose) return comp;else comp = comp.value;
  2380. }
  2381. if (!(this instanceof Comparator)) return new Comparator(comp, loose);
  2382. debug('comparator', comp, loose);
  2383. this.loose = loose;
  2384. this.parse(comp);
  2385. if (this.semver === ANY) this.value = '';else this.value = this.operator + this.semver.version;
  2386. debug('comp', this);
  2387. }
  2388. var ANY = {};
  2389. Comparator.prototype.parse = function (comp) {
  2390. var r = this.loose ? re[COMPARATORLOOSE] : re[COMPARATOR];
  2391. var m = comp.match(r);
  2392. if (!m) throw new TypeError('Invalid comparator: ' + comp);
  2393. this.operator = m[1];
  2394. if (this.operator === '=') this.operator = ''; // if it literally is just '>' or '' then allow anything.
  2395. if (!m[2]) this.semver = ANY;else this.semver = new SemVer(m[2], this.loose);
  2396. };
  2397. Comparator.prototype.toString = function () {
  2398. return this.value;
  2399. };
  2400. Comparator.prototype.test = function (version) {
  2401. debug('Comparator.test', version, this.loose);
  2402. if (this.semver === ANY) return true;
  2403. if (typeof version === 'string') version = new SemVer(version, this.loose);
  2404. return cmp(version, this.operator, this.semver, this.loose);
  2405. };
  2406. Comparator.prototype.intersects = function (comp, loose) {
  2407. if (!(comp instanceof Comparator)) {
  2408. throw new TypeError('a Comparator is required');
  2409. }
  2410. var rangeTmp;
  2411. if (this.operator === '') {
  2412. rangeTmp = new Range(comp.value, loose);
  2413. return satisfies(this.value, rangeTmp, loose);
  2414. } else if (comp.operator === '') {
  2415. rangeTmp = new Range(this.value, loose);
  2416. return satisfies(comp.semver, rangeTmp, loose);
  2417. }
  2418. var sameDirectionIncreasing = (this.operator === '>=' || this.operator === '>') && (comp.operator === '>=' || comp.operator === '>');
  2419. var sameDirectionDecreasing = (this.operator === '<=' || this.operator === '<') && (comp.operator === '<=' || comp.operator === '<');
  2420. var sameSemVer = this.semver.version === comp.semver.version;
  2421. var differentDirectionsInclusive = (this.operator === '>=' || this.operator === '<=') && (comp.operator === '>=' || comp.operator === '<=');
  2422. var oppositeDirectionsLessThan = cmp(this.semver, '<', comp.semver, loose) && (this.operator === '>=' || this.operator === '>') && (comp.operator === '<=' || comp.operator === '<');
  2423. var oppositeDirectionsGreaterThan = cmp(this.semver, '>', comp.semver, loose) && (this.operator === '<=' || this.operator === '<') && (comp.operator === '>=' || comp.operator === '>');
  2424. return sameDirectionIncreasing || sameDirectionDecreasing || sameSemVer && differentDirectionsInclusive || oppositeDirectionsLessThan || oppositeDirectionsGreaterThan;
  2425. };
  2426. exports.Range = Range;
  2427. function Range(range, loose) {
  2428. if (range instanceof Range) {
  2429. if (range.loose === loose) {
  2430. return range;
  2431. } else {
  2432. return new Range(range.raw, loose);
  2433. }
  2434. }
  2435. if (range instanceof Comparator) {
  2436. return new Range(range.value, loose);
  2437. }
  2438. if (!(this instanceof Range)) return new Range(range, loose);
  2439. this.loose = loose; // First, split based on boolean or ||
  2440. this.raw = range;
  2441. this.set = range.split(/\s*\|\|\s*/).map(function (range) {
  2442. return this.parseRange(range.trim());
  2443. }, this).filter(function (c) {
  2444. // throw out any that are not relevant for whatever reason
  2445. return c.length;
  2446. });
  2447. if (!this.set.length) {
  2448. throw new TypeError('Invalid SemVer Range: ' + range);
  2449. }
  2450. this.format();
  2451. }
  2452. Range.prototype.format = function () {
  2453. this.range = this.set.map(function (comps) {
  2454. return comps.join(' ').trim();
  2455. }).join('||').trim();
  2456. return this.range;
  2457. };
  2458. Range.prototype.toString = function () {
  2459. return this.range;
  2460. };
  2461. Range.prototype.parseRange = function (range) {
  2462. var loose = this.loose;
  2463. range = range.trim();
  2464. debug('range', range, loose); // `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4`
  2465. var hr = loose ? re[HYPHENRANGELOOSE] : re[HYPHENRANGE];
  2466. range = range.replace(hr, hyphenReplace);
  2467. debug('hyphen replace', range); // `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5`
  2468. range = range.replace(re[COMPARATORTRIM], comparatorTrimReplace);
  2469. debug('comparator trim', range, re[COMPARATORTRIM]); // `~ 1.2.3` => `~1.2.3`
  2470. range = range.replace(re[TILDETRIM], tildeTrimReplace); // `^ 1.2.3` => `^1.2.3`
  2471. range = range.replace(re[CARETTRIM], caretTrimReplace); // normalize spaces
  2472. range = range.split(/\s+/).join(' '); // At this point, the range is completely trimmed and
  2473. // ready to be split into comparators.
  2474. var compRe = loose ? re[COMPARATORLOOSE] : re[COMPARATOR];
  2475. var set = range.split(' ').map(function (comp) {
  2476. return parseComparator(comp, loose);
  2477. }).join(' ').split(/\s+/);
  2478. if (this.loose) {
  2479. // in loose mode, throw out any that are not valid comparators
  2480. set = set.filter(function (comp) {
  2481. return !!comp.match(compRe);
  2482. });
  2483. }
  2484. set = set.map(function (comp) {
  2485. return new Comparator(comp, loose);
  2486. });
  2487. return set;
  2488. };
  2489. Range.prototype.intersects = function (range, loose) {
  2490. if (!(range instanceof Range)) {
  2491. throw new TypeError('a Range is required');
  2492. }
  2493. return this.set.some(function (thisComparators) {
  2494. return thisComparators.every(function (thisComparator) {
  2495. return range.set.some(function (rangeComparators) {
  2496. return rangeComparators.every(function (rangeComparator) {
  2497. return thisComparator.intersects(rangeComparator, loose);
  2498. });
  2499. });
  2500. });
  2501. });
  2502. }; // Mostly just for testing and legacy API reasons
  2503. exports.toComparators = toComparators;
  2504. function toComparators(range, loose) {
  2505. return new Range(range, loose).set.map(function (comp) {
  2506. return comp.map(function (c) {
  2507. return c.value;
  2508. }).join(' ').trim().split(' ');
  2509. });
  2510. } // comprised of xranges, tildes, stars, and gtlt's at this point.
  2511. // already replaced the hyphen ranges
  2512. // turn into a set of JUST comparators.
  2513. function parseComparator(comp, loose) {
  2514. debug('comp', comp);
  2515. comp = replaceCarets(comp, loose);
  2516. debug('caret', comp);
  2517. comp = replaceTildes(comp, loose);
  2518. debug('tildes', comp);
  2519. comp = replaceXRanges(comp, loose);
  2520. debug('xrange', comp);
  2521. comp = replaceStars(comp, loose);
  2522. debug('stars', comp);
  2523. return comp;
  2524. }
  2525. function isX(id) {
  2526. return !id || id.toLowerCase() === 'x' || id === '*';
  2527. } // ~, ~> --> * (any, kinda silly)
  2528. // ~2, ~2.x, ~2.x.x, ~>2, ~>2.x ~>2.x.x --> >=2.0.0 <3.0.0
  2529. // ~2.0, ~2.0.x, ~>2.0, ~>2.0.x --> >=2.0.0 <2.1.0
  2530. // ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <1.3.0
  2531. // ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0
  2532. // ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0
  2533. function replaceTildes(comp, loose) {
  2534. return comp.trim().split(/\s+/).map(function (comp) {
  2535. return replaceTilde(comp, loose);
  2536. }).join(' ');
  2537. }
  2538. function replaceTilde(comp, loose) {
  2539. var r = loose ? re[TILDELOOSE] : re[TILDE];
  2540. return comp.replace(r, function (_, M, m, p, pr) {
  2541. debug('tilde', comp, _, M, m, p, pr);
  2542. var ret;
  2543. if (isX(M)) ret = '';else if (isX(m)) ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0';else if (isX(p)) // ~1.2 == >=1.2.0 <1.3.0
  2544. ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0';else if (pr) {
  2545. debug('replaceTilde pr', pr);
  2546. if (pr.charAt(0) !== '-') pr = '-' + pr;
  2547. ret = '>=' + M + '.' + m + '.' + p + pr + ' <' + M + '.' + (+m + 1) + '.0';
  2548. } else // ~1.2.3 == >=1.2.3 <1.3.0
  2549. ret = '>=' + M + '.' + m + '.' + p + ' <' + M + '.' + (+m + 1) + '.0';
  2550. debug('tilde return', ret);
  2551. return ret;
  2552. });
  2553. } // ^ --> * (any, kinda silly)
  2554. // ^2, ^2.x, ^2.x.x --> >=2.0.0 <3.0.0
  2555. // ^2.0, ^2.0.x --> >=2.0.0 <3.0.0
  2556. // ^1.2, ^1.2.x --> >=1.2.0 <2.0.0
  2557. // ^1.2.3 --> >=1.2.3 <2.0.0
  2558. // ^1.2.0 --> >=1.2.0 <2.0.0
  2559. function replaceCarets(comp, loose) {
  2560. return comp.trim().split(/\s+/).map(function (comp) {
  2561. return replaceCaret(comp, loose);
  2562. }).join(' ');
  2563. }
  2564. function replaceCaret(comp, loose) {
  2565. debug('caret', comp, loose);
  2566. var r = loose ? re[CARETLOOSE] : re[CARET];
  2567. return comp.replace(r, function (_, M, m, p, pr) {
  2568. debug('caret', comp, _, M, m, p, pr);
  2569. var ret;
  2570. if (isX(M)) ret = '';else if (isX(m)) ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0';else if (isX(p)) {
  2571. if (M === '0') ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0';else ret = '>=' + M + '.' + m + '.0 <' + (+M + 1) + '.0.0';
  2572. } else if (pr) {
  2573. debug('replaceCaret pr', pr);
  2574. if (pr.charAt(0) !== '-') pr = '-' + pr;
  2575. if (M === '0') {
  2576. if (m === '0') ret = '>=' + M + '.' + m + '.' + p + pr + ' <' + M + '.' + m + '.' + (+p + 1);else ret = '>=' + M + '.' + m + '.' + p + pr + ' <' + M + '.' + (+m + 1) + '.0';
  2577. } else ret = '>=' + M + '.' + m + '.' + p + pr + ' <' + (+M + 1) + '.0.0';
  2578. } else {
  2579. debug('no pr');
  2580. if (M === '0') {
  2581. if (m === '0') ret = '>=' + M + '.' + m + '.' + p + ' <' + M + '.' + m + '.' + (+p + 1);else ret = '>=' + M + '.' + m + '.' + p + ' <' + M + '.' + (+m + 1) + '.0';
  2582. } else ret = '>=' + M + '.' + m + '.' + p + ' <' + (+M + 1) + '.0.0';
  2583. }
  2584. debug('caret return', ret);
  2585. return ret;
  2586. });
  2587. }
  2588. function replaceXRanges(comp, loose) {
  2589. debug('replaceXRanges', comp, loose);
  2590. return comp.split(/\s+/).map(function (comp) {
  2591. return replaceXRange(comp, loose);
  2592. }).join(' ');
  2593. }
  2594. function replaceXRange(comp, loose) {
  2595. comp = comp.trim();
  2596. var r = loose ? re[XRANGELOOSE] : re[XRANGE];
  2597. return comp.replace(r, function (ret, gtlt, M, m, p, pr) {
  2598. debug('xRange', comp, ret, gtlt, M, m, p, pr);
  2599. var xM = isX(M);
  2600. var xm = xM || isX(m);
  2601. var xp = xm || isX(p);
  2602. var anyX = xp;
  2603. if (gtlt === '=' && anyX) gtlt = '';
  2604. if (xM) {
  2605. if (gtlt === '>' || gtlt === '<') {
  2606. // nothing is allowed
  2607. ret = '<0.0.0';
  2608. } else {
  2609. // nothing is forbidden
  2610. ret = '*';
  2611. }
  2612. } else if (gtlt && anyX) {
  2613. // replace X with 0
  2614. if (xm) m = 0;
  2615. if (xp) p = 0;
  2616. if (gtlt === '>') {
  2617. // >1 => >=2.0.0
  2618. // >1.2 => >=1.3.0
  2619. // >1.2.3 => >= 1.2.4
  2620. gtlt = '>=';
  2621. if (xm) {
  2622. M = +M + 1;
  2623. m = 0;
  2624. p = 0;
  2625. } else if (xp) {
  2626. m = +m + 1;
  2627. p = 0;
  2628. }
  2629. } else if (gtlt === '<=') {
  2630. // <=0.7.x is actually <0.8.0, since any 0.7.x should
  2631. // pass. Similarly, <=7.x is actually <8.0.0, etc.
  2632. gtlt = '<';
  2633. if (xm) M = +M + 1;else m = +m + 1;
  2634. }
  2635. ret = gtlt + M + '.' + m + '.' + p;
  2636. } else if (xm) {
  2637. ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0';
  2638. } else if (xp) {
  2639. ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0';
  2640. }
  2641. debug('xRange return', ret);
  2642. return ret;
  2643. });
  2644. } // Because * is AND-ed with everything else in the comparator,
  2645. // and '' means "any version", just remove the *s entirely.
  2646. function replaceStars(comp, loose) {
  2647. debug('replaceStars', comp, loose); // Looseness is ignored here. star is always as loose as it gets!
  2648. return comp.trim().replace(re[STAR], '');
  2649. } // This function is passed to string.replace(re[HYPHENRANGE])
  2650. // M, m, patch, prerelease, build
  2651. // 1.2 - 3.4.5 => >=1.2.0 <=3.4.5
  2652. // 1.2.3 - 3.4 => >=1.2.0 <3.5.0 Any 3.4.x will do
  2653. // 1.2 - 3.4 => >=1.2.0 <3.5.0
  2654. function hyphenReplace($0, from, fM, fm, fp, fpr, fb, to, tM, tm, tp, tpr, tb) {
  2655. if (isX(fM)) from = '';else if (isX(fm)) from = '>=' + fM + '.0.0';else if (isX(fp)) from = '>=' + fM + '.' + fm + '.0';else from = '>=' + from;
  2656. if (isX(tM)) to = '';else if (isX(tm)) to = '<' + (+tM + 1) + '.0.0';else if (isX(tp)) to = '<' + tM + '.' + (+tm + 1) + '.0';else if (tpr) to = '<=' + tM + '.' + tm + '.' + tp + '-' + tpr;else to = '<=' + to;
  2657. return (from + ' ' + to).trim();
  2658. } // if ANY of the sets match ALL of its comparators, then pass
  2659. Range.prototype.test = function (version) {
  2660. if (!version) return false;
  2661. if (typeof version === 'string') version = new SemVer(version, this.loose);
  2662. for (var i = 0; i < this.set.length; i++) {
  2663. if (testSet(this.set[i], version)) return true;
  2664. }
  2665. return false;
  2666. };
  2667. function testSet(set, version) {
  2668. for (var i = 0; i < set.length; i++) {
  2669. if (!set[i].test(version)) return false;
  2670. }
  2671. if (version.prerelease.length) {
  2672. // Find the set of versions that are allowed to have prereleases
  2673. // For example, ^1.2.3-pr.1 desugars to >=1.2.3-pr.1 <2.0.0
  2674. // That should allow `1.2.3-pr.2` to pass.
  2675. // However, `1.2.4-alpha.notready` should NOT be allowed,
  2676. // even though it's within the range set by the comparators.
  2677. for (var i = 0; i < set.length; i++) {
  2678. debug(set[i].semver);
  2679. if (set[i].semver === ANY) continue;
  2680. if (set[i].semver.prerelease.length > 0) {
  2681. var allowed = set[i].semver;
  2682. if (allowed.major === version.major && allowed.minor === version.minor && allowed.patch === version.patch) return true;
  2683. }
  2684. } // Version has a -pre, but it's not one of the ones we like.
  2685. return false;
  2686. }
  2687. return true;
  2688. }
  2689. exports.satisfies = satisfies;
  2690. function satisfies(version, range, loose) {
  2691. try {
  2692. range = new Range(range, loose);
  2693. } catch (er) {
  2694. return false;
  2695. }
  2696. return range.test(version);
  2697. }
  2698. exports.maxSatisfying = maxSatisfying;
  2699. function maxSatisfying(versions$$1, range, loose) {
  2700. var max = null;
  2701. var maxSV = null;
  2702. try {
  2703. var rangeObj = new Range(range, loose);
  2704. } catch (er) {
  2705. return null;
  2706. }
  2707. versions$$1.forEach(function (v) {
  2708. if (rangeObj.test(v)) {
  2709. // satisfies(v, range, loose)
  2710. if (!max || maxSV.compare(v) === -1) {
  2711. // compare(max, v, true)
  2712. max = v;
  2713. maxSV = new SemVer(max, loose);
  2714. }
  2715. }
  2716. });
  2717. return max;
  2718. }
  2719. exports.minSatisfying = minSatisfying;
  2720. function minSatisfying(versions$$1, range, loose) {
  2721. var min = null;
  2722. var minSV = null;
  2723. try {
  2724. var rangeObj = new Range(range, loose);
  2725. } catch (er) {
  2726. return null;
  2727. }
  2728. versions$$1.forEach(function (v) {
  2729. if (rangeObj.test(v)) {
  2730. // satisfies(v, range, loose)
  2731. if (!min || minSV.compare(v) === 1) {
  2732. // compare(min, v, true)
  2733. min = v;
  2734. minSV = new SemVer(min, loose);
  2735. }
  2736. }
  2737. });
  2738. return min;
  2739. }
  2740. exports.validRange = validRange;
  2741. function validRange(range, loose) {
  2742. try {
  2743. // Return '*' instead of '' so that truthiness works.
  2744. // This will throw if it's invalid anyway
  2745. return new Range(range, loose).range || '*';
  2746. } catch (er) {
  2747. return null;
  2748. }
  2749. } // Determine if version is less than all the versions possible in the range
  2750. exports.ltr = ltr;
  2751. function ltr(version, range, loose) {
  2752. return outside(version, range, '<', loose);
  2753. } // Determine if version is greater than all the versions possible in the range.
  2754. exports.gtr = gtr;
  2755. function gtr(version, range, loose) {
  2756. return outside(version, range, '>', loose);
  2757. }
  2758. exports.outside = outside;
  2759. function outside(version, range, hilo, loose) {
  2760. version = new SemVer(version, loose);
  2761. range = new Range(range, loose);
  2762. var gtfn, ltefn, ltfn, comp, ecomp;
  2763. switch (hilo) {
  2764. case '>':
  2765. gtfn = gt;
  2766. ltefn = lte;
  2767. ltfn = lt;
  2768. comp = '>';
  2769. ecomp = '>=';
  2770. break;
  2771. case '<':
  2772. gtfn = lt;
  2773. ltefn = gte;
  2774. ltfn = gt;
  2775. comp = '<';
  2776. ecomp = '<=';
  2777. break;
  2778. default:
  2779. throw new TypeError('Must provide a hilo val of "<" or ">"');
  2780. } // If it satisifes the range it is not outside
  2781. if (satisfies(version, range, loose)) {
  2782. return false;
  2783. } // From now on, variable terms are as if we're in "gtr" mode.
  2784. // but note that everything is flipped for the "ltr" function.
  2785. for (var i = 0; i < range.set.length; ++i) {
  2786. var comparators = range.set[i];
  2787. var high = null;
  2788. var low = null;
  2789. comparators.forEach(function (comparator) {
  2790. if (comparator.semver === ANY) {
  2791. comparator = new Comparator('>=0.0.0');
  2792. }
  2793. high = high || comparator;
  2794. low = low || comparator;
  2795. if (gtfn(comparator.semver, high.semver, loose)) {
  2796. high = comparator;
  2797. } else if (ltfn(comparator.semver, low.semver, loose)) {
  2798. low = comparator;
  2799. }
  2800. }); // If the edge version comparator has a operator then our version
  2801. // isn't outside it
  2802. if (high.operator === comp || high.operator === ecomp) {
  2803. return false;
  2804. } // If the lowest version comparator has an operator and our version
  2805. // is less than it then it isn't higher than the range
  2806. if ((!low.operator || low.operator === comp) && ltefn(version, low.semver)) {
  2807. return false;
  2808. } else if (low.operator === ecomp && ltfn(version, low.semver)) {
  2809. return false;
  2810. }
  2811. }
  2812. return true;
  2813. }
  2814. exports.prerelease = prerelease;
  2815. function prerelease(version, loose) {
  2816. var parsed = parse(version, loose);
  2817. return parsed && parsed.prerelease.length ? parsed.prerelease : null;
  2818. }
  2819. exports.intersects = intersects;
  2820. function intersects(r1, r2, loose) {
  2821. r1 = new Range(r1, loose);
  2822. r2 = new Range(r2, loose);
  2823. return r1.intersects(r2);
  2824. }
  2825. });
  2826. var arrayify = function arrayify(object, keyName) {
  2827. return Object.keys(object).reduce(function (array, key) {
  2828. return array.concat(Object.assign(_defineProperty({}, keyName, key), object[key]));
  2829. }, []);
  2830. };
  2831. var dedent_1 = createCommonjsModule(function (module) {
  2832. "use strict";
  2833. function dedent(strings) {
  2834. var raw = void 0;
  2835. if (typeof strings === "string") {
  2836. // dedent can be used as a plain function
  2837. raw = [strings];
  2838. } else {
  2839. raw = strings.raw;
  2840. } // first, perform interpolation
  2841. var result = "";
  2842. for (var i = 0; i < raw.length; i++) {
  2843. result += raw[i]. // join lines when there is a suppressed newline
  2844. replace(/\\\n[ \t]*/g, ""). // handle escaped backticks
  2845. replace(/\\`/g, "`");
  2846. if (i < (arguments.length <= 1 ? 0 : arguments.length - 1)) {
  2847. result += arguments.length <= i + 1 ? undefined : arguments[i + 1];
  2848. }
  2849. } // now strip indentation
  2850. var lines = result.split("\n");
  2851. var mindent = null;
  2852. lines.forEach(function (l) {
  2853. var m = l.match(/^(\s+)\S+/);
  2854. if (m) {
  2855. var indent = m[1].length;
  2856. if (!mindent) {
  2857. // this is the first indented line
  2858. mindent = indent;
  2859. } else {
  2860. mindent = Math.min(mindent, indent);
  2861. }
  2862. }
  2863. });
  2864. if (mindent !== null) {
  2865. result = lines.map(function (l) {
  2866. return l[0] === " " ? l.slice(mindent) : l;
  2867. }).join("\n");
  2868. } // dedent eats leading and trailing whitespace too
  2869. result = result.trim(); // handle escaped newlines at the end to ensure they don't get stripped too
  2870. return result.replace(/\\n/g, "\n");
  2871. }
  2872. {
  2873. module.exports = dedent;
  2874. }
  2875. });
  2876. function _templateObject5() {
  2877. var data = _taggedTemplateLiteral(["\n Require either '@prettier' or '@format' to be present in the file's first docblock comment\n in order for it to be formatted.\n "]);
  2878. _templateObject5 = function _templateObject5() {
  2879. return data;
  2880. };
  2881. return data;
  2882. }
  2883. function _templateObject4() {
  2884. var data = _taggedTemplateLiteral(["\n Format code starting at a given character offset.\n The range will extend backwards to the start of the first line containing the selected statement.\n This option cannot be used with --cursor-offset.\n "]);
  2885. _templateObject4 = function _templateObject4() {
  2886. return data;
  2887. };
  2888. return data;
  2889. }
  2890. function _templateObject3() {
  2891. var data = _taggedTemplateLiteral(["\n Format code ending at a given character offset (exclusive).\n The range will extend forwards to the end of the selected statement.\n This option cannot be used with --cursor-offset.\n "]);
  2892. _templateObject3 = function _templateObject3() {
  2893. return data;
  2894. };
  2895. return data;
  2896. }
  2897. function _templateObject2() {
  2898. var data = _taggedTemplateLiteral(["\n Custom directory that contains prettier plugins in node_modules subdirectory.\n Overrides default behavior when plugins are searched relatively to the location of Prettier.\n Multiple values are accepted.\n "]);
  2899. _templateObject2 = function _templateObject2() {
  2900. return data;
  2901. };
  2902. return data;
  2903. }
  2904. function _templateObject() {
  2905. var data = _taggedTemplateLiteral(["\n Print (to stderr) where a cursor at the given position would move to after formatting.\n This option cannot be used with --range-start and --range-end.\n "]);
  2906. _templateObject = function _templateObject() {
  2907. return data;
  2908. };
  2909. return data;
  2910. }
  2911. var CATEGORY_CONFIG = "Config";
  2912. var CATEGORY_EDITOR = "Editor";
  2913. var CATEGORY_FORMAT = "Format";
  2914. var CATEGORY_OTHER = "Other";
  2915. var CATEGORY_OUTPUT = "Output";
  2916. var CATEGORY_GLOBAL = "Global";
  2917. var CATEGORY_SPECIAL = "Special";
  2918. /**
  2919. * @typedef {Object} OptionInfo
  2920. * @property {string} since - available since version
  2921. * @property {string} category
  2922. * @property {'int' | 'boolean' | 'choice' | 'path'} type
  2923. * @property {boolean} array - indicate it's an array of the specified type
  2924. * @property {boolean?} deprecated - deprecated since version
  2925. * @property {OptionRedirectInfo?} redirect - redirect deprecated option
  2926. * @property {string} description
  2927. * @property {string?} oppositeDescription - for `false` option
  2928. * @property {OptionValueInfo} default
  2929. * @property {OptionRangeInfo?} range - for type int
  2930. * @property {OptionChoiceInfo?} choices - for type choice
  2931. * @property {(value: any) => boolean} exception
  2932. *
  2933. * @typedef {number | boolean | string} OptionValue
  2934. * @typedef {OptionValue | [{ value: OptionValue[] }] | Array<{ since: string, value: OptionValue}>} OptionValueInfo
  2935. *
  2936. * @typedef {Object} OptionRedirectInfo
  2937. * @property {string} option
  2938. * @property {OptionValue} value
  2939. *
  2940. * @typedef {Object} OptionRangeInfo
  2941. * @property {number} start - recommended range start
  2942. * @property {number} end - recommended range end
  2943. * @property {number} step - recommended range step
  2944. *
  2945. * @typedef {Object} OptionChoiceInfo
  2946. * @property {boolean | string} value - boolean for the option that is originally boolean type
  2947. * @property {string?} description - undefined if redirect
  2948. * @property {string?} since - undefined if available since the first version of the option
  2949. * @property {string?} deprecated - deprecated since version
  2950. * @property {OptionValueInfo?} redirect - redirect deprecated value
  2951. *
  2952. * @property {string?} cliName
  2953. * @property {string?} cliCategory
  2954. * @property {string?} cliDescription
  2955. */
  2956. /** @type {{ [name: string]: OptionInfo } */
  2957. var options$2 = {
  2958. cursorOffset: {
  2959. since: "1.4.0",
  2960. category: CATEGORY_SPECIAL,
  2961. type: "int",
  2962. default: -1,
  2963. range: {
  2964. start: -1,
  2965. end: Infinity,
  2966. step: 1
  2967. },
  2968. description: dedent_1(_templateObject()),
  2969. cliCategory: CATEGORY_EDITOR
  2970. },
  2971. filepath: {
  2972. since: "1.4.0",
  2973. category: CATEGORY_SPECIAL,
  2974. type: "path",
  2975. default: undefined,
  2976. description: "Specify the input filepath. This will be used to do parser inference.",
  2977. cliName: "stdin-filepath",
  2978. cliCategory: CATEGORY_OTHER,
  2979. cliDescription: "Path to the file to pretend that stdin comes from."
  2980. },
  2981. insertPragma: {
  2982. since: "1.8.0",
  2983. category: CATEGORY_SPECIAL,
  2984. type: "boolean",
  2985. default: false,
  2986. description: "Insert @format pragma into file's first docblock comment.",
  2987. cliCategory: CATEGORY_OTHER
  2988. },
  2989. parser: {
  2990. since: "0.0.10",
  2991. category: CATEGORY_GLOBAL,
  2992. type: "choice",
  2993. default: [{
  2994. since: "0.0.10",
  2995. value: "babylon"
  2996. }, {
  2997. since: "1.13.0",
  2998. value: undefined
  2999. }],
  3000. description: "Which parser to use.",
  3001. exception: function exception(value) {
  3002. return typeof value === "string" || typeof value === "function";
  3003. },
  3004. choices: [{
  3005. value: "flow",
  3006. description: "Flow"
  3007. }, {
  3008. value: "babylon",
  3009. description: "JavaScript"
  3010. }, {
  3011. value: "typescript",
  3012. since: "1.4.0",
  3013. description: "TypeScript"
  3014. }, {
  3015. value: "css",
  3016. since: "1.7.1",
  3017. description: "CSS"
  3018. }, {
  3019. value: "postcss",
  3020. since: "1.4.0",
  3021. description: "CSS/Less/SCSS",
  3022. deprecated: "1.7.1",
  3023. redirect: "css"
  3024. }, {
  3025. value: "less",
  3026. since: "1.7.1",
  3027. description: "Less"
  3028. }, {
  3029. value: "scss",
  3030. since: "1.7.1",
  3031. description: "SCSS"
  3032. }, {
  3033. value: "json",
  3034. since: "1.5.0",
  3035. description: "JSON"
  3036. }, {
  3037. value: "json5",
  3038. since: "1.13.0",
  3039. description: "JSON5"
  3040. }, {
  3041. value: "json-stringify",
  3042. since: "1.13.0",
  3043. description: "JSON.stringify"
  3044. }, {
  3045. value: "graphql",
  3046. since: "1.5.0",
  3047. description: "GraphQL"
  3048. }, {
  3049. value: "markdown",
  3050. since: "1.8.0",
  3051. description: "Markdown"
  3052. }, {
  3053. value: "vue",
  3054. since: "1.10.0",
  3055. description: "Vue"
  3056. }]
  3057. },
  3058. plugins: {
  3059. since: "1.10.0",
  3060. type: "path",
  3061. array: true,
  3062. default: [{
  3063. value: []
  3064. }],
  3065. category: CATEGORY_GLOBAL,
  3066. description: "Add a plugin. Multiple plugins can be passed as separate `--plugin`s.",
  3067. exception: function exception(value) {
  3068. return typeof value === "string" || _typeof(value) === "object";
  3069. },
  3070. cliName: "plugin",
  3071. cliCategory: CATEGORY_CONFIG
  3072. },
  3073. pluginSearchDirs: {
  3074. since: "1.13.0",
  3075. type: "path",
  3076. array: true,
  3077. default: [{
  3078. value: []
  3079. }],
  3080. category: CATEGORY_GLOBAL,
  3081. description: dedent_1(_templateObject2()),
  3082. exception: function exception(value) {
  3083. return typeof value === "string" || _typeof(value) === "object";
  3084. },
  3085. cliName: "plugin-search-dir",
  3086. cliCategory: CATEGORY_CONFIG
  3087. },
  3088. printWidth: {
  3089. since: "0.0.0",
  3090. category: CATEGORY_GLOBAL,
  3091. type: "int",
  3092. default: 80,
  3093. description: "The line length where Prettier will try wrap.",
  3094. range: {
  3095. start: 0,
  3096. end: Infinity,
  3097. step: 1
  3098. }
  3099. },
  3100. rangeEnd: {
  3101. since: "1.4.0",
  3102. category: CATEGORY_SPECIAL,
  3103. type: "int",
  3104. default: Infinity,
  3105. range: {
  3106. start: 0,
  3107. end: Infinity,
  3108. step: 1
  3109. },
  3110. description: dedent_1(_templateObject3()),
  3111. cliCategory: CATEGORY_EDITOR
  3112. },
  3113. rangeStart: {
  3114. since: "1.4.0",
  3115. category: CATEGORY_SPECIAL,
  3116. type: "int",
  3117. default: 0,
  3118. range: {
  3119. start: 0,
  3120. end: Infinity,
  3121. step: 1
  3122. },
  3123. description: dedent_1(_templateObject4()),
  3124. cliCategory: CATEGORY_EDITOR
  3125. },
  3126. requirePragma: {
  3127. since: "1.7.0",
  3128. category: CATEGORY_SPECIAL,
  3129. type: "boolean",
  3130. default: false,
  3131. description: dedent_1(_templateObject5()),
  3132. cliCategory: CATEGORY_OTHER
  3133. },
  3134. tabWidth: {
  3135. type: "int",
  3136. category: CATEGORY_GLOBAL,
  3137. default: 2,
  3138. description: "Number of spaces per indentation level.",
  3139. range: {
  3140. start: 0,
  3141. end: Infinity,
  3142. step: 1
  3143. }
  3144. },
  3145. useFlowParser: {
  3146. since: "0.0.0",
  3147. category: CATEGORY_GLOBAL,
  3148. type: "boolean",
  3149. default: false,
  3150. deprecated: "0.0.10",
  3151. description: "Use flow parser.",
  3152. redirect: {
  3153. option: "parser",
  3154. value: "flow"
  3155. },
  3156. cliName: "flow-parser"
  3157. },
  3158. useTabs: {
  3159. since: "1.0.0",
  3160. category: CATEGORY_GLOBAL,
  3161. type: "boolean",
  3162. default: false,
  3163. description: "Indent with tabs instead of spaces."
  3164. }
  3165. };
  3166. var coreOptions$1 = {
  3167. CATEGORY_CONFIG: CATEGORY_CONFIG,
  3168. CATEGORY_EDITOR: CATEGORY_EDITOR,
  3169. CATEGORY_FORMAT: CATEGORY_FORMAT,
  3170. CATEGORY_OTHER: CATEGORY_OTHER,
  3171. CATEGORY_OUTPUT: CATEGORY_OUTPUT,
  3172. CATEGORY_GLOBAL: CATEGORY_GLOBAL,
  3173. CATEGORY_SPECIAL: CATEGORY_SPECIAL,
  3174. options: options$2
  3175. };
  3176. var require$$0 = ( _package$1 && _package ) || _package$1;
  3177. var currentVersion = require$$0.version;
  3178. var coreOptions = coreOptions$1.options;
  3179. function getSupportInfo$2(version, opts) {
  3180. opts = Object.assign({
  3181. plugins: [],
  3182. showUnreleased: false,
  3183. showDeprecated: false,
  3184. showInternal: false
  3185. }, opts);
  3186. if (!version) {
  3187. version = currentVersion;
  3188. }
  3189. var plugins = opts.plugins;
  3190. var options = arrayify(Object.assign(plugins.reduce(function (currentOptions, plugin) {
  3191. return Object.assign(currentOptions, plugin.options);
  3192. }, {}), coreOptions), "name").sort(function (a, b) {
  3193. return a.name === b.name ? 0 : a.name < b.name ? -1 : 1;
  3194. }).filter(filterSince).filter(filterDeprecated).map(mapDeprecated).map(mapInternal).map(function (option) {
  3195. var newOption = Object.assign({}, option);
  3196. if (Array.isArray(newOption.default)) {
  3197. newOption.default = newOption.default.length === 1 ? newOption.default[0].value : newOption.default.filter(filterSince).sort(function (info1, info2) {
  3198. return semver.compare(info2.since, info1.since);
  3199. })[0].value;
  3200. }
  3201. if (Array.isArray(newOption.choices)) {
  3202. newOption.choices = newOption.choices.filter(filterSince).filter(filterDeprecated).map(mapDeprecated);
  3203. }
  3204. return newOption;
  3205. }).map(function (option) {
  3206. var filteredPlugins = plugins.filter(function (plugin) {
  3207. return plugin.defaultOptions && plugin.defaultOptions[option.name];
  3208. });
  3209. var pluginDefaults = filteredPlugins.reduce(function (reduced, plugin) {
  3210. reduced[plugin.name] = plugin.defaultOptions[option.name];
  3211. return reduced;
  3212. }, {});
  3213. return Object.assign(option, {
  3214. pluginDefaults: pluginDefaults
  3215. });
  3216. });
  3217. var usePostCssParser = semver.lt(version, "1.7.1");
  3218. var languages = plugins.reduce(function (all, plugin) {
  3219. return all.concat(plugin.languages || []);
  3220. }, []).filter(function (language) {
  3221. return language.since ? semver.gte(version, language.since) : language.since !== null;
  3222. }).map(function (language) {
  3223. // Prevent breaking changes
  3224. if (language.name === "Markdown") {
  3225. return Object.assign({}, language, {
  3226. parsers: ["markdown"]
  3227. });
  3228. }
  3229. if (language.name === "TypeScript") {
  3230. return Object.assign({}, language, {
  3231. parsers: ["typescript"]
  3232. });
  3233. }
  3234. if (usePostCssParser && language.group === "CSS") {
  3235. return Object.assign({}, language, {
  3236. parsers: ["postcss"]
  3237. });
  3238. }
  3239. return language;
  3240. });
  3241. return {
  3242. languages: languages,
  3243. options: options
  3244. };
  3245. function filterSince(object) {
  3246. return opts.showUnreleased || !("since" in object) || object.since && semver.gte(version, object.since);
  3247. }
  3248. function filterDeprecated(object) {
  3249. return opts.showDeprecated || !("deprecated" in object) || object.deprecated && semver.lt(version, object.deprecated);
  3250. }
  3251. function mapDeprecated(object) {
  3252. if (!object.deprecated || opts.showDeprecated) {
  3253. return object;
  3254. }
  3255. var newObject = Object.assign({}, object);
  3256. delete newObject.deprecated;
  3257. delete newObject.redirect;
  3258. return newObject;
  3259. }
  3260. function mapInternal(object) {
  3261. if (opts.showInternal) {
  3262. return object;
  3263. }
  3264. var newObject = Object.assign({}, object);
  3265. delete newObject.cliName;
  3266. delete newObject.cliCategory;
  3267. delete newObject.cliDescription;
  3268. return newObject;
  3269. }
  3270. }
  3271. var support = {
  3272. getSupportInfo: getSupportInfo$2
  3273. };
  3274. /* eslint-disable no-nested-ternary */
  3275. var arr = [];
  3276. var charCodeCache = [];
  3277. var leven = function leven(a, b) {
  3278. if (a === b) {
  3279. return 0;
  3280. }
  3281. var swap = a; // Swapping the strings if `a` is longer than `b` so we know which one is the
  3282. // shortest & which one is the longest
  3283. if (a.length > b.length) {
  3284. a = b;
  3285. b = swap;
  3286. }
  3287. var aLen = a.length;
  3288. var bLen = b.length;
  3289. if (aLen === 0) {
  3290. return bLen;
  3291. }
  3292. if (bLen === 0) {
  3293. return aLen;
  3294. } // Performing suffix trimming:
  3295. // We can linearly drop suffix common to both strings since they
  3296. // don't increase distance at all
  3297. // Note: `~-` is the bitwise way to perform a `- 1` operation
  3298. while (aLen > 0 && a.charCodeAt(~-aLen) === b.charCodeAt(~-bLen)) {
  3299. aLen--;
  3300. bLen--;
  3301. }
  3302. if (aLen === 0) {
  3303. return bLen;
  3304. } // Performing prefix trimming
  3305. // We can linearly drop prefix common to both strings since they
  3306. // don't increase distance at all
  3307. var start = 0;
  3308. while (start < aLen && a.charCodeAt(start) === b.charCodeAt(start)) {
  3309. start++;
  3310. }
  3311. aLen -= start;
  3312. bLen -= start;
  3313. if (aLen === 0) {
  3314. return bLen;
  3315. }
  3316. var bCharCode;
  3317. var ret;
  3318. var tmp;
  3319. var tmp2;
  3320. var i = 0;
  3321. var j = 0;
  3322. while (i < aLen) {
  3323. charCodeCache[start + i] = a.charCodeAt(start + i);
  3324. arr[i] = ++i;
  3325. }
  3326. while (j < bLen) {
  3327. bCharCode = b.charCodeAt(start + j);
  3328. tmp = j++;
  3329. ret = j;
  3330. for (i = 0; i < aLen; i++) {
  3331. tmp2 = bCharCode === charCodeCache[start + i] ? tmp : tmp + 1;
  3332. tmp = arr[i];
  3333. ret = arr[i] = tmp > ret ? tmp2 > ret ? ret + 1 : tmp2 : tmp2 > tmp ? tmp + 1 : tmp2;
  3334. }
  3335. }
  3336. return ret;
  3337. };
  3338. function apiDescriptor(name, value) {
  3339. return arguments.length === 1 ? JSON.stringify(name) : "`{ ".concat(apiDescriptor(name), ": ").concat(JSON.stringify(value), " }`");
  3340. }
  3341. function cliDescriptor(name, value) {
  3342. return value === false ? "`--no-".concat(name, "`") : value === true || arguments.length === 1 ? "`--".concat(name, "`") : value === "" ? "`--".concat(name, "` without an argument") : "`--".concat(name, "=").concat(value, "`");
  3343. }
  3344. var optionsDescriptor = {
  3345. apiDescriptor: apiDescriptor,
  3346. cliDescriptor: cliDescriptor
  3347. };
  3348. function validateOption(value, optionInfo, opts) {
  3349. opts = opts || {};
  3350. var descriptor = opts.descriptor || optionsDescriptor.apiDescriptor;
  3351. if (typeof optionInfo.exception === "function" && optionInfo.exception(value)) {
  3352. return;
  3353. }
  3354. try {
  3355. validateOptionType(value, optionInfo);
  3356. } catch (error) {
  3357. throw new Error("Invalid `".concat(descriptor(optionInfo.name), "` value. ").concat(error.message, ", but received `").concat(JSON.stringify(value), "`."));
  3358. }
  3359. }
  3360. function validateOptionType(value, optionInfo) {
  3361. if (optionInfo.array) {
  3362. if (!Array.isArray(value)) {
  3363. throw new Error("Expected an array");
  3364. }
  3365. value.forEach(function (v) {
  3366. return validateOptionType(v, Object.assign({}, optionInfo, {
  3367. array: false
  3368. }));
  3369. });
  3370. } else {
  3371. switch (optionInfo.type) {
  3372. case "int":
  3373. validateIntOption(value);
  3374. break;
  3375. case "boolean":
  3376. validateBooleanOption(value);
  3377. break;
  3378. case "choice":
  3379. validateChoiceOption(value, optionInfo.choices);
  3380. break;
  3381. }
  3382. }
  3383. }
  3384. function validateBooleanOption(value) {
  3385. if (typeof value !== "boolean") {
  3386. throw new Error("Expected a boolean");
  3387. }
  3388. }
  3389. function validateIntOption(value) {
  3390. if (!(typeof value === "number" && Math.floor(value) === value && value >= 0 && value !== Infinity)) {
  3391. throw new Error("Expected an integer");
  3392. }
  3393. }
  3394. function validateChoiceOption(value, choiceInfos) {
  3395. if (!choiceInfos.some(function (choiceInfo) {
  3396. return choiceInfo.value === value;
  3397. })) {
  3398. var choices = choiceInfos.filter(function (choiceInfo) {
  3399. return !choiceInfo.deprecated;
  3400. }).map(function (choiceInfo) {
  3401. return JSON.stringify(choiceInfo.value);
  3402. }).sort();
  3403. var head = choices.slice(0, -2);
  3404. var tail = choices.slice(-2);
  3405. throw new Error("Expected ".concat(head.concat(tail.join(" or ")).join(", ")));
  3406. }
  3407. }
  3408. var optionsValidator = {
  3409. validateOption: validateOption
  3410. };
  3411. function normalizeOptions$1(options, optionInfos, opts) {
  3412. opts = opts || {};
  3413. var logger = opts.logger === false ? {
  3414. warn: function warn() {}
  3415. } : opts.logger !== undefined ? opts.logger : console;
  3416. var descriptor = opts.descriptor || optionsDescriptor.apiDescriptor;
  3417. var passThrough = opts.passThrough || [];
  3418. var optionInfoMap = optionInfos.reduce(function (reduced, optionInfo) {
  3419. return Object.assign(reduced, _defineProperty({}, optionInfo.name, optionInfo));
  3420. }, {});
  3421. var normalizedOptions = Object.keys(options).reduce(function (newOptions, key) {
  3422. var optionInfo = optionInfoMap[key];
  3423. var optionName = key;
  3424. var optionValue = options[key];
  3425. if (!optionInfo) {
  3426. if (passThrough === true || passThrough.indexOf(optionName) !== -1) {
  3427. newOptions[optionName] = optionValue;
  3428. } else {
  3429. logger.warn(createUnknownOptionMessage(optionName, optionValue, optionInfos, descriptor));
  3430. }
  3431. return newOptions;
  3432. }
  3433. if (!optionInfo.deprecated) {
  3434. optionValue = normalizeOption(optionValue, optionInfo);
  3435. } else if (typeof optionInfo.redirect === "string") {
  3436. logger.warn(createRedirectOptionMessage(optionInfo, descriptor));
  3437. optionName = optionInfo.redirect;
  3438. } else if (optionValue) {
  3439. logger.warn(createRedirectOptionMessage(optionInfo, descriptor));
  3440. optionValue = optionInfo.redirect.value;
  3441. optionName = optionInfo.redirect.option;
  3442. }
  3443. if (optionInfo.choices) {
  3444. var choiceInfo = optionInfo.choices.find(function (choice) {
  3445. return choice.value === optionValue;
  3446. });
  3447. if (choiceInfo && choiceInfo.deprecated) {
  3448. logger.warn(createRedirectChoiceMessage(optionInfo, choiceInfo, descriptor));
  3449. optionValue = choiceInfo.redirect;
  3450. }
  3451. }
  3452. if (optionInfo.array && !Array.isArray(optionValue)) {
  3453. optionValue = [optionValue];
  3454. }
  3455. if (optionValue !== optionInfo.default) {
  3456. optionsValidator.validateOption(optionValue, optionInfoMap[optionName], {
  3457. descriptor: descriptor
  3458. });
  3459. }
  3460. newOptions[optionName] = optionValue;
  3461. return newOptions;
  3462. }, {});
  3463. return normalizedOptions;
  3464. }
  3465. function normalizeOption(option, optionInfo) {
  3466. return optionInfo.type === "int" ? Number(option) : option;
  3467. }
  3468. function createUnknownOptionMessage(key, value, optionInfos, descriptor) {
  3469. var messages = ["Ignored unknown option ".concat(descriptor(key, value), ".")];
  3470. var suggestedOptionInfo = optionInfos.find(function (optionInfo) {
  3471. return leven(optionInfo.name, key) < 3;
  3472. });
  3473. if (suggestedOptionInfo) {
  3474. messages.push("Did you mean ".concat(JSON.stringify(suggestedOptionInfo.name), "?"));
  3475. }
  3476. return messages.join(" ");
  3477. }
  3478. function createRedirectOptionMessage(optionInfo, descriptor) {
  3479. return "".concat(descriptor(optionInfo.name), " is deprecated. Prettier now treats it as ").concat(typeof optionInfo.redirect === "string" ? descriptor(optionInfo.redirect) : descriptor(optionInfo.redirect.option, optionInfo.redirect.value), ".");
  3480. }
  3481. function createRedirectChoiceMessage(optionInfo, choiceInfo, descriptor) {
  3482. return "".concat(descriptor(optionInfo.name, choiceInfo.value), " is deprecated. Prettier now treats it as ").concat(descriptor(optionInfo.name, choiceInfo.redirect), ".");
  3483. }
  3484. function normalizeApiOptions(options, optionInfos, opts) {
  3485. return normalizeOptions$1(options, optionInfos, Object.assign({
  3486. descriptor: optionsDescriptor.apiDescriptor
  3487. }, opts));
  3488. }
  3489. function normalizeCliOptions(options, optionInfos, opts) {
  3490. var args = options["_"] || [];
  3491. var newOptions = normalizeOptions$1(Object.keys(options).reduce(function (reduced, key) {
  3492. return Object.assign(reduced, key.length === 1 // omit alias
  3493. ? null : _defineProperty({}, key, options[key]));
  3494. }, {}), optionInfos, Object.assign({
  3495. descriptor: optionsDescriptor.cliDescriptor
  3496. }, opts));
  3497. newOptions["_"] = args;
  3498. return newOptions;
  3499. }
  3500. var optionsNormalizer = {
  3501. normalizeApiOptions: normalizeApiOptions,
  3502. normalizeCliOptions: normalizeCliOptions
  3503. };
  3504. var getLast = function getLast(arr) {
  3505. return arr.length > 0 ? arr[arr.length - 1] : null;
  3506. };
  3507. function locStart$1(node) {
  3508. // Handle nodes with decorators. They should start at the first decorator
  3509. if (node.declaration && node.declaration.decorators && node.declaration.decorators.length > 0) {
  3510. return locStart$1(node.declaration.decorators[0]);
  3511. }
  3512. if (node.decorators && node.decorators.length > 0) {
  3513. return locStart$1(node.decorators[0]);
  3514. }
  3515. if (node.__location) {
  3516. return node.__location.startOffset;
  3517. }
  3518. if (node.range) {
  3519. return node.range[0];
  3520. }
  3521. if (typeof node.start === "number") {
  3522. return node.start;
  3523. }
  3524. if (node.loc) {
  3525. return node.loc.start;
  3526. }
  3527. return null;
  3528. }
  3529. function locEnd$1(node) {
  3530. var endNode = node.nodes && getLast(node.nodes);
  3531. if (endNode && node.source && !node.source.end) {
  3532. node = endNode;
  3533. }
  3534. if (node.__location) {
  3535. return node.__location.endOffset;
  3536. }
  3537. var loc = node.range ? node.range[1] : typeof node.end === "number" ? node.end : null;
  3538. if (node.typeAnnotation) {
  3539. return Math.max(loc, locEnd$1(node.typeAnnotation));
  3540. }
  3541. if (node.loc && !loc) {
  3542. return node.loc.end;
  3543. }
  3544. return loc;
  3545. }
  3546. var loc = {
  3547. locStart: locStart$1,
  3548. locEnd: locEnd$1
  3549. };
  3550. var jsTokens = createCommonjsModule(function (module, exports) {
  3551. // Copyright 2014, 2015, 2016, 2017 Simon Lydell
  3552. // License: MIT. (See LICENSE.)
  3553. Object.defineProperty(exports, "__esModule", {
  3554. value: true
  3555. }); // This regex comes from regex.coffee, and is inserted here by generate-index.js
  3556. // (run `npm run build`).
  3557. exports.default = /((['"])(?:(?!\2|\\).|\\(?:\r\n|[\s\S]))*(\2)?|`(?:[^`\\$]|\\[\s\S]|\$(?!\{)|\$\{(?:[^{}]|\{[^}]*\}?)*\}?)*(`)?)|(\/\/.*)|(\/\*(?:[^*]|\*(?!\/))*(\*\/)?)|(\/(?!\*)(?:\[(?:(?![\]\\]).|\\.)*\]|(?![\/\]\\]).|\\.)+\/(?:(?!\s*(?:\b|[\u0080-\uFFFF$\\'"~({]|[+\-!](?!=)|\.?\d))|[gmiyu]{1,5}\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;
  3558. exports.matchToToken = function (match) {
  3559. var token = {
  3560. type: "invalid",
  3561. value: match[0]
  3562. };
  3563. 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";
  3564. return token;
  3565. };
  3566. });
  3567. unwrapExports(jsTokens);
  3568. var ast = createCommonjsModule(function (module) {
  3569. /*
  3570. Copyright (C) 2013 Yusuke Suzuki <utatane.tea@gmail.com>
  3571. Redistribution and use in source and binary forms, with or without
  3572. modification, are permitted provided that the following conditions are met:
  3573. * Redistributions of source code must retain the above copyright
  3574. notice, this list of conditions and the following disclaimer.
  3575. * Redistributions in binary form must reproduce the above copyright
  3576. notice, this list of conditions and the following disclaimer in the
  3577. documentation and/or other materials provided with the distribution.
  3578. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS'
  3579. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  3580. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  3581. ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
  3582. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  3583. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  3584. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  3585. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  3586. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  3587. THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  3588. */
  3589. (function () {
  3590. 'use strict';
  3591. function isExpression(node) {
  3592. if (node == null) {
  3593. return false;
  3594. }
  3595. switch (node.type) {
  3596. case 'ArrayExpression':
  3597. case 'AssignmentExpression':
  3598. case 'BinaryExpression':
  3599. case 'CallExpression':
  3600. case 'ConditionalExpression':
  3601. case 'FunctionExpression':
  3602. case 'Identifier':
  3603. case 'Literal':
  3604. case 'LogicalExpression':
  3605. case 'MemberExpression':
  3606. case 'NewExpression':
  3607. case 'ObjectExpression':
  3608. case 'SequenceExpression':
  3609. case 'ThisExpression':
  3610. case 'UnaryExpression':
  3611. case 'UpdateExpression':
  3612. return true;
  3613. }
  3614. return false;
  3615. }
  3616. function isIterationStatement(node) {
  3617. if (node == null) {
  3618. return false;
  3619. }
  3620. switch (node.type) {
  3621. case 'DoWhileStatement':
  3622. case 'ForInStatement':
  3623. case 'ForStatement':
  3624. case 'WhileStatement':
  3625. return true;
  3626. }
  3627. return false;
  3628. }
  3629. function isStatement(node) {
  3630. if (node == null) {
  3631. return false;
  3632. }
  3633. switch (node.type) {
  3634. case 'BlockStatement':
  3635. case 'BreakStatement':
  3636. case 'ContinueStatement':
  3637. case 'DebuggerStatement':
  3638. case 'DoWhileStatement':
  3639. case 'EmptyStatement':
  3640. case 'ExpressionStatement':
  3641. case 'ForInStatement':
  3642. case 'ForStatement':
  3643. case 'IfStatement':
  3644. case 'LabeledStatement':
  3645. case 'ReturnStatement':
  3646. case 'SwitchStatement':
  3647. case 'ThrowStatement':
  3648. case 'TryStatement':
  3649. case 'VariableDeclaration':
  3650. case 'WhileStatement':
  3651. case 'WithStatement':
  3652. return true;
  3653. }
  3654. return false;
  3655. }
  3656. function isSourceElement(node) {
  3657. return isStatement(node) || node != null && node.type === 'FunctionDeclaration';
  3658. }
  3659. function trailingStatement(node) {
  3660. switch (node.type) {
  3661. case 'IfStatement':
  3662. if (node.alternate != null) {
  3663. return node.alternate;
  3664. }
  3665. return node.consequent;
  3666. case 'LabeledStatement':
  3667. case 'ForStatement':
  3668. case 'ForInStatement':
  3669. case 'WhileStatement':
  3670. case 'WithStatement':
  3671. return node.body;
  3672. }
  3673. return null;
  3674. }
  3675. function isProblematicIfStatement(node) {
  3676. var current;
  3677. if (node.type !== 'IfStatement') {
  3678. return false;
  3679. }
  3680. if (node.alternate == null) {
  3681. return false;
  3682. }
  3683. current = node.consequent;
  3684. do {
  3685. if (current.type === 'IfStatement') {
  3686. if (current.alternate == null) {
  3687. return true;
  3688. }
  3689. }
  3690. current = trailingStatement(current);
  3691. } while (current);
  3692. return false;
  3693. }
  3694. module.exports = {
  3695. isExpression: isExpression,
  3696. isStatement: isStatement,
  3697. isIterationStatement: isIterationStatement,
  3698. isSourceElement: isSourceElement,
  3699. isProblematicIfStatement: isProblematicIfStatement,
  3700. trailingStatement: trailingStatement
  3701. };
  3702. })();
  3703. /* vim: set sw=4 ts=4 et tw=80 : */
  3704. });
  3705. var code = createCommonjsModule(function (module) {
  3706. /*
  3707. Copyright (C) 2013-2014 Yusuke Suzuki <utatane.tea@gmail.com>
  3708. Copyright (C) 2014 Ivan Nikulin <ifaaan@gmail.com>
  3709. Redistribution and use in source and binary forms, with or without
  3710. modification, are permitted provided that the following conditions are met:
  3711. * Redistributions of source code must retain the above copyright
  3712. notice, this list of conditions and the following disclaimer.
  3713. * Redistributions in binary form must reproduce the above copyright
  3714. notice, this list of conditions and the following disclaimer in the
  3715. documentation and/or other materials provided with the distribution.
  3716. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  3717. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  3718. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  3719. ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
  3720. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  3721. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  3722. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  3723. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  3724. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  3725. THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  3726. */
  3727. (function () {
  3728. 'use strict';
  3729. var ES6Regex, ES5Regex, NON_ASCII_WHITESPACES, IDENTIFIER_START, IDENTIFIER_PART, ch; // See `tools/generate-identifier-regex.js`.
  3730. ES5Regex = {
  3731. // ECMAScript 5.1/Unicode v7.0.0 NonAsciiIdentifierStart:
  3732. NonAsciiIdentifierStart: /[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0-\u08B2\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D60\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19C1-\u19C7\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA7AD\uA7B0\uA7B1\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB5F\uAB64\uAB65\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]/,
  3733. // ECMAScript 5.1/Unicode v7.0.0 NonAsciiIdentifierPart:
  3734. NonAsciiIdentifierPart: /[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u08A0-\u08B2\u08E4-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58\u0C59\u0C60-\u0C63\u0C66-\u0C6F\u0C81-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D01-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D57\u0D60-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19D9\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1CD0-\u1CD2\u1CD4-\u1CF6\u1CF8\u1CF9\u1D00-\u1DF5\u1DFC-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u200C\u200D\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u2E2F\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA69D\uA69F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA7AD\uA7B0\uA7B1\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C4\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB5F\uAB64\uAB65\uABC0-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2D\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]/
  3735. };
  3736. ES6Regex = {
  3737. // ECMAScript 6/Unicode v7.0.0 NonAsciiIdentifierStart:
  3738. NonAsciiIdentifierStart: /[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0-\u08B2\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D60\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19C1-\u19C7\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309B-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA7AD\uA7B0\uA7B1\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB5F\uAB64\uAB65\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF30-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDE00-\uDE11\uDE13-\uDE2B\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF5D-\uDF61]|\uD805[\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDE00-\uDE2F\uDE44\uDE80-\uDEAA]|\uD806[\uDCA0-\uDCDF\uDCFF\uDEC0-\uDEF8]|\uD808[\uDC00-\uDF98]|\uD809[\uDC00-\uDC6E]|[\uD80C\uD840-\uD868\uD86A-\uD86C][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F]|\uD82C[\uDC00\uDC01]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD83A[\uDC00-\uDCC4]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D]|\uD87E[\uDC00-\uDE1D]/,
  3739. // ECMAScript 6/Unicode v7.0.0 NonAsciiIdentifierPart:
  3740. NonAsciiIdentifierPart: /[\xAA\xB5\xB7\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u08A0-\u08B2\u08E4-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58\u0C59\u0C60-\u0C63\u0C66-\u0C6F\u0C81-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D01-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D57\u0D60-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1369-\u1371\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19DA\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1CD0-\u1CD2\u1CD4-\u1CF6\u1CF8\u1CF9\u1D00-\u1DF5\u1DFC-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u200C\u200D\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA69D\uA69F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA7AD\uA7B0\uA7B1\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C4\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB5F\uAB64\uAB65\uABC0-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2D\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0\uDF00-\uDF1F\uDF30-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE38-\uDE3A\uDE3F\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE6\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48]|\uD804[\uDC00-\uDC46\uDC66-\uDC6F\uDC7F-\uDCBA\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDD0-\uDDDA\uDE00-\uDE11\uDE13-\uDE37\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF01-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3C-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB7\uDEC0-\uDEC9]|\uD806[\uDCA0-\uDCE9\uDCFF\uDEC0-\uDEF8]|\uD808[\uDC00-\uDF98]|\uD809[\uDC00-\uDC6E]|[\uD80C\uD840-\uD868\uD86A-\uD86C][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50-\uDF7E\uDF8F-\uDF9F]|\uD82C[\uDC00\uDC01]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D]|\uD87E[\uDC00-\uDE1D]|\uDB40[\uDD00-\uDDEF]/
  3741. };
  3742. function isDecimalDigit(ch) {
  3743. return 0x30 <= ch && ch <= 0x39; // 0..9
  3744. }
  3745. function isHexDigit(ch) {
  3746. return 0x30 <= ch && ch <= 0x39 || // 0..9
  3747. 0x61 <= ch && ch <= 0x66 || // a..f
  3748. 0x41 <= ch && ch <= 0x46; // A..F
  3749. }
  3750. function isOctalDigit(ch) {
  3751. return ch >= 0x30 && ch <= 0x37; // 0..7
  3752. } // 7.2 White Space
  3753. NON_ASCII_WHITESPACES = [0x1680, 0x180E, 0x2000, 0x2001, 0x2002, 0x2003, 0x2004, 0x2005, 0x2006, 0x2007, 0x2008, 0x2009, 0x200A, 0x202F, 0x205F, 0x3000, 0xFEFF];
  3754. function isWhiteSpace(ch) {
  3755. return ch === 0x20 || ch === 0x09 || ch === 0x0B || ch === 0x0C || ch === 0xA0 || ch >= 0x1680 && NON_ASCII_WHITESPACES.indexOf(ch) >= 0;
  3756. } // 7.3 Line Terminators
  3757. function isLineTerminator(ch) {
  3758. return ch === 0x0A || ch === 0x0D || ch === 0x2028 || ch === 0x2029;
  3759. } // 7.6 Identifier Names and Identifiers
  3760. function fromCodePoint(cp) {
  3761. if (cp <= 0xFFFF) {
  3762. return String.fromCharCode(cp);
  3763. }
  3764. var cu1 = String.fromCharCode(Math.floor((cp - 0x10000) / 0x400) + 0xD800);
  3765. var cu2 = String.fromCharCode((cp - 0x10000) % 0x400 + 0xDC00);
  3766. return cu1 + cu2;
  3767. }
  3768. IDENTIFIER_START = new Array(0x80);
  3769. for (ch = 0; ch < 0x80; ++ch) {
  3770. IDENTIFIER_START[ch] = ch >= 0x61 && ch <= 0x7A || // a..z
  3771. ch >= 0x41 && ch <= 0x5A || // A..Z
  3772. ch === 0x24 || ch === 0x5F; // $ (dollar) and _ (underscore)
  3773. }
  3774. IDENTIFIER_PART = new Array(0x80);
  3775. for (ch = 0; ch < 0x80; ++ch) {
  3776. IDENTIFIER_PART[ch] = ch >= 0x61 && ch <= 0x7A || // a..z
  3777. ch >= 0x41 && ch <= 0x5A || // A..Z
  3778. ch >= 0x30 && ch <= 0x39 || // 0..9
  3779. ch === 0x24 || ch === 0x5F; // $ (dollar) and _ (underscore)
  3780. }
  3781. function isIdentifierStartES5(ch) {
  3782. return ch < 0x80 ? IDENTIFIER_START[ch] : ES5Regex.NonAsciiIdentifierStart.test(fromCodePoint(ch));
  3783. }
  3784. function isIdentifierPartES5(ch) {
  3785. return ch < 0x80 ? IDENTIFIER_PART[ch] : ES5Regex.NonAsciiIdentifierPart.test(fromCodePoint(ch));
  3786. }
  3787. function isIdentifierStartES6(ch) {
  3788. return ch < 0x80 ? IDENTIFIER_START[ch] : ES6Regex.NonAsciiIdentifierStart.test(fromCodePoint(ch));
  3789. }
  3790. function isIdentifierPartES6(ch) {
  3791. return ch < 0x80 ? IDENTIFIER_PART[ch] : ES6Regex.NonAsciiIdentifierPart.test(fromCodePoint(ch));
  3792. }
  3793. module.exports = {
  3794. isDecimalDigit: isDecimalDigit,
  3795. isHexDigit: isHexDigit,
  3796. isOctalDigit: isOctalDigit,
  3797. isWhiteSpace: isWhiteSpace,
  3798. isLineTerminator: isLineTerminator,
  3799. isIdentifierStartES5: isIdentifierStartES5,
  3800. isIdentifierPartES5: isIdentifierPartES5,
  3801. isIdentifierStartES6: isIdentifierStartES6,
  3802. isIdentifierPartES6: isIdentifierPartES6
  3803. };
  3804. })();
  3805. /* vim: set sw=4 ts=4 et tw=80 : */
  3806. });
  3807. var keyword = createCommonjsModule(function (module) {
  3808. /*
  3809. Copyright (C) 2013 Yusuke Suzuki <utatane.tea@gmail.com>
  3810. Redistribution and use in source and binary forms, with or without
  3811. modification, are permitted provided that the following conditions are met:
  3812. * Redistributions of source code must retain the above copyright
  3813. notice, this list of conditions and the following disclaimer.
  3814. * Redistributions in binary form must reproduce the above copyright
  3815. notice, this list of conditions and the following disclaimer in the
  3816. documentation and/or other materials provided with the distribution.
  3817. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  3818. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  3819. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  3820. ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
  3821. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  3822. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  3823. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  3824. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  3825. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  3826. THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  3827. */
  3828. (function () {
  3829. 'use strict';
  3830. var code$$1 = code;
  3831. function isStrictModeReservedWordES6(id) {
  3832. switch (id) {
  3833. case 'implements':
  3834. case 'interface':
  3835. case 'package':
  3836. case 'private':
  3837. case 'protected':
  3838. case 'public':
  3839. case 'static':
  3840. case 'let':
  3841. return true;
  3842. default:
  3843. return false;
  3844. }
  3845. }
  3846. function isKeywordES5(id, strict) {
  3847. // yield should not be treated as keyword under non-strict mode.
  3848. if (!strict && id === 'yield') {
  3849. return false;
  3850. }
  3851. return isKeywordES6(id, strict);
  3852. }
  3853. function isKeywordES6(id, strict) {
  3854. if (strict && isStrictModeReservedWordES6(id)) {
  3855. return true;
  3856. }
  3857. switch (id.length) {
  3858. case 2:
  3859. return id === 'if' || id === 'in' || id === 'do';
  3860. case 3:
  3861. return id === 'var' || id === 'for' || id === 'new' || id === 'try';
  3862. case 4:
  3863. return id === 'this' || id === 'else' || id === 'case' || id === 'void' || id === 'with' || id === 'enum';
  3864. case 5:
  3865. return id === 'while' || id === 'break' || id === 'catch' || id === 'throw' || id === 'const' || id === 'yield' || id === 'class' || id === 'super';
  3866. case 6:
  3867. return id === 'return' || id === 'typeof' || id === 'delete' || id === 'switch' || id === 'export' || id === 'import';
  3868. case 7:
  3869. return id === 'default' || id === 'finally' || id === 'extends';
  3870. case 8:
  3871. return id === 'function' || id === 'continue' || id === 'debugger';
  3872. case 10:
  3873. return id === 'instanceof';
  3874. default:
  3875. return false;
  3876. }
  3877. }
  3878. function isReservedWordES5(id, strict) {
  3879. return id === 'null' || id === 'true' || id === 'false' || isKeywordES5(id, strict);
  3880. }
  3881. function isReservedWordES6(id, strict) {
  3882. return id === 'null' || id === 'true' || id === 'false' || isKeywordES6(id, strict);
  3883. }
  3884. function isRestrictedWord(id) {
  3885. return id === 'eval' || id === 'arguments';
  3886. }
  3887. function isIdentifierNameES5(id) {
  3888. var i, iz, ch;
  3889. if (id.length === 0) {
  3890. return false;
  3891. }
  3892. ch = id.charCodeAt(0);
  3893. if (!code$$1.isIdentifierStartES5(ch)) {
  3894. return false;
  3895. }
  3896. for (i = 1, iz = id.length; i < iz; ++i) {
  3897. ch = id.charCodeAt(i);
  3898. if (!code$$1.isIdentifierPartES5(ch)) {
  3899. return false;
  3900. }
  3901. }
  3902. return true;
  3903. }
  3904. function decodeUtf16(lead, trail) {
  3905. return (lead - 0xD800) * 0x400 + (trail - 0xDC00) + 0x10000;
  3906. }
  3907. function isIdentifierNameES6(id) {
  3908. var i, iz, ch, lowCh, check;
  3909. if (id.length === 0) {
  3910. return false;
  3911. }
  3912. check = code$$1.isIdentifierStartES6;
  3913. for (i = 0, iz = id.length; i < iz; ++i) {
  3914. ch = id.charCodeAt(i);
  3915. if (0xD800 <= ch && ch <= 0xDBFF) {
  3916. ++i;
  3917. if (i >= iz) {
  3918. return false;
  3919. }
  3920. lowCh = id.charCodeAt(i);
  3921. if (!(0xDC00 <= lowCh && lowCh <= 0xDFFF)) {
  3922. return false;
  3923. }
  3924. ch = decodeUtf16(ch, lowCh);
  3925. }
  3926. if (!check(ch)) {
  3927. return false;
  3928. }
  3929. check = code$$1.isIdentifierPartES6;
  3930. }
  3931. return true;
  3932. }
  3933. function isIdentifierES5(id, strict) {
  3934. return isIdentifierNameES5(id) && !isReservedWordES5(id, strict);
  3935. }
  3936. function isIdentifierES6(id, strict) {
  3937. return isIdentifierNameES6(id) && !isReservedWordES6(id, strict);
  3938. }
  3939. module.exports = {
  3940. isKeywordES5: isKeywordES5,
  3941. isKeywordES6: isKeywordES6,
  3942. isReservedWordES5: isReservedWordES5,
  3943. isReservedWordES6: isReservedWordES6,
  3944. isRestrictedWord: isRestrictedWord,
  3945. isIdentifierNameES5: isIdentifierNameES5,
  3946. isIdentifierNameES6: isIdentifierNameES6,
  3947. isIdentifierES5: isIdentifierES5,
  3948. isIdentifierES6: isIdentifierES6
  3949. };
  3950. })();
  3951. /* vim: set sw=4 ts=4 et tw=80 : */
  3952. });
  3953. var utils = createCommonjsModule(function (module, exports) {
  3954. /*
  3955. Copyright (C) 2013 Yusuke Suzuki <utatane.tea@gmail.com>
  3956. Redistribution and use in source and binary forms, with or without
  3957. modification, are permitted provided that the following conditions are met:
  3958. * Redistributions of source code must retain the above copyright
  3959. notice, this list of conditions and the following disclaimer.
  3960. * Redistributions in binary form must reproduce the above copyright
  3961. notice, this list of conditions and the following disclaimer in the
  3962. documentation and/or other materials provided with the distribution.
  3963. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  3964. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  3965. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  3966. ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
  3967. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  3968. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  3969. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  3970. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  3971. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  3972. THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  3973. */
  3974. (function () {
  3975. 'use strict';
  3976. exports.ast = ast;
  3977. exports.code = code;
  3978. exports.keyword = keyword;
  3979. })();
  3980. /* vim: set sw=4 ts=4 et tw=80 : */
  3981. });
  3982. var matchOperatorsRe = /[|\\{}()[\]^$+*?.]/g;
  3983. var escapeStringRegexp = function escapeStringRegexp(str) {
  3984. if (typeof str !== 'string') {
  3985. throw new TypeError('Expected a string');
  3986. }
  3987. return str.replace(matchOperatorsRe, '\\$&');
  3988. };
  3989. var colorName = {
  3990. "aliceblue": [240, 248, 255],
  3991. "antiquewhite": [250, 235, 215],
  3992. "aqua": [0, 255, 255],
  3993. "aquamarine": [127, 255, 212],
  3994. "azure": [240, 255, 255],
  3995. "beige": [245, 245, 220],
  3996. "bisque": [255, 228, 196],
  3997. "black": [0, 0, 0],
  3998. "blanchedalmond": [255, 235, 205],
  3999. "blue": [0, 0, 255],
  4000. "blueviolet": [138, 43, 226],
  4001. "brown": [165, 42, 42],
  4002. "burlywood": [222, 184, 135],
  4003. "cadetblue": [95, 158, 160],
  4004. "chartreuse": [127, 255, 0],
  4005. "chocolate": [210, 105, 30],
  4006. "coral": [255, 127, 80],
  4007. "cornflowerblue": [100, 149, 237],
  4008. "cornsilk": [255, 248, 220],
  4009. "crimson": [220, 20, 60],
  4010. "cyan": [0, 255, 255],
  4011. "darkblue": [0, 0, 139],
  4012. "darkcyan": [0, 139, 139],
  4013. "darkgoldenrod": [184, 134, 11],
  4014. "darkgray": [169, 169, 169],
  4015. "darkgreen": [0, 100, 0],
  4016. "darkgrey": [169, 169, 169],
  4017. "darkkhaki": [189, 183, 107],
  4018. "darkmagenta": [139, 0, 139],
  4019. "darkolivegreen": [85, 107, 47],
  4020. "darkorange": [255, 140, 0],
  4021. "darkorchid": [153, 50, 204],
  4022. "darkred": [139, 0, 0],
  4023. "darksalmon": [233, 150, 122],
  4024. "darkseagreen": [143, 188, 143],
  4025. "darkslateblue": [72, 61, 139],
  4026. "darkslategray": [47, 79, 79],
  4027. "darkslategrey": [47, 79, 79],
  4028. "darkturquoise": [0, 206, 209],
  4029. "darkviolet": [148, 0, 211],
  4030. "deeppink": [255, 20, 147],
  4031. "deepskyblue": [0, 191, 255],
  4032. "dimgray": [105, 105, 105],
  4033. "dimgrey": [105, 105, 105],
  4034. "dodgerblue": [30, 144, 255],
  4035. "firebrick": [178, 34, 34],
  4036. "floralwhite": [255, 250, 240],
  4037. "forestgreen": [34, 139, 34],
  4038. "fuchsia": [255, 0, 255],
  4039. "gainsboro": [220, 220, 220],
  4040. "ghostwhite": [248, 248, 255],
  4041. "gold": [255, 215, 0],
  4042. "goldenrod": [218, 165, 32],
  4043. "gray": [128, 128, 128],
  4044. "green": [0, 128, 0],
  4045. "greenyellow": [173, 255, 47],
  4046. "grey": [128, 128, 128],
  4047. "honeydew": [240, 255, 240],
  4048. "hotpink": [255, 105, 180],
  4049. "indianred": [205, 92, 92],
  4050. "indigo": [75, 0, 130],
  4051. "ivory": [255, 255, 240],
  4052. "khaki": [240, 230, 140],
  4053. "lavender": [230, 230, 250],
  4054. "lavenderblush": [255, 240, 245],
  4055. "lawngreen": [124, 252, 0],
  4056. "lemonchiffon": [255, 250, 205],
  4057. "lightblue": [173, 216, 230],
  4058. "lightcoral": [240, 128, 128],
  4059. "lightcyan": [224, 255, 255],
  4060. "lightgoldenrodyellow": [250, 250, 210],
  4061. "lightgray": [211, 211, 211],
  4062. "lightgreen": [144, 238, 144],
  4063. "lightgrey": [211, 211, 211],
  4064. "lightpink": [255, 182, 193],
  4065. "lightsalmon": [255, 160, 122],
  4066. "lightseagreen": [32, 178, 170],
  4067. "lightskyblue": [135, 206, 250],
  4068. "lightslategray": [119, 136, 153],
  4069. "lightslategrey": [119, 136, 153],
  4070. "lightsteelblue": [176, 196, 222],
  4071. "lightyellow": [255, 255, 224],
  4072. "lime": [0, 255, 0],
  4073. "limegreen": [50, 205, 50],
  4074. "linen": [250, 240, 230],
  4075. "magenta": [255, 0, 255],
  4076. "maroon": [128, 0, 0],
  4077. "mediumaquamarine": [102, 205, 170],
  4078. "mediumblue": [0, 0, 205],
  4079. "mediumorchid": [186, 85, 211],
  4080. "mediumpurple": [147, 112, 219],
  4081. "mediumseagreen": [60, 179, 113],
  4082. "mediumslateblue": [123, 104, 238],
  4083. "mediumspringgreen": [0, 250, 154],
  4084. "mediumturquoise": [72, 209, 204],
  4085. "mediumvioletred": [199, 21, 133],
  4086. "midnightblue": [25, 25, 112],
  4087. "mintcream": [245, 255, 250],
  4088. "mistyrose": [255, 228, 225],
  4089. "moccasin": [255, 228, 181],
  4090. "navajowhite": [255, 222, 173],
  4091. "navy": [0, 0, 128],
  4092. "oldlace": [253, 245, 230],
  4093. "olive": [128, 128, 0],
  4094. "olivedrab": [107, 142, 35],
  4095. "orange": [255, 165, 0],
  4096. "orangered": [255, 69, 0],
  4097. "orchid": [218, 112, 214],
  4098. "palegoldenrod": [238, 232, 170],
  4099. "palegreen": [152, 251, 152],
  4100. "paleturquoise": [175, 238, 238],
  4101. "palevioletred": [219, 112, 147],
  4102. "papayawhip": [255, 239, 213],
  4103. "peachpuff": [255, 218, 185],
  4104. "peru": [205, 133, 63],
  4105. "pink": [255, 192, 203],
  4106. "plum": [221, 160, 221],
  4107. "powderblue": [176, 224, 230],
  4108. "purple": [128, 0, 128],
  4109. "rebeccapurple": [102, 51, 153],
  4110. "red": [255, 0, 0],
  4111. "rosybrown": [188, 143, 143],
  4112. "royalblue": [65, 105, 225],
  4113. "saddlebrown": [139, 69, 19],
  4114. "salmon": [250, 128, 114],
  4115. "sandybrown": [244, 164, 96],
  4116. "seagreen": [46, 139, 87],
  4117. "seashell": [255, 245, 238],
  4118. "sienna": [160, 82, 45],
  4119. "silver": [192, 192, 192],
  4120. "skyblue": [135, 206, 235],
  4121. "slateblue": [106, 90, 205],
  4122. "slategray": [112, 128, 144],
  4123. "slategrey": [112, 128, 144],
  4124. "snow": [255, 250, 250],
  4125. "springgreen": [0, 255, 127],
  4126. "steelblue": [70, 130, 180],
  4127. "tan": [210, 180, 140],
  4128. "teal": [0, 128, 128],
  4129. "thistle": [216, 191, 216],
  4130. "tomato": [255, 99, 71],
  4131. "turquoise": [64, 224, 208],
  4132. "violet": [238, 130, 238],
  4133. "wheat": [245, 222, 179],
  4134. "white": [255, 255, 255],
  4135. "whitesmoke": [245, 245, 245],
  4136. "yellow": [255, 255, 0],
  4137. "yellowgreen": [154, 205, 50]
  4138. };
  4139. var conversions = createCommonjsModule(function (module) {
  4140. /* MIT license */
  4141. // NOTE: conversions should only return primitive values (i.e. arrays, or
  4142. // values that give correct `typeof` results).
  4143. // do not use box values types (i.e. Number(), String(), etc.)
  4144. var reverseKeywords = {};
  4145. for (var key in colorName) {
  4146. if (colorName.hasOwnProperty(key)) {
  4147. reverseKeywords[colorName[key]] = key;
  4148. }
  4149. }
  4150. var convert = module.exports = {
  4151. rgb: {
  4152. channels: 3,
  4153. labels: 'rgb'
  4154. },
  4155. hsl: {
  4156. channels: 3,
  4157. labels: 'hsl'
  4158. },
  4159. hsv: {
  4160. channels: 3,
  4161. labels: 'hsv'
  4162. },
  4163. hwb: {
  4164. channels: 3,
  4165. labels: 'hwb'
  4166. },
  4167. cmyk: {
  4168. channels: 4,
  4169. labels: 'cmyk'
  4170. },
  4171. xyz: {
  4172. channels: 3,
  4173. labels: 'xyz'
  4174. },
  4175. lab: {
  4176. channels: 3,
  4177. labels: 'lab'
  4178. },
  4179. lch: {
  4180. channels: 3,
  4181. labels: 'lch'
  4182. },
  4183. hex: {
  4184. channels: 1,
  4185. labels: ['hex']
  4186. },
  4187. keyword: {
  4188. channels: 1,
  4189. labels: ['keyword']
  4190. },
  4191. ansi16: {
  4192. channels: 1,
  4193. labels: ['ansi16']
  4194. },
  4195. ansi256: {
  4196. channels: 1,
  4197. labels: ['ansi256']
  4198. },
  4199. hcg: {
  4200. channels: 3,
  4201. labels: ['h', 'c', 'g']
  4202. },
  4203. apple: {
  4204. channels: 3,
  4205. labels: ['r16', 'g16', 'b16']
  4206. },
  4207. gray: {
  4208. channels: 1,
  4209. labels: ['gray']
  4210. }
  4211. }; // hide .channels and .labels properties
  4212. for (var model in convert) {
  4213. if (convert.hasOwnProperty(model)) {
  4214. if (!('channels' in convert[model])) {
  4215. throw new Error('missing channels property: ' + model);
  4216. }
  4217. if (!('labels' in convert[model])) {
  4218. throw new Error('missing channel labels property: ' + model);
  4219. }
  4220. if (convert[model].labels.length !== convert[model].channels) {
  4221. throw new Error('channel and label counts mismatch: ' + model);
  4222. }
  4223. var channels = convert[model].channels;
  4224. var labels = convert[model].labels;
  4225. delete convert[model].channels;
  4226. delete convert[model].labels;
  4227. Object.defineProperty(convert[model], 'channels', {
  4228. value: channels
  4229. });
  4230. Object.defineProperty(convert[model], 'labels', {
  4231. value: labels
  4232. });
  4233. }
  4234. }
  4235. convert.rgb.hsl = function (rgb) {
  4236. var r = rgb[0] / 255;
  4237. var g = rgb[1] / 255;
  4238. var b = rgb[2] / 255;
  4239. var min = Math.min(r, g, b);
  4240. var max = Math.max(r, g, b);
  4241. var delta = max - min;
  4242. var h;
  4243. var s;
  4244. var l;
  4245. if (max === min) {
  4246. h = 0;
  4247. } else if (r === max) {
  4248. h = (g - b) / delta;
  4249. } else if (g === max) {
  4250. h = 2 + (b - r) / delta;
  4251. } else if (b === max) {
  4252. h = 4 + (r - g) / delta;
  4253. }
  4254. h = Math.min(h * 60, 360);
  4255. if (h < 0) {
  4256. h += 360;
  4257. }
  4258. l = (min + max) / 2;
  4259. if (max === min) {
  4260. s = 0;
  4261. } else if (l <= 0.5) {
  4262. s = delta / (max + min);
  4263. } else {
  4264. s = delta / (2 - max - min);
  4265. }
  4266. return [h, s * 100, l * 100];
  4267. };
  4268. convert.rgb.hsv = function (rgb) {
  4269. var r = rgb[0];
  4270. var g = rgb[1];
  4271. var b = rgb[2];
  4272. var min = Math.min(r, g, b);
  4273. var max = Math.max(r, g, b);
  4274. var delta = max - min;
  4275. var h;
  4276. var s;
  4277. var v;
  4278. if (max === 0) {
  4279. s = 0;
  4280. } else {
  4281. s = delta / max * 1000 / 10;
  4282. }
  4283. if (max === min) {
  4284. h = 0;
  4285. } else if (r === max) {
  4286. h = (g - b) / delta;
  4287. } else if (g === max) {
  4288. h = 2 + (b - r) / delta;
  4289. } else if (b === max) {
  4290. h = 4 + (r - g) / delta;
  4291. }
  4292. h = Math.min(h * 60, 360);
  4293. if (h < 0) {
  4294. h += 360;
  4295. }
  4296. v = max / 255 * 1000 / 10;
  4297. return [h, s, v];
  4298. };
  4299. convert.rgb.hwb = function (rgb) {
  4300. var r = rgb[0];
  4301. var g = rgb[1];
  4302. var b = rgb[2];
  4303. var h = convert.rgb.hsl(rgb)[0];
  4304. var w = 1 / 255 * Math.min(r, Math.min(g, b));
  4305. b = 1 - 1 / 255 * Math.max(r, Math.max(g, b));
  4306. return [h, w * 100, b * 100];
  4307. };
  4308. convert.rgb.cmyk = function (rgb) {
  4309. var r = rgb[0] / 255;
  4310. var g = rgb[1] / 255;
  4311. var b = rgb[2] / 255;
  4312. var c;
  4313. var m;
  4314. var y;
  4315. var k;
  4316. k = Math.min(1 - r, 1 - g, 1 - b);
  4317. c = (1 - r - k) / (1 - k) || 0;
  4318. m = (1 - g - k) / (1 - k) || 0;
  4319. y = (1 - b - k) / (1 - k) || 0;
  4320. return [c * 100, m * 100, y * 100, k * 100];
  4321. };
  4322. /**
  4323. * See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
  4324. * */
  4325. function comparativeDistance(x, y) {
  4326. return Math.pow(x[0] - y[0], 2) + Math.pow(x[1] - y[1], 2) + Math.pow(x[2] - y[2], 2);
  4327. }
  4328. convert.rgb.keyword = function (rgb) {
  4329. var reversed = reverseKeywords[rgb];
  4330. if (reversed) {
  4331. return reversed;
  4332. }
  4333. var currentClosestDistance = Infinity;
  4334. var currentClosestKeyword;
  4335. for (var keyword in colorName) {
  4336. if (colorName.hasOwnProperty(keyword)) {
  4337. var value = colorName[keyword]; // Compute comparative distance
  4338. var distance = comparativeDistance(rgb, value); // Check if its less, if so set as closest
  4339. if (distance < currentClosestDistance) {
  4340. currentClosestDistance = distance;
  4341. currentClosestKeyword = keyword;
  4342. }
  4343. }
  4344. }
  4345. return currentClosestKeyword;
  4346. };
  4347. convert.keyword.rgb = function (keyword) {
  4348. return colorName[keyword];
  4349. };
  4350. convert.rgb.xyz = function (rgb) {
  4351. var r = rgb[0] / 255;
  4352. var g = rgb[1] / 255;
  4353. var b = rgb[2] / 255; // assume sRGB
  4354. r = r > 0.04045 ? Math.pow((r + 0.055) / 1.055, 2.4) : r / 12.92;
  4355. g = g > 0.04045 ? Math.pow((g + 0.055) / 1.055, 2.4) : g / 12.92;
  4356. b = b > 0.04045 ? Math.pow((b + 0.055) / 1.055, 2.4) : b / 12.92;
  4357. var x = r * 0.4124 + g * 0.3576 + b * 0.1805;
  4358. var y = r * 0.2126 + g * 0.7152 + b * 0.0722;
  4359. var z = r * 0.0193 + g * 0.1192 + b * 0.9505;
  4360. return [x * 100, y * 100, z * 100];
  4361. };
  4362. convert.rgb.lab = function (rgb) {
  4363. var xyz = convert.rgb.xyz(rgb);
  4364. var x = xyz[0];
  4365. var y = xyz[1];
  4366. var z = xyz[2];
  4367. var l;
  4368. var a;
  4369. var b;
  4370. x /= 95.047;
  4371. y /= 100;
  4372. z /= 108.883;
  4373. x = x > 0.008856 ? Math.pow(x, 1 / 3) : 7.787 * x + 16 / 116;
  4374. y = y > 0.008856 ? Math.pow(y, 1 / 3) : 7.787 * y + 16 / 116;
  4375. z = z > 0.008856 ? Math.pow(z, 1 / 3) : 7.787 * z + 16 / 116;
  4376. l = 116 * y - 16;
  4377. a = 500 * (x - y);
  4378. b = 200 * (y - z);
  4379. return [l, a, b];
  4380. };
  4381. convert.hsl.rgb = function (hsl) {
  4382. var h = hsl[0] / 360;
  4383. var s = hsl[1] / 100;
  4384. var l = hsl[2] / 100;
  4385. var t1;
  4386. var t2;
  4387. var t3;
  4388. var rgb;
  4389. var val;
  4390. if (s === 0) {
  4391. val = l * 255;
  4392. return [val, val, val];
  4393. }
  4394. if (l < 0.5) {
  4395. t2 = l * (1 + s);
  4396. } else {
  4397. t2 = l + s - l * s;
  4398. }
  4399. t1 = 2 * l - t2;
  4400. rgb = [0, 0, 0];
  4401. for (var i = 0; i < 3; i++) {
  4402. t3 = h + 1 / 3 * -(i - 1);
  4403. if (t3 < 0) {
  4404. t3++;
  4405. }
  4406. if (t3 > 1) {
  4407. t3--;
  4408. }
  4409. if (6 * t3 < 1) {
  4410. val = t1 + (t2 - t1) * 6 * t3;
  4411. } else if (2 * t3 < 1) {
  4412. val = t2;
  4413. } else if (3 * t3 < 2) {
  4414. val = t1 + (t2 - t1) * (2 / 3 - t3) * 6;
  4415. } else {
  4416. val = t1;
  4417. }
  4418. rgb[i] = val * 255;
  4419. }
  4420. return rgb;
  4421. };
  4422. convert.hsl.hsv = function (hsl) {
  4423. var h = hsl[0];
  4424. var s = hsl[1] / 100;
  4425. var l = hsl[2] / 100;
  4426. var smin = s;
  4427. var lmin = Math.max(l, 0.01);
  4428. var sv;
  4429. var v;
  4430. l *= 2;
  4431. s *= l <= 1 ? l : 2 - l;
  4432. smin *= lmin <= 1 ? lmin : 2 - lmin;
  4433. v = (l + s) / 2;
  4434. sv = l === 0 ? 2 * smin / (lmin + smin) : 2 * s / (l + s);
  4435. return [h, sv * 100, v * 100];
  4436. };
  4437. convert.hsv.rgb = function (hsv) {
  4438. var h = hsv[0] / 60;
  4439. var s = hsv[1] / 100;
  4440. var v = hsv[2] / 100;
  4441. var hi = Math.floor(h) % 6;
  4442. var f = h - Math.floor(h);
  4443. var p = 255 * v * (1 - s);
  4444. var q = 255 * v * (1 - s * f);
  4445. var t = 255 * v * (1 - s * (1 - f));
  4446. v *= 255;
  4447. switch (hi) {
  4448. case 0:
  4449. return [v, t, p];
  4450. case 1:
  4451. return [q, v, p];
  4452. case 2:
  4453. return [p, v, t];
  4454. case 3:
  4455. return [p, q, v];
  4456. case 4:
  4457. return [t, p, v];
  4458. case 5:
  4459. return [v, p, q];
  4460. }
  4461. };
  4462. convert.hsv.hsl = function (hsv) {
  4463. var h = hsv[0];
  4464. var s = hsv[1] / 100;
  4465. var v = hsv[2] / 100;
  4466. var vmin = Math.max(v, 0.01);
  4467. var lmin;
  4468. var sl;
  4469. var l;
  4470. l = (2 - s) * v;
  4471. lmin = (2 - s) * vmin;
  4472. sl = s * vmin;
  4473. sl /= lmin <= 1 ? lmin : 2 - lmin;
  4474. sl = sl || 0;
  4475. l /= 2;
  4476. return [h, sl * 100, l * 100];
  4477. }; // http://dev.w3.org/csswg/css-color/#hwb-to-rgb
  4478. convert.hwb.rgb = function (hwb) {
  4479. var h = hwb[0] / 360;
  4480. var wh = hwb[1] / 100;
  4481. var bl = hwb[2] / 100;
  4482. var ratio = wh + bl;
  4483. var i;
  4484. var v;
  4485. var f;
  4486. var n; // wh + bl cant be > 1
  4487. if (ratio > 1) {
  4488. wh /= ratio;
  4489. bl /= ratio;
  4490. }
  4491. i = Math.floor(6 * h);
  4492. v = 1 - bl;
  4493. f = 6 * h - i;
  4494. if ((i & 0x01) !== 0) {
  4495. f = 1 - f;
  4496. }
  4497. n = wh + f * (v - wh); // linear interpolation
  4498. var r;
  4499. var g;
  4500. var b;
  4501. switch (i) {
  4502. default:
  4503. case 6:
  4504. case 0:
  4505. r = v;
  4506. g = n;
  4507. b = wh;
  4508. break;
  4509. case 1:
  4510. r = n;
  4511. g = v;
  4512. b = wh;
  4513. break;
  4514. case 2:
  4515. r = wh;
  4516. g = v;
  4517. b = n;
  4518. break;
  4519. case 3:
  4520. r = wh;
  4521. g = n;
  4522. b = v;
  4523. break;
  4524. case 4:
  4525. r = n;
  4526. g = wh;
  4527. b = v;
  4528. break;
  4529. case 5:
  4530. r = v;
  4531. g = wh;
  4532. b = n;
  4533. break;
  4534. }
  4535. return [r * 255, g * 255, b * 255];
  4536. };
  4537. convert.cmyk.rgb = function (cmyk) {
  4538. var c = cmyk[0] / 100;
  4539. var m = cmyk[1] / 100;
  4540. var y = cmyk[2] / 100;
  4541. var k = cmyk[3] / 100;
  4542. var r;
  4543. var g;
  4544. var b;
  4545. r = 1 - Math.min(1, c * (1 - k) + k);
  4546. g = 1 - Math.min(1, m * (1 - k) + k);
  4547. b = 1 - Math.min(1, y * (1 - k) + k);
  4548. return [r * 255, g * 255, b * 255];
  4549. };
  4550. convert.xyz.rgb = function (xyz) {
  4551. var x = xyz[0] / 100;
  4552. var y = xyz[1] / 100;
  4553. var z = xyz[2] / 100;
  4554. var r;
  4555. var g;
  4556. var b;
  4557. r = x * 3.2406 + y * -1.5372 + z * -0.4986;
  4558. g = x * -0.9689 + y * 1.8758 + z * 0.0415;
  4559. b = x * 0.0557 + y * -0.2040 + z * 1.0570; // assume sRGB
  4560. r = r > 0.0031308 ? 1.055 * Math.pow(r, 1.0 / 2.4) - 0.055 : r * 12.92;
  4561. g = g > 0.0031308 ? 1.055 * Math.pow(g, 1.0 / 2.4) - 0.055 : g * 12.92;
  4562. b = b > 0.0031308 ? 1.055 * Math.pow(b, 1.0 / 2.4) - 0.055 : b * 12.92;
  4563. r = Math.min(Math.max(0, r), 1);
  4564. g = Math.min(Math.max(0, g), 1);
  4565. b = Math.min(Math.max(0, b), 1);
  4566. return [r * 255, g * 255, b * 255];
  4567. };
  4568. convert.xyz.lab = function (xyz) {
  4569. var x = xyz[0];
  4570. var y = xyz[1];
  4571. var z = xyz[2];
  4572. var l;
  4573. var a;
  4574. var b;
  4575. x /= 95.047;
  4576. y /= 100;
  4577. z /= 108.883;
  4578. x = x > 0.008856 ? Math.pow(x, 1 / 3) : 7.787 * x + 16 / 116;
  4579. y = y > 0.008856 ? Math.pow(y, 1 / 3) : 7.787 * y + 16 / 116;
  4580. z = z > 0.008856 ? Math.pow(z, 1 / 3) : 7.787 * z + 16 / 116;
  4581. l = 116 * y - 16;
  4582. a = 500 * (x - y);
  4583. b = 200 * (y - z);
  4584. return [l, a, b];
  4585. };
  4586. convert.lab.xyz = function (lab) {
  4587. var l = lab[0];
  4588. var a = lab[1];
  4589. var b = lab[2];
  4590. var x;
  4591. var y;
  4592. var z;
  4593. y = (l + 16) / 116;
  4594. x = a / 500 + y;
  4595. z = y - b / 200;
  4596. var y2 = Math.pow(y, 3);
  4597. var x2 = Math.pow(x, 3);
  4598. var z2 = Math.pow(z, 3);
  4599. y = y2 > 0.008856 ? y2 : (y - 16 / 116) / 7.787;
  4600. x = x2 > 0.008856 ? x2 : (x - 16 / 116) / 7.787;
  4601. z = z2 > 0.008856 ? z2 : (z - 16 / 116) / 7.787;
  4602. x *= 95.047;
  4603. y *= 100;
  4604. z *= 108.883;
  4605. return [x, y, z];
  4606. };
  4607. convert.lab.lch = function (lab) {
  4608. var l = lab[0];
  4609. var a = lab[1];
  4610. var b = lab[2];
  4611. var hr;
  4612. var h;
  4613. var c;
  4614. hr = Math.atan2(b, a);
  4615. h = hr * 360 / 2 / Math.PI;
  4616. if (h < 0) {
  4617. h += 360;
  4618. }
  4619. c = Math.sqrt(a * a + b * b);
  4620. return [l, c, h];
  4621. };
  4622. convert.lch.lab = function (lch) {
  4623. var l = lch[0];
  4624. var c = lch[1];
  4625. var h = lch[2];
  4626. var a;
  4627. var b;
  4628. var hr;
  4629. hr = h / 360 * 2 * Math.PI;
  4630. a = c * Math.cos(hr);
  4631. b = c * Math.sin(hr);
  4632. return [l, a, b];
  4633. };
  4634. convert.rgb.ansi16 = function (args) {
  4635. var r = args[0];
  4636. var g = args[1];
  4637. var b = args[2];
  4638. var value = 1 in arguments ? arguments[1] : convert.rgb.hsv(args)[2]; // hsv -> ansi16 optimization
  4639. value = Math.round(value / 50);
  4640. if (value === 0) {
  4641. return 30;
  4642. }
  4643. var ansi = 30 + (Math.round(b / 255) << 2 | Math.round(g / 255) << 1 | Math.round(r / 255));
  4644. if (value === 2) {
  4645. ansi += 60;
  4646. }
  4647. return ansi;
  4648. };
  4649. convert.hsv.ansi16 = function (args) {
  4650. // optimization here; we already know the value and don't need to get
  4651. // it converted for us.
  4652. return convert.rgb.ansi16(convert.hsv.rgb(args), args[2]);
  4653. };
  4654. convert.rgb.ansi256 = function (args) {
  4655. var r = args[0];
  4656. var g = args[1];
  4657. var b = args[2]; // we use the extended greyscale palette here, with the exception of
  4658. // black and white. normal palette only has 4 greyscale shades.
  4659. if (r === g && g === b) {
  4660. if (r < 8) {
  4661. return 16;
  4662. }
  4663. if (r > 248) {
  4664. return 231;
  4665. }
  4666. return Math.round((r - 8) / 247 * 24) + 232;
  4667. }
  4668. var ansi = 16 + 36 * Math.round(r / 255 * 5) + 6 * Math.round(g / 255 * 5) + Math.round(b / 255 * 5);
  4669. return ansi;
  4670. };
  4671. convert.ansi16.rgb = function (args) {
  4672. var color = args % 10; // handle greyscale
  4673. if (color === 0 || color === 7) {
  4674. if (args > 50) {
  4675. color += 3.5;
  4676. }
  4677. color = color / 10.5 * 255;
  4678. return [color, color, color];
  4679. }
  4680. var mult = (~~(args > 50) + 1) * 0.5;
  4681. var r = (color & 1) * mult * 255;
  4682. var g = (color >> 1 & 1) * mult * 255;
  4683. var b = (color >> 2 & 1) * mult * 255;
  4684. return [r, g, b];
  4685. };
  4686. convert.ansi256.rgb = function (args) {
  4687. // handle greyscale
  4688. if (args >= 232) {
  4689. var c = (args - 232) * 10 + 8;
  4690. return [c, c, c];
  4691. }
  4692. args -= 16;
  4693. var rem;
  4694. var r = Math.floor(args / 36) / 5 * 255;
  4695. var g = Math.floor((rem = args % 36) / 6) / 5 * 255;
  4696. var b = rem % 6 / 5 * 255;
  4697. return [r, g, b];
  4698. };
  4699. convert.rgb.hex = function (args) {
  4700. var integer = ((Math.round(args[0]) & 0xFF) << 16) + ((Math.round(args[1]) & 0xFF) << 8) + (Math.round(args[2]) & 0xFF);
  4701. var string = integer.toString(16).toUpperCase();
  4702. return '000000'.substring(string.length) + string;
  4703. };
  4704. convert.hex.rgb = function (args) {
  4705. var match = args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);
  4706. if (!match) {
  4707. return [0, 0, 0];
  4708. }
  4709. var colorString = match[0];
  4710. if (match[0].length === 3) {
  4711. colorString = colorString.split('').map(function (char) {
  4712. return char + char;
  4713. }).join('');
  4714. }
  4715. var integer = parseInt(colorString, 16);
  4716. var r = integer >> 16 & 0xFF;
  4717. var g = integer >> 8 & 0xFF;
  4718. var b = integer & 0xFF;
  4719. return [r, g, b];
  4720. };
  4721. convert.rgb.hcg = function (rgb) {
  4722. var r = rgb[0] / 255;
  4723. var g = rgb[1] / 255;
  4724. var b = rgb[2] / 255;
  4725. var max = Math.max(Math.max(r, g), b);
  4726. var min = Math.min(Math.min(r, g), b);
  4727. var chroma = max - min;
  4728. var grayscale;
  4729. var hue;
  4730. if (chroma < 1) {
  4731. grayscale = min / (1 - chroma);
  4732. } else {
  4733. grayscale = 0;
  4734. }
  4735. if (chroma <= 0) {
  4736. hue = 0;
  4737. } else if (max === r) {
  4738. hue = (g - b) / chroma % 6;
  4739. } else if (max === g) {
  4740. hue = 2 + (b - r) / chroma;
  4741. } else {
  4742. hue = 4 + (r - g) / chroma + 4;
  4743. }
  4744. hue /= 6;
  4745. hue %= 1;
  4746. return [hue * 360, chroma * 100, grayscale * 100];
  4747. };
  4748. convert.hsl.hcg = function (hsl) {
  4749. var s = hsl[1] / 100;
  4750. var l = hsl[2] / 100;
  4751. var c = 1;
  4752. var f = 0;
  4753. if (l < 0.5) {
  4754. c = 2.0 * s * l;
  4755. } else {
  4756. c = 2.0 * s * (1.0 - l);
  4757. }
  4758. if (c < 1.0) {
  4759. f = (l - 0.5 * c) / (1.0 - c);
  4760. }
  4761. return [hsl[0], c * 100, f * 100];
  4762. };
  4763. convert.hsv.hcg = function (hsv) {
  4764. var s = hsv[1] / 100;
  4765. var v = hsv[2] / 100;
  4766. var c = s * v;
  4767. var f = 0;
  4768. if (c < 1.0) {
  4769. f = (v - c) / (1 - c);
  4770. }
  4771. return [hsv[0], c * 100, f * 100];
  4772. };
  4773. convert.hcg.rgb = function (hcg) {
  4774. var h = hcg[0] / 360;
  4775. var c = hcg[1] / 100;
  4776. var g = hcg[2] / 100;
  4777. if (c === 0.0) {
  4778. return [g * 255, g * 255, g * 255];
  4779. }
  4780. var pure = [0, 0, 0];
  4781. var hi = h % 1 * 6;
  4782. var v = hi % 1;
  4783. var w = 1 - v;
  4784. var mg = 0;
  4785. switch (Math.floor(hi)) {
  4786. case 0:
  4787. pure[0] = 1;
  4788. pure[1] = v;
  4789. pure[2] = 0;
  4790. break;
  4791. case 1:
  4792. pure[0] = w;
  4793. pure[1] = 1;
  4794. pure[2] = 0;
  4795. break;
  4796. case 2:
  4797. pure[0] = 0;
  4798. pure[1] = 1;
  4799. pure[2] = v;
  4800. break;
  4801. case 3:
  4802. pure[0] = 0;
  4803. pure[1] = w;
  4804. pure[2] = 1;
  4805. break;
  4806. case 4:
  4807. pure[0] = v;
  4808. pure[1] = 0;
  4809. pure[2] = 1;
  4810. break;
  4811. default:
  4812. pure[0] = 1;
  4813. pure[1] = 0;
  4814. pure[2] = w;
  4815. }
  4816. mg = (1.0 - c) * g;
  4817. return [(c * pure[0] + mg) * 255, (c * pure[1] + mg) * 255, (c * pure[2] + mg) * 255];
  4818. };
  4819. convert.hcg.hsv = function (hcg) {
  4820. var c = hcg[1] / 100;
  4821. var g = hcg[2] / 100;
  4822. var v = c + g * (1.0 - c);
  4823. var f = 0;
  4824. if (v > 0.0) {
  4825. f = c / v;
  4826. }
  4827. return [hcg[0], f * 100, v * 100];
  4828. };
  4829. convert.hcg.hsl = function (hcg) {
  4830. var c = hcg[1] / 100;
  4831. var g = hcg[2] / 100;
  4832. var l = g * (1.0 - c) + 0.5 * c;
  4833. var s = 0;
  4834. if (l > 0.0 && l < 0.5) {
  4835. s = c / (2 * l);
  4836. } else if (l >= 0.5 && l < 1.0) {
  4837. s = c / (2 * (1 - l));
  4838. }
  4839. return [hcg[0], s * 100, l * 100];
  4840. };
  4841. convert.hcg.hwb = function (hcg) {
  4842. var c = hcg[1] / 100;
  4843. var g = hcg[2] / 100;
  4844. var v = c + g * (1.0 - c);
  4845. return [hcg[0], (v - c) * 100, (1 - v) * 100];
  4846. };
  4847. convert.hwb.hcg = function (hwb) {
  4848. var w = hwb[1] / 100;
  4849. var b = hwb[2] / 100;
  4850. var v = 1 - b;
  4851. var c = v - w;
  4852. var g = 0;
  4853. if (c < 1) {
  4854. g = (v - c) / (1 - c);
  4855. }
  4856. return [hwb[0], c * 100, g * 100];
  4857. };
  4858. convert.apple.rgb = function (apple) {
  4859. return [apple[0] / 65535 * 255, apple[1] / 65535 * 255, apple[2] / 65535 * 255];
  4860. };
  4861. convert.rgb.apple = function (rgb) {
  4862. return [rgb[0] / 255 * 65535, rgb[1] / 255 * 65535, rgb[2] / 255 * 65535];
  4863. };
  4864. convert.gray.rgb = function (args) {
  4865. return [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255];
  4866. };
  4867. convert.gray.hsl = convert.gray.hsv = function (args) {
  4868. return [0, 0, args[0]];
  4869. };
  4870. convert.gray.hwb = function (gray) {
  4871. return [0, 100, gray[0]];
  4872. };
  4873. convert.gray.cmyk = function (gray) {
  4874. return [0, 0, 0, gray[0]];
  4875. };
  4876. convert.gray.lab = function (gray) {
  4877. return [gray[0], 0, 0];
  4878. };
  4879. convert.gray.hex = function (gray) {
  4880. var val = Math.round(gray[0] / 100 * 255) & 0xFF;
  4881. var integer = (val << 16) + (val << 8) + val;
  4882. var string = integer.toString(16).toUpperCase();
  4883. return '000000'.substring(string.length) + string;
  4884. };
  4885. convert.rgb.gray = function (rgb) {
  4886. var val = (rgb[0] + rgb[1] + rgb[2]) / 3;
  4887. return [val / 255 * 100];
  4888. };
  4889. });
  4890. /*
  4891. this function routes a model to all other models.
  4892. all functions that are routed have a property `.conversion` attached
  4893. to the returned synthetic function. This property is an array
  4894. of strings, each with the steps in between the 'from' and 'to'
  4895. color models (inclusive).
  4896. conversions that are not possible simply are not included.
  4897. */
  4898. // https://jsperf.com/object-keys-vs-for-in-with-closure/3
  4899. var models$1 = Object.keys(conversions);
  4900. function buildGraph() {
  4901. var graph = {};
  4902. for (var len = models$1.length, i = 0; i < len; i++) {
  4903. graph[models$1[i]] = {
  4904. // http://jsperf.com/1-vs-infinity
  4905. // micro-opt, but this is simple.
  4906. distance: -1,
  4907. parent: null
  4908. };
  4909. }
  4910. return graph;
  4911. } // https://en.wikipedia.org/wiki/Breadth-first_search
  4912. function deriveBFS(fromModel) {
  4913. var graph = buildGraph();
  4914. var queue = [fromModel]; // unshift -> queue -> pop
  4915. graph[fromModel].distance = 0;
  4916. while (queue.length) {
  4917. var current = queue.pop();
  4918. var adjacents = Object.keys(conversions[current]);
  4919. for (var len = adjacents.length, i = 0; i < len; i++) {
  4920. var adjacent = adjacents[i];
  4921. var node = graph[adjacent];
  4922. if (node.distance === -1) {
  4923. node.distance = graph[current].distance + 1;
  4924. node.parent = current;
  4925. queue.unshift(adjacent);
  4926. }
  4927. }
  4928. }
  4929. return graph;
  4930. }
  4931. function link(from, to) {
  4932. return function (args) {
  4933. return to(from(args));
  4934. };
  4935. }
  4936. function wrapConversion(toModel, graph) {
  4937. var path = [graph[toModel].parent, toModel];
  4938. var fn = conversions[graph[toModel].parent][toModel];
  4939. var cur = graph[toModel].parent;
  4940. while (graph[cur].parent) {
  4941. path.unshift(graph[cur].parent);
  4942. fn = link(conversions[graph[cur].parent][cur], fn);
  4943. cur = graph[cur].parent;
  4944. }
  4945. fn.conversion = path;
  4946. return fn;
  4947. }
  4948. var route = function route(fromModel) {
  4949. var graph = deriveBFS(fromModel);
  4950. var conversion = {};
  4951. var models = Object.keys(graph);
  4952. for (var len = models.length, i = 0; i < len; i++) {
  4953. var toModel = models[i];
  4954. var node = graph[toModel];
  4955. if (node.parent === null) {
  4956. // no possible conversion, or this node is the source model.
  4957. continue;
  4958. }
  4959. conversion[toModel] = wrapConversion(toModel, graph);
  4960. }
  4961. return conversion;
  4962. };
  4963. var convert = {};
  4964. var models = Object.keys(conversions);
  4965. function wrapRaw(fn) {
  4966. var wrappedFn = function wrappedFn(args) {
  4967. if (args === undefined || args === null) {
  4968. return args;
  4969. }
  4970. if (arguments.length > 1) {
  4971. args = Array.prototype.slice.call(arguments);
  4972. }
  4973. return fn(args);
  4974. }; // preserve .conversion property if there is one
  4975. if ('conversion' in fn) {
  4976. wrappedFn.conversion = fn.conversion;
  4977. }
  4978. return wrappedFn;
  4979. }
  4980. function wrapRounded(fn) {
  4981. var wrappedFn = function wrappedFn(args) {
  4982. if (args === undefined || args === null) {
  4983. return args;
  4984. }
  4985. if (arguments.length > 1) {
  4986. args = Array.prototype.slice.call(arguments);
  4987. }
  4988. var result = fn(args); // we're assuming the result is an array here.
  4989. // see notice in conversions.js; don't use box types
  4990. // in conversion functions.
  4991. if (_typeof(result) === 'object') {
  4992. for (var len = result.length, i = 0; i < len; i++) {
  4993. result[i] = Math.round(result[i]);
  4994. }
  4995. }
  4996. return result;
  4997. }; // preserve .conversion property if there is one
  4998. if ('conversion' in fn) {
  4999. wrappedFn.conversion = fn.conversion;
  5000. }
  5001. return wrappedFn;
  5002. }
  5003. models.forEach(function (fromModel) {
  5004. convert[fromModel] = {};
  5005. Object.defineProperty(convert[fromModel], 'channels', {
  5006. value: conversions[fromModel].channels
  5007. });
  5008. Object.defineProperty(convert[fromModel], 'labels', {
  5009. value: conversions[fromModel].labels
  5010. });
  5011. var routes = route(fromModel);
  5012. var routeModels = Object.keys(routes);
  5013. routeModels.forEach(function (toModel) {
  5014. var fn = routes[toModel];
  5015. convert[fromModel][toModel] = wrapRounded(fn);
  5016. convert[fromModel][toModel].raw = wrapRaw(fn);
  5017. });
  5018. });
  5019. var colorConvert = convert;
  5020. var ansiStyles = createCommonjsModule(function (module) {
  5021. 'use strict';
  5022. var wrapAnsi16 = function wrapAnsi16(fn, offset) {
  5023. return function () {
  5024. var code = fn.apply(colorConvert, arguments);
  5025. return "\x1B[".concat(code + offset, "m");
  5026. };
  5027. };
  5028. var wrapAnsi256 = function wrapAnsi256(fn, offset) {
  5029. return function () {
  5030. var code = fn.apply(colorConvert, arguments);
  5031. return "\x1B[".concat(38 + offset, ";5;").concat(code, "m");
  5032. };
  5033. };
  5034. var wrapAnsi16m = function wrapAnsi16m(fn, offset) {
  5035. return function () {
  5036. var rgb = fn.apply(colorConvert, arguments);
  5037. return "\x1B[".concat(38 + offset, ";2;").concat(rgb[0], ";").concat(rgb[1], ";").concat(rgb[2], "m");
  5038. };
  5039. };
  5040. function assembleStyles() {
  5041. var styles = {
  5042. modifier: {
  5043. reset: [0, 0],
  5044. // 21 isn't widely supported and 22 does the same thing
  5045. bold: [1, 22],
  5046. dim: [2, 22],
  5047. italic: [3, 23],
  5048. underline: [4, 24],
  5049. inverse: [7, 27],
  5050. hidden: [8, 28],
  5051. strikethrough: [9, 29]
  5052. },
  5053. color: {
  5054. black: [30, 39],
  5055. red: [31, 39],
  5056. green: [32, 39],
  5057. yellow: [33, 39],
  5058. blue: [34, 39],
  5059. magenta: [35, 39],
  5060. cyan: [36, 39],
  5061. white: [37, 39],
  5062. gray: [90, 39],
  5063. // Bright color
  5064. redBright: [91, 39],
  5065. greenBright: [92, 39],
  5066. yellowBright: [93, 39],
  5067. blueBright: [94, 39],
  5068. magentaBright: [95, 39],
  5069. cyanBright: [96, 39],
  5070. whiteBright: [97, 39]
  5071. },
  5072. bgColor: {
  5073. bgBlack: [40, 49],
  5074. bgRed: [41, 49],
  5075. bgGreen: [42, 49],
  5076. bgYellow: [43, 49],
  5077. bgBlue: [44, 49],
  5078. bgMagenta: [45, 49],
  5079. bgCyan: [46, 49],
  5080. bgWhite: [47, 49],
  5081. // Bright color
  5082. bgBlackBright: [100, 49],
  5083. bgRedBright: [101, 49],
  5084. bgGreenBright: [102, 49],
  5085. bgYellowBright: [103, 49],
  5086. bgBlueBright: [104, 49],
  5087. bgMagentaBright: [105, 49],
  5088. bgCyanBright: [106, 49],
  5089. bgWhiteBright: [107, 49]
  5090. }
  5091. }; // Fix humans
  5092. styles.color.grey = styles.color.gray;
  5093. Object.keys(styles).forEach(function (groupName) {
  5094. var group = styles[groupName];
  5095. Object.keys(group).forEach(function (styleName) {
  5096. var style = group[styleName];
  5097. styles[styleName] = {
  5098. open: "\x1B[".concat(style[0], "m"),
  5099. close: "\x1B[".concat(style[1], "m")
  5100. };
  5101. group[styleName] = styles[styleName];
  5102. });
  5103. Object.defineProperty(styles, groupName, {
  5104. value: group,
  5105. enumerable: false
  5106. });
  5107. });
  5108. var rgb2rgb = function rgb2rgb(r, g, b) {
  5109. return [r, g, b];
  5110. };
  5111. styles.color.close = "\x1B[39m";
  5112. styles.bgColor.close = "\x1B[49m";
  5113. styles.color.ansi = {};
  5114. styles.color.ansi256 = {};
  5115. styles.color.ansi16m = {
  5116. rgb: wrapAnsi16m(rgb2rgb, 0)
  5117. };
  5118. styles.bgColor.ansi = {};
  5119. styles.bgColor.ansi256 = {};
  5120. styles.bgColor.ansi16m = {
  5121. rgb: wrapAnsi16m(rgb2rgb, 10)
  5122. };
  5123. var _arr = Object.keys(colorConvert);
  5124. for (var _i = 0; _i < _arr.length; _i++) {
  5125. var key = _arr[_i];
  5126. if (_typeof(colorConvert[key]) !== 'object') {
  5127. continue;
  5128. }
  5129. var suite = colorConvert[key];
  5130. if ('ansi16' in suite) {
  5131. styles.color.ansi[key] = wrapAnsi16(suite.ansi16, 0);
  5132. styles.bgColor.ansi[key] = wrapAnsi16(suite.ansi16, 10);
  5133. }
  5134. if ('ansi256' in suite) {
  5135. styles.color.ansi256[key] = wrapAnsi256(suite.ansi256, 0);
  5136. styles.bgColor.ansi256[key] = wrapAnsi256(suite.ansi256, 10);
  5137. }
  5138. if ('rgb' in suite) {
  5139. styles.color.ansi16m[key] = wrapAnsi16m(suite.rgb, 0);
  5140. styles.bgColor.ansi16m[key] = wrapAnsi16m(suite.rgb, 10);
  5141. }
  5142. }
  5143. return styles;
  5144. }
  5145. Object.defineProperty(module, 'exports', {
  5146. enumerable: true,
  5147. get: assembleStyles
  5148. });
  5149. });
  5150. var hasFlag = function hasFlag(flag, argv$$1) {
  5151. argv$$1 = argv$$1 || process.argv;
  5152. var terminatorPos = argv$$1.indexOf('--');
  5153. var prefix = /^-{1,2}/.test(flag) ? '' : '--';
  5154. var pos = argv$$1.indexOf(prefix + flag);
  5155. return pos !== -1 && (terminatorPos === -1 ? true : pos < terminatorPos);
  5156. };
  5157. var os$3 = {};
  5158. var os$5 = Object.freeze({
  5159. default: os$3,
  5160. __moduleExports: os$3
  5161. });
  5162. var os$2 = ( os$5 && os$3 ) || os$5;
  5163. var supportsColor = createCommonjsModule(function (module) {
  5164. 'use strict';
  5165. var env$$1 = process.env;
  5166. var support = function support(level) {
  5167. if (level === 0) {
  5168. return false;
  5169. }
  5170. return {
  5171. level: level,
  5172. hasBasic: true,
  5173. has256: level >= 2,
  5174. has16m: level >= 3
  5175. };
  5176. };
  5177. var supportLevel = function () {
  5178. if (hasFlag('no-color') || hasFlag('no-colors') || hasFlag('color=false')) {
  5179. return 0;
  5180. }
  5181. if (hasFlag('color=16m') || hasFlag('color=full') || hasFlag('color=truecolor')) {
  5182. return 3;
  5183. }
  5184. if (hasFlag('color=256')) {
  5185. return 2;
  5186. }
  5187. if (hasFlag('color') || hasFlag('colors') || hasFlag('color=true') || hasFlag('color=always')) {
  5188. return 1;
  5189. }
  5190. if (process.stdout && !process.stdout.isTTY) {
  5191. return 0;
  5192. }
  5193. if (process.platform === 'win32') {
  5194. // Node.js 7.5.0 is the first version of Node.js to include a patch to
  5195. // libuv that enables 256 color output on Windows. Anything earlier and it
  5196. // won't work. However, here we target Node.js 8 at minimum as it is an LTS
  5197. // release, and Node.js 7 is not. Windows 10 build 10586 is the first Windows
  5198. // release that supports 256 colors.
  5199. var osRelease = os$2.release().split('.');
  5200. if (Number(process.version.split('.')[0]) >= 8 && Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
  5201. return 2;
  5202. }
  5203. return 1;
  5204. }
  5205. if ('CI' in env$$1) {
  5206. if ('TRAVIS' in env$$1 || env$$1.CI === 'Travis' || 'CIRCLECI' in env$$1) {
  5207. return 1;
  5208. }
  5209. return 0;
  5210. }
  5211. if ('TEAMCITY_VERSION' in env$$1) {
  5212. return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env$$1.TEAMCITY_VERSION) ? 1 : 0;
  5213. }
  5214. if ('TERM_PROGRAM' in env$$1) {
  5215. var version = parseInt((env$$1.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
  5216. switch (env$$1.TERM_PROGRAM) {
  5217. case 'iTerm.app':
  5218. return version >= 3 ? 3 : 2;
  5219. case 'Hyper':
  5220. return 3;
  5221. case 'Apple_Terminal':
  5222. return 2;
  5223. // No default
  5224. }
  5225. }
  5226. if (/^(screen|xterm)-256(?:color)?/.test(env$$1.TERM)) {
  5227. return 2;
  5228. }
  5229. if (/^screen|^xterm|^vt100|color|ansi|cygwin|linux/i.test(env$$1.TERM)) {
  5230. return 1;
  5231. }
  5232. if ('COLORTERM' in env$$1) {
  5233. return 1;
  5234. }
  5235. if (env$$1.TERM === 'dumb') {
  5236. return 0;
  5237. }
  5238. return 0;
  5239. }();
  5240. if ('FORCE_COLOR' in env$$1) {
  5241. supportLevel = parseInt(env$$1.FORCE_COLOR, 10) === 0 ? 0 : supportLevel || 1;
  5242. }
  5243. module.exports = process && support(supportLevel);
  5244. });
  5245. var templates = createCommonjsModule(function (module) {
  5246. 'use strict';
  5247. var TEMPLATE_REGEX = /(?:\\(u[a-f\d]{4}|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi;
  5248. var STYLE_REGEX = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g;
  5249. var STRING_REGEX = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/;
  5250. var ESCAPE_REGEX = /\\(u[a-f\d]{4}|x[a-f\d]{2}|.)|([^\\])/gi;
  5251. var ESCAPES = new Map([['n', '\n'], ['r', '\r'], ['t', '\t'], ['b', '\b'], ['f', '\f'], ['v', '\v'], ['0', '\0'], ['\\', '\\'], ['e', "\x1B"], ['a', "\x07"]]);
  5252. function unescape(c) {
  5253. if (c[0] === 'u' && c.length === 5 || c[0] === 'x' && c.length === 3) {
  5254. return String.fromCharCode(parseInt(c.slice(1), 16));
  5255. }
  5256. return ESCAPES.get(c) || c;
  5257. }
  5258. function parseArguments(name, args) {
  5259. var results = [];
  5260. var chunks = args.trim().split(/\s*,\s*/g);
  5261. var matches;
  5262. var _iteratorNormalCompletion = true;
  5263. var _didIteratorError = false;
  5264. var _iteratorError = undefined;
  5265. try {
  5266. for (var _iterator = chunks[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  5267. var chunk = _step.value;
  5268. if (!isNaN(chunk)) {
  5269. results.push(Number(chunk));
  5270. } else if (matches = chunk.match(STRING_REGEX)) {
  5271. results.push(matches[2].replace(ESCAPE_REGEX, function (m, escape, chr) {
  5272. return escape ? unescape(escape) : chr;
  5273. }));
  5274. } else {
  5275. throw new Error("Invalid Chalk template style argument: ".concat(chunk, " (in style '").concat(name, "')"));
  5276. }
  5277. }
  5278. } catch (err) {
  5279. _didIteratorError = true;
  5280. _iteratorError = err;
  5281. } finally {
  5282. try {
  5283. if (!_iteratorNormalCompletion && _iterator.return != null) {
  5284. _iterator.return();
  5285. }
  5286. } finally {
  5287. if (_didIteratorError) {
  5288. throw _iteratorError;
  5289. }
  5290. }
  5291. }
  5292. return results;
  5293. }
  5294. function parseStyle(style) {
  5295. STYLE_REGEX.lastIndex = 0;
  5296. var results = [];
  5297. var matches;
  5298. while ((matches = STYLE_REGEX.exec(style)) !== null) {
  5299. var name = matches[1];
  5300. if (matches[2]) {
  5301. var args = parseArguments(name, matches[2]);
  5302. results.push([name].concat(args));
  5303. } else {
  5304. results.push([name]);
  5305. }
  5306. }
  5307. return results;
  5308. }
  5309. function buildStyle(chalk, styles) {
  5310. var enabled = {};
  5311. var _iteratorNormalCompletion2 = true;
  5312. var _didIteratorError2 = false;
  5313. var _iteratorError2 = undefined;
  5314. try {
  5315. for (var _iterator2 = styles[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
  5316. var layer = _step2.value;
  5317. var _iteratorNormalCompletion3 = true;
  5318. var _didIteratorError3 = false;
  5319. var _iteratorError3 = undefined;
  5320. try {
  5321. for (var _iterator3 = layer.styles[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
  5322. var style = _step3.value;
  5323. enabled[style[0]] = layer.inverse ? null : style.slice(1);
  5324. }
  5325. } catch (err) {
  5326. _didIteratorError3 = true;
  5327. _iteratorError3 = err;
  5328. } finally {
  5329. try {
  5330. if (!_iteratorNormalCompletion3 && _iterator3.return != null) {
  5331. _iterator3.return();
  5332. }
  5333. } finally {
  5334. if (_didIteratorError3) {
  5335. throw _iteratorError3;
  5336. }
  5337. }
  5338. }
  5339. }
  5340. } catch (err) {
  5341. _didIteratorError2 = true;
  5342. _iteratorError2 = err;
  5343. } finally {
  5344. try {
  5345. if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
  5346. _iterator2.return();
  5347. }
  5348. } finally {
  5349. if (_didIteratorError2) {
  5350. throw _iteratorError2;
  5351. }
  5352. }
  5353. }
  5354. var current = chalk;
  5355. var _arr = Object.keys(enabled);
  5356. for (var _i = 0; _i < _arr.length; _i++) {
  5357. var styleName = _arr[_i];
  5358. if (Array.isArray(enabled[styleName])) {
  5359. if (!(styleName in current)) {
  5360. throw new Error("Unknown Chalk style: ".concat(styleName));
  5361. }
  5362. if (enabled[styleName].length > 0) {
  5363. current = current[styleName].apply(current, enabled[styleName]);
  5364. } else {
  5365. current = current[styleName];
  5366. }
  5367. }
  5368. }
  5369. return current;
  5370. }
  5371. module.exports = function (chalk, tmp) {
  5372. var styles = [];
  5373. var chunks = [];
  5374. var chunk = []; // eslint-disable-next-line max-params
  5375. tmp.replace(TEMPLATE_REGEX, function (m, escapeChar, inverse, style, close, chr) {
  5376. if (escapeChar) {
  5377. chunk.push(unescape(escapeChar));
  5378. } else if (style) {
  5379. var str = chunk.join('');
  5380. chunk = [];
  5381. chunks.push(styles.length === 0 ? str : buildStyle(chalk, styles)(str));
  5382. styles.push({
  5383. inverse: inverse,
  5384. styles: parseStyle(style)
  5385. });
  5386. } else if (close) {
  5387. if (styles.length === 0) {
  5388. throw new Error('Found extraneous } in Chalk template literal');
  5389. }
  5390. chunks.push(buildStyle(chalk, styles)(chunk.join('')));
  5391. chunk = [];
  5392. styles.pop();
  5393. } else {
  5394. chunk.push(chr);
  5395. }
  5396. });
  5397. chunks.push(chunk.join(''));
  5398. if (styles.length > 0) {
  5399. var errMsg = "Chalk template literal is missing ".concat(styles.length, " closing bracket").concat(styles.length === 1 ? '' : 's', " (`}`)");
  5400. throw new Error(errMsg);
  5401. }
  5402. return chunks.join('');
  5403. };
  5404. });
  5405. var chalk = createCommonjsModule(function (module) {
  5406. 'use strict';
  5407. var isSimpleWindowsTerm = process.platform === 'win32' && !(process.env.TERM || '').toLowerCase().startsWith('xterm'); // `supportsColor.level` → `ansiStyles.color[name]` mapping
  5408. var levelMapping = ['ansi', 'ansi', 'ansi256', 'ansi16m']; // `color-convert` models to exclude from the Chalk API due to conflicts and such
  5409. var skipModels = new Set(['gray']);
  5410. var styles = Object.create(null);
  5411. function applyOptions(obj, options) {
  5412. options = options || {}; // Detect level if not set manually
  5413. var scLevel = supportsColor ? supportsColor.level : 0;
  5414. obj.level = options.level === undefined ? scLevel : options.level;
  5415. obj.enabled = 'enabled' in options ? options.enabled : obj.level > 0;
  5416. }
  5417. function Chalk(options) {
  5418. // We check for this.template here since calling `chalk.constructor()`
  5419. // by itself will have a `this` of a previously constructed chalk object
  5420. if (!this || !(this instanceof Chalk) || this.template) {
  5421. var _chalk = {};
  5422. applyOptions(_chalk, options);
  5423. _chalk.template = function () {
  5424. var args = [].slice.call(arguments);
  5425. return chalkTag.apply(null, [_chalk.template].concat(args));
  5426. };
  5427. Object.setPrototypeOf(_chalk, Chalk.prototype);
  5428. Object.setPrototypeOf(_chalk.template, _chalk);
  5429. _chalk.template.constructor = Chalk;
  5430. return _chalk.template;
  5431. }
  5432. applyOptions(this, options);
  5433. } // Use bright blue on Windows as the normal blue color is illegible
  5434. if (isSimpleWindowsTerm) {
  5435. ansiStyles.blue.open = "\x1B[94m";
  5436. }
  5437. var _arr = Object.keys(ansiStyles);
  5438. var _loop = function _loop() {
  5439. var key = _arr[_i];
  5440. ansiStyles[key].closeRe = new RegExp(escapeStringRegexp(ansiStyles[key].close), 'g');
  5441. styles[key] = {
  5442. get: function get() {
  5443. var codes = ansiStyles[key];
  5444. return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, key);
  5445. }
  5446. };
  5447. };
  5448. for (var _i = 0; _i < _arr.length; _i++) {
  5449. _loop();
  5450. }
  5451. styles.visible = {
  5452. get: function get() {
  5453. return build.call(this, this._styles || [], true, 'visible');
  5454. }
  5455. };
  5456. ansiStyles.color.closeRe = new RegExp(escapeStringRegexp(ansiStyles.color.close), 'g');
  5457. var _arr2 = Object.keys(ansiStyles.color.ansi);
  5458. var _loop2 = function _loop2() {
  5459. var model = _arr2[_i2];
  5460. if (skipModels.has(model)) {
  5461. return "continue";
  5462. }
  5463. styles[model] = {
  5464. get: function get() {
  5465. var level = this.level;
  5466. return function () {
  5467. var open = ansiStyles.color[levelMapping[level]][model].apply(null, arguments);
  5468. var codes = {
  5469. open: open,
  5470. close: ansiStyles.color.close,
  5471. closeRe: ansiStyles.color.closeRe
  5472. };
  5473. return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, model);
  5474. };
  5475. }
  5476. };
  5477. };
  5478. for (var _i2 = 0; _i2 < _arr2.length; _i2++) {
  5479. var _ret = _loop2();
  5480. if (_ret === "continue") continue;
  5481. }
  5482. ansiStyles.bgColor.closeRe = new RegExp(escapeStringRegexp(ansiStyles.bgColor.close), 'g');
  5483. var _arr3 = Object.keys(ansiStyles.bgColor.ansi);
  5484. var _loop3 = function _loop3() {
  5485. var model = _arr3[_i3];
  5486. if (skipModels.has(model)) {
  5487. return "continue";
  5488. }
  5489. var bgModel = 'bg' + model[0].toUpperCase() + model.slice(1);
  5490. styles[bgModel] = {
  5491. get: function get() {
  5492. var level = this.level;
  5493. return function () {
  5494. var open = ansiStyles.bgColor[levelMapping[level]][model].apply(null, arguments);
  5495. var codes = {
  5496. open: open,
  5497. close: ansiStyles.bgColor.close,
  5498. closeRe: ansiStyles.bgColor.closeRe
  5499. };
  5500. return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, model);
  5501. };
  5502. }
  5503. };
  5504. };
  5505. for (var _i3 = 0; _i3 < _arr3.length; _i3++) {
  5506. var _ret2 = _loop3();
  5507. if (_ret2 === "continue") continue;
  5508. }
  5509. var proto = Object.defineProperties(function () {}, styles);
  5510. function build(_styles, _empty, key) {
  5511. var builder = function builder() {
  5512. return applyStyle.apply(builder, arguments);
  5513. };
  5514. builder._styles = _styles;
  5515. builder._empty = _empty;
  5516. var self = this;
  5517. Object.defineProperty(builder, 'level', {
  5518. enumerable: true,
  5519. get: function get() {
  5520. return self.level;
  5521. },
  5522. set: function set(level) {
  5523. self.level = level;
  5524. }
  5525. });
  5526. Object.defineProperty(builder, 'enabled', {
  5527. enumerable: true,
  5528. get: function get() {
  5529. return self.enabled;
  5530. },
  5531. set: function set(enabled) {
  5532. self.enabled = enabled;
  5533. }
  5534. }); // See below for fix regarding invisible grey/dim combination on Windows
  5535. builder.hasGrey = this.hasGrey || key === 'gray' || key === 'grey'; // `__proto__` is used because we must return a function, but there is
  5536. // no way to create a function with a different prototype
  5537. builder.__proto__ = proto; // eslint-disable-line no-proto
  5538. return builder;
  5539. }
  5540. function applyStyle() {
  5541. // Support varags, but simply cast to string in case there's only one arg
  5542. var args = arguments;
  5543. var argsLen = args.length;
  5544. var str = String(arguments[0]);
  5545. if (argsLen === 0) {
  5546. return '';
  5547. }
  5548. if (argsLen > 1) {
  5549. // Don't slice `arguments`, it prevents V8 optimizations
  5550. for (var a = 1; a < argsLen; a++) {
  5551. str += ' ' + args[a];
  5552. }
  5553. }
  5554. if (!this.enabled || this.level <= 0 || !str) {
  5555. return this._empty ? '' : str;
  5556. } // Turns out that on Windows dimmed gray text becomes invisible in cmd.exe,
  5557. // see https://github.com/chalk/chalk/issues/58
  5558. // If we're on Windows and we're dealing with a gray color, temporarily make 'dim' a noop.
  5559. var originalDim = ansiStyles.dim.open;
  5560. if (isSimpleWindowsTerm && this.hasGrey) {
  5561. ansiStyles.dim.open = '';
  5562. }
  5563. var _iteratorNormalCompletion = true;
  5564. var _didIteratorError = false;
  5565. var _iteratorError = undefined;
  5566. try {
  5567. for (var _iterator = this._styles.slice().reverse()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  5568. var code = _step.value;
  5569. // Replace any instances already present with a re-opening code
  5570. // otherwise only the part of the string until said closing code
  5571. // will be colored, and the rest will simply be 'plain'.
  5572. str = code.open + str.replace(code.closeRe, code.open) + code.close; // Close the styling before a linebreak and reopen
  5573. // after next line to fix a bleed issue on macOS
  5574. // https://github.com/chalk/chalk/pull/92
  5575. str = str.replace(/\r?\n/g, "".concat(code.close, "$&").concat(code.open));
  5576. } // Reset the original `dim` if we changed it to work around the Windows dimmed gray issue
  5577. } catch (err) {
  5578. _didIteratorError = true;
  5579. _iteratorError = err;
  5580. } finally {
  5581. try {
  5582. if (!_iteratorNormalCompletion && _iterator.return != null) {
  5583. _iterator.return();
  5584. }
  5585. } finally {
  5586. if (_didIteratorError) {
  5587. throw _iteratorError;
  5588. }
  5589. }
  5590. }
  5591. ansiStyles.dim.open = originalDim;
  5592. return str;
  5593. }
  5594. function chalkTag(chalk, strings) {
  5595. if (!Array.isArray(strings)) {
  5596. // If chalk() was called by itself or with a string,
  5597. // return the string itself as a string.
  5598. return [].slice.call(arguments, 1).join(' ');
  5599. }
  5600. var args = [].slice.call(arguments, 2);
  5601. var parts = [strings.raw[0]];
  5602. for (var i = 1; i < strings.length; i++) {
  5603. parts.push(String(args[i - 1]).replace(/[{}\\]/g, '\\$&'));
  5604. parts.push(String(strings.raw[i]));
  5605. }
  5606. return templates(chalk, parts.join(''));
  5607. }
  5608. Object.defineProperties(Chalk.prototype, styles);
  5609. module.exports = Chalk(); // eslint-disable-line new-cap
  5610. module.exports.supportsColor = supportsColor;
  5611. module.exports.default = module.exports; // For TypeScript
  5612. });
  5613. var lib$2 = createCommonjsModule(function (module, exports) {
  5614. "use strict";
  5615. Object.defineProperty(exports, "__esModule", {
  5616. value: true
  5617. });
  5618. exports.shouldHighlight = shouldHighlight;
  5619. exports.getChalk = getChalk;
  5620. exports.default = highlight;
  5621. function _jsTokens() {
  5622. var data = _interopRequireWildcard$$1(jsTokens);
  5623. _jsTokens = function _jsTokens() {
  5624. return data;
  5625. };
  5626. return data;
  5627. }
  5628. function _esutils() {
  5629. var data = _interopRequireDefault$$1(utils);
  5630. _esutils = function _esutils() {
  5631. return data;
  5632. };
  5633. return data;
  5634. }
  5635. function _chalk() {
  5636. var data = _interopRequireDefault$$1(chalk);
  5637. _chalk = function _chalk() {
  5638. return data;
  5639. };
  5640. return data;
  5641. }
  5642. function _interopRequireDefault$$1(obj) {
  5643. return obj && obj.__esModule ? obj : {
  5644. default: obj
  5645. };
  5646. }
  5647. function _interopRequireWildcard$$1(obj) {
  5648. if (obj && obj.__esModule) {
  5649. return obj;
  5650. } else {
  5651. var newObj = {};
  5652. if (obj != null) {
  5653. for (var key in obj) {
  5654. if (Object.prototype.hasOwnProperty.call(obj, key)) {
  5655. var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {};
  5656. if (desc.get || desc.set) {
  5657. Object.defineProperty(newObj, key, desc);
  5658. } else {
  5659. newObj[key] = obj[key];
  5660. }
  5661. }
  5662. }
  5663. }
  5664. newObj.default = obj;
  5665. return newObj;
  5666. }
  5667. }
  5668. function getDefs(chalk$$1) {
  5669. return {
  5670. keyword: chalk$$1.cyan,
  5671. capitalized: chalk$$1.yellow,
  5672. jsx_tag: chalk$$1.yellow,
  5673. punctuator: chalk$$1.yellow,
  5674. number: chalk$$1.magenta,
  5675. string: chalk$$1.green,
  5676. regex: chalk$$1.magenta,
  5677. comment: chalk$$1.grey,
  5678. invalid: chalk$$1.white.bgRed.bold
  5679. };
  5680. }
  5681. var NEWLINE = /\r\n|[\n\r\u2028\u2029]/;
  5682. var JSX_TAG = /^[a-z][\w-]*$/i;
  5683. var BRACKET = /^[()[\]{}]$/;
  5684. function getTokenType(match) {
  5685. var _match$slice = match.slice(-2),
  5686. _match$slice2 = _slicedToArray(_match$slice, 2),
  5687. offset = _match$slice2[0],
  5688. text = _match$slice2[1];
  5689. var token = (0, _jsTokens().matchToToken)(match);
  5690. if (token.type === "name") {
  5691. if (_esutils().default.keyword.isReservedWordES6(token.value)) {
  5692. return "keyword";
  5693. }
  5694. if (JSX_TAG.test(token.value) && (text[offset - 1] === "<" || text.substr(offset - 2, 2) == "</")) {
  5695. return "jsx_tag";
  5696. }
  5697. if (token.value[0] !== token.value[0].toLowerCase()) {
  5698. return "capitalized";
  5699. }
  5700. }
  5701. if (token.type === "punctuator" && BRACKET.test(token.value)) {
  5702. return "bracket";
  5703. }
  5704. if (token.type === "invalid" && (token.value === "@" || token.value === "#")) {
  5705. return "punctuator";
  5706. }
  5707. return token.type;
  5708. }
  5709. function highlightTokens(defs, text) {
  5710. return text.replace(_jsTokens().default, function () {
  5711. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  5712. args[_key] = arguments[_key];
  5713. }
  5714. var type = getTokenType(args);
  5715. var colorize = defs[type];
  5716. if (colorize) {
  5717. return args[0].split(NEWLINE).map(function (str) {
  5718. return colorize(str);
  5719. }).join("\n");
  5720. } else {
  5721. return args[0];
  5722. }
  5723. });
  5724. }
  5725. function shouldHighlight(options) {
  5726. return _chalk().default.supportsColor || options.forceColor;
  5727. }
  5728. function getChalk(options) {
  5729. var chalk$$1 = _chalk().default;
  5730. if (options.forceColor) {
  5731. chalk$$1 = new (_chalk().default.constructor)({
  5732. enabled: true,
  5733. level: 1
  5734. });
  5735. }
  5736. return chalk$$1;
  5737. }
  5738. function highlight(code) {
  5739. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  5740. if (shouldHighlight(options)) {
  5741. var chalk$$1 = getChalk(options);
  5742. var defs = getDefs(chalk$$1);
  5743. return highlightTokens(defs, code);
  5744. } else {
  5745. return code;
  5746. }
  5747. }
  5748. });
  5749. unwrapExports(lib$2);
  5750. var lib$1 = createCommonjsModule(function (module, exports) {
  5751. "use strict";
  5752. Object.defineProperty(exports, "__esModule", {
  5753. value: true
  5754. });
  5755. exports.codeFrameColumns = codeFrameColumns;
  5756. exports.default = _default;
  5757. function _highlight() {
  5758. var data = _interopRequireWildcard(lib$2);
  5759. _highlight = function _highlight() {
  5760. return data;
  5761. };
  5762. return data;
  5763. }
  5764. function _interopRequireWildcard(obj) {
  5765. if (obj && obj.__esModule) {
  5766. return obj;
  5767. } else {
  5768. var newObj = {};
  5769. if (obj != null) {
  5770. for (var key in obj) {
  5771. if (Object.prototype.hasOwnProperty.call(obj, key)) {
  5772. var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {};
  5773. if (desc.get || desc.set) {
  5774. Object.defineProperty(newObj, key, desc);
  5775. } else {
  5776. newObj[key] = obj[key];
  5777. }
  5778. }
  5779. }
  5780. }
  5781. newObj.default = obj;
  5782. return newObj;
  5783. }
  5784. }
  5785. var deprecationWarningShown = false;
  5786. function getDefs(chalk) {
  5787. return {
  5788. gutter: chalk.grey,
  5789. marker: chalk.red.bold,
  5790. message: chalk.red.bold
  5791. };
  5792. }
  5793. var NEWLINE = /\r\n|[\n\r\u2028\u2029]/;
  5794. function getMarkerLines(loc, source, opts) {
  5795. var startLoc = Object.assign({
  5796. column: 0,
  5797. line: -1
  5798. }, loc.start);
  5799. var endLoc = Object.assign({}, startLoc, loc.end);
  5800. var _ref = opts || {},
  5801. _ref$linesAbove = _ref.linesAbove,
  5802. linesAbove = _ref$linesAbove === void 0 ? 2 : _ref$linesAbove,
  5803. _ref$linesBelow = _ref.linesBelow,
  5804. linesBelow = _ref$linesBelow === void 0 ? 3 : _ref$linesBelow;
  5805. var startLine = startLoc.line;
  5806. var startColumn = startLoc.column;
  5807. var endLine = endLoc.line;
  5808. var endColumn = endLoc.column;
  5809. var start = Math.max(startLine - (linesAbove + 1), 0);
  5810. var end = Math.min(source.length, endLine + linesBelow);
  5811. if (startLine === -1) {
  5812. start = 0;
  5813. }
  5814. if (endLine === -1) {
  5815. end = source.length;
  5816. }
  5817. var lineDiff = endLine - startLine;
  5818. var markerLines = {};
  5819. if (lineDiff) {
  5820. for (var i = 0; i <= lineDiff; i++) {
  5821. var lineNumber = i + startLine;
  5822. if (!startColumn) {
  5823. markerLines[lineNumber] = true;
  5824. } else if (i === 0) {
  5825. var sourceLength = source[lineNumber - 1].length;
  5826. markerLines[lineNumber] = [startColumn, sourceLength - startColumn];
  5827. } else if (i === lineDiff) {
  5828. markerLines[lineNumber] = [0, endColumn];
  5829. } else {
  5830. var _sourceLength = source[lineNumber - i].length;
  5831. markerLines[lineNumber] = [0, _sourceLength];
  5832. }
  5833. }
  5834. } else {
  5835. if (startColumn === endColumn) {
  5836. if (startColumn) {
  5837. markerLines[startLine] = [startColumn, 0];
  5838. } else {
  5839. markerLines[startLine] = true;
  5840. }
  5841. } else {
  5842. markerLines[startLine] = [startColumn, endColumn - startColumn];
  5843. }
  5844. }
  5845. return {
  5846. start: start,
  5847. end: end,
  5848. markerLines: markerLines
  5849. };
  5850. }
  5851. function codeFrameColumns(rawLines, loc) {
  5852. var opts = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  5853. var highlighted = (opts.highlightCode || opts.forceColor) && (0, _highlight().shouldHighlight)(opts);
  5854. var chalk = (0, _highlight().getChalk)(opts);
  5855. var defs = getDefs(chalk);
  5856. var maybeHighlight = function maybeHighlight(chalkFn, string) {
  5857. return highlighted ? chalkFn(string) : string;
  5858. };
  5859. if (highlighted) rawLines = (0, _highlight().default)(rawLines, opts);
  5860. var lines = rawLines.split(NEWLINE);
  5861. var _getMarkerLines = getMarkerLines(loc, lines, opts),
  5862. start = _getMarkerLines.start,
  5863. end = _getMarkerLines.end,
  5864. markerLines = _getMarkerLines.markerLines;
  5865. var hasColumns = loc.start && typeof loc.start.column === "number";
  5866. var numberMaxWidth = String(end).length;
  5867. var frame = lines.slice(start, end).map(function (line, index) {
  5868. var number = start + 1 + index;
  5869. var paddedNumber = " ".concat(number).slice(-numberMaxWidth);
  5870. var gutter = " ".concat(paddedNumber, " | ");
  5871. var hasMarker = markerLines[number];
  5872. var lastMarkerLine = !markerLines[number + 1];
  5873. if (hasMarker) {
  5874. var markerLine = "";
  5875. if (Array.isArray(hasMarker)) {
  5876. var markerSpacing = line.slice(0, Math.max(hasMarker[0] - 1, 0)).replace(/[^\t]/g, " ");
  5877. var numberOfMarkers = hasMarker[1] || 1;
  5878. markerLine = ["\n ", maybeHighlight(defs.gutter, gutter.replace(/\d/g, " ")), markerSpacing, maybeHighlight(defs.marker, "^").repeat(numberOfMarkers)].join("");
  5879. if (lastMarkerLine && opts.message) {
  5880. markerLine += " " + maybeHighlight(defs.message, opts.message);
  5881. }
  5882. }
  5883. return [maybeHighlight(defs.marker, ">"), maybeHighlight(defs.gutter, gutter), line, markerLine].join("");
  5884. } else {
  5885. return " ".concat(maybeHighlight(defs.gutter, gutter)).concat(line);
  5886. }
  5887. }).join("\n");
  5888. if (opts.message && !hasColumns) {
  5889. frame = "".concat(" ".repeat(numberMaxWidth + 1)).concat(opts.message, "\n").concat(frame);
  5890. }
  5891. if (highlighted) {
  5892. return chalk.reset(frame);
  5893. } else {
  5894. return frame;
  5895. }
  5896. }
  5897. function _default(rawLines, lineNumber, colNumber) {
  5898. var opts = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
  5899. if (!deprecationWarningShown) {
  5900. deprecationWarningShown = true;
  5901. var message = "Passing lineNumber and colNumber is deprecated to @babel/code-frame. Please use `codeFrameColumns`.";
  5902. if (process.emitWarning) {
  5903. process.emitWarning(message, "DeprecationWarning");
  5904. } else {
  5905. var deprecationError = new Error(message);
  5906. deprecationError.name = "DeprecationWarning";
  5907. console.warn(new Error(message));
  5908. }
  5909. }
  5910. colNumber = Math.max(colNumber, 0);
  5911. var location = {
  5912. start: {
  5913. column: colNumber,
  5914. line: lineNumber
  5915. }
  5916. };
  5917. return codeFrameColumns(rawLines, location, opts);
  5918. }
  5919. });
  5920. unwrapExports(lib$1);
  5921. var path$5 = {};
  5922. var path$7 = Object.freeze({
  5923. default: path$5,
  5924. __moduleExports: path$5
  5925. });
  5926. var path$4 = ( path$7 && path$5 ) || path$7;
  5927. var ConfigError$1 = errors.ConfigError;
  5928. var locStart = loc.locStart;
  5929. var locEnd = loc.locEnd; // Use defineProperties()/getOwnPropertyDescriptor() to prevent
  5930. // triggering the parsers getters.
  5931. var ownNames = Object.getOwnPropertyNames;
  5932. var ownDescriptor = Object.getOwnPropertyDescriptor;
  5933. function getParsers(options) {
  5934. var parsers = {};
  5935. var _iteratorNormalCompletion = true;
  5936. var _didIteratorError = false;
  5937. var _iteratorError = undefined;
  5938. try {
  5939. for (var _iterator = options.plugins[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  5940. var plugin = _step.value;
  5941. if (!plugin.parsers) {
  5942. continue;
  5943. }
  5944. var _iteratorNormalCompletion2 = true;
  5945. var _didIteratorError2 = false;
  5946. var _iteratorError2 = undefined;
  5947. try {
  5948. for (var _iterator2 = ownNames(plugin.parsers)[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
  5949. var name = _step2.value;
  5950. Object.defineProperty(parsers, name, ownDescriptor(plugin.parsers, name));
  5951. }
  5952. } catch (err) {
  5953. _didIteratorError2 = true;
  5954. _iteratorError2 = err;
  5955. } finally {
  5956. try {
  5957. if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
  5958. _iterator2.return();
  5959. }
  5960. } finally {
  5961. if (_didIteratorError2) {
  5962. throw _iteratorError2;
  5963. }
  5964. }
  5965. }
  5966. }
  5967. } catch (err) {
  5968. _didIteratorError = true;
  5969. _iteratorError = err;
  5970. } finally {
  5971. try {
  5972. if (!_iteratorNormalCompletion && _iterator.return != null) {
  5973. _iterator.return();
  5974. }
  5975. } finally {
  5976. if (_didIteratorError) {
  5977. throw _iteratorError;
  5978. }
  5979. }
  5980. }
  5981. return parsers;
  5982. }
  5983. function resolveParser$1(opts, parsers) {
  5984. parsers = parsers || getParsers(opts);
  5985. if (typeof opts.parser === "function") {
  5986. // Custom parser API always works with JavaScript.
  5987. return {
  5988. parse: opts.parser,
  5989. astFormat: "estree",
  5990. locStart: locStart,
  5991. locEnd: locEnd
  5992. };
  5993. }
  5994. if (typeof opts.parser === "string") {
  5995. if (parsers.hasOwnProperty(opts.parser)) {
  5996. return parsers[opts.parser];
  5997. }
  5998. try {
  5999. return {
  6000. parse: require(path$4.resolve(process.cwd(), opts.parser)),
  6001. astFormat: "estree",
  6002. locStart: locStart,
  6003. locEnd: locEnd
  6004. };
  6005. } catch (err) {
  6006. /* istanbul ignore next */
  6007. throw new ConfigError$1("Couldn't resolve parser \"".concat(opts.parser, "\""));
  6008. }
  6009. }
  6010. }
  6011. function parse$2(text, opts) {
  6012. var parsers = getParsers(opts); // Create a new object {parserName: parseFn}. Uses defineProperty() to only call
  6013. // the parsers getters when actually calling the parser `parse` function.
  6014. var parsersForCustomParserApi = Object.keys(parsers).reduce(function (object, parserName) {
  6015. return Object.defineProperty(object, parserName, {
  6016. enumerable: true,
  6017. get: function get() {
  6018. return parsers[parserName].parse;
  6019. }
  6020. });
  6021. }, {});
  6022. var parser = resolveParser$1(opts, parsers);
  6023. try {
  6024. if (parser.preprocess) {
  6025. text = parser.preprocess(text, opts);
  6026. }
  6027. return {
  6028. text: text,
  6029. ast: parser.parse(text, parsersForCustomParserApi, opts)
  6030. };
  6031. } catch (error) {
  6032. var loc$$1 = error.loc;
  6033. if (loc$$1) {
  6034. var codeFrame = lib$1;
  6035. error.codeFrame = codeFrame.codeFrameColumns(text, loc$$1, {
  6036. highlightCode: true
  6037. });
  6038. error.message += "\n" + error.codeFrame;
  6039. throw error;
  6040. }
  6041. /* istanbul ignore next */
  6042. throw error.stack;
  6043. }
  6044. }
  6045. var parser = {
  6046. parse: parse$2,
  6047. resolveParser: resolveParser$1
  6048. };
  6049. var path$9 = {};
  6050. var path$11 = Object.freeze({
  6051. default: path$9,
  6052. __moduleExports: path$9
  6053. });
  6054. var path$8 = ( path$11 && path$9 ) || path$11;
  6055. var UndefinedParserError = errors.UndefinedParserError;
  6056. var getSupportInfo$1 = support.getSupportInfo;
  6057. var resolveParser = parser.resolveParser;
  6058. var hiddenDefaults = {
  6059. astFormat: "estree",
  6060. printer: {},
  6061. locStart: null,
  6062. locEnd: null
  6063. }; // Copy options and fill in default values.
  6064. function normalize(options, opts) {
  6065. opts = opts || {};
  6066. var rawOptions = Object.assign({}, options);
  6067. var supportOptions = getSupportInfo$1(null, {
  6068. plugins: options.plugins,
  6069. showUnreleased: true,
  6070. showDeprecated: true
  6071. }).options;
  6072. var defaults = supportOptions.reduce(function (reduced, optionInfo) {
  6073. return Object.assign(reduced, _defineProperty({}, optionInfo.name, optionInfo.default));
  6074. }, Object.assign({}, hiddenDefaults));
  6075. if (!rawOptions.parser) {
  6076. if (!rawOptions.filepath) {
  6077. var logger = opts.logger || console;
  6078. logger.warn("No parser and no filepath given, using 'babylon' the parser now " + "but this will throw an error in the future. " + "Please specify a parser or a filepath so one can be inferred.");
  6079. rawOptions.parser = "babylon";
  6080. } else {
  6081. rawOptions.parser = inferParser(rawOptions.filepath, rawOptions.plugins);
  6082. if (!rawOptions.parser) {
  6083. throw new UndefinedParserError("No parser could be inferred for file: ".concat(rawOptions.filepath));
  6084. }
  6085. }
  6086. }
  6087. var parser$$1 = resolveParser(optionsNormalizer.normalizeApiOptions(rawOptions, [supportOptions.find(function (x) {
  6088. return x.name === "parser";
  6089. })], {
  6090. passThrough: true,
  6091. logger: false
  6092. }));
  6093. rawOptions.astFormat = parser$$1.astFormat;
  6094. rawOptions.locEnd = parser$$1.locEnd;
  6095. rawOptions.locStart = parser$$1.locStart;
  6096. var plugin = getPlugin(rawOptions);
  6097. rawOptions.printer = plugin.printers[rawOptions.astFormat];
  6098. var pluginDefaults = supportOptions.filter(function (optionInfo) {
  6099. return optionInfo.pluginDefaults && optionInfo.pluginDefaults[plugin.name];
  6100. }).reduce(function (reduced, optionInfo) {
  6101. return Object.assign(reduced, _defineProperty({}, optionInfo.name, optionInfo.pluginDefaults[plugin.name]));
  6102. }, {});
  6103. var mixedDefaults = Object.assign({}, defaults, pluginDefaults);
  6104. Object.keys(mixedDefaults).forEach(function (k) {
  6105. if (rawOptions[k] == null) {
  6106. rawOptions[k] = mixedDefaults[k];
  6107. }
  6108. });
  6109. if (rawOptions.parser === "json") {
  6110. rawOptions.trailingComma = "none";
  6111. }
  6112. return optionsNormalizer.normalizeApiOptions(rawOptions, supportOptions, Object.assign({
  6113. passThrough: Object.keys(hiddenDefaults)
  6114. }, opts));
  6115. }
  6116. function getPlugin(options) {
  6117. var astFormat = options.astFormat;
  6118. if (!astFormat) {
  6119. throw new Error("getPlugin() requires astFormat to be set");
  6120. }
  6121. var printerPlugin = options.plugins.find(function (plugin) {
  6122. return plugin.printers && plugin.printers[astFormat];
  6123. });
  6124. if (!printerPlugin) {
  6125. throw new Error("Couldn't find plugin for AST format \"".concat(astFormat, "\""));
  6126. }
  6127. return printerPlugin;
  6128. }
  6129. function inferParser(filepath, plugins) {
  6130. var extension = path$8.extname(filepath);
  6131. var filename = path$8.basename(filepath).toLowerCase();
  6132. var language = getSupportInfo$1(null, {
  6133. plugins: plugins
  6134. }).languages.find(function (language) {
  6135. return language.since !== null && (language.extensions && language.extensions.indexOf(extension) > -1 || language.filenames && language.filenames.find(function (name) {
  6136. return name.toLowerCase() === filename;
  6137. }));
  6138. });
  6139. return language && language.parsers[0];
  6140. }
  6141. var options = {
  6142. normalize: normalize,
  6143. hiddenDefaults: hiddenDefaults,
  6144. inferParser: inferParser
  6145. };
  6146. function massageAST(ast, options, parent) {
  6147. if (Array.isArray(ast)) {
  6148. return ast.map(function (e) {
  6149. return massageAST(e, options, parent);
  6150. }).filter(function (e) {
  6151. return e;
  6152. });
  6153. }
  6154. if (!ast || _typeof(ast) !== "object") {
  6155. return ast;
  6156. }
  6157. var newObj = {};
  6158. var _arr = Object.keys(ast);
  6159. for (var _i = 0; _i < _arr.length; _i++) {
  6160. var key = _arr[_i];
  6161. if (typeof ast[key] !== "function") {
  6162. newObj[key] = massageAST(ast[key], options, ast);
  6163. }
  6164. }
  6165. if (options.printer.massageAstNode) {
  6166. var result = options.printer.massageAstNode(ast, newObj, parent);
  6167. if (result === null) {
  6168. return undefined;
  6169. }
  6170. if (result) {
  6171. return result;
  6172. }
  6173. }
  6174. return newObj;
  6175. }
  6176. var massageAst = massageAST;
  6177. var assert = {
  6178. ok: function ok() {},
  6179. strictEqual: function strictEqual() {}
  6180. };
  6181. function assertDoc(val) {
  6182. /* istanbul ignore if */
  6183. if (!(typeof val === "string" || val != null && typeof val.type === "string")) {
  6184. throw new Error("Value " + JSON.stringify(val) + " is not a valid document");
  6185. }
  6186. }
  6187. function concat$1(parts) {
  6188. if (process.env.NODE_ENV !== "production") {
  6189. parts.forEach(assertDoc);
  6190. } // We cannot do this until we change `printJSXElement` to not
  6191. // access the internals of a document directly.
  6192. // if(parts.length === 1) {
  6193. // // If it's a single document, no need to concat it.
  6194. // return parts[0];
  6195. // }
  6196. return {
  6197. type: "concat",
  6198. parts: parts
  6199. };
  6200. }
  6201. function indent$1(contents) {
  6202. if (process.env.NODE_ENV !== "production") {
  6203. assertDoc(contents);
  6204. }
  6205. return {
  6206. type: "indent",
  6207. contents: contents
  6208. };
  6209. }
  6210. function align(n, contents) {
  6211. if (process.env.NODE_ENV !== "production") {
  6212. assertDoc(contents);
  6213. }
  6214. return {
  6215. type: "align",
  6216. contents: contents,
  6217. n: n
  6218. };
  6219. }
  6220. function group(contents, opts) {
  6221. opts = opts || {};
  6222. if (process.env.NODE_ENV !== "production") {
  6223. assertDoc(contents);
  6224. }
  6225. return {
  6226. type: "group",
  6227. contents: contents,
  6228. break: !!opts.shouldBreak,
  6229. expandedStates: opts.expandedStates
  6230. };
  6231. }
  6232. function dedentToRoot(contents) {
  6233. return align(-Infinity, contents);
  6234. }
  6235. function markAsRoot(contents) {
  6236. return align({
  6237. type: "root"
  6238. }, contents);
  6239. }
  6240. function dedent$1(contents) {
  6241. return align(-1, contents);
  6242. }
  6243. function conditionalGroup(states, opts) {
  6244. return group(states[0], Object.assign(opts || {}, {
  6245. expandedStates: states
  6246. }));
  6247. }
  6248. function fill(parts) {
  6249. if (process.env.NODE_ENV !== "production") {
  6250. parts.forEach(assertDoc);
  6251. }
  6252. return {
  6253. type: "fill",
  6254. parts: parts
  6255. };
  6256. }
  6257. function ifBreak(breakContents, flatContents) {
  6258. if (process.env.NODE_ENV !== "production") {
  6259. if (breakContents) {
  6260. assertDoc(breakContents);
  6261. }
  6262. if (flatContents) {
  6263. assertDoc(flatContents);
  6264. }
  6265. }
  6266. return {
  6267. type: "if-break",
  6268. breakContents: breakContents,
  6269. flatContents: flatContents
  6270. };
  6271. }
  6272. function lineSuffix$1(contents) {
  6273. if (process.env.NODE_ENV !== "production") {
  6274. assertDoc(contents);
  6275. }
  6276. return {
  6277. type: "line-suffix",
  6278. contents: contents
  6279. };
  6280. }
  6281. var lineSuffixBoundary = {
  6282. type: "line-suffix-boundary"
  6283. };
  6284. var breakParent$1 = {
  6285. type: "break-parent"
  6286. };
  6287. var line$2 = {
  6288. type: "line"
  6289. };
  6290. var softline = {
  6291. type: "line",
  6292. soft: true
  6293. };
  6294. var hardline$1 = concat$1([{
  6295. type: "line",
  6296. hard: true
  6297. }, breakParent$1]);
  6298. var literalline = concat$1([{
  6299. type: "line",
  6300. hard: true,
  6301. literal: true
  6302. }, breakParent$1]);
  6303. var cursor$1 = {
  6304. type: "cursor",
  6305. placeholder: Symbol("cursor")
  6306. };
  6307. function join$1(sep, arr) {
  6308. var res = [];
  6309. for (var i = 0; i < arr.length; i++) {
  6310. if (i !== 0) {
  6311. res.push(sep);
  6312. }
  6313. res.push(arr[i]);
  6314. }
  6315. return concat$1(res);
  6316. }
  6317. function addAlignmentToDoc(doc, size, tabWidth) {
  6318. var aligned = doc;
  6319. if (size > 0) {
  6320. // Use indent to add tabs for all the levels of tabs we need
  6321. for (var i = 0; i < Math.floor(size / tabWidth); ++i) {
  6322. aligned = indent$1(aligned);
  6323. } // Use align for all the spaces that are needed
  6324. aligned = align(size % tabWidth, aligned); // size is absolute from 0 and not relative to the current
  6325. // indentation, so we use -Infinity to reset the indentation to 0
  6326. aligned = align(-Infinity, aligned);
  6327. }
  6328. return aligned;
  6329. }
  6330. var docBuilders = {
  6331. concat: concat$1,
  6332. join: join$1,
  6333. line: line$2,
  6334. softline: softline,
  6335. hardline: hardline$1,
  6336. literalline: literalline,
  6337. group: group,
  6338. conditionalGroup: conditionalGroup,
  6339. fill: fill,
  6340. lineSuffix: lineSuffix$1,
  6341. lineSuffixBoundary: lineSuffixBoundary,
  6342. cursor: cursor$1,
  6343. breakParent: breakParent$1,
  6344. ifBreak: ifBreak,
  6345. indent: indent$1,
  6346. align: align,
  6347. addAlignmentToDoc: addAlignmentToDoc,
  6348. markAsRoot: markAsRoot,
  6349. dedentToRoot: dedentToRoot,
  6350. dedent: dedent$1
  6351. };
  6352. var ansiRegex = createCommonjsModule(function (module) {
  6353. 'use strict';
  6354. module.exports = function () {
  6355. var pattern = ["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[a-zA-Z\\d]*)*)?\\u0007)", '(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PRZcf-ntqry=><~]))'].join('|');
  6356. return new RegExp(pattern, 'g');
  6357. };
  6358. });
  6359. var stripAnsi = function stripAnsi(input) {
  6360. return typeof input === 'string' ? input.replace(ansiRegex(), '') : input;
  6361. };
  6362. var isFullwidthCodePoint = createCommonjsModule(function (module) {
  6363. 'use strict';
  6364. /* eslint-disable yoda */
  6365. module.exports = function (x) {
  6366. if (Number.isNaN(x)) {
  6367. return false;
  6368. } // code points are derived from:
  6369. // http://www.unix.org/Public/UNIDATA/EastAsianWidth.txt
  6370. if (x >= 0x1100 && (x <= 0x115f || // Hangul Jamo
  6371. x === 0x2329 || // LEFT-POINTING ANGLE BRACKET
  6372. x === 0x232a || // RIGHT-POINTING ANGLE BRACKET
  6373. // CJK Radicals Supplement .. Enclosed CJK Letters and Months
  6374. 0x2e80 <= x && x <= 0x3247 && x !== 0x303f || // Enclosed CJK Letters and Months .. CJK Unified Ideographs Extension A
  6375. 0x3250 <= x && x <= 0x4dbf || // CJK Unified Ideographs .. Yi Radicals
  6376. 0x4e00 <= x && x <= 0xa4c6 || // Hangul Jamo Extended-A
  6377. 0xa960 <= x && x <= 0xa97c || // Hangul Syllables
  6378. 0xac00 <= x && x <= 0xd7a3 || // CJK Compatibility Ideographs
  6379. 0xf900 <= x && x <= 0xfaff || // Vertical Forms
  6380. 0xfe10 <= x && x <= 0xfe19 || // CJK Compatibility Forms .. Small Form Variants
  6381. 0xfe30 <= x && x <= 0xfe6b || // Halfwidth and Fullwidth Forms
  6382. 0xff01 <= x && x <= 0xff60 || 0xffe0 <= x && x <= 0xffe6 || // Kana Supplement
  6383. 0x1b000 <= x && x <= 0x1b001 || // Enclosed Ideographic Supplement
  6384. 0x1f200 <= x && x <= 0x1f251 || // CJK Unified Ideographs Extension B .. Tertiary Ideographic Plane
  6385. 0x20000 <= x && x <= 0x3fffd)) {
  6386. return true;
  6387. }
  6388. return false;
  6389. };
  6390. });
  6391. var stringWidth = createCommonjsModule(function (module) {
  6392. 'use strict';
  6393. module.exports = function (str) {
  6394. if (typeof str !== 'string' || str.length === 0) {
  6395. return 0;
  6396. }
  6397. str = stripAnsi(str);
  6398. var width = 0;
  6399. for (var i = 0; i < str.length; i++) {
  6400. var code = str.codePointAt(i); // Ignore control characters
  6401. if (code <= 0x1F || code >= 0x7F && code <= 0x9F) {
  6402. continue;
  6403. } // Ignore combining characters
  6404. if (code >= 0x300 && code <= 0x36F) {
  6405. continue;
  6406. } // Surrogates
  6407. if (code > 0xFFFF) {
  6408. i++;
  6409. }
  6410. width += isFullwidthCodePoint(code) ? 2 : 1;
  6411. }
  6412. return width;
  6413. };
  6414. });
  6415. var emojiRegex$1 = function emojiRegex() {
  6416. // https://mathiasbynens.be/notes/es-unicode-property-escapes#emoji
  6417. return /\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74)\uDB40\uDC7F|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC68(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|[\u2695\u2696\u2708]\uFE0F|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92])|(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2695\u2696\u2708]\uFE0F|(?:\uD83C[\uDFFB-\uDFFF])\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]))|\uD83D\uDC69\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92])|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83D\uDC69(?:\uD83C[\uDFFB-\uDFFF])\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\uDDD6-\uDDDD])(?:(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\u200D[\u2640\u2642])|\uD83D\uDC69\u200D[\u2695\u2696\u2708])\uFE0F|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D\uDC68(?:\u200D(?:(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D[\uDC66\uDC67])|\uD83C[\uDFFB-\uDFFF])|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83D\uDC69(?:\uD83C[\uDFFB-\uDFFF])\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92])|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83C\uDDF4\uD83C\uDDF2|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF6\uD83C\uDDE6|\uD83D\uDC69(?:\uD83C[\uDFFB-\uDFFF])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|[#\*0-9]\uFE0F\u20E3|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|(?:\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\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270A-\u270D]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC70\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDCAA\uDD74\uDD7A\uDD90\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD36\uDDD1-\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC69\uDC6E\uDC70-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD18-\uDD1C\uDD1E\uDD1F\uDD26\uDD30-\uDD39\uDD3D\uDD3E\uDDD1-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])?|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDEEB\uDEEC\uDEF4-\uDEF8]|\uD83E[\uDD10-\uDD3A\uDD3C-\uDD3E\uDD40-\uDD45\uDD47-\uDD4C\uDD50-\uDD6B\uDD80-\uDD97\uDDC0\uDDD0-\uDDE6])|(?:[#\*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\u2660\u2663\u2665\u2666\u2668\u267B\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEF8]|\uD83E[\uDD10-\uDD3A\uDD3C-\uDD3E\uDD40-\uDD45\uDD47-\uDD4C\uDD50-\uDD6B\uDD80-\uDD97\uDDC0\uDDD0-\uDDE6])\uFE0F/g;
  6418. };
  6419. var punctuation_ranges = [// http://www.unicode.org/charts/PDF/U3000.pdf CJK Symbols and Punctuation
  6420. [0x3000, 0x303f], // http://www.unicode.org/charts/PDF/UAC00.pdf Hangul Syllables
  6421. [0xac00, 0xd7af], // http://www.unicode.org/charts/PDF/UFE10.pdf Vertical Forms
  6422. [0xfe10, 0xfe1f], // http://www.unicode.org/charts/PDF/UFE30.pdf CJK Compatibility Forms
  6423. // http://www.unicode.org/charts/PDF/UFE50.pdf Small Form Variants
  6424. [0xfe30, 0xfe6f], // http://www.unicode.org/charts/PDF/UFF00.pdf Halfwidth and Fullwidth Forms
  6425. [0xff00, 0xff60], [0xffe0, 0xffef]];
  6426. var character_ranges = [// http://www.unicode.org/charts/PDF/U1100.pdf Hangul Jamo
  6427. [0x1100, 0x11ff], // http://www.unicode.org/charts/PDF/U2E80.pdf CJK Radicals Supplement
  6428. // http://www.unicode.org/charts/PDF/U2F00.pdf Kangxi Radicals
  6429. [0x2e80, 0x2fdf], // http://www.unicode.org/charts/PDF/U3040.pdf Hiragana
  6430. // http://www.unicode.org/charts/PDF/U30A0.pdf Katakana
  6431. // http://www.unicode.org/charts/PDF/U3100.pdf Bopomofo
  6432. // http://www.unicode.org/charts/PDF/U3130.pdf Hangul Compatibility Jamo
  6433. [0x3040, 0x318f], // http://www.unicode.org/charts/PDF/U3200.pdf Enclosed CJK Letters and Months
  6434. // http://www.unicode.org/charts/PDF/U3300.pdf CJK Compatibility
  6435. // http://www.unicode.org/charts/PDF/U3400.pdf CJK Unified Ideographs Extension A
  6436. [0x3200, 0x4dbf], // http://www.unicode.org/charts/PDF/U4E00.pdf CJK Unified Ideographs (Han)
  6437. [0x4e00, 0x9fff], // http://www.unicode.org/charts/PDF/UA960.pdf Hangul Jamo Extended-A
  6438. [0xa960, 0xa97f], // http://www.unicode.org/charts/PDF/UF900.pdf CJK Compatibility Ideographs
  6439. [0xf900, 0xfaff]];
  6440. function get_regex() {
  6441. return create_regex(character_ranges.concat(punctuation_ranges));
  6442. } // istanbul ignore next
  6443. // tslint:disable-next-line:no-namespace
  6444. (function (get_regex) {
  6445. function punctuations() {
  6446. return create_regex(punctuation_ranges);
  6447. }
  6448. get_regex.punctuations = punctuations;
  6449. function characters() {
  6450. return create_regex(character_ranges);
  6451. }
  6452. get_regex.characters = characters;
  6453. })(get_regex || (get_regex = {}));
  6454. function create_regex(ranges) {
  6455. return new RegExp("[" + ranges.map(get_bracket_content).reduce(function (a, b) {
  6456. return a + b;
  6457. }) + "]", 'g');
  6458. }
  6459. function get_bracket_content(range) {
  6460. return get_escaped_unicode(range[0]) + "-" + get_escaped_unicode(range[1]);
  6461. }
  6462. function get_escaped_unicode(num) {
  6463. return "\\u" + num.toString(16);
  6464. }
  6465. var lib$3 = get_regex;
  6466. var data_generated = createCommonjsModule(function (module, exports) {
  6467. "use strict";
  6468. exports.__esModule = true;
  6469. exports.get_data = function () {
  6470. return {
  6471. "Pc": [[95, 95], [8255, 8256], [8276, 8276], [65075, 65076], [65101, 65103], [65343, 65343]],
  6472. "Pe": [[41, 41], [93, 93], [125, 125], [3899, 3899], [3901, 3901], [5788, 5788], [8262, 8262], [8318, 8318], [8334, 8334], [8969, 8969], [8971, 8971], [9002, 9002], [10089, 10089], [10091, 10091], [10093, 10093], [10095, 10095], [10097, 10097], [10099, 10099], [10101, 10101], [10182, 10182], [10215, 10215], [10217, 10217], [10219, 10219], [10221, 10221], [10223, 10223], [10628, 10628], [10630, 10630], [10632, 10632], [10634, 10634], [10636, 10636], [10638, 10638], [10640, 10640], [10642, 10642], [10644, 10644], [10646, 10646], [10648, 10648], [10713, 10713], [10715, 10715], [10749, 10749], [11811, 11811], [11813, 11813], [11815, 11815], [11817, 11817], [12297, 12297], [12299, 12299], [12301, 12301], [12303, 12303], [12305, 12305], [12309, 12309], [12311, 12311], [12313, 12313], [12315, 12315], [12318, 12319], [64830, 64830], [65048, 65048], [65078, 65078], [65080, 65080], [65082, 65082], [65084, 65084], [65086, 65086], [65088, 65088], [65090, 65090], [65092, 65092], [65096, 65096], [65114, 65114], [65116, 65116], [65118, 65118], [65289, 65289], [65341, 65341], [65373, 65373], [65376, 65376], [65379, 65379]],
  6473. "Ps": [[40, 40], [91, 91], [123, 123], [3898, 3898], [3900, 3900], [5787, 5787], [8218, 8218], [8222, 8222], [8261, 8261], [8317, 8317], [8333, 8333], [8968, 8968], [8970, 8970], [9001, 9001], [10088, 10088], [10090, 10090], [10092, 10092], [10094, 10094], [10096, 10096], [10098, 10098], [10100, 10100], [10181, 10181], [10214, 10214], [10216, 10216], [10218, 10218], [10220, 10220], [10222, 10222], [10627, 10627], [10629, 10629], [10631, 10631], [10633, 10633], [10635, 10635], [10637, 10637], [10639, 10639], [10641, 10641], [10643, 10643], [10645, 10645], [10647, 10647], [10712, 10712], [10714, 10714], [10748, 10748], [11810, 11810], [11812, 11812], [11814, 11814], [11816, 11816], [11842, 11842], [12296, 12296], [12298, 12298], [12300, 12300], [12302, 12302], [12304, 12304], [12308, 12308], [12310, 12310], [12312, 12312], [12314, 12314], [12317, 12317], [64831, 64831], [65047, 65047], [65077, 65077], [65079, 65079], [65081, 65081], [65083, 65083], [65085, 65085], [65087, 65087], [65089, 65089], [65091, 65091], [65095, 65095], [65113, 65113], [65115, 65115], [65117, 65117], [65288, 65288], [65339, 65339], [65371, 65371], [65375, 65375], [65378, 65378]],
  6474. "Lm": [[688, 705], [710, 721], [736, 740], [748, 748], [750, 750], [884, 884], [890, 890], [1369, 1369], [1600, 1600], [1765, 1766], [2036, 2037], [2042, 2042], [2074, 2074], [2084, 2084], [2088, 2088], [2417, 2417], [3654, 3654], [3782, 3782], [4348, 4348], [6103, 6103], [6211, 6211], [6823, 6823], [7288, 7293], [7468, 7530], [7544, 7544], [7579, 7615], [8305, 8305], [8319, 8319], [8336, 8348], [11388, 11389], [11631, 11631], [11823, 11823], [12293, 12293], [12337, 12341], [12347, 12347], [12445, 12446], [12540, 12542], [40981, 40981], [42232, 42237], [42508, 42508], [42623, 42623], [42652, 42653], [42775, 42783], [42864, 42864], [42888, 42888], [43000, 43001], [43471, 43471], [43494, 43494], [43632, 43632], [43741, 43741], [43763, 43764], [43868, 43871], [65392, 65392], [65438, 65439]],
  6475. "Mc": [[2307, 2307], [2363, 2363], [2366, 2368], [2377, 2380], [2382, 2383], [2434, 2435], [2494, 2496], [2503, 2504], [2507, 2508], [2519, 2519], [2563, 2563], [2622, 2624], [2691, 2691], [2750, 2752], [2761, 2761], [2763, 2764], [2818, 2819], [2878, 2878], [2880, 2880], [2887, 2888], [2891, 2892], [2903, 2903], [3006, 3007], [3009, 3010], [3014, 3016], [3018, 3020], [3031, 3031], [3073, 3075], [3137, 3140], [3202, 3203], [3262, 3262], [3264, 3268], [3271, 3272], [3274, 3275], [3285, 3286], [3330, 3331], [3390, 3392], [3398, 3400], [3402, 3404], [3415, 3415], [3458, 3459], [3535, 3537], [3544, 3551], [3570, 3571], [3902, 3903], [3967, 3967], [4139, 4140], [4145, 4145], [4152, 4152], [4155, 4156], [4182, 4183], [4194, 4196], [4199, 4205], [4227, 4228], [4231, 4236], [4239, 4239], [4250, 4252], [6070, 6070], [6078, 6085], [6087, 6088], [6435, 6438], [6441, 6443], [6448, 6449], [6451, 6456], [6681, 6682], [6741, 6741], [6743, 6743], [6753, 6753], [6755, 6756], [6765, 6770], [6916, 6916], [6965, 6965], [6971, 6971], [6973, 6977], [6979, 6980], [7042, 7042], [7073, 7073], [7078, 7079], [7082, 7082], [7143, 7143], [7146, 7148], [7150, 7150], [7154, 7155], [7204, 7211], [7220, 7221], [7393, 7393], [7410, 7411], [7415, 7415], [12334, 12335], [43043, 43044], [43047, 43047], [43136, 43137], [43188, 43203], [43346, 43347], [43395, 43395], [43444, 43445], [43450, 43451], [43453, 43456], [43567, 43568], [43571, 43572], [43597, 43597], [43643, 43643], [43645, 43645], [43755, 43755], [43758, 43759], [43765, 43765], [44003, 44004], [44006, 44007], [44009, 44010], [44012, 44012]],
  6476. "Zp": [[8233, 8233]],
  6477. "Sc": [[36, 36], [162, 165], [1423, 1423], [1547, 1547], [2546, 2547], [2555, 2555], [2801, 2801], [3065, 3065], [3647, 3647], [6107, 6107], [8352, 8383], [43064, 43064], [65020, 65020], [65129, 65129], [65284, 65284], [65504, 65505], [65509, 65510]],
  6478. "Me": [[1160, 1161], [6846, 6846], [8413, 8416], [8418, 8420], [42608, 42610]],
  6479. "Sk": [[94, 94], [96, 96], [168, 168], [175, 175], [180, 180], [184, 184], [706, 709], [722, 735], [741, 747], [749, 749], [751, 767], [885, 885], [900, 901], [8125, 8125], [8127, 8129], [8141, 8143], [8157, 8159], [8173, 8175], [8189, 8190], [12443, 12444], [42752, 42774], [42784, 42785], [42889, 42890], [43867, 43867], [64434, 64449], [65342, 65342], [65344, 65344], [65507, 65507]],
  6480. "Cs": [[55296, 55296], [56191, 56192], [56319, 56320], [57343, 57343]],
  6481. "Nl": [[5870, 5872], [8544, 8578], [8581, 8584], [12295, 12295], [12321, 12329], [12344, 12346], [42726, 42735]],
  6482. "So": [[166, 166], [169, 169], [174, 174], [176, 176], [1154, 1154], [1421, 1422], [1550, 1551], [1758, 1758], [1769, 1769], [1789, 1790], [2038, 2038], [2554, 2554], [2928, 2928], [3059, 3064], [3066, 3066], [3199, 3199], [3407, 3407], [3449, 3449], [3841, 3843], [3859, 3859], [3861, 3863], [3866, 3871], [3892, 3892], [3894, 3894], [3896, 3896], [4030, 4037], [4039, 4044], [4046, 4047], [4053, 4056], [4254, 4255], [5008, 5017], [6464, 6464], [6622, 6655], [7009, 7018], [7028, 7036], [8448, 8449], [8451, 8454], [8456, 8457], [8468, 8468], [8470, 8471], [8478, 8483], [8485, 8485], [8487, 8487], [8489, 8489], [8494, 8494], [8506, 8507], [8522, 8522], [8524, 8525], [8527, 8527], [8586, 8587], [8597, 8601], [8604, 8607], [8609, 8610], [8612, 8613], [8615, 8621], [8623, 8653], [8656, 8657], [8659, 8659], [8661, 8691], [8960, 8967], [8972, 8991], [8994, 9000], [9003, 9083], [9085, 9114], [9140, 9179], [9186, 9254], [9280, 9290], [9372, 9449], [9472, 9654], [9656, 9664], [9666, 9719], [9728, 9838], [9840, 10087], [10132, 10175], [10240, 10495], [11008, 11055], [11077, 11078], [11085, 11123], [11126, 11157], [11160, 11193], [11197, 11208], [11210, 11218], [11244, 11247], [11493, 11498], [11904, 11929], [11931, 12019], [12032, 12245], [12272, 12283], [12292, 12292], [12306, 12307], [12320, 12320], [12342, 12343], [12350, 12351], [12688, 12689], [12694, 12703], [12736, 12771], [12800, 12830], [12842, 12871], [12880, 12880], [12896, 12927], [12938, 12976], [12992, 13054], [13056, 13311], [19904, 19967], [42128, 42182], [43048, 43051], [43062, 43063], [43065, 43065], [43639, 43641], [65021, 65021], [65508, 65508], [65512, 65512], [65517, 65518], [65532, 65533]],
  6483. "Lt": [[453, 453], [456, 456], [459, 459], [498, 498], [8072, 8079], [8088, 8095], [8104, 8111], [8124, 8124], [8140, 8140], [8188, 8188]],
  6484. "Zl": [[8232, 8232]],
  6485. "Lo": [[170, 170], [186, 186], [443, 443], [448, 451], [660, 660], [1488, 1514], [1520, 1522], [1568, 1599], [1601, 1610], [1646, 1647], [1649, 1747], [1749, 1749], [1774, 1775], [1786, 1788], [1791, 1791], [1808, 1808], [1810, 1839], [1869, 1957], [1969, 1969], [1994, 2026], [2048, 2069], [2112, 2136], [2144, 2154], [2208, 2228], [2230, 2237], [2308, 2361], [2365, 2365], [2384, 2384], [2392, 2401], [2418, 2432], [2437, 2444], [2447, 2448], [2451, 2472], [2474, 2480], [2482, 2482], [2486, 2489], [2493, 2493], [2510, 2510], [2524, 2525], [2527, 2529], [2544, 2545], [2556, 2556], [2565, 2570], [2575, 2576], [2579, 2600], [2602, 2608], [2610, 2611], [2613, 2614], [2616, 2617], [2649, 2652], [2654, 2654], [2674, 2676], [2693, 2701], [2703, 2705], [2707, 2728], [2730, 2736], [2738, 2739], [2741, 2745], [2749, 2749], [2768, 2768], [2784, 2785], [2809, 2809], [2821, 2828], [2831, 2832], [2835, 2856], [2858, 2864], [2866, 2867], [2869, 2873], [2877, 2877], [2908, 2909], [2911, 2913], [2929, 2929], [2947, 2947], [2949, 2954], [2958, 2960], [2962, 2965], [2969, 2970], [2972, 2972], [2974, 2975], [2979, 2980], [2984, 2986], [2990, 3001], [3024, 3024], [3077, 3084], [3086, 3088], [3090, 3112], [3114, 3129], [3133, 3133], [3160, 3162], [3168, 3169], [3200, 3200], [3205, 3212], [3214, 3216], [3218, 3240], [3242, 3251], [3253, 3257], [3261, 3261], [3294, 3294], [3296, 3297], [3313, 3314], [3333, 3340], [3342, 3344], [3346, 3386], [3389, 3389], [3406, 3406], [3412, 3414], [3423, 3425], [3450, 3455], [3461, 3478], [3482, 3505], [3507, 3515], [3517, 3517], [3520, 3526], [3585, 3632], [3634, 3635], [3648, 3653], [3713, 3714], [3716, 3716], [3719, 3720], [3722, 3722], [3725, 3725], [3732, 3735], [3737, 3743], [3745, 3747], [3749, 3749], [3751, 3751], [3754, 3755], [3757, 3760], [3762, 3763], [3773, 3773], [3776, 3780], [3804, 3807], [3840, 3840], [3904, 3911], [3913, 3948], [3976, 3980], [4096, 4138], [4159, 4159], [4176, 4181], [4186, 4189], [4193, 4193], [4197, 4198], [4206, 4208], [4213, 4225], [4238, 4238], [4304, 4346], [4349, 4680], [4682, 4685], [4688, 4694], [4696, 4696], [4698, 4701], [4704, 4744], [4746, 4749], [4752, 4784], [4786, 4789], [4792, 4798], [4800, 4800], [4802, 4805], [4808, 4822], [4824, 4880], [4882, 4885], [4888, 4954], [4992, 5007], [5121, 5740], [5743, 5759], [5761, 5786], [5792, 5866], [5873, 5880], [5888, 5900], [5902, 5905], [5920, 5937], [5952, 5969], [5984, 5996], [5998, 6000], [6016, 6067], [6108, 6108], [6176, 6210], [6212, 6263], [6272, 6276], [6279, 6312], [6314, 6314], [6320, 6389], [6400, 6430], [6480, 6509], [6512, 6516], [6528, 6571], [6576, 6601], [6656, 6678], [6688, 6740], [6917, 6963], [6981, 6987], [7043, 7072], [7086, 7087], [7098, 7141], [7168, 7203], [7245, 7247], [7258, 7287], [7401, 7404], [7406, 7409], [7413, 7414], [8501, 8504], [11568, 11623], [11648, 11670], [11680, 11686], [11688, 11694], [11696, 11702], [11704, 11710], [11712, 11718], [11720, 11726], [11728, 11734], [11736, 11742], [12294, 12294], [12348, 12348], [12353, 12438], [12447, 12447], [12449, 12538], [12543, 12543], [12549, 12590], [12593, 12686], [12704, 12730], [12784, 12799], [13312, 13312], [19893, 19893], [19968, 19968], [40938, 40938], [40960, 40980], [40982, 42124], [42192, 42231], [42240, 42507], [42512, 42527], [42538, 42539], [42606, 42606], [42656, 42725], [42895, 42895], [42999, 42999], [43003, 43009], [43011, 43013], [43015, 43018], [43020, 43042], [43072, 43123], [43138, 43187], [43250, 43255], [43259, 43259], [43261, 43261], [43274, 43301], [43312, 43334], [43360, 43388], [43396, 43442], [43488, 43492], [43495, 43503], [43514, 43518], [43520, 43560], [43584, 43586], [43588, 43595], [43616, 43631], [43633, 43638], [43642, 43642], [43646, 43695], [43697, 43697], [43701, 43702], [43705, 43709], [43712, 43712], [43714, 43714], [43739, 43740], [43744, 43754], [43762, 43762], [43777, 43782], [43785, 43790], [43793, 43798], [43808, 43814], [43816, 43822], [43968, 44002], [44032, 44032], [55203, 55203], [55216, 55238], [55243, 55291], [63744, 64109], [64112, 64217], [64285, 64285], [64287, 64296], [64298, 64310], [64312, 64316], [64318, 64318], [64320, 64321], [64323, 64324], [64326, 64433], [64467, 64829], [64848, 64911], [64914, 64967], [65008, 65019], [65136, 65140], [65142, 65276], [65382, 65391], [65393, 65437], [65440, 65470], [65474, 65479], [65482, 65487], [65490, 65495], [65498, 65500]],
  6486. "Mn": [[768, 879], [1155, 1159], [1425, 1469], [1471, 1471], [1473, 1474], [1476, 1477], [1479, 1479], [1552, 1562], [1611, 1631], [1648, 1648], [1750, 1756], [1759, 1764], [1767, 1768], [1770, 1773], [1809, 1809], [1840, 1866], [1958, 1968], [2027, 2035], [2070, 2073], [2075, 2083], [2085, 2087], [2089, 2093], [2137, 2139], [2260, 2273], [2275, 2306], [2362, 2362], [2364, 2364], [2369, 2376], [2381, 2381], [2385, 2391], [2402, 2403], [2433, 2433], [2492, 2492], [2497, 2500], [2509, 2509], [2530, 2531], [2561, 2562], [2620, 2620], [2625, 2626], [2631, 2632], [2635, 2637], [2641, 2641], [2672, 2673], [2677, 2677], [2689, 2690], [2748, 2748], [2753, 2757], [2759, 2760], [2765, 2765], [2786, 2787], [2810, 2815], [2817, 2817], [2876, 2876], [2879, 2879], [2881, 2884], [2893, 2893], [2902, 2902], [2914, 2915], [2946, 2946], [3008, 3008], [3021, 3021], [3072, 3072], [3134, 3136], [3142, 3144], [3146, 3149], [3157, 3158], [3170, 3171], [3201, 3201], [3260, 3260], [3263, 3263], [3270, 3270], [3276, 3277], [3298, 3299], [3328, 3329], [3387, 3388], [3393, 3396], [3405, 3405], [3426, 3427], [3530, 3530], [3538, 3540], [3542, 3542], [3633, 3633], [3636, 3642], [3655, 3662], [3761, 3761], [3764, 3769], [3771, 3772], [3784, 3789], [3864, 3865], [3893, 3893], [3895, 3895], [3897, 3897], [3953, 3966], [3968, 3972], [3974, 3975], [3981, 3991], [3993, 4028], [4038, 4038], [4141, 4144], [4146, 4151], [4153, 4154], [4157, 4158], [4184, 4185], [4190, 4192], [4209, 4212], [4226, 4226], [4229, 4230], [4237, 4237], [4253, 4253], [4957, 4959], [5906, 5908], [5938, 5940], [5970, 5971], [6002, 6003], [6068, 6069], [6071, 6077], [6086, 6086], [6089, 6099], [6109, 6109], [6155, 6157], [6277, 6278], [6313, 6313], [6432, 6434], [6439, 6440], [6450, 6450], [6457, 6459], [6679, 6680], [6683, 6683], [6742, 6742], [6744, 6750], [6752, 6752], [6754, 6754], [6757, 6764], [6771, 6780], [6783, 6783], [6832, 6845], [6912, 6915], [6964, 6964], [6966, 6970], [6972, 6972], [6978, 6978], [7019, 7027], [7040, 7041], [7074, 7077], [7080, 7081], [7083, 7085], [7142, 7142], [7144, 7145], [7149, 7149], [7151, 7153], [7212, 7219], [7222, 7223], [7376, 7378], [7380, 7392], [7394, 7400], [7405, 7405], [7412, 7412], [7416, 7417], [7616, 7673], [7675, 7679], [8400, 8412], [8417, 8417], [8421, 8432], [11503, 11505], [11647, 11647], [11744, 11775], [12330, 12333], [12441, 12442], [42607, 42607], [42612, 42621], [42654, 42655], [42736, 42737], [43010, 43010], [43014, 43014], [43019, 43019], [43045, 43046], [43204, 43205], [43232, 43249], [43302, 43309], [43335, 43345], [43392, 43394], [43443, 43443], [43446, 43449], [43452, 43452], [43493, 43493], [43561, 43566], [43569, 43570], [43573, 43574], [43587, 43587], [43596, 43596], [43644, 43644], [43696, 43696], [43698, 43700], [43703, 43704], [43710, 43711], [43713, 43713], [43756, 43757], [43766, 43766], [44005, 44005], [44008, 44008], [44013, 44013], [64286, 64286], [65024, 65039], [65056, 65071]],
  6487. "Po": [[33, 35], [37, 39], [42, 42], [44, 44], [46, 47], [58, 59], [63, 64], [92, 92], [161, 161], [167, 167], [182, 183], [191, 191], [894, 894], [903, 903], [1370, 1375], [1417, 1417], [1472, 1472], [1475, 1475], [1478, 1478], [1523, 1524], [1545, 1546], [1548, 1549], [1563, 1563], [1566, 1567], [1642, 1645], [1748, 1748], [1792, 1805], [2039, 2041], [2096, 2110], [2142, 2142], [2404, 2405], [2416, 2416], [2557, 2557], [2800, 2800], [3572, 3572], [3663, 3663], [3674, 3675], [3844, 3858], [3860, 3860], [3973, 3973], [4048, 4052], [4057, 4058], [4170, 4175], [4347, 4347], [4960, 4968], [5741, 5742], [5867, 5869], [5941, 5942], [6100, 6102], [6104, 6106], [6144, 6149], [6151, 6154], [6468, 6469], [6686, 6687], [6816, 6822], [6824, 6829], [7002, 7008], [7164, 7167], [7227, 7231], [7294, 7295], [7360, 7367], [7379, 7379], [8214, 8215], [8224, 8231], [8240, 8248], [8251, 8254], [8257, 8259], [8263, 8273], [8275, 8275], [8277, 8286], [11513, 11516], [11518, 11519], [11632, 11632], [11776, 11777], [11782, 11784], [11787, 11787], [11790, 11798], [11800, 11801], [11803, 11803], [11806, 11807], [11818, 11822], [11824, 11833], [11836, 11839], [11841, 11841], [11843, 11849], [12289, 12291], [12349, 12349], [12539, 12539], [42238, 42239], [42509, 42511], [42611, 42611], [42622, 42622], [42738, 42743], [43124, 43127], [43214, 43215], [43256, 43258], [43260, 43260], [43310, 43311], [43359, 43359], [43457, 43469], [43486, 43487], [43612, 43615], [43742, 43743], [43760, 43761], [44011, 44011], [65040, 65046], [65049, 65049], [65072, 65072], [65093, 65094], [65097, 65100], [65104, 65106], [65108, 65111], [65119, 65121], [65128, 65128], [65130, 65131], [65281, 65283], [65285, 65287], [65290, 65290], [65292, 65292], [65294, 65295], [65306, 65307], [65311, 65312], [65340, 65340], [65377, 65377], [65380, 65381]],
  6488. "Co": [[57344, 57344], [63743, 63743]],
  6489. "Sm": [[43, 43], [60, 62], [124, 124], [126, 126], [172, 172], [177, 177], [215, 215], [247, 247], [1014, 1014], [1542, 1544], [8260, 8260], [8274, 8274], [8314, 8316], [8330, 8332], [8472, 8472], [8512, 8516], [8523, 8523], [8592, 8596], [8602, 8603], [8608, 8608], [8611, 8611], [8614, 8614], [8622, 8622], [8654, 8655], [8658, 8658], [8660, 8660], [8692, 8959], [8992, 8993], [9084, 9084], [9115, 9139], [9180, 9185], [9655, 9655], [9665, 9665], [9720, 9727], [9839, 9839], [10176, 10180], [10183, 10213], [10224, 10239], [10496, 10626], [10649, 10711], [10716, 10747], [10750, 11007], [11056, 11076], [11079, 11084], [64297, 64297], [65122, 65122], [65124, 65126], [65291, 65291], [65308, 65310], [65372, 65372], [65374, 65374], [65506, 65506], [65513, 65516]],
  6490. "Pf": [[187, 187], [8217, 8217], [8221, 8221], [8250, 8250], [11779, 11779], [11781, 11781], [11786, 11786], [11789, 11789], [11805, 11805], [11809, 11809]],
  6491. "Cc": [[0, 31], [127, 159]],
  6492. "Pi": [[171, 171], [8216, 8216], [8219, 8220], [8223, 8223], [8249, 8249], [11778, 11778], [11780, 11780], [11785, 11785], [11788, 11788], [11804, 11804], [11808, 11808]],
  6493. "Lu": [[65, 90], [192, 214], [216, 222], [256, 256], [258, 258], [260, 260], [262, 262], [264, 264], [266, 266], [268, 268], [270, 270], [272, 272], [274, 274], [276, 276], [278, 278], [280, 280], [282, 282], [284, 284], [286, 286], [288, 288], [290, 290], [292, 292], [294, 294], [296, 296], [298, 298], [300, 300], [302, 302], [304, 304], [306, 306], [308, 308], [310, 310], [313, 313], [315, 315], [317, 317], [319, 319], [321, 321], [323, 323], [325, 325], [327, 327], [330, 330], [332, 332], [334, 334], [336, 336], [338, 338], [340, 340], [342, 342], [344, 344], [346, 346], [348, 348], [350, 350], [352, 352], [354, 354], [356, 356], [358, 358], [360, 360], [362, 362], [364, 364], [366, 366], [368, 368], [370, 370], [372, 372], [374, 374], [376, 377], [379, 379], [381, 381], [385, 386], [388, 388], [390, 391], [393, 395], [398, 401], [403, 404], [406, 408], [412, 413], [415, 416], [418, 418], [420, 420], [422, 423], [425, 425], [428, 428], [430, 431], [433, 435], [437, 437], [439, 440], [444, 444], [452, 452], [455, 455], [458, 458], [461, 461], [463, 463], [465, 465], [467, 467], [469, 469], [471, 471], [473, 473], [475, 475], [478, 478], [480, 480], [482, 482], [484, 484], [486, 486], [488, 488], [490, 490], [492, 492], [494, 494], [497, 497], [500, 500], [502, 504], [506, 506], [508, 508], [510, 510], [512, 512], [514, 514], [516, 516], [518, 518], [520, 520], [522, 522], [524, 524], [526, 526], [528, 528], [530, 530], [532, 532], [534, 534], [536, 536], [538, 538], [540, 540], [542, 542], [544, 544], [546, 546], [548, 548], [550, 550], [552, 552], [554, 554], [556, 556], [558, 558], [560, 560], [562, 562], [570, 571], [573, 574], [577, 577], [579, 582], [584, 584], [586, 586], [588, 588], [590, 590], [880, 880], [882, 882], [886, 886], [895, 895], [902, 902], [904, 906], [908, 908], [910, 911], [913, 929], [931, 939], [975, 975], [978, 980], [984, 984], [986, 986], [988, 988], [990, 990], [992, 992], [994, 994], [996, 996], [998, 998], [1000, 1000], [1002, 1002], [1004, 1004], [1006, 1006], [1012, 1012], [1015, 1015], [1017, 1018], [1021, 1071], [1120, 1120], [1122, 1122], [1124, 1124], [1126, 1126], [1128, 1128], [1130, 1130], [1132, 1132], [1134, 1134], [1136, 1136], [1138, 1138], [1140, 1140], [1142, 1142], [1144, 1144], [1146, 1146], [1148, 1148], [1150, 1150], [1152, 1152], [1162, 1162], [1164, 1164], [1166, 1166], [1168, 1168], [1170, 1170], [1172, 1172], [1174, 1174], [1176, 1176], [1178, 1178], [1180, 1180], [1182, 1182], [1184, 1184], [1186, 1186], [1188, 1188], [1190, 1190], [1192, 1192], [1194, 1194], [1196, 1196], [1198, 1198], [1200, 1200], [1202, 1202], [1204, 1204], [1206, 1206], [1208, 1208], [1210, 1210], [1212, 1212], [1214, 1214], [1216, 1217], [1219, 1219], [1221, 1221], [1223, 1223], [1225, 1225], [1227, 1227], [1229, 1229], [1232, 1232], [1234, 1234], [1236, 1236], [1238, 1238], [1240, 1240], [1242, 1242], [1244, 1244], [1246, 1246], [1248, 1248], [1250, 1250], [1252, 1252], [1254, 1254], [1256, 1256], [1258, 1258], [1260, 1260], [1262, 1262], [1264, 1264], [1266, 1266], [1268, 1268], [1270, 1270], [1272, 1272], [1274, 1274], [1276, 1276], [1278, 1278], [1280, 1280], [1282, 1282], [1284, 1284], [1286, 1286], [1288, 1288], [1290, 1290], [1292, 1292], [1294, 1294], [1296, 1296], [1298, 1298], [1300, 1300], [1302, 1302], [1304, 1304], [1306, 1306], [1308, 1308], [1310, 1310], [1312, 1312], [1314, 1314], [1316, 1316], [1318, 1318], [1320, 1320], [1322, 1322], [1324, 1324], [1326, 1326], [1329, 1366], [4256, 4293], [4295, 4295], [4301, 4301], [5024, 5109], [7680, 7680], [7682, 7682], [7684, 7684], [7686, 7686], [7688, 7688], [7690, 7690], [7692, 7692], [7694, 7694], [7696, 7696], [7698, 7698], [7700, 7700], [7702, 7702], [7704, 7704], [7706, 7706], [7708, 7708], [7710, 7710], [7712, 7712], [7714, 7714], [7716, 7716], [7718, 7718], [7720, 7720], [7722, 7722], [7724, 7724], [7726, 7726], [7728, 7728], [7730, 7730], [7732, 7732], [7734, 7734], [7736, 7736], [7738, 7738], [7740, 7740], [7742, 7742], [7744, 7744], [7746, 7746], [7748, 7748], [7750, 7750], [7752, 7752], [7754, 7754], [7756, 7756], [7758, 7758], [7760, 7760], [7762, 7762], [7764, 7764], [7766, 7766], [7768, 7768], [7770, 7770], [7772, 7772], [7774, 7774], [7776, 7776], [7778, 7778], [7780, 7780], [7782, 7782], [7784, 7784], [7786, 7786], [7788, 7788], [7790, 7790], [7792, 7792], [7794, 7794], [7796, 7796], [7798, 7798], [7800, 7800], [7802, 7802], [7804, 7804], [7806, 7806], [7808, 7808], [7810, 7810], [7812, 7812], [7814, 7814], [7816, 7816], [7818, 7818], [7820, 7820], [7822, 7822], [7824, 7824], [7826, 7826], [7828, 7828], [7838, 7838], [7840, 7840], [7842, 7842], [7844, 7844], [7846, 7846], [7848, 7848], [7850, 7850], [7852, 7852], [7854, 7854], [7856, 7856], [7858, 7858], [7860, 7860], [7862, 7862], [7864, 7864], [7866, 7866], [7868, 7868], [7870, 7870], [7872, 7872], [7874, 7874], [7876, 7876], [7878, 7878], [7880, 7880], [7882, 7882], [7884, 7884], [7886, 7886], [7888, 7888], [7890, 7890], [7892, 7892], [7894, 7894], [7896, 7896], [7898, 7898], [7900, 7900], [7902, 7902], [7904, 7904], [7906, 7906], [7908, 7908], [7910, 7910], [7912, 7912], [7914, 7914], [7916, 7916], [7918, 7918], [7920, 7920], [7922, 7922], [7924, 7924], [7926, 7926], [7928, 7928], [7930, 7930], [7932, 7932], [7934, 7934], [7944, 7951], [7960, 7965], [7976, 7983], [7992, 7999], [8008, 8013], [8025, 8025], [8027, 8027], [8029, 8029], [8031, 8031], [8040, 8047], [8120, 8123], [8136, 8139], [8152, 8155], [8168, 8172], [8184, 8187], [8450, 8450], [8455, 8455], [8459, 8461], [8464, 8466], [8469, 8469], [8473, 8477], [8484, 8484], [8486, 8486], [8488, 8488], [8490, 8493], [8496, 8499], [8510, 8511], [8517, 8517], [8579, 8579], [11264, 11310], [11360, 11360], [11362, 11364], [11367, 11367], [11369, 11369], [11371, 11371], [11373, 11376], [11378, 11378], [11381, 11381], [11390, 11392], [11394, 11394], [11396, 11396], [11398, 11398], [11400, 11400], [11402, 11402], [11404, 11404], [11406, 11406], [11408, 11408], [11410, 11410], [11412, 11412], [11414, 11414], [11416, 11416], [11418, 11418], [11420, 11420], [11422, 11422], [11424, 11424], [11426, 11426], [11428, 11428], [11430, 11430], [11432, 11432], [11434, 11434], [11436, 11436], [11438, 11438], [11440, 11440], [11442, 11442], [11444, 11444], [11446, 11446], [11448, 11448], [11450, 11450], [11452, 11452], [11454, 11454], [11456, 11456], [11458, 11458], [11460, 11460], [11462, 11462], [11464, 11464], [11466, 11466], [11468, 11468], [11470, 11470], [11472, 11472], [11474, 11474], [11476, 11476], [11478, 11478], [11480, 11480], [11482, 11482], [11484, 11484], [11486, 11486], [11488, 11488], [11490, 11490], [11499, 11499], [11501, 11501], [11506, 11506], [42560, 42560], [42562, 42562], [42564, 42564], [42566, 42566], [42568, 42568], [42570, 42570], [42572, 42572], [42574, 42574], [42576, 42576], [42578, 42578], [42580, 42580], [42582, 42582], [42584, 42584], [42586, 42586], [42588, 42588], [42590, 42590], [42592, 42592], [42594, 42594], [42596, 42596], [42598, 42598], [42600, 42600], [42602, 42602], [42604, 42604], [42624, 42624], [42626, 42626], [42628, 42628], [42630, 42630], [42632, 42632], [42634, 42634], [42636, 42636], [42638, 42638], [42640, 42640], [42642, 42642], [42644, 42644], [42646, 42646], [42648, 42648], [42650, 42650], [42786, 42786], [42788, 42788], [42790, 42790], [42792, 42792], [42794, 42794], [42796, 42796], [42798, 42798], [42802, 42802], [42804, 42804], [42806, 42806], [42808, 42808], [42810, 42810], [42812, 42812], [42814, 42814], [42816, 42816], [42818, 42818], [42820, 42820], [42822, 42822], [42824, 42824], [42826, 42826], [42828, 42828], [42830, 42830], [42832, 42832], [42834, 42834], [42836, 42836], [42838, 42838], [42840, 42840], [42842, 42842], [42844, 42844], [42846, 42846], [42848, 42848], [42850, 42850], [42852, 42852], [42854, 42854], [42856, 42856], [42858, 42858], [42860, 42860], [42862, 42862], [42873, 42873], [42875, 42875], [42877, 42878], [42880, 42880], [42882, 42882], [42884, 42884], [42886, 42886], [42891, 42891], [42893, 42893], [42896, 42896], [42898, 42898], [42902, 42902], [42904, 42904], [42906, 42906], [42908, 42908], [42910, 42910], [42912, 42912], [42914, 42914], [42916, 42916], [42918, 42918], [42920, 42920], [42922, 42926], [42928, 42932], [42934, 42934], [65313, 65338]],
  6494. "Pd": [[45, 45], [1418, 1418], [1470, 1470], [5120, 5120], [6150, 6150], [8208, 8213], [11799, 11799], [11802, 11802], [11834, 11835], [11840, 11840], [12316, 12316], [12336, 12336], [12448, 12448], [65073, 65074], [65112, 65112], [65123, 65123], [65293, 65293]],
  6495. "Cf": [[173, 173], [1536, 1541], [1564, 1564], [1757, 1757], [1807, 1807], [2274, 2274], [6158, 6158], [8203, 8207], [8234, 8238], [8288, 8292], [8294, 8303], [65279, 65279], [65529, 65531]],
  6496. "Nd": [[48, 57], [1632, 1641], [1776, 1785], [1984, 1993], [2406, 2415], [2534, 2543], [2662, 2671], [2790, 2799], [2918, 2927], [3046, 3055], [3174, 3183], [3302, 3311], [3430, 3439], [3558, 3567], [3664, 3673], [3792, 3801], [3872, 3881], [4160, 4169], [4240, 4249], [6112, 6121], [6160, 6169], [6470, 6479], [6608, 6617], [6784, 6793], [6800, 6809], [6992, 7001], [7088, 7097], [7232, 7241], [7248, 7257], [42528, 42537], [43216, 43225], [43264, 43273], [43472, 43481], [43504, 43513], [43600, 43609], [44016, 44025], [65296, 65305]],
  6497. "Ll": [[97, 122], [181, 181], [223, 246], [248, 255], [257, 257], [259, 259], [261, 261], [263, 263], [265, 265], [267, 267], [269, 269], [271, 271], [273, 273], [275, 275], [277, 277], [279, 279], [281, 281], [283, 283], [285, 285], [287, 287], [289, 289], [291, 291], [293, 293], [295, 295], [297, 297], [299, 299], [301, 301], [303, 303], [305, 305], [307, 307], [309, 309], [311, 312], [314, 314], [316, 316], [318, 318], [320, 320], [322, 322], [324, 324], [326, 326], [328, 329], [331, 331], [333, 333], [335, 335], [337, 337], [339, 339], [341, 341], [343, 343], [345, 345], [347, 347], [349, 349], [351, 351], [353, 353], [355, 355], [357, 357], [359, 359], [361, 361], [363, 363], [365, 365], [367, 367], [369, 369], [371, 371], [373, 373], [375, 375], [378, 378], [380, 380], [382, 384], [387, 387], [389, 389], [392, 392], [396, 397], [402, 402], [405, 405], [409, 411], [414, 414], [417, 417], [419, 419], [421, 421], [424, 424], [426, 427], [429, 429], [432, 432], [436, 436], [438, 438], [441, 442], [445, 447], [454, 454], [457, 457], [460, 460], [462, 462], [464, 464], [466, 466], [468, 468], [470, 470], [472, 472], [474, 474], [476, 477], [479, 479], [481, 481], [483, 483], [485, 485], [487, 487], [489, 489], [491, 491], [493, 493], [495, 496], [499, 499], [501, 501], [505, 505], [507, 507], [509, 509], [511, 511], [513, 513], [515, 515], [517, 517], [519, 519], [521, 521], [523, 523], [525, 525], [527, 527], [529, 529], [531, 531], [533, 533], [535, 535], [537, 537], [539, 539], [541, 541], [543, 543], [545, 545], [547, 547], [549, 549], [551, 551], [553, 553], [555, 555], [557, 557], [559, 559], [561, 561], [563, 569], [572, 572], [575, 576], [578, 578], [583, 583], [585, 585], [587, 587], [589, 589], [591, 659], [661, 687], [881, 881], [883, 883], [887, 887], [891, 893], [912, 912], [940, 974], [976, 977], [981, 983], [985, 985], [987, 987], [989, 989], [991, 991], [993, 993], [995, 995], [997, 997], [999, 999], [1001, 1001], [1003, 1003], [1005, 1005], [1007, 1011], [1013, 1013], [1016, 1016], [1019, 1020], [1072, 1119], [1121, 1121], [1123, 1123], [1125, 1125], [1127, 1127], [1129, 1129], [1131, 1131], [1133, 1133], [1135, 1135], [1137, 1137], [1139, 1139], [1141, 1141], [1143, 1143], [1145, 1145], [1147, 1147], [1149, 1149], [1151, 1151], [1153, 1153], [1163, 1163], [1165, 1165], [1167, 1167], [1169, 1169], [1171, 1171], [1173, 1173], [1175, 1175], [1177, 1177], [1179, 1179], [1181, 1181], [1183, 1183], [1185, 1185], [1187, 1187], [1189, 1189], [1191, 1191], [1193, 1193], [1195, 1195], [1197, 1197], [1199, 1199], [1201, 1201], [1203, 1203], [1205, 1205], [1207, 1207], [1209, 1209], [1211, 1211], [1213, 1213], [1215, 1215], [1218, 1218], [1220, 1220], [1222, 1222], [1224, 1224], [1226, 1226], [1228, 1228], [1230, 1231], [1233, 1233], [1235, 1235], [1237, 1237], [1239, 1239], [1241, 1241], [1243, 1243], [1245, 1245], [1247, 1247], [1249, 1249], [1251, 1251], [1253, 1253], [1255, 1255], [1257, 1257], [1259, 1259], [1261, 1261], [1263, 1263], [1265, 1265], [1267, 1267], [1269, 1269], [1271, 1271], [1273, 1273], [1275, 1275], [1277, 1277], [1279, 1279], [1281, 1281], [1283, 1283], [1285, 1285], [1287, 1287], [1289, 1289], [1291, 1291], [1293, 1293], [1295, 1295], [1297, 1297], [1299, 1299], [1301, 1301], [1303, 1303], [1305, 1305], [1307, 1307], [1309, 1309], [1311, 1311], [1313, 1313], [1315, 1315], [1317, 1317], [1319, 1319], [1321, 1321], [1323, 1323], [1325, 1325], [1327, 1327], [1377, 1415], [5112, 5117], [7296, 7304], [7424, 7467], [7531, 7543], [7545, 7578], [7681, 7681], [7683, 7683], [7685, 7685], [7687, 7687], [7689, 7689], [7691, 7691], [7693, 7693], [7695, 7695], [7697, 7697], [7699, 7699], [7701, 7701], [7703, 7703], [7705, 7705], [7707, 7707], [7709, 7709], [7711, 7711], [7713, 7713], [7715, 7715], [7717, 7717], [7719, 7719], [7721, 7721], [7723, 7723], [7725, 7725], [7727, 7727], [7729, 7729], [7731, 7731], [7733, 7733], [7735, 7735], [7737, 7737], [7739, 7739], [7741, 7741], [7743, 7743], [7745, 7745], [7747, 7747], [7749, 7749], [7751, 7751], [7753, 7753], [7755, 7755], [7757, 7757], [7759, 7759], [7761, 7761], [7763, 7763], [7765, 7765], [7767, 7767], [7769, 7769], [7771, 7771], [7773, 7773], [7775, 7775], [7777, 7777], [7779, 7779], [7781, 7781], [7783, 7783], [7785, 7785], [7787, 7787], [7789, 7789], [7791, 7791], [7793, 7793], [7795, 7795], [7797, 7797], [7799, 7799], [7801, 7801], [7803, 7803], [7805, 7805], [7807, 7807], [7809, 7809], [7811, 7811], [7813, 7813], [7815, 7815], [7817, 7817], [7819, 7819], [7821, 7821], [7823, 7823], [7825, 7825], [7827, 7827], [7829, 7837], [7839, 7839], [7841, 7841], [7843, 7843], [7845, 7845], [7847, 7847], [7849, 7849], [7851, 7851], [7853, 7853], [7855, 7855], [7857, 7857], [7859, 7859], [7861, 7861], [7863, 7863], [7865, 7865], [7867, 7867], [7869, 7869], [7871, 7871], [7873, 7873], [7875, 7875], [7877, 7877], [7879, 7879], [7881, 7881], [7883, 7883], [7885, 7885], [7887, 7887], [7889, 7889], [7891, 7891], [7893, 7893], [7895, 7895], [7897, 7897], [7899, 7899], [7901, 7901], [7903, 7903], [7905, 7905], [7907, 7907], [7909, 7909], [7911, 7911], [7913, 7913], [7915, 7915], [7917, 7917], [7919, 7919], [7921, 7921], [7923, 7923], [7925, 7925], [7927, 7927], [7929, 7929], [7931, 7931], [7933, 7933], [7935, 7943], [7952, 7957], [7968, 7975], [7984, 7991], [8000, 8005], [8016, 8023], [8032, 8039], [8048, 8061], [8064, 8071], [8080, 8087], [8096, 8103], [8112, 8116], [8118, 8119], [8126, 8126], [8130, 8132], [8134, 8135], [8144, 8147], [8150, 8151], [8160, 8167], [8178, 8180], [8182, 8183], [8458, 8458], [8462, 8463], [8467, 8467], [8495, 8495], [8500, 8500], [8505, 8505], [8508, 8509], [8518, 8521], [8526, 8526], [8580, 8580], [11312, 11358], [11361, 11361], [11365, 11366], [11368, 11368], [11370, 11370], [11372, 11372], [11377, 11377], [11379, 11380], [11382, 11387], [11393, 11393], [11395, 11395], [11397, 11397], [11399, 11399], [11401, 11401], [11403, 11403], [11405, 11405], [11407, 11407], [11409, 11409], [11411, 11411], [11413, 11413], [11415, 11415], [11417, 11417], [11419, 11419], [11421, 11421], [11423, 11423], [11425, 11425], [11427, 11427], [11429, 11429], [11431, 11431], [11433, 11433], [11435, 11435], [11437, 11437], [11439, 11439], [11441, 11441], [11443, 11443], [11445, 11445], [11447, 11447], [11449, 11449], [11451, 11451], [11453, 11453], [11455, 11455], [11457, 11457], [11459, 11459], [11461, 11461], [11463, 11463], [11465, 11465], [11467, 11467], [11469, 11469], [11471, 11471], [11473, 11473], [11475, 11475], [11477, 11477], [11479, 11479], [11481, 11481], [11483, 11483], [11485, 11485], [11487, 11487], [11489, 11489], [11491, 11492], [11500, 11500], [11502, 11502], [11507, 11507], [11520, 11557], [11559, 11559], [11565, 11565], [42561, 42561], [42563, 42563], [42565, 42565], [42567, 42567], [42569, 42569], [42571, 42571], [42573, 42573], [42575, 42575], [42577, 42577], [42579, 42579], [42581, 42581], [42583, 42583], [42585, 42585], [42587, 42587], [42589, 42589], [42591, 42591], [42593, 42593], [42595, 42595], [42597, 42597], [42599, 42599], [42601, 42601], [42603, 42603], [42605, 42605], [42625, 42625], [42627, 42627], [42629, 42629], [42631, 42631], [42633, 42633], [42635, 42635], [42637, 42637], [42639, 42639], [42641, 42641], [42643, 42643], [42645, 42645], [42647, 42647], [42649, 42649], [42651, 42651], [42787, 42787], [42789, 42789], [42791, 42791], [42793, 42793], [42795, 42795], [42797, 42797], [42799, 42801], [42803, 42803], [42805, 42805], [42807, 42807], [42809, 42809], [42811, 42811], [42813, 42813], [42815, 42815], [42817, 42817], [42819, 42819], [42821, 42821], [42823, 42823], [42825, 42825], [42827, 42827], [42829, 42829], [42831, 42831], [42833, 42833], [42835, 42835], [42837, 42837], [42839, 42839], [42841, 42841], [42843, 42843], [42845, 42845], [42847, 42847], [42849, 42849], [42851, 42851], [42853, 42853], [42855, 42855], [42857, 42857], [42859, 42859], [42861, 42861], [42863, 42863], [42865, 42872], [42874, 42874], [42876, 42876], [42879, 42879], [42881, 42881], [42883, 42883], [42885, 42885], [42887, 42887], [42892, 42892], [42894, 42894], [42897, 42897], [42899, 42901], [42903, 42903], [42905, 42905], [42907, 42907], [42909, 42909], [42911, 42911], [42913, 42913], [42915, 42915], [42917, 42917], [42919, 42919], [42921, 42921], [42933, 42933], [42935, 42935], [43002, 43002], [43824, 43866], [43872, 43877], [43888, 43967], [64256, 64262], [64275, 64279], [65345, 65370]],
  6498. "No": [[178, 179], [185, 185], [188, 190], [2548, 2553], [2930, 2935], [3056, 3058], [3192, 3198], [3416, 3422], [3440, 3448], [3882, 3891], [4969, 4988], [6128, 6137], [6618, 6618], [8304, 8304], [8308, 8313], [8320, 8329], [8528, 8543], [8585, 8585], [9312, 9371], [9450, 9471], [10102, 10131], [11517, 11517], [12690, 12693], [12832, 12841], [12872, 12879], [12881, 12895], [12928, 12937], [12977, 12991], [43056, 43061]],
  6499. "Zs": [[32, 32], [160, 160], [5760, 5760], [8192, 8202], [8239, 8239], [8287, 8287], [12288, 12288]]
  6500. };
  6501. };
  6502. });
  6503. unwrapExports(data_generated);
  6504. var utils$2 = createCommonjsModule(function (module, exports) {
  6505. "use strict";
  6506. exports.__esModule = true;
  6507. function normalize_ranges(ranges) {
  6508. return ranges.sort(function (_a, _b) {
  6509. var start1 = _a[0];
  6510. var start2 = _b[0];
  6511. return start1 - start2;
  6512. }).reduce(function (current, tuple, index) {
  6513. if (index === 0) {
  6514. return [tuple];
  6515. }
  6516. var _a = current[current.length - 1],
  6517. last_start = _a[0],
  6518. last_end = _a[1];
  6519. var start = tuple[0],
  6520. end = tuple[1];
  6521. return last_end + 1 === start ? current.slice(0, -1).concat([[last_start, end]]) : current.concat([tuple]);
  6522. }, []);
  6523. }
  6524. exports.normalize_ranges = normalize_ranges;
  6525. function build_regex(ranges, flag) {
  6526. var pattern = ranges.map(function (_a) {
  6527. var start = _a[0],
  6528. end = _a[1];
  6529. return start === end ? "\\u" + get_hex(start) : "\\u" + get_hex(start) + "-\\u" + get_hex(end);
  6530. }).join('');
  6531. return new RegExp("[" + pattern + "]", flag);
  6532. }
  6533. exports.build_regex = build_regex;
  6534. function get_hex(char_code) {
  6535. var hex = char_code.toString(16);
  6536. while (hex.length < 4) {
  6537. hex = "0" + hex;
  6538. }
  6539. return hex;
  6540. }
  6541. });
  6542. unwrapExports(utils$2);
  6543. var lib$5 = function lib(categories, flag) {
  6544. var data = data_generated.get_data();
  6545. var ranges = categories.reduce(function (current, category) {
  6546. return current.concat(data[category]);
  6547. }, []);
  6548. return utils$2.build_regex(utils$2.normalize_ranges(ranges), flag);
  6549. };
  6550. var emojiRegex = emojiRegex$1();
  6551. var cjkPattern = lib$3().source; // http://spec.commonmark.org/0.25/#ascii-punctuation-character
  6552. var asciiPunctuationCharRange = escapeStringRegexp("!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~"); // http://spec.commonmark.org/0.25/#punctuation-character
  6553. var punctuationCharRange = "".concat(asciiPunctuationCharRange).concat(lib$5(["Pc", "Pd", "Pe", "Pf", "Pi", "Po", "Ps"]).source.slice(1, -1)); // remove bracket expression `[` and `]`
  6554. var punctuationRegex = new RegExp("[".concat(punctuationCharRange, "]"));
  6555. function isExportDeclaration(node) {
  6556. if (node) {
  6557. switch (node.type) {
  6558. case "ExportDefaultDeclaration":
  6559. case "ExportDefaultSpecifier":
  6560. case "DeclareExportDeclaration":
  6561. case "ExportNamedDeclaration":
  6562. case "ExportAllDeclaration":
  6563. return true;
  6564. }
  6565. }
  6566. return false;
  6567. }
  6568. function getParentExportDeclaration(path) {
  6569. var parentNode = path.getParentNode();
  6570. if (path.getName() === "declaration" && isExportDeclaration(parentNode)) {
  6571. return parentNode;
  6572. }
  6573. return null;
  6574. }
  6575. function getPenultimate(arr) {
  6576. if (arr.length > 1) {
  6577. return arr[arr.length - 2];
  6578. }
  6579. return null;
  6580. }
  6581. function getLast$3(arr) {
  6582. if (arr.length > 0) {
  6583. return arr[arr.length - 1];
  6584. }
  6585. return null;
  6586. }
  6587. function skip(chars) {
  6588. return function (text, index, opts) {
  6589. var backwards = opts && opts.backwards; // Allow `skip` functions to be threaded together without having
  6590. // to check for failures (did someone say monads?).
  6591. if (index === false) {
  6592. return false;
  6593. }
  6594. var length = text.length;
  6595. var cursor = index;
  6596. while (cursor >= 0 && cursor < length) {
  6597. var c = text.charAt(cursor);
  6598. if (chars instanceof RegExp) {
  6599. if (!chars.test(c)) {
  6600. return cursor;
  6601. }
  6602. } else if (chars.indexOf(c) === -1) {
  6603. return cursor;
  6604. }
  6605. backwards ? cursor-- : cursor++;
  6606. }
  6607. if (cursor === -1 || cursor === length) {
  6608. // If we reached the beginning or end of the file, return the
  6609. // out-of-bounds cursor. It's up to the caller to handle this
  6610. // correctly. We don't want to indicate `false` though if it
  6611. // actually skipped valid characters.
  6612. return cursor;
  6613. }
  6614. return false;
  6615. };
  6616. }
  6617. var skipWhitespace = skip(/\s/);
  6618. var skipSpaces = skip(" \t");
  6619. var skipToLineEnd = skip(",; \t");
  6620. var skipEverythingButNewLine = skip(/[^\r\n]/);
  6621. function skipInlineComment(text, index) {
  6622. if (index === false) {
  6623. return false;
  6624. }
  6625. if (text.charAt(index) === "/" && text.charAt(index + 1) === "*") {
  6626. for (var i = index + 2; i < text.length; ++i) {
  6627. if (text.charAt(i) === "*" && text.charAt(i + 1) === "/") {
  6628. return i + 2;
  6629. }
  6630. }
  6631. }
  6632. return index;
  6633. }
  6634. function skipTrailingComment(text, index) {
  6635. if (index === false) {
  6636. return false;
  6637. }
  6638. if (text.charAt(index) === "/" && text.charAt(index + 1) === "/") {
  6639. return skipEverythingButNewLine(text, index);
  6640. }
  6641. return index;
  6642. } // This one doesn't use the above helper function because it wants to
  6643. // test \r\n in order and `skip` doesn't support ordering and we only
  6644. // want to skip one newline. It's simple to implement.
  6645. function skipNewline$1(text, index, opts) {
  6646. var backwards = opts && opts.backwards;
  6647. if (index === false) {
  6648. return false;
  6649. }
  6650. var atIndex = text.charAt(index);
  6651. if (backwards) {
  6652. if (text.charAt(index - 1) === "\r" && atIndex === "\n") {
  6653. return index - 2;
  6654. }
  6655. if (atIndex === "\n" || atIndex === "\r" || atIndex === "\u2028" || atIndex === "\u2029") {
  6656. return index - 1;
  6657. }
  6658. } else {
  6659. if (atIndex === "\r" && text.charAt(index + 1) === "\n") {
  6660. return index + 2;
  6661. }
  6662. if (atIndex === "\n" || atIndex === "\r" || atIndex === "\u2028" || atIndex === "\u2029") {
  6663. return index + 1;
  6664. }
  6665. }
  6666. return index;
  6667. }
  6668. function hasNewline$1(text, index, opts) {
  6669. opts = opts || {};
  6670. var idx = skipSpaces(text, opts.backwards ? index - 1 : index, opts);
  6671. var idx2 = skipNewline$1(text, idx, opts);
  6672. return idx !== idx2;
  6673. }
  6674. function hasNewlineInRange(text, start, end) {
  6675. for (var i = start; i < end; ++i) {
  6676. if (text.charAt(i) === "\n") {
  6677. return true;
  6678. }
  6679. }
  6680. return false;
  6681. } // Note: this function doesn't ignore leading comments unlike isNextLineEmpty
  6682. function isPreviousLineEmpty$1(text, node, locStart) {
  6683. var idx = locStart(node) - 1;
  6684. idx = skipSpaces(text, idx, {
  6685. backwards: true
  6686. });
  6687. idx = skipNewline$1(text, idx, {
  6688. backwards: true
  6689. });
  6690. idx = skipSpaces(text, idx, {
  6691. backwards: true
  6692. });
  6693. var idx2 = skipNewline$1(text, idx, {
  6694. backwards: true
  6695. });
  6696. return idx !== idx2;
  6697. }
  6698. function isNextLineEmptyAfterIndex(text, index) {
  6699. var oldIdx = null;
  6700. var idx = index;
  6701. while (idx !== oldIdx) {
  6702. // We need to skip all the potential trailing inline comments
  6703. oldIdx = idx;
  6704. idx = skipToLineEnd(text, idx);
  6705. idx = skipInlineComment(text, idx);
  6706. idx = skipSpaces(text, idx);
  6707. }
  6708. idx = skipTrailingComment(text, idx);
  6709. idx = skipNewline$1(text, idx);
  6710. return hasNewline$1(text, idx);
  6711. }
  6712. function isNextLineEmpty(text, node, locEnd) {
  6713. return isNextLineEmptyAfterIndex(text, locEnd(node));
  6714. }
  6715. function getNextNonSpaceNonCommentCharacterIndex(text, node, locEnd) {
  6716. var oldIdx = null;
  6717. var idx = locEnd(node);
  6718. while (idx !== oldIdx) {
  6719. oldIdx = idx;
  6720. idx = skipSpaces(text, idx);
  6721. idx = skipInlineComment(text, idx);
  6722. idx = skipTrailingComment(text, idx);
  6723. idx = skipNewline$1(text, idx);
  6724. }
  6725. return idx;
  6726. }
  6727. function getNextNonSpaceNonCommentCharacter(text, node, locEnd) {
  6728. return text.charAt(getNextNonSpaceNonCommentCharacterIndex(text, node, locEnd));
  6729. }
  6730. function hasSpaces(text, index, opts) {
  6731. opts = opts || {};
  6732. var idx = skipSpaces(text, opts.backwards ? index - 1 : index, opts);
  6733. return idx !== index;
  6734. }
  6735. function setLocStart(node, index) {
  6736. if (node.range) {
  6737. node.range[0] = index;
  6738. } else {
  6739. node.start = index;
  6740. }
  6741. }
  6742. function setLocEnd(node, index) {
  6743. if (node.range) {
  6744. node.range[1] = index;
  6745. } else {
  6746. node.end = index;
  6747. }
  6748. }
  6749. var PRECEDENCE = {};
  6750. [["|>"], ["||", "??"], ["&&"], ["|"], ["^"], ["&"], ["==", "===", "!=", "!=="], ["<", ">", "<=", ">=", "in", "instanceof"], [">>", "<<", ">>>"], ["+", "-"], ["*", "/", "%"], ["**"]].forEach(function (tier, i) {
  6751. tier.forEach(function (op) {
  6752. PRECEDENCE[op] = i;
  6753. });
  6754. });
  6755. function getPrecedence(op) {
  6756. return PRECEDENCE[op];
  6757. }
  6758. var equalityOperators = {
  6759. "==": true,
  6760. "!=": true,
  6761. "===": true,
  6762. "!==": true
  6763. };
  6764. var additiveOperators = {
  6765. "+": true,
  6766. "-": true
  6767. };
  6768. var multiplicativeOperators = {
  6769. "*": true,
  6770. "/": true,
  6771. "%": true
  6772. };
  6773. var bitshiftOperators = {
  6774. ">>": true,
  6775. ">>>": true,
  6776. "<<": true
  6777. };
  6778. function shouldFlatten(parentOp, nodeOp) {
  6779. if (getPrecedence(nodeOp) !== getPrecedence(parentOp)) {
  6780. // x + y % z --> (x + y) % z
  6781. if (nodeOp === "%" && !additiveOperators[parentOp]) {
  6782. return true;
  6783. }
  6784. return false;
  6785. } // ** is right-associative
  6786. // x ** y ** z --> x ** (y ** z)
  6787. if (parentOp === "**") {
  6788. return false;
  6789. } // x == y == z --> (x == y) == z
  6790. if (equalityOperators[parentOp] && equalityOperators[nodeOp]) {
  6791. return false;
  6792. } // x * y % z --> (x * y) % z
  6793. if (nodeOp === "%" && multiplicativeOperators[parentOp] || parentOp === "%" && multiplicativeOperators[nodeOp]) {
  6794. return false;
  6795. } // x * y / z --> (x * y) / z
  6796. // x / y * z --> (x / y) * z
  6797. if (nodeOp !== parentOp && multiplicativeOperators[nodeOp] && multiplicativeOperators[parentOp]) {
  6798. return false;
  6799. } // x << y << z --> (x << y) << z
  6800. if (bitshiftOperators[parentOp] && bitshiftOperators[nodeOp]) {
  6801. return false;
  6802. }
  6803. return true;
  6804. }
  6805. function isBitwiseOperator(operator) {
  6806. return !!bitshiftOperators[operator] || operator === "|" || operator === "^" || operator === "&";
  6807. } // Tests if an expression starts with `{`, or (if forbidFunctionClassAndDoExpr
  6808. // holds) `function`, `class`, or `do {}`. Will be overzealous if there's
  6809. // already necessary grouping parentheses.
  6810. function startsWithNoLookaheadToken(node, forbidFunctionClassAndDoExpr) {
  6811. node = getLeftMost(node);
  6812. switch (node.type) {
  6813. // Hack. Remove after https://github.com/eslint/typescript-eslint-parser/issues/331
  6814. case "ObjectPattern":
  6815. return !forbidFunctionClassAndDoExpr;
  6816. case "FunctionExpression":
  6817. case "ClassExpression":
  6818. case "DoExpression":
  6819. return forbidFunctionClassAndDoExpr;
  6820. case "ObjectExpression":
  6821. return true;
  6822. case "MemberExpression":
  6823. return startsWithNoLookaheadToken(node.object, forbidFunctionClassAndDoExpr);
  6824. case "TaggedTemplateExpression":
  6825. if (node.tag.type === "FunctionExpression") {
  6826. // IIFEs are always already parenthesized
  6827. return false;
  6828. }
  6829. return startsWithNoLookaheadToken(node.tag, forbidFunctionClassAndDoExpr);
  6830. case "CallExpression":
  6831. if (node.callee.type === "FunctionExpression") {
  6832. // IIFEs are always already parenthesized
  6833. return false;
  6834. }
  6835. return startsWithNoLookaheadToken(node.callee, forbidFunctionClassAndDoExpr);
  6836. case "ConditionalExpression":
  6837. return startsWithNoLookaheadToken(node.test, forbidFunctionClassAndDoExpr);
  6838. case "UpdateExpression":
  6839. return !node.prefix && startsWithNoLookaheadToken(node.argument, forbidFunctionClassAndDoExpr);
  6840. case "BindExpression":
  6841. return node.object && startsWithNoLookaheadToken(node.object, forbidFunctionClassAndDoExpr);
  6842. case "SequenceExpression":
  6843. return startsWithNoLookaheadToken(node.expressions[0], forbidFunctionClassAndDoExpr);
  6844. case "TSAsExpression":
  6845. return startsWithNoLookaheadToken(node.expression, forbidFunctionClassAndDoExpr);
  6846. default:
  6847. return false;
  6848. }
  6849. }
  6850. function getLeftMost(node) {
  6851. if (node.left) {
  6852. return getLeftMost(node.left);
  6853. }
  6854. return node;
  6855. }
  6856. function getAlignmentSize(value, tabWidth, startIndex) {
  6857. startIndex = startIndex || 0;
  6858. var size = 0;
  6859. for (var i = startIndex; i < value.length; ++i) {
  6860. if (value[i] === "\t") {
  6861. // Tabs behave in a way that they are aligned to the nearest
  6862. // multiple of tabWidth:
  6863. // 0 -> 4, 1 -> 4, 2 -> 4, 3 -> 4
  6864. // 4 -> 8, 5 -> 8, 6 -> 8, 7 -> 8 ...
  6865. size = size + tabWidth - size % tabWidth;
  6866. } else {
  6867. size++;
  6868. }
  6869. }
  6870. return size;
  6871. }
  6872. function getIndentSize(value, tabWidth) {
  6873. var lastNewlineIndex = value.lastIndexOf("\n");
  6874. if (lastNewlineIndex === -1) {
  6875. return 0;
  6876. }
  6877. return getAlignmentSize( // All the leading whitespaces
  6878. value.slice(lastNewlineIndex + 1).match(/^[ \t]*/)[0], tabWidth);
  6879. }
  6880. function printString(raw, options, isDirectiveLiteral) {
  6881. // `rawContent` is the string exactly like it appeared in the input source
  6882. // code, without its enclosing quotes.
  6883. var rawContent = raw.slice(1, -1);
  6884. var double = {
  6885. quote: '"',
  6886. regex: /"/g
  6887. };
  6888. var single = {
  6889. quote: "'",
  6890. regex: /'/g
  6891. };
  6892. var preferred = options.singleQuote ? single : double;
  6893. var alternate = preferred === single ? double : single;
  6894. var shouldUseAlternateQuote = false;
  6895. var canChangeDirectiveQuotes = false; // If `rawContent` contains at least one of the quote preferred for enclosing
  6896. // the string, we might want to enclose with the alternate quote instead, to
  6897. // minimize the number of escaped quotes.
  6898. // Also check for the alternate quote, to determine if we're allowed to swap
  6899. // the quotes on a DirectiveLiteral.
  6900. if (rawContent.includes(preferred.quote) || rawContent.includes(alternate.quote)) {
  6901. var numPreferredQuotes = (rawContent.match(preferred.regex) || []).length;
  6902. var numAlternateQuotes = (rawContent.match(alternate.regex) || []).length;
  6903. shouldUseAlternateQuote = numPreferredQuotes > numAlternateQuotes;
  6904. } else {
  6905. canChangeDirectiveQuotes = true;
  6906. }
  6907. var enclosingQuote = options.parser === "json" ? double.quote : shouldUseAlternateQuote ? alternate.quote : preferred.quote; // Directives are exact code unit sequences, which means that you can't
  6908. // change the escape sequences they use.
  6909. // See https://github.com/prettier/prettier/issues/1555
  6910. // and https://tc39.github.io/ecma262/#directive-prologue
  6911. if (isDirectiveLiteral) {
  6912. if (canChangeDirectiveQuotes) {
  6913. return enclosingQuote + rawContent + enclosingQuote;
  6914. }
  6915. return raw;
  6916. } // It might sound unnecessary to use `makeString` even if the string already
  6917. // is enclosed with `enclosingQuote`, but it isn't. The string could contain
  6918. // unnecessary escapes (such as in `"\'"`). Always using `makeString` makes
  6919. // sure that we consistently output the minimum amount of escaped quotes.
  6920. return makeString(rawContent, enclosingQuote, !(options.parser === "css" || options.parser === "less" || options.parser === "scss"));
  6921. }
  6922. function makeString(rawContent, enclosingQuote, unescapeUnnecessaryEscapes) {
  6923. var otherQuote = enclosingQuote === '"' ? "'" : '"'; // Matches _any_ escape and unescaped quotes (both single and double).
  6924. var regex = /\\([\s\S])|(['"])/g; // Escape and unescape single and double quotes as needed to be able to
  6925. // enclose `rawContent` with `enclosingQuote`.
  6926. var newContent = rawContent.replace(regex, function (match, escaped, quote) {
  6927. // If we matched an escape, and the escaped character is a quote of the
  6928. // other type than we intend to enclose the string with, there's no need for
  6929. // it to be escaped, so return it _without_ the backslash.
  6930. if (escaped === otherQuote) {
  6931. return escaped;
  6932. } // If we matched an unescaped quote and it is of the _same_ type as we
  6933. // intend to enclose the string with, it must be escaped, so return it with
  6934. // a backslash.
  6935. if (quote === enclosingQuote) {
  6936. return "\\" + quote;
  6937. }
  6938. if (quote) {
  6939. return quote;
  6940. } // Unescape any unnecessarily escaped character.
  6941. // Adapted from https://github.com/eslint/eslint/blob/de0b4ad7bd820ade41b1f606008bea68683dc11a/lib/rules/no-useless-escape.js#L27
  6942. return unescapeUnnecessaryEscapes && /^[^\\nrvtbfux\r\n\u2028\u2029"'0-7]$/.test(escaped) ? escaped : "\\" + escaped;
  6943. });
  6944. return enclosingQuote + newContent + enclosingQuote;
  6945. }
  6946. function printNumber(rawNumber) {
  6947. return rawNumber.toLowerCase() // Remove unnecessary plus and zeroes from scientific notation.
  6948. .replace(/^([+-]?[\d.]+e)(?:\+|(-))?0*(\d)/, "$1$2$3") // Remove unnecessary scientific notation (1e0).
  6949. .replace(/^([+-]?[\d.]+)e[+-]?0+$/, "$1") // Make sure numbers always start with a digit.
  6950. .replace(/^([+-])?\./, "$10.") // Remove extraneous trailing decimal zeroes.
  6951. .replace(/(\.\d+?)0+(?=e|$)/, "$1") // Remove trailing dot.
  6952. .replace(/\.(?=e|$)/, "");
  6953. }
  6954. function getMaxContinuousCount(str, target) {
  6955. var results = str.match(new RegExp("(".concat(escapeStringRegexp(target), ")+"), "g"));
  6956. if (results === null) {
  6957. return 0;
  6958. }
  6959. return results.reduce(function (maxCount, result) {
  6960. return Math.max(maxCount, result.length / target.length);
  6961. }, 0);
  6962. }
  6963. /**
  6964. * split text into whitespaces and words
  6965. * @param {string} text
  6966. * @return {Array<{ type: "whitespace", value: " " | "\n" | "" } | { type: "word", value: string }>}
  6967. */
  6968. function splitText(text, options) {
  6969. var KIND_NON_CJK = "non-cjk";
  6970. var KIND_CJK_CHARACTER = "cjk-character";
  6971. var KIND_CJK_PUNCTUATION = "cjk-punctuation";
  6972. var nodes = [];
  6973. (options.proseWrap === "preserve" ? text : text.replace(new RegExp("(".concat(cjkPattern, ")\n(").concat(cjkPattern, ")"), "g"), "$1$2")).split(/([ \t\n]+)/).forEach(function (token, index, tokens) {
  6974. // whitespace
  6975. if (index % 2 === 1) {
  6976. nodes.push({
  6977. type: "whitespace",
  6978. value: /\n/.test(token) ? "\n" : " "
  6979. });
  6980. return;
  6981. } // word separated by whitespace
  6982. if ((index === 0 || index === tokens.length - 1) && token === "") {
  6983. return;
  6984. }
  6985. token.split(new RegExp("(".concat(cjkPattern, ")"))).forEach(function (innerToken, innerIndex, innerTokens) {
  6986. if ((innerIndex === 0 || innerIndex === innerTokens.length - 1) && innerToken === "") {
  6987. return;
  6988. } // non-CJK word
  6989. if (innerIndex % 2 === 0) {
  6990. if (innerToken !== "") {
  6991. appendNode({
  6992. type: "word",
  6993. value: innerToken,
  6994. kind: KIND_NON_CJK,
  6995. hasLeadingPunctuation: punctuationRegex.test(innerToken[0]),
  6996. hasTrailingPunctuation: punctuationRegex.test(getLast$3(innerToken))
  6997. });
  6998. }
  6999. return;
  7000. } // CJK character
  7001. appendNode(punctuationRegex.test(innerToken) ? {
  7002. type: "word",
  7003. value: innerToken,
  7004. kind: KIND_CJK_PUNCTUATION,
  7005. hasLeadingPunctuation: true,
  7006. hasTrailingPunctuation: true
  7007. } : {
  7008. type: "word",
  7009. value: innerToken,
  7010. kind: KIND_CJK_CHARACTER,
  7011. hasLeadingPunctuation: false,
  7012. hasTrailingPunctuation: false
  7013. });
  7014. });
  7015. });
  7016. return nodes;
  7017. function appendNode(node) {
  7018. var lastNode = getLast$3(nodes);
  7019. if (lastNode && lastNode.type === "word") {
  7020. if (lastNode.kind === KIND_NON_CJK && node.kind === KIND_CJK_CHARACTER && !lastNode.hasTrailingPunctuation || lastNode.kind === KIND_CJK_CHARACTER && node.kind === KIND_NON_CJK && !node.hasLeadingPunctuation) {
  7021. nodes.push({
  7022. type: "whitespace",
  7023. value: " "
  7024. });
  7025. } else if (!isBetween(KIND_NON_CJK, KIND_CJK_PUNCTUATION) && // disallow leading/trailing full-width whitespace
  7026. ![lastNode.value, node.value].some(function (value) {
  7027. return /\u3000/.test(value);
  7028. })) {
  7029. nodes.push({
  7030. type: "whitespace",
  7031. value: ""
  7032. });
  7033. }
  7034. }
  7035. nodes.push(node);
  7036. function isBetween(kind1, kind2) {
  7037. return lastNode.kind === kind1 && node.kind === kind2 || lastNode.kind === kind2 && node.kind === kind1;
  7038. }
  7039. }
  7040. }
  7041. function getStringWidth(text) {
  7042. if (!text) {
  7043. return 0;
  7044. } // emojis are considered 2-char width for consistency
  7045. // see https://github.com/sindresorhus/string-width/issues/11
  7046. // for the reason why not implemented in `string-width`
  7047. return stringWidth(text.replace(emojiRegex, " "));
  7048. }
  7049. function hasIgnoreComment(path) {
  7050. var node = path.getValue();
  7051. return hasNodeIgnoreComment(node);
  7052. }
  7053. function hasNodeIgnoreComment(node) {
  7054. return node && node.comments && node.comments.length > 0 && node.comments.some(function (comment) {
  7055. return comment.value.trim() === "prettier-ignore";
  7056. });
  7057. }
  7058. function addCommentHelper(node, comment) {
  7059. var comments = node.comments || (node.comments = []);
  7060. comments.push(comment);
  7061. comment.printed = false; // For some reason, TypeScript parses `// x` inside of JSXText as a comment
  7062. // We already "print" it via the raw text, we don't need to re-print it as a
  7063. // comment
  7064. if (node.type === "JSXText") {
  7065. comment.printed = true;
  7066. }
  7067. }
  7068. function addLeadingComment$1(node, comment) {
  7069. comment.leading = true;
  7070. comment.trailing = false;
  7071. addCommentHelper(node, comment);
  7072. }
  7073. function addDanglingComment$1(node, comment) {
  7074. comment.leading = false;
  7075. comment.trailing = false;
  7076. addCommentHelper(node, comment);
  7077. }
  7078. function addTrailingComment$1(node, comment) {
  7079. comment.leading = false;
  7080. comment.trailing = true;
  7081. addCommentHelper(node, comment);
  7082. }
  7083. var util = {
  7084. punctuationRegex: punctuationRegex,
  7085. punctuationCharRange: punctuationCharRange,
  7086. getStringWidth: getStringWidth,
  7087. splitText: splitText,
  7088. getMaxContinuousCount: getMaxContinuousCount,
  7089. getPrecedence: getPrecedence,
  7090. shouldFlatten: shouldFlatten,
  7091. isBitwiseOperator: isBitwiseOperator,
  7092. isExportDeclaration: isExportDeclaration,
  7093. getParentExportDeclaration: getParentExportDeclaration,
  7094. getPenultimate: getPenultimate,
  7095. getLast: getLast$3,
  7096. getNextNonSpaceNonCommentCharacterIndex: getNextNonSpaceNonCommentCharacterIndex,
  7097. getNextNonSpaceNonCommentCharacter: getNextNonSpaceNonCommentCharacter,
  7098. skipWhitespace: skipWhitespace,
  7099. skipSpaces: skipSpaces,
  7100. skipNewline: skipNewline$1,
  7101. isNextLineEmptyAfterIndex: isNextLineEmptyAfterIndex,
  7102. isNextLineEmpty: isNextLineEmpty,
  7103. isPreviousLineEmpty: isPreviousLineEmpty$1,
  7104. hasNewline: hasNewline$1,
  7105. hasNewlineInRange: hasNewlineInRange,
  7106. hasSpaces: hasSpaces,
  7107. setLocStart: setLocStart,
  7108. setLocEnd: setLocEnd,
  7109. startsWithNoLookaheadToken: startsWithNoLookaheadToken,
  7110. getAlignmentSize: getAlignmentSize,
  7111. getIndentSize: getIndentSize,
  7112. printString: printString,
  7113. printNumber: printNumber,
  7114. hasIgnoreComment: hasIgnoreComment,
  7115. hasNodeIgnoreComment: hasNodeIgnoreComment,
  7116. makeString: makeString,
  7117. addLeadingComment: addLeadingComment$1,
  7118. addDanglingComment: addDanglingComment$1,
  7119. addTrailingComment: addTrailingComment$1
  7120. };
  7121. var concat$2 = docBuilders.concat;
  7122. var fill$1 = docBuilders.fill;
  7123. var cursor$2 = docBuilders.cursor;
  7124. var MODE_BREAK = 1;
  7125. var MODE_FLAT = 2;
  7126. function rootIndent() {
  7127. return {
  7128. value: "",
  7129. length: 0,
  7130. queue: []
  7131. };
  7132. }
  7133. function makeIndent(ind, options) {
  7134. return generateInd(ind, {
  7135. type: "indent"
  7136. }, options);
  7137. }
  7138. function makeAlign(ind, n, options) {
  7139. return n === -Infinity ? ind.root || rootIndent() : n < 0 ? generateInd(ind, {
  7140. type: "dedent"
  7141. }, options) : !n ? ind : n.type === "root" ? Object.assign({}, ind, {
  7142. root: ind
  7143. }) : typeof n === "string" ? generateInd(ind, {
  7144. type: "stringAlign",
  7145. n: n
  7146. }, options) : generateInd(ind, {
  7147. type: "numberAlign",
  7148. n: n
  7149. }, options);
  7150. }
  7151. function generateInd(ind, newPart, options) {
  7152. var queue = newPart.type === "dedent" ? ind.queue.slice(0, -1) : ind.queue.concat(newPart);
  7153. var value = "";
  7154. var length = 0;
  7155. var lastTabs = 0;
  7156. var lastSpaces = 0;
  7157. var _iteratorNormalCompletion = true;
  7158. var _didIteratorError = false;
  7159. var _iteratorError = undefined;
  7160. try {
  7161. for (var _iterator = queue[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  7162. var part = _step.value;
  7163. switch (part.type) {
  7164. case "indent":
  7165. flush();
  7166. if (options.useTabs) {
  7167. addTabs(1);
  7168. } else {
  7169. addSpaces(options.tabWidth);
  7170. }
  7171. break;
  7172. case "stringAlign":
  7173. flush();
  7174. value += part.n;
  7175. length += part.n.length;
  7176. break;
  7177. case "numberAlign":
  7178. lastTabs += 1;
  7179. lastSpaces += part.n;
  7180. break;
  7181. /* istanbul ignore next */
  7182. default:
  7183. throw new Error("Unexpected type '".concat(part.type, "'"));
  7184. }
  7185. }
  7186. } catch (err) {
  7187. _didIteratorError = true;
  7188. _iteratorError = err;
  7189. } finally {
  7190. try {
  7191. if (!_iteratorNormalCompletion && _iterator.return != null) {
  7192. _iterator.return();
  7193. }
  7194. } finally {
  7195. if (_didIteratorError) {
  7196. throw _iteratorError;
  7197. }
  7198. }
  7199. }
  7200. flushSpaces();
  7201. return Object.assign({}, ind, {
  7202. value: value,
  7203. length: length,
  7204. queue: queue
  7205. });
  7206. function addTabs(count) {
  7207. value += "\t".repeat(count);
  7208. length += options.tabWidth * count;
  7209. }
  7210. function addSpaces(count) {
  7211. value += " ".repeat(count);
  7212. length += count;
  7213. }
  7214. function flush() {
  7215. if (options.useTabs) {
  7216. flushTabs();
  7217. } else {
  7218. flushSpaces();
  7219. }
  7220. }
  7221. function flushTabs() {
  7222. if (lastTabs > 0) {
  7223. addTabs(lastTabs);
  7224. }
  7225. resetLast();
  7226. }
  7227. function flushSpaces() {
  7228. if (lastSpaces > 0) {
  7229. addSpaces(lastSpaces);
  7230. }
  7231. resetLast();
  7232. }
  7233. function resetLast() {
  7234. lastTabs = 0;
  7235. lastSpaces = 0;
  7236. }
  7237. }
  7238. function fits(next, restCommands, width, options, mustBeFlat) {
  7239. var restIdx = restCommands.length;
  7240. var cmds = [next];
  7241. while (width >= 0) {
  7242. if (cmds.length === 0) {
  7243. if (restIdx === 0) {
  7244. return true;
  7245. }
  7246. cmds.push(restCommands[restIdx - 1]);
  7247. restIdx--;
  7248. continue;
  7249. }
  7250. var x = cmds.pop();
  7251. var ind = x[0];
  7252. var mode = x[1];
  7253. var doc = x[2];
  7254. if (typeof doc === "string") {
  7255. width -= util.getStringWidth(doc);
  7256. } else {
  7257. switch (doc.type) {
  7258. case "concat":
  7259. for (var i = doc.parts.length - 1; i >= 0; i--) {
  7260. cmds.push([ind, mode, doc.parts[i]]);
  7261. }
  7262. break;
  7263. case "indent":
  7264. cmds.push([makeIndent(ind, options), mode, doc.contents]);
  7265. break;
  7266. case "align":
  7267. cmds.push([makeAlign(ind, doc.n, options), mode, doc.contents]);
  7268. break;
  7269. case "group":
  7270. if (mustBeFlat && doc.break) {
  7271. return false;
  7272. }
  7273. cmds.push([ind, doc.break ? MODE_BREAK : mode, doc.contents]);
  7274. break;
  7275. case "fill":
  7276. for (var _i = doc.parts.length - 1; _i >= 0; _i--) {
  7277. cmds.push([ind, mode, doc.parts[_i]]);
  7278. }
  7279. break;
  7280. case "if-break":
  7281. if (mode === MODE_BREAK) {
  7282. if (doc.breakContents) {
  7283. cmds.push([ind, mode, doc.breakContents]);
  7284. }
  7285. }
  7286. if (mode === MODE_FLAT) {
  7287. if (doc.flatContents) {
  7288. cmds.push([ind, mode, doc.flatContents]);
  7289. }
  7290. }
  7291. break;
  7292. case "line":
  7293. switch (mode) {
  7294. // fallthrough
  7295. case MODE_FLAT:
  7296. if (!doc.hard) {
  7297. if (!doc.soft) {
  7298. width -= 1;
  7299. }
  7300. break;
  7301. }
  7302. return true;
  7303. case MODE_BREAK:
  7304. return true;
  7305. }
  7306. break;
  7307. }
  7308. }
  7309. }
  7310. return false;
  7311. }
  7312. function printDocToString(doc, options) {
  7313. var width = options.printWidth;
  7314. var newLine = options.newLine || "\n";
  7315. var pos = 0; // cmds is basically a stack. We've turned a recursive call into a
  7316. // while loop which is much faster. The while loop below adds new
  7317. // cmds to the array instead of recursively calling `print`.
  7318. var cmds = [[rootIndent(), MODE_BREAK, doc]];
  7319. var out = [];
  7320. var shouldRemeasure = false;
  7321. var lineSuffix = [];
  7322. while (cmds.length !== 0) {
  7323. var x = cmds.pop();
  7324. var ind = x[0];
  7325. var mode = x[1];
  7326. var _doc = x[2];
  7327. if (typeof _doc === "string") {
  7328. out.push(_doc);
  7329. pos += util.getStringWidth(_doc);
  7330. } else {
  7331. switch (_doc.type) {
  7332. case "cursor":
  7333. out.push(cursor$2.placeholder);
  7334. break;
  7335. case "concat":
  7336. for (var i = _doc.parts.length - 1; i >= 0; i--) {
  7337. cmds.push([ind, mode, _doc.parts[i]]);
  7338. }
  7339. break;
  7340. case "indent":
  7341. cmds.push([makeIndent(ind, options), mode, _doc.contents]);
  7342. break;
  7343. case "align":
  7344. cmds.push([makeAlign(ind, _doc.n, options), mode, _doc.contents]);
  7345. break;
  7346. case "group":
  7347. switch (mode) {
  7348. case MODE_FLAT:
  7349. if (!shouldRemeasure) {
  7350. cmds.push([ind, _doc.break ? MODE_BREAK : MODE_FLAT, _doc.contents]);
  7351. break;
  7352. }
  7353. // fallthrough
  7354. case MODE_BREAK:
  7355. {
  7356. shouldRemeasure = false;
  7357. var next = [ind, MODE_FLAT, _doc.contents];
  7358. var rem = width - pos;
  7359. if (!_doc.break && fits(next, cmds, rem, options)) {
  7360. cmds.push(next);
  7361. } else {
  7362. // Expanded states are a rare case where a document
  7363. // can manually provide multiple representations of
  7364. // itself. It provides an array of documents
  7365. // going from the least expanded (most flattened)
  7366. // representation first to the most expanded. If a
  7367. // group has these, we need to manually go through
  7368. // these states and find the first one that fits.
  7369. if (_doc.expandedStates) {
  7370. var mostExpanded = _doc.expandedStates[_doc.expandedStates.length - 1];
  7371. if (_doc.break) {
  7372. cmds.push([ind, MODE_BREAK, mostExpanded]);
  7373. break;
  7374. } else {
  7375. for (var _i2 = 1; _i2 < _doc.expandedStates.length + 1; _i2++) {
  7376. if (_i2 >= _doc.expandedStates.length) {
  7377. cmds.push([ind, MODE_BREAK, mostExpanded]);
  7378. break;
  7379. } else {
  7380. var state = _doc.expandedStates[_i2];
  7381. var cmd = [ind, MODE_FLAT, state];
  7382. if (fits(cmd, cmds, rem, options)) {
  7383. cmds.push(cmd);
  7384. break;
  7385. }
  7386. }
  7387. }
  7388. }
  7389. } else {
  7390. cmds.push([ind, MODE_BREAK, _doc.contents]);
  7391. }
  7392. }
  7393. break;
  7394. }
  7395. }
  7396. break;
  7397. // Fills each line with as much code as possible before moving to a new
  7398. // line with the same indentation.
  7399. //
  7400. // Expects doc.parts to be an array of alternating content and
  7401. // whitespace. The whitespace contains the linebreaks.
  7402. //
  7403. // For example:
  7404. // ["I", line, "love", line, "monkeys"]
  7405. // or
  7406. // [{ type: group, ... }, softline, { type: group, ... }]
  7407. //
  7408. // It uses this parts structure to handle three main layout cases:
  7409. // * The first two content items fit on the same line without
  7410. // breaking
  7411. // -> output the first content item and the whitespace "flat".
  7412. // * Only the first content item fits on the line without breaking
  7413. // -> output the first content item "flat" and the whitespace with
  7414. // "break".
  7415. // * Neither content item fits on the line without breaking
  7416. // -> output the first content item and the whitespace with "break".
  7417. case "fill":
  7418. {
  7419. var _rem = width - pos;
  7420. var parts = _doc.parts;
  7421. if (parts.length === 0) {
  7422. break;
  7423. }
  7424. var content = parts[0];
  7425. var contentFlatCmd = [ind, MODE_FLAT, content];
  7426. var contentBreakCmd = [ind, MODE_BREAK, content];
  7427. var contentFits = fits(contentFlatCmd, [], _rem, options, true);
  7428. if (parts.length === 1) {
  7429. if (contentFits) {
  7430. cmds.push(contentFlatCmd);
  7431. } else {
  7432. cmds.push(contentBreakCmd);
  7433. }
  7434. break;
  7435. }
  7436. var whitespace = parts[1];
  7437. var whitespaceFlatCmd = [ind, MODE_FLAT, whitespace];
  7438. var whitespaceBreakCmd = [ind, MODE_BREAK, whitespace];
  7439. if (parts.length === 2) {
  7440. if (contentFits) {
  7441. cmds.push(whitespaceFlatCmd);
  7442. cmds.push(contentFlatCmd);
  7443. } else {
  7444. cmds.push(whitespaceBreakCmd);
  7445. cmds.push(contentBreakCmd);
  7446. }
  7447. break;
  7448. } // At this point we've handled the first pair (context, separator)
  7449. // and will create a new fill doc for the rest of the content.
  7450. // Ideally we wouldn't mutate the array here but coping all the
  7451. // elements to a new array would make this algorithm quadratic,
  7452. // which is unusable for large arrays (e.g. large texts in JSX).
  7453. parts.splice(0, 2);
  7454. var remainingCmd = [ind, mode, fill$1(parts)];
  7455. var secondContent = parts[0];
  7456. var firstAndSecondContentFlatCmd = [ind, MODE_FLAT, concat$2([content, whitespace, secondContent])];
  7457. var firstAndSecondContentFits = fits(firstAndSecondContentFlatCmd, [], _rem, options, true);
  7458. if (firstAndSecondContentFits) {
  7459. cmds.push(remainingCmd);
  7460. cmds.push(whitespaceFlatCmd);
  7461. cmds.push(contentFlatCmd);
  7462. } else if (contentFits) {
  7463. cmds.push(remainingCmd);
  7464. cmds.push(whitespaceBreakCmd);
  7465. cmds.push(contentFlatCmd);
  7466. } else {
  7467. cmds.push(remainingCmd);
  7468. cmds.push(whitespaceBreakCmd);
  7469. cmds.push(contentBreakCmd);
  7470. }
  7471. break;
  7472. }
  7473. case "if-break":
  7474. if (mode === MODE_BREAK) {
  7475. if (_doc.breakContents) {
  7476. cmds.push([ind, mode, _doc.breakContents]);
  7477. }
  7478. }
  7479. if (mode === MODE_FLAT) {
  7480. if (_doc.flatContents) {
  7481. cmds.push([ind, mode, _doc.flatContents]);
  7482. }
  7483. }
  7484. break;
  7485. case "line-suffix":
  7486. lineSuffix.push([ind, mode, _doc.contents]);
  7487. break;
  7488. case "line-suffix-boundary":
  7489. if (lineSuffix.length > 0) {
  7490. cmds.push([ind, mode, {
  7491. type: "line",
  7492. hard: true
  7493. }]);
  7494. }
  7495. break;
  7496. case "line":
  7497. switch (mode) {
  7498. case MODE_FLAT:
  7499. if (!_doc.hard) {
  7500. if (!_doc.soft) {
  7501. out.push(" ");
  7502. pos += 1;
  7503. }
  7504. break;
  7505. } else {
  7506. // This line was forced into the output even if we
  7507. // were in flattened mode, so we need to tell the next
  7508. // group that no matter what, it needs to remeasure
  7509. // because the previous measurement didn't accurately
  7510. // capture the entire expression (this is necessary
  7511. // for nested groups)
  7512. shouldRemeasure = true;
  7513. }
  7514. // fallthrough
  7515. case MODE_BREAK:
  7516. if (lineSuffix.length) {
  7517. cmds.push([ind, mode, _doc]);
  7518. [].push.apply(cmds, lineSuffix.reverse());
  7519. lineSuffix = [];
  7520. break;
  7521. }
  7522. if (_doc.literal) {
  7523. if (ind.root) {
  7524. out.push(newLine, ind.root.value);
  7525. pos = ind.root.length;
  7526. } else {
  7527. out.push(newLine);
  7528. pos = 0;
  7529. }
  7530. } else {
  7531. if (out.length > 0) {
  7532. // Trim whitespace at the end of line
  7533. while (out.length > 0 && typeof out[out.length - 1] === "string" && out[out.length - 1].match(/^[^\S\n]*$/)) {
  7534. out.pop();
  7535. }
  7536. if (out.length && typeof out[out.length - 1] === "string") {
  7537. out[out.length - 1] = out[out.length - 1].replace(/[^\S\n]*$/, "");
  7538. }
  7539. }
  7540. out.push(newLine + ind.value);
  7541. pos = ind.length;
  7542. }
  7543. break;
  7544. }
  7545. break;
  7546. default:
  7547. }
  7548. }
  7549. }
  7550. var cursorPlaceholderIndex = out.indexOf(cursor$2.placeholder);
  7551. if (cursorPlaceholderIndex !== -1) {
  7552. var otherCursorPlaceholderIndex = out.indexOf(cursor$2.placeholder, cursorPlaceholderIndex + 1);
  7553. var beforeCursor = out.slice(0, cursorPlaceholderIndex).join("");
  7554. var aroundCursor = out.slice(cursorPlaceholderIndex + 1, otherCursorPlaceholderIndex).join("");
  7555. var afterCursor = out.slice(otherCursorPlaceholderIndex + 1).join("");
  7556. return {
  7557. formatted: beforeCursor + aroundCursor + afterCursor,
  7558. cursorNodeStart: beforeCursor.length,
  7559. cursorNodeText: aroundCursor
  7560. };
  7561. }
  7562. return {
  7563. formatted: out.join("")
  7564. };
  7565. }
  7566. var docPrinter = {
  7567. printDocToString: printDocToString
  7568. };
  7569. function traverseDoc(doc, onEnter, onExit, shouldTraverseConditionalGroups) {
  7570. function traverseDocRec(doc) {
  7571. var shouldRecurse = true;
  7572. if (onEnter) {
  7573. if (onEnter(doc) === false) {
  7574. shouldRecurse = false;
  7575. }
  7576. }
  7577. if (shouldRecurse) {
  7578. if (doc.type === "concat" || doc.type === "fill") {
  7579. for (var i = 0; i < doc.parts.length; i++) {
  7580. traverseDocRec(doc.parts[i]);
  7581. }
  7582. } else if (doc.type === "if-break") {
  7583. if (doc.breakContents) {
  7584. traverseDocRec(doc.breakContents);
  7585. }
  7586. if (doc.flatContents) {
  7587. traverseDocRec(doc.flatContents);
  7588. }
  7589. } else if (doc.type === "group" && doc.expandedStates) {
  7590. if (shouldTraverseConditionalGroups) {
  7591. doc.expandedStates.forEach(traverseDocRec);
  7592. } else {
  7593. traverseDocRec(doc.contents);
  7594. }
  7595. } else if (doc.contents) {
  7596. traverseDocRec(doc.contents);
  7597. }
  7598. }
  7599. if (onExit) {
  7600. onExit(doc);
  7601. }
  7602. }
  7603. traverseDocRec(doc);
  7604. }
  7605. function mapDoc(doc, cb) {
  7606. if (doc.type === "concat" || doc.type === "fill") {
  7607. var parts = doc.parts.map(function (part) {
  7608. return mapDoc(part, cb);
  7609. });
  7610. return cb(Object.assign({}, doc, {
  7611. parts: parts
  7612. }));
  7613. } else if (doc.type === "if-break") {
  7614. var breakContents = doc.breakContents && mapDoc(doc.breakContents, cb);
  7615. var flatContents = doc.flatContents && mapDoc(doc.flatContents, cb);
  7616. return cb(Object.assign({}, doc, {
  7617. breakContents: breakContents,
  7618. flatContents: flatContents
  7619. }));
  7620. } else if (doc.contents) {
  7621. var contents = mapDoc(doc.contents, cb);
  7622. return cb(Object.assign({}, doc, {
  7623. contents: contents
  7624. }));
  7625. }
  7626. return cb(doc);
  7627. }
  7628. function findInDoc(doc, fn, defaultValue) {
  7629. var result = defaultValue;
  7630. var hasStopped = false;
  7631. traverseDoc(doc, function (doc) {
  7632. var maybeResult = fn(doc);
  7633. if (maybeResult !== undefined) {
  7634. hasStopped = true;
  7635. result = maybeResult;
  7636. }
  7637. if (hasStopped) {
  7638. return false;
  7639. }
  7640. });
  7641. return result;
  7642. }
  7643. function isEmpty(n) {
  7644. return typeof n === "string" && n.length === 0;
  7645. }
  7646. function isLineNext(doc) {
  7647. return findInDoc(doc, function (doc) {
  7648. if (typeof doc === "string") {
  7649. return false;
  7650. }
  7651. if (doc.type === "line") {
  7652. return true;
  7653. }
  7654. }, false);
  7655. }
  7656. function willBreak(doc) {
  7657. return findInDoc(doc, function (doc) {
  7658. if (doc.type === "group" && doc.break) {
  7659. return true;
  7660. }
  7661. if (doc.type === "line" && doc.hard) {
  7662. return true;
  7663. }
  7664. if (doc.type === "break-parent") {
  7665. return true;
  7666. }
  7667. }, false);
  7668. }
  7669. function breakParentGroup(groupStack) {
  7670. if (groupStack.length > 0) {
  7671. var parentGroup = groupStack[groupStack.length - 1]; // Breaks are not propagated through conditional groups because
  7672. // the user is expected to manually handle what breaks.
  7673. if (!parentGroup.expandedStates) {
  7674. parentGroup.break = true;
  7675. }
  7676. }
  7677. return null;
  7678. }
  7679. function propagateBreaks(doc) {
  7680. var alreadyVisited = new Map();
  7681. var groupStack = [];
  7682. traverseDoc(doc, function (doc) {
  7683. if (doc.type === "break-parent") {
  7684. breakParentGroup(groupStack);
  7685. }
  7686. if (doc.type === "group") {
  7687. groupStack.push(doc);
  7688. if (alreadyVisited.has(doc)) {
  7689. return false;
  7690. }
  7691. alreadyVisited.set(doc, true);
  7692. }
  7693. }, function (doc) {
  7694. if (doc.type === "group") {
  7695. var group = groupStack.pop();
  7696. if (group.break) {
  7697. breakParentGroup(groupStack);
  7698. }
  7699. }
  7700. },
  7701. /* shouldTraverseConditionalGroups */
  7702. true);
  7703. }
  7704. function removeLines(doc) {
  7705. // Force this doc into flat mode by statically converting all
  7706. // lines into spaces (or soft lines into nothing). Hard lines
  7707. // should still output because there's too great of a chance
  7708. // of breaking existing assumptions otherwise.
  7709. return mapDoc(doc, function (d) {
  7710. if (d.type === "line" && !d.hard) {
  7711. return d.soft ? "" : " ";
  7712. } else if (d.type === "if-break") {
  7713. return d.flatContents || "";
  7714. }
  7715. return d;
  7716. });
  7717. }
  7718. function stripTrailingHardline(doc) {
  7719. // HACK remove ending hardline, original PR: #1984
  7720. if (doc.type === "concat" && doc.parts.length === 2 && doc.parts[1].type === "concat" && doc.parts[1].parts.length === 2 && doc.parts[1].parts[0].hard && doc.parts[1].parts[1].type === "break-parent") {
  7721. return doc.parts[0];
  7722. }
  7723. return doc;
  7724. }
  7725. var docUtils = {
  7726. isEmpty: isEmpty,
  7727. willBreak: willBreak,
  7728. isLineNext: isLineNext,
  7729. traverseDoc: traverseDoc,
  7730. mapDoc: mapDoc,
  7731. propagateBreaks: propagateBreaks,
  7732. removeLines: removeLines,
  7733. stripTrailingHardline: stripTrailingHardline
  7734. };
  7735. function flattenDoc(doc) {
  7736. if (doc.type === "concat") {
  7737. var res = [];
  7738. for (var i = 0; i < doc.parts.length; ++i) {
  7739. var doc2 = doc.parts[i];
  7740. if (typeof doc2 !== "string" && doc2.type === "concat") {
  7741. [].push.apply(res, flattenDoc(doc2).parts);
  7742. } else {
  7743. var flattened = flattenDoc(doc2);
  7744. if (flattened !== "") {
  7745. res.push(flattened);
  7746. }
  7747. }
  7748. }
  7749. return Object.assign({}, doc, {
  7750. parts: res
  7751. });
  7752. } else if (doc.type === "if-break") {
  7753. return Object.assign({}, doc, {
  7754. breakContents: doc.breakContents != null ? flattenDoc(doc.breakContents) : null,
  7755. flatContents: doc.flatContents != null ? flattenDoc(doc.flatContents) : null
  7756. });
  7757. } else if (doc.type === "group") {
  7758. return Object.assign({}, doc, {
  7759. contents: flattenDoc(doc.contents),
  7760. expandedStates: doc.expandedStates ? doc.expandedStates.map(flattenDoc) : doc.expandedStates
  7761. });
  7762. } else if (doc.contents) {
  7763. return Object.assign({}, doc, {
  7764. contents: flattenDoc(doc.contents)
  7765. });
  7766. }
  7767. return doc;
  7768. }
  7769. function printDoc(doc) {
  7770. if (typeof doc === "string") {
  7771. return JSON.stringify(doc);
  7772. }
  7773. if (doc.type === "line") {
  7774. if (doc.literalline) {
  7775. return "literalline";
  7776. }
  7777. if (doc.hard) {
  7778. return "hardline";
  7779. }
  7780. if (doc.soft) {
  7781. return "softline";
  7782. }
  7783. return "line";
  7784. }
  7785. if (doc.type === "break-parent") {
  7786. return "breakParent";
  7787. }
  7788. if (doc.type === "concat") {
  7789. return "[" + doc.parts.map(printDoc).join(", ") + "]";
  7790. }
  7791. if (doc.type === "indent") {
  7792. return "indent(" + printDoc(doc.contents) + ")";
  7793. }
  7794. if (doc.type === "align") {
  7795. return doc.n === -Infinity ? "dedentToRoot(" + printDoc(doc.contents) + ")" : doc.n < 0 ? "dedent(" + printDoc(doc.contents) + ")" : doc.n.type === "root" ? "markAsRoot(" + printDoc(doc.contents) + ")" : "align(" + JSON.stringify(doc.n) + ", " + printDoc(doc.contents) + ")";
  7796. }
  7797. if (doc.type === "if-break") {
  7798. return "ifBreak(" + printDoc(doc.breakContents) + (doc.flatContents ? ", " + printDoc(doc.flatContents) : "") + ")";
  7799. }
  7800. if (doc.type === "group") {
  7801. if (doc.expandedStates) {
  7802. return "conditionalGroup(" + "[" + doc.expandedStates.map(printDoc).join(",") + "])";
  7803. }
  7804. return (doc.break ? "wrappedGroup" : "group") + "(" + printDoc(doc.contents) + ")";
  7805. }
  7806. if (doc.type === "fill") {
  7807. return "fill" + "(" + doc.parts.map(printDoc).join(", ") + ")";
  7808. }
  7809. if (doc.type === "line-suffix") {
  7810. return "lineSuffix(" + printDoc(doc.contents) + ")";
  7811. }
  7812. if (doc.type === "line-suffix-boundary") {
  7813. return "lineSuffixBoundary";
  7814. }
  7815. throw new Error("Unknown doc type " + doc.type);
  7816. }
  7817. var docDebug = {
  7818. printDocToDebug: function printDocToDebug(doc) {
  7819. return printDoc(flattenDoc(doc));
  7820. }
  7821. };
  7822. var doc = {
  7823. builders: docBuilders,
  7824. printer: docPrinter,
  7825. utils: docUtils,
  7826. debug: docDebug
  7827. };
  7828. var mapDoc$1 = doc.utils.mapDoc;
  7829. function isNextLineEmpty$1(text, node, options) {
  7830. return util.isNextLineEmpty(text, node, options.locEnd);
  7831. }
  7832. function getNextNonSpaceNonCommentCharacterIndex$1(text, node, options) {
  7833. return util.getNextNonSpaceNonCommentCharacterIndex(text, node, options.locEnd);
  7834. }
  7835. var utilShared = {
  7836. isNextLineEmpty: isNextLineEmpty$1,
  7837. isNextLineEmptyAfterIndex: util.isNextLineEmptyAfterIndex,
  7838. getNextNonSpaceNonCommentCharacterIndex: getNextNonSpaceNonCommentCharacterIndex$1,
  7839. mapDoc: mapDoc$1,
  7840. // TODO: remove in 2.0, we already exposed it in docUtils
  7841. makeString: util.makeString,
  7842. addLeadingComment: util.addLeadingComment,
  7843. addDanglingComment: util.addDanglingComment,
  7844. addTrailingComment: util.addTrailingComment
  7845. };
  7846. var _require$$0$builders = doc.builders;
  7847. var concat = _require$$0$builders.concat;
  7848. var hardline = _require$$0$builders.hardline;
  7849. var breakParent = _require$$0$builders.breakParent;
  7850. var indent = _require$$0$builders.indent;
  7851. var lineSuffix = _require$$0$builders.lineSuffix;
  7852. var join = _require$$0$builders.join;
  7853. var cursor = _require$$0$builders.cursor;
  7854. var hasNewline = util.hasNewline;
  7855. var skipNewline = util.skipNewline;
  7856. var isPreviousLineEmpty = util.isPreviousLineEmpty;
  7857. var addLeadingComment = utilShared.addLeadingComment;
  7858. var addDanglingComment = utilShared.addDanglingComment;
  7859. var addTrailingComment = utilShared.addTrailingComment;
  7860. var childNodesCacheKey = Symbol("child-nodes");
  7861. function getSortedChildNodes(node, options, resultArray) {
  7862. if (!node) {
  7863. return;
  7864. }
  7865. var printer = options.printer;
  7866. var locStart = options.locStart;
  7867. var locEnd = options.locEnd;
  7868. if (resultArray) {
  7869. if (node && printer.canAttachComment && printer.canAttachComment(node)) {
  7870. // This reverse insertion sort almost always takes constant
  7871. // time because we almost always (maybe always?) append the
  7872. // nodes in order anyway.
  7873. var i;
  7874. for (i = resultArray.length - 1; i >= 0; --i) {
  7875. if (locStart(resultArray[i]) <= locStart(node) && locEnd(resultArray[i]) <= locEnd(node)) {
  7876. break;
  7877. }
  7878. }
  7879. resultArray.splice(i + 1, 0, node);
  7880. return;
  7881. }
  7882. } else if (node[childNodesCacheKey]) {
  7883. return node[childNodesCacheKey];
  7884. }
  7885. var childNodes;
  7886. if (printer.getCommentChildNodes) {
  7887. childNodes = printer.getCommentChildNodes(node);
  7888. } else if (node && _typeof(node) === "object") {
  7889. childNodes = Object.keys(node).filter(function (n) {
  7890. return n !== "enclosingNode" && n !== "precedingNode" && n !== "followingNode";
  7891. }).map(function (n) {
  7892. return node[n];
  7893. });
  7894. }
  7895. if (!childNodes) {
  7896. return;
  7897. }
  7898. if (!resultArray) {
  7899. Object.defineProperty(node, childNodesCacheKey, {
  7900. value: resultArray = [],
  7901. enumerable: false
  7902. });
  7903. }
  7904. childNodes.forEach(function (childNode) {
  7905. getSortedChildNodes(childNode, options, resultArray);
  7906. });
  7907. return resultArray;
  7908. } // As efficiently as possible, decorate the comment object with
  7909. // .precedingNode, .enclosingNode, and/or .followingNode properties, at
  7910. // least one of which is guaranteed to be defined.
  7911. function decorateComment(node, comment, options) {
  7912. var locStart = options.locStart;
  7913. var locEnd = options.locEnd;
  7914. var childNodes = getSortedChildNodes(node, options);
  7915. var precedingNode;
  7916. var followingNode; // Time to dust off the old binary search robes and wizard hat.
  7917. var left = 0;
  7918. var right = childNodes.length;
  7919. while (left < right) {
  7920. var middle = left + right >> 1;
  7921. var child = childNodes[middle];
  7922. if (locStart(child) - locStart(comment) <= 0 && locEnd(comment) - locEnd(child) <= 0) {
  7923. // The comment is completely contained by this child node.
  7924. comment.enclosingNode = child;
  7925. decorateComment(child, comment, options);
  7926. return; // Abandon the binary search at this level.
  7927. }
  7928. if (locEnd(child) - locStart(comment) <= 0) {
  7929. // This child node falls completely before the comment.
  7930. // Because we will never consider this node or any nodes
  7931. // before it again, this node must be the closest preceding
  7932. // node we have encountered so far.
  7933. precedingNode = child;
  7934. left = middle + 1;
  7935. continue;
  7936. }
  7937. if (locEnd(comment) - locStart(child) <= 0) {
  7938. // This child node falls completely after the comment.
  7939. // Because we will never consider this node or any nodes after
  7940. // it again, this node must be the closest following node we
  7941. // have encountered so far.
  7942. followingNode = child;
  7943. right = middle;
  7944. continue;
  7945. }
  7946. /* istanbul ignore next */
  7947. throw new Error("Comment location overlaps with node location");
  7948. } // We don't want comments inside of different expressions inside of the same
  7949. // template literal to move to another expression.
  7950. if (comment.enclosingNode && comment.enclosingNode.type === "TemplateLiteral") {
  7951. var quasis = comment.enclosingNode.quasis;
  7952. var commentIndex = findExpressionIndexForComment(quasis, comment, options);
  7953. if (precedingNode && findExpressionIndexForComment(quasis, precedingNode, options) !== commentIndex) {
  7954. precedingNode = null;
  7955. }
  7956. if (followingNode && findExpressionIndexForComment(quasis, followingNode, options) !== commentIndex) {
  7957. followingNode = null;
  7958. }
  7959. }
  7960. if (precedingNode) {
  7961. comment.precedingNode = precedingNode;
  7962. }
  7963. if (followingNode) {
  7964. comment.followingNode = followingNode;
  7965. }
  7966. }
  7967. function attach(comments, ast, text, options) {
  7968. if (!Array.isArray(comments)) {
  7969. return;
  7970. }
  7971. var tiesToBreak = [];
  7972. var locStart = options.locStart;
  7973. var locEnd = options.locEnd;
  7974. comments.forEach(function (comment, i) {
  7975. if ((options.parser === "json" || options.parser === "json5") && locStart(comment) - locStart(ast) <= 0) {
  7976. addLeadingComment(ast, comment);
  7977. return;
  7978. }
  7979. decorateComment(ast, comment, options);
  7980. var precedingNode = comment.precedingNode;
  7981. var enclosingNode = comment.enclosingNode;
  7982. var followingNode = comment.followingNode;
  7983. var pluginHandleOwnLineComment = options.printer.handleComments && options.printer.handleComments.ownLine ? options.printer.handleComments.ownLine : function () {
  7984. return false;
  7985. };
  7986. var pluginHandleEndOfLineComment = options.printer.handleComments && options.printer.handleComments.endOfLine ? options.printer.handleComments.endOfLine : function () {
  7987. return false;
  7988. };
  7989. var pluginHandleRemainingComment = options.printer.handleComments && options.printer.handleComments.remaining ? options.printer.handleComments.remaining : function () {
  7990. return false;
  7991. };
  7992. var isLastComment = comments.length - 1 === i;
  7993. if (hasNewline(text, locStart(comment), {
  7994. backwards: true
  7995. })) {
  7996. // If a comment exists on its own line, prefer a leading comment.
  7997. // We also need to check if it's the first line of the file.
  7998. if (pluginHandleOwnLineComment(comment, text, options, ast, isLastComment)) {// We're good
  7999. } else if (followingNode) {
  8000. // Always a leading comment.
  8001. addLeadingComment(followingNode, comment);
  8002. } else if (precedingNode) {
  8003. addTrailingComment(precedingNode, comment);
  8004. } else if (enclosingNode) {
  8005. addDanglingComment(enclosingNode, comment);
  8006. } else {
  8007. // There are no nodes, let's attach it to the root of the ast
  8008. /* istanbul ignore next */
  8009. addDanglingComment(ast, comment);
  8010. }
  8011. } else if (hasNewline(text, locEnd(comment))) {
  8012. if (pluginHandleEndOfLineComment(comment, text, options, ast, isLastComment)) {// We're good
  8013. } else if (precedingNode) {
  8014. // There is content before this comment on the same line, but
  8015. // none after it, so prefer a trailing comment of the previous node.
  8016. addTrailingComment(precedingNode, comment);
  8017. } else if (followingNode) {
  8018. addLeadingComment(followingNode, comment);
  8019. } else if (enclosingNode) {
  8020. addDanglingComment(enclosingNode, comment);
  8021. } else {
  8022. // There are no nodes, let's attach it to the root of the ast
  8023. /* istanbul ignore next */
  8024. addDanglingComment(ast, comment);
  8025. }
  8026. } else {
  8027. if (pluginHandleRemainingComment(comment, text, options, ast, isLastComment)) {// We're good
  8028. } else if (precedingNode && followingNode) {
  8029. // Otherwise, text exists both before and after the comment on
  8030. // the same line. If there is both a preceding and following
  8031. // node, use a tie-breaking algorithm to determine if it should
  8032. // be attached to the next or previous node. In the last case,
  8033. // simply attach the right node;
  8034. var tieCount = tiesToBreak.length;
  8035. if (tieCount > 0) {
  8036. var lastTie = tiesToBreak[tieCount - 1];
  8037. if (lastTie.followingNode !== comment.followingNode) {
  8038. breakTies(tiesToBreak, text, options);
  8039. }
  8040. }
  8041. tiesToBreak.push(comment);
  8042. } else if (precedingNode) {
  8043. addTrailingComment(precedingNode, comment);
  8044. } else if (followingNode) {
  8045. addLeadingComment(followingNode, comment);
  8046. } else if (enclosingNode) {
  8047. addDanglingComment(enclosingNode, comment);
  8048. } else {
  8049. // There are no nodes, let's attach it to the root of the ast
  8050. /* istanbul ignore next */
  8051. addDanglingComment(ast, comment);
  8052. }
  8053. }
  8054. });
  8055. breakTies(tiesToBreak, text, options);
  8056. comments.forEach(function (comment) {
  8057. // These node references were useful for breaking ties, but we
  8058. // don't need them anymore, and they create cycles in the AST that
  8059. // may lead to infinite recursion if we don't delete them here.
  8060. delete comment.precedingNode;
  8061. delete comment.enclosingNode;
  8062. delete comment.followingNode;
  8063. });
  8064. }
  8065. function breakTies(tiesToBreak, text, options) {
  8066. var tieCount = tiesToBreak.length;
  8067. if (tieCount === 0) {
  8068. return;
  8069. }
  8070. var precedingNode = tiesToBreak[0].precedingNode;
  8071. var followingNode = tiesToBreak[0].followingNode;
  8072. var gapEndPos = options.locStart(followingNode); // Iterate backwards through tiesToBreak, examining the gaps
  8073. // between the tied comments. In order to qualify as leading, a
  8074. // comment must be separated from followingNode by an unbroken series of
  8075. // gaps (or other comments). Gaps should only contain whitespace or open
  8076. // parentheses.
  8077. var indexOfFirstLeadingComment;
  8078. for (indexOfFirstLeadingComment = tieCount; indexOfFirstLeadingComment > 0; --indexOfFirstLeadingComment) {
  8079. var comment = tiesToBreak[indexOfFirstLeadingComment - 1];
  8080. assert.strictEqual(comment.precedingNode, precedingNode);
  8081. assert.strictEqual(comment.followingNode, followingNode);
  8082. var gap = text.slice(options.locEnd(comment), gapEndPos).trim();
  8083. if (gap === "" || /^\(+$/.test(gap)) {
  8084. gapEndPos = options.locStart(comment);
  8085. } else {
  8086. // The gap string contained something other than whitespace or open
  8087. // parentheses.
  8088. break;
  8089. }
  8090. }
  8091. tiesToBreak.forEach(function (comment, i) {
  8092. if (i < indexOfFirstLeadingComment) {
  8093. addTrailingComment(precedingNode, comment);
  8094. } else {
  8095. addLeadingComment(followingNode, comment);
  8096. }
  8097. });
  8098. tiesToBreak.length = 0;
  8099. }
  8100. function printComment(commentPath, options) {
  8101. var comment = commentPath.getValue();
  8102. comment.printed = true;
  8103. return options.printer.printComment(commentPath, options);
  8104. }
  8105. function findExpressionIndexForComment(quasis, comment, options) {
  8106. var startPos = options.locStart(comment) - 1;
  8107. for (var i = 1; i < quasis.length; ++i) {
  8108. if (startPos < getQuasiRange(quasis[i]).start) {
  8109. return i - 1;
  8110. }
  8111. } // We haven't found it, it probably means that some of the locations are off.
  8112. // Let's just return the first one.
  8113. /* istanbul ignore next */
  8114. return 0;
  8115. }
  8116. function getQuasiRange(expr) {
  8117. if (expr.start !== undefined) {
  8118. // Babylon
  8119. return {
  8120. start: expr.start,
  8121. end: expr.end
  8122. };
  8123. } // Flow
  8124. return {
  8125. start: expr.range[0],
  8126. end: expr.range[1]
  8127. };
  8128. }
  8129. function printLeadingComment(commentPath, print, options) {
  8130. var comment = commentPath.getValue();
  8131. var contents = printComment(commentPath, options);
  8132. if (!contents) {
  8133. return "";
  8134. }
  8135. var isBlock = options.printer.isBlockComment && options.printer.isBlockComment(comment); // Leading block comments should see if they need to stay on the
  8136. // same line or not.
  8137. if (isBlock) {
  8138. return concat([contents, hasNewline(options.originalText, options.locEnd(comment)) ? hardline : " "]);
  8139. }
  8140. return concat([contents, hardline]);
  8141. }
  8142. function printTrailingComment(commentPath, print, options) {
  8143. var comment = commentPath.getValue();
  8144. var contents = printComment(commentPath, options);
  8145. if (!contents) {
  8146. return "";
  8147. }
  8148. var isBlock = options.printer.isBlockComment && options.printer.isBlockComment(comment); // We don't want the line to break
  8149. // when the parentParentNode is a ClassDeclaration/-Expression
  8150. // And the parentNode is in the superClass property
  8151. var parentNode = commentPath.getNode(1);
  8152. var parentParentNode = commentPath.getNode(2);
  8153. var isParentSuperClass = parentParentNode && (parentParentNode.type === "ClassDeclaration" || parentParentNode.type === "ClassExpression") && parentParentNode.superClass === parentNode;
  8154. if (hasNewline(options.originalText, options.locStart(comment), {
  8155. backwards: true
  8156. })) {
  8157. // This allows comments at the end of nested structures:
  8158. // {
  8159. // x: 1,
  8160. // y: 2
  8161. // // A comment
  8162. // }
  8163. // Those kinds of comments are almost always leading comments, but
  8164. // here it doesn't go "outside" the block and turns it into a
  8165. // trailing comment for `2`. We can simulate the above by checking
  8166. // if this a comment on its own line; normal trailing comments are
  8167. // always at the end of another expression.
  8168. var isLineBeforeEmpty = isPreviousLineEmpty(options.originalText, comment, options.locStart);
  8169. return lineSuffix(concat([hardline, isLineBeforeEmpty ? hardline : "", contents]));
  8170. } else if (isBlock || isParentSuperClass) {
  8171. // Trailing block comments never need a newline
  8172. return concat([" ", contents]);
  8173. }
  8174. return concat([lineSuffix(" " + contents), !isBlock ? breakParent : ""]);
  8175. }
  8176. function printDanglingComments(path, options, sameIndent, filter) {
  8177. var parts = [];
  8178. var node = path.getValue();
  8179. if (!node || !node.comments) {
  8180. return "";
  8181. }
  8182. path.each(function (commentPath) {
  8183. var comment = commentPath.getValue();
  8184. if (comment && !comment.leading && !comment.trailing && (!filter || filter(comment))) {
  8185. parts.push(printComment(commentPath, options));
  8186. }
  8187. }, "comments");
  8188. if (parts.length === 0) {
  8189. return "";
  8190. }
  8191. if (sameIndent) {
  8192. return join(hardline, parts);
  8193. }
  8194. return indent(concat([hardline, join(hardline, parts)]));
  8195. }
  8196. function prependCursorPlaceholder(path, options, printed) {
  8197. if (path.getNode() === options.cursorNode && path.getValue()) {
  8198. return concat([cursor, printed, cursor]);
  8199. }
  8200. return printed;
  8201. }
  8202. function printComments(path, print, options, needsSemi) {
  8203. var value = path.getValue();
  8204. var printed = print(path);
  8205. var comments = value && value.comments;
  8206. if (!comments || comments.length === 0) {
  8207. return prependCursorPlaceholder(path, options, printed);
  8208. }
  8209. var leadingParts = [];
  8210. var trailingParts = [needsSemi ? ";" : "", printed];
  8211. path.each(function (commentPath) {
  8212. var comment = commentPath.getValue();
  8213. var leading = comment.leading;
  8214. var trailing = comment.trailing;
  8215. if (leading) {
  8216. var contents = printLeadingComment(commentPath, print, options);
  8217. if (!contents) {
  8218. return;
  8219. }
  8220. leadingParts.push(contents);
  8221. var text = options.originalText;
  8222. if (hasNewline(text, skipNewline(text, options.locEnd(comment)))) {
  8223. leadingParts.push(hardline);
  8224. }
  8225. } else if (trailing) {
  8226. trailingParts.push(printTrailingComment(commentPath, print, options));
  8227. }
  8228. }, "comments");
  8229. return prependCursorPlaceholder(path, options, concat(leadingParts.concat(trailingParts)));
  8230. }
  8231. var comments = {
  8232. attach: attach,
  8233. printComments: printComments,
  8234. printDanglingComments: printDanglingComments,
  8235. getSortedChildNodes: getSortedChildNodes
  8236. };
  8237. function FastPath(value) {
  8238. assert.ok(this instanceof FastPath);
  8239. this.stack = [value];
  8240. } // The name of the current property is always the penultimate element of
  8241. // this.stack, and always a String.
  8242. FastPath.prototype.getName = function getName() {
  8243. var s = this.stack;
  8244. var len = s.length;
  8245. if (len > 1) {
  8246. return s[len - 2];
  8247. } // Since the name is always a string, null is a safe sentinel value to
  8248. // return if we do not know the name of the (root) value.
  8249. /* istanbul ignore next */
  8250. return null;
  8251. }; // The value of the current property is always the final element of
  8252. // this.stack.
  8253. FastPath.prototype.getValue = function getValue() {
  8254. var s = this.stack;
  8255. return s[s.length - 1];
  8256. };
  8257. function getNodeHelper(path, count) {
  8258. var s = path.stack;
  8259. for (var i = s.length - 1; i >= 0; i -= 2) {
  8260. var value = s[i];
  8261. if (value && !Array.isArray(value) && --count < 0) {
  8262. return value;
  8263. }
  8264. }
  8265. return null;
  8266. }
  8267. FastPath.prototype.getNode = function getNode(count) {
  8268. return getNodeHelper(this, ~~count);
  8269. };
  8270. FastPath.prototype.getParentNode = function getParentNode(count) {
  8271. return getNodeHelper(this, ~~count + 1);
  8272. }; // Temporarily push properties named by string arguments given after the
  8273. // callback function onto this.stack, then call the callback with a
  8274. // reference to this (modified) FastPath object. Note that the stack will
  8275. // be restored to its original state after the callback is finished, so it
  8276. // is probably a mistake to retain a reference to the path.
  8277. FastPath.prototype.call = function call(callback
  8278. /*, name1, name2, ... */
  8279. ) {
  8280. var s = this.stack;
  8281. var origLen = s.length;
  8282. var value = s[origLen - 1];
  8283. var argc = arguments.length;
  8284. for (var i = 1; i < argc; ++i) {
  8285. var name = arguments[i];
  8286. value = value[name];
  8287. s.push(name, value);
  8288. }
  8289. var result = callback(this);
  8290. s.length = origLen;
  8291. return result;
  8292. }; // Similar to FastPath.prototype.call, except that the value obtained by
  8293. // accessing this.getValue()[name1][name2]... should be array-like. The
  8294. // callback will be called with a reference to this path object for each
  8295. // element of the array.
  8296. FastPath.prototype.each = function each(callback
  8297. /*, name1, name2, ... */
  8298. ) {
  8299. var s = this.stack;
  8300. var origLen = s.length;
  8301. var value = s[origLen - 1];
  8302. var argc = arguments.length;
  8303. for (var i = 1; i < argc; ++i) {
  8304. var name = arguments[i];
  8305. value = value[name];
  8306. s.push(name, value);
  8307. }
  8308. for (var _i = 0; _i < value.length; ++_i) {
  8309. if (_i in value) {
  8310. s.push(_i, value[_i]); // If the callback needs to know the value of i, call
  8311. // path.getName(), assuming path is the parameter name.
  8312. callback(this);
  8313. s.length -= 2;
  8314. }
  8315. }
  8316. s.length = origLen;
  8317. }; // Similar to FastPath.prototype.each, except that the results of the
  8318. // callback function invocations are stored in an array and returned at
  8319. // the end of the iteration.
  8320. FastPath.prototype.map = function map(callback
  8321. /*, name1, name2, ... */
  8322. ) {
  8323. var s = this.stack;
  8324. var origLen = s.length;
  8325. var value = s[origLen - 1];
  8326. var argc = arguments.length;
  8327. for (var i = 1; i < argc; ++i) {
  8328. var name = arguments[i];
  8329. value = value[name];
  8330. s.push(name, value);
  8331. }
  8332. var result = new Array(value.length);
  8333. for (var _i2 = 0; _i2 < value.length; ++_i2) {
  8334. if (_i2 in value) {
  8335. s.push(_i2, value[_i2]);
  8336. result[_i2] = callback(this, _i2);
  8337. s.length -= 2;
  8338. }
  8339. }
  8340. s.length = origLen;
  8341. return result;
  8342. };
  8343. var fastPath = FastPath;
  8344. var normalize$1 = options.normalize;
  8345. function printSubtree(path, print, options$$1, printAstToDoc) {
  8346. if (options$$1.printer.embed) {
  8347. return options$$1.printer.embed(path, print, function (text, partialNextOptions) {
  8348. return textToDoc(text, partialNextOptions, options$$1, printAstToDoc);
  8349. }, options$$1);
  8350. }
  8351. }
  8352. function textToDoc(text, partialNextOptions, parentOptions, printAstToDoc) {
  8353. var nextOptions = normalize$1(Object.assign({}, parentOptions, partialNextOptions, {
  8354. parentParser: parentOptions.parser,
  8355. originalText: text
  8356. }), {
  8357. passThrough: true
  8358. });
  8359. var result = parser.parse(text, nextOptions);
  8360. var ast = result.ast;
  8361. text = result.text;
  8362. var astComments = ast.comments;
  8363. delete ast.comments;
  8364. comments.attach(astComments, ast, text, nextOptions);
  8365. return printAstToDoc(ast, nextOptions);
  8366. }
  8367. var multiparser = {
  8368. printSubtree: printSubtree
  8369. };
  8370. var doc$2 = doc;
  8371. var docBuilders$2 = doc$2.builders;
  8372. var concat$3 = docBuilders$2.concat;
  8373. var hardline$2 = docBuilders$2.hardline;
  8374. var addAlignmentToDoc$1 = docBuilders$2.addAlignmentToDoc;
  8375. var docUtils$2 = doc$2.utils;
  8376. function printAstToDoc(ast, options, addAlignmentSize) {
  8377. addAlignmentSize = addAlignmentSize || 0;
  8378. var printer = options.printer;
  8379. var cache = new Map();
  8380. function printGenerically(path, args) {
  8381. var node = path.getValue();
  8382. var shouldCache = node && _typeof(node) === "object" && args === undefined;
  8383. if (shouldCache && cache.has(node)) {
  8384. return cache.get(node);
  8385. } // We let JSXElement print its comments itself because it adds () around
  8386. // UnionTypeAnnotation has to align the child without the comments
  8387. var res;
  8388. if (printer.willPrintOwnComments && printer.willPrintOwnComments(path)) {
  8389. res = genericPrint(path, options, printGenerically, args);
  8390. } else {
  8391. res = comments.printComments(path, function (p) {
  8392. return genericPrint(p, options, printGenerically, args);
  8393. }, options, args && args.needsSemi);
  8394. }
  8395. if (shouldCache) {
  8396. cache.set(node, res);
  8397. }
  8398. return res;
  8399. }
  8400. var doc$$2 = printGenerically(new fastPath(ast));
  8401. if (addAlignmentSize > 0) {
  8402. // Add a hardline to make the indents take effect
  8403. // It should be removed in index.js format()
  8404. doc$$2 = addAlignmentToDoc$1(docUtils$2.removeLines(concat$3([hardline$2, doc$$2])), addAlignmentSize, options.tabWidth);
  8405. }
  8406. docUtils$2.propagateBreaks(doc$$2);
  8407. if (options.parser === "json" || options.parser === "json5" || options.parser === "json-stringify") {
  8408. doc$$2 = concat$3([doc$$2, hardline$2]);
  8409. }
  8410. return doc$$2;
  8411. }
  8412. function genericPrint(path, options, printPath, args) {
  8413. assert.ok(path instanceof fastPath);
  8414. var node = path.getValue();
  8415. var printer = options.printer; // Escape hatch
  8416. if (printer.hasPrettierIgnore && printer.hasPrettierIgnore(path)) {
  8417. return options.originalText.slice(options.locStart(node), options.locEnd(node));
  8418. }
  8419. if (node) {
  8420. try {
  8421. // Potentially switch to a different parser
  8422. var sub = multiparser.printSubtree(path, printPath, options, printAstToDoc);
  8423. if (sub) {
  8424. return sub;
  8425. }
  8426. } catch (error) {
  8427. /* istanbul ignore if */
  8428. if (commonjsGlobal.PRETTIER_DEBUG) {
  8429. throw error;
  8430. } // Continue with current parser
  8431. }
  8432. }
  8433. return printer.print(path, options, printPath, args);
  8434. }
  8435. var astToDoc = printAstToDoc;
  8436. function findSiblingAncestors(startNodeAndParents, endNodeAndParents, opts) {
  8437. var resultStartNode = startNodeAndParents.node;
  8438. var resultEndNode = endNodeAndParents.node;
  8439. if (resultStartNode === resultEndNode) {
  8440. return {
  8441. startNode: resultStartNode,
  8442. endNode: resultEndNode
  8443. };
  8444. }
  8445. var _iteratorNormalCompletion = true;
  8446. var _didIteratorError = false;
  8447. var _iteratorError = undefined;
  8448. try {
  8449. for (var _iterator = endNodeAndParents.parentNodes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  8450. var endParent = _step.value;
  8451. if (endParent.type !== "Program" && endParent.type !== "File" && opts.locStart(endParent) >= opts.locStart(startNodeAndParents.node)) {
  8452. resultEndNode = endParent;
  8453. } else {
  8454. break;
  8455. }
  8456. }
  8457. } catch (err) {
  8458. _didIteratorError = true;
  8459. _iteratorError = err;
  8460. } finally {
  8461. try {
  8462. if (!_iteratorNormalCompletion && _iterator.return != null) {
  8463. _iterator.return();
  8464. }
  8465. } finally {
  8466. if (_didIteratorError) {
  8467. throw _iteratorError;
  8468. }
  8469. }
  8470. }
  8471. var _iteratorNormalCompletion2 = true;
  8472. var _didIteratorError2 = false;
  8473. var _iteratorError2 = undefined;
  8474. try {
  8475. for (var _iterator2 = startNodeAndParents.parentNodes[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
  8476. var startParent = _step2.value;
  8477. if (startParent.type !== "Program" && startParent.type !== "File" && opts.locEnd(startParent) <= opts.locEnd(endNodeAndParents.node)) {
  8478. resultStartNode = startParent;
  8479. } else {
  8480. break;
  8481. }
  8482. }
  8483. } catch (err) {
  8484. _didIteratorError2 = true;
  8485. _iteratorError2 = err;
  8486. } finally {
  8487. try {
  8488. if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
  8489. _iterator2.return();
  8490. }
  8491. } finally {
  8492. if (_didIteratorError2) {
  8493. throw _iteratorError2;
  8494. }
  8495. }
  8496. }
  8497. return {
  8498. startNode: resultStartNode,
  8499. endNode: resultEndNode
  8500. };
  8501. }
  8502. function findNodeAtOffset(node, offset, options, predicate, parentNodes) {
  8503. predicate = predicate || function () {
  8504. return true;
  8505. };
  8506. parentNodes = parentNodes || [];
  8507. var start = options.locStart(node, options.locStart);
  8508. var end = options.locEnd(node, options.locEnd);
  8509. if (start <= offset && offset <= end) {
  8510. var _iteratorNormalCompletion3 = true;
  8511. var _didIteratorError3 = false;
  8512. var _iteratorError3 = undefined;
  8513. try {
  8514. for (var _iterator3 = comments.getSortedChildNodes(node, options)[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
  8515. var childNode = _step3.value;
  8516. var childResult = findNodeAtOffset(childNode, offset, options, predicate, [node].concat(parentNodes));
  8517. if (childResult) {
  8518. return childResult;
  8519. }
  8520. }
  8521. } catch (err) {
  8522. _didIteratorError3 = true;
  8523. _iteratorError3 = err;
  8524. } finally {
  8525. try {
  8526. if (!_iteratorNormalCompletion3 && _iterator3.return != null) {
  8527. _iterator3.return();
  8528. }
  8529. } finally {
  8530. if (_didIteratorError3) {
  8531. throw _iteratorError3;
  8532. }
  8533. }
  8534. }
  8535. if (predicate(node)) {
  8536. return {
  8537. node: node,
  8538. parentNodes: parentNodes
  8539. };
  8540. }
  8541. }
  8542. } // See https://www.ecma-international.org/ecma-262/5.1/#sec-A.5
  8543. function isSourceElement(opts, node) {
  8544. if (node == null) {
  8545. return false;
  8546. } // JS and JS like to avoid repetitions
  8547. var jsSourceElements = ["FunctionDeclaration", "BlockStatement", "BreakStatement", "ContinueStatement", "DebuggerStatement", "DoWhileStatement", "EmptyStatement", "ExpressionStatement", "ForInStatement", "ForStatement", "IfStatement", "LabeledStatement", "ReturnStatement", "SwitchStatement", "ThrowStatement", "TryStatement", "VariableDeclaration", "WhileStatement", "WithStatement", "ClassDeclaration", // ES 2015
  8548. "ImportDeclaration", // Module
  8549. "ExportDefaultDeclaration", // Module
  8550. "ExportNamedDeclaration", // Module
  8551. "ExportAllDeclaration", // Module
  8552. "TypeAlias", // Flow
  8553. "InterfaceDeclaration", // Flow, TypeScript
  8554. "TypeAliasDeclaration", // TypeScript
  8555. "ExportAssignment", // TypeScript
  8556. "ExportDeclaration" // TypeScript
  8557. ];
  8558. var jsonSourceElements = ["ObjectExpression", "ArrayExpression", "StringLiteral", "NumericLiteral", "BooleanLiteral", "NullLiteral"];
  8559. var graphqlSourceElements = ["OperationDefinition", "FragmentDefinition", "VariableDefinition", "TypeExtensionDefinition", "ObjectTypeDefinition", "FieldDefinition", "DirectiveDefinition", "EnumTypeDefinition", "EnumValueDefinition", "InputValueDefinition", "InputObjectTypeDefinition", "SchemaDefinition", "OperationTypeDefinition", "InterfaceTypeDefinition", "UnionTypeDefinition", "ScalarTypeDefinition"];
  8560. switch (opts.parser) {
  8561. case "flow":
  8562. case "babylon":
  8563. case "typescript":
  8564. return jsSourceElements.indexOf(node.type) > -1;
  8565. case "json":
  8566. return jsonSourceElements.indexOf(node.type) > -1;
  8567. case "graphql":
  8568. return graphqlSourceElements.indexOf(node.kind) > -1;
  8569. }
  8570. return false;
  8571. }
  8572. function calculateRange(text, opts, ast) {
  8573. // Contract the range so that it has non-whitespace characters at its endpoints.
  8574. // This ensures we can format a range that doesn't end on a node.
  8575. var rangeStringOrig = text.slice(opts.rangeStart, opts.rangeEnd);
  8576. var startNonWhitespace = Math.max(opts.rangeStart + rangeStringOrig.search(/\S/), opts.rangeStart);
  8577. var endNonWhitespace;
  8578. for (endNonWhitespace = opts.rangeEnd; endNonWhitespace > opts.rangeStart; --endNonWhitespace) {
  8579. if (text[endNonWhitespace - 1].match(/\S/)) {
  8580. break;
  8581. }
  8582. }
  8583. var startNodeAndParents = findNodeAtOffset(ast, startNonWhitespace, opts, function (node) {
  8584. return isSourceElement(opts, node);
  8585. });
  8586. var endNodeAndParents = findNodeAtOffset(ast, endNonWhitespace, opts, function (node) {
  8587. return isSourceElement(opts, node);
  8588. });
  8589. if (!startNodeAndParents || !endNodeAndParents) {
  8590. return {
  8591. rangeStart: 0,
  8592. rangeEnd: 0
  8593. };
  8594. }
  8595. var siblingAncestors = findSiblingAncestors(startNodeAndParents, endNodeAndParents, opts);
  8596. var startNode = siblingAncestors.startNode;
  8597. var endNode = siblingAncestors.endNode;
  8598. var rangeStart = Math.min(opts.locStart(startNode, opts.locStart), opts.locStart(endNode, opts.locStart));
  8599. var rangeEnd = Math.max(opts.locEnd(startNode, opts.locEnd), opts.locEnd(endNode, opts.locEnd));
  8600. return {
  8601. rangeStart: rangeStart,
  8602. rangeEnd: rangeEnd
  8603. };
  8604. }
  8605. var rangeUtil = {
  8606. calculateRange: calculateRange,
  8607. findNodeAtOffset: findNodeAtOffset
  8608. };
  8609. var normalizeOptions = options.normalize;
  8610. var _printDocToString = doc.printer.printDocToString;
  8611. var printDocToDebug = doc.debug.printDocToDebug;
  8612. var UTF8BOM = 0xfeff;
  8613. var CURSOR = Symbol("cursor");
  8614. function guessLineEnding(text) {
  8615. var index = text.indexOf("\n");
  8616. if (index >= 0 && text.charAt(index - 1) === "\r") {
  8617. return "\r\n";
  8618. }
  8619. return "\n";
  8620. }
  8621. function ensureAllCommentsPrinted(astComments) {
  8622. if (!astComments) {
  8623. return;
  8624. }
  8625. for (var i = 0; i < astComments.length; ++i) {
  8626. if (astComments[i].value.trim() === "prettier-ignore") {
  8627. // If there's a prettier-ignore, we're not printing that sub-tree so we
  8628. // don't know if the comments was printed or not.
  8629. return;
  8630. }
  8631. }
  8632. astComments.forEach(function (comment) {
  8633. if (!comment.printed) {
  8634. throw new Error('Comment "' + comment.value.trim() + '" was not printed. Please report this error!');
  8635. }
  8636. delete comment.printed;
  8637. });
  8638. }
  8639. function attachComments(text, ast, opts) {
  8640. var astComments = ast.comments;
  8641. if (astComments) {
  8642. delete ast.comments;
  8643. comments.attach(astComments, ast, text, opts);
  8644. }
  8645. ast.tokens = [];
  8646. opts.originalText = text.trimRight();
  8647. return astComments;
  8648. }
  8649. function coreFormat(text, opts, addAlignmentSize) {
  8650. if (!text || !text.trim().length) {
  8651. return {
  8652. formatted: "",
  8653. cursorOffset: 0
  8654. };
  8655. }
  8656. addAlignmentSize = addAlignmentSize || 0;
  8657. var parsed = parser.parse(text, opts);
  8658. var ast = parsed.ast;
  8659. text = parsed.text;
  8660. if (opts.cursorOffset >= 0) {
  8661. var nodeResult = rangeUtil.findNodeAtOffset(ast, opts.cursorOffset, opts);
  8662. if (nodeResult && nodeResult.node) {
  8663. opts.cursorNode = nodeResult.node;
  8664. }
  8665. }
  8666. var astComments = attachComments(text, ast, opts);
  8667. var doc$$1 = astToDoc(ast, opts, addAlignmentSize);
  8668. opts.newLine = guessLineEnding(text);
  8669. var result = _printDocToString(doc$$1, opts);
  8670. ensureAllCommentsPrinted(astComments); // Remove extra leading indentation as well as the added indentation after last newline
  8671. if (addAlignmentSize > 0) {
  8672. var trimmed = result.formatted.trim();
  8673. if (result.cursorNodeStart !== undefined) {
  8674. result.cursorNodeStart -= result.formatted.indexOf(trimmed);
  8675. }
  8676. result.formatted = trimmed + opts.newLine;
  8677. }
  8678. if (opts.cursorOffset >= 0) {
  8679. var oldCursorNodeStart;
  8680. var oldCursorNodeText;
  8681. var cursorOffsetRelativeToOldCursorNode;
  8682. var newCursorNodeStart;
  8683. var newCursorNodeText;
  8684. if (opts.cursorNode && result.cursorNodeText) {
  8685. oldCursorNodeStart = opts.locStart(opts.cursorNode);
  8686. oldCursorNodeText = text.slice(oldCursorNodeStart, opts.locEnd(opts.cursorNode));
  8687. cursorOffsetRelativeToOldCursorNode = opts.cursorOffset - oldCursorNodeStart;
  8688. newCursorNodeStart = result.cursorNodeStart;
  8689. newCursorNodeText = result.cursorNodeText;
  8690. } else {
  8691. oldCursorNodeStart = 0;
  8692. oldCursorNodeText = text;
  8693. cursorOffsetRelativeToOldCursorNode = opts.cursorOffset;
  8694. newCursorNodeStart = 0;
  8695. newCursorNodeText = result.formatted;
  8696. }
  8697. if (oldCursorNodeText === newCursorNodeText) {
  8698. return {
  8699. formatted: result.formatted,
  8700. cursorOffset: newCursorNodeStart + cursorOffsetRelativeToOldCursorNode
  8701. };
  8702. } // diff old and new cursor node texts, with a special cursor
  8703. // symbol inserted to find out where it moves to
  8704. var oldCursorNodeCharArray = oldCursorNodeText.split("");
  8705. oldCursorNodeCharArray.splice(cursorOffsetRelativeToOldCursorNode, 0, CURSOR);
  8706. var newCursorNodeCharArray = newCursorNodeText.split("");
  8707. var cursorNodeDiff = lib.diffArrays(oldCursorNodeCharArray, newCursorNodeCharArray);
  8708. var cursorOffset = newCursorNodeStart;
  8709. var _iteratorNormalCompletion = true;
  8710. var _didIteratorError = false;
  8711. var _iteratorError = undefined;
  8712. try {
  8713. for (var _iterator = cursorNodeDiff[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  8714. var entry = _step.value;
  8715. if (entry.removed) {
  8716. if (entry.value.indexOf(CURSOR) > -1) {
  8717. break;
  8718. }
  8719. } else {
  8720. cursorOffset += entry.count;
  8721. }
  8722. }
  8723. } catch (err) {
  8724. _didIteratorError = true;
  8725. _iteratorError = err;
  8726. } finally {
  8727. try {
  8728. if (!_iteratorNormalCompletion && _iterator.return != null) {
  8729. _iterator.return();
  8730. }
  8731. } finally {
  8732. if (_didIteratorError) {
  8733. throw _iteratorError;
  8734. }
  8735. }
  8736. }
  8737. return {
  8738. formatted: result.formatted,
  8739. cursorOffset: cursorOffset
  8740. };
  8741. }
  8742. return {
  8743. formatted: result.formatted
  8744. };
  8745. }
  8746. function formatRange(text, opts) {
  8747. var parsed = parser.parse(text, opts);
  8748. var ast = parsed.ast;
  8749. text = parsed.text;
  8750. var range = rangeUtil.calculateRange(text, opts, ast);
  8751. var rangeStart = range.rangeStart;
  8752. var rangeEnd = range.rangeEnd;
  8753. var rangeString = text.slice(rangeStart, rangeEnd); // Try to extend the range backwards to the beginning of the line.
  8754. // This is so we can detect indentation correctly and restore it.
  8755. // Use `Math.min` since `lastIndexOf` returns 0 when `rangeStart` is 0
  8756. var rangeStart2 = Math.min(rangeStart, text.lastIndexOf("\n", rangeStart) + 1);
  8757. var indentString = text.slice(rangeStart2, rangeStart);
  8758. var alignmentSize = util.getAlignmentSize(indentString, opts.tabWidth);
  8759. var rangeResult = coreFormat(rangeString, Object.assign({}, opts, {
  8760. rangeStart: 0,
  8761. rangeEnd: Infinity,
  8762. printWidth: opts.printWidth - alignmentSize,
  8763. // track the cursor offset only if it's within our range
  8764. cursorOffset: opts.cursorOffset >= rangeStart && opts.cursorOffset < rangeEnd ? opts.cursorOffset - rangeStart : -1
  8765. }), alignmentSize); // Since the range contracts to avoid trailing whitespace,
  8766. // we need to remove the newline that was inserted by the `format` call.
  8767. var rangeTrimmed = rangeResult.formatted.trimRight();
  8768. var formatted = text.slice(0, rangeStart) + rangeTrimmed + text.slice(rangeEnd);
  8769. var cursorOffset = opts.cursorOffset;
  8770. if (opts.cursorOffset >= rangeEnd) {
  8771. // handle the case where the cursor was past the end of the range
  8772. cursorOffset = opts.cursorOffset - rangeEnd + (rangeStart + rangeTrimmed.length);
  8773. } else if (rangeResult.cursorOffset !== undefined) {
  8774. // handle the case where the cursor was in the range
  8775. cursorOffset = rangeResult.cursorOffset + rangeStart;
  8776. } // keep the cursor as it was if it was before the start of the range
  8777. return {
  8778. formatted: formatted,
  8779. cursorOffset: cursorOffset
  8780. };
  8781. }
  8782. function format(text, opts) {
  8783. var selectedParser = parser.resolveParser(opts);
  8784. var hasPragma = !selectedParser.hasPragma || selectedParser.hasPragma(text);
  8785. if (opts.requirePragma && !hasPragma) {
  8786. return {
  8787. formatted: text
  8788. };
  8789. }
  8790. if (opts.rangeStart > 0 || opts.rangeEnd < text.length) {
  8791. return formatRange(text, opts);
  8792. }
  8793. var hasUnicodeBOM = text.charCodeAt(0) === UTF8BOM;
  8794. if (hasUnicodeBOM) {
  8795. text = text.substring(1);
  8796. }
  8797. if (opts.insertPragma && opts.printer.insertPragma && !hasPragma) {
  8798. text = opts.printer.insertPragma(text);
  8799. }
  8800. var result = coreFormat(text, opts);
  8801. if (hasUnicodeBOM) {
  8802. result.formatted = String.fromCharCode(UTF8BOM) + result.formatted;
  8803. }
  8804. return result;
  8805. }
  8806. var core = {
  8807. formatWithCursor: function formatWithCursor(text, opts) {
  8808. opts = normalizeOptions(opts);
  8809. return format(text, normalizeOptions(opts));
  8810. },
  8811. parse: function parse(text, opts, massage) {
  8812. opts = normalizeOptions(opts);
  8813. var parsed = parser.parse(text, opts);
  8814. if (massage) {
  8815. parsed.ast = massageAst(parsed.ast, opts);
  8816. }
  8817. return parsed;
  8818. },
  8819. formatAST: function formatAST(ast, opts) {
  8820. opts = normalizeOptions(opts);
  8821. var doc$$1 = astToDoc(ast, opts);
  8822. return _printDocToString(doc$$1, opts);
  8823. },
  8824. // Doesn't handle shebang for now
  8825. formatDoc: function formatDoc(doc$$1, opts) {
  8826. var debug = printDocToDebug(doc$$1);
  8827. opts = normalizeOptions(Object.assign({}, opts, {
  8828. parser: "babylon"
  8829. }));
  8830. return format(debug, opts).formatted;
  8831. },
  8832. printToDoc: function printToDoc(text, opts) {
  8833. opts = normalizeOptions(opts);
  8834. var parsed = parser.parse(text, opts);
  8835. var ast = parsed.ast;
  8836. text = parsed.text;
  8837. attachComments(text, ast, opts);
  8838. return astToDoc(ast, opts);
  8839. },
  8840. printDocToString: function printDocToString(doc$$1, opts) {
  8841. return _printDocToString(doc$$1, normalizeOptions(opts));
  8842. }
  8843. };
  8844. var _require$$0$builders$1 = doc.builders;
  8845. var indent$3 = _require$$0$builders$1.indent;
  8846. var join$3 = _require$$0$builders$1.join;
  8847. var hardline$4 = _require$$0$builders$1.hardline;
  8848. var softline$2 = _require$$0$builders$1.softline;
  8849. var literalline$2 = _require$$0$builders$1.literalline;
  8850. var concat$5 = _require$$0$builders$1.concat;
  8851. var dedentToRoot$1 = _require$$0$builders$1.dedentToRoot;
  8852. var _require$$0$utils = doc.utils;
  8853. var mapDoc$2 = _require$$0$utils.mapDoc;
  8854. var stripTrailingHardline$1 = _require$$0$utils.stripTrailingHardline;
  8855. function embed(path, print, textToDoc
  8856. /*, options */
  8857. ) {
  8858. var node = path.getValue();
  8859. var parent = path.getParentNode();
  8860. var parentParent = path.getParentNode(1);
  8861. switch (node.type) {
  8862. case "TemplateLiteral":
  8863. {
  8864. var isCss = [isStyledJsx, isStyledComponents, isCssProp, isAngularComponentStyles].some(function (isIt) {
  8865. return isIt(path);
  8866. });
  8867. if (isCss) {
  8868. // Get full template literal with expressions replaced by placeholders
  8869. var rawQuasis = node.quasis.map(function (q) {
  8870. return q.value.raw;
  8871. });
  8872. var placeholderID = 0;
  8873. var text = rawQuasis.reduce(function (prevVal, currVal, idx) {
  8874. return idx == 0 ? currVal : prevVal + "@prettier-placeholder-" + placeholderID++ + "-id" + currVal;
  8875. }, "");
  8876. var doc$$2 = textToDoc(text, {
  8877. parser: "css"
  8878. });
  8879. return transformCssDoc(doc$$2, path, print);
  8880. }
  8881. /*
  8882. * react-relay and graphql-tag
  8883. * graphql`...`
  8884. * graphql.experimental`...`
  8885. * gql`...`
  8886. *
  8887. * This intentionally excludes Relay Classic tags, as Prettier does not
  8888. * support Relay Classic formatting.
  8889. */
  8890. if (isGraphQL(path)) {
  8891. var expressionDocs = node.expressions ? path.map(print, "expressions") : [];
  8892. var numQuasis = node.quasis.length;
  8893. if (numQuasis === 1 && node.quasis[0].value.raw.trim() === "") {
  8894. return "``";
  8895. }
  8896. var parts = [];
  8897. for (var i = 0; i < numQuasis; i++) {
  8898. var templateElement = node.quasis[i];
  8899. var isFirst = i === 0;
  8900. var isLast = i === numQuasis - 1;
  8901. var _text = templateElement.value.cooked; // Bail out if any of the quasis have an invalid escape sequence
  8902. // (which would make the `cooked` value be `null` or `undefined`)
  8903. if (typeof _text !== "string") {
  8904. return null;
  8905. }
  8906. var lines = _text.split("\n");
  8907. var numLines = lines.length;
  8908. var expressionDoc = expressionDocs[i];
  8909. var startsWithBlankLine = numLines > 2 && lines[0].trim() === "" && lines[1].trim() === "";
  8910. var endsWithBlankLine = numLines > 2 && lines[numLines - 1].trim() === "" && lines[numLines - 2].trim() === "";
  8911. var commentsAndWhitespaceOnly = lines.every(function (line) {
  8912. return /^\s*(?:#[^\r\n]*)?$/.test(line);
  8913. }); // Bail out if an interpolation occurs within a comment.
  8914. if (!isLast && /#[^\r\n]*$/.test(lines[numLines - 1])) {
  8915. return null;
  8916. }
  8917. var _doc = null;
  8918. if (commentsAndWhitespaceOnly) {
  8919. _doc = printGraphqlComments(lines);
  8920. } else {
  8921. _doc = stripTrailingHardline$1(textToDoc(_text, {
  8922. parser: "graphql"
  8923. }));
  8924. }
  8925. if (_doc) {
  8926. _doc = escapeBackticks(_doc);
  8927. if (!isFirst && startsWithBlankLine) {
  8928. parts.push("");
  8929. }
  8930. parts.push(_doc);
  8931. if (!isLast && endsWithBlankLine) {
  8932. parts.push("");
  8933. }
  8934. } else if (!isFirst && !isLast && startsWithBlankLine) {
  8935. parts.push("");
  8936. }
  8937. if (expressionDoc) {
  8938. parts.push(concat$5(["${", expressionDoc, "}"]));
  8939. }
  8940. }
  8941. return concat$5(["`", indent$3(concat$5([hardline$4, join$3(hardline$4, parts)])), hardline$4, "`"]);
  8942. }
  8943. break;
  8944. }
  8945. case "TemplateElement":
  8946. {
  8947. /**
  8948. * md`...`
  8949. * markdown`...`
  8950. */
  8951. if (parentParent && parentParent.type === "TaggedTemplateExpression" && parent.quasis.length === 1 && parentParent.tag.type === "Identifier" && (parentParent.tag.name === "md" || parentParent.tag.name === "markdown")) {
  8952. var _text2 = parent.quasis[0].value.raw.replace(/((?:\\\\)*)\\`/g, function (_, backslashes) {
  8953. return "\\".repeat(backslashes.length / 2) + "`";
  8954. });
  8955. var indentation = getIndentation(_text2);
  8956. var hasIndent = indentation !== "";
  8957. return concat$5([hasIndent ? indent$3(concat$5([softline$2, printMarkdown(_text2.replace(new RegExp("^".concat(indentation), "gm"), ""))])) : concat$5([literalline$2, dedentToRoot$1(printMarkdown(_text2))]), softline$2]);
  8958. }
  8959. break;
  8960. }
  8961. }
  8962. function printMarkdown(text) {
  8963. var doc$$2 = textToDoc(text, {
  8964. parser: "markdown",
  8965. __inJsTemplate: true
  8966. });
  8967. return stripTrailingHardline$1(escapeBackticks(doc$$2));
  8968. }
  8969. }
  8970. function isPropertyWithinAngularComponentDecorator(path, parentIndexToCheck) {
  8971. var parent = path.getParentNode(parentIndexToCheck);
  8972. return !!(parent && parent.type === "Decorator" && parent.expression && parent.expression.type === "CallExpression" && parent.expression.callee && parent.expression.callee.name === "Component");
  8973. }
  8974. function getIndentation(str) {
  8975. var firstMatchedIndent = str.match(/^([^\S\n]*)\S/m);
  8976. return firstMatchedIndent === null ? "" : firstMatchedIndent[1];
  8977. }
  8978. function escapeBackticks(doc$$2) {
  8979. return mapDoc$2(doc$$2, function (currentDoc) {
  8980. if (!currentDoc.parts) {
  8981. return currentDoc;
  8982. }
  8983. var parts = [];
  8984. currentDoc.parts.forEach(function (part) {
  8985. if (typeof part === "string") {
  8986. parts.push(part.replace(/(\\*)`/g, "$1$1\\`"));
  8987. } else {
  8988. parts.push(part);
  8989. }
  8990. });
  8991. return Object.assign({}, currentDoc, {
  8992. parts: parts
  8993. });
  8994. });
  8995. }
  8996. function transformCssDoc(quasisDoc, path, print) {
  8997. var parentNode = path.getValue();
  8998. var isEmpty = parentNode.quasis.length === 1 && !parentNode.quasis[0].value.raw.trim();
  8999. if (isEmpty) {
  9000. return "``";
  9001. }
  9002. var expressionDocs = parentNode.expressions ? path.map(print, "expressions") : [];
  9003. var newDoc = replacePlaceholders(quasisDoc, expressionDocs);
  9004. /* istanbul ignore if */
  9005. if (!newDoc) {
  9006. throw new Error("Couldn't insert all the expressions");
  9007. }
  9008. return concat$5(["`", indent$3(concat$5([hardline$4, stripTrailingHardline$1(newDoc)])), softline$2, "`"]);
  9009. } // Search all the placeholders in the quasisDoc tree
  9010. // and replace them with the expression docs one by one
  9011. // returns a new doc with all the placeholders replaced,
  9012. // or null if it couldn't replace any expression
  9013. function replacePlaceholders(quasisDoc, expressionDocs) {
  9014. if (!expressionDocs || !expressionDocs.length) {
  9015. return quasisDoc;
  9016. }
  9017. var expressions = expressionDocs.slice();
  9018. var replaceCounter = 0;
  9019. var newDoc = mapDoc$2(quasisDoc, function (doc$$2) {
  9020. if (!doc$$2 || !doc$$2.parts || !doc$$2.parts.length) {
  9021. return doc$$2;
  9022. }
  9023. var parts = doc$$2.parts;
  9024. var atIndex = parts.indexOf("@");
  9025. var placeholderIndex = atIndex + 1;
  9026. if (atIndex > -1 && typeof parts[placeholderIndex] === "string" && parts[placeholderIndex].startsWith("prettier-placeholder")) {
  9027. // If placeholder is split, join it
  9028. var at = parts[atIndex];
  9029. var placeholder = parts[placeholderIndex];
  9030. var rest = parts.slice(placeholderIndex + 1);
  9031. parts = parts.slice(0, atIndex).concat([at + placeholder]).concat(rest);
  9032. }
  9033. var atPlaceholderIndex = parts.findIndex(function (part) {
  9034. return typeof part === "string" && part.startsWith("@prettier-placeholder");
  9035. });
  9036. if (atPlaceholderIndex > -1) {
  9037. var _placeholder = parts[atPlaceholderIndex];
  9038. var _rest = parts.slice(atPlaceholderIndex + 1);
  9039. var placeholderMatch = _placeholder.match(/@prettier-placeholder-(.+)-id([\s\S]*)/);
  9040. var placeholderID = placeholderMatch[1]; // When the expression has a suffix appended, like:
  9041. // animation: linear ${time}s ease-out;
  9042. var suffix = placeholderMatch[2];
  9043. var expression = expressions[placeholderID];
  9044. replaceCounter++;
  9045. parts = parts.slice(0, atPlaceholderIndex).concat(["${", expression, "}" + suffix]).concat(_rest);
  9046. }
  9047. return Object.assign({}, doc$$2, {
  9048. parts: parts
  9049. });
  9050. });
  9051. return expressions.length === replaceCounter ? newDoc : null;
  9052. }
  9053. function printGraphqlComments(lines) {
  9054. var parts = [];
  9055. var seenComment = false;
  9056. lines.map(function (textLine) {
  9057. return textLine.trim();
  9058. }).forEach(function (textLine, i, array) {
  9059. // Lines are either whitespace only, or a comment (with poential whitespace
  9060. // around it). Drop whitespace-only lines.
  9061. if (textLine === "") {
  9062. return;
  9063. }
  9064. if (array[i - 1] === "" && seenComment) {
  9065. // If a non-first comment is preceded by a blank (whitespace only) line,
  9066. // add in a blank line.
  9067. parts.push(concat$5([hardline$4, textLine]));
  9068. } else {
  9069. parts.push(textLine);
  9070. }
  9071. seenComment = true;
  9072. }); // If `lines` was whitespace only, return `null`.
  9073. return parts.length === 0 ? null : join$3(hardline$4, parts);
  9074. }
  9075. /**
  9076. * Template literal in this context:
  9077. * <style jsx>{`div{color:red}`}</style>
  9078. */
  9079. function isStyledJsx(path) {
  9080. var node = path.getValue();
  9081. var parent = path.getParentNode();
  9082. var parentParent = path.getParentNode(1);
  9083. return parentParent && node.quasis && parent.type === "JSXExpressionContainer" && parentParent.type === "JSXElement" && parentParent.openingElement.name.name === "style" && parentParent.openingElement.attributes.some(function (attribute) {
  9084. return attribute.name.name === "jsx";
  9085. });
  9086. }
  9087. /**
  9088. * Angular Components can have:
  9089. * - Inline HTML template
  9090. * - Inline CSS styles
  9091. *
  9092. * ...which are both within template literals somewhere
  9093. * inside of the Component decorator factory.
  9094. *
  9095. * TODO: Format HTML template once prettier's HTML
  9096. * formatting is "ready"
  9097. *
  9098. * E.g.
  9099. * @Component({
  9100. * template: `<div>...</div>`,
  9101. * styles: [`h1 { color: blue; }`]
  9102. * })
  9103. */
  9104. function isAngularComponentStyles(path) {
  9105. var parent = path.getParentNode();
  9106. var parentParent = path.getParentNode(1);
  9107. var isWithinArrayValueFromProperty = !!(parent && parent.type === "ArrayExpression" && parentParent.type === "Property");
  9108. if (isWithinArrayValueFromProperty && isPropertyWithinAngularComponentDecorator(path, 4)) {
  9109. if (parentParent.key && parentParent.key.name === "styles") {
  9110. return true;
  9111. }
  9112. }
  9113. return false;
  9114. }
  9115. /**
  9116. * styled-components template literals
  9117. */
  9118. function isStyledComponents(path) {
  9119. var parent = path.getParentNode();
  9120. if (!parent || parent.type !== "TaggedTemplateExpression") {
  9121. return false;
  9122. }
  9123. var tag = parent.tag;
  9124. switch (tag.type) {
  9125. case "MemberExpression":
  9126. return (// styled.foo``
  9127. isStyledIdentifier(tag.object) || // Component.extend``
  9128. isStyledExtend(tag)
  9129. );
  9130. case "CallExpression":
  9131. return (// styled(Component)``
  9132. isStyledIdentifier(tag.callee) || tag.callee.type === "MemberExpression" && (tag.callee.object.type === "MemberExpression" && ( // styled.foo.attr({})``
  9133. isStyledIdentifier(tag.callee.object.object) || // Component.extend.attr({)``
  9134. isStyledExtend(tag.callee.object)) || // styled(Component).attr({})``
  9135. tag.callee.object.type === "CallExpression" && isStyledIdentifier(tag.callee.object.callee))
  9136. );
  9137. case "Identifier":
  9138. // css``
  9139. return tag.name === "css";
  9140. default:
  9141. return false;
  9142. }
  9143. }
  9144. /**
  9145. * JSX element with CSS prop
  9146. */
  9147. function isCssProp(path) {
  9148. var parent = path.getParentNode();
  9149. var parentParent = path.getParentNode(1);
  9150. return parentParent && parent.type === "JSXExpressionContainer" && parentParent.type === "JSXAttribute" && parentParent.name.type === "JSXIdentifier" && parentParent.name.name === "css";
  9151. }
  9152. function isStyledIdentifier(node) {
  9153. return node.type === "Identifier" && node.name === "styled";
  9154. }
  9155. function isStyledExtend(node) {
  9156. return /^[A-Z]/.test(node.object.name) && node.property.name === "extend";
  9157. }
  9158. /*
  9159. * react-relay and graphql-tag
  9160. * graphql`...`
  9161. * graphql.experimental`...`
  9162. * gql`...`
  9163. * GraphQL comment block
  9164. *
  9165. * This intentionally excludes Relay Classic tags, as Prettier does not
  9166. * support Relay Classic formatting.
  9167. */
  9168. function isGraphQL(path) {
  9169. var node = path.getValue();
  9170. var parent = path.getParentNode(); // This checks for a leading comment that is exactly `/* GraphQL */`
  9171. // In order to be in line with other implementations of this comment tag
  9172. // we will not trim the comment value and we will expect exactly one space on
  9173. // either side of the GraphQL string
  9174. // Also see ./clean.js
  9175. var hasGraphQLComment = node.leadingComments && node.leadingComments.some(function (comment) {
  9176. return comment.type === "CommentBlock" && comment.value === " GraphQL ";
  9177. });
  9178. return hasGraphQLComment || 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");
  9179. }
  9180. var embed_1 = embed;
  9181. function clean(ast, newObj, parent) {
  9182. ["range", "raw", "comments", "leadingComments", "trailingComments", "extra", "start", "end", "flags"].forEach(function (name) {
  9183. delete newObj[name];
  9184. }); // We remove extra `;` and add them when needed
  9185. if (ast.type === "EmptyStatement") {
  9186. return null;
  9187. } // We move text around, including whitespaces and add {" "}
  9188. if (ast.type === "JSXText") {
  9189. return null;
  9190. }
  9191. if (ast.type === "JSXExpressionContainer" && ast.expression.type === "Literal" && ast.expression.value === " ") {
  9192. return null;
  9193. } // (TypeScript) Ignore `static` in `constructor(static p) {}`
  9194. // and `export` in `constructor(export p) {}`
  9195. if (ast.type === "TSParameterProperty" && ast.accessibility === null && !ast.readonly) {
  9196. return {
  9197. type: "Identifier",
  9198. name: ast.parameter.name,
  9199. typeAnnotation: newObj.parameter.typeAnnotation,
  9200. decorators: newObj.decorators
  9201. };
  9202. } // (TypeScript) ignore empty `specifiers` array
  9203. if (ast.type === "TSNamespaceExportDeclaration" && ast.specifiers && ast.specifiers.length === 0) {
  9204. delete newObj.specifiers;
  9205. } // (TypeScript) bypass TSParenthesizedType
  9206. if (ast.type === "TSParenthesizedType" && ast.typeAnnotation.type === "TSTypeAnnotation") {
  9207. return newObj.typeAnnotation.typeAnnotation;
  9208. } // We convert <div></div> to <div />
  9209. if (ast.type === "JSXOpeningElement") {
  9210. delete newObj.selfClosing;
  9211. }
  9212. if (ast.type === "JSXElement") {
  9213. delete newObj.closingElement;
  9214. } // We change {'key': value} into {key: value}
  9215. if ((ast.type === "Property" || ast.type === "ObjectProperty" || ast.type === "MethodDefinition" || ast.type === "ClassProperty" || ast.type === "TSPropertySignature" || ast.type === "ObjectTypeProperty") && _typeof(ast.key) === "object" && ast.key && (ast.key.type === "Literal" || ast.key.type === "StringLiteral" || ast.key.type === "Identifier")) {
  9216. delete newObj.key;
  9217. }
  9218. if (ast.type === "OptionalMemberExpression" && ast.optional === false) {
  9219. newObj.type = "MemberExpression";
  9220. delete newObj.optional;
  9221. } // Remove raw and cooked values from TemplateElement when it's CSS
  9222. // styled-jsx
  9223. if (ast.type === "JSXElement" && ast.openingElement.name.name === "style" && ast.openingElement.attributes.some(function (attr) {
  9224. return attr.name.name === "jsx";
  9225. })) {
  9226. var templateLiterals = newObj.children.filter(function (child) {
  9227. return child.type === "JSXExpressionContainer" && child.expression.type === "TemplateLiteral";
  9228. }).map(function (container) {
  9229. return container.expression;
  9230. });
  9231. var quasis = templateLiterals.reduce(function (quasis, templateLiteral) {
  9232. return quasis.concat(templateLiteral.quasis);
  9233. }, []);
  9234. quasis.forEach(function (q) {
  9235. return delete q.value;
  9236. });
  9237. } // CSS template literals in css prop
  9238. if (ast.type === "JSXAttribute" && ast.name.name === "css" && ast.value.type === "JSXExpressionContainer" && ast.value.expression.type === "TemplateLiteral") {
  9239. newObj.value.expression.quasis.forEach(function (q) {
  9240. return delete q.value;
  9241. });
  9242. } // CSS template literals in Angular Component decorator
  9243. var expression = ast.expression || ast.callee;
  9244. if (ast.type === "Decorator" && expression.type === "CallExpression" && expression.callee.name === "Component" && expression.arguments.length === 1 && expression.arguments[0].properties.some(function (prop) {
  9245. return prop.key.name === "styles" && prop.value.type === "ArrayExpression";
  9246. })) {
  9247. newObj.expression.arguments[0].properties.forEach(function (prop) {
  9248. if (prop.value.type === "ArrayExpression") {
  9249. prop.value.elements[0].quasis.forEach(function (q) {
  9250. return delete q.value;
  9251. });
  9252. }
  9253. });
  9254. } // styled-components, graphql, markdown
  9255. 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.type === "CallExpression")) {
  9256. newObj.quasi.quasis.forEach(function (quasi) {
  9257. return delete quasi.value;
  9258. });
  9259. }
  9260. if (ast.type === "TemplateLiteral") {
  9261. // This checks for a leading comment that is exactly `/* GraphQL */`
  9262. // In order to be in line with other implementations of this comment tag
  9263. // we will not trim the comment value and we will expect exactly one space on
  9264. // either side of the GraphQL string
  9265. // Also see ./embed.js
  9266. var hasGraphQLComment = ast.leadingComments && ast.leadingComments.some(function (comment) {
  9267. return comment.type === "CommentBlock" && comment.value === " GraphQL ";
  9268. });
  9269. if (hasGraphQLComment || parent.type === "CallExpression" && parent.callee.name === "graphql") {
  9270. newObj.quasis.forEach(function (quasi) {
  9271. return delete quasi.value;
  9272. });
  9273. }
  9274. }
  9275. }
  9276. var clean_1 = clean;
  9277. var detectNewline = createCommonjsModule(function (module) {
  9278. 'use strict';
  9279. module.exports = function (str) {
  9280. if (typeof str !== 'string') {
  9281. throw new TypeError('Expected a string');
  9282. }
  9283. var newlines = str.match(/(?:\r?\n)/g) || [];
  9284. if (newlines.length === 0) {
  9285. return null;
  9286. }
  9287. var crlf = newlines.filter(function (el) {
  9288. return el === '\r\n';
  9289. }).length;
  9290. var lf = newlines.length - crlf;
  9291. return crlf > lf ? '\r\n' : '\n';
  9292. };
  9293. module.exports.graceful = function (str) {
  9294. return module.exports(str) || '\n';
  9295. };
  9296. });
  9297. var os$8 = {};
  9298. var os$10 = Object.freeze({
  9299. default: os$8,
  9300. __moduleExports: os$8
  9301. });
  9302. var require$$1$4 = ( os$10 && os$8 ) || os$10;
  9303. var build = createCommonjsModule(function (module, exports) {
  9304. 'use strict';
  9305. Object.defineProperty(exports, "__esModule", {
  9306. value: true
  9307. });
  9308. exports.extract = extract;
  9309. exports.strip = strip;
  9310. exports.parse = parse;
  9311. exports.parseWithComments = parseWithComments;
  9312. exports.print = print;
  9313. var _detectNewline;
  9314. function _load_detectNewline() {
  9315. return _detectNewline = _interopRequireDefault(detectNewline);
  9316. }
  9317. var _os;
  9318. function _load_os() {
  9319. return _os = require$$1$4;
  9320. }
  9321. function _interopRequireDefault(obj) {
  9322. return obj && obj.__esModule ? obj : {
  9323. default: obj
  9324. };
  9325. }
  9326. /**
  9327. * Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
  9328. *
  9329. * This source code is licensed under the MIT license found in the
  9330. * LICENSE file in the root directory of this source tree.
  9331. *
  9332. *
  9333. */
  9334. var commentEndRe = /\*\/$/;
  9335. var commentStartRe = /^\/\*\*/;
  9336. var docblockRe = /^\s*(\/\*\*?(.|\r?\n)*?\*\/)/;
  9337. var lineCommentRe = /(^|\s+)\/\/([^\r\n]*)/g;
  9338. var ltrimRe = /^\s*/;
  9339. var rtrimRe = /\s*$/;
  9340. var ltrimNewlineRe = /^(\r?\n)+/;
  9341. var multilineRe = /(?:^|\r?\n) *(@[^\r\n]*?) *\r?\n *(?![^@\r\n]*\/\/[^]*)([^@\r\n\s][^@\r\n]+?) *\r?\n/g;
  9342. var propertyRe = /(?:^|\r?\n) *@(\S+) *([^\r\n]*)/g;
  9343. var stringStartRe = /(\r?\n|^) *\* ?/g;
  9344. function extract(contents) {
  9345. var match = contents.match(docblockRe);
  9346. return match ? match[0].replace(ltrimRe, '') || '' : '';
  9347. }
  9348. function strip(contents) {
  9349. var match = contents.match(docblockRe);
  9350. return match && match[0] ? contents.substring(match[0].length) : contents;
  9351. }
  9352. function parse(docblock) {
  9353. return parseWithComments(docblock).pragmas;
  9354. }
  9355. function parseWithComments(docblock) {
  9356. var line = (0, (_detectNewline || _load_detectNewline()).default)(docblock) || (_os || _load_os()).EOL;
  9357. docblock = docblock.replace(commentStartRe, '').replace(commentEndRe, '').replace(stringStartRe, '$1'); // Normalize multi-line directives
  9358. var prev = '';
  9359. while (prev !== docblock) {
  9360. prev = docblock;
  9361. docblock = docblock.replace(multilineRe, "".concat(line, "$1 $2").concat(line));
  9362. }
  9363. docblock = docblock.replace(ltrimNewlineRe, '').replace(rtrimRe, '');
  9364. var result = Object.create(null);
  9365. var comments = docblock.replace(propertyRe, '').replace(ltrimNewlineRe, '').replace(rtrimRe, '');
  9366. var match;
  9367. while (match = propertyRe.exec(docblock)) {
  9368. // strip linecomments from pragmas
  9369. var nextPragma = match[2].replace(lineCommentRe, '');
  9370. if (typeof result[match[1]] === 'string' || Array.isArray(result[match[1]])) {
  9371. result[match[1]] = [].concat(result[match[1]], nextPragma);
  9372. } else {
  9373. result[match[1]] = nextPragma;
  9374. }
  9375. }
  9376. return {
  9377. comments: comments,
  9378. pragmas: result
  9379. };
  9380. }
  9381. function print(_ref) {
  9382. var _ref$comments = _ref.comments;
  9383. var comments = _ref$comments === undefined ? '' : _ref$comments;
  9384. var _ref$pragmas = _ref.pragmas;
  9385. var pragmas = _ref$pragmas === undefined ? {} : _ref$pragmas;
  9386. var line = (0, (_detectNewline || _load_detectNewline()).default)(comments) || (_os || _load_os()).EOL;
  9387. var head = '/**';
  9388. var start = ' *';
  9389. var tail = ' */';
  9390. var keys = Object.keys(pragmas);
  9391. var printedObject = keys.map(function (key) {
  9392. return printKeyValues(key, pragmas[key]);
  9393. }).reduce(function (arr, next) {
  9394. return arr.concat(next);
  9395. }, []).map(function (keyValue) {
  9396. return start + ' ' + keyValue + line;
  9397. }).join('');
  9398. if (!comments) {
  9399. if (keys.length === 0) {
  9400. return '';
  9401. }
  9402. if (keys.length === 1 && !Array.isArray(pragmas[keys[0]])) {
  9403. var value = pragmas[keys[0]];
  9404. return "".concat(head, " ").concat(printKeyValues(keys[0], value)[0]).concat(tail);
  9405. }
  9406. }
  9407. var printedComments = comments.split(line).map(function (textLine) {
  9408. return "".concat(start, " ").concat(textLine);
  9409. }).join(line) + line;
  9410. return head + line + (comments ? printedComments : '') + (comments && keys.length ? start + line : '') + printedObject + tail;
  9411. }
  9412. function printKeyValues(key, valueOrArray) {
  9413. return [].concat(valueOrArray).map(function (value) {
  9414. return "@".concat(key, " ").concat(value).trim();
  9415. });
  9416. }
  9417. });
  9418. unwrapExports(build);
  9419. function hasPragma(text) {
  9420. var pragmas = Object.keys(build.parse(build.extract(text)));
  9421. return pragmas.indexOf("prettier") !== -1 || pragmas.indexOf("format") !== -1;
  9422. }
  9423. function insertPragma$1(text) {
  9424. var parsedDocblock = build.parseWithComments(build.extract(text));
  9425. var pragmas = Object.assign({
  9426. format: ""
  9427. }, parsedDocblock.pragmas);
  9428. var newDocblock = build.print({
  9429. pragmas: pragmas,
  9430. comments: parsedDocblock.comments.replace(/^(\s+?\r?\n)+/, "") // remove leading newlines
  9431. });
  9432. var strippedText = build.strip(text);
  9433. var separatingNewlines = strippedText.startsWith("\n") ? "\n" : "\n\n";
  9434. return newDocblock + separatingNewlines + strippedText;
  9435. }
  9436. var pragma = {
  9437. hasPragma: hasPragma,
  9438. insertPragma: insertPragma$1
  9439. };
  9440. var addLeadingComment$2 = utilShared.addLeadingComment;
  9441. var addTrailingComment$2 = utilShared.addTrailingComment;
  9442. var addDanglingComment$2 = utilShared.addDanglingComment;
  9443. function handleOwnLineComment(comment, text, options, ast, isLastComment) {
  9444. var precedingNode = comment.precedingNode;
  9445. var enclosingNode = comment.enclosingNode;
  9446. var followingNode = comment.followingNode;
  9447. if (handleLastFunctionArgComments(text, precedingNode, enclosingNode, followingNode, comment, options) || handleMemberExpressionComments(enclosingNode, followingNode, comment) || handleIfStatementComments(text, precedingNode, enclosingNode, followingNode, comment, options) || handleTryStatementComments(enclosingNode, followingNode, comment) || handleClassComments(enclosingNode, precedingNode, followingNode, comment) || handleImportSpecifierComments(enclosingNode, comment) || handleForComments(enclosingNode, precedingNode, comment) || handleUnionTypeComments(precedingNode, enclosingNode, followingNode, comment) || handleOnlyComments(enclosingNode, ast, comment, isLastComment) || handleImportDeclarationComments(text, enclosingNode, precedingNode, comment, options) || handleAssignmentPatternComments(enclosingNode, comment) || handleMethodNameComments(text, enclosingNode, precedingNode, comment, options)) {
  9448. return true;
  9449. }
  9450. return false;
  9451. }
  9452. function handleEndOfLineComment(comment, text, options, ast, isLastComment) {
  9453. var precedingNode = comment.precedingNode;
  9454. var enclosingNode = comment.enclosingNode;
  9455. var followingNode = comment.followingNode;
  9456. if (handleLastFunctionArgComments(text, precedingNode, enclosingNode, followingNode, comment, options) || handleConditionalExpressionComments(enclosingNode, precedingNode, followingNode, comment, text, options) || handleImportSpecifierComments(enclosingNode, comment) || handleIfStatementComments(text, precedingNode, enclosingNode, followingNode, comment, options) || handleClassComments(enclosingNode, precedingNode, followingNode, comment) || handleLabeledStatementComments(enclosingNode, comment) || handleCallExpressionComments(precedingNode, enclosingNode, comment) || handlePropertyComments(enclosingNode, comment) || handleOnlyComments(enclosingNode, ast, comment, isLastComment) || handleTypeAliasComments(enclosingNode, followingNode, comment) || handleVariableDeclaratorComments(enclosingNode, followingNode, comment)) {
  9457. return true;
  9458. }
  9459. return false;
  9460. }
  9461. function handleRemainingComment(comment, text, options, ast, isLastComment) {
  9462. var precedingNode = comment.precedingNode;
  9463. var enclosingNode = comment.enclosingNode;
  9464. var followingNode = comment.followingNode;
  9465. if (handleIfStatementComments(text, precedingNode, enclosingNode, followingNode, comment, options) || handleObjectPropertyAssignment(enclosingNode, precedingNode, comment) || handleCommentInEmptyParens(text, enclosingNode, comment, options) || handleMethodNameComments(text, enclosingNode, precedingNode, comment, options) || handleOnlyComments(enclosingNode, ast, comment, isLastComment) || handleCommentAfterArrowParams(text, enclosingNode, comment, options) || handleFunctionNameComments(text, enclosingNode, precedingNode, comment, options) || handleTSMappedTypeComments(text, enclosingNode, precedingNode, followingNode, comment) || handleBreakAndContinueStatementComments(enclosingNode, comment)) {
  9466. return true;
  9467. }
  9468. return false;
  9469. }
  9470. function addBlockStatementFirstComment(node, comment) {
  9471. var body = node.body.filter(function (n) {
  9472. return n.type !== "EmptyStatement";
  9473. });
  9474. if (body.length === 0) {
  9475. addDanglingComment$2(node, comment);
  9476. } else {
  9477. addLeadingComment$2(body[0], comment);
  9478. }
  9479. }
  9480. function addBlockOrNotComment(node, comment) {
  9481. if (node.type === "BlockStatement") {
  9482. addBlockStatementFirstComment(node, comment);
  9483. } else {
  9484. addLeadingComment$2(node, comment);
  9485. }
  9486. } // There are often comments before the else clause of if statements like
  9487. //
  9488. // if (1) { ... }
  9489. // // comment
  9490. // else { ... }
  9491. //
  9492. // They are being attached as leading comments of the BlockExpression which
  9493. // is not well printed. What we want is to instead move the comment inside
  9494. // of the block and make it leadingComment of the first element of the block
  9495. // or dangling comment of the block if there is nothing inside
  9496. //
  9497. // if (1) { ... }
  9498. // else {
  9499. // // comment
  9500. // ...
  9501. // }
  9502. function handleIfStatementComments(text, precedingNode, enclosingNode, followingNode, comment, options) {
  9503. if (!enclosingNode || enclosingNode.type !== "IfStatement" || !followingNode) {
  9504. return false;
  9505. } // We unfortunately have no way using the AST or location of nodes to know
  9506. // if the comment is positioned before the condition parenthesis:
  9507. // if (a /* comment */) {}
  9508. // The only workaround I found is to look at the next character to see if
  9509. // it is a ).
  9510. var nextCharacter = util.getNextNonSpaceNonCommentCharacter(text, comment, options.locEnd);
  9511. if (nextCharacter === ")") {
  9512. addTrailingComment$2(precedingNode, comment);
  9513. return true;
  9514. } // Comments before `else`:
  9515. // - treat as trailing comments of the consequent, if it's a BlockStatement
  9516. // - treat as a dangling comment otherwise
  9517. if (precedingNode === enclosingNode.consequent && followingNode === enclosingNode.alternate) {
  9518. if (precedingNode.type === "BlockStatement") {
  9519. addTrailingComment$2(precedingNode, comment);
  9520. } else {
  9521. addDanglingComment$2(enclosingNode, comment);
  9522. }
  9523. return true;
  9524. }
  9525. if (followingNode.type === "BlockStatement") {
  9526. addBlockStatementFirstComment(followingNode, comment);
  9527. return true;
  9528. }
  9529. if (followingNode.type === "IfStatement") {
  9530. addBlockOrNotComment(followingNode.consequent, comment);
  9531. return true;
  9532. } // For comments positioned after the condition parenthesis in an if statement
  9533. // before the consequent with or without brackets on, such as
  9534. // if (a) /* comment */ {} or if (a) /* comment */ true,
  9535. // we look at the next character to see if it is a { or if the following node
  9536. // is the consequent for the if statement
  9537. if (nextCharacter === "{" || enclosingNode.consequent === followingNode) {
  9538. addLeadingComment$2(followingNode, comment);
  9539. return true;
  9540. }
  9541. return false;
  9542. } // Same as IfStatement but for TryStatement
  9543. function handleTryStatementComments(enclosingNode, followingNode, comment) {
  9544. if (!enclosingNode || enclosingNode.type !== "TryStatement" || !followingNode) {
  9545. return false;
  9546. }
  9547. if (followingNode.type === "BlockStatement") {
  9548. addBlockStatementFirstComment(followingNode, comment);
  9549. return true;
  9550. }
  9551. if (followingNode.type === "TryStatement") {
  9552. addBlockOrNotComment(followingNode.finalizer, comment);
  9553. return true;
  9554. }
  9555. if (followingNode.type === "CatchClause") {
  9556. addBlockOrNotComment(followingNode.body, comment);
  9557. return true;
  9558. }
  9559. return false;
  9560. }
  9561. function handleMemberExpressionComments(enclosingNode, followingNode, comment) {
  9562. if (enclosingNode && enclosingNode.type === "MemberExpression" && followingNode && followingNode.type === "Identifier") {
  9563. addLeadingComment$2(enclosingNode, comment);
  9564. return true;
  9565. }
  9566. return false;
  9567. }
  9568. function handleConditionalExpressionComments(enclosingNode, precedingNode, followingNode, comment, text, options) {
  9569. var isSameLineAsPrecedingNode = precedingNode && !util.hasNewlineInRange(text, options.locEnd(precedingNode), options.locStart(comment));
  9570. if ((!precedingNode || !isSameLineAsPrecedingNode) && enclosingNode && enclosingNode.type === "ConditionalExpression" && followingNode) {
  9571. addLeadingComment$2(followingNode, comment);
  9572. return true;
  9573. }
  9574. return false;
  9575. }
  9576. function handleObjectPropertyAssignment(enclosingNode, precedingNode, comment) {
  9577. if (enclosingNode && (enclosingNode.type === "ObjectProperty" || enclosingNode.type === "Property") && enclosingNode.shorthand && enclosingNode.key === precedingNode && enclosingNode.value.type === "AssignmentPattern") {
  9578. addTrailingComment$2(enclosingNode.value.left, comment);
  9579. return true;
  9580. }
  9581. return false;
  9582. }
  9583. function handleClassComments(enclosingNode, precedingNode, followingNode, comment) {
  9584. if (enclosingNode && (enclosingNode.type === "ClassDeclaration" || enclosingNode.type === "ClassExpression") && enclosingNode.decorators && enclosingNode.decorators.length > 0 && !(followingNode && followingNode.type === "Decorator")) {
  9585. if (!enclosingNode.decorators || enclosingNode.decorators.length === 0) {
  9586. addLeadingComment$2(enclosingNode, comment);
  9587. } else {
  9588. addTrailingComment$2(enclosingNode.decorators[enclosingNode.decorators.length - 1], comment);
  9589. }
  9590. return true;
  9591. }
  9592. return false;
  9593. }
  9594. function handleMethodNameComments(text, enclosingNode, precedingNode, comment, options) {
  9595. // This is only needed for estree parsers (flow, typescript) to attach
  9596. // after a method name:
  9597. // obj = { fn /*comment*/() {} };
  9598. if (enclosingNode && precedingNode && (enclosingNode.type === "Property" || enclosingNode.type === "MethodDefinition") && precedingNode.type === "Identifier" && enclosingNode.key === precedingNode && // special Property case: { key: /*comment*/(value) };
  9599. // comment should be attached to value instead of key
  9600. util.getNextNonSpaceNonCommentCharacter(text, precedingNode, options.locEnd) !== ":") {
  9601. addTrailingComment$2(precedingNode, comment);
  9602. return true;
  9603. } // Print comments between decorators and class methods as a trailing comment
  9604. // on the decorator node instead of the method node
  9605. if (precedingNode && enclosingNode && precedingNode.type === "Decorator" && (enclosingNode.type === "ClassMethod" || enclosingNode.type === "ClassProperty" || enclosingNode.type === "TSAbstractClassProperty" || enclosingNode.type === "TSAbstractMethodDefinition" || enclosingNode.type === "MethodDefinition")) {
  9606. addTrailingComment$2(precedingNode, comment);
  9607. return true;
  9608. }
  9609. return false;
  9610. }
  9611. function handleFunctionNameComments(text, enclosingNode, precedingNode, comment, options) {
  9612. if (util.getNextNonSpaceNonCommentCharacter(text, comment, options.locEnd) !== "(") {
  9613. return false;
  9614. }
  9615. if (precedingNode && enclosingNode && (enclosingNode.type === "FunctionDeclaration" || enclosingNode.type === "FunctionExpression" || enclosingNode.type === "ClassMethod" || enclosingNode.type === "MethodDefinition" || enclosingNode.type === "ObjectMethod")) {
  9616. addTrailingComment$2(precedingNode, comment);
  9617. return true;
  9618. }
  9619. return false;
  9620. }
  9621. function handleCommentAfterArrowParams(text, enclosingNode, comment, options) {
  9622. if (!(enclosingNode && enclosingNode.type === "ArrowFunctionExpression")) {
  9623. return false;
  9624. }
  9625. var index = utilShared.getNextNonSpaceNonCommentCharacterIndex(text, comment, options);
  9626. if (text.substr(index, 2) === "=>") {
  9627. addDanglingComment$2(enclosingNode, comment);
  9628. return true;
  9629. }
  9630. return false;
  9631. }
  9632. function handleCommentInEmptyParens(text, enclosingNode, comment, options) {
  9633. if (util.getNextNonSpaceNonCommentCharacter(text, comment, options.locEnd) !== ")") {
  9634. return false;
  9635. } // Only add dangling comments to fix the case when no params are present,
  9636. // i.e. a function without any argument.
  9637. if (enclosingNode && ((enclosingNode.type === "FunctionDeclaration" || enclosingNode.type === "FunctionExpression" || enclosingNode.type === "ArrowFunctionExpression" && (enclosingNode.body.type !== "CallExpression" || enclosingNode.body.arguments.length === 0) || enclosingNode.type === "ClassMethod" || enclosingNode.type === "ObjectMethod") && enclosingNode.params.length === 0 || enclosingNode.type === "CallExpression" && enclosingNode.arguments.length === 0)) {
  9638. addDanglingComment$2(enclosingNode, comment);
  9639. return true;
  9640. }
  9641. if (enclosingNode && enclosingNode.type === "MethodDefinition" && enclosingNode.value.params.length === 0) {
  9642. addDanglingComment$2(enclosingNode.value, comment);
  9643. return true;
  9644. }
  9645. return false;
  9646. }
  9647. function handleLastFunctionArgComments(text, precedingNode, enclosingNode, followingNode, comment, options) {
  9648. // Type definitions functions
  9649. if (precedingNode && precedingNode.type === "FunctionTypeParam" && enclosingNode && enclosingNode.type === "FunctionTypeAnnotation" && followingNode && followingNode.type !== "FunctionTypeParam") {
  9650. addTrailingComment$2(precedingNode, comment);
  9651. return true;
  9652. } // Real functions
  9653. if (precedingNode && (precedingNode.type === "Identifier" || precedingNode.type === "AssignmentPattern") && enclosingNode && (enclosingNode.type === "ArrowFunctionExpression" || enclosingNode.type === "FunctionExpression" || enclosingNode.type === "FunctionDeclaration" || enclosingNode.type === "ObjectMethod" || enclosingNode.type === "ClassMethod") && util.getNextNonSpaceNonCommentCharacter(text, comment, options.locEnd) === ")") {
  9654. addTrailingComment$2(precedingNode, comment);
  9655. return true;
  9656. }
  9657. return false;
  9658. }
  9659. function handleImportSpecifierComments(enclosingNode, comment) {
  9660. if (enclosingNode && enclosingNode.type === "ImportSpecifier") {
  9661. addLeadingComment$2(enclosingNode, comment);
  9662. return true;
  9663. }
  9664. return false;
  9665. }
  9666. function handleLabeledStatementComments(enclosingNode, comment) {
  9667. if (enclosingNode && enclosingNode.type === "LabeledStatement") {
  9668. addLeadingComment$2(enclosingNode, comment);
  9669. return true;
  9670. }
  9671. return false;
  9672. }
  9673. function handleBreakAndContinueStatementComments(enclosingNode, comment) {
  9674. if (enclosingNode && (enclosingNode.type === "ContinueStatement" || enclosingNode.type === "BreakStatement") && !enclosingNode.label) {
  9675. addTrailingComment$2(enclosingNode, comment);
  9676. return true;
  9677. }
  9678. return false;
  9679. }
  9680. function handleCallExpressionComments(precedingNode, enclosingNode, comment) {
  9681. if (enclosingNode && enclosingNode.type === "CallExpression" && precedingNode && enclosingNode.callee === precedingNode && enclosingNode.arguments.length > 0) {
  9682. addLeadingComment$2(enclosingNode.arguments[0], comment);
  9683. return true;
  9684. }
  9685. return false;
  9686. }
  9687. function handleUnionTypeComments(precedingNode, enclosingNode, followingNode, comment) {
  9688. if (enclosingNode && (enclosingNode.type === "UnionTypeAnnotation" || enclosingNode.type === "TSUnionType")) {
  9689. addTrailingComment$2(precedingNode, comment);
  9690. return true;
  9691. }
  9692. return false;
  9693. }
  9694. function handlePropertyComments(enclosingNode, comment) {
  9695. if (enclosingNode && (enclosingNode.type === "Property" || enclosingNode.type === "ObjectProperty")) {
  9696. addLeadingComment$2(enclosingNode, comment);
  9697. return true;
  9698. }
  9699. return false;
  9700. }
  9701. function handleOnlyComments(enclosingNode, ast, comment, isLastComment) {
  9702. // With Flow the enclosingNode is undefined so use the AST instead.
  9703. if (ast && ast.body && ast.body.length === 0) {
  9704. if (isLastComment) {
  9705. addDanglingComment$2(ast, comment);
  9706. } else {
  9707. addLeadingComment$2(ast, comment);
  9708. }
  9709. return true;
  9710. } else if (enclosingNode && enclosingNode.type === "Program" && enclosingNode.body.length === 0 && enclosingNode.directives && enclosingNode.directives.length === 0) {
  9711. if (isLastComment) {
  9712. addDanglingComment$2(enclosingNode, comment);
  9713. } else {
  9714. addLeadingComment$2(enclosingNode, comment);
  9715. }
  9716. return true;
  9717. }
  9718. return false;
  9719. }
  9720. function handleForComments(enclosingNode, precedingNode, comment) {
  9721. if (enclosingNode && (enclosingNode.type === "ForInStatement" || enclosingNode.type === "ForOfStatement")) {
  9722. addLeadingComment$2(enclosingNode, comment);
  9723. return true;
  9724. }
  9725. return false;
  9726. }
  9727. function handleImportDeclarationComments(text, enclosingNode, precedingNode, comment, options) {
  9728. if (precedingNode && enclosingNode && enclosingNode.type === "ImportDeclaration" && util.hasNewline(text, options.locEnd(comment))) {
  9729. addTrailingComment$2(precedingNode, comment);
  9730. return true;
  9731. }
  9732. return false;
  9733. }
  9734. function handleAssignmentPatternComments(enclosingNode, comment) {
  9735. if (enclosingNode && enclosingNode.type === "AssignmentPattern") {
  9736. addLeadingComment$2(enclosingNode, comment);
  9737. return true;
  9738. }
  9739. return false;
  9740. }
  9741. function handleTypeAliasComments(enclosingNode, followingNode, comment) {
  9742. if (enclosingNode && enclosingNode.type === "TypeAlias") {
  9743. addLeadingComment$2(enclosingNode, comment);
  9744. return true;
  9745. }
  9746. return false;
  9747. }
  9748. function handleVariableDeclaratorComments(enclosingNode, followingNode, comment) {
  9749. if (enclosingNode && (enclosingNode.type === "VariableDeclarator" || enclosingNode.type === "AssignmentExpression") && followingNode && (followingNode.type === "ObjectExpression" || followingNode.type === "ArrayExpression" || followingNode.type === "TemplateLiteral" || followingNode.type === "TaggedTemplateExpression")) {
  9750. addLeadingComment$2(followingNode, comment);
  9751. return true;
  9752. }
  9753. return false;
  9754. }
  9755. function handleTSMappedTypeComments(text, enclosingNode, precedingNode, followingNode, comment) {
  9756. if (!enclosingNode || enclosingNode.type !== "TSMappedType") {
  9757. return false;
  9758. }
  9759. if (followingNode && followingNode.type === "TSTypeParameter" && followingNode.name) {
  9760. addLeadingComment$2(followingNode.name, comment);
  9761. return true;
  9762. }
  9763. if (precedingNode && precedingNode.type === "TSTypeParameter" && precedingNode.constraint) {
  9764. addTrailingComment$2(precedingNode.constraint, comment);
  9765. return true;
  9766. }
  9767. return false;
  9768. }
  9769. function isBlockComment(comment) {
  9770. return comment.type === "Block" || comment.type === "CommentBlock";
  9771. }
  9772. var comments$3 = {
  9773. handleOwnLineComment: handleOwnLineComment,
  9774. handleEndOfLineComment: handleEndOfLineComment,
  9775. handleRemainingComment: handleRemainingComment,
  9776. isBlockComment: isBlockComment
  9777. };
  9778. function hasClosureCompilerTypeCastComment(text, path, locStart, locEnd) {
  9779. // https://github.com/google/closure-compiler/wiki/Annotating-Types#type-casts
  9780. // Syntax example: var x = /** @type {string} */ (fruit);
  9781. var n = path.getValue();
  9782. return util.getNextNonSpaceNonCommentCharacter(text, n, locEnd) === ")" && (hasTypeCastComment(n) || hasAncestorTypeCastComment(0)); // for sub-item: /** @type {array} */ (numberOrString).map(x => x);
  9783. function hasAncestorTypeCastComment(index) {
  9784. var ancestor = path.getParentNode(index);
  9785. return ancestor && util.getNextNonSpaceNonCommentCharacter(text, ancestor, locEnd) !== ")" && /^[\s(]*$/.test(text.slice(locStart(ancestor), locStart(n))) ? hasTypeCastComment(ancestor) || hasAncestorTypeCastComment(index + 1) : false;
  9786. }
  9787. function hasTypeCastComment(node) {
  9788. return node.comments && node.comments.some(function (comment) {
  9789. return comment.leading && comments$3.isBlockComment(comment) && comment.value.match(/^\*\s*@type\s*{[^}]+}\s*$/) && util.getNextNonSpaceNonCommentCharacter(text, comment, locEnd) === "(";
  9790. });
  9791. }
  9792. }
  9793. function needsParens(path, options) {
  9794. var parent = path.getParentNode();
  9795. if (!parent) {
  9796. return false;
  9797. }
  9798. var name = path.getName();
  9799. var node = path.getNode(); // If the value of this path is some child of a Node and not a Node
  9800. // itself, then it doesn't need parentheses. Only Node objects (in
  9801. // fact, only Expression nodes) need parentheses.
  9802. if (path.getValue() !== node) {
  9803. return false;
  9804. } // Only statements don't need parentheses.
  9805. if (isStatement(node)) {
  9806. return false;
  9807. } // Closure compiler requires that type casted expressions to be surrounded by
  9808. // parentheses.
  9809. if (hasClosureCompilerTypeCastComment(options.originalText, path, options.locStart, options.locEnd)) {
  9810. return true;
  9811. } // Identifiers never need parentheses.
  9812. if (node.type === "Identifier") {
  9813. return false;
  9814. }
  9815. if (parent.type === "ParenthesizedExpression") {
  9816. return false;
  9817. } // Add parens around the extends clause of a class. It is needed for almost
  9818. // all expressions.
  9819. if ((parent.type === "ClassDeclaration" || parent.type === "ClassExpression") && parent.superClass === node && (node.type === "ArrowFunctionExpression" || node.type === "AssignmentExpression" || node.type === "AwaitExpression" || node.type === "BinaryExpression" || node.type === "ConditionalExpression" || node.type === "LogicalExpression" || node.type === "NewExpression" || node.type === "ObjectExpression" || node.type === "ParenthesizedExpression" || node.type === "SequenceExpression" || node.type === "TaggedTemplateExpression" || node.type === "UnaryExpression" || node.type === "UpdateExpression" || node.type === "YieldExpression")) {
  9820. return true;
  9821. }
  9822. if (parent.type === "ArrowFunctionExpression" && parent.body === node && node.type !== "SequenceExpression" && // these have parens added anyway
  9823. util.startsWithNoLookaheadToken(node,
  9824. /* forbidFunctionClassAndDoExpr */
  9825. false) || parent.type === "ExpressionStatement" && util.startsWithNoLookaheadToken(node,
  9826. /* forbidFunctionClassAndDoExpr */
  9827. true)) {
  9828. return true;
  9829. }
  9830. switch (node.type) {
  9831. case "CallExpression":
  9832. {
  9833. var firstParentNotMemberExpression = parent;
  9834. var i = 0;
  9835. while (firstParentNotMemberExpression && firstParentNotMemberExpression.type === "MemberExpression") {
  9836. firstParentNotMemberExpression = path.getParentNode(++i);
  9837. }
  9838. if (firstParentNotMemberExpression.type === "NewExpression" && firstParentNotMemberExpression.callee === path.getParentNode(i - 1)) {
  9839. return true;
  9840. }
  9841. return false;
  9842. }
  9843. case "SpreadElement":
  9844. case "SpreadProperty":
  9845. return parent.type === "MemberExpression" && name === "object" && parent.object === node;
  9846. case "UpdateExpression":
  9847. if (parent.type === "UnaryExpression") {
  9848. return node.prefix && (node.operator === "++" && parent.operator === "+" || node.operator === "--" && parent.operator === "-");
  9849. }
  9850. // else fallthrough
  9851. case "UnaryExpression":
  9852. switch (parent.type) {
  9853. case "UnaryExpression":
  9854. return node.operator === parent.operator && (node.operator === "+" || node.operator === "-");
  9855. case "MemberExpression":
  9856. return name === "object" && parent.object === node;
  9857. case "TaggedTemplateExpression":
  9858. return true;
  9859. case "NewExpression":
  9860. case "CallExpression":
  9861. return name === "callee" && parent.callee === node;
  9862. case "BinaryExpression":
  9863. return parent.operator === "**" && name === "left";
  9864. case "TSNonNullExpression":
  9865. return true;
  9866. default:
  9867. return false;
  9868. }
  9869. case "BinaryExpression":
  9870. {
  9871. if (parent.type === "UpdateExpression") {
  9872. return true;
  9873. }
  9874. var isLeftOfAForStatement = function isLeftOfAForStatement(node) {
  9875. var i = 0;
  9876. while (node) {
  9877. var _parent = path.getParentNode(i++);
  9878. if (!_parent) {
  9879. return false;
  9880. }
  9881. if (_parent.type === "ForStatement" && _parent.init === node) {
  9882. return true;
  9883. }
  9884. node = _parent;
  9885. }
  9886. return false;
  9887. };
  9888. if (node.operator === "in" && isLeftOfAForStatement(node)) {
  9889. return true;
  9890. }
  9891. }
  9892. // fallthrough
  9893. case "TSTypeAssertionExpression":
  9894. case "TSAsExpression":
  9895. case "LogicalExpression":
  9896. switch (parent.type) {
  9897. case "ConditionalExpression":
  9898. return node.type === "TSAsExpression";
  9899. case "CallExpression":
  9900. case "NewExpression":
  9901. return name === "callee" && parent.callee === node;
  9902. case "ClassDeclaration":
  9903. case "TSAbstractClassDeclaration":
  9904. return name === "superClass" && parent.superClass === node;
  9905. case "TSTypeAssertionExpression":
  9906. case "TaggedTemplateExpression":
  9907. case "UnaryExpression":
  9908. case "SpreadElement":
  9909. case "SpreadProperty":
  9910. case "ExperimentalSpreadProperty":
  9911. case "BindExpression":
  9912. case "AwaitExpression":
  9913. case "TSAsExpression":
  9914. case "TSNonNullExpression":
  9915. case "UpdateExpression":
  9916. return true;
  9917. case "MemberExpression":
  9918. return name === "object" && parent.object === node;
  9919. case "AssignmentExpression":
  9920. return parent.left === node && (node.type === "TSTypeAssertionExpression" || node.type === "TSAsExpression");
  9921. case "Decorator":
  9922. return parent.expression === node && (node.type === "TSTypeAssertionExpression" || node.type === "TSAsExpression");
  9923. case "BinaryExpression":
  9924. case "LogicalExpression":
  9925. {
  9926. if (!node.operator && node.type !== "TSTypeAssertionExpression") {
  9927. return true;
  9928. }
  9929. var po = parent.operator;
  9930. var pp = util.getPrecedence(po);
  9931. var no = node.operator;
  9932. var np = util.getPrecedence(no);
  9933. if (pp > np) {
  9934. return true;
  9935. }
  9936. if ((po === "||" || po === "??") && no === "&&") {
  9937. return true;
  9938. }
  9939. if (pp === np && name === "right") {
  9940. assert.strictEqual(parent.right, node);
  9941. return true;
  9942. }
  9943. if (pp === np && !util.shouldFlatten(po, no)) {
  9944. return true;
  9945. }
  9946. if (pp < np && no === "%") {
  9947. return !util.shouldFlatten(po, no);
  9948. } // Add parenthesis when working with binary operators
  9949. // It's not stricly needed but helps with code understanding
  9950. if (util.isBitwiseOperator(po)) {
  9951. return true;
  9952. }
  9953. return false;
  9954. }
  9955. default:
  9956. return false;
  9957. }
  9958. case "TSParenthesizedType":
  9959. {
  9960. var grandParent = path.getParentNode(1);
  9961. if ((parent.type === "TSTypeParameter" || parent.type === "TypeParameter" || parent.type === "VariableDeclarator" || parent.type === "TSTypeAnnotation" || parent.type === "GenericTypeAnnotation" || parent.type === "TSTypeReference") && node.typeAnnotation.type === "TSTypeAnnotation" && node.typeAnnotation.typeAnnotation.type !== "TSFunctionType" && grandParent.type !== "TSTypeOperator") {
  9962. return false;
  9963. } // Delegate to inner TSParenthesizedType
  9964. if (node.typeAnnotation.type === "TSParenthesizedType") {
  9965. return false;
  9966. }
  9967. return true;
  9968. }
  9969. case "SequenceExpression":
  9970. switch (parent.type) {
  9971. case "ReturnStatement":
  9972. return false;
  9973. case "ForStatement":
  9974. // Although parentheses wouldn't hurt around sequence
  9975. // expressions in the head of for loops, traditional style
  9976. // dictates that e.g. i++, j++ should not be wrapped with
  9977. // parentheses.
  9978. return false;
  9979. case "ExpressionStatement":
  9980. return name !== "expression";
  9981. case "ArrowFunctionExpression":
  9982. // We do need parentheses, but SequenceExpressions are handled
  9983. // specially when printing bodies of arrow functions.
  9984. return name !== "body";
  9985. default:
  9986. // Otherwise err on the side of overparenthesization, adding
  9987. // explicit exceptions above if this proves overzealous.
  9988. return true;
  9989. }
  9990. case "YieldExpression":
  9991. if (parent.type === "UnaryExpression" || parent.type === "AwaitExpression" || parent.type === "TSAsExpression" || parent.type === "TSNonNullExpression") {
  9992. return true;
  9993. }
  9994. // else fallthrough
  9995. case "AwaitExpression":
  9996. switch (parent.type) {
  9997. case "TaggedTemplateExpression":
  9998. case "UnaryExpression":
  9999. case "BinaryExpression":
  10000. case "LogicalExpression":
  10001. case "SpreadElement":
  10002. case "SpreadProperty":
  10003. case "ExperimentalSpreadProperty":
  10004. case "TSAsExpression":
  10005. case "TSNonNullExpression":
  10006. return true;
  10007. case "MemberExpression":
  10008. return parent.object === node;
  10009. case "NewExpression":
  10010. case "CallExpression":
  10011. return parent.callee === node;
  10012. case "ConditionalExpression":
  10013. return parent.test === node;
  10014. default:
  10015. return false;
  10016. }
  10017. case "ArrayTypeAnnotation":
  10018. return parent.type === "NullableTypeAnnotation";
  10019. case "IntersectionTypeAnnotation":
  10020. case "UnionTypeAnnotation":
  10021. return parent.type === "ArrayTypeAnnotation" || parent.type === "NullableTypeAnnotation" || parent.type === "IntersectionTypeAnnotation" || parent.type === "UnionTypeAnnotation";
  10022. case "NullableTypeAnnotation":
  10023. return parent.type === "ArrayTypeAnnotation";
  10024. case "FunctionTypeAnnotation":
  10025. {
  10026. var ancestor = parent.type === "NullableTypeAnnotation" ? path.getParentNode(1) : parent;
  10027. return ancestor.type === "UnionTypeAnnotation" || ancestor.type === "IntersectionTypeAnnotation" || ancestor.type === "ArrayTypeAnnotation" || // We should check ancestor's parent to know whether the parentheses
  10028. // are really needed, but since ??T doesn't make sense this check
  10029. // will almost never be true.
  10030. ancestor.type === "NullableTypeAnnotation";
  10031. }
  10032. case "StringLiteral":
  10033. case "NumericLiteral":
  10034. case "Literal":
  10035. if (typeof node.value === "string" && parent.type === "ExpressionStatement" && ( // TypeScript workaround for eslint/typescript-eslint-parser#267
  10036. // See corresponding workaround in printer.js case: "Literal"
  10037. options.parser !== "typescript" && !parent.directive || options.parser === "typescript" && options.originalText.substr(options.locStart(node) - 1, 1) === "(")) {
  10038. // To avoid becoming a directive
  10039. var _grandParent = path.getParentNode(1);
  10040. return _grandParent.type === "Program" || _grandParent.type === "BlockStatement";
  10041. }
  10042. return parent.type === "MemberExpression" && typeof node.value === "number" && name === "object" && parent.object === node;
  10043. case "AssignmentExpression":
  10044. {
  10045. var _grandParent2 = path.getParentNode(1);
  10046. if (parent.type === "ArrowFunctionExpression" && parent.body === node) {
  10047. return true;
  10048. } else if (parent.type === "ClassProperty" && parent.key === node && parent.computed) {
  10049. return false;
  10050. } else if (parent.type === "TSPropertySignature" && parent.name === node) {
  10051. return false;
  10052. } else if (parent.type === "ForStatement" && (parent.init === node || parent.update === node)) {
  10053. return false;
  10054. } else if (parent.type === "ExpressionStatement") {
  10055. return node.left.type === "ObjectPattern";
  10056. } else if (parent.type === "TSPropertySignature" && parent.key === node) {
  10057. return false;
  10058. } else if (parent.type === "AssignmentExpression") {
  10059. return false;
  10060. } else if (parent.type === "SequenceExpression" && _grandParent2 && _grandParent2.type === "ForStatement" && (_grandParent2.init === parent || _grandParent2.update === parent)) {
  10061. return false;
  10062. }
  10063. return true;
  10064. }
  10065. case "ConditionalExpression":
  10066. switch (parent.type) {
  10067. case "TaggedTemplateExpression":
  10068. case "UnaryExpression":
  10069. case "SpreadElement":
  10070. case "SpreadProperty":
  10071. case "ExperimentalSpreadProperty":
  10072. case "BinaryExpression":
  10073. case "LogicalExpression":
  10074. case "ExportDefaultDeclaration":
  10075. case "AwaitExpression":
  10076. case "JSXSpreadAttribute":
  10077. case "TSTypeAssertionExpression":
  10078. case "TypeCastExpression":
  10079. case "TSAsExpression":
  10080. case "TSNonNullExpression":
  10081. return true;
  10082. case "NewExpression":
  10083. case "CallExpression":
  10084. return name === "callee" && parent.callee === node;
  10085. case "ConditionalExpression":
  10086. return name === "test" && parent.test === node;
  10087. case "MemberExpression":
  10088. return name === "object" && parent.object === node;
  10089. default:
  10090. return false;
  10091. }
  10092. case "FunctionExpression":
  10093. switch (parent.type) {
  10094. case "CallExpression":
  10095. return name === "callee";
  10096. // Not strictly necessary, but it's clearer to the reader if IIFEs are wrapped in parentheses.
  10097. case "TaggedTemplateExpression":
  10098. return true;
  10099. // This is basically a kind of IIFE.
  10100. case "ExportDefaultDeclaration":
  10101. return true;
  10102. default:
  10103. return false;
  10104. }
  10105. case "ArrowFunctionExpression":
  10106. switch (parent.type) {
  10107. case "CallExpression":
  10108. return name === "callee";
  10109. case "NewExpression":
  10110. return name === "callee";
  10111. case "MemberExpression":
  10112. return name === "object";
  10113. case "TSAsExpression":
  10114. case "BindExpression":
  10115. case "TaggedTemplateExpression":
  10116. case "UnaryExpression":
  10117. case "LogicalExpression":
  10118. case "BinaryExpression":
  10119. case "AwaitExpression":
  10120. case "TSTypeAssertionExpression":
  10121. return true;
  10122. case "ConditionalExpression":
  10123. return name === "test";
  10124. default:
  10125. return false;
  10126. }
  10127. case "ClassExpression":
  10128. return parent.type === "ExportDefaultDeclaration";
  10129. case "OptionalMemberExpression":
  10130. return parent.type === "MemberExpression";
  10131. }
  10132. return false;
  10133. }
  10134. function isStatement(node) {
  10135. return node.type === "BlockStatement" || node.type === "BreakStatement" || node.type === "ClassBody" || node.type === "ClassDeclaration" || node.type === "ClassMethod" || node.type === "ClassProperty" || node.type === "ClassPrivateProperty" || node.type === "ContinueStatement" || node.type === "DebuggerStatement" || node.type === "DeclareClass" || node.type === "DeclareExportAllDeclaration" || node.type === "DeclareExportDeclaration" || node.type === "DeclareFunction" || node.type === "DeclareInterface" || node.type === "DeclareModule" || node.type === "DeclareModuleExports" || node.type === "DeclareVariable" || node.type === "DoWhileStatement" || node.type === "ExportAllDeclaration" || node.type === "ExportDefaultDeclaration" || node.type === "ExportNamedDeclaration" || node.type === "ExpressionStatement" || node.type === "ForAwaitStatement" || node.type === "ForInStatement" || node.type === "ForOfStatement" || node.type === "ForStatement" || node.type === "FunctionDeclaration" || node.type === "IfStatement" || node.type === "ImportDeclaration" || node.type === "InterfaceDeclaration" || node.type === "LabeledStatement" || node.type === "MethodDefinition" || node.type === "ReturnStatement" || node.type === "SwitchStatement" || node.type === "ThrowStatement" || node.type === "TryStatement" || node.type === "TSAbstractClassDeclaration" || 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";
  10136. }
  10137. var needsParens_1 = needsParens;
  10138. var getParentExportDeclaration$1 = util.getParentExportDeclaration;
  10139. var isExportDeclaration$1 = util.isExportDeclaration;
  10140. var shouldFlatten$1 = util.shouldFlatten;
  10141. var getNextNonSpaceNonCommentCharacter$1 = util.getNextNonSpaceNonCommentCharacter;
  10142. var hasNewline$2 = util.hasNewline;
  10143. var hasNewlineInRange$1 = util.hasNewlineInRange;
  10144. var getLast$4 = util.getLast;
  10145. var getStringWidth$1 = util.getStringWidth;
  10146. var printString$1 = util.printString;
  10147. var printNumber$1 = util.printNumber;
  10148. var hasIgnoreComment$1 = util.hasIgnoreComment;
  10149. var skipWhitespace$1 = util.skipWhitespace;
  10150. var hasNodeIgnoreComment$1 = util.hasNodeIgnoreComment;
  10151. var getPenultimate$1 = util.getPenultimate;
  10152. var startsWithNoLookaheadToken$1 = util.startsWithNoLookaheadToken;
  10153. var getIndentSize$1 = util.getIndentSize;
  10154. var isNextLineEmpty$2 = utilShared.isNextLineEmpty;
  10155. var isNextLineEmptyAfterIndex$1 = utilShared.isNextLineEmptyAfterIndex;
  10156. var getNextNonSpaceNonCommentCharacterIndex$2 = utilShared.getNextNonSpaceNonCommentCharacterIndex;
  10157. var isIdentifierName = utils.keyword.isIdentifierNameES6;
  10158. var insertPragma = pragma.insertPragma;
  10159. var _require$$4$builders = doc.builders;
  10160. var concat$4 = _require$$4$builders.concat;
  10161. var join$2 = _require$$4$builders.join;
  10162. var line$3 = _require$$4$builders.line;
  10163. var hardline$3 = _require$$4$builders.hardline;
  10164. var softline$1 = _require$$4$builders.softline;
  10165. var literalline$1 = _require$$4$builders.literalline;
  10166. var group$1 = _require$$4$builders.group;
  10167. var indent$2 = _require$$4$builders.indent;
  10168. var align$1 = _require$$4$builders.align;
  10169. var conditionalGroup$1 = _require$$4$builders.conditionalGroup;
  10170. var fill$2 = _require$$4$builders.fill;
  10171. var ifBreak$1 = _require$$4$builders.ifBreak;
  10172. var breakParent$2 = _require$$4$builders.breakParent;
  10173. var lineSuffixBoundary$1 = _require$$4$builders.lineSuffixBoundary;
  10174. var addAlignmentToDoc$2 = _require$$4$builders.addAlignmentToDoc;
  10175. var dedent$2 = _require$$4$builders.dedent;
  10176. var _require$$4$utils = doc.utils;
  10177. var willBreak$1 = _require$$4$utils.willBreak;
  10178. var isLineNext$1 = _require$$4$utils.isLineNext;
  10179. var isEmpty$1 = _require$$4$utils.isEmpty;
  10180. var removeLines$1 = _require$$4$utils.removeLines;
  10181. var printDocToString$1 = doc.printer.printDocToString;
  10182. function shouldPrintComma(options, level) {
  10183. level = level || "es5";
  10184. switch (options.trailingComma) {
  10185. case "all":
  10186. if (level === "all") {
  10187. return true;
  10188. }
  10189. // fallthrough
  10190. case "es5":
  10191. if (level === "es5") {
  10192. return true;
  10193. }
  10194. // fallthrough
  10195. case "none":
  10196. default:
  10197. return false;
  10198. }
  10199. }
  10200. function genericPrint$1(path, options, printPath, args) {
  10201. var node = path.getValue();
  10202. var needsParens = false;
  10203. var linesWithoutParens = printPathNoParens(path, options, printPath, args);
  10204. if (!node || isEmpty$1(linesWithoutParens)) {
  10205. return linesWithoutParens;
  10206. }
  10207. var decorators = [];
  10208. if (node.decorators && node.decorators.length > 0 && // If the parent node is an export declaration, it will be
  10209. // responsible for printing node.decorators.
  10210. !getParentExportDeclaration$1(path)) {
  10211. var separator = hardline$3;
  10212. path.each(function (decoratorPath) {
  10213. var decorator = decoratorPath.getValue();
  10214. if (decorator.expression) {
  10215. decorator = decorator.expression;
  10216. } else {
  10217. decorator = decorator.callee;
  10218. }
  10219. if (node.decorators.length === 1 && node.type !== "ClassDeclaration" && node.type !== "MethodDefinition" && node.type !== "ClassMethod" && (decorator.type === "Identifier" || decorator.type === "MemberExpression" || decorator.type === "OptionalMemberExpression" || (decorator.type === "CallExpression" || decorator.type === "OptionalCallExpression") && (decorator.arguments.length === 0 || decorator.arguments.length === 1 && (isStringLiteral(decorator.arguments[0]) || decorator.arguments[0].type === "Identifier" || decorator.arguments[0].type === "MemberExpression" || decorator.arguments[0].type === "OptionalMemberExpression")))) {
  10220. separator = line$3;
  10221. }
  10222. decorators.push(printPath(decoratorPath), separator);
  10223. }, "decorators");
  10224. } else if (isExportDeclaration$1(node) && node.declaration && node.declaration.decorators) {
  10225. // Export declarations are responsible for printing any decorators
  10226. // that logically apply to node.declaration.
  10227. path.each(function (decoratorPath) {
  10228. var decorator = decoratorPath.getValue();
  10229. var prefix = decorator.type === "Decorator" ? "" : "@";
  10230. decorators.push(prefix, printPath(decoratorPath), hardline$3);
  10231. }, "declaration", "decorators");
  10232. } else {
  10233. // Nodes with decorators can't have parentheses, so we can avoid
  10234. // computing pathNeedsParens() except in this case.
  10235. needsParens = needsParens_1(path, options);
  10236. }
  10237. var parts = [];
  10238. if (needsParens) {
  10239. parts.unshift("(");
  10240. }
  10241. parts.push(linesWithoutParens);
  10242. if (needsParens) {
  10243. parts.push(")");
  10244. }
  10245. if (decorators.length > 0) {
  10246. return group$1(concat$4(decorators.concat(parts)));
  10247. }
  10248. return concat$4(parts);
  10249. }
  10250. function hasPrettierIgnore(path) {
  10251. return hasIgnoreComment$1(path) || hasJsxIgnoreComment(path);
  10252. }
  10253. function hasJsxIgnoreComment(path) {
  10254. var node = path.getValue();
  10255. var parent = path.getParentNode();
  10256. if (!parent || !node || !isJSXNode(node) || !isJSXNode(parent)) {
  10257. return false;
  10258. } // Lookup the previous sibling, ignoring any empty JSXText elements
  10259. var index = parent.children.indexOf(node);
  10260. var prevSibling = null;
  10261. for (var i = index; i > 0; i--) {
  10262. var candidate = parent.children[i - 1];
  10263. if (candidate.type === "JSXText" && !isMeaningfulJSXText(candidate)) {
  10264. continue;
  10265. }
  10266. prevSibling = candidate;
  10267. break;
  10268. }
  10269. return prevSibling && prevSibling.type === "JSXExpressionContainer" && prevSibling.expression.type === "JSXEmptyExpression" && prevSibling.expression.comments && prevSibling.expression.comments.find(function (comment) {
  10270. return comment.value.trim() === "prettier-ignore";
  10271. });
  10272. } // The following is the shared logic for
  10273. // ternary operators, namely ConditionalExpression
  10274. // and TSConditionalType
  10275. function formatTernaryOperator(path, options, print, operatorOptions) {
  10276. var n = path.getValue();
  10277. var parts = [];
  10278. var operatorOpts = Object.assign({
  10279. beforeParts: function beforeParts() {
  10280. return [""];
  10281. },
  10282. afterParts: function afterParts() {
  10283. return [""];
  10284. },
  10285. shouldCheckJsx: true,
  10286. operatorName: "ConditionalExpression",
  10287. consequentNode: "consequent",
  10288. alternateNode: "alternate",
  10289. testNode: "test",
  10290. breakNested: true
  10291. }, operatorOptions || {}); // We print a ConditionalExpression in either "JSX mode" or "normal mode".
  10292. // See tests/jsx/conditional-expression.js for more info.
  10293. var jsxMode = false;
  10294. var parent = path.getParentNode();
  10295. var forceNoIndent = parent.type === operatorOpts.operatorName; // Find the outermost non-ConditionalExpression parent, and the outermost
  10296. // ConditionalExpression parent. We'll use these to determine if we should
  10297. // print in JSX mode.
  10298. var currentParent;
  10299. var previousParent;
  10300. var i = 0;
  10301. do {
  10302. previousParent = currentParent || n;
  10303. currentParent = path.getParentNode(i);
  10304. i++;
  10305. } while (currentParent && currentParent.type === operatorOpts.operatorName);
  10306. var firstNonConditionalParent = currentParent || parent;
  10307. var lastConditionalParent = previousParent;
  10308. if (operatorOpts.shouldCheckJsx && isJSXNode(n[operatorOpts.testNode]) || isJSXNode(n[operatorOpts.consequentNode]) || isJSXNode(n[operatorOpts.alternateNode]) || conditionalExpressionChainContainsJSX(lastConditionalParent)) {
  10309. jsxMode = true;
  10310. forceNoIndent = true; // Even though they don't need parens, we wrap (almost) everything in
  10311. // parens when using ?: within JSX, because the parens are analogous to
  10312. // curly braces in an if statement.
  10313. var wrap = function wrap(doc$$2) {
  10314. return concat$4([ifBreak$1("(", ""), indent$2(concat$4([softline$1, doc$$2])), softline$1, ifBreak$1(")", "")]);
  10315. }; // The only things we don't wrap are:
  10316. // * Nested conditional expressions in alternates
  10317. // * null
  10318. var isNull = function isNull(node) {
  10319. return node.type === "NullLiteral" || node.type === "Literal" && node.value === null;
  10320. };
  10321. parts.push(" ? ", isNull(n[operatorOpts.consequentNode]) ? path.call(print, operatorOpts.consequentNode) : wrap(path.call(print, operatorOpts.consequentNode)), " : ", n[operatorOpts.alternateNode].type === operatorOpts.operatorName || isNull(n[operatorOpts.alternateNode]) ? path.call(print, operatorOpts.alternateNode) : wrap(path.call(print, operatorOpts.alternateNode)));
  10322. } else {
  10323. // normal mode
  10324. var part = concat$4([line$3, "? ", n[operatorOpts.consequentNode].type === operatorOpts.operatorName ? ifBreak$1("", "(") : "", align$1(2, path.call(print, operatorOpts.consequentNode)), n[operatorOpts.consequentNode].type === operatorOpts.operatorName ? ifBreak$1("", ")") : "", line$3, ": ", align$1(2, path.call(print, operatorOpts.alternateNode))]);
  10325. parts.push(parent.type === operatorOpts.operatorName ? options.useTabs ? dedent$2(indent$2(part)) : align$1(Math.max(0, options.tabWidth - 2), part) : part);
  10326. } // We want a whole chain of ConditionalExpressions to all
  10327. // break if any of them break. That means we should only group around the
  10328. // outer-most ConditionalExpression.
  10329. var maybeGroup = function maybeGroup(doc$$2) {
  10330. return operatorOpts.breakNested ? parent === firstNonConditionalParent ? group$1(doc$$2) : doc$$2 : group$1(doc$$2);
  10331. }; // Always group in normal mode.
  10332. // Break the closing paren to keep the chain right after it:
  10333. // (a
  10334. // ? b
  10335. // : c
  10336. // ).call()
  10337. var breakClosingParen = !jsxMode && (parent.type === "MemberExpression" || parent.type === "OptionalMemberExpression") && !parent.computed;
  10338. return maybeGroup(concat$4([].concat(operatorOpts.beforeParts(), forceNoIndent ? concat$4(parts) : indent$2(concat$4(parts)), operatorOpts.afterParts(breakClosingParen))));
  10339. }
  10340. function getTypeScriptMappedTypeModifier(tokenNode, keyword) {
  10341. if (tokenNode.type === "TSPlusToken") {
  10342. return "+" + keyword;
  10343. } else if (tokenNode.type === "TSMinusToken") {
  10344. return "-" + keyword;
  10345. }
  10346. return keyword;
  10347. }
  10348. function printPathNoParens(path, options, print, args) {
  10349. var n = path.getValue();
  10350. var semi = options.semi ? ";" : "";
  10351. if (!n) {
  10352. return "";
  10353. }
  10354. if (typeof n === "string") {
  10355. return n;
  10356. }
  10357. var parts = [];
  10358. switch (n.type) {
  10359. case "File":
  10360. // Print @babel/parser's InterpreterDirective here so that
  10361. // leading comments on the `Program` node get printed after the hashbang.
  10362. if (n.program && n.program.interpreter) {
  10363. parts.push(path.call(function (programPath) {
  10364. return programPath.call(print, "interpreter");
  10365. }, "program"));
  10366. }
  10367. parts.push(path.call(print, "program"));
  10368. return concat$4(parts);
  10369. case "Program":
  10370. // Babel 6
  10371. if (n.directives) {
  10372. path.each(function (childPath) {
  10373. parts.push(print(childPath), semi, hardline$3);
  10374. if (isNextLineEmpty$2(options.originalText, childPath.getValue(), options)) {
  10375. parts.push(hardline$3);
  10376. }
  10377. }, "directives");
  10378. }
  10379. parts.push(path.call(function (bodyPath) {
  10380. return printStatementSequence(bodyPath, options, print);
  10381. }, "body"));
  10382. parts.push(comments.printDanglingComments(path, options,
  10383. /* sameIndent */
  10384. true)); // Only force a trailing newline if there were any contents.
  10385. if (n.body.length || n.comments) {
  10386. parts.push(hardline$3);
  10387. }
  10388. return concat$4(parts);
  10389. // Babel extension.
  10390. case "EmptyStatement":
  10391. return "";
  10392. case "ExpressionStatement":
  10393. // Detect Flow-parsed directives
  10394. if (n.directive) {
  10395. return concat$4([nodeStr(n.expression, options, true), semi]);
  10396. } // Do not append semicolon after the only JSX element in a program
  10397. return concat$4([path.call(print, "expression"), isTheOnlyJSXElementInMarkdown(options, path) ? "" : semi]);
  10398. // Babel extension.
  10399. case "ParenthesizedExpression":
  10400. return concat$4(["(", path.call(print, "expression"), ")"]);
  10401. case "AssignmentExpression":
  10402. return printAssignment(n.left, path.call(print, "left"), concat$4([" ", n.operator]), n.right, path.call(print, "right"), options);
  10403. case "BinaryExpression":
  10404. case "LogicalExpression":
  10405. {
  10406. var parent = path.getParentNode();
  10407. var parentParent = path.getParentNode(1);
  10408. var isInsideParenthesis = n !== parent.body && (parent.type === "IfStatement" || parent.type === "WhileStatement" || parent.type === "DoWhileStatement");
  10409. var _parts = printBinaryishExpressions(path, print, options,
  10410. /* isNested */
  10411. false, isInsideParenthesis); // if (
  10412. // this.hasPlugin("dynamicImports") && this.lookahead().type === tt.parenLeft
  10413. // ) {
  10414. //
  10415. // looks super weird, we want to break the children if the parent breaks
  10416. //
  10417. // if (
  10418. // this.hasPlugin("dynamicImports") &&
  10419. // this.lookahead().type === tt.parenLeft
  10420. // ) {
  10421. if (isInsideParenthesis) {
  10422. return concat$4(_parts);
  10423. } // Break between the parens in unaries or in a member expression, i.e.
  10424. //
  10425. // (
  10426. // a &&
  10427. // b &&
  10428. // c
  10429. // ).call()
  10430. if (parent.type === "UnaryExpression" || (parent.type === "MemberExpression" || parent.type === "OptionalMemberExpression") && !parent.computed) {
  10431. return group$1(concat$4([indent$2(concat$4([softline$1, concat$4(_parts)])), softline$1]));
  10432. } // Avoid indenting sub-expressions in some cases where the first sub-expression is already
  10433. // indented accordingly. We should indent sub-expressions where the first case isn't indented.
  10434. var shouldNotIndent = parent.type === "ReturnStatement" || parent.type === "JSXExpressionContainer" && parentParent.type === "JSXAttribute" || n === parent.body && parent.type === "ArrowFunctionExpression" || n !== parent.body && parent.type === "ForStatement" || parent.type === "ConditionalExpression" && parentParent.type !== "ReturnStatement";
  10435. var shouldIndentIfInlining = parent.type === "AssignmentExpression" || parent.type === "VariableDeclarator" || parent.type === "ClassProperty" || parent.type === "TSAbstractClassProperty" || parent.type === "ClassPrivateProperty" || parent.type === "ObjectProperty" || parent.type === "Property";
  10436. var samePrecedenceSubExpression = isBinaryish(n.left) && shouldFlatten$1(n.operator, n.left.operator);
  10437. if (shouldNotIndent || shouldInlineLogicalExpression(n) && !samePrecedenceSubExpression || !shouldInlineLogicalExpression(n) && shouldIndentIfInlining) {
  10438. return group$1(concat$4(_parts));
  10439. }
  10440. var rest = concat$4(_parts.slice(1));
  10441. return group$1(concat$4([// Don't include the initial expression in the indentation
  10442. // level. The first item is guaranteed to be the first
  10443. // left-most expression.
  10444. _parts.length > 0 ? _parts[0] : "", indent$2(rest)]));
  10445. }
  10446. case "AssignmentPattern":
  10447. return concat$4([path.call(print, "left"), " = ", path.call(print, "right")]);
  10448. case "TSTypeAssertionExpression":
  10449. {
  10450. var shouldBreakAfterCast = !(n.expression.type === "ArrayExpression" || n.expression.type === "ObjectExpression");
  10451. var castGroup = group$1(concat$4(["<", indent$2(concat$4([softline$1, path.call(print, "typeAnnotation")])), softline$1, ">"]));
  10452. var exprContents = concat$4([ifBreak$1("("), indent$2(concat$4([softline$1, path.call(print, "expression")])), softline$1, ifBreak$1(")")]);
  10453. if (shouldBreakAfterCast) {
  10454. return conditionalGroup$1([concat$4([castGroup, path.call(print, "expression")]), concat$4([castGroup, group$1(exprContents, {
  10455. shouldBreak: true
  10456. })]), concat$4([castGroup, path.call(print, "expression")])]);
  10457. }
  10458. return group$1(concat$4([castGroup, path.call(print, "expression")]));
  10459. }
  10460. case "OptionalMemberExpression":
  10461. case "MemberExpression":
  10462. {
  10463. var _parent = path.getParentNode();
  10464. var firstNonMemberParent;
  10465. var i = 0;
  10466. do {
  10467. firstNonMemberParent = path.getParentNode(i);
  10468. i++;
  10469. } while (firstNonMemberParent && (firstNonMemberParent.type === "MemberExpression" || firstNonMemberParent.type === "OptionalMemberExpression" || firstNonMemberParent.type === "TSNonNullExpression"));
  10470. var shouldInline = firstNonMemberParent && (firstNonMemberParent.type === "NewExpression" || firstNonMemberParent.type === "BindExpression" || firstNonMemberParent.type === "VariableDeclarator" && firstNonMemberParent.id.type !== "Identifier" || firstNonMemberParent.type === "AssignmentExpression" && firstNonMemberParent.left.type !== "Identifier") || n.computed || n.object.type === "Identifier" && n.property.type === "Identifier" && _parent.type !== "MemberExpression" && _parent.type !== "OptionalMemberExpression";
  10471. return concat$4([path.call(print, "object"), shouldInline ? printMemberLookup(path, options, print) : group$1(indent$2(concat$4([softline$1, printMemberLookup(path, options, print)])))]);
  10472. }
  10473. case "MetaProperty":
  10474. return concat$4([path.call(print, "meta"), ".", path.call(print, "property")]);
  10475. case "BindExpression":
  10476. if (n.object) {
  10477. parts.push(path.call(print, "object"));
  10478. }
  10479. parts.push(group$1(indent$2(concat$4([softline$1, printBindExpressionCallee(path, options, print)]))));
  10480. return concat$4(parts);
  10481. case "Identifier":
  10482. {
  10483. return concat$4([n.name, printOptionalToken(path), printTypeAnnotation(path, options, print)]);
  10484. }
  10485. case "SpreadElement":
  10486. case "SpreadElementPattern":
  10487. case "RestProperty":
  10488. case "ExperimentalRestProperty":
  10489. case "ExperimentalSpreadProperty":
  10490. case "SpreadProperty":
  10491. case "SpreadPropertyPattern":
  10492. case "RestElement":
  10493. case "ObjectTypeSpreadProperty":
  10494. return concat$4(["...", path.call(print, "argument"), printTypeAnnotation(path, options, print)]);
  10495. case "FunctionDeclaration":
  10496. case "FunctionExpression":
  10497. if (isNodeStartingWithDeclare(n, options)) {
  10498. parts.push("declare ");
  10499. }
  10500. parts.push(printFunctionDeclaration(path, print, options));
  10501. if (!n.body) {
  10502. parts.push(semi);
  10503. }
  10504. return concat$4(parts);
  10505. case "ArrowFunctionExpression":
  10506. {
  10507. if (n.async) {
  10508. parts.push("async ");
  10509. }
  10510. if (shouldPrintParamsWithoutParens(path, options)) {
  10511. parts.push(path.call(print, "params", 0));
  10512. } else {
  10513. parts.push(group$1(concat$4([printFunctionParams(path, print, options,
  10514. /* expandLast */
  10515. args && (args.expandLastArg || args.expandFirstArg),
  10516. /* printTypeParams */
  10517. true), printReturnType(path, print, options)])));
  10518. }
  10519. var dangling = comments.printDanglingComments(path, options,
  10520. /* sameIndent */
  10521. true, function (comment) {
  10522. var nextCharacter = getNextNonSpaceNonCommentCharacterIndex$2(options.originalText, comment, options);
  10523. return options.originalText.substr(nextCharacter, 2) === "=>";
  10524. });
  10525. if (dangling) {
  10526. parts.push(" ", dangling);
  10527. }
  10528. parts.push(" =>");
  10529. var body = path.call(function (bodyPath) {
  10530. return print(bodyPath, args);
  10531. }, "body"); // We want to always keep these types of nodes on the same line
  10532. // as the arrow.
  10533. if (!hasLeadingOwnLineComment(options.originalText, n.body, options) && (n.body.type === "ArrayExpression" || n.body.type === "ObjectExpression" || n.body.type === "BlockStatement" || isJSXNode(n.body) || isTemplateOnItsOwnLine(n.body, options.originalText, options) || n.body.type === "ArrowFunctionExpression" || n.body.type === "DoExpression")) {
  10534. return group$1(concat$4([concat$4(parts), " ", body]));
  10535. } // We handle sequence expressions as the body of arrows specially,
  10536. // so that the required parentheses end up on their own lines.
  10537. if (n.body.type === "SequenceExpression") {
  10538. return group$1(concat$4([concat$4(parts), group$1(concat$4([" (", indent$2(concat$4([softline$1, body])), softline$1, ")"]))]));
  10539. } // if the arrow function is expanded as last argument, we are adding a
  10540. // level of indentation and need to add a softline to align the closing )
  10541. // with the opening (, or if it's inside a JSXExpression (e.g. an attribute)
  10542. // we should align the expression's closing } with the line with the opening {.
  10543. var shouldAddSoftLine = (args && args.expandLastArg || path.getParentNode().type === "JSXExpressionContainer") && !(n.comments && n.comments.length);
  10544. var printTrailingComma = args && args.expandLastArg && shouldPrintComma(options, "all"); // In order to avoid confusion between
  10545. // a => a ? a : a
  10546. // a <= a ? a : a
  10547. var shouldAddParens = n.body.type === "ConditionalExpression" && !startsWithNoLookaheadToken$1(n.body,
  10548. /* forbidFunctionAndClass */
  10549. false);
  10550. return group$1(concat$4([concat$4(parts), group$1(concat$4([indent$2(concat$4([line$3, shouldAddParens ? ifBreak$1("", "(") : "", body, shouldAddParens ? ifBreak$1("", ")") : ""])), shouldAddSoftLine ? concat$4([ifBreak$1(printTrailingComma ? "," : ""), softline$1]) : ""]))]));
  10551. }
  10552. case "MethodDefinition":
  10553. case "TSAbstractMethodDefinition":
  10554. if (n.accessibility) {
  10555. parts.push(n.accessibility + " ");
  10556. }
  10557. if (n.static) {
  10558. parts.push("static ");
  10559. }
  10560. if (n.type === "TSAbstractMethodDefinition") {
  10561. parts.push("abstract ");
  10562. }
  10563. parts.push(printMethod(path, options, print));
  10564. return concat$4(parts);
  10565. case "YieldExpression":
  10566. parts.push("yield");
  10567. if (n.delegate) {
  10568. parts.push("*");
  10569. }
  10570. if (n.argument) {
  10571. parts.push(" ", path.call(print, "argument"));
  10572. }
  10573. return concat$4(parts);
  10574. case "AwaitExpression":
  10575. return concat$4(["await ", path.call(print, "argument")]);
  10576. case "ImportSpecifier":
  10577. if (n.importKind) {
  10578. parts.push(path.call(print, "importKind"), " ");
  10579. }
  10580. parts.push(path.call(print, "imported"));
  10581. if (n.local && n.local.name !== n.imported.name) {
  10582. parts.push(" as ", path.call(print, "local"));
  10583. }
  10584. return concat$4(parts);
  10585. case "ExportSpecifier":
  10586. parts.push(path.call(print, "local"));
  10587. if (n.exported && n.exported.name !== n.local.name) {
  10588. parts.push(" as ", path.call(print, "exported"));
  10589. }
  10590. return concat$4(parts);
  10591. case "ImportNamespaceSpecifier":
  10592. parts.push("* as ");
  10593. if (n.local) {
  10594. parts.push(path.call(print, "local"));
  10595. } else if (n.id) {
  10596. parts.push(path.call(print, "id"));
  10597. }
  10598. return concat$4(parts);
  10599. case "ImportDefaultSpecifier":
  10600. if (n.local) {
  10601. return path.call(print, "local");
  10602. }
  10603. return path.call(print, "id");
  10604. case "TSExportAssignment":
  10605. return concat$4(["export = ", path.call(print, "expression"), semi]);
  10606. case "ExportDefaultDeclaration":
  10607. case "ExportNamedDeclaration":
  10608. return printExportDeclaration(path, options, print);
  10609. case "ExportAllDeclaration":
  10610. parts.push("export ");
  10611. if (n.exportKind === "type") {
  10612. parts.push("type ");
  10613. }
  10614. parts.push("* from ", path.call(print, "source"), semi);
  10615. return concat$4(parts);
  10616. case "ExportNamespaceSpecifier":
  10617. case "ExportDefaultSpecifier":
  10618. return path.call(print, "exported");
  10619. case "ImportDeclaration":
  10620. {
  10621. parts.push("import ");
  10622. if (n.importKind && n.importKind !== "value") {
  10623. parts.push(n.importKind + " ");
  10624. }
  10625. var standalones = [];
  10626. var grouped = [];
  10627. if (n.specifiers && n.specifiers.length > 0) {
  10628. path.each(function (specifierPath) {
  10629. var value = specifierPath.getValue();
  10630. if (value.type === "ImportDefaultSpecifier" || value.type === "ImportNamespaceSpecifier") {
  10631. standalones.push(print(specifierPath));
  10632. } else {
  10633. grouped.push(print(specifierPath));
  10634. }
  10635. }, "specifiers");
  10636. if (standalones.length > 0) {
  10637. parts.push(join$2(", ", standalones));
  10638. }
  10639. if (standalones.length > 0 && grouped.length > 0) {
  10640. parts.push(", ");
  10641. }
  10642. if (grouped.length === 1 && standalones.length === 0 && n.specifiers && !n.specifiers.some(function (node) {
  10643. return node.comments;
  10644. })) {
  10645. parts.push(concat$4(["{", options.bracketSpacing ? " " : "", concat$4(grouped), options.bracketSpacing ? " " : "", "}"]));
  10646. } else if (grouped.length >= 1) {
  10647. parts.push(group$1(concat$4(["{", indent$2(concat$4([options.bracketSpacing ? line$3 : softline$1, join$2(concat$4([",", line$3]), grouped)])), ifBreak$1(shouldPrintComma(options) ? "," : ""), options.bracketSpacing ? line$3 : softline$1, "}"])));
  10648. }
  10649. parts.push(" from ");
  10650. } else if (n.importKind && n.importKind === "type" || // import {} from 'x'
  10651. /{\s*}/.test(options.originalText.slice(options.locStart(n), options.locStart(n.source)))) {
  10652. parts.push("{} from ");
  10653. }
  10654. parts.push(path.call(print, "source"), semi);
  10655. return concat$4(parts);
  10656. }
  10657. case "Import":
  10658. return "import";
  10659. case "BlockStatement":
  10660. {
  10661. var naked = path.call(function (bodyPath) {
  10662. return printStatementSequence(bodyPath, options, print);
  10663. }, "body");
  10664. var hasContent = n.body.find(function (node) {
  10665. return node.type !== "EmptyStatement";
  10666. });
  10667. var hasDirectives = n.directives && n.directives.length > 0;
  10668. var _parent2 = path.getParentNode();
  10669. var _parentParent = path.getParentNode(1);
  10670. if (!hasContent && !hasDirectives && !hasDanglingComments(n) && (_parent2.type === "ArrowFunctionExpression" || _parent2.type === "FunctionExpression" || _parent2.type === "FunctionDeclaration" || _parent2.type === "ObjectMethod" || _parent2.type === "ClassMethod" || _parent2.type === "ForStatement" || _parent2.type === "WhileStatement" || _parent2.type === "DoWhileStatement" || _parent2.type === "DoExpression" || _parent2.type === "CatchClause" && !_parentParent.finalizer)) {
  10671. return "{}";
  10672. }
  10673. parts.push("{"); // Babel 6
  10674. if (hasDirectives) {
  10675. path.each(function (childPath) {
  10676. parts.push(indent$2(concat$4([hardline$3, print(childPath), semi])));
  10677. if (isNextLineEmpty$2(options.originalText, childPath.getValue(), options)) {
  10678. parts.push(hardline$3);
  10679. }
  10680. }, "directives");
  10681. }
  10682. if (hasContent) {
  10683. parts.push(indent$2(concat$4([hardline$3, naked])));
  10684. }
  10685. parts.push(comments.printDanglingComments(path, options));
  10686. parts.push(hardline$3, "}");
  10687. return concat$4(parts);
  10688. }
  10689. case "ReturnStatement":
  10690. parts.push("return");
  10691. if (n.argument) {
  10692. if (returnArgumentHasLeadingComment(options, n.argument)) {
  10693. parts.push(concat$4([" (", indent$2(concat$4([hardline$3, path.call(print, "argument")])), hardline$3, ")"]));
  10694. } else if (n.argument.type === "LogicalExpression" || n.argument.type === "BinaryExpression" || n.argument.type === "SequenceExpression") {
  10695. parts.push(group$1(concat$4([ifBreak$1(" (", " "), indent$2(concat$4([softline$1, path.call(print, "argument")])), softline$1, ifBreak$1(")")])));
  10696. } else {
  10697. parts.push(" ", path.call(print, "argument"));
  10698. }
  10699. }
  10700. if (hasDanglingComments(n)) {
  10701. parts.push(" ", comments.printDanglingComments(path, options,
  10702. /* sameIndent */
  10703. true));
  10704. }
  10705. parts.push(semi);
  10706. return concat$4(parts);
  10707. case "NewExpression":
  10708. case "OptionalCallExpression":
  10709. case "CallExpression":
  10710. {
  10711. var isNew = n.type === "NewExpression";
  10712. var optional = printOptionalToken(path);
  10713. if ( // We want to keep CommonJS- and AMD-style require calls, and AMD-style
  10714. // define calls, as a unit.
  10715. // e.g. `define(["some/lib", (lib) => {`
  10716. !isNew && n.callee.type === "Identifier" && (n.callee.name === "require" || n.callee.name === "define") || n.callee.type === "Import" || // Template literals as single arguments
  10717. n.arguments.length === 1 && isTemplateOnItsOwnLine(n.arguments[0], options.originalText, options) || // Keep test declarations on a single line
  10718. // e.g. `it('long name', () => {`
  10719. !isNew && isTestCall(n, path.getParentNode())) {
  10720. return concat$4([isNew ? "new " : "", path.call(print, "callee"), optional, printFunctionTypeParameters(path, options, print), concat$4(["(", join$2(", ", path.map(print, "arguments")), ")"])]);
  10721. } // We detect calls on member lookups and possibly print them in a
  10722. // special chain format. See `printMemberChain` for more info.
  10723. if (!isNew && isMemberish(n.callee)) {
  10724. return printMemberChain(path, options, print);
  10725. }
  10726. return concat$4([isNew ? "new " : "", path.call(print, "callee"), optional, printFunctionTypeParameters(path, options, print), printArgumentsList(path, options, print)]);
  10727. }
  10728. case "TSInterfaceDeclaration":
  10729. if (isNodeStartingWithDeclare(n, options)) {
  10730. parts.push("declare ");
  10731. }
  10732. parts.push(n.abstract ? "abstract " : "", printTypeScriptModifiers(path, options, print), "interface ", path.call(print, "id"), n.typeParameters ? path.call(print, "typeParameters") : "", " ");
  10733. if (n.heritage.length) {
  10734. parts.push(group$1(indent$2(concat$4([softline$1, "extends ", indent$2(join$2(concat$4([",", line$3]), path.map(print, "heritage"))), " "]))));
  10735. }
  10736. parts.push(path.call(print, "body"));
  10737. return concat$4(parts);
  10738. case "ObjectExpression":
  10739. case "ObjectPattern":
  10740. case "ObjectTypeAnnotation":
  10741. case "TSInterfaceBody":
  10742. case "TSTypeLiteral":
  10743. {
  10744. var isTypeAnnotation = n.type === "ObjectTypeAnnotation";
  10745. var _parent3 = path.getParentNode(0);
  10746. var shouldBreak = n.type === "TSInterfaceBody" || n.type === "ObjectPattern" && _parent3.type !== "FunctionDeclaration" && _parent3.type !== "FunctionExpression" && _parent3.type !== "ArrowFunctionExpression" && _parent3.type !== "AssignmentPattern" && _parent3.type !== "CatchClause" && n.properties.some(function (property) {
  10747. return property.value && (property.value.type === "ObjectPattern" || property.value.type === "ArrayPattern");
  10748. }) || n.type !== "ObjectPattern" && hasNewlineInRange$1(options.originalText, options.locStart(n), options.locEnd(n));
  10749. var isFlowInterfaceLikeBody = isTypeAnnotation && _parent3 && (_parent3.type === "InterfaceDeclaration" || _parent3.type === "DeclareInterface" || _parent3.type === "DeclareClass") && path.getName() === "body";
  10750. var separator = isFlowInterfaceLikeBody ? ";" : n.type === "TSInterfaceBody" || n.type === "TSTypeLiteral" ? ifBreak$1(semi, ";") : ",";
  10751. var fields = [];
  10752. var leftBrace = n.exact ? "{|" : "{";
  10753. var rightBrace = n.exact ? "|}" : "}";
  10754. var propertiesField;
  10755. if (n.type === "TSTypeLiteral") {
  10756. propertiesField = "members";
  10757. } else if (n.type === "TSInterfaceBody") {
  10758. propertiesField = "body";
  10759. } else {
  10760. propertiesField = "properties";
  10761. }
  10762. if (isTypeAnnotation) {
  10763. fields.push("indexers", "callProperties");
  10764. }
  10765. fields.push(propertiesField); // Unfortunately, things are grouped together in the ast can be
  10766. // interleaved in the source code. So we need to reorder them before
  10767. // printing them.
  10768. var propsAndLoc = [];
  10769. fields.forEach(function (field) {
  10770. path.each(function (childPath) {
  10771. var node = childPath.getValue();
  10772. propsAndLoc.push({
  10773. node: node,
  10774. printed: print(childPath),
  10775. loc: options.locStart(node)
  10776. });
  10777. }, field);
  10778. });
  10779. var separatorParts = [];
  10780. var props = propsAndLoc.sort(function (a, b) {
  10781. return a.loc - b.loc;
  10782. }).map(function (prop) {
  10783. var result = concat$4(separatorParts.concat(group$1(prop.printed)));
  10784. separatorParts = [separator, line$3];
  10785. if (prop.node.type === "TSPropertySignature" && hasNodeIgnoreComment$1(prop.node)) {
  10786. separatorParts.shift();
  10787. }
  10788. if (isNextLineEmpty$2(options.originalText, prop.node, options)) {
  10789. separatorParts.push(hardline$3);
  10790. }
  10791. return result;
  10792. });
  10793. var lastElem = getLast$4(n[propertiesField]);
  10794. var canHaveTrailingSeparator = !(lastElem && (lastElem.type === "RestProperty" || lastElem.type === "RestElement" || lastElem.type === "ExperimentalRestProperty" || hasNodeIgnoreComment$1(lastElem)));
  10795. var content;
  10796. if (props.length === 0 && !n.typeAnnotation) {
  10797. if (!hasDanglingComments(n)) {
  10798. return concat$4([leftBrace, rightBrace]);
  10799. }
  10800. content = group$1(concat$4([leftBrace, comments.printDanglingComments(path, options), softline$1, rightBrace, printOptionalToken(path)]));
  10801. } else {
  10802. content = concat$4([leftBrace, indent$2(concat$4([options.bracketSpacing ? line$3 : softline$1, concat$4(props)])), ifBreak$1(canHaveTrailingSeparator && (separator !== "," || shouldPrintComma(options)) ? separator : ""), concat$4([options.bracketSpacing ? line$3 : softline$1, rightBrace]), printOptionalToken(path), printTypeAnnotation(path, options, print)]);
  10803. } // If we inline the object as first argument of the parent, we don't want
  10804. // to create another group so that the object breaks before the return
  10805. // type
  10806. var parentParentParent = path.getParentNode(2);
  10807. if (n.type === "ObjectPattern" && _parent3 && shouldHugArguments(_parent3) && _parent3.params[0] === n || shouldHugType(n) && parentParentParent && shouldHugArguments(parentParentParent) && parentParentParent.params[0].typeAnnotation && parentParentParent.params[0].typeAnnotation.typeAnnotation === n) {
  10808. return content;
  10809. }
  10810. return group$1(content, {
  10811. shouldBreak: shouldBreak
  10812. });
  10813. }
  10814. // Babel 6
  10815. case "ObjectProperty": // Non-standard AST node type.
  10816. case "Property":
  10817. if (n.method || n.kind === "get" || n.kind === "set") {
  10818. return printMethod(path, options, print);
  10819. }
  10820. if (n.shorthand) {
  10821. parts.push(path.call(print, "value"));
  10822. } else {
  10823. var printedLeft;
  10824. if (n.computed) {
  10825. printedLeft = concat$4(["[", path.call(print, "key"), "]"]);
  10826. } else {
  10827. printedLeft = printPropertyKey(path, options, print);
  10828. }
  10829. parts.push(printAssignment(n.key, printedLeft, ":", n.value, path.call(print, "value"), options));
  10830. }
  10831. return concat$4(parts);
  10832. // Babel 6
  10833. case "ClassMethod":
  10834. if (n.static) {
  10835. parts.push("static ");
  10836. }
  10837. parts = parts.concat(printObjectMethod(path, options, print));
  10838. return concat$4(parts);
  10839. // Babel 6
  10840. case "ObjectMethod":
  10841. return printObjectMethod(path, options, print);
  10842. case "Decorator":
  10843. return concat$4(["@", path.call(print, "expression"), path.call(print, "callee")]);
  10844. case "ArrayExpression":
  10845. case "ArrayPattern":
  10846. if (n.elements.length === 0) {
  10847. if (!hasDanglingComments(n)) {
  10848. parts.push("[]");
  10849. } else {
  10850. parts.push(group$1(concat$4(["[", comments.printDanglingComments(path, options), softline$1, "]"])));
  10851. }
  10852. } else {
  10853. var _lastElem = getLast$4(n.elements);
  10854. var canHaveTrailingComma = !(_lastElem && _lastElem.type === "RestElement"); // JavaScript allows you to have empty elements in an array which
  10855. // changes its length based on the number of commas. The algorithm
  10856. // is that if the last argument is null, we need to force insert
  10857. // a comma to ensure JavaScript recognizes it.
  10858. // [,].length === 1
  10859. // [1,].length === 1
  10860. // [1,,].length === 2
  10861. //
  10862. // Note that getLast returns null if the array is empty, but
  10863. // we already check for an empty array just above so we are safe
  10864. var needsForcedTrailingComma = canHaveTrailingComma && _lastElem === null;
  10865. parts.push(group$1(concat$4(["[", indent$2(concat$4([softline$1, printArrayItems(path, options, "elements", print)])), needsForcedTrailingComma ? "," : "", ifBreak$1(canHaveTrailingComma && !needsForcedTrailingComma && shouldPrintComma(options) ? "," : ""), comments.printDanglingComments(path, options,
  10866. /* sameIndent */
  10867. true), softline$1, "]"])));
  10868. }
  10869. parts.push(printOptionalToken(path), printTypeAnnotation(path, options, print));
  10870. return concat$4(parts);
  10871. case "SequenceExpression":
  10872. {
  10873. var _parent4 = path.getParentNode(0);
  10874. if (_parent4.type === "ExpressionStatement" || _parent4.type === "ForStatement") {
  10875. // For ExpressionStatements and for-loop heads, which are among
  10876. // the few places a SequenceExpression appears unparenthesized, we want
  10877. // to indent expressions after the first.
  10878. var _parts2 = [];
  10879. path.each(function (p) {
  10880. if (p.getName() === 0) {
  10881. _parts2.push(print(p));
  10882. } else {
  10883. _parts2.push(",", indent$2(concat$4([line$3, print(p)])));
  10884. }
  10885. }, "expressions");
  10886. return group$1(concat$4(_parts2));
  10887. }
  10888. return group$1(concat$4([join$2(concat$4([",", line$3]), path.map(print, "expressions"))]));
  10889. }
  10890. case "ThisExpression":
  10891. return "this";
  10892. case "Super":
  10893. return "super";
  10894. case "NullLiteral":
  10895. // Babel 6 Literal split
  10896. return "null";
  10897. case "RegExpLiteral":
  10898. // Babel 6 Literal split
  10899. return printRegex(n);
  10900. case "NumericLiteral":
  10901. // Babel 6 Literal split
  10902. return printNumber$1(n.extra.raw);
  10903. case "BooleanLiteral": // Babel 6 Literal split
  10904. case "StringLiteral": // Babel 6 Literal split
  10905. case "Literal":
  10906. {
  10907. if (n.regex) {
  10908. return printRegex(n.regex);
  10909. }
  10910. if (typeof n.value === "number") {
  10911. return printNumber$1(n.raw);
  10912. }
  10913. if (typeof n.value !== "string") {
  10914. return "" + n.value;
  10915. } // TypeScript workaround for eslint/typescript-eslint-parser#267
  10916. // See corresponding workaround in needs-parens.js
  10917. var grandParent = path.getParentNode(1);
  10918. var isTypeScriptDirective = options.parser === "typescript" && typeof n.value === "string" && grandParent && (grandParent.type === "Program" || grandParent.type === "BlockStatement");
  10919. return nodeStr(n, options, isTypeScriptDirective);
  10920. }
  10921. case "Directive":
  10922. return path.call(print, "value");
  10923. // Babel 6
  10924. case "DirectiveLiteral":
  10925. return nodeStr(n, options);
  10926. case "UnaryExpression":
  10927. parts.push(n.operator);
  10928. if (/[a-z]$/.test(n.operator)) {
  10929. parts.push(" ");
  10930. }
  10931. parts.push(path.call(print, "argument"));
  10932. return concat$4(parts);
  10933. case "UpdateExpression":
  10934. parts.push(path.call(print, "argument"), n.operator);
  10935. if (n.prefix) {
  10936. parts.reverse();
  10937. }
  10938. return concat$4(parts);
  10939. case "ConditionalExpression":
  10940. return formatTernaryOperator(path, options, print, {
  10941. beforeParts: function beforeParts() {
  10942. return [path.call(print, "test")];
  10943. },
  10944. afterParts: function afterParts(breakClosingParen) {
  10945. return [breakClosingParen ? softline$1 : ""];
  10946. }
  10947. });
  10948. case "VariableDeclaration":
  10949. {
  10950. var printed = path.map(function (childPath) {
  10951. return print(childPath);
  10952. }, "declarations"); // We generally want to terminate all variable declarations with a
  10953. // semicolon, except when they in the () part of for loops.
  10954. var parentNode = path.getParentNode();
  10955. var isParentForLoop = parentNode.type === "ForStatement" || parentNode.type === "ForInStatement" || parentNode.type === "ForOfStatement" || parentNode.type === "ForAwaitStatement";
  10956. var hasValue = n.declarations.some(function (decl) {
  10957. return decl.init;
  10958. });
  10959. var firstVariable;
  10960. if (printed.length === 1) {
  10961. firstVariable = printed[0];
  10962. } else if (printed.length > 1) {
  10963. // Indent first var to comply with eslint one-var rule
  10964. firstVariable = indent$2(printed[0]);
  10965. }
  10966. parts = [isNodeStartingWithDeclare(n, options) ? "declare " : "", n.kind, firstVariable ? concat$4([" ", firstVariable]) : "", indent$2(concat$4(printed.slice(1).map(function (p) {
  10967. return concat$4([",", hasValue && !isParentForLoop ? hardline$3 : line$3, p]);
  10968. })))];
  10969. if (!(isParentForLoop && parentNode.body !== n)) {
  10970. parts.push(semi);
  10971. }
  10972. return group$1(concat$4(parts));
  10973. }
  10974. case "VariableDeclarator":
  10975. return printAssignment(n.id, concat$4([path.call(print, "id"), path.call(print, "typeParameters")]), " =", n.init, n.init && path.call(print, "init"), options);
  10976. case "WithStatement":
  10977. return group$1(concat$4(["with (", path.call(print, "object"), ")", adjustClause(n.body, path.call(print, "body"))]));
  10978. case "IfStatement":
  10979. {
  10980. var con = adjustClause(n.consequent, path.call(print, "consequent"));
  10981. var opening = group$1(concat$4(["if (", group$1(concat$4([indent$2(concat$4([softline$1, path.call(print, "test")])), softline$1])), ")", con]));
  10982. parts.push(opening);
  10983. if (n.alternate) {
  10984. var commentOnOwnLine = hasTrailingComment(n.consequent) && n.consequent.comments.some(function (comment) {
  10985. return comment.trailing && !comments$3.isBlockComment(comment);
  10986. }) || needsHardlineAfterDanglingComment(n);
  10987. var elseOnSameLine = n.consequent.type === "BlockStatement" && !commentOnOwnLine;
  10988. parts.push(elseOnSameLine ? " " : hardline$3);
  10989. if (hasDanglingComments(n)) {
  10990. parts.push(comments.printDanglingComments(path, options, true), commentOnOwnLine ? hardline$3 : " ");
  10991. }
  10992. parts.push("else", group$1(adjustClause(n.alternate, path.call(print, "alternate"), n.alternate.type === "IfStatement")));
  10993. }
  10994. return concat$4(parts);
  10995. }
  10996. case "ForStatement":
  10997. {
  10998. var _body = adjustClause(n.body, path.call(print, "body")); // We want to keep dangling comments above the loop to stay consistent.
  10999. // Any comment positioned between the for statement and the parentheses
  11000. // is going to be printed before the statement.
  11001. var _dangling = comments.printDanglingComments(path, options,
  11002. /* sameLine */
  11003. true);
  11004. var printedComments = _dangling ? concat$4([_dangling, softline$1]) : "";
  11005. if (!n.init && !n.test && !n.update) {
  11006. return concat$4([printedComments, group$1(concat$4(["for (;;)", _body]))]);
  11007. }
  11008. return concat$4([printedComments, group$1(concat$4(["for (", group$1(concat$4([indent$2(concat$4([softline$1, path.call(print, "init"), ";", line$3, path.call(print, "test"), ";", line$3, path.call(print, "update")])), softline$1])), ")", _body]))]);
  11009. }
  11010. case "WhileStatement":
  11011. return group$1(concat$4(["while (", group$1(concat$4([indent$2(concat$4([softline$1, path.call(print, "test")])), softline$1])), ")", adjustClause(n.body, path.call(print, "body"))]));
  11012. case "ForInStatement":
  11013. // Note: esprima can't actually parse "for each (".
  11014. return group$1(concat$4([n.each ? "for each (" : "for (", path.call(print, "left"), " in ", path.call(print, "right"), ")", adjustClause(n.body, path.call(print, "body"))]));
  11015. case "ForOfStatement":
  11016. case "ForAwaitStatement":
  11017. {
  11018. // Babylon 7 removed ForAwaitStatement in favor of ForOfStatement
  11019. // with `"await": true`:
  11020. // https://github.com/estree/estree/pull/138
  11021. var isAwait = n.type === "ForAwaitStatement" || n.await;
  11022. return group$1(concat$4(["for", isAwait ? " await" : "", " (", path.call(print, "left"), " of ", path.call(print, "right"), ")", adjustClause(n.body, path.call(print, "body"))]));
  11023. }
  11024. case "DoWhileStatement":
  11025. {
  11026. var clause = adjustClause(n.body, path.call(print, "body"));
  11027. var doBody = group$1(concat$4(["do", clause]));
  11028. parts = [doBody];
  11029. if (n.body.type === "BlockStatement") {
  11030. parts.push(" ");
  11031. } else {
  11032. parts.push(hardline$3);
  11033. }
  11034. parts.push("while (");
  11035. parts.push(group$1(concat$4([indent$2(concat$4([softline$1, path.call(print, "test")])), softline$1])), ")", semi);
  11036. return concat$4(parts);
  11037. }
  11038. case "DoExpression":
  11039. return concat$4(["do ", path.call(print, "body")]);
  11040. case "BreakStatement":
  11041. parts.push("break");
  11042. if (n.label) {
  11043. parts.push(" ", path.call(print, "label"));
  11044. }
  11045. parts.push(semi);
  11046. return concat$4(parts);
  11047. case "ContinueStatement":
  11048. parts.push("continue");
  11049. if (n.label) {
  11050. parts.push(" ", path.call(print, "label"));
  11051. }
  11052. parts.push(semi);
  11053. return concat$4(parts);
  11054. case "LabeledStatement":
  11055. if (n.body.type === "EmptyStatement") {
  11056. return concat$4([path.call(print, "label"), ":;"]);
  11057. }
  11058. return concat$4([path.call(print, "label"), ": ", path.call(print, "body")]);
  11059. case "TryStatement":
  11060. return concat$4(["try ", path.call(print, "block"), n.handler ? concat$4([" ", path.call(print, "handler")]) : "", n.finalizer ? concat$4([" finally ", path.call(print, "finalizer")]) : ""]);
  11061. case "CatchClause":
  11062. return concat$4(["catch ", n.param ? concat$4(["(", path.call(print, "param"), ") "]) : "", path.call(print, "body")]);
  11063. case "ThrowStatement":
  11064. return concat$4(["throw ", path.call(print, "argument"), semi]);
  11065. // Note: ignoring n.lexical because it has no printing consequences.
  11066. case "SwitchStatement":
  11067. return concat$4([group$1(concat$4(["switch (", indent$2(concat$4([softline$1, path.call(print, "discriminant")])), softline$1, ")"])), " {", n.cases.length > 0 ? indent$2(concat$4([hardline$3, join$2(hardline$3, path.map(function (casePath) {
  11068. var caseNode = casePath.getValue();
  11069. return concat$4([casePath.call(print), n.cases.indexOf(caseNode) !== n.cases.length - 1 && isNextLineEmpty$2(options.originalText, caseNode, options) ? hardline$3 : ""]);
  11070. }, "cases"))])) : "", hardline$3, "}"]);
  11071. case "SwitchCase":
  11072. {
  11073. if (n.test) {
  11074. parts.push("case ", path.call(print, "test"), ":");
  11075. } else {
  11076. parts.push("default:");
  11077. }
  11078. var consequent = n.consequent.filter(function (node) {
  11079. return node.type !== "EmptyStatement";
  11080. });
  11081. if (consequent.length > 0) {
  11082. var cons = path.call(function (consequentPath) {
  11083. return printStatementSequence(consequentPath, options, print);
  11084. }, "consequent");
  11085. parts.push(consequent.length === 1 && consequent[0].type === "BlockStatement" ? concat$4([" ", cons]) : indent$2(concat$4([hardline$3, cons])));
  11086. }
  11087. return concat$4(parts);
  11088. }
  11089. // JSX extensions below.
  11090. case "DebuggerStatement":
  11091. return concat$4(["debugger", semi]);
  11092. case "JSXAttribute":
  11093. parts.push(path.call(print, "name"));
  11094. if (n.value) {
  11095. var res;
  11096. if (isStringLiteral(n.value)) {
  11097. var value = rawText(n.value);
  11098. res = '"' + value.slice(1, -1).replace(/"/g, "&quot;") + '"';
  11099. } else {
  11100. res = path.call(print, "value");
  11101. }
  11102. parts.push("=", res);
  11103. }
  11104. return concat$4(parts);
  11105. case "JSXIdentifier":
  11106. // Can be removed when this is fixed:
  11107. // https://github.com/eslint/typescript-eslint-parser/issues/337
  11108. if (!n.name) {
  11109. return "this";
  11110. }
  11111. return "" + n.name;
  11112. case "JSXNamespacedName":
  11113. return join$2(":", [path.call(print, "namespace"), path.call(print, "name")]);
  11114. case "JSXMemberExpression":
  11115. return join$2(".", [path.call(print, "object"), path.call(print, "property")]);
  11116. case "TSQualifiedName":
  11117. return join$2(".", [path.call(print, "left"), path.call(print, "right")]);
  11118. case "JSXSpreadAttribute":
  11119. case "JSXSpreadChild":
  11120. {
  11121. return concat$4(["{", path.call(function (p) {
  11122. var printed = concat$4(["...", print(p)]);
  11123. var n = p.getValue();
  11124. if (!n.comments || !n.comments.length) {
  11125. return printed;
  11126. }
  11127. return concat$4([indent$2(concat$4([softline$1, comments.printComments(p, function () {
  11128. return printed;
  11129. }, options)])), softline$1]);
  11130. }, n.type === "JSXSpreadAttribute" ? "argument" : "expression"), "}"]);
  11131. }
  11132. case "JSXExpressionContainer":
  11133. {
  11134. var _parent5 = path.getParentNode(0);
  11135. var preventInline = _parent5.type === "JSXAttribute" && n.expression.comments && n.expression.comments.length > 0;
  11136. var _shouldInline = !preventInline && (n.expression.type === "ArrayExpression" || n.expression.type === "ObjectExpression" || n.expression.type === "ArrowFunctionExpression" || n.expression.type === "CallExpression" || n.expression.type === "OptionalCallExpression" || n.expression.type === "FunctionExpression" || n.expression.type === "JSXEmptyExpression" || n.expression.type === "TemplateLiteral" || n.expression.type === "TaggedTemplateExpression" || n.expression.type === "DoExpression" || isJSXNode(_parent5) && (n.expression.type === "ConditionalExpression" || isBinaryish(n.expression)));
  11137. if (_shouldInline) {
  11138. return group$1(concat$4(["{", path.call(print, "expression"), lineSuffixBoundary$1, "}"]));
  11139. }
  11140. return group$1(concat$4(["{", indent$2(concat$4([softline$1, path.call(print, "expression")])), softline$1, lineSuffixBoundary$1, "}"]));
  11141. }
  11142. case "JSXFragment":
  11143. case "TSJsxFragment":
  11144. case "JSXElement":
  11145. {
  11146. var elem = comments.printComments(path, function () {
  11147. return printJSXElement(path, options, print);
  11148. }, options);
  11149. return maybeWrapJSXElementInParens(path, elem);
  11150. }
  11151. case "JSXOpeningElement":
  11152. {
  11153. var _n = path.getValue();
  11154. var nameHasComments = _n.name && _n.name.comments && _n.name.comments.length > 0; // Don't break self-closing elements with no attributes and no comments
  11155. if (_n.selfClosing && !_n.attributes.length && !nameHasComments) {
  11156. return concat$4(["<", path.call(print, "name"), path.call(print, "typeParameters"), " />"]);
  11157. } // don't break up opening elements with a single long text attribute
  11158. if (_n.attributes && _n.attributes.length === 1 && _n.attributes[0].value && isStringLiteral(_n.attributes[0].value) && !_n.attributes[0].value.value.includes("\n") && // We should break for the following cases:
  11159. // <div
  11160. // // comment
  11161. // attr="value"
  11162. // >
  11163. // <div
  11164. // attr="value"
  11165. // // comment
  11166. // >
  11167. !nameHasComments && (!_n.attributes[0].comments || !_n.attributes[0].comments.length)) {
  11168. return group$1(concat$4(["<", path.call(print, "name"), path.call(print, "typeParameters"), " ", concat$4(path.map(print, "attributes")), _n.selfClosing ? " />" : ">"]));
  11169. }
  11170. var lastAttrHasTrailingComments = _n.attributes.length && hasTrailingComment(getLast$4(_n.attributes));
  11171. var bracketSameLine = options.jsxBracketSameLine && ( // We should print the bracket in a new line for the following cases:
  11172. // <div
  11173. // // comment
  11174. // >
  11175. // <div
  11176. // attr // comment
  11177. // >
  11178. !nameHasComments || _n.attributes.length) && !lastAttrHasTrailingComments; // We should print the opening element expanded if any prop value is a
  11179. // string literal with newlines
  11180. var _shouldBreak = _n.attributes && _n.attributes.some(function (attr) {
  11181. return attr.value && isStringLiteral(attr.value) && attr.value.value.includes("\n");
  11182. });
  11183. return group$1(concat$4(["<", path.call(print, "name"), path.call(print, "typeParameters"), concat$4([indent$2(concat$4(path.map(function (attr) {
  11184. return concat$4([line$3, print(attr)]);
  11185. }, "attributes"))), _n.selfClosing ? line$3 : bracketSameLine ? ">" : softline$1]), _n.selfClosing ? "/>" : bracketSameLine ? "" : ">"]), {
  11186. shouldBreak: _shouldBreak
  11187. });
  11188. }
  11189. case "JSXClosingElement":
  11190. return concat$4(["</", path.call(print, "name"), ">"]);
  11191. case "JSXOpeningFragment":
  11192. case "JSXClosingFragment":
  11193. case "TSJsxOpeningFragment":
  11194. case "TSJsxClosingFragment":
  11195. {
  11196. var hasComment = n.comments && n.comments.length;
  11197. var hasOwnLineComment = hasComment && !n.comments.every(comments$3.isBlockComment);
  11198. var isOpeningFragment = n.type === "JSXOpeningFragment" || n.type === "TSJsxOpeningFragment";
  11199. return concat$4([isOpeningFragment ? "<" : "</", indent$2(concat$4([hasOwnLineComment ? hardline$3 : hasComment && !isOpeningFragment ? " " : "", comments.printDanglingComments(path, options, true)])), hasOwnLineComment ? hardline$3 : "", ">"]);
  11200. }
  11201. case "JSXText":
  11202. /* istanbul ignore next */
  11203. throw new Error("JSXTest should be handled by JSXElement");
  11204. case "JSXEmptyExpression":
  11205. {
  11206. var requiresHardline = n.comments && !n.comments.every(comments$3.isBlockComment);
  11207. return concat$4([comments.printDanglingComments(path, options,
  11208. /* sameIndent */
  11209. !requiresHardline), requiresHardline ? hardline$3 : ""]);
  11210. }
  11211. case "ClassBody":
  11212. if (!n.comments && n.body.length === 0) {
  11213. return "{}";
  11214. }
  11215. return concat$4(["{", n.body.length > 0 ? indent$2(concat$4([hardline$3, path.call(function (bodyPath) {
  11216. return printStatementSequence(bodyPath, options, print);
  11217. }, "body")])) : comments.printDanglingComments(path, options), hardline$3, "}"]);
  11218. case "ClassProperty":
  11219. case "TSAbstractClassProperty":
  11220. case "ClassPrivateProperty":
  11221. {
  11222. if (n.accessibility) {
  11223. parts.push(n.accessibility + " ");
  11224. }
  11225. if (n.static) {
  11226. parts.push("static ");
  11227. }
  11228. if (n.type === "TSAbstractClassProperty") {
  11229. parts.push("abstract ");
  11230. }
  11231. if (n.readonly) {
  11232. parts.push("readonly ");
  11233. }
  11234. var variance = getFlowVariance(n);
  11235. if (variance) {
  11236. parts.push(variance);
  11237. }
  11238. if (n.computed) {
  11239. parts.push("[", path.call(print, "key"), "]");
  11240. } else {
  11241. parts.push(printPropertyKey(path, options, print));
  11242. }
  11243. parts.push(printTypeAnnotation(path, options, print));
  11244. if (n.value) {
  11245. parts.push(" =", printAssignmentRight(n.key, n.value, path.call(print, "value"), options));
  11246. }
  11247. parts.push(semi);
  11248. return group$1(concat$4(parts));
  11249. }
  11250. case "ClassDeclaration":
  11251. case "ClassExpression":
  11252. case "TSAbstractClassDeclaration":
  11253. if (isNodeStartingWithDeclare(n, options)) {
  11254. parts.push("declare ");
  11255. }
  11256. parts.push(concat$4(printClass(path, options, print)));
  11257. return concat$4(parts);
  11258. case "TSInterfaceHeritage":
  11259. parts.push(path.call(print, "id"));
  11260. if (n.typeParameters) {
  11261. parts.push(path.call(print, "typeParameters"));
  11262. }
  11263. return concat$4(parts);
  11264. case "TemplateElement":
  11265. return join$2(literalline$1, n.value.raw.split(/\r?\n/g));
  11266. case "TemplateLiteral":
  11267. {
  11268. var expressions = path.map(print, "expressions");
  11269. var _parentNode = path.getParentNode();
  11270. /**
  11271. * describe.each`table`(name, fn)
  11272. * describe.only.each`table`(name, fn)
  11273. * describe.skip.each`table`(name, fn)
  11274. * test.each`table`(name, fn)
  11275. * test.only.each`table`(name, fn)
  11276. * test.skip.each`table`(name, fn)
  11277. *
  11278. * Ref: https://github.com/facebook/jest/pull/6102
  11279. */
  11280. var jestEachTriggerRegex = /^[xf]?(describe|it|test)$/;
  11281. if (_parentNode.type === "TaggedTemplateExpression" && _parentNode.quasi === n && _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))) {
  11282. /**
  11283. * a | b | expected
  11284. * ${1} | ${1} | ${2}
  11285. * ${1} | ${2} | ${3}
  11286. * ${2} | ${1} | ${3}
  11287. */
  11288. var headerNames = n.quasis[0].value.raw.trim().split(/\s*\|\s*/);
  11289. if (headerNames.length > 1 || headerNames.some(function (headerName) {
  11290. return headerName.length !== 0;
  11291. })) {
  11292. var stringifiedExpressions = expressions.map(function (doc$$2) {
  11293. return "${" + printDocToString$1(doc$$2, Object.assign({}, options, {
  11294. printWidth: Infinity
  11295. })).formatted + "}";
  11296. });
  11297. var tableBody = [{
  11298. hasLineBreak: false,
  11299. cells: []
  11300. }];
  11301. for (var _i = 1; _i < n.quasis.length; _i++) {
  11302. var row = tableBody[tableBody.length - 1];
  11303. var correspondingExpression = stringifiedExpressions[_i - 1];
  11304. row.cells.push(correspondingExpression);
  11305. if (correspondingExpression.indexOf("\n") !== -1) {
  11306. row.hasLineBreak = true;
  11307. }
  11308. if (n.quasis[_i].value.raw.indexOf("\n") !== -1) {
  11309. tableBody.push({
  11310. hasLineBreak: false,
  11311. cells: []
  11312. });
  11313. }
  11314. }
  11315. var maxColumnCount = tableBody.reduce(function (maxColumnCount, row) {
  11316. return Math.max(maxColumnCount, row.cells.length);
  11317. }, headerNames.length);
  11318. var maxColumnWidths = Array.from(new Array(maxColumnCount), function () {
  11319. return 0;
  11320. });
  11321. var table = [{
  11322. cells: headerNames
  11323. }].concat(tableBody.filter(function (row) {
  11324. return row.cells.length !== 0;
  11325. }));
  11326. table.filter(function (row) {
  11327. return !row.hasLineBreak;
  11328. }).forEach(function (row) {
  11329. row.cells.forEach(function (cell, index) {
  11330. maxColumnWidths[index] = Math.max(maxColumnWidths[index], getStringWidth$1(cell));
  11331. });
  11332. });
  11333. parts.push("`", indent$2(concat$4([hardline$3, join$2(hardline$3, table.map(function (row) {
  11334. return join$2(" | ", row.cells.map(function (cell, index) {
  11335. return row.hasLineBreak ? cell : cell + " ".repeat(maxColumnWidths[index] - getStringWidth$1(cell));
  11336. }));
  11337. }))])), hardline$3, "`");
  11338. return concat$4(parts);
  11339. }
  11340. }
  11341. parts.push("`");
  11342. path.each(function (childPath) {
  11343. var i = childPath.getName();
  11344. parts.push(print(childPath));
  11345. if (i < expressions.length) {
  11346. // For a template literal of the following form:
  11347. // `someQuery {
  11348. // ${call({
  11349. // a,
  11350. // b,
  11351. // })}
  11352. // }`
  11353. // the expression is on its own line (there is a \n in the previous
  11354. // quasi literal), therefore we want to indent the JavaScript
  11355. // expression inside at the beginning of ${ instead of the beginning
  11356. // of the `.
  11357. var tabWidth = options.tabWidth;
  11358. var indentSize = getIndentSize$1(childPath.getValue().value.raw, tabWidth);
  11359. var _printed = expressions[i];
  11360. if (n.expressions[i].comments && n.expressions[i].comments.length || n.expressions[i].type === "MemberExpression" || n.expressions[i].type === "OptionalMemberExpression" || n.expressions[i].type === "ConditionalExpression") {
  11361. _printed = concat$4([indent$2(concat$4([softline$1, _printed])), softline$1]);
  11362. }
  11363. var aligned = addAlignmentToDoc$2(_printed, indentSize, tabWidth);
  11364. parts.push(group$1(concat$4(["${", aligned, lineSuffixBoundary$1, "}"])));
  11365. }
  11366. }, "quasis");
  11367. parts.push("`");
  11368. return concat$4(parts);
  11369. }
  11370. // These types are unprintable because they serve as abstract
  11371. // supertypes for other (printable) types.
  11372. case "TaggedTemplateExpression":
  11373. return concat$4([path.call(print, "tag"), path.call(print, "typeParameters"), path.call(print, "quasi")]);
  11374. case "Node":
  11375. case "Printable":
  11376. case "SourceLocation":
  11377. case "Position":
  11378. case "Statement":
  11379. case "Function":
  11380. case "Pattern":
  11381. case "Expression":
  11382. case "Declaration":
  11383. case "Specifier":
  11384. case "NamedSpecifier":
  11385. case "Comment":
  11386. case "MemberTypeAnnotation": // Flow
  11387. case "Type":
  11388. /* istanbul ignore next */
  11389. throw new Error("unprintable type: " + JSON.stringify(n.type));
  11390. // Type Annotations for Facebook Flow, typically stripped out or
  11391. // transformed away before printing.
  11392. case "TypeAnnotation":
  11393. case "TSTypeAnnotation":
  11394. if (n.typeAnnotation) {
  11395. return path.call(print, "typeAnnotation");
  11396. }
  11397. /* istanbul ignore next */
  11398. return "";
  11399. case "TSTupleType":
  11400. case "TupleTypeAnnotation":
  11401. {
  11402. var typesField = n.type === "TSTupleType" ? "elementTypes" : "types";
  11403. return group$1(concat$4(["[", indent$2(concat$4([softline$1, printArrayItems(path, options, typesField, print)])), // TypeScript doesn't support trailing commas in tuple types
  11404. n.type === "TSTupleType" ? "" : ifBreak$1(shouldPrintComma(options) ? "," : ""), comments.printDanglingComments(path, options,
  11405. /* sameIndent */
  11406. true), softline$1, "]"]));
  11407. }
  11408. case "ExistsTypeAnnotation":
  11409. return "*";
  11410. case "EmptyTypeAnnotation":
  11411. return "empty";
  11412. case "AnyTypeAnnotation":
  11413. return "any";
  11414. case "MixedTypeAnnotation":
  11415. return "mixed";
  11416. case "ArrayTypeAnnotation":
  11417. return concat$4([path.call(print, "elementType"), "[]"]);
  11418. case "BooleanTypeAnnotation":
  11419. return "boolean";
  11420. case "BooleanLiteralTypeAnnotation":
  11421. return "" + n.value;
  11422. case "DeclareClass":
  11423. return printFlowDeclaration(path, printClass(path, options, print));
  11424. case "DeclareFunction":
  11425. // For TypeScript the DeclareFunction node shares the AST
  11426. // structure with FunctionDeclaration
  11427. if (n.params) {
  11428. return concat$4(["declare ", printFunctionDeclaration(path, print, options), semi]);
  11429. }
  11430. return printFlowDeclaration(path, ["function ", path.call(print, "id"), n.predicate ? " " : "", path.call(print, "predicate"), semi]);
  11431. case "DeclareModule":
  11432. return printFlowDeclaration(path, ["module ", path.call(print, "id"), " ", path.call(print, "body")]);
  11433. case "DeclareModuleExports":
  11434. return printFlowDeclaration(path, ["module.exports", ": ", path.call(print, "typeAnnotation"), semi]);
  11435. case "DeclareVariable":
  11436. return printFlowDeclaration(path, ["var ", path.call(print, "id"), semi]);
  11437. case "DeclareExportAllDeclaration":
  11438. return concat$4(["declare export * from ", path.call(print, "source")]);
  11439. case "DeclareExportDeclaration":
  11440. return concat$4(["declare ", printExportDeclaration(path, options, print)]);
  11441. case "DeclareOpaqueType":
  11442. case "OpaqueType":
  11443. {
  11444. parts.push("opaque type ", path.call(print, "id"), path.call(print, "typeParameters"));
  11445. if (n.supertype) {
  11446. parts.push(": ", path.call(print, "supertype"));
  11447. }
  11448. if (n.impltype) {
  11449. parts.push(" = ", path.call(print, "impltype"));
  11450. }
  11451. parts.push(semi);
  11452. if (n.type === "DeclareOpaqueType") {
  11453. return printFlowDeclaration(path, parts);
  11454. }
  11455. return concat$4(parts);
  11456. }
  11457. case "FunctionTypeAnnotation":
  11458. case "TSFunctionType":
  11459. {
  11460. // FunctionTypeAnnotation is ambiguous:
  11461. // declare function foo(a: B): void; OR
  11462. // var A: (a: B) => void;
  11463. var _parent6 = path.getParentNode(0);
  11464. var _parentParent2 = path.getParentNode(1);
  11465. var _parentParentParent = path.getParentNode(2);
  11466. var isArrowFunctionTypeAnnotation = n.type === "TSFunctionType" || !(_parent6.type === "ObjectTypeProperty" && !getFlowVariance(_parent6) && !_parent6.optional && options.locStart(_parent6) === options.locStart(n) || _parent6.type === "ObjectTypeCallProperty" || _parentParentParent && _parentParentParent.type === "DeclareFunction");
  11467. var needsColon = isArrowFunctionTypeAnnotation && (_parent6.type === "TypeAnnotation" || _parent6.type === "TSTypeAnnotation"); // Sadly we can't put it inside of FastPath::needsColon because we are
  11468. // printing ":" as part of the expression and it would put parenthesis
  11469. // around :(
  11470. var needsParens = needsColon && isArrowFunctionTypeAnnotation && (_parent6.type === "TypeAnnotation" || _parent6.type === "TSTypeAnnotation") && _parentParent2.type === "ArrowFunctionExpression";
  11471. if (isObjectTypePropertyAFunction(_parent6, options)) {
  11472. isArrowFunctionTypeAnnotation = true;
  11473. needsColon = true;
  11474. }
  11475. if (needsParens) {
  11476. parts.push("(");
  11477. }
  11478. parts.push(printFunctionParams(path, print, options,
  11479. /* expandArg */
  11480. false,
  11481. /* printTypeParams */
  11482. true)); // The returnType is not wrapped in a TypeAnnotation, so the colon
  11483. // needs to be added separately.
  11484. if (n.returnType || n.predicate || n.typeAnnotation) {
  11485. parts.push(isArrowFunctionTypeAnnotation ? " => " : ": ", path.call(print, "returnType"), path.call(print, "predicate"), path.call(print, "typeAnnotation"));
  11486. }
  11487. if (needsParens) {
  11488. parts.push(")");
  11489. }
  11490. return group$1(concat$4(parts));
  11491. }
  11492. case "FunctionTypeParam":
  11493. return concat$4([path.call(print, "name"), printOptionalToken(path), n.name ? ": " : "", path.call(print, "typeAnnotation")]);
  11494. case "GenericTypeAnnotation":
  11495. return concat$4([path.call(print, "id"), path.call(print, "typeParameters")]);
  11496. case "DeclareInterface":
  11497. case "InterfaceDeclaration":
  11498. case "InterfaceTypeAnnotation":
  11499. {
  11500. if (n.type === "DeclareInterface" || isNodeStartingWithDeclare(n, options)) {
  11501. parts.push("declare ");
  11502. }
  11503. parts.push("interface");
  11504. if (n.type === "DeclareInterface" || n.type === "InterfaceDeclaration") {
  11505. parts.push(" ", path.call(print, "id"), path.call(print, "typeParameters"));
  11506. }
  11507. if (n["extends"].length > 0) {
  11508. parts.push(group$1(indent$2(concat$4([line$3, "extends ", join$2(", ", path.map(print, "extends"))]))));
  11509. }
  11510. parts.push(" ", path.call(print, "body"));
  11511. return group$1(concat$4(parts));
  11512. }
  11513. case "ClassImplements":
  11514. case "InterfaceExtends":
  11515. return concat$4([path.call(print, "id"), path.call(print, "typeParameters")]);
  11516. case "TSIntersectionType":
  11517. case "IntersectionTypeAnnotation":
  11518. {
  11519. var types = path.map(print, "types");
  11520. var result = [];
  11521. var wasIndented = false;
  11522. for (var _i2 = 0; _i2 < types.length; ++_i2) {
  11523. if (_i2 === 0) {
  11524. result.push(types[_i2]);
  11525. } else if (isObjectType(n.types[_i2 - 1]) && isObjectType(n.types[_i2])) {
  11526. // If both are objects, don't indent
  11527. result.push(concat$4([" & ", wasIndented ? indent$2(types[_i2]) : types[_i2]]));
  11528. } else if (!isObjectType(n.types[_i2 - 1]) && !isObjectType(n.types[_i2])) {
  11529. // If no object is involved, go to the next line if it breaks
  11530. result.push(indent$2(concat$4([" &", line$3, types[_i2]])));
  11531. } else {
  11532. // If you go from object to non-object or vis-versa, then inline it
  11533. if (_i2 > 1) {
  11534. wasIndented = true;
  11535. }
  11536. result.push(" & ", _i2 > 1 ? indent$2(types[_i2]) : types[_i2]);
  11537. }
  11538. }
  11539. return group$1(concat$4(result));
  11540. }
  11541. case "TSUnionType":
  11542. case "UnionTypeAnnotation":
  11543. {
  11544. // single-line variation
  11545. // A | B | C
  11546. // multi-line variation
  11547. // | A
  11548. // | B
  11549. // | C
  11550. var _parent7 = path.getParentNode();
  11551. var _parentParent3 = path.getParentNode(1); // If there's a leading comment, the parent is doing the indentation
  11552. var shouldIndent = _parent7.type !== "TypeParameterInstantiation" && _parent7.type !== "TSTypeParameterInstantiation" && _parent7.type !== "GenericTypeAnnotation" && _parent7.type !== "TSTypeReference" && !(_parent7.type === "FunctionTypeParam" && !_parent7.name) && _parentParent3.type !== "TSTypeAssertionExpression" && !((_parent7.type === "TypeAlias" || _parent7.type === "VariableDeclarator") && hasLeadingOwnLineComment(options.originalText, n, options)); // {
  11553. // a: string
  11554. // } | null | void
  11555. // should be inlined and not be printed in the multi-line variant
  11556. var shouldHug = shouldHugType(n); // We want to align the children but without its comment, so it looks like
  11557. // | child1
  11558. // // comment
  11559. // | child2
  11560. var _printed2 = path.map(function (typePath) {
  11561. var printedType = typePath.call(print);
  11562. if (!shouldHug) {
  11563. printedType = align$1(2, printedType);
  11564. }
  11565. return comments.printComments(typePath, function () {
  11566. return printedType;
  11567. }, options);
  11568. }, "types");
  11569. if (shouldHug) {
  11570. return join$2(" | ", _printed2);
  11571. }
  11572. var code = concat$4([ifBreak$1(concat$4([shouldIndent ? line$3 : "", "| "])), join$2(concat$4([line$3, "| "]), _printed2)]);
  11573. var hasParens;
  11574. if (n.type === "TSUnionType") {
  11575. var greatGrandParent = path.getParentNode(2);
  11576. var greatGreatGrandParent = path.getParentNode(3);
  11577. hasParens = greatGrandParent && greatGrandParent.type === "TSParenthesizedType" && greatGreatGrandParent && (greatGreatGrandParent.type === "TSUnionType" || greatGreatGrandParent.type === "TSIntersectionType");
  11578. } else {
  11579. hasParens = needsParens_1(path, options);
  11580. }
  11581. if (hasParens) {
  11582. return group$1(concat$4([indent$2(code), softline$1]));
  11583. }
  11584. return group$1(shouldIndent ? indent$2(code) : code);
  11585. }
  11586. case "NullableTypeAnnotation":
  11587. return concat$4(["?", path.call(print, "typeAnnotation")]);
  11588. case "TSNullKeyword":
  11589. case "NullLiteralTypeAnnotation":
  11590. return "null";
  11591. case "ThisTypeAnnotation":
  11592. return "this";
  11593. case "NumberTypeAnnotation":
  11594. return "number";
  11595. case "ObjectTypeCallProperty":
  11596. if (n.static) {
  11597. parts.push("static ");
  11598. }
  11599. parts.push(path.call(print, "value"));
  11600. return concat$4(parts);
  11601. case "ObjectTypeIndexer":
  11602. {
  11603. var _variance = getFlowVariance(n);
  11604. return concat$4([_variance || "", "[", path.call(print, "id"), n.id ? ": " : "", path.call(print, "key"), "]: ", path.call(print, "value")]);
  11605. }
  11606. case "ObjectTypeProperty":
  11607. {
  11608. var _variance2 = getFlowVariance(n);
  11609. var modifier = "";
  11610. if (n.proto) {
  11611. modifier = "proto ";
  11612. } else if (n.static) {
  11613. modifier = "static ";
  11614. }
  11615. return concat$4([modifier, isGetterOrSetter(n) ? n.kind + " " : "", _variance2 || "", printPropertyKey(path, options, print), printOptionalToken(path), isFunctionNotation(n, options) ? "" : ": ", path.call(print, "value")]);
  11616. }
  11617. case "QualifiedTypeIdentifier":
  11618. return concat$4([path.call(print, "qualification"), ".", path.call(print, "id")]);
  11619. case "StringLiteralTypeAnnotation":
  11620. return nodeStr(n, options);
  11621. case "NumberLiteralTypeAnnotation":
  11622. assert.strictEqual(_typeof(n.value), "number");
  11623. if (n.extra != null) {
  11624. return printNumber$1(n.extra.raw);
  11625. }
  11626. return printNumber$1(n.raw);
  11627. case "StringTypeAnnotation":
  11628. return "string";
  11629. case "DeclareTypeAlias":
  11630. case "TypeAlias":
  11631. {
  11632. if (n.type === "DeclareTypeAlias" || isNodeStartingWithDeclare(n, options)) {
  11633. parts.push("declare ");
  11634. }
  11635. var _printed3 = printAssignmentRight(n.id, n.right, path.call(print, "right"), options);
  11636. parts.push("type ", path.call(print, "id"), path.call(print, "typeParameters"), " =", _printed3, semi);
  11637. return group$1(concat$4(parts));
  11638. }
  11639. case "TypeCastExpression":
  11640. return concat$4(["(", path.call(print, "expression"), ": ", path.call(print, "typeAnnotation"), ")"]);
  11641. case "TypeParameterDeclaration":
  11642. case "TypeParameterInstantiation":
  11643. case "TSTypeParameterDeclaration":
  11644. case "TSTypeParameterInstantiation":
  11645. return printTypeParameters(path, options, print, "params");
  11646. case "TSTypeParameter":
  11647. case "TypeParameter":
  11648. {
  11649. var _parent8 = path.getParentNode();
  11650. if (_parent8.type === "TSMappedType") {
  11651. parts.push("[", path.call(print, "name"));
  11652. if (n.constraint) {
  11653. parts.push(" in ", path.call(print, "constraint"));
  11654. }
  11655. parts.push("]");
  11656. return concat$4(parts);
  11657. }
  11658. var _variance3 = getFlowVariance(n);
  11659. if (_variance3) {
  11660. parts.push(_variance3);
  11661. }
  11662. parts.push(path.call(print, "name"));
  11663. if (n.bound) {
  11664. parts.push(": ");
  11665. parts.push(path.call(print, "bound"));
  11666. }
  11667. if (n.constraint) {
  11668. parts.push(" extends ", path.call(print, "constraint"));
  11669. }
  11670. if (n["default"]) {
  11671. parts.push(" = ", path.call(print, "default"));
  11672. }
  11673. return concat$4(parts);
  11674. }
  11675. case "TypeofTypeAnnotation":
  11676. return concat$4(["typeof ", path.call(print, "argument")]);
  11677. case "VoidTypeAnnotation":
  11678. return "void";
  11679. case "InferredPredicate":
  11680. return "%checks";
  11681. // Unhandled types below. If encountered, nodes of these types should
  11682. // be either left alone or desugared into AST types that are fully
  11683. // supported by the pretty-printer.
  11684. case "DeclaredPredicate":
  11685. return concat$4(["%checks(", path.call(print, "value"), ")"]);
  11686. case "TSAbstractKeyword":
  11687. return "abstract";
  11688. case "TSAnyKeyword":
  11689. return "any";
  11690. case "TSAsyncKeyword":
  11691. return "async";
  11692. case "TSBooleanKeyword":
  11693. return "boolean";
  11694. case "TSConstKeyword":
  11695. return "const";
  11696. case "TSDeclareKeyword":
  11697. return "declare";
  11698. case "TSExportKeyword":
  11699. return "export";
  11700. case "TSNeverKeyword":
  11701. return "never";
  11702. case "TSNumberKeyword":
  11703. return "number";
  11704. case "TSObjectKeyword":
  11705. return "object";
  11706. case "TSProtectedKeyword":
  11707. return "protected";
  11708. case "TSPrivateKeyword":
  11709. return "private";
  11710. case "TSPublicKeyword":
  11711. return "public";
  11712. case "TSReadonlyKeyword":
  11713. return "readonly";
  11714. case "TSSymbolKeyword":
  11715. return "symbol";
  11716. case "TSStaticKeyword":
  11717. return "static";
  11718. case "TSStringKeyword":
  11719. return "string";
  11720. case "TSUndefinedKeyword":
  11721. return "undefined";
  11722. case "TSVoidKeyword":
  11723. return "void";
  11724. case "TSAsExpression":
  11725. return concat$4([path.call(print, "expression"), " as ", path.call(print, "typeAnnotation")]);
  11726. case "TSArrayType":
  11727. return concat$4([path.call(print, "elementType"), "[]"]);
  11728. case "TSPropertySignature":
  11729. {
  11730. if (n.export) {
  11731. parts.push("export ");
  11732. }
  11733. if (n.accessibility) {
  11734. parts.push(n.accessibility + " ");
  11735. }
  11736. if (n.static) {
  11737. parts.push("static ");
  11738. }
  11739. if (n.readonly) {
  11740. parts.push("readonly ");
  11741. }
  11742. if (n.computed) {
  11743. parts.push("[");
  11744. }
  11745. parts.push(printPropertyKey(path, options, print));
  11746. if (n.computed) {
  11747. parts.push("]");
  11748. }
  11749. parts.push(printOptionalToken(path));
  11750. if (n.typeAnnotation) {
  11751. parts.push(": ");
  11752. parts.push(path.call(print, "typeAnnotation"));
  11753. } // This isn't valid semantically, but it's in the AST so we can print it.
  11754. if (n.initializer) {
  11755. parts.push(" = ", path.call(print, "initializer"));
  11756. }
  11757. return concat$4(parts);
  11758. }
  11759. case "TSParameterProperty":
  11760. if (n.accessibility) {
  11761. parts.push(n.accessibility + " ");
  11762. }
  11763. if (n.export) {
  11764. parts.push("export ");
  11765. }
  11766. if (n.static) {
  11767. parts.push("static ");
  11768. }
  11769. if (n.readonly) {
  11770. parts.push("readonly ");
  11771. }
  11772. parts.push(path.call(print, "parameter"));
  11773. return concat$4(parts);
  11774. case "TSTypeReference":
  11775. return concat$4([path.call(print, "typeName"), printTypeParameters(path, options, print, "typeParameters")]);
  11776. case "TSTypeQuery":
  11777. return concat$4(["typeof ", path.call(print, "exprName")]);
  11778. case "TSParenthesizedType":
  11779. {
  11780. return path.call(print, "typeAnnotation");
  11781. }
  11782. case "TSIndexSignature":
  11783. {
  11784. var _parent9 = path.getParentNode();
  11785. return concat$4([n.export ? "export " : "", n.accessibility ? concat$4([n.accessibility, " "]) : "", n.static ? "static " : "", n.readonly ? "readonly " : "", "[", path.call(print, "index"), "]: ", path.call(print, "typeAnnotation"), _parent9.type === "ClassBody" ? semi : ""]);
  11786. }
  11787. case "TSTypePredicate":
  11788. return concat$4([path.call(print, "parameterName"), " is ", path.call(print, "typeAnnotation")]);
  11789. case "TSNonNullExpression":
  11790. return concat$4([path.call(print, "expression"), "!"]);
  11791. case "TSThisType":
  11792. return "this";
  11793. case "TSLastTypeNode":
  11794. // TSImportType
  11795. return concat$4([!n.isTypeOf ? "" : "typeof ", "import(", path.call(print, "argument"), ")", !n.qualifier ? "" : concat$4([".", path.call(print, "qualifier")]), printTypeParameters(path, options, print, "typeParameters")]);
  11796. case "TSLiteralType":
  11797. return path.call(print, "literal");
  11798. case "TSIndexedAccessType":
  11799. return concat$4([path.call(print, "objectType"), "[", path.call(print, "indexType"), "]"]);
  11800. case "TSConstructSignature":
  11801. case "TSConstructorType":
  11802. case "TSCallSignature":
  11803. {
  11804. if (n.type !== "TSCallSignature") {
  11805. parts.push("new ");
  11806. }
  11807. parts.push(group$1(printFunctionParams(path, print, options,
  11808. /* expandArg */
  11809. false,
  11810. /* printTypeParams */
  11811. true)));
  11812. if (n.typeAnnotation) {
  11813. var isType = n.type === "TSConstructorType";
  11814. parts.push(isType ? " => " : ": ", path.call(print, "typeAnnotation"));
  11815. }
  11816. return concat$4(parts);
  11817. }
  11818. case "TSTypeOperator":
  11819. return concat$4([n.operator, " ", path.call(print, "typeAnnotation")]);
  11820. case "TSMappedType":
  11821. return group$1(concat$4(["{", indent$2(concat$4([options.bracketSpacing ? line$3 : softline$1, n.readonlyToken ? concat$4([getTypeScriptMappedTypeModifier(n.readonlyToken, "readonly"), " "]) : "", printTypeScriptModifiers(path, options, print), path.call(print, "typeParameter"), n.questionToken ? getTypeScriptMappedTypeModifier(n.questionToken, "?") : "", ": ", path.call(print, "typeAnnotation")])), comments.printDanglingComments(path, options,
  11822. /* sameIndent */
  11823. true), options.bracketSpacing ? line$3 : softline$1, "}"]));
  11824. case "TSMethodSignature":
  11825. parts.push(n.accessibility ? concat$4([n.accessibility, " "]) : "", n.export ? "export " : "", n.static ? "static " : "", n.readonly ? "readonly " : "", n.computed ? "[" : "", path.call(print, "key"), n.computed ? "]" : "", printOptionalToken(path), printFunctionParams(path, print, options,
  11826. /* expandArg */
  11827. false,
  11828. /* printTypeParams */
  11829. true));
  11830. if (n.typeAnnotation) {
  11831. parts.push(": ", path.call(print, "typeAnnotation"));
  11832. }
  11833. return group$1(concat$4(parts));
  11834. case "TSNamespaceExportDeclaration":
  11835. parts.push("export as namespace ", path.call(print, "name"));
  11836. if (options.semi) {
  11837. parts.push(";");
  11838. }
  11839. return group$1(concat$4(parts));
  11840. case "TSEnumDeclaration":
  11841. if (isNodeStartingWithDeclare(n, options)) {
  11842. parts.push("declare ");
  11843. }
  11844. if (n.modifiers) {
  11845. parts.push(printTypeScriptModifiers(path, options, print));
  11846. }
  11847. if (n.const) {
  11848. parts.push("const ");
  11849. }
  11850. parts.push("enum ", path.call(print, "id"), " ");
  11851. if (n.members.length === 0) {
  11852. parts.push(group$1(concat$4(["{", comments.printDanglingComments(path, options), softline$1, "}"])));
  11853. } else {
  11854. parts.push(group$1(concat$4(["{", indent$2(concat$4([hardline$3, printArrayItems(path, options, "members", print), shouldPrintComma(options, "es5") ? "," : ""])), comments.printDanglingComments(path, options,
  11855. /* sameIndent */
  11856. true), hardline$3, "}"])));
  11857. }
  11858. return concat$4(parts);
  11859. case "TSEnumMember":
  11860. parts.push(path.call(print, "id"));
  11861. if (n.initializer) {
  11862. parts.push(" = ", path.call(print, "initializer"));
  11863. }
  11864. return concat$4(parts);
  11865. case "TSImportEqualsDeclaration":
  11866. parts.push(printTypeScriptModifiers(path, options, print), "import ", path.call(print, "name"), " = ", path.call(print, "moduleReference"));
  11867. if (options.semi) {
  11868. parts.push(";");
  11869. }
  11870. return group$1(concat$4(parts));
  11871. case "TSExternalModuleReference":
  11872. return concat$4(["require(", path.call(print, "expression"), ")"]);
  11873. case "TSModuleDeclaration":
  11874. {
  11875. var _parent10 = path.getParentNode();
  11876. var isExternalModule = isLiteral(n.id);
  11877. var parentIsDeclaration = _parent10.type === "TSModuleDeclaration";
  11878. var bodyIsDeclaration = n.body && n.body.type === "TSModuleDeclaration";
  11879. if (parentIsDeclaration) {
  11880. parts.push(".");
  11881. } else {
  11882. if (n.declare === true) {
  11883. parts.push("declare ");
  11884. }
  11885. parts.push(printTypeScriptModifiers(path, options, print)); // Global declaration looks like this:
  11886. // (declare)? global { ... }
  11887. var isGlobalDeclaration = n.id.type === "Identifier" && n.id.name === "global" && !/namespace|module/.test(options.originalText.slice(options.locStart(n), options.locStart(n.id)));
  11888. if (!isGlobalDeclaration) {
  11889. parts.push(isExternalModule ? "module " : "namespace ");
  11890. }
  11891. }
  11892. parts.push(path.call(print, "id"));
  11893. if (bodyIsDeclaration) {
  11894. parts.push(path.call(print, "body"));
  11895. } else if (n.body) {
  11896. parts.push(" {", indent$2(concat$4([line$3, path.call(function (bodyPath) {
  11897. return comments.printDanglingComments(bodyPath, options, true);
  11898. }, "body"), group$1(path.call(print, "body"))])), line$3, "}");
  11899. } else {
  11900. parts.push(semi);
  11901. }
  11902. return concat$4(parts);
  11903. }
  11904. case "TSModuleBlock":
  11905. return path.call(function (bodyPath) {
  11906. return printStatementSequence(bodyPath, options, print);
  11907. }, "body");
  11908. case "PrivateName":
  11909. return concat$4(["#", path.call(print, "id")]);
  11910. case "TSConditionalType":
  11911. return formatTernaryOperator(path, options, print, {
  11912. beforeParts: function beforeParts() {
  11913. return [path.call(print, "checkType"), " ", "extends", " ", path.call(print, "extendsType")];
  11914. },
  11915. shouldCheckJsx: false,
  11916. operatorName: "TSConditionalType",
  11917. consequentNode: "trueType",
  11918. alternateNode: "falseType",
  11919. testNode: "checkType",
  11920. breakNested: false
  11921. });
  11922. case "TSInferType":
  11923. return concat$4(["infer", " ", path.call(print, "typeParameter")]);
  11924. case "InterpreterDirective":
  11925. parts.push("#!", n.value, hardline$3);
  11926. if (isNextLineEmpty$2(options.originalText, n, options)) {
  11927. parts.push(hardline$3);
  11928. }
  11929. return concat$4(parts);
  11930. default:
  11931. /* istanbul ignore next */
  11932. throw new Error("unknown type: " + JSON.stringify(n.type));
  11933. }
  11934. }
  11935. function printStatementSequence(path, options, print) {
  11936. var printed = [];
  11937. var bodyNode = path.getNode();
  11938. var isClass = bodyNode.type === "ClassBody";
  11939. path.map(function (stmtPath, i) {
  11940. var stmt = stmtPath.getValue(); // Just in case the AST has been modified to contain falsy
  11941. // "statements," it's safer simply to skip them.
  11942. /* istanbul ignore if */
  11943. if (!stmt) {
  11944. return;
  11945. } // Skip printing EmptyStatement nodes to avoid leaving stray
  11946. // semicolons lying around.
  11947. if (stmt.type === "EmptyStatement") {
  11948. return;
  11949. }
  11950. var stmtPrinted = print(stmtPath);
  11951. var text = options.originalText;
  11952. var parts = []; // in no-semi mode, prepend statement with semicolon if it might break ASI
  11953. // don't prepend the only JSX element in a program with semicolon
  11954. if (!options.semi && !isClass && !isTheOnlyJSXElementInMarkdown(options, stmtPath) && stmtNeedsASIProtection(stmtPath, options)) {
  11955. if (stmt.comments && stmt.comments.some(function (comment) {
  11956. return comment.leading;
  11957. })) {
  11958. parts.push(print(stmtPath, {
  11959. needsSemi: true
  11960. }));
  11961. } else {
  11962. parts.push(";", stmtPrinted);
  11963. }
  11964. } else {
  11965. parts.push(stmtPrinted);
  11966. }
  11967. if (!options.semi && isClass) {
  11968. if (classPropMayCauseASIProblems(stmtPath)) {
  11969. parts.push(";");
  11970. } else if (stmt.type === "ClassProperty") {
  11971. var nextChild = bodyNode.body[i + 1];
  11972. if (classChildNeedsASIProtection(nextChild)) {
  11973. parts.push(";");
  11974. }
  11975. }
  11976. }
  11977. if (isNextLineEmpty$2(text, stmt, options) && !isLastStatement(stmtPath)) {
  11978. parts.push(hardline$3);
  11979. }
  11980. printed.push(concat$4(parts));
  11981. });
  11982. return join$2(hardline$3, printed);
  11983. }
  11984. function printPropertyKey(path, options, print) {
  11985. var node = path.getNode();
  11986. var key = node.key;
  11987. if (key.type === "Identifier" && !node.computed && options.parser === "json") {
  11988. // a -> "a"
  11989. return path.call(function (keyPath) {
  11990. return comments.printComments(keyPath, function () {
  11991. return JSON.stringify(key.name);
  11992. }, options);
  11993. }, "key");
  11994. }
  11995. if (isStringLiteral(key) && isIdentifierName(key.value) && !node.computed && options.parser !== "json" && !(options.parser === "typescript" && node.type === "ClassProperty")) {
  11996. // 'a' -> a
  11997. return path.call(function (keyPath) {
  11998. return comments.printComments(keyPath, function () {
  11999. return key.value;
  12000. }, options);
  12001. }, "key");
  12002. }
  12003. return path.call(print, "key");
  12004. }
  12005. function printMethod(path, options, print) {
  12006. var node = path.getNode();
  12007. var semi = options.semi ? ";" : "";
  12008. var kind = node.kind;
  12009. var parts = [];
  12010. if (node.type === "ObjectMethod" || node.type === "ClassMethod") {
  12011. node.value = node;
  12012. }
  12013. if (node.value.async) {
  12014. parts.push("async ");
  12015. }
  12016. if (!kind || kind === "init" || kind === "method" || kind === "constructor") {
  12017. if (node.value.generator) {
  12018. parts.push("*");
  12019. }
  12020. } else {
  12021. assert.ok(kind === "get" || kind === "set");
  12022. parts.push(kind, " ");
  12023. }
  12024. var key = printPropertyKey(path, options, print);
  12025. if (node.computed) {
  12026. key = concat$4(["[", key, "]"]);
  12027. }
  12028. parts.push(key, concat$4(path.call(function (valuePath) {
  12029. return [printFunctionTypeParameters(valuePath, options, print), group$1(concat$4([printFunctionParams(valuePath, print, options), printReturnType(valuePath, print, options)]))];
  12030. }, "value")));
  12031. if (!node.value.body || node.value.body.length === 0) {
  12032. parts.push(semi);
  12033. } else {
  12034. parts.push(" ", path.call(print, "value", "body"));
  12035. }
  12036. return concat$4(parts);
  12037. }
  12038. function couldGroupArg(arg) {
  12039. return arg.type === "ObjectExpression" && (arg.properties.length > 0 || arg.comments) || arg.type === "ArrayExpression" && (arg.elements.length > 0 || arg.comments) || arg.type === "TSTypeAssertionExpression" || arg.type === "TSAsExpression" || arg.type === "FunctionExpression" || arg.type === "ArrowFunctionExpression" && !arg.returnType && (arg.body.type === "BlockStatement" || arg.body.type === "ArrowFunctionExpression" || arg.body.type === "ObjectExpression" || arg.body.type === "ArrayExpression" || arg.body.type === "CallExpression" || arg.body.type === "OptionalCallExpression" || isJSXNode(arg.body));
  12040. }
  12041. function shouldGroupLastArg(args) {
  12042. var lastArg = getLast$4(args);
  12043. var penultimateArg = getPenultimate$1(args);
  12044. return !hasLeadingComment(lastArg) && !hasTrailingComment(lastArg) && couldGroupArg(lastArg) && ( // If the last two arguments are of the same type,
  12045. // disable last element expansion.
  12046. !penultimateArg || penultimateArg.type !== lastArg.type);
  12047. }
  12048. function shouldGroupFirstArg(args) {
  12049. if (args.length !== 2) {
  12050. return false;
  12051. }
  12052. var firstArg = args[0];
  12053. var secondArg = args[1];
  12054. return (!firstArg.comments || !firstArg.comments.length) && (firstArg.type === "FunctionExpression" || firstArg.type === "ArrowFunctionExpression" && firstArg.body.type === "BlockStatement") && !couldGroupArg(secondArg);
  12055. }
  12056. var functionCompositionFunctionNames = new Set(["pipe", // RxJS, Ramda
  12057. "pipeP", // Ramda
  12058. "pipeK", // Ramda
  12059. "compose", // Ramda, Redux
  12060. "composeFlipped", // Not from any library, but common in Haskell, so supported
  12061. "composeP", // Ramda
  12062. "composeK", // Ramda
  12063. "flow", // Lodash
  12064. "flowRight", // Lodash
  12065. "connect" // Redux
  12066. ]);
  12067. function isFunctionCompositionFunction(node) {
  12068. switch (node.type) {
  12069. case "OptionalMemberExpression":
  12070. case "MemberExpression":
  12071. {
  12072. return isFunctionCompositionFunction(node.property);
  12073. }
  12074. case "Identifier":
  12075. {
  12076. return functionCompositionFunctionNames.has(node.name);
  12077. }
  12078. case "StringLiteral":
  12079. case "Literal":
  12080. {
  12081. return functionCompositionFunctionNames.has(node.value);
  12082. }
  12083. }
  12084. }
  12085. function printArgumentsList(path, options, print) {
  12086. var node = path.getValue();
  12087. var args = node.arguments;
  12088. if (args.length === 0) {
  12089. return concat$4(["(", comments.printDanglingComments(path, options,
  12090. /* sameIndent */
  12091. true), ")"]);
  12092. }
  12093. var anyArgEmptyLine = false;
  12094. var hasEmptyLineFollowingFirstArg = false;
  12095. var lastArgIndex = args.length - 1;
  12096. var printedArguments = path.map(function (argPath, index) {
  12097. var arg = argPath.getNode();
  12098. var parts = [print(argPath)];
  12099. if (index === lastArgIndex) {// do nothing
  12100. } else if (isNextLineEmpty$2(options.originalText, arg, options)) {
  12101. if (index === 0) {
  12102. hasEmptyLineFollowingFirstArg = true;
  12103. }
  12104. anyArgEmptyLine = true;
  12105. parts.push(",", hardline$3, hardline$3);
  12106. } else {
  12107. parts.push(",", line$3);
  12108. }
  12109. return concat$4(parts);
  12110. }, "arguments");
  12111. var maybeTrailingComma = shouldPrintComma(options, "all") ? "," : "";
  12112. function allArgsBrokenOut() {
  12113. return group$1(concat$4(["(", indent$2(concat$4([line$3, concat$4(printedArguments)])), maybeTrailingComma, line$3, ")"]), {
  12114. shouldBreak: true
  12115. });
  12116. } // We want to get
  12117. // pipe(
  12118. // x => x + 1,
  12119. // x => x - 1
  12120. // )
  12121. // here, but not
  12122. // process.stdout.pipe(socket)
  12123. if (isFunctionCompositionFunction(node.callee) && args.length > 1) {
  12124. return allArgsBrokenOut();
  12125. }
  12126. var shouldGroupFirst = shouldGroupFirstArg(args);
  12127. var shouldGroupLast = shouldGroupLastArg(args);
  12128. if (shouldGroupFirst || shouldGroupLast) {
  12129. var shouldBreak = (shouldGroupFirst ? printedArguments.slice(1).some(willBreak$1) : printedArguments.slice(0, -1).some(willBreak$1)) || anyArgEmptyLine; // We want to print the last argument with a special flag
  12130. var printedExpanded;
  12131. var i = 0;
  12132. path.each(function (argPath) {
  12133. if (shouldGroupFirst && i === 0) {
  12134. printedExpanded = [concat$4([argPath.call(function (p) {
  12135. return print(p, {
  12136. expandFirstArg: true
  12137. });
  12138. }), printedArguments.length > 1 ? "," : "", hasEmptyLineFollowingFirstArg ? hardline$3 : line$3, hasEmptyLineFollowingFirstArg ? hardline$3 : ""])].concat(printedArguments.slice(1));
  12139. }
  12140. if (shouldGroupLast && i === args.length - 1) {
  12141. printedExpanded = printedArguments.slice(0, -1).concat(argPath.call(function (p) {
  12142. return print(p, {
  12143. expandLastArg: true
  12144. });
  12145. }));
  12146. }
  12147. i++;
  12148. }, "arguments");
  12149. var somePrintedArgumentsWillBreak = printedArguments.some(willBreak$1);
  12150. return concat$4([somePrintedArgumentsWillBreak ? breakParent$2 : "", conditionalGroup$1([concat$4([ifBreak$1(indent$2(concat$4(["(", softline$1, concat$4(printedExpanded)])), concat$4(["(", concat$4(printedExpanded)])), somePrintedArgumentsWillBreak ? concat$4([ifBreak$1(maybeTrailingComma), softline$1]) : "", ")"]), shouldGroupFirst ? concat$4(["(", group$1(printedExpanded[0], {
  12151. shouldBreak: true
  12152. }), concat$4(printedExpanded.slice(1)), ")"]) : concat$4(["(", concat$4(printedArguments.slice(0, -1)), group$1(getLast$4(printedExpanded), {
  12153. shouldBreak: true
  12154. }), ")"]), allArgsBrokenOut()], {
  12155. shouldBreak: shouldBreak
  12156. })]);
  12157. }
  12158. return group$1(concat$4(["(", indent$2(concat$4([softline$1, concat$4(printedArguments)])), ifBreak$1(shouldPrintComma(options, "all") ? "," : ""), softline$1, ")"]), {
  12159. shouldBreak: printedArguments.some(willBreak$1) || anyArgEmptyLine
  12160. });
  12161. }
  12162. function printTypeAnnotation(path, options, print) {
  12163. var node = path.getValue();
  12164. if (!node.typeAnnotation) {
  12165. return "";
  12166. }
  12167. var parentNode = path.getParentNode();
  12168. var isDefinite = node.definite || parentNode && parentNode.type === "VariableDeclarator" && parentNode.definite;
  12169. var isFunctionDeclarationIdentifier = parentNode.type === "DeclareFunction" && parentNode.id === node;
  12170. if (isFlowAnnotationComment(options.originalText, node.typeAnnotation, options)) {
  12171. return concat$4([" /*: ", path.call(print, "typeAnnotation"), " */"]);
  12172. }
  12173. return concat$4([isFunctionDeclarationIdentifier ? "" : isDefinite ? "!: " : ": ", path.call(print, "typeAnnotation")]);
  12174. }
  12175. function printFunctionTypeParameters(path, options, print) {
  12176. var fun = path.getValue();
  12177. if (fun.typeArguments) {
  12178. return path.call(print, "typeArguments");
  12179. }
  12180. if (fun.typeParameters) {
  12181. return path.call(print, "typeParameters");
  12182. }
  12183. return "";
  12184. }
  12185. function printFunctionParams(path, print, options, expandArg, printTypeParams) {
  12186. var fun = path.getValue();
  12187. var paramsField = fun.parameters ? "parameters" : "params";
  12188. var typeParams = printTypeParams ? printFunctionTypeParameters(path, options, print) : "";
  12189. var printed = [];
  12190. if (fun[paramsField]) {
  12191. printed = path.map(print, paramsField);
  12192. }
  12193. if (fun.rest) {
  12194. printed.push(concat$4(["...", path.call(print, "rest")]));
  12195. }
  12196. if (printed.length === 0) {
  12197. return concat$4([typeParams, "(", comments.printDanglingComments(path, options,
  12198. /* sameIndent */
  12199. true, function (comment) {
  12200. return getNextNonSpaceNonCommentCharacter$1(options.originalText, comment, options.locEnd) === ")";
  12201. }), ")"]);
  12202. }
  12203. var lastParam = getLast$4(fun[paramsField]); // If the parent is a call with the first/last argument expansion and this is the
  12204. // params of the first/last argument, we dont want the arguments to break and instead
  12205. // want the whole expression to be on a new line.
  12206. //
  12207. // Good: Bad:
  12208. // verylongcall( verylongcall((
  12209. // (a, b) => { a,
  12210. // } b,
  12211. // }) ) => {
  12212. // })
  12213. if (expandArg && !(fun[paramsField] && fun[paramsField].some(function (n) {
  12214. return n.comments;
  12215. }))) {
  12216. return group$1(concat$4([removeLines$1(typeParams), "(", join$2(", ", printed.map(removeLines$1)), ")"]));
  12217. } // Single object destructuring should hug
  12218. //
  12219. // function({
  12220. // a,
  12221. // b,
  12222. // c
  12223. // }) {}
  12224. if (shouldHugArguments(fun)) {
  12225. return concat$4([typeParams, "(", join$2(", ", printed), ")"]);
  12226. }
  12227. var parent = path.getParentNode(); // don't break in specs, eg; `it("should maintain parens around done even when long", (done) => {})`
  12228. if (isTestCall(parent)) {
  12229. return concat$4([typeParams, "(", join$2(", ", printed), ")"]);
  12230. }
  12231. var flowTypeAnnotations = ["AnyTypeAnnotation", "NullLiteralTypeAnnotation", "GenericTypeAnnotation", "ThisTypeAnnotation", "NumberTypeAnnotation", "VoidTypeAnnotation", "EmptyTypeAnnotation", "MixedTypeAnnotation", "BooleanTypeAnnotation", "BooleanLiteralTypeAnnotation", "StringTypeAnnotation"];
  12232. var isFlowShorthandWithOneArg = (isObjectTypePropertyAFunction(parent, options) || isTypeAnnotationAFunction(parent, options) || parent.type === "TypeAlias" || parent.type === "UnionTypeAnnotation" || parent.type === "TSUnionType" || parent.type === "IntersectionTypeAnnotation" || parent.type === "FunctionTypeAnnotation" && parent.returnType === fun) && fun[paramsField].length === 1 && fun[paramsField][0].name === null && fun[paramsField][0].typeAnnotation && fun.typeParameters === null && flowTypeAnnotations.indexOf(fun[paramsField][0].typeAnnotation.type) !== -1 && !(fun[paramsField][0].typeAnnotation.type === "GenericTypeAnnotation" && fun[paramsField][0].typeAnnotation.typeParameters) && !fun.rest;
  12233. if (isFlowShorthandWithOneArg) {
  12234. if (options.arrowParens === "always") {
  12235. return concat$4(["(", concat$4(printed), ")"]);
  12236. }
  12237. return concat$4(printed);
  12238. }
  12239. var canHaveTrailingComma = !(lastParam && lastParam.type === "RestElement") && !fun.rest;
  12240. return concat$4([typeParams, "(", indent$2(concat$4([softline$1, join$2(concat$4([",", line$3]), printed)])), ifBreak$1(canHaveTrailingComma && shouldPrintComma(options, "all") ? "," : ""), softline$1, ")"]);
  12241. }
  12242. function shouldPrintParamsWithoutParens(path, options) {
  12243. if (options.arrowParens === "always") {
  12244. return false;
  12245. }
  12246. if (options.arrowParens === "avoid") {
  12247. var node = path.getValue();
  12248. return canPrintParamsWithoutParens(node);
  12249. } // Fallback default; should be unreachable
  12250. return false;
  12251. }
  12252. function canPrintParamsWithoutParens(node) {
  12253. return node.params.length === 1 && !node.rest && !node.typeParameters && !hasDanglingComments(node) && node.params[0].type === "Identifier" && !node.params[0].typeAnnotation && !node.params[0].comments && !node.params[0].optional && !node.predicate && !node.returnType;
  12254. }
  12255. function printFunctionDeclaration(path, print, options) {
  12256. var n = path.getValue();
  12257. var parts = [];
  12258. if (n.async) {
  12259. parts.push("async ");
  12260. }
  12261. parts.push("function");
  12262. if (n.generator) {
  12263. parts.push("*");
  12264. }
  12265. if (n.id) {
  12266. parts.push(" ", path.call(print, "id"));
  12267. }
  12268. parts.push(printFunctionTypeParameters(path, options, print), group$1(concat$4([printFunctionParams(path, print, options), printReturnType(path, print, options)])), n.body ? " " : "", path.call(print, "body"));
  12269. return concat$4(parts);
  12270. }
  12271. function printObjectMethod(path, options, print) {
  12272. var objMethod = path.getValue();
  12273. var parts = [];
  12274. if (objMethod.async) {
  12275. parts.push("async ");
  12276. }
  12277. if (objMethod.generator) {
  12278. parts.push("*");
  12279. }
  12280. if (objMethod.method || objMethod.kind === "get" || objMethod.kind === "set") {
  12281. return printMethod(path, options, print);
  12282. }
  12283. var key = printPropertyKey(path, options, print);
  12284. if (objMethod.computed) {
  12285. parts.push("[", key, "]");
  12286. } else {
  12287. parts.push(key);
  12288. }
  12289. parts.push(printFunctionTypeParameters(path, options, print), group$1(concat$4([printFunctionParams(path, print, options), printReturnType(path, print, options)])), " ", path.call(print, "body"));
  12290. return concat$4(parts);
  12291. }
  12292. function printReturnType(path, print, options) {
  12293. var n = path.getValue();
  12294. var returnType = path.call(print, "returnType");
  12295. if (n.returnType && isFlowAnnotationComment(options.originalText, n.returnType, options)) {
  12296. return concat$4([" /*: ", returnType, " */"]);
  12297. }
  12298. var parts = [returnType]; // prepend colon to TypeScript type annotation
  12299. if (n.returnType && n.returnType.typeAnnotation) {
  12300. parts.unshift(": ");
  12301. }
  12302. if (n.predicate) {
  12303. // The return type will already add the colon, but otherwise we
  12304. // need to do it ourselves
  12305. parts.push(n.returnType ? " " : ": ", path.call(print, "predicate"));
  12306. }
  12307. return concat$4(parts);
  12308. }
  12309. function printExportDeclaration(path, options, print) {
  12310. var decl = path.getValue();
  12311. var semi = options.semi ? ";" : "";
  12312. var parts = ["export "];
  12313. var isDefault = decl["default"] || decl.type === "ExportDefaultDeclaration";
  12314. if (isDefault) {
  12315. parts.push("default ");
  12316. }
  12317. parts.push(comments.printDanglingComments(path, options,
  12318. /* sameIndent */
  12319. true));
  12320. if (needsHardlineAfterDanglingComment(decl)) {
  12321. parts.push(hardline$3);
  12322. }
  12323. if (decl.declaration) {
  12324. parts.push(path.call(print, "declaration"));
  12325. if (isDefault && decl.declaration.type !== "ClassDeclaration" && decl.declaration.type !== "FunctionDeclaration" && decl.declaration.type !== "TSAbstractClassDeclaration" && decl.declaration.type !== "TSInterfaceDeclaration" && decl.declaration.type !== "DeclareClass" && decl.declaration.type !== "DeclareFunction") {
  12326. parts.push(semi);
  12327. }
  12328. } else {
  12329. if (decl.specifiers && decl.specifiers.length > 0) {
  12330. var specifiers = [];
  12331. var defaultSpecifiers = [];
  12332. var namespaceSpecifiers = [];
  12333. path.each(function (specifierPath) {
  12334. var specifierType = path.getValue().type;
  12335. if (specifierType === "ExportSpecifier") {
  12336. specifiers.push(print(specifierPath));
  12337. } else if (specifierType === "ExportDefaultSpecifier") {
  12338. defaultSpecifiers.push(print(specifierPath));
  12339. } else if (specifierType === "ExportNamespaceSpecifier") {
  12340. namespaceSpecifiers.push(concat$4(["* as ", print(specifierPath)]));
  12341. }
  12342. }, "specifiers");
  12343. var isNamespaceFollowed = namespaceSpecifiers.length !== 0 && specifiers.length !== 0;
  12344. var isDefaultFollowed = defaultSpecifiers.length !== 0 && (namespaceSpecifiers.length !== 0 || specifiers.length !== 0);
  12345. parts.push(decl.exportKind === "type" ? "type " : "", concat$4(defaultSpecifiers), concat$4([isDefaultFollowed ? ", " : ""]), concat$4(namespaceSpecifiers), concat$4([isNamespaceFollowed ? ", " : ""]), specifiers.length !== 0 ? group$1(concat$4(["{", indent$2(concat$4([options.bracketSpacing ? line$3 : softline$1, join$2(concat$4([",", line$3]), specifiers)])), ifBreak$1(shouldPrintComma(options) ? "," : ""), options.bracketSpacing ? line$3 : softline$1, "}"])) : "");
  12346. } else {
  12347. parts.push("{}");
  12348. }
  12349. if (decl.source) {
  12350. parts.push(" from ", path.call(print, "source"));
  12351. }
  12352. parts.push(semi);
  12353. }
  12354. return concat$4(parts);
  12355. }
  12356. function printFlowDeclaration(path, parts) {
  12357. var parentExportDecl = getParentExportDeclaration$1(path);
  12358. if (parentExportDecl) {
  12359. assert.strictEqual(parentExportDecl.type, "DeclareExportDeclaration");
  12360. } else {
  12361. // If the parent node has type DeclareExportDeclaration, then it
  12362. // will be responsible for printing the "declare" token. Otherwise
  12363. // it needs to be printed with this non-exported declaration node.
  12364. parts.unshift("declare ");
  12365. }
  12366. return concat$4(parts);
  12367. }
  12368. function getFlowVariance(path) {
  12369. if (!path.variance) {
  12370. return null;
  12371. } // Babylon 7.0 currently uses variance node type, and flow should
  12372. // follow suit soon:
  12373. // https://github.com/babel/babel/issues/4722
  12374. var variance = path.variance.kind || path.variance;
  12375. switch (variance) {
  12376. case "plus":
  12377. return "+";
  12378. case "minus":
  12379. return "-";
  12380. default:
  12381. /* istanbul ignore next */
  12382. return variance;
  12383. }
  12384. }
  12385. function printTypeScriptModifiers(path, options, print) {
  12386. var n = path.getValue();
  12387. if (!n.modifiers || !n.modifiers.length) {
  12388. return "";
  12389. }
  12390. return concat$4([join$2(" ", path.map(print, "modifiers")), " "]);
  12391. }
  12392. function printTypeParameters(path, options, print, paramsKey) {
  12393. var n = path.getValue();
  12394. if (!n[paramsKey]) {
  12395. return "";
  12396. } // for TypeParameterDeclaration typeParameters is a single node
  12397. if (!Array.isArray(n[paramsKey])) {
  12398. return path.call(print, paramsKey);
  12399. }
  12400. var grandparent = path.getNode(2);
  12401. var isParameterInTestCall = grandparent != null && isTestCall(grandparent);
  12402. var shouldInline = isParameterInTestCall || n[paramsKey].length === 0 || n[paramsKey].length === 1 && (shouldHugType(n[paramsKey][0]) || n[paramsKey][0].type === "GenericTypeAnnotation" && shouldHugType(n[paramsKey][0].id) || n[paramsKey][0].type === "TSTypeReference" && shouldHugType(n[paramsKey][0].typeName) || n[paramsKey][0].type === "NullableTypeAnnotation");
  12403. if (shouldInline) {
  12404. return concat$4(["<", join$2(", ", path.map(print, paramsKey)), ">"]);
  12405. }
  12406. return group$1(concat$4(["<", indent$2(concat$4([softline$1, join$2(concat$4([",", line$3]), path.map(print, paramsKey))])), ifBreak$1(options.parser !== "typescript" && shouldPrintComma(options, "all") ? "," : ""), softline$1, ">"]));
  12407. }
  12408. function printClass(path, options, print) {
  12409. var n = path.getValue();
  12410. var parts = [];
  12411. if (n.type === "TSAbstractClassDeclaration") {
  12412. parts.push("abstract ");
  12413. }
  12414. parts.push("class");
  12415. if (n.id) {
  12416. parts.push(" ", path.call(print, "id"));
  12417. }
  12418. parts.push(path.call(print, "typeParameters"));
  12419. var partsGroup = [];
  12420. if (n.superClass) {
  12421. var printed = concat$4(["extends ", path.call(print, "superClass"), path.call(print, "superTypeParameters")]); // Keep old behaviour of extends in same line
  12422. // If there is only on extends and there are not comments
  12423. if ((!n.implements || n.implements.length === 0) && (!n.superClass.comments || n.superClass.comments.length === 0)) {
  12424. parts.push(concat$4([" ", path.call(function (superClass) {
  12425. return comments.printComments(superClass, function () {
  12426. return printed;
  12427. }, options);
  12428. }, "superClass")]));
  12429. } else {
  12430. partsGroup.push(group$1(concat$4([line$3, path.call(function (superClass) {
  12431. return comments.printComments(superClass, function () {
  12432. return printed;
  12433. }, options);
  12434. }, "superClass")])));
  12435. }
  12436. } else if (n.extends && n.extends.length > 0) {
  12437. parts.push(" extends ", join$2(", ", path.map(print, "extends")));
  12438. }
  12439. if (n["mixins"] && n["mixins"].length > 0) {
  12440. partsGroup.push(line$3, "mixins ", group$1(indent$2(join$2(concat$4([",", line$3]), path.map(print, "mixins")))));
  12441. }
  12442. if (n["implements"] && n["implements"].length > 0) {
  12443. partsGroup.push(line$3, "implements", group$1(indent$2(concat$4([line$3, join$2(concat$4([",", line$3]), path.map(print, "implements"))]))));
  12444. }
  12445. if (partsGroup.length > 0) {
  12446. parts.push(group$1(indent$2(concat$4(partsGroup))));
  12447. }
  12448. if (n.body && n.body.comments && hasLeadingOwnLineComment(options.originalText, n.body, options)) {
  12449. parts.push(hardline$3);
  12450. } else {
  12451. parts.push(" ");
  12452. }
  12453. parts.push(path.call(print, "body"));
  12454. return parts;
  12455. }
  12456. function printOptionalToken(path) {
  12457. var node = path.getValue();
  12458. if (!node.optional) {
  12459. return "";
  12460. }
  12461. if (node.type === "OptionalCallExpression" || node.type === "OptionalMemberExpression" && node.computed) {
  12462. return "?.";
  12463. }
  12464. return "?";
  12465. }
  12466. function printMemberLookup(path, options, print) {
  12467. var property = path.call(print, "property");
  12468. var n = path.getValue();
  12469. var optional = printOptionalToken(path);
  12470. if (!n.computed) {
  12471. return concat$4([optional, ".", property]);
  12472. }
  12473. if (!n.property || isNumericLiteral(n.property)) {
  12474. return concat$4([optional, "[", property, "]"]);
  12475. }
  12476. return group$1(concat$4([optional, "[", indent$2(concat$4([softline$1, property])), softline$1, "]"]));
  12477. }
  12478. function printBindExpressionCallee(path, options, print) {
  12479. return concat$4(["::", path.call(print, "callee")]);
  12480. } // We detect calls on member expressions specially to format a
  12481. // common pattern better. The pattern we are looking for is this:
  12482. //
  12483. // arr
  12484. // .map(x => x + 1)
  12485. // .filter(x => x > 10)
  12486. // .some(x => x % 2)
  12487. //
  12488. // The way it is structured in the AST is via a nested sequence of
  12489. // MemberExpression and CallExpression. We need to traverse the AST
  12490. // and make groups out of it to print it in the desired way.
  12491. function printMemberChain(path, options, print) {
  12492. // The first phase is to linearize the AST by traversing it down.
  12493. //
  12494. // a().b()
  12495. // has the following AST structure:
  12496. // CallExpression(MemberExpression(CallExpression(Identifier)))
  12497. // and we transform it into
  12498. // [Identifier, CallExpression, MemberExpression, CallExpression]
  12499. var printedNodes = []; // Here we try to retain one typed empty line after each call expression or
  12500. // the first group whether it is in parentheses or not
  12501. function shouldInsertEmptyLineAfter(node) {
  12502. var originalText = options.originalText;
  12503. var nextCharIndex = getNextNonSpaceNonCommentCharacterIndex$2(originalText, node, options);
  12504. var nextChar = originalText.charAt(nextCharIndex); // if it is cut off by a parenthesis, we only account for one typed empty
  12505. // line after that parenthesis
  12506. if (nextChar == ")") {
  12507. return isNextLineEmptyAfterIndex$1(originalText, nextCharIndex + 1, options);
  12508. }
  12509. return isNextLineEmpty$2(originalText, node, options);
  12510. }
  12511. function rec(path) {
  12512. var node = path.getValue();
  12513. if ((node.type === "CallExpression" || node.type === "OptionalCallExpression") && (isMemberish(node.callee) || node.callee.type === "CallExpression" || node.callee.type === "OptionalCallExpression")) {
  12514. printedNodes.unshift({
  12515. node: node,
  12516. printed: concat$4([comments.printComments(path, function () {
  12517. return concat$4([printOptionalToken(path), printFunctionTypeParameters(path, options, print), printArgumentsList(path, options, print)]);
  12518. }, options), shouldInsertEmptyLineAfter(node) ? hardline$3 : ""])
  12519. });
  12520. path.call(function (callee) {
  12521. return rec(callee);
  12522. }, "callee");
  12523. } else if (isMemberish(node)) {
  12524. printedNodes.unshift({
  12525. node: node,
  12526. needsParens: needsParens_1(path, options),
  12527. printed: comments.printComments(path, function () {
  12528. return node.type === "OptionalMemberExpression" || node.type === "MemberExpression" ? printMemberLookup(path, options, print) : printBindExpressionCallee(path, options, print);
  12529. }, options)
  12530. });
  12531. path.call(function (object) {
  12532. return rec(object);
  12533. }, "object");
  12534. } else if (node.type === "TSNonNullExpression") {
  12535. printedNodes.unshift({
  12536. node: node,
  12537. printed: comments.printComments(path, function () {
  12538. return "!";
  12539. }, options)
  12540. });
  12541. path.call(function (expression) {
  12542. return rec(expression);
  12543. }, "expression");
  12544. } else {
  12545. printedNodes.unshift({
  12546. node: node,
  12547. printed: path.call(print)
  12548. });
  12549. }
  12550. } // Note: the comments of the root node have already been printed, so we
  12551. // need to extract this first call without printing them as they would
  12552. // if handled inside of the recursive call.
  12553. var node = path.getValue();
  12554. printedNodes.unshift({
  12555. node: node,
  12556. printed: concat$4([printOptionalToken(path), printFunctionTypeParameters(path, options, print), printArgumentsList(path, options, print)])
  12557. });
  12558. path.call(function (callee) {
  12559. return rec(callee);
  12560. }, "callee"); // Once we have a linear list of printed nodes, we want to create groups out
  12561. // of it.
  12562. //
  12563. // a().b.c().d().e
  12564. // will be grouped as
  12565. // [
  12566. // [Identifier, CallExpression],
  12567. // [MemberExpression, MemberExpression, CallExpression],
  12568. // [MemberExpression, CallExpression],
  12569. // [MemberExpression],
  12570. // ]
  12571. // so that we can print it as
  12572. // a()
  12573. // .b.c()
  12574. // .d()
  12575. // .e
  12576. // The first group is the first node followed by
  12577. // - as many CallExpression as possible
  12578. // < fn()()() >.something()
  12579. // - as many array acessors as possible
  12580. // < fn()[0][1][2] >.something()
  12581. // - then, as many MemberExpression as possible but the last one
  12582. // < this.items >.something()
  12583. var groups = [];
  12584. var currentGroup = [printedNodes[0]];
  12585. var i = 1;
  12586. for (; i < printedNodes.length; ++i) {
  12587. if (printedNodes[i].node.type === "TSNonNullExpression" || printedNodes[i].node.type === "OptionalCallExpression" || printedNodes[i].node.type === "CallExpression" || (printedNodes[i].node.type === "MemberExpression" || printedNodes[i].node.type === "OptionalMemberExpression") && printedNodes[i].node.computed && isNumericLiteral(printedNodes[i].node.property)) {
  12588. currentGroup.push(printedNodes[i]);
  12589. } else {
  12590. break;
  12591. }
  12592. }
  12593. if (printedNodes[0].node.type !== "CallExpression" && printedNodes[0].node.type !== "OptionalCallExpression") {
  12594. for (; i + 1 < printedNodes.length; ++i) {
  12595. if (isMemberish(printedNodes[i].node) && isMemberish(printedNodes[i + 1].node)) {
  12596. currentGroup.push(printedNodes[i]);
  12597. } else {
  12598. break;
  12599. }
  12600. }
  12601. }
  12602. groups.push(currentGroup);
  12603. currentGroup = []; // Then, each following group is a sequence of MemberExpression followed by
  12604. // a sequence of CallExpression. To compute it, we keep adding things to the
  12605. // group until we has seen a CallExpression in the past and reach a
  12606. // MemberExpression
  12607. var hasSeenCallExpression = false;
  12608. for (; i < printedNodes.length; ++i) {
  12609. if (hasSeenCallExpression && isMemberish(printedNodes[i].node)) {
  12610. // [0] should be appended at the end of the group instead of the
  12611. // beginning of the next one
  12612. if (printedNodes[i].node.computed && isNumericLiteral(printedNodes[i].node.property)) {
  12613. currentGroup.push(printedNodes[i]);
  12614. continue;
  12615. }
  12616. groups.push(currentGroup);
  12617. currentGroup = [];
  12618. hasSeenCallExpression = false;
  12619. }
  12620. if (printedNodes[i].node.type === "CallExpression" || printedNodes[i].node.type === "OptionalCallExpression") {
  12621. hasSeenCallExpression = true;
  12622. }
  12623. currentGroup.push(printedNodes[i]);
  12624. if (printedNodes[i].node.comments && printedNodes[i].node.comments.some(function (comment) {
  12625. return comment.trailing;
  12626. })) {
  12627. groups.push(currentGroup);
  12628. currentGroup = [];
  12629. hasSeenCallExpression = false;
  12630. }
  12631. }
  12632. if (currentGroup.length > 0) {
  12633. groups.push(currentGroup);
  12634. } // There are cases like Object.keys(), Observable.of(), _.values() where
  12635. // they are the subject of all the chained calls and therefore should
  12636. // be kept on the same line:
  12637. //
  12638. // Object.keys(items)
  12639. // .filter(x => x)
  12640. // .map(x => x)
  12641. //
  12642. // In order to detect those cases, we use an heuristic: if the first
  12643. // node is an identifier with the name starting with a capital
  12644. // letter or just a sequence of _$. The rationale is that they are
  12645. // likely to be factories.
  12646. function isFactory(name) {
  12647. return /^[A-Z]|^[_$]+$/.test(name);
  12648. } // In case the Identifier is shorter than tab width, we can keep the
  12649. // first call in a single line, if it's an ExpressionStatement.
  12650. //
  12651. // d3.scaleLinear()
  12652. // .domain([0, 100])
  12653. // .range([0, width]);
  12654. //
  12655. function isShort(name) {
  12656. return name.length <= options.tabWidth;
  12657. }
  12658. function shouldNotWrap(groups) {
  12659. var parent = path.getParentNode();
  12660. var isExpression = parent && parent.type === "ExpressionStatement";
  12661. var hasComputed = groups[1].length && groups[1][0].node.computed;
  12662. if (groups[0].length === 1) {
  12663. var firstNode = groups[0][0].node;
  12664. return firstNode.type === "ThisExpression" || firstNode.type === "Identifier" && (isFactory(firstNode.name) || isExpression && isShort(firstNode.name) || hasComputed);
  12665. }
  12666. var lastNode = getLast$4(groups[0]).node;
  12667. return (lastNode.type === "MemberExpression" || lastNode.type === "OptionalMemberExpression") && lastNode.property.type === "Identifier" && (isFactory(lastNode.property.name) || hasComputed);
  12668. }
  12669. var shouldMerge = groups.length >= 2 && !groups[1][0].node.comments && shouldNotWrap(groups);
  12670. function printGroup(printedGroup) {
  12671. var result = [];
  12672. for (var _i3 = 0; _i3 < printedGroup.length; _i3++) {
  12673. // Checks if the next node (i.e. the parent node) needs parens
  12674. // and print accordingl y
  12675. if (printedGroup[_i3 + 1] && printedGroup[_i3 + 1].needsParens) {
  12676. result.push("(", printedGroup[_i3].printed, printedGroup[_i3 + 1].printed, ")");
  12677. _i3++;
  12678. } else {
  12679. result.push(printedGroup[_i3].printed);
  12680. }
  12681. }
  12682. return concat$4(result);
  12683. }
  12684. function printIndentedGroup(groups) {
  12685. if (groups.length === 0) {
  12686. return "";
  12687. }
  12688. return indent$2(group$1(concat$4([hardline$3, join$2(hardline$3, groups.map(printGroup))])));
  12689. }
  12690. var printedGroups = groups.map(printGroup);
  12691. var oneLine = concat$4(printedGroups);
  12692. var cutoff = shouldMerge ? 3 : 2;
  12693. var flatGroups = groups.slice(0, cutoff).reduce(function (res, group) {
  12694. return res.concat(group);
  12695. }, []);
  12696. var hasComment = flatGroups.slice(1, -1).some(function (node) {
  12697. return hasLeadingComment(node.node);
  12698. }) || flatGroups.slice(0, -1).some(function (node) {
  12699. return hasTrailingComment(node.node);
  12700. }) || groups[cutoff] && hasLeadingComment(groups[cutoff][0].node); // If we only have a single `.`, we shouldn't do anything fancy and just
  12701. // render everything concatenated together.
  12702. if (groups.length <= cutoff && !hasComment) {
  12703. return group$1(oneLine);
  12704. } // Find out the last node in the first group and check if it has an
  12705. // empty line after
  12706. var lastNodeBeforeIndent = getLast$4(shouldMerge ? groups.slice(1, 2)[0] : groups[0]).node;
  12707. var shouldHaveEmptyLineBeforeIndent = lastNodeBeforeIndent.type !== "CallExpression" && lastNodeBeforeIndent.type !== "OptionalCallExpression" && shouldInsertEmptyLineAfter(lastNodeBeforeIndent);
  12708. var expanded = concat$4([printGroup(groups[0]), shouldMerge ? concat$4(groups.slice(1, 2).map(printGroup)) : "", shouldHaveEmptyLineBeforeIndent ? hardline$3 : "", printIndentedGroup(groups.slice(shouldMerge ? 2 : 1))]);
  12709. var callExpressionCount = printedNodes.filter(function (tuple) {
  12710. return tuple.node.type === "CallExpression" || tuple.node.type === "OptionalCallExpression";
  12711. }).length; // We don't want to print in one line if there's:
  12712. // * A comment.
  12713. // * 3 or more chained calls.
  12714. // * Any group but the last one has a hard line.
  12715. // If the last group is a function it's okay to inline if it fits.
  12716. if (hasComment || callExpressionCount >= 3 || printedGroups.slice(0, -1).some(willBreak$1)) {
  12717. return group$1(expanded);
  12718. }
  12719. return concat$4([// We only need to check `oneLine` because if `expanded` is chosen
  12720. // that means that the parent group has already been broken
  12721. // naturally
  12722. willBreak$1(oneLine) || shouldHaveEmptyLineBeforeIndent ? breakParent$2 : "", conditionalGroup$1([oneLine, expanded])]);
  12723. }
  12724. function isJSXNode(node) {
  12725. return node.type === "JSXElement" || node.type === "JSXFragment" || node.type === "TSJsxFragment";
  12726. }
  12727. function isEmptyJSXElement(node) {
  12728. if (node.children.length === 0) {
  12729. return true;
  12730. }
  12731. if (node.children.length > 1) {
  12732. return false;
  12733. } // if there is one text child and does not contain any meaningful text
  12734. // we can treat the element as empty.
  12735. var child = node.children[0];
  12736. return isLiteral(child) && !isMeaningfulJSXText(child);
  12737. } // Only space, newline, carriage return, and tab are treated as whitespace
  12738. // inside JSX.
  12739. var jsxWhitespaceChars = " \n\r\t";
  12740. var containsNonJsxWhitespaceRegex = new RegExp("[^" + jsxWhitespaceChars + "]");
  12741. var matchJsxWhitespaceRegex = new RegExp("([" + jsxWhitespaceChars + "]+)"); // Meaningful if it contains non-whitespace characters,
  12742. // or it contains whitespace without a new line.
  12743. function isMeaningfulJSXText(node) {
  12744. return isLiteral(node) && (containsNonJsxWhitespaceRegex.test(rawText(node)) || !/\n/.test(rawText(node)));
  12745. }
  12746. function conditionalExpressionChainContainsJSX(node) {
  12747. return Boolean(getConditionalChainContents(node).find(isJSXNode));
  12748. } // If we have nested conditional expressions, we want to print them in JSX mode
  12749. // if there's at least one JSXElement somewhere in the tree.
  12750. //
  12751. // A conditional expression chain like this should be printed in normal mode,
  12752. // because there aren't JSXElements anywhere in it:
  12753. //
  12754. // isA ? "A" : isB ? "B" : isC ? "C" : "Unknown";
  12755. //
  12756. // But a conditional expression chain like this should be printed in JSX mode,
  12757. // because there is a JSXElement in the last ConditionalExpression:
  12758. //
  12759. // isA ? "A" : isB ? "B" : isC ? "C" : <span className="warning">Unknown</span>;
  12760. //
  12761. // This type of ConditionalExpression chain is structured like this in the AST:
  12762. //
  12763. // ConditionalExpression {
  12764. // test: ...,
  12765. // consequent: ...,
  12766. // alternate: ConditionalExpression {
  12767. // test: ...,
  12768. // consequent: ...,
  12769. // alternate: ConditionalExpression {
  12770. // test: ...,
  12771. // consequent: ...,
  12772. // alternate: ...,
  12773. // }
  12774. // }
  12775. // }
  12776. //
  12777. // We want to traverse over that shape and convert it into a flat structure so
  12778. // that we can find if there's a JSXElement somewhere inside.
  12779. function getConditionalChainContents(node) {
  12780. // Given this code:
  12781. //
  12782. // // Using a ConditionalExpression as the consequent is uncommon, but should
  12783. // // be handled.
  12784. // A ? B : C ? D : E ? F ? G : H : I
  12785. //
  12786. // which has this AST:
  12787. //
  12788. // ConditionalExpression {
  12789. // test: Identifier(A),
  12790. // consequent: Identifier(B),
  12791. // alternate: ConditionalExpression {
  12792. // test: Identifier(C),
  12793. // consequent: Identifier(D),
  12794. // alternate: ConditionalExpression {
  12795. // test: Identifier(E),
  12796. // consequent: ConditionalExpression {
  12797. // test: Identifier(F),
  12798. // consequent: Identifier(G),
  12799. // alternate: Identifier(H),
  12800. // },
  12801. // alternate: Identifier(I),
  12802. // }
  12803. // }
  12804. // }
  12805. //
  12806. // we should return this Array:
  12807. //
  12808. // [
  12809. // Identifier(A),
  12810. // Identifier(B),
  12811. // Identifier(C),
  12812. // Identifier(D),
  12813. // Identifier(E),
  12814. // Identifier(F),
  12815. // Identifier(G),
  12816. // Identifier(H),
  12817. // Identifier(I)
  12818. // ];
  12819. //
  12820. // This loses the information about whether each node was the test,
  12821. // consequent, or alternate, but we don't care about that here- we are only
  12822. // flattening this structure to find if there's any JSXElements inside.
  12823. var nonConditionalExpressions = [];
  12824. function recurse(node) {
  12825. if (node.type === "ConditionalExpression") {
  12826. recurse(node.test);
  12827. recurse(node.consequent);
  12828. recurse(node.alternate);
  12829. } else {
  12830. nonConditionalExpressions.push(node);
  12831. }
  12832. }
  12833. recurse(node);
  12834. return nonConditionalExpressions;
  12835. } // Detect an expression node representing `{" "}`
  12836. function isJSXWhitespaceExpression(node) {
  12837. return node.type === "JSXExpressionContainer" && isLiteral(node.expression) && node.expression.value === " " && !node.expression.comments;
  12838. } // JSX Children are strange, mostly for two reasons:
  12839. // 1. JSX reads newlines into string values, instead of skipping them like JS
  12840. // 2. up to one whitespace between elements within a line is significant,
  12841. // but not between lines.
  12842. //
  12843. // Leading, trailing, and lone whitespace all need to
  12844. // turn themselves into the rather ugly `{' '}` when breaking.
  12845. //
  12846. // We print JSX using the `fill` doc primitive.
  12847. // This requires that we give it an array of alternating
  12848. // content and whitespace elements.
  12849. // To ensure this we add dummy `""` content elements as needed.
  12850. function printJSXChildren(path, options, print, jsxWhitespace) {
  12851. var n = path.getValue();
  12852. var children = []; // using `map` instead of `each` because it provides `i`
  12853. path.map(function (childPath, i) {
  12854. var child = childPath.getValue();
  12855. if (isLiteral(child)) {
  12856. var text = rawText(child); // Contains a non-whitespace character
  12857. if (isMeaningfulJSXText(child)) {
  12858. var words = text.split(matchJsxWhitespaceRegex); // Starts with whitespace
  12859. if (words[0] === "") {
  12860. children.push("");
  12861. words.shift();
  12862. if (/\n/.test(words[0])) {
  12863. children.push(hardline$3);
  12864. } else {
  12865. children.push(jsxWhitespace);
  12866. }
  12867. words.shift();
  12868. }
  12869. var endWhitespace; // Ends with whitespace
  12870. if (getLast$4(words) === "") {
  12871. words.pop();
  12872. endWhitespace = words.pop();
  12873. } // This was whitespace only without a new line.
  12874. if (words.length === 0) {
  12875. return;
  12876. }
  12877. words.forEach(function (word, i) {
  12878. if (i % 2 === 1) {
  12879. children.push(line$3);
  12880. } else {
  12881. children.push(word);
  12882. }
  12883. });
  12884. if (endWhitespace !== undefined) {
  12885. if (/\n/.test(endWhitespace)) {
  12886. children.push(hardline$3);
  12887. } else {
  12888. children.push(jsxWhitespace);
  12889. }
  12890. } else {
  12891. // Ideally this would be a `hardline` to allow a break between
  12892. // tags and text.
  12893. // Unfortunately Facebook have a custom translation pipeline
  12894. // (https://github.com/prettier/prettier/issues/1581#issuecomment-300975032)
  12895. // that uses the JSX syntax, but does not follow the React whitespace
  12896. // rules.
  12897. // Ensuring that we never have a break between tags and text in JSX
  12898. // will allow Facebook to adopt Prettier without too much of an
  12899. // adverse effect on formatting algorithm.
  12900. children.push("");
  12901. }
  12902. } else if (/\n/.test(text)) {
  12903. // Keep (up to one) blank line between tags/expressions/text.
  12904. // Note: We don't keep blank lines between text elements.
  12905. if (text.match(/\n/g).length > 1) {
  12906. children.push("");
  12907. children.push(hardline$3);
  12908. }
  12909. } else {
  12910. children.push("");
  12911. children.push(jsxWhitespace);
  12912. }
  12913. } else {
  12914. var printedChild = print(childPath);
  12915. children.push(printedChild);
  12916. var next = n.children[i + 1];
  12917. var directlyFollowedByMeaningfulText = next && isMeaningfulJSXText(next) && !/^[ \n\r\t]/.test(rawText(next));
  12918. if (directlyFollowedByMeaningfulText) {
  12919. // Potentially this could be a hardline as well.
  12920. // See the comment above about the Facebook translation pipeline as
  12921. // to why this is an empty string.
  12922. children.push("");
  12923. } else {
  12924. children.push(hardline$3);
  12925. }
  12926. }
  12927. }, "children");
  12928. return children;
  12929. } // JSX expands children from the inside-out, instead of the outside-in.
  12930. // This is both to break children before attributes,
  12931. // and to ensure that when children break, their parents do as well.
  12932. //
  12933. // Any element that is written without any newlines and fits on a single line
  12934. // is left that way.
  12935. // Not only that, any user-written-line containing multiple JSX siblings
  12936. // should also be kept on one line if possible,
  12937. // so each user-written-line is wrapped in its own group.
  12938. //
  12939. // Elements that contain newlines or don't fit on a single line (recursively)
  12940. // are fully-split, using hardline and shouldBreak: true.
  12941. //
  12942. // To support that case properly, all leading and trailing spaces
  12943. // are stripped from the list of children, and replaced with a single hardline.
  12944. function printJSXElement(path, options, print) {
  12945. var n = path.getValue(); // Turn <div></div> into <div />
  12946. if (n.type === "JSXElement" && isEmptyJSXElement(n)) {
  12947. n.openingElement.selfClosing = true;
  12948. return path.call(print, "openingElement");
  12949. }
  12950. var openingLines = n.type === "JSXElement" ? path.call(print, "openingElement") : path.call(print, "openingFragment");
  12951. var closingLines = n.type === "JSXElement" ? path.call(print, "closingElement") : path.call(print, "closingFragment");
  12952. if (n.children.length === 1 && n.children[0].type === "JSXExpressionContainer" && (n.children[0].expression.type === "TemplateLiteral" || n.children[0].expression.type === "TaggedTemplateExpression")) {
  12953. return concat$4([openingLines, concat$4(path.map(print, "children")), closingLines]);
  12954. } // Convert `{" "}` to text nodes containing a space.
  12955. // This makes it easy to turn them into `jsxWhitespace` which
  12956. // can then print as either a space or `{" "}` when breaking.
  12957. n.children = n.children.map(function (child) {
  12958. if (isJSXWhitespaceExpression(child)) {
  12959. return {
  12960. type: "JSXText",
  12961. value: " ",
  12962. raw: " "
  12963. };
  12964. }
  12965. return child;
  12966. });
  12967. var containsTag = n.children.filter(isJSXNode).length > 0;
  12968. var containsMultipleExpressions = n.children.filter(function (child) {
  12969. return child.type === "JSXExpressionContainer";
  12970. }).length > 1;
  12971. var containsMultipleAttributes = n.type === "JSXElement" && n.openingElement.attributes.length > 1; // Record any breaks. Should never go from true to false, only false to true.
  12972. var forcedBreak = willBreak$1(openingLines) || containsTag || containsMultipleAttributes || containsMultipleExpressions;
  12973. var rawJsxWhitespace = options.singleQuote ? "{' '}" : '{" "}';
  12974. var jsxWhitespace = ifBreak$1(concat$4([rawJsxWhitespace, softline$1]), " ");
  12975. var children = printJSXChildren(path, options, print, jsxWhitespace);
  12976. var containsText = n.children.filter(function (child) {
  12977. return isMeaningfulJSXText(child);
  12978. }).length > 0; // We can end up we multiple whitespace elements with empty string
  12979. // content between them.
  12980. // We need to remove empty whitespace and softlines before JSX whitespace
  12981. // to get the correct output.
  12982. for (var i = children.length - 2; i >= 0; i--) {
  12983. var isPairOfEmptyStrings = children[i] === "" && children[i + 1] === "";
  12984. var isPairOfHardlines = children[i] === hardline$3 && children[i + 1] === "" && children[i + 2] === hardline$3;
  12985. var isLineFollowedByJSXWhitespace = (children[i] === softline$1 || children[i] === hardline$3) && children[i + 1] === "" && children[i + 2] === jsxWhitespace;
  12986. var isJSXWhitespaceFollowedByLine = children[i] === jsxWhitespace && children[i + 1] === "" && (children[i + 2] === softline$1 || children[i + 2] === hardline$3);
  12987. var isDoubleJSXWhitespace = children[i] === jsxWhitespace && children[i + 1] === "" && children[i + 2] === jsxWhitespace;
  12988. if (isPairOfHardlines && containsText || isPairOfEmptyStrings || isLineFollowedByJSXWhitespace || isDoubleJSXWhitespace) {
  12989. children.splice(i, 2);
  12990. } else if (isJSXWhitespaceFollowedByLine) {
  12991. children.splice(i + 1, 2);
  12992. }
  12993. } // Trim trailing lines (or empty strings)
  12994. while (children.length && (isLineNext$1(getLast$4(children)) || isEmpty$1(getLast$4(children)))) {
  12995. children.pop();
  12996. } // Trim leading lines (or empty strings)
  12997. while (children.length && (isLineNext$1(children[0]) || isEmpty$1(children[0])) && (isLineNext$1(children[1]) || isEmpty$1(children[1]))) {
  12998. children.shift();
  12999. children.shift();
  13000. } // Tweak how we format children if outputting this element over multiple lines.
  13001. // Also detect whether we will force this element to output over multiple lines.
  13002. var multilineChildren = [];
  13003. children.forEach(function (child, i) {
  13004. // There are a number of situations where we need to ensure we display
  13005. // whitespace as `{" "}` when outputting this element over multiple lines.
  13006. if (child === jsxWhitespace) {
  13007. if (i === 1 && children[i - 1] === "") {
  13008. if (children.length === 2) {
  13009. // Solitary whitespace
  13010. multilineChildren.push(rawJsxWhitespace);
  13011. return;
  13012. } // Leading whitespace
  13013. multilineChildren.push(concat$4([rawJsxWhitespace, hardline$3]));
  13014. return;
  13015. } else if (i === children.length - 1) {
  13016. // Trailing whitespace
  13017. multilineChildren.push(rawJsxWhitespace);
  13018. return;
  13019. } else if (children[i - 1] === "" && children[i - 2] === hardline$3) {
  13020. // Whitespace after line break
  13021. multilineChildren.push(rawJsxWhitespace);
  13022. return;
  13023. }
  13024. }
  13025. multilineChildren.push(child);
  13026. if (willBreak$1(child)) {
  13027. forcedBreak = true;
  13028. }
  13029. }); // If there is text we use `fill` to fit as much onto each line as possible.
  13030. // When there is no text (just tags and expressions) we use `group`
  13031. // to output each on a separate line.
  13032. var content = containsText ? fill$2(multilineChildren) : group$1(concat$4(multilineChildren), {
  13033. shouldBreak: true
  13034. });
  13035. var multiLineElem = group$1(concat$4([openingLines, indent$2(concat$4([hardline$3, content])), hardline$3, closingLines]));
  13036. if (forcedBreak) {
  13037. return multiLineElem;
  13038. }
  13039. return conditionalGroup$1([group$1(concat$4([openingLines, concat$4(children), closingLines])), multiLineElem]);
  13040. }
  13041. function maybeWrapJSXElementInParens(path, elem) {
  13042. var parent = path.getParentNode();
  13043. if (!parent) {
  13044. return elem;
  13045. }
  13046. var NO_WRAP_PARENTS = {
  13047. ArrayExpression: true,
  13048. JSXAttribute: true,
  13049. JSXElement: true,
  13050. JSXExpressionContainer: true,
  13051. JSXFragment: true,
  13052. TSJsxFragment: true,
  13053. ExpressionStatement: true,
  13054. CallExpression: true,
  13055. OptionalCallExpression: true,
  13056. ConditionalExpression: true
  13057. };
  13058. if (NO_WRAP_PARENTS[parent.type]) {
  13059. return elem;
  13060. }
  13061. return group$1(concat$4([ifBreak$1("("), indent$2(concat$4([softline$1, elem])), softline$1, ifBreak$1(")")]));
  13062. }
  13063. function isBinaryish(node) {
  13064. return node.type === "BinaryExpression" || node.type === "LogicalExpression";
  13065. }
  13066. function isMemberish(node) {
  13067. return node.type === "MemberExpression" || node.type === "OptionalMemberExpression" || node.type === "BindExpression" && node.object;
  13068. }
  13069. function shouldInlineLogicalExpression(node) {
  13070. if (node.type !== "LogicalExpression") {
  13071. return false;
  13072. }
  13073. if (node.right.type === "ObjectExpression" && node.right.properties.length !== 0) {
  13074. return true;
  13075. }
  13076. if (node.right.type === "ArrayExpression" && node.right.elements.length !== 0) {
  13077. return true;
  13078. }
  13079. if (isJSXNode(node.right)) {
  13080. return true;
  13081. }
  13082. return false;
  13083. } // For binary expressions to be consistent, we need to group
  13084. // subsequent operators with the same precedence level under a single
  13085. // group. Otherwise they will be nested such that some of them break
  13086. // onto new lines but not all. Operators with the same precedence
  13087. // level should either all break or not. Because we group them by
  13088. // precedence level and the AST is structured based on precedence
  13089. // level, things are naturally broken up correctly, i.e. `&&` is
  13090. // broken before `+`.
  13091. function printBinaryishExpressions(path, print, options, isNested, isInsideParenthesis) {
  13092. var parts = [];
  13093. var node = path.getValue(); // We treat BinaryExpression and LogicalExpression nodes the same.
  13094. if (isBinaryish(node)) {
  13095. // Put all operators with the same precedence level in the same
  13096. // group. The reason we only need to do this with the `left`
  13097. // expression is because given an expression like `1 + 2 - 3`, it
  13098. // is always parsed like `((1 + 2) - 3)`, meaning the `left` side
  13099. // is where the rest of the expression will exist. Binary
  13100. // expressions on the right side mean they have a difference
  13101. // precedence level and should be treated as a separate group, so
  13102. // print them normally. (This doesn't hold for the `**` operator,
  13103. // which is unique in that it is right-associative.)
  13104. if (shouldFlatten$1(node.operator, node.left.operator)) {
  13105. // Flatten them out by recursively calling this function.
  13106. parts = parts.concat(path.call(function (left) {
  13107. return printBinaryishExpressions(left, print, options,
  13108. /* isNested */
  13109. true, isInsideParenthesis);
  13110. }, "left"));
  13111. } else {
  13112. parts.push(path.call(print, "left"));
  13113. }
  13114. var shouldInline = shouldInlineLogicalExpression(node);
  13115. var lineBeforeOperator = node.operator === "|>";
  13116. var right = shouldInline ? concat$4([node.operator, " ", path.call(print, "right")]) : concat$4([lineBeforeOperator ? softline$1 : "", node.operator, lineBeforeOperator ? " " : line$3, path.call(print, "right")]); // If there's only a single binary expression, we want to create a group
  13117. // in order to avoid having a small right part like -1 be on its own line.
  13118. var parent = path.getParentNode();
  13119. var shouldGroup = !(isInsideParenthesis && node.type === "LogicalExpression") && parent.type !== node.type && node.left.type !== node.type && node.right.type !== node.type;
  13120. parts.push(" ", shouldGroup ? group$1(right) : right); // The root comments are already printed, but we need to manually print
  13121. // the other ones since we don't call the normal print on BinaryExpression,
  13122. // only for the left and right parts
  13123. if (isNested && node.comments) {
  13124. parts = comments.printComments(path, function () {
  13125. return concat$4(parts);
  13126. }, options);
  13127. }
  13128. } else {
  13129. // Our stopping case. Simply print the node normally.
  13130. parts.push(path.call(print));
  13131. }
  13132. return parts;
  13133. }
  13134. function printAssignmentRight(leftNode, rightNode, printedRight, options) {
  13135. if (hasLeadingOwnLineComment(options.originalText, rightNode, options)) {
  13136. return indent$2(concat$4([hardline$3, printedRight]));
  13137. }
  13138. var canBreak = isBinaryish(rightNode) && !shouldInlineLogicalExpression(rightNode) || rightNode.type === "ConditionalExpression" && isBinaryish(rightNode.test) && !shouldInlineLogicalExpression(rightNode.test) || rightNode.type === "StringLiteralTypeAnnotation" || (leftNode.type === "Identifier" || isStringLiteral(leftNode) || leftNode.type === "MemberExpression") && (isStringLiteral(rightNode) || isMemberExpressionChain(rightNode));
  13139. if (canBreak) {
  13140. return indent$2(concat$4([line$3, printedRight]));
  13141. }
  13142. return concat$4([" ", printedRight]);
  13143. }
  13144. function printAssignment(leftNode, printedLeft, operator, rightNode, printedRight, options) {
  13145. if (!rightNode) {
  13146. return printedLeft;
  13147. }
  13148. var printed = printAssignmentRight(leftNode, rightNode, printedRight, options);
  13149. return group$1(concat$4([printedLeft, operator, printed]));
  13150. }
  13151. function adjustClause(node, clause, forceSpace) {
  13152. if (node.type === "EmptyStatement") {
  13153. return ";";
  13154. }
  13155. if (node.type === "BlockStatement" || forceSpace) {
  13156. return concat$4([" ", clause]);
  13157. }
  13158. return indent$2(concat$4([line$3, clause]));
  13159. }
  13160. function nodeStr(node, options, isFlowOrTypeScriptDirectiveLiteral) {
  13161. var raw = rawText(node);
  13162. var isDirectiveLiteral = isFlowOrTypeScriptDirectiveLiteral || node.type === "DirectiveLiteral";
  13163. return printString$1(raw, options, isDirectiveLiteral);
  13164. }
  13165. function printRegex(node) {
  13166. var flags = node.flags.split("").sort().join("");
  13167. return "/".concat(node.pattern, "/").concat(flags);
  13168. }
  13169. function isLastStatement(path) {
  13170. var parent = path.getParentNode();
  13171. if (!parent) {
  13172. return true;
  13173. }
  13174. var node = path.getValue();
  13175. var body = (parent.body || parent.consequent).filter(function (stmt) {
  13176. return stmt.type !== "EmptyStatement";
  13177. });
  13178. return body && body[body.length - 1] === node;
  13179. }
  13180. function hasLeadingComment(node) {
  13181. return node.comments && node.comments.some(function (comment) {
  13182. return comment.leading;
  13183. });
  13184. }
  13185. function hasTrailingComment(node) {
  13186. return node.comments && node.comments.some(function (comment) {
  13187. return comment.trailing;
  13188. });
  13189. }
  13190. function hasLeadingOwnLineComment(text, node, options) {
  13191. if (isJSXNode(node)) {
  13192. return hasNodeIgnoreComment$1(node);
  13193. }
  13194. var res = node.comments && node.comments.some(function (comment) {
  13195. return comment.leading && hasNewline$2(text, options.locEnd(comment));
  13196. });
  13197. return res;
  13198. }
  13199. function hasNakedLeftSide(node) {
  13200. return node.type === "AssignmentExpression" || node.type === "BinaryExpression" || node.type === "LogicalExpression" || node.type === "ConditionalExpression" || node.type === "CallExpression" || node.type === "OptionalCallExpression" || node.type === "MemberExpression" || node.type === "OptionalMemberExpression" || node.type === "SequenceExpression" || node.type === "TaggedTemplateExpression" || node.type === "BindExpression" && !node.object || node.type === "UpdateExpression" && !node.prefix;
  13201. }
  13202. function isFlowAnnotationComment(text, typeAnnotation, options) {
  13203. var start = options.locStart(typeAnnotation);
  13204. var end = skipWhitespace$1(text, options.locEnd(typeAnnotation));
  13205. return text.substr(start, 2) === "/*" && text.substr(end, 2) === "*/";
  13206. }
  13207. function getLeftSide(node) {
  13208. if (node.expressions) {
  13209. return node.expressions[0];
  13210. }
  13211. return node.left || node.test || node.callee || node.object || node.tag || node.argument || node.expression;
  13212. }
  13213. function getLeftSidePathName(path, node) {
  13214. if (node.expressions) {
  13215. return ["expressions", 0];
  13216. }
  13217. if (node.left) {
  13218. return ["left"];
  13219. }
  13220. if (node.test) {
  13221. return ["test"];
  13222. }
  13223. if (node.callee) {
  13224. return ["callee"];
  13225. }
  13226. if (node.object) {
  13227. return ["object"];
  13228. }
  13229. if (node.tag) {
  13230. return ["tag"];
  13231. }
  13232. if (node.argument) {
  13233. return ["argument"];
  13234. }
  13235. if (node.expression) {
  13236. return ["expression"];
  13237. }
  13238. throw new Error("Unexpected node has no left side", node);
  13239. }
  13240. function exprNeedsASIProtection(path, options) {
  13241. var node = path.getValue();
  13242. var maybeASIProblem = needsParens_1(path, options) || node.type === "ParenthesizedExpression" || node.type === "TypeCastExpression" || node.type === "ArrowFunctionExpression" && !shouldPrintParamsWithoutParens(path, options) || node.type === "ArrayExpression" || node.type === "ArrayPattern" || node.type === "UnaryExpression" && node.prefix && (node.operator === "+" || node.operator === "-") || node.type === "TemplateLiteral" || node.type === "TemplateElement" || isJSXNode(node) || node.type === "BindExpression" || node.type === "RegExpLiteral" || node.type === "Literal" && node.pattern || node.type === "Literal" && node.regex;
  13243. if (maybeASIProblem) {
  13244. return true;
  13245. }
  13246. if (!hasNakedLeftSide(node)) {
  13247. return false;
  13248. }
  13249. return path.call.apply(path, [function (childPath) {
  13250. return exprNeedsASIProtection(childPath, options);
  13251. }].concat(getLeftSidePathName(path, node)));
  13252. }
  13253. function stmtNeedsASIProtection(path, options) {
  13254. var node = path.getNode();
  13255. if (node.type !== "ExpressionStatement") {
  13256. return false;
  13257. }
  13258. return path.call(function (childPath) {
  13259. return exprNeedsASIProtection(childPath, options);
  13260. }, "expression");
  13261. }
  13262. function classPropMayCauseASIProblems(path) {
  13263. var node = path.getNode();
  13264. if (node.type !== "ClassProperty") {
  13265. return false;
  13266. }
  13267. var name = node.key && node.key.name; // this isn't actually possible yet with most parsers available today
  13268. // so isn't properly tested yet.
  13269. if ((name === "static" || name === "get" || name === "set") && !node.value && !node.typeAnnotation) {
  13270. return true;
  13271. }
  13272. }
  13273. function classChildNeedsASIProtection(node) {
  13274. if (!node) {
  13275. return;
  13276. }
  13277. if (!node.computed) {
  13278. var name = node.key && node.key.name;
  13279. if (name === "in" || name === "instanceof") {
  13280. return true;
  13281. }
  13282. }
  13283. switch (node.type) {
  13284. case "ClassProperty":
  13285. case "TSAbstractClassProperty":
  13286. return node.computed;
  13287. case "MethodDefinition": // Flow
  13288. case "TSAbstractMethodDefinition": // TypeScript
  13289. case "ClassMethod":
  13290. {
  13291. // Babylon
  13292. var isAsync = node.value ? node.value.async : node.async;
  13293. var isGenerator = node.value ? node.value.generator : node.generator;
  13294. if (isAsync || node.static || node.kind === "get" || node.kind === "set") {
  13295. return false;
  13296. }
  13297. if (node.computed || isGenerator) {
  13298. return true;
  13299. }
  13300. return false;
  13301. }
  13302. default:
  13303. /* istanbul ignore next */
  13304. return false;
  13305. }
  13306. } // This recurses the return argument, looking for the first token
  13307. // (the leftmost leaf node) and, if it (or its parents) has any
  13308. // leadingComments, returns true (so it can be wrapped in parens).
  13309. function returnArgumentHasLeadingComment(options, argument) {
  13310. if (hasLeadingOwnLineComment(options.originalText, argument, options)) {
  13311. return true;
  13312. }
  13313. if (hasNakedLeftSide(argument)) {
  13314. var leftMost = argument;
  13315. var newLeftMost;
  13316. while (newLeftMost = getLeftSide(leftMost)) {
  13317. leftMost = newLeftMost;
  13318. if (hasLeadingOwnLineComment(options.originalText, leftMost, options)) {
  13319. return true;
  13320. }
  13321. }
  13322. }
  13323. return false;
  13324. }
  13325. function isMemberExpressionChain(node) {
  13326. if (node.type !== "MemberExpression" && node.type !== "OptionalMemberExpression") {
  13327. return false;
  13328. }
  13329. if (node.object.type === "Identifier") {
  13330. return true;
  13331. }
  13332. return isMemberExpressionChain(node.object);
  13333. } // Hack to differentiate between the following two which have the same ast
  13334. // type T = { method: () => void };
  13335. // type T = { method(): void };
  13336. function isObjectTypePropertyAFunction(node, options) {
  13337. return node.type === "ObjectTypeProperty" && node.value.type === "FunctionTypeAnnotation" && !node.static && !isFunctionNotation(node, options);
  13338. } // TODO: This is a bad hack and we need a better way to distinguish between
  13339. // arrow functions and otherwise
  13340. function isFunctionNotation(node, options) {
  13341. return isGetterOrSetter(node) || sameLocStart(node, node.value, options);
  13342. }
  13343. function isGetterOrSetter(node) {
  13344. return node.kind === "get" || node.kind === "set";
  13345. }
  13346. function sameLocStart(nodeA, nodeB, options) {
  13347. return options.locStart(nodeA) === options.locStart(nodeB);
  13348. } // Hack to differentiate between the following two which have the same ast
  13349. // declare function f(a): void;
  13350. // var f: (a) => void;
  13351. function isTypeAnnotationAFunction(node, options) {
  13352. return (node.type === "TypeAnnotation" || node.type === "TSTypeAnnotation") && node.typeAnnotation.type === "FunctionTypeAnnotation" && !node.static && !sameLocStart(node, node.typeAnnotation, options);
  13353. }
  13354. function isNodeStartingWithDeclare(node, options) {
  13355. if (!(options.parser === "flow" || options.parser === "typescript")) {
  13356. return false;
  13357. }
  13358. return options.originalText.slice(0, options.locStart(node)).match(/declare[ \t]*$/) || options.originalText.slice(node.range[0], node.range[1]).startsWith("declare ");
  13359. }
  13360. function shouldHugType(node) {
  13361. if (isObjectType(node)) {
  13362. return true;
  13363. }
  13364. if (node.type === "UnionTypeAnnotation" || node.type === "TSUnionType") {
  13365. var voidCount = node.types.filter(function (n) {
  13366. return n.type === "VoidTypeAnnotation" || n.type === "TSVoidKeyword" || n.type === "NullLiteralTypeAnnotation" || n.type === "TSNullKeyword";
  13367. }).length;
  13368. var objectCount = node.types.filter(function (n) {
  13369. return n.type === "ObjectTypeAnnotation" || n.type === "TSTypeLiteral" || // This is a bit aggressive but captures Array<{x}>
  13370. n.type === "GenericTypeAnnotation" || n.type === "TSTypeReference";
  13371. }).length;
  13372. if (node.types.length - 1 === voidCount && objectCount > 0) {
  13373. return true;
  13374. }
  13375. }
  13376. return false;
  13377. }
  13378. function shouldHugArguments(fun) {
  13379. return fun && fun.params && fun.params.length === 1 && !fun.params[0].comments && (fun.params[0].type === "ObjectPattern" || fun.params[0].type === "ArrayPattern" || fun.params[0].type === "Identifier" && fun.params[0].typeAnnotation && (fun.params[0].typeAnnotation.type === "TypeAnnotation" || fun.params[0].typeAnnotation.type === "TSTypeAnnotation") && isObjectType(fun.params[0].typeAnnotation.typeAnnotation) || fun.params[0].type === "FunctionTypeParam" && isObjectType(fun.params[0].typeAnnotation) || fun.params[0].type === "AssignmentPattern" && (fun.params[0].left.type === "ObjectPattern" || fun.params[0].left.type === "ArrayPattern") && (fun.params[0].right.type === "Identifier" || fun.params[0].right.type === "ObjectExpression" && fun.params[0].right.properties.length === 0 || fun.params[0].right.type === "ArrayExpression" && fun.params[0].right.elements.length === 0)) && !fun.rest;
  13380. }
  13381. function templateLiteralHasNewLines(template) {
  13382. return template.quasis.some(function (quasi) {
  13383. return quasi.value.raw.includes("\n");
  13384. });
  13385. }
  13386. function isTemplateOnItsOwnLine(n, text, options) {
  13387. return (n.type === "TemplateLiteral" && templateLiteralHasNewLines(n) || n.type === "TaggedTemplateExpression" && templateLiteralHasNewLines(n.quasi)) && !hasNewline$2(text, options.locStart(n), {
  13388. backwards: true
  13389. });
  13390. }
  13391. function printArrayItems(path, options, printPath, print) {
  13392. var printedElements = [];
  13393. var separatorParts = [];
  13394. path.each(function (childPath) {
  13395. printedElements.push(concat$4(separatorParts));
  13396. printedElements.push(group$1(print(childPath)));
  13397. separatorParts = [",", line$3];
  13398. if (childPath.getValue() && isNextLineEmpty$2(options.originalText, childPath.getValue(), options)) {
  13399. separatorParts.push(softline$1);
  13400. }
  13401. }, printPath);
  13402. return concat$4(printedElements);
  13403. }
  13404. function hasDanglingComments(node) {
  13405. return node.comments && node.comments.some(function (comment) {
  13406. return !comment.leading && !comment.trailing;
  13407. });
  13408. }
  13409. function needsHardlineAfterDanglingComment(node) {
  13410. if (!node.comments) {
  13411. return false;
  13412. }
  13413. var lastDanglingComment = getLast$4(node.comments.filter(function (comment) {
  13414. return !comment.leading && !comment.trailing;
  13415. }));
  13416. return lastDanglingComment && !comments$3.isBlockComment(lastDanglingComment);
  13417. }
  13418. function isLiteral(node) {
  13419. return node.type === "BooleanLiteral" || node.type === "DirectiveLiteral" || node.type === "Literal" || node.type === "NullLiteral" || node.type === "NumericLiteral" || node.type === "RegExpLiteral" || node.type === "StringLiteral" || node.type === "TemplateLiteral" || node.type === "TSTypeLiteral" || node.type === "JSXText";
  13420. }
  13421. function isNumericLiteral(node) {
  13422. return node.type === "NumericLiteral" || node.type === "Literal" && typeof node.value === "number";
  13423. }
  13424. function isStringLiteral(node) {
  13425. return node.type === "StringLiteral" || node.type === "Literal" && typeof node.value === "string";
  13426. }
  13427. function isObjectType(n) {
  13428. return n.type === "ObjectTypeAnnotation" || n.type === "TSTypeLiteral";
  13429. }
  13430. var unitTestRe = /^(skip|[fx]?(it|describe|test))$/; // eg; `describe("some string", (done) => {})`
  13431. function isTestCall(n, parent) {
  13432. if (n.type !== "CallExpression") {
  13433. return false;
  13434. }
  13435. if (n.arguments.length === 1) {
  13436. if (isAngularTestWrapper(n) && parent && isTestCall(parent)) {
  13437. return isFunctionOrArrowExpression(n.arguments[0].type);
  13438. }
  13439. if (isUnitTestSetUp(n)) {
  13440. return isFunctionOrArrowExpression(n.arguments[0].type) || isAngularTestWrapper(n.arguments[0]);
  13441. }
  13442. } else if (n.arguments.length === 2) {
  13443. if ((n.callee.type === "Identifier" && unitTestRe.test(n.callee.name) || isSkipOrOnlyBlock(n)) && (isTemplateLiteral(n.arguments[0]) || isStringLiteral(n.arguments[0]))) {
  13444. return isFunctionOrArrowExpression(n.arguments[1].type) && n.arguments[1].params.length <= 1 || isAngularTestWrapper(n.arguments[1]);
  13445. }
  13446. }
  13447. return false;
  13448. }
  13449. function isSkipOrOnlyBlock(node) {
  13450. return (node.callee.type === "MemberExpression" || node.callee.type === "OptionalMemberExpression") && node.callee.object.type === "Identifier" && node.callee.property.type === "Identifier" && unitTestRe.test(node.callee.object.name) && (node.callee.property.name === "only" || node.callee.property.name === "skip");
  13451. }
  13452. function isTemplateLiteral(node) {
  13453. return node.type === "TemplateLiteral";
  13454. } // `inject` is used in AngularJS 1.x, `async` in Angular 2+
  13455. // example: https://docs.angularjs.org/guide/unit-testing#using-beforeall-
  13456. function isAngularTestWrapper(node) {
  13457. return (node.type === "CallExpression" || node.type === "OptionalCallExpression") && node.callee.type === "Identifier" && (node.callee.name === "async" || node.callee.name === "inject");
  13458. }
  13459. function isFunctionOrArrowExpression(type) {
  13460. return type === "FunctionExpression" || type === "ArrowFunctionExpression";
  13461. }
  13462. function isUnitTestSetUp(n) {
  13463. var unitTestSetUpRe = /^(before|after)(Each|All)$/;
  13464. return n.callee.type === "Identifier" && unitTestSetUpRe.test(n.callee.name) && n.arguments.length === 1;
  13465. }
  13466. function isTheOnlyJSXElementInMarkdown(options, path) {
  13467. if (options.parentParser !== "markdown") {
  13468. return false;
  13469. }
  13470. var node = path.getNode();
  13471. if (!node.expression || !isJSXNode(node.expression)) {
  13472. return false;
  13473. }
  13474. var parent = path.getParentNode();
  13475. return parent.type === "Program" && parent.body.length == 1;
  13476. }
  13477. function willPrintOwnComments(path) {
  13478. var node = path.getValue();
  13479. var parent = path.getParentNode();
  13480. return (node && isJSXNode(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);
  13481. }
  13482. function canAttachComment(node) {
  13483. return node.type && node.type !== "CommentBlock" && node.type !== "CommentLine" && node.type !== "Line" && node.type !== "Block" && node.type !== "EmptyStatement" && node.type !== "TemplateElement" && node.type !== "Import" && !(node.callee && node.callee.type === "Import");
  13484. }
  13485. function printComment$1(commentPath, options) {
  13486. var comment = commentPath.getValue();
  13487. switch (comment.type) {
  13488. case "CommentBlock":
  13489. case "Block":
  13490. {
  13491. if (isJsDocComment(comment)) {
  13492. var printed = printJsDocComment(comment); // We need to prevent an edge case of a previous trailing comment
  13493. // printed as a `lineSuffix` which causes the comments to be
  13494. // interleaved. See https://github.com/prettier/prettier/issues/4412
  13495. if (comment.trailing && !hasNewline$2(options.originalText, options.locStart(comment), {
  13496. backwards: true
  13497. })) {
  13498. return concat$4([hardline$3, printed]);
  13499. }
  13500. return printed;
  13501. }
  13502. var isInsideFlowComment = options.originalText.substr(options.locEnd(comment) - 3, 3) === "*-/";
  13503. return "/*" + comment.value + (isInsideFlowComment ? "*-/" : "*/");
  13504. }
  13505. case "CommentLine":
  13506. case "Line":
  13507. // Print shebangs with the proper comment characters
  13508. if (options.originalText.slice(options.locStart(comment)).startsWith("#!")) {
  13509. return "#!" + comment.value.trimRight();
  13510. }
  13511. return "//" + comment.value.trimRight();
  13512. default:
  13513. throw new Error("Not a comment: " + JSON.stringify(comment));
  13514. }
  13515. }
  13516. function isJsDocComment(comment) {
  13517. var lines = comment.value.split("\n");
  13518. return lines.length > 1 && lines.slice(0, lines.length - 1).every(function (line) {
  13519. return line.trim()[0] === "*";
  13520. });
  13521. }
  13522. function printJsDocComment(comment) {
  13523. var lines = comment.value.split("\n");
  13524. return concat$4(["/*", join$2(hardline$3, lines.map(function (line, index) {
  13525. return (index > 0 ? " " : "") + (index < lines.length - 1 ? line.trim() : line.trimLeft());
  13526. })), "*/"]);
  13527. }
  13528. function rawText(node) {
  13529. return node.extra ? node.extra.raw : node.raw;
  13530. }
  13531. var printerEstree = {
  13532. print: genericPrint$1,
  13533. embed: embed_1,
  13534. insertPragma: insertPragma,
  13535. massageAstNode: clean_1,
  13536. hasPrettierIgnore: hasPrettierIgnore,
  13537. willPrintOwnComments: willPrintOwnComments,
  13538. canAttachComment: canAttachComment,
  13539. printComment: printComment$1,
  13540. isBlockComment: comments$3.isBlockComment,
  13541. handleComments: {
  13542. ownLine: comments$3.handleOwnLineComment,
  13543. endOfLine: comments$3.handleEndOfLineComment,
  13544. remaining: comments$3.handleRemainingComment
  13545. }
  13546. };
  13547. var _require$$0$builders$2 = doc.builders;
  13548. var concat$6 = _require$$0$builders$2.concat;
  13549. var hardline$5 = _require$$0$builders$2.hardline;
  13550. var indent$4 = _require$$0$builders$2.indent;
  13551. var join$4 = _require$$0$builders$2.join;
  13552. function genericPrint$2(path, options, print) {
  13553. var node = path.getValue();
  13554. switch (node.type) {
  13555. case "ArrayExpression":
  13556. return node.elements.length === 0 ? "[]" : concat$6(["[", indent$4(concat$6([hardline$5, join$4(concat$6([",", hardline$5]), path.map(print, "elements"))])), hardline$5, "]"]);
  13557. case "ObjectExpression":
  13558. return node.properties.length === 0 ? "{}" : concat$6(["{", indent$4(concat$6([hardline$5, join$4(concat$6([",", hardline$5]), path.map(print, "properties"))])), hardline$5, "}"]);
  13559. case "ObjectProperty":
  13560. return concat$6([path.call(print, "key"), ": ", path.call(print, "value")]);
  13561. case "UnaryExpression":
  13562. return concat$6([node.operator === "+" ? "" : node.operator, path.call(print, "argument")]);
  13563. case "NullLiteral":
  13564. return "null";
  13565. case "BooleanLiteral":
  13566. return node.value ? "true" : "false";
  13567. case "StringLiteral":
  13568. case "NumericLiteral":
  13569. return JSON.stringify(node.value);
  13570. case "Identifier":
  13571. return JSON.stringify(node.name);
  13572. default:
  13573. /* istanbul ignore next */
  13574. throw new Error("unknown type: " + JSON.stringify(node.type));
  13575. }
  13576. }
  13577. function clean$2(node, newNode
  13578. /*, parent*/
  13579. ) {
  13580. delete newNode.start;
  13581. delete newNode.end;
  13582. delete newNode.extra;
  13583. delete newNode.loc;
  13584. delete newNode.comments;
  13585. if (node.type === "Identifier") {
  13586. return {
  13587. type: "StringLiteral",
  13588. value: node.name
  13589. };
  13590. }
  13591. if (node.type === "UnaryExpression" && node.operator === "+") {
  13592. return newNode.argument;
  13593. }
  13594. }
  13595. var printerEstreeJson = {
  13596. print: genericPrint$2,
  13597. massageAstNode: clean$2
  13598. };
  13599. var CATEGORY_COMMON = "Common"; // format based on https://github.com/prettier/prettier/blob/master/src/main/core-options.js
  13600. var commonOptions = {
  13601. bracketSpacing: {
  13602. since: "0.0.0",
  13603. category: CATEGORY_COMMON,
  13604. type: "boolean",
  13605. default: true,
  13606. description: "Print spaces between brackets.",
  13607. oppositeDescription: "Do not print spaces between brackets."
  13608. },
  13609. singleQuote: {
  13610. since: "0.0.0",
  13611. category: CATEGORY_COMMON,
  13612. type: "boolean",
  13613. default: false,
  13614. description: "Use single quotes instead of double quotes."
  13615. }
  13616. };
  13617. var CATEGORY_JAVASCRIPT = "JavaScript"; // format based on https://github.com/prettier/prettier/blob/master/src/main/core-options.js
  13618. var options$3 = {
  13619. arrowParens: {
  13620. since: "1.9.0",
  13621. category: CATEGORY_JAVASCRIPT,
  13622. type: "choice",
  13623. default: "avoid",
  13624. description: "Include parentheses around a sole arrow function parameter.",
  13625. choices: [{
  13626. value: "avoid",
  13627. description: "Omit parens when possible. Example: `x => x`"
  13628. }, {
  13629. value: "always",
  13630. description: "Always include parens. Example: `(x) => x`"
  13631. }]
  13632. },
  13633. bracketSpacing: commonOptions.bracketSpacing,
  13634. jsxBracketSameLine: {
  13635. since: "0.17.0",
  13636. category: CATEGORY_JAVASCRIPT,
  13637. type: "boolean",
  13638. default: false,
  13639. description: "Put > on the last line instead of at a new line."
  13640. },
  13641. semi: {
  13642. since: "1.0.0",
  13643. category: CATEGORY_JAVASCRIPT,
  13644. type: "boolean",
  13645. default: true,
  13646. description: "Print semicolons.",
  13647. oppositeDescription: "Do not print semicolons, except at the beginning of lines which may need them."
  13648. },
  13649. singleQuote: commonOptions.singleQuote,
  13650. trailingComma: {
  13651. since: "0.0.0",
  13652. category: CATEGORY_JAVASCRIPT,
  13653. type: "choice",
  13654. default: [{
  13655. since: "0.0.0",
  13656. value: false
  13657. }, {
  13658. since: "0.19.0",
  13659. value: "none"
  13660. }],
  13661. description: "Print trailing commas wherever possible when multi-line.",
  13662. choices: [{
  13663. value: "none",
  13664. description: "No trailing commas."
  13665. }, {
  13666. value: "es5",
  13667. description: "Trailing commas where valid in ES5 (objects, arrays, etc.)"
  13668. }, {
  13669. value: "all",
  13670. description: "Trailing commas wherever possible (including function arguments)."
  13671. }, {
  13672. value: true,
  13673. deprecated: "0.19.0",
  13674. redirect: "es5"
  13675. }, {
  13676. value: false,
  13677. deprecated: "0.19.0",
  13678. redirect: "none"
  13679. }]
  13680. }
  13681. };
  13682. // https://github.com/github/linguist/blob/master/lib/linguist/languages.yml
  13683. var languages = [{
  13684. name: "JavaScript",
  13685. since: "0.0.0",
  13686. parsers: ["babylon", "flow"],
  13687. group: "JavaScript",
  13688. tmScope: "source.js",
  13689. aceMode: "javascript",
  13690. codemirrorMode: "javascript",
  13691. codemirrorMimeType: "text/javascript",
  13692. aliases: ["js", "node"],
  13693. extensions: [".js", "._js", ".bones", ".es", ".es6", ".frag", ".gs", ".jake", ".jsb", ".jscad", ".jsfl", ".jsm", ".jss", ".mjs", ".njs", ".pac", ".sjs", ".ssjs", ".xsjs", ".xsjslib"],
  13694. filenames: ["Jakefile"],
  13695. linguistLanguageId: 183,
  13696. vscodeLanguageIds: ["javascript"]
  13697. }, {
  13698. name: "JSX",
  13699. since: "0.0.0",
  13700. parsers: ["babylon", "flow"],
  13701. group: "JavaScript",
  13702. extensions: [".jsx"],
  13703. tmScope: "source.js.jsx",
  13704. aceMode: "javascript",
  13705. codemirrorMode: "jsx",
  13706. codemirrorMimeType: "text/jsx",
  13707. liguistLanguageId: 178,
  13708. vscodeLanguageIds: ["javascriptreact"]
  13709. }, {
  13710. name: "TypeScript",
  13711. since: "1.4.0",
  13712. parsers: ["typescript-eslint"],
  13713. group: "JavaScript",
  13714. aliases: ["ts"],
  13715. extensions: [".ts", ".tsx"],
  13716. tmScope: "source.ts",
  13717. aceMode: "typescript",
  13718. codemirrorMode: "javascript",
  13719. codemirrorMimeType: "application/typescript",
  13720. liguistLanguageId: 378,
  13721. vscodeLanguageIds: ["typescript", "typescriptreact"]
  13722. }, {
  13723. name: "JSON.stringify",
  13724. since: "1.13.0",
  13725. parsers: ["json-stringify"],
  13726. group: "JavaScript",
  13727. tmScope: "source.json",
  13728. aceMode: "json",
  13729. codemirrorMode: "javascript",
  13730. codemirrorMimeType: "application/json",
  13731. extensions: [],
  13732. // .json file defaults to json instead of json-stringify
  13733. filenames: ["package.json", "package-lock.json", "composer.json"],
  13734. linguistLanguageId: 174,
  13735. vscodeLanguageIds: ["json"]
  13736. }, {
  13737. name: "JSON",
  13738. since: "1.5.0",
  13739. parsers: ["json"],
  13740. group: "JavaScript",
  13741. tmScope: "source.json",
  13742. aceMode: "json",
  13743. codemirrorMode: "javascript",
  13744. codemirrorMimeType: "application/json",
  13745. extensions: [".json", ".geojson", ".JSON-tmLanguage", ".topojson"],
  13746. filenames: [".arcconfig", ".jshintrc", ".eslintrc", ".prettierrc", "composer.lock", "mcmod.info"],
  13747. linguistLanguageId: 174,
  13748. vscodeLanguageIds: ["json", "jsonc"]
  13749. }, {
  13750. name: "JSON5",
  13751. since: "1.13.0",
  13752. parsers: ["json5"],
  13753. group: "JavaScript",
  13754. tmScope: "source.json",
  13755. aceMode: "json",
  13756. codemirrorMode: "javascript",
  13757. codemirrorMimeType: "application/json",
  13758. extensions: [".json5"],
  13759. filenames: [".babelrc"],
  13760. linguistLanguageId: 175,
  13761. vscodeLanguageIds: ["json5"]
  13762. }];
  13763. var printers = {
  13764. estree: printerEstree,
  13765. "estree-json": printerEstreeJson
  13766. };
  13767. var languageJs = {
  13768. languages: languages,
  13769. options: options$3,
  13770. printers: printers
  13771. };
  13772. var index$5 = ["a", "abbr", "acronym", "address", "applet", "area", "article", "aside", "audio", "b", "base", "basefont", "bdi", "bdo", "bgsound", "big", "blink", "blockquote", "body", "br", "button", "canvas", "caption", "center", "cite", "code", "col", "colgroup", "command", "content", "data", "datalist", "dd", "del", "details", "dfn", "dialog", "dir", "div", "dl", "dt", "element", "em", "embed", "fieldset", "figcaption", "figure", "font", "footer", "form", "frame", "frameset", "h1", "h2", "h3", "h4", "h5", "h6", "head", "header", "hgroup", "hr", "html", "i", "iframe", "image", "img", "input", "ins", "isindex", "kbd", "keygen", "label", "legend", "li", "link", "listing", "main", "map", "mark", "marquee", "math", "menu", "menuitem", "meta", "meter", "multicol", "nav", "nextid", "nobr", "noembed", "noframes", "noscript", "object", "ol", "optgroup", "option", "output", "p", "param", "picture", "plaintext", "pre", "progress", "q", "rb", "rbc", "rp", "rt", "rtc", "ruby", "s", "samp", "script", "section", "select", "shadow", "slot", "small", "source", "spacer", "span", "strike", "strong", "style", "sub", "summary", "sup", "svg", "table", "tbody", "td", "template", "textarea", "tfoot", "th", "thead", "time", "title", "tr", "track", "tt", "u", "ul", "var", "video", "wbr", "xmp"];
  13773. var htmlTagNames = Object.freeze({
  13774. default: index$5
  13775. });
  13776. var htmlTagNames$1 = ( htmlTagNames && index$5 ) || htmlTagNames;
  13777. function clean$3(ast, newObj) {
  13778. ["raws", "sourceIndex", "source", "before", "after", "trailingComma"].forEach(function (name) {
  13779. delete newObj[name];
  13780. });
  13781. if (ast.type === "media-query" || ast.type === "media-query-list" || ast.type === "media-feature-expression") {
  13782. delete newObj.value;
  13783. }
  13784. if (ast.type === "css-rule") {
  13785. delete newObj.params;
  13786. }
  13787. if (ast.type === "selector-combinator") {
  13788. newObj.value = newObj.value.replace(/\s+/g, " ");
  13789. }
  13790. if (ast.type === "media-feature") {
  13791. newObj.value = newObj.value.replace(/ /g, "");
  13792. }
  13793. if (ast.type === "value-word" && (ast.isColor && ast.isHex || ["initial", "inherit", "unset", "revert"].indexOf(newObj.value.replace().toLowerCase()) !== -1) || ast.type === "media-feature" || ast.type === "selector-root-invalid" || ast.type === "selector-pseudo") {
  13794. newObj.value = newObj.value.toLowerCase();
  13795. }
  13796. if (ast.type === "css-decl") {
  13797. newObj.prop = newObj.prop.toLowerCase();
  13798. }
  13799. if (ast.type === "css-atrule" || ast.type === "css-import") {
  13800. newObj.name = newObj.name.toLowerCase();
  13801. }
  13802. if (ast.type === "value-number") {
  13803. newObj.unit = newObj.unit.toLowerCase();
  13804. }
  13805. 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) {
  13806. newObj.value = cleanCSSStrings(newObj.value);
  13807. }
  13808. if (ast.type === "selector-attribute") {
  13809. newObj.attribute = newObj.attribute.trim();
  13810. if (newObj.namespace) {
  13811. if (typeof newObj.namespace === "string") {
  13812. newObj.namespace = newObj.namespace.trim();
  13813. if (newObj.namespace.length === 0) {
  13814. newObj.namespace = true;
  13815. }
  13816. }
  13817. }
  13818. if (newObj.value) {
  13819. newObj.value = newObj.value.trim().replace(/^['"]|['"]$/g, "");
  13820. delete newObj.quoted;
  13821. }
  13822. }
  13823. 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) {
  13824. newObj.value = newObj.value.replace(/([\d.eE+-]+)([a-zA-Z]*)/g, function (match, numStr, unit) {
  13825. var num = Number(numStr);
  13826. return isNaN(num) ? match : num + unit.toLowerCase();
  13827. });
  13828. }
  13829. if (ast.type === "selector-tag") {
  13830. var lowercasedValue = ast.value.toLowerCase();
  13831. if (htmlTagNames$1.indexOf(lowercasedValue) !== -1) {
  13832. newObj.value = lowercasedValue;
  13833. }
  13834. if (["from", "to"].indexOf(lowercasedValue) !== -1) {
  13835. newObj.value = lowercasedValue;
  13836. }
  13837. } // Workaround when `postcss-values-parser` parse `not`, `and` or `or` keywords as `value-func`
  13838. if (ast.type === "css-atrule" && ast.name.toLowerCase() === "supports") {
  13839. delete newObj.value;
  13840. } // Workaround for SCSS nested properties
  13841. if (ast.type === "selector-unknown") {
  13842. delete newObj.value;
  13843. }
  13844. }
  13845. function cleanCSSStrings(value) {
  13846. return value.replace(/'/g, '"').replace(/\\([^a-fA-F\d])/g, "$1");
  13847. }
  13848. var clean_1$2 = clean$3;
  13849. var colorAdjusterFunctions = ["red", "green", "blue", "alpha", "a", "rgb", "hue", "h", "saturation", "s", "lightness", "l", "whiteness", "w", "blackness", "b", "tint", "shade", "blend", "blenda", "contrast", "hsl", "hsla", "hwb", "hwba"];
  13850. function getAncestorCounter(path, typeOrTypes) {
  13851. var types = [].concat(typeOrTypes);
  13852. var counter = -1;
  13853. var ancestorNode;
  13854. while (ancestorNode = path.getParentNode(++counter)) {
  13855. if (types.indexOf(ancestorNode.type) !== -1) {
  13856. return counter;
  13857. }
  13858. }
  13859. return -1;
  13860. }
  13861. function getAncestorNode$1(path, typeOrTypes) {
  13862. var counter = getAncestorCounter(path, typeOrTypes);
  13863. return counter === -1 ? null : path.getParentNode(counter);
  13864. }
  13865. function getPropOfDeclNode$1(path) {
  13866. var declAncestorNode = getAncestorNode$1(path, "css-decl");
  13867. return declAncestorNode && declAncestorNode.prop && declAncestorNode.prop.toLowerCase();
  13868. }
  13869. function isSCSS$1(parser, text) {
  13870. var hasExplicitParserChoice = parser === "less" || parser === "scss";
  13871. var IS_POSSIBLY_SCSS = /(\w\s*: [^}:]+|#){|@import[^\n]+(url|,)/;
  13872. return hasExplicitParserChoice ? parser === "scss" : IS_POSSIBLY_SCSS.test(text);
  13873. }
  13874. function isWideKeywords$1(value) {
  13875. return ["initial", "inherit", "unset", "revert"].indexOf(value.toLowerCase()) !== -1;
  13876. }
  13877. function isKeyframeAtRuleKeywords$1(path, value) {
  13878. var atRuleAncestorNode = getAncestorNode$1(path, "css-atrule");
  13879. return atRuleAncestorNode && atRuleAncestorNode.name && atRuleAncestorNode.name.toLowerCase().endsWith("keyframes") && ["from", "to"].indexOf(value.toLowerCase()) !== -1;
  13880. }
  13881. function maybeToLowerCase$1(value) {
  13882. return value.includes("$") || value.includes("@") || value.includes("#") || value.startsWith("%") || value.startsWith("--") || value.startsWith(":--") || value.includes("(") && value.includes(")") ? value : value.toLowerCase();
  13883. }
  13884. function insideValueFunctionNode$1(path, functionName) {
  13885. var funcAncestorNode = getAncestorNode$1(path, "value-func");
  13886. return funcAncestorNode && funcAncestorNode.value && funcAncestorNode.value.toLowerCase() === functionName;
  13887. }
  13888. function insideICSSRuleNode$1(path) {
  13889. var ruleAncestorNode = getAncestorNode$1(path, "css-rule");
  13890. return ruleAncestorNode && ruleAncestorNode.raws && ruleAncestorNode.raws.selector && (ruleAncestorNode.raws.selector.startsWith(":import") || ruleAncestorNode.raws.selector.startsWith(":export"));
  13891. }
  13892. function insideAtRuleNode$1(path, atRuleNameOrAtRuleNames) {
  13893. var atRuleNames = [].concat(atRuleNameOrAtRuleNames);
  13894. var atRuleAncestorNode = getAncestorNode$1(path, "css-atrule");
  13895. return atRuleAncestorNode && atRuleNames.indexOf(atRuleAncestorNode.name.toLowerCase()) !== -1;
  13896. }
  13897. function insideURLFunctionInImportAtRuleNode$1(path) {
  13898. var node = path.getValue();
  13899. var atRuleAncestorNode = getAncestorNode$1(path, "css-atrule");
  13900. return atRuleAncestorNode && atRuleAncestorNode.name === "import" && node.groups[0].value === "url" && node.groups.length === 2;
  13901. }
  13902. function isURLFunctionNode$1(node) {
  13903. return node.type === "value-func" && node.value.toLowerCase() === "url";
  13904. }
  13905. function isLastNode$1(path, node) {
  13906. var parentNode = path.getParentNode();
  13907. if (!parentNode) {
  13908. return false;
  13909. }
  13910. var nodes = parentNode.nodes;
  13911. return nodes && nodes.indexOf(node) === nodes.length - 1;
  13912. }
  13913. function isHTMLTag$1(value) {
  13914. return htmlTagNames$1.indexOf(value.toLowerCase()) !== -1;
  13915. }
  13916. function isDetachedRulesetDeclarationNode$1(node) {
  13917. // If a Less file ends up being parsed with the SCSS parser, Less
  13918. // variable declarations will be parsed as atrules with names ending
  13919. // with a colon, so keep the original case then.
  13920. if (!node.selector) {
  13921. return false;
  13922. }
  13923. return typeof node.selector === "string" && /^@.+:.*$/.test(node.selector) || node.selector.value && /^@.+:.*$/.test(node.selector.value);
  13924. }
  13925. function isForKeywordNode$1(node) {
  13926. return node.type === "value-word" && ["from", "through", "end"].indexOf(node.value) !== -1;
  13927. }
  13928. function isIfElseKeywordNode$1(node) {
  13929. return node.type === "value-word" && ["and", "or", "not"].indexOf(node.value) !== -1;
  13930. }
  13931. function isEachKeywordNode$1(node) {
  13932. return node.type === "value-word" && node.value === "in";
  13933. }
  13934. function isMultiplicationNode$1(node) {
  13935. return node.type === "value-operator" && node.value === "*";
  13936. }
  13937. function isDivisionNode$1(node) {
  13938. return node.type === "value-operator" && node.value === "/";
  13939. }
  13940. function isAdditionNode$1(node) {
  13941. return node.type === "value-operator" && node.value === "+";
  13942. }
  13943. function isSubtractionNode$1(node) {
  13944. return node.type === "value-operator" && node.value === "-";
  13945. }
  13946. function isModuloNode(node) {
  13947. return node.type === "value-operator" && node.value === "%";
  13948. }
  13949. function isMathOperatorNode$1(node) {
  13950. return isMultiplicationNode$1(node) || isDivisionNode$1(node) || isAdditionNode$1(node) || isSubtractionNode$1(node) || isModuloNode(node);
  13951. }
  13952. function isEqualityOperatorNode$1(node) {
  13953. return node.type === "value-word" && ["==", "!="].indexOf(node.value) !== -1;
  13954. }
  13955. function isRelationalOperatorNode$1(node) {
  13956. return node.type === "value-word" && ["<", ">", "<=", ">="].indexOf(node.value) !== -1;
  13957. }
  13958. function isSCSSControlDirectiveNode$1(node) {
  13959. return node.type === "css-atrule" && ["if", "else", "for", "each", "while"].indexOf(node.name) !== -1;
  13960. }
  13961. function isSCSSNestedPropertyNode(node) {
  13962. if (!node.selector) {
  13963. return false;
  13964. }
  13965. return node.selector.replace(/\/\*.*?\*\//, "").replace(/\/\/.*?\n/, "").trim().endsWith(":");
  13966. }
  13967. function isDetachedRulesetCallNode$1(node) {
  13968. return node.raws && node.raws.params && /^\(\s*\)$/.test(node.raws.params);
  13969. }
  13970. function isPostcssSimpleVarNode$1(currentNode, nextNode) {
  13971. return currentNode.value === "$$" && currentNode.type === "value-func" && nextNode && nextNode.type === "value-word" && !nextNode.raws.before;
  13972. }
  13973. function hasComposesNode$1(node) {
  13974. return node.value && node.value.type === "value-root" && node.value.group && node.value.group.type === "value-value" && node.prop.toLowerCase() === "composes";
  13975. }
  13976. function hasParensAroundNode$1(node) {
  13977. 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;
  13978. }
  13979. function hasEmptyRawBefore$1(node) {
  13980. return node.raws && node.raws.before === "";
  13981. }
  13982. function isKeyValuePairNode$1(node) {
  13983. return node.type === "value-comma_group" && node.groups && node.groups[1] && node.groups[1].type === "value-colon";
  13984. }
  13985. function isKeyValuePairInParenGroupNode(node) {
  13986. return node.type === "value-paren_group" && node.groups && node.groups[0] && isKeyValuePairNode$1(node.groups[0]);
  13987. }
  13988. function isSCSSMapItemNode$1(path) {
  13989. var node = path.getValue(); // Ignore empty item (i.e. `$key: ()`)
  13990. if (node.groups.length === 0) {
  13991. return false;
  13992. }
  13993. var parentParentNode = path.getParentNode(1); // Check open parens contain key/value pair (i.e. `(key: value)` and `(key: (value, other-value)`)
  13994. if (!isKeyValuePairInParenGroupNode(node) && !(parentParentNode && isKeyValuePairInParenGroupNode(parentParentNode))) {
  13995. return false;
  13996. }
  13997. var declNode = getAncestorNode$1(path, "css-decl"); // SCSS map declaration (i.e. `$map: (key: value, other-key: other-value)`)
  13998. if (declNode && declNode.prop && declNode.prop.startsWith("$")) {
  13999. return true;
  14000. } // List as value of key inside SCSS map (i.e. `$map: (key: (value other-value other-other-value))`)
  14001. if (isKeyValuePairInParenGroupNode(parentParentNode)) {
  14002. return true;
  14003. } // SCSS Map is argument of function (i.e. `func((key: value, other-key: other-value))`)
  14004. if (parentParentNode.type === "value-func") {
  14005. return true;
  14006. }
  14007. return false;
  14008. }
  14009. function isInlineValueCommentNode$1(node) {
  14010. return node.type === "value-comment" && node.inline;
  14011. }
  14012. function isHashNode$1(node) {
  14013. return node.type === "value-word" && node.value === "#";
  14014. }
  14015. function isLeftCurlyBraceNode$1(node) {
  14016. return node.type === "value-word" && node.value === "{";
  14017. }
  14018. function isRightCurlyBraceNode$1(node) {
  14019. return node.type === "value-word" && node.value === "}";
  14020. }
  14021. function isWordNode$1(node) {
  14022. return ["value-word", "value-atword"].indexOf(node.type) !== -1;
  14023. }
  14024. function isColonNode$1(node) {
  14025. return node.type === "value-colon";
  14026. }
  14027. function isMediaAndSupportsKeywords$1(node) {
  14028. return node.value && ["not", "and", "or"].indexOf(node.value.toLowerCase()) !== -1;
  14029. }
  14030. function isColorAdjusterFuncNode$1(node) {
  14031. if (node.type !== "value-func") {
  14032. return false;
  14033. }
  14034. return colorAdjusterFunctions.indexOf(node.value.toLowerCase()) !== -1;
  14035. }
  14036. var utils$4 = {
  14037. getAncestorCounter: getAncestorCounter,
  14038. getAncestorNode: getAncestorNode$1,
  14039. getPropOfDeclNode: getPropOfDeclNode$1,
  14040. maybeToLowerCase: maybeToLowerCase$1,
  14041. insideValueFunctionNode: insideValueFunctionNode$1,
  14042. insideICSSRuleNode: insideICSSRuleNode$1,
  14043. insideAtRuleNode: insideAtRuleNode$1,
  14044. insideURLFunctionInImportAtRuleNode: insideURLFunctionInImportAtRuleNode$1,
  14045. isKeyframeAtRuleKeywords: isKeyframeAtRuleKeywords$1,
  14046. isHTMLTag: isHTMLTag$1,
  14047. isWideKeywords: isWideKeywords$1,
  14048. isSCSS: isSCSS$1,
  14049. isLastNode: isLastNode$1,
  14050. isSCSSControlDirectiveNode: isSCSSControlDirectiveNode$1,
  14051. isDetachedRulesetDeclarationNode: isDetachedRulesetDeclarationNode$1,
  14052. isRelationalOperatorNode: isRelationalOperatorNode$1,
  14053. isEqualityOperatorNode: isEqualityOperatorNode$1,
  14054. isMultiplicationNode: isMultiplicationNode$1,
  14055. isDivisionNode: isDivisionNode$1,
  14056. isAdditionNode: isAdditionNode$1,
  14057. isSubtractionNode: isSubtractionNode$1,
  14058. isModuloNode: isModuloNode,
  14059. isMathOperatorNode: isMathOperatorNode$1,
  14060. isEachKeywordNode: isEachKeywordNode$1,
  14061. isForKeywordNode: isForKeywordNode$1,
  14062. isURLFunctionNode: isURLFunctionNode$1,
  14063. isIfElseKeywordNode: isIfElseKeywordNode$1,
  14064. hasComposesNode: hasComposesNode$1,
  14065. hasParensAroundNode: hasParensAroundNode$1,
  14066. hasEmptyRawBefore: hasEmptyRawBefore$1,
  14067. isSCSSNestedPropertyNode: isSCSSNestedPropertyNode,
  14068. isDetachedRulesetCallNode: isDetachedRulesetCallNode$1,
  14069. isPostcssSimpleVarNode: isPostcssSimpleVarNode$1,
  14070. isKeyValuePairNode: isKeyValuePairNode$1,
  14071. isKeyValuePairInParenGroupNode: isKeyValuePairInParenGroupNode,
  14072. isSCSSMapItemNode: isSCSSMapItemNode$1,
  14073. isInlineValueCommentNode: isInlineValueCommentNode$1,
  14074. isHashNode: isHashNode$1,
  14075. isLeftCurlyBraceNode: isLeftCurlyBraceNode$1,
  14076. isRightCurlyBraceNode: isRightCurlyBraceNode$1,
  14077. isWordNode: isWordNode$1,
  14078. isColonNode: isColonNode$1,
  14079. isMediaAndSupportsKeywords: isMediaAndSupportsKeywords$1,
  14080. isColorAdjusterFuncNode: isColorAdjusterFuncNode$1
  14081. };
  14082. var printNumber$2 = util.printNumber;
  14083. var printString$2 = util.printString;
  14084. var hasIgnoreComment$2 = util.hasIgnoreComment;
  14085. var hasNewline$3 = util.hasNewline;
  14086. var isNextLineEmpty$3 = utilShared.isNextLineEmpty;
  14087. var _require$$2$builders = doc.builders;
  14088. var concat$7 = _require$$2$builders.concat;
  14089. var join$5 = _require$$2$builders.join;
  14090. var line$4 = _require$$2$builders.line;
  14091. var hardline$6 = _require$$2$builders.hardline;
  14092. var softline$3 = _require$$2$builders.softline;
  14093. var group$2 = _require$$2$builders.group;
  14094. var fill$3 = _require$$2$builders.fill;
  14095. var indent$5 = _require$$2$builders.indent;
  14096. var dedent$3 = _require$$2$builders.dedent;
  14097. var ifBreak$2 = _require$$2$builders.ifBreak;
  14098. var removeLines$2 = doc.utils.removeLines;
  14099. var getAncestorNode = utils$4.getAncestorNode;
  14100. var getPropOfDeclNode = utils$4.getPropOfDeclNode;
  14101. var maybeToLowerCase = utils$4.maybeToLowerCase;
  14102. var insideValueFunctionNode = utils$4.insideValueFunctionNode;
  14103. var insideICSSRuleNode = utils$4.insideICSSRuleNode;
  14104. var insideAtRuleNode = utils$4.insideAtRuleNode;
  14105. var insideURLFunctionInImportAtRuleNode = utils$4.insideURLFunctionInImportAtRuleNode;
  14106. var isKeyframeAtRuleKeywords = utils$4.isKeyframeAtRuleKeywords;
  14107. var isHTMLTag = utils$4.isHTMLTag;
  14108. var isWideKeywords = utils$4.isWideKeywords;
  14109. var isSCSS = utils$4.isSCSS;
  14110. var isLastNode = utils$4.isLastNode;
  14111. var isSCSSControlDirectiveNode = utils$4.isSCSSControlDirectiveNode;
  14112. var isDetachedRulesetDeclarationNode = utils$4.isDetachedRulesetDeclarationNode;
  14113. var isRelationalOperatorNode = utils$4.isRelationalOperatorNode;
  14114. var isEqualityOperatorNode = utils$4.isEqualityOperatorNode;
  14115. var isMultiplicationNode = utils$4.isMultiplicationNode;
  14116. var isDivisionNode = utils$4.isDivisionNode;
  14117. var isAdditionNode = utils$4.isAdditionNode;
  14118. var isSubtractionNode = utils$4.isSubtractionNode;
  14119. var isMathOperatorNode = utils$4.isMathOperatorNode;
  14120. var isEachKeywordNode = utils$4.isEachKeywordNode;
  14121. var isForKeywordNode = utils$4.isForKeywordNode;
  14122. var isURLFunctionNode = utils$4.isURLFunctionNode;
  14123. var isIfElseKeywordNode = utils$4.isIfElseKeywordNode;
  14124. var hasComposesNode = utils$4.hasComposesNode;
  14125. var hasParensAroundNode = utils$4.hasParensAroundNode;
  14126. var hasEmptyRawBefore = utils$4.hasEmptyRawBefore;
  14127. var isKeyValuePairNode = utils$4.isKeyValuePairNode;
  14128. var isDetachedRulesetCallNode = utils$4.isDetachedRulesetCallNode;
  14129. var isPostcssSimpleVarNode = utils$4.isPostcssSimpleVarNode;
  14130. var isSCSSMapItemNode = utils$4.isSCSSMapItemNode;
  14131. var isInlineValueCommentNode = utils$4.isInlineValueCommentNode;
  14132. var isHashNode = utils$4.isHashNode;
  14133. var isLeftCurlyBraceNode = utils$4.isLeftCurlyBraceNode;
  14134. var isRightCurlyBraceNode = utils$4.isRightCurlyBraceNode;
  14135. var isWordNode = utils$4.isWordNode;
  14136. var isColonNode = utils$4.isColonNode;
  14137. var isMediaAndSupportsKeywords = utils$4.isMediaAndSupportsKeywords;
  14138. var isColorAdjusterFuncNode = utils$4.isColorAdjusterFuncNode;
  14139. function shouldPrintComma$1(options) {
  14140. switch (options.trailingComma) {
  14141. case "all":
  14142. case "es5":
  14143. return true;
  14144. case "none":
  14145. default:
  14146. return false;
  14147. }
  14148. }
  14149. function genericPrint$3(path, options, print) {
  14150. var node = path.getValue();
  14151. /* istanbul ignore if */
  14152. if (!node) {
  14153. return "";
  14154. }
  14155. if (typeof node === "string") {
  14156. return node;
  14157. }
  14158. switch (node.type) {
  14159. case "front-matter":
  14160. return concat$7([node.value, hardline$6]);
  14161. case "css-root":
  14162. {
  14163. var nodes = printNodeSequence(path, options, print);
  14164. if (nodes.parts.length) {
  14165. return concat$7([nodes, hardline$6]);
  14166. }
  14167. return nodes;
  14168. }
  14169. case "css-comment":
  14170. {
  14171. if (node.raws.content) {
  14172. return node.raws.content;
  14173. }
  14174. var text = options.originalText.slice(options.locStart(node), options.locEnd(node));
  14175. var rawText = node.raws.text || node.text; // Workaround a bug where the location is off.
  14176. // https://github.com/postcss/postcss-scss/issues/63
  14177. if (text.indexOf(rawText) === -1) {
  14178. if (node.raws.inline) {
  14179. return concat$7(["// ", rawText]);
  14180. }
  14181. return concat$7(["/* ", rawText, " */"]);
  14182. }
  14183. return text;
  14184. }
  14185. case "css-rule":
  14186. {
  14187. return concat$7([path.call(print, "selector"), node.important ? " !important" : "", node.nodes ? concat$7([" {", node.nodes.length > 0 ? indent$5(concat$7([hardline$6, printNodeSequence(path, options, print)])) : "", hardline$6, "}", isDetachedRulesetDeclarationNode(node) ? ";" : ""]) : ";"]);
  14188. }
  14189. case "css-decl":
  14190. {
  14191. return concat$7([node.raws.before.replace(/[\s;]/g, ""), insideICSSRuleNode(path) ? node.prop : maybeToLowerCase(node.prop), node.raws.between.trim() === ":" ? ":" : node.raws.between.trim(), node.extend ? "" : " ", hasComposesNode(node) ? removeLines$2(path.call(print, "value")) : path.call(print, "value"), node.raws.important ? node.raws.important.replace(/\s*!\s*important/i, " !important") : node.important ? " !important" : "", node.raws.scssDefault ? node.raws.scssDefault.replace(/\s*!default/i, " !default") : node.scssDefault ? " !default" : "", node.raws.scssGlobal ? node.raws.scssGlobal.replace(/\s*!global/i, " !global") : node.scssGlobal ? " !global" : "", node.nodes ? concat$7([" {", indent$5(concat$7([softline$3, printNodeSequence(path, options, print)])), softline$3, "}"]) : ";"]);
  14192. }
  14193. case "css-atrule":
  14194. {
  14195. return concat$7(["@", // If a Less file ends up being parsed with the SCSS parser, Less
  14196. // variable declarations will be parsed as at-rules with names ending
  14197. // with a colon, so keep the original case then.
  14198. isDetachedRulesetCallNode(node) || node.name.endsWith(":") ? node.name : maybeToLowerCase(node.name), node.params ? concat$7([isDetachedRulesetCallNode(node) ? "" : " ", path.call(print, "params")]) : "", node.selector ? indent$5(concat$7([" ", path.call(print, "selector")])) : "", node.value ? group$2(concat$7([" ", path.call(print, "value"), isSCSSControlDirectiveNode(node) ? hasParensAroundNode(node) ? " " : line$4 : ""])) : node.name === "else" ? " " : "", node.nodes ? concat$7([isSCSSControlDirectiveNode(node) ? "" : " ", "{", indent$5(concat$7([node.nodes.length > 0 ? softline$3 : "", printNodeSequence(path, options, print)])), softline$3, "}"]) : ";"]);
  14199. }
  14200. // postcss-media-query-parser
  14201. case "media-query-list":
  14202. {
  14203. var parts = [];
  14204. path.each(function (childPath) {
  14205. var node = childPath.getValue();
  14206. if (node.type === "media-query" && node.value === "") {
  14207. return;
  14208. }
  14209. parts.push(childPath.call(print));
  14210. }, "nodes");
  14211. return group$2(indent$5(join$5(line$4, parts)));
  14212. }
  14213. case "media-query":
  14214. {
  14215. return concat$7([join$5(" ", path.map(print, "nodes")), isLastNode(path, node) ? "" : ","]);
  14216. }
  14217. case "media-type":
  14218. {
  14219. return adjustNumbers(adjustStrings(node.value, options));
  14220. }
  14221. case "media-feature-expression":
  14222. {
  14223. if (!node.nodes) {
  14224. return node.value;
  14225. }
  14226. return concat$7(["(", concat$7(path.map(print, "nodes")), ")"]);
  14227. }
  14228. case "media-feature":
  14229. {
  14230. return maybeToLowerCase(adjustStrings(node.value.replace(/ +/g, " "), options));
  14231. }
  14232. case "media-colon":
  14233. {
  14234. return concat$7([node.value, " "]);
  14235. }
  14236. case "media-value":
  14237. {
  14238. return adjustNumbers(adjustStrings(node.value, options));
  14239. }
  14240. case "media-keyword":
  14241. {
  14242. return adjustStrings(node.value, options);
  14243. }
  14244. case "media-url":
  14245. {
  14246. return adjustStrings(node.value.replace(/^url\(\s+/gi, "url(").replace(/\s+\)$/gi, ")"), options);
  14247. }
  14248. case "media-unknown":
  14249. {
  14250. return node.value;
  14251. }
  14252. // postcss-selector-parser
  14253. case "selector-root":
  14254. {
  14255. return group$2(concat$7([insideAtRuleNode(path, "custom-selector") ? concat$7([getAncestorNode(path, "css-atrule").customSelector, line$4]) : "", join$5(concat$7([",", insideAtRuleNode(path, ["extend", "custom-selector", "nest"]) ? line$4 : hardline$6]), path.map(print, "nodes"))]));
  14256. }
  14257. case "selector-selector":
  14258. {
  14259. return group$2(indent$5(concat$7(path.map(print, "nodes"))));
  14260. }
  14261. case "selector-comment":
  14262. {
  14263. return node.value;
  14264. }
  14265. case "selector-string":
  14266. {
  14267. return adjustStrings(node.value, options);
  14268. }
  14269. case "selector-tag":
  14270. {
  14271. var parentNode = path.getParentNode();
  14272. var index = parentNode && parentNode.nodes.indexOf(node);
  14273. var prevNode = index && parentNode.nodes[index - 1];
  14274. return concat$7([node.namespace ? concat$7([node.namespace === true ? "" : node.namespace.trim(), "|"]) : "", prevNode.type === "selector-nesting" ? node.value : adjustNumbers(isHTMLTag(node.value) || isKeyframeAtRuleKeywords(path, node.value) ? node.value.toLowerCase() : node.value)]);
  14275. }
  14276. case "selector-id":
  14277. {
  14278. return concat$7(["#", node.value]);
  14279. }
  14280. case "selector-class":
  14281. {
  14282. return concat$7([".", adjustNumbers(adjustStrings(node.value, options))]);
  14283. }
  14284. case "selector-attribute":
  14285. {
  14286. return concat$7(["[", node.namespace ? concat$7([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" : "", "]"]);
  14287. }
  14288. case "selector-combinator":
  14289. {
  14290. if (node.value === "+" || node.value === ">" || node.value === "~" || node.value === ">>>") {
  14291. var _parentNode = path.getParentNode();
  14292. var _leading = _parentNode.type === "selector-selector" && _parentNode.nodes[0] === node ? "" : line$4;
  14293. return concat$7([_leading, node.value, isLastNode(path, node) ? "" : " "]);
  14294. }
  14295. var leading = node.value.trim().startsWith("(") ? line$4 : "";
  14296. var value = adjustNumbers(adjustStrings(node.value.trim(), options)) || line$4;
  14297. return concat$7([leading, value]);
  14298. }
  14299. case "selector-universal":
  14300. {
  14301. return concat$7([node.namespace ? concat$7([node.namespace === true ? "" : node.namespace.trim(), "|"]) : "", adjustNumbers(node.value)]);
  14302. }
  14303. case "selector-pseudo":
  14304. {
  14305. return concat$7([maybeToLowerCase(node.value), node.nodes && node.nodes.length > 0 ? concat$7(["(", join$5(", ", path.map(print, "nodes")), ")"]) : ""]);
  14306. }
  14307. case "selector-nesting":
  14308. {
  14309. return node.value;
  14310. }
  14311. case "selector-unknown":
  14312. {
  14313. var ruleAncestorNode = getAncestorNode(path, "css-rule"); // Nested SCSS property
  14314. if (ruleAncestorNode && ruleAncestorNode.isSCSSNesterProperty) {
  14315. return adjustNumbers(adjustStrings(maybeToLowerCase(node.value), options));
  14316. }
  14317. return node.value;
  14318. }
  14319. // postcss-values-parser
  14320. case "value-value":
  14321. case "value-root":
  14322. {
  14323. return path.call(print, "group");
  14324. }
  14325. case "value-comment":
  14326. {
  14327. return concat$7([node.inline ? "//" : "/*", node.value, node.inline ? "" : "*/"]);
  14328. }
  14329. case "value-comma_group":
  14330. {
  14331. var _parentNode2 = path.getParentNode();
  14332. var parentParentNode = path.getParentNode(1);
  14333. var declAncestorProp = getPropOfDeclNode(path);
  14334. var isGridValue = declAncestorProp && _parentNode2.type === "value-value" && (declAncestorProp === "grid" || declAncestorProp.startsWith("grid-template"));
  14335. var atRuleAncestorNode = getAncestorNode(path, "css-atrule");
  14336. var isControlDirective = atRuleAncestorNode && isSCSSControlDirectiveNode(atRuleAncestorNode);
  14337. var printed = path.map(print, "groups");
  14338. var _parts = [];
  14339. var insideURLFunction = insideValueFunctionNode(path, "url");
  14340. var insideSCSSInterpolationInString = false;
  14341. var didBreak = false;
  14342. for (var i = 0; i < node.groups.length; ++i) {
  14343. _parts.push(printed[i]); // Ignore value inside `url()`
  14344. if (insideURLFunction) {
  14345. continue;
  14346. }
  14347. var iPrevNode = node.groups[i - 1];
  14348. var iNode = node.groups[i];
  14349. var iNextNode = node.groups[i + 1];
  14350. var iNextNextNode = node.groups[i + 2]; // Ignore after latest node (i.e. before semicolon)
  14351. if (!iNextNode) {
  14352. continue;
  14353. } // Ignore spaces before/after string interpolation (i.e. `"#{my-fn("_")}"`)
  14354. var isStartSCSSinterpolationInString = iNode.type === "value-string" && iNode.value.startsWith("#{");
  14355. var isEndingSCSSinterpolationInString = insideSCSSInterpolationInString && iNextNode.type === "value-string" && iNextNode.value.endsWith("}");
  14356. if (isStartSCSSinterpolationInString || isEndingSCSSinterpolationInString) {
  14357. insideSCSSInterpolationInString = !insideSCSSInterpolationInString;
  14358. continue;
  14359. }
  14360. if (insideSCSSInterpolationInString) {
  14361. continue;
  14362. } // Ignore colon (i.e. `:`)
  14363. if (isColonNode(iNode) || isColonNode(iNextNode)) {
  14364. continue;
  14365. } // Ignore `@` in Less (i.e. `@@var;`)
  14366. if (iNode.type === "value-atword" && iNode.value === "") {
  14367. continue;
  14368. } // Ignore `~` in Less (i.e. `content: ~"^//* some horrible but needed css hack";`)
  14369. if (iNode.value === "~") {
  14370. continue;
  14371. } // Ignore `\` (i.e. `$variable: \@small;`)
  14372. if (iNode.value === "\\") {
  14373. continue;
  14374. } // Ignore `$$` (i.e. `background-color: $$(style)Color;`)
  14375. if (isPostcssSimpleVarNode(iNode, iNextNode)) {
  14376. continue;
  14377. } // Ignore spaces after `#` and after `{` and before `}` in SCSS interpolation (i.e. `#{variable}`)
  14378. if (isHashNode(iNode) || isLeftCurlyBraceNode(iNode) || isRightCurlyBraceNode(iNextNode) || isLeftCurlyBraceNode(iNextNode) && hasEmptyRawBefore(iNextNode) || isRightCurlyBraceNode(iNode) && hasEmptyRawBefore(iNextNode)) {
  14379. continue;
  14380. } // Ignore css variables and interpolation in SCSS (i.e. `--#{$var}`)
  14381. if (iNode.value === "--" && isHashNode(iNextNode)) {
  14382. continue;
  14383. } // Formatting math operations
  14384. var isMathOperator = isMathOperatorNode(iNode);
  14385. var isNextMathOperator = isMathOperatorNode(iNextNode); // Print spaces before and after math operators beside SCSS interpolation as is
  14386. // (i.e. `#{$var}+5`, `#{$var} +5`, `#{$var}+ 5`, `#{$var} + 5`)
  14387. // (i.e. `5+#{$var}`, `5 +#{$var}`, `5+ #{$var}`, `5 + #{$var}`)
  14388. if ((isMathOperator && isHashNode(iNextNode) || isNextMathOperator && isRightCurlyBraceNode(iNode)) && hasEmptyRawBefore(iNextNode)) {
  14389. continue;
  14390. } // Print spaces before and after addition and subtraction math operators as is in `calc` function
  14391. // due to the fact that it is not valid syntax
  14392. // (i.e. `calc(1px+1px)`, `calc(1px+ 1px)`, `calc(1px +1px)`, `calc(1px + 1px)`)
  14393. if (insideValueFunctionNode(path, "calc") && (isAdditionNode(iNode) || isAdditionNode(iNextNode) || isSubtractionNode(iNode) || isSubtractionNode(iNextNode)) && hasEmptyRawBefore(iNextNode)) {
  14394. continue;
  14395. } // Print spaces after `+` and `-` in color adjuster functions as is (e.g. `color(red l(+ 20%))`)
  14396. // Adjusters with signed numbers (e.g. `color(red l(+20%))`) output as-is.
  14397. var isColorAdjusterNode = (isAdditionNode(iNode) || isSubtractionNode(iNode)) && i === 0 && (iNextNode.type === "value-number" || iNextNode.isHex) && parentParentNode && isColorAdjusterFuncNode(parentParentNode) && !hasEmptyRawBefore(iNextNode);
  14398. var requireSpaceBeforeOperator = iNextNextNode && iNextNextNode.type === "value-func" || iNextNextNode && isWordNode(iNextNextNode) || iNode.type === "value-func" || isWordNode(iNode);
  14399. var requireSpaceAfterOperator = iNextNode.type === "value-func" || isWordNode(iNextNode) || iPrevNode && iPrevNode.type === "value-func" || iPrevNode && isWordNode(iPrevNode); // Formatting `/`, `+`, `-` sign
  14400. 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)))) {
  14401. continue;
  14402. } // Ignore inline comment, they already contain newline at end (i.e. `// Comment`)
  14403. // Add `hardline` after inline comment (i.e. `// comment\n foo: bar;`)
  14404. var isInlineComment = isInlineValueCommentNode(iNode);
  14405. if (iPrevNode && isInlineValueCommentNode(iPrevNode) || isInlineComment || isInlineValueCommentNode(iNextNode)) {
  14406. if (isInlineComment) {
  14407. _parts.push(hardline$6);
  14408. }
  14409. continue;
  14410. } // Handle keywords in SCSS control directive
  14411. if (isControlDirective && (isEqualityOperatorNode(iNextNode) || isRelationalOperatorNode(iNextNode) || isIfElseKeywordNode(iNextNode) || isEachKeywordNode(iNode) || isForKeywordNode(iNode))) {
  14412. _parts.push(" ");
  14413. continue;
  14414. } // At-rule `namespace` should be in one line
  14415. if (atRuleAncestorNode && atRuleAncestorNode.name.toLowerCase() === "namespace") {
  14416. _parts.push(" ");
  14417. continue;
  14418. } // Formatting `grid` property
  14419. if (isGridValue) {
  14420. if (iNode.source.start.line !== iNextNode.source.start.line) {
  14421. _parts.push(hardline$6);
  14422. didBreak = true;
  14423. } else {
  14424. _parts.push(" ");
  14425. }
  14426. continue;
  14427. } // Add `space` before next math operation
  14428. // Note: `grip` property have `/` delimiter and it is not math operation, so
  14429. // `grid` property handles above
  14430. if (isNextMathOperator) {
  14431. _parts.push(" ");
  14432. continue;
  14433. } // Be default all values go through `line`
  14434. _parts.push(line$4);
  14435. }
  14436. if (didBreak) {
  14437. _parts.unshift(hardline$6);
  14438. }
  14439. if (isControlDirective) {
  14440. return group$2(indent$5(concat$7(_parts)));
  14441. } // Indent is not needed for import url when url is very long
  14442. // and node has two groups
  14443. // when type is value-comma_group
  14444. // example @import url("verylongurl") projection,tv
  14445. if (insideURLFunctionInImportAtRuleNode(path)) {
  14446. return group$2(fill$3(_parts));
  14447. }
  14448. return group$2(indent$5(fill$3(_parts)));
  14449. }
  14450. case "value-paren_group":
  14451. {
  14452. var _parentNode3 = path.getParentNode();
  14453. if (_parentNode3 && isURLFunctionNode(_parentNode3) && (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:"))) {
  14454. return concat$7([node.open ? path.call(print, "open") : "", join$5(",", path.map(print, "groups")), node.close ? path.call(print, "close") : ""]);
  14455. }
  14456. if (!node.open) {
  14457. var _printed = path.map(print, "groups");
  14458. var res = [];
  14459. for (var _i = 0; _i < _printed.length; _i++) {
  14460. if (_i !== 0) {
  14461. res.push(concat$7([",", line$4]));
  14462. }
  14463. res.push(_printed[_i]);
  14464. }
  14465. return group$2(indent$5(fill$3(res)));
  14466. }
  14467. var isSCSSMapItem = isSCSSMapItemNode(path);
  14468. return group$2(concat$7([node.open ? path.call(print, "open") : "", indent$5(concat$7([softline$3, join$5(concat$7([",", line$4]), path.map(function (childPath) {
  14469. var node = childPath.getValue();
  14470. var printed = print(childPath); // Key/Value pair in open paren already indented
  14471. if (isKeyValuePairNode(node) && node.type === "value-comma_group" && node.groups && node.groups[2] && node.groups[2].type === "value-paren_group") {
  14472. printed.contents.contents.parts[1] = group$2(printed.contents.contents.parts[1]);
  14473. return group$2(dedent$3(printed));
  14474. }
  14475. return printed;
  14476. }, "groups"))])), ifBreak$2(isSCSS(options.parser, options.originalText) && isSCSSMapItem && shouldPrintComma$1(options) ? "," : ""), softline$3, node.close ? path.call(print, "close") : ""]), {
  14477. shouldBreak: isSCSSMapItem
  14478. });
  14479. }
  14480. case "value-func":
  14481. {
  14482. return concat$7([node.value, insideAtRuleNode(path, "supports") && isMediaAndSupportsKeywords(node) ? " " : "", path.call(print, "group")]);
  14483. }
  14484. case "value-paren":
  14485. {
  14486. return node.value;
  14487. }
  14488. case "value-number":
  14489. {
  14490. return concat$7([printCssNumber(node.value), maybeToLowerCase(node.unit)]);
  14491. }
  14492. case "value-operator":
  14493. {
  14494. return node.value;
  14495. }
  14496. case "value-word":
  14497. {
  14498. if (node.isColor && node.isHex || isWideKeywords(node.value)) {
  14499. return node.value.toLowerCase();
  14500. }
  14501. return node.value;
  14502. }
  14503. case "value-colon":
  14504. {
  14505. return concat$7([node.value, // Don't add spaces on `:` in `url` function (i.e. `url(fbglyph: cross-outline, fig-white)`)
  14506. insideValueFunctionNode(path, "url") ? "" : line$4]);
  14507. }
  14508. case "value-comma":
  14509. {
  14510. return concat$7([node.value, " "]);
  14511. }
  14512. case "value-string":
  14513. {
  14514. return printString$2(node.raws.quote + node.value + node.raws.quote, options);
  14515. }
  14516. case "value-atword":
  14517. {
  14518. return concat$7(["@", node.value]);
  14519. }
  14520. case "value-unicode-range":
  14521. {
  14522. return node.value;
  14523. }
  14524. case "value-unknown":
  14525. {
  14526. return node.value;
  14527. }
  14528. default:
  14529. /* istanbul ignore next */
  14530. throw new Error("Unknown postcss type ".concat(JSON.stringify(node.type)));
  14531. }
  14532. }
  14533. function printNodeSequence(path, options, print) {
  14534. var node = path.getValue();
  14535. var parts = [];
  14536. var i = 0;
  14537. path.map(function (pathChild) {
  14538. var prevNode = node.nodes[i - 1];
  14539. if (prevNode && prevNode.type === "css-comment" && prevNode.text.trim() === "prettier-ignore") {
  14540. var childNode = pathChild.getValue();
  14541. parts.push(options.originalText.slice(options.locStart(childNode), options.locEnd(childNode)));
  14542. } else {
  14543. parts.push(pathChild.call(print));
  14544. }
  14545. if (i !== node.nodes.length - 1) {
  14546. if (node.nodes[i + 1].type === "css-comment" && !hasNewline$3(options.originalText, options.locStart(node.nodes[i + 1]), {
  14547. backwards: true
  14548. }) || node.nodes[i + 1].type === "css-atrule" && node.nodes[i + 1].name === "else" && node.nodes[i].type !== "css-comment") {
  14549. parts.push(" ");
  14550. } else {
  14551. parts.push(hardline$6);
  14552. if (isNextLineEmpty$3(options.originalText, pathChild.getValue(), options)) {
  14553. parts.push(hardline$6);
  14554. }
  14555. }
  14556. }
  14557. i++;
  14558. }, "nodes");
  14559. return concat$7(parts);
  14560. }
  14561. var STRING_REGEX = /(['"])(?:(?!\1)[^\\]|\\[\s\S])*\1/g;
  14562. var NUMBER_REGEX = /(?:\d*\.\d+|\d+\.?)(?:[eE][+-]?\d+)?/g;
  14563. var STANDARD_UNIT_REGEX = /[a-zA-Z]+/g;
  14564. var WORD_PART_REGEX = /[$@]?[a-zA-Z_\u0080-\uFFFF][\w\-\u0080-\uFFFF]*/g;
  14565. var ADJUST_NUMBERS_REGEX = RegExp(STRING_REGEX.source + "|" + "(".concat(WORD_PART_REGEX.source, ")?") + "(".concat(NUMBER_REGEX.source, ")") + "(".concat(STANDARD_UNIT_REGEX.source, ")?"), "g");
  14566. function adjustStrings(value, options) {
  14567. return value.replace(STRING_REGEX, function (match) {
  14568. return printString$2(match, options);
  14569. });
  14570. }
  14571. function quoteAttributeValue(value, options) {
  14572. var quote = options.singleQuote ? "'" : '"';
  14573. return value.includes('"') || value.includes("'") ? value : quote + value + quote;
  14574. }
  14575. function adjustNumbers(value) {
  14576. return value.replace(ADJUST_NUMBERS_REGEX, function (match, quote, wordPart, number, unit) {
  14577. return !wordPart && number ? (wordPart || "") + printCssNumber(number) + maybeToLowerCase(unit || "") : match;
  14578. });
  14579. }
  14580. function printCssNumber(rawNumber) {
  14581. return printNumber$2(rawNumber) // Remove trailing `.0`.
  14582. .replace(/\.0(?=$|e)/, "");
  14583. }
  14584. var printerPostcss = {
  14585. print: genericPrint$3,
  14586. hasPrettierIgnore: hasIgnoreComment$2,
  14587. massageAstNode: clean_1$2
  14588. };
  14589. var options$6 = {
  14590. singleQuote: commonOptions.singleQuote
  14591. };
  14592. // https://github.com/github/linguist/blob/master/lib/linguist/languages.yml
  14593. var languages$1 = [{
  14594. name: "CSS",
  14595. since: "1.4.0",
  14596. parsers: ["css"],
  14597. group: "CSS",
  14598. tmScope: "source.css",
  14599. aceMode: "css",
  14600. codemirrorMode: "css",
  14601. codemirrorMimeType: "text/css",
  14602. extensions: [".css", ".pcss", ".postcss"],
  14603. liguistLanguageId: 50,
  14604. vscodeLanguageIds: ["css", "postcss"]
  14605. }, {
  14606. name: "Less",
  14607. since: "1.4.0",
  14608. parsers: ["less"],
  14609. group: "CSS",
  14610. extensions: [".less"],
  14611. tmScope: "source.css.less",
  14612. aceMode: "less",
  14613. codemirrorMode: "css",
  14614. codemirrorMimeType: "text/css",
  14615. liguistLanguageId: 198,
  14616. vscodeLanguageIds: ["less"]
  14617. }, {
  14618. name: "SCSS",
  14619. since: "1.4.0",
  14620. parsers: ["scss"],
  14621. group: "CSS",
  14622. tmScope: "source.scss",
  14623. aceMode: "scss",
  14624. codemirrorMode: "css",
  14625. codemirrorMimeType: "text/x-scss",
  14626. extensions: [".scss"],
  14627. liguistLanguageId: 329,
  14628. vscodeLanguageIds: ["scss"]
  14629. }];
  14630. var printers$1 = {
  14631. postcss: printerPostcss
  14632. };
  14633. var languageCss = {
  14634. languages: languages$1,
  14635. options: options$6,
  14636. printers: printers$1
  14637. };
  14638. var _require$$0$builders$3 = doc.builders;
  14639. var concat$8 = _require$$0$builders$3.concat;
  14640. var join$6 = _require$$0$builders$3.join;
  14641. var hardline$7 = _require$$0$builders$3.hardline;
  14642. var line$5 = _require$$0$builders$3.line;
  14643. var softline$4 = _require$$0$builders$3.softline;
  14644. var group$3 = _require$$0$builders$3.group;
  14645. var indent$6 = _require$$0$builders$3.indent;
  14646. var ifBreak$3 = _require$$0$builders$3.ifBreak;
  14647. var hasIgnoreComment$3 = util.hasIgnoreComment;
  14648. var isNextLineEmpty$4 = utilShared.isNextLineEmpty;
  14649. function genericPrint$4(path, options, print) {
  14650. var n = path.getValue();
  14651. if (!n) {
  14652. return "";
  14653. }
  14654. if (typeof n === "string") {
  14655. return n;
  14656. }
  14657. switch (n.kind) {
  14658. case "Document":
  14659. {
  14660. var parts = [];
  14661. path.map(function (pathChild, index) {
  14662. parts.push(concat$8([pathChild.call(print)]));
  14663. if (index !== n.definitions.length - 1) {
  14664. parts.push(hardline$7);
  14665. if (isNextLineEmpty$4(options.originalText, pathChild.getValue(), options)) {
  14666. parts.push(hardline$7);
  14667. }
  14668. }
  14669. }, "definitions");
  14670. return concat$8([concat$8(parts), hardline$7]);
  14671. }
  14672. case "OperationDefinition":
  14673. {
  14674. var hasOperation = options.originalText[options.locStart(n)] !== "{";
  14675. var hasName = !!n.name;
  14676. return concat$8([hasOperation ? n.operation : "", hasOperation && hasName ? concat$8([" ", path.call(print, "name")]) : "", n.variableDefinitions && n.variableDefinitions.length ? group$3(concat$8(["(", indent$6(concat$8([softline$4, join$6(concat$8([ifBreak$3("", ", "), softline$4]), path.map(print, "variableDefinitions"))])), softline$4, ")"])) : "", printDirectives(path, print, n), n.selectionSet ? !hasOperation && !hasName ? "" : " " : "", path.call(print, "selectionSet")]);
  14677. }
  14678. case "FragmentDefinition":
  14679. {
  14680. return concat$8(["fragment ", path.call(print, "name"), " on ", path.call(print, "typeCondition"), printDirectives(path, print, n), " ", path.call(print, "selectionSet")]);
  14681. }
  14682. case "SelectionSet":
  14683. {
  14684. return concat$8(["{", indent$6(concat$8([hardline$7, join$6(hardline$7, path.call(function (selectionsPath) {
  14685. return printSequence(selectionsPath, options, print);
  14686. }, "selections"))])), hardline$7, "}"]);
  14687. }
  14688. case "Field":
  14689. {
  14690. return group$3(concat$8([n.alias ? concat$8([path.call(print, "alias"), ": "]) : "", path.call(print, "name"), n.arguments.length > 0 ? group$3(concat$8(["(", indent$6(concat$8([softline$4, join$6(concat$8([ifBreak$3("", ", "), softline$4]), path.call(function (argsPath) {
  14691. return printSequence(argsPath, options, print);
  14692. }, "arguments"))])), softline$4, ")"])) : "", printDirectives(path, print, n), n.selectionSet ? " " : "", path.call(print, "selectionSet")]));
  14693. }
  14694. case "Name":
  14695. {
  14696. return n.value;
  14697. }
  14698. case "StringValue":
  14699. {
  14700. if (n.block) {
  14701. return concat$8(['"""', hardline$7, join$6(hardline$7, n.value.replace(/"""/g, "\\$&").split("\n")), hardline$7, '"""']);
  14702. }
  14703. return concat$8(['"', n.value.replace(/["\\]/g, "\\$&"), '"']);
  14704. }
  14705. case "IntValue":
  14706. case "FloatValue":
  14707. case "EnumValue":
  14708. {
  14709. return n.value;
  14710. }
  14711. case "BooleanValue":
  14712. {
  14713. return n.value ? "true" : "false";
  14714. }
  14715. case "NullValue":
  14716. {
  14717. return "null";
  14718. }
  14719. case "Variable":
  14720. {
  14721. return concat$8(["$", path.call(print, "name")]);
  14722. }
  14723. case "ListValue":
  14724. {
  14725. return group$3(concat$8(["[", indent$6(concat$8([softline$4, join$6(concat$8([ifBreak$3("", ", "), softline$4]), path.map(print, "values"))])), softline$4, "]"]));
  14726. }
  14727. case "ObjectValue":
  14728. {
  14729. return group$3(concat$8(["{", options.bracketSpacing && n.fields.length > 0 ? " " : "", indent$6(concat$8([softline$4, join$6(concat$8([ifBreak$3("", ", "), softline$4]), path.map(print, "fields"))])), softline$4, ifBreak$3("", options.bracketSpacing && n.fields.length > 0 ? " " : ""), "}"]));
  14730. }
  14731. case "ObjectField":
  14732. case "Argument":
  14733. {
  14734. return concat$8([path.call(print, "name"), ": ", path.call(print, "value")]);
  14735. }
  14736. case "Directive":
  14737. {
  14738. return concat$8(["@", path.call(print, "name"), n.arguments.length > 0 ? group$3(concat$8(["(", indent$6(concat$8([softline$4, join$6(concat$8([ifBreak$3("", ", "), softline$4]), path.call(function (argsPath) {
  14739. return printSequence(argsPath, options, print);
  14740. }, "arguments"))])), softline$4, ")"])) : ""]);
  14741. }
  14742. case "NamedType":
  14743. {
  14744. return path.call(print, "name");
  14745. }
  14746. case "VariableDefinition":
  14747. {
  14748. return concat$8([path.call(print, "variable"), ": ", path.call(print, "type"), n.defaultValue ? concat$8([" = ", path.call(print, "defaultValue")]) : ""]);
  14749. }
  14750. case "TypeExtensionDefinition":
  14751. {
  14752. return concat$8(["extend ", path.call(print, "definition")]);
  14753. }
  14754. case "ObjectTypeExtension":
  14755. case "ObjectTypeDefinition":
  14756. {
  14757. return concat$8([path.call(print, "description"), n.description ? hardline$7 : "", n.kind === "ObjectTypeExtension" ? "extend " : "", "type ", path.call(print, "name"), n.interfaces.length > 0 ? concat$8([" implements ", join$6(determineInterfaceSeparator(options.originalText.substr(options.locStart(n), options.locEnd(n))), path.map(print, "interfaces"))]) : "", printDirectives(path, print, n), n.fields.length > 0 ? concat$8([" {", indent$6(concat$8([hardline$7, join$6(hardline$7, path.call(function (fieldsPath) {
  14758. return printSequence(fieldsPath, options, print);
  14759. }, "fields"))])), hardline$7, "}"]) : ""]);
  14760. }
  14761. case "FieldDefinition":
  14762. {
  14763. return concat$8([path.call(print, "description"), n.description ? hardline$7 : "", path.call(print, "name"), n.arguments.length > 0 ? group$3(concat$8(["(", indent$6(concat$8([softline$4, join$6(concat$8([ifBreak$3("", ", "), softline$4]), path.call(function (argsPath) {
  14764. return printSequence(argsPath, options, print);
  14765. }, "arguments"))])), softline$4, ")"])) : "", ": ", path.call(print, "type"), printDirectives(path, print, n)]);
  14766. }
  14767. case "DirectiveDefinition":
  14768. {
  14769. return concat$8([path.call(print, "description"), n.description ? hardline$7 : "", "directive ", "@", path.call(print, "name"), n.arguments.length > 0 ? group$3(concat$8(["(", indent$6(concat$8([softline$4, join$6(concat$8([ifBreak$3("", ", "), softline$4]), path.call(function (argsPath) {
  14770. return printSequence(argsPath, options, print);
  14771. }, "arguments"))])), softline$4, ")"])) : "", concat$8([" on ", join$6(" | ", path.map(print, "locations"))])]);
  14772. }
  14773. case "EnumTypeExtension":
  14774. case "EnumTypeDefinition":
  14775. {
  14776. return concat$8([path.call(print, "description"), n.description ? hardline$7 : "", n.kind === "EnumTypeExtension" ? "extend " : "", "enum ", path.call(print, "name"), printDirectives(path, print, n), n.values.length > 0 ? concat$8([" {", indent$6(concat$8([hardline$7, join$6(hardline$7, path.call(function (valuesPath) {
  14777. return printSequence(valuesPath, options, print);
  14778. }, "values"))])), hardline$7, "}"]) : ""]);
  14779. }
  14780. case "EnumValueDefinition":
  14781. {
  14782. return concat$8([path.call(print, "description"), n.description ? hardline$7 : "", path.call(print, "name"), printDirectives(path, print, n)]);
  14783. }
  14784. case "InputValueDefinition":
  14785. {
  14786. return concat$8([path.call(print, "description"), n.description ? n.description.block ? hardline$7 : line$5 : "", path.call(print, "name"), ": ", path.call(print, "type"), n.defaultValue ? concat$8([" = ", path.call(print, "defaultValue")]) : "", printDirectives(path, print, n)]);
  14787. }
  14788. case "InputObjectTypeExtension":
  14789. case "InputObjectTypeDefinition":
  14790. {
  14791. return concat$8([path.call(print, "description"), n.description ? hardline$7 : "", n.kind === "InputObjectTypeExtension" ? "extend " : "", "input ", path.call(print, "name"), printDirectives(path, print, n), n.fields.length > 0 ? concat$8([" {", indent$6(concat$8([hardline$7, join$6(hardline$7, path.call(function (fieldsPath) {
  14792. return printSequence(fieldsPath, options, print);
  14793. }, "fields"))])), hardline$7, "}"]) : ""]);
  14794. }
  14795. case "SchemaDefinition":
  14796. {
  14797. return concat$8(["schema", printDirectives(path, print, n), " {", n.operationTypes.length > 0 ? indent$6(concat$8([hardline$7, join$6(hardline$7, path.call(function (opsPath) {
  14798. return printSequence(opsPath, options, print);
  14799. }, "operationTypes"))])) : "", hardline$7, "}"]);
  14800. }
  14801. case "OperationTypeDefinition":
  14802. {
  14803. return concat$8([path.call(print, "operation"), ": ", path.call(print, "type")]);
  14804. }
  14805. case "InterfaceTypeExtension":
  14806. case "InterfaceTypeDefinition":
  14807. {
  14808. return concat$8([path.call(print, "description"), n.description ? hardline$7 : "", n.kind === "InterfaceTypeExtension" ? "extend " : "", "interface ", path.call(print, "name"), printDirectives(path, print, n), n.fields.length > 0 ? concat$8([" {", indent$6(concat$8([hardline$7, join$6(hardline$7, path.call(function (fieldsPath) {
  14809. return printSequence(fieldsPath, options, print);
  14810. }, "fields"))])), hardline$7, "}"]) : ""]);
  14811. }
  14812. case "FragmentSpread":
  14813. {
  14814. return concat$8(["...", path.call(print, "name"), printDirectives(path, print, n)]);
  14815. }
  14816. case "InlineFragment":
  14817. {
  14818. return concat$8(["...", n.typeCondition ? concat$8([" on ", path.call(print, "typeCondition")]) : "", printDirectives(path, print, n), " ", path.call(print, "selectionSet")]);
  14819. }
  14820. case "UnionTypeExtension":
  14821. case "UnionTypeDefinition":
  14822. {
  14823. return group$3(concat$8([path.call(print, "description"), n.description ? hardline$7 : "", group$3(concat$8([n.kind === "UnionTypeExtension" ? "extend " : "", "union ", path.call(print, "name"), printDirectives(path, print, n), n.types.length > 0 ? concat$8([" =", ifBreak$3("", " "), indent$6(concat$8([ifBreak$3(concat$8([line$5, " "])), join$6(concat$8([line$5, "| "]), path.map(print, "types"))]))]) : ""]))]));
  14824. }
  14825. case "ScalarTypeExtension":
  14826. case "ScalarTypeDefinition":
  14827. {
  14828. return concat$8([path.call(print, "description"), n.description ? hardline$7 : "", n.kind === "ScalarTypeExtension" ? "extend " : "", "scalar ", path.call(print, "name"), printDirectives(path, print, n)]);
  14829. }
  14830. case "NonNullType":
  14831. {
  14832. return concat$8([path.call(print, "type"), "!"]);
  14833. }
  14834. case "ListType":
  14835. {
  14836. return concat$8(["[", path.call(print, "type"), "]"]);
  14837. }
  14838. default:
  14839. /* istanbul ignore next */
  14840. throw new Error("unknown graphql type: " + JSON.stringify(n.kind));
  14841. }
  14842. }
  14843. function printDirectives(path, print, n) {
  14844. if (n.directives.length === 0) {
  14845. return "";
  14846. }
  14847. return concat$8([" ", group$3(indent$6(concat$8([softline$4, join$6(concat$8([ifBreak$3("", " "), softline$4]), path.map(print, "directives"))])))]);
  14848. }
  14849. function printSequence(sequencePath, options, print) {
  14850. var count = sequencePath.getValue().length;
  14851. return sequencePath.map(function (path, i) {
  14852. var printed = print(path);
  14853. if (isNextLineEmpty$4(options.originalText, path.getValue(), options) && i < count - 1) {
  14854. return concat$8([printed, hardline$7]);
  14855. }
  14856. return printed;
  14857. });
  14858. }
  14859. function canAttachComment$1(node) {
  14860. return node.kind && node.kind !== "Comment";
  14861. }
  14862. function printComment$2(commentPath) {
  14863. var comment = commentPath.getValue();
  14864. switch (comment.kind) {
  14865. case "Comment":
  14866. return "#" + comment.value.trimRight();
  14867. default:
  14868. throw new Error("Not a comment: " + JSON.stringify(comment));
  14869. }
  14870. }
  14871. function determineInterfaceSeparator(originalSource) {
  14872. var start = originalSource.indexOf("implements");
  14873. if (start === -1) {
  14874. throw new Error("Must implement interfaces: " + originalSource);
  14875. }
  14876. var end = originalSource.indexOf("{");
  14877. if (end === -1) {
  14878. end = originalSource.length;
  14879. }
  14880. return originalSource.substr(start, end).includes("&") ? " & " : ", ";
  14881. }
  14882. function clean$5(node, newNode
  14883. /*, parent*/
  14884. ) {
  14885. delete newNode.loc;
  14886. delete newNode.comments;
  14887. }
  14888. var printerGraphql = {
  14889. print: genericPrint$4,
  14890. massageAstNode: clean$5,
  14891. hasPrettierIgnore: hasIgnoreComment$3,
  14892. printComment: printComment$2,
  14893. canAttachComment: canAttachComment$1
  14894. };
  14895. var options$9 = {
  14896. bracketSpacing: commonOptions.bracketSpacing
  14897. };
  14898. // https://github.com/github/linguist/blob/master/lib/linguist/languages.yml
  14899. var languages$2 = [{
  14900. name: "GraphQL",
  14901. since: "1.5.0",
  14902. parsers: ["graphql"],
  14903. extensions: [".graphql", ".gql"],
  14904. tmScope: "source.graphql",
  14905. aceMode: "text",
  14906. liguistLanguageId: 139,
  14907. vscodeLanguageIds: ["graphql"]
  14908. }];
  14909. var printers$2 = {
  14910. graphql: printerGraphql
  14911. };
  14912. var languageGraphql = {
  14913. languages: languages$2,
  14914. options: options$9,
  14915. printers: printers$2
  14916. };
  14917. var _require$$0$builders$5 = doc.builders;
  14918. var hardline$9 = _require$$0$builders$5.hardline;
  14919. var literalline$4 = _require$$0$builders$5.literalline;
  14920. var concat$10 = _require$$0$builders$5.concat;
  14921. var markAsRoot$2 = _require$$0$builders$5.markAsRoot;
  14922. var mapDoc$4 = doc.utils.mapDoc;
  14923. function embed$2(path, print, textToDoc, options) {
  14924. var node = path.getValue();
  14925. if (node.type === "code" && node.lang !== null) {
  14926. // only look for the first string so as to support [markdown-preview-enhanced](https://shd101wyy.github.io/markdown-preview-enhanced/#/code-chunk)
  14927. var lang = node.lang.split(/\s/, 1)[0];
  14928. var parser = getParserName(lang);
  14929. if (parser) {
  14930. var styleUnit = options.__inJsTemplate ? "~" : "`";
  14931. var style = styleUnit.repeat(Math.max(3, util.getMaxContinuousCount(node.value, styleUnit) + 1));
  14932. var doc$$2 = textToDoc(node.value, {
  14933. parser: parser
  14934. });
  14935. return markAsRoot$2(concat$10([style, node.lang, hardline$9, replaceNewlinesWithLiterallines(doc$$2), style]));
  14936. }
  14937. }
  14938. return null;
  14939. function getParserName(lang) {
  14940. var supportInfo = support.getSupportInfo(null, {
  14941. plugins: options.plugins
  14942. });
  14943. var language = supportInfo.languages.find(function (language) {
  14944. return language.name.toLowerCase() === lang || language.extensions && language.extensions.find(function (ext) {
  14945. return ext.substring(1) === lang;
  14946. });
  14947. });
  14948. if (language) {
  14949. return language.parsers[0];
  14950. }
  14951. return null;
  14952. }
  14953. function replaceNewlinesWithLiterallines(doc$$2) {
  14954. return mapDoc$4(doc$$2, function (currentDoc) {
  14955. return typeof currentDoc === "string" && currentDoc.includes("\n") ? concat$10(currentDoc.split(/(\n)/g).map(function (v, i) {
  14956. return i % 2 === 0 ? v : literalline$4;
  14957. })) : currentDoc;
  14958. });
  14959. }
  14960. }
  14961. var embed_1$2 = embed$2;
  14962. function parse$3(text) {
  14963. var delimiter;
  14964. if (text.indexOf("---") === 0) {
  14965. delimiter = "---";
  14966. } else if (text.indexOf("+++") === 0) {
  14967. delimiter = "+++";
  14968. }
  14969. var end = -1;
  14970. if (!delimiter || (end = text.indexOf("\n".concat(delimiter), 3)) === -1) {
  14971. return {
  14972. frontMatter: null,
  14973. content: text
  14974. };
  14975. }
  14976. end = end + 4;
  14977. return {
  14978. frontMatter: text.slice(0, end),
  14979. content: text.slice(end)
  14980. };
  14981. }
  14982. var frontMatter = parse$3;
  14983. var pragma$2 = createCommonjsModule(function (module) {
  14984. "use strict";
  14985. var pragmas = ["format", "prettier"];
  14986. function startWithPragma(text) {
  14987. var pragma = "@(".concat(pragmas.join("|"), ")");
  14988. var regex = new RegExp(["<!--\\s*".concat(pragma, "\\s*-->"), "<!--.*\n[\\s\\S]*(^|\n)[^\\S\n]*".concat(pragma, "[^\\S\n]*($|\n)[\\s\\S]*\n.*-->")].join("|"), "m");
  14989. var matched = text.match(regex);
  14990. return matched && matched.index === 0;
  14991. }
  14992. module.exports = {
  14993. startWithPragma: startWithPragma,
  14994. hasPragma: function hasPragma(text) {
  14995. return startWithPragma(frontMatter(text).content.trimLeft());
  14996. },
  14997. insertPragma: function insertPragma(text) {
  14998. var extracted = frontMatter(text);
  14999. var pragma = "<!-- @".concat(pragmas[0], " -->");
  15000. return extracted.frontMatter ? "".concat(extracted.frontMatter, "\n\n").concat(pragma, "\n\n").concat(extracted.content) : "".concat(pragma, "\n\n").concat(extracted.content);
  15001. }
  15002. };
  15003. });
  15004. var _require$$0$builders$4 = doc.builders;
  15005. var concat$9 = _require$$0$builders$4.concat;
  15006. var join$7 = _require$$0$builders$4.join;
  15007. var line$6 = _require$$0$builders$4.line;
  15008. var literalline$3 = _require$$0$builders$4.literalline;
  15009. var markAsRoot$1 = _require$$0$builders$4.markAsRoot;
  15010. var hardline$8 = _require$$0$builders$4.hardline;
  15011. var softline$5 = _require$$0$builders$4.softline;
  15012. var fill$4 = _require$$0$builders$4.fill;
  15013. var align$2 = _require$$0$builders$4.align;
  15014. var indent$7 = _require$$0$builders$4.indent;
  15015. var group$4 = _require$$0$builders$4.group;
  15016. var mapDoc$3 = doc.utils.mapDoc;
  15017. var printDocToString$2 = doc.printer.printDocToString;
  15018. var SINGLE_LINE_NODE_TYPES = ["heading", "tableCell", "link"];
  15019. var SIBLING_NODE_TYPES = ["listItem", "definition", "footnoteDefinition"];
  15020. var INLINE_NODE_TYPES = ["liquidNode", "inlineCode", "emphasis", "strong", "delete", "link", "linkReference", "image", "imageReference", "footnote", "footnoteReference", "sentence", "whitespace", "word", "break"];
  15021. var INLINE_NODE_WRAPPER_TYPES = INLINE_NODE_TYPES.concat(["tableCell", "paragraph", "heading"]);
  15022. function genericPrint$5(path, options, print) {
  15023. var node = path.getValue();
  15024. if (shouldRemainTheSameContent(path)) {
  15025. return concat$9(util.splitText(options.originalText.slice(node.position.start.offset, node.position.end.offset), options).map(function (node) {
  15026. return node.type === "word" ? node.value : node.value === "" ? "" : printLine(path, node.value, options);
  15027. }));
  15028. }
  15029. switch (node.type) {
  15030. case "root":
  15031. if (node.children.length === 0) {
  15032. return "";
  15033. }
  15034. return concat$9([normalizeDoc(printRoot(path, options, print)), hardline$8]);
  15035. case "paragraph":
  15036. return printChildren(path, options, print, {
  15037. postprocessor: fill$4
  15038. });
  15039. case "sentence":
  15040. return printChildren(path, options, print);
  15041. case "word":
  15042. return node.value.replace(/[*]/g, "\\*") // escape all `*`
  15043. .replace(new RegExp(["(^|[".concat(util.punctuationCharRange, "])(_+)"), "(_+)([".concat(util.punctuationCharRange, "]|$)")].join("|"), "g"), function (_, text1, underscore1, underscore2, text2) {
  15044. return (underscore1 ? "".concat(text1).concat(underscore1) : "".concat(underscore2).concat(text2)).replace(/_/g, "\\_");
  15045. });
  15046. // escape all `_` except concating with non-punctuation, e.g. `1_2_3` is not considered emphasis
  15047. case "whitespace":
  15048. {
  15049. var parentNode = path.getParentNode();
  15050. var index = parentNode.children.indexOf(node);
  15051. var nextNode = parentNode.children[index + 1];
  15052. var proseWrap = // leading char that may cause different syntax
  15053. nextNode && /^>|^([-+*]|#{1,6}|[0-9]+[.)])$/.test(nextNode.value) ? "never" : options.proseWrap;
  15054. return printLine(path, node.value, {
  15055. proseWrap: proseWrap
  15056. });
  15057. }
  15058. case "emphasis":
  15059. {
  15060. var _parentNode = path.getParentNode();
  15061. var _index = _parentNode.children.indexOf(node);
  15062. var prevNode = _parentNode.children[_index - 1];
  15063. var _nextNode = _parentNode.children[_index + 1];
  15064. var hasPrevOrNextWord = // `1*2*3` is considered emphais but `1_2_3` is not
  15065. prevNode && prevNode.type === "sentence" && prevNode.children.length > 0 && util.getLast(prevNode.children).type === "word" && !util.getLast(prevNode.children).hasTrailingPunctuation || _nextNode && _nextNode.type === "sentence" && _nextNode.children.length > 0 && _nextNode.children[0].type === "word" && !_nextNode.children[0].hasLeadingPunctuation;
  15066. var style = hasPrevOrNextWord || getAncestorNode$2(path, "emphasis") ? "*" : "_";
  15067. return concat$9([style, printChildren(path, options, print), style]);
  15068. }
  15069. case "strong":
  15070. return concat$9(["**", printChildren(path, options, print), "**"]);
  15071. case "delete":
  15072. return concat$9(["~~", printChildren(path, options, print), "~~"]);
  15073. case "inlineCode":
  15074. {
  15075. var backtickCount = util.getMaxContinuousCount(node.value, "`");
  15076. var _style = backtickCount === 1 ? "``" : "`";
  15077. var gap = backtickCount ? " " : "";
  15078. return concat$9([_style, gap, node.value, gap, _style]);
  15079. }
  15080. case "link":
  15081. switch (options.originalText[node.position.start.offset]) {
  15082. case "<":
  15083. return concat$9(["<", node.url, ">"]);
  15084. case "[":
  15085. return concat$9(["[", printChildren(path, options, print), "](", printUrl(node.url, ")"), printTitle(node.title, options), ")"]);
  15086. default:
  15087. return options.originalText.slice(node.position.start.offset, node.position.end.offset);
  15088. }
  15089. case "image":
  15090. return concat$9(["![", node.alt || "", "](", printUrl(node.url, ")"), printTitle(node.title, options), ")"]);
  15091. case "blockquote":
  15092. return concat$9(["> ", align$2("> ", printChildren(path, options, print))]);
  15093. case "heading":
  15094. return concat$9(["#".repeat(node.depth) + " ", printChildren(path, options, print)]);
  15095. case "code":
  15096. {
  15097. if ( // the first char may point to `\n`, e.g. `\n\t\tbar`, just ignore it
  15098. /^\n?( {4,}|\t)/.test(options.originalText.slice(node.position.start.offset, node.position.end.offset))) {
  15099. // indented code block
  15100. var alignment = " ".repeat(4);
  15101. return align$2(alignment, concat$9([alignment, join$7(hardline$8, node.value.split("\n"))]));
  15102. } // fenced code block
  15103. var styleUnit = options.__inJsTemplate ? "~" : "`";
  15104. var _style2 = styleUnit.repeat(Math.max(3, util.getMaxContinuousCount(node.value, styleUnit) + 1));
  15105. return concat$9([_style2, node.lang || "", hardline$8, join$7(hardline$8, node.value.split("\n")), hardline$8, _style2]);
  15106. }
  15107. case "front-matter":
  15108. return node.value;
  15109. case "html":
  15110. {
  15111. var _parentNode2 = path.getParentNode();
  15112. var value = _parentNode2.type === "root" && util.getLast(_parentNode2.children) === node ? node.value.trimRight() : node.value;
  15113. var isHtmlComment = /^<!--[\s\S]*-->$/.test(value);
  15114. return replaceNewlinesWith(value, isHtmlComment ? hardline$8 : markAsRoot$1(literalline$3));
  15115. }
  15116. case "list":
  15117. {
  15118. var nthSiblingIndex = getNthListSiblingIndex(node, path.getParentNode());
  15119. var isGitDiffFriendlyOrderedList = node.ordered && node.children.length > 1 && /^\s*1(\.|\))/.test(options.originalText.slice(node.children[1].position.start.offset, node.children[1].position.end.offset));
  15120. return printChildren(path, options, print, {
  15121. processor: function processor(childPath, index) {
  15122. var prefix = getPrefix();
  15123. return concat$9([prefix, align$2(" ".repeat(prefix.length), printListItem(childPath, options, print, prefix))]);
  15124. function getPrefix() {
  15125. var rawPrefix = node.ordered ? (index === 0 ? node.start : isGitDiffFriendlyOrderedList ? 1 : node.start + index) + (nthSiblingIndex % 2 === 0 ? ". " : ") ") : nthSiblingIndex % 2 === 0 ? "- " : "* "; // do not print trailing spaces for empty list item since it might be treated as `break` node
  15126. // by [doc-printer](https://github.com/prettier/prettier/blob/1.10.2/src/doc/doc-printer.js#L395-L405),
  15127. // we don't want to preserve unnecessary trailing spaces.
  15128. var listItem = childPath.getValue();
  15129. return listItem.children.length ? alignListPrefix(rawPrefix, options) : rawPrefix;
  15130. }
  15131. }
  15132. });
  15133. }
  15134. case "thematicBreak":
  15135. {
  15136. var counter = getAncestorCounter$1(path, "list");
  15137. if (counter === -1) {
  15138. return "---";
  15139. }
  15140. var _nthSiblingIndex = getNthListSiblingIndex(path.getParentNode(counter), path.getParentNode(counter + 1));
  15141. return _nthSiblingIndex % 2 === 0 ? "***" : "---";
  15142. }
  15143. case "linkReference":
  15144. return concat$9(["[", printChildren(path, options, print), "]", node.referenceType === "full" ? concat$9(["[", node.identifier, "]"]) : node.referenceType === "collapsed" ? "[]" : ""]);
  15145. case "imageReference":
  15146. switch (node.referenceType) {
  15147. case "full":
  15148. return concat$9(["![", node.alt || "", "][", node.identifier, "]"]);
  15149. default:
  15150. return concat$9(["![", node.alt, "]", node.referenceType === "collapsed" ? "[]" : ""]);
  15151. }
  15152. case "definition":
  15153. {
  15154. var lineOrSpace = options.proseWrap === "always" ? line$6 : " ";
  15155. return group$4(concat$9([concat$9(["[", node.identifier, "]:"]), indent$7(concat$9([lineOrSpace, printUrl(node.url), node.title === null ? "" : concat$9([lineOrSpace, printTitle(node.title, options, false)])]))]));
  15156. }
  15157. case "footnote":
  15158. return concat$9(["[^", printChildren(path, options, print), "]"]);
  15159. case "footnoteReference":
  15160. return concat$9(["[^", node.identifier, "]"]);
  15161. case "footnoteDefinition":
  15162. {
  15163. var _nextNode2 = path.getParentNode().children[path.getName() + 1];
  15164. return concat$9(["[^", node.identifier, "]: ", group$4(concat$9([align$2(" ".repeat(options.tabWidth), printChildren(path, options, print, {
  15165. processor: function processor(childPath, index) {
  15166. return index === 0 ? group$4(concat$9([softline$5, softline$5, childPath.call(print)])) : childPath.call(print);
  15167. }
  15168. })), _nextNode2 && _nextNode2.type === "footnoteDefinition" ? softline$5 : ""]))]);
  15169. }
  15170. case "table":
  15171. return printTable(path, options, print);
  15172. case "tableCell":
  15173. return printChildren(path, options, print);
  15174. case "break":
  15175. return /\s/.test(options.originalText[node.position.start.offset]) ? concat$9([" ", markAsRoot$1(literalline$3)]) : concat$9(["\\", hardline$8]);
  15176. case "liquidNode":
  15177. return replaceNewlinesWith(node.value, hardline$8);
  15178. case "tableRow": // handled in "table"
  15179. case "listItem": // handled in "list"
  15180. default:
  15181. throw new Error("Unknown markdown type ".concat(JSON.stringify(node.type)));
  15182. }
  15183. }
  15184. function printListItem(path, options, print, listPrefix) {
  15185. var node = path.getValue();
  15186. var prefix = node.checked === null ? "" : node.checked ? "[x] " : "[ ] ";
  15187. return concat$9([prefix, printChildren(path, options, print, {
  15188. processor: function processor(childPath, index) {
  15189. if (index === 0 && childPath.getValue().type !== "list") {
  15190. return align$2(" ".repeat(prefix.length), childPath.call(print));
  15191. }
  15192. var alignment = " ".repeat(clamp(options.tabWidth - listPrefix.length, 0, 3) // 4+ will cause indented code block
  15193. );
  15194. return concat$9([alignment, align$2(alignment, childPath.call(print))]);
  15195. }
  15196. })]);
  15197. }
  15198. function alignListPrefix(prefix, options) {
  15199. var additionalSpaces = getAdditionalSpaces();
  15200. return prefix + " ".repeat(additionalSpaces >= 4 ? 0 : additionalSpaces // 4+ will cause indented code block
  15201. );
  15202. function getAdditionalSpaces() {
  15203. var restSpaces = prefix.length % options.tabWidth;
  15204. return restSpaces === 0 ? 0 : options.tabWidth - restSpaces;
  15205. }
  15206. }
  15207. function getNthListSiblingIndex(node, parentNode) {
  15208. return getNthSiblingIndex(node, parentNode, function (siblingNode) {
  15209. return siblingNode.ordered === node.ordered;
  15210. });
  15211. }
  15212. function replaceNewlinesWith(str, doc$$2) {
  15213. return join$7(doc$$2, str.split("\n"));
  15214. }
  15215. function getNthSiblingIndex(node, parentNode, condition) {
  15216. condition = condition || function () {
  15217. return true;
  15218. };
  15219. var index = -1;
  15220. var _iteratorNormalCompletion = true;
  15221. var _didIteratorError = false;
  15222. var _iteratorError = undefined;
  15223. try {
  15224. for (var _iterator = parentNode.children[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  15225. var childNode = _step.value;
  15226. if (childNode.type === node.type && condition(childNode)) {
  15227. index++;
  15228. } else {
  15229. index = -1;
  15230. }
  15231. if (childNode === node) {
  15232. return index;
  15233. }
  15234. }
  15235. } catch (err) {
  15236. _didIteratorError = true;
  15237. _iteratorError = err;
  15238. } finally {
  15239. try {
  15240. if (!_iteratorNormalCompletion && _iterator.return != null) {
  15241. _iterator.return();
  15242. }
  15243. } finally {
  15244. if (_didIteratorError) {
  15245. throw _iteratorError;
  15246. }
  15247. }
  15248. }
  15249. }
  15250. function getAncestorCounter$1(path, typeOrTypes) {
  15251. var types = [].concat(typeOrTypes);
  15252. var counter = -1;
  15253. var ancestorNode;
  15254. while (ancestorNode = path.getParentNode(++counter)) {
  15255. if (types.indexOf(ancestorNode.type) !== -1) {
  15256. return counter;
  15257. }
  15258. }
  15259. return -1;
  15260. }
  15261. function getAncestorNode$2(path, typeOrTypes) {
  15262. var counter = getAncestorCounter$1(path, typeOrTypes);
  15263. return counter === -1 ? null : path.getParentNode(counter);
  15264. }
  15265. function printLine(path, value, options) {
  15266. if (options.proseWrap === "preserve" && value === "\n") {
  15267. return hardline$8;
  15268. }
  15269. var isBreakable = options.proseWrap === "always" && !getAncestorNode$2(path, SINGLE_LINE_NODE_TYPES);
  15270. return value !== "" ? isBreakable ? line$6 : " " : isBreakable ? softline$5 : "";
  15271. }
  15272. function printTable(path, options, print) {
  15273. var node = path.getValue();
  15274. var contents = []; // { [rowIndex: number]: { [columnIndex: number]: string } }
  15275. path.map(function (rowPath) {
  15276. var rowContents = [];
  15277. rowPath.map(function (cellPath) {
  15278. rowContents.push(printDocToString$2(cellPath.call(print), options).formatted);
  15279. }, "children");
  15280. contents.push(rowContents);
  15281. }, "children");
  15282. var columnMaxWidths = contents.reduce(function (currentWidths, rowContents) {
  15283. return currentWidths.map(function (width, columnIndex) {
  15284. return Math.max(width, util.getStringWidth(rowContents[columnIndex]));
  15285. });
  15286. }, contents[0].map(function () {
  15287. return 3;
  15288. }) // minimum width = 3 (---, :--, :-:, --:)
  15289. );
  15290. return join$7(hardline$8, [printRow(contents[0]), printSeparator(), join$7(hardline$8, contents.slice(1).map(printRow))]);
  15291. function printSeparator() {
  15292. return concat$9(["| ", join$7(" | ", columnMaxWidths.map(function (width, index) {
  15293. switch (node.align[index]) {
  15294. case "left":
  15295. return ":" + "-".repeat(width - 1);
  15296. case "right":
  15297. return "-".repeat(width - 1) + ":";
  15298. case "center":
  15299. return ":" + "-".repeat(width - 2) + ":";
  15300. default:
  15301. return "-".repeat(width);
  15302. }
  15303. })), " |"]);
  15304. }
  15305. function printRow(rowContents) {
  15306. return concat$9(["| ", join$7(" | ", rowContents.map(function (rowContent, columnIndex) {
  15307. switch (node.align[columnIndex]) {
  15308. case "right":
  15309. return alignRight(rowContent, columnMaxWidths[columnIndex]);
  15310. case "center":
  15311. return alignCenter(rowContent, columnMaxWidths[columnIndex]);
  15312. default:
  15313. return alignLeft(rowContent, columnMaxWidths[columnIndex]);
  15314. }
  15315. })), " |"]);
  15316. }
  15317. function alignLeft(text, width) {
  15318. return concat$9([text, " ".repeat(width - util.getStringWidth(text))]);
  15319. }
  15320. function alignRight(text, width) {
  15321. return concat$9([" ".repeat(width - util.getStringWidth(text)), text]);
  15322. }
  15323. function alignCenter(text, width) {
  15324. var spaces = width - util.getStringWidth(text);
  15325. var left = Math.floor(spaces / 2);
  15326. var right = spaces - left;
  15327. return concat$9([" ".repeat(left), text, " ".repeat(right)]);
  15328. }
  15329. }
  15330. function printRoot(path, options, print) {
  15331. /** @typedef {{ index: number, offset: number }} IgnorePosition */
  15332. /** @type {Array<{start: IgnorePosition, end: IgnorePosition}>} */
  15333. var ignoreRanges = [];
  15334. /** @type {IgnorePosition | null} */
  15335. var ignoreStart = null;
  15336. var children = path.getValue().children;
  15337. children.forEach(function (childNode, index) {
  15338. switch (isPrettierIgnore(childNode)) {
  15339. case "start":
  15340. if (ignoreStart === null) {
  15341. ignoreStart = {
  15342. index: index,
  15343. offset: childNode.position.end.offset
  15344. };
  15345. }
  15346. break;
  15347. case "end":
  15348. if (ignoreStart !== null) {
  15349. ignoreRanges.push({
  15350. start: ignoreStart,
  15351. end: {
  15352. index: index,
  15353. offset: childNode.position.start.offset
  15354. }
  15355. });
  15356. ignoreStart = null;
  15357. }
  15358. break;
  15359. default:
  15360. // do nothing
  15361. break;
  15362. }
  15363. });
  15364. return printChildren(path, options, print, {
  15365. processor: function processor(childPath, index) {
  15366. if (ignoreRanges.length !== 0) {
  15367. var ignoreRange = ignoreRanges[0];
  15368. if (index === ignoreRange.start.index) {
  15369. return concat$9([children[ignoreRange.start.index].value, options.originalText.slice(ignoreRange.start.offset, ignoreRange.end.offset), children[ignoreRange.end.index].value]);
  15370. }
  15371. if (ignoreRange.start.index < index && index < ignoreRange.end.index) {
  15372. return false;
  15373. }
  15374. if (index === ignoreRange.end.index) {
  15375. ignoreRanges.shift();
  15376. return false;
  15377. }
  15378. }
  15379. return childPath.call(print);
  15380. }
  15381. });
  15382. }
  15383. function printChildren(path, options, print, events) {
  15384. events = events || {};
  15385. var postprocessor = events.postprocessor || concat$9;
  15386. var processor = events.processor || function (childPath) {
  15387. return childPath.call(print);
  15388. };
  15389. var node = path.getValue();
  15390. var parts = [];
  15391. var lastChildNode;
  15392. path.map(function (childPath, index) {
  15393. var childNode = childPath.getValue();
  15394. var result = processor(childPath, index);
  15395. if (result !== false) {
  15396. var data = {
  15397. parts: parts,
  15398. prevNode: lastChildNode,
  15399. parentNode: node,
  15400. options: options
  15401. };
  15402. if (!shouldNotPrePrintHardline(childNode, data)) {
  15403. parts.push(hardline$8);
  15404. if (shouldPrePrintDoubleHardline(childNode, data) || shouldPrePrintTripleHardline(childNode, data)) {
  15405. parts.push(hardline$8);
  15406. }
  15407. if (shouldPrePrintTripleHardline(childNode, data)) {
  15408. parts.push(hardline$8);
  15409. }
  15410. }
  15411. parts.push(result);
  15412. lastChildNode = childNode;
  15413. }
  15414. }, "children");
  15415. return postprocessor(parts);
  15416. }
  15417. /** @return {false | 'next' | 'start' | 'end'} */
  15418. function isPrettierIgnore(node) {
  15419. if (node.type !== "html") {
  15420. return false;
  15421. }
  15422. var match = node.value.match(/^<!--\s*prettier-ignore(?:-(start|end))?\s*-->$/);
  15423. return match === null ? false : match[1] ? match[1] : "next";
  15424. }
  15425. function shouldNotPrePrintHardline(node, data) {
  15426. var isFirstNode = data.parts.length === 0;
  15427. var isInlineNode = INLINE_NODE_TYPES.indexOf(node.type) !== -1;
  15428. var isInlineHTML = node.type === "html" && INLINE_NODE_WRAPPER_TYPES.indexOf(data.parentNode.type) !== -1;
  15429. return isFirstNode || isInlineNode || isInlineHTML;
  15430. }
  15431. function shouldPrePrintDoubleHardline(node, data) {
  15432. var isSequence = (data.prevNode && data.prevNode.type) === node.type;
  15433. var isSiblingNode = isSequence && SIBLING_NODE_TYPES.indexOf(node.type) !== -1;
  15434. var isInTightListItem = data.parentNode.type === "listItem" && !data.parentNode.loose;
  15435. var isPrevNodeLooseListItem = data.prevNode && data.prevNode.type === "listItem" && data.prevNode.loose;
  15436. var isPrevNodePrettierIgnore = isPrettierIgnore(data.prevNode) === "next";
  15437. var isBlockHtmlWithoutBlankLineBetweenPrevHtml = node.type === "html" && data.prevNode && data.prevNode.type === "html" && data.prevNode.position.end.line + 1 === node.position.start.line;
  15438. return isPrevNodeLooseListItem || !(isSiblingNode || isInTightListItem || isPrevNodePrettierIgnore || isBlockHtmlWithoutBlankLineBetweenPrevHtml);
  15439. }
  15440. function shouldPrePrintTripleHardline(node, data) {
  15441. var isPrevNodeList = data.prevNode && data.prevNode.type === "list";
  15442. var isIndentedCode = node.type === "code" && /\s/.test(data.options.originalText[node.position.start.offset]);
  15443. return isPrevNodeList && isIndentedCode;
  15444. }
  15445. function shouldRemainTheSameContent(path) {
  15446. var ancestorNode = getAncestorNode$2(path, ["linkReference", "imageReference"]);
  15447. return ancestorNode && (ancestorNode.type !== "linkReference" || ancestorNode.referenceType !== "full");
  15448. }
  15449. function normalizeDoc(doc$$2) {
  15450. return mapDoc$3(doc$$2, function (currentDoc) {
  15451. if (!currentDoc.parts) {
  15452. return currentDoc;
  15453. }
  15454. if (currentDoc.type === "concat" && currentDoc.parts.length === 1) {
  15455. return currentDoc.parts[0];
  15456. }
  15457. var parts = [];
  15458. currentDoc.parts.forEach(function (part) {
  15459. if (part.type === "concat") {
  15460. parts.push.apply(parts, part.parts);
  15461. } else if (part !== "") {
  15462. parts.push(part);
  15463. }
  15464. });
  15465. return Object.assign({}, currentDoc, {
  15466. parts: normalizeParts(parts)
  15467. });
  15468. });
  15469. }
  15470. function printUrl(url, dangerousCharOrChars) {
  15471. var dangerousChars = [" "].concat(dangerousCharOrChars || []);
  15472. return new RegExp(dangerousChars.map(function (x) {
  15473. return "\\".concat(x);
  15474. }).join("|")).test(url) ? "<".concat(url, ">") : url;
  15475. }
  15476. function printTitle(title, options, printSpace) {
  15477. if (printSpace == null) {
  15478. printSpace = true;
  15479. }
  15480. if (!title) {
  15481. return "";
  15482. }
  15483. if (printSpace) {
  15484. return " " + printTitle(title, options, false);
  15485. }
  15486. if (title.includes('"') && title.includes("'") && !title.includes(")")) {
  15487. return "(".concat(title, ")"); // avoid escaped quotes
  15488. } // faster than using RegExps: https://jsperf.com/performance-of-match-vs-split
  15489. var singleCount = title.split("'").length - 1;
  15490. var doubleCount = title.split('"').length - 1;
  15491. var quote = singleCount > doubleCount ? '"' : doubleCount > singleCount ? "'" : options.singleQuote ? "'" : '"';
  15492. title = title.replace(new RegExp("(".concat(quote, ")"), "g"), "\\$1");
  15493. return "".concat(quote).concat(title).concat(quote);
  15494. }
  15495. function normalizeParts(parts) {
  15496. return parts.reduce(function (current, part) {
  15497. var lastPart = util.getLast(current);
  15498. if (typeof lastPart === "string" && typeof part === "string") {
  15499. current.splice(-1, 1, lastPart + part);
  15500. } else {
  15501. current.push(part);
  15502. }
  15503. return current;
  15504. }, []);
  15505. }
  15506. function clamp(value, min, max) {
  15507. return value < min ? min : value > max ? max : value;
  15508. }
  15509. function clean$6(ast, newObj, parent) {
  15510. delete newObj.position; // for codeblock
  15511. if (ast.type === "code") {
  15512. delete newObj.value;
  15513. } // for whitespace: "\n" and " " are considered the same
  15514. if (ast.type === "whitespace" && ast.value === "\n") {
  15515. newObj.value = " ";
  15516. } // for insert pragma
  15517. if (parent && parent.type === "root" && parent.children.length > 0 && (parent.children[0] === ast || parent.children[0].type === "front-matter" && parent.children[1] === ast) && ast.type === "html" && pragma$2.startWithPragma(ast.value)) {
  15518. return null;
  15519. }
  15520. }
  15521. function hasPrettierIgnore$1(path) {
  15522. var index = +path.getName();
  15523. if (index === 0) {
  15524. return false;
  15525. }
  15526. var prevNode = path.getParentNode().children[index - 1];
  15527. return isPrettierIgnore(prevNode) === "next";
  15528. }
  15529. var printerMarkdown = {
  15530. print: genericPrint$5,
  15531. embed: embed_1$2,
  15532. massageAstNode: clean$6,
  15533. hasPrettierIgnore: hasPrettierIgnore$1,
  15534. insertPragma: pragma$2.insertPragma
  15535. };
  15536. var CATEGORY_MARKDOWN = "Markdown"; // format based on https://github.com/prettier/prettier/blob/master/src/main/core-options.js
  15537. var options$12 = {
  15538. proseWrap: {
  15539. since: "1.8.2",
  15540. category: CATEGORY_MARKDOWN,
  15541. type: "choice",
  15542. default: [{
  15543. since: "1.8.2",
  15544. value: true
  15545. }, {
  15546. since: "1.9.0",
  15547. value: "preserve"
  15548. }],
  15549. description: "How to wrap prose. (markdown)",
  15550. choices: [{
  15551. since: "1.9.0",
  15552. value: "always",
  15553. description: "Wrap prose if it exceeds the print width."
  15554. }, {
  15555. since: "1.9.0",
  15556. value: "never",
  15557. description: "Do not wrap prose."
  15558. }, {
  15559. since: "1.9.0",
  15560. value: "preserve",
  15561. description: "Wrap prose as-is."
  15562. }, {
  15563. value: false,
  15564. deprecated: "1.9.0",
  15565. redirect: "never"
  15566. }, {
  15567. value: true,
  15568. deprecated: "1.9.0",
  15569. redirect: "always"
  15570. }]
  15571. },
  15572. singleQuote: commonOptions.singleQuote
  15573. };
  15574. // https://github.com/github/linguist/blob/master/lib/linguist/languages.yml
  15575. var languages$3 = [{
  15576. name: "Markdown",
  15577. since: "1.8.0",
  15578. parsers: ["remark"],
  15579. aliases: ["pandoc"],
  15580. aceMode: "markdown",
  15581. codemirrorMode: "gfm",
  15582. codemirrorMimeType: "text/x-gfm",
  15583. wrap: true,
  15584. extensions: [".md", ".markdown", ".mdown", ".mdwn", ".mkd", ".mkdn", ".mkdown", ".ron", ".workbook"],
  15585. filenames: ["README"],
  15586. tmScope: "source.gfm",
  15587. linguistLanguageId: 222,
  15588. vscodeLanguageIds: ["markdown"]
  15589. }];
  15590. var printers$3 = {
  15591. mdast: printerMarkdown
  15592. };
  15593. var languageMarkdown = {
  15594. languages: languages$3,
  15595. options: options$12,
  15596. printers: printers$3
  15597. };
  15598. var _require$$0$builders$7 = doc.builders;
  15599. var concat$12 = _require$$0$builders$7.concat;
  15600. var hardline$11 = _require$$0$builders$7.hardline;
  15601. function embed$4(path, print, textToDoc, options) {
  15602. var node = path.getValue();
  15603. var parent = path.getParentNode();
  15604. if (!parent || parent.tag !== "root" || node.unary) {
  15605. return null;
  15606. }
  15607. var parser;
  15608. if (node.tag === "style") {
  15609. var langAttr = node.attrs.find(function (attr) {
  15610. return attr.name === "lang";
  15611. });
  15612. if (!langAttr || langAttr.value === "postcss") {
  15613. parser = "css";
  15614. } else if (langAttr.value === "scss") {
  15615. parser = "scss";
  15616. } else if (langAttr.value === "less") {
  15617. parser = "less";
  15618. }
  15619. }
  15620. if (node.tag === "script") {
  15621. var _langAttr = node.attrs.find(function (attr) {
  15622. return attr.name === "lang";
  15623. });
  15624. if (!_langAttr) {
  15625. parser = "babylon";
  15626. } else if (_langAttr.value === "ts" || _langAttr.value === "tsx") {
  15627. parser = "typescript";
  15628. }
  15629. }
  15630. if (!parser) {
  15631. return null;
  15632. }
  15633. return concat$12([options.originalText.slice(node.start, node.contentStart), hardline$11, textToDoc(options.originalText.slice(node.contentStart, node.contentEnd), {
  15634. parser: parser
  15635. }), options.originalText.slice(node.contentEnd, node.end)]);
  15636. }
  15637. var embed_1$4 = embed$4;
  15638. var _require$$0$builders$6 = doc.builders;
  15639. var concat$11 = _require$$0$builders$6.concat;
  15640. var hardline$10 = _require$$0$builders$6.hardline;
  15641. function genericPrint$6(path, options, print) {
  15642. var n = path.getValue();
  15643. var res = [];
  15644. var index = n.start;
  15645. path.each(function (childPath) {
  15646. var child = childPath.getValue();
  15647. res.push(options.originalText.slice(index, child.start));
  15648. res.push(childPath.call(print));
  15649. index = child.end;
  15650. }, "children"); // If there are no children, we just print the node from start to end.
  15651. // Otherwise, index should point to the end of the last child, and we
  15652. // need to print the closing tag.
  15653. res.push(options.originalText.slice(index, n.end)); // Only force a trailing newline if there were any contents.
  15654. if (n.tag === "root" && n.children.length) {
  15655. res.push(hardline$10);
  15656. }
  15657. return concat$11(res);
  15658. }
  15659. var clean$7 = function clean(ast, newObj) {
  15660. delete newObj.start;
  15661. delete newObj.end;
  15662. delete newObj.contentStart;
  15663. delete newObj.contentEnd;
  15664. };
  15665. var printerVue = {
  15666. print: genericPrint$6,
  15667. embed: embed_1$4,
  15668. massageAstNode: clean$7
  15669. };
  15670. // https://github.com/github/linguist/blob/master/lib/linguist/languages.yml
  15671. var languages$4 = [{
  15672. name: "Vue",
  15673. since: "1.10.0",
  15674. parsers: ["vue"],
  15675. group: "HTML",
  15676. tmScope: "text.html.vue",
  15677. aceMode: "html",
  15678. codemirrorMode: "htmlmixed",
  15679. codemirrorMimeType: "text/html",
  15680. extensions: [".vue"],
  15681. linguistLanguageId: 146,
  15682. vscodeLanguageIds: ["vue"]
  15683. }];
  15684. var printers$4 = {
  15685. vue: printerVue
  15686. };
  15687. var languageVue = {
  15688. languages: languages$4,
  15689. printers: printers$4
  15690. };
  15691. var version = require$$0.version;
  15692. var getSupportInfo = support.getSupportInfo;
  15693. var internalPlugins = [languageJs, languageCss, languageGraphql, languageMarkdown, languageVue];
  15694. var isArray = Array.isArray || function (arr) {
  15695. return Object.prototype.toString.call(arr) === "[object Array]";
  15696. }; // Luckily `opts` is always the 2nd argument
  15697. function withPlugins(fn) {
  15698. return function () {
  15699. var args = Array.from(arguments);
  15700. var plugins = args[1] && args[1].plugins || [];
  15701. if (!isArray(plugins)) {
  15702. plugins = Object.values(plugins);
  15703. }
  15704. args[1] = Object.assign({}, args[1], {
  15705. plugins: internalPlugins.concat(plugins)
  15706. });
  15707. return fn.apply(null, args);
  15708. };
  15709. }
  15710. var formatWithCursor = withPlugins(core.formatWithCursor);
  15711. var standalone = {
  15712. formatWithCursor: formatWithCursor,
  15713. format: function format(text, opts) {
  15714. return formatWithCursor(text, opts).formatted;
  15715. },
  15716. check: function check(text, opts) {
  15717. var formatted = formatWithCursor(text, opts).formatted;
  15718. return formatted === text;
  15719. },
  15720. doc: doc,
  15721. getSupportInfo: withPlugins(getSupportInfo),
  15722. version: version,
  15723. util: utilShared,
  15724. __debug: {
  15725. parse: withPlugins(core.parse),
  15726. formatAST: withPlugins(core.formatAST),
  15727. formatDoc: withPlugins(core.formatDoc),
  15728. printToDoc: withPlugins(core.printToDoc),
  15729. printDocToString: withPlugins(core.printDocToString)
  15730. }
  15731. };
  15732. return standalone;
  15733. })));