standalone.js 966 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733
  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.16.3";
  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. "@angular/compiler": "6.1.10",
  22. "@babel/code-frame": "7.0.0-beta.46",
  23. "@babel/parser": "7.2.0",
  24. "@glimmer/syntax": "0.30.3",
  25. "@iarna/toml": "2.0.0",
  26. "angular-estree-parser": "1.1.5",
  27. "angular-html-parser": "1.2.0",
  28. "camelcase": "4.1.0",
  29. "chalk": "2.1.0",
  30. "cjk-regex": "2.0.0",
  31. "cosmiconfig": "5.0.7",
  32. "dashify": "0.2.2",
  33. "dedent": "0.7.0",
  34. "diff": "3.2.0",
  35. "editorconfig": "0.15.2",
  36. "editorconfig-to-prettier": "0.1.1",
  37. "escape-string-regexp": "1.0.5",
  38. "esutils": "2.0.2",
  39. "find-parent-dir": "0.3.0",
  40. "find-project-root": "1.1.1",
  41. "flow-parser": "0.84.0",
  42. "get-stream": "3.0.0",
  43. "globby": "6.1.0",
  44. "graphql": "0.13.2",
  45. "html-element-attributes": "2.0.0",
  46. "html-styles": "1.0.0",
  47. "html-tag-names": "1.1.2",
  48. "ignore": "3.3.7",
  49. "is-ci": "2.0.0",
  50. "jest-docblock": "23.2.0",
  51. "json-stable-stringify": "1.0.1",
  52. "leven": "2.1.0",
  53. "lines-and-columns": "1.1.6",
  54. "linguist-languages": "6.2.1-dev.20180706",
  55. "lodash.uniqby": "4.7.0",
  56. "mem": "1.1.0",
  57. "minimatch": "3.0.4",
  58. "minimist": "1.2.0",
  59. "n-readlines": "1.0.0",
  60. "normalize-path": "3.0.0",
  61. "parse-srcset": "ikatyang/parse-srcset#54eb9c1cb21db5c62b4d0e275d7249516df6f0ee",
  62. "postcss-less": "1.1.5",
  63. "postcss-media-query-parser": "0.2.3",
  64. "postcss-scss": "2.0.0",
  65. "postcss-selector-parser": "2.2.3",
  66. "postcss-values-parser": "1.5.0",
  67. "regexp-util": "1.2.2",
  68. "remark-math": "1.0.4",
  69. "remark-parse": "5.0.0",
  70. "resolve": "1.5.0",
  71. "semver": "5.4.1",
  72. "string-width": "3.0.0",
  73. "typescript": "3.2.2",
  74. "typescript-estree": "18.0.0",
  75. "unicode-regex": "2.0.0",
  76. "unified": "6.1.6",
  77. "vnopts": "1.0.2",
  78. "yaml": "1.0.2",
  79. "yaml-unist-parser": "1.0.0"
  80. };
  81. var devDependencies = {
  82. "@babel/cli": "7.2.0",
  83. "@babel/core": "7.2.0",
  84. "@babel/preset-env": "7.2.0",
  85. "babel-loader": "8.0.4",
  86. "benchmark": "2.1.4",
  87. "builtin-modules": "2.0.0",
  88. "codecov": "codecov/codecov-node#e427d900309adb50746a39a50aa7d80071a5ddd0",
  89. "cross-env": "5.0.5",
  90. "eslint": "4.18.2",
  91. "eslint-config-prettier": "2.9.0",
  92. "eslint-friendly-formatter": "3.0.0",
  93. "eslint-plugin-import": "2.9.0",
  94. "eslint-plugin-prettier": "2.6.0",
  95. "eslint-plugin-react": "7.7.0",
  96. "execa": "0.10.0",
  97. "jest": "23.3.0",
  98. "jest-junit": "5.0.0",
  99. "jest-snapshot-serializer-ansi": "1.0.0",
  100. "jest-snapshot-serializer-raw": "1.1.0",
  101. "jest-watch-typeahead": "0.1.0",
  102. "mkdirp": "0.5.1",
  103. "prettier": "1.16.2",
  104. "prettylint": "1.0.0",
  105. "rimraf": "2.6.2",
  106. "rollup": "0.47.6",
  107. "rollup-plugin-alias": "1.4.0",
  108. "rollup-plugin-babel": "4.0.0-beta.4",
  109. "rollup-plugin-commonjs": "8.2.6",
  110. "rollup-plugin-json": "2.1.1",
  111. "rollup-plugin-node-builtins": "2.0.0",
  112. "rollup-plugin-node-globals": "1.1.0",
  113. "rollup-plugin-node-resolve": "2.0.0",
  114. "rollup-plugin-replace": "1.2.1",
  115. "rollup-plugin-uglify": "3.0.0",
  116. "shelljs": "0.8.1",
  117. "snapshot-diff": "0.4.0",
  118. "strip-ansi": "4.0.0",
  119. "tempy": "0.2.1",
  120. "webpack": "3.12.0"
  121. };
  122. var resolutions = {
  123. "@babel/code-frame": "7.0.0-beta.46"
  124. };
  125. var scripts = {
  126. "prepublishOnly": "echo \"Error: must publish from dist/\" && exit 1",
  127. "prepare-release": "yarn && yarn build && yarn test:dist",
  128. "test": "jest",
  129. "test:dist": "node ./scripts/test-dist.js",
  130. "test-integration": "jest tests_integration",
  131. "perf-repeat": "yarn && yarn build && cross-env NODE_ENV=production node ./dist/bin-prettier.js --debug-repeat ${PERF_REPEAT:-1000} --loglevel debug ${PERF_FILE:-./index.js} > /dev/null",
  132. "perf-repeat-inspect": "yarn && yarn build && cross-env NODE_ENV=production node --inspect-brk ./dist/bin-prettier.js --debug-repeat ${PERF_REPEAT:-1000} --loglevel debug ${PERF_FILE:-./index.js} > /dev/null",
  133. "perf-benchmark": "yarn && yarn build && cross-env NODE_ENV=production node ./dist/bin-prettier.js --debug-benchmark --loglevel debug ${PERF_FILE:-./index.js} > /dev/null",
  134. "lint": "cross-env EFF_NO_LINK_RULES=true eslint . --format node_modules/eslint-friendly-formatter",
  135. "lint-docs": "prettylint {.,docs,website,website/blog}/*.md",
  136. "lint-dist": "eslint --no-eslintrc --no-ignore --env=browser \"dist/!(bin-prettier|index|third-party).js\"",
  137. "build": "node --max-old-space-size=2048 ./scripts/build/build.js",
  138. "build-docs": "node ./scripts/build-docs.js",
  139. "check-deps": "node ./scripts/check-deps.js"
  140. };
  141. var _package = {
  142. name: name,
  143. version: version$1,
  144. description: description,
  145. bin: bin,
  146. repository: repository,
  147. homepage: homepage,
  148. author: author,
  149. license: license,
  150. main: main,
  151. engines: engines,
  152. dependencies: dependencies,
  153. devDependencies: devDependencies,
  154. resolutions: resolutions,
  155. scripts: scripts
  156. };
  157. var _package$1 = Object.freeze({
  158. name: name,
  159. version: version$1,
  160. description: description,
  161. bin: bin,
  162. repository: repository,
  163. homepage: homepage,
  164. author: author,
  165. license: license,
  166. main: main,
  167. engines: engines,
  168. dependencies: dependencies,
  169. devDependencies: devDependencies,
  170. resolutions: resolutions,
  171. scripts: scripts,
  172. default: _package
  173. });
  174. var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
  175. function unwrapExports (x) {
  176. return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
  177. }
  178. function createCommonjsModule(fn, module) {
  179. return module = { exports: {} }, fn(module, module.exports), module.exports;
  180. }
  181. var base = createCommonjsModule(function (module, exports) {
  182. /*istanbul ignore start*/
  183. 'use strict';
  184. exports.__esModule = true;
  185. exports['default'] =
  186. /*istanbul ignore end*/
  187. Diff;
  188. function Diff() {}
  189. Diff.prototype = {
  190. /*istanbul ignore start*/
  191. /*istanbul ignore end*/
  192. diff: function diff(oldString, newString) {
  193. /*istanbul ignore start*/
  194. var
  195. /*istanbul ignore end*/
  196. options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];
  197. var callback = options.callback;
  198. if (typeof options === 'function') {
  199. callback = options;
  200. options = {};
  201. }
  202. this.options = options;
  203. var self = this;
  204. function done(value) {
  205. if (callback) {
  206. setTimeout(function () {
  207. callback(undefined, value);
  208. }, 0);
  209. return true;
  210. } else {
  211. return value;
  212. }
  213. } // Allow subclasses to massage the input prior to running
  214. oldString = this.castInput(oldString);
  215. newString = this.castInput(newString);
  216. oldString = this.removeEmpty(this.tokenize(oldString));
  217. newString = this.removeEmpty(this.tokenize(newString));
  218. var newLen = newString.length,
  219. oldLen = oldString.length;
  220. var editLength = 1;
  221. var maxEditLength = newLen + oldLen;
  222. var bestPath = [{
  223. newPos: -1,
  224. components: []
  225. }]; // Seed editLength = 0, i.e. the content starts with the same values
  226. var oldPos = this.extractCommon(bestPath[0], newString, oldString, 0);
  227. if (bestPath[0].newPos + 1 >= newLen && oldPos + 1 >= oldLen) {
  228. // Identity per the equality and tokenizer
  229. return done([{
  230. value: this.join(newString),
  231. count: newString.length
  232. }]);
  233. } // Main worker method. checks all permutations of a given edit length for acceptance.
  234. function execEditLength() {
  235. for (var diagonalPath = -1 * editLength; diagonalPath <= editLength; diagonalPath += 2) {
  236. var basePath =
  237. /*istanbul ignore start*/
  238. void 0;
  239. var addPath = bestPath[diagonalPath - 1],
  240. removePath = bestPath[diagonalPath + 1],
  241. _oldPos = (removePath ? removePath.newPos : 0) - diagonalPath;
  242. if (addPath) {
  243. // No one else is going to attempt to use this value, clear it
  244. bestPath[diagonalPath - 1] = undefined;
  245. }
  246. var canAdd = addPath && addPath.newPos + 1 < newLen,
  247. canRemove = removePath && 0 <= _oldPos && _oldPos < oldLen;
  248. if (!canAdd && !canRemove) {
  249. // If this path is a terminal then prune
  250. bestPath[diagonalPath] = undefined;
  251. continue;
  252. } // Select the diagonal that we want to branch from. We select the prior
  253. // path whose position in the new string is the farthest from the origin
  254. // and does not pass the bounds of the diff graph
  255. if (!canAdd || canRemove && addPath.newPos < removePath.newPos) {
  256. basePath = clonePath(removePath);
  257. self.pushComponent(basePath.components, undefined, true);
  258. } else {
  259. basePath = addPath; // No need to clone, we've pulled it from the list
  260. basePath.newPos++;
  261. self.pushComponent(basePath.components, true, undefined);
  262. }
  263. _oldPos = self.extractCommon(basePath, newString, oldString, diagonalPath); // If we have hit the end of both strings, then we are done
  264. if (basePath.newPos + 1 >= newLen && _oldPos + 1 >= oldLen) {
  265. return done(buildValues(self, basePath.components, newString, oldString, self.useLongestToken));
  266. } else {
  267. // Otherwise track this path as a potential candidate and continue.
  268. bestPath[diagonalPath] = basePath;
  269. }
  270. }
  271. editLength++;
  272. } // Performs the length of edit iteration. Is a bit fugly as this has to support the
  273. // sync and async mode which is never fun. Loops over execEditLength until a value
  274. // is produced.
  275. if (callback) {
  276. (function exec() {
  277. setTimeout(function () {
  278. // This should not happen, but we want to be safe.
  279. /* istanbul ignore next */
  280. if (editLength > maxEditLength) {
  281. return callback();
  282. }
  283. if (!execEditLength()) {
  284. exec();
  285. }
  286. }, 0);
  287. })();
  288. } else {
  289. while (editLength <= maxEditLength) {
  290. var ret = execEditLength();
  291. if (ret) {
  292. return ret;
  293. }
  294. }
  295. }
  296. },
  297. /*istanbul ignore start*/
  298. /*istanbul ignore end*/
  299. pushComponent: function pushComponent(components, added, removed) {
  300. var last = components[components.length - 1];
  301. if (last && last.added === added && last.removed === removed) {
  302. // We need to clone here as the component clone operation is just
  303. // as shallow array clone
  304. components[components.length - 1] = {
  305. count: last.count + 1,
  306. added: added,
  307. removed: removed
  308. };
  309. } else {
  310. components.push({
  311. count: 1,
  312. added: added,
  313. removed: removed
  314. });
  315. }
  316. },
  317. /*istanbul ignore start*/
  318. /*istanbul ignore end*/
  319. extractCommon: function extractCommon(basePath, newString, oldString, diagonalPath) {
  320. var newLen = newString.length,
  321. oldLen = oldString.length,
  322. newPos = basePath.newPos,
  323. oldPos = newPos - diagonalPath,
  324. commonCount = 0;
  325. while (newPos + 1 < newLen && oldPos + 1 < oldLen && this.equals(newString[newPos + 1], oldString[oldPos + 1])) {
  326. newPos++;
  327. oldPos++;
  328. commonCount++;
  329. }
  330. if (commonCount) {
  331. basePath.components.push({
  332. count: commonCount
  333. });
  334. }
  335. basePath.newPos = newPos;
  336. return oldPos;
  337. },
  338. /*istanbul ignore start*/
  339. /*istanbul ignore end*/
  340. equals: function equals(left, right) {
  341. return left === right;
  342. },
  343. /*istanbul ignore start*/
  344. /*istanbul ignore end*/
  345. removeEmpty: function removeEmpty(array) {
  346. var ret = [];
  347. for (var i = 0; i < array.length; i++) {
  348. if (array[i]) {
  349. ret.push(array[i]);
  350. }
  351. }
  352. return ret;
  353. },
  354. /*istanbul ignore start*/
  355. /*istanbul ignore end*/
  356. castInput: function castInput(value) {
  357. return value;
  358. },
  359. /*istanbul ignore start*/
  360. /*istanbul ignore end*/
  361. tokenize: function tokenize(value) {
  362. return value.split('');
  363. },
  364. /*istanbul ignore start*/
  365. /*istanbul ignore end*/
  366. join: function join(chars) {
  367. return chars.join('');
  368. }
  369. };
  370. function buildValues(diff, components, newString, oldString, useLongestToken) {
  371. var componentPos = 0,
  372. componentLen = components.length,
  373. newPos = 0,
  374. oldPos = 0;
  375. for (; componentPos < componentLen; componentPos++) {
  376. var component = components[componentPos];
  377. if (!component.removed) {
  378. if (!component.added && useLongestToken) {
  379. var value = newString.slice(newPos, newPos + component.count);
  380. value = value.map(function (value, i) {
  381. var oldValue = oldString[oldPos + i];
  382. return oldValue.length > value.length ? oldValue : value;
  383. });
  384. component.value = diff.join(value);
  385. } else {
  386. component.value = diff.join(newString.slice(newPos, newPos + component.count));
  387. }
  388. newPos += component.count; // Common case
  389. if (!component.added) {
  390. oldPos += component.count;
  391. }
  392. } else {
  393. component.value = diff.join(oldString.slice(oldPos, oldPos + component.count));
  394. oldPos += component.count; // Reverse add and remove so removes are output first to match common convention
  395. // The diffing algorithm is tied to add then remove output and this is the simplest
  396. // route to get the desired output with minimal overhead.
  397. if (componentPos && components[componentPos - 1].added) {
  398. var tmp = components[componentPos - 1];
  399. components[componentPos - 1] = components[componentPos];
  400. components[componentPos] = tmp;
  401. }
  402. }
  403. } // Special case handle for when one terminal is ignored. For this case we merge the
  404. // terminal into the prior string and drop the change.
  405. var lastComponent = components[componentLen - 1];
  406. if (componentLen > 1 && (lastComponent.added || lastComponent.removed) && diff.equals('', lastComponent.value)) {
  407. components[componentLen - 2].value += lastComponent.value;
  408. components.pop();
  409. }
  410. return components;
  411. }
  412. function clonePath(path) {
  413. return {
  414. newPos: path.newPos,
  415. components: path.components.slice(0)
  416. };
  417. }
  418. });
  419. unwrapExports(base);
  420. var character = createCommonjsModule(function (module, exports) {
  421. /*istanbul ignore start*/
  422. 'use strict';
  423. exports.__esModule = true;
  424. exports.characterDiff = undefined;
  425. exports.
  426. /*istanbul ignore end*/
  427. diffChars = diffChars;
  428. /*istanbul ignore start*/
  429. var _base2 = _interopRequireDefault(base);
  430. function _interopRequireDefault(obj) {
  431. return obj && obj.__esModule ? obj : {
  432. 'default': obj
  433. };
  434. }
  435. /*istanbul ignore end*/
  436. var characterDiff =
  437. /*istanbul ignore start*/
  438. exports.
  439. /*istanbul ignore end*/
  440. characterDiff = new
  441. /*istanbul ignore start*/
  442. _base2['default']();
  443. function diffChars(oldStr, newStr, callback) {
  444. return characterDiff.diff(oldStr, newStr, callback);
  445. }
  446. });
  447. unwrapExports(character);
  448. var params = createCommonjsModule(function (module, exports) {
  449. /*istanbul ignore start*/
  450. 'use strict';
  451. exports.__esModule = true;
  452. exports.
  453. /*istanbul ignore end*/
  454. generateOptions = generateOptions;
  455. function generateOptions(options, defaults) {
  456. if (typeof options === 'function') {
  457. defaults.callback = options;
  458. } else if (options) {
  459. for (var name in options) {
  460. /* istanbul ignore else */
  461. if (options.hasOwnProperty(name)) {
  462. defaults[name] = options[name];
  463. }
  464. }
  465. }
  466. return defaults;
  467. }
  468. });
  469. unwrapExports(params);
  470. var word = createCommonjsModule(function (module, exports) {
  471. /*istanbul ignore start*/
  472. 'use strict';
  473. exports.__esModule = true;
  474. exports.wordDiff = undefined;
  475. exports.
  476. /*istanbul ignore end*/
  477. diffWords = diffWords;
  478. /*istanbul ignore start*/
  479. exports.
  480. /*istanbul ignore end*/
  481. diffWordsWithSpace = diffWordsWithSpace;
  482. /*istanbul ignore start*/
  483. var _base2 = _interopRequireDefault(base);
  484. /*istanbul ignore end*/
  485. /*istanbul ignore start*/
  486. function _interopRequireDefault(obj) {
  487. return obj && obj.__esModule ? obj : {
  488. 'default': obj
  489. };
  490. }
  491. /*istanbul ignore end*/
  492. // Based on https://en.wikipedia.org/wiki/Latin_script_in_Unicode
  493. //
  494. // Ranges and exceptions:
  495. // Latin-1 Supplement, 0080–00FF
  496. // - U+00D7 × Multiplication sign
  497. // - U+00F7 ÷ Division sign
  498. // Latin Extended-A, 0100–017F
  499. // Latin Extended-B, 0180–024F
  500. // IPA Extensions, 0250–02AF
  501. // Spacing Modifier Letters, 02B0–02FF
  502. // - U+02C7 ˇ &#711; Caron
  503. // - U+02D8 ˘ &#728; Breve
  504. // - U+02D9 ˙ &#729; Dot Above
  505. // - U+02DA ˚ &#730; Ring Above
  506. // - U+02DB ˛ &#731; Ogonek
  507. // - U+02DC ˜ &#732; Small Tilde
  508. // - U+02DD ˝ &#733; Double Acute Accent
  509. // Latin Extended Additional, 1E00–1EFF
  510. var extendedWordChars = /^[A-Za-z\xC0-\u02C6\u02C8-\u02D7\u02DE-\u02FF\u1E00-\u1EFF]+$/;
  511. var reWhitespace = /\S/;
  512. var wordDiff =
  513. /*istanbul ignore start*/
  514. exports.
  515. /*istanbul ignore end*/
  516. wordDiff = new
  517. /*istanbul ignore start*/
  518. _base2['default']();
  519. wordDiff.equals = function (left, right) {
  520. return left === right || this.options.ignoreWhitespace && !reWhitespace.test(left) && !reWhitespace.test(right);
  521. };
  522. wordDiff.tokenize = function (value) {
  523. 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.
  524. for (var i = 0; i < tokens.length - 1; i++) {
  525. // If we have an empty string in the next field and we have only word chars before and after, merge
  526. if (!tokens[i + 1] && tokens[i + 2] && extendedWordChars.test(tokens[i]) && extendedWordChars.test(tokens[i + 2])) {
  527. tokens[i] += tokens[i + 2];
  528. tokens.splice(i + 1, 2);
  529. i--;
  530. }
  531. }
  532. return tokens;
  533. };
  534. function diffWords(oldStr, newStr, callback) {
  535. var options =
  536. /*istanbul ignore start*/
  537. (0, params.generateOptions
  538. /*istanbul ignore end*/
  539. )(callback, {
  540. ignoreWhitespace: true
  541. });
  542. return wordDiff.diff(oldStr, newStr, options);
  543. }
  544. function diffWordsWithSpace(oldStr, newStr, callback) {
  545. return wordDiff.diff(oldStr, newStr, callback);
  546. }
  547. });
  548. unwrapExports(word);
  549. var line = createCommonjsModule(function (module, exports) {
  550. /*istanbul ignore start*/
  551. 'use strict';
  552. exports.__esModule = true;
  553. exports.lineDiff = undefined;
  554. exports.
  555. /*istanbul ignore end*/
  556. diffLines = diffLines;
  557. /*istanbul ignore start*/
  558. exports.
  559. /*istanbul ignore end*/
  560. diffTrimmedLines = diffTrimmedLines;
  561. /*istanbul ignore start*/
  562. var _base2 = _interopRequireDefault(base);
  563. /*istanbul ignore end*/
  564. /*istanbul ignore start*/
  565. function _interopRequireDefault(obj) {
  566. return obj && obj.__esModule ? obj : {
  567. 'default': obj
  568. };
  569. }
  570. /*istanbul ignore end*/
  571. var lineDiff =
  572. /*istanbul ignore start*/
  573. exports.
  574. /*istanbul ignore end*/
  575. lineDiff = new
  576. /*istanbul ignore start*/
  577. _base2['default']();
  578. lineDiff.tokenize = function (value) {
  579. var retLines = [],
  580. linesAndNewlines = value.split(/(\n|\r\n)/); // Ignore the final empty token that occurs if the string ends with a new line
  581. if (!linesAndNewlines[linesAndNewlines.length - 1]) {
  582. linesAndNewlines.pop();
  583. } // Merge the content and line separators into single tokens
  584. for (var i = 0; i < linesAndNewlines.length; i++) {
  585. var line = linesAndNewlines[i];
  586. if (i % 2 && !this.options.newlineIsToken) {
  587. retLines[retLines.length - 1] += line;
  588. } else {
  589. if (this.options.ignoreWhitespace) {
  590. line = line.trim();
  591. }
  592. retLines.push(line);
  593. }
  594. }
  595. return retLines;
  596. };
  597. function diffLines(oldStr, newStr, callback) {
  598. return lineDiff.diff(oldStr, newStr, callback);
  599. }
  600. function diffTrimmedLines(oldStr, newStr, callback) {
  601. var options =
  602. /*istanbul ignore start*/
  603. (0, params.generateOptions
  604. /*istanbul ignore end*/
  605. )(callback, {
  606. ignoreWhitespace: true
  607. });
  608. return lineDiff.diff(oldStr, newStr, options);
  609. }
  610. });
  611. unwrapExports(line);
  612. var sentence = createCommonjsModule(function (module, exports) {
  613. /*istanbul ignore start*/
  614. 'use strict';
  615. exports.__esModule = true;
  616. exports.sentenceDiff = undefined;
  617. exports.
  618. /*istanbul ignore end*/
  619. diffSentences = diffSentences;
  620. /*istanbul ignore start*/
  621. var _base2 = _interopRequireDefault(base);
  622. function _interopRequireDefault(obj) {
  623. return obj && obj.__esModule ? obj : {
  624. 'default': obj
  625. };
  626. }
  627. /*istanbul ignore end*/
  628. var sentenceDiff =
  629. /*istanbul ignore start*/
  630. exports.
  631. /*istanbul ignore end*/
  632. sentenceDiff = new
  633. /*istanbul ignore start*/
  634. _base2['default']();
  635. sentenceDiff.tokenize = function (value) {
  636. return value.split(/(\S.+?[.!?])(?=\s+|$)/);
  637. };
  638. function diffSentences(oldStr, newStr, callback) {
  639. return sentenceDiff.diff(oldStr, newStr, callback);
  640. }
  641. });
  642. unwrapExports(sentence);
  643. var css = createCommonjsModule(function (module, exports) {
  644. /*istanbul ignore start*/
  645. 'use strict';
  646. exports.__esModule = true;
  647. exports.cssDiff = undefined;
  648. exports.
  649. /*istanbul ignore end*/
  650. diffCss = diffCss;
  651. /*istanbul ignore start*/
  652. var _base2 = _interopRequireDefault(base);
  653. function _interopRequireDefault(obj) {
  654. return obj && obj.__esModule ? obj : {
  655. 'default': obj
  656. };
  657. }
  658. /*istanbul ignore end*/
  659. var cssDiff =
  660. /*istanbul ignore start*/
  661. exports.
  662. /*istanbul ignore end*/
  663. cssDiff = new
  664. /*istanbul ignore start*/
  665. _base2['default']();
  666. cssDiff.tokenize = function (value) {
  667. return value.split(/([{}:;,]|\s+)/);
  668. };
  669. function diffCss(oldStr, newStr, callback) {
  670. return cssDiff.diff(oldStr, newStr, callback);
  671. }
  672. });
  673. unwrapExports(css);
  674. function _typeof(obj) {
  675. if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
  676. _typeof = function (obj) {
  677. return typeof obj;
  678. };
  679. } else {
  680. _typeof = function (obj) {
  681. return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
  682. };
  683. }
  684. return _typeof(obj);
  685. }
  686. function _classCallCheck(instance, Constructor) {
  687. if (!(instance instanceof Constructor)) {
  688. throw new TypeError("Cannot call a class as a function");
  689. }
  690. }
  691. function _defineProperties(target, props) {
  692. for (var i = 0; i < props.length; i++) {
  693. var descriptor = props[i];
  694. descriptor.enumerable = descriptor.enumerable || false;
  695. descriptor.configurable = true;
  696. if ("value" in descriptor) descriptor.writable = true;
  697. Object.defineProperty(target, descriptor.key, descriptor);
  698. }
  699. }
  700. function _createClass(Constructor, protoProps, staticProps) {
  701. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  702. if (staticProps) _defineProperties(Constructor, staticProps);
  703. return Constructor;
  704. }
  705. function _defineProperty(obj, key, value) {
  706. if (key in obj) {
  707. Object.defineProperty(obj, key, {
  708. value: value,
  709. enumerable: true,
  710. configurable: true,
  711. writable: true
  712. });
  713. } else {
  714. obj[key] = value;
  715. }
  716. return obj;
  717. }
  718. function _inherits(subClass, superClass) {
  719. if (typeof superClass !== "function" && superClass !== null) {
  720. throw new TypeError("Super expression must either be null or a function");
  721. }
  722. subClass.prototype = Object.create(superClass && superClass.prototype, {
  723. constructor: {
  724. value: subClass,
  725. writable: true,
  726. configurable: true
  727. }
  728. });
  729. if (superClass) _setPrototypeOf(subClass, superClass);
  730. }
  731. function _getPrototypeOf(o) {
  732. _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
  733. return o.__proto__ || Object.getPrototypeOf(o);
  734. };
  735. return _getPrototypeOf(o);
  736. }
  737. function _setPrototypeOf(o, p) {
  738. _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
  739. o.__proto__ = p;
  740. return o;
  741. };
  742. return _setPrototypeOf(o, p);
  743. }
  744. function isNativeReflectConstruct() {
  745. if (typeof Reflect === "undefined" || !Reflect.construct) return false;
  746. if (Reflect.construct.sham) return false;
  747. if (typeof Proxy === "function") return true;
  748. try {
  749. Date.prototype.toString.call(Reflect.construct(Date, [], function () {}));
  750. return true;
  751. } catch (e) {
  752. return false;
  753. }
  754. }
  755. function _construct(Parent, args, Class) {
  756. if (isNativeReflectConstruct()) {
  757. _construct = Reflect.construct;
  758. } else {
  759. _construct = function _construct(Parent, args, Class) {
  760. var a = [null];
  761. a.push.apply(a, args);
  762. var Constructor = Function.bind.apply(Parent, a);
  763. var instance = new Constructor();
  764. if (Class) _setPrototypeOf(instance, Class.prototype);
  765. return instance;
  766. };
  767. }
  768. return _construct.apply(null, arguments);
  769. }
  770. function _isNativeFunction(fn) {
  771. return Function.toString.call(fn).indexOf("[native code]") !== -1;
  772. }
  773. function _wrapNativeSuper(Class) {
  774. var _cache = typeof Map === "function" ? new Map() : undefined;
  775. _wrapNativeSuper = function _wrapNativeSuper(Class) {
  776. if (Class === null || !_isNativeFunction(Class)) return Class;
  777. if (typeof Class !== "function") {
  778. throw new TypeError("Super expression must either be null or a function");
  779. }
  780. if (typeof _cache !== "undefined") {
  781. if (_cache.has(Class)) return _cache.get(Class);
  782. _cache.set(Class, Wrapper);
  783. }
  784. function Wrapper() {
  785. return _construct(Class, arguments, _getPrototypeOf(this).constructor);
  786. }
  787. Wrapper.prototype = Object.create(Class.prototype, {
  788. constructor: {
  789. value: Wrapper,
  790. enumerable: false,
  791. writable: true,
  792. configurable: true
  793. }
  794. });
  795. return _setPrototypeOf(Wrapper, Class);
  796. };
  797. return _wrapNativeSuper(Class);
  798. }
  799. function _assertThisInitialized(self) {
  800. if (self === void 0) {
  801. throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
  802. }
  803. return self;
  804. }
  805. function _possibleConstructorReturn(self, call) {
  806. if (call && (typeof call === "object" || typeof call === "function")) {
  807. return call;
  808. }
  809. return _assertThisInitialized(self);
  810. }
  811. function _superPropBase(object, property) {
  812. while (!Object.prototype.hasOwnProperty.call(object, property)) {
  813. object = _getPrototypeOf(object);
  814. if (object === null) break;
  815. }
  816. return object;
  817. }
  818. function _get(target, property, receiver) {
  819. if (typeof Reflect !== "undefined" && Reflect.get) {
  820. _get = Reflect.get;
  821. } else {
  822. _get = function _get(target, property, receiver) {
  823. var base = _superPropBase(target, property);
  824. if (!base) return;
  825. var desc = Object.getOwnPropertyDescriptor(base, property);
  826. if (desc.get) {
  827. return desc.get.call(receiver);
  828. }
  829. return desc.value;
  830. };
  831. }
  832. return _get(target, property, receiver || target);
  833. }
  834. function _taggedTemplateLiteral(strings, raw) {
  835. if (!raw) {
  836. raw = strings.slice(0);
  837. }
  838. return Object.freeze(Object.defineProperties(strings, {
  839. raw: {
  840. value: Object.freeze(raw)
  841. }
  842. }));
  843. }
  844. function _slicedToArray(arr, i) {
  845. return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest();
  846. }
  847. function _toArray(arr) {
  848. return _arrayWithHoles(arr) || _iterableToArray(arr) || _nonIterableRest();
  849. }
  850. function _toConsumableArray(arr) {
  851. return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread();
  852. }
  853. function _arrayWithoutHoles(arr) {
  854. if (Array.isArray(arr)) {
  855. for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
  856. return arr2;
  857. }
  858. }
  859. function _arrayWithHoles(arr) {
  860. if (Array.isArray(arr)) return arr;
  861. }
  862. function _iterableToArray(iter) {
  863. if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter);
  864. }
  865. function _iterableToArrayLimit(arr, i) {
  866. var _arr = [];
  867. var _n = true;
  868. var _d = false;
  869. var _e = undefined;
  870. try {
  871. for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
  872. _arr.push(_s.value);
  873. if (i && _arr.length === i) break;
  874. }
  875. } catch (err) {
  876. _d = true;
  877. _e = err;
  878. } finally {
  879. try {
  880. if (!_n && _i["return"] != null) _i["return"]();
  881. } finally {
  882. if (_d) throw _e;
  883. }
  884. }
  885. return _arr;
  886. }
  887. function _nonIterableSpread() {
  888. throw new TypeError("Invalid attempt to spread non-iterable instance");
  889. }
  890. function _nonIterableRest() {
  891. throw new TypeError("Invalid attempt to destructure non-iterable instance");
  892. }
  893. function _toPrimitive(input, hint) {
  894. if (typeof input !== "object" || input === null) return input;
  895. var prim = input[Symbol.toPrimitive];
  896. if (prim !== undefined) {
  897. var res = prim.call(input, hint || "default");
  898. if (typeof res !== "object") return res;
  899. throw new TypeError("@@toPrimitive must return a primitive value.");
  900. }
  901. return (hint === "string" ? String : Number)(input);
  902. }
  903. function _toPropertyKey(arg) {
  904. var key = _toPrimitive(arg, "string");
  905. return typeof key === "symbol" ? key : String(key);
  906. }
  907. function _addElementPlacement(element, placements, silent) {
  908. var keys = placements[element.placement];
  909. if (!silent && keys.indexOf(element.key) !== -1) {
  910. throw new TypeError("Duplicated element (" + element.key + ")");
  911. }
  912. keys.push(element.key);
  913. }
  914. function _fromElementDescriptor(element) {
  915. var obj = {
  916. kind: element.kind,
  917. key: element.key,
  918. placement: element.placement,
  919. descriptor: element.descriptor
  920. };
  921. var desc = {
  922. value: "Descriptor",
  923. configurable: true
  924. };
  925. Object.defineProperty(obj, Symbol.toStringTag, desc);
  926. if (element.kind === "field") obj.initializer = element.initializer;
  927. return obj;
  928. }
  929. function _toElementDescriptors(elementObjects) {
  930. if (elementObjects === undefined) return;
  931. return _toArray(elementObjects).map(function (elementObject) {
  932. var element = _toElementDescriptor(elementObject);
  933. _disallowProperty(elementObject, "finisher", "An element descriptor");
  934. _disallowProperty(elementObject, "extras", "An element descriptor");
  935. return element;
  936. });
  937. }
  938. function _toElementDescriptor(elementObject) {
  939. var kind = String(elementObject.kind);
  940. if (kind !== "method" && kind !== "field") {
  941. throw new TypeError('An element descriptor\'s .kind property must be either "method" or' + ' "field", but a decorator created an element descriptor with' + ' .kind "' + kind + '"');
  942. }
  943. var key = _toPropertyKey(elementObject.key);
  944. var placement = String(elementObject.placement);
  945. if (placement !== "static" && placement !== "prototype" && placement !== "own") {
  946. throw new TypeError('An element descriptor\'s .placement property must be one of "static",' + ' "prototype" or "own", but a decorator created an element descriptor' + ' with .placement "' + placement + '"');
  947. }
  948. var descriptor = elementObject.descriptor;
  949. _disallowProperty(elementObject, "elements", "An element descriptor");
  950. var element = {
  951. kind: kind,
  952. key: key,
  953. placement: placement,
  954. descriptor: Object.assign({}, descriptor)
  955. };
  956. if (kind !== "field") {
  957. _disallowProperty(elementObject, "initializer", "A method descriptor");
  958. } else {
  959. _disallowProperty(descriptor, "get", "The property descriptor of a field descriptor");
  960. _disallowProperty(descriptor, "set", "The property descriptor of a field descriptor");
  961. _disallowProperty(descriptor, "value", "The property descriptor of a field descriptor");
  962. element.initializer = elementObject.initializer;
  963. }
  964. return element;
  965. }
  966. function _toElementFinisherExtras(elementObject) {
  967. var element = _toElementDescriptor(elementObject);
  968. var finisher = _optionalCallableProperty(elementObject, "finisher");
  969. var extras = _toElementDescriptors(elementObject.extras);
  970. return {
  971. element: element,
  972. finisher: finisher,
  973. extras: extras
  974. };
  975. }
  976. function _fromClassDescriptor(elements) {
  977. var obj = {
  978. kind: "class",
  979. elements: elements.map(_fromElementDescriptor)
  980. };
  981. var desc = {
  982. value: "Descriptor",
  983. configurable: true
  984. };
  985. Object.defineProperty(obj, Symbol.toStringTag, desc);
  986. return obj;
  987. }
  988. function _toClassDescriptor(obj) {
  989. var kind = String(obj.kind);
  990. if (kind !== "class") {
  991. throw new TypeError('A class descriptor\'s .kind property must be "class", but a decorator' + ' created a class descriptor with .kind "' + kind + '"');
  992. }
  993. _disallowProperty(obj, "key", "A class descriptor");
  994. _disallowProperty(obj, "placement", "A class descriptor");
  995. _disallowProperty(obj, "descriptor", "A class descriptor");
  996. _disallowProperty(obj, "initializer", "A class descriptor");
  997. _disallowProperty(obj, "extras", "A class descriptor");
  998. var finisher = _optionalCallableProperty(obj, "finisher");
  999. var elements = _toElementDescriptors(obj.elements);
  1000. return {
  1001. elements: elements,
  1002. finisher: finisher
  1003. };
  1004. }
  1005. function _disallowProperty(obj, name, objectType) {
  1006. if (obj[name] !== undefined) {
  1007. throw new TypeError(objectType + " can't have a ." + name + " property.");
  1008. }
  1009. }
  1010. function _optionalCallableProperty(obj, name) {
  1011. var value = obj[name];
  1012. if (value !== undefined && typeof value !== "function") {
  1013. throw new TypeError("Expected '" + name + "' to be a function");
  1014. }
  1015. return value;
  1016. }
  1017. var json = createCommonjsModule(function (module, exports) {
  1018. /*istanbul ignore start*/
  1019. 'use strict';
  1020. exports.__esModule = true;
  1021. exports.jsonDiff = undefined;
  1022. var _typeof$$1 = typeof Symbol === "function" && _typeof(Symbol.iterator) === "symbol" ? function (obj) {
  1023. return _typeof(obj);
  1024. } : function (obj) {
  1025. return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : _typeof(obj);
  1026. };
  1027. exports.
  1028. /*istanbul ignore end*/
  1029. diffJson = diffJson;
  1030. /*istanbul ignore start*/
  1031. exports.
  1032. /*istanbul ignore end*/
  1033. canonicalize = canonicalize;
  1034. /*istanbul ignore start*/
  1035. var _base2 = _interopRequireDefault$$1(base);
  1036. /*istanbul ignore end*/
  1037. /*istanbul ignore start*/
  1038. function _interopRequireDefault$$1(obj) {
  1039. return obj && obj.__esModule ? obj : {
  1040. 'default': obj
  1041. };
  1042. }
  1043. /*istanbul ignore end*/
  1044. var objectPrototypeToString = Object.prototype.toString;
  1045. var jsonDiff =
  1046. /*istanbul ignore start*/
  1047. exports.
  1048. /*istanbul ignore end*/
  1049. jsonDiff = new
  1050. /*istanbul ignore start*/
  1051. _base2['default'](); // Discriminate between two lines of pretty-printed, serialized JSON where one of them has a
  1052. // dangling comma and the other doesn't. Turns out including the dangling comma yields the nicest output:
  1053. jsonDiff.useLongestToken = true;
  1054. jsonDiff.tokenize =
  1055. /*istanbul ignore start*/
  1056. line.lineDiff.
  1057. /*istanbul ignore end*/
  1058. tokenize;
  1059. jsonDiff.castInput = function (value) {
  1060. /*istanbul ignore start*/
  1061. var
  1062. /*istanbul ignore end*/
  1063. undefinedReplacement = this.options.undefinedReplacement;
  1064. return typeof value === 'string' ? value : JSON.stringify(canonicalize(value), function (k, v) {
  1065. if (typeof v === 'undefined') {
  1066. return undefinedReplacement;
  1067. }
  1068. return v;
  1069. }, ' ');
  1070. };
  1071. jsonDiff.equals = function (left, right) {
  1072. return (
  1073. /*istanbul ignore start*/
  1074. _base2['default'].
  1075. /*istanbul ignore end*/
  1076. prototype.equals(left.replace(/,([\r\n])/g, '$1'), right.replace(/,([\r\n])/g, '$1'))
  1077. );
  1078. };
  1079. function diffJson(oldObj, newObj, options) {
  1080. return jsonDiff.diff(oldObj, newObj, options);
  1081. } // This function handles the presence of circular references by bailing out when encountering an
  1082. // object that is already on the "stack" of items being processed.
  1083. function canonicalize(obj, stack, replacementStack) {
  1084. stack = stack || [];
  1085. replacementStack = replacementStack || [];
  1086. var i =
  1087. /*istanbul ignore start*/
  1088. void 0;
  1089. for (i = 0; i < stack.length; i += 1) {
  1090. if (stack[i] === obj) {
  1091. return replacementStack[i];
  1092. }
  1093. }
  1094. var canonicalizedObj =
  1095. /*istanbul ignore start*/
  1096. void 0;
  1097. if ('[object Array]' === objectPrototypeToString.call(obj)) {
  1098. stack.push(obj);
  1099. canonicalizedObj = new Array(obj.length);
  1100. replacementStack.push(canonicalizedObj);
  1101. for (i = 0; i < obj.length; i += 1) {
  1102. canonicalizedObj[i] = canonicalize(obj[i], stack, replacementStack);
  1103. }
  1104. stack.pop();
  1105. replacementStack.pop();
  1106. return canonicalizedObj;
  1107. }
  1108. if (obj && obj.toJSON) {
  1109. obj = obj.toJSON();
  1110. }
  1111. if (
  1112. /*istanbul ignore start*/
  1113. (typeof
  1114. /*istanbul ignore end*/
  1115. obj === 'undefined' ? 'undefined' : _typeof$$1(obj)) === 'object' && obj !== null) {
  1116. stack.push(obj);
  1117. canonicalizedObj = {};
  1118. replacementStack.push(canonicalizedObj);
  1119. var sortedKeys = [],
  1120. key =
  1121. /*istanbul ignore start*/
  1122. void 0;
  1123. for (key in obj) {
  1124. /* istanbul ignore else */
  1125. if (obj.hasOwnProperty(key)) {
  1126. sortedKeys.push(key);
  1127. }
  1128. }
  1129. sortedKeys.sort();
  1130. for (i = 0; i < sortedKeys.length; i += 1) {
  1131. key = sortedKeys[i];
  1132. canonicalizedObj[key] = canonicalize(obj[key], stack, replacementStack);
  1133. }
  1134. stack.pop();
  1135. replacementStack.pop();
  1136. } else {
  1137. canonicalizedObj = obj;
  1138. }
  1139. return canonicalizedObj;
  1140. }
  1141. });
  1142. unwrapExports(json);
  1143. var array = createCommonjsModule(function (module, exports) {
  1144. /*istanbul ignore start*/
  1145. 'use strict';
  1146. exports.__esModule = true;
  1147. exports.arrayDiff = undefined;
  1148. exports.
  1149. /*istanbul ignore end*/
  1150. diffArrays = diffArrays;
  1151. /*istanbul ignore start*/
  1152. var _base2 = _interopRequireDefault(base);
  1153. function _interopRequireDefault(obj) {
  1154. return obj && obj.__esModule ? obj : {
  1155. 'default': obj
  1156. };
  1157. }
  1158. /*istanbul ignore end*/
  1159. var arrayDiff =
  1160. /*istanbul ignore start*/
  1161. exports.
  1162. /*istanbul ignore end*/
  1163. arrayDiff = new
  1164. /*istanbul ignore start*/
  1165. _base2['default']();
  1166. arrayDiff.tokenize = arrayDiff.join = function (value) {
  1167. return value.slice();
  1168. };
  1169. function diffArrays(oldArr, newArr, callback) {
  1170. return arrayDiff.diff(oldArr, newArr, callback);
  1171. }
  1172. });
  1173. unwrapExports(array);
  1174. var parse = createCommonjsModule(function (module, exports) {
  1175. /*istanbul ignore start*/
  1176. 'use strict';
  1177. exports.__esModule = true;
  1178. exports.
  1179. /*istanbul ignore end*/
  1180. parsePatch = parsePatch;
  1181. function parsePatch(uniDiff) {
  1182. /*istanbul ignore start*/
  1183. var
  1184. /*istanbul ignore end*/
  1185. options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
  1186. var diffstr = uniDiff.split(/\r\n|[\n\v\f\r\x85]/),
  1187. delimiters = uniDiff.match(/\r\n|[\n\v\f\r\x85]/g) || [],
  1188. list = [],
  1189. i = 0;
  1190. function parseIndex() {
  1191. var index = {};
  1192. list.push(index); // Parse diff metadata
  1193. while (i < diffstr.length) {
  1194. var line = diffstr[i]; // File header found, end parsing diff metadata
  1195. if (/^(\-\-\-|\+\+\+|@@)\s/.test(line)) {
  1196. break;
  1197. } // Diff index
  1198. var header = /^(?:Index:|diff(?: -r \w+)+)\s+(.+?)\s*$/.exec(line);
  1199. if (header) {
  1200. index.index = header[1];
  1201. }
  1202. i++;
  1203. } // Parse file headers if they are defined. Unified diff requires them, but
  1204. // there's no technical issues to have an isolated hunk without file header
  1205. parseFileHeader(index);
  1206. parseFileHeader(index); // Parse hunks
  1207. index.hunks = [];
  1208. while (i < diffstr.length) {
  1209. var _line = diffstr[i];
  1210. if (/^(Index:|diff|\-\-\-|\+\+\+)\s/.test(_line)) {
  1211. break;
  1212. } else if (/^@@/.test(_line)) {
  1213. index.hunks.push(parseHunk());
  1214. } else if (_line && options.strict) {
  1215. // Ignore unexpected content unless in strict mode
  1216. throw new Error('Unknown line ' + (i + 1) + ' ' + JSON.stringify(_line));
  1217. } else {
  1218. i++;
  1219. }
  1220. }
  1221. } // Parses the --- and +++ headers, if none are found, no lines
  1222. // are consumed.
  1223. function parseFileHeader(index) {
  1224. var headerPattern = /^(---|\+\+\+)\s+([\S ]*)(?:\t(.*?)\s*)?$/;
  1225. var fileHeader = headerPattern.exec(diffstr[i]);
  1226. if (fileHeader) {
  1227. var keyPrefix = fileHeader[1] === '---' ? 'old' : 'new';
  1228. index[keyPrefix + 'FileName'] = fileHeader[2];
  1229. index[keyPrefix + 'Header'] = fileHeader[3];
  1230. i++;
  1231. }
  1232. } // Parses a hunk
  1233. // This assumes that we are at the start of a hunk.
  1234. function parseHunk() {
  1235. var chunkHeaderIndex = i,
  1236. chunkHeaderLine = diffstr[i++],
  1237. chunkHeader = chunkHeaderLine.split(/@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/);
  1238. var hunk = {
  1239. oldStart: +chunkHeader[1],
  1240. oldLines: +chunkHeader[2] || 1,
  1241. newStart: +chunkHeader[3],
  1242. newLines: +chunkHeader[4] || 1,
  1243. lines: [],
  1244. linedelimiters: []
  1245. };
  1246. var addCount = 0,
  1247. removeCount = 0;
  1248. for (; i < diffstr.length; i++) {
  1249. // Lines starting with '---' could be mistaken for the "remove line" operation
  1250. // But they could be the header for the next file. Therefore prune such cases out.
  1251. if (diffstr[i].indexOf('--- ') === 0 && i + 2 < diffstr.length && diffstr[i + 1].indexOf('+++ ') === 0 && diffstr[i + 2].indexOf('@@') === 0) {
  1252. break;
  1253. }
  1254. var operation = diffstr[i][0];
  1255. if (operation === '+' || operation === '-' || operation === ' ' || operation === '\\') {
  1256. hunk.lines.push(diffstr[i]);
  1257. hunk.linedelimiters.push(delimiters[i] || '\n');
  1258. if (operation === '+') {
  1259. addCount++;
  1260. } else if (operation === '-') {
  1261. removeCount++;
  1262. } else if (operation === ' ') {
  1263. addCount++;
  1264. removeCount++;
  1265. }
  1266. } else {
  1267. break;
  1268. }
  1269. } // Handle the empty block count case
  1270. if (!addCount && hunk.newLines === 1) {
  1271. hunk.newLines = 0;
  1272. }
  1273. if (!removeCount && hunk.oldLines === 1) {
  1274. hunk.oldLines = 0;
  1275. } // Perform optional sanity checking
  1276. if (options.strict) {
  1277. if (addCount !== hunk.newLines) {
  1278. throw new Error('Added line count did not match for hunk at line ' + (chunkHeaderIndex + 1));
  1279. }
  1280. if (removeCount !== hunk.oldLines) {
  1281. throw new Error('Removed line count did not match for hunk at line ' + (chunkHeaderIndex + 1));
  1282. }
  1283. }
  1284. return hunk;
  1285. }
  1286. while (i < diffstr.length) {
  1287. parseIndex();
  1288. }
  1289. return list;
  1290. }
  1291. });
  1292. unwrapExports(parse);
  1293. var distanceIterator = createCommonjsModule(function (module, exports) {
  1294. /*istanbul ignore start*/
  1295. "use strict";
  1296. exports.__esModule = true;
  1297. exports["default"] =
  1298. /*istanbul ignore end*/
  1299. function (start, minLine, maxLine) {
  1300. var wantForward = true,
  1301. backwardExhausted = false,
  1302. forwardExhausted = false,
  1303. localOffset = 1;
  1304. return function iterator() {
  1305. if (wantForward && !forwardExhausted) {
  1306. if (backwardExhausted) {
  1307. localOffset++;
  1308. } else {
  1309. wantForward = false;
  1310. } // Check if trying to fit beyond text length, and if not, check it fits
  1311. // after offset location (or desired location on first iteration)
  1312. if (start + localOffset <= maxLine) {
  1313. return localOffset;
  1314. }
  1315. forwardExhausted = true;
  1316. }
  1317. if (!backwardExhausted) {
  1318. if (!forwardExhausted) {
  1319. wantForward = true;
  1320. } // Check if trying to fit before text beginning, and if not, check it fits
  1321. // before offset location
  1322. if (minLine <= start - localOffset) {
  1323. return -localOffset++;
  1324. }
  1325. backwardExhausted = true;
  1326. return iterator();
  1327. } // We tried to fit hunk before text beginning and beyond text lenght, then
  1328. // hunk can't fit on the text. Return undefined
  1329. };
  1330. };
  1331. });
  1332. unwrapExports(distanceIterator);
  1333. var apply = createCommonjsModule(function (module, exports) {
  1334. /*istanbul ignore start*/
  1335. 'use strict';
  1336. exports.__esModule = true;
  1337. exports.
  1338. /*istanbul ignore end*/
  1339. applyPatch = applyPatch;
  1340. /*istanbul ignore start*/
  1341. exports.
  1342. /*istanbul ignore end*/
  1343. applyPatches = applyPatches;
  1344. /*istanbul ignore start*/
  1345. var _distanceIterator2 = _interopRequireDefault(distanceIterator);
  1346. function _interopRequireDefault(obj) {
  1347. return obj && obj.__esModule ? obj : {
  1348. 'default': obj
  1349. };
  1350. }
  1351. /*istanbul ignore end*/
  1352. function applyPatch(source, uniDiff) {
  1353. /*istanbul ignore start*/
  1354. var
  1355. /*istanbul ignore end*/
  1356. options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];
  1357. if (typeof uniDiff === 'string') {
  1358. uniDiff =
  1359. /*istanbul ignore start*/
  1360. (0, parse.parsePatch
  1361. /*istanbul ignore end*/
  1362. )(uniDiff);
  1363. }
  1364. if (Array.isArray(uniDiff)) {
  1365. if (uniDiff.length > 1) {
  1366. throw new Error('applyPatch only works with a single input.');
  1367. }
  1368. uniDiff = uniDiff[0];
  1369. } // Apply the diff to the input
  1370. var lines = source.split(/\r\n|[\n\v\f\r\x85]/),
  1371. delimiters = source.match(/\r\n|[\n\v\f\r\x85]/g) || [],
  1372. hunks = uniDiff.hunks,
  1373. compareLine = options.compareLine || function (lineNumber, line, operation, patchContent)
  1374. /*istanbul ignore start*/
  1375. {
  1376. return (
  1377. /*istanbul ignore end*/
  1378. line === patchContent
  1379. );
  1380. },
  1381. errorCount = 0,
  1382. fuzzFactor = options.fuzzFactor || 0,
  1383. minLine = 0,
  1384. offset = 0,
  1385. removeEOFNL =
  1386. /*istanbul ignore start*/
  1387. void 0
  1388. /*istanbul ignore end*/
  1389. ,
  1390. addEOFNL =
  1391. /*istanbul ignore start*/
  1392. void 0;
  1393. /**
  1394. * Checks if the hunk exactly fits on the provided location
  1395. */
  1396. function hunkFits(hunk, toPos) {
  1397. for (var j = 0; j < hunk.lines.length; j++) {
  1398. var line = hunk.lines[j],
  1399. operation = line[0],
  1400. content = line.substr(1);
  1401. if (operation === ' ' || operation === '-') {
  1402. // Context sanity check
  1403. if (!compareLine(toPos + 1, lines[toPos], operation, content)) {
  1404. errorCount++;
  1405. if (errorCount > fuzzFactor) {
  1406. return false;
  1407. }
  1408. }
  1409. toPos++;
  1410. }
  1411. }
  1412. return true;
  1413. } // Search best fit offsets for each hunk based on the previous ones
  1414. for (var i = 0; i < hunks.length; i++) {
  1415. var hunk = hunks[i],
  1416. maxLine = lines.length - hunk.oldLines,
  1417. localOffset = 0,
  1418. toPos = offset + hunk.oldStart - 1;
  1419. var iterator =
  1420. /*istanbul ignore start*/
  1421. (0, _distanceIterator2['default']
  1422. /*istanbul ignore end*/
  1423. )(toPos, minLine, maxLine);
  1424. for (; localOffset !== undefined; localOffset = iterator()) {
  1425. if (hunkFits(hunk, toPos + localOffset)) {
  1426. hunk.offset = offset += localOffset;
  1427. break;
  1428. }
  1429. }
  1430. if (localOffset === undefined) {
  1431. return false;
  1432. } // Set lower text limit to end of the current hunk, so next ones don't try
  1433. // to fit over already patched text
  1434. minLine = hunk.offset + hunk.oldStart + hunk.oldLines;
  1435. } // Apply patch hunks
  1436. for (var _i = 0; _i < hunks.length; _i++) {
  1437. var _hunk = hunks[_i],
  1438. _toPos = _hunk.offset + _hunk.newStart - 1;
  1439. if (_hunk.newLines == 0) {
  1440. _toPos++;
  1441. }
  1442. for (var j = 0; j < _hunk.lines.length; j++) {
  1443. var line = _hunk.lines[j],
  1444. operation = line[0],
  1445. content = line.substr(1),
  1446. delimiter = _hunk.linedelimiters[j];
  1447. if (operation === ' ') {
  1448. _toPos++;
  1449. } else if (operation === '-') {
  1450. lines.splice(_toPos, 1);
  1451. delimiters.splice(_toPos, 1);
  1452. /* istanbul ignore else */
  1453. } else if (operation === '+') {
  1454. lines.splice(_toPos, 0, content);
  1455. delimiters.splice(_toPos, 0, delimiter);
  1456. _toPos++;
  1457. } else if (operation === '\\') {
  1458. var previousOperation = _hunk.lines[j - 1] ? _hunk.lines[j - 1][0] : null;
  1459. if (previousOperation === '+') {
  1460. removeEOFNL = true;
  1461. } else if (previousOperation === '-') {
  1462. addEOFNL = true;
  1463. }
  1464. }
  1465. }
  1466. } // Handle EOFNL insertion/removal
  1467. if (removeEOFNL) {
  1468. while (!lines[lines.length - 1]) {
  1469. lines.pop();
  1470. delimiters.pop();
  1471. }
  1472. } else if (addEOFNL) {
  1473. lines.push('');
  1474. delimiters.push('\n');
  1475. }
  1476. for (var _k = 0; _k < lines.length - 1; _k++) {
  1477. lines[_k] = lines[_k] + delimiters[_k];
  1478. }
  1479. return lines.join('');
  1480. } // Wrapper that supports multiple file patches via callbacks.
  1481. function applyPatches(uniDiff, options) {
  1482. if (typeof uniDiff === 'string') {
  1483. uniDiff =
  1484. /*istanbul ignore start*/
  1485. (0, parse.parsePatch
  1486. /*istanbul ignore end*/
  1487. )(uniDiff);
  1488. }
  1489. var currentIndex = 0;
  1490. function processIndex() {
  1491. var index = uniDiff[currentIndex++];
  1492. if (!index) {
  1493. return options.complete();
  1494. }
  1495. options.loadFile(index, function (err, data) {
  1496. if (err) {
  1497. return options.complete(err);
  1498. }
  1499. var updatedContent = applyPatch(data, index, options);
  1500. options.patched(index, updatedContent, function (err) {
  1501. if (err) {
  1502. return options.complete(err);
  1503. }
  1504. processIndex();
  1505. });
  1506. });
  1507. }
  1508. processIndex();
  1509. }
  1510. });
  1511. unwrapExports(apply);
  1512. var create = createCommonjsModule(function (module, exports) {
  1513. /*istanbul ignore start*/
  1514. 'use strict';
  1515. exports.__esModule = true;
  1516. exports.
  1517. /*istanbul ignore end*/
  1518. structuredPatch = structuredPatch;
  1519. /*istanbul ignore start*/
  1520. exports.
  1521. /*istanbul ignore end*/
  1522. createTwoFilesPatch = createTwoFilesPatch;
  1523. /*istanbul ignore start*/
  1524. exports.
  1525. /*istanbul ignore end*/
  1526. createPatch = createPatch;
  1527. /*istanbul ignore start*/
  1528. function _toConsumableArray(arr) {
  1529. if (Array.isArray(arr)) {
  1530. for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) {
  1531. arr2[i] = arr[i];
  1532. }
  1533. return arr2;
  1534. } else {
  1535. return Array.from(arr);
  1536. }
  1537. }
  1538. /*istanbul ignore end*/
  1539. function structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
  1540. if (!options) {
  1541. options = {};
  1542. }
  1543. if (typeof options.context === 'undefined') {
  1544. options.context = 4;
  1545. }
  1546. var diff =
  1547. /*istanbul ignore start*/
  1548. (0, line.diffLines
  1549. /*istanbul ignore end*/
  1550. )(oldStr, newStr, options);
  1551. diff.push({
  1552. value: '',
  1553. lines: []
  1554. }); // Append an empty value to make cleanup easier
  1555. function contextLines(lines) {
  1556. return lines.map(function (entry) {
  1557. return ' ' + entry;
  1558. });
  1559. }
  1560. var hunks = [];
  1561. var oldRangeStart = 0,
  1562. newRangeStart = 0,
  1563. curRange = [],
  1564. oldLine = 1,
  1565. newLine = 1;
  1566. /*istanbul ignore start*/
  1567. var _loop = function _loop(
  1568. /*istanbul ignore end*/
  1569. i) {
  1570. var current = diff[i],
  1571. lines = current.lines || current.value.replace(/\n$/, '').split('\n');
  1572. current.lines = lines;
  1573. if (current.added || current.removed) {
  1574. /*istanbul ignore start*/
  1575. var _curRange;
  1576. /*istanbul ignore end*/
  1577. // If we have previous context, start with that
  1578. if (!oldRangeStart) {
  1579. var prev = diff[i - 1];
  1580. oldRangeStart = oldLine;
  1581. newRangeStart = newLine;
  1582. if (prev) {
  1583. curRange = options.context > 0 ? contextLines(prev.lines.slice(-options.context)) : [];
  1584. oldRangeStart -= curRange.length;
  1585. newRangeStart -= curRange.length;
  1586. }
  1587. } // Output our changes
  1588. /*istanbul ignore start*/
  1589. (_curRange =
  1590. /*istanbul ignore end*/
  1591. curRange).push.
  1592. /*istanbul ignore start*/
  1593. apply
  1594. /*istanbul ignore end*/
  1595. (
  1596. /*istanbul ignore start*/
  1597. _curRange
  1598. /*istanbul ignore end*/
  1599. ,
  1600. /*istanbul ignore start*/
  1601. _toConsumableArray(
  1602. /*istanbul ignore end*/
  1603. lines.map(function (entry) {
  1604. return (current.added ? '+' : '-') + entry;
  1605. }))); // Track the updated file position
  1606. if (current.added) {
  1607. newLine += lines.length;
  1608. } else {
  1609. oldLine += lines.length;
  1610. }
  1611. } else {
  1612. // Identical context lines. Track line changes
  1613. if (oldRangeStart) {
  1614. // Close out any changes that have been output (or join overlapping)
  1615. if (lines.length <= options.context * 2 && i < diff.length - 2) {
  1616. /*istanbul ignore start*/
  1617. var _curRange2;
  1618. /*istanbul ignore end*/
  1619. // Overlapping
  1620. /*istanbul ignore start*/
  1621. (_curRange2 =
  1622. /*istanbul ignore end*/
  1623. curRange).push.
  1624. /*istanbul ignore start*/
  1625. apply
  1626. /*istanbul ignore end*/
  1627. (
  1628. /*istanbul ignore start*/
  1629. _curRange2
  1630. /*istanbul ignore end*/
  1631. ,
  1632. /*istanbul ignore start*/
  1633. _toConsumableArray(
  1634. /*istanbul ignore end*/
  1635. contextLines(lines)));
  1636. } else {
  1637. /*istanbul ignore start*/
  1638. var _curRange3;
  1639. /*istanbul ignore end*/
  1640. // end the range and output
  1641. var contextSize = Math.min(lines.length, options.context);
  1642. /*istanbul ignore start*/
  1643. (_curRange3 =
  1644. /*istanbul ignore end*/
  1645. curRange).push.
  1646. /*istanbul ignore start*/
  1647. apply
  1648. /*istanbul ignore end*/
  1649. (
  1650. /*istanbul ignore start*/
  1651. _curRange3
  1652. /*istanbul ignore end*/
  1653. ,
  1654. /*istanbul ignore start*/
  1655. _toConsumableArray(
  1656. /*istanbul ignore end*/
  1657. contextLines(lines.slice(0, contextSize))));
  1658. var hunk = {
  1659. oldStart: oldRangeStart,
  1660. oldLines: oldLine - oldRangeStart + contextSize,
  1661. newStart: newRangeStart,
  1662. newLines: newLine - newRangeStart + contextSize,
  1663. lines: curRange
  1664. };
  1665. if (i >= diff.length - 2 && lines.length <= options.context) {
  1666. // EOF is inside this hunk
  1667. var oldEOFNewline = /\n$/.test(oldStr);
  1668. var newEOFNewline = /\n$/.test(newStr);
  1669. if (lines.length == 0 && !oldEOFNewline) {
  1670. // special case: old has no eol and no trailing context; no-nl can end up before adds
  1671. curRange.splice(hunk.oldLines, 0, '\\ No newline at end of file');
  1672. } else if (!oldEOFNewline || !newEOFNewline) {
  1673. curRange.push('\\ No newline at end of file');
  1674. }
  1675. }
  1676. hunks.push(hunk);
  1677. oldRangeStart = 0;
  1678. newRangeStart = 0;
  1679. curRange = [];
  1680. }
  1681. }
  1682. oldLine += lines.length;
  1683. newLine += lines.length;
  1684. }
  1685. };
  1686. for (var i = 0; i < diff.length; i++) {
  1687. /*istanbul ignore start*/
  1688. _loop(
  1689. /*istanbul ignore end*/
  1690. i);
  1691. }
  1692. return {
  1693. oldFileName: oldFileName,
  1694. newFileName: newFileName,
  1695. oldHeader: oldHeader,
  1696. newHeader: newHeader,
  1697. hunks: hunks
  1698. };
  1699. }
  1700. function createTwoFilesPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
  1701. var diff = structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options);
  1702. var ret = [];
  1703. if (oldFileName == newFileName) {
  1704. ret.push('Index: ' + oldFileName);
  1705. }
  1706. ret.push('===================================================================');
  1707. ret.push('--- ' + diff.oldFileName + (typeof diff.oldHeader === 'undefined' ? '' : '\t' + diff.oldHeader));
  1708. ret.push('+++ ' + diff.newFileName + (typeof diff.newHeader === 'undefined' ? '' : '\t' + diff.newHeader));
  1709. for (var i = 0; i < diff.hunks.length; i++) {
  1710. var hunk = diff.hunks[i];
  1711. ret.push('@@ -' + hunk.oldStart + ',' + hunk.oldLines + ' +' + hunk.newStart + ',' + hunk.newLines + ' @@');
  1712. ret.push.apply(ret, hunk.lines);
  1713. }
  1714. return ret.join('\n') + '\n';
  1715. }
  1716. function createPatch(fileName, oldStr, newStr, oldHeader, newHeader, options) {
  1717. return createTwoFilesPatch(fileName, fileName, oldStr, newStr, oldHeader, newHeader, options);
  1718. }
  1719. });
  1720. unwrapExports(create);
  1721. var dmp = createCommonjsModule(function (module, exports) {
  1722. /*istanbul ignore start*/
  1723. "use strict";
  1724. exports.__esModule = true;
  1725. exports.
  1726. /*istanbul ignore end*/
  1727. convertChangesToDMP = convertChangesToDMP; // See: http://code.google.com/p/google-diff-match-patch/wiki/API
  1728. function convertChangesToDMP(changes) {
  1729. var ret = [],
  1730. change =
  1731. /*istanbul ignore start*/
  1732. void 0
  1733. /*istanbul ignore end*/
  1734. ,
  1735. operation =
  1736. /*istanbul ignore start*/
  1737. void 0;
  1738. for (var i = 0; i < changes.length; i++) {
  1739. change = changes[i];
  1740. if (change.added) {
  1741. operation = 1;
  1742. } else if (change.removed) {
  1743. operation = -1;
  1744. } else {
  1745. operation = 0;
  1746. }
  1747. ret.push([operation, change.value]);
  1748. }
  1749. return ret;
  1750. }
  1751. });
  1752. unwrapExports(dmp);
  1753. var xml = createCommonjsModule(function (module, exports) {
  1754. /*istanbul ignore start*/
  1755. 'use strict';
  1756. exports.__esModule = true;
  1757. exports.
  1758. /*istanbul ignore end*/
  1759. convertChangesToXML = convertChangesToXML;
  1760. function convertChangesToXML(changes) {
  1761. var ret = [];
  1762. for (var i = 0; i < changes.length; i++) {
  1763. var change = changes[i];
  1764. if (change.added) {
  1765. ret.push('<ins>');
  1766. } else if (change.removed) {
  1767. ret.push('<del>');
  1768. }
  1769. ret.push(escapeHTML(change.value));
  1770. if (change.added) {
  1771. ret.push('</ins>');
  1772. } else if (change.removed) {
  1773. ret.push('</del>');
  1774. }
  1775. }
  1776. return ret.join('');
  1777. }
  1778. function escapeHTML(s) {
  1779. var n = s;
  1780. n = n.replace(/&/g, '&amp;');
  1781. n = n.replace(/</g, '&lt;');
  1782. n = n.replace(/>/g, '&gt;');
  1783. n = n.replace(/"/g, '&quot;');
  1784. return n;
  1785. }
  1786. });
  1787. unwrapExports(xml);
  1788. var lib = createCommonjsModule(function (module, exports) {
  1789. /*istanbul ignore start*/
  1790. 'use strict';
  1791. exports.__esModule = true;
  1792. 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;
  1793. /*istanbul ignore end*/
  1794. /*istanbul ignore start*/
  1795. var _base2 = _interopRequireDefault(base);
  1796. /*istanbul ignore end*/
  1797. /*istanbul ignore start*/
  1798. function _interopRequireDefault(obj) {
  1799. return obj && obj.__esModule ? obj : {
  1800. 'default': obj
  1801. };
  1802. }
  1803. exports.
  1804. /*istanbul ignore end*/
  1805. Diff = _base2['default'];
  1806. /*istanbul ignore start*/
  1807. exports.
  1808. /*istanbul ignore end*/
  1809. diffChars = character.diffChars;
  1810. /*istanbul ignore start*/
  1811. exports.
  1812. /*istanbul ignore end*/
  1813. diffWords = word.diffWords;
  1814. /*istanbul ignore start*/
  1815. exports.
  1816. /*istanbul ignore end*/
  1817. diffWordsWithSpace = word.diffWordsWithSpace;
  1818. /*istanbul ignore start*/
  1819. exports.
  1820. /*istanbul ignore end*/
  1821. diffLines = line.diffLines;
  1822. /*istanbul ignore start*/
  1823. exports.
  1824. /*istanbul ignore end*/
  1825. diffTrimmedLines = line.diffTrimmedLines;
  1826. /*istanbul ignore start*/
  1827. exports.
  1828. /*istanbul ignore end*/
  1829. diffSentences = sentence.diffSentences;
  1830. /*istanbul ignore start*/
  1831. exports.
  1832. /*istanbul ignore end*/
  1833. diffCss = css.diffCss;
  1834. /*istanbul ignore start*/
  1835. exports.
  1836. /*istanbul ignore end*/
  1837. diffJson = json.diffJson;
  1838. /*istanbul ignore start*/
  1839. exports.
  1840. /*istanbul ignore end*/
  1841. diffArrays = array.diffArrays;
  1842. /*istanbul ignore start*/
  1843. exports.
  1844. /*istanbul ignore end*/
  1845. structuredPatch = create.structuredPatch;
  1846. /*istanbul ignore start*/
  1847. exports.
  1848. /*istanbul ignore end*/
  1849. createTwoFilesPatch = create.createTwoFilesPatch;
  1850. /*istanbul ignore start*/
  1851. exports.
  1852. /*istanbul ignore end*/
  1853. createPatch = create.createPatch;
  1854. /*istanbul ignore start*/
  1855. exports.
  1856. /*istanbul ignore end*/
  1857. applyPatch = apply.applyPatch;
  1858. /*istanbul ignore start*/
  1859. exports.
  1860. /*istanbul ignore end*/
  1861. applyPatches = apply.applyPatches;
  1862. /*istanbul ignore start*/
  1863. exports.
  1864. /*istanbul ignore end*/
  1865. parsePatch = parse.parsePatch;
  1866. /*istanbul ignore start*/
  1867. exports.
  1868. /*istanbul ignore end*/
  1869. convertChangesToDMP = dmp.convertChangesToDMP;
  1870. /*istanbul ignore start*/
  1871. exports.
  1872. /*istanbul ignore end*/
  1873. convertChangesToXML = xml.convertChangesToXML;
  1874. /*istanbul ignore start*/
  1875. exports.
  1876. /*istanbul ignore end*/
  1877. canonicalize = json.canonicalize;
  1878. /* See LICENSE file for terms of use */
  1879. /*
  1880. * Text diff implementation.
  1881. *
  1882. * This library supports the following APIS:
  1883. * JsDiff.diffChars: Character by character diff
  1884. * JsDiff.diffWords: Word (as defined by \b regex) diff which ignores whitespace
  1885. * JsDiff.diffLines: Line based diff
  1886. *
  1887. * JsDiff.diffCss: Diff targeted at CSS content
  1888. *
  1889. * These methods are based on the implementation proposed in
  1890. * "An O(ND) Difference Algorithm and its Variations" (Myers, 1986).
  1891. * http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.4.6927
  1892. */
  1893. });
  1894. unwrapExports(lib);
  1895. var _shim_fs = {};
  1896. var _shim_fs$1 = Object.freeze({
  1897. default: _shim_fs
  1898. });
  1899. /*!
  1900. * normalize-path <https://github.com/jonschlinkert/normalize-path>
  1901. *
  1902. * Copyright (c) 2014-2018, Jon Schlinkert.
  1903. * Released under the MIT License.
  1904. */
  1905. var normalizePath = function normalizePath(path, stripTrailing) {
  1906. if (typeof path !== 'string') {
  1907. throw new TypeError('expected path to be a string');
  1908. }
  1909. if (path === '\\' || path === '/') return '/';
  1910. var len = path.length;
  1911. if (len <= 1) return path; // ensure that win32 namespaces has two leading slashes, so that the path is
  1912. // handled properly by the win32 version of path.parse() after being normalized
  1913. // https://msdn.microsoft.com/library/windows/desktop/aa365247(v=vs.85).aspx#namespaces
  1914. var prefix = '';
  1915. if (len > 4 && path[3] === '\\') {
  1916. var ch = path[2];
  1917. if ((ch === '?' || ch === '.') && path.slice(0, 2) === '\\\\') {
  1918. path = path.slice(2);
  1919. prefix = '//';
  1920. }
  1921. }
  1922. var segs = path.split(/[/\\]+/);
  1923. if (stripTrailing !== false && segs[segs.length - 1] === '') {
  1924. segs.pop();
  1925. }
  1926. return prefix + segs.join('/');
  1927. };
  1928. var global$1 = typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {};
  1929. var lookup = [];
  1930. var revLookup = [];
  1931. var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array;
  1932. var inited = false;
  1933. function init() {
  1934. inited = true;
  1935. var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
  1936. for (var i = 0, len = code.length; i < len; ++i) {
  1937. lookup[i] = code[i];
  1938. revLookup[code.charCodeAt(i)] = i;
  1939. }
  1940. revLookup['-'.charCodeAt(0)] = 62;
  1941. revLookup['_'.charCodeAt(0)] = 63;
  1942. }
  1943. function toByteArray(b64) {
  1944. if (!inited) {
  1945. init();
  1946. }
  1947. var i, j, l, tmp, placeHolders, arr;
  1948. var len = b64.length;
  1949. if (len % 4 > 0) {
  1950. throw new Error('Invalid string. Length must be a multiple of 4');
  1951. } // the number of equal signs (place holders)
  1952. // if there are two placeholders, than the two characters before it
  1953. // represent one byte
  1954. // if there is only one, then the three characters before it represent 2 bytes
  1955. // this is just a cheap hack to not do indexOf twice
  1956. placeHolders = b64[len - 2] === '=' ? 2 : b64[len - 1] === '=' ? 1 : 0; // base64 is 4/3 + up to two characters of the original data
  1957. arr = new Arr(len * 3 / 4 - placeHolders); // if there are placeholders, only get up to the last complete 4 chars
  1958. l = placeHolders > 0 ? len - 4 : len;
  1959. var L = 0;
  1960. for (i = 0, j = 0; i < l; i += 4, j += 3) {
  1961. tmp = revLookup[b64.charCodeAt(i)] << 18 | revLookup[b64.charCodeAt(i + 1)] << 12 | revLookup[b64.charCodeAt(i + 2)] << 6 | revLookup[b64.charCodeAt(i + 3)];
  1962. arr[L++] = tmp >> 16 & 0xFF;
  1963. arr[L++] = tmp >> 8 & 0xFF;
  1964. arr[L++] = tmp & 0xFF;
  1965. }
  1966. if (placeHolders === 2) {
  1967. tmp = revLookup[b64.charCodeAt(i)] << 2 | revLookup[b64.charCodeAt(i + 1)] >> 4;
  1968. arr[L++] = tmp & 0xFF;
  1969. } else if (placeHolders === 1) {
  1970. tmp = revLookup[b64.charCodeAt(i)] << 10 | revLookup[b64.charCodeAt(i + 1)] << 4 | revLookup[b64.charCodeAt(i + 2)] >> 2;
  1971. arr[L++] = tmp >> 8 & 0xFF;
  1972. arr[L++] = tmp & 0xFF;
  1973. }
  1974. return arr;
  1975. }
  1976. function tripletToBase64(num) {
  1977. return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F];
  1978. }
  1979. function encodeChunk(uint8, start, end) {
  1980. var tmp;
  1981. var output = [];
  1982. for (var i = start; i < end; i += 3) {
  1983. tmp = (uint8[i] << 16) + (uint8[i + 1] << 8) + uint8[i + 2];
  1984. output.push(tripletToBase64(tmp));
  1985. }
  1986. return output.join('');
  1987. }
  1988. function fromByteArray(uint8) {
  1989. if (!inited) {
  1990. init();
  1991. }
  1992. var tmp;
  1993. var len = uint8.length;
  1994. var extraBytes = len % 3; // if we have 1 byte left, pad 2 bytes
  1995. var output = '';
  1996. var parts = [];
  1997. var maxChunkLength = 16383; // must be multiple of 3
  1998. // go through the array every three bytes, we'll deal with trailing stuff later
  1999. for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
  2000. parts.push(encodeChunk(uint8, i, i + maxChunkLength > len2 ? len2 : i + maxChunkLength));
  2001. } // pad the end with zeros, but make sure to not forget the extra bytes
  2002. if (extraBytes === 1) {
  2003. tmp = uint8[len - 1];
  2004. output += lookup[tmp >> 2];
  2005. output += lookup[tmp << 4 & 0x3F];
  2006. output += '==';
  2007. } else if (extraBytes === 2) {
  2008. tmp = (uint8[len - 2] << 8) + uint8[len - 1];
  2009. output += lookup[tmp >> 10];
  2010. output += lookup[tmp >> 4 & 0x3F];
  2011. output += lookup[tmp << 2 & 0x3F];
  2012. output += '=';
  2013. }
  2014. parts.push(output);
  2015. return parts.join('');
  2016. }
  2017. function read(buffer, offset, isLE, mLen, nBytes) {
  2018. var e, m;
  2019. var eLen = nBytes * 8 - mLen - 1;
  2020. var eMax = (1 << eLen) - 1;
  2021. var eBias = eMax >> 1;
  2022. var nBits = -7;
  2023. var i = isLE ? nBytes - 1 : 0;
  2024. var d = isLE ? -1 : 1;
  2025. var s = buffer[offset + i];
  2026. i += d;
  2027. e = s & (1 << -nBits) - 1;
  2028. s >>= -nBits;
  2029. nBits += eLen;
  2030. for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {}
  2031. m = e & (1 << -nBits) - 1;
  2032. e >>= -nBits;
  2033. nBits += mLen;
  2034. for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {}
  2035. if (e === 0) {
  2036. e = 1 - eBias;
  2037. } else if (e === eMax) {
  2038. return m ? NaN : (s ? -1 : 1) * Infinity;
  2039. } else {
  2040. m = m + Math.pow(2, mLen);
  2041. e = e - eBias;
  2042. }
  2043. return (s ? -1 : 1) * m * Math.pow(2, e - mLen);
  2044. }
  2045. function write(buffer, value, offset, isLE, mLen, nBytes) {
  2046. var e, m, c;
  2047. var eLen = nBytes * 8 - mLen - 1;
  2048. var eMax = (1 << eLen) - 1;
  2049. var eBias = eMax >> 1;
  2050. var rt = mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0;
  2051. var i = isLE ? 0 : nBytes - 1;
  2052. var d = isLE ? 1 : -1;
  2053. var s = value < 0 || value === 0 && 1 / value < 0 ? 1 : 0;
  2054. value = Math.abs(value);
  2055. if (isNaN(value) || value === Infinity) {
  2056. m = isNaN(value) ? 1 : 0;
  2057. e = eMax;
  2058. } else {
  2059. e = Math.floor(Math.log(value) / Math.LN2);
  2060. if (value * (c = Math.pow(2, -e)) < 1) {
  2061. e--;
  2062. c *= 2;
  2063. }
  2064. if (e + eBias >= 1) {
  2065. value += rt / c;
  2066. } else {
  2067. value += rt * Math.pow(2, 1 - eBias);
  2068. }
  2069. if (value * c >= 2) {
  2070. e++;
  2071. c /= 2;
  2072. }
  2073. if (e + eBias >= eMax) {
  2074. m = 0;
  2075. e = eMax;
  2076. } else if (e + eBias >= 1) {
  2077. m = (value * c - 1) * Math.pow(2, mLen);
  2078. e = e + eBias;
  2079. } else {
  2080. m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen);
  2081. e = 0;
  2082. }
  2083. }
  2084. for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
  2085. e = e << mLen | m;
  2086. eLen += mLen;
  2087. for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
  2088. buffer[offset + i - d] |= s * 128;
  2089. }
  2090. var toString = {}.toString;
  2091. var isArray$1 = Array.isArray || function (arr) {
  2092. return toString.call(arr) == '[object Array]';
  2093. };
  2094. /*!
  2095. * The buffer module from node.js, for the browser.
  2096. *
  2097. * @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
  2098. * @license MIT
  2099. */
  2100. /* eslint-disable no-proto */
  2101. var INSPECT_MAX_BYTES = 50;
  2102. /**
  2103. * If `Buffer.TYPED_ARRAY_SUPPORT`:
  2104. * === true Use Uint8Array implementation (fastest)
  2105. * === false Use Object implementation (most compatible, even IE6)
  2106. *
  2107. * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
  2108. * Opera 11.6+, iOS 4.2+.
  2109. *
  2110. * Due to various browser bugs, sometimes the Object implementation will be used even
  2111. * when the browser supports typed arrays.
  2112. *
  2113. * Note:
  2114. *
  2115. * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,
  2116. * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.
  2117. *
  2118. * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.
  2119. *
  2120. * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of
  2121. * incorrect length in some situations.
  2122. * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they
  2123. * get the Object implementation, which is slower but behaves correctly.
  2124. */
  2125. Buffer.TYPED_ARRAY_SUPPORT = global$1.TYPED_ARRAY_SUPPORT !== undefined ? global$1.TYPED_ARRAY_SUPPORT : true;
  2126. function kMaxLength() {
  2127. return Buffer.TYPED_ARRAY_SUPPORT ? 0x7fffffff : 0x3fffffff;
  2128. }
  2129. function createBuffer(that, length) {
  2130. if (kMaxLength() < length) {
  2131. throw new RangeError('Invalid typed array length');
  2132. }
  2133. if (Buffer.TYPED_ARRAY_SUPPORT) {
  2134. // Return an augmented `Uint8Array` instance, for best performance
  2135. that = new Uint8Array(length);
  2136. that.__proto__ = Buffer.prototype;
  2137. } else {
  2138. // Fallback: Return an object instance of the Buffer class
  2139. if (that === null) {
  2140. that = new Buffer(length);
  2141. }
  2142. that.length = length;
  2143. }
  2144. return that;
  2145. }
  2146. /**
  2147. * The Buffer constructor returns instances of `Uint8Array` that have their
  2148. * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
  2149. * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
  2150. * and the `Uint8Array` methods. Square bracket notation works as expected -- it
  2151. * returns a single octet.
  2152. *
  2153. * The `Uint8Array` prototype remains unmodified.
  2154. */
  2155. function Buffer(arg, encodingOrOffset, length) {
  2156. if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) {
  2157. return new Buffer(arg, encodingOrOffset, length);
  2158. } // Common case.
  2159. if (typeof arg === 'number') {
  2160. if (typeof encodingOrOffset === 'string') {
  2161. throw new Error('If encoding is specified then the first argument must be a string');
  2162. }
  2163. return allocUnsafe(this, arg);
  2164. }
  2165. return from(this, arg, encodingOrOffset, length);
  2166. }
  2167. Buffer.poolSize = 8192; // not used by this implementation
  2168. // TODO: Legacy, not needed anymore. Remove in next major version.
  2169. Buffer._augment = function (arr) {
  2170. arr.__proto__ = Buffer.prototype;
  2171. return arr;
  2172. };
  2173. function from(that, value, encodingOrOffset, length) {
  2174. if (typeof value === 'number') {
  2175. throw new TypeError('"value" argument must not be a number');
  2176. }
  2177. if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {
  2178. return fromArrayBuffer(that, value, encodingOrOffset, length);
  2179. }
  2180. if (typeof value === 'string') {
  2181. return fromString(that, value, encodingOrOffset);
  2182. }
  2183. return fromObject(that, value);
  2184. }
  2185. /**
  2186. * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
  2187. * if value is a number.
  2188. * Buffer.from(str[, encoding])
  2189. * Buffer.from(array)
  2190. * Buffer.from(buffer)
  2191. * Buffer.from(arrayBuffer[, byteOffset[, length]])
  2192. **/
  2193. Buffer.from = function (value, encodingOrOffset, length) {
  2194. return from(null, value, encodingOrOffset, length);
  2195. };
  2196. if (Buffer.TYPED_ARRAY_SUPPORT) {
  2197. Buffer.prototype.__proto__ = Uint8Array.prototype;
  2198. Buffer.__proto__ = Uint8Array;
  2199. if (typeof Symbol !== 'undefined' && Symbol.species && Buffer[Symbol.species] === Buffer) {// Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97
  2200. // Object.defineProperty(Buffer, Symbol.species, {
  2201. // value: null,
  2202. // configurable: true
  2203. // })
  2204. }
  2205. }
  2206. function assertSize(size) {
  2207. if (typeof size !== 'number') {
  2208. throw new TypeError('"size" argument must be a number');
  2209. } else if (size < 0) {
  2210. throw new RangeError('"size" argument must not be negative');
  2211. }
  2212. }
  2213. function alloc(that, size, fill, encoding) {
  2214. assertSize(size);
  2215. if (size <= 0) {
  2216. return createBuffer(that, size);
  2217. }
  2218. if (fill !== undefined) {
  2219. // Only pay attention to encoding if it's a string. This
  2220. // prevents accidentally sending in a number that would
  2221. // be interpretted as a start offset.
  2222. return typeof encoding === 'string' ? createBuffer(that, size).fill(fill, encoding) : createBuffer(that, size).fill(fill);
  2223. }
  2224. return createBuffer(that, size);
  2225. }
  2226. /**
  2227. * Creates a new filled Buffer instance.
  2228. * alloc(size[, fill[, encoding]])
  2229. **/
  2230. Buffer.alloc = function (size, fill, encoding) {
  2231. return alloc(null, size, fill, encoding);
  2232. };
  2233. function allocUnsafe(that, size) {
  2234. assertSize(size);
  2235. that = createBuffer(that, size < 0 ? 0 : checked(size) | 0);
  2236. if (!Buffer.TYPED_ARRAY_SUPPORT) {
  2237. for (var i = 0; i < size; ++i) {
  2238. that[i] = 0;
  2239. }
  2240. }
  2241. return that;
  2242. }
  2243. /**
  2244. * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
  2245. * */
  2246. Buffer.allocUnsafe = function (size) {
  2247. return allocUnsafe(null, size);
  2248. };
  2249. /**
  2250. * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
  2251. */
  2252. Buffer.allocUnsafeSlow = function (size) {
  2253. return allocUnsafe(null, size);
  2254. };
  2255. function fromString(that, string, encoding) {
  2256. if (typeof encoding !== 'string' || encoding === '') {
  2257. encoding = 'utf8';
  2258. }
  2259. if (!Buffer.isEncoding(encoding)) {
  2260. throw new TypeError('"encoding" must be a valid string encoding');
  2261. }
  2262. var length = byteLength(string, encoding) | 0;
  2263. that = createBuffer(that, length);
  2264. var actual = that.write(string, encoding);
  2265. if (actual !== length) {
  2266. // Writing a hex string, for example, that contains invalid characters will
  2267. // cause everything after the first invalid character to be ignored. (e.g.
  2268. // 'abxxcd' will be treated as 'ab')
  2269. that = that.slice(0, actual);
  2270. }
  2271. return that;
  2272. }
  2273. function fromArrayLike(that, array) {
  2274. var length = array.length < 0 ? 0 : checked(array.length) | 0;
  2275. that = createBuffer(that, length);
  2276. for (var i = 0; i < length; i += 1) {
  2277. that[i] = array[i] & 255;
  2278. }
  2279. return that;
  2280. }
  2281. function fromArrayBuffer(that, array, byteOffset, length) {
  2282. array.byteLength; // this throws if `array` is not a valid ArrayBuffer
  2283. if (byteOffset < 0 || array.byteLength < byteOffset) {
  2284. throw new RangeError('\'offset\' is out of bounds');
  2285. }
  2286. if (array.byteLength < byteOffset + (length || 0)) {
  2287. throw new RangeError('\'length\' is out of bounds');
  2288. }
  2289. if (byteOffset === undefined && length === undefined) {
  2290. array = new Uint8Array(array);
  2291. } else if (length === undefined) {
  2292. array = new Uint8Array(array, byteOffset);
  2293. } else {
  2294. array = new Uint8Array(array, byteOffset, length);
  2295. }
  2296. if (Buffer.TYPED_ARRAY_SUPPORT) {
  2297. // Return an augmented `Uint8Array` instance, for best performance
  2298. that = array;
  2299. that.__proto__ = Buffer.prototype;
  2300. } else {
  2301. // Fallback: Return an object instance of the Buffer class
  2302. that = fromArrayLike(that, array);
  2303. }
  2304. return that;
  2305. }
  2306. function fromObject(that, obj) {
  2307. if (internalIsBuffer(obj)) {
  2308. var len = checked(obj.length) | 0;
  2309. that = createBuffer(that, len);
  2310. if (that.length === 0) {
  2311. return that;
  2312. }
  2313. obj.copy(that, 0, 0, len);
  2314. return that;
  2315. }
  2316. if (obj) {
  2317. if (typeof ArrayBuffer !== 'undefined' && obj.buffer instanceof ArrayBuffer || 'length' in obj) {
  2318. if (typeof obj.length !== 'number' || isnan(obj.length)) {
  2319. return createBuffer(that, 0);
  2320. }
  2321. return fromArrayLike(that, obj);
  2322. }
  2323. if (obj.type === 'Buffer' && isArray$1(obj.data)) {
  2324. return fromArrayLike(that, obj.data);
  2325. }
  2326. }
  2327. throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.');
  2328. }
  2329. function checked(length) {
  2330. // Note: cannot use `length < kMaxLength()` here because that fails when
  2331. // length is NaN (which is otherwise coerced to zero.)
  2332. if (length >= kMaxLength()) {
  2333. throw new RangeError('Attempt to allocate Buffer larger than maximum ' + 'size: 0x' + kMaxLength().toString(16) + ' bytes');
  2334. }
  2335. return length | 0;
  2336. }
  2337. Buffer.isBuffer = isBuffer;
  2338. function internalIsBuffer(b) {
  2339. return !!(b != null && b._isBuffer);
  2340. }
  2341. Buffer.compare = function compare(a, b) {
  2342. if (!internalIsBuffer(a) || !internalIsBuffer(b)) {
  2343. throw new TypeError('Arguments must be Buffers');
  2344. }
  2345. if (a === b) return 0;
  2346. var x = a.length;
  2347. var y = b.length;
  2348. for (var i = 0, len = Math.min(x, y); i < len; ++i) {
  2349. if (a[i] !== b[i]) {
  2350. x = a[i];
  2351. y = b[i];
  2352. break;
  2353. }
  2354. }
  2355. if (x < y) return -1;
  2356. if (y < x) return 1;
  2357. return 0;
  2358. };
  2359. Buffer.isEncoding = function isEncoding(encoding) {
  2360. switch (String(encoding).toLowerCase()) {
  2361. case 'hex':
  2362. case 'utf8':
  2363. case 'utf-8':
  2364. case 'ascii':
  2365. case 'latin1':
  2366. case 'binary':
  2367. case 'base64':
  2368. case 'ucs2':
  2369. case 'ucs-2':
  2370. case 'utf16le':
  2371. case 'utf-16le':
  2372. return true;
  2373. default:
  2374. return false;
  2375. }
  2376. };
  2377. Buffer.concat = function concat(list, length) {
  2378. if (!isArray$1(list)) {
  2379. throw new TypeError('"list" argument must be an Array of Buffers');
  2380. }
  2381. if (list.length === 0) {
  2382. return Buffer.alloc(0);
  2383. }
  2384. var i;
  2385. if (length === undefined) {
  2386. length = 0;
  2387. for (i = 0; i < list.length; ++i) {
  2388. length += list[i].length;
  2389. }
  2390. }
  2391. var buffer = Buffer.allocUnsafe(length);
  2392. var pos = 0;
  2393. for (i = 0; i < list.length; ++i) {
  2394. var buf = list[i];
  2395. if (!internalIsBuffer(buf)) {
  2396. throw new TypeError('"list" argument must be an Array of Buffers');
  2397. }
  2398. buf.copy(buffer, pos);
  2399. pos += buf.length;
  2400. }
  2401. return buffer;
  2402. };
  2403. function byteLength(string, encoding) {
  2404. if (internalIsBuffer(string)) {
  2405. return string.length;
  2406. }
  2407. if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' && (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {
  2408. return string.byteLength;
  2409. }
  2410. if (typeof string !== 'string') {
  2411. string = '' + string;
  2412. }
  2413. var len = string.length;
  2414. if (len === 0) return 0; // Use a for loop to avoid recursion
  2415. var loweredCase = false;
  2416. for (;;) {
  2417. switch (encoding) {
  2418. case 'ascii':
  2419. case 'latin1':
  2420. case 'binary':
  2421. return len;
  2422. case 'utf8':
  2423. case 'utf-8':
  2424. case undefined:
  2425. return utf8ToBytes(string).length;
  2426. case 'ucs2':
  2427. case 'ucs-2':
  2428. case 'utf16le':
  2429. case 'utf-16le':
  2430. return len * 2;
  2431. case 'hex':
  2432. return len >>> 1;
  2433. case 'base64':
  2434. return base64ToBytes(string).length;
  2435. default:
  2436. if (loweredCase) return utf8ToBytes(string).length; // assume utf8
  2437. encoding = ('' + encoding).toLowerCase();
  2438. loweredCase = true;
  2439. }
  2440. }
  2441. }
  2442. Buffer.byteLength = byteLength;
  2443. function slowToString(encoding, start, end) {
  2444. var loweredCase = false; // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
  2445. // property of a typed array.
  2446. // This behaves neither like String nor Uint8Array in that we set start/end
  2447. // to their upper/lower bounds if the value passed is out of range.
  2448. // undefined is handled specially as per ECMA-262 6th Edition,
  2449. // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
  2450. if (start === undefined || start < 0) {
  2451. start = 0;
  2452. } // Return early if start > this.length. Done here to prevent potential uint32
  2453. // coercion fail below.
  2454. if (start > this.length) {
  2455. return '';
  2456. }
  2457. if (end === undefined || end > this.length) {
  2458. end = this.length;
  2459. }
  2460. if (end <= 0) {
  2461. return '';
  2462. } // Force coersion to uint32. This will also coerce falsey/NaN values to 0.
  2463. end >>>= 0;
  2464. start >>>= 0;
  2465. if (end <= start) {
  2466. return '';
  2467. }
  2468. if (!encoding) encoding = 'utf8';
  2469. while (true) {
  2470. switch (encoding) {
  2471. case 'hex':
  2472. return hexSlice(this, start, end);
  2473. case 'utf8':
  2474. case 'utf-8':
  2475. return utf8Slice(this, start, end);
  2476. case 'ascii':
  2477. return asciiSlice(this, start, end);
  2478. case 'latin1':
  2479. case 'binary':
  2480. return latin1Slice(this, start, end);
  2481. case 'base64':
  2482. return base64Slice(this, start, end);
  2483. case 'ucs2':
  2484. case 'ucs-2':
  2485. case 'utf16le':
  2486. case 'utf-16le':
  2487. return utf16leSlice(this, start, end);
  2488. default:
  2489. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding);
  2490. encoding = (encoding + '').toLowerCase();
  2491. loweredCase = true;
  2492. }
  2493. }
  2494. } // The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect
  2495. // Buffer instances.
  2496. Buffer.prototype._isBuffer = true;
  2497. function swap(b, n, m) {
  2498. var i = b[n];
  2499. b[n] = b[m];
  2500. b[m] = i;
  2501. }
  2502. Buffer.prototype.swap16 = function swap16() {
  2503. var len = this.length;
  2504. if (len % 2 !== 0) {
  2505. throw new RangeError('Buffer size must be a multiple of 16-bits');
  2506. }
  2507. for (var i = 0; i < len; i += 2) {
  2508. swap(this, i, i + 1);
  2509. }
  2510. return this;
  2511. };
  2512. Buffer.prototype.swap32 = function swap32() {
  2513. var len = this.length;
  2514. if (len % 4 !== 0) {
  2515. throw new RangeError('Buffer size must be a multiple of 32-bits');
  2516. }
  2517. for (var i = 0; i < len; i += 4) {
  2518. swap(this, i, i + 3);
  2519. swap(this, i + 1, i + 2);
  2520. }
  2521. return this;
  2522. };
  2523. Buffer.prototype.swap64 = function swap64() {
  2524. var len = this.length;
  2525. if (len % 8 !== 0) {
  2526. throw new RangeError('Buffer size must be a multiple of 64-bits');
  2527. }
  2528. for (var i = 0; i < len; i += 8) {
  2529. swap(this, i, i + 7);
  2530. swap(this, i + 1, i + 6);
  2531. swap(this, i + 2, i + 5);
  2532. swap(this, i + 3, i + 4);
  2533. }
  2534. return this;
  2535. };
  2536. Buffer.prototype.toString = function toString() {
  2537. var length = this.length | 0;
  2538. if (length === 0) return '';
  2539. if (arguments.length === 0) return utf8Slice(this, 0, length);
  2540. return slowToString.apply(this, arguments);
  2541. };
  2542. Buffer.prototype.equals = function equals(b) {
  2543. if (!internalIsBuffer(b)) throw new TypeError('Argument must be a Buffer');
  2544. if (this === b) return true;
  2545. return Buffer.compare(this, b) === 0;
  2546. };
  2547. Buffer.prototype.inspect = function inspect() {
  2548. var str = '';
  2549. var max = INSPECT_MAX_BYTES;
  2550. if (this.length > 0) {
  2551. str = this.toString('hex', 0, max).match(/.{2}/g).join(' ');
  2552. if (this.length > max) str += ' ... ';
  2553. }
  2554. return '<Buffer ' + str + '>';
  2555. };
  2556. Buffer.prototype.compare = function compare(target, start, end, thisStart, thisEnd) {
  2557. if (!internalIsBuffer(target)) {
  2558. throw new TypeError('Argument must be a Buffer');
  2559. }
  2560. if (start === undefined) {
  2561. start = 0;
  2562. }
  2563. if (end === undefined) {
  2564. end = target ? target.length : 0;
  2565. }
  2566. if (thisStart === undefined) {
  2567. thisStart = 0;
  2568. }
  2569. if (thisEnd === undefined) {
  2570. thisEnd = this.length;
  2571. }
  2572. if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
  2573. throw new RangeError('out of range index');
  2574. }
  2575. if (thisStart >= thisEnd && start >= end) {
  2576. return 0;
  2577. }
  2578. if (thisStart >= thisEnd) {
  2579. return -1;
  2580. }
  2581. if (start >= end) {
  2582. return 1;
  2583. }
  2584. start >>>= 0;
  2585. end >>>= 0;
  2586. thisStart >>>= 0;
  2587. thisEnd >>>= 0;
  2588. if (this === target) return 0;
  2589. var x = thisEnd - thisStart;
  2590. var y = end - start;
  2591. var len = Math.min(x, y);
  2592. var thisCopy = this.slice(thisStart, thisEnd);
  2593. var targetCopy = target.slice(start, end);
  2594. for (var i = 0; i < len; ++i) {
  2595. if (thisCopy[i] !== targetCopy[i]) {
  2596. x = thisCopy[i];
  2597. y = targetCopy[i];
  2598. break;
  2599. }
  2600. }
  2601. if (x < y) return -1;
  2602. if (y < x) return 1;
  2603. return 0;
  2604. }; // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
  2605. // OR the last index of `val` in `buffer` at offset <= `byteOffset`.
  2606. //
  2607. // Arguments:
  2608. // - buffer - a Buffer to search
  2609. // - val - a string, Buffer, or number
  2610. // - byteOffset - an index into `buffer`; will be clamped to an int32
  2611. // - encoding - an optional encoding, relevant is val is a string
  2612. // - dir - true for indexOf, false for lastIndexOf
  2613. function bidirectionalIndexOf(buffer, val, byteOffset, encoding, dir) {
  2614. // Empty buffer means no match
  2615. if (buffer.length === 0) return -1; // Normalize byteOffset
  2616. if (typeof byteOffset === 'string') {
  2617. encoding = byteOffset;
  2618. byteOffset = 0;
  2619. } else if (byteOffset > 0x7fffffff) {
  2620. byteOffset = 0x7fffffff;
  2621. } else if (byteOffset < -0x80000000) {
  2622. byteOffset = -0x80000000;
  2623. }
  2624. byteOffset = +byteOffset; // Coerce to Number.
  2625. if (isNaN(byteOffset)) {
  2626. // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
  2627. byteOffset = dir ? 0 : buffer.length - 1;
  2628. } // Normalize byteOffset: negative offsets start from the end of the buffer
  2629. if (byteOffset < 0) byteOffset = buffer.length + byteOffset;
  2630. if (byteOffset >= buffer.length) {
  2631. if (dir) return -1;else byteOffset = buffer.length - 1;
  2632. } else if (byteOffset < 0) {
  2633. if (dir) byteOffset = 0;else return -1;
  2634. } // Normalize val
  2635. if (typeof val === 'string') {
  2636. val = Buffer.from(val, encoding);
  2637. } // Finally, search either indexOf (if dir is true) or lastIndexOf
  2638. if (internalIsBuffer(val)) {
  2639. // Special case: looking for empty string/buffer always fails
  2640. if (val.length === 0) {
  2641. return -1;
  2642. }
  2643. return arrayIndexOf(buffer, val, byteOffset, encoding, dir);
  2644. } else if (typeof val === 'number') {
  2645. val = val & 0xFF; // Search for a byte value [0-255]
  2646. if (Buffer.TYPED_ARRAY_SUPPORT && typeof Uint8Array.prototype.indexOf === 'function') {
  2647. if (dir) {
  2648. return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset);
  2649. } else {
  2650. return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset);
  2651. }
  2652. }
  2653. return arrayIndexOf(buffer, [val], byteOffset, encoding, dir);
  2654. }
  2655. throw new TypeError('val must be string, number or Buffer');
  2656. }
  2657. function arrayIndexOf(arr, val, byteOffset, encoding, dir) {
  2658. var indexSize = 1;
  2659. var arrLength = arr.length;
  2660. var valLength = val.length;
  2661. if (encoding !== undefined) {
  2662. encoding = String(encoding).toLowerCase();
  2663. if (encoding === 'ucs2' || encoding === 'ucs-2' || encoding === 'utf16le' || encoding === 'utf-16le') {
  2664. if (arr.length < 2 || val.length < 2) {
  2665. return -1;
  2666. }
  2667. indexSize = 2;
  2668. arrLength /= 2;
  2669. valLength /= 2;
  2670. byteOffset /= 2;
  2671. }
  2672. }
  2673. function read$$1(buf, i) {
  2674. if (indexSize === 1) {
  2675. return buf[i];
  2676. } else {
  2677. return buf.readUInt16BE(i * indexSize);
  2678. }
  2679. }
  2680. var i;
  2681. if (dir) {
  2682. var foundIndex = -1;
  2683. for (i = byteOffset; i < arrLength; i++) {
  2684. if (read$$1(arr, i) === read$$1(val, foundIndex === -1 ? 0 : i - foundIndex)) {
  2685. if (foundIndex === -1) foundIndex = i;
  2686. if (i - foundIndex + 1 === valLength) return foundIndex * indexSize;
  2687. } else {
  2688. if (foundIndex !== -1) i -= i - foundIndex;
  2689. foundIndex = -1;
  2690. }
  2691. }
  2692. } else {
  2693. if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength;
  2694. for (i = byteOffset; i >= 0; i--) {
  2695. var found = true;
  2696. for (var j = 0; j < valLength; j++) {
  2697. if (read$$1(arr, i + j) !== read$$1(val, j)) {
  2698. found = false;
  2699. break;
  2700. }
  2701. }
  2702. if (found) return i;
  2703. }
  2704. }
  2705. return -1;
  2706. }
  2707. Buffer.prototype.includes = function includes(val, byteOffset, encoding) {
  2708. return this.indexOf(val, byteOffset, encoding) !== -1;
  2709. };
  2710. Buffer.prototype.indexOf = function indexOf(val, byteOffset, encoding) {
  2711. return bidirectionalIndexOf(this, val, byteOffset, encoding, true);
  2712. };
  2713. Buffer.prototype.lastIndexOf = function lastIndexOf(val, byteOffset, encoding) {
  2714. return bidirectionalIndexOf(this, val, byteOffset, encoding, false);
  2715. };
  2716. function hexWrite(buf, string, offset, length) {
  2717. offset = Number(offset) || 0;
  2718. var remaining = buf.length - offset;
  2719. if (!length) {
  2720. length = remaining;
  2721. } else {
  2722. length = Number(length);
  2723. if (length > remaining) {
  2724. length = remaining;
  2725. }
  2726. } // must be an even number of digits
  2727. var strLen = string.length;
  2728. if (strLen % 2 !== 0) throw new TypeError('Invalid hex string');
  2729. if (length > strLen / 2) {
  2730. length = strLen / 2;
  2731. }
  2732. for (var i = 0; i < length; ++i) {
  2733. var parsed = parseInt(string.substr(i * 2, 2), 16);
  2734. if (isNaN(parsed)) return i;
  2735. buf[offset + i] = parsed;
  2736. }
  2737. return i;
  2738. }
  2739. function utf8Write(buf, string, offset, length) {
  2740. return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length);
  2741. }
  2742. function asciiWrite(buf, string, offset, length) {
  2743. return blitBuffer(asciiToBytes(string), buf, offset, length);
  2744. }
  2745. function latin1Write(buf, string, offset, length) {
  2746. return asciiWrite(buf, string, offset, length);
  2747. }
  2748. function base64Write(buf, string, offset, length) {
  2749. return blitBuffer(base64ToBytes(string), buf, offset, length);
  2750. }
  2751. function ucs2Write(buf, string, offset, length) {
  2752. return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length);
  2753. }
  2754. Buffer.prototype.write = function write$$1(string, offset, length, encoding) {
  2755. // Buffer#write(string)
  2756. if (offset === undefined) {
  2757. encoding = 'utf8';
  2758. length = this.length;
  2759. offset = 0; // Buffer#write(string, encoding)
  2760. } else if (length === undefined && typeof offset === 'string') {
  2761. encoding = offset;
  2762. length = this.length;
  2763. offset = 0; // Buffer#write(string, offset[, length][, encoding])
  2764. } else if (isFinite(offset)) {
  2765. offset = offset | 0;
  2766. if (isFinite(length)) {
  2767. length = length | 0;
  2768. if (encoding === undefined) encoding = 'utf8';
  2769. } else {
  2770. encoding = length;
  2771. length = undefined;
  2772. } // legacy write(string, encoding, offset, length) - remove in v0.13
  2773. } else {
  2774. throw new Error('Buffer.write(string, encoding, offset[, length]) is no longer supported');
  2775. }
  2776. var remaining = this.length - offset;
  2777. if (length === undefined || length > remaining) length = remaining;
  2778. if (string.length > 0 && (length < 0 || offset < 0) || offset > this.length) {
  2779. throw new RangeError('Attempt to write outside buffer bounds');
  2780. }
  2781. if (!encoding) encoding = 'utf8';
  2782. var loweredCase = false;
  2783. for (;;) {
  2784. switch (encoding) {
  2785. case 'hex':
  2786. return hexWrite(this, string, offset, length);
  2787. case 'utf8':
  2788. case 'utf-8':
  2789. return utf8Write(this, string, offset, length);
  2790. case 'ascii':
  2791. return asciiWrite(this, string, offset, length);
  2792. case 'latin1':
  2793. case 'binary':
  2794. return latin1Write(this, string, offset, length);
  2795. case 'base64':
  2796. // Warning: maxLength not taken into account in base64Write
  2797. return base64Write(this, string, offset, length);
  2798. case 'ucs2':
  2799. case 'ucs-2':
  2800. case 'utf16le':
  2801. case 'utf-16le':
  2802. return ucs2Write(this, string, offset, length);
  2803. default:
  2804. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding);
  2805. encoding = ('' + encoding).toLowerCase();
  2806. loweredCase = true;
  2807. }
  2808. }
  2809. };
  2810. Buffer.prototype.toJSON = function toJSON() {
  2811. return {
  2812. type: 'Buffer',
  2813. data: Array.prototype.slice.call(this._arr || this, 0)
  2814. };
  2815. };
  2816. function base64Slice(buf, start, end) {
  2817. if (start === 0 && end === buf.length) {
  2818. return fromByteArray(buf);
  2819. } else {
  2820. return fromByteArray(buf.slice(start, end));
  2821. }
  2822. }
  2823. function utf8Slice(buf, start, end) {
  2824. end = Math.min(buf.length, end);
  2825. var res = [];
  2826. var i = start;
  2827. while (i < end) {
  2828. var firstByte = buf[i];
  2829. var codePoint = null;
  2830. var bytesPerSequence = firstByte > 0xEF ? 4 : firstByte > 0xDF ? 3 : firstByte > 0xBF ? 2 : 1;
  2831. if (i + bytesPerSequence <= end) {
  2832. var secondByte, thirdByte, fourthByte, tempCodePoint;
  2833. switch (bytesPerSequence) {
  2834. case 1:
  2835. if (firstByte < 0x80) {
  2836. codePoint = firstByte;
  2837. }
  2838. break;
  2839. case 2:
  2840. secondByte = buf[i + 1];
  2841. if ((secondByte & 0xC0) === 0x80) {
  2842. tempCodePoint = (firstByte & 0x1F) << 0x6 | secondByte & 0x3F;
  2843. if (tempCodePoint > 0x7F) {
  2844. codePoint = tempCodePoint;
  2845. }
  2846. }
  2847. break;
  2848. case 3:
  2849. secondByte = buf[i + 1];
  2850. thirdByte = buf[i + 2];
  2851. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
  2852. tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | thirdByte & 0x3F;
  2853. if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
  2854. codePoint = tempCodePoint;
  2855. }
  2856. }
  2857. break;
  2858. case 4:
  2859. secondByte = buf[i + 1];
  2860. thirdByte = buf[i + 2];
  2861. fourthByte = buf[i + 3];
  2862. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
  2863. tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | fourthByte & 0x3F;
  2864. if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
  2865. codePoint = tempCodePoint;
  2866. }
  2867. }
  2868. }
  2869. }
  2870. if (codePoint === null) {
  2871. // we did not generate a valid codePoint so insert a
  2872. // replacement char (U+FFFD) and advance only 1 byte
  2873. codePoint = 0xFFFD;
  2874. bytesPerSequence = 1;
  2875. } else if (codePoint > 0xFFFF) {
  2876. // encode to utf16 (surrogate pair dance)
  2877. codePoint -= 0x10000;
  2878. res.push(codePoint >>> 10 & 0x3FF | 0xD800);
  2879. codePoint = 0xDC00 | codePoint & 0x3FF;
  2880. }
  2881. res.push(codePoint);
  2882. i += bytesPerSequence;
  2883. }
  2884. return decodeCodePointsArray(res);
  2885. } // Based on http://stackoverflow.com/a/22747272/680742, the browser with
  2886. // the lowest limit is Chrome, with 0x10000 args.
  2887. // We go 1 magnitude less, for safety
  2888. var MAX_ARGUMENTS_LENGTH = 0x1000;
  2889. function decodeCodePointsArray(codePoints) {
  2890. var len = codePoints.length;
  2891. if (len <= MAX_ARGUMENTS_LENGTH) {
  2892. return String.fromCharCode.apply(String, codePoints); // avoid extra slice()
  2893. } // Decode in chunks to avoid "call stack size exceeded".
  2894. var res = '';
  2895. var i = 0;
  2896. while (i < len) {
  2897. res += String.fromCharCode.apply(String, codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH));
  2898. }
  2899. return res;
  2900. }
  2901. function asciiSlice(buf, start, end) {
  2902. var ret = '';
  2903. end = Math.min(buf.length, end);
  2904. for (var i = start; i < end; ++i) {
  2905. ret += String.fromCharCode(buf[i] & 0x7F);
  2906. }
  2907. return ret;
  2908. }
  2909. function latin1Slice(buf, start, end) {
  2910. var ret = '';
  2911. end = Math.min(buf.length, end);
  2912. for (var i = start; i < end; ++i) {
  2913. ret += String.fromCharCode(buf[i]);
  2914. }
  2915. return ret;
  2916. }
  2917. function hexSlice(buf, start, end) {
  2918. var len = buf.length;
  2919. if (!start || start < 0) start = 0;
  2920. if (!end || end < 0 || end > len) end = len;
  2921. var out = '';
  2922. for (var i = start; i < end; ++i) {
  2923. out += toHex(buf[i]);
  2924. }
  2925. return out;
  2926. }
  2927. function utf16leSlice(buf, start, end) {
  2928. var bytes = buf.slice(start, end);
  2929. var res = '';
  2930. for (var i = 0; i < bytes.length; i += 2) {
  2931. res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256);
  2932. }
  2933. return res;
  2934. }
  2935. Buffer.prototype.slice = function slice(start, end) {
  2936. var len = this.length;
  2937. start = ~~start;
  2938. end = end === undefined ? len : ~~end;
  2939. if (start < 0) {
  2940. start += len;
  2941. if (start < 0) start = 0;
  2942. } else if (start > len) {
  2943. start = len;
  2944. }
  2945. if (end < 0) {
  2946. end += len;
  2947. if (end < 0) end = 0;
  2948. } else if (end > len) {
  2949. end = len;
  2950. }
  2951. if (end < start) end = start;
  2952. var newBuf;
  2953. if (Buffer.TYPED_ARRAY_SUPPORT) {
  2954. newBuf = this.subarray(start, end);
  2955. newBuf.__proto__ = Buffer.prototype;
  2956. } else {
  2957. var sliceLen = end - start;
  2958. newBuf = new Buffer(sliceLen, undefined);
  2959. for (var i = 0; i < sliceLen; ++i) {
  2960. newBuf[i] = this[i + start];
  2961. }
  2962. }
  2963. return newBuf;
  2964. };
  2965. /*
  2966. * Need to make sure that buffer isn't trying to write out of bounds.
  2967. */
  2968. function checkOffset(offset, ext, length) {
  2969. if (offset % 1 !== 0 || offset < 0) throw new RangeError('offset is not uint');
  2970. if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length');
  2971. }
  2972. Buffer.prototype.readUIntLE = function readUIntLE(offset, byteLength, noAssert) {
  2973. offset = offset | 0;
  2974. byteLength = byteLength | 0;
  2975. if (!noAssert) checkOffset(offset, byteLength, this.length);
  2976. var val = this[offset];
  2977. var mul = 1;
  2978. var i = 0;
  2979. while (++i < byteLength && (mul *= 0x100)) {
  2980. val += this[offset + i] * mul;
  2981. }
  2982. return val;
  2983. };
  2984. Buffer.prototype.readUIntBE = function readUIntBE(offset, byteLength, noAssert) {
  2985. offset = offset | 0;
  2986. byteLength = byteLength | 0;
  2987. if (!noAssert) {
  2988. checkOffset(offset, byteLength, this.length);
  2989. }
  2990. var val = this[offset + --byteLength];
  2991. var mul = 1;
  2992. while (byteLength > 0 && (mul *= 0x100)) {
  2993. val += this[offset + --byteLength] * mul;
  2994. }
  2995. return val;
  2996. };
  2997. Buffer.prototype.readUInt8 = function readUInt8(offset, noAssert) {
  2998. if (!noAssert) checkOffset(offset, 1, this.length);
  2999. return this[offset];
  3000. };
  3001. Buffer.prototype.readUInt16LE = function readUInt16LE(offset, noAssert) {
  3002. if (!noAssert) checkOffset(offset, 2, this.length);
  3003. return this[offset] | this[offset + 1] << 8;
  3004. };
  3005. Buffer.prototype.readUInt16BE = function readUInt16BE(offset, noAssert) {
  3006. if (!noAssert) checkOffset(offset, 2, this.length);
  3007. return this[offset] << 8 | this[offset + 1];
  3008. };
  3009. Buffer.prototype.readUInt32LE = function readUInt32LE(offset, noAssert) {
  3010. if (!noAssert) checkOffset(offset, 4, this.length);
  3011. return (this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16) + this[offset + 3] * 0x1000000;
  3012. };
  3013. Buffer.prototype.readUInt32BE = function readUInt32BE(offset, noAssert) {
  3014. if (!noAssert) checkOffset(offset, 4, this.length);
  3015. return this[offset] * 0x1000000 + (this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3]);
  3016. };
  3017. Buffer.prototype.readIntLE = function readIntLE(offset, byteLength, noAssert) {
  3018. offset = offset | 0;
  3019. byteLength = byteLength | 0;
  3020. if (!noAssert) checkOffset(offset, byteLength, this.length);
  3021. var val = this[offset];
  3022. var mul = 1;
  3023. var i = 0;
  3024. while (++i < byteLength && (mul *= 0x100)) {
  3025. val += this[offset + i] * mul;
  3026. }
  3027. mul *= 0x80;
  3028. if (val >= mul) val -= Math.pow(2, 8 * byteLength);
  3029. return val;
  3030. };
  3031. Buffer.prototype.readIntBE = function readIntBE(offset, byteLength, noAssert) {
  3032. offset = offset | 0;
  3033. byteLength = byteLength | 0;
  3034. if (!noAssert) checkOffset(offset, byteLength, this.length);
  3035. var i = byteLength;
  3036. var mul = 1;
  3037. var val = this[offset + --i];
  3038. while (i > 0 && (mul *= 0x100)) {
  3039. val += this[offset + --i] * mul;
  3040. }
  3041. mul *= 0x80;
  3042. if (val >= mul) val -= Math.pow(2, 8 * byteLength);
  3043. return val;
  3044. };
  3045. Buffer.prototype.readInt8 = function readInt8(offset, noAssert) {
  3046. if (!noAssert) checkOffset(offset, 1, this.length);
  3047. if (!(this[offset] & 0x80)) return this[offset];
  3048. return (0xff - this[offset] + 1) * -1;
  3049. };
  3050. Buffer.prototype.readInt16LE = function readInt16LE(offset, noAssert) {
  3051. if (!noAssert) checkOffset(offset, 2, this.length);
  3052. var val = this[offset] | this[offset + 1] << 8;
  3053. return val & 0x8000 ? val | 0xFFFF0000 : val;
  3054. };
  3055. Buffer.prototype.readInt16BE = function readInt16BE(offset, noAssert) {
  3056. if (!noAssert) checkOffset(offset, 2, this.length);
  3057. var val = this[offset + 1] | this[offset] << 8;
  3058. return val & 0x8000 ? val | 0xFFFF0000 : val;
  3059. };
  3060. Buffer.prototype.readInt32LE = function readInt32LE(offset, noAssert) {
  3061. if (!noAssert) checkOffset(offset, 4, this.length);
  3062. return this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16 | this[offset + 3] << 24;
  3063. };
  3064. Buffer.prototype.readInt32BE = function readInt32BE(offset, noAssert) {
  3065. if (!noAssert) checkOffset(offset, 4, this.length);
  3066. return this[offset] << 24 | this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3];
  3067. };
  3068. Buffer.prototype.readFloatLE = function readFloatLE(offset, noAssert) {
  3069. if (!noAssert) checkOffset(offset, 4, this.length);
  3070. return read(this, offset, true, 23, 4);
  3071. };
  3072. Buffer.prototype.readFloatBE = function readFloatBE(offset, noAssert) {
  3073. if (!noAssert) checkOffset(offset, 4, this.length);
  3074. return read(this, offset, false, 23, 4);
  3075. };
  3076. Buffer.prototype.readDoubleLE = function readDoubleLE(offset, noAssert) {
  3077. if (!noAssert) checkOffset(offset, 8, this.length);
  3078. return read(this, offset, true, 52, 8);
  3079. };
  3080. Buffer.prototype.readDoubleBE = function readDoubleBE(offset, noAssert) {
  3081. if (!noAssert) checkOffset(offset, 8, this.length);
  3082. return read(this, offset, false, 52, 8);
  3083. };
  3084. function checkInt(buf, value, offset, ext, max, min) {
  3085. if (!internalIsBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance');
  3086. if (value > max || value < min) throw new RangeError('"value" argument is out of bounds');
  3087. if (offset + ext > buf.length) throw new RangeError('Index out of range');
  3088. }
  3089. Buffer.prototype.writeUIntLE = function writeUIntLE(value, offset, byteLength, noAssert) {
  3090. value = +value;
  3091. offset = offset | 0;
  3092. byteLength = byteLength | 0;
  3093. if (!noAssert) {
  3094. var maxBytes = Math.pow(2, 8 * byteLength) - 1;
  3095. checkInt(this, value, offset, byteLength, maxBytes, 0);
  3096. }
  3097. var mul = 1;
  3098. var i = 0;
  3099. this[offset] = value & 0xFF;
  3100. while (++i < byteLength && (mul *= 0x100)) {
  3101. this[offset + i] = value / mul & 0xFF;
  3102. }
  3103. return offset + byteLength;
  3104. };
  3105. Buffer.prototype.writeUIntBE = function writeUIntBE(value, offset, byteLength, noAssert) {
  3106. value = +value;
  3107. offset = offset | 0;
  3108. byteLength = byteLength | 0;
  3109. if (!noAssert) {
  3110. var maxBytes = Math.pow(2, 8 * byteLength) - 1;
  3111. checkInt(this, value, offset, byteLength, maxBytes, 0);
  3112. }
  3113. var i = byteLength - 1;
  3114. var mul = 1;
  3115. this[offset + i] = value & 0xFF;
  3116. while (--i >= 0 && (mul *= 0x100)) {
  3117. this[offset + i] = value / mul & 0xFF;
  3118. }
  3119. return offset + byteLength;
  3120. };
  3121. Buffer.prototype.writeUInt8 = function writeUInt8(value, offset, noAssert) {
  3122. value = +value;
  3123. offset = offset | 0;
  3124. if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0);
  3125. if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value);
  3126. this[offset] = value & 0xff;
  3127. return offset + 1;
  3128. };
  3129. function objectWriteUInt16(buf, value, offset, littleEndian) {
  3130. if (value < 0) value = 0xffff + value + 1;
  3131. for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) {
  3132. buf[offset + i] = (value & 0xff << 8 * (littleEndian ? i : 1 - i)) >>> (littleEndian ? i : 1 - i) * 8;
  3133. }
  3134. }
  3135. Buffer.prototype.writeUInt16LE = function writeUInt16LE(value, offset, noAssert) {
  3136. value = +value;
  3137. offset = offset | 0;
  3138. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0);
  3139. if (Buffer.TYPED_ARRAY_SUPPORT) {
  3140. this[offset] = value & 0xff;
  3141. this[offset + 1] = value >>> 8;
  3142. } else {
  3143. objectWriteUInt16(this, value, offset, true);
  3144. }
  3145. return offset + 2;
  3146. };
  3147. Buffer.prototype.writeUInt16BE = function writeUInt16BE(value, offset, noAssert) {
  3148. value = +value;
  3149. offset = offset | 0;
  3150. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0);
  3151. if (Buffer.TYPED_ARRAY_SUPPORT) {
  3152. this[offset] = value >>> 8;
  3153. this[offset + 1] = value & 0xff;
  3154. } else {
  3155. objectWriteUInt16(this, value, offset, false);
  3156. }
  3157. return offset + 2;
  3158. };
  3159. function objectWriteUInt32(buf, value, offset, littleEndian) {
  3160. if (value < 0) value = 0xffffffff + value + 1;
  3161. for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) {
  3162. buf[offset + i] = value >>> (littleEndian ? i : 3 - i) * 8 & 0xff;
  3163. }
  3164. }
  3165. Buffer.prototype.writeUInt32LE = function writeUInt32LE(value, offset, noAssert) {
  3166. value = +value;
  3167. offset = offset | 0;
  3168. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0);
  3169. if (Buffer.TYPED_ARRAY_SUPPORT) {
  3170. this[offset + 3] = value >>> 24;
  3171. this[offset + 2] = value >>> 16;
  3172. this[offset + 1] = value >>> 8;
  3173. this[offset] = value & 0xff;
  3174. } else {
  3175. objectWriteUInt32(this, value, offset, true);
  3176. }
  3177. return offset + 4;
  3178. };
  3179. Buffer.prototype.writeUInt32BE = function writeUInt32BE(value, offset, noAssert) {
  3180. value = +value;
  3181. offset = offset | 0;
  3182. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0);
  3183. if (Buffer.TYPED_ARRAY_SUPPORT) {
  3184. this[offset] = value >>> 24;
  3185. this[offset + 1] = value >>> 16;
  3186. this[offset + 2] = value >>> 8;
  3187. this[offset + 3] = value & 0xff;
  3188. } else {
  3189. objectWriteUInt32(this, value, offset, false);
  3190. }
  3191. return offset + 4;
  3192. };
  3193. Buffer.prototype.writeIntLE = function writeIntLE(value, offset, byteLength, noAssert) {
  3194. value = +value;
  3195. offset = offset | 0;
  3196. if (!noAssert) {
  3197. var limit = Math.pow(2, 8 * byteLength - 1);
  3198. checkInt(this, value, offset, byteLength, limit - 1, -limit);
  3199. }
  3200. var i = 0;
  3201. var mul = 1;
  3202. var sub = 0;
  3203. this[offset] = value & 0xFF;
  3204. while (++i < byteLength && (mul *= 0x100)) {
  3205. if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
  3206. sub = 1;
  3207. }
  3208. this[offset + i] = (value / mul >> 0) - sub & 0xFF;
  3209. }
  3210. return offset + byteLength;
  3211. };
  3212. Buffer.prototype.writeIntBE = function writeIntBE(value, offset, byteLength, noAssert) {
  3213. value = +value;
  3214. offset = offset | 0;
  3215. if (!noAssert) {
  3216. var limit = Math.pow(2, 8 * byteLength - 1);
  3217. checkInt(this, value, offset, byteLength, limit - 1, -limit);
  3218. }
  3219. var i = byteLength - 1;
  3220. var mul = 1;
  3221. var sub = 0;
  3222. this[offset + i] = value & 0xFF;
  3223. while (--i >= 0 && (mul *= 0x100)) {
  3224. if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
  3225. sub = 1;
  3226. }
  3227. this[offset + i] = (value / mul >> 0) - sub & 0xFF;
  3228. }
  3229. return offset + byteLength;
  3230. };
  3231. Buffer.prototype.writeInt8 = function writeInt8(value, offset, noAssert) {
  3232. value = +value;
  3233. offset = offset | 0;
  3234. if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80);
  3235. if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value);
  3236. if (value < 0) value = 0xff + value + 1;
  3237. this[offset] = value & 0xff;
  3238. return offset + 1;
  3239. };
  3240. Buffer.prototype.writeInt16LE = function writeInt16LE(value, offset, noAssert) {
  3241. value = +value;
  3242. offset = offset | 0;
  3243. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000);
  3244. if (Buffer.TYPED_ARRAY_SUPPORT) {
  3245. this[offset] = value & 0xff;
  3246. this[offset + 1] = value >>> 8;
  3247. } else {
  3248. objectWriteUInt16(this, value, offset, true);
  3249. }
  3250. return offset + 2;
  3251. };
  3252. Buffer.prototype.writeInt16BE = function writeInt16BE(value, offset, noAssert) {
  3253. value = +value;
  3254. offset = offset | 0;
  3255. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000);
  3256. if (Buffer.TYPED_ARRAY_SUPPORT) {
  3257. this[offset] = value >>> 8;
  3258. this[offset + 1] = value & 0xff;
  3259. } else {
  3260. objectWriteUInt16(this, value, offset, false);
  3261. }
  3262. return offset + 2;
  3263. };
  3264. Buffer.prototype.writeInt32LE = function writeInt32LE(value, offset, noAssert) {
  3265. value = +value;
  3266. offset = offset | 0;
  3267. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000);
  3268. if (Buffer.TYPED_ARRAY_SUPPORT) {
  3269. this[offset] = value & 0xff;
  3270. this[offset + 1] = value >>> 8;
  3271. this[offset + 2] = value >>> 16;
  3272. this[offset + 3] = value >>> 24;
  3273. } else {
  3274. objectWriteUInt32(this, value, offset, true);
  3275. }
  3276. return offset + 4;
  3277. };
  3278. Buffer.prototype.writeInt32BE = function writeInt32BE(value, offset, noAssert) {
  3279. value = +value;
  3280. offset = offset | 0;
  3281. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000);
  3282. if (value < 0) value = 0xffffffff + value + 1;
  3283. if (Buffer.TYPED_ARRAY_SUPPORT) {
  3284. this[offset] = value >>> 24;
  3285. this[offset + 1] = value >>> 16;
  3286. this[offset + 2] = value >>> 8;
  3287. this[offset + 3] = value & 0xff;
  3288. } else {
  3289. objectWriteUInt32(this, value, offset, false);
  3290. }
  3291. return offset + 4;
  3292. };
  3293. function checkIEEE754(buf, value, offset, ext, max, min) {
  3294. if (offset + ext > buf.length) throw new RangeError('Index out of range');
  3295. if (offset < 0) throw new RangeError('Index out of range');
  3296. }
  3297. function writeFloat(buf, value, offset, littleEndian, noAssert) {
  3298. if (!noAssert) {
  3299. checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38);
  3300. }
  3301. write(buf, value, offset, littleEndian, 23, 4);
  3302. return offset + 4;
  3303. }
  3304. Buffer.prototype.writeFloatLE = function writeFloatLE(value, offset, noAssert) {
  3305. return writeFloat(this, value, offset, true, noAssert);
  3306. };
  3307. Buffer.prototype.writeFloatBE = function writeFloatBE(value, offset, noAssert) {
  3308. return writeFloat(this, value, offset, false, noAssert);
  3309. };
  3310. function writeDouble(buf, value, offset, littleEndian, noAssert) {
  3311. if (!noAssert) {
  3312. checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308);
  3313. }
  3314. write(buf, value, offset, littleEndian, 52, 8);
  3315. return offset + 8;
  3316. }
  3317. Buffer.prototype.writeDoubleLE = function writeDoubleLE(value, offset, noAssert) {
  3318. return writeDouble(this, value, offset, true, noAssert);
  3319. };
  3320. Buffer.prototype.writeDoubleBE = function writeDoubleBE(value, offset, noAssert) {
  3321. return writeDouble(this, value, offset, false, noAssert);
  3322. }; // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
  3323. Buffer.prototype.copy = function copy(target, targetStart, start, end) {
  3324. if (!start) start = 0;
  3325. if (!end && end !== 0) end = this.length;
  3326. if (targetStart >= target.length) targetStart = target.length;
  3327. if (!targetStart) targetStart = 0;
  3328. if (end > 0 && end < start) end = start; // Copy 0 bytes; we're done
  3329. if (end === start) return 0;
  3330. if (target.length === 0 || this.length === 0) return 0; // Fatal error conditions
  3331. if (targetStart < 0) {
  3332. throw new RangeError('targetStart out of bounds');
  3333. }
  3334. if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds');
  3335. if (end < 0) throw new RangeError('sourceEnd out of bounds'); // Are we oob?
  3336. if (end > this.length) end = this.length;
  3337. if (target.length - targetStart < end - start) {
  3338. end = target.length - targetStart + start;
  3339. }
  3340. var len = end - start;
  3341. var i;
  3342. if (this === target && start < targetStart && targetStart < end) {
  3343. // descending copy from end
  3344. for (i = len - 1; i >= 0; --i) {
  3345. target[i + targetStart] = this[i + start];
  3346. }
  3347. } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {
  3348. // ascending copy from start
  3349. for (i = 0; i < len; ++i) {
  3350. target[i + targetStart] = this[i + start];
  3351. }
  3352. } else {
  3353. Uint8Array.prototype.set.call(target, this.subarray(start, start + len), targetStart);
  3354. }
  3355. return len;
  3356. }; // Usage:
  3357. // buffer.fill(number[, offset[, end]])
  3358. // buffer.fill(buffer[, offset[, end]])
  3359. // buffer.fill(string[, offset[, end]][, encoding])
  3360. Buffer.prototype.fill = function fill(val, start, end, encoding) {
  3361. // Handle string cases:
  3362. if (typeof val === 'string') {
  3363. if (typeof start === 'string') {
  3364. encoding = start;
  3365. start = 0;
  3366. end = this.length;
  3367. } else if (typeof end === 'string') {
  3368. encoding = end;
  3369. end = this.length;
  3370. }
  3371. if (val.length === 1) {
  3372. var code = val.charCodeAt(0);
  3373. if (code < 256) {
  3374. val = code;
  3375. }
  3376. }
  3377. if (encoding !== undefined && typeof encoding !== 'string') {
  3378. throw new TypeError('encoding must be a string');
  3379. }
  3380. if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
  3381. throw new TypeError('Unknown encoding: ' + encoding);
  3382. }
  3383. } else if (typeof val === 'number') {
  3384. val = val & 255;
  3385. } // Invalid ranges are not set to a default, so can range check early.
  3386. if (start < 0 || this.length < start || this.length < end) {
  3387. throw new RangeError('Out of range index');
  3388. }
  3389. if (end <= start) {
  3390. return this;
  3391. }
  3392. start = start >>> 0;
  3393. end = end === undefined ? this.length : end >>> 0;
  3394. if (!val) val = 0;
  3395. var i;
  3396. if (typeof val === 'number') {
  3397. for (i = start; i < end; ++i) {
  3398. this[i] = val;
  3399. }
  3400. } else {
  3401. var bytes = internalIsBuffer(val) ? val : utf8ToBytes(new Buffer(val, encoding).toString());
  3402. var len = bytes.length;
  3403. for (i = 0; i < end - start; ++i) {
  3404. this[i + start] = bytes[i % len];
  3405. }
  3406. }
  3407. return this;
  3408. }; // HELPER FUNCTIONS
  3409. // ================
  3410. var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g;
  3411. function base64clean(str) {
  3412. // Node strips out invalid characters like \n and \t from the string, base64-js does not
  3413. str = stringtrim(str).replace(INVALID_BASE64_RE, ''); // Node converts strings with length < 2 to ''
  3414. if (str.length < 2) return ''; // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
  3415. while (str.length % 4 !== 0) {
  3416. str = str + '=';
  3417. }
  3418. return str;
  3419. }
  3420. function stringtrim(str) {
  3421. if (str.trim) return str.trim();
  3422. return str.replace(/^\s+|\s+$/g, '');
  3423. }
  3424. function toHex(n) {
  3425. if (n < 16) return '0' + n.toString(16);
  3426. return n.toString(16);
  3427. }
  3428. function utf8ToBytes(string, units) {
  3429. units = units || Infinity;
  3430. var codePoint;
  3431. var length = string.length;
  3432. var leadSurrogate = null;
  3433. var bytes = [];
  3434. for (var i = 0; i < length; ++i) {
  3435. codePoint = string.charCodeAt(i); // is surrogate component
  3436. if (codePoint > 0xD7FF && codePoint < 0xE000) {
  3437. // last char was a lead
  3438. if (!leadSurrogate) {
  3439. // no lead yet
  3440. if (codePoint > 0xDBFF) {
  3441. // unexpected trail
  3442. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
  3443. continue;
  3444. } else if (i + 1 === length) {
  3445. // unpaired lead
  3446. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
  3447. continue;
  3448. } // valid lead
  3449. leadSurrogate = codePoint;
  3450. continue;
  3451. } // 2 leads in a row
  3452. if (codePoint < 0xDC00) {
  3453. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
  3454. leadSurrogate = codePoint;
  3455. continue;
  3456. } // valid surrogate pair
  3457. codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000;
  3458. } else if (leadSurrogate) {
  3459. // valid bmp char, but last char was a lead
  3460. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
  3461. }
  3462. leadSurrogate = null; // encode utf8
  3463. if (codePoint < 0x80) {
  3464. if ((units -= 1) < 0) break;
  3465. bytes.push(codePoint);
  3466. } else if (codePoint < 0x800) {
  3467. if ((units -= 2) < 0) break;
  3468. bytes.push(codePoint >> 0x6 | 0xC0, codePoint & 0x3F | 0x80);
  3469. } else if (codePoint < 0x10000) {
  3470. if ((units -= 3) < 0) break;
  3471. bytes.push(codePoint >> 0xC | 0xE0, codePoint >> 0x6 & 0x3F | 0x80, codePoint & 0x3F | 0x80);
  3472. } else if (codePoint < 0x110000) {
  3473. if ((units -= 4) < 0) break;
  3474. bytes.push(codePoint >> 0x12 | 0xF0, codePoint >> 0xC & 0x3F | 0x80, codePoint >> 0x6 & 0x3F | 0x80, codePoint & 0x3F | 0x80);
  3475. } else {
  3476. throw new Error('Invalid code point');
  3477. }
  3478. }
  3479. return bytes;
  3480. }
  3481. function asciiToBytes(str) {
  3482. var byteArray = [];
  3483. for (var i = 0; i < str.length; ++i) {
  3484. // Node's code seems to be doing this and not & 0x7F..
  3485. byteArray.push(str.charCodeAt(i) & 0xFF);
  3486. }
  3487. return byteArray;
  3488. }
  3489. function utf16leToBytes(str, units) {
  3490. var c, hi, lo;
  3491. var byteArray = [];
  3492. for (var i = 0; i < str.length; ++i) {
  3493. if ((units -= 2) < 0) break;
  3494. c = str.charCodeAt(i);
  3495. hi = c >> 8;
  3496. lo = c % 256;
  3497. byteArray.push(lo);
  3498. byteArray.push(hi);
  3499. }
  3500. return byteArray;
  3501. }
  3502. function base64ToBytes(str) {
  3503. return toByteArray(base64clean(str));
  3504. }
  3505. function blitBuffer(src, dst, offset, length) {
  3506. for (var i = 0; i < length; ++i) {
  3507. if (i + offset >= dst.length || i >= src.length) break;
  3508. dst[i + offset] = src[i];
  3509. }
  3510. return i;
  3511. }
  3512. function isnan(val) {
  3513. return val !== val; // eslint-disable-line no-self-compare
  3514. } // the following is from is-buffer, also by Feross Aboukhadijeh and with same lisence
  3515. // The _isBuffer check is for Safari 5-7 support, because it's missing
  3516. // Object.prototype.constructor. Remove this eventually
  3517. function isBuffer(obj) {
  3518. return obj != null && (!!obj._isBuffer || isFastBuffer(obj) || isSlowBuffer(obj));
  3519. }
  3520. function isFastBuffer(obj) {
  3521. return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj);
  3522. } // For Node v0.10 support. Remove this eventually.
  3523. function isSlowBuffer(obj) {
  3524. return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isFastBuffer(obj.slice(0, 0));
  3525. }
  3526. var fs = ( _shim_fs$1 && _shim_fs ) || _shim_fs$1;
  3527. /**
  3528. * @class
  3529. */
  3530. var LineByLine =
  3531. /*#__PURE__*/
  3532. function () {
  3533. function LineByLine(file, options) {
  3534. _classCallCheck(this, LineByLine);
  3535. options = options || {};
  3536. if (!options.readChunk) options.readChunk = 1024;
  3537. if (!options.newLineCharacter) {
  3538. options.newLineCharacter = 0x0a; //linux line ending
  3539. } else {
  3540. options.newLineCharacter = options.newLineCharacter.charCodeAt(0);
  3541. }
  3542. if (typeof file === 'number') {
  3543. this.fd = file;
  3544. } else {
  3545. this.fd = fs.openSync(file, 'r');
  3546. }
  3547. this.options = options;
  3548. this.newLineCharacter = options.newLineCharacter;
  3549. this.reset();
  3550. }
  3551. _createClass(LineByLine, [{
  3552. key: "_searchInBuffer",
  3553. value: function _searchInBuffer(buffer, hexNeedle) {
  3554. var found = -1;
  3555. for (var i = 0; i <= buffer.length; i++) {
  3556. var b_byte = buffer[i];
  3557. if (b_byte === hexNeedle) {
  3558. found = i;
  3559. break;
  3560. }
  3561. }
  3562. return found;
  3563. }
  3564. }, {
  3565. key: "reset",
  3566. value: function reset() {
  3567. this.eofReached = false;
  3568. this.linesCache = [];
  3569. this.fdPosition = 0;
  3570. }
  3571. }, {
  3572. key: "close",
  3573. value: function close() {
  3574. fs.closeSync(this.fd);
  3575. this.fd = null;
  3576. }
  3577. }, {
  3578. key: "_extractLines",
  3579. value: function _extractLines(buffer) {
  3580. var line;
  3581. var lines = [];
  3582. var bufferPosition = 0;
  3583. var lastNewLineBufferPosition = 0;
  3584. while (true) {
  3585. var bufferPositionValue = buffer[bufferPosition++];
  3586. if (bufferPositionValue === this.newLineCharacter) {
  3587. line = buffer.slice(lastNewLineBufferPosition, bufferPosition);
  3588. lines.push(line);
  3589. lastNewLineBufferPosition = bufferPosition;
  3590. } else if (!bufferPositionValue) {
  3591. break;
  3592. }
  3593. }
  3594. var leftovers = buffer.slice(lastNewLineBufferPosition, bufferPosition);
  3595. if (leftovers.length) {
  3596. lines.push(leftovers);
  3597. }
  3598. return lines;
  3599. }
  3600. }, {
  3601. key: "_readChunk",
  3602. value: function _readChunk(lineLeftovers) {
  3603. var totalBytesRead = 0;
  3604. var bytesRead;
  3605. var buffers = [];
  3606. do {
  3607. var readBuffer = new Buffer(this.options.readChunk);
  3608. bytesRead = fs.readSync(this.fd, readBuffer, 0, this.options.readChunk, this.fdPosition);
  3609. totalBytesRead = totalBytesRead + bytesRead;
  3610. this.fdPosition = this.fdPosition + bytesRead;
  3611. buffers.push(readBuffer);
  3612. } while (bytesRead && this._searchInBuffer(buffers[buffers.length - 1], this.options.newLineCharacter) === -1);
  3613. var bufferData = Buffer.concat(buffers);
  3614. if (bytesRead < this.options.readChunk) {
  3615. this.eofReached = true;
  3616. bufferData = bufferData.slice(0, totalBytesRead);
  3617. }
  3618. if (totalBytesRead) {
  3619. this.linesCache = this._extractLines(bufferData);
  3620. if (lineLeftovers) {
  3621. this.linesCache[0] = Buffer.concat([lineLeftovers, this.linesCache[0]]);
  3622. }
  3623. }
  3624. return totalBytesRead;
  3625. }
  3626. }, {
  3627. key: "next",
  3628. value: function next() {
  3629. if (!this.fd) return false;
  3630. var line = false;
  3631. if (this.eofReached && this.linesCache.length === 0) {
  3632. return line;
  3633. }
  3634. var bytesRead;
  3635. if (!this.linesCache.length) {
  3636. bytesRead = this._readChunk();
  3637. }
  3638. if (this.linesCache.length) {
  3639. line = this.linesCache.shift();
  3640. var lastLineCharacter = line[line.length - 1];
  3641. if (lastLineCharacter !== 0x0a) {
  3642. bytesRead = this._readChunk(line);
  3643. if (bytesRead) {
  3644. line = this.linesCache.shift();
  3645. }
  3646. }
  3647. }
  3648. if (this.eofReached && this.linesCache.length === 0) {
  3649. this.close();
  3650. }
  3651. if (line && line[line.length - 1] === this.newLineCharacter) {
  3652. line = line.slice(0, line.length - 1);
  3653. }
  3654. return line;
  3655. }
  3656. }]);
  3657. return LineByLine;
  3658. }();
  3659. var readlines = LineByLine;
  3660. var ConfigError =
  3661. /*#__PURE__*/
  3662. function (_Error) {
  3663. _inherits(ConfigError, _Error);
  3664. function ConfigError() {
  3665. _classCallCheck(this, ConfigError);
  3666. return _possibleConstructorReturn(this, _getPrototypeOf(ConfigError).apply(this, arguments));
  3667. }
  3668. return ConfigError;
  3669. }(_wrapNativeSuper(Error));
  3670. var DebugError =
  3671. /*#__PURE__*/
  3672. function (_Error2) {
  3673. _inherits(DebugError, _Error2);
  3674. function DebugError() {
  3675. _classCallCheck(this, DebugError);
  3676. return _possibleConstructorReturn(this, _getPrototypeOf(DebugError).apply(this, arguments));
  3677. }
  3678. return DebugError;
  3679. }(_wrapNativeSuper(Error));
  3680. var UndefinedParserError$1 =
  3681. /*#__PURE__*/
  3682. function (_Error3) {
  3683. _inherits(UndefinedParserError, _Error3);
  3684. function UndefinedParserError() {
  3685. _classCallCheck(this, UndefinedParserError);
  3686. return _possibleConstructorReturn(this, _getPrototypeOf(UndefinedParserError).apply(this, arguments));
  3687. }
  3688. return UndefinedParserError;
  3689. }(_wrapNativeSuper(Error));
  3690. var errors = {
  3691. ConfigError: ConfigError,
  3692. DebugError: DebugError,
  3693. UndefinedParserError: UndefinedParserError$1
  3694. };
  3695. // based off https://github.com/defunctzombie/node-process/blob/master/browser.js
  3696. function defaultSetTimout() {
  3697. throw new Error('setTimeout has not been defined');
  3698. }
  3699. function defaultClearTimeout() {
  3700. throw new Error('clearTimeout has not been defined');
  3701. }
  3702. var cachedSetTimeout = defaultSetTimout;
  3703. var cachedClearTimeout = defaultClearTimeout;
  3704. if (typeof global$1.setTimeout === 'function') {
  3705. cachedSetTimeout = setTimeout;
  3706. }
  3707. if (typeof global$1.clearTimeout === 'function') {
  3708. cachedClearTimeout = clearTimeout;
  3709. }
  3710. function runTimeout(fun) {
  3711. if (cachedSetTimeout === setTimeout) {
  3712. //normal enviroments in sane situations
  3713. return setTimeout(fun, 0);
  3714. } // if setTimeout wasn't available but was latter defined
  3715. if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
  3716. cachedSetTimeout = setTimeout;
  3717. return setTimeout(fun, 0);
  3718. }
  3719. try {
  3720. // when when somebody has screwed with setTimeout but no I.E. maddness
  3721. return cachedSetTimeout(fun, 0);
  3722. } catch (e) {
  3723. try {
  3724. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  3725. return cachedSetTimeout.call(null, fun, 0);
  3726. } catch (e) {
  3727. // 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
  3728. return cachedSetTimeout.call(this, fun, 0);
  3729. }
  3730. }
  3731. }
  3732. function runClearTimeout(marker) {
  3733. if (cachedClearTimeout === clearTimeout) {
  3734. //normal enviroments in sane situations
  3735. return clearTimeout(marker);
  3736. } // if clearTimeout wasn't available but was latter defined
  3737. if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
  3738. cachedClearTimeout = clearTimeout;
  3739. return clearTimeout(marker);
  3740. }
  3741. try {
  3742. // when when somebody has screwed with setTimeout but no I.E. maddness
  3743. return cachedClearTimeout(marker);
  3744. } catch (e) {
  3745. try {
  3746. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  3747. return cachedClearTimeout.call(null, marker);
  3748. } catch (e) {
  3749. // 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.
  3750. // Some versions of I.E. have different rules for clearTimeout vs setTimeout
  3751. return cachedClearTimeout.call(this, marker);
  3752. }
  3753. }
  3754. }
  3755. var queue = [];
  3756. var draining = false;
  3757. var currentQueue;
  3758. var queueIndex = -1;
  3759. function cleanUpNextTick() {
  3760. if (!draining || !currentQueue) {
  3761. return;
  3762. }
  3763. draining = false;
  3764. if (currentQueue.length) {
  3765. queue = currentQueue.concat(queue);
  3766. } else {
  3767. queueIndex = -1;
  3768. }
  3769. if (queue.length) {
  3770. drainQueue();
  3771. }
  3772. }
  3773. function drainQueue() {
  3774. if (draining) {
  3775. return;
  3776. }
  3777. var timeout = runTimeout(cleanUpNextTick);
  3778. draining = true;
  3779. var len = queue.length;
  3780. while (len) {
  3781. currentQueue = queue;
  3782. queue = [];
  3783. while (++queueIndex < len) {
  3784. if (currentQueue) {
  3785. currentQueue[queueIndex].run();
  3786. }
  3787. }
  3788. queueIndex = -1;
  3789. len = queue.length;
  3790. }
  3791. currentQueue = null;
  3792. draining = false;
  3793. runClearTimeout(timeout);
  3794. }
  3795. function nextTick(fun) {
  3796. var args = new Array(arguments.length - 1);
  3797. if (arguments.length > 1) {
  3798. for (var i = 1; i < arguments.length; i++) {
  3799. args[i - 1] = arguments[i];
  3800. }
  3801. }
  3802. queue.push(new Item(fun, args));
  3803. if (queue.length === 1 && !draining) {
  3804. runTimeout(drainQueue);
  3805. }
  3806. } // v8 likes predictible objects
  3807. function Item(fun, array) {
  3808. this.fun = fun;
  3809. this.array = array;
  3810. }
  3811. Item.prototype.run = function () {
  3812. this.fun.apply(null, this.array);
  3813. };
  3814. var title = 'browser';
  3815. var platform = 'browser';
  3816. var browser = true;
  3817. var env = {};
  3818. var argv = [];
  3819. var version$2 = ''; // empty string to avoid regexp issues
  3820. var versions = {};
  3821. var release = {};
  3822. var config = {};
  3823. function noop() {}
  3824. var on = noop;
  3825. var addListener = noop;
  3826. var once = noop;
  3827. var off = noop;
  3828. var removeListener = noop;
  3829. var removeAllListeners = noop;
  3830. var emit = noop;
  3831. function binding(name) {
  3832. throw new Error('process.binding is not supported');
  3833. }
  3834. function cwd() {
  3835. return '/';
  3836. }
  3837. function chdir(dir) {
  3838. throw new Error('process.chdir is not supported');
  3839. }
  3840. function umask() {
  3841. return 0;
  3842. } // from https://github.com/kumavis/browser-process-hrtime/blob/master/index.js
  3843. var performance = global$1.performance || {};
  3844. var performanceNow = performance.now || performance.mozNow || performance.msNow || performance.oNow || performance.webkitNow || function () {
  3845. return new Date().getTime();
  3846. }; // generate timestamp or delta
  3847. // see http://nodejs.org/api/process.html#process_process_hrtime
  3848. function hrtime(previousTimestamp) {
  3849. var clocktime = performanceNow.call(performance) * 1e-3;
  3850. var seconds = Math.floor(clocktime);
  3851. var nanoseconds = Math.floor(clocktime % 1 * 1e9);
  3852. if (previousTimestamp) {
  3853. seconds = seconds - previousTimestamp[0];
  3854. nanoseconds = nanoseconds - previousTimestamp[1];
  3855. if (nanoseconds < 0) {
  3856. seconds--;
  3857. nanoseconds += 1e9;
  3858. }
  3859. }
  3860. return [seconds, nanoseconds];
  3861. }
  3862. var startTime = new Date();
  3863. function uptime() {
  3864. var currentTime = new Date();
  3865. var dif = currentTime - startTime;
  3866. return dif / 1000;
  3867. }
  3868. var process = {
  3869. nextTick: nextTick,
  3870. title: title,
  3871. browser: browser,
  3872. env: env,
  3873. argv: argv,
  3874. version: version$2,
  3875. versions: versions,
  3876. on: on,
  3877. addListener: addListener,
  3878. once: once,
  3879. off: off,
  3880. removeListener: removeListener,
  3881. removeAllListeners: removeAllListeners,
  3882. emit: emit,
  3883. binding: binding,
  3884. cwd: cwd,
  3885. chdir: chdir,
  3886. umask: umask,
  3887. hrtime: hrtime,
  3888. platform: platform,
  3889. release: release,
  3890. config: config,
  3891. uptime: uptime
  3892. };
  3893. var semver = createCommonjsModule(function (module, exports) {
  3894. exports = module.exports = SemVer; // The debug function is excluded entirely from the minified version.
  3895. /* nomin */
  3896. var debug;
  3897. /* nomin */
  3898. if (_typeof(process) === 'object' &&
  3899. /* nomin */
  3900. process.env &&
  3901. /* nomin */
  3902. process.env.NODE_DEBUG &&
  3903. /* nomin */
  3904. /\bsemver\b/i.test(process.env.NODE_DEBUG))
  3905. /* nomin */
  3906. debug = function debug() {
  3907. /* nomin */
  3908. var args = Array.prototype.slice.call(arguments, 0);
  3909. /* nomin */
  3910. args.unshift('SEMVER');
  3911. /* nomin */
  3912. console.log.apply(console, args);
  3913. /* nomin */
  3914. };
  3915. /* nomin */
  3916. else
  3917. /* nomin */
  3918. debug = function debug() {}; // Note: this is the semver.org version of the spec that it implements
  3919. // Not necessarily the package version of this code.
  3920. exports.SEMVER_SPEC_VERSION = '2.0.0';
  3921. var MAX_LENGTH = 256;
  3922. var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || 9007199254740991; // The actual regexps go on exports.re
  3923. var re = exports.re = [];
  3924. var src = exports.src = [];
  3925. var R = 0; // The following Regular Expressions can be used for tokenizing,
  3926. // validating, and parsing SemVer version strings.
  3927. // ## Numeric Identifier
  3928. // A single `0`, or a non-zero digit followed by zero or more digits.
  3929. var NUMERICIDENTIFIER = R++;
  3930. src[NUMERICIDENTIFIER] = '0|[1-9]\\d*';
  3931. var NUMERICIDENTIFIERLOOSE = R++;
  3932. src[NUMERICIDENTIFIERLOOSE] = '[0-9]+'; // ## Non-numeric Identifier
  3933. // Zero or more digits, followed by a letter or hyphen, and then zero or
  3934. // more letters, digits, or hyphens.
  3935. var NONNUMERICIDENTIFIER = R++;
  3936. src[NONNUMERICIDENTIFIER] = '\\d*[a-zA-Z-][a-zA-Z0-9-]*'; // ## Main Version
  3937. // Three dot-separated numeric identifiers.
  3938. var MAINVERSION = R++;
  3939. src[MAINVERSION] = '(' + src[NUMERICIDENTIFIER] + ')\\.' + '(' + src[NUMERICIDENTIFIER] + ')\\.' + '(' + src[NUMERICIDENTIFIER] + ')';
  3940. var MAINVERSIONLOOSE = R++;
  3941. src[MAINVERSIONLOOSE] = '(' + src[NUMERICIDENTIFIERLOOSE] + ')\\.' + '(' + src[NUMERICIDENTIFIERLOOSE] + ')\\.' + '(' + src[NUMERICIDENTIFIERLOOSE] + ')'; // ## Pre-release Version Identifier
  3942. // A numeric identifier, or a non-numeric identifier.
  3943. var PRERELEASEIDENTIFIER = R++;
  3944. src[PRERELEASEIDENTIFIER] = '(?:' + src[NUMERICIDENTIFIER] + '|' + src[NONNUMERICIDENTIFIER] + ')';
  3945. var PRERELEASEIDENTIFIERLOOSE = R++;
  3946. src[PRERELEASEIDENTIFIERLOOSE] = '(?:' + src[NUMERICIDENTIFIERLOOSE] + '|' + src[NONNUMERICIDENTIFIER] + ')'; // ## Pre-release Version
  3947. // Hyphen, followed by one or more dot-separated pre-release version
  3948. // identifiers.
  3949. var PRERELEASE = R++;
  3950. src[PRERELEASE] = '(?:-(' + src[PRERELEASEIDENTIFIER] + '(?:\\.' + src[PRERELEASEIDENTIFIER] + ')*))';
  3951. var PRERELEASELOOSE = R++;
  3952. src[PRERELEASELOOSE] = '(?:-?(' + src[PRERELEASEIDENTIFIERLOOSE] + '(?:\\.' + src[PRERELEASEIDENTIFIERLOOSE] + ')*))'; // ## Build Metadata Identifier
  3953. // Any combination of digits, letters, or hyphens.
  3954. var BUILDIDENTIFIER = R++;
  3955. src[BUILDIDENTIFIER] = '[0-9A-Za-z-]+'; // ## Build Metadata
  3956. // Plus sign, followed by one or more period-separated build metadata
  3957. // identifiers.
  3958. var BUILD = R++;
  3959. src[BUILD] = '(?:\\+(' + src[BUILDIDENTIFIER] + '(?:\\.' + src[BUILDIDENTIFIER] + ')*))'; // ## Full Version String
  3960. // A main version, followed optionally by a pre-release version and
  3961. // build metadata.
  3962. // Note that the only major, minor, patch, and pre-release sections of
  3963. // the version string are capturing groups. The build metadata is not a
  3964. // capturing group, because it should not ever be used in version
  3965. // comparison.
  3966. var FULL = R++;
  3967. var FULLPLAIN = 'v?' + src[MAINVERSION] + src[PRERELEASE] + '?' + src[BUILD] + '?';
  3968. src[FULL] = '^' + FULLPLAIN + '$'; // like full, but allows v1.2.3 and =1.2.3, which people do sometimes.
  3969. // also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty
  3970. // common in the npm registry.
  3971. var LOOSEPLAIN = '[v=\\s]*' + src[MAINVERSIONLOOSE] + src[PRERELEASELOOSE] + '?' + src[BUILD] + '?';
  3972. var LOOSE = R++;
  3973. src[LOOSE] = '^' + LOOSEPLAIN + '$';
  3974. var GTLT = R++;
  3975. src[GTLT] = '((?:<|>)?=?)'; // Something like "2.*" or "1.2.x".
  3976. // Note that "x.x" is a valid xRange identifer, meaning "any version"
  3977. // Only the first item is strictly required.
  3978. var XRANGEIDENTIFIERLOOSE = R++;
  3979. src[XRANGEIDENTIFIERLOOSE] = src[NUMERICIDENTIFIERLOOSE] + '|x|X|\\*';
  3980. var XRANGEIDENTIFIER = R++;
  3981. src[XRANGEIDENTIFIER] = src[NUMERICIDENTIFIER] + '|x|X|\\*';
  3982. var XRANGEPLAIN = R++;
  3983. src[XRANGEPLAIN] = '[v=\\s]*(' + src[XRANGEIDENTIFIER] + ')' + '(?:\\.(' + src[XRANGEIDENTIFIER] + ')' + '(?:\\.(' + src[XRANGEIDENTIFIER] + ')' + '(?:' + src[PRERELEASE] + ')?' + src[BUILD] + '?' + ')?)?';
  3984. var XRANGEPLAINLOOSE = R++;
  3985. src[XRANGEPLAINLOOSE] = '[v=\\s]*(' + src[XRANGEIDENTIFIERLOOSE] + ')' + '(?:\\.(' + src[XRANGEIDENTIFIERLOOSE] + ')' + '(?:\\.(' + src[XRANGEIDENTIFIERLOOSE] + ')' + '(?:' + src[PRERELEASELOOSE] + ')?' + src[BUILD] + '?' + ')?)?';
  3986. var XRANGE = R++;
  3987. src[XRANGE] = '^' + src[GTLT] + '\\s*' + src[XRANGEPLAIN] + '$';
  3988. var XRANGELOOSE = R++;
  3989. src[XRANGELOOSE] = '^' + src[GTLT] + '\\s*' + src[XRANGEPLAINLOOSE] + '$'; // Tilde ranges.
  3990. // Meaning is "reasonably at or greater than"
  3991. var LONETILDE = R++;
  3992. src[LONETILDE] = '(?:~>?)';
  3993. var TILDETRIM = R++;
  3994. src[TILDETRIM] = '(\\s*)' + src[LONETILDE] + '\\s+';
  3995. re[TILDETRIM] = new RegExp(src[TILDETRIM], 'g');
  3996. var tildeTrimReplace = '$1~';
  3997. var TILDE = R++;
  3998. src[TILDE] = '^' + src[LONETILDE] + src[XRANGEPLAIN] + '$';
  3999. var TILDELOOSE = R++;
  4000. src[TILDELOOSE] = '^' + src[LONETILDE] + src[XRANGEPLAINLOOSE] + '$'; // Caret ranges.
  4001. // Meaning is "at least and backwards compatible with"
  4002. var LONECARET = R++;
  4003. src[LONECARET] = '(?:\\^)';
  4004. var CARETTRIM = R++;
  4005. src[CARETTRIM] = '(\\s*)' + src[LONECARET] + '\\s+';
  4006. re[CARETTRIM] = new RegExp(src[CARETTRIM], 'g');
  4007. var caretTrimReplace = '$1^';
  4008. var CARET = R++;
  4009. src[CARET] = '^' + src[LONECARET] + src[XRANGEPLAIN] + '$';
  4010. var CARETLOOSE = R++;
  4011. src[CARETLOOSE] = '^' + src[LONECARET] + src[XRANGEPLAINLOOSE] + '$'; // A simple gt/lt/eq thing, or just "" to indicate "any version"
  4012. var COMPARATORLOOSE = R++;
  4013. src[COMPARATORLOOSE] = '^' + src[GTLT] + '\\s*(' + LOOSEPLAIN + ')$|^$';
  4014. var COMPARATOR = R++;
  4015. src[COMPARATOR] = '^' + src[GTLT] + '\\s*(' + FULLPLAIN + ')$|^$'; // An expression to strip any whitespace between the gtlt and the thing
  4016. // it modifies, so that `> 1.2.3` ==> `>1.2.3`
  4017. var COMPARATORTRIM = R++;
  4018. src[COMPARATORTRIM] = '(\\s*)' + src[GTLT] + '\\s*(' + LOOSEPLAIN + '|' + src[XRANGEPLAIN] + ')'; // this one has to use the /g flag
  4019. re[COMPARATORTRIM] = new RegExp(src[COMPARATORTRIM], 'g');
  4020. var comparatorTrimReplace = '$1$2$3'; // Something like `1.2.3 - 1.2.4`
  4021. // Note that these all use the loose form, because they'll be
  4022. // checked against either the strict or loose comparator form
  4023. // later.
  4024. var HYPHENRANGE = R++;
  4025. src[HYPHENRANGE] = '^\\s*(' + src[XRANGEPLAIN] + ')' + '\\s+-\\s+' + '(' + src[XRANGEPLAIN] + ')' + '\\s*$';
  4026. var HYPHENRANGELOOSE = R++;
  4027. src[HYPHENRANGELOOSE] = '^\\s*(' + src[XRANGEPLAINLOOSE] + ')' + '\\s+-\\s+' + '(' + src[XRANGEPLAINLOOSE] + ')' + '\\s*$'; // Star ranges basically just allow anything at all.
  4028. var STAR = R++;
  4029. src[STAR] = '(<|>)?=?\\s*\\*'; // Compile to actual regexp objects.
  4030. // All are flag-free, unless they were created above with a flag.
  4031. for (var i = 0; i < R; i++) {
  4032. debug(i, src[i]);
  4033. if (!re[i]) re[i] = new RegExp(src[i]);
  4034. }
  4035. exports.parse = parse;
  4036. function parse(version, loose) {
  4037. if (version instanceof SemVer) return version;
  4038. if (typeof version !== 'string') return null;
  4039. if (version.length > MAX_LENGTH) return null;
  4040. var r = loose ? re[LOOSE] : re[FULL];
  4041. if (!r.test(version)) return null;
  4042. try {
  4043. return new SemVer(version, loose);
  4044. } catch (er) {
  4045. return null;
  4046. }
  4047. }
  4048. exports.valid = valid;
  4049. function valid(version, loose) {
  4050. var v = parse(version, loose);
  4051. return v ? v.version : null;
  4052. }
  4053. exports.clean = clean;
  4054. function clean(version, loose) {
  4055. var s = parse(version.trim().replace(/^[=v]+/, ''), loose);
  4056. return s ? s.version : null;
  4057. }
  4058. exports.SemVer = SemVer;
  4059. function SemVer(version, loose) {
  4060. if (version instanceof SemVer) {
  4061. if (version.loose === loose) return version;else version = version.version;
  4062. } else if (typeof version !== 'string') {
  4063. throw new TypeError('Invalid Version: ' + version);
  4064. }
  4065. if (version.length > MAX_LENGTH) throw new TypeError('version is longer than ' + MAX_LENGTH + ' characters');
  4066. if (!(this instanceof SemVer)) return new SemVer(version, loose);
  4067. debug('SemVer', version, loose);
  4068. this.loose = loose;
  4069. var m = version.trim().match(loose ? re[LOOSE] : re[FULL]);
  4070. if (!m) throw new TypeError('Invalid Version: ' + version);
  4071. this.raw = version; // these are actually numbers
  4072. this.major = +m[1];
  4073. this.minor = +m[2];
  4074. this.patch = +m[3];
  4075. if (this.major > MAX_SAFE_INTEGER || this.major < 0) throw new TypeError('Invalid major version');
  4076. if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) throw new TypeError('Invalid minor version');
  4077. if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) throw new TypeError('Invalid patch version'); // numberify any prerelease numeric ids
  4078. if (!m[4]) this.prerelease = [];else this.prerelease = m[4].split('.').map(function (id) {
  4079. if (/^[0-9]+$/.test(id)) {
  4080. var num = +id;
  4081. if (num >= 0 && num < MAX_SAFE_INTEGER) return num;
  4082. }
  4083. return id;
  4084. });
  4085. this.build = m[5] ? m[5].split('.') : [];
  4086. this.format();
  4087. }
  4088. SemVer.prototype.format = function () {
  4089. this.version = this.major + '.' + this.minor + '.' + this.patch;
  4090. if (this.prerelease.length) this.version += '-' + this.prerelease.join('.');
  4091. return this.version;
  4092. };
  4093. SemVer.prototype.toString = function () {
  4094. return this.version;
  4095. };
  4096. SemVer.prototype.compare = function (other) {
  4097. debug('SemVer.compare', this.version, this.loose, other);
  4098. if (!(other instanceof SemVer)) other = new SemVer(other, this.loose);
  4099. return this.compareMain(other) || this.comparePre(other);
  4100. };
  4101. SemVer.prototype.compareMain = function (other) {
  4102. if (!(other instanceof SemVer)) other = new SemVer(other, this.loose);
  4103. return compareIdentifiers(this.major, other.major) || compareIdentifiers(this.minor, other.minor) || compareIdentifiers(this.patch, other.patch);
  4104. };
  4105. SemVer.prototype.comparePre = function (other) {
  4106. if (!(other instanceof SemVer)) other = new SemVer(other, this.loose); // NOT having a prerelease is > having one
  4107. 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;
  4108. var i = 0;
  4109. do {
  4110. var a = this.prerelease[i];
  4111. var b = other.prerelease[i];
  4112. debug('prerelease compare', i, a, b);
  4113. 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);
  4114. } while (++i);
  4115. }; // preminor will bump the version up to the next minor release, and immediately
  4116. // down to pre-release. premajor and prepatch work the same way.
  4117. SemVer.prototype.inc = function (release$$1, identifier) {
  4118. switch (release$$1) {
  4119. case 'premajor':
  4120. this.prerelease.length = 0;
  4121. this.patch = 0;
  4122. this.minor = 0;
  4123. this.major++;
  4124. this.inc('pre', identifier);
  4125. break;
  4126. case 'preminor':
  4127. this.prerelease.length = 0;
  4128. this.patch = 0;
  4129. this.minor++;
  4130. this.inc('pre', identifier);
  4131. break;
  4132. case 'prepatch':
  4133. // If this is already a prerelease, it will bump to the next version
  4134. // drop any prereleases that might already exist, since they are not
  4135. // relevant at this point.
  4136. this.prerelease.length = 0;
  4137. this.inc('patch', identifier);
  4138. this.inc('pre', identifier);
  4139. break;
  4140. // If the input is a non-prerelease version, this acts the same as
  4141. // prepatch.
  4142. case 'prerelease':
  4143. if (this.prerelease.length === 0) this.inc('patch', identifier);
  4144. this.inc('pre', identifier);
  4145. break;
  4146. case 'major':
  4147. // If this is a pre-major version, bump up to the same major version.
  4148. // Otherwise increment major.
  4149. // 1.0.0-5 bumps to 1.0.0
  4150. // 1.1.0 bumps to 2.0.0
  4151. if (this.minor !== 0 || this.patch !== 0 || this.prerelease.length === 0) this.major++;
  4152. this.minor = 0;
  4153. this.patch = 0;
  4154. this.prerelease = [];
  4155. break;
  4156. case 'minor':
  4157. // If this is a pre-minor version, bump up to the same minor version.
  4158. // Otherwise increment minor.
  4159. // 1.2.0-5 bumps to 1.2.0
  4160. // 1.2.1 bumps to 1.3.0
  4161. if (this.patch !== 0 || this.prerelease.length === 0) this.minor++;
  4162. this.patch = 0;
  4163. this.prerelease = [];
  4164. break;
  4165. case 'patch':
  4166. // If this is not a pre-release version, it will increment the patch.
  4167. // If it is a pre-release it will bump up to the same patch version.
  4168. // 1.2.0-5 patches to 1.2.0
  4169. // 1.2.0 patches to 1.2.1
  4170. if (this.prerelease.length === 0) this.patch++;
  4171. this.prerelease = [];
  4172. break;
  4173. // This probably shouldn't be used publicly.
  4174. // 1.0.0 "pre" would become 1.0.0-0 which is the wrong direction.
  4175. case 'pre':
  4176. if (this.prerelease.length === 0) this.prerelease = [0];else {
  4177. var i = this.prerelease.length;
  4178. while (--i >= 0) {
  4179. if (typeof this.prerelease[i] === 'number') {
  4180. this.prerelease[i]++;
  4181. i = -2;
  4182. }
  4183. }
  4184. if (i === -1) // didn't increment anything
  4185. this.prerelease.push(0);
  4186. }
  4187. if (identifier) {
  4188. // 1.2.0-beta.1 bumps to 1.2.0-beta.2,
  4189. // 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0
  4190. if (this.prerelease[0] === identifier) {
  4191. if (isNaN(this.prerelease[1])) this.prerelease = [identifier, 0];
  4192. } else this.prerelease = [identifier, 0];
  4193. }
  4194. break;
  4195. default:
  4196. throw new Error('invalid increment argument: ' + release$$1);
  4197. }
  4198. this.format();
  4199. this.raw = this.version;
  4200. return this;
  4201. };
  4202. exports.inc = inc;
  4203. function inc(version, release$$1, loose, identifier) {
  4204. if (typeof loose === 'string') {
  4205. identifier = loose;
  4206. loose = undefined;
  4207. }
  4208. try {
  4209. return new SemVer(version, loose).inc(release$$1, identifier).version;
  4210. } catch (er) {
  4211. return null;
  4212. }
  4213. }
  4214. exports.diff = diff;
  4215. function diff(version1, version2) {
  4216. if (eq(version1, version2)) {
  4217. return null;
  4218. } else {
  4219. var v1 = parse(version1);
  4220. var v2 = parse(version2);
  4221. if (v1.prerelease.length || v2.prerelease.length) {
  4222. for (var key in v1) {
  4223. if (key === 'major' || key === 'minor' || key === 'patch') {
  4224. if (v1[key] !== v2[key]) {
  4225. return 'pre' + key;
  4226. }
  4227. }
  4228. }
  4229. return 'prerelease';
  4230. }
  4231. for (var key in v1) {
  4232. if (key === 'major' || key === 'minor' || key === 'patch') {
  4233. if (v1[key] !== v2[key]) {
  4234. return key;
  4235. }
  4236. }
  4237. }
  4238. }
  4239. }
  4240. exports.compareIdentifiers = compareIdentifiers;
  4241. var numeric = /^[0-9]+$/;
  4242. function compareIdentifiers(a, b) {
  4243. var anum = numeric.test(a);
  4244. var bnum = numeric.test(b);
  4245. if (anum && bnum) {
  4246. a = +a;
  4247. b = +b;
  4248. }
  4249. return anum && !bnum ? -1 : bnum && !anum ? 1 : a < b ? -1 : a > b ? 1 : 0;
  4250. }
  4251. exports.rcompareIdentifiers = rcompareIdentifiers;
  4252. function rcompareIdentifiers(a, b) {
  4253. return compareIdentifiers(b, a);
  4254. }
  4255. exports.major = major;
  4256. function major(a, loose) {
  4257. return new SemVer(a, loose).major;
  4258. }
  4259. exports.minor = minor;
  4260. function minor(a, loose) {
  4261. return new SemVer(a, loose).minor;
  4262. }
  4263. exports.patch = patch;
  4264. function patch(a, loose) {
  4265. return new SemVer(a, loose).patch;
  4266. }
  4267. exports.compare = compare;
  4268. function compare(a, b, loose) {
  4269. return new SemVer(a, loose).compare(new SemVer(b, loose));
  4270. }
  4271. exports.compareLoose = compareLoose;
  4272. function compareLoose(a, b) {
  4273. return compare(a, b, true);
  4274. }
  4275. exports.rcompare = rcompare;
  4276. function rcompare(a, b, loose) {
  4277. return compare(b, a, loose);
  4278. }
  4279. exports.sort = sort;
  4280. function sort(list, loose) {
  4281. return list.sort(function (a, b) {
  4282. return exports.compare(a, b, loose);
  4283. });
  4284. }
  4285. exports.rsort = rsort;
  4286. function rsort(list, loose) {
  4287. return list.sort(function (a, b) {
  4288. return exports.rcompare(a, b, loose);
  4289. });
  4290. }
  4291. exports.gt = gt;
  4292. function gt(a, b, loose) {
  4293. return compare(a, b, loose) > 0;
  4294. }
  4295. exports.lt = lt;
  4296. function lt(a, b, loose) {
  4297. return compare(a, b, loose) < 0;
  4298. }
  4299. exports.eq = eq;
  4300. function eq(a, b, loose) {
  4301. return compare(a, b, loose) === 0;
  4302. }
  4303. exports.neq = neq;
  4304. function neq(a, b, loose) {
  4305. return compare(a, b, loose) !== 0;
  4306. }
  4307. exports.gte = gte;
  4308. function gte(a, b, loose) {
  4309. return compare(a, b, loose) >= 0;
  4310. }
  4311. exports.lte = lte;
  4312. function lte(a, b, loose) {
  4313. return compare(a, b, loose) <= 0;
  4314. }
  4315. exports.cmp = cmp;
  4316. function cmp(a, op, b, loose) {
  4317. var ret;
  4318. switch (op) {
  4319. case '===':
  4320. if (_typeof(a) === 'object') a = a.version;
  4321. if (_typeof(b) === 'object') b = b.version;
  4322. ret = a === b;
  4323. break;
  4324. case '!==':
  4325. if (_typeof(a) === 'object') a = a.version;
  4326. if (_typeof(b) === 'object') b = b.version;
  4327. ret = a !== b;
  4328. break;
  4329. case '':
  4330. case '=':
  4331. case '==':
  4332. ret = eq(a, b, loose);
  4333. break;
  4334. case '!=':
  4335. ret = neq(a, b, loose);
  4336. break;
  4337. case '>':
  4338. ret = gt(a, b, loose);
  4339. break;
  4340. case '>=':
  4341. ret = gte(a, b, loose);
  4342. break;
  4343. case '<':
  4344. ret = lt(a, b, loose);
  4345. break;
  4346. case '<=':
  4347. ret = lte(a, b, loose);
  4348. break;
  4349. default:
  4350. throw new TypeError('Invalid operator: ' + op);
  4351. }
  4352. return ret;
  4353. }
  4354. exports.Comparator = Comparator;
  4355. function Comparator(comp, loose) {
  4356. if (comp instanceof Comparator) {
  4357. if (comp.loose === loose) return comp;else comp = comp.value;
  4358. }
  4359. if (!(this instanceof Comparator)) return new Comparator(comp, loose);
  4360. debug('comparator', comp, loose);
  4361. this.loose = loose;
  4362. this.parse(comp);
  4363. if (this.semver === ANY) this.value = '';else this.value = this.operator + this.semver.version;
  4364. debug('comp', this);
  4365. }
  4366. var ANY = {};
  4367. Comparator.prototype.parse = function (comp) {
  4368. var r = this.loose ? re[COMPARATORLOOSE] : re[COMPARATOR];
  4369. var m = comp.match(r);
  4370. if (!m) throw new TypeError('Invalid comparator: ' + comp);
  4371. this.operator = m[1];
  4372. if (this.operator === '=') this.operator = ''; // if it literally is just '>' or '' then allow anything.
  4373. if (!m[2]) this.semver = ANY;else this.semver = new SemVer(m[2], this.loose);
  4374. };
  4375. Comparator.prototype.toString = function () {
  4376. return this.value;
  4377. };
  4378. Comparator.prototype.test = function (version) {
  4379. debug('Comparator.test', version, this.loose);
  4380. if (this.semver === ANY) return true;
  4381. if (typeof version === 'string') version = new SemVer(version, this.loose);
  4382. return cmp(version, this.operator, this.semver, this.loose);
  4383. };
  4384. Comparator.prototype.intersects = function (comp, loose) {
  4385. if (!(comp instanceof Comparator)) {
  4386. throw new TypeError('a Comparator is required');
  4387. }
  4388. var rangeTmp;
  4389. if (this.operator === '') {
  4390. rangeTmp = new Range(comp.value, loose);
  4391. return satisfies(this.value, rangeTmp, loose);
  4392. } else if (comp.operator === '') {
  4393. rangeTmp = new Range(this.value, loose);
  4394. return satisfies(comp.semver, rangeTmp, loose);
  4395. }
  4396. var sameDirectionIncreasing = (this.operator === '>=' || this.operator === '>') && (comp.operator === '>=' || comp.operator === '>');
  4397. var sameDirectionDecreasing = (this.operator === '<=' || this.operator === '<') && (comp.operator === '<=' || comp.operator === '<');
  4398. var sameSemVer = this.semver.version === comp.semver.version;
  4399. var differentDirectionsInclusive = (this.operator === '>=' || this.operator === '<=') && (comp.operator === '>=' || comp.operator === '<=');
  4400. var oppositeDirectionsLessThan = cmp(this.semver, '<', comp.semver, loose) && (this.operator === '>=' || this.operator === '>') && (comp.operator === '<=' || comp.operator === '<');
  4401. var oppositeDirectionsGreaterThan = cmp(this.semver, '>', comp.semver, loose) && (this.operator === '<=' || this.operator === '<') && (comp.operator === '>=' || comp.operator === '>');
  4402. return sameDirectionIncreasing || sameDirectionDecreasing || sameSemVer && differentDirectionsInclusive || oppositeDirectionsLessThan || oppositeDirectionsGreaterThan;
  4403. };
  4404. exports.Range = Range;
  4405. function Range(range, loose) {
  4406. if (range instanceof Range) {
  4407. if (range.loose === loose) {
  4408. return range;
  4409. } else {
  4410. return new Range(range.raw, loose);
  4411. }
  4412. }
  4413. if (range instanceof Comparator) {
  4414. return new Range(range.value, loose);
  4415. }
  4416. if (!(this instanceof Range)) return new Range(range, loose);
  4417. this.loose = loose; // First, split based on boolean or ||
  4418. this.raw = range;
  4419. this.set = range.split(/\s*\|\|\s*/).map(function (range) {
  4420. return this.parseRange(range.trim());
  4421. }, this).filter(function (c) {
  4422. // throw out any that are not relevant for whatever reason
  4423. return c.length;
  4424. });
  4425. if (!this.set.length) {
  4426. throw new TypeError('Invalid SemVer Range: ' + range);
  4427. }
  4428. this.format();
  4429. }
  4430. Range.prototype.format = function () {
  4431. this.range = this.set.map(function (comps) {
  4432. return comps.join(' ').trim();
  4433. }).join('||').trim();
  4434. return this.range;
  4435. };
  4436. Range.prototype.toString = function () {
  4437. return this.range;
  4438. };
  4439. Range.prototype.parseRange = function (range) {
  4440. var loose = this.loose;
  4441. range = range.trim();
  4442. debug('range', range, loose); // `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4`
  4443. var hr = loose ? re[HYPHENRANGELOOSE] : re[HYPHENRANGE];
  4444. range = range.replace(hr, hyphenReplace);
  4445. debug('hyphen replace', range); // `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5`
  4446. range = range.replace(re[COMPARATORTRIM], comparatorTrimReplace);
  4447. debug('comparator trim', range, re[COMPARATORTRIM]); // `~ 1.2.3` => `~1.2.3`
  4448. range = range.replace(re[TILDETRIM], tildeTrimReplace); // `^ 1.2.3` => `^1.2.3`
  4449. range = range.replace(re[CARETTRIM], caretTrimReplace); // normalize spaces
  4450. range = range.split(/\s+/).join(' '); // At this point, the range is completely trimmed and
  4451. // ready to be split into comparators.
  4452. var compRe = loose ? re[COMPARATORLOOSE] : re[COMPARATOR];
  4453. var set = range.split(' ').map(function (comp) {
  4454. return parseComparator(comp, loose);
  4455. }).join(' ').split(/\s+/);
  4456. if (this.loose) {
  4457. // in loose mode, throw out any that are not valid comparators
  4458. set = set.filter(function (comp) {
  4459. return !!comp.match(compRe);
  4460. });
  4461. }
  4462. set = set.map(function (comp) {
  4463. return new Comparator(comp, loose);
  4464. });
  4465. return set;
  4466. };
  4467. Range.prototype.intersects = function (range, loose) {
  4468. if (!(range instanceof Range)) {
  4469. throw new TypeError('a Range is required');
  4470. }
  4471. return this.set.some(function (thisComparators) {
  4472. return thisComparators.every(function (thisComparator) {
  4473. return range.set.some(function (rangeComparators) {
  4474. return rangeComparators.every(function (rangeComparator) {
  4475. return thisComparator.intersects(rangeComparator, loose);
  4476. });
  4477. });
  4478. });
  4479. });
  4480. }; // Mostly just for testing and legacy API reasons
  4481. exports.toComparators = toComparators;
  4482. function toComparators(range, loose) {
  4483. return new Range(range, loose).set.map(function (comp) {
  4484. return comp.map(function (c) {
  4485. return c.value;
  4486. }).join(' ').trim().split(' ');
  4487. });
  4488. } // comprised of xranges, tildes, stars, and gtlt's at this point.
  4489. // already replaced the hyphen ranges
  4490. // turn into a set of JUST comparators.
  4491. function parseComparator(comp, loose) {
  4492. debug('comp', comp);
  4493. comp = replaceCarets(comp, loose);
  4494. debug('caret', comp);
  4495. comp = replaceTildes(comp, loose);
  4496. debug('tildes', comp);
  4497. comp = replaceXRanges(comp, loose);
  4498. debug('xrange', comp);
  4499. comp = replaceStars(comp, loose);
  4500. debug('stars', comp);
  4501. return comp;
  4502. }
  4503. function isX(id) {
  4504. return !id || id.toLowerCase() === 'x' || id === '*';
  4505. } // ~, ~> --> * (any, kinda silly)
  4506. // ~2, ~2.x, ~2.x.x, ~>2, ~>2.x ~>2.x.x --> >=2.0.0 <3.0.0
  4507. // ~2.0, ~2.0.x, ~>2.0, ~>2.0.x --> >=2.0.0 <2.1.0
  4508. // ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <1.3.0
  4509. // ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0
  4510. // ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0
  4511. function replaceTildes(comp, loose) {
  4512. return comp.trim().split(/\s+/).map(function (comp) {
  4513. return replaceTilde(comp, loose);
  4514. }).join(' ');
  4515. }
  4516. function replaceTilde(comp, loose) {
  4517. var r = loose ? re[TILDELOOSE] : re[TILDE];
  4518. return comp.replace(r, function (_, M, m, p, pr) {
  4519. debug('tilde', comp, _, M, m, p, pr);
  4520. var ret;
  4521. 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
  4522. ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0';else if (pr) {
  4523. debug('replaceTilde pr', pr);
  4524. if (pr.charAt(0) !== '-') pr = '-' + pr;
  4525. ret = '>=' + M + '.' + m + '.' + p + pr + ' <' + M + '.' + (+m + 1) + '.0';
  4526. } else // ~1.2.3 == >=1.2.3 <1.3.0
  4527. ret = '>=' + M + '.' + m + '.' + p + ' <' + M + '.' + (+m + 1) + '.0';
  4528. debug('tilde return', ret);
  4529. return ret;
  4530. });
  4531. } // ^ --> * (any, kinda silly)
  4532. // ^2, ^2.x, ^2.x.x --> >=2.0.0 <3.0.0
  4533. // ^2.0, ^2.0.x --> >=2.0.0 <3.0.0
  4534. // ^1.2, ^1.2.x --> >=1.2.0 <2.0.0
  4535. // ^1.2.3 --> >=1.2.3 <2.0.0
  4536. // ^1.2.0 --> >=1.2.0 <2.0.0
  4537. function replaceCarets(comp, loose) {
  4538. return comp.trim().split(/\s+/).map(function (comp) {
  4539. return replaceCaret(comp, loose);
  4540. }).join(' ');
  4541. }
  4542. function replaceCaret(comp, loose) {
  4543. debug('caret', comp, loose);
  4544. var r = loose ? re[CARETLOOSE] : re[CARET];
  4545. return comp.replace(r, function (_, M, m, p, pr) {
  4546. debug('caret', comp, _, M, m, p, pr);
  4547. var ret;
  4548. if (isX(M)) ret = '';else if (isX(m)) ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0';else if (isX(p)) {
  4549. if (M === '0') ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0';else ret = '>=' + M + '.' + m + '.0 <' + (+M + 1) + '.0.0';
  4550. } else if (pr) {
  4551. debug('replaceCaret pr', pr);
  4552. if (pr.charAt(0) !== '-') pr = '-' + pr;
  4553. if (M === '0') {
  4554. if (m === '0') ret = '>=' + M + '.' + m + '.' + p + pr + ' <' + M + '.' + m + '.' + (+p + 1);else ret = '>=' + M + '.' + m + '.' + p + pr + ' <' + M + '.' + (+m + 1) + '.0';
  4555. } else ret = '>=' + M + '.' + m + '.' + p + pr + ' <' + (+M + 1) + '.0.0';
  4556. } else {
  4557. debug('no pr');
  4558. if (M === '0') {
  4559. if (m === '0') ret = '>=' + M + '.' + m + '.' + p + ' <' + M + '.' + m + '.' + (+p + 1);else ret = '>=' + M + '.' + m + '.' + p + ' <' + M + '.' + (+m + 1) + '.0';
  4560. } else ret = '>=' + M + '.' + m + '.' + p + ' <' + (+M + 1) + '.0.0';
  4561. }
  4562. debug('caret return', ret);
  4563. return ret;
  4564. });
  4565. }
  4566. function replaceXRanges(comp, loose) {
  4567. debug('replaceXRanges', comp, loose);
  4568. return comp.split(/\s+/).map(function (comp) {
  4569. return replaceXRange(comp, loose);
  4570. }).join(' ');
  4571. }
  4572. function replaceXRange(comp, loose) {
  4573. comp = comp.trim();
  4574. var r = loose ? re[XRANGELOOSE] : re[XRANGE];
  4575. return comp.replace(r, function (ret, gtlt, M, m, p, pr) {
  4576. debug('xRange', comp, ret, gtlt, M, m, p, pr);
  4577. var xM = isX(M);
  4578. var xm = xM || isX(m);
  4579. var xp = xm || isX(p);
  4580. var anyX = xp;
  4581. if (gtlt === '=' && anyX) gtlt = '';
  4582. if (xM) {
  4583. if (gtlt === '>' || gtlt === '<') {
  4584. // nothing is allowed
  4585. ret = '<0.0.0';
  4586. } else {
  4587. // nothing is forbidden
  4588. ret = '*';
  4589. }
  4590. } else if (gtlt && anyX) {
  4591. // replace X with 0
  4592. if (xm) m = 0;
  4593. if (xp) p = 0;
  4594. if (gtlt === '>') {
  4595. // >1 => >=2.0.0
  4596. // >1.2 => >=1.3.0
  4597. // >1.2.3 => >= 1.2.4
  4598. gtlt = '>=';
  4599. if (xm) {
  4600. M = +M + 1;
  4601. m = 0;
  4602. p = 0;
  4603. } else if (xp) {
  4604. m = +m + 1;
  4605. p = 0;
  4606. }
  4607. } else if (gtlt === '<=') {
  4608. // <=0.7.x is actually <0.8.0, since any 0.7.x should
  4609. // pass. Similarly, <=7.x is actually <8.0.0, etc.
  4610. gtlt = '<';
  4611. if (xm) M = +M + 1;else m = +m + 1;
  4612. }
  4613. ret = gtlt + M + '.' + m + '.' + p;
  4614. } else if (xm) {
  4615. ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0';
  4616. } else if (xp) {
  4617. ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0';
  4618. }
  4619. debug('xRange return', ret);
  4620. return ret;
  4621. });
  4622. } // Because * is AND-ed with everything else in the comparator,
  4623. // and '' means "any version", just remove the *s entirely.
  4624. function replaceStars(comp, loose) {
  4625. debug('replaceStars', comp, loose); // Looseness is ignored here. star is always as loose as it gets!
  4626. return comp.trim().replace(re[STAR], '');
  4627. } // This function is passed to string.replace(re[HYPHENRANGE])
  4628. // M, m, patch, prerelease, build
  4629. // 1.2 - 3.4.5 => >=1.2.0 <=3.4.5
  4630. // 1.2.3 - 3.4 => >=1.2.0 <3.5.0 Any 3.4.x will do
  4631. // 1.2 - 3.4 => >=1.2.0 <3.5.0
  4632. function hyphenReplace($0, from, fM, fm, fp, fpr, fb, to, tM, tm, tp, tpr, tb) {
  4633. if (isX(fM)) from = '';else if (isX(fm)) from = '>=' + fM + '.0.0';else if (isX(fp)) from = '>=' + fM + '.' + fm + '.0';else from = '>=' + from;
  4634. 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;
  4635. return (from + ' ' + to).trim();
  4636. } // if ANY of the sets match ALL of its comparators, then pass
  4637. Range.prototype.test = function (version) {
  4638. if (!version) return false;
  4639. if (typeof version === 'string') version = new SemVer(version, this.loose);
  4640. for (var i = 0; i < this.set.length; i++) {
  4641. if (testSet(this.set[i], version)) return true;
  4642. }
  4643. return false;
  4644. };
  4645. function testSet(set, version) {
  4646. for (var i = 0; i < set.length; i++) {
  4647. if (!set[i].test(version)) return false;
  4648. }
  4649. if (version.prerelease.length) {
  4650. // Find the set of versions that are allowed to have prereleases
  4651. // For example, ^1.2.3-pr.1 desugars to >=1.2.3-pr.1 <2.0.0
  4652. // That should allow `1.2.3-pr.2` to pass.
  4653. // However, `1.2.4-alpha.notready` should NOT be allowed,
  4654. // even though it's within the range set by the comparators.
  4655. for (var i = 0; i < set.length; i++) {
  4656. debug(set[i].semver);
  4657. if (set[i].semver === ANY) continue;
  4658. if (set[i].semver.prerelease.length > 0) {
  4659. var allowed = set[i].semver;
  4660. if (allowed.major === version.major && allowed.minor === version.minor && allowed.patch === version.patch) return true;
  4661. }
  4662. } // Version has a -pre, but it's not one of the ones we like.
  4663. return false;
  4664. }
  4665. return true;
  4666. }
  4667. exports.satisfies = satisfies;
  4668. function satisfies(version, range, loose) {
  4669. try {
  4670. range = new Range(range, loose);
  4671. } catch (er) {
  4672. return false;
  4673. }
  4674. return range.test(version);
  4675. }
  4676. exports.maxSatisfying = maxSatisfying;
  4677. function maxSatisfying(versions$$1, range, loose) {
  4678. var max = null;
  4679. var maxSV = null;
  4680. try {
  4681. var rangeObj = new Range(range, loose);
  4682. } catch (er) {
  4683. return null;
  4684. }
  4685. versions$$1.forEach(function (v) {
  4686. if (rangeObj.test(v)) {
  4687. // satisfies(v, range, loose)
  4688. if (!max || maxSV.compare(v) === -1) {
  4689. // compare(max, v, true)
  4690. max = v;
  4691. maxSV = new SemVer(max, loose);
  4692. }
  4693. }
  4694. });
  4695. return max;
  4696. }
  4697. exports.minSatisfying = minSatisfying;
  4698. function minSatisfying(versions$$1, range, loose) {
  4699. var min = null;
  4700. var minSV = null;
  4701. try {
  4702. var rangeObj = new Range(range, loose);
  4703. } catch (er) {
  4704. return null;
  4705. }
  4706. versions$$1.forEach(function (v) {
  4707. if (rangeObj.test(v)) {
  4708. // satisfies(v, range, loose)
  4709. if (!min || minSV.compare(v) === 1) {
  4710. // compare(min, v, true)
  4711. min = v;
  4712. minSV = new SemVer(min, loose);
  4713. }
  4714. }
  4715. });
  4716. return min;
  4717. }
  4718. exports.validRange = validRange;
  4719. function validRange(range, loose) {
  4720. try {
  4721. // Return '*' instead of '' so that truthiness works.
  4722. // This will throw if it's invalid anyway
  4723. return new Range(range, loose).range || '*';
  4724. } catch (er) {
  4725. return null;
  4726. }
  4727. } // Determine if version is less than all the versions possible in the range
  4728. exports.ltr = ltr;
  4729. function ltr(version, range, loose) {
  4730. return outside(version, range, '<', loose);
  4731. } // Determine if version is greater than all the versions possible in the range.
  4732. exports.gtr = gtr;
  4733. function gtr(version, range, loose) {
  4734. return outside(version, range, '>', loose);
  4735. }
  4736. exports.outside = outside;
  4737. function outside(version, range, hilo, loose) {
  4738. version = new SemVer(version, loose);
  4739. range = new Range(range, loose);
  4740. var gtfn, ltefn, ltfn, comp, ecomp;
  4741. switch (hilo) {
  4742. case '>':
  4743. gtfn = gt;
  4744. ltefn = lte;
  4745. ltfn = lt;
  4746. comp = '>';
  4747. ecomp = '>=';
  4748. break;
  4749. case '<':
  4750. gtfn = lt;
  4751. ltefn = gte;
  4752. ltfn = gt;
  4753. comp = '<';
  4754. ecomp = '<=';
  4755. break;
  4756. default:
  4757. throw new TypeError('Must provide a hilo val of "<" or ">"');
  4758. } // If it satisifes the range it is not outside
  4759. if (satisfies(version, range, loose)) {
  4760. return false;
  4761. } // From now on, variable terms are as if we're in "gtr" mode.
  4762. // but note that everything is flipped for the "ltr" function.
  4763. for (var i = 0; i < range.set.length; ++i) {
  4764. var comparators = range.set[i];
  4765. var high = null;
  4766. var low = null;
  4767. comparators.forEach(function (comparator) {
  4768. if (comparator.semver === ANY) {
  4769. comparator = new Comparator('>=0.0.0');
  4770. }
  4771. high = high || comparator;
  4772. low = low || comparator;
  4773. if (gtfn(comparator.semver, high.semver, loose)) {
  4774. high = comparator;
  4775. } else if (ltfn(comparator.semver, low.semver, loose)) {
  4776. low = comparator;
  4777. }
  4778. }); // If the edge version comparator has a operator then our version
  4779. // isn't outside it
  4780. if (high.operator === comp || high.operator === ecomp) {
  4781. return false;
  4782. } // If the lowest version comparator has an operator and our version
  4783. // is less than it then it isn't higher than the range
  4784. if ((!low.operator || low.operator === comp) && ltefn(version, low.semver)) {
  4785. return false;
  4786. } else if (low.operator === ecomp && ltfn(version, low.semver)) {
  4787. return false;
  4788. }
  4789. }
  4790. return true;
  4791. }
  4792. exports.prerelease = prerelease;
  4793. function prerelease(version, loose) {
  4794. var parsed = parse(version, loose);
  4795. return parsed && parsed.prerelease.length ? parsed.prerelease : null;
  4796. }
  4797. exports.intersects = intersects;
  4798. function intersects(r1, r2, loose) {
  4799. r1 = new Range(r1, loose);
  4800. r2 = new Range(r2, loose);
  4801. return r1.intersects(r2);
  4802. }
  4803. });
  4804. var arrayify = function arrayify(object, keyName) {
  4805. return Object.keys(object).reduce(function (array, key) {
  4806. return array.concat(Object.assign(_defineProperty({}, keyName, key), object[key]));
  4807. }, []);
  4808. };
  4809. var dedent_1 = createCommonjsModule(function (module) {
  4810. "use strict";
  4811. function dedent(strings) {
  4812. var raw = void 0;
  4813. if (typeof strings === "string") {
  4814. // dedent can be used as a plain function
  4815. raw = [strings];
  4816. } else {
  4817. raw = strings.raw;
  4818. } // first, perform interpolation
  4819. var result = "";
  4820. for (var i = 0; i < raw.length; i++) {
  4821. result += raw[i]. // join lines when there is a suppressed newline
  4822. replace(/\\\n[ \t]*/g, ""). // handle escaped backticks
  4823. replace(/\\`/g, "`");
  4824. if (i < (arguments.length <= 1 ? 0 : arguments.length - 1)) {
  4825. result += arguments.length <= i + 1 ? undefined : arguments[i + 1];
  4826. }
  4827. } // now strip indentation
  4828. var lines = result.split("\n");
  4829. var mindent = null;
  4830. lines.forEach(function (l) {
  4831. var m = l.match(/^(\s+)\S+/);
  4832. if (m) {
  4833. var indent = m[1].length;
  4834. if (!mindent) {
  4835. // this is the first indented line
  4836. mindent = indent;
  4837. } else {
  4838. mindent = Math.min(mindent, indent);
  4839. }
  4840. }
  4841. });
  4842. if (mindent !== null) {
  4843. result = lines.map(function (l) {
  4844. return l[0] === " " ? l.slice(mindent) : l;
  4845. }).join("\n");
  4846. } // dedent eats leading and trailing whitespace too
  4847. result = result.trim(); // handle escaped newlines at the end to ensure they don't get stripped too
  4848. return result.replace(/\\n/g, "\n");
  4849. }
  4850. {
  4851. module.exports = dedent;
  4852. }
  4853. });
  4854. function _templateObject6() {
  4855. 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 "]);
  4856. _templateObject6 = function _templateObject6() {
  4857. return data;
  4858. };
  4859. return data;
  4860. }
  4861. function _templateObject5() {
  4862. 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 "]);
  4863. _templateObject5 = function _templateObject5() {
  4864. return data;
  4865. };
  4866. return data;
  4867. }
  4868. function _templateObject4() {
  4869. 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 "]);
  4870. _templateObject4 = function _templateObject4() {
  4871. return data;
  4872. };
  4873. return data;
  4874. }
  4875. function _templateObject3() {
  4876. 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 "]);
  4877. _templateObject3 = function _templateObject3() {
  4878. return data;
  4879. };
  4880. return data;
  4881. }
  4882. function _templateObject2() {
  4883. var data = _taggedTemplateLiteral(["\n Maintain existing\n (mixed values within one file are normalised by looking at what's used after the first line)\n "]);
  4884. _templateObject2 = function _templateObject2() {
  4885. return data;
  4886. };
  4887. return data;
  4888. }
  4889. function _templateObject() {
  4890. 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 "]);
  4891. _templateObject = function _templateObject() {
  4892. return data;
  4893. };
  4894. return data;
  4895. }
  4896. var CATEGORY_CONFIG = "Config";
  4897. var CATEGORY_EDITOR = "Editor";
  4898. var CATEGORY_FORMAT = "Format";
  4899. var CATEGORY_OTHER = "Other";
  4900. var CATEGORY_OUTPUT = "Output";
  4901. var CATEGORY_GLOBAL = "Global";
  4902. var CATEGORY_SPECIAL = "Special";
  4903. /**
  4904. * @typedef {Object} OptionInfo
  4905. * @property {string} since - available since version
  4906. * @property {string} category
  4907. * @property {'int' | 'boolean' | 'choice' | 'path'} type
  4908. * @property {boolean} array - indicate it's an array of the specified type
  4909. * @property {boolean?} deprecated - deprecated since version
  4910. * @property {OptionRedirectInfo?} redirect - redirect deprecated option
  4911. * @property {string} description
  4912. * @property {string?} oppositeDescription - for `false` option
  4913. * @property {OptionValueInfo} default
  4914. * @property {OptionRangeInfo?} range - for type int
  4915. * @property {OptionChoiceInfo?} choices - for type choice
  4916. * @property {(value: any) => boolean} exception
  4917. *
  4918. * @typedef {number | boolean | string} OptionValue
  4919. * @typedef {OptionValue | [{ value: OptionValue[] }] | Array<{ since: string, value: OptionValue}>} OptionValueInfo
  4920. *
  4921. * @typedef {Object} OptionRedirectInfo
  4922. * @property {string} option
  4923. * @property {OptionValue} value
  4924. *
  4925. * @typedef {Object} OptionRangeInfo
  4926. * @property {number} start - recommended range start
  4927. * @property {number} end - recommended range end
  4928. * @property {number} step - recommended range step
  4929. *
  4930. * @typedef {Object} OptionChoiceInfo
  4931. * @property {boolean | string} value - boolean for the option that is originally boolean type
  4932. * @property {string?} description - undefined if redirect
  4933. * @property {string?} since - undefined if available since the first version of the option
  4934. * @property {string?} deprecated - deprecated since version
  4935. * @property {OptionValueInfo?} redirect - redirect deprecated value
  4936. *
  4937. * @property {string?} cliName
  4938. * @property {string?} cliCategory
  4939. * @property {string?} cliDescription
  4940. */
  4941. /** @type {{ [name: string]: OptionInfo } */
  4942. var options$2 = {
  4943. cursorOffset: {
  4944. since: "1.4.0",
  4945. category: CATEGORY_SPECIAL,
  4946. type: "int",
  4947. default: -1,
  4948. range: {
  4949. start: -1,
  4950. end: Infinity,
  4951. step: 1
  4952. },
  4953. description: dedent_1(_templateObject()),
  4954. cliCategory: CATEGORY_EDITOR
  4955. },
  4956. endOfLine: {
  4957. since: "1.15.0",
  4958. category: CATEGORY_GLOBAL,
  4959. type: "choice",
  4960. default: "auto",
  4961. description: "Which end of line characters to apply.",
  4962. choices: [{
  4963. value: "auto",
  4964. description: dedent_1(_templateObject2())
  4965. }, {
  4966. value: "lf",
  4967. description: "Line Feed only (\\n), common on Linux and macOS as well as inside git repos"
  4968. }, {
  4969. value: "crlf",
  4970. description: "Carriage Return + Line Feed characters (\\r\\n), common on Windows"
  4971. }, {
  4972. value: "cr",
  4973. description: "Carriage Return character only (\\r), used very rarely"
  4974. }]
  4975. },
  4976. filepath: {
  4977. since: "1.4.0",
  4978. category: CATEGORY_SPECIAL,
  4979. type: "path",
  4980. description: "Specify the input filepath. This will be used to do parser inference.",
  4981. cliName: "stdin-filepath",
  4982. cliCategory: CATEGORY_OTHER,
  4983. cliDescription: "Path to the file to pretend that stdin comes from."
  4984. },
  4985. insertPragma: {
  4986. since: "1.8.0",
  4987. category: CATEGORY_SPECIAL,
  4988. type: "boolean",
  4989. default: false,
  4990. description: "Insert @format pragma into file's first docblock comment.",
  4991. cliCategory: CATEGORY_OTHER
  4992. },
  4993. parser: {
  4994. since: "0.0.10",
  4995. category: CATEGORY_GLOBAL,
  4996. type: "choice",
  4997. default: [{
  4998. since: "0.0.10",
  4999. value: "babylon"
  5000. }, {
  5001. since: "1.13.0",
  5002. value: undefined
  5003. }],
  5004. description: "Which parser to use.",
  5005. exception: function exception(value) {
  5006. return typeof value === "string" || typeof value === "function";
  5007. },
  5008. choices: [{
  5009. value: "flow",
  5010. description: "Flow"
  5011. }, {
  5012. value: "babylon",
  5013. description: "JavaScript",
  5014. deprecated: "1.16.0",
  5015. redirect: "babel"
  5016. }, {
  5017. value: "babel",
  5018. since: "1.16.0",
  5019. description: "JavaScript"
  5020. }, {
  5021. value: "babel-flow",
  5022. since: "1.16.0",
  5023. description: "Flow"
  5024. }, {
  5025. value: "typescript",
  5026. since: "1.4.0",
  5027. description: "TypeScript"
  5028. }, {
  5029. value: "css",
  5030. since: "1.7.1",
  5031. description: "CSS"
  5032. }, {
  5033. value: "postcss",
  5034. since: "1.4.0",
  5035. description: "CSS/Less/SCSS",
  5036. deprecated: "1.7.1",
  5037. redirect: "css"
  5038. }, {
  5039. value: "less",
  5040. since: "1.7.1",
  5041. description: "Less"
  5042. }, {
  5043. value: "scss",
  5044. since: "1.7.1",
  5045. description: "SCSS"
  5046. }, {
  5047. value: "json",
  5048. since: "1.5.0",
  5049. description: "JSON"
  5050. }, {
  5051. value: "json5",
  5052. since: "1.13.0",
  5053. description: "JSON5"
  5054. }, {
  5055. value: "json-stringify",
  5056. since: "1.13.0",
  5057. description: "JSON.stringify"
  5058. }, {
  5059. value: "graphql",
  5060. since: "1.5.0",
  5061. description: "GraphQL"
  5062. }, {
  5063. value: "markdown",
  5064. since: "1.8.0",
  5065. description: "Markdown"
  5066. }, {
  5067. value: "mdx",
  5068. since: "1.15.0",
  5069. description: "MDX"
  5070. }, {
  5071. value: "vue",
  5072. since: "1.10.0",
  5073. description: "Vue"
  5074. }, {
  5075. value: "yaml",
  5076. since: "1.14.0",
  5077. description: "YAML"
  5078. }, {
  5079. value: "glimmer",
  5080. since: null,
  5081. description: "Handlebars"
  5082. }, {
  5083. value: "html",
  5084. since: "1.15.0",
  5085. description: "HTML"
  5086. }, {
  5087. value: "angular",
  5088. since: "1.15.0",
  5089. description: "Angular"
  5090. }]
  5091. },
  5092. plugins: {
  5093. since: "1.10.0",
  5094. type: "path",
  5095. array: true,
  5096. default: [{
  5097. value: []
  5098. }],
  5099. category: CATEGORY_GLOBAL,
  5100. description: "Add a plugin. Multiple plugins can be passed as separate `--plugin`s.",
  5101. exception: function exception(value) {
  5102. return typeof value === "string" || _typeof(value) === "object";
  5103. },
  5104. cliName: "plugin",
  5105. cliCategory: CATEGORY_CONFIG
  5106. },
  5107. pluginSearchDirs: {
  5108. since: "1.13.0",
  5109. type: "path",
  5110. array: true,
  5111. default: [{
  5112. value: []
  5113. }],
  5114. category: CATEGORY_GLOBAL,
  5115. description: dedent_1(_templateObject3()),
  5116. exception: function exception(value) {
  5117. return typeof value === "string" || _typeof(value) === "object";
  5118. },
  5119. cliName: "plugin-search-dir",
  5120. cliCategory: CATEGORY_CONFIG
  5121. },
  5122. printWidth: {
  5123. since: "0.0.0",
  5124. category: CATEGORY_GLOBAL,
  5125. type: "int",
  5126. default: 80,
  5127. description: "The line length where Prettier will try wrap.",
  5128. range: {
  5129. start: 0,
  5130. end: Infinity,
  5131. step: 1
  5132. }
  5133. },
  5134. rangeEnd: {
  5135. since: "1.4.0",
  5136. category: CATEGORY_SPECIAL,
  5137. type: "int",
  5138. default: Infinity,
  5139. range: {
  5140. start: 0,
  5141. end: Infinity,
  5142. step: 1
  5143. },
  5144. description: dedent_1(_templateObject4()),
  5145. cliCategory: CATEGORY_EDITOR
  5146. },
  5147. rangeStart: {
  5148. since: "1.4.0",
  5149. category: CATEGORY_SPECIAL,
  5150. type: "int",
  5151. default: 0,
  5152. range: {
  5153. start: 0,
  5154. end: Infinity,
  5155. step: 1
  5156. },
  5157. description: dedent_1(_templateObject5()),
  5158. cliCategory: CATEGORY_EDITOR
  5159. },
  5160. requirePragma: {
  5161. since: "1.7.0",
  5162. category: CATEGORY_SPECIAL,
  5163. type: "boolean",
  5164. default: false,
  5165. description: dedent_1(_templateObject6()),
  5166. cliCategory: CATEGORY_OTHER
  5167. },
  5168. tabWidth: {
  5169. type: "int",
  5170. category: CATEGORY_GLOBAL,
  5171. default: 2,
  5172. description: "Number of spaces per indentation level.",
  5173. range: {
  5174. start: 0,
  5175. end: Infinity,
  5176. step: 1
  5177. }
  5178. },
  5179. useFlowParser: {
  5180. since: "0.0.0",
  5181. category: CATEGORY_GLOBAL,
  5182. type: "boolean",
  5183. default: [{
  5184. since: "0.0.0",
  5185. value: false
  5186. }, {
  5187. since: "1.15.0",
  5188. value: undefined
  5189. }],
  5190. deprecated: "0.0.10",
  5191. description: "Use flow parser.",
  5192. redirect: {
  5193. option: "parser",
  5194. value: "flow"
  5195. },
  5196. cliName: "flow-parser"
  5197. },
  5198. useTabs: {
  5199. since: "1.0.0",
  5200. category: CATEGORY_GLOBAL,
  5201. type: "boolean",
  5202. default: false,
  5203. description: "Indent with tabs instead of spaces."
  5204. }
  5205. };
  5206. var coreOptions$1 = {
  5207. CATEGORY_CONFIG: CATEGORY_CONFIG,
  5208. CATEGORY_EDITOR: CATEGORY_EDITOR,
  5209. CATEGORY_FORMAT: CATEGORY_FORMAT,
  5210. CATEGORY_OTHER: CATEGORY_OTHER,
  5211. CATEGORY_OUTPUT: CATEGORY_OUTPUT,
  5212. CATEGORY_GLOBAL: CATEGORY_GLOBAL,
  5213. CATEGORY_SPECIAL: CATEGORY_SPECIAL,
  5214. options: options$2
  5215. };
  5216. var require$$0 = ( _package$1 && _package ) || _package$1;
  5217. var currentVersion = require$$0.version;
  5218. var coreOptions = coreOptions$1.options;
  5219. function getSupportInfo$2(version, opts) {
  5220. opts = Object.assign({
  5221. plugins: [],
  5222. showUnreleased: false,
  5223. showDeprecated: false,
  5224. showInternal: false
  5225. }, opts);
  5226. if (!version) {
  5227. // pre-release version is smaller than the normal version in semver,
  5228. // we need to treat it as the normal one so as to test new features.
  5229. version = currentVersion.split("-", 1)[0];
  5230. }
  5231. var plugins = opts.plugins;
  5232. var options = arrayify(Object.assign(plugins.reduce(function (currentOptions, plugin) {
  5233. return Object.assign(currentOptions, plugin.options);
  5234. }, {}), coreOptions), "name").sort(function (a, b) {
  5235. return a.name === b.name ? 0 : a.name < b.name ? -1 : 1;
  5236. }).filter(filterSince).filter(filterDeprecated).map(mapDeprecated).map(mapInternal).map(function (option) {
  5237. var newOption = Object.assign({}, option);
  5238. if (Array.isArray(newOption.default)) {
  5239. newOption.default = newOption.default.length === 1 ? newOption.default[0].value : newOption.default.filter(filterSince).sort(function (info1, info2) {
  5240. return semver.compare(info2.since, info1.since);
  5241. })[0].value;
  5242. }
  5243. if (Array.isArray(newOption.choices)) {
  5244. newOption.choices = newOption.choices.filter(filterSince).filter(filterDeprecated).map(mapDeprecated);
  5245. }
  5246. return newOption;
  5247. }).map(function (option) {
  5248. var filteredPlugins = plugins.filter(function (plugin) {
  5249. return plugin.defaultOptions && plugin.defaultOptions[option.name];
  5250. });
  5251. var pluginDefaults = filteredPlugins.reduce(function (reduced, plugin) {
  5252. reduced[plugin.name] = plugin.defaultOptions[option.name];
  5253. return reduced;
  5254. }, {});
  5255. return Object.assign(option, {
  5256. pluginDefaults: pluginDefaults
  5257. });
  5258. });
  5259. var usePostCssParser = semver.lt(version, "1.7.1");
  5260. var languages = plugins.reduce(function (all, plugin) {
  5261. return all.concat(plugin.languages || []);
  5262. }, []).filter(filterSince).map(function (language) {
  5263. // Prevent breaking changes
  5264. if (language.name === "Markdown") {
  5265. return Object.assign({}, language, {
  5266. parsers: ["markdown"]
  5267. });
  5268. }
  5269. if (language.name === "TypeScript") {
  5270. return Object.assign({}, language, {
  5271. parsers: ["typescript"]
  5272. });
  5273. }
  5274. if (usePostCssParser && (language.name === "CSS" || language.group === "CSS")) {
  5275. return Object.assign({}, language, {
  5276. parsers: ["postcss"]
  5277. });
  5278. }
  5279. return language;
  5280. });
  5281. return {
  5282. languages: languages,
  5283. options: options
  5284. };
  5285. function filterSince(object) {
  5286. return opts.showUnreleased || !("since" in object) || object.since && semver.gte(version, object.since);
  5287. }
  5288. function filterDeprecated(object) {
  5289. return opts.showDeprecated || !("deprecated" in object) || object.deprecated && semver.lt(version, object.deprecated);
  5290. }
  5291. function mapDeprecated(object) {
  5292. if (!object.deprecated || opts.showDeprecated) {
  5293. return object;
  5294. }
  5295. var newObject = Object.assign({}, object);
  5296. delete newObject.deprecated;
  5297. delete newObject.redirect;
  5298. return newObject;
  5299. }
  5300. function mapInternal(object) {
  5301. if (opts.showInternal) {
  5302. return object;
  5303. }
  5304. var newObject = Object.assign({}, object);
  5305. delete newObject.cliName;
  5306. delete newObject.cliCategory;
  5307. delete newObject.cliDescription;
  5308. return newObject;
  5309. }
  5310. }
  5311. var support = {
  5312. getSupportInfo: getSupportInfo$2
  5313. };
  5314. /*! *****************************************************************************
  5315. Copyright (c) Microsoft Corporation. All rights reserved.
  5316. Licensed under the Apache License, Version 2.0 (the "License"); you may not use
  5317. this file except in compliance with the License. You may obtain a copy of the
  5318. License at http://www.apache.org/licenses/LICENSE-2.0
  5319. THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  5320. KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  5321. WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  5322. MERCHANTABLITY OR NON-INFRINGEMENT.
  5323. See the Apache Version 2.0 License for specific language governing permissions
  5324. and limitations under the License.
  5325. ***************************************************************************** */
  5326. /* global Reflect, Promise */
  5327. var _extendStatics = function extendStatics(d, b) {
  5328. _extendStatics = Object.setPrototypeOf || {
  5329. __proto__: []
  5330. } instanceof Array && function (d, b) {
  5331. d.__proto__ = b;
  5332. } || function (d, b) {
  5333. for (var p in b) {
  5334. if (b.hasOwnProperty(p)) d[p] = b[p];
  5335. }
  5336. };
  5337. return _extendStatics(d, b);
  5338. };
  5339. function __extends(d, b) {
  5340. _extendStatics(d, b);
  5341. function __() {
  5342. this.constructor = d;
  5343. }
  5344. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  5345. }
  5346. var _assign = function __assign() {
  5347. _assign = Object.assign || function __assign(t) {
  5348. for (var s, i = 1, n = arguments.length; i < n; i++) {
  5349. s = arguments[i];
  5350. for (var p in s) {
  5351. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  5352. }
  5353. }
  5354. return t;
  5355. };
  5356. return _assign.apply(this, arguments);
  5357. };
  5358. function __rest(s, e) {
  5359. var t = {};
  5360. for (var p in s) {
  5361. if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
  5362. }
  5363. if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
  5364. if (e.indexOf(p[i]) < 0) t[p[i]] = s[p[i]];
  5365. }
  5366. return t;
  5367. }
  5368. function __decorate(decorators, target, key, desc) {
  5369. var c = arguments.length,
  5370. r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
  5371. d;
  5372. if ((typeof Reflect === "undefined" ? "undefined" : _typeof(Reflect)) === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) {
  5373. if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  5374. }
  5375. return c > 3 && r && Object.defineProperty(target, key, r), r;
  5376. }
  5377. function __param(paramIndex, decorator) {
  5378. return function (target, key) {
  5379. decorator(target, key, paramIndex);
  5380. };
  5381. }
  5382. function __metadata(metadataKey, metadataValue) {
  5383. if ((typeof Reflect === "undefined" ? "undefined" : _typeof(Reflect)) === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
  5384. }
  5385. function __awaiter(thisArg, _arguments, P, generator) {
  5386. return new (P || (P = Promise))(function (resolve, reject) {
  5387. function fulfilled(value) {
  5388. try {
  5389. step(generator.next(value));
  5390. } catch (e) {
  5391. reject(e);
  5392. }
  5393. }
  5394. function rejected(value) {
  5395. try {
  5396. step(generator["throw"](value));
  5397. } catch (e) {
  5398. reject(e);
  5399. }
  5400. }
  5401. function step(result) {
  5402. result.done ? resolve(result.value) : new P(function (resolve) {
  5403. resolve(result.value);
  5404. }).then(fulfilled, rejected);
  5405. }
  5406. step((generator = generator.apply(thisArg, _arguments || [])).next());
  5407. });
  5408. }
  5409. function __generator(thisArg, body) {
  5410. var _ = {
  5411. label: 0,
  5412. sent: function sent() {
  5413. if (t[0] & 1) throw t[1];
  5414. return t[1];
  5415. },
  5416. trys: [],
  5417. ops: []
  5418. },
  5419. f,
  5420. y,
  5421. t,
  5422. g;
  5423. return g = {
  5424. next: verb(0),
  5425. "throw": verb(1),
  5426. "return": verb(2)
  5427. }, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
  5428. return this;
  5429. }), g;
  5430. function verb(n) {
  5431. return function (v) {
  5432. return step([n, v]);
  5433. };
  5434. }
  5435. function step(op) {
  5436. if (f) throw new TypeError("Generator is already executing.");
  5437. while (_) {
  5438. try {
  5439. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  5440. if (y = 0, t) op = [op[0] & 2, t.value];
  5441. switch (op[0]) {
  5442. case 0:
  5443. case 1:
  5444. t = op;
  5445. break;
  5446. case 4:
  5447. _.label++;
  5448. return {
  5449. value: op[1],
  5450. done: false
  5451. };
  5452. case 5:
  5453. _.label++;
  5454. y = op[1];
  5455. op = [0];
  5456. continue;
  5457. case 7:
  5458. op = _.ops.pop();
  5459. _.trys.pop();
  5460. continue;
  5461. default:
  5462. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
  5463. _ = 0;
  5464. continue;
  5465. }
  5466. if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
  5467. _.label = op[1];
  5468. break;
  5469. }
  5470. if (op[0] === 6 && _.label < t[1]) {
  5471. _.label = t[1];
  5472. t = op;
  5473. break;
  5474. }
  5475. if (t && _.label < t[2]) {
  5476. _.label = t[2];
  5477. _.ops.push(op);
  5478. break;
  5479. }
  5480. if (t[2]) _.ops.pop();
  5481. _.trys.pop();
  5482. continue;
  5483. }
  5484. op = body.call(thisArg, _);
  5485. } catch (e) {
  5486. op = [6, e];
  5487. y = 0;
  5488. } finally {
  5489. f = t = 0;
  5490. }
  5491. }
  5492. if (op[0] & 5) throw op[1];
  5493. return {
  5494. value: op[0] ? op[1] : void 0,
  5495. done: true
  5496. };
  5497. }
  5498. }
  5499. function __exportStar(m, exports) {
  5500. for (var p in m) {
  5501. if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  5502. }
  5503. }
  5504. function __values(o) {
  5505. var m = typeof Symbol === "function" && o[Symbol.iterator],
  5506. i = 0;
  5507. if (m) return m.call(o);
  5508. return {
  5509. next: function next() {
  5510. if (o && i >= o.length) o = void 0;
  5511. return {
  5512. value: o && o[i++],
  5513. done: !o
  5514. };
  5515. }
  5516. };
  5517. }
  5518. function __read(o, n) {
  5519. var m = typeof Symbol === "function" && o[Symbol.iterator];
  5520. if (!m) return o;
  5521. var i = m.call(o),
  5522. r,
  5523. ar = [],
  5524. e;
  5525. try {
  5526. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) {
  5527. ar.push(r.value);
  5528. }
  5529. } catch (error) {
  5530. e = {
  5531. error: error
  5532. };
  5533. } finally {
  5534. try {
  5535. if (r && !r.done && (m = i["return"])) m.call(i);
  5536. } finally {
  5537. if (e) throw e.error;
  5538. }
  5539. }
  5540. return ar;
  5541. }
  5542. function __spread() {
  5543. for (var ar = [], i = 0; i < arguments.length; i++) {
  5544. ar = ar.concat(__read(arguments[i]));
  5545. }
  5546. return ar;
  5547. }
  5548. function __await(v) {
  5549. return this instanceof __await ? (this.v = v, this) : new __await(v);
  5550. }
  5551. function __asyncGenerator(thisArg, _arguments, generator) {
  5552. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  5553. var g = generator.apply(thisArg, _arguments || []),
  5554. i,
  5555. q = [];
  5556. return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () {
  5557. return this;
  5558. }, i;
  5559. function verb(n) {
  5560. if (g[n]) i[n] = function (v) {
  5561. return new Promise(function (a, b) {
  5562. q.push([n, v, a, b]) > 1 || resume(n, v);
  5563. });
  5564. };
  5565. }
  5566. function resume(n, v) {
  5567. try {
  5568. step(g[n](v));
  5569. } catch (e) {
  5570. settle(q[0][3], e);
  5571. }
  5572. }
  5573. function step(r) {
  5574. r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r);
  5575. }
  5576. function fulfill(value) {
  5577. resume("next", value);
  5578. }
  5579. function reject(value) {
  5580. resume("throw", value);
  5581. }
  5582. function settle(f, v) {
  5583. if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]);
  5584. }
  5585. }
  5586. function __asyncDelegator(o) {
  5587. var i, p;
  5588. return i = {}, verb("next"), verb("throw", function (e) {
  5589. throw e;
  5590. }), verb("return"), i[Symbol.iterator] = function () {
  5591. return this;
  5592. }, i;
  5593. function verb(n, f) {
  5594. i[n] = o[n] ? function (v) {
  5595. return (p = !p) ? {
  5596. value: __await(o[n](v)),
  5597. done: n === "return"
  5598. } : f ? f(v) : v;
  5599. } : f;
  5600. }
  5601. }
  5602. function __asyncValues(o) {
  5603. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  5604. var m = o[Symbol.asyncIterator],
  5605. i;
  5606. return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () {
  5607. return this;
  5608. }, i);
  5609. function verb(n) {
  5610. i[n] = o[n] && function (v) {
  5611. return new Promise(function (resolve, reject) {
  5612. v = o[n](v), settle(resolve, reject, v.done, v.value);
  5613. });
  5614. };
  5615. }
  5616. function settle(resolve, reject, d, v) {
  5617. Promise.resolve(v).then(function (v) {
  5618. resolve({
  5619. value: v,
  5620. done: d
  5621. });
  5622. }, reject);
  5623. }
  5624. }
  5625. function __makeTemplateObject(cooked, raw) {
  5626. if (Object.defineProperty) {
  5627. Object.defineProperty(cooked, "raw", {
  5628. value: raw
  5629. });
  5630. } else {
  5631. cooked.raw = raw;
  5632. }
  5633. return cooked;
  5634. }
  5635. function __importStar(mod) {
  5636. if (mod && mod.__esModule) return mod;
  5637. var result = {};
  5638. if (mod != null) for (var k in mod) {
  5639. if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  5640. }
  5641. result.default = mod;
  5642. return result;
  5643. }
  5644. function __importDefault(mod) {
  5645. return mod && mod.__esModule ? mod : {
  5646. default: mod
  5647. };
  5648. }
  5649. var tslib_1 = Object.freeze({
  5650. __extends: __extends,
  5651. get __assign () { return _assign; },
  5652. __rest: __rest,
  5653. __decorate: __decorate,
  5654. __param: __param,
  5655. __metadata: __metadata,
  5656. __awaiter: __awaiter,
  5657. __generator: __generator,
  5658. __exportStar: __exportStar,
  5659. __values: __values,
  5660. __read: __read,
  5661. __spread: __spread,
  5662. __await: __await,
  5663. __asyncGenerator: __asyncGenerator,
  5664. __asyncDelegator: __asyncDelegator,
  5665. __asyncValues: __asyncValues,
  5666. __makeTemplateObject: __makeTemplateObject,
  5667. __importStar: __importStar,
  5668. __importDefault: __importDefault
  5669. });
  5670. var api = createCommonjsModule(function (module, exports) {
  5671. "use strict";
  5672. Object.defineProperty(exports, "__esModule", {
  5673. value: true
  5674. });
  5675. exports.apiDescriptor = {
  5676. key: function key(_key) {
  5677. return /^[$_a-zA-Z][$_a-zA-Z0-9]*$/.test(_key) ? _key : JSON.stringify(_key);
  5678. },
  5679. value: function value(_value) {
  5680. if (_value === null || _typeof(_value) !== 'object') {
  5681. return JSON.stringify(_value);
  5682. }
  5683. if (Array.isArray(_value)) {
  5684. return "[".concat(_value.map(function (subValue) {
  5685. return exports.apiDescriptor.value(subValue);
  5686. }).join(', '), "]");
  5687. }
  5688. var keys = Object.keys(_value);
  5689. return keys.length === 0 ? '{}' : "{ ".concat(keys.map(function (key) {
  5690. return "".concat(exports.apiDescriptor.key(key), ": ").concat(exports.apiDescriptor.value(_value[key]));
  5691. }).join(', '), " }");
  5692. },
  5693. pair: function pair(_ref) {
  5694. var key = _ref.key,
  5695. value = _ref.value;
  5696. return exports.apiDescriptor.value(_defineProperty({}, key, value));
  5697. }
  5698. };
  5699. });
  5700. unwrapExports(api);
  5701. var descriptors = createCommonjsModule(function (module, exports) {
  5702. "use strict";
  5703. Object.defineProperty(exports, "__esModule", {
  5704. value: true
  5705. });
  5706. tslib_1.__exportStar(api, exports);
  5707. });
  5708. unwrapExports(descriptors);
  5709. var matchOperatorsRe = /[|\\{}()[\]^$+*?.]/g;
  5710. var escapeStringRegexp = function escapeStringRegexp(str) {
  5711. if (typeof str !== 'string') {
  5712. throw new TypeError('Expected a string');
  5713. }
  5714. return str.replace(matchOperatorsRe, '\\$&');
  5715. };
  5716. var colorName = {
  5717. "aliceblue": [240, 248, 255],
  5718. "antiquewhite": [250, 235, 215],
  5719. "aqua": [0, 255, 255],
  5720. "aquamarine": [127, 255, 212],
  5721. "azure": [240, 255, 255],
  5722. "beige": [245, 245, 220],
  5723. "bisque": [255, 228, 196],
  5724. "black": [0, 0, 0],
  5725. "blanchedalmond": [255, 235, 205],
  5726. "blue": [0, 0, 255],
  5727. "blueviolet": [138, 43, 226],
  5728. "brown": [165, 42, 42],
  5729. "burlywood": [222, 184, 135],
  5730. "cadetblue": [95, 158, 160],
  5731. "chartreuse": [127, 255, 0],
  5732. "chocolate": [210, 105, 30],
  5733. "coral": [255, 127, 80],
  5734. "cornflowerblue": [100, 149, 237],
  5735. "cornsilk": [255, 248, 220],
  5736. "crimson": [220, 20, 60],
  5737. "cyan": [0, 255, 255],
  5738. "darkblue": [0, 0, 139],
  5739. "darkcyan": [0, 139, 139],
  5740. "darkgoldenrod": [184, 134, 11],
  5741. "darkgray": [169, 169, 169],
  5742. "darkgreen": [0, 100, 0],
  5743. "darkgrey": [169, 169, 169],
  5744. "darkkhaki": [189, 183, 107],
  5745. "darkmagenta": [139, 0, 139],
  5746. "darkolivegreen": [85, 107, 47],
  5747. "darkorange": [255, 140, 0],
  5748. "darkorchid": [153, 50, 204],
  5749. "darkred": [139, 0, 0],
  5750. "darksalmon": [233, 150, 122],
  5751. "darkseagreen": [143, 188, 143],
  5752. "darkslateblue": [72, 61, 139],
  5753. "darkslategray": [47, 79, 79],
  5754. "darkslategrey": [47, 79, 79],
  5755. "darkturquoise": [0, 206, 209],
  5756. "darkviolet": [148, 0, 211],
  5757. "deeppink": [255, 20, 147],
  5758. "deepskyblue": [0, 191, 255],
  5759. "dimgray": [105, 105, 105],
  5760. "dimgrey": [105, 105, 105],
  5761. "dodgerblue": [30, 144, 255],
  5762. "firebrick": [178, 34, 34],
  5763. "floralwhite": [255, 250, 240],
  5764. "forestgreen": [34, 139, 34],
  5765. "fuchsia": [255, 0, 255],
  5766. "gainsboro": [220, 220, 220],
  5767. "ghostwhite": [248, 248, 255],
  5768. "gold": [255, 215, 0],
  5769. "goldenrod": [218, 165, 32],
  5770. "gray": [128, 128, 128],
  5771. "green": [0, 128, 0],
  5772. "greenyellow": [173, 255, 47],
  5773. "grey": [128, 128, 128],
  5774. "honeydew": [240, 255, 240],
  5775. "hotpink": [255, 105, 180],
  5776. "indianred": [205, 92, 92],
  5777. "indigo": [75, 0, 130],
  5778. "ivory": [255, 255, 240],
  5779. "khaki": [240, 230, 140],
  5780. "lavender": [230, 230, 250],
  5781. "lavenderblush": [255, 240, 245],
  5782. "lawngreen": [124, 252, 0],
  5783. "lemonchiffon": [255, 250, 205],
  5784. "lightblue": [173, 216, 230],
  5785. "lightcoral": [240, 128, 128],
  5786. "lightcyan": [224, 255, 255],
  5787. "lightgoldenrodyellow": [250, 250, 210],
  5788. "lightgray": [211, 211, 211],
  5789. "lightgreen": [144, 238, 144],
  5790. "lightgrey": [211, 211, 211],
  5791. "lightpink": [255, 182, 193],
  5792. "lightsalmon": [255, 160, 122],
  5793. "lightseagreen": [32, 178, 170],
  5794. "lightskyblue": [135, 206, 250],
  5795. "lightslategray": [119, 136, 153],
  5796. "lightslategrey": [119, 136, 153],
  5797. "lightsteelblue": [176, 196, 222],
  5798. "lightyellow": [255, 255, 224],
  5799. "lime": [0, 255, 0],
  5800. "limegreen": [50, 205, 50],
  5801. "linen": [250, 240, 230],
  5802. "magenta": [255, 0, 255],
  5803. "maroon": [128, 0, 0],
  5804. "mediumaquamarine": [102, 205, 170],
  5805. "mediumblue": [0, 0, 205],
  5806. "mediumorchid": [186, 85, 211],
  5807. "mediumpurple": [147, 112, 219],
  5808. "mediumseagreen": [60, 179, 113],
  5809. "mediumslateblue": [123, 104, 238],
  5810. "mediumspringgreen": [0, 250, 154],
  5811. "mediumturquoise": [72, 209, 204],
  5812. "mediumvioletred": [199, 21, 133],
  5813. "midnightblue": [25, 25, 112],
  5814. "mintcream": [245, 255, 250],
  5815. "mistyrose": [255, 228, 225],
  5816. "moccasin": [255, 228, 181],
  5817. "navajowhite": [255, 222, 173],
  5818. "navy": [0, 0, 128],
  5819. "oldlace": [253, 245, 230],
  5820. "olive": [128, 128, 0],
  5821. "olivedrab": [107, 142, 35],
  5822. "orange": [255, 165, 0],
  5823. "orangered": [255, 69, 0],
  5824. "orchid": [218, 112, 214],
  5825. "palegoldenrod": [238, 232, 170],
  5826. "palegreen": [152, 251, 152],
  5827. "paleturquoise": [175, 238, 238],
  5828. "palevioletred": [219, 112, 147],
  5829. "papayawhip": [255, 239, 213],
  5830. "peachpuff": [255, 218, 185],
  5831. "peru": [205, 133, 63],
  5832. "pink": [255, 192, 203],
  5833. "plum": [221, 160, 221],
  5834. "powderblue": [176, 224, 230],
  5835. "purple": [128, 0, 128],
  5836. "rebeccapurple": [102, 51, 153],
  5837. "red": [255, 0, 0],
  5838. "rosybrown": [188, 143, 143],
  5839. "royalblue": [65, 105, 225],
  5840. "saddlebrown": [139, 69, 19],
  5841. "salmon": [250, 128, 114],
  5842. "sandybrown": [244, 164, 96],
  5843. "seagreen": [46, 139, 87],
  5844. "seashell": [255, 245, 238],
  5845. "sienna": [160, 82, 45],
  5846. "silver": [192, 192, 192],
  5847. "skyblue": [135, 206, 235],
  5848. "slateblue": [106, 90, 205],
  5849. "slategray": [112, 128, 144],
  5850. "slategrey": [112, 128, 144],
  5851. "snow": [255, 250, 250],
  5852. "springgreen": [0, 255, 127],
  5853. "steelblue": [70, 130, 180],
  5854. "tan": [210, 180, 140],
  5855. "teal": [0, 128, 128],
  5856. "thistle": [216, 191, 216],
  5857. "tomato": [255, 99, 71],
  5858. "turquoise": [64, 224, 208],
  5859. "violet": [238, 130, 238],
  5860. "wheat": [245, 222, 179],
  5861. "white": [255, 255, 255],
  5862. "whitesmoke": [245, 245, 245],
  5863. "yellow": [255, 255, 0],
  5864. "yellowgreen": [154, 205, 50]
  5865. };
  5866. var conversions = createCommonjsModule(function (module) {
  5867. /* MIT license */
  5868. // NOTE: conversions should only return primitive values (i.e. arrays, or
  5869. // values that give correct `typeof` results).
  5870. // do not use box values types (i.e. Number(), String(), etc.)
  5871. var reverseKeywords = {};
  5872. for (var key in colorName) {
  5873. if (colorName.hasOwnProperty(key)) {
  5874. reverseKeywords[colorName[key]] = key;
  5875. }
  5876. }
  5877. var convert = module.exports = {
  5878. rgb: {
  5879. channels: 3,
  5880. labels: 'rgb'
  5881. },
  5882. hsl: {
  5883. channels: 3,
  5884. labels: 'hsl'
  5885. },
  5886. hsv: {
  5887. channels: 3,
  5888. labels: 'hsv'
  5889. },
  5890. hwb: {
  5891. channels: 3,
  5892. labels: 'hwb'
  5893. },
  5894. cmyk: {
  5895. channels: 4,
  5896. labels: 'cmyk'
  5897. },
  5898. xyz: {
  5899. channels: 3,
  5900. labels: 'xyz'
  5901. },
  5902. lab: {
  5903. channels: 3,
  5904. labels: 'lab'
  5905. },
  5906. lch: {
  5907. channels: 3,
  5908. labels: 'lch'
  5909. },
  5910. hex: {
  5911. channels: 1,
  5912. labels: ['hex']
  5913. },
  5914. keyword: {
  5915. channels: 1,
  5916. labels: ['keyword']
  5917. },
  5918. ansi16: {
  5919. channels: 1,
  5920. labels: ['ansi16']
  5921. },
  5922. ansi256: {
  5923. channels: 1,
  5924. labels: ['ansi256']
  5925. },
  5926. hcg: {
  5927. channels: 3,
  5928. labels: ['h', 'c', 'g']
  5929. },
  5930. apple: {
  5931. channels: 3,
  5932. labels: ['r16', 'g16', 'b16']
  5933. },
  5934. gray: {
  5935. channels: 1,
  5936. labels: ['gray']
  5937. }
  5938. }; // hide .channels and .labels properties
  5939. for (var model in convert) {
  5940. if (convert.hasOwnProperty(model)) {
  5941. if (!('channels' in convert[model])) {
  5942. throw new Error('missing channels property: ' + model);
  5943. }
  5944. if (!('labels' in convert[model])) {
  5945. throw new Error('missing channel labels property: ' + model);
  5946. }
  5947. if (convert[model].labels.length !== convert[model].channels) {
  5948. throw new Error('channel and label counts mismatch: ' + model);
  5949. }
  5950. var channels = convert[model].channels;
  5951. var labels = convert[model].labels;
  5952. delete convert[model].channels;
  5953. delete convert[model].labels;
  5954. Object.defineProperty(convert[model], 'channels', {
  5955. value: channels
  5956. });
  5957. Object.defineProperty(convert[model], 'labels', {
  5958. value: labels
  5959. });
  5960. }
  5961. }
  5962. convert.rgb.hsl = function (rgb) {
  5963. var r = rgb[0] / 255;
  5964. var g = rgb[1] / 255;
  5965. var b = rgb[2] / 255;
  5966. var min = Math.min(r, g, b);
  5967. var max = Math.max(r, g, b);
  5968. var delta = max - min;
  5969. var h;
  5970. var s;
  5971. var l;
  5972. if (max === min) {
  5973. h = 0;
  5974. } else if (r === max) {
  5975. h = (g - b) / delta;
  5976. } else if (g === max) {
  5977. h = 2 + (b - r) / delta;
  5978. } else if (b === max) {
  5979. h = 4 + (r - g) / delta;
  5980. }
  5981. h = Math.min(h * 60, 360);
  5982. if (h < 0) {
  5983. h += 360;
  5984. }
  5985. l = (min + max) / 2;
  5986. if (max === min) {
  5987. s = 0;
  5988. } else if (l <= 0.5) {
  5989. s = delta / (max + min);
  5990. } else {
  5991. s = delta / (2 - max - min);
  5992. }
  5993. return [h, s * 100, l * 100];
  5994. };
  5995. convert.rgb.hsv = function (rgb) {
  5996. var r = rgb[0];
  5997. var g = rgb[1];
  5998. var b = rgb[2];
  5999. var min = Math.min(r, g, b);
  6000. var max = Math.max(r, g, b);
  6001. var delta = max - min;
  6002. var h;
  6003. var s;
  6004. var v;
  6005. if (max === 0) {
  6006. s = 0;
  6007. } else {
  6008. s = delta / max * 1000 / 10;
  6009. }
  6010. if (max === min) {
  6011. h = 0;
  6012. } else if (r === max) {
  6013. h = (g - b) / delta;
  6014. } else if (g === max) {
  6015. h = 2 + (b - r) / delta;
  6016. } else if (b === max) {
  6017. h = 4 + (r - g) / delta;
  6018. }
  6019. h = Math.min(h * 60, 360);
  6020. if (h < 0) {
  6021. h += 360;
  6022. }
  6023. v = max / 255 * 1000 / 10;
  6024. return [h, s, v];
  6025. };
  6026. convert.rgb.hwb = function (rgb) {
  6027. var r = rgb[0];
  6028. var g = rgb[1];
  6029. var b = rgb[2];
  6030. var h = convert.rgb.hsl(rgb)[0];
  6031. var w = 1 / 255 * Math.min(r, Math.min(g, b));
  6032. b = 1 - 1 / 255 * Math.max(r, Math.max(g, b));
  6033. return [h, w * 100, b * 100];
  6034. };
  6035. convert.rgb.cmyk = function (rgb) {
  6036. var r = rgb[0] / 255;
  6037. var g = rgb[1] / 255;
  6038. var b = rgb[2] / 255;
  6039. var c;
  6040. var m;
  6041. var y;
  6042. var k;
  6043. k = Math.min(1 - r, 1 - g, 1 - b);
  6044. c = (1 - r - k) / (1 - k) || 0;
  6045. m = (1 - g - k) / (1 - k) || 0;
  6046. y = (1 - b - k) / (1 - k) || 0;
  6047. return [c * 100, m * 100, y * 100, k * 100];
  6048. };
  6049. /**
  6050. * See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
  6051. * */
  6052. function comparativeDistance(x, y) {
  6053. return Math.pow(x[0] - y[0], 2) + Math.pow(x[1] - y[1], 2) + Math.pow(x[2] - y[2], 2);
  6054. }
  6055. convert.rgb.keyword = function (rgb) {
  6056. var reversed = reverseKeywords[rgb];
  6057. if (reversed) {
  6058. return reversed;
  6059. }
  6060. var currentClosestDistance = Infinity;
  6061. var currentClosestKeyword;
  6062. for (var keyword in colorName) {
  6063. if (colorName.hasOwnProperty(keyword)) {
  6064. var value = colorName[keyword]; // Compute comparative distance
  6065. var distance = comparativeDistance(rgb, value); // Check if its less, if so set as closest
  6066. if (distance < currentClosestDistance) {
  6067. currentClosestDistance = distance;
  6068. currentClosestKeyword = keyword;
  6069. }
  6070. }
  6071. }
  6072. return currentClosestKeyword;
  6073. };
  6074. convert.keyword.rgb = function (keyword) {
  6075. return colorName[keyword];
  6076. };
  6077. convert.rgb.xyz = function (rgb) {
  6078. var r = rgb[0] / 255;
  6079. var g = rgb[1] / 255;
  6080. var b = rgb[2] / 255; // assume sRGB
  6081. r = r > 0.04045 ? Math.pow((r + 0.055) / 1.055, 2.4) : r / 12.92;
  6082. g = g > 0.04045 ? Math.pow((g + 0.055) / 1.055, 2.4) : g / 12.92;
  6083. b = b > 0.04045 ? Math.pow((b + 0.055) / 1.055, 2.4) : b / 12.92;
  6084. var x = r * 0.4124 + g * 0.3576 + b * 0.1805;
  6085. var y = r * 0.2126 + g * 0.7152 + b * 0.0722;
  6086. var z = r * 0.0193 + g * 0.1192 + b * 0.9505;
  6087. return [x * 100, y * 100, z * 100];
  6088. };
  6089. convert.rgb.lab = function (rgb) {
  6090. var xyz = convert.rgb.xyz(rgb);
  6091. var x = xyz[0];
  6092. var y = xyz[1];
  6093. var z = xyz[2];
  6094. var l;
  6095. var a;
  6096. var b;
  6097. x /= 95.047;
  6098. y /= 100;
  6099. z /= 108.883;
  6100. x = x > 0.008856 ? Math.pow(x, 1 / 3) : 7.787 * x + 16 / 116;
  6101. y = y > 0.008856 ? Math.pow(y, 1 / 3) : 7.787 * y + 16 / 116;
  6102. z = z > 0.008856 ? Math.pow(z, 1 / 3) : 7.787 * z + 16 / 116;
  6103. l = 116 * y - 16;
  6104. a = 500 * (x - y);
  6105. b = 200 * (y - z);
  6106. return [l, a, b];
  6107. };
  6108. convert.hsl.rgb = function (hsl) {
  6109. var h = hsl[0] / 360;
  6110. var s = hsl[1] / 100;
  6111. var l = hsl[2] / 100;
  6112. var t1;
  6113. var t2;
  6114. var t3;
  6115. var rgb;
  6116. var val;
  6117. if (s === 0) {
  6118. val = l * 255;
  6119. return [val, val, val];
  6120. }
  6121. if (l < 0.5) {
  6122. t2 = l * (1 + s);
  6123. } else {
  6124. t2 = l + s - l * s;
  6125. }
  6126. t1 = 2 * l - t2;
  6127. rgb = [0, 0, 0];
  6128. for (var i = 0; i < 3; i++) {
  6129. t3 = h + 1 / 3 * -(i - 1);
  6130. if (t3 < 0) {
  6131. t3++;
  6132. }
  6133. if (t3 > 1) {
  6134. t3--;
  6135. }
  6136. if (6 * t3 < 1) {
  6137. val = t1 + (t2 - t1) * 6 * t3;
  6138. } else if (2 * t3 < 1) {
  6139. val = t2;
  6140. } else if (3 * t3 < 2) {
  6141. val = t1 + (t2 - t1) * (2 / 3 - t3) * 6;
  6142. } else {
  6143. val = t1;
  6144. }
  6145. rgb[i] = val * 255;
  6146. }
  6147. return rgb;
  6148. };
  6149. convert.hsl.hsv = function (hsl) {
  6150. var h = hsl[0];
  6151. var s = hsl[1] / 100;
  6152. var l = hsl[2] / 100;
  6153. var smin = s;
  6154. var lmin = Math.max(l, 0.01);
  6155. var sv;
  6156. var v;
  6157. l *= 2;
  6158. s *= l <= 1 ? l : 2 - l;
  6159. smin *= lmin <= 1 ? lmin : 2 - lmin;
  6160. v = (l + s) / 2;
  6161. sv = l === 0 ? 2 * smin / (lmin + smin) : 2 * s / (l + s);
  6162. return [h, sv * 100, v * 100];
  6163. };
  6164. convert.hsv.rgb = function (hsv) {
  6165. var h = hsv[0] / 60;
  6166. var s = hsv[1] / 100;
  6167. var v = hsv[2] / 100;
  6168. var hi = Math.floor(h) % 6;
  6169. var f = h - Math.floor(h);
  6170. var p = 255 * v * (1 - s);
  6171. var q = 255 * v * (1 - s * f);
  6172. var t = 255 * v * (1 - s * (1 - f));
  6173. v *= 255;
  6174. switch (hi) {
  6175. case 0:
  6176. return [v, t, p];
  6177. case 1:
  6178. return [q, v, p];
  6179. case 2:
  6180. return [p, v, t];
  6181. case 3:
  6182. return [p, q, v];
  6183. case 4:
  6184. return [t, p, v];
  6185. case 5:
  6186. return [v, p, q];
  6187. }
  6188. };
  6189. convert.hsv.hsl = function (hsv) {
  6190. var h = hsv[0];
  6191. var s = hsv[1] / 100;
  6192. var v = hsv[2] / 100;
  6193. var vmin = Math.max(v, 0.01);
  6194. var lmin;
  6195. var sl;
  6196. var l;
  6197. l = (2 - s) * v;
  6198. lmin = (2 - s) * vmin;
  6199. sl = s * vmin;
  6200. sl /= lmin <= 1 ? lmin : 2 - lmin;
  6201. sl = sl || 0;
  6202. l /= 2;
  6203. return [h, sl * 100, l * 100];
  6204. }; // http://dev.w3.org/csswg/css-color/#hwb-to-rgb
  6205. convert.hwb.rgb = function (hwb) {
  6206. var h = hwb[0] / 360;
  6207. var wh = hwb[1] / 100;
  6208. var bl = hwb[2] / 100;
  6209. var ratio = wh + bl;
  6210. var i;
  6211. var v;
  6212. var f;
  6213. var n; // wh + bl cant be > 1
  6214. if (ratio > 1) {
  6215. wh /= ratio;
  6216. bl /= ratio;
  6217. }
  6218. i = Math.floor(6 * h);
  6219. v = 1 - bl;
  6220. f = 6 * h - i;
  6221. if ((i & 0x01) !== 0) {
  6222. f = 1 - f;
  6223. }
  6224. n = wh + f * (v - wh); // linear interpolation
  6225. var r;
  6226. var g;
  6227. var b;
  6228. switch (i) {
  6229. default:
  6230. case 6:
  6231. case 0:
  6232. r = v;
  6233. g = n;
  6234. b = wh;
  6235. break;
  6236. case 1:
  6237. r = n;
  6238. g = v;
  6239. b = wh;
  6240. break;
  6241. case 2:
  6242. r = wh;
  6243. g = v;
  6244. b = n;
  6245. break;
  6246. case 3:
  6247. r = wh;
  6248. g = n;
  6249. b = v;
  6250. break;
  6251. case 4:
  6252. r = n;
  6253. g = wh;
  6254. b = v;
  6255. break;
  6256. case 5:
  6257. r = v;
  6258. g = wh;
  6259. b = n;
  6260. break;
  6261. }
  6262. return [r * 255, g * 255, b * 255];
  6263. };
  6264. convert.cmyk.rgb = function (cmyk) {
  6265. var c = cmyk[0] / 100;
  6266. var m = cmyk[1] / 100;
  6267. var y = cmyk[2] / 100;
  6268. var k = cmyk[3] / 100;
  6269. var r;
  6270. var g;
  6271. var b;
  6272. r = 1 - Math.min(1, c * (1 - k) + k);
  6273. g = 1 - Math.min(1, m * (1 - k) + k);
  6274. b = 1 - Math.min(1, y * (1 - k) + k);
  6275. return [r * 255, g * 255, b * 255];
  6276. };
  6277. convert.xyz.rgb = function (xyz) {
  6278. var x = xyz[0] / 100;
  6279. var y = xyz[1] / 100;
  6280. var z = xyz[2] / 100;
  6281. var r;
  6282. var g;
  6283. var b;
  6284. r = x * 3.2406 + y * -1.5372 + z * -0.4986;
  6285. g = x * -0.9689 + y * 1.8758 + z * 0.0415;
  6286. b = x * 0.0557 + y * -0.2040 + z * 1.0570; // assume sRGB
  6287. r = r > 0.0031308 ? 1.055 * Math.pow(r, 1.0 / 2.4) - 0.055 : r * 12.92;
  6288. g = g > 0.0031308 ? 1.055 * Math.pow(g, 1.0 / 2.4) - 0.055 : g * 12.92;
  6289. b = b > 0.0031308 ? 1.055 * Math.pow(b, 1.0 / 2.4) - 0.055 : b * 12.92;
  6290. r = Math.min(Math.max(0, r), 1);
  6291. g = Math.min(Math.max(0, g), 1);
  6292. b = Math.min(Math.max(0, b), 1);
  6293. return [r * 255, g * 255, b * 255];
  6294. };
  6295. convert.xyz.lab = function (xyz) {
  6296. var x = xyz[0];
  6297. var y = xyz[1];
  6298. var z = xyz[2];
  6299. var l;
  6300. var a;
  6301. var b;
  6302. x /= 95.047;
  6303. y /= 100;
  6304. z /= 108.883;
  6305. x = x > 0.008856 ? Math.pow(x, 1 / 3) : 7.787 * x + 16 / 116;
  6306. y = y > 0.008856 ? Math.pow(y, 1 / 3) : 7.787 * y + 16 / 116;
  6307. z = z > 0.008856 ? Math.pow(z, 1 / 3) : 7.787 * z + 16 / 116;
  6308. l = 116 * y - 16;
  6309. a = 500 * (x - y);
  6310. b = 200 * (y - z);
  6311. return [l, a, b];
  6312. };
  6313. convert.lab.xyz = function (lab) {
  6314. var l = lab[0];
  6315. var a = lab[1];
  6316. var b = lab[2];
  6317. var x;
  6318. var y;
  6319. var z;
  6320. y = (l + 16) / 116;
  6321. x = a / 500 + y;
  6322. z = y - b / 200;
  6323. var y2 = Math.pow(y, 3);
  6324. var x2 = Math.pow(x, 3);
  6325. var z2 = Math.pow(z, 3);
  6326. y = y2 > 0.008856 ? y2 : (y - 16 / 116) / 7.787;
  6327. x = x2 > 0.008856 ? x2 : (x - 16 / 116) / 7.787;
  6328. z = z2 > 0.008856 ? z2 : (z - 16 / 116) / 7.787;
  6329. x *= 95.047;
  6330. y *= 100;
  6331. z *= 108.883;
  6332. return [x, y, z];
  6333. };
  6334. convert.lab.lch = function (lab) {
  6335. var l = lab[0];
  6336. var a = lab[1];
  6337. var b = lab[2];
  6338. var hr;
  6339. var h;
  6340. var c;
  6341. hr = Math.atan2(b, a);
  6342. h = hr * 360 / 2 / Math.PI;
  6343. if (h < 0) {
  6344. h += 360;
  6345. }
  6346. c = Math.sqrt(a * a + b * b);
  6347. return [l, c, h];
  6348. };
  6349. convert.lch.lab = function (lch) {
  6350. var l = lch[0];
  6351. var c = lch[1];
  6352. var h = lch[2];
  6353. var a;
  6354. var b;
  6355. var hr;
  6356. hr = h / 360 * 2 * Math.PI;
  6357. a = c * Math.cos(hr);
  6358. b = c * Math.sin(hr);
  6359. return [l, a, b];
  6360. };
  6361. convert.rgb.ansi16 = function (args) {
  6362. var r = args[0];
  6363. var g = args[1];
  6364. var b = args[2];
  6365. var value = 1 in arguments ? arguments[1] : convert.rgb.hsv(args)[2]; // hsv -> ansi16 optimization
  6366. value = Math.round(value / 50);
  6367. if (value === 0) {
  6368. return 30;
  6369. }
  6370. var ansi = 30 + (Math.round(b / 255) << 2 | Math.round(g / 255) << 1 | Math.round(r / 255));
  6371. if (value === 2) {
  6372. ansi += 60;
  6373. }
  6374. return ansi;
  6375. };
  6376. convert.hsv.ansi16 = function (args) {
  6377. // optimization here; we already know the value and don't need to get
  6378. // it converted for us.
  6379. return convert.rgb.ansi16(convert.hsv.rgb(args), args[2]);
  6380. };
  6381. convert.rgb.ansi256 = function (args) {
  6382. var r = args[0];
  6383. var g = args[1];
  6384. var b = args[2]; // we use the extended greyscale palette here, with the exception of
  6385. // black and white. normal palette only has 4 greyscale shades.
  6386. if (r === g && g === b) {
  6387. if (r < 8) {
  6388. return 16;
  6389. }
  6390. if (r > 248) {
  6391. return 231;
  6392. }
  6393. return Math.round((r - 8) / 247 * 24) + 232;
  6394. }
  6395. var ansi = 16 + 36 * Math.round(r / 255 * 5) + 6 * Math.round(g / 255 * 5) + Math.round(b / 255 * 5);
  6396. return ansi;
  6397. };
  6398. convert.ansi16.rgb = function (args) {
  6399. var color = args % 10; // handle greyscale
  6400. if (color === 0 || color === 7) {
  6401. if (args > 50) {
  6402. color += 3.5;
  6403. }
  6404. color = color / 10.5 * 255;
  6405. return [color, color, color];
  6406. }
  6407. var mult = (~~(args > 50) + 1) * 0.5;
  6408. var r = (color & 1) * mult * 255;
  6409. var g = (color >> 1 & 1) * mult * 255;
  6410. var b = (color >> 2 & 1) * mult * 255;
  6411. return [r, g, b];
  6412. };
  6413. convert.ansi256.rgb = function (args) {
  6414. // handle greyscale
  6415. if (args >= 232) {
  6416. var c = (args - 232) * 10 + 8;
  6417. return [c, c, c];
  6418. }
  6419. args -= 16;
  6420. var rem;
  6421. var r = Math.floor(args / 36) / 5 * 255;
  6422. var g = Math.floor((rem = args % 36) / 6) / 5 * 255;
  6423. var b = rem % 6 / 5 * 255;
  6424. return [r, g, b];
  6425. };
  6426. convert.rgb.hex = function (args) {
  6427. var integer = ((Math.round(args[0]) & 0xFF) << 16) + ((Math.round(args[1]) & 0xFF) << 8) + (Math.round(args[2]) & 0xFF);
  6428. var string = integer.toString(16).toUpperCase();
  6429. return '000000'.substring(string.length) + string;
  6430. };
  6431. convert.hex.rgb = function (args) {
  6432. var match = args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);
  6433. if (!match) {
  6434. return [0, 0, 0];
  6435. }
  6436. var colorString = match[0];
  6437. if (match[0].length === 3) {
  6438. colorString = colorString.split('').map(function (char) {
  6439. return char + char;
  6440. }).join('');
  6441. }
  6442. var integer = parseInt(colorString, 16);
  6443. var r = integer >> 16 & 0xFF;
  6444. var g = integer >> 8 & 0xFF;
  6445. var b = integer & 0xFF;
  6446. return [r, g, b];
  6447. };
  6448. convert.rgb.hcg = function (rgb) {
  6449. var r = rgb[0] / 255;
  6450. var g = rgb[1] / 255;
  6451. var b = rgb[2] / 255;
  6452. var max = Math.max(Math.max(r, g), b);
  6453. var min = Math.min(Math.min(r, g), b);
  6454. var chroma = max - min;
  6455. var grayscale;
  6456. var hue;
  6457. if (chroma < 1) {
  6458. grayscale = min / (1 - chroma);
  6459. } else {
  6460. grayscale = 0;
  6461. }
  6462. if (chroma <= 0) {
  6463. hue = 0;
  6464. } else if (max === r) {
  6465. hue = (g - b) / chroma % 6;
  6466. } else if (max === g) {
  6467. hue = 2 + (b - r) / chroma;
  6468. } else {
  6469. hue = 4 + (r - g) / chroma + 4;
  6470. }
  6471. hue /= 6;
  6472. hue %= 1;
  6473. return [hue * 360, chroma * 100, grayscale * 100];
  6474. };
  6475. convert.hsl.hcg = function (hsl) {
  6476. var s = hsl[1] / 100;
  6477. var l = hsl[2] / 100;
  6478. var c = 1;
  6479. var f = 0;
  6480. if (l < 0.5) {
  6481. c = 2.0 * s * l;
  6482. } else {
  6483. c = 2.0 * s * (1.0 - l);
  6484. }
  6485. if (c < 1.0) {
  6486. f = (l - 0.5 * c) / (1.0 - c);
  6487. }
  6488. return [hsl[0], c * 100, f * 100];
  6489. };
  6490. convert.hsv.hcg = function (hsv) {
  6491. var s = hsv[1] / 100;
  6492. var v = hsv[2] / 100;
  6493. var c = s * v;
  6494. var f = 0;
  6495. if (c < 1.0) {
  6496. f = (v - c) / (1 - c);
  6497. }
  6498. return [hsv[0], c * 100, f * 100];
  6499. };
  6500. convert.hcg.rgb = function (hcg) {
  6501. var h = hcg[0] / 360;
  6502. var c = hcg[1] / 100;
  6503. var g = hcg[2] / 100;
  6504. if (c === 0.0) {
  6505. return [g * 255, g * 255, g * 255];
  6506. }
  6507. var pure = [0, 0, 0];
  6508. var hi = h % 1 * 6;
  6509. var v = hi % 1;
  6510. var w = 1 - v;
  6511. var mg = 0;
  6512. switch (Math.floor(hi)) {
  6513. case 0:
  6514. pure[0] = 1;
  6515. pure[1] = v;
  6516. pure[2] = 0;
  6517. break;
  6518. case 1:
  6519. pure[0] = w;
  6520. pure[1] = 1;
  6521. pure[2] = 0;
  6522. break;
  6523. case 2:
  6524. pure[0] = 0;
  6525. pure[1] = 1;
  6526. pure[2] = v;
  6527. break;
  6528. case 3:
  6529. pure[0] = 0;
  6530. pure[1] = w;
  6531. pure[2] = 1;
  6532. break;
  6533. case 4:
  6534. pure[0] = v;
  6535. pure[1] = 0;
  6536. pure[2] = 1;
  6537. break;
  6538. default:
  6539. pure[0] = 1;
  6540. pure[1] = 0;
  6541. pure[2] = w;
  6542. }
  6543. mg = (1.0 - c) * g;
  6544. return [(c * pure[0] + mg) * 255, (c * pure[1] + mg) * 255, (c * pure[2] + mg) * 255];
  6545. };
  6546. convert.hcg.hsv = function (hcg) {
  6547. var c = hcg[1] / 100;
  6548. var g = hcg[2] / 100;
  6549. var v = c + g * (1.0 - c);
  6550. var f = 0;
  6551. if (v > 0.0) {
  6552. f = c / v;
  6553. }
  6554. return [hcg[0], f * 100, v * 100];
  6555. };
  6556. convert.hcg.hsl = function (hcg) {
  6557. var c = hcg[1] / 100;
  6558. var g = hcg[2] / 100;
  6559. var l = g * (1.0 - c) + 0.5 * c;
  6560. var s = 0;
  6561. if (l > 0.0 && l < 0.5) {
  6562. s = c / (2 * l);
  6563. } else if (l >= 0.5 && l < 1.0) {
  6564. s = c / (2 * (1 - l));
  6565. }
  6566. return [hcg[0], s * 100, l * 100];
  6567. };
  6568. convert.hcg.hwb = function (hcg) {
  6569. var c = hcg[1] / 100;
  6570. var g = hcg[2] / 100;
  6571. var v = c + g * (1.0 - c);
  6572. return [hcg[0], (v - c) * 100, (1 - v) * 100];
  6573. };
  6574. convert.hwb.hcg = function (hwb) {
  6575. var w = hwb[1] / 100;
  6576. var b = hwb[2] / 100;
  6577. var v = 1 - b;
  6578. var c = v - w;
  6579. var g = 0;
  6580. if (c < 1) {
  6581. g = (v - c) / (1 - c);
  6582. }
  6583. return [hwb[0], c * 100, g * 100];
  6584. };
  6585. convert.apple.rgb = function (apple) {
  6586. return [apple[0] / 65535 * 255, apple[1] / 65535 * 255, apple[2] / 65535 * 255];
  6587. };
  6588. convert.rgb.apple = function (rgb) {
  6589. return [rgb[0] / 255 * 65535, rgb[1] / 255 * 65535, rgb[2] / 255 * 65535];
  6590. };
  6591. convert.gray.rgb = function (args) {
  6592. return [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255];
  6593. };
  6594. convert.gray.hsl = convert.gray.hsv = function (args) {
  6595. return [0, 0, args[0]];
  6596. };
  6597. convert.gray.hwb = function (gray) {
  6598. return [0, 100, gray[0]];
  6599. };
  6600. convert.gray.cmyk = function (gray) {
  6601. return [0, 0, 0, gray[0]];
  6602. };
  6603. convert.gray.lab = function (gray) {
  6604. return [gray[0], 0, 0];
  6605. };
  6606. convert.gray.hex = function (gray) {
  6607. var val = Math.round(gray[0] / 100 * 255) & 0xFF;
  6608. var integer = (val << 16) + (val << 8) + val;
  6609. var string = integer.toString(16).toUpperCase();
  6610. return '000000'.substring(string.length) + string;
  6611. };
  6612. convert.rgb.gray = function (rgb) {
  6613. var val = (rgb[0] + rgb[1] + rgb[2]) / 3;
  6614. return [val / 255 * 100];
  6615. };
  6616. });
  6617. /*
  6618. this function routes a model to all other models.
  6619. all functions that are routed have a property `.conversion` attached
  6620. to the returned synthetic function. This property is an array
  6621. of strings, each with the steps in between the 'from' and 'to'
  6622. color models (inclusive).
  6623. conversions that are not possible simply are not included.
  6624. */
  6625. // https://jsperf.com/object-keys-vs-for-in-with-closure/3
  6626. var models$1 = Object.keys(conversions);
  6627. function buildGraph() {
  6628. var graph = {};
  6629. for (var len = models$1.length, i = 0; i < len; i++) {
  6630. graph[models$1[i]] = {
  6631. // http://jsperf.com/1-vs-infinity
  6632. // micro-opt, but this is simple.
  6633. distance: -1,
  6634. parent: null
  6635. };
  6636. }
  6637. return graph;
  6638. } // https://en.wikipedia.org/wiki/Breadth-first_search
  6639. function deriveBFS(fromModel) {
  6640. var graph = buildGraph();
  6641. var queue = [fromModel]; // unshift -> queue -> pop
  6642. graph[fromModel].distance = 0;
  6643. while (queue.length) {
  6644. var current = queue.pop();
  6645. var adjacents = Object.keys(conversions[current]);
  6646. for (var len = adjacents.length, i = 0; i < len; i++) {
  6647. var adjacent = adjacents[i];
  6648. var node = graph[adjacent];
  6649. if (node.distance === -1) {
  6650. node.distance = graph[current].distance + 1;
  6651. node.parent = current;
  6652. queue.unshift(adjacent);
  6653. }
  6654. }
  6655. }
  6656. return graph;
  6657. }
  6658. function link(from, to) {
  6659. return function (args) {
  6660. return to(from(args));
  6661. };
  6662. }
  6663. function wrapConversion(toModel, graph) {
  6664. var path = [graph[toModel].parent, toModel];
  6665. var fn = conversions[graph[toModel].parent][toModel];
  6666. var cur = graph[toModel].parent;
  6667. while (graph[cur].parent) {
  6668. path.unshift(graph[cur].parent);
  6669. fn = link(conversions[graph[cur].parent][cur], fn);
  6670. cur = graph[cur].parent;
  6671. }
  6672. fn.conversion = path;
  6673. return fn;
  6674. }
  6675. var route = function route(fromModel) {
  6676. var graph = deriveBFS(fromModel);
  6677. var conversion = {};
  6678. var models = Object.keys(graph);
  6679. for (var len = models.length, i = 0; i < len; i++) {
  6680. var toModel = models[i];
  6681. var node = graph[toModel];
  6682. if (node.parent === null) {
  6683. // no possible conversion, or this node is the source model.
  6684. continue;
  6685. }
  6686. conversion[toModel] = wrapConversion(toModel, graph);
  6687. }
  6688. return conversion;
  6689. };
  6690. var convert = {};
  6691. var models = Object.keys(conversions);
  6692. function wrapRaw(fn) {
  6693. var wrappedFn = function wrappedFn(args) {
  6694. if (args === undefined || args === null) {
  6695. return args;
  6696. }
  6697. if (arguments.length > 1) {
  6698. args = Array.prototype.slice.call(arguments);
  6699. }
  6700. return fn(args);
  6701. }; // preserve .conversion property if there is one
  6702. if ('conversion' in fn) {
  6703. wrappedFn.conversion = fn.conversion;
  6704. }
  6705. return wrappedFn;
  6706. }
  6707. function wrapRounded(fn) {
  6708. var wrappedFn = function wrappedFn(args) {
  6709. if (args === undefined || args === null) {
  6710. return args;
  6711. }
  6712. if (arguments.length > 1) {
  6713. args = Array.prototype.slice.call(arguments);
  6714. }
  6715. var result = fn(args); // we're assuming the result is an array here.
  6716. // see notice in conversions.js; don't use box types
  6717. // in conversion functions.
  6718. if (_typeof(result) === 'object') {
  6719. for (var len = result.length, i = 0; i < len; i++) {
  6720. result[i] = Math.round(result[i]);
  6721. }
  6722. }
  6723. return result;
  6724. }; // preserve .conversion property if there is one
  6725. if ('conversion' in fn) {
  6726. wrappedFn.conversion = fn.conversion;
  6727. }
  6728. return wrappedFn;
  6729. }
  6730. models.forEach(function (fromModel) {
  6731. convert[fromModel] = {};
  6732. Object.defineProperty(convert[fromModel], 'channels', {
  6733. value: conversions[fromModel].channels
  6734. });
  6735. Object.defineProperty(convert[fromModel], 'labels', {
  6736. value: conversions[fromModel].labels
  6737. });
  6738. var routes = route(fromModel);
  6739. var routeModels = Object.keys(routes);
  6740. routeModels.forEach(function (toModel) {
  6741. var fn = routes[toModel];
  6742. convert[fromModel][toModel] = wrapRounded(fn);
  6743. convert[fromModel][toModel].raw = wrapRaw(fn);
  6744. });
  6745. });
  6746. var colorConvert = convert;
  6747. var ansiStyles = createCommonjsModule(function (module) {
  6748. 'use strict';
  6749. var wrapAnsi16 = function wrapAnsi16(fn, offset) {
  6750. return function () {
  6751. var code = fn.apply(colorConvert, arguments);
  6752. return "\x1B[".concat(code + offset, "m");
  6753. };
  6754. };
  6755. var wrapAnsi256 = function wrapAnsi256(fn, offset) {
  6756. return function () {
  6757. var code = fn.apply(colorConvert, arguments);
  6758. return "\x1B[".concat(38 + offset, ";5;").concat(code, "m");
  6759. };
  6760. };
  6761. var wrapAnsi16m = function wrapAnsi16m(fn, offset) {
  6762. return function () {
  6763. var rgb = fn.apply(colorConvert, arguments);
  6764. return "\x1B[".concat(38 + offset, ";2;").concat(rgb[0], ";").concat(rgb[1], ";").concat(rgb[2], "m");
  6765. };
  6766. };
  6767. function assembleStyles() {
  6768. var codes = new Map();
  6769. var styles = {
  6770. modifier: {
  6771. reset: [0, 0],
  6772. // 21 isn't widely supported and 22 does the same thing
  6773. bold: [1, 22],
  6774. dim: [2, 22],
  6775. italic: [3, 23],
  6776. underline: [4, 24],
  6777. inverse: [7, 27],
  6778. hidden: [8, 28],
  6779. strikethrough: [9, 29]
  6780. },
  6781. color: {
  6782. black: [30, 39],
  6783. red: [31, 39],
  6784. green: [32, 39],
  6785. yellow: [33, 39],
  6786. blue: [34, 39],
  6787. magenta: [35, 39],
  6788. cyan: [36, 39],
  6789. white: [37, 39],
  6790. gray: [90, 39],
  6791. // Bright color
  6792. redBright: [91, 39],
  6793. greenBright: [92, 39],
  6794. yellowBright: [93, 39],
  6795. blueBright: [94, 39],
  6796. magentaBright: [95, 39],
  6797. cyanBright: [96, 39],
  6798. whiteBright: [97, 39]
  6799. },
  6800. bgColor: {
  6801. bgBlack: [40, 49],
  6802. bgRed: [41, 49],
  6803. bgGreen: [42, 49],
  6804. bgYellow: [43, 49],
  6805. bgBlue: [44, 49],
  6806. bgMagenta: [45, 49],
  6807. bgCyan: [46, 49],
  6808. bgWhite: [47, 49],
  6809. // Bright color
  6810. bgBlackBright: [100, 49],
  6811. bgRedBright: [101, 49],
  6812. bgGreenBright: [102, 49],
  6813. bgYellowBright: [103, 49],
  6814. bgBlueBright: [104, 49],
  6815. bgMagentaBright: [105, 49],
  6816. bgCyanBright: [106, 49],
  6817. bgWhiteBright: [107, 49]
  6818. }
  6819. }; // Fix humans
  6820. styles.color.grey = styles.color.gray;
  6821. var _arr = Object.keys(styles);
  6822. for (var _i = 0; _i < _arr.length; _i++) {
  6823. var groupName = _arr[_i];
  6824. var group = styles[groupName];
  6825. var _arr3 = Object.keys(group);
  6826. for (var _i3 = 0; _i3 < _arr3.length; _i3++) {
  6827. var styleName = _arr3[_i3];
  6828. var style = group[styleName];
  6829. styles[styleName] = {
  6830. open: "\x1B[".concat(style[0], "m"),
  6831. close: "\x1B[".concat(style[1], "m")
  6832. };
  6833. group[styleName] = styles[styleName];
  6834. codes.set(style[0], style[1]);
  6835. }
  6836. Object.defineProperty(styles, groupName, {
  6837. value: group,
  6838. enumerable: false
  6839. });
  6840. Object.defineProperty(styles, 'codes', {
  6841. value: codes,
  6842. enumerable: false
  6843. });
  6844. }
  6845. var ansi2ansi = function ansi2ansi(n) {
  6846. return n;
  6847. };
  6848. var rgb2rgb = function rgb2rgb(r, g, b) {
  6849. return [r, g, b];
  6850. };
  6851. styles.color.close = "\x1B[39m";
  6852. styles.bgColor.close = "\x1B[49m";
  6853. styles.color.ansi = {
  6854. ansi: wrapAnsi16(ansi2ansi, 0)
  6855. };
  6856. styles.color.ansi256 = {
  6857. ansi256: wrapAnsi256(ansi2ansi, 0)
  6858. };
  6859. styles.color.ansi16m = {
  6860. rgb: wrapAnsi16m(rgb2rgb, 0)
  6861. };
  6862. styles.bgColor.ansi = {
  6863. ansi: wrapAnsi16(ansi2ansi, 10)
  6864. };
  6865. styles.bgColor.ansi256 = {
  6866. ansi256: wrapAnsi256(ansi2ansi, 10)
  6867. };
  6868. styles.bgColor.ansi16m = {
  6869. rgb: wrapAnsi16m(rgb2rgb, 10)
  6870. };
  6871. var _arr2 = Object.keys(colorConvert);
  6872. for (var _i2 = 0; _i2 < _arr2.length; _i2++) {
  6873. var key = _arr2[_i2];
  6874. if (_typeof(colorConvert[key]) !== 'object') {
  6875. continue;
  6876. }
  6877. var suite = colorConvert[key];
  6878. if (key === 'ansi16') {
  6879. key = 'ansi';
  6880. }
  6881. if ('ansi16' in suite) {
  6882. styles.color.ansi[key] = wrapAnsi16(suite.ansi16, 0);
  6883. styles.bgColor.ansi[key] = wrapAnsi16(suite.ansi16, 10);
  6884. }
  6885. if ('ansi256' in suite) {
  6886. styles.color.ansi256[key] = wrapAnsi256(suite.ansi256, 0);
  6887. styles.bgColor.ansi256[key] = wrapAnsi256(suite.ansi256, 10);
  6888. }
  6889. if ('rgb' in suite) {
  6890. styles.color.ansi16m[key] = wrapAnsi16m(suite.rgb, 0);
  6891. styles.bgColor.ansi16m[key] = wrapAnsi16m(suite.rgb, 10);
  6892. }
  6893. }
  6894. return styles;
  6895. } // Make the export immutable
  6896. Object.defineProperty(module, 'exports', {
  6897. enumerable: true,
  6898. get: assembleStyles
  6899. });
  6900. });
  6901. var os = {
  6902. EOL: "\n"
  6903. };
  6904. var os$1 = Object.freeze({
  6905. default: os
  6906. });
  6907. var hasFlag = createCommonjsModule(function (module) {
  6908. 'use strict';
  6909. module.exports = function (flag, argv$$1) {
  6910. argv$$1 = argv$$1 || process.argv;
  6911. var prefix = flag.startsWith('-') ? '' : flag.length === 1 ? '-' : '--';
  6912. var pos = argv$$1.indexOf(prefix + flag);
  6913. var terminatorPos = argv$$1.indexOf('--');
  6914. return pos !== -1 && (terminatorPos === -1 ? true : pos < terminatorPos);
  6915. };
  6916. });
  6917. var require$$1$1 = ( os$1 && os ) || os$1;
  6918. var env$1 = process.env;
  6919. var forceColor;
  6920. if (hasFlag('no-color') || hasFlag('no-colors') || hasFlag('color=false')) {
  6921. forceColor = false;
  6922. } else if (hasFlag('color') || hasFlag('colors') || hasFlag('color=true') || hasFlag('color=always')) {
  6923. forceColor = true;
  6924. }
  6925. if ('FORCE_COLOR' in env$1) {
  6926. forceColor = env$1.FORCE_COLOR.length === 0 || parseInt(env$1.FORCE_COLOR, 10) !== 0;
  6927. }
  6928. function translateLevel(level) {
  6929. if (level === 0) {
  6930. return false;
  6931. }
  6932. return {
  6933. level: level,
  6934. hasBasic: true,
  6935. has256: level >= 2,
  6936. has16m: level >= 3
  6937. };
  6938. }
  6939. function supportsColor(stream) {
  6940. if (forceColor === false) {
  6941. return 0;
  6942. }
  6943. if (hasFlag('color=16m') || hasFlag('color=full') || hasFlag('color=truecolor')) {
  6944. return 3;
  6945. }
  6946. if (hasFlag('color=256')) {
  6947. return 2;
  6948. }
  6949. if (stream && !stream.isTTY && forceColor !== true) {
  6950. return 0;
  6951. }
  6952. var min = forceColor ? 1 : 0;
  6953. if (process.platform === 'win32') {
  6954. // Node.js 7.5.0 is the first version of Node.js to include a patch to
  6955. // libuv that enables 256 color output on Windows. Anything earlier and it
  6956. // won't work. However, here we target Node.js 8 at minimum as it is an LTS
  6957. // release, and Node.js 7 is not. Windows 10 build 10586 is the first Windows
  6958. // release that supports 256 colors. Windows 10 build 14931 is the first release
  6959. // that supports 16m/TrueColor.
  6960. var osRelease = require$$1$1.release().split('.');
  6961. if (Number(process.versions.node.split('.')[0]) >= 8 && Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
  6962. return Number(osRelease[2]) >= 14931 ? 3 : 2;
  6963. }
  6964. return 1;
  6965. }
  6966. if ('CI' in env$1) {
  6967. if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI'].some(function (sign) {
  6968. return sign in env$1;
  6969. }) || env$1.CI_NAME === 'codeship') {
  6970. return 1;
  6971. }
  6972. return min;
  6973. }
  6974. if ('TEAMCITY_VERSION' in env$1) {
  6975. return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env$1.TEAMCITY_VERSION) ? 1 : 0;
  6976. }
  6977. if (env$1.COLORTERM === 'truecolor') {
  6978. return 3;
  6979. }
  6980. if ('TERM_PROGRAM' in env$1) {
  6981. var version = parseInt((env$1.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
  6982. switch (env$1.TERM_PROGRAM) {
  6983. case 'iTerm.app':
  6984. return version >= 3 ? 3 : 2;
  6985. case 'Apple_Terminal':
  6986. return 2;
  6987. // No default
  6988. }
  6989. }
  6990. if (/-256(color)?$/i.test(env$1.TERM)) {
  6991. return 2;
  6992. }
  6993. if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env$1.TERM)) {
  6994. return 1;
  6995. }
  6996. if ('COLORTERM' in env$1) {
  6997. return 1;
  6998. }
  6999. if (env$1.TERM === 'dumb') {
  7000. return min;
  7001. }
  7002. return min;
  7003. }
  7004. function getSupportLevel(stream) {
  7005. var level = supportsColor(stream);
  7006. return translateLevel(level);
  7007. }
  7008. var supportsColor_1 = {
  7009. supportsColor: getSupportLevel,
  7010. stdout: getSupportLevel(process.stdout),
  7011. stderr: getSupportLevel(process.stderr)
  7012. };
  7013. var templates = createCommonjsModule(function (module) {
  7014. 'use strict';
  7015. var TEMPLATE_REGEX = /(?:\\(u[a-f\d]{4}|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi;
  7016. var STYLE_REGEX = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g;
  7017. var STRING_REGEX = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/;
  7018. var ESCAPE_REGEX = /\\(u[a-f\d]{4}|x[a-f\d]{2}|.)|([^\\])/gi;
  7019. var ESCAPES = new Map([['n', '\n'], ['r', '\r'], ['t', '\t'], ['b', '\b'], ['f', '\f'], ['v', '\v'], ['0', '\0'], ['\\', '\\'], ['e', "\x1B"], ['a', "\x07"]]);
  7020. function unescape(c) {
  7021. if (c[0] === 'u' && c.length === 5 || c[0] === 'x' && c.length === 3) {
  7022. return String.fromCharCode(parseInt(c.slice(1), 16));
  7023. }
  7024. return ESCAPES.get(c) || c;
  7025. }
  7026. function parseArguments(name, args) {
  7027. var results = [];
  7028. var chunks = args.trim().split(/\s*,\s*/g);
  7029. var matches;
  7030. var _iteratorNormalCompletion = true;
  7031. var _didIteratorError = false;
  7032. var _iteratorError = undefined;
  7033. try {
  7034. for (var _iterator = chunks[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  7035. var chunk = _step.value;
  7036. if (!isNaN(chunk)) {
  7037. results.push(Number(chunk));
  7038. } else if (matches = chunk.match(STRING_REGEX)) {
  7039. results.push(matches[2].replace(ESCAPE_REGEX, function (m, escape, chr) {
  7040. return escape ? unescape(escape) : chr;
  7041. }));
  7042. } else {
  7043. throw new Error("Invalid Chalk template style argument: ".concat(chunk, " (in style '").concat(name, "')"));
  7044. }
  7045. }
  7046. } catch (err) {
  7047. _didIteratorError = true;
  7048. _iteratorError = err;
  7049. } finally {
  7050. try {
  7051. if (!_iteratorNormalCompletion && _iterator.return != null) {
  7052. _iterator.return();
  7053. }
  7054. } finally {
  7055. if (_didIteratorError) {
  7056. throw _iteratorError;
  7057. }
  7058. }
  7059. }
  7060. return results;
  7061. }
  7062. function parseStyle(style) {
  7063. STYLE_REGEX.lastIndex = 0;
  7064. var results = [];
  7065. var matches;
  7066. while ((matches = STYLE_REGEX.exec(style)) !== null) {
  7067. var name = matches[1];
  7068. if (matches[2]) {
  7069. var args = parseArguments(name, matches[2]);
  7070. results.push([name].concat(args));
  7071. } else {
  7072. results.push([name]);
  7073. }
  7074. }
  7075. return results;
  7076. }
  7077. function buildStyle(chalk, styles) {
  7078. var enabled = {};
  7079. var _iteratorNormalCompletion2 = true;
  7080. var _didIteratorError2 = false;
  7081. var _iteratorError2 = undefined;
  7082. try {
  7083. for (var _iterator2 = styles[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
  7084. var layer = _step2.value;
  7085. var _iteratorNormalCompletion3 = true;
  7086. var _didIteratorError3 = false;
  7087. var _iteratorError3 = undefined;
  7088. try {
  7089. for (var _iterator3 = layer.styles[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
  7090. var style = _step3.value;
  7091. enabled[style[0]] = layer.inverse ? null : style.slice(1);
  7092. }
  7093. } catch (err) {
  7094. _didIteratorError3 = true;
  7095. _iteratorError3 = err;
  7096. } finally {
  7097. try {
  7098. if (!_iteratorNormalCompletion3 && _iterator3.return != null) {
  7099. _iterator3.return();
  7100. }
  7101. } finally {
  7102. if (_didIteratorError3) {
  7103. throw _iteratorError3;
  7104. }
  7105. }
  7106. }
  7107. }
  7108. } catch (err) {
  7109. _didIteratorError2 = true;
  7110. _iteratorError2 = err;
  7111. } finally {
  7112. try {
  7113. if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
  7114. _iterator2.return();
  7115. }
  7116. } finally {
  7117. if (_didIteratorError2) {
  7118. throw _iteratorError2;
  7119. }
  7120. }
  7121. }
  7122. var current = chalk;
  7123. var _arr = Object.keys(enabled);
  7124. for (var _i = 0; _i < _arr.length; _i++) {
  7125. var styleName = _arr[_i];
  7126. if (Array.isArray(enabled[styleName])) {
  7127. if (!(styleName in current)) {
  7128. throw new Error("Unknown Chalk style: ".concat(styleName));
  7129. }
  7130. if (enabled[styleName].length > 0) {
  7131. current = current[styleName].apply(current, enabled[styleName]);
  7132. } else {
  7133. current = current[styleName];
  7134. }
  7135. }
  7136. }
  7137. return current;
  7138. }
  7139. module.exports = function (chalk, tmp) {
  7140. var styles = [];
  7141. var chunks = [];
  7142. var chunk = []; // eslint-disable-next-line max-params
  7143. tmp.replace(TEMPLATE_REGEX, function (m, escapeChar, inverse, style, close, chr) {
  7144. if (escapeChar) {
  7145. chunk.push(unescape(escapeChar));
  7146. } else if (style) {
  7147. var str = chunk.join('');
  7148. chunk = [];
  7149. chunks.push(styles.length === 0 ? str : buildStyle(chalk, styles)(str));
  7150. styles.push({
  7151. inverse: inverse,
  7152. styles: parseStyle(style)
  7153. });
  7154. } else if (close) {
  7155. if (styles.length === 0) {
  7156. throw new Error('Found extraneous } in Chalk template literal');
  7157. }
  7158. chunks.push(buildStyle(chalk, styles)(chunk.join('')));
  7159. chunk = [];
  7160. styles.pop();
  7161. } else {
  7162. chunk.push(chr);
  7163. }
  7164. });
  7165. chunks.push(chunk.join(''));
  7166. if (styles.length > 0) {
  7167. var errMsg = "Chalk template literal is missing ".concat(styles.length, " closing bracket").concat(styles.length === 1 ? '' : 's', " (`}`)");
  7168. throw new Error(errMsg);
  7169. }
  7170. return chunks.join('');
  7171. };
  7172. });
  7173. var chalk = createCommonjsModule(function (module) {
  7174. 'use strict';
  7175. var stdoutColor = supportsColor_1.stdout;
  7176. var isSimpleWindowsTerm = process.platform === 'win32' && !(process.env.TERM || '').toLowerCase().startsWith('xterm'); // `supportsColor.level` → `ansiStyles.color[name]` mapping
  7177. var levelMapping = ['ansi', 'ansi', 'ansi256', 'ansi16m']; // `color-convert` models to exclude from the Chalk API due to conflicts and such
  7178. var skipModels = new Set(['gray']);
  7179. var styles = Object.create(null);
  7180. function applyOptions(obj, options) {
  7181. options = options || {}; // Detect level if not set manually
  7182. var scLevel = stdoutColor ? stdoutColor.level : 0;
  7183. obj.level = options.level === undefined ? scLevel : options.level;
  7184. obj.enabled = 'enabled' in options ? options.enabled : obj.level > 0;
  7185. }
  7186. function Chalk(options) {
  7187. // We check for this.template here since calling `chalk.constructor()`
  7188. // by itself will have a `this` of a previously constructed chalk object
  7189. if (!this || !(this instanceof Chalk) || this.template) {
  7190. var _chalk = {};
  7191. applyOptions(_chalk, options);
  7192. _chalk.template = function () {
  7193. var args = [].slice.call(arguments);
  7194. return chalkTag.apply(null, [_chalk.template].concat(args));
  7195. };
  7196. Object.setPrototypeOf(_chalk, Chalk.prototype);
  7197. Object.setPrototypeOf(_chalk.template, _chalk);
  7198. _chalk.template.constructor = Chalk;
  7199. return _chalk.template;
  7200. }
  7201. applyOptions(this, options);
  7202. } // Use bright blue on Windows as the normal blue color is illegible
  7203. if (isSimpleWindowsTerm) {
  7204. ansiStyles.blue.open = "\x1B[94m";
  7205. }
  7206. var _arr = Object.keys(ansiStyles);
  7207. var _loop = function _loop() {
  7208. var key = _arr[_i];
  7209. ansiStyles[key].closeRe = new RegExp(escapeStringRegexp(ansiStyles[key].close), 'g');
  7210. styles[key] = {
  7211. get: function get() {
  7212. var codes = ansiStyles[key];
  7213. return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, key);
  7214. }
  7215. };
  7216. };
  7217. for (var _i = 0; _i < _arr.length; _i++) {
  7218. _loop();
  7219. }
  7220. styles.visible = {
  7221. get: function get() {
  7222. return build.call(this, this._styles || [], true, 'visible');
  7223. }
  7224. };
  7225. ansiStyles.color.closeRe = new RegExp(escapeStringRegexp(ansiStyles.color.close), 'g');
  7226. var _arr2 = Object.keys(ansiStyles.color.ansi);
  7227. var _loop2 = function _loop2() {
  7228. var model = _arr2[_i2];
  7229. if (skipModels.has(model)) {
  7230. return "continue";
  7231. }
  7232. styles[model] = {
  7233. get: function get() {
  7234. var level = this.level;
  7235. return function () {
  7236. var open = ansiStyles.color[levelMapping[level]][model].apply(null, arguments);
  7237. var codes = {
  7238. open: open,
  7239. close: ansiStyles.color.close,
  7240. closeRe: ansiStyles.color.closeRe
  7241. };
  7242. return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, model);
  7243. };
  7244. }
  7245. };
  7246. };
  7247. for (var _i2 = 0; _i2 < _arr2.length; _i2++) {
  7248. var _ret = _loop2();
  7249. if (_ret === "continue") continue;
  7250. }
  7251. ansiStyles.bgColor.closeRe = new RegExp(escapeStringRegexp(ansiStyles.bgColor.close), 'g');
  7252. var _arr3 = Object.keys(ansiStyles.bgColor.ansi);
  7253. var _loop3 = function _loop3() {
  7254. var model = _arr3[_i3];
  7255. if (skipModels.has(model)) {
  7256. return "continue";
  7257. }
  7258. var bgModel = 'bg' + model[0].toUpperCase() + model.slice(1);
  7259. styles[bgModel] = {
  7260. get: function get() {
  7261. var level = this.level;
  7262. return function () {
  7263. var open = ansiStyles.bgColor[levelMapping[level]][model].apply(null, arguments);
  7264. var codes = {
  7265. open: open,
  7266. close: ansiStyles.bgColor.close,
  7267. closeRe: ansiStyles.bgColor.closeRe
  7268. };
  7269. return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, model);
  7270. };
  7271. }
  7272. };
  7273. };
  7274. for (var _i3 = 0; _i3 < _arr3.length; _i3++) {
  7275. var _ret2 = _loop3();
  7276. if (_ret2 === "continue") continue;
  7277. }
  7278. var proto = Object.defineProperties(function () {}, styles);
  7279. function build(_styles, _empty, key) {
  7280. var builder = function builder() {
  7281. return applyStyle.apply(builder, arguments);
  7282. };
  7283. builder._styles = _styles;
  7284. builder._empty = _empty;
  7285. var self = this;
  7286. Object.defineProperty(builder, 'level', {
  7287. enumerable: true,
  7288. get: function get() {
  7289. return self.level;
  7290. },
  7291. set: function set(level) {
  7292. self.level = level;
  7293. }
  7294. });
  7295. Object.defineProperty(builder, 'enabled', {
  7296. enumerable: true,
  7297. get: function get() {
  7298. return self.enabled;
  7299. },
  7300. set: function set(enabled) {
  7301. self.enabled = enabled;
  7302. }
  7303. }); // See below for fix regarding invisible grey/dim combination on Windows
  7304. builder.hasGrey = this.hasGrey || key === 'gray' || key === 'grey'; // `__proto__` is used because we must return a function, but there is
  7305. // no way to create a function with a different prototype
  7306. builder.__proto__ = proto; // eslint-disable-line no-proto
  7307. return builder;
  7308. }
  7309. function applyStyle() {
  7310. // Support varags, but simply cast to string in case there's only one arg
  7311. var args = arguments;
  7312. var argsLen = args.length;
  7313. var str = String(arguments[0]);
  7314. if (argsLen === 0) {
  7315. return '';
  7316. }
  7317. if (argsLen > 1) {
  7318. // Don't slice `arguments`, it prevents V8 optimizations
  7319. for (var a = 1; a < argsLen; a++) {
  7320. str += ' ' + args[a];
  7321. }
  7322. }
  7323. if (!this.enabled || this.level <= 0 || !str) {
  7324. return this._empty ? '' : str;
  7325. } // Turns out that on Windows dimmed gray text becomes invisible in cmd.exe,
  7326. // see https://github.com/chalk/chalk/issues/58
  7327. // If we're on Windows and we're dealing with a gray color, temporarily make 'dim' a noop.
  7328. var originalDim = ansiStyles.dim.open;
  7329. if (isSimpleWindowsTerm && this.hasGrey) {
  7330. ansiStyles.dim.open = '';
  7331. }
  7332. var _iteratorNormalCompletion = true;
  7333. var _didIteratorError = false;
  7334. var _iteratorError = undefined;
  7335. try {
  7336. for (var _iterator = this._styles.slice().reverse()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  7337. var code = _step.value;
  7338. // Replace any instances already present with a re-opening code
  7339. // otherwise only the part of the string until said closing code
  7340. // will be colored, and the rest will simply be 'plain'.
  7341. str = code.open + str.replace(code.closeRe, code.open) + code.close; // Close the styling before a linebreak and reopen
  7342. // after next line to fix a bleed issue on macOS
  7343. // https://github.com/chalk/chalk/pull/92
  7344. str = str.replace(/\r?\n/g, "".concat(code.close, "$&").concat(code.open));
  7345. } // Reset the original `dim` if we changed it to work around the Windows dimmed gray issue
  7346. } catch (err) {
  7347. _didIteratorError = true;
  7348. _iteratorError = err;
  7349. } finally {
  7350. try {
  7351. if (!_iteratorNormalCompletion && _iterator.return != null) {
  7352. _iterator.return();
  7353. }
  7354. } finally {
  7355. if (_didIteratorError) {
  7356. throw _iteratorError;
  7357. }
  7358. }
  7359. }
  7360. ansiStyles.dim.open = originalDim;
  7361. return str;
  7362. }
  7363. function chalkTag(chalk, strings) {
  7364. if (!Array.isArray(strings)) {
  7365. // If chalk() was called by itself or with a string,
  7366. // return the string itself as a string.
  7367. return [].slice.call(arguments, 1).join(' ');
  7368. }
  7369. var args = [].slice.call(arguments, 2);
  7370. var parts = [strings.raw[0]];
  7371. for (var i = 1; i < strings.length; i++) {
  7372. parts.push(String(args[i - 1]).replace(/[{}\\]/g, '\\$&'));
  7373. parts.push(String(strings.raw[i]));
  7374. }
  7375. return templates(chalk, parts.join(''));
  7376. }
  7377. Object.defineProperties(Chalk.prototype, styles);
  7378. module.exports = Chalk(); // eslint-disable-line new-cap
  7379. module.exports.supportsColor = stdoutColor;
  7380. module.exports.default = module.exports; // For TypeScript
  7381. });
  7382. var common = createCommonjsModule(function (module, exports) {
  7383. "use strict";
  7384. Object.defineProperty(exports, "__esModule", {
  7385. value: true
  7386. });
  7387. exports.commonDeprecatedHandler = function (keyOrPair, redirectTo, _ref) {
  7388. var descriptor = _ref.descriptor;
  7389. var messages = ["".concat(chalk.default.yellow(typeof keyOrPair === 'string' ? descriptor.key(keyOrPair) : descriptor.pair(keyOrPair)), " is deprecated")];
  7390. if (redirectTo) {
  7391. messages.push("we now treat it as ".concat(chalk.default.blue(typeof redirectTo === 'string' ? descriptor.key(redirectTo) : descriptor.pair(redirectTo))));
  7392. }
  7393. return messages.join('; ') + '.';
  7394. };
  7395. });
  7396. unwrapExports(common);
  7397. var deprecated = createCommonjsModule(function (module, exports) {
  7398. "use strict";
  7399. Object.defineProperty(exports, "__esModule", {
  7400. value: true
  7401. });
  7402. tslib_1.__exportStar(common, exports);
  7403. });
  7404. unwrapExports(deprecated);
  7405. var common$2 = createCommonjsModule(function (module, exports) {
  7406. "use strict";
  7407. Object.defineProperty(exports, "__esModule", {
  7408. value: true
  7409. });
  7410. exports.commonInvalidHandler = function (key, value, utils) {
  7411. return ["Invalid ".concat(chalk.default.red(utils.descriptor.key(key)), " value."), "Expected ".concat(chalk.default.blue(utils.schemas[key].expected(utils)), ","), "but received ".concat(chalk.default.red(utils.descriptor.value(value)), ".")].join(' ');
  7412. };
  7413. });
  7414. unwrapExports(common$2);
  7415. var invalid = createCommonjsModule(function (module, exports) {
  7416. "use strict";
  7417. Object.defineProperty(exports, "__esModule", {
  7418. value: true
  7419. });
  7420. tslib_1.__exportStar(common$2, exports);
  7421. });
  7422. unwrapExports(invalid);
  7423. /* eslint-disable no-nested-ternary */
  7424. var arr = [];
  7425. var charCodeCache = [];
  7426. var leven$1 = function leven(a, b) {
  7427. if (a === b) {
  7428. return 0;
  7429. }
  7430. var swap = a; // Swapping the strings if `a` is longer than `b` so we know which one is the
  7431. // shortest & which one is the longest
  7432. if (a.length > b.length) {
  7433. a = b;
  7434. b = swap;
  7435. }
  7436. var aLen = a.length;
  7437. var bLen = b.length;
  7438. if (aLen === 0) {
  7439. return bLen;
  7440. }
  7441. if (bLen === 0) {
  7442. return aLen;
  7443. } // Performing suffix trimming:
  7444. // We can linearly drop suffix common to both strings since they
  7445. // don't increase distance at all
  7446. // Note: `~-` is the bitwise way to perform a `- 1` operation
  7447. while (aLen > 0 && a.charCodeAt(~-aLen) === b.charCodeAt(~-bLen)) {
  7448. aLen--;
  7449. bLen--;
  7450. }
  7451. if (aLen === 0) {
  7452. return bLen;
  7453. } // Performing prefix trimming
  7454. // We can linearly drop prefix common to both strings since they
  7455. // don't increase distance at all
  7456. var start = 0;
  7457. while (start < aLen && a.charCodeAt(start) === b.charCodeAt(start)) {
  7458. start++;
  7459. }
  7460. aLen -= start;
  7461. bLen -= start;
  7462. if (aLen === 0) {
  7463. return bLen;
  7464. }
  7465. var bCharCode;
  7466. var ret;
  7467. var tmp;
  7468. var tmp2;
  7469. var i = 0;
  7470. var j = 0;
  7471. while (i < aLen) {
  7472. charCodeCache[start + i] = a.charCodeAt(start + i);
  7473. arr[i] = ++i;
  7474. }
  7475. while (j < bLen) {
  7476. bCharCode = b.charCodeAt(start + j);
  7477. tmp = j++;
  7478. ret = j;
  7479. for (i = 0; i < aLen; i++) {
  7480. tmp2 = bCharCode === charCodeCache[start + i] ? tmp : tmp + 1;
  7481. tmp = arr[i];
  7482. ret = arr[i] = tmp > ret ? tmp2 > ret ? ret + 1 : tmp2 : tmp2 > tmp ? tmp + 1 : tmp2;
  7483. }
  7484. }
  7485. return ret;
  7486. };
  7487. var leven_1 = createCommonjsModule(function (module, exports) {
  7488. "use strict";
  7489. Object.defineProperty(exports, "__esModule", {
  7490. value: true
  7491. });
  7492. exports.levenUnknownHandler = function (key, value, _ref) {
  7493. var descriptor = _ref.descriptor,
  7494. logger = _ref.logger,
  7495. schemas = _ref.schemas;
  7496. var messages = ["Ignored unknown option ".concat(chalk.default.yellow(descriptor.pair({
  7497. key: key,
  7498. value: value
  7499. })), ".")];
  7500. var suggestion = Object.keys(schemas).sort().find(function (knownKey) {
  7501. return leven$1(key, knownKey) < 3;
  7502. });
  7503. if (suggestion) {
  7504. messages.push("Did you mean ".concat(chalk.default.blue(descriptor.key(suggestion)), "?"));
  7505. }
  7506. logger.warn(messages.join(' '));
  7507. };
  7508. });
  7509. unwrapExports(leven_1);
  7510. var unknown = createCommonjsModule(function (module, exports) {
  7511. "use strict";
  7512. Object.defineProperty(exports, "__esModule", {
  7513. value: true
  7514. });
  7515. tslib_1.__exportStar(leven_1, exports);
  7516. });
  7517. unwrapExports(unknown);
  7518. var handlers = createCommonjsModule(function (module, exports) {
  7519. "use strict";
  7520. Object.defineProperty(exports, "__esModule", {
  7521. value: true
  7522. });
  7523. tslib_1.__exportStar(deprecated, exports);
  7524. tslib_1.__exportStar(invalid, exports);
  7525. tslib_1.__exportStar(unknown, exports);
  7526. });
  7527. unwrapExports(handlers);
  7528. var schema = createCommonjsModule(function (module, exports) {
  7529. "use strict";
  7530. Object.defineProperty(exports, "__esModule", {
  7531. value: true
  7532. });
  7533. var HANDLER_KEYS = ['default', 'expected', 'validate', 'deprecated', 'forward', 'redirect', 'overlap', 'preprocess', 'postprocess'];
  7534. function createSchema(SchemaConstructor, parameters) {
  7535. var schema = new SchemaConstructor(parameters);
  7536. var subSchema = Object.create(schema);
  7537. for (var _i = 0; _i < HANDLER_KEYS.length; _i++) {
  7538. var handlerKey = HANDLER_KEYS[_i];
  7539. if (handlerKey in parameters) {
  7540. subSchema[handlerKey] = normalizeHandler(parameters[handlerKey], schema, Schema.prototype[handlerKey].length);
  7541. }
  7542. }
  7543. return subSchema;
  7544. }
  7545. exports.createSchema = createSchema;
  7546. var Schema =
  7547. /*#__PURE__*/
  7548. function () {
  7549. function Schema(parameters) {
  7550. _classCallCheck(this, Schema);
  7551. this.name = parameters.name;
  7552. }
  7553. _createClass(Schema, [{
  7554. key: "default",
  7555. value: function _default(_utils) {
  7556. return undefined;
  7557. } // istanbul ignore next: this is actually an abstract method but we need a placeholder to get `function.length`
  7558. }, {
  7559. key: "expected",
  7560. value: function expected(_utils) {
  7561. return 'nothing';
  7562. } // istanbul ignore next: this is actually an abstract method but we need a placeholder to get `function.length`
  7563. }, {
  7564. key: "validate",
  7565. value: function validate(_value, _utils) {
  7566. return false;
  7567. }
  7568. }, {
  7569. key: "deprecated",
  7570. value: function deprecated(_value, _utils) {
  7571. return false;
  7572. }
  7573. }, {
  7574. key: "forward",
  7575. value: function forward(_value, _utils) {
  7576. return undefined;
  7577. }
  7578. }, {
  7579. key: "redirect",
  7580. value: function redirect(_value, _utils) {
  7581. return undefined;
  7582. }
  7583. }, {
  7584. key: "overlap",
  7585. value: function overlap(currentValue, _newValue, _utils) {
  7586. return currentValue;
  7587. }
  7588. }, {
  7589. key: "preprocess",
  7590. value: function preprocess(value, _utils) {
  7591. return value;
  7592. }
  7593. }, {
  7594. key: "postprocess",
  7595. value: function postprocess(value, _utils) {
  7596. return value;
  7597. }
  7598. }], [{
  7599. key: "create",
  7600. value: function create(parameters) {
  7601. // @ts-ignore: https://github.com/Microsoft/TypeScript/issues/5863
  7602. return createSchema(this, parameters);
  7603. }
  7604. }]);
  7605. return Schema;
  7606. }();
  7607. exports.Schema = Schema;
  7608. function normalizeHandler(handler, superSchema, handlerArgumentsLength) {
  7609. return typeof handler === 'function' ? function () {
  7610. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  7611. args[_key] = arguments[_key];
  7612. }
  7613. return handler.apply(void 0, _toConsumableArray(args.slice(0, handlerArgumentsLength - 1)).concat([superSchema], _toConsumableArray(args.slice(handlerArgumentsLength - 1))));
  7614. } : function () {
  7615. return handler;
  7616. };
  7617. }
  7618. });
  7619. unwrapExports(schema);
  7620. var alias = createCommonjsModule(function (module, exports) {
  7621. "use strict";
  7622. Object.defineProperty(exports, "__esModule", {
  7623. value: true
  7624. });
  7625. var AliasSchema =
  7626. /*#__PURE__*/
  7627. function (_schema_1$Schema) {
  7628. _inherits(AliasSchema, _schema_1$Schema);
  7629. function AliasSchema(parameters) {
  7630. var _this;
  7631. _classCallCheck(this, AliasSchema);
  7632. _this = _possibleConstructorReturn(this, _getPrototypeOf(AliasSchema).call(this, parameters));
  7633. _this._sourceName = parameters.sourceName;
  7634. return _this;
  7635. }
  7636. _createClass(AliasSchema, [{
  7637. key: "expected",
  7638. value: function expected(utils) {
  7639. return utils.schemas[this._sourceName].expected(utils);
  7640. }
  7641. }, {
  7642. key: "validate",
  7643. value: function validate(value, utils) {
  7644. return utils.schemas[this._sourceName].validate(value, utils);
  7645. }
  7646. }, {
  7647. key: "redirect",
  7648. value: function redirect(_value, _utils) {
  7649. return this._sourceName;
  7650. }
  7651. }]);
  7652. return AliasSchema;
  7653. }(schema.Schema);
  7654. exports.AliasSchema = AliasSchema;
  7655. });
  7656. unwrapExports(alias);
  7657. var any = createCommonjsModule(function (module, exports) {
  7658. "use strict";
  7659. Object.defineProperty(exports, "__esModule", {
  7660. value: true
  7661. });
  7662. var AnySchema =
  7663. /*#__PURE__*/
  7664. function (_schema_1$Schema) {
  7665. _inherits(AnySchema, _schema_1$Schema);
  7666. function AnySchema() {
  7667. _classCallCheck(this, AnySchema);
  7668. return _possibleConstructorReturn(this, _getPrototypeOf(AnySchema).apply(this, arguments));
  7669. }
  7670. _createClass(AnySchema, [{
  7671. key: "expected",
  7672. value: function expected() {
  7673. return 'anything';
  7674. }
  7675. }, {
  7676. key: "validate",
  7677. value: function validate() {
  7678. return true;
  7679. }
  7680. }]);
  7681. return AnySchema;
  7682. }(schema.Schema);
  7683. exports.AnySchema = AnySchema;
  7684. });
  7685. unwrapExports(any);
  7686. var array$2 = createCommonjsModule(function (module, exports) {
  7687. "use strict";
  7688. Object.defineProperty(exports, "__esModule", {
  7689. value: true
  7690. });
  7691. var ArraySchema =
  7692. /*#__PURE__*/
  7693. function (_schema_1$Schema) {
  7694. _inherits(ArraySchema, _schema_1$Schema);
  7695. function ArraySchema(_a) {
  7696. var _this;
  7697. _classCallCheck(this, ArraySchema);
  7698. var valueSchema = _a.valueSchema,
  7699. _a$name = _a.name,
  7700. name = _a$name === void 0 ? valueSchema.name : _a$name,
  7701. handlers = tslib_1.__rest(_a, ["valueSchema", "name"]);
  7702. _this = _possibleConstructorReturn(this, _getPrototypeOf(ArraySchema).call(this, Object.assign({}, handlers, {
  7703. name: name
  7704. })));
  7705. _this._valueSchema = valueSchema;
  7706. return _this;
  7707. }
  7708. _createClass(ArraySchema, [{
  7709. key: "expected",
  7710. value: function expected(utils) {
  7711. return "an array of ".concat(this._valueSchema.expected(utils));
  7712. }
  7713. }, {
  7714. key: "validate",
  7715. value: function validate(value, utils) {
  7716. if (!Array.isArray(value)) {
  7717. return false;
  7718. }
  7719. var invalidValues = [];
  7720. var _iteratorNormalCompletion = true;
  7721. var _didIteratorError = false;
  7722. var _iteratorError = undefined;
  7723. try {
  7724. for (var _iterator = value[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  7725. var subValue = _step.value;
  7726. var subValidateResult = utils.normalizeValidateResult(this._valueSchema.validate(subValue, utils), subValue);
  7727. if (subValidateResult !== true) {
  7728. invalidValues.push(subValidateResult.value);
  7729. }
  7730. }
  7731. } catch (err) {
  7732. _didIteratorError = true;
  7733. _iteratorError = err;
  7734. } finally {
  7735. try {
  7736. if (!_iteratorNormalCompletion && _iterator.return != null) {
  7737. _iterator.return();
  7738. }
  7739. } finally {
  7740. if (_didIteratorError) {
  7741. throw _iteratorError;
  7742. }
  7743. }
  7744. }
  7745. return invalidValues.length === 0 ? true : {
  7746. value: invalidValues
  7747. };
  7748. }
  7749. }, {
  7750. key: "deprecated",
  7751. value: function deprecated(value, utils) {
  7752. var deprecatedResult = [];
  7753. var _iteratorNormalCompletion2 = true;
  7754. var _didIteratorError2 = false;
  7755. var _iteratorError2 = undefined;
  7756. try {
  7757. for (var _iterator2 = value[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
  7758. var subValue = _step2.value;
  7759. var subDeprecatedResult = utils.normalizeDeprecatedResult(this._valueSchema.deprecated(subValue, utils), subValue);
  7760. if (subDeprecatedResult !== false) {
  7761. deprecatedResult.push.apply(deprecatedResult, _toConsumableArray(subDeprecatedResult.map(function (_ref) {
  7762. var deprecatedValue = _ref.value;
  7763. return {
  7764. value: [deprecatedValue]
  7765. };
  7766. })));
  7767. }
  7768. }
  7769. } catch (err) {
  7770. _didIteratorError2 = true;
  7771. _iteratorError2 = err;
  7772. } finally {
  7773. try {
  7774. if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
  7775. _iterator2.return();
  7776. }
  7777. } finally {
  7778. if (_didIteratorError2) {
  7779. throw _iteratorError2;
  7780. }
  7781. }
  7782. }
  7783. return deprecatedResult;
  7784. }
  7785. }, {
  7786. key: "forward",
  7787. value: function forward(value, utils) {
  7788. var forwardResult = [];
  7789. var _iteratorNormalCompletion3 = true;
  7790. var _didIteratorError3 = false;
  7791. var _iteratorError3 = undefined;
  7792. try {
  7793. for (var _iterator3 = value[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
  7794. var subValue = _step3.value;
  7795. var subForwardResult = utils.normalizeForwardResult(this._valueSchema.forward(subValue, utils), subValue);
  7796. forwardResult.push.apply(forwardResult, _toConsumableArray(subForwardResult.map(wrapTransferResult)));
  7797. }
  7798. } catch (err) {
  7799. _didIteratorError3 = true;
  7800. _iteratorError3 = err;
  7801. } finally {
  7802. try {
  7803. if (!_iteratorNormalCompletion3 && _iterator3.return != null) {
  7804. _iterator3.return();
  7805. }
  7806. } finally {
  7807. if (_didIteratorError3) {
  7808. throw _iteratorError3;
  7809. }
  7810. }
  7811. }
  7812. return forwardResult;
  7813. }
  7814. }, {
  7815. key: "redirect",
  7816. value: function redirect(value, utils) {
  7817. var remain = [];
  7818. var redirect = [];
  7819. var _iteratorNormalCompletion4 = true;
  7820. var _didIteratorError4 = false;
  7821. var _iteratorError4 = undefined;
  7822. try {
  7823. for (var _iterator4 = value[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {
  7824. var subValue = _step4.value;
  7825. var subRedirectResult = utils.normalizeRedirectResult(this._valueSchema.redirect(subValue, utils), subValue);
  7826. if ('remain' in subRedirectResult) {
  7827. remain.push(subRedirectResult.remain);
  7828. }
  7829. redirect.push.apply(redirect, _toConsumableArray(subRedirectResult.redirect.map(wrapTransferResult)));
  7830. }
  7831. } catch (err) {
  7832. _didIteratorError4 = true;
  7833. _iteratorError4 = err;
  7834. } finally {
  7835. try {
  7836. if (!_iteratorNormalCompletion4 && _iterator4.return != null) {
  7837. _iterator4.return();
  7838. }
  7839. } finally {
  7840. if (_didIteratorError4) {
  7841. throw _iteratorError4;
  7842. }
  7843. }
  7844. }
  7845. return remain.length === 0 ? {
  7846. redirect: redirect
  7847. } : {
  7848. redirect: redirect,
  7849. remain: remain
  7850. };
  7851. }
  7852. }, {
  7853. key: "overlap",
  7854. value: function overlap(currentValue, newValue) {
  7855. return currentValue.concat(newValue);
  7856. }
  7857. }]);
  7858. return ArraySchema;
  7859. }(schema.Schema);
  7860. exports.ArraySchema = ArraySchema;
  7861. function wrapTransferResult(_ref2) {
  7862. var from = _ref2.from,
  7863. to = _ref2.to;
  7864. return {
  7865. from: [from],
  7866. to: to
  7867. };
  7868. }
  7869. });
  7870. unwrapExports(array$2);
  7871. var boolean_1 = createCommonjsModule(function (module, exports) {
  7872. "use strict";
  7873. Object.defineProperty(exports, "__esModule", {
  7874. value: true
  7875. });
  7876. var BooleanSchema =
  7877. /*#__PURE__*/
  7878. function (_schema_1$Schema) {
  7879. _inherits(BooleanSchema, _schema_1$Schema);
  7880. function BooleanSchema() {
  7881. _classCallCheck(this, BooleanSchema);
  7882. return _possibleConstructorReturn(this, _getPrototypeOf(BooleanSchema).apply(this, arguments));
  7883. }
  7884. _createClass(BooleanSchema, [{
  7885. key: "expected",
  7886. value: function expected() {
  7887. return 'true or false';
  7888. }
  7889. }, {
  7890. key: "validate",
  7891. value: function validate(value) {
  7892. return typeof value === 'boolean';
  7893. }
  7894. }]);
  7895. return BooleanSchema;
  7896. }(schema.Schema);
  7897. exports.BooleanSchema = BooleanSchema;
  7898. });
  7899. unwrapExports(boolean_1);
  7900. var utils = createCommonjsModule(function (module, exports) {
  7901. "use strict";
  7902. Object.defineProperty(exports, "__esModule", {
  7903. value: true
  7904. });
  7905. function recordFromArray(array, mainKey) {
  7906. var record = Object.create(null);
  7907. var _iteratorNormalCompletion = true;
  7908. var _didIteratorError = false;
  7909. var _iteratorError = undefined;
  7910. try {
  7911. for (var _iterator = array[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  7912. var value = _step.value;
  7913. var key = value[mainKey]; // istanbul ignore next
  7914. if (record[key]) {
  7915. throw new Error("Duplicate ".concat(mainKey, " ").concat(JSON.stringify(key)));
  7916. } // @ts-ignore
  7917. record[key] = value;
  7918. }
  7919. } catch (err) {
  7920. _didIteratorError = true;
  7921. _iteratorError = err;
  7922. } finally {
  7923. try {
  7924. if (!_iteratorNormalCompletion && _iterator.return != null) {
  7925. _iterator.return();
  7926. }
  7927. } finally {
  7928. if (_didIteratorError) {
  7929. throw _iteratorError;
  7930. }
  7931. }
  7932. }
  7933. return record;
  7934. }
  7935. exports.recordFromArray = recordFromArray;
  7936. function mapFromArray(array, mainKey) {
  7937. var map = new Map();
  7938. var _iteratorNormalCompletion2 = true;
  7939. var _didIteratorError2 = false;
  7940. var _iteratorError2 = undefined;
  7941. try {
  7942. for (var _iterator2 = array[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
  7943. var value = _step2.value;
  7944. var key = value[mainKey]; // istanbul ignore next
  7945. if (map.has(key)) {
  7946. throw new Error("Duplicate ".concat(mainKey, " ").concat(JSON.stringify(key)));
  7947. }
  7948. map.set(key, value);
  7949. }
  7950. } catch (err) {
  7951. _didIteratorError2 = true;
  7952. _iteratorError2 = err;
  7953. } finally {
  7954. try {
  7955. if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
  7956. _iterator2.return();
  7957. }
  7958. } finally {
  7959. if (_didIteratorError2) {
  7960. throw _iteratorError2;
  7961. }
  7962. }
  7963. }
  7964. return map;
  7965. }
  7966. exports.mapFromArray = mapFromArray;
  7967. function createAutoChecklist() {
  7968. var map = Object.create(null);
  7969. return function (id) {
  7970. var idString = JSON.stringify(id);
  7971. if (map[idString]) {
  7972. return true;
  7973. }
  7974. map[idString] = true;
  7975. return false;
  7976. };
  7977. }
  7978. exports.createAutoChecklist = createAutoChecklist;
  7979. function partition(array, predicate) {
  7980. var trueArray = [];
  7981. var falseArray = [];
  7982. var _iteratorNormalCompletion3 = true;
  7983. var _didIteratorError3 = false;
  7984. var _iteratorError3 = undefined;
  7985. try {
  7986. for (var _iterator3 = array[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
  7987. var value = _step3.value;
  7988. if (predicate(value)) {
  7989. trueArray.push(value);
  7990. } else {
  7991. falseArray.push(value);
  7992. }
  7993. }
  7994. } catch (err) {
  7995. _didIteratorError3 = true;
  7996. _iteratorError3 = err;
  7997. } finally {
  7998. try {
  7999. if (!_iteratorNormalCompletion3 && _iterator3.return != null) {
  8000. _iterator3.return();
  8001. }
  8002. } finally {
  8003. if (_didIteratorError3) {
  8004. throw _iteratorError3;
  8005. }
  8006. }
  8007. }
  8008. return [trueArray, falseArray];
  8009. }
  8010. exports.partition = partition;
  8011. function isInt(value) {
  8012. return value === Math.floor(value);
  8013. }
  8014. exports.isInt = isInt;
  8015. function comparePrimitive(a, b) {
  8016. if (a === b) {
  8017. return 0;
  8018. }
  8019. var typeofA = _typeof(a);
  8020. var typeofB = _typeof(b);
  8021. var orders = ['undefined', 'object', 'boolean', 'number', 'string'];
  8022. if (typeofA !== typeofB) {
  8023. return orders.indexOf(typeofA) - orders.indexOf(typeofB);
  8024. }
  8025. if (typeofA !== 'string') {
  8026. return Number(a) - Number(b);
  8027. }
  8028. return a.localeCompare(b);
  8029. }
  8030. exports.comparePrimitive = comparePrimitive;
  8031. function normalizeDefaultResult(result) {
  8032. return result === undefined ? {} : result;
  8033. }
  8034. exports.normalizeDefaultResult = normalizeDefaultResult;
  8035. function normalizeValidateResult(result, value) {
  8036. return result === true ? true : result === false ? {
  8037. value: value
  8038. } : result;
  8039. }
  8040. exports.normalizeValidateResult = normalizeValidateResult;
  8041. function normalizeDeprecatedResult(result, value) {
  8042. var doNotNormalizeTrue = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  8043. return result === false ? false : result === true ? doNotNormalizeTrue ? true : [{
  8044. value: value
  8045. }] : 'value' in result ? [result] : result.length === 0 ? false : result;
  8046. }
  8047. exports.normalizeDeprecatedResult = normalizeDeprecatedResult;
  8048. function normalizeTransferResult(result, value) {
  8049. return typeof result === 'string' || 'key' in result ? {
  8050. from: value,
  8051. to: result
  8052. } : 'from' in result ? {
  8053. from: result.from,
  8054. to: result.to
  8055. } : {
  8056. from: value,
  8057. to: result.to
  8058. };
  8059. }
  8060. exports.normalizeTransferResult = normalizeTransferResult;
  8061. function normalizeForwardResult(result, value) {
  8062. return result === undefined ? [] : Array.isArray(result) ? result.map(function (transferResult) {
  8063. return normalizeTransferResult(transferResult, value);
  8064. }) : [normalizeTransferResult(result, value)];
  8065. }
  8066. exports.normalizeForwardResult = normalizeForwardResult;
  8067. function normalizeRedirectResult(result, value) {
  8068. var redirect = normalizeForwardResult(_typeof(result) === 'object' && 'redirect' in result ? result.redirect : result, value);
  8069. return redirect.length === 0 ? {
  8070. remain: value,
  8071. redirect: redirect
  8072. } : _typeof(result) === 'object' && 'remain' in result ? {
  8073. remain: result.remain,
  8074. redirect: redirect
  8075. } : {
  8076. redirect: redirect
  8077. };
  8078. }
  8079. exports.normalizeRedirectResult = normalizeRedirectResult;
  8080. });
  8081. unwrapExports(utils);
  8082. var choice = createCommonjsModule(function (module, exports) {
  8083. "use strict";
  8084. Object.defineProperty(exports, "__esModule", {
  8085. value: true
  8086. });
  8087. var ChoiceSchema =
  8088. /*#__PURE__*/
  8089. function (_schema_1$Schema) {
  8090. _inherits(ChoiceSchema, _schema_1$Schema);
  8091. function ChoiceSchema(parameters) {
  8092. var _this;
  8093. _classCallCheck(this, ChoiceSchema);
  8094. _this = _possibleConstructorReturn(this, _getPrototypeOf(ChoiceSchema).call(this, parameters));
  8095. _this._choices = utils.mapFromArray(parameters.choices.map(function (choice) {
  8096. return choice && _typeof(choice) === 'object' ? choice : {
  8097. value: choice
  8098. };
  8099. }), 'value');
  8100. return _this;
  8101. }
  8102. _createClass(ChoiceSchema, [{
  8103. key: "expected",
  8104. value: function expected(_ref) {
  8105. var _this2 = this;
  8106. var descriptor = _ref.descriptor;
  8107. var choiceValues = Array.from(this._choices.keys()).map(function (value) {
  8108. return _this2._choices.get(value);
  8109. }).filter(function (choiceInfo) {
  8110. return !choiceInfo.deprecated;
  8111. }).map(function (choiceInfo) {
  8112. return choiceInfo.value;
  8113. }).sort(utils.comparePrimitive).map(descriptor.value);
  8114. var head = choiceValues.slice(0, -2);
  8115. var tail = choiceValues.slice(-2);
  8116. return head.concat(tail.join(' or ')).join(', ');
  8117. }
  8118. }, {
  8119. key: "validate",
  8120. value: function validate(value) {
  8121. return this._choices.has(value);
  8122. }
  8123. }, {
  8124. key: "deprecated",
  8125. value: function deprecated(value) {
  8126. var choiceInfo = this._choices.get(value);
  8127. return choiceInfo && choiceInfo.deprecated ? {
  8128. value: value
  8129. } : false;
  8130. }
  8131. }, {
  8132. key: "forward",
  8133. value: function forward(value) {
  8134. var choiceInfo = this._choices.get(value);
  8135. return choiceInfo ? choiceInfo.forward : undefined;
  8136. }
  8137. }, {
  8138. key: "redirect",
  8139. value: function redirect(value) {
  8140. var choiceInfo = this._choices.get(value);
  8141. return choiceInfo ? choiceInfo.redirect : undefined;
  8142. }
  8143. }]);
  8144. return ChoiceSchema;
  8145. }(schema.Schema);
  8146. exports.ChoiceSchema = ChoiceSchema;
  8147. });
  8148. unwrapExports(choice);
  8149. var number = createCommonjsModule(function (module, exports) {
  8150. "use strict";
  8151. Object.defineProperty(exports, "__esModule", {
  8152. value: true
  8153. });
  8154. var NumberSchema =
  8155. /*#__PURE__*/
  8156. function (_schema_1$Schema) {
  8157. _inherits(NumberSchema, _schema_1$Schema);
  8158. function NumberSchema() {
  8159. _classCallCheck(this, NumberSchema);
  8160. return _possibleConstructorReturn(this, _getPrototypeOf(NumberSchema).apply(this, arguments));
  8161. }
  8162. _createClass(NumberSchema, [{
  8163. key: "expected",
  8164. value: function expected() {
  8165. return 'a number';
  8166. }
  8167. }, {
  8168. key: "validate",
  8169. value: function validate(value, _utils) {
  8170. return typeof value === 'number';
  8171. }
  8172. }]);
  8173. return NumberSchema;
  8174. }(schema.Schema);
  8175. exports.NumberSchema = NumberSchema;
  8176. });
  8177. unwrapExports(number);
  8178. var integer = createCommonjsModule(function (module, exports) {
  8179. "use strict";
  8180. Object.defineProperty(exports, "__esModule", {
  8181. value: true
  8182. });
  8183. var IntegerSchema =
  8184. /*#__PURE__*/
  8185. function (_number_1$NumberSchem) {
  8186. _inherits(IntegerSchema, _number_1$NumberSchem);
  8187. function IntegerSchema() {
  8188. _classCallCheck(this, IntegerSchema);
  8189. return _possibleConstructorReturn(this, _getPrototypeOf(IntegerSchema).apply(this, arguments));
  8190. }
  8191. _createClass(IntegerSchema, [{
  8192. key: "expected",
  8193. value: function expected() {
  8194. return 'an integer';
  8195. }
  8196. }, {
  8197. key: "validate",
  8198. value: function validate(value, utils$$2) {
  8199. return utils$$2.normalizeValidateResult(_get(_getPrototypeOf(IntegerSchema.prototype), "validate", this).call(this, value, utils$$2), value) === true && utils.isInt(value);
  8200. }
  8201. }]);
  8202. return IntegerSchema;
  8203. }(number.NumberSchema);
  8204. exports.IntegerSchema = IntegerSchema;
  8205. });
  8206. unwrapExports(integer);
  8207. var string = createCommonjsModule(function (module, exports) {
  8208. "use strict";
  8209. Object.defineProperty(exports, "__esModule", {
  8210. value: true
  8211. });
  8212. var StringSchema =
  8213. /*#__PURE__*/
  8214. function (_schema_1$Schema) {
  8215. _inherits(StringSchema, _schema_1$Schema);
  8216. function StringSchema() {
  8217. _classCallCheck(this, StringSchema);
  8218. return _possibleConstructorReturn(this, _getPrototypeOf(StringSchema).apply(this, arguments));
  8219. }
  8220. _createClass(StringSchema, [{
  8221. key: "expected",
  8222. value: function expected() {
  8223. return 'a string';
  8224. }
  8225. }, {
  8226. key: "validate",
  8227. value: function validate(value) {
  8228. return typeof value === 'string';
  8229. }
  8230. }]);
  8231. return StringSchema;
  8232. }(schema.Schema);
  8233. exports.StringSchema = StringSchema;
  8234. });
  8235. unwrapExports(string);
  8236. var schemas = createCommonjsModule(function (module, exports) {
  8237. "use strict";
  8238. Object.defineProperty(exports, "__esModule", {
  8239. value: true
  8240. });
  8241. tslib_1.__exportStar(alias, exports);
  8242. tslib_1.__exportStar(any, exports);
  8243. tslib_1.__exportStar(array$2, exports);
  8244. tslib_1.__exportStar(boolean_1, exports);
  8245. tslib_1.__exportStar(choice, exports);
  8246. tslib_1.__exportStar(integer, exports);
  8247. tslib_1.__exportStar(number, exports);
  8248. tslib_1.__exportStar(string, exports);
  8249. });
  8250. unwrapExports(schemas);
  8251. var defaults = createCommonjsModule(function (module, exports) {
  8252. "use strict";
  8253. Object.defineProperty(exports, "__esModule", {
  8254. value: true
  8255. });
  8256. exports.defaultDescriptor = api.apiDescriptor;
  8257. exports.defaultUnknownHandler = leven_1.levenUnknownHandler;
  8258. exports.defaultInvalidHandler = invalid.commonInvalidHandler;
  8259. exports.defaultDeprecatedHandler = common.commonDeprecatedHandler;
  8260. });
  8261. unwrapExports(defaults);
  8262. var normalize$1 = createCommonjsModule(function (module, exports) {
  8263. "use strict";
  8264. Object.defineProperty(exports, "__esModule", {
  8265. value: true
  8266. });
  8267. exports.normalize = function (options, schemas, opts) {
  8268. return new Normalizer(schemas, opts).normalize(options);
  8269. };
  8270. var Normalizer =
  8271. /*#__PURE__*/
  8272. function () {
  8273. function Normalizer(schemas, opts) {
  8274. _classCallCheck(this, Normalizer);
  8275. // istanbul ignore next
  8276. var _ref = opts || {},
  8277. _ref$logger = _ref.logger,
  8278. logger = _ref$logger === void 0 ? console : _ref$logger,
  8279. _ref$descriptor = _ref.descriptor,
  8280. descriptor = _ref$descriptor === void 0 ? defaults.defaultDescriptor : _ref$descriptor,
  8281. _ref$unknown = _ref.unknown,
  8282. unknown = _ref$unknown === void 0 ? defaults.defaultUnknownHandler : _ref$unknown,
  8283. _ref$invalid = _ref.invalid,
  8284. invalid = _ref$invalid === void 0 ? defaults.defaultInvalidHandler : _ref$invalid,
  8285. _ref$deprecated = _ref.deprecated,
  8286. deprecated = _ref$deprecated === void 0 ? defaults.defaultDeprecatedHandler : _ref$deprecated;
  8287. this._utils = {
  8288. descriptor: descriptor,
  8289. logger:
  8290. /* istanbul ignore next */
  8291. logger || {
  8292. warn: function warn() {}
  8293. },
  8294. schemas: utils.recordFromArray(schemas, 'name'),
  8295. normalizeDefaultResult: utils.normalizeDefaultResult,
  8296. normalizeDeprecatedResult: utils.normalizeDeprecatedResult,
  8297. normalizeForwardResult: utils.normalizeForwardResult,
  8298. normalizeRedirectResult: utils.normalizeRedirectResult,
  8299. normalizeValidateResult: utils.normalizeValidateResult
  8300. };
  8301. this._unknownHandler = unknown;
  8302. this._invalidHandler = invalid;
  8303. this._deprecatedHandler = deprecated;
  8304. this.cleanHistory();
  8305. }
  8306. _createClass(Normalizer, [{
  8307. key: "cleanHistory",
  8308. value: function cleanHistory() {
  8309. this._hasDeprecationWarned = utils.createAutoChecklist();
  8310. }
  8311. }, {
  8312. key: "normalize",
  8313. value: function normalize(options) {
  8314. var _this = this;
  8315. var normalized = {};
  8316. var restOptionsArray = [options];
  8317. var applyNormalization = function applyNormalization() {
  8318. while (restOptionsArray.length !== 0) {
  8319. var currentOptions = restOptionsArray.shift();
  8320. var transferredOptionsArray = _this._applyNormalization(currentOptions, normalized);
  8321. restOptionsArray.push.apply(restOptionsArray, _toConsumableArray(transferredOptionsArray));
  8322. }
  8323. };
  8324. applyNormalization();
  8325. var _arr = Object.keys(this._utils.schemas);
  8326. for (var _i = 0; _i < _arr.length; _i++) {
  8327. var key = _arr[_i];
  8328. var schema = this._utils.schemas[key];
  8329. if (!(key in normalized)) {
  8330. var defaultResult = utils.normalizeDefaultResult(schema.default(this._utils));
  8331. if ('value' in defaultResult) {
  8332. restOptionsArray.push(_defineProperty({}, key, defaultResult.value));
  8333. }
  8334. }
  8335. }
  8336. applyNormalization();
  8337. var _arr2 = Object.keys(this._utils.schemas);
  8338. for (var _i2 = 0; _i2 < _arr2.length; _i2++) {
  8339. var _key = _arr2[_i2];
  8340. var _schema = this._utils.schemas[_key];
  8341. if (_key in normalized) {
  8342. normalized[_key] = _schema.postprocess(normalized[_key], this._utils);
  8343. }
  8344. }
  8345. return normalized;
  8346. }
  8347. }, {
  8348. key: "_applyNormalization",
  8349. value: function _applyNormalization(options, normalized) {
  8350. var _this2 = this;
  8351. var transferredOptionsArray = [];
  8352. var _utils_1$partition = utils.partition(Object.keys(options), function (key) {
  8353. return key in _this2._utils.schemas;
  8354. }),
  8355. _utils_1$partition2 = _slicedToArray(_utils_1$partition, 2),
  8356. knownOptionNames = _utils_1$partition2[0],
  8357. unknownOptionNames = _utils_1$partition2[1];
  8358. var _iteratorNormalCompletion = true;
  8359. var _didIteratorError = false;
  8360. var _iteratorError = undefined;
  8361. try {
  8362. var _loop = function _loop() {
  8363. var key = _step.value;
  8364. var schema = _this2._utils.schemas[key];
  8365. var value = schema.preprocess(options[key], _this2._utils);
  8366. var validateResult = utils.normalizeValidateResult(schema.validate(value, _this2._utils), value);
  8367. if (validateResult !== true) {
  8368. var invalidValue = validateResult.value;
  8369. var errorMessageOrError = _this2._invalidHandler(key, invalidValue, _this2._utils);
  8370. throw typeof errorMessageOrError === 'string' ? new Error(errorMessageOrError) :
  8371. /* istanbul ignore next*/
  8372. errorMessageOrError;
  8373. }
  8374. var appendTransferredOptions = function appendTransferredOptions(_ref2) {
  8375. var from = _ref2.from,
  8376. to = _ref2.to;
  8377. transferredOptionsArray.push(typeof to === 'string' ? _defineProperty({}, to, from) : _defineProperty({}, to.key, to.value));
  8378. };
  8379. var warnDeprecated = function warnDeprecated(_ref5) {
  8380. var currentValue = _ref5.value,
  8381. redirectTo = _ref5.redirectTo;
  8382. var deprecatedResult = utils.normalizeDeprecatedResult(schema.deprecated(currentValue, _this2._utils), value,
  8383. /* doNotNormalizeTrue */
  8384. true);
  8385. if (deprecatedResult === false) {
  8386. return;
  8387. }
  8388. if (deprecatedResult === true) {
  8389. if (!_this2._hasDeprecationWarned(key)) {
  8390. _this2._utils.logger.warn(_this2._deprecatedHandler(key, redirectTo, _this2._utils));
  8391. }
  8392. } else {
  8393. var _iteratorNormalCompletion3 = true;
  8394. var _didIteratorError3 = false;
  8395. var _iteratorError3 = undefined;
  8396. try {
  8397. for (var _iterator3 = deprecatedResult[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
  8398. var deprecatedValue = _step3.value.value;
  8399. var pair = {
  8400. key: key,
  8401. value: deprecatedValue
  8402. };
  8403. if (!_this2._hasDeprecationWarned(pair)) {
  8404. var redirectToPair = typeof redirectTo === 'string' ? {
  8405. key: redirectTo,
  8406. value: deprecatedValue
  8407. } : redirectTo;
  8408. _this2._utils.logger.warn(_this2._deprecatedHandler(pair, redirectToPair, _this2._utils));
  8409. }
  8410. }
  8411. } catch (err) {
  8412. _didIteratorError3 = true;
  8413. _iteratorError3 = err;
  8414. } finally {
  8415. try {
  8416. if (!_iteratorNormalCompletion3 && _iterator3.return != null) {
  8417. _iterator3.return();
  8418. }
  8419. } finally {
  8420. if (_didIteratorError3) {
  8421. throw _iteratorError3;
  8422. }
  8423. }
  8424. }
  8425. }
  8426. };
  8427. var forwardResult = utils.normalizeForwardResult(schema.forward(value, _this2._utils), value);
  8428. forwardResult.forEach(appendTransferredOptions);
  8429. var redirectResult = utils.normalizeRedirectResult(schema.redirect(value, _this2._utils), value);
  8430. redirectResult.redirect.forEach(appendTransferredOptions);
  8431. if ('remain' in redirectResult) {
  8432. var remainingValue = redirectResult.remain;
  8433. normalized[key] = key in normalized ? schema.overlap(normalized[key], remainingValue, _this2._utils) : remainingValue;
  8434. warnDeprecated({
  8435. value: remainingValue
  8436. });
  8437. }
  8438. var _iteratorNormalCompletion4 = true;
  8439. var _didIteratorError4 = false;
  8440. var _iteratorError4 = undefined;
  8441. try {
  8442. for (var _iterator4 = redirectResult.redirect[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {
  8443. var _step4$value = _step4.value,
  8444. from = _step4$value.from,
  8445. to = _step4$value.to;
  8446. warnDeprecated({
  8447. value: from,
  8448. redirectTo: to
  8449. });
  8450. }
  8451. } catch (err) {
  8452. _didIteratorError4 = true;
  8453. _iteratorError4 = err;
  8454. } finally {
  8455. try {
  8456. if (!_iteratorNormalCompletion4 && _iterator4.return != null) {
  8457. _iterator4.return();
  8458. }
  8459. } finally {
  8460. if (_didIteratorError4) {
  8461. throw _iteratorError4;
  8462. }
  8463. }
  8464. }
  8465. };
  8466. for (var _iterator = knownOptionNames[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  8467. _loop();
  8468. }
  8469. } catch (err) {
  8470. _didIteratorError = true;
  8471. _iteratorError = err;
  8472. } finally {
  8473. try {
  8474. if (!_iteratorNormalCompletion && _iterator.return != null) {
  8475. _iterator.return();
  8476. }
  8477. } finally {
  8478. if (_didIteratorError) {
  8479. throw _iteratorError;
  8480. }
  8481. }
  8482. }
  8483. var _iteratorNormalCompletion2 = true;
  8484. var _didIteratorError2 = false;
  8485. var _iteratorError2 = undefined;
  8486. try {
  8487. for (var _iterator2 = unknownOptionNames[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
  8488. var key = _step2.value;
  8489. var value = options[key];
  8490. var unknownResult = this._unknownHandler(key, value, this._utils);
  8491. if (unknownResult) {
  8492. var _arr3 = Object.keys(unknownResult);
  8493. for (var _i3 = 0; _i3 < _arr3.length; _i3++) {
  8494. var unknownKey = _arr3[_i3];
  8495. var unknownOption = _defineProperty({}, unknownKey, unknownResult[unknownKey]);
  8496. if (unknownKey in this._utils.schemas) {
  8497. transferredOptionsArray.push(unknownOption);
  8498. } else {
  8499. Object.assign(normalized, unknownOption);
  8500. }
  8501. }
  8502. }
  8503. }
  8504. } catch (err) {
  8505. _didIteratorError2 = true;
  8506. _iteratorError2 = err;
  8507. } finally {
  8508. try {
  8509. if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
  8510. _iterator2.return();
  8511. }
  8512. } finally {
  8513. if (_didIteratorError2) {
  8514. throw _iteratorError2;
  8515. }
  8516. }
  8517. }
  8518. return transferredOptionsArray;
  8519. }
  8520. }]);
  8521. return Normalizer;
  8522. }();
  8523. exports.Normalizer = Normalizer;
  8524. });
  8525. unwrapExports(normalize$1);
  8526. var lib$1 = createCommonjsModule(function (module, exports) {
  8527. "use strict";
  8528. Object.defineProperty(exports, "__esModule", {
  8529. value: true
  8530. });
  8531. tslib_1.__exportStar(descriptors, exports);
  8532. tslib_1.__exportStar(handlers, exports);
  8533. tslib_1.__exportStar(schemas, exports);
  8534. tslib_1.__exportStar(normalize$1, exports);
  8535. tslib_1.__exportStar(schema, exports);
  8536. });
  8537. unwrapExports(lib$1);
  8538. var hasFlag$3 = function hasFlag(flag, argv$$1) {
  8539. argv$$1 = argv$$1 || process.argv;
  8540. var terminatorPos = argv$$1.indexOf('--');
  8541. var prefix = /^-{1,2}/.test(flag) ? '' : '--';
  8542. var pos = argv$$1.indexOf(prefix + flag);
  8543. return pos !== -1 && (terminatorPos === -1 ? true : pos < terminatorPos);
  8544. };
  8545. var supportsColor$1 = createCommonjsModule(function (module) {
  8546. 'use strict';
  8547. var env$$1 = process.env;
  8548. var support = function support(level) {
  8549. if (level === 0) {
  8550. return false;
  8551. }
  8552. return {
  8553. level: level,
  8554. hasBasic: true,
  8555. has256: level >= 2,
  8556. has16m: level >= 3
  8557. };
  8558. };
  8559. var supportLevel = function () {
  8560. if (hasFlag$3('no-color') || hasFlag$3('no-colors') || hasFlag$3('color=false')) {
  8561. return 0;
  8562. }
  8563. if (hasFlag$3('color=16m') || hasFlag$3('color=full') || hasFlag$3('color=truecolor')) {
  8564. return 3;
  8565. }
  8566. if (hasFlag$3('color=256')) {
  8567. return 2;
  8568. }
  8569. if (hasFlag$3('color') || hasFlag$3('colors') || hasFlag$3('color=true') || hasFlag$3('color=always')) {
  8570. return 1;
  8571. }
  8572. if (process.stdout && !process.stdout.isTTY) {
  8573. return 0;
  8574. }
  8575. if (process.platform === 'win32') {
  8576. // Node.js 7.5.0 is the first version of Node.js to include a patch to
  8577. // libuv that enables 256 color output on Windows. Anything earlier and it
  8578. // won't work. However, here we target Node.js 8 at minimum as it is an LTS
  8579. // release, and Node.js 7 is not. Windows 10 build 10586 is the first Windows
  8580. // release that supports 256 colors.
  8581. var osRelease = require$$1$1.release().split('.');
  8582. if (Number(process.versions.node.split('.')[0]) >= 8 && Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
  8583. return 2;
  8584. }
  8585. return 1;
  8586. }
  8587. if ('CI' in env$$1) {
  8588. if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI'].some(function (sign) {
  8589. return sign in env$$1;
  8590. }) || env$$1.CI_NAME === 'codeship') {
  8591. return 1;
  8592. }
  8593. return 0;
  8594. }
  8595. if ('TEAMCITY_VERSION' in env$$1) {
  8596. return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env$$1.TEAMCITY_VERSION) ? 1 : 0;
  8597. }
  8598. if ('TERM_PROGRAM' in env$$1) {
  8599. var version = parseInt((env$$1.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
  8600. switch (env$$1.TERM_PROGRAM) {
  8601. case 'iTerm.app':
  8602. return version >= 3 ? 3 : 2;
  8603. case 'Hyper':
  8604. return 3;
  8605. case 'Apple_Terminal':
  8606. return 2;
  8607. // No default
  8608. }
  8609. }
  8610. if (/-256(color)?$/i.test(env$$1.TERM)) {
  8611. return 2;
  8612. }
  8613. if (/^screen|^xterm|^vt100|^rxvt|color|ansi|cygwin|linux/i.test(env$$1.TERM)) {
  8614. return 1;
  8615. }
  8616. if ('COLORTERM' in env$$1) {
  8617. return 1;
  8618. }
  8619. if (env$$1.TERM === 'dumb') {
  8620. return 0;
  8621. }
  8622. return 0;
  8623. }();
  8624. if ('FORCE_COLOR' in env$$1) {
  8625. supportLevel = parseInt(env$$1.FORCE_COLOR, 10) === 0 ? 0 : supportLevel || 1;
  8626. }
  8627. module.exports = process && support(supportLevel);
  8628. });
  8629. var templates$2 = createCommonjsModule(function (module) {
  8630. 'use strict';
  8631. var TEMPLATE_REGEX = /(?:\\(u[a-f0-9]{4}|x[a-f0-9]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi;
  8632. var STYLE_REGEX = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g;
  8633. var STRING_REGEX = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/;
  8634. var ESCAPE_REGEX = /\\(u[0-9a-f]{4}|x[0-9a-f]{2}|.)|([^\\])/gi;
  8635. var ESCAPES = {
  8636. n: '\n',
  8637. r: '\r',
  8638. t: '\t',
  8639. b: '\b',
  8640. f: '\f',
  8641. v: '\v',
  8642. 0: '\0',
  8643. '\\': '\\',
  8644. e: "\x1B",
  8645. a: "\x07"
  8646. };
  8647. function unescape(c) {
  8648. if (c[0] === 'u' && c.length === 5 || c[0] === 'x' && c.length === 3) {
  8649. return String.fromCharCode(parseInt(c.slice(1), 16));
  8650. }
  8651. return ESCAPES[c] || c;
  8652. }
  8653. function parseArguments(name, args) {
  8654. var results = [];
  8655. var chunks = args.trim().split(/\s*,\s*/g);
  8656. var matches;
  8657. var _iteratorNormalCompletion = true;
  8658. var _didIteratorError = false;
  8659. var _iteratorError = undefined;
  8660. try {
  8661. for (var _iterator = chunks[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  8662. var chunk = _step.value;
  8663. if (!isNaN(chunk)) {
  8664. results.push(Number(chunk));
  8665. } else if (matches = chunk.match(STRING_REGEX)) {
  8666. results.push(matches[2].replace(ESCAPE_REGEX, function (m, escape, chr) {
  8667. return escape ? unescape(escape) : chr;
  8668. }));
  8669. } else {
  8670. throw new Error("Invalid Chalk template style argument: ".concat(chunk, " (in style '").concat(name, "')"));
  8671. }
  8672. }
  8673. } catch (err) {
  8674. _didIteratorError = true;
  8675. _iteratorError = err;
  8676. } finally {
  8677. try {
  8678. if (!_iteratorNormalCompletion && _iterator.return != null) {
  8679. _iterator.return();
  8680. }
  8681. } finally {
  8682. if (_didIteratorError) {
  8683. throw _iteratorError;
  8684. }
  8685. }
  8686. }
  8687. return results;
  8688. }
  8689. function parseStyle(style) {
  8690. STYLE_REGEX.lastIndex = 0;
  8691. var results = [];
  8692. var matches;
  8693. while ((matches = STYLE_REGEX.exec(style)) !== null) {
  8694. var name = matches[1];
  8695. if (matches[2]) {
  8696. var args = parseArguments(name, matches[2]);
  8697. results.push([name].concat(args));
  8698. } else {
  8699. results.push([name]);
  8700. }
  8701. }
  8702. return results;
  8703. }
  8704. function buildStyle(chalk, styles) {
  8705. var enabled = {};
  8706. var _iteratorNormalCompletion2 = true;
  8707. var _didIteratorError2 = false;
  8708. var _iteratorError2 = undefined;
  8709. try {
  8710. for (var _iterator2 = styles[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
  8711. var layer = _step2.value;
  8712. var _iteratorNormalCompletion3 = true;
  8713. var _didIteratorError3 = false;
  8714. var _iteratorError3 = undefined;
  8715. try {
  8716. for (var _iterator3 = layer.styles[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
  8717. var style = _step3.value;
  8718. enabled[style[0]] = layer.inverse ? null : style.slice(1);
  8719. }
  8720. } catch (err) {
  8721. _didIteratorError3 = true;
  8722. _iteratorError3 = err;
  8723. } finally {
  8724. try {
  8725. if (!_iteratorNormalCompletion3 && _iterator3.return != null) {
  8726. _iterator3.return();
  8727. }
  8728. } finally {
  8729. if (_didIteratorError3) {
  8730. throw _iteratorError3;
  8731. }
  8732. }
  8733. }
  8734. }
  8735. } catch (err) {
  8736. _didIteratorError2 = true;
  8737. _iteratorError2 = err;
  8738. } finally {
  8739. try {
  8740. if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
  8741. _iterator2.return();
  8742. }
  8743. } finally {
  8744. if (_didIteratorError2) {
  8745. throw _iteratorError2;
  8746. }
  8747. }
  8748. }
  8749. var current = chalk;
  8750. var _arr = Object.keys(enabled);
  8751. for (var _i = 0; _i < _arr.length; _i++) {
  8752. var styleName = _arr[_i];
  8753. if (Array.isArray(enabled[styleName])) {
  8754. if (!(styleName in current)) {
  8755. throw new Error("Unknown Chalk style: ".concat(styleName));
  8756. }
  8757. if (enabled[styleName].length > 0) {
  8758. current = current[styleName].apply(current, enabled[styleName]);
  8759. } else {
  8760. current = current[styleName];
  8761. }
  8762. }
  8763. }
  8764. return current;
  8765. }
  8766. module.exports = function (chalk, tmp) {
  8767. var styles = [];
  8768. var chunks = [];
  8769. var chunk = []; // eslint-disable-next-line max-params
  8770. tmp.replace(TEMPLATE_REGEX, function (m, escapeChar, inverse, style, close, chr) {
  8771. if (escapeChar) {
  8772. chunk.push(unescape(escapeChar));
  8773. } else if (style) {
  8774. var str = chunk.join('');
  8775. chunk = [];
  8776. chunks.push(styles.length === 0 ? str : buildStyle(chalk, styles)(str));
  8777. styles.push({
  8778. inverse: inverse,
  8779. styles: parseStyle(style)
  8780. });
  8781. } else if (close) {
  8782. if (styles.length === 0) {
  8783. throw new Error('Found extraneous } in Chalk template literal');
  8784. }
  8785. chunks.push(buildStyle(chalk, styles)(chunk.join('')));
  8786. chunk = [];
  8787. styles.pop();
  8788. } else {
  8789. chunk.push(chr);
  8790. }
  8791. });
  8792. chunks.push(chunk.join(''));
  8793. if (styles.length > 0) {
  8794. var errMsg = "Chalk template literal is missing ".concat(styles.length, " closing bracket").concat(styles.length === 1 ? '' : 's', " (`}`)");
  8795. throw new Error(errMsg);
  8796. }
  8797. return chunks.join('');
  8798. };
  8799. });
  8800. var isSimpleWindowsTerm = process.platform === 'win32' && !(process.env.TERM || '').toLowerCase().startsWith('xterm'); // `supportsColor.level` → `ansiStyles.color[name]` mapping
  8801. var levelMapping = ['ansi', 'ansi', 'ansi256', 'ansi16m']; // `color-convert` models to exclude from the Chalk API due to conflicts and such
  8802. var skipModels = new Set(['gray']);
  8803. var styles = Object.create(null);
  8804. function applyOptions(obj, options) {
  8805. options = options || {}; // Detect level if not set manually
  8806. var scLevel = supportsColor$1 ? supportsColor$1.level : 0;
  8807. obj.level = options.level === undefined ? scLevel : options.level;
  8808. obj.enabled = 'enabled' in options ? options.enabled : obj.level > 0;
  8809. }
  8810. function Chalk(options) {
  8811. // We check for this.template here since calling `chalk.constructor()`
  8812. // by itself will have a `this` of a previously constructed chalk object
  8813. if (!this || !(this instanceof Chalk) || this.template) {
  8814. var _chalk = {};
  8815. applyOptions(_chalk, options);
  8816. _chalk.template = function () {
  8817. var args = [].slice.call(arguments);
  8818. return chalkTag.apply(null, [_chalk.template].concat(args));
  8819. };
  8820. Object.setPrototypeOf(_chalk, Chalk.prototype);
  8821. Object.setPrototypeOf(_chalk.template, _chalk);
  8822. _chalk.template.constructor = Chalk;
  8823. return _chalk.template;
  8824. }
  8825. applyOptions(this, options);
  8826. } // Use bright blue on Windows as the normal blue color is illegible
  8827. if (isSimpleWindowsTerm) {
  8828. ansiStyles.blue.open = "\x1B[94m";
  8829. }
  8830. var _arr = Object.keys(ansiStyles);
  8831. var _loop = function _loop() {
  8832. var key = _arr[_i];
  8833. ansiStyles[key].closeRe = new RegExp(escapeStringRegexp(ansiStyles[key].close), 'g');
  8834. styles[key] = {
  8835. get: function get() {
  8836. var codes = ansiStyles[key];
  8837. return build.call(this, this._styles ? this._styles.concat(codes) : [codes], key);
  8838. }
  8839. };
  8840. };
  8841. for (var _i = 0; _i < _arr.length; _i++) {
  8842. _loop();
  8843. }
  8844. ansiStyles.color.closeRe = new RegExp(escapeStringRegexp(ansiStyles.color.close), 'g');
  8845. var _arr2 = Object.keys(ansiStyles.color.ansi);
  8846. var _loop2 = function _loop2() {
  8847. var model = _arr2[_i2];
  8848. if (skipModels.has(model)) {
  8849. return "continue";
  8850. }
  8851. styles[model] = {
  8852. get: function get() {
  8853. var level = this.level;
  8854. return function () {
  8855. var open = ansiStyles.color[levelMapping[level]][model].apply(null, arguments);
  8856. var codes = {
  8857. open: open,
  8858. close: ansiStyles.color.close,
  8859. closeRe: ansiStyles.color.closeRe
  8860. };
  8861. return build.call(this, this._styles ? this._styles.concat(codes) : [codes], model);
  8862. };
  8863. }
  8864. };
  8865. };
  8866. for (var _i2 = 0; _i2 < _arr2.length; _i2++) {
  8867. var _ret = _loop2();
  8868. if (_ret === "continue") continue;
  8869. }
  8870. ansiStyles.bgColor.closeRe = new RegExp(escapeStringRegexp(ansiStyles.bgColor.close), 'g');
  8871. var _arr3 = Object.keys(ansiStyles.bgColor.ansi);
  8872. var _loop3 = function _loop3() {
  8873. var model = _arr3[_i3];
  8874. if (skipModels.has(model)) {
  8875. return "continue";
  8876. }
  8877. var bgModel = 'bg' + model[0].toUpperCase() + model.slice(1);
  8878. styles[bgModel] = {
  8879. get: function get() {
  8880. var level = this.level;
  8881. return function () {
  8882. var open = ansiStyles.bgColor[levelMapping[level]][model].apply(null, arguments);
  8883. var codes = {
  8884. open: open,
  8885. close: ansiStyles.bgColor.close,
  8886. closeRe: ansiStyles.bgColor.closeRe
  8887. };
  8888. return build.call(this, this._styles ? this._styles.concat(codes) : [codes], model);
  8889. };
  8890. }
  8891. };
  8892. };
  8893. for (var _i3 = 0; _i3 < _arr3.length; _i3++) {
  8894. var _ret2 = _loop3();
  8895. if (_ret2 === "continue") continue;
  8896. }
  8897. var proto = Object.defineProperties(function () {}, styles);
  8898. function build(_styles, key) {
  8899. var builder = function builder() {
  8900. return applyStyle.apply(builder, arguments);
  8901. };
  8902. builder._styles = _styles;
  8903. var self = this;
  8904. Object.defineProperty(builder, 'level', {
  8905. enumerable: true,
  8906. get: function get() {
  8907. return self.level;
  8908. },
  8909. set: function set(level) {
  8910. self.level = level;
  8911. }
  8912. });
  8913. Object.defineProperty(builder, 'enabled', {
  8914. enumerable: true,
  8915. get: function get() {
  8916. return self.enabled;
  8917. },
  8918. set: function set(enabled) {
  8919. self.enabled = enabled;
  8920. }
  8921. }); // See below for fix regarding invisible grey/dim combination on Windows
  8922. builder.hasGrey = this.hasGrey || key === 'gray' || key === 'grey'; // `__proto__` is used because we must return a function, but there is
  8923. // no way to create a function with a different prototype
  8924. builder.__proto__ = proto; // eslint-disable-line no-proto
  8925. return builder;
  8926. }
  8927. function applyStyle() {
  8928. // Support varags, but simply cast to string in case there's only one arg
  8929. var args = arguments;
  8930. var argsLen = args.length;
  8931. var str = String(arguments[0]);
  8932. if (argsLen === 0) {
  8933. return '';
  8934. }
  8935. if (argsLen > 1) {
  8936. // Don't slice `arguments`, it prevents V8 optimizations
  8937. for (var a = 1; a < argsLen; a++) {
  8938. str += ' ' + args[a];
  8939. }
  8940. }
  8941. if (!this.enabled || this.level <= 0 || !str) {
  8942. return str;
  8943. } // Turns out that on Windows dimmed gray text becomes invisible in cmd.exe,
  8944. // see https://github.com/chalk/chalk/issues/58
  8945. // If we're on Windows and we're dealing with a gray color, temporarily make 'dim' a noop.
  8946. var originalDim = ansiStyles.dim.open;
  8947. if (isSimpleWindowsTerm && this.hasGrey) {
  8948. ansiStyles.dim.open = '';
  8949. }
  8950. var _iteratorNormalCompletion = true;
  8951. var _didIteratorError = false;
  8952. var _iteratorError = undefined;
  8953. try {
  8954. for (var _iterator = this._styles.slice().reverse()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  8955. var code = _step.value;
  8956. // Replace any instances already present with a re-opening code
  8957. // otherwise only the part of the string until said closing code
  8958. // will be colored, and the rest will simply be 'plain'.
  8959. str = code.open + str.replace(code.closeRe, code.open) + code.close; // Close the styling before a linebreak and reopen
  8960. // after next line to fix a bleed issue on macOS
  8961. // https://github.com/chalk/chalk/pull/92
  8962. str = str.replace(/\r?\n/g, "".concat(code.close, "$&").concat(code.open));
  8963. } // Reset the original `dim` if we changed it to work around the Windows dimmed gray issue
  8964. } catch (err) {
  8965. _didIteratorError = true;
  8966. _iteratorError = err;
  8967. } finally {
  8968. try {
  8969. if (!_iteratorNormalCompletion && _iterator.return != null) {
  8970. _iterator.return();
  8971. }
  8972. } finally {
  8973. if (_didIteratorError) {
  8974. throw _iteratorError;
  8975. }
  8976. }
  8977. }
  8978. ansiStyles.dim.open = originalDim;
  8979. return str;
  8980. }
  8981. function chalkTag(chalk, strings) {
  8982. if (!Array.isArray(strings)) {
  8983. // If chalk() was called by itself or with a string,
  8984. // return the string itself as a string.
  8985. return [].slice.call(arguments, 1).join(' ');
  8986. }
  8987. var args = [].slice.call(arguments, 2);
  8988. var parts = [strings.raw[0]];
  8989. for (var i = 1; i < strings.length; i++) {
  8990. parts.push(String(args[i - 1]).replace(/[{}\\]/g, '\\$&'));
  8991. parts.push(String(strings.raw[i]));
  8992. }
  8993. return templates$2(chalk, parts.join(''));
  8994. }
  8995. Object.defineProperties(Chalk.prototype, styles);
  8996. var chalk$2 = Chalk(); // eslint-disable-line new-cap
  8997. var supportsColor_1$2 = supportsColor$1;
  8998. chalk$2.supportsColor = supportsColor_1$2;
  8999. var cliDescriptor = {
  9000. key: function key(_key) {
  9001. return _key.length === 1 ? "-".concat(_key) : "--".concat(_key);
  9002. },
  9003. value: function value(_value) {
  9004. return lib$1.apiDescriptor.value(_value);
  9005. },
  9006. pair: function pair(_ref) {
  9007. var key = _ref.key,
  9008. value = _ref.value;
  9009. return value === false ? "--no-".concat(key) : value === true ? cliDescriptor.key(key) : value === "" ? "".concat(cliDescriptor.key(key), " without an argument") : "".concat(cliDescriptor.key(key), "=").concat(value);
  9010. }
  9011. };
  9012. var FlagSchema =
  9013. /*#__PURE__*/
  9014. function (_vnopts$ChoiceSchema) {
  9015. _inherits(FlagSchema, _vnopts$ChoiceSchema);
  9016. function FlagSchema(_ref2) {
  9017. var _this;
  9018. var name = _ref2.name,
  9019. flags = _ref2.flags;
  9020. _classCallCheck(this, FlagSchema);
  9021. _this = _possibleConstructorReturn(this, _getPrototypeOf(FlagSchema).call(this, {
  9022. name: name,
  9023. choices: flags
  9024. }));
  9025. _this._flags = flags.slice().sort();
  9026. return _this;
  9027. }
  9028. _createClass(FlagSchema, [{
  9029. key: "preprocess",
  9030. value: function preprocess(value, utils) {
  9031. if (typeof value === "string" && value.length !== 0 && this._flags.indexOf(value) === -1) {
  9032. var suggestion = this._flags.find(function (flag) {
  9033. return leven$1(flag, value) < 3;
  9034. });
  9035. if (suggestion) {
  9036. utils.logger.warn(["Unknown flag ".concat(chalk$2.yellow(utils.descriptor.value(value)), ","), "did you mean ".concat(chalk$2.blue(utils.descriptor.value(suggestion)), "?")].join(" "));
  9037. return suggestion;
  9038. }
  9039. }
  9040. return value;
  9041. }
  9042. }, {
  9043. key: "expected",
  9044. value: function expected() {
  9045. return "a flag";
  9046. }
  9047. }]);
  9048. return FlagSchema;
  9049. }(lib$1.ChoiceSchema);
  9050. var hasDeprecationWarned;
  9051. function normalizeOptions$1(options, optionInfos) {
  9052. var _ref3 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
  9053. logger = _ref3.logger,
  9054. _ref3$isCLI = _ref3.isCLI,
  9055. isCLI = _ref3$isCLI === void 0 ? false : _ref3$isCLI,
  9056. _ref3$passThrough = _ref3.passThrough,
  9057. passThrough = _ref3$passThrough === void 0 ? false : _ref3$passThrough;
  9058. var unknown = !passThrough ? lib$1.levenUnknownHandler : Array.isArray(passThrough) ? function (key, value) {
  9059. return passThrough.indexOf(key) === -1 ? undefined : _defineProperty({}, key, value);
  9060. } : function (key, value) {
  9061. return _defineProperty({}, key, value);
  9062. };
  9063. var descriptor = isCLI ? cliDescriptor : lib$1.apiDescriptor;
  9064. var schemas = optionInfosToSchemas(optionInfos, {
  9065. isCLI: isCLI
  9066. });
  9067. var normalizer = new lib$1.Normalizer(schemas, {
  9068. logger: logger,
  9069. unknown: unknown,
  9070. descriptor: descriptor
  9071. });
  9072. var shouldSuppressDuplicateDeprecationWarnings = logger !== false;
  9073. if (shouldSuppressDuplicateDeprecationWarnings && hasDeprecationWarned) {
  9074. normalizer._hasDeprecationWarned = hasDeprecationWarned;
  9075. }
  9076. var normalized = normalizer.normalize(options);
  9077. if (shouldSuppressDuplicateDeprecationWarnings) {
  9078. hasDeprecationWarned = normalizer._hasDeprecationWarned;
  9079. }
  9080. return normalized;
  9081. }
  9082. function optionInfosToSchemas(optionInfos, _ref6) {
  9083. var isCLI = _ref6.isCLI;
  9084. var schemas = [];
  9085. if (isCLI) {
  9086. schemas.push(lib$1.AnySchema.create({
  9087. name: "_"
  9088. }));
  9089. }
  9090. var _iteratorNormalCompletion = true;
  9091. var _didIteratorError = false;
  9092. var _iteratorError = undefined;
  9093. try {
  9094. for (var _iterator = optionInfos[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  9095. var optionInfo = _step.value;
  9096. schemas.push(optionInfoToSchema(optionInfo, {
  9097. isCLI: isCLI,
  9098. optionInfos: optionInfos
  9099. }));
  9100. if (optionInfo.alias && isCLI) {
  9101. schemas.push(lib$1.AliasSchema.create({
  9102. name: optionInfo.alias,
  9103. sourceName: optionInfo.name
  9104. }));
  9105. }
  9106. }
  9107. } catch (err) {
  9108. _didIteratorError = true;
  9109. _iteratorError = err;
  9110. } finally {
  9111. try {
  9112. if (!_iteratorNormalCompletion && _iterator.return != null) {
  9113. _iterator.return();
  9114. }
  9115. } finally {
  9116. if (_didIteratorError) {
  9117. throw _iteratorError;
  9118. }
  9119. }
  9120. }
  9121. return schemas;
  9122. }
  9123. function optionInfoToSchema(optionInfo, _ref7) {
  9124. var isCLI = _ref7.isCLI,
  9125. optionInfos = _ref7.optionInfos;
  9126. var SchemaConstructor;
  9127. var parameters = {
  9128. name: optionInfo.name
  9129. };
  9130. var handlers = {};
  9131. switch (optionInfo.type) {
  9132. case "int":
  9133. SchemaConstructor = lib$1.IntegerSchema;
  9134. if (isCLI) {
  9135. parameters.preprocess = function (value) {
  9136. return Number(value);
  9137. };
  9138. }
  9139. break;
  9140. case "choice":
  9141. SchemaConstructor = lib$1.ChoiceSchema;
  9142. parameters.choices = optionInfo.choices.map(function (choiceInfo) {
  9143. return _typeof(choiceInfo) === "object" && choiceInfo.redirect ? Object.assign({}, choiceInfo, {
  9144. redirect: {
  9145. to: {
  9146. key: optionInfo.name,
  9147. value: choiceInfo.redirect
  9148. }
  9149. }
  9150. }) : choiceInfo;
  9151. });
  9152. break;
  9153. case "boolean":
  9154. SchemaConstructor = lib$1.BooleanSchema;
  9155. break;
  9156. case "flag":
  9157. SchemaConstructor = FlagSchema;
  9158. parameters.flags = optionInfos.map(function (optionInfo) {
  9159. return [].concat(optionInfo.alias || [], optionInfo.description ? optionInfo.name : [], optionInfo.oppositeDescription ? "no-".concat(optionInfo.name) : []);
  9160. }).reduce(function (a, b) {
  9161. return a.concat(b);
  9162. }, []);
  9163. break;
  9164. case "path":
  9165. SchemaConstructor = lib$1.StringSchema;
  9166. break;
  9167. default:
  9168. throw new Error("Unexpected type ".concat(optionInfo.type));
  9169. }
  9170. if (optionInfo.exception) {
  9171. parameters.validate = function (value, schema, utils) {
  9172. return optionInfo.exception(value) || schema.validate(value, utils);
  9173. };
  9174. } else {
  9175. parameters.validate = function (value, schema, utils) {
  9176. return value === undefined || schema.validate(value, utils);
  9177. };
  9178. }
  9179. if (optionInfo.redirect) {
  9180. handlers.redirect = function (value) {
  9181. return !value ? undefined : {
  9182. to: {
  9183. key: optionInfo.redirect.option,
  9184. value: optionInfo.redirect.value
  9185. }
  9186. };
  9187. };
  9188. }
  9189. if (optionInfo.deprecated) {
  9190. handlers.deprecated = true;
  9191. } // allow CLI overriding, e.g., prettier package.json --tab-width 1 --tab-width 2
  9192. if (isCLI && !optionInfo.array) {
  9193. var originalPreprocess = parameters.preprocess || function (x) {
  9194. return x;
  9195. };
  9196. parameters.preprocess = function (value, schema, utils) {
  9197. return schema.preprocess(originalPreprocess(Array.isArray(value) ? value[value.length - 1] : value), utils);
  9198. };
  9199. }
  9200. return optionInfo.array ? lib$1.ArraySchema.create(Object.assign(isCLI ? {
  9201. preprocess: function preprocess(v) {
  9202. return [].concat(v);
  9203. }
  9204. } : {}, handlers, {
  9205. valueSchema: SchemaConstructor.create(parameters)
  9206. })) : SchemaConstructor.create(Object.assign({}, parameters, handlers));
  9207. }
  9208. function normalizeApiOptions(options, optionInfos, opts) {
  9209. return normalizeOptions$1(options, optionInfos, opts);
  9210. }
  9211. function normalizeCliOptions(options, optionInfos, opts) {
  9212. return normalizeOptions$1(options, optionInfos, Object.assign({
  9213. isCLI: true
  9214. }, opts));
  9215. }
  9216. var optionsNormalizer = {
  9217. normalizeApiOptions: normalizeApiOptions,
  9218. normalizeCliOptions: normalizeCliOptions
  9219. };
  9220. var getLast = function getLast(arr) {
  9221. return arr.length > 0 ? arr[arr.length - 1] : null;
  9222. };
  9223. function locStart$1(node, opts) {
  9224. opts = opts || {}; // Handle nodes with decorators. They should start at the first decorator
  9225. if (!opts.ignoreDecorators && node.declaration && node.declaration.decorators && node.declaration.decorators.length > 0) {
  9226. return locStart$1(node.declaration.decorators[0]);
  9227. }
  9228. if (!opts.ignoreDecorators && node.decorators && node.decorators.length > 0) {
  9229. return locStart$1(node.decorators[0]);
  9230. }
  9231. if (node.__location) {
  9232. return node.__location.startOffset;
  9233. }
  9234. if (node.range) {
  9235. return node.range[0];
  9236. }
  9237. if (typeof node.start === "number") {
  9238. return node.start;
  9239. }
  9240. if (node.loc) {
  9241. return node.loc.start;
  9242. }
  9243. return null;
  9244. }
  9245. function locEnd$1(node) {
  9246. var endNode = node.nodes && getLast(node.nodes);
  9247. if (endNode && node.source && !node.source.end) {
  9248. node = endNode;
  9249. }
  9250. if (node.__location) {
  9251. return node.__location.endOffset;
  9252. }
  9253. var loc = node.range ? node.range[1] : typeof node.end === "number" ? node.end : null;
  9254. if (node.typeAnnotation) {
  9255. return Math.max(loc, locEnd$1(node.typeAnnotation));
  9256. }
  9257. if (node.loc && !loc) {
  9258. return node.loc.end;
  9259. }
  9260. return loc;
  9261. }
  9262. var loc = {
  9263. locStart: locStart$1,
  9264. locEnd: locEnd$1
  9265. };
  9266. var jsTokens = createCommonjsModule(function (module, exports) {
  9267. // Copyright 2014, 2015, 2016, 2017 Simon Lydell
  9268. // License: MIT. (See LICENSE.)
  9269. Object.defineProperty(exports, "__esModule", {
  9270. value: true
  9271. }); // This regex comes from regex.coffee, and is inserted here by generate-index.js
  9272. // (run `npm run build`).
  9273. 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;
  9274. exports.matchToToken = function (match) {
  9275. var token = {
  9276. type: "invalid",
  9277. value: match[0]
  9278. };
  9279. 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";
  9280. return token;
  9281. };
  9282. });
  9283. unwrapExports(jsTokens);
  9284. var ast = createCommonjsModule(function (module) {
  9285. /*
  9286. Copyright (C) 2013 Yusuke Suzuki <utatane.tea@gmail.com>
  9287. Redistribution and use in source and binary forms, with or without
  9288. modification, are permitted provided that the following conditions are met:
  9289. * Redistributions of source code must retain the above copyright
  9290. notice, this list of conditions and the following disclaimer.
  9291. * Redistributions in binary form must reproduce the above copyright
  9292. notice, this list of conditions and the following disclaimer in the
  9293. documentation and/or other materials provided with the distribution.
  9294. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS'
  9295. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  9296. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  9297. ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
  9298. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  9299. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  9300. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  9301. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  9302. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  9303. THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  9304. */
  9305. (function () {
  9306. 'use strict';
  9307. function isExpression(node) {
  9308. if (node == null) {
  9309. return false;
  9310. }
  9311. switch (node.type) {
  9312. case 'ArrayExpression':
  9313. case 'AssignmentExpression':
  9314. case 'BinaryExpression':
  9315. case 'CallExpression':
  9316. case 'ConditionalExpression':
  9317. case 'FunctionExpression':
  9318. case 'Identifier':
  9319. case 'Literal':
  9320. case 'LogicalExpression':
  9321. case 'MemberExpression':
  9322. case 'NewExpression':
  9323. case 'ObjectExpression':
  9324. case 'SequenceExpression':
  9325. case 'ThisExpression':
  9326. case 'UnaryExpression':
  9327. case 'UpdateExpression':
  9328. return true;
  9329. }
  9330. return false;
  9331. }
  9332. function isIterationStatement(node) {
  9333. if (node == null) {
  9334. return false;
  9335. }
  9336. switch (node.type) {
  9337. case 'DoWhileStatement':
  9338. case 'ForInStatement':
  9339. case 'ForStatement':
  9340. case 'WhileStatement':
  9341. return true;
  9342. }
  9343. return false;
  9344. }
  9345. function isStatement(node) {
  9346. if (node == null) {
  9347. return false;
  9348. }
  9349. switch (node.type) {
  9350. case 'BlockStatement':
  9351. case 'BreakStatement':
  9352. case 'ContinueStatement':
  9353. case 'DebuggerStatement':
  9354. case 'DoWhileStatement':
  9355. case 'EmptyStatement':
  9356. case 'ExpressionStatement':
  9357. case 'ForInStatement':
  9358. case 'ForStatement':
  9359. case 'IfStatement':
  9360. case 'LabeledStatement':
  9361. case 'ReturnStatement':
  9362. case 'SwitchStatement':
  9363. case 'ThrowStatement':
  9364. case 'TryStatement':
  9365. case 'VariableDeclaration':
  9366. case 'WhileStatement':
  9367. case 'WithStatement':
  9368. return true;
  9369. }
  9370. return false;
  9371. }
  9372. function isSourceElement(node) {
  9373. return isStatement(node) || node != null && node.type === 'FunctionDeclaration';
  9374. }
  9375. function trailingStatement(node) {
  9376. switch (node.type) {
  9377. case 'IfStatement':
  9378. if (node.alternate != null) {
  9379. return node.alternate;
  9380. }
  9381. return node.consequent;
  9382. case 'LabeledStatement':
  9383. case 'ForStatement':
  9384. case 'ForInStatement':
  9385. case 'WhileStatement':
  9386. case 'WithStatement':
  9387. return node.body;
  9388. }
  9389. return null;
  9390. }
  9391. function isProblematicIfStatement(node) {
  9392. var current;
  9393. if (node.type !== 'IfStatement') {
  9394. return false;
  9395. }
  9396. if (node.alternate == null) {
  9397. return false;
  9398. }
  9399. current = node.consequent;
  9400. do {
  9401. if (current.type === 'IfStatement') {
  9402. if (current.alternate == null) {
  9403. return true;
  9404. }
  9405. }
  9406. current = trailingStatement(current);
  9407. } while (current);
  9408. return false;
  9409. }
  9410. module.exports = {
  9411. isExpression: isExpression,
  9412. isStatement: isStatement,
  9413. isIterationStatement: isIterationStatement,
  9414. isSourceElement: isSourceElement,
  9415. isProblematicIfStatement: isProblematicIfStatement,
  9416. trailingStatement: trailingStatement
  9417. };
  9418. })();
  9419. /* vim: set sw=4 ts=4 et tw=80 : */
  9420. });
  9421. var code = createCommonjsModule(function (module) {
  9422. /*
  9423. Copyright (C) 2013-2014 Yusuke Suzuki <utatane.tea@gmail.com>
  9424. Copyright (C) 2014 Ivan Nikulin <ifaaan@gmail.com>
  9425. Redistribution and use in source and binary forms, with or without
  9426. modification, are permitted provided that the following conditions are met:
  9427. * Redistributions of source code must retain the above copyright
  9428. notice, this list of conditions and the following disclaimer.
  9429. * Redistributions in binary form must reproduce the above copyright
  9430. notice, this list of conditions and the following disclaimer in the
  9431. documentation and/or other materials provided with the distribution.
  9432. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  9433. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  9434. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  9435. ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
  9436. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  9437. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  9438. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  9439. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  9440. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  9441. THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  9442. */
  9443. (function () {
  9444. 'use strict';
  9445. var ES6Regex, ES5Regex, NON_ASCII_WHITESPACES, IDENTIFIER_START, IDENTIFIER_PART, ch; // See `tools/generate-identifier-regex.js`.
  9446. ES5Regex = {
  9447. // ECMAScript 5.1/Unicode v7.0.0 NonAsciiIdentifierStart:
  9448. 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]/,
  9449. // ECMAScript 5.1/Unicode v7.0.0 NonAsciiIdentifierPart:
  9450. 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]/
  9451. };
  9452. ES6Regex = {
  9453. // ECMAScript 6/Unicode v7.0.0 NonAsciiIdentifierStart:
  9454. 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]/,
  9455. // ECMAScript 6/Unicode v7.0.0 NonAsciiIdentifierPart:
  9456. 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]/
  9457. };
  9458. function isDecimalDigit(ch) {
  9459. return 0x30 <= ch && ch <= 0x39; // 0..9
  9460. }
  9461. function isHexDigit(ch) {
  9462. return 0x30 <= ch && ch <= 0x39 || // 0..9
  9463. 0x61 <= ch && ch <= 0x66 || // a..f
  9464. 0x41 <= ch && ch <= 0x46; // A..F
  9465. }
  9466. function isOctalDigit(ch) {
  9467. return ch >= 0x30 && ch <= 0x37; // 0..7
  9468. } // 7.2 White Space
  9469. NON_ASCII_WHITESPACES = [0x1680, 0x180E, 0x2000, 0x2001, 0x2002, 0x2003, 0x2004, 0x2005, 0x2006, 0x2007, 0x2008, 0x2009, 0x200A, 0x202F, 0x205F, 0x3000, 0xFEFF];
  9470. function isWhiteSpace(ch) {
  9471. return ch === 0x20 || ch === 0x09 || ch === 0x0B || ch === 0x0C || ch === 0xA0 || ch >= 0x1680 && NON_ASCII_WHITESPACES.indexOf(ch) >= 0;
  9472. } // 7.3 Line Terminators
  9473. function isLineTerminator(ch) {
  9474. return ch === 0x0A || ch === 0x0D || ch === 0x2028 || ch === 0x2029;
  9475. } // 7.6 Identifier Names and Identifiers
  9476. function fromCodePoint(cp) {
  9477. if (cp <= 0xFFFF) {
  9478. return String.fromCharCode(cp);
  9479. }
  9480. var cu1 = String.fromCharCode(Math.floor((cp - 0x10000) / 0x400) + 0xD800);
  9481. var cu2 = String.fromCharCode((cp - 0x10000) % 0x400 + 0xDC00);
  9482. return cu1 + cu2;
  9483. }
  9484. IDENTIFIER_START = new Array(0x80);
  9485. for (ch = 0; ch < 0x80; ++ch) {
  9486. IDENTIFIER_START[ch] = ch >= 0x61 && ch <= 0x7A || // a..z
  9487. ch >= 0x41 && ch <= 0x5A || // A..Z
  9488. ch === 0x24 || ch === 0x5F; // $ (dollar) and _ (underscore)
  9489. }
  9490. IDENTIFIER_PART = new Array(0x80);
  9491. for (ch = 0; ch < 0x80; ++ch) {
  9492. IDENTIFIER_PART[ch] = ch >= 0x61 && ch <= 0x7A || // a..z
  9493. ch >= 0x41 && ch <= 0x5A || // A..Z
  9494. ch >= 0x30 && ch <= 0x39 || // 0..9
  9495. ch === 0x24 || ch === 0x5F; // $ (dollar) and _ (underscore)
  9496. }
  9497. function isIdentifierStartES5(ch) {
  9498. return ch < 0x80 ? IDENTIFIER_START[ch] : ES5Regex.NonAsciiIdentifierStart.test(fromCodePoint(ch));
  9499. }
  9500. function isIdentifierPartES5(ch) {
  9501. return ch < 0x80 ? IDENTIFIER_PART[ch] : ES5Regex.NonAsciiIdentifierPart.test(fromCodePoint(ch));
  9502. }
  9503. function isIdentifierStartES6(ch) {
  9504. return ch < 0x80 ? IDENTIFIER_START[ch] : ES6Regex.NonAsciiIdentifierStart.test(fromCodePoint(ch));
  9505. }
  9506. function isIdentifierPartES6(ch) {
  9507. return ch < 0x80 ? IDENTIFIER_PART[ch] : ES6Regex.NonAsciiIdentifierPart.test(fromCodePoint(ch));
  9508. }
  9509. module.exports = {
  9510. isDecimalDigit: isDecimalDigit,
  9511. isHexDigit: isHexDigit,
  9512. isOctalDigit: isOctalDigit,
  9513. isWhiteSpace: isWhiteSpace,
  9514. isLineTerminator: isLineTerminator,
  9515. isIdentifierStartES5: isIdentifierStartES5,
  9516. isIdentifierPartES5: isIdentifierPartES5,
  9517. isIdentifierStartES6: isIdentifierStartES6,
  9518. isIdentifierPartES6: isIdentifierPartES6
  9519. };
  9520. })();
  9521. /* vim: set sw=4 ts=4 et tw=80 : */
  9522. });
  9523. var keyword = createCommonjsModule(function (module) {
  9524. /*
  9525. Copyright (C) 2013 Yusuke Suzuki <utatane.tea@gmail.com>
  9526. Redistribution and use in source and binary forms, with or without
  9527. modification, are permitted provided that the following conditions are met:
  9528. * Redistributions of source code must retain the above copyright
  9529. notice, this list of conditions and the following disclaimer.
  9530. * Redistributions in binary form must reproduce the above copyright
  9531. notice, this list of conditions and the following disclaimer in the
  9532. documentation and/or other materials provided with the distribution.
  9533. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  9534. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  9535. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  9536. ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
  9537. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  9538. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  9539. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  9540. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  9541. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  9542. THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  9543. */
  9544. (function () {
  9545. 'use strict';
  9546. var code$$1 = code;
  9547. function isStrictModeReservedWordES6(id) {
  9548. switch (id) {
  9549. case 'implements':
  9550. case 'interface':
  9551. case 'package':
  9552. case 'private':
  9553. case 'protected':
  9554. case 'public':
  9555. case 'static':
  9556. case 'let':
  9557. return true;
  9558. default:
  9559. return false;
  9560. }
  9561. }
  9562. function isKeywordES5(id, strict) {
  9563. // yield should not be treated as keyword under non-strict mode.
  9564. if (!strict && id === 'yield') {
  9565. return false;
  9566. }
  9567. return isKeywordES6(id, strict);
  9568. }
  9569. function isKeywordES6(id, strict) {
  9570. if (strict && isStrictModeReservedWordES6(id)) {
  9571. return true;
  9572. }
  9573. switch (id.length) {
  9574. case 2:
  9575. return id === 'if' || id === 'in' || id === 'do';
  9576. case 3:
  9577. return id === 'var' || id === 'for' || id === 'new' || id === 'try';
  9578. case 4:
  9579. return id === 'this' || id === 'else' || id === 'case' || id === 'void' || id === 'with' || id === 'enum';
  9580. case 5:
  9581. return id === 'while' || id === 'break' || id === 'catch' || id === 'throw' || id === 'const' || id === 'yield' || id === 'class' || id === 'super';
  9582. case 6:
  9583. return id === 'return' || id === 'typeof' || id === 'delete' || id === 'switch' || id === 'export' || id === 'import';
  9584. case 7:
  9585. return id === 'default' || id === 'finally' || id === 'extends';
  9586. case 8:
  9587. return id === 'function' || id === 'continue' || id === 'debugger';
  9588. case 10:
  9589. return id === 'instanceof';
  9590. default:
  9591. return false;
  9592. }
  9593. }
  9594. function isReservedWordES5(id, strict) {
  9595. return id === 'null' || id === 'true' || id === 'false' || isKeywordES5(id, strict);
  9596. }
  9597. function isReservedWordES6(id, strict) {
  9598. return id === 'null' || id === 'true' || id === 'false' || isKeywordES6(id, strict);
  9599. }
  9600. function isRestrictedWord(id) {
  9601. return id === 'eval' || id === 'arguments';
  9602. }
  9603. function isIdentifierNameES5(id) {
  9604. var i, iz, ch;
  9605. if (id.length === 0) {
  9606. return false;
  9607. }
  9608. ch = id.charCodeAt(0);
  9609. if (!code$$1.isIdentifierStartES5(ch)) {
  9610. return false;
  9611. }
  9612. for (i = 1, iz = id.length; i < iz; ++i) {
  9613. ch = id.charCodeAt(i);
  9614. if (!code$$1.isIdentifierPartES5(ch)) {
  9615. return false;
  9616. }
  9617. }
  9618. return true;
  9619. }
  9620. function decodeUtf16(lead, trail) {
  9621. return (lead - 0xD800) * 0x400 + (trail - 0xDC00) + 0x10000;
  9622. }
  9623. function isIdentifierNameES6(id) {
  9624. var i, iz, ch, lowCh, check;
  9625. if (id.length === 0) {
  9626. return false;
  9627. }
  9628. check = code$$1.isIdentifierStartES6;
  9629. for (i = 0, iz = id.length; i < iz; ++i) {
  9630. ch = id.charCodeAt(i);
  9631. if (0xD800 <= ch && ch <= 0xDBFF) {
  9632. ++i;
  9633. if (i >= iz) {
  9634. return false;
  9635. }
  9636. lowCh = id.charCodeAt(i);
  9637. if (!(0xDC00 <= lowCh && lowCh <= 0xDFFF)) {
  9638. return false;
  9639. }
  9640. ch = decodeUtf16(ch, lowCh);
  9641. }
  9642. if (!check(ch)) {
  9643. return false;
  9644. }
  9645. check = code$$1.isIdentifierPartES6;
  9646. }
  9647. return true;
  9648. }
  9649. function isIdentifierES5(id, strict) {
  9650. return isIdentifierNameES5(id) && !isReservedWordES5(id, strict);
  9651. }
  9652. function isIdentifierES6(id, strict) {
  9653. return isIdentifierNameES6(id) && !isReservedWordES6(id, strict);
  9654. }
  9655. module.exports = {
  9656. isKeywordES5: isKeywordES5,
  9657. isKeywordES6: isKeywordES6,
  9658. isReservedWordES5: isReservedWordES5,
  9659. isReservedWordES6: isReservedWordES6,
  9660. isRestrictedWord: isRestrictedWord,
  9661. isIdentifierNameES5: isIdentifierNameES5,
  9662. isIdentifierNameES6: isIdentifierNameES6,
  9663. isIdentifierES5: isIdentifierES5,
  9664. isIdentifierES6: isIdentifierES6
  9665. };
  9666. })();
  9667. /* vim: set sw=4 ts=4 et tw=80 : */
  9668. });
  9669. var utils$2 = createCommonjsModule(function (module, exports) {
  9670. /*
  9671. Copyright (C) 2013 Yusuke Suzuki <utatane.tea@gmail.com>
  9672. Redistribution and use in source and binary forms, with or without
  9673. modification, are permitted provided that the following conditions are met:
  9674. * Redistributions of source code must retain the above copyright
  9675. notice, this list of conditions and the following disclaimer.
  9676. * Redistributions in binary form must reproduce the above copyright
  9677. notice, this list of conditions and the following disclaimer in the
  9678. documentation and/or other materials provided with the distribution.
  9679. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  9680. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  9681. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  9682. ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
  9683. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  9684. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  9685. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  9686. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  9687. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  9688. THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  9689. */
  9690. (function () {
  9691. 'use strict';
  9692. exports.ast = ast;
  9693. exports.code = code;
  9694. exports.keyword = keyword;
  9695. })();
  9696. /* vim: set sw=4 ts=4 et tw=80 : */
  9697. });
  9698. var hasFlag$6 = createCommonjsModule(function (module) {
  9699. 'use strict';
  9700. module.exports = function (flag, argv$$1) {
  9701. argv$$1 = argv$$1 || process.argv;
  9702. var prefix = flag.startsWith('-') ? '' : flag.length === 1 ? '-' : '--';
  9703. var pos = argv$$1.indexOf(prefix + flag);
  9704. var terminatorPos = argv$$1.indexOf('--');
  9705. return pos !== -1 && (terminatorPos === -1 ? true : pos < terminatorPos);
  9706. };
  9707. });
  9708. var env$2 = process.env;
  9709. var forceColor$1;
  9710. if (hasFlag$6('no-color') || hasFlag$6('no-colors') || hasFlag$6('color=false')) {
  9711. forceColor$1 = false;
  9712. } else if (hasFlag$6('color') || hasFlag$6('colors') || hasFlag$6('color=true') || hasFlag$6('color=always')) {
  9713. forceColor$1 = true;
  9714. }
  9715. if ('FORCE_COLOR' in env$2) {
  9716. forceColor$1 = env$2.FORCE_COLOR.length === 0 || parseInt(env$2.FORCE_COLOR, 10) !== 0;
  9717. }
  9718. function translateLevel$1(level) {
  9719. if (level === 0) {
  9720. return false;
  9721. }
  9722. return {
  9723. level: level,
  9724. hasBasic: true,
  9725. has256: level >= 2,
  9726. has16m: level >= 3
  9727. };
  9728. }
  9729. function supportsColor$4(stream) {
  9730. if (forceColor$1 === false) {
  9731. return 0;
  9732. }
  9733. if (hasFlag$6('color=16m') || hasFlag$6('color=full') || hasFlag$6('color=truecolor')) {
  9734. return 3;
  9735. }
  9736. if (hasFlag$6('color=256')) {
  9737. return 2;
  9738. }
  9739. if (stream && !stream.isTTY && forceColor$1 !== true) {
  9740. return 0;
  9741. }
  9742. var min = forceColor$1 ? 1 : 0;
  9743. if (process.platform === 'win32') {
  9744. // Node.js 7.5.0 is the first version of Node.js to include a patch to
  9745. // libuv that enables 256 color output on Windows. Anything earlier and it
  9746. // won't work. However, here we target Node.js 8 at minimum as it is an LTS
  9747. // release, and Node.js 7 is not. Windows 10 build 10586 is the first Windows
  9748. // release that supports 256 colors. Windows 10 build 14931 is the first release
  9749. // that supports 16m/TrueColor.
  9750. var osRelease = require$$1$1.release().split('.');
  9751. if (Number(process.versions.node.split('.')[0]) >= 8 && Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
  9752. return Number(osRelease[2]) >= 14931 ? 3 : 2;
  9753. }
  9754. return 1;
  9755. }
  9756. if ('CI' in env$2) {
  9757. if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI'].some(function (sign) {
  9758. return sign in env$2;
  9759. }) || env$2.CI_NAME === 'codeship') {
  9760. return 1;
  9761. }
  9762. return min;
  9763. }
  9764. if ('TEAMCITY_VERSION' in env$2) {
  9765. return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env$2.TEAMCITY_VERSION) ? 1 : 0;
  9766. }
  9767. if (env$2.COLORTERM === 'truecolor') {
  9768. return 3;
  9769. }
  9770. if ('TERM_PROGRAM' in env$2) {
  9771. var version = parseInt((env$2.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
  9772. switch (env$2.TERM_PROGRAM) {
  9773. case 'iTerm.app':
  9774. return version >= 3 ? 3 : 2;
  9775. case 'Apple_Terminal':
  9776. return 2;
  9777. // No default
  9778. }
  9779. }
  9780. if (/-256(color)?$/i.test(env$2.TERM)) {
  9781. return 2;
  9782. }
  9783. if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env$2.TERM)) {
  9784. return 1;
  9785. }
  9786. if ('COLORTERM' in env$2) {
  9787. return 1;
  9788. }
  9789. if (env$2.TERM === 'dumb') {
  9790. return min;
  9791. }
  9792. return min;
  9793. }
  9794. function getSupportLevel$1(stream) {
  9795. var level = supportsColor$4(stream);
  9796. return translateLevel$1(level);
  9797. }
  9798. var supportsColor_1$3 = {
  9799. supportsColor: getSupportLevel$1,
  9800. stdout: getSupportLevel$1(process.stdout),
  9801. stderr: getSupportLevel$1(process.stderr)
  9802. };
  9803. var templates$4 = createCommonjsModule(function (module) {
  9804. 'use strict';
  9805. var TEMPLATE_REGEX = /(?:\\(u[a-f\d]{4}|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi;
  9806. var STYLE_REGEX = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g;
  9807. var STRING_REGEX = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/;
  9808. var ESCAPE_REGEX = /\\(u[a-f\d]{4}|x[a-f\d]{2}|.)|([^\\])/gi;
  9809. var ESCAPES = new Map([['n', '\n'], ['r', '\r'], ['t', '\t'], ['b', '\b'], ['f', '\f'], ['v', '\v'], ['0', '\0'], ['\\', '\\'], ['e', "\x1B"], ['a', "\x07"]]);
  9810. function unescape(c) {
  9811. if (c[0] === 'u' && c.length === 5 || c[0] === 'x' && c.length === 3) {
  9812. return String.fromCharCode(parseInt(c.slice(1), 16));
  9813. }
  9814. return ESCAPES.get(c) || c;
  9815. }
  9816. function parseArguments(name, args) {
  9817. var results = [];
  9818. var chunks = args.trim().split(/\s*,\s*/g);
  9819. var matches;
  9820. var _iteratorNormalCompletion = true;
  9821. var _didIteratorError = false;
  9822. var _iteratorError = undefined;
  9823. try {
  9824. for (var _iterator = chunks[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  9825. var chunk = _step.value;
  9826. if (!isNaN(chunk)) {
  9827. results.push(Number(chunk));
  9828. } else if (matches = chunk.match(STRING_REGEX)) {
  9829. results.push(matches[2].replace(ESCAPE_REGEX, function (m, escape, chr) {
  9830. return escape ? unescape(escape) : chr;
  9831. }));
  9832. } else {
  9833. throw new Error("Invalid Chalk template style argument: ".concat(chunk, " (in style '").concat(name, "')"));
  9834. }
  9835. }
  9836. } catch (err) {
  9837. _didIteratorError = true;
  9838. _iteratorError = err;
  9839. } finally {
  9840. try {
  9841. if (!_iteratorNormalCompletion && _iterator.return != null) {
  9842. _iterator.return();
  9843. }
  9844. } finally {
  9845. if (_didIteratorError) {
  9846. throw _iteratorError;
  9847. }
  9848. }
  9849. }
  9850. return results;
  9851. }
  9852. function parseStyle(style) {
  9853. STYLE_REGEX.lastIndex = 0;
  9854. var results = [];
  9855. var matches;
  9856. while ((matches = STYLE_REGEX.exec(style)) !== null) {
  9857. var name = matches[1];
  9858. if (matches[2]) {
  9859. var args = parseArguments(name, matches[2]);
  9860. results.push([name].concat(args));
  9861. } else {
  9862. results.push([name]);
  9863. }
  9864. }
  9865. return results;
  9866. }
  9867. function buildStyle(chalk, styles) {
  9868. var enabled = {};
  9869. var _iteratorNormalCompletion2 = true;
  9870. var _didIteratorError2 = false;
  9871. var _iteratorError2 = undefined;
  9872. try {
  9873. for (var _iterator2 = styles[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
  9874. var layer = _step2.value;
  9875. var _iteratorNormalCompletion3 = true;
  9876. var _didIteratorError3 = false;
  9877. var _iteratorError3 = undefined;
  9878. try {
  9879. for (var _iterator3 = layer.styles[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
  9880. var style = _step3.value;
  9881. enabled[style[0]] = layer.inverse ? null : style.slice(1);
  9882. }
  9883. } catch (err) {
  9884. _didIteratorError3 = true;
  9885. _iteratorError3 = err;
  9886. } finally {
  9887. try {
  9888. if (!_iteratorNormalCompletion3 && _iterator3.return != null) {
  9889. _iterator3.return();
  9890. }
  9891. } finally {
  9892. if (_didIteratorError3) {
  9893. throw _iteratorError3;
  9894. }
  9895. }
  9896. }
  9897. }
  9898. } catch (err) {
  9899. _didIteratorError2 = true;
  9900. _iteratorError2 = err;
  9901. } finally {
  9902. try {
  9903. if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
  9904. _iterator2.return();
  9905. }
  9906. } finally {
  9907. if (_didIteratorError2) {
  9908. throw _iteratorError2;
  9909. }
  9910. }
  9911. }
  9912. var current = chalk;
  9913. var _arr = Object.keys(enabled);
  9914. for (var _i = 0; _i < _arr.length; _i++) {
  9915. var styleName = _arr[_i];
  9916. if (Array.isArray(enabled[styleName])) {
  9917. if (!(styleName in current)) {
  9918. throw new Error("Unknown Chalk style: ".concat(styleName));
  9919. }
  9920. if (enabled[styleName].length > 0) {
  9921. current = current[styleName].apply(current, enabled[styleName]);
  9922. } else {
  9923. current = current[styleName];
  9924. }
  9925. }
  9926. }
  9927. return current;
  9928. }
  9929. module.exports = function (chalk, tmp) {
  9930. var styles = [];
  9931. var chunks = [];
  9932. var chunk = []; // eslint-disable-next-line max-params
  9933. tmp.replace(TEMPLATE_REGEX, function (m, escapeChar, inverse, style, close, chr) {
  9934. if (escapeChar) {
  9935. chunk.push(unescape(escapeChar));
  9936. } else if (style) {
  9937. var str = chunk.join('');
  9938. chunk = [];
  9939. chunks.push(styles.length === 0 ? str : buildStyle(chalk, styles)(str));
  9940. styles.push({
  9941. inverse: inverse,
  9942. styles: parseStyle(style)
  9943. });
  9944. } else if (close) {
  9945. if (styles.length === 0) {
  9946. throw new Error('Found extraneous } in Chalk template literal');
  9947. }
  9948. chunks.push(buildStyle(chalk, styles)(chunk.join('')));
  9949. chunk = [];
  9950. styles.pop();
  9951. } else {
  9952. chunk.push(chr);
  9953. }
  9954. });
  9955. chunks.push(chunk.join(''));
  9956. if (styles.length > 0) {
  9957. var errMsg = "Chalk template literal is missing ".concat(styles.length, " closing bracket").concat(styles.length === 1 ? '' : 's', " (`}`)");
  9958. throw new Error(errMsg);
  9959. }
  9960. return chunks.join('');
  9961. };
  9962. });
  9963. var chalk$5 = createCommonjsModule(function (module) {
  9964. 'use strict';
  9965. var stdoutColor = supportsColor_1$3.stdout;
  9966. var isSimpleWindowsTerm = process.platform === 'win32' && !(process.env.TERM || '').toLowerCase().startsWith('xterm'); // `supportsColor.level` → `ansiStyles.color[name]` mapping
  9967. var levelMapping = ['ansi', 'ansi', 'ansi256', 'ansi16m']; // `color-convert` models to exclude from the Chalk API due to conflicts and such
  9968. var skipModels = new Set(['gray']);
  9969. var styles = Object.create(null);
  9970. function applyOptions(obj, options) {
  9971. options = options || {}; // Detect level if not set manually
  9972. var scLevel = stdoutColor ? stdoutColor.level : 0;
  9973. obj.level = options.level === undefined ? scLevel : options.level;
  9974. obj.enabled = 'enabled' in options ? options.enabled : obj.level > 0;
  9975. }
  9976. function Chalk(options) {
  9977. // We check for this.template here since calling `chalk.constructor()`
  9978. // by itself will have a `this` of a previously constructed chalk object
  9979. if (!this || !(this instanceof Chalk) || this.template) {
  9980. var _chalk = {};
  9981. applyOptions(_chalk, options);
  9982. _chalk.template = function () {
  9983. var args = [].slice.call(arguments);
  9984. return chalkTag.apply(null, [_chalk.template].concat(args));
  9985. };
  9986. Object.setPrototypeOf(_chalk, Chalk.prototype);
  9987. Object.setPrototypeOf(_chalk.template, _chalk);
  9988. _chalk.template.constructor = Chalk;
  9989. return _chalk.template;
  9990. }
  9991. applyOptions(this, options);
  9992. } // Use bright blue on Windows as the normal blue color is illegible
  9993. if (isSimpleWindowsTerm) {
  9994. ansiStyles.blue.open = "\x1B[94m";
  9995. }
  9996. var _arr = Object.keys(ansiStyles);
  9997. var _loop = function _loop() {
  9998. var key = _arr[_i];
  9999. ansiStyles[key].closeRe = new RegExp(escapeStringRegexp(ansiStyles[key].close), 'g');
  10000. styles[key] = {
  10001. get: function get() {
  10002. var codes = ansiStyles[key];
  10003. return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, key);
  10004. }
  10005. };
  10006. };
  10007. for (var _i = 0; _i < _arr.length; _i++) {
  10008. _loop();
  10009. }
  10010. styles.visible = {
  10011. get: function get() {
  10012. return build.call(this, this._styles || [], true, 'visible');
  10013. }
  10014. };
  10015. ansiStyles.color.closeRe = new RegExp(escapeStringRegexp(ansiStyles.color.close), 'g');
  10016. var _arr2 = Object.keys(ansiStyles.color.ansi);
  10017. var _loop2 = function _loop2() {
  10018. var model = _arr2[_i2];
  10019. if (skipModels.has(model)) {
  10020. return "continue";
  10021. }
  10022. styles[model] = {
  10023. get: function get() {
  10024. var level = this.level;
  10025. return function () {
  10026. var open = ansiStyles.color[levelMapping[level]][model].apply(null, arguments);
  10027. var codes = {
  10028. open: open,
  10029. close: ansiStyles.color.close,
  10030. closeRe: ansiStyles.color.closeRe
  10031. };
  10032. return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, model);
  10033. };
  10034. }
  10035. };
  10036. };
  10037. for (var _i2 = 0; _i2 < _arr2.length; _i2++) {
  10038. var _ret = _loop2();
  10039. if (_ret === "continue") continue;
  10040. }
  10041. ansiStyles.bgColor.closeRe = new RegExp(escapeStringRegexp(ansiStyles.bgColor.close), 'g');
  10042. var _arr3 = Object.keys(ansiStyles.bgColor.ansi);
  10043. var _loop3 = function _loop3() {
  10044. var model = _arr3[_i3];
  10045. if (skipModels.has(model)) {
  10046. return "continue";
  10047. }
  10048. var bgModel = 'bg' + model[0].toUpperCase() + model.slice(1);
  10049. styles[bgModel] = {
  10050. get: function get() {
  10051. var level = this.level;
  10052. return function () {
  10053. var open = ansiStyles.bgColor[levelMapping[level]][model].apply(null, arguments);
  10054. var codes = {
  10055. open: open,
  10056. close: ansiStyles.bgColor.close,
  10057. closeRe: ansiStyles.bgColor.closeRe
  10058. };
  10059. return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, model);
  10060. };
  10061. }
  10062. };
  10063. };
  10064. for (var _i3 = 0; _i3 < _arr3.length; _i3++) {
  10065. var _ret2 = _loop3();
  10066. if (_ret2 === "continue") continue;
  10067. }
  10068. var proto = Object.defineProperties(function () {}, styles);
  10069. function build(_styles, _empty, key) {
  10070. var builder = function builder() {
  10071. return applyStyle.apply(builder, arguments);
  10072. };
  10073. builder._styles = _styles;
  10074. builder._empty = _empty;
  10075. var self = this;
  10076. Object.defineProperty(builder, 'level', {
  10077. enumerable: true,
  10078. get: function get() {
  10079. return self.level;
  10080. },
  10081. set: function set(level) {
  10082. self.level = level;
  10083. }
  10084. });
  10085. Object.defineProperty(builder, 'enabled', {
  10086. enumerable: true,
  10087. get: function get() {
  10088. return self.enabled;
  10089. },
  10090. set: function set(enabled) {
  10091. self.enabled = enabled;
  10092. }
  10093. }); // See below for fix regarding invisible grey/dim combination on Windows
  10094. builder.hasGrey = this.hasGrey || key === 'gray' || key === 'grey'; // `__proto__` is used because we must return a function, but there is
  10095. // no way to create a function with a different prototype
  10096. builder.__proto__ = proto; // eslint-disable-line no-proto
  10097. return builder;
  10098. }
  10099. function applyStyle() {
  10100. // Support varags, but simply cast to string in case there's only one arg
  10101. var args = arguments;
  10102. var argsLen = args.length;
  10103. var str = String(arguments[0]);
  10104. if (argsLen === 0) {
  10105. return '';
  10106. }
  10107. if (argsLen > 1) {
  10108. // Don't slice `arguments`, it prevents V8 optimizations
  10109. for (var a = 1; a < argsLen; a++) {
  10110. str += ' ' + args[a];
  10111. }
  10112. }
  10113. if (!this.enabled || this.level <= 0 || !str) {
  10114. return this._empty ? '' : str;
  10115. } // Turns out that on Windows dimmed gray text becomes invisible in cmd.exe,
  10116. // see https://github.com/chalk/chalk/issues/58
  10117. // If we're on Windows and we're dealing with a gray color, temporarily make 'dim' a noop.
  10118. var originalDim = ansiStyles.dim.open;
  10119. if (isSimpleWindowsTerm && this.hasGrey) {
  10120. ansiStyles.dim.open = '';
  10121. }
  10122. var _iteratorNormalCompletion = true;
  10123. var _didIteratorError = false;
  10124. var _iteratorError = undefined;
  10125. try {
  10126. for (var _iterator = this._styles.slice().reverse()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  10127. var code = _step.value;
  10128. // Replace any instances already present with a re-opening code
  10129. // otherwise only the part of the string until said closing code
  10130. // will be colored, and the rest will simply be 'plain'.
  10131. str = code.open + str.replace(code.closeRe, code.open) + code.close; // Close the styling before a linebreak and reopen
  10132. // after next line to fix a bleed issue on macOS
  10133. // https://github.com/chalk/chalk/pull/92
  10134. str = str.replace(/\r?\n/g, "".concat(code.close, "$&").concat(code.open));
  10135. } // Reset the original `dim` if we changed it to work around the Windows dimmed gray issue
  10136. } catch (err) {
  10137. _didIteratorError = true;
  10138. _iteratorError = err;
  10139. } finally {
  10140. try {
  10141. if (!_iteratorNormalCompletion && _iterator.return != null) {
  10142. _iterator.return();
  10143. }
  10144. } finally {
  10145. if (_didIteratorError) {
  10146. throw _iteratorError;
  10147. }
  10148. }
  10149. }
  10150. ansiStyles.dim.open = originalDim;
  10151. return str;
  10152. }
  10153. function chalkTag(chalk, strings) {
  10154. if (!Array.isArray(strings)) {
  10155. // If chalk() was called by itself or with a string,
  10156. // return the string itself as a string.
  10157. return [].slice.call(arguments, 1).join(' ');
  10158. }
  10159. var args = [].slice.call(arguments, 2);
  10160. var parts = [strings.raw[0]];
  10161. for (var i = 1; i < strings.length; i++) {
  10162. parts.push(String(args[i - 1]).replace(/[{}\\]/g, '\\$&'));
  10163. parts.push(String(strings.raw[i]));
  10164. }
  10165. return templates$4(chalk, parts.join(''));
  10166. }
  10167. Object.defineProperties(Chalk.prototype, styles);
  10168. module.exports = Chalk(); // eslint-disable-line new-cap
  10169. module.exports.supportsColor = stdoutColor;
  10170. module.exports.default = module.exports; // For TypeScript
  10171. });
  10172. var lib$3 = createCommonjsModule(function (module, exports) {
  10173. "use strict";
  10174. Object.defineProperty(exports, "__esModule", {
  10175. value: true
  10176. });
  10177. exports.shouldHighlight = shouldHighlight;
  10178. exports.getChalk = getChalk;
  10179. exports.default = highlight;
  10180. function _jsTokens() {
  10181. var data = _interopRequireWildcard(jsTokens);
  10182. _jsTokens = function _jsTokens() {
  10183. return data;
  10184. };
  10185. return data;
  10186. }
  10187. function _esutils() {
  10188. var data = _interopRequireDefault(utils$2);
  10189. _esutils = function _esutils() {
  10190. return data;
  10191. };
  10192. return data;
  10193. }
  10194. function _chalk() {
  10195. var data = _interopRequireDefault(chalk$5);
  10196. _chalk = function _chalk() {
  10197. return data;
  10198. };
  10199. return data;
  10200. }
  10201. function _interopRequireDefault(obj) {
  10202. return obj && obj.__esModule ? obj : {
  10203. default: obj
  10204. };
  10205. }
  10206. function _interopRequireWildcard(obj) {
  10207. if (obj && obj.__esModule) {
  10208. return obj;
  10209. } else {
  10210. var newObj = {};
  10211. if (obj != null) {
  10212. for (var key in obj) {
  10213. if (Object.prototype.hasOwnProperty.call(obj, key)) {
  10214. var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {};
  10215. if (desc.get || desc.set) {
  10216. Object.defineProperty(newObj, key, desc);
  10217. } else {
  10218. newObj[key] = obj[key];
  10219. }
  10220. }
  10221. }
  10222. }
  10223. newObj.default = obj;
  10224. return newObj;
  10225. }
  10226. }
  10227. function getDefs(chalk) {
  10228. return {
  10229. keyword: chalk.cyan,
  10230. capitalized: chalk.yellow,
  10231. jsx_tag: chalk.yellow,
  10232. punctuator: chalk.yellow,
  10233. number: chalk.magenta,
  10234. string: chalk.green,
  10235. regex: chalk.magenta,
  10236. comment: chalk.grey,
  10237. invalid: chalk.white.bgRed.bold
  10238. };
  10239. }
  10240. var NEWLINE = /\r\n|[\n\r\u2028\u2029]/;
  10241. var JSX_TAG = /^[a-z][\w-]*$/i;
  10242. var BRACKET = /^[()[\]{}]$/;
  10243. function getTokenType(match) {
  10244. var _match$slice = match.slice(-2),
  10245. offset = _match$slice[0],
  10246. text = _match$slice[1];
  10247. var token = (0, _jsTokens().matchToToken)(match);
  10248. if (token.type === "name") {
  10249. if (_esutils().default.keyword.isReservedWordES6(token.value)) {
  10250. return "keyword";
  10251. }
  10252. if (JSX_TAG.test(token.value) && (text[offset - 1] === "<" || text.substr(offset - 2, 2) == "</")) {
  10253. return "jsx_tag";
  10254. }
  10255. if (token.value[0] !== token.value[0].toLowerCase()) {
  10256. return "capitalized";
  10257. }
  10258. }
  10259. if (token.type === "punctuator" && BRACKET.test(token.value)) {
  10260. return "bracket";
  10261. }
  10262. if (token.type === "invalid" && (token.value === "@" || token.value === "#")) {
  10263. return "punctuator";
  10264. }
  10265. return token.type;
  10266. }
  10267. function highlightTokens(defs, text) {
  10268. return text.replace(_jsTokens().default, function () {
  10269. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  10270. args[_key] = arguments[_key];
  10271. }
  10272. var type = getTokenType(args);
  10273. var colorize = defs[type];
  10274. if (colorize) {
  10275. return args[0].split(NEWLINE).map(function (str) {
  10276. return colorize(str);
  10277. }).join("\n");
  10278. } else {
  10279. return args[0];
  10280. }
  10281. });
  10282. }
  10283. function shouldHighlight(options) {
  10284. return _chalk().default.supportsColor || options.forceColor;
  10285. }
  10286. function getChalk(options) {
  10287. var chalk = _chalk().default;
  10288. if (options.forceColor) {
  10289. chalk = new (_chalk().default.constructor)({
  10290. enabled: true,
  10291. level: 1
  10292. });
  10293. }
  10294. return chalk;
  10295. }
  10296. function highlight(code, options) {
  10297. if (options === void 0) {
  10298. options = {};
  10299. }
  10300. if (shouldHighlight(options)) {
  10301. var chalk = getChalk(options);
  10302. var defs = getDefs(chalk);
  10303. return highlightTokens(defs, code);
  10304. } else {
  10305. return code;
  10306. }
  10307. }
  10308. });
  10309. unwrapExports(lib$3);
  10310. var lib$2 = createCommonjsModule(function (module, exports) {
  10311. "use strict";
  10312. Object.defineProperty(exports, "__esModule", {
  10313. value: true
  10314. });
  10315. exports.codeFrameColumns = codeFrameColumns;
  10316. exports.default = _default;
  10317. function _highlight() {
  10318. var data = _interopRequireWildcard(lib$3);
  10319. _highlight = function _highlight() {
  10320. return data;
  10321. };
  10322. return data;
  10323. }
  10324. function _interopRequireWildcard(obj) {
  10325. if (obj && obj.__esModule) {
  10326. return obj;
  10327. } else {
  10328. var newObj = {};
  10329. if (obj != null) {
  10330. for (var key in obj) {
  10331. if (Object.prototype.hasOwnProperty.call(obj, key)) {
  10332. var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {};
  10333. if (desc.get || desc.set) {
  10334. Object.defineProperty(newObj, key, desc);
  10335. } else {
  10336. newObj[key] = obj[key];
  10337. }
  10338. }
  10339. }
  10340. }
  10341. newObj.default = obj;
  10342. return newObj;
  10343. }
  10344. }
  10345. var deprecationWarningShown = false;
  10346. function getDefs(chalk) {
  10347. return {
  10348. gutter: chalk.grey,
  10349. marker: chalk.red.bold,
  10350. message: chalk.red.bold
  10351. };
  10352. }
  10353. var NEWLINE = /\r\n|[\n\r\u2028\u2029]/;
  10354. function getMarkerLines(loc, source, opts) {
  10355. var startLoc = Object.assign({}, {
  10356. column: 0,
  10357. line: -1
  10358. }, loc.start);
  10359. var endLoc = Object.assign({}, startLoc, loc.end);
  10360. var _ref = opts || {},
  10361. _ref$linesAbove = _ref.linesAbove,
  10362. linesAbove = _ref$linesAbove === void 0 ? 2 : _ref$linesAbove,
  10363. _ref$linesBelow = _ref.linesBelow,
  10364. linesBelow = _ref$linesBelow === void 0 ? 3 : _ref$linesBelow;
  10365. var startLine = startLoc.line;
  10366. var startColumn = startLoc.column;
  10367. var endLine = endLoc.line;
  10368. var endColumn = endLoc.column;
  10369. var start = Math.max(startLine - (linesAbove + 1), 0);
  10370. var end = Math.min(source.length, endLine + linesBelow);
  10371. if (startLine === -1) {
  10372. start = 0;
  10373. }
  10374. if (endLine === -1) {
  10375. end = source.length;
  10376. }
  10377. var lineDiff = endLine - startLine;
  10378. var markerLines = {};
  10379. if (lineDiff) {
  10380. for (var i = 0; i <= lineDiff; i++) {
  10381. var lineNumber = i + startLine;
  10382. if (!startColumn) {
  10383. markerLines[lineNumber] = true;
  10384. } else if (i === 0) {
  10385. var sourceLength = source[lineNumber - 1].length;
  10386. markerLines[lineNumber] = [startColumn, sourceLength - startColumn];
  10387. } else if (i === lineDiff) {
  10388. markerLines[lineNumber] = [0, endColumn];
  10389. } else {
  10390. var _sourceLength = source[lineNumber - i].length;
  10391. markerLines[lineNumber] = [0, _sourceLength];
  10392. }
  10393. }
  10394. } else {
  10395. if (startColumn === endColumn) {
  10396. if (startColumn) {
  10397. markerLines[startLine] = [startColumn, 0];
  10398. } else {
  10399. markerLines[startLine] = true;
  10400. }
  10401. } else {
  10402. markerLines[startLine] = [startColumn, endColumn - startColumn];
  10403. }
  10404. }
  10405. return {
  10406. start: start,
  10407. end: end,
  10408. markerLines: markerLines
  10409. };
  10410. }
  10411. function codeFrameColumns(rawLines, loc, opts) {
  10412. if (opts === void 0) {
  10413. opts = {};
  10414. }
  10415. var highlighted = (opts.highlightCode || opts.forceColor) && (0, _highlight().shouldHighlight)(opts);
  10416. var chalk = (0, _highlight().getChalk)(opts);
  10417. var defs = getDefs(chalk);
  10418. var maybeHighlight = function maybeHighlight(chalkFn, string) {
  10419. return highlighted ? chalkFn(string) : string;
  10420. };
  10421. if (highlighted) rawLines = (0, _highlight().default)(rawLines, opts);
  10422. var lines = rawLines.split(NEWLINE);
  10423. var _getMarkerLines = getMarkerLines(loc, lines, opts),
  10424. start = _getMarkerLines.start,
  10425. end = _getMarkerLines.end,
  10426. markerLines = _getMarkerLines.markerLines;
  10427. var hasColumns = loc.start && typeof loc.start.column === "number";
  10428. var numberMaxWidth = String(end).length;
  10429. var frame = lines.slice(start, end).map(function (line, index) {
  10430. var number = start + 1 + index;
  10431. var paddedNumber = (" " + number).slice(-numberMaxWidth);
  10432. var gutter = " " + paddedNumber + " | ";
  10433. var hasMarker = markerLines[number];
  10434. var lastMarkerLine = !markerLines[number + 1];
  10435. if (hasMarker) {
  10436. var markerLine = "";
  10437. if (Array.isArray(hasMarker)) {
  10438. var markerSpacing = line.slice(0, Math.max(hasMarker[0] - 1, 0)).replace(/[^\t]/g, " ");
  10439. var numberOfMarkers = hasMarker[1] || 1;
  10440. markerLine = ["\n ", maybeHighlight(defs.gutter, gutter.replace(/\d/g, " ")), markerSpacing, maybeHighlight(defs.marker, "^").repeat(numberOfMarkers)].join("");
  10441. if (lastMarkerLine && opts.message) {
  10442. markerLine += " " + maybeHighlight(defs.message, opts.message);
  10443. }
  10444. }
  10445. return [maybeHighlight(defs.marker, ">"), maybeHighlight(defs.gutter, gutter), line, markerLine].join("");
  10446. } else {
  10447. return " " + maybeHighlight(defs.gutter, gutter) + line;
  10448. }
  10449. }).join("\n");
  10450. if (opts.message && !hasColumns) {
  10451. frame = "" + " ".repeat(numberMaxWidth + 1) + opts.message + "\n" + frame;
  10452. }
  10453. if (highlighted) {
  10454. return chalk.reset(frame);
  10455. } else {
  10456. return frame;
  10457. }
  10458. }
  10459. function _default(rawLines, lineNumber, colNumber, opts) {
  10460. if (opts === void 0) {
  10461. opts = {};
  10462. }
  10463. if (!deprecationWarningShown) {
  10464. deprecationWarningShown = true;
  10465. var message = "Passing lineNumber and colNumber is deprecated to @babel/code-frame. Please use `codeFrameColumns`.";
  10466. if (process.emitWarning) {
  10467. process.emitWarning(message, "DeprecationWarning");
  10468. } else {
  10469. var deprecationError = new Error(message);
  10470. deprecationError.name = "DeprecationWarning";
  10471. console.warn(new Error(message));
  10472. }
  10473. }
  10474. colNumber = Math.max(colNumber, 0);
  10475. var location = {
  10476. start: {
  10477. column: colNumber,
  10478. line: lineNumber
  10479. }
  10480. };
  10481. return codeFrameColumns(rawLines, location, opts);
  10482. }
  10483. });
  10484. unwrapExports(lib$2);
  10485. var ConfigError$1 = errors.ConfigError;
  10486. var locStart = loc.locStart;
  10487. var locEnd = loc.locEnd; // Use defineProperties()/getOwnPropertyDescriptor() to prevent
  10488. // triggering the parsers getters.
  10489. var ownNames = Object.getOwnPropertyNames;
  10490. var ownDescriptor = Object.getOwnPropertyDescriptor;
  10491. function getParsers(options) {
  10492. var parsers = {};
  10493. var _iteratorNormalCompletion = true;
  10494. var _didIteratorError = false;
  10495. var _iteratorError = undefined;
  10496. try {
  10497. for (var _iterator = options.plugins[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  10498. var plugin = _step.value;
  10499. if (!plugin.parsers) {
  10500. continue;
  10501. }
  10502. var _iteratorNormalCompletion2 = true;
  10503. var _didIteratorError2 = false;
  10504. var _iteratorError2 = undefined;
  10505. try {
  10506. for (var _iterator2 = ownNames(plugin.parsers)[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
  10507. var name = _step2.value;
  10508. Object.defineProperty(parsers, name, ownDescriptor(plugin.parsers, name));
  10509. }
  10510. } catch (err) {
  10511. _didIteratorError2 = true;
  10512. _iteratorError2 = err;
  10513. } finally {
  10514. try {
  10515. if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
  10516. _iterator2.return();
  10517. }
  10518. } finally {
  10519. if (_didIteratorError2) {
  10520. throw _iteratorError2;
  10521. }
  10522. }
  10523. }
  10524. }
  10525. } catch (err) {
  10526. _didIteratorError = true;
  10527. _iteratorError = err;
  10528. } finally {
  10529. try {
  10530. if (!_iteratorNormalCompletion && _iterator.return != null) {
  10531. _iterator.return();
  10532. }
  10533. } finally {
  10534. if (_didIteratorError) {
  10535. throw _iteratorError;
  10536. }
  10537. }
  10538. }
  10539. return parsers;
  10540. }
  10541. function resolveParser$1(opts, parsers) {
  10542. parsers = parsers || getParsers(opts);
  10543. if (typeof opts.parser === "function") {
  10544. // Custom parser API always works with JavaScript.
  10545. return {
  10546. parse: opts.parser,
  10547. astFormat: "estree",
  10548. locStart: locStart,
  10549. locEnd: locEnd
  10550. };
  10551. }
  10552. if (typeof opts.parser === "string") {
  10553. if (parsers.hasOwnProperty(opts.parser)) {
  10554. return parsers[opts.parser];
  10555. }
  10556. /* istanbul ignore next */
  10557. {
  10558. throw new ConfigError$1("Couldn't resolve parser \"".concat(opts.parser, "\". Parsers must be explicitly added to the standalone bundle."));
  10559. }
  10560. }
  10561. }
  10562. function parse$2(text, opts) {
  10563. var parsers = getParsers(opts); // Create a new object {parserName: parseFn}. Uses defineProperty() to only call
  10564. // the parsers getters when actually calling the parser `parse` function.
  10565. var parsersForCustomParserApi = Object.keys(parsers).reduce(function (object, parserName) {
  10566. return Object.defineProperty(object, parserName, {
  10567. enumerable: true,
  10568. get: function get() {
  10569. return parsers[parserName].parse;
  10570. }
  10571. });
  10572. }, {});
  10573. var parser = resolveParser$1(opts, parsers);
  10574. try {
  10575. if (parser.preprocess) {
  10576. text = parser.preprocess(text, opts);
  10577. }
  10578. return {
  10579. text: text,
  10580. ast: parser.parse(text, parsersForCustomParserApi, opts)
  10581. };
  10582. } catch (error) {
  10583. var loc$$1 = error.loc;
  10584. if (loc$$1) {
  10585. var codeFrame = lib$2;
  10586. error.codeFrame = codeFrame.codeFrameColumns(text, loc$$1, {
  10587. highlightCode: true
  10588. });
  10589. error.message += "\n" + error.codeFrame;
  10590. throw error;
  10591. }
  10592. /* istanbul ignore next */
  10593. throw error.stack;
  10594. }
  10595. }
  10596. var parser = {
  10597. parse: parse$2,
  10598. resolveParser: resolveParser$1
  10599. };
  10600. var UndefinedParserError = errors.UndefinedParserError;
  10601. var getSupportInfo$1 = support.getSupportInfo;
  10602. var resolveParser = parser.resolveParser;
  10603. var hiddenDefaults = {
  10604. astFormat: "estree",
  10605. printer: {},
  10606. originalText: undefined,
  10607. locStart: null,
  10608. locEnd: null
  10609. }; // Copy options and fill in default values.
  10610. function normalize(options, opts) {
  10611. opts = opts || {};
  10612. var rawOptions = Object.assign({}, options);
  10613. var supportOptions = getSupportInfo$1(null, {
  10614. plugins: options.plugins,
  10615. showUnreleased: true,
  10616. showDeprecated: true
  10617. }).options;
  10618. var defaults = supportOptions.reduce(function (reduced, optionInfo) {
  10619. return optionInfo.default !== undefined ? Object.assign(reduced, _defineProperty({}, optionInfo.name, optionInfo.default)) : reduced;
  10620. }, Object.assign({}, hiddenDefaults));
  10621. if (!rawOptions.parser) {
  10622. if (!rawOptions.filepath) {
  10623. var logger = opts.logger || console;
  10624. logger.warn("No parser and no filepath given, using 'babel' the parser now " + "but this will throw an error in the future. " + "Please specify a parser or a filepath so one can be inferred.");
  10625. rawOptions.parser = "babel";
  10626. } else {
  10627. rawOptions.parser = inferParser(rawOptions.filepath, rawOptions.plugins);
  10628. if (!rawOptions.parser) {
  10629. throw new UndefinedParserError("No parser could be inferred for file: ".concat(rawOptions.filepath));
  10630. }
  10631. }
  10632. }
  10633. var parser$$1 = resolveParser(optionsNormalizer.normalizeApiOptions(rawOptions, [supportOptions.find(function (x) {
  10634. return x.name === "parser";
  10635. })], {
  10636. passThrough: true,
  10637. logger: false
  10638. }));
  10639. rawOptions.astFormat = parser$$1.astFormat;
  10640. rawOptions.locEnd = parser$$1.locEnd;
  10641. rawOptions.locStart = parser$$1.locStart;
  10642. var plugin = getPlugin(rawOptions);
  10643. rawOptions.printer = plugin.printers[rawOptions.astFormat];
  10644. var pluginDefaults = supportOptions.filter(function (optionInfo) {
  10645. return optionInfo.pluginDefaults && optionInfo.pluginDefaults[plugin.name];
  10646. }).reduce(function (reduced, optionInfo) {
  10647. return Object.assign(reduced, _defineProperty({}, optionInfo.name, optionInfo.pluginDefaults[plugin.name]));
  10648. }, {});
  10649. var mixedDefaults = Object.assign({}, defaults, pluginDefaults);
  10650. Object.keys(mixedDefaults).forEach(function (k) {
  10651. if (rawOptions[k] == null) {
  10652. rawOptions[k] = mixedDefaults[k];
  10653. }
  10654. });
  10655. if (rawOptions.parser === "json") {
  10656. rawOptions.trailingComma = "none";
  10657. }
  10658. return optionsNormalizer.normalizeApiOptions(rawOptions, supportOptions, Object.assign({
  10659. passThrough: Object.keys(hiddenDefaults)
  10660. }, opts));
  10661. }
  10662. function getPlugin(options) {
  10663. var astFormat = options.astFormat;
  10664. if (!astFormat) {
  10665. throw new Error("getPlugin() requires astFormat to be set");
  10666. }
  10667. var printerPlugin = options.plugins.find(function (plugin) {
  10668. return plugin.printers && plugin.printers[astFormat];
  10669. });
  10670. if (!printerPlugin) {
  10671. throw new Error("Couldn't find plugin for AST format \"".concat(astFormat, "\""));
  10672. }
  10673. return printerPlugin;
  10674. }
  10675. function getInterpreter(filepath) {
  10676. if (typeof filepath !== "string") {
  10677. return "";
  10678. }
  10679. var fd;
  10680. try {
  10681. fd = fs.openSync(filepath, "r");
  10682. } catch (err) {
  10683. return "";
  10684. }
  10685. try {
  10686. var liner = new readlines(fd);
  10687. var firstLine = liner.next().toString("utf8"); // #!/bin/env node, #!/usr/bin/env node
  10688. var m1 = firstLine.match(/^#!\/(?:usr\/)?bin\/env\s+(\S+)/);
  10689. if (m1) {
  10690. return m1[1];
  10691. } // #!/bin/node, #!/usr/bin/node, #!/usr/local/bin/node
  10692. var m2 = firstLine.match(/^#!\/(?:usr\/(?:local\/)?)?bin\/(\S+)/);
  10693. if (m2) {
  10694. return m2[1];
  10695. }
  10696. return "";
  10697. } catch (err) {
  10698. // There are some weird cases where paths are missing, causing Jest
  10699. // failures. It's unclear what these correspond to in the real world.
  10700. return "";
  10701. } finally {
  10702. try {
  10703. // There are some weird cases where paths are missing, causing Jest
  10704. // failures. It's unclear what these correspond to in the real world.
  10705. fs.closeSync(fd);
  10706. } catch (err) {// nop
  10707. }
  10708. }
  10709. }
  10710. function inferParser(filepath, plugins) {
  10711. var filepathParts = normalizePath(filepath).split("/");
  10712. var filename = filepathParts[filepathParts.length - 1].toLowerCase(); // If the file has no extension, we can try to infer the language from the
  10713. // interpreter in the shebang line, if any; but since this requires FS access,
  10714. // do it last.
  10715. var language = getSupportInfo$1(null, {
  10716. plugins: plugins
  10717. }).languages.find(function (language) {
  10718. return language.since !== null && (language.extensions && language.extensions.some(function (extension) {
  10719. return filename.endsWith(extension);
  10720. }) || language.filenames && language.filenames.find(function (name) {
  10721. return name.toLowerCase() === filename;
  10722. }) || filename.indexOf(".") === -1 && language.interpreters && language.interpreters.indexOf(getInterpreter(filepath)) !== -1);
  10723. });
  10724. return language && language.parsers[0];
  10725. }
  10726. var options = {
  10727. normalize: normalize,
  10728. hiddenDefaults: hiddenDefaults,
  10729. inferParser: inferParser
  10730. };
  10731. function massageAST(ast, options, parent) {
  10732. if (Array.isArray(ast)) {
  10733. return ast.map(function (e) {
  10734. return massageAST(e, options, parent);
  10735. }).filter(function (e) {
  10736. return e;
  10737. });
  10738. }
  10739. if (!ast || _typeof(ast) !== "object") {
  10740. return ast;
  10741. }
  10742. var newObj = {};
  10743. var _arr = Object.keys(ast);
  10744. for (var _i = 0; _i < _arr.length; _i++) {
  10745. var key = _arr[_i];
  10746. if (typeof ast[key] !== "function") {
  10747. newObj[key] = massageAST(ast[key], options, ast);
  10748. }
  10749. }
  10750. if (options.printer.massageAstNode) {
  10751. var result = options.printer.massageAstNode(ast, newObj, parent);
  10752. if (result === null) {
  10753. return undefined;
  10754. }
  10755. if (result) {
  10756. return result;
  10757. }
  10758. }
  10759. return newObj;
  10760. }
  10761. var massageAst = massageAST;
  10762. function assert() {}
  10763. assert.ok = function () {};
  10764. assert.strictEqual = function () {};
  10765. var assert$2 = Object.freeze({
  10766. default: assert
  10767. });
  10768. function concat$1(parts) {
  10769. return {
  10770. type: "concat",
  10771. parts: parts
  10772. };
  10773. }
  10774. function indent$1(contents) {
  10775. return {
  10776. type: "indent",
  10777. contents: contents
  10778. };
  10779. }
  10780. function align(n, contents) {
  10781. return {
  10782. type: "align",
  10783. contents: contents,
  10784. n: n
  10785. };
  10786. }
  10787. function group(contents, opts) {
  10788. opts = opts || {};
  10789. return {
  10790. type: "group",
  10791. id: opts.id,
  10792. contents: contents,
  10793. break: !!opts.shouldBreak,
  10794. expandedStates: opts.expandedStates
  10795. };
  10796. }
  10797. function dedentToRoot(contents) {
  10798. return align(-Infinity, contents);
  10799. }
  10800. function markAsRoot(contents) {
  10801. return align({
  10802. type: "root"
  10803. }, contents);
  10804. }
  10805. function dedent$1(contents) {
  10806. return align(-1, contents);
  10807. }
  10808. function conditionalGroup(states, opts) {
  10809. return group(states[0], Object.assign(opts || {}, {
  10810. expandedStates: states
  10811. }));
  10812. }
  10813. function fill(parts) {
  10814. return {
  10815. type: "fill",
  10816. parts: parts
  10817. };
  10818. }
  10819. function ifBreak(breakContents, flatContents, opts) {
  10820. opts = opts || {};
  10821. return {
  10822. type: "if-break",
  10823. breakContents: breakContents,
  10824. flatContents: flatContents,
  10825. groupId: opts.groupId
  10826. };
  10827. }
  10828. function lineSuffix$1(contents) {
  10829. return {
  10830. type: "line-suffix",
  10831. contents: contents
  10832. };
  10833. }
  10834. var lineSuffixBoundary = {
  10835. type: "line-suffix-boundary"
  10836. };
  10837. var breakParent$1 = {
  10838. type: "break-parent"
  10839. };
  10840. var trim = {
  10841. type: "trim"
  10842. };
  10843. var line$2 = {
  10844. type: "line"
  10845. };
  10846. var softline = {
  10847. type: "line",
  10848. soft: true
  10849. };
  10850. var hardline$1 = concat$1([{
  10851. type: "line",
  10852. hard: true
  10853. }, breakParent$1]);
  10854. var literalline = concat$1([{
  10855. type: "line",
  10856. hard: true,
  10857. literal: true
  10858. }, breakParent$1]);
  10859. var cursor$1 = {
  10860. type: "cursor",
  10861. placeholder: Symbol("cursor")
  10862. };
  10863. function join$1(sep, arr) {
  10864. var res = [];
  10865. for (var i = 0; i < arr.length; i++) {
  10866. if (i !== 0) {
  10867. res.push(sep);
  10868. }
  10869. res.push(arr[i]);
  10870. }
  10871. return concat$1(res);
  10872. }
  10873. function addAlignmentToDoc(doc, size, tabWidth) {
  10874. var aligned = doc;
  10875. if (size > 0) {
  10876. // Use indent to add tabs for all the levels of tabs we need
  10877. for (var i = 0; i < Math.floor(size / tabWidth); ++i) {
  10878. aligned = indent$1(aligned);
  10879. } // Use align for all the spaces that are needed
  10880. aligned = align(size % tabWidth, aligned); // size is absolute from 0 and not relative to the current
  10881. // indentation, so we use -Infinity to reset the indentation to 0
  10882. aligned = align(-Infinity, aligned);
  10883. }
  10884. return aligned;
  10885. }
  10886. var docBuilders = {
  10887. concat: concat$1,
  10888. join: join$1,
  10889. line: line$2,
  10890. softline: softline,
  10891. hardline: hardline$1,
  10892. literalline: literalline,
  10893. group: group,
  10894. conditionalGroup: conditionalGroup,
  10895. fill: fill,
  10896. lineSuffix: lineSuffix$1,
  10897. lineSuffixBoundary: lineSuffixBoundary,
  10898. cursor: cursor$1,
  10899. breakParent: breakParent$1,
  10900. ifBreak: ifBreak,
  10901. trim: trim,
  10902. indent: indent$1,
  10903. align: align,
  10904. addAlignmentToDoc: addAlignmentToDoc,
  10905. markAsRoot: markAsRoot,
  10906. dedentToRoot: dedentToRoot,
  10907. dedent: dedent$1
  10908. };
  10909. var ansiRegex = createCommonjsModule(function (module) {
  10910. 'use strict';
  10911. module.exports = function (options) {
  10912. options = Object.assign({
  10913. onlyFirst: false
  10914. }, options);
  10915. var pattern = ["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[a-zA-Z\\d]*)*)?\\u0007)", '(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))'].join('|');
  10916. return new RegExp(pattern, options.onlyFirst ? undefined : 'g');
  10917. };
  10918. });
  10919. var stripAnsi = function stripAnsi(input) {
  10920. return typeof input === 'string' ? input.replace(ansiRegex(), '') : input;
  10921. };
  10922. var isFullwidthCodePoint = createCommonjsModule(function (module) {
  10923. 'use strict';
  10924. /* eslint-disable yoda */
  10925. module.exports = function (x) {
  10926. if (Number.isNaN(x)) {
  10927. return false;
  10928. } // code points are derived from:
  10929. // http://www.unix.org/Public/UNIDATA/EastAsianWidth.txt
  10930. if (x >= 0x1100 && (x <= 0x115f || // Hangul Jamo
  10931. x === 0x2329 || // LEFT-POINTING ANGLE BRACKET
  10932. x === 0x232a || // RIGHT-POINTING ANGLE BRACKET
  10933. // CJK Radicals Supplement .. Enclosed CJK Letters and Months
  10934. 0x2e80 <= x && x <= 0x3247 && x !== 0x303f || // Enclosed CJK Letters and Months .. CJK Unified Ideographs Extension A
  10935. 0x3250 <= x && x <= 0x4dbf || // CJK Unified Ideographs .. Yi Radicals
  10936. 0x4e00 <= x && x <= 0xa4c6 || // Hangul Jamo Extended-A
  10937. 0xa960 <= x && x <= 0xa97c || // Hangul Syllables
  10938. 0xac00 <= x && x <= 0xd7a3 || // CJK Compatibility Ideographs
  10939. 0xf900 <= x && x <= 0xfaff || // Vertical Forms
  10940. 0xfe10 <= x && x <= 0xfe19 || // CJK Compatibility Forms .. Small Form Variants
  10941. 0xfe30 <= x && x <= 0xfe6b || // Halfwidth and Fullwidth Forms
  10942. 0xff01 <= x && x <= 0xff60 || 0xffe0 <= x && x <= 0xffe6 || // Kana Supplement
  10943. 0x1b000 <= x && x <= 0x1b001 || // Enclosed Ideographic Supplement
  10944. 0x1f200 <= x && x <= 0x1f251 || // CJK Unified Ideographs Extension B .. Tertiary Ideographic Plane
  10945. 0x20000 <= x && x <= 0x3fffd)) {
  10946. return true;
  10947. }
  10948. return false;
  10949. };
  10950. });
  10951. var emojiRegex = function emojiRegex() {
  10952. // https://mths.be/emoji
  10953. return /\uD83C\uDFF4(?:\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74)\uDB40\uDC7F|\u200D\u2620\uFE0F)|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC68(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDB0-\uDDB3])|(?:\uD83C[\uDFFB-\uDFFF])\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDB0-\uDDB3]))|\uD83D\uDC69\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDB0-\uDDB3])|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83D\uDC69(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2695\u2696\u2708]|\uD83D\uDC68(?:(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|(?:(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)\uFE0F|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDD6-\uDDDD])(?:(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\u200D[\u2640\u2642])|\uD83D\uDC69\u200D[\u2695\u2696\u2708])\uFE0F|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D\uDC68(?:\u200D(?:(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D[\uDC66\uDC67])|\uD83C[\uDFFB-\uDFFF])|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83D\uDC69(?:\uD83C[\uDFFB-\uDFFF])\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDB0-\uDDB3])|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83C\uDDF6\uD83C\uDDE6|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF4\uD83C\uDDF2|\uD83D\uDC69(?:\uD83C[\uDFFB-\uDFFF])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|[#\*0-9]\uFE0F\u20E3|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270A-\u270D]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC70\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDCAA\uDD74\uDD7A\uDD90\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD36\uDDB5\uDDB6\uDDD1-\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDEEB\uDEEC\uDEF4-\uDEF9]|\uD83E[\uDD10-\uDD3A\uDD3C-\uDD3E\uDD40-\uDD45\uDD47-\uDD70\uDD73-\uDD76\uDD7A\uDD7C-\uDDA2\uDDB0-\uDDB9\uDDC0-\uDDC2\uDDD0-\uDDFF])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEF9]|\uD83E[\uDD10-\uDD3A\uDD3C-\uDD3E\uDD40-\uDD45\uDD47-\uDD70\uDD73-\uDD76\uDD7A\uDD7C-\uDDA2\uDDB0-\uDDB9\uDDC0-\uDDC2\uDDD0-\uDDFF])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC69\uDC6E\uDC70-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD18-\uDD1C\uDD1E\uDD1F\uDD26\uDD30-\uDD39\uDD3D\uDD3E\uDDB5\uDDB6\uDDB8\uDDB9\uDDD1-\uDDDD])/g;
  10954. };
  10955. var stringWidth = createCommonjsModule(function (module) {
  10956. 'use strict';
  10957. var emojiRegex$$1 = emojiRegex();
  10958. module.exports = function (input) {
  10959. input = input.replace(emojiRegex$$1, ' ');
  10960. if (typeof input !== 'string' || input.length === 0) {
  10961. return 0;
  10962. }
  10963. input = stripAnsi(input);
  10964. var width = 0;
  10965. for (var i = 0; i < input.length; i++) {
  10966. var code = input.codePointAt(i); // Ignore control characters
  10967. if (code <= 0x1F || code >= 0x7F && code <= 0x9F) {
  10968. continue;
  10969. } // Ignore combining characters
  10970. if (code >= 0x300 && code <= 0x36F) {
  10971. continue;
  10972. } // Surrogates
  10973. if (code > 0xFFFF) {
  10974. i++;
  10975. }
  10976. width += isFullwidthCodePoint(code) ? 2 : 1;
  10977. }
  10978. return width;
  10979. };
  10980. });
  10981. var notAsciiRegex = /[^\x20-\x7F]/;
  10982. function isExportDeclaration(node) {
  10983. if (node) {
  10984. switch (node.type) {
  10985. case "ExportDefaultDeclaration":
  10986. case "ExportDefaultSpecifier":
  10987. case "DeclareExportDeclaration":
  10988. case "ExportNamedDeclaration":
  10989. case "ExportAllDeclaration":
  10990. return true;
  10991. }
  10992. }
  10993. return false;
  10994. }
  10995. function getParentExportDeclaration(path) {
  10996. var parentNode = path.getParentNode();
  10997. if (path.getName() === "declaration" && isExportDeclaration(parentNode)) {
  10998. return parentNode;
  10999. }
  11000. return null;
  11001. }
  11002. function getPenultimate(arr) {
  11003. if (arr.length > 1) {
  11004. return arr[arr.length - 2];
  11005. }
  11006. return null;
  11007. }
  11008. function getLast$3(arr) {
  11009. if (arr.length > 0) {
  11010. return arr[arr.length - 1];
  11011. }
  11012. return null;
  11013. }
  11014. function skip(chars) {
  11015. return function (text, index, opts) {
  11016. var backwards = opts && opts.backwards; // Allow `skip` functions to be threaded together without having
  11017. // to check for failures (did someone say monads?).
  11018. if (index === false) {
  11019. return false;
  11020. }
  11021. var length = text.length;
  11022. var cursor = index;
  11023. while (cursor >= 0 && cursor < length) {
  11024. var c = text.charAt(cursor);
  11025. if (chars instanceof RegExp) {
  11026. if (!chars.test(c)) {
  11027. return cursor;
  11028. }
  11029. } else if (chars.indexOf(c) === -1) {
  11030. return cursor;
  11031. }
  11032. backwards ? cursor-- : cursor++;
  11033. }
  11034. if (cursor === -1 || cursor === length) {
  11035. // If we reached the beginning or end of the file, return the
  11036. // out-of-bounds cursor. It's up to the caller to handle this
  11037. // correctly. We don't want to indicate `false` though if it
  11038. // actually skipped valid characters.
  11039. return cursor;
  11040. }
  11041. return false;
  11042. };
  11043. }
  11044. var skipWhitespace = skip(/\s/);
  11045. var skipSpaces = skip(" \t");
  11046. var skipToLineEnd = skip(",; \t");
  11047. var skipEverythingButNewLine = skip(/[^\r\n]/);
  11048. function skipInlineComment(text, index) {
  11049. if (index === false) {
  11050. return false;
  11051. }
  11052. if (text.charAt(index) === "/" && text.charAt(index + 1) === "*") {
  11053. for (var i = index + 2; i < text.length; ++i) {
  11054. if (text.charAt(i) === "*" && text.charAt(i + 1) === "/") {
  11055. return i + 2;
  11056. }
  11057. }
  11058. }
  11059. return index;
  11060. }
  11061. function skipTrailingComment(text, index) {
  11062. if (index === false) {
  11063. return false;
  11064. }
  11065. if (text.charAt(index) === "/" && text.charAt(index + 1) === "/") {
  11066. return skipEverythingButNewLine(text, index);
  11067. }
  11068. return index;
  11069. } // This one doesn't use the above helper function because it wants to
  11070. // test \r\n in order and `skip` doesn't support ordering and we only
  11071. // want to skip one newline. It's simple to implement.
  11072. function skipNewline$1(text, index, opts) {
  11073. var backwards = opts && opts.backwards;
  11074. if (index === false) {
  11075. return false;
  11076. }
  11077. var atIndex = text.charAt(index);
  11078. if (backwards) {
  11079. if (text.charAt(index - 1) === "\r" && atIndex === "\n") {
  11080. return index - 2;
  11081. }
  11082. if (atIndex === "\n" || atIndex === "\r" || atIndex === "\u2028" || atIndex === "\u2029") {
  11083. return index - 1;
  11084. }
  11085. } else {
  11086. if (atIndex === "\r" && text.charAt(index + 1) === "\n") {
  11087. return index + 2;
  11088. }
  11089. if (atIndex === "\n" || atIndex === "\r" || atIndex === "\u2028" || atIndex === "\u2029") {
  11090. return index + 1;
  11091. }
  11092. }
  11093. return index;
  11094. }
  11095. function hasNewline$1(text, index, opts) {
  11096. opts = opts || {};
  11097. var idx = skipSpaces(text, opts.backwards ? index - 1 : index, opts);
  11098. var idx2 = skipNewline$1(text, idx, opts);
  11099. return idx !== idx2;
  11100. }
  11101. function hasNewlineInRange(text, start, end) {
  11102. for (var i = start; i < end; ++i) {
  11103. if (text.charAt(i) === "\n") {
  11104. return true;
  11105. }
  11106. }
  11107. return false;
  11108. } // Note: this function doesn't ignore leading comments unlike isNextLineEmpty
  11109. function isPreviousLineEmpty$1(text, node, locStart) {
  11110. var idx = locStart(node) - 1;
  11111. idx = skipSpaces(text, idx, {
  11112. backwards: true
  11113. });
  11114. idx = skipNewline$1(text, idx, {
  11115. backwards: true
  11116. });
  11117. idx = skipSpaces(text, idx, {
  11118. backwards: true
  11119. });
  11120. var idx2 = skipNewline$1(text, idx, {
  11121. backwards: true
  11122. });
  11123. return idx !== idx2;
  11124. }
  11125. function isNextLineEmptyAfterIndex(text, index) {
  11126. var oldIdx = null;
  11127. var idx = index;
  11128. while (idx !== oldIdx) {
  11129. // We need to skip all the potential trailing inline comments
  11130. oldIdx = idx;
  11131. idx = skipToLineEnd(text, idx);
  11132. idx = skipInlineComment(text, idx);
  11133. idx = skipSpaces(text, idx);
  11134. }
  11135. idx = skipTrailingComment(text, idx);
  11136. idx = skipNewline$1(text, idx);
  11137. return hasNewline$1(text, idx);
  11138. }
  11139. function isNextLineEmpty(text, node, locEnd) {
  11140. return isNextLineEmptyAfterIndex(text, locEnd(node));
  11141. }
  11142. function getNextNonSpaceNonCommentCharacterIndexWithStartIndex(text, idx) {
  11143. var oldIdx = null;
  11144. while (idx !== oldIdx) {
  11145. oldIdx = idx;
  11146. idx = skipSpaces(text, idx);
  11147. idx = skipInlineComment(text, idx);
  11148. idx = skipTrailingComment(text, idx);
  11149. idx = skipNewline$1(text, idx);
  11150. }
  11151. return idx;
  11152. }
  11153. function getNextNonSpaceNonCommentCharacterIndex(text, node, locEnd) {
  11154. return getNextNonSpaceNonCommentCharacterIndexWithStartIndex(text, locEnd(node));
  11155. }
  11156. function getNextNonSpaceNonCommentCharacter(text, node, locEnd) {
  11157. return text.charAt(getNextNonSpaceNonCommentCharacterIndex(text, node, locEnd));
  11158. }
  11159. function hasSpaces(text, index, opts) {
  11160. opts = opts || {};
  11161. var idx = skipSpaces(text, opts.backwards ? index - 1 : index, opts);
  11162. return idx !== index;
  11163. }
  11164. function setLocStart(node, index) {
  11165. if (node.range) {
  11166. node.range[0] = index;
  11167. } else {
  11168. node.start = index;
  11169. }
  11170. }
  11171. function setLocEnd(node, index) {
  11172. if (node.range) {
  11173. node.range[1] = index;
  11174. } else {
  11175. node.end = index;
  11176. }
  11177. }
  11178. var PRECEDENCE = {};
  11179. [["|>"], ["||", "??"], ["&&"], ["|"], ["^"], ["&"], ["==", "===", "!=", "!=="], ["<", ">", "<=", ">=", "in", "instanceof"], [">>", "<<", ">>>"], ["+", "-"], ["*", "/", "%"], ["**"]].forEach(function (tier, i) {
  11180. tier.forEach(function (op) {
  11181. PRECEDENCE[op] = i;
  11182. });
  11183. });
  11184. function getPrecedence(op) {
  11185. return PRECEDENCE[op];
  11186. }
  11187. var equalityOperators = {
  11188. "==": true,
  11189. "!=": true,
  11190. "===": true,
  11191. "!==": true
  11192. };
  11193. var multiplicativeOperators = {
  11194. "*": true,
  11195. "/": true,
  11196. "%": true
  11197. };
  11198. var bitshiftOperators = {
  11199. ">>": true,
  11200. ">>>": true,
  11201. "<<": true
  11202. };
  11203. function shouldFlatten(parentOp, nodeOp) {
  11204. if (getPrecedence(nodeOp) !== getPrecedence(parentOp)) {
  11205. return false;
  11206. } // ** is right-associative
  11207. // x ** y ** z --> x ** (y ** z)
  11208. if (parentOp === "**") {
  11209. return false;
  11210. } // x == y == z --> (x == y) == z
  11211. if (equalityOperators[parentOp] && equalityOperators[nodeOp]) {
  11212. return false;
  11213. } // x * y % z --> (x * y) % z
  11214. if (nodeOp === "%" && multiplicativeOperators[parentOp] || parentOp === "%" && multiplicativeOperators[nodeOp]) {
  11215. return false;
  11216. } // x * y / z --> (x * y) / z
  11217. // x / y * z --> (x / y) * z
  11218. if (nodeOp !== parentOp && multiplicativeOperators[nodeOp] && multiplicativeOperators[parentOp]) {
  11219. return false;
  11220. } // x << y << z --> (x << y) << z
  11221. if (bitshiftOperators[parentOp] && bitshiftOperators[nodeOp]) {
  11222. return false;
  11223. }
  11224. return true;
  11225. }
  11226. function isBitwiseOperator(operator) {
  11227. return !!bitshiftOperators[operator] || operator === "|" || operator === "^" || operator === "&";
  11228. } // Tests if an expression starts with `{`, or (if forbidFunctionClassAndDoExpr
  11229. // holds) `function`, `class`, or `do {}`. Will be overzealous if there's
  11230. // already necessary grouping parentheses.
  11231. function startsWithNoLookaheadToken(node, forbidFunctionClassAndDoExpr) {
  11232. node = getLeftMost(node);
  11233. switch (node.type) {
  11234. case "FunctionExpression":
  11235. case "ClassExpression":
  11236. case "DoExpression":
  11237. return forbidFunctionClassAndDoExpr;
  11238. case "ObjectExpression":
  11239. return true;
  11240. case "MemberExpression":
  11241. return startsWithNoLookaheadToken(node.object, forbidFunctionClassAndDoExpr);
  11242. case "TaggedTemplateExpression":
  11243. if (node.tag.type === "FunctionExpression") {
  11244. // IIFEs are always already parenthesized
  11245. return false;
  11246. }
  11247. return startsWithNoLookaheadToken(node.tag, forbidFunctionClassAndDoExpr);
  11248. case "CallExpression":
  11249. if (node.callee.type === "FunctionExpression") {
  11250. // IIFEs are always already parenthesized
  11251. return false;
  11252. }
  11253. return startsWithNoLookaheadToken(node.callee, forbidFunctionClassAndDoExpr);
  11254. case "ConditionalExpression":
  11255. return startsWithNoLookaheadToken(node.test, forbidFunctionClassAndDoExpr);
  11256. case "UpdateExpression":
  11257. return !node.prefix && startsWithNoLookaheadToken(node.argument, forbidFunctionClassAndDoExpr);
  11258. case "BindExpression":
  11259. return node.object && startsWithNoLookaheadToken(node.object, forbidFunctionClassAndDoExpr);
  11260. case "SequenceExpression":
  11261. return startsWithNoLookaheadToken(node.expressions[0], forbidFunctionClassAndDoExpr);
  11262. case "TSAsExpression":
  11263. return startsWithNoLookaheadToken(node.expression, forbidFunctionClassAndDoExpr);
  11264. default:
  11265. return false;
  11266. }
  11267. }
  11268. function getLeftMost(node) {
  11269. if (node.left) {
  11270. return getLeftMost(node.left);
  11271. }
  11272. return node;
  11273. }
  11274. function getAlignmentSize(value, tabWidth, startIndex) {
  11275. startIndex = startIndex || 0;
  11276. var size = 0;
  11277. for (var i = startIndex; i < value.length; ++i) {
  11278. if (value[i] === "\t") {
  11279. // Tabs behave in a way that they are aligned to the nearest
  11280. // multiple of tabWidth:
  11281. // 0 -> 4, 1 -> 4, 2 -> 4, 3 -> 4
  11282. // 4 -> 8, 5 -> 8, 6 -> 8, 7 -> 8 ...
  11283. size = size + tabWidth - size % tabWidth;
  11284. } else {
  11285. size++;
  11286. }
  11287. }
  11288. return size;
  11289. }
  11290. function getIndentSize(value, tabWidth) {
  11291. var lastNewlineIndex = value.lastIndexOf("\n");
  11292. if (lastNewlineIndex === -1) {
  11293. return 0;
  11294. }
  11295. return getAlignmentSize( // All the leading whitespaces
  11296. value.slice(lastNewlineIndex + 1).match(/^[ \t]*/)[0], tabWidth);
  11297. }
  11298. function getPreferredQuote(raw, preferredQuote) {
  11299. // `rawContent` is the string exactly like it appeared in the input source
  11300. // code, without its enclosing quotes.
  11301. var rawContent = raw.slice(1, -1);
  11302. var double = {
  11303. quote: '"',
  11304. regex: /"/g
  11305. };
  11306. var single = {
  11307. quote: "'",
  11308. regex: /'/g
  11309. };
  11310. var preferred = preferredQuote === "'" ? single : double;
  11311. var alternate = preferred === single ? double : single;
  11312. var result = preferred.quote; // If `rawContent` contains at least one of the quote preferred for enclosing
  11313. // the string, we might want to enclose with the alternate quote instead, to
  11314. // minimize the number of escaped quotes.
  11315. if (rawContent.includes(preferred.quote) || rawContent.includes(alternate.quote)) {
  11316. var numPreferredQuotes = (rawContent.match(preferred.regex) || []).length;
  11317. var numAlternateQuotes = (rawContent.match(alternate.regex) || []).length;
  11318. result = numPreferredQuotes > numAlternateQuotes ? alternate.quote : preferred.quote;
  11319. }
  11320. return result;
  11321. }
  11322. function printString(raw, options, isDirectiveLiteral) {
  11323. // `rawContent` is the string exactly like it appeared in the input source
  11324. // code, without its enclosing quotes.
  11325. var rawContent = raw.slice(1, -1); // Check for the alternate quote, to determine if we're allowed to swap
  11326. // the quotes on a DirectiveLiteral.
  11327. var canChangeDirectiveQuotes = !rawContent.includes('"') && !rawContent.includes("'");
  11328. var enclosingQuote = options.parser === "json" ? '"' : options.__isInHtmlAttribute ? "'" : getPreferredQuote(raw, options.singleQuote ? "'" : '"'); // Directives are exact code unit sequences, which means that you can't
  11329. // change the escape sequences they use.
  11330. // See https://github.com/prettier/prettier/issues/1555
  11331. // and https://tc39.github.io/ecma262/#directive-prologue
  11332. if (isDirectiveLiteral) {
  11333. if (canChangeDirectiveQuotes) {
  11334. return enclosingQuote + rawContent + enclosingQuote;
  11335. }
  11336. return raw;
  11337. } // It might sound unnecessary to use `makeString` even if the string already
  11338. // is enclosed with `enclosingQuote`, but it isn't. The string could contain
  11339. // unnecessary escapes (such as in `"\'"`). Always using `makeString` makes
  11340. // sure that we consistently output the minimum amount of escaped quotes.
  11341. return makeString(rawContent, enclosingQuote, !(options.parser === "css" || options.parser === "less" || options.parser === "scss" || options.parentParser === "html" || options.parentParser === "vue" || options.parentParser === "angular"));
  11342. }
  11343. function makeString(rawContent, enclosingQuote, unescapeUnnecessaryEscapes) {
  11344. var otherQuote = enclosingQuote === '"' ? "'" : '"'; // Matches _any_ escape and unescaped quotes (both single and double).
  11345. var regex = /\\([\s\S])|(['"])/g; // Escape and unescape single and double quotes as needed to be able to
  11346. // enclose `rawContent` with `enclosingQuote`.
  11347. var newContent = rawContent.replace(regex, function (match, escaped, quote) {
  11348. // If we matched an escape, and the escaped character is a quote of the
  11349. // other type than we intend to enclose the string with, there's no need for
  11350. // it to be escaped, so return it _without_ the backslash.
  11351. if (escaped === otherQuote) {
  11352. return escaped;
  11353. } // If we matched an unescaped quote and it is of the _same_ type as we
  11354. // intend to enclose the string with, it must be escaped, so return it with
  11355. // a backslash.
  11356. if (quote === enclosingQuote) {
  11357. return "\\" + quote;
  11358. }
  11359. if (quote) {
  11360. return quote;
  11361. } // Unescape any unnecessarily escaped character.
  11362. // Adapted from https://github.com/eslint/eslint/blob/de0b4ad7bd820ade41b1f606008bea68683dc11a/lib/rules/no-useless-escape.js#L27
  11363. return unescapeUnnecessaryEscapes && /^[^\\nrvtbfux\r\n\u2028\u2029"'0-7]$/.test(escaped) ? escaped : "\\" + escaped;
  11364. });
  11365. return enclosingQuote + newContent + enclosingQuote;
  11366. }
  11367. function printNumber(rawNumber) {
  11368. return rawNumber.toLowerCase() // Remove unnecessary plus and zeroes from scientific notation.
  11369. .replace(/^([+-]?[\d.]+e)(?:\+|(-))?0*(\d)/, "$1$2$3") // Remove unnecessary scientific notation (1e0).
  11370. .replace(/^([+-]?[\d.]+)e[+-]?0+$/, "$1") // Make sure numbers always start with a digit.
  11371. .replace(/^([+-])?\./, "$10.") // Remove extraneous trailing decimal zeroes.
  11372. .replace(/(\.\d+?)0+(?=e|$)/, "$1") // Remove trailing dot.
  11373. .replace(/\.(?=e|$)/, "");
  11374. }
  11375. function getMaxContinuousCount(str, target) {
  11376. var results = str.match(new RegExp("(".concat(escapeStringRegexp(target), ")+"), "g"));
  11377. if (results === null) {
  11378. return 0;
  11379. }
  11380. return results.reduce(function (maxCount, result) {
  11381. return Math.max(maxCount, result.length / target.length);
  11382. }, 0);
  11383. }
  11384. function getStringWidth$1(text) {
  11385. if (!text) {
  11386. return 0;
  11387. } // shortcut to avoid needless string `RegExp`s, replacements, and allocations within `string-width`
  11388. if (!notAsciiRegex.test(text)) {
  11389. return text.length;
  11390. }
  11391. return stringWidth(text);
  11392. }
  11393. function hasIgnoreComment(path) {
  11394. var node = path.getValue();
  11395. return hasNodeIgnoreComment(node);
  11396. }
  11397. function hasNodeIgnoreComment(node) {
  11398. return node && node.comments && node.comments.length > 0 && node.comments.some(function (comment) {
  11399. return comment.value.trim() === "prettier-ignore";
  11400. });
  11401. }
  11402. function matchAncestorTypes(path, types, index) {
  11403. index = index || 0;
  11404. types = types.slice();
  11405. while (types.length) {
  11406. var parent = path.getParentNode(index);
  11407. var type = types.shift();
  11408. if (!parent || parent.type !== type) {
  11409. return false;
  11410. }
  11411. index++;
  11412. }
  11413. return true;
  11414. }
  11415. function addCommentHelper(node, comment) {
  11416. var comments = node.comments || (node.comments = []);
  11417. comments.push(comment);
  11418. comment.printed = false; // For some reason, TypeScript parses `// x` inside of JSXText as a comment
  11419. // We already "print" it via the raw text, we don't need to re-print it as a
  11420. // comment
  11421. if (node.type === "JSXText") {
  11422. comment.printed = true;
  11423. }
  11424. }
  11425. function addLeadingComment$1(node, comment) {
  11426. comment.leading = true;
  11427. comment.trailing = false;
  11428. addCommentHelper(node, comment);
  11429. }
  11430. function addDanglingComment$1(node, comment) {
  11431. comment.leading = false;
  11432. comment.trailing = false;
  11433. addCommentHelper(node, comment);
  11434. }
  11435. function addTrailingComment$1(node, comment) {
  11436. comment.leading = false;
  11437. comment.trailing = true;
  11438. addCommentHelper(node, comment);
  11439. }
  11440. function isWithinParentArrayProperty(path, propertyName) {
  11441. var node = path.getValue();
  11442. var parent = path.getParentNode();
  11443. if (parent == null) {
  11444. return false;
  11445. }
  11446. if (!Array.isArray(parent[propertyName])) {
  11447. return false;
  11448. }
  11449. var key = path.getName();
  11450. return parent[propertyName][key] === node;
  11451. }
  11452. function replaceEndOfLineWith(text, replacement) {
  11453. var parts = [];
  11454. var _iteratorNormalCompletion = true;
  11455. var _didIteratorError = false;
  11456. var _iteratorError = undefined;
  11457. try {
  11458. for (var _iterator = text.split("\n")[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  11459. var part = _step.value;
  11460. if (parts.length !== 0) {
  11461. parts.push(replacement);
  11462. }
  11463. parts.push(part);
  11464. }
  11465. } catch (err) {
  11466. _didIteratorError = true;
  11467. _iteratorError = err;
  11468. } finally {
  11469. try {
  11470. if (!_iteratorNormalCompletion && _iterator.return != null) {
  11471. _iterator.return();
  11472. }
  11473. } finally {
  11474. if (_didIteratorError) {
  11475. throw _iteratorError;
  11476. }
  11477. }
  11478. }
  11479. return parts;
  11480. }
  11481. var util = {
  11482. replaceEndOfLineWith: replaceEndOfLineWith,
  11483. getStringWidth: getStringWidth$1,
  11484. getMaxContinuousCount: getMaxContinuousCount,
  11485. getPrecedence: getPrecedence,
  11486. shouldFlatten: shouldFlatten,
  11487. isBitwiseOperator: isBitwiseOperator,
  11488. isExportDeclaration: isExportDeclaration,
  11489. getParentExportDeclaration: getParentExportDeclaration,
  11490. getPenultimate: getPenultimate,
  11491. getLast: getLast$3,
  11492. getNextNonSpaceNonCommentCharacterIndexWithStartIndex: getNextNonSpaceNonCommentCharacterIndexWithStartIndex,
  11493. getNextNonSpaceNonCommentCharacterIndex: getNextNonSpaceNonCommentCharacterIndex,
  11494. getNextNonSpaceNonCommentCharacter: getNextNonSpaceNonCommentCharacter,
  11495. skip: skip,
  11496. skipWhitespace: skipWhitespace,
  11497. skipSpaces: skipSpaces,
  11498. skipToLineEnd: skipToLineEnd,
  11499. skipEverythingButNewLine: skipEverythingButNewLine,
  11500. skipInlineComment: skipInlineComment,
  11501. skipTrailingComment: skipTrailingComment,
  11502. skipNewline: skipNewline$1,
  11503. isNextLineEmptyAfterIndex: isNextLineEmptyAfterIndex,
  11504. isNextLineEmpty: isNextLineEmpty,
  11505. isPreviousLineEmpty: isPreviousLineEmpty$1,
  11506. hasNewline: hasNewline$1,
  11507. hasNewlineInRange: hasNewlineInRange,
  11508. hasSpaces: hasSpaces,
  11509. setLocStart: setLocStart,
  11510. setLocEnd: setLocEnd,
  11511. startsWithNoLookaheadToken: startsWithNoLookaheadToken,
  11512. getAlignmentSize: getAlignmentSize,
  11513. getIndentSize: getIndentSize,
  11514. getPreferredQuote: getPreferredQuote,
  11515. printString: printString,
  11516. printNumber: printNumber,
  11517. hasIgnoreComment: hasIgnoreComment,
  11518. hasNodeIgnoreComment: hasNodeIgnoreComment,
  11519. makeString: makeString,
  11520. matchAncestorTypes: matchAncestorTypes,
  11521. addLeadingComment: addLeadingComment$1,
  11522. addDanglingComment: addDanglingComment$1,
  11523. addTrailingComment: addTrailingComment$1,
  11524. isWithinParentArrayProperty: isWithinParentArrayProperty
  11525. };
  11526. function guessEndOfLine$1(text) {
  11527. var index = text.indexOf("\r");
  11528. if (index >= 0) {
  11529. return text.charAt(index + 1) === "\n" ? "crlf" : "cr";
  11530. }
  11531. return "lf";
  11532. }
  11533. function convertEndOfLineToChars$2(value) {
  11534. switch (value) {
  11535. case "cr":
  11536. return "\r";
  11537. case "crlf":
  11538. return "\r\n";
  11539. default:
  11540. return "\n";
  11541. }
  11542. }
  11543. var endOfLine = {
  11544. guessEndOfLine: guessEndOfLine$1,
  11545. convertEndOfLineToChars: convertEndOfLineToChars$2
  11546. };
  11547. var getStringWidth = util.getStringWidth;
  11548. var convertEndOfLineToChars$1 = endOfLine.convertEndOfLineToChars;
  11549. var concat$2 = docBuilders.concat;
  11550. var fill$1 = docBuilders.fill;
  11551. var cursor$2 = docBuilders.cursor;
  11552. /** @type {{[groupId: PropertyKey]: MODE}} */
  11553. var groupModeMap;
  11554. var MODE_BREAK = 1;
  11555. var MODE_FLAT = 2;
  11556. function rootIndent() {
  11557. return {
  11558. value: "",
  11559. length: 0,
  11560. queue: []
  11561. };
  11562. }
  11563. function makeIndent(ind, options) {
  11564. return generateInd(ind, {
  11565. type: "indent"
  11566. }, options);
  11567. }
  11568. function makeAlign(ind, n, options) {
  11569. return n === -Infinity ? ind.root || rootIndent() : n < 0 ? generateInd(ind, {
  11570. type: "dedent"
  11571. }, options) : !n ? ind : n.type === "root" ? Object.assign({}, ind, {
  11572. root: ind
  11573. }) : typeof n === "string" ? generateInd(ind, {
  11574. type: "stringAlign",
  11575. n: n
  11576. }, options) : generateInd(ind, {
  11577. type: "numberAlign",
  11578. n: n
  11579. }, options);
  11580. }
  11581. function generateInd(ind, newPart, options) {
  11582. var queue = newPart.type === "dedent" ? ind.queue.slice(0, -1) : ind.queue.concat(newPart);
  11583. var value = "";
  11584. var length = 0;
  11585. var lastTabs = 0;
  11586. var lastSpaces = 0;
  11587. var _iteratorNormalCompletion = true;
  11588. var _didIteratorError = false;
  11589. var _iteratorError = undefined;
  11590. try {
  11591. for (var _iterator = queue[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  11592. var part = _step.value;
  11593. switch (part.type) {
  11594. case "indent":
  11595. flush();
  11596. if (options.useTabs) {
  11597. addTabs(1);
  11598. } else {
  11599. addSpaces(options.tabWidth);
  11600. }
  11601. break;
  11602. case "stringAlign":
  11603. flush();
  11604. value += part.n;
  11605. length += part.n.length;
  11606. break;
  11607. case "numberAlign":
  11608. lastTabs += 1;
  11609. lastSpaces += part.n;
  11610. break;
  11611. /* istanbul ignore next */
  11612. default:
  11613. throw new Error("Unexpected type '".concat(part.type, "'"));
  11614. }
  11615. }
  11616. } catch (err) {
  11617. _didIteratorError = true;
  11618. _iteratorError = err;
  11619. } finally {
  11620. try {
  11621. if (!_iteratorNormalCompletion && _iterator.return != null) {
  11622. _iterator.return();
  11623. }
  11624. } finally {
  11625. if (_didIteratorError) {
  11626. throw _iteratorError;
  11627. }
  11628. }
  11629. }
  11630. flushSpaces();
  11631. return Object.assign({}, ind, {
  11632. value: value,
  11633. length: length,
  11634. queue: queue
  11635. });
  11636. function addTabs(count) {
  11637. value += "\t".repeat(count);
  11638. length += options.tabWidth * count;
  11639. }
  11640. function addSpaces(count) {
  11641. value += " ".repeat(count);
  11642. length += count;
  11643. }
  11644. function flush() {
  11645. if (options.useTabs) {
  11646. flushTabs();
  11647. } else {
  11648. flushSpaces();
  11649. }
  11650. }
  11651. function flushTabs() {
  11652. if (lastTabs > 0) {
  11653. addTabs(lastTabs);
  11654. }
  11655. resetLast();
  11656. }
  11657. function flushSpaces() {
  11658. if (lastSpaces > 0) {
  11659. addSpaces(lastSpaces);
  11660. }
  11661. resetLast();
  11662. }
  11663. function resetLast() {
  11664. lastTabs = 0;
  11665. lastSpaces = 0;
  11666. }
  11667. }
  11668. function trim$1(out) {
  11669. if (out.length === 0) {
  11670. return 0;
  11671. }
  11672. var trimCount = 0; // Trim whitespace at the end of line
  11673. while (out.length > 0 && typeof out[out.length - 1] === "string" && out[out.length - 1].match(/^[ \t]*$/)) {
  11674. trimCount += out.pop().length;
  11675. }
  11676. if (out.length && typeof out[out.length - 1] === "string") {
  11677. var trimmed = out[out.length - 1].replace(/[ \t]*$/, "");
  11678. trimCount += out[out.length - 1].length - trimmed.length;
  11679. out[out.length - 1] = trimmed;
  11680. }
  11681. return trimCount;
  11682. }
  11683. function fits(next, restCommands, width, options, mustBeFlat) {
  11684. var restIdx = restCommands.length;
  11685. var cmds = [next]; // `out` is only used for width counting because `trim` requires to look
  11686. // backwards for space characters.
  11687. var out = [];
  11688. while (width >= 0) {
  11689. if (cmds.length === 0) {
  11690. if (restIdx === 0) {
  11691. return true;
  11692. }
  11693. cmds.push(restCommands[restIdx - 1]);
  11694. restIdx--;
  11695. continue;
  11696. }
  11697. var x = cmds.pop();
  11698. var ind = x[0];
  11699. var mode = x[1];
  11700. var doc = x[2];
  11701. if (typeof doc === "string") {
  11702. out.push(doc);
  11703. width -= getStringWidth(doc);
  11704. } else {
  11705. switch (doc.type) {
  11706. case "concat":
  11707. for (var i = doc.parts.length - 1; i >= 0; i--) {
  11708. cmds.push([ind, mode, doc.parts[i]]);
  11709. }
  11710. break;
  11711. case "indent":
  11712. cmds.push([makeIndent(ind, options), mode, doc.contents]);
  11713. break;
  11714. case "align":
  11715. cmds.push([makeAlign(ind, doc.n, options), mode, doc.contents]);
  11716. break;
  11717. case "trim":
  11718. width += trim$1(out);
  11719. break;
  11720. case "group":
  11721. if (mustBeFlat && doc.break) {
  11722. return false;
  11723. }
  11724. cmds.push([ind, doc.break ? MODE_BREAK : mode, doc.contents]);
  11725. if (doc.id) {
  11726. groupModeMap[doc.id] = cmds[cmds.length - 1][1];
  11727. }
  11728. break;
  11729. case "fill":
  11730. for (var _i = doc.parts.length - 1; _i >= 0; _i--) {
  11731. cmds.push([ind, mode, doc.parts[_i]]);
  11732. }
  11733. break;
  11734. case "if-break":
  11735. {
  11736. var groupMode = doc.groupId ? groupModeMap[doc.groupId] : mode;
  11737. if (groupMode === MODE_BREAK) {
  11738. if (doc.breakContents) {
  11739. cmds.push([ind, mode, doc.breakContents]);
  11740. }
  11741. }
  11742. if (groupMode === MODE_FLAT) {
  11743. if (doc.flatContents) {
  11744. cmds.push([ind, mode, doc.flatContents]);
  11745. }
  11746. }
  11747. break;
  11748. }
  11749. case "line":
  11750. switch (mode) {
  11751. // fallthrough
  11752. case MODE_FLAT:
  11753. if (!doc.hard) {
  11754. if (!doc.soft) {
  11755. out.push(" ");
  11756. width -= 1;
  11757. }
  11758. break;
  11759. }
  11760. return true;
  11761. case MODE_BREAK:
  11762. return true;
  11763. }
  11764. break;
  11765. }
  11766. }
  11767. }
  11768. return false;
  11769. }
  11770. function printDocToString(doc, options) {
  11771. groupModeMap = {};
  11772. var width = options.printWidth;
  11773. var newLine = convertEndOfLineToChars$1(options.endOfLine);
  11774. var pos = 0; // cmds is basically a stack. We've turned a recursive call into a
  11775. // while loop which is much faster. The while loop below adds new
  11776. // cmds to the array instead of recursively calling `print`.
  11777. var cmds = [[rootIndent(), MODE_BREAK, doc]];
  11778. var out = [];
  11779. var shouldRemeasure = false;
  11780. var lineSuffix = [];
  11781. while (cmds.length !== 0) {
  11782. var x = cmds.pop();
  11783. var ind = x[0];
  11784. var mode = x[1];
  11785. var _doc = x[2];
  11786. if (typeof _doc === "string") {
  11787. out.push(_doc);
  11788. pos += getStringWidth(_doc);
  11789. } else {
  11790. switch (_doc.type) {
  11791. case "cursor":
  11792. out.push(cursor$2.placeholder);
  11793. break;
  11794. case "concat":
  11795. for (var i = _doc.parts.length - 1; i >= 0; i--) {
  11796. cmds.push([ind, mode, _doc.parts[i]]);
  11797. }
  11798. break;
  11799. case "indent":
  11800. cmds.push([makeIndent(ind, options), mode, _doc.contents]);
  11801. break;
  11802. case "align":
  11803. cmds.push([makeAlign(ind, _doc.n, options), mode, _doc.contents]);
  11804. break;
  11805. case "trim":
  11806. pos -= trim$1(out);
  11807. break;
  11808. case "group":
  11809. switch (mode) {
  11810. case MODE_FLAT:
  11811. if (!shouldRemeasure) {
  11812. cmds.push([ind, _doc.break ? MODE_BREAK : MODE_FLAT, _doc.contents]);
  11813. break;
  11814. }
  11815. // fallthrough
  11816. case MODE_BREAK:
  11817. {
  11818. shouldRemeasure = false;
  11819. var next = [ind, MODE_FLAT, _doc.contents];
  11820. var rem = width - pos;
  11821. if (!_doc.break && fits(next, cmds, rem, options)) {
  11822. cmds.push(next);
  11823. } else {
  11824. // Expanded states are a rare case where a document
  11825. // can manually provide multiple representations of
  11826. // itself. It provides an array of documents
  11827. // going from the least expanded (most flattened)
  11828. // representation first to the most expanded. If a
  11829. // group has these, we need to manually go through
  11830. // these states and find the first one that fits.
  11831. if (_doc.expandedStates) {
  11832. var mostExpanded = _doc.expandedStates[_doc.expandedStates.length - 1];
  11833. if (_doc.break) {
  11834. cmds.push([ind, MODE_BREAK, mostExpanded]);
  11835. break;
  11836. } else {
  11837. for (var _i2 = 1; _i2 < _doc.expandedStates.length + 1; _i2++) {
  11838. if (_i2 >= _doc.expandedStates.length) {
  11839. cmds.push([ind, MODE_BREAK, mostExpanded]);
  11840. break;
  11841. } else {
  11842. var state = _doc.expandedStates[_i2];
  11843. var cmd = [ind, MODE_FLAT, state];
  11844. if (fits(cmd, cmds, rem, options)) {
  11845. cmds.push(cmd);
  11846. break;
  11847. }
  11848. }
  11849. }
  11850. }
  11851. } else {
  11852. cmds.push([ind, MODE_BREAK, _doc.contents]);
  11853. }
  11854. }
  11855. break;
  11856. }
  11857. }
  11858. if (_doc.id) {
  11859. groupModeMap[_doc.id] = cmds[cmds.length - 1][1];
  11860. }
  11861. break;
  11862. // Fills each line with as much code as possible before moving to a new
  11863. // line with the same indentation.
  11864. //
  11865. // Expects doc.parts to be an array of alternating content and
  11866. // whitespace. The whitespace contains the linebreaks.
  11867. //
  11868. // For example:
  11869. // ["I", line, "love", line, "monkeys"]
  11870. // or
  11871. // [{ type: group, ... }, softline, { type: group, ... }]
  11872. //
  11873. // It uses this parts structure to handle three main layout cases:
  11874. // * The first two content items fit on the same line without
  11875. // breaking
  11876. // -> output the first content item and the whitespace "flat".
  11877. // * Only the first content item fits on the line without breaking
  11878. // -> output the first content item "flat" and the whitespace with
  11879. // "break".
  11880. // * Neither content item fits on the line without breaking
  11881. // -> output the first content item and the whitespace with "break".
  11882. case "fill":
  11883. {
  11884. var _rem = width - pos;
  11885. var parts = _doc.parts;
  11886. if (parts.length === 0) {
  11887. break;
  11888. }
  11889. var content = parts[0];
  11890. var contentFlatCmd = [ind, MODE_FLAT, content];
  11891. var contentBreakCmd = [ind, MODE_BREAK, content];
  11892. var contentFits = fits(contentFlatCmd, [], _rem, options, true);
  11893. if (parts.length === 1) {
  11894. if (contentFits) {
  11895. cmds.push(contentFlatCmd);
  11896. } else {
  11897. cmds.push(contentBreakCmd);
  11898. }
  11899. break;
  11900. }
  11901. var whitespace = parts[1];
  11902. var whitespaceFlatCmd = [ind, MODE_FLAT, whitespace];
  11903. var whitespaceBreakCmd = [ind, MODE_BREAK, whitespace];
  11904. if (parts.length === 2) {
  11905. if (contentFits) {
  11906. cmds.push(whitespaceFlatCmd);
  11907. cmds.push(contentFlatCmd);
  11908. } else {
  11909. cmds.push(whitespaceBreakCmd);
  11910. cmds.push(contentBreakCmd);
  11911. }
  11912. break;
  11913. } // At this point we've handled the first pair (context, separator)
  11914. // and will create a new fill doc for the rest of the content.
  11915. // Ideally we wouldn't mutate the array here but coping all the
  11916. // elements to a new array would make this algorithm quadratic,
  11917. // which is unusable for large arrays (e.g. large texts in JSX).
  11918. parts.splice(0, 2);
  11919. var remainingCmd = [ind, mode, fill$1(parts)];
  11920. var secondContent = parts[0];
  11921. var firstAndSecondContentFlatCmd = [ind, MODE_FLAT, concat$2([content, whitespace, secondContent])];
  11922. var firstAndSecondContentFits = fits(firstAndSecondContentFlatCmd, [], _rem, options, true);
  11923. if (firstAndSecondContentFits) {
  11924. cmds.push(remainingCmd);
  11925. cmds.push(whitespaceFlatCmd);
  11926. cmds.push(contentFlatCmd);
  11927. } else if (contentFits) {
  11928. cmds.push(remainingCmd);
  11929. cmds.push(whitespaceBreakCmd);
  11930. cmds.push(contentFlatCmd);
  11931. } else {
  11932. cmds.push(remainingCmd);
  11933. cmds.push(whitespaceBreakCmd);
  11934. cmds.push(contentBreakCmd);
  11935. }
  11936. break;
  11937. }
  11938. case "if-break":
  11939. {
  11940. var groupMode = _doc.groupId ? groupModeMap[_doc.groupId] : mode;
  11941. if (groupMode === MODE_BREAK) {
  11942. if (_doc.breakContents) {
  11943. cmds.push([ind, mode, _doc.breakContents]);
  11944. }
  11945. }
  11946. if (groupMode === MODE_FLAT) {
  11947. if (_doc.flatContents) {
  11948. cmds.push([ind, mode, _doc.flatContents]);
  11949. }
  11950. }
  11951. break;
  11952. }
  11953. case "line-suffix":
  11954. lineSuffix.push([ind, mode, _doc.contents]);
  11955. break;
  11956. case "line-suffix-boundary":
  11957. if (lineSuffix.length > 0) {
  11958. cmds.push([ind, mode, {
  11959. type: "line",
  11960. hard: true
  11961. }]);
  11962. }
  11963. break;
  11964. case "line":
  11965. switch (mode) {
  11966. case MODE_FLAT:
  11967. if (!_doc.hard) {
  11968. if (!_doc.soft) {
  11969. out.push(" ");
  11970. pos += 1;
  11971. }
  11972. break;
  11973. } else {
  11974. // This line was forced into the output even if we
  11975. // were in flattened mode, so we need to tell the next
  11976. // group that no matter what, it needs to remeasure
  11977. // because the previous measurement didn't accurately
  11978. // capture the entire expression (this is necessary
  11979. // for nested groups)
  11980. shouldRemeasure = true;
  11981. }
  11982. // fallthrough
  11983. case MODE_BREAK:
  11984. if (lineSuffix.length) {
  11985. cmds.push([ind, mode, _doc]);
  11986. [].push.apply(cmds, lineSuffix.reverse());
  11987. lineSuffix = [];
  11988. break;
  11989. }
  11990. if (_doc.literal) {
  11991. if (ind.root) {
  11992. out.push(newLine, ind.root.value);
  11993. pos = ind.root.length;
  11994. } else {
  11995. out.push(newLine);
  11996. pos = 0;
  11997. }
  11998. } else {
  11999. pos -= trim$1(out);
  12000. out.push(newLine + ind.value);
  12001. pos = ind.length;
  12002. }
  12003. break;
  12004. }
  12005. break;
  12006. default:
  12007. }
  12008. }
  12009. }
  12010. var cursorPlaceholderIndex = out.indexOf(cursor$2.placeholder);
  12011. if (cursorPlaceholderIndex !== -1) {
  12012. var otherCursorPlaceholderIndex = out.indexOf(cursor$2.placeholder, cursorPlaceholderIndex + 1);
  12013. var beforeCursor = out.slice(0, cursorPlaceholderIndex).join("");
  12014. var aroundCursor = out.slice(cursorPlaceholderIndex + 1, otherCursorPlaceholderIndex).join("");
  12015. var afterCursor = out.slice(otherCursorPlaceholderIndex + 1).join("");
  12016. return {
  12017. formatted: beforeCursor + aroundCursor + afterCursor,
  12018. cursorNodeStart: beforeCursor.length,
  12019. cursorNodeText: aroundCursor
  12020. };
  12021. }
  12022. return {
  12023. formatted: out.join("")
  12024. };
  12025. }
  12026. var docPrinter = {
  12027. printDocToString: printDocToString
  12028. };
  12029. var traverseDocOnExitStackMarker = {};
  12030. function traverseDoc(doc, onEnter, onExit, shouldTraverseConditionalGroups) {
  12031. var docsStack = [doc];
  12032. while (docsStack.length !== 0) {
  12033. var _doc = docsStack.pop();
  12034. if (_doc === traverseDocOnExitStackMarker) {
  12035. onExit(docsStack.pop());
  12036. continue;
  12037. }
  12038. var shouldRecurse = true;
  12039. if (onEnter) {
  12040. if (onEnter(_doc) === false) {
  12041. shouldRecurse = false;
  12042. }
  12043. }
  12044. if (onExit) {
  12045. docsStack.push(_doc);
  12046. docsStack.push(traverseDocOnExitStackMarker);
  12047. }
  12048. if (shouldRecurse) {
  12049. // When there are multiple parts to process,
  12050. // the parts need to be pushed onto the stack in reverse order,
  12051. // so that they are processed in the original order
  12052. // when the stack is popped.
  12053. if (_doc.type === "concat" || _doc.type === "fill") {
  12054. for (var ic = _doc.parts.length, i = ic - 1; i >= 0; --i) {
  12055. docsStack.push(_doc.parts[i]);
  12056. }
  12057. } else if (_doc.type === "if-break") {
  12058. if (_doc.flatContents) {
  12059. docsStack.push(_doc.flatContents);
  12060. }
  12061. if (_doc.breakContents) {
  12062. docsStack.push(_doc.breakContents);
  12063. }
  12064. } else if (_doc.type === "group" && _doc.expandedStates) {
  12065. if (shouldTraverseConditionalGroups) {
  12066. for (var _ic = _doc.expandedStates.length, _i = _ic - 1; _i >= 0; --_i) {
  12067. docsStack.push(_doc.expandedStates[_i]);
  12068. }
  12069. } else {
  12070. docsStack.push(_doc.contents);
  12071. }
  12072. } else if (_doc.contents) {
  12073. docsStack.push(_doc.contents);
  12074. }
  12075. }
  12076. }
  12077. }
  12078. function mapDoc$1(doc, cb) {
  12079. if (doc.type === "concat" || doc.type === "fill") {
  12080. var parts = doc.parts.map(function (part) {
  12081. return mapDoc$1(part, cb);
  12082. });
  12083. return cb(Object.assign({}, doc, {
  12084. parts: parts
  12085. }));
  12086. } else if (doc.type === "if-break") {
  12087. var breakContents = doc.breakContents && mapDoc$1(doc.breakContents, cb);
  12088. var flatContents = doc.flatContents && mapDoc$1(doc.flatContents, cb);
  12089. return cb(Object.assign({}, doc, {
  12090. breakContents: breakContents,
  12091. flatContents: flatContents
  12092. }));
  12093. } else if (doc.contents) {
  12094. var contents = mapDoc$1(doc.contents, cb);
  12095. return cb(Object.assign({}, doc, {
  12096. contents: contents
  12097. }));
  12098. }
  12099. return cb(doc);
  12100. }
  12101. function findInDoc(doc, fn, defaultValue) {
  12102. var result = defaultValue;
  12103. var hasStopped = false;
  12104. function findInDocOnEnterFn(doc) {
  12105. var maybeResult = fn(doc);
  12106. if (maybeResult !== undefined) {
  12107. hasStopped = true;
  12108. result = maybeResult;
  12109. }
  12110. if (hasStopped) {
  12111. return false;
  12112. }
  12113. }
  12114. traverseDoc(doc, findInDocOnEnterFn);
  12115. return result;
  12116. }
  12117. function isEmpty(n) {
  12118. return typeof n === "string" && n.length === 0;
  12119. }
  12120. function isLineNextFn(doc) {
  12121. if (typeof doc === "string") {
  12122. return false;
  12123. }
  12124. if (doc.type === "line") {
  12125. return true;
  12126. }
  12127. }
  12128. function isLineNext(doc) {
  12129. return findInDoc(doc, isLineNextFn, false);
  12130. }
  12131. function willBreakFn(doc) {
  12132. if (doc.type === "group" && doc.break) {
  12133. return true;
  12134. }
  12135. if (doc.type === "line" && doc.hard) {
  12136. return true;
  12137. }
  12138. if (doc.type === "break-parent") {
  12139. return true;
  12140. }
  12141. }
  12142. function willBreak(doc) {
  12143. return findInDoc(doc, willBreakFn, false);
  12144. }
  12145. function breakParentGroup(groupStack) {
  12146. if (groupStack.length > 0) {
  12147. var parentGroup = groupStack[groupStack.length - 1]; // Breaks are not propagated through conditional groups because
  12148. // the user is expected to manually handle what breaks.
  12149. if (!parentGroup.expandedStates) {
  12150. parentGroup.break = true;
  12151. }
  12152. }
  12153. return null;
  12154. }
  12155. function propagateBreaks(doc) {
  12156. var alreadyVisitedSet = new Set();
  12157. var groupStack = [];
  12158. function propagateBreaksOnEnterFn(doc) {
  12159. if (doc.type === "break-parent") {
  12160. breakParentGroup(groupStack);
  12161. }
  12162. if (doc.type === "group") {
  12163. groupStack.push(doc);
  12164. if (alreadyVisitedSet.has(doc)) {
  12165. return false;
  12166. }
  12167. alreadyVisitedSet.add(doc);
  12168. }
  12169. }
  12170. function propagateBreaksOnExitFn(doc) {
  12171. if (doc.type === "group") {
  12172. var group = groupStack.pop();
  12173. if (group.break) {
  12174. breakParentGroup(groupStack);
  12175. }
  12176. }
  12177. }
  12178. traverseDoc(doc, propagateBreaksOnEnterFn, propagateBreaksOnExitFn,
  12179. /* shouldTraverseConditionalGroups */
  12180. true);
  12181. }
  12182. function removeLinesFn(doc) {
  12183. // Force this doc into flat mode by statically converting all
  12184. // lines into spaces (or soft lines into nothing). Hard lines
  12185. // should still output because there's too great of a chance
  12186. // of breaking existing assumptions otherwise.
  12187. if (doc.type === "line" && !doc.hard) {
  12188. return doc.soft ? "" : " ";
  12189. } else if (doc.type === "if-break") {
  12190. return doc.flatContents || "";
  12191. }
  12192. return doc;
  12193. }
  12194. function removeLines(doc) {
  12195. return mapDoc$1(doc, removeLinesFn);
  12196. }
  12197. function stripTrailingHardline(doc) {
  12198. // HACK remove ending hardline, original PR: #1984
  12199. if (doc.type === "concat" && doc.parts.length !== 0) {
  12200. var lastPart = doc.parts[doc.parts.length - 1];
  12201. if (lastPart.type === "concat") {
  12202. if (lastPart.parts.length === 2 && lastPart.parts[0].hard && lastPart.parts[1].type === "break-parent") {
  12203. return {
  12204. type: "concat",
  12205. parts: doc.parts.slice(0, -1)
  12206. };
  12207. }
  12208. return {
  12209. type: "concat",
  12210. parts: doc.parts.slice(0, -1).concat(stripTrailingHardline(lastPart))
  12211. };
  12212. }
  12213. }
  12214. return doc;
  12215. }
  12216. var docUtils = {
  12217. isEmpty: isEmpty,
  12218. willBreak: willBreak,
  12219. isLineNext: isLineNext,
  12220. traverseDoc: traverseDoc,
  12221. mapDoc: mapDoc$1,
  12222. propagateBreaks: propagateBreaks,
  12223. removeLines: removeLines,
  12224. stripTrailingHardline: stripTrailingHardline
  12225. };
  12226. function flattenDoc(doc) {
  12227. if (doc.type === "concat") {
  12228. var res = [];
  12229. for (var i = 0; i < doc.parts.length; ++i) {
  12230. var doc2 = doc.parts[i];
  12231. if (typeof doc2 !== "string" && doc2.type === "concat") {
  12232. [].push.apply(res, flattenDoc(doc2).parts);
  12233. } else {
  12234. var flattened = flattenDoc(doc2);
  12235. if (flattened !== "") {
  12236. res.push(flattened);
  12237. }
  12238. }
  12239. }
  12240. return Object.assign({}, doc, {
  12241. parts: res
  12242. });
  12243. } else if (doc.type === "if-break") {
  12244. return Object.assign({}, doc, {
  12245. breakContents: doc.breakContents != null ? flattenDoc(doc.breakContents) : null,
  12246. flatContents: doc.flatContents != null ? flattenDoc(doc.flatContents) : null
  12247. });
  12248. } else if (doc.type === "group") {
  12249. return Object.assign({}, doc, {
  12250. contents: flattenDoc(doc.contents),
  12251. expandedStates: doc.expandedStates ? doc.expandedStates.map(flattenDoc) : doc.expandedStates
  12252. });
  12253. } else if (doc.contents) {
  12254. return Object.assign({}, doc, {
  12255. contents: flattenDoc(doc.contents)
  12256. });
  12257. }
  12258. return doc;
  12259. }
  12260. function printDoc(doc) {
  12261. if (typeof doc === "string") {
  12262. return JSON.stringify(doc);
  12263. }
  12264. if (doc.type === "line") {
  12265. if (doc.literal) {
  12266. return "literalline";
  12267. }
  12268. if (doc.hard) {
  12269. return "hardline";
  12270. }
  12271. if (doc.soft) {
  12272. return "softline";
  12273. }
  12274. return "line";
  12275. }
  12276. if (doc.type === "break-parent") {
  12277. return "breakParent";
  12278. }
  12279. if (doc.type === "trim") {
  12280. return "trim";
  12281. }
  12282. if (doc.type === "concat") {
  12283. return "[" + doc.parts.map(printDoc).join(", ") + "]";
  12284. }
  12285. if (doc.type === "indent") {
  12286. return "indent(" + printDoc(doc.contents) + ")";
  12287. }
  12288. if (doc.type === "align") {
  12289. 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) + ")";
  12290. }
  12291. if (doc.type === "if-break") {
  12292. return "ifBreak(" + printDoc(doc.breakContents) + (doc.flatContents ? ", " + printDoc(doc.flatContents) : "") + ")";
  12293. }
  12294. if (doc.type === "group") {
  12295. if (doc.expandedStates) {
  12296. return "conditionalGroup(" + "[" + doc.expandedStates.map(printDoc).join(",") + "])";
  12297. }
  12298. return (doc.break ? "wrappedGroup" : "group") + "(" + printDoc(doc.contents) + ")";
  12299. }
  12300. if (doc.type === "fill") {
  12301. return "fill" + "(" + doc.parts.map(printDoc).join(", ") + ")";
  12302. }
  12303. if (doc.type === "line-suffix") {
  12304. return "lineSuffix(" + printDoc(doc.contents) + ")";
  12305. }
  12306. if (doc.type === "line-suffix-boundary") {
  12307. return "lineSuffixBoundary";
  12308. }
  12309. throw new Error("Unknown doc type " + doc.type);
  12310. }
  12311. var docDebug = {
  12312. printDocToDebug: function printDocToDebug(doc) {
  12313. return printDoc(flattenDoc(doc));
  12314. }
  12315. };
  12316. var doc = {
  12317. builders: docBuilders,
  12318. printer: docPrinter,
  12319. utils: docUtils,
  12320. debug: docDebug
  12321. };
  12322. var mapDoc$2 = doc.utils.mapDoc;
  12323. function isNextLineEmpty$1(text, node, options) {
  12324. return util.isNextLineEmpty(text, node, options.locEnd);
  12325. }
  12326. function isPreviousLineEmpty$2(text, node, options) {
  12327. return util.isPreviousLineEmpty(text, node, options.locStart);
  12328. }
  12329. function getNextNonSpaceNonCommentCharacterIndex$1(text, node, options) {
  12330. return util.getNextNonSpaceNonCommentCharacterIndex(text, node, options.locEnd);
  12331. }
  12332. var utilShared = {
  12333. getMaxContinuousCount: util.getMaxContinuousCount,
  12334. getStringWidth: util.getStringWidth,
  12335. getAlignmentSize: util.getAlignmentSize,
  12336. getIndentSize: util.getIndentSize,
  12337. skip: util.skip,
  12338. skipWhitespace: util.skipWhitespace,
  12339. skipSpaces: util.skipSpaces,
  12340. skipNewline: util.skipNewline,
  12341. skipToLineEnd: util.skipToLineEnd,
  12342. skipEverythingButNewLine: util.skipEverythingButNewLine,
  12343. skipInlineComment: util.skipInlineComment,
  12344. skipTrailingComment: util.skipTrailingComment,
  12345. hasNewline: util.hasNewline,
  12346. hasNewlineInRange: util.hasNewlineInRange,
  12347. hasSpaces: util.hasSpaces,
  12348. isNextLineEmpty: isNextLineEmpty$1,
  12349. isNextLineEmptyAfterIndex: util.isNextLineEmptyAfterIndex,
  12350. isPreviousLineEmpty: isPreviousLineEmpty$2,
  12351. getNextNonSpaceNonCommentCharacterIndex: getNextNonSpaceNonCommentCharacterIndex$1,
  12352. mapDoc: mapDoc$2,
  12353. // TODO: remove in 2.0, we already exposed it in docUtils
  12354. makeString: util.makeString,
  12355. addLeadingComment: util.addLeadingComment,
  12356. addDanglingComment: util.addDanglingComment,
  12357. addTrailingComment: util.addTrailingComment
  12358. };
  12359. var assert$3 = ( assert$2 && assert ) || assert$2;
  12360. var _require$$0$builders = doc.builders;
  12361. var concat = _require$$0$builders.concat;
  12362. var hardline = _require$$0$builders.hardline;
  12363. var breakParent = _require$$0$builders.breakParent;
  12364. var indent = _require$$0$builders.indent;
  12365. var lineSuffix = _require$$0$builders.lineSuffix;
  12366. var join = _require$$0$builders.join;
  12367. var cursor = _require$$0$builders.cursor;
  12368. var hasNewline = util.hasNewline;
  12369. var skipNewline = util.skipNewline;
  12370. var isPreviousLineEmpty = util.isPreviousLineEmpty;
  12371. var addLeadingComment = utilShared.addLeadingComment;
  12372. var addDanglingComment = utilShared.addDanglingComment;
  12373. var addTrailingComment = utilShared.addTrailingComment;
  12374. var childNodesCacheKey = Symbol("child-nodes");
  12375. function getSortedChildNodes(node, options, resultArray) {
  12376. if (!node) {
  12377. return;
  12378. }
  12379. var printer = options.printer,
  12380. locStart = options.locStart,
  12381. locEnd = options.locEnd;
  12382. if (resultArray) {
  12383. if (node && printer.canAttachComment && printer.canAttachComment(node)) {
  12384. // This reverse insertion sort almost always takes constant
  12385. // time because we almost always (maybe always?) append the
  12386. // nodes in order anyway.
  12387. var i;
  12388. for (i = resultArray.length - 1; i >= 0; --i) {
  12389. if (locStart(resultArray[i]) <= locStart(node) && locEnd(resultArray[i]) <= locEnd(node)) {
  12390. break;
  12391. }
  12392. }
  12393. resultArray.splice(i + 1, 0, node);
  12394. return;
  12395. }
  12396. } else if (node[childNodesCacheKey]) {
  12397. return node[childNodesCacheKey];
  12398. }
  12399. var childNodes;
  12400. if (printer.getCommentChildNodes) {
  12401. childNodes = printer.getCommentChildNodes(node);
  12402. } else if (node && _typeof(node) === "object") {
  12403. childNodes = Object.keys(node).filter(function (n) {
  12404. return n !== "enclosingNode" && n !== "precedingNode" && n !== "followingNode";
  12405. }).map(function (n) {
  12406. return node[n];
  12407. });
  12408. }
  12409. if (!childNodes) {
  12410. return;
  12411. }
  12412. if (!resultArray) {
  12413. Object.defineProperty(node, childNodesCacheKey, {
  12414. value: resultArray = [],
  12415. enumerable: false
  12416. });
  12417. }
  12418. childNodes.forEach(function (childNode) {
  12419. getSortedChildNodes(childNode, options, resultArray);
  12420. });
  12421. return resultArray;
  12422. } // As efficiently as possible, decorate the comment object with
  12423. // .precedingNode, .enclosingNode, and/or .followingNode properties, at
  12424. // least one of which is guaranteed to be defined.
  12425. function decorateComment(node, comment, options) {
  12426. var locStart = options.locStart,
  12427. locEnd = options.locEnd;
  12428. var childNodes = getSortedChildNodes(node, options);
  12429. var precedingNode;
  12430. var followingNode; // Time to dust off the old binary search robes and wizard hat.
  12431. var left = 0;
  12432. var right = childNodes.length;
  12433. while (left < right) {
  12434. var middle = left + right >> 1;
  12435. var child = childNodes[middle];
  12436. if (locStart(child) - locStart(comment) <= 0 && locEnd(comment) - locEnd(child) <= 0) {
  12437. // The comment is completely contained by this child node.
  12438. comment.enclosingNode = child;
  12439. decorateComment(child, comment, options);
  12440. return; // Abandon the binary search at this level.
  12441. }
  12442. if (locEnd(child) - locStart(comment) <= 0) {
  12443. // This child node falls completely before the comment.
  12444. // Because we will never consider this node or any nodes
  12445. // before it again, this node must be the closest preceding
  12446. // node we have encountered so far.
  12447. precedingNode = child;
  12448. left = middle + 1;
  12449. continue;
  12450. }
  12451. if (locEnd(comment) - locStart(child) <= 0) {
  12452. // This child node falls completely after the comment.
  12453. // Because we will never consider this node or any nodes after
  12454. // it again, this node must be the closest following node we
  12455. // have encountered so far.
  12456. followingNode = child;
  12457. right = middle;
  12458. continue;
  12459. }
  12460. /* istanbul ignore next */
  12461. throw new Error("Comment location overlaps with node location");
  12462. } // We don't want comments inside of different expressions inside of the same
  12463. // template literal to move to another expression.
  12464. if (comment.enclosingNode && comment.enclosingNode.type === "TemplateLiteral") {
  12465. var quasis = comment.enclosingNode.quasis;
  12466. var commentIndex = findExpressionIndexForComment(quasis, comment, options);
  12467. if (precedingNode && findExpressionIndexForComment(quasis, precedingNode, options) !== commentIndex) {
  12468. precedingNode = null;
  12469. }
  12470. if (followingNode && findExpressionIndexForComment(quasis, followingNode, options) !== commentIndex) {
  12471. followingNode = null;
  12472. }
  12473. }
  12474. if (precedingNode) {
  12475. comment.precedingNode = precedingNode;
  12476. }
  12477. if (followingNode) {
  12478. comment.followingNode = followingNode;
  12479. }
  12480. }
  12481. function attach(comments, ast, text, options) {
  12482. if (!Array.isArray(comments)) {
  12483. return;
  12484. }
  12485. var tiesToBreak = [];
  12486. var locStart = options.locStart,
  12487. locEnd = options.locEnd;
  12488. comments.forEach(function (comment, i) {
  12489. if (options.parser === "json" || options.parser === "json5" || options.parser === "__js_expression" || options.parser === "__vue_expression") {
  12490. if (locStart(comment) - locStart(ast) <= 0) {
  12491. addLeadingComment(ast, comment);
  12492. return;
  12493. }
  12494. if (locEnd(comment) - locEnd(ast) >= 0) {
  12495. addTrailingComment(ast, comment);
  12496. return;
  12497. }
  12498. }
  12499. decorateComment(ast, comment, options);
  12500. var precedingNode = comment.precedingNode,
  12501. enclosingNode = comment.enclosingNode,
  12502. followingNode = comment.followingNode;
  12503. var pluginHandleOwnLineComment = options.printer.handleComments && options.printer.handleComments.ownLine ? options.printer.handleComments.ownLine : function () {
  12504. return false;
  12505. };
  12506. var pluginHandleEndOfLineComment = options.printer.handleComments && options.printer.handleComments.endOfLine ? options.printer.handleComments.endOfLine : function () {
  12507. return false;
  12508. };
  12509. var pluginHandleRemainingComment = options.printer.handleComments && options.printer.handleComments.remaining ? options.printer.handleComments.remaining : function () {
  12510. return false;
  12511. };
  12512. var isLastComment = comments.length - 1 === i;
  12513. if (hasNewline(text, locStart(comment), {
  12514. backwards: true
  12515. })) {
  12516. // If a comment exists on its own line, prefer a leading comment.
  12517. // We also need to check if it's the first line of the file.
  12518. if (pluginHandleOwnLineComment(comment, text, options, ast, isLastComment)) {// We're good
  12519. } else if (followingNode) {
  12520. // Always a leading comment.
  12521. addLeadingComment(followingNode, comment);
  12522. } else if (precedingNode) {
  12523. addTrailingComment(precedingNode, comment);
  12524. } else if (enclosingNode) {
  12525. addDanglingComment(enclosingNode, comment);
  12526. } else {
  12527. // There are no nodes, let's attach it to the root of the ast
  12528. /* istanbul ignore next */
  12529. addDanglingComment(ast, comment);
  12530. }
  12531. } else if (hasNewline(text, locEnd(comment))) {
  12532. if (pluginHandleEndOfLineComment(comment, text, options, ast, isLastComment)) {// We're good
  12533. } else if (precedingNode) {
  12534. // There is content before this comment on the same line, but
  12535. // none after it, so prefer a trailing comment of the previous node.
  12536. addTrailingComment(precedingNode, comment);
  12537. } else if (followingNode) {
  12538. addLeadingComment(followingNode, comment);
  12539. } else if (enclosingNode) {
  12540. addDanglingComment(enclosingNode, comment);
  12541. } else {
  12542. // There are no nodes, let's attach it to the root of the ast
  12543. /* istanbul ignore next */
  12544. addDanglingComment(ast, comment);
  12545. }
  12546. } else {
  12547. if (pluginHandleRemainingComment(comment, text, options, ast, isLastComment)) {// We're good
  12548. } else if (precedingNode && followingNode) {
  12549. // Otherwise, text exists both before and after the comment on
  12550. // the same line. If there is both a preceding and following
  12551. // node, use a tie-breaking algorithm to determine if it should
  12552. // be attached to the next or previous node. In the last case,
  12553. // simply attach the right node;
  12554. var tieCount = tiesToBreak.length;
  12555. if (tieCount > 0) {
  12556. var lastTie = tiesToBreak[tieCount - 1];
  12557. if (lastTie.followingNode !== comment.followingNode) {
  12558. breakTies(tiesToBreak, text, options);
  12559. }
  12560. }
  12561. tiesToBreak.push(comment);
  12562. } else if (precedingNode) {
  12563. addTrailingComment(precedingNode, comment);
  12564. } else if (followingNode) {
  12565. addLeadingComment(followingNode, comment);
  12566. } else if (enclosingNode) {
  12567. addDanglingComment(enclosingNode, comment);
  12568. } else {
  12569. // There are no nodes, let's attach it to the root of the ast
  12570. /* istanbul ignore next */
  12571. addDanglingComment(ast, comment);
  12572. }
  12573. }
  12574. });
  12575. breakTies(tiesToBreak, text, options);
  12576. comments.forEach(function (comment) {
  12577. // These node references were useful for breaking ties, but we
  12578. // don't need them anymore, and they create cycles in the AST that
  12579. // may lead to infinite recursion if we don't delete them here.
  12580. delete comment.precedingNode;
  12581. delete comment.enclosingNode;
  12582. delete comment.followingNode;
  12583. });
  12584. }
  12585. function breakTies(tiesToBreak, text, options) {
  12586. var tieCount = tiesToBreak.length;
  12587. if (tieCount === 0) {
  12588. return;
  12589. }
  12590. var _tiesToBreak$ = tiesToBreak[0],
  12591. precedingNode = _tiesToBreak$.precedingNode,
  12592. followingNode = _tiesToBreak$.followingNode;
  12593. var gapEndPos = options.locStart(followingNode); // Iterate backwards through tiesToBreak, examining the gaps
  12594. // between the tied comments. In order to qualify as leading, a
  12595. // comment must be separated from followingNode by an unbroken series of
  12596. // gaps (or other comments). Gaps should only contain whitespace or open
  12597. // parentheses.
  12598. var indexOfFirstLeadingComment;
  12599. for (indexOfFirstLeadingComment = tieCount; indexOfFirstLeadingComment > 0; --indexOfFirstLeadingComment) {
  12600. var comment = tiesToBreak[indexOfFirstLeadingComment - 1];
  12601. assert$3.strictEqual(comment.precedingNode, precedingNode);
  12602. assert$3.strictEqual(comment.followingNode, followingNode);
  12603. var gap = text.slice(options.locEnd(comment), gapEndPos).trim();
  12604. if (gap === "" || /^\(+$/.test(gap)) {
  12605. gapEndPos = options.locStart(comment);
  12606. } else {
  12607. // The gap string contained something other than whitespace or open
  12608. // parentheses.
  12609. break;
  12610. }
  12611. }
  12612. tiesToBreak.forEach(function (comment, i) {
  12613. if (i < indexOfFirstLeadingComment) {
  12614. addTrailingComment(precedingNode, comment);
  12615. } else {
  12616. addLeadingComment(followingNode, comment);
  12617. }
  12618. });
  12619. tiesToBreak.length = 0;
  12620. }
  12621. function printComment(commentPath, options) {
  12622. var comment = commentPath.getValue();
  12623. comment.printed = true;
  12624. return options.printer.printComment(commentPath, options);
  12625. }
  12626. function findExpressionIndexForComment(quasis, comment, options) {
  12627. var startPos = options.locStart(comment) - 1;
  12628. for (var i = 1; i < quasis.length; ++i) {
  12629. if (startPos < getQuasiRange(quasis[i]).start) {
  12630. return i - 1;
  12631. }
  12632. } // We haven't found it, it probably means that some of the locations are off.
  12633. // Let's just return the first one.
  12634. /* istanbul ignore next */
  12635. return 0;
  12636. }
  12637. function getQuasiRange(expr) {
  12638. if (expr.start !== undefined) {
  12639. // Babel
  12640. return {
  12641. start: expr.start,
  12642. end: expr.end
  12643. };
  12644. } // Flow
  12645. return {
  12646. start: expr.range[0],
  12647. end: expr.range[1]
  12648. };
  12649. }
  12650. function printLeadingComment(commentPath, print, options) {
  12651. var comment = commentPath.getValue();
  12652. var contents = printComment(commentPath, options);
  12653. if (!contents) {
  12654. return "";
  12655. }
  12656. var isBlock = options.printer.isBlockComment && options.printer.isBlockComment(comment); // Leading block comments should see if they need to stay on the
  12657. // same line or not.
  12658. if (isBlock) {
  12659. return concat([contents, hasNewline(options.originalText, options.locEnd(comment)) ? hardline : " "]);
  12660. }
  12661. return concat([contents, hardline]);
  12662. }
  12663. function printTrailingComment(commentPath, print, options) {
  12664. var comment = commentPath.getValue();
  12665. var contents = printComment(commentPath, options);
  12666. if (!contents) {
  12667. return "";
  12668. }
  12669. var isBlock = options.printer.isBlockComment && options.printer.isBlockComment(comment); // We don't want the line to break
  12670. // when the parentParentNode is a ClassDeclaration/-Expression
  12671. // And the parentNode is in the superClass property
  12672. var parentNode = commentPath.getNode(1);
  12673. var parentParentNode = commentPath.getNode(2);
  12674. var isParentSuperClass = parentParentNode && (parentParentNode.type === "ClassDeclaration" || parentParentNode.type === "ClassExpression") && parentParentNode.superClass === parentNode;
  12675. if (hasNewline(options.originalText, options.locStart(comment), {
  12676. backwards: true
  12677. })) {
  12678. // This allows comments at the end of nested structures:
  12679. // {
  12680. // x: 1,
  12681. // y: 2
  12682. // // A comment
  12683. // }
  12684. // Those kinds of comments are almost always leading comments, but
  12685. // here it doesn't go "outside" the block and turns it into a
  12686. // trailing comment for `2`. We can simulate the above by checking
  12687. // if this a comment on its own line; normal trailing comments are
  12688. // always at the end of another expression.
  12689. var isLineBeforeEmpty = isPreviousLineEmpty(options.originalText, comment, options.locStart);
  12690. return lineSuffix(concat([hardline, isLineBeforeEmpty ? hardline : "", contents]));
  12691. } else if (isBlock || isParentSuperClass) {
  12692. // Trailing block comments never need a newline
  12693. return concat([" ", contents]);
  12694. }
  12695. return concat([lineSuffix(" " + contents), !isBlock ? breakParent : ""]);
  12696. }
  12697. function printDanglingComments(path, options, sameIndent, filter) {
  12698. var parts = [];
  12699. var node = path.getValue();
  12700. if (!node || !node.comments) {
  12701. return "";
  12702. }
  12703. path.each(function (commentPath) {
  12704. var comment = commentPath.getValue();
  12705. if (comment && !comment.leading && !comment.trailing && (!filter || filter(comment))) {
  12706. parts.push(printComment(commentPath, options));
  12707. }
  12708. }, "comments");
  12709. if (parts.length === 0) {
  12710. return "";
  12711. }
  12712. if (sameIndent) {
  12713. return join(hardline, parts);
  12714. }
  12715. return indent(concat([hardline, join(hardline, parts)]));
  12716. }
  12717. function prependCursorPlaceholder(path, options, printed) {
  12718. if (path.getNode() === options.cursorNode && path.getValue()) {
  12719. return concat([cursor, printed, cursor]);
  12720. }
  12721. return printed;
  12722. }
  12723. function printComments(path, print, options, needsSemi) {
  12724. var value = path.getValue();
  12725. var printed = print(path);
  12726. var comments = value && value.comments;
  12727. if (!comments || comments.length === 0) {
  12728. return prependCursorPlaceholder(path, options, printed);
  12729. }
  12730. var leadingParts = [];
  12731. var trailingParts = [needsSemi ? ";" : "", printed];
  12732. path.each(function (commentPath) {
  12733. var comment = commentPath.getValue();
  12734. var leading = comment.leading,
  12735. trailing = comment.trailing;
  12736. if (leading) {
  12737. var contents = printLeadingComment(commentPath, print, options);
  12738. if (!contents) {
  12739. return;
  12740. }
  12741. leadingParts.push(contents);
  12742. var text = options.originalText;
  12743. if (hasNewline(text, skipNewline(text, options.locEnd(comment)))) {
  12744. leadingParts.push(hardline);
  12745. }
  12746. } else if (trailing) {
  12747. trailingParts.push(printTrailingComment(commentPath, print, options));
  12748. }
  12749. }, "comments");
  12750. return prependCursorPlaceholder(path, options, concat(leadingParts.concat(trailingParts)));
  12751. }
  12752. var comments = {
  12753. attach: attach,
  12754. printComments: printComments,
  12755. printDanglingComments: printDanglingComments,
  12756. getSortedChildNodes: getSortedChildNodes
  12757. };
  12758. function FastPath(value) {
  12759. assert$3.ok(this instanceof FastPath);
  12760. this.stack = [value];
  12761. } // The name of the current property is always the penultimate element of
  12762. // this.stack, and always a String.
  12763. FastPath.prototype.getName = function getName() {
  12764. var s = this.stack;
  12765. var len = s.length;
  12766. if (len > 1) {
  12767. return s[len - 2];
  12768. } // Since the name is always a string, null is a safe sentinel value to
  12769. // return if we do not know the name of the (root) value.
  12770. /* istanbul ignore next */
  12771. return null;
  12772. }; // The value of the current property is always the final element of
  12773. // this.stack.
  12774. FastPath.prototype.getValue = function getValue() {
  12775. var s = this.stack;
  12776. return s[s.length - 1];
  12777. };
  12778. function getNodeHelper(path, count) {
  12779. var stackIndex = getNodeStackIndexHelper(path.stack, count);
  12780. return stackIndex === -1 ? null : path.stack[stackIndex];
  12781. }
  12782. function getNodeStackIndexHelper(stack, count) {
  12783. for (var i = stack.length - 1; i >= 0; i -= 2) {
  12784. var value = stack[i];
  12785. if (value && !Array.isArray(value) && --count < 0) {
  12786. return i;
  12787. }
  12788. }
  12789. return -1;
  12790. }
  12791. FastPath.prototype.getNode = function getNode(count) {
  12792. return getNodeHelper(this, ~~count);
  12793. };
  12794. FastPath.prototype.getParentNode = function getParentNode(count) {
  12795. return getNodeHelper(this, ~~count + 1);
  12796. }; // Temporarily push properties named by string arguments given after the
  12797. // callback function onto this.stack, then call the callback with a
  12798. // reference to this (modified) FastPath object. Note that the stack will
  12799. // be restored to its original state after the callback is finished, so it
  12800. // is probably a mistake to retain a reference to the path.
  12801. FastPath.prototype.call = function call(callback
  12802. /*, name1, name2, ... */
  12803. ) {
  12804. var s = this.stack;
  12805. var origLen = s.length;
  12806. var value = s[origLen - 1];
  12807. var argc = arguments.length;
  12808. for (var i = 1; i < argc; ++i) {
  12809. var name = arguments[i];
  12810. value = value[name];
  12811. s.push(name, value);
  12812. }
  12813. var result = callback(this);
  12814. s.length = origLen;
  12815. return result;
  12816. };
  12817. FastPath.prototype.callParent = function callParent(callback, count) {
  12818. var stackIndex = getNodeStackIndexHelper(this.stack, ~~count + 1);
  12819. var parentValues = this.stack.splice(stackIndex + 1);
  12820. var result = callback(this);
  12821. Array.prototype.push.apply(this.stack, parentValues);
  12822. return result;
  12823. }; // Similar to FastPath.prototype.call, except that the value obtained by
  12824. // accessing this.getValue()[name1][name2]... should be array-like. The
  12825. // callback will be called with a reference to this path object for each
  12826. // element of the array.
  12827. FastPath.prototype.each = function each(callback
  12828. /*, name1, name2, ... */
  12829. ) {
  12830. var s = this.stack;
  12831. var origLen = s.length;
  12832. var value = s[origLen - 1];
  12833. var argc = arguments.length;
  12834. for (var i = 1; i < argc; ++i) {
  12835. var name = arguments[i];
  12836. value = value[name];
  12837. s.push(name, value);
  12838. }
  12839. for (var _i = 0; _i < value.length; ++_i) {
  12840. if (_i in value) {
  12841. s.push(_i, value[_i]); // If the callback needs to know the value of i, call
  12842. // path.getName(), assuming path is the parameter name.
  12843. callback(this);
  12844. s.length -= 2;
  12845. }
  12846. }
  12847. s.length = origLen;
  12848. }; // Similar to FastPath.prototype.each, except that the results of the
  12849. // callback function invocations are stored in an array and returned at
  12850. // the end of the iteration.
  12851. FastPath.prototype.map = function map(callback
  12852. /*, name1, name2, ... */
  12853. ) {
  12854. var s = this.stack;
  12855. var origLen = s.length;
  12856. var value = s[origLen - 1];
  12857. var argc = arguments.length;
  12858. for (var i = 1; i < argc; ++i) {
  12859. var name = arguments[i];
  12860. value = value[name];
  12861. s.push(name, value);
  12862. }
  12863. var result = new Array(value.length);
  12864. for (var _i2 = 0; _i2 < value.length; ++_i2) {
  12865. if (_i2 in value) {
  12866. s.push(_i2, value[_i2]);
  12867. result[_i2] = callback(this, _i2);
  12868. s.length -= 2;
  12869. }
  12870. }
  12871. s.length = origLen;
  12872. return result;
  12873. };
  12874. var fastPath = FastPath;
  12875. var normalize$3 = options.normalize;
  12876. function printSubtree(path, print, options$$1, printAstToDoc) {
  12877. if (options$$1.printer.embed) {
  12878. return options$$1.printer.embed(path, print, function (text, partialNextOptions) {
  12879. return textToDoc(text, partialNextOptions, options$$1, printAstToDoc);
  12880. }, options$$1);
  12881. }
  12882. }
  12883. function textToDoc(text, partialNextOptions, parentOptions, printAstToDoc) {
  12884. var nextOptions = normalize$3(Object.assign({}, parentOptions, partialNextOptions, {
  12885. parentParser: parentOptions.parser,
  12886. originalText: text
  12887. }), {
  12888. passThrough: true
  12889. });
  12890. var result = parser.parse(text, nextOptions);
  12891. var ast = result.ast;
  12892. text = result.text;
  12893. var astComments = ast.comments;
  12894. delete ast.comments;
  12895. comments.attach(astComments, ast, text, nextOptions);
  12896. return printAstToDoc(ast, nextOptions);
  12897. }
  12898. var multiparser = {
  12899. printSubtree: printSubtree
  12900. };
  12901. var doc$2 = doc;
  12902. var docBuilders$2 = doc$2.builders;
  12903. var concat$3 = docBuilders$2.concat;
  12904. var hardline$2 = docBuilders$2.hardline;
  12905. var addAlignmentToDoc$1 = docBuilders$2.addAlignmentToDoc;
  12906. var docUtils$2 = doc$2.utils;
  12907. /**
  12908. * Takes an abstract syntax tree (AST) and recursively converts it to a
  12909. * document (series of printing primitives).
  12910. *
  12911. * This is done by descending down the AST recursively. The recursion
  12912. * involves two functions that call each other:
  12913. *
  12914. * 1. printGenerically(), which is defined as an inner function here.
  12915. * It basically takes care of node caching.
  12916. * 2. callPluginPrintFunction(), which checks for some options, and
  12917. * ultimately calls the print() function provided by the plugin.
  12918. *
  12919. * The plugin function will call printGenerically() again for child nodes
  12920. * of the current node, which will do its housekeeping, then call the
  12921. * plugin function again, and so on.
  12922. *
  12923. * All the while, these functions pass a "path" variable around, which
  12924. * is a stack-like data structure (FastPath) that maintains the current
  12925. * state of the recursion. It is called "path", because it represents
  12926. * the path to the current node through the Abstract Syntax Tree.
  12927. */
  12928. function printAstToDoc(ast, options) {
  12929. var alignmentSize = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
  12930. var printer = options.printer;
  12931. if (printer.preprocess) {
  12932. ast = printer.preprocess(ast, options);
  12933. }
  12934. var cache = new Map();
  12935. function printGenerically(path, args) {
  12936. var node = path.getValue();
  12937. var shouldCache = node && _typeof(node) === "object" && args === undefined;
  12938. if (shouldCache && cache.has(node)) {
  12939. return cache.get(node);
  12940. } // We let JSXElement print its comments itself because it adds () around
  12941. // UnionTypeAnnotation has to align the child without the comments
  12942. var res;
  12943. if (printer.willPrintOwnComments && printer.willPrintOwnComments(path)) {
  12944. res = callPluginPrintFunction(path, options, printGenerically, args);
  12945. } else {
  12946. // printComments will call the plugin print function and check for
  12947. // comments to print
  12948. res = comments.printComments(path, function (p) {
  12949. return callPluginPrintFunction(p, options, printGenerically, args);
  12950. }, options, args && args.needsSemi);
  12951. }
  12952. if (shouldCache) {
  12953. cache.set(node, res);
  12954. }
  12955. return res;
  12956. }
  12957. var doc$$2 = printGenerically(new fastPath(ast));
  12958. if (alignmentSize > 0) {
  12959. // Add a hardline to make the indents take effect
  12960. // It should be removed in index.js format()
  12961. doc$$2 = addAlignmentToDoc$1(concat$3([hardline$2, doc$$2]), alignmentSize, options.tabWidth);
  12962. }
  12963. docUtils$2.propagateBreaks(doc$$2);
  12964. return doc$$2;
  12965. }
  12966. function callPluginPrintFunction(path, options, printPath, args) {
  12967. assert$3.ok(path instanceof fastPath);
  12968. var node = path.getValue();
  12969. var printer = options.printer; // Escape hatch
  12970. if (printer.hasPrettierIgnore && printer.hasPrettierIgnore(path)) {
  12971. return options.originalText.slice(options.locStart(node), options.locEnd(node));
  12972. }
  12973. if (node) {
  12974. try {
  12975. // Potentially switch to a different parser
  12976. var sub = multiparser.printSubtree(path, printPath, options, printAstToDoc);
  12977. if (sub) {
  12978. return sub;
  12979. }
  12980. } catch (error) {
  12981. /* istanbul ignore if */
  12982. if (commonjsGlobal.PRETTIER_DEBUG) {
  12983. throw error;
  12984. } // Continue with current parser
  12985. }
  12986. }
  12987. return printer.print(path, options, printPath, args);
  12988. }
  12989. var astToDoc = printAstToDoc;
  12990. function findSiblingAncestors(startNodeAndParents, endNodeAndParents, opts) {
  12991. var resultStartNode = startNodeAndParents.node;
  12992. var resultEndNode = endNodeAndParents.node;
  12993. if (resultStartNode === resultEndNode) {
  12994. return {
  12995. startNode: resultStartNode,
  12996. endNode: resultEndNode
  12997. };
  12998. }
  12999. var _iteratorNormalCompletion = true;
  13000. var _didIteratorError = false;
  13001. var _iteratorError = undefined;
  13002. try {
  13003. for (var _iterator = endNodeAndParents.parentNodes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  13004. var endParent = _step.value;
  13005. if (endParent.type !== "Program" && endParent.type !== "File" && opts.locStart(endParent) >= opts.locStart(startNodeAndParents.node)) {
  13006. resultEndNode = endParent;
  13007. } else {
  13008. break;
  13009. }
  13010. }
  13011. } catch (err) {
  13012. _didIteratorError = true;
  13013. _iteratorError = err;
  13014. } finally {
  13015. try {
  13016. if (!_iteratorNormalCompletion && _iterator.return != null) {
  13017. _iterator.return();
  13018. }
  13019. } finally {
  13020. if (_didIteratorError) {
  13021. throw _iteratorError;
  13022. }
  13023. }
  13024. }
  13025. var _iteratorNormalCompletion2 = true;
  13026. var _didIteratorError2 = false;
  13027. var _iteratorError2 = undefined;
  13028. try {
  13029. for (var _iterator2 = startNodeAndParents.parentNodes[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
  13030. var startParent = _step2.value;
  13031. if (startParent.type !== "Program" && startParent.type !== "File" && opts.locEnd(startParent) <= opts.locEnd(endNodeAndParents.node)) {
  13032. resultStartNode = startParent;
  13033. } else {
  13034. break;
  13035. }
  13036. }
  13037. } catch (err) {
  13038. _didIteratorError2 = true;
  13039. _iteratorError2 = err;
  13040. } finally {
  13041. try {
  13042. if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
  13043. _iterator2.return();
  13044. }
  13045. } finally {
  13046. if (_didIteratorError2) {
  13047. throw _iteratorError2;
  13048. }
  13049. }
  13050. }
  13051. return {
  13052. startNode: resultStartNode,
  13053. endNode: resultEndNode
  13054. };
  13055. }
  13056. function findNodeAtOffset(node, offset, options, predicate, parentNodes) {
  13057. predicate = predicate || function () {
  13058. return true;
  13059. };
  13060. parentNodes = parentNodes || [];
  13061. var start = options.locStart(node, options.locStart);
  13062. var end = options.locEnd(node, options.locEnd);
  13063. if (start <= offset && offset <= end) {
  13064. var _iteratorNormalCompletion3 = true;
  13065. var _didIteratorError3 = false;
  13066. var _iteratorError3 = undefined;
  13067. try {
  13068. for (var _iterator3 = comments.getSortedChildNodes(node, options)[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
  13069. var childNode = _step3.value;
  13070. var childResult = findNodeAtOffset(childNode, offset, options, predicate, [node].concat(parentNodes));
  13071. if (childResult) {
  13072. return childResult;
  13073. }
  13074. }
  13075. } catch (err) {
  13076. _didIteratorError3 = true;
  13077. _iteratorError3 = err;
  13078. } finally {
  13079. try {
  13080. if (!_iteratorNormalCompletion3 && _iterator3.return != null) {
  13081. _iterator3.return();
  13082. }
  13083. } finally {
  13084. if (_didIteratorError3) {
  13085. throw _iteratorError3;
  13086. }
  13087. }
  13088. }
  13089. if (predicate(node)) {
  13090. return {
  13091. node: node,
  13092. parentNodes: parentNodes
  13093. };
  13094. }
  13095. }
  13096. } // See https://www.ecma-international.org/ecma-262/5.1/#sec-A.5
  13097. function isSourceElement(opts, node) {
  13098. if (node == null) {
  13099. return false;
  13100. } // JS and JS like to avoid repetitions
  13101. var jsSourceElements = ["FunctionDeclaration", "BlockStatement", "BreakStatement", "ContinueStatement", "DebuggerStatement", "DoWhileStatement", "EmptyStatement", "ExpressionStatement", "ForInStatement", "ForStatement", "IfStatement", "LabeledStatement", "ReturnStatement", "SwitchStatement", "ThrowStatement", "TryStatement", "VariableDeclaration", "WhileStatement", "WithStatement", "ClassDeclaration", // ES 2015
  13102. "ImportDeclaration", // Module
  13103. "ExportDefaultDeclaration", // Module
  13104. "ExportNamedDeclaration", // Module
  13105. "ExportAllDeclaration", // Module
  13106. "TypeAlias", // Flow
  13107. "InterfaceDeclaration", // Flow, TypeScript
  13108. "TypeAliasDeclaration", // TypeScript
  13109. "ExportAssignment", // TypeScript
  13110. "ExportDeclaration" // TypeScript
  13111. ];
  13112. var jsonSourceElements = ["ObjectExpression", "ArrayExpression", "StringLiteral", "NumericLiteral", "BooleanLiteral", "NullLiteral"];
  13113. var graphqlSourceElements = ["OperationDefinition", "FragmentDefinition", "VariableDefinition", "TypeExtensionDefinition", "ObjectTypeDefinition", "FieldDefinition", "DirectiveDefinition", "EnumTypeDefinition", "EnumValueDefinition", "InputValueDefinition", "InputObjectTypeDefinition", "SchemaDefinition", "OperationTypeDefinition", "InterfaceTypeDefinition", "UnionTypeDefinition", "ScalarTypeDefinition"];
  13114. switch (opts.parser) {
  13115. case "flow":
  13116. case "babel":
  13117. case "typescript":
  13118. return jsSourceElements.indexOf(node.type) > -1;
  13119. case "json":
  13120. return jsonSourceElements.indexOf(node.type) > -1;
  13121. case "graphql":
  13122. return graphqlSourceElements.indexOf(node.kind) > -1;
  13123. case "vue":
  13124. return node.tag !== "root";
  13125. }
  13126. return false;
  13127. }
  13128. function calculateRange(text, opts, ast) {
  13129. // Contract the range so that it has non-whitespace characters at its endpoints.
  13130. // This ensures we can format a range that doesn't end on a node.
  13131. var rangeStringOrig = text.slice(opts.rangeStart, opts.rangeEnd);
  13132. var startNonWhitespace = Math.max(opts.rangeStart + rangeStringOrig.search(/\S/), opts.rangeStart);
  13133. var endNonWhitespace;
  13134. for (endNonWhitespace = opts.rangeEnd; endNonWhitespace > opts.rangeStart; --endNonWhitespace) {
  13135. if (text[endNonWhitespace - 1].match(/\S/)) {
  13136. break;
  13137. }
  13138. }
  13139. var startNodeAndParents = findNodeAtOffset(ast, startNonWhitespace, opts, function (node) {
  13140. return isSourceElement(opts, node);
  13141. });
  13142. var endNodeAndParents = findNodeAtOffset(ast, endNonWhitespace, opts, function (node) {
  13143. return isSourceElement(opts, node);
  13144. });
  13145. if (!startNodeAndParents || !endNodeAndParents) {
  13146. return {
  13147. rangeStart: 0,
  13148. rangeEnd: 0
  13149. };
  13150. }
  13151. var siblingAncestors = findSiblingAncestors(startNodeAndParents, endNodeAndParents, opts);
  13152. var startNode = siblingAncestors.startNode,
  13153. endNode = siblingAncestors.endNode;
  13154. var rangeStart = Math.min(opts.locStart(startNode, opts.locStart), opts.locStart(endNode, opts.locStart));
  13155. var rangeEnd = Math.max(opts.locEnd(startNode, opts.locEnd), opts.locEnd(endNode, opts.locEnd));
  13156. return {
  13157. rangeStart: rangeStart,
  13158. rangeEnd: rangeEnd
  13159. };
  13160. }
  13161. var rangeUtil = {
  13162. calculateRange: calculateRange,
  13163. findNodeAtOffset: findNodeAtOffset
  13164. };
  13165. var normalizeOptions = options.normalize;
  13166. var guessEndOfLine = endOfLine.guessEndOfLine;
  13167. var convertEndOfLineToChars = endOfLine.convertEndOfLineToChars;
  13168. var mapDoc = doc.utils.mapDoc;
  13169. var _printDocToString = doc.printer.printDocToString;
  13170. var printDocToDebug = doc.debug.printDocToDebug;
  13171. var UTF8BOM = 0xfeff;
  13172. var CURSOR = Symbol("cursor");
  13173. var PLACEHOLDERS = {
  13174. cursorOffset: "<<<PRETTIER_CURSOR>>>",
  13175. rangeStart: "<<<PRETTIER_RANGE_START>>>",
  13176. rangeEnd: "<<<PRETTIER_RANGE_END>>>"
  13177. };
  13178. function ensureAllCommentsPrinted(astComments) {
  13179. if (!astComments) {
  13180. return;
  13181. }
  13182. for (var i = 0; i < astComments.length; ++i) {
  13183. if (astComments[i].value.trim() === "prettier-ignore") {
  13184. // If there's a prettier-ignore, we're not printing that sub-tree so we
  13185. // don't know if the comments was printed or not.
  13186. return;
  13187. }
  13188. }
  13189. astComments.forEach(function (comment) {
  13190. if (!comment.printed) {
  13191. throw new Error('Comment "' + comment.value.trim() + '" was not printed. Please report this error!');
  13192. }
  13193. delete comment.printed;
  13194. });
  13195. }
  13196. function attachComments(text, ast, opts) {
  13197. var astComments = ast.comments;
  13198. if (astComments) {
  13199. delete ast.comments;
  13200. comments.attach(astComments, ast, text, opts);
  13201. }
  13202. ast.tokens = [];
  13203. opts.originalText = opts.parser === "yaml" ? text : text.trimRight();
  13204. return astComments;
  13205. }
  13206. function coreFormat(text, opts, addAlignmentSize) {
  13207. if (!text || !text.trim().length) {
  13208. return {
  13209. formatted: "",
  13210. cursorOffset: 0
  13211. };
  13212. }
  13213. addAlignmentSize = addAlignmentSize || 0;
  13214. var parsed = parser.parse(text, opts);
  13215. var ast = parsed.ast;
  13216. text = parsed.text;
  13217. if (opts.cursorOffset >= 0) {
  13218. var nodeResult = rangeUtil.findNodeAtOffset(ast, opts.cursorOffset, opts);
  13219. if (nodeResult && nodeResult.node) {
  13220. opts.cursorNode = nodeResult.node;
  13221. }
  13222. }
  13223. var astComments = attachComments(text, ast, opts);
  13224. var doc$$1 = astToDoc(ast, opts, addAlignmentSize);
  13225. var eol = convertEndOfLineToChars(opts.endOfLine);
  13226. var result = _printDocToString(opts.endOfLine === "lf" ? doc$$1 : mapDoc(doc$$1, function (currentDoc) {
  13227. return typeof currentDoc === "string" && currentDoc.indexOf("\n") !== -1 ? currentDoc.replace(/\n/g, eol) : currentDoc;
  13228. }), opts);
  13229. ensureAllCommentsPrinted(astComments); // Remove extra leading indentation as well as the added indentation after last newline
  13230. if (addAlignmentSize > 0) {
  13231. var trimmed = result.formatted.trim();
  13232. if (result.cursorNodeStart !== undefined) {
  13233. result.cursorNodeStart -= result.formatted.indexOf(trimmed);
  13234. }
  13235. result.formatted = trimmed + convertEndOfLineToChars(opts.endOfLine);
  13236. }
  13237. if (opts.cursorOffset >= 0) {
  13238. var oldCursorNodeStart;
  13239. var oldCursorNodeText;
  13240. var cursorOffsetRelativeToOldCursorNode;
  13241. var newCursorNodeStart;
  13242. var newCursorNodeText;
  13243. if (opts.cursorNode && result.cursorNodeText) {
  13244. oldCursorNodeStart = opts.locStart(opts.cursorNode);
  13245. oldCursorNodeText = text.slice(oldCursorNodeStart, opts.locEnd(opts.cursorNode));
  13246. cursorOffsetRelativeToOldCursorNode = opts.cursorOffset - oldCursorNodeStart;
  13247. newCursorNodeStart = result.cursorNodeStart;
  13248. newCursorNodeText = result.cursorNodeText;
  13249. } else {
  13250. oldCursorNodeStart = 0;
  13251. oldCursorNodeText = text;
  13252. cursorOffsetRelativeToOldCursorNode = opts.cursorOffset;
  13253. newCursorNodeStart = 0;
  13254. newCursorNodeText = result.formatted;
  13255. }
  13256. if (oldCursorNodeText === newCursorNodeText) {
  13257. return {
  13258. formatted: result.formatted,
  13259. cursorOffset: newCursorNodeStart + cursorOffsetRelativeToOldCursorNode
  13260. };
  13261. } // diff old and new cursor node texts, with a special cursor
  13262. // symbol inserted to find out where it moves to
  13263. var oldCursorNodeCharArray = oldCursorNodeText.split("");
  13264. oldCursorNodeCharArray.splice(cursorOffsetRelativeToOldCursorNode, 0, CURSOR);
  13265. var newCursorNodeCharArray = newCursorNodeText.split("");
  13266. var cursorNodeDiff = lib.diffArrays(oldCursorNodeCharArray, newCursorNodeCharArray);
  13267. var cursorOffset = newCursorNodeStart;
  13268. var _iteratorNormalCompletion = true;
  13269. var _didIteratorError = false;
  13270. var _iteratorError = undefined;
  13271. try {
  13272. for (var _iterator = cursorNodeDiff[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  13273. var entry = _step.value;
  13274. if (entry.removed) {
  13275. if (entry.value.indexOf(CURSOR) > -1) {
  13276. break;
  13277. }
  13278. } else {
  13279. cursorOffset += entry.count;
  13280. }
  13281. }
  13282. } catch (err) {
  13283. _didIteratorError = true;
  13284. _iteratorError = err;
  13285. } finally {
  13286. try {
  13287. if (!_iteratorNormalCompletion && _iterator.return != null) {
  13288. _iterator.return();
  13289. }
  13290. } finally {
  13291. if (_didIteratorError) {
  13292. throw _iteratorError;
  13293. }
  13294. }
  13295. }
  13296. return {
  13297. formatted: result.formatted,
  13298. cursorOffset: cursorOffset
  13299. };
  13300. }
  13301. return {
  13302. formatted: result.formatted
  13303. };
  13304. }
  13305. function formatRange(text, opts) {
  13306. var parsed = parser.parse(text, opts);
  13307. var ast = parsed.ast;
  13308. text = parsed.text;
  13309. var range = rangeUtil.calculateRange(text, opts, ast);
  13310. var rangeStart = range.rangeStart;
  13311. var rangeEnd = range.rangeEnd;
  13312. var rangeString = text.slice(rangeStart, rangeEnd); // Try to extend the range backwards to the beginning of the line.
  13313. // This is so we can detect indentation correctly and restore it.
  13314. // Use `Math.min` since `lastIndexOf` returns 0 when `rangeStart` is 0
  13315. var rangeStart2 = Math.min(rangeStart, text.lastIndexOf("\n", rangeStart) + 1);
  13316. var indentString = text.slice(rangeStart2, rangeStart);
  13317. var alignmentSize = util.getAlignmentSize(indentString, opts.tabWidth);
  13318. var rangeResult = coreFormat(rangeString, Object.assign({}, opts, {
  13319. rangeStart: 0,
  13320. rangeEnd: Infinity,
  13321. printWidth: opts.printWidth - alignmentSize,
  13322. // track the cursor offset only if it's within our range
  13323. cursorOffset: opts.cursorOffset >= rangeStart && opts.cursorOffset < rangeEnd ? opts.cursorOffset - rangeStart : -1
  13324. }), alignmentSize); // Since the range contracts to avoid trailing whitespace,
  13325. // we need to remove the newline that was inserted by the `format` call.
  13326. var rangeTrimmed = rangeResult.formatted.trimRight();
  13327. var rangeLeft = text.slice(0, rangeStart);
  13328. var rangeRight = text.slice(rangeEnd);
  13329. var cursorOffset = opts.cursorOffset;
  13330. if (opts.cursorOffset >= rangeEnd) {
  13331. // handle the case where the cursor was past the end of the range
  13332. cursorOffset = opts.cursorOffset - rangeEnd + (rangeStart + rangeTrimmed.length);
  13333. } else if (rangeResult.cursorOffset !== undefined) {
  13334. // handle the case where the cursor was in the range
  13335. cursorOffset = rangeResult.cursorOffset + rangeStart;
  13336. } // keep the cursor as it was if it was before the start of the range
  13337. var formatted;
  13338. if (opts.endOfLine === "lf") {
  13339. formatted = rangeLeft + rangeTrimmed + rangeRight;
  13340. } else {
  13341. var eol = convertEndOfLineToChars(opts.endOfLine);
  13342. if (cursorOffset >= 0) {
  13343. var parts = [rangeLeft, rangeTrimmed, rangeRight];
  13344. var partIndex = 0;
  13345. var partOffset = cursorOffset;
  13346. while (partIndex < parts.length) {
  13347. var part = parts[partIndex];
  13348. if (partOffset < part.length) {
  13349. parts[partIndex] = parts[partIndex].slice(0, partOffset) + PLACEHOLDERS.cursorOffset + parts[partIndex].slice(partOffset);
  13350. break;
  13351. }
  13352. partIndex++;
  13353. partOffset -= part.length;
  13354. }
  13355. var newRangeLeft = parts[0],
  13356. newRangeTrimmed = parts[1],
  13357. newRangeRight = parts[2];
  13358. formatted = (newRangeLeft.replace(/\n/g, eol) + newRangeTrimmed + newRangeRight.replace(/\n/g, eol)).replace(PLACEHOLDERS.cursorOffset, function (_, index) {
  13359. cursorOffset = index;
  13360. return "";
  13361. });
  13362. } else {
  13363. formatted = rangeLeft.replace(/\n/g, eol) + rangeTrimmed + rangeRight.replace(/\n/g, eol);
  13364. }
  13365. }
  13366. return {
  13367. formatted: formatted,
  13368. cursorOffset: cursorOffset
  13369. };
  13370. }
  13371. function format(text, opts) {
  13372. var selectedParser = parser.resolveParser(opts);
  13373. var hasPragma = !selectedParser.hasPragma || selectedParser.hasPragma(text);
  13374. if (opts.requirePragma && !hasPragma) {
  13375. return {
  13376. formatted: text
  13377. };
  13378. }
  13379. if (opts.endOfLine === "auto") {
  13380. opts.endOfLine = guessEndOfLine(text);
  13381. }
  13382. var hasCursor = opts.cursorOffset >= 0;
  13383. var hasRangeStart = opts.rangeStart > 0;
  13384. var hasRangeEnd = opts.rangeEnd < text.length; // get rid of CR/CRLF parsing
  13385. if (text.indexOf("\r") !== -1) {
  13386. var offsetKeys = [hasCursor && "cursorOffset", hasRangeStart && "rangeStart", hasRangeEnd && "rangeEnd"].filter(Boolean).sort(function (aKey, bKey) {
  13387. return opts[aKey] - opts[bKey];
  13388. });
  13389. for (var i = offsetKeys.length - 1; i >= 0; i--) {
  13390. var key = offsetKeys[i];
  13391. text = text.slice(0, opts[key]) + PLACEHOLDERS[key] + text.slice(opts[key]);
  13392. }
  13393. text = text.replace(/\r\n?/g, "\n");
  13394. var _loop = function _loop(_i) {
  13395. var key = offsetKeys[_i];
  13396. text = text.replace(PLACEHOLDERS[key], function (_, index) {
  13397. opts[key] = index;
  13398. return "";
  13399. });
  13400. };
  13401. for (var _i = 0; _i < offsetKeys.length; _i++) {
  13402. _loop(_i);
  13403. }
  13404. }
  13405. var hasUnicodeBOM = text.charCodeAt(0) === UTF8BOM;
  13406. if (hasUnicodeBOM) {
  13407. text = text.substring(1);
  13408. if (hasCursor) {
  13409. opts.cursorOffset++;
  13410. }
  13411. if (hasRangeStart) {
  13412. opts.rangeStart++;
  13413. }
  13414. if (hasRangeEnd) {
  13415. opts.rangeEnd++;
  13416. }
  13417. }
  13418. if (!hasCursor) {
  13419. opts.cursorOffset = -1;
  13420. }
  13421. if (opts.rangeStart < 0) {
  13422. opts.rangeStart = 0;
  13423. }
  13424. if (opts.rangeEnd > text.length) {
  13425. opts.rangeEnd = text.length;
  13426. }
  13427. var result = hasRangeStart || hasRangeEnd ? formatRange(text, opts) : coreFormat(opts.insertPragma && opts.printer.insertPragma && !hasPragma ? opts.printer.insertPragma(text) : text, opts);
  13428. if (hasUnicodeBOM) {
  13429. result.formatted = String.fromCharCode(UTF8BOM) + result.formatted;
  13430. if (hasCursor) {
  13431. result.cursorOffset++;
  13432. }
  13433. }
  13434. return result;
  13435. }
  13436. var core = {
  13437. formatWithCursor: function formatWithCursor(text, opts) {
  13438. opts = normalizeOptions(opts);
  13439. return format(text, opts);
  13440. },
  13441. parse: function parse(text, opts, massage) {
  13442. opts = normalizeOptions(opts);
  13443. if (text.indexOf("\r") !== -1) {
  13444. text = text.replace(/\r\n?/g, "\n");
  13445. }
  13446. var parsed = parser.parse(text, opts);
  13447. if (massage) {
  13448. parsed.ast = massageAst(parsed.ast, opts);
  13449. }
  13450. return parsed;
  13451. },
  13452. formatAST: function formatAST(ast, opts) {
  13453. opts = normalizeOptions(opts);
  13454. var doc$$1 = astToDoc(ast, opts);
  13455. return _printDocToString(doc$$1, opts);
  13456. },
  13457. // Doesn't handle shebang for now
  13458. formatDoc: function formatDoc(doc$$1, opts) {
  13459. var debug = printDocToDebug(doc$$1);
  13460. opts = normalizeOptions(Object.assign({}, opts, {
  13461. parser: "babel"
  13462. }));
  13463. return format(debug, opts).formatted;
  13464. },
  13465. printToDoc: function printToDoc(text, opts) {
  13466. opts = normalizeOptions(opts);
  13467. var parsed = parser.parse(text, opts);
  13468. var ast = parsed.ast;
  13469. text = parsed.text;
  13470. attachComments(text, ast, opts);
  13471. return astToDoc(ast, opts);
  13472. },
  13473. printDocToString: function printDocToString(doc$$1, opts) {
  13474. return _printDocToString(doc$$1, normalizeOptions(opts));
  13475. }
  13476. };
  13477. var index$11 = ["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"];
  13478. var htmlTagNames = Object.freeze({
  13479. default: index$11
  13480. });
  13481. var htmlTagNames$1 = ( htmlTagNames && index$11 ) || htmlTagNames;
  13482. function clean(ast, newObj, parent) {
  13483. ["raw", // front-matter
  13484. "raws", "sourceIndex", "source", "before", "after", "trailingComma"].forEach(function (name) {
  13485. delete newObj[name];
  13486. });
  13487. if (ast.type === "yaml") {
  13488. delete newObj.value;
  13489. } // --insert-pragma
  13490. if (ast.type === "css-comment" && parent.type === "css-root" && parent.nodes.length !== 0 && ( // first non-front-matter comment
  13491. parent.nodes[0] === ast || (parent.nodes[0].type === "yaml" || parent.nodes[0].type === "toml") && parent.nodes[1] === ast)) {
  13492. /**
  13493. * something
  13494. *
  13495. * @format
  13496. */
  13497. delete newObj.text; // standalone pragma
  13498. if (/^\*\s*@(format|prettier)\s*$/.test(ast.text)) {
  13499. return null;
  13500. }
  13501. }
  13502. if (ast.type === "media-query" || ast.type === "media-query-list" || ast.type === "media-feature-expression") {
  13503. delete newObj.value;
  13504. }
  13505. if (ast.type === "css-rule") {
  13506. delete newObj.params;
  13507. }
  13508. if (ast.type === "selector-combinator") {
  13509. newObj.value = newObj.value.replace(/\s+/g, " ");
  13510. }
  13511. if (ast.type === "media-feature") {
  13512. newObj.value = newObj.value.replace(/ /g, "");
  13513. }
  13514. 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") {
  13515. newObj.value = newObj.value.toLowerCase();
  13516. }
  13517. if (ast.type === "css-decl") {
  13518. newObj.prop = newObj.prop.toLowerCase();
  13519. }
  13520. if (ast.type === "css-atrule" || ast.type === "css-import") {
  13521. newObj.name = newObj.name.toLowerCase();
  13522. }
  13523. if (ast.type === "value-number") {
  13524. newObj.unit = newObj.unit.toLowerCase();
  13525. }
  13526. 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) {
  13527. newObj.value = cleanCSSStrings(newObj.value);
  13528. }
  13529. if (ast.type === "selector-attribute") {
  13530. newObj.attribute = newObj.attribute.trim();
  13531. if (newObj.namespace) {
  13532. if (typeof newObj.namespace === "string") {
  13533. newObj.namespace = newObj.namespace.trim();
  13534. if (newObj.namespace.length === 0) {
  13535. newObj.namespace = true;
  13536. }
  13537. }
  13538. }
  13539. if (newObj.value) {
  13540. newObj.value = newObj.value.trim().replace(/^['"]|['"]$/g, "");
  13541. delete newObj.quoted;
  13542. }
  13543. }
  13544. 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) {
  13545. newObj.value = newObj.value.replace(/([\d.eE+-]+)([a-zA-Z]*)/g, function (match, numStr, unit) {
  13546. var num = Number(numStr);
  13547. return isNaN(num) ? match : num + unit.toLowerCase();
  13548. });
  13549. }
  13550. if (ast.type === "selector-tag") {
  13551. var lowercasedValue = ast.value.toLowerCase();
  13552. if (htmlTagNames$1.indexOf(lowercasedValue) !== -1) {
  13553. newObj.value = lowercasedValue;
  13554. }
  13555. if (["from", "to"].indexOf(lowercasedValue) !== -1) {
  13556. newObj.value = lowercasedValue;
  13557. }
  13558. } // Workaround when `postcss-values-parser` parse `not`, `and` or `or` keywords as `value-func`
  13559. if (ast.type === "css-atrule" && ast.name.toLowerCase() === "supports") {
  13560. delete newObj.value;
  13561. } // Workaround for SCSS nested properties
  13562. if (ast.type === "selector-unknown") {
  13563. delete newObj.value;
  13564. }
  13565. }
  13566. function cleanCSSStrings(value) {
  13567. return value.replace(/'/g, '"').replace(/\\([^a-fA-F\d])/g, "$1");
  13568. }
  13569. var clean_1 = clean;
  13570. var _require$$0$builders$1 = doc.builders;
  13571. var hardline$4 = _require$$0$builders$1.hardline;
  13572. var literalline$1 = _require$$0$builders$1.literalline;
  13573. var concat$5 = _require$$0$builders$1.concat;
  13574. var markAsRoot$1 = _require$$0$builders$1.markAsRoot;
  13575. var mapDoc$3 = doc.utils.mapDoc;
  13576. function embed(path, print, textToDoc
  13577. /*, options */
  13578. ) {
  13579. var node = path.getValue();
  13580. if (node.type === "yaml") {
  13581. return markAsRoot$1(concat$5(["---", hardline$4, node.value.trim() ? replaceNewlinesWithLiterallines(textToDoc(node.value, {
  13582. parser: "yaml"
  13583. })) : "", "---", hardline$4]));
  13584. }
  13585. return null;
  13586. function replaceNewlinesWithLiterallines(doc$$2) {
  13587. return mapDoc$3(doc$$2, function (currentDoc) {
  13588. return typeof currentDoc === "string" && currentDoc.includes("\n") ? concat$5(currentDoc.split(/(\n)/g).map(function (v, i) {
  13589. return i % 2 === 0 ? v : literalline$1;
  13590. })) : currentDoc;
  13591. });
  13592. }
  13593. }
  13594. var embed_1 = embed;
  13595. var detectNewline = createCommonjsModule(function (module) {
  13596. 'use strict';
  13597. module.exports = function (str) {
  13598. if (typeof str !== 'string') {
  13599. throw new TypeError('Expected a string');
  13600. }
  13601. var newlines = str.match(/(?:\r?\n)/g) || [];
  13602. if (newlines.length === 0) {
  13603. return null;
  13604. }
  13605. var crlf = newlines.filter(function (el) {
  13606. return el === '\r\n';
  13607. }).length;
  13608. var lf = newlines.length - crlf;
  13609. return crlf > lf ? '\r\n' : '\n';
  13610. };
  13611. module.exports.graceful = function (str) {
  13612. return module.exports(str) || '\n';
  13613. };
  13614. });
  13615. var build$1 = createCommonjsModule(function (module, exports) {
  13616. 'use strict';
  13617. Object.defineProperty(exports, '__esModule', {
  13618. value: true
  13619. });
  13620. exports.extract = extract;
  13621. exports.strip = strip;
  13622. exports.parse = parse;
  13623. exports.parseWithComments = parseWithComments;
  13624. exports.print = print;
  13625. var _detectNewline;
  13626. function _load_detectNewline() {
  13627. return _detectNewline = _interopRequireDefault(detectNewline);
  13628. }
  13629. var _os;
  13630. function _load_os() {
  13631. return _os = require$$1$1;
  13632. }
  13633. function _interopRequireDefault(obj) {
  13634. return obj && obj.__esModule ? obj : {
  13635. default: obj
  13636. };
  13637. }
  13638. /**
  13639. * Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
  13640. *
  13641. * This source code is licensed under the MIT license found in the
  13642. * LICENSE file in the root directory of this source tree.
  13643. *
  13644. *
  13645. */
  13646. var commentEndRe = /\*\/$/;
  13647. var commentStartRe = /^\/\*\*/;
  13648. var docblockRe = /^\s*(\/\*\*?(.|\r?\n)*?\*\/)/;
  13649. var lineCommentRe = /(^|\s+)\/\/([^\r\n]*)/g;
  13650. var ltrimNewlineRe = /^(\r?\n)+/;
  13651. var multilineRe = /(?:^|\r?\n) *(@[^\r\n]*?) *\r?\n *(?![^@\r\n]*\/\/[^]*)([^@\r\n\s][^@\r\n]+?) *\r?\n/g;
  13652. var propertyRe = /(?:^|\r?\n) *@(\S+) *([^\r\n]*)/g;
  13653. var stringStartRe = /(\r?\n|^) *\* ?/g;
  13654. function extract(contents) {
  13655. var match = contents.match(docblockRe);
  13656. return match ? match[0].trimLeft() : '';
  13657. }
  13658. function strip(contents) {
  13659. var match = contents.match(docblockRe);
  13660. return match && match[0] ? contents.substring(match[0].length) : contents;
  13661. }
  13662. function parse(docblock) {
  13663. return parseWithComments(docblock).pragmas;
  13664. }
  13665. function parseWithComments(docblock) {
  13666. var line = (0, (_detectNewline || _load_detectNewline()).default)(docblock) || (_os || _load_os()).EOL;
  13667. docblock = docblock.replace(commentStartRe, '').replace(commentEndRe, '').replace(stringStartRe, '$1'); // Normalize multi-line directives
  13668. var prev = '';
  13669. while (prev !== docblock) {
  13670. prev = docblock;
  13671. docblock = docblock.replace(multilineRe, "".concat(line, "$1 $2").concat(line));
  13672. }
  13673. docblock = docblock.replace(ltrimNewlineRe, '').trimRight();
  13674. var result = Object.create(null);
  13675. var comments = docblock.replace(propertyRe, '').replace(ltrimNewlineRe, '').trimRight();
  13676. var match;
  13677. while (match = propertyRe.exec(docblock)) {
  13678. // strip linecomments from pragmas
  13679. var nextPragma = match[2].replace(lineCommentRe, '');
  13680. if (typeof result[match[1]] === 'string' || Array.isArray(result[match[1]])) {
  13681. result[match[1]] = [].concat(result[match[1]], nextPragma);
  13682. } else {
  13683. result[match[1]] = nextPragma;
  13684. }
  13685. }
  13686. return {
  13687. comments: comments,
  13688. pragmas: result
  13689. };
  13690. }
  13691. function print(_ref) {
  13692. var _ref$comments = _ref.comments;
  13693. var comments = _ref$comments === undefined ? '' : _ref$comments;
  13694. var _ref$pragmas = _ref.pragmas;
  13695. var pragmas = _ref$pragmas === undefined ? {} : _ref$pragmas;
  13696. var line = (0, (_detectNewline || _load_detectNewline()).default)(comments) || (_os || _load_os()).EOL;
  13697. var head = '/**';
  13698. var start = ' *';
  13699. var tail = ' */';
  13700. var keys = Object.keys(pragmas);
  13701. var printedObject = keys.map(function (key) {
  13702. return printKeyValues(key, pragmas[key]);
  13703. }).reduce(function (arr, next) {
  13704. return arr.concat(next);
  13705. }, []).map(function (keyValue) {
  13706. return start + ' ' + keyValue + line;
  13707. }).join('');
  13708. if (!comments) {
  13709. if (keys.length === 0) {
  13710. return '';
  13711. }
  13712. if (keys.length === 1 && !Array.isArray(pragmas[keys[0]])) {
  13713. var value = pragmas[keys[0]];
  13714. return "".concat(head, " ").concat(printKeyValues(keys[0], value)[0]).concat(tail);
  13715. }
  13716. }
  13717. var printedComments = comments.split(line).map(function (textLine) {
  13718. return "".concat(start, " ").concat(textLine);
  13719. }).join(line) + line;
  13720. return head + line + (comments ? printedComments : '') + (comments && keys.length ? start + line : '') + printedObject + tail;
  13721. }
  13722. function printKeyValues(key, valueOrArray) {
  13723. return [].concat(valueOrArray).map(function (value) {
  13724. return "@".concat(key, " ").concat(value).trim();
  13725. });
  13726. }
  13727. });
  13728. unwrapExports(build$1);
  13729. function hasPragma$1(text) {
  13730. var pragmas = Object.keys(build$1.parse(build$1.extract(text)));
  13731. return pragmas.indexOf("prettier") !== -1 || pragmas.indexOf("format") !== -1;
  13732. }
  13733. function insertPragma$2(text) {
  13734. var parsedDocblock = build$1.parseWithComments(build$1.extract(text));
  13735. var pragmas = Object.assign({
  13736. format: ""
  13737. }, parsedDocblock.pragmas);
  13738. var newDocblock = build$1.print({
  13739. pragmas: pragmas,
  13740. comments: parsedDocblock.comments.replace(/^(\s+?\r?\n)+/, "") // remove leading newlines
  13741. }).replace(/(\r\n|\r)/g, "\n"); // normalise newlines (mitigate use of os.EOL by jest-docblock)
  13742. var strippedText = build$1.strip(text);
  13743. var separatingNewlines = strippedText.startsWith("\n") ? "\n" : "\n\n";
  13744. return newDocblock + separatingNewlines + strippedText;
  13745. }
  13746. var pragma$2 = {
  13747. hasPragma: hasPragma$1,
  13748. insertPragma: insertPragma$2
  13749. };
  13750. var DELIMITER_MAP = {
  13751. "---": "yaml",
  13752. "+++": "toml"
  13753. };
  13754. function parse$3(text) {
  13755. var delimiterRegex = Object.keys(DELIMITER_MAP).map(escapeStringRegexp).join("|");
  13756. var match = text.match( // trailing spaces after delimiters are allowed
  13757. new RegExp("^(".concat(delimiterRegex, ")[^\\n\\S]*\\n(?:([\\s\\S]*?)\\n)?\\1[^\\n\\S]*(\\n|$)")));
  13758. if (match === null) {
  13759. return {
  13760. frontMatter: null,
  13761. content: text
  13762. };
  13763. }
  13764. var raw = match[0].replace(/\n$/, "");
  13765. var delimiter = match[1];
  13766. var value = match[2];
  13767. return {
  13768. frontMatter: {
  13769. type: DELIMITER_MAP[delimiter],
  13770. value: value,
  13771. raw: raw
  13772. },
  13773. content: match[0].replace(/[^\n]/g, " ") + text.slice(match[0].length)
  13774. };
  13775. }
  13776. var frontMatter = parse$3;
  13777. function hasPragma(text) {
  13778. return pragma$2.hasPragma(frontMatter(text).content);
  13779. }
  13780. function insertPragma$1(text) {
  13781. var _parseFrontMatter = frontMatter(text),
  13782. frontMatter$$1 = _parseFrontMatter.frontMatter,
  13783. content = _parseFrontMatter.content;
  13784. return (frontMatter$$1 ? frontMatter$$1.raw + "\n\n" : "") + pragma$2.insertPragma(content);
  13785. }
  13786. var pragma = {
  13787. hasPragma: hasPragma,
  13788. insertPragma: insertPragma$1
  13789. };
  13790. 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"];
  13791. function getAncestorCounter(path, typeOrTypes) {
  13792. var types = [].concat(typeOrTypes);
  13793. var counter = -1;
  13794. var ancestorNode;
  13795. while (ancestorNode = path.getParentNode(++counter)) {
  13796. if (types.indexOf(ancestorNode.type) !== -1) {
  13797. return counter;
  13798. }
  13799. }
  13800. return -1;
  13801. }
  13802. function getAncestorNode$1(path, typeOrTypes) {
  13803. var counter = getAncestorCounter(path, typeOrTypes);
  13804. return counter === -1 ? null : path.getParentNode(counter);
  13805. }
  13806. function getPropOfDeclNode$1(path) {
  13807. var declAncestorNode = getAncestorNode$1(path, "css-decl");
  13808. return declAncestorNode && declAncestorNode.prop && declAncestorNode.prop.toLowerCase();
  13809. }
  13810. function isSCSS$1(parser, text) {
  13811. var hasExplicitParserChoice = parser === "less" || parser === "scss";
  13812. var IS_POSSIBLY_SCSS = /(\w\s*: [^}:]+|#){|@import[^\n]+(url|,)/;
  13813. return hasExplicitParserChoice ? parser === "scss" : IS_POSSIBLY_SCSS.test(text);
  13814. }
  13815. function isWideKeywords$1(value) {
  13816. return ["initial", "inherit", "unset", "revert"].indexOf(value.toLowerCase()) !== -1;
  13817. }
  13818. function isKeyframeAtRuleKeywords$1(path, value) {
  13819. var atRuleAncestorNode = getAncestorNode$1(path, "css-atrule");
  13820. return atRuleAncestorNode && atRuleAncestorNode.name && atRuleAncestorNode.name.toLowerCase().endsWith("keyframes") && ["from", "to"].indexOf(value.toLowerCase()) !== -1;
  13821. }
  13822. function maybeToLowerCase$1(value) {
  13823. return value.includes("$") || value.includes("@") || value.includes("#") || value.startsWith("%") || value.startsWith("--") || value.startsWith(":--") || value.includes("(") && value.includes(")") ? value : value.toLowerCase();
  13824. }
  13825. function insideValueFunctionNode$1(path, functionName) {
  13826. var funcAncestorNode = getAncestorNode$1(path, "value-func");
  13827. return funcAncestorNode && funcAncestorNode.value && funcAncestorNode.value.toLowerCase() === functionName;
  13828. }
  13829. function insideICSSRuleNode$1(path) {
  13830. var ruleAncestorNode = getAncestorNode$1(path, "css-rule");
  13831. return ruleAncestorNode && ruleAncestorNode.raws && ruleAncestorNode.raws.selector && (ruleAncestorNode.raws.selector.startsWith(":import") || ruleAncestorNode.raws.selector.startsWith(":export"));
  13832. }
  13833. function insideAtRuleNode$1(path, atRuleNameOrAtRuleNames) {
  13834. var atRuleNames = [].concat(atRuleNameOrAtRuleNames);
  13835. var atRuleAncestorNode = getAncestorNode$1(path, "css-atrule");
  13836. return atRuleAncestorNode && atRuleNames.indexOf(atRuleAncestorNode.name.toLowerCase()) !== -1;
  13837. }
  13838. function insideURLFunctionInImportAtRuleNode$1(path) {
  13839. var node = path.getValue();
  13840. var atRuleAncestorNode = getAncestorNode$1(path, "css-atrule");
  13841. return atRuleAncestorNode && atRuleAncestorNode.name === "import" && node.groups[0].value === "url" && node.groups.length === 2;
  13842. }
  13843. function isURLFunctionNode$1(node) {
  13844. return node.type === "value-func" && node.value.toLowerCase() === "url";
  13845. }
  13846. function isLastNode$1(path, node) {
  13847. var parentNode = path.getParentNode();
  13848. if (!parentNode) {
  13849. return false;
  13850. }
  13851. var nodes = parentNode.nodes;
  13852. return nodes && nodes.indexOf(node) === nodes.length - 1;
  13853. }
  13854. function isHTMLTag$1(value) {
  13855. return htmlTagNames$1.indexOf(value.toLowerCase()) !== -1;
  13856. }
  13857. function isDetachedRulesetDeclarationNode$1(node) {
  13858. // If a Less file ends up being parsed with the SCSS parser, Less
  13859. // variable declarations will be parsed as atrules with names ending
  13860. // with a colon, so keep the original case then.
  13861. if (!node.selector) {
  13862. return false;
  13863. }
  13864. return typeof node.selector === "string" && /^@.+:.*$/.test(node.selector) || node.selector.value && /^@.+:.*$/.test(node.selector.value);
  13865. }
  13866. function isForKeywordNode$1(node) {
  13867. return node.type === "value-word" && ["from", "through", "end"].indexOf(node.value) !== -1;
  13868. }
  13869. function isIfElseKeywordNode$1(node) {
  13870. return node.type === "value-word" && ["and", "or", "not"].indexOf(node.value) !== -1;
  13871. }
  13872. function isEachKeywordNode$1(node) {
  13873. return node.type === "value-word" && node.value === "in";
  13874. }
  13875. function isMultiplicationNode$1(node) {
  13876. return node.type === "value-operator" && node.value === "*";
  13877. }
  13878. function isDivisionNode$1(node) {
  13879. return node.type === "value-operator" && node.value === "/";
  13880. }
  13881. function isAdditionNode$1(node) {
  13882. return node.type === "value-operator" && node.value === "+";
  13883. }
  13884. function isSubtractionNode$1(node) {
  13885. return node.type === "value-operator" && node.value === "-";
  13886. }
  13887. function isModuloNode(node) {
  13888. return node.type === "value-operator" && node.value === "%";
  13889. }
  13890. function isMathOperatorNode$1(node) {
  13891. return isMultiplicationNode$1(node) || isDivisionNode$1(node) || isAdditionNode$1(node) || isSubtractionNode$1(node) || isModuloNode(node);
  13892. }
  13893. function isEqualityOperatorNode$1(node) {
  13894. return node.type === "value-word" && ["==", "!="].indexOf(node.value) !== -1;
  13895. }
  13896. function isRelationalOperatorNode$1(node) {
  13897. return node.type === "value-word" && ["<", ">", "<=", ">="].indexOf(node.value) !== -1;
  13898. }
  13899. function isSCSSControlDirectiveNode$1(node) {
  13900. return node.type === "css-atrule" && ["if", "else", "for", "each", "while"].indexOf(node.name) !== -1;
  13901. }
  13902. function isSCSSNestedPropertyNode(node) {
  13903. if (!node.selector) {
  13904. return false;
  13905. }
  13906. return node.selector.replace(/\/\*.*?\*\//, "").replace(/\/\/.*?\n/, "").trim().endsWith(":");
  13907. }
  13908. function isDetachedRulesetCallNode$1(node) {
  13909. return node.raws && node.raws.params && /^\(\s*\)$/.test(node.raws.params);
  13910. }
  13911. function isTemplatePlaceholderNode$1(node) {
  13912. return node.name.startsWith("prettier-placeholder");
  13913. }
  13914. function isTemplatePropNode$1(node) {
  13915. return node.prop.startsWith("@prettier-placeholder");
  13916. }
  13917. function isPostcssSimpleVarNode$1(currentNode, nextNode) {
  13918. return currentNode.value === "$$" && currentNode.type === "value-func" && nextNode && nextNode.type === "value-word" && !nextNode.raws.before;
  13919. }
  13920. function hasComposesNode$1(node) {
  13921. return node.value && node.value.type === "value-root" && node.value.group && node.value.group.type === "value-value" && node.prop.toLowerCase() === "composes";
  13922. }
  13923. function hasParensAroundNode$1(node) {
  13924. 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;
  13925. }
  13926. function hasEmptyRawBefore$1(node) {
  13927. return node.raws && node.raws.before === "";
  13928. }
  13929. function isKeyValuePairNode$1(node) {
  13930. return node.type === "value-comma_group" && node.groups && node.groups[1] && node.groups[1].type === "value-colon";
  13931. }
  13932. function isKeyValuePairInParenGroupNode(node) {
  13933. return node.type === "value-paren_group" && node.groups && node.groups[0] && isKeyValuePairNode$1(node.groups[0]);
  13934. }
  13935. function isSCSSMapItemNode$1(path) {
  13936. var node = path.getValue(); // Ignore empty item (i.e. `$key: ()`)
  13937. if (node.groups.length === 0) {
  13938. return false;
  13939. }
  13940. var parentParentNode = path.getParentNode(1); // Check open parens contain key/value pair (i.e. `(key: value)` and `(key: (value, other-value)`)
  13941. if (!isKeyValuePairInParenGroupNode(node) && !(parentParentNode && isKeyValuePairInParenGroupNode(parentParentNode))) {
  13942. return false;
  13943. }
  13944. var declNode = getAncestorNode$1(path, "css-decl"); // SCSS map declaration (i.e. `$map: (key: value, other-key: other-value)`)
  13945. if (declNode && declNode.prop && declNode.prop.startsWith("$")) {
  13946. return true;
  13947. } // List as value of key inside SCSS map (i.e. `$map: (key: (value other-value other-other-value))`)
  13948. if (isKeyValuePairInParenGroupNode(parentParentNode)) {
  13949. return true;
  13950. } // SCSS Map is argument of function (i.e. `func((key: value, other-key: other-value))`)
  13951. if (parentParentNode.type === "value-func") {
  13952. return true;
  13953. }
  13954. return false;
  13955. }
  13956. function isInlineValueCommentNode$1(node) {
  13957. return node.type === "value-comment" && node.inline;
  13958. }
  13959. function isHashNode$1(node) {
  13960. return node.type === "value-word" && node.value === "#";
  13961. }
  13962. function isLeftCurlyBraceNode$1(node) {
  13963. return node.type === "value-word" && node.value === "{";
  13964. }
  13965. function isRightCurlyBraceNode$1(node) {
  13966. return node.type === "value-word" && node.value === "}";
  13967. }
  13968. function isWordNode$1(node) {
  13969. return ["value-word", "value-atword"].indexOf(node.type) !== -1;
  13970. }
  13971. function isColonNode$1(node) {
  13972. return node.type === "value-colon";
  13973. }
  13974. function isMediaAndSupportsKeywords$1(node) {
  13975. return node.value && ["not", "and", "or"].indexOf(node.value.toLowerCase()) !== -1;
  13976. }
  13977. function isColorAdjusterFuncNode$1(node) {
  13978. if (node.type !== "value-func") {
  13979. return false;
  13980. }
  13981. return colorAdjusterFunctions.indexOf(node.value.toLowerCase()) !== -1;
  13982. }
  13983. var utils$4 = {
  13984. getAncestorCounter: getAncestorCounter,
  13985. getAncestorNode: getAncestorNode$1,
  13986. getPropOfDeclNode: getPropOfDeclNode$1,
  13987. maybeToLowerCase: maybeToLowerCase$1,
  13988. insideValueFunctionNode: insideValueFunctionNode$1,
  13989. insideICSSRuleNode: insideICSSRuleNode$1,
  13990. insideAtRuleNode: insideAtRuleNode$1,
  13991. insideURLFunctionInImportAtRuleNode: insideURLFunctionInImportAtRuleNode$1,
  13992. isKeyframeAtRuleKeywords: isKeyframeAtRuleKeywords$1,
  13993. isHTMLTag: isHTMLTag$1,
  13994. isWideKeywords: isWideKeywords$1,
  13995. isSCSS: isSCSS$1,
  13996. isLastNode: isLastNode$1,
  13997. isSCSSControlDirectiveNode: isSCSSControlDirectiveNode$1,
  13998. isDetachedRulesetDeclarationNode: isDetachedRulesetDeclarationNode$1,
  13999. isRelationalOperatorNode: isRelationalOperatorNode$1,
  14000. isEqualityOperatorNode: isEqualityOperatorNode$1,
  14001. isMultiplicationNode: isMultiplicationNode$1,
  14002. isDivisionNode: isDivisionNode$1,
  14003. isAdditionNode: isAdditionNode$1,
  14004. isSubtractionNode: isSubtractionNode$1,
  14005. isModuloNode: isModuloNode,
  14006. isMathOperatorNode: isMathOperatorNode$1,
  14007. isEachKeywordNode: isEachKeywordNode$1,
  14008. isForKeywordNode: isForKeywordNode$1,
  14009. isURLFunctionNode: isURLFunctionNode$1,
  14010. isIfElseKeywordNode: isIfElseKeywordNode$1,
  14011. hasComposesNode: hasComposesNode$1,
  14012. hasParensAroundNode: hasParensAroundNode$1,
  14013. hasEmptyRawBefore: hasEmptyRawBefore$1,
  14014. isSCSSNestedPropertyNode: isSCSSNestedPropertyNode,
  14015. isDetachedRulesetCallNode: isDetachedRulesetCallNode$1,
  14016. isTemplatePlaceholderNode: isTemplatePlaceholderNode$1,
  14017. isTemplatePropNode: isTemplatePropNode$1,
  14018. isPostcssSimpleVarNode: isPostcssSimpleVarNode$1,
  14019. isKeyValuePairNode: isKeyValuePairNode$1,
  14020. isKeyValuePairInParenGroupNode: isKeyValuePairInParenGroupNode,
  14021. isSCSSMapItemNode: isSCSSMapItemNode$1,
  14022. isInlineValueCommentNode: isInlineValueCommentNode$1,
  14023. isHashNode: isHashNode$1,
  14024. isLeftCurlyBraceNode: isLeftCurlyBraceNode$1,
  14025. isRightCurlyBraceNode: isRightCurlyBraceNode$1,
  14026. isWordNode: isWordNode$1,
  14027. isColonNode: isColonNode$1,
  14028. isMediaAndSupportsKeywords: isMediaAndSupportsKeywords$1,
  14029. isColorAdjusterFuncNode: isColorAdjusterFuncNode$1
  14030. };
  14031. var insertPragma = pragma.insertPragma;
  14032. var printNumber$1 = util.printNumber;
  14033. var printString$1 = util.printString;
  14034. var hasIgnoreComment$1 = util.hasIgnoreComment;
  14035. var hasNewline$2 = util.hasNewline;
  14036. var isNextLineEmpty$2 = utilShared.isNextLineEmpty;
  14037. var _require$$3$builders = doc.builders;
  14038. var concat$4 = _require$$3$builders.concat;
  14039. var join$2 = _require$$3$builders.join;
  14040. var line$3 = _require$$3$builders.line;
  14041. var hardline$3 = _require$$3$builders.hardline;
  14042. var softline$1 = _require$$3$builders.softline;
  14043. var group$1 = _require$$3$builders.group;
  14044. var fill$2 = _require$$3$builders.fill;
  14045. var indent$2 = _require$$3$builders.indent;
  14046. var dedent$2 = _require$$3$builders.dedent;
  14047. var ifBreak$1 = _require$$3$builders.ifBreak;
  14048. var removeLines$1 = doc.utils.removeLines;
  14049. var getAncestorNode = utils$4.getAncestorNode;
  14050. var getPropOfDeclNode = utils$4.getPropOfDeclNode;
  14051. var maybeToLowerCase = utils$4.maybeToLowerCase;
  14052. var insideValueFunctionNode = utils$4.insideValueFunctionNode;
  14053. var insideICSSRuleNode = utils$4.insideICSSRuleNode;
  14054. var insideAtRuleNode = utils$4.insideAtRuleNode;
  14055. var insideURLFunctionInImportAtRuleNode = utils$4.insideURLFunctionInImportAtRuleNode;
  14056. var isKeyframeAtRuleKeywords = utils$4.isKeyframeAtRuleKeywords;
  14057. var isHTMLTag = utils$4.isHTMLTag;
  14058. var isWideKeywords = utils$4.isWideKeywords;
  14059. var isSCSS = utils$4.isSCSS;
  14060. var isLastNode = utils$4.isLastNode;
  14061. var isSCSSControlDirectiveNode = utils$4.isSCSSControlDirectiveNode;
  14062. var isDetachedRulesetDeclarationNode = utils$4.isDetachedRulesetDeclarationNode;
  14063. var isRelationalOperatorNode = utils$4.isRelationalOperatorNode;
  14064. var isEqualityOperatorNode = utils$4.isEqualityOperatorNode;
  14065. var isMultiplicationNode = utils$4.isMultiplicationNode;
  14066. var isDivisionNode = utils$4.isDivisionNode;
  14067. var isAdditionNode = utils$4.isAdditionNode;
  14068. var isSubtractionNode = utils$4.isSubtractionNode;
  14069. var isMathOperatorNode = utils$4.isMathOperatorNode;
  14070. var isEachKeywordNode = utils$4.isEachKeywordNode;
  14071. var isForKeywordNode = utils$4.isForKeywordNode;
  14072. var isURLFunctionNode = utils$4.isURLFunctionNode;
  14073. var isIfElseKeywordNode = utils$4.isIfElseKeywordNode;
  14074. var hasComposesNode = utils$4.hasComposesNode;
  14075. var hasParensAroundNode = utils$4.hasParensAroundNode;
  14076. var hasEmptyRawBefore = utils$4.hasEmptyRawBefore;
  14077. var isKeyValuePairNode = utils$4.isKeyValuePairNode;
  14078. var isDetachedRulesetCallNode = utils$4.isDetachedRulesetCallNode;
  14079. var isTemplatePlaceholderNode = utils$4.isTemplatePlaceholderNode;
  14080. var isTemplatePropNode = utils$4.isTemplatePropNode;
  14081. var isPostcssSimpleVarNode = utils$4.isPostcssSimpleVarNode;
  14082. var isSCSSMapItemNode = utils$4.isSCSSMapItemNode;
  14083. var isInlineValueCommentNode = utils$4.isInlineValueCommentNode;
  14084. var isHashNode = utils$4.isHashNode;
  14085. var isLeftCurlyBraceNode = utils$4.isLeftCurlyBraceNode;
  14086. var isRightCurlyBraceNode = utils$4.isRightCurlyBraceNode;
  14087. var isWordNode = utils$4.isWordNode;
  14088. var isColonNode = utils$4.isColonNode;
  14089. var isMediaAndSupportsKeywords = utils$4.isMediaAndSupportsKeywords;
  14090. var isColorAdjusterFuncNode = utils$4.isColorAdjusterFuncNode;
  14091. function shouldPrintComma(options) {
  14092. switch (options.trailingComma) {
  14093. case "all":
  14094. case "es5":
  14095. return true;
  14096. case "none":
  14097. default:
  14098. return false;
  14099. }
  14100. }
  14101. function genericPrint(path, options, print) {
  14102. var node = path.getValue();
  14103. /* istanbul ignore if */
  14104. if (!node) {
  14105. return "";
  14106. }
  14107. if (typeof node === "string") {
  14108. return node;
  14109. }
  14110. switch (node.type) {
  14111. case "yaml":
  14112. case "toml":
  14113. return concat$4([node.raw, hardline$3]);
  14114. case "css-root":
  14115. {
  14116. var nodes = printNodeSequence(path, options, print);
  14117. if (nodes.parts.length) {
  14118. return concat$4([nodes, hardline$3]);
  14119. }
  14120. return nodes;
  14121. }
  14122. case "css-comment":
  14123. {
  14124. if (node.raws.content) {
  14125. return node.raws.content;
  14126. }
  14127. var text = options.originalText.slice(options.locStart(node), options.locEnd(node));
  14128. var rawText = node.raws.text || node.text; // Workaround a bug where the location is off.
  14129. // https://github.com/postcss/postcss-scss/issues/63
  14130. if (text.indexOf(rawText) === -1) {
  14131. if (node.raws.inline) {
  14132. return concat$4(["// ", rawText]);
  14133. }
  14134. return concat$4(["/* ", rawText, " */"]);
  14135. }
  14136. return text;
  14137. }
  14138. case "css-rule":
  14139. {
  14140. return concat$4([path.call(print, "selector"), node.important ? " !important" : "", node.nodes ? concat$4([" {", node.nodes.length > 0 ? indent$2(concat$4([hardline$3, printNodeSequence(path, options, print)])) : "", hardline$3, "}", isDetachedRulesetDeclarationNode(node) ? ";" : ""]) : ";"]);
  14141. }
  14142. case "css-decl":
  14143. {
  14144. var parentNode = path.getParentNode();
  14145. return concat$4([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$1(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$4([" {", indent$2(concat$4([softline$1, printNodeSequence(path, options, print)])), softline$1, "}"]) : isTemplatePropNode(node) && !parentNode.raws.semicolon && options.originalText[options.locEnd(node) - 1] !== ";" ? "" : ";"]);
  14146. }
  14147. case "css-atrule":
  14148. {
  14149. var _parentNode = path.getParentNode();
  14150. return concat$4(["@", // If a Less file ends up being parsed with the SCSS parser, Less
  14151. // variable declarations will be parsed as at-rules with names ending
  14152. // with a colon, so keep the original case then.
  14153. isDetachedRulesetCallNode(node) || node.name.endsWith(":") ? node.name : maybeToLowerCase(node.name), node.params ? concat$4([isDetachedRulesetCallNode(node) ? "" : isTemplatePlaceholderNode(node) && /^\s*\n/.test(node.raws.afterName) ? /^\s*\n\s*\n/.test(node.raws.afterName) ? concat$4([hardline$3, hardline$3]) : hardline$3 : " ", path.call(print, "params")]) : "", node.selector ? indent$2(concat$4([" ", path.call(print, "selector")])) : "", node.value ? group$1(concat$4([" ", path.call(print, "value"), isSCSSControlDirectiveNode(node) ? hasParensAroundNode(node) ? " " : line$3 : ""])) : node.name === "else" ? " " : "", node.nodes ? concat$4([isSCSSControlDirectiveNode(node) ? "" : " ", "{", indent$2(concat$4([node.nodes.length > 0 ? softline$1 : "", printNodeSequence(path, options, print)])), softline$1, "}"]) : isTemplatePlaceholderNode(node) && !_parentNode.raws.semicolon && options.originalText[options.locEnd(node) - 1] !== ";" ? "" : ";"]);
  14154. }
  14155. // postcss-media-query-parser
  14156. case "media-query-list":
  14157. {
  14158. var parts = [];
  14159. path.each(function (childPath) {
  14160. var node = childPath.getValue();
  14161. if (node.type === "media-query" && node.value === "") {
  14162. return;
  14163. }
  14164. parts.push(childPath.call(print));
  14165. }, "nodes");
  14166. return group$1(indent$2(join$2(line$3, parts)));
  14167. }
  14168. case "media-query":
  14169. {
  14170. return concat$4([join$2(" ", path.map(print, "nodes")), isLastNode(path, node) ? "" : ","]);
  14171. }
  14172. case "media-type":
  14173. {
  14174. return adjustNumbers(adjustStrings(node.value, options));
  14175. }
  14176. case "media-feature-expression":
  14177. {
  14178. if (!node.nodes) {
  14179. return node.value;
  14180. }
  14181. return concat$4(["(", concat$4(path.map(print, "nodes")), ")"]);
  14182. }
  14183. case "media-feature":
  14184. {
  14185. return maybeToLowerCase(adjustStrings(node.value.replace(/ +/g, " "), options));
  14186. }
  14187. case "media-colon":
  14188. {
  14189. return concat$4([node.value, " "]);
  14190. }
  14191. case "media-value":
  14192. {
  14193. return adjustNumbers(adjustStrings(node.value, options));
  14194. }
  14195. case "media-keyword":
  14196. {
  14197. return adjustStrings(node.value, options);
  14198. }
  14199. case "media-url":
  14200. {
  14201. return adjustStrings(node.value.replace(/^url\(\s+/gi, "url(").replace(/\s+\)$/gi, ")"), options);
  14202. }
  14203. case "media-unknown":
  14204. {
  14205. return node.value;
  14206. }
  14207. // postcss-selector-parser
  14208. case "selector-root":
  14209. {
  14210. return group$1(concat$4([insideAtRuleNode(path, "custom-selector") ? concat$4([getAncestorNode(path, "css-atrule").customSelector, line$3]) : "", join$2(concat$4([",", insideAtRuleNode(path, ["extend", "custom-selector", "nest"]) ? line$3 : hardline$3]), path.map(print, "nodes"))]));
  14211. }
  14212. case "selector-selector":
  14213. {
  14214. return group$1(indent$2(concat$4(path.map(print, "nodes"))));
  14215. }
  14216. case "selector-comment":
  14217. {
  14218. return node.value;
  14219. }
  14220. case "selector-string":
  14221. {
  14222. return adjustStrings(node.value, options);
  14223. }
  14224. case "selector-tag":
  14225. {
  14226. var _parentNode2 = path.getParentNode();
  14227. var index = _parentNode2 && _parentNode2.nodes.indexOf(node);
  14228. var prevNode = index && _parentNode2.nodes[index - 1];
  14229. return concat$4([node.namespace ? concat$4([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)]);
  14230. }
  14231. case "selector-id":
  14232. {
  14233. return concat$4(["#", node.value]);
  14234. }
  14235. case "selector-class":
  14236. {
  14237. return concat$4([".", adjustNumbers(adjustStrings(node.value, options))]);
  14238. }
  14239. case "selector-attribute":
  14240. {
  14241. return concat$4(["[", node.namespace ? concat$4([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" : "", "]"]);
  14242. }
  14243. case "selector-combinator":
  14244. {
  14245. if (node.value === "+" || node.value === ">" || node.value === "~" || node.value === ">>>") {
  14246. var _parentNode3 = path.getParentNode();
  14247. var _leading = _parentNode3.type === "selector-selector" && _parentNode3.nodes[0] === node ? "" : line$3;
  14248. return concat$4([_leading, node.value, isLastNode(path, node) ? "" : " "]);
  14249. }
  14250. var leading = node.value.trim().startsWith("(") ? line$3 : "";
  14251. var value = adjustNumbers(adjustStrings(node.value.trim(), options)) || line$3;
  14252. return concat$4([leading, value]);
  14253. }
  14254. case "selector-universal":
  14255. {
  14256. return concat$4([node.namespace ? concat$4([node.namespace === true ? "" : node.namespace.trim(), "|"]) : "", node.value]);
  14257. }
  14258. case "selector-pseudo":
  14259. {
  14260. return concat$4([maybeToLowerCase(node.value), node.nodes && node.nodes.length > 0 ? concat$4(["(", join$2(", ", path.map(print, "nodes")), ")"]) : ""]);
  14261. }
  14262. case "selector-nesting":
  14263. {
  14264. return node.value;
  14265. }
  14266. case "selector-unknown":
  14267. {
  14268. var ruleAncestorNode = getAncestorNode(path, "css-rule"); // Nested SCSS property
  14269. if (ruleAncestorNode && ruleAncestorNode.isSCSSNesterProperty) {
  14270. return adjustNumbers(adjustStrings(maybeToLowerCase(node.value), options));
  14271. }
  14272. return node.value;
  14273. }
  14274. // postcss-values-parser
  14275. case "value-value":
  14276. case "value-root":
  14277. {
  14278. return path.call(print, "group");
  14279. }
  14280. case "value-comment":
  14281. {
  14282. return concat$4([node.inline ? "//" : "/*", node.value, node.inline ? "" : "*/"]);
  14283. }
  14284. case "value-comma_group":
  14285. {
  14286. var _parentNode4 = path.getParentNode();
  14287. var parentParentNode = path.getParentNode(1);
  14288. var declAncestorProp = getPropOfDeclNode(path);
  14289. var isGridValue = declAncestorProp && _parentNode4.type === "value-value" && (declAncestorProp === "grid" || declAncestorProp.startsWith("grid-template"));
  14290. var atRuleAncestorNode = getAncestorNode(path, "css-atrule");
  14291. var isControlDirective = atRuleAncestorNode && isSCSSControlDirectiveNode(atRuleAncestorNode);
  14292. var printed = path.map(print, "groups");
  14293. var _parts = [];
  14294. var insideURLFunction = insideValueFunctionNode(path, "url");
  14295. var insideSCSSInterpolationInString = false;
  14296. var didBreak = false;
  14297. for (var i = 0; i < node.groups.length; ++i) {
  14298. _parts.push(printed[i]); // Ignore value inside `url()`
  14299. if (insideURLFunction) {
  14300. continue;
  14301. }
  14302. var iPrevNode = node.groups[i - 1];
  14303. var iNode = node.groups[i];
  14304. var iNextNode = node.groups[i + 1];
  14305. var iNextNextNode = node.groups[i + 2]; // Ignore after latest node (i.e. before semicolon)
  14306. if (!iNextNode) {
  14307. continue;
  14308. } // Ignore spaces before/after string interpolation (i.e. `"#{my-fn("_")}"`)
  14309. var isStartSCSSinterpolationInString = iNode.type === "value-string" && iNode.value.startsWith("#{");
  14310. var isEndingSCSSinterpolationInString = insideSCSSInterpolationInString && iNextNode.type === "value-string" && iNextNode.value.endsWith("}");
  14311. if (isStartSCSSinterpolationInString || isEndingSCSSinterpolationInString) {
  14312. insideSCSSInterpolationInString = !insideSCSSInterpolationInString;
  14313. continue;
  14314. }
  14315. if (insideSCSSInterpolationInString) {
  14316. continue;
  14317. } // Ignore colon (i.e. `:`)
  14318. if (isColonNode(iNode) || isColonNode(iNextNode)) {
  14319. continue;
  14320. } // Ignore `@` in Less (i.e. `@@var;`)
  14321. if (iNode.type === "value-atword" && iNode.value === "") {
  14322. continue;
  14323. } // Ignore `~` in Less (i.e. `content: ~"^//* some horrible but needed css hack";`)
  14324. if (iNode.value === "~") {
  14325. continue;
  14326. } // Ignore escape `\`
  14327. if (iNode.value && iNode.value.indexOf("\\") !== -1 && iNextNode && iNextNode.type !== "value-comment") {
  14328. continue;
  14329. } // Ignore escaped `/`
  14330. if (iPrevNode && iPrevNode.value && iPrevNode.value.indexOf("\\") === iPrevNode.value.length - 1 && iNode.type === "value-operator" && iNode.value === "/") {
  14331. continue;
  14332. } // Ignore `\` (i.e. `$variable: \@small;`)
  14333. if (iNode.value === "\\") {
  14334. continue;
  14335. } // Ignore `$$` (i.e. `background-color: $$(style)Color;`)
  14336. if (isPostcssSimpleVarNode(iNode, iNextNode)) {
  14337. continue;
  14338. } // Ignore spaces after `#` and after `{` and before `}` in SCSS interpolation (i.e. `#{variable}`)
  14339. if (isHashNode(iNode) || isLeftCurlyBraceNode(iNode) || isRightCurlyBraceNode(iNextNode) || isLeftCurlyBraceNode(iNextNode) && hasEmptyRawBefore(iNextNode) || isRightCurlyBraceNode(iNode) && hasEmptyRawBefore(iNextNode)) {
  14340. continue;
  14341. } // Ignore css variables and interpolation in SCSS (i.e. `--#{$var}`)
  14342. if (iNode.value === "--" && isHashNode(iNextNode)) {
  14343. continue;
  14344. } // Formatting math operations
  14345. var isMathOperator = isMathOperatorNode(iNode);
  14346. var isNextMathOperator = isMathOperatorNode(iNextNode); // Print spaces before and after math operators beside SCSS interpolation as is
  14347. // (i.e. `#{$var}+5`, `#{$var} +5`, `#{$var}+ 5`, `#{$var} + 5`)
  14348. // (i.e. `5+#{$var}`, `5 +#{$var}`, `5+ #{$var}`, `5 + #{$var}`)
  14349. if ((isMathOperator && isHashNode(iNextNode) || isNextMathOperator && isRightCurlyBraceNode(iNode)) && hasEmptyRawBefore(iNextNode)) {
  14350. continue;
  14351. } // Print spaces before and after addition and subtraction math operators as is in `calc` function
  14352. // due to the fact that it is not valid syntax
  14353. // (i.e. `calc(1px+1px)`, `calc(1px+ 1px)`, `calc(1px +1px)`, `calc(1px + 1px)`)
  14354. if (insideValueFunctionNode(path, "calc") && (isAdditionNode(iNode) || isAdditionNode(iNextNode) || isSubtractionNode(iNode) || isSubtractionNode(iNextNode)) && hasEmptyRawBefore(iNextNode)) {
  14355. continue;
  14356. } // Print spaces after `+` and `-` in color adjuster functions as is (e.g. `color(red l(+ 20%))`)
  14357. // Adjusters with signed numbers (e.g. `color(red l(+20%))`) output as-is.
  14358. var isColorAdjusterNode = (isAdditionNode(iNode) || isSubtractionNode(iNode)) && i === 0 && (iNextNode.type === "value-number" || iNextNode.isHex) && parentParentNode && isColorAdjusterFuncNode(parentParentNode) && !hasEmptyRawBefore(iNextNode);
  14359. var requireSpaceBeforeOperator = iNextNextNode && iNextNextNode.type === "value-func" || iNextNextNode && isWordNode(iNextNextNode) || iNode.type === "value-func" || isWordNode(iNode);
  14360. var requireSpaceAfterOperator = iNextNode.type === "value-func" || isWordNode(iNextNode) || iPrevNode && iPrevNode.type === "value-func" || iPrevNode && isWordNode(iPrevNode); // Formatting `/`, `+`, `-` sign
  14361. 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)))) {
  14362. continue;
  14363. } // Add `hardline` after inline comment (i.e. `// comment\n foo: bar;`)
  14364. if (isInlineValueCommentNode(iNode)) {
  14365. _parts.push(hardline$3);
  14366. continue;
  14367. } // Handle keywords in SCSS control directive
  14368. if (isControlDirective && (isEqualityOperatorNode(iNextNode) || isRelationalOperatorNode(iNextNode) || isIfElseKeywordNode(iNextNode) || isEachKeywordNode(iNode) || isForKeywordNode(iNode))) {
  14369. _parts.push(" ");
  14370. continue;
  14371. } // At-rule `namespace` should be in one line
  14372. if (atRuleAncestorNode && atRuleAncestorNode.name.toLowerCase() === "namespace") {
  14373. _parts.push(" ");
  14374. continue;
  14375. } // Formatting `grid` property
  14376. if (isGridValue) {
  14377. if (iNode.source && iNextNode.source && iNode.source.start.line !== iNextNode.source.start.line) {
  14378. _parts.push(hardline$3);
  14379. didBreak = true;
  14380. } else {
  14381. _parts.push(" ");
  14382. }
  14383. continue;
  14384. } // Add `space` before next math operation
  14385. // Note: `grip` property have `/` delimiter and it is not math operation, so
  14386. // `grid` property handles above
  14387. if (isNextMathOperator) {
  14388. _parts.push(" ");
  14389. continue;
  14390. } // Be default all values go through `line`
  14391. _parts.push(line$3);
  14392. }
  14393. if (didBreak) {
  14394. _parts.unshift(hardline$3);
  14395. }
  14396. if (isControlDirective) {
  14397. return group$1(indent$2(concat$4(_parts)));
  14398. } // Indent is not needed for import url when url is very long
  14399. // and node has two groups
  14400. // when type is value-comma_group
  14401. // example @import url("verylongurl") projection,tv
  14402. if (insideURLFunctionInImportAtRuleNode(path)) {
  14403. return group$1(fill$2(_parts));
  14404. }
  14405. return group$1(indent$2(fill$2(_parts)));
  14406. }
  14407. case "value-paren_group":
  14408. {
  14409. var _parentNode5 = path.getParentNode();
  14410. if (_parentNode5 && isURLFunctionNode(_parentNode5) && (node.groups.length === 1 || node.groups.length > 0 && node.groups[0].type === "value-comma_group" && node.groups[0].groups.length > 0 && node.groups[0].groups[0].type === "value-word" && node.groups[0].groups[0].value.startsWith("data:"))) {
  14411. return concat$4([node.open ? path.call(print, "open") : "", join$2(",", path.map(print, "groups")), node.close ? path.call(print, "close") : ""]);
  14412. }
  14413. if (!node.open) {
  14414. var _printed = path.map(print, "groups");
  14415. var res = [];
  14416. for (var _i = 0; _i < _printed.length; _i++) {
  14417. if (_i !== 0) {
  14418. res.push(concat$4([",", line$3]));
  14419. }
  14420. res.push(_printed[_i]);
  14421. }
  14422. return group$1(indent$2(fill$2(res)));
  14423. }
  14424. var isSCSSMapItem = isSCSSMapItemNode(path);
  14425. return group$1(concat$4([node.open ? path.call(print, "open") : "", indent$2(concat$4([softline$1, join$2(concat$4([",", line$3]), path.map(function (childPath) {
  14426. var node = childPath.getValue();
  14427. var printed = print(childPath); // Key/Value pair in open paren already indented
  14428. if (isKeyValuePairNode(node) && node.type === "value-comma_group" && node.groups && node.groups[2] && node.groups[2].type === "value-paren_group") {
  14429. printed.contents.contents.parts[1] = group$1(printed.contents.contents.parts[1]);
  14430. return group$1(dedent$2(printed));
  14431. }
  14432. return printed;
  14433. }, "groups"))])), ifBreak$1(isSCSS(options.parser, options.originalText) && isSCSSMapItem && shouldPrintComma(options) ? "," : ""), softline$1, node.close ? path.call(print, "close") : ""]), {
  14434. shouldBreak: isSCSSMapItem
  14435. });
  14436. }
  14437. case "value-func":
  14438. {
  14439. return concat$4([node.value, insideAtRuleNode(path, "supports") && isMediaAndSupportsKeywords(node) ? " " : "", path.call(print, "group")]);
  14440. }
  14441. case "value-paren":
  14442. {
  14443. return node.value;
  14444. }
  14445. case "value-number":
  14446. {
  14447. return concat$4([printCssNumber(node.value), maybeToLowerCase(node.unit)]);
  14448. }
  14449. case "value-operator":
  14450. {
  14451. return node.value;
  14452. }
  14453. case "value-word":
  14454. {
  14455. if (node.isColor && node.isHex || isWideKeywords(node.value)) {
  14456. return node.value.toLowerCase();
  14457. }
  14458. return node.value;
  14459. }
  14460. case "value-colon":
  14461. {
  14462. return concat$4([node.value, // Don't add spaces on `:` in `url` function (i.e. `url(fbglyph: cross-outline, fig-white)`)
  14463. insideValueFunctionNode(path, "url") ? "" : line$3]);
  14464. }
  14465. case "value-comma":
  14466. {
  14467. return concat$4([node.value, " "]);
  14468. }
  14469. case "value-string":
  14470. {
  14471. return printString$1(node.raws.quote + node.value + node.raws.quote, options);
  14472. }
  14473. case "value-atword":
  14474. {
  14475. return concat$4(["@", node.value]);
  14476. }
  14477. case "value-unicode-range":
  14478. {
  14479. return node.value;
  14480. }
  14481. case "value-unknown":
  14482. {
  14483. return node.value;
  14484. }
  14485. default:
  14486. /* istanbul ignore next */
  14487. throw new Error("Unknown postcss type ".concat(JSON.stringify(node.type)));
  14488. }
  14489. }
  14490. function printNodeSequence(path, options, print) {
  14491. var node = path.getValue();
  14492. var parts = [];
  14493. var i = 0;
  14494. path.map(function (pathChild) {
  14495. var prevNode = node.nodes[i - 1];
  14496. if (prevNode && prevNode.type === "css-comment" && prevNode.text.trim() === "prettier-ignore") {
  14497. var childNode = pathChild.getValue();
  14498. parts.push(options.originalText.slice(options.locStart(childNode), options.locEnd(childNode)));
  14499. } else {
  14500. parts.push(pathChild.call(print));
  14501. }
  14502. if (i !== node.nodes.length - 1) {
  14503. if (node.nodes[i + 1].type === "css-comment" && !hasNewline$2(options.originalText, options.locStart(node.nodes[i + 1]), {
  14504. backwards: true
  14505. }) && node.nodes[i].type !== "yaml" && node.nodes[i].type !== "toml" || node.nodes[i + 1].type === "css-atrule" && node.nodes[i + 1].name === "else" && node.nodes[i].type !== "css-comment") {
  14506. parts.push(" ");
  14507. } else {
  14508. parts.push(hardline$3);
  14509. if (isNextLineEmpty$2(options.originalText, pathChild.getValue(), options) && node.nodes[i].type !== "yaml" && node.nodes[i].type !== "toml") {
  14510. parts.push(hardline$3);
  14511. }
  14512. }
  14513. }
  14514. i++;
  14515. }, "nodes");
  14516. return concat$4(parts);
  14517. }
  14518. var STRING_REGEX = /(['"])(?:(?!\1)[^\\]|\\[\s\S])*\1/g;
  14519. var NUMBER_REGEX = /(?:\d*\.\d+|\d+\.?)(?:[eE][+-]?\d+)?/g;
  14520. var STANDARD_UNIT_REGEX = /[a-zA-Z]+/g;
  14521. var WORD_PART_REGEX = /[$@]?[a-zA-Z_\u0080-\uFFFF][\w\-\u0080-\uFFFF]*/g;
  14522. var ADJUST_NUMBERS_REGEX = RegExp(STRING_REGEX.source + "|" + "(".concat(WORD_PART_REGEX.source, ")?") + "(".concat(NUMBER_REGEX.source, ")") + "(".concat(STANDARD_UNIT_REGEX.source, ")?"), "g");
  14523. function adjustStrings(value, options) {
  14524. return value.replace(STRING_REGEX, function (match) {
  14525. return printString$1(match, options);
  14526. });
  14527. }
  14528. function quoteAttributeValue(value, options) {
  14529. var quote = options.singleQuote ? "'" : '"';
  14530. return value.includes('"') || value.includes("'") ? value : quote + value + quote;
  14531. }
  14532. function adjustNumbers(value) {
  14533. return value.replace(ADJUST_NUMBERS_REGEX, function (match, quote, wordPart, number, unit) {
  14534. return !wordPart && number ? (wordPart || "") + printCssNumber(number) + maybeToLowerCase(unit || "") : match;
  14535. });
  14536. }
  14537. function printCssNumber(rawNumber) {
  14538. return printNumber$1(rawNumber) // Remove trailing `.0`.
  14539. .replace(/\.0(?=$|e)/, "");
  14540. }
  14541. var printerPostcss = {
  14542. print: genericPrint,
  14543. embed: embed_1,
  14544. insertPragma: insertPragma,
  14545. hasPrettierIgnore: hasIgnoreComment$1,
  14546. massageAstNode: clean_1
  14547. };
  14548. var CATEGORY_COMMON = "Common"; // format based on https://github.com/prettier/prettier/blob/master/src/main/core-options.js
  14549. var commonOptions = {
  14550. bracketSpacing: {
  14551. since: "0.0.0",
  14552. category: CATEGORY_COMMON,
  14553. type: "boolean",
  14554. default: true,
  14555. description: "Print spaces between brackets.",
  14556. oppositeDescription: "Do not print spaces between brackets."
  14557. },
  14558. singleQuote: {
  14559. since: "0.0.0",
  14560. category: CATEGORY_COMMON,
  14561. type: "boolean",
  14562. default: false,
  14563. description: "Use single quotes instead of double quotes."
  14564. },
  14565. proseWrap: {
  14566. since: "1.8.2",
  14567. category: CATEGORY_COMMON,
  14568. type: "choice",
  14569. default: [{
  14570. since: "1.8.2",
  14571. value: true
  14572. }, {
  14573. since: "1.9.0",
  14574. value: "preserve"
  14575. }],
  14576. description: "How to wrap prose.",
  14577. choices: [{
  14578. since: "1.9.0",
  14579. value: "always",
  14580. description: "Wrap prose if it exceeds the print width."
  14581. }, {
  14582. since: "1.9.0",
  14583. value: "never",
  14584. description: "Do not wrap prose."
  14585. }, {
  14586. since: "1.9.0",
  14587. value: "preserve",
  14588. description: "Wrap prose as-is."
  14589. }, {
  14590. value: false,
  14591. deprecated: "1.9.0",
  14592. redirect: "never"
  14593. }, {
  14594. value: true,
  14595. deprecated: "1.9.0",
  14596. redirect: "always"
  14597. }]
  14598. }
  14599. };
  14600. var options$3 = {
  14601. singleQuote: commonOptions.singleQuote
  14602. };
  14603. var createLanguage = function createLanguage(linguistData, _ref) {
  14604. var extend = _ref.extend,
  14605. override = _ref.override;
  14606. var language = {};
  14607. for (var key in linguistData) {
  14608. var newKey = key === "languageId" ? "linguistLanguageId" : key;
  14609. language[newKey] = linguistData[key];
  14610. }
  14611. if (extend) {
  14612. for (var _key in extend) {
  14613. language[_key] = (language[_key] || []).concat(extend[_key]);
  14614. }
  14615. }
  14616. for (var _key2 in override) {
  14617. language[_key2] = override[_key2];
  14618. }
  14619. return language;
  14620. };
  14621. var name$1 = "CSS";
  14622. var type = "markup";
  14623. var tmScope = "source.css";
  14624. var aceMode = "css";
  14625. var codemirrorMode = "css";
  14626. var codemirrorMimeType = "text/css";
  14627. var color = "#563d7c";
  14628. var extensions = [".css"];
  14629. var languageId = 50;
  14630. var css$2 = {
  14631. name: name$1,
  14632. type: type,
  14633. tmScope: tmScope,
  14634. aceMode: aceMode,
  14635. codemirrorMode: codemirrorMode,
  14636. codemirrorMimeType: codemirrorMimeType,
  14637. color: color,
  14638. extensions: extensions,
  14639. languageId: languageId
  14640. };
  14641. var css$3 = Object.freeze({
  14642. name: name$1,
  14643. type: type,
  14644. tmScope: tmScope,
  14645. aceMode: aceMode,
  14646. codemirrorMode: codemirrorMode,
  14647. codemirrorMimeType: codemirrorMimeType,
  14648. color: color,
  14649. extensions: extensions,
  14650. languageId: languageId,
  14651. default: css$2
  14652. });
  14653. var name$2 = "PostCSS";
  14654. var type$1 = "markup";
  14655. var tmScope$1 = "source.postcss";
  14656. var group$2 = "CSS";
  14657. var extensions$1 = [".pcss"];
  14658. var aceMode$1 = "text";
  14659. var languageId$1 = 262764437;
  14660. var postcss = {
  14661. name: name$2,
  14662. type: type$1,
  14663. tmScope: tmScope$1,
  14664. group: group$2,
  14665. extensions: extensions$1,
  14666. aceMode: aceMode$1,
  14667. languageId: languageId$1
  14668. };
  14669. var postcss$1 = Object.freeze({
  14670. name: name$2,
  14671. type: type$1,
  14672. tmScope: tmScope$1,
  14673. group: group$2,
  14674. extensions: extensions$1,
  14675. aceMode: aceMode$1,
  14676. languageId: languageId$1,
  14677. default: postcss
  14678. });
  14679. var name$3 = "Less";
  14680. var type$2 = "markup";
  14681. var group$3 = "CSS";
  14682. var extensions$2 = [".less"];
  14683. var tmScope$2 = "source.css.less";
  14684. var aceMode$2 = "less";
  14685. var codemirrorMode$1 = "css";
  14686. var codemirrorMimeType$1 = "text/css";
  14687. var languageId$2 = 198;
  14688. var less = {
  14689. name: name$3,
  14690. type: type$2,
  14691. group: group$3,
  14692. extensions: extensions$2,
  14693. tmScope: tmScope$2,
  14694. aceMode: aceMode$2,
  14695. codemirrorMode: codemirrorMode$1,
  14696. codemirrorMimeType: codemirrorMimeType$1,
  14697. languageId: languageId$2
  14698. };
  14699. var less$1 = Object.freeze({
  14700. name: name$3,
  14701. type: type$2,
  14702. group: group$3,
  14703. extensions: extensions$2,
  14704. tmScope: tmScope$2,
  14705. aceMode: aceMode$2,
  14706. codemirrorMode: codemirrorMode$1,
  14707. codemirrorMimeType: codemirrorMimeType$1,
  14708. languageId: languageId$2,
  14709. default: less
  14710. });
  14711. var name$4 = "SCSS";
  14712. var type$3 = "markup";
  14713. var tmScope$3 = "source.scss";
  14714. var group$4 = "CSS";
  14715. var aceMode$3 = "scss";
  14716. var codemirrorMode$2 = "css";
  14717. var codemirrorMimeType$2 = "text/x-scss";
  14718. var extensions$3 = [".scss"];
  14719. var languageId$3 = 329;
  14720. var scss = {
  14721. name: name$4,
  14722. type: type$3,
  14723. tmScope: tmScope$3,
  14724. group: group$4,
  14725. aceMode: aceMode$3,
  14726. codemirrorMode: codemirrorMode$2,
  14727. codemirrorMimeType: codemirrorMimeType$2,
  14728. extensions: extensions$3,
  14729. languageId: languageId$3
  14730. };
  14731. var scss$1 = Object.freeze({
  14732. name: name$4,
  14733. type: type$3,
  14734. tmScope: tmScope$3,
  14735. group: group$4,
  14736. aceMode: aceMode$3,
  14737. codemirrorMode: codemirrorMode$2,
  14738. codemirrorMimeType: codemirrorMimeType$2,
  14739. extensions: extensions$3,
  14740. languageId: languageId$3,
  14741. default: scss
  14742. });
  14743. var require$$0$17 = ( css$3 && css$2 ) || css$3;
  14744. var require$$1$8 = ( postcss$1 && postcss ) || postcss$1;
  14745. var require$$2$9 = ( less$1 && less ) || less$1;
  14746. var require$$3$4 = ( scss$1 && scss ) || scss$1;
  14747. var languages = [createLanguage(require$$0$17, {
  14748. override: {
  14749. since: "1.4.0",
  14750. parsers: ["css"],
  14751. vscodeLanguageIds: ["css"]
  14752. }
  14753. }), createLanguage(require$$1$8, {
  14754. override: {
  14755. since: "1.4.0",
  14756. parsers: ["css"],
  14757. vscodeLanguageIds: ["postcss"]
  14758. },
  14759. extend: {
  14760. extensions: [".postcss"]
  14761. }
  14762. }), createLanguage(require$$2$9, {
  14763. override: {
  14764. since: "1.4.0",
  14765. parsers: ["less"],
  14766. vscodeLanguageIds: ["less"]
  14767. }
  14768. }), createLanguage(require$$3$4, {
  14769. override: {
  14770. since: "1.4.0",
  14771. parsers: ["scss"],
  14772. vscodeLanguageIds: ["scss"]
  14773. }
  14774. })];
  14775. var printers = {
  14776. postcss: printerPostcss
  14777. };
  14778. var languageCss = {
  14779. languages: languages,
  14780. options: options$3,
  14781. printers: printers
  14782. };
  14783. function hasPragma$2(text) {
  14784. return /^\s*#[^\n\S]*@(format|prettier)\s*(\n|$)/.test(text);
  14785. }
  14786. function insertPragma$4(text) {
  14787. return "# @format\n\n" + text;
  14788. }
  14789. var pragma$4 = {
  14790. hasPragma: hasPragma$2,
  14791. insertPragma: insertPragma$4
  14792. };
  14793. var _require$$0$builders$2 = doc.builders;
  14794. var concat$6 = _require$$0$builders$2.concat;
  14795. var join$3 = _require$$0$builders$2.join;
  14796. var hardline$5 = _require$$0$builders$2.hardline;
  14797. var line$4 = _require$$0$builders$2.line;
  14798. var softline$2 = _require$$0$builders$2.softline;
  14799. var group$5 = _require$$0$builders$2.group;
  14800. var indent$3 = _require$$0$builders$2.indent;
  14801. var ifBreak$2 = _require$$0$builders$2.ifBreak;
  14802. var hasIgnoreComment$2 = util.hasIgnoreComment;
  14803. var isNextLineEmpty$3 = utilShared.isNextLineEmpty;
  14804. var insertPragma$3 = pragma$4.insertPragma;
  14805. function genericPrint$1(path, options, print) {
  14806. var n = path.getValue();
  14807. if (!n) {
  14808. return "";
  14809. }
  14810. if (typeof n === "string") {
  14811. return n;
  14812. }
  14813. switch (n.kind) {
  14814. case "Document":
  14815. {
  14816. var parts = [];
  14817. path.map(function (pathChild, index) {
  14818. parts.push(concat$6([pathChild.call(print)]));
  14819. if (index !== n.definitions.length - 1) {
  14820. parts.push(hardline$5);
  14821. if (isNextLineEmpty$3(options.originalText, pathChild.getValue(), options)) {
  14822. parts.push(hardline$5);
  14823. }
  14824. }
  14825. }, "definitions");
  14826. return concat$6([concat$6(parts), hardline$5]);
  14827. }
  14828. case "OperationDefinition":
  14829. {
  14830. var hasOperation = options.originalText[options.locStart(n)] !== "{";
  14831. var hasName = !!n.name;
  14832. return concat$6([hasOperation ? n.operation : "", hasOperation && hasName ? concat$6([" ", path.call(print, "name")]) : "", n.variableDefinitions && n.variableDefinitions.length ? group$5(concat$6(["(", indent$3(concat$6([softline$2, join$3(concat$6([ifBreak$2("", ", "), softline$2]), path.map(print, "variableDefinitions"))])), softline$2, ")"])) : "", printDirectives(path, print, n), n.selectionSet ? !hasOperation && !hasName ? "" : " " : "", path.call(print, "selectionSet")]);
  14833. }
  14834. case "FragmentDefinition":
  14835. {
  14836. return concat$6(["fragment ", path.call(print, "name"), " on ", path.call(print, "typeCondition"), printDirectives(path, print, n), " ", path.call(print, "selectionSet")]);
  14837. }
  14838. case "SelectionSet":
  14839. {
  14840. return concat$6(["{", indent$3(concat$6([hardline$5, join$3(hardline$5, path.call(function (selectionsPath) {
  14841. return printSequence(selectionsPath, options, print);
  14842. }, "selections"))])), hardline$5, "}"]);
  14843. }
  14844. case "Field":
  14845. {
  14846. return group$5(concat$6([n.alias ? concat$6([path.call(print, "alias"), ": "]) : "", path.call(print, "name"), n.arguments.length > 0 ? group$5(concat$6(["(", indent$3(concat$6([softline$2, join$3(concat$6([ifBreak$2("", ", "), softline$2]), path.call(function (argsPath) {
  14847. return printSequence(argsPath, options, print);
  14848. }, "arguments"))])), softline$2, ")"])) : "", printDirectives(path, print, n), n.selectionSet ? " " : "", path.call(print, "selectionSet")]));
  14849. }
  14850. case "Name":
  14851. {
  14852. return n.value;
  14853. }
  14854. case "StringValue":
  14855. {
  14856. if (n.block) {
  14857. return concat$6(['"""', hardline$5, join$3(hardline$5, n.value.replace(/"""/g, "\\$&").split("\n")), hardline$5, '"""']);
  14858. }
  14859. return concat$6(['"', n.value.replace(/["\\]/g, "\\$&").replace(/\n/g, "\\n"), '"']);
  14860. }
  14861. case "IntValue":
  14862. case "FloatValue":
  14863. case "EnumValue":
  14864. {
  14865. return n.value;
  14866. }
  14867. case "BooleanValue":
  14868. {
  14869. return n.value ? "true" : "false";
  14870. }
  14871. case "NullValue":
  14872. {
  14873. return "null";
  14874. }
  14875. case "Variable":
  14876. {
  14877. return concat$6(["$", path.call(print, "name")]);
  14878. }
  14879. case "ListValue":
  14880. {
  14881. return group$5(concat$6(["[", indent$3(concat$6([softline$2, join$3(concat$6([ifBreak$2("", ", "), softline$2]), path.map(print, "values"))])), softline$2, "]"]));
  14882. }
  14883. case "ObjectValue":
  14884. {
  14885. return group$5(concat$6(["{", options.bracketSpacing && n.fields.length > 0 ? " " : "", indent$3(concat$6([softline$2, join$3(concat$6([ifBreak$2("", ", "), softline$2]), path.map(print, "fields"))])), softline$2, ifBreak$2("", options.bracketSpacing && n.fields.length > 0 ? " " : ""), "}"]));
  14886. }
  14887. case "ObjectField":
  14888. case "Argument":
  14889. {
  14890. return concat$6([path.call(print, "name"), ": ", path.call(print, "value")]);
  14891. }
  14892. case "Directive":
  14893. {
  14894. return concat$6(["@", path.call(print, "name"), n.arguments.length > 0 ? group$5(concat$6(["(", indent$3(concat$6([softline$2, join$3(concat$6([ifBreak$2("", ", "), softline$2]), path.call(function (argsPath) {
  14895. return printSequence(argsPath, options, print);
  14896. }, "arguments"))])), softline$2, ")"])) : ""]);
  14897. }
  14898. case "NamedType":
  14899. {
  14900. return path.call(print, "name");
  14901. }
  14902. case "VariableDefinition":
  14903. {
  14904. return concat$6([path.call(print, "variable"), ": ", path.call(print, "type"), n.defaultValue ? concat$6([" = ", path.call(print, "defaultValue")]) : ""]);
  14905. }
  14906. case "TypeExtensionDefinition":
  14907. {
  14908. return concat$6(["extend ", path.call(print, "definition")]);
  14909. }
  14910. case "ObjectTypeExtension":
  14911. case "ObjectTypeDefinition":
  14912. {
  14913. return concat$6([path.call(print, "description"), n.description ? hardline$5 : "", n.kind === "ObjectTypeExtension" ? "extend " : "", "type ", path.call(print, "name"), n.interfaces.length > 0 ? concat$6([" implements ", join$3(determineInterfaceSeparator(options.originalText.substr(options.locStart(n), options.locEnd(n))), path.map(print, "interfaces"))]) : "", printDirectives(path, print, n), n.fields.length > 0 ? concat$6([" {", indent$3(concat$6([hardline$5, join$3(hardline$5, path.call(function (fieldsPath) {
  14914. return printSequence(fieldsPath, options, print);
  14915. }, "fields"))])), hardline$5, "}"]) : ""]);
  14916. }
  14917. case "FieldDefinition":
  14918. {
  14919. return concat$6([path.call(print, "description"), n.description ? hardline$5 : "", path.call(print, "name"), n.arguments.length > 0 ? group$5(concat$6(["(", indent$3(concat$6([softline$2, join$3(concat$6([ifBreak$2("", ", "), softline$2]), path.call(function (argsPath) {
  14920. return printSequence(argsPath, options, print);
  14921. }, "arguments"))])), softline$2, ")"])) : "", ": ", path.call(print, "type"), printDirectives(path, print, n)]);
  14922. }
  14923. case "DirectiveDefinition":
  14924. {
  14925. return concat$6([path.call(print, "description"), n.description ? hardline$5 : "", "directive ", "@", path.call(print, "name"), n.arguments.length > 0 ? group$5(concat$6(["(", indent$3(concat$6([softline$2, join$3(concat$6([ifBreak$2("", ", "), softline$2]), path.call(function (argsPath) {
  14926. return printSequence(argsPath, options, print);
  14927. }, "arguments"))])), softline$2, ")"])) : "", concat$6([" on ", join$3(" | ", path.map(print, "locations"))])]);
  14928. }
  14929. case "EnumTypeExtension":
  14930. case "EnumTypeDefinition":
  14931. {
  14932. return concat$6([path.call(print, "description"), n.description ? hardline$5 : "", n.kind === "EnumTypeExtension" ? "extend " : "", "enum ", path.call(print, "name"), printDirectives(path, print, n), n.values.length > 0 ? concat$6([" {", indent$3(concat$6([hardline$5, join$3(hardline$5, path.call(function (valuesPath) {
  14933. return printSequence(valuesPath, options, print);
  14934. }, "values"))])), hardline$5, "}"]) : ""]);
  14935. }
  14936. case "EnumValueDefinition":
  14937. {
  14938. return concat$6([path.call(print, "description"), n.description ? hardline$5 : "", path.call(print, "name"), printDirectives(path, print, n)]);
  14939. }
  14940. case "InputValueDefinition":
  14941. {
  14942. return concat$6([path.call(print, "description"), n.description ? n.description.block ? hardline$5 : line$4 : "", path.call(print, "name"), ": ", path.call(print, "type"), n.defaultValue ? concat$6([" = ", path.call(print, "defaultValue")]) : "", printDirectives(path, print, n)]);
  14943. }
  14944. case "InputObjectTypeExtension":
  14945. case "InputObjectTypeDefinition":
  14946. {
  14947. return concat$6([path.call(print, "description"), n.description ? hardline$5 : "", n.kind === "InputObjectTypeExtension" ? "extend " : "", "input ", path.call(print, "name"), printDirectives(path, print, n), n.fields.length > 0 ? concat$6([" {", indent$3(concat$6([hardline$5, join$3(hardline$5, path.call(function (fieldsPath) {
  14948. return printSequence(fieldsPath, options, print);
  14949. }, "fields"))])), hardline$5, "}"]) : ""]);
  14950. }
  14951. case "SchemaDefinition":
  14952. {
  14953. return concat$6(["schema", printDirectives(path, print, n), " {", n.operationTypes.length > 0 ? indent$3(concat$6([hardline$5, join$3(hardline$5, path.call(function (opsPath) {
  14954. return printSequence(opsPath, options, print);
  14955. }, "operationTypes"))])) : "", hardline$5, "}"]);
  14956. }
  14957. case "OperationTypeDefinition":
  14958. {
  14959. return concat$6([path.call(print, "operation"), ": ", path.call(print, "type")]);
  14960. }
  14961. case "InterfaceTypeExtension":
  14962. case "InterfaceTypeDefinition":
  14963. {
  14964. return concat$6([path.call(print, "description"), n.description ? hardline$5 : "", n.kind === "InterfaceTypeExtension" ? "extend " : "", "interface ", path.call(print, "name"), printDirectives(path, print, n), n.fields.length > 0 ? concat$6([" {", indent$3(concat$6([hardline$5, join$3(hardline$5, path.call(function (fieldsPath) {
  14965. return printSequence(fieldsPath, options, print);
  14966. }, "fields"))])), hardline$5, "}"]) : ""]);
  14967. }
  14968. case "FragmentSpread":
  14969. {
  14970. return concat$6(["...", path.call(print, "name"), printDirectives(path, print, n)]);
  14971. }
  14972. case "InlineFragment":
  14973. {
  14974. return concat$6(["...", n.typeCondition ? concat$6([" on ", path.call(print, "typeCondition")]) : "", printDirectives(path, print, n), " ", path.call(print, "selectionSet")]);
  14975. }
  14976. case "UnionTypeExtension":
  14977. case "UnionTypeDefinition":
  14978. {
  14979. return group$5(concat$6([path.call(print, "description"), n.description ? hardline$5 : "", group$5(concat$6([n.kind === "UnionTypeExtension" ? "extend " : "", "union ", path.call(print, "name"), printDirectives(path, print, n), n.types.length > 0 ? concat$6([" =", ifBreak$2("", " "), indent$3(concat$6([ifBreak$2(concat$6([line$4, " "])), join$3(concat$6([line$4, "| "]), path.map(print, "types"))]))]) : ""]))]));
  14980. }
  14981. case "ScalarTypeExtension":
  14982. case "ScalarTypeDefinition":
  14983. {
  14984. return concat$6([path.call(print, "description"), n.description ? hardline$5 : "", n.kind === "ScalarTypeExtension" ? "extend " : "", "scalar ", path.call(print, "name"), printDirectives(path, print, n)]);
  14985. }
  14986. case "NonNullType":
  14987. {
  14988. return concat$6([path.call(print, "type"), "!"]);
  14989. }
  14990. case "ListType":
  14991. {
  14992. return concat$6(["[", path.call(print, "type"), "]"]);
  14993. }
  14994. default:
  14995. /* istanbul ignore next */
  14996. throw new Error("unknown graphql type: " + JSON.stringify(n.kind));
  14997. }
  14998. }
  14999. function printDirectives(path, print, n) {
  15000. if (n.directives.length === 0) {
  15001. return "";
  15002. }
  15003. return concat$6([" ", group$5(indent$3(concat$6([softline$2, join$3(concat$6([ifBreak$2("", " "), softline$2]), path.map(print, "directives"))])))]);
  15004. }
  15005. function printSequence(sequencePath, options, print) {
  15006. var count = sequencePath.getValue().length;
  15007. return sequencePath.map(function (path, i) {
  15008. var printed = print(path);
  15009. if (isNextLineEmpty$3(options.originalText, path.getValue(), options) && i < count - 1) {
  15010. return concat$6([printed, hardline$5]);
  15011. }
  15012. return printed;
  15013. });
  15014. }
  15015. function canAttachComment(node) {
  15016. return node.kind && node.kind !== "Comment";
  15017. }
  15018. function printComment$1(commentPath) {
  15019. var comment = commentPath.getValue();
  15020. if (comment.kind === "Comment") {
  15021. return "#" + comment.value.trimRight();
  15022. }
  15023. throw new Error("Not a comment: " + JSON.stringify(comment));
  15024. }
  15025. function determineInterfaceSeparator(originalSource) {
  15026. var start = originalSource.indexOf("implements");
  15027. if (start === -1) {
  15028. throw new Error("Must implement interfaces: " + originalSource);
  15029. }
  15030. var end = originalSource.indexOf("{");
  15031. if (end === -1) {
  15032. end = originalSource.length;
  15033. }
  15034. return originalSource.substr(start, end).includes("&") ? " & " : ", ";
  15035. }
  15036. function clean$2(node, newNode
  15037. /*, parent*/
  15038. ) {
  15039. delete newNode.loc;
  15040. delete newNode.comments;
  15041. }
  15042. var printerGraphql = {
  15043. print: genericPrint$1,
  15044. massageAstNode: clean$2,
  15045. hasPrettierIgnore: hasIgnoreComment$2,
  15046. insertPragma: insertPragma$3,
  15047. printComment: printComment$1,
  15048. canAttachComment: canAttachComment
  15049. };
  15050. var options$6 = {
  15051. bracketSpacing: commonOptions.bracketSpacing
  15052. };
  15053. var name$5 = "GraphQL";
  15054. var type$4 = "data";
  15055. var extensions$4 = [".graphql", ".gql"];
  15056. var tmScope$4 = "source.graphql";
  15057. var aceMode$4 = "text";
  15058. var languageId$4 = 139;
  15059. var graphql = {
  15060. name: name$5,
  15061. type: type$4,
  15062. extensions: extensions$4,
  15063. tmScope: tmScope$4,
  15064. aceMode: aceMode$4,
  15065. languageId: languageId$4
  15066. };
  15067. var graphql$1 = Object.freeze({
  15068. name: name$5,
  15069. type: type$4,
  15070. extensions: extensions$4,
  15071. tmScope: tmScope$4,
  15072. aceMode: aceMode$4,
  15073. languageId: languageId$4,
  15074. default: graphql
  15075. });
  15076. var require$$0$18 = ( graphql$1 && graphql ) || graphql$1;
  15077. var languages$1 = [createLanguage(require$$0$18, {
  15078. override: {
  15079. since: "1.5.0",
  15080. parsers: ["graphql"],
  15081. vscodeLanguageIds: ["graphql"]
  15082. }
  15083. })];
  15084. var printers$1 = {
  15085. graphql: printerGraphql
  15086. };
  15087. var languageGraphql = {
  15088. languages: languages$1,
  15089. options: options$6,
  15090. printers: printers$1
  15091. };
  15092. var _require$$0$builders$3 = doc.builders;
  15093. var concat$7 = _require$$0$builders$3.concat;
  15094. var join$4 = _require$$0$builders$3.join;
  15095. var softline$3 = _require$$0$builders$3.softline;
  15096. var hardline$6 = _require$$0$builders$3.hardline;
  15097. var line$5 = _require$$0$builders$3.line;
  15098. var group$6 = _require$$0$builders$3.group;
  15099. var indent$4 = _require$$0$builders$3.indent;
  15100. var ifBreak$3 = _require$$0$builders$3.ifBreak; // http://w3c.github.io/html/single-page.html#void-elements
  15101. var voidTags = ["area", "base", "br", "col", "embed", "hr", "img", "input", "link", "meta", "param", "source", "track", "wbr"]; // Formatter based on @glimmerjs/syntax's built-in test formatter:
  15102. // https://github.com/glimmerjs/glimmer-vm/blob/master/packages/%40glimmer/syntax/lib/generation/print.ts
  15103. function print(path, options, print) {
  15104. var n = path.getValue();
  15105. /* istanbul ignore if*/
  15106. if (!n) {
  15107. return "";
  15108. }
  15109. switch (n.type) {
  15110. case "Program":
  15111. {
  15112. return group$6(join$4(softline$3, path.map(print, "body").filter(function (text) {
  15113. return text !== "";
  15114. })));
  15115. }
  15116. case "ElementNode":
  15117. {
  15118. var tagFirstChar = n.tag[0];
  15119. var isLocal = n.tag.indexOf(".") !== -1;
  15120. var isGlimmerComponent = tagFirstChar.toUpperCase() === tagFirstChar || isLocal;
  15121. var hasChildren = n.children.length > 0;
  15122. var isVoid = isGlimmerComponent && !hasChildren || voidTags.indexOf(n.tag) !== -1;
  15123. var closeTag = isVoid ? concat$7([" />", softline$3]) : ">";
  15124. var _getParams = function _getParams(path, print) {
  15125. return indent$4(concat$7([n.attributes.length ? line$5 : "", join$4(line$5, path.map(print, "attributes")), n.modifiers.length ? line$5 : "", join$4(line$5, path.map(print, "modifiers")), n.comments.length ? line$5 : "", join$4(line$5, path.map(print, "comments"))]));
  15126. }; // The problem here is that I want to not break at all if the children
  15127. // would not break but I need to force an indent, so I use a hardline.
  15128. /**
  15129. * What happens now:
  15130. * <div>
  15131. * Hello
  15132. * </div>
  15133. * ==>
  15134. * <div>Hello</div>
  15135. * This is due to me using hasChildren to decide to put the hardline in.
  15136. * I would rather use a {DOES THE WHOLE THING NEED TO BREAK}
  15137. */
  15138. return concat$7([group$6(concat$7(["<", n.tag, _getParams(path, print), n.blockParams.length ? " as |".concat(n.blockParams.join(" "), "|") : "", ifBreak$3(softline$3, ""), closeTag])), group$6(concat$7([indent$4(join$4(softline$3, [""].concat(path.map(print, "children")))), ifBreak$3(hasChildren ? hardline$6 : "", ""), !isVoid ? concat$7(["</", n.tag, ">"]) : ""]))]);
  15139. }
  15140. case "BlockStatement":
  15141. {
  15142. var pp = path.getParentNode(1);
  15143. var isElseIf = pp && pp.inverse && pp.inverse.body[0] === n && pp.inverse.body[0].path.parts[0] === "if";
  15144. var hasElseIf = n.inverse && n.inverse.body[0] && n.inverse.body[0].type === "BlockStatement" && n.inverse.body[0].path.parts[0] === "if";
  15145. var indentElse = hasElseIf ? function (a) {
  15146. return a;
  15147. } : indent$4;
  15148. if (n.inverse) {
  15149. return concat$7([isElseIf ? concat$7(["{{else ", printPathParams(path, print), "}}"]) : printOpenBlock(path, print), indent$4(concat$7([hardline$6, path.call(print, "program")])), n.inverse && !hasElseIf ? concat$7([hardline$6, "{{else}}"]) : "", n.inverse ? indentElse(concat$7([hardline$6, path.call(print, "inverse")])) : "", isElseIf ? "" : concat$7([hardline$6, printCloseBlock(path, print)])]);
  15150. } else if (isElseIf) {
  15151. return concat$7([concat$7(["{{else ", printPathParams(path, print), "}}"]), indent$4(concat$7([hardline$6, path.call(print, "program")]))]);
  15152. }
  15153. /**
  15154. * I want this boolean to be: if params are going to cause a break,
  15155. * not that it has params.
  15156. */
  15157. var hasParams = n.params.length > 0 || n.hash.pairs.length > 0;
  15158. var _hasChildren = n.program.body.length > 0;
  15159. return concat$7([printOpenBlock(path, print), group$6(concat$7([indent$4(concat$7([softline$3, path.call(print, "program")])), hasParams && _hasChildren ? hardline$6 : softline$3, printCloseBlock(path, print)]))]);
  15160. }
  15161. case "ElementModifierStatement":
  15162. case "MustacheStatement":
  15163. {
  15164. var _pp = path.getParentNode(1);
  15165. var isConcat = _pp && _pp.type === "ConcatStatement";
  15166. return group$6(concat$7([n.escaped === false ? "{{{" : "{{", printPathParams(path, print), isConcat ? "" : softline$3, n.escaped === false ? "}}}" : "}}"]));
  15167. }
  15168. case "SubExpression":
  15169. {
  15170. var params = getParams(path, print);
  15171. var printedParams = params.length > 0 ? indent$4(concat$7([line$5, group$6(join$4(line$5, params))])) : "";
  15172. return group$6(concat$7(["(", printPath(path, print), printedParams, softline$3, ")"]));
  15173. }
  15174. case "AttrNode":
  15175. {
  15176. var isText = n.value.type === "TextNode";
  15177. if (isText && n.value.loc.start.column === n.value.loc.end.column) {
  15178. return concat$7([n.name]);
  15179. }
  15180. var quote = isText ? '"' : "";
  15181. return concat$7([n.name, "=", quote, path.call(print, "value"), quote]);
  15182. }
  15183. case "ConcatStatement":
  15184. {
  15185. return concat$7(['"', group$6(indent$4(join$4(softline$3, path.map(function (partPath) {
  15186. return print(partPath);
  15187. }, "parts").filter(function (a) {
  15188. return a !== "";
  15189. })))), '"']);
  15190. }
  15191. case "Hash":
  15192. {
  15193. return concat$7([join$4(line$5, path.map(print, "pairs"))]);
  15194. }
  15195. case "HashPair":
  15196. {
  15197. return concat$7([n.key, "=", path.call(print, "value")]);
  15198. }
  15199. case "TextNode":
  15200. {
  15201. var leadingSpace = "";
  15202. var trailingSpace = ""; // preserve a space inside of an attribute node where whitespace present, when next to mustache statement.
  15203. var inAttrNode = path.stack.indexOf("attributes") >= 0;
  15204. if (inAttrNode) {
  15205. var parentNode = path.getParentNode(0);
  15206. var _isConcat = parentNode.type === "ConcatStatement";
  15207. if (_isConcat) {
  15208. var parts = parentNode.parts;
  15209. var partIndex = parts.indexOf(n);
  15210. if (partIndex > 0) {
  15211. var partType = parts[partIndex - 1].type;
  15212. var isMustache = partType === "MustacheStatement";
  15213. if (isMustache) {
  15214. leadingSpace = " ";
  15215. }
  15216. }
  15217. if (partIndex < parts.length - 1) {
  15218. var _partType = parts[partIndex + 1].type;
  15219. var _isMustache = _partType === "MustacheStatement";
  15220. if (_isMustache) {
  15221. trailingSpace = " ";
  15222. }
  15223. }
  15224. }
  15225. }
  15226. return n.chars.replace(/^\s+/, leadingSpace).replace(/\s+$/, trailingSpace);
  15227. }
  15228. case "MustacheCommentStatement":
  15229. {
  15230. var dashes = n.value.indexOf("}}") > -1 ? "--" : "";
  15231. return concat$7(["{{!", dashes, n.value, dashes, "}}"]);
  15232. }
  15233. case "PathExpression":
  15234. {
  15235. return n.original;
  15236. }
  15237. case "BooleanLiteral":
  15238. {
  15239. return String(n.value);
  15240. }
  15241. case "CommentStatement":
  15242. {
  15243. return concat$7(["<!--", n.value, "-->"]);
  15244. }
  15245. case "StringLiteral":
  15246. {
  15247. return printStringLiteral(n.value, options);
  15248. }
  15249. case "NumberLiteral":
  15250. {
  15251. return String(n.value);
  15252. }
  15253. case "UndefinedLiteral":
  15254. {
  15255. return "undefined";
  15256. }
  15257. case "NullLiteral":
  15258. {
  15259. return "null";
  15260. }
  15261. /* istanbul ignore next */
  15262. default:
  15263. throw new Error("unknown glimmer type: " + JSON.stringify(n.type));
  15264. }
  15265. }
  15266. /**
  15267. * Prints a string literal with the correct surrounding quotes based on
  15268. * `options.singleQuote` and the number of escaped quotes contained in
  15269. * the string literal. This function is the glimmer equivalent of `printString`
  15270. * in `common/util`, but has differences because of the way escaped characters
  15271. * are treated in hbs string literals.
  15272. * @param {string} stringLiteral - the string literal value
  15273. * @param {object} options - the prettier options object
  15274. */
  15275. function printStringLiteral(stringLiteral, options) {
  15276. var double = {
  15277. quote: '"',
  15278. regex: /"/g
  15279. };
  15280. var single = {
  15281. quote: "'",
  15282. regex: /'/g
  15283. };
  15284. var preferred = options.singleQuote ? single : double;
  15285. var alternate = preferred === single ? double : single;
  15286. var shouldUseAlternateQuote = false; // If `stringLiteral` contains at least one of the quote preferred for
  15287. // enclosing the string, we might want to enclose with the alternate quote
  15288. // instead, to minimize the number of escaped quotes.
  15289. if (stringLiteral.includes(preferred.quote) || stringLiteral.includes(alternate.quote)) {
  15290. var numPreferredQuotes = (stringLiteral.match(preferred.regex) || []).length;
  15291. var numAlternateQuotes = (stringLiteral.match(alternate.regex) || []).length;
  15292. shouldUseAlternateQuote = numPreferredQuotes > numAlternateQuotes;
  15293. }
  15294. var enclosingQuote = shouldUseAlternateQuote ? alternate : preferred;
  15295. var escapedStringLiteral = stringLiteral.replace(enclosingQuote.regex, "\\".concat(enclosingQuote.quote));
  15296. return "".concat(enclosingQuote.quote).concat(escapedStringLiteral).concat(enclosingQuote.quote);
  15297. }
  15298. function printPath(path, print) {
  15299. return path.call(print, "path");
  15300. }
  15301. function getParams(path, print) {
  15302. var node = path.getValue();
  15303. var parts = [];
  15304. if (node.params.length > 0) {
  15305. parts = parts.concat(path.map(print, "params"));
  15306. }
  15307. if (node.hash && node.hash.pairs.length > 0) {
  15308. parts.push(path.call(print, "hash"));
  15309. }
  15310. return parts;
  15311. }
  15312. function printPathParams(path, print) {
  15313. var parts = [];
  15314. parts.push(printPath(path, print));
  15315. parts = parts.concat(getParams(path, print));
  15316. return indent$4(group$6(join$4(line$5, parts)));
  15317. }
  15318. function printBlockParams(path) {
  15319. var block = path.getValue();
  15320. if (!block.program || !block.program.blockParams.length) {
  15321. return "";
  15322. }
  15323. return concat$7([" as |", block.program.blockParams.join(" "), "|"]);
  15324. }
  15325. function printOpenBlock(path, print) {
  15326. return group$6(concat$7(["{{#", printPathParams(path, print), printBlockParams(path), softline$3, "}}"]));
  15327. }
  15328. function printCloseBlock(path, print) {
  15329. return concat$7(["{{/", path.call(print, "path"), "}}"]);
  15330. }
  15331. function clean$3(ast, newObj) {
  15332. delete newObj.loc; // (Glimmer/HTML) ignore TextNode whitespace
  15333. if (ast.type === "TextNode") {
  15334. if (ast.chars.replace(/\s+/, "") === "") {
  15335. return null;
  15336. }
  15337. newObj.chars = ast.chars.replace(/^\s+/, "").replace(/\s+$/, "");
  15338. }
  15339. }
  15340. var printerGlimmer = {
  15341. print: print,
  15342. massageAstNode: clean$3
  15343. };
  15344. var name$6 = "Handlebars";
  15345. var type$5 = "markup";
  15346. var group$7 = "HTML";
  15347. var aliases = ["hbs", "htmlbars"];
  15348. var extensions$5 = [".handlebars", ".hbs"];
  15349. var tmScope$5 = "text.html.handlebars";
  15350. var aceMode$5 = "handlebars";
  15351. var languageId$5 = 155;
  15352. var handlebars = {
  15353. name: name$6,
  15354. type: type$5,
  15355. group: group$7,
  15356. aliases: aliases,
  15357. extensions: extensions$5,
  15358. tmScope: tmScope$5,
  15359. aceMode: aceMode$5,
  15360. languageId: languageId$5
  15361. };
  15362. var handlebars$1 = Object.freeze({
  15363. name: name$6,
  15364. type: type$5,
  15365. group: group$7,
  15366. aliases: aliases,
  15367. extensions: extensions$5,
  15368. tmScope: tmScope$5,
  15369. aceMode: aceMode$5,
  15370. languageId: languageId$5,
  15371. default: handlebars
  15372. });
  15373. var require$$0$19 = ( handlebars$1 && handlebars ) || handlebars$1;
  15374. var languages$2 = [createLanguage(require$$0$19, {
  15375. override: {
  15376. since: null,
  15377. // unreleased
  15378. parsers: ["glimmer"],
  15379. vscodeLanguageIds: ["handlebars"]
  15380. }
  15381. })];
  15382. var printers$2 = {
  15383. glimmer: printerGlimmer
  15384. };
  15385. var languageHandlebars = {
  15386. languages: languages$2,
  15387. printers: printers$2
  15388. };
  15389. var clean$4 = function clean(ast, newNode) {
  15390. delete newNode.sourceSpan;
  15391. delete newNode.startSourceSpan;
  15392. delete newNode.endSourceSpan;
  15393. delete newNode.nameSpan;
  15394. delete newNode.valueSpan;
  15395. if (ast.type === "text" || ast.type === "comment") {
  15396. return null;
  15397. } // may be formatted by multiparser
  15398. if (ast.type === "yaml" || ast.type === "toml") {
  15399. return null;
  15400. }
  15401. if (ast.type === "attribute") {
  15402. delete newNode.value;
  15403. }
  15404. if (ast.type === "docType") {
  15405. delete newNode.value;
  15406. }
  15407. };
  15408. var a = ["accesskey", "charset", "coords", "download", "href", "hreflang", "name", "ping", "referrerpolicy", "rel", "rev", "shape", "tabindex", "target", "type"];
  15409. var abbr = ["title"];
  15410. var applet = ["align", "alt", "archive", "code", "codebase", "height", "hspace", "name", "object", "vspace", "width"];
  15411. var area = ["accesskey", "alt", "coords", "download", "href", "hreflang", "nohref", "ping", "referrerpolicy", "rel", "shape", "tabindex", "target", "type"];
  15412. var audio = ["autoplay", "controls", "crossorigin", "loop", "muted", "preload", "src"];
  15413. var base$2 = ["href", "target"];
  15414. var basefont = ["color", "face", "size"];
  15415. var bdo = ["dir"];
  15416. var blockquote = ["cite"];
  15417. var body = ["alink", "background", "bgcolor", "link", "text", "vlink"];
  15418. var br = ["clear"];
  15419. var button = ["accesskey", "autofocus", "disabled", "form", "formaction", "formenctype", "formmethod", "formnovalidate", "formtarget", "name", "tabindex", "type", "value"];
  15420. var canvas = ["height", "width"];
  15421. var caption = ["align"];
  15422. var col = ["align", "char", "charoff", "span", "valign", "width"];
  15423. var colgroup = ["align", "char", "charoff", "span", "valign", "width"];
  15424. var data = ["value"];
  15425. var del = ["cite", "datetime"];
  15426. var details = ["open"];
  15427. var dfn = ["title"];
  15428. var dialog = ["open"];
  15429. var dir = ["compact"];
  15430. var div = ["align"];
  15431. var dl = ["compact"];
  15432. var embed$3 = ["height", "src", "type", "width"];
  15433. var fieldset = ["disabled", "form", "name"];
  15434. var font = ["color", "face", "size"];
  15435. var form = ["accept", "accept-charset", "action", "autocomplete", "enctype", "method", "name", "novalidate", "target"];
  15436. var frame = ["frameborder", "longdesc", "marginheight", "marginwidth", "name", "noresize", "scrolling", "src"];
  15437. var frameset = ["cols", "rows"];
  15438. var h1 = ["align"];
  15439. var h2 = ["align"];
  15440. var h3 = ["align"];
  15441. var h4 = ["align"];
  15442. var h5 = ["align"];
  15443. var h6 = ["align"];
  15444. var head = ["profile"];
  15445. var hr = ["align", "noshade", "size", "width"];
  15446. var html = ["manifest", "version"];
  15447. var iframe = ["align", "allowfullscreen", "allowpaymentrequest", "allowusermedia", "frameborder", "height", "longdesc", "marginheight", "marginwidth", "name", "referrerpolicy", "sandbox", "scrolling", "src", "srcdoc", "width"];
  15448. var img = ["align", "alt", "border", "crossorigin", "decoding", "height", "hspace", "ismap", "longdesc", "name", "referrerpolicy", "sizes", "src", "srcset", "usemap", "vspace", "width"];
  15449. var input = ["accept", "accesskey", "align", "alt", "autocomplete", "autofocus", "checked", "dirname", "disabled", "form", "formaction", "formenctype", "formmethod", "formnovalidate", "formtarget", "height", "ismap", "list", "max", "maxlength", "min", "minlength", "multiple", "name", "pattern", "placeholder", "readonly", "required", "size", "src", "step", "tabindex", "title", "type", "usemap", "value", "width"];
  15450. var ins = ["cite", "datetime"];
  15451. var isindex = ["prompt"];
  15452. var label = ["accesskey", "for", "form"];
  15453. var legend = ["accesskey", "align"];
  15454. var li = ["type", "value"];
  15455. var link$1 = ["as", "charset", "color", "crossorigin", "href", "hreflang", "integrity", "media", "nonce", "referrerpolicy", "rel", "rev", "sizes", "target", "title", "type"];
  15456. var map = ["name"];
  15457. var menu = ["compact"];
  15458. var meta = ["charset", "content", "http-equiv", "name", "scheme"];
  15459. var meter = ["high", "low", "max", "min", "optimum", "value"];
  15460. var object = ["align", "archive", "border", "classid", "codebase", "codetype", "data", "declare", "form", "height", "hspace", "name", "standby", "tabindex", "type", "typemustmatch", "usemap", "vspace", "width"];
  15461. var ol = ["compact", "reversed", "start", "type"];
  15462. var optgroup = ["disabled", "label"];
  15463. var option = ["disabled", "label", "selected", "value"];
  15464. var output = ["for", "form", "name"];
  15465. var p = ["align"];
  15466. var param = ["name", "type", "value", "valuetype"];
  15467. var pre = ["width"];
  15468. var progress = ["max", "value"];
  15469. var q = ["cite"];
  15470. var script = ["async", "charset", "crossorigin", "defer", "integrity", "language", "nomodule", "nonce", "referrerpolicy", "src", "type"];
  15471. var select = ["autocomplete", "autofocus", "disabled", "form", "multiple", "name", "required", "size", "tabindex"];
  15472. var slot = ["name"];
  15473. var source = ["media", "sizes", "src", "srcset", "type"];
  15474. var style = ["media", "nonce", "title", "type"];
  15475. var table = ["align", "bgcolor", "border", "cellpadding", "cellspacing", "frame", "rules", "summary", "width"];
  15476. var tbody = ["align", "char", "charoff", "valign"];
  15477. var td = ["abbr", "align", "axis", "bgcolor", "char", "charoff", "colspan", "headers", "height", "nowrap", "rowspan", "scope", "valign", "width"];
  15478. var textarea = ["accesskey", "autocomplete", "autofocus", "cols", "dirname", "disabled", "form", "maxlength", "minlength", "name", "placeholder", "readonly", "required", "rows", "tabindex", "wrap"];
  15479. var tfoot = ["align", "char", "charoff", "valign"];
  15480. var th = ["abbr", "align", "axis", "bgcolor", "char", "charoff", "colspan", "headers", "height", "nowrap", "rowspan", "scope", "valign", "width"];
  15481. var thead = ["align", "char", "charoff", "valign"];
  15482. var time = ["datetime"];
  15483. var tr = ["align", "bgcolor", "char", "charoff", "valign"];
  15484. var track = ["default", "kind", "label", "src", "srclang"];
  15485. var ul = ["compact", "type"];
  15486. var video = ["autoplay", "controls", "crossorigin", "height", "loop", "muted", "playsinline", "poster", "preload", "src", "width"];
  15487. var index$13 = {
  15488. a: a,
  15489. abbr: abbr,
  15490. applet: applet,
  15491. area: area,
  15492. audio: audio,
  15493. base: base$2,
  15494. basefont: basefont,
  15495. bdo: bdo,
  15496. blockquote: blockquote,
  15497. body: body,
  15498. br: br,
  15499. button: button,
  15500. canvas: canvas,
  15501. caption: caption,
  15502. col: col,
  15503. colgroup: colgroup,
  15504. data: data,
  15505. del: del,
  15506. details: details,
  15507. dfn: dfn,
  15508. dialog: dialog,
  15509. dir: dir,
  15510. div: div,
  15511. dl: dl,
  15512. embed: embed$3,
  15513. fieldset: fieldset,
  15514. font: font,
  15515. form: form,
  15516. frame: frame,
  15517. frameset: frameset,
  15518. h1: h1,
  15519. h2: h2,
  15520. h3: h3,
  15521. h4: h4,
  15522. h5: h5,
  15523. h6: h6,
  15524. head: head,
  15525. hr: hr,
  15526. html: html,
  15527. iframe: iframe,
  15528. img: img,
  15529. input: input,
  15530. ins: ins,
  15531. isindex: isindex,
  15532. label: label,
  15533. legend: legend,
  15534. li: li,
  15535. link: link$1,
  15536. map: map,
  15537. menu: menu,
  15538. meta: meta,
  15539. meter: meter,
  15540. object: object,
  15541. ol: ol,
  15542. optgroup: optgroup,
  15543. option: option,
  15544. output: output,
  15545. p: p,
  15546. param: param,
  15547. pre: pre,
  15548. progress: progress,
  15549. q: q,
  15550. script: script,
  15551. select: select,
  15552. slot: slot,
  15553. source: source,
  15554. style: style,
  15555. table: table,
  15556. tbody: tbody,
  15557. td: td,
  15558. textarea: textarea,
  15559. tfoot: tfoot,
  15560. th: th,
  15561. thead: thead,
  15562. time: time,
  15563. tr: tr,
  15564. track: track,
  15565. ul: ul,
  15566. video: video,
  15567. "*": ["accesskey", "autocapitalize", "class", "contenteditable", "dir", "draggable", "hidden", "id", "inputmode", "is", "itemid", "itemprop", "itemref", "itemscope", "itemtype", "lang", "nonce", "slot", "spellcheck", "style", "tabindex", "title", "translate"]
  15568. };
  15569. var htmlElementAttributes = Object.freeze({
  15570. a: a,
  15571. abbr: abbr,
  15572. applet: applet,
  15573. area: area,
  15574. audio: audio,
  15575. base: base$2,
  15576. basefont: basefont,
  15577. bdo: bdo,
  15578. blockquote: blockquote,
  15579. body: body,
  15580. br: br,
  15581. button: button,
  15582. canvas: canvas,
  15583. caption: caption,
  15584. col: col,
  15585. colgroup: colgroup,
  15586. data: data,
  15587. del: del,
  15588. details: details,
  15589. dfn: dfn,
  15590. dialog: dialog,
  15591. dir: dir,
  15592. div: div,
  15593. dl: dl,
  15594. embed: embed$3,
  15595. fieldset: fieldset,
  15596. font: font,
  15597. form: form,
  15598. frame: frame,
  15599. frameset: frameset,
  15600. h1: h1,
  15601. h2: h2,
  15602. h3: h3,
  15603. h4: h4,
  15604. h5: h5,
  15605. h6: h6,
  15606. head: head,
  15607. hr: hr,
  15608. html: html,
  15609. iframe: iframe,
  15610. img: img,
  15611. input: input,
  15612. ins: ins,
  15613. isindex: isindex,
  15614. label: label,
  15615. legend: legend,
  15616. li: li,
  15617. link: link$1,
  15618. map: map,
  15619. menu: menu,
  15620. meta: meta,
  15621. meter: meter,
  15622. object: object,
  15623. ol: ol,
  15624. optgroup: optgroup,
  15625. option: option,
  15626. output: output,
  15627. p: p,
  15628. param: param,
  15629. pre: pre,
  15630. progress: progress,
  15631. q: q,
  15632. script: script,
  15633. select: select,
  15634. slot: slot,
  15635. source: source,
  15636. style: style,
  15637. table: table,
  15638. tbody: tbody,
  15639. td: td,
  15640. textarea: textarea,
  15641. tfoot: tfoot,
  15642. th: th,
  15643. thead: thead,
  15644. time: time,
  15645. tr: tr,
  15646. track: track,
  15647. ul: ul,
  15648. video: video,
  15649. default: index$13
  15650. });
  15651. var json$4 = {"CSS_DISPLAY_TAGS":{"area":"none","base":"none","basefont":"none","datalist":"none","head":"none","link":"none","meta":"none","noembed":"none","noframes":"none","param":"none","rp":"none","script":"none","source":"block","style":"none","template":"inline","track":"block","title":"none","html":"block","body":"block","address":"block","blockquote":"block","center":"block","div":"block","figure":"block","figcaption":"block","footer":"block","form":"block","header":"block","hr":"block","legend":"block","listing":"block","main":"block","p":"block","plaintext":"block","pre":"block","xmp":"block","slot":"contents","ruby":"ruby","rt":"ruby-text","article":"block","aside":"block","h1":"block","h2":"block","h3":"block","h4":"block","h5":"block","h6":"block","hgroup":"block","nav":"block","section":"block","dir":"block","dd":"block","dl":"block","dt":"block","ol":"block","ul":"block","li":"list-item","table":"table","caption":"table-caption","colgroup":"table-column-group","col":"table-column","thead":"table-header-group","tbody":"table-row-group","tfoot":"table-footer-group","tr":"table-row","td":"table-cell","th":"table-cell","fieldset":"block","button":"inline-block","video":"inline-block","audio":"inline-block"},"CSS_DISPLAY_DEFAULT":"inline","CSS_WHITE_SPACE_TAGS":{"listing":"pre","plaintext":"pre","pre":"pre","xmp":"pre","nobr":"nowrap","table":"initial","textarea":"pre-wrap"},"CSS_WHITE_SPACE_DEFAULT":"normal"};
  15652. var htmlElementAttributes$1 = ( htmlElementAttributes && index$13 ) || htmlElementAttributes;
  15653. var CSS_DISPLAY_TAGS = json$4.CSS_DISPLAY_TAGS;
  15654. var CSS_DISPLAY_DEFAULT = json$4.CSS_DISPLAY_DEFAULT;
  15655. var CSS_WHITE_SPACE_TAGS = json$4.CSS_WHITE_SPACE_TAGS;
  15656. var CSS_WHITE_SPACE_DEFAULT = json$4.CSS_WHITE_SPACE_DEFAULT;
  15657. var HTML_TAGS = arrayToMap(htmlTagNames$1);
  15658. var HTML_ELEMENT_ATTRIBUTES = mapObject(htmlElementAttributes$1, arrayToMap);
  15659. function arrayToMap(array) {
  15660. var map = Object.create(null);
  15661. var _iteratorNormalCompletion = true;
  15662. var _didIteratorError = false;
  15663. var _iteratorError = undefined;
  15664. try {
  15665. for (var _iterator = array[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  15666. var value = _step.value;
  15667. map[value] = true;
  15668. }
  15669. } catch (err) {
  15670. _didIteratorError = true;
  15671. _iteratorError = err;
  15672. } finally {
  15673. try {
  15674. if (!_iteratorNormalCompletion && _iterator.return != null) {
  15675. _iterator.return();
  15676. }
  15677. } finally {
  15678. if (_didIteratorError) {
  15679. throw _iteratorError;
  15680. }
  15681. }
  15682. }
  15683. return map;
  15684. }
  15685. function mapObject(object, fn) {
  15686. var newObject = Object.create(null);
  15687. var _arr = Object.keys(object);
  15688. for (var _i = 0; _i < _arr.length; _i++) {
  15689. var key = _arr[_i];
  15690. newObject[key] = fn(object[key], key);
  15691. }
  15692. return newObject;
  15693. }
  15694. function shouldPreserveContent$1(node, options) {
  15695. if (node.type === "element" && node.fullName === "template" && node.attrMap.lang && node.attrMap.lang !== "html") {
  15696. return true;
  15697. } // unterminated node in ie conditional comment
  15698. // e.g. <!--[if lt IE 9]><html><![endif]-->
  15699. if (node.type === "ieConditionalComment" && node.lastChild && !node.lastChild.isSelfClosing && !node.lastChild.endSourceSpan) {
  15700. return true;
  15701. } // incomplete html in ie conditional comment
  15702. // e.g. <!--[if lt IE 9]></div><![endif]-->
  15703. if (node.type === "ieConditionalComment" && !node.complete) {
  15704. return true;
  15705. } // top-level elements (excluding <template>, <style> and <script>) in Vue SFC are considered custom block
  15706. // custom blocks can be written in other languages so we should preserve them to not break the code
  15707. if (options.parser === "vue" && node.type === "element" && node.parent.type === "root" && ["template", "style", "script", // vue parser can be used for vue dom template as well, so we should still format top-level <html>
  15708. "html"].indexOf(node.fullName) === -1) {
  15709. return true;
  15710. } // TODO: handle non-text children in <pre>
  15711. if (isPreLikeNode(node) && node.children.some(function (child) {
  15712. return child.type !== "text" && child.type !== "interpolation";
  15713. })) {
  15714. return true;
  15715. }
  15716. return false;
  15717. }
  15718. function hasPrettierIgnore$1(node) {
  15719. if (node.type === "attribute" || isTextLikeNode$1(node)) {
  15720. return false;
  15721. }
  15722. if (!node.parent) {
  15723. return false;
  15724. }
  15725. if (typeof node.index !== "number" || node.index === 0) {
  15726. return false;
  15727. }
  15728. var prevNode = node.parent.children[node.index - 1];
  15729. return isPrettierIgnore(prevNode);
  15730. }
  15731. function isPrettierIgnore(node) {
  15732. return node.type === "comment" && node.value.trim() === "prettier-ignore";
  15733. }
  15734. function getPrettierIgnoreAttributeCommentData$1(value) {
  15735. var match = value.trim().match(/^prettier-ignore-attribute(?:\s+([^]+))?$/);
  15736. if (!match) {
  15737. return false;
  15738. }
  15739. if (!match[1]) {
  15740. return true;
  15741. }
  15742. return match[1].split(/\s+/);
  15743. }
  15744. /** there's no opening/closing tag or it's considered not breakable */
  15745. function isTextLikeNode$1(node) {
  15746. return node.type === "text" || node.type === "comment";
  15747. }
  15748. function isScriptLikeTag$1(node) {
  15749. return node.type === "element" && (node.fullName === "script" || node.fullName === "style" || node.fullName === "svg:style");
  15750. }
  15751. function isFrontMatterNode(node) {
  15752. return node.type === "yaml" || node.type === "toml";
  15753. }
  15754. function canHaveInterpolation(node) {
  15755. return node.children && !isScriptLikeTag$1(node);
  15756. }
  15757. function isWhitespaceSensitiveNode(node) {
  15758. return isScriptLikeTag$1(node) || node.type === "interpolation" || isIndentationSensitiveNode(node);
  15759. }
  15760. function isIndentationSensitiveNode(node) {
  15761. return getNodeCssStyleWhiteSpace(node).startsWith("pre");
  15762. }
  15763. function isLeadingSpaceSensitiveNode(node) {
  15764. var isLeadingSpaceSensitive = _isLeadingSpaceSensitiveNode();
  15765. if (isLeadingSpaceSensitive && !node.prev && node.parent && node.parent.tagDefinition && node.parent.tagDefinition.ignoreFirstLf) {
  15766. return node.type === "interpolation";
  15767. }
  15768. return isLeadingSpaceSensitive;
  15769. function _isLeadingSpaceSensitiveNode() {
  15770. if (isFrontMatterNode(node)) {
  15771. return false;
  15772. }
  15773. if ((node.type === "text" || node.type === "interpolation") && node.prev && (node.prev.type === "text" || node.prev.type === "interpolation")) {
  15774. return true;
  15775. }
  15776. if (!node.parent || node.parent.cssDisplay === "none") {
  15777. return false;
  15778. }
  15779. if (isPreLikeNode(node.parent)) {
  15780. return true;
  15781. }
  15782. if (!node.prev && (node.parent.type === "root" || isScriptLikeTag$1(node.parent) || !isFirstChildLeadingSpaceSensitiveCssDisplay(node.parent.cssDisplay))) {
  15783. return false;
  15784. }
  15785. if (node.prev && !isNextLeadingSpaceSensitiveCssDisplay(node.prev.cssDisplay)) {
  15786. return false;
  15787. }
  15788. return true;
  15789. }
  15790. }
  15791. function isTrailingSpaceSensitiveNode(node) {
  15792. if (isFrontMatterNode(node)) {
  15793. return false;
  15794. }
  15795. if ((node.type === "text" || node.type === "interpolation") && node.next && (node.next.type === "text" || node.next.type === "interpolation")) {
  15796. return true;
  15797. }
  15798. if (!node.parent || node.parent.cssDisplay === "none") {
  15799. return false;
  15800. }
  15801. if (isPreLikeNode(node.parent)) {
  15802. return true;
  15803. }
  15804. if (!node.next && (node.parent.type === "root" || isScriptLikeTag$1(node.parent) || !isLastChildTrailingSpaceSensitiveCssDisplay(node.parent.cssDisplay))) {
  15805. return false;
  15806. }
  15807. if (node.next && !isPrevTrailingSpaceSensitiveCssDisplay(node.next.cssDisplay)) {
  15808. return false;
  15809. }
  15810. return true;
  15811. }
  15812. function isDanglingSpaceSensitiveNode(node) {
  15813. return isDanglingSpaceSensitiveCssDisplay(node.cssDisplay) && !isScriptLikeTag$1(node);
  15814. }
  15815. function forceNextEmptyLine$1(node) {
  15816. return isFrontMatterNode(node) || node.next && node.sourceSpan.end.line + 1 < node.next.sourceSpan.start.line;
  15817. }
  15818. /** firstChild leadingSpaces and lastChild trailingSpaces */
  15819. function forceBreakContent$1(node) {
  15820. return forceBreakChildren$1(node) || node.type === "element" && node.children.length !== 0 && (["body", "template", "script", "style"].indexOf(node.name) !== -1 || node.children.some(function (child) {
  15821. return hasNonTextChild(child);
  15822. })) || node.firstChild && node.firstChild === node.lastChild && hasLeadingLineBreak(node.firstChild) && (!node.lastChild.isTrailingSpaceSensitive || hasTrailingLineBreak(node.lastChild));
  15823. }
  15824. /** spaces between children */
  15825. function forceBreakChildren$1(node) {
  15826. return node.type === "element" && node.children.length !== 0 && (["html", "head", "ul", "ol", "select"].indexOf(node.name) !== -1 || node.cssDisplay.startsWith("table") && node.cssDisplay !== "table-cell");
  15827. }
  15828. function preferHardlineAsLeadingSpaces$1(node) {
  15829. return preferHardlineAsSurroundingSpaces(node) || node.prev && preferHardlineAsTrailingSpaces(node.prev) || hasSurroundingLineBreak(node);
  15830. }
  15831. function preferHardlineAsTrailingSpaces(node) {
  15832. return preferHardlineAsSurroundingSpaces(node) || node.type === "element" && node.fullName === "br" || hasSurroundingLineBreak(node);
  15833. }
  15834. function hasSurroundingLineBreak(node) {
  15835. return hasLeadingLineBreak(node) && hasTrailingLineBreak(node);
  15836. }
  15837. function hasLeadingLineBreak(node) {
  15838. return node.hasLeadingSpaces && (node.prev ? node.prev.sourceSpan.end.line < node.sourceSpan.start.line : node.parent.type === "root" || node.parent.startSourceSpan.end.line < node.sourceSpan.start.line);
  15839. }
  15840. function hasTrailingLineBreak(node) {
  15841. return node.hasTrailingSpaces && (node.next ? node.next.sourceSpan.start.line > node.sourceSpan.end.line : node.parent.type === "root" || node.parent.endSourceSpan.start.line > node.sourceSpan.end.line);
  15842. }
  15843. function preferHardlineAsSurroundingSpaces(node) {
  15844. switch (node.type) {
  15845. case "ieConditionalComment":
  15846. case "comment":
  15847. case "directive":
  15848. return true;
  15849. case "element":
  15850. return ["script", "select"].indexOf(node.name) !== -1;
  15851. }
  15852. return false;
  15853. }
  15854. function getLastDescendant$1(node) {
  15855. return node.lastChild ? getLastDescendant$1(node.lastChild) : node;
  15856. }
  15857. function hasNonTextChild(node) {
  15858. return node.children && node.children.some(function (child) {
  15859. return child.type !== "text";
  15860. });
  15861. }
  15862. function inferScriptParser$1(node) {
  15863. if (node.name === "script" && !node.attrMap.src) {
  15864. if (!node.attrMap.lang && !node.attrMap.type || node.attrMap.type === "module" || node.attrMap.type === "text/javascript" || node.attrMap.type === "text/babel" || node.attrMap.type === "application/javascript") {
  15865. return "babel";
  15866. }
  15867. if (node.attrMap.type === "application/x-typescript" || node.attrMap.lang === "ts" || node.attrMap.lang === "tsx") {
  15868. return "typescript";
  15869. }
  15870. if (node.attrMap.type === "text/markdown") {
  15871. return "markdown";
  15872. }
  15873. if (node.attrMap.type === "application/ld+json") {
  15874. return "json";
  15875. }
  15876. }
  15877. if (node.name === "style") {
  15878. if (!node.attrMap.lang || node.attrMap.lang === "postcss") {
  15879. return "css";
  15880. }
  15881. if (node.attrMap.lang === "scss") {
  15882. return "scss";
  15883. }
  15884. if (node.attrMap.lang === "less") {
  15885. return "less";
  15886. }
  15887. }
  15888. return null;
  15889. }
  15890. function isBlockLikeCssDisplay(cssDisplay) {
  15891. return cssDisplay === "block" || cssDisplay === "list-item" || cssDisplay.startsWith("table");
  15892. }
  15893. function isFirstChildLeadingSpaceSensitiveCssDisplay(cssDisplay) {
  15894. return !isBlockLikeCssDisplay(cssDisplay) && cssDisplay !== "inline-block";
  15895. }
  15896. function isLastChildTrailingSpaceSensitiveCssDisplay(cssDisplay) {
  15897. return !isBlockLikeCssDisplay(cssDisplay) && cssDisplay !== "inline-block";
  15898. }
  15899. function isPrevTrailingSpaceSensitiveCssDisplay(cssDisplay) {
  15900. return !isBlockLikeCssDisplay(cssDisplay);
  15901. }
  15902. function isNextLeadingSpaceSensitiveCssDisplay(cssDisplay) {
  15903. return !isBlockLikeCssDisplay(cssDisplay);
  15904. }
  15905. function isDanglingSpaceSensitiveCssDisplay(cssDisplay) {
  15906. return !isBlockLikeCssDisplay(cssDisplay) && cssDisplay !== "inline-block";
  15907. }
  15908. function isPreLikeNode(node) {
  15909. return getNodeCssStyleWhiteSpace(node).startsWith("pre");
  15910. }
  15911. function countParents$1(path) {
  15912. var predicate = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () {
  15913. return true;
  15914. };
  15915. var counter = 0;
  15916. for (var i = path.stack.length - 1; i >= 0; i--) {
  15917. var value = path.stack[i];
  15918. if (value && _typeof(value) === "object" && !Array.isArray(value) && predicate(value)) {
  15919. counter++;
  15920. }
  15921. }
  15922. return counter;
  15923. }
  15924. function hasParent(node, fn) {
  15925. var current = node;
  15926. while (current) {
  15927. if (fn(current)) {
  15928. return true;
  15929. }
  15930. current = current.parent;
  15931. }
  15932. return false;
  15933. }
  15934. function getNodeCssStyleDisplay(node, options) {
  15935. if (node.prev && node.prev.type === "comment") {
  15936. // <!-- display: block -->
  15937. var match = node.prev.value.match(/^\s*display:\s*([a-z]+)\s*$/);
  15938. if (match) {
  15939. return match[1];
  15940. }
  15941. }
  15942. var isInSvgForeignObject = false;
  15943. if (node.type === "element" && node.namespace === "svg") {
  15944. if (hasParent(node, function (parent) {
  15945. return parent.fullName === "svg:foreignObject";
  15946. })) {
  15947. isInSvgForeignObject = true;
  15948. } else {
  15949. return node.name === "svg" ? "inline-block" : "block";
  15950. }
  15951. }
  15952. switch (options.htmlWhitespaceSensitivity) {
  15953. case "strict":
  15954. return "inline";
  15955. case "ignore":
  15956. return "block";
  15957. default:
  15958. return node.type === "element" && (!node.namespace || isInSvgForeignObject) && CSS_DISPLAY_TAGS[node.name] || CSS_DISPLAY_DEFAULT;
  15959. }
  15960. }
  15961. function getNodeCssStyleWhiteSpace(node) {
  15962. return node.type === "element" && !node.namespace && CSS_WHITE_SPACE_TAGS[node.name] || CSS_WHITE_SPACE_DEFAULT;
  15963. }
  15964. function getMinIndentation(text) {
  15965. var minIndentation = Infinity;
  15966. var _iteratorNormalCompletion2 = true;
  15967. var _didIteratorError2 = false;
  15968. var _iteratorError2 = undefined;
  15969. try {
  15970. for (var _iterator2 = text.split("\n")[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
  15971. var lineText = _step2.value;
  15972. if (lineText.length === 0) {
  15973. continue;
  15974. }
  15975. if (/\S/.test(lineText[0])) {
  15976. return 0;
  15977. }
  15978. var indentation = lineText.match(/^\s*/)[0].length;
  15979. if (lineText.length === indentation) {
  15980. continue;
  15981. }
  15982. if (indentation < minIndentation) {
  15983. minIndentation = indentation;
  15984. }
  15985. }
  15986. } catch (err) {
  15987. _didIteratorError2 = true;
  15988. _iteratorError2 = err;
  15989. } finally {
  15990. try {
  15991. if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
  15992. _iterator2.return();
  15993. }
  15994. } finally {
  15995. if (_didIteratorError2) {
  15996. throw _iteratorError2;
  15997. }
  15998. }
  15999. }
  16000. return minIndentation === Infinity ? 0 : minIndentation;
  16001. }
  16002. function dedentString$1(text) {
  16003. var minIndent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : getMinIndentation(text);
  16004. return minIndent === 0 ? text : text.split("\n").map(function (lineText) {
  16005. return lineText.slice(minIndent);
  16006. }).join("\n");
  16007. }
  16008. function normalizeParts$1(parts) {
  16009. var newParts = [];
  16010. var restParts = parts.slice();
  16011. while (restParts.length !== 0) {
  16012. var part = restParts.shift();
  16013. if (!part) {
  16014. continue;
  16015. }
  16016. if (part.type === "concat") {
  16017. Array.prototype.unshift.apply(restParts, part.parts);
  16018. continue;
  16019. }
  16020. if (newParts.length !== 0 && typeof newParts[newParts.length - 1] === "string" && typeof part === "string") {
  16021. newParts.push(newParts.pop() + part);
  16022. continue;
  16023. }
  16024. newParts.push(part);
  16025. }
  16026. return newParts;
  16027. }
  16028. function identity(x) {
  16029. return x;
  16030. }
  16031. function shouldNotPrintClosingTag$1(node, options) {
  16032. return !node.isSelfClosing && !node.endSourceSpan && (hasPrettierIgnore$1(node) || shouldPreserveContent$1(node.parent, options));
  16033. }
  16034. function countChars$1(text, char) {
  16035. var counter = 0;
  16036. for (var i = 0; i < text.length; i++) {
  16037. if (text[i] === char) {
  16038. counter++;
  16039. }
  16040. }
  16041. return counter;
  16042. }
  16043. function unescapeQuoteEntities$1(text) {
  16044. return text.replace(/&apos;/g, "'").replace(/&quot;/g, '"');
  16045. }
  16046. var utils$6 = {
  16047. HTML_ELEMENT_ATTRIBUTES: HTML_ELEMENT_ATTRIBUTES,
  16048. HTML_TAGS: HTML_TAGS,
  16049. canHaveInterpolation: canHaveInterpolation,
  16050. countChars: countChars$1,
  16051. countParents: countParents$1,
  16052. dedentString: dedentString$1,
  16053. forceBreakChildren: forceBreakChildren$1,
  16054. forceBreakContent: forceBreakContent$1,
  16055. forceNextEmptyLine: forceNextEmptyLine$1,
  16056. getLastDescendant: getLastDescendant$1,
  16057. getNodeCssStyleDisplay: getNodeCssStyleDisplay,
  16058. getNodeCssStyleWhiteSpace: getNodeCssStyleWhiteSpace,
  16059. getPrettierIgnoreAttributeCommentData: getPrettierIgnoreAttributeCommentData$1,
  16060. hasPrettierIgnore: hasPrettierIgnore$1,
  16061. identity: identity,
  16062. inferScriptParser: inferScriptParser$1,
  16063. isDanglingSpaceSensitiveNode: isDanglingSpaceSensitiveNode,
  16064. isFrontMatterNode: isFrontMatterNode,
  16065. isIndentationSensitiveNode: isIndentationSensitiveNode,
  16066. isLeadingSpaceSensitiveNode: isLeadingSpaceSensitiveNode,
  16067. isPreLikeNode: isPreLikeNode,
  16068. isScriptLikeTag: isScriptLikeTag$1,
  16069. isTextLikeNode: isTextLikeNode$1,
  16070. isTrailingSpaceSensitiveNode: isTrailingSpaceSensitiveNode,
  16071. isWhitespaceSensitiveNode: isWhitespaceSensitiveNode,
  16072. normalizeParts: normalizeParts$1,
  16073. preferHardlineAsLeadingSpaces: preferHardlineAsLeadingSpaces$1,
  16074. preferHardlineAsTrailingSpaces: preferHardlineAsTrailingSpaces,
  16075. shouldNotPrintClosingTag: shouldNotPrintClosingTag$1,
  16076. shouldPreserveContent: shouldPreserveContent$1,
  16077. unescapeQuoteEntities: unescapeQuoteEntities$1
  16078. };
  16079. var canHaveInterpolation$1 = utils$6.canHaveInterpolation;
  16080. var getNodeCssStyleDisplay$1 = utils$6.getNodeCssStyleDisplay;
  16081. var isDanglingSpaceSensitiveNode$1 = utils$6.isDanglingSpaceSensitiveNode;
  16082. var isIndentationSensitiveNode$1 = utils$6.isIndentationSensitiveNode;
  16083. var isLeadingSpaceSensitiveNode$1 = utils$6.isLeadingSpaceSensitiveNode;
  16084. var isTrailingSpaceSensitiveNode$1 = utils$6.isTrailingSpaceSensitiveNode;
  16085. var isWhitespaceSensitiveNode$1 = utils$6.isWhitespaceSensitiveNode;
  16086. var PREPROCESS_PIPELINE = [removeIgnorableFirstLf, mergeIeConditonalStartEndCommentIntoElementOpeningTag, mergeCdataIntoText, extractInterpolation, extractWhitespaces, addCssDisplay, addIsSelfClosing, addHasHtmComponentClosingTag, addIsSpaceSensitive, mergeSimpleElementIntoText];
  16087. function preprocess(ast, options) {
  16088. for (var _i = 0; _i < PREPROCESS_PIPELINE.length; _i++) {
  16089. var fn = PREPROCESS_PIPELINE[_i];
  16090. ast = fn(ast, options);
  16091. }
  16092. return ast;
  16093. }
  16094. function removeIgnorableFirstLf(ast
  16095. /*, options */
  16096. ) {
  16097. return ast.map(function (node) {
  16098. if (node.type === "element" && node.tagDefinition.ignoreFirstLf && node.children.length !== 0 && node.children[0].type === "text" && node.children[0].value[0] === "\n") {
  16099. var text = node.children[0];
  16100. return node.clone({
  16101. children: text.value.length === 1 ? node.children.slice(1) : [].concat(text.clone({
  16102. value: text.value.slice(1)
  16103. }), node.children.slice(1))
  16104. });
  16105. }
  16106. return node;
  16107. });
  16108. }
  16109. function mergeIeConditonalStartEndCommentIntoElementOpeningTag(ast
  16110. /*, options */
  16111. ) {
  16112. /**
  16113. * <!--[if ...]><!--><target><!--<![endif]-->
  16114. */
  16115. var isTarget = function isTarget(node) {
  16116. return node.type === "element" && node.prev && node.prev.type === "ieConditionalStartComment" && node.prev.sourceSpan.end.offset === node.startSourceSpan.start.offset && node.firstChild && node.firstChild.type === "ieConditionalEndComment" && node.firstChild.sourceSpan.start.offset === node.startSourceSpan.end.offset;
  16117. };
  16118. return ast.map(function (node) {
  16119. if (node.children) {
  16120. var isTargetResults = node.children.map(isTarget);
  16121. if (isTargetResults.some(Boolean)) {
  16122. var newChildren = [];
  16123. for (var i = 0; i < node.children.length; i++) {
  16124. var child = node.children[i];
  16125. if (isTargetResults[i + 1]) {
  16126. // ieConditionalStartComment
  16127. continue;
  16128. }
  16129. if (isTargetResults[i]) {
  16130. var ieConditionalStartComment = child.prev;
  16131. var ieConditionalEndComment = child.firstChild;
  16132. var ParseSourceSpan = child.sourceSpan.constructor;
  16133. var startSourceSpan = new ParseSourceSpan(ieConditionalStartComment.sourceSpan.start, ieConditionalEndComment.sourceSpan.end);
  16134. var sourceSpan = new ParseSourceSpan(startSourceSpan.start, child.sourceSpan.end);
  16135. newChildren.push(child.clone({
  16136. condition: ieConditionalStartComment.condition,
  16137. sourceSpan: sourceSpan,
  16138. startSourceSpan: startSourceSpan,
  16139. children: child.children.slice(1)
  16140. }));
  16141. continue;
  16142. }
  16143. newChildren.push(child);
  16144. }
  16145. return node.clone({
  16146. children: newChildren
  16147. });
  16148. }
  16149. }
  16150. return node;
  16151. });
  16152. }
  16153. function mergeNodeIntoText(ast, shouldMerge, getValue) {
  16154. return ast.map(function (node) {
  16155. if (node.children) {
  16156. var shouldMergeResults = node.children.map(shouldMerge);
  16157. if (shouldMergeResults.some(Boolean)) {
  16158. var newChildren = [];
  16159. for (var i = 0; i < node.children.length; i++) {
  16160. var child = node.children[i];
  16161. if (child.type !== "text" && !shouldMergeResults[i]) {
  16162. newChildren.push(child);
  16163. continue;
  16164. }
  16165. var newChild = child.type === "text" ? child : child.clone({
  16166. type: "text",
  16167. value: getValue(child)
  16168. });
  16169. if (newChildren.length === 0 || newChildren[newChildren.length - 1].type !== "text") {
  16170. newChildren.push(newChild);
  16171. continue;
  16172. }
  16173. var lastChild = newChildren.pop();
  16174. var ParseSourceSpan = lastChild.sourceSpan.constructor;
  16175. newChildren.push(lastChild.clone({
  16176. value: lastChild.value + newChild.value,
  16177. sourceSpan: new ParseSourceSpan(lastChild.sourceSpan.start, newChild.sourceSpan.end)
  16178. }));
  16179. }
  16180. return node.clone({
  16181. children: newChildren
  16182. });
  16183. }
  16184. }
  16185. return node;
  16186. });
  16187. }
  16188. function mergeCdataIntoText(ast
  16189. /*, options */
  16190. ) {
  16191. return mergeNodeIntoText(ast, function (node) {
  16192. return node.type === "cdata";
  16193. }, function (node) {
  16194. return "<![CDATA[".concat(node.value, "]]>");
  16195. });
  16196. }
  16197. function mergeSimpleElementIntoText(ast
  16198. /*, options */
  16199. ) {
  16200. var isSimpleElement = function isSimpleElement(node) {
  16201. return node.type === "element" && node.attrs.length === 0 && node.children.length === 1 && node.firstChild.type === "text" && // \xA0: non-breaking whitespace
  16202. !/[^\S\xA0]/.test(node.children[0].value) && !node.firstChild.hasLeadingSpaces && !node.firstChild.hasTrailingSpaces && node.isLeadingSpaceSensitive && !node.hasLeadingSpaces && node.isTrailingSpaceSensitive && !node.hasTrailingSpaces && node.prev && node.prev.type === "text" && node.next && node.next.type === "text";
  16203. };
  16204. return ast.map(function (node) {
  16205. if (node.children) {
  16206. var isSimpleElementResults = node.children.map(isSimpleElement);
  16207. if (isSimpleElementResults.some(Boolean)) {
  16208. var newChildren = [];
  16209. for (var i = 0; i < node.children.length; i++) {
  16210. var child = node.children[i];
  16211. if (isSimpleElementResults[i]) {
  16212. var lastChild = newChildren.pop();
  16213. var nextChild = node.children[++i];
  16214. var ParseSourceSpan = node.sourceSpan.constructor;
  16215. var isTrailingSpaceSensitive = nextChild.isTrailingSpaceSensitive,
  16216. hasTrailingSpaces = nextChild.hasTrailingSpaces;
  16217. newChildren.push(lastChild.clone({
  16218. value: lastChild.value + "<".concat(child.rawName, ">") + child.firstChild.value + "</".concat(child.rawName, ">") + nextChild.value,
  16219. sourceSpan: new ParseSourceSpan(lastChild.sourceSpan.start, nextChild.sourceSpan.end),
  16220. isTrailingSpaceSensitive: isTrailingSpaceSensitive,
  16221. hasTrailingSpaces: hasTrailingSpaces
  16222. }));
  16223. } else {
  16224. newChildren.push(child);
  16225. }
  16226. }
  16227. return node.clone({
  16228. children: newChildren
  16229. });
  16230. }
  16231. }
  16232. return node;
  16233. });
  16234. }
  16235. function extractInterpolation(ast, options) {
  16236. if (options.parser === "html") {
  16237. return ast;
  16238. }
  16239. var interpolationRegex = /\{\{([\s\S]+?)\}\}/g;
  16240. return ast.map(function (node) {
  16241. if (!canHaveInterpolation$1(node)) {
  16242. return node;
  16243. }
  16244. var newChildren = [];
  16245. var _iteratorNormalCompletion = true;
  16246. var _didIteratorError = false;
  16247. var _iteratorError = undefined;
  16248. try {
  16249. for (var _iterator = node.children[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  16250. var child = _step.value;
  16251. if (child.type !== "text") {
  16252. newChildren.push(child);
  16253. continue;
  16254. }
  16255. var ParseSourceSpan = child.sourceSpan.constructor;
  16256. var startSourceSpan = child.sourceSpan.start;
  16257. var endSourceSpan = null;
  16258. var components = child.value.split(interpolationRegex);
  16259. for (var i = 0; i < components.length; i++, startSourceSpan = endSourceSpan) {
  16260. var value = components[i];
  16261. if (i % 2 === 0) {
  16262. endSourceSpan = startSourceSpan.moveBy(value.length);
  16263. if (value.length !== 0) {
  16264. newChildren.push({
  16265. type: "text",
  16266. value: value,
  16267. sourceSpan: new ParseSourceSpan(startSourceSpan, endSourceSpan)
  16268. });
  16269. }
  16270. continue;
  16271. }
  16272. endSourceSpan = startSourceSpan.moveBy(value.length + 4); // `{{` + `}}`
  16273. newChildren.push({
  16274. type: "interpolation",
  16275. sourceSpan: new ParseSourceSpan(startSourceSpan, endSourceSpan),
  16276. children: value.length === 0 ? [] : [{
  16277. type: "text",
  16278. value: value,
  16279. sourceSpan: new ParseSourceSpan(startSourceSpan.moveBy(2), endSourceSpan.moveBy(-2))
  16280. }]
  16281. });
  16282. }
  16283. }
  16284. } catch (err) {
  16285. _didIteratorError = true;
  16286. _iteratorError = err;
  16287. } finally {
  16288. try {
  16289. if (!_iteratorNormalCompletion && _iterator.return != null) {
  16290. _iterator.return();
  16291. }
  16292. } finally {
  16293. if (_didIteratorError) {
  16294. throw _iteratorError;
  16295. }
  16296. }
  16297. }
  16298. return node.clone({
  16299. children: newChildren
  16300. });
  16301. });
  16302. }
  16303. /**
  16304. * - add `hasLeadingSpaces` field
  16305. * - add `hasTrailingSpaces` field
  16306. * - add `hasDanglingSpaces` field for parent nodes
  16307. * - add `isWhitespaceSensitive`, `isIndentationSensitive` field for text nodes
  16308. * - remove insensitive whitespaces
  16309. */
  16310. function extractWhitespaces(ast
  16311. /*, options*/
  16312. ) {
  16313. var TYPE_WHITESPACE = "whitespace";
  16314. return ast.map(function (node) {
  16315. if (!node.children) {
  16316. return node;
  16317. }
  16318. if (node.children.length === 0 || node.children.length === 1 && node.children[0].type === "text" && node.children[0].value.trim().length === 0) {
  16319. return node.clone({
  16320. children: [],
  16321. hasDanglingSpaces: node.children.length !== 0
  16322. });
  16323. }
  16324. var isWhitespaceSensitive = isWhitespaceSensitiveNode$1(node);
  16325. var isIndentationSensitive = isIndentationSensitiveNode$1(node);
  16326. return node.clone({
  16327. isWhitespaceSensitive: isWhitespaceSensitive,
  16328. isIndentationSensitive: isIndentationSensitive,
  16329. children: node.children // extract whitespace nodes
  16330. .reduce(function (newChildren, child) {
  16331. if (child.type !== "text" || isWhitespaceSensitive) {
  16332. return newChildren.concat(child);
  16333. }
  16334. var localChildren = [];
  16335. var _child$value$match = child.value.match(/^(\s*)([\s\S]*?)(\s*)$/),
  16336. _child$value$match2 = _slicedToArray(_child$value$match, 4),
  16337. leadingSpaces = _child$value$match2[1],
  16338. text = _child$value$match2[2],
  16339. trailingSpaces = _child$value$match2[3];
  16340. if (leadingSpaces) {
  16341. localChildren.push({
  16342. type: TYPE_WHITESPACE
  16343. });
  16344. }
  16345. var ParseSourceSpan = child.sourceSpan.constructor;
  16346. if (text) {
  16347. localChildren.push({
  16348. type: "text",
  16349. value: text,
  16350. sourceSpan: new ParseSourceSpan(child.sourceSpan.start.moveBy(leadingSpaces.length), child.sourceSpan.end.moveBy(-trailingSpaces.length))
  16351. });
  16352. }
  16353. if (trailingSpaces) {
  16354. localChildren.push({
  16355. type: TYPE_WHITESPACE
  16356. });
  16357. }
  16358. return newChildren.concat(localChildren);
  16359. }, []) // set hasLeadingSpaces/hasTrailingSpaces and filter whitespace nodes
  16360. .reduce(function (newChildren, child, i, children) {
  16361. if (child.type === TYPE_WHITESPACE) {
  16362. return newChildren;
  16363. }
  16364. var hasLeadingSpaces = i !== 0 && children[i - 1].type === TYPE_WHITESPACE;
  16365. var hasTrailingSpaces = i !== children.length - 1 && children[i + 1].type === TYPE_WHITESPACE;
  16366. return newChildren.concat(Object.assign({}, child, {
  16367. hasLeadingSpaces: hasLeadingSpaces,
  16368. hasTrailingSpaces: hasTrailingSpaces
  16369. }));
  16370. }, [])
  16371. });
  16372. });
  16373. }
  16374. function addIsSelfClosing(ast
  16375. /*, options */
  16376. ) {
  16377. return ast.map(function (node) {
  16378. return Object.assign(node, {
  16379. isSelfClosing: !node.children || node.type === "element" && (node.tagDefinition.isVoid || // self-closing
  16380. node.startSourceSpan === node.endSourceSpan)
  16381. });
  16382. });
  16383. }
  16384. function addHasHtmComponentClosingTag(ast, options) {
  16385. return ast.map(function (node) {
  16386. return node.type !== "element" ? node : Object.assign(node, {
  16387. hasHtmComponentClosingTag: node.endSourceSpan && /^<\s*\/\s*\/\s*>$/.test(options.originalText.slice(node.endSourceSpan.start.offset, node.endSourceSpan.end.offset))
  16388. });
  16389. });
  16390. }
  16391. function addCssDisplay(ast, options) {
  16392. return ast.map(function (node) {
  16393. return Object.assign(node, {
  16394. cssDisplay: getNodeCssStyleDisplay$1(node, options)
  16395. });
  16396. });
  16397. }
  16398. /**
  16399. * - add `isLeadingSpaceSensitive` field
  16400. * - add `isTrailingSpaceSensitive` field
  16401. * - add `isDanglingSpaceSensitive` field for parent nodes
  16402. */
  16403. function addIsSpaceSensitive(ast
  16404. /*, options */
  16405. ) {
  16406. return ast.map(function (node) {
  16407. if (!node.children) {
  16408. return node;
  16409. }
  16410. if (node.children.length === 0) {
  16411. return node.clone({
  16412. isDanglingSpaceSensitive: isDanglingSpaceSensitiveNode$1(node)
  16413. });
  16414. }
  16415. return node.clone({
  16416. children: node.children.map(function (child) {
  16417. return Object.assign({}, child, {
  16418. isLeadingSpaceSensitive: isLeadingSpaceSensitiveNode$1(child),
  16419. isTrailingSpaceSensitive: isTrailingSpaceSensitiveNode$1(child)
  16420. });
  16421. }).map(function (child, index, children) {
  16422. return Object.assign({}, child, {
  16423. isLeadingSpaceSensitive: index === 0 ? child.isLeadingSpaceSensitive : children[index - 1].isTrailingSpaceSensitive && child.isLeadingSpaceSensitive,
  16424. isTrailingSpaceSensitive: index === children.length - 1 ? child.isTrailingSpaceSensitive : children[index + 1].isLeadingSpaceSensitive && child.isTrailingSpaceSensitive
  16425. });
  16426. })
  16427. });
  16428. });
  16429. }
  16430. var preprocess_1 = preprocess;
  16431. function hasPragma$3(text) {
  16432. return /^\s*<!--\s*@(format|prettier)\s*-->/.test(text);
  16433. }
  16434. function insertPragma$6(text) {
  16435. return "<!-- @format -->\n\n" + text.replace(/^\s*\n/, "");
  16436. }
  16437. var pragma$6 = {
  16438. hasPragma: hasPragma$3,
  16439. insertPragma: insertPragma$6
  16440. };
  16441. var _require$$0$builders$4 = doc.builders;
  16442. var concat$9 = _require$$0$builders$4.concat;
  16443. var group$9 = _require$$0$builders$4.group;
  16444. /**
  16445. * v-for="... in ..."
  16446. * v-for="... of ..."
  16447. * v-for="(..., ...) in ..."
  16448. * v-for="(..., ...) of ..."
  16449. */
  16450. function printVueFor$1(value, textToDoc) {
  16451. var _parseVueFor = parseVueFor(value),
  16452. left = _parseVueFor.left,
  16453. operator = _parseVueFor.operator,
  16454. right = _parseVueFor.right;
  16455. return concat$9([group$9(textToDoc("function _(".concat(left, ") {}"), {
  16456. parser: "babel",
  16457. __isVueForBindingLeft: true
  16458. })), " ", operator, " ", textToDoc(right, {
  16459. parser: "__js_expression"
  16460. })]);
  16461. } // modified from https://github.com/vuejs/vue/blob/v2.5.17/src/compiler/parser/index.js#L370-L387
  16462. function parseVueFor(value) {
  16463. var forAliasRE = /([^]*?)\s+(in|of)\s+([^]*)/;
  16464. var forIteratorRE = /,([^,}\]]*)(?:,([^,}\]]*))?$/;
  16465. var stripParensRE = /^\(|\)$/g;
  16466. var inMatch = value.match(forAliasRE);
  16467. if (!inMatch) {
  16468. return;
  16469. }
  16470. var res = {};
  16471. res.for = inMatch[3].trim();
  16472. var alias = inMatch[1].trim().replace(stripParensRE, "");
  16473. var iteratorMatch = alias.match(forIteratorRE);
  16474. if (iteratorMatch) {
  16475. res.alias = alias.replace(forIteratorRE, "");
  16476. res.iterator1 = iteratorMatch[1].trim();
  16477. if (iteratorMatch[2]) {
  16478. res.iterator2 = iteratorMatch[2].trim();
  16479. }
  16480. } else {
  16481. res.alias = alias;
  16482. }
  16483. return {
  16484. left: "".concat([res.alias, res.iterator1, res.iterator2].filter(Boolean).join(",")),
  16485. operator: inMatch[2],
  16486. right: res.for
  16487. };
  16488. }
  16489. function printVueSlotScope$1(value, textToDoc) {
  16490. return textToDoc("function _(".concat(value, ") {}"), {
  16491. parser: "babel",
  16492. __isVueSlotScope: true
  16493. });
  16494. }
  16495. function isVueEventBindingExpression$1(eventBindingValue) {
  16496. // https://github.com/vuejs/vue/blob/v2.5.17/src/compiler/codegen/events.js#L3-L4
  16497. // arrow function or anonymous function
  16498. var fnExpRE = /^([\w$_]+|\([^)]*?\))\s*=>|^function\s*\(/; // simple member expression chain (a, a.b, a['b'], a["b"], a[0], a[b])
  16499. var simplePathRE = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*$/; // https://github.com/vuejs/vue/blob/v2.5.17/src/compiler/helpers.js#L104
  16500. var value = eventBindingValue.trim();
  16501. return fnExpRE.test(value) || simplePathRE.test(value);
  16502. }
  16503. var syntaxVue = {
  16504. isVueEventBindingExpression: isVueEventBindingExpression$1,
  16505. printVueFor: printVueFor$1,
  16506. printVueSlotScope: printVueSlotScope$1
  16507. };
  16508. var parseSrcset = createCommonjsModule(function (module) {
  16509. /**
  16510. * Srcset Parser
  16511. *
  16512. * By Alex Bell | MIT License
  16513. *
  16514. * JS Parser for the string value that appears in markup <img srcset="here">
  16515. *
  16516. * @returns Array [{url: _, d: _, w: _, h:_}, ...]
  16517. *
  16518. * Based super duper closely on the reference algorithm at:
  16519. * https://html.spec.whatwg.org/multipage/embedded-content.html#parse-a-srcset-attribute
  16520. *
  16521. * Most comments are copied in directly from the spec
  16522. * (except for comments in parens).
  16523. */
  16524. (function (root, factory) {
  16525. if (typeof undefined === 'function' && undefined.amd) {
  16526. // AMD. Register as an anonymous module.
  16527. undefined([], factory);
  16528. } else if ('object' === 'object' && module.exports) {
  16529. // Node. Does not work with strict CommonJS, but
  16530. // only CommonJS-like environments that support module.exports,
  16531. // like Node.
  16532. module.exports = factory();
  16533. } else {
  16534. // Browser globals (root is window)
  16535. root.parseSrcset = factory();
  16536. }
  16537. })(commonjsGlobal, function () {
  16538. // 1. Let input be the value passed to this algorithm.
  16539. return function (input, options) {
  16540. var logger = options && options.logger || console; // UTILITY FUNCTIONS
  16541. // Manual is faster than RegEx
  16542. // http://bjorn.tipling.com/state-and-regular-expressions-in-javascript
  16543. // http://jsperf.com/whitespace-character/5
  16544. function isSpace(c) {
  16545. return c === " " || // space
  16546. c === "\t" || // horizontal tab
  16547. c === "\n" || // new line
  16548. c === "\f" || // form feed
  16549. c === "\r"; // carriage return
  16550. }
  16551. function collectCharacters(regEx) {
  16552. var chars,
  16553. match = regEx.exec(input.substring(pos));
  16554. if (match) {
  16555. chars = match[0];
  16556. pos += chars.length;
  16557. return chars;
  16558. }
  16559. }
  16560. var inputLength = input.length,
  16561. // (Don't use \s, to avoid matching non-breaking space)
  16562. regexLeadingSpaces = /^[ \t\n\r\u000c]+/,
  16563. regexLeadingCommasOrSpaces = /^[, \t\n\r\u000c]+/,
  16564. regexLeadingNotSpaces = /^[^ \t\n\r\u000c]+/,
  16565. regexTrailingCommas = /[,]+$/,
  16566. regexNonNegativeInteger = /^\d+$/,
  16567. // ( Positive or negative or unsigned integers or decimals, without or without exponents.
  16568. // Must include at least one digit.
  16569. // According to spec tests any decimal point must be followed by a digit.
  16570. // No leading plus sign is allowed.)
  16571. // https://html.spec.whatwg.org/multipage/infrastructure.html#valid-floating-point-number
  16572. regexFloatingPoint = /^-?(?:[0-9]+|[0-9]*\.[0-9]+)(?:[eE][+-]?[0-9]+)?$/,
  16573. url,
  16574. descriptors,
  16575. currentDescriptor,
  16576. state,
  16577. c,
  16578. // 2. Let position be a pointer into input, initially pointing at the start
  16579. // of the string.
  16580. pos = 0,
  16581. // 3. Let candidates be an initially empty source set.
  16582. candidates = []; // 4. Splitting loop: Collect a sequence of characters that are space
  16583. // characters or U+002C COMMA characters. If any U+002C COMMA characters
  16584. // were collected, that is a parse error.
  16585. while (true) {
  16586. collectCharacters(regexLeadingCommasOrSpaces); // 5. If position is past the end of input, return candidates and abort these steps.
  16587. if (pos >= inputLength) {
  16588. return candidates; // (we're done, this is the sole return path)
  16589. } // 6. Collect a sequence of characters that are not space characters,
  16590. // and let that be url.
  16591. url = collectCharacters(regexLeadingNotSpaces); // 7. Let descriptors be a new empty list.
  16592. descriptors = []; // 8. If url ends with a U+002C COMMA character (,), follow these substeps:
  16593. // (1). Remove all trailing U+002C COMMA characters from url. If this removed
  16594. // more than one character, that is a parse error.
  16595. if (url.slice(-1) === ",") {
  16596. url = url.replace(regexTrailingCommas, ""); // (Jump ahead to step 9 to skip tokenization and just push the candidate).
  16597. parseDescriptors(); // Otherwise, follow these substeps:
  16598. } else {
  16599. tokenize();
  16600. } // (close else of step 8)
  16601. // 16. Return to the step labeled splitting loop.
  16602. } // (Close of big while loop.)
  16603. /**
  16604. * Tokenizes descriptor properties prior to parsing
  16605. * Returns undefined.
  16606. */
  16607. function tokenize() {
  16608. // 8.1. Descriptor tokeniser: Skip whitespace
  16609. collectCharacters(regexLeadingSpaces); // 8.2. Let current descriptor be the empty string.
  16610. currentDescriptor = ""; // 8.3. Let state be in descriptor.
  16611. state = "in descriptor";
  16612. while (true) {
  16613. // 8.4. Let c be the character at position.
  16614. c = input.charAt(pos); // Do the following depending on the value of state.
  16615. // For the purpose of this step, "EOF" is a special character representing
  16616. // that position is past the end of input.
  16617. // In descriptor
  16618. if (state === "in descriptor") {
  16619. // Do the following, depending on the value of c:
  16620. // Space character
  16621. // If current descriptor is not empty, append current descriptor to
  16622. // descriptors and let current descriptor be the empty string.
  16623. // Set state to after descriptor.
  16624. if (isSpace(c)) {
  16625. if (currentDescriptor) {
  16626. descriptors.push(currentDescriptor);
  16627. currentDescriptor = "";
  16628. state = "after descriptor";
  16629. } // U+002C COMMA (,)
  16630. // Advance position to the next character in input. If current descriptor
  16631. // is not empty, append current descriptor to descriptors. Jump to the step
  16632. // labeled descriptor parser.
  16633. } else if (c === ",") {
  16634. pos += 1;
  16635. if (currentDescriptor) {
  16636. descriptors.push(currentDescriptor);
  16637. }
  16638. parseDescriptors();
  16639. return; // U+0028 LEFT PARENTHESIS (()
  16640. // Append c to current descriptor. Set state to in parens.
  16641. } else if (c === "(") {
  16642. currentDescriptor = currentDescriptor + c;
  16643. state = "in parens"; // EOF
  16644. // If current descriptor is not empty, append current descriptor to
  16645. // descriptors. Jump to the step labeled descriptor parser.
  16646. } else if (c === "") {
  16647. if (currentDescriptor) {
  16648. descriptors.push(currentDescriptor);
  16649. }
  16650. parseDescriptors();
  16651. return; // Anything else
  16652. // Append c to current descriptor.
  16653. } else {
  16654. currentDescriptor = currentDescriptor + c;
  16655. } // (end "in descriptor"
  16656. // In parens
  16657. } else if (state === "in parens") {
  16658. // U+0029 RIGHT PARENTHESIS ())
  16659. // Append c to current descriptor. Set state to in descriptor.
  16660. if (c === ")") {
  16661. currentDescriptor = currentDescriptor + c;
  16662. state = "in descriptor"; // EOF
  16663. // Append current descriptor to descriptors. Jump to the step labeled
  16664. // descriptor parser.
  16665. } else if (c === "") {
  16666. descriptors.push(currentDescriptor);
  16667. parseDescriptors();
  16668. return; // Anything else
  16669. // Append c to current descriptor.
  16670. } else {
  16671. currentDescriptor = currentDescriptor + c;
  16672. } // After descriptor
  16673. } else if (state === "after descriptor") {
  16674. // Do the following, depending on the value of c:
  16675. // Space character: Stay in this state.
  16676. if (isSpace(c)) {// EOF: Jump to the step labeled descriptor parser.
  16677. } else if (c === "") {
  16678. parseDescriptors();
  16679. return; // Anything else
  16680. // Set state to in descriptor. Set position to the previous character in input.
  16681. } else {
  16682. state = "in descriptor";
  16683. pos -= 1;
  16684. }
  16685. } // Advance position to the next character in input.
  16686. pos += 1; // Repeat this step.
  16687. } // (close while true loop)
  16688. }
  16689. /**
  16690. * Adds descriptor properties to a candidate, pushes to the candidates array
  16691. * @return undefined
  16692. */
  16693. // Declared outside of the while loop so that it's only created once.
  16694. function parseDescriptors() {
  16695. // 9. Descriptor parser: Let error be no.
  16696. var pError = false,
  16697. // 10. Let width be absent.
  16698. // 11. Let density be absent.
  16699. // 12. Let future-compat-h be absent. (We're implementing it now as h)
  16700. w,
  16701. d,
  16702. h,
  16703. i,
  16704. candidate = {},
  16705. desc,
  16706. lastChar,
  16707. value,
  16708. intVal,
  16709. floatVal; // 13. For each descriptor in descriptors, run the appropriate set of steps
  16710. // from the following list:
  16711. for (i = 0; i < descriptors.length; i++) {
  16712. desc = descriptors[i];
  16713. lastChar = desc[desc.length - 1];
  16714. value = desc.substring(0, desc.length - 1);
  16715. intVal = parseInt(value, 10);
  16716. floatVal = parseFloat(value); // If the descriptor consists of a valid non-negative integer followed by
  16717. // a U+0077 LATIN SMALL LETTER W character
  16718. if (regexNonNegativeInteger.test(value) && lastChar === "w") {
  16719. // If width and density are not both absent, then let error be yes.
  16720. if (w || d) {
  16721. pError = true;
  16722. } // Apply the rules for parsing non-negative integers to the descriptor.
  16723. // If the result is zero, let error be yes.
  16724. // Otherwise, let width be the result.
  16725. if (intVal === 0) {
  16726. pError = true;
  16727. } else {
  16728. w = intVal;
  16729. } // If the descriptor consists of a valid floating-point number followed by
  16730. // a U+0078 LATIN SMALL LETTER X character
  16731. } else if (regexFloatingPoint.test(value) && lastChar === "x") {
  16732. // If width, density and future-compat-h are not all absent, then let error
  16733. // be yes.
  16734. if (w || d || h) {
  16735. pError = true;
  16736. } // Apply the rules for parsing floating-point number values to the descriptor.
  16737. // If the result is less than zero, let error be yes. Otherwise, let density
  16738. // be the result.
  16739. if (floatVal < 0) {
  16740. pError = true;
  16741. } else {
  16742. d = floatVal;
  16743. } // If the descriptor consists of a valid non-negative integer followed by
  16744. // a U+0068 LATIN SMALL LETTER H character
  16745. } else if (regexNonNegativeInteger.test(value) && lastChar === "h") {
  16746. // If height and density are not both absent, then let error be yes.
  16747. if (h || d) {
  16748. pError = true;
  16749. } // Apply the rules for parsing non-negative integers to the descriptor.
  16750. // If the result is zero, let error be yes. Otherwise, let future-compat-h
  16751. // be the result.
  16752. if (intVal === 0) {
  16753. pError = true;
  16754. } else {
  16755. h = intVal;
  16756. } // Anything else, Let error be yes.
  16757. } else {
  16758. pError = true;
  16759. }
  16760. } // (close step 13 for loop)
  16761. // 15. If error is still no, then append a new image source to candidates whose
  16762. // URL is url, associated with a width width if not absent and a pixel
  16763. // density density if not absent. Otherwise, there is a parse error.
  16764. if (!pError) {
  16765. candidate.url = url;
  16766. if (w) {
  16767. candidate.w = w;
  16768. }
  16769. if (d) {
  16770. candidate.d = d;
  16771. }
  16772. if (h) {
  16773. candidate.h = h;
  16774. }
  16775. candidates.push(candidate);
  16776. } else if (logger && logger.error) {
  16777. logger.error("Invalid srcset descriptor found in '" + input + "' at '" + desc + "'.");
  16778. }
  16779. } // (close parseDescriptors fn)
  16780. };
  16781. });
  16782. });
  16783. var _require$$0$builders$5 = doc.builders;
  16784. var concat$10 = _require$$0$builders$5.concat;
  16785. var ifBreak$5 = _require$$0$builders$5.ifBreak;
  16786. var join$6 = _require$$0$builders$5.join;
  16787. var line$7 = _require$$0$builders$5.line;
  16788. function printImgSrcset$1(value) {
  16789. var srcset = parseSrcset(value, {
  16790. logger: {
  16791. error: function error(message) {
  16792. throw new Error(message);
  16793. }
  16794. }
  16795. });
  16796. var hasW = srcset.some(function (src) {
  16797. return src.w;
  16798. });
  16799. var hasH = srcset.some(function (src) {
  16800. return src.h;
  16801. });
  16802. var hasX = srcset.some(function (src) {
  16803. return src.d;
  16804. });
  16805. if (hasW + hasH + hasX !== 1) {
  16806. throw new Error("Mixed descriptor in srcset is not supported");
  16807. }
  16808. var key = hasW ? "w" : hasH ? "h" : "d";
  16809. var unit = hasW ? "w" : hasH ? "h" : "x";
  16810. var getMax = function getMax(values) {
  16811. return Math.max.apply(Math, values);
  16812. };
  16813. var urls = srcset.map(function (src) {
  16814. return src.url;
  16815. });
  16816. var maxUrlLength = getMax(urls.map(function (url) {
  16817. return url.length;
  16818. }));
  16819. var descriptors = srcset.map(function (src) {
  16820. return src[key];
  16821. }).map(function (descriptor) {
  16822. return descriptor ? descriptor.toString() : "";
  16823. });
  16824. var descriptorLeftLengths = descriptors.map(function (descriptor) {
  16825. var index = descriptor.indexOf(".");
  16826. return index === -1 ? descriptor.length : index;
  16827. });
  16828. var maxDescriptorLeftLength = getMax(descriptorLeftLengths);
  16829. return join$6(concat$10([",", line$7]), urls.map(function (url, index) {
  16830. var parts = [url];
  16831. var descriptor = descriptors[index];
  16832. if (descriptor) {
  16833. var urlPadding = maxUrlLength - url.length + 1;
  16834. var descriptorPadding = maxDescriptorLeftLength - descriptorLeftLengths[index];
  16835. var alignment = " ".repeat(urlPadding + descriptorPadding);
  16836. parts.push(ifBreak$5(alignment, " "), descriptor + unit);
  16837. }
  16838. return concat$10(parts);
  16839. }));
  16840. }
  16841. var syntaxAttribute = {
  16842. printImgSrcset: printImgSrcset$1
  16843. };
  16844. var builders = doc.builders;
  16845. var _require$$0$utils = doc.utils;
  16846. var stripTrailingHardline$1 = _require$$0$utils.stripTrailingHardline;
  16847. var mapDoc$4 = _require$$0$utils.mapDoc;
  16848. var breakParent$2 = builders.breakParent;
  16849. var dedentToRoot$1 = builders.dedentToRoot;
  16850. var fill$3 = builders.fill;
  16851. var group$8 = builders.group;
  16852. var hardline$7 = builders.hardline;
  16853. var ifBreak$4 = builders.ifBreak;
  16854. var indent$5 = builders.indent;
  16855. var join$5 = builders.join;
  16856. var line$6 = builders.line;
  16857. var literalline$2 = builders.literalline;
  16858. var markAsRoot$2 = builders.markAsRoot;
  16859. var softline$4 = builders.softline;
  16860. var countChars = utils$6.countChars;
  16861. var countParents = utils$6.countParents;
  16862. var dedentString = utils$6.dedentString;
  16863. var forceBreakChildren = utils$6.forceBreakChildren;
  16864. var forceBreakContent = utils$6.forceBreakContent;
  16865. var forceNextEmptyLine = utils$6.forceNextEmptyLine;
  16866. var getLastDescendant = utils$6.getLastDescendant;
  16867. var getPrettierIgnoreAttributeCommentData = utils$6.getPrettierIgnoreAttributeCommentData;
  16868. var hasPrettierIgnore = utils$6.hasPrettierIgnore;
  16869. var inferScriptParser = utils$6.inferScriptParser;
  16870. var isScriptLikeTag = utils$6.isScriptLikeTag;
  16871. var isTextLikeNode = utils$6.isTextLikeNode;
  16872. var normalizeParts = utils$6.normalizeParts;
  16873. var preferHardlineAsLeadingSpaces = utils$6.preferHardlineAsLeadingSpaces;
  16874. var shouldNotPrintClosingTag = utils$6.shouldNotPrintClosingTag;
  16875. var shouldPreserveContent = utils$6.shouldPreserveContent;
  16876. var unescapeQuoteEntities = utils$6.unescapeQuoteEntities;
  16877. var replaceEndOfLineWith$1 = util.replaceEndOfLineWith;
  16878. var insertPragma$5 = pragma$6.insertPragma;
  16879. var printVueFor = syntaxVue.printVueFor;
  16880. var printVueSlotScope = syntaxVue.printVueSlotScope;
  16881. var isVueEventBindingExpression = syntaxVue.isVueEventBindingExpression;
  16882. var printImgSrcset = syntaxAttribute.printImgSrcset;
  16883. function concat$8(parts) {
  16884. var newParts = normalizeParts(parts);
  16885. return newParts.length === 0 ? "" : newParts.length === 1 ? newParts[0] : builders.concat(newParts);
  16886. }
  16887. function embed$2(path, print, textToDoc, options) {
  16888. var node = path.getValue();
  16889. switch (node.type) {
  16890. case "text":
  16891. {
  16892. if (isScriptLikeTag(node.parent)) {
  16893. var parser = inferScriptParser(node.parent);
  16894. if (parser) {
  16895. var value = parser === "markdown" ? dedentString(node.value.replace(/^[^\S\n]*?\n/, "")) : node.value;
  16896. return builders.concat([concat$8([breakParent$2, printOpeningTagPrefix(node, options), stripTrailingHardline$1(textToDoc(value, {
  16897. parser: parser
  16898. })), printClosingTagSuffix(node, options)])]);
  16899. }
  16900. } else if (node.parent.type === "interpolation") {
  16901. return concat$8([indent$5(concat$8([line$6, textToDoc(node.value, Object.assign({
  16902. __isInHtmlInterpolation: true // to avoid unexpected `}}`
  16903. }, options.parser === "angular" ? {
  16904. parser: "__ng_interpolation",
  16905. trailingComma: "none"
  16906. } : options.parser === "vue" ? {
  16907. parser: "__vue_expression"
  16908. } : {
  16909. parser: "__js_expression"
  16910. }))])), node.parent.next && needsToBorrowPrevClosingTagEndMarker(node.parent.next) ? " " : line$6]);
  16911. }
  16912. break;
  16913. }
  16914. case "attribute":
  16915. {
  16916. if (!node.value) {
  16917. break;
  16918. } // lit-html: html`<my-element obj=${obj}></my-element>`
  16919. if (/^PRETTIER_HTML_PLACEHOLDER_\d+_IN_JS$/.test(options.originalText.slice(node.valueSpan.start.offset, node.valueSpan.end.offset))) {
  16920. return concat$8([node.rawName, "=", node.value]);
  16921. }
  16922. var embeddedAttributeValueDoc = printEmbeddedAttributeValue(node, function (code, opts) {
  16923. return (// strictly prefer single quote to avoid unnecessary html entity escape
  16924. textToDoc(code, Object.assign({
  16925. __isInHtmlAttribute: true
  16926. }, opts))
  16927. );
  16928. }, options);
  16929. if (embeddedAttributeValueDoc) {
  16930. return concat$8([node.rawName, '="', group$8(mapDoc$4(embeddedAttributeValueDoc, function (doc$$2) {
  16931. return typeof doc$$2 === "string" ? doc$$2.replace(/"/g, "&quot;") : doc$$2;
  16932. })), '"']);
  16933. }
  16934. break;
  16935. }
  16936. case "yaml":
  16937. return markAsRoot$2(concat$8(["---", hardline$7, node.value.trim().length === 0 ? "" : textToDoc(node.value, {
  16938. parser: "yaml"
  16939. }), "---"]));
  16940. }
  16941. }
  16942. function genericPrint$2(path, options, print) {
  16943. var node = path.getValue();
  16944. switch (node.type) {
  16945. case "root":
  16946. // use original concat to not break stripTrailingHardline
  16947. return builders.concat([group$8(printChildren(path, options, print)), hardline$7]);
  16948. case "element":
  16949. case "ieConditionalComment":
  16950. {
  16951. /**
  16952. * do not break:
  16953. *
  16954. * <div>{{
  16955. * ~
  16956. * interpolation
  16957. * }}</div>
  16958. * ~
  16959. *
  16960. * exception: break if the opening tag breaks
  16961. *
  16962. * <div
  16963. * long
  16964. * ~
  16965. * >{{
  16966. * interpolation
  16967. * }}</div
  16968. * ~
  16969. * >
  16970. */
  16971. var shouldHugContent = node.children.length === 1 && node.firstChild.type === "interpolation" && node.firstChild.isLeadingSpaceSensitive && !node.firstChild.hasLeadingSpaces && node.lastChild.isTrailingSpaceSensitive && !node.lastChild.hasTrailingSpaces;
  16972. var attrGroupId = Symbol("element-attr-group-id");
  16973. return concat$8([group$8(concat$8([group$8(printOpeningTag(path, options, print), {
  16974. id: attrGroupId
  16975. }), node.children.length === 0 ? node.hasDanglingSpaces && node.isDanglingSpaceSensitive ? line$6 : "" : concat$8([forceBreakContent(node) ? breakParent$2 : "", function (childrenDoc) {
  16976. return shouldHugContent ? ifBreak$4(indent$5(childrenDoc), childrenDoc, {
  16977. groupId: attrGroupId
  16978. }) : isScriptLikeTag(node) && node.parent.type === "root" && options.parser === "vue" ? childrenDoc : indent$5(childrenDoc);
  16979. }(concat$8([shouldHugContent ? ifBreak$4(softline$4, "", {
  16980. groupId: attrGroupId
  16981. }) : node.firstChild.hasLeadingSpaces && node.firstChild.isLeadingSpaceSensitive ? line$6 : node.firstChild.type === "text" && node.isWhitespaceSensitive && node.isIndentationSensitive ? dedentToRoot$1(softline$4) : softline$4, printChildren(path, options, print)])), (node.next ? needsToBorrowPrevClosingTagEndMarker(node.next) : needsToBorrowLastChildClosingTagEndMarker(node.parent)) ? node.lastChild.hasTrailingSpaces && node.lastChild.isTrailingSpaceSensitive ? " " : "" : shouldHugContent ? ifBreak$4(softline$4, "", {
  16982. groupId: attrGroupId
  16983. }) : node.lastChild.hasTrailingSpaces && node.lastChild.isTrailingSpaceSensitive ? line$6 : (node.lastChild.type === "comment" || node.lastChild.type === "text" && node.isWhitespaceSensitive && node.isIndentationSensitive) && new RegExp("\\n\\s{".concat(options.tabWidth * countParents(path, function (n) {
  16984. return n.parent && n.parent.type !== "root";
  16985. }), "}$")).test(node.lastChild.value) ?
  16986. /**
  16987. * <div>
  16988. * <pre>
  16989. * something
  16990. * </pre>
  16991. * ~
  16992. * </div>
  16993. */
  16994. "" : softline$4])])), printClosingTag(node, options)]);
  16995. }
  16996. case "ieConditionalStartComment":
  16997. case "ieConditionalEndComment":
  16998. return concat$8([printOpeningTagStart(node), printClosingTagEnd(node)]);
  16999. case "interpolation":
  17000. return concat$8([printOpeningTagStart(node, options), concat$8(path.map(print, "children")), printClosingTagEnd(node, options)]);
  17001. case "text":
  17002. {
  17003. if (node.parent.type === "interpolation") {
  17004. // replace the trailing literalline with hardline for better readability
  17005. var trailingNewlineRegex = /\n[^\S\n]*?$/;
  17006. var hasTrailingNewline = trailingNewlineRegex.test(node.value);
  17007. var value = hasTrailingNewline ? node.value.replace(trailingNewlineRegex, "") : node.value;
  17008. return concat$8([concat$8(replaceEndOfLineWith$1(value, literalline$2)), hasTrailingNewline ? hardline$7 : ""]);
  17009. }
  17010. return fill$3(normalizeParts([].concat(printOpeningTagPrefix(node, options), getTextValueParts(node), printClosingTagSuffix(node, options))));
  17011. }
  17012. case "docType":
  17013. return concat$8([group$8(concat$8([printOpeningTagStart(node, options), " ", node.value.replace(/^html\b/i, "html").replace(/\s+/g, " ")])), printClosingTagEnd(node, options)]);
  17014. case "comment":
  17015. {
  17016. return concat$8([printOpeningTagPrefix(node, options), concat$8(replaceEndOfLineWith$1(options.originalText.slice(options.locStart(node), options.locEnd(node)), literalline$2)), printClosingTagSuffix(node, options)]);
  17017. }
  17018. case "attribute":
  17019. {
  17020. if (node.value === null) {
  17021. return node.rawName;
  17022. }
  17023. var _value = unescapeQuoteEntities(node.value);
  17024. var singleQuoteCount = countChars(_value, "'");
  17025. var doubleQuoteCount = countChars(_value, '"');
  17026. var quote = singleQuoteCount < doubleQuoteCount ? "'" : '"';
  17027. return concat$8([node.rawName, concat$8(["=", quote, concat$8(replaceEndOfLineWith$1(quote === '"' ? _value.replace(/"/g, "&quot;") : _value.replace(/'/g, "&apos;"), literalline$2)), quote])]);
  17028. }
  17029. case "yaml":
  17030. case "toml":
  17031. return concat$8(replaceEndOfLineWith$1(node.raw, literalline$2));
  17032. default:
  17033. throw new Error("Unexpected node type ".concat(node.type));
  17034. }
  17035. }
  17036. function printChildren(path, options, print) {
  17037. var node = path.getValue();
  17038. if (forceBreakChildren(node)) {
  17039. return concat$8([breakParent$2, concat$8(path.map(function (childPath) {
  17040. var childNode = childPath.getValue();
  17041. var prevBetweenLine = !childNode.prev ? "" : printBetweenLine(childNode.prev, childNode);
  17042. return concat$8([!prevBetweenLine ? "" : concat$8([prevBetweenLine, forceNextEmptyLine(childNode.prev) ? hardline$7 : ""]), printChild(childPath)]);
  17043. }, "children"))]);
  17044. }
  17045. var groupIds = node.children.map(function () {
  17046. return Symbol("");
  17047. });
  17048. return concat$8(path.map(function (childPath, childIndex) {
  17049. var childNode = childPath.getValue();
  17050. if (isTextLikeNode(childNode)) {
  17051. if (childNode.prev && isTextLikeNode(childNode.prev)) {
  17052. var _prevBetweenLine = printBetweenLine(childNode.prev, childNode);
  17053. if (_prevBetweenLine) {
  17054. if (forceNextEmptyLine(childNode.prev)) {
  17055. return concat$8([hardline$7, hardline$7, printChild(childPath)]);
  17056. }
  17057. return concat$8([_prevBetweenLine, printChild(childPath)]);
  17058. }
  17059. }
  17060. return printChild(childPath);
  17061. }
  17062. var prevParts = [];
  17063. var leadingParts = [];
  17064. var trailingParts = [];
  17065. var nextParts = [];
  17066. var prevBetweenLine = childNode.prev ? printBetweenLine(childNode.prev, childNode) : "";
  17067. var nextBetweenLine = childNode.next ? printBetweenLine(childNode, childNode.next) : "";
  17068. if (prevBetweenLine) {
  17069. if (forceNextEmptyLine(childNode.prev)) {
  17070. prevParts.push(hardline$7, hardline$7);
  17071. } else if (prevBetweenLine === hardline$7) {
  17072. prevParts.push(hardline$7);
  17073. } else {
  17074. if (isTextLikeNode(childNode.prev)) {
  17075. leadingParts.push(prevBetweenLine);
  17076. } else {
  17077. leadingParts.push(ifBreak$4("", softline$4, {
  17078. groupId: groupIds[childIndex - 1]
  17079. }));
  17080. }
  17081. }
  17082. }
  17083. if (nextBetweenLine) {
  17084. if (forceNextEmptyLine(childNode)) {
  17085. if (isTextLikeNode(childNode.next)) {
  17086. nextParts.push(hardline$7, hardline$7);
  17087. }
  17088. } else if (nextBetweenLine === hardline$7) {
  17089. if (isTextLikeNode(childNode.next)) {
  17090. nextParts.push(hardline$7);
  17091. }
  17092. } else {
  17093. trailingParts.push(nextBetweenLine);
  17094. }
  17095. }
  17096. return concat$8([].concat(prevParts, group$8(concat$8([concat$8(leadingParts), group$8(concat$8([printChild(childPath), concat$8(trailingParts)]), {
  17097. id: groupIds[childIndex]
  17098. })])), nextParts));
  17099. }, "children"));
  17100. function printChild(childPath) {
  17101. var child = childPath.getValue();
  17102. if (hasPrettierIgnore(child)) {
  17103. return concat$8([].concat(printOpeningTagPrefix(child, options), replaceEndOfLineWith$1(options.originalText.slice(options.locStart(child) + (child.prev && needsToBorrowNextOpeningTagStartMarker(child.prev) ? printOpeningTagStartMarker(child).length : 0), options.locEnd(child) - (child.next && needsToBorrowPrevClosingTagEndMarker(child.next) ? printClosingTagEndMarker(child, options).length : 0)), literalline$2), printClosingTagSuffix(child, options)));
  17104. }
  17105. if (shouldPreserveContent(child, options)) {
  17106. return concat$8([].concat(printOpeningTagPrefix(child, options), group$8(printOpeningTag(childPath, options, print)), replaceEndOfLineWith$1(options.originalText.slice(child.startSourceSpan.end.offset + (child.firstChild && needsToBorrowParentOpeningTagEndMarker(child.firstChild) ? -printOpeningTagEndMarker(child).length : 0), child.endSourceSpan.start.offset + (child.lastChild && needsToBorrowParentClosingTagStartMarker(child.lastChild) ? printClosingTagStartMarker(child, options).length : needsToBorrowLastChildClosingTagEndMarker(child) ? -printClosingTagEndMarker(child.lastChild, options).length : 0)), literalline$2), printClosingTag(child, options), printClosingTagSuffix(child, options)));
  17107. }
  17108. return print(childPath);
  17109. }
  17110. function printBetweenLine(prevNode, nextNode) {
  17111. return isTextLikeNode(prevNode) && isTextLikeNode(nextNode) ? prevNode.isTrailingSpaceSensitive ? prevNode.hasTrailingSpaces ? preferHardlineAsLeadingSpaces(nextNode) ? hardline$7 : line$6 : "" : preferHardlineAsLeadingSpaces(nextNode) ? hardline$7 : softline$4 : needsToBorrowNextOpeningTagStartMarker(prevNode) && (
  17112. /**
  17113. * 123<a
  17114. * ~
  17115. * ><b>
  17116. */
  17117. nextNode.firstChild ||
  17118. /**
  17119. * 123<!--
  17120. * ~
  17121. * -->
  17122. */
  17123. nextNode.isSelfClosing ||
  17124. /**
  17125. * 123<span
  17126. * ~
  17127. * attr
  17128. */
  17129. nextNode.type === "element" && nextNode.attrs.length !== 0) ||
  17130. /**
  17131. * <img
  17132. * src="long"
  17133. * ~
  17134. * />123
  17135. */
  17136. prevNode.type === "element" && prevNode.isSelfClosing && needsToBorrowPrevClosingTagEndMarker(nextNode) ? "" : !nextNode.isLeadingSpaceSensitive || preferHardlineAsLeadingSpaces(nextNode) ||
  17137. /**
  17138. * Want to write us a letter? Use our<a
  17139. * ><b><a>mailing address</a></b></a
  17140. * ~
  17141. * >.
  17142. */
  17143. needsToBorrowPrevClosingTagEndMarker(nextNode) && prevNode.lastChild && needsToBorrowParentClosingTagStartMarker(prevNode.lastChild) && prevNode.lastChild.lastChild && needsToBorrowParentClosingTagStartMarker(prevNode.lastChild.lastChild) ? hardline$7 : nextNode.hasLeadingSpaces ? line$6 : softline$4;
  17144. }
  17145. }
  17146. function printOpeningTag(path, options, print) {
  17147. var node = path.getValue();
  17148. var forceNotToBreakAttrContent = node.type === "element" && node.fullName === "script" && node.attrs.length === 1 && node.attrs[0].fullName === "src" && node.children.length === 0;
  17149. return concat$8([printOpeningTagStart(node, options), !node.attrs || node.attrs.length === 0 ? node.isSelfClosing ?
  17150. /**
  17151. * <br />
  17152. * ^
  17153. */
  17154. " " : "" : concat$8([indent$5(concat$8([forceNotToBreakAttrContent ? " " : line$6, join$5(line$6, function (ignoreAttributeData) {
  17155. var hasPrettierIgnoreAttribute = typeof ignoreAttributeData === "boolean" ? function () {
  17156. return ignoreAttributeData;
  17157. } : Array.isArray(ignoreAttributeData) ? function (attr) {
  17158. return ignoreAttributeData.indexOf(attr.rawName) !== -1;
  17159. } : function () {
  17160. return false;
  17161. };
  17162. return path.map(function (attrPath) {
  17163. var attr = attrPath.getValue();
  17164. return hasPrettierIgnoreAttribute(attr) ? concat$8(replaceEndOfLineWith$1(options.originalText.slice(options.locStart(attr), options.locEnd(attr)), literalline$2)) : print(attrPath);
  17165. }, "attrs");
  17166. }(node.prev && node.prev.type === "comment" && getPrettierIgnoreAttributeCommentData(node.prev.value)))])),
  17167. /**
  17168. * 123<a
  17169. * attr
  17170. * ~
  17171. * >456
  17172. */
  17173. node.firstChild && needsToBorrowParentOpeningTagEndMarker(node.firstChild) ||
  17174. /**
  17175. * <span
  17176. * >123<meta
  17177. * ~
  17178. * /></span>
  17179. */
  17180. node.isSelfClosing && needsToBorrowLastChildClosingTagEndMarker(node.parent) ? "" : node.isSelfClosing ? forceNotToBreakAttrContent ? " " : line$6 : forceNotToBreakAttrContent ? "" : softline$4]), node.isSelfClosing ? "" : printOpeningTagEnd(node)]);
  17181. }
  17182. function printOpeningTagStart(node, options) {
  17183. return node.prev && needsToBorrowNextOpeningTagStartMarker(node.prev) ? "" : concat$8([printOpeningTagPrefix(node, options), printOpeningTagStartMarker(node)]);
  17184. }
  17185. function printOpeningTagEnd(node) {
  17186. return node.firstChild && needsToBorrowParentOpeningTagEndMarker(node.firstChild) ? "" : printOpeningTagEndMarker(node);
  17187. }
  17188. function printClosingTag(node, options) {
  17189. return concat$8([node.isSelfClosing ? "" : printClosingTagStart(node, options), printClosingTagEnd(node, options)]);
  17190. }
  17191. function printClosingTagStart(node, options) {
  17192. return node.lastChild && needsToBorrowParentClosingTagStartMarker(node.lastChild) ? "" : concat$8([printClosingTagPrefix(node, options), printClosingTagStartMarker(node, options)]);
  17193. }
  17194. function printClosingTagEnd(node, options) {
  17195. return (node.next ? needsToBorrowPrevClosingTagEndMarker(node.next) : needsToBorrowLastChildClosingTagEndMarker(node.parent)) ? "" : concat$8([printClosingTagEndMarker(node, options), printClosingTagSuffix(node, options)]);
  17196. }
  17197. function needsToBorrowNextOpeningTagStartMarker(node) {
  17198. /**
  17199. * 123<p
  17200. * ^^
  17201. * >
  17202. */
  17203. return node.next && !isTextLikeNode(node.next) && isTextLikeNode(node) && node.isTrailingSpaceSensitive && !node.hasTrailingSpaces;
  17204. }
  17205. function needsToBorrowParentOpeningTagEndMarker(node) {
  17206. /**
  17207. * <p
  17208. * >123
  17209. * ^
  17210. *
  17211. * <p
  17212. * ><a
  17213. * ^
  17214. */
  17215. return !node.prev && node.isLeadingSpaceSensitive && !node.hasLeadingSpaces;
  17216. }
  17217. function needsToBorrowPrevClosingTagEndMarker(node) {
  17218. /**
  17219. * <p></p
  17220. * >123
  17221. * ^
  17222. *
  17223. * <p></p
  17224. * ><a
  17225. * ^
  17226. */
  17227. return node.prev && !isTextLikeNode(node.prev) && node.isLeadingSpaceSensitive && !node.hasLeadingSpaces;
  17228. }
  17229. function needsToBorrowLastChildClosingTagEndMarker(node) {
  17230. /**
  17231. * <p
  17232. * ><a></a
  17233. * ></p
  17234. * ^
  17235. * >
  17236. */
  17237. return node.lastChild && node.lastChild.isTrailingSpaceSensitive && !node.lastChild.hasTrailingSpaces && !isTextLikeNode(getLastDescendant(node.lastChild));
  17238. }
  17239. function needsToBorrowParentClosingTagStartMarker(node) {
  17240. /**
  17241. * <p>
  17242. * 123</p
  17243. * ^^^
  17244. * >
  17245. *
  17246. * 123</b
  17247. * ></a
  17248. * ^^^
  17249. * >
  17250. */
  17251. return !node.next && !node.hasTrailingSpaces && node.isTrailingSpaceSensitive && isTextLikeNode(getLastDescendant(node));
  17252. }
  17253. function printOpeningTagPrefix(node, options) {
  17254. return needsToBorrowParentOpeningTagEndMarker(node) ? printOpeningTagEndMarker(node.parent) : needsToBorrowPrevClosingTagEndMarker(node) ? printClosingTagEndMarker(node.prev, options) : "";
  17255. }
  17256. function printClosingTagPrefix(node, options) {
  17257. return needsToBorrowLastChildClosingTagEndMarker(node) ? printClosingTagEndMarker(node.lastChild, options) : "";
  17258. }
  17259. function printClosingTagSuffix(node, options) {
  17260. return needsToBorrowParentClosingTagStartMarker(node) ? printClosingTagStartMarker(node.parent, options) : needsToBorrowNextOpeningTagStartMarker(node) ? printOpeningTagStartMarker(node.next) : "";
  17261. }
  17262. function printOpeningTagStartMarker(node) {
  17263. switch (node.type) {
  17264. case "ieConditionalComment":
  17265. case "ieConditionalStartComment":
  17266. return "<!--[if ".concat(node.condition);
  17267. case "ieConditionalEndComment":
  17268. return "<!--<!";
  17269. case "interpolation":
  17270. return "{{";
  17271. case "docType":
  17272. return "<!DOCTYPE";
  17273. case "element":
  17274. if (node.condition) {
  17275. return "<!--[if ".concat(node.condition, "]><!--><").concat(node.rawName);
  17276. }
  17277. // fall through
  17278. default:
  17279. return "<".concat(node.rawName);
  17280. }
  17281. }
  17282. function printOpeningTagEndMarker(node) {
  17283. assert$3(!node.isSelfClosing);
  17284. switch (node.type) {
  17285. case "ieConditionalComment":
  17286. return "]>";
  17287. case "element":
  17288. if (node.condition) {
  17289. return "><!--<![endif]-->";
  17290. }
  17291. // fall through
  17292. default:
  17293. return ">";
  17294. }
  17295. }
  17296. function printClosingTagStartMarker(node, options) {
  17297. assert$3(!node.isSelfClosing);
  17298. if (shouldNotPrintClosingTag(node, options)) {
  17299. return "";
  17300. }
  17301. switch (node.type) {
  17302. case "ieConditionalComment":
  17303. return "<!";
  17304. case "element":
  17305. if (node.hasHtmComponentClosingTag) {
  17306. return "<//";
  17307. }
  17308. // fall through
  17309. default:
  17310. return "</".concat(node.rawName);
  17311. }
  17312. }
  17313. function printClosingTagEndMarker(node, options) {
  17314. if (shouldNotPrintClosingTag(node, options)) {
  17315. return "";
  17316. }
  17317. switch (node.type) {
  17318. case "ieConditionalComment":
  17319. case "ieConditionalEndComment":
  17320. return "[endif]-->";
  17321. case "ieConditionalStartComment":
  17322. return "]><!-->";
  17323. case "interpolation":
  17324. return "}}";
  17325. case "element":
  17326. if (node.isSelfClosing) {
  17327. return "/>";
  17328. }
  17329. // fall through
  17330. default:
  17331. return ">";
  17332. }
  17333. }
  17334. function getTextValueParts(node) {
  17335. var value = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : node.value;
  17336. return node.parent.isWhitespaceSensitive ? node.parent.isIndentationSensitive ? replaceEndOfLineWith$1(value, literalline$2) : replaceEndOfLineWith$1(dedentString(value.replace(/^\s*?\n|\n\s*?$/g, "")), hardline$7) : // https://infra.spec.whatwg.org/#ascii-whitespace
  17337. join$5(line$6, value.split(/[\t\n\f\r ]+/)).parts;
  17338. }
  17339. function printEmbeddedAttributeValue(node, originalTextToDoc, options) {
  17340. var isKeyMatched = function isKeyMatched(patterns) {
  17341. return new RegExp(patterns.join("|")).test(node.fullName);
  17342. };
  17343. var getValue = function getValue() {
  17344. return unescapeQuoteEntities(node.value);
  17345. };
  17346. var shouldHug = false;
  17347. var __onHtmlBindingRoot = function __onHtmlBindingRoot(root) {
  17348. var rootNode = root.type === "NGRoot" ? root.node.type === "NGMicrosyntax" && root.node.body.length === 1 && root.node.body[0].type === "NGMicrosyntaxExpression" ? root.node.body[0].expression : root.node : root.type === "JsExpressionRoot" ? root.node : root;
  17349. if (rootNode && (rootNode.type === "ObjectExpression" || rootNode.type === "ArrayExpression")) {
  17350. shouldHug = true;
  17351. }
  17352. };
  17353. var printHug = function printHug(doc$$2) {
  17354. return group$8(doc$$2);
  17355. };
  17356. var printExpand = function printExpand(doc$$2) {
  17357. return group$8(concat$8([indent$5(concat$8([softline$4, doc$$2])), softline$4]));
  17358. };
  17359. var printMaybeHug = function printMaybeHug(doc$$2) {
  17360. return shouldHug ? printHug(doc$$2) : printExpand(doc$$2);
  17361. };
  17362. var textToDoc = function textToDoc(code, opts) {
  17363. return originalTextToDoc(code, Object.assign({
  17364. __onHtmlBindingRoot: __onHtmlBindingRoot
  17365. }, opts));
  17366. };
  17367. if (node.fullName === "srcset" && (node.parent.fullName === "img" || node.parent.fullName === "source")) {
  17368. return printExpand(printImgSrcset(getValue()));
  17369. }
  17370. if (options.parser === "vue") {
  17371. if (node.fullName === "v-for") {
  17372. return printVueFor(getValue(), textToDoc);
  17373. }
  17374. if (node.fullName === "slot-scope") {
  17375. return printVueSlotScope(getValue(), textToDoc);
  17376. }
  17377. /**
  17378. * @click="jsStatement"
  17379. * @click="jsExpression"
  17380. * v-on:click="jsStatement"
  17381. * v-on:click="jsExpression"
  17382. */
  17383. var vueEventBindingPatterns = ["^@", "^v-on:"];
  17384. /**
  17385. * :class="vueExpression"
  17386. * v-bind:id="vueExpression"
  17387. */
  17388. var vueExpressionBindingPatterns = ["^:", "^v-bind:"];
  17389. /**
  17390. * v-if="jsExpression"
  17391. */
  17392. var jsExpressionBindingPatterns = ["^v-"];
  17393. if (isKeyMatched(vueEventBindingPatterns)) {
  17394. var value = getValue();
  17395. return printMaybeHug(isVueEventBindingExpression(value) ? textToDoc(value, {
  17396. parser: "__js_expression"
  17397. }) : stripTrailingHardline$1(textToDoc(value, {
  17398. parser: "__vue_event_binding"
  17399. })));
  17400. }
  17401. if (isKeyMatched(vueExpressionBindingPatterns)) {
  17402. return printMaybeHug(textToDoc(getValue(), {
  17403. parser: "__vue_expression"
  17404. }));
  17405. }
  17406. if (isKeyMatched(jsExpressionBindingPatterns)) {
  17407. return printMaybeHug(textToDoc(getValue(), {
  17408. parser: "__js_expression"
  17409. }));
  17410. }
  17411. }
  17412. if (options.parser === "angular") {
  17413. var ngTextToDoc = function ngTextToDoc(code, opts) {
  17414. return (// angular does not allow trailing comma
  17415. textToDoc(code, Object.assign({
  17416. trailingComma: "none"
  17417. }, opts))
  17418. );
  17419. };
  17420. /**
  17421. * *directive="angularDirective"
  17422. */
  17423. var ngDirectiveBindingPatterns = ["^\\*"];
  17424. /**
  17425. * (click)="angularStatement"
  17426. * on-click="angularStatement"
  17427. */
  17428. var ngStatementBindingPatterns = ["^\\(.+\\)$", "^on-"];
  17429. /**
  17430. * [target]="angularExpression"
  17431. * bind-target="angularExpression"
  17432. * [(target)]="angularExpression"
  17433. * bindon-target="angularExpression"
  17434. */
  17435. var ngExpressionBindingPatterns = ["^\\[.+\\]$", "^bind(on)?-"];
  17436. if (isKeyMatched(ngStatementBindingPatterns)) {
  17437. return printMaybeHug(ngTextToDoc(getValue(), {
  17438. parser: "__ng_action"
  17439. }));
  17440. }
  17441. if (isKeyMatched(ngExpressionBindingPatterns)) {
  17442. return printMaybeHug(ngTextToDoc(getValue(), {
  17443. parser: "__ng_binding"
  17444. }));
  17445. }
  17446. if (isKeyMatched(ngDirectiveBindingPatterns)) {
  17447. return printMaybeHug(ngTextToDoc(getValue(), {
  17448. parser: "__ng_directive"
  17449. }));
  17450. }
  17451. var interpolationRegex = /\{\{([\s\S]+?)\}\}/g;
  17452. var _value2 = getValue();
  17453. if (interpolationRegex.test(_value2)) {
  17454. var parts = [];
  17455. _value2.split(interpolationRegex).forEach(function (part, index) {
  17456. if (index % 2 === 0) {
  17457. parts.push(concat$8(replaceEndOfLineWith$1(part, literalline$2)));
  17458. } else {
  17459. try {
  17460. parts.push(group$8(concat$8(["{{", indent$5(concat$8([line$6, ngTextToDoc(part, {
  17461. parser: "__ng_interpolation",
  17462. __isInHtmlInterpolation: true // to avoid unexpected `}}`
  17463. })])), line$6, "}}"])));
  17464. } catch (e) {
  17465. parts.push("{{", concat$8(replaceEndOfLineWith$1(part, literalline$2)), "}}");
  17466. }
  17467. }
  17468. });
  17469. return group$8(concat$8(parts));
  17470. }
  17471. }
  17472. return null;
  17473. }
  17474. var printerHtml = {
  17475. preprocess: preprocess_1,
  17476. print: genericPrint$2,
  17477. insertPragma: insertPragma$5,
  17478. massageAstNode: clean$4,
  17479. embed: embed$2
  17480. };
  17481. var CATEGORY_HTML = "HTML"; // format based on https://github.com/prettier/prettier/blob/master/src/main/core-options.js
  17482. var options$9 = {
  17483. htmlWhitespaceSensitivity: {
  17484. since: "1.15.0",
  17485. category: CATEGORY_HTML,
  17486. type: "choice",
  17487. default: "css",
  17488. description: "How to handle whitespaces in HTML.",
  17489. choices: [{
  17490. value: "css",
  17491. description: "Respect the default value of CSS display property."
  17492. }, {
  17493. value: "strict",
  17494. description: "Whitespaces are considered sensitive."
  17495. }, {
  17496. value: "ignore",
  17497. description: "Whitespaces are considered insensitive."
  17498. }]
  17499. }
  17500. };
  17501. var name$7 = "HTML";
  17502. var type$6 = "markup";
  17503. var tmScope$6 = "text.html.basic";
  17504. var aceMode$6 = "html";
  17505. var codemirrorMode$3 = "htmlmixed";
  17506. var codemirrorMimeType$3 = "text/html";
  17507. var color$1 = "#e34c26";
  17508. var aliases$1 = ["xhtml"];
  17509. var extensions$6 = [".html", ".htm", ".html.hl", ".inc", ".st", ".xht", ".xhtml"];
  17510. var languageId$6 = 146;
  17511. var html$1 = {
  17512. name: name$7,
  17513. type: type$6,
  17514. tmScope: tmScope$6,
  17515. aceMode: aceMode$6,
  17516. codemirrorMode: codemirrorMode$3,
  17517. codemirrorMimeType: codemirrorMimeType$3,
  17518. color: color$1,
  17519. aliases: aliases$1,
  17520. extensions: extensions$6,
  17521. languageId: languageId$6
  17522. };
  17523. var html$2 = Object.freeze({
  17524. name: name$7,
  17525. type: type$6,
  17526. tmScope: tmScope$6,
  17527. aceMode: aceMode$6,
  17528. codemirrorMode: codemirrorMode$3,
  17529. codemirrorMimeType: codemirrorMimeType$3,
  17530. color: color$1,
  17531. aliases: aliases$1,
  17532. extensions: extensions$6,
  17533. languageId: languageId$6,
  17534. default: html$1
  17535. });
  17536. var name$8 = "Vue";
  17537. var type$7 = "markup";
  17538. var color$2 = "#2c3e50";
  17539. var extensions$7 = [".vue"];
  17540. var tmScope$7 = "text.html.vue";
  17541. var aceMode$7 = "html";
  17542. var languageId$7 = 391;
  17543. var vue = {
  17544. name: name$8,
  17545. type: type$7,
  17546. color: color$2,
  17547. extensions: extensions$7,
  17548. tmScope: tmScope$7,
  17549. aceMode: aceMode$7,
  17550. languageId: languageId$7
  17551. };
  17552. var vue$1 = Object.freeze({
  17553. name: name$8,
  17554. type: type$7,
  17555. color: color$2,
  17556. extensions: extensions$7,
  17557. tmScope: tmScope$7,
  17558. aceMode: aceMode$7,
  17559. languageId: languageId$7,
  17560. default: vue
  17561. });
  17562. var require$$0$22 = ( html$2 && html$1 ) || html$2;
  17563. var require$$1$9 = ( vue$1 && vue ) || vue$1;
  17564. var languages$3 = [createLanguage(require$$0$22, {
  17565. override: {
  17566. name: "Angular",
  17567. since: "1.15.0",
  17568. parsers: ["angular"],
  17569. vscodeLanguageIds: ["html"],
  17570. extensions: [".component.html"],
  17571. filenames: []
  17572. }
  17573. }), createLanguage(require$$0$22, {
  17574. override: {
  17575. since: "1.15.0",
  17576. parsers: ["html"],
  17577. vscodeLanguageIds: ["html"]
  17578. },
  17579. extend: {
  17580. extensions: [".mjml" // MJML is considered XML in Linguist but it should be formatted as HTML
  17581. ]
  17582. }
  17583. }), createLanguage(require$$1$9, {
  17584. override: {
  17585. since: "1.10.0",
  17586. parsers: ["vue"],
  17587. vscodeLanguageIds: ["vue"]
  17588. }
  17589. })];
  17590. var printers$3 = {
  17591. html: printerHtml
  17592. };
  17593. var languageHtml = {
  17594. languages: languages$3,
  17595. printers: printers$3,
  17596. options: options$9
  17597. };
  17598. var addLeadingComment$2 = utilShared.addLeadingComment;
  17599. var addTrailingComment$2 = utilShared.addTrailingComment;
  17600. var addDanglingComment$2 = utilShared.addDanglingComment;
  17601. function handleOwnLineComment(comment, text, options, ast, isLastComment) {
  17602. var precedingNode = comment.precedingNode,
  17603. enclosingNode = comment.enclosingNode,
  17604. followingNode = comment.followingNode;
  17605. if (handleLastFunctionArgComments(text, precedingNode, enclosingNode, followingNode, comment, options) || handleMemberExpressionComments(enclosingNode, followingNode, comment) || handleIfStatementComments(text, precedingNode, enclosingNode, followingNode, comment, options) || handleWhileComments(text, precedingNode, enclosingNode, followingNode, comment, options) || handleTryStatementComments(enclosingNode, precedingNode, followingNode, comment) || handleClassComments(enclosingNode, precedingNode, followingNode, comment) || handleImportSpecifierComments(enclosingNode, comment) || handleForComments(enclosingNode, precedingNode, comment) || handleUnionTypeComments(precedingNode, enclosingNode, followingNode, comment) || handleOnlyComments(enclosingNode, ast, comment, isLastComment) || handleImportDeclarationComments(text, enclosingNode, precedingNode, comment, options) || handleAssignmentPatternComments(enclosingNode, comment) || handleMethodNameComments(text, enclosingNode, precedingNode, comment, options)) {
  17606. return true;
  17607. }
  17608. return false;
  17609. }
  17610. function handleEndOfLineComment(comment, text, options, ast, isLastComment) {
  17611. var precedingNode = comment.precedingNode,
  17612. enclosingNode = comment.enclosingNode,
  17613. followingNode = comment.followingNode;
  17614. if (handleLastFunctionArgComments(text, precedingNode, enclosingNode, followingNode, comment, options) || handleConditionalExpressionComments(enclosingNode, precedingNode, followingNode, comment, text, options) || handleImportSpecifierComments(enclosingNode, comment) || handleIfStatementComments(text, precedingNode, enclosingNode, followingNode, comment, options) || handleWhileComments(text, precedingNode, enclosingNode, followingNode, comment, options) || handleTryStatementComments(enclosingNode, precedingNode, followingNode, comment) || handleClassComments(enclosingNode, precedingNode, followingNode, comment) || handleLabeledStatementComments(enclosingNode, comment) || handleCallExpressionComments(precedingNode, enclosingNode, comment) || handlePropertyComments(enclosingNode, comment) || handleOnlyComments(enclosingNode, ast, comment, isLastComment) || handleTypeAliasComments(enclosingNode, followingNode, comment) || handleVariableDeclaratorComments(enclosingNode, followingNode, comment)) {
  17615. return true;
  17616. }
  17617. return false;
  17618. }
  17619. function handleRemainingComment(comment, text, options, ast, isLastComment) {
  17620. var precedingNode = comment.precedingNode,
  17621. enclosingNode = comment.enclosingNode,
  17622. followingNode = comment.followingNode;
  17623. if (handleIfStatementComments(text, precedingNode, enclosingNode, followingNode, comment, options) || handleWhileComments(text, precedingNode, enclosingNode, followingNode, comment, options) || handleObjectPropertyAssignment(enclosingNode, precedingNode, comment) || handleCommentInEmptyParens(text, enclosingNode, comment, options) || handleMethodNameComments(text, enclosingNode, precedingNode, comment, options) || handleOnlyComments(enclosingNode, ast, comment, isLastComment) || handleCommentAfterArrowParams(text, enclosingNode, comment, options) || handleFunctionNameComments(text, enclosingNode, precedingNode, comment, options) || handleTSMappedTypeComments(text, enclosingNode, precedingNode, followingNode, comment) || handleBreakAndContinueStatementComments(enclosingNode, comment)) {
  17624. return true;
  17625. }
  17626. return false;
  17627. }
  17628. function addBlockStatementFirstComment(node, comment) {
  17629. var body = node.body.filter(function (n) {
  17630. return n.type !== "EmptyStatement";
  17631. });
  17632. if (body.length === 0) {
  17633. addDanglingComment$2(node, comment);
  17634. } else {
  17635. addLeadingComment$2(body[0], comment);
  17636. }
  17637. }
  17638. function addBlockOrNotComment(node, comment) {
  17639. if (node.type === "BlockStatement") {
  17640. addBlockStatementFirstComment(node, comment);
  17641. } else {
  17642. addLeadingComment$2(node, comment);
  17643. }
  17644. } // There are often comments before the else clause of if statements like
  17645. //
  17646. // if (1) { ... }
  17647. // // comment
  17648. // else { ... }
  17649. //
  17650. // They are being attached as leading comments of the BlockExpression which
  17651. // is not well printed. What we want is to instead move the comment inside
  17652. // of the block and make it leadingComment of the first element of the block
  17653. // or dangling comment of the block if there is nothing inside
  17654. //
  17655. // if (1) { ... }
  17656. // else {
  17657. // // comment
  17658. // ...
  17659. // }
  17660. function handleIfStatementComments(text, precedingNode, enclosingNode, followingNode, comment, options) {
  17661. if (!enclosingNode || enclosingNode.type !== "IfStatement" || !followingNode) {
  17662. return false;
  17663. } // We unfortunately have no way using the AST or location of nodes to know
  17664. // if the comment is positioned before the condition parenthesis:
  17665. // if (a /* comment */) {}
  17666. // The only workaround I found is to look at the next character to see if
  17667. // it is a ).
  17668. var nextCharacter = util.getNextNonSpaceNonCommentCharacter(text, comment, options.locEnd);
  17669. if (nextCharacter === ")") {
  17670. addTrailingComment$2(precedingNode, comment);
  17671. return true;
  17672. } // Comments before `else`:
  17673. // - treat as trailing comments of the consequent, if it's a BlockStatement
  17674. // - treat as a dangling comment otherwise
  17675. if (precedingNode === enclosingNode.consequent && followingNode === enclosingNode.alternate) {
  17676. if (precedingNode.type === "BlockStatement") {
  17677. addTrailingComment$2(precedingNode, comment);
  17678. } else {
  17679. addDanglingComment$2(enclosingNode, comment);
  17680. }
  17681. return true;
  17682. }
  17683. if (followingNode.type === "BlockStatement") {
  17684. addBlockStatementFirstComment(followingNode, comment);
  17685. return true;
  17686. }
  17687. if (followingNode.type === "IfStatement") {
  17688. addBlockOrNotComment(followingNode.consequent, comment);
  17689. return true;
  17690. } // For comments positioned after the condition parenthesis in an if statement
  17691. // before the consequent without brackets on, such as
  17692. // if (a) /* comment */ true,
  17693. // we look at the next character to see if the following node
  17694. // is the consequent for the if statement
  17695. if (enclosingNode.consequent === followingNode) {
  17696. addLeadingComment$2(followingNode, comment);
  17697. return true;
  17698. }
  17699. return false;
  17700. }
  17701. function handleWhileComments(text, precedingNode, enclosingNode, followingNode, comment, options) {
  17702. if (!enclosingNode || enclosingNode.type !== "WhileStatement" || !followingNode) {
  17703. return false;
  17704. } // We unfortunately have no way using the AST or location of nodes to know
  17705. // if the comment is positioned before the condition parenthesis:
  17706. // while (a /* comment */) {}
  17707. // The only workaround I found is to look at the next character to see if
  17708. // it is a ).
  17709. var nextCharacter = util.getNextNonSpaceNonCommentCharacter(text, comment, options.locEnd);
  17710. if (nextCharacter === ")") {
  17711. addTrailingComment$2(precedingNode, comment);
  17712. return true;
  17713. }
  17714. if (followingNode.type === "BlockStatement") {
  17715. addBlockStatementFirstComment(followingNode, comment);
  17716. return true;
  17717. }
  17718. return false;
  17719. } // Same as IfStatement but for TryStatement
  17720. function handleTryStatementComments(enclosingNode, precedingNode, followingNode, comment) {
  17721. if (!enclosingNode || enclosingNode.type !== "TryStatement" && enclosingNode.type !== "CatchClause" || !followingNode) {
  17722. return false;
  17723. }
  17724. if (enclosingNode.type === "CatchClause" && precedingNode) {
  17725. addTrailingComment$2(precedingNode, comment);
  17726. return true;
  17727. }
  17728. if (followingNode.type === "BlockStatement") {
  17729. addBlockStatementFirstComment(followingNode, comment);
  17730. return true;
  17731. }
  17732. if (followingNode.type === "TryStatement") {
  17733. addBlockOrNotComment(followingNode.finalizer, comment);
  17734. return true;
  17735. }
  17736. if (followingNode.type === "CatchClause") {
  17737. addBlockOrNotComment(followingNode.body, comment);
  17738. return true;
  17739. }
  17740. return false;
  17741. }
  17742. function handleMemberExpressionComments(enclosingNode, followingNode, comment) {
  17743. if (enclosingNode && enclosingNode.type === "MemberExpression" && followingNode && followingNode.type === "Identifier") {
  17744. addLeadingComment$2(enclosingNode, comment);
  17745. return true;
  17746. }
  17747. return false;
  17748. }
  17749. function handleConditionalExpressionComments(enclosingNode, precedingNode, followingNode, comment, text, options) {
  17750. var isSameLineAsPrecedingNode = precedingNode && !util.hasNewlineInRange(text, options.locEnd(precedingNode), options.locStart(comment));
  17751. if ((!precedingNode || !isSameLineAsPrecedingNode) && enclosingNode && enclosingNode.type === "ConditionalExpression" && followingNode) {
  17752. addLeadingComment$2(followingNode, comment);
  17753. return true;
  17754. }
  17755. return false;
  17756. }
  17757. function handleObjectPropertyAssignment(enclosingNode, precedingNode, comment) {
  17758. if (enclosingNode && (enclosingNode.type === "ObjectProperty" || enclosingNode.type === "Property") && enclosingNode.shorthand && enclosingNode.key === precedingNode && enclosingNode.value.type === "AssignmentPattern") {
  17759. addTrailingComment$2(enclosingNode.value.left, comment);
  17760. return true;
  17761. }
  17762. return false;
  17763. }
  17764. function handleClassComments(enclosingNode, precedingNode, followingNode, comment) {
  17765. if (enclosingNode && (enclosingNode.type === "ClassDeclaration" || enclosingNode.type === "ClassExpression") && enclosingNode.decorators && enclosingNode.decorators.length > 0 && !(followingNode && followingNode.type === "Decorator")) {
  17766. if (!enclosingNode.decorators || enclosingNode.decorators.length === 0) {
  17767. addLeadingComment$2(enclosingNode, comment);
  17768. } else {
  17769. addTrailingComment$2(enclosingNode.decorators[enclosingNode.decorators.length - 1], comment);
  17770. }
  17771. return true;
  17772. }
  17773. return false;
  17774. }
  17775. function handleMethodNameComments(text, enclosingNode, precedingNode, comment, options) {
  17776. // This is only needed for estree parsers (flow, typescript) to attach
  17777. // after a method name:
  17778. // obj = { fn /*comment*/() {} };
  17779. if (enclosingNode && precedingNode && (enclosingNode.type === "Property" || enclosingNode.type === "MethodDefinition") && precedingNode.type === "Identifier" && enclosingNode.key === precedingNode && // special Property case: { key: /*comment*/(value) };
  17780. // comment should be attached to value instead of key
  17781. util.getNextNonSpaceNonCommentCharacter(text, precedingNode, options.locEnd) !== ":") {
  17782. addTrailingComment$2(precedingNode, comment);
  17783. return true;
  17784. } // Print comments between decorators and class methods as a trailing comment
  17785. // on the decorator node instead of the method node
  17786. if (precedingNode && enclosingNode && precedingNode.type === "Decorator" && (enclosingNode.type === "ClassMethod" || enclosingNode.type === "ClassProperty" || enclosingNode.type === "TSAbstractClassProperty" || enclosingNode.type === "TSAbstractMethodDefinition" || enclosingNode.type === "MethodDefinition")) {
  17787. addTrailingComment$2(precedingNode, comment);
  17788. return true;
  17789. }
  17790. return false;
  17791. }
  17792. function handleFunctionNameComments(text, enclosingNode, precedingNode, comment, options) {
  17793. if (util.getNextNonSpaceNonCommentCharacter(text, comment, options.locEnd) !== "(") {
  17794. return false;
  17795. }
  17796. if (precedingNode && enclosingNode && (enclosingNode.type === "FunctionDeclaration" || enclosingNode.type === "FunctionExpression" || enclosingNode.type === "ClassMethod" || enclosingNode.type === "MethodDefinition" || enclosingNode.type === "ObjectMethod")) {
  17797. addTrailingComment$2(precedingNode, comment);
  17798. return true;
  17799. }
  17800. return false;
  17801. }
  17802. function handleCommentAfterArrowParams(text, enclosingNode, comment, options) {
  17803. if (!(enclosingNode && enclosingNode.type === "ArrowFunctionExpression")) {
  17804. return false;
  17805. }
  17806. var index = utilShared.getNextNonSpaceNonCommentCharacterIndex(text, comment, options);
  17807. if (text.substr(index, 2) === "=>") {
  17808. addDanglingComment$2(enclosingNode, comment);
  17809. return true;
  17810. }
  17811. return false;
  17812. }
  17813. function handleCommentInEmptyParens(text, enclosingNode, comment, options) {
  17814. if (util.getNextNonSpaceNonCommentCharacter(text, comment, options.locEnd) !== ")") {
  17815. return false;
  17816. } // Only add dangling comments to fix the case when no params are present,
  17817. // i.e. a function without any argument.
  17818. 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.type === "NewExpression") && enclosingNode.arguments.length === 0)) {
  17819. addDanglingComment$2(enclosingNode, comment);
  17820. return true;
  17821. }
  17822. if (enclosingNode && enclosingNode.type === "MethodDefinition" && enclosingNode.value.params.length === 0) {
  17823. addDanglingComment$2(enclosingNode.value, comment);
  17824. return true;
  17825. }
  17826. return false;
  17827. }
  17828. function handleLastFunctionArgComments(text, precedingNode, enclosingNode, followingNode, comment, options) {
  17829. // Type definitions functions
  17830. if (precedingNode && precedingNode.type === "FunctionTypeParam" && enclosingNode && enclosingNode.type === "FunctionTypeAnnotation" && followingNode && followingNode.type !== "FunctionTypeParam") {
  17831. addTrailingComment$2(precedingNode, comment);
  17832. return true;
  17833. } // Real functions
  17834. 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) === ")") {
  17835. addTrailingComment$2(precedingNode, comment);
  17836. return true;
  17837. }
  17838. if (enclosingNode && enclosingNode.type === "FunctionDeclaration" && followingNode && followingNode.type === "BlockStatement") {
  17839. var functionParamRightParenIndex = function () {
  17840. if (enclosingNode.params.length !== 0) {
  17841. return util.getNextNonSpaceNonCommentCharacterIndexWithStartIndex(text, options.locEnd(util.getLast(enclosingNode.params)));
  17842. }
  17843. var functionParamLeftParenIndex = util.getNextNonSpaceNonCommentCharacterIndexWithStartIndex(text, options.locEnd(enclosingNode.id));
  17844. return util.getNextNonSpaceNonCommentCharacterIndexWithStartIndex(text, functionParamLeftParenIndex + 1);
  17845. }();
  17846. if (options.locStart(comment) > functionParamRightParenIndex) {
  17847. addBlockStatementFirstComment(followingNode, comment);
  17848. return true;
  17849. }
  17850. }
  17851. return false;
  17852. }
  17853. function handleImportSpecifierComments(enclosingNode, comment) {
  17854. if (enclosingNode && enclosingNode.type === "ImportSpecifier") {
  17855. addLeadingComment$2(enclosingNode, comment);
  17856. return true;
  17857. }
  17858. return false;
  17859. }
  17860. function handleLabeledStatementComments(enclosingNode, comment) {
  17861. if (enclosingNode && enclosingNode.type === "LabeledStatement") {
  17862. addLeadingComment$2(enclosingNode, comment);
  17863. return true;
  17864. }
  17865. return false;
  17866. }
  17867. function handleBreakAndContinueStatementComments(enclosingNode, comment) {
  17868. if (enclosingNode && (enclosingNode.type === "ContinueStatement" || enclosingNode.type === "BreakStatement") && !enclosingNode.label) {
  17869. addTrailingComment$2(enclosingNode, comment);
  17870. return true;
  17871. }
  17872. return false;
  17873. }
  17874. function handleCallExpressionComments(precedingNode, enclosingNode, comment) {
  17875. if (enclosingNode && enclosingNode.type === "CallExpression" && precedingNode && enclosingNode.callee === precedingNode && enclosingNode.arguments.length > 0) {
  17876. addLeadingComment$2(enclosingNode.arguments[0], comment);
  17877. return true;
  17878. }
  17879. return false;
  17880. }
  17881. function handleUnionTypeComments(precedingNode, enclosingNode, followingNode, comment) {
  17882. if (enclosingNode && (enclosingNode.type === "UnionTypeAnnotation" || enclosingNode.type === "TSUnionType")) {
  17883. addTrailingComment$2(precedingNode, comment);
  17884. return true;
  17885. }
  17886. return false;
  17887. }
  17888. function handlePropertyComments(enclosingNode, comment) {
  17889. if (enclosingNode && (enclosingNode.type === "Property" || enclosingNode.type === "ObjectProperty")) {
  17890. addLeadingComment$2(enclosingNode, comment);
  17891. return true;
  17892. }
  17893. return false;
  17894. }
  17895. function handleOnlyComments(enclosingNode, ast, comment, isLastComment) {
  17896. // With Flow the enclosingNode is undefined so use the AST instead.
  17897. if (ast && ast.body && ast.body.length === 0) {
  17898. if (isLastComment) {
  17899. addDanglingComment$2(ast, comment);
  17900. } else {
  17901. addLeadingComment$2(ast, comment);
  17902. }
  17903. return true;
  17904. } else if (enclosingNode && enclosingNode.type === "Program" && enclosingNode.body.length === 0 && enclosingNode.directives && enclosingNode.directives.length === 0) {
  17905. if (isLastComment) {
  17906. addDanglingComment$2(enclosingNode, comment);
  17907. } else {
  17908. addLeadingComment$2(enclosingNode, comment);
  17909. }
  17910. return true;
  17911. }
  17912. return false;
  17913. }
  17914. function handleForComments(enclosingNode, precedingNode, comment) {
  17915. if (enclosingNode && (enclosingNode.type === "ForInStatement" || enclosingNode.type === "ForOfStatement")) {
  17916. addLeadingComment$2(enclosingNode, comment);
  17917. return true;
  17918. }
  17919. return false;
  17920. }
  17921. function handleImportDeclarationComments(text, enclosingNode, precedingNode, comment, options) {
  17922. if (precedingNode && precedingNode.type === "ImportSpecifier" && enclosingNode && enclosingNode.type === "ImportDeclaration" && util.hasNewline(text, options.locEnd(comment))) {
  17923. addTrailingComment$2(precedingNode, comment);
  17924. return true;
  17925. }
  17926. return false;
  17927. }
  17928. function handleAssignmentPatternComments(enclosingNode, comment) {
  17929. if (enclosingNode && enclosingNode.type === "AssignmentPattern") {
  17930. addLeadingComment$2(enclosingNode, comment);
  17931. return true;
  17932. }
  17933. return false;
  17934. }
  17935. function handleTypeAliasComments(enclosingNode, followingNode, comment) {
  17936. if (enclosingNode && enclosingNode.type === "TypeAlias") {
  17937. addLeadingComment$2(enclosingNode, comment);
  17938. return true;
  17939. }
  17940. return false;
  17941. }
  17942. function handleVariableDeclaratorComments(enclosingNode, followingNode, comment) {
  17943. if (enclosingNode && (enclosingNode.type === "VariableDeclarator" || enclosingNode.type === "AssignmentExpression") && followingNode && (followingNode.type === "ObjectExpression" || followingNode.type === "ArrayExpression" || followingNode.type === "TemplateLiteral" || followingNode.type === "TaggedTemplateExpression")) {
  17944. addLeadingComment$2(followingNode, comment);
  17945. return true;
  17946. }
  17947. return false;
  17948. }
  17949. function handleTSMappedTypeComments(text, enclosingNode, precedingNode, followingNode, comment) {
  17950. if (!enclosingNode || enclosingNode.type !== "TSMappedType") {
  17951. return false;
  17952. }
  17953. if (followingNode && followingNode.type === "TSTypeParameter" && followingNode.name) {
  17954. addLeadingComment$2(followingNode.name, comment);
  17955. return true;
  17956. }
  17957. if (precedingNode && precedingNode.type === "TSTypeParameter" && precedingNode.constraint) {
  17958. addTrailingComment$2(precedingNode.constraint, comment);
  17959. return true;
  17960. }
  17961. return false;
  17962. }
  17963. function isBlockComment$1(comment) {
  17964. return comment.type === "Block" || comment.type === "CommentBlock";
  17965. }
  17966. function hasLeadingComment$2(node) {
  17967. var fn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () {
  17968. return true;
  17969. };
  17970. if (node.leadingComments) {
  17971. return node.leadingComments.some(fn);
  17972. }
  17973. if (node.comments) {
  17974. return node.comments.some(function (comment) {
  17975. return comment.leading && fn(comment);
  17976. });
  17977. }
  17978. return false;
  17979. }
  17980. var comments$3 = {
  17981. handleOwnLineComment: handleOwnLineComment,
  17982. handleEndOfLineComment: handleEndOfLineComment,
  17983. handleRemainingComment: handleRemainingComment,
  17984. hasLeadingComment: hasLeadingComment$2,
  17985. isBlockComment: isBlockComment$1
  17986. };
  17987. var isBlockComment = comments$3.isBlockComment;
  17988. var hasLeadingComment$1 = comments$3.hasLeadingComment;
  17989. var _require$$1$builders = doc.builders;
  17990. var indent$7 = _require$$1$builders.indent;
  17991. var join$8 = _require$$1$builders.join;
  17992. var hardline$9 = _require$$1$builders.hardline;
  17993. var softline$6 = _require$$1$builders.softline;
  17994. var literalline$4 = _require$$1$builders.literalline;
  17995. var concat$12 = _require$$1$builders.concat;
  17996. var group$11 = _require$$1$builders.group;
  17997. var dedentToRoot$2 = _require$$1$builders.dedentToRoot;
  17998. var _require$$1$utils = doc.utils;
  17999. var mapDoc$5 = _require$$1$utils.mapDoc;
  18000. var stripTrailingHardline$2 = _require$$1$utils.stripTrailingHardline;
  18001. function embed$4(path, print, textToDoc
  18002. /*, options */
  18003. ) {
  18004. var node = path.getValue();
  18005. var parent = path.getParentNode();
  18006. var parentParent = path.getParentNode(1);
  18007. switch (node.type) {
  18008. case "TemplateLiteral":
  18009. {
  18010. var isCss = [isStyledJsx, isStyledComponents, isCssProp, isAngularComponentStyles].some(function (isIt) {
  18011. return isIt(path);
  18012. });
  18013. if (isCss) {
  18014. // Get full template literal with expressions replaced by placeholders
  18015. var rawQuasis = node.quasis.map(function (q) {
  18016. return q.value.raw;
  18017. });
  18018. var placeholderID = 0;
  18019. var text = rawQuasis.reduce(function (prevVal, currVal, idx) {
  18020. return idx == 0 ? currVal : prevVal + "@prettier-placeholder-" + placeholderID++ + "-id" + currVal;
  18021. }, "");
  18022. var doc$$2 = textToDoc(text, {
  18023. parser: "css"
  18024. });
  18025. return transformCssDoc(doc$$2, path, print);
  18026. }
  18027. /*
  18028. * react-relay and graphql-tag
  18029. * graphql`...`
  18030. * graphql.experimental`...`
  18031. * gql`...`
  18032. *
  18033. * This intentionally excludes Relay Classic tags, as Prettier does not
  18034. * support Relay Classic formatting.
  18035. */
  18036. if (isGraphQL(path)) {
  18037. var expressionDocs = node.expressions ? path.map(print, "expressions") : [];
  18038. var numQuasis = node.quasis.length;
  18039. if (numQuasis === 1 && node.quasis[0].value.raw.trim() === "") {
  18040. return "``";
  18041. }
  18042. var parts = [];
  18043. for (var i = 0; i < numQuasis; i++) {
  18044. var templateElement = node.quasis[i];
  18045. var isFirst = i === 0;
  18046. var isLast = i === numQuasis - 1;
  18047. var _text = templateElement.value.cooked; // Bail out if any of the quasis have an invalid escape sequence
  18048. // (which would make the `cooked` value be `null` or `undefined`)
  18049. if (typeof _text !== "string") {
  18050. return null;
  18051. }
  18052. var lines = _text.split("\n");
  18053. var numLines = lines.length;
  18054. var expressionDoc = expressionDocs[i];
  18055. var startsWithBlankLine = numLines > 2 && lines[0].trim() === "" && lines[1].trim() === "";
  18056. var endsWithBlankLine = numLines > 2 && lines[numLines - 1].trim() === "" && lines[numLines - 2].trim() === "";
  18057. var commentsAndWhitespaceOnly = lines.every(function (line) {
  18058. return /^\s*(?:#[^\r\n]*)?$/.test(line);
  18059. }); // Bail out if an interpolation occurs within a comment.
  18060. if (!isLast && /#[^\r\n]*$/.test(lines[numLines - 1])) {
  18061. return null;
  18062. }
  18063. var _doc = null;
  18064. if (commentsAndWhitespaceOnly) {
  18065. _doc = printGraphqlComments(lines);
  18066. } else {
  18067. _doc = stripTrailingHardline$2(textToDoc(_text, {
  18068. parser: "graphql"
  18069. }));
  18070. }
  18071. if (_doc) {
  18072. _doc = escapeTemplateCharacters(_doc, false);
  18073. if (!isFirst && startsWithBlankLine) {
  18074. parts.push("");
  18075. }
  18076. parts.push(_doc);
  18077. if (!isLast && endsWithBlankLine) {
  18078. parts.push("");
  18079. }
  18080. } else if (!isFirst && !isLast && startsWithBlankLine) {
  18081. parts.push("");
  18082. }
  18083. if (expressionDoc) {
  18084. parts.push(concat$12(["${", expressionDoc, "}"]));
  18085. }
  18086. }
  18087. return concat$12(["`", indent$7(concat$12([hardline$9, join$8(hardline$9, parts)])), hardline$9, "`"]);
  18088. }
  18089. if (isHtml(path)) {
  18090. return printHtmlTemplateLiteral(path, print, textToDoc, "html");
  18091. }
  18092. if (isAngularComponentTemplate(path)) {
  18093. return printHtmlTemplateLiteral(path, print, textToDoc, "angular");
  18094. }
  18095. break;
  18096. }
  18097. case "TemplateElement":
  18098. {
  18099. /**
  18100. * md`...`
  18101. * markdown`...`
  18102. */
  18103. if (parentParent && parentParent.type === "TaggedTemplateExpression" && parent.quasis.length === 1 && parentParent.tag.type === "Identifier" && (parentParent.tag.name === "md" || parentParent.tag.name === "markdown")) {
  18104. var _text2 = parent.quasis[0].value.raw.replace(/((?:\\\\)*)\\`/g, function (_, backslashes) {
  18105. return "\\".repeat(backslashes.length / 2) + "`";
  18106. });
  18107. var indentation = getIndentation(_text2);
  18108. var hasIndent = indentation !== "";
  18109. return concat$12([hasIndent ? indent$7(concat$12([softline$6, printMarkdown(_text2.replace(new RegExp("^".concat(indentation), "gm"), ""))])) : concat$12([literalline$4, dedentToRoot$2(printMarkdown(_text2))]), softline$6]);
  18110. }
  18111. break;
  18112. }
  18113. }
  18114. function printMarkdown(text) {
  18115. var doc$$2 = textToDoc(text, {
  18116. parser: "markdown",
  18117. __inJsTemplate: true
  18118. });
  18119. return stripTrailingHardline$2(escapeTemplateCharacters(doc$$2, true));
  18120. }
  18121. }
  18122. function getIndentation(str) {
  18123. var firstMatchedIndent = str.match(/^([^\S\n]*)\S/m);
  18124. return firstMatchedIndent === null ? "" : firstMatchedIndent[1];
  18125. }
  18126. function escapeTemplateCharacters(doc$$2, raw) {
  18127. return mapDoc$5(doc$$2, function (currentDoc) {
  18128. if (!currentDoc.parts) {
  18129. return currentDoc;
  18130. }
  18131. var parts = [];
  18132. currentDoc.parts.forEach(function (part) {
  18133. if (typeof part === "string") {
  18134. parts.push(raw ? part.replace(/(\\*)`/g, "$1$1\\`") : part.replace(/([\\`]|\$\{)/g, "\\$1"));
  18135. } else {
  18136. parts.push(part);
  18137. }
  18138. });
  18139. return Object.assign({}, currentDoc, {
  18140. parts: parts
  18141. });
  18142. });
  18143. }
  18144. function transformCssDoc(quasisDoc, path, print) {
  18145. var parentNode = path.getValue();
  18146. var isEmpty = parentNode.quasis.length === 1 && !parentNode.quasis[0].value.raw.trim();
  18147. if (isEmpty) {
  18148. return "``";
  18149. }
  18150. var expressionDocs = parentNode.expressions ? path.map(print, "expressions") : [];
  18151. var newDoc = replacePlaceholders(quasisDoc, expressionDocs);
  18152. /* istanbul ignore if */
  18153. if (!newDoc) {
  18154. throw new Error("Couldn't insert all the expressions");
  18155. }
  18156. return concat$12(["`", indent$7(concat$12([hardline$9, stripTrailingHardline$2(newDoc)])), softline$6, "`"]);
  18157. } // Search all the placeholders in the quasisDoc tree
  18158. // and replace them with the expression docs one by one
  18159. // returns a new doc with all the placeholders replaced,
  18160. // or null if it couldn't replace any expression
  18161. function replacePlaceholders(quasisDoc, expressionDocs) {
  18162. if (!expressionDocs || !expressionDocs.length) {
  18163. return quasisDoc;
  18164. }
  18165. var expressions = expressionDocs.slice();
  18166. var replaceCounter = 0;
  18167. var newDoc = mapDoc$5(quasisDoc, function (doc$$2) {
  18168. if (!doc$$2 || !doc$$2.parts || !doc$$2.parts.length) {
  18169. return doc$$2;
  18170. }
  18171. var parts = doc$$2.parts;
  18172. var atIndex = parts.indexOf("@");
  18173. var placeholderIndex = atIndex + 1;
  18174. if (atIndex > -1 && typeof parts[placeholderIndex] === "string" && parts[placeholderIndex].startsWith("prettier-placeholder")) {
  18175. // If placeholder is split, join it
  18176. var at = parts[atIndex];
  18177. var placeholder = parts[placeholderIndex];
  18178. var rest = parts.slice(placeholderIndex + 1);
  18179. parts = parts.slice(0, atIndex).concat([at + placeholder]).concat(rest);
  18180. }
  18181. var atPlaceholderIndex = parts.findIndex(function (part) {
  18182. return typeof part === "string" && part.startsWith("@prettier-placeholder");
  18183. });
  18184. if (atPlaceholderIndex > -1) {
  18185. var _placeholder = parts[atPlaceholderIndex];
  18186. var _rest = parts.slice(atPlaceholderIndex + 1);
  18187. var placeholderMatch = _placeholder.match(/@prettier-placeholder-(.+)-id([\s\S]*)/);
  18188. var placeholderID = placeholderMatch[1]; // When the expression has a suffix appended, like:
  18189. // animation: linear ${time}s ease-out;
  18190. var suffix = placeholderMatch[2];
  18191. var expression = expressions[placeholderID];
  18192. replaceCounter++;
  18193. parts = parts.slice(0, atPlaceholderIndex).concat(["${", expression, "}" + suffix]).concat(_rest);
  18194. }
  18195. return Object.assign({}, doc$$2, {
  18196. parts: parts
  18197. });
  18198. });
  18199. return expressions.length === replaceCounter ? newDoc : null;
  18200. }
  18201. function printGraphqlComments(lines) {
  18202. var parts = [];
  18203. var seenComment = false;
  18204. lines.map(function (textLine) {
  18205. return textLine.trim();
  18206. }).forEach(function (textLine, i, array) {
  18207. // Lines are either whitespace only, or a comment (with poential whitespace
  18208. // around it). Drop whitespace-only lines.
  18209. if (textLine === "") {
  18210. return;
  18211. }
  18212. if (array[i - 1] === "" && seenComment) {
  18213. // If a non-first comment is preceded by a blank (whitespace only) line,
  18214. // add in a blank line.
  18215. parts.push(concat$12([hardline$9, textLine]));
  18216. } else {
  18217. parts.push(textLine);
  18218. }
  18219. seenComment = true;
  18220. }); // If `lines` was whitespace only, return `null`.
  18221. return parts.length === 0 ? null : join$8(hardline$9, parts);
  18222. }
  18223. /**
  18224. * Template literal in this context:
  18225. * <style jsx>{`div{color:red}`}</style>
  18226. */
  18227. function isStyledJsx(path) {
  18228. var node = path.getValue();
  18229. var parent = path.getParentNode();
  18230. var parentParent = path.getParentNode(1);
  18231. return parentParent && node.quasis && parent.type === "JSXExpressionContainer" && parentParent.type === "JSXElement" && parentParent.openingElement.name.name === "style" && parentParent.openingElement.attributes.some(function (attribute) {
  18232. return attribute.name.name === "jsx";
  18233. });
  18234. }
  18235. /**
  18236. * Angular Components can have:
  18237. * - Inline HTML template
  18238. * - Inline CSS styles
  18239. *
  18240. * ...which are both within template literals somewhere
  18241. * inside of the Component decorator factory.
  18242. *
  18243. * E.g.
  18244. * @Component({
  18245. * template: `<div>...</div>`,
  18246. * styles: [`h1 { color: blue; }`]
  18247. * })
  18248. */
  18249. function isAngularComponentStyles(path) {
  18250. return isPathMatch(path, [function (node) {
  18251. return node.type === "TemplateLiteral";
  18252. }, function (node, name) {
  18253. return node.type === "ArrayExpression" && name === "elements";
  18254. }, function (node, name) {
  18255. return node.type === "Property" && node.key.type === "Identifier" && node.key.name === "styles" && name === "value";
  18256. }].concat(getAngularComponentObjectExpressionPredicates()));
  18257. }
  18258. function isAngularComponentTemplate(path) {
  18259. return isPathMatch(path, [function (node) {
  18260. return node.type === "TemplateLiteral";
  18261. }, function (node, name) {
  18262. return node.type === "Property" && node.key.type === "Identifier" && node.key.name === "template" && name === "value";
  18263. }].concat(getAngularComponentObjectExpressionPredicates()));
  18264. }
  18265. function getAngularComponentObjectExpressionPredicates() {
  18266. return [function (node, name) {
  18267. return node.type === "ObjectExpression" && name === "properties";
  18268. }, function (node, name) {
  18269. return node.type === "CallExpression" && node.callee.type === "Identifier" && node.callee.name === "Component" && name === "arguments";
  18270. }, function (node, name) {
  18271. return node.type === "Decorator" && name === "expression";
  18272. }];
  18273. }
  18274. /**
  18275. * styled-components template literals
  18276. */
  18277. function isStyledComponents(path) {
  18278. var parent = path.getParentNode();
  18279. if (!parent || parent.type !== "TaggedTemplateExpression") {
  18280. return false;
  18281. }
  18282. var tag = parent.tag;
  18283. switch (tag.type) {
  18284. case "MemberExpression":
  18285. return (// styled.foo``
  18286. isStyledIdentifier(tag.object) || // Component.extend``
  18287. isStyledExtend(tag)
  18288. );
  18289. case "CallExpression":
  18290. return (// styled(Component)``
  18291. isStyledIdentifier(tag.callee) || tag.callee.type === "MemberExpression" && (tag.callee.object.type === "MemberExpression" && ( // styled.foo.attr({})``
  18292. isStyledIdentifier(tag.callee.object.object) || // Component.extend.attr({)``
  18293. isStyledExtend(tag.callee.object)) || // styled(Component).attr({})``
  18294. tag.callee.object.type === "CallExpression" && isStyledIdentifier(tag.callee.object.callee))
  18295. );
  18296. case "Identifier":
  18297. // css``
  18298. return tag.name === "css";
  18299. default:
  18300. return false;
  18301. }
  18302. }
  18303. /**
  18304. * JSX element with CSS prop
  18305. */
  18306. function isCssProp(path) {
  18307. var parent = path.getParentNode();
  18308. var parentParent = path.getParentNode(1);
  18309. return parentParent && parent.type === "JSXExpressionContainer" && parentParent.type === "JSXAttribute" && parentParent.name.type === "JSXIdentifier" && parentParent.name.name === "css";
  18310. }
  18311. function isStyledIdentifier(node) {
  18312. return node.type === "Identifier" && node.name === "styled";
  18313. }
  18314. function isStyledExtend(node) {
  18315. return /^[A-Z]/.test(node.object.name) && node.property.name === "extend";
  18316. }
  18317. /*
  18318. * react-relay and graphql-tag
  18319. * graphql`...`
  18320. * graphql.experimental`...`
  18321. * gql`...`
  18322. * GraphQL comment block
  18323. *
  18324. * This intentionally excludes Relay Classic tags, as Prettier does not
  18325. * support Relay Classic formatting.
  18326. */
  18327. function isGraphQL(path) {
  18328. var node = path.getValue();
  18329. var parent = path.getParentNode();
  18330. return hasLanguageComment(node, "GraphQL") || parent && (parent.type === "TaggedTemplateExpression" && (parent.tag.type === "MemberExpression" && parent.tag.object.name === "graphql" && parent.tag.property.name === "experimental" || parent.tag.type === "Identifier" && (parent.tag.name === "gql" || parent.tag.name === "graphql")) || parent.type === "CallExpression" && parent.callee.type === "Identifier" && parent.callee.name === "graphql");
  18331. }
  18332. function hasLanguageComment(node, languageName) {
  18333. // This checks for a leading comment that is exactly `/* GraphQL */`
  18334. // In order to be in line with other implementations of this comment tag
  18335. // we will not trim the comment value and we will expect exactly one space on
  18336. // either side of the GraphQL string
  18337. // Also see ./clean.js
  18338. return hasLeadingComment$1(node, function (comment) {
  18339. return isBlockComment(comment) && comment.value === " ".concat(languageName, " ");
  18340. });
  18341. }
  18342. function isPathMatch(path, predicateStack) {
  18343. var stack = path.stack.slice();
  18344. var name = null;
  18345. var node = stack.pop();
  18346. var _iteratorNormalCompletion = true;
  18347. var _didIteratorError = false;
  18348. var _iteratorError = undefined;
  18349. try {
  18350. for (var _iterator = predicateStack[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  18351. var predicate = _step.value;
  18352. if (node === undefined) {
  18353. return false;
  18354. } // skip index/array
  18355. if (typeof name === "number") {
  18356. name = stack.pop();
  18357. node = stack.pop();
  18358. }
  18359. if (!predicate(node, name)) {
  18360. return false;
  18361. }
  18362. name = stack.pop();
  18363. node = stack.pop();
  18364. }
  18365. } catch (err) {
  18366. _didIteratorError = true;
  18367. _iteratorError = err;
  18368. } finally {
  18369. try {
  18370. if (!_iteratorNormalCompletion && _iterator.return != null) {
  18371. _iterator.return();
  18372. }
  18373. } finally {
  18374. if (_didIteratorError) {
  18375. throw _iteratorError;
  18376. }
  18377. }
  18378. }
  18379. return true;
  18380. }
  18381. /**
  18382. * - html`...`
  18383. * - HTML comment block
  18384. */
  18385. function isHtml(path) {
  18386. var node = path.getValue();
  18387. return hasLanguageComment(node, "HTML") || isPathMatch(path, [function (node) {
  18388. return node.type === "TemplateLiteral";
  18389. }, function (node, name) {
  18390. return node.type === "TaggedTemplateExpression" && node.tag.type === "Identifier" && node.tag.name === "html" && name === "quasi";
  18391. }]);
  18392. }
  18393. function printHtmlTemplateLiteral(path, print, textToDoc, parser) {
  18394. var node = path.getValue();
  18395. var placeholderPattern = "PRETTIER_HTML_PLACEHOLDER_(\\d+)_IN_JS";
  18396. var placeholders = node.expressions.map(function (_, i) {
  18397. return "PRETTIER_HTML_PLACEHOLDER_".concat(i, "_IN_JS");
  18398. });
  18399. var text = node.quasis.map(function (quasi, index, quasis) {
  18400. return index === quasis.length - 1 ? quasi.value.raw : quasi.value.raw + placeholders[index];
  18401. }).join("");
  18402. var expressionDocs = path.map(print, "expressions");
  18403. if (expressionDocs.length === 0 && text.trim().length === 0) {
  18404. return "``";
  18405. }
  18406. var contentDoc = mapDoc$5(stripTrailingHardline$2(textToDoc(text, {
  18407. parser: parser
  18408. })), function (doc$$2) {
  18409. var placeholderRegex = new RegExp(placeholderPattern, "g");
  18410. var hasPlaceholder = typeof doc$$2 === "string" && placeholderRegex.test(doc$$2);
  18411. if (!hasPlaceholder) {
  18412. return doc$$2;
  18413. }
  18414. var parts = [];
  18415. var components = doc$$2.split(placeholderRegex);
  18416. for (var i = 0; i < components.length; i++) {
  18417. var component = components[i];
  18418. if (i % 2 === 0) {
  18419. if (component) {
  18420. parts.push(component);
  18421. }
  18422. continue;
  18423. }
  18424. var placeholderIndex = +component;
  18425. parts.push(concat$12(["${", group$11(expressionDocs[placeholderIndex]), "}"]));
  18426. }
  18427. return concat$12(parts);
  18428. });
  18429. return group$11(concat$12(["`", indent$7(concat$12([hardline$9, group$11(contentDoc)])), softline$6, "`"]));
  18430. }
  18431. var embed_1$2 = embed$4;
  18432. function clean$7(ast, newObj, parent) {
  18433. ["range", "raw", "comments", "leadingComments", "trailingComments", "extra", "start", "end", "flags"].forEach(function (name) {
  18434. delete newObj[name];
  18435. });
  18436. if (ast.type === "BigIntLiteral") {
  18437. newObj.value = newObj.value.toLowerCase();
  18438. } // We remove extra `;` and add them when needed
  18439. if (ast.type === "EmptyStatement") {
  18440. return null;
  18441. } // We move text around, including whitespaces and add {" "}
  18442. if (ast.type === "JSXText") {
  18443. return null;
  18444. }
  18445. if (ast.type === "JSXExpressionContainer" && ast.expression.type === "Literal" && ast.expression.value === " ") {
  18446. return null;
  18447. } // (TypeScript) Ignore `static` in `constructor(static p) {}`
  18448. // and `export` in `constructor(export p) {}`
  18449. if (ast.type === "TSParameterProperty" && ast.accessibility === null && !ast.readonly) {
  18450. return {
  18451. type: "Identifier",
  18452. name: ast.parameter.name,
  18453. typeAnnotation: newObj.parameter.typeAnnotation,
  18454. decorators: newObj.decorators
  18455. };
  18456. } // (TypeScript) ignore empty `specifiers` array
  18457. if (ast.type === "TSNamespaceExportDeclaration" && ast.specifiers && ast.specifiers.length === 0) {
  18458. delete newObj.specifiers;
  18459. } // (TypeScript) bypass TSParenthesizedType
  18460. if (ast.type === "TSParenthesizedType") {
  18461. return newObj.typeAnnotation;
  18462. } // We convert <div></div> to <div />
  18463. if (ast.type === "JSXOpeningElement") {
  18464. delete newObj.selfClosing;
  18465. }
  18466. if (ast.type === "JSXElement") {
  18467. delete newObj.closingElement;
  18468. } // We change {'key': value} into {key: value}
  18469. 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")) {
  18470. delete newObj.key;
  18471. }
  18472. if (ast.type === "OptionalMemberExpression" && ast.optional === false) {
  18473. newObj.type = "MemberExpression";
  18474. delete newObj.optional;
  18475. } // Remove raw and cooked values from TemplateElement when it's CSS
  18476. // styled-jsx
  18477. if (ast.type === "JSXElement" && ast.openingElement.name.name === "style" && ast.openingElement.attributes.some(function (attr) {
  18478. return attr.name.name === "jsx";
  18479. })) {
  18480. var templateLiterals = newObj.children.filter(function (child) {
  18481. return child.type === "JSXExpressionContainer" && child.expression.type === "TemplateLiteral";
  18482. }).map(function (container) {
  18483. return container.expression;
  18484. });
  18485. var quasis = templateLiterals.reduce(function (quasis, templateLiteral) {
  18486. return quasis.concat(templateLiteral.quasis);
  18487. }, []);
  18488. quasis.forEach(function (q) {
  18489. return delete q.value;
  18490. });
  18491. } // CSS template literals in css prop
  18492. if (ast.type === "JSXAttribute" && ast.name.name === "css" && ast.value.type === "JSXExpressionContainer" && ast.value.expression.type === "TemplateLiteral") {
  18493. newObj.value.expression.quasis.forEach(function (q) {
  18494. return delete q.value;
  18495. });
  18496. } // Angular Components: Inline HTML template and Inline CSS styles
  18497. var expression = ast.expression || ast.callee;
  18498. if (ast.type === "Decorator" && expression.type === "CallExpression" && expression.callee.name === "Component" && expression.arguments.length === 1) {
  18499. var astProps = ast.expression.arguments[0].properties;
  18500. newObj.expression.arguments[0].properties.forEach(function (prop, index) {
  18501. var templateLiteral = null;
  18502. switch (astProps[index].key.name) {
  18503. case "styles":
  18504. if (prop.value.type === "ArrayExpression") {
  18505. templateLiteral = prop.value.elements[0];
  18506. }
  18507. break;
  18508. case "template":
  18509. if (prop.value.type === "TemplateLiteral") {
  18510. templateLiteral = prop.value;
  18511. }
  18512. break;
  18513. }
  18514. if (templateLiteral) {
  18515. templateLiteral.quasis.forEach(function (q) {
  18516. return delete q.value;
  18517. });
  18518. }
  18519. });
  18520. } // styled-components, graphql, markdown
  18521. if (ast.type === "TaggedTemplateExpression" && (ast.tag.type === "MemberExpression" || ast.tag.type === "Identifier" && (ast.tag.name === "gql" || ast.tag.name === "graphql" || ast.tag.name === "css" || ast.tag.name === "md" || ast.tag.name === "markdown" || ast.tag.name === "html") || ast.tag.type === "CallExpression")) {
  18522. newObj.quasi.quasis.forEach(function (quasi) {
  18523. return delete quasi.value;
  18524. });
  18525. }
  18526. if (ast.type === "TemplateLiteral") {
  18527. // This checks for a leading comment that is exactly `/* GraphQL */`
  18528. // In order to be in line with other implementations of this comment tag
  18529. // we will not trim the comment value and we will expect exactly one space on
  18530. // either side of the GraphQL string
  18531. // Also see ./embed.js
  18532. var hasLanguageComment = ast.leadingComments && ast.leadingComments.some(function (comment) {
  18533. return comment.type === "CommentBlock" && ["GraphQL", "HTML"].some(function (languageName) {
  18534. return comment.value === " ".concat(languageName, " ");
  18535. });
  18536. });
  18537. if (hasLanguageComment || parent.type === "CallExpression" && parent.callee.name === "graphql") {
  18538. newObj.quasis.forEach(function (quasi) {
  18539. return delete quasi.value;
  18540. });
  18541. }
  18542. }
  18543. }
  18544. var clean_1$2 = clean$7;
  18545. // Flow annotation comments cannot be split across lines. For example:
  18546. //
  18547. // (this /*
  18548. // : any */).foo = 5;
  18549. //
  18550. // is not picked up by Flow (see https://github.com/facebook/flow/issues/7050), so
  18551. // removing the newline would create a type annotation that the user did not intend
  18552. // to create.
  18553. var NON_LINE_TERMINATING_WHITE_SPACE = "(?:(?=.)\\s)";
  18554. var FLOW_SHORTHAND_ANNOTATION = new RegExp("^".concat(NON_LINE_TERMINATING_WHITE_SPACE, "*:"));
  18555. var FLOW_ANNOTATION = new RegExp("^".concat(NON_LINE_TERMINATING_WHITE_SPACE, "*::"));
  18556. function hasFlowShorthandAnnotationComment$2(node) {
  18557. // https://flow.org/en/docs/types/comments/
  18558. // Syntax example: const r = new (window.Request /*: Class<Request> */)("");
  18559. return node.extra && node.extra.parenthesized && node.trailingComments && node.trailingComments[0].value.match(FLOW_SHORTHAND_ANNOTATION);
  18560. }
  18561. function hasFlowAnnotationComment$1(comments) {
  18562. return comments && comments[0].value.match(FLOW_ANNOTATION);
  18563. }
  18564. function hasNode$1(node, fn) {
  18565. if (!node || _typeof(node) !== "object") {
  18566. return false;
  18567. }
  18568. if (Array.isArray(node)) {
  18569. return node.some(function (value) {
  18570. return hasNode$1(value, fn);
  18571. });
  18572. }
  18573. var result = fn(node);
  18574. return typeof result === "boolean" ? result : Object.keys(node).some(function (key) {
  18575. return hasNode$1(node[key], fn);
  18576. });
  18577. }
  18578. var utils$8 = {
  18579. hasNode: hasNode$1,
  18580. hasFlowShorthandAnnotationComment: hasFlowShorthandAnnotationComment$2,
  18581. hasFlowAnnotationComment: hasFlowAnnotationComment$1
  18582. };
  18583. var hasFlowShorthandAnnotationComment$1 = utils$8.hasFlowShorthandAnnotationComment;
  18584. function hasClosureCompilerTypeCastComment(text, path, locStart, locEnd) {
  18585. // https://github.com/google/closure-compiler/wiki/Annotating-Types#type-casts
  18586. // Syntax example: var x = /** @type {string} */ (fruit);
  18587. var n = path.getValue();
  18588. return util.getNextNonSpaceNonCommentCharacter(text, n, locEnd) === ")" && (hasTypeCastComment(n) || hasAncestorTypeCastComment(0)); // for sub-item: /** @type {array} */ (numberOrString).map(x => x);
  18589. function hasAncestorTypeCastComment(index) {
  18590. var ancestor = path.getParentNode(index);
  18591. return ancestor && util.getNextNonSpaceNonCommentCharacter(text, ancestor, locEnd) !== ")" && /^[\s(]*$/.test(text.slice(locStart(ancestor), locStart(n))) ? hasTypeCastComment(ancestor) || hasAncestorTypeCastComment(index + 1) : false;
  18592. }
  18593. function hasTypeCastComment(node) {
  18594. return node.comments && node.comments.some(function (comment) {
  18595. return comment.leading && comments$3.isBlockComment(comment) && isTypeCastComment(comment.value) && util.getNextNonSpaceNonCommentCharacter(text, comment, locEnd) === "(";
  18596. });
  18597. }
  18598. function isTypeCastComment(comment) {
  18599. var trimmed = comment.trim();
  18600. if (!/^\*\s*@type\s*\{[^]+\}$/.test(trimmed)) {
  18601. return false;
  18602. }
  18603. var isCompletelyClosed = false;
  18604. var unpairedBracketCount = 0;
  18605. var _iteratorNormalCompletion = true;
  18606. var _didIteratorError = false;
  18607. var _iteratorError = undefined;
  18608. try {
  18609. for (var _iterator = trimmed[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  18610. var char = _step.value;
  18611. if (char === "{") {
  18612. if (isCompletelyClosed) {
  18613. return false;
  18614. }
  18615. unpairedBracketCount++;
  18616. } else if (char === "}") {
  18617. if (unpairedBracketCount === 0) {
  18618. return false;
  18619. }
  18620. unpairedBracketCount--;
  18621. if (unpairedBracketCount === 0) {
  18622. isCompletelyClosed = true;
  18623. }
  18624. }
  18625. }
  18626. } catch (err) {
  18627. _didIteratorError = true;
  18628. _iteratorError = err;
  18629. } finally {
  18630. try {
  18631. if (!_iteratorNormalCompletion && _iterator.return != null) {
  18632. _iterator.return();
  18633. }
  18634. } finally {
  18635. if (_didIteratorError) {
  18636. throw _iteratorError;
  18637. }
  18638. }
  18639. }
  18640. return unpairedBracketCount === 0;
  18641. }
  18642. }
  18643. function needsParens(path, options) {
  18644. var parent = path.getParentNode();
  18645. if (!parent) {
  18646. return false;
  18647. }
  18648. var name = path.getName();
  18649. var node = path.getNode(); // If the value of this path is some child of a Node and not a Node
  18650. // itself, then it doesn't need parentheses. Only Node objects (in
  18651. // fact, only Expression nodes) need parentheses.
  18652. if (path.getValue() !== node) {
  18653. return false;
  18654. } // to avoid unexpected `}}` in HTML interpolations
  18655. if (options.__isInHtmlInterpolation && !options.bracketSpacing && endsWithRightBracket(node) && isFollowedByRightBracket(path)) {
  18656. return true;
  18657. } // Only statements don't need parentheses.
  18658. if (isStatement(node)) {
  18659. return false;
  18660. } // Closure compiler requires that type casted expressions to be surrounded by
  18661. // parentheses.
  18662. if (hasClosureCompilerTypeCastComment(options.originalText, path, options.locStart, options.locEnd)) {
  18663. return true;
  18664. }
  18665. if ( // Preserve parens if we have a Flow annotation comment, unless we're using the Flow
  18666. // parser. The Flow parser turns Flow comments into type annotation nodes in its
  18667. // AST, which we handle separately.
  18668. options.parser !== "flow" && hasFlowShorthandAnnotationComment$1(path.getValue())) {
  18669. return true;
  18670. } // Identifiers never need parentheses.
  18671. if (node.type === "Identifier") {
  18672. return false;
  18673. }
  18674. if (parent.type === "ParenthesizedExpression") {
  18675. return false;
  18676. } // Add parens around the extends clause of a class. It is needed for almost
  18677. // all expressions.
  18678. 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")) {
  18679. return true;
  18680. }
  18681. if (parent.type === "Decorator" && parent.expression === node) {
  18682. var hasCallExpression = false;
  18683. var hasMemberExpression = false;
  18684. var current = node;
  18685. while (current) {
  18686. switch (current.type) {
  18687. case "MemberExpression":
  18688. hasMemberExpression = true;
  18689. current = current.object;
  18690. break;
  18691. case "CallExpression":
  18692. if (
  18693. /** @(x().y) */
  18694. hasMemberExpression ||
  18695. /** @(x().y()) */
  18696. hasCallExpression) {
  18697. return true;
  18698. }
  18699. hasCallExpression = true;
  18700. current = current.callee;
  18701. break;
  18702. case "Identifier":
  18703. return false;
  18704. default:
  18705. return true;
  18706. }
  18707. }
  18708. return true;
  18709. }
  18710. if (parent.type === "ArrowFunctionExpression" && parent.body === node && node.type !== "SequenceExpression" && // these have parens added anyway
  18711. util.startsWithNoLookaheadToken(node,
  18712. /* forbidFunctionClassAndDoExpr */
  18713. false) || parent.type === "ExpressionStatement" && util.startsWithNoLookaheadToken(node,
  18714. /* forbidFunctionClassAndDoExpr */
  18715. true)) {
  18716. return true;
  18717. }
  18718. switch (node.type) {
  18719. case "CallExpression":
  18720. {
  18721. var firstParentNotMemberExpression = parent;
  18722. var i = 0;
  18723. while (firstParentNotMemberExpression && firstParentNotMemberExpression.type === "MemberExpression") {
  18724. firstParentNotMemberExpression = path.getParentNode(++i);
  18725. }
  18726. if (firstParentNotMemberExpression.type === "NewExpression" && firstParentNotMemberExpression.callee === path.getParentNode(i - 1)) {
  18727. return true;
  18728. }
  18729. if (parent.type === "BindExpression" && parent.callee === node) {
  18730. return true;
  18731. }
  18732. return false;
  18733. }
  18734. case "SpreadElement":
  18735. case "SpreadProperty":
  18736. return parent.type === "MemberExpression" && name === "object" && parent.object === node;
  18737. case "UpdateExpression":
  18738. if (parent.type === "UnaryExpression") {
  18739. return node.prefix && (node.operator === "++" && parent.operator === "+" || node.operator === "--" && parent.operator === "-");
  18740. }
  18741. // else fallthrough
  18742. case "UnaryExpression":
  18743. switch (parent.type) {
  18744. case "UnaryExpression":
  18745. return node.operator === parent.operator && (node.operator === "+" || node.operator === "-");
  18746. case "BindExpression":
  18747. return true;
  18748. case "MemberExpression":
  18749. return name === "object" && parent.object === node;
  18750. case "TaggedTemplateExpression":
  18751. return true;
  18752. case "NewExpression":
  18753. case "CallExpression":
  18754. return name === "callee" && parent.callee === node;
  18755. case "BinaryExpression":
  18756. return parent.operator === "**" && name === "left";
  18757. case "TSNonNullExpression":
  18758. return true;
  18759. default:
  18760. return false;
  18761. }
  18762. case "BinaryExpression":
  18763. {
  18764. if (parent.type === "UpdateExpression") {
  18765. return true;
  18766. }
  18767. var isLeftOfAForStatement = function isLeftOfAForStatement(node) {
  18768. var i = 0;
  18769. while (node) {
  18770. var _parent = path.getParentNode(i++);
  18771. if (!_parent) {
  18772. return false;
  18773. }
  18774. if (_parent.type === "ForStatement" && _parent.init === node) {
  18775. return true;
  18776. }
  18777. node = _parent;
  18778. }
  18779. return false;
  18780. };
  18781. if (node.operator === "in" && isLeftOfAForStatement(node)) {
  18782. return true;
  18783. }
  18784. }
  18785. // fallthrough
  18786. case "TSTypeAssertion":
  18787. case "TSAsExpression":
  18788. case "LogicalExpression":
  18789. switch (parent.type) {
  18790. case "ConditionalExpression":
  18791. return node.type === "TSAsExpression";
  18792. case "CallExpression":
  18793. case "NewExpression":
  18794. return name === "callee" && parent.callee === node;
  18795. case "ClassExpression":
  18796. case "ClassDeclaration":
  18797. case "TSAbstractClassDeclaration":
  18798. return name === "superClass" && parent.superClass === node;
  18799. case "TSTypeAssertion":
  18800. case "TaggedTemplateExpression":
  18801. case "UnaryExpression":
  18802. case "SpreadElement":
  18803. case "SpreadProperty":
  18804. case "BindExpression":
  18805. case "AwaitExpression":
  18806. case "TSAsExpression":
  18807. case "TSNonNullExpression":
  18808. case "UpdateExpression":
  18809. return true;
  18810. case "MemberExpression":
  18811. case "OptionalMemberExpression":
  18812. return name === "object" && parent.object === node;
  18813. case "AssignmentExpression":
  18814. return parent.left === node && (node.type === "TSTypeAssertion" || node.type === "TSAsExpression");
  18815. case "BinaryExpression":
  18816. case "LogicalExpression":
  18817. {
  18818. if (!node.operator && node.type !== "TSTypeAssertion") {
  18819. return true;
  18820. }
  18821. var po = parent.operator;
  18822. var pp = util.getPrecedence(po);
  18823. var no = node.operator;
  18824. var np = util.getPrecedence(no);
  18825. if (pp > np) {
  18826. return true;
  18827. }
  18828. if ((po === "||" || po === "??") && no === "&&") {
  18829. return true;
  18830. }
  18831. if (pp === np && name === "right") {
  18832. assert$3.strictEqual(parent.right, node);
  18833. return true;
  18834. }
  18835. if (pp === np && !util.shouldFlatten(po, no)) {
  18836. return true;
  18837. }
  18838. if (pp < np && no === "%") {
  18839. return po === "+" || po === "-";
  18840. } // Add parenthesis when working with bitwise operators
  18841. // It's not stricly needed but helps with code understanding
  18842. if (util.isBitwiseOperator(po)) {
  18843. return true;
  18844. }
  18845. return false;
  18846. }
  18847. default:
  18848. return false;
  18849. }
  18850. case "TSParenthesizedType":
  18851. {
  18852. var grandParent = path.getParentNode(1);
  18853. /**
  18854. * const foo = (): (() => void) => (): void => null;
  18855. * ^ ^
  18856. */
  18857. if (getUnparenthesizedNode(node).type === "TSFunctionType" && parent.type === "TSTypeAnnotation" && grandParent.type === "ArrowFunctionExpression" && grandParent.returnType === parent) {
  18858. return true;
  18859. }
  18860. if ((parent.type === "TSTypeParameter" || parent.type === "TypeParameter" || parent.type === "TSTypeAliasDeclaration" || parent.type === "TSTypeAnnotation" || parent.type === "TSParenthesizedType" || parent.type === "TSTypeParameterInstantiation") && grandParent.type !== "TSTypeOperator" && grandParent.type !== "TSOptionalType") {
  18861. return false;
  18862. } // Delegate to inner TSParenthesizedType
  18863. if (node.typeAnnotation.type === "TSParenthesizedType") {
  18864. return false;
  18865. }
  18866. return true;
  18867. }
  18868. case "SequenceExpression":
  18869. switch (parent.type) {
  18870. case "ReturnStatement":
  18871. return false;
  18872. case "ForStatement":
  18873. // Although parentheses wouldn't hurt around sequence
  18874. // expressions in the head of for loops, traditional style
  18875. // dictates that e.g. i++, j++ should not be wrapped with
  18876. // parentheses.
  18877. return false;
  18878. case "ExpressionStatement":
  18879. return name !== "expression";
  18880. case "ArrowFunctionExpression":
  18881. // We do need parentheses, but SequenceExpressions are handled
  18882. // specially when printing bodies of arrow functions.
  18883. return name !== "body";
  18884. default:
  18885. // Otherwise err on the side of overparenthesization, adding
  18886. // explicit exceptions above if this proves overzealous.
  18887. return true;
  18888. }
  18889. case "YieldExpression":
  18890. if (parent.type === "UnaryExpression" || parent.type === "AwaitExpression" || parent.type === "TSAsExpression" || parent.type === "TSNonNullExpression") {
  18891. return true;
  18892. }
  18893. // else fallthrough
  18894. case "AwaitExpression":
  18895. switch (parent.type) {
  18896. case "TaggedTemplateExpression":
  18897. case "UnaryExpression":
  18898. case "BinaryExpression":
  18899. case "LogicalExpression":
  18900. case "SpreadElement":
  18901. case "SpreadProperty":
  18902. case "TSAsExpression":
  18903. case "TSNonNullExpression":
  18904. case "BindExpression":
  18905. return true;
  18906. case "MemberExpression":
  18907. return parent.object === node;
  18908. case "NewExpression":
  18909. case "CallExpression":
  18910. return parent.callee === node;
  18911. case "ConditionalExpression":
  18912. return parent.test === node;
  18913. default:
  18914. return false;
  18915. }
  18916. case "ArrayTypeAnnotation":
  18917. return parent.type === "NullableTypeAnnotation";
  18918. case "IntersectionTypeAnnotation":
  18919. case "UnionTypeAnnotation":
  18920. return parent.type === "ArrayTypeAnnotation" || parent.type === "NullableTypeAnnotation" || parent.type === "IntersectionTypeAnnotation" || parent.type === "UnionTypeAnnotation";
  18921. case "NullableTypeAnnotation":
  18922. return parent.type === "ArrayTypeAnnotation";
  18923. case "FunctionTypeAnnotation":
  18924. {
  18925. var ancestor = parent.type === "NullableTypeAnnotation" ? path.getParentNode(1) : parent;
  18926. return ancestor.type === "UnionTypeAnnotation" || ancestor.type === "IntersectionTypeAnnotation" || ancestor.type === "ArrayTypeAnnotation" || // We should check ancestor's parent to know whether the parentheses
  18927. // are really needed, but since ??T doesn't make sense this check
  18928. // will almost never be true.
  18929. ancestor.type === "NullableTypeAnnotation";
  18930. }
  18931. case "StringLiteral":
  18932. case "NumericLiteral":
  18933. case "Literal":
  18934. if (typeof node.value === "string" && parent.type === "ExpressionStatement" && ( // TypeScript workaround for https://github.com/JamesHenry/typescript-estree/issues/2
  18935. // See corresponding workaround in printer.js case: "Literal"
  18936. options.parser !== "typescript" && !parent.directive || options.parser === "typescript" && options.originalText.substr(options.locStart(node) - 1, 1) === "(")) {
  18937. // To avoid becoming a directive
  18938. var _grandParent = path.getParentNode(1);
  18939. return _grandParent.type === "Program" || _grandParent.type === "BlockStatement";
  18940. }
  18941. return parent.type === "MemberExpression" && typeof node.value === "number" && name === "object" && parent.object === node;
  18942. case "AssignmentExpression":
  18943. {
  18944. var _grandParent2 = path.getParentNode(1);
  18945. if (parent.type === "ArrowFunctionExpression" && parent.body === node) {
  18946. return true;
  18947. } else if (parent.type === "ClassProperty" && parent.key === node && parent.computed) {
  18948. return false;
  18949. } else if (parent.type === "TSPropertySignature" && parent.name === node) {
  18950. return false;
  18951. } else if (parent.type === "ForStatement" && (parent.init === node || parent.update === node)) {
  18952. return false;
  18953. } else if (parent.type === "ExpressionStatement") {
  18954. return node.left.type === "ObjectPattern";
  18955. } else if (parent.type === "TSPropertySignature" && parent.key === node) {
  18956. return false;
  18957. } else if (parent.type === "AssignmentExpression") {
  18958. return false;
  18959. } else if (parent.type === "SequenceExpression" && _grandParent2 && _grandParent2.type === "ForStatement" && (_grandParent2.init === parent || _grandParent2.update === parent)) {
  18960. return false;
  18961. } else if (parent.type === "Property" && parent.value === node) {
  18962. return false;
  18963. } else if (parent.type === "NGChainedExpression") {
  18964. return false;
  18965. }
  18966. return true;
  18967. }
  18968. case "ConditionalExpression":
  18969. switch (parent.type) {
  18970. case "TaggedTemplateExpression":
  18971. case "UnaryExpression":
  18972. case "SpreadElement":
  18973. case "SpreadProperty":
  18974. case "BinaryExpression":
  18975. case "LogicalExpression":
  18976. case "NGPipeExpression":
  18977. case "ExportDefaultDeclaration":
  18978. case "AwaitExpression":
  18979. case "JSXSpreadAttribute":
  18980. case "TSTypeAssertion":
  18981. case "TypeCastExpression":
  18982. case "TSAsExpression":
  18983. case "TSNonNullExpression":
  18984. case "OptionalMemberExpression":
  18985. return true;
  18986. case "NewExpression":
  18987. case "CallExpression":
  18988. return name === "callee" && parent.callee === node;
  18989. case "ConditionalExpression":
  18990. return name === "test" && parent.test === node;
  18991. case "MemberExpression":
  18992. return name === "object" && parent.object === node;
  18993. default:
  18994. return false;
  18995. }
  18996. case "FunctionExpression":
  18997. switch (parent.type) {
  18998. case "CallExpression":
  18999. return name === "callee";
  19000. // Not strictly necessary, but it's clearer to the reader if IIFEs are wrapped in parentheses.
  19001. case "TaggedTemplateExpression":
  19002. return true;
  19003. // This is basically a kind of IIFE.
  19004. case "ExportDefaultDeclaration":
  19005. return true;
  19006. default:
  19007. return false;
  19008. }
  19009. case "ArrowFunctionExpression":
  19010. switch (parent.type) {
  19011. case "CallExpression":
  19012. return name === "callee";
  19013. case "NewExpression":
  19014. return name === "callee";
  19015. case "MemberExpression":
  19016. return name === "object";
  19017. case "TSAsExpression":
  19018. case "BindExpression":
  19019. case "TaggedTemplateExpression":
  19020. case "UnaryExpression":
  19021. case "LogicalExpression":
  19022. case "BinaryExpression":
  19023. case "AwaitExpression":
  19024. case "TSTypeAssertion":
  19025. return true;
  19026. case "ConditionalExpression":
  19027. return name === "test";
  19028. default:
  19029. return false;
  19030. }
  19031. case "ClassExpression":
  19032. return parent.type === "ExportDefaultDeclaration";
  19033. case "OptionalMemberExpression":
  19034. return parent.type === "MemberExpression";
  19035. case "MemberExpression":
  19036. if (parent.type === "BindExpression" && name === "callee" && parent.callee === node) {
  19037. var object = node.object;
  19038. while (object) {
  19039. if (object.type === "CallExpression") {
  19040. return true;
  19041. }
  19042. if (object.type !== "MemberExpression" && object.type !== "BindExpression") {
  19043. break;
  19044. }
  19045. object = object.object;
  19046. }
  19047. }
  19048. return false;
  19049. case "BindExpression":
  19050. if (parent.type === "BindExpression" && name === "callee" && parent.callee === node || parent.type === "MemberExpression") {
  19051. return true;
  19052. }
  19053. return false;
  19054. case "NGPipeExpression":
  19055. if (parent.type === "NGRoot" || parent.type === "ObjectProperty" || parent.type === "ArrayExpression" || (parent.type === "CallExpression" || parent.type === "OptionalCallExpression") && parent.arguments[name] === node || parent.type === "NGPipeExpression" && name === "right" || parent.type === "MemberExpression" && name === "property" || parent.type === "AssignmentExpression") {
  19056. return false;
  19057. }
  19058. return true;
  19059. }
  19060. return false;
  19061. }
  19062. function isStatement(node) {
  19063. 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 === "TSDeclareFunction" || node.type === "TSEnumDeclaration" || node.type === "TSImportEqualsDeclaration" || node.type === "TSInterfaceDeclaration" || node.type === "TSModuleDeclaration" || node.type === "TSNamespaceExportDeclaration" || node.type === "TypeAlias" || node.type === "VariableDeclaration" || node.type === "WhileStatement" || node.type === "WithStatement";
  19064. }
  19065. function getUnparenthesizedNode(node) {
  19066. return node.type === "TSParenthesizedType" ? getUnparenthesizedNode(node.typeAnnotation) : node;
  19067. }
  19068. function endsWithRightBracket(node) {
  19069. switch (node.type) {
  19070. case "ObjectExpression":
  19071. return true;
  19072. default:
  19073. return false;
  19074. }
  19075. }
  19076. function isFollowedByRightBracket(path) {
  19077. var node = path.getValue();
  19078. var parent = path.getParentNode();
  19079. var name = path.getName();
  19080. switch (parent.type) {
  19081. case "NGPipeExpression":
  19082. if (typeof name === "number" && parent.arguments[name] === node && parent.arguments.length - 1 === name) {
  19083. return path.callParent(isFollowedByRightBracket);
  19084. }
  19085. break;
  19086. case "ObjectProperty":
  19087. if (name === "value") {
  19088. var parentParent = path.getParentNode(1);
  19089. return parentParent.properties[parentParent.properties.length - 1] === parent;
  19090. }
  19091. break;
  19092. case "BinaryExpression":
  19093. case "LogicalExpression":
  19094. if (name === "right") {
  19095. return path.callParent(isFollowedByRightBracket);
  19096. }
  19097. break;
  19098. case "ConditionalExpression":
  19099. if (name === "alternate") {
  19100. return path.callParent(isFollowedByRightBracket);
  19101. }
  19102. break;
  19103. case "UnaryExpression":
  19104. if (parent.prefix) {
  19105. return path.callParent(isFollowedByRightBracket);
  19106. }
  19107. break;
  19108. }
  19109. return false;
  19110. }
  19111. var needsParens_1 = needsParens;
  19112. var _require$$0$builders$6 = doc.builders;
  19113. var concat$13 = _require$$0$builders$6.concat;
  19114. var join$9 = _require$$0$builders$6.join;
  19115. var line$9 = _require$$0$builders$6.line;
  19116. function printHtmlBinding$1(path, options, print) {
  19117. var node = path.getValue();
  19118. if (options.__onHtmlBindingRoot && path.getName() === null) {
  19119. options.__onHtmlBindingRoot(node);
  19120. }
  19121. if (node.type !== "File") {
  19122. return;
  19123. }
  19124. if (options.__isVueForBindingLeft) {
  19125. return path.call(function (functionDeclarationPath) {
  19126. var _functionDeclarationP = functionDeclarationPath.getValue(),
  19127. params = _functionDeclarationP.params;
  19128. return concat$13([params.length > 1 ? "(" : "", join$9(concat$13([",", line$9]), functionDeclarationPath.map(print, "params")), params.length > 1 ? ")" : ""]);
  19129. }, "program", "body", 0);
  19130. }
  19131. if (options.__isVueSlotScope) {
  19132. return path.call(function (functionDeclarationPath) {
  19133. return join$9(concat$13([",", line$9]), functionDeclarationPath.map(print, "params"));
  19134. }, "program", "body", 0);
  19135. }
  19136. } // based on https://github.com/prettier/prettier/blob/master/src/language-html/syntax-vue.js isVueEventBindingExpression()
  19137. function isVueEventBindingExpression$3(node) {
  19138. switch (node.type) {
  19139. case "MemberExpression":
  19140. switch (node.property.type) {
  19141. case "Identifier":
  19142. case "NumericLiteral":
  19143. case "StringLiteral":
  19144. return isVueEventBindingExpression$3(node.object);
  19145. }
  19146. return false;
  19147. case "Identifier":
  19148. return true;
  19149. default:
  19150. return false;
  19151. }
  19152. }
  19153. var htmlBinding = {
  19154. isVueEventBindingExpression: isVueEventBindingExpression$3,
  19155. printHtmlBinding: printHtmlBinding$1
  19156. };
  19157. function preprocess$2(ast, options) {
  19158. switch (options.parser) {
  19159. case "json":
  19160. case "json5":
  19161. case "json-stringify":
  19162. case "__js_expression":
  19163. case "__vue_expression":
  19164. return Object.assign({}, ast, {
  19165. type: options.parser.startsWith("__") ? "JsExpressionRoot" : "JsonRoot",
  19166. node: ast,
  19167. comments: []
  19168. });
  19169. default:
  19170. return ast;
  19171. }
  19172. }
  19173. var preprocess_1$2 = preprocess$2;
  19174. var getParentExportDeclaration$1 = util.getParentExportDeclaration;
  19175. var isExportDeclaration$1 = util.isExportDeclaration;
  19176. var shouldFlatten$1 = util.shouldFlatten;
  19177. var getNextNonSpaceNonCommentCharacter$1 = util.getNextNonSpaceNonCommentCharacter;
  19178. var hasNewline$3 = util.hasNewline;
  19179. var hasNewlineInRange$1 = util.hasNewlineInRange;
  19180. var getLast$4 = util.getLast;
  19181. var getStringWidth$2 = util.getStringWidth;
  19182. var printString$2 = util.printString;
  19183. var printNumber$2 = util.printNumber;
  19184. var hasIgnoreComment$3 = util.hasIgnoreComment;
  19185. var skipWhitespace$1 = util.skipWhitespace;
  19186. var hasNodeIgnoreComment$1 = util.hasNodeIgnoreComment;
  19187. var getPenultimate$1 = util.getPenultimate;
  19188. var startsWithNoLookaheadToken$1 = util.startsWithNoLookaheadToken;
  19189. var getIndentSize$1 = util.getIndentSize;
  19190. var matchAncestorTypes$1 = util.matchAncestorTypes;
  19191. var getPreferredQuote$1 = util.getPreferredQuote;
  19192. var isNextLineEmpty$4 = utilShared.isNextLineEmpty;
  19193. var isNextLineEmptyAfterIndex$1 = utilShared.isNextLineEmptyAfterIndex;
  19194. var getNextNonSpaceNonCommentCharacterIndex$2 = utilShared.getNextNonSpaceNonCommentCharacterIndex;
  19195. var isIdentifierName = utils$2.keyword.isIdentifierNameES5;
  19196. var insertPragma$7 = pragma$2.insertPragma;
  19197. var printHtmlBinding = htmlBinding.printHtmlBinding;
  19198. var isVueEventBindingExpression$2 = htmlBinding.isVueEventBindingExpression;
  19199. var hasNode = utils$8.hasNode;
  19200. var hasFlowAnnotationComment = utils$8.hasFlowAnnotationComment;
  19201. var hasFlowShorthandAnnotationComment = utils$8.hasFlowShorthandAnnotationComment;
  19202. var _require$$6$builders = doc.builders;
  19203. var concat$11 = _require$$6$builders.concat;
  19204. var join$7 = _require$$6$builders.join;
  19205. var line$8 = _require$$6$builders.line;
  19206. var hardline$8 = _require$$6$builders.hardline;
  19207. var softline$5 = _require$$6$builders.softline;
  19208. var literalline$3 = _require$$6$builders.literalline;
  19209. var group$10 = _require$$6$builders.group;
  19210. var indent$6 = _require$$6$builders.indent;
  19211. var align$1 = _require$$6$builders.align;
  19212. var conditionalGroup$1 = _require$$6$builders.conditionalGroup;
  19213. var fill$4 = _require$$6$builders.fill;
  19214. var ifBreak$6 = _require$$6$builders.ifBreak;
  19215. var breakParent$3 = _require$$6$builders.breakParent;
  19216. var lineSuffixBoundary$1 = _require$$6$builders.lineSuffixBoundary;
  19217. var addAlignmentToDoc$2 = _require$$6$builders.addAlignmentToDoc;
  19218. var dedent$3 = _require$$6$builders.dedent;
  19219. var _require$$6$utils = doc.utils;
  19220. var willBreak$1 = _require$$6$utils.willBreak;
  19221. var isLineNext$1 = _require$$6$utils.isLineNext;
  19222. var isEmpty$1 = _require$$6$utils.isEmpty;
  19223. var removeLines$2 = _require$$6$utils.removeLines;
  19224. var printDocToString$1 = doc.printer.printDocToString;
  19225. var uid = 0;
  19226. function shouldPrintComma$1(options, level) {
  19227. level = level || "es5";
  19228. switch (options.trailingComma) {
  19229. case "all":
  19230. if (level === "all") {
  19231. return true;
  19232. }
  19233. // fallthrough
  19234. case "es5":
  19235. if (level === "es5") {
  19236. return true;
  19237. }
  19238. // fallthrough
  19239. case "none":
  19240. default:
  19241. return false;
  19242. }
  19243. }
  19244. function genericPrint$3(path, options, printPath, args) {
  19245. var node = path.getValue();
  19246. var needsParens = false;
  19247. var linesWithoutParens = printPathNoParens(path, options, printPath, args);
  19248. if (!node || isEmpty$1(linesWithoutParens)) {
  19249. return linesWithoutParens;
  19250. }
  19251. var parentExportDecl = getParentExportDeclaration$1(path);
  19252. var decorators = [];
  19253. if (node.type === "ClassMethod" || node.type === "ClassPrivateMethod" || node.type === "ClassProperty" || node.type === "TSAbstractClassProperty" || node.type === "ClassPrivateProperty" || node.type === "MethodDefinition" || node.type === "TSAbstractMethodDefinition") {// their decorators are handled themselves
  19254. } else if (node.decorators && node.decorators.length > 0 && // If the parent node is an export declaration and the decorator
  19255. // was written before the export, the export will be responsible
  19256. // for printing the decorators.
  19257. !(parentExportDecl && options.locStart(parentExportDecl, {
  19258. ignoreDecorators: true
  19259. }) > options.locStart(node.decorators[0]))) {
  19260. var shouldBreak = node.type === "ClassExpression" || node.type === "ClassDeclaration" || hasNewlineBetweenOrAfterDecorators(node, options);
  19261. var separator = shouldBreak ? hardline$8 : line$8;
  19262. path.each(function (decoratorPath) {
  19263. var decorator = decoratorPath.getValue();
  19264. if (decorator.expression) {
  19265. decorator = decorator.expression;
  19266. } else {
  19267. decorator = decorator.callee;
  19268. }
  19269. decorators.push(printPath(decoratorPath), separator);
  19270. }, "decorators");
  19271. if (parentExportDecl) {
  19272. decorators.unshift(hardline$8);
  19273. }
  19274. } else if (isExportDeclaration$1(node) && node.declaration && node.declaration.decorators && node.declaration.decorators.length > 0 && // Only print decorators here if they were written before the export,
  19275. // otherwise they are printed by the node.declaration
  19276. options.locStart(node, {
  19277. ignoreDecorators: true
  19278. }) > options.locStart(node.declaration.decorators[0])) {
  19279. // Export declarations are responsible for printing any decorators
  19280. // that logically apply to node.declaration.
  19281. path.each(function (decoratorPath) {
  19282. var decorator = decoratorPath.getValue();
  19283. var prefix = decorator.type === "Decorator" ? "" : "@";
  19284. decorators.push(prefix, printPath(decoratorPath), hardline$8);
  19285. }, "declaration", "decorators");
  19286. } else {
  19287. // Nodes with decorators can't have parentheses, so we can avoid
  19288. // computing pathNeedsParens() except in this case.
  19289. needsParens = needsParens_1(path, options);
  19290. }
  19291. var parts = [];
  19292. if (needsParens) {
  19293. parts.unshift("(");
  19294. }
  19295. parts.push(linesWithoutParens);
  19296. if (needsParens) {
  19297. var _node = path.getValue();
  19298. if (hasFlowShorthandAnnotationComment(_node)) {
  19299. parts.push(" /*");
  19300. parts.push(_node.trailingComments[0].value.trimLeft());
  19301. parts.push("*/");
  19302. _node.trailingComments[0].printed = true;
  19303. }
  19304. parts.push(")");
  19305. }
  19306. if (decorators.length > 0) {
  19307. return group$10(concat$11(decorators.concat(parts)));
  19308. }
  19309. return concat$11(parts);
  19310. }
  19311. function hasNewlineBetweenOrAfterDecorators(node, options) {
  19312. return hasNewlineInRange$1(options.originalText, options.locStart(node.decorators[0]), options.locEnd(getLast$4(node.decorators))) || hasNewline$3(options.originalText, options.locEnd(getLast$4(node.decorators)));
  19313. }
  19314. function printDecorators(path, options, print) {
  19315. var node = path.getValue();
  19316. return group$10(concat$11([join$7(line$8, path.map(print, "decorators")), hasNewlineBetweenOrAfterDecorators(node, options) ? hardline$8 : line$8]));
  19317. }
  19318. function hasPrettierIgnore$2(path) {
  19319. return hasIgnoreComment$3(path) || hasJsxIgnoreComment(path);
  19320. }
  19321. function hasJsxIgnoreComment(path) {
  19322. var node = path.getValue();
  19323. var parent = path.getParentNode();
  19324. if (!parent || !node || !isJSXNode(node) || !isJSXNode(parent)) {
  19325. return false;
  19326. } // Lookup the previous sibling, ignoring any empty JSXText elements
  19327. var index = parent.children.indexOf(node);
  19328. var prevSibling = null;
  19329. for (var i = index; i > 0; i--) {
  19330. var candidate = parent.children[i - 1];
  19331. if (candidate.type === "JSXText" && !isMeaningfulJSXText(candidate)) {
  19332. continue;
  19333. }
  19334. prevSibling = candidate;
  19335. break;
  19336. }
  19337. return prevSibling && prevSibling.type === "JSXExpressionContainer" && prevSibling.expression.type === "JSXEmptyExpression" && prevSibling.expression.comments && prevSibling.expression.comments.find(function (comment) {
  19338. return comment.value.trim() === "prettier-ignore";
  19339. });
  19340. }
  19341. /**
  19342. * The following is the shared logic for
  19343. * ternary operators, namely ConditionalExpression
  19344. * and TSConditionalType
  19345. * @typedef {Object} OperatorOptions
  19346. * @property {() => Array<string | Doc>} beforeParts - Parts to print before the `?`.
  19347. * @property {(breakClosingParen: boolean) => Array<string | Doc>} afterParts - Parts to print after the conditional expression.
  19348. * @property {boolean} shouldCheckJsx - Whether to check for and print in JSX mode.
  19349. * @property {string} conditionalNodeType - The type of the conditional expression node, ie "ConditionalExpression" or "TSConditionalType".
  19350. * @property {string} consequentNodePropertyName - The property at which the consequent node can be found on the main node, eg "consequent".
  19351. * @property {string} alternateNodePropertyName - The property at which the alternate node can be found on the main node, eg "alternate".
  19352. * @property {string} testNodePropertyName - The property at which the test node can be found on the main node, eg "test".
  19353. * @property {boolean} breakNested - Whether to break all nested ternaries when one breaks.
  19354. * @param {FastPath} path - The path to the ConditionalExpression/TSConditionalType node.
  19355. * @param {Options} options - Prettier options
  19356. * @param {Function} print - Print function to call recursively
  19357. * @param {OperatorOptions} operatorOptions
  19358. * @returns Doc
  19359. */
  19360. function printTernaryOperator(path, options, print, operatorOptions) {
  19361. var node = path.getValue();
  19362. var testNode = node[operatorOptions.testNodePropertyName];
  19363. var consequentNode = node[operatorOptions.consequentNodePropertyName];
  19364. var alternateNode = node[operatorOptions.alternateNodePropertyName];
  19365. var parts = []; // We print a ConditionalExpression in either "JSX mode" or "normal mode".
  19366. // See tests/jsx/conditional-expression.js for more info.
  19367. var jsxMode = false;
  19368. var parent = path.getParentNode();
  19369. var forceNoIndent = parent.type === operatorOptions.conditionalNodeType; // Find the outermost non-ConditionalExpression parent, and the outermost
  19370. // ConditionalExpression parent. We'll use these to determine if we should
  19371. // print in JSX mode.
  19372. var currentParent;
  19373. var previousParent;
  19374. var i = 0;
  19375. do {
  19376. previousParent = currentParent || node;
  19377. currentParent = path.getParentNode(i);
  19378. i++;
  19379. } while (currentParent && currentParent.type === operatorOptions.conditionalNodeType);
  19380. var firstNonConditionalParent = currentParent || parent;
  19381. var lastConditionalParent = previousParent;
  19382. if (operatorOptions.shouldCheckJsx && (isJSXNode(testNode) || isJSXNode(consequentNode) || isJSXNode(alternateNode) || conditionalExpressionChainContainsJSX(lastConditionalParent))) {
  19383. jsxMode = true;
  19384. forceNoIndent = true; // Even though they don't need parens, we wrap (almost) everything in
  19385. // parens when using ?: within JSX, because the parens are analogous to
  19386. // curly braces in an if statement.
  19387. var wrap = function wrap(doc$$2) {
  19388. return concat$11([ifBreak$6("(", ""), indent$6(concat$11([softline$5, doc$$2])), softline$5, ifBreak$6(")", "")]);
  19389. }; // The only things we don't wrap are:
  19390. // * Nested conditional expressions in alternates
  19391. // * null
  19392. var isNull = function isNull(node) {
  19393. return node.type === "NullLiteral" || node.type === "Literal" && node.value === null;
  19394. };
  19395. parts.push(" ? ", isNull(consequentNode) ? path.call(print, operatorOptions.consequentNodePropertyName) : wrap(path.call(print, operatorOptions.consequentNodePropertyName)), " : ", alternateNode.type === operatorOptions.conditionalNodeType || isNull(alternateNode) ? path.call(print, operatorOptions.alternateNodePropertyName) : wrap(path.call(print, operatorOptions.alternateNodePropertyName)));
  19396. } else {
  19397. // normal mode
  19398. var part = concat$11([line$8, "? ", consequentNode.type === operatorOptions.conditionalNodeType ? ifBreak$6("", "(") : "", align$1(2, path.call(print, operatorOptions.consequentNodePropertyName)), consequentNode.type === operatorOptions.conditionalNodeType ? ifBreak$6("", ")") : "", line$8, ": ", alternateNode.type === operatorOptions.conditionalNodeType ? path.call(print, operatorOptions.alternateNodePropertyName) : align$1(2, path.call(print, operatorOptions.alternateNodePropertyName))]);
  19399. parts.push(parent.type !== operatorOptions.conditionalNodeType || parent[operatorOptions.alternateNodePropertyName] === node ? part : options.useTabs ? dedent$3(indent$6(part)) : align$1(Math.max(0, options.tabWidth - 2), part));
  19400. } // We want a whole chain of ConditionalExpressions to all
  19401. // break if any of them break. That means we should only group around the
  19402. // outer-most ConditionalExpression.
  19403. var maybeGroup = function maybeGroup(doc$$2) {
  19404. return operatorOptions.breakNested ? parent === firstNonConditionalParent ? group$10(doc$$2) : doc$$2 : group$10(doc$$2);
  19405. }; // Break the closing paren to keep the chain right after it:
  19406. // (a
  19407. // ? b
  19408. // : c
  19409. // ).call()
  19410. var breakClosingParen = !jsxMode && (parent.type === "MemberExpression" || parent.type === "OptionalMemberExpression") && !parent.computed;
  19411. return maybeGroup(concat$11([].concat(function (testDoc) {
  19412. return (
  19413. /**
  19414. * a
  19415. * ? b
  19416. * : multiline
  19417. * test
  19418. * node
  19419. * ^^ align(2)
  19420. * ? d
  19421. * : e
  19422. */
  19423. parent.type === operatorOptions.conditionalNodeType && parent[operatorOptions.alternateNodePropertyName] === node ? align$1(2, testDoc) : testDoc
  19424. );
  19425. }(concat$11(operatorOptions.beforeParts())), forceNoIndent ? concat$11(parts) : indent$6(concat$11(parts)), operatorOptions.afterParts(breakClosingParen))));
  19426. }
  19427. function getTypeScriptMappedTypeModifier(tokenNode, keyword) {
  19428. if (tokenNode === "+") {
  19429. return "+" + keyword;
  19430. } else if (tokenNode === "-") {
  19431. return "-" + keyword;
  19432. }
  19433. return keyword;
  19434. }
  19435. function printPathNoParens(path, options, print, args) {
  19436. var n = path.getValue();
  19437. var semi = options.semi ? ";" : "";
  19438. if (!n) {
  19439. return "";
  19440. }
  19441. if (typeof n === "string") {
  19442. return n;
  19443. }
  19444. var htmlBinding$$1 = printHtmlBinding(path, options, print);
  19445. if (htmlBinding$$1) {
  19446. return htmlBinding$$1;
  19447. }
  19448. var parts = [];
  19449. switch (n.type) {
  19450. case "JsExpressionRoot":
  19451. return path.call(print, "node");
  19452. case "JsonRoot":
  19453. return concat$11([path.call(print, "node"), hardline$8]);
  19454. case "File":
  19455. // Print @babel/parser's InterpreterDirective here so that
  19456. // leading comments on the `Program` node get printed after the hashbang.
  19457. if (n.program && n.program.interpreter) {
  19458. parts.push(path.call(function (programPath) {
  19459. return programPath.call(print, "interpreter");
  19460. }, "program"));
  19461. }
  19462. parts.push(path.call(print, "program"));
  19463. return concat$11(parts);
  19464. case "Program":
  19465. // Babel 6
  19466. if (n.directives) {
  19467. path.each(function (childPath) {
  19468. parts.push(print(childPath), semi, hardline$8);
  19469. if (isNextLineEmpty$4(options.originalText, childPath.getValue(), options)) {
  19470. parts.push(hardline$8);
  19471. }
  19472. }, "directives");
  19473. }
  19474. parts.push(path.call(function (bodyPath) {
  19475. return printStatementSequence(bodyPath, options, print);
  19476. }, "body"));
  19477. parts.push(comments.printDanglingComments(path, options,
  19478. /* sameIndent */
  19479. true)); // Only force a trailing newline if there were any contents.
  19480. if (n.body.length || n.comments) {
  19481. parts.push(hardline$8);
  19482. }
  19483. return concat$11(parts);
  19484. // Babel extension.
  19485. case "EmptyStatement":
  19486. return "";
  19487. case "ExpressionStatement":
  19488. // Detect Flow-parsed directives
  19489. if (n.directive) {
  19490. return concat$11([nodeStr(n.expression, options, true), semi]);
  19491. }
  19492. if (options.parser === "__vue_event_binding") {
  19493. var parent = path.getParentNode();
  19494. if (parent.type === "Program" && parent.body.length === 1 && parent.body[0] === n) {
  19495. return concat$11([path.call(print, "expression"), isVueEventBindingExpression$2(n.expression) ? ";" : ""]);
  19496. }
  19497. } // Do not append semicolon after the only JSX element in a program
  19498. return concat$11([path.call(print, "expression"), isTheOnlyJSXElementInMarkdown(options, path) ? "" : semi]);
  19499. // Babel extension.
  19500. case "ParenthesizedExpression":
  19501. return concat$11(["(", path.call(print, "expression"), ")"]);
  19502. case "AssignmentExpression":
  19503. return printAssignment(n.left, path.call(print, "left"), concat$11([" ", n.operator]), n.right, path.call(print, "right"), options);
  19504. case "BinaryExpression":
  19505. case "LogicalExpression":
  19506. case "NGPipeExpression":
  19507. {
  19508. var _parent = path.getParentNode();
  19509. var parentParent = path.getParentNode(1);
  19510. var isInsideParenthesis = n !== _parent.body && (_parent.type === "IfStatement" || _parent.type === "WhileStatement" || _parent.type === "DoWhileStatement");
  19511. var _parts = printBinaryishExpressions(path, print, options,
  19512. /* isNested */
  19513. false, isInsideParenthesis); // if (
  19514. // this.hasPlugin("dynamicImports") && this.lookahead().type === tt.parenLeft
  19515. // ) {
  19516. //
  19517. // looks super weird, we want to break the children if the parent breaks
  19518. //
  19519. // if (
  19520. // this.hasPlugin("dynamicImports") &&
  19521. // this.lookahead().type === tt.parenLeft
  19522. // ) {
  19523. if (isInsideParenthesis) {
  19524. return concat$11(_parts);
  19525. } // Break between the parens in unaries or in a member expression, i.e.
  19526. //
  19527. // (
  19528. // a &&
  19529. // b &&
  19530. // c
  19531. // ).call()
  19532. if (_parent.type === "UnaryExpression" || (_parent.type === "MemberExpression" || _parent.type === "OptionalMemberExpression") && !_parent.computed) {
  19533. return group$10(concat$11([indent$6(concat$11([softline$5, concat$11(_parts)])), softline$5]));
  19534. } // Avoid indenting sub-expressions in some cases where the first sub-expression is already
  19535. // indented accordingly. We should indent sub-expressions where the first case isn't indented.
  19536. var shouldNotIndent = _parent.type === "ReturnStatement" || _parent.type === "JSXExpressionContainer" && parentParent.type === "JSXAttribute" || n.type !== "NGPipeExpression" && (_parent.type === "NGRoot" && options.parser === "__ng_binding" || _parent.type === "NGMicrosyntaxExpression" && parentParent.type === "NGMicrosyntax" && parentParent.body.length === 1) || n === _parent.body && _parent.type === "ArrowFunctionExpression" || n !== _parent.body && _parent.type === "ForStatement" || _parent.type === "ConditionalExpression" && parentParent.type !== "ReturnStatement" && parentParent.type !== "CallExpression";
  19537. var shouldIndentIfInlining = _parent.type === "AssignmentExpression" || _parent.type === "VariableDeclarator" || _parent.type === "ClassProperty" || _parent.type === "TSAbstractClassProperty" || _parent.type === "ClassPrivateProperty" || _parent.type === "ObjectProperty" || _parent.type === "Property";
  19538. var samePrecedenceSubExpression = isBinaryish(n.left) && shouldFlatten$1(n.operator, n.left.operator);
  19539. if (shouldNotIndent || shouldInlineLogicalExpression(n) && !samePrecedenceSubExpression || !shouldInlineLogicalExpression(n) && shouldIndentIfInlining) {
  19540. return group$10(concat$11(_parts));
  19541. }
  19542. if (_parts.length === 0) {
  19543. return "";
  19544. } // If the right part is a JSX node, we include it in a separate group to
  19545. // prevent it breaking the whole chain, so we can print the expression like:
  19546. //
  19547. // foo && bar && (
  19548. // <Foo>
  19549. // <Bar />
  19550. // </Foo>
  19551. // )
  19552. var hasJSX = isJSXNode(n.right);
  19553. var rest = concat$11(hasJSX ? _parts.slice(1, -1) : _parts.slice(1));
  19554. var groupId = Symbol("logicalChain-" + ++uid);
  19555. var chain = group$10(concat$11([// Don't include the initial expression in the indentation
  19556. // level. The first item is guaranteed to be the first
  19557. // left-most expression.
  19558. _parts.length > 0 ? _parts[0] : "", indent$6(rest)]), {
  19559. id: groupId
  19560. });
  19561. if (!hasJSX) {
  19562. return chain;
  19563. }
  19564. var jsxPart = getLast$4(_parts);
  19565. return group$10(concat$11([chain, ifBreak$6(indent$6(jsxPart), jsxPart, {
  19566. groupId: groupId
  19567. })]));
  19568. }
  19569. case "AssignmentPattern":
  19570. return concat$11([path.call(print, "left"), " = ", path.call(print, "right")]);
  19571. case "TSTypeAssertion":
  19572. {
  19573. var shouldBreakAfterCast = !(n.expression.type === "ArrayExpression" || n.expression.type === "ObjectExpression");
  19574. var castGroup = group$10(concat$11(["<", indent$6(concat$11([softline$5, path.call(print, "typeAnnotation")])), softline$5, ">"]));
  19575. var exprContents = concat$11([ifBreak$6("("), indent$6(concat$11([softline$5, path.call(print, "expression")])), softline$5, ifBreak$6(")")]);
  19576. if (shouldBreakAfterCast) {
  19577. return conditionalGroup$1([concat$11([castGroup, path.call(print, "expression")]), concat$11([castGroup, group$10(exprContents, {
  19578. shouldBreak: true
  19579. })]), concat$11([castGroup, path.call(print, "expression")])]);
  19580. }
  19581. return group$10(concat$11([castGroup, path.call(print, "expression")]));
  19582. }
  19583. case "OptionalMemberExpression":
  19584. case "MemberExpression":
  19585. {
  19586. var _parent2 = path.getParentNode();
  19587. var firstNonMemberParent;
  19588. var i = 0;
  19589. do {
  19590. firstNonMemberParent = path.getParentNode(i);
  19591. i++;
  19592. } while (firstNonMemberParent && (firstNonMemberParent.type === "MemberExpression" || firstNonMemberParent.type === "OptionalMemberExpression" || firstNonMemberParent.type === "TSNonNullExpression"));
  19593. var shouldInline = firstNonMemberParent && (firstNonMemberParent.type === "NewExpression" || firstNonMemberParent.type === "BindExpression" || firstNonMemberParent.type === "VariableDeclarator" && firstNonMemberParent.id.type !== "Identifier" || firstNonMemberParent.type === "AssignmentExpression" && firstNonMemberParent.left.type !== "Identifier") || n.computed || n.object.type === "Identifier" && n.property.type === "Identifier" && _parent2.type !== "MemberExpression" && _parent2.type !== "OptionalMemberExpression";
  19594. return concat$11([path.call(print, "object"), shouldInline ? printMemberLookup(path, options, print) : group$10(indent$6(concat$11([softline$5, printMemberLookup(path, options, print)])))]);
  19595. }
  19596. case "MetaProperty":
  19597. return concat$11([path.call(print, "meta"), ".", path.call(print, "property")]);
  19598. case "BindExpression":
  19599. if (n.object) {
  19600. parts.push(path.call(print, "object"));
  19601. }
  19602. parts.push(group$10(indent$6(concat$11([softline$5, printBindExpressionCallee(path, options, print)]))));
  19603. return concat$11(parts);
  19604. case "Identifier":
  19605. {
  19606. return concat$11([n.name, printOptionalToken(path), printTypeAnnotation(path, options, print)]);
  19607. }
  19608. case "SpreadElement":
  19609. case "SpreadElementPattern":
  19610. case "RestProperty":
  19611. case "SpreadProperty":
  19612. case "SpreadPropertyPattern":
  19613. case "RestElement":
  19614. case "ObjectTypeSpreadProperty":
  19615. return concat$11(["...", path.call(print, "argument"), printTypeAnnotation(path, options, print)]);
  19616. case "FunctionDeclaration":
  19617. case "FunctionExpression":
  19618. parts.push(printFunctionDeclaration(path, print, options));
  19619. if (!n.body) {
  19620. parts.push(semi);
  19621. }
  19622. return concat$11(parts);
  19623. case "ArrowFunctionExpression":
  19624. {
  19625. if (n.async) {
  19626. parts.push("async ");
  19627. }
  19628. if (shouldPrintParamsWithoutParens(path, options)) {
  19629. parts.push(path.call(print, "params", 0));
  19630. } else {
  19631. parts.push(group$10(concat$11([printFunctionParams(path, print, options,
  19632. /* expandLast */
  19633. args && (args.expandLastArg || args.expandFirstArg),
  19634. /* printTypeParams */
  19635. true), printReturnType(path, print, options)])));
  19636. }
  19637. var dangling = comments.printDanglingComments(path, options,
  19638. /* sameIndent */
  19639. true, function (comment) {
  19640. var nextCharacter = getNextNonSpaceNonCommentCharacterIndex$2(options.originalText, comment, options);
  19641. return options.originalText.substr(nextCharacter, 2) === "=>";
  19642. });
  19643. if (dangling) {
  19644. parts.push(" ", dangling);
  19645. }
  19646. parts.push(" =>");
  19647. var body = path.call(function (bodyPath) {
  19648. return print(bodyPath, args);
  19649. }, "body"); // We want to always keep these types of nodes on the same line
  19650. // as the arrow.
  19651. 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")) {
  19652. return group$10(concat$11([concat$11(parts), " ", body]));
  19653. } // We handle sequence expressions as the body of arrows specially,
  19654. // so that the required parentheses end up on their own lines.
  19655. if (n.body.type === "SequenceExpression") {
  19656. return group$10(concat$11([concat$11(parts), group$10(concat$11([" (", indent$6(concat$11([softline$5, body])), softline$5, ")"]))]));
  19657. } // if the arrow function is expanded as last argument, we are adding a
  19658. // level of indentation and need to add a softline to align the closing )
  19659. // with the opening (, or if it's inside a JSXExpression (e.g. an attribute)
  19660. // we should align the expression's closing } with the line with the opening {.
  19661. var shouldAddSoftLine = (args && args.expandLastArg || path.getParentNode().type === "JSXExpressionContainer") && !(n.comments && n.comments.length);
  19662. var printTrailingComma = args && args.expandLastArg && shouldPrintComma$1(options, "all"); // In order to avoid confusion between
  19663. // a => a ? a : a
  19664. // a <= a ? a : a
  19665. var shouldAddParens = n.body.type === "ConditionalExpression" && !startsWithNoLookaheadToken$1(n.body,
  19666. /* forbidFunctionAndClass */
  19667. false);
  19668. return group$10(concat$11([concat$11(parts), group$10(concat$11([indent$6(concat$11([line$8, shouldAddParens ? ifBreak$6("", "(") : "", body, shouldAddParens ? ifBreak$6("", ")") : ""])), shouldAddSoftLine ? concat$11([ifBreak$6(printTrailingComma ? "," : ""), softline$5]) : ""]))]));
  19669. }
  19670. case "MethodDefinition":
  19671. case "TSAbstractMethodDefinition":
  19672. if (n.decorators && n.decorators.length !== 0) {
  19673. parts.push(printDecorators(path, options, print));
  19674. }
  19675. if (n.accessibility) {
  19676. parts.push(n.accessibility + " ");
  19677. }
  19678. if (n.static) {
  19679. parts.push("static ");
  19680. }
  19681. if (n.type === "TSAbstractMethodDefinition") {
  19682. parts.push("abstract ");
  19683. }
  19684. parts.push(printMethod(path, options, print));
  19685. return concat$11(parts);
  19686. case "YieldExpression":
  19687. parts.push("yield");
  19688. if (n.delegate) {
  19689. parts.push("*");
  19690. }
  19691. if (n.argument) {
  19692. parts.push(" ", path.call(print, "argument"));
  19693. }
  19694. return concat$11(parts);
  19695. case "AwaitExpression":
  19696. return concat$11(["await ", path.call(print, "argument")]);
  19697. case "ImportSpecifier":
  19698. if (n.importKind) {
  19699. parts.push(path.call(print, "importKind"), " ");
  19700. }
  19701. parts.push(path.call(print, "imported"));
  19702. if (n.local && n.local.name !== n.imported.name) {
  19703. parts.push(" as ", path.call(print, "local"));
  19704. }
  19705. return concat$11(parts);
  19706. case "ExportSpecifier":
  19707. parts.push(path.call(print, "local"));
  19708. if (n.exported && n.exported.name !== n.local.name) {
  19709. parts.push(" as ", path.call(print, "exported"));
  19710. }
  19711. return concat$11(parts);
  19712. case "ImportNamespaceSpecifier":
  19713. parts.push("* as ");
  19714. parts.push(path.call(print, "local"));
  19715. return concat$11(parts);
  19716. case "ImportDefaultSpecifier":
  19717. return path.call(print, "local");
  19718. case "TSExportAssignment":
  19719. return concat$11(["export = ", path.call(print, "expression"), semi]);
  19720. case "ExportDefaultDeclaration":
  19721. case "ExportNamedDeclaration":
  19722. return printExportDeclaration(path, options, print);
  19723. case "ExportAllDeclaration":
  19724. parts.push("export ");
  19725. if (n.exportKind === "type") {
  19726. parts.push("type ");
  19727. }
  19728. parts.push("* from ", path.call(print, "source"), semi);
  19729. return concat$11(parts);
  19730. case "ExportNamespaceSpecifier":
  19731. case "ExportDefaultSpecifier":
  19732. return path.call(print, "exported");
  19733. case "ImportDeclaration":
  19734. {
  19735. parts.push("import ");
  19736. if (n.importKind && n.importKind !== "value") {
  19737. parts.push(n.importKind + " ");
  19738. }
  19739. var standalones = [];
  19740. var grouped = [];
  19741. if (n.specifiers && n.specifiers.length > 0) {
  19742. path.each(function (specifierPath) {
  19743. var value = specifierPath.getValue();
  19744. if (value.type === "ImportDefaultSpecifier" || value.type === "ImportNamespaceSpecifier") {
  19745. standalones.push(print(specifierPath));
  19746. } else {
  19747. grouped.push(print(specifierPath));
  19748. }
  19749. }, "specifiers");
  19750. if (standalones.length > 0) {
  19751. parts.push(join$7(", ", standalones));
  19752. }
  19753. if (standalones.length > 0 && grouped.length > 0) {
  19754. parts.push(", ");
  19755. }
  19756. if (grouped.length === 1 && standalones.length === 0 && n.specifiers && !n.specifiers.some(function (node) {
  19757. return node.comments;
  19758. })) {
  19759. parts.push(concat$11(["{", options.bracketSpacing ? " " : "", concat$11(grouped), options.bracketSpacing ? " " : "", "}"]));
  19760. } else if (grouped.length >= 1) {
  19761. parts.push(group$10(concat$11(["{", indent$6(concat$11([options.bracketSpacing ? line$8 : softline$5, join$7(concat$11([",", line$8]), grouped)])), ifBreak$6(shouldPrintComma$1(options) ? "," : ""), options.bracketSpacing ? line$8 : softline$5, "}"])));
  19762. }
  19763. parts.push(" from ");
  19764. } else if (n.importKind && n.importKind === "type" || // import {} from 'x'
  19765. /{\s*}/.test(options.originalText.slice(options.locStart(n), options.locStart(n.source)))) {
  19766. parts.push("{} from ");
  19767. }
  19768. parts.push(path.call(print, "source"), semi);
  19769. return concat$11(parts);
  19770. }
  19771. case "Import":
  19772. return "import";
  19773. case "TSModuleBlock":
  19774. case "BlockStatement":
  19775. {
  19776. var naked = path.call(function (bodyPath) {
  19777. return printStatementSequence(bodyPath, options, print);
  19778. }, "body");
  19779. var hasContent = n.body.find(function (node) {
  19780. return node.type !== "EmptyStatement";
  19781. });
  19782. var hasDirectives = n.directives && n.directives.length > 0;
  19783. var _parent3 = path.getParentNode();
  19784. var _parentParent = path.getParentNode(1);
  19785. if (!hasContent && !hasDirectives && !hasDanglingComments(n) && (_parent3.type === "ArrowFunctionExpression" || _parent3.type === "FunctionExpression" || _parent3.type === "FunctionDeclaration" || _parent3.type === "ObjectMethod" || _parent3.type === "ClassMethod" || _parent3.type === "ClassPrivateMethod" || _parent3.type === "ForStatement" || _parent3.type === "WhileStatement" || _parent3.type === "DoWhileStatement" || _parent3.type === "DoExpression" || _parent3.type === "CatchClause" && !_parentParent.finalizer || _parent3.type === "TSModuleDeclaration")) {
  19786. return "{}";
  19787. }
  19788. parts.push("{"); // Babel 6
  19789. if (hasDirectives) {
  19790. path.each(function (childPath) {
  19791. parts.push(indent$6(concat$11([hardline$8, print(childPath), semi])));
  19792. if (isNextLineEmpty$4(options.originalText, childPath.getValue(), options)) {
  19793. parts.push(hardline$8);
  19794. }
  19795. }, "directives");
  19796. }
  19797. if (hasContent) {
  19798. parts.push(indent$6(concat$11([hardline$8, naked])));
  19799. }
  19800. parts.push(comments.printDanglingComments(path, options));
  19801. parts.push(hardline$8, "}");
  19802. return concat$11(parts);
  19803. }
  19804. case "ReturnStatement":
  19805. parts.push("return");
  19806. if (n.argument) {
  19807. if (returnArgumentHasLeadingComment(options, n.argument)) {
  19808. parts.push(concat$11([" (", indent$6(concat$11([hardline$8, path.call(print, "argument")])), hardline$8, ")"]));
  19809. } else if (n.argument.type === "LogicalExpression" || n.argument.type === "BinaryExpression" || n.argument.type === "SequenceExpression") {
  19810. parts.push(group$10(concat$11([ifBreak$6(" (", " "), indent$6(concat$11([softline$5, path.call(print, "argument")])), softline$5, ifBreak$6(")")])));
  19811. } else {
  19812. parts.push(" ", path.call(print, "argument"));
  19813. }
  19814. }
  19815. if (hasDanglingComments(n)) {
  19816. parts.push(" ", comments.printDanglingComments(path, options,
  19817. /* sameIndent */
  19818. true));
  19819. }
  19820. parts.push(semi);
  19821. return concat$11(parts);
  19822. case "NewExpression":
  19823. case "OptionalCallExpression":
  19824. case "CallExpression":
  19825. {
  19826. var isNew = n.type === "NewExpression";
  19827. var optional = printOptionalToken(path);
  19828. if ( // We want to keep CommonJS- and AMD-style require calls, and AMD-style
  19829. // define calls, as a unit.
  19830. // e.g. `define(["some/lib", (lib) => {`
  19831. !isNew && n.callee.type === "Identifier" && (n.callee.name === "require" || n.callee.name === "define") || n.callee.type === "Import" || // Template literals as single arguments
  19832. n.arguments.length === 1 && isTemplateOnItsOwnLine(n.arguments[0], options.originalText, options) || // Keep test declarations on a single line
  19833. // e.g. `it('long name', () => {`
  19834. !isNew && isTestCall(n, path.getParentNode())) {
  19835. return concat$11([isNew ? "new " : "", path.call(print, "callee"), optional, printFunctionTypeParameters(path, options, print), concat$11(["(", join$7(", ", path.map(print, "arguments")), ")"])]);
  19836. } // Inline Flow annotation comments following Identifiers in Call nodes need to
  19837. // stay with the Identifier. For example:
  19838. //
  19839. // foo /*:: <SomeGeneric> */(bar);
  19840. //
  19841. // Here, we ensure that such comments stay between the Identifier and the Callee.
  19842. var isIdentifierWithFlowAnnotation = n.callee.type === "Identifier" && hasFlowAnnotationComment(n.callee.trailingComments);
  19843. if (isIdentifierWithFlowAnnotation) {
  19844. n.callee.trailingComments[0].printed = true;
  19845. } // We detect calls on member lookups and possibly print them in a
  19846. // special chain format. See `printMemberChain` for more info.
  19847. if (!isNew && isMemberish(n.callee)) {
  19848. return printMemberChain(path, options, print);
  19849. }
  19850. return concat$11([isNew ? "new " : "", path.call(print, "callee"), optional, isIdentifierWithFlowAnnotation ? "/*:: ".concat(n.callee.trailingComments[0].value.substring(2).trim(), " */") : "", printFunctionTypeParameters(path, options, print), printArgumentsList(path, options, print)]);
  19851. }
  19852. case "TSInterfaceDeclaration":
  19853. if (isNodeStartingWithDeclare(n, options)) {
  19854. parts.push("declare ");
  19855. }
  19856. parts.push(n.abstract ? "abstract " : "", printTypeScriptModifiers(path, options, print), "interface ", path.call(print, "id"), n.typeParameters ? path.call(print, "typeParameters") : "", " ");
  19857. if (n.extends && n.extends.length) {
  19858. parts.push(group$10(indent$6(concat$11([softline$5, "extends ", (n.extends.length === 1 ? identity$1 : indent$6)(join$7(concat$11([",", line$8]), path.map(print, "extends"))), " "]))));
  19859. }
  19860. parts.push(path.call(print, "body"));
  19861. return concat$11(parts);
  19862. case "ObjectTypeInternalSlot":
  19863. return concat$11([n.static ? "static " : "", "[[", path.call(print, "id"), "]]", printOptionalToken(path), n.method ? "" : ": ", path.call(print, "value")]);
  19864. case "ObjectExpression":
  19865. case "ObjectPattern":
  19866. case "ObjectTypeAnnotation":
  19867. case "TSInterfaceBody":
  19868. case "TSTypeLiteral":
  19869. {
  19870. var propertiesField;
  19871. if (n.type === "TSTypeLiteral") {
  19872. propertiesField = "members";
  19873. } else if (n.type === "TSInterfaceBody") {
  19874. propertiesField = "body";
  19875. } else {
  19876. propertiesField = "properties";
  19877. }
  19878. var isTypeAnnotation = n.type === "ObjectTypeAnnotation";
  19879. var fields = [];
  19880. if (isTypeAnnotation) {
  19881. fields.push("indexers", "callProperties", "internalSlots");
  19882. }
  19883. fields.push(propertiesField);
  19884. var firstProperty = fields.map(function (field) {
  19885. return n[field][0];
  19886. }).sort(function (a, b) {
  19887. return options.locStart(a) - options.locStart(b);
  19888. })[0];
  19889. var _parent4 = path.getParentNode(0);
  19890. var isFlowInterfaceLikeBody = isTypeAnnotation && _parent4 && (_parent4.type === "InterfaceDeclaration" || _parent4.type === "DeclareInterface" || _parent4.type === "DeclareClass") && path.getName() === "body";
  19891. var shouldBreak = n.type === "TSInterfaceBody" || isFlowInterfaceLikeBody || n.type === "ObjectPattern" && _parent4.type !== "FunctionDeclaration" && _parent4.type !== "FunctionExpression" && _parent4.type !== "ArrowFunctionExpression" && _parent4.type !== "AssignmentPattern" && _parent4.type !== "CatchClause" && n.properties.some(function (property) {
  19892. return property.value && (property.value.type === "ObjectPattern" || property.value.type === "ArrayPattern");
  19893. }) || n.type !== "ObjectPattern" && firstProperty && hasNewlineInRange$1(options.originalText, options.locStart(n), options.locStart(firstProperty));
  19894. var separator = isFlowInterfaceLikeBody ? ";" : n.type === "TSInterfaceBody" || n.type === "TSTypeLiteral" ? ifBreak$6(semi, ";") : ",";
  19895. var leftBrace = n.exact ? "{|" : "{";
  19896. var rightBrace = n.exact ? "|}" : "}"; // Unfortunately, things are grouped together in the ast can be
  19897. // interleaved in the source code. So we need to reorder them before
  19898. // printing them.
  19899. var propsAndLoc = [];
  19900. fields.forEach(function (field) {
  19901. path.each(function (childPath) {
  19902. var node = childPath.getValue();
  19903. propsAndLoc.push({
  19904. node: node,
  19905. printed: print(childPath),
  19906. loc: options.locStart(node)
  19907. });
  19908. }, field);
  19909. });
  19910. var separatorParts = [];
  19911. var props = propsAndLoc.sort(function (a, b) {
  19912. return a.loc - b.loc;
  19913. }).map(function (prop) {
  19914. var result = concat$11(separatorParts.concat(group$10(prop.printed)));
  19915. separatorParts = [separator, line$8];
  19916. if ((prop.node.type === "TSPropertySignature" || prop.node.type === "TSMethodSignature" || prop.node.type === "TSConstructSignatureDeclaration") && hasNodeIgnoreComment$1(prop.node)) {
  19917. separatorParts.shift();
  19918. }
  19919. if (isNextLineEmpty$4(options.originalText, prop.node, options)) {
  19920. separatorParts.push(hardline$8);
  19921. }
  19922. return result;
  19923. });
  19924. if (n.inexact) {
  19925. props.push(concat$11(separatorParts.concat(group$10("..."))));
  19926. }
  19927. var lastElem = getLast$4(n[propertiesField]);
  19928. var canHaveTrailingSeparator = !(lastElem && (lastElem.type === "RestProperty" || lastElem.type === "RestElement" || hasNodeIgnoreComment$1(lastElem) || n.inexact));
  19929. var content;
  19930. if (props.length === 0 && !n.typeAnnotation) {
  19931. if (!hasDanglingComments(n)) {
  19932. return concat$11([leftBrace, rightBrace]);
  19933. }
  19934. content = group$10(concat$11([leftBrace, comments.printDanglingComments(path, options), softline$5, rightBrace, printOptionalToken(path)]));
  19935. } else {
  19936. content = concat$11([leftBrace, indent$6(concat$11([options.bracketSpacing ? line$8 : softline$5, concat$11(props)])), ifBreak$6(canHaveTrailingSeparator && (separator !== "," || shouldPrintComma$1(options)) ? separator : ""), concat$11([options.bracketSpacing ? line$8 : softline$5, rightBrace]), printOptionalToken(path), printTypeAnnotation(path, options, print)]);
  19937. } // If we inline the object as first argument of the parent, we don't want
  19938. // to create another group so that the object breaks before the return
  19939. // type
  19940. var parentParentParent = path.getParentNode(2);
  19941. if (n.type === "ObjectPattern" && _parent4 && shouldHugArguments(_parent4) && _parent4.params[0] === n || shouldHugType(n) && parentParentParent && shouldHugArguments(parentParentParent) && parentParentParent.params[0].typeAnnotation && parentParentParent.params[0].typeAnnotation.typeAnnotation === n) {
  19942. return content;
  19943. }
  19944. return group$10(content, {
  19945. shouldBreak: shouldBreak
  19946. });
  19947. }
  19948. // Babel 6
  19949. case "ObjectProperty": // Non-standard AST node type.
  19950. case "Property":
  19951. if (n.method || n.kind === "get" || n.kind === "set") {
  19952. return printMethod(path, options, print);
  19953. }
  19954. if (n.shorthand) {
  19955. parts.push(path.call(print, "value"));
  19956. } else {
  19957. var printedLeft;
  19958. if (n.computed) {
  19959. printedLeft = concat$11(["[", path.call(print, "key"), "]"]);
  19960. } else {
  19961. printedLeft = printPropertyKey(path, options, print);
  19962. }
  19963. parts.push(printAssignment(n.key, printedLeft, ":", n.value, path.call(print, "value"), options));
  19964. }
  19965. return concat$11(parts);
  19966. // Babel 6
  19967. case "ClassMethod":
  19968. case "ClassPrivateMethod":
  19969. if (n.decorators && n.decorators.length !== 0) {
  19970. parts.push(printDecorators(path, options, print));
  19971. }
  19972. if (n.static) {
  19973. parts.push("static ");
  19974. }
  19975. parts = parts.concat(printObjectMethod(path, options, print));
  19976. return concat$11(parts);
  19977. // Babel 6
  19978. case "ObjectMethod":
  19979. return printObjectMethod(path, options, print);
  19980. case "Decorator":
  19981. return concat$11(["@", path.call(print, "expression"), path.call(print, "callee")]);
  19982. case "ArrayExpression":
  19983. case "ArrayPattern":
  19984. if (n.elements.length === 0) {
  19985. if (!hasDanglingComments(n)) {
  19986. parts.push("[]");
  19987. } else {
  19988. parts.push(group$10(concat$11(["[", comments.printDanglingComments(path, options), softline$5, "]"])));
  19989. }
  19990. } else {
  19991. var _lastElem = getLast$4(n.elements);
  19992. var canHaveTrailingComma = !(_lastElem && _lastElem.type === "RestElement"); // JavaScript allows you to have empty elements in an array which
  19993. // changes its length based on the number of commas. The algorithm
  19994. // is that if the last argument is null, we need to force insert
  19995. // a comma to ensure JavaScript recognizes it.
  19996. // [,].length === 1
  19997. // [1,].length === 1
  19998. // [1,,].length === 2
  19999. //
  20000. // Note that getLast returns null if the array is empty, but
  20001. // we already check for an empty array just above so we are safe
  20002. var needsForcedTrailingComma = canHaveTrailingComma && _lastElem === null;
  20003. parts.push(group$10(concat$11(["[", indent$6(concat$11([softline$5, printArrayItems(path, options, "elements", print)])), needsForcedTrailingComma ? "," : "", ifBreak$6(canHaveTrailingComma && !needsForcedTrailingComma && shouldPrintComma$1(options) ? "," : ""), comments.printDanglingComments(path, options,
  20004. /* sameIndent */
  20005. true), softline$5, "]"])));
  20006. }
  20007. parts.push(printOptionalToken(path), printTypeAnnotation(path, options, print));
  20008. return concat$11(parts);
  20009. case "SequenceExpression":
  20010. {
  20011. var _parent5 = path.getParentNode(0);
  20012. if (_parent5.type === "ExpressionStatement" || _parent5.type === "ForStatement") {
  20013. // For ExpressionStatements and for-loop heads, which are among
  20014. // the few places a SequenceExpression appears unparenthesized, we want
  20015. // to indent expressions after the first.
  20016. var _parts2 = [];
  20017. path.each(function (p) {
  20018. if (p.getName() === 0) {
  20019. _parts2.push(print(p));
  20020. } else {
  20021. _parts2.push(",", indent$6(concat$11([line$8, print(p)])));
  20022. }
  20023. }, "expressions");
  20024. return group$10(concat$11(_parts2));
  20025. }
  20026. return group$10(concat$11([join$7(concat$11([",", line$8]), path.map(print, "expressions"))]));
  20027. }
  20028. case "ThisExpression":
  20029. return "this";
  20030. case "Super":
  20031. return "super";
  20032. case "NullLiteral":
  20033. // Babel 6 Literal split
  20034. return "null";
  20035. case "RegExpLiteral":
  20036. // Babel 6 Literal split
  20037. return printRegex(n);
  20038. case "NumericLiteral":
  20039. // Babel 6 Literal split
  20040. return printNumber$2(n.extra.raw);
  20041. case "BigIntLiteral":
  20042. return concat$11([printNumber$2(n.extra ? n.extra.rawValue : // TypeScript
  20043. n.value), "n"]);
  20044. case "BooleanLiteral": // Babel 6 Literal split
  20045. case "StringLiteral": // Babel 6 Literal split
  20046. case "Literal":
  20047. {
  20048. if (n.regex) {
  20049. return printRegex(n.regex);
  20050. }
  20051. if (typeof n.value === "number") {
  20052. return printNumber$2(n.raw);
  20053. }
  20054. if (typeof n.value !== "string") {
  20055. return "" + n.value;
  20056. } // TypeScript workaround for https://github.com/JamesHenry/typescript-estree/issues/2
  20057. // See corresponding workaround in needs-parens.js
  20058. var grandParent = path.getParentNode(1);
  20059. var isTypeScriptDirective = options.parser === "typescript" && typeof n.value === "string" && grandParent && (grandParent.type === "Program" || grandParent.type === "BlockStatement");
  20060. return nodeStr(n, options, isTypeScriptDirective);
  20061. }
  20062. case "Directive":
  20063. return path.call(print, "value");
  20064. // Babel 6
  20065. case "DirectiveLiteral":
  20066. return nodeStr(n, options);
  20067. case "UnaryExpression":
  20068. parts.push(n.operator);
  20069. if (/[a-z]$/.test(n.operator)) {
  20070. parts.push(" ");
  20071. }
  20072. parts.push(path.call(print, "argument"));
  20073. return concat$11(parts);
  20074. case "UpdateExpression":
  20075. parts.push(path.call(print, "argument"), n.operator);
  20076. if (n.prefix) {
  20077. parts.reverse();
  20078. }
  20079. return concat$11(parts);
  20080. case "ConditionalExpression":
  20081. return printTernaryOperator(path, options, print, {
  20082. beforeParts: function beforeParts() {
  20083. return [path.call(print, "test")];
  20084. },
  20085. afterParts: function afterParts(breakClosingParen) {
  20086. return [breakClosingParen ? softline$5 : ""];
  20087. },
  20088. shouldCheckJsx: true,
  20089. conditionalNodeType: "ConditionalExpression",
  20090. consequentNodePropertyName: "consequent",
  20091. alternateNodePropertyName: "alternate",
  20092. testNodePropertyName: "test",
  20093. breakNested: true
  20094. });
  20095. case "VariableDeclaration":
  20096. {
  20097. var printed = path.map(function (childPath) {
  20098. return print(childPath);
  20099. }, "declarations"); // We generally want to terminate all variable declarations with a
  20100. // semicolon, except when they in the () part of for loops.
  20101. var parentNode = path.getParentNode();
  20102. var isParentForLoop = parentNode.type === "ForStatement" || parentNode.type === "ForInStatement" || parentNode.type === "ForOfStatement" || parentNode.type === "ForAwaitStatement";
  20103. var hasValue = n.declarations.some(function (decl) {
  20104. return decl.init;
  20105. });
  20106. var firstVariable;
  20107. if (printed.length === 1 && !n.declarations[0].comments) {
  20108. firstVariable = printed[0];
  20109. } else if (printed.length > 0) {
  20110. // Indent first var to comply with eslint one-var rule
  20111. firstVariable = indent$6(printed[0]);
  20112. }
  20113. parts = [isNodeStartingWithDeclare(n, options) ? "declare " : "", n.kind, firstVariable ? concat$11([" ", firstVariable]) : "", indent$6(concat$11(printed.slice(1).map(function (p) {
  20114. return concat$11([",", hasValue && !isParentForLoop ? hardline$8 : line$8, p]);
  20115. })))];
  20116. if (!(isParentForLoop && parentNode.body !== n)) {
  20117. parts.push(semi);
  20118. }
  20119. return group$10(concat$11(parts));
  20120. }
  20121. case "TSTypeAliasDeclaration":
  20122. {
  20123. if (n.declare) {
  20124. parts.push("declare ");
  20125. }
  20126. var _printed = printAssignmentRight(n.id, n.typeAnnotation, n.typeAnnotation && path.call(print, "typeAnnotation"), options);
  20127. parts.push("type ", path.call(print, "id"), path.call(print, "typeParameters"), " =", _printed, semi);
  20128. return group$10(concat$11(parts));
  20129. }
  20130. case "VariableDeclarator":
  20131. return printAssignment(n.id, path.call(print, "id"), " =", n.init, n.init && path.call(print, "init"), options);
  20132. case "WithStatement":
  20133. return group$10(concat$11(["with (", path.call(print, "object"), ")", adjustClause(n.body, path.call(print, "body"))]));
  20134. case "IfStatement":
  20135. {
  20136. var con = adjustClause(n.consequent, path.call(print, "consequent"));
  20137. var opening = group$10(concat$11(["if (", group$10(concat$11([indent$6(concat$11([softline$5, path.call(print, "test")])), softline$5])), ")", con]));
  20138. parts.push(opening);
  20139. if (n.alternate) {
  20140. var commentOnOwnLine = hasTrailingComment(n.consequent) && n.consequent.comments.some(function (comment) {
  20141. return comment.trailing && !comments$3.isBlockComment(comment);
  20142. }) || needsHardlineAfterDanglingComment(n);
  20143. var elseOnSameLine = n.consequent.type === "BlockStatement" && !commentOnOwnLine;
  20144. parts.push(elseOnSameLine ? " " : hardline$8);
  20145. if (hasDanglingComments(n)) {
  20146. parts.push(comments.printDanglingComments(path, options, true), commentOnOwnLine ? hardline$8 : " ");
  20147. }
  20148. parts.push("else", group$10(adjustClause(n.alternate, path.call(print, "alternate"), n.alternate.type === "IfStatement")));
  20149. }
  20150. return concat$11(parts);
  20151. }
  20152. case "ForStatement":
  20153. {
  20154. var _body = adjustClause(n.body, path.call(print, "body")); // We want to keep dangling comments above the loop to stay consistent.
  20155. // Any comment positioned between the for statement and the parentheses
  20156. // is going to be printed before the statement.
  20157. var _dangling = comments.printDanglingComments(path, options,
  20158. /* sameLine */
  20159. true);
  20160. var printedComments = _dangling ? concat$11([_dangling, softline$5]) : "";
  20161. if (!n.init && !n.test && !n.update) {
  20162. return concat$11([printedComments, group$10(concat$11(["for (;;)", _body]))]);
  20163. }
  20164. return concat$11([printedComments, group$10(concat$11(["for (", group$10(concat$11([indent$6(concat$11([softline$5, path.call(print, "init"), ";", line$8, path.call(print, "test"), ";", line$8, path.call(print, "update")])), softline$5])), ")", _body]))]);
  20165. }
  20166. case "WhileStatement":
  20167. return group$10(concat$11(["while (", group$10(concat$11([indent$6(concat$11([softline$5, path.call(print, "test")])), softline$5])), ")", adjustClause(n.body, path.call(print, "body"))]));
  20168. case "ForInStatement":
  20169. // Note: esprima can't actually parse "for each (".
  20170. return group$10(concat$11([n.each ? "for each (" : "for (", path.call(print, "left"), " in ", path.call(print, "right"), ")", adjustClause(n.body, path.call(print, "body"))]));
  20171. case "ForOfStatement":
  20172. case "ForAwaitStatement":
  20173. {
  20174. // Babel 7 removed ForAwaitStatement in favor of ForOfStatement
  20175. // with `"await": true`:
  20176. // https://github.com/estree/estree/pull/138
  20177. var isAwait = n.type === "ForAwaitStatement" || n.await;
  20178. return group$10(concat$11(["for", isAwait ? " await" : "", " (", path.call(print, "left"), " of ", path.call(print, "right"), ")", adjustClause(n.body, path.call(print, "body"))]));
  20179. }
  20180. case "DoWhileStatement":
  20181. {
  20182. var clause = adjustClause(n.body, path.call(print, "body"));
  20183. var doBody = group$10(concat$11(["do", clause]));
  20184. parts = [doBody];
  20185. if (n.body.type === "BlockStatement") {
  20186. parts.push(" ");
  20187. } else {
  20188. parts.push(hardline$8);
  20189. }
  20190. parts.push("while (");
  20191. parts.push(group$10(concat$11([indent$6(concat$11([softline$5, path.call(print, "test")])), softline$5])), ")", semi);
  20192. return concat$11(parts);
  20193. }
  20194. case "DoExpression":
  20195. return concat$11(["do ", path.call(print, "body")]);
  20196. case "BreakStatement":
  20197. parts.push("break");
  20198. if (n.label) {
  20199. parts.push(" ", path.call(print, "label"));
  20200. }
  20201. parts.push(semi);
  20202. return concat$11(parts);
  20203. case "ContinueStatement":
  20204. parts.push("continue");
  20205. if (n.label) {
  20206. parts.push(" ", path.call(print, "label"));
  20207. }
  20208. parts.push(semi);
  20209. return concat$11(parts);
  20210. case "LabeledStatement":
  20211. if (n.body.type === "EmptyStatement") {
  20212. return concat$11([path.call(print, "label"), ":;"]);
  20213. }
  20214. return concat$11([path.call(print, "label"), ": ", path.call(print, "body")]);
  20215. case "TryStatement":
  20216. return concat$11(["try ", path.call(print, "block"), n.handler ? concat$11([" ", path.call(print, "handler")]) : "", n.finalizer ? concat$11([" finally ", path.call(print, "finalizer")]) : ""]);
  20217. case "CatchClause":
  20218. if (n.param) {
  20219. var hasComments = n.param.comments && n.param.comments.some(function (comment) {
  20220. return !comments$3.isBlockComment(comment) || comment.leading && hasNewline$3(options.originalText, options.locEnd(comment)) || comment.trailing && hasNewline$3(options.originalText, options.locStart(comment), {
  20221. backwards: true
  20222. });
  20223. });
  20224. var param = path.call(print, "param");
  20225. return concat$11(["catch ", hasComments ? concat$11(["(", indent$6(concat$11([softline$5, param])), softline$5, ") "]) : concat$11(["(", param, ") "]), path.call(print, "body")]);
  20226. }
  20227. return concat$11(["catch ", path.call(print, "body")]);
  20228. case "ThrowStatement":
  20229. return concat$11(["throw ", path.call(print, "argument"), semi]);
  20230. // Note: ignoring n.lexical because it has no printing consequences.
  20231. case "SwitchStatement":
  20232. return concat$11([group$10(concat$11(["switch (", indent$6(concat$11([softline$5, path.call(print, "discriminant")])), softline$5, ")"])), " {", n.cases.length > 0 ? indent$6(concat$11([hardline$8, join$7(hardline$8, path.map(function (casePath) {
  20233. var caseNode = casePath.getValue();
  20234. return concat$11([casePath.call(print), n.cases.indexOf(caseNode) !== n.cases.length - 1 && isNextLineEmpty$4(options.originalText, caseNode, options) ? hardline$8 : ""]);
  20235. }, "cases"))])) : "", hardline$8, "}"]);
  20236. case "SwitchCase":
  20237. {
  20238. if (n.test) {
  20239. parts.push("case ", path.call(print, "test"), ":");
  20240. } else {
  20241. parts.push("default:");
  20242. }
  20243. var consequent = n.consequent.filter(function (node) {
  20244. return node.type !== "EmptyStatement";
  20245. });
  20246. if (consequent.length > 0) {
  20247. var cons = path.call(function (consequentPath) {
  20248. return printStatementSequence(consequentPath, options, print);
  20249. }, "consequent");
  20250. parts.push(consequent.length === 1 && consequent[0].type === "BlockStatement" ? concat$11([" ", cons]) : indent$6(concat$11([hardline$8, cons])));
  20251. }
  20252. return concat$11(parts);
  20253. }
  20254. // JSX extensions below.
  20255. case "DebuggerStatement":
  20256. return concat$11(["debugger", semi]);
  20257. case "JSXAttribute":
  20258. parts.push(path.call(print, "name"));
  20259. if (n.value) {
  20260. var res;
  20261. if (isStringLiteral(n.value)) {
  20262. var raw = rawText(n.value); // Unescape all quotes so we get an accurate preferred quote
  20263. var final = raw.replace(/&apos;/g, "'").replace(/&quot;/g, '"');
  20264. var quote = getPreferredQuote$1(final, options.jsxSingleQuote ? "'" : '"');
  20265. var _escape = quote === "'" ? "&apos;" : "&quot;";
  20266. final = final.slice(1, -1).replace(new RegExp(quote, "g"), _escape);
  20267. res = concat$11([quote, final, quote]);
  20268. } else {
  20269. res = path.call(print, "value");
  20270. }
  20271. parts.push("=", res);
  20272. }
  20273. return concat$11(parts);
  20274. case "JSXIdentifier":
  20275. return "" + n.name;
  20276. case "JSXNamespacedName":
  20277. return join$7(":", [path.call(print, "namespace"), path.call(print, "name")]);
  20278. case "JSXMemberExpression":
  20279. return join$7(".", [path.call(print, "object"), path.call(print, "property")]);
  20280. case "TSQualifiedName":
  20281. return join$7(".", [path.call(print, "left"), path.call(print, "right")]);
  20282. case "JSXSpreadAttribute":
  20283. case "JSXSpreadChild":
  20284. {
  20285. return concat$11(["{", path.call(function (p) {
  20286. var printed = concat$11(["...", print(p)]);
  20287. var n = p.getValue();
  20288. if (!n.comments || !n.comments.length) {
  20289. return printed;
  20290. }
  20291. return concat$11([indent$6(concat$11([softline$5, comments.printComments(p, function () {
  20292. return printed;
  20293. }, options)])), softline$5]);
  20294. }, n.type === "JSXSpreadAttribute" ? "argument" : "expression"), "}"]);
  20295. }
  20296. case "JSXExpressionContainer":
  20297. {
  20298. var _parent6 = path.getParentNode(0);
  20299. var preventInline = _parent6.type === "JSXAttribute" && n.expression.comments && n.expression.comments.length > 0;
  20300. var _shouldInline = !preventInline && (n.expression.type === "ArrayExpression" || n.expression.type === "ObjectExpression" || n.expression.type === "ArrowFunctionExpression" || n.expression.type === "CallExpression" || n.expression.type === "OptionalCallExpression" || n.expression.type === "FunctionExpression" || n.expression.type === "JSXEmptyExpression" || n.expression.type === "TemplateLiteral" || n.expression.type === "TaggedTemplateExpression" || n.expression.type === "DoExpression" || isJSXNode(_parent6) && (n.expression.type === "ConditionalExpression" || isBinaryish(n.expression)));
  20301. if (_shouldInline) {
  20302. return group$10(concat$11(["{", path.call(print, "expression"), lineSuffixBoundary$1, "}"]));
  20303. }
  20304. return group$10(concat$11(["{", indent$6(concat$11([softline$5, path.call(print, "expression")])), softline$5, lineSuffixBoundary$1, "}"]));
  20305. }
  20306. case "JSXFragment":
  20307. case "JSXElement":
  20308. {
  20309. var elem = comments.printComments(path, function () {
  20310. return printJSXElement(path, options, print);
  20311. }, options);
  20312. return maybeWrapJSXElementInParens(path, elem);
  20313. }
  20314. case "JSXOpeningElement":
  20315. {
  20316. var _n = path.getValue();
  20317. var nameHasComments = _n.name && _n.name.comments && _n.name.comments.length > 0; // Don't break self-closing elements with no attributes and no comments
  20318. if (_n.selfClosing && !_n.attributes.length && !nameHasComments) {
  20319. return concat$11(["<", path.call(print, "name"), path.call(print, "typeParameters"), " />"]);
  20320. } // don't break up opening elements with a single long text attribute
  20321. 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:
  20322. // <div
  20323. // // comment
  20324. // attr="value"
  20325. // >
  20326. // <div
  20327. // attr="value"
  20328. // // comment
  20329. // >
  20330. !nameHasComments && (!_n.attributes[0].comments || !_n.attributes[0].comments.length)) {
  20331. return group$10(concat$11(["<", path.call(print, "name"), path.call(print, "typeParameters"), " ", concat$11(path.map(print, "attributes")), _n.selfClosing ? " />" : ">"]));
  20332. }
  20333. var lastAttrHasTrailingComments = _n.attributes.length && hasTrailingComment(getLast$4(_n.attributes));
  20334. var bracketSameLine = // Simple tags (no attributes and no comment in tag name) should be
  20335. // kept unbroken regardless of `jsxBracketSameLine`
  20336. !_n.attributes.length && !nameHasComments || options.jsxBracketSameLine && ( // We should print the bracket in a new line for the following cases:
  20337. // <div
  20338. // // comment
  20339. // >
  20340. // <div
  20341. // attr // comment
  20342. // >
  20343. !nameHasComments || _n.attributes.length) && !lastAttrHasTrailingComments; // We should print the opening element expanded if any prop value is a
  20344. // string literal with newlines
  20345. var _shouldBreak = _n.attributes && _n.attributes.some(function (attr) {
  20346. return attr.value && isStringLiteral(attr.value) && attr.value.value.includes("\n");
  20347. });
  20348. return group$10(concat$11(["<", path.call(print, "name"), path.call(print, "typeParameters"), concat$11([indent$6(concat$11(path.map(function (attr) {
  20349. return concat$11([line$8, print(attr)]);
  20350. }, "attributes"))), _n.selfClosing ? line$8 : bracketSameLine ? ">" : softline$5]), _n.selfClosing ? "/>" : bracketSameLine ? "" : ">"]), {
  20351. shouldBreak: _shouldBreak
  20352. });
  20353. }
  20354. case "JSXClosingElement":
  20355. return concat$11(["</", path.call(print, "name"), ">"]);
  20356. case "JSXOpeningFragment":
  20357. case "JSXClosingFragment":
  20358. {
  20359. var hasComment = n.comments && n.comments.length;
  20360. var hasOwnLineComment = hasComment && !n.comments.every(comments$3.isBlockComment);
  20361. var isOpeningFragment = n.type === "JSXOpeningFragment";
  20362. return concat$11([isOpeningFragment ? "<" : "</", indent$6(concat$11([hasOwnLineComment ? hardline$8 : hasComment && !isOpeningFragment ? " " : "", comments.printDanglingComments(path, options, true)])), hasOwnLineComment ? hardline$8 : "", ">"]);
  20363. }
  20364. case "JSXText":
  20365. /* istanbul ignore next */
  20366. throw new Error("JSXTest should be handled by JSXElement");
  20367. case "JSXEmptyExpression":
  20368. {
  20369. var requiresHardline = n.comments && !n.comments.every(comments$3.isBlockComment);
  20370. return concat$11([comments.printDanglingComments(path, options,
  20371. /* sameIndent */
  20372. !requiresHardline), requiresHardline ? hardline$8 : ""]);
  20373. }
  20374. case "ClassBody":
  20375. if (!n.comments && n.body.length === 0) {
  20376. return "{}";
  20377. }
  20378. return concat$11(["{", n.body.length > 0 ? indent$6(concat$11([hardline$8, path.call(function (bodyPath) {
  20379. return printStatementSequence(bodyPath, options, print);
  20380. }, "body")])) : comments.printDanglingComments(path, options), hardline$8, "}"]);
  20381. case "ClassProperty":
  20382. case "TSAbstractClassProperty":
  20383. case "ClassPrivateProperty":
  20384. {
  20385. if (n.decorators && n.decorators.length !== 0) {
  20386. parts.push(printDecorators(path, options, print));
  20387. }
  20388. if (n.accessibility) {
  20389. parts.push(n.accessibility + " ");
  20390. }
  20391. if (n.static) {
  20392. parts.push("static ");
  20393. }
  20394. if (n.type === "TSAbstractClassProperty") {
  20395. parts.push("abstract ");
  20396. }
  20397. if (n.readonly) {
  20398. parts.push("readonly ");
  20399. }
  20400. var variance = getFlowVariance(n);
  20401. if (variance) {
  20402. parts.push(variance);
  20403. }
  20404. if (n.computed) {
  20405. parts.push("[", path.call(print, "key"), "]");
  20406. } else {
  20407. parts.push(printPropertyKey(path, options, print));
  20408. }
  20409. parts.push(printOptionalToken(path));
  20410. parts.push(printTypeAnnotation(path, options, print));
  20411. if (n.value) {
  20412. parts.push(" =", printAssignmentRight(n.key, n.value, path.call(print, "value"), options));
  20413. }
  20414. parts.push(semi);
  20415. return group$10(concat$11(parts));
  20416. }
  20417. case "ClassDeclaration":
  20418. case "ClassExpression":
  20419. case "TSAbstractClassDeclaration":
  20420. if (isNodeStartingWithDeclare(n, options)) {
  20421. parts.push("declare ");
  20422. }
  20423. parts.push(concat$11(printClass(path, options, print)));
  20424. return concat$11(parts);
  20425. case "TSInterfaceHeritage":
  20426. parts.push(path.call(print, "expression"));
  20427. if (n.typeParameters) {
  20428. parts.push(path.call(print, "typeParameters"));
  20429. }
  20430. return concat$11(parts);
  20431. case "TemplateElement":
  20432. return join$7(literalline$3, n.value.raw.split(/\r?\n/g));
  20433. case "TemplateLiteral":
  20434. {
  20435. var expressions = path.map(print, "expressions");
  20436. var _parentNode = path.getParentNode();
  20437. /**
  20438. * describe.each`table`(name, fn)
  20439. * describe.only.each`table`(name, fn)
  20440. * describe.skip.each`table`(name, fn)
  20441. * test.each`table`(name, fn)
  20442. * test.only.each`table`(name, fn)
  20443. * test.skip.each`table`(name, fn)
  20444. *
  20445. * Ref: https://github.com/facebook/jest/pull/6102
  20446. */
  20447. var jestEachTriggerRegex = /^[xf]?(describe|it|test)$/;
  20448. 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))) {
  20449. /**
  20450. * a | b | expected
  20451. * ${1} | ${1} | ${2}
  20452. * ${1} | ${2} | ${3}
  20453. * ${2} | ${1} | ${3}
  20454. */
  20455. var headerNames = n.quasis[0].value.raw.trim().split(/\s*\|\s*/);
  20456. if (headerNames.length > 1 || headerNames.some(function (headerName) {
  20457. return headerName.length !== 0;
  20458. })) {
  20459. var stringifiedExpressions = expressions.map(function (doc$$2) {
  20460. return "${" + printDocToString$1(doc$$2, Object.assign({}, options, {
  20461. printWidth: Infinity,
  20462. endOfLine: "lf"
  20463. })).formatted + "}";
  20464. });
  20465. var tableBody = [{
  20466. hasLineBreak: false,
  20467. cells: []
  20468. }];
  20469. for (var _i = 1; _i < n.quasis.length; _i++) {
  20470. var row = tableBody[tableBody.length - 1];
  20471. var correspondingExpression = stringifiedExpressions[_i - 1];
  20472. row.cells.push(correspondingExpression);
  20473. if (correspondingExpression.indexOf("\n") !== -1) {
  20474. row.hasLineBreak = true;
  20475. }
  20476. if (n.quasis[_i].value.raw.indexOf("\n") !== -1) {
  20477. tableBody.push({
  20478. hasLineBreak: false,
  20479. cells: []
  20480. });
  20481. }
  20482. }
  20483. var maxColumnCount = tableBody.reduce(function (maxColumnCount, row) {
  20484. return Math.max(maxColumnCount, row.cells.length);
  20485. }, headerNames.length);
  20486. var maxColumnWidths = Array.from(new Array(maxColumnCount), function () {
  20487. return 0;
  20488. });
  20489. var table = [{
  20490. cells: headerNames
  20491. }].concat(tableBody.filter(function (row) {
  20492. return row.cells.length !== 0;
  20493. }));
  20494. table.filter(function (row) {
  20495. return !row.hasLineBreak;
  20496. }).forEach(function (row) {
  20497. row.cells.forEach(function (cell, index) {
  20498. maxColumnWidths[index] = Math.max(maxColumnWidths[index], getStringWidth$2(cell));
  20499. });
  20500. });
  20501. parts.push("`", indent$6(concat$11([hardline$8, join$7(hardline$8, table.map(function (row) {
  20502. return join$7(" | ", row.cells.map(function (cell, index) {
  20503. return row.hasLineBreak ? cell : cell + " ".repeat(maxColumnWidths[index] - getStringWidth$2(cell));
  20504. }));
  20505. }))])), hardline$8, "`");
  20506. return concat$11(parts);
  20507. }
  20508. }
  20509. parts.push("`");
  20510. path.each(function (childPath) {
  20511. var i = childPath.getName();
  20512. parts.push(print(childPath));
  20513. if (i < expressions.length) {
  20514. // For a template literal of the following form:
  20515. // `someQuery {
  20516. // ${call({
  20517. // a,
  20518. // b,
  20519. // })}
  20520. // }`
  20521. // the expression is on its own line (there is a \n in the previous
  20522. // quasi literal), therefore we want to indent the JavaScript
  20523. // expression inside at the beginning of ${ instead of the beginning
  20524. // of the `.
  20525. var tabWidth = options.tabWidth;
  20526. var quasi = childPath.getValue();
  20527. var indentSize = getIndentSize$1(quasi.value.raw, tabWidth);
  20528. var _printed2 = expressions[i];
  20529. 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") {
  20530. _printed2 = concat$11([indent$6(concat$11([softline$5, _printed2])), softline$5]);
  20531. }
  20532. var aligned = indentSize === 0 && quasi.value.raw.endsWith("\n") ? align$1(-Infinity, _printed2) : addAlignmentToDoc$2(_printed2, indentSize, tabWidth);
  20533. parts.push(group$10(concat$11(["${", aligned, lineSuffixBoundary$1, "}"])));
  20534. }
  20535. }, "quasis");
  20536. parts.push("`");
  20537. return concat$11(parts);
  20538. }
  20539. // These types are unprintable because they serve as abstract
  20540. // supertypes for other (printable) types.
  20541. case "TaggedTemplateExpression":
  20542. return concat$11([path.call(print, "tag"), path.call(print, "typeParameters"), path.call(print, "quasi")]);
  20543. case "Node":
  20544. case "Printable":
  20545. case "SourceLocation":
  20546. case "Position":
  20547. case "Statement":
  20548. case "Function":
  20549. case "Pattern":
  20550. case "Expression":
  20551. case "Declaration":
  20552. case "Specifier":
  20553. case "NamedSpecifier":
  20554. case "Comment":
  20555. case "MemberTypeAnnotation": // Flow
  20556. case "Type":
  20557. /* istanbul ignore next */
  20558. throw new Error("unprintable type: " + JSON.stringify(n.type));
  20559. // Type Annotations for Facebook Flow, typically stripped out or
  20560. // transformed away before printing.
  20561. case "TypeAnnotation":
  20562. case "TSTypeAnnotation":
  20563. if (n.typeAnnotation) {
  20564. return path.call(print, "typeAnnotation");
  20565. }
  20566. /* istanbul ignore next */
  20567. return "";
  20568. case "TSTupleType":
  20569. case "TupleTypeAnnotation":
  20570. {
  20571. var typesField = n.type === "TSTupleType" ? "elementTypes" : "types";
  20572. return group$10(concat$11(["[", indent$6(concat$11([softline$5, printArrayItems(path, options, typesField, print)])), // TypeScript doesn't support trailing commas in tuple types
  20573. n.type === "TSTupleType" ? "" : ifBreak$6(shouldPrintComma$1(options) ? "," : ""), comments.printDanglingComments(path, options,
  20574. /* sameIndent */
  20575. true), softline$5, "]"]));
  20576. }
  20577. case "ExistsTypeAnnotation":
  20578. return "*";
  20579. case "EmptyTypeAnnotation":
  20580. return "empty";
  20581. case "AnyTypeAnnotation":
  20582. return "any";
  20583. case "MixedTypeAnnotation":
  20584. return "mixed";
  20585. case "ArrayTypeAnnotation":
  20586. return concat$11([path.call(print, "elementType"), "[]"]);
  20587. case "BooleanTypeAnnotation":
  20588. return "boolean";
  20589. case "BooleanLiteralTypeAnnotation":
  20590. return "" + n.value;
  20591. case "DeclareClass":
  20592. return printFlowDeclaration(path, printClass(path, options, print));
  20593. case "TSDeclareFunction":
  20594. // For TypeScript the TSDeclareFunction node shares the AST
  20595. // structure with FunctionDeclaration
  20596. return concat$11([n.declare ? "declare " : "", printFunctionDeclaration(path, print, options), semi]);
  20597. case "DeclareFunction":
  20598. return printFlowDeclaration(path, ["function ", path.call(print, "id"), n.predicate ? " " : "", path.call(print, "predicate"), semi]);
  20599. case "DeclareModule":
  20600. return printFlowDeclaration(path, ["module ", path.call(print, "id"), " ", path.call(print, "body")]);
  20601. case "DeclareModuleExports":
  20602. return printFlowDeclaration(path, ["module.exports", ": ", path.call(print, "typeAnnotation"), semi]);
  20603. case "DeclareVariable":
  20604. return printFlowDeclaration(path, ["var ", path.call(print, "id"), semi]);
  20605. case "DeclareExportAllDeclaration":
  20606. return concat$11(["declare export * from ", path.call(print, "source")]);
  20607. case "DeclareExportDeclaration":
  20608. return concat$11(["declare ", printExportDeclaration(path, options, print)]);
  20609. case "DeclareOpaqueType":
  20610. case "OpaqueType":
  20611. {
  20612. parts.push("opaque type ", path.call(print, "id"), path.call(print, "typeParameters"));
  20613. if (n.supertype) {
  20614. parts.push(": ", path.call(print, "supertype"));
  20615. }
  20616. if (n.impltype) {
  20617. parts.push(" = ", path.call(print, "impltype"));
  20618. }
  20619. parts.push(semi);
  20620. if (n.type === "DeclareOpaqueType") {
  20621. return printFlowDeclaration(path, parts);
  20622. }
  20623. return concat$11(parts);
  20624. }
  20625. case "FunctionTypeAnnotation":
  20626. case "TSFunctionType":
  20627. {
  20628. // FunctionTypeAnnotation is ambiguous:
  20629. // declare function foo(a: B): void; OR
  20630. // var A: (a: B) => void;
  20631. var _parent7 = path.getParentNode(0);
  20632. var _parentParent2 = path.getParentNode(1);
  20633. var _parentParentParent = path.getParentNode(2);
  20634. var isArrowFunctionTypeAnnotation = n.type === "TSFunctionType" || !((_parent7.type === "ObjectTypeProperty" || _parent7.type === "ObjectTypeInternalSlot") && !getFlowVariance(_parent7) && !_parent7.optional && options.locStart(_parent7) === options.locStart(n) || _parent7.type === "ObjectTypeCallProperty" || _parentParentParent && _parentParentParent.type === "DeclareFunction");
  20635. var needsColon = isArrowFunctionTypeAnnotation && (_parent7.type === "TypeAnnotation" || _parent7.type === "TSTypeAnnotation"); // Sadly we can't put it inside of FastPath::needsColon because we are
  20636. // printing ":" as part of the expression and it would put parenthesis
  20637. // around :(
  20638. var needsParens = needsColon && isArrowFunctionTypeAnnotation && (_parent7.type === "TypeAnnotation" || _parent7.type === "TSTypeAnnotation") && _parentParent2.type === "ArrowFunctionExpression";
  20639. if (isObjectTypePropertyAFunction(_parent7, options)) {
  20640. isArrowFunctionTypeAnnotation = true;
  20641. needsColon = true;
  20642. }
  20643. if (needsParens) {
  20644. parts.push("(");
  20645. }
  20646. parts.push(printFunctionParams(path, print, options,
  20647. /* expandArg */
  20648. false,
  20649. /* printTypeParams */
  20650. true)); // The returnType is not wrapped in a TypeAnnotation, so the colon
  20651. // needs to be added separately.
  20652. if (n.returnType || n.predicate || n.typeAnnotation) {
  20653. parts.push(isArrowFunctionTypeAnnotation ? " => " : ": ", path.call(print, "returnType"), path.call(print, "predicate"), path.call(print, "typeAnnotation"));
  20654. }
  20655. if (needsParens) {
  20656. parts.push(")");
  20657. }
  20658. return group$10(concat$11(parts));
  20659. }
  20660. case "TSRestType":
  20661. return concat$11(["...", path.call(print, "typeAnnotation")]);
  20662. case "TSOptionalType":
  20663. return concat$11([path.call(print, "typeAnnotation"), "?"]);
  20664. case "FunctionTypeParam":
  20665. return concat$11([path.call(print, "name"), printOptionalToken(path), n.name ? ": " : "", path.call(print, "typeAnnotation")]);
  20666. case "GenericTypeAnnotation":
  20667. return concat$11([path.call(print, "id"), path.call(print, "typeParameters")]);
  20668. case "DeclareInterface":
  20669. case "InterfaceDeclaration":
  20670. case "InterfaceTypeAnnotation":
  20671. {
  20672. if (n.type === "DeclareInterface" || isNodeStartingWithDeclare(n, options)) {
  20673. parts.push("declare ");
  20674. }
  20675. parts.push("interface");
  20676. if (n.type === "DeclareInterface" || n.type === "InterfaceDeclaration") {
  20677. parts.push(" ", path.call(print, "id"), path.call(print, "typeParameters"));
  20678. }
  20679. if (n["extends"].length > 0) {
  20680. parts.push(group$10(indent$6(concat$11([line$8, "extends ", (n.extends.length === 1 ? identity$1 : indent$6)(join$7(concat$11([",", line$8]), path.map(print, "extends")))]))));
  20681. }
  20682. parts.push(" ", path.call(print, "body"));
  20683. return group$10(concat$11(parts));
  20684. }
  20685. case "ClassImplements":
  20686. case "InterfaceExtends":
  20687. return concat$11([path.call(print, "id"), path.call(print, "typeParameters")]);
  20688. case "TSClassImplements":
  20689. return concat$11([path.call(print, "expression"), path.call(print, "typeParameters")]);
  20690. case "TSIntersectionType":
  20691. case "IntersectionTypeAnnotation":
  20692. {
  20693. var types = path.map(print, "types");
  20694. var result = [];
  20695. var wasIndented = false;
  20696. for (var _i2 = 0; _i2 < types.length; ++_i2) {
  20697. if (_i2 === 0) {
  20698. result.push(types[_i2]);
  20699. } else if (isObjectType(n.types[_i2 - 1]) && isObjectType(n.types[_i2])) {
  20700. // If both are objects, don't indent
  20701. result.push(concat$11([" & ", wasIndented ? indent$6(types[_i2]) : types[_i2]]));
  20702. } else if (!isObjectType(n.types[_i2 - 1]) && !isObjectType(n.types[_i2])) {
  20703. // If no object is involved, go to the next line if it breaks
  20704. result.push(indent$6(concat$11([" &", line$8, types[_i2]])));
  20705. } else {
  20706. // If you go from object to non-object or vis-versa, then inline it
  20707. if (_i2 > 1) {
  20708. wasIndented = true;
  20709. }
  20710. result.push(" & ", _i2 > 1 ? indent$6(types[_i2]) : types[_i2]);
  20711. }
  20712. }
  20713. return group$10(concat$11(result));
  20714. }
  20715. case "TSUnionType":
  20716. case "UnionTypeAnnotation":
  20717. {
  20718. // single-line variation
  20719. // A | B | C
  20720. // multi-line variation
  20721. // | A
  20722. // | B
  20723. // | C
  20724. var _parent8 = path.getParentNode(); // If there's a leading comment, the parent is doing the indentation
  20725. var shouldIndent = _parent8.type !== "TypeParameterInstantiation" && _parent8.type !== "TSTypeParameterInstantiation" && _parent8.type !== "GenericTypeAnnotation" && _parent8.type !== "TSTypeReference" && _parent8.type !== "TSTypeAssertion" && !(_parent8.type === "FunctionTypeParam" && !_parent8.name) && !((_parent8.type === "TypeAlias" || _parent8.type === "VariableDeclarator" || _parent8.type === "TSTypeAliasDeclaration") && hasLeadingOwnLineComment(options.originalText, n, options)); // {
  20726. // a: string
  20727. // } | null | void
  20728. // should be inlined and not be printed in the multi-line variant
  20729. var shouldHug = shouldHugType(n); // We want to align the children but without its comment, so it looks like
  20730. // | child1
  20731. // // comment
  20732. // | child2
  20733. var _printed3 = path.map(function (typePath) {
  20734. var printedType = typePath.call(print);
  20735. if (!shouldHug) {
  20736. printedType = align$1(2, printedType);
  20737. }
  20738. return comments.printComments(typePath, function () {
  20739. return printedType;
  20740. }, options);
  20741. }, "types");
  20742. if (shouldHug) {
  20743. return join$7(" | ", _printed3);
  20744. }
  20745. var shouldAddStartLine = shouldIndent && !hasLeadingOwnLineComment(options.originalText, n, options);
  20746. var code = concat$11([ifBreak$6(concat$11([shouldAddStartLine ? line$8 : "", "| "])), join$7(concat$11([line$8, "| "]), _printed3)]);
  20747. var hasParens;
  20748. if (n.type === "TSUnionType") {
  20749. var greatGrandParent = path.getParentNode(2);
  20750. var greatGreatGrandParent = path.getParentNode(3);
  20751. hasParens = greatGrandParent && greatGrandParent.type === "TSParenthesizedType" && greatGreatGrandParent && (greatGreatGrandParent.type === "TSUnionType" || greatGreatGrandParent.type === "TSIntersectionType");
  20752. } else {
  20753. hasParens = needsParens_1(path, options);
  20754. }
  20755. if (hasParens) {
  20756. return group$10(concat$11([indent$6(code), softline$5]));
  20757. }
  20758. return group$10(shouldIndent ? indent$6(code) : code);
  20759. }
  20760. case "NullableTypeAnnotation":
  20761. return concat$11(["?", path.call(print, "typeAnnotation")]);
  20762. case "TSNullKeyword":
  20763. case "NullLiteralTypeAnnotation":
  20764. return "null";
  20765. case "ThisTypeAnnotation":
  20766. return "this";
  20767. case "NumberTypeAnnotation":
  20768. return "number";
  20769. case "ObjectTypeCallProperty":
  20770. if (n.static) {
  20771. parts.push("static ");
  20772. }
  20773. parts.push(path.call(print, "value"));
  20774. return concat$11(parts);
  20775. case "ObjectTypeIndexer":
  20776. {
  20777. var _variance = getFlowVariance(n);
  20778. return concat$11([_variance || "", "[", path.call(print, "id"), n.id ? ": " : "", path.call(print, "key"), "]: ", path.call(print, "value")]);
  20779. }
  20780. case "ObjectTypeProperty":
  20781. {
  20782. var _variance2 = getFlowVariance(n);
  20783. var modifier = "";
  20784. if (n.proto) {
  20785. modifier = "proto ";
  20786. } else if (n.static) {
  20787. modifier = "static ";
  20788. }
  20789. return concat$11([modifier, isGetterOrSetter(n) ? n.kind + " " : "", _variance2 || "", printPropertyKey(path, options, print), printOptionalToken(path), isFunctionNotation(n, options) ? "" : ": ", path.call(print, "value")]);
  20790. }
  20791. case "QualifiedTypeIdentifier":
  20792. return concat$11([path.call(print, "qualification"), ".", path.call(print, "id")]);
  20793. case "StringLiteralTypeAnnotation":
  20794. return nodeStr(n, options);
  20795. case "NumberLiteralTypeAnnotation":
  20796. assert$3.strictEqual(_typeof(n.value), "number");
  20797. if (n.extra != null) {
  20798. return printNumber$2(n.extra.raw);
  20799. }
  20800. return printNumber$2(n.raw);
  20801. case "StringTypeAnnotation":
  20802. return "string";
  20803. case "DeclareTypeAlias":
  20804. case "TypeAlias":
  20805. {
  20806. if (n.type === "DeclareTypeAlias" || isNodeStartingWithDeclare(n, options)) {
  20807. parts.push("declare ");
  20808. }
  20809. var _printed4 = printAssignmentRight(n.id, n.right, path.call(print, "right"), options);
  20810. parts.push("type ", path.call(print, "id"), path.call(print, "typeParameters"), " =", _printed4, semi);
  20811. return group$10(concat$11(parts));
  20812. }
  20813. case "TypeCastExpression":
  20814. {
  20815. var value = path.getValue(); // Flow supports a comment syntax for specifying type annotations: https://flow.org/en/docs/types/comments/.
  20816. // Unfortunately, its parser doesn't differentiate between comment annotations and regular
  20817. // annotations when producing an AST. So to preserve parentheses around type casts that use
  20818. // the comment syntax, we need to hackily read the source itself to see if the code contains
  20819. // a type annotation comment.
  20820. //
  20821. // Note that we're able to use the normal whitespace regex here because the Flow parser has
  20822. // already deemed this AST node to be a type cast. Only the Babel parser needs the
  20823. // non-line-break whitespace regex, which is why hasFlowShorthandAnnotationComment() is
  20824. // implemented differently.
  20825. var commentSyntax = value && value.typeAnnotation && value.typeAnnotation.range && options.originalText.substring(value.typeAnnotation.range[0]).match(/^\/\*\s*:/);
  20826. return concat$11(["(", path.call(print, "expression"), commentSyntax ? " /*" : "", ": ", path.call(print, "typeAnnotation"), commentSyntax ? " */" : "", ")"]);
  20827. }
  20828. case "TypeParameterDeclaration":
  20829. case "TypeParameterInstantiation":
  20830. {
  20831. var _value = path.getValue();
  20832. var commentStart = _value.range ? options.originalText.substring(0, _value.range[0]).lastIndexOf("/*") : -1; // As noted in the TypeCastExpression comments above, we're able to use a normal whitespace regex here
  20833. // because we know for sure that this is a type definition.
  20834. var _commentSyntax = commentStart >= 0 && options.originalText.substring(commentStart).match(/^\/\*\s*::/);
  20835. if (_commentSyntax) {
  20836. return concat$11(["/*:: ", printTypeParameters(path, options, print, "params"), " */"]);
  20837. }
  20838. return printTypeParameters(path, options, print, "params");
  20839. }
  20840. case "TSTypeParameterDeclaration":
  20841. case "TSTypeParameterInstantiation":
  20842. return printTypeParameters(path, options, print, "params");
  20843. case "TSTypeParameter":
  20844. case "TypeParameter":
  20845. {
  20846. var _parent9 = path.getParentNode();
  20847. if (_parent9.type === "TSMappedType") {
  20848. parts.push("[", path.call(print, "name"));
  20849. if (n.constraint) {
  20850. parts.push(" in ", path.call(print, "constraint"));
  20851. }
  20852. parts.push("]");
  20853. return concat$11(parts);
  20854. }
  20855. var _variance3 = getFlowVariance(n);
  20856. if (_variance3) {
  20857. parts.push(_variance3);
  20858. }
  20859. parts.push(path.call(print, "name"));
  20860. if (n.bound) {
  20861. parts.push(": ");
  20862. parts.push(path.call(print, "bound"));
  20863. }
  20864. if (n.constraint) {
  20865. parts.push(" extends ", path.call(print, "constraint"));
  20866. }
  20867. if (n["default"]) {
  20868. parts.push(" = ", path.call(print, "default"));
  20869. }
  20870. return concat$11(parts);
  20871. }
  20872. case "TypeofTypeAnnotation":
  20873. return concat$11(["typeof ", path.call(print, "argument")]);
  20874. case "VoidTypeAnnotation":
  20875. return "void";
  20876. case "InferredPredicate":
  20877. return "%checks";
  20878. // Unhandled types below. If encountered, nodes of these types should
  20879. // be either left alone or desugared into AST types that are fully
  20880. // supported by the pretty-printer.
  20881. case "DeclaredPredicate":
  20882. return concat$11(["%checks(", path.call(print, "value"), ")"]);
  20883. case "TSAbstractKeyword":
  20884. return "abstract";
  20885. case "TSAnyKeyword":
  20886. return "any";
  20887. case "TSAsyncKeyword":
  20888. return "async";
  20889. case "TSBooleanKeyword":
  20890. return "boolean";
  20891. case "TSBigIntKeyword":
  20892. return "bigint";
  20893. case "TSConstKeyword":
  20894. return "const";
  20895. case "TSDeclareKeyword":
  20896. return "declare";
  20897. case "TSExportKeyword":
  20898. return "export";
  20899. case "TSNeverKeyword":
  20900. return "never";
  20901. case "TSNumberKeyword":
  20902. return "number";
  20903. case "TSObjectKeyword":
  20904. return "object";
  20905. case "TSProtectedKeyword":
  20906. return "protected";
  20907. case "TSPrivateKeyword":
  20908. return "private";
  20909. case "TSPublicKeyword":
  20910. return "public";
  20911. case "TSReadonlyKeyword":
  20912. return "readonly";
  20913. case "TSSymbolKeyword":
  20914. return "symbol";
  20915. case "TSStaticKeyword":
  20916. return "static";
  20917. case "TSStringKeyword":
  20918. return "string";
  20919. case "TSUndefinedKeyword":
  20920. return "undefined";
  20921. case "TSUnknownKeyword":
  20922. return "unknown";
  20923. case "TSVoidKeyword":
  20924. return "void";
  20925. case "TSAsExpression":
  20926. return concat$11([path.call(print, "expression"), " as ", path.call(print, "typeAnnotation")]);
  20927. case "TSArrayType":
  20928. return concat$11([path.call(print, "elementType"), "[]"]);
  20929. case "TSPropertySignature":
  20930. {
  20931. if (n.export) {
  20932. parts.push("export ");
  20933. }
  20934. if (n.accessibility) {
  20935. parts.push(n.accessibility + " ");
  20936. }
  20937. if (n.static) {
  20938. parts.push("static ");
  20939. }
  20940. if (n.readonly) {
  20941. parts.push("readonly ");
  20942. }
  20943. if (n.computed) {
  20944. parts.push("[");
  20945. }
  20946. parts.push(printPropertyKey(path, options, print));
  20947. if (n.computed) {
  20948. parts.push("]");
  20949. }
  20950. parts.push(printOptionalToken(path));
  20951. if (n.typeAnnotation) {
  20952. parts.push(": ");
  20953. parts.push(path.call(print, "typeAnnotation"));
  20954. } // This isn't valid semantically, but it's in the AST so we can print it.
  20955. if (n.initializer) {
  20956. parts.push(" = ", path.call(print, "initializer"));
  20957. }
  20958. return concat$11(parts);
  20959. }
  20960. case "TSParameterProperty":
  20961. if (n.accessibility) {
  20962. parts.push(n.accessibility + " ");
  20963. }
  20964. if (n.export) {
  20965. parts.push("export ");
  20966. }
  20967. if (n.static) {
  20968. parts.push("static ");
  20969. }
  20970. if (n.readonly) {
  20971. parts.push("readonly ");
  20972. }
  20973. parts.push(path.call(print, "parameter"));
  20974. return concat$11(parts);
  20975. case "TSTypeReference":
  20976. return concat$11([path.call(print, "typeName"), printTypeParameters(path, options, print, "typeParameters")]);
  20977. case "TSTypeQuery":
  20978. return concat$11(["typeof ", path.call(print, "exprName")]);
  20979. case "TSParenthesizedType":
  20980. {
  20981. return path.call(print, "typeAnnotation");
  20982. }
  20983. case "TSIndexSignature":
  20984. {
  20985. var _parent10 = path.getParentNode();
  20986. return concat$11([n.export ? "export " : "", n.accessibility ? concat$11([n.accessibility, " "]) : "", n.static ? "static " : "", n.readonly ? "readonly " : "", "[", n.parameters ? concat$11(path.map(print, "parameters")) : "", "]: ", path.call(print, "typeAnnotation"), _parent10.type === "ClassBody" ? semi : ""]);
  20987. }
  20988. case "TSTypePredicate":
  20989. return concat$11([path.call(print, "parameterName"), " is ", path.call(print, "typeAnnotation")]);
  20990. case "TSNonNullExpression":
  20991. return concat$11([path.call(print, "expression"), "!"]);
  20992. case "TSThisType":
  20993. return "this";
  20994. case "TSImportType":
  20995. return concat$11([!n.isTypeOf ? "" : "typeof ", "import(", path.call(print, "parameter"), ")", !n.qualifier ? "" : concat$11([".", path.call(print, "qualifier")]), printTypeParameters(path, options, print, "typeParameters")]);
  20996. case "TSLiteralType":
  20997. return path.call(print, "literal");
  20998. case "TSIndexedAccessType":
  20999. return concat$11([path.call(print, "objectType"), "[", path.call(print, "indexType"), "]"]);
  21000. case "TSConstructSignatureDeclaration":
  21001. case "TSCallSignatureDeclaration":
  21002. case "TSConstructorType":
  21003. {
  21004. if (n.type !== "TSCallSignatureDeclaration") {
  21005. parts.push("new ");
  21006. }
  21007. parts.push(group$10(printFunctionParams(path, print, options,
  21008. /* expandArg */
  21009. false,
  21010. /* printTypeParams */
  21011. true)));
  21012. if (n.returnType) {
  21013. var isType = n.type === "TSConstructorType";
  21014. parts.push(isType ? " => " : ": ", path.call(print, "returnType"));
  21015. }
  21016. return concat$11(parts);
  21017. }
  21018. case "TSTypeOperator":
  21019. return concat$11([n.operator, " ", path.call(print, "typeAnnotation")]);
  21020. case "TSMappedType":
  21021. return group$10(concat$11(["{", indent$6(concat$11([options.bracketSpacing ? line$8 : softline$5, n.readonly ? concat$11([getTypeScriptMappedTypeModifier(n.readonly, "readonly"), " "]) : "", printTypeScriptModifiers(path, options, print), path.call(print, "typeParameter"), n.optional ? getTypeScriptMappedTypeModifier(n.optional, "?") : "", ": ", path.call(print, "typeAnnotation")])), comments.printDanglingComments(path, options,
  21022. /* sameIndent */
  21023. true), options.bracketSpacing ? line$8 : softline$5, "}"]));
  21024. case "TSMethodSignature":
  21025. parts.push(n.accessibility ? concat$11([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,
  21026. /* expandArg */
  21027. false,
  21028. /* printTypeParams */
  21029. true));
  21030. if (n.returnType) {
  21031. parts.push(": ", path.call(print, "returnType"));
  21032. }
  21033. return group$10(concat$11(parts));
  21034. case "TSNamespaceExportDeclaration":
  21035. parts.push("export as namespace ", path.call(print, "id"));
  21036. if (options.semi) {
  21037. parts.push(";");
  21038. }
  21039. return group$10(concat$11(parts));
  21040. case "TSEnumDeclaration":
  21041. if (isNodeStartingWithDeclare(n, options)) {
  21042. parts.push("declare ");
  21043. }
  21044. if (n.modifiers) {
  21045. parts.push(printTypeScriptModifiers(path, options, print));
  21046. }
  21047. if (n.const) {
  21048. parts.push("const ");
  21049. }
  21050. parts.push("enum ", path.call(print, "id"), " ");
  21051. if (n.members.length === 0) {
  21052. parts.push(group$10(concat$11(["{", comments.printDanglingComments(path, options), softline$5, "}"])));
  21053. } else {
  21054. parts.push(group$10(concat$11(["{", indent$6(concat$11([hardline$8, printArrayItems(path, options, "members", print), shouldPrintComma$1(options, "es5") ? "," : ""])), comments.printDanglingComments(path, options,
  21055. /* sameIndent */
  21056. true), hardline$8, "}"])));
  21057. }
  21058. return concat$11(parts);
  21059. case "TSEnumMember":
  21060. parts.push(path.call(print, "id"));
  21061. if (n.initializer) {
  21062. parts.push(" = ", path.call(print, "initializer"));
  21063. }
  21064. return concat$11(parts);
  21065. case "TSImportEqualsDeclaration":
  21066. if (n.isExport) {
  21067. parts.push("export ");
  21068. }
  21069. parts.push("import ", path.call(print, "id"), " = ", path.call(print, "moduleReference"));
  21070. if (options.semi) {
  21071. parts.push(";");
  21072. }
  21073. return group$10(concat$11(parts));
  21074. case "TSExternalModuleReference":
  21075. return concat$11(["require(", path.call(print, "expression"), ")"]);
  21076. case "TSModuleDeclaration":
  21077. {
  21078. var _parent11 = path.getParentNode();
  21079. var isExternalModule = isLiteral(n.id);
  21080. var parentIsDeclaration = _parent11.type === "TSModuleDeclaration";
  21081. var bodyIsDeclaration = n.body && n.body.type === "TSModuleDeclaration";
  21082. if (parentIsDeclaration) {
  21083. parts.push(".");
  21084. } else {
  21085. if (n.declare === true) {
  21086. parts.push("declare ");
  21087. }
  21088. parts.push(printTypeScriptModifiers(path, options, print));
  21089. var textBetweenNodeAndItsId = options.originalText.slice(options.locStart(n), options.locStart(n.id)); // Global declaration looks like this:
  21090. // (declare)? global { ... }
  21091. var isGlobalDeclaration = n.id.type === "Identifier" && n.id.name === "global" && !/namespace|module/.test(textBetweenNodeAndItsId);
  21092. if (!isGlobalDeclaration) {
  21093. parts.push(isExternalModule || /(^|\s)module(\s|$)/.test(textBetweenNodeAndItsId) ? "module " : "namespace ");
  21094. }
  21095. }
  21096. parts.push(path.call(print, "id"));
  21097. if (bodyIsDeclaration) {
  21098. parts.push(path.call(print, "body"));
  21099. } else if (n.body) {
  21100. parts.push(" ", group$10(path.call(print, "body")));
  21101. } else {
  21102. parts.push(semi);
  21103. }
  21104. return concat$11(parts);
  21105. }
  21106. case "PrivateName":
  21107. return concat$11(["#", path.call(print, "id")]);
  21108. case "TSConditionalType":
  21109. return printTernaryOperator(path, options, print, {
  21110. beforeParts: function beforeParts() {
  21111. return [path.call(print, "checkType"), " ", "extends", " ", path.call(print, "extendsType")];
  21112. },
  21113. afterParts: function afterParts() {
  21114. return [];
  21115. },
  21116. shouldCheckJsx: false,
  21117. conditionalNodeType: "TSConditionalType",
  21118. consequentNodePropertyName: "trueType",
  21119. alternateNodePropertyName: "falseType",
  21120. testNodePropertyName: "checkType",
  21121. breakNested: true
  21122. });
  21123. case "TSInferType":
  21124. return concat$11(["infer", " ", path.call(print, "typeParameter")]);
  21125. case "InterpreterDirective":
  21126. parts.push("#!", n.value, hardline$8);
  21127. if (isNextLineEmpty$4(options.originalText, n, options)) {
  21128. parts.push(hardline$8);
  21129. }
  21130. return concat$11(parts);
  21131. case "NGRoot":
  21132. return concat$11([].concat(path.call(print, "node"), !n.node.comments || n.node.comments.length === 0 ? [] : concat$11([" //", n.node.comments[0].value.trimRight()])));
  21133. case "NGChainedExpression":
  21134. return group$10(join$7(concat$11([";", line$8]), path.map(function (childPath) {
  21135. return hasNgSideEffect(childPath) ? print(childPath) : concat$11(["(", print(childPath), ")"]);
  21136. }, "expressions")));
  21137. case "NGEmptyExpression":
  21138. return "";
  21139. case "NGQuotedExpression":
  21140. return concat$11([n.prefix, ":", n.value]);
  21141. case "NGMicrosyntax":
  21142. return concat$11(path.map(function (childPath, index) {
  21143. return concat$11([index === 0 ? "" : isNgForOf(childPath.getValue(), index, n) ? " " : concat$11([";", line$8]), print(childPath)]);
  21144. }, "body"));
  21145. case "NGMicrosyntaxKey":
  21146. return /^[a-z_$][a-z0-9_$]*(-[a-z_$][a-z0-9_$])*$/i.test(n.name) ? n.name : JSON.stringify(n.name);
  21147. case "NGMicrosyntaxExpression":
  21148. return concat$11([path.call(print, "expression"), n.alias === null ? "" : concat$11([" as ", path.call(print, "alias")])]);
  21149. case "NGMicrosyntaxKeyedExpression":
  21150. {
  21151. var index = path.getName();
  21152. var _parentNode2 = path.getParentNode();
  21153. var shouldNotPrintColon = isNgForOf(n, index, _parentNode2) || (index === 1 && (n.key.name === "then" || n.key.name === "else") || index === 2 && n.key.name === "else" && _parentNode2.body[index - 1].type === "NGMicrosyntaxKeyedExpression" && _parentNode2.body[index - 1].key.name === "then") && _parentNode2.body[0].type === "NGMicrosyntaxExpression";
  21154. return concat$11([path.call(print, "key"), shouldNotPrintColon ? " " : ": ", path.call(print, "expression")]);
  21155. }
  21156. case "NGMicrosyntaxLet":
  21157. return concat$11(["let ", path.call(print, "key"), n.value === null ? "" : concat$11([" = ", path.call(print, "value")])]);
  21158. case "NGMicrosyntaxAs":
  21159. return concat$11([path.call(print, "key"), " as ", path.call(print, "alias")]);
  21160. default:
  21161. /* istanbul ignore next */
  21162. throw new Error("unknown type: " + JSON.stringify(n.type));
  21163. }
  21164. }
  21165. function isNgForOf(node, index, parentNode) {
  21166. return node.type === "NGMicrosyntaxKeyedExpression" && node.key.name === "of" && index === 1 && parentNode.body[0].type === "NGMicrosyntaxLet" && parentNode.body[0].value === null;
  21167. }
  21168. /** identify if an angular expression seems to have side effects */
  21169. function hasNgSideEffect(path) {
  21170. return hasNode(path.getValue(), function (node) {
  21171. switch (node.type) {
  21172. case undefined:
  21173. return false;
  21174. case "CallExpression":
  21175. case "OptionalCallExpression":
  21176. case "AssignmentExpression":
  21177. return true;
  21178. }
  21179. });
  21180. }
  21181. function printStatementSequence(path, options, print) {
  21182. var printed = [];
  21183. var bodyNode = path.getNode();
  21184. var isClass = bodyNode.type === "ClassBody";
  21185. path.map(function (stmtPath, i) {
  21186. var stmt = stmtPath.getValue(); // Just in case the AST has been modified to contain falsy
  21187. // "statements," it's safer simply to skip them.
  21188. /* istanbul ignore if */
  21189. if (!stmt) {
  21190. return;
  21191. } // Skip printing EmptyStatement nodes to avoid leaving stray
  21192. // semicolons lying around.
  21193. if (stmt.type === "EmptyStatement") {
  21194. return;
  21195. }
  21196. var stmtPrinted = print(stmtPath);
  21197. var text = options.originalText;
  21198. var parts = []; // in no-semi mode, prepend statement with semicolon if it might break ASI
  21199. // don't prepend the only JSX element in a program with semicolon
  21200. if (!options.semi && !isClass && !isTheOnlyJSXElementInMarkdown(options, stmtPath) && stmtNeedsASIProtection(stmtPath, options)) {
  21201. if (stmt.comments && stmt.comments.some(function (comment) {
  21202. return comment.leading;
  21203. })) {
  21204. parts.push(print(stmtPath, {
  21205. needsSemi: true
  21206. }));
  21207. } else {
  21208. parts.push(";", stmtPrinted);
  21209. }
  21210. } else {
  21211. parts.push(stmtPrinted);
  21212. }
  21213. if (!options.semi && isClass) {
  21214. if (classPropMayCauseASIProblems(stmtPath)) {
  21215. parts.push(";");
  21216. } else if (stmt.type === "ClassProperty") {
  21217. var nextChild = bodyNode.body[i + 1];
  21218. if (classChildNeedsASIProtection(nextChild)) {
  21219. parts.push(";");
  21220. }
  21221. }
  21222. }
  21223. if (isNextLineEmpty$4(text, stmt, options) && !isLastStatement(stmtPath)) {
  21224. parts.push(hardline$8);
  21225. }
  21226. printed.push(concat$11(parts));
  21227. });
  21228. return join$7(hardline$8, printed);
  21229. }
  21230. function printPropertyKey(path, options, print) {
  21231. var node = path.getNode();
  21232. var key = node.key;
  21233. if (key.type === "Identifier" && !node.computed && options.parser === "json") {
  21234. // a -> "a"
  21235. return path.call(function (keyPath) {
  21236. return comments.printComments(keyPath, function () {
  21237. return JSON.stringify(key.name);
  21238. }, options);
  21239. }, "key");
  21240. }
  21241. if (isStringLiteral(key) && isIdentifierName(key.value) && !node.computed && options.parser !== "json" && !(options.parser === "typescript" && node.type === "ClassProperty")) {
  21242. // 'a' -> a
  21243. return path.call(function (keyPath) {
  21244. return comments.printComments(keyPath, function () {
  21245. return key.value;
  21246. }, options);
  21247. }, "key");
  21248. }
  21249. return path.call(print, "key");
  21250. }
  21251. function printMethod(path, options, print) {
  21252. var node = path.getNode();
  21253. var semi = options.semi ? ";" : "";
  21254. var kind = node.kind;
  21255. var parts = [];
  21256. if (node.type === "ObjectMethod" || node.type === "ClassMethod" || node.type === "ClassPrivateMethod") {
  21257. node.value = node;
  21258. }
  21259. if (node.value.async) {
  21260. parts.push("async ");
  21261. }
  21262. if (!kind || kind === "init" || kind === "method" || kind === "constructor") {
  21263. if (node.value.generator) {
  21264. parts.push("*");
  21265. }
  21266. } else {
  21267. assert$3.ok(kind === "get" || kind === "set");
  21268. parts.push(kind, " ");
  21269. }
  21270. var key = printPropertyKey(path, options, print);
  21271. if (node.computed) {
  21272. key = concat$11(["[", key, "]"]);
  21273. }
  21274. parts.push(key, concat$11(path.call(function (valuePath) {
  21275. return [printFunctionTypeParameters(valuePath, options, print), group$10(concat$11([printFunctionParams(valuePath, print, options), printReturnType(valuePath, print, options)]))];
  21276. }, "value")));
  21277. if (!node.value.body || node.value.body.length === 0) {
  21278. parts.push(semi);
  21279. } else {
  21280. parts.push(" ", path.call(print, "value", "body"));
  21281. }
  21282. return concat$11(parts);
  21283. }
  21284. function couldGroupArg(arg) {
  21285. return arg.type === "ObjectExpression" && (arg.properties.length > 0 || arg.comments) || arg.type === "ArrayExpression" && (arg.elements.length > 0 || arg.comments) || arg.type === "TSTypeAssertion" || arg.type === "TSAsExpression" || arg.type === "FunctionExpression" || arg.type === "ArrowFunctionExpression" && !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" || arg.body.type === "ConditionalExpression" || isJSXNode(arg.body));
  21286. }
  21287. function shouldGroupLastArg(args) {
  21288. var lastArg = getLast$4(args);
  21289. var penultimateArg = getPenultimate$1(args);
  21290. return !hasLeadingComment(lastArg) && !hasTrailingComment(lastArg) && couldGroupArg(lastArg) && ( // If the last two arguments are of the same type,
  21291. // disable last element expansion.
  21292. !penultimateArg || penultimateArg.type !== lastArg.type);
  21293. }
  21294. function shouldGroupFirstArg(args) {
  21295. if (args.length !== 2) {
  21296. return false;
  21297. }
  21298. var firstArg = args[0];
  21299. var secondArg = args[1];
  21300. return (!firstArg.comments || !firstArg.comments.length) && (firstArg.type === "FunctionExpression" || firstArg.type === "ArrowFunctionExpression" && firstArg.body.type === "BlockStatement") && secondArg.type !== "FunctionExpression" && secondArg.type !== "ArrowFunctionExpression" && secondArg.type !== "ConditionalExpression" && !couldGroupArg(secondArg);
  21301. }
  21302. function isSimpleFlowType(node) {
  21303. var flowTypeAnnotations = ["AnyTypeAnnotation", "NullLiteralTypeAnnotation", "GenericTypeAnnotation", "ThisTypeAnnotation", "NumberTypeAnnotation", "VoidTypeAnnotation", "EmptyTypeAnnotation", "MixedTypeAnnotation", "BooleanTypeAnnotation", "BooleanLiteralTypeAnnotation", "StringTypeAnnotation"];
  21304. return node && flowTypeAnnotations.indexOf(node.type) !== -1 && !(node.type === "GenericTypeAnnotation" && node.typeParameters);
  21305. }
  21306. var functionCompositionFunctionNames = new Set(["pipe", // RxJS, Ramda
  21307. "pipeP", // Ramda
  21308. "pipeK", // Ramda
  21309. "compose", // Ramda, Redux
  21310. "composeFlipped", // Not from any library, but common in Haskell, so supported
  21311. "composeP", // Ramda
  21312. "composeK", // Ramda
  21313. "flow", // Lodash
  21314. "flowRight", // Lodash
  21315. "connect", // Redux
  21316. "createSelector" // Reselect
  21317. ]);
  21318. var ordinaryMethodNames = new Set(["connect" // GObject, MongoDB
  21319. ]);
  21320. function isFunctionCompositionFunction(node) {
  21321. switch (node.type) {
  21322. case "OptionalMemberExpression":
  21323. case "MemberExpression":
  21324. {
  21325. return isFunctionCompositionFunction(node.property) && !ordinaryMethodNames.has(node.property.name);
  21326. }
  21327. case "Identifier":
  21328. {
  21329. return functionCompositionFunctionNames.has(node.name);
  21330. }
  21331. case "StringLiteral":
  21332. case "Literal":
  21333. {
  21334. return functionCompositionFunctionNames.has(node.value);
  21335. }
  21336. }
  21337. }
  21338. function printArgumentsList(path, options, print) {
  21339. var node = path.getValue();
  21340. var args = node.arguments;
  21341. if (args.length === 0) {
  21342. return concat$11(["(", comments.printDanglingComments(path, options,
  21343. /* sameIndent */
  21344. true), ")"]);
  21345. } // useEffect(() => { ... }, [foo, bar, baz])
  21346. if (args.length === 2 && args[0].type === "ArrowFunctionExpression" && args[0].params.length === 0 && args[0].body.type === "BlockStatement" && args[1].type === "ArrayExpression" && !args.find(function (arg) {
  21347. return arg.leadingComments || arg.trailingComments;
  21348. })) {
  21349. return concat$11(["(", path.call(print, "arguments", 0), ", ", path.call(print, "arguments", 1), ")"]);
  21350. }
  21351. var anyArgEmptyLine = false;
  21352. var hasEmptyLineFollowingFirstArg = false;
  21353. var lastArgIndex = args.length - 1;
  21354. var printedArguments = path.map(function (argPath, index) {
  21355. var arg = argPath.getNode();
  21356. var parts = [print(argPath)];
  21357. if (index === lastArgIndex) {// do nothing
  21358. } else if (isNextLineEmpty$4(options.originalText, arg, options)) {
  21359. if (index === 0) {
  21360. hasEmptyLineFollowingFirstArg = true;
  21361. }
  21362. anyArgEmptyLine = true;
  21363. parts.push(",", hardline$8, hardline$8);
  21364. } else {
  21365. parts.push(",", line$8);
  21366. }
  21367. return concat$11(parts);
  21368. }, "arguments");
  21369. var maybeTrailingComma = shouldPrintComma$1(options, "all") ? "," : "";
  21370. function allArgsBrokenOut() {
  21371. return group$10(concat$11(["(", indent$6(concat$11([line$8, concat$11(printedArguments)])), maybeTrailingComma, line$8, ")"]), {
  21372. shouldBreak: true
  21373. });
  21374. } // We want to get
  21375. // pipe(
  21376. // x => x + 1,
  21377. // x => x - 1
  21378. // )
  21379. // here, but not
  21380. // process.stdout.pipe(socket)
  21381. if (isFunctionCompositionFunction(node.callee) && args.length > 1) {
  21382. return allArgsBrokenOut();
  21383. }
  21384. var shouldGroupFirst = shouldGroupFirstArg(args);
  21385. var shouldGroupLast = shouldGroupLastArg(args);
  21386. if (shouldGroupFirst || shouldGroupLast) {
  21387. 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
  21388. var printedExpanded;
  21389. var i = 0;
  21390. path.each(function (argPath) {
  21391. if (shouldGroupFirst && i === 0) {
  21392. printedExpanded = [concat$11([argPath.call(function (p) {
  21393. return print(p, {
  21394. expandFirstArg: true
  21395. });
  21396. }), printedArguments.length > 1 ? "," : "", hasEmptyLineFollowingFirstArg ? hardline$8 : line$8, hasEmptyLineFollowingFirstArg ? hardline$8 : ""])].concat(printedArguments.slice(1));
  21397. }
  21398. if (shouldGroupLast && i === args.length - 1) {
  21399. printedExpanded = printedArguments.slice(0, -1).concat(argPath.call(function (p) {
  21400. return print(p, {
  21401. expandLastArg: true
  21402. });
  21403. }));
  21404. }
  21405. i++;
  21406. }, "arguments");
  21407. var somePrintedArgumentsWillBreak = printedArguments.some(willBreak$1);
  21408. return concat$11([somePrintedArgumentsWillBreak ? breakParent$3 : "", conditionalGroup$1([concat$11([ifBreak$6(indent$6(concat$11(["(", softline$5, concat$11(printedExpanded)])), concat$11(["(", concat$11(printedExpanded)])), somePrintedArgumentsWillBreak ? concat$11([ifBreak$6(maybeTrailingComma), softline$5]) : "", ")"]), shouldGroupFirst ? concat$11(["(", group$10(printedExpanded[0], {
  21409. shouldBreak: true
  21410. }), concat$11(printedExpanded.slice(1)), ")"]) : concat$11(["(", concat$11(printedArguments.slice(0, -1)), group$10(getLast$4(printedExpanded), {
  21411. shouldBreak: true
  21412. }), ")"]), allArgsBrokenOut()], {
  21413. shouldBreak: shouldBreak
  21414. })]);
  21415. }
  21416. return group$10(concat$11(["(", indent$6(concat$11([softline$5, concat$11(printedArguments)])), ifBreak$6(shouldPrintComma$1(options, "all") ? "," : ""), softline$5, ")"]), {
  21417. shouldBreak: printedArguments.some(willBreak$1) || anyArgEmptyLine
  21418. });
  21419. }
  21420. function printTypeAnnotation(path, options, print) {
  21421. var node = path.getValue();
  21422. if (!node.typeAnnotation) {
  21423. return "";
  21424. }
  21425. var parentNode = path.getParentNode();
  21426. var isDefinite = node.definite || parentNode && parentNode.type === "VariableDeclarator" && parentNode.definite;
  21427. var isFunctionDeclarationIdentifier = parentNode.type === "DeclareFunction" && parentNode.id === node;
  21428. if (isFlowAnnotationComment(options.originalText, node.typeAnnotation, options)) {
  21429. return concat$11([" /*: ", path.call(print, "typeAnnotation"), " */"]);
  21430. }
  21431. return concat$11([isFunctionDeclarationIdentifier ? "" : isDefinite ? "!: " : ": ", path.call(print, "typeAnnotation")]);
  21432. }
  21433. function printFunctionTypeParameters(path, options, print) {
  21434. var fun = path.getValue();
  21435. if (fun.typeArguments) {
  21436. return path.call(print, "typeArguments");
  21437. }
  21438. if (fun.typeParameters) {
  21439. return path.call(print, "typeParameters");
  21440. }
  21441. return "";
  21442. }
  21443. function printFunctionParams(path, print, options, expandArg, printTypeParams) {
  21444. var fun = path.getValue();
  21445. var paramsField = fun.parameters ? "parameters" : "params";
  21446. var typeParams = printTypeParams ? printFunctionTypeParameters(path, options, print) : "";
  21447. var printed = [];
  21448. if (fun[paramsField]) {
  21449. printed = path.map(print, paramsField);
  21450. }
  21451. if (fun.rest) {
  21452. printed.push(concat$11(["...", path.call(print, "rest")]));
  21453. }
  21454. if (printed.length === 0) {
  21455. return concat$11([typeParams, "(", comments.printDanglingComments(path, options,
  21456. /* sameIndent */
  21457. true, function (comment) {
  21458. return getNextNonSpaceNonCommentCharacter$1(options.originalText, comment, options.locEnd) === ")";
  21459. }), ")"]);
  21460. }
  21461. var lastParam = getLast$4(fun[paramsField]); // If the parent is a call with the first/last argument expansion and this is the
  21462. // params of the first/last argument, we dont want the arguments to break and instead
  21463. // want the whole expression to be on a new line.
  21464. //
  21465. // Good: Bad:
  21466. // verylongcall( verylongcall((
  21467. // (a, b) => { a,
  21468. // } b,
  21469. // }) ) => {
  21470. // })
  21471. if (expandArg && !(fun[paramsField] && fun[paramsField].some(function (n) {
  21472. return n.comments;
  21473. }))) {
  21474. return group$10(concat$11([removeLines$2(typeParams), "(", join$7(", ", printed.map(removeLines$2)), ")"]));
  21475. } // Single object destructuring should hug
  21476. //
  21477. // function({
  21478. // a,
  21479. // b,
  21480. // c
  21481. // }) {}
  21482. if (shouldHugArguments(fun)) {
  21483. return concat$11([typeParams, "(", join$7(", ", printed), ")"]);
  21484. }
  21485. var parent = path.getParentNode(); // don't break in specs, eg; `it("should maintain parens around done even when long", (done) => {})`
  21486. if (isTestCall(parent)) {
  21487. return concat$11([typeParams, "(", join$7(", ", printed), ")"]);
  21488. }
  21489. var isFlowShorthandWithOneArg = (isObjectTypePropertyAFunction(parent, options) || isTypeAnnotationAFunction(parent, options) || parent.type === "TypeAlias" || parent.type === "UnionTypeAnnotation" || parent.type === "TSUnionType" || parent.type === "IntersectionTypeAnnotation" || parent.type === "FunctionTypeAnnotation" && parent.returnType === fun) && fun[paramsField].length === 1 && fun[paramsField][0].name === null && fun[paramsField][0].typeAnnotation && fun.typeParameters === null && isSimpleFlowType(fun[paramsField][0].typeAnnotation) && !fun.rest;
  21490. if (isFlowShorthandWithOneArg) {
  21491. if (options.arrowParens === "always") {
  21492. return concat$11(["(", concat$11(printed), ")"]);
  21493. }
  21494. return concat$11(printed);
  21495. }
  21496. var canHaveTrailingComma = !(lastParam && lastParam.type === "RestElement") && !fun.rest;
  21497. return concat$11([typeParams, "(", indent$6(concat$11([softline$5, join$7(concat$11([",", line$8]), printed)])), ifBreak$6(canHaveTrailingComma && shouldPrintComma$1(options, "all") ? "," : ""), softline$5, ")"]);
  21498. }
  21499. function shouldPrintParamsWithoutParens(path, options) {
  21500. if (options.arrowParens === "always") {
  21501. return false;
  21502. }
  21503. if (options.arrowParens === "avoid") {
  21504. var node = path.getValue();
  21505. return canPrintParamsWithoutParens(node);
  21506. } // Fallback default; should be unreachable
  21507. return false;
  21508. }
  21509. function canPrintParamsWithoutParens(node) {
  21510. 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;
  21511. }
  21512. function printFunctionDeclaration(path, print, options) {
  21513. var n = path.getValue();
  21514. var parts = [];
  21515. if (n.async) {
  21516. parts.push("async ");
  21517. }
  21518. parts.push("function");
  21519. if (n.generator) {
  21520. parts.push("*");
  21521. }
  21522. if (n.id) {
  21523. parts.push(" ", path.call(print, "id"));
  21524. }
  21525. parts.push(printFunctionTypeParameters(path, options, print), group$10(concat$11([printFunctionParams(path, print, options), printReturnType(path, print, options)])), n.body ? " " : "", path.call(print, "body"));
  21526. return concat$11(parts);
  21527. }
  21528. function printObjectMethod(path, options, print) {
  21529. var objMethod = path.getValue();
  21530. var parts = [];
  21531. if (objMethod.async) {
  21532. parts.push("async ");
  21533. }
  21534. if (objMethod.generator) {
  21535. parts.push("*");
  21536. }
  21537. if (objMethod.method || objMethod.kind === "get" || objMethod.kind === "set") {
  21538. return printMethod(path, options, print);
  21539. }
  21540. var key = printPropertyKey(path, options, print);
  21541. if (objMethod.computed) {
  21542. parts.push("[", key, "]");
  21543. } else {
  21544. parts.push(key);
  21545. }
  21546. parts.push(printFunctionTypeParameters(path, options, print), group$10(concat$11([printFunctionParams(path, print, options), printReturnType(path, print, options)])), " ", path.call(print, "body"));
  21547. return concat$11(parts);
  21548. }
  21549. function printReturnType(path, print, options) {
  21550. var n = path.getValue();
  21551. var returnType = path.call(print, "returnType");
  21552. if (n.returnType && isFlowAnnotationComment(options.originalText, n.returnType, options)) {
  21553. return concat$11([" /*: ", returnType, " */"]);
  21554. }
  21555. var parts = [returnType]; // prepend colon to TypeScript type annotation
  21556. if (n.returnType && n.returnType.typeAnnotation) {
  21557. parts.unshift(": ");
  21558. }
  21559. if (n.predicate) {
  21560. // The return type will already add the colon, but otherwise we
  21561. // need to do it ourselves
  21562. parts.push(n.returnType ? " " : ": ", path.call(print, "predicate"));
  21563. }
  21564. return concat$11(parts);
  21565. }
  21566. function printExportDeclaration(path, options, print) {
  21567. var decl = path.getValue();
  21568. var semi = options.semi ? ";" : "";
  21569. var parts = ["export "];
  21570. var isDefault = decl["default"] || decl.type === "ExportDefaultDeclaration";
  21571. if (isDefault) {
  21572. parts.push("default ");
  21573. }
  21574. parts.push(comments.printDanglingComments(path, options,
  21575. /* sameIndent */
  21576. true));
  21577. if (needsHardlineAfterDanglingComment(decl)) {
  21578. parts.push(hardline$8);
  21579. }
  21580. if (decl.declaration) {
  21581. parts.push(path.call(print, "declaration"));
  21582. 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" && decl.declaration.type !== "TSDeclareFunction") {
  21583. parts.push(semi);
  21584. }
  21585. } else {
  21586. if (decl.specifiers && decl.specifiers.length > 0) {
  21587. var specifiers = [];
  21588. var defaultSpecifiers = [];
  21589. var namespaceSpecifiers = [];
  21590. path.each(function (specifierPath) {
  21591. var specifierType = path.getValue().type;
  21592. if (specifierType === "ExportSpecifier") {
  21593. specifiers.push(print(specifierPath));
  21594. } else if (specifierType === "ExportDefaultSpecifier") {
  21595. defaultSpecifiers.push(print(specifierPath));
  21596. } else if (specifierType === "ExportNamespaceSpecifier") {
  21597. namespaceSpecifiers.push(concat$11(["* as ", print(specifierPath)]));
  21598. }
  21599. }, "specifiers");
  21600. var isNamespaceFollowed = namespaceSpecifiers.length !== 0 && specifiers.length !== 0;
  21601. var isDefaultFollowed = defaultSpecifiers.length !== 0 && (namespaceSpecifiers.length !== 0 || specifiers.length !== 0);
  21602. parts.push(decl.exportKind === "type" ? "type " : "", concat$11(defaultSpecifiers), concat$11([isDefaultFollowed ? ", " : ""]), concat$11(namespaceSpecifiers), concat$11([isNamespaceFollowed ? ", " : ""]), specifiers.length !== 0 ? group$10(concat$11(["{", indent$6(concat$11([options.bracketSpacing ? line$8 : softline$5, join$7(concat$11([",", line$8]), specifiers)])), ifBreak$6(shouldPrintComma$1(options) ? "," : ""), options.bracketSpacing ? line$8 : softline$5, "}"])) : "");
  21603. } else {
  21604. parts.push("{}");
  21605. }
  21606. if (decl.source) {
  21607. parts.push(" from ", path.call(print, "source"));
  21608. }
  21609. parts.push(semi);
  21610. }
  21611. return concat$11(parts);
  21612. }
  21613. function printFlowDeclaration(path, parts) {
  21614. var parentExportDecl = getParentExportDeclaration$1(path);
  21615. if (parentExportDecl) {
  21616. assert$3.strictEqual(parentExportDecl.type, "DeclareExportDeclaration");
  21617. } else {
  21618. // If the parent node has type DeclareExportDeclaration, then it
  21619. // will be responsible for printing the "declare" token. Otherwise
  21620. // it needs to be printed with this non-exported declaration node.
  21621. parts.unshift("declare ");
  21622. }
  21623. return concat$11(parts);
  21624. }
  21625. function getFlowVariance(path) {
  21626. if (!path.variance) {
  21627. return null;
  21628. } // Babel 7.0 currently uses variance node type, and flow should
  21629. // follow suit soon:
  21630. // https://github.com/babel/babel/issues/4722
  21631. var variance = path.variance.kind || path.variance;
  21632. switch (variance) {
  21633. case "plus":
  21634. return "+";
  21635. case "minus":
  21636. return "-";
  21637. default:
  21638. /* istanbul ignore next */
  21639. return variance;
  21640. }
  21641. }
  21642. function printTypeScriptModifiers(path, options, print) {
  21643. var n = path.getValue();
  21644. if (!n.modifiers || !n.modifiers.length) {
  21645. return "";
  21646. }
  21647. return concat$11([join$7(" ", path.map(print, "modifiers")), " "]);
  21648. }
  21649. function printTypeParameters(path, options, print, paramsKey) {
  21650. var n = path.getValue();
  21651. if (!n[paramsKey]) {
  21652. return "";
  21653. } // for TypeParameterDeclaration typeParameters is a single node
  21654. if (!Array.isArray(n[paramsKey])) {
  21655. return path.call(print, paramsKey);
  21656. }
  21657. var grandparent = path.getNode(2);
  21658. var isParameterInTestCall = grandparent != null && isTestCall(grandparent);
  21659. 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");
  21660. if (shouldInline) {
  21661. return concat$11(["<", join$7(", ", path.map(print, paramsKey)), ">"]);
  21662. }
  21663. return group$10(concat$11(["<", indent$6(concat$11([softline$5, join$7(concat$11([",", line$8]), path.map(print, paramsKey))])), ifBreak$6(options.parser !== "typescript" && shouldPrintComma$1(options, "all") ? "," : ""), softline$5, ">"]));
  21664. }
  21665. function printClass(path, options, print) {
  21666. var n = path.getValue();
  21667. var parts = [];
  21668. if (n.type === "TSAbstractClassDeclaration") {
  21669. parts.push("abstract ");
  21670. }
  21671. parts.push("class");
  21672. if (n.id) {
  21673. parts.push(" ", path.call(print, "id"));
  21674. }
  21675. parts.push(path.call(print, "typeParameters"));
  21676. var partsGroup = [];
  21677. if (n.superClass) {
  21678. var printed = concat$11(["extends ", path.call(print, "superClass"), path.call(print, "superTypeParameters")]); // Keep old behaviour of extends in same line
  21679. // If there is only on extends and there are not comments
  21680. if ((!n.implements || n.implements.length === 0) && (!n.superClass.comments || n.superClass.comments.length === 0)) {
  21681. parts.push(concat$11([" ", path.call(function (superClass) {
  21682. return comments.printComments(superClass, function () {
  21683. return printed;
  21684. }, options);
  21685. }, "superClass")]));
  21686. } else {
  21687. partsGroup.push(group$10(concat$11([line$8, path.call(function (superClass) {
  21688. return comments.printComments(superClass, function () {
  21689. return printed;
  21690. }, options);
  21691. }, "superClass")])));
  21692. }
  21693. } else if (n.extends && n.extends.length > 0) {
  21694. parts.push(" extends ", join$7(", ", path.map(print, "extends")));
  21695. }
  21696. if (n["mixins"] && n["mixins"].length > 0) {
  21697. partsGroup.push(line$8, "mixins ", group$10(indent$6(join$7(concat$11([",", line$8]), path.map(print, "mixins")))));
  21698. }
  21699. if (n["implements"] && n["implements"].length > 0) {
  21700. partsGroup.push(line$8, "implements", group$10(indent$6(concat$11([line$8, join$7(concat$11([",", line$8]), path.map(print, "implements"))]))));
  21701. }
  21702. if (partsGroup.length > 0) {
  21703. parts.push(group$10(indent$6(concat$11(partsGroup))));
  21704. }
  21705. if (n.body && n.body.comments && hasLeadingOwnLineComment(options.originalText, n.body, options)) {
  21706. parts.push(hardline$8);
  21707. } else {
  21708. parts.push(" ");
  21709. }
  21710. parts.push(path.call(print, "body"));
  21711. return parts;
  21712. }
  21713. function printOptionalToken(path) {
  21714. var node = path.getValue();
  21715. if (!node.optional) {
  21716. return "";
  21717. }
  21718. if (node.type === "OptionalCallExpression" || node.type === "OptionalMemberExpression" && node.computed) {
  21719. return "?.";
  21720. }
  21721. return "?";
  21722. }
  21723. function printMemberLookup(path, options, print) {
  21724. var property = path.call(print, "property");
  21725. var n = path.getValue();
  21726. var optional = printOptionalToken(path);
  21727. if (!n.computed) {
  21728. return concat$11([optional, ".", property]);
  21729. }
  21730. if (!n.property || isNumericLiteral(n.property)) {
  21731. return concat$11([optional, "[", property, "]"]);
  21732. }
  21733. return group$10(concat$11([optional, "[", indent$6(concat$11([softline$5, property])), softline$5, "]"]));
  21734. }
  21735. function printBindExpressionCallee(path, options, print) {
  21736. return concat$11(["::", path.call(print, "callee")]);
  21737. } // We detect calls on member expressions specially to format a
  21738. // common pattern better. The pattern we are looking for is this:
  21739. //
  21740. // arr
  21741. // .map(x => x + 1)
  21742. // .filter(x => x > 10)
  21743. // .some(x => x % 2)
  21744. //
  21745. // The way it is structured in the AST is via a nested sequence of
  21746. // MemberExpression and CallExpression. We need to traverse the AST
  21747. // and make groups out of it to print it in the desired way.
  21748. function printMemberChain(path, options, print) {
  21749. // The first phase is to linearize the AST by traversing it down.
  21750. //
  21751. // a().b()
  21752. // has the following AST structure:
  21753. // CallExpression(MemberExpression(CallExpression(Identifier)))
  21754. // and we transform it into
  21755. // [Identifier, CallExpression, MemberExpression, CallExpression]
  21756. var printedNodes = []; // Here we try to retain one typed empty line after each call expression or
  21757. // the first group whether it is in parentheses or not
  21758. function shouldInsertEmptyLineAfter(node) {
  21759. var originalText = options.originalText;
  21760. var nextCharIndex = getNextNonSpaceNonCommentCharacterIndex$2(originalText, node, options);
  21761. var nextChar = originalText.charAt(nextCharIndex); // if it is cut off by a parenthesis, we only account for one typed empty
  21762. // line after that parenthesis
  21763. if (nextChar == ")") {
  21764. return isNextLineEmptyAfterIndex$1(originalText, nextCharIndex + 1, options);
  21765. }
  21766. return isNextLineEmpty$4(originalText, node, options);
  21767. }
  21768. function rec(path) {
  21769. var node = path.getValue();
  21770. if ((node.type === "CallExpression" || node.type === "OptionalCallExpression") && (isMemberish(node.callee) || node.callee.type === "CallExpression" || node.callee.type === "OptionalCallExpression")) {
  21771. printedNodes.unshift({
  21772. node: node,
  21773. printed: concat$11([comments.printComments(path, function () {
  21774. return concat$11([printOptionalToken(path), printFunctionTypeParameters(path, options, print), printArgumentsList(path, options, print)]);
  21775. }, options), shouldInsertEmptyLineAfter(node) ? hardline$8 : ""])
  21776. });
  21777. path.call(function (callee) {
  21778. return rec(callee);
  21779. }, "callee");
  21780. } else if (isMemberish(node)) {
  21781. printedNodes.unshift({
  21782. node: node,
  21783. needsParens: needsParens_1(path, options),
  21784. printed: comments.printComments(path, function () {
  21785. return node.type === "OptionalMemberExpression" || node.type === "MemberExpression" ? printMemberLookup(path, options, print) : printBindExpressionCallee(path, options, print);
  21786. }, options)
  21787. });
  21788. path.call(function (object) {
  21789. return rec(object);
  21790. }, "object");
  21791. } else if (node.type === "TSNonNullExpression") {
  21792. printedNodes.unshift({
  21793. node: node,
  21794. printed: comments.printComments(path, function () {
  21795. return "!";
  21796. }, options)
  21797. });
  21798. path.call(function (expression) {
  21799. return rec(expression);
  21800. }, "expression");
  21801. } else {
  21802. printedNodes.unshift({
  21803. node: node,
  21804. printed: path.call(print)
  21805. });
  21806. }
  21807. } // Note: the comments of the root node have already been printed, so we
  21808. // need to extract this first call without printing them as they would
  21809. // if handled inside of the recursive call.
  21810. var node = path.getValue();
  21811. printedNodes.unshift({
  21812. node: node,
  21813. printed: concat$11([printOptionalToken(path), printFunctionTypeParameters(path, options, print), printArgumentsList(path, options, print)])
  21814. });
  21815. path.call(function (callee) {
  21816. return rec(callee);
  21817. }, "callee"); // Once we have a linear list of printed nodes, we want to create groups out
  21818. // of it.
  21819. //
  21820. // a().b.c().d().e
  21821. // will be grouped as
  21822. // [
  21823. // [Identifier, CallExpression],
  21824. // [MemberExpression, MemberExpression, CallExpression],
  21825. // [MemberExpression, CallExpression],
  21826. // [MemberExpression],
  21827. // ]
  21828. // so that we can print it as
  21829. // a()
  21830. // .b.c()
  21831. // .d()
  21832. // .e
  21833. // The first group is the first node followed by
  21834. // - as many CallExpression as possible
  21835. // < fn()()() >.something()
  21836. // - as many array acessors as possible
  21837. // < fn()[0][1][2] >.something()
  21838. // - then, as many MemberExpression as possible but the last one
  21839. // < this.items >.something()
  21840. var groups = [];
  21841. var currentGroup = [printedNodes[0]];
  21842. var i = 1;
  21843. for (; i < printedNodes.length; ++i) {
  21844. 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)) {
  21845. currentGroup.push(printedNodes[i]);
  21846. } else {
  21847. break;
  21848. }
  21849. }
  21850. if (printedNodes[0].node.type !== "CallExpression" && printedNodes[0].node.type !== "OptionalCallExpression") {
  21851. for (; i + 1 < printedNodes.length; ++i) {
  21852. if (isMemberish(printedNodes[i].node) && isMemberish(printedNodes[i + 1].node)) {
  21853. currentGroup.push(printedNodes[i]);
  21854. } else {
  21855. break;
  21856. }
  21857. }
  21858. }
  21859. groups.push(currentGroup);
  21860. currentGroup = []; // Then, each following group is a sequence of MemberExpression followed by
  21861. // a sequence of CallExpression. To compute it, we keep adding things to the
  21862. // group until we has seen a CallExpression in the past and reach a
  21863. // MemberExpression
  21864. var hasSeenCallExpression = false;
  21865. for (; i < printedNodes.length; ++i) {
  21866. if (hasSeenCallExpression && isMemberish(printedNodes[i].node)) {
  21867. // [0] should be appended at the end of the group instead of the
  21868. // beginning of the next one
  21869. if (printedNodes[i].node.computed && isNumericLiteral(printedNodes[i].node.property)) {
  21870. currentGroup.push(printedNodes[i]);
  21871. continue;
  21872. }
  21873. groups.push(currentGroup);
  21874. currentGroup = [];
  21875. hasSeenCallExpression = false;
  21876. }
  21877. if (printedNodes[i].node.type === "CallExpression" || printedNodes[i].node.type === "OptionalCallExpression") {
  21878. hasSeenCallExpression = true;
  21879. }
  21880. currentGroup.push(printedNodes[i]);
  21881. if (printedNodes[i].node.comments && printedNodes[i].node.comments.some(function (comment) {
  21882. return comment.trailing;
  21883. })) {
  21884. groups.push(currentGroup);
  21885. currentGroup = [];
  21886. hasSeenCallExpression = false;
  21887. }
  21888. }
  21889. if (currentGroup.length > 0) {
  21890. groups.push(currentGroup);
  21891. } // There are cases like Object.keys(), Observable.of(), _.values() where
  21892. // they are the subject of all the chained calls and therefore should
  21893. // be kept on the same line:
  21894. //
  21895. // Object.keys(items)
  21896. // .filter(x => x)
  21897. // .map(x => x)
  21898. //
  21899. // In order to detect those cases, we use an heuristic: if the first
  21900. // node is an identifier with the name starting with a capital
  21901. // letter or just a sequence of _$. The rationale is that they are
  21902. // likely to be factories.
  21903. function isFactory(name) {
  21904. return /^[A-Z]|^[_$]+$/.test(name);
  21905. } // In case the Identifier is shorter than tab width, we can keep the
  21906. // first call in a single line, if it's an ExpressionStatement.
  21907. //
  21908. // d3.scaleLinear()
  21909. // .domain([0, 100])
  21910. // .range([0, width]);
  21911. //
  21912. function isShort(name) {
  21913. return name.length <= options.tabWidth;
  21914. }
  21915. function shouldNotWrap(groups) {
  21916. var parent = path.getParentNode();
  21917. var isExpression = parent && parent.type === "ExpressionStatement";
  21918. var hasComputed = groups[1].length && groups[1][0].node.computed;
  21919. if (groups[0].length === 1) {
  21920. var firstNode = groups[0][0].node;
  21921. return firstNode.type === "ThisExpression" || firstNode.type === "Identifier" && (isFactory(firstNode.name) || isExpression && isShort(firstNode.name) || hasComputed);
  21922. }
  21923. var lastNode = getLast$4(groups[0]).node;
  21924. return (lastNode.type === "MemberExpression" || lastNode.type === "OptionalMemberExpression") && lastNode.property.type === "Identifier" && (isFactory(lastNode.property.name) || hasComputed);
  21925. }
  21926. var shouldMerge = groups.length >= 2 && !groups[1][0].node.comments && shouldNotWrap(groups);
  21927. function printGroup(printedGroup) {
  21928. var result = [];
  21929. for (var _i3 = 0; _i3 < printedGroup.length; _i3++) {
  21930. // Checks if the next node (i.e. the parent node) needs parens
  21931. // and print accordingly
  21932. if (printedGroup[_i3 + 1] && printedGroup[_i3 + 1].needsParens) {
  21933. result.push("(", printedGroup[_i3].printed, printedGroup[_i3 + 1].printed, ")");
  21934. _i3++;
  21935. } else {
  21936. result.push(printedGroup[_i3].printed);
  21937. }
  21938. }
  21939. return concat$11(result);
  21940. }
  21941. function printIndentedGroup(groups) {
  21942. if (groups.length === 0) {
  21943. return "";
  21944. }
  21945. return indent$6(group$10(concat$11([hardline$8, join$7(hardline$8, groups.map(printGroup))])));
  21946. }
  21947. var printedGroups = groups.map(printGroup);
  21948. var oneLine = concat$11(printedGroups);
  21949. var cutoff = shouldMerge ? 3 : 2;
  21950. var flatGroups = groups.slice(0, cutoff).reduce(function (res, group) {
  21951. return res.concat(group);
  21952. }, []);
  21953. var hasComment = flatGroups.slice(1, -1).some(function (node) {
  21954. return hasLeadingComment(node.node);
  21955. }) || flatGroups.slice(0, -1).some(function (node) {
  21956. return hasTrailingComment(node.node);
  21957. }) || groups[cutoff] && hasLeadingComment(groups[cutoff][0].node); // If we only have a single `.`, we shouldn't do anything fancy and just
  21958. // render everything concatenated together.
  21959. if (groups.length <= cutoff && !hasComment) {
  21960. return group$10(oneLine);
  21961. } // Find out the last node in the first group and check if it has an
  21962. // empty line after
  21963. var lastNodeBeforeIndent = getLast$4(shouldMerge ? groups.slice(1, 2)[0] : groups[0]).node;
  21964. var shouldHaveEmptyLineBeforeIndent = lastNodeBeforeIndent.type !== "CallExpression" && lastNodeBeforeIndent.type !== "OptionalCallExpression" && shouldInsertEmptyLineAfter(lastNodeBeforeIndent);
  21965. var expanded = concat$11([printGroup(groups[0]), shouldMerge ? concat$11(groups.slice(1, 2).map(printGroup)) : "", shouldHaveEmptyLineBeforeIndent ? hardline$8 : "", printIndentedGroup(groups.slice(shouldMerge ? 2 : 1))]);
  21966. var callExpressions = printedNodes.map(function (_ref) {
  21967. var node = _ref.node;
  21968. return node;
  21969. }).filter(isCallOrOptionalCallExpression); // We don't want to print in one line if there's:
  21970. // * A comment.
  21971. // * 3 or more chained calls.
  21972. // * Any group but the last one has a hard line.
  21973. // If the last group is a function it's okay to inline if it fits.
  21974. if (hasComment || callExpressions.length >= 3 || printedGroups.slice(0, -1).some(willBreak$1) ||
  21975. /**
  21976. * scopes.filter(scope => scope.value !== '').map((scope, i) => {
  21977. * // multi line content
  21978. * })
  21979. */
  21980. function (lastGroupDoc, lastGroupNode) {
  21981. return isCallOrOptionalCallExpression(lastGroupNode) && willBreak$1(lastGroupDoc);
  21982. }(getLast$4(printedGroups), getLast$4(getLast$4(groups)).node) && callExpressions.slice(0, -1).some(function (n) {
  21983. return n.arguments.some(isFunctionOrArrowExpression);
  21984. })) {
  21985. return group$10(expanded);
  21986. }
  21987. return concat$11([// We only need to check `oneLine` because if `expanded` is chosen
  21988. // that means that the parent group has already been broken
  21989. // naturally
  21990. willBreak$1(oneLine) || shouldHaveEmptyLineBeforeIndent ? breakParent$3 : "", conditionalGroup$1([oneLine, expanded])]);
  21991. }
  21992. function isCallOrOptionalCallExpression(node) {
  21993. return node.type === "CallExpression" || node.type === "OptionalCallExpression";
  21994. }
  21995. function isJSXNode(node) {
  21996. return node.type === "JSXElement" || node.type === "JSXFragment";
  21997. }
  21998. function isEmptyJSXElement(node) {
  21999. if (node.children.length === 0) {
  22000. return true;
  22001. }
  22002. if (node.children.length > 1) {
  22003. return false;
  22004. } // if there is one text child and does not contain any meaningful text
  22005. // we can treat the element as empty.
  22006. var child = node.children[0];
  22007. return isLiteral(child) && !isMeaningfulJSXText(child);
  22008. } // Only space, newline, carriage return, and tab are treated as whitespace
  22009. // inside JSX.
  22010. var jsxWhitespaceChars = " \n\r\t";
  22011. var containsNonJsxWhitespaceRegex = new RegExp("[^" + jsxWhitespaceChars + "]");
  22012. var matchJsxWhitespaceRegex = new RegExp("([" + jsxWhitespaceChars + "]+)"); // Meaningful if it contains non-whitespace characters,
  22013. // or it contains whitespace without a new line.
  22014. function isMeaningfulJSXText(node) {
  22015. return isLiteral(node) && (containsNonJsxWhitespaceRegex.test(rawText(node)) || !/\n/.test(rawText(node)));
  22016. }
  22017. function conditionalExpressionChainContainsJSX(node) {
  22018. return Boolean(getConditionalChainContents(node).find(isJSXNode));
  22019. } // If we have nested conditional expressions, we want to print them in JSX mode
  22020. // if there's at least one JSXElement somewhere in the tree.
  22021. //
  22022. // A conditional expression chain like this should be printed in normal mode,
  22023. // because there aren't JSXElements anywhere in it:
  22024. //
  22025. // isA ? "A" : isB ? "B" : isC ? "C" : "Unknown";
  22026. //
  22027. // But a conditional expression chain like this should be printed in JSX mode,
  22028. // because there is a JSXElement in the last ConditionalExpression:
  22029. //
  22030. // isA ? "A" : isB ? "B" : isC ? "C" : <span className="warning">Unknown</span>;
  22031. //
  22032. // This type of ConditionalExpression chain is structured like this in the AST:
  22033. //
  22034. // ConditionalExpression {
  22035. // test: ...,
  22036. // consequent: ...,
  22037. // alternate: ConditionalExpression {
  22038. // test: ...,
  22039. // consequent: ...,
  22040. // alternate: ConditionalExpression {
  22041. // test: ...,
  22042. // consequent: ...,
  22043. // alternate: ...,
  22044. // }
  22045. // }
  22046. // }
  22047. //
  22048. // We want to traverse over that shape and convert it into a flat structure so
  22049. // that we can find if there's a JSXElement somewhere inside.
  22050. function getConditionalChainContents(node) {
  22051. // Given this code:
  22052. //
  22053. // // Using a ConditionalExpression as the consequent is uncommon, but should
  22054. // // be handled.
  22055. // A ? B : C ? D : E ? F ? G : H : I
  22056. //
  22057. // which has this AST:
  22058. //
  22059. // ConditionalExpression {
  22060. // test: Identifier(A),
  22061. // consequent: Identifier(B),
  22062. // alternate: ConditionalExpression {
  22063. // test: Identifier(C),
  22064. // consequent: Identifier(D),
  22065. // alternate: ConditionalExpression {
  22066. // test: Identifier(E),
  22067. // consequent: ConditionalExpression {
  22068. // test: Identifier(F),
  22069. // consequent: Identifier(G),
  22070. // alternate: Identifier(H),
  22071. // },
  22072. // alternate: Identifier(I),
  22073. // }
  22074. // }
  22075. // }
  22076. //
  22077. // we should return this Array:
  22078. //
  22079. // [
  22080. // Identifier(A),
  22081. // Identifier(B),
  22082. // Identifier(C),
  22083. // Identifier(D),
  22084. // Identifier(E),
  22085. // Identifier(F),
  22086. // Identifier(G),
  22087. // Identifier(H),
  22088. // Identifier(I)
  22089. // ];
  22090. //
  22091. // This loses the information about whether each node was the test,
  22092. // consequent, or alternate, but we don't care about that here- we are only
  22093. // flattening this structure to find if there's any JSXElements inside.
  22094. var nonConditionalExpressions = [];
  22095. function recurse(node) {
  22096. if (node.type === "ConditionalExpression") {
  22097. recurse(node.test);
  22098. recurse(node.consequent);
  22099. recurse(node.alternate);
  22100. } else {
  22101. nonConditionalExpressions.push(node);
  22102. }
  22103. }
  22104. recurse(node);
  22105. return nonConditionalExpressions;
  22106. } // Detect an expression node representing `{" "}`
  22107. function isJSXWhitespaceExpression(node) {
  22108. return node.type === "JSXExpressionContainer" && isLiteral(node.expression) && node.expression.value === " " && !node.expression.comments;
  22109. }
  22110. function separatorNoWhitespace(isFacebookTranslationTag, child, childNode, nextNode) {
  22111. if (isFacebookTranslationTag) {
  22112. return "";
  22113. }
  22114. if (childNode.type === "JSXElement" && !childNode.closingElement || nextNode && nextNode.type === "JSXElement" && !nextNode.closingElement) {
  22115. return child.length === 1 ? softline$5 : hardline$8;
  22116. }
  22117. return softline$5;
  22118. }
  22119. function separatorWithWhitespace(isFacebookTranslationTag, child, childNode, nextNode) {
  22120. if (isFacebookTranslationTag) {
  22121. return hardline$8;
  22122. }
  22123. if (child.length === 1) {
  22124. return childNode.type === "JSXElement" && !childNode.closingElement || nextNode && nextNode.type === "JSXElement" && !nextNode.closingElement ? hardline$8 : softline$5;
  22125. }
  22126. return hardline$8;
  22127. } // JSX Children are strange, mostly for two reasons:
  22128. // 1. JSX reads newlines into string values, instead of skipping them like JS
  22129. // 2. up to one whitespace between elements within a line is significant,
  22130. // but not between lines.
  22131. //
  22132. // Leading, trailing, and lone whitespace all need to
  22133. // turn themselves into the rather ugly `{' '}` when breaking.
  22134. //
  22135. // We print JSX using the `fill` doc primitive.
  22136. // This requires that we give it an array of alternating
  22137. // content and whitespace elements.
  22138. // To ensure this we add dummy `""` content elements as needed.
  22139. function printJSXChildren(path, options, print, jsxWhitespace, isFacebookTranslationTag) {
  22140. var n = path.getValue();
  22141. var children = []; // using `map` instead of `each` because it provides `i`
  22142. path.map(function (childPath, i) {
  22143. var child = childPath.getValue();
  22144. if (isLiteral(child)) {
  22145. var text = rawText(child); // Contains a non-whitespace character
  22146. if (isMeaningfulJSXText(child)) {
  22147. var words = text.split(matchJsxWhitespaceRegex); // Starts with whitespace
  22148. if (words[0] === "") {
  22149. children.push("");
  22150. words.shift();
  22151. if (/\n/.test(words[0])) {
  22152. var next = n.children[i + 1];
  22153. children.push(separatorWithWhitespace(isFacebookTranslationTag, words[1], child, next));
  22154. } else {
  22155. children.push(jsxWhitespace);
  22156. }
  22157. words.shift();
  22158. }
  22159. var endWhitespace; // Ends with whitespace
  22160. if (getLast$4(words) === "") {
  22161. words.pop();
  22162. endWhitespace = words.pop();
  22163. } // This was whitespace only without a new line.
  22164. if (words.length === 0) {
  22165. return;
  22166. }
  22167. words.forEach(function (word, i) {
  22168. if (i % 2 === 1) {
  22169. children.push(line$8);
  22170. } else {
  22171. children.push(word);
  22172. }
  22173. });
  22174. if (endWhitespace !== undefined) {
  22175. if (/\n/.test(endWhitespace)) {
  22176. var _next = n.children[i + 1];
  22177. children.push(separatorWithWhitespace(isFacebookTranslationTag, getLast$4(children), child, _next));
  22178. } else {
  22179. children.push(jsxWhitespace);
  22180. }
  22181. } else {
  22182. var _next2 = n.children[i + 1];
  22183. children.push(separatorNoWhitespace(isFacebookTranslationTag, getLast$4(children), child, _next2));
  22184. }
  22185. } else if (/\n/.test(text)) {
  22186. // Keep (up to one) blank line between tags/expressions/text.
  22187. // Note: We don't keep blank lines between text elements.
  22188. if (text.match(/\n/g).length > 1) {
  22189. children.push("");
  22190. children.push(hardline$8);
  22191. }
  22192. } else {
  22193. children.push("");
  22194. children.push(jsxWhitespace);
  22195. }
  22196. } else {
  22197. var printedChild = print(childPath);
  22198. children.push(printedChild);
  22199. var _next3 = n.children[i + 1];
  22200. var directlyFollowedByMeaningfulText = _next3 && isMeaningfulJSXText(_next3);
  22201. if (directlyFollowedByMeaningfulText) {
  22202. var firstWord = rawText(_next3).trim().split(matchJsxWhitespaceRegex)[0];
  22203. children.push(separatorNoWhitespace(isFacebookTranslationTag, firstWord, child, _next3));
  22204. } else {
  22205. children.push(hardline$8);
  22206. }
  22207. }
  22208. }, "children");
  22209. return children;
  22210. } // JSX expands children from the inside-out, instead of the outside-in.
  22211. // This is both to break children before attributes,
  22212. // and to ensure that when children break, their parents do as well.
  22213. //
  22214. // Any element that is written without any newlines and fits on a single line
  22215. // is left that way.
  22216. // Not only that, any user-written-line containing multiple JSX siblings
  22217. // should also be kept on one line if possible,
  22218. // so each user-written-line is wrapped in its own group.
  22219. //
  22220. // Elements that contain newlines or don't fit on a single line (recursively)
  22221. // are fully-split, using hardline and shouldBreak: true.
  22222. //
  22223. // To support that case properly, all leading and trailing spaces
  22224. // are stripped from the list of children, and replaced with a single hardline.
  22225. function printJSXElement(path, options, print) {
  22226. var n = path.getValue(); // Turn <div></div> into <div />
  22227. if (n.type === "JSXElement" && isEmptyJSXElement(n)) {
  22228. n.openingElement.selfClosing = true;
  22229. return path.call(print, "openingElement");
  22230. }
  22231. var openingLines = n.type === "JSXElement" ? path.call(print, "openingElement") : path.call(print, "openingFragment");
  22232. var closingLines = n.type === "JSXElement" ? path.call(print, "closingElement") : path.call(print, "closingFragment");
  22233. if (n.children.length === 1 && n.children[0].type === "JSXExpressionContainer" && (n.children[0].expression.type === "TemplateLiteral" || n.children[0].expression.type === "TaggedTemplateExpression")) {
  22234. return concat$11([openingLines, concat$11(path.map(print, "children")), closingLines]);
  22235. } // Convert `{" "}` to text nodes containing a space.
  22236. // This makes it easy to turn them into `jsxWhitespace` which
  22237. // can then print as either a space or `{" "}` when breaking.
  22238. n.children = n.children.map(function (child) {
  22239. if (isJSXWhitespaceExpression(child)) {
  22240. return {
  22241. type: "JSXText",
  22242. value: " ",
  22243. raw: " "
  22244. };
  22245. }
  22246. return child;
  22247. });
  22248. var containsTag = n.children.filter(isJSXNode).length > 0;
  22249. var containsMultipleExpressions = n.children.filter(function (child) {
  22250. return child.type === "JSXExpressionContainer";
  22251. }).length > 1;
  22252. var containsMultipleAttributes = n.type === "JSXElement" && n.openingElement.attributes.length > 1; // Record any breaks. Should never go from true to false, only false to true.
  22253. var forcedBreak = willBreak$1(openingLines) || containsTag || containsMultipleAttributes || containsMultipleExpressions;
  22254. var rawJsxWhitespace = options.singleQuote ? "{' '}" : '{" "}';
  22255. var jsxWhitespace = ifBreak$6(concat$11([rawJsxWhitespace, softline$5]), " ");
  22256. var isFacebookTranslationTag = n.openingElement && n.openingElement.name && n.openingElement.name.name === "fbt";
  22257. var children = printJSXChildren(path, options, print, jsxWhitespace, isFacebookTranslationTag);
  22258. var containsText = n.children.filter(function (child) {
  22259. return isMeaningfulJSXText(child);
  22260. }).length > 0; // We can end up we multiple whitespace elements with empty string
  22261. // content between them.
  22262. // We need to remove empty whitespace and softlines before JSX whitespace
  22263. // to get the correct output.
  22264. for (var i = children.length - 2; i >= 0; i--) {
  22265. var isPairOfEmptyStrings = children[i] === "" && children[i + 1] === "";
  22266. var isPairOfHardlines = children[i] === hardline$8 && children[i + 1] === "" && children[i + 2] === hardline$8;
  22267. var isLineFollowedByJSXWhitespace = (children[i] === softline$5 || children[i] === hardline$8) && children[i + 1] === "" && children[i + 2] === jsxWhitespace;
  22268. var isJSXWhitespaceFollowedByLine = children[i] === jsxWhitespace && children[i + 1] === "" && (children[i + 2] === softline$5 || children[i + 2] === hardline$8);
  22269. var isDoubleJSXWhitespace = children[i] === jsxWhitespace && children[i + 1] === "" && children[i + 2] === jsxWhitespace;
  22270. var isPairOfHardOrSoftLines = children[i] === softline$5 && children[i + 1] === "" && children[i + 2] === hardline$8 || children[i] === hardline$8 && children[i + 1] === "" && children[i + 2] === softline$5;
  22271. if (isPairOfHardlines && containsText || isPairOfEmptyStrings || isLineFollowedByJSXWhitespace || isDoubleJSXWhitespace || isPairOfHardOrSoftLines) {
  22272. children.splice(i, 2);
  22273. } else if (isJSXWhitespaceFollowedByLine) {
  22274. children.splice(i + 1, 2);
  22275. }
  22276. } // Trim trailing lines (or empty strings)
  22277. while (children.length && (isLineNext$1(getLast$4(children)) || isEmpty$1(getLast$4(children)))) {
  22278. children.pop();
  22279. } // Trim leading lines (or empty strings)
  22280. while (children.length && (isLineNext$1(children[0]) || isEmpty$1(children[0])) && (isLineNext$1(children[1]) || isEmpty$1(children[1]))) {
  22281. children.shift();
  22282. children.shift();
  22283. } // Tweak how we format children if outputting this element over multiple lines.
  22284. // Also detect whether we will force this element to output over multiple lines.
  22285. var multilineChildren = [];
  22286. children.forEach(function (child, i) {
  22287. // There are a number of situations where we need to ensure we display
  22288. // whitespace as `{" "}` when outputting this element over multiple lines.
  22289. if (child === jsxWhitespace) {
  22290. if (i === 1 && children[i - 1] === "") {
  22291. if (children.length === 2) {
  22292. // Solitary whitespace
  22293. multilineChildren.push(rawJsxWhitespace);
  22294. return;
  22295. } // Leading whitespace
  22296. multilineChildren.push(concat$11([rawJsxWhitespace, hardline$8]));
  22297. return;
  22298. } else if (i === children.length - 1) {
  22299. // Trailing whitespace
  22300. multilineChildren.push(rawJsxWhitespace);
  22301. return;
  22302. } else if (children[i - 1] === "" && children[i - 2] === hardline$8) {
  22303. // Whitespace after line break
  22304. multilineChildren.push(rawJsxWhitespace);
  22305. return;
  22306. }
  22307. }
  22308. multilineChildren.push(child);
  22309. if (willBreak$1(child)) {
  22310. forcedBreak = true;
  22311. }
  22312. }); // If there is text we use `fill` to fit as much onto each line as possible.
  22313. // When there is no text (just tags and expressions) we use `group`
  22314. // to output each on a separate line.
  22315. var content = containsText ? fill$4(multilineChildren) : group$10(concat$11(multilineChildren), {
  22316. shouldBreak: true
  22317. });
  22318. var multiLineElem = group$10(concat$11([openingLines, indent$6(concat$11([hardline$8, content])), hardline$8, closingLines]));
  22319. if (forcedBreak) {
  22320. return multiLineElem;
  22321. }
  22322. return conditionalGroup$1([group$10(concat$11([openingLines, concat$11(children), closingLines])), multiLineElem]);
  22323. }
  22324. function maybeWrapJSXElementInParens(path, elem) {
  22325. var parent = path.getParentNode();
  22326. if (!parent) {
  22327. return elem;
  22328. }
  22329. var NO_WRAP_PARENTS = {
  22330. ArrayExpression: true,
  22331. JSXAttribute: true,
  22332. JSXElement: true,
  22333. JSXExpressionContainer: true,
  22334. JSXFragment: true,
  22335. ExpressionStatement: true,
  22336. CallExpression: true,
  22337. OptionalCallExpression: true,
  22338. ConditionalExpression: true,
  22339. JsExpressionRoot: true
  22340. };
  22341. if (NO_WRAP_PARENTS[parent.type]) {
  22342. return elem;
  22343. }
  22344. var shouldBreak = matchAncestorTypes$1(path, ["ArrowFunctionExpression", "CallExpression", "JSXExpressionContainer"]);
  22345. return group$10(concat$11([ifBreak$6("("), indent$6(concat$11([softline$5, elem])), softline$5, ifBreak$6(")")]), {
  22346. shouldBreak: shouldBreak
  22347. });
  22348. }
  22349. function isBinaryish(node) {
  22350. return node.type === "BinaryExpression" || node.type === "LogicalExpression" || node.type === "NGPipeExpression";
  22351. }
  22352. function isMemberish(node) {
  22353. return node.type === "MemberExpression" || node.type === "OptionalMemberExpression" || node.type === "BindExpression" && node.object;
  22354. }
  22355. function shouldInlineLogicalExpression(node) {
  22356. if (node.type !== "LogicalExpression") {
  22357. return false;
  22358. }
  22359. if (node.right.type === "ObjectExpression" && node.right.properties.length !== 0) {
  22360. return true;
  22361. }
  22362. if (node.right.type === "ArrayExpression" && node.right.elements.length !== 0) {
  22363. return true;
  22364. }
  22365. if (isJSXNode(node.right)) {
  22366. return true;
  22367. }
  22368. return false;
  22369. } // For binary expressions to be consistent, we need to group
  22370. // subsequent operators with the same precedence level under a single
  22371. // group. Otherwise they will be nested such that some of them break
  22372. // onto new lines but not all. Operators with the same precedence
  22373. // level should either all break or not. Because we group them by
  22374. // precedence level and the AST is structured based on precedence
  22375. // level, things are naturally broken up correctly, i.e. `&&` is
  22376. // broken before `+`.
  22377. function printBinaryishExpressions(path, print, options, isNested, isInsideParenthesis) {
  22378. var parts = [];
  22379. var node = path.getValue(); // We treat BinaryExpression and LogicalExpression nodes the same.
  22380. if (isBinaryish(node)) {
  22381. // Put all operators with the same precedence level in the same
  22382. // group. The reason we only need to do this with the `left`
  22383. // expression is because given an expression like `1 + 2 - 3`, it
  22384. // is always parsed like `((1 + 2) - 3)`, meaning the `left` side
  22385. // is where the rest of the expression will exist. Binary
  22386. // expressions on the right side mean they have a difference
  22387. // precedence level and should be treated as a separate group, so
  22388. // print them normally. (This doesn't hold for the `**` operator,
  22389. // which is unique in that it is right-associative.)
  22390. if (shouldFlatten$1(node.operator, node.left.operator)) {
  22391. // Flatten them out by recursively calling this function.
  22392. parts = parts.concat(path.call(function (left) {
  22393. return printBinaryishExpressions(left, print, options,
  22394. /* isNested */
  22395. true, isInsideParenthesis);
  22396. }, "left"));
  22397. } else {
  22398. parts.push(path.call(print, "left"));
  22399. }
  22400. var shouldInline = shouldInlineLogicalExpression(node);
  22401. var lineBeforeOperator = (node.operator === "|>" || node.type === "NGPipeExpression" || node.operator === "|" && options.parser === "__vue_expression") && !hasLeadingOwnLineComment(options.originalText, node.right, options);
  22402. var operator = node.type === "NGPipeExpression" ? "|" : node.operator;
  22403. var rightSuffix = node.type === "NGPipeExpression" && node.arguments.length !== 0 ? group$10(indent$6(concat$11([softline$5, ": ", join$7(concat$11([softline$5, ":", ifBreak$6(" ")]), path.map(print, "arguments").map(function (arg) {
  22404. return align$1(2, group$10(arg));
  22405. }))]))) : "";
  22406. var right = shouldInline ? concat$11([operator, " ", path.call(print, "right"), rightSuffix]) : concat$11([lineBeforeOperator ? softline$5 : "", operator, lineBeforeOperator ? " " : line$8, path.call(print, "right"), rightSuffix]); // If there's only a single binary expression, we want to create a group
  22407. // in order to avoid having a small right part like -1 be on its own line.
  22408. var parent = path.getParentNode();
  22409. var shouldGroup = !(isInsideParenthesis && node.type === "LogicalExpression") && parent.type !== node.type && node.left.type !== node.type && node.right.type !== node.type;
  22410. parts.push(" ", shouldGroup ? group$10(right) : right); // The root comments are already printed, but we need to manually print
  22411. // the other ones since we don't call the normal print on BinaryExpression,
  22412. // only for the left and right parts
  22413. if (isNested && node.comments) {
  22414. parts = comments.printComments(path, function () {
  22415. return concat$11(parts);
  22416. }, options);
  22417. }
  22418. } else {
  22419. // Our stopping case. Simply print the node normally.
  22420. parts.push(path.call(print));
  22421. }
  22422. return parts;
  22423. }
  22424. function printAssignmentRight(leftNode, rightNode, printedRight, options) {
  22425. if (hasLeadingOwnLineComment(options.originalText, rightNode, options)) {
  22426. return indent$6(concat$11([hardline$8, printedRight]));
  22427. }
  22428. var canBreak = isBinaryish(rightNode) && !shouldInlineLogicalExpression(rightNode) || rightNode.type === "ConditionalExpression" && isBinaryish(rightNode.test) && !shouldInlineLogicalExpression(rightNode.test) || rightNode.type === "StringLiteralTypeAnnotation" || rightNode.type === "ClassExpression" && rightNode.decorators && rightNode.decorators.length || (leftNode.type === "Identifier" || isStringLiteral(leftNode) || leftNode.type === "MemberExpression") && (isStringLiteral(rightNode) || isMemberExpressionChain(rightNode)) && // do not put values on a separate line from the key in json
  22429. options.parser !== "json" && options.parser !== "json5";
  22430. if (canBreak) {
  22431. return group$10(indent$6(concat$11([line$8, printedRight])));
  22432. }
  22433. return concat$11([" ", printedRight]);
  22434. }
  22435. function printAssignment(leftNode, printedLeft, operator, rightNode, printedRight, options) {
  22436. if (!rightNode) {
  22437. return printedLeft;
  22438. }
  22439. var printed = printAssignmentRight(leftNode, rightNode, printedRight, options);
  22440. return group$10(concat$11([printedLeft, operator, printed]));
  22441. }
  22442. function adjustClause(node, clause, forceSpace) {
  22443. if (node.type === "EmptyStatement") {
  22444. return ";";
  22445. }
  22446. if (node.type === "BlockStatement" || forceSpace) {
  22447. return concat$11([" ", clause]);
  22448. }
  22449. return indent$6(concat$11([line$8, clause]));
  22450. }
  22451. function nodeStr(node, options, isFlowOrTypeScriptDirectiveLiteral) {
  22452. var raw = rawText(node);
  22453. var isDirectiveLiteral = isFlowOrTypeScriptDirectiveLiteral || node.type === "DirectiveLiteral";
  22454. return printString$2(raw, options, isDirectiveLiteral);
  22455. }
  22456. function printRegex(node) {
  22457. var flags = node.flags.split("").sort().join("");
  22458. return "/".concat(node.pattern, "/").concat(flags);
  22459. }
  22460. function isLastStatement(path) {
  22461. var parent = path.getParentNode();
  22462. if (!parent) {
  22463. return true;
  22464. }
  22465. var node = path.getValue();
  22466. var body = (parent.body || parent.consequent).filter(function (stmt) {
  22467. return stmt.type !== "EmptyStatement";
  22468. });
  22469. return body && body[body.length - 1] === node;
  22470. }
  22471. function hasLeadingComment(node) {
  22472. return node.comments && node.comments.some(function (comment) {
  22473. return comment.leading;
  22474. });
  22475. }
  22476. function hasTrailingComment(node) {
  22477. return node.comments && node.comments.some(function (comment) {
  22478. return comment.trailing;
  22479. });
  22480. }
  22481. function hasLeadingOwnLineComment(text, node, options) {
  22482. if (isJSXNode(node)) {
  22483. return hasNodeIgnoreComment$1(node);
  22484. }
  22485. var res = node.comments && node.comments.some(function (comment) {
  22486. return comment.leading && hasNewline$3(text, options.locEnd(comment));
  22487. });
  22488. return res;
  22489. }
  22490. function hasNakedLeftSide(node) {
  22491. return node.type === "AssignmentExpression" || node.type === "BinaryExpression" || node.type === "LogicalExpression" || node.type === "NGPipeExpression" || node.type === "ConditionalExpression" || node.type === "CallExpression" || node.type === "OptionalCallExpression" || node.type === "MemberExpression" || node.type === "OptionalMemberExpression" || node.type === "SequenceExpression" || node.type === "TaggedTemplateExpression" || node.type === "BindExpression" || node.type === "UpdateExpression" && !node.prefix || node.type === "TSNonNullExpression";
  22492. }
  22493. function isFlowAnnotationComment(text, typeAnnotation, options) {
  22494. var start = options.locStart(typeAnnotation);
  22495. var end = skipWhitespace$1(text, options.locEnd(typeAnnotation));
  22496. return text.substr(start, 2) === "/*" && text.substr(end, 2) === "*/";
  22497. }
  22498. function getLeftSide(node) {
  22499. if (node.expressions) {
  22500. return node.expressions[0];
  22501. }
  22502. return node.left || node.test || node.callee || node.object || node.tag || node.argument || node.expression;
  22503. }
  22504. function getLeftSidePathName(path, node) {
  22505. if (node.expressions) {
  22506. return ["expressions", 0];
  22507. }
  22508. if (node.left) {
  22509. return ["left"];
  22510. }
  22511. if (node.test) {
  22512. return ["test"];
  22513. }
  22514. if (node.object) {
  22515. return ["object"];
  22516. }
  22517. if (node.callee) {
  22518. return ["callee"];
  22519. }
  22520. if (node.tag) {
  22521. return ["tag"];
  22522. }
  22523. if (node.argument) {
  22524. return ["argument"];
  22525. }
  22526. if (node.expression) {
  22527. return ["expression"];
  22528. }
  22529. throw new Error("Unexpected node has no left side", node);
  22530. }
  22531. function exprNeedsASIProtection(path, options) {
  22532. var node = path.getValue();
  22533. 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.object || node.type === "RegExpLiteral" || node.type === "Literal" && node.pattern || node.type === "Literal" && node.regex;
  22534. if (maybeASIProblem) {
  22535. return true;
  22536. }
  22537. if (!hasNakedLeftSide(node)) {
  22538. return false;
  22539. }
  22540. return path.call.apply(path, [function (childPath) {
  22541. return exprNeedsASIProtection(childPath, options);
  22542. }].concat(getLeftSidePathName(path, node)));
  22543. }
  22544. function stmtNeedsASIProtection(path, options) {
  22545. var node = path.getNode();
  22546. if (node.type !== "ExpressionStatement") {
  22547. return false;
  22548. }
  22549. return path.call(function (childPath) {
  22550. return exprNeedsASIProtection(childPath, options);
  22551. }, "expression");
  22552. }
  22553. function classPropMayCauseASIProblems(path) {
  22554. var node = path.getNode();
  22555. if (node.type !== "ClassProperty") {
  22556. return false;
  22557. }
  22558. var name = node.key && node.key.name; // this isn't actually possible yet with most parsers available today
  22559. // so isn't properly tested yet.
  22560. if ((name === "static" || name === "get" || name === "set") && !node.value && !node.typeAnnotation) {
  22561. return true;
  22562. }
  22563. }
  22564. function classChildNeedsASIProtection(node) {
  22565. if (!node) {
  22566. return;
  22567. }
  22568. if (node.static || node.accessibility // TypeScript
  22569. ) {
  22570. return false;
  22571. }
  22572. if (!node.computed) {
  22573. var name = node.key && node.key.name;
  22574. if (name === "in" || name === "instanceof") {
  22575. return true;
  22576. }
  22577. }
  22578. switch (node.type) {
  22579. case "ClassProperty":
  22580. case "TSAbstractClassProperty":
  22581. return node.computed;
  22582. case "MethodDefinition": // Flow
  22583. case "TSAbstractMethodDefinition": // TypeScript
  22584. case "ClassMethod":
  22585. case "ClassPrivateMethod":
  22586. {
  22587. // Babel
  22588. var isAsync = node.value ? node.value.async : node.async;
  22589. var isGenerator = node.value ? node.value.generator : node.generator;
  22590. if (isAsync || node.kind === "get" || node.kind === "set") {
  22591. return false;
  22592. }
  22593. if (node.computed || isGenerator) {
  22594. return true;
  22595. }
  22596. return false;
  22597. }
  22598. default:
  22599. /* istanbul ignore next */
  22600. return false;
  22601. }
  22602. } // This recurses the return argument, looking for the first token
  22603. // (the leftmost leaf node) and, if it (or its parents) has any
  22604. // leadingComments, returns true (so it can be wrapped in parens).
  22605. function returnArgumentHasLeadingComment(options, argument) {
  22606. if (hasLeadingOwnLineComment(options.originalText, argument, options)) {
  22607. return true;
  22608. }
  22609. if (hasNakedLeftSide(argument)) {
  22610. var leftMost = argument;
  22611. var newLeftMost;
  22612. while (newLeftMost = getLeftSide(leftMost)) {
  22613. leftMost = newLeftMost;
  22614. if (hasLeadingOwnLineComment(options.originalText, leftMost, options)) {
  22615. return true;
  22616. }
  22617. }
  22618. }
  22619. return false;
  22620. }
  22621. function isMemberExpressionChain(node) {
  22622. if (node.type !== "MemberExpression" && node.type !== "OptionalMemberExpression") {
  22623. return false;
  22624. }
  22625. if (node.object.type === "Identifier") {
  22626. return true;
  22627. }
  22628. return isMemberExpressionChain(node.object);
  22629. } // Hack to differentiate between the following two which have the same ast
  22630. // type T = { method: () => void };
  22631. // type T = { method(): void };
  22632. function isObjectTypePropertyAFunction(node, options) {
  22633. return (node.type === "ObjectTypeProperty" || node.type === "ObjectTypeInternalSlot") && node.value.type === "FunctionTypeAnnotation" && !node.static && !isFunctionNotation(node, options);
  22634. } // TODO: This is a bad hack and we need a better way to distinguish between
  22635. // arrow functions and otherwise
  22636. function isFunctionNotation(node, options) {
  22637. return isGetterOrSetter(node) || sameLocStart(node, node.value, options);
  22638. }
  22639. function isGetterOrSetter(node) {
  22640. return node.kind === "get" || node.kind === "set";
  22641. }
  22642. function sameLocStart(nodeA, nodeB, options) {
  22643. return options.locStart(nodeA) === options.locStart(nodeB);
  22644. } // Hack to differentiate between the following two which have the same ast
  22645. // declare function f(a): void;
  22646. // var f: (a) => void;
  22647. function isTypeAnnotationAFunction(node, options) {
  22648. return (node.type === "TypeAnnotation" || node.type === "TSTypeAnnotation") && node.typeAnnotation.type === "FunctionTypeAnnotation" && !node.static && !sameLocStart(node, node.typeAnnotation, options);
  22649. }
  22650. function isNodeStartingWithDeclare(node, options) {
  22651. if (!(options.parser === "flow" || options.parser === "typescript")) {
  22652. return false;
  22653. }
  22654. return options.originalText.slice(0, options.locStart(node)).match(/declare[ \t]*$/) || options.originalText.slice(node.range[0], node.range[1]).startsWith("declare ");
  22655. }
  22656. function shouldHugType(node) {
  22657. if (isSimpleFlowType(node) || isObjectType(node)) {
  22658. return true;
  22659. }
  22660. if (node.type === "UnionTypeAnnotation" || node.type === "TSUnionType") {
  22661. var voidCount = node.types.filter(function (n) {
  22662. return n.type === "VoidTypeAnnotation" || n.type === "TSVoidKeyword" || n.type === "NullLiteralTypeAnnotation" || n.type === "TSNullKeyword";
  22663. }).length;
  22664. var objectCount = node.types.filter(function (n) {
  22665. return n.type === "ObjectTypeAnnotation" || n.type === "TSTypeLiteral" || // This is a bit aggressive but captures Array<{x}>
  22666. n.type === "GenericTypeAnnotation" || n.type === "TSTypeReference";
  22667. }).length;
  22668. if (node.types.length - 1 === voidCount && objectCount > 0) {
  22669. return true;
  22670. }
  22671. }
  22672. return false;
  22673. }
  22674. function shouldHugArguments(fun) {
  22675. 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;
  22676. }
  22677. function templateLiteralHasNewLines(template) {
  22678. return template.quasis.some(function (quasi) {
  22679. return quasi.value.raw.includes("\n");
  22680. });
  22681. }
  22682. function isTemplateOnItsOwnLine(n, text, options) {
  22683. return (n.type === "TemplateLiteral" && templateLiteralHasNewLines(n) || n.type === "TaggedTemplateExpression" && templateLiteralHasNewLines(n.quasi)) && !hasNewline$3(text, options.locStart(n), {
  22684. backwards: true
  22685. });
  22686. }
  22687. function printArrayItems(path, options, printPath, print) {
  22688. var printedElements = [];
  22689. var separatorParts = [];
  22690. path.each(function (childPath) {
  22691. printedElements.push(concat$11(separatorParts));
  22692. printedElements.push(group$10(print(childPath)));
  22693. separatorParts = [",", line$8];
  22694. if (childPath.getValue() && isNextLineEmpty$4(options.originalText, childPath.getValue(), options)) {
  22695. separatorParts.push(softline$5);
  22696. }
  22697. }, printPath);
  22698. return concat$11(printedElements);
  22699. }
  22700. function hasDanglingComments(node) {
  22701. return node.comments && node.comments.some(function (comment) {
  22702. return !comment.leading && !comment.trailing;
  22703. });
  22704. }
  22705. function needsHardlineAfterDanglingComment(node) {
  22706. if (!node.comments) {
  22707. return false;
  22708. }
  22709. var lastDanglingComment = getLast$4(node.comments.filter(function (comment) {
  22710. return !comment.leading && !comment.trailing;
  22711. }));
  22712. return lastDanglingComment && !comments$3.isBlockComment(lastDanglingComment);
  22713. }
  22714. function isLiteral(node) {
  22715. 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";
  22716. }
  22717. function isNumericLiteral(node) {
  22718. return node.type === "NumericLiteral" || node.type === "Literal" && typeof node.value === "number";
  22719. }
  22720. function isStringLiteral(node) {
  22721. return node.type === "StringLiteral" || node.type === "Literal" && typeof node.value === "string";
  22722. }
  22723. function isObjectType(n) {
  22724. return n.type === "ObjectTypeAnnotation" || n.type === "TSTypeLiteral";
  22725. }
  22726. var unitTestRe = /^(skip|[fx]?(it|describe|test))$/; // eg; `describe("some string", (done) => {})`
  22727. function isTestCall(n, parent) {
  22728. if (n.type !== "CallExpression") {
  22729. return false;
  22730. }
  22731. if (n.arguments.length === 1) {
  22732. if (isAngularTestWrapper(n) && parent && isTestCall(parent)) {
  22733. return isFunctionOrArrowExpression(n.arguments[0]);
  22734. }
  22735. if (isUnitTestSetUp(n)) {
  22736. return isAngularTestWrapper(n.arguments[0]);
  22737. }
  22738. } else if (n.arguments.length === 2 || n.arguments.length === 3) {
  22739. if ((n.callee.type === "Identifier" && unitTestRe.test(n.callee.name) || isSkipOrOnlyBlock(n)) && (isTemplateLiteral(n.arguments[0]) || isStringLiteral(n.arguments[0]))) {
  22740. // it("name", () => { ... }, 2500)
  22741. if (n.arguments[2] && !isNumericLiteral(n.arguments[2])) {
  22742. return false;
  22743. }
  22744. return (n.arguments.length === 2 ? isFunctionOrArrowExpression(n.arguments[1]) : isFunctionOrArrowExpressionWithBody(n.arguments[1]) && n.arguments[1].params.length <= 1) || isAngularTestWrapper(n.arguments[1]);
  22745. }
  22746. }
  22747. return false;
  22748. }
  22749. function isSkipOrOnlyBlock(node) {
  22750. 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");
  22751. }
  22752. function isTemplateLiteral(node) {
  22753. return node.type === "TemplateLiteral";
  22754. } // `inject` is used in AngularJS 1.x, `async` in Angular 2+
  22755. // example: https://docs.angularjs.org/guide/unit-testing#using-beforeall-
  22756. function isAngularTestWrapper(node) {
  22757. return (node.type === "CallExpression" || node.type === "OptionalCallExpression") && node.callee.type === "Identifier" && (node.callee.name === "async" || node.callee.name === "inject" || node.callee.name === "fakeAsync");
  22758. }
  22759. function isFunctionOrArrowExpression(node) {
  22760. return node.type === "FunctionExpression" || node.type === "ArrowFunctionExpression";
  22761. }
  22762. function isFunctionOrArrowExpressionWithBody(node) {
  22763. return node.type === "FunctionExpression" || node.type === "ArrowFunctionExpression" && node.body.type === "BlockStatement";
  22764. }
  22765. function isUnitTestSetUp(n) {
  22766. var unitTestSetUpRe = /^(before|after)(Each|All)$/;
  22767. return n.callee.type === "Identifier" && unitTestSetUpRe.test(n.callee.name) && n.arguments.length === 1;
  22768. }
  22769. function isTheOnlyJSXElementInMarkdown(options, path) {
  22770. if (options.parentParser !== "markdown" && options.parentParser !== "mdx") {
  22771. return false;
  22772. }
  22773. var node = path.getNode();
  22774. if (!node.expression || !isJSXNode(node.expression)) {
  22775. return false;
  22776. }
  22777. var parent = path.getParentNode();
  22778. return parent.type === "Program" && parent.body.length == 1;
  22779. }
  22780. function willPrintOwnComments(path) {
  22781. var node = path.getValue();
  22782. var parent = path.getParentNode();
  22783. return (node && (isJSXNode(node) || hasFlowShorthandAnnotationComment(node) || parent && parent.type === "CallExpression" && (hasFlowAnnotationComment(node.leadingComments) || hasFlowAnnotationComment(node.trailingComments))) || parent && (parent.type === "JSXSpreadAttribute" || parent.type === "JSXSpreadChild" || parent.type === "UnionTypeAnnotation" || parent.type === "TSUnionType" || (parent.type === "ClassDeclaration" || parent.type === "ClassExpression") && parent.superClass === node)) && !hasIgnoreComment$3(path);
  22784. }
  22785. function canAttachComment$1(node) {
  22786. 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");
  22787. }
  22788. function printComment$2(commentPath, options) {
  22789. var comment = commentPath.getValue();
  22790. switch (comment.type) {
  22791. case "CommentBlock":
  22792. case "Block":
  22793. {
  22794. if (isIndentableBlockComment(comment)) {
  22795. var printed = printIndentableBlockComment(comment); // We need to prevent an edge case of a previous trailing comment
  22796. // printed as a `lineSuffix` which causes the comments to be
  22797. // interleaved. See https://github.com/prettier/prettier/issues/4412
  22798. if (comment.trailing && !hasNewline$3(options.originalText, options.locStart(comment), {
  22799. backwards: true
  22800. })) {
  22801. return concat$11([hardline$8, printed]);
  22802. }
  22803. return printed;
  22804. }
  22805. var isInsideFlowComment = options.originalText.substr(options.locEnd(comment) - 3, 3) === "*-/";
  22806. return "/*" + comment.value + (isInsideFlowComment ? "*-/" : "*/");
  22807. }
  22808. case "CommentLine":
  22809. case "Line":
  22810. // Print shebangs with the proper comment characters
  22811. if (options.originalText.slice(options.locStart(comment)).startsWith("#!")) {
  22812. return "#!" + comment.value.trimRight();
  22813. }
  22814. return "//" + comment.value.trimRight();
  22815. default:
  22816. throw new Error("Not a comment: " + JSON.stringify(comment));
  22817. }
  22818. }
  22819. function isIndentableBlockComment(comment) {
  22820. // If the comment has multiple lines and every line starts with a star
  22821. // we can fix the indentation of each line. The stars in the `/*` and
  22822. // `*/` delimiters are not included in the comment value, so add them
  22823. // back first.
  22824. var lines = "*".concat(comment.value, "*").split("\n");
  22825. return lines.length > 1 && lines.every(function (line) {
  22826. return line.trim()[0] === "*";
  22827. });
  22828. }
  22829. function printIndentableBlockComment(comment) {
  22830. var lines = comment.value.split("\n");
  22831. return concat$11(["/*", join$7(hardline$8, lines.map(function (line, index) {
  22832. return index === 0 ? line.trimRight() : " " + (index < lines.length - 1 ? line.trim() : line.trimLeft());
  22833. })), "*/"]);
  22834. }
  22835. function rawText(node) {
  22836. return node.extra ? node.extra.raw : node.raw;
  22837. }
  22838. function identity$1(x) {
  22839. return x;
  22840. }
  22841. var printerEstree = {
  22842. preprocess: preprocess_1$2,
  22843. print: genericPrint$3,
  22844. embed: embed_1$2,
  22845. insertPragma: insertPragma$7,
  22846. massageAstNode: clean_1$2,
  22847. hasPrettierIgnore: hasPrettierIgnore$2,
  22848. willPrintOwnComments: willPrintOwnComments,
  22849. canAttachComment: canAttachComment$1,
  22850. printComment: printComment$2,
  22851. isBlockComment: comments$3.isBlockComment,
  22852. handleComments: {
  22853. ownLine: comments$3.handleOwnLineComment,
  22854. endOfLine: comments$3.handleEndOfLineComment,
  22855. remaining: comments$3.handleRemainingComment
  22856. }
  22857. };
  22858. var _require$$0$builders$7 = doc.builders;
  22859. var concat$14 = _require$$0$builders$7.concat;
  22860. var hardline$10 = _require$$0$builders$7.hardline;
  22861. var indent$8 = _require$$0$builders$7.indent;
  22862. var join$10 = _require$$0$builders$7.join;
  22863. function genericPrint$4(path, options, print) {
  22864. var node = path.getValue();
  22865. switch (node.type) {
  22866. case "JsonRoot":
  22867. return concat$14([path.call(print, "node"), hardline$10]);
  22868. case "ArrayExpression":
  22869. return node.elements.length === 0 ? "[]" : concat$14(["[", indent$8(concat$14([hardline$10, join$10(concat$14([",", hardline$10]), path.map(print, "elements"))])), hardline$10, "]"]);
  22870. case "ObjectExpression":
  22871. return node.properties.length === 0 ? "{}" : concat$14(["{", indent$8(concat$14([hardline$10, join$10(concat$14([",", hardline$10]), path.map(print, "properties"))])), hardline$10, "}"]);
  22872. case "ObjectProperty":
  22873. return concat$14([path.call(print, "key"), ": ", path.call(print, "value")]);
  22874. case "UnaryExpression":
  22875. return concat$14([node.operator === "+" ? "" : node.operator, path.call(print, "argument")]);
  22876. case "NullLiteral":
  22877. return "null";
  22878. case "BooleanLiteral":
  22879. return node.value ? "true" : "false";
  22880. case "StringLiteral":
  22881. case "NumericLiteral":
  22882. return JSON.stringify(node.value);
  22883. case "Identifier":
  22884. return JSON.stringify(node.name);
  22885. default:
  22886. /* istanbul ignore next */
  22887. throw new Error("unknown type: " + JSON.stringify(node.type));
  22888. }
  22889. }
  22890. function clean$9(node, newNode
  22891. /*, parent*/
  22892. ) {
  22893. delete newNode.start;
  22894. delete newNode.end;
  22895. delete newNode.extra;
  22896. delete newNode.loc;
  22897. delete newNode.comments;
  22898. if (node.type === "Identifier") {
  22899. return {
  22900. type: "StringLiteral",
  22901. value: node.name
  22902. };
  22903. }
  22904. if (node.type === "UnaryExpression" && node.operator === "+") {
  22905. return newNode.argument;
  22906. }
  22907. }
  22908. var printerEstreeJson = {
  22909. preprocess: preprocess_1$2,
  22910. print: genericPrint$4,
  22911. massageAstNode: clean$9
  22912. };
  22913. var CATEGORY_JAVASCRIPT = "JavaScript"; // format based on https://github.com/prettier/prettier/blob/master/src/main/core-options.js
  22914. var options$12 = {
  22915. arrowParens: {
  22916. since: "1.9.0",
  22917. category: CATEGORY_JAVASCRIPT,
  22918. type: "choice",
  22919. default: "avoid",
  22920. description: "Include parentheses around a sole arrow function parameter.",
  22921. choices: [{
  22922. value: "avoid",
  22923. description: "Omit parens when possible. Example: `x => x`"
  22924. }, {
  22925. value: "always",
  22926. description: "Always include parens. Example: `(x) => x`"
  22927. }]
  22928. },
  22929. bracketSpacing: commonOptions.bracketSpacing,
  22930. jsxBracketSameLine: {
  22931. since: "0.17.0",
  22932. category: CATEGORY_JAVASCRIPT,
  22933. type: "boolean",
  22934. default: false,
  22935. description: "Put > on the last line instead of at a new line."
  22936. },
  22937. semi: {
  22938. since: "1.0.0",
  22939. category: CATEGORY_JAVASCRIPT,
  22940. type: "boolean",
  22941. default: true,
  22942. description: "Print semicolons.",
  22943. oppositeDescription: "Do not print semicolons, except at the beginning of lines which may need them."
  22944. },
  22945. singleQuote: commonOptions.singleQuote,
  22946. jsxSingleQuote: {
  22947. since: "1.15.0",
  22948. category: CATEGORY_JAVASCRIPT,
  22949. type: "boolean",
  22950. default: false,
  22951. description: "Use single quotes in JSX."
  22952. },
  22953. trailingComma: {
  22954. since: "0.0.0",
  22955. category: CATEGORY_JAVASCRIPT,
  22956. type: "choice",
  22957. default: [{
  22958. since: "0.0.0",
  22959. value: false
  22960. }, {
  22961. since: "0.19.0",
  22962. value: "none"
  22963. }],
  22964. description: "Print trailing commas wherever possible when multi-line.",
  22965. choices: [{
  22966. value: "none",
  22967. description: "No trailing commas."
  22968. }, {
  22969. value: "es5",
  22970. description: "Trailing commas where valid in ES5 (objects, arrays, etc.)"
  22971. }, {
  22972. value: "all",
  22973. description: "Trailing commas wherever possible (including function arguments)."
  22974. }, {
  22975. value: true,
  22976. deprecated: "0.19.0",
  22977. redirect: "es5"
  22978. }, {
  22979. value: false,
  22980. deprecated: "0.19.0",
  22981. redirect: "none"
  22982. }]
  22983. }
  22984. };
  22985. var name$9 = "JavaScript";
  22986. var type$8 = "programming";
  22987. var tmScope$8 = "source.js";
  22988. var aceMode$8 = "javascript";
  22989. var codemirrorMode$4 = "javascript";
  22990. var codemirrorMimeType$4 = "text/javascript";
  22991. var color$3 = "#f1e05a";
  22992. var aliases$2 = ["js", "node"];
  22993. var extensions$8 = [".js", "._js", ".bones", ".es", ".es6", ".frag", ".gs", ".jake", ".jsb", ".jscad", ".jsfl", ".jsm", ".jss", ".mjs", ".njs", ".pac", ".sjs", ".ssjs", ".xsjs", ".xsjslib"];
  22994. var filenames = ["Jakefile"];
  22995. var interpreters = ["node"];
  22996. var languageId$8 = 183;
  22997. var javascript = {
  22998. name: name$9,
  22999. type: type$8,
  23000. tmScope: tmScope$8,
  23001. aceMode: aceMode$8,
  23002. codemirrorMode: codemirrorMode$4,
  23003. codemirrorMimeType: codemirrorMimeType$4,
  23004. color: color$3,
  23005. aliases: aliases$2,
  23006. extensions: extensions$8,
  23007. filenames: filenames,
  23008. interpreters: interpreters,
  23009. languageId: languageId$8
  23010. };
  23011. var javascript$1 = Object.freeze({
  23012. name: name$9,
  23013. type: type$8,
  23014. tmScope: tmScope$8,
  23015. aceMode: aceMode$8,
  23016. codemirrorMode: codemirrorMode$4,
  23017. codemirrorMimeType: codemirrorMimeType$4,
  23018. color: color$3,
  23019. aliases: aliases$2,
  23020. extensions: extensions$8,
  23021. filenames: filenames,
  23022. interpreters: interpreters,
  23023. languageId: languageId$8,
  23024. default: javascript
  23025. });
  23026. var name$10 = "JSX";
  23027. var type$9 = "programming";
  23028. var group$12 = "JavaScript";
  23029. var extensions$9 = [".jsx"];
  23030. var tmScope$9 = "source.js.jsx";
  23031. var aceMode$9 = "javascript";
  23032. var codemirrorMode$5 = "jsx";
  23033. var codemirrorMimeType$5 = "text/jsx";
  23034. var languageId$9 = 178;
  23035. var jsx = {
  23036. name: name$10,
  23037. type: type$9,
  23038. group: group$12,
  23039. extensions: extensions$9,
  23040. tmScope: tmScope$9,
  23041. aceMode: aceMode$9,
  23042. codemirrorMode: codemirrorMode$5,
  23043. codemirrorMimeType: codemirrorMimeType$5,
  23044. languageId: languageId$9
  23045. };
  23046. var jsx$1 = Object.freeze({
  23047. name: name$10,
  23048. type: type$9,
  23049. group: group$12,
  23050. extensions: extensions$9,
  23051. tmScope: tmScope$9,
  23052. aceMode: aceMode$9,
  23053. codemirrorMode: codemirrorMode$5,
  23054. codemirrorMimeType: codemirrorMimeType$5,
  23055. languageId: languageId$9,
  23056. default: jsx
  23057. });
  23058. var name$11 = "TypeScript";
  23059. var type$10 = "programming";
  23060. var color$4 = "#2b7489";
  23061. var aliases$3 = ["ts"];
  23062. var extensions$10 = [".ts", ".tsx"];
  23063. var tmScope$10 = "source.ts";
  23064. var aceMode$10 = "typescript";
  23065. var codemirrorMode$6 = "javascript";
  23066. var codemirrorMimeType$6 = "application/typescript";
  23067. var languageId$10 = 378;
  23068. var typescript = {
  23069. name: name$11,
  23070. type: type$10,
  23071. color: color$4,
  23072. aliases: aliases$3,
  23073. extensions: extensions$10,
  23074. tmScope: tmScope$10,
  23075. aceMode: aceMode$10,
  23076. codemirrorMode: codemirrorMode$6,
  23077. codemirrorMimeType: codemirrorMimeType$6,
  23078. languageId: languageId$10
  23079. };
  23080. var typescript$1 = Object.freeze({
  23081. name: name$11,
  23082. type: type$10,
  23083. color: color$4,
  23084. aliases: aliases$3,
  23085. extensions: extensions$10,
  23086. tmScope: tmScope$10,
  23087. aceMode: aceMode$10,
  23088. codemirrorMode: codemirrorMode$6,
  23089. codemirrorMimeType: codemirrorMimeType$6,
  23090. languageId: languageId$10,
  23091. default: typescript
  23092. });
  23093. var name$12 = "JSON";
  23094. var type$11 = "data";
  23095. var tmScope$11 = "source.json";
  23096. var group$13 = "JavaScript";
  23097. var aceMode$11 = "json";
  23098. var codemirrorMode$7 = "javascript";
  23099. var codemirrorMimeType$7 = "application/json";
  23100. var searchable = false;
  23101. var extensions$11 = [".json", ".avsc", ".geojson", ".gltf", ".JSON-tmLanguage", ".jsonl", ".tfstate", ".tfstate.backup", ".topojson", ".webapp", ".webmanifest"];
  23102. var filenames$1 = [".arcconfig", ".htmlhintrc", ".tern-config", ".tern-project", "composer.lock", "mcmod.info"];
  23103. var languageId$11 = 174;
  23104. var json$5 = {
  23105. name: name$12,
  23106. type: type$11,
  23107. tmScope: tmScope$11,
  23108. group: group$13,
  23109. aceMode: aceMode$11,
  23110. codemirrorMode: codemirrorMode$7,
  23111. codemirrorMimeType: codemirrorMimeType$7,
  23112. searchable: searchable,
  23113. extensions: extensions$11,
  23114. filenames: filenames$1,
  23115. languageId: languageId$11
  23116. };
  23117. var json$6 = Object.freeze({
  23118. name: name$12,
  23119. type: type$11,
  23120. tmScope: tmScope$11,
  23121. group: group$13,
  23122. aceMode: aceMode$11,
  23123. codemirrorMode: codemirrorMode$7,
  23124. codemirrorMimeType: codemirrorMimeType$7,
  23125. searchable: searchable,
  23126. extensions: extensions$11,
  23127. filenames: filenames$1,
  23128. languageId: languageId$11,
  23129. default: json$5
  23130. });
  23131. var name$13 = "JSON with Comments";
  23132. var type$12 = "data";
  23133. var group$14 = "JSON";
  23134. var tmScope$12 = "source.js";
  23135. var aceMode$12 = "javascript";
  23136. var codemirrorMode$8 = "javascript";
  23137. var codemirrorMimeType$8 = "text/javascript";
  23138. var aliases$4 = ["jsonc"];
  23139. var extensions$12 = [".sublime-build", ".sublime-commands", ".sublime-completions", ".sublime-keymap", ".sublime-macro", ".sublime-menu", ".sublime-mousemap", ".sublime-project", ".sublime-settings", ".sublime-theme", ".sublime-workspace", ".sublime_metrics", ".sublime_session"];
  23140. var filenames$2 = [".babelrc", ".eslintrc.json", ".jscsrc", ".jshintrc", ".jslintrc", "tsconfig.json"];
  23141. var languageId$12 = 423;
  23142. var jsonWithComments = {
  23143. name: name$13,
  23144. type: type$12,
  23145. group: group$14,
  23146. tmScope: tmScope$12,
  23147. aceMode: aceMode$12,
  23148. codemirrorMode: codemirrorMode$8,
  23149. codemirrorMimeType: codemirrorMimeType$8,
  23150. aliases: aliases$4,
  23151. extensions: extensions$12,
  23152. filenames: filenames$2,
  23153. languageId: languageId$12
  23154. };
  23155. var jsonWithComments$1 = Object.freeze({
  23156. name: name$13,
  23157. type: type$12,
  23158. group: group$14,
  23159. tmScope: tmScope$12,
  23160. aceMode: aceMode$12,
  23161. codemirrorMode: codemirrorMode$8,
  23162. codemirrorMimeType: codemirrorMimeType$8,
  23163. aliases: aliases$4,
  23164. extensions: extensions$12,
  23165. filenames: filenames$2,
  23166. languageId: languageId$12,
  23167. default: jsonWithComments
  23168. });
  23169. var name$14 = "JSON5";
  23170. var type$13 = "data";
  23171. var extensions$13 = [".json5"];
  23172. var tmScope$13 = "source.js";
  23173. var aceMode$13 = "javascript";
  23174. var codemirrorMode$9 = "javascript";
  23175. var codemirrorMimeType$9 = "application/json";
  23176. var languageId$13 = 175;
  23177. var json5 = {
  23178. name: name$14,
  23179. type: type$13,
  23180. extensions: extensions$13,
  23181. tmScope: tmScope$13,
  23182. aceMode: aceMode$13,
  23183. codemirrorMode: codemirrorMode$9,
  23184. codemirrorMimeType: codemirrorMimeType$9,
  23185. languageId: languageId$13
  23186. };
  23187. var json5$1 = Object.freeze({
  23188. name: name$14,
  23189. type: type$13,
  23190. extensions: extensions$13,
  23191. tmScope: tmScope$13,
  23192. aceMode: aceMode$13,
  23193. codemirrorMode: codemirrorMode$9,
  23194. codemirrorMimeType: codemirrorMimeType$9,
  23195. languageId: languageId$13,
  23196. default: json5
  23197. });
  23198. var require$$0$24 = ( javascript$1 && javascript ) || javascript$1;
  23199. var require$$1$10 = ( jsx$1 && jsx ) || jsx$1;
  23200. var require$$2$10 = ( typescript$1 && typescript ) || typescript$1;
  23201. var require$$3$7 = ( json$6 && json$5 ) || json$6;
  23202. var require$$4$4 = ( jsonWithComments$1 && jsonWithComments ) || jsonWithComments$1;
  23203. var require$$5$2 = ( json5$1 && json5 ) || json5$1;
  23204. var languages$4 = [createLanguage(require$$0$24, {
  23205. override: {
  23206. since: "0.0.0",
  23207. parsers: ["babel", "flow"],
  23208. vscodeLanguageIds: ["javascript"]
  23209. },
  23210. extend: {
  23211. interpreters: ["nodejs"]
  23212. }
  23213. }), createLanguage(require$$0$24, {
  23214. override: {
  23215. name: "Flow",
  23216. since: "0.0.0",
  23217. parsers: ["babel", "flow"],
  23218. vscodeLanguageIds: ["javascript"],
  23219. aliases: [],
  23220. filenames: [],
  23221. extensions: [".js.flow"]
  23222. }
  23223. }), createLanguage(require$$1$10, {
  23224. override: {
  23225. since: "0.0.0",
  23226. parsers: ["babel", "flow"],
  23227. vscodeLanguageIds: ["javascriptreact"]
  23228. }
  23229. }), createLanguage(require$$2$10, {
  23230. override: {
  23231. since: "1.4.0",
  23232. parsers: ["typescript"],
  23233. vscodeLanguageIds: ["typescript", "typescriptreact"]
  23234. }
  23235. }), createLanguage(require$$3$7, {
  23236. override: {
  23237. name: "JSON.stringify",
  23238. since: "1.13.0",
  23239. parsers: ["json-stringify"],
  23240. vscodeLanguageIds: ["json"],
  23241. extensions: [],
  23242. // .json file defaults to json instead of json-stringify
  23243. filenames: ["package.json", "package-lock.json", "composer.json"]
  23244. }
  23245. }), createLanguage(require$$3$7, {
  23246. override: {
  23247. since: "1.5.0",
  23248. parsers: ["json"],
  23249. vscodeLanguageIds: ["json"]
  23250. },
  23251. extend: {
  23252. filenames: [".prettierrc"]
  23253. }
  23254. }), createLanguage(require$$4$4, {
  23255. override: {
  23256. since: "1.5.0",
  23257. parsers: ["json"],
  23258. vscodeLanguageIds: ["jsonc"]
  23259. },
  23260. extend: {
  23261. filenames: [".eslintrc"]
  23262. }
  23263. }), createLanguage(require$$5$2, {
  23264. override: {
  23265. since: "1.13.0",
  23266. parsers: ["json5"],
  23267. vscodeLanguageIds: ["json5"]
  23268. }
  23269. })];
  23270. var printers$4 = {
  23271. estree: printerEstree,
  23272. "estree-json": printerEstreeJson
  23273. };
  23274. var languageJs = {
  23275. languages: languages$4,
  23276. options: options$12,
  23277. printers: printers$4
  23278. };
  23279. var json$9 = {"cjkPattern":"[\\u02ea-\\u02eb\\u1100-\\u11ff\\u2e80-\\u2e99\\u2e9b-\\u2ef3\\u2f00-\\u2fd5\\u3000-\\u303f\\u3041-\\u3096\\u3099-\\u309f\\u30a1-\\u30fa\\u30fc-\\u30ff\\u3105-\\u312e\\u3131-\\u318e\\u3190-\\u3191\\u3196-\\u31ba\\u31c0-\\u31e3\\u31f0-\\u321e\\u322a-\\u3247\\u3260-\\u327e\\u328a-\\u32b0\\u32c0-\\u32cb\\u32d0-\\u32fe\\u3300-\\u3370\\u337b-\\u337f\\u33e0-\\u33fe\\u3400-\\u4db5\\u4e00-\\u9fea\\ua960-\\ua97c\\uac00-\\ud7a3\\ud7b0-\\ud7c6\\ud7cb-\\ud7fb\\uf900-\\ufa6d\\ufa70-\\ufad9\\ufe10-\\ufe1f\\ufe30-\\ufe6f\\uff00-\\uffef]|[\\ud840-\\ud868\\ud86a-\\ud86c\\ud86f-\\ud872\\ud874-\\ud879][\\udc00-\\udfff]|\\ud82c[\\udc00-\\udd1e]|\\ud83c[\\ude00\\ude50-\\ude51]|\\ud869[\\udc00-\\uded6\\udf00-\\udfff]|\\ud86d[\\udc00-\\udf34\\udf40-\\udfff]|\\ud86e[\\udc00-\\udc1d\\udc20-\\udfff]|\\ud873[\\udc00-\\udea1\\udeb0-\\udfff]|\\ud87a[\\udc00-\\udfe0]|\\ud87e[\\udc00-\\ude1d]","kPattern":"[\\u1100-\\u11ff\\u3001-\\u3003\\u3008-\\u3011\\u3013-\\u301f\\u302e-\\u3030\\u3037\\u30fb\\u3131-\\u318e\\u3200-\\u321e\\u3260-\\u327e\\ua960-\\ua97c\\uac00-\\ud7a3\\ud7b0-\\ud7c6\\ud7cb-\\ud7fb\\ufe45-\\ufe46\\uff61-\\uff65\\uffa0-\\uffbe\\uffc2-\\uffc7\\uffca-\\uffcf\\uffd2-\\uffd7\\uffda-\\uffdc]","punctuationPattern":"[\\u0021-\\u002f\\u003a-\\u0040\\u005b-\\u0060\\u007b-\\u007e\\u00a1\\u00a7\\u00ab\\u00b6-\\u00b7\\u00bb\\u00bf\\u037e\\u0387\\u055a-\\u055f\\u0589-\\u058a\\u05be\\u05c0\\u05c3\\u05c6\\u05f3-\\u05f4\\u0609-\\u060a\\u060c-\\u060d\\u061b\\u061e-\\u061f\\u066a-\\u066d\\u06d4\\u0700-\\u070d\\u07f7-\\u07f9\\u0830-\\u083e\\u085e\\u0964-\\u0965\\u0970\\u09fd\\u0af0\\u0df4\\u0e4f\\u0e5a-\\u0e5b\\u0f04-\\u0f12\\u0f14\\u0f3a-\\u0f3d\\u0f85\\u0fd0-\\u0fd4\\u0fd9-\\u0fda\\u104a-\\u104f\\u10fb\\u1360-\\u1368\\u1400\\u166d-\\u166e\\u169b-\\u169c\\u16eb-\\u16ed\\u1735-\\u1736\\u17d4-\\u17d6\\u17d8-\\u17da\\u1800-\\u180a\\u1944-\\u1945\\u1a1e-\\u1a1f\\u1aa0-\\u1aa6\\u1aa8-\\u1aad\\u1b5a-\\u1b60\\u1bfc-\\u1bff\\u1c3b-\\u1c3f\\u1c7e-\\u1c7f\\u1cc0-\\u1cc7\\u1cd3\\u2010-\\u2027\\u2030-\\u2043\\u2045-\\u2051\\u2053-\\u205e\\u207d-\\u207e\\u208d-\\u208e\\u2308-\\u230b\\u2329-\\u232a\\u2768-\\u2775\\u27c5-\\u27c6\\u27e6-\\u27ef\\u2983-\\u2998\\u29d8-\\u29db\\u29fc-\\u29fd\\u2cf9-\\u2cfc\\u2cfe-\\u2cff\\u2d70\\u2e00-\\u2e2e\\u2e30-\\u2e49\\u3001-\\u3003\\u3008-\\u3011\\u3014-\\u301f\\u3030\\u303d\\u30a0\\u30fb\\ua4fe-\\ua4ff\\ua60d-\\ua60f\\ua673\\ua67e\\ua6f2-\\ua6f7\\ua874-\\ua877\\ua8ce-\\ua8cf\\ua8f8-\\ua8fa\\ua8fc\\ua92e-\\ua92f\\ua95f\\ua9c1-\\ua9cd\\ua9de-\\ua9df\\uaa5c-\\uaa5f\\uaade-\\uaadf\\uaaf0-\\uaaf1\\uabeb\\ufd3e-\\ufd3f\\ufe10-\\ufe19\\ufe30-\\ufe52\\ufe54-\\ufe61\\ufe63\\ufe68\\ufe6a-\\ufe6b\\uff01-\\uff03\\uff05-\\uff0a\\uff0c-\\uff0f\\uff1a-\\uff1b\\uff1f-\\uff20\\uff3b-\\uff3d\\uff3f\\uff5b\\uff5d\\uff5f-\\uff65]|\\ud800[\\udd00-\\udd02\\udf9f\\udfd0]|\\ud801[\\udd6f]|\\ud802[\\udc57\\udd1f\\udd3f\\ude50-\\ude58\\ude7f\\udef0-\\udef6\\udf39-\\udf3f\\udf99-\\udf9c]|\\ud804[\\udc47-\\udc4d\\udcbb-\\udcbc\\udcbe-\\udcc1\\udd40-\\udd43\\udd74-\\udd75\\uddc5-\\uddc9\\uddcd\\udddb\\udddd-\\udddf\\ude38-\\ude3d\\udea9]|\\ud805[\\udc4b-\\udc4f\\udc5b\\udc5d\\udcc6\\uddc1-\\uddd7\\ude41-\\ude43\\ude60-\\ude6c\\udf3c-\\udf3e]|\\ud806[\\ude3f-\\ude46\\ude9a-\\ude9c\\ude9e-\\udea2]|\\ud807[\\udc41-\\udc45\\udc70-\\udc71]|\\ud809[\\udc70-\\udc74]|\\ud81a[\\ude6e-\\ude6f\\udef5\\udf37-\\udf3b\\udf44]|\\ud82f[\\udc9f]|\\ud836[\\ude87-\\ude8b]|\\ud83a[\\udd5e-\\udd5f]"};
  23280. var cjkPattern = json$9.cjkPattern;
  23281. var kPattern = json$9.kPattern;
  23282. var punctuationPattern$1 = json$9.punctuationPattern;
  23283. var getLast$5 = util.getLast;
  23284. var INLINE_NODE_TYPES$1 = ["liquidNode", "inlineCode", "emphasis", "strong", "delete", "link", "linkReference", "image", "imageReference", "footnote", "footnoteReference", "sentence", "whitespace", "word", "break", "inlineMath"];
  23285. var INLINE_NODE_WRAPPER_TYPES$1 = INLINE_NODE_TYPES$1.concat(["tableCell", "paragraph", "heading"]);
  23286. var kRegex = new RegExp(kPattern);
  23287. var punctuationRegex = new RegExp(punctuationPattern$1);
  23288. /**
  23289. * split text into whitespaces and words
  23290. * @param {string} text
  23291. * @return {Array<{ type: "whitespace", value: " " | "\n" | "" } | { type: "word", value: string }>}
  23292. */
  23293. function splitText$1(text, options) {
  23294. var KIND_NON_CJK = "non-cjk";
  23295. var KIND_CJ_LETTER = "cj-letter";
  23296. var KIND_K_LETTER = "k-letter";
  23297. var KIND_CJK_PUNCTUATION = "cjk-punctuation";
  23298. var nodes = [];
  23299. (options.proseWrap === "preserve" ? text : text.replace(new RegExp("(".concat(cjkPattern, ")\n(").concat(cjkPattern, ")"), "g"), "$1$2")).split(/([ \t\n]+)/).forEach(function (token, index, tokens) {
  23300. // whitespace
  23301. if (index % 2 === 1) {
  23302. nodes.push({
  23303. type: "whitespace",
  23304. value: /\n/.test(token) ? "\n" : " "
  23305. });
  23306. return;
  23307. } // word separated by whitespace
  23308. if ((index === 0 || index === tokens.length - 1) && token === "") {
  23309. return;
  23310. }
  23311. token.split(new RegExp("(".concat(cjkPattern, ")"))).forEach(function (innerToken, innerIndex, innerTokens) {
  23312. if ((innerIndex === 0 || innerIndex === innerTokens.length - 1) && innerToken === "") {
  23313. return;
  23314. } // non-CJK word
  23315. if (innerIndex % 2 === 0) {
  23316. if (innerToken !== "") {
  23317. appendNode({
  23318. type: "word",
  23319. value: innerToken,
  23320. kind: KIND_NON_CJK,
  23321. hasLeadingPunctuation: punctuationRegex.test(innerToken[0]),
  23322. hasTrailingPunctuation: punctuationRegex.test(getLast$5(innerToken))
  23323. });
  23324. }
  23325. return;
  23326. } // CJK character
  23327. appendNode(punctuationRegex.test(innerToken) ? {
  23328. type: "word",
  23329. value: innerToken,
  23330. kind: KIND_CJK_PUNCTUATION,
  23331. hasLeadingPunctuation: true,
  23332. hasTrailingPunctuation: true
  23333. } : {
  23334. type: "word",
  23335. value: innerToken,
  23336. kind: kRegex.test(innerToken) ? KIND_K_LETTER : KIND_CJ_LETTER,
  23337. hasLeadingPunctuation: false,
  23338. hasTrailingPunctuation: false
  23339. });
  23340. });
  23341. });
  23342. return nodes;
  23343. function appendNode(node) {
  23344. var lastNode = getLast$5(nodes);
  23345. if (lastNode && lastNode.type === "word") {
  23346. if (lastNode.kind === KIND_NON_CJK && node.kind === KIND_CJ_LETTER && !lastNode.hasTrailingPunctuation || lastNode.kind === KIND_CJ_LETTER && node.kind === KIND_NON_CJK && !node.hasLeadingPunctuation) {
  23347. nodes.push({
  23348. type: "whitespace",
  23349. value: " "
  23350. });
  23351. } else if (!isBetween(KIND_NON_CJK, KIND_CJK_PUNCTUATION) && // disallow leading/trailing full-width whitespace
  23352. ![lastNode.value, node.value].some(function (value) {
  23353. return /\u3000/.test(value);
  23354. })) {
  23355. nodes.push({
  23356. type: "whitespace",
  23357. value: ""
  23358. });
  23359. }
  23360. }
  23361. nodes.push(node);
  23362. function isBetween(kind1, kind2) {
  23363. return lastNode.kind === kind1 && node.kind === kind2 || lastNode.kind === kind2 && node.kind === kind1;
  23364. }
  23365. }
  23366. }
  23367. function getOrderedListItemInfo$1(orderListItem, originalText) {
  23368. var _originalText$slice$m = originalText.slice(orderListItem.position.start.offset, orderListItem.position.end.offset).match(/^\s*(\d+)(\.|\))(\s*)/),
  23369. _originalText$slice$m2 = _slicedToArray(_originalText$slice$m, 4),
  23370. numberText = _originalText$slice$m2[1],
  23371. marker = _originalText$slice$m2[2],
  23372. leadingSpaces = _originalText$slice$m2[3];
  23373. return {
  23374. numberText: numberText,
  23375. marker: marker,
  23376. leadingSpaces: leadingSpaces
  23377. };
  23378. } // workaround for https://github.com/remarkjs/remark/issues/351
  23379. // leading and trailing newlines are stripped by remark
  23380. function getFencedCodeBlockValue$2(node, originalText) {
  23381. var text = originalText.slice(node.position.start.offset, node.position.end.offset);
  23382. var leadingSpaceCount = text.match(/^\s*/)[0].length;
  23383. var replaceRegex = new RegExp("^\\s{0,".concat(leadingSpaceCount, "}"));
  23384. var lineContents = text.split("\n");
  23385. var markerStyle = text[leadingSpaceCount]; // ` or ~
  23386. var marker = text.slice(leadingSpaceCount).match(new RegExp("^[".concat(markerStyle, "]+")))[0]; // https://spec.commonmark.org/0.28/#example-104: Closing fences may be indented by 0-3 spaces
  23387. // https://spec.commonmark.org/0.28/#example-93: The closing code fence must be at least as long as the opening fence
  23388. var hasEndMarker = new RegExp("^\\s{0,3}".concat(marker)).test(lineContents[lineContents.length - 1].slice(getIndent(lineContents.length - 1)));
  23389. return lineContents.slice(1, hasEndMarker ? -1 : undefined).map(function (x, i) {
  23390. return x.slice(getIndent(i + 1)).replace(replaceRegex, "");
  23391. }).join("\n");
  23392. function getIndent(lineIndex) {
  23393. return node.position.indent[lineIndex - 1] - 1;
  23394. }
  23395. }
  23396. function mapAst(ast, handler) {
  23397. return function preorder(node, index, parentStack) {
  23398. parentStack = parentStack || [];
  23399. var newNode = Object.assign({}, handler(node, index, parentStack));
  23400. if (newNode.children) {
  23401. newNode.children = newNode.children.map(function (child, index) {
  23402. return preorder(child, index, [newNode].concat(parentStack));
  23403. });
  23404. }
  23405. return newNode;
  23406. }(ast, null, null);
  23407. }
  23408. var utils$10 = {
  23409. mapAst: mapAst,
  23410. splitText: splitText$1,
  23411. punctuationPattern: punctuationPattern$1,
  23412. getFencedCodeBlockValue: getFencedCodeBlockValue$2,
  23413. getOrderedListItemInfo: getOrderedListItemInfo$1,
  23414. INLINE_NODE_TYPES: INLINE_NODE_TYPES$1,
  23415. INLINE_NODE_WRAPPER_TYPES: INLINE_NODE_WRAPPER_TYPES$1
  23416. };
  23417. var _require$$0$builders$9 = doc.builders;
  23418. var hardline$12 = _require$$0$builders$9.hardline;
  23419. var literalline$6 = _require$$0$builders$9.literalline;
  23420. var concat$16 = _require$$0$builders$9.concat;
  23421. var markAsRoot$4 = _require$$0$builders$9.markAsRoot;
  23422. var mapDoc$7 = doc.utils.mapDoc;
  23423. var getFencedCodeBlockValue$1 = utils$10.getFencedCodeBlockValue;
  23424. function embed$6(path, print, textToDoc, options) {
  23425. var node = path.getValue();
  23426. if (node.type === "code" && node.lang !== null) {
  23427. // only look for the first string so as to support [markdown-preview-enhanced](https://shd101wyy.github.io/markdown-preview-enhanced/#/code-chunk)
  23428. var langMatch = node.lang.match(/^[A-Za-z0-9_-]+/);
  23429. var lang = langMatch ? langMatch[0] : "";
  23430. var parser = getParserName(lang);
  23431. if (parser) {
  23432. var styleUnit = options.__inJsTemplate ? "~" : "`";
  23433. var style = styleUnit.repeat(Math.max(3, util.getMaxContinuousCount(node.value, styleUnit) + 1));
  23434. var doc$$2 = textToDoc(getFencedCodeBlockValue$1(node, options.originalText), {
  23435. parser: parser
  23436. });
  23437. return markAsRoot$4(concat$16([style, node.lang, hardline$12, replaceNewlinesWithLiterallines(doc$$2), style]));
  23438. }
  23439. }
  23440. if (node.type === "yaml") {
  23441. return markAsRoot$4(concat$16(["---", hardline$12, node.value && node.value.trim() ? replaceNewlinesWithLiterallines(textToDoc(node.value, {
  23442. parser: "yaml"
  23443. })) : "", "---"]));
  23444. } // MDX
  23445. switch (node.type) {
  23446. case "importExport":
  23447. return textToDoc(node.value, {
  23448. parser: "babel"
  23449. });
  23450. case "jsx":
  23451. return textToDoc(node.value, {
  23452. parser: "__js_expression"
  23453. });
  23454. }
  23455. return null;
  23456. function getParserName(lang) {
  23457. var supportInfo = support.getSupportInfo(null, {
  23458. plugins: options.plugins
  23459. });
  23460. var language = supportInfo.languages.find(function (language) {
  23461. return language.name.toLowerCase() === lang || language.aliases && language.aliases.indexOf(lang) !== -1 || language.extensions && language.extensions.find(function (ext) {
  23462. return ext.substring(1) === lang;
  23463. });
  23464. });
  23465. if (language) {
  23466. return language.parsers[0];
  23467. }
  23468. return null;
  23469. }
  23470. function replaceNewlinesWithLiterallines(doc$$2) {
  23471. return mapDoc$7(doc$$2, function (currentDoc) {
  23472. return typeof currentDoc === "string" && currentDoc.includes("\n") ? concat$16(currentDoc.split(/(\n)/g).map(function (v, i) {
  23473. return i % 2 === 0 ? v : literalline$6;
  23474. })) : currentDoc;
  23475. });
  23476. }
  23477. }
  23478. var embed_1$4 = embed$6;
  23479. var pragma$8 = createCommonjsModule(function (module) {
  23480. "use strict";
  23481. var pragmas = ["format", "prettier"];
  23482. function startWithPragma(text) {
  23483. var pragma = "@(".concat(pragmas.join("|"), ")");
  23484. var regex = new RegExp(["<!--\\s*".concat(pragma, "\\s*-->"), "<!--.*\r?\n[\\s\\S]*(^|\n)[^\\S\n]*".concat(pragma, "[^\\S\n]*($|\n)[\\s\\S]*\n.*-->")].join("|"), "m");
  23485. var matched = text.match(regex);
  23486. return matched && matched.index === 0;
  23487. }
  23488. module.exports = {
  23489. startWithPragma: startWithPragma,
  23490. hasPragma: function hasPragma(text) {
  23491. return startWithPragma(frontMatter(text).content.trimLeft());
  23492. },
  23493. insertPragma: function insertPragma(text) {
  23494. var extracted = frontMatter(text);
  23495. var pragma = "<!-- @".concat(pragmas[0], " -->");
  23496. return extracted.frontMatter ? "".concat(extracted.frontMatter.raw, "\n\n").concat(pragma, "\n\n").concat(extracted.content) : "".concat(pragma, "\n\n").concat(extracted.content);
  23497. }
  23498. };
  23499. });
  23500. var getOrderedListItemInfo$2 = utils$10.getOrderedListItemInfo;
  23501. var mapAst$1 = utils$10.mapAst;
  23502. var splitText$2 = utils$10.splitText; // 0x0 ~ 0x10ffff
  23503. var isSingleCharRegex = /^([\u0000-\uffff]|[\ud800-\udbff][\udc00-\udfff])$/;
  23504. function preprocess$4(ast, options) {
  23505. ast = restoreUnescapedCharacter(ast, options);
  23506. ast = mergeContinuousTexts(ast);
  23507. ast = transformInlineCode(ast);
  23508. ast = transformIndentedCodeblockAndMarkItsParentList(ast, options);
  23509. ast = markAlignedList(ast, options);
  23510. ast = splitTextIntoSentences(ast, options);
  23511. ast = transformImportExport(ast);
  23512. ast = mergeContinuousImportExport(ast);
  23513. return ast;
  23514. }
  23515. function transformImportExport(ast) {
  23516. return mapAst$1(ast, function (node) {
  23517. if (node.type !== "import" && node.type !== "export") {
  23518. return node;
  23519. }
  23520. return Object.assign({}, node, {
  23521. type: "importExport"
  23522. });
  23523. });
  23524. }
  23525. function transformInlineCode(ast) {
  23526. return mapAst$1(ast, function (node) {
  23527. if (node.type !== "inlineCode") {
  23528. return node;
  23529. }
  23530. return Object.assign({}, node, {
  23531. value: node.value.replace(/\s+/g, " ")
  23532. });
  23533. });
  23534. }
  23535. function restoreUnescapedCharacter(ast, options) {
  23536. return mapAst$1(ast, function (node) {
  23537. return node.type !== "text" ? node : Object.assign({}, node, {
  23538. value: node.value !== "*" && node.value !== "_" && node.value !== "$" && // handle these cases in printer
  23539. isSingleCharRegex.test(node.value) && node.position.end.offset - node.position.start.offset !== node.value.length ? options.originalText.slice(node.position.start.offset, node.position.end.offset) : node.value
  23540. });
  23541. });
  23542. }
  23543. function mergeContinuousImportExport(ast) {
  23544. return mergeChildren(ast, function (prevNode, node) {
  23545. return prevNode.type === "importExport" && node.type === "importExport";
  23546. }, function (prevNode, node) {
  23547. return {
  23548. type: "importExport",
  23549. value: prevNode.value + "\n\n" + node.value,
  23550. position: {
  23551. start: prevNode.position.start,
  23552. end: node.position.end
  23553. }
  23554. };
  23555. });
  23556. }
  23557. function mergeChildren(ast, shouldMerge, mergeNode) {
  23558. return mapAst$1(ast, function (node) {
  23559. if (!node.children) {
  23560. return node;
  23561. }
  23562. var children = node.children.reduce(function (current, child) {
  23563. var lastChild = current[current.length - 1];
  23564. if (lastChild && shouldMerge(lastChild, child)) {
  23565. current.splice(-1, 1, mergeNode(lastChild, child));
  23566. } else {
  23567. current.push(child);
  23568. }
  23569. return current;
  23570. }, []);
  23571. return Object.assign({}, node, {
  23572. children: children
  23573. });
  23574. });
  23575. }
  23576. function mergeContinuousTexts(ast) {
  23577. return mergeChildren(ast, function (prevNode, node) {
  23578. return prevNode.type === "text" && node.type === "text";
  23579. }, function (prevNode, node) {
  23580. return {
  23581. type: "text",
  23582. value: prevNode.value + node.value,
  23583. position: {
  23584. start: prevNode.position.start,
  23585. end: node.position.end
  23586. }
  23587. };
  23588. });
  23589. }
  23590. function splitTextIntoSentences(ast, options) {
  23591. return mapAst$1(ast, function (node, index, _ref) {
  23592. var _ref2 = _slicedToArray(_ref, 1),
  23593. parentNode = _ref2[0];
  23594. if (node.type !== "text") {
  23595. return node;
  23596. }
  23597. var value = node.value;
  23598. if (parentNode.type === "paragraph") {
  23599. if (index === 0) {
  23600. value = value.trimLeft();
  23601. }
  23602. if (index === parentNode.children.length - 1) {
  23603. value = value.trimRight();
  23604. }
  23605. }
  23606. return {
  23607. type: "sentence",
  23608. position: node.position,
  23609. children: splitText$2(value, options)
  23610. };
  23611. });
  23612. }
  23613. function transformIndentedCodeblockAndMarkItsParentList(ast, options) {
  23614. return mapAst$1(ast, function (node, index, parentStack) {
  23615. if (node.type === "code") {
  23616. // the first char may point to `\n`, e.g. `\n\t\tbar`, just ignore it
  23617. var isIndented = /^\n?( {4,}|\t)/.test(options.originalText.slice(node.position.start.offset, node.position.end.offset));
  23618. node.isIndented = isIndented;
  23619. if (isIndented) {
  23620. for (var i = 0; i < parentStack.length; i++) {
  23621. var parent = parentStack[i]; // no need to check checked items
  23622. if (parent.hasIndentedCodeblock) {
  23623. break;
  23624. }
  23625. if (parent.type === "list") {
  23626. parent.hasIndentedCodeblock = true;
  23627. }
  23628. }
  23629. }
  23630. }
  23631. return node;
  23632. });
  23633. }
  23634. function markAlignedList(ast, options) {
  23635. return mapAst$1(ast, function (node, index, parentStack) {
  23636. if (node.type === "list" && node.children.length !== 0) {
  23637. // if one of its parents is not aligned, it's not possible to be aligned in sub-lists
  23638. for (var i = 0; i < parentStack.length; i++) {
  23639. var parent = parentStack[i];
  23640. if (parent.type === "list" && !parent.isAligned) {
  23641. node.isAligned = false;
  23642. return node;
  23643. }
  23644. }
  23645. node.isAligned = isAligned(node);
  23646. }
  23647. return node;
  23648. });
  23649. function getListItemStart(listItem) {
  23650. return listItem.children.length === 0 ? -1 : listItem.children[0].position.start.column - 1;
  23651. }
  23652. function isAligned(list) {
  23653. if (!list.ordered) {
  23654. /**
  23655. * - 123
  23656. * - 123
  23657. */
  23658. return true;
  23659. }
  23660. var _list$children = _slicedToArray(list.children, 2),
  23661. firstItem = _list$children[0],
  23662. secondItem = _list$children[1];
  23663. var firstInfo = getOrderedListItemInfo$2(firstItem, options.originalText);
  23664. if (firstInfo.leadingSpaces.length > 1) {
  23665. /**
  23666. * 1. 123
  23667. *
  23668. * 1. 123
  23669. * 1. 123
  23670. */
  23671. return true;
  23672. }
  23673. var firstStart = getListItemStart(firstItem);
  23674. if (firstStart === -1) {
  23675. /**
  23676. * 1.
  23677. *
  23678. * 1.
  23679. * 1.
  23680. */
  23681. return false;
  23682. }
  23683. if (list.children.length === 1) {
  23684. /**
  23685. * aligned:
  23686. *
  23687. * 11. 123
  23688. *
  23689. * not aligned:
  23690. *
  23691. * 1. 123
  23692. */
  23693. return firstStart % options.tabWidth === 0;
  23694. }
  23695. var secondStart = getListItemStart(secondItem);
  23696. if (firstStart !== secondStart) {
  23697. /**
  23698. * 11. 123
  23699. * 1. 123
  23700. *
  23701. * 1. 123
  23702. * 11. 123
  23703. */
  23704. return false;
  23705. }
  23706. if (firstStart % options.tabWidth === 0) {
  23707. /**
  23708. * 11. 123
  23709. * 12. 123
  23710. */
  23711. return true;
  23712. }
  23713. /**
  23714. * aligned:
  23715. *
  23716. * 11. 123
  23717. * 1. 123
  23718. *
  23719. * not aligned:
  23720. *
  23721. * 1. 123
  23722. * 2. 123
  23723. */
  23724. var secondInfo = getOrderedListItemInfo$2(secondItem, options.originalText);
  23725. return secondInfo.leadingSpaces.length > 1;
  23726. }
  23727. }
  23728. var preprocess_1$4 = preprocess$4;
  23729. var _require$$0$builders$8 = doc.builders;
  23730. var concat$15 = _require$$0$builders$8.concat;
  23731. var join$11 = _require$$0$builders$8.join;
  23732. var line$10 = _require$$0$builders$8.line;
  23733. var literalline$5 = _require$$0$builders$8.literalline;
  23734. var markAsRoot$3 = _require$$0$builders$8.markAsRoot;
  23735. var hardline$11 = _require$$0$builders$8.hardline;
  23736. var softline$7 = _require$$0$builders$8.softline;
  23737. var fill$5 = _require$$0$builders$8.fill;
  23738. var align$2 = _require$$0$builders$8.align;
  23739. var indent$9 = _require$$0$builders$8.indent;
  23740. var group$15 = _require$$0$builders$8.group;
  23741. var mapDoc$6 = doc.utils.mapDoc;
  23742. var printDocToString$2 = doc.printer.printDocToString;
  23743. var getFencedCodeBlockValue = utils$10.getFencedCodeBlockValue;
  23744. var getOrderedListItemInfo = utils$10.getOrderedListItemInfo;
  23745. var splitText = utils$10.splitText;
  23746. var punctuationPattern = utils$10.punctuationPattern;
  23747. var INLINE_NODE_TYPES = utils$10.INLINE_NODE_TYPES;
  23748. var INLINE_NODE_WRAPPER_TYPES = utils$10.INLINE_NODE_WRAPPER_TYPES;
  23749. var replaceEndOfLineWith$2 = util.replaceEndOfLineWith;
  23750. var TRAILING_HARDLINE_NODES = ["importExport"];
  23751. var SINGLE_LINE_NODE_TYPES = ["heading", "tableCell", "link"];
  23752. var SIBLING_NODE_TYPES = ["listItem", "definition", "footnoteDefinition"];
  23753. function genericPrint$5(path, options, print) {
  23754. var node = path.getValue();
  23755. if (shouldRemainTheSameContent(path)) {
  23756. return concat$15(splitText(options.originalText.slice(node.position.start.offset, node.position.end.offset), options).map(function (node) {
  23757. return node.type === "word" ? node.value : node.value === "" ? "" : printLine(path, node.value, options);
  23758. }));
  23759. }
  23760. switch (node.type) {
  23761. case "root":
  23762. if (node.children.length === 0) {
  23763. return "";
  23764. }
  23765. return concat$15([normalizeDoc(printRoot(path, options, print)), TRAILING_HARDLINE_NODES.indexOf(getLastDescendantNode(node).type) === -1 ? hardline$11 : ""]);
  23766. case "paragraph":
  23767. return printChildren$1(path, options, print, {
  23768. postprocessor: fill$5
  23769. });
  23770. case "sentence":
  23771. return printChildren$1(path, options, print);
  23772. case "word":
  23773. return node.value.replace(/[*$]/g, "\\$&") // escape all `*` and `$` (math)
  23774. .replace(new RegExp(["(^|".concat(punctuationPattern, ")(_+)"), "(_+)(".concat(punctuationPattern, "|$)")].join("|"), "g"), function (_, text1, underscore1, underscore2, text2) {
  23775. return (underscore1 ? "".concat(text1).concat(underscore1) : "".concat(underscore2).concat(text2)).replace(/_/g, "\\_");
  23776. });
  23777. // escape all `_` except concating with non-punctuation, e.g. `1_2_3` is not considered emphasis
  23778. case "whitespace":
  23779. {
  23780. var parentNode = path.getParentNode();
  23781. var index = parentNode.children.indexOf(node);
  23782. var nextNode = parentNode.children[index + 1];
  23783. var proseWrap = // leading char that may cause different syntax
  23784. nextNode && /^>|^([-+*]|#{1,6}|[0-9]+[.)])$/.test(nextNode.value) ? "never" : options.proseWrap;
  23785. return printLine(path, node.value, {
  23786. proseWrap: proseWrap
  23787. });
  23788. }
  23789. case "emphasis":
  23790. {
  23791. var _parentNode = path.getParentNode();
  23792. var _index = _parentNode.children.indexOf(node);
  23793. var prevNode = _parentNode.children[_index - 1];
  23794. var _nextNode = _parentNode.children[_index + 1];
  23795. var hasPrevOrNextWord = // `1*2*3` is considered emphais but `1_2_3` is not
  23796. 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;
  23797. var style = hasPrevOrNextWord || getAncestorNode$2(path, "emphasis") ? "*" : "_";
  23798. return concat$15([style, printChildren$1(path, options, print), style]);
  23799. }
  23800. case "strong":
  23801. return concat$15(["**", printChildren$1(path, options, print), "**"]);
  23802. case "delete":
  23803. return concat$15(["~~", printChildren$1(path, options, print), "~~"]);
  23804. case "inlineCode":
  23805. {
  23806. var backtickCount = util.getMaxContinuousCount(node.value, "`");
  23807. var _style = backtickCount === 1 ? "``" : "`";
  23808. var gap = backtickCount ? " " : "";
  23809. return concat$15([_style, gap, node.value, gap, _style]);
  23810. }
  23811. case "link":
  23812. switch (options.originalText[node.position.start.offset]) {
  23813. case "<":
  23814. {
  23815. var mailto = "mailto:";
  23816. var url = // <hello@example.com> is parsed as { url: "mailto:hello@example.com" }
  23817. node.url.startsWith(mailto) && options.originalText.slice(node.position.start.offset + 1, node.position.start.offset + 1 + mailto.length) !== mailto ? node.url.slice(mailto.length) : node.url;
  23818. return concat$15(["<", url, ">"]);
  23819. }
  23820. case "[":
  23821. return concat$15(["[", printChildren$1(path, options, print), "](", printUrl(node.url, ")"), printTitle(node.title, options), ")"]);
  23822. default:
  23823. return options.originalText.slice(node.position.start.offset, node.position.end.offset);
  23824. }
  23825. case "image":
  23826. return concat$15(["![", node.alt || "", "](", printUrl(node.url, ")"), printTitle(node.title, options), ")"]);
  23827. case "blockquote":
  23828. return concat$15(["> ", align$2("> ", printChildren$1(path, options, print))]);
  23829. case "heading":
  23830. return concat$15(["#".repeat(node.depth) + " ", printChildren$1(path, options, print)]);
  23831. case "code":
  23832. {
  23833. if (node.isIndented) {
  23834. // indented code block
  23835. var alignment = " ".repeat(4);
  23836. return align$2(alignment, concat$15([alignment, concat$15(replaceEndOfLineWith$2(node.value, hardline$11))]));
  23837. } // fenced code block
  23838. var styleUnit = options.__inJsTemplate ? "~" : "`";
  23839. var _style2 = styleUnit.repeat(Math.max(3, util.getMaxContinuousCount(node.value, styleUnit) + 1));
  23840. return concat$15([_style2, node.lang || "", hardline$11, concat$15(replaceEndOfLineWith$2(getFencedCodeBlockValue(node, options.originalText), hardline$11)), hardline$11, _style2]);
  23841. }
  23842. case "yaml":
  23843. case "toml":
  23844. return options.originalText.slice(node.position.start.offset, node.position.end.offset);
  23845. case "html":
  23846. {
  23847. var _parentNode2 = path.getParentNode();
  23848. var value = _parentNode2.type === "root" && util.getLast(_parentNode2.children) === node ? node.value.trimRight() : node.value;
  23849. var isHtmlComment = /^<!--[\s\S]*-->$/.test(value);
  23850. return concat$15(replaceEndOfLineWith$2(value, isHtmlComment ? hardline$11 : markAsRoot$3(literalline$5)));
  23851. }
  23852. case "list":
  23853. {
  23854. var nthSiblingIndex = getNthListSiblingIndex(node, path.getParentNode());
  23855. var isGitDiffFriendlyOrderedList = node.ordered && node.children.length > 1 && +getOrderedListItemInfo(node.children[1], options.originalText).numberText === 1;
  23856. return printChildren$1(path, options, print, {
  23857. processor: function processor(childPath, index) {
  23858. var prefix = getPrefix();
  23859. return concat$15([prefix, align$2(" ".repeat(prefix.length), printListItem(childPath, options, print, prefix))]);
  23860. function getPrefix() {
  23861. var rawPrefix = node.ordered ? (index === 0 ? node.start : isGitDiffFriendlyOrderedList ? 1 : node.start + index) + (nthSiblingIndex % 2 === 0 ? ". " : ") ") : nthSiblingIndex % 2 === 0 ? "- " : "* ";
  23862. return node.isAligned ||
  23863. /* workaround for https://github.com/remarkjs/remark/issues/315 */
  23864. node.hasIndentedCodeblock ? alignListPrefix(rawPrefix, options) : rawPrefix;
  23865. }
  23866. }
  23867. });
  23868. }
  23869. case "thematicBreak":
  23870. {
  23871. var counter = getAncestorCounter$1(path, "list");
  23872. if (counter === -1) {
  23873. return "---";
  23874. }
  23875. var _nthSiblingIndex = getNthListSiblingIndex(path.getParentNode(counter), path.getParentNode(counter + 1));
  23876. return _nthSiblingIndex % 2 === 0 ? "***" : "---";
  23877. }
  23878. case "linkReference":
  23879. return concat$15(["[", printChildren$1(path, options, print), "]", node.referenceType === "full" ? concat$15(["[", node.identifier, "]"]) : node.referenceType === "collapsed" ? "[]" : ""]);
  23880. case "imageReference":
  23881. switch (node.referenceType) {
  23882. case "full":
  23883. return concat$15(["![", node.alt || "", "][", node.identifier, "]"]);
  23884. default:
  23885. return concat$15(["![", node.alt, "]", node.referenceType === "collapsed" ? "[]" : ""]);
  23886. }
  23887. case "definition":
  23888. {
  23889. var lineOrSpace = options.proseWrap === "always" ? line$10 : " ";
  23890. return group$15(concat$15([concat$15(["[", node.identifier, "]:"]), indent$9(concat$15([lineOrSpace, printUrl(node.url), node.title === null ? "" : concat$15([lineOrSpace, printTitle(node.title, options, false)])]))]));
  23891. }
  23892. case "footnote":
  23893. return concat$15(["[^", printChildren$1(path, options, print), "]"]);
  23894. case "footnoteReference":
  23895. return concat$15(["[^", node.identifier, "]"]);
  23896. case "footnoteDefinition":
  23897. {
  23898. var _nextNode2 = path.getParentNode().children[path.getName() + 1];
  23899. var shouldInlineFootnote = node.children.length === 1 && node.children[0].type === "paragraph" && (options.proseWrap === "never" || options.proseWrap === "preserve" && node.children[0].position.start.line === node.children[0].position.end.line);
  23900. return concat$15(["[^", node.identifier, "]: ", shouldInlineFootnote ? printChildren$1(path, options, print) : group$15(concat$15([align$2(" ".repeat(options.tabWidth), printChildren$1(path, options, print, {
  23901. processor: function processor(childPath, index) {
  23902. return index === 0 ? group$15(concat$15([softline$7, softline$7, childPath.call(print)])) : childPath.call(print);
  23903. }
  23904. })), _nextNode2 && _nextNode2.type === "footnoteDefinition" ? softline$7 : ""]))]);
  23905. }
  23906. case "table":
  23907. return printTable(path, options, print);
  23908. case "tableCell":
  23909. return printChildren$1(path, options, print);
  23910. case "break":
  23911. return /\s/.test(options.originalText[node.position.start.offset]) ? concat$15([" ", markAsRoot$3(literalline$5)]) : concat$15(["\\", hardline$11]);
  23912. case "liquidNode":
  23913. return concat$15(replaceEndOfLineWith$2(node.value, hardline$11));
  23914. // MDX
  23915. case "importExport":
  23916. case "jsx":
  23917. return node.value;
  23918. // fallback to the original text if multiparser failed
  23919. case "math":
  23920. return concat$15(["$$", hardline$11, node.value ? concat$15([concat$15(replaceEndOfLineWith$2(node.value, hardline$11)), hardline$11]) : "", "$$"]);
  23921. case "inlineMath":
  23922. {
  23923. // remark-math trims content but we don't want to remove whitespaces
  23924. // since it's very possible that it's recognized as math accidentally
  23925. return options.originalText.slice(options.locStart(node), options.locEnd(node));
  23926. }
  23927. case "tableRow": // handled in "table"
  23928. case "listItem": // handled in "list"
  23929. default:
  23930. throw new Error("Unknown markdown type ".concat(JSON.stringify(node.type)));
  23931. }
  23932. }
  23933. function printListItem(path, options, print, listPrefix) {
  23934. var node = path.getValue();
  23935. var prefix = node.checked === null ? "" : node.checked ? "[x] " : "[ ] ";
  23936. return concat$15([prefix, printChildren$1(path, options, print, {
  23937. processor: function processor(childPath, index) {
  23938. if (index === 0 && childPath.getValue().type !== "list") {
  23939. return align$2(" ".repeat(prefix.length), childPath.call(print));
  23940. }
  23941. var alignment = " ".repeat(clamp(options.tabWidth - listPrefix.length, 0, 3) // 4+ will cause indented code block
  23942. );
  23943. return concat$15([alignment, align$2(alignment, childPath.call(print))]);
  23944. }
  23945. })]);
  23946. }
  23947. function alignListPrefix(prefix, options) {
  23948. var additionalSpaces = getAdditionalSpaces();
  23949. return prefix + " ".repeat(additionalSpaces >= 4 ? 0 : additionalSpaces // 4+ will cause indented code block
  23950. );
  23951. function getAdditionalSpaces() {
  23952. var restSpaces = prefix.length % options.tabWidth;
  23953. return restSpaces === 0 ? 0 : options.tabWidth - restSpaces;
  23954. }
  23955. }
  23956. function getNthListSiblingIndex(node, parentNode) {
  23957. return getNthSiblingIndex(node, parentNode, function (siblingNode) {
  23958. return siblingNode.ordered === node.ordered;
  23959. });
  23960. }
  23961. function getNthSiblingIndex(node, parentNode, condition) {
  23962. condition = condition || function () {
  23963. return true;
  23964. };
  23965. var index = -1;
  23966. var _iteratorNormalCompletion = true;
  23967. var _didIteratorError = false;
  23968. var _iteratorError = undefined;
  23969. try {
  23970. for (var _iterator = parentNode.children[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  23971. var childNode = _step.value;
  23972. if (childNode.type === node.type && condition(childNode)) {
  23973. index++;
  23974. } else {
  23975. index = -1;
  23976. }
  23977. if (childNode === node) {
  23978. return index;
  23979. }
  23980. }
  23981. } catch (err) {
  23982. _didIteratorError = true;
  23983. _iteratorError = err;
  23984. } finally {
  23985. try {
  23986. if (!_iteratorNormalCompletion && _iterator.return != null) {
  23987. _iterator.return();
  23988. }
  23989. } finally {
  23990. if (_didIteratorError) {
  23991. throw _iteratorError;
  23992. }
  23993. }
  23994. }
  23995. }
  23996. function getAncestorCounter$1(path, typeOrTypes) {
  23997. var types = [].concat(typeOrTypes);
  23998. var counter = -1;
  23999. var ancestorNode;
  24000. while (ancestorNode = path.getParentNode(++counter)) {
  24001. if (types.indexOf(ancestorNode.type) !== -1) {
  24002. return counter;
  24003. }
  24004. }
  24005. return -1;
  24006. }
  24007. function getAncestorNode$2(path, typeOrTypes) {
  24008. var counter = getAncestorCounter$1(path, typeOrTypes);
  24009. return counter === -1 ? null : path.getParentNode(counter);
  24010. }
  24011. function printLine(path, value, options) {
  24012. if (options.proseWrap === "preserve" && value === "\n") {
  24013. return hardline$11;
  24014. }
  24015. var isBreakable = options.proseWrap === "always" && !getAncestorNode$2(path, SINGLE_LINE_NODE_TYPES);
  24016. return value !== "" ? isBreakable ? line$10 : " " : isBreakable ? softline$7 : "";
  24017. }
  24018. function printTable(path, options, print) {
  24019. var node = path.getValue();
  24020. var contents = []; // { [rowIndex: number]: { [columnIndex: number]: string } }
  24021. path.map(function (rowPath) {
  24022. var rowContents = [];
  24023. rowPath.map(function (cellPath) {
  24024. rowContents.push(printDocToString$2(cellPath.call(print), options).formatted);
  24025. }, "children");
  24026. contents.push(rowContents);
  24027. }, "children");
  24028. var columnMaxWidths = contents.reduce(function (currentWidths, rowContents) {
  24029. return currentWidths.map(function (width, columnIndex) {
  24030. return Math.max(width, util.getStringWidth(rowContents[columnIndex]));
  24031. });
  24032. }, contents[0].map(function () {
  24033. return 3;
  24034. }) // minimum width = 3 (---, :--, :-:, --:)
  24035. );
  24036. return join$11(hardline$11, [printRow(contents[0]), printSeparator(), join$11(hardline$11, contents.slice(1).map(printRow))]);
  24037. function printSeparator() {
  24038. return concat$15(["| ", join$11(" | ", columnMaxWidths.map(function (width, index) {
  24039. switch (node.align[index]) {
  24040. case "left":
  24041. return ":" + "-".repeat(width - 1);
  24042. case "right":
  24043. return "-".repeat(width - 1) + ":";
  24044. case "center":
  24045. return ":" + "-".repeat(width - 2) + ":";
  24046. default:
  24047. return "-".repeat(width);
  24048. }
  24049. })), " |"]);
  24050. }
  24051. function printRow(rowContents) {
  24052. return concat$15(["| ", join$11(" | ", rowContents.map(function (rowContent, columnIndex) {
  24053. switch (node.align[columnIndex]) {
  24054. case "right":
  24055. return alignRight(rowContent, columnMaxWidths[columnIndex]);
  24056. case "center":
  24057. return alignCenter(rowContent, columnMaxWidths[columnIndex]);
  24058. default:
  24059. return alignLeft(rowContent, columnMaxWidths[columnIndex]);
  24060. }
  24061. })), " |"]);
  24062. }
  24063. function alignLeft(text, width) {
  24064. return concat$15([text, " ".repeat(width - util.getStringWidth(text))]);
  24065. }
  24066. function alignRight(text, width) {
  24067. return concat$15([" ".repeat(width - util.getStringWidth(text)), text]);
  24068. }
  24069. function alignCenter(text, width) {
  24070. var spaces = width - util.getStringWidth(text);
  24071. var left = Math.floor(spaces / 2);
  24072. var right = spaces - left;
  24073. return concat$15([" ".repeat(left), text, " ".repeat(right)]);
  24074. }
  24075. }
  24076. function printRoot(path, options, print) {
  24077. /** @typedef {{ index: number, offset: number }} IgnorePosition */
  24078. /** @type {Array<{start: IgnorePosition, end: IgnorePosition}>} */
  24079. var ignoreRanges = [];
  24080. /** @type {IgnorePosition | null} */
  24081. var ignoreStart = null;
  24082. var children = path.getValue().children;
  24083. children.forEach(function (childNode, index) {
  24084. switch (isPrettierIgnore$1(childNode)) {
  24085. case "start":
  24086. if (ignoreStart === null) {
  24087. ignoreStart = {
  24088. index: index,
  24089. offset: childNode.position.end.offset
  24090. };
  24091. }
  24092. break;
  24093. case "end":
  24094. if (ignoreStart !== null) {
  24095. ignoreRanges.push({
  24096. start: ignoreStart,
  24097. end: {
  24098. index: index,
  24099. offset: childNode.position.start.offset
  24100. }
  24101. });
  24102. ignoreStart = null;
  24103. }
  24104. break;
  24105. default:
  24106. // do nothing
  24107. break;
  24108. }
  24109. });
  24110. return printChildren$1(path, options, print, {
  24111. processor: function processor(childPath, index) {
  24112. if (ignoreRanges.length !== 0) {
  24113. var ignoreRange = ignoreRanges[0];
  24114. if (index === ignoreRange.start.index) {
  24115. return concat$15([children[ignoreRange.start.index].value, options.originalText.slice(ignoreRange.start.offset, ignoreRange.end.offset), children[ignoreRange.end.index].value]);
  24116. }
  24117. if (ignoreRange.start.index < index && index < ignoreRange.end.index) {
  24118. return false;
  24119. }
  24120. if (index === ignoreRange.end.index) {
  24121. ignoreRanges.shift();
  24122. return false;
  24123. }
  24124. }
  24125. return childPath.call(print);
  24126. }
  24127. });
  24128. }
  24129. function printChildren$1(path, options, print, events) {
  24130. events = events || {};
  24131. var postprocessor = events.postprocessor || concat$15;
  24132. var processor = events.processor || function (childPath) {
  24133. return childPath.call(print);
  24134. };
  24135. var node = path.getValue();
  24136. var parts = [];
  24137. var lastChildNode;
  24138. path.map(function (childPath, index) {
  24139. var childNode = childPath.getValue();
  24140. var result = processor(childPath, index);
  24141. if (result !== false) {
  24142. var data = {
  24143. parts: parts,
  24144. prevNode: lastChildNode,
  24145. parentNode: node,
  24146. options: options
  24147. };
  24148. if (!shouldNotPrePrintHardline(childNode, data)) {
  24149. parts.push(hardline$11);
  24150. if (lastChildNode && TRAILING_HARDLINE_NODES.indexOf(lastChildNode.type) !== -1) {
  24151. if (shouldPrePrintTripleHardline(childNode, data)) {
  24152. parts.push(hardline$11);
  24153. }
  24154. } else {
  24155. if (shouldPrePrintDoubleHardline(childNode, data) || shouldPrePrintTripleHardline(childNode, data)) {
  24156. parts.push(hardline$11);
  24157. }
  24158. if (shouldPrePrintTripleHardline(childNode, data)) {
  24159. parts.push(hardline$11);
  24160. }
  24161. }
  24162. }
  24163. parts.push(result);
  24164. lastChildNode = childNode;
  24165. }
  24166. }, "children");
  24167. return postprocessor(parts);
  24168. }
  24169. function getLastDescendantNode(node) {
  24170. var current = node;
  24171. while (current.children && current.children.length !== 0) {
  24172. current = current.children[current.children.length - 1];
  24173. }
  24174. return current;
  24175. }
  24176. /** @return {false | 'next' | 'start' | 'end'} */
  24177. function isPrettierIgnore$1(node) {
  24178. if (node.type !== "html") {
  24179. return false;
  24180. }
  24181. var match = node.value.match(/^<!--\s*prettier-ignore(?:-(start|end))?\s*-->$/);
  24182. return match === null ? false : match[1] ? match[1] : "next";
  24183. }
  24184. function shouldNotPrePrintHardline(node, data) {
  24185. var isFirstNode = data.parts.length === 0;
  24186. var isInlineNode = INLINE_NODE_TYPES.indexOf(node.type) !== -1;
  24187. var isInlineHTML = node.type === "html" && INLINE_NODE_WRAPPER_TYPES.indexOf(data.parentNode.type) !== -1;
  24188. return isFirstNode || isInlineNode || isInlineHTML;
  24189. }
  24190. function shouldPrePrintDoubleHardline(node, data) {
  24191. var isSequence = (data.prevNode && data.prevNode.type) === node.type;
  24192. var isSiblingNode = isSequence && SIBLING_NODE_TYPES.indexOf(node.type) !== -1;
  24193. var isInTightListItem = data.parentNode.type === "listItem" && !data.parentNode.loose;
  24194. var isPrevNodeLooseListItem = data.prevNode && data.prevNode.type === "listItem" && data.prevNode.loose;
  24195. var isPrevNodePrettierIgnore = isPrettierIgnore$1(data.prevNode) === "next";
  24196. var isBlockHtmlWithoutBlankLineBetweenPrevHtml = node.type === "html" && data.prevNode && data.prevNode.type === "html" && data.prevNode.position.end.line + 1 === node.position.start.line;
  24197. return isPrevNodeLooseListItem || !(isSiblingNode || isInTightListItem || isPrevNodePrettierIgnore || isBlockHtmlWithoutBlankLineBetweenPrevHtml);
  24198. }
  24199. function shouldPrePrintTripleHardline(node, data) {
  24200. var isPrevNodeList = data.prevNode && data.prevNode.type === "list";
  24201. var isIndentedCode = node.type === "code" && node.isIndented;
  24202. return isPrevNodeList && isIndentedCode;
  24203. }
  24204. function shouldRemainTheSameContent(path) {
  24205. var ancestorNode = getAncestorNode$2(path, ["linkReference", "imageReference"]);
  24206. return ancestorNode && (ancestorNode.type !== "linkReference" || ancestorNode.referenceType !== "full");
  24207. }
  24208. function normalizeDoc(doc$$2) {
  24209. return mapDoc$6(doc$$2, function (currentDoc) {
  24210. if (!currentDoc.parts) {
  24211. return currentDoc;
  24212. }
  24213. if (currentDoc.type === "concat" && currentDoc.parts.length === 1) {
  24214. return currentDoc.parts[0];
  24215. }
  24216. var parts = [];
  24217. currentDoc.parts.forEach(function (part) {
  24218. if (part.type === "concat") {
  24219. parts.push.apply(parts, part.parts);
  24220. } else if (part !== "") {
  24221. parts.push(part);
  24222. }
  24223. });
  24224. return Object.assign({}, currentDoc, {
  24225. parts: normalizeParts$2(parts)
  24226. });
  24227. });
  24228. }
  24229. function printUrl(url, dangerousCharOrChars) {
  24230. var dangerousChars = [" "].concat(dangerousCharOrChars || []);
  24231. return new RegExp(dangerousChars.map(function (x) {
  24232. return "\\".concat(x);
  24233. }).join("|")).test(url) ? "<".concat(url, ">") : url;
  24234. }
  24235. function printTitle(title, options, printSpace) {
  24236. if (printSpace == null) {
  24237. printSpace = true;
  24238. }
  24239. if (!title) {
  24240. return "";
  24241. }
  24242. if (printSpace) {
  24243. return " " + printTitle(title, options, false);
  24244. }
  24245. if (title.includes('"') && title.includes("'") && !title.includes(")")) {
  24246. return "(".concat(title, ")"); // avoid escaped quotes
  24247. } // faster than using RegExps: https://jsperf.com/performance-of-match-vs-split
  24248. var singleCount = title.split("'").length - 1;
  24249. var doubleCount = title.split('"').length - 1;
  24250. var quote = singleCount > doubleCount ? '"' : doubleCount > singleCount ? "'" : options.singleQuote ? "'" : '"';
  24251. title = title.replace(new RegExp("(".concat(quote, ")"), "g"), "\\$1");
  24252. return "".concat(quote).concat(title).concat(quote);
  24253. }
  24254. function normalizeParts$2(parts) {
  24255. return parts.reduce(function (current, part) {
  24256. var lastPart = util.getLast(current);
  24257. if (typeof lastPart === "string" && typeof part === "string") {
  24258. current.splice(-1, 1, lastPart + part);
  24259. } else {
  24260. current.push(part);
  24261. }
  24262. return current;
  24263. }, []);
  24264. }
  24265. function clamp(value, min, max) {
  24266. return value < min ? min : value > max ? max : value;
  24267. }
  24268. function clean$10(ast, newObj, parent) {
  24269. delete newObj.position;
  24270. delete newObj.raw; // front-matter
  24271. // for codeblock
  24272. if (ast.type === "code" || ast.type === "yaml" || ast.type === "import" || ast.type === "export" || ast.type === "jsx") {
  24273. delete newObj.value;
  24274. }
  24275. if (ast.type === "list") {
  24276. delete newObj.isAligned;
  24277. } // texts can be splitted or merged
  24278. if (ast.type === "text") {
  24279. return null;
  24280. }
  24281. if (ast.type === "inlineCode") {
  24282. newObj.value = ast.value.replace(/[ \t\n]+/g, " ");
  24283. } // for insert pragma
  24284. if (parent && parent.type === "root" && parent.children.length > 0 && (parent.children[0] === ast || (parent.children[0].type === "yaml" || parent.children[0].type === "toml") && parent.children[1] === ast) && ast.type === "html" && pragma$8.startWithPragma(ast.value)) {
  24285. return null;
  24286. }
  24287. }
  24288. function hasPrettierIgnore$3(path) {
  24289. var index = +path.getName();
  24290. if (index === 0) {
  24291. return false;
  24292. }
  24293. var prevNode = path.getParentNode().children[index - 1];
  24294. return isPrettierIgnore$1(prevNode) === "next";
  24295. }
  24296. var printerMarkdown = {
  24297. preprocess: preprocess_1$4,
  24298. print: genericPrint$5,
  24299. embed: embed_1$4,
  24300. massageAstNode: clean$10,
  24301. hasPrettierIgnore: hasPrettierIgnore$3,
  24302. insertPragma: pragma$8.insertPragma
  24303. };
  24304. var options$15 = {
  24305. proseWrap: commonOptions.proseWrap,
  24306. singleQuote: commonOptions.singleQuote
  24307. };
  24308. var name$15 = "Markdown";
  24309. var type$14 = "prose";
  24310. var aliases$5 = ["pandoc"];
  24311. var aceMode$14 = "markdown";
  24312. var codemirrorMode$10 = "gfm";
  24313. var codemirrorMimeType$10 = "text/x-gfm";
  24314. var wrap = true;
  24315. var extensions$14 = [".md", ".markdown", ".mdown", ".mdwn", ".mkd", ".mkdn", ".mkdown", ".ronn", ".workbook"];
  24316. var tmScope$14 = "source.gfm";
  24317. var languageId$14 = 222;
  24318. var markdown = {
  24319. name: name$15,
  24320. type: type$14,
  24321. aliases: aliases$5,
  24322. aceMode: aceMode$14,
  24323. codemirrorMode: codemirrorMode$10,
  24324. codemirrorMimeType: codemirrorMimeType$10,
  24325. wrap: wrap,
  24326. extensions: extensions$14,
  24327. tmScope: tmScope$14,
  24328. languageId: languageId$14
  24329. };
  24330. var markdown$1 = Object.freeze({
  24331. name: name$15,
  24332. type: type$14,
  24333. aliases: aliases$5,
  24334. aceMode: aceMode$14,
  24335. codemirrorMode: codemirrorMode$10,
  24336. codemirrorMimeType: codemirrorMimeType$10,
  24337. wrap: wrap,
  24338. extensions: extensions$14,
  24339. tmScope: tmScope$14,
  24340. languageId: languageId$14,
  24341. default: markdown
  24342. });
  24343. var require$$0$27 = ( markdown$1 && markdown ) || markdown$1;
  24344. var languages$5 = [createLanguage(require$$0$27, {
  24345. override: {
  24346. since: "1.8.0",
  24347. parsers: ["remark"],
  24348. vscodeLanguageIds: ["markdown"]
  24349. },
  24350. extend: {
  24351. filenames: ["README"]
  24352. }
  24353. }), createLanguage({
  24354. name: "MDX",
  24355. extensions: [".mdx"]
  24356. }, // TODO: use linguist data
  24357. {
  24358. override: {
  24359. since: "1.15.0",
  24360. parsers: ["mdx"],
  24361. vscodeLanguageIds: ["mdx"]
  24362. }
  24363. })];
  24364. var printers$5 = {
  24365. mdast: printerMarkdown
  24366. };
  24367. var languageMarkdown = {
  24368. languages: languages$5,
  24369. options: options$15,
  24370. printers: printers$5
  24371. };
  24372. function isPragma$1(text) {
  24373. return /^\s*@(prettier|format)\s*$/.test(text);
  24374. }
  24375. function hasPragma$4(text) {
  24376. return /^\s*#[^\n\S]*@(prettier|format)\s*?(\n|$)/.test(text);
  24377. }
  24378. function insertPragma$9(text) {
  24379. return "# @format\n\n".concat(text);
  24380. }
  24381. var pragma$11 = {
  24382. isPragma: isPragma$1,
  24383. hasPragma: hasPragma$4,
  24384. insertPragma: insertPragma$9
  24385. };
  24386. var getLast$7 = util.getLast;
  24387. function getAncestorCount$1(path, filter) {
  24388. var counter = 0;
  24389. var pathStackLength = path.stack.length - 1;
  24390. for (var i = 0; i < pathStackLength; i++) {
  24391. var value = path.stack[i];
  24392. if (isNode$1(value) && filter(value)) {
  24393. counter++;
  24394. }
  24395. }
  24396. return counter;
  24397. }
  24398. /**
  24399. * @param {any} value
  24400. * @param {string[]=} types
  24401. */
  24402. function isNode$1(value, types) {
  24403. return value && typeof value.type === "string" && (!types || types.indexOf(value.type) !== -1);
  24404. }
  24405. function mapNode$1(node, callback, parent) {
  24406. return callback("children" in node ? Object.assign({}, node, {
  24407. children: node.children.map(function (childNode) {
  24408. return mapNode$1(childNode, callback, node);
  24409. })
  24410. }) : node, parent);
  24411. }
  24412. function defineShortcut$1(x, key, getter) {
  24413. Object.defineProperty(x, key, {
  24414. get: getter,
  24415. enumerable: false
  24416. });
  24417. }
  24418. function isNextLineEmpty$6(node, text) {
  24419. var newlineCount = 0;
  24420. var textLength = text.length;
  24421. for (var i = node.position.end.offset - 1; i < textLength; i++) {
  24422. var char = text[i];
  24423. if (char === "\n") {
  24424. newlineCount++;
  24425. }
  24426. if (newlineCount === 1 && /\S/.test(char)) {
  24427. return false;
  24428. }
  24429. if (newlineCount === 2) {
  24430. return true;
  24431. }
  24432. }
  24433. return false;
  24434. }
  24435. function isLastDescendantNode$1(path) {
  24436. var node = path.getValue();
  24437. switch (node.type) {
  24438. case "tag":
  24439. case "anchor":
  24440. case "comment":
  24441. return false;
  24442. }
  24443. var pathStackLength = path.stack.length;
  24444. for (var i = 1; i < pathStackLength; i++) {
  24445. var item = path.stack[i];
  24446. var parentItem = path.stack[i - 1];
  24447. if (Array.isArray(parentItem) && typeof item === "number" && item !== parentItem.length - 1) {
  24448. return false;
  24449. }
  24450. }
  24451. return true;
  24452. }
  24453. function getLastDescendantNode$2(node) {
  24454. return "children" in node && node.children.length !== 0 ? getLastDescendantNode$2(getLast$7(node.children)) : node;
  24455. }
  24456. function isPrettierIgnore$2(comment) {
  24457. return comment.value.trim() === "prettier-ignore";
  24458. }
  24459. function hasPrettierIgnore$5(path) {
  24460. var node = path.getValue();
  24461. if (node.type === "documentBody") {
  24462. var document = path.getParentNode();
  24463. return hasEndComments$1(document.head) && isPrettierIgnore$2(getLast$7(document.head.endComments));
  24464. }
  24465. return hasLeadingComments$1(node) && isPrettierIgnore$2(getLast$7(node.leadingComments));
  24466. }
  24467. function isEmptyNode$1(node) {
  24468. return (!node.children || node.children.length === 0) && !hasComments(node);
  24469. }
  24470. function hasComments(node) {
  24471. return hasLeadingComments$1(node) || hasMiddleComments$1(node) || hasIndicatorComment$1(node) || hasTrailingComment$2(node) || hasEndComments$1(node);
  24472. }
  24473. function hasLeadingComments$1(node) {
  24474. return node && node.leadingComments && node.leadingComments.length !== 0;
  24475. }
  24476. function hasMiddleComments$1(node) {
  24477. return node && node.middleComments && node.middleComments.length !== 0;
  24478. }
  24479. function hasIndicatorComment$1(node) {
  24480. return node && node.indicatorComment;
  24481. }
  24482. function hasTrailingComment$2(node) {
  24483. return node && node.trailingComment;
  24484. }
  24485. function hasEndComments$1(node) {
  24486. return node && node.endComments && node.endComments.length !== 0;
  24487. }
  24488. /**
  24489. * " a b c d e f " -> [" a b", "c d", "e f "]
  24490. */
  24491. function splitWithSingleSpace(text) {
  24492. var parts = [];
  24493. var lastPart = undefined;
  24494. var _iteratorNormalCompletion = true;
  24495. var _didIteratorError = false;
  24496. var _iteratorError = undefined;
  24497. try {
  24498. for (var _iterator = text.split(/( +)/g)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  24499. var part = _step.value;
  24500. if (part !== " ") {
  24501. if (lastPart === " ") {
  24502. parts.push(part);
  24503. } else {
  24504. parts.push((parts.pop() || "") + part);
  24505. }
  24506. } else if (lastPart === undefined) {
  24507. parts.unshift("");
  24508. }
  24509. lastPart = part;
  24510. }
  24511. } catch (err) {
  24512. _didIteratorError = true;
  24513. _iteratorError = err;
  24514. } finally {
  24515. try {
  24516. if (!_iteratorNormalCompletion && _iterator.return != null) {
  24517. _iterator.return();
  24518. }
  24519. } finally {
  24520. if (_didIteratorError) {
  24521. throw _iteratorError;
  24522. }
  24523. }
  24524. }
  24525. if (lastPart === " ") {
  24526. parts.push((parts.pop() || "") + " ");
  24527. }
  24528. if (parts[0] === "") {
  24529. parts.shift();
  24530. parts.unshift(" " + (parts.shift() || ""));
  24531. }
  24532. return parts;
  24533. }
  24534. function getFlowScalarLineContents$1(nodeType, content, options) {
  24535. var rawLineContents = content.split("\n").map(function (lineContent, index, lineContents) {
  24536. return index === 0 && index === lineContents.length - 1 ? lineContent : index !== 0 && index !== lineContents.length - 1 ? lineContent.trim() : index === 0 ? lineContent.trimRight() : lineContent.trimLeft();
  24537. });
  24538. if (options.proseWrap === "preserve") {
  24539. return rawLineContents.map(function (lineContent) {
  24540. return lineContent.length === 0 ? [] : [lineContent];
  24541. });
  24542. }
  24543. return rawLineContents.map(function (lineContent) {
  24544. return lineContent.length === 0 ? [] : splitWithSingleSpace(lineContent);
  24545. }).reduce(function (reduced, lineContentWords, index) {
  24546. return index !== 0 && rawLineContents[index - 1].length !== 0 && lineContentWords.length !== 0 && !( // trailing backslash in quoteDouble should be preserved
  24547. nodeType === "quoteDouble" && getLast$7(getLast$7(reduced)).endsWith("\\")) ? reduced.concat([reduced.pop().concat(lineContentWords)]) : reduced.concat([lineContentWords]);
  24548. }, []).map(function (lineContentWords) {
  24549. return options.proseWrap === "never" ? [lineContentWords.join(" ")] : lineContentWords;
  24550. });
  24551. }
  24552. function getBlockValueLineContents$1(node, _ref) {
  24553. var parentIndent = _ref.parentIndent,
  24554. isLastDescendant = _ref.isLastDescendant,
  24555. options = _ref.options;
  24556. var content = node.position.start.line === node.position.end.line ? "" : options.originalText.slice(node.position.start.offset, node.position.end.offset) // exclude open line `>` or `|`
  24557. .match(/^[^\n]*?\n([\s\S]*)$/)[1];
  24558. var leadingSpaceCount = node.indent === null ? function (match) {
  24559. return match ? match[1].length : Infinity;
  24560. }(content.match(/^( *)\S/m)) : node.indent - 1 + parentIndent;
  24561. var rawLineContents = content.split("\n").map(function (lineContent) {
  24562. return lineContent.slice(leadingSpaceCount);
  24563. });
  24564. if (options.proseWrap === "preserve" || node.type === "blockLiteral") {
  24565. return removeUnnecessaryTrailingNewlines(rawLineContents.map(function (lineContent) {
  24566. return lineContent.length === 0 ? [] : [lineContent];
  24567. }));
  24568. }
  24569. return removeUnnecessaryTrailingNewlines(rawLineContents.map(function (lineContent) {
  24570. return lineContent.length === 0 ? [] : splitWithSingleSpace(lineContent);
  24571. }).reduce(function (reduced, lineContentWords, index) {
  24572. return index !== 0 && rawLineContents[index - 1].length !== 0 && lineContentWords.length !== 0 && !/^\s/.test(lineContentWords[0]) && !/^\s|\s$/.test(getLast$7(reduced)) ? reduced.concat([reduced.pop().concat(lineContentWords)]) : reduced.concat([lineContentWords]);
  24573. }, []).map(function (lineContentWords) {
  24574. return lineContentWords.reduce(function (reduced, word) {
  24575. return (// disallow trailing spaces
  24576. reduced.length !== 0 && /\s$/.test(getLast$7(reduced)) ? reduced.concat(reduced.pop() + " " + word) : reduced.concat(word)
  24577. );
  24578. }, []);
  24579. }).map(function (lineContentWords) {
  24580. return options.proseWrap === "never" ? [lineContentWords.join(" ")] : lineContentWords;
  24581. }));
  24582. function removeUnnecessaryTrailingNewlines(lineContents) {
  24583. if (node.chomping === "keep") {
  24584. return getLast$7(lineContents).length === 0 ? lineContents.slice(0, -1) : lineContents;
  24585. }
  24586. var trailingNewlineCount = 0;
  24587. for (var i = lineContents.length - 1; i >= 0; i--) {
  24588. if (lineContents[i].length === 0) {
  24589. trailingNewlineCount++;
  24590. } else {
  24591. break;
  24592. }
  24593. }
  24594. return trailingNewlineCount === 0 ? lineContents : trailingNewlineCount >= 2 && !isLastDescendant ? // next empty line
  24595. lineContents.slice(0, -(trailingNewlineCount - 1)) : lineContents.slice(0, -trailingNewlineCount);
  24596. }
  24597. }
  24598. var utils$12 = {
  24599. getLast: getLast$7,
  24600. getAncestorCount: getAncestorCount$1,
  24601. isNode: isNode$1,
  24602. isEmptyNode: isEmptyNode$1,
  24603. mapNode: mapNode$1,
  24604. defineShortcut: defineShortcut$1,
  24605. isNextLineEmpty: isNextLineEmpty$6,
  24606. isLastDescendantNode: isLastDescendantNode$1,
  24607. getBlockValueLineContents: getBlockValueLineContents$1,
  24608. getFlowScalarLineContents: getFlowScalarLineContents$1,
  24609. getLastDescendantNode: getLastDescendantNode$2,
  24610. hasPrettierIgnore: hasPrettierIgnore$5,
  24611. hasLeadingComments: hasLeadingComments$1,
  24612. hasMiddleComments: hasMiddleComments$1,
  24613. hasIndicatorComment: hasIndicatorComment$1,
  24614. hasTrailingComment: hasTrailingComment$2,
  24615. hasEndComments: hasEndComments$1
  24616. };
  24617. var insertPragma$8 = pragma$11.insertPragma;
  24618. var isPragma = pragma$11.isPragma;
  24619. var getAncestorCount = utils$12.getAncestorCount;
  24620. var getBlockValueLineContents = utils$12.getBlockValueLineContents;
  24621. var getFlowScalarLineContents = utils$12.getFlowScalarLineContents;
  24622. var getLast$6 = utils$12.getLast;
  24623. var getLastDescendantNode$1 = utils$12.getLastDescendantNode;
  24624. var hasLeadingComments = utils$12.hasLeadingComments;
  24625. var hasMiddleComments = utils$12.hasMiddleComments;
  24626. var hasIndicatorComment = utils$12.hasIndicatorComment;
  24627. var hasTrailingComment$1 = utils$12.hasTrailingComment;
  24628. var hasEndComments = utils$12.hasEndComments;
  24629. var hasPrettierIgnore$4 = utils$12.hasPrettierIgnore;
  24630. var isLastDescendantNode = utils$12.isLastDescendantNode;
  24631. var isNextLineEmpty$5 = utils$12.isNextLineEmpty;
  24632. var isNode = utils$12.isNode;
  24633. var isEmptyNode = utils$12.isEmptyNode;
  24634. var defineShortcut = utils$12.defineShortcut;
  24635. var mapNode = utils$12.mapNode;
  24636. var docBuilders$3 = doc.builders;
  24637. var conditionalGroup$2 = docBuilders$3.conditionalGroup;
  24638. var breakParent$4 = docBuilders$3.breakParent;
  24639. var concat$17 = docBuilders$3.concat;
  24640. var dedent$4 = docBuilders$3.dedent;
  24641. var dedentToRoot$3 = docBuilders$3.dedentToRoot;
  24642. var fill$6 = docBuilders$3.fill;
  24643. var group$16 = docBuilders$3.group;
  24644. var hardline$13 = docBuilders$3.hardline;
  24645. var ifBreak$7 = docBuilders$3.ifBreak;
  24646. var join$12 = docBuilders$3.join;
  24647. var line$11 = docBuilders$3.line;
  24648. var lineSuffix$2 = docBuilders$3.lineSuffix;
  24649. var literalline$7 = docBuilders$3.literalline;
  24650. var markAsRoot$5 = docBuilders$3.markAsRoot;
  24651. var softline$8 = docBuilders$3.softline;
  24652. var replaceEndOfLineWith$3 = util.replaceEndOfLineWith;
  24653. function preprocess$6(ast) {
  24654. return mapNode(ast, defineShortcuts);
  24655. }
  24656. function defineShortcuts(node) {
  24657. switch (node.type) {
  24658. case "document":
  24659. defineShortcut(node, "head", function () {
  24660. return node.children[0];
  24661. });
  24662. defineShortcut(node, "body", function () {
  24663. return node.children[1];
  24664. });
  24665. break;
  24666. case "documentBody":
  24667. case "sequenceItem":
  24668. case "flowSequenceItem":
  24669. case "mappingKey":
  24670. case "mappingValue":
  24671. defineShortcut(node, "content", function () {
  24672. return node.children[0];
  24673. });
  24674. break;
  24675. case "mappingItem":
  24676. case "flowMappingItem":
  24677. defineShortcut(node, "key", function () {
  24678. return node.children[0];
  24679. });
  24680. defineShortcut(node, "value", function () {
  24681. return node.children[1];
  24682. });
  24683. break;
  24684. }
  24685. return node;
  24686. }
  24687. function genericPrint$6(path, options, print) {
  24688. var node = path.getValue();
  24689. var parentNode = path.getParentNode();
  24690. var tag = !node.tag ? "" : path.call(print, "tag");
  24691. var anchor = !node.anchor ? "" : path.call(print, "anchor");
  24692. var nextEmptyLine = isNode(node, ["mapping", "sequence", "comment", "directive", "mappingItem", "sequenceItem"]) && !isLastDescendantNode(path) ? printNextEmptyLine(path, options.originalText) : "";
  24693. return concat$17([node.type !== "mappingValue" && hasLeadingComments(node) ? concat$17([join$12(hardline$13, path.map(print, "leadingComments")), hardline$13]) : "", tag, tag && anchor ? " " : "", anchor, tag || anchor ? isNode(node, ["sequence", "mapping"]) && !hasMiddleComments(node) ? hardline$13 : " " : "", hasMiddleComments(node) ? concat$17([node.middleComments.length === 1 ? "" : hardline$13, join$12(hardline$13, path.map(print, "middleComments")), hardline$13]) : "", hasPrettierIgnore$4(path) ? concat$17(replaceEndOfLineWith$3(options.originalText.slice(node.position.start.offset, node.position.end.offset), literalline$7)) : group$16(_print(node, parentNode, path, options, print)), hasTrailingComment$1(node) && !isNode(node, ["document", "documentHead"]) ? lineSuffix$2(concat$17([node.type === "mappingValue" && !node.content ? "" : " ", parentNode.type === "mappingKey" && path.getParentNode(2).type === "mapping" && isInlineNode(node) ? "" : breakParent$4, path.call(print, "trailingComment")])) : "", nextEmptyLine, hasEndComments(node) && !isNode(node, ["documentHead", "documentBody"]) ? align$3(node.type === "sequenceItem" ? 2 : 0, concat$17([hardline$13, join$12(hardline$13, path.map(print, "endComments"))])) : ""]);
  24694. }
  24695. function _print(node, parentNode, path, options, print) {
  24696. switch (node.type) {
  24697. case "root":
  24698. return concat$17([join$12(hardline$13, path.map(function (childPath, index) {
  24699. var document = node.children[index];
  24700. var nextDocument = node.children[index + 1];
  24701. return concat$17([print(childPath), shouldPrintDocumentEndMarker(document, nextDocument) ? concat$17([hardline$13, "...", hasTrailingComment$1(document) ? concat$17([" ", path.call(print, "trailingComment")]) : ""]) : !nextDocument || hasTrailingComment$1(nextDocument.head) ? "" : concat$17([hardline$13, "---"])]);
  24702. }, "children")), node.children.length === 0 || function (lastDescendantNode) {
  24703. return isNode(lastDescendantNode, ["blockLiteral", "blockFolded"]) && lastDescendantNode.chomping === "keep";
  24704. }(getLastDescendantNode$1(node)) ? "" : hardline$13]);
  24705. case "document":
  24706. {
  24707. var nextDocument = parentNode.children[path.getName() + 1];
  24708. return join$12(hardline$13, [shouldPrintDocumentHeadEndMarker(node, nextDocument, parentNode, options) === "head" ? join$12(hardline$13, [node.head.children.length === 0 && node.head.endComments.length === 0 ? "" : path.call(print, "head"), concat$17(["---", hasTrailingComment$1(node.head) ? concat$17([" ", path.call(print, "head", "trailingComment")]) : ""])].filter(Boolean)) : "", shouldPrintDocumentBody(node) ? path.call(print, "body") : ""].filter(Boolean));
  24709. }
  24710. case "documentHead":
  24711. return join$12(hardline$13, [].concat(path.map(print, "children"), path.map(print, "endComments")));
  24712. case "documentBody":
  24713. {
  24714. var children = join$12(hardline$13, path.map(print, "children")).parts;
  24715. var endComments = join$12(hardline$13, path.map(print, "endComments")).parts;
  24716. var separator = children.length === 0 || endComments.length === 0 ? "" : function (lastDescendantNode) {
  24717. return isNode(lastDescendantNode, ["blockFolded", "blockLiteral"]) ? lastDescendantNode.chomping === "keep" ? // there's already a newline printed at the end of blockValue (chomping=keep, lastDescendant=true)
  24718. "" : // an extra newline for better readability
  24719. concat$17([hardline$13, hardline$13]) : hardline$13;
  24720. }(getLastDescendantNode$1(node));
  24721. return concat$17([].concat(children, separator, endComments));
  24722. }
  24723. case "directive":
  24724. return concat$17(["%", join$12(" ", [node.name].concat(node.parameters))]);
  24725. case "comment":
  24726. return concat$17(["#", node.value]);
  24727. case "alias":
  24728. return concat$17(["*", node.value]);
  24729. case "tag":
  24730. return options.originalText.slice(node.position.start.offset, node.position.end.offset);
  24731. case "anchor":
  24732. return concat$17(["&", node.value]);
  24733. case "plain":
  24734. return printFlowScalarContent(node.type, options.originalText.slice(node.position.start.offset, node.position.end.offset), options);
  24735. case "quoteDouble":
  24736. case "quoteSingle":
  24737. {
  24738. var singleQuote = "'";
  24739. var doubleQuote = '"';
  24740. var raw = options.originalText.slice(node.position.start.offset + 1, node.position.end.offset - 1);
  24741. if (node.type === "quoteSingle" && raw.includes("\\") || node.type === "quoteDouble" && /\\[^"]/.test(raw)) {
  24742. // only quoteDouble can use escape chars
  24743. // and quoteSingle do not need to escape backslashes
  24744. var originalQuote = node.type === "quoteDouble" ? doubleQuote : singleQuote;
  24745. return concat$17([originalQuote, printFlowScalarContent(node.type, raw, options), originalQuote]);
  24746. } else if (raw.includes(doubleQuote)) {
  24747. return concat$17([singleQuote, printFlowScalarContent(node.type, node.type === "quoteDouble" ? raw // double quote needs to be escaped by backslash in quoteDouble
  24748. .replace(/\\"/g, doubleQuote).replace(/'/g, singleQuote.repeat(2)) : raw, options), singleQuote]);
  24749. }
  24750. if (raw.includes(singleQuote)) {
  24751. return concat$17([doubleQuote, printFlowScalarContent(node.type, node.type === "quoteSingle" ? // single quote needs to be escaped by 2 single quotes in quoteSingle
  24752. raw.replace(/''/g, singleQuote) : raw, options), doubleQuote]);
  24753. }
  24754. var quote = options.singleQuote ? singleQuote : doubleQuote;
  24755. return concat$17([quote, printFlowScalarContent(node.type, raw, options), quote]);
  24756. }
  24757. case "blockFolded":
  24758. case "blockLiteral":
  24759. {
  24760. var parentIndent = getAncestorCount(path, function (ancestorNode) {
  24761. return isNode(ancestorNode, ["sequence", "mapping"]);
  24762. });
  24763. var isLastDescendant = isLastDescendantNode(path);
  24764. return concat$17([node.type === "blockFolded" ? ">" : "|", node.indent === null ? "" : node.indent.toString(), node.chomping === "clip" ? "" : node.chomping === "keep" ? "+" : "-", hasIndicatorComment(node) ? concat$17([" ", path.call(print, "indicatorComment")]) : "", (node.indent === null ? dedent$4 : dedentToRoot$3)(align$3(node.indent === null ? options.tabWidth : node.indent - 1 + parentIndent, concat$17(getBlockValueLineContents(node, {
  24765. parentIndent: parentIndent,
  24766. isLastDescendant: isLastDescendant,
  24767. options: options
  24768. }).reduce(function (reduced, lineWords, index, lineContents) {
  24769. return reduced.concat(index === 0 ? hardline$13 : "", fill$6(join$12(line$11, lineWords).parts), index !== lineContents.length - 1 ? lineWords.length === 0 ? hardline$13 : markAsRoot$5(literalline$7) : node.chomping === "keep" && isLastDescendant ? lineWords.length === 0 ? dedentToRoot$3(hardline$13) : dedentToRoot$3(literalline$7) : "");
  24770. }, []))))]);
  24771. }
  24772. case "sequence":
  24773. return join$12(hardline$13, path.map(print, "children"));
  24774. case "sequenceItem":
  24775. return concat$17(["- ", align$3(2, !node.content ? "" : path.call(print, "content"))]);
  24776. case "mappingKey":
  24777. return !node.content ? "" : path.call(print, "content");
  24778. case "mappingValue":
  24779. return !node.content ? "" : path.call(print, "content");
  24780. case "mapping":
  24781. return join$12(hardline$13, path.map(print, "children"));
  24782. case "mappingItem":
  24783. case "flowMappingItem":
  24784. {
  24785. var isEmptyMappingKey = isEmptyNode(node.key);
  24786. var isEmptyMappingValue = isEmptyNode(node.value);
  24787. if (isEmptyMappingKey && isEmptyMappingValue) {
  24788. return concat$17([": "]);
  24789. }
  24790. var key = path.call(print, "key");
  24791. var value = path.call(print, "value");
  24792. if (isEmptyMappingValue) {
  24793. return node.type === "flowMappingItem" && parentNode.type === "flowMapping" ? key : node.type === "mappingItem" && isAbsolutelyPrintedAsSingleLineNode(node.key.content, options) && !hasTrailingComment$1(node.key.content) && (!parentNode.tag || parentNode.tag.value !== "tag:yaml.org,2002:set") ? concat$17([key, needsSpaceInFrontOfMappingValue(node) ? " " : "", ":"]) : concat$17(["? ", align$3(2, key)]);
  24794. }
  24795. if (isEmptyMappingKey) {
  24796. return concat$17([": ", align$3(2, value)]);
  24797. }
  24798. var groupId = Symbol("mappingKey");
  24799. var forceExplicitKey = hasLeadingComments(node.value) || !isInlineNode(node.key.content);
  24800. return forceExplicitKey ? concat$17(["? ", align$3(2, key), hardline$13, join$12("", path.map(print, "value", "leadingComments").map(function (comment) {
  24801. return concat$17([comment, hardline$13]);
  24802. })), ": ", align$3(2, value)]) : // force singleline
  24803. isSingleLineNode(node.key.content) && !hasLeadingComments(node.key.content) && !hasMiddleComments(node.key.content) && !hasTrailingComment$1(node.key.content) && !hasEndComments(node.key) && !hasLeadingComments(node.value.content) && !hasMiddleComments(node.value.content) && !hasEndComments(node.value) && isAbsolutelyPrintedAsSingleLineNode(node.value.content, options) ? concat$17([key, needsSpaceInFrontOfMappingValue(node) ? " " : "", ": ", value]) : conditionalGroup$2([concat$17([group$16(concat$17([ifBreak$7("? "), group$16(align$3(2, key), {
  24804. id: groupId
  24805. })])), ifBreak$7(concat$17([hardline$13, ": ", align$3(2, value)]), indent(concat$17([needsSpaceInFrontOfMappingValue(node) ? " " : "", ":", hasLeadingComments(node.value.content) || hasEndComments(node.value) && node.value.content && !isNode(node.value.content, ["mapping", "sequence"]) || parentNode.type === "mapping" && hasTrailingComment$1(node.key.content) && isInlineNode(node.value.content) || isNode(node.value.content, ["mapping", "sequence"]) && node.value.content.tag === null && node.value.content.anchor === null ? hardline$13 : !node.value.content ? "" : line$11, value])), {
  24806. groupId: groupId
  24807. })])]);
  24808. }
  24809. case "flowMapping":
  24810. case "flowSequence":
  24811. {
  24812. var openMarker = node.type === "flowMapping" ? "{" : "[";
  24813. var closeMarker = node.type === "flowMapping" ? "}" : "]";
  24814. var bracketSpacing = node.type === "flowMapping" && node.children.length !== 0 && options.bracketSpacing ? line$11 : softline$8;
  24815. var isLastItemEmptyMappingItem = node.children.length !== 0 && function (lastItem) {
  24816. return lastItem.type === "flowMappingItem" && isEmptyNode(lastItem.key) && isEmptyNode(lastItem.value);
  24817. }(getLast$6(node.children));
  24818. return concat$17([openMarker, indent(concat$17([bracketSpacing, concat$17(path.map(function (childPath, index) {
  24819. return concat$17([print(childPath), index === node.children.length - 1 ? "" : concat$17([",", line$11, node.children[index].position.start.line !== node.children[index + 1].position.start.line ? printNextEmptyLine(childPath, options.originalText) : ""])]);
  24820. }, "children")), ifBreak$7(",", "")])), isLastItemEmptyMappingItem ? "" : bracketSpacing, closeMarker]);
  24821. }
  24822. case "flowSequenceItem":
  24823. return path.call(print, "content");
  24824. // istanbul ignore next
  24825. default:
  24826. throw new Error("Unexpected node type ".concat(node.type));
  24827. }
  24828. function indent(doc$$2) {
  24829. return docBuilders$3.align(" ".repeat(options.tabWidth), doc$$2);
  24830. }
  24831. }
  24832. function align$3(n, doc$$2) {
  24833. return typeof n === "number" && n > 0 ? docBuilders$3.align(" ".repeat(n), doc$$2) : docBuilders$3.align(n, doc$$2);
  24834. }
  24835. function isInlineNode(node) {
  24836. if (!node) {
  24837. return true;
  24838. }
  24839. switch (node.type) {
  24840. case "plain":
  24841. case "quoteDouble":
  24842. case "quoteSingle":
  24843. case "alias":
  24844. case "flowMapping":
  24845. case "flowSequence":
  24846. return true;
  24847. default:
  24848. return false;
  24849. }
  24850. }
  24851. function isSingleLineNode(node) {
  24852. if (!node) {
  24853. return true;
  24854. }
  24855. switch (node.type) {
  24856. case "plain":
  24857. case "quoteDouble":
  24858. case "quoteSingle":
  24859. return node.position.start.line === node.position.end.line;
  24860. case "alias":
  24861. return true;
  24862. default:
  24863. return false;
  24864. }
  24865. }
  24866. function shouldPrintDocumentBody(document) {
  24867. return document.body.children.length !== 0 || hasEndComments(document.body);
  24868. }
  24869. function shouldPrintDocumentEndMarker(document, nextDocument) {
  24870. return (
  24871. /**
  24872. *... # trailingComment
  24873. */
  24874. hasTrailingComment$1(document) || nextDocument && (
  24875. /**
  24876. * ...
  24877. * %DIRECTIVE
  24878. * ---
  24879. */
  24880. nextDocument.head.children.length !== 0 ||
  24881. /**
  24882. * ...
  24883. * # endComment
  24884. * ---
  24885. */
  24886. hasEndComments(nextDocument.head))
  24887. );
  24888. }
  24889. function shouldPrintDocumentHeadEndMarker(document, nextDocument, root, options) {
  24890. if (
  24891. /**
  24892. * ---
  24893. * preserve the first document head end marker
  24894. */
  24895. root.children[0] === document && /---(\s|$)/.test(options.originalText.slice(options.locStart(document), options.locStart(document) + 4)) ||
  24896. /**
  24897. * %DIRECTIVE
  24898. * ---
  24899. */
  24900. document.head.children.length !== 0 ||
  24901. /**
  24902. * # end comment
  24903. * ---
  24904. */
  24905. hasEndComments(document.head) ||
  24906. /**
  24907. * --- # trailing comment
  24908. */
  24909. hasTrailingComment$1(document.head)) {
  24910. return "head";
  24911. }
  24912. if (shouldPrintDocumentEndMarker(document, nextDocument)) {
  24913. return false;
  24914. }
  24915. return nextDocument ? "root" : false;
  24916. }
  24917. function isAbsolutelyPrintedAsSingleLineNode(node, options) {
  24918. if (!node) {
  24919. return true;
  24920. }
  24921. switch (node.type) {
  24922. case "plain":
  24923. case "quoteSingle":
  24924. case "quoteDouble":
  24925. break;
  24926. case "alias":
  24927. return true;
  24928. default:
  24929. return false;
  24930. }
  24931. if (options.proseWrap === "preserve") {
  24932. return node.position.start.line === node.position.end.line;
  24933. }
  24934. if ( // backslash-newline
  24935. /\\$/m.test(options.originalText.slice(node.position.start.offset, node.position.end.offset))) {
  24936. return false;
  24937. }
  24938. switch (options.proseWrap) {
  24939. case "never":
  24940. return node.value.indexOf("\n") === -1;
  24941. case "always":
  24942. return !/[\n ]/.test(node.value);
  24943. // istanbul ignore next
  24944. default:
  24945. return false;
  24946. }
  24947. }
  24948. function needsSpaceInFrontOfMappingValue(node) {
  24949. return node.key.content && node.key.content.type === "alias";
  24950. }
  24951. function printNextEmptyLine(path, originalText) {
  24952. var node = path.getValue();
  24953. var root = path.stack[0];
  24954. root.isNextEmptyLinePrintedChecklist = root.isNextEmptyLinePrintedChecklist || [];
  24955. if (!root.isNextEmptyLinePrintedChecklist[node.position.end.line]) {
  24956. if (isNextLineEmpty$5(node, originalText)) {
  24957. root.isNextEmptyLinePrintedChecklist[node.position.end.line] = true;
  24958. return softline$8;
  24959. }
  24960. }
  24961. return "";
  24962. }
  24963. function printFlowScalarContent(nodeType, content, options) {
  24964. var lineContents = getFlowScalarLineContents(nodeType, content, options);
  24965. return join$12(hardline$13, lineContents.map(function (lineContentWords) {
  24966. return fill$6(join$12(line$11, lineContentWords).parts);
  24967. }));
  24968. }
  24969. function clean$11(node, newNode
  24970. /*, parent */
  24971. ) {
  24972. if (isNode(newNode)) {
  24973. delete newNode.position;
  24974. switch (newNode.type) {
  24975. case "comment":
  24976. // insert pragma
  24977. if (isPragma(newNode.value)) {
  24978. return null;
  24979. }
  24980. break;
  24981. case "quoteDouble":
  24982. case "quoteSingle":
  24983. newNode.type = "quote";
  24984. break;
  24985. }
  24986. }
  24987. }
  24988. var printerYaml = {
  24989. preprocess: preprocess$6,
  24990. print: genericPrint$6,
  24991. massageAstNode: clean$11,
  24992. insertPragma: insertPragma$8
  24993. };
  24994. var options$18 = {
  24995. bracketSpacing: commonOptions.bracketSpacing,
  24996. singleQuote: commonOptions.singleQuote,
  24997. proseWrap: commonOptions.proseWrap
  24998. };
  24999. var name$16 = "YAML";
  25000. var type$15 = "data";
  25001. var tmScope$15 = "source.yaml";
  25002. var aliases$6 = ["yml"];
  25003. var extensions$15 = [".yml", ".mir", ".reek", ".rviz", ".sublime-syntax", ".syntax", ".yaml", ".yaml-tmlanguage", ".yml.mysql"];
  25004. var filenames$3 = [".clang-format", ".clang-tidy", ".gemrc", "glide.lock"];
  25005. var aceMode$15 = "yaml";
  25006. var codemirrorMode$11 = "yaml";
  25007. var codemirrorMimeType$11 = "text/x-yaml";
  25008. var languageId$15 = 407;
  25009. var yaml = {
  25010. name: name$16,
  25011. type: type$15,
  25012. tmScope: tmScope$15,
  25013. aliases: aliases$6,
  25014. extensions: extensions$15,
  25015. filenames: filenames$3,
  25016. aceMode: aceMode$15,
  25017. codemirrorMode: codemirrorMode$11,
  25018. codemirrorMimeType: codemirrorMimeType$11,
  25019. languageId: languageId$15
  25020. };
  25021. var yaml$1 = Object.freeze({
  25022. name: name$16,
  25023. type: type$15,
  25024. tmScope: tmScope$15,
  25025. aliases: aliases$6,
  25026. extensions: extensions$15,
  25027. filenames: filenames$3,
  25028. aceMode: aceMode$15,
  25029. codemirrorMode: codemirrorMode$11,
  25030. codemirrorMimeType: codemirrorMimeType$11,
  25031. languageId: languageId$15,
  25032. default: yaml
  25033. });
  25034. var require$$0$29 = ( yaml$1 && yaml ) || yaml$1;
  25035. var languages$6 = [createLanguage(require$$0$29, {
  25036. override: {
  25037. since: "1.14.0",
  25038. parsers: ["yaml"],
  25039. vscodeLanguageIds: ["yaml"]
  25040. }
  25041. })];
  25042. var languageYaml = {
  25043. languages: languages$6,
  25044. printers: {
  25045. yaml: printerYaml
  25046. },
  25047. options: options$18
  25048. };
  25049. var version = require$$0.version;
  25050. var getSupportInfo = support.getSupportInfo;
  25051. var internalPlugins = [languageCss, languageGraphql, languageHandlebars, languageHtml, languageJs, languageMarkdown, languageYaml];
  25052. var isArray = Array.isArray || function (arr) {
  25053. return Object.prototype.toString.call(arr) === "[object Array]";
  25054. }; // Luckily `opts` is always the 2nd argument
  25055. function withPlugins(fn) {
  25056. return function () {
  25057. var args = Array.from(arguments);
  25058. var plugins = args[1] && args[1].plugins || [];
  25059. if (!isArray(plugins)) {
  25060. plugins = Object.values(plugins);
  25061. }
  25062. args[1] = Object.assign({}, args[1], {
  25063. plugins: internalPlugins.concat(plugins)
  25064. });
  25065. return fn.apply(null, args);
  25066. };
  25067. }
  25068. var formatWithCursor = withPlugins(core.formatWithCursor);
  25069. var standalone$2 = {
  25070. formatWithCursor: formatWithCursor,
  25071. format: function format(text, opts) {
  25072. return formatWithCursor(text, opts).formatted;
  25073. },
  25074. check: function check(text, opts) {
  25075. var formatted = formatWithCursor(text, opts).formatted;
  25076. return formatted === text;
  25077. },
  25078. doc: doc,
  25079. getSupportInfo: withPlugins(getSupportInfo),
  25080. version: version,
  25081. util: utilShared,
  25082. __debug: {
  25083. parse: withPlugins(core.parse),
  25084. formatAST: withPlugins(core.formatAST),
  25085. formatDoc: withPlugins(core.formatDoc),
  25086. printToDoc: withPlugins(core.printToDoc),
  25087. printDocToString: withPlugins(core.printDocToString)
  25088. }
  25089. };
  25090. var standalone = standalone$2;
  25091. return standalone;
  25092. })));