standalone.js 976 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023
  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.18.2";
  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": "7.2.9",
  22. "@babel/code-frame": "7.0.0",
  23. "@babel/parser": "7.2.0",
  24. "@glimmer/syntax": "0.38.4",
  25. "@iarna/toml": "2.2.3",
  26. "@typescript-eslint/typescript-estree": "1.6.0",
  27. "angular-estree-parser": "1.1.5",
  28. "angular-html-parser": "1.2.0",
  29. "camelcase": "4.1.0",
  30. "chalk": "2.1.0",
  31. "cjk-regex": "2.0.0",
  32. "cosmiconfig": "5.0.7",
  33. "dashify": "0.2.2",
  34. "dedent": "0.7.0",
  35. "diff": "3.2.0",
  36. "editorconfig": "0.15.2",
  37. "editorconfig-to-prettier": "0.1.1",
  38. "escape-string-regexp": "1.0.5",
  39. "esutils": "2.0.2",
  40. "find-parent-dir": "0.3.0",
  41. "find-project-root": "1.1.1",
  42. "flow-parser": "0.84.0",
  43. "get-stream": "3.0.0",
  44. "globby": "6.1.0",
  45. "graphql": "14.2.0",
  46. "html-element-attributes": "2.0.0",
  47. "html-styles": "1.0.0",
  48. "html-tag-names": "1.1.2",
  49. "ignore": "4.0.6",
  50. "is-ci": "2.0.0",
  51. "jest-docblock": "23.2.0",
  52. "json-stable-stringify": "1.0.1",
  53. "leven": "2.1.0",
  54. "lines-and-columns": "1.1.6",
  55. "linguist-languages": "6.2.1-dev.20180706",
  56. "lodash.uniqby": "4.7.0",
  57. "mem": "1.1.0",
  58. "minimatch": "3.0.4",
  59. "minimist": "1.2.0",
  60. "n-readlines": "1.0.0",
  61. "normalize-path": "3.0.0",
  62. "parse-srcset": "ikatyang/parse-srcset#54eb9c1cb21db5c62b4d0e275d7249516df6f0ee",
  63. "postcss-less": "1.1.5",
  64. "postcss-media-query-parser": "0.2.3",
  65. "postcss-scss": "2.0.0",
  66. "postcss-selector-parser": "2.2.3",
  67. "postcss-values-parser": "1.5.0",
  68. "regexp-util": "1.2.2",
  69. "remark-math": "1.0.4",
  70. "remark-parse": "5.0.0",
  71. "resolve": "1.5.0",
  72. "semver": "5.4.1",
  73. "string-width": "3.0.0",
  74. "typescript": "3.4.1",
  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.18.0",
  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 scripts = {
  123. "prepublishOnly": "echo \"Error: must publish from dist/\" && exit 1",
  124. "prepare-release": "yarn && yarn build && yarn test:dist",
  125. "test": "jest",
  126. "test:dist": "node ./scripts/test-dist.js",
  127. "test-integration": "jest tests_integration",
  128. "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",
  129. "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",
  130. "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",
  131. "lint": "cross-env EFF_NO_LINK_RULES=true eslint . --format node_modules/eslint-friendly-formatter",
  132. "lint-docs": "prettylint {.,docs,website,website/blog}/*.md",
  133. "lint-dist": "eslint --no-eslintrc --no-ignore --env=browser \"dist/!(bin-prettier|index|third-party).js\"",
  134. "build": "node --max-old-space-size=2048 ./scripts/build/build.js",
  135. "build-docs": "node ./scripts/build-docs.js",
  136. "check-deps": "node ./scripts/check-deps.js"
  137. };
  138. var _package = {
  139. name: name,
  140. version: version$1,
  141. description: description,
  142. bin: bin,
  143. repository: repository,
  144. homepage: homepage,
  145. author: author,
  146. license: license,
  147. main: main,
  148. engines: engines,
  149. dependencies: dependencies,
  150. devDependencies: devDependencies,
  151. scripts: scripts
  152. };
  153. var _package$1 = Object.freeze({
  154. name: name,
  155. version: version$1,
  156. description: description,
  157. bin: bin,
  158. repository: repository,
  159. homepage: homepage,
  160. author: author,
  161. license: license,
  162. main: main,
  163. engines: engines,
  164. dependencies: dependencies,
  165. devDependencies: devDependencies,
  166. scripts: scripts,
  167. default: _package
  168. });
  169. var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
  170. function unwrapExports (x) {
  171. return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
  172. }
  173. function createCommonjsModule(fn, module) {
  174. return module = { exports: {} }, fn(module, module.exports), module.exports;
  175. }
  176. var base = createCommonjsModule(function (module, exports) {
  177. /*istanbul ignore start*/
  178. 'use strict';
  179. exports.__esModule = true;
  180. exports['default'] =
  181. /*istanbul ignore end*/
  182. Diff;
  183. function Diff() {}
  184. Diff.prototype = {
  185. /*istanbul ignore start*/
  186. /*istanbul ignore end*/
  187. diff: function diff(oldString, newString) {
  188. /*istanbul ignore start*/
  189. var
  190. /*istanbul ignore end*/
  191. options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];
  192. var callback = options.callback;
  193. if (typeof options === 'function') {
  194. callback = options;
  195. options = {};
  196. }
  197. this.options = options;
  198. var self = this;
  199. function done(value) {
  200. if (callback) {
  201. setTimeout(function () {
  202. callback(undefined, value);
  203. }, 0);
  204. return true;
  205. } else {
  206. return value;
  207. }
  208. } // Allow subclasses to massage the input prior to running
  209. oldString = this.castInput(oldString);
  210. newString = this.castInput(newString);
  211. oldString = this.removeEmpty(this.tokenize(oldString));
  212. newString = this.removeEmpty(this.tokenize(newString));
  213. var newLen = newString.length,
  214. oldLen = oldString.length;
  215. var editLength = 1;
  216. var maxEditLength = newLen + oldLen;
  217. var bestPath = [{
  218. newPos: -1,
  219. components: []
  220. }]; // Seed editLength = 0, i.e. the content starts with the same values
  221. var oldPos = this.extractCommon(bestPath[0], newString, oldString, 0);
  222. if (bestPath[0].newPos + 1 >= newLen && oldPos + 1 >= oldLen) {
  223. // Identity per the equality and tokenizer
  224. return done([{
  225. value: this.join(newString),
  226. count: newString.length
  227. }]);
  228. } // Main worker method. checks all permutations of a given edit length for acceptance.
  229. function execEditLength() {
  230. for (var diagonalPath = -1 * editLength; diagonalPath <= editLength; diagonalPath += 2) {
  231. var basePath =
  232. /*istanbul ignore start*/
  233. void 0;
  234. var addPath = bestPath[diagonalPath - 1],
  235. removePath = bestPath[diagonalPath + 1],
  236. _oldPos = (removePath ? removePath.newPos : 0) - diagonalPath;
  237. if (addPath) {
  238. // No one else is going to attempt to use this value, clear it
  239. bestPath[diagonalPath - 1] = undefined;
  240. }
  241. var canAdd = addPath && addPath.newPos + 1 < newLen,
  242. canRemove = removePath && 0 <= _oldPos && _oldPos < oldLen;
  243. if (!canAdd && !canRemove) {
  244. // If this path is a terminal then prune
  245. bestPath[diagonalPath] = undefined;
  246. continue;
  247. } // Select the diagonal that we want to branch from. We select the prior
  248. // path whose position in the new string is the farthest from the origin
  249. // and does not pass the bounds of the diff graph
  250. if (!canAdd || canRemove && addPath.newPos < removePath.newPos) {
  251. basePath = clonePath(removePath);
  252. self.pushComponent(basePath.components, undefined, true);
  253. } else {
  254. basePath = addPath; // No need to clone, we've pulled it from the list
  255. basePath.newPos++;
  256. self.pushComponent(basePath.components, true, undefined);
  257. }
  258. _oldPos = self.extractCommon(basePath, newString, oldString, diagonalPath); // If we have hit the end of both strings, then we are done
  259. if (basePath.newPos + 1 >= newLen && _oldPos + 1 >= oldLen) {
  260. return done(buildValues(self, basePath.components, newString, oldString, self.useLongestToken));
  261. } else {
  262. // Otherwise track this path as a potential candidate and continue.
  263. bestPath[diagonalPath] = basePath;
  264. }
  265. }
  266. editLength++;
  267. } // Performs the length of edit iteration. Is a bit fugly as this has to support the
  268. // sync and async mode which is never fun. Loops over execEditLength until a value
  269. // is produced.
  270. if (callback) {
  271. (function exec() {
  272. setTimeout(function () {
  273. // This should not happen, but we want to be safe.
  274. /* istanbul ignore next */
  275. if (editLength > maxEditLength) {
  276. return callback();
  277. }
  278. if (!execEditLength()) {
  279. exec();
  280. }
  281. }, 0);
  282. })();
  283. } else {
  284. while (editLength <= maxEditLength) {
  285. var ret = execEditLength();
  286. if (ret) {
  287. return ret;
  288. }
  289. }
  290. }
  291. },
  292. /*istanbul ignore start*/
  293. /*istanbul ignore end*/
  294. pushComponent: function pushComponent(components, added, removed) {
  295. var last = components[components.length - 1];
  296. if (last && last.added === added && last.removed === removed) {
  297. // We need to clone here as the component clone operation is just
  298. // as shallow array clone
  299. components[components.length - 1] = {
  300. count: last.count + 1,
  301. added: added,
  302. removed: removed
  303. };
  304. } else {
  305. components.push({
  306. count: 1,
  307. added: added,
  308. removed: removed
  309. });
  310. }
  311. },
  312. /*istanbul ignore start*/
  313. /*istanbul ignore end*/
  314. extractCommon: function extractCommon(basePath, newString, oldString, diagonalPath) {
  315. var newLen = newString.length,
  316. oldLen = oldString.length,
  317. newPos = basePath.newPos,
  318. oldPos = newPos - diagonalPath,
  319. commonCount = 0;
  320. while (newPos + 1 < newLen && oldPos + 1 < oldLen && this.equals(newString[newPos + 1], oldString[oldPos + 1])) {
  321. newPos++;
  322. oldPos++;
  323. commonCount++;
  324. }
  325. if (commonCount) {
  326. basePath.components.push({
  327. count: commonCount
  328. });
  329. }
  330. basePath.newPos = newPos;
  331. return oldPos;
  332. },
  333. /*istanbul ignore start*/
  334. /*istanbul ignore end*/
  335. equals: function equals(left, right) {
  336. return left === right;
  337. },
  338. /*istanbul ignore start*/
  339. /*istanbul ignore end*/
  340. removeEmpty: function removeEmpty(array) {
  341. var ret = [];
  342. for (var i = 0; i < array.length; i++) {
  343. if (array[i]) {
  344. ret.push(array[i]);
  345. }
  346. }
  347. return ret;
  348. },
  349. /*istanbul ignore start*/
  350. /*istanbul ignore end*/
  351. castInput: function castInput(value) {
  352. return value;
  353. },
  354. /*istanbul ignore start*/
  355. /*istanbul ignore end*/
  356. tokenize: function tokenize(value) {
  357. return value.split('');
  358. },
  359. /*istanbul ignore start*/
  360. /*istanbul ignore end*/
  361. join: function join(chars) {
  362. return chars.join('');
  363. }
  364. };
  365. function buildValues(diff, components, newString, oldString, useLongestToken) {
  366. var componentPos = 0,
  367. componentLen = components.length,
  368. newPos = 0,
  369. oldPos = 0;
  370. for (; componentPos < componentLen; componentPos++) {
  371. var component = components[componentPos];
  372. if (!component.removed) {
  373. if (!component.added && useLongestToken) {
  374. var value = newString.slice(newPos, newPos + component.count);
  375. value = value.map(function (value, i) {
  376. var oldValue = oldString[oldPos + i];
  377. return oldValue.length > value.length ? oldValue : value;
  378. });
  379. component.value = diff.join(value);
  380. } else {
  381. component.value = diff.join(newString.slice(newPos, newPos + component.count));
  382. }
  383. newPos += component.count; // Common case
  384. if (!component.added) {
  385. oldPos += component.count;
  386. }
  387. } else {
  388. component.value = diff.join(oldString.slice(oldPos, oldPos + component.count));
  389. oldPos += component.count; // Reverse add and remove so removes are output first to match common convention
  390. // The diffing algorithm is tied to add then remove output and this is the simplest
  391. // route to get the desired output with minimal overhead.
  392. if (componentPos && components[componentPos - 1].added) {
  393. var tmp = components[componentPos - 1];
  394. components[componentPos - 1] = components[componentPos];
  395. components[componentPos] = tmp;
  396. }
  397. }
  398. } // Special case handle for when one terminal is ignored. For this case we merge the
  399. // terminal into the prior string and drop the change.
  400. var lastComponent = components[componentLen - 1];
  401. if (componentLen > 1 && (lastComponent.added || lastComponent.removed) && diff.equals('', lastComponent.value)) {
  402. components[componentLen - 2].value += lastComponent.value;
  403. components.pop();
  404. }
  405. return components;
  406. }
  407. function clonePath(path) {
  408. return {
  409. newPos: path.newPos,
  410. components: path.components.slice(0)
  411. };
  412. }
  413. });
  414. unwrapExports(base);
  415. var character = createCommonjsModule(function (module, exports) {
  416. /*istanbul ignore start*/
  417. 'use strict';
  418. exports.__esModule = true;
  419. exports.characterDiff = undefined;
  420. exports.
  421. /*istanbul ignore end*/
  422. diffChars = diffChars;
  423. /*istanbul ignore start*/
  424. var _base2 = _interopRequireDefault(base);
  425. function _interopRequireDefault(obj) {
  426. return obj && obj.__esModule ? obj : {
  427. 'default': obj
  428. };
  429. }
  430. /*istanbul ignore end*/
  431. var characterDiff =
  432. /*istanbul ignore start*/
  433. exports.
  434. /*istanbul ignore end*/
  435. characterDiff = new
  436. /*istanbul ignore start*/
  437. _base2['default']();
  438. function diffChars(oldStr, newStr, callback) {
  439. return characterDiff.diff(oldStr, newStr, callback);
  440. }
  441. });
  442. unwrapExports(character);
  443. var params = createCommonjsModule(function (module, exports) {
  444. /*istanbul ignore start*/
  445. 'use strict';
  446. exports.__esModule = true;
  447. exports.
  448. /*istanbul ignore end*/
  449. generateOptions = generateOptions;
  450. function generateOptions(options, defaults) {
  451. if (typeof options === 'function') {
  452. defaults.callback = options;
  453. } else if (options) {
  454. for (var name in options) {
  455. /* istanbul ignore else */
  456. if (options.hasOwnProperty(name)) {
  457. defaults[name] = options[name];
  458. }
  459. }
  460. }
  461. return defaults;
  462. }
  463. });
  464. unwrapExports(params);
  465. var word = createCommonjsModule(function (module, exports) {
  466. /*istanbul ignore start*/
  467. 'use strict';
  468. exports.__esModule = true;
  469. exports.wordDiff = undefined;
  470. exports.
  471. /*istanbul ignore end*/
  472. diffWords = diffWords;
  473. /*istanbul ignore start*/
  474. exports.
  475. /*istanbul ignore end*/
  476. diffWordsWithSpace = diffWordsWithSpace;
  477. /*istanbul ignore start*/
  478. var _base2 = _interopRequireDefault(base);
  479. /*istanbul ignore end*/
  480. /*istanbul ignore start*/
  481. function _interopRequireDefault(obj) {
  482. return obj && obj.__esModule ? obj : {
  483. 'default': obj
  484. };
  485. }
  486. /*istanbul ignore end*/
  487. // Based on https://en.wikipedia.org/wiki/Latin_script_in_Unicode
  488. //
  489. // Ranges and exceptions:
  490. // Latin-1 Supplement, 0080–00FF
  491. // - U+00D7 × Multiplication sign
  492. // - U+00F7 ÷ Division sign
  493. // Latin Extended-A, 0100–017F
  494. // Latin Extended-B, 0180–024F
  495. // IPA Extensions, 0250–02AF
  496. // Spacing Modifier Letters, 02B0–02FF
  497. // - U+02C7 ˇ &#711; Caron
  498. // - U+02D8 ˘ &#728; Breve
  499. // - U+02D9 ˙ &#729; Dot Above
  500. // - U+02DA ˚ &#730; Ring Above
  501. // - U+02DB ˛ &#731; Ogonek
  502. // - U+02DC ˜ &#732; Small Tilde
  503. // - U+02DD ˝ &#733; Double Acute Accent
  504. // Latin Extended Additional, 1E00–1EFF
  505. var extendedWordChars = /^[A-Za-z\xC0-\u02C6\u02C8-\u02D7\u02DE-\u02FF\u1E00-\u1EFF]+$/;
  506. var reWhitespace = /\S/;
  507. var wordDiff =
  508. /*istanbul ignore start*/
  509. exports.
  510. /*istanbul ignore end*/
  511. wordDiff = new
  512. /*istanbul ignore start*/
  513. _base2['default']();
  514. wordDiff.equals = function (left, right) {
  515. return left === right || this.options.ignoreWhitespace && !reWhitespace.test(left) && !reWhitespace.test(right);
  516. };
  517. wordDiff.tokenize = function (value) {
  518. 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.
  519. for (var i = 0; i < tokens.length - 1; i++) {
  520. // If we have an empty string in the next field and we have only word chars before and after, merge
  521. if (!tokens[i + 1] && tokens[i + 2] && extendedWordChars.test(tokens[i]) && extendedWordChars.test(tokens[i + 2])) {
  522. tokens[i] += tokens[i + 2];
  523. tokens.splice(i + 1, 2);
  524. i--;
  525. }
  526. }
  527. return tokens;
  528. };
  529. function diffWords(oldStr, newStr, callback) {
  530. var options =
  531. /*istanbul ignore start*/
  532. (0, params.generateOptions
  533. /*istanbul ignore end*/
  534. )(callback, {
  535. ignoreWhitespace: true
  536. });
  537. return wordDiff.diff(oldStr, newStr, options);
  538. }
  539. function diffWordsWithSpace(oldStr, newStr, callback) {
  540. return wordDiff.diff(oldStr, newStr, callback);
  541. }
  542. });
  543. unwrapExports(word);
  544. var line = createCommonjsModule(function (module, exports) {
  545. /*istanbul ignore start*/
  546. 'use strict';
  547. exports.__esModule = true;
  548. exports.lineDiff = undefined;
  549. exports.
  550. /*istanbul ignore end*/
  551. diffLines = diffLines;
  552. /*istanbul ignore start*/
  553. exports.
  554. /*istanbul ignore end*/
  555. diffTrimmedLines = diffTrimmedLines;
  556. /*istanbul ignore start*/
  557. var _base2 = _interopRequireDefault(base);
  558. /*istanbul ignore end*/
  559. /*istanbul ignore start*/
  560. function _interopRequireDefault(obj) {
  561. return obj && obj.__esModule ? obj : {
  562. 'default': obj
  563. };
  564. }
  565. /*istanbul ignore end*/
  566. var lineDiff =
  567. /*istanbul ignore start*/
  568. exports.
  569. /*istanbul ignore end*/
  570. lineDiff = new
  571. /*istanbul ignore start*/
  572. _base2['default']();
  573. lineDiff.tokenize = function (value) {
  574. var retLines = [],
  575. linesAndNewlines = value.split(/(\n|\r\n)/); // Ignore the final empty token that occurs if the string ends with a new line
  576. if (!linesAndNewlines[linesAndNewlines.length - 1]) {
  577. linesAndNewlines.pop();
  578. } // Merge the content and line separators into single tokens
  579. for (var i = 0; i < linesAndNewlines.length; i++) {
  580. var line = linesAndNewlines[i];
  581. if (i % 2 && !this.options.newlineIsToken) {
  582. retLines[retLines.length - 1] += line;
  583. } else {
  584. if (this.options.ignoreWhitespace) {
  585. line = line.trim();
  586. }
  587. retLines.push(line);
  588. }
  589. }
  590. return retLines;
  591. };
  592. function diffLines(oldStr, newStr, callback) {
  593. return lineDiff.diff(oldStr, newStr, callback);
  594. }
  595. function diffTrimmedLines(oldStr, newStr, callback) {
  596. var options =
  597. /*istanbul ignore start*/
  598. (0, params.generateOptions
  599. /*istanbul ignore end*/
  600. )(callback, {
  601. ignoreWhitespace: true
  602. });
  603. return lineDiff.diff(oldStr, newStr, options);
  604. }
  605. });
  606. unwrapExports(line);
  607. var sentence = createCommonjsModule(function (module, exports) {
  608. /*istanbul ignore start*/
  609. 'use strict';
  610. exports.__esModule = true;
  611. exports.sentenceDiff = undefined;
  612. exports.
  613. /*istanbul ignore end*/
  614. diffSentences = diffSentences;
  615. /*istanbul ignore start*/
  616. var _base2 = _interopRequireDefault(base);
  617. function _interopRequireDefault(obj) {
  618. return obj && obj.__esModule ? obj : {
  619. 'default': obj
  620. };
  621. }
  622. /*istanbul ignore end*/
  623. var sentenceDiff =
  624. /*istanbul ignore start*/
  625. exports.
  626. /*istanbul ignore end*/
  627. sentenceDiff = new
  628. /*istanbul ignore start*/
  629. _base2['default']();
  630. sentenceDiff.tokenize = function (value) {
  631. return value.split(/(\S.+?[.!?])(?=\s+|$)/);
  632. };
  633. function diffSentences(oldStr, newStr, callback) {
  634. return sentenceDiff.diff(oldStr, newStr, callback);
  635. }
  636. });
  637. unwrapExports(sentence);
  638. var css = createCommonjsModule(function (module, exports) {
  639. /*istanbul ignore start*/
  640. 'use strict';
  641. exports.__esModule = true;
  642. exports.cssDiff = undefined;
  643. exports.
  644. /*istanbul ignore end*/
  645. diffCss = diffCss;
  646. /*istanbul ignore start*/
  647. var _base2 = _interopRequireDefault(base);
  648. function _interopRequireDefault(obj) {
  649. return obj && obj.__esModule ? obj : {
  650. 'default': obj
  651. };
  652. }
  653. /*istanbul ignore end*/
  654. var cssDiff =
  655. /*istanbul ignore start*/
  656. exports.
  657. /*istanbul ignore end*/
  658. cssDiff = new
  659. /*istanbul ignore start*/
  660. _base2['default']();
  661. cssDiff.tokenize = function (value) {
  662. return value.split(/([{}:;,]|\s+)/);
  663. };
  664. function diffCss(oldStr, newStr, callback) {
  665. return cssDiff.diff(oldStr, newStr, callback);
  666. }
  667. });
  668. unwrapExports(css);
  669. function _typeof(obj) {
  670. if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
  671. _typeof = function (obj) {
  672. return typeof obj;
  673. };
  674. } else {
  675. _typeof = function (obj) {
  676. return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
  677. };
  678. }
  679. return _typeof(obj);
  680. }
  681. function _classCallCheck(instance, Constructor) {
  682. if (!(instance instanceof Constructor)) {
  683. throw new TypeError("Cannot call a class as a function");
  684. }
  685. }
  686. function _defineProperties(target, props) {
  687. for (var i = 0; i < props.length; i++) {
  688. var descriptor = props[i];
  689. descriptor.enumerable = descriptor.enumerable || false;
  690. descriptor.configurable = true;
  691. if ("value" in descriptor) descriptor.writable = true;
  692. Object.defineProperty(target, descriptor.key, descriptor);
  693. }
  694. }
  695. function _createClass(Constructor, protoProps, staticProps) {
  696. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  697. if (staticProps) _defineProperties(Constructor, staticProps);
  698. return Constructor;
  699. }
  700. function _defineProperty(obj, key, value) {
  701. if (key in obj) {
  702. Object.defineProperty(obj, key, {
  703. value: value,
  704. enumerable: true,
  705. configurable: true,
  706. writable: true
  707. });
  708. } else {
  709. obj[key] = value;
  710. }
  711. return obj;
  712. }
  713. function _inherits(subClass, superClass) {
  714. if (typeof superClass !== "function" && superClass !== null) {
  715. throw new TypeError("Super expression must either be null or a function");
  716. }
  717. subClass.prototype = Object.create(superClass && superClass.prototype, {
  718. constructor: {
  719. value: subClass,
  720. writable: true,
  721. configurable: true
  722. }
  723. });
  724. if (superClass) _setPrototypeOf(subClass, superClass);
  725. }
  726. function _getPrototypeOf(o) {
  727. _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
  728. return o.__proto__ || Object.getPrototypeOf(o);
  729. };
  730. return _getPrototypeOf(o);
  731. }
  732. function _setPrototypeOf(o, p) {
  733. _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
  734. o.__proto__ = p;
  735. return o;
  736. };
  737. return _setPrototypeOf(o, p);
  738. }
  739. function isNativeReflectConstruct() {
  740. if (typeof Reflect === "undefined" || !Reflect.construct) return false;
  741. if (Reflect.construct.sham) return false;
  742. if (typeof Proxy === "function") return true;
  743. try {
  744. Date.prototype.toString.call(Reflect.construct(Date, [], function () {}));
  745. return true;
  746. } catch (e) {
  747. return false;
  748. }
  749. }
  750. function _construct(Parent, args, Class) {
  751. if (isNativeReflectConstruct()) {
  752. _construct = Reflect.construct;
  753. } else {
  754. _construct = function _construct(Parent, args, Class) {
  755. var a = [null];
  756. a.push.apply(a, args);
  757. var Constructor = Function.bind.apply(Parent, a);
  758. var instance = new Constructor();
  759. if (Class) _setPrototypeOf(instance, Class.prototype);
  760. return instance;
  761. };
  762. }
  763. return _construct.apply(null, arguments);
  764. }
  765. function _isNativeFunction(fn) {
  766. return Function.toString.call(fn).indexOf("[native code]") !== -1;
  767. }
  768. function _wrapNativeSuper(Class) {
  769. var _cache = typeof Map === "function" ? new Map() : undefined;
  770. _wrapNativeSuper = function _wrapNativeSuper(Class) {
  771. if (Class === null || !_isNativeFunction(Class)) return Class;
  772. if (typeof Class !== "function") {
  773. throw new TypeError("Super expression must either be null or a function");
  774. }
  775. if (typeof _cache !== "undefined") {
  776. if (_cache.has(Class)) return _cache.get(Class);
  777. _cache.set(Class, Wrapper);
  778. }
  779. function Wrapper() {
  780. return _construct(Class, arguments, _getPrototypeOf(this).constructor);
  781. }
  782. Wrapper.prototype = Object.create(Class.prototype, {
  783. constructor: {
  784. value: Wrapper,
  785. enumerable: false,
  786. writable: true,
  787. configurable: true
  788. }
  789. });
  790. return _setPrototypeOf(Wrapper, Class);
  791. };
  792. return _wrapNativeSuper(Class);
  793. }
  794. function _assertThisInitialized(self) {
  795. if (self === void 0) {
  796. throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
  797. }
  798. return self;
  799. }
  800. function _possibleConstructorReturn(self, call) {
  801. if (call && (typeof call === "object" || typeof call === "function")) {
  802. return call;
  803. }
  804. return _assertThisInitialized(self);
  805. }
  806. function _superPropBase(object, property) {
  807. while (!Object.prototype.hasOwnProperty.call(object, property)) {
  808. object = _getPrototypeOf(object);
  809. if (object === null) break;
  810. }
  811. return object;
  812. }
  813. function _get(target, property, receiver) {
  814. if (typeof Reflect !== "undefined" && Reflect.get) {
  815. _get = Reflect.get;
  816. } else {
  817. _get = function _get(target, property, receiver) {
  818. var base = _superPropBase(target, property);
  819. if (!base) return;
  820. var desc = Object.getOwnPropertyDescriptor(base, property);
  821. if (desc.get) {
  822. return desc.get.call(receiver);
  823. }
  824. return desc.value;
  825. };
  826. }
  827. return _get(target, property, receiver || target);
  828. }
  829. function _taggedTemplateLiteral(strings, raw) {
  830. if (!raw) {
  831. raw = strings.slice(0);
  832. }
  833. return Object.freeze(Object.defineProperties(strings, {
  834. raw: {
  835. value: Object.freeze(raw)
  836. }
  837. }));
  838. }
  839. function _slicedToArray(arr, i) {
  840. return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest();
  841. }
  842. function _toArray(arr) {
  843. return _arrayWithHoles(arr) || _iterableToArray(arr) || _nonIterableRest();
  844. }
  845. function _toConsumableArray(arr) {
  846. return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread();
  847. }
  848. function _arrayWithoutHoles(arr) {
  849. if (Array.isArray(arr)) {
  850. for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
  851. return arr2;
  852. }
  853. }
  854. function _arrayWithHoles(arr) {
  855. if (Array.isArray(arr)) return arr;
  856. }
  857. function _iterableToArray(iter) {
  858. if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter);
  859. }
  860. function _iterableToArrayLimit(arr, i) {
  861. var _arr = [];
  862. var _n = true;
  863. var _d = false;
  864. var _e = undefined;
  865. try {
  866. for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
  867. _arr.push(_s.value);
  868. if (i && _arr.length === i) break;
  869. }
  870. } catch (err) {
  871. _d = true;
  872. _e = err;
  873. } finally {
  874. try {
  875. if (!_n && _i["return"] != null) _i["return"]();
  876. } finally {
  877. if (_d) throw _e;
  878. }
  879. }
  880. return _arr;
  881. }
  882. function _nonIterableSpread() {
  883. throw new TypeError("Invalid attempt to spread non-iterable instance");
  884. }
  885. function _nonIterableRest() {
  886. throw new TypeError("Invalid attempt to destructure non-iterable instance");
  887. }
  888. function _toPrimitive(input, hint) {
  889. if (typeof input !== "object" || input === null) return input;
  890. var prim = input[Symbol.toPrimitive];
  891. if (prim !== undefined) {
  892. var res = prim.call(input, hint || "default");
  893. if (typeof res !== "object") return res;
  894. throw new TypeError("@@toPrimitive must return a primitive value.");
  895. }
  896. return (hint === "string" ? String : Number)(input);
  897. }
  898. function _toPropertyKey(arg) {
  899. var key = _toPrimitive(arg, "string");
  900. return typeof key === "symbol" ? key : String(key);
  901. }
  902. function _addElementPlacement(element, placements, silent) {
  903. var keys = placements[element.placement];
  904. if (!silent && keys.indexOf(element.key) !== -1) {
  905. throw new TypeError("Duplicated element (" + element.key + ")");
  906. }
  907. keys.push(element.key);
  908. }
  909. function _fromElementDescriptor(element) {
  910. var obj = {
  911. kind: element.kind,
  912. key: element.key,
  913. placement: element.placement,
  914. descriptor: element.descriptor
  915. };
  916. var desc = {
  917. value: "Descriptor",
  918. configurable: true
  919. };
  920. Object.defineProperty(obj, Symbol.toStringTag, desc);
  921. if (element.kind === "field") obj.initializer = element.initializer;
  922. return obj;
  923. }
  924. function _toElementDescriptors(elementObjects) {
  925. if (elementObjects === undefined) return;
  926. return _toArray(elementObjects).map(function (elementObject) {
  927. var element = _toElementDescriptor(elementObject);
  928. _disallowProperty(elementObject, "finisher", "An element descriptor");
  929. _disallowProperty(elementObject, "extras", "An element descriptor");
  930. return element;
  931. });
  932. }
  933. function _toElementDescriptor(elementObject) {
  934. var kind = String(elementObject.kind);
  935. if (kind !== "method" && kind !== "field") {
  936. 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 + '"');
  937. }
  938. var key = _toPropertyKey(elementObject.key);
  939. var placement = String(elementObject.placement);
  940. if (placement !== "static" && placement !== "prototype" && placement !== "own") {
  941. 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 + '"');
  942. }
  943. var descriptor = elementObject.descriptor;
  944. _disallowProperty(elementObject, "elements", "An element descriptor");
  945. var element = {
  946. kind: kind,
  947. key: key,
  948. placement: placement,
  949. descriptor: Object.assign({}, descriptor)
  950. };
  951. if (kind !== "field") {
  952. _disallowProperty(elementObject, "initializer", "A method descriptor");
  953. } else {
  954. _disallowProperty(descriptor, "get", "The property descriptor of a field descriptor");
  955. _disallowProperty(descriptor, "set", "The property descriptor of a field descriptor");
  956. _disallowProperty(descriptor, "value", "The property descriptor of a field descriptor");
  957. element.initializer = elementObject.initializer;
  958. }
  959. return element;
  960. }
  961. function _toElementFinisherExtras(elementObject) {
  962. var element = _toElementDescriptor(elementObject);
  963. var finisher = _optionalCallableProperty(elementObject, "finisher");
  964. var extras = _toElementDescriptors(elementObject.extras);
  965. return {
  966. element: element,
  967. finisher: finisher,
  968. extras: extras
  969. };
  970. }
  971. function _fromClassDescriptor(elements) {
  972. var obj = {
  973. kind: "class",
  974. elements: elements.map(_fromElementDescriptor)
  975. };
  976. var desc = {
  977. value: "Descriptor",
  978. configurable: true
  979. };
  980. Object.defineProperty(obj, Symbol.toStringTag, desc);
  981. return obj;
  982. }
  983. function _toClassDescriptor(obj) {
  984. var kind = String(obj.kind);
  985. if (kind !== "class") {
  986. throw new TypeError('A class descriptor\'s .kind property must be "class", but a decorator' + ' created a class descriptor with .kind "' + kind + '"');
  987. }
  988. _disallowProperty(obj, "key", "A class descriptor");
  989. _disallowProperty(obj, "placement", "A class descriptor");
  990. _disallowProperty(obj, "descriptor", "A class descriptor");
  991. _disallowProperty(obj, "initializer", "A class descriptor");
  992. _disallowProperty(obj, "extras", "A class descriptor");
  993. var finisher = _optionalCallableProperty(obj, "finisher");
  994. var elements = _toElementDescriptors(obj.elements);
  995. return {
  996. elements: elements,
  997. finisher: finisher
  998. };
  999. }
  1000. function _disallowProperty(obj, name, objectType) {
  1001. if (obj[name] !== undefined) {
  1002. throw new TypeError(objectType + " can't have a ." + name + " property.");
  1003. }
  1004. }
  1005. function _optionalCallableProperty(obj, name) {
  1006. var value = obj[name];
  1007. if (value !== undefined && typeof value !== "function") {
  1008. throw new TypeError("Expected '" + name + "' to be a function");
  1009. }
  1010. return value;
  1011. }
  1012. var json = createCommonjsModule(function (module, exports) {
  1013. /*istanbul ignore start*/
  1014. 'use strict';
  1015. exports.__esModule = true;
  1016. exports.jsonDiff = undefined;
  1017. var _typeof$$1 = typeof Symbol === "function" && _typeof(Symbol.iterator) === "symbol" ? function (obj) {
  1018. return _typeof(obj);
  1019. } : function (obj) {
  1020. return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : _typeof(obj);
  1021. };
  1022. exports.
  1023. /*istanbul ignore end*/
  1024. diffJson = diffJson;
  1025. /*istanbul ignore start*/
  1026. exports.
  1027. /*istanbul ignore end*/
  1028. canonicalize = canonicalize;
  1029. /*istanbul ignore start*/
  1030. var _base2 = _interopRequireDefault$$1(base);
  1031. /*istanbul ignore end*/
  1032. /*istanbul ignore start*/
  1033. function _interopRequireDefault$$1(obj) {
  1034. return obj && obj.__esModule ? obj : {
  1035. 'default': obj
  1036. };
  1037. }
  1038. /*istanbul ignore end*/
  1039. var objectPrototypeToString = Object.prototype.toString;
  1040. var jsonDiff =
  1041. /*istanbul ignore start*/
  1042. exports.
  1043. /*istanbul ignore end*/
  1044. jsonDiff = new
  1045. /*istanbul ignore start*/
  1046. _base2['default'](); // Discriminate between two lines of pretty-printed, serialized JSON where one of them has a
  1047. // dangling comma and the other doesn't. Turns out including the dangling comma yields the nicest output:
  1048. jsonDiff.useLongestToken = true;
  1049. jsonDiff.tokenize =
  1050. /*istanbul ignore start*/
  1051. line.lineDiff.
  1052. /*istanbul ignore end*/
  1053. tokenize;
  1054. jsonDiff.castInput = function (value) {
  1055. /*istanbul ignore start*/
  1056. var
  1057. /*istanbul ignore end*/
  1058. undefinedReplacement = this.options.undefinedReplacement;
  1059. return typeof value === 'string' ? value : JSON.stringify(canonicalize(value), function (k, v) {
  1060. if (typeof v === 'undefined') {
  1061. return undefinedReplacement;
  1062. }
  1063. return v;
  1064. }, ' ');
  1065. };
  1066. jsonDiff.equals = function (left, right) {
  1067. return (
  1068. /*istanbul ignore start*/
  1069. _base2['default'].
  1070. /*istanbul ignore end*/
  1071. prototype.equals(left.replace(/,([\r\n])/g, '$1'), right.replace(/,([\r\n])/g, '$1'))
  1072. );
  1073. };
  1074. function diffJson(oldObj, newObj, options) {
  1075. return jsonDiff.diff(oldObj, newObj, options);
  1076. } // This function handles the presence of circular references by bailing out when encountering an
  1077. // object that is already on the "stack" of items being processed.
  1078. function canonicalize(obj, stack, replacementStack) {
  1079. stack = stack || [];
  1080. replacementStack = replacementStack || [];
  1081. var i =
  1082. /*istanbul ignore start*/
  1083. void 0;
  1084. for (i = 0; i < stack.length; i += 1) {
  1085. if (stack[i] === obj) {
  1086. return replacementStack[i];
  1087. }
  1088. }
  1089. var canonicalizedObj =
  1090. /*istanbul ignore start*/
  1091. void 0;
  1092. if ('[object Array]' === objectPrototypeToString.call(obj)) {
  1093. stack.push(obj);
  1094. canonicalizedObj = new Array(obj.length);
  1095. replacementStack.push(canonicalizedObj);
  1096. for (i = 0; i < obj.length; i += 1) {
  1097. canonicalizedObj[i] = canonicalize(obj[i], stack, replacementStack);
  1098. }
  1099. stack.pop();
  1100. replacementStack.pop();
  1101. return canonicalizedObj;
  1102. }
  1103. if (obj && obj.toJSON) {
  1104. obj = obj.toJSON();
  1105. }
  1106. if (
  1107. /*istanbul ignore start*/
  1108. (typeof
  1109. /*istanbul ignore end*/
  1110. obj === 'undefined' ? 'undefined' : _typeof$$1(obj)) === 'object' && obj !== null) {
  1111. stack.push(obj);
  1112. canonicalizedObj = {};
  1113. replacementStack.push(canonicalizedObj);
  1114. var sortedKeys = [],
  1115. key =
  1116. /*istanbul ignore start*/
  1117. void 0;
  1118. for (key in obj) {
  1119. /* istanbul ignore else */
  1120. if (obj.hasOwnProperty(key)) {
  1121. sortedKeys.push(key);
  1122. }
  1123. }
  1124. sortedKeys.sort();
  1125. for (i = 0; i < sortedKeys.length; i += 1) {
  1126. key = sortedKeys[i];
  1127. canonicalizedObj[key] = canonicalize(obj[key], stack, replacementStack);
  1128. }
  1129. stack.pop();
  1130. replacementStack.pop();
  1131. } else {
  1132. canonicalizedObj = obj;
  1133. }
  1134. return canonicalizedObj;
  1135. }
  1136. });
  1137. unwrapExports(json);
  1138. var array = createCommonjsModule(function (module, exports) {
  1139. /*istanbul ignore start*/
  1140. 'use strict';
  1141. exports.__esModule = true;
  1142. exports.arrayDiff = undefined;
  1143. exports.
  1144. /*istanbul ignore end*/
  1145. diffArrays = diffArrays;
  1146. /*istanbul ignore start*/
  1147. var _base2 = _interopRequireDefault(base);
  1148. function _interopRequireDefault(obj) {
  1149. return obj && obj.__esModule ? obj : {
  1150. 'default': obj
  1151. };
  1152. }
  1153. /*istanbul ignore end*/
  1154. var arrayDiff =
  1155. /*istanbul ignore start*/
  1156. exports.
  1157. /*istanbul ignore end*/
  1158. arrayDiff = new
  1159. /*istanbul ignore start*/
  1160. _base2['default']();
  1161. arrayDiff.tokenize = arrayDiff.join = function (value) {
  1162. return value.slice();
  1163. };
  1164. function diffArrays(oldArr, newArr, callback) {
  1165. return arrayDiff.diff(oldArr, newArr, callback);
  1166. }
  1167. });
  1168. unwrapExports(array);
  1169. var parse = createCommonjsModule(function (module, exports) {
  1170. /*istanbul ignore start*/
  1171. 'use strict';
  1172. exports.__esModule = true;
  1173. exports.
  1174. /*istanbul ignore end*/
  1175. parsePatch = parsePatch;
  1176. function parsePatch(uniDiff) {
  1177. /*istanbul ignore start*/
  1178. var
  1179. /*istanbul ignore end*/
  1180. options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
  1181. var diffstr = uniDiff.split(/\r\n|[\n\v\f\r\x85]/),
  1182. delimiters = uniDiff.match(/\r\n|[\n\v\f\r\x85]/g) || [],
  1183. list = [],
  1184. i = 0;
  1185. function parseIndex() {
  1186. var index = {};
  1187. list.push(index); // Parse diff metadata
  1188. while (i < diffstr.length) {
  1189. var line = diffstr[i]; // File header found, end parsing diff metadata
  1190. if (/^(\-\-\-|\+\+\+|@@)\s/.test(line)) {
  1191. break;
  1192. } // Diff index
  1193. var header = /^(?:Index:|diff(?: -r \w+)+)\s+(.+?)\s*$/.exec(line);
  1194. if (header) {
  1195. index.index = header[1];
  1196. }
  1197. i++;
  1198. } // Parse file headers if they are defined. Unified diff requires them, but
  1199. // there's no technical issues to have an isolated hunk without file header
  1200. parseFileHeader(index);
  1201. parseFileHeader(index); // Parse hunks
  1202. index.hunks = [];
  1203. while (i < diffstr.length) {
  1204. var _line = diffstr[i];
  1205. if (/^(Index:|diff|\-\-\-|\+\+\+)\s/.test(_line)) {
  1206. break;
  1207. } else if (/^@@/.test(_line)) {
  1208. index.hunks.push(parseHunk());
  1209. } else if (_line && options.strict) {
  1210. // Ignore unexpected content unless in strict mode
  1211. throw new Error('Unknown line ' + (i + 1) + ' ' + JSON.stringify(_line));
  1212. } else {
  1213. i++;
  1214. }
  1215. }
  1216. } // Parses the --- and +++ headers, if none are found, no lines
  1217. // are consumed.
  1218. function parseFileHeader(index) {
  1219. var headerPattern = /^(---|\+\+\+)\s+([\S ]*)(?:\t(.*?)\s*)?$/;
  1220. var fileHeader = headerPattern.exec(diffstr[i]);
  1221. if (fileHeader) {
  1222. var keyPrefix = fileHeader[1] === '---' ? 'old' : 'new';
  1223. index[keyPrefix + 'FileName'] = fileHeader[2];
  1224. index[keyPrefix + 'Header'] = fileHeader[3];
  1225. i++;
  1226. }
  1227. } // Parses a hunk
  1228. // This assumes that we are at the start of a hunk.
  1229. function parseHunk() {
  1230. var chunkHeaderIndex = i,
  1231. chunkHeaderLine = diffstr[i++],
  1232. chunkHeader = chunkHeaderLine.split(/@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/);
  1233. var hunk = {
  1234. oldStart: +chunkHeader[1],
  1235. oldLines: +chunkHeader[2] || 1,
  1236. newStart: +chunkHeader[3],
  1237. newLines: +chunkHeader[4] || 1,
  1238. lines: [],
  1239. linedelimiters: []
  1240. };
  1241. var addCount = 0,
  1242. removeCount = 0;
  1243. for (; i < diffstr.length; i++) {
  1244. // Lines starting with '---' could be mistaken for the "remove line" operation
  1245. // But they could be the header for the next file. Therefore prune such cases out.
  1246. if (diffstr[i].indexOf('--- ') === 0 && i + 2 < diffstr.length && diffstr[i + 1].indexOf('+++ ') === 0 && diffstr[i + 2].indexOf('@@') === 0) {
  1247. break;
  1248. }
  1249. var operation = diffstr[i][0];
  1250. if (operation === '+' || operation === '-' || operation === ' ' || operation === '\\') {
  1251. hunk.lines.push(diffstr[i]);
  1252. hunk.linedelimiters.push(delimiters[i] || '\n');
  1253. if (operation === '+') {
  1254. addCount++;
  1255. } else if (operation === '-') {
  1256. removeCount++;
  1257. } else if (operation === ' ') {
  1258. addCount++;
  1259. removeCount++;
  1260. }
  1261. } else {
  1262. break;
  1263. }
  1264. } // Handle the empty block count case
  1265. if (!addCount && hunk.newLines === 1) {
  1266. hunk.newLines = 0;
  1267. }
  1268. if (!removeCount && hunk.oldLines === 1) {
  1269. hunk.oldLines = 0;
  1270. } // Perform optional sanity checking
  1271. if (options.strict) {
  1272. if (addCount !== hunk.newLines) {
  1273. throw new Error('Added line count did not match for hunk at line ' + (chunkHeaderIndex + 1));
  1274. }
  1275. if (removeCount !== hunk.oldLines) {
  1276. throw new Error('Removed line count did not match for hunk at line ' + (chunkHeaderIndex + 1));
  1277. }
  1278. }
  1279. return hunk;
  1280. }
  1281. while (i < diffstr.length) {
  1282. parseIndex();
  1283. }
  1284. return list;
  1285. }
  1286. });
  1287. unwrapExports(parse);
  1288. var distanceIterator = createCommonjsModule(function (module, exports) {
  1289. /*istanbul ignore start*/
  1290. "use strict";
  1291. exports.__esModule = true;
  1292. exports["default"] =
  1293. /*istanbul ignore end*/
  1294. function (start, minLine, maxLine) {
  1295. var wantForward = true,
  1296. backwardExhausted = false,
  1297. forwardExhausted = false,
  1298. localOffset = 1;
  1299. return function iterator() {
  1300. if (wantForward && !forwardExhausted) {
  1301. if (backwardExhausted) {
  1302. localOffset++;
  1303. } else {
  1304. wantForward = false;
  1305. } // Check if trying to fit beyond text length, and if not, check it fits
  1306. // after offset location (or desired location on first iteration)
  1307. if (start + localOffset <= maxLine) {
  1308. return localOffset;
  1309. }
  1310. forwardExhausted = true;
  1311. }
  1312. if (!backwardExhausted) {
  1313. if (!forwardExhausted) {
  1314. wantForward = true;
  1315. } // Check if trying to fit before text beginning, and if not, check it fits
  1316. // before offset location
  1317. if (minLine <= start - localOffset) {
  1318. return -localOffset++;
  1319. }
  1320. backwardExhausted = true;
  1321. return iterator();
  1322. } // We tried to fit hunk before text beginning and beyond text lenght, then
  1323. // hunk can't fit on the text. Return undefined
  1324. };
  1325. };
  1326. });
  1327. unwrapExports(distanceIterator);
  1328. var apply = createCommonjsModule(function (module, exports) {
  1329. /*istanbul ignore start*/
  1330. 'use strict';
  1331. exports.__esModule = true;
  1332. exports.
  1333. /*istanbul ignore end*/
  1334. applyPatch = applyPatch;
  1335. /*istanbul ignore start*/
  1336. exports.
  1337. /*istanbul ignore end*/
  1338. applyPatches = applyPatches;
  1339. /*istanbul ignore start*/
  1340. var _distanceIterator2 = _interopRequireDefault(distanceIterator);
  1341. function _interopRequireDefault(obj) {
  1342. return obj && obj.__esModule ? obj : {
  1343. 'default': obj
  1344. };
  1345. }
  1346. /*istanbul ignore end*/
  1347. function applyPatch(source, uniDiff) {
  1348. /*istanbul ignore start*/
  1349. var
  1350. /*istanbul ignore end*/
  1351. options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];
  1352. if (typeof uniDiff === 'string') {
  1353. uniDiff =
  1354. /*istanbul ignore start*/
  1355. (0, parse.parsePatch
  1356. /*istanbul ignore end*/
  1357. )(uniDiff);
  1358. }
  1359. if (Array.isArray(uniDiff)) {
  1360. if (uniDiff.length > 1) {
  1361. throw new Error('applyPatch only works with a single input.');
  1362. }
  1363. uniDiff = uniDiff[0];
  1364. } // Apply the diff to the input
  1365. var lines = source.split(/\r\n|[\n\v\f\r\x85]/),
  1366. delimiters = source.match(/\r\n|[\n\v\f\r\x85]/g) || [],
  1367. hunks = uniDiff.hunks,
  1368. compareLine = options.compareLine || function (lineNumber, line, operation, patchContent)
  1369. /*istanbul ignore start*/
  1370. {
  1371. return (
  1372. /*istanbul ignore end*/
  1373. line === patchContent
  1374. );
  1375. },
  1376. errorCount = 0,
  1377. fuzzFactor = options.fuzzFactor || 0,
  1378. minLine = 0,
  1379. offset = 0,
  1380. removeEOFNL =
  1381. /*istanbul ignore start*/
  1382. void 0
  1383. /*istanbul ignore end*/
  1384. ,
  1385. addEOFNL =
  1386. /*istanbul ignore start*/
  1387. void 0;
  1388. /**
  1389. * Checks if the hunk exactly fits on the provided location
  1390. */
  1391. function hunkFits(hunk, toPos) {
  1392. for (var j = 0; j < hunk.lines.length; j++) {
  1393. var line = hunk.lines[j],
  1394. operation = line[0],
  1395. content = line.substr(1);
  1396. if (operation === ' ' || operation === '-') {
  1397. // Context sanity check
  1398. if (!compareLine(toPos + 1, lines[toPos], operation, content)) {
  1399. errorCount++;
  1400. if (errorCount > fuzzFactor) {
  1401. return false;
  1402. }
  1403. }
  1404. toPos++;
  1405. }
  1406. }
  1407. return true;
  1408. } // Search best fit offsets for each hunk based on the previous ones
  1409. for (var i = 0; i < hunks.length; i++) {
  1410. var hunk = hunks[i],
  1411. maxLine = lines.length - hunk.oldLines,
  1412. localOffset = 0,
  1413. toPos = offset + hunk.oldStart - 1;
  1414. var iterator =
  1415. /*istanbul ignore start*/
  1416. (0, _distanceIterator2['default']
  1417. /*istanbul ignore end*/
  1418. )(toPos, minLine, maxLine);
  1419. for (; localOffset !== undefined; localOffset = iterator()) {
  1420. if (hunkFits(hunk, toPos + localOffset)) {
  1421. hunk.offset = offset += localOffset;
  1422. break;
  1423. }
  1424. }
  1425. if (localOffset === undefined) {
  1426. return false;
  1427. } // Set lower text limit to end of the current hunk, so next ones don't try
  1428. // to fit over already patched text
  1429. minLine = hunk.offset + hunk.oldStart + hunk.oldLines;
  1430. } // Apply patch hunks
  1431. for (var _i = 0; _i < hunks.length; _i++) {
  1432. var _hunk = hunks[_i],
  1433. _toPos = _hunk.offset + _hunk.newStart - 1;
  1434. if (_hunk.newLines == 0) {
  1435. _toPos++;
  1436. }
  1437. for (var j = 0; j < _hunk.lines.length; j++) {
  1438. var line = _hunk.lines[j],
  1439. operation = line[0],
  1440. content = line.substr(1),
  1441. delimiter = _hunk.linedelimiters[j];
  1442. if (operation === ' ') {
  1443. _toPos++;
  1444. } else if (operation === '-') {
  1445. lines.splice(_toPos, 1);
  1446. delimiters.splice(_toPos, 1);
  1447. /* istanbul ignore else */
  1448. } else if (operation === '+') {
  1449. lines.splice(_toPos, 0, content);
  1450. delimiters.splice(_toPos, 0, delimiter);
  1451. _toPos++;
  1452. } else if (operation === '\\') {
  1453. var previousOperation = _hunk.lines[j - 1] ? _hunk.lines[j - 1][0] : null;
  1454. if (previousOperation === '+') {
  1455. removeEOFNL = true;
  1456. } else if (previousOperation === '-') {
  1457. addEOFNL = true;
  1458. }
  1459. }
  1460. }
  1461. } // Handle EOFNL insertion/removal
  1462. if (removeEOFNL) {
  1463. while (!lines[lines.length - 1]) {
  1464. lines.pop();
  1465. delimiters.pop();
  1466. }
  1467. } else if (addEOFNL) {
  1468. lines.push('');
  1469. delimiters.push('\n');
  1470. }
  1471. for (var _k = 0; _k < lines.length - 1; _k++) {
  1472. lines[_k] = lines[_k] + delimiters[_k];
  1473. }
  1474. return lines.join('');
  1475. } // Wrapper that supports multiple file patches via callbacks.
  1476. function applyPatches(uniDiff, options) {
  1477. if (typeof uniDiff === 'string') {
  1478. uniDiff =
  1479. /*istanbul ignore start*/
  1480. (0, parse.parsePatch
  1481. /*istanbul ignore end*/
  1482. )(uniDiff);
  1483. }
  1484. var currentIndex = 0;
  1485. function processIndex() {
  1486. var index = uniDiff[currentIndex++];
  1487. if (!index) {
  1488. return options.complete();
  1489. }
  1490. options.loadFile(index, function (err, data) {
  1491. if (err) {
  1492. return options.complete(err);
  1493. }
  1494. var updatedContent = applyPatch(data, index, options);
  1495. options.patched(index, updatedContent, function (err) {
  1496. if (err) {
  1497. return options.complete(err);
  1498. }
  1499. processIndex();
  1500. });
  1501. });
  1502. }
  1503. processIndex();
  1504. }
  1505. });
  1506. unwrapExports(apply);
  1507. var create = createCommonjsModule(function (module, exports) {
  1508. /*istanbul ignore start*/
  1509. 'use strict';
  1510. exports.__esModule = true;
  1511. exports.
  1512. /*istanbul ignore end*/
  1513. structuredPatch = structuredPatch;
  1514. /*istanbul ignore start*/
  1515. exports.
  1516. /*istanbul ignore end*/
  1517. createTwoFilesPatch = createTwoFilesPatch;
  1518. /*istanbul ignore start*/
  1519. exports.
  1520. /*istanbul ignore end*/
  1521. createPatch = createPatch;
  1522. /*istanbul ignore start*/
  1523. function _toConsumableArray(arr) {
  1524. if (Array.isArray(arr)) {
  1525. for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) {
  1526. arr2[i] = arr[i];
  1527. }
  1528. return arr2;
  1529. } else {
  1530. return Array.from(arr);
  1531. }
  1532. }
  1533. /*istanbul ignore end*/
  1534. function structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
  1535. if (!options) {
  1536. options = {};
  1537. }
  1538. if (typeof options.context === 'undefined') {
  1539. options.context = 4;
  1540. }
  1541. var diff =
  1542. /*istanbul ignore start*/
  1543. (0, line.diffLines
  1544. /*istanbul ignore end*/
  1545. )(oldStr, newStr, options);
  1546. diff.push({
  1547. value: '',
  1548. lines: []
  1549. }); // Append an empty value to make cleanup easier
  1550. function contextLines(lines) {
  1551. return lines.map(function (entry) {
  1552. return ' ' + entry;
  1553. });
  1554. }
  1555. var hunks = [];
  1556. var oldRangeStart = 0,
  1557. newRangeStart = 0,
  1558. curRange = [],
  1559. oldLine = 1,
  1560. newLine = 1;
  1561. /*istanbul ignore start*/
  1562. var _loop = function _loop(
  1563. /*istanbul ignore end*/
  1564. i) {
  1565. var current = diff[i],
  1566. lines = current.lines || current.value.replace(/\n$/, '').split('\n');
  1567. current.lines = lines;
  1568. if (current.added || current.removed) {
  1569. /*istanbul ignore start*/
  1570. var _curRange;
  1571. /*istanbul ignore end*/
  1572. // If we have previous context, start with that
  1573. if (!oldRangeStart) {
  1574. var prev = diff[i - 1];
  1575. oldRangeStart = oldLine;
  1576. newRangeStart = newLine;
  1577. if (prev) {
  1578. curRange = options.context > 0 ? contextLines(prev.lines.slice(-options.context)) : [];
  1579. oldRangeStart -= curRange.length;
  1580. newRangeStart -= curRange.length;
  1581. }
  1582. } // Output our changes
  1583. /*istanbul ignore start*/
  1584. (_curRange =
  1585. /*istanbul ignore end*/
  1586. curRange).push.
  1587. /*istanbul ignore start*/
  1588. apply
  1589. /*istanbul ignore end*/
  1590. (
  1591. /*istanbul ignore start*/
  1592. _curRange
  1593. /*istanbul ignore end*/
  1594. ,
  1595. /*istanbul ignore start*/
  1596. _toConsumableArray(
  1597. /*istanbul ignore end*/
  1598. lines.map(function (entry) {
  1599. return (current.added ? '+' : '-') + entry;
  1600. }))); // Track the updated file position
  1601. if (current.added) {
  1602. newLine += lines.length;
  1603. } else {
  1604. oldLine += lines.length;
  1605. }
  1606. } else {
  1607. // Identical context lines. Track line changes
  1608. if (oldRangeStart) {
  1609. // Close out any changes that have been output (or join overlapping)
  1610. if (lines.length <= options.context * 2 && i < diff.length - 2) {
  1611. /*istanbul ignore start*/
  1612. var _curRange2;
  1613. /*istanbul ignore end*/
  1614. // Overlapping
  1615. /*istanbul ignore start*/
  1616. (_curRange2 =
  1617. /*istanbul ignore end*/
  1618. curRange).push.
  1619. /*istanbul ignore start*/
  1620. apply
  1621. /*istanbul ignore end*/
  1622. (
  1623. /*istanbul ignore start*/
  1624. _curRange2
  1625. /*istanbul ignore end*/
  1626. ,
  1627. /*istanbul ignore start*/
  1628. _toConsumableArray(
  1629. /*istanbul ignore end*/
  1630. contextLines(lines)));
  1631. } else {
  1632. /*istanbul ignore start*/
  1633. var _curRange3;
  1634. /*istanbul ignore end*/
  1635. // end the range and output
  1636. var contextSize = Math.min(lines.length, options.context);
  1637. /*istanbul ignore start*/
  1638. (_curRange3 =
  1639. /*istanbul ignore end*/
  1640. curRange).push.
  1641. /*istanbul ignore start*/
  1642. apply
  1643. /*istanbul ignore end*/
  1644. (
  1645. /*istanbul ignore start*/
  1646. _curRange3
  1647. /*istanbul ignore end*/
  1648. ,
  1649. /*istanbul ignore start*/
  1650. _toConsumableArray(
  1651. /*istanbul ignore end*/
  1652. contextLines(lines.slice(0, contextSize))));
  1653. var hunk = {
  1654. oldStart: oldRangeStart,
  1655. oldLines: oldLine - oldRangeStart + contextSize,
  1656. newStart: newRangeStart,
  1657. newLines: newLine - newRangeStart + contextSize,
  1658. lines: curRange
  1659. };
  1660. if (i >= diff.length - 2 && lines.length <= options.context) {
  1661. // EOF is inside this hunk
  1662. var oldEOFNewline = /\n$/.test(oldStr);
  1663. var newEOFNewline = /\n$/.test(newStr);
  1664. if (lines.length == 0 && !oldEOFNewline) {
  1665. // special case: old has no eol and no trailing context; no-nl can end up before adds
  1666. curRange.splice(hunk.oldLines, 0, '\\ No newline at end of file');
  1667. } else if (!oldEOFNewline || !newEOFNewline) {
  1668. curRange.push('\\ No newline at end of file');
  1669. }
  1670. }
  1671. hunks.push(hunk);
  1672. oldRangeStart = 0;
  1673. newRangeStart = 0;
  1674. curRange = [];
  1675. }
  1676. }
  1677. oldLine += lines.length;
  1678. newLine += lines.length;
  1679. }
  1680. };
  1681. for (var i = 0; i < diff.length; i++) {
  1682. /*istanbul ignore start*/
  1683. _loop(
  1684. /*istanbul ignore end*/
  1685. i);
  1686. }
  1687. return {
  1688. oldFileName: oldFileName,
  1689. newFileName: newFileName,
  1690. oldHeader: oldHeader,
  1691. newHeader: newHeader,
  1692. hunks: hunks
  1693. };
  1694. }
  1695. function createTwoFilesPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
  1696. var diff = structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options);
  1697. var ret = [];
  1698. if (oldFileName == newFileName) {
  1699. ret.push('Index: ' + oldFileName);
  1700. }
  1701. ret.push('===================================================================');
  1702. ret.push('--- ' + diff.oldFileName + (typeof diff.oldHeader === 'undefined' ? '' : '\t' + diff.oldHeader));
  1703. ret.push('+++ ' + diff.newFileName + (typeof diff.newHeader === 'undefined' ? '' : '\t' + diff.newHeader));
  1704. for (var i = 0; i < diff.hunks.length; i++) {
  1705. var hunk = diff.hunks[i];
  1706. ret.push('@@ -' + hunk.oldStart + ',' + hunk.oldLines + ' +' + hunk.newStart + ',' + hunk.newLines + ' @@');
  1707. ret.push.apply(ret, hunk.lines);
  1708. }
  1709. return ret.join('\n') + '\n';
  1710. }
  1711. function createPatch(fileName, oldStr, newStr, oldHeader, newHeader, options) {
  1712. return createTwoFilesPatch(fileName, fileName, oldStr, newStr, oldHeader, newHeader, options);
  1713. }
  1714. });
  1715. unwrapExports(create);
  1716. var dmp = createCommonjsModule(function (module, exports) {
  1717. /*istanbul ignore start*/
  1718. "use strict";
  1719. exports.__esModule = true;
  1720. exports.
  1721. /*istanbul ignore end*/
  1722. convertChangesToDMP = convertChangesToDMP; // See: http://code.google.com/p/google-diff-match-patch/wiki/API
  1723. function convertChangesToDMP(changes) {
  1724. var ret = [],
  1725. change =
  1726. /*istanbul ignore start*/
  1727. void 0
  1728. /*istanbul ignore end*/
  1729. ,
  1730. operation =
  1731. /*istanbul ignore start*/
  1732. void 0;
  1733. for (var i = 0; i < changes.length; i++) {
  1734. change = changes[i];
  1735. if (change.added) {
  1736. operation = 1;
  1737. } else if (change.removed) {
  1738. operation = -1;
  1739. } else {
  1740. operation = 0;
  1741. }
  1742. ret.push([operation, change.value]);
  1743. }
  1744. return ret;
  1745. }
  1746. });
  1747. unwrapExports(dmp);
  1748. var xml = createCommonjsModule(function (module, exports) {
  1749. /*istanbul ignore start*/
  1750. 'use strict';
  1751. exports.__esModule = true;
  1752. exports.
  1753. /*istanbul ignore end*/
  1754. convertChangesToXML = convertChangesToXML;
  1755. function convertChangesToXML(changes) {
  1756. var ret = [];
  1757. for (var i = 0; i < changes.length; i++) {
  1758. var change = changes[i];
  1759. if (change.added) {
  1760. ret.push('<ins>');
  1761. } else if (change.removed) {
  1762. ret.push('<del>');
  1763. }
  1764. ret.push(escapeHTML(change.value));
  1765. if (change.added) {
  1766. ret.push('</ins>');
  1767. } else if (change.removed) {
  1768. ret.push('</del>');
  1769. }
  1770. }
  1771. return ret.join('');
  1772. }
  1773. function escapeHTML(s) {
  1774. var n = s;
  1775. n = n.replace(/&/g, '&amp;');
  1776. n = n.replace(/</g, '&lt;');
  1777. n = n.replace(/>/g, '&gt;');
  1778. n = n.replace(/"/g, '&quot;');
  1779. return n;
  1780. }
  1781. });
  1782. unwrapExports(xml);
  1783. var lib = createCommonjsModule(function (module, exports) {
  1784. /*istanbul ignore start*/
  1785. 'use strict';
  1786. exports.__esModule = true;
  1787. 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;
  1788. /*istanbul ignore end*/
  1789. /*istanbul ignore start*/
  1790. var _base2 = _interopRequireDefault(base);
  1791. /*istanbul ignore end*/
  1792. /*istanbul ignore start*/
  1793. function _interopRequireDefault(obj) {
  1794. return obj && obj.__esModule ? obj : {
  1795. 'default': obj
  1796. };
  1797. }
  1798. exports.
  1799. /*istanbul ignore end*/
  1800. Diff = _base2['default'];
  1801. /*istanbul ignore start*/
  1802. exports.
  1803. /*istanbul ignore end*/
  1804. diffChars = character.diffChars;
  1805. /*istanbul ignore start*/
  1806. exports.
  1807. /*istanbul ignore end*/
  1808. diffWords = word.diffWords;
  1809. /*istanbul ignore start*/
  1810. exports.
  1811. /*istanbul ignore end*/
  1812. diffWordsWithSpace = word.diffWordsWithSpace;
  1813. /*istanbul ignore start*/
  1814. exports.
  1815. /*istanbul ignore end*/
  1816. diffLines = line.diffLines;
  1817. /*istanbul ignore start*/
  1818. exports.
  1819. /*istanbul ignore end*/
  1820. diffTrimmedLines = line.diffTrimmedLines;
  1821. /*istanbul ignore start*/
  1822. exports.
  1823. /*istanbul ignore end*/
  1824. diffSentences = sentence.diffSentences;
  1825. /*istanbul ignore start*/
  1826. exports.
  1827. /*istanbul ignore end*/
  1828. diffCss = css.diffCss;
  1829. /*istanbul ignore start*/
  1830. exports.
  1831. /*istanbul ignore end*/
  1832. diffJson = json.diffJson;
  1833. /*istanbul ignore start*/
  1834. exports.
  1835. /*istanbul ignore end*/
  1836. diffArrays = array.diffArrays;
  1837. /*istanbul ignore start*/
  1838. exports.
  1839. /*istanbul ignore end*/
  1840. structuredPatch = create.structuredPatch;
  1841. /*istanbul ignore start*/
  1842. exports.
  1843. /*istanbul ignore end*/
  1844. createTwoFilesPatch = create.createTwoFilesPatch;
  1845. /*istanbul ignore start*/
  1846. exports.
  1847. /*istanbul ignore end*/
  1848. createPatch = create.createPatch;
  1849. /*istanbul ignore start*/
  1850. exports.
  1851. /*istanbul ignore end*/
  1852. applyPatch = apply.applyPatch;
  1853. /*istanbul ignore start*/
  1854. exports.
  1855. /*istanbul ignore end*/
  1856. applyPatches = apply.applyPatches;
  1857. /*istanbul ignore start*/
  1858. exports.
  1859. /*istanbul ignore end*/
  1860. parsePatch = parse.parsePatch;
  1861. /*istanbul ignore start*/
  1862. exports.
  1863. /*istanbul ignore end*/
  1864. convertChangesToDMP = dmp.convertChangesToDMP;
  1865. /*istanbul ignore start*/
  1866. exports.
  1867. /*istanbul ignore end*/
  1868. convertChangesToXML = xml.convertChangesToXML;
  1869. /*istanbul ignore start*/
  1870. exports.
  1871. /*istanbul ignore end*/
  1872. canonicalize = json.canonicalize;
  1873. /* See LICENSE file for terms of use */
  1874. /*
  1875. * Text diff implementation.
  1876. *
  1877. * This library supports the following APIS:
  1878. * JsDiff.diffChars: Character by character diff
  1879. * JsDiff.diffWords: Word (as defined by \b regex) diff which ignores whitespace
  1880. * JsDiff.diffLines: Line based diff
  1881. *
  1882. * JsDiff.diffCss: Diff targeted at CSS content
  1883. *
  1884. * These methods are based on the implementation proposed in
  1885. * "An O(ND) Difference Algorithm and its Variations" (Myers, 1986).
  1886. * http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.4.6927
  1887. */
  1888. });
  1889. unwrapExports(lib);
  1890. var _shim_fs = {};
  1891. var _shim_fs$1 = Object.freeze({
  1892. default: _shim_fs
  1893. });
  1894. /*!
  1895. * normalize-path <https://github.com/jonschlinkert/normalize-path>
  1896. *
  1897. * Copyright (c) 2014-2018, Jon Schlinkert.
  1898. * Released under the MIT License.
  1899. */
  1900. var normalizePath = function normalizePath(path, stripTrailing) {
  1901. if (typeof path !== 'string') {
  1902. throw new TypeError('expected path to be a string');
  1903. }
  1904. if (path === '\\' || path === '/') return '/';
  1905. var len = path.length;
  1906. if (len <= 1) return path; // ensure that win32 namespaces has two leading slashes, so that the path is
  1907. // handled properly by the win32 version of path.parse() after being normalized
  1908. // https://msdn.microsoft.com/library/windows/desktop/aa365247(v=vs.85).aspx#namespaces
  1909. var prefix = '';
  1910. if (len > 4 && path[3] === '\\') {
  1911. var ch = path[2];
  1912. if ((ch === '?' || ch === '.') && path.slice(0, 2) === '\\\\') {
  1913. path = path.slice(2);
  1914. prefix = '//';
  1915. }
  1916. }
  1917. var segs = path.split(/[/\\]+/);
  1918. if (stripTrailing !== false && segs[segs.length - 1] === '') {
  1919. segs.pop();
  1920. }
  1921. return prefix + segs.join('/');
  1922. };
  1923. var global$1 = typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {};
  1924. var lookup = [];
  1925. var revLookup = [];
  1926. var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array;
  1927. var inited = false;
  1928. function init() {
  1929. inited = true;
  1930. var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
  1931. for (var i = 0, len = code.length; i < len; ++i) {
  1932. lookup[i] = code[i];
  1933. revLookup[code.charCodeAt(i)] = i;
  1934. }
  1935. revLookup['-'.charCodeAt(0)] = 62;
  1936. revLookup['_'.charCodeAt(0)] = 63;
  1937. }
  1938. function toByteArray(b64) {
  1939. if (!inited) {
  1940. init();
  1941. }
  1942. var i, j, l, tmp, placeHolders, arr;
  1943. var len = b64.length;
  1944. if (len % 4 > 0) {
  1945. throw new Error('Invalid string. Length must be a multiple of 4');
  1946. } // the number of equal signs (place holders)
  1947. // if there are two placeholders, than the two characters before it
  1948. // represent one byte
  1949. // if there is only one, then the three characters before it represent 2 bytes
  1950. // this is just a cheap hack to not do indexOf twice
  1951. placeHolders = b64[len - 2] === '=' ? 2 : b64[len - 1] === '=' ? 1 : 0; // base64 is 4/3 + up to two characters of the original data
  1952. arr = new Arr(len * 3 / 4 - placeHolders); // if there are placeholders, only get up to the last complete 4 chars
  1953. l = placeHolders > 0 ? len - 4 : len;
  1954. var L = 0;
  1955. for (i = 0, j = 0; i < l; i += 4, j += 3) {
  1956. tmp = revLookup[b64.charCodeAt(i)] << 18 | revLookup[b64.charCodeAt(i + 1)] << 12 | revLookup[b64.charCodeAt(i + 2)] << 6 | revLookup[b64.charCodeAt(i + 3)];
  1957. arr[L++] = tmp >> 16 & 0xFF;
  1958. arr[L++] = tmp >> 8 & 0xFF;
  1959. arr[L++] = tmp & 0xFF;
  1960. }
  1961. if (placeHolders === 2) {
  1962. tmp = revLookup[b64.charCodeAt(i)] << 2 | revLookup[b64.charCodeAt(i + 1)] >> 4;
  1963. arr[L++] = tmp & 0xFF;
  1964. } else if (placeHolders === 1) {
  1965. tmp = revLookup[b64.charCodeAt(i)] << 10 | revLookup[b64.charCodeAt(i + 1)] << 4 | revLookup[b64.charCodeAt(i + 2)] >> 2;
  1966. arr[L++] = tmp >> 8 & 0xFF;
  1967. arr[L++] = tmp & 0xFF;
  1968. }
  1969. return arr;
  1970. }
  1971. function tripletToBase64(num) {
  1972. return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F];
  1973. }
  1974. function encodeChunk(uint8, start, end) {
  1975. var tmp;
  1976. var output = [];
  1977. for (var i = start; i < end; i += 3) {
  1978. tmp = (uint8[i] << 16) + (uint8[i + 1] << 8) + uint8[i + 2];
  1979. output.push(tripletToBase64(tmp));
  1980. }
  1981. return output.join('');
  1982. }
  1983. function fromByteArray(uint8) {
  1984. if (!inited) {
  1985. init();
  1986. }
  1987. var tmp;
  1988. var len = uint8.length;
  1989. var extraBytes = len % 3; // if we have 1 byte left, pad 2 bytes
  1990. var output = '';
  1991. var parts = [];
  1992. var maxChunkLength = 16383; // must be multiple of 3
  1993. // go through the array every three bytes, we'll deal with trailing stuff later
  1994. for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
  1995. parts.push(encodeChunk(uint8, i, i + maxChunkLength > len2 ? len2 : i + maxChunkLength));
  1996. } // pad the end with zeros, but make sure to not forget the extra bytes
  1997. if (extraBytes === 1) {
  1998. tmp = uint8[len - 1];
  1999. output += lookup[tmp >> 2];
  2000. output += lookup[tmp << 4 & 0x3F];
  2001. output += '==';
  2002. } else if (extraBytes === 2) {
  2003. tmp = (uint8[len - 2] << 8) + uint8[len - 1];
  2004. output += lookup[tmp >> 10];
  2005. output += lookup[tmp >> 4 & 0x3F];
  2006. output += lookup[tmp << 2 & 0x3F];
  2007. output += '=';
  2008. }
  2009. parts.push(output);
  2010. return parts.join('');
  2011. }
  2012. function read(buffer, offset, isLE, mLen, nBytes) {
  2013. var e, m;
  2014. var eLen = nBytes * 8 - mLen - 1;
  2015. var eMax = (1 << eLen) - 1;
  2016. var eBias = eMax >> 1;
  2017. var nBits = -7;
  2018. var i = isLE ? nBytes - 1 : 0;
  2019. var d = isLE ? -1 : 1;
  2020. var s = buffer[offset + i];
  2021. i += d;
  2022. e = s & (1 << -nBits) - 1;
  2023. s >>= -nBits;
  2024. nBits += eLen;
  2025. for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {}
  2026. m = e & (1 << -nBits) - 1;
  2027. e >>= -nBits;
  2028. nBits += mLen;
  2029. for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {}
  2030. if (e === 0) {
  2031. e = 1 - eBias;
  2032. } else if (e === eMax) {
  2033. return m ? NaN : (s ? -1 : 1) * Infinity;
  2034. } else {
  2035. m = m + Math.pow(2, mLen);
  2036. e = e - eBias;
  2037. }
  2038. return (s ? -1 : 1) * m * Math.pow(2, e - mLen);
  2039. }
  2040. function write(buffer, value, offset, isLE, mLen, nBytes) {
  2041. var e, m, c;
  2042. var eLen = nBytes * 8 - mLen - 1;
  2043. var eMax = (1 << eLen) - 1;
  2044. var eBias = eMax >> 1;
  2045. var rt = mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0;
  2046. var i = isLE ? 0 : nBytes - 1;
  2047. var d = isLE ? 1 : -1;
  2048. var s = value < 0 || value === 0 && 1 / value < 0 ? 1 : 0;
  2049. value = Math.abs(value);
  2050. if (isNaN(value) || value === Infinity) {
  2051. m = isNaN(value) ? 1 : 0;
  2052. e = eMax;
  2053. } else {
  2054. e = Math.floor(Math.log(value) / Math.LN2);
  2055. if (value * (c = Math.pow(2, -e)) < 1) {
  2056. e--;
  2057. c *= 2;
  2058. }
  2059. if (e + eBias >= 1) {
  2060. value += rt / c;
  2061. } else {
  2062. value += rt * Math.pow(2, 1 - eBias);
  2063. }
  2064. if (value * c >= 2) {
  2065. e++;
  2066. c /= 2;
  2067. }
  2068. if (e + eBias >= eMax) {
  2069. m = 0;
  2070. e = eMax;
  2071. } else if (e + eBias >= 1) {
  2072. m = (value * c - 1) * Math.pow(2, mLen);
  2073. e = e + eBias;
  2074. } else {
  2075. m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen);
  2076. e = 0;
  2077. }
  2078. }
  2079. for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
  2080. e = e << mLen | m;
  2081. eLen += mLen;
  2082. for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
  2083. buffer[offset + i - d] |= s * 128;
  2084. }
  2085. var toString = {}.toString;
  2086. var isArray$1 = Array.isArray || function (arr) {
  2087. return toString.call(arr) == '[object Array]';
  2088. };
  2089. /*!
  2090. * The buffer module from node.js, for the browser.
  2091. *
  2092. * @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
  2093. * @license MIT
  2094. */
  2095. /* eslint-disable no-proto */
  2096. var INSPECT_MAX_BYTES = 50;
  2097. /**
  2098. * If `Buffer.TYPED_ARRAY_SUPPORT`:
  2099. * === true Use Uint8Array implementation (fastest)
  2100. * === false Use Object implementation (most compatible, even IE6)
  2101. *
  2102. * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
  2103. * Opera 11.6+, iOS 4.2+.
  2104. *
  2105. * Due to various browser bugs, sometimes the Object implementation will be used even
  2106. * when the browser supports typed arrays.
  2107. *
  2108. * Note:
  2109. *
  2110. * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,
  2111. * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.
  2112. *
  2113. * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.
  2114. *
  2115. * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of
  2116. * incorrect length in some situations.
  2117. * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they
  2118. * get the Object implementation, which is slower but behaves correctly.
  2119. */
  2120. Buffer.TYPED_ARRAY_SUPPORT = global$1.TYPED_ARRAY_SUPPORT !== undefined ? global$1.TYPED_ARRAY_SUPPORT : true;
  2121. function kMaxLength() {
  2122. return Buffer.TYPED_ARRAY_SUPPORT ? 0x7fffffff : 0x3fffffff;
  2123. }
  2124. function createBuffer(that, length) {
  2125. if (kMaxLength() < length) {
  2126. throw new RangeError('Invalid typed array length');
  2127. }
  2128. if (Buffer.TYPED_ARRAY_SUPPORT) {
  2129. // Return an augmented `Uint8Array` instance, for best performance
  2130. that = new Uint8Array(length);
  2131. that.__proto__ = Buffer.prototype;
  2132. } else {
  2133. // Fallback: Return an object instance of the Buffer class
  2134. if (that === null) {
  2135. that = new Buffer(length);
  2136. }
  2137. that.length = length;
  2138. }
  2139. return that;
  2140. }
  2141. /**
  2142. * The Buffer constructor returns instances of `Uint8Array` that have their
  2143. * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
  2144. * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
  2145. * and the `Uint8Array` methods. Square bracket notation works as expected -- it
  2146. * returns a single octet.
  2147. *
  2148. * The `Uint8Array` prototype remains unmodified.
  2149. */
  2150. function Buffer(arg, encodingOrOffset, length) {
  2151. if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) {
  2152. return new Buffer(arg, encodingOrOffset, length);
  2153. } // Common case.
  2154. if (typeof arg === 'number') {
  2155. if (typeof encodingOrOffset === 'string') {
  2156. throw new Error('If encoding is specified then the first argument must be a string');
  2157. }
  2158. return allocUnsafe(this, arg);
  2159. }
  2160. return from(this, arg, encodingOrOffset, length);
  2161. }
  2162. Buffer.poolSize = 8192; // not used by this implementation
  2163. // TODO: Legacy, not needed anymore. Remove in next major version.
  2164. Buffer._augment = function (arr) {
  2165. arr.__proto__ = Buffer.prototype;
  2166. return arr;
  2167. };
  2168. function from(that, value, encodingOrOffset, length) {
  2169. if (typeof value === 'number') {
  2170. throw new TypeError('"value" argument must not be a number');
  2171. }
  2172. if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {
  2173. return fromArrayBuffer(that, value, encodingOrOffset, length);
  2174. }
  2175. if (typeof value === 'string') {
  2176. return fromString(that, value, encodingOrOffset);
  2177. }
  2178. return fromObject(that, value);
  2179. }
  2180. /**
  2181. * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
  2182. * if value is a number.
  2183. * Buffer.from(str[, encoding])
  2184. * Buffer.from(array)
  2185. * Buffer.from(buffer)
  2186. * Buffer.from(arrayBuffer[, byteOffset[, length]])
  2187. **/
  2188. Buffer.from = function (value, encodingOrOffset, length) {
  2189. return from(null, value, encodingOrOffset, length);
  2190. };
  2191. if (Buffer.TYPED_ARRAY_SUPPORT) {
  2192. Buffer.prototype.__proto__ = Uint8Array.prototype;
  2193. Buffer.__proto__ = Uint8Array;
  2194. if (typeof Symbol !== 'undefined' && Symbol.species && Buffer[Symbol.species] === Buffer) {// Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97
  2195. // Object.defineProperty(Buffer, Symbol.species, {
  2196. // value: null,
  2197. // configurable: true
  2198. // })
  2199. }
  2200. }
  2201. function assertSize(size) {
  2202. if (typeof size !== 'number') {
  2203. throw new TypeError('"size" argument must be a number');
  2204. } else if (size < 0) {
  2205. throw new RangeError('"size" argument must not be negative');
  2206. }
  2207. }
  2208. function alloc(that, size, fill, encoding) {
  2209. assertSize(size);
  2210. if (size <= 0) {
  2211. return createBuffer(that, size);
  2212. }
  2213. if (fill !== undefined) {
  2214. // Only pay attention to encoding if it's a string. This
  2215. // prevents accidentally sending in a number that would
  2216. // be interpretted as a start offset.
  2217. return typeof encoding === 'string' ? createBuffer(that, size).fill(fill, encoding) : createBuffer(that, size).fill(fill);
  2218. }
  2219. return createBuffer(that, size);
  2220. }
  2221. /**
  2222. * Creates a new filled Buffer instance.
  2223. * alloc(size[, fill[, encoding]])
  2224. **/
  2225. Buffer.alloc = function (size, fill, encoding) {
  2226. return alloc(null, size, fill, encoding);
  2227. };
  2228. function allocUnsafe(that, size) {
  2229. assertSize(size);
  2230. that = createBuffer(that, size < 0 ? 0 : checked(size) | 0);
  2231. if (!Buffer.TYPED_ARRAY_SUPPORT) {
  2232. for (var i = 0; i < size; ++i) {
  2233. that[i] = 0;
  2234. }
  2235. }
  2236. return that;
  2237. }
  2238. /**
  2239. * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
  2240. * */
  2241. Buffer.allocUnsafe = function (size) {
  2242. return allocUnsafe(null, size);
  2243. };
  2244. /**
  2245. * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
  2246. */
  2247. Buffer.allocUnsafeSlow = function (size) {
  2248. return allocUnsafe(null, size);
  2249. };
  2250. function fromString(that, string, encoding) {
  2251. if (typeof encoding !== 'string' || encoding === '') {
  2252. encoding = 'utf8';
  2253. }
  2254. if (!Buffer.isEncoding(encoding)) {
  2255. throw new TypeError('"encoding" must be a valid string encoding');
  2256. }
  2257. var length = byteLength(string, encoding) | 0;
  2258. that = createBuffer(that, length);
  2259. var actual = that.write(string, encoding);
  2260. if (actual !== length) {
  2261. // Writing a hex string, for example, that contains invalid characters will
  2262. // cause everything after the first invalid character to be ignored. (e.g.
  2263. // 'abxxcd' will be treated as 'ab')
  2264. that = that.slice(0, actual);
  2265. }
  2266. return that;
  2267. }
  2268. function fromArrayLike(that, array) {
  2269. var length = array.length < 0 ? 0 : checked(array.length) | 0;
  2270. that = createBuffer(that, length);
  2271. for (var i = 0; i < length; i += 1) {
  2272. that[i] = array[i] & 255;
  2273. }
  2274. return that;
  2275. }
  2276. function fromArrayBuffer(that, array, byteOffset, length) {
  2277. array.byteLength; // this throws if `array` is not a valid ArrayBuffer
  2278. if (byteOffset < 0 || array.byteLength < byteOffset) {
  2279. throw new RangeError('\'offset\' is out of bounds');
  2280. }
  2281. if (array.byteLength < byteOffset + (length || 0)) {
  2282. throw new RangeError('\'length\' is out of bounds');
  2283. }
  2284. if (byteOffset === undefined && length === undefined) {
  2285. array = new Uint8Array(array);
  2286. } else if (length === undefined) {
  2287. array = new Uint8Array(array, byteOffset);
  2288. } else {
  2289. array = new Uint8Array(array, byteOffset, length);
  2290. }
  2291. if (Buffer.TYPED_ARRAY_SUPPORT) {
  2292. // Return an augmented `Uint8Array` instance, for best performance
  2293. that = array;
  2294. that.__proto__ = Buffer.prototype;
  2295. } else {
  2296. // Fallback: Return an object instance of the Buffer class
  2297. that = fromArrayLike(that, array);
  2298. }
  2299. return that;
  2300. }
  2301. function fromObject(that, obj) {
  2302. if (internalIsBuffer(obj)) {
  2303. var len = checked(obj.length) | 0;
  2304. that = createBuffer(that, len);
  2305. if (that.length === 0) {
  2306. return that;
  2307. }
  2308. obj.copy(that, 0, 0, len);
  2309. return that;
  2310. }
  2311. if (obj) {
  2312. if (typeof ArrayBuffer !== 'undefined' && obj.buffer instanceof ArrayBuffer || 'length' in obj) {
  2313. if (typeof obj.length !== 'number' || isnan(obj.length)) {
  2314. return createBuffer(that, 0);
  2315. }
  2316. return fromArrayLike(that, obj);
  2317. }
  2318. if (obj.type === 'Buffer' && isArray$1(obj.data)) {
  2319. return fromArrayLike(that, obj.data);
  2320. }
  2321. }
  2322. throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.');
  2323. }
  2324. function checked(length) {
  2325. // Note: cannot use `length < kMaxLength()` here because that fails when
  2326. // length is NaN (which is otherwise coerced to zero.)
  2327. if (length >= kMaxLength()) {
  2328. throw new RangeError('Attempt to allocate Buffer larger than maximum ' + 'size: 0x' + kMaxLength().toString(16) + ' bytes');
  2329. }
  2330. return length | 0;
  2331. }
  2332. Buffer.isBuffer = isBuffer;
  2333. function internalIsBuffer(b) {
  2334. return !!(b != null && b._isBuffer);
  2335. }
  2336. Buffer.compare = function compare(a, b) {
  2337. if (!internalIsBuffer(a) || !internalIsBuffer(b)) {
  2338. throw new TypeError('Arguments must be Buffers');
  2339. }
  2340. if (a === b) return 0;
  2341. var x = a.length;
  2342. var y = b.length;
  2343. for (var i = 0, len = Math.min(x, y); i < len; ++i) {
  2344. if (a[i] !== b[i]) {
  2345. x = a[i];
  2346. y = b[i];
  2347. break;
  2348. }
  2349. }
  2350. if (x < y) return -1;
  2351. if (y < x) return 1;
  2352. return 0;
  2353. };
  2354. Buffer.isEncoding = function isEncoding(encoding) {
  2355. switch (String(encoding).toLowerCase()) {
  2356. case 'hex':
  2357. case 'utf8':
  2358. case 'utf-8':
  2359. case 'ascii':
  2360. case 'latin1':
  2361. case 'binary':
  2362. case 'base64':
  2363. case 'ucs2':
  2364. case 'ucs-2':
  2365. case 'utf16le':
  2366. case 'utf-16le':
  2367. return true;
  2368. default:
  2369. return false;
  2370. }
  2371. };
  2372. Buffer.concat = function concat(list, length) {
  2373. if (!isArray$1(list)) {
  2374. throw new TypeError('"list" argument must be an Array of Buffers');
  2375. }
  2376. if (list.length === 0) {
  2377. return Buffer.alloc(0);
  2378. }
  2379. var i;
  2380. if (length === undefined) {
  2381. length = 0;
  2382. for (i = 0; i < list.length; ++i) {
  2383. length += list[i].length;
  2384. }
  2385. }
  2386. var buffer = Buffer.allocUnsafe(length);
  2387. var pos = 0;
  2388. for (i = 0; i < list.length; ++i) {
  2389. var buf = list[i];
  2390. if (!internalIsBuffer(buf)) {
  2391. throw new TypeError('"list" argument must be an Array of Buffers');
  2392. }
  2393. buf.copy(buffer, pos);
  2394. pos += buf.length;
  2395. }
  2396. return buffer;
  2397. };
  2398. function byteLength(string, encoding) {
  2399. if (internalIsBuffer(string)) {
  2400. return string.length;
  2401. }
  2402. if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' && (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {
  2403. return string.byteLength;
  2404. }
  2405. if (typeof string !== 'string') {
  2406. string = '' + string;
  2407. }
  2408. var len = string.length;
  2409. if (len === 0) return 0; // Use a for loop to avoid recursion
  2410. var loweredCase = false;
  2411. for (;;) {
  2412. switch (encoding) {
  2413. case 'ascii':
  2414. case 'latin1':
  2415. case 'binary':
  2416. return len;
  2417. case 'utf8':
  2418. case 'utf-8':
  2419. case undefined:
  2420. return utf8ToBytes(string).length;
  2421. case 'ucs2':
  2422. case 'ucs-2':
  2423. case 'utf16le':
  2424. case 'utf-16le':
  2425. return len * 2;
  2426. case 'hex':
  2427. return len >>> 1;
  2428. case 'base64':
  2429. return base64ToBytes(string).length;
  2430. default:
  2431. if (loweredCase) return utf8ToBytes(string).length; // assume utf8
  2432. encoding = ('' + encoding).toLowerCase();
  2433. loweredCase = true;
  2434. }
  2435. }
  2436. }
  2437. Buffer.byteLength = byteLength;
  2438. function slowToString(encoding, start, end) {
  2439. var loweredCase = false; // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
  2440. // property of a typed array.
  2441. // This behaves neither like String nor Uint8Array in that we set start/end
  2442. // to their upper/lower bounds if the value passed is out of range.
  2443. // undefined is handled specially as per ECMA-262 6th Edition,
  2444. // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
  2445. if (start === undefined || start < 0) {
  2446. start = 0;
  2447. } // Return early if start > this.length. Done here to prevent potential uint32
  2448. // coercion fail below.
  2449. if (start > this.length) {
  2450. return '';
  2451. }
  2452. if (end === undefined || end > this.length) {
  2453. end = this.length;
  2454. }
  2455. if (end <= 0) {
  2456. return '';
  2457. } // Force coersion to uint32. This will also coerce falsey/NaN values to 0.
  2458. end >>>= 0;
  2459. start >>>= 0;
  2460. if (end <= start) {
  2461. return '';
  2462. }
  2463. if (!encoding) encoding = 'utf8';
  2464. while (true) {
  2465. switch (encoding) {
  2466. case 'hex':
  2467. return hexSlice(this, start, end);
  2468. case 'utf8':
  2469. case 'utf-8':
  2470. return utf8Slice(this, start, end);
  2471. case 'ascii':
  2472. return asciiSlice(this, start, end);
  2473. case 'latin1':
  2474. case 'binary':
  2475. return latin1Slice(this, start, end);
  2476. case 'base64':
  2477. return base64Slice(this, start, end);
  2478. case 'ucs2':
  2479. case 'ucs-2':
  2480. case 'utf16le':
  2481. case 'utf-16le':
  2482. return utf16leSlice(this, start, end);
  2483. default:
  2484. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding);
  2485. encoding = (encoding + '').toLowerCase();
  2486. loweredCase = true;
  2487. }
  2488. }
  2489. } // The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect
  2490. // Buffer instances.
  2491. Buffer.prototype._isBuffer = true;
  2492. function swap(b, n, m) {
  2493. var i = b[n];
  2494. b[n] = b[m];
  2495. b[m] = i;
  2496. }
  2497. Buffer.prototype.swap16 = function swap16() {
  2498. var len = this.length;
  2499. if (len % 2 !== 0) {
  2500. throw new RangeError('Buffer size must be a multiple of 16-bits');
  2501. }
  2502. for (var i = 0; i < len; i += 2) {
  2503. swap(this, i, i + 1);
  2504. }
  2505. return this;
  2506. };
  2507. Buffer.prototype.swap32 = function swap32() {
  2508. var len = this.length;
  2509. if (len % 4 !== 0) {
  2510. throw new RangeError('Buffer size must be a multiple of 32-bits');
  2511. }
  2512. for (var i = 0; i < len; i += 4) {
  2513. swap(this, i, i + 3);
  2514. swap(this, i + 1, i + 2);
  2515. }
  2516. return this;
  2517. };
  2518. Buffer.prototype.swap64 = function swap64() {
  2519. var len = this.length;
  2520. if (len % 8 !== 0) {
  2521. throw new RangeError('Buffer size must be a multiple of 64-bits');
  2522. }
  2523. for (var i = 0; i < len; i += 8) {
  2524. swap(this, i, i + 7);
  2525. swap(this, i + 1, i + 6);
  2526. swap(this, i + 2, i + 5);
  2527. swap(this, i + 3, i + 4);
  2528. }
  2529. return this;
  2530. };
  2531. Buffer.prototype.toString = function toString() {
  2532. var length = this.length | 0;
  2533. if (length === 0) return '';
  2534. if (arguments.length === 0) return utf8Slice(this, 0, length);
  2535. return slowToString.apply(this, arguments);
  2536. };
  2537. Buffer.prototype.equals = function equals(b) {
  2538. if (!internalIsBuffer(b)) throw new TypeError('Argument must be a Buffer');
  2539. if (this === b) return true;
  2540. return Buffer.compare(this, b) === 0;
  2541. };
  2542. Buffer.prototype.inspect = function inspect() {
  2543. var str = '';
  2544. var max = INSPECT_MAX_BYTES;
  2545. if (this.length > 0) {
  2546. str = this.toString('hex', 0, max).match(/.{2}/g).join(' ');
  2547. if (this.length > max) str += ' ... ';
  2548. }
  2549. return '<Buffer ' + str + '>';
  2550. };
  2551. Buffer.prototype.compare = function compare(target, start, end, thisStart, thisEnd) {
  2552. if (!internalIsBuffer(target)) {
  2553. throw new TypeError('Argument must be a Buffer');
  2554. }
  2555. if (start === undefined) {
  2556. start = 0;
  2557. }
  2558. if (end === undefined) {
  2559. end = target ? target.length : 0;
  2560. }
  2561. if (thisStart === undefined) {
  2562. thisStart = 0;
  2563. }
  2564. if (thisEnd === undefined) {
  2565. thisEnd = this.length;
  2566. }
  2567. if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
  2568. throw new RangeError('out of range index');
  2569. }
  2570. if (thisStart >= thisEnd && start >= end) {
  2571. return 0;
  2572. }
  2573. if (thisStart >= thisEnd) {
  2574. return -1;
  2575. }
  2576. if (start >= end) {
  2577. return 1;
  2578. }
  2579. start >>>= 0;
  2580. end >>>= 0;
  2581. thisStart >>>= 0;
  2582. thisEnd >>>= 0;
  2583. if (this === target) return 0;
  2584. var x = thisEnd - thisStart;
  2585. var y = end - start;
  2586. var len = Math.min(x, y);
  2587. var thisCopy = this.slice(thisStart, thisEnd);
  2588. var targetCopy = target.slice(start, end);
  2589. for (var i = 0; i < len; ++i) {
  2590. if (thisCopy[i] !== targetCopy[i]) {
  2591. x = thisCopy[i];
  2592. y = targetCopy[i];
  2593. break;
  2594. }
  2595. }
  2596. if (x < y) return -1;
  2597. if (y < x) return 1;
  2598. return 0;
  2599. }; // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
  2600. // OR the last index of `val` in `buffer` at offset <= `byteOffset`.
  2601. //
  2602. // Arguments:
  2603. // - buffer - a Buffer to search
  2604. // - val - a string, Buffer, or number
  2605. // - byteOffset - an index into `buffer`; will be clamped to an int32
  2606. // - encoding - an optional encoding, relevant is val is a string
  2607. // - dir - true for indexOf, false for lastIndexOf
  2608. function bidirectionalIndexOf(buffer, val, byteOffset, encoding, dir) {
  2609. // Empty buffer means no match
  2610. if (buffer.length === 0) return -1; // Normalize byteOffset
  2611. if (typeof byteOffset === 'string') {
  2612. encoding = byteOffset;
  2613. byteOffset = 0;
  2614. } else if (byteOffset > 0x7fffffff) {
  2615. byteOffset = 0x7fffffff;
  2616. } else if (byteOffset < -0x80000000) {
  2617. byteOffset = -0x80000000;
  2618. }
  2619. byteOffset = +byteOffset; // Coerce to Number.
  2620. if (isNaN(byteOffset)) {
  2621. // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
  2622. byteOffset = dir ? 0 : buffer.length - 1;
  2623. } // Normalize byteOffset: negative offsets start from the end of the buffer
  2624. if (byteOffset < 0) byteOffset = buffer.length + byteOffset;
  2625. if (byteOffset >= buffer.length) {
  2626. if (dir) return -1;else byteOffset = buffer.length - 1;
  2627. } else if (byteOffset < 0) {
  2628. if (dir) byteOffset = 0;else return -1;
  2629. } // Normalize val
  2630. if (typeof val === 'string') {
  2631. val = Buffer.from(val, encoding);
  2632. } // Finally, search either indexOf (if dir is true) or lastIndexOf
  2633. if (internalIsBuffer(val)) {
  2634. // Special case: looking for empty string/buffer always fails
  2635. if (val.length === 0) {
  2636. return -1;
  2637. }
  2638. return arrayIndexOf(buffer, val, byteOffset, encoding, dir);
  2639. } else if (typeof val === 'number') {
  2640. val = val & 0xFF; // Search for a byte value [0-255]
  2641. if (Buffer.TYPED_ARRAY_SUPPORT && typeof Uint8Array.prototype.indexOf === 'function') {
  2642. if (dir) {
  2643. return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset);
  2644. } else {
  2645. return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset);
  2646. }
  2647. }
  2648. return arrayIndexOf(buffer, [val], byteOffset, encoding, dir);
  2649. }
  2650. throw new TypeError('val must be string, number or Buffer');
  2651. }
  2652. function arrayIndexOf(arr, val, byteOffset, encoding, dir) {
  2653. var indexSize = 1;
  2654. var arrLength = arr.length;
  2655. var valLength = val.length;
  2656. if (encoding !== undefined) {
  2657. encoding = String(encoding).toLowerCase();
  2658. if (encoding === 'ucs2' || encoding === 'ucs-2' || encoding === 'utf16le' || encoding === 'utf-16le') {
  2659. if (arr.length < 2 || val.length < 2) {
  2660. return -1;
  2661. }
  2662. indexSize = 2;
  2663. arrLength /= 2;
  2664. valLength /= 2;
  2665. byteOffset /= 2;
  2666. }
  2667. }
  2668. function read$$1(buf, i) {
  2669. if (indexSize === 1) {
  2670. return buf[i];
  2671. } else {
  2672. return buf.readUInt16BE(i * indexSize);
  2673. }
  2674. }
  2675. var i;
  2676. if (dir) {
  2677. var foundIndex = -1;
  2678. for (i = byteOffset; i < arrLength; i++) {
  2679. if (read$$1(arr, i) === read$$1(val, foundIndex === -1 ? 0 : i - foundIndex)) {
  2680. if (foundIndex === -1) foundIndex = i;
  2681. if (i - foundIndex + 1 === valLength) return foundIndex * indexSize;
  2682. } else {
  2683. if (foundIndex !== -1) i -= i - foundIndex;
  2684. foundIndex = -1;
  2685. }
  2686. }
  2687. } else {
  2688. if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength;
  2689. for (i = byteOffset; i >= 0; i--) {
  2690. var found = true;
  2691. for (var j = 0; j < valLength; j++) {
  2692. if (read$$1(arr, i + j) !== read$$1(val, j)) {
  2693. found = false;
  2694. break;
  2695. }
  2696. }
  2697. if (found) return i;
  2698. }
  2699. }
  2700. return -1;
  2701. }
  2702. Buffer.prototype.includes = function includes(val, byteOffset, encoding) {
  2703. return this.indexOf(val, byteOffset, encoding) !== -1;
  2704. };
  2705. Buffer.prototype.indexOf = function indexOf(val, byteOffset, encoding) {
  2706. return bidirectionalIndexOf(this, val, byteOffset, encoding, true);
  2707. };
  2708. Buffer.prototype.lastIndexOf = function lastIndexOf(val, byteOffset, encoding) {
  2709. return bidirectionalIndexOf(this, val, byteOffset, encoding, false);
  2710. };
  2711. function hexWrite(buf, string, offset, length) {
  2712. offset = Number(offset) || 0;
  2713. var remaining = buf.length - offset;
  2714. if (!length) {
  2715. length = remaining;
  2716. } else {
  2717. length = Number(length);
  2718. if (length > remaining) {
  2719. length = remaining;
  2720. }
  2721. } // must be an even number of digits
  2722. var strLen = string.length;
  2723. if (strLen % 2 !== 0) throw new TypeError('Invalid hex string');
  2724. if (length > strLen / 2) {
  2725. length = strLen / 2;
  2726. }
  2727. for (var i = 0; i < length; ++i) {
  2728. var parsed = parseInt(string.substr(i * 2, 2), 16);
  2729. if (isNaN(parsed)) return i;
  2730. buf[offset + i] = parsed;
  2731. }
  2732. return i;
  2733. }
  2734. function utf8Write(buf, string, offset, length) {
  2735. return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length);
  2736. }
  2737. function asciiWrite(buf, string, offset, length) {
  2738. return blitBuffer(asciiToBytes(string), buf, offset, length);
  2739. }
  2740. function latin1Write(buf, string, offset, length) {
  2741. return asciiWrite(buf, string, offset, length);
  2742. }
  2743. function base64Write(buf, string, offset, length) {
  2744. return blitBuffer(base64ToBytes(string), buf, offset, length);
  2745. }
  2746. function ucs2Write(buf, string, offset, length) {
  2747. return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length);
  2748. }
  2749. Buffer.prototype.write = function write$$1(string, offset, length, encoding) {
  2750. // Buffer#write(string)
  2751. if (offset === undefined) {
  2752. encoding = 'utf8';
  2753. length = this.length;
  2754. offset = 0; // Buffer#write(string, encoding)
  2755. } else if (length === undefined && typeof offset === 'string') {
  2756. encoding = offset;
  2757. length = this.length;
  2758. offset = 0; // Buffer#write(string, offset[, length][, encoding])
  2759. } else if (isFinite(offset)) {
  2760. offset = offset | 0;
  2761. if (isFinite(length)) {
  2762. length = length | 0;
  2763. if (encoding === undefined) encoding = 'utf8';
  2764. } else {
  2765. encoding = length;
  2766. length = undefined;
  2767. } // legacy write(string, encoding, offset, length) - remove in v0.13
  2768. } else {
  2769. throw new Error('Buffer.write(string, encoding, offset[, length]) is no longer supported');
  2770. }
  2771. var remaining = this.length - offset;
  2772. if (length === undefined || length > remaining) length = remaining;
  2773. if (string.length > 0 && (length < 0 || offset < 0) || offset > this.length) {
  2774. throw new RangeError('Attempt to write outside buffer bounds');
  2775. }
  2776. if (!encoding) encoding = 'utf8';
  2777. var loweredCase = false;
  2778. for (;;) {
  2779. switch (encoding) {
  2780. case 'hex':
  2781. return hexWrite(this, string, offset, length);
  2782. case 'utf8':
  2783. case 'utf-8':
  2784. return utf8Write(this, string, offset, length);
  2785. case 'ascii':
  2786. return asciiWrite(this, string, offset, length);
  2787. case 'latin1':
  2788. case 'binary':
  2789. return latin1Write(this, string, offset, length);
  2790. case 'base64':
  2791. // Warning: maxLength not taken into account in base64Write
  2792. return base64Write(this, string, offset, length);
  2793. case 'ucs2':
  2794. case 'ucs-2':
  2795. case 'utf16le':
  2796. case 'utf-16le':
  2797. return ucs2Write(this, string, offset, length);
  2798. default:
  2799. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding);
  2800. encoding = ('' + encoding).toLowerCase();
  2801. loweredCase = true;
  2802. }
  2803. }
  2804. };
  2805. Buffer.prototype.toJSON = function toJSON() {
  2806. return {
  2807. type: 'Buffer',
  2808. data: Array.prototype.slice.call(this._arr || this, 0)
  2809. };
  2810. };
  2811. function base64Slice(buf, start, end) {
  2812. if (start === 0 && end === buf.length) {
  2813. return fromByteArray(buf);
  2814. } else {
  2815. return fromByteArray(buf.slice(start, end));
  2816. }
  2817. }
  2818. function utf8Slice(buf, start, end) {
  2819. end = Math.min(buf.length, end);
  2820. var res = [];
  2821. var i = start;
  2822. while (i < end) {
  2823. var firstByte = buf[i];
  2824. var codePoint = null;
  2825. var bytesPerSequence = firstByte > 0xEF ? 4 : firstByte > 0xDF ? 3 : firstByte > 0xBF ? 2 : 1;
  2826. if (i + bytesPerSequence <= end) {
  2827. var secondByte, thirdByte, fourthByte, tempCodePoint;
  2828. switch (bytesPerSequence) {
  2829. case 1:
  2830. if (firstByte < 0x80) {
  2831. codePoint = firstByte;
  2832. }
  2833. break;
  2834. case 2:
  2835. secondByte = buf[i + 1];
  2836. if ((secondByte & 0xC0) === 0x80) {
  2837. tempCodePoint = (firstByte & 0x1F) << 0x6 | secondByte & 0x3F;
  2838. if (tempCodePoint > 0x7F) {
  2839. codePoint = tempCodePoint;
  2840. }
  2841. }
  2842. break;
  2843. case 3:
  2844. secondByte = buf[i + 1];
  2845. thirdByte = buf[i + 2];
  2846. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
  2847. tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | thirdByte & 0x3F;
  2848. if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
  2849. codePoint = tempCodePoint;
  2850. }
  2851. }
  2852. break;
  2853. case 4:
  2854. secondByte = buf[i + 1];
  2855. thirdByte = buf[i + 2];
  2856. fourthByte = buf[i + 3];
  2857. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
  2858. tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | fourthByte & 0x3F;
  2859. if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
  2860. codePoint = tempCodePoint;
  2861. }
  2862. }
  2863. }
  2864. }
  2865. if (codePoint === null) {
  2866. // we did not generate a valid codePoint so insert a
  2867. // replacement char (U+FFFD) and advance only 1 byte
  2868. codePoint = 0xFFFD;
  2869. bytesPerSequence = 1;
  2870. } else if (codePoint > 0xFFFF) {
  2871. // encode to utf16 (surrogate pair dance)
  2872. codePoint -= 0x10000;
  2873. res.push(codePoint >>> 10 & 0x3FF | 0xD800);
  2874. codePoint = 0xDC00 | codePoint & 0x3FF;
  2875. }
  2876. res.push(codePoint);
  2877. i += bytesPerSequence;
  2878. }
  2879. return decodeCodePointsArray(res);
  2880. } // Based on http://stackoverflow.com/a/22747272/680742, the browser with
  2881. // the lowest limit is Chrome, with 0x10000 args.
  2882. // We go 1 magnitude less, for safety
  2883. var MAX_ARGUMENTS_LENGTH = 0x1000;
  2884. function decodeCodePointsArray(codePoints) {
  2885. var len = codePoints.length;
  2886. if (len <= MAX_ARGUMENTS_LENGTH) {
  2887. return String.fromCharCode.apply(String, codePoints); // avoid extra slice()
  2888. } // Decode in chunks to avoid "call stack size exceeded".
  2889. var res = '';
  2890. var i = 0;
  2891. while (i < len) {
  2892. res += String.fromCharCode.apply(String, codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH));
  2893. }
  2894. return res;
  2895. }
  2896. function asciiSlice(buf, start, end) {
  2897. var ret = '';
  2898. end = Math.min(buf.length, end);
  2899. for (var i = start; i < end; ++i) {
  2900. ret += String.fromCharCode(buf[i] & 0x7F);
  2901. }
  2902. return ret;
  2903. }
  2904. function latin1Slice(buf, start, end) {
  2905. var ret = '';
  2906. end = Math.min(buf.length, end);
  2907. for (var i = start; i < end; ++i) {
  2908. ret += String.fromCharCode(buf[i]);
  2909. }
  2910. return ret;
  2911. }
  2912. function hexSlice(buf, start, end) {
  2913. var len = buf.length;
  2914. if (!start || start < 0) start = 0;
  2915. if (!end || end < 0 || end > len) end = len;
  2916. var out = '';
  2917. for (var i = start; i < end; ++i) {
  2918. out += toHex(buf[i]);
  2919. }
  2920. return out;
  2921. }
  2922. function utf16leSlice(buf, start, end) {
  2923. var bytes = buf.slice(start, end);
  2924. var res = '';
  2925. for (var i = 0; i < bytes.length; i += 2) {
  2926. res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256);
  2927. }
  2928. return res;
  2929. }
  2930. Buffer.prototype.slice = function slice(start, end) {
  2931. var len = this.length;
  2932. start = ~~start;
  2933. end = end === undefined ? len : ~~end;
  2934. if (start < 0) {
  2935. start += len;
  2936. if (start < 0) start = 0;
  2937. } else if (start > len) {
  2938. start = len;
  2939. }
  2940. if (end < 0) {
  2941. end += len;
  2942. if (end < 0) end = 0;
  2943. } else if (end > len) {
  2944. end = len;
  2945. }
  2946. if (end < start) end = start;
  2947. var newBuf;
  2948. if (Buffer.TYPED_ARRAY_SUPPORT) {
  2949. newBuf = this.subarray(start, end);
  2950. newBuf.__proto__ = Buffer.prototype;
  2951. } else {
  2952. var sliceLen = end - start;
  2953. newBuf = new Buffer(sliceLen, undefined);
  2954. for (var i = 0; i < sliceLen; ++i) {
  2955. newBuf[i] = this[i + start];
  2956. }
  2957. }
  2958. return newBuf;
  2959. };
  2960. /*
  2961. * Need to make sure that buffer isn't trying to write out of bounds.
  2962. */
  2963. function checkOffset(offset, ext, length) {
  2964. if (offset % 1 !== 0 || offset < 0) throw new RangeError('offset is not uint');
  2965. if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length');
  2966. }
  2967. Buffer.prototype.readUIntLE = function readUIntLE(offset, byteLength, noAssert) {
  2968. offset = offset | 0;
  2969. byteLength = byteLength | 0;
  2970. if (!noAssert) checkOffset(offset, byteLength, this.length);
  2971. var val = this[offset];
  2972. var mul = 1;
  2973. var i = 0;
  2974. while (++i < byteLength && (mul *= 0x100)) {
  2975. val += this[offset + i] * mul;
  2976. }
  2977. return val;
  2978. };
  2979. Buffer.prototype.readUIntBE = function readUIntBE(offset, byteLength, noAssert) {
  2980. offset = offset | 0;
  2981. byteLength = byteLength | 0;
  2982. if (!noAssert) {
  2983. checkOffset(offset, byteLength, this.length);
  2984. }
  2985. var val = this[offset + --byteLength];
  2986. var mul = 1;
  2987. while (byteLength > 0 && (mul *= 0x100)) {
  2988. val += this[offset + --byteLength] * mul;
  2989. }
  2990. return val;
  2991. };
  2992. Buffer.prototype.readUInt8 = function readUInt8(offset, noAssert) {
  2993. if (!noAssert) checkOffset(offset, 1, this.length);
  2994. return this[offset];
  2995. };
  2996. Buffer.prototype.readUInt16LE = function readUInt16LE(offset, noAssert) {
  2997. if (!noAssert) checkOffset(offset, 2, this.length);
  2998. return this[offset] | this[offset + 1] << 8;
  2999. };
  3000. Buffer.prototype.readUInt16BE = function readUInt16BE(offset, noAssert) {
  3001. if (!noAssert) checkOffset(offset, 2, this.length);
  3002. return this[offset] << 8 | this[offset + 1];
  3003. };
  3004. Buffer.prototype.readUInt32LE = function readUInt32LE(offset, noAssert) {
  3005. if (!noAssert) checkOffset(offset, 4, this.length);
  3006. return (this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16) + this[offset + 3] * 0x1000000;
  3007. };
  3008. Buffer.prototype.readUInt32BE = function readUInt32BE(offset, noAssert) {
  3009. if (!noAssert) checkOffset(offset, 4, this.length);
  3010. return this[offset] * 0x1000000 + (this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3]);
  3011. };
  3012. Buffer.prototype.readIntLE = function readIntLE(offset, byteLength, noAssert) {
  3013. offset = offset | 0;
  3014. byteLength = byteLength | 0;
  3015. if (!noAssert) checkOffset(offset, byteLength, this.length);
  3016. var val = this[offset];
  3017. var mul = 1;
  3018. var i = 0;
  3019. while (++i < byteLength && (mul *= 0x100)) {
  3020. val += this[offset + i] * mul;
  3021. }
  3022. mul *= 0x80;
  3023. if (val >= mul) val -= Math.pow(2, 8 * byteLength);
  3024. return val;
  3025. };
  3026. Buffer.prototype.readIntBE = function readIntBE(offset, byteLength, noAssert) {
  3027. offset = offset | 0;
  3028. byteLength = byteLength | 0;
  3029. if (!noAssert) checkOffset(offset, byteLength, this.length);
  3030. var i = byteLength;
  3031. var mul = 1;
  3032. var val = this[offset + --i];
  3033. while (i > 0 && (mul *= 0x100)) {
  3034. val += this[offset + --i] * mul;
  3035. }
  3036. mul *= 0x80;
  3037. if (val >= mul) val -= Math.pow(2, 8 * byteLength);
  3038. return val;
  3039. };
  3040. Buffer.prototype.readInt8 = function readInt8(offset, noAssert) {
  3041. if (!noAssert) checkOffset(offset, 1, this.length);
  3042. if (!(this[offset] & 0x80)) return this[offset];
  3043. return (0xff - this[offset] + 1) * -1;
  3044. };
  3045. Buffer.prototype.readInt16LE = function readInt16LE(offset, noAssert) {
  3046. if (!noAssert) checkOffset(offset, 2, this.length);
  3047. var val = this[offset] | this[offset + 1] << 8;
  3048. return val & 0x8000 ? val | 0xFFFF0000 : val;
  3049. };
  3050. Buffer.prototype.readInt16BE = function readInt16BE(offset, noAssert) {
  3051. if (!noAssert) checkOffset(offset, 2, this.length);
  3052. var val = this[offset + 1] | this[offset] << 8;
  3053. return val & 0x8000 ? val | 0xFFFF0000 : val;
  3054. };
  3055. Buffer.prototype.readInt32LE = function readInt32LE(offset, noAssert) {
  3056. if (!noAssert) checkOffset(offset, 4, this.length);
  3057. return this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16 | this[offset + 3] << 24;
  3058. };
  3059. Buffer.prototype.readInt32BE = function readInt32BE(offset, noAssert) {
  3060. if (!noAssert) checkOffset(offset, 4, this.length);
  3061. return this[offset] << 24 | this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3];
  3062. };
  3063. Buffer.prototype.readFloatLE = function readFloatLE(offset, noAssert) {
  3064. if (!noAssert) checkOffset(offset, 4, this.length);
  3065. return read(this, offset, true, 23, 4);
  3066. };
  3067. Buffer.prototype.readFloatBE = function readFloatBE(offset, noAssert) {
  3068. if (!noAssert) checkOffset(offset, 4, this.length);
  3069. return read(this, offset, false, 23, 4);
  3070. };
  3071. Buffer.prototype.readDoubleLE = function readDoubleLE(offset, noAssert) {
  3072. if (!noAssert) checkOffset(offset, 8, this.length);
  3073. return read(this, offset, true, 52, 8);
  3074. };
  3075. Buffer.prototype.readDoubleBE = function readDoubleBE(offset, noAssert) {
  3076. if (!noAssert) checkOffset(offset, 8, this.length);
  3077. return read(this, offset, false, 52, 8);
  3078. };
  3079. function checkInt(buf, value, offset, ext, max, min) {
  3080. if (!internalIsBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance');
  3081. if (value > max || value < min) throw new RangeError('"value" argument is out of bounds');
  3082. if (offset + ext > buf.length) throw new RangeError('Index out of range');
  3083. }
  3084. Buffer.prototype.writeUIntLE = function writeUIntLE(value, offset, byteLength, noAssert) {
  3085. value = +value;
  3086. offset = offset | 0;
  3087. byteLength = byteLength | 0;
  3088. if (!noAssert) {
  3089. var maxBytes = Math.pow(2, 8 * byteLength) - 1;
  3090. checkInt(this, value, offset, byteLength, maxBytes, 0);
  3091. }
  3092. var mul = 1;
  3093. var i = 0;
  3094. this[offset] = value & 0xFF;
  3095. while (++i < byteLength && (mul *= 0x100)) {
  3096. this[offset + i] = value / mul & 0xFF;
  3097. }
  3098. return offset + byteLength;
  3099. };
  3100. Buffer.prototype.writeUIntBE = function writeUIntBE(value, offset, byteLength, noAssert) {
  3101. value = +value;
  3102. offset = offset | 0;
  3103. byteLength = byteLength | 0;
  3104. if (!noAssert) {
  3105. var maxBytes = Math.pow(2, 8 * byteLength) - 1;
  3106. checkInt(this, value, offset, byteLength, maxBytes, 0);
  3107. }
  3108. var i = byteLength - 1;
  3109. var mul = 1;
  3110. this[offset + i] = value & 0xFF;
  3111. while (--i >= 0 && (mul *= 0x100)) {
  3112. this[offset + i] = value / mul & 0xFF;
  3113. }
  3114. return offset + byteLength;
  3115. };
  3116. Buffer.prototype.writeUInt8 = function writeUInt8(value, offset, noAssert) {
  3117. value = +value;
  3118. offset = offset | 0;
  3119. if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0);
  3120. if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value);
  3121. this[offset] = value & 0xff;
  3122. return offset + 1;
  3123. };
  3124. function objectWriteUInt16(buf, value, offset, littleEndian) {
  3125. if (value < 0) value = 0xffff + value + 1;
  3126. for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) {
  3127. buf[offset + i] = (value & 0xff << 8 * (littleEndian ? i : 1 - i)) >>> (littleEndian ? i : 1 - i) * 8;
  3128. }
  3129. }
  3130. Buffer.prototype.writeUInt16LE = function writeUInt16LE(value, offset, noAssert) {
  3131. value = +value;
  3132. offset = offset | 0;
  3133. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0);
  3134. if (Buffer.TYPED_ARRAY_SUPPORT) {
  3135. this[offset] = value & 0xff;
  3136. this[offset + 1] = value >>> 8;
  3137. } else {
  3138. objectWriteUInt16(this, value, offset, true);
  3139. }
  3140. return offset + 2;
  3141. };
  3142. Buffer.prototype.writeUInt16BE = function writeUInt16BE(value, offset, noAssert) {
  3143. value = +value;
  3144. offset = offset | 0;
  3145. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0);
  3146. if (Buffer.TYPED_ARRAY_SUPPORT) {
  3147. this[offset] = value >>> 8;
  3148. this[offset + 1] = value & 0xff;
  3149. } else {
  3150. objectWriteUInt16(this, value, offset, false);
  3151. }
  3152. return offset + 2;
  3153. };
  3154. function objectWriteUInt32(buf, value, offset, littleEndian) {
  3155. if (value < 0) value = 0xffffffff + value + 1;
  3156. for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) {
  3157. buf[offset + i] = value >>> (littleEndian ? i : 3 - i) * 8 & 0xff;
  3158. }
  3159. }
  3160. Buffer.prototype.writeUInt32LE = function writeUInt32LE(value, offset, noAssert) {
  3161. value = +value;
  3162. offset = offset | 0;
  3163. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0);
  3164. if (Buffer.TYPED_ARRAY_SUPPORT) {
  3165. this[offset + 3] = value >>> 24;
  3166. this[offset + 2] = value >>> 16;
  3167. this[offset + 1] = value >>> 8;
  3168. this[offset] = value & 0xff;
  3169. } else {
  3170. objectWriteUInt32(this, value, offset, true);
  3171. }
  3172. return offset + 4;
  3173. };
  3174. Buffer.prototype.writeUInt32BE = function writeUInt32BE(value, offset, noAssert) {
  3175. value = +value;
  3176. offset = offset | 0;
  3177. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0);
  3178. if (Buffer.TYPED_ARRAY_SUPPORT) {
  3179. this[offset] = value >>> 24;
  3180. this[offset + 1] = value >>> 16;
  3181. this[offset + 2] = value >>> 8;
  3182. this[offset + 3] = value & 0xff;
  3183. } else {
  3184. objectWriteUInt32(this, value, offset, false);
  3185. }
  3186. return offset + 4;
  3187. };
  3188. Buffer.prototype.writeIntLE = function writeIntLE(value, offset, byteLength, noAssert) {
  3189. value = +value;
  3190. offset = offset | 0;
  3191. if (!noAssert) {
  3192. var limit = Math.pow(2, 8 * byteLength - 1);
  3193. checkInt(this, value, offset, byteLength, limit - 1, -limit);
  3194. }
  3195. var i = 0;
  3196. var mul = 1;
  3197. var sub = 0;
  3198. this[offset] = value & 0xFF;
  3199. while (++i < byteLength && (mul *= 0x100)) {
  3200. if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
  3201. sub = 1;
  3202. }
  3203. this[offset + i] = (value / mul >> 0) - sub & 0xFF;
  3204. }
  3205. return offset + byteLength;
  3206. };
  3207. Buffer.prototype.writeIntBE = function writeIntBE(value, offset, byteLength, noAssert) {
  3208. value = +value;
  3209. offset = offset | 0;
  3210. if (!noAssert) {
  3211. var limit = Math.pow(2, 8 * byteLength - 1);
  3212. checkInt(this, value, offset, byteLength, limit - 1, -limit);
  3213. }
  3214. var i = byteLength - 1;
  3215. var mul = 1;
  3216. var sub = 0;
  3217. this[offset + i] = value & 0xFF;
  3218. while (--i >= 0 && (mul *= 0x100)) {
  3219. if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
  3220. sub = 1;
  3221. }
  3222. this[offset + i] = (value / mul >> 0) - sub & 0xFF;
  3223. }
  3224. return offset + byteLength;
  3225. };
  3226. Buffer.prototype.writeInt8 = function writeInt8(value, offset, noAssert) {
  3227. value = +value;
  3228. offset = offset | 0;
  3229. if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80);
  3230. if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value);
  3231. if (value < 0) value = 0xff + value + 1;
  3232. this[offset] = value & 0xff;
  3233. return offset + 1;
  3234. };
  3235. Buffer.prototype.writeInt16LE = function writeInt16LE(value, offset, noAssert) {
  3236. value = +value;
  3237. offset = offset | 0;
  3238. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000);
  3239. if (Buffer.TYPED_ARRAY_SUPPORT) {
  3240. this[offset] = value & 0xff;
  3241. this[offset + 1] = value >>> 8;
  3242. } else {
  3243. objectWriteUInt16(this, value, offset, true);
  3244. }
  3245. return offset + 2;
  3246. };
  3247. Buffer.prototype.writeInt16BE = function writeInt16BE(value, offset, noAssert) {
  3248. value = +value;
  3249. offset = offset | 0;
  3250. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000);
  3251. if (Buffer.TYPED_ARRAY_SUPPORT) {
  3252. this[offset] = value >>> 8;
  3253. this[offset + 1] = value & 0xff;
  3254. } else {
  3255. objectWriteUInt16(this, value, offset, false);
  3256. }
  3257. return offset + 2;
  3258. };
  3259. Buffer.prototype.writeInt32LE = function writeInt32LE(value, offset, noAssert) {
  3260. value = +value;
  3261. offset = offset | 0;
  3262. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000);
  3263. if (Buffer.TYPED_ARRAY_SUPPORT) {
  3264. this[offset] = value & 0xff;
  3265. this[offset + 1] = value >>> 8;
  3266. this[offset + 2] = value >>> 16;
  3267. this[offset + 3] = value >>> 24;
  3268. } else {
  3269. objectWriteUInt32(this, value, offset, true);
  3270. }
  3271. return offset + 4;
  3272. };
  3273. Buffer.prototype.writeInt32BE = function writeInt32BE(value, offset, noAssert) {
  3274. value = +value;
  3275. offset = offset | 0;
  3276. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000);
  3277. if (value < 0) value = 0xffffffff + value + 1;
  3278. if (Buffer.TYPED_ARRAY_SUPPORT) {
  3279. this[offset] = value >>> 24;
  3280. this[offset + 1] = value >>> 16;
  3281. this[offset + 2] = value >>> 8;
  3282. this[offset + 3] = value & 0xff;
  3283. } else {
  3284. objectWriteUInt32(this, value, offset, false);
  3285. }
  3286. return offset + 4;
  3287. };
  3288. function checkIEEE754(buf, value, offset, ext, max, min) {
  3289. if (offset + ext > buf.length) throw new RangeError('Index out of range');
  3290. if (offset < 0) throw new RangeError('Index out of range');
  3291. }
  3292. function writeFloat(buf, value, offset, littleEndian, noAssert) {
  3293. if (!noAssert) {
  3294. checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38);
  3295. }
  3296. write(buf, value, offset, littleEndian, 23, 4);
  3297. return offset + 4;
  3298. }
  3299. Buffer.prototype.writeFloatLE = function writeFloatLE(value, offset, noAssert) {
  3300. return writeFloat(this, value, offset, true, noAssert);
  3301. };
  3302. Buffer.prototype.writeFloatBE = function writeFloatBE(value, offset, noAssert) {
  3303. return writeFloat(this, value, offset, false, noAssert);
  3304. };
  3305. function writeDouble(buf, value, offset, littleEndian, noAssert) {
  3306. if (!noAssert) {
  3307. checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308);
  3308. }
  3309. write(buf, value, offset, littleEndian, 52, 8);
  3310. return offset + 8;
  3311. }
  3312. Buffer.prototype.writeDoubleLE = function writeDoubleLE(value, offset, noAssert) {
  3313. return writeDouble(this, value, offset, true, noAssert);
  3314. };
  3315. Buffer.prototype.writeDoubleBE = function writeDoubleBE(value, offset, noAssert) {
  3316. return writeDouble(this, value, offset, false, noAssert);
  3317. }; // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
  3318. Buffer.prototype.copy = function copy(target, targetStart, start, end) {
  3319. if (!start) start = 0;
  3320. if (!end && end !== 0) end = this.length;
  3321. if (targetStart >= target.length) targetStart = target.length;
  3322. if (!targetStart) targetStart = 0;
  3323. if (end > 0 && end < start) end = start; // Copy 0 bytes; we're done
  3324. if (end === start) return 0;
  3325. if (target.length === 0 || this.length === 0) return 0; // Fatal error conditions
  3326. if (targetStart < 0) {
  3327. throw new RangeError('targetStart out of bounds');
  3328. }
  3329. if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds');
  3330. if (end < 0) throw new RangeError('sourceEnd out of bounds'); // Are we oob?
  3331. if (end > this.length) end = this.length;
  3332. if (target.length - targetStart < end - start) {
  3333. end = target.length - targetStart + start;
  3334. }
  3335. var len = end - start;
  3336. var i;
  3337. if (this === target && start < targetStart && targetStart < end) {
  3338. // descending copy from end
  3339. for (i = len - 1; i >= 0; --i) {
  3340. target[i + targetStart] = this[i + start];
  3341. }
  3342. } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {
  3343. // ascending copy from start
  3344. for (i = 0; i < len; ++i) {
  3345. target[i + targetStart] = this[i + start];
  3346. }
  3347. } else {
  3348. Uint8Array.prototype.set.call(target, this.subarray(start, start + len), targetStart);
  3349. }
  3350. return len;
  3351. }; // Usage:
  3352. // buffer.fill(number[, offset[, end]])
  3353. // buffer.fill(buffer[, offset[, end]])
  3354. // buffer.fill(string[, offset[, end]][, encoding])
  3355. Buffer.prototype.fill = function fill(val, start, end, encoding) {
  3356. // Handle string cases:
  3357. if (typeof val === 'string') {
  3358. if (typeof start === 'string') {
  3359. encoding = start;
  3360. start = 0;
  3361. end = this.length;
  3362. } else if (typeof end === 'string') {
  3363. encoding = end;
  3364. end = this.length;
  3365. }
  3366. if (val.length === 1) {
  3367. var code = val.charCodeAt(0);
  3368. if (code < 256) {
  3369. val = code;
  3370. }
  3371. }
  3372. if (encoding !== undefined && typeof encoding !== 'string') {
  3373. throw new TypeError('encoding must be a string');
  3374. }
  3375. if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
  3376. throw new TypeError('Unknown encoding: ' + encoding);
  3377. }
  3378. } else if (typeof val === 'number') {
  3379. val = val & 255;
  3380. } // Invalid ranges are not set to a default, so can range check early.
  3381. if (start < 0 || this.length < start || this.length < end) {
  3382. throw new RangeError('Out of range index');
  3383. }
  3384. if (end <= start) {
  3385. return this;
  3386. }
  3387. start = start >>> 0;
  3388. end = end === undefined ? this.length : end >>> 0;
  3389. if (!val) val = 0;
  3390. var i;
  3391. if (typeof val === 'number') {
  3392. for (i = start; i < end; ++i) {
  3393. this[i] = val;
  3394. }
  3395. } else {
  3396. var bytes = internalIsBuffer(val) ? val : utf8ToBytes(new Buffer(val, encoding).toString());
  3397. var len = bytes.length;
  3398. for (i = 0; i < end - start; ++i) {
  3399. this[i + start] = bytes[i % len];
  3400. }
  3401. }
  3402. return this;
  3403. }; // HELPER FUNCTIONS
  3404. // ================
  3405. var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g;
  3406. function base64clean(str) {
  3407. // Node strips out invalid characters like \n and \t from the string, base64-js does not
  3408. str = stringtrim(str).replace(INVALID_BASE64_RE, ''); // Node converts strings with length < 2 to ''
  3409. if (str.length < 2) return ''; // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
  3410. while (str.length % 4 !== 0) {
  3411. str = str + '=';
  3412. }
  3413. return str;
  3414. }
  3415. function stringtrim(str) {
  3416. if (str.trim) return str.trim();
  3417. return str.replace(/^\s+|\s+$/g, '');
  3418. }
  3419. function toHex(n) {
  3420. if (n < 16) return '0' + n.toString(16);
  3421. return n.toString(16);
  3422. }
  3423. function utf8ToBytes(string, units) {
  3424. units = units || Infinity;
  3425. var codePoint;
  3426. var length = string.length;
  3427. var leadSurrogate = null;
  3428. var bytes = [];
  3429. for (var i = 0; i < length; ++i) {
  3430. codePoint = string.charCodeAt(i); // is surrogate component
  3431. if (codePoint > 0xD7FF && codePoint < 0xE000) {
  3432. // last char was a lead
  3433. if (!leadSurrogate) {
  3434. // no lead yet
  3435. if (codePoint > 0xDBFF) {
  3436. // unexpected trail
  3437. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
  3438. continue;
  3439. } else if (i + 1 === length) {
  3440. // unpaired lead
  3441. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
  3442. continue;
  3443. } // valid lead
  3444. leadSurrogate = codePoint;
  3445. continue;
  3446. } // 2 leads in a row
  3447. if (codePoint < 0xDC00) {
  3448. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
  3449. leadSurrogate = codePoint;
  3450. continue;
  3451. } // valid surrogate pair
  3452. codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000;
  3453. } else if (leadSurrogate) {
  3454. // valid bmp char, but last char was a lead
  3455. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
  3456. }
  3457. leadSurrogate = null; // encode utf8
  3458. if (codePoint < 0x80) {
  3459. if ((units -= 1) < 0) break;
  3460. bytes.push(codePoint);
  3461. } else if (codePoint < 0x800) {
  3462. if ((units -= 2) < 0) break;
  3463. bytes.push(codePoint >> 0x6 | 0xC0, codePoint & 0x3F | 0x80);
  3464. } else if (codePoint < 0x10000) {
  3465. if ((units -= 3) < 0) break;
  3466. bytes.push(codePoint >> 0xC | 0xE0, codePoint >> 0x6 & 0x3F | 0x80, codePoint & 0x3F | 0x80);
  3467. } else if (codePoint < 0x110000) {
  3468. if ((units -= 4) < 0) break;
  3469. bytes.push(codePoint >> 0x12 | 0xF0, codePoint >> 0xC & 0x3F | 0x80, codePoint >> 0x6 & 0x3F | 0x80, codePoint & 0x3F | 0x80);
  3470. } else {
  3471. throw new Error('Invalid code point');
  3472. }
  3473. }
  3474. return bytes;
  3475. }
  3476. function asciiToBytes(str) {
  3477. var byteArray = [];
  3478. for (var i = 0; i < str.length; ++i) {
  3479. // Node's code seems to be doing this and not & 0x7F..
  3480. byteArray.push(str.charCodeAt(i) & 0xFF);
  3481. }
  3482. return byteArray;
  3483. }
  3484. function utf16leToBytes(str, units) {
  3485. var c, hi, lo;
  3486. var byteArray = [];
  3487. for (var i = 0; i < str.length; ++i) {
  3488. if ((units -= 2) < 0) break;
  3489. c = str.charCodeAt(i);
  3490. hi = c >> 8;
  3491. lo = c % 256;
  3492. byteArray.push(lo);
  3493. byteArray.push(hi);
  3494. }
  3495. return byteArray;
  3496. }
  3497. function base64ToBytes(str) {
  3498. return toByteArray(base64clean(str));
  3499. }
  3500. function blitBuffer(src, dst, offset, length) {
  3501. for (var i = 0; i < length; ++i) {
  3502. if (i + offset >= dst.length || i >= src.length) break;
  3503. dst[i + offset] = src[i];
  3504. }
  3505. return i;
  3506. }
  3507. function isnan(val) {
  3508. return val !== val; // eslint-disable-line no-self-compare
  3509. } // the following is from is-buffer, also by Feross Aboukhadijeh and with same lisence
  3510. // The _isBuffer check is for Safari 5-7 support, because it's missing
  3511. // Object.prototype.constructor. Remove this eventually
  3512. function isBuffer(obj) {
  3513. return obj != null && (!!obj._isBuffer || isFastBuffer(obj) || isSlowBuffer(obj));
  3514. }
  3515. function isFastBuffer(obj) {
  3516. return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj);
  3517. } // For Node v0.10 support. Remove this eventually.
  3518. function isSlowBuffer(obj) {
  3519. return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isFastBuffer(obj.slice(0, 0));
  3520. }
  3521. var fs = ( _shim_fs$1 && _shim_fs ) || _shim_fs$1;
  3522. /**
  3523. * @class
  3524. */
  3525. var LineByLine =
  3526. /*#__PURE__*/
  3527. function () {
  3528. function LineByLine(file, options) {
  3529. _classCallCheck(this, LineByLine);
  3530. options = options || {};
  3531. if (!options.readChunk) options.readChunk = 1024;
  3532. if (!options.newLineCharacter) {
  3533. options.newLineCharacter = 0x0a; //linux line ending
  3534. } else {
  3535. options.newLineCharacter = options.newLineCharacter.charCodeAt(0);
  3536. }
  3537. if (typeof file === 'number') {
  3538. this.fd = file;
  3539. } else {
  3540. this.fd = fs.openSync(file, 'r');
  3541. }
  3542. this.options = options;
  3543. this.newLineCharacter = options.newLineCharacter;
  3544. this.reset();
  3545. }
  3546. _createClass(LineByLine, [{
  3547. key: "_searchInBuffer",
  3548. value: function _searchInBuffer(buffer, hexNeedle) {
  3549. var found = -1;
  3550. for (var i = 0; i <= buffer.length; i++) {
  3551. var b_byte = buffer[i];
  3552. if (b_byte === hexNeedle) {
  3553. found = i;
  3554. break;
  3555. }
  3556. }
  3557. return found;
  3558. }
  3559. }, {
  3560. key: "reset",
  3561. value: function reset() {
  3562. this.eofReached = false;
  3563. this.linesCache = [];
  3564. this.fdPosition = 0;
  3565. }
  3566. }, {
  3567. key: "close",
  3568. value: function close() {
  3569. fs.closeSync(this.fd);
  3570. this.fd = null;
  3571. }
  3572. }, {
  3573. key: "_extractLines",
  3574. value: function _extractLines(buffer) {
  3575. var line;
  3576. var lines = [];
  3577. var bufferPosition = 0;
  3578. var lastNewLineBufferPosition = 0;
  3579. while (true) {
  3580. var bufferPositionValue = buffer[bufferPosition++];
  3581. if (bufferPositionValue === this.newLineCharacter) {
  3582. line = buffer.slice(lastNewLineBufferPosition, bufferPosition);
  3583. lines.push(line);
  3584. lastNewLineBufferPosition = bufferPosition;
  3585. } else if (!bufferPositionValue) {
  3586. break;
  3587. }
  3588. }
  3589. var leftovers = buffer.slice(lastNewLineBufferPosition, bufferPosition);
  3590. if (leftovers.length) {
  3591. lines.push(leftovers);
  3592. }
  3593. return lines;
  3594. }
  3595. }, {
  3596. key: "_readChunk",
  3597. value: function _readChunk(lineLeftovers) {
  3598. var totalBytesRead = 0;
  3599. var bytesRead;
  3600. var buffers = [];
  3601. do {
  3602. var readBuffer = new Buffer(this.options.readChunk);
  3603. bytesRead = fs.readSync(this.fd, readBuffer, 0, this.options.readChunk, this.fdPosition);
  3604. totalBytesRead = totalBytesRead + bytesRead;
  3605. this.fdPosition = this.fdPosition + bytesRead;
  3606. buffers.push(readBuffer);
  3607. } while (bytesRead && this._searchInBuffer(buffers[buffers.length - 1], this.options.newLineCharacter) === -1);
  3608. var bufferData = Buffer.concat(buffers);
  3609. if (bytesRead < this.options.readChunk) {
  3610. this.eofReached = true;
  3611. bufferData = bufferData.slice(0, totalBytesRead);
  3612. }
  3613. if (totalBytesRead) {
  3614. this.linesCache = this._extractLines(bufferData);
  3615. if (lineLeftovers) {
  3616. this.linesCache[0] = Buffer.concat([lineLeftovers, this.linesCache[0]]);
  3617. }
  3618. }
  3619. return totalBytesRead;
  3620. }
  3621. }, {
  3622. key: "next",
  3623. value: function next() {
  3624. if (!this.fd) return false;
  3625. var line = false;
  3626. if (this.eofReached && this.linesCache.length === 0) {
  3627. return line;
  3628. }
  3629. var bytesRead;
  3630. if (!this.linesCache.length) {
  3631. bytesRead = this._readChunk();
  3632. }
  3633. if (this.linesCache.length) {
  3634. line = this.linesCache.shift();
  3635. var lastLineCharacter = line[line.length - 1];
  3636. if (lastLineCharacter !== 0x0a) {
  3637. bytesRead = this._readChunk(line);
  3638. if (bytesRead) {
  3639. line = this.linesCache.shift();
  3640. }
  3641. }
  3642. }
  3643. if (this.eofReached && this.linesCache.length === 0) {
  3644. this.close();
  3645. }
  3646. if (line && line[line.length - 1] === this.newLineCharacter) {
  3647. line = line.slice(0, line.length - 1);
  3648. }
  3649. return line;
  3650. }
  3651. }]);
  3652. return LineByLine;
  3653. }();
  3654. var readlines = LineByLine;
  3655. var ConfigError =
  3656. /*#__PURE__*/
  3657. function (_Error) {
  3658. _inherits(ConfigError, _Error);
  3659. function ConfigError() {
  3660. _classCallCheck(this, ConfigError);
  3661. return _possibleConstructorReturn(this, _getPrototypeOf(ConfigError).apply(this, arguments));
  3662. }
  3663. return ConfigError;
  3664. }(_wrapNativeSuper(Error));
  3665. var DebugError =
  3666. /*#__PURE__*/
  3667. function (_Error2) {
  3668. _inherits(DebugError, _Error2);
  3669. function DebugError() {
  3670. _classCallCheck(this, DebugError);
  3671. return _possibleConstructorReturn(this, _getPrototypeOf(DebugError).apply(this, arguments));
  3672. }
  3673. return DebugError;
  3674. }(_wrapNativeSuper(Error));
  3675. var UndefinedParserError$1 =
  3676. /*#__PURE__*/
  3677. function (_Error3) {
  3678. _inherits(UndefinedParserError, _Error3);
  3679. function UndefinedParserError() {
  3680. _classCallCheck(this, UndefinedParserError);
  3681. return _possibleConstructorReturn(this, _getPrototypeOf(UndefinedParserError).apply(this, arguments));
  3682. }
  3683. return UndefinedParserError;
  3684. }(_wrapNativeSuper(Error));
  3685. var errors = {
  3686. ConfigError: ConfigError,
  3687. DebugError: DebugError,
  3688. UndefinedParserError: UndefinedParserError$1
  3689. };
  3690. // based off https://github.com/defunctzombie/node-process/blob/master/browser.js
  3691. function defaultSetTimout() {
  3692. throw new Error('setTimeout has not been defined');
  3693. }
  3694. function defaultClearTimeout() {
  3695. throw new Error('clearTimeout has not been defined');
  3696. }
  3697. var cachedSetTimeout = defaultSetTimout;
  3698. var cachedClearTimeout = defaultClearTimeout;
  3699. if (typeof global$1.setTimeout === 'function') {
  3700. cachedSetTimeout = setTimeout;
  3701. }
  3702. if (typeof global$1.clearTimeout === 'function') {
  3703. cachedClearTimeout = clearTimeout;
  3704. }
  3705. function runTimeout(fun) {
  3706. if (cachedSetTimeout === setTimeout) {
  3707. //normal enviroments in sane situations
  3708. return setTimeout(fun, 0);
  3709. } // if setTimeout wasn't available but was latter defined
  3710. if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
  3711. cachedSetTimeout = setTimeout;
  3712. return setTimeout(fun, 0);
  3713. }
  3714. try {
  3715. // when when somebody has screwed with setTimeout but no I.E. maddness
  3716. return cachedSetTimeout(fun, 0);
  3717. } catch (e) {
  3718. try {
  3719. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  3720. return cachedSetTimeout.call(null, fun, 0);
  3721. } catch (e) {
  3722. // 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
  3723. return cachedSetTimeout.call(this, fun, 0);
  3724. }
  3725. }
  3726. }
  3727. function runClearTimeout(marker) {
  3728. if (cachedClearTimeout === clearTimeout) {
  3729. //normal enviroments in sane situations
  3730. return clearTimeout(marker);
  3731. } // if clearTimeout wasn't available but was latter defined
  3732. if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
  3733. cachedClearTimeout = clearTimeout;
  3734. return clearTimeout(marker);
  3735. }
  3736. try {
  3737. // when when somebody has screwed with setTimeout but no I.E. maddness
  3738. return cachedClearTimeout(marker);
  3739. } catch (e) {
  3740. try {
  3741. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  3742. return cachedClearTimeout.call(null, marker);
  3743. } catch (e) {
  3744. // 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.
  3745. // Some versions of I.E. have different rules for clearTimeout vs setTimeout
  3746. return cachedClearTimeout.call(this, marker);
  3747. }
  3748. }
  3749. }
  3750. var queue = [];
  3751. var draining = false;
  3752. var currentQueue;
  3753. var queueIndex = -1;
  3754. function cleanUpNextTick() {
  3755. if (!draining || !currentQueue) {
  3756. return;
  3757. }
  3758. draining = false;
  3759. if (currentQueue.length) {
  3760. queue = currentQueue.concat(queue);
  3761. } else {
  3762. queueIndex = -1;
  3763. }
  3764. if (queue.length) {
  3765. drainQueue();
  3766. }
  3767. }
  3768. function drainQueue() {
  3769. if (draining) {
  3770. return;
  3771. }
  3772. var timeout = runTimeout(cleanUpNextTick);
  3773. draining = true;
  3774. var len = queue.length;
  3775. while (len) {
  3776. currentQueue = queue;
  3777. queue = [];
  3778. while (++queueIndex < len) {
  3779. if (currentQueue) {
  3780. currentQueue[queueIndex].run();
  3781. }
  3782. }
  3783. queueIndex = -1;
  3784. len = queue.length;
  3785. }
  3786. currentQueue = null;
  3787. draining = false;
  3788. runClearTimeout(timeout);
  3789. }
  3790. function nextTick(fun) {
  3791. var args = new Array(arguments.length - 1);
  3792. if (arguments.length > 1) {
  3793. for (var i = 1; i < arguments.length; i++) {
  3794. args[i - 1] = arguments[i];
  3795. }
  3796. }
  3797. queue.push(new Item(fun, args));
  3798. if (queue.length === 1 && !draining) {
  3799. runTimeout(drainQueue);
  3800. }
  3801. } // v8 likes predictible objects
  3802. function Item(fun, array) {
  3803. this.fun = fun;
  3804. this.array = array;
  3805. }
  3806. Item.prototype.run = function () {
  3807. this.fun.apply(null, this.array);
  3808. };
  3809. var title = 'browser';
  3810. var platform = 'browser';
  3811. var browser = true;
  3812. var env = {};
  3813. var argv = [];
  3814. var version$2 = ''; // empty string to avoid regexp issues
  3815. var versions = {};
  3816. var release = {};
  3817. var config = {};
  3818. function noop() {}
  3819. var on = noop;
  3820. var addListener = noop;
  3821. var once = noop;
  3822. var off = noop;
  3823. var removeListener = noop;
  3824. var removeAllListeners = noop;
  3825. var emit = noop;
  3826. function binding(name) {
  3827. throw new Error('process.binding is not supported');
  3828. }
  3829. function cwd() {
  3830. return '/';
  3831. }
  3832. function chdir(dir) {
  3833. throw new Error('process.chdir is not supported');
  3834. }
  3835. function umask() {
  3836. return 0;
  3837. } // from https://github.com/kumavis/browser-process-hrtime/blob/master/index.js
  3838. var performance = global$1.performance || {};
  3839. var performanceNow = performance.now || performance.mozNow || performance.msNow || performance.oNow || performance.webkitNow || function () {
  3840. return new Date().getTime();
  3841. }; // generate timestamp or delta
  3842. // see http://nodejs.org/api/process.html#process_process_hrtime
  3843. function hrtime(previousTimestamp) {
  3844. var clocktime = performanceNow.call(performance) * 1e-3;
  3845. var seconds = Math.floor(clocktime);
  3846. var nanoseconds = Math.floor(clocktime % 1 * 1e9);
  3847. if (previousTimestamp) {
  3848. seconds = seconds - previousTimestamp[0];
  3849. nanoseconds = nanoseconds - previousTimestamp[1];
  3850. if (nanoseconds < 0) {
  3851. seconds--;
  3852. nanoseconds += 1e9;
  3853. }
  3854. }
  3855. return [seconds, nanoseconds];
  3856. }
  3857. var startTime = new Date();
  3858. function uptime() {
  3859. var currentTime = new Date();
  3860. var dif = currentTime - startTime;
  3861. return dif / 1000;
  3862. }
  3863. var process = {
  3864. nextTick: nextTick,
  3865. title: title,
  3866. browser: browser,
  3867. env: env,
  3868. argv: argv,
  3869. version: version$2,
  3870. versions: versions,
  3871. on: on,
  3872. addListener: addListener,
  3873. once: once,
  3874. off: off,
  3875. removeListener: removeListener,
  3876. removeAllListeners: removeAllListeners,
  3877. emit: emit,
  3878. binding: binding,
  3879. cwd: cwd,
  3880. chdir: chdir,
  3881. umask: umask,
  3882. hrtime: hrtime,
  3883. platform: platform,
  3884. release: release,
  3885. config: config,
  3886. uptime: uptime
  3887. };
  3888. var semver = createCommonjsModule(function (module, exports) {
  3889. exports = module.exports = SemVer; // The debug function is excluded entirely from the minified version.
  3890. /* nomin */
  3891. var debug;
  3892. /* nomin */
  3893. if (_typeof(process) === 'object' &&
  3894. /* nomin */
  3895. process.env &&
  3896. /* nomin */
  3897. process.env.NODE_DEBUG &&
  3898. /* nomin */
  3899. /\bsemver\b/i.test(process.env.NODE_DEBUG))
  3900. /* nomin */
  3901. debug = function debug() {
  3902. /* nomin */
  3903. var args = Array.prototype.slice.call(arguments, 0);
  3904. /* nomin */
  3905. args.unshift('SEMVER');
  3906. /* nomin */
  3907. console.log.apply(console, args);
  3908. /* nomin */
  3909. };
  3910. /* nomin */
  3911. else
  3912. /* nomin */
  3913. debug = function debug() {}; // Note: this is the semver.org version of the spec that it implements
  3914. // Not necessarily the package version of this code.
  3915. exports.SEMVER_SPEC_VERSION = '2.0.0';
  3916. var MAX_LENGTH = 256;
  3917. var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || 9007199254740991; // The actual regexps go on exports.re
  3918. var re = exports.re = [];
  3919. var src = exports.src = [];
  3920. var R = 0; // The following Regular Expressions can be used for tokenizing,
  3921. // validating, and parsing SemVer version strings.
  3922. // ## Numeric Identifier
  3923. // A single `0`, or a non-zero digit followed by zero or more digits.
  3924. var NUMERICIDENTIFIER = R++;
  3925. src[NUMERICIDENTIFIER] = '0|[1-9]\\d*';
  3926. var NUMERICIDENTIFIERLOOSE = R++;
  3927. src[NUMERICIDENTIFIERLOOSE] = '[0-9]+'; // ## Non-numeric Identifier
  3928. // Zero or more digits, followed by a letter or hyphen, and then zero or
  3929. // more letters, digits, or hyphens.
  3930. var NONNUMERICIDENTIFIER = R++;
  3931. src[NONNUMERICIDENTIFIER] = '\\d*[a-zA-Z-][a-zA-Z0-9-]*'; // ## Main Version
  3932. // Three dot-separated numeric identifiers.
  3933. var MAINVERSION = R++;
  3934. src[MAINVERSION] = '(' + src[NUMERICIDENTIFIER] + ')\\.' + '(' + src[NUMERICIDENTIFIER] + ')\\.' + '(' + src[NUMERICIDENTIFIER] + ')';
  3935. var MAINVERSIONLOOSE = R++;
  3936. src[MAINVERSIONLOOSE] = '(' + src[NUMERICIDENTIFIERLOOSE] + ')\\.' + '(' + src[NUMERICIDENTIFIERLOOSE] + ')\\.' + '(' + src[NUMERICIDENTIFIERLOOSE] + ')'; // ## Pre-release Version Identifier
  3937. // A numeric identifier, or a non-numeric identifier.
  3938. var PRERELEASEIDENTIFIER = R++;
  3939. src[PRERELEASEIDENTIFIER] = '(?:' + src[NUMERICIDENTIFIER] + '|' + src[NONNUMERICIDENTIFIER] + ')';
  3940. var PRERELEASEIDENTIFIERLOOSE = R++;
  3941. src[PRERELEASEIDENTIFIERLOOSE] = '(?:' + src[NUMERICIDENTIFIERLOOSE] + '|' + src[NONNUMERICIDENTIFIER] + ')'; // ## Pre-release Version
  3942. // Hyphen, followed by one or more dot-separated pre-release version
  3943. // identifiers.
  3944. var PRERELEASE = R++;
  3945. src[PRERELEASE] = '(?:-(' + src[PRERELEASEIDENTIFIER] + '(?:\\.' + src[PRERELEASEIDENTIFIER] + ')*))';
  3946. var PRERELEASELOOSE = R++;
  3947. src[PRERELEASELOOSE] = '(?:-?(' + src[PRERELEASEIDENTIFIERLOOSE] + '(?:\\.' + src[PRERELEASEIDENTIFIERLOOSE] + ')*))'; // ## Build Metadata Identifier
  3948. // Any combination of digits, letters, or hyphens.
  3949. var BUILDIDENTIFIER = R++;
  3950. src[BUILDIDENTIFIER] = '[0-9A-Za-z-]+'; // ## Build Metadata
  3951. // Plus sign, followed by one or more period-separated build metadata
  3952. // identifiers.
  3953. var BUILD = R++;
  3954. src[BUILD] = '(?:\\+(' + src[BUILDIDENTIFIER] + '(?:\\.' + src[BUILDIDENTIFIER] + ')*))'; // ## Full Version String
  3955. // A main version, followed optionally by a pre-release version and
  3956. // build metadata.
  3957. // Note that the only major, minor, patch, and pre-release sections of
  3958. // the version string are capturing groups. The build metadata is not a
  3959. // capturing group, because it should not ever be used in version
  3960. // comparison.
  3961. var FULL = R++;
  3962. var FULLPLAIN = 'v?' + src[MAINVERSION] + src[PRERELEASE] + '?' + src[BUILD] + '?';
  3963. src[FULL] = '^' + FULLPLAIN + '$'; // like full, but allows v1.2.3 and =1.2.3, which people do sometimes.
  3964. // also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty
  3965. // common in the npm registry.
  3966. var LOOSEPLAIN = '[v=\\s]*' + src[MAINVERSIONLOOSE] + src[PRERELEASELOOSE] + '?' + src[BUILD] + '?';
  3967. var LOOSE = R++;
  3968. src[LOOSE] = '^' + LOOSEPLAIN + '$';
  3969. var GTLT = R++;
  3970. src[GTLT] = '((?:<|>)?=?)'; // Something like "2.*" or "1.2.x".
  3971. // Note that "x.x" is a valid xRange identifer, meaning "any version"
  3972. // Only the first item is strictly required.
  3973. var XRANGEIDENTIFIERLOOSE = R++;
  3974. src[XRANGEIDENTIFIERLOOSE] = src[NUMERICIDENTIFIERLOOSE] + '|x|X|\\*';
  3975. var XRANGEIDENTIFIER = R++;
  3976. src[XRANGEIDENTIFIER] = src[NUMERICIDENTIFIER] + '|x|X|\\*';
  3977. var XRANGEPLAIN = R++;
  3978. src[XRANGEPLAIN] = '[v=\\s]*(' + src[XRANGEIDENTIFIER] + ')' + '(?:\\.(' + src[XRANGEIDENTIFIER] + ')' + '(?:\\.(' + src[XRANGEIDENTIFIER] + ')' + '(?:' + src[PRERELEASE] + ')?' + src[BUILD] + '?' + ')?)?';
  3979. var XRANGEPLAINLOOSE = R++;
  3980. src[XRANGEPLAINLOOSE] = '[v=\\s]*(' + src[XRANGEIDENTIFIERLOOSE] + ')' + '(?:\\.(' + src[XRANGEIDENTIFIERLOOSE] + ')' + '(?:\\.(' + src[XRANGEIDENTIFIERLOOSE] + ')' + '(?:' + src[PRERELEASELOOSE] + ')?' + src[BUILD] + '?' + ')?)?';
  3981. var XRANGE = R++;
  3982. src[XRANGE] = '^' + src[GTLT] + '\\s*' + src[XRANGEPLAIN] + '$';
  3983. var XRANGELOOSE = R++;
  3984. src[XRANGELOOSE] = '^' + src[GTLT] + '\\s*' + src[XRANGEPLAINLOOSE] + '$'; // Tilde ranges.
  3985. // Meaning is "reasonably at or greater than"
  3986. var LONETILDE = R++;
  3987. src[LONETILDE] = '(?:~>?)';
  3988. var TILDETRIM = R++;
  3989. src[TILDETRIM] = '(\\s*)' + src[LONETILDE] + '\\s+';
  3990. re[TILDETRIM] = new RegExp(src[TILDETRIM], 'g');
  3991. var tildeTrimReplace = '$1~';
  3992. var TILDE = R++;
  3993. src[TILDE] = '^' + src[LONETILDE] + src[XRANGEPLAIN] + '$';
  3994. var TILDELOOSE = R++;
  3995. src[TILDELOOSE] = '^' + src[LONETILDE] + src[XRANGEPLAINLOOSE] + '$'; // Caret ranges.
  3996. // Meaning is "at least and backwards compatible with"
  3997. var LONECARET = R++;
  3998. src[LONECARET] = '(?:\\^)';
  3999. var CARETTRIM = R++;
  4000. src[CARETTRIM] = '(\\s*)' + src[LONECARET] + '\\s+';
  4001. re[CARETTRIM] = new RegExp(src[CARETTRIM], 'g');
  4002. var caretTrimReplace = '$1^';
  4003. var CARET = R++;
  4004. src[CARET] = '^' + src[LONECARET] + src[XRANGEPLAIN] + '$';
  4005. var CARETLOOSE = R++;
  4006. src[CARETLOOSE] = '^' + src[LONECARET] + src[XRANGEPLAINLOOSE] + '$'; // A simple gt/lt/eq thing, or just "" to indicate "any version"
  4007. var COMPARATORLOOSE = R++;
  4008. src[COMPARATORLOOSE] = '^' + src[GTLT] + '\\s*(' + LOOSEPLAIN + ')$|^$';
  4009. var COMPARATOR = R++;
  4010. src[COMPARATOR] = '^' + src[GTLT] + '\\s*(' + FULLPLAIN + ')$|^$'; // An expression to strip any whitespace between the gtlt and the thing
  4011. // it modifies, so that `> 1.2.3` ==> `>1.2.3`
  4012. var COMPARATORTRIM = R++;
  4013. src[COMPARATORTRIM] = '(\\s*)' + src[GTLT] + '\\s*(' + LOOSEPLAIN + '|' + src[XRANGEPLAIN] + ')'; // this one has to use the /g flag
  4014. re[COMPARATORTRIM] = new RegExp(src[COMPARATORTRIM], 'g');
  4015. var comparatorTrimReplace = '$1$2$3'; // Something like `1.2.3 - 1.2.4`
  4016. // Note that these all use the loose form, because they'll be
  4017. // checked against either the strict or loose comparator form
  4018. // later.
  4019. var HYPHENRANGE = R++;
  4020. src[HYPHENRANGE] = '^\\s*(' + src[XRANGEPLAIN] + ')' + '\\s+-\\s+' + '(' + src[XRANGEPLAIN] + ')' + '\\s*$';
  4021. var HYPHENRANGELOOSE = R++;
  4022. src[HYPHENRANGELOOSE] = '^\\s*(' + src[XRANGEPLAINLOOSE] + ')' + '\\s+-\\s+' + '(' + src[XRANGEPLAINLOOSE] + ')' + '\\s*$'; // Star ranges basically just allow anything at all.
  4023. var STAR = R++;
  4024. src[STAR] = '(<|>)?=?\\s*\\*'; // Compile to actual regexp objects.
  4025. // All are flag-free, unless they were created above with a flag.
  4026. for (var i = 0; i < R; i++) {
  4027. debug(i, src[i]);
  4028. if (!re[i]) re[i] = new RegExp(src[i]);
  4029. }
  4030. exports.parse = parse;
  4031. function parse(version, loose) {
  4032. if (version instanceof SemVer) return version;
  4033. if (typeof version !== 'string') return null;
  4034. if (version.length > MAX_LENGTH) return null;
  4035. var r = loose ? re[LOOSE] : re[FULL];
  4036. if (!r.test(version)) return null;
  4037. try {
  4038. return new SemVer(version, loose);
  4039. } catch (er) {
  4040. return null;
  4041. }
  4042. }
  4043. exports.valid = valid;
  4044. function valid(version, loose) {
  4045. var v = parse(version, loose);
  4046. return v ? v.version : null;
  4047. }
  4048. exports.clean = clean;
  4049. function clean(version, loose) {
  4050. var s = parse(version.trim().replace(/^[=v]+/, ''), loose);
  4051. return s ? s.version : null;
  4052. }
  4053. exports.SemVer = SemVer;
  4054. function SemVer(version, loose) {
  4055. if (version instanceof SemVer) {
  4056. if (version.loose === loose) return version;else version = version.version;
  4057. } else if (typeof version !== 'string') {
  4058. throw new TypeError('Invalid Version: ' + version);
  4059. }
  4060. if (version.length > MAX_LENGTH) throw new TypeError('version is longer than ' + MAX_LENGTH + ' characters');
  4061. if (!(this instanceof SemVer)) return new SemVer(version, loose);
  4062. debug('SemVer', version, loose);
  4063. this.loose = loose;
  4064. var m = version.trim().match(loose ? re[LOOSE] : re[FULL]);
  4065. if (!m) throw new TypeError('Invalid Version: ' + version);
  4066. this.raw = version; // these are actually numbers
  4067. this.major = +m[1];
  4068. this.minor = +m[2];
  4069. this.patch = +m[3];
  4070. if (this.major > MAX_SAFE_INTEGER || this.major < 0) throw new TypeError('Invalid major version');
  4071. if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) throw new TypeError('Invalid minor version');
  4072. if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) throw new TypeError('Invalid patch version'); // numberify any prerelease numeric ids
  4073. if (!m[4]) this.prerelease = [];else this.prerelease = m[4].split('.').map(function (id) {
  4074. if (/^[0-9]+$/.test(id)) {
  4075. var num = +id;
  4076. if (num >= 0 && num < MAX_SAFE_INTEGER) return num;
  4077. }
  4078. return id;
  4079. });
  4080. this.build = m[5] ? m[5].split('.') : [];
  4081. this.format();
  4082. }
  4083. SemVer.prototype.format = function () {
  4084. this.version = this.major + '.' + this.minor + '.' + this.patch;
  4085. if (this.prerelease.length) this.version += '-' + this.prerelease.join('.');
  4086. return this.version;
  4087. };
  4088. SemVer.prototype.toString = function () {
  4089. return this.version;
  4090. };
  4091. SemVer.prototype.compare = function (other) {
  4092. debug('SemVer.compare', this.version, this.loose, other);
  4093. if (!(other instanceof SemVer)) other = new SemVer(other, this.loose);
  4094. return this.compareMain(other) || this.comparePre(other);
  4095. };
  4096. SemVer.prototype.compareMain = function (other) {
  4097. if (!(other instanceof SemVer)) other = new SemVer(other, this.loose);
  4098. return compareIdentifiers(this.major, other.major) || compareIdentifiers(this.minor, other.minor) || compareIdentifiers(this.patch, other.patch);
  4099. };
  4100. SemVer.prototype.comparePre = function (other) {
  4101. if (!(other instanceof SemVer)) other = new SemVer(other, this.loose); // NOT having a prerelease is > having one
  4102. 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;
  4103. var i = 0;
  4104. do {
  4105. var a = this.prerelease[i];
  4106. var b = other.prerelease[i];
  4107. debug('prerelease compare', i, a, b);
  4108. 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);
  4109. } while (++i);
  4110. }; // preminor will bump the version up to the next minor release, and immediately
  4111. // down to pre-release. premajor and prepatch work the same way.
  4112. SemVer.prototype.inc = function (release$$1, identifier) {
  4113. switch (release$$1) {
  4114. case 'premajor':
  4115. this.prerelease.length = 0;
  4116. this.patch = 0;
  4117. this.minor = 0;
  4118. this.major++;
  4119. this.inc('pre', identifier);
  4120. break;
  4121. case 'preminor':
  4122. this.prerelease.length = 0;
  4123. this.patch = 0;
  4124. this.minor++;
  4125. this.inc('pre', identifier);
  4126. break;
  4127. case 'prepatch':
  4128. // If this is already a prerelease, it will bump to the next version
  4129. // drop any prereleases that might already exist, since they are not
  4130. // relevant at this point.
  4131. this.prerelease.length = 0;
  4132. this.inc('patch', identifier);
  4133. this.inc('pre', identifier);
  4134. break;
  4135. // If the input is a non-prerelease version, this acts the same as
  4136. // prepatch.
  4137. case 'prerelease':
  4138. if (this.prerelease.length === 0) this.inc('patch', identifier);
  4139. this.inc('pre', identifier);
  4140. break;
  4141. case 'major':
  4142. // If this is a pre-major version, bump up to the same major version.
  4143. // Otherwise increment major.
  4144. // 1.0.0-5 bumps to 1.0.0
  4145. // 1.1.0 bumps to 2.0.0
  4146. if (this.minor !== 0 || this.patch !== 0 || this.prerelease.length === 0) this.major++;
  4147. this.minor = 0;
  4148. this.patch = 0;
  4149. this.prerelease = [];
  4150. break;
  4151. case 'minor':
  4152. // If this is a pre-minor version, bump up to the same minor version.
  4153. // Otherwise increment minor.
  4154. // 1.2.0-5 bumps to 1.2.0
  4155. // 1.2.1 bumps to 1.3.0
  4156. if (this.patch !== 0 || this.prerelease.length === 0) this.minor++;
  4157. this.patch = 0;
  4158. this.prerelease = [];
  4159. break;
  4160. case 'patch':
  4161. // If this is not a pre-release version, it will increment the patch.
  4162. // If it is a pre-release it will bump up to the same patch version.
  4163. // 1.2.0-5 patches to 1.2.0
  4164. // 1.2.0 patches to 1.2.1
  4165. if (this.prerelease.length === 0) this.patch++;
  4166. this.prerelease = [];
  4167. break;
  4168. // This probably shouldn't be used publicly.
  4169. // 1.0.0 "pre" would become 1.0.0-0 which is the wrong direction.
  4170. case 'pre':
  4171. if (this.prerelease.length === 0) this.prerelease = [0];else {
  4172. var i = this.prerelease.length;
  4173. while (--i >= 0) {
  4174. if (typeof this.prerelease[i] === 'number') {
  4175. this.prerelease[i]++;
  4176. i = -2;
  4177. }
  4178. }
  4179. if (i === -1) // didn't increment anything
  4180. this.prerelease.push(0);
  4181. }
  4182. if (identifier) {
  4183. // 1.2.0-beta.1 bumps to 1.2.0-beta.2,
  4184. // 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0
  4185. if (this.prerelease[0] === identifier) {
  4186. if (isNaN(this.prerelease[1])) this.prerelease = [identifier, 0];
  4187. } else this.prerelease = [identifier, 0];
  4188. }
  4189. break;
  4190. default:
  4191. throw new Error('invalid increment argument: ' + release$$1);
  4192. }
  4193. this.format();
  4194. this.raw = this.version;
  4195. return this;
  4196. };
  4197. exports.inc = inc;
  4198. function inc(version, release$$1, loose, identifier) {
  4199. if (typeof loose === 'string') {
  4200. identifier = loose;
  4201. loose = undefined;
  4202. }
  4203. try {
  4204. return new SemVer(version, loose).inc(release$$1, identifier).version;
  4205. } catch (er) {
  4206. return null;
  4207. }
  4208. }
  4209. exports.diff = diff;
  4210. function diff(version1, version2) {
  4211. if (eq(version1, version2)) {
  4212. return null;
  4213. } else {
  4214. var v1 = parse(version1);
  4215. var v2 = parse(version2);
  4216. if (v1.prerelease.length || v2.prerelease.length) {
  4217. for (var key in v1) {
  4218. if (key === 'major' || key === 'minor' || key === 'patch') {
  4219. if (v1[key] !== v2[key]) {
  4220. return 'pre' + key;
  4221. }
  4222. }
  4223. }
  4224. return 'prerelease';
  4225. }
  4226. for (var key in v1) {
  4227. if (key === 'major' || key === 'minor' || key === 'patch') {
  4228. if (v1[key] !== v2[key]) {
  4229. return key;
  4230. }
  4231. }
  4232. }
  4233. }
  4234. }
  4235. exports.compareIdentifiers = compareIdentifiers;
  4236. var numeric = /^[0-9]+$/;
  4237. function compareIdentifiers(a, b) {
  4238. var anum = numeric.test(a);
  4239. var bnum = numeric.test(b);
  4240. if (anum && bnum) {
  4241. a = +a;
  4242. b = +b;
  4243. }
  4244. return anum && !bnum ? -1 : bnum && !anum ? 1 : a < b ? -1 : a > b ? 1 : 0;
  4245. }
  4246. exports.rcompareIdentifiers = rcompareIdentifiers;
  4247. function rcompareIdentifiers(a, b) {
  4248. return compareIdentifiers(b, a);
  4249. }
  4250. exports.major = major;
  4251. function major(a, loose) {
  4252. return new SemVer(a, loose).major;
  4253. }
  4254. exports.minor = minor;
  4255. function minor(a, loose) {
  4256. return new SemVer(a, loose).minor;
  4257. }
  4258. exports.patch = patch;
  4259. function patch(a, loose) {
  4260. return new SemVer(a, loose).patch;
  4261. }
  4262. exports.compare = compare;
  4263. function compare(a, b, loose) {
  4264. return new SemVer(a, loose).compare(new SemVer(b, loose));
  4265. }
  4266. exports.compareLoose = compareLoose;
  4267. function compareLoose(a, b) {
  4268. return compare(a, b, true);
  4269. }
  4270. exports.rcompare = rcompare;
  4271. function rcompare(a, b, loose) {
  4272. return compare(b, a, loose);
  4273. }
  4274. exports.sort = sort;
  4275. function sort(list, loose) {
  4276. return list.sort(function (a, b) {
  4277. return exports.compare(a, b, loose);
  4278. });
  4279. }
  4280. exports.rsort = rsort;
  4281. function rsort(list, loose) {
  4282. return list.sort(function (a, b) {
  4283. return exports.rcompare(a, b, loose);
  4284. });
  4285. }
  4286. exports.gt = gt;
  4287. function gt(a, b, loose) {
  4288. return compare(a, b, loose) > 0;
  4289. }
  4290. exports.lt = lt;
  4291. function lt(a, b, loose) {
  4292. return compare(a, b, loose) < 0;
  4293. }
  4294. exports.eq = eq;
  4295. function eq(a, b, loose) {
  4296. return compare(a, b, loose) === 0;
  4297. }
  4298. exports.neq = neq;
  4299. function neq(a, b, loose) {
  4300. return compare(a, b, loose) !== 0;
  4301. }
  4302. exports.gte = gte;
  4303. function gte(a, b, loose) {
  4304. return compare(a, b, loose) >= 0;
  4305. }
  4306. exports.lte = lte;
  4307. function lte(a, b, loose) {
  4308. return compare(a, b, loose) <= 0;
  4309. }
  4310. exports.cmp = cmp;
  4311. function cmp(a, op, b, loose) {
  4312. var ret;
  4313. switch (op) {
  4314. case '===':
  4315. if (_typeof(a) === 'object') a = a.version;
  4316. if (_typeof(b) === 'object') b = b.version;
  4317. ret = a === b;
  4318. break;
  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. case '=':
  4326. case '==':
  4327. ret = eq(a, b, loose);
  4328. break;
  4329. case '!=':
  4330. ret = neq(a, b, loose);
  4331. break;
  4332. case '>':
  4333. ret = gt(a, b, loose);
  4334. break;
  4335. case '>=':
  4336. ret = gte(a, b, loose);
  4337. break;
  4338. case '<':
  4339. ret = lt(a, b, loose);
  4340. break;
  4341. case '<=':
  4342. ret = lte(a, b, loose);
  4343. break;
  4344. default:
  4345. throw new TypeError('Invalid operator: ' + op);
  4346. }
  4347. return ret;
  4348. }
  4349. exports.Comparator = Comparator;
  4350. function Comparator(comp, loose) {
  4351. if (comp instanceof Comparator) {
  4352. if (comp.loose === loose) return comp;else comp = comp.value;
  4353. }
  4354. if (!(this instanceof Comparator)) return new Comparator(comp, loose);
  4355. debug('comparator', comp, loose);
  4356. this.loose = loose;
  4357. this.parse(comp);
  4358. if (this.semver === ANY) this.value = '';else this.value = this.operator + this.semver.version;
  4359. debug('comp', this);
  4360. }
  4361. var ANY = {};
  4362. Comparator.prototype.parse = function (comp) {
  4363. var r = this.loose ? re[COMPARATORLOOSE] : re[COMPARATOR];
  4364. var m = comp.match(r);
  4365. if (!m) throw new TypeError('Invalid comparator: ' + comp);
  4366. this.operator = m[1];
  4367. if (this.operator === '=') this.operator = ''; // if it literally is just '>' or '' then allow anything.
  4368. if (!m[2]) this.semver = ANY;else this.semver = new SemVer(m[2], this.loose);
  4369. };
  4370. Comparator.prototype.toString = function () {
  4371. return this.value;
  4372. };
  4373. Comparator.prototype.test = function (version) {
  4374. debug('Comparator.test', version, this.loose);
  4375. if (this.semver === ANY) return true;
  4376. if (typeof version === 'string') version = new SemVer(version, this.loose);
  4377. return cmp(version, this.operator, this.semver, this.loose);
  4378. };
  4379. Comparator.prototype.intersects = function (comp, loose) {
  4380. if (!(comp instanceof Comparator)) {
  4381. throw new TypeError('a Comparator is required');
  4382. }
  4383. var rangeTmp;
  4384. if (this.operator === '') {
  4385. rangeTmp = new Range(comp.value, loose);
  4386. return satisfies(this.value, rangeTmp, loose);
  4387. } else if (comp.operator === '') {
  4388. rangeTmp = new Range(this.value, loose);
  4389. return satisfies(comp.semver, rangeTmp, loose);
  4390. }
  4391. var sameDirectionIncreasing = (this.operator === '>=' || this.operator === '>') && (comp.operator === '>=' || comp.operator === '>');
  4392. var sameDirectionDecreasing = (this.operator === '<=' || this.operator === '<') && (comp.operator === '<=' || comp.operator === '<');
  4393. var sameSemVer = this.semver.version === comp.semver.version;
  4394. var differentDirectionsInclusive = (this.operator === '>=' || this.operator === '<=') && (comp.operator === '>=' || comp.operator === '<=');
  4395. var oppositeDirectionsLessThan = cmp(this.semver, '<', comp.semver, loose) && (this.operator === '>=' || this.operator === '>') && (comp.operator === '<=' || comp.operator === '<');
  4396. var oppositeDirectionsGreaterThan = cmp(this.semver, '>', comp.semver, loose) && (this.operator === '<=' || this.operator === '<') && (comp.operator === '>=' || comp.operator === '>');
  4397. return sameDirectionIncreasing || sameDirectionDecreasing || sameSemVer && differentDirectionsInclusive || oppositeDirectionsLessThan || oppositeDirectionsGreaterThan;
  4398. };
  4399. exports.Range = Range;
  4400. function Range(range, loose) {
  4401. if (range instanceof Range) {
  4402. if (range.loose === loose) {
  4403. return range;
  4404. } else {
  4405. return new Range(range.raw, loose);
  4406. }
  4407. }
  4408. if (range instanceof Comparator) {
  4409. return new Range(range.value, loose);
  4410. }
  4411. if (!(this instanceof Range)) return new Range(range, loose);
  4412. this.loose = loose; // First, split based on boolean or ||
  4413. this.raw = range;
  4414. this.set = range.split(/\s*\|\|\s*/).map(function (range) {
  4415. return this.parseRange(range.trim());
  4416. }, this).filter(function (c) {
  4417. // throw out any that are not relevant for whatever reason
  4418. return c.length;
  4419. });
  4420. if (!this.set.length) {
  4421. throw new TypeError('Invalid SemVer Range: ' + range);
  4422. }
  4423. this.format();
  4424. }
  4425. Range.prototype.format = function () {
  4426. this.range = this.set.map(function (comps) {
  4427. return comps.join(' ').trim();
  4428. }).join('||').trim();
  4429. return this.range;
  4430. };
  4431. Range.prototype.toString = function () {
  4432. return this.range;
  4433. };
  4434. Range.prototype.parseRange = function (range) {
  4435. var loose = this.loose;
  4436. range = range.trim();
  4437. debug('range', range, loose); // `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4`
  4438. var hr = loose ? re[HYPHENRANGELOOSE] : re[HYPHENRANGE];
  4439. range = range.replace(hr, hyphenReplace);
  4440. debug('hyphen replace', range); // `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5`
  4441. range = range.replace(re[COMPARATORTRIM], comparatorTrimReplace);
  4442. debug('comparator trim', range, re[COMPARATORTRIM]); // `~ 1.2.3` => `~1.2.3`
  4443. range = range.replace(re[TILDETRIM], tildeTrimReplace); // `^ 1.2.3` => `^1.2.3`
  4444. range = range.replace(re[CARETTRIM], caretTrimReplace); // normalize spaces
  4445. range = range.split(/\s+/).join(' '); // At this point, the range is completely trimmed and
  4446. // ready to be split into comparators.
  4447. var compRe = loose ? re[COMPARATORLOOSE] : re[COMPARATOR];
  4448. var set = range.split(' ').map(function (comp) {
  4449. return parseComparator(comp, loose);
  4450. }).join(' ').split(/\s+/);
  4451. if (this.loose) {
  4452. // in loose mode, throw out any that are not valid comparators
  4453. set = set.filter(function (comp) {
  4454. return !!comp.match(compRe);
  4455. });
  4456. }
  4457. set = set.map(function (comp) {
  4458. return new Comparator(comp, loose);
  4459. });
  4460. return set;
  4461. };
  4462. Range.prototype.intersects = function (range, loose) {
  4463. if (!(range instanceof Range)) {
  4464. throw new TypeError('a Range is required');
  4465. }
  4466. return this.set.some(function (thisComparators) {
  4467. return thisComparators.every(function (thisComparator) {
  4468. return range.set.some(function (rangeComparators) {
  4469. return rangeComparators.every(function (rangeComparator) {
  4470. return thisComparator.intersects(rangeComparator, loose);
  4471. });
  4472. });
  4473. });
  4474. });
  4475. }; // Mostly just for testing and legacy API reasons
  4476. exports.toComparators = toComparators;
  4477. function toComparators(range, loose) {
  4478. return new Range(range, loose).set.map(function (comp) {
  4479. return comp.map(function (c) {
  4480. return c.value;
  4481. }).join(' ').trim().split(' ');
  4482. });
  4483. } // comprised of xranges, tildes, stars, and gtlt's at this point.
  4484. // already replaced the hyphen ranges
  4485. // turn into a set of JUST comparators.
  4486. function parseComparator(comp, loose) {
  4487. debug('comp', comp);
  4488. comp = replaceCarets(comp, loose);
  4489. debug('caret', comp);
  4490. comp = replaceTildes(comp, loose);
  4491. debug('tildes', comp);
  4492. comp = replaceXRanges(comp, loose);
  4493. debug('xrange', comp);
  4494. comp = replaceStars(comp, loose);
  4495. debug('stars', comp);
  4496. return comp;
  4497. }
  4498. function isX(id) {
  4499. return !id || id.toLowerCase() === 'x' || id === '*';
  4500. } // ~, ~> --> * (any, kinda silly)
  4501. // ~2, ~2.x, ~2.x.x, ~>2, ~>2.x ~>2.x.x --> >=2.0.0 <3.0.0
  4502. // ~2.0, ~2.0.x, ~>2.0, ~>2.0.x --> >=2.0.0 <2.1.0
  4503. // ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <1.3.0
  4504. // ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0
  4505. // ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0
  4506. function replaceTildes(comp, loose) {
  4507. return comp.trim().split(/\s+/).map(function (comp) {
  4508. return replaceTilde(comp, loose);
  4509. }).join(' ');
  4510. }
  4511. function replaceTilde(comp, loose) {
  4512. var r = loose ? re[TILDELOOSE] : re[TILDE];
  4513. return comp.replace(r, function (_, M, m, p, pr) {
  4514. debug('tilde', comp, _, M, m, p, pr);
  4515. var ret;
  4516. 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
  4517. ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0';else if (pr) {
  4518. debug('replaceTilde pr', pr);
  4519. if (pr.charAt(0) !== '-') pr = '-' + pr;
  4520. ret = '>=' + M + '.' + m + '.' + p + pr + ' <' + M + '.' + (+m + 1) + '.0';
  4521. } else // ~1.2.3 == >=1.2.3 <1.3.0
  4522. ret = '>=' + M + '.' + m + '.' + p + ' <' + M + '.' + (+m + 1) + '.0';
  4523. debug('tilde return', ret);
  4524. return ret;
  4525. });
  4526. } // ^ --> * (any, kinda silly)
  4527. // ^2, ^2.x, ^2.x.x --> >=2.0.0 <3.0.0
  4528. // ^2.0, ^2.0.x --> >=2.0.0 <3.0.0
  4529. // ^1.2, ^1.2.x --> >=1.2.0 <2.0.0
  4530. // ^1.2.3 --> >=1.2.3 <2.0.0
  4531. // ^1.2.0 --> >=1.2.0 <2.0.0
  4532. function replaceCarets(comp, loose) {
  4533. return comp.trim().split(/\s+/).map(function (comp) {
  4534. return replaceCaret(comp, loose);
  4535. }).join(' ');
  4536. }
  4537. function replaceCaret(comp, loose) {
  4538. debug('caret', comp, loose);
  4539. var r = loose ? re[CARETLOOSE] : re[CARET];
  4540. return comp.replace(r, function (_, M, m, p, pr) {
  4541. debug('caret', comp, _, M, m, p, pr);
  4542. var ret;
  4543. if (isX(M)) ret = '';else if (isX(m)) ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0';else if (isX(p)) {
  4544. if (M === '0') ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0';else ret = '>=' + M + '.' + m + '.0 <' + (+M + 1) + '.0.0';
  4545. } else if (pr) {
  4546. debug('replaceCaret pr', pr);
  4547. if (pr.charAt(0) !== '-') pr = '-' + pr;
  4548. if (M === '0') {
  4549. if (m === '0') ret = '>=' + M + '.' + m + '.' + p + pr + ' <' + M + '.' + m + '.' + (+p + 1);else ret = '>=' + M + '.' + m + '.' + p + pr + ' <' + M + '.' + (+m + 1) + '.0';
  4550. } else ret = '>=' + M + '.' + m + '.' + p + pr + ' <' + (+M + 1) + '.0.0';
  4551. } else {
  4552. debug('no pr');
  4553. if (M === '0') {
  4554. if (m === '0') ret = '>=' + M + '.' + m + '.' + p + ' <' + M + '.' + m + '.' + (+p + 1);else ret = '>=' + M + '.' + m + '.' + p + ' <' + M + '.' + (+m + 1) + '.0';
  4555. } else ret = '>=' + M + '.' + m + '.' + p + ' <' + (+M + 1) + '.0.0';
  4556. }
  4557. debug('caret return', ret);
  4558. return ret;
  4559. });
  4560. }
  4561. function replaceXRanges(comp, loose) {
  4562. debug('replaceXRanges', comp, loose);
  4563. return comp.split(/\s+/).map(function (comp) {
  4564. return replaceXRange(comp, loose);
  4565. }).join(' ');
  4566. }
  4567. function replaceXRange(comp, loose) {
  4568. comp = comp.trim();
  4569. var r = loose ? re[XRANGELOOSE] : re[XRANGE];
  4570. return comp.replace(r, function (ret, gtlt, M, m, p, pr) {
  4571. debug('xRange', comp, ret, gtlt, M, m, p, pr);
  4572. var xM = isX(M);
  4573. var xm = xM || isX(m);
  4574. var xp = xm || isX(p);
  4575. var anyX = xp;
  4576. if (gtlt === '=' && anyX) gtlt = '';
  4577. if (xM) {
  4578. if (gtlt === '>' || gtlt === '<') {
  4579. // nothing is allowed
  4580. ret = '<0.0.0';
  4581. } else {
  4582. // nothing is forbidden
  4583. ret = '*';
  4584. }
  4585. } else if (gtlt && anyX) {
  4586. // replace X with 0
  4587. if (xm) m = 0;
  4588. if (xp) p = 0;
  4589. if (gtlt === '>') {
  4590. // >1 => >=2.0.0
  4591. // >1.2 => >=1.3.0
  4592. // >1.2.3 => >= 1.2.4
  4593. gtlt = '>=';
  4594. if (xm) {
  4595. M = +M + 1;
  4596. m = 0;
  4597. p = 0;
  4598. } else if (xp) {
  4599. m = +m + 1;
  4600. p = 0;
  4601. }
  4602. } else if (gtlt === '<=') {
  4603. // <=0.7.x is actually <0.8.0, since any 0.7.x should
  4604. // pass. Similarly, <=7.x is actually <8.0.0, etc.
  4605. gtlt = '<';
  4606. if (xm) M = +M + 1;else m = +m + 1;
  4607. }
  4608. ret = gtlt + M + '.' + m + '.' + p;
  4609. } else if (xm) {
  4610. ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0';
  4611. } else if (xp) {
  4612. ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0';
  4613. }
  4614. debug('xRange return', ret);
  4615. return ret;
  4616. });
  4617. } // Because * is AND-ed with everything else in the comparator,
  4618. // and '' means "any version", just remove the *s entirely.
  4619. function replaceStars(comp, loose) {
  4620. debug('replaceStars', comp, loose); // Looseness is ignored here. star is always as loose as it gets!
  4621. return comp.trim().replace(re[STAR], '');
  4622. } // This function is passed to string.replace(re[HYPHENRANGE])
  4623. // M, m, patch, prerelease, build
  4624. // 1.2 - 3.4.5 => >=1.2.0 <=3.4.5
  4625. // 1.2.3 - 3.4 => >=1.2.0 <3.5.0 Any 3.4.x will do
  4626. // 1.2 - 3.4 => >=1.2.0 <3.5.0
  4627. function hyphenReplace($0, from, fM, fm, fp, fpr, fb, to, tM, tm, tp, tpr, tb) {
  4628. if (isX(fM)) from = '';else if (isX(fm)) from = '>=' + fM + '.0.0';else if (isX(fp)) from = '>=' + fM + '.' + fm + '.0';else from = '>=' + from;
  4629. 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;
  4630. return (from + ' ' + to).trim();
  4631. } // if ANY of the sets match ALL of its comparators, then pass
  4632. Range.prototype.test = function (version) {
  4633. if (!version) return false;
  4634. if (typeof version === 'string') version = new SemVer(version, this.loose);
  4635. for (var i = 0; i < this.set.length; i++) {
  4636. if (testSet(this.set[i], version)) return true;
  4637. }
  4638. return false;
  4639. };
  4640. function testSet(set, version) {
  4641. for (var i = 0; i < set.length; i++) {
  4642. if (!set[i].test(version)) return false;
  4643. }
  4644. if (version.prerelease.length) {
  4645. // Find the set of versions that are allowed to have prereleases
  4646. // For example, ^1.2.3-pr.1 desugars to >=1.2.3-pr.1 <2.0.0
  4647. // That should allow `1.2.3-pr.2` to pass.
  4648. // However, `1.2.4-alpha.notready` should NOT be allowed,
  4649. // even though it's within the range set by the comparators.
  4650. for (var i = 0; i < set.length; i++) {
  4651. debug(set[i].semver);
  4652. if (set[i].semver === ANY) continue;
  4653. if (set[i].semver.prerelease.length > 0) {
  4654. var allowed = set[i].semver;
  4655. if (allowed.major === version.major && allowed.minor === version.minor && allowed.patch === version.patch) return true;
  4656. }
  4657. } // Version has a -pre, but it's not one of the ones we like.
  4658. return false;
  4659. }
  4660. return true;
  4661. }
  4662. exports.satisfies = satisfies;
  4663. function satisfies(version, range, loose) {
  4664. try {
  4665. range = new Range(range, loose);
  4666. } catch (er) {
  4667. return false;
  4668. }
  4669. return range.test(version);
  4670. }
  4671. exports.maxSatisfying = maxSatisfying;
  4672. function maxSatisfying(versions$$1, range, loose) {
  4673. var max = null;
  4674. var maxSV = null;
  4675. try {
  4676. var rangeObj = new Range(range, loose);
  4677. } catch (er) {
  4678. return null;
  4679. }
  4680. versions$$1.forEach(function (v) {
  4681. if (rangeObj.test(v)) {
  4682. // satisfies(v, range, loose)
  4683. if (!max || maxSV.compare(v) === -1) {
  4684. // compare(max, v, true)
  4685. max = v;
  4686. maxSV = new SemVer(max, loose);
  4687. }
  4688. }
  4689. });
  4690. return max;
  4691. }
  4692. exports.minSatisfying = minSatisfying;
  4693. function minSatisfying(versions$$1, range, loose) {
  4694. var min = null;
  4695. var minSV = null;
  4696. try {
  4697. var rangeObj = new Range(range, loose);
  4698. } catch (er) {
  4699. return null;
  4700. }
  4701. versions$$1.forEach(function (v) {
  4702. if (rangeObj.test(v)) {
  4703. // satisfies(v, range, loose)
  4704. if (!min || minSV.compare(v) === 1) {
  4705. // compare(min, v, true)
  4706. min = v;
  4707. minSV = new SemVer(min, loose);
  4708. }
  4709. }
  4710. });
  4711. return min;
  4712. }
  4713. exports.validRange = validRange;
  4714. function validRange(range, loose) {
  4715. try {
  4716. // Return '*' instead of '' so that truthiness works.
  4717. // This will throw if it's invalid anyway
  4718. return new Range(range, loose).range || '*';
  4719. } catch (er) {
  4720. return null;
  4721. }
  4722. } // Determine if version is less than all the versions possible in the range
  4723. exports.ltr = ltr;
  4724. function ltr(version, range, loose) {
  4725. return outside(version, range, '<', loose);
  4726. } // Determine if version is greater than all the versions possible in the range.
  4727. exports.gtr = gtr;
  4728. function gtr(version, range, loose) {
  4729. return outside(version, range, '>', loose);
  4730. }
  4731. exports.outside = outside;
  4732. function outside(version, range, hilo, loose) {
  4733. version = new SemVer(version, loose);
  4734. range = new Range(range, loose);
  4735. var gtfn, ltefn, ltfn, comp, ecomp;
  4736. switch (hilo) {
  4737. case '>':
  4738. gtfn = gt;
  4739. ltefn = lte;
  4740. ltfn = lt;
  4741. comp = '>';
  4742. ecomp = '>=';
  4743. break;
  4744. case '<':
  4745. gtfn = lt;
  4746. ltefn = gte;
  4747. ltfn = gt;
  4748. comp = '<';
  4749. ecomp = '<=';
  4750. break;
  4751. default:
  4752. throw new TypeError('Must provide a hilo val of "<" or ">"');
  4753. } // If it satisifes the range it is not outside
  4754. if (satisfies(version, range, loose)) {
  4755. return false;
  4756. } // From now on, variable terms are as if we're in "gtr" mode.
  4757. // but note that everything is flipped for the "ltr" function.
  4758. for (var i = 0; i < range.set.length; ++i) {
  4759. var comparators = range.set[i];
  4760. var high = null;
  4761. var low = null;
  4762. comparators.forEach(function (comparator) {
  4763. if (comparator.semver === ANY) {
  4764. comparator = new Comparator('>=0.0.0');
  4765. }
  4766. high = high || comparator;
  4767. low = low || comparator;
  4768. if (gtfn(comparator.semver, high.semver, loose)) {
  4769. high = comparator;
  4770. } else if (ltfn(comparator.semver, low.semver, loose)) {
  4771. low = comparator;
  4772. }
  4773. }); // If the edge version comparator has a operator then our version
  4774. // isn't outside it
  4775. if (high.operator === comp || high.operator === ecomp) {
  4776. return false;
  4777. } // If the lowest version comparator has an operator and our version
  4778. // is less than it then it isn't higher than the range
  4779. if ((!low.operator || low.operator === comp) && ltefn(version, low.semver)) {
  4780. return false;
  4781. } else if (low.operator === ecomp && ltfn(version, low.semver)) {
  4782. return false;
  4783. }
  4784. }
  4785. return true;
  4786. }
  4787. exports.prerelease = prerelease;
  4788. function prerelease(version, loose) {
  4789. var parsed = parse(version, loose);
  4790. return parsed && parsed.prerelease.length ? parsed.prerelease : null;
  4791. }
  4792. exports.intersects = intersects;
  4793. function intersects(r1, r2, loose) {
  4794. r1 = new Range(r1, loose);
  4795. r2 = new Range(r2, loose);
  4796. return r1.intersects(r2);
  4797. }
  4798. });
  4799. var arrayify = function arrayify(object, keyName) {
  4800. return Object.keys(object).reduce(function (array, key) {
  4801. return array.concat(Object.assign(_defineProperty({}, keyName, key), object[key]));
  4802. }, []);
  4803. };
  4804. var dedent_1 = createCommonjsModule(function (module) {
  4805. "use strict";
  4806. function dedent(strings) {
  4807. var raw = void 0;
  4808. if (typeof strings === "string") {
  4809. // dedent can be used as a plain function
  4810. raw = [strings];
  4811. } else {
  4812. raw = strings.raw;
  4813. } // first, perform interpolation
  4814. var result = "";
  4815. for (var i = 0; i < raw.length; i++) {
  4816. result += raw[i]. // join lines when there is a suppressed newline
  4817. replace(/\\\n[ \t]*/g, ""). // handle escaped backticks
  4818. replace(/\\`/g, "`");
  4819. if (i < (arguments.length <= 1 ? 0 : arguments.length - 1)) {
  4820. result += arguments.length <= i + 1 ? undefined : arguments[i + 1];
  4821. }
  4822. } // now strip indentation
  4823. var lines = result.split("\n");
  4824. var mindent = null;
  4825. lines.forEach(function (l) {
  4826. var m = l.match(/^(\s+)\S+/);
  4827. if (m) {
  4828. var indent = m[1].length;
  4829. if (!mindent) {
  4830. // this is the first indented line
  4831. mindent = indent;
  4832. } else {
  4833. mindent = Math.min(mindent, indent);
  4834. }
  4835. }
  4836. });
  4837. if (mindent !== null) {
  4838. result = lines.map(function (l) {
  4839. return l[0] === " " ? l.slice(mindent) : l;
  4840. }).join("\n");
  4841. } // dedent eats leading and trailing whitespace too
  4842. result = result.trim(); // handle escaped newlines at the end to ensure they don't get stripped too
  4843. return result.replace(/\\n/g, "\n");
  4844. }
  4845. {
  4846. module.exports = dedent;
  4847. }
  4848. });
  4849. function _templateObject6() {
  4850. 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 "]);
  4851. _templateObject6 = function _templateObject6() {
  4852. return data;
  4853. };
  4854. return data;
  4855. }
  4856. function _templateObject5() {
  4857. 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 "]);
  4858. _templateObject5 = function _templateObject5() {
  4859. return data;
  4860. };
  4861. return data;
  4862. }
  4863. function _templateObject4() {
  4864. 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 "]);
  4865. _templateObject4 = function _templateObject4() {
  4866. return data;
  4867. };
  4868. return data;
  4869. }
  4870. function _templateObject3() {
  4871. 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 "]);
  4872. _templateObject3 = function _templateObject3() {
  4873. return data;
  4874. };
  4875. return data;
  4876. }
  4877. function _templateObject2() {
  4878. 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 "]);
  4879. _templateObject2 = function _templateObject2() {
  4880. return data;
  4881. };
  4882. return data;
  4883. }
  4884. function _templateObject() {
  4885. 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 "]);
  4886. _templateObject = function _templateObject() {
  4887. return data;
  4888. };
  4889. return data;
  4890. }
  4891. var CATEGORY_CONFIG = "Config";
  4892. var CATEGORY_EDITOR = "Editor";
  4893. var CATEGORY_FORMAT = "Format";
  4894. var CATEGORY_OTHER = "Other";
  4895. var CATEGORY_OUTPUT = "Output";
  4896. var CATEGORY_GLOBAL = "Global";
  4897. var CATEGORY_SPECIAL = "Special";
  4898. /**
  4899. * @typedef {Object} OptionInfo
  4900. * @property {string} since - available since version
  4901. * @property {string} category
  4902. * @property {'int' | 'boolean' | 'choice' | 'path'} type
  4903. * @property {boolean} array - indicate it's an array of the specified type
  4904. * @property {boolean?} deprecated - deprecated since version
  4905. * @property {OptionRedirectInfo?} redirect - redirect deprecated option
  4906. * @property {string} description
  4907. * @property {string?} oppositeDescription - for `false` option
  4908. * @property {OptionValueInfo} default
  4909. * @property {OptionRangeInfo?} range - for type int
  4910. * @property {OptionChoiceInfo?} choices - for type choice
  4911. * @property {(value: any) => boolean} exception
  4912. *
  4913. * @typedef {number | boolean | string} OptionValue
  4914. * @typedef {OptionValue | [{ value: OptionValue[] }] | Array<{ since: string, value: OptionValue}>} OptionValueInfo
  4915. *
  4916. * @typedef {Object} OptionRedirectInfo
  4917. * @property {string} option
  4918. * @property {OptionValue} value
  4919. *
  4920. * @typedef {Object} OptionRangeInfo
  4921. * @property {number} start - recommended range start
  4922. * @property {number} end - recommended range end
  4923. * @property {number} step - recommended range step
  4924. *
  4925. * @typedef {Object} OptionChoiceInfo
  4926. * @property {boolean | string} value - boolean for the option that is originally boolean type
  4927. * @property {string?} description - undefined if redirect
  4928. * @property {string?} since - undefined if available since the first version of the option
  4929. * @property {string?} deprecated - deprecated since version
  4930. * @property {OptionValueInfo?} redirect - redirect deprecated value
  4931. *
  4932. * @property {string?} cliName
  4933. * @property {string?} cliCategory
  4934. * @property {string?} cliDescription
  4935. */
  4936. /** @type {{ [name: string]: OptionInfo } */
  4937. var options$2 = {
  4938. cursorOffset: {
  4939. since: "1.4.0",
  4940. category: CATEGORY_SPECIAL,
  4941. type: "int",
  4942. default: -1,
  4943. range: {
  4944. start: -1,
  4945. end: Infinity,
  4946. step: 1
  4947. },
  4948. description: dedent_1(_templateObject()),
  4949. cliCategory: CATEGORY_EDITOR
  4950. },
  4951. endOfLine: {
  4952. since: "1.15.0",
  4953. category: CATEGORY_GLOBAL,
  4954. type: "choice",
  4955. default: "auto",
  4956. description: "Which end of line characters to apply.",
  4957. choices: [{
  4958. value: "auto",
  4959. description: dedent_1(_templateObject2())
  4960. }, {
  4961. value: "lf",
  4962. description: "Line Feed only (\\n), common on Linux and macOS as well as inside git repos"
  4963. }, {
  4964. value: "crlf",
  4965. description: "Carriage Return + Line Feed characters (\\r\\n), common on Windows"
  4966. }, {
  4967. value: "cr",
  4968. description: "Carriage Return character only (\\r), used very rarely"
  4969. }]
  4970. },
  4971. filepath: {
  4972. since: "1.4.0",
  4973. category: CATEGORY_SPECIAL,
  4974. type: "path",
  4975. description: "Specify the input filepath. This will be used to do parser inference.",
  4976. cliName: "stdin-filepath",
  4977. cliCategory: CATEGORY_OTHER,
  4978. cliDescription: "Path to the file to pretend that stdin comes from."
  4979. },
  4980. insertPragma: {
  4981. since: "1.8.0",
  4982. category: CATEGORY_SPECIAL,
  4983. type: "boolean",
  4984. default: false,
  4985. description: "Insert @format pragma into file's first docblock comment.",
  4986. cliCategory: CATEGORY_OTHER
  4987. },
  4988. parser: {
  4989. since: "0.0.10",
  4990. category: CATEGORY_GLOBAL,
  4991. type: "choice",
  4992. default: [{
  4993. since: "0.0.10",
  4994. value: "babylon"
  4995. }, {
  4996. since: "1.13.0",
  4997. value: undefined
  4998. }],
  4999. description: "Which parser to use.",
  5000. exception: function exception(value) {
  5001. return typeof value === "string" || typeof value === "function";
  5002. },
  5003. choices: [{
  5004. value: "flow",
  5005. description: "Flow"
  5006. }, {
  5007. value: "babylon",
  5008. description: "JavaScript",
  5009. deprecated: "1.16.0",
  5010. redirect: "babel"
  5011. }, {
  5012. value: "babel",
  5013. since: "1.16.0",
  5014. description: "JavaScript"
  5015. }, {
  5016. value: "babel-flow",
  5017. since: "1.16.0",
  5018. description: "Flow"
  5019. }, {
  5020. value: "typescript",
  5021. since: "1.4.0",
  5022. description: "TypeScript"
  5023. }, {
  5024. value: "css",
  5025. since: "1.7.1",
  5026. description: "CSS"
  5027. }, {
  5028. value: "postcss",
  5029. since: "1.4.0",
  5030. description: "CSS/Less/SCSS",
  5031. deprecated: "1.7.1",
  5032. redirect: "css"
  5033. }, {
  5034. value: "less",
  5035. since: "1.7.1",
  5036. description: "Less"
  5037. }, {
  5038. value: "scss",
  5039. since: "1.7.1",
  5040. description: "SCSS"
  5041. }, {
  5042. value: "json",
  5043. since: "1.5.0",
  5044. description: "JSON"
  5045. }, {
  5046. value: "json5",
  5047. since: "1.13.0",
  5048. description: "JSON5"
  5049. }, {
  5050. value: "json-stringify",
  5051. since: "1.13.0",
  5052. description: "JSON.stringify"
  5053. }, {
  5054. value: "graphql",
  5055. since: "1.5.0",
  5056. description: "GraphQL"
  5057. }, {
  5058. value: "markdown",
  5059. since: "1.8.0",
  5060. description: "Markdown"
  5061. }, {
  5062. value: "mdx",
  5063. since: "1.15.0",
  5064. description: "MDX"
  5065. }, {
  5066. value: "vue",
  5067. since: "1.10.0",
  5068. description: "Vue"
  5069. }, {
  5070. value: "yaml",
  5071. since: "1.14.0",
  5072. description: "YAML"
  5073. }, {
  5074. value: "glimmer",
  5075. since: null,
  5076. description: "Handlebars"
  5077. }, {
  5078. value: "html",
  5079. since: "1.15.0",
  5080. description: "HTML"
  5081. }, {
  5082. value: "angular",
  5083. since: "1.15.0",
  5084. description: "Angular"
  5085. }, {
  5086. value: "lwc",
  5087. since: "1.17.0",
  5088. description: "Lightning Web Components"
  5089. }]
  5090. },
  5091. plugins: {
  5092. since: "1.10.0",
  5093. type: "path",
  5094. array: true,
  5095. default: [{
  5096. value: []
  5097. }],
  5098. category: CATEGORY_GLOBAL,
  5099. description: "Add a plugin. Multiple plugins can be passed as separate `--plugin`s.",
  5100. exception: function exception(value) {
  5101. return typeof value === "string" || _typeof(value) === "object";
  5102. },
  5103. cliName: "plugin",
  5104. cliCategory: CATEGORY_CONFIG
  5105. },
  5106. pluginSearchDirs: {
  5107. since: "1.13.0",
  5108. type: "path",
  5109. array: true,
  5110. default: [{
  5111. value: []
  5112. }],
  5113. category: CATEGORY_GLOBAL,
  5114. description: dedent_1(_templateObject3()),
  5115. exception: function exception(value) {
  5116. return typeof value === "string" || _typeof(value) === "object";
  5117. },
  5118. cliName: "plugin-search-dir",
  5119. cliCategory: CATEGORY_CONFIG
  5120. },
  5121. printWidth: {
  5122. since: "0.0.0",
  5123. category: CATEGORY_GLOBAL,
  5124. type: "int",
  5125. default: 80,
  5126. description: "The line length where Prettier will try wrap.",
  5127. range: {
  5128. start: 0,
  5129. end: Infinity,
  5130. step: 1
  5131. }
  5132. },
  5133. rangeEnd: {
  5134. since: "1.4.0",
  5135. category: CATEGORY_SPECIAL,
  5136. type: "int",
  5137. default: Infinity,
  5138. range: {
  5139. start: 0,
  5140. end: Infinity,
  5141. step: 1
  5142. },
  5143. description: dedent_1(_templateObject4()),
  5144. cliCategory: CATEGORY_EDITOR
  5145. },
  5146. rangeStart: {
  5147. since: "1.4.0",
  5148. category: CATEGORY_SPECIAL,
  5149. type: "int",
  5150. default: 0,
  5151. range: {
  5152. start: 0,
  5153. end: Infinity,
  5154. step: 1
  5155. },
  5156. description: dedent_1(_templateObject5()),
  5157. cliCategory: CATEGORY_EDITOR
  5158. },
  5159. requirePragma: {
  5160. since: "1.7.0",
  5161. category: CATEGORY_SPECIAL,
  5162. type: "boolean",
  5163. default: false,
  5164. description: dedent_1(_templateObject6()),
  5165. cliCategory: CATEGORY_OTHER
  5166. },
  5167. tabWidth: {
  5168. type: "int",
  5169. category: CATEGORY_GLOBAL,
  5170. default: 2,
  5171. description: "Number of spaces per indentation level.",
  5172. range: {
  5173. start: 0,
  5174. end: Infinity,
  5175. step: 1
  5176. }
  5177. },
  5178. useFlowParser: {
  5179. since: "0.0.0",
  5180. category: CATEGORY_GLOBAL,
  5181. type: "boolean",
  5182. default: [{
  5183. since: "0.0.0",
  5184. value: false
  5185. }, {
  5186. since: "1.15.0",
  5187. value: undefined
  5188. }],
  5189. deprecated: "0.0.10",
  5190. description: "Use flow parser.",
  5191. redirect: {
  5192. option: "parser",
  5193. value: "flow"
  5194. },
  5195. cliName: "flow-parser"
  5196. },
  5197. useTabs: {
  5198. since: "1.0.0",
  5199. category: CATEGORY_GLOBAL,
  5200. type: "boolean",
  5201. default: false,
  5202. description: "Indent with tabs instead of spaces."
  5203. }
  5204. };
  5205. var coreOptions$1 = {
  5206. CATEGORY_CONFIG: CATEGORY_CONFIG,
  5207. CATEGORY_EDITOR: CATEGORY_EDITOR,
  5208. CATEGORY_FORMAT: CATEGORY_FORMAT,
  5209. CATEGORY_OTHER: CATEGORY_OTHER,
  5210. CATEGORY_OUTPUT: CATEGORY_OUTPUT,
  5211. CATEGORY_GLOBAL: CATEGORY_GLOBAL,
  5212. CATEGORY_SPECIAL: CATEGORY_SPECIAL,
  5213. options: options$2
  5214. };
  5215. var require$$0 = ( _package$1 && _package ) || _package$1;
  5216. var currentVersion = require$$0.version;
  5217. var coreOptions = coreOptions$1.options;
  5218. function getSupportInfo$2(version, opts) {
  5219. opts = Object.assign({
  5220. plugins: [],
  5221. showUnreleased: false,
  5222. showDeprecated: false,
  5223. showInternal: false
  5224. }, opts);
  5225. if (!version) {
  5226. // pre-release version is smaller than the normal version in semver,
  5227. // we need to treat it as the normal one so as to test new features.
  5228. version = currentVersion.split("-", 1)[0];
  5229. }
  5230. var plugins = opts.plugins;
  5231. var options = arrayify(Object.assign(plugins.reduce(function (currentOptions, plugin) {
  5232. return Object.assign(currentOptions, plugin.options);
  5233. }, {}), coreOptions), "name").sort(function (a, b) {
  5234. return a.name === b.name ? 0 : a.name < b.name ? -1 : 1;
  5235. }).filter(filterSince).filter(filterDeprecated).map(mapDeprecated).map(mapInternal).map(function (option) {
  5236. var newOption = Object.assign({}, option);
  5237. if (Array.isArray(newOption.default)) {
  5238. newOption.default = newOption.default.length === 1 ? newOption.default[0].value : newOption.default.filter(filterSince).sort(function (info1, info2) {
  5239. return semver.compare(info2.since, info1.since);
  5240. })[0].value;
  5241. }
  5242. if (Array.isArray(newOption.choices)) {
  5243. newOption.choices = newOption.choices.filter(filterSince).filter(filterDeprecated).map(mapDeprecated);
  5244. }
  5245. return newOption;
  5246. }).map(function (option) {
  5247. var filteredPlugins = plugins.filter(function (plugin) {
  5248. return plugin.defaultOptions && plugin.defaultOptions[option.name];
  5249. });
  5250. var pluginDefaults = filteredPlugins.reduce(function (reduced, plugin) {
  5251. reduced[plugin.name] = plugin.defaultOptions[option.name];
  5252. return reduced;
  5253. }, {});
  5254. return Object.assign(option, {
  5255. pluginDefaults: pluginDefaults
  5256. });
  5257. });
  5258. var usePostCssParser = semver.lt(version, "1.7.1");
  5259. var useBabylonParser = semver.lt(version, "1.16.0");
  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. } // "babylon" was renamed to "babel" in 1.16.0
  5274. if (useBabylonParser && language.parsers.indexOf("babel") !== -1) {
  5275. return Object.assign({}, language, {
  5276. parsers: language.parsers.map(function (parser) {
  5277. return parser === "babel" ? "babylon" : parser;
  5278. })
  5279. });
  5280. }
  5281. if (usePostCssParser && (language.name === "CSS" || language.group === "CSS")) {
  5282. return Object.assign({}, language, {
  5283. parsers: ["postcss"]
  5284. });
  5285. }
  5286. return language;
  5287. });
  5288. return {
  5289. languages: languages,
  5290. options: options
  5291. };
  5292. function filterSince(object) {
  5293. return opts.showUnreleased || !("since" in object) || object.since && semver.gte(version, object.since);
  5294. }
  5295. function filterDeprecated(object) {
  5296. return opts.showDeprecated || !("deprecated" in object) || object.deprecated && semver.lt(version, object.deprecated);
  5297. }
  5298. function mapDeprecated(object) {
  5299. if (!object.deprecated || opts.showDeprecated) {
  5300. return object;
  5301. }
  5302. var newObject = Object.assign({}, object);
  5303. delete newObject.deprecated;
  5304. delete newObject.redirect;
  5305. return newObject;
  5306. }
  5307. function mapInternal(object) {
  5308. if (opts.showInternal) {
  5309. return object;
  5310. }
  5311. var newObject = Object.assign({}, object);
  5312. delete newObject.cliName;
  5313. delete newObject.cliCategory;
  5314. delete newObject.cliDescription;
  5315. return newObject;
  5316. }
  5317. }
  5318. var support = {
  5319. getSupportInfo: getSupportInfo$2
  5320. };
  5321. /*! *****************************************************************************
  5322. Copyright (c) Microsoft Corporation. All rights reserved.
  5323. Licensed under the Apache License, Version 2.0 (the "License"); you may not use
  5324. this file except in compliance with the License. You may obtain a copy of the
  5325. License at http://www.apache.org/licenses/LICENSE-2.0
  5326. THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  5327. KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  5328. WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  5329. MERCHANTABLITY OR NON-INFRINGEMENT.
  5330. See the Apache Version 2.0 License for specific language governing permissions
  5331. and limitations under the License.
  5332. ***************************************************************************** */
  5333. /* global Reflect, Promise */
  5334. var _extendStatics = function extendStatics(d, b) {
  5335. _extendStatics = Object.setPrototypeOf || {
  5336. __proto__: []
  5337. } instanceof Array && function (d, b) {
  5338. d.__proto__ = b;
  5339. } || function (d, b) {
  5340. for (var p in b) {
  5341. if (b.hasOwnProperty(p)) d[p] = b[p];
  5342. }
  5343. };
  5344. return _extendStatics(d, b);
  5345. };
  5346. function __extends(d, b) {
  5347. _extendStatics(d, b);
  5348. function __() {
  5349. this.constructor = d;
  5350. }
  5351. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  5352. }
  5353. var _assign = function __assign() {
  5354. _assign = Object.assign || function __assign(t) {
  5355. for (var s, i = 1, n = arguments.length; i < n; i++) {
  5356. s = arguments[i];
  5357. for (var p in s) {
  5358. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  5359. }
  5360. }
  5361. return t;
  5362. };
  5363. return _assign.apply(this, arguments);
  5364. };
  5365. function __rest(s, e) {
  5366. var t = {};
  5367. for (var p in s) {
  5368. if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
  5369. }
  5370. if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
  5371. if (e.indexOf(p[i]) < 0) t[p[i]] = s[p[i]];
  5372. }
  5373. return t;
  5374. }
  5375. function __decorate(decorators, target, key, desc) {
  5376. var c = arguments.length,
  5377. r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
  5378. d;
  5379. 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--) {
  5380. if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  5381. }
  5382. return c > 3 && r && Object.defineProperty(target, key, r), r;
  5383. }
  5384. function __param(paramIndex, decorator) {
  5385. return function (target, key) {
  5386. decorator(target, key, paramIndex);
  5387. };
  5388. }
  5389. function __metadata(metadataKey, metadataValue) {
  5390. if ((typeof Reflect === "undefined" ? "undefined" : _typeof(Reflect)) === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
  5391. }
  5392. function __awaiter(thisArg, _arguments, P, generator) {
  5393. return new (P || (P = Promise))(function (resolve, reject) {
  5394. function fulfilled(value) {
  5395. try {
  5396. step(generator.next(value));
  5397. } catch (e) {
  5398. reject(e);
  5399. }
  5400. }
  5401. function rejected(value) {
  5402. try {
  5403. step(generator["throw"](value));
  5404. } catch (e) {
  5405. reject(e);
  5406. }
  5407. }
  5408. function step(result) {
  5409. result.done ? resolve(result.value) : new P(function (resolve) {
  5410. resolve(result.value);
  5411. }).then(fulfilled, rejected);
  5412. }
  5413. step((generator = generator.apply(thisArg, _arguments || [])).next());
  5414. });
  5415. }
  5416. function __generator(thisArg, body) {
  5417. var _ = {
  5418. label: 0,
  5419. sent: function sent() {
  5420. if (t[0] & 1) throw t[1];
  5421. return t[1];
  5422. },
  5423. trys: [],
  5424. ops: []
  5425. },
  5426. f,
  5427. y,
  5428. t,
  5429. g;
  5430. return g = {
  5431. next: verb(0),
  5432. "throw": verb(1),
  5433. "return": verb(2)
  5434. }, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
  5435. return this;
  5436. }), g;
  5437. function verb(n) {
  5438. return function (v) {
  5439. return step([n, v]);
  5440. };
  5441. }
  5442. function step(op) {
  5443. if (f) throw new TypeError("Generator is already executing.");
  5444. while (_) {
  5445. try {
  5446. 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;
  5447. if (y = 0, t) op = [op[0] & 2, t.value];
  5448. switch (op[0]) {
  5449. case 0:
  5450. case 1:
  5451. t = op;
  5452. break;
  5453. case 4:
  5454. _.label++;
  5455. return {
  5456. value: op[1],
  5457. done: false
  5458. };
  5459. case 5:
  5460. _.label++;
  5461. y = op[1];
  5462. op = [0];
  5463. continue;
  5464. case 7:
  5465. op = _.ops.pop();
  5466. _.trys.pop();
  5467. continue;
  5468. default:
  5469. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
  5470. _ = 0;
  5471. continue;
  5472. }
  5473. if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
  5474. _.label = op[1];
  5475. break;
  5476. }
  5477. if (op[0] === 6 && _.label < t[1]) {
  5478. _.label = t[1];
  5479. t = op;
  5480. break;
  5481. }
  5482. if (t && _.label < t[2]) {
  5483. _.label = t[2];
  5484. _.ops.push(op);
  5485. break;
  5486. }
  5487. if (t[2]) _.ops.pop();
  5488. _.trys.pop();
  5489. continue;
  5490. }
  5491. op = body.call(thisArg, _);
  5492. } catch (e) {
  5493. op = [6, e];
  5494. y = 0;
  5495. } finally {
  5496. f = t = 0;
  5497. }
  5498. }
  5499. if (op[0] & 5) throw op[1];
  5500. return {
  5501. value: op[0] ? op[1] : void 0,
  5502. done: true
  5503. };
  5504. }
  5505. }
  5506. function __exportStar(m, exports) {
  5507. for (var p in m) {
  5508. if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  5509. }
  5510. }
  5511. function __values(o) {
  5512. var m = typeof Symbol === "function" && o[Symbol.iterator],
  5513. i = 0;
  5514. if (m) return m.call(o);
  5515. return {
  5516. next: function next() {
  5517. if (o && i >= o.length) o = void 0;
  5518. return {
  5519. value: o && o[i++],
  5520. done: !o
  5521. };
  5522. }
  5523. };
  5524. }
  5525. function __read(o, n) {
  5526. var m = typeof Symbol === "function" && o[Symbol.iterator];
  5527. if (!m) return o;
  5528. var i = m.call(o),
  5529. r,
  5530. ar = [],
  5531. e;
  5532. try {
  5533. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) {
  5534. ar.push(r.value);
  5535. }
  5536. } catch (error) {
  5537. e = {
  5538. error: error
  5539. };
  5540. } finally {
  5541. try {
  5542. if (r && !r.done && (m = i["return"])) m.call(i);
  5543. } finally {
  5544. if (e) throw e.error;
  5545. }
  5546. }
  5547. return ar;
  5548. }
  5549. function __spread() {
  5550. for (var ar = [], i = 0; i < arguments.length; i++) {
  5551. ar = ar.concat(__read(arguments[i]));
  5552. }
  5553. return ar;
  5554. }
  5555. function __await(v) {
  5556. return this instanceof __await ? (this.v = v, this) : new __await(v);
  5557. }
  5558. function __asyncGenerator(thisArg, _arguments, generator) {
  5559. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  5560. var g = generator.apply(thisArg, _arguments || []),
  5561. i,
  5562. q = [];
  5563. return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () {
  5564. return this;
  5565. }, i;
  5566. function verb(n) {
  5567. if (g[n]) i[n] = function (v) {
  5568. return new Promise(function (a, b) {
  5569. q.push([n, v, a, b]) > 1 || resume(n, v);
  5570. });
  5571. };
  5572. }
  5573. function resume(n, v) {
  5574. try {
  5575. step(g[n](v));
  5576. } catch (e) {
  5577. settle(q[0][3], e);
  5578. }
  5579. }
  5580. function step(r) {
  5581. r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r);
  5582. }
  5583. function fulfill(value) {
  5584. resume("next", value);
  5585. }
  5586. function reject(value) {
  5587. resume("throw", value);
  5588. }
  5589. function settle(f, v) {
  5590. if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]);
  5591. }
  5592. }
  5593. function __asyncDelegator(o) {
  5594. var i, p;
  5595. return i = {}, verb("next"), verb("throw", function (e) {
  5596. throw e;
  5597. }), verb("return"), i[Symbol.iterator] = function () {
  5598. return this;
  5599. }, i;
  5600. function verb(n, f) {
  5601. i[n] = o[n] ? function (v) {
  5602. return (p = !p) ? {
  5603. value: __await(o[n](v)),
  5604. done: n === "return"
  5605. } : f ? f(v) : v;
  5606. } : f;
  5607. }
  5608. }
  5609. function __asyncValues(o) {
  5610. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  5611. var m = o[Symbol.asyncIterator],
  5612. i;
  5613. 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 () {
  5614. return this;
  5615. }, i);
  5616. function verb(n) {
  5617. i[n] = o[n] && function (v) {
  5618. return new Promise(function (resolve, reject) {
  5619. v = o[n](v), settle(resolve, reject, v.done, v.value);
  5620. });
  5621. };
  5622. }
  5623. function settle(resolve, reject, d, v) {
  5624. Promise.resolve(v).then(function (v) {
  5625. resolve({
  5626. value: v,
  5627. done: d
  5628. });
  5629. }, reject);
  5630. }
  5631. }
  5632. function __makeTemplateObject(cooked, raw) {
  5633. if (Object.defineProperty) {
  5634. Object.defineProperty(cooked, "raw", {
  5635. value: raw
  5636. });
  5637. } else {
  5638. cooked.raw = raw;
  5639. }
  5640. return cooked;
  5641. }
  5642. function __importStar(mod) {
  5643. if (mod && mod.__esModule) return mod;
  5644. var result = {};
  5645. if (mod != null) for (var k in mod) {
  5646. if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  5647. }
  5648. result.default = mod;
  5649. return result;
  5650. }
  5651. function __importDefault(mod) {
  5652. return mod && mod.__esModule ? mod : {
  5653. default: mod
  5654. };
  5655. }
  5656. var tslib_1 = Object.freeze({
  5657. __extends: __extends,
  5658. get __assign () { return _assign; },
  5659. __rest: __rest,
  5660. __decorate: __decorate,
  5661. __param: __param,
  5662. __metadata: __metadata,
  5663. __awaiter: __awaiter,
  5664. __generator: __generator,
  5665. __exportStar: __exportStar,
  5666. __values: __values,
  5667. __read: __read,
  5668. __spread: __spread,
  5669. __await: __await,
  5670. __asyncGenerator: __asyncGenerator,
  5671. __asyncDelegator: __asyncDelegator,
  5672. __asyncValues: __asyncValues,
  5673. __makeTemplateObject: __makeTemplateObject,
  5674. __importStar: __importStar,
  5675. __importDefault: __importDefault
  5676. });
  5677. var api = createCommonjsModule(function (module, exports) {
  5678. "use strict";
  5679. Object.defineProperty(exports, "__esModule", {
  5680. value: true
  5681. });
  5682. exports.apiDescriptor = {
  5683. key: function key(_key) {
  5684. return /^[$_a-zA-Z][$_a-zA-Z0-9]*$/.test(_key) ? _key : JSON.stringify(_key);
  5685. },
  5686. value: function value(_value) {
  5687. if (_value === null || _typeof(_value) !== 'object') {
  5688. return JSON.stringify(_value);
  5689. }
  5690. if (Array.isArray(_value)) {
  5691. return "[".concat(_value.map(function (subValue) {
  5692. return exports.apiDescriptor.value(subValue);
  5693. }).join(', '), "]");
  5694. }
  5695. var keys = Object.keys(_value);
  5696. return keys.length === 0 ? '{}' : "{ ".concat(keys.map(function (key) {
  5697. return "".concat(exports.apiDescriptor.key(key), ": ").concat(exports.apiDescriptor.value(_value[key]));
  5698. }).join(', '), " }");
  5699. },
  5700. pair: function pair(_ref) {
  5701. var key = _ref.key,
  5702. value = _ref.value;
  5703. return exports.apiDescriptor.value(_defineProperty({}, key, value));
  5704. }
  5705. };
  5706. });
  5707. unwrapExports(api);
  5708. var descriptors = createCommonjsModule(function (module, exports) {
  5709. "use strict";
  5710. Object.defineProperty(exports, "__esModule", {
  5711. value: true
  5712. });
  5713. tslib_1.__exportStar(api, exports);
  5714. });
  5715. unwrapExports(descriptors);
  5716. var matchOperatorsRe = /[|\\{}()[\]^$+*?.]/g;
  5717. var escapeStringRegexp = function escapeStringRegexp(str) {
  5718. if (typeof str !== 'string') {
  5719. throw new TypeError('Expected a string');
  5720. }
  5721. return str.replace(matchOperatorsRe, '\\$&');
  5722. };
  5723. var colorName = {
  5724. "aliceblue": [240, 248, 255],
  5725. "antiquewhite": [250, 235, 215],
  5726. "aqua": [0, 255, 255],
  5727. "aquamarine": [127, 255, 212],
  5728. "azure": [240, 255, 255],
  5729. "beige": [245, 245, 220],
  5730. "bisque": [255, 228, 196],
  5731. "black": [0, 0, 0],
  5732. "blanchedalmond": [255, 235, 205],
  5733. "blue": [0, 0, 255],
  5734. "blueviolet": [138, 43, 226],
  5735. "brown": [165, 42, 42],
  5736. "burlywood": [222, 184, 135],
  5737. "cadetblue": [95, 158, 160],
  5738. "chartreuse": [127, 255, 0],
  5739. "chocolate": [210, 105, 30],
  5740. "coral": [255, 127, 80],
  5741. "cornflowerblue": [100, 149, 237],
  5742. "cornsilk": [255, 248, 220],
  5743. "crimson": [220, 20, 60],
  5744. "cyan": [0, 255, 255],
  5745. "darkblue": [0, 0, 139],
  5746. "darkcyan": [0, 139, 139],
  5747. "darkgoldenrod": [184, 134, 11],
  5748. "darkgray": [169, 169, 169],
  5749. "darkgreen": [0, 100, 0],
  5750. "darkgrey": [169, 169, 169],
  5751. "darkkhaki": [189, 183, 107],
  5752. "darkmagenta": [139, 0, 139],
  5753. "darkolivegreen": [85, 107, 47],
  5754. "darkorange": [255, 140, 0],
  5755. "darkorchid": [153, 50, 204],
  5756. "darkred": [139, 0, 0],
  5757. "darksalmon": [233, 150, 122],
  5758. "darkseagreen": [143, 188, 143],
  5759. "darkslateblue": [72, 61, 139],
  5760. "darkslategray": [47, 79, 79],
  5761. "darkslategrey": [47, 79, 79],
  5762. "darkturquoise": [0, 206, 209],
  5763. "darkviolet": [148, 0, 211],
  5764. "deeppink": [255, 20, 147],
  5765. "deepskyblue": [0, 191, 255],
  5766. "dimgray": [105, 105, 105],
  5767. "dimgrey": [105, 105, 105],
  5768. "dodgerblue": [30, 144, 255],
  5769. "firebrick": [178, 34, 34],
  5770. "floralwhite": [255, 250, 240],
  5771. "forestgreen": [34, 139, 34],
  5772. "fuchsia": [255, 0, 255],
  5773. "gainsboro": [220, 220, 220],
  5774. "ghostwhite": [248, 248, 255],
  5775. "gold": [255, 215, 0],
  5776. "goldenrod": [218, 165, 32],
  5777. "gray": [128, 128, 128],
  5778. "green": [0, 128, 0],
  5779. "greenyellow": [173, 255, 47],
  5780. "grey": [128, 128, 128],
  5781. "honeydew": [240, 255, 240],
  5782. "hotpink": [255, 105, 180],
  5783. "indianred": [205, 92, 92],
  5784. "indigo": [75, 0, 130],
  5785. "ivory": [255, 255, 240],
  5786. "khaki": [240, 230, 140],
  5787. "lavender": [230, 230, 250],
  5788. "lavenderblush": [255, 240, 245],
  5789. "lawngreen": [124, 252, 0],
  5790. "lemonchiffon": [255, 250, 205],
  5791. "lightblue": [173, 216, 230],
  5792. "lightcoral": [240, 128, 128],
  5793. "lightcyan": [224, 255, 255],
  5794. "lightgoldenrodyellow": [250, 250, 210],
  5795. "lightgray": [211, 211, 211],
  5796. "lightgreen": [144, 238, 144],
  5797. "lightgrey": [211, 211, 211],
  5798. "lightpink": [255, 182, 193],
  5799. "lightsalmon": [255, 160, 122],
  5800. "lightseagreen": [32, 178, 170],
  5801. "lightskyblue": [135, 206, 250],
  5802. "lightslategray": [119, 136, 153],
  5803. "lightslategrey": [119, 136, 153],
  5804. "lightsteelblue": [176, 196, 222],
  5805. "lightyellow": [255, 255, 224],
  5806. "lime": [0, 255, 0],
  5807. "limegreen": [50, 205, 50],
  5808. "linen": [250, 240, 230],
  5809. "magenta": [255, 0, 255],
  5810. "maroon": [128, 0, 0],
  5811. "mediumaquamarine": [102, 205, 170],
  5812. "mediumblue": [0, 0, 205],
  5813. "mediumorchid": [186, 85, 211],
  5814. "mediumpurple": [147, 112, 219],
  5815. "mediumseagreen": [60, 179, 113],
  5816. "mediumslateblue": [123, 104, 238],
  5817. "mediumspringgreen": [0, 250, 154],
  5818. "mediumturquoise": [72, 209, 204],
  5819. "mediumvioletred": [199, 21, 133],
  5820. "midnightblue": [25, 25, 112],
  5821. "mintcream": [245, 255, 250],
  5822. "mistyrose": [255, 228, 225],
  5823. "moccasin": [255, 228, 181],
  5824. "navajowhite": [255, 222, 173],
  5825. "navy": [0, 0, 128],
  5826. "oldlace": [253, 245, 230],
  5827. "olive": [128, 128, 0],
  5828. "olivedrab": [107, 142, 35],
  5829. "orange": [255, 165, 0],
  5830. "orangered": [255, 69, 0],
  5831. "orchid": [218, 112, 214],
  5832. "palegoldenrod": [238, 232, 170],
  5833. "palegreen": [152, 251, 152],
  5834. "paleturquoise": [175, 238, 238],
  5835. "palevioletred": [219, 112, 147],
  5836. "papayawhip": [255, 239, 213],
  5837. "peachpuff": [255, 218, 185],
  5838. "peru": [205, 133, 63],
  5839. "pink": [255, 192, 203],
  5840. "plum": [221, 160, 221],
  5841. "powderblue": [176, 224, 230],
  5842. "purple": [128, 0, 128],
  5843. "rebeccapurple": [102, 51, 153],
  5844. "red": [255, 0, 0],
  5845. "rosybrown": [188, 143, 143],
  5846. "royalblue": [65, 105, 225],
  5847. "saddlebrown": [139, 69, 19],
  5848. "salmon": [250, 128, 114],
  5849. "sandybrown": [244, 164, 96],
  5850. "seagreen": [46, 139, 87],
  5851. "seashell": [255, 245, 238],
  5852. "sienna": [160, 82, 45],
  5853. "silver": [192, 192, 192],
  5854. "skyblue": [135, 206, 235],
  5855. "slateblue": [106, 90, 205],
  5856. "slategray": [112, 128, 144],
  5857. "slategrey": [112, 128, 144],
  5858. "snow": [255, 250, 250],
  5859. "springgreen": [0, 255, 127],
  5860. "steelblue": [70, 130, 180],
  5861. "tan": [210, 180, 140],
  5862. "teal": [0, 128, 128],
  5863. "thistle": [216, 191, 216],
  5864. "tomato": [255, 99, 71],
  5865. "turquoise": [64, 224, 208],
  5866. "violet": [238, 130, 238],
  5867. "wheat": [245, 222, 179],
  5868. "white": [255, 255, 255],
  5869. "whitesmoke": [245, 245, 245],
  5870. "yellow": [255, 255, 0],
  5871. "yellowgreen": [154, 205, 50]
  5872. };
  5873. var conversions = createCommonjsModule(function (module) {
  5874. /* MIT license */
  5875. // NOTE: conversions should only return primitive values (i.e. arrays, or
  5876. // values that give correct `typeof` results).
  5877. // do not use box values types (i.e. Number(), String(), etc.)
  5878. var reverseKeywords = {};
  5879. for (var key in colorName) {
  5880. if (colorName.hasOwnProperty(key)) {
  5881. reverseKeywords[colorName[key]] = key;
  5882. }
  5883. }
  5884. var convert = module.exports = {
  5885. rgb: {
  5886. channels: 3,
  5887. labels: 'rgb'
  5888. },
  5889. hsl: {
  5890. channels: 3,
  5891. labels: 'hsl'
  5892. },
  5893. hsv: {
  5894. channels: 3,
  5895. labels: 'hsv'
  5896. },
  5897. hwb: {
  5898. channels: 3,
  5899. labels: 'hwb'
  5900. },
  5901. cmyk: {
  5902. channels: 4,
  5903. labels: 'cmyk'
  5904. },
  5905. xyz: {
  5906. channels: 3,
  5907. labels: 'xyz'
  5908. },
  5909. lab: {
  5910. channels: 3,
  5911. labels: 'lab'
  5912. },
  5913. lch: {
  5914. channels: 3,
  5915. labels: 'lch'
  5916. },
  5917. hex: {
  5918. channels: 1,
  5919. labels: ['hex']
  5920. },
  5921. keyword: {
  5922. channels: 1,
  5923. labels: ['keyword']
  5924. },
  5925. ansi16: {
  5926. channels: 1,
  5927. labels: ['ansi16']
  5928. },
  5929. ansi256: {
  5930. channels: 1,
  5931. labels: ['ansi256']
  5932. },
  5933. hcg: {
  5934. channels: 3,
  5935. labels: ['h', 'c', 'g']
  5936. },
  5937. apple: {
  5938. channels: 3,
  5939. labels: ['r16', 'g16', 'b16']
  5940. },
  5941. gray: {
  5942. channels: 1,
  5943. labels: ['gray']
  5944. }
  5945. }; // hide .channels and .labels properties
  5946. for (var model in convert) {
  5947. if (convert.hasOwnProperty(model)) {
  5948. if (!('channels' in convert[model])) {
  5949. throw new Error('missing channels property: ' + model);
  5950. }
  5951. if (!('labels' in convert[model])) {
  5952. throw new Error('missing channel labels property: ' + model);
  5953. }
  5954. if (convert[model].labels.length !== convert[model].channels) {
  5955. throw new Error('channel and label counts mismatch: ' + model);
  5956. }
  5957. var channels = convert[model].channels;
  5958. var labels = convert[model].labels;
  5959. delete convert[model].channels;
  5960. delete convert[model].labels;
  5961. Object.defineProperty(convert[model], 'channels', {
  5962. value: channels
  5963. });
  5964. Object.defineProperty(convert[model], 'labels', {
  5965. value: labels
  5966. });
  5967. }
  5968. }
  5969. convert.rgb.hsl = function (rgb) {
  5970. var r = rgb[0] / 255;
  5971. var g = rgb[1] / 255;
  5972. var b = rgb[2] / 255;
  5973. var min = Math.min(r, g, b);
  5974. var max = Math.max(r, g, b);
  5975. var delta = max - min;
  5976. var h;
  5977. var s;
  5978. var l;
  5979. if (max === min) {
  5980. h = 0;
  5981. } else if (r === max) {
  5982. h = (g - b) / delta;
  5983. } else if (g === max) {
  5984. h = 2 + (b - r) / delta;
  5985. } else if (b === max) {
  5986. h = 4 + (r - g) / delta;
  5987. }
  5988. h = Math.min(h * 60, 360);
  5989. if (h < 0) {
  5990. h += 360;
  5991. }
  5992. l = (min + max) / 2;
  5993. if (max === min) {
  5994. s = 0;
  5995. } else if (l <= 0.5) {
  5996. s = delta / (max + min);
  5997. } else {
  5998. s = delta / (2 - max - min);
  5999. }
  6000. return [h, s * 100, l * 100];
  6001. };
  6002. convert.rgb.hsv = function (rgb) {
  6003. var r = rgb[0];
  6004. var g = rgb[1];
  6005. var b = rgb[2];
  6006. var min = Math.min(r, g, b);
  6007. var max = Math.max(r, g, b);
  6008. var delta = max - min;
  6009. var h;
  6010. var s;
  6011. var v;
  6012. if (max === 0) {
  6013. s = 0;
  6014. } else {
  6015. s = delta / max * 1000 / 10;
  6016. }
  6017. if (max === min) {
  6018. h = 0;
  6019. } else if (r === max) {
  6020. h = (g - b) / delta;
  6021. } else if (g === max) {
  6022. h = 2 + (b - r) / delta;
  6023. } else if (b === max) {
  6024. h = 4 + (r - g) / delta;
  6025. }
  6026. h = Math.min(h * 60, 360);
  6027. if (h < 0) {
  6028. h += 360;
  6029. }
  6030. v = max / 255 * 1000 / 10;
  6031. return [h, s, v];
  6032. };
  6033. convert.rgb.hwb = function (rgb) {
  6034. var r = rgb[0];
  6035. var g = rgb[1];
  6036. var b = rgb[2];
  6037. var h = convert.rgb.hsl(rgb)[0];
  6038. var w = 1 / 255 * Math.min(r, Math.min(g, b));
  6039. b = 1 - 1 / 255 * Math.max(r, Math.max(g, b));
  6040. return [h, w * 100, b * 100];
  6041. };
  6042. convert.rgb.cmyk = function (rgb) {
  6043. var r = rgb[0] / 255;
  6044. var g = rgb[1] / 255;
  6045. var b = rgb[2] / 255;
  6046. var c;
  6047. var m;
  6048. var y;
  6049. var k;
  6050. k = Math.min(1 - r, 1 - g, 1 - b);
  6051. c = (1 - r - k) / (1 - k) || 0;
  6052. m = (1 - g - k) / (1 - k) || 0;
  6053. y = (1 - b - k) / (1 - k) || 0;
  6054. return [c * 100, m * 100, y * 100, k * 100];
  6055. };
  6056. /**
  6057. * See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
  6058. * */
  6059. function comparativeDistance(x, y) {
  6060. return Math.pow(x[0] - y[0], 2) + Math.pow(x[1] - y[1], 2) + Math.pow(x[2] - y[2], 2);
  6061. }
  6062. convert.rgb.keyword = function (rgb) {
  6063. var reversed = reverseKeywords[rgb];
  6064. if (reversed) {
  6065. return reversed;
  6066. }
  6067. var currentClosestDistance = Infinity;
  6068. var currentClosestKeyword;
  6069. for (var keyword in colorName) {
  6070. if (colorName.hasOwnProperty(keyword)) {
  6071. var value = colorName[keyword]; // Compute comparative distance
  6072. var distance = comparativeDistance(rgb, value); // Check if its less, if so set as closest
  6073. if (distance < currentClosestDistance) {
  6074. currentClosestDistance = distance;
  6075. currentClosestKeyword = keyword;
  6076. }
  6077. }
  6078. }
  6079. return currentClosestKeyword;
  6080. };
  6081. convert.keyword.rgb = function (keyword) {
  6082. return colorName[keyword];
  6083. };
  6084. convert.rgb.xyz = function (rgb) {
  6085. var r = rgb[0] / 255;
  6086. var g = rgb[1] / 255;
  6087. var b = rgb[2] / 255; // assume sRGB
  6088. r = r > 0.04045 ? Math.pow((r + 0.055) / 1.055, 2.4) : r / 12.92;
  6089. g = g > 0.04045 ? Math.pow((g + 0.055) / 1.055, 2.4) : g / 12.92;
  6090. b = b > 0.04045 ? Math.pow((b + 0.055) / 1.055, 2.4) : b / 12.92;
  6091. var x = r * 0.4124 + g * 0.3576 + b * 0.1805;
  6092. var y = r * 0.2126 + g * 0.7152 + b * 0.0722;
  6093. var z = r * 0.0193 + g * 0.1192 + b * 0.9505;
  6094. return [x * 100, y * 100, z * 100];
  6095. };
  6096. convert.rgb.lab = function (rgb) {
  6097. var xyz = convert.rgb.xyz(rgb);
  6098. var x = xyz[0];
  6099. var y = xyz[1];
  6100. var z = xyz[2];
  6101. var l;
  6102. var a;
  6103. var b;
  6104. x /= 95.047;
  6105. y /= 100;
  6106. z /= 108.883;
  6107. x = x > 0.008856 ? Math.pow(x, 1 / 3) : 7.787 * x + 16 / 116;
  6108. y = y > 0.008856 ? Math.pow(y, 1 / 3) : 7.787 * y + 16 / 116;
  6109. z = z > 0.008856 ? Math.pow(z, 1 / 3) : 7.787 * z + 16 / 116;
  6110. l = 116 * y - 16;
  6111. a = 500 * (x - y);
  6112. b = 200 * (y - z);
  6113. return [l, a, b];
  6114. };
  6115. convert.hsl.rgb = function (hsl) {
  6116. var h = hsl[0] / 360;
  6117. var s = hsl[1] / 100;
  6118. var l = hsl[2] / 100;
  6119. var t1;
  6120. var t2;
  6121. var t3;
  6122. var rgb;
  6123. var val;
  6124. if (s === 0) {
  6125. val = l * 255;
  6126. return [val, val, val];
  6127. }
  6128. if (l < 0.5) {
  6129. t2 = l * (1 + s);
  6130. } else {
  6131. t2 = l + s - l * s;
  6132. }
  6133. t1 = 2 * l - t2;
  6134. rgb = [0, 0, 0];
  6135. for (var i = 0; i < 3; i++) {
  6136. t3 = h + 1 / 3 * -(i - 1);
  6137. if (t3 < 0) {
  6138. t3++;
  6139. }
  6140. if (t3 > 1) {
  6141. t3--;
  6142. }
  6143. if (6 * t3 < 1) {
  6144. val = t1 + (t2 - t1) * 6 * t3;
  6145. } else if (2 * t3 < 1) {
  6146. val = t2;
  6147. } else if (3 * t3 < 2) {
  6148. val = t1 + (t2 - t1) * (2 / 3 - t3) * 6;
  6149. } else {
  6150. val = t1;
  6151. }
  6152. rgb[i] = val * 255;
  6153. }
  6154. return rgb;
  6155. };
  6156. convert.hsl.hsv = function (hsl) {
  6157. var h = hsl[0];
  6158. var s = hsl[1] / 100;
  6159. var l = hsl[2] / 100;
  6160. var smin = s;
  6161. var lmin = Math.max(l, 0.01);
  6162. var sv;
  6163. var v;
  6164. l *= 2;
  6165. s *= l <= 1 ? l : 2 - l;
  6166. smin *= lmin <= 1 ? lmin : 2 - lmin;
  6167. v = (l + s) / 2;
  6168. sv = l === 0 ? 2 * smin / (lmin + smin) : 2 * s / (l + s);
  6169. return [h, sv * 100, v * 100];
  6170. };
  6171. convert.hsv.rgb = function (hsv) {
  6172. var h = hsv[0] / 60;
  6173. var s = hsv[1] / 100;
  6174. var v = hsv[2] / 100;
  6175. var hi = Math.floor(h) % 6;
  6176. var f = h - Math.floor(h);
  6177. var p = 255 * v * (1 - s);
  6178. var q = 255 * v * (1 - s * f);
  6179. var t = 255 * v * (1 - s * (1 - f));
  6180. v *= 255;
  6181. switch (hi) {
  6182. case 0:
  6183. return [v, t, p];
  6184. case 1:
  6185. return [q, v, p];
  6186. case 2:
  6187. return [p, v, t];
  6188. case 3:
  6189. return [p, q, v];
  6190. case 4:
  6191. return [t, p, v];
  6192. case 5:
  6193. return [v, p, q];
  6194. }
  6195. };
  6196. convert.hsv.hsl = function (hsv) {
  6197. var h = hsv[0];
  6198. var s = hsv[1] / 100;
  6199. var v = hsv[2] / 100;
  6200. var vmin = Math.max(v, 0.01);
  6201. var lmin;
  6202. var sl;
  6203. var l;
  6204. l = (2 - s) * v;
  6205. lmin = (2 - s) * vmin;
  6206. sl = s * vmin;
  6207. sl /= lmin <= 1 ? lmin : 2 - lmin;
  6208. sl = sl || 0;
  6209. l /= 2;
  6210. return [h, sl * 100, l * 100];
  6211. }; // http://dev.w3.org/csswg/css-color/#hwb-to-rgb
  6212. convert.hwb.rgb = function (hwb) {
  6213. var h = hwb[0] / 360;
  6214. var wh = hwb[1] / 100;
  6215. var bl = hwb[2] / 100;
  6216. var ratio = wh + bl;
  6217. var i;
  6218. var v;
  6219. var f;
  6220. var n; // wh + bl cant be > 1
  6221. if (ratio > 1) {
  6222. wh /= ratio;
  6223. bl /= ratio;
  6224. }
  6225. i = Math.floor(6 * h);
  6226. v = 1 - bl;
  6227. f = 6 * h - i;
  6228. if ((i & 0x01) !== 0) {
  6229. f = 1 - f;
  6230. }
  6231. n = wh + f * (v - wh); // linear interpolation
  6232. var r;
  6233. var g;
  6234. var b;
  6235. switch (i) {
  6236. default:
  6237. case 6:
  6238. case 0:
  6239. r = v;
  6240. g = n;
  6241. b = wh;
  6242. break;
  6243. case 1:
  6244. r = n;
  6245. g = v;
  6246. b = wh;
  6247. break;
  6248. case 2:
  6249. r = wh;
  6250. g = v;
  6251. b = n;
  6252. break;
  6253. case 3:
  6254. r = wh;
  6255. g = n;
  6256. b = v;
  6257. break;
  6258. case 4:
  6259. r = n;
  6260. g = wh;
  6261. b = v;
  6262. break;
  6263. case 5:
  6264. r = v;
  6265. g = wh;
  6266. b = n;
  6267. break;
  6268. }
  6269. return [r * 255, g * 255, b * 255];
  6270. };
  6271. convert.cmyk.rgb = function (cmyk) {
  6272. var c = cmyk[0] / 100;
  6273. var m = cmyk[1] / 100;
  6274. var y = cmyk[2] / 100;
  6275. var k = cmyk[3] / 100;
  6276. var r;
  6277. var g;
  6278. var b;
  6279. r = 1 - Math.min(1, c * (1 - k) + k);
  6280. g = 1 - Math.min(1, m * (1 - k) + k);
  6281. b = 1 - Math.min(1, y * (1 - k) + k);
  6282. return [r * 255, g * 255, b * 255];
  6283. };
  6284. convert.xyz.rgb = function (xyz) {
  6285. var x = xyz[0] / 100;
  6286. var y = xyz[1] / 100;
  6287. var z = xyz[2] / 100;
  6288. var r;
  6289. var g;
  6290. var b;
  6291. r = x * 3.2406 + y * -1.5372 + z * -0.4986;
  6292. g = x * -0.9689 + y * 1.8758 + z * 0.0415;
  6293. b = x * 0.0557 + y * -0.2040 + z * 1.0570; // assume sRGB
  6294. r = r > 0.0031308 ? 1.055 * Math.pow(r, 1.0 / 2.4) - 0.055 : r * 12.92;
  6295. g = g > 0.0031308 ? 1.055 * Math.pow(g, 1.0 / 2.4) - 0.055 : g * 12.92;
  6296. b = b > 0.0031308 ? 1.055 * Math.pow(b, 1.0 / 2.4) - 0.055 : b * 12.92;
  6297. r = Math.min(Math.max(0, r), 1);
  6298. g = Math.min(Math.max(0, g), 1);
  6299. b = Math.min(Math.max(0, b), 1);
  6300. return [r * 255, g * 255, b * 255];
  6301. };
  6302. convert.xyz.lab = function (xyz) {
  6303. var x = xyz[0];
  6304. var y = xyz[1];
  6305. var z = xyz[2];
  6306. var l;
  6307. var a;
  6308. var b;
  6309. x /= 95.047;
  6310. y /= 100;
  6311. z /= 108.883;
  6312. x = x > 0.008856 ? Math.pow(x, 1 / 3) : 7.787 * x + 16 / 116;
  6313. y = y > 0.008856 ? Math.pow(y, 1 / 3) : 7.787 * y + 16 / 116;
  6314. z = z > 0.008856 ? Math.pow(z, 1 / 3) : 7.787 * z + 16 / 116;
  6315. l = 116 * y - 16;
  6316. a = 500 * (x - y);
  6317. b = 200 * (y - z);
  6318. return [l, a, b];
  6319. };
  6320. convert.lab.xyz = function (lab) {
  6321. var l = lab[0];
  6322. var a = lab[1];
  6323. var b = lab[2];
  6324. var x;
  6325. var y;
  6326. var z;
  6327. y = (l + 16) / 116;
  6328. x = a / 500 + y;
  6329. z = y - b / 200;
  6330. var y2 = Math.pow(y, 3);
  6331. var x2 = Math.pow(x, 3);
  6332. var z2 = Math.pow(z, 3);
  6333. y = y2 > 0.008856 ? y2 : (y - 16 / 116) / 7.787;
  6334. x = x2 > 0.008856 ? x2 : (x - 16 / 116) / 7.787;
  6335. z = z2 > 0.008856 ? z2 : (z - 16 / 116) / 7.787;
  6336. x *= 95.047;
  6337. y *= 100;
  6338. z *= 108.883;
  6339. return [x, y, z];
  6340. };
  6341. convert.lab.lch = function (lab) {
  6342. var l = lab[0];
  6343. var a = lab[1];
  6344. var b = lab[2];
  6345. var hr;
  6346. var h;
  6347. var c;
  6348. hr = Math.atan2(b, a);
  6349. h = hr * 360 / 2 / Math.PI;
  6350. if (h < 0) {
  6351. h += 360;
  6352. }
  6353. c = Math.sqrt(a * a + b * b);
  6354. return [l, c, h];
  6355. };
  6356. convert.lch.lab = function (lch) {
  6357. var l = lch[0];
  6358. var c = lch[1];
  6359. var h = lch[2];
  6360. var a;
  6361. var b;
  6362. var hr;
  6363. hr = h / 360 * 2 * Math.PI;
  6364. a = c * Math.cos(hr);
  6365. b = c * Math.sin(hr);
  6366. return [l, a, b];
  6367. };
  6368. convert.rgb.ansi16 = function (args) {
  6369. var r = args[0];
  6370. var g = args[1];
  6371. var b = args[2];
  6372. var value = 1 in arguments ? arguments[1] : convert.rgb.hsv(args)[2]; // hsv -> ansi16 optimization
  6373. value = Math.round(value / 50);
  6374. if (value === 0) {
  6375. return 30;
  6376. }
  6377. var ansi = 30 + (Math.round(b / 255) << 2 | Math.round(g / 255) << 1 | Math.round(r / 255));
  6378. if (value === 2) {
  6379. ansi += 60;
  6380. }
  6381. return ansi;
  6382. };
  6383. convert.hsv.ansi16 = function (args) {
  6384. // optimization here; we already know the value and don't need to get
  6385. // it converted for us.
  6386. return convert.rgb.ansi16(convert.hsv.rgb(args), args[2]);
  6387. };
  6388. convert.rgb.ansi256 = function (args) {
  6389. var r = args[0];
  6390. var g = args[1];
  6391. var b = args[2]; // we use the extended greyscale palette here, with the exception of
  6392. // black and white. normal palette only has 4 greyscale shades.
  6393. if (r === g && g === b) {
  6394. if (r < 8) {
  6395. return 16;
  6396. }
  6397. if (r > 248) {
  6398. return 231;
  6399. }
  6400. return Math.round((r - 8) / 247 * 24) + 232;
  6401. }
  6402. var ansi = 16 + 36 * Math.round(r / 255 * 5) + 6 * Math.round(g / 255 * 5) + Math.round(b / 255 * 5);
  6403. return ansi;
  6404. };
  6405. convert.ansi16.rgb = function (args) {
  6406. var color = args % 10; // handle greyscale
  6407. if (color === 0 || color === 7) {
  6408. if (args > 50) {
  6409. color += 3.5;
  6410. }
  6411. color = color / 10.5 * 255;
  6412. return [color, color, color];
  6413. }
  6414. var mult = (~~(args > 50) + 1) * 0.5;
  6415. var r = (color & 1) * mult * 255;
  6416. var g = (color >> 1 & 1) * mult * 255;
  6417. var b = (color >> 2 & 1) * mult * 255;
  6418. return [r, g, b];
  6419. };
  6420. convert.ansi256.rgb = function (args) {
  6421. // handle greyscale
  6422. if (args >= 232) {
  6423. var c = (args - 232) * 10 + 8;
  6424. return [c, c, c];
  6425. }
  6426. args -= 16;
  6427. var rem;
  6428. var r = Math.floor(args / 36) / 5 * 255;
  6429. var g = Math.floor((rem = args % 36) / 6) / 5 * 255;
  6430. var b = rem % 6 / 5 * 255;
  6431. return [r, g, b];
  6432. };
  6433. convert.rgb.hex = function (args) {
  6434. var integer = ((Math.round(args[0]) & 0xFF) << 16) + ((Math.round(args[1]) & 0xFF) << 8) + (Math.round(args[2]) & 0xFF);
  6435. var string = integer.toString(16).toUpperCase();
  6436. return '000000'.substring(string.length) + string;
  6437. };
  6438. convert.hex.rgb = function (args) {
  6439. var match = args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);
  6440. if (!match) {
  6441. return [0, 0, 0];
  6442. }
  6443. var colorString = match[0];
  6444. if (match[0].length === 3) {
  6445. colorString = colorString.split('').map(function (char) {
  6446. return char + char;
  6447. }).join('');
  6448. }
  6449. var integer = parseInt(colorString, 16);
  6450. var r = integer >> 16 & 0xFF;
  6451. var g = integer >> 8 & 0xFF;
  6452. var b = integer & 0xFF;
  6453. return [r, g, b];
  6454. };
  6455. convert.rgb.hcg = function (rgb) {
  6456. var r = rgb[0] / 255;
  6457. var g = rgb[1] / 255;
  6458. var b = rgb[2] / 255;
  6459. var max = Math.max(Math.max(r, g), b);
  6460. var min = Math.min(Math.min(r, g), b);
  6461. var chroma = max - min;
  6462. var grayscale;
  6463. var hue;
  6464. if (chroma < 1) {
  6465. grayscale = min / (1 - chroma);
  6466. } else {
  6467. grayscale = 0;
  6468. }
  6469. if (chroma <= 0) {
  6470. hue = 0;
  6471. } else if (max === r) {
  6472. hue = (g - b) / chroma % 6;
  6473. } else if (max === g) {
  6474. hue = 2 + (b - r) / chroma;
  6475. } else {
  6476. hue = 4 + (r - g) / chroma + 4;
  6477. }
  6478. hue /= 6;
  6479. hue %= 1;
  6480. return [hue * 360, chroma * 100, grayscale * 100];
  6481. };
  6482. convert.hsl.hcg = function (hsl) {
  6483. var s = hsl[1] / 100;
  6484. var l = hsl[2] / 100;
  6485. var c = 1;
  6486. var f = 0;
  6487. if (l < 0.5) {
  6488. c = 2.0 * s * l;
  6489. } else {
  6490. c = 2.0 * s * (1.0 - l);
  6491. }
  6492. if (c < 1.0) {
  6493. f = (l - 0.5 * c) / (1.0 - c);
  6494. }
  6495. return [hsl[0], c * 100, f * 100];
  6496. };
  6497. convert.hsv.hcg = function (hsv) {
  6498. var s = hsv[1] / 100;
  6499. var v = hsv[2] / 100;
  6500. var c = s * v;
  6501. var f = 0;
  6502. if (c < 1.0) {
  6503. f = (v - c) / (1 - c);
  6504. }
  6505. return [hsv[0], c * 100, f * 100];
  6506. };
  6507. convert.hcg.rgb = function (hcg) {
  6508. var h = hcg[0] / 360;
  6509. var c = hcg[1] / 100;
  6510. var g = hcg[2] / 100;
  6511. if (c === 0.0) {
  6512. return [g * 255, g * 255, g * 255];
  6513. }
  6514. var pure = [0, 0, 0];
  6515. var hi = h % 1 * 6;
  6516. var v = hi % 1;
  6517. var w = 1 - v;
  6518. var mg = 0;
  6519. switch (Math.floor(hi)) {
  6520. case 0:
  6521. pure[0] = 1;
  6522. pure[1] = v;
  6523. pure[2] = 0;
  6524. break;
  6525. case 1:
  6526. pure[0] = w;
  6527. pure[1] = 1;
  6528. pure[2] = 0;
  6529. break;
  6530. case 2:
  6531. pure[0] = 0;
  6532. pure[1] = 1;
  6533. pure[2] = v;
  6534. break;
  6535. case 3:
  6536. pure[0] = 0;
  6537. pure[1] = w;
  6538. pure[2] = 1;
  6539. break;
  6540. case 4:
  6541. pure[0] = v;
  6542. pure[1] = 0;
  6543. pure[2] = 1;
  6544. break;
  6545. default:
  6546. pure[0] = 1;
  6547. pure[1] = 0;
  6548. pure[2] = w;
  6549. }
  6550. mg = (1.0 - c) * g;
  6551. return [(c * pure[0] + mg) * 255, (c * pure[1] + mg) * 255, (c * pure[2] + mg) * 255];
  6552. };
  6553. convert.hcg.hsv = function (hcg) {
  6554. var c = hcg[1] / 100;
  6555. var g = hcg[2] / 100;
  6556. var v = c + g * (1.0 - c);
  6557. var f = 0;
  6558. if (v > 0.0) {
  6559. f = c / v;
  6560. }
  6561. return [hcg[0], f * 100, v * 100];
  6562. };
  6563. convert.hcg.hsl = function (hcg) {
  6564. var c = hcg[1] / 100;
  6565. var g = hcg[2] / 100;
  6566. var l = g * (1.0 - c) + 0.5 * c;
  6567. var s = 0;
  6568. if (l > 0.0 && l < 0.5) {
  6569. s = c / (2 * l);
  6570. } else if (l >= 0.5 && l < 1.0) {
  6571. s = c / (2 * (1 - l));
  6572. }
  6573. return [hcg[0], s * 100, l * 100];
  6574. };
  6575. convert.hcg.hwb = function (hcg) {
  6576. var c = hcg[1] / 100;
  6577. var g = hcg[2] / 100;
  6578. var v = c + g * (1.0 - c);
  6579. return [hcg[0], (v - c) * 100, (1 - v) * 100];
  6580. };
  6581. convert.hwb.hcg = function (hwb) {
  6582. var w = hwb[1] / 100;
  6583. var b = hwb[2] / 100;
  6584. var v = 1 - b;
  6585. var c = v - w;
  6586. var g = 0;
  6587. if (c < 1) {
  6588. g = (v - c) / (1 - c);
  6589. }
  6590. return [hwb[0], c * 100, g * 100];
  6591. };
  6592. convert.apple.rgb = function (apple) {
  6593. return [apple[0] / 65535 * 255, apple[1] / 65535 * 255, apple[2] / 65535 * 255];
  6594. };
  6595. convert.rgb.apple = function (rgb) {
  6596. return [rgb[0] / 255 * 65535, rgb[1] / 255 * 65535, rgb[2] / 255 * 65535];
  6597. };
  6598. convert.gray.rgb = function (args) {
  6599. return [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255];
  6600. };
  6601. convert.gray.hsl = convert.gray.hsv = function (args) {
  6602. return [0, 0, args[0]];
  6603. };
  6604. convert.gray.hwb = function (gray) {
  6605. return [0, 100, gray[0]];
  6606. };
  6607. convert.gray.cmyk = function (gray) {
  6608. return [0, 0, 0, gray[0]];
  6609. };
  6610. convert.gray.lab = function (gray) {
  6611. return [gray[0], 0, 0];
  6612. };
  6613. convert.gray.hex = function (gray) {
  6614. var val = Math.round(gray[0] / 100 * 255) & 0xFF;
  6615. var integer = (val << 16) + (val << 8) + val;
  6616. var string = integer.toString(16).toUpperCase();
  6617. return '000000'.substring(string.length) + string;
  6618. };
  6619. convert.rgb.gray = function (rgb) {
  6620. var val = (rgb[0] + rgb[1] + rgb[2]) / 3;
  6621. return [val / 255 * 100];
  6622. };
  6623. });
  6624. /*
  6625. this function routes a model to all other models.
  6626. all functions that are routed have a property `.conversion` attached
  6627. to the returned synthetic function. This property is an array
  6628. of strings, each with the steps in between the 'from' and 'to'
  6629. color models (inclusive).
  6630. conversions that are not possible simply are not included.
  6631. */
  6632. // https://jsperf.com/object-keys-vs-for-in-with-closure/3
  6633. var models$1 = Object.keys(conversions);
  6634. function buildGraph() {
  6635. var graph = {};
  6636. for (var len = models$1.length, i = 0; i < len; i++) {
  6637. graph[models$1[i]] = {
  6638. // http://jsperf.com/1-vs-infinity
  6639. // micro-opt, but this is simple.
  6640. distance: -1,
  6641. parent: null
  6642. };
  6643. }
  6644. return graph;
  6645. } // https://en.wikipedia.org/wiki/Breadth-first_search
  6646. function deriveBFS(fromModel) {
  6647. var graph = buildGraph();
  6648. var queue = [fromModel]; // unshift -> queue -> pop
  6649. graph[fromModel].distance = 0;
  6650. while (queue.length) {
  6651. var current = queue.pop();
  6652. var adjacents = Object.keys(conversions[current]);
  6653. for (var len = adjacents.length, i = 0; i < len; i++) {
  6654. var adjacent = adjacents[i];
  6655. var node = graph[adjacent];
  6656. if (node.distance === -1) {
  6657. node.distance = graph[current].distance + 1;
  6658. node.parent = current;
  6659. queue.unshift(adjacent);
  6660. }
  6661. }
  6662. }
  6663. return graph;
  6664. }
  6665. function link(from, to) {
  6666. return function (args) {
  6667. return to(from(args));
  6668. };
  6669. }
  6670. function wrapConversion(toModel, graph) {
  6671. var path = [graph[toModel].parent, toModel];
  6672. var fn = conversions[graph[toModel].parent][toModel];
  6673. var cur = graph[toModel].parent;
  6674. while (graph[cur].parent) {
  6675. path.unshift(graph[cur].parent);
  6676. fn = link(conversions[graph[cur].parent][cur], fn);
  6677. cur = graph[cur].parent;
  6678. }
  6679. fn.conversion = path;
  6680. return fn;
  6681. }
  6682. var route = function route(fromModel) {
  6683. var graph = deriveBFS(fromModel);
  6684. var conversion = {};
  6685. var models = Object.keys(graph);
  6686. for (var len = models.length, i = 0; i < len; i++) {
  6687. var toModel = models[i];
  6688. var node = graph[toModel];
  6689. if (node.parent === null) {
  6690. // no possible conversion, or this node is the source model.
  6691. continue;
  6692. }
  6693. conversion[toModel] = wrapConversion(toModel, graph);
  6694. }
  6695. return conversion;
  6696. };
  6697. var convert = {};
  6698. var models = Object.keys(conversions);
  6699. function wrapRaw(fn) {
  6700. var wrappedFn = function wrappedFn(args) {
  6701. if (args === undefined || args === null) {
  6702. return args;
  6703. }
  6704. if (arguments.length > 1) {
  6705. args = Array.prototype.slice.call(arguments);
  6706. }
  6707. return fn(args);
  6708. }; // preserve .conversion property if there is one
  6709. if ('conversion' in fn) {
  6710. wrappedFn.conversion = fn.conversion;
  6711. }
  6712. return wrappedFn;
  6713. }
  6714. function wrapRounded(fn) {
  6715. var wrappedFn = function wrappedFn(args) {
  6716. if (args === undefined || args === null) {
  6717. return args;
  6718. }
  6719. if (arguments.length > 1) {
  6720. args = Array.prototype.slice.call(arguments);
  6721. }
  6722. var result = fn(args); // we're assuming the result is an array here.
  6723. // see notice in conversions.js; don't use box types
  6724. // in conversion functions.
  6725. if (_typeof(result) === 'object') {
  6726. for (var len = result.length, i = 0; i < len; i++) {
  6727. result[i] = Math.round(result[i]);
  6728. }
  6729. }
  6730. return result;
  6731. }; // preserve .conversion property if there is one
  6732. if ('conversion' in fn) {
  6733. wrappedFn.conversion = fn.conversion;
  6734. }
  6735. return wrappedFn;
  6736. }
  6737. models.forEach(function (fromModel) {
  6738. convert[fromModel] = {};
  6739. Object.defineProperty(convert[fromModel], 'channels', {
  6740. value: conversions[fromModel].channels
  6741. });
  6742. Object.defineProperty(convert[fromModel], 'labels', {
  6743. value: conversions[fromModel].labels
  6744. });
  6745. var routes = route(fromModel);
  6746. var routeModels = Object.keys(routes);
  6747. routeModels.forEach(function (toModel) {
  6748. var fn = routes[toModel];
  6749. convert[fromModel][toModel] = wrapRounded(fn);
  6750. convert[fromModel][toModel].raw = wrapRaw(fn);
  6751. });
  6752. });
  6753. var colorConvert = convert;
  6754. var ansiStyles = createCommonjsModule(function (module) {
  6755. 'use strict';
  6756. var wrapAnsi16 = function wrapAnsi16(fn, offset) {
  6757. return function () {
  6758. var code = fn.apply(colorConvert, arguments);
  6759. return "\x1B[".concat(code + offset, "m");
  6760. };
  6761. };
  6762. var wrapAnsi256 = function wrapAnsi256(fn, offset) {
  6763. return function () {
  6764. var code = fn.apply(colorConvert, arguments);
  6765. return "\x1B[".concat(38 + offset, ";5;").concat(code, "m");
  6766. };
  6767. };
  6768. var wrapAnsi16m = function wrapAnsi16m(fn, offset) {
  6769. return function () {
  6770. var rgb = fn.apply(colorConvert, arguments);
  6771. return "\x1B[".concat(38 + offset, ";2;").concat(rgb[0], ";").concat(rgb[1], ";").concat(rgb[2], "m");
  6772. };
  6773. };
  6774. function assembleStyles() {
  6775. var codes = new Map();
  6776. var styles = {
  6777. modifier: {
  6778. reset: [0, 0],
  6779. // 21 isn't widely supported and 22 does the same thing
  6780. bold: [1, 22],
  6781. dim: [2, 22],
  6782. italic: [3, 23],
  6783. underline: [4, 24],
  6784. inverse: [7, 27],
  6785. hidden: [8, 28],
  6786. strikethrough: [9, 29]
  6787. },
  6788. color: {
  6789. black: [30, 39],
  6790. red: [31, 39],
  6791. green: [32, 39],
  6792. yellow: [33, 39],
  6793. blue: [34, 39],
  6794. magenta: [35, 39],
  6795. cyan: [36, 39],
  6796. white: [37, 39],
  6797. gray: [90, 39],
  6798. // Bright color
  6799. redBright: [91, 39],
  6800. greenBright: [92, 39],
  6801. yellowBright: [93, 39],
  6802. blueBright: [94, 39],
  6803. magentaBright: [95, 39],
  6804. cyanBright: [96, 39],
  6805. whiteBright: [97, 39]
  6806. },
  6807. bgColor: {
  6808. bgBlack: [40, 49],
  6809. bgRed: [41, 49],
  6810. bgGreen: [42, 49],
  6811. bgYellow: [43, 49],
  6812. bgBlue: [44, 49],
  6813. bgMagenta: [45, 49],
  6814. bgCyan: [46, 49],
  6815. bgWhite: [47, 49],
  6816. // Bright color
  6817. bgBlackBright: [100, 49],
  6818. bgRedBright: [101, 49],
  6819. bgGreenBright: [102, 49],
  6820. bgYellowBright: [103, 49],
  6821. bgBlueBright: [104, 49],
  6822. bgMagentaBright: [105, 49],
  6823. bgCyanBright: [106, 49],
  6824. bgWhiteBright: [107, 49]
  6825. }
  6826. }; // Fix humans
  6827. styles.color.grey = styles.color.gray;
  6828. var _arr = Object.keys(styles);
  6829. for (var _i = 0; _i < _arr.length; _i++) {
  6830. var groupName = _arr[_i];
  6831. var group = styles[groupName];
  6832. var _arr3 = Object.keys(group);
  6833. for (var _i3 = 0; _i3 < _arr3.length; _i3++) {
  6834. var styleName = _arr3[_i3];
  6835. var style = group[styleName];
  6836. styles[styleName] = {
  6837. open: "\x1B[".concat(style[0], "m"),
  6838. close: "\x1B[".concat(style[1], "m")
  6839. };
  6840. group[styleName] = styles[styleName];
  6841. codes.set(style[0], style[1]);
  6842. }
  6843. Object.defineProperty(styles, groupName, {
  6844. value: group,
  6845. enumerable: false
  6846. });
  6847. Object.defineProperty(styles, 'codes', {
  6848. value: codes,
  6849. enumerable: false
  6850. });
  6851. }
  6852. var ansi2ansi = function ansi2ansi(n) {
  6853. return n;
  6854. };
  6855. var rgb2rgb = function rgb2rgb(r, g, b) {
  6856. return [r, g, b];
  6857. };
  6858. styles.color.close = "\x1B[39m";
  6859. styles.bgColor.close = "\x1B[49m";
  6860. styles.color.ansi = {
  6861. ansi: wrapAnsi16(ansi2ansi, 0)
  6862. };
  6863. styles.color.ansi256 = {
  6864. ansi256: wrapAnsi256(ansi2ansi, 0)
  6865. };
  6866. styles.color.ansi16m = {
  6867. rgb: wrapAnsi16m(rgb2rgb, 0)
  6868. };
  6869. styles.bgColor.ansi = {
  6870. ansi: wrapAnsi16(ansi2ansi, 10)
  6871. };
  6872. styles.bgColor.ansi256 = {
  6873. ansi256: wrapAnsi256(ansi2ansi, 10)
  6874. };
  6875. styles.bgColor.ansi16m = {
  6876. rgb: wrapAnsi16m(rgb2rgb, 10)
  6877. };
  6878. var _arr2 = Object.keys(colorConvert);
  6879. for (var _i2 = 0; _i2 < _arr2.length; _i2++) {
  6880. var key = _arr2[_i2];
  6881. if (_typeof(colorConvert[key]) !== 'object') {
  6882. continue;
  6883. }
  6884. var suite = colorConvert[key];
  6885. if (key === 'ansi16') {
  6886. key = 'ansi';
  6887. }
  6888. if ('ansi16' in suite) {
  6889. styles.color.ansi[key] = wrapAnsi16(suite.ansi16, 0);
  6890. styles.bgColor.ansi[key] = wrapAnsi16(suite.ansi16, 10);
  6891. }
  6892. if ('ansi256' in suite) {
  6893. styles.color.ansi256[key] = wrapAnsi256(suite.ansi256, 0);
  6894. styles.bgColor.ansi256[key] = wrapAnsi256(suite.ansi256, 10);
  6895. }
  6896. if ('rgb' in suite) {
  6897. styles.color.ansi16m[key] = wrapAnsi16m(suite.rgb, 0);
  6898. styles.bgColor.ansi16m[key] = wrapAnsi16m(suite.rgb, 10);
  6899. }
  6900. }
  6901. return styles;
  6902. } // Make the export immutable
  6903. Object.defineProperty(module, 'exports', {
  6904. enumerable: true,
  6905. get: assembleStyles
  6906. });
  6907. });
  6908. var os = {
  6909. EOL: "\n"
  6910. };
  6911. var os$1 = Object.freeze({
  6912. default: os
  6913. });
  6914. var hasFlag = createCommonjsModule(function (module) {
  6915. 'use strict';
  6916. module.exports = function (flag, argv$$1) {
  6917. argv$$1 = argv$$1 || process.argv;
  6918. var prefix = flag.startsWith('-') ? '' : flag.length === 1 ? '-' : '--';
  6919. var pos = argv$$1.indexOf(prefix + flag);
  6920. var terminatorPos = argv$$1.indexOf('--');
  6921. return pos !== -1 && (terminatorPos === -1 ? true : pos < terminatorPos);
  6922. };
  6923. });
  6924. var require$$1$1 = ( os$1 && os ) || os$1;
  6925. var env$1 = process.env;
  6926. var forceColor;
  6927. if (hasFlag('no-color') || hasFlag('no-colors') || hasFlag('color=false')) {
  6928. forceColor = false;
  6929. } else if (hasFlag('color') || hasFlag('colors') || hasFlag('color=true') || hasFlag('color=always')) {
  6930. forceColor = true;
  6931. }
  6932. if ('FORCE_COLOR' in env$1) {
  6933. forceColor = env$1.FORCE_COLOR.length === 0 || parseInt(env$1.FORCE_COLOR, 10) !== 0;
  6934. }
  6935. function translateLevel(level) {
  6936. if (level === 0) {
  6937. return false;
  6938. }
  6939. return {
  6940. level: level,
  6941. hasBasic: true,
  6942. has256: level >= 2,
  6943. has16m: level >= 3
  6944. };
  6945. }
  6946. function supportsColor(stream) {
  6947. if (forceColor === false) {
  6948. return 0;
  6949. }
  6950. if (hasFlag('color=16m') || hasFlag('color=full') || hasFlag('color=truecolor')) {
  6951. return 3;
  6952. }
  6953. if (hasFlag('color=256')) {
  6954. return 2;
  6955. }
  6956. if (stream && !stream.isTTY && forceColor !== true) {
  6957. return 0;
  6958. }
  6959. var min = forceColor ? 1 : 0;
  6960. if (process.platform === 'win32') {
  6961. // Node.js 7.5.0 is the first version of Node.js to include a patch to
  6962. // libuv that enables 256 color output on Windows. Anything earlier and it
  6963. // won't work. However, here we target Node.js 8 at minimum as it is an LTS
  6964. // release, and Node.js 7 is not. Windows 10 build 10586 is the first Windows
  6965. // release that supports 256 colors. Windows 10 build 14931 is the first release
  6966. // that supports 16m/TrueColor.
  6967. var osRelease = require$$1$1.release().split('.');
  6968. if (Number(process.versions.node.split('.')[0]) >= 8 && Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
  6969. return Number(osRelease[2]) >= 14931 ? 3 : 2;
  6970. }
  6971. return 1;
  6972. }
  6973. if ('CI' in env$1) {
  6974. if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI'].some(function (sign) {
  6975. return sign in env$1;
  6976. }) || env$1.CI_NAME === 'codeship') {
  6977. return 1;
  6978. }
  6979. return min;
  6980. }
  6981. if ('TEAMCITY_VERSION' in env$1) {
  6982. return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env$1.TEAMCITY_VERSION) ? 1 : 0;
  6983. }
  6984. if (env$1.COLORTERM === 'truecolor') {
  6985. return 3;
  6986. }
  6987. if ('TERM_PROGRAM' in env$1) {
  6988. var version = parseInt((env$1.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
  6989. switch (env$1.TERM_PROGRAM) {
  6990. case 'iTerm.app':
  6991. return version >= 3 ? 3 : 2;
  6992. case 'Apple_Terminal':
  6993. return 2;
  6994. // No default
  6995. }
  6996. }
  6997. if (/-256(color)?$/i.test(env$1.TERM)) {
  6998. return 2;
  6999. }
  7000. if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env$1.TERM)) {
  7001. return 1;
  7002. }
  7003. if ('COLORTERM' in env$1) {
  7004. return 1;
  7005. }
  7006. if (env$1.TERM === 'dumb') {
  7007. return min;
  7008. }
  7009. return min;
  7010. }
  7011. function getSupportLevel(stream) {
  7012. var level = supportsColor(stream);
  7013. return translateLevel(level);
  7014. }
  7015. var supportsColor_1 = {
  7016. supportsColor: getSupportLevel,
  7017. stdout: getSupportLevel(process.stdout),
  7018. stderr: getSupportLevel(process.stderr)
  7019. };
  7020. var templates = createCommonjsModule(function (module) {
  7021. 'use strict';
  7022. var TEMPLATE_REGEX = /(?:\\(u[a-f\d]{4}|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi;
  7023. var STYLE_REGEX = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g;
  7024. var STRING_REGEX = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/;
  7025. var ESCAPE_REGEX = /\\(u[a-f\d]{4}|x[a-f\d]{2}|.)|([^\\])/gi;
  7026. var ESCAPES = new Map([['n', '\n'], ['r', '\r'], ['t', '\t'], ['b', '\b'], ['f', '\f'], ['v', '\v'], ['0', '\0'], ['\\', '\\'], ['e', "\x1B"], ['a', "\x07"]]);
  7027. function unescape(c) {
  7028. if (c[0] === 'u' && c.length === 5 || c[0] === 'x' && c.length === 3) {
  7029. return String.fromCharCode(parseInt(c.slice(1), 16));
  7030. }
  7031. return ESCAPES.get(c) || c;
  7032. }
  7033. function parseArguments(name, args) {
  7034. var results = [];
  7035. var chunks = args.trim().split(/\s*,\s*/g);
  7036. var matches;
  7037. var _iteratorNormalCompletion = true;
  7038. var _didIteratorError = false;
  7039. var _iteratorError = undefined;
  7040. try {
  7041. for (var _iterator = chunks[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  7042. var chunk = _step.value;
  7043. if (!isNaN(chunk)) {
  7044. results.push(Number(chunk));
  7045. } else if (matches = chunk.match(STRING_REGEX)) {
  7046. results.push(matches[2].replace(ESCAPE_REGEX, function (m, escape, chr) {
  7047. return escape ? unescape(escape) : chr;
  7048. }));
  7049. } else {
  7050. throw new Error("Invalid Chalk template style argument: ".concat(chunk, " (in style '").concat(name, "')"));
  7051. }
  7052. }
  7053. } catch (err) {
  7054. _didIteratorError = true;
  7055. _iteratorError = err;
  7056. } finally {
  7057. try {
  7058. if (!_iteratorNormalCompletion && _iterator.return != null) {
  7059. _iterator.return();
  7060. }
  7061. } finally {
  7062. if (_didIteratorError) {
  7063. throw _iteratorError;
  7064. }
  7065. }
  7066. }
  7067. return results;
  7068. }
  7069. function parseStyle(style) {
  7070. STYLE_REGEX.lastIndex = 0;
  7071. var results = [];
  7072. var matches;
  7073. while ((matches = STYLE_REGEX.exec(style)) !== null) {
  7074. var name = matches[1];
  7075. if (matches[2]) {
  7076. var args = parseArguments(name, matches[2]);
  7077. results.push([name].concat(args));
  7078. } else {
  7079. results.push([name]);
  7080. }
  7081. }
  7082. return results;
  7083. }
  7084. function buildStyle(chalk, styles) {
  7085. var enabled = {};
  7086. var _iteratorNormalCompletion2 = true;
  7087. var _didIteratorError2 = false;
  7088. var _iteratorError2 = undefined;
  7089. try {
  7090. for (var _iterator2 = styles[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
  7091. var layer = _step2.value;
  7092. var _iteratorNormalCompletion3 = true;
  7093. var _didIteratorError3 = false;
  7094. var _iteratorError3 = undefined;
  7095. try {
  7096. for (var _iterator3 = layer.styles[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
  7097. var style = _step3.value;
  7098. enabled[style[0]] = layer.inverse ? null : style.slice(1);
  7099. }
  7100. } catch (err) {
  7101. _didIteratorError3 = true;
  7102. _iteratorError3 = err;
  7103. } finally {
  7104. try {
  7105. if (!_iteratorNormalCompletion3 && _iterator3.return != null) {
  7106. _iterator3.return();
  7107. }
  7108. } finally {
  7109. if (_didIteratorError3) {
  7110. throw _iteratorError3;
  7111. }
  7112. }
  7113. }
  7114. }
  7115. } catch (err) {
  7116. _didIteratorError2 = true;
  7117. _iteratorError2 = err;
  7118. } finally {
  7119. try {
  7120. if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
  7121. _iterator2.return();
  7122. }
  7123. } finally {
  7124. if (_didIteratorError2) {
  7125. throw _iteratorError2;
  7126. }
  7127. }
  7128. }
  7129. var current = chalk;
  7130. var _arr = Object.keys(enabled);
  7131. for (var _i = 0; _i < _arr.length; _i++) {
  7132. var styleName = _arr[_i];
  7133. if (Array.isArray(enabled[styleName])) {
  7134. if (!(styleName in current)) {
  7135. throw new Error("Unknown Chalk style: ".concat(styleName));
  7136. }
  7137. if (enabled[styleName].length > 0) {
  7138. current = current[styleName].apply(current, enabled[styleName]);
  7139. } else {
  7140. current = current[styleName];
  7141. }
  7142. }
  7143. }
  7144. return current;
  7145. }
  7146. module.exports = function (chalk, tmp) {
  7147. var styles = [];
  7148. var chunks = [];
  7149. var chunk = []; // eslint-disable-next-line max-params
  7150. tmp.replace(TEMPLATE_REGEX, function (m, escapeChar, inverse, style, close, chr) {
  7151. if (escapeChar) {
  7152. chunk.push(unescape(escapeChar));
  7153. } else if (style) {
  7154. var str = chunk.join('');
  7155. chunk = [];
  7156. chunks.push(styles.length === 0 ? str : buildStyle(chalk, styles)(str));
  7157. styles.push({
  7158. inverse: inverse,
  7159. styles: parseStyle(style)
  7160. });
  7161. } else if (close) {
  7162. if (styles.length === 0) {
  7163. throw new Error('Found extraneous } in Chalk template literal');
  7164. }
  7165. chunks.push(buildStyle(chalk, styles)(chunk.join('')));
  7166. chunk = [];
  7167. styles.pop();
  7168. } else {
  7169. chunk.push(chr);
  7170. }
  7171. });
  7172. chunks.push(chunk.join(''));
  7173. if (styles.length > 0) {
  7174. var errMsg = "Chalk template literal is missing ".concat(styles.length, " closing bracket").concat(styles.length === 1 ? '' : 's', " (`}`)");
  7175. throw new Error(errMsg);
  7176. }
  7177. return chunks.join('');
  7178. };
  7179. });
  7180. var chalk = createCommonjsModule(function (module) {
  7181. 'use strict';
  7182. var stdoutColor = supportsColor_1.stdout;
  7183. var isSimpleWindowsTerm = process.platform === 'win32' && !(process.env.TERM || '').toLowerCase().startsWith('xterm'); // `supportsColor.level` → `ansiStyles.color[name]` mapping
  7184. var levelMapping = ['ansi', 'ansi', 'ansi256', 'ansi16m']; // `color-convert` models to exclude from the Chalk API due to conflicts and such
  7185. var skipModels = new Set(['gray']);
  7186. var styles = Object.create(null);
  7187. function applyOptions(obj, options) {
  7188. options = options || {}; // Detect level if not set manually
  7189. var scLevel = stdoutColor ? stdoutColor.level : 0;
  7190. obj.level = options.level === undefined ? scLevel : options.level;
  7191. obj.enabled = 'enabled' in options ? options.enabled : obj.level > 0;
  7192. }
  7193. function Chalk(options) {
  7194. // We check for this.template here since calling `chalk.constructor()`
  7195. // by itself will have a `this` of a previously constructed chalk object
  7196. if (!this || !(this instanceof Chalk) || this.template) {
  7197. var _chalk = {};
  7198. applyOptions(_chalk, options);
  7199. _chalk.template = function () {
  7200. var args = [].slice.call(arguments);
  7201. return chalkTag.apply(null, [_chalk.template].concat(args));
  7202. };
  7203. Object.setPrototypeOf(_chalk, Chalk.prototype);
  7204. Object.setPrototypeOf(_chalk.template, _chalk);
  7205. _chalk.template.constructor = Chalk;
  7206. return _chalk.template;
  7207. }
  7208. applyOptions(this, options);
  7209. } // Use bright blue on Windows as the normal blue color is illegible
  7210. if (isSimpleWindowsTerm) {
  7211. ansiStyles.blue.open = "\x1B[94m";
  7212. }
  7213. var _arr = Object.keys(ansiStyles);
  7214. var _loop = function _loop() {
  7215. var key = _arr[_i];
  7216. ansiStyles[key].closeRe = new RegExp(escapeStringRegexp(ansiStyles[key].close), 'g');
  7217. styles[key] = {
  7218. get: function get() {
  7219. var codes = ansiStyles[key];
  7220. return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, key);
  7221. }
  7222. };
  7223. };
  7224. for (var _i = 0; _i < _arr.length; _i++) {
  7225. _loop();
  7226. }
  7227. styles.visible = {
  7228. get: function get() {
  7229. return build.call(this, this._styles || [], true, 'visible');
  7230. }
  7231. };
  7232. ansiStyles.color.closeRe = new RegExp(escapeStringRegexp(ansiStyles.color.close), 'g');
  7233. var _arr2 = Object.keys(ansiStyles.color.ansi);
  7234. var _loop2 = function _loop2() {
  7235. var model = _arr2[_i2];
  7236. if (skipModels.has(model)) {
  7237. return "continue";
  7238. }
  7239. styles[model] = {
  7240. get: function get() {
  7241. var level = this.level;
  7242. return function () {
  7243. var open = ansiStyles.color[levelMapping[level]][model].apply(null, arguments);
  7244. var codes = {
  7245. open: open,
  7246. close: ansiStyles.color.close,
  7247. closeRe: ansiStyles.color.closeRe
  7248. };
  7249. return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, model);
  7250. };
  7251. }
  7252. };
  7253. };
  7254. for (var _i2 = 0; _i2 < _arr2.length; _i2++) {
  7255. var _ret = _loop2();
  7256. if (_ret === "continue") continue;
  7257. }
  7258. ansiStyles.bgColor.closeRe = new RegExp(escapeStringRegexp(ansiStyles.bgColor.close), 'g');
  7259. var _arr3 = Object.keys(ansiStyles.bgColor.ansi);
  7260. var _loop3 = function _loop3() {
  7261. var model = _arr3[_i3];
  7262. if (skipModels.has(model)) {
  7263. return "continue";
  7264. }
  7265. var bgModel = 'bg' + model[0].toUpperCase() + model.slice(1);
  7266. styles[bgModel] = {
  7267. get: function get() {
  7268. var level = this.level;
  7269. return function () {
  7270. var open = ansiStyles.bgColor[levelMapping[level]][model].apply(null, arguments);
  7271. var codes = {
  7272. open: open,
  7273. close: ansiStyles.bgColor.close,
  7274. closeRe: ansiStyles.bgColor.closeRe
  7275. };
  7276. return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, model);
  7277. };
  7278. }
  7279. };
  7280. };
  7281. for (var _i3 = 0; _i3 < _arr3.length; _i3++) {
  7282. var _ret2 = _loop3();
  7283. if (_ret2 === "continue") continue;
  7284. }
  7285. var proto = Object.defineProperties(function () {}, styles);
  7286. function build(_styles, _empty, key) {
  7287. var builder = function builder() {
  7288. return applyStyle.apply(builder, arguments);
  7289. };
  7290. builder._styles = _styles;
  7291. builder._empty = _empty;
  7292. var self = this;
  7293. Object.defineProperty(builder, 'level', {
  7294. enumerable: true,
  7295. get: function get() {
  7296. return self.level;
  7297. },
  7298. set: function set(level) {
  7299. self.level = level;
  7300. }
  7301. });
  7302. Object.defineProperty(builder, 'enabled', {
  7303. enumerable: true,
  7304. get: function get() {
  7305. return self.enabled;
  7306. },
  7307. set: function set(enabled) {
  7308. self.enabled = enabled;
  7309. }
  7310. }); // See below for fix regarding invisible grey/dim combination on Windows
  7311. builder.hasGrey = this.hasGrey || key === 'gray' || key === 'grey'; // `__proto__` is used because we must return a function, but there is
  7312. // no way to create a function with a different prototype
  7313. builder.__proto__ = proto; // eslint-disable-line no-proto
  7314. return builder;
  7315. }
  7316. function applyStyle() {
  7317. // Support varags, but simply cast to string in case there's only one arg
  7318. var args = arguments;
  7319. var argsLen = args.length;
  7320. var str = String(arguments[0]);
  7321. if (argsLen === 0) {
  7322. return '';
  7323. }
  7324. if (argsLen > 1) {
  7325. // Don't slice `arguments`, it prevents V8 optimizations
  7326. for (var a = 1; a < argsLen; a++) {
  7327. str += ' ' + args[a];
  7328. }
  7329. }
  7330. if (!this.enabled || this.level <= 0 || !str) {
  7331. return this._empty ? '' : str;
  7332. } // Turns out that on Windows dimmed gray text becomes invisible in cmd.exe,
  7333. // see https://github.com/chalk/chalk/issues/58
  7334. // If we're on Windows and we're dealing with a gray color, temporarily make 'dim' a noop.
  7335. var originalDim = ansiStyles.dim.open;
  7336. if (isSimpleWindowsTerm && this.hasGrey) {
  7337. ansiStyles.dim.open = '';
  7338. }
  7339. var _iteratorNormalCompletion = true;
  7340. var _didIteratorError = false;
  7341. var _iteratorError = undefined;
  7342. try {
  7343. for (var _iterator = this._styles.slice().reverse()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  7344. var code = _step.value;
  7345. // Replace any instances already present with a re-opening code
  7346. // otherwise only the part of the string until said closing code
  7347. // will be colored, and the rest will simply be 'plain'.
  7348. str = code.open + str.replace(code.closeRe, code.open) + code.close; // Close the styling before a linebreak and reopen
  7349. // after next line to fix a bleed issue on macOS
  7350. // https://github.com/chalk/chalk/pull/92
  7351. str = str.replace(/\r?\n/g, "".concat(code.close, "$&").concat(code.open));
  7352. } // Reset the original `dim` if we changed it to work around the Windows dimmed gray issue
  7353. } catch (err) {
  7354. _didIteratorError = true;
  7355. _iteratorError = err;
  7356. } finally {
  7357. try {
  7358. if (!_iteratorNormalCompletion && _iterator.return != null) {
  7359. _iterator.return();
  7360. }
  7361. } finally {
  7362. if (_didIteratorError) {
  7363. throw _iteratorError;
  7364. }
  7365. }
  7366. }
  7367. ansiStyles.dim.open = originalDim;
  7368. return str;
  7369. }
  7370. function chalkTag(chalk, strings) {
  7371. if (!Array.isArray(strings)) {
  7372. // If chalk() was called by itself or with a string,
  7373. // return the string itself as a string.
  7374. return [].slice.call(arguments, 1).join(' ');
  7375. }
  7376. var args = [].slice.call(arguments, 2);
  7377. var parts = [strings.raw[0]];
  7378. for (var i = 1; i < strings.length; i++) {
  7379. parts.push(String(args[i - 1]).replace(/[{}\\]/g, '\\$&'));
  7380. parts.push(String(strings.raw[i]));
  7381. }
  7382. return templates(chalk, parts.join(''));
  7383. }
  7384. Object.defineProperties(Chalk.prototype, styles);
  7385. module.exports = Chalk(); // eslint-disable-line new-cap
  7386. module.exports.supportsColor = stdoutColor;
  7387. module.exports.default = module.exports; // For TypeScript
  7388. });
  7389. var common = createCommonjsModule(function (module, exports) {
  7390. "use strict";
  7391. Object.defineProperty(exports, "__esModule", {
  7392. value: true
  7393. });
  7394. exports.commonDeprecatedHandler = function (keyOrPair, redirectTo, _ref) {
  7395. var descriptor = _ref.descriptor;
  7396. var messages = ["".concat(chalk.default.yellow(typeof keyOrPair === 'string' ? descriptor.key(keyOrPair) : descriptor.pair(keyOrPair)), " is deprecated")];
  7397. if (redirectTo) {
  7398. messages.push("we now treat it as ".concat(chalk.default.blue(typeof redirectTo === 'string' ? descriptor.key(redirectTo) : descriptor.pair(redirectTo))));
  7399. }
  7400. return messages.join('; ') + '.';
  7401. };
  7402. });
  7403. unwrapExports(common);
  7404. var deprecated = createCommonjsModule(function (module, exports) {
  7405. "use strict";
  7406. Object.defineProperty(exports, "__esModule", {
  7407. value: true
  7408. });
  7409. tslib_1.__exportStar(common, exports);
  7410. });
  7411. unwrapExports(deprecated);
  7412. var common$2 = createCommonjsModule(function (module, exports) {
  7413. "use strict";
  7414. Object.defineProperty(exports, "__esModule", {
  7415. value: true
  7416. });
  7417. exports.commonInvalidHandler = function (key, value, utils) {
  7418. 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(' ');
  7419. };
  7420. });
  7421. unwrapExports(common$2);
  7422. var invalid = createCommonjsModule(function (module, exports) {
  7423. "use strict";
  7424. Object.defineProperty(exports, "__esModule", {
  7425. value: true
  7426. });
  7427. tslib_1.__exportStar(common$2, exports);
  7428. });
  7429. unwrapExports(invalid);
  7430. /* eslint-disable no-nested-ternary */
  7431. var arr = [];
  7432. var charCodeCache = [];
  7433. var leven$1 = function leven(a, b) {
  7434. if (a === b) {
  7435. return 0;
  7436. }
  7437. var swap = a; // Swapping the strings if `a` is longer than `b` so we know which one is the
  7438. // shortest & which one is the longest
  7439. if (a.length > b.length) {
  7440. a = b;
  7441. b = swap;
  7442. }
  7443. var aLen = a.length;
  7444. var bLen = b.length;
  7445. if (aLen === 0) {
  7446. return bLen;
  7447. }
  7448. if (bLen === 0) {
  7449. return aLen;
  7450. } // Performing suffix trimming:
  7451. // We can linearly drop suffix common to both strings since they
  7452. // don't increase distance at all
  7453. // Note: `~-` is the bitwise way to perform a `- 1` operation
  7454. while (aLen > 0 && a.charCodeAt(~-aLen) === b.charCodeAt(~-bLen)) {
  7455. aLen--;
  7456. bLen--;
  7457. }
  7458. if (aLen === 0) {
  7459. return bLen;
  7460. } // Performing prefix trimming
  7461. // We can linearly drop prefix common to both strings since they
  7462. // don't increase distance at all
  7463. var start = 0;
  7464. while (start < aLen && a.charCodeAt(start) === b.charCodeAt(start)) {
  7465. start++;
  7466. }
  7467. aLen -= start;
  7468. bLen -= start;
  7469. if (aLen === 0) {
  7470. return bLen;
  7471. }
  7472. var bCharCode;
  7473. var ret;
  7474. var tmp;
  7475. var tmp2;
  7476. var i = 0;
  7477. var j = 0;
  7478. while (i < aLen) {
  7479. charCodeCache[start + i] = a.charCodeAt(start + i);
  7480. arr[i] = ++i;
  7481. }
  7482. while (j < bLen) {
  7483. bCharCode = b.charCodeAt(start + j);
  7484. tmp = j++;
  7485. ret = j;
  7486. for (i = 0; i < aLen; i++) {
  7487. tmp2 = bCharCode === charCodeCache[start + i] ? tmp : tmp + 1;
  7488. tmp = arr[i];
  7489. ret = arr[i] = tmp > ret ? tmp2 > ret ? ret + 1 : tmp2 : tmp2 > tmp ? tmp + 1 : tmp2;
  7490. }
  7491. }
  7492. return ret;
  7493. };
  7494. var leven_1 = createCommonjsModule(function (module, exports) {
  7495. "use strict";
  7496. Object.defineProperty(exports, "__esModule", {
  7497. value: true
  7498. });
  7499. exports.levenUnknownHandler = function (key, value, _ref) {
  7500. var descriptor = _ref.descriptor,
  7501. logger = _ref.logger,
  7502. schemas = _ref.schemas;
  7503. var messages = ["Ignored unknown option ".concat(chalk.default.yellow(descriptor.pair({
  7504. key: key,
  7505. value: value
  7506. })), ".")];
  7507. var suggestion = Object.keys(schemas).sort().find(function (knownKey) {
  7508. return leven$1(key, knownKey) < 3;
  7509. });
  7510. if (suggestion) {
  7511. messages.push("Did you mean ".concat(chalk.default.blue(descriptor.key(suggestion)), "?"));
  7512. }
  7513. logger.warn(messages.join(' '));
  7514. };
  7515. });
  7516. unwrapExports(leven_1);
  7517. var unknown = createCommonjsModule(function (module, exports) {
  7518. "use strict";
  7519. Object.defineProperty(exports, "__esModule", {
  7520. value: true
  7521. });
  7522. tslib_1.__exportStar(leven_1, exports);
  7523. });
  7524. unwrapExports(unknown);
  7525. var handlers = createCommonjsModule(function (module, exports) {
  7526. "use strict";
  7527. Object.defineProperty(exports, "__esModule", {
  7528. value: true
  7529. });
  7530. tslib_1.__exportStar(deprecated, exports);
  7531. tslib_1.__exportStar(invalid, exports);
  7532. tslib_1.__exportStar(unknown, exports);
  7533. });
  7534. unwrapExports(handlers);
  7535. var schema = createCommonjsModule(function (module, exports) {
  7536. "use strict";
  7537. Object.defineProperty(exports, "__esModule", {
  7538. value: true
  7539. });
  7540. var HANDLER_KEYS = ['default', 'expected', 'validate', 'deprecated', 'forward', 'redirect', 'overlap', 'preprocess', 'postprocess'];
  7541. function createSchema(SchemaConstructor, parameters) {
  7542. var schema = new SchemaConstructor(parameters);
  7543. var subSchema = Object.create(schema);
  7544. for (var _i = 0; _i < HANDLER_KEYS.length; _i++) {
  7545. var handlerKey = HANDLER_KEYS[_i];
  7546. if (handlerKey in parameters) {
  7547. subSchema[handlerKey] = normalizeHandler(parameters[handlerKey], schema, Schema.prototype[handlerKey].length);
  7548. }
  7549. }
  7550. return subSchema;
  7551. }
  7552. exports.createSchema = createSchema;
  7553. var Schema =
  7554. /*#__PURE__*/
  7555. function () {
  7556. function Schema(parameters) {
  7557. _classCallCheck(this, Schema);
  7558. this.name = parameters.name;
  7559. }
  7560. _createClass(Schema, [{
  7561. key: "default",
  7562. value: function _default(_utils) {
  7563. return undefined;
  7564. } // istanbul ignore next: this is actually an abstract method but we need a placeholder to get `function.length`
  7565. }, {
  7566. key: "expected",
  7567. value: function expected(_utils) {
  7568. return 'nothing';
  7569. } // istanbul ignore next: this is actually an abstract method but we need a placeholder to get `function.length`
  7570. }, {
  7571. key: "validate",
  7572. value: function validate(_value, _utils) {
  7573. return false;
  7574. }
  7575. }, {
  7576. key: "deprecated",
  7577. value: function deprecated(_value, _utils) {
  7578. return false;
  7579. }
  7580. }, {
  7581. key: "forward",
  7582. value: function forward(_value, _utils) {
  7583. return undefined;
  7584. }
  7585. }, {
  7586. key: "redirect",
  7587. value: function redirect(_value, _utils) {
  7588. return undefined;
  7589. }
  7590. }, {
  7591. key: "overlap",
  7592. value: function overlap(currentValue, _newValue, _utils) {
  7593. return currentValue;
  7594. }
  7595. }, {
  7596. key: "preprocess",
  7597. value: function preprocess(value, _utils) {
  7598. return value;
  7599. }
  7600. }, {
  7601. key: "postprocess",
  7602. value: function postprocess(value, _utils) {
  7603. return value;
  7604. }
  7605. }], [{
  7606. key: "create",
  7607. value: function create(parameters) {
  7608. // @ts-ignore: https://github.com/Microsoft/TypeScript/issues/5863
  7609. return createSchema(this, parameters);
  7610. }
  7611. }]);
  7612. return Schema;
  7613. }();
  7614. exports.Schema = Schema;
  7615. function normalizeHandler(handler, superSchema, handlerArgumentsLength) {
  7616. return typeof handler === 'function' ? function () {
  7617. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  7618. args[_key] = arguments[_key];
  7619. }
  7620. return handler.apply(void 0, _toConsumableArray(args.slice(0, handlerArgumentsLength - 1)).concat([superSchema], _toConsumableArray(args.slice(handlerArgumentsLength - 1))));
  7621. } : function () {
  7622. return handler;
  7623. };
  7624. }
  7625. });
  7626. unwrapExports(schema);
  7627. var alias = createCommonjsModule(function (module, exports) {
  7628. "use strict";
  7629. Object.defineProperty(exports, "__esModule", {
  7630. value: true
  7631. });
  7632. var AliasSchema =
  7633. /*#__PURE__*/
  7634. function (_schema_1$Schema) {
  7635. _inherits(AliasSchema, _schema_1$Schema);
  7636. function AliasSchema(parameters) {
  7637. var _this;
  7638. _classCallCheck(this, AliasSchema);
  7639. _this = _possibleConstructorReturn(this, _getPrototypeOf(AliasSchema).call(this, parameters));
  7640. _this._sourceName = parameters.sourceName;
  7641. return _this;
  7642. }
  7643. _createClass(AliasSchema, [{
  7644. key: "expected",
  7645. value: function expected(utils) {
  7646. return utils.schemas[this._sourceName].expected(utils);
  7647. }
  7648. }, {
  7649. key: "validate",
  7650. value: function validate(value, utils) {
  7651. return utils.schemas[this._sourceName].validate(value, utils);
  7652. }
  7653. }, {
  7654. key: "redirect",
  7655. value: function redirect(_value, _utils) {
  7656. return this._sourceName;
  7657. }
  7658. }]);
  7659. return AliasSchema;
  7660. }(schema.Schema);
  7661. exports.AliasSchema = AliasSchema;
  7662. });
  7663. unwrapExports(alias);
  7664. var any = createCommonjsModule(function (module, exports) {
  7665. "use strict";
  7666. Object.defineProperty(exports, "__esModule", {
  7667. value: true
  7668. });
  7669. var AnySchema =
  7670. /*#__PURE__*/
  7671. function (_schema_1$Schema) {
  7672. _inherits(AnySchema, _schema_1$Schema);
  7673. function AnySchema() {
  7674. _classCallCheck(this, AnySchema);
  7675. return _possibleConstructorReturn(this, _getPrototypeOf(AnySchema).apply(this, arguments));
  7676. }
  7677. _createClass(AnySchema, [{
  7678. key: "expected",
  7679. value: function expected() {
  7680. return 'anything';
  7681. }
  7682. }, {
  7683. key: "validate",
  7684. value: function validate() {
  7685. return true;
  7686. }
  7687. }]);
  7688. return AnySchema;
  7689. }(schema.Schema);
  7690. exports.AnySchema = AnySchema;
  7691. });
  7692. unwrapExports(any);
  7693. var array$2 = createCommonjsModule(function (module, exports) {
  7694. "use strict";
  7695. Object.defineProperty(exports, "__esModule", {
  7696. value: true
  7697. });
  7698. var ArraySchema =
  7699. /*#__PURE__*/
  7700. function (_schema_1$Schema) {
  7701. _inherits(ArraySchema, _schema_1$Schema);
  7702. function ArraySchema(_a) {
  7703. var _this;
  7704. _classCallCheck(this, ArraySchema);
  7705. var valueSchema = _a.valueSchema,
  7706. _a$name = _a.name,
  7707. name = _a$name === void 0 ? valueSchema.name : _a$name,
  7708. handlers = tslib_1.__rest(_a, ["valueSchema", "name"]);
  7709. _this = _possibleConstructorReturn(this, _getPrototypeOf(ArraySchema).call(this, Object.assign({}, handlers, {
  7710. name: name
  7711. })));
  7712. _this._valueSchema = valueSchema;
  7713. return _this;
  7714. }
  7715. _createClass(ArraySchema, [{
  7716. key: "expected",
  7717. value: function expected(utils) {
  7718. return "an array of ".concat(this._valueSchema.expected(utils));
  7719. }
  7720. }, {
  7721. key: "validate",
  7722. value: function validate(value, utils) {
  7723. if (!Array.isArray(value)) {
  7724. return false;
  7725. }
  7726. var invalidValues = [];
  7727. var _iteratorNormalCompletion = true;
  7728. var _didIteratorError = false;
  7729. var _iteratorError = undefined;
  7730. try {
  7731. for (var _iterator = value[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  7732. var subValue = _step.value;
  7733. var subValidateResult = utils.normalizeValidateResult(this._valueSchema.validate(subValue, utils), subValue);
  7734. if (subValidateResult !== true) {
  7735. invalidValues.push(subValidateResult.value);
  7736. }
  7737. }
  7738. } catch (err) {
  7739. _didIteratorError = true;
  7740. _iteratorError = err;
  7741. } finally {
  7742. try {
  7743. if (!_iteratorNormalCompletion && _iterator.return != null) {
  7744. _iterator.return();
  7745. }
  7746. } finally {
  7747. if (_didIteratorError) {
  7748. throw _iteratorError;
  7749. }
  7750. }
  7751. }
  7752. return invalidValues.length === 0 ? true : {
  7753. value: invalidValues
  7754. };
  7755. }
  7756. }, {
  7757. key: "deprecated",
  7758. value: function deprecated(value, utils) {
  7759. var deprecatedResult = [];
  7760. var _iteratorNormalCompletion2 = true;
  7761. var _didIteratorError2 = false;
  7762. var _iteratorError2 = undefined;
  7763. try {
  7764. for (var _iterator2 = value[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
  7765. var subValue = _step2.value;
  7766. var subDeprecatedResult = utils.normalizeDeprecatedResult(this._valueSchema.deprecated(subValue, utils), subValue);
  7767. if (subDeprecatedResult !== false) {
  7768. deprecatedResult.push.apply(deprecatedResult, _toConsumableArray(subDeprecatedResult.map(function (_ref) {
  7769. var deprecatedValue = _ref.value;
  7770. return {
  7771. value: [deprecatedValue]
  7772. };
  7773. })));
  7774. }
  7775. }
  7776. } catch (err) {
  7777. _didIteratorError2 = true;
  7778. _iteratorError2 = err;
  7779. } finally {
  7780. try {
  7781. if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
  7782. _iterator2.return();
  7783. }
  7784. } finally {
  7785. if (_didIteratorError2) {
  7786. throw _iteratorError2;
  7787. }
  7788. }
  7789. }
  7790. return deprecatedResult;
  7791. }
  7792. }, {
  7793. key: "forward",
  7794. value: function forward(value, utils) {
  7795. var forwardResult = [];
  7796. var _iteratorNormalCompletion3 = true;
  7797. var _didIteratorError3 = false;
  7798. var _iteratorError3 = undefined;
  7799. try {
  7800. for (var _iterator3 = value[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
  7801. var subValue = _step3.value;
  7802. var subForwardResult = utils.normalizeForwardResult(this._valueSchema.forward(subValue, utils), subValue);
  7803. forwardResult.push.apply(forwardResult, _toConsumableArray(subForwardResult.map(wrapTransferResult)));
  7804. }
  7805. } catch (err) {
  7806. _didIteratorError3 = true;
  7807. _iteratorError3 = err;
  7808. } finally {
  7809. try {
  7810. if (!_iteratorNormalCompletion3 && _iterator3.return != null) {
  7811. _iterator3.return();
  7812. }
  7813. } finally {
  7814. if (_didIteratorError3) {
  7815. throw _iteratorError3;
  7816. }
  7817. }
  7818. }
  7819. return forwardResult;
  7820. }
  7821. }, {
  7822. key: "redirect",
  7823. value: function redirect(value, utils) {
  7824. var remain = [];
  7825. var redirect = [];
  7826. var _iteratorNormalCompletion4 = true;
  7827. var _didIteratorError4 = false;
  7828. var _iteratorError4 = undefined;
  7829. try {
  7830. for (var _iterator4 = value[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {
  7831. var subValue = _step4.value;
  7832. var subRedirectResult = utils.normalizeRedirectResult(this._valueSchema.redirect(subValue, utils), subValue);
  7833. if ('remain' in subRedirectResult) {
  7834. remain.push(subRedirectResult.remain);
  7835. }
  7836. redirect.push.apply(redirect, _toConsumableArray(subRedirectResult.redirect.map(wrapTransferResult)));
  7837. }
  7838. } catch (err) {
  7839. _didIteratorError4 = true;
  7840. _iteratorError4 = err;
  7841. } finally {
  7842. try {
  7843. if (!_iteratorNormalCompletion4 && _iterator4.return != null) {
  7844. _iterator4.return();
  7845. }
  7846. } finally {
  7847. if (_didIteratorError4) {
  7848. throw _iteratorError4;
  7849. }
  7850. }
  7851. }
  7852. return remain.length === 0 ? {
  7853. redirect: redirect
  7854. } : {
  7855. redirect: redirect,
  7856. remain: remain
  7857. };
  7858. }
  7859. }, {
  7860. key: "overlap",
  7861. value: function overlap(currentValue, newValue) {
  7862. return currentValue.concat(newValue);
  7863. }
  7864. }]);
  7865. return ArraySchema;
  7866. }(schema.Schema);
  7867. exports.ArraySchema = ArraySchema;
  7868. function wrapTransferResult(_ref2) {
  7869. var from = _ref2.from,
  7870. to = _ref2.to;
  7871. return {
  7872. from: [from],
  7873. to: to
  7874. };
  7875. }
  7876. });
  7877. unwrapExports(array$2);
  7878. var boolean_1 = createCommonjsModule(function (module, exports) {
  7879. "use strict";
  7880. Object.defineProperty(exports, "__esModule", {
  7881. value: true
  7882. });
  7883. var BooleanSchema =
  7884. /*#__PURE__*/
  7885. function (_schema_1$Schema) {
  7886. _inherits(BooleanSchema, _schema_1$Schema);
  7887. function BooleanSchema() {
  7888. _classCallCheck(this, BooleanSchema);
  7889. return _possibleConstructorReturn(this, _getPrototypeOf(BooleanSchema).apply(this, arguments));
  7890. }
  7891. _createClass(BooleanSchema, [{
  7892. key: "expected",
  7893. value: function expected() {
  7894. return 'true or false';
  7895. }
  7896. }, {
  7897. key: "validate",
  7898. value: function validate(value) {
  7899. return typeof value === 'boolean';
  7900. }
  7901. }]);
  7902. return BooleanSchema;
  7903. }(schema.Schema);
  7904. exports.BooleanSchema = BooleanSchema;
  7905. });
  7906. unwrapExports(boolean_1);
  7907. var utils = createCommonjsModule(function (module, exports) {
  7908. "use strict";
  7909. Object.defineProperty(exports, "__esModule", {
  7910. value: true
  7911. });
  7912. function recordFromArray(array, mainKey) {
  7913. var record = Object.create(null);
  7914. var _iteratorNormalCompletion = true;
  7915. var _didIteratorError = false;
  7916. var _iteratorError = undefined;
  7917. try {
  7918. for (var _iterator = array[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  7919. var value = _step.value;
  7920. var key = value[mainKey]; // istanbul ignore next
  7921. if (record[key]) {
  7922. throw new Error("Duplicate ".concat(mainKey, " ").concat(JSON.stringify(key)));
  7923. } // @ts-ignore
  7924. record[key] = value;
  7925. }
  7926. } catch (err) {
  7927. _didIteratorError = true;
  7928. _iteratorError = err;
  7929. } finally {
  7930. try {
  7931. if (!_iteratorNormalCompletion && _iterator.return != null) {
  7932. _iterator.return();
  7933. }
  7934. } finally {
  7935. if (_didIteratorError) {
  7936. throw _iteratorError;
  7937. }
  7938. }
  7939. }
  7940. return record;
  7941. }
  7942. exports.recordFromArray = recordFromArray;
  7943. function mapFromArray(array, mainKey) {
  7944. var map = new Map();
  7945. var _iteratorNormalCompletion2 = true;
  7946. var _didIteratorError2 = false;
  7947. var _iteratorError2 = undefined;
  7948. try {
  7949. for (var _iterator2 = array[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
  7950. var value = _step2.value;
  7951. var key = value[mainKey]; // istanbul ignore next
  7952. if (map.has(key)) {
  7953. throw new Error("Duplicate ".concat(mainKey, " ").concat(JSON.stringify(key)));
  7954. }
  7955. map.set(key, value);
  7956. }
  7957. } catch (err) {
  7958. _didIteratorError2 = true;
  7959. _iteratorError2 = err;
  7960. } finally {
  7961. try {
  7962. if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
  7963. _iterator2.return();
  7964. }
  7965. } finally {
  7966. if (_didIteratorError2) {
  7967. throw _iteratorError2;
  7968. }
  7969. }
  7970. }
  7971. return map;
  7972. }
  7973. exports.mapFromArray = mapFromArray;
  7974. function createAutoChecklist() {
  7975. var map = Object.create(null);
  7976. return function (id) {
  7977. var idString = JSON.stringify(id);
  7978. if (map[idString]) {
  7979. return true;
  7980. }
  7981. map[idString] = true;
  7982. return false;
  7983. };
  7984. }
  7985. exports.createAutoChecklist = createAutoChecklist;
  7986. function partition(array, predicate) {
  7987. var trueArray = [];
  7988. var falseArray = [];
  7989. var _iteratorNormalCompletion3 = true;
  7990. var _didIteratorError3 = false;
  7991. var _iteratorError3 = undefined;
  7992. try {
  7993. for (var _iterator3 = array[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
  7994. var value = _step3.value;
  7995. if (predicate(value)) {
  7996. trueArray.push(value);
  7997. } else {
  7998. falseArray.push(value);
  7999. }
  8000. }
  8001. } catch (err) {
  8002. _didIteratorError3 = true;
  8003. _iteratorError3 = err;
  8004. } finally {
  8005. try {
  8006. if (!_iteratorNormalCompletion3 && _iterator3.return != null) {
  8007. _iterator3.return();
  8008. }
  8009. } finally {
  8010. if (_didIteratorError3) {
  8011. throw _iteratorError3;
  8012. }
  8013. }
  8014. }
  8015. return [trueArray, falseArray];
  8016. }
  8017. exports.partition = partition;
  8018. function isInt(value) {
  8019. return value === Math.floor(value);
  8020. }
  8021. exports.isInt = isInt;
  8022. function comparePrimitive(a, b) {
  8023. if (a === b) {
  8024. return 0;
  8025. }
  8026. var typeofA = _typeof(a);
  8027. var typeofB = _typeof(b);
  8028. var orders = ['undefined', 'object', 'boolean', 'number', 'string'];
  8029. if (typeofA !== typeofB) {
  8030. return orders.indexOf(typeofA) - orders.indexOf(typeofB);
  8031. }
  8032. if (typeofA !== 'string') {
  8033. return Number(a) - Number(b);
  8034. }
  8035. return a.localeCompare(b);
  8036. }
  8037. exports.comparePrimitive = comparePrimitive;
  8038. function normalizeDefaultResult(result) {
  8039. return result === undefined ? {} : result;
  8040. }
  8041. exports.normalizeDefaultResult = normalizeDefaultResult;
  8042. function normalizeValidateResult(result, value) {
  8043. return result === true ? true : result === false ? {
  8044. value: value
  8045. } : result;
  8046. }
  8047. exports.normalizeValidateResult = normalizeValidateResult;
  8048. function normalizeDeprecatedResult(result, value) {
  8049. var doNotNormalizeTrue = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  8050. return result === false ? false : result === true ? doNotNormalizeTrue ? true : [{
  8051. value: value
  8052. }] : 'value' in result ? [result] : result.length === 0 ? false : result;
  8053. }
  8054. exports.normalizeDeprecatedResult = normalizeDeprecatedResult;
  8055. function normalizeTransferResult(result, value) {
  8056. return typeof result === 'string' || 'key' in result ? {
  8057. from: value,
  8058. to: result
  8059. } : 'from' in result ? {
  8060. from: result.from,
  8061. to: result.to
  8062. } : {
  8063. from: value,
  8064. to: result.to
  8065. };
  8066. }
  8067. exports.normalizeTransferResult = normalizeTransferResult;
  8068. function normalizeForwardResult(result, value) {
  8069. return result === undefined ? [] : Array.isArray(result) ? result.map(function (transferResult) {
  8070. return normalizeTransferResult(transferResult, value);
  8071. }) : [normalizeTransferResult(result, value)];
  8072. }
  8073. exports.normalizeForwardResult = normalizeForwardResult;
  8074. function normalizeRedirectResult(result, value) {
  8075. var redirect = normalizeForwardResult(_typeof(result) === 'object' && 'redirect' in result ? result.redirect : result, value);
  8076. return redirect.length === 0 ? {
  8077. remain: value,
  8078. redirect: redirect
  8079. } : _typeof(result) === 'object' && 'remain' in result ? {
  8080. remain: result.remain,
  8081. redirect: redirect
  8082. } : {
  8083. redirect: redirect
  8084. };
  8085. }
  8086. exports.normalizeRedirectResult = normalizeRedirectResult;
  8087. });
  8088. unwrapExports(utils);
  8089. var choice = createCommonjsModule(function (module, exports) {
  8090. "use strict";
  8091. Object.defineProperty(exports, "__esModule", {
  8092. value: true
  8093. });
  8094. var ChoiceSchema =
  8095. /*#__PURE__*/
  8096. function (_schema_1$Schema) {
  8097. _inherits(ChoiceSchema, _schema_1$Schema);
  8098. function ChoiceSchema(parameters) {
  8099. var _this;
  8100. _classCallCheck(this, ChoiceSchema);
  8101. _this = _possibleConstructorReturn(this, _getPrototypeOf(ChoiceSchema).call(this, parameters));
  8102. _this._choices = utils.mapFromArray(parameters.choices.map(function (choice) {
  8103. return choice && _typeof(choice) === 'object' ? choice : {
  8104. value: choice
  8105. };
  8106. }), 'value');
  8107. return _this;
  8108. }
  8109. _createClass(ChoiceSchema, [{
  8110. key: "expected",
  8111. value: function expected(_ref) {
  8112. var _this2 = this;
  8113. var descriptor = _ref.descriptor;
  8114. var choiceValues = Array.from(this._choices.keys()).map(function (value) {
  8115. return _this2._choices.get(value);
  8116. }).filter(function (choiceInfo) {
  8117. return !choiceInfo.deprecated;
  8118. }).map(function (choiceInfo) {
  8119. return choiceInfo.value;
  8120. }).sort(utils.comparePrimitive).map(descriptor.value);
  8121. var head = choiceValues.slice(0, -2);
  8122. var tail = choiceValues.slice(-2);
  8123. return head.concat(tail.join(' or ')).join(', ');
  8124. }
  8125. }, {
  8126. key: "validate",
  8127. value: function validate(value) {
  8128. return this._choices.has(value);
  8129. }
  8130. }, {
  8131. key: "deprecated",
  8132. value: function deprecated(value) {
  8133. var choiceInfo = this._choices.get(value);
  8134. return choiceInfo && choiceInfo.deprecated ? {
  8135. value: value
  8136. } : false;
  8137. }
  8138. }, {
  8139. key: "forward",
  8140. value: function forward(value) {
  8141. var choiceInfo = this._choices.get(value);
  8142. return choiceInfo ? choiceInfo.forward : undefined;
  8143. }
  8144. }, {
  8145. key: "redirect",
  8146. value: function redirect(value) {
  8147. var choiceInfo = this._choices.get(value);
  8148. return choiceInfo ? choiceInfo.redirect : undefined;
  8149. }
  8150. }]);
  8151. return ChoiceSchema;
  8152. }(schema.Schema);
  8153. exports.ChoiceSchema = ChoiceSchema;
  8154. });
  8155. unwrapExports(choice);
  8156. var number = createCommonjsModule(function (module, exports) {
  8157. "use strict";
  8158. Object.defineProperty(exports, "__esModule", {
  8159. value: true
  8160. });
  8161. var NumberSchema =
  8162. /*#__PURE__*/
  8163. function (_schema_1$Schema) {
  8164. _inherits(NumberSchema, _schema_1$Schema);
  8165. function NumberSchema() {
  8166. _classCallCheck(this, NumberSchema);
  8167. return _possibleConstructorReturn(this, _getPrototypeOf(NumberSchema).apply(this, arguments));
  8168. }
  8169. _createClass(NumberSchema, [{
  8170. key: "expected",
  8171. value: function expected() {
  8172. return 'a number';
  8173. }
  8174. }, {
  8175. key: "validate",
  8176. value: function validate(value, _utils) {
  8177. return typeof value === 'number';
  8178. }
  8179. }]);
  8180. return NumberSchema;
  8181. }(schema.Schema);
  8182. exports.NumberSchema = NumberSchema;
  8183. });
  8184. unwrapExports(number);
  8185. var integer = createCommonjsModule(function (module, exports) {
  8186. "use strict";
  8187. Object.defineProperty(exports, "__esModule", {
  8188. value: true
  8189. });
  8190. var IntegerSchema =
  8191. /*#__PURE__*/
  8192. function (_number_1$NumberSchem) {
  8193. _inherits(IntegerSchema, _number_1$NumberSchem);
  8194. function IntegerSchema() {
  8195. _classCallCheck(this, IntegerSchema);
  8196. return _possibleConstructorReturn(this, _getPrototypeOf(IntegerSchema).apply(this, arguments));
  8197. }
  8198. _createClass(IntegerSchema, [{
  8199. key: "expected",
  8200. value: function expected() {
  8201. return 'an integer';
  8202. }
  8203. }, {
  8204. key: "validate",
  8205. value: function validate(value, utils$$2) {
  8206. return utils$$2.normalizeValidateResult(_get(_getPrototypeOf(IntegerSchema.prototype), "validate", this).call(this, value, utils$$2), value) === true && utils.isInt(value);
  8207. }
  8208. }]);
  8209. return IntegerSchema;
  8210. }(number.NumberSchema);
  8211. exports.IntegerSchema = IntegerSchema;
  8212. });
  8213. unwrapExports(integer);
  8214. var string = createCommonjsModule(function (module, exports) {
  8215. "use strict";
  8216. Object.defineProperty(exports, "__esModule", {
  8217. value: true
  8218. });
  8219. var StringSchema =
  8220. /*#__PURE__*/
  8221. function (_schema_1$Schema) {
  8222. _inherits(StringSchema, _schema_1$Schema);
  8223. function StringSchema() {
  8224. _classCallCheck(this, StringSchema);
  8225. return _possibleConstructorReturn(this, _getPrototypeOf(StringSchema).apply(this, arguments));
  8226. }
  8227. _createClass(StringSchema, [{
  8228. key: "expected",
  8229. value: function expected() {
  8230. return 'a string';
  8231. }
  8232. }, {
  8233. key: "validate",
  8234. value: function validate(value) {
  8235. return typeof value === 'string';
  8236. }
  8237. }]);
  8238. return StringSchema;
  8239. }(schema.Schema);
  8240. exports.StringSchema = StringSchema;
  8241. });
  8242. unwrapExports(string);
  8243. var schemas = createCommonjsModule(function (module, exports) {
  8244. "use strict";
  8245. Object.defineProperty(exports, "__esModule", {
  8246. value: true
  8247. });
  8248. tslib_1.__exportStar(alias, exports);
  8249. tslib_1.__exportStar(any, exports);
  8250. tslib_1.__exportStar(array$2, exports);
  8251. tslib_1.__exportStar(boolean_1, exports);
  8252. tslib_1.__exportStar(choice, exports);
  8253. tslib_1.__exportStar(integer, exports);
  8254. tslib_1.__exportStar(number, exports);
  8255. tslib_1.__exportStar(string, exports);
  8256. });
  8257. unwrapExports(schemas);
  8258. var defaults = createCommonjsModule(function (module, exports) {
  8259. "use strict";
  8260. Object.defineProperty(exports, "__esModule", {
  8261. value: true
  8262. });
  8263. exports.defaultDescriptor = api.apiDescriptor;
  8264. exports.defaultUnknownHandler = leven_1.levenUnknownHandler;
  8265. exports.defaultInvalidHandler = invalid.commonInvalidHandler;
  8266. exports.defaultDeprecatedHandler = common.commonDeprecatedHandler;
  8267. });
  8268. unwrapExports(defaults);
  8269. var normalize$1 = createCommonjsModule(function (module, exports) {
  8270. "use strict";
  8271. Object.defineProperty(exports, "__esModule", {
  8272. value: true
  8273. });
  8274. exports.normalize = function (options, schemas, opts) {
  8275. return new Normalizer(schemas, opts).normalize(options);
  8276. };
  8277. var Normalizer =
  8278. /*#__PURE__*/
  8279. function () {
  8280. function Normalizer(schemas, opts) {
  8281. _classCallCheck(this, Normalizer);
  8282. // istanbul ignore next
  8283. var _ref = opts || {},
  8284. _ref$logger = _ref.logger,
  8285. logger = _ref$logger === void 0 ? console : _ref$logger,
  8286. _ref$descriptor = _ref.descriptor,
  8287. descriptor = _ref$descriptor === void 0 ? defaults.defaultDescriptor : _ref$descriptor,
  8288. _ref$unknown = _ref.unknown,
  8289. unknown = _ref$unknown === void 0 ? defaults.defaultUnknownHandler : _ref$unknown,
  8290. _ref$invalid = _ref.invalid,
  8291. invalid = _ref$invalid === void 0 ? defaults.defaultInvalidHandler : _ref$invalid,
  8292. _ref$deprecated = _ref.deprecated,
  8293. deprecated = _ref$deprecated === void 0 ? defaults.defaultDeprecatedHandler : _ref$deprecated;
  8294. this._utils = {
  8295. descriptor: descriptor,
  8296. logger:
  8297. /* istanbul ignore next */
  8298. logger || {
  8299. warn: function warn() {}
  8300. },
  8301. schemas: utils.recordFromArray(schemas, 'name'),
  8302. normalizeDefaultResult: utils.normalizeDefaultResult,
  8303. normalizeDeprecatedResult: utils.normalizeDeprecatedResult,
  8304. normalizeForwardResult: utils.normalizeForwardResult,
  8305. normalizeRedirectResult: utils.normalizeRedirectResult,
  8306. normalizeValidateResult: utils.normalizeValidateResult
  8307. };
  8308. this._unknownHandler = unknown;
  8309. this._invalidHandler = invalid;
  8310. this._deprecatedHandler = deprecated;
  8311. this.cleanHistory();
  8312. }
  8313. _createClass(Normalizer, [{
  8314. key: "cleanHistory",
  8315. value: function cleanHistory() {
  8316. this._hasDeprecationWarned = utils.createAutoChecklist();
  8317. }
  8318. }, {
  8319. key: "normalize",
  8320. value: function normalize(options) {
  8321. var _this = this;
  8322. var normalized = {};
  8323. var restOptionsArray = [options];
  8324. var applyNormalization = function applyNormalization() {
  8325. while (restOptionsArray.length !== 0) {
  8326. var currentOptions = restOptionsArray.shift();
  8327. var transferredOptionsArray = _this._applyNormalization(currentOptions, normalized);
  8328. restOptionsArray.push.apply(restOptionsArray, _toConsumableArray(transferredOptionsArray));
  8329. }
  8330. };
  8331. applyNormalization();
  8332. var _arr = Object.keys(this._utils.schemas);
  8333. for (var _i = 0; _i < _arr.length; _i++) {
  8334. var key = _arr[_i];
  8335. var schema = this._utils.schemas[key];
  8336. if (!(key in normalized)) {
  8337. var defaultResult = utils.normalizeDefaultResult(schema.default(this._utils));
  8338. if ('value' in defaultResult) {
  8339. restOptionsArray.push(_defineProperty({}, key, defaultResult.value));
  8340. }
  8341. }
  8342. }
  8343. applyNormalization();
  8344. var _arr2 = Object.keys(this._utils.schemas);
  8345. for (var _i2 = 0; _i2 < _arr2.length; _i2++) {
  8346. var _key = _arr2[_i2];
  8347. var _schema = this._utils.schemas[_key];
  8348. if (_key in normalized) {
  8349. normalized[_key] = _schema.postprocess(normalized[_key], this._utils);
  8350. }
  8351. }
  8352. return normalized;
  8353. }
  8354. }, {
  8355. key: "_applyNormalization",
  8356. value: function _applyNormalization(options, normalized) {
  8357. var _this2 = this;
  8358. var transferredOptionsArray = [];
  8359. var _utils_1$partition = utils.partition(Object.keys(options), function (key) {
  8360. return key in _this2._utils.schemas;
  8361. }),
  8362. _utils_1$partition2 = _slicedToArray(_utils_1$partition, 2),
  8363. knownOptionNames = _utils_1$partition2[0],
  8364. unknownOptionNames = _utils_1$partition2[1];
  8365. var _iteratorNormalCompletion = true;
  8366. var _didIteratorError = false;
  8367. var _iteratorError = undefined;
  8368. try {
  8369. var _loop = function _loop() {
  8370. var key = _step.value;
  8371. var schema = _this2._utils.schemas[key];
  8372. var value = schema.preprocess(options[key], _this2._utils);
  8373. var validateResult = utils.normalizeValidateResult(schema.validate(value, _this2._utils), value);
  8374. if (validateResult !== true) {
  8375. var invalidValue = validateResult.value;
  8376. var errorMessageOrError = _this2._invalidHandler(key, invalidValue, _this2._utils);
  8377. throw typeof errorMessageOrError === 'string' ? new Error(errorMessageOrError) :
  8378. /* istanbul ignore next*/
  8379. errorMessageOrError;
  8380. }
  8381. var appendTransferredOptions = function appendTransferredOptions(_ref2) {
  8382. var from = _ref2.from,
  8383. to = _ref2.to;
  8384. transferredOptionsArray.push(typeof to === 'string' ? _defineProperty({}, to, from) : _defineProperty({}, to.key, to.value));
  8385. };
  8386. var warnDeprecated = function warnDeprecated(_ref5) {
  8387. var currentValue = _ref5.value,
  8388. redirectTo = _ref5.redirectTo;
  8389. var deprecatedResult = utils.normalizeDeprecatedResult(schema.deprecated(currentValue, _this2._utils), value,
  8390. /* doNotNormalizeTrue */
  8391. true);
  8392. if (deprecatedResult === false) {
  8393. return;
  8394. }
  8395. if (deprecatedResult === true) {
  8396. if (!_this2._hasDeprecationWarned(key)) {
  8397. _this2._utils.logger.warn(_this2._deprecatedHandler(key, redirectTo, _this2._utils));
  8398. }
  8399. } else {
  8400. var _iteratorNormalCompletion3 = true;
  8401. var _didIteratorError3 = false;
  8402. var _iteratorError3 = undefined;
  8403. try {
  8404. for (var _iterator3 = deprecatedResult[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
  8405. var deprecatedValue = _step3.value.value;
  8406. var pair = {
  8407. key: key,
  8408. value: deprecatedValue
  8409. };
  8410. if (!_this2._hasDeprecationWarned(pair)) {
  8411. var redirectToPair = typeof redirectTo === 'string' ? {
  8412. key: redirectTo,
  8413. value: deprecatedValue
  8414. } : redirectTo;
  8415. _this2._utils.logger.warn(_this2._deprecatedHandler(pair, redirectToPair, _this2._utils));
  8416. }
  8417. }
  8418. } catch (err) {
  8419. _didIteratorError3 = true;
  8420. _iteratorError3 = err;
  8421. } finally {
  8422. try {
  8423. if (!_iteratorNormalCompletion3 && _iterator3.return != null) {
  8424. _iterator3.return();
  8425. }
  8426. } finally {
  8427. if (_didIteratorError3) {
  8428. throw _iteratorError3;
  8429. }
  8430. }
  8431. }
  8432. }
  8433. };
  8434. var forwardResult = utils.normalizeForwardResult(schema.forward(value, _this2._utils), value);
  8435. forwardResult.forEach(appendTransferredOptions);
  8436. var redirectResult = utils.normalizeRedirectResult(schema.redirect(value, _this2._utils), value);
  8437. redirectResult.redirect.forEach(appendTransferredOptions);
  8438. if ('remain' in redirectResult) {
  8439. var remainingValue = redirectResult.remain;
  8440. normalized[key] = key in normalized ? schema.overlap(normalized[key], remainingValue, _this2._utils) : remainingValue;
  8441. warnDeprecated({
  8442. value: remainingValue
  8443. });
  8444. }
  8445. var _iteratorNormalCompletion4 = true;
  8446. var _didIteratorError4 = false;
  8447. var _iteratorError4 = undefined;
  8448. try {
  8449. for (var _iterator4 = redirectResult.redirect[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {
  8450. var _step4$value = _step4.value,
  8451. from = _step4$value.from,
  8452. to = _step4$value.to;
  8453. warnDeprecated({
  8454. value: from,
  8455. redirectTo: to
  8456. });
  8457. }
  8458. } catch (err) {
  8459. _didIteratorError4 = true;
  8460. _iteratorError4 = err;
  8461. } finally {
  8462. try {
  8463. if (!_iteratorNormalCompletion4 && _iterator4.return != null) {
  8464. _iterator4.return();
  8465. }
  8466. } finally {
  8467. if (_didIteratorError4) {
  8468. throw _iteratorError4;
  8469. }
  8470. }
  8471. }
  8472. };
  8473. for (var _iterator = knownOptionNames[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  8474. _loop();
  8475. }
  8476. } catch (err) {
  8477. _didIteratorError = true;
  8478. _iteratorError = err;
  8479. } finally {
  8480. try {
  8481. if (!_iteratorNormalCompletion && _iterator.return != null) {
  8482. _iterator.return();
  8483. }
  8484. } finally {
  8485. if (_didIteratorError) {
  8486. throw _iteratorError;
  8487. }
  8488. }
  8489. }
  8490. var _iteratorNormalCompletion2 = true;
  8491. var _didIteratorError2 = false;
  8492. var _iteratorError2 = undefined;
  8493. try {
  8494. for (var _iterator2 = unknownOptionNames[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
  8495. var key = _step2.value;
  8496. var value = options[key];
  8497. var unknownResult = this._unknownHandler(key, value, this._utils);
  8498. if (unknownResult) {
  8499. var _arr3 = Object.keys(unknownResult);
  8500. for (var _i3 = 0; _i3 < _arr3.length; _i3++) {
  8501. var unknownKey = _arr3[_i3];
  8502. var unknownOption = _defineProperty({}, unknownKey, unknownResult[unknownKey]);
  8503. if (unknownKey in this._utils.schemas) {
  8504. transferredOptionsArray.push(unknownOption);
  8505. } else {
  8506. Object.assign(normalized, unknownOption);
  8507. }
  8508. }
  8509. }
  8510. }
  8511. } catch (err) {
  8512. _didIteratorError2 = true;
  8513. _iteratorError2 = err;
  8514. } finally {
  8515. try {
  8516. if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
  8517. _iterator2.return();
  8518. }
  8519. } finally {
  8520. if (_didIteratorError2) {
  8521. throw _iteratorError2;
  8522. }
  8523. }
  8524. }
  8525. return transferredOptionsArray;
  8526. }
  8527. }]);
  8528. return Normalizer;
  8529. }();
  8530. exports.Normalizer = Normalizer;
  8531. });
  8532. unwrapExports(normalize$1);
  8533. var lib$1 = createCommonjsModule(function (module, exports) {
  8534. "use strict";
  8535. Object.defineProperty(exports, "__esModule", {
  8536. value: true
  8537. });
  8538. tslib_1.__exportStar(descriptors, exports);
  8539. tslib_1.__exportStar(handlers, exports);
  8540. tslib_1.__exportStar(schemas, exports);
  8541. tslib_1.__exportStar(normalize$1, exports);
  8542. tslib_1.__exportStar(schema, exports);
  8543. });
  8544. unwrapExports(lib$1);
  8545. var hasFlag$3 = function hasFlag(flag, argv$$1) {
  8546. argv$$1 = argv$$1 || process.argv;
  8547. var terminatorPos = argv$$1.indexOf('--');
  8548. var prefix = /^-{1,2}/.test(flag) ? '' : '--';
  8549. var pos = argv$$1.indexOf(prefix + flag);
  8550. return pos !== -1 && (terminatorPos === -1 ? true : pos < terminatorPos);
  8551. };
  8552. var supportsColor$1 = createCommonjsModule(function (module) {
  8553. 'use strict';
  8554. var env$$1 = process.env;
  8555. var support = function support(level) {
  8556. if (level === 0) {
  8557. return false;
  8558. }
  8559. return {
  8560. level: level,
  8561. hasBasic: true,
  8562. has256: level >= 2,
  8563. has16m: level >= 3
  8564. };
  8565. };
  8566. var supportLevel = function () {
  8567. if (hasFlag$3('no-color') || hasFlag$3('no-colors') || hasFlag$3('color=false')) {
  8568. return 0;
  8569. }
  8570. if (hasFlag$3('color=16m') || hasFlag$3('color=full') || hasFlag$3('color=truecolor')) {
  8571. return 3;
  8572. }
  8573. if (hasFlag$3('color=256')) {
  8574. return 2;
  8575. }
  8576. if (hasFlag$3('color') || hasFlag$3('colors') || hasFlag$3('color=true') || hasFlag$3('color=always')) {
  8577. return 1;
  8578. }
  8579. if (process.stdout && !process.stdout.isTTY) {
  8580. return 0;
  8581. }
  8582. if (process.platform === 'win32') {
  8583. // Node.js 7.5.0 is the first version of Node.js to include a patch to
  8584. // libuv that enables 256 color output on Windows. Anything earlier and it
  8585. // won't work. However, here we target Node.js 8 at minimum as it is an LTS
  8586. // release, and Node.js 7 is not. Windows 10 build 10586 is the first Windows
  8587. // release that supports 256 colors.
  8588. var osRelease = require$$1$1.release().split('.');
  8589. if (Number(process.versions.node.split('.')[0]) >= 8 && Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
  8590. return 2;
  8591. }
  8592. return 1;
  8593. }
  8594. if ('CI' in env$$1) {
  8595. if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI'].some(function (sign) {
  8596. return sign in env$$1;
  8597. }) || env$$1.CI_NAME === 'codeship') {
  8598. return 1;
  8599. }
  8600. return 0;
  8601. }
  8602. if ('TEAMCITY_VERSION' in env$$1) {
  8603. return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env$$1.TEAMCITY_VERSION) ? 1 : 0;
  8604. }
  8605. if ('TERM_PROGRAM' in env$$1) {
  8606. var version = parseInt((env$$1.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
  8607. switch (env$$1.TERM_PROGRAM) {
  8608. case 'iTerm.app':
  8609. return version >= 3 ? 3 : 2;
  8610. case 'Hyper':
  8611. return 3;
  8612. case 'Apple_Terminal':
  8613. return 2;
  8614. // No default
  8615. }
  8616. }
  8617. if (/-256(color)?$/i.test(env$$1.TERM)) {
  8618. return 2;
  8619. }
  8620. if (/^screen|^xterm|^vt100|^rxvt|color|ansi|cygwin|linux/i.test(env$$1.TERM)) {
  8621. return 1;
  8622. }
  8623. if ('COLORTERM' in env$$1) {
  8624. return 1;
  8625. }
  8626. if (env$$1.TERM === 'dumb') {
  8627. return 0;
  8628. }
  8629. return 0;
  8630. }();
  8631. if ('FORCE_COLOR' in env$$1) {
  8632. supportLevel = parseInt(env$$1.FORCE_COLOR, 10) === 0 ? 0 : supportLevel || 1;
  8633. }
  8634. module.exports = process && support(supportLevel);
  8635. });
  8636. var templates$2 = createCommonjsModule(function (module) {
  8637. 'use strict';
  8638. var TEMPLATE_REGEX = /(?:\\(u[a-f0-9]{4}|x[a-f0-9]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi;
  8639. var STYLE_REGEX = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g;
  8640. var STRING_REGEX = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/;
  8641. var ESCAPE_REGEX = /\\(u[0-9a-f]{4}|x[0-9a-f]{2}|.)|([^\\])/gi;
  8642. var ESCAPES = {
  8643. n: '\n',
  8644. r: '\r',
  8645. t: '\t',
  8646. b: '\b',
  8647. f: '\f',
  8648. v: '\v',
  8649. 0: '\0',
  8650. '\\': '\\',
  8651. e: "\x1B",
  8652. a: "\x07"
  8653. };
  8654. function unescape(c) {
  8655. if (c[0] === 'u' && c.length === 5 || c[0] === 'x' && c.length === 3) {
  8656. return String.fromCharCode(parseInt(c.slice(1), 16));
  8657. }
  8658. return ESCAPES[c] || c;
  8659. }
  8660. function parseArguments(name, args) {
  8661. var results = [];
  8662. var chunks = args.trim().split(/\s*,\s*/g);
  8663. var matches;
  8664. var _iteratorNormalCompletion = true;
  8665. var _didIteratorError = false;
  8666. var _iteratorError = undefined;
  8667. try {
  8668. for (var _iterator = chunks[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  8669. var chunk = _step.value;
  8670. if (!isNaN(chunk)) {
  8671. results.push(Number(chunk));
  8672. } else if (matches = chunk.match(STRING_REGEX)) {
  8673. results.push(matches[2].replace(ESCAPE_REGEX, function (m, escape, chr) {
  8674. return escape ? unescape(escape) : chr;
  8675. }));
  8676. } else {
  8677. throw new Error("Invalid Chalk template style argument: ".concat(chunk, " (in style '").concat(name, "')"));
  8678. }
  8679. }
  8680. } catch (err) {
  8681. _didIteratorError = true;
  8682. _iteratorError = err;
  8683. } finally {
  8684. try {
  8685. if (!_iteratorNormalCompletion && _iterator.return != null) {
  8686. _iterator.return();
  8687. }
  8688. } finally {
  8689. if (_didIteratorError) {
  8690. throw _iteratorError;
  8691. }
  8692. }
  8693. }
  8694. return results;
  8695. }
  8696. function parseStyle(style) {
  8697. STYLE_REGEX.lastIndex = 0;
  8698. var results = [];
  8699. var matches;
  8700. while ((matches = STYLE_REGEX.exec(style)) !== null) {
  8701. var name = matches[1];
  8702. if (matches[2]) {
  8703. var args = parseArguments(name, matches[2]);
  8704. results.push([name].concat(args));
  8705. } else {
  8706. results.push([name]);
  8707. }
  8708. }
  8709. return results;
  8710. }
  8711. function buildStyle(chalk, styles) {
  8712. var enabled = {};
  8713. var _iteratorNormalCompletion2 = true;
  8714. var _didIteratorError2 = false;
  8715. var _iteratorError2 = undefined;
  8716. try {
  8717. for (var _iterator2 = styles[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
  8718. var layer = _step2.value;
  8719. var _iteratorNormalCompletion3 = true;
  8720. var _didIteratorError3 = false;
  8721. var _iteratorError3 = undefined;
  8722. try {
  8723. for (var _iterator3 = layer.styles[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
  8724. var style = _step3.value;
  8725. enabled[style[0]] = layer.inverse ? null : style.slice(1);
  8726. }
  8727. } catch (err) {
  8728. _didIteratorError3 = true;
  8729. _iteratorError3 = err;
  8730. } finally {
  8731. try {
  8732. if (!_iteratorNormalCompletion3 && _iterator3.return != null) {
  8733. _iterator3.return();
  8734. }
  8735. } finally {
  8736. if (_didIteratorError3) {
  8737. throw _iteratorError3;
  8738. }
  8739. }
  8740. }
  8741. }
  8742. } catch (err) {
  8743. _didIteratorError2 = true;
  8744. _iteratorError2 = err;
  8745. } finally {
  8746. try {
  8747. if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
  8748. _iterator2.return();
  8749. }
  8750. } finally {
  8751. if (_didIteratorError2) {
  8752. throw _iteratorError2;
  8753. }
  8754. }
  8755. }
  8756. var current = chalk;
  8757. var _arr = Object.keys(enabled);
  8758. for (var _i = 0; _i < _arr.length; _i++) {
  8759. var styleName = _arr[_i];
  8760. if (Array.isArray(enabled[styleName])) {
  8761. if (!(styleName in current)) {
  8762. throw new Error("Unknown Chalk style: ".concat(styleName));
  8763. }
  8764. if (enabled[styleName].length > 0) {
  8765. current = current[styleName].apply(current, enabled[styleName]);
  8766. } else {
  8767. current = current[styleName];
  8768. }
  8769. }
  8770. }
  8771. return current;
  8772. }
  8773. module.exports = function (chalk, tmp) {
  8774. var styles = [];
  8775. var chunks = [];
  8776. var chunk = []; // eslint-disable-next-line max-params
  8777. tmp.replace(TEMPLATE_REGEX, function (m, escapeChar, inverse, style, close, chr) {
  8778. if (escapeChar) {
  8779. chunk.push(unescape(escapeChar));
  8780. } else if (style) {
  8781. var str = chunk.join('');
  8782. chunk = [];
  8783. chunks.push(styles.length === 0 ? str : buildStyle(chalk, styles)(str));
  8784. styles.push({
  8785. inverse: inverse,
  8786. styles: parseStyle(style)
  8787. });
  8788. } else if (close) {
  8789. if (styles.length === 0) {
  8790. throw new Error('Found extraneous } in Chalk template literal');
  8791. }
  8792. chunks.push(buildStyle(chalk, styles)(chunk.join('')));
  8793. chunk = [];
  8794. styles.pop();
  8795. } else {
  8796. chunk.push(chr);
  8797. }
  8798. });
  8799. chunks.push(chunk.join(''));
  8800. if (styles.length > 0) {
  8801. var errMsg = "Chalk template literal is missing ".concat(styles.length, " closing bracket").concat(styles.length === 1 ? '' : 's', " (`}`)");
  8802. throw new Error(errMsg);
  8803. }
  8804. return chunks.join('');
  8805. };
  8806. });
  8807. var isSimpleWindowsTerm = process.platform === 'win32' && !(process.env.TERM || '').toLowerCase().startsWith('xterm'); // `supportsColor.level` → `ansiStyles.color[name]` mapping
  8808. var levelMapping = ['ansi', 'ansi', 'ansi256', 'ansi16m']; // `color-convert` models to exclude from the Chalk API due to conflicts and such
  8809. var skipModels = new Set(['gray']);
  8810. var styles = Object.create(null);
  8811. function applyOptions(obj, options) {
  8812. options = options || {}; // Detect level if not set manually
  8813. var scLevel = supportsColor$1 ? supportsColor$1.level : 0;
  8814. obj.level = options.level === undefined ? scLevel : options.level;
  8815. obj.enabled = 'enabled' in options ? options.enabled : obj.level > 0;
  8816. }
  8817. function Chalk(options) {
  8818. // We check for this.template here since calling `chalk.constructor()`
  8819. // by itself will have a `this` of a previously constructed chalk object
  8820. if (!this || !(this instanceof Chalk) || this.template) {
  8821. var _chalk = {};
  8822. applyOptions(_chalk, options);
  8823. _chalk.template = function () {
  8824. var args = [].slice.call(arguments);
  8825. return chalkTag.apply(null, [_chalk.template].concat(args));
  8826. };
  8827. Object.setPrototypeOf(_chalk, Chalk.prototype);
  8828. Object.setPrototypeOf(_chalk.template, _chalk);
  8829. _chalk.template.constructor = Chalk;
  8830. return _chalk.template;
  8831. }
  8832. applyOptions(this, options);
  8833. } // Use bright blue on Windows as the normal blue color is illegible
  8834. if (isSimpleWindowsTerm) {
  8835. ansiStyles.blue.open = "\x1B[94m";
  8836. }
  8837. var _arr = Object.keys(ansiStyles);
  8838. var _loop = function _loop() {
  8839. var key = _arr[_i];
  8840. ansiStyles[key].closeRe = new RegExp(escapeStringRegexp(ansiStyles[key].close), 'g');
  8841. styles[key] = {
  8842. get: function get() {
  8843. var codes = ansiStyles[key];
  8844. return build.call(this, this._styles ? this._styles.concat(codes) : [codes], key);
  8845. }
  8846. };
  8847. };
  8848. for (var _i = 0; _i < _arr.length; _i++) {
  8849. _loop();
  8850. }
  8851. ansiStyles.color.closeRe = new RegExp(escapeStringRegexp(ansiStyles.color.close), 'g');
  8852. var _arr2 = Object.keys(ansiStyles.color.ansi);
  8853. var _loop2 = function _loop2() {
  8854. var model = _arr2[_i2];
  8855. if (skipModels.has(model)) {
  8856. return "continue";
  8857. }
  8858. styles[model] = {
  8859. get: function get() {
  8860. var level = this.level;
  8861. return function () {
  8862. var open = ansiStyles.color[levelMapping[level]][model].apply(null, arguments);
  8863. var codes = {
  8864. open: open,
  8865. close: ansiStyles.color.close,
  8866. closeRe: ansiStyles.color.closeRe
  8867. };
  8868. return build.call(this, this._styles ? this._styles.concat(codes) : [codes], model);
  8869. };
  8870. }
  8871. };
  8872. };
  8873. for (var _i2 = 0; _i2 < _arr2.length; _i2++) {
  8874. var _ret = _loop2();
  8875. if (_ret === "continue") continue;
  8876. }
  8877. ansiStyles.bgColor.closeRe = new RegExp(escapeStringRegexp(ansiStyles.bgColor.close), 'g');
  8878. var _arr3 = Object.keys(ansiStyles.bgColor.ansi);
  8879. var _loop3 = function _loop3() {
  8880. var model = _arr3[_i3];
  8881. if (skipModels.has(model)) {
  8882. return "continue";
  8883. }
  8884. var bgModel = 'bg' + model[0].toUpperCase() + model.slice(1);
  8885. styles[bgModel] = {
  8886. get: function get() {
  8887. var level = this.level;
  8888. return function () {
  8889. var open = ansiStyles.bgColor[levelMapping[level]][model].apply(null, arguments);
  8890. var codes = {
  8891. open: open,
  8892. close: ansiStyles.bgColor.close,
  8893. closeRe: ansiStyles.bgColor.closeRe
  8894. };
  8895. return build.call(this, this._styles ? this._styles.concat(codes) : [codes], model);
  8896. };
  8897. }
  8898. };
  8899. };
  8900. for (var _i3 = 0; _i3 < _arr3.length; _i3++) {
  8901. var _ret2 = _loop3();
  8902. if (_ret2 === "continue") continue;
  8903. }
  8904. var proto = Object.defineProperties(function () {}, styles);
  8905. function build(_styles, key) {
  8906. var builder = function builder() {
  8907. return applyStyle.apply(builder, arguments);
  8908. };
  8909. builder._styles = _styles;
  8910. var self = this;
  8911. Object.defineProperty(builder, 'level', {
  8912. enumerable: true,
  8913. get: function get() {
  8914. return self.level;
  8915. },
  8916. set: function set(level) {
  8917. self.level = level;
  8918. }
  8919. });
  8920. Object.defineProperty(builder, 'enabled', {
  8921. enumerable: true,
  8922. get: function get() {
  8923. return self.enabled;
  8924. },
  8925. set: function set(enabled) {
  8926. self.enabled = enabled;
  8927. }
  8928. }); // See below for fix regarding invisible grey/dim combination on Windows
  8929. builder.hasGrey = this.hasGrey || key === 'gray' || key === 'grey'; // `__proto__` is used because we must return a function, but there is
  8930. // no way to create a function with a different prototype
  8931. builder.__proto__ = proto; // eslint-disable-line no-proto
  8932. return builder;
  8933. }
  8934. function applyStyle() {
  8935. // Support varags, but simply cast to string in case there's only one arg
  8936. var args = arguments;
  8937. var argsLen = args.length;
  8938. var str = String(arguments[0]);
  8939. if (argsLen === 0) {
  8940. return '';
  8941. }
  8942. if (argsLen > 1) {
  8943. // Don't slice `arguments`, it prevents V8 optimizations
  8944. for (var a = 1; a < argsLen; a++) {
  8945. str += ' ' + args[a];
  8946. }
  8947. }
  8948. if (!this.enabled || this.level <= 0 || !str) {
  8949. return str;
  8950. } // Turns out that on Windows dimmed gray text becomes invisible in cmd.exe,
  8951. // see https://github.com/chalk/chalk/issues/58
  8952. // If we're on Windows and we're dealing with a gray color, temporarily make 'dim' a noop.
  8953. var originalDim = ansiStyles.dim.open;
  8954. if (isSimpleWindowsTerm && this.hasGrey) {
  8955. ansiStyles.dim.open = '';
  8956. }
  8957. var _iteratorNormalCompletion = true;
  8958. var _didIteratorError = false;
  8959. var _iteratorError = undefined;
  8960. try {
  8961. for (var _iterator = this._styles.slice().reverse()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  8962. var code = _step.value;
  8963. // Replace any instances already present with a re-opening code
  8964. // otherwise only the part of the string until said closing code
  8965. // will be colored, and the rest will simply be 'plain'.
  8966. str = code.open + str.replace(code.closeRe, code.open) + code.close; // Close the styling before a linebreak and reopen
  8967. // after next line to fix a bleed issue on macOS
  8968. // https://github.com/chalk/chalk/pull/92
  8969. str = str.replace(/\r?\n/g, "".concat(code.close, "$&").concat(code.open));
  8970. } // Reset the original `dim` if we changed it to work around the Windows dimmed gray issue
  8971. } catch (err) {
  8972. _didIteratorError = true;
  8973. _iteratorError = err;
  8974. } finally {
  8975. try {
  8976. if (!_iteratorNormalCompletion && _iterator.return != null) {
  8977. _iterator.return();
  8978. }
  8979. } finally {
  8980. if (_didIteratorError) {
  8981. throw _iteratorError;
  8982. }
  8983. }
  8984. }
  8985. ansiStyles.dim.open = originalDim;
  8986. return str;
  8987. }
  8988. function chalkTag(chalk, strings) {
  8989. if (!Array.isArray(strings)) {
  8990. // If chalk() was called by itself or with a string,
  8991. // return the string itself as a string.
  8992. return [].slice.call(arguments, 1).join(' ');
  8993. }
  8994. var args = [].slice.call(arguments, 2);
  8995. var parts = [strings.raw[0]];
  8996. for (var i = 1; i < strings.length; i++) {
  8997. parts.push(String(args[i - 1]).replace(/[{}\\]/g, '\\$&'));
  8998. parts.push(String(strings.raw[i]));
  8999. }
  9000. return templates$2(chalk, parts.join(''));
  9001. }
  9002. Object.defineProperties(Chalk.prototype, styles);
  9003. var chalk$2 = Chalk(); // eslint-disable-line new-cap
  9004. var supportsColor_1$2 = supportsColor$1;
  9005. chalk$2.supportsColor = supportsColor_1$2;
  9006. var cliDescriptor = {
  9007. key: function key(_key) {
  9008. return _key.length === 1 ? "-".concat(_key) : "--".concat(_key);
  9009. },
  9010. value: function value(_value) {
  9011. return lib$1.apiDescriptor.value(_value);
  9012. },
  9013. pair: function pair(_ref) {
  9014. var key = _ref.key,
  9015. value = _ref.value;
  9016. 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);
  9017. }
  9018. };
  9019. var FlagSchema =
  9020. /*#__PURE__*/
  9021. function (_vnopts$ChoiceSchema) {
  9022. _inherits(FlagSchema, _vnopts$ChoiceSchema);
  9023. function FlagSchema(_ref2) {
  9024. var _this;
  9025. var name = _ref2.name,
  9026. flags = _ref2.flags;
  9027. _classCallCheck(this, FlagSchema);
  9028. _this = _possibleConstructorReturn(this, _getPrototypeOf(FlagSchema).call(this, {
  9029. name: name,
  9030. choices: flags
  9031. }));
  9032. _this._flags = flags.slice().sort();
  9033. return _this;
  9034. }
  9035. _createClass(FlagSchema, [{
  9036. key: "preprocess",
  9037. value: function preprocess(value, utils) {
  9038. if (typeof value === "string" && value.length !== 0 && this._flags.indexOf(value) === -1) {
  9039. var suggestion = this._flags.find(function (flag) {
  9040. return leven$1(flag, value) < 3;
  9041. });
  9042. if (suggestion) {
  9043. 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(" "));
  9044. return suggestion;
  9045. }
  9046. }
  9047. return value;
  9048. }
  9049. }, {
  9050. key: "expected",
  9051. value: function expected() {
  9052. return "a flag";
  9053. }
  9054. }]);
  9055. return FlagSchema;
  9056. }(lib$1.ChoiceSchema);
  9057. var hasDeprecationWarned;
  9058. function normalizeOptions$1(options, optionInfos) {
  9059. var _ref3 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
  9060. logger = _ref3.logger,
  9061. _ref3$isCLI = _ref3.isCLI,
  9062. isCLI = _ref3$isCLI === void 0 ? false : _ref3$isCLI,
  9063. _ref3$passThrough = _ref3.passThrough,
  9064. passThrough = _ref3$passThrough === void 0 ? false : _ref3$passThrough;
  9065. var unknown = !passThrough ? lib$1.levenUnknownHandler : Array.isArray(passThrough) ? function (key, value) {
  9066. return passThrough.indexOf(key) === -1 ? undefined : _defineProperty({}, key, value);
  9067. } : function (key, value) {
  9068. return _defineProperty({}, key, value);
  9069. };
  9070. var descriptor = isCLI ? cliDescriptor : lib$1.apiDescriptor;
  9071. var schemas = optionInfosToSchemas(optionInfos, {
  9072. isCLI: isCLI
  9073. });
  9074. var normalizer = new lib$1.Normalizer(schemas, {
  9075. logger: logger,
  9076. unknown: unknown,
  9077. descriptor: descriptor
  9078. });
  9079. var shouldSuppressDuplicateDeprecationWarnings = logger !== false;
  9080. if (shouldSuppressDuplicateDeprecationWarnings && hasDeprecationWarned) {
  9081. normalizer._hasDeprecationWarned = hasDeprecationWarned;
  9082. }
  9083. var normalized = normalizer.normalize(options);
  9084. if (shouldSuppressDuplicateDeprecationWarnings) {
  9085. hasDeprecationWarned = normalizer._hasDeprecationWarned;
  9086. }
  9087. return normalized;
  9088. }
  9089. function optionInfosToSchemas(optionInfos, _ref6) {
  9090. var isCLI = _ref6.isCLI;
  9091. var schemas = [];
  9092. if (isCLI) {
  9093. schemas.push(lib$1.AnySchema.create({
  9094. name: "_"
  9095. }));
  9096. }
  9097. var _iteratorNormalCompletion = true;
  9098. var _didIteratorError = false;
  9099. var _iteratorError = undefined;
  9100. try {
  9101. for (var _iterator = optionInfos[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  9102. var optionInfo = _step.value;
  9103. schemas.push(optionInfoToSchema(optionInfo, {
  9104. isCLI: isCLI,
  9105. optionInfos: optionInfos
  9106. }));
  9107. if (optionInfo.alias && isCLI) {
  9108. schemas.push(lib$1.AliasSchema.create({
  9109. name: optionInfo.alias,
  9110. sourceName: optionInfo.name
  9111. }));
  9112. }
  9113. }
  9114. } catch (err) {
  9115. _didIteratorError = true;
  9116. _iteratorError = err;
  9117. } finally {
  9118. try {
  9119. if (!_iteratorNormalCompletion && _iterator.return != null) {
  9120. _iterator.return();
  9121. }
  9122. } finally {
  9123. if (_didIteratorError) {
  9124. throw _iteratorError;
  9125. }
  9126. }
  9127. }
  9128. return schemas;
  9129. }
  9130. function optionInfoToSchema(optionInfo, _ref7) {
  9131. var isCLI = _ref7.isCLI,
  9132. optionInfos = _ref7.optionInfos;
  9133. var SchemaConstructor;
  9134. var parameters = {
  9135. name: optionInfo.name
  9136. };
  9137. var handlers = {};
  9138. switch (optionInfo.type) {
  9139. case "int":
  9140. SchemaConstructor = lib$1.IntegerSchema;
  9141. if (isCLI) {
  9142. parameters.preprocess = function (value) {
  9143. return Number(value);
  9144. };
  9145. }
  9146. break;
  9147. case "choice":
  9148. SchemaConstructor = lib$1.ChoiceSchema;
  9149. parameters.choices = optionInfo.choices.map(function (choiceInfo) {
  9150. return _typeof(choiceInfo) === "object" && choiceInfo.redirect ? Object.assign({}, choiceInfo, {
  9151. redirect: {
  9152. to: {
  9153. key: optionInfo.name,
  9154. value: choiceInfo.redirect
  9155. }
  9156. }
  9157. }) : choiceInfo;
  9158. });
  9159. break;
  9160. case "boolean":
  9161. SchemaConstructor = lib$1.BooleanSchema;
  9162. break;
  9163. case "flag":
  9164. SchemaConstructor = FlagSchema;
  9165. parameters.flags = optionInfos.map(function (optionInfo) {
  9166. return [].concat(optionInfo.alias || [], optionInfo.description ? optionInfo.name : [], optionInfo.oppositeDescription ? "no-".concat(optionInfo.name) : []);
  9167. }).reduce(function (a, b) {
  9168. return a.concat(b);
  9169. }, []);
  9170. break;
  9171. case "path":
  9172. SchemaConstructor = lib$1.StringSchema;
  9173. break;
  9174. default:
  9175. throw new Error("Unexpected type ".concat(optionInfo.type));
  9176. }
  9177. if (optionInfo.exception) {
  9178. parameters.validate = function (value, schema, utils) {
  9179. return optionInfo.exception(value) || schema.validate(value, utils);
  9180. };
  9181. } else {
  9182. parameters.validate = function (value, schema, utils) {
  9183. return value === undefined || schema.validate(value, utils);
  9184. };
  9185. }
  9186. if (optionInfo.redirect) {
  9187. handlers.redirect = function (value) {
  9188. return !value ? undefined : {
  9189. to: {
  9190. key: optionInfo.redirect.option,
  9191. value: optionInfo.redirect.value
  9192. }
  9193. };
  9194. };
  9195. }
  9196. if (optionInfo.deprecated) {
  9197. handlers.deprecated = true;
  9198. } // allow CLI overriding, e.g., prettier package.json --tab-width 1 --tab-width 2
  9199. if (isCLI && !optionInfo.array) {
  9200. var originalPreprocess = parameters.preprocess || function (x) {
  9201. return x;
  9202. };
  9203. parameters.preprocess = function (value, schema, utils) {
  9204. return schema.preprocess(originalPreprocess(Array.isArray(value) ? value[value.length - 1] : value), utils);
  9205. };
  9206. }
  9207. return optionInfo.array ? lib$1.ArraySchema.create(Object.assign(isCLI ? {
  9208. preprocess: function preprocess(v) {
  9209. return [].concat(v);
  9210. }
  9211. } : {}, handlers, {
  9212. valueSchema: SchemaConstructor.create(parameters)
  9213. })) : SchemaConstructor.create(Object.assign({}, parameters, handlers));
  9214. }
  9215. function normalizeApiOptions(options, optionInfos, opts) {
  9216. return normalizeOptions$1(options, optionInfos, opts);
  9217. }
  9218. function normalizeCliOptions(options, optionInfos, opts) {
  9219. return normalizeOptions$1(options, optionInfos, Object.assign({
  9220. isCLI: true
  9221. }, opts));
  9222. }
  9223. var optionsNormalizer = {
  9224. normalizeApiOptions: normalizeApiOptions,
  9225. normalizeCliOptions: normalizeCliOptions
  9226. };
  9227. var getLast = function getLast(arr) {
  9228. return arr.length > 0 ? arr[arr.length - 1] : null;
  9229. };
  9230. function locStart$1(node, opts) {
  9231. opts = opts || {}; // Handle nodes with decorators. They should start at the first decorator
  9232. if (!opts.ignoreDecorators && node.declaration && node.declaration.decorators && node.declaration.decorators.length > 0) {
  9233. return locStart$1(node.declaration.decorators[0]);
  9234. }
  9235. if (!opts.ignoreDecorators && node.decorators && node.decorators.length > 0) {
  9236. return locStart$1(node.decorators[0]);
  9237. }
  9238. if (node.__location) {
  9239. return node.__location.startOffset;
  9240. }
  9241. if (node.range) {
  9242. return node.range[0];
  9243. }
  9244. if (typeof node.start === "number") {
  9245. return node.start;
  9246. }
  9247. if (node.loc) {
  9248. return node.loc.start;
  9249. }
  9250. return null;
  9251. }
  9252. function locEnd$1(node) {
  9253. var endNode = node.nodes && getLast(node.nodes);
  9254. if (endNode && node.source && !node.source.end) {
  9255. node = endNode;
  9256. }
  9257. if (node.__location) {
  9258. return node.__location.endOffset;
  9259. }
  9260. var loc = node.range ? node.range[1] : typeof node.end === "number" ? node.end : null;
  9261. if (node.typeAnnotation) {
  9262. return Math.max(loc, locEnd$1(node.typeAnnotation));
  9263. }
  9264. if (node.loc && !loc) {
  9265. return node.loc.end;
  9266. }
  9267. return loc;
  9268. }
  9269. var loc = {
  9270. locStart: locStart$1,
  9271. locEnd: locEnd$1
  9272. };
  9273. var jsTokens = createCommonjsModule(function (module, exports) {
  9274. // Copyright 2014, 2015, 2016, 2017, 2018 Simon Lydell
  9275. // License: MIT. (See LICENSE.)
  9276. Object.defineProperty(exports, "__esModule", {
  9277. value: true
  9278. }); // This regex comes from regex.coffee, and is inserted here by generate-index.js
  9279. // (run `npm run build`).
  9280. exports.default = /((['"])(?:(?!\2|\\).|\\(?:\r\n|[\s\S]))*(\2)?|`(?:[^`\\$]|\\[\s\S]|\$(?!\{)|\$\{(?:[^{}]|\{[^}]*\}?)*\}?)*(`)?)|(\/\/.*)|(\/\*(?:[^*]|\*(?!\/))*(\*\/)?)|(\/(?!\*)(?:\[(?:(?![\]\\]).|\\.)*\]|(?![\/\]\\]).|\\.)+\/(?:(?!\s*(?:\b|[\u0080-\uFFFF$\\'"~({]|[+\-!](?!=)|\.?\d))|[gmiyus]{1,6}\b(?![\u0080-\uFFFF$\\]|\s*(?:[+\-*%&|^<>!=?({]|\/(?![\/*])))))|(0[xX][\da-fA-F]+|0[oO][0-7]+|0[bB][01]+|(?:\d*\.\d+|\d+\.?)(?:[eE][+-]?\d+)?)|((?!\d)(?:(?!\s)[$\w\u0080-\uFFFF]|\\u[\da-fA-F]{4}|\\u\{[\da-fA-F]+\})+)|(--|\+\+|&&|\|\||=>|\.{3}|(?:[+\-\/%&|^]|\*{1,2}|<{1,2}|>{1,3}|!=?|={1,2})=?|[?~.,:;[\](){}])|(\s+)|(^$|[\s\S])/g;
  9281. exports.matchToToken = function (match) {
  9282. var token = {
  9283. type: "invalid",
  9284. value: match[0],
  9285. closed: undefined
  9286. };
  9287. 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";
  9288. return token;
  9289. };
  9290. });
  9291. unwrapExports(jsTokens);
  9292. var ast = createCommonjsModule(function (module) {
  9293. /*
  9294. Copyright (C) 2013 Yusuke Suzuki <utatane.tea@gmail.com>
  9295. Redistribution and use in source and binary forms, with or without
  9296. modification, are permitted provided that the following conditions are met:
  9297. * Redistributions of source code must retain the above copyright
  9298. notice, this list of conditions and the following disclaimer.
  9299. * Redistributions in binary form must reproduce the above copyright
  9300. notice, this list of conditions and the following disclaimer in the
  9301. documentation and/or other materials provided with the distribution.
  9302. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS'
  9303. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  9304. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  9305. ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
  9306. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  9307. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  9308. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  9309. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  9310. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  9311. THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  9312. */
  9313. (function () {
  9314. 'use strict';
  9315. function isExpression(node) {
  9316. if (node == null) {
  9317. return false;
  9318. }
  9319. switch (node.type) {
  9320. case 'ArrayExpression':
  9321. case 'AssignmentExpression':
  9322. case 'BinaryExpression':
  9323. case 'CallExpression':
  9324. case 'ConditionalExpression':
  9325. case 'FunctionExpression':
  9326. case 'Identifier':
  9327. case 'Literal':
  9328. case 'LogicalExpression':
  9329. case 'MemberExpression':
  9330. case 'NewExpression':
  9331. case 'ObjectExpression':
  9332. case 'SequenceExpression':
  9333. case 'ThisExpression':
  9334. case 'UnaryExpression':
  9335. case 'UpdateExpression':
  9336. return true;
  9337. }
  9338. return false;
  9339. }
  9340. function isIterationStatement(node) {
  9341. if (node == null) {
  9342. return false;
  9343. }
  9344. switch (node.type) {
  9345. case 'DoWhileStatement':
  9346. case 'ForInStatement':
  9347. case 'ForStatement':
  9348. case 'WhileStatement':
  9349. return true;
  9350. }
  9351. return false;
  9352. }
  9353. function isStatement(node) {
  9354. if (node == null) {
  9355. return false;
  9356. }
  9357. switch (node.type) {
  9358. case 'BlockStatement':
  9359. case 'BreakStatement':
  9360. case 'ContinueStatement':
  9361. case 'DebuggerStatement':
  9362. case 'DoWhileStatement':
  9363. case 'EmptyStatement':
  9364. case 'ExpressionStatement':
  9365. case 'ForInStatement':
  9366. case 'ForStatement':
  9367. case 'IfStatement':
  9368. case 'LabeledStatement':
  9369. case 'ReturnStatement':
  9370. case 'SwitchStatement':
  9371. case 'ThrowStatement':
  9372. case 'TryStatement':
  9373. case 'VariableDeclaration':
  9374. case 'WhileStatement':
  9375. case 'WithStatement':
  9376. return true;
  9377. }
  9378. return false;
  9379. }
  9380. function isSourceElement(node) {
  9381. return isStatement(node) || node != null && node.type === 'FunctionDeclaration';
  9382. }
  9383. function trailingStatement(node) {
  9384. switch (node.type) {
  9385. case 'IfStatement':
  9386. if (node.alternate != null) {
  9387. return node.alternate;
  9388. }
  9389. return node.consequent;
  9390. case 'LabeledStatement':
  9391. case 'ForStatement':
  9392. case 'ForInStatement':
  9393. case 'WhileStatement':
  9394. case 'WithStatement':
  9395. return node.body;
  9396. }
  9397. return null;
  9398. }
  9399. function isProblematicIfStatement(node) {
  9400. var current;
  9401. if (node.type !== 'IfStatement') {
  9402. return false;
  9403. }
  9404. if (node.alternate == null) {
  9405. return false;
  9406. }
  9407. current = node.consequent;
  9408. do {
  9409. if (current.type === 'IfStatement') {
  9410. if (current.alternate == null) {
  9411. return true;
  9412. }
  9413. }
  9414. current = trailingStatement(current);
  9415. } while (current);
  9416. return false;
  9417. }
  9418. module.exports = {
  9419. isExpression: isExpression,
  9420. isStatement: isStatement,
  9421. isIterationStatement: isIterationStatement,
  9422. isSourceElement: isSourceElement,
  9423. isProblematicIfStatement: isProblematicIfStatement,
  9424. trailingStatement: trailingStatement
  9425. };
  9426. })();
  9427. /* vim: set sw=4 ts=4 et tw=80 : */
  9428. });
  9429. var code = createCommonjsModule(function (module) {
  9430. /*
  9431. Copyright (C) 2013-2014 Yusuke Suzuki <utatane.tea@gmail.com>
  9432. Copyright (C) 2014 Ivan Nikulin <ifaaan@gmail.com>
  9433. Redistribution and use in source and binary forms, with or without
  9434. modification, are permitted provided that the following conditions are met:
  9435. * Redistributions of source code must retain the above copyright
  9436. notice, this list of conditions and the following disclaimer.
  9437. * Redistributions in binary form must reproduce the above copyright
  9438. notice, this list of conditions and the following disclaimer in the
  9439. documentation and/or other materials provided with the distribution.
  9440. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  9441. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  9442. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  9443. ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
  9444. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  9445. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  9446. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  9447. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  9448. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  9449. THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  9450. */
  9451. (function () {
  9452. 'use strict';
  9453. var ES6Regex, ES5Regex, NON_ASCII_WHITESPACES, IDENTIFIER_START, IDENTIFIER_PART, ch; // See `tools/generate-identifier-regex.js`.
  9454. ES5Regex = {
  9455. // ECMAScript 5.1/Unicode v7.0.0 NonAsciiIdentifierStart:
  9456. 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]/,
  9457. // ECMAScript 5.1/Unicode v7.0.0 NonAsciiIdentifierPart:
  9458. 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]/
  9459. };
  9460. ES6Regex = {
  9461. // ECMAScript 6/Unicode v7.0.0 NonAsciiIdentifierStart:
  9462. 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]/,
  9463. // ECMAScript 6/Unicode v7.0.0 NonAsciiIdentifierPart:
  9464. 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]/
  9465. };
  9466. function isDecimalDigit(ch) {
  9467. return 0x30 <= ch && ch <= 0x39; // 0..9
  9468. }
  9469. function isHexDigit(ch) {
  9470. return 0x30 <= ch && ch <= 0x39 || // 0..9
  9471. 0x61 <= ch && ch <= 0x66 || // a..f
  9472. 0x41 <= ch && ch <= 0x46; // A..F
  9473. }
  9474. function isOctalDigit(ch) {
  9475. return ch >= 0x30 && ch <= 0x37; // 0..7
  9476. } // 7.2 White Space
  9477. NON_ASCII_WHITESPACES = [0x1680, 0x180E, 0x2000, 0x2001, 0x2002, 0x2003, 0x2004, 0x2005, 0x2006, 0x2007, 0x2008, 0x2009, 0x200A, 0x202F, 0x205F, 0x3000, 0xFEFF];
  9478. function isWhiteSpace(ch) {
  9479. return ch === 0x20 || ch === 0x09 || ch === 0x0B || ch === 0x0C || ch === 0xA0 || ch >= 0x1680 && NON_ASCII_WHITESPACES.indexOf(ch) >= 0;
  9480. } // 7.3 Line Terminators
  9481. function isLineTerminator(ch) {
  9482. return ch === 0x0A || ch === 0x0D || ch === 0x2028 || ch === 0x2029;
  9483. } // 7.6 Identifier Names and Identifiers
  9484. function fromCodePoint(cp) {
  9485. if (cp <= 0xFFFF) {
  9486. return String.fromCharCode(cp);
  9487. }
  9488. var cu1 = String.fromCharCode(Math.floor((cp - 0x10000) / 0x400) + 0xD800);
  9489. var cu2 = String.fromCharCode((cp - 0x10000) % 0x400 + 0xDC00);
  9490. return cu1 + cu2;
  9491. }
  9492. IDENTIFIER_START = new Array(0x80);
  9493. for (ch = 0; ch < 0x80; ++ch) {
  9494. IDENTIFIER_START[ch] = ch >= 0x61 && ch <= 0x7A || // a..z
  9495. ch >= 0x41 && ch <= 0x5A || // A..Z
  9496. ch === 0x24 || ch === 0x5F; // $ (dollar) and _ (underscore)
  9497. }
  9498. IDENTIFIER_PART = new Array(0x80);
  9499. for (ch = 0; ch < 0x80; ++ch) {
  9500. IDENTIFIER_PART[ch] = ch >= 0x61 && ch <= 0x7A || // a..z
  9501. ch >= 0x41 && ch <= 0x5A || // A..Z
  9502. ch >= 0x30 && ch <= 0x39 || // 0..9
  9503. ch === 0x24 || ch === 0x5F; // $ (dollar) and _ (underscore)
  9504. }
  9505. function isIdentifierStartES5(ch) {
  9506. return ch < 0x80 ? IDENTIFIER_START[ch] : ES5Regex.NonAsciiIdentifierStart.test(fromCodePoint(ch));
  9507. }
  9508. function isIdentifierPartES5(ch) {
  9509. return ch < 0x80 ? IDENTIFIER_PART[ch] : ES5Regex.NonAsciiIdentifierPart.test(fromCodePoint(ch));
  9510. }
  9511. function isIdentifierStartES6(ch) {
  9512. return ch < 0x80 ? IDENTIFIER_START[ch] : ES6Regex.NonAsciiIdentifierStart.test(fromCodePoint(ch));
  9513. }
  9514. function isIdentifierPartES6(ch) {
  9515. return ch < 0x80 ? IDENTIFIER_PART[ch] : ES6Regex.NonAsciiIdentifierPart.test(fromCodePoint(ch));
  9516. }
  9517. module.exports = {
  9518. isDecimalDigit: isDecimalDigit,
  9519. isHexDigit: isHexDigit,
  9520. isOctalDigit: isOctalDigit,
  9521. isWhiteSpace: isWhiteSpace,
  9522. isLineTerminator: isLineTerminator,
  9523. isIdentifierStartES5: isIdentifierStartES5,
  9524. isIdentifierPartES5: isIdentifierPartES5,
  9525. isIdentifierStartES6: isIdentifierStartES6,
  9526. isIdentifierPartES6: isIdentifierPartES6
  9527. };
  9528. })();
  9529. /* vim: set sw=4 ts=4 et tw=80 : */
  9530. });
  9531. var keyword = createCommonjsModule(function (module) {
  9532. /*
  9533. Copyright (C) 2013 Yusuke Suzuki <utatane.tea@gmail.com>
  9534. Redistribution and use in source and binary forms, with or without
  9535. modification, are permitted provided that the following conditions are met:
  9536. * Redistributions of source code must retain the above copyright
  9537. notice, this list of conditions and the following disclaimer.
  9538. * Redistributions in binary form must reproduce the above copyright
  9539. notice, this list of conditions and the following disclaimer in the
  9540. documentation and/or other materials provided with the distribution.
  9541. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  9542. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  9543. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  9544. ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
  9545. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  9546. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  9547. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  9548. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  9549. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  9550. THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  9551. */
  9552. (function () {
  9553. 'use strict';
  9554. var code$$1 = code;
  9555. function isStrictModeReservedWordES6(id) {
  9556. switch (id) {
  9557. case 'implements':
  9558. case 'interface':
  9559. case 'package':
  9560. case 'private':
  9561. case 'protected':
  9562. case 'public':
  9563. case 'static':
  9564. case 'let':
  9565. return true;
  9566. default:
  9567. return false;
  9568. }
  9569. }
  9570. function isKeywordES5(id, strict) {
  9571. // yield should not be treated as keyword under non-strict mode.
  9572. if (!strict && id === 'yield') {
  9573. return false;
  9574. }
  9575. return isKeywordES6(id, strict);
  9576. }
  9577. function isKeywordES6(id, strict) {
  9578. if (strict && isStrictModeReservedWordES6(id)) {
  9579. return true;
  9580. }
  9581. switch (id.length) {
  9582. case 2:
  9583. return id === 'if' || id === 'in' || id === 'do';
  9584. case 3:
  9585. return id === 'var' || id === 'for' || id === 'new' || id === 'try';
  9586. case 4:
  9587. return id === 'this' || id === 'else' || id === 'case' || id === 'void' || id === 'with' || id === 'enum';
  9588. case 5:
  9589. return id === 'while' || id === 'break' || id === 'catch' || id === 'throw' || id === 'const' || id === 'yield' || id === 'class' || id === 'super';
  9590. case 6:
  9591. return id === 'return' || id === 'typeof' || id === 'delete' || id === 'switch' || id === 'export' || id === 'import';
  9592. case 7:
  9593. return id === 'default' || id === 'finally' || id === 'extends';
  9594. case 8:
  9595. return id === 'function' || id === 'continue' || id === 'debugger';
  9596. case 10:
  9597. return id === 'instanceof';
  9598. default:
  9599. return false;
  9600. }
  9601. }
  9602. function isReservedWordES5(id, strict) {
  9603. return id === 'null' || id === 'true' || id === 'false' || isKeywordES5(id, strict);
  9604. }
  9605. function isReservedWordES6(id, strict) {
  9606. return id === 'null' || id === 'true' || id === 'false' || isKeywordES6(id, strict);
  9607. }
  9608. function isRestrictedWord(id) {
  9609. return id === 'eval' || id === 'arguments';
  9610. }
  9611. function isIdentifierNameES5(id) {
  9612. var i, iz, ch;
  9613. if (id.length === 0) {
  9614. return false;
  9615. }
  9616. ch = id.charCodeAt(0);
  9617. if (!code$$1.isIdentifierStartES5(ch)) {
  9618. return false;
  9619. }
  9620. for (i = 1, iz = id.length; i < iz; ++i) {
  9621. ch = id.charCodeAt(i);
  9622. if (!code$$1.isIdentifierPartES5(ch)) {
  9623. return false;
  9624. }
  9625. }
  9626. return true;
  9627. }
  9628. function decodeUtf16(lead, trail) {
  9629. return (lead - 0xD800) * 0x400 + (trail - 0xDC00) + 0x10000;
  9630. }
  9631. function isIdentifierNameES6(id) {
  9632. var i, iz, ch, lowCh, check;
  9633. if (id.length === 0) {
  9634. return false;
  9635. }
  9636. check = code$$1.isIdentifierStartES6;
  9637. for (i = 0, iz = id.length; i < iz; ++i) {
  9638. ch = id.charCodeAt(i);
  9639. if (0xD800 <= ch && ch <= 0xDBFF) {
  9640. ++i;
  9641. if (i >= iz) {
  9642. return false;
  9643. }
  9644. lowCh = id.charCodeAt(i);
  9645. if (!(0xDC00 <= lowCh && lowCh <= 0xDFFF)) {
  9646. return false;
  9647. }
  9648. ch = decodeUtf16(ch, lowCh);
  9649. }
  9650. if (!check(ch)) {
  9651. return false;
  9652. }
  9653. check = code$$1.isIdentifierPartES6;
  9654. }
  9655. return true;
  9656. }
  9657. function isIdentifierES5(id, strict) {
  9658. return isIdentifierNameES5(id) && !isReservedWordES5(id, strict);
  9659. }
  9660. function isIdentifierES6(id, strict) {
  9661. return isIdentifierNameES6(id) && !isReservedWordES6(id, strict);
  9662. }
  9663. module.exports = {
  9664. isKeywordES5: isKeywordES5,
  9665. isKeywordES6: isKeywordES6,
  9666. isReservedWordES5: isReservedWordES5,
  9667. isReservedWordES6: isReservedWordES6,
  9668. isRestrictedWord: isRestrictedWord,
  9669. isIdentifierNameES5: isIdentifierNameES5,
  9670. isIdentifierNameES6: isIdentifierNameES6,
  9671. isIdentifierES5: isIdentifierES5,
  9672. isIdentifierES6: isIdentifierES6
  9673. };
  9674. })();
  9675. /* vim: set sw=4 ts=4 et tw=80 : */
  9676. });
  9677. var utils$2 = createCommonjsModule(function (module, exports) {
  9678. /*
  9679. Copyright (C) 2013 Yusuke Suzuki <utatane.tea@gmail.com>
  9680. Redistribution and use in source and binary forms, with or without
  9681. modification, are permitted provided that the following conditions are met:
  9682. * Redistributions of source code must retain the above copyright
  9683. notice, this list of conditions and the following disclaimer.
  9684. * Redistributions in binary form must reproduce the above copyright
  9685. notice, this list of conditions and the following disclaimer in the
  9686. documentation and/or other materials provided with the distribution.
  9687. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  9688. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  9689. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  9690. ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
  9691. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  9692. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  9693. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  9694. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  9695. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  9696. THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  9697. */
  9698. (function () {
  9699. 'use strict';
  9700. exports.ast = ast;
  9701. exports.code = code;
  9702. exports.keyword = keyword;
  9703. })();
  9704. /* vim: set sw=4 ts=4 et tw=80 : */
  9705. });
  9706. var hasFlag$6 = createCommonjsModule(function (module) {
  9707. 'use strict';
  9708. module.exports = function (flag, argv$$1) {
  9709. argv$$1 = argv$$1 || process.argv;
  9710. var prefix = flag.startsWith('-') ? '' : flag.length === 1 ? '-' : '--';
  9711. var pos = argv$$1.indexOf(prefix + flag);
  9712. var terminatorPos = argv$$1.indexOf('--');
  9713. return pos !== -1 && (terminatorPos === -1 ? true : pos < terminatorPos);
  9714. };
  9715. });
  9716. var env$2 = process.env;
  9717. var forceColor$1;
  9718. if (hasFlag$6('no-color') || hasFlag$6('no-colors') || hasFlag$6('color=false')) {
  9719. forceColor$1 = false;
  9720. } else if (hasFlag$6('color') || hasFlag$6('colors') || hasFlag$6('color=true') || hasFlag$6('color=always')) {
  9721. forceColor$1 = true;
  9722. }
  9723. if ('FORCE_COLOR' in env$2) {
  9724. forceColor$1 = env$2.FORCE_COLOR.length === 0 || parseInt(env$2.FORCE_COLOR, 10) !== 0;
  9725. }
  9726. function translateLevel$1(level) {
  9727. if (level === 0) {
  9728. return false;
  9729. }
  9730. return {
  9731. level: level,
  9732. hasBasic: true,
  9733. has256: level >= 2,
  9734. has16m: level >= 3
  9735. };
  9736. }
  9737. function supportsColor$4(stream) {
  9738. if (forceColor$1 === false) {
  9739. return 0;
  9740. }
  9741. if (hasFlag$6('color=16m') || hasFlag$6('color=full') || hasFlag$6('color=truecolor')) {
  9742. return 3;
  9743. }
  9744. if (hasFlag$6('color=256')) {
  9745. return 2;
  9746. }
  9747. if (stream && !stream.isTTY && forceColor$1 !== true) {
  9748. return 0;
  9749. }
  9750. var min = forceColor$1 ? 1 : 0;
  9751. if (process.platform === 'win32') {
  9752. // Node.js 7.5.0 is the first version of Node.js to include a patch to
  9753. // libuv that enables 256 color output on Windows. Anything earlier and it
  9754. // won't work. However, here we target Node.js 8 at minimum as it is an LTS
  9755. // release, and Node.js 7 is not. Windows 10 build 10586 is the first Windows
  9756. // release that supports 256 colors. Windows 10 build 14931 is the first release
  9757. // that supports 16m/TrueColor.
  9758. var osRelease = require$$1$1.release().split('.');
  9759. if (Number(process.versions.node.split('.')[0]) >= 8 && Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
  9760. return Number(osRelease[2]) >= 14931 ? 3 : 2;
  9761. }
  9762. return 1;
  9763. }
  9764. if ('CI' in env$2) {
  9765. if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI'].some(function (sign) {
  9766. return sign in env$2;
  9767. }) || env$2.CI_NAME === 'codeship') {
  9768. return 1;
  9769. }
  9770. return min;
  9771. }
  9772. if ('TEAMCITY_VERSION' in env$2) {
  9773. return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env$2.TEAMCITY_VERSION) ? 1 : 0;
  9774. }
  9775. if (env$2.COLORTERM === 'truecolor') {
  9776. return 3;
  9777. }
  9778. if ('TERM_PROGRAM' in env$2) {
  9779. var version = parseInt((env$2.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
  9780. switch (env$2.TERM_PROGRAM) {
  9781. case 'iTerm.app':
  9782. return version >= 3 ? 3 : 2;
  9783. case 'Apple_Terminal':
  9784. return 2;
  9785. // No default
  9786. }
  9787. }
  9788. if (/-256(color)?$/i.test(env$2.TERM)) {
  9789. return 2;
  9790. }
  9791. if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env$2.TERM)) {
  9792. return 1;
  9793. }
  9794. if ('COLORTERM' in env$2) {
  9795. return 1;
  9796. }
  9797. if (env$2.TERM === 'dumb') {
  9798. return min;
  9799. }
  9800. return min;
  9801. }
  9802. function getSupportLevel$1(stream) {
  9803. var level = supportsColor$4(stream);
  9804. return translateLevel$1(level);
  9805. }
  9806. var supportsColor_1$3 = {
  9807. supportsColor: getSupportLevel$1,
  9808. stdout: getSupportLevel$1(process.stdout),
  9809. stderr: getSupportLevel$1(process.stderr)
  9810. };
  9811. var templates$4 = createCommonjsModule(function (module) {
  9812. 'use strict';
  9813. var TEMPLATE_REGEX = /(?:\\(u[a-f\d]{4}|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi;
  9814. var STYLE_REGEX = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g;
  9815. var STRING_REGEX = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/;
  9816. var ESCAPE_REGEX = /\\(u[a-f\d]{4}|x[a-f\d]{2}|.)|([^\\])/gi;
  9817. var ESCAPES = new Map([['n', '\n'], ['r', '\r'], ['t', '\t'], ['b', '\b'], ['f', '\f'], ['v', '\v'], ['0', '\0'], ['\\', '\\'], ['e', "\x1B"], ['a', "\x07"]]);
  9818. function unescape(c) {
  9819. if (c[0] === 'u' && c.length === 5 || c[0] === 'x' && c.length === 3) {
  9820. return String.fromCharCode(parseInt(c.slice(1), 16));
  9821. }
  9822. return ESCAPES.get(c) || c;
  9823. }
  9824. function parseArguments(name, args) {
  9825. var results = [];
  9826. var chunks = args.trim().split(/\s*,\s*/g);
  9827. var matches;
  9828. var _iteratorNormalCompletion = true;
  9829. var _didIteratorError = false;
  9830. var _iteratorError = undefined;
  9831. try {
  9832. for (var _iterator = chunks[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  9833. var chunk = _step.value;
  9834. if (!isNaN(chunk)) {
  9835. results.push(Number(chunk));
  9836. } else if (matches = chunk.match(STRING_REGEX)) {
  9837. results.push(matches[2].replace(ESCAPE_REGEX, function (m, escape, chr) {
  9838. return escape ? unescape(escape) : chr;
  9839. }));
  9840. } else {
  9841. throw new Error("Invalid Chalk template style argument: ".concat(chunk, " (in style '").concat(name, "')"));
  9842. }
  9843. }
  9844. } catch (err) {
  9845. _didIteratorError = true;
  9846. _iteratorError = err;
  9847. } finally {
  9848. try {
  9849. if (!_iteratorNormalCompletion && _iterator.return != null) {
  9850. _iterator.return();
  9851. }
  9852. } finally {
  9853. if (_didIteratorError) {
  9854. throw _iteratorError;
  9855. }
  9856. }
  9857. }
  9858. return results;
  9859. }
  9860. function parseStyle(style) {
  9861. STYLE_REGEX.lastIndex = 0;
  9862. var results = [];
  9863. var matches;
  9864. while ((matches = STYLE_REGEX.exec(style)) !== null) {
  9865. var name = matches[1];
  9866. if (matches[2]) {
  9867. var args = parseArguments(name, matches[2]);
  9868. results.push([name].concat(args));
  9869. } else {
  9870. results.push([name]);
  9871. }
  9872. }
  9873. return results;
  9874. }
  9875. function buildStyle(chalk, styles) {
  9876. var enabled = {};
  9877. var _iteratorNormalCompletion2 = true;
  9878. var _didIteratorError2 = false;
  9879. var _iteratorError2 = undefined;
  9880. try {
  9881. for (var _iterator2 = styles[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
  9882. var layer = _step2.value;
  9883. var _iteratorNormalCompletion3 = true;
  9884. var _didIteratorError3 = false;
  9885. var _iteratorError3 = undefined;
  9886. try {
  9887. for (var _iterator3 = layer.styles[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
  9888. var style = _step3.value;
  9889. enabled[style[0]] = layer.inverse ? null : style.slice(1);
  9890. }
  9891. } catch (err) {
  9892. _didIteratorError3 = true;
  9893. _iteratorError3 = err;
  9894. } finally {
  9895. try {
  9896. if (!_iteratorNormalCompletion3 && _iterator3.return != null) {
  9897. _iterator3.return();
  9898. }
  9899. } finally {
  9900. if (_didIteratorError3) {
  9901. throw _iteratorError3;
  9902. }
  9903. }
  9904. }
  9905. }
  9906. } catch (err) {
  9907. _didIteratorError2 = true;
  9908. _iteratorError2 = err;
  9909. } finally {
  9910. try {
  9911. if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
  9912. _iterator2.return();
  9913. }
  9914. } finally {
  9915. if (_didIteratorError2) {
  9916. throw _iteratorError2;
  9917. }
  9918. }
  9919. }
  9920. var current = chalk;
  9921. var _arr = Object.keys(enabled);
  9922. for (var _i = 0; _i < _arr.length; _i++) {
  9923. var styleName = _arr[_i];
  9924. if (Array.isArray(enabled[styleName])) {
  9925. if (!(styleName in current)) {
  9926. throw new Error("Unknown Chalk style: ".concat(styleName));
  9927. }
  9928. if (enabled[styleName].length > 0) {
  9929. current = current[styleName].apply(current, enabled[styleName]);
  9930. } else {
  9931. current = current[styleName];
  9932. }
  9933. }
  9934. }
  9935. return current;
  9936. }
  9937. module.exports = function (chalk, tmp) {
  9938. var styles = [];
  9939. var chunks = [];
  9940. var chunk = []; // eslint-disable-next-line max-params
  9941. tmp.replace(TEMPLATE_REGEX, function (m, escapeChar, inverse, style, close, chr) {
  9942. if (escapeChar) {
  9943. chunk.push(unescape(escapeChar));
  9944. } else if (style) {
  9945. var str = chunk.join('');
  9946. chunk = [];
  9947. chunks.push(styles.length === 0 ? str : buildStyle(chalk, styles)(str));
  9948. styles.push({
  9949. inverse: inverse,
  9950. styles: parseStyle(style)
  9951. });
  9952. } else if (close) {
  9953. if (styles.length === 0) {
  9954. throw new Error('Found extraneous } in Chalk template literal');
  9955. }
  9956. chunks.push(buildStyle(chalk, styles)(chunk.join('')));
  9957. chunk = [];
  9958. styles.pop();
  9959. } else {
  9960. chunk.push(chr);
  9961. }
  9962. });
  9963. chunks.push(chunk.join(''));
  9964. if (styles.length > 0) {
  9965. var errMsg = "Chalk template literal is missing ".concat(styles.length, " closing bracket").concat(styles.length === 1 ? '' : 's', " (`}`)");
  9966. throw new Error(errMsg);
  9967. }
  9968. return chunks.join('');
  9969. };
  9970. });
  9971. var chalk$5 = createCommonjsModule(function (module) {
  9972. 'use strict';
  9973. var stdoutColor = supportsColor_1$3.stdout;
  9974. var isSimpleWindowsTerm = process.platform === 'win32' && !(process.env.TERM || '').toLowerCase().startsWith('xterm'); // `supportsColor.level` → `ansiStyles.color[name]` mapping
  9975. var levelMapping = ['ansi', 'ansi', 'ansi256', 'ansi16m']; // `color-convert` models to exclude from the Chalk API due to conflicts and such
  9976. var skipModels = new Set(['gray']);
  9977. var styles = Object.create(null);
  9978. function applyOptions(obj, options) {
  9979. options = options || {}; // Detect level if not set manually
  9980. var scLevel = stdoutColor ? stdoutColor.level : 0;
  9981. obj.level = options.level === undefined ? scLevel : options.level;
  9982. obj.enabled = 'enabled' in options ? options.enabled : obj.level > 0;
  9983. }
  9984. function Chalk(options) {
  9985. // We check for this.template here since calling `chalk.constructor()`
  9986. // by itself will have a `this` of a previously constructed chalk object
  9987. if (!this || !(this instanceof Chalk) || this.template) {
  9988. var _chalk = {};
  9989. applyOptions(_chalk, options);
  9990. _chalk.template = function () {
  9991. var args = [].slice.call(arguments);
  9992. return chalkTag.apply(null, [_chalk.template].concat(args));
  9993. };
  9994. Object.setPrototypeOf(_chalk, Chalk.prototype);
  9995. Object.setPrototypeOf(_chalk.template, _chalk);
  9996. _chalk.template.constructor = Chalk;
  9997. return _chalk.template;
  9998. }
  9999. applyOptions(this, options);
  10000. } // Use bright blue on Windows as the normal blue color is illegible
  10001. if (isSimpleWindowsTerm) {
  10002. ansiStyles.blue.open = "\x1B[94m";
  10003. }
  10004. var _arr = Object.keys(ansiStyles);
  10005. var _loop = function _loop() {
  10006. var key = _arr[_i];
  10007. ansiStyles[key].closeRe = new RegExp(escapeStringRegexp(ansiStyles[key].close), 'g');
  10008. styles[key] = {
  10009. get: function get() {
  10010. var codes = ansiStyles[key];
  10011. return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, key);
  10012. }
  10013. };
  10014. };
  10015. for (var _i = 0; _i < _arr.length; _i++) {
  10016. _loop();
  10017. }
  10018. styles.visible = {
  10019. get: function get() {
  10020. return build.call(this, this._styles || [], true, 'visible');
  10021. }
  10022. };
  10023. ansiStyles.color.closeRe = new RegExp(escapeStringRegexp(ansiStyles.color.close), 'g');
  10024. var _arr2 = Object.keys(ansiStyles.color.ansi);
  10025. var _loop2 = function _loop2() {
  10026. var model = _arr2[_i2];
  10027. if (skipModels.has(model)) {
  10028. return "continue";
  10029. }
  10030. styles[model] = {
  10031. get: function get() {
  10032. var level = this.level;
  10033. return function () {
  10034. var open = ansiStyles.color[levelMapping[level]][model].apply(null, arguments);
  10035. var codes = {
  10036. open: open,
  10037. close: ansiStyles.color.close,
  10038. closeRe: ansiStyles.color.closeRe
  10039. };
  10040. return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, model);
  10041. };
  10042. }
  10043. };
  10044. };
  10045. for (var _i2 = 0; _i2 < _arr2.length; _i2++) {
  10046. var _ret = _loop2();
  10047. if (_ret === "continue") continue;
  10048. }
  10049. ansiStyles.bgColor.closeRe = new RegExp(escapeStringRegexp(ansiStyles.bgColor.close), 'g');
  10050. var _arr3 = Object.keys(ansiStyles.bgColor.ansi);
  10051. var _loop3 = function _loop3() {
  10052. var model = _arr3[_i3];
  10053. if (skipModels.has(model)) {
  10054. return "continue";
  10055. }
  10056. var bgModel = 'bg' + model[0].toUpperCase() + model.slice(1);
  10057. styles[bgModel] = {
  10058. get: function get() {
  10059. var level = this.level;
  10060. return function () {
  10061. var open = ansiStyles.bgColor[levelMapping[level]][model].apply(null, arguments);
  10062. var codes = {
  10063. open: open,
  10064. close: ansiStyles.bgColor.close,
  10065. closeRe: ansiStyles.bgColor.closeRe
  10066. };
  10067. return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, model);
  10068. };
  10069. }
  10070. };
  10071. };
  10072. for (var _i3 = 0; _i3 < _arr3.length; _i3++) {
  10073. var _ret2 = _loop3();
  10074. if (_ret2 === "continue") continue;
  10075. }
  10076. var proto = Object.defineProperties(function () {}, styles);
  10077. function build(_styles, _empty, key) {
  10078. var builder = function builder() {
  10079. return applyStyle.apply(builder, arguments);
  10080. };
  10081. builder._styles = _styles;
  10082. builder._empty = _empty;
  10083. var self = this;
  10084. Object.defineProperty(builder, 'level', {
  10085. enumerable: true,
  10086. get: function get() {
  10087. return self.level;
  10088. },
  10089. set: function set(level) {
  10090. self.level = level;
  10091. }
  10092. });
  10093. Object.defineProperty(builder, 'enabled', {
  10094. enumerable: true,
  10095. get: function get() {
  10096. return self.enabled;
  10097. },
  10098. set: function set(enabled) {
  10099. self.enabled = enabled;
  10100. }
  10101. }); // See below for fix regarding invisible grey/dim combination on Windows
  10102. builder.hasGrey = this.hasGrey || key === 'gray' || key === 'grey'; // `__proto__` is used because we must return a function, but there is
  10103. // no way to create a function with a different prototype
  10104. builder.__proto__ = proto; // eslint-disable-line no-proto
  10105. return builder;
  10106. }
  10107. function applyStyle() {
  10108. // Support varags, but simply cast to string in case there's only one arg
  10109. var args = arguments;
  10110. var argsLen = args.length;
  10111. var str = String(arguments[0]);
  10112. if (argsLen === 0) {
  10113. return '';
  10114. }
  10115. if (argsLen > 1) {
  10116. // Don't slice `arguments`, it prevents V8 optimizations
  10117. for (var a = 1; a < argsLen; a++) {
  10118. str += ' ' + args[a];
  10119. }
  10120. }
  10121. if (!this.enabled || this.level <= 0 || !str) {
  10122. return this._empty ? '' : str;
  10123. } // Turns out that on Windows dimmed gray text becomes invisible in cmd.exe,
  10124. // see https://github.com/chalk/chalk/issues/58
  10125. // If we're on Windows and we're dealing with a gray color, temporarily make 'dim' a noop.
  10126. var originalDim = ansiStyles.dim.open;
  10127. if (isSimpleWindowsTerm && this.hasGrey) {
  10128. ansiStyles.dim.open = '';
  10129. }
  10130. var _iteratorNormalCompletion = true;
  10131. var _didIteratorError = false;
  10132. var _iteratorError = undefined;
  10133. try {
  10134. for (var _iterator = this._styles.slice().reverse()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  10135. var code = _step.value;
  10136. // Replace any instances already present with a re-opening code
  10137. // otherwise only the part of the string until said closing code
  10138. // will be colored, and the rest will simply be 'plain'.
  10139. str = code.open + str.replace(code.closeRe, code.open) + code.close; // Close the styling before a linebreak and reopen
  10140. // after next line to fix a bleed issue on macOS
  10141. // https://github.com/chalk/chalk/pull/92
  10142. str = str.replace(/\r?\n/g, "".concat(code.close, "$&").concat(code.open));
  10143. } // Reset the original `dim` if we changed it to work around the Windows dimmed gray issue
  10144. } catch (err) {
  10145. _didIteratorError = true;
  10146. _iteratorError = err;
  10147. } finally {
  10148. try {
  10149. if (!_iteratorNormalCompletion && _iterator.return != null) {
  10150. _iterator.return();
  10151. }
  10152. } finally {
  10153. if (_didIteratorError) {
  10154. throw _iteratorError;
  10155. }
  10156. }
  10157. }
  10158. ansiStyles.dim.open = originalDim;
  10159. return str;
  10160. }
  10161. function chalkTag(chalk, strings) {
  10162. if (!Array.isArray(strings)) {
  10163. // If chalk() was called by itself or with a string,
  10164. // return the string itself as a string.
  10165. return [].slice.call(arguments, 1).join(' ');
  10166. }
  10167. var args = [].slice.call(arguments, 2);
  10168. var parts = [strings.raw[0]];
  10169. for (var i = 1; i < strings.length; i++) {
  10170. parts.push(String(args[i - 1]).replace(/[{}\\]/g, '\\$&'));
  10171. parts.push(String(strings.raw[i]));
  10172. }
  10173. return templates$4(chalk, parts.join(''));
  10174. }
  10175. Object.defineProperties(Chalk.prototype, styles);
  10176. module.exports = Chalk(); // eslint-disable-line new-cap
  10177. module.exports.supportsColor = stdoutColor;
  10178. module.exports.default = module.exports; // For TypeScript
  10179. });
  10180. var lib$3 = createCommonjsModule(function (module, exports) {
  10181. "use strict";
  10182. Object.defineProperty(exports, "__esModule", {
  10183. value: true
  10184. });
  10185. exports.shouldHighlight = shouldHighlight;
  10186. exports.getChalk = getChalk;
  10187. exports.default = highlight;
  10188. function _jsTokens() {
  10189. var data = _interopRequireWildcard$$1(jsTokens);
  10190. _jsTokens = function _jsTokens() {
  10191. return data;
  10192. };
  10193. return data;
  10194. }
  10195. function _esutils() {
  10196. var data = _interopRequireDefault$$1(utils$2);
  10197. _esutils = function _esutils() {
  10198. return data;
  10199. };
  10200. return data;
  10201. }
  10202. function _chalk() {
  10203. var data = _interopRequireDefault$$1(chalk$5);
  10204. _chalk = function _chalk() {
  10205. return data;
  10206. };
  10207. return data;
  10208. }
  10209. function _interopRequireDefault$$1(obj) {
  10210. return obj && obj.__esModule ? obj : {
  10211. default: obj
  10212. };
  10213. }
  10214. function _interopRequireWildcard$$1(obj) {
  10215. if (obj && obj.__esModule) {
  10216. return obj;
  10217. } else {
  10218. var newObj = {};
  10219. if (obj != null) {
  10220. for (var key in obj) {
  10221. if (Object.prototype.hasOwnProperty.call(obj, key)) {
  10222. var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {};
  10223. if (desc.get || desc.set) {
  10224. Object.defineProperty(newObj, key, desc);
  10225. } else {
  10226. newObj[key] = obj[key];
  10227. }
  10228. }
  10229. }
  10230. }
  10231. newObj.default = obj;
  10232. return newObj;
  10233. }
  10234. }
  10235. function getDefs(chalk) {
  10236. return {
  10237. keyword: chalk.cyan,
  10238. capitalized: chalk.yellow,
  10239. jsx_tag: chalk.yellow,
  10240. punctuator: chalk.yellow,
  10241. number: chalk.magenta,
  10242. string: chalk.green,
  10243. regex: chalk.magenta,
  10244. comment: chalk.grey,
  10245. invalid: chalk.white.bgRed.bold
  10246. };
  10247. }
  10248. var NEWLINE = /\r\n|[\n\r\u2028\u2029]/;
  10249. var JSX_TAG = /^[a-z][\w-]*$/i;
  10250. var BRACKET = /^[()[\]{}]$/;
  10251. function getTokenType(match) {
  10252. var _match$slice = match.slice(-2),
  10253. _match$slice2 = _slicedToArray(_match$slice, 2),
  10254. offset = _match$slice2[0],
  10255. text = _match$slice2[1];
  10256. var token = (0, _jsTokens().matchToToken)(match);
  10257. if (token.type === "name") {
  10258. if (_esutils().default.keyword.isReservedWordES6(token.value)) {
  10259. return "keyword";
  10260. }
  10261. if (JSX_TAG.test(token.value) && (text[offset - 1] === "<" || text.substr(offset - 2, 2) == "</")) {
  10262. return "jsx_tag";
  10263. }
  10264. if (token.value[0] !== token.value[0].toLowerCase()) {
  10265. return "capitalized";
  10266. }
  10267. }
  10268. if (token.type === "punctuator" && BRACKET.test(token.value)) {
  10269. return "bracket";
  10270. }
  10271. if (token.type === "invalid" && (token.value === "@" || token.value === "#")) {
  10272. return "punctuator";
  10273. }
  10274. return token.type;
  10275. }
  10276. function highlightTokens(defs, text) {
  10277. return text.replace(_jsTokens().default, function () {
  10278. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  10279. args[_key] = arguments[_key];
  10280. }
  10281. var type = getTokenType(args);
  10282. var colorize = defs[type];
  10283. if (colorize) {
  10284. return args[0].split(NEWLINE).map(function (str) {
  10285. return colorize(str);
  10286. }).join("\n");
  10287. } else {
  10288. return args[0];
  10289. }
  10290. });
  10291. }
  10292. function shouldHighlight(options) {
  10293. return _chalk().default.supportsColor || options.forceColor;
  10294. }
  10295. function getChalk(options) {
  10296. var chalk = _chalk().default;
  10297. if (options.forceColor) {
  10298. chalk = new (_chalk().default.constructor)({
  10299. enabled: true,
  10300. level: 1
  10301. });
  10302. }
  10303. return chalk;
  10304. }
  10305. function highlight(code) {
  10306. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  10307. if (shouldHighlight(options)) {
  10308. var chalk = getChalk(options);
  10309. var defs = getDefs(chalk);
  10310. return highlightTokens(defs, code);
  10311. } else {
  10312. return code;
  10313. }
  10314. }
  10315. });
  10316. unwrapExports(lib$3);
  10317. var lib$2 = createCommonjsModule(function (module, exports) {
  10318. "use strict";
  10319. Object.defineProperty(exports, "__esModule", {
  10320. value: true
  10321. });
  10322. exports.codeFrameColumns = codeFrameColumns;
  10323. exports.default = _default;
  10324. function _highlight() {
  10325. var data = _interopRequireWildcard(lib$3);
  10326. _highlight = function _highlight() {
  10327. return data;
  10328. };
  10329. return data;
  10330. }
  10331. function _interopRequireWildcard(obj) {
  10332. if (obj && obj.__esModule) {
  10333. return obj;
  10334. } else {
  10335. var newObj = {};
  10336. if (obj != null) {
  10337. for (var key in obj) {
  10338. if (Object.prototype.hasOwnProperty.call(obj, key)) {
  10339. var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {};
  10340. if (desc.get || desc.set) {
  10341. Object.defineProperty(newObj, key, desc);
  10342. } else {
  10343. newObj[key] = obj[key];
  10344. }
  10345. }
  10346. }
  10347. }
  10348. newObj.default = obj;
  10349. return newObj;
  10350. }
  10351. }
  10352. var deprecationWarningShown = false;
  10353. function getDefs(chalk) {
  10354. return {
  10355. gutter: chalk.grey,
  10356. marker: chalk.red.bold,
  10357. message: chalk.red.bold
  10358. };
  10359. }
  10360. var NEWLINE = /\r\n|[\n\r\u2028\u2029]/;
  10361. function getMarkerLines(loc, source, opts) {
  10362. var startLoc = Object.assign({
  10363. column: 0,
  10364. line: -1
  10365. }, loc.start);
  10366. var endLoc = Object.assign({}, startLoc, loc.end);
  10367. var _ref = opts || {},
  10368. _ref$linesAbove = _ref.linesAbove,
  10369. linesAbove = _ref$linesAbove === void 0 ? 2 : _ref$linesAbove,
  10370. _ref$linesBelow = _ref.linesBelow,
  10371. linesBelow = _ref$linesBelow === void 0 ? 3 : _ref$linesBelow;
  10372. var startLine = startLoc.line;
  10373. var startColumn = startLoc.column;
  10374. var endLine = endLoc.line;
  10375. var endColumn = endLoc.column;
  10376. var start = Math.max(startLine - (linesAbove + 1), 0);
  10377. var end = Math.min(source.length, endLine + linesBelow);
  10378. if (startLine === -1) {
  10379. start = 0;
  10380. }
  10381. if (endLine === -1) {
  10382. end = source.length;
  10383. }
  10384. var lineDiff = endLine - startLine;
  10385. var markerLines = {};
  10386. if (lineDiff) {
  10387. for (var i = 0; i <= lineDiff; i++) {
  10388. var lineNumber = i + startLine;
  10389. if (!startColumn) {
  10390. markerLines[lineNumber] = true;
  10391. } else if (i === 0) {
  10392. var sourceLength = source[lineNumber - 1].length;
  10393. markerLines[lineNumber] = [startColumn, sourceLength - startColumn];
  10394. } else if (i === lineDiff) {
  10395. markerLines[lineNumber] = [0, endColumn];
  10396. } else {
  10397. var _sourceLength = source[lineNumber - i].length;
  10398. markerLines[lineNumber] = [0, _sourceLength];
  10399. }
  10400. }
  10401. } else {
  10402. if (startColumn === endColumn) {
  10403. if (startColumn) {
  10404. markerLines[startLine] = [startColumn, 0];
  10405. } else {
  10406. markerLines[startLine] = true;
  10407. }
  10408. } else {
  10409. markerLines[startLine] = [startColumn, endColumn - startColumn];
  10410. }
  10411. }
  10412. return {
  10413. start: start,
  10414. end: end,
  10415. markerLines: markerLines
  10416. };
  10417. }
  10418. function codeFrameColumns(rawLines, loc) {
  10419. var opts = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  10420. var highlighted = (opts.highlightCode || opts.forceColor) && (0, _highlight().shouldHighlight)(opts);
  10421. var chalk = (0, _highlight().getChalk)(opts);
  10422. var defs = getDefs(chalk);
  10423. var maybeHighlight = function maybeHighlight(chalkFn, string) {
  10424. return highlighted ? chalkFn(string) : string;
  10425. };
  10426. if (highlighted) rawLines = (0, _highlight().default)(rawLines, opts);
  10427. var lines = rawLines.split(NEWLINE);
  10428. var _getMarkerLines = getMarkerLines(loc, lines, opts),
  10429. start = _getMarkerLines.start,
  10430. end = _getMarkerLines.end,
  10431. markerLines = _getMarkerLines.markerLines;
  10432. var hasColumns = loc.start && typeof loc.start.column === "number";
  10433. var numberMaxWidth = String(end).length;
  10434. var frame = lines.slice(start, end).map(function (line, index) {
  10435. var number = start + 1 + index;
  10436. var paddedNumber = " ".concat(number).slice(-numberMaxWidth);
  10437. var gutter = " ".concat(paddedNumber, " | ");
  10438. var hasMarker = markerLines[number];
  10439. var lastMarkerLine = !markerLines[number + 1];
  10440. if (hasMarker) {
  10441. var markerLine = "";
  10442. if (Array.isArray(hasMarker)) {
  10443. var markerSpacing = line.slice(0, Math.max(hasMarker[0] - 1, 0)).replace(/[^\t]/g, " ");
  10444. var numberOfMarkers = hasMarker[1] || 1;
  10445. markerLine = ["\n ", maybeHighlight(defs.gutter, gutter.replace(/\d/g, " ")), markerSpacing, maybeHighlight(defs.marker, "^").repeat(numberOfMarkers)].join("");
  10446. if (lastMarkerLine && opts.message) {
  10447. markerLine += " " + maybeHighlight(defs.message, opts.message);
  10448. }
  10449. }
  10450. return [maybeHighlight(defs.marker, ">"), maybeHighlight(defs.gutter, gutter), line, markerLine].join("");
  10451. } else {
  10452. return " ".concat(maybeHighlight(defs.gutter, gutter)).concat(line);
  10453. }
  10454. }).join("\n");
  10455. if (opts.message && !hasColumns) {
  10456. frame = "".concat(" ".repeat(numberMaxWidth + 1)).concat(opts.message, "\n").concat(frame);
  10457. }
  10458. if (highlighted) {
  10459. return chalk.reset(frame);
  10460. } else {
  10461. return frame;
  10462. }
  10463. }
  10464. function _default(rawLines, lineNumber, colNumber) {
  10465. var opts = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
  10466. if (!deprecationWarningShown) {
  10467. deprecationWarningShown = true;
  10468. var message = "Passing lineNumber and colNumber is deprecated to @babel/code-frame. Please use `codeFrameColumns`.";
  10469. if (process.emitWarning) {
  10470. process.emitWarning(message, "DeprecationWarning");
  10471. } else {
  10472. var deprecationError = new Error(message);
  10473. deprecationError.name = "DeprecationWarning";
  10474. console.warn(new Error(message));
  10475. }
  10476. }
  10477. colNumber = Math.max(colNumber, 0);
  10478. var location = {
  10479. start: {
  10480. column: colNumber,
  10481. line: lineNumber
  10482. }
  10483. };
  10484. return codeFrameColumns(rawLines, location, opts);
  10485. }
  10486. });
  10487. unwrapExports(lib$2);
  10488. var ConfigError$1 = errors.ConfigError;
  10489. var locStart = loc.locStart;
  10490. var locEnd = loc.locEnd; // Use defineProperties()/getOwnPropertyDescriptor() to prevent
  10491. // triggering the parsers getters.
  10492. var ownNames = Object.getOwnPropertyNames;
  10493. var ownDescriptor = Object.getOwnPropertyDescriptor;
  10494. function getParsers(options) {
  10495. var parsers = {};
  10496. var _iteratorNormalCompletion = true;
  10497. var _didIteratorError = false;
  10498. var _iteratorError = undefined;
  10499. try {
  10500. for (var _iterator = options.plugins[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  10501. var plugin = _step.value;
  10502. if (!plugin.parsers) {
  10503. continue;
  10504. }
  10505. var _iteratorNormalCompletion2 = true;
  10506. var _didIteratorError2 = false;
  10507. var _iteratorError2 = undefined;
  10508. try {
  10509. for (var _iterator2 = ownNames(plugin.parsers)[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
  10510. var name = _step2.value;
  10511. Object.defineProperty(parsers, name, ownDescriptor(plugin.parsers, name));
  10512. }
  10513. } catch (err) {
  10514. _didIteratorError2 = true;
  10515. _iteratorError2 = err;
  10516. } finally {
  10517. try {
  10518. if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
  10519. _iterator2.return();
  10520. }
  10521. } finally {
  10522. if (_didIteratorError2) {
  10523. throw _iteratorError2;
  10524. }
  10525. }
  10526. }
  10527. }
  10528. } catch (err) {
  10529. _didIteratorError = true;
  10530. _iteratorError = err;
  10531. } finally {
  10532. try {
  10533. if (!_iteratorNormalCompletion && _iterator.return != null) {
  10534. _iterator.return();
  10535. }
  10536. } finally {
  10537. if (_didIteratorError) {
  10538. throw _iteratorError;
  10539. }
  10540. }
  10541. }
  10542. return parsers;
  10543. }
  10544. function resolveParser$1(opts, parsers) {
  10545. parsers = parsers || getParsers(opts);
  10546. if (typeof opts.parser === "function") {
  10547. // Custom parser API always works with JavaScript.
  10548. return {
  10549. parse: opts.parser,
  10550. astFormat: "estree",
  10551. locStart: locStart,
  10552. locEnd: locEnd
  10553. };
  10554. }
  10555. if (typeof opts.parser === "string") {
  10556. if (parsers.hasOwnProperty(opts.parser)) {
  10557. return parsers[opts.parser];
  10558. }
  10559. /* istanbul ignore next */
  10560. {
  10561. throw new ConfigError$1("Couldn't resolve parser \"".concat(opts.parser, "\". Parsers must be explicitly added to the standalone bundle."));
  10562. }
  10563. }
  10564. }
  10565. function parse$2(text, opts) {
  10566. var parsers = getParsers(opts); // Create a new object {parserName: parseFn}. Uses defineProperty() to only call
  10567. // the parsers getters when actually calling the parser `parse` function.
  10568. var parsersForCustomParserApi = Object.keys(parsers).reduce(function (object, parserName) {
  10569. return Object.defineProperty(object, parserName, {
  10570. enumerable: true,
  10571. get: function get() {
  10572. return parsers[parserName].parse;
  10573. }
  10574. });
  10575. }, {});
  10576. var parser = resolveParser$1(opts, parsers);
  10577. try {
  10578. if (parser.preprocess) {
  10579. text = parser.preprocess(text, opts);
  10580. }
  10581. return {
  10582. text: text,
  10583. ast: parser.parse(text, parsersForCustomParserApi, opts)
  10584. };
  10585. } catch (error) {
  10586. var loc$$1 = error.loc;
  10587. if (loc$$1) {
  10588. var codeFrame = lib$2;
  10589. error.codeFrame = codeFrame.codeFrameColumns(text, loc$$1, {
  10590. highlightCode: true
  10591. });
  10592. error.message += "\n" + error.codeFrame;
  10593. throw error;
  10594. }
  10595. /* istanbul ignore next */
  10596. throw error.stack;
  10597. }
  10598. }
  10599. var parser = {
  10600. parse: parse$2,
  10601. resolveParser: resolveParser$1
  10602. };
  10603. var UndefinedParserError = errors.UndefinedParserError;
  10604. var getSupportInfo$1 = support.getSupportInfo;
  10605. var resolveParser = parser.resolveParser;
  10606. var hiddenDefaults = {
  10607. astFormat: "estree",
  10608. printer: {},
  10609. originalText: undefined,
  10610. locStart: null,
  10611. locEnd: null
  10612. }; // Copy options and fill in default values.
  10613. function normalize(options, opts) {
  10614. opts = opts || {};
  10615. var rawOptions = Object.assign({}, options);
  10616. var supportOptions = getSupportInfo$1(null, {
  10617. plugins: options.plugins,
  10618. showUnreleased: true,
  10619. showDeprecated: true
  10620. }).options;
  10621. var defaults = supportOptions.reduce(function (reduced, optionInfo) {
  10622. return optionInfo.default !== undefined ? Object.assign(reduced, _defineProperty({}, optionInfo.name, optionInfo.default)) : reduced;
  10623. }, Object.assign({}, hiddenDefaults));
  10624. if (!rawOptions.parser) {
  10625. if (!rawOptions.filepath) {
  10626. var logger = opts.logger || console;
  10627. 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.");
  10628. rawOptions.parser = "babel";
  10629. } else {
  10630. rawOptions.parser = inferParser(rawOptions.filepath, rawOptions.plugins);
  10631. if (!rawOptions.parser) {
  10632. throw new UndefinedParserError("No parser could be inferred for file: ".concat(rawOptions.filepath));
  10633. }
  10634. }
  10635. }
  10636. var parser$$1 = resolveParser(optionsNormalizer.normalizeApiOptions(rawOptions, [supportOptions.find(function (x) {
  10637. return x.name === "parser";
  10638. })], {
  10639. passThrough: true,
  10640. logger: false
  10641. }));
  10642. rawOptions.astFormat = parser$$1.astFormat;
  10643. rawOptions.locEnd = parser$$1.locEnd;
  10644. rawOptions.locStart = parser$$1.locStart;
  10645. var plugin = getPlugin(rawOptions);
  10646. rawOptions.printer = plugin.printers[rawOptions.astFormat];
  10647. var pluginDefaults = supportOptions.filter(function (optionInfo) {
  10648. return optionInfo.pluginDefaults && optionInfo.pluginDefaults[plugin.name];
  10649. }).reduce(function (reduced, optionInfo) {
  10650. return Object.assign(reduced, _defineProperty({}, optionInfo.name, optionInfo.pluginDefaults[plugin.name]));
  10651. }, {});
  10652. var mixedDefaults = Object.assign({}, defaults, pluginDefaults);
  10653. Object.keys(mixedDefaults).forEach(function (k) {
  10654. if (rawOptions[k] == null) {
  10655. rawOptions[k] = mixedDefaults[k];
  10656. }
  10657. });
  10658. if (rawOptions.parser === "json") {
  10659. rawOptions.trailingComma = "none";
  10660. }
  10661. return optionsNormalizer.normalizeApiOptions(rawOptions, supportOptions, Object.assign({
  10662. passThrough: Object.keys(hiddenDefaults)
  10663. }, opts));
  10664. }
  10665. function getPlugin(options) {
  10666. var astFormat = options.astFormat;
  10667. if (!astFormat) {
  10668. throw new Error("getPlugin() requires astFormat to be set");
  10669. }
  10670. var printerPlugin = options.plugins.find(function (plugin) {
  10671. return plugin.printers && plugin.printers[astFormat];
  10672. });
  10673. if (!printerPlugin) {
  10674. throw new Error("Couldn't find plugin for AST format \"".concat(astFormat, "\""));
  10675. }
  10676. return printerPlugin;
  10677. }
  10678. function getInterpreter(filepath) {
  10679. if (typeof filepath !== "string") {
  10680. return "";
  10681. }
  10682. var fd;
  10683. try {
  10684. fd = fs.openSync(filepath, "r");
  10685. } catch (err) {
  10686. return "";
  10687. }
  10688. try {
  10689. var liner = new readlines(fd);
  10690. var firstLine = liner.next().toString("utf8"); // #!/bin/env node, #!/usr/bin/env node
  10691. var m1 = firstLine.match(/^#!\/(?:usr\/)?bin\/env\s+(\S+)/);
  10692. if (m1) {
  10693. return m1[1];
  10694. } // #!/bin/node, #!/usr/bin/node, #!/usr/local/bin/node
  10695. var m2 = firstLine.match(/^#!\/(?:usr\/(?:local\/)?)?bin\/(\S+)/);
  10696. if (m2) {
  10697. return m2[1];
  10698. }
  10699. return "";
  10700. } catch (err) {
  10701. // There are some weird cases where paths are missing, causing Jest
  10702. // failures. It's unclear what these correspond to in the real world.
  10703. return "";
  10704. } finally {
  10705. try {
  10706. // There are some weird cases where paths are missing, causing Jest
  10707. // failures. It's unclear what these correspond to in the real world.
  10708. fs.closeSync(fd);
  10709. } catch (err) {// nop
  10710. }
  10711. }
  10712. }
  10713. function inferParser(filepath, plugins) {
  10714. var filepathParts = normalizePath(filepath).split("/");
  10715. var filename = filepathParts[filepathParts.length - 1].toLowerCase(); // If the file has no extension, we can try to infer the language from the
  10716. // interpreter in the shebang line, if any; but since this requires FS access,
  10717. // do it last.
  10718. var language = getSupportInfo$1(null, {
  10719. plugins: plugins
  10720. }).languages.find(function (language) {
  10721. return language.since !== null && (language.extensions && language.extensions.some(function (extension) {
  10722. return filename.endsWith(extension);
  10723. }) || language.filenames && language.filenames.find(function (name) {
  10724. return name.toLowerCase() === filename;
  10725. }) || filename.indexOf(".") === -1 && language.interpreters && language.interpreters.indexOf(getInterpreter(filepath)) !== -1);
  10726. });
  10727. return language && language.parsers[0];
  10728. }
  10729. var options = {
  10730. normalize: normalize,
  10731. hiddenDefaults: hiddenDefaults,
  10732. inferParser: inferParser
  10733. };
  10734. function massageAST(ast, options, parent) {
  10735. if (Array.isArray(ast)) {
  10736. return ast.map(function (e) {
  10737. return massageAST(e, options, parent);
  10738. }).filter(function (e) {
  10739. return e;
  10740. });
  10741. }
  10742. if (!ast || _typeof(ast) !== "object") {
  10743. return ast;
  10744. }
  10745. var newObj = {};
  10746. var _arr = Object.keys(ast);
  10747. for (var _i = 0; _i < _arr.length; _i++) {
  10748. var key = _arr[_i];
  10749. if (typeof ast[key] !== "function") {
  10750. newObj[key] = massageAST(ast[key], options, ast);
  10751. }
  10752. }
  10753. if (options.printer.massageAstNode) {
  10754. var result = options.printer.massageAstNode(ast, newObj, parent);
  10755. if (result === null) {
  10756. return undefined;
  10757. }
  10758. if (result) {
  10759. return result;
  10760. }
  10761. }
  10762. return newObj;
  10763. }
  10764. var massageAst = massageAST;
  10765. function assert() {}
  10766. assert.ok = function () {};
  10767. assert.strictEqual = function () {};
  10768. var assert$2 = Object.freeze({
  10769. default: assert
  10770. });
  10771. function concat$1(parts) {
  10772. return {
  10773. type: "concat",
  10774. parts: parts
  10775. };
  10776. }
  10777. function indent$1(contents) {
  10778. return {
  10779. type: "indent",
  10780. contents: contents
  10781. };
  10782. }
  10783. function align(n, contents) {
  10784. return {
  10785. type: "align",
  10786. contents: contents,
  10787. n: n
  10788. };
  10789. }
  10790. function group(contents, opts) {
  10791. opts = opts || {};
  10792. return {
  10793. type: "group",
  10794. id: opts.id,
  10795. contents: contents,
  10796. break: !!opts.shouldBreak,
  10797. expandedStates: opts.expandedStates
  10798. };
  10799. }
  10800. function dedentToRoot(contents) {
  10801. return align(-Infinity, contents);
  10802. }
  10803. function markAsRoot(contents) {
  10804. return align({
  10805. type: "root"
  10806. }, contents);
  10807. }
  10808. function dedent$1(contents) {
  10809. return align(-1, contents);
  10810. }
  10811. function conditionalGroup(states, opts) {
  10812. return group(states[0], Object.assign(opts || {}, {
  10813. expandedStates: states
  10814. }));
  10815. }
  10816. function fill(parts) {
  10817. return {
  10818. type: "fill",
  10819. parts: parts
  10820. };
  10821. }
  10822. function ifBreak(breakContents, flatContents, opts) {
  10823. opts = opts || {};
  10824. return {
  10825. type: "if-break",
  10826. breakContents: breakContents,
  10827. flatContents: flatContents,
  10828. groupId: opts.groupId
  10829. };
  10830. }
  10831. function lineSuffix$1(contents) {
  10832. return {
  10833. type: "line-suffix",
  10834. contents: contents
  10835. };
  10836. }
  10837. var lineSuffixBoundary = {
  10838. type: "line-suffix-boundary"
  10839. };
  10840. var breakParent$1 = {
  10841. type: "break-parent"
  10842. };
  10843. var trim = {
  10844. type: "trim"
  10845. };
  10846. var line$2 = {
  10847. type: "line"
  10848. };
  10849. var softline = {
  10850. type: "line",
  10851. soft: true
  10852. };
  10853. var hardline$1 = concat$1([{
  10854. type: "line",
  10855. hard: true
  10856. }, breakParent$1]);
  10857. var literalline = concat$1([{
  10858. type: "line",
  10859. hard: true,
  10860. literal: true
  10861. }, breakParent$1]);
  10862. var cursor$1 = {
  10863. type: "cursor",
  10864. placeholder: Symbol("cursor")
  10865. };
  10866. function join$1(sep, arr) {
  10867. var res = [];
  10868. for (var i = 0; i < arr.length; i++) {
  10869. if (i !== 0) {
  10870. res.push(sep);
  10871. }
  10872. res.push(arr[i]);
  10873. }
  10874. return concat$1(res);
  10875. }
  10876. function addAlignmentToDoc(doc, size, tabWidth) {
  10877. var aligned = doc;
  10878. if (size > 0) {
  10879. // Use indent to add tabs for all the levels of tabs we need
  10880. for (var i = 0; i < Math.floor(size / tabWidth); ++i) {
  10881. aligned = indent$1(aligned);
  10882. } // Use align for all the spaces that are needed
  10883. aligned = align(size % tabWidth, aligned); // size is absolute from 0 and not relative to the current
  10884. // indentation, so we use -Infinity to reset the indentation to 0
  10885. aligned = align(-Infinity, aligned);
  10886. }
  10887. return aligned;
  10888. }
  10889. var docBuilders = {
  10890. concat: concat$1,
  10891. join: join$1,
  10892. line: line$2,
  10893. softline: softline,
  10894. hardline: hardline$1,
  10895. literalline: literalline,
  10896. group: group,
  10897. conditionalGroup: conditionalGroup,
  10898. fill: fill,
  10899. lineSuffix: lineSuffix$1,
  10900. lineSuffixBoundary: lineSuffixBoundary,
  10901. cursor: cursor$1,
  10902. breakParent: breakParent$1,
  10903. ifBreak: ifBreak,
  10904. trim: trim,
  10905. indent: indent$1,
  10906. align: align,
  10907. addAlignmentToDoc: addAlignmentToDoc,
  10908. markAsRoot: markAsRoot,
  10909. dedentToRoot: dedentToRoot,
  10910. dedent: dedent$1
  10911. };
  10912. var ansiRegex = createCommonjsModule(function (module) {
  10913. 'use strict';
  10914. module.exports = function (options) {
  10915. options = Object.assign({
  10916. onlyFirst: false
  10917. }, options);
  10918. var pattern = ["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[a-zA-Z\\d]*)*)?\\u0007)", '(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))'].join('|');
  10919. return new RegExp(pattern, options.onlyFirst ? undefined : 'g');
  10920. };
  10921. });
  10922. var stripAnsi = function stripAnsi(input) {
  10923. return typeof input === 'string' ? input.replace(ansiRegex(), '') : input;
  10924. };
  10925. var isFullwidthCodePoint = createCommonjsModule(function (module) {
  10926. 'use strict';
  10927. /* eslint-disable yoda */
  10928. module.exports = function (x) {
  10929. if (Number.isNaN(x)) {
  10930. return false;
  10931. } // code points are derived from:
  10932. // http://www.unix.org/Public/UNIDATA/EastAsianWidth.txt
  10933. if (x >= 0x1100 && (x <= 0x115f || // Hangul Jamo
  10934. x === 0x2329 || // LEFT-POINTING ANGLE BRACKET
  10935. x === 0x232a || // RIGHT-POINTING ANGLE BRACKET
  10936. // CJK Radicals Supplement .. Enclosed CJK Letters and Months
  10937. 0x2e80 <= x && x <= 0x3247 && x !== 0x303f || // Enclosed CJK Letters and Months .. CJK Unified Ideographs Extension A
  10938. 0x3250 <= x && x <= 0x4dbf || // CJK Unified Ideographs .. Yi Radicals
  10939. 0x4e00 <= x && x <= 0xa4c6 || // Hangul Jamo Extended-A
  10940. 0xa960 <= x && x <= 0xa97c || // Hangul Syllables
  10941. 0xac00 <= x && x <= 0xd7a3 || // CJK Compatibility Ideographs
  10942. 0xf900 <= x && x <= 0xfaff || // Vertical Forms
  10943. 0xfe10 <= x && x <= 0xfe19 || // CJK Compatibility Forms .. Small Form Variants
  10944. 0xfe30 <= x && x <= 0xfe6b || // Halfwidth and Fullwidth Forms
  10945. 0xff01 <= x && x <= 0xff60 || 0xffe0 <= x && x <= 0xffe6 || // Kana Supplement
  10946. 0x1b000 <= x && x <= 0x1b001 || // Enclosed Ideographic Supplement
  10947. 0x1f200 <= x && x <= 0x1f251 || // CJK Unified Ideographs Extension B .. Tertiary Ideographic Plane
  10948. 0x20000 <= x && x <= 0x3fffd)) {
  10949. return true;
  10950. }
  10951. return false;
  10952. };
  10953. });
  10954. var emojiRegex = function emojiRegex() {
  10955. // https://mths.be/emoji
  10956. 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;
  10957. };
  10958. var stringWidth = createCommonjsModule(function (module) {
  10959. 'use strict';
  10960. var emojiRegex$$1 = emojiRegex();
  10961. module.exports = function (input) {
  10962. input = input.replace(emojiRegex$$1, ' ');
  10963. if (typeof input !== 'string' || input.length === 0) {
  10964. return 0;
  10965. }
  10966. input = stripAnsi(input);
  10967. var width = 0;
  10968. for (var i = 0; i < input.length; i++) {
  10969. var code = input.codePointAt(i); // Ignore control characters
  10970. if (code <= 0x1F || code >= 0x7F && code <= 0x9F) {
  10971. continue;
  10972. } // Ignore combining characters
  10973. if (code >= 0x300 && code <= 0x36F) {
  10974. continue;
  10975. } // Surrogates
  10976. if (code > 0xFFFF) {
  10977. i++;
  10978. }
  10979. width += isFullwidthCodePoint(code) ? 2 : 1;
  10980. }
  10981. return width;
  10982. };
  10983. });
  10984. var notAsciiRegex = /[^\x20-\x7F]/;
  10985. function isExportDeclaration(node) {
  10986. if (node) {
  10987. switch (node.type) {
  10988. case "ExportDefaultDeclaration":
  10989. case "ExportDefaultSpecifier":
  10990. case "DeclareExportDeclaration":
  10991. case "ExportNamedDeclaration":
  10992. case "ExportAllDeclaration":
  10993. return true;
  10994. }
  10995. }
  10996. return false;
  10997. }
  10998. function getParentExportDeclaration(path) {
  10999. var parentNode = path.getParentNode();
  11000. if (path.getName() === "declaration" && isExportDeclaration(parentNode)) {
  11001. return parentNode;
  11002. }
  11003. return null;
  11004. }
  11005. function getPenultimate(arr) {
  11006. if (arr.length > 1) {
  11007. return arr[arr.length - 2];
  11008. }
  11009. return null;
  11010. }
  11011. function skip(chars) {
  11012. return function (text, index, opts) {
  11013. var backwards = opts && opts.backwards; // Allow `skip` functions to be threaded together without having
  11014. // to check for failures (did someone say monads?).
  11015. if (index === false) {
  11016. return false;
  11017. }
  11018. var length = text.length;
  11019. var cursor = index;
  11020. while (cursor >= 0 && cursor < length) {
  11021. var c = text.charAt(cursor);
  11022. if (chars instanceof RegExp) {
  11023. if (!chars.test(c)) {
  11024. return cursor;
  11025. }
  11026. } else if (chars.indexOf(c) === -1) {
  11027. return cursor;
  11028. }
  11029. backwards ? cursor-- : cursor++;
  11030. }
  11031. if (cursor === -1 || cursor === length) {
  11032. // If we reached the beginning or end of the file, return the
  11033. // out-of-bounds cursor. It's up to the caller to handle this
  11034. // correctly. We don't want to indicate `false` though if it
  11035. // actually skipped valid characters.
  11036. return cursor;
  11037. }
  11038. return false;
  11039. };
  11040. }
  11041. var skipWhitespace = skip(/\s/);
  11042. var skipSpaces = skip(" \t");
  11043. var skipToLineEnd = skip(",; \t");
  11044. var skipEverythingButNewLine = skip(/[^\r\n]/);
  11045. function skipInlineComment(text, index) {
  11046. if (index === false) {
  11047. return false;
  11048. }
  11049. if (text.charAt(index) === "/" && text.charAt(index + 1) === "*") {
  11050. for (var i = index + 2; i < text.length; ++i) {
  11051. if (text.charAt(i) === "*" && text.charAt(i + 1) === "/") {
  11052. return i + 2;
  11053. }
  11054. }
  11055. }
  11056. return index;
  11057. }
  11058. function skipTrailingComment(text, index) {
  11059. if (index === false) {
  11060. return false;
  11061. }
  11062. if (text.charAt(index) === "/" && text.charAt(index + 1) === "/") {
  11063. return skipEverythingButNewLine(text, index);
  11064. }
  11065. return index;
  11066. } // This one doesn't use the above helper function because it wants to
  11067. // test \r\n in order and `skip` doesn't support ordering and we only
  11068. // want to skip one newline. It's simple to implement.
  11069. function skipNewline$1(text, index, opts) {
  11070. var backwards = opts && opts.backwards;
  11071. if (index === false) {
  11072. return false;
  11073. }
  11074. var atIndex = text.charAt(index);
  11075. if (backwards) {
  11076. if (text.charAt(index - 1) === "\r" && atIndex === "\n") {
  11077. return index - 2;
  11078. }
  11079. if (atIndex === "\n" || atIndex === "\r" || atIndex === "\u2028" || atIndex === "\u2029") {
  11080. return index - 1;
  11081. }
  11082. } else {
  11083. if (atIndex === "\r" && text.charAt(index + 1) === "\n") {
  11084. return index + 2;
  11085. }
  11086. if (atIndex === "\n" || atIndex === "\r" || atIndex === "\u2028" || atIndex === "\u2029") {
  11087. return index + 1;
  11088. }
  11089. }
  11090. return index;
  11091. }
  11092. function hasNewline$1(text, index, opts) {
  11093. opts = opts || {};
  11094. var idx = skipSpaces(text, opts.backwards ? index - 1 : index, opts);
  11095. var idx2 = skipNewline$1(text, idx, opts);
  11096. return idx !== idx2;
  11097. }
  11098. function hasNewlineInRange(text, start, end) {
  11099. for (var i = start; i < end; ++i) {
  11100. if (text.charAt(i) === "\n") {
  11101. return true;
  11102. }
  11103. }
  11104. return false;
  11105. } // Note: this function doesn't ignore leading comments unlike isNextLineEmpty
  11106. function isPreviousLineEmpty$1(text, node, locStart) {
  11107. var idx = locStart(node) - 1;
  11108. idx = skipSpaces(text, idx, {
  11109. backwards: true
  11110. });
  11111. idx = skipNewline$1(text, idx, {
  11112. backwards: true
  11113. });
  11114. idx = skipSpaces(text, idx, {
  11115. backwards: true
  11116. });
  11117. var idx2 = skipNewline$1(text, idx, {
  11118. backwards: true
  11119. });
  11120. return idx !== idx2;
  11121. }
  11122. function isNextLineEmptyAfterIndex(text, index) {
  11123. var oldIdx = null;
  11124. var idx = index;
  11125. while (idx !== oldIdx) {
  11126. // We need to skip all the potential trailing inline comments
  11127. oldIdx = idx;
  11128. idx = skipToLineEnd(text, idx);
  11129. idx = skipInlineComment(text, idx);
  11130. idx = skipSpaces(text, idx);
  11131. }
  11132. idx = skipTrailingComment(text, idx);
  11133. idx = skipNewline$1(text, idx);
  11134. return hasNewline$1(text, idx);
  11135. }
  11136. function isNextLineEmpty(text, node, locEnd) {
  11137. return isNextLineEmptyAfterIndex(text, locEnd(node));
  11138. }
  11139. function getNextNonSpaceNonCommentCharacterIndexWithStartIndex(text, idx) {
  11140. var oldIdx = null;
  11141. while (idx !== oldIdx) {
  11142. oldIdx = idx;
  11143. idx = skipSpaces(text, idx);
  11144. idx = skipInlineComment(text, idx);
  11145. idx = skipTrailingComment(text, idx);
  11146. idx = skipNewline$1(text, idx);
  11147. }
  11148. return idx;
  11149. }
  11150. function getNextNonSpaceNonCommentCharacterIndex(text, node, locEnd) {
  11151. return getNextNonSpaceNonCommentCharacterIndexWithStartIndex(text, locEnd(node));
  11152. }
  11153. function getNextNonSpaceNonCommentCharacter(text, node, locEnd) {
  11154. return text.charAt(getNextNonSpaceNonCommentCharacterIndex(text, node, locEnd));
  11155. }
  11156. function hasSpaces(text, index, opts) {
  11157. opts = opts || {};
  11158. var idx = skipSpaces(text, opts.backwards ? index - 1 : index, opts);
  11159. return idx !== index;
  11160. }
  11161. function setLocStart(node, index) {
  11162. if (node.range) {
  11163. node.range[0] = index;
  11164. } else {
  11165. node.start = index;
  11166. }
  11167. }
  11168. function setLocEnd(node, index) {
  11169. if (node.range) {
  11170. node.range[1] = index;
  11171. } else {
  11172. node.end = index;
  11173. }
  11174. }
  11175. var PRECEDENCE = {};
  11176. [["|>"], ["||", "??"], ["&&"], ["|"], ["^"], ["&"], ["==", "===", "!=", "!=="], ["<", ">", "<=", ">=", "in", "instanceof"], [">>", "<<", ">>>"], ["+", "-"], ["*", "/", "%"], ["**"]].forEach(function (tier, i) {
  11177. tier.forEach(function (op) {
  11178. PRECEDENCE[op] = i;
  11179. });
  11180. });
  11181. function getPrecedence(op) {
  11182. return PRECEDENCE[op];
  11183. }
  11184. var equalityOperators = {
  11185. "==": true,
  11186. "!=": true,
  11187. "===": true,
  11188. "!==": true
  11189. };
  11190. var multiplicativeOperators = {
  11191. "*": true,
  11192. "/": true,
  11193. "%": true
  11194. };
  11195. var bitshiftOperators = {
  11196. ">>": true,
  11197. ">>>": true,
  11198. "<<": true
  11199. };
  11200. function shouldFlatten(parentOp, nodeOp) {
  11201. if (getPrecedence(nodeOp) !== getPrecedence(parentOp)) {
  11202. return false;
  11203. } // ** is right-associative
  11204. // x ** y ** z --> x ** (y ** z)
  11205. if (parentOp === "**") {
  11206. return false;
  11207. } // x == y == z --> (x == y) == z
  11208. if (equalityOperators[parentOp] && equalityOperators[nodeOp]) {
  11209. return false;
  11210. } // x * y % z --> (x * y) % z
  11211. if (nodeOp === "%" && multiplicativeOperators[parentOp] || parentOp === "%" && multiplicativeOperators[nodeOp]) {
  11212. return false;
  11213. } // x * y / z --> (x * y) / z
  11214. // x / y * z --> (x / y) * z
  11215. if (nodeOp !== parentOp && multiplicativeOperators[nodeOp] && multiplicativeOperators[parentOp]) {
  11216. return false;
  11217. } // x << y << z --> (x << y) << z
  11218. if (bitshiftOperators[parentOp] && bitshiftOperators[nodeOp]) {
  11219. return false;
  11220. }
  11221. return true;
  11222. }
  11223. function isBitwiseOperator(operator) {
  11224. return !!bitshiftOperators[operator] || operator === "|" || operator === "^" || operator === "&";
  11225. } // Tests if an expression starts with `{`, or (if forbidFunctionClassAndDoExpr
  11226. // holds) `function`, `class`, or `do {}`. Will be overzealous if there's
  11227. // already necessary grouping parentheses.
  11228. function startsWithNoLookaheadToken(node, forbidFunctionClassAndDoExpr) {
  11229. node = getLeftMost(node);
  11230. switch (node.type) {
  11231. case "FunctionExpression":
  11232. case "ClassExpression":
  11233. case "DoExpression":
  11234. return forbidFunctionClassAndDoExpr;
  11235. case "ObjectExpression":
  11236. return true;
  11237. case "MemberExpression":
  11238. return startsWithNoLookaheadToken(node.object, forbidFunctionClassAndDoExpr);
  11239. case "TaggedTemplateExpression":
  11240. if (node.tag.type === "FunctionExpression") {
  11241. // IIFEs are always already parenthesized
  11242. return false;
  11243. }
  11244. return startsWithNoLookaheadToken(node.tag, forbidFunctionClassAndDoExpr);
  11245. case "CallExpression":
  11246. if (node.callee.type === "FunctionExpression") {
  11247. // IIFEs are always already parenthesized
  11248. return false;
  11249. }
  11250. return startsWithNoLookaheadToken(node.callee, forbidFunctionClassAndDoExpr);
  11251. case "ConditionalExpression":
  11252. return startsWithNoLookaheadToken(node.test, forbidFunctionClassAndDoExpr);
  11253. case "UpdateExpression":
  11254. return !node.prefix && startsWithNoLookaheadToken(node.argument, forbidFunctionClassAndDoExpr);
  11255. case "BindExpression":
  11256. return node.object && startsWithNoLookaheadToken(node.object, forbidFunctionClassAndDoExpr);
  11257. case "SequenceExpression":
  11258. return startsWithNoLookaheadToken(node.expressions[0], forbidFunctionClassAndDoExpr);
  11259. case "TSAsExpression":
  11260. return startsWithNoLookaheadToken(node.expression, forbidFunctionClassAndDoExpr);
  11261. default:
  11262. return false;
  11263. }
  11264. }
  11265. function getLeftMost(node) {
  11266. if (node.left) {
  11267. return getLeftMost(node.left);
  11268. }
  11269. return node;
  11270. }
  11271. function getAlignmentSize(value, tabWidth, startIndex) {
  11272. startIndex = startIndex || 0;
  11273. var size = 0;
  11274. for (var i = startIndex; i < value.length; ++i) {
  11275. if (value[i] === "\t") {
  11276. // Tabs behave in a way that they are aligned to the nearest
  11277. // multiple of tabWidth:
  11278. // 0 -> 4, 1 -> 4, 2 -> 4, 3 -> 4
  11279. // 4 -> 8, 5 -> 8, 6 -> 8, 7 -> 8 ...
  11280. size = size + tabWidth - size % tabWidth;
  11281. } else {
  11282. size++;
  11283. }
  11284. }
  11285. return size;
  11286. }
  11287. function getIndentSize(value, tabWidth) {
  11288. var lastNewlineIndex = value.lastIndexOf("\n");
  11289. if (lastNewlineIndex === -1) {
  11290. return 0;
  11291. }
  11292. return getAlignmentSize( // All the leading whitespaces
  11293. value.slice(lastNewlineIndex + 1).match(/^[ \t]*/)[0], tabWidth);
  11294. }
  11295. function getPreferredQuote(raw, preferredQuote) {
  11296. // `rawContent` is the string exactly like it appeared in the input source
  11297. // code, without its enclosing quotes.
  11298. var rawContent = raw.slice(1, -1);
  11299. var double = {
  11300. quote: '"',
  11301. regex: /"/g
  11302. };
  11303. var single = {
  11304. quote: "'",
  11305. regex: /'/g
  11306. };
  11307. var preferred = preferredQuote === "'" ? single : double;
  11308. var alternate = preferred === single ? double : single;
  11309. var result = preferred.quote; // If `rawContent` contains at least one of the quote preferred for enclosing
  11310. // the string, we might want to enclose with the alternate quote instead, to
  11311. // minimize the number of escaped quotes.
  11312. if (rawContent.includes(preferred.quote) || rawContent.includes(alternate.quote)) {
  11313. var numPreferredQuotes = (rawContent.match(preferred.regex) || []).length;
  11314. var numAlternateQuotes = (rawContent.match(alternate.regex) || []).length;
  11315. result = numPreferredQuotes > numAlternateQuotes ? alternate.quote : preferred.quote;
  11316. }
  11317. return result;
  11318. }
  11319. function printString(raw, options, isDirectiveLiteral) {
  11320. // `rawContent` is the string exactly like it appeared in the input source
  11321. // code, without its enclosing quotes.
  11322. var rawContent = raw.slice(1, -1); // Check for the alternate quote, to determine if we're allowed to swap
  11323. // the quotes on a DirectiveLiteral.
  11324. var canChangeDirectiveQuotes = !rawContent.includes('"') && !rawContent.includes("'");
  11325. var enclosingQuote = options.parser === "json" ? '"' : options.__isInHtmlAttribute ? "'" : getPreferredQuote(raw, options.singleQuote ? "'" : '"'); // Directives are exact code unit sequences, which means that you can't
  11326. // change the escape sequences they use.
  11327. // See https://github.com/prettier/prettier/issues/1555
  11328. // and https://tc39.github.io/ecma262/#directive-prologue
  11329. if (isDirectiveLiteral) {
  11330. if (canChangeDirectiveQuotes) {
  11331. return enclosingQuote + rawContent + enclosingQuote;
  11332. }
  11333. return raw;
  11334. } // It might sound unnecessary to use `makeString` even if the string already
  11335. // is enclosed with `enclosingQuote`, but it isn't. The string could contain
  11336. // unnecessary escapes (such as in `"\'"`). Always using `makeString` makes
  11337. // sure that we consistently output the minimum amount of escaped quotes.
  11338. return makeString(rawContent, enclosingQuote, !(options.parser === "css" || options.parser === "less" || options.parser === "scss" || options.embeddedInHtml));
  11339. }
  11340. function makeString(rawContent, enclosingQuote, unescapeUnnecessaryEscapes) {
  11341. var otherQuote = enclosingQuote === '"' ? "'" : '"'; // Matches _any_ escape and unescaped quotes (both single and double).
  11342. var regex = /\\([\s\S])|(['"])/g; // Escape and unescape single and double quotes as needed to be able to
  11343. // enclose `rawContent` with `enclosingQuote`.
  11344. var newContent = rawContent.replace(regex, function (match, escaped, quote) {
  11345. // If we matched an escape, and the escaped character is a quote of the
  11346. // other type than we intend to enclose the string with, there's no need for
  11347. // it to be escaped, so return it _without_ the backslash.
  11348. if (escaped === otherQuote) {
  11349. return escaped;
  11350. } // If we matched an unescaped quote and it is of the _same_ type as we
  11351. // intend to enclose the string with, it must be escaped, so return it with
  11352. // a backslash.
  11353. if (quote === enclosingQuote) {
  11354. return "\\" + quote;
  11355. }
  11356. if (quote) {
  11357. return quote;
  11358. } // Unescape any unnecessarily escaped character.
  11359. // Adapted from https://github.com/eslint/eslint/blob/de0b4ad7bd820ade41b1f606008bea68683dc11a/lib/rules/no-useless-escape.js#L27
  11360. return unescapeUnnecessaryEscapes && /^[^\\nrvtbfux\r\n\u2028\u2029"'0-7]$/.test(escaped) ? escaped : "\\" + escaped;
  11361. });
  11362. return enclosingQuote + newContent + enclosingQuote;
  11363. }
  11364. function printNumber(rawNumber) {
  11365. return rawNumber.toLowerCase() // Remove unnecessary plus and zeroes from scientific notation.
  11366. .replace(/^([+-]?[\d.]+e)(?:\+|(-))?0*(\d)/, "$1$2$3") // Remove unnecessary scientific notation (1e0).
  11367. .replace(/^([+-]?[\d.]+)e[+-]?0+$/, "$1") // Make sure numbers always start with a digit.
  11368. .replace(/^([+-])?\./, "$10.") // Remove extraneous trailing decimal zeroes.
  11369. .replace(/(\.\d+?)0+(?=e|$)/, "$1") // Remove trailing dot.
  11370. .replace(/\.(?=e|$)/, "");
  11371. }
  11372. function getMaxContinuousCount(str, target) {
  11373. var results = str.match(new RegExp("(".concat(escapeStringRegexp(target), ")+"), "g"));
  11374. if (results === null) {
  11375. return 0;
  11376. }
  11377. return results.reduce(function (maxCount, result) {
  11378. return Math.max(maxCount, result.length / target.length);
  11379. }, 0);
  11380. }
  11381. function getMinNotPresentContinuousCount(str, target) {
  11382. var matches = str.match(new RegExp("(".concat(escapeStringRegexp(target), ")+"), "g"));
  11383. if (matches === null) {
  11384. return 0;
  11385. }
  11386. var countPresent = new Map();
  11387. var max = 0;
  11388. var _iteratorNormalCompletion = true;
  11389. var _didIteratorError = false;
  11390. var _iteratorError = undefined;
  11391. try {
  11392. for (var _iterator = matches[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  11393. var match = _step.value;
  11394. var count = match.length / target.length;
  11395. countPresent.set(count, true);
  11396. if (count > max) {
  11397. max = count;
  11398. }
  11399. }
  11400. } catch (err) {
  11401. _didIteratorError = true;
  11402. _iteratorError = err;
  11403. } finally {
  11404. try {
  11405. if (!_iteratorNormalCompletion && _iterator.return != null) {
  11406. _iterator.return();
  11407. }
  11408. } finally {
  11409. if (_didIteratorError) {
  11410. throw _iteratorError;
  11411. }
  11412. }
  11413. }
  11414. for (var i = 1; i < max; i++) {
  11415. if (!countPresent.get(i)) {
  11416. return i;
  11417. }
  11418. }
  11419. return max + 1;
  11420. }
  11421. function getStringWidth$1(text) {
  11422. if (!text) {
  11423. return 0;
  11424. } // shortcut to avoid needless string `RegExp`s, replacements, and allocations within `string-width`
  11425. if (!notAsciiRegex.test(text)) {
  11426. return text.length;
  11427. }
  11428. return stringWidth(text);
  11429. }
  11430. function hasIgnoreComment(path) {
  11431. var node = path.getValue();
  11432. return hasNodeIgnoreComment(node);
  11433. }
  11434. function hasNodeIgnoreComment(node) {
  11435. return node && node.comments && node.comments.length > 0 && node.comments.some(function (comment) {
  11436. return comment.value.trim() === "prettier-ignore";
  11437. });
  11438. }
  11439. function matchAncestorTypes(path, types, index) {
  11440. index = index || 0;
  11441. types = types.slice();
  11442. while (types.length) {
  11443. var parent = path.getParentNode(index);
  11444. var type = types.shift();
  11445. if (!parent || parent.type !== type) {
  11446. return false;
  11447. }
  11448. index++;
  11449. }
  11450. return true;
  11451. }
  11452. function addCommentHelper(node, comment) {
  11453. var comments = node.comments || (node.comments = []);
  11454. comments.push(comment);
  11455. comment.printed = false; // For some reason, TypeScript parses `// x` inside of JSXText as a comment
  11456. // We already "print" it via the raw text, we don't need to re-print it as a
  11457. // comment
  11458. if (node.type === "JSXText") {
  11459. comment.printed = true;
  11460. }
  11461. }
  11462. function addLeadingComment$1(node, comment) {
  11463. comment.leading = true;
  11464. comment.trailing = false;
  11465. addCommentHelper(node, comment);
  11466. }
  11467. function addDanglingComment$1(node, comment) {
  11468. comment.leading = false;
  11469. comment.trailing = false;
  11470. addCommentHelper(node, comment);
  11471. }
  11472. function addTrailingComment$1(node, comment) {
  11473. comment.leading = false;
  11474. comment.trailing = true;
  11475. addCommentHelper(node, comment);
  11476. }
  11477. function isWithinParentArrayProperty(path, propertyName) {
  11478. var node = path.getValue();
  11479. var parent = path.getParentNode();
  11480. if (parent == null) {
  11481. return false;
  11482. }
  11483. if (!Array.isArray(parent[propertyName])) {
  11484. return false;
  11485. }
  11486. var key = path.getName();
  11487. return parent[propertyName][key] === node;
  11488. }
  11489. function replaceEndOfLineWith(text, replacement) {
  11490. var parts = [];
  11491. var _iteratorNormalCompletion2 = true;
  11492. var _didIteratorError2 = false;
  11493. var _iteratorError2 = undefined;
  11494. try {
  11495. for (var _iterator2 = text.split("\n")[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
  11496. var part = _step2.value;
  11497. if (parts.length !== 0) {
  11498. parts.push(replacement);
  11499. }
  11500. parts.push(part);
  11501. }
  11502. } catch (err) {
  11503. _didIteratorError2 = true;
  11504. _iteratorError2 = err;
  11505. } finally {
  11506. try {
  11507. if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
  11508. _iterator2.return();
  11509. }
  11510. } finally {
  11511. if (_didIteratorError2) {
  11512. throw _iteratorError2;
  11513. }
  11514. }
  11515. }
  11516. return parts;
  11517. }
  11518. var util = {
  11519. replaceEndOfLineWith: replaceEndOfLineWith,
  11520. getStringWidth: getStringWidth$1,
  11521. getMaxContinuousCount: getMaxContinuousCount,
  11522. getMinNotPresentContinuousCount: getMinNotPresentContinuousCount,
  11523. getPrecedence: getPrecedence,
  11524. shouldFlatten: shouldFlatten,
  11525. isBitwiseOperator: isBitwiseOperator,
  11526. isExportDeclaration: isExportDeclaration,
  11527. getParentExportDeclaration: getParentExportDeclaration,
  11528. getPenultimate: getPenultimate,
  11529. getLast: getLast,
  11530. getNextNonSpaceNonCommentCharacterIndexWithStartIndex: getNextNonSpaceNonCommentCharacterIndexWithStartIndex,
  11531. getNextNonSpaceNonCommentCharacterIndex: getNextNonSpaceNonCommentCharacterIndex,
  11532. getNextNonSpaceNonCommentCharacter: getNextNonSpaceNonCommentCharacter,
  11533. skip: skip,
  11534. skipWhitespace: skipWhitespace,
  11535. skipSpaces: skipSpaces,
  11536. skipToLineEnd: skipToLineEnd,
  11537. skipEverythingButNewLine: skipEverythingButNewLine,
  11538. skipInlineComment: skipInlineComment,
  11539. skipTrailingComment: skipTrailingComment,
  11540. skipNewline: skipNewline$1,
  11541. isNextLineEmptyAfterIndex: isNextLineEmptyAfterIndex,
  11542. isNextLineEmpty: isNextLineEmpty,
  11543. isPreviousLineEmpty: isPreviousLineEmpty$1,
  11544. hasNewline: hasNewline$1,
  11545. hasNewlineInRange: hasNewlineInRange,
  11546. hasSpaces: hasSpaces,
  11547. setLocStart: setLocStart,
  11548. setLocEnd: setLocEnd,
  11549. startsWithNoLookaheadToken: startsWithNoLookaheadToken,
  11550. getAlignmentSize: getAlignmentSize,
  11551. getIndentSize: getIndentSize,
  11552. getPreferredQuote: getPreferredQuote,
  11553. printString: printString,
  11554. printNumber: printNumber,
  11555. hasIgnoreComment: hasIgnoreComment,
  11556. hasNodeIgnoreComment: hasNodeIgnoreComment,
  11557. makeString: makeString,
  11558. matchAncestorTypes: matchAncestorTypes,
  11559. addLeadingComment: addLeadingComment$1,
  11560. addDanglingComment: addDanglingComment$1,
  11561. addTrailingComment: addTrailingComment$1,
  11562. isWithinParentArrayProperty: isWithinParentArrayProperty
  11563. };
  11564. function guessEndOfLine$1(text) {
  11565. var index = text.indexOf("\r");
  11566. if (index >= 0) {
  11567. return text.charAt(index + 1) === "\n" ? "crlf" : "cr";
  11568. }
  11569. return "lf";
  11570. }
  11571. function convertEndOfLineToChars$2(value) {
  11572. switch (value) {
  11573. case "cr":
  11574. return "\r";
  11575. case "crlf":
  11576. return "\r\n";
  11577. default:
  11578. return "\n";
  11579. }
  11580. }
  11581. var endOfLine = {
  11582. guessEndOfLine: guessEndOfLine$1,
  11583. convertEndOfLineToChars: convertEndOfLineToChars$2
  11584. };
  11585. var getStringWidth = util.getStringWidth;
  11586. var convertEndOfLineToChars$1 = endOfLine.convertEndOfLineToChars;
  11587. var concat$2 = docBuilders.concat;
  11588. var fill$1 = docBuilders.fill;
  11589. var cursor$2 = docBuilders.cursor;
  11590. /** @type {{[groupId: PropertyKey]: MODE}} */
  11591. var groupModeMap;
  11592. var MODE_BREAK = 1;
  11593. var MODE_FLAT = 2;
  11594. function rootIndent() {
  11595. return {
  11596. value: "",
  11597. length: 0,
  11598. queue: []
  11599. };
  11600. }
  11601. function makeIndent(ind, options) {
  11602. return generateInd(ind, {
  11603. type: "indent"
  11604. }, options);
  11605. }
  11606. function makeAlign(ind, n, options) {
  11607. return n === -Infinity ? ind.root || rootIndent() : n < 0 ? generateInd(ind, {
  11608. type: "dedent"
  11609. }, options) : !n ? ind : n.type === "root" ? Object.assign({}, ind, {
  11610. root: ind
  11611. }) : typeof n === "string" ? generateInd(ind, {
  11612. type: "stringAlign",
  11613. n: n
  11614. }, options) : generateInd(ind, {
  11615. type: "numberAlign",
  11616. n: n
  11617. }, options);
  11618. }
  11619. function generateInd(ind, newPart, options) {
  11620. var queue = newPart.type === "dedent" ? ind.queue.slice(0, -1) : ind.queue.concat(newPart);
  11621. var value = "";
  11622. var length = 0;
  11623. var lastTabs = 0;
  11624. var lastSpaces = 0;
  11625. var _iteratorNormalCompletion = true;
  11626. var _didIteratorError = false;
  11627. var _iteratorError = undefined;
  11628. try {
  11629. for (var _iterator = queue[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  11630. var part = _step.value;
  11631. switch (part.type) {
  11632. case "indent":
  11633. flush();
  11634. if (options.useTabs) {
  11635. addTabs(1);
  11636. } else {
  11637. addSpaces(options.tabWidth);
  11638. }
  11639. break;
  11640. case "stringAlign":
  11641. flush();
  11642. value += part.n;
  11643. length += part.n.length;
  11644. break;
  11645. case "numberAlign":
  11646. lastTabs += 1;
  11647. lastSpaces += part.n;
  11648. break;
  11649. /* istanbul ignore next */
  11650. default:
  11651. throw new Error("Unexpected type '".concat(part.type, "'"));
  11652. }
  11653. }
  11654. } catch (err) {
  11655. _didIteratorError = true;
  11656. _iteratorError = err;
  11657. } finally {
  11658. try {
  11659. if (!_iteratorNormalCompletion && _iterator.return != null) {
  11660. _iterator.return();
  11661. }
  11662. } finally {
  11663. if (_didIteratorError) {
  11664. throw _iteratorError;
  11665. }
  11666. }
  11667. }
  11668. flushSpaces();
  11669. return Object.assign({}, ind, {
  11670. value: value,
  11671. length: length,
  11672. queue: queue
  11673. });
  11674. function addTabs(count) {
  11675. value += "\t".repeat(count);
  11676. length += options.tabWidth * count;
  11677. }
  11678. function addSpaces(count) {
  11679. value += " ".repeat(count);
  11680. length += count;
  11681. }
  11682. function flush() {
  11683. if (options.useTabs) {
  11684. flushTabs();
  11685. } else {
  11686. flushSpaces();
  11687. }
  11688. }
  11689. function flushTabs() {
  11690. if (lastTabs > 0) {
  11691. addTabs(lastTabs);
  11692. }
  11693. resetLast();
  11694. }
  11695. function flushSpaces() {
  11696. if (lastSpaces > 0) {
  11697. addSpaces(lastSpaces);
  11698. }
  11699. resetLast();
  11700. }
  11701. function resetLast() {
  11702. lastTabs = 0;
  11703. lastSpaces = 0;
  11704. }
  11705. }
  11706. function trim$1(out) {
  11707. if (out.length === 0) {
  11708. return 0;
  11709. }
  11710. var trimCount = 0; // Trim whitespace at the end of line
  11711. while (out.length > 0 && typeof out[out.length - 1] === "string" && out[out.length - 1].match(/^[ \t]*$/)) {
  11712. trimCount += out.pop().length;
  11713. }
  11714. if (out.length && typeof out[out.length - 1] === "string") {
  11715. var trimmed = out[out.length - 1].replace(/[ \t]*$/, "");
  11716. trimCount += out[out.length - 1].length - trimmed.length;
  11717. out[out.length - 1] = trimmed;
  11718. }
  11719. return trimCount;
  11720. }
  11721. function fits(next, restCommands, width, options, mustBeFlat) {
  11722. var restIdx = restCommands.length;
  11723. var cmds = [next]; // `out` is only used for width counting because `trim` requires to look
  11724. // backwards for space characters.
  11725. var out = [];
  11726. while (width >= 0) {
  11727. if (cmds.length === 0) {
  11728. if (restIdx === 0) {
  11729. return true;
  11730. }
  11731. cmds.push(restCommands[restIdx - 1]);
  11732. restIdx--;
  11733. continue;
  11734. }
  11735. var x = cmds.pop();
  11736. var ind = x[0];
  11737. var mode = x[1];
  11738. var doc = x[2];
  11739. if (typeof doc === "string") {
  11740. out.push(doc);
  11741. width -= getStringWidth(doc);
  11742. } else {
  11743. switch (doc.type) {
  11744. case "concat":
  11745. for (var i = doc.parts.length - 1; i >= 0; i--) {
  11746. cmds.push([ind, mode, doc.parts[i]]);
  11747. }
  11748. break;
  11749. case "indent":
  11750. cmds.push([makeIndent(ind, options), mode, doc.contents]);
  11751. break;
  11752. case "align":
  11753. cmds.push([makeAlign(ind, doc.n, options), mode, doc.contents]);
  11754. break;
  11755. case "trim":
  11756. width += trim$1(out);
  11757. break;
  11758. case "group":
  11759. if (mustBeFlat && doc.break) {
  11760. return false;
  11761. }
  11762. cmds.push([ind, doc.break ? MODE_BREAK : mode, doc.contents]);
  11763. if (doc.id) {
  11764. groupModeMap[doc.id] = cmds[cmds.length - 1][1];
  11765. }
  11766. break;
  11767. case "fill":
  11768. for (var _i = doc.parts.length - 1; _i >= 0; _i--) {
  11769. cmds.push([ind, mode, doc.parts[_i]]);
  11770. }
  11771. break;
  11772. case "if-break":
  11773. {
  11774. var groupMode = doc.groupId ? groupModeMap[doc.groupId] : mode;
  11775. if (groupMode === MODE_BREAK) {
  11776. if (doc.breakContents) {
  11777. cmds.push([ind, mode, doc.breakContents]);
  11778. }
  11779. }
  11780. if (groupMode === MODE_FLAT) {
  11781. if (doc.flatContents) {
  11782. cmds.push([ind, mode, doc.flatContents]);
  11783. }
  11784. }
  11785. break;
  11786. }
  11787. case "line":
  11788. switch (mode) {
  11789. // fallthrough
  11790. case MODE_FLAT:
  11791. if (!doc.hard) {
  11792. if (!doc.soft) {
  11793. out.push(" ");
  11794. width -= 1;
  11795. }
  11796. break;
  11797. }
  11798. return true;
  11799. case MODE_BREAK:
  11800. return true;
  11801. }
  11802. break;
  11803. }
  11804. }
  11805. }
  11806. return false;
  11807. }
  11808. function printDocToString(doc, options) {
  11809. groupModeMap = {};
  11810. var width = options.printWidth;
  11811. var newLine = convertEndOfLineToChars$1(options.endOfLine);
  11812. var pos = 0; // cmds is basically a stack. We've turned a recursive call into a
  11813. // while loop which is much faster. The while loop below adds new
  11814. // cmds to the array instead of recursively calling `print`.
  11815. var cmds = [[rootIndent(), MODE_BREAK, doc]];
  11816. var out = [];
  11817. var shouldRemeasure = false;
  11818. var lineSuffix = [];
  11819. while (cmds.length !== 0) {
  11820. var x = cmds.pop();
  11821. var ind = x[0];
  11822. var mode = x[1];
  11823. var _doc = x[2];
  11824. if (typeof _doc === "string") {
  11825. out.push(_doc);
  11826. pos += getStringWidth(_doc);
  11827. } else {
  11828. switch (_doc.type) {
  11829. case "cursor":
  11830. out.push(cursor$2.placeholder);
  11831. break;
  11832. case "concat":
  11833. for (var i = _doc.parts.length - 1; i >= 0; i--) {
  11834. cmds.push([ind, mode, _doc.parts[i]]);
  11835. }
  11836. break;
  11837. case "indent":
  11838. cmds.push([makeIndent(ind, options), mode, _doc.contents]);
  11839. break;
  11840. case "align":
  11841. cmds.push([makeAlign(ind, _doc.n, options), mode, _doc.contents]);
  11842. break;
  11843. case "trim":
  11844. pos -= trim$1(out);
  11845. break;
  11846. case "group":
  11847. switch (mode) {
  11848. case MODE_FLAT:
  11849. if (!shouldRemeasure) {
  11850. cmds.push([ind, _doc.break ? MODE_BREAK : MODE_FLAT, _doc.contents]);
  11851. break;
  11852. }
  11853. // fallthrough
  11854. case MODE_BREAK:
  11855. {
  11856. shouldRemeasure = false;
  11857. var next = [ind, MODE_FLAT, _doc.contents];
  11858. var rem = width - pos;
  11859. if (!_doc.break && fits(next, cmds, rem, options)) {
  11860. cmds.push(next);
  11861. } else {
  11862. // Expanded states are a rare case where a document
  11863. // can manually provide multiple representations of
  11864. // itself. It provides an array of documents
  11865. // going from the least expanded (most flattened)
  11866. // representation first to the most expanded. If a
  11867. // group has these, we need to manually go through
  11868. // these states and find the first one that fits.
  11869. if (_doc.expandedStates) {
  11870. var mostExpanded = _doc.expandedStates[_doc.expandedStates.length - 1];
  11871. if (_doc.break) {
  11872. cmds.push([ind, MODE_BREAK, mostExpanded]);
  11873. break;
  11874. } else {
  11875. for (var _i2 = 1; _i2 < _doc.expandedStates.length + 1; _i2++) {
  11876. if (_i2 >= _doc.expandedStates.length) {
  11877. cmds.push([ind, MODE_BREAK, mostExpanded]);
  11878. break;
  11879. } else {
  11880. var state = _doc.expandedStates[_i2];
  11881. var cmd = [ind, MODE_FLAT, state];
  11882. if (fits(cmd, cmds, rem, options)) {
  11883. cmds.push(cmd);
  11884. break;
  11885. }
  11886. }
  11887. }
  11888. }
  11889. } else {
  11890. cmds.push([ind, MODE_BREAK, _doc.contents]);
  11891. }
  11892. }
  11893. break;
  11894. }
  11895. }
  11896. if (_doc.id) {
  11897. groupModeMap[_doc.id] = cmds[cmds.length - 1][1];
  11898. }
  11899. break;
  11900. // Fills each line with as much code as possible before moving to a new
  11901. // line with the same indentation.
  11902. //
  11903. // Expects doc.parts to be an array of alternating content and
  11904. // whitespace. The whitespace contains the linebreaks.
  11905. //
  11906. // For example:
  11907. // ["I", line, "love", line, "monkeys"]
  11908. // or
  11909. // [{ type: group, ... }, softline, { type: group, ... }]
  11910. //
  11911. // It uses this parts structure to handle three main layout cases:
  11912. // * The first two content items fit on the same line without
  11913. // breaking
  11914. // -> output the first content item and the whitespace "flat".
  11915. // * Only the first content item fits on the line without breaking
  11916. // -> output the first content item "flat" and the whitespace with
  11917. // "break".
  11918. // * Neither content item fits on the line without breaking
  11919. // -> output the first content item and the whitespace with "break".
  11920. case "fill":
  11921. {
  11922. var _rem = width - pos;
  11923. var parts = _doc.parts;
  11924. if (parts.length === 0) {
  11925. break;
  11926. }
  11927. var content = parts[0];
  11928. var contentFlatCmd = [ind, MODE_FLAT, content];
  11929. var contentBreakCmd = [ind, MODE_BREAK, content];
  11930. var contentFits = fits(contentFlatCmd, [], _rem, options, true);
  11931. if (parts.length === 1) {
  11932. if (contentFits) {
  11933. cmds.push(contentFlatCmd);
  11934. } else {
  11935. cmds.push(contentBreakCmd);
  11936. }
  11937. break;
  11938. }
  11939. var whitespace = parts[1];
  11940. var whitespaceFlatCmd = [ind, MODE_FLAT, whitespace];
  11941. var whitespaceBreakCmd = [ind, MODE_BREAK, whitespace];
  11942. if (parts.length === 2) {
  11943. if (contentFits) {
  11944. cmds.push(whitespaceFlatCmd);
  11945. cmds.push(contentFlatCmd);
  11946. } else {
  11947. cmds.push(whitespaceBreakCmd);
  11948. cmds.push(contentBreakCmd);
  11949. }
  11950. break;
  11951. } // At this point we've handled the first pair (context, separator)
  11952. // and will create a new fill doc for the rest of the content.
  11953. // Ideally we wouldn't mutate the array here but coping all the
  11954. // elements to a new array would make this algorithm quadratic,
  11955. // which is unusable for large arrays (e.g. large texts in JSX).
  11956. parts.splice(0, 2);
  11957. var remainingCmd = [ind, mode, fill$1(parts)];
  11958. var secondContent = parts[0];
  11959. var firstAndSecondContentFlatCmd = [ind, MODE_FLAT, concat$2([content, whitespace, secondContent])];
  11960. var firstAndSecondContentFits = fits(firstAndSecondContentFlatCmd, [], _rem, options, true);
  11961. if (firstAndSecondContentFits) {
  11962. cmds.push(remainingCmd);
  11963. cmds.push(whitespaceFlatCmd);
  11964. cmds.push(contentFlatCmd);
  11965. } else if (contentFits) {
  11966. cmds.push(remainingCmd);
  11967. cmds.push(whitespaceBreakCmd);
  11968. cmds.push(contentFlatCmd);
  11969. } else {
  11970. cmds.push(remainingCmd);
  11971. cmds.push(whitespaceBreakCmd);
  11972. cmds.push(contentBreakCmd);
  11973. }
  11974. break;
  11975. }
  11976. case "if-break":
  11977. {
  11978. var groupMode = _doc.groupId ? groupModeMap[_doc.groupId] : mode;
  11979. if (groupMode === MODE_BREAK) {
  11980. if (_doc.breakContents) {
  11981. cmds.push([ind, mode, _doc.breakContents]);
  11982. }
  11983. }
  11984. if (groupMode === MODE_FLAT) {
  11985. if (_doc.flatContents) {
  11986. cmds.push([ind, mode, _doc.flatContents]);
  11987. }
  11988. }
  11989. break;
  11990. }
  11991. case "line-suffix":
  11992. lineSuffix.push([ind, mode, _doc.contents]);
  11993. break;
  11994. case "line-suffix-boundary":
  11995. if (lineSuffix.length > 0) {
  11996. cmds.push([ind, mode, {
  11997. type: "line",
  11998. hard: true
  11999. }]);
  12000. }
  12001. break;
  12002. case "line":
  12003. switch (mode) {
  12004. case MODE_FLAT:
  12005. if (!_doc.hard) {
  12006. if (!_doc.soft) {
  12007. out.push(" ");
  12008. pos += 1;
  12009. }
  12010. break;
  12011. } else {
  12012. // This line was forced into the output even if we
  12013. // were in flattened mode, so we need to tell the next
  12014. // group that no matter what, it needs to remeasure
  12015. // because the previous measurement didn't accurately
  12016. // capture the entire expression (this is necessary
  12017. // for nested groups)
  12018. shouldRemeasure = true;
  12019. }
  12020. // fallthrough
  12021. case MODE_BREAK:
  12022. if (lineSuffix.length) {
  12023. cmds.push([ind, mode, _doc]);
  12024. [].push.apply(cmds, lineSuffix.reverse());
  12025. lineSuffix = [];
  12026. break;
  12027. }
  12028. if (_doc.literal) {
  12029. if (ind.root) {
  12030. out.push(newLine, ind.root.value);
  12031. pos = ind.root.length;
  12032. } else {
  12033. out.push(newLine);
  12034. pos = 0;
  12035. }
  12036. } else {
  12037. pos -= trim$1(out);
  12038. out.push(newLine + ind.value);
  12039. pos = ind.length;
  12040. }
  12041. break;
  12042. }
  12043. break;
  12044. default:
  12045. }
  12046. }
  12047. }
  12048. var cursorPlaceholderIndex = out.indexOf(cursor$2.placeholder);
  12049. if (cursorPlaceholderIndex !== -1) {
  12050. var otherCursorPlaceholderIndex = out.indexOf(cursor$2.placeholder, cursorPlaceholderIndex + 1);
  12051. var beforeCursor = out.slice(0, cursorPlaceholderIndex).join("");
  12052. var aroundCursor = out.slice(cursorPlaceholderIndex + 1, otherCursorPlaceholderIndex).join("");
  12053. var afterCursor = out.slice(otherCursorPlaceholderIndex + 1).join("");
  12054. return {
  12055. formatted: beforeCursor + aroundCursor + afterCursor,
  12056. cursorNodeStart: beforeCursor.length,
  12057. cursorNodeText: aroundCursor
  12058. };
  12059. }
  12060. return {
  12061. formatted: out.join("")
  12062. };
  12063. }
  12064. var docPrinter = {
  12065. printDocToString: printDocToString
  12066. };
  12067. var traverseDocOnExitStackMarker = {};
  12068. function traverseDoc(doc, onEnter, onExit, shouldTraverseConditionalGroups) {
  12069. var docsStack = [doc];
  12070. while (docsStack.length !== 0) {
  12071. var _doc = docsStack.pop();
  12072. if (_doc === traverseDocOnExitStackMarker) {
  12073. onExit(docsStack.pop());
  12074. continue;
  12075. }
  12076. var shouldRecurse = true;
  12077. if (onEnter) {
  12078. if (onEnter(_doc) === false) {
  12079. shouldRecurse = false;
  12080. }
  12081. }
  12082. if (onExit) {
  12083. docsStack.push(_doc);
  12084. docsStack.push(traverseDocOnExitStackMarker);
  12085. }
  12086. if (shouldRecurse) {
  12087. // When there are multiple parts to process,
  12088. // the parts need to be pushed onto the stack in reverse order,
  12089. // so that they are processed in the original order
  12090. // when the stack is popped.
  12091. if (_doc.type === "concat" || _doc.type === "fill") {
  12092. for (var ic = _doc.parts.length, i = ic - 1; i >= 0; --i) {
  12093. docsStack.push(_doc.parts[i]);
  12094. }
  12095. } else if (_doc.type === "if-break") {
  12096. if (_doc.flatContents) {
  12097. docsStack.push(_doc.flatContents);
  12098. }
  12099. if (_doc.breakContents) {
  12100. docsStack.push(_doc.breakContents);
  12101. }
  12102. } else if (_doc.type === "group" && _doc.expandedStates) {
  12103. if (shouldTraverseConditionalGroups) {
  12104. for (var _ic = _doc.expandedStates.length, _i = _ic - 1; _i >= 0; --_i) {
  12105. docsStack.push(_doc.expandedStates[_i]);
  12106. }
  12107. } else {
  12108. docsStack.push(_doc.contents);
  12109. }
  12110. } else if (_doc.contents) {
  12111. docsStack.push(_doc.contents);
  12112. }
  12113. }
  12114. }
  12115. }
  12116. function mapDoc$1(doc, cb) {
  12117. if (doc.type === "concat" || doc.type === "fill") {
  12118. var parts = doc.parts.map(function (part) {
  12119. return mapDoc$1(part, cb);
  12120. });
  12121. return cb(Object.assign({}, doc, {
  12122. parts: parts
  12123. }));
  12124. } else if (doc.type === "if-break") {
  12125. var breakContents = doc.breakContents && mapDoc$1(doc.breakContents, cb);
  12126. var flatContents = doc.flatContents && mapDoc$1(doc.flatContents, cb);
  12127. return cb(Object.assign({}, doc, {
  12128. breakContents: breakContents,
  12129. flatContents: flatContents
  12130. }));
  12131. } else if (doc.contents) {
  12132. var contents = mapDoc$1(doc.contents, cb);
  12133. return cb(Object.assign({}, doc, {
  12134. contents: contents
  12135. }));
  12136. }
  12137. return cb(doc);
  12138. }
  12139. function findInDoc(doc, fn, defaultValue) {
  12140. var result = defaultValue;
  12141. var hasStopped = false;
  12142. function findInDocOnEnterFn(doc) {
  12143. var maybeResult = fn(doc);
  12144. if (maybeResult !== undefined) {
  12145. hasStopped = true;
  12146. result = maybeResult;
  12147. }
  12148. if (hasStopped) {
  12149. return false;
  12150. }
  12151. }
  12152. traverseDoc(doc, findInDocOnEnterFn);
  12153. return result;
  12154. }
  12155. function isEmpty(n) {
  12156. return typeof n === "string" && n.length === 0;
  12157. }
  12158. function isLineNextFn(doc) {
  12159. if (typeof doc === "string") {
  12160. return false;
  12161. }
  12162. if (doc.type === "line") {
  12163. return true;
  12164. }
  12165. }
  12166. function isLineNext(doc) {
  12167. return findInDoc(doc, isLineNextFn, false);
  12168. }
  12169. function willBreakFn(doc) {
  12170. if (doc.type === "group" && doc.break) {
  12171. return true;
  12172. }
  12173. if (doc.type === "line" && doc.hard) {
  12174. return true;
  12175. }
  12176. if (doc.type === "break-parent") {
  12177. return true;
  12178. }
  12179. }
  12180. function willBreak(doc) {
  12181. return findInDoc(doc, willBreakFn, false);
  12182. }
  12183. function breakParentGroup(groupStack) {
  12184. if (groupStack.length > 0) {
  12185. var parentGroup = groupStack[groupStack.length - 1]; // Breaks are not propagated through conditional groups because
  12186. // the user is expected to manually handle what breaks.
  12187. if (!parentGroup.expandedStates) {
  12188. parentGroup.break = true;
  12189. }
  12190. }
  12191. return null;
  12192. }
  12193. function propagateBreaks(doc) {
  12194. var alreadyVisitedSet = new Set();
  12195. var groupStack = [];
  12196. function propagateBreaksOnEnterFn(doc) {
  12197. if (doc.type === "break-parent") {
  12198. breakParentGroup(groupStack);
  12199. }
  12200. if (doc.type === "group") {
  12201. groupStack.push(doc);
  12202. if (alreadyVisitedSet.has(doc)) {
  12203. return false;
  12204. }
  12205. alreadyVisitedSet.add(doc);
  12206. }
  12207. }
  12208. function propagateBreaksOnExitFn(doc) {
  12209. if (doc.type === "group") {
  12210. var group = groupStack.pop();
  12211. if (group.break) {
  12212. breakParentGroup(groupStack);
  12213. }
  12214. }
  12215. }
  12216. traverseDoc(doc, propagateBreaksOnEnterFn, propagateBreaksOnExitFn,
  12217. /* shouldTraverseConditionalGroups */
  12218. true);
  12219. }
  12220. function removeLinesFn(doc) {
  12221. // Force this doc into flat mode by statically converting all
  12222. // lines into spaces (or soft lines into nothing). Hard lines
  12223. // should still output because there's too great of a chance
  12224. // of breaking existing assumptions otherwise.
  12225. if (doc.type === "line" && !doc.hard) {
  12226. return doc.soft ? "" : " ";
  12227. } else if (doc.type === "if-break") {
  12228. return doc.flatContents || "";
  12229. }
  12230. return doc;
  12231. }
  12232. function removeLines(doc) {
  12233. return mapDoc$1(doc, removeLinesFn);
  12234. }
  12235. function stripTrailingHardline(doc) {
  12236. // HACK remove ending hardline, original PR: #1984
  12237. if (doc.type === "concat" && doc.parts.length !== 0) {
  12238. var lastPart = doc.parts[doc.parts.length - 1];
  12239. if (lastPart.type === "concat") {
  12240. if (lastPart.parts.length === 2 && lastPart.parts[0].hard && lastPart.parts[1].type === "break-parent") {
  12241. return {
  12242. type: "concat",
  12243. parts: doc.parts.slice(0, -1)
  12244. };
  12245. }
  12246. return {
  12247. type: "concat",
  12248. parts: doc.parts.slice(0, -1).concat(stripTrailingHardline(lastPart))
  12249. };
  12250. }
  12251. }
  12252. return doc;
  12253. }
  12254. var docUtils = {
  12255. isEmpty: isEmpty,
  12256. willBreak: willBreak,
  12257. isLineNext: isLineNext,
  12258. traverseDoc: traverseDoc,
  12259. findInDoc: findInDoc,
  12260. mapDoc: mapDoc$1,
  12261. propagateBreaks: propagateBreaks,
  12262. removeLines: removeLines,
  12263. stripTrailingHardline: stripTrailingHardline
  12264. };
  12265. function flattenDoc(doc) {
  12266. if (doc.type === "concat") {
  12267. var res = [];
  12268. for (var i = 0; i < doc.parts.length; ++i) {
  12269. var doc2 = doc.parts[i];
  12270. if (typeof doc2 !== "string" && doc2.type === "concat") {
  12271. [].push.apply(res, flattenDoc(doc2).parts);
  12272. } else {
  12273. var flattened = flattenDoc(doc2);
  12274. if (flattened !== "") {
  12275. res.push(flattened);
  12276. }
  12277. }
  12278. }
  12279. return Object.assign({}, doc, {
  12280. parts: res
  12281. });
  12282. } else if (doc.type === "if-break") {
  12283. return Object.assign({}, doc, {
  12284. breakContents: doc.breakContents != null ? flattenDoc(doc.breakContents) : null,
  12285. flatContents: doc.flatContents != null ? flattenDoc(doc.flatContents) : null
  12286. });
  12287. } else if (doc.type === "group") {
  12288. return Object.assign({}, doc, {
  12289. contents: flattenDoc(doc.contents),
  12290. expandedStates: doc.expandedStates ? doc.expandedStates.map(flattenDoc) : doc.expandedStates
  12291. });
  12292. } else if (doc.contents) {
  12293. return Object.assign({}, doc, {
  12294. contents: flattenDoc(doc.contents)
  12295. });
  12296. }
  12297. return doc;
  12298. }
  12299. function printDoc(doc) {
  12300. if (typeof doc === "string") {
  12301. return JSON.stringify(doc);
  12302. }
  12303. if (doc.type === "line") {
  12304. if (doc.literal) {
  12305. return "literalline";
  12306. }
  12307. if (doc.hard) {
  12308. return "hardline";
  12309. }
  12310. if (doc.soft) {
  12311. return "softline";
  12312. }
  12313. return "line";
  12314. }
  12315. if (doc.type === "break-parent") {
  12316. return "breakParent";
  12317. }
  12318. if (doc.type === "trim") {
  12319. return "trim";
  12320. }
  12321. if (doc.type === "concat") {
  12322. return "[" + doc.parts.map(printDoc).join(", ") + "]";
  12323. }
  12324. if (doc.type === "indent") {
  12325. return "indent(" + printDoc(doc.contents) + ")";
  12326. }
  12327. if (doc.type === "align") {
  12328. 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) + ")";
  12329. }
  12330. if (doc.type === "if-break") {
  12331. return "ifBreak(" + printDoc(doc.breakContents) + (doc.flatContents ? ", " + printDoc(doc.flatContents) : "") + ")";
  12332. }
  12333. if (doc.type === "group") {
  12334. if (doc.expandedStates) {
  12335. return "conditionalGroup(" + "[" + doc.expandedStates.map(printDoc).join(",") + "])";
  12336. }
  12337. return (doc.break ? "wrappedGroup" : "group") + "(" + printDoc(doc.contents) + ")";
  12338. }
  12339. if (doc.type === "fill") {
  12340. return "fill" + "(" + doc.parts.map(printDoc).join(", ") + ")";
  12341. }
  12342. if (doc.type === "line-suffix") {
  12343. return "lineSuffix(" + printDoc(doc.contents) + ")";
  12344. }
  12345. if (doc.type === "line-suffix-boundary") {
  12346. return "lineSuffixBoundary";
  12347. }
  12348. throw new Error("Unknown doc type " + doc.type);
  12349. }
  12350. var docDebug = {
  12351. printDocToDebug: function printDocToDebug(doc) {
  12352. return printDoc(flattenDoc(doc));
  12353. }
  12354. };
  12355. var doc = {
  12356. builders: docBuilders,
  12357. printer: docPrinter,
  12358. utils: docUtils,
  12359. debug: docDebug
  12360. };
  12361. var mapDoc$2 = doc.utils.mapDoc;
  12362. function isNextLineEmpty$1(text, node, options) {
  12363. return util.isNextLineEmpty(text, node, options.locEnd);
  12364. }
  12365. function isPreviousLineEmpty$2(text, node, options) {
  12366. return util.isPreviousLineEmpty(text, node, options.locStart);
  12367. }
  12368. function getNextNonSpaceNonCommentCharacterIndex$1(text, node, options) {
  12369. return util.getNextNonSpaceNonCommentCharacterIndex(text, node, options.locEnd);
  12370. }
  12371. var utilShared = {
  12372. getMaxContinuousCount: util.getMaxContinuousCount,
  12373. getStringWidth: util.getStringWidth,
  12374. getAlignmentSize: util.getAlignmentSize,
  12375. getIndentSize: util.getIndentSize,
  12376. skip: util.skip,
  12377. skipWhitespace: util.skipWhitespace,
  12378. skipSpaces: util.skipSpaces,
  12379. skipNewline: util.skipNewline,
  12380. skipToLineEnd: util.skipToLineEnd,
  12381. skipEverythingButNewLine: util.skipEverythingButNewLine,
  12382. skipInlineComment: util.skipInlineComment,
  12383. skipTrailingComment: util.skipTrailingComment,
  12384. hasNewline: util.hasNewline,
  12385. hasNewlineInRange: util.hasNewlineInRange,
  12386. hasSpaces: util.hasSpaces,
  12387. isNextLineEmpty: isNextLineEmpty$1,
  12388. isNextLineEmptyAfterIndex: util.isNextLineEmptyAfterIndex,
  12389. isPreviousLineEmpty: isPreviousLineEmpty$2,
  12390. getNextNonSpaceNonCommentCharacterIndex: getNextNonSpaceNonCommentCharacterIndex$1,
  12391. mapDoc: mapDoc$2,
  12392. // TODO: remove in 2.0, we already exposed it in docUtils
  12393. makeString: util.makeString,
  12394. addLeadingComment: util.addLeadingComment,
  12395. addDanglingComment: util.addDanglingComment,
  12396. addTrailingComment: util.addTrailingComment
  12397. };
  12398. var assert$3 = ( assert$2 && assert ) || assert$2;
  12399. var _require$$0$builders = doc.builders;
  12400. var concat = _require$$0$builders.concat;
  12401. var hardline = _require$$0$builders.hardline;
  12402. var breakParent = _require$$0$builders.breakParent;
  12403. var indent = _require$$0$builders.indent;
  12404. var lineSuffix = _require$$0$builders.lineSuffix;
  12405. var join = _require$$0$builders.join;
  12406. var cursor = _require$$0$builders.cursor;
  12407. var hasNewline = util.hasNewline;
  12408. var skipNewline = util.skipNewline;
  12409. var isPreviousLineEmpty = util.isPreviousLineEmpty;
  12410. var addLeadingComment = utilShared.addLeadingComment;
  12411. var addDanglingComment = utilShared.addDanglingComment;
  12412. var addTrailingComment = utilShared.addTrailingComment;
  12413. var childNodesCacheKey = Symbol("child-nodes");
  12414. function getSortedChildNodes(node, options, resultArray) {
  12415. if (!node) {
  12416. return;
  12417. }
  12418. var printer = options.printer,
  12419. locStart = options.locStart,
  12420. locEnd = options.locEnd;
  12421. if (resultArray) {
  12422. if (node && printer.canAttachComment && printer.canAttachComment(node)) {
  12423. // This reverse insertion sort almost always takes constant
  12424. // time because we almost always (maybe always?) append the
  12425. // nodes in order anyway.
  12426. var i;
  12427. for (i = resultArray.length - 1; i >= 0; --i) {
  12428. if (locStart(resultArray[i]) <= locStart(node) && locEnd(resultArray[i]) <= locEnd(node)) {
  12429. break;
  12430. }
  12431. }
  12432. resultArray.splice(i + 1, 0, node);
  12433. return;
  12434. }
  12435. } else if (node[childNodesCacheKey]) {
  12436. return node[childNodesCacheKey];
  12437. }
  12438. var childNodes;
  12439. if (printer.getCommentChildNodes) {
  12440. childNodes = printer.getCommentChildNodes(node);
  12441. } else if (node && _typeof(node) === "object") {
  12442. childNodes = Object.keys(node).filter(function (n) {
  12443. return n !== "enclosingNode" && n !== "precedingNode" && n !== "followingNode";
  12444. }).map(function (n) {
  12445. return node[n];
  12446. });
  12447. }
  12448. if (!childNodes) {
  12449. return;
  12450. }
  12451. if (!resultArray) {
  12452. Object.defineProperty(node, childNodesCacheKey, {
  12453. value: resultArray = [],
  12454. enumerable: false
  12455. });
  12456. }
  12457. childNodes.forEach(function (childNode) {
  12458. getSortedChildNodes(childNode, options, resultArray);
  12459. });
  12460. return resultArray;
  12461. } // As efficiently as possible, decorate the comment object with
  12462. // .precedingNode, .enclosingNode, and/or .followingNode properties, at
  12463. // least one of which is guaranteed to be defined.
  12464. function decorateComment(node, comment, options) {
  12465. var locStart = options.locStart,
  12466. locEnd = options.locEnd;
  12467. var childNodes = getSortedChildNodes(node, options);
  12468. var precedingNode;
  12469. var followingNode; // Time to dust off the old binary search robes and wizard hat.
  12470. var left = 0;
  12471. var right = childNodes.length;
  12472. while (left < right) {
  12473. var middle = left + right >> 1;
  12474. var child = childNodes[middle];
  12475. if (locStart(child) - locStart(comment) <= 0 && locEnd(comment) - locEnd(child) <= 0) {
  12476. // The comment is completely contained by this child node.
  12477. comment.enclosingNode = child;
  12478. decorateComment(child, comment, options);
  12479. return; // Abandon the binary search at this level.
  12480. }
  12481. if (locEnd(child) - locStart(comment) <= 0) {
  12482. // This child node falls completely before the comment.
  12483. // Because we will never consider this node or any nodes
  12484. // before it again, this node must be the closest preceding
  12485. // node we have encountered so far.
  12486. precedingNode = child;
  12487. left = middle + 1;
  12488. continue;
  12489. }
  12490. if (locEnd(comment) - locStart(child) <= 0) {
  12491. // This child node falls completely after the comment.
  12492. // Because we will never consider this node or any nodes after
  12493. // it again, this node must be the closest following node we
  12494. // have encountered so far.
  12495. followingNode = child;
  12496. right = middle;
  12497. continue;
  12498. }
  12499. /* istanbul ignore next */
  12500. throw new Error("Comment location overlaps with node location");
  12501. } // We don't want comments inside of different expressions inside of the same
  12502. // template literal to move to another expression.
  12503. if (comment.enclosingNode && comment.enclosingNode.type === "TemplateLiteral") {
  12504. var quasis = comment.enclosingNode.quasis;
  12505. var commentIndex = findExpressionIndexForComment(quasis, comment, options);
  12506. if (precedingNode && findExpressionIndexForComment(quasis, precedingNode, options) !== commentIndex) {
  12507. precedingNode = null;
  12508. }
  12509. if (followingNode && findExpressionIndexForComment(quasis, followingNode, options) !== commentIndex) {
  12510. followingNode = null;
  12511. }
  12512. }
  12513. if (precedingNode) {
  12514. comment.precedingNode = precedingNode;
  12515. }
  12516. if (followingNode) {
  12517. comment.followingNode = followingNode;
  12518. }
  12519. }
  12520. function attach(comments, ast, text, options) {
  12521. if (!Array.isArray(comments)) {
  12522. return;
  12523. }
  12524. var tiesToBreak = [];
  12525. var locStart = options.locStart,
  12526. locEnd = options.locEnd;
  12527. comments.forEach(function (comment, i) {
  12528. if (options.parser === "json" || options.parser === "json5" || options.parser === "__js_expression" || options.parser === "__vue_expression") {
  12529. if (locStart(comment) - locStart(ast) <= 0) {
  12530. addLeadingComment(ast, comment);
  12531. return;
  12532. }
  12533. if (locEnd(comment) - locEnd(ast) >= 0) {
  12534. addTrailingComment(ast, comment);
  12535. return;
  12536. }
  12537. }
  12538. decorateComment(ast, comment, options);
  12539. var precedingNode = comment.precedingNode,
  12540. enclosingNode = comment.enclosingNode,
  12541. followingNode = comment.followingNode;
  12542. var pluginHandleOwnLineComment = options.printer.handleComments && options.printer.handleComments.ownLine ? options.printer.handleComments.ownLine : function () {
  12543. return false;
  12544. };
  12545. var pluginHandleEndOfLineComment = options.printer.handleComments && options.printer.handleComments.endOfLine ? options.printer.handleComments.endOfLine : function () {
  12546. return false;
  12547. };
  12548. var pluginHandleRemainingComment = options.printer.handleComments && options.printer.handleComments.remaining ? options.printer.handleComments.remaining : function () {
  12549. return false;
  12550. };
  12551. var isLastComment = comments.length - 1 === i;
  12552. if (hasNewline(text, locStart(comment), {
  12553. backwards: true
  12554. })) {
  12555. // If a comment exists on its own line, prefer a leading comment.
  12556. // We also need to check if it's the first line of the file.
  12557. if (pluginHandleOwnLineComment(comment, text, options, ast, isLastComment)) {// We're good
  12558. } else if (followingNode) {
  12559. // Always a leading comment.
  12560. addLeadingComment(followingNode, comment);
  12561. } else if (precedingNode) {
  12562. addTrailingComment(precedingNode, comment);
  12563. } else if (enclosingNode) {
  12564. addDanglingComment(enclosingNode, comment);
  12565. } else {
  12566. // There are no nodes, let's attach it to the root of the ast
  12567. /* istanbul ignore next */
  12568. addDanglingComment(ast, comment);
  12569. }
  12570. } else if (hasNewline(text, locEnd(comment))) {
  12571. if (pluginHandleEndOfLineComment(comment, text, options, ast, isLastComment)) {// We're good
  12572. } else if (precedingNode) {
  12573. // There is content before this comment on the same line, but
  12574. // none after it, so prefer a trailing comment of the previous node.
  12575. addTrailingComment(precedingNode, comment);
  12576. } else if (followingNode) {
  12577. addLeadingComment(followingNode, comment);
  12578. } else if (enclosingNode) {
  12579. addDanglingComment(enclosingNode, comment);
  12580. } else {
  12581. // There are no nodes, let's attach it to the root of the ast
  12582. /* istanbul ignore next */
  12583. addDanglingComment(ast, comment);
  12584. }
  12585. } else {
  12586. if (pluginHandleRemainingComment(comment, text, options, ast, isLastComment)) {// We're good
  12587. } else if (precedingNode && followingNode) {
  12588. // Otherwise, text exists both before and after the comment on
  12589. // the same line. If there is both a preceding and following
  12590. // node, use a tie-breaking algorithm to determine if it should
  12591. // be attached to the next or previous node. In the last case,
  12592. // simply attach the right node;
  12593. var tieCount = tiesToBreak.length;
  12594. if (tieCount > 0) {
  12595. var lastTie = tiesToBreak[tieCount - 1];
  12596. if (lastTie.followingNode !== comment.followingNode) {
  12597. breakTies(tiesToBreak, text, options);
  12598. }
  12599. }
  12600. tiesToBreak.push(comment);
  12601. } else if (precedingNode) {
  12602. addTrailingComment(precedingNode, comment);
  12603. } else if (followingNode) {
  12604. addLeadingComment(followingNode, comment);
  12605. } else if (enclosingNode) {
  12606. addDanglingComment(enclosingNode, comment);
  12607. } else {
  12608. // There are no nodes, let's attach it to the root of the ast
  12609. /* istanbul ignore next */
  12610. addDanglingComment(ast, comment);
  12611. }
  12612. }
  12613. });
  12614. breakTies(tiesToBreak, text, options);
  12615. comments.forEach(function (comment) {
  12616. // These node references were useful for breaking ties, but we
  12617. // don't need them anymore, and they create cycles in the AST that
  12618. // may lead to infinite recursion if we don't delete them here.
  12619. delete comment.precedingNode;
  12620. delete comment.enclosingNode;
  12621. delete comment.followingNode;
  12622. });
  12623. }
  12624. function breakTies(tiesToBreak, text, options) {
  12625. var tieCount = tiesToBreak.length;
  12626. if (tieCount === 0) {
  12627. return;
  12628. }
  12629. var _tiesToBreak$ = tiesToBreak[0],
  12630. precedingNode = _tiesToBreak$.precedingNode,
  12631. followingNode = _tiesToBreak$.followingNode;
  12632. var gapEndPos = options.locStart(followingNode); // Iterate backwards through tiesToBreak, examining the gaps
  12633. // between the tied comments. In order to qualify as leading, a
  12634. // comment must be separated from followingNode by an unbroken series of
  12635. // gaps (or other comments). Gaps should only contain whitespace or open
  12636. // parentheses.
  12637. var indexOfFirstLeadingComment;
  12638. for (indexOfFirstLeadingComment = tieCount; indexOfFirstLeadingComment > 0; --indexOfFirstLeadingComment) {
  12639. var comment = tiesToBreak[indexOfFirstLeadingComment - 1];
  12640. assert$3.strictEqual(comment.precedingNode, precedingNode);
  12641. assert$3.strictEqual(comment.followingNode, followingNode);
  12642. var gap = text.slice(options.locEnd(comment), gapEndPos).trim();
  12643. if (gap === "" || /^\(+$/.test(gap)) {
  12644. gapEndPos = options.locStart(comment);
  12645. } else {
  12646. // The gap string contained something other than whitespace or open
  12647. // parentheses.
  12648. break;
  12649. }
  12650. }
  12651. tiesToBreak.forEach(function (comment, i) {
  12652. if (i < indexOfFirstLeadingComment) {
  12653. addTrailingComment(precedingNode, comment);
  12654. } else {
  12655. addLeadingComment(followingNode, comment);
  12656. }
  12657. });
  12658. tiesToBreak.length = 0;
  12659. }
  12660. function printComment(commentPath, options) {
  12661. var comment = commentPath.getValue();
  12662. comment.printed = true;
  12663. return options.printer.printComment(commentPath, options);
  12664. }
  12665. function findExpressionIndexForComment(quasis, comment, options) {
  12666. var startPos = options.locStart(comment) - 1;
  12667. for (var i = 1; i < quasis.length; ++i) {
  12668. if (startPos < getQuasiRange(quasis[i]).start) {
  12669. return i - 1;
  12670. }
  12671. } // We haven't found it, it probably means that some of the locations are off.
  12672. // Let's just return the first one.
  12673. /* istanbul ignore next */
  12674. return 0;
  12675. }
  12676. function getQuasiRange(expr) {
  12677. if (expr.start !== undefined) {
  12678. // Babel
  12679. return {
  12680. start: expr.start,
  12681. end: expr.end
  12682. };
  12683. } // Flow
  12684. return {
  12685. start: expr.range[0],
  12686. end: expr.range[1]
  12687. };
  12688. }
  12689. function printLeadingComment(commentPath, print, options) {
  12690. var comment = commentPath.getValue();
  12691. var contents = printComment(commentPath, options);
  12692. if (!contents) {
  12693. return "";
  12694. }
  12695. var isBlock = options.printer.isBlockComment && options.printer.isBlockComment(comment); // Leading block comments should see if they need to stay on the
  12696. // same line or not.
  12697. if (isBlock) {
  12698. return concat([contents, hasNewline(options.originalText, options.locEnd(comment)) ? hardline : " "]);
  12699. }
  12700. return concat([contents, hardline]);
  12701. }
  12702. function printTrailingComment(commentPath, print, options) {
  12703. var comment = commentPath.getValue();
  12704. var contents = printComment(commentPath, options);
  12705. if (!contents) {
  12706. return "";
  12707. }
  12708. var isBlock = options.printer.isBlockComment && options.printer.isBlockComment(comment); // We don't want the line to break
  12709. // when the parentParentNode is a ClassDeclaration/-Expression
  12710. // And the parentNode is in the superClass property
  12711. var parentNode = commentPath.getNode(1);
  12712. var parentParentNode = commentPath.getNode(2);
  12713. var isParentSuperClass = parentParentNode && (parentParentNode.type === "ClassDeclaration" || parentParentNode.type === "ClassExpression") && parentParentNode.superClass === parentNode;
  12714. if (hasNewline(options.originalText, options.locStart(comment), {
  12715. backwards: true
  12716. })) {
  12717. // This allows comments at the end of nested structures:
  12718. // {
  12719. // x: 1,
  12720. // y: 2
  12721. // // A comment
  12722. // }
  12723. // Those kinds of comments are almost always leading comments, but
  12724. // here it doesn't go "outside" the block and turns it into a
  12725. // trailing comment for `2`. We can simulate the above by checking
  12726. // if this a comment on its own line; normal trailing comments are
  12727. // always at the end of another expression.
  12728. var isLineBeforeEmpty = isPreviousLineEmpty(options.originalText, comment, options.locStart);
  12729. return lineSuffix(concat([hardline, isLineBeforeEmpty ? hardline : "", contents]));
  12730. } else if (isBlock || isParentSuperClass) {
  12731. // Trailing block comments never need a newline
  12732. return concat([" ", contents]);
  12733. }
  12734. return concat([lineSuffix(concat([" ", contents])), !isBlock ? breakParent : ""]);
  12735. }
  12736. function printDanglingComments(path, options, sameIndent, filter) {
  12737. var parts = [];
  12738. var node = path.getValue();
  12739. if (!node || !node.comments) {
  12740. return "";
  12741. }
  12742. path.each(function (commentPath) {
  12743. var comment = commentPath.getValue();
  12744. if (comment && !comment.leading && !comment.trailing && (!filter || filter(comment))) {
  12745. parts.push(printComment(commentPath, options));
  12746. }
  12747. }, "comments");
  12748. if (parts.length === 0) {
  12749. return "";
  12750. }
  12751. if (sameIndent) {
  12752. return join(hardline, parts);
  12753. }
  12754. return indent(concat([hardline, join(hardline, parts)]));
  12755. }
  12756. function prependCursorPlaceholder(path, options, printed) {
  12757. if (path.getNode() === options.cursorNode && path.getValue()) {
  12758. return concat([cursor, printed, cursor]);
  12759. }
  12760. return printed;
  12761. }
  12762. function printComments(path, print, options, needsSemi) {
  12763. var value = path.getValue();
  12764. var printed = print(path);
  12765. var comments = value && value.comments;
  12766. if (!comments || comments.length === 0) {
  12767. return prependCursorPlaceholder(path, options, printed);
  12768. }
  12769. var leadingParts = [];
  12770. var trailingParts = [needsSemi ? ";" : "", printed];
  12771. path.each(function (commentPath) {
  12772. var comment = commentPath.getValue();
  12773. var leading = comment.leading,
  12774. trailing = comment.trailing;
  12775. if (leading) {
  12776. var contents = printLeadingComment(commentPath, print, options);
  12777. if (!contents) {
  12778. return;
  12779. }
  12780. leadingParts.push(contents);
  12781. var text = options.originalText;
  12782. if (hasNewline(text, skipNewline(text, options.locEnd(comment)))) {
  12783. leadingParts.push(hardline);
  12784. }
  12785. } else if (trailing) {
  12786. trailingParts.push(printTrailingComment(commentPath, print, options));
  12787. }
  12788. }, "comments");
  12789. return prependCursorPlaceholder(path, options, concat(leadingParts.concat(trailingParts)));
  12790. }
  12791. var comments = {
  12792. attach: attach,
  12793. printComments: printComments,
  12794. printDanglingComments: printDanglingComments,
  12795. getSortedChildNodes: getSortedChildNodes
  12796. };
  12797. function FastPath(value) {
  12798. assert$3.ok(this instanceof FastPath);
  12799. this.stack = [value];
  12800. } // The name of the current property is always the penultimate element of
  12801. // this.stack, and always a String.
  12802. FastPath.prototype.getName = function getName() {
  12803. var s = this.stack;
  12804. var len = s.length;
  12805. if (len > 1) {
  12806. return s[len - 2];
  12807. } // Since the name is always a string, null is a safe sentinel value to
  12808. // return if we do not know the name of the (root) value.
  12809. /* istanbul ignore next */
  12810. return null;
  12811. }; // The value of the current property is always the final element of
  12812. // this.stack.
  12813. FastPath.prototype.getValue = function getValue() {
  12814. var s = this.stack;
  12815. return s[s.length - 1];
  12816. };
  12817. function getNodeHelper(path, count) {
  12818. var stackIndex = getNodeStackIndexHelper(path.stack, count);
  12819. return stackIndex === -1 ? null : path.stack[stackIndex];
  12820. }
  12821. function getNodeStackIndexHelper(stack, count) {
  12822. for (var i = stack.length - 1; i >= 0; i -= 2) {
  12823. var value = stack[i];
  12824. if (value && !Array.isArray(value) && --count < 0) {
  12825. return i;
  12826. }
  12827. }
  12828. return -1;
  12829. }
  12830. FastPath.prototype.getNode = function getNode(count) {
  12831. return getNodeHelper(this, ~~count);
  12832. };
  12833. FastPath.prototype.getParentNode = function getParentNode(count) {
  12834. return getNodeHelper(this, ~~count + 1);
  12835. }; // Temporarily push properties named by string arguments given after the
  12836. // callback function onto this.stack, then call the callback with a
  12837. // reference to this (modified) FastPath object. Note that the stack will
  12838. // be restored to its original state after the callback is finished, so it
  12839. // is probably a mistake to retain a reference to the path.
  12840. FastPath.prototype.call = function call(callback
  12841. /*, name1, name2, ... */
  12842. ) {
  12843. var s = this.stack;
  12844. var origLen = s.length;
  12845. var value = s[origLen - 1];
  12846. var argc = arguments.length;
  12847. for (var i = 1; i < argc; ++i) {
  12848. var name = arguments[i];
  12849. value = value[name];
  12850. s.push(name, value);
  12851. }
  12852. var result = callback(this);
  12853. s.length = origLen;
  12854. return result;
  12855. };
  12856. FastPath.prototype.callParent = function callParent(callback, count) {
  12857. var stackIndex = getNodeStackIndexHelper(this.stack, ~~count + 1);
  12858. var parentValues = this.stack.splice(stackIndex + 1);
  12859. var result = callback(this);
  12860. Array.prototype.push.apply(this.stack, parentValues);
  12861. return result;
  12862. }; // Similar to FastPath.prototype.call, except that the value obtained by
  12863. // accessing this.getValue()[name1][name2]... should be array-like. The
  12864. // callback will be called with a reference to this path object for each
  12865. // element of the array.
  12866. FastPath.prototype.each = function each(callback
  12867. /*, name1, name2, ... */
  12868. ) {
  12869. var s = this.stack;
  12870. var origLen = s.length;
  12871. var value = s[origLen - 1];
  12872. var argc = arguments.length;
  12873. for (var i = 1; i < argc; ++i) {
  12874. var name = arguments[i];
  12875. value = value[name];
  12876. s.push(name, value);
  12877. }
  12878. for (var _i = 0; _i < value.length; ++_i) {
  12879. if (_i in value) {
  12880. s.push(_i, value[_i]); // If the callback needs to know the value of i, call
  12881. // path.getName(), assuming path is the parameter name.
  12882. callback(this);
  12883. s.length -= 2;
  12884. }
  12885. }
  12886. s.length = origLen;
  12887. }; // Similar to FastPath.prototype.each, except that the results of the
  12888. // callback function invocations are stored in an array and returned at
  12889. // the end of the iteration.
  12890. FastPath.prototype.map = function map(callback
  12891. /*, name1, name2, ... */
  12892. ) {
  12893. var s = this.stack;
  12894. var origLen = s.length;
  12895. var value = s[origLen - 1];
  12896. var argc = arguments.length;
  12897. for (var i = 1; i < argc; ++i) {
  12898. var name = arguments[i];
  12899. value = value[name];
  12900. s.push(name, value);
  12901. }
  12902. var result = new Array(value.length);
  12903. for (var _i2 = 0; _i2 < value.length; ++_i2) {
  12904. if (_i2 in value) {
  12905. s.push(_i2, value[_i2]);
  12906. result[_i2] = callback(this, _i2);
  12907. s.length -= 2;
  12908. }
  12909. }
  12910. s.length = origLen;
  12911. return result;
  12912. };
  12913. var fastPath = FastPath;
  12914. var normalize$3 = options.normalize;
  12915. function printSubtree(path, print, options$$1, printAstToDoc) {
  12916. if (options$$1.printer.embed) {
  12917. return options$$1.printer.embed(path, print, function (text, partialNextOptions) {
  12918. return textToDoc(text, partialNextOptions, options$$1, printAstToDoc);
  12919. }, options$$1);
  12920. }
  12921. }
  12922. function textToDoc(text, partialNextOptions, parentOptions, printAstToDoc) {
  12923. var nextOptions = normalize$3(Object.assign({}, parentOptions, partialNextOptions, {
  12924. parentParser: parentOptions.parser,
  12925. embeddedInHtml: !!(parentOptions.embeddedInHtml || parentOptions.parser === "html" || parentOptions.parser === "vue" || parentOptions.parser === "angular" || parentOptions.parser === "lwc"),
  12926. originalText: text
  12927. }), {
  12928. passThrough: true
  12929. });
  12930. var result = parser.parse(text, nextOptions);
  12931. var ast = result.ast;
  12932. text = result.text;
  12933. var astComments = ast.comments;
  12934. delete ast.comments;
  12935. comments.attach(astComments, ast, text, nextOptions);
  12936. return printAstToDoc(ast, nextOptions);
  12937. }
  12938. var multiparser = {
  12939. printSubtree: printSubtree
  12940. };
  12941. var doc$2 = doc;
  12942. var docBuilders$2 = doc$2.builders;
  12943. var concat$3 = docBuilders$2.concat;
  12944. var hardline$2 = docBuilders$2.hardline;
  12945. var addAlignmentToDoc$1 = docBuilders$2.addAlignmentToDoc;
  12946. var docUtils$2 = doc$2.utils;
  12947. /**
  12948. * Takes an abstract syntax tree (AST) and recursively converts it to a
  12949. * document (series of printing primitives).
  12950. *
  12951. * This is done by descending down the AST recursively. The recursion
  12952. * involves two functions that call each other:
  12953. *
  12954. * 1. printGenerically(), which is defined as an inner function here.
  12955. * It basically takes care of node caching.
  12956. * 2. callPluginPrintFunction(), which checks for some options, and
  12957. * ultimately calls the print() function provided by the plugin.
  12958. *
  12959. * The plugin function will call printGenerically() again for child nodes
  12960. * of the current node, which will do its housekeeping, then call the
  12961. * plugin function again, and so on.
  12962. *
  12963. * All the while, these functions pass a "path" variable around, which
  12964. * is a stack-like data structure (FastPath) that maintains the current
  12965. * state of the recursion. It is called "path", because it represents
  12966. * the path to the current node through the Abstract Syntax Tree.
  12967. */
  12968. function printAstToDoc(ast, options) {
  12969. var alignmentSize = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
  12970. var printer = options.printer;
  12971. if (printer.preprocess) {
  12972. ast = printer.preprocess(ast, options);
  12973. }
  12974. var cache = new Map();
  12975. function printGenerically(path, args) {
  12976. var node = path.getValue();
  12977. var shouldCache = node && _typeof(node) === "object" && args === undefined;
  12978. if (shouldCache && cache.has(node)) {
  12979. return cache.get(node);
  12980. } // We let JSXElement print its comments itself because it adds () around
  12981. // UnionTypeAnnotation has to align the child without the comments
  12982. var res;
  12983. if (printer.willPrintOwnComments && printer.willPrintOwnComments(path, options)) {
  12984. res = callPluginPrintFunction(path, options, printGenerically, args);
  12985. } else {
  12986. // printComments will call the plugin print function and check for
  12987. // comments to print
  12988. res = comments.printComments(path, function (p) {
  12989. return callPluginPrintFunction(p, options, printGenerically, args);
  12990. }, options, args && args.needsSemi);
  12991. }
  12992. if (shouldCache) {
  12993. cache.set(node, res);
  12994. }
  12995. return res;
  12996. }
  12997. var doc$$2 = printGenerically(new fastPath(ast));
  12998. if (alignmentSize > 0) {
  12999. // Add a hardline to make the indents take effect
  13000. // It should be removed in index.js format()
  13001. doc$$2 = addAlignmentToDoc$1(concat$3([hardline$2, doc$$2]), alignmentSize, options.tabWidth);
  13002. }
  13003. docUtils$2.propagateBreaks(doc$$2);
  13004. return doc$$2;
  13005. }
  13006. function callPluginPrintFunction(path, options, printPath, args) {
  13007. assert$3.ok(path instanceof fastPath);
  13008. var node = path.getValue();
  13009. var printer = options.printer; // Escape hatch
  13010. if (printer.hasPrettierIgnore && printer.hasPrettierIgnore(path)) {
  13011. return options.originalText.slice(options.locStart(node), options.locEnd(node));
  13012. }
  13013. if (node) {
  13014. try {
  13015. // Potentially switch to a different parser
  13016. var sub = multiparser.printSubtree(path, printPath, options, printAstToDoc);
  13017. if (sub) {
  13018. return sub;
  13019. }
  13020. } catch (error) {
  13021. /* istanbul ignore if */
  13022. if (commonjsGlobal.PRETTIER_DEBUG) {
  13023. throw error;
  13024. } // Continue with current parser
  13025. }
  13026. }
  13027. return printer.print(path, options, printPath, args);
  13028. }
  13029. var astToDoc = printAstToDoc;
  13030. function findSiblingAncestors(startNodeAndParents, endNodeAndParents, opts) {
  13031. var resultStartNode = startNodeAndParents.node;
  13032. var resultEndNode = endNodeAndParents.node;
  13033. if (resultStartNode === resultEndNode) {
  13034. return {
  13035. startNode: resultStartNode,
  13036. endNode: resultEndNode
  13037. };
  13038. }
  13039. var _iteratorNormalCompletion = true;
  13040. var _didIteratorError = false;
  13041. var _iteratorError = undefined;
  13042. try {
  13043. for (var _iterator = endNodeAndParents.parentNodes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  13044. var endParent = _step.value;
  13045. if (endParent.type !== "Program" && endParent.type !== "File" && opts.locStart(endParent) >= opts.locStart(startNodeAndParents.node)) {
  13046. resultEndNode = endParent;
  13047. } else {
  13048. break;
  13049. }
  13050. }
  13051. } catch (err) {
  13052. _didIteratorError = true;
  13053. _iteratorError = err;
  13054. } finally {
  13055. try {
  13056. if (!_iteratorNormalCompletion && _iterator.return != null) {
  13057. _iterator.return();
  13058. }
  13059. } finally {
  13060. if (_didIteratorError) {
  13061. throw _iteratorError;
  13062. }
  13063. }
  13064. }
  13065. var _iteratorNormalCompletion2 = true;
  13066. var _didIteratorError2 = false;
  13067. var _iteratorError2 = undefined;
  13068. try {
  13069. for (var _iterator2 = startNodeAndParents.parentNodes[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
  13070. var startParent = _step2.value;
  13071. if (startParent.type !== "Program" && startParent.type !== "File" && opts.locEnd(startParent) <= opts.locEnd(endNodeAndParents.node)) {
  13072. resultStartNode = startParent;
  13073. } else {
  13074. break;
  13075. }
  13076. }
  13077. } catch (err) {
  13078. _didIteratorError2 = true;
  13079. _iteratorError2 = err;
  13080. } finally {
  13081. try {
  13082. if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
  13083. _iterator2.return();
  13084. }
  13085. } finally {
  13086. if (_didIteratorError2) {
  13087. throw _iteratorError2;
  13088. }
  13089. }
  13090. }
  13091. return {
  13092. startNode: resultStartNode,
  13093. endNode: resultEndNode
  13094. };
  13095. }
  13096. function findNodeAtOffset(node, offset, options, predicate, parentNodes) {
  13097. predicate = predicate || function () {
  13098. return true;
  13099. };
  13100. parentNodes = parentNodes || [];
  13101. var start = options.locStart(node, options.locStart);
  13102. var end = options.locEnd(node, options.locEnd);
  13103. if (start <= offset && offset <= end) {
  13104. var _iteratorNormalCompletion3 = true;
  13105. var _didIteratorError3 = false;
  13106. var _iteratorError3 = undefined;
  13107. try {
  13108. for (var _iterator3 = comments.getSortedChildNodes(node, options)[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
  13109. var childNode = _step3.value;
  13110. var childResult = findNodeAtOffset(childNode, offset, options, predicate, [node].concat(parentNodes));
  13111. if (childResult) {
  13112. return childResult;
  13113. }
  13114. }
  13115. } catch (err) {
  13116. _didIteratorError3 = true;
  13117. _iteratorError3 = err;
  13118. } finally {
  13119. try {
  13120. if (!_iteratorNormalCompletion3 && _iterator3.return != null) {
  13121. _iterator3.return();
  13122. }
  13123. } finally {
  13124. if (_didIteratorError3) {
  13125. throw _iteratorError3;
  13126. }
  13127. }
  13128. }
  13129. if (predicate(node)) {
  13130. return {
  13131. node: node,
  13132. parentNodes: parentNodes
  13133. };
  13134. }
  13135. }
  13136. } // See https://www.ecma-international.org/ecma-262/5.1/#sec-A.5
  13137. function isSourceElement(opts, node) {
  13138. if (node == null) {
  13139. return false;
  13140. } // JS and JS like to avoid repetitions
  13141. var jsSourceElements = ["FunctionDeclaration", "BlockStatement", "BreakStatement", "ContinueStatement", "DebuggerStatement", "DoWhileStatement", "EmptyStatement", "ExpressionStatement", "ForInStatement", "ForStatement", "IfStatement", "LabeledStatement", "ReturnStatement", "SwitchStatement", "ThrowStatement", "TryStatement", "VariableDeclaration", "WhileStatement", "WithStatement", "ClassDeclaration", // ES 2015
  13142. "ImportDeclaration", // Module
  13143. "ExportDefaultDeclaration", // Module
  13144. "ExportNamedDeclaration", // Module
  13145. "ExportAllDeclaration", // Module
  13146. "TypeAlias", // Flow
  13147. "InterfaceDeclaration", // Flow, TypeScript
  13148. "TypeAliasDeclaration", // TypeScript
  13149. "ExportAssignment", // TypeScript
  13150. "ExportDeclaration" // TypeScript
  13151. ];
  13152. var jsonSourceElements = ["ObjectExpression", "ArrayExpression", "StringLiteral", "NumericLiteral", "BooleanLiteral", "NullLiteral"];
  13153. var graphqlSourceElements = ["OperationDefinition", "FragmentDefinition", "VariableDefinition", "TypeExtensionDefinition", "ObjectTypeDefinition", "FieldDefinition", "DirectiveDefinition", "EnumTypeDefinition", "EnumValueDefinition", "InputValueDefinition", "InputObjectTypeDefinition", "SchemaDefinition", "OperationTypeDefinition", "InterfaceTypeDefinition", "UnionTypeDefinition", "ScalarTypeDefinition"];
  13154. switch (opts.parser) {
  13155. case "flow":
  13156. case "babel":
  13157. case "typescript":
  13158. return jsSourceElements.indexOf(node.type) > -1;
  13159. case "json":
  13160. return jsonSourceElements.indexOf(node.type) > -1;
  13161. case "graphql":
  13162. return graphqlSourceElements.indexOf(node.kind) > -1;
  13163. case "vue":
  13164. return node.tag !== "root";
  13165. }
  13166. return false;
  13167. }
  13168. function calculateRange(text, opts, ast) {
  13169. // Contract the range so that it has non-whitespace characters at its endpoints.
  13170. // This ensures we can format a range that doesn't end on a node.
  13171. var rangeStringOrig = text.slice(opts.rangeStart, opts.rangeEnd);
  13172. var startNonWhitespace = Math.max(opts.rangeStart + rangeStringOrig.search(/\S/), opts.rangeStart);
  13173. var endNonWhitespace;
  13174. for (endNonWhitespace = opts.rangeEnd; endNonWhitespace > opts.rangeStart; --endNonWhitespace) {
  13175. if (text[endNonWhitespace - 1].match(/\S/)) {
  13176. break;
  13177. }
  13178. }
  13179. var startNodeAndParents = findNodeAtOffset(ast, startNonWhitespace, opts, function (node) {
  13180. return isSourceElement(opts, node);
  13181. });
  13182. var endNodeAndParents = findNodeAtOffset(ast, endNonWhitespace, opts, function (node) {
  13183. return isSourceElement(opts, node);
  13184. });
  13185. if (!startNodeAndParents || !endNodeAndParents) {
  13186. return {
  13187. rangeStart: 0,
  13188. rangeEnd: 0
  13189. };
  13190. }
  13191. var siblingAncestors = findSiblingAncestors(startNodeAndParents, endNodeAndParents, opts);
  13192. var startNode = siblingAncestors.startNode,
  13193. endNode = siblingAncestors.endNode;
  13194. var rangeStart = Math.min(opts.locStart(startNode, opts.locStart), opts.locStart(endNode, opts.locStart));
  13195. var rangeEnd = Math.max(opts.locEnd(startNode, opts.locEnd), opts.locEnd(endNode, opts.locEnd));
  13196. return {
  13197. rangeStart: rangeStart,
  13198. rangeEnd: rangeEnd
  13199. };
  13200. }
  13201. var rangeUtil = {
  13202. calculateRange: calculateRange,
  13203. findNodeAtOffset: findNodeAtOffset
  13204. };
  13205. var normalizeOptions = options.normalize;
  13206. var guessEndOfLine = endOfLine.guessEndOfLine;
  13207. var convertEndOfLineToChars = endOfLine.convertEndOfLineToChars;
  13208. var mapDoc = doc.utils.mapDoc;
  13209. var _printDocToString = doc.printer.printDocToString;
  13210. var printDocToDebug = doc.debug.printDocToDebug;
  13211. var UTF8BOM = 0xfeff;
  13212. var CURSOR = Symbol("cursor");
  13213. var PLACEHOLDERS = {
  13214. cursorOffset: "<<<PRETTIER_CURSOR>>>",
  13215. rangeStart: "<<<PRETTIER_RANGE_START>>>",
  13216. rangeEnd: "<<<PRETTIER_RANGE_END>>>"
  13217. };
  13218. function ensureAllCommentsPrinted(astComments) {
  13219. if (!astComments) {
  13220. return;
  13221. }
  13222. for (var i = 0; i < astComments.length; ++i) {
  13223. if (astComments[i].value.trim() === "prettier-ignore") {
  13224. // If there's a prettier-ignore, we're not printing that sub-tree so we
  13225. // don't know if the comments was printed or not.
  13226. return;
  13227. }
  13228. }
  13229. astComments.forEach(function (comment) {
  13230. if (!comment.printed) {
  13231. throw new Error('Comment "' + comment.value.trim() + '" was not printed. Please report this error!');
  13232. }
  13233. delete comment.printed;
  13234. });
  13235. }
  13236. function attachComments(text, ast, opts) {
  13237. var astComments = ast.comments;
  13238. if (astComments) {
  13239. delete ast.comments;
  13240. comments.attach(astComments, ast, text, opts);
  13241. }
  13242. ast.tokens = [];
  13243. opts.originalText = opts.parser === "yaml" ? text : text.trimRight();
  13244. return astComments;
  13245. }
  13246. function coreFormat(text, opts, addAlignmentSize) {
  13247. if (!text || !text.trim().length) {
  13248. return {
  13249. formatted: "",
  13250. cursorOffset: 0
  13251. };
  13252. }
  13253. addAlignmentSize = addAlignmentSize || 0;
  13254. var parsed = parser.parse(text, opts);
  13255. var ast = parsed.ast;
  13256. text = parsed.text;
  13257. if (opts.cursorOffset >= 0) {
  13258. var nodeResult = rangeUtil.findNodeAtOffset(ast, opts.cursorOffset, opts);
  13259. if (nodeResult && nodeResult.node) {
  13260. opts.cursorNode = nodeResult.node;
  13261. }
  13262. }
  13263. var astComments = attachComments(text, ast, opts);
  13264. var doc$$1 = astToDoc(ast, opts, addAlignmentSize);
  13265. var eol = convertEndOfLineToChars(opts.endOfLine);
  13266. var result = _printDocToString(opts.endOfLine === "lf" ? doc$$1 : mapDoc(doc$$1, function (currentDoc) {
  13267. return typeof currentDoc === "string" && currentDoc.indexOf("\n") !== -1 ? currentDoc.replace(/\n/g, eol) : currentDoc;
  13268. }), opts);
  13269. ensureAllCommentsPrinted(astComments); // Remove extra leading indentation as well as the added indentation after last newline
  13270. if (addAlignmentSize > 0) {
  13271. var trimmed = result.formatted.trim();
  13272. if (result.cursorNodeStart !== undefined) {
  13273. result.cursorNodeStart -= result.formatted.indexOf(trimmed);
  13274. }
  13275. result.formatted = trimmed + convertEndOfLineToChars(opts.endOfLine);
  13276. }
  13277. if (opts.cursorOffset >= 0) {
  13278. var oldCursorNodeStart;
  13279. var oldCursorNodeText;
  13280. var cursorOffsetRelativeToOldCursorNode;
  13281. var newCursorNodeStart;
  13282. var newCursorNodeText;
  13283. if (opts.cursorNode && result.cursorNodeText) {
  13284. oldCursorNodeStart = opts.locStart(opts.cursorNode);
  13285. oldCursorNodeText = text.slice(oldCursorNodeStart, opts.locEnd(opts.cursorNode));
  13286. cursorOffsetRelativeToOldCursorNode = opts.cursorOffset - oldCursorNodeStart;
  13287. newCursorNodeStart = result.cursorNodeStart;
  13288. newCursorNodeText = result.cursorNodeText;
  13289. } else {
  13290. oldCursorNodeStart = 0;
  13291. oldCursorNodeText = text;
  13292. cursorOffsetRelativeToOldCursorNode = opts.cursorOffset;
  13293. newCursorNodeStart = 0;
  13294. newCursorNodeText = result.formatted;
  13295. }
  13296. if (oldCursorNodeText === newCursorNodeText) {
  13297. return {
  13298. formatted: result.formatted,
  13299. cursorOffset: newCursorNodeStart + cursorOffsetRelativeToOldCursorNode
  13300. };
  13301. } // diff old and new cursor node texts, with a special cursor
  13302. // symbol inserted to find out where it moves to
  13303. var oldCursorNodeCharArray = oldCursorNodeText.split("");
  13304. oldCursorNodeCharArray.splice(cursorOffsetRelativeToOldCursorNode, 0, CURSOR);
  13305. var newCursorNodeCharArray = newCursorNodeText.split("");
  13306. var cursorNodeDiff = lib.diffArrays(oldCursorNodeCharArray, newCursorNodeCharArray);
  13307. var cursorOffset = newCursorNodeStart;
  13308. var _iteratorNormalCompletion = true;
  13309. var _didIteratorError = false;
  13310. var _iteratorError = undefined;
  13311. try {
  13312. for (var _iterator = cursorNodeDiff[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  13313. var entry = _step.value;
  13314. if (entry.removed) {
  13315. if (entry.value.indexOf(CURSOR) > -1) {
  13316. break;
  13317. }
  13318. } else {
  13319. cursorOffset += entry.count;
  13320. }
  13321. }
  13322. } catch (err) {
  13323. _didIteratorError = true;
  13324. _iteratorError = err;
  13325. } finally {
  13326. try {
  13327. if (!_iteratorNormalCompletion && _iterator.return != null) {
  13328. _iterator.return();
  13329. }
  13330. } finally {
  13331. if (_didIteratorError) {
  13332. throw _iteratorError;
  13333. }
  13334. }
  13335. }
  13336. return {
  13337. formatted: result.formatted,
  13338. cursorOffset: cursorOffset
  13339. };
  13340. }
  13341. return {
  13342. formatted: result.formatted
  13343. };
  13344. }
  13345. function formatRange(text, opts) {
  13346. var parsed = parser.parse(text, opts);
  13347. var ast = parsed.ast;
  13348. text = parsed.text;
  13349. var range = rangeUtil.calculateRange(text, opts, ast);
  13350. var rangeStart = range.rangeStart;
  13351. var rangeEnd = range.rangeEnd;
  13352. var rangeString = text.slice(rangeStart, rangeEnd); // Try to extend the range backwards to the beginning of the line.
  13353. // This is so we can detect indentation correctly and restore it.
  13354. // Use `Math.min` since `lastIndexOf` returns 0 when `rangeStart` is 0
  13355. var rangeStart2 = Math.min(rangeStart, text.lastIndexOf("\n", rangeStart) + 1);
  13356. var indentString = text.slice(rangeStart2, rangeStart);
  13357. var alignmentSize = util.getAlignmentSize(indentString, opts.tabWidth);
  13358. var rangeResult = coreFormat(rangeString, Object.assign({}, opts, {
  13359. rangeStart: 0,
  13360. rangeEnd: Infinity,
  13361. // track the cursor offset only if it's within our range
  13362. cursorOffset: opts.cursorOffset >= rangeStart && opts.cursorOffset < rangeEnd ? opts.cursorOffset - rangeStart : -1
  13363. }), alignmentSize); // Since the range contracts to avoid trailing whitespace,
  13364. // we need to remove the newline that was inserted by the `format` call.
  13365. var rangeTrimmed = rangeResult.formatted.trimRight();
  13366. var rangeLeft = text.slice(0, rangeStart);
  13367. var rangeRight = text.slice(rangeEnd);
  13368. var cursorOffset = opts.cursorOffset;
  13369. if (opts.cursorOffset >= rangeEnd) {
  13370. // handle the case where the cursor was past the end of the range
  13371. cursorOffset = opts.cursorOffset - rangeEnd + (rangeStart + rangeTrimmed.length);
  13372. } else if (rangeResult.cursorOffset !== undefined) {
  13373. // handle the case where the cursor was in the range
  13374. cursorOffset = rangeResult.cursorOffset + rangeStart;
  13375. } // keep the cursor as it was if it was before the start of the range
  13376. var formatted;
  13377. if (opts.endOfLine === "lf") {
  13378. formatted = rangeLeft + rangeTrimmed + rangeRight;
  13379. } else {
  13380. var eol = convertEndOfLineToChars(opts.endOfLine);
  13381. if (cursorOffset >= 0) {
  13382. var parts = [rangeLeft, rangeTrimmed, rangeRight];
  13383. var partIndex = 0;
  13384. var partOffset = cursorOffset;
  13385. while (partIndex < parts.length) {
  13386. var part = parts[partIndex];
  13387. if (partOffset < part.length) {
  13388. parts[partIndex] = parts[partIndex].slice(0, partOffset) + PLACEHOLDERS.cursorOffset + parts[partIndex].slice(partOffset);
  13389. break;
  13390. }
  13391. partIndex++;
  13392. partOffset -= part.length;
  13393. }
  13394. var newRangeLeft = parts[0],
  13395. newRangeTrimmed = parts[1],
  13396. newRangeRight = parts[2];
  13397. formatted = (newRangeLeft.replace(/\n/g, eol) + newRangeTrimmed + newRangeRight.replace(/\n/g, eol)).replace(PLACEHOLDERS.cursorOffset, function (_, index) {
  13398. cursorOffset = index;
  13399. return "";
  13400. });
  13401. } else {
  13402. formatted = rangeLeft.replace(/\n/g, eol) + rangeTrimmed + rangeRight.replace(/\n/g, eol);
  13403. }
  13404. }
  13405. return {
  13406. formatted: formatted,
  13407. cursorOffset: cursorOffset
  13408. };
  13409. }
  13410. function format(text, opts) {
  13411. var selectedParser = parser.resolveParser(opts);
  13412. var hasPragma = !selectedParser.hasPragma || selectedParser.hasPragma(text);
  13413. if (opts.requirePragma && !hasPragma) {
  13414. return {
  13415. formatted: text
  13416. };
  13417. }
  13418. if (opts.endOfLine === "auto") {
  13419. opts.endOfLine = guessEndOfLine(text);
  13420. }
  13421. var hasCursor = opts.cursorOffset >= 0;
  13422. var hasRangeStart = opts.rangeStart > 0;
  13423. var hasRangeEnd = opts.rangeEnd < text.length; // get rid of CR/CRLF parsing
  13424. if (text.indexOf("\r") !== -1) {
  13425. var offsetKeys = [hasCursor && "cursorOffset", hasRangeStart && "rangeStart", hasRangeEnd && "rangeEnd"].filter(Boolean).sort(function (aKey, bKey) {
  13426. return opts[aKey] - opts[bKey];
  13427. });
  13428. for (var i = offsetKeys.length - 1; i >= 0; i--) {
  13429. var key = offsetKeys[i];
  13430. text = text.slice(0, opts[key]) + PLACEHOLDERS[key] + text.slice(opts[key]);
  13431. }
  13432. text = text.replace(/\r\n?/g, "\n");
  13433. var _loop = function _loop(_i) {
  13434. var key = offsetKeys[_i];
  13435. text = text.replace(PLACEHOLDERS[key], function (_, index) {
  13436. opts[key] = index;
  13437. return "";
  13438. });
  13439. };
  13440. for (var _i = 0; _i < offsetKeys.length; _i++) {
  13441. _loop(_i);
  13442. }
  13443. }
  13444. var hasUnicodeBOM = text.charCodeAt(0) === UTF8BOM;
  13445. if (hasUnicodeBOM) {
  13446. text = text.substring(1);
  13447. if (hasCursor) {
  13448. opts.cursorOffset++;
  13449. }
  13450. if (hasRangeStart) {
  13451. opts.rangeStart++;
  13452. }
  13453. if (hasRangeEnd) {
  13454. opts.rangeEnd++;
  13455. }
  13456. }
  13457. if (!hasCursor) {
  13458. opts.cursorOffset = -1;
  13459. }
  13460. if (opts.rangeStart < 0) {
  13461. opts.rangeStart = 0;
  13462. }
  13463. if (opts.rangeEnd > text.length) {
  13464. opts.rangeEnd = text.length;
  13465. }
  13466. var result = hasRangeStart || hasRangeEnd ? formatRange(text, opts) : coreFormat(opts.insertPragma && opts.printer.insertPragma && !hasPragma ? opts.printer.insertPragma(text) : text, opts);
  13467. if (hasUnicodeBOM) {
  13468. result.formatted = String.fromCharCode(UTF8BOM) + result.formatted;
  13469. if (hasCursor) {
  13470. result.cursorOffset++;
  13471. }
  13472. }
  13473. return result;
  13474. }
  13475. var core = {
  13476. formatWithCursor: function formatWithCursor(text, opts) {
  13477. opts = normalizeOptions(opts);
  13478. return format(text, opts);
  13479. },
  13480. parse: function parse(text, opts, massage) {
  13481. opts = normalizeOptions(opts);
  13482. if (text.indexOf("\r") !== -1) {
  13483. text = text.replace(/\r\n?/g, "\n");
  13484. }
  13485. var parsed = parser.parse(text, opts);
  13486. if (massage) {
  13487. parsed.ast = massageAst(parsed.ast, opts);
  13488. }
  13489. return parsed;
  13490. },
  13491. formatAST: function formatAST(ast, opts) {
  13492. opts = normalizeOptions(opts);
  13493. var doc$$1 = astToDoc(ast, opts);
  13494. return _printDocToString(doc$$1, opts);
  13495. },
  13496. // Doesn't handle shebang for now
  13497. formatDoc: function formatDoc(doc$$1, opts) {
  13498. var debug = printDocToDebug(doc$$1);
  13499. opts = normalizeOptions(Object.assign({}, opts, {
  13500. parser: "babel"
  13501. }));
  13502. return format(debug, opts).formatted;
  13503. },
  13504. printToDoc: function printToDoc(text, opts) {
  13505. opts = normalizeOptions(opts);
  13506. var parsed = parser.parse(text, opts);
  13507. var ast = parsed.ast;
  13508. text = parsed.text;
  13509. attachComments(text, ast, opts);
  13510. return astToDoc(ast, opts);
  13511. },
  13512. printDocToString: function printDocToString(doc$$1, opts) {
  13513. return _printDocToString(doc$$1, normalizeOptions(opts));
  13514. }
  13515. };
  13516. 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"];
  13517. var htmlTagNames = Object.freeze({
  13518. default: index$11
  13519. });
  13520. var htmlTagNames$1 = ( htmlTagNames && index$11 ) || htmlTagNames;
  13521. function clean(ast, newObj, parent) {
  13522. ["raw", // front-matter
  13523. "raws", "sourceIndex", "source", "before", "after", "trailingComma"].forEach(function (name) {
  13524. delete newObj[name];
  13525. });
  13526. if (ast.type === "yaml") {
  13527. delete newObj.value;
  13528. } // --insert-pragma
  13529. if (ast.type === "css-comment" && parent.type === "css-root" && parent.nodes.length !== 0 && ( // first non-front-matter comment
  13530. parent.nodes[0] === ast || (parent.nodes[0].type === "yaml" || parent.nodes[0].type === "toml") && parent.nodes[1] === ast)) {
  13531. /**
  13532. * something
  13533. *
  13534. * @format
  13535. */
  13536. delete newObj.text; // standalone pragma
  13537. if (/^\*\s*@(format|prettier)\s*$/.test(ast.text)) {
  13538. return null;
  13539. }
  13540. }
  13541. if (ast.type === "media-query" || ast.type === "media-query-list" || ast.type === "media-feature-expression") {
  13542. delete newObj.value;
  13543. }
  13544. if (ast.type === "css-rule") {
  13545. delete newObj.params;
  13546. }
  13547. if (ast.type === "selector-combinator") {
  13548. newObj.value = newObj.value.replace(/\s+/g, " ");
  13549. }
  13550. if (ast.type === "media-feature") {
  13551. newObj.value = newObj.value.replace(/ /g, "");
  13552. }
  13553. 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") {
  13554. newObj.value = newObj.value.toLowerCase();
  13555. }
  13556. if (ast.type === "css-decl") {
  13557. newObj.prop = newObj.prop.toLowerCase();
  13558. }
  13559. if (ast.type === "css-atrule" || ast.type === "css-import") {
  13560. newObj.name = newObj.name.toLowerCase();
  13561. }
  13562. if (ast.type === "value-number") {
  13563. newObj.unit = newObj.unit.toLowerCase();
  13564. }
  13565. 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) {
  13566. newObj.value = cleanCSSStrings(newObj.value);
  13567. }
  13568. if (ast.type === "selector-attribute") {
  13569. newObj.attribute = newObj.attribute.trim();
  13570. if (newObj.namespace) {
  13571. if (typeof newObj.namespace === "string") {
  13572. newObj.namespace = newObj.namespace.trim();
  13573. if (newObj.namespace.length === 0) {
  13574. newObj.namespace = true;
  13575. }
  13576. }
  13577. }
  13578. if (newObj.value) {
  13579. newObj.value = newObj.value.trim().replace(/^['"]|['"]$/g, "");
  13580. delete newObj.quoted;
  13581. }
  13582. }
  13583. 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) {
  13584. newObj.value = newObj.value.replace(/([\d.eE+-]+)([a-zA-Z]*)/g, function (match, numStr, unit) {
  13585. var num = Number(numStr);
  13586. return isNaN(num) ? match : num + unit.toLowerCase();
  13587. });
  13588. }
  13589. if (ast.type === "selector-tag") {
  13590. var lowercasedValue = ast.value.toLowerCase();
  13591. if (htmlTagNames$1.indexOf(lowercasedValue) !== -1) {
  13592. newObj.value = lowercasedValue;
  13593. }
  13594. if (["from", "to"].indexOf(lowercasedValue) !== -1) {
  13595. newObj.value = lowercasedValue;
  13596. }
  13597. } // Workaround when `postcss-values-parser` parse `not`, `and` or `or` keywords as `value-func`
  13598. if (ast.type === "css-atrule" && ast.name.toLowerCase() === "supports") {
  13599. delete newObj.value;
  13600. } // Workaround for SCSS nested properties
  13601. if (ast.type === "selector-unknown") {
  13602. delete newObj.value;
  13603. }
  13604. }
  13605. function cleanCSSStrings(value) {
  13606. return value.replace(/'/g, '"').replace(/\\([^a-fA-F\d])/g, "$1");
  13607. }
  13608. var clean_1 = clean;
  13609. var _require$$0$builders$1 = doc.builders;
  13610. var hardline$4 = _require$$0$builders$1.hardline;
  13611. var literalline$1 = _require$$0$builders$1.literalline;
  13612. var concat$5 = _require$$0$builders$1.concat;
  13613. var markAsRoot$1 = _require$$0$builders$1.markAsRoot;
  13614. var mapDoc$3 = doc.utils.mapDoc;
  13615. function embed(path, print, textToDoc
  13616. /*, options */
  13617. ) {
  13618. var node = path.getValue();
  13619. if (node.type === "yaml") {
  13620. return markAsRoot$1(concat$5(["---", hardline$4, node.value.trim() ? replaceNewlinesWithLiterallines(textToDoc(node.value, {
  13621. parser: "yaml"
  13622. })) : "", "---", hardline$4]));
  13623. }
  13624. return null;
  13625. function replaceNewlinesWithLiterallines(doc$$2) {
  13626. return mapDoc$3(doc$$2, function (currentDoc) {
  13627. return typeof currentDoc === "string" && currentDoc.includes("\n") ? concat$5(currentDoc.split(/(\n)/g).map(function (v, i) {
  13628. return i % 2 === 0 ? v : literalline$1;
  13629. })) : currentDoc;
  13630. });
  13631. }
  13632. }
  13633. var embed_1 = embed;
  13634. var detectNewline = createCommonjsModule(function (module) {
  13635. 'use strict';
  13636. module.exports = function (str) {
  13637. if (typeof str !== 'string') {
  13638. throw new TypeError('Expected a string');
  13639. }
  13640. var newlines = str.match(/(?:\r?\n)/g) || [];
  13641. if (newlines.length === 0) {
  13642. return null;
  13643. }
  13644. var crlf = newlines.filter(function (el) {
  13645. return el === '\r\n';
  13646. }).length;
  13647. var lf = newlines.length - crlf;
  13648. return crlf > lf ? '\r\n' : '\n';
  13649. };
  13650. module.exports.graceful = function (str) {
  13651. return module.exports(str) || '\n';
  13652. };
  13653. });
  13654. var build$1 = createCommonjsModule(function (module, exports) {
  13655. 'use strict';
  13656. Object.defineProperty(exports, '__esModule', {
  13657. value: true
  13658. });
  13659. exports.extract = extract;
  13660. exports.strip = strip;
  13661. exports.parse = parse;
  13662. exports.parseWithComments = parseWithComments;
  13663. exports.print = print;
  13664. var _detectNewline;
  13665. function _load_detectNewline() {
  13666. return _detectNewline = _interopRequireDefault(detectNewline);
  13667. }
  13668. var _os;
  13669. function _load_os() {
  13670. return _os = require$$1$1;
  13671. }
  13672. function _interopRequireDefault(obj) {
  13673. return obj && obj.__esModule ? obj : {
  13674. default: obj
  13675. };
  13676. }
  13677. /**
  13678. * Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
  13679. *
  13680. * This source code is licensed under the MIT license found in the
  13681. * LICENSE file in the root directory of this source tree.
  13682. *
  13683. *
  13684. */
  13685. var commentEndRe = /\*\/$/;
  13686. var commentStartRe = /^\/\*\*/;
  13687. var docblockRe = /^\s*(\/\*\*?(.|\r?\n)*?\*\/)/;
  13688. var lineCommentRe = /(^|\s+)\/\/([^\r\n]*)/g;
  13689. var ltrimNewlineRe = /^(\r?\n)+/;
  13690. var multilineRe = /(?:^|\r?\n) *(@[^\r\n]*?) *\r?\n *(?![^@\r\n]*\/\/[^]*)([^@\r\n\s][^@\r\n]+?) *\r?\n/g;
  13691. var propertyRe = /(?:^|\r?\n) *@(\S+) *([^\r\n]*)/g;
  13692. var stringStartRe = /(\r?\n|^) *\* ?/g;
  13693. function extract(contents) {
  13694. var match = contents.match(docblockRe);
  13695. return match ? match[0].trimLeft() : '';
  13696. }
  13697. function strip(contents) {
  13698. var match = contents.match(docblockRe);
  13699. return match && match[0] ? contents.substring(match[0].length) : contents;
  13700. }
  13701. function parse(docblock) {
  13702. return parseWithComments(docblock).pragmas;
  13703. }
  13704. function parseWithComments(docblock) {
  13705. var line = (0, (_detectNewline || _load_detectNewline()).default)(docblock) || (_os || _load_os()).EOL;
  13706. docblock = docblock.replace(commentStartRe, '').replace(commentEndRe, '').replace(stringStartRe, '$1'); // Normalize multi-line directives
  13707. var prev = '';
  13708. while (prev !== docblock) {
  13709. prev = docblock;
  13710. docblock = docblock.replace(multilineRe, "".concat(line, "$1 $2").concat(line));
  13711. }
  13712. docblock = docblock.replace(ltrimNewlineRe, '').trimRight();
  13713. var result = Object.create(null);
  13714. var comments = docblock.replace(propertyRe, '').replace(ltrimNewlineRe, '').trimRight();
  13715. var match;
  13716. while (match = propertyRe.exec(docblock)) {
  13717. // strip linecomments from pragmas
  13718. var nextPragma = match[2].replace(lineCommentRe, '');
  13719. if (typeof result[match[1]] === 'string' || Array.isArray(result[match[1]])) {
  13720. result[match[1]] = [].concat(result[match[1]], nextPragma);
  13721. } else {
  13722. result[match[1]] = nextPragma;
  13723. }
  13724. }
  13725. return {
  13726. comments: comments,
  13727. pragmas: result
  13728. };
  13729. }
  13730. function print(_ref) {
  13731. var _ref$comments = _ref.comments;
  13732. var comments = _ref$comments === undefined ? '' : _ref$comments;
  13733. var _ref$pragmas = _ref.pragmas;
  13734. var pragmas = _ref$pragmas === undefined ? {} : _ref$pragmas;
  13735. var line = (0, (_detectNewline || _load_detectNewline()).default)(comments) || (_os || _load_os()).EOL;
  13736. var head = '/**';
  13737. var start = ' *';
  13738. var tail = ' */';
  13739. var keys = Object.keys(pragmas);
  13740. var printedObject = keys.map(function (key) {
  13741. return printKeyValues(key, pragmas[key]);
  13742. }).reduce(function (arr, next) {
  13743. return arr.concat(next);
  13744. }, []).map(function (keyValue) {
  13745. return start + ' ' + keyValue + line;
  13746. }).join('');
  13747. if (!comments) {
  13748. if (keys.length === 0) {
  13749. return '';
  13750. }
  13751. if (keys.length === 1 && !Array.isArray(pragmas[keys[0]])) {
  13752. var value = pragmas[keys[0]];
  13753. return "".concat(head, " ").concat(printKeyValues(keys[0], value)[0]).concat(tail);
  13754. }
  13755. }
  13756. var printedComments = comments.split(line).map(function (textLine) {
  13757. return "".concat(start, " ").concat(textLine);
  13758. }).join(line) + line;
  13759. return head + line + (comments ? printedComments : '') + (comments && keys.length ? start + line : '') + printedObject + tail;
  13760. }
  13761. function printKeyValues(key, valueOrArray) {
  13762. return [].concat(valueOrArray).map(function (value) {
  13763. return "@".concat(key, " ").concat(value).trim();
  13764. });
  13765. }
  13766. });
  13767. unwrapExports(build$1);
  13768. function hasPragma$1(text) {
  13769. var pragmas = Object.keys(build$1.parse(build$1.extract(text)));
  13770. return pragmas.indexOf("prettier") !== -1 || pragmas.indexOf("format") !== -1;
  13771. }
  13772. function insertPragma$2(text) {
  13773. var parsedDocblock = build$1.parseWithComments(build$1.extract(text));
  13774. var pragmas = Object.assign({
  13775. format: ""
  13776. }, parsedDocblock.pragmas);
  13777. var newDocblock = build$1.print({
  13778. pragmas: pragmas,
  13779. comments: parsedDocblock.comments.replace(/^(\s+?\r?\n)+/, "") // remove leading newlines
  13780. }).replace(/(\r\n|\r)/g, "\n"); // normalise newlines (mitigate use of os.EOL by jest-docblock)
  13781. var strippedText = build$1.strip(text);
  13782. var separatingNewlines = strippedText.startsWith("\n") ? "\n" : "\n\n";
  13783. return newDocblock + separatingNewlines + strippedText;
  13784. }
  13785. var pragma$2 = {
  13786. hasPragma: hasPragma$1,
  13787. insertPragma: insertPragma$2
  13788. };
  13789. var DELIMITER_MAP = {
  13790. "---": "yaml",
  13791. "+++": "toml"
  13792. };
  13793. function parse$3(text) {
  13794. var delimiterRegex = Object.keys(DELIMITER_MAP).map(escapeStringRegexp).join("|");
  13795. var match = text.match( // trailing spaces after delimiters are allowed
  13796. new RegExp("^(".concat(delimiterRegex, ")[^\\n\\S]*\\n(?:([\\s\\S]*?)\\n)?\\1[^\\n\\S]*(\\n|$)")));
  13797. if (match === null) {
  13798. return {
  13799. frontMatter: null,
  13800. content: text
  13801. };
  13802. }
  13803. var raw = match[0].replace(/\n$/, "");
  13804. var delimiter = match[1];
  13805. var value = match[2];
  13806. return {
  13807. frontMatter: {
  13808. type: DELIMITER_MAP[delimiter],
  13809. value: value,
  13810. raw: raw
  13811. },
  13812. content: match[0].replace(/[^\n]/g, " ") + text.slice(match[0].length)
  13813. };
  13814. }
  13815. var frontMatter = parse$3;
  13816. function hasPragma(text) {
  13817. return pragma$2.hasPragma(frontMatter(text).content);
  13818. }
  13819. function insertPragma$1(text) {
  13820. var _parseFrontMatter = frontMatter(text),
  13821. frontMatter$$1 = _parseFrontMatter.frontMatter,
  13822. content = _parseFrontMatter.content;
  13823. return (frontMatter$$1 ? frontMatter$$1.raw + "\n\n" : "") + pragma$2.insertPragma(content);
  13824. }
  13825. var pragma = {
  13826. hasPragma: hasPragma,
  13827. insertPragma: insertPragma$1
  13828. };
  13829. 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"];
  13830. function getAncestorCounter(path, typeOrTypes) {
  13831. var types = [].concat(typeOrTypes);
  13832. var counter = -1;
  13833. var ancestorNode;
  13834. while (ancestorNode = path.getParentNode(++counter)) {
  13835. if (types.indexOf(ancestorNode.type) !== -1) {
  13836. return counter;
  13837. }
  13838. }
  13839. return -1;
  13840. }
  13841. function getAncestorNode$1(path, typeOrTypes) {
  13842. var counter = getAncestorCounter(path, typeOrTypes);
  13843. return counter === -1 ? null : path.getParentNode(counter);
  13844. }
  13845. function getPropOfDeclNode$1(path) {
  13846. var declAncestorNode = getAncestorNode$1(path, "css-decl");
  13847. return declAncestorNode && declAncestorNode.prop && declAncestorNode.prop.toLowerCase();
  13848. }
  13849. function isSCSS$1(parser, text) {
  13850. var hasExplicitParserChoice = parser === "less" || parser === "scss";
  13851. var IS_POSSIBLY_SCSS = /(\w\s*: [^}:]+|#){|@import[^\n]+(url|,)/;
  13852. return hasExplicitParserChoice ? parser === "scss" : IS_POSSIBLY_SCSS.test(text);
  13853. }
  13854. function isWideKeywords$1(value) {
  13855. return ["initial", "inherit", "unset", "revert"].indexOf(value.toLowerCase()) !== -1;
  13856. }
  13857. function isKeyframeAtRuleKeywords$1(path, value) {
  13858. var atRuleAncestorNode = getAncestorNode$1(path, "css-atrule");
  13859. return atRuleAncestorNode && atRuleAncestorNode.name && atRuleAncestorNode.name.toLowerCase().endsWith("keyframes") && ["from", "to"].indexOf(value.toLowerCase()) !== -1;
  13860. }
  13861. function maybeToLowerCase$1(value) {
  13862. return value.includes("$") || value.includes("@") || value.includes("#") || value.startsWith("%") || value.startsWith("--") || value.startsWith(":--") || value.includes("(") && value.includes(")") ? value : value.toLowerCase();
  13863. }
  13864. function insideValueFunctionNode$1(path, functionName) {
  13865. var funcAncestorNode = getAncestorNode$1(path, "value-func");
  13866. return funcAncestorNode && funcAncestorNode.value && funcAncestorNode.value.toLowerCase() === functionName;
  13867. }
  13868. function insideICSSRuleNode$1(path) {
  13869. var ruleAncestorNode = getAncestorNode$1(path, "css-rule");
  13870. return ruleAncestorNode && ruleAncestorNode.raws && ruleAncestorNode.raws.selector && (ruleAncestorNode.raws.selector.startsWith(":import") || ruleAncestorNode.raws.selector.startsWith(":export"));
  13871. }
  13872. function insideAtRuleNode$1(path, atRuleNameOrAtRuleNames) {
  13873. var atRuleNames = [].concat(atRuleNameOrAtRuleNames);
  13874. var atRuleAncestorNode = getAncestorNode$1(path, "css-atrule");
  13875. return atRuleAncestorNode && atRuleNames.indexOf(atRuleAncestorNode.name.toLowerCase()) !== -1;
  13876. }
  13877. function insideURLFunctionInImportAtRuleNode$1(path) {
  13878. var node = path.getValue();
  13879. var atRuleAncestorNode = getAncestorNode$1(path, "css-atrule");
  13880. return atRuleAncestorNode && atRuleAncestorNode.name === "import" && node.groups[0].value === "url" && node.groups.length === 2;
  13881. }
  13882. function isURLFunctionNode$1(node) {
  13883. return node.type === "value-func" && node.value.toLowerCase() === "url";
  13884. }
  13885. function isLastNode$1(path, node) {
  13886. var parentNode = path.getParentNode();
  13887. if (!parentNode) {
  13888. return false;
  13889. }
  13890. var nodes = parentNode.nodes;
  13891. return nodes && nodes.indexOf(node) === nodes.length - 1;
  13892. }
  13893. function isHTMLTag$1(value) {
  13894. return htmlTagNames$1.indexOf(value.toLowerCase()) !== -1;
  13895. }
  13896. function isDetachedRulesetDeclarationNode$1(node) {
  13897. // If a Less file ends up being parsed with the SCSS parser, Less
  13898. // variable declarations will be parsed as atrules with names ending
  13899. // with a colon, so keep the original case then.
  13900. if (!node.selector) {
  13901. return false;
  13902. }
  13903. return typeof node.selector === "string" && /^@.+:.*$/.test(node.selector) || node.selector.value && /^@.+:.*$/.test(node.selector.value);
  13904. }
  13905. function isForKeywordNode$1(node) {
  13906. return node.type === "value-word" && ["from", "through", "end"].indexOf(node.value) !== -1;
  13907. }
  13908. function isIfElseKeywordNode$1(node) {
  13909. return node.type === "value-word" && ["and", "or", "not"].indexOf(node.value) !== -1;
  13910. }
  13911. function isEachKeywordNode$1(node) {
  13912. return node.type === "value-word" && node.value === "in";
  13913. }
  13914. function isMultiplicationNode$1(node) {
  13915. return node.type === "value-operator" && node.value === "*";
  13916. }
  13917. function isDivisionNode$1(node) {
  13918. return node.type === "value-operator" && node.value === "/";
  13919. }
  13920. function isAdditionNode$1(node) {
  13921. return node.type === "value-operator" && node.value === "+";
  13922. }
  13923. function isSubtractionNode$1(node) {
  13924. return node.type === "value-operator" && node.value === "-";
  13925. }
  13926. function isModuloNode(node) {
  13927. return node.type === "value-operator" && node.value === "%";
  13928. }
  13929. function isMathOperatorNode$1(node) {
  13930. return isMultiplicationNode$1(node) || isDivisionNode$1(node) || isAdditionNode$1(node) || isSubtractionNode$1(node) || isModuloNode(node);
  13931. }
  13932. function isEqualityOperatorNode$1(node) {
  13933. return node.type === "value-word" && ["==", "!="].indexOf(node.value) !== -1;
  13934. }
  13935. function isRelationalOperatorNode$1(node) {
  13936. return node.type === "value-word" && ["<", ">", "<=", ">="].indexOf(node.value) !== -1;
  13937. }
  13938. function isSCSSControlDirectiveNode$1(node) {
  13939. return node.type === "css-atrule" && ["if", "else", "for", "each", "while"].indexOf(node.name) !== -1;
  13940. }
  13941. function isSCSSNestedPropertyNode(node) {
  13942. if (!node.selector) {
  13943. return false;
  13944. }
  13945. return node.selector.replace(/\/\*.*?\*\//, "").replace(/\/\/.*?\n/, "").trim().endsWith(":");
  13946. }
  13947. function isDetachedRulesetCallNode$1(node) {
  13948. return node.raws && node.raws.params && /^\(\s*\)$/.test(node.raws.params);
  13949. }
  13950. function isTemplatePlaceholderNode$1(node) {
  13951. return node.name.startsWith("prettier-placeholder");
  13952. }
  13953. function isTemplatePropNode$1(node) {
  13954. return node.prop.startsWith("@prettier-placeholder");
  13955. }
  13956. function isPostcssSimpleVarNode$1(currentNode, nextNode) {
  13957. return currentNode.value === "$$" && currentNode.type === "value-func" && nextNode && nextNode.type === "value-word" && !nextNode.raws.before;
  13958. }
  13959. function hasComposesNode$1(node) {
  13960. return node.value && node.value.type === "value-root" && node.value.group && node.value.group.type === "value-value" && node.prop.toLowerCase() === "composes";
  13961. }
  13962. function hasParensAroundNode$1(node) {
  13963. 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;
  13964. }
  13965. function hasEmptyRawBefore$1(node) {
  13966. return node.raws && node.raws.before === "";
  13967. }
  13968. function isKeyValuePairNode$1(node) {
  13969. return node.type === "value-comma_group" && node.groups && node.groups[1] && node.groups[1].type === "value-colon";
  13970. }
  13971. function isKeyValuePairInParenGroupNode(node) {
  13972. return node.type === "value-paren_group" && node.groups && node.groups[0] && isKeyValuePairNode$1(node.groups[0]);
  13973. }
  13974. function isSCSSMapItemNode$1(path) {
  13975. var node = path.getValue(); // Ignore empty item (i.e. `$key: ()`)
  13976. if (node.groups.length === 0) {
  13977. return false;
  13978. }
  13979. var parentParentNode = path.getParentNode(1); // Check open parens contain key/value pair (i.e. `(key: value)` and `(key: (value, other-value)`)
  13980. if (!isKeyValuePairInParenGroupNode(node) && !(parentParentNode && isKeyValuePairInParenGroupNode(parentParentNode))) {
  13981. return false;
  13982. }
  13983. var declNode = getAncestorNode$1(path, "css-decl"); // SCSS map declaration (i.e. `$map: (key: value, other-key: other-value)`)
  13984. if (declNode && declNode.prop && declNode.prop.startsWith("$")) {
  13985. return true;
  13986. } // List as value of key inside SCSS map (i.e. `$map: (key: (value other-value other-other-value))`)
  13987. if (isKeyValuePairInParenGroupNode(parentParentNode)) {
  13988. return true;
  13989. } // SCSS Map is argument of function (i.e. `func((key: value, other-key: other-value))`)
  13990. if (parentParentNode.type === "value-func") {
  13991. return true;
  13992. }
  13993. return false;
  13994. }
  13995. function isInlineValueCommentNode$1(node) {
  13996. return node.type === "value-comment" && node.inline;
  13997. }
  13998. function isHashNode$1(node) {
  13999. return node.type === "value-word" && node.value === "#";
  14000. }
  14001. function isLeftCurlyBraceNode$1(node) {
  14002. return node.type === "value-word" && node.value === "{";
  14003. }
  14004. function isRightCurlyBraceNode$1(node) {
  14005. return node.type === "value-word" && node.value === "}";
  14006. }
  14007. function isWordNode$1(node) {
  14008. return ["value-word", "value-atword"].indexOf(node.type) !== -1;
  14009. }
  14010. function isColonNode$1(node) {
  14011. return node.type === "value-colon";
  14012. }
  14013. function isMediaAndSupportsKeywords$1(node) {
  14014. return node.value && ["not", "and", "or"].indexOf(node.value.toLowerCase()) !== -1;
  14015. }
  14016. function isColorAdjusterFuncNode$1(node) {
  14017. if (node.type !== "value-func") {
  14018. return false;
  14019. }
  14020. return colorAdjusterFunctions.indexOf(node.value.toLowerCase()) !== -1;
  14021. }
  14022. var utils$4 = {
  14023. getAncestorCounter: getAncestorCounter,
  14024. getAncestorNode: getAncestorNode$1,
  14025. getPropOfDeclNode: getPropOfDeclNode$1,
  14026. maybeToLowerCase: maybeToLowerCase$1,
  14027. insideValueFunctionNode: insideValueFunctionNode$1,
  14028. insideICSSRuleNode: insideICSSRuleNode$1,
  14029. insideAtRuleNode: insideAtRuleNode$1,
  14030. insideURLFunctionInImportAtRuleNode: insideURLFunctionInImportAtRuleNode$1,
  14031. isKeyframeAtRuleKeywords: isKeyframeAtRuleKeywords$1,
  14032. isHTMLTag: isHTMLTag$1,
  14033. isWideKeywords: isWideKeywords$1,
  14034. isSCSS: isSCSS$1,
  14035. isLastNode: isLastNode$1,
  14036. isSCSSControlDirectiveNode: isSCSSControlDirectiveNode$1,
  14037. isDetachedRulesetDeclarationNode: isDetachedRulesetDeclarationNode$1,
  14038. isRelationalOperatorNode: isRelationalOperatorNode$1,
  14039. isEqualityOperatorNode: isEqualityOperatorNode$1,
  14040. isMultiplicationNode: isMultiplicationNode$1,
  14041. isDivisionNode: isDivisionNode$1,
  14042. isAdditionNode: isAdditionNode$1,
  14043. isSubtractionNode: isSubtractionNode$1,
  14044. isModuloNode: isModuloNode,
  14045. isMathOperatorNode: isMathOperatorNode$1,
  14046. isEachKeywordNode: isEachKeywordNode$1,
  14047. isForKeywordNode: isForKeywordNode$1,
  14048. isURLFunctionNode: isURLFunctionNode$1,
  14049. isIfElseKeywordNode: isIfElseKeywordNode$1,
  14050. hasComposesNode: hasComposesNode$1,
  14051. hasParensAroundNode: hasParensAroundNode$1,
  14052. hasEmptyRawBefore: hasEmptyRawBefore$1,
  14053. isSCSSNestedPropertyNode: isSCSSNestedPropertyNode,
  14054. isDetachedRulesetCallNode: isDetachedRulesetCallNode$1,
  14055. isTemplatePlaceholderNode: isTemplatePlaceholderNode$1,
  14056. isTemplatePropNode: isTemplatePropNode$1,
  14057. isPostcssSimpleVarNode: isPostcssSimpleVarNode$1,
  14058. isKeyValuePairNode: isKeyValuePairNode$1,
  14059. isKeyValuePairInParenGroupNode: isKeyValuePairInParenGroupNode,
  14060. isSCSSMapItemNode: isSCSSMapItemNode$1,
  14061. isInlineValueCommentNode: isInlineValueCommentNode$1,
  14062. isHashNode: isHashNode$1,
  14063. isLeftCurlyBraceNode: isLeftCurlyBraceNode$1,
  14064. isRightCurlyBraceNode: isRightCurlyBraceNode$1,
  14065. isWordNode: isWordNode$1,
  14066. isColonNode: isColonNode$1,
  14067. isMediaAndSupportsKeywords: isMediaAndSupportsKeywords$1,
  14068. isColorAdjusterFuncNode: isColorAdjusterFuncNode$1
  14069. };
  14070. var insertPragma = pragma.insertPragma;
  14071. var printNumber$1 = util.printNumber;
  14072. var printString$1 = util.printString;
  14073. var hasIgnoreComment$1 = util.hasIgnoreComment;
  14074. var hasNewline$2 = util.hasNewline;
  14075. var isNextLineEmpty$2 = utilShared.isNextLineEmpty;
  14076. var _require$$3$builders = doc.builders;
  14077. var concat$4 = _require$$3$builders.concat;
  14078. var join$2 = _require$$3$builders.join;
  14079. var line$3 = _require$$3$builders.line;
  14080. var hardline$3 = _require$$3$builders.hardline;
  14081. var softline$1 = _require$$3$builders.softline;
  14082. var group$1 = _require$$3$builders.group;
  14083. var fill$2 = _require$$3$builders.fill;
  14084. var indent$2 = _require$$3$builders.indent;
  14085. var dedent$2 = _require$$3$builders.dedent;
  14086. var ifBreak$1 = _require$$3$builders.ifBreak;
  14087. var removeLines$1 = doc.utils.removeLines;
  14088. var getAncestorNode = utils$4.getAncestorNode;
  14089. var getPropOfDeclNode = utils$4.getPropOfDeclNode;
  14090. var maybeToLowerCase = utils$4.maybeToLowerCase;
  14091. var insideValueFunctionNode = utils$4.insideValueFunctionNode;
  14092. var insideICSSRuleNode = utils$4.insideICSSRuleNode;
  14093. var insideAtRuleNode = utils$4.insideAtRuleNode;
  14094. var insideURLFunctionInImportAtRuleNode = utils$4.insideURLFunctionInImportAtRuleNode;
  14095. var isKeyframeAtRuleKeywords = utils$4.isKeyframeAtRuleKeywords;
  14096. var isHTMLTag = utils$4.isHTMLTag;
  14097. var isWideKeywords = utils$4.isWideKeywords;
  14098. var isSCSS = utils$4.isSCSS;
  14099. var isLastNode = utils$4.isLastNode;
  14100. var isSCSSControlDirectiveNode = utils$4.isSCSSControlDirectiveNode;
  14101. var isDetachedRulesetDeclarationNode = utils$4.isDetachedRulesetDeclarationNode;
  14102. var isRelationalOperatorNode = utils$4.isRelationalOperatorNode;
  14103. var isEqualityOperatorNode = utils$4.isEqualityOperatorNode;
  14104. var isMultiplicationNode = utils$4.isMultiplicationNode;
  14105. var isDivisionNode = utils$4.isDivisionNode;
  14106. var isAdditionNode = utils$4.isAdditionNode;
  14107. var isSubtractionNode = utils$4.isSubtractionNode;
  14108. var isMathOperatorNode = utils$4.isMathOperatorNode;
  14109. var isEachKeywordNode = utils$4.isEachKeywordNode;
  14110. var isForKeywordNode = utils$4.isForKeywordNode;
  14111. var isURLFunctionNode = utils$4.isURLFunctionNode;
  14112. var isIfElseKeywordNode = utils$4.isIfElseKeywordNode;
  14113. var hasComposesNode = utils$4.hasComposesNode;
  14114. var hasParensAroundNode = utils$4.hasParensAroundNode;
  14115. var hasEmptyRawBefore = utils$4.hasEmptyRawBefore;
  14116. var isKeyValuePairNode = utils$4.isKeyValuePairNode;
  14117. var isDetachedRulesetCallNode = utils$4.isDetachedRulesetCallNode;
  14118. var isTemplatePlaceholderNode = utils$4.isTemplatePlaceholderNode;
  14119. var isTemplatePropNode = utils$4.isTemplatePropNode;
  14120. var isPostcssSimpleVarNode = utils$4.isPostcssSimpleVarNode;
  14121. var isSCSSMapItemNode = utils$4.isSCSSMapItemNode;
  14122. var isInlineValueCommentNode = utils$4.isInlineValueCommentNode;
  14123. var isHashNode = utils$4.isHashNode;
  14124. var isLeftCurlyBraceNode = utils$4.isLeftCurlyBraceNode;
  14125. var isRightCurlyBraceNode = utils$4.isRightCurlyBraceNode;
  14126. var isWordNode = utils$4.isWordNode;
  14127. var isColonNode = utils$4.isColonNode;
  14128. var isMediaAndSupportsKeywords = utils$4.isMediaAndSupportsKeywords;
  14129. var isColorAdjusterFuncNode = utils$4.isColorAdjusterFuncNode;
  14130. function shouldPrintComma(options) {
  14131. switch (options.trailingComma) {
  14132. case "all":
  14133. case "es5":
  14134. return true;
  14135. case "none":
  14136. default:
  14137. return false;
  14138. }
  14139. }
  14140. function genericPrint(path, options, print) {
  14141. var node = path.getValue();
  14142. /* istanbul ignore if */
  14143. if (!node) {
  14144. return "";
  14145. }
  14146. if (typeof node === "string") {
  14147. return node;
  14148. }
  14149. switch (node.type) {
  14150. case "yaml":
  14151. case "toml":
  14152. return concat$4([node.raw, hardline$3]);
  14153. case "css-root":
  14154. {
  14155. var nodes = printNodeSequence(path, options, print);
  14156. if (nodes.parts.length) {
  14157. return concat$4([nodes, hardline$3]);
  14158. }
  14159. return nodes;
  14160. }
  14161. case "css-comment":
  14162. {
  14163. if (node.raws.content) {
  14164. return node.raws.content;
  14165. }
  14166. var text = options.originalText.slice(options.locStart(node), options.locEnd(node));
  14167. var rawText = node.raws.text || node.text; // Workaround a bug where the location is off.
  14168. // https://github.com/postcss/postcss-scss/issues/63
  14169. if (text.indexOf(rawText) === -1) {
  14170. if (node.raws.inline) {
  14171. return concat$4(["// ", rawText]);
  14172. }
  14173. return concat$4(["/* ", rawText, " */"]);
  14174. }
  14175. return text;
  14176. }
  14177. case "css-rule":
  14178. {
  14179. 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) ? ";" : ""]) : ";"]);
  14180. }
  14181. case "css-decl":
  14182. {
  14183. var parentNode = path.getParentNode();
  14184. 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] !== ";" ? "" : ";"]);
  14185. }
  14186. case "css-atrule":
  14187. {
  14188. var _parentNode = path.getParentNode();
  14189. return concat$4(["@", // If a Less file ends up being parsed with the SCSS parser, Less
  14190. // variable declarations will be parsed as at-rules with names ending
  14191. // with a colon, so keep the original case then.
  14192. 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] !== ";" ? "" : ";"]);
  14193. }
  14194. // postcss-media-query-parser
  14195. case "media-query-list":
  14196. {
  14197. var parts = [];
  14198. path.each(function (childPath) {
  14199. var node = childPath.getValue();
  14200. if (node.type === "media-query" && node.value === "") {
  14201. return;
  14202. }
  14203. parts.push(childPath.call(print));
  14204. }, "nodes");
  14205. return group$1(indent$2(join$2(line$3, parts)));
  14206. }
  14207. case "media-query":
  14208. {
  14209. return concat$4([join$2(" ", path.map(print, "nodes")), isLastNode(path, node) ? "" : ","]);
  14210. }
  14211. case "media-type":
  14212. {
  14213. return adjustNumbers(adjustStrings(node.value, options));
  14214. }
  14215. case "media-feature-expression":
  14216. {
  14217. if (!node.nodes) {
  14218. return node.value;
  14219. }
  14220. return concat$4(["(", concat$4(path.map(print, "nodes")), ")"]);
  14221. }
  14222. case "media-feature":
  14223. {
  14224. return maybeToLowerCase(adjustStrings(node.value.replace(/ +/g, " "), options));
  14225. }
  14226. case "media-colon":
  14227. {
  14228. return concat$4([node.value, " "]);
  14229. }
  14230. case "media-value":
  14231. {
  14232. return adjustNumbers(adjustStrings(node.value, options));
  14233. }
  14234. case "media-keyword":
  14235. {
  14236. return adjustStrings(node.value, options);
  14237. }
  14238. case "media-url":
  14239. {
  14240. return adjustStrings(node.value.replace(/^url\(\s+/gi, "url(").replace(/\s+\)$/gi, ")"), options);
  14241. }
  14242. case "media-unknown":
  14243. {
  14244. return node.value;
  14245. }
  14246. // postcss-selector-parser
  14247. case "selector-root":
  14248. {
  14249. 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"))]));
  14250. }
  14251. case "selector-selector":
  14252. {
  14253. return group$1(indent$2(concat$4(path.map(print, "nodes"))));
  14254. }
  14255. case "selector-comment":
  14256. {
  14257. return node.value;
  14258. }
  14259. case "selector-string":
  14260. {
  14261. return adjustStrings(node.value, options);
  14262. }
  14263. case "selector-tag":
  14264. {
  14265. var _parentNode2 = path.getParentNode();
  14266. var index = _parentNode2 && _parentNode2.nodes.indexOf(node);
  14267. var prevNode = index && _parentNode2.nodes[index - 1];
  14268. 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)]);
  14269. }
  14270. case "selector-id":
  14271. {
  14272. return concat$4(["#", node.value]);
  14273. }
  14274. case "selector-class":
  14275. {
  14276. return concat$4([".", adjustNumbers(adjustStrings(node.value, options))]);
  14277. }
  14278. case "selector-attribute":
  14279. {
  14280. 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" : "", "]"]);
  14281. }
  14282. case "selector-combinator":
  14283. {
  14284. if (node.value === "+" || node.value === ">" || node.value === "~" || node.value === ">>>") {
  14285. var _parentNode3 = path.getParentNode();
  14286. var _leading = _parentNode3.type === "selector-selector" && _parentNode3.nodes[0] === node ? "" : line$3;
  14287. return concat$4([_leading, node.value, isLastNode(path, node) ? "" : " "]);
  14288. }
  14289. var leading = node.value.trim().startsWith("(") ? line$3 : "";
  14290. var value = adjustNumbers(adjustStrings(node.value.trim(), options)) || line$3;
  14291. return concat$4([leading, value]);
  14292. }
  14293. case "selector-universal":
  14294. {
  14295. return concat$4([node.namespace ? concat$4([node.namespace === true ? "" : node.namespace.trim(), "|"]) : "", node.value]);
  14296. }
  14297. case "selector-pseudo":
  14298. {
  14299. return concat$4([maybeToLowerCase(node.value), node.nodes && node.nodes.length > 0 ? concat$4(["(", join$2(", ", path.map(print, "nodes")), ")"]) : ""]);
  14300. }
  14301. case "selector-nesting":
  14302. {
  14303. return node.value;
  14304. }
  14305. case "selector-unknown":
  14306. {
  14307. var ruleAncestorNode = getAncestorNode(path, "css-rule"); // Nested SCSS property
  14308. if (ruleAncestorNode && ruleAncestorNode.isSCSSNesterProperty) {
  14309. return adjustNumbers(adjustStrings(maybeToLowerCase(node.value), options));
  14310. }
  14311. return node.value;
  14312. }
  14313. // postcss-values-parser
  14314. case "value-value":
  14315. case "value-root":
  14316. {
  14317. return path.call(print, "group");
  14318. }
  14319. case "value-comment":
  14320. {
  14321. return concat$4([node.inline ? "//" : "/*", node.value, node.inline ? "" : "*/"]);
  14322. }
  14323. case "value-comma_group":
  14324. {
  14325. var _parentNode4 = path.getParentNode();
  14326. var parentParentNode = path.getParentNode(1);
  14327. var declAncestorProp = getPropOfDeclNode(path);
  14328. var isGridValue = declAncestorProp && _parentNode4.type === "value-value" && (declAncestorProp === "grid" || declAncestorProp.startsWith("grid-template"));
  14329. var atRuleAncestorNode = getAncestorNode(path, "css-atrule");
  14330. var isControlDirective = atRuleAncestorNode && isSCSSControlDirectiveNode(atRuleAncestorNode);
  14331. var printed = path.map(print, "groups");
  14332. var _parts = [];
  14333. var insideURLFunction = insideValueFunctionNode(path, "url");
  14334. var insideSCSSInterpolationInString = false;
  14335. var didBreak = false;
  14336. for (var i = 0; i < node.groups.length; ++i) {
  14337. _parts.push(printed[i]); // Ignore value inside `url()`
  14338. if (insideURLFunction) {
  14339. continue;
  14340. }
  14341. var iPrevNode = node.groups[i - 1];
  14342. var iNode = node.groups[i];
  14343. var iNextNode = node.groups[i + 1];
  14344. var iNextNextNode = node.groups[i + 2]; // Ignore after latest node (i.e. before semicolon)
  14345. if (!iNextNode) {
  14346. continue;
  14347. } // Ignore spaces before/after string interpolation (i.e. `"#{my-fn("_")}"`)
  14348. var isStartSCSSinterpolationInString = iNode.type === "value-string" && iNode.value.startsWith("#{");
  14349. var isEndingSCSSinterpolationInString = insideSCSSInterpolationInString && iNextNode.type === "value-string" && iNextNode.value.endsWith("}");
  14350. if (isStartSCSSinterpolationInString || isEndingSCSSinterpolationInString) {
  14351. insideSCSSInterpolationInString = !insideSCSSInterpolationInString;
  14352. continue;
  14353. }
  14354. if (insideSCSSInterpolationInString) {
  14355. continue;
  14356. } // Ignore colon (i.e. `:`)
  14357. if (isColonNode(iNode) || isColonNode(iNextNode)) {
  14358. continue;
  14359. } // Ignore `@` in Less (i.e. `@@var;`)
  14360. if (iNode.type === "value-atword" && iNode.value === "") {
  14361. continue;
  14362. } // Ignore `~` in Less (i.e. `content: ~"^//* some horrible but needed css hack";`)
  14363. if (iNode.value === "~") {
  14364. continue;
  14365. } // Ignore escape `\`
  14366. if (iNode.value && iNode.value.indexOf("\\") !== -1 && iNextNode && iNextNode.type !== "value-comment") {
  14367. continue;
  14368. } // Ignore escaped `/`
  14369. if (iPrevNode && iPrevNode.value && iPrevNode.value.indexOf("\\") === iPrevNode.value.length - 1 && iNode.type === "value-operator" && iNode.value === "/") {
  14370. continue;
  14371. } // Ignore `\` (i.e. `$variable: \@small;`)
  14372. if (iNode.value === "\\") {
  14373. continue;
  14374. } // Ignore `$$` (i.e. `background-color: $$(style)Color;`)
  14375. if (isPostcssSimpleVarNode(iNode, iNextNode)) {
  14376. continue;
  14377. } // Ignore spaces after `#` and after `{` and before `}` in SCSS interpolation (i.e. `#{variable}`)
  14378. if (isHashNode(iNode) || isLeftCurlyBraceNode(iNode) || isRightCurlyBraceNode(iNextNode) || isLeftCurlyBraceNode(iNextNode) && hasEmptyRawBefore(iNextNode) || isRightCurlyBraceNode(iNode) && hasEmptyRawBefore(iNextNode)) {
  14379. continue;
  14380. } // Ignore css variables and interpolation in SCSS (i.e. `--#{$var}`)
  14381. if (iNode.value === "--" && isHashNode(iNextNode)) {
  14382. continue;
  14383. } // Formatting math operations
  14384. var isMathOperator = isMathOperatorNode(iNode);
  14385. var isNextMathOperator = isMathOperatorNode(iNextNode); // Print spaces before and after math operators beside SCSS interpolation as is
  14386. // (i.e. `#{$var}+5`, `#{$var} +5`, `#{$var}+ 5`, `#{$var} + 5`)
  14387. // (i.e. `5+#{$var}`, `5 +#{$var}`, `5+ #{$var}`, `5 + #{$var}`)
  14388. if ((isMathOperator && isHashNode(iNextNode) || isNextMathOperator && isRightCurlyBraceNode(iNode)) && hasEmptyRawBefore(iNextNode)) {
  14389. continue;
  14390. } // Print spaces before and after addition and subtraction math operators as is in `calc` function
  14391. // due to the fact that it is not valid syntax
  14392. // (i.e. `calc(1px+1px)`, `calc(1px+ 1px)`, `calc(1px +1px)`, `calc(1px + 1px)`)
  14393. if (insideValueFunctionNode(path, "calc") && (isAdditionNode(iNode) || isAdditionNode(iNextNode) || isSubtractionNode(iNode) || isSubtractionNode(iNextNode)) && hasEmptyRawBefore(iNextNode)) {
  14394. continue;
  14395. } // Print spaces after `+` and `-` in color adjuster functions as is (e.g. `color(red l(+ 20%))`)
  14396. // Adjusters with signed numbers (e.g. `color(red l(+20%))`) output as-is.
  14397. var isColorAdjusterNode = (isAdditionNode(iNode) || isSubtractionNode(iNode)) && i === 0 && (iNextNode.type === "value-number" || iNextNode.isHex) && parentParentNode && isColorAdjusterFuncNode(parentParentNode) && !hasEmptyRawBefore(iNextNode);
  14398. var requireSpaceBeforeOperator = iNextNextNode && iNextNextNode.type === "value-func" || iNextNextNode && isWordNode(iNextNextNode) || iNode.type === "value-func" || isWordNode(iNode);
  14399. var requireSpaceAfterOperator = iNextNode.type === "value-func" || isWordNode(iNextNode) || iPrevNode && iPrevNode.type === "value-func" || iPrevNode && isWordNode(iPrevNode); // Formatting `/`, `+`, `-` sign
  14400. if (!(isMultiplicationNode(iNextNode) || isMultiplicationNode(iNode)) && !insideValueFunctionNode(path, "calc") && !isColorAdjusterNode && (isDivisionNode(iNextNode) && !requireSpaceBeforeOperator || isDivisionNode(iNode) && !requireSpaceAfterOperator || isAdditionNode(iNextNode) && !requireSpaceBeforeOperator || isAdditionNode(iNode) && !requireSpaceAfterOperator || isSubtractionNode(iNextNode) || isSubtractionNode(iNode)) && (hasEmptyRawBefore(iNextNode) || isMathOperator && (!iPrevNode || iPrevNode && isMathOperatorNode(iPrevNode)))) {
  14401. continue;
  14402. } // Add `hardline` after inline comment (i.e. `// comment\n foo: bar;`)
  14403. if (isInlineValueCommentNode(iNode)) {
  14404. _parts.push(hardline$3);
  14405. continue;
  14406. } // Handle keywords in SCSS control directive
  14407. if (isControlDirective && (isEqualityOperatorNode(iNextNode) || isRelationalOperatorNode(iNextNode) || isIfElseKeywordNode(iNextNode) || isEachKeywordNode(iNode) || isForKeywordNode(iNode))) {
  14408. _parts.push(" ");
  14409. continue;
  14410. } // At-rule `namespace` should be in one line
  14411. if (atRuleAncestorNode && atRuleAncestorNode.name.toLowerCase() === "namespace") {
  14412. _parts.push(" ");
  14413. continue;
  14414. } // Formatting `grid` property
  14415. if (isGridValue) {
  14416. if (iNode.source && iNextNode.source && iNode.source.start.line !== iNextNode.source.start.line) {
  14417. _parts.push(hardline$3);
  14418. didBreak = true;
  14419. } else {
  14420. _parts.push(" ");
  14421. }
  14422. continue;
  14423. } // Add `space` before next math operation
  14424. // Note: `grip` property have `/` delimiter and it is not math operation, so
  14425. // `grid` property handles above
  14426. if (isNextMathOperator) {
  14427. _parts.push(" ");
  14428. continue;
  14429. } // Be default all values go through `line`
  14430. _parts.push(line$3);
  14431. }
  14432. if (didBreak) {
  14433. _parts.unshift(hardline$3);
  14434. }
  14435. if (isControlDirective) {
  14436. return group$1(indent$2(concat$4(_parts)));
  14437. } // Indent is not needed for import url when url is very long
  14438. // and node has two groups
  14439. // when type is value-comma_group
  14440. // example @import url("verylongurl") projection,tv
  14441. if (insideURLFunctionInImportAtRuleNode(path)) {
  14442. return group$1(fill$2(_parts));
  14443. }
  14444. return group$1(indent$2(fill$2(_parts)));
  14445. }
  14446. case "value-paren_group":
  14447. {
  14448. var _parentNode5 = path.getParentNode();
  14449. 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:"))) {
  14450. return concat$4([node.open ? path.call(print, "open") : "", join$2(",", path.map(print, "groups")), node.close ? path.call(print, "close") : ""]);
  14451. }
  14452. if (!node.open) {
  14453. var _printed = path.map(print, "groups");
  14454. var res = [];
  14455. for (var _i = 0; _i < _printed.length; _i++) {
  14456. if (_i !== 0) {
  14457. res.push(concat$4([",", line$3]));
  14458. }
  14459. res.push(_printed[_i]);
  14460. }
  14461. return group$1(indent$2(fill$2(res)));
  14462. }
  14463. var isSCSSMapItem = isSCSSMapItemNode(path);
  14464. 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) {
  14465. var node = childPath.getValue();
  14466. var printed = print(childPath); // Key/Value pair in open paren already indented
  14467. if (isKeyValuePairNode(node) && node.type === "value-comma_group" && node.groups && node.groups[2] && node.groups[2].type === "value-paren_group") {
  14468. printed.contents.contents.parts[1] = group$1(printed.contents.contents.parts[1]);
  14469. return group$1(dedent$2(printed));
  14470. }
  14471. return printed;
  14472. }, "groups"))])), ifBreak$1(isSCSS(options.parser, options.originalText) && isSCSSMapItem && shouldPrintComma(options) ? "," : ""), softline$1, node.close ? path.call(print, "close") : ""]), {
  14473. shouldBreak: isSCSSMapItem
  14474. });
  14475. }
  14476. case "value-func":
  14477. {
  14478. return concat$4([node.value, insideAtRuleNode(path, "supports") && isMediaAndSupportsKeywords(node) ? " " : "", path.call(print, "group")]);
  14479. }
  14480. case "value-paren":
  14481. {
  14482. return node.value;
  14483. }
  14484. case "value-number":
  14485. {
  14486. return concat$4([printCssNumber(node.value), maybeToLowerCase(node.unit)]);
  14487. }
  14488. case "value-operator":
  14489. {
  14490. return node.value;
  14491. }
  14492. case "value-word":
  14493. {
  14494. if (node.isColor && node.isHex || isWideKeywords(node.value)) {
  14495. return node.value.toLowerCase();
  14496. }
  14497. return node.value;
  14498. }
  14499. case "value-colon":
  14500. {
  14501. return concat$4([node.value, // Don't add spaces on `:` in `url` function (i.e. `url(fbglyph: cross-outline, fig-white)`)
  14502. insideValueFunctionNode(path, "url") ? "" : line$3]);
  14503. }
  14504. case "value-comma":
  14505. {
  14506. return concat$4([node.value, " "]);
  14507. }
  14508. case "value-string":
  14509. {
  14510. return printString$1(node.raws.quote + node.value + node.raws.quote, options);
  14511. }
  14512. case "value-atword":
  14513. {
  14514. return concat$4(["@", node.value]);
  14515. }
  14516. case "value-unicode-range":
  14517. {
  14518. return node.value;
  14519. }
  14520. case "value-unknown":
  14521. {
  14522. return node.value;
  14523. }
  14524. default:
  14525. /* istanbul ignore next */
  14526. throw new Error("Unknown postcss type ".concat(JSON.stringify(node.type)));
  14527. }
  14528. }
  14529. function printNodeSequence(path, options, print) {
  14530. var node = path.getValue();
  14531. var parts = [];
  14532. var i = 0;
  14533. path.map(function (pathChild) {
  14534. var prevNode = node.nodes[i - 1];
  14535. if (prevNode && prevNode.type === "css-comment" && prevNode.text.trim() === "prettier-ignore") {
  14536. var childNode = pathChild.getValue();
  14537. parts.push(options.originalText.slice(options.locStart(childNode), options.locEnd(childNode)));
  14538. } else {
  14539. parts.push(pathChild.call(print));
  14540. }
  14541. if (i !== node.nodes.length - 1) {
  14542. if (node.nodes[i + 1].type === "css-comment" && !hasNewline$2(options.originalText, options.locStart(node.nodes[i + 1]), {
  14543. backwards: true
  14544. }) && 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") {
  14545. parts.push(" ");
  14546. } else {
  14547. parts.push(hardline$3);
  14548. if (isNextLineEmpty$2(options.originalText, pathChild.getValue(), options) && node.nodes[i].type !== "yaml" && node.nodes[i].type !== "toml") {
  14549. parts.push(hardline$3);
  14550. }
  14551. }
  14552. }
  14553. i++;
  14554. }, "nodes");
  14555. return concat$4(parts);
  14556. }
  14557. var STRING_REGEX = /(['"])(?:(?!\1)[^\\]|\\[\s\S])*\1/g;
  14558. var NUMBER_REGEX = /(?:\d*\.\d+|\d+\.?)(?:[eE][+-]?\d+)?/g;
  14559. var STANDARD_UNIT_REGEX = /[a-zA-Z]+/g;
  14560. var WORD_PART_REGEX = /[$@]?[a-zA-Z_\u0080-\uFFFF][\w\-\u0080-\uFFFF]*/g;
  14561. var ADJUST_NUMBERS_REGEX = RegExp(STRING_REGEX.source + "|" + "(".concat(WORD_PART_REGEX.source, ")?") + "(".concat(NUMBER_REGEX.source, ")") + "(".concat(STANDARD_UNIT_REGEX.source, ")?"), "g");
  14562. function adjustStrings(value, options) {
  14563. return value.replace(STRING_REGEX, function (match) {
  14564. return printString$1(match, options);
  14565. });
  14566. }
  14567. function quoteAttributeValue(value, options) {
  14568. var quote = options.singleQuote ? "'" : '"';
  14569. return value.includes('"') || value.includes("'") ? value : quote + value + quote;
  14570. }
  14571. function adjustNumbers(value) {
  14572. return value.replace(ADJUST_NUMBERS_REGEX, function (match, quote, wordPart, number, unit) {
  14573. return !wordPart && number ? (wordPart || "") + printCssNumber(number) + maybeToLowerCase(unit || "") : match;
  14574. });
  14575. }
  14576. function printCssNumber(rawNumber) {
  14577. return printNumber$1(rawNumber) // Remove trailing `.0`.
  14578. .replace(/\.0(?=$|e)/, "");
  14579. }
  14580. var printerPostcss = {
  14581. print: genericPrint,
  14582. embed: embed_1,
  14583. insertPragma: insertPragma,
  14584. hasPrettierIgnore: hasIgnoreComment$1,
  14585. massageAstNode: clean_1
  14586. };
  14587. var CATEGORY_COMMON = "Common"; // format based on https://github.com/prettier/prettier/blob/master/src/main/core-options.js
  14588. var commonOptions = {
  14589. bracketSpacing: {
  14590. since: "0.0.0",
  14591. category: CATEGORY_COMMON,
  14592. type: "boolean",
  14593. default: true,
  14594. description: "Print spaces between brackets.",
  14595. oppositeDescription: "Do not print spaces between brackets."
  14596. },
  14597. singleQuote: {
  14598. since: "0.0.0",
  14599. category: CATEGORY_COMMON,
  14600. type: "boolean",
  14601. default: false,
  14602. description: "Use single quotes instead of double quotes."
  14603. },
  14604. proseWrap: {
  14605. since: "1.8.2",
  14606. category: CATEGORY_COMMON,
  14607. type: "choice",
  14608. default: [{
  14609. since: "1.8.2",
  14610. value: true
  14611. }, {
  14612. since: "1.9.0",
  14613. value: "preserve"
  14614. }],
  14615. description: "How to wrap prose.",
  14616. choices: [{
  14617. since: "1.9.0",
  14618. value: "always",
  14619. description: "Wrap prose if it exceeds the print width."
  14620. }, {
  14621. since: "1.9.0",
  14622. value: "never",
  14623. description: "Do not wrap prose."
  14624. }, {
  14625. since: "1.9.0",
  14626. value: "preserve",
  14627. description: "Wrap prose as-is."
  14628. }, {
  14629. value: false,
  14630. deprecated: "1.9.0",
  14631. redirect: "never"
  14632. }, {
  14633. value: true,
  14634. deprecated: "1.9.0",
  14635. redirect: "always"
  14636. }]
  14637. }
  14638. };
  14639. var options$3 = {
  14640. singleQuote: commonOptions.singleQuote
  14641. };
  14642. var createLanguage = function createLanguage(linguistData, _ref) {
  14643. var extend = _ref.extend,
  14644. override = _ref.override;
  14645. var language = {};
  14646. for (var key in linguistData) {
  14647. var newKey = key === "languageId" ? "linguistLanguageId" : key;
  14648. language[newKey] = linguistData[key];
  14649. }
  14650. if (extend) {
  14651. for (var _key in extend) {
  14652. language[_key] = (language[_key] || []).concat(extend[_key]);
  14653. }
  14654. }
  14655. for (var _key2 in override) {
  14656. language[_key2] = override[_key2];
  14657. }
  14658. return language;
  14659. };
  14660. var name$1 = "CSS";
  14661. var type = "markup";
  14662. var tmScope = "source.css";
  14663. var aceMode = "css";
  14664. var codemirrorMode = "css";
  14665. var codemirrorMimeType = "text/css";
  14666. var color = "#563d7c";
  14667. var extensions = [".css"];
  14668. var languageId = 50;
  14669. var css$2 = {
  14670. name: name$1,
  14671. type: type,
  14672. tmScope: tmScope,
  14673. aceMode: aceMode,
  14674. codemirrorMode: codemirrorMode,
  14675. codemirrorMimeType: codemirrorMimeType,
  14676. color: color,
  14677. extensions: extensions,
  14678. languageId: languageId
  14679. };
  14680. var css$3 = Object.freeze({
  14681. name: name$1,
  14682. type: type,
  14683. tmScope: tmScope,
  14684. aceMode: aceMode,
  14685. codemirrorMode: codemirrorMode,
  14686. codemirrorMimeType: codemirrorMimeType,
  14687. color: color,
  14688. extensions: extensions,
  14689. languageId: languageId,
  14690. default: css$2
  14691. });
  14692. var name$2 = "PostCSS";
  14693. var type$1 = "markup";
  14694. var tmScope$1 = "source.postcss";
  14695. var group$2 = "CSS";
  14696. var extensions$1 = [".pcss"];
  14697. var aceMode$1 = "text";
  14698. var languageId$1 = 262764437;
  14699. var postcss = {
  14700. name: name$2,
  14701. type: type$1,
  14702. tmScope: tmScope$1,
  14703. group: group$2,
  14704. extensions: extensions$1,
  14705. aceMode: aceMode$1,
  14706. languageId: languageId$1
  14707. };
  14708. var postcss$1 = Object.freeze({
  14709. name: name$2,
  14710. type: type$1,
  14711. tmScope: tmScope$1,
  14712. group: group$2,
  14713. extensions: extensions$1,
  14714. aceMode: aceMode$1,
  14715. languageId: languageId$1,
  14716. default: postcss
  14717. });
  14718. var name$3 = "Less";
  14719. var type$2 = "markup";
  14720. var group$3 = "CSS";
  14721. var extensions$2 = [".less"];
  14722. var tmScope$2 = "source.css.less";
  14723. var aceMode$2 = "less";
  14724. var codemirrorMode$1 = "css";
  14725. var codemirrorMimeType$1 = "text/css";
  14726. var languageId$2 = 198;
  14727. var less = {
  14728. name: name$3,
  14729. type: type$2,
  14730. group: group$3,
  14731. extensions: extensions$2,
  14732. tmScope: tmScope$2,
  14733. aceMode: aceMode$2,
  14734. codemirrorMode: codemirrorMode$1,
  14735. codemirrorMimeType: codemirrorMimeType$1,
  14736. languageId: languageId$2
  14737. };
  14738. var less$1 = Object.freeze({
  14739. name: name$3,
  14740. type: type$2,
  14741. group: group$3,
  14742. extensions: extensions$2,
  14743. tmScope: tmScope$2,
  14744. aceMode: aceMode$2,
  14745. codemirrorMode: codemirrorMode$1,
  14746. codemirrorMimeType: codemirrorMimeType$1,
  14747. languageId: languageId$2,
  14748. default: less
  14749. });
  14750. var name$4 = "SCSS";
  14751. var type$3 = "markup";
  14752. var tmScope$3 = "source.scss";
  14753. var group$4 = "CSS";
  14754. var aceMode$3 = "scss";
  14755. var codemirrorMode$2 = "css";
  14756. var codemirrorMimeType$2 = "text/x-scss";
  14757. var extensions$3 = [".scss"];
  14758. var languageId$3 = 329;
  14759. var scss = {
  14760. name: name$4,
  14761. type: type$3,
  14762. tmScope: tmScope$3,
  14763. group: group$4,
  14764. aceMode: aceMode$3,
  14765. codemirrorMode: codemirrorMode$2,
  14766. codemirrorMimeType: codemirrorMimeType$2,
  14767. extensions: extensions$3,
  14768. languageId: languageId$3
  14769. };
  14770. var scss$1 = Object.freeze({
  14771. name: name$4,
  14772. type: type$3,
  14773. tmScope: tmScope$3,
  14774. group: group$4,
  14775. aceMode: aceMode$3,
  14776. codemirrorMode: codemirrorMode$2,
  14777. codemirrorMimeType: codemirrorMimeType$2,
  14778. extensions: extensions$3,
  14779. languageId: languageId$3,
  14780. default: scss
  14781. });
  14782. var require$$0$17 = ( css$3 && css$2 ) || css$3;
  14783. var require$$1$8 = ( postcss$1 && postcss ) || postcss$1;
  14784. var require$$2$9 = ( less$1 && less ) || less$1;
  14785. var require$$3$4 = ( scss$1 && scss ) || scss$1;
  14786. var languages = [createLanguage(require$$0$17, {
  14787. override: {
  14788. since: "1.4.0",
  14789. parsers: ["css"],
  14790. vscodeLanguageIds: ["css"]
  14791. }
  14792. }), createLanguage(require$$1$8, {
  14793. override: {
  14794. since: "1.4.0",
  14795. parsers: ["css"],
  14796. vscodeLanguageIds: ["postcss"]
  14797. },
  14798. extend: {
  14799. extensions: [".postcss"]
  14800. }
  14801. }), createLanguage(require$$2$9, {
  14802. override: {
  14803. since: "1.4.0",
  14804. parsers: ["less"],
  14805. vscodeLanguageIds: ["less"]
  14806. }
  14807. }), createLanguage(require$$3$4, {
  14808. override: {
  14809. since: "1.4.0",
  14810. parsers: ["scss"],
  14811. vscodeLanguageIds: ["scss"]
  14812. }
  14813. })];
  14814. var printers = {
  14815. postcss: printerPostcss
  14816. };
  14817. var languageCss = {
  14818. languages: languages,
  14819. options: options$3,
  14820. printers: printers
  14821. };
  14822. function hasPragma$2(text) {
  14823. return /^\s*#[^\n\S]*@(format|prettier)\s*(\n|$)/.test(text);
  14824. }
  14825. function insertPragma$4(text) {
  14826. return "# @format\n\n" + text;
  14827. }
  14828. var pragma$4 = {
  14829. hasPragma: hasPragma$2,
  14830. insertPragma: insertPragma$4
  14831. };
  14832. var _require$$0$builders$2 = doc.builders;
  14833. var concat$6 = _require$$0$builders$2.concat;
  14834. var join$3 = _require$$0$builders$2.join;
  14835. var hardline$5 = _require$$0$builders$2.hardline;
  14836. var line$4 = _require$$0$builders$2.line;
  14837. var softline$2 = _require$$0$builders$2.softline;
  14838. var group$5 = _require$$0$builders$2.group;
  14839. var indent$3 = _require$$0$builders$2.indent;
  14840. var ifBreak$2 = _require$$0$builders$2.ifBreak;
  14841. var hasIgnoreComment$2 = util.hasIgnoreComment;
  14842. var isNextLineEmpty$3 = utilShared.isNextLineEmpty;
  14843. var insertPragma$3 = pragma$4.insertPragma;
  14844. function genericPrint$1(path, options, print) {
  14845. var n = path.getValue();
  14846. if (!n) {
  14847. return "";
  14848. }
  14849. if (typeof n === "string") {
  14850. return n;
  14851. }
  14852. switch (n.kind) {
  14853. case "Document":
  14854. {
  14855. var parts = [];
  14856. path.map(function (pathChild, index) {
  14857. parts.push(concat$6([pathChild.call(print)]));
  14858. if (index !== n.definitions.length - 1) {
  14859. parts.push(hardline$5);
  14860. if (isNextLineEmpty$3(options.originalText, pathChild.getValue(), options)) {
  14861. parts.push(hardline$5);
  14862. }
  14863. }
  14864. }, "definitions");
  14865. return concat$6([concat$6(parts), hardline$5]);
  14866. }
  14867. case "OperationDefinition":
  14868. {
  14869. var hasOperation = options.originalText[options.locStart(n)] !== "{";
  14870. var hasName = !!n.name;
  14871. 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")]);
  14872. }
  14873. case "FragmentDefinition":
  14874. {
  14875. return concat$6(["fragment ", 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, ")"])) : "", " on ", path.call(print, "typeCondition"), printDirectives(path, print, n), " ", path.call(print, "selectionSet")]);
  14876. }
  14877. case "SelectionSet":
  14878. {
  14879. return concat$6(["{", indent$3(concat$6([hardline$5, join$3(hardline$5, path.call(function (selectionsPath) {
  14880. return printSequence(selectionsPath, options, print);
  14881. }, "selections"))])), hardline$5, "}"]);
  14882. }
  14883. case "Field":
  14884. {
  14885. 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) {
  14886. return printSequence(argsPath, options, print);
  14887. }, "arguments"))])), softline$2, ")"])) : "", printDirectives(path, print, n), n.selectionSet ? " " : "", path.call(print, "selectionSet")]));
  14888. }
  14889. case "Name":
  14890. {
  14891. return n.value;
  14892. }
  14893. case "StringValue":
  14894. {
  14895. if (n.block) {
  14896. return concat$6(['"""', hardline$5, join$3(hardline$5, n.value.replace(/"""/g, "\\$&").split("\n")), hardline$5, '"""']);
  14897. }
  14898. return concat$6(['"', n.value.replace(/["\\]/g, "\\$&").replace(/\n/g, "\\n"), '"']);
  14899. }
  14900. case "IntValue":
  14901. case "FloatValue":
  14902. case "EnumValue":
  14903. {
  14904. return n.value;
  14905. }
  14906. case "BooleanValue":
  14907. {
  14908. return n.value ? "true" : "false";
  14909. }
  14910. case "NullValue":
  14911. {
  14912. return "null";
  14913. }
  14914. case "Variable":
  14915. {
  14916. return concat$6(["$", path.call(print, "name")]);
  14917. }
  14918. case "ListValue":
  14919. {
  14920. 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, "]"]));
  14921. }
  14922. case "ObjectValue":
  14923. {
  14924. 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 ? " " : ""), "}"]));
  14925. }
  14926. case "ObjectField":
  14927. case "Argument":
  14928. {
  14929. return concat$6([path.call(print, "name"), ": ", path.call(print, "value")]);
  14930. }
  14931. case "Directive":
  14932. {
  14933. 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) {
  14934. return printSequence(argsPath, options, print);
  14935. }, "arguments"))])), softline$2, ")"])) : ""]);
  14936. }
  14937. case "NamedType":
  14938. {
  14939. return path.call(print, "name");
  14940. }
  14941. case "VariableDefinition":
  14942. {
  14943. return concat$6([path.call(print, "variable"), ": ", path.call(print, "type"), n.defaultValue ? concat$6([" = ", path.call(print, "defaultValue")]) : "", printDirectives(path, print, n)]);
  14944. }
  14945. case "TypeExtensionDefinition":
  14946. {
  14947. return concat$6(["extend ", path.call(print, "definition")]);
  14948. }
  14949. case "ObjectTypeExtension":
  14950. case "ObjectTypeDefinition":
  14951. {
  14952. 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) {
  14953. return printSequence(fieldsPath, options, print);
  14954. }, "fields"))])), hardline$5, "}"]) : ""]);
  14955. }
  14956. case "FieldDefinition":
  14957. {
  14958. 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) {
  14959. return printSequence(argsPath, options, print);
  14960. }, "arguments"))])), softline$2, ")"])) : "", ": ", path.call(print, "type"), printDirectives(path, print, n)]);
  14961. }
  14962. case "DirectiveDefinition":
  14963. {
  14964. 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) {
  14965. return printSequence(argsPath, options, print);
  14966. }, "arguments"))])), softline$2, ")"])) : "", concat$6([" on ", join$3(" | ", path.map(print, "locations"))])]);
  14967. }
  14968. case "EnumTypeExtension":
  14969. case "EnumTypeDefinition":
  14970. {
  14971. 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) {
  14972. return printSequence(valuesPath, options, print);
  14973. }, "values"))])), hardline$5, "}"]) : ""]);
  14974. }
  14975. case "EnumValueDefinition":
  14976. {
  14977. return concat$6([path.call(print, "description"), n.description ? hardline$5 : "", path.call(print, "name"), printDirectives(path, print, n)]);
  14978. }
  14979. case "InputValueDefinition":
  14980. {
  14981. 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)]);
  14982. }
  14983. case "InputObjectTypeExtension":
  14984. case "InputObjectTypeDefinition":
  14985. {
  14986. 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) {
  14987. return printSequence(fieldsPath, options, print);
  14988. }, "fields"))])), hardline$5, "}"]) : ""]);
  14989. }
  14990. case "SchemaDefinition":
  14991. {
  14992. 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) {
  14993. return printSequence(opsPath, options, print);
  14994. }, "operationTypes"))])) : "", hardline$5, "}"]);
  14995. }
  14996. case "OperationTypeDefinition":
  14997. {
  14998. return concat$6([path.call(print, "operation"), ": ", path.call(print, "type")]);
  14999. }
  15000. case "InterfaceTypeExtension":
  15001. case "InterfaceTypeDefinition":
  15002. {
  15003. 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) {
  15004. return printSequence(fieldsPath, options, print);
  15005. }, "fields"))])), hardline$5, "}"]) : ""]);
  15006. }
  15007. case "FragmentSpread":
  15008. {
  15009. return concat$6(["...", path.call(print, "name"), printDirectives(path, print, n)]);
  15010. }
  15011. case "InlineFragment":
  15012. {
  15013. return concat$6(["...", n.typeCondition ? concat$6([" on ", path.call(print, "typeCondition")]) : "", printDirectives(path, print, n), " ", path.call(print, "selectionSet")]);
  15014. }
  15015. case "UnionTypeExtension":
  15016. case "UnionTypeDefinition":
  15017. {
  15018. 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"))]))]) : ""]))]));
  15019. }
  15020. case "ScalarTypeExtension":
  15021. case "ScalarTypeDefinition":
  15022. {
  15023. return concat$6([path.call(print, "description"), n.description ? hardline$5 : "", n.kind === "ScalarTypeExtension" ? "extend " : "", "scalar ", path.call(print, "name"), printDirectives(path, print, n)]);
  15024. }
  15025. case "NonNullType":
  15026. {
  15027. return concat$6([path.call(print, "type"), "!"]);
  15028. }
  15029. case "ListType":
  15030. {
  15031. return concat$6(["[", path.call(print, "type"), "]"]);
  15032. }
  15033. default:
  15034. /* istanbul ignore next */
  15035. throw new Error("unknown graphql type: " + JSON.stringify(n.kind));
  15036. }
  15037. }
  15038. function printDirectives(path, print, n) {
  15039. if (n.directives.length === 0) {
  15040. return "";
  15041. }
  15042. return concat$6([" ", group$5(indent$3(concat$6([softline$2, join$3(concat$6([ifBreak$2("", " "), softline$2]), path.map(print, "directives"))])))]);
  15043. }
  15044. function printSequence(sequencePath, options, print) {
  15045. var count = sequencePath.getValue().length;
  15046. return sequencePath.map(function (path, i) {
  15047. var printed = print(path);
  15048. if (isNextLineEmpty$3(options.originalText, path.getValue(), options) && i < count - 1) {
  15049. return concat$6([printed, hardline$5]);
  15050. }
  15051. return printed;
  15052. });
  15053. }
  15054. function canAttachComment(node) {
  15055. return node.kind && node.kind !== "Comment";
  15056. }
  15057. function printComment$1(commentPath) {
  15058. var comment = commentPath.getValue();
  15059. if (comment.kind === "Comment") {
  15060. return "#" + comment.value.trimRight();
  15061. }
  15062. throw new Error("Not a comment: " + JSON.stringify(comment));
  15063. }
  15064. function determineInterfaceSeparator(originalSource) {
  15065. var start = originalSource.indexOf("implements");
  15066. if (start === -1) {
  15067. throw new Error("Must implement interfaces: " + originalSource);
  15068. }
  15069. var end = originalSource.indexOf("{");
  15070. if (end === -1) {
  15071. end = originalSource.length;
  15072. }
  15073. return originalSource.substr(start, end).includes("&") ? " & " : ", ";
  15074. }
  15075. function clean$2(node, newNode
  15076. /*, parent*/
  15077. ) {
  15078. delete newNode.loc;
  15079. delete newNode.comments;
  15080. }
  15081. var printerGraphql = {
  15082. print: genericPrint$1,
  15083. massageAstNode: clean$2,
  15084. hasPrettierIgnore: hasIgnoreComment$2,
  15085. insertPragma: insertPragma$3,
  15086. printComment: printComment$1,
  15087. canAttachComment: canAttachComment
  15088. };
  15089. var options$6 = {
  15090. bracketSpacing: commonOptions.bracketSpacing
  15091. };
  15092. var name$5 = "GraphQL";
  15093. var type$4 = "data";
  15094. var extensions$4 = [".graphql", ".gql"];
  15095. var tmScope$4 = "source.graphql";
  15096. var aceMode$4 = "text";
  15097. var languageId$4 = 139;
  15098. var graphql = {
  15099. name: name$5,
  15100. type: type$4,
  15101. extensions: extensions$4,
  15102. tmScope: tmScope$4,
  15103. aceMode: aceMode$4,
  15104. languageId: languageId$4
  15105. };
  15106. var graphql$1 = Object.freeze({
  15107. name: name$5,
  15108. type: type$4,
  15109. extensions: extensions$4,
  15110. tmScope: tmScope$4,
  15111. aceMode: aceMode$4,
  15112. languageId: languageId$4,
  15113. default: graphql
  15114. });
  15115. var require$$0$18 = ( graphql$1 && graphql ) || graphql$1;
  15116. var languages$1 = [createLanguage(require$$0$18, {
  15117. override: {
  15118. since: "1.5.0",
  15119. parsers: ["graphql"],
  15120. vscodeLanguageIds: ["graphql"]
  15121. }
  15122. })];
  15123. var printers$1 = {
  15124. graphql: printerGraphql
  15125. };
  15126. var languageGraphql = {
  15127. languages: languages$1,
  15128. options: options$6,
  15129. printers: printers$1
  15130. };
  15131. var _require$$0$builders$3 = doc.builders;
  15132. var concat$7 = _require$$0$builders$3.concat;
  15133. var join$4 = _require$$0$builders$3.join;
  15134. var softline$3 = _require$$0$builders$3.softline;
  15135. var hardline$6 = _require$$0$builders$3.hardline;
  15136. var line$5 = _require$$0$builders$3.line;
  15137. var group$6 = _require$$0$builders$3.group;
  15138. var indent$4 = _require$$0$builders$3.indent;
  15139. var ifBreak$3 = _require$$0$builders$3.ifBreak; // http://w3c.github.io/html/single-page.html#void-elements
  15140. 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:
  15141. // https://github.com/glimmerjs/glimmer-vm/blob/master/packages/%40glimmer/syntax/lib/generation/print.ts
  15142. function print(path, options, print) {
  15143. var n = path.getValue();
  15144. /* istanbul ignore if*/
  15145. if (!n) {
  15146. return "";
  15147. }
  15148. switch (n.type) {
  15149. case "Program":
  15150. {
  15151. return group$6(join$4(softline$3, path.map(print, "body").filter(function (text) {
  15152. return text !== "";
  15153. })));
  15154. }
  15155. case "ElementNode":
  15156. {
  15157. var tagFirstChar = n.tag[0];
  15158. var isLocal = n.tag.indexOf(".") !== -1;
  15159. var isGlimmerComponent = tagFirstChar.toUpperCase() === tagFirstChar || isLocal;
  15160. var hasChildren = n.children.length > 0;
  15161. var isVoid = isGlimmerComponent && !hasChildren || voidTags.indexOf(n.tag) !== -1;
  15162. var closeTagForNoBreak = isVoid ? concat$7([" />", softline$3]) : ">";
  15163. var closeTagForBreak = isVoid ? "/>" : ">";
  15164. var _getParams = function _getParams(path, print) {
  15165. 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"))]));
  15166. };
  15167. return concat$7([group$6(concat$7(["<", n.tag, _getParams(path, print), n.blockParams.length ? " as |".concat(n.blockParams.join(" "), "|") : "", ifBreak$3(softline$3, ""), ifBreak$3(closeTagForBreak, closeTagForNoBreak)])), 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, ">"]) : ""]))]);
  15168. }
  15169. case "BlockStatement":
  15170. {
  15171. var pp = path.getParentNode(1);
  15172. var isElseIf = pp && pp.inverse && pp.inverse.body.length === 1 && pp.inverse.body[0] === n && pp.inverse.body[0].path.parts[0] === "if";
  15173. var hasElseIf = n.inverse && n.inverse.body.length === 1 && n.inverse.body[0].type === "BlockStatement" && n.inverse.body[0].path.parts[0] === "if";
  15174. var indentElse = hasElseIf ? function (a) {
  15175. return a;
  15176. } : indent$4;
  15177. if (n.inverse) {
  15178. 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)])]);
  15179. } else if (isElseIf) {
  15180. return concat$7([concat$7(["{{else ", printPathParams(path, print), "}}"]), indent$4(concat$7([hardline$6, path.call(print, "program")]))]);
  15181. }
  15182. /**
  15183. * I want this boolean to be: if params are going to cause a break,
  15184. * not that it has params.
  15185. */
  15186. var hasParams = n.params.length > 0 || n.hash.pairs.length > 0;
  15187. var _hasChildren = n.program.body.length > 0;
  15188. 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)]))]);
  15189. }
  15190. case "ElementModifierStatement":
  15191. case "MustacheStatement":
  15192. {
  15193. var _pp = path.getParentNode(1);
  15194. var isConcat = _pp && _pp.type === "ConcatStatement";
  15195. return group$6(concat$7([n.escaped === false ? "{{{" : "{{", printPathParams(path, print), isConcat ? "" : softline$3, n.escaped === false ? "}}}" : "}}"]));
  15196. }
  15197. case "SubExpression":
  15198. {
  15199. var params = getParams(path, print);
  15200. var printedParams = params.length > 0 ? indent$4(concat$7([line$5, group$6(join$4(line$5, params))])) : "";
  15201. return group$6(concat$7(["(", printPath(path, print), printedParams, softline$3, ")"]));
  15202. }
  15203. case "AttrNode":
  15204. {
  15205. var isText = n.value.type === "TextNode";
  15206. if (isText && n.value.loc.start.column === n.value.loc.end.column) {
  15207. return concat$7([n.name]);
  15208. }
  15209. var quote = isText ? '"' : "";
  15210. return concat$7([n.name, "=", quote, path.call(print, "value"), quote]);
  15211. }
  15212. case "ConcatStatement":
  15213. {
  15214. return concat$7(['"', group$6(indent$4(join$4(softline$3, path.map(function (partPath) {
  15215. return print(partPath);
  15216. }, "parts").filter(function (a) {
  15217. return a !== "";
  15218. })))), '"']);
  15219. }
  15220. case "Hash":
  15221. {
  15222. return concat$7([join$4(line$5, path.map(print, "pairs"))]);
  15223. }
  15224. case "HashPair":
  15225. {
  15226. return concat$7([n.key, "=", path.call(print, "value")]);
  15227. }
  15228. case "TextNode":
  15229. {
  15230. var leadingSpace = "";
  15231. var trailingSpace = ""; // preserve a space inside of an attribute node where whitespace present, when next to mustache statement.
  15232. var inAttrNode = path.stack.indexOf("attributes") >= 0;
  15233. if (inAttrNode) {
  15234. var parentNode = path.getParentNode(0);
  15235. var _isConcat = parentNode.type === "ConcatStatement";
  15236. if (_isConcat) {
  15237. var parts = parentNode.parts;
  15238. var partIndex = parts.indexOf(n);
  15239. if (partIndex > 0) {
  15240. var partType = parts[partIndex - 1].type;
  15241. var isMustache = partType === "MustacheStatement";
  15242. if (isMustache) {
  15243. leadingSpace = " ";
  15244. }
  15245. }
  15246. if (partIndex < parts.length - 1) {
  15247. var _partType = parts[partIndex + 1].type;
  15248. var _isMustache = _partType === "MustacheStatement";
  15249. if (_isMustache) {
  15250. trailingSpace = " ";
  15251. }
  15252. }
  15253. }
  15254. }
  15255. return n.chars.replace(/^\s+/, leadingSpace).replace(/\s+$/, trailingSpace);
  15256. }
  15257. case "MustacheCommentStatement":
  15258. {
  15259. var dashes = n.value.indexOf("}}") > -1 ? "--" : "";
  15260. return concat$7(["{{!", dashes, n.value, dashes, "}}"]);
  15261. }
  15262. case "PathExpression":
  15263. {
  15264. return n.original;
  15265. }
  15266. case "BooleanLiteral":
  15267. {
  15268. return String(n.value);
  15269. }
  15270. case "CommentStatement":
  15271. {
  15272. return concat$7(["<!--", n.value, "-->"]);
  15273. }
  15274. case "StringLiteral":
  15275. {
  15276. return printStringLiteral(n.value, options);
  15277. }
  15278. case "NumberLiteral":
  15279. {
  15280. return String(n.value);
  15281. }
  15282. case "UndefinedLiteral":
  15283. {
  15284. return "undefined";
  15285. }
  15286. case "NullLiteral":
  15287. {
  15288. return "null";
  15289. }
  15290. /* istanbul ignore next */
  15291. default:
  15292. throw new Error("unknown glimmer type: " + JSON.stringify(n.type));
  15293. }
  15294. }
  15295. /**
  15296. * Prints a string literal with the correct surrounding quotes based on
  15297. * `options.singleQuote` and the number of escaped quotes contained in
  15298. * the string literal. This function is the glimmer equivalent of `printString`
  15299. * in `common/util`, but has differences because of the way escaped characters
  15300. * are treated in hbs string literals.
  15301. * @param {string} stringLiteral - the string literal value
  15302. * @param {object} options - the prettier options object
  15303. */
  15304. function printStringLiteral(stringLiteral, options) {
  15305. var double = {
  15306. quote: '"',
  15307. regex: /"/g
  15308. };
  15309. var single = {
  15310. quote: "'",
  15311. regex: /'/g
  15312. };
  15313. var preferred = options.singleQuote ? single : double;
  15314. var alternate = preferred === single ? double : single;
  15315. var shouldUseAlternateQuote = false; // If `stringLiteral` contains at least one of the quote preferred for
  15316. // enclosing the string, we might want to enclose with the alternate quote
  15317. // instead, to minimize the number of escaped quotes.
  15318. if (stringLiteral.includes(preferred.quote) || stringLiteral.includes(alternate.quote)) {
  15319. var numPreferredQuotes = (stringLiteral.match(preferred.regex) || []).length;
  15320. var numAlternateQuotes = (stringLiteral.match(alternate.regex) || []).length;
  15321. shouldUseAlternateQuote = numPreferredQuotes > numAlternateQuotes;
  15322. }
  15323. var enclosingQuote = shouldUseAlternateQuote ? alternate : preferred;
  15324. var escapedStringLiteral = stringLiteral.replace(enclosingQuote.regex, "\\".concat(enclosingQuote.quote));
  15325. return "".concat(enclosingQuote.quote).concat(escapedStringLiteral).concat(enclosingQuote.quote);
  15326. }
  15327. function printPath(path, print) {
  15328. return path.call(print, "path");
  15329. }
  15330. function getParams(path, print) {
  15331. var node = path.getValue();
  15332. var parts = [];
  15333. if (node.params.length > 0) {
  15334. parts = parts.concat(path.map(print, "params"));
  15335. }
  15336. if (node.hash && node.hash.pairs.length > 0) {
  15337. parts.push(path.call(print, "hash"));
  15338. }
  15339. return parts;
  15340. }
  15341. function printPathParams(path, print) {
  15342. var parts = [];
  15343. parts.push(printPath(path, print));
  15344. parts = parts.concat(getParams(path, print));
  15345. return indent$4(group$6(join$4(line$5, parts)));
  15346. }
  15347. function printBlockParams(path) {
  15348. var block = path.getValue();
  15349. if (!block.program || !block.program.blockParams.length) {
  15350. return "";
  15351. }
  15352. return concat$7([" as |", block.program.blockParams.join(" "), "|"]);
  15353. }
  15354. function printOpenBlock(path, print) {
  15355. return group$6(concat$7(["{{#", printPathParams(path, print), printBlockParams(path), softline$3, "}}"]));
  15356. }
  15357. function printCloseBlock(path, print) {
  15358. return concat$7(["{{/", path.call(print, "path"), "}}"]);
  15359. }
  15360. function clean$3(ast, newObj) {
  15361. delete newObj.loc; // (Glimmer/HTML) ignore TextNode whitespace
  15362. if (ast.type === "TextNode") {
  15363. if (ast.chars.replace(/\s+/, "") === "") {
  15364. return null;
  15365. }
  15366. newObj.chars = ast.chars.replace(/^\s+/, "").replace(/\s+$/, "");
  15367. }
  15368. }
  15369. var printerGlimmer = {
  15370. print: print,
  15371. massageAstNode: clean$3
  15372. };
  15373. var name$6 = "Handlebars";
  15374. var type$5 = "markup";
  15375. var group$7 = "HTML";
  15376. var aliases = ["hbs", "htmlbars"];
  15377. var extensions$5 = [".handlebars", ".hbs"];
  15378. var tmScope$5 = "text.html.handlebars";
  15379. var aceMode$5 = "handlebars";
  15380. var languageId$5 = 155;
  15381. var handlebars = {
  15382. name: name$6,
  15383. type: type$5,
  15384. group: group$7,
  15385. aliases: aliases,
  15386. extensions: extensions$5,
  15387. tmScope: tmScope$5,
  15388. aceMode: aceMode$5,
  15389. languageId: languageId$5
  15390. };
  15391. var handlebars$1 = Object.freeze({
  15392. name: name$6,
  15393. type: type$5,
  15394. group: group$7,
  15395. aliases: aliases,
  15396. extensions: extensions$5,
  15397. tmScope: tmScope$5,
  15398. aceMode: aceMode$5,
  15399. languageId: languageId$5,
  15400. default: handlebars
  15401. });
  15402. var require$$0$19 = ( handlebars$1 && handlebars ) || handlebars$1;
  15403. var languages$2 = [createLanguage(require$$0$19, {
  15404. override: {
  15405. since: null,
  15406. // unreleased
  15407. parsers: ["glimmer"],
  15408. vscodeLanguageIds: ["handlebars"]
  15409. }
  15410. })];
  15411. var printers$2 = {
  15412. glimmer: printerGlimmer
  15413. };
  15414. var languageHandlebars = {
  15415. languages: languages$2,
  15416. printers: printers$2
  15417. };
  15418. var clean$4 = function clean(ast, newNode) {
  15419. delete newNode.sourceSpan;
  15420. delete newNode.startSourceSpan;
  15421. delete newNode.endSourceSpan;
  15422. delete newNode.nameSpan;
  15423. delete newNode.valueSpan;
  15424. if (ast.type === "text" || ast.type === "comment") {
  15425. return null;
  15426. } // may be formatted by multiparser
  15427. if (ast.type === "yaml" || ast.type === "toml") {
  15428. return null;
  15429. }
  15430. if (ast.type === "attribute") {
  15431. delete newNode.value;
  15432. }
  15433. if (ast.type === "docType") {
  15434. delete newNode.value;
  15435. }
  15436. };
  15437. var a = ["accesskey", "charset", "coords", "download", "href", "hreflang", "name", "ping", "referrerpolicy", "rel", "rev", "shape", "tabindex", "target", "type"];
  15438. var abbr = ["title"];
  15439. var applet = ["align", "alt", "archive", "code", "codebase", "height", "hspace", "name", "object", "vspace", "width"];
  15440. var area = ["accesskey", "alt", "coords", "download", "href", "hreflang", "nohref", "ping", "referrerpolicy", "rel", "shape", "tabindex", "target", "type"];
  15441. var audio = ["autoplay", "controls", "crossorigin", "loop", "muted", "preload", "src"];
  15442. var base$2 = ["href", "target"];
  15443. var basefont = ["color", "face", "size"];
  15444. var bdo = ["dir"];
  15445. var blockquote = ["cite"];
  15446. var body = ["alink", "background", "bgcolor", "link", "text", "vlink"];
  15447. var br = ["clear"];
  15448. var button = ["accesskey", "autofocus", "disabled", "form", "formaction", "formenctype", "formmethod", "formnovalidate", "formtarget", "name", "tabindex", "type", "value"];
  15449. var canvas = ["height", "width"];
  15450. var caption = ["align"];
  15451. var col = ["align", "char", "charoff", "span", "valign", "width"];
  15452. var colgroup = ["align", "char", "charoff", "span", "valign", "width"];
  15453. var data = ["value"];
  15454. var del = ["cite", "datetime"];
  15455. var details = ["open"];
  15456. var dfn = ["title"];
  15457. var dialog = ["open"];
  15458. var dir = ["compact"];
  15459. var div = ["align"];
  15460. var dl = ["compact"];
  15461. var embed$3 = ["height", "src", "type", "width"];
  15462. var fieldset = ["disabled", "form", "name"];
  15463. var font = ["color", "face", "size"];
  15464. var form = ["accept", "accept-charset", "action", "autocomplete", "enctype", "method", "name", "novalidate", "target"];
  15465. var frame = ["frameborder", "longdesc", "marginheight", "marginwidth", "name", "noresize", "scrolling", "src"];
  15466. var frameset = ["cols", "rows"];
  15467. var h1 = ["align"];
  15468. var h2 = ["align"];
  15469. var h3 = ["align"];
  15470. var h4 = ["align"];
  15471. var h5 = ["align"];
  15472. var h6 = ["align"];
  15473. var head = ["profile"];
  15474. var hr = ["align", "noshade", "size", "width"];
  15475. var html = ["manifest", "version"];
  15476. var iframe = ["align", "allowfullscreen", "allowpaymentrequest", "allowusermedia", "frameborder", "height", "longdesc", "marginheight", "marginwidth", "name", "referrerpolicy", "sandbox", "scrolling", "src", "srcdoc", "width"];
  15477. var img = ["align", "alt", "border", "crossorigin", "decoding", "height", "hspace", "ismap", "longdesc", "name", "referrerpolicy", "sizes", "src", "srcset", "usemap", "vspace", "width"];
  15478. 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"];
  15479. var ins = ["cite", "datetime"];
  15480. var isindex = ["prompt"];
  15481. var label = ["accesskey", "for", "form"];
  15482. var legend = ["accesskey", "align"];
  15483. var li = ["type", "value"];
  15484. var link$1 = ["as", "charset", "color", "crossorigin", "href", "hreflang", "integrity", "media", "nonce", "referrerpolicy", "rel", "rev", "sizes", "target", "title", "type"];
  15485. var map = ["name"];
  15486. var menu = ["compact"];
  15487. var meta = ["charset", "content", "http-equiv", "name", "scheme"];
  15488. var meter = ["high", "low", "max", "min", "optimum", "value"];
  15489. var object = ["align", "archive", "border", "classid", "codebase", "codetype", "data", "declare", "form", "height", "hspace", "name", "standby", "tabindex", "type", "typemustmatch", "usemap", "vspace", "width"];
  15490. var ol = ["compact", "reversed", "start", "type"];
  15491. var optgroup = ["disabled", "label"];
  15492. var option = ["disabled", "label", "selected", "value"];
  15493. var output = ["for", "form", "name"];
  15494. var p = ["align"];
  15495. var param = ["name", "type", "value", "valuetype"];
  15496. var pre = ["width"];
  15497. var progress = ["max", "value"];
  15498. var q = ["cite"];
  15499. var script = ["async", "charset", "crossorigin", "defer", "integrity", "language", "nomodule", "nonce", "referrerpolicy", "src", "type"];
  15500. var select = ["autocomplete", "autofocus", "disabled", "form", "multiple", "name", "required", "size", "tabindex"];
  15501. var slot = ["name"];
  15502. var source = ["media", "sizes", "src", "srcset", "type"];
  15503. var style = ["media", "nonce", "title", "type"];
  15504. var table = ["align", "bgcolor", "border", "cellpadding", "cellspacing", "frame", "rules", "summary", "width"];
  15505. var tbody = ["align", "char", "charoff", "valign"];
  15506. var td = ["abbr", "align", "axis", "bgcolor", "char", "charoff", "colspan", "headers", "height", "nowrap", "rowspan", "scope", "valign", "width"];
  15507. var textarea = ["accesskey", "autocomplete", "autofocus", "cols", "dirname", "disabled", "form", "maxlength", "minlength", "name", "placeholder", "readonly", "required", "rows", "tabindex", "wrap"];
  15508. var tfoot = ["align", "char", "charoff", "valign"];
  15509. var th = ["abbr", "align", "axis", "bgcolor", "char", "charoff", "colspan", "headers", "height", "nowrap", "rowspan", "scope", "valign", "width"];
  15510. var thead = ["align", "char", "charoff", "valign"];
  15511. var time = ["datetime"];
  15512. var tr = ["align", "bgcolor", "char", "charoff", "valign"];
  15513. var track = ["default", "kind", "label", "src", "srclang"];
  15514. var ul = ["compact", "type"];
  15515. var video = ["autoplay", "controls", "crossorigin", "height", "loop", "muted", "playsinline", "poster", "preload", "src", "width"];
  15516. var index$13 = {
  15517. a: a,
  15518. abbr: abbr,
  15519. applet: applet,
  15520. area: area,
  15521. audio: audio,
  15522. base: base$2,
  15523. basefont: basefont,
  15524. bdo: bdo,
  15525. blockquote: blockquote,
  15526. body: body,
  15527. br: br,
  15528. button: button,
  15529. canvas: canvas,
  15530. caption: caption,
  15531. col: col,
  15532. colgroup: colgroup,
  15533. data: data,
  15534. del: del,
  15535. details: details,
  15536. dfn: dfn,
  15537. dialog: dialog,
  15538. dir: dir,
  15539. div: div,
  15540. dl: dl,
  15541. embed: embed$3,
  15542. fieldset: fieldset,
  15543. font: font,
  15544. form: form,
  15545. frame: frame,
  15546. frameset: frameset,
  15547. h1: h1,
  15548. h2: h2,
  15549. h3: h3,
  15550. h4: h4,
  15551. h5: h5,
  15552. h6: h6,
  15553. head: head,
  15554. hr: hr,
  15555. html: html,
  15556. iframe: iframe,
  15557. img: img,
  15558. input: input,
  15559. ins: ins,
  15560. isindex: isindex,
  15561. label: label,
  15562. legend: legend,
  15563. li: li,
  15564. link: link$1,
  15565. map: map,
  15566. menu: menu,
  15567. meta: meta,
  15568. meter: meter,
  15569. object: object,
  15570. ol: ol,
  15571. optgroup: optgroup,
  15572. option: option,
  15573. output: output,
  15574. p: p,
  15575. param: param,
  15576. pre: pre,
  15577. progress: progress,
  15578. q: q,
  15579. script: script,
  15580. select: select,
  15581. slot: slot,
  15582. source: source,
  15583. style: style,
  15584. table: table,
  15585. tbody: tbody,
  15586. td: td,
  15587. textarea: textarea,
  15588. tfoot: tfoot,
  15589. th: th,
  15590. thead: thead,
  15591. time: time,
  15592. tr: tr,
  15593. track: track,
  15594. ul: ul,
  15595. video: video,
  15596. "*": ["accesskey", "autocapitalize", "class", "contenteditable", "dir", "draggable", "hidden", "id", "inputmode", "is", "itemid", "itemprop", "itemref", "itemscope", "itemtype", "lang", "nonce", "slot", "spellcheck", "style", "tabindex", "title", "translate"]
  15597. };
  15598. var htmlElementAttributes = Object.freeze({
  15599. a: a,
  15600. abbr: abbr,
  15601. applet: applet,
  15602. area: area,
  15603. audio: audio,
  15604. base: base$2,
  15605. basefont: basefont,
  15606. bdo: bdo,
  15607. blockquote: blockquote,
  15608. body: body,
  15609. br: br,
  15610. button: button,
  15611. canvas: canvas,
  15612. caption: caption,
  15613. col: col,
  15614. colgroup: colgroup,
  15615. data: data,
  15616. del: del,
  15617. details: details,
  15618. dfn: dfn,
  15619. dialog: dialog,
  15620. dir: dir,
  15621. div: div,
  15622. dl: dl,
  15623. embed: embed$3,
  15624. fieldset: fieldset,
  15625. font: font,
  15626. form: form,
  15627. frame: frame,
  15628. frameset: frameset,
  15629. h1: h1,
  15630. h2: h2,
  15631. h3: h3,
  15632. h4: h4,
  15633. h5: h5,
  15634. h6: h6,
  15635. head: head,
  15636. hr: hr,
  15637. html: html,
  15638. iframe: iframe,
  15639. img: img,
  15640. input: input,
  15641. ins: ins,
  15642. isindex: isindex,
  15643. label: label,
  15644. legend: legend,
  15645. li: li,
  15646. link: link$1,
  15647. map: map,
  15648. menu: menu,
  15649. meta: meta,
  15650. meter: meter,
  15651. object: object,
  15652. ol: ol,
  15653. optgroup: optgroup,
  15654. option: option,
  15655. output: output,
  15656. p: p,
  15657. param: param,
  15658. pre: pre,
  15659. progress: progress,
  15660. q: q,
  15661. script: script,
  15662. select: select,
  15663. slot: slot,
  15664. source: source,
  15665. style: style,
  15666. table: table,
  15667. tbody: tbody,
  15668. td: td,
  15669. textarea: textarea,
  15670. tfoot: tfoot,
  15671. th: th,
  15672. thead: thead,
  15673. time: time,
  15674. tr: tr,
  15675. track: track,
  15676. ul: ul,
  15677. video: video,
  15678. default: index$13
  15679. });
  15680. 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"};
  15681. var htmlElementAttributes$1 = ( htmlElementAttributes && index$13 ) || htmlElementAttributes;
  15682. var CSS_DISPLAY_TAGS = json$4.CSS_DISPLAY_TAGS;
  15683. var CSS_DISPLAY_DEFAULT = json$4.CSS_DISPLAY_DEFAULT;
  15684. var CSS_WHITE_SPACE_TAGS = json$4.CSS_WHITE_SPACE_TAGS;
  15685. var CSS_WHITE_SPACE_DEFAULT = json$4.CSS_WHITE_SPACE_DEFAULT;
  15686. var HTML_TAGS = arrayToMap(htmlTagNames$1);
  15687. var HTML_ELEMENT_ATTRIBUTES = mapObject(htmlElementAttributes$1, arrayToMap);
  15688. function arrayToMap(array) {
  15689. var map = Object.create(null);
  15690. var _iteratorNormalCompletion = true;
  15691. var _didIteratorError = false;
  15692. var _iteratorError = undefined;
  15693. try {
  15694. for (var _iterator = array[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  15695. var value = _step.value;
  15696. map[value] = true;
  15697. }
  15698. } catch (err) {
  15699. _didIteratorError = true;
  15700. _iteratorError = err;
  15701. } finally {
  15702. try {
  15703. if (!_iteratorNormalCompletion && _iterator.return != null) {
  15704. _iterator.return();
  15705. }
  15706. } finally {
  15707. if (_didIteratorError) {
  15708. throw _iteratorError;
  15709. }
  15710. }
  15711. }
  15712. return map;
  15713. }
  15714. function mapObject(object, fn) {
  15715. var newObject = Object.create(null);
  15716. var _arr = Object.keys(object);
  15717. for (var _i = 0; _i < _arr.length; _i++) {
  15718. var key = _arr[_i];
  15719. newObject[key] = fn(object[key], key);
  15720. }
  15721. return newObject;
  15722. }
  15723. function shouldPreserveContent$1(node, options) {
  15724. if (node.type === "element" && node.fullName === "template" && node.attrMap.lang && node.attrMap.lang !== "html") {
  15725. return true;
  15726. } // unterminated node in ie conditional comment
  15727. // e.g. <!--[if lt IE 9]><html><![endif]-->
  15728. if (node.type === "ieConditionalComment" && node.lastChild && !node.lastChild.isSelfClosing && !node.lastChild.endSourceSpan) {
  15729. return true;
  15730. } // incomplete html in ie conditional comment
  15731. // e.g. <!--[if lt IE 9]></div><![endif]-->
  15732. if (node.type === "ieConditionalComment" && !node.complete) {
  15733. return true;
  15734. } // top-level elements (excluding <template>, <style> and <script>) in Vue SFC are considered custom block
  15735. // custom blocks can be written in other languages so we should preserve them to not break the code
  15736. 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>
  15737. "html"].indexOf(node.fullName) === -1) {
  15738. return true;
  15739. } // TODO: handle non-text children in <pre>
  15740. if (isPreLikeNode(node) && node.children.some(function (child) {
  15741. return child.type !== "text" && child.type !== "interpolation";
  15742. })) {
  15743. return true;
  15744. }
  15745. return false;
  15746. }
  15747. function hasPrettierIgnore$1(node) {
  15748. if (node.type === "attribute" || isTextLikeNode$1(node)) {
  15749. return false;
  15750. }
  15751. if (!node.parent) {
  15752. return false;
  15753. }
  15754. if (typeof node.index !== "number" || node.index === 0) {
  15755. return false;
  15756. }
  15757. var prevNode = node.parent.children[node.index - 1];
  15758. return isPrettierIgnore(prevNode);
  15759. }
  15760. function isPrettierIgnore(node) {
  15761. return node.type === "comment" && node.value.trim() === "prettier-ignore";
  15762. }
  15763. function getPrettierIgnoreAttributeCommentData$1(value) {
  15764. var match = value.trim().match(/^prettier-ignore-attribute(?:\s+([^]+))?$/);
  15765. if (!match) {
  15766. return false;
  15767. }
  15768. if (!match[1]) {
  15769. return true;
  15770. }
  15771. return match[1].split(/\s+/);
  15772. }
  15773. /** there's no opening/closing tag or it's considered not breakable */
  15774. function isTextLikeNode$1(node) {
  15775. return node.type === "text" || node.type === "comment";
  15776. }
  15777. function isScriptLikeTag$1(node) {
  15778. return node.type === "element" && (node.fullName === "script" || node.fullName === "style" || node.fullName === "svg:style");
  15779. }
  15780. function isFrontMatterNode(node) {
  15781. return node.type === "yaml" || node.type === "toml";
  15782. }
  15783. function canHaveInterpolation(node) {
  15784. return node.children && !isScriptLikeTag$1(node);
  15785. }
  15786. function isWhitespaceSensitiveNode(node) {
  15787. return isScriptLikeTag$1(node) || node.type === "interpolation" || isIndentationSensitiveNode(node);
  15788. }
  15789. function isIndentationSensitiveNode(node) {
  15790. return getNodeCssStyleWhiteSpace(node).startsWith("pre");
  15791. }
  15792. function isLeadingSpaceSensitiveNode(node) {
  15793. var isLeadingSpaceSensitive = _isLeadingSpaceSensitiveNode();
  15794. if (isLeadingSpaceSensitive && !node.prev && node.parent && node.parent.tagDefinition && node.parent.tagDefinition.ignoreFirstLf) {
  15795. return node.type === "interpolation";
  15796. }
  15797. return isLeadingSpaceSensitive;
  15798. function _isLeadingSpaceSensitiveNode() {
  15799. if (isFrontMatterNode(node)) {
  15800. return false;
  15801. }
  15802. if ((node.type === "text" || node.type === "interpolation") && node.prev && (node.prev.type === "text" || node.prev.type === "interpolation")) {
  15803. return true;
  15804. }
  15805. if (!node.parent || node.parent.cssDisplay === "none") {
  15806. return false;
  15807. }
  15808. if (isPreLikeNode(node.parent)) {
  15809. return true;
  15810. }
  15811. if (!node.prev && (node.parent.type === "root" || isScriptLikeTag$1(node.parent) || !isFirstChildLeadingSpaceSensitiveCssDisplay(node.parent.cssDisplay))) {
  15812. return false;
  15813. }
  15814. if (node.prev && !isNextLeadingSpaceSensitiveCssDisplay(node.prev.cssDisplay)) {
  15815. return false;
  15816. }
  15817. return true;
  15818. }
  15819. }
  15820. function isTrailingSpaceSensitiveNode(node) {
  15821. if (isFrontMatterNode(node)) {
  15822. return false;
  15823. }
  15824. if ((node.type === "text" || node.type === "interpolation") && node.next && (node.next.type === "text" || node.next.type === "interpolation")) {
  15825. return true;
  15826. }
  15827. if (!node.parent || node.parent.cssDisplay === "none") {
  15828. return false;
  15829. }
  15830. if (isPreLikeNode(node.parent)) {
  15831. return true;
  15832. }
  15833. if (!node.next && (node.parent.type === "root" || isScriptLikeTag$1(node.parent) || !isLastChildTrailingSpaceSensitiveCssDisplay(node.parent.cssDisplay))) {
  15834. return false;
  15835. }
  15836. if (node.next && !isPrevTrailingSpaceSensitiveCssDisplay(node.next.cssDisplay)) {
  15837. return false;
  15838. }
  15839. return true;
  15840. }
  15841. function isDanglingSpaceSensitiveNode(node) {
  15842. return isDanglingSpaceSensitiveCssDisplay(node.cssDisplay) && !isScriptLikeTag$1(node);
  15843. }
  15844. function forceNextEmptyLine$1(node) {
  15845. return isFrontMatterNode(node) || node.next && node.sourceSpan.end.line + 1 < node.next.sourceSpan.start.line;
  15846. }
  15847. /** firstChild leadingSpaces and lastChild trailingSpaces */
  15848. function forceBreakContent$1(node) {
  15849. return forceBreakChildren$1(node) || node.type === "element" && node.children.length !== 0 && (["body", "template", "script", "style"].indexOf(node.name) !== -1 || node.children.some(function (child) {
  15850. return hasNonTextChild(child);
  15851. })) || node.firstChild && node.firstChild === node.lastChild && hasLeadingLineBreak(node.firstChild) && (!node.lastChild.isTrailingSpaceSensitive || hasTrailingLineBreak(node.lastChild));
  15852. }
  15853. /** spaces between children */
  15854. function forceBreakChildren$1(node) {
  15855. 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");
  15856. }
  15857. function preferHardlineAsLeadingSpaces$1(node) {
  15858. return preferHardlineAsSurroundingSpaces(node) || node.prev && preferHardlineAsTrailingSpaces(node.prev) || hasSurroundingLineBreak(node);
  15859. }
  15860. function preferHardlineAsTrailingSpaces(node) {
  15861. return preferHardlineAsSurroundingSpaces(node) || node.type === "element" && node.fullName === "br" || hasSurroundingLineBreak(node);
  15862. }
  15863. function hasSurroundingLineBreak(node) {
  15864. return hasLeadingLineBreak(node) && hasTrailingLineBreak(node);
  15865. }
  15866. function hasLeadingLineBreak(node) {
  15867. 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);
  15868. }
  15869. function hasTrailingLineBreak(node) {
  15870. 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);
  15871. }
  15872. function preferHardlineAsSurroundingSpaces(node) {
  15873. switch (node.type) {
  15874. case "ieConditionalComment":
  15875. case "comment":
  15876. case "directive":
  15877. return true;
  15878. case "element":
  15879. return ["script", "select"].indexOf(node.name) !== -1;
  15880. }
  15881. return false;
  15882. }
  15883. function getLastDescendant$1(node) {
  15884. return node.lastChild ? getLastDescendant$1(node.lastChild) : node;
  15885. }
  15886. function hasNonTextChild(node) {
  15887. return node.children && node.children.some(function (child) {
  15888. return child.type !== "text";
  15889. });
  15890. }
  15891. function inferScriptParser$1(node) {
  15892. if (node.name === "script" && !node.attrMap.src) {
  15893. 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") {
  15894. return "babel";
  15895. }
  15896. if (node.attrMap.type === "application/x-typescript" || node.attrMap.lang === "ts" || node.attrMap.lang === "tsx") {
  15897. return "typescript";
  15898. }
  15899. if (node.attrMap.type === "text/markdown") {
  15900. return "markdown";
  15901. }
  15902. if (node.attrMap.type === "application/ld+json") {
  15903. return "json";
  15904. }
  15905. }
  15906. if (node.name === "style") {
  15907. if (!node.attrMap.lang || node.attrMap.lang === "postcss") {
  15908. return "css";
  15909. }
  15910. if (node.attrMap.lang === "scss") {
  15911. return "scss";
  15912. }
  15913. if (node.attrMap.lang === "less") {
  15914. return "less";
  15915. }
  15916. }
  15917. return null;
  15918. }
  15919. function isBlockLikeCssDisplay(cssDisplay) {
  15920. return cssDisplay === "block" || cssDisplay === "list-item" || cssDisplay.startsWith("table");
  15921. }
  15922. function isFirstChildLeadingSpaceSensitiveCssDisplay(cssDisplay) {
  15923. return !isBlockLikeCssDisplay(cssDisplay) && cssDisplay !== "inline-block";
  15924. }
  15925. function isLastChildTrailingSpaceSensitiveCssDisplay(cssDisplay) {
  15926. return !isBlockLikeCssDisplay(cssDisplay) && cssDisplay !== "inline-block";
  15927. }
  15928. function isPrevTrailingSpaceSensitiveCssDisplay(cssDisplay) {
  15929. return !isBlockLikeCssDisplay(cssDisplay);
  15930. }
  15931. function isNextLeadingSpaceSensitiveCssDisplay(cssDisplay) {
  15932. return !isBlockLikeCssDisplay(cssDisplay);
  15933. }
  15934. function isDanglingSpaceSensitiveCssDisplay(cssDisplay) {
  15935. return !isBlockLikeCssDisplay(cssDisplay) && cssDisplay !== "inline-block";
  15936. }
  15937. function isPreLikeNode(node) {
  15938. return getNodeCssStyleWhiteSpace(node).startsWith("pre");
  15939. }
  15940. function countParents$1(path) {
  15941. var predicate = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () {
  15942. return true;
  15943. };
  15944. var counter = 0;
  15945. for (var i = path.stack.length - 1; i >= 0; i--) {
  15946. var value = path.stack[i];
  15947. if (value && _typeof(value) === "object" && !Array.isArray(value) && predicate(value)) {
  15948. counter++;
  15949. }
  15950. }
  15951. return counter;
  15952. }
  15953. function hasParent(node, fn) {
  15954. var current = node;
  15955. while (current) {
  15956. if (fn(current)) {
  15957. return true;
  15958. }
  15959. current = current.parent;
  15960. }
  15961. return false;
  15962. }
  15963. function getNodeCssStyleDisplay(node, options) {
  15964. if (node.prev && node.prev.type === "comment") {
  15965. // <!-- display: block -->
  15966. var match = node.prev.value.match(/^\s*display:\s*([a-z]+)\s*$/);
  15967. if (match) {
  15968. return match[1];
  15969. }
  15970. }
  15971. var isInSvgForeignObject = false;
  15972. if (node.type === "element" && node.namespace === "svg") {
  15973. if (hasParent(node, function (parent) {
  15974. return parent.fullName === "svg:foreignObject";
  15975. })) {
  15976. isInSvgForeignObject = true;
  15977. } else {
  15978. return node.name === "svg" ? "inline-block" : "block";
  15979. }
  15980. }
  15981. switch (options.htmlWhitespaceSensitivity) {
  15982. case "strict":
  15983. return "inline";
  15984. case "ignore":
  15985. return "block";
  15986. default:
  15987. return node.type === "element" && (!node.namespace || isInSvgForeignObject) && CSS_DISPLAY_TAGS[node.name] || CSS_DISPLAY_DEFAULT;
  15988. }
  15989. }
  15990. function getNodeCssStyleWhiteSpace(node) {
  15991. return node.type === "element" && !node.namespace && CSS_WHITE_SPACE_TAGS[node.name] || CSS_WHITE_SPACE_DEFAULT;
  15992. }
  15993. function getMinIndentation(text) {
  15994. var minIndentation = Infinity;
  15995. var _iteratorNormalCompletion2 = true;
  15996. var _didIteratorError2 = false;
  15997. var _iteratorError2 = undefined;
  15998. try {
  15999. for (var _iterator2 = text.split("\n")[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
  16000. var lineText = _step2.value;
  16001. if (lineText.length === 0) {
  16002. continue;
  16003. }
  16004. if (/\S/.test(lineText[0])) {
  16005. return 0;
  16006. }
  16007. var indentation = lineText.match(/^\s*/)[0].length;
  16008. if (lineText.length === indentation) {
  16009. continue;
  16010. }
  16011. if (indentation < minIndentation) {
  16012. minIndentation = indentation;
  16013. }
  16014. }
  16015. } catch (err) {
  16016. _didIteratorError2 = true;
  16017. _iteratorError2 = err;
  16018. } finally {
  16019. try {
  16020. if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
  16021. _iterator2.return();
  16022. }
  16023. } finally {
  16024. if (_didIteratorError2) {
  16025. throw _iteratorError2;
  16026. }
  16027. }
  16028. }
  16029. return minIndentation === Infinity ? 0 : minIndentation;
  16030. }
  16031. function dedentString$1(text) {
  16032. var minIndent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : getMinIndentation(text);
  16033. return minIndent === 0 ? text : text.split("\n").map(function (lineText) {
  16034. return lineText.slice(minIndent);
  16035. }).join("\n");
  16036. }
  16037. function normalizeParts$1(parts) {
  16038. var newParts = [];
  16039. var restParts = parts.slice();
  16040. while (restParts.length !== 0) {
  16041. var part = restParts.shift();
  16042. if (!part) {
  16043. continue;
  16044. }
  16045. if (part.type === "concat") {
  16046. Array.prototype.unshift.apply(restParts, part.parts);
  16047. continue;
  16048. }
  16049. if (newParts.length !== 0 && typeof newParts[newParts.length - 1] === "string" && typeof part === "string") {
  16050. newParts.push(newParts.pop() + part);
  16051. continue;
  16052. }
  16053. newParts.push(part);
  16054. }
  16055. return newParts;
  16056. }
  16057. function identity(x) {
  16058. return x;
  16059. }
  16060. function shouldNotPrintClosingTag$1(node, options) {
  16061. return !node.isSelfClosing && !node.endSourceSpan && (hasPrettierIgnore$1(node) || shouldPreserveContent$1(node.parent, options));
  16062. }
  16063. function countChars$1(text, char) {
  16064. var counter = 0;
  16065. for (var i = 0; i < text.length; i++) {
  16066. if (text[i] === char) {
  16067. counter++;
  16068. }
  16069. }
  16070. return counter;
  16071. }
  16072. function unescapeQuoteEntities$1(text) {
  16073. return text.replace(/&apos;/g, "'").replace(/&quot;/g, '"');
  16074. }
  16075. var utils$6 = {
  16076. HTML_ELEMENT_ATTRIBUTES: HTML_ELEMENT_ATTRIBUTES,
  16077. HTML_TAGS: HTML_TAGS,
  16078. canHaveInterpolation: canHaveInterpolation,
  16079. countChars: countChars$1,
  16080. countParents: countParents$1,
  16081. dedentString: dedentString$1,
  16082. forceBreakChildren: forceBreakChildren$1,
  16083. forceBreakContent: forceBreakContent$1,
  16084. forceNextEmptyLine: forceNextEmptyLine$1,
  16085. getLastDescendant: getLastDescendant$1,
  16086. getNodeCssStyleDisplay: getNodeCssStyleDisplay,
  16087. getNodeCssStyleWhiteSpace: getNodeCssStyleWhiteSpace,
  16088. getPrettierIgnoreAttributeCommentData: getPrettierIgnoreAttributeCommentData$1,
  16089. hasPrettierIgnore: hasPrettierIgnore$1,
  16090. identity: identity,
  16091. inferScriptParser: inferScriptParser$1,
  16092. isDanglingSpaceSensitiveNode: isDanglingSpaceSensitiveNode,
  16093. isFrontMatterNode: isFrontMatterNode,
  16094. isIndentationSensitiveNode: isIndentationSensitiveNode,
  16095. isLeadingSpaceSensitiveNode: isLeadingSpaceSensitiveNode,
  16096. isPreLikeNode: isPreLikeNode,
  16097. isScriptLikeTag: isScriptLikeTag$1,
  16098. isTextLikeNode: isTextLikeNode$1,
  16099. isTrailingSpaceSensitiveNode: isTrailingSpaceSensitiveNode,
  16100. isWhitespaceSensitiveNode: isWhitespaceSensitiveNode,
  16101. normalizeParts: normalizeParts$1,
  16102. preferHardlineAsLeadingSpaces: preferHardlineAsLeadingSpaces$1,
  16103. preferHardlineAsTrailingSpaces: preferHardlineAsTrailingSpaces,
  16104. shouldNotPrintClosingTag: shouldNotPrintClosingTag$1,
  16105. shouldPreserveContent: shouldPreserveContent$1,
  16106. unescapeQuoteEntities: unescapeQuoteEntities$1
  16107. };
  16108. var canHaveInterpolation$1 = utils$6.canHaveInterpolation;
  16109. var getNodeCssStyleDisplay$1 = utils$6.getNodeCssStyleDisplay;
  16110. var isDanglingSpaceSensitiveNode$1 = utils$6.isDanglingSpaceSensitiveNode;
  16111. var isIndentationSensitiveNode$1 = utils$6.isIndentationSensitiveNode;
  16112. var isLeadingSpaceSensitiveNode$1 = utils$6.isLeadingSpaceSensitiveNode;
  16113. var isTrailingSpaceSensitiveNode$1 = utils$6.isTrailingSpaceSensitiveNode;
  16114. var isWhitespaceSensitiveNode$1 = utils$6.isWhitespaceSensitiveNode;
  16115. var PREPROCESS_PIPELINE = [removeIgnorableFirstLf, mergeIeConditonalStartEndCommentIntoElementOpeningTag, mergeCdataIntoText, extractInterpolation, extractWhitespaces, addCssDisplay, addIsSelfClosing, addHasHtmComponentClosingTag, addIsSpaceSensitive, mergeSimpleElementIntoText];
  16116. function preprocess(ast, options) {
  16117. for (var _i = 0; _i < PREPROCESS_PIPELINE.length; _i++) {
  16118. var fn = PREPROCESS_PIPELINE[_i];
  16119. ast = fn(ast, options);
  16120. }
  16121. return ast;
  16122. }
  16123. function removeIgnorableFirstLf(ast
  16124. /*, options */
  16125. ) {
  16126. return ast.map(function (node) {
  16127. if (node.type === "element" && node.tagDefinition.ignoreFirstLf && node.children.length !== 0 && node.children[0].type === "text" && node.children[0].value[0] === "\n") {
  16128. var text = node.children[0];
  16129. return node.clone({
  16130. children: text.value.length === 1 ? node.children.slice(1) : [].concat(text.clone({
  16131. value: text.value.slice(1)
  16132. }), node.children.slice(1))
  16133. });
  16134. }
  16135. return node;
  16136. });
  16137. }
  16138. function mergeIeConditonalStartEndCommentIntoElementOpeningTag(ast
  16139. /*, options */
  16140. ) {
  16141. /**
  16142. * <!--[if ...]><!--><target><!--<![endif]-->
  16143. */
  16144. var isTarget = function isTarget(node) {
  16145. 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;
  16146. };
  16147. return ast.map(function (node) {
  16148. if (node.children) {
  16149. var isTargetResults = node.children.map(isTarget);
  16150. if (isTargetResults.some(Boolean)) {
  16151. var newChildren = [];
  16152. for (var i = 0; i < node.children.length; i++) {
  16153. var child = node.children[i];
  16154. if (isTargetResults[i + 1]) {
  16155. // ieConditionalStartComment
  16156. continue;
  16157. }
  16158. if (isTargetResults[i]) {
  16159. var ieConditionalStartComment = child.prev;
  16160. var ieConditionalEndComment = child.firstChild;
  16161. var ParseSourceSpan = child.sourceSpan.constructor;
  16162. var startSourceSpan = new ParseSourceSpan(ieConditionalStartComment.sourceSpan.start, ieConditionalEndComment.sourceSpan.end);
  16163. var sourceSpan = new ParseSourceSpan(startSourceSpan.start, child.sourceSpan.end);
  16164. newChildren.push(child.clone({
  16165. condition: ieConditionalStartComment.condition,
  16166. sourceSpan: sourceSpan,
  16167. startSourceSpan: startSourceSpan,
  16168. children: child.children.slice(1)
  16169. }));
  16170. continue;
  16171. }
  16172. newChildren.push(child);
  16173. }
  16174. return node.clone({
  16175. children: newChildren
  16176. });
  16177. }
  16178. }
  16179. return node;
  16180. });
  16181. }
  16182. function mergeNodeIntoText(ast, shouldMerge, getValue) {
  16183. return ast.map(function (node) {
  16184. if (node.children) {
  16185. var shouldMergeResults = node.children.map(shouldMerge);
  16186. if (shouldMergeResults.some(Boolean)) {
  16187. var newChildren = [];
  16188. for (var i = 0; i < node.children.length; i++) {
  16189. var child = node.children[i];
  16190. if (child.type !== "text" && !shouldMergeResults[i]) {
  16191. newChildren.push(child);
  16192. continue;
  16193. }
  16194. var newChild = child.type === "text" ? child : child.clone({
  16195. type: "text",
  16196. value: getValue(child)
  16197. });
  16198. if (newChildren.length === 0 || newChildren[newChildren.length - 1].type !== "text") {
  16199. newChildren.push(newChild);
  16200. continue;
  16201. }
  16202. var lastChild = newChildren.pop();
  16203. var ParseSourceSpan = lastChild.sourceSpan.constructor;
  16204. newChildren.push(lastChild.clone({
  16205. value: lastChild.value + newChild.value,
  16206. sourceSpan: new ParseSourceSpan(lastChild.sourceSpan.start, newChild.sourceSpan.end)
  16207. }));
  16208. }
  16209. return node.clone({
  16210. children: newChildren
  16211. });
  16212. }
  16213. }
  16214. return node;
  16215. });
  16216. }
  16217. function mergeCdataIntoText(ast
  16218. /*, options */
  16219. ) {
  16220. return mergeNodeIntoText(ast, function (node) {
  16221. return node.type === "cdata";
  16222. }, function (node) {
  16223. return "<![CDATA[".concat(node.value, "]]>");
  16224. });
  16225. }
  16226. function mergeSimpleElementIntoText(ast
  16227. /*, options */
  16228. ) {
  16229. var isSimpleElement = function isSimpleElement(node) {
  16230. return node.type === "element" && node.attrs.length === 0 && node.children.length === 1 && node.firstChild.type === "text" && // \xA0: non-breaking whitespace
  16231. !/[^\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";
  16232. };
  16233. return ast.map(function (node) {
  16234. if (node.children) {
  16235. var isSimpleElementResults = node.children.map(isSimpleElement);
  16236. if (isSimpleElementResults.some(Boolean)) {
  16237. var newChildren = [];
  16238. for (var i = 0; i < node.children.length; i++) {
  16239. var child = node.children[i];
  16240. if (isSimpleElementResults[i]) {
  16241. var lastChild = newChildren.pop();
  16242. var nextChild = node.children[++i];
  16243. var ParseSourceSpan = node.sourceSpan.constructor;
  16244. var isTrailingSpaceSensitive = nextChild.isTrailingSpaceSensitive,
  16245. hasTrailingSpaces = nextChild.hasTrailingSpaces;
  16246. newChildren.push(lastChild.clone({
  16247. value: lastChild.value + "<".concat(child.rawName, ">") + child.firstChild.value + "</".concat(child.rawName, ">") + nextChild.value,
  16248. sourceSpan: new ParseSourceSpan(lastChild.sourceSpan.start, nextChild.sourceSpan.end),
  16249. isTrailingSpaceSensitive: isTrailingSpaceSensitive,
  16250. hasTrailingSpaces: hasTrailingSpaces
  16251. }));
  16252. } else {
  16253. newChildren.push(child);
  16254. }
  16255. }
  16256. return node.clone({
  16257. children: newChildren
  16258. });
  16259. }
  16260. }
  16261. return node;
  16262. });
  16263. }
  16264. function extractInterpolation(ast, options) {
  16265. if (options.parser === "html") {
  16266. return ast;
  16267. }
  16268. var interpolationRegex = /\{\{([\s\S]+?)\}\}/g;
  16269. return ast.map(function (node) {
  16270. if (!canHaveInterpolation$1(node)) {
  16271. return node;
  16272. }
  16273. var newChildren = [];
  16274. var _iteratorNormalCompletion = true;
  16275. var _didIteratorError = false;
  16276. var _iteratorError = undefined;
  16277. try {
  16278. for (var _iterator = node.children[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  16279. var child = _step.value;
  16280. if (child.type !== "text") {
  16281. newChildren.push(child);
  16282. continue;
  16283. }
  16284. var ParseSourceSpan = child.sourceSpan.constructor;
  16285. var startSourceSpan = child.sourceSpan.start;
  16286. var endSourceSpan = null;
  16287. var components = child.value.split(interpolationRegex);
  16288. for (var i = 0; i < components.length; i++, startSourceSpan = endSourceSpan) {
  16289. var value = components[i];
  16290. if (i % 2 === 0) {
  16291. endSourceSpan = startSourceSpan.moveBy(value.length);
  16292. if (value.length !== 0) {
  16293. newChildren.push({
  16294. type: "text",
  16295. value: value,
  16296. sourceSpan: new ParseSourceSpan(startSourceSpan, endSourceSpan)
  16297. });
  16298. }
  16299. continue;
  16300. }
  16301. endSourceSpan = startSourceSpan.moveBy(value.length + 4); // `{{` + `}}`
  16302. newChildren.push({
  16303. type: "interpolation",
  16304. sourceSpan: new ParseSourceSpan(startSourceSpan, endSourceSpan),
  16305. children: value.length === 0 ? [] : [{
  16306. type: "text",
  16307. value: value,
  16308. sourceSpan: new ParseSourceSpan(startSourceSpan.moveBy(2), endSourceSpan.moveBy(-2))
  16309. }]
  16310. });
  16311. }
  16312. }
  16313. } catch (err) {
  16314. _didIteratorError = true;
  16315. _iteratorError = err;
  16316. } finally {
  16317. try {
  16318. if (!_iteratorNormalCompletion && _iterator.return != null) {
  16319. _iterator.return();
  16320. }
  16321. } finally {
  16322. if (_didIteratorError) {
  16323. throw _iteratorError;
  16324. }
  16325. }
  16326. }
  16327. return node.clone({
  16328. children: newChildren
  16329. });
  16330. });
  16331. }
  16332. /**
  16333. * - add `hasLeadingSpaces` field
  16334. * - add `hasTrailingSpaces` field
  16335. * - add `hasDanglingSpaces` field for parent nodes
  16336. * - add `isWhitespaceSensitive`, `isIndentationSensitive` field for text nodes
  16337. * - remove insensitive whitespaces
  16338. */
  16339. function extractWhitespaces(ast
  16340. /*, options*/
  16341. ) {
  16342. var TYPE_WHITESPACE = "whitespace";
  16343. return ast.map(function (node) {
  16344. if (!node.children) {
  16345. return node;
  16346. }
  16347. if (node.children.length === 0 || node.children.length === 1 && node.children[0].type === "text" && node.children[0].value.trim().length === 0) {
  16348. return node.clone({
  16349. children: [],
  16350. hasDanglingSpaces: node.children.length !== 0
  16351. });
  16352. }
  16353. var isWhitespaceSensitive = isWhitespaceSensitiveNode$1(node);
  16354. var isIndentationSensitive = isIndentationSensitiveNode$1(node);
  16355. return node.clone({
  16356. isWhitespaceSensitive: isWhitespaceSensitive,
  16357. isIndentationSensitive: isIndentationSensitive,
  16358. children: node.children // extract whitespace nodes
  16359. .reduce(function (newChildren, child) {
  16360. if (child.type !== "text" || isWhitespaceSensitive) {
  16361. return newChildren.concat(child);
  16362. }
  16363. var localChildren = [];
  16364. var _child$value$match = child.value.match(/^(\s*)([\s\S]*?)(\s*)$/),
  16365. _child$value$match2 = _slicedToArray(_child$value$match, 4),
  16366. leadingSpaces = _child$value$match2[1],
  16367. text = _child$value$match2[2],
  16368. trailingSpaces = _child$value$match2[3];
  16369. if (leadingSpaces) {
  16370. localChildren.push({
  16371. type: TYPE_WHITESPACE
  16372. });
  16373. }
  16374. var ParseSourceSpan = child.sourceSpan.constructor;
  16375. if (text) {
  16376. localChildren.push({
  16377. type: "text",
  16378. value: text,
  16379. sourceSpan: new ParseSourceSpan(child.sourceSpan.start.moveBy(leadingSpaces.length), child.sourceSpan.end.moveBy(-trailingSpaces.length))
  16380. });
  16381. }
  16382. if (trailingSpaces) {
  16383. localChildren.push({
  16384. type: TYPE_WHITESPACE
  16385. });
  16386. }
  16387. return newChildren.concat(localChildren);
  16388. }, []) // set hasLeadingSpaces/hasTrailingSpaces and filter whitespace nodes
  16389. .reduce(function (newChildren, child, i, children) {
  16390. if (child.type === TYPE_WHITESPACE) {
  16391. return newChildren;
  16392. }
  16393. var hasLeadingSpaces = i !== 0 && children[i - 1].type === TYPE_WHITESPACE;
  16394. var hasTrailingSpaces = i !== children.length - 1 && children[i + 1].type === TYPE_WHITESPACE;
  16395. return newChildren.concat(Object.assign({}, child, {
  16396. hasLeadingSpaces: hasLeadingSpaces,
  16397. hasTrailingSpaces: hasTrailingSpaces
  16398. }));
  16399. }, [])
  16400. });
  16401. });
  16402. }
  16403. function addIsSelfClosing(ast
  16404. /*, options */
  16405. ) {
  16406. return ast.map(function (node) {
  16407. return Object.assign(node, {
  16408. isSelfClosing: !node.children || node.type === "element" && (node.tagDefinition.isVoid || // self-closing
  16409. node.startSourceSpan === node.endSourceSpan)
  16410. });
  16411. });
  16412. }
  16413. function addHasHtmComponentClosingTag(ast, options) {
  16414. return ast.map(function (node) {
  16415. return node.type !== "element" ? node : Object.assign(node, {
  16416. hasHtmComponentClosingTag: node.endSourceSpan && /^<\s*\/\s*\/\s*>$/.test(options.originalText.slice(node.endSourceSpan.start.offset, node.endSourceSpan.end.offset))
  16417. });
  16418. });
  16419. }
  16420. function addCssDisplay(ast, options) {
  16421. return ast.map(function (node) {
  16422. return Object.assign(node, {
  16423. cssDisplay: getNodeCssStyleDisplay$1(node, options)
  16424. });
  16425. });
  16426. }
  16427. /**
  16428. * - add `isLeadingSpaceSensitive` field
  16429. * - add `isTrailingSpaceSensitive` field
  16430. * - add `isDanglingSpaceSensitive` field for parent nodes
  16431. */
  16432. function addIsSpaceSensitive(ast
  16433. /*, options */
  16434. ) {
  16435. return ast.map(function (node) {
  16436. if (!node.children) {
  16437. return node;
  16438. }
  16439. if (node.children.length === 0) {
  16440. return node.clone({
  16441. isDanglingSpaceSensitive: isDanglingSpaceSensitiveNode$1(node)
  16442. });
  16443. }
  16444. return node.clone({
  16445. children: node.children.map(function (child) {
  16446. return Object.assign({}, child, {
  16447. isLeadingSpaceSensitive: isLeadingSpaceSensitiveNode$1(child),
  16448. isTrailingSpaceSensitive: isTrailingSpaceSensitiveNode$1(child)
  16449. });
  16450. }).map(function (child, index, children) {
  16451. return Object.assign({}, child, {
  16452. isLeadingSpaceSensitive: index === 0 ? child.isLeadingSpaceSensitive : children[index - 1].isTrailingSpaceSensitive && child.isLeadingSpaceSensitive,
  16453. isTrailingSpaceSensitive: index === children.length - 1 ? child.isTrailingSpaceSensitive : children[index + 1].isLeadingSpaceSensitive && child.isTrailingSpaceSensitive
  16454. });
  16455. })
  16456. });
  16457. });
  16458. }
  16459. var preprocess_1 = preprocess;
  16460. function hasPragma$3(text) {
  16461. return /^\s*<!--\s*@(format|prettier)\s*-->/.test(text);
  16462. }
  16463. function insertPragma$6(text) {
  16464. return "<!-- @format -->\n\n" + text.replace(/^\s*\n/, "");
  16465. }
  16466. var pragma$6 = {
  16467. hasPragma: hasPragma$3,
  16468. insertPragma: insertPragma$6
  16469. };
  16470. var _require$$0$builders$4 = doc.builders;
  16471. var concat$9 = _require$$0$builders$4.concat;
  16472. var group$9 = _require$$0$builders$4.group;
  16473. /**
  16474. * v-for="... in ..."
  16475. * v-for="... of ..."
  16476. * v-for="(..., ...) in ..."
  16477. * v-for="(..., ...) of ..."
  16478. */
  16479. function printVueFor$1(value, textToDoc) {
  16480. var _parseVueFor = parseVueFor(value),
  16481. left = _parseVueFor.left,
  16482. operator = _parseVueFor.operator,
  16483. right = _parseVueFor.right;
  16484. return concat$9([group$9(textToDoc("function _(".concat(left, ") {}"), {
  16485. parser: "babel",
  16486. __isVueForBindingLeft: true
  16487. })), " ", operator, " ", textToDoc(right, {
  16488. parser: "__js_expression"
  16489. })]);
  16490. } // modified from https://github.com/vuejs/vue/blob/v2.5.17/src/compiler/parser/index.js#L370-L387
  16491. function parseVueFor(value) {
  16492. var forAliasRE = /([^]*?)\s+(in|of)\s+([^]*)/;
  16493. var forIteratorRE = /,([^,}\]]*)(?:,([^,}\]]*))?$/;
  16494. var stripParensRE = /^\(|\)$/g;
  16495. var inMatch = value.match(forAliasRE);
  16496. if (!inMatch) {
  16497. return;
  16498. }
  16499. var res = {};
  16500. res.for = inMatch[3].trim();
  16501. var alias = inMatch[1].trim().replace(stripParensRE, "");
  16502. var iteratorMatch = alias.match(forIteratorRE);
  16503. if (iteratorMatch) {
  16504. res.alias = alias.replace(forIteratorRE, "");
  16505. res.iterator1 = iteratorMatch[1].trim();
  16506. if (iteratorMatch[2]) {
  16507. res.iterator2 = iteratorMatch[2].trim();
  16508. }
  16509. } else {
  16510. res.alias = alias;
  16511. }
  16512. return {
  16513. left: "".concat([res.alias, res.iterator1, res.iterator2].filter(Boolean).join(",")),
  16514. operator: inMatch[2],
  16515. right: res.for
  16516. };
  16517. }
  16518. function printVueSlotScope$1(value, textToDoc) {
  16519. return textToDoc("function _(".concat(value, ") {}"), {
  16520. parser: "babel",
  16521. __isVueSlotScope: true
  16522. });
  16523. }
  16524. function isVueEventBindingExpression$1(eventBindingValue) {
  16525. // https://github.com/vuejs/vue/blob/v2.5.17/src/compiler/codegen/events.js#L3-L4
  16526. // arrow function or anonymous function
  16527. var fnExpRE = /^([\w$_]+|\([^)]*?\))\s*=>|^function\s*\(/; // simple member expression chain (a, a.b, a['b'], a["b"], a[0], a[b])
  16528. 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
  16529. var value = eventBindingValue.trim();
  16530. return fnExpRE.test(value) || simplePathRE.test(value);
  16531. }
  16532. var syntaxVue = {
  16533. isVueEventBindingExpression: isVueEventBindingExpression$1,
  16534. printVueFor: printVueFor$1,
  16535. printVueSlotScope: printVueSlotScope$1
  16536. };
  16537. var parseSrcset = createCommonjsModule(function (module) {
  16538. /**
  16539. * Srcset Parser
  16540. *
  16541. * By Alex Bell | MIT License
  16542. *
  16543. * JS Parser for the string value that appears in markup <img srcset="here">
  16544. *
  16545. * @returns Array [{url: _, d: _, w: _, h:_}, ...]
  16546. *
  16547. * Based super duper closely on the reference algorithm at:
  16548. * https://html.spec.whatwg.org/multipage/embedded-content.html#parse-a-srcset-attribute
  16549. *
  16550. * Most comments are copied in directly from the spec
  16551. * (except for comments in parens).
  16552. */
  16553. (function (root, factory) {
  16554. if (typeof undefined === 'function' && undefined.amd) {
  16555. // AMD. Register as an anonymous module.
  16556. undefined([], factory);
  16557. } else if ('object' === 'object' && module.exports) {
  16558. // Node. Does not work with strict CommonJS, but
  16559. // only CommonJS-like environments that support module.exports,
  16560. // like Node.
  16561. module.exports = factory();
  16562. } else {
  16563. // Browser globals (root is window)
  16564. root.parseSrcset = factory();
  16565. }
  16566. })(commonjsGlobal, function () {
  16567. // 1. Let input be the value passed to this algorithm.
  16568. return function (input, options) {
  16569. var logger = options && options.logger || console; // UTILITY FUNCTIONS
  16570. // Manual is faster than RegEx
  16571. // http://bjorn.tipling.com/state-and-regular-expressions-in-javascript
  16572. // http://jsperf.com/whitespace-character/5
  16573. function isSpace(c) {
  16574. return c === " " || // space
  16575. c === "\t" || // horizontal tab
  16576. c === "\n" || // new line
  16577. c === "\f" || // form feed
  16578. c === "\r"; // carriage return
  16579. }
  16580. function collectCharacters(regEx) {
  16581. var chars,
  16582. match = regEx.exec(input.substring(pos));
  16583. if (match) {
  16584. chars = match[0];
  16585. pos += chars.length;
  16586. return chars;
  16587. }
  16588. }
  16589. var inputLength = input.length,
  16590. // (Don't use \s, to avoid matching non-breaking space)
  16591. regexLeadingSpaces = /^[ \t\n\r\u000c]+/,
  16592. regexLeadingCommasOrSpaces = /^[, \t\n\r\u000c]+/,
  16593. regexLeadingNotSpaces = /^[^ \t\n\r\u000c]+/,
  16594. regexTrailingCommas = /[,]+$/,
  16595. regexNonNegativeInteger = /^\d+$/,
  16596. // ( Positive or negative or unsigned integers or decimals, without or without exponents.
  16597. // Must include at least one digit.
  16598. // According to spec tests any decimal point must be followed by a digit.
  16599. // No leading plus sign is allowed.)
  16600. // https://html.spec.whatwg.org/multipage/infrastructure.html#valid-floating-point-number
  16601. regexFloatingPoint = /^-?(?:[0-9]+|[0-9]*\.[0-9]+)(?:[eE][+-]?[0-9]+)?$/,
  16602. url,
  16603. descriptors,
  16604. currentDescriptor,
  16605. state,
  16606. c,
  16607. // 2. Let position be a pointer into input, initially pointing at the start
  16608. // of the string.
  16609. pos = 0,
  16610. // 3. Let candidates be an initially empty source set.
  16611. candidates = []; // 4. Splitting loop: Collect a sequence of characters that are space
  16612. // characters or U+002C COMMA characters. If any U+002C COMMA characters
  16613. // were collected, that is a parse error.
  16614. while (true) {
  16615. collectCharacters(regexLeadingCommasOrSpaces); // 5. If position is past the end of input, return candidates and abort these steps.
  16616. if (pos >= inputLength) {
  16617. return candidates; // (we're done, this is the sole return path)
  16618. } // 6. Collect a sequence of characters that are not space characters,
  16619. // and let that be url.
  16620. url = collectCharacters(regexLeadingNotSpaces); // 7. Let descriptors be a new empty list.
  16621. descriptors = []; // 8. If url ends with a U+002C COMMA character (,), follow these substeps:
  16622. // (1). Remove all trailing U+002C COMMA characters from url. If this removed
  16623. // more than one character, that is a parse error.
  16624. if (url.slice(-1) === ",") {
  16625. url = url.replace(regexTrailingCommas, ""); // (Jump ahead to step 9 to skip tokenization and just push the candidate).
  16626. parseDescriptors(); // Otherwise, follow these substeps:
  16627. } else {
  16628. tokenize();
  16629. } // (close else of step 8)
  16630. // 16. Return to the step labeled splitting loop.
  16631. } // (Close of big while loop.)
  16632. /**
  16633. * Tokenizes descriptor properties prior to parsing
  16634. * Returns undefined.
  16635. */
  16636. function tokenize() {
  16637. // 8.1. Descriptor tokeniser: Skip whitespace
  16638. collectCharacters(regexLeadingSpaces); // 8.2. Let current descriptor be the empty string.
  16639. currentDescriptor = ""; // 8.3. Let state be in descriptor.
  16640. state = "in descriptor";
  16641. while (true) {
  16642. // 8.4. Let c be the character at position.
  16643. c = input.charAt(pos); // Do the following depending on the value of state.
  16644. // For the purpose of this step, "EOF" is a special character representing
  16645. // that position is past the end of input.
  16646. // In descriptor
  16647. if (state === "in descriptor") {
  16648. // Do the following, depending on the value of c:
  16649. // Space character
  16650. // If current descriptor is not empty, append current descriptor to
  16651. // descriptors and let current descriptor be the empty string.
  16652. // Set state to after descriptor.
  16653. if (isSpace(c)) {
  16654. if (currentDescriptor) {
  16655. descriptors.push(currentDescriptor);
  16656. currentDescriptor = "";
  16657. state = "after descriptor";
  16658. } // U+002C COMMA (,)
  16659. // Advance position to the next character in input. If current descriptor
  16660. // is not empty, append current descriptor to descriptors. Jump to the step
  16661. // labeled descriptor parser.
  16662. } else if (c === ",") {
  16663. pos += 1;
  16664. if (currentDescriptor) {
  16665. descriptors.push(currentDescriptor);
  16666. }
  16667. parseDescriptors();
  16668. return; // U+0028 LEFT PARENTHESIS (()
  16669. // Append c to current descriptor. Set state to in parens.
  16670. } else if (c === "(") {
  16671. currentDescriptor = currentDescriptor + c;
  16672. state = "in parens"; // EOF
  16673. // If current descriptor is not empty, append current descriptor to
  16674. // descriptors. Jump to the step labeled descriptor parser.
  16675. } else if (c === "") {
  16676. if (currentDescriptor) {
  16677. descriptors.push(currentDescriptor);
  16678. }
  16679. parseDescriptors();
  16680. return; // Anything else
  16681. // Append c to current descriptor.
  16682. } else {
  16683. currentDescriptor = currentDescriptor + c;
  16684. } // (end "in descriptor"
  16685. // In parens
  16686. } else if (state === "in parens") {
  16687. // U+0029 RIGHT PARENTHESIS ())
  16688. // Append c to current descriptor. Set state to in descriptor.
  16689. if (c === ")") {
  16690. currentDescriptor = currentDescriptor + c;
  16691. state = "in descriptor"; // EOF
  16692. // Append current descriptor to descriptors. Jump to the step labeled
  16693. // descriptor parser.
  16694. } else if (c === "") {
  16695. descriptors.push(currentDescriptor);
  16696. parseDescriptors();
  16697. return; // Anything else
  16698. // Append c to current descriptor.
  16699. } else {
  16700. currentDescriptor = currentDescriptor + c;
  16701. } // After descriptor
  16702. } else if (state === "after descriptor") {
  16703. // Do the following, depending on the value of c:
  16704. // Space character: Stay in this state.
  16705. if (isSpace(c)) {// EOF: Jump to the step labeled descriptor parser.
  16706. } else if (c === "") {
  16707. parseDescriptors();
  16708. return; // Anything else
  16709. // Set state to in descriptor. Set position to the previous character in input.
  16710. } else {
  16711. state = "in descriptor";
  16712. pos -= 1;
  16713. }
  16714. } // Advance position to the next character in input.
  16715. pos += 1; // Repeat this step.
  16716. } // (close while true loop)
  16717. }
  16718. /**
  16719. * Adds descriptor properties to a candidate, pushes to the candidates array
  16720. * @return undefined
  16721. */
  16722. // Declared outside of the while loop so that it's only created once.
  16723. function parseDescriptors() {
  16724. // 9. Descriptor parser: Let error be no.
  16725. var pError = false,
  16726. // 10. Let width be absent.
  16727. // 11. Let density be absent.
  16728. // 12. Let future-compat-h be absent. (We're implementing it now as h)
  16729. w,
  16730. d,
  16731. h,
  16732. i,
  16733. candidate = {},
  16734. desc,
  16735. lastChar,
  16736. value,
  16737. intVal,
  16738. floatVal; // 13. For each descriptor in descriptors, run the appropriate set of steps
  16739. // from the following list:
  16740. for (i = 0; i < descriptors.length; i++) {
  16741. desc = descriptors[i];
  16742. lastChar = desc[desc.length - 1];
  16743. value = desc.substring(0, desc.length - 1);
  16744. intVal = parseInt(value, 10);
  16745. floatVal = parseFloat(value); // If the descriptor consists of a valid non-negative integer followed by
  16746. // a U+0077 LATIN SMALL LETTER W character
  16747. if (regexNonNegativeInteger.test(value) && lastChar === "w") {
  16748. // If width and density are not both absent, then let error be yes.
  16749. if (w || d) {
  16750. pError = true;
  16751. } // Apply the rules for parsing non-negative integers to the descriptor.
  16752. // If the result is zero, let error be yes.
  16753. // Otherwise, let width be the result.
  16754. if (intVal === 0) {
  16755. pError = true;
  16756. } else {
  16757. w = intVal;
  16758. } // If the descriptor consists of a valid floating-point number followed by
  16759. // a U+0078 LATIN SMALL LETTER X character
  16760. } else if (regexFloatingPoint.test(value) && lastChar === "x") {
  16761. // If width, density and future-compat-h are not all absent, then let error
  16762. // be yes.
  16763. if (w || d || h) {
  16764. pError = true;
  16765. } // Apply the rules for parsing floating-point number values to the descriptor.
  16766. // If the result is less than zero, let error be yes. Otherwise, let density
  16767. // be the result.
  16768. if (floatVal < 0) {
  16769. pError = true;
  16770. } else {
  16771. d = floatVal;
  16772. } // If the descriptor consists of a valid non-negative integer followed by
  16773. // a U+0068 LATIN SMALL LETTER H character
  16774. } else if (regexNonNegativeInteger.test(value) && lastChar === "h") {
  16775. // If height and density are not both absent, then let error be yes.
  16776. if (h || d) {
  16777. pError = true;
  16778. } // Apply the rules for parsing non-negative integers to the descriptor.
  16779. // If the result is zero, let error be yes. Otherwise, let future-compat-h
  16780. // be the result.
  16781. if (intVal === 0) {
  16782. pError = true;
  16783. } else {
  16784. h = intVal;
  16785. } // Anything else, Let error be yes.
  16786. } else {
  16787. pError = true;
  16788. }
  16789. } // (close step 13 for loop)
  16790. // 15. If error is still no, then append a new image source to candidates whose
  16791. // URL is url, associated with a width width if not absent and a pixel
  16792. // density density if not absent. Otherwise, there is a parse error.
  16793. if (!pError) {
  16794. candidate.url = url;
  16795. if (w) {
  16796. candidate.w = w;
  16797. }
  16798. if (d) {
  16799. candidate.d = d;
  16800. }
  16801. if (h) {
  16802. candidate.h = h;
  16803. }
  16804. candidates.push(candidate);
  16805. } else if (logger && logger.error) {
  16806. logger.error("Invalid srcset descriptor found in '" + input + "' at '" + desc + "'.");
  16807. }
  16808. } // (close parseDescriptors fn)
  16809. };
  16810. });
  16811. });
  16812. var _require$$0$builders$5 = doc.builders;
  16813. var concat$10 = _require$$0$builders$5.concat;
  16814. var ifBreak$5 = _require$$0$builders$5.ifBreak;
  16815. var join$6 = _require$$0$builders$5.join;
  16816. var line$7 = _require$$0$builders$5.line;
  16817. function printImgSrcset$1(value) {
  16818. var srcset = parseSrcset(value, {
  16819. logger: {
  16820. error: function error(message) {
  16821. throw new Error(message);
  16822. }
  16823. }
  16824. });
  16825. var hasW = srcset.some(function (src) {
  16826. return src.w;
  16827. });
  16828. var hasH = srcset.some(function (src) {
  16829. return src.h;
  16830. });
  16831. var hasX = srcset.some(function (src) {
  16832. return src.d;
  16833. });
  16834. if (hasW + hasH + hasX !== 1) {
  16835. throw new Error("Mixed descriptor in srcset is not supported");
  16836. }
  16837. var key = hasW ? "w" : hasH ? "h" : "d";
  16838. var unit = hasW ? "w" : hasH ? "h" : "x";
  16839. var getMax = function getMax(values) {
  16840. return Math.max.apply(Math, values);
  16841. };
  16842. var urls = srcset.map(function (src) {
  16843. return src.url;
  16844. });
  16845. var maxUrlLength = getMax(urls.map(function (url) {
  16846. return url.length;
  16847. }));
  16848. var descriptors = srcset.map(function (src) {
  16849. return src[key];
  16850. }).map(function (descriptor) {
  16851. return descriptor ? descriptor.toString() : "";
  16852. });
  16853. var descriptorLeftLengths = descriptors.map(function (descriptor) {
  16854. var index = descriptor.indexOf(".");
  16855. return index === -1 ? descriptor.length : index;
  16856. });
  16857. var maxDescriptorLeftLength = getMax(descriptorLeftLengths);
  16858. return join$6(concat$10([",", line$7]), urls.map(function (url, index) {
  16859. var parts = [url];
  16860. var descriptor = descriptors[index];
  16861. if (descriptor) {
  16862. var urlPadding = maxUrlLength - url.length + 1;
  16863. var descriptorPadding = maxDescriptorLeftLength - descriptorLeftLengths[index];
  16864. var alignment = " ".repeat(urlPadding + descriptorPadding);
  16865. parts.push(ifBreak$5(alignment, " "), descriptor + unit);
  16866. }
  16867. return concat$10(parts);
  16868. }));
  16869. }
  16870. var syntaxAttribute = {
  16871. printImgSrcset: printImgSrcset$1
  16872. };
  16873. var builders = doc.builders;
  16874. var _require$$0$utils = doc.utils;
  16875. var stripTrailingHardline$1 = _require$$0$utils.stripTrailingHardline;
  16876. var mapDoc$4 = _require$$0$utils.mapDoc;
  16877. var breakParent$2 = builders.breakParent;
  16878. var dedentToRoot$1 = builders.dedentToRoot;
  16879. var fill$3 = builders.fill;
  16880. var group$8 = builders.group;
  16881. var hardline$7 = builders.hardline;
  16882. var ifBreak$4 = builders.ifBreak;
  16883. var indent$5 = builders.indent;
  16884. var join$5 = builders.join;
  16885. var line$6 = builders.line;
  16886. var literalline$2 = builders.literalline;
  16887. var markAsRoot$2 = builders.markAsRoot;
  16888. var softline$4 = builders.softline;
  16889. var countChars = utils$6.countChars;
  16890. var countParents = utils$6.countParents;
  16891. var dedentString = utils$6.dedentString;
  16892. var forceBreakChildren = utils$6.forceBreakChildren;
  16893. var forceBreakContent = utils$6.forceBreakContent;
  16894. var forceNextEmptyLine = utils$6.forceNextEmptyLine;
  16895. var getLastDescendant = utils$6.getLastDescendant;
  16896. var getPrettierIgnoreAttributeCommentData = utils$6.getPrettierIgnoreAttributeCommentData;
  16897. var hasPrettierIgnore = utils$6.hasPrettierIgnore;
  16898. var inferScriptParser = utils$6.inferScriptParser;
  16899. var isScriptLikeTag = utils$6.isScriptLikeTag;
  16900. var isTextLikeNode = utils$6.isTextLikeNode;
  16901. var normalizeParts = utils$6.normalizeParts;
  16902. var preferHardlineAsLeadingSpaces = utils$6.preferHardlineAsLeadingSpaces;
  16903. var shouldNotPrintClosingTag = utils$6.shouldNotPrintClosingTag;
  16904. var shouldPreserveContent = utils$6.shouldPreserveContent;
  16905. var unescapeQuoteEntities = utils$6.unescapeQuoteEntities;
  16906. var replaceEndOfLineWith$1 = util.replaceEndOfLineWith;
  16907. var insertPragma$5 = pragma$6.insertPragma;
  16908. var printVueFor = syntaxVue.printVueFor;
  16909. var printVueSlotScope = syntaxVue.printVueSlotScope;
  16910. var isVueEventBindingExpression = syntaxVue.isVueEventBindingExpression;
  16911. var printImgSrcset = syntaxAttribute.printImgSrcset;
  16912. function concat$8(parts) {
  16913. var newParts = normalizeParts(parts);
  16914. return newParts.length === 0 ? "" : newParts.length === 1 ? newParts[0] : builders.concat(newParts);
  16915. }
  16916. function embed$2(path, print, textToDoc, options) {
  16917. var node = path.getValue();
  16918. switch (node.type) {
  16919. case "text":
  16920. {
  16921. if (isScriptLikeTag(node.parent)) {
  16922. var parser = inferScriptParser(node.parent);
  16923. if (parser) {
  16924. var value = parser === "markdown" ? dedentString(node.value.replace(/^[^\S\n]*?\n/, "")) : node.value;
  16925. return builders.concat([concat$8([breakParent$2, printOpeningTagPrefix(node, options), stripTrailingHardline$1(textToDoc(value, {
  16926. parser: parser
  16927. })), printClosingTagSuffix(node, options)])]);
  16928. }
  16929. } else if (node.parent.type === "interpolation") {
  16930. return concat$8([indent$5(concat$8([line$6, textToDoc(node.value, Object.assign({
  16931. __isInHtmlInterpolation: true // to avoid unexpected `}}`
  16932. }, options.parser === "angular" ? {
  16933. parser: "__ng_interpolation",
  16934. trailingComma: "none"
  16935. } : options.parser === "vue" ? {
  16936. parser: "__vue_expression"
  16937. } : {
  16938. parser: "__js_expression"
  16939. }))])), node.parent.next && needsToBorrowPrevClosingTagEndMarker(node.parent.next) ? " " : line$6]);
  16940. }
  16941. break;
  16942. }
  16943. case "attribute":
  16944. {
  16945. if (!node.value) {
  16946. break;
  16947. } // lit-html: html`<my-element obj=${obj}></my-element>`
  16948. if (/^PRETTIER_HTML_PLACEHOLDER_\d+_\d+_IN_JS$/.test(options.originalText.slice(node.valueSpan.start.offset, node.valueSpan.end.offset))) {
  16949. return concat$8([node.rawName, "=", node.value]);
  16950. } // lwc: html`<my-element data-for={value}></my-elememt>`
  16951. if (options.parser === "lwc") {
  16952. var interpolationRegex = /^\{[\s\S]*\}$/;
  16953. if (interpolationRegex.test(options.originalText.slice(node.valueSpan.start.offset, node.valueSpan.end.offset))) {
  16954. return concat$8([node.rawName, "=", node.value]);
  16955. }
  16956. }
  16957. var embeddedAttributeValueDoc = printEmbeddedAttributeValue(node, function (code, opts) {
  16958. return (// strictly prefer single quote to avoid unnecessary html entity escape
  16959. textToDoc(code, Object.assign({
  16960. __isInHtmlAttribute: true
  16961. }, opts))
  16962. );
  16963. }, options);
  16964. if (embeddedAttributeValueDoc) {
  16965. return concat$8([node.rawName, '="', group$8(mapDoc$4(embeddedAttributeValueDoc, function (doc$$2) {
  16966. return typeof doc$$2 === "string" ? doc$$2.replace(/"/g, "&quot;") : doc$$2;
  16967. })), '"']);
  16968. }
  16969. break;
  16970. }
  16971. case "yaml":
  16972. return markAsRoot$2(concat$8(["---", hardline$7, node.value.trim().length === 0 ? "" : textToDoc(node.value, {
  16973. parser: "yaml"
  16974. }), "---"]));
  16975. }
  16976. }
  16977. function genericPrint$2(path, options, print) {
  16978. var node = path.getValue();
  16979. switch (node.type) {
  16980. case "root":
  16981. // use original concat to not break stripTrailingHardline
  16982. return builders.concat([group$8(printChildren(path, options, print)), hardline$7]);
  16983. case "element":
  16984. case "ieConditionalComment":
  16985. {
  16986. /**
  16987. * do not break:
  16988. *
  16989. * <div>{{
  16990. * ~
  16991. * interpolation
  16992. * }}</div>
  16993. * ~
  16994. *
  16995. * exception: break if the opening tag breaks
  16996. *
  16997. * <div
  16998. * long
  16999. * ~
  17000. * >{{
  17001. * interpolation
  17002. * }}</div
  17003. * ~
  17004. * >
  17005. */
  17006. var shouldHugContent = node.children.length === 1 && node.firstChild.type === "interpolation" && node.firstChild.isLeadingSpaceSensitive && !node.firstChild.hasLeadingSpaces && node.lastChild.isTrailingSpaceSensitive && !node.lastChild.hasTrailingSpaces;
  17007. var attrGroupId = Symbol("element-attr-group-id");
  17008. return concat$8([group$8(concat$8([group$8(printOpeningTag(path, options, print), {
  17009. id: attrGroupId
  17010. }), node.children.length === 0 ? node.hasDanglingSpaces && node.isDanglingSpaceSensitive ? line$6 : "" : concat$8([forceBreakContent(node) ? breakParent$2 : "", function (childrenDoc) {
  17011. return shouldHugContent ? ifBreak$4(indent$5(childrenDoc), childrenDoc, {
  17012. groupId: attrGroupId
  17013. }) : isScriptLikeTag(node) && node.parent.type === "root" && options.parser === "vue" ? childrenDoc : indent$5(childrenDoc);
  17014. }(concat$8([shouldHugContent ? ifBreak$4(softline$4, "", {
  17015. groupId: attrGroupId
  17016. }) : 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, "", {
  17017. groupId: attrGroupId
  17018. }) : 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) {
  17019. return n.parent && n.parent.type !== "root";
  17020. }), "}$")).test(node.lastChild.value) ?
  17021. /**
  17022. * <div>
  17023. * <pre>
  17024. * something
  17025. * </pre>
  17026. * ~
  17027. * </div>
  17028. */
  17029. "" : softline$4])])), printClosingTag(node, options)]);
  17030. }
  17031. case "ieConditionalStartComment":
  17032. case "ieConditionalEndComment":
  17033. return concat$8([printOpeningTagStart(node), printClosingTagEnd(node)]);
  17034. case "interpolation":
  17035. return concat$8([printOpeningTagStart(node, options), concat$8(path.map(print, "children")), printClosingTagEnd(node, options)]);
  17036. case "text":
  17037. {
  17038. if (node.parent.type === "interpolation") {
  17039. // replace the trailing literalline with hardline for better readability
  17040. var trailingNewlineRegex = /\n[^\S\n]*?$/;
  17041. var hasTrailingNewline = trailingNewlineRegex.test(node.value);
  17042. var value = hasTrailingNewline ? node.value.replace(trailingNewlineRegex, "") : node.value;
  17043. return concat$8([concat$8(replaceEndOfLineWith$1(value, literalline$2)), hasTrailingNewline ? hardline$7 : ""]);
  17044. }
  17045. return fill$3(normalizeParts([].concat(printOpeningTagPrefix(node, options), getTextValueParts(node), printClosingTagSuffix(node, options))));
  17046. }
  17047. case "docType":
  17048. return concat$8([group$8(concat$8([printOpeningTagStart(node, options), " ", node.value.replace(/^html\b/i, "html").replace(/\s+/g, " ")])), printClosingTagEnd(node, options)]);
  17049. case "comment":
  17050. {
  17051. return concat$8([printOpeningTagPrefix(node, options), concat$8(replaceEndOfLineWith$1(options.originalText.slice(options.locStart(node), options.locEnd(node)), literalline$2)), printClosingTagSuffix(node, options)]);
  17052. }
  17053. case "attribute":
  17054. {
  17055. if (node.value === null) {
  17056. return node.rawName;
  17057. }
  17058. var _value = unescapeQuoteEntities(node.value);
  17059. var singleQuoteCount = countChars(_value, "'");
  17060. var doubleQuoteCount = countChars(_value, '"');
  17061. var quote = singleQuoteCount < doubleQuoteCount ? "'" : '"';
  17062. return concat$8([node.rawName, concat$8(["=", quote, concat$8(replaceEndOfLineWith$1(quote === '"' ? _value.replace(/"/g, "&quot;") : _value.replace(/'/g, "&apos;"), literalline$2)), quote])]);
  17063. }
  17064. case "yaml":
  17065. case "toml":
  17066. return concat$8(replaceEndOfLineWith$1(node.raw, literalline$2));
  17067. default:
  17068. throw new Error("Unexpected node type ".concat(node.type));
  17069. }
  17070. }
  17071. function printChildren(path, options, print) {
  17072. var node = path.getValue();
  17073. if (forceBreakChildren(node)) {
  17074. return concat$8([breakParent$2, concat$8(path.map(function (childPath) {
  17075. var childNode = childPath.getValue();
  17076. var prevBetweenLine = !childNode.prev ? "" : printBetweenLine(childNode.prev, childNode);
  17077. return concat$8([!prevBetweenLine ? "" : concat$8([prevBetweenLine, forceNextEmptyLine(childNode.prev) ? hardline$7 : ""]), printChild(childPath)]);
  17078. }, "children"))]);
  17079. }
  17080. var groupIds = node.children.map(function () {
  17081. return Symbol("");
  17082. });
  17083. return concat$8(path.map(function (childPath, childIndex) {
  17084. var childNode = childPath.getValue();
  17085. if (isTextLikeNode(childNode)) {
  17086. if (childNode.prev && isTextLikeNode(childNode.prev)) {
  17087. var _prevBetweenLine = printBetweenLine(childNode.prev, childNode);
  17088. if (_prevBetweenLine) {
  17089. if (forceNextEmptyLine(childNode.prev)) {
  17090. return concat$8([hardline$7, hardline$7, printChild(childPath)]);
  17091. }
  17092. return concat$8([_prevBetweenLine, printChild(childPath)]);
  17093. }
  17094. }
  17095. return printChild(childPath);
  17096. }
  17097. var prevParts = [];
  17098. var leadingParts = [];
  17099. var trailingParts = [];
  17100. var nextParts = [];
  17101. var prevBetweenLine = childNode.prev ? printBetweenLine(childNode.prev, childNode) : "";
  17102. var nextBetweenLine = childNode.next ? printBetweenLine(childNode, childNode.next) : "";
  17103. if (prevBetweenLine) {
  17104. if (forceNextEmptyLine(childNode.prev)) {
  17105. prevParts.push(hardline$7, hardline$7);
  17106. } else if (prevBetweenLine === hardline$7) {
  17107. prevParts.push(hardline$7);
  17108. } else {
  17109. if (isTextLikeNode(childNode.prev)) {
  17110. leadingParts.push(prevBetweenLine);
  17111. } else {
  17112. leadingParts.push(ifBreak$4("", softline$4, {
  17113. groupId: groupIds[childIndex - 1]
  17114. }));
  17115. }
  17116. }
  17117. }
  17118. if (nextBetweenLine) {
  17119. if (forceNextEmptyLine(childNode)) {
  17120. if (isTextLikeNode(childNode.next)) {
  17121. nextParts.push(hardline$7, hardline$7);
  17122. }
  17123. } else if (nextBetweenLine === hardline$7) {
  17124. if (isTextLikeNode(childNode.next)) {
  17125. nextParts.push(hardline$7);
  17126. }
  17127. } else {
  17128. trailingParts.push(nextBetweenLine);
  17129. }
  17130. }
  17131. return concat$8([].concat(prevParts, group$8(concat$8([concat$8(leadingParts), group$8(concat$8([printChild(childPath), concat$8(trailingParts)]), {
  17132. id: groupIds[childIndex]
  17133. })])), nextParts));
  17134. }, "children"));
  17135. function printChild(childPath) {
  17136. var child = childPath.getValue();
  17137. if (hasPrettierIgnore(child)) {
  17138. 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)));
  17139. }
  17140. if (shouldPreserveContent(child, options)) {
  17141. 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)));
  17142. }
  17143. return print(childPath);
  17144. }
  17145. function printBetweenLine(prevNode, nextNode) {
  17146. return isTextLikeNode(prevNode) && isTextLikeNode(nextNode) ? prevNode.isTrailingSpaceSensitive ? prevNode.hasTrailingSpaces ? preferHardlineAsLeadingSpaces(nextNode) ? hardline$7 : line$6 : "" : preferHardlineAsLeadingSpaces(nextNode) ? hardline$7 : softline$4 : needsToBorrowNextOpeningTagStartMarker(prevNode) && (
  17147. /**
  17148. * 123<a
  17149. * ~
  17150. * ><b>
  17151. */
  17152. nextNode.firstChild ||
  17153. /**
  17154. * 123<!--
  17155. * ~
  17156. * -->
  17157. */
  17158. nextNode.isSelfClosing ||
  17159. /**
  17160. * 123<span
  17161. * ~
  17162. * attr
  17163. */
  17164. nextNode.type === "element" && nextNode.attrs.length !== 0) ||
  17165. /**
  17166. * <img
  17167. * src="long"
  17168. * ~
  17169. * />123
  17170. */
  17171. prevNode.type === "element" && prevNode.isSelfClosing && needsToBorrowPrevClosingTagEndMarker(nextNode) ? "" : !nextNode.isLeadingSpaceSensitive || preferHardlineAsLeadingSpaces(nextNode) ||
  17172. /**
  17173. * Want to write us a letter? Use our<a
  17174. * ><b><a>mailing address</a></b></a
  17175. * ~
  17176. * >.
  17177. */
  17178. needsToBorrowPrevClosingTagEndMarker(nextNode) && prevNode.lastChild && needsToBorrowParentClosingTagStartMarker(prevNode.lastChild) && prevNode.lastChild.lastChild && needsToBorrowParentClosingTagStartMarker(prevNode.lastChild.lastChild) ? hardline$7 : nextNode.hasLeadingSpaces ? line$6 : softline$4;
  17179. }
  17180. }
  17181. function printOpeningTag(path, options, print) {
  17182. var node = path.getValue();
  17183. var forceNotToBreakAttrContent = node.type === "element" && node.fullName === "script" && node.attrs.length === 1 && node.attrs[0].fullName === "src" && node.children.length === 0;
  17184. return concat$8([printOpeningTagStart(node, options), !node.attrs || node.attrs.length === 0 ? node.isSelfClosing ?
  17185. /**
  17186. * <br />
  17187. * ^
  17188. */
  17189. " " : "" : concat$8([indent$5(concat$8([forceNotToBreakAttrContent ? " " : line$6, join$5(line$6, function (ignoreAttributeData) {
  17190. var hasPrettierIgnoreAttribute = typeof ignoreAttributeData === "boolean" ? function () {
  17191. return ignoreAttributeData;
  17192. } : Array.isArray(ignoreAttributeData) ? function (attr) {
  17193. return ignoreAttributeData.indexOf(attr.rawName) !== -1;
  17194. } : function () {
  17195. return false;
  17196. };
  17197. return path.map(function (attrPath) {
  17198. var attr = attrPath.getValue();
  17199. return hasPrettierIgnoreAttribute(attr) ? concat$8(replaceEndOfLineWith$1(options.originalText.slice(options.locStart(attr), options.locEnd(attr)), literalline$2)) : print(attrPath);
  17200. }, "attrs");
  17201. }(node.prev && node.prev.type === "comment" && getPrettierIgnoreAttributeCommentData(node.prev.value)))])),
  17202. /**
  17203. * 123<a
  17204. * attr
  17205. * ~
  17206. * >456
  17207. */
  17208. node.firstChild && needsToBorrowParentOpeningTagEndMarker(node.firstChild) ||
  17209. /**
  17210. * <span
  17211. * >123<meta
  17212. * ~
  17213. * /></span>
  17214. */
  17215. node.isSelfClosing && needsToBorrowLastChildClosingTagEndMarker(node.parent) ? "" : node.isSelfClosing ? forceNotToBreakAttrContent ? " " : line$6 : forceNotToBreakAttrContent ? "" : softline$4]), node.isSelfClosing ? "" : printOpeningTagEnd(node)]);
  17216. }
  17217. function printOpeningTagStart(node, options) {
  17218. return node.prev && needsToBorrowNextOpeningTagStartMarker(node.prev) ? "" : concat$8([printOpeningTagPrefix(node, options), printOpeningTagStartMarker(node)]);
  17219. }
  17220. function printOpeningTagEnd(node) {
  17221. return node.firstChild && needsToBorrowParentOpeningTagEndMarker(node.firstChild) ? "" : printOpeningTagEndMarker(node);
  17222. }
  17223. function printClosingTag(node, options) {
  17224. return concat$8([node.isSelfClosing ? "" : printClosingTagStart(node, options), printClosingTagEnd(node, options)]);
  17225. }
  17226. function printClosingTagStart(node, options) {
  17227. return node.lastChild && needsToBorrowParentClosingTagStartMarker(node.lastChild) ? "" : concat$8([printClosingTagPrefix(node, options), printClosingTagStartMarker(node, options)]);
  17228. }
  17229. function printClosingTagEnd(node, options) {
  17230. return (node.next ? needsToBorrowPrevClosingTagEndMarker(node.next) : needsToBorrowLastChildClosingTagEndMarker(node.parent)) ? "" : concat$8([printClosingTagEndMarker(node, options), printClosingTagSuffix(node, options)]);
  17231. }
  17232. function needsToBorrowNextOpeningTagStartMarker(node) {
  17233. /**
  17234. * 123<p
  17235. * ^^
  17236. * >
  17237. */
  17238. return node.next && !isTextLikeNode(node.next) && isTextLikeNode(node) && node.isTrailingSpaceSensitive && !node.hasTrailingSpaces;
  17239. }
  17240. function needsToBorrowParentOpeningTagEndMarker(node) {
  17241. /**
  17242. * <p
  17243. * >123
  17244. * ^
  17245. *
  17246. * <p
  17247. * ><a
  17248. * ^
  17249. */
  17250. return !node.prev && node.isLeadingSpaceSensitive && !node.hasLeadingSpaces;
  17251. }
  17252. function needsToBorrowPrevClosingTagEndMarker(node) {
  17253. /**
  17254. * <p></p
  17255. * >123
  17256. * ^
  17257. *
  17258. * <p></p
  17259. * ><a
  17260. * ^
  17261. */
  17262. return node.prev && !isTextLikeNode(node.prev) && node.isLeadingSpaceSensitive && !node.hasLeadingSpaces;
  17263. }
  17264. function needsToBorrowLastChildClosingTagEndMarker(node) {
  17265. /**
  17266. * <p
  17267. * ><a></a
  17268. * ></p
  17269. * ^
  17270. * >
  17271. */
  17272. return node.lastChild && node.lastChild.isTrailingSpaceSensitive && !node.lastChild.hasTrailingSpaces && !isTextLikeNode(getLastDescendant(node.lastChild));
  17273. }
  17274. function needsToBorrowParentClosingTagStartMarker(node) {
  17275. /**
  17276. * <p>
  17277. * 123</p
  17278. * ^^^
  17279. * >
  17280. *
  17281. * 123</b
  17282. * ></a
  17283. * ^^^
  17284. * >
  17285. */
  17286. return !node.next && !node.hasTrailingSpaces && node.isTrailingSpaceSensitive && isTextLikeNode(getLastDescendant(node));
  17287. }
  17288. function printOpeningTagPrefix(node, options) {
  17289. return needsToBorrowParentOpeningTagEndMarker(node) ? printOpeningTagEndMarker(node.parent) : needsToBorrowPrevClosingTagEndMarker(node) ? printClosingTagEndMarker(node.prev, options) : "";
  17290. }
  17291. function printClosingTagPrefix(node, options) {
  17292. return needsToBorrowLastChildClosingTagEndMarker(node) ? printClosingTagEndMarker(node.lastChild, options) : "";
  17293. }
  17294. function printClosingTagSuffix(node, options) {
  17295. return needsToBorrowParentClosingTagStartMarker(node) ? printClosingTagStartMarker(node.parent, options) : needsToBorrowNextOpeningTagStartMarker(node) ? printOpeningTagStartMarker(node.next) : "";
  17296. }
  17297. function printOpeningTagStartMarker(node) {
  17298. switch (node.type) {
  17299. case "ieConditionalComment":
  17300. case "ieConditionalStartComment":
  17301. return "<!--[if ".concat(node.condition);
  17302. case "ieConditionalEndComment":
  17303. return "<!--<!";
  17304. case "interpolation":
  17305. return "{{";
  17306. case "docType":
  17307. return "<!DOCTYPE";
  17308. case "element":
  17309. if (node.condition) {
  17310. return "<!--[if ".concat(node.condition, "]><!--><").concat(node.rawName);
  17311. }
  17312. // fall through
  17313. default:
  17314. return "<".concat(node.rawName);
  17315. }
  17316. }
  17317. function printOpeningTagEndMarker(node) {
  17318. assert$3(!node.isSelfClosing);
  17319. switch (node.type) {
  17320. case "ieConditionalComment":
  17321. return "]>";
  17322. case "element":
  17323. if (node.condition) {
  17324. return "><!--<![endif]-->";
  17325. }
  17326. // fall through
  17327. default:
  17328. return ">";
  17329. }
  17330. }
  17331. function printClosingTagStartMarker(node, options) {
  17332. assert$3(!node.isSelfClosing);
  17333. if (shouldNotPrintClosingTag(node, options)) {
  17334. return "";
  17335. }
  17336. switch (node.type) {
  17337. case "ieConditionalComment":
  17338. return "<!";
  17339. case "element":
  17340. if (node.hasHtmComponentClosingTag) {
  17341. return "<//";
  17342. }
  17343. // fall through
  17344. default:
  17345. return "</".concat(node.rawName);
  17346. }
  17347. }
  17348. function printClosingTagEndMarker(node, options) {
  17349. if (shouldNotPrintClosingTag(node, options)) {
  17350. return "";
  17351. }
  17352. switch (node.type) {
  17353. case "ieConditionalComment":
  17354. case "ieConditionalEndComment":
  17355. return "[endif]-->";
  17356. case "ieConditionalStartComment":
  17357. return "]><!-->";
  17358. case "interpolation":
  17359. return "}}";
  17360. case "element":
  17361. if (node.isSelfClosing) {
  17362. return "/>";
  17363. }
  17364. // fall through
  17365. default:
  17366. return ">";
  17367. }
  17368. }
  17369. function getTextValueParts(node) {
  17370. var value = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : node.value;
  17371. 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
  17372. join$5(line$6, value.split(/[\t\n\f\r ]+/)).parts;
  17373. }
  17374. function printEmbeddedAttributeValue(node, originalTextToDoc, options) {
  17375. var isKeyMatched = function isKeyMatched(patterns) {
  17376. return new RegExp(patterns.join("|")).test(node.fullName);
  17377. };
  17378. var getValue = function getValue() {
  17379. return unescapeQuoteEntities(node.value);
  17380. };
  17381. var shouldHug = false;
  17382. var __onHtmlBindingRoot = function __onHtmlBindingRoot(root) {
  17383. 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;
  17384. if (rootNode && (rootNode.type === "ObjectExpression" || rootNode.type === "ArrayExpression")) {
  17385. shouldHug = true;
  17386. }
  17387. };
  17388. var printHug = function printHug(doc$$2) {
  17389. return group$8(doc$$2);
  17390. };
  17391. var printExpand = function printExpand(doc$$2) {
  17392. return group$8(concat$8([indent$5(concat$8([softline$4, doc$$2])), softline$4]));
  17393. };
  17394. var printMaybeHug = function printMaybeHug(doc$$2) {
  17395. return shouldHug ? printHug(doc$$2) : printExpand(doc$$2);
  17396. };
  17397. var textToDoc = function textToDoc(code, opts) {
  17398. return originalTextToDoc(code, Object.assign({
  17399. __onHtmlBindingRoot: __onHtmlBindingRoot
  17400. }, opts));
  17401. };
  17402. if (node.fullName === "srcset" && (node.parent.fullName === "img" || node.parent.fullName === "source")) {
  17403. return printExpand(printImgSrcset(getValue()));
  17404. }
  17405. if (options.parser === "vue") {
  17406. if (node.fullName === "v-for") {
  17407. return printVueFor(getValue(), textToDoc);
  17408. }
  17409. if (node.fullName === "slot-scope") {
  17410. return printVueSlotScope(getValue(), textToDoc);
  17411. }
  17412. /**
  17413. * @click="jsStatement"
  17414. * @click="jsExpression"
  17415. * v-on:click="jsStatement"
  17416. * v-on:click="jsExpression"
  17417. */
  17418. var vueEventBindingPatterns = ["^@", "^v-on:"];
  17419. /**
  17420. * :class="vueExpression"
  17421. * v-bind:id="vueExpression"
  17422. */
  17423. var vueExpressionBindingPatterns = ["^:", "^v-bind:"];
  17424. /**
  17425. * v-if="jsExpression"
  17426. */
  17427. var jsExpressionBindingPatterns = ["^v-"];
  17428. if (isKeyMatched(vueEventBindingPatterns)) {
  17429. var value = getValue();
  17430. return printMaybeHug(isVueEventBindingExpression(value) ? textToDoc(value, {
  17431. parser: "__js_expression"
  17432. }) : stripTrailingHardline$1(textToDoc(value, {
  17433. parser: "__vue_event_binding"
  17434. })));
  17435. }
  17436. if (isKeyMatched(vueExpressionBindingPatterns)) {
  17437. return printMaybeHug(textToDoc(getValue(), {
  17438. parser: "__vue_expression"
  17439. }));
  17440. }
  17441. if (isKeyMatched(jsExpressionBindingPatterns)) {
  17442. return printMaybeHug(textToDoc(getValue(), {
  17443. parser: "__js_expression"
  17444. }));
  17445. }
  17446. }
  17447. if (options.parser === "angular") {
  17448. var ngTextToDoc = function ngTextToDoc(code, opts) {
  17449. return (// angular does not allow trailing comma
  17450. textToDoc(code, Object.assign({
  17451. trailingComma: "none"
  17452. }, opts))
  17453. );
  17454. };
  17455. /**
  17456. * *directive="angularDirective"
  17457. */
  17458. var ngDirectiveBindingPatterns = ["^\\*"];
  17459. /**
  17460. * (click)="angularStatement"
  17461. * on-click="angularStatement"
  17462. */
  17463. var ngStatementBindingPatterns = ["^\\(.+\\)$", "^on-"];
  17464. /**
  17465. * [target]="angularExpression"
  17466. * bind-target="angularExpression"
  17467. * [(target)]="angularExpression"
  17468. * bindon-target="angularExpression"
  17469. */
  17470. var ngExpressionBindingPatterns = ["^\\[.+\\]$", "^bind(on)?-"];
  17471. if (isKeyMatched(ngStatementBindingPatterns)) {
  17472. return printMaybeHug(ngTextToDoc(getValue(), {
  17473. parser: "__ng_action"
  17474. }));
  17475. }
  17476. if (isKeyMatched(ngExpressionBindingPatterns)) {
  17477. return printMaybeHug(ngTextToDoc(getValue(), {
  17478. parser: "__ng_binding"
  17479. }));
  17480. }
  17481. if (isKeyMatched(ngDirectiveBindingPatterns)) {
  17482. return printMaybeHug(ngTextToDoc(getValue(), {
  17483. parser: "__ng_directive"
  17484. }));
  17485. }
  17486. var interpolationRegex = /\{\{([\s\S]+?)\}\}/g;
  17487. var _value2 = getValue();
  17488. if (interpolationRegex.test(_value2)) {
  17489. var parts = [];
  17490. _value2.split(interpolationRegex).forEach(function (part, index) {
  17491. if (index % 2 === 0) {
  17492. parts.push(concat$8(replaceEndOfLineWith$1(part, literalline$2)));
  17493. } else {
  17494. try {
  17495. parts.push(group$8(concat$8(["{{", indent$5(concat$8([line$6, ngTextToDoc(part, {
  17496. parser: "__ng_interpolation",
  17497. __isInHtmlInterpolation: true // to avoid unexpected `}}`
  17498. })])), line$6, "}}"])));
  17499. } catch (e) {
  17500. parts.push("{{", concat$8(replaceEndOfLineWith$1(part, literalline$2)), "}}");
  17501. }
  17502. }
  17503. });
  17504. return group$8(concat$8(parts));
  17505. }
  17506. }
  17507. return null;
  17508. }
  17509. var printerHtml = {
  17510. preprocess: preprocess_1,
  17511. print: genericPrint$2,
  17512. insertPragma: insertPragma$5,
  17513. massageAstNode: clean$4,
  17514. embed: embed$2
  17515. };
  17516. var CATEGORY_HTML = "HTML"; // format based on https://github.com/prettier/prettier/blob/master/src/main/core-options.js
  17517. var options$9 = {
  17518. htmlWhitespaceSensitivity: {
  17519. since: "1.15.0",
  17520. category: CATEGORY_HTML,
  17521. type: "choice",
  17522. default: "css",
  17523. description: "How to handle whitespaces in HTML.",
  17524. choices: [{
  17525. value: "css",
  17526. description: "Respect the default value of CSS display property."
  17527. }, {
  17528. value: "strict",
  17529. description: "Whitespaces are considered sensitive."
  17530. }, {
  17531. value: "ignore",
  17532. description: "Whitespaces are considered insensitive."
  17533. }]
  17534. }
  17535. };
  17536. var name$7 = "HTML";
  17537. var type$6 = "markup";
  17538. var tmScope$6 = "text.html.basic";
  17539. var aceMode$6 = "html";
  17540. var codemirrorMode$3 = "htmlmixed";
  17541. var codemirrorMimeType$3 = "text/html";
  17542. var color$1 = "#e34c26";
  17543. var aliases$1 = ["xhtml"];
  17544. var extensions$6 = [".html", ".htm", ".html.hl", ".inc", ".st", ".xht", ".xhtml"];
  17545. var languageId$6 = 146;
  17546. var html$1 = {
  17547. name: name$7,
  17548. type: type$6,
  17549. tmScope: tmScope$6,
  17550. aceMode: aceMode$6,
  17551. codemirrorMode: codemirrorMode$3,
  17552. codemirrorMimeType: codemirrorMimeType$3,
  17553. color: color$1,
  17554. aliases: aliases$1,
  17555. extensions: extensions$6,
  17556. languageId: languageId$6
  17557. };
  17558. var html$2 = Object.freeze({
  17559. name: name$7,
  17560. type: type$6,
  17561. tmScope: tmScope$6,
  17562. aceMode: aceMode$6,
  17563. codemirrorMode: codemirrorMode$3,
  17564. codemirrorMimeType: codemirrorMimeType$3,
  17565. color: color$1,
  17566. aliases: aliases$1,
  17567. extensions: extensions$6,
  17568. languageId: languageId$6,
  17569. default: html$1
  17570. });
  17571. var name$8 = "Vue";
  17572. var type$7 = "markup";
  17573. var color$2 = "#2c3e50";
  17574. var extensions$7 = [".vue"];
  17575. var tmScope$7 = "text.html.vue";
  17576. var aceMode$7 = "html";
  17577. var languageId$7 = 391;
  17578. var vue = {
  17579. name: name$8,
  17580. type: type$7,
  17581. color: color$2,
  17582. extensions: extensions$7,
  17583. tmScope: tmScope$7,
  17584. aceMode: aceMode$7,
  17585. languageId: languageId$7
  17586. };
  17587. var vue$1 = Object.freeze({
  17588. name: name$8,
  17589. type: type$7,
  17590. color: color$2,
  17591. extensions: extensions$7,
  17592. tmScope: tmScope$7,
  17593. aceMode: aceMode$7,
  17594. languageId: languageId$7,
  17595. default: vue
  17596. });
  17597. var require$$0$22 = ( html$2 && html$1 ) || html$2;
  17598. var require$$1$9 = ( vue$1 && vue ) || vue$1;
  17599. var languages$3 = [createLanguage(require$$0$22, {
  17600. override: {
  17601. name: "Angular",
  17602. since: "1.15.0",
  17603. parsers: ["angular"],
  17604. vscodeLanguageIds: ["html"],
  17605. extensions: [".component.html"],
  17606. filenames: []
  17607. }
  17608. }), createLanguage(require$$0$22, {
  17609. override: {
  17610. since: "1.15.0",
  17611. parsers: ["html"],
  17612. vscodeLanguageIds: ["html"]
  17613. },
  17614. extend: {
  17615. extensions: [".mjml" // MJML is considered XML in Linguist but it should be formatted as HTML
  17616. ]
  17617. }
  17618. }), createLanguage(require$$0$22, {
  17619. override: {
  17620. name: "Lightning Web Components",
  17621. since: "1.17.0",
  17622. parsers: ["lwc"],
  17623. vscodeLanguageIds: ["html"],
  17624. extensions: [],
  17625. filenames: []
  17626. }
  17627. }), createLanguage(require$$1$9, {
  17628. override: {
  17629. since: "1.10.0",
  17630. parsers: ["vue"],
  17631. vscodeLanguageIds: ["vue"]
  17632. }
  17633. })];
  17634. var printers$3 = {
  17635. html: printerHtml
  17636. };
  17637. var languageHtml = {
  17638. languages: languages$3,
  17639. printers: printers$3,
  17640. options: options$9
  17641. };
  17642. var addLeadingComment$2 = utilShared.addLeadingComment;
  17643. var addTrailingComment$2 = utilShared.addTrailingComment;
  17644. var addDanglingComment$2 = utilShared.addDanglingComment;
  17645. function handleOwnLineComment(comment, text, options, ast, isLastComment) {
  17646. var precedingNode = comment.precedingNode,
  17647. enclosingNode = comment.enclosingNode,
  17648. followingNode = comment.followingNode;
  17649. 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)) {
  17650. return true;
  17651. }
  17652. return false;
  17653. }
  17654. function handleEndOfLineComment(comment, text, options, ast, isLastComment) {
  17655. var precedingNode = comment.precedingNode,
  17656. enclosingNode = comment.enclosingNode,
  17657. followingNode = comment.followingNode;
  17658. 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)) {
  17659. return true;
  17660. }
  17661. return false;
  17662. }
  17663. function handleRemainingComment(comment, text, options, ast, isLastComment) {
  17664. var precedingNode = comment.precedingNode,
  17665. enclosingNode = comment.enclosingNode,
  17666. followingNode = comment.followingNode;
  17667. 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)) {
  17668. return true;
  17669. }
  17670. return false;
  17671. }
  17672. function addBlockStatementFirstComment(node, comment) {
  17673. var body = node.body.filter(function (n) {
  17674. return n.type !== "EmptyStatement";
  17675. });
  17676. if (body.length === 0) {
  17677. addDanglingComment$2(node, comment);
  17678. } else {
  17679. addLeadingComment$2(body[0], comment);
  17680. }
  17681. }
  17682. function addBlockOrNotComment(node, comment) {
  17683. if (node.type === "BlockStatement") {
  17684. addBlockStatementFirstComment(node, comment);
  17685. } else {
  17686. addLeadingComment$2(node, comment);
  17687. }
  17688. } // There are often comments before the else clause of if statements like
  17689. //
  17690. // if (1) { ... }
  17691. // // comment
  17692. // else { ... }
  17693. //
  17694. // They are being attached as leading comments of the BlockExpression which
  17695. // is not well printed. What we want is to instead move the comment inside
  17696. // of the block and make it leadingComment of the first element of the block
  17697. // or dangling comment of the block if there is nothing inside
  17698. //
  17699. // if (1) { ... }
  17700. // else {
  17701. // // comment
  17702. // ...
  17703. // }
  17704. function handleIfStatementComments(text, precedingNode, enclosingNode, followingNode, comment, options) {
  17705. if (!enclosingNode || enclosingNode.type !== "IfStatement" || !followingNode) {
  17706. return false;
  17707. } // We unfortunately have no way using the AST or location of nodes to know
  17708. // if the comment is positioned before the condition parenthesis:
  17709. // if (a /* comment */) {}
  17710. // The only workaround I found is to look at the next character to see if
  17711. // it is a ).
  17712. var nextCharacter = util.getNextNonSpaceNonCommentCharacter(text, comment, options.locEnd);
  17713. if (nextCharacter === ")") {
  17714. addTrailingComment$2(precedingNode, comment);
  17715. return true;
  17716. } // Comments before `else`:
  17717. // - treat as trailing comments of the consequent, if it's a BlockStatement
  17718. // - treat as a dangling comment otherwise
  17719. if (precedingNode === enclosingNode.consequent && followingNode === enclosingNode.alternate) {
  17720. if (precedingNode.type === "BlockStatement") {
  17721. addTrailingComment$2(precedingNode, comment);
  17722. } else {
  17723. addDanglingComment$2(enclosingNode, comment);
  17724. }
  17725. return true;
  17726. }
  17727. if (followingNode.type === "BlockStatement") {
  17728. addBlockStatementFirstComment(followingNode, comment);
  17729. return true;
  17730. }
  17731. if (followingNode.type === "IfStatement") {
  17732. addBlockOrNotComment(followingNode.consequent, comment);
  17733. return true;
  17734. } // For comments positioned after the condition parenthesis in an if statement
  17735. // before the consequent without brackets on, such as
  17736. // if (a) /* comment */ true,
  17737. // we look at the next character to see if the following node
  17738. // is the consequent for the if statement
  17739. if (enclosingNode.consequent === followingNode) {
  17740. addLeadingComment$2(followingNode, comment);
  17741. return true;
  17742. }
  17743. return false;
  17744. }
  17745. function handleWhileComments(text, precedingNode, enclosingNode, followingNode, comment, options) {
  17746. if (!enclosingNode || enclosingNode.type !== "WhileStatement" || !followingNode) {
  17747. return false;
  17748. } // We unfortunately have no way using the AST or location of nodes to know
  17749. // if the comment is positioned before the condition parenthesis:
  17750. // while (a /* comment */) {}
  17751. // The only workaround I found is to look at the next character to see if
  17752. // it is a ).
  17753. var nextCharacter = util.getNextNonSpaceNonCommentCharacter(text, comment, options.locEnd);
  17754. if (nextCharacter === ")") {
  17755. addTrailingComment$2(precedingNode, comment);
  17756. return true;
  17757. }
  17758. if (followingNode.type === "BlockStatement") {
  17759. addBlockStatementFirstComment(followingNode, comment);
  17760. return true;
  17761. }
  17762. return false;
  17763. } // Same as IfStatement but for TryStatement
  17764. function handleTryStatementComments(enclosingNode, precedingNode, followingNode, comment) {
  17765. if (!enclosingNode || enclosingNode.type !== "TryStatement" && enclosingNode.type !== "CatchClause" || !followingNode) {
  17766. return false;
  17767. }
  17768. if (enclosingNode.type === "CatchClause" && precedingNode) {
  17769. addTrailingComment$2(precedingNode, comment);
  17770. return true;
  17771. }
  17772. if (followingNode.type === "BlockStatement") {
  17773. addBlockStatementFirstComment(followingNode, comment);
  17774. return true;
  17775. }
  17776. if (followingNode.type === "TryStatement") {
  17777. addBlockOrNotComment(followingNode.finalizer, comment);
  17778. return true;
  17779. }
  17780. if (followingNode.type === "CatchClause") {
  17781. addBlockOrNotComment(followingNode.body, comment);
  17782. return true;
  17783. }
  17784. return false;
  17785. }
  17786. function handleMemberExpressionComments(enclosingNode, followingNode, comment) {
  17787. if (enclosingNode && enclosingNode.type === "MemberExpression" && followingNode && followingNode.type === "Identifier") {
  17788. addLeadingComment$2(enclosingNode, comment);
  17789. return true;
  17790. }
  17791. return false;
  17792. }
  17793. function handleConditionalExpressionComments(enclosingNode, precedingNode, followingNode, comment, text, options) {
  17794. var isSameLineAsPrecedingNode = precedingNode && !util.hasNewlineInRange(text, options.locEnd(precedingNode), options.locStart(comment));
  17795. if ((!precedingNode || !isSameLineAsPrecedingNode) && enclosingNode && enclosingNode.type === "ConditionalExpression" && followingNode) {
  17796. addLeadingComment$2(followingNode, comment);
  17797. return true;
  17798. }
  17799. return false;
  17800. }
  17801. function handleObjectPropertyAssignment(enclosingNode, precedingNode, comment) {
  17802. if (enclosingNode && (enclosingNode.type === "ObjectProperty" || enclosingNode.type === "Property") && enclosingNode.shorthand && enclosingNode.key === precedingNode && enclosingNode.value.type === "AssignmentPattern") {
  17803. addTrailingComment$2(enclosingNode.value.left, comment);
  17804. return true;
  17805. }
  17806. return false;
  17807. }
  17808. function handleClassComments(enclosingNode, precedingNode, followingNode, comment) {
  17809. if (enclosingNode && (enclosingNode.type === "ClassDeclaration" || enclosingNode.type === "ClassExpression") && enclosingNode.decorators && enclosingNode.decorators.length > 0 && !(followingNode && followingNode.type === "Decorator")) {
  17810. if (!enclosingNode.decorators || enclosingNode.decorators.length === 0) {
  17811. addLeadingComment$2(enclosingNode, comment);
  17812. } else {
  17813. addTrailingComment$2(enclosingNode.decorators[enclosingNode.decorators.length - 1], comment);
  17814. }
  17815. return true;
  17816. }
  17817. return false;
  17818. }
  17819. function handleMethodNameComments(text, enclosingNode, precedingNode, comment, options) {
  17820. // This is only needed for estree parsers (flow, typescript) to attach
  17821. // after a method name:
  17822. // obj = { fn /*comment*/() {} };
  17823. if (enclosingNode && precedingNode && (enclosingNode.type === "Property" || enclosingNode.type === "MethodDefinition") && precedingNode.type === "Identifier" && enclosingNode.key === precedingNode && // special Property case: { key: /*comment*/(value) };
  17824. // comment should be attached to value instead of key
  17825. util.getNextNonSpaceNonCommentCharacter(text, precedingNode, options.locEnd) !== ":") {
  17826. addTrailingComment$2(precedingNode, comment);
  17827. return true;
  17828. } // Print comments between decorators and class methods as a trailing comment
  17829. // on the decorator node instead of the method node
  17830. if (precedingNode && enclosingNode && precedingNode.type === "Decorator" && (enclosingNode.type === "ClassMethod" || enclosingNode.type === "ClassProperty" || enclosingNode.type === "TSAbstractClassProperty" || enclosingNode.type === "TSAbstractMethodDefinition" || enclosingNode.type === "MethodDefinition")) {
  17831. addTrailingComment$2(precedingNode, comment);
  17832. return true;
  17833. }
  17834. return false;
  17835. }
  17836. function handleFunctionNameComments(text, enclosingNode, precedingNode, comment, options) {
  17837. if (util.getNextNonSpaceNonCommentCharacter(text, comment, options.locEnd) !== "(") {
  17838. return false;
  17839. }
  17840. if (precedingNode && enclosingNode && (enclosingNode.type === "FunctionDeclaration" || enclosingNode.type === "FunctionExpression" || enclosingNode.type === "ClassMethod" || enclosingNode.type === "MethodDefinition" || enclosingNode.type === "ObjectMethod")) {
  17841. addTrailingComment$2(precedingNode, comment);
  17842. return true;
  17843. }
  17844. return false;
  17845. }
  17846. function handleCommentAfterArrowParams(text, enclosingNode, comment, options) {
  17847. if (!(enclosingNode && enclosingNode.type === "ArrowFunctionExpression")) {
  17848. return false;
  17849. }
  17850. var index = utilShared.getNextNonSpaceNonCommentCharacterIndex(text, comment, options);
  17851. if (text.substr(index, 2) === "=>") {
  17852. addDanglingComment$2(enclosingNode, comment);
  17853. return true;
  17854. }
  17855. return false;
  17856. }
  17857. function handleCommentInEmptyParens(text, enclosingNode, comment, options) {
  17858. if (util.getNextNonSpaceNonCommentCharacter(text, comment, options.locEnd) !== ")") {
  17859. return false;
  17860. } // Only add dangling comments to fix the case when no params are present,
  17861. // i.e. a function without any argument.
  17862. if (enclosingNode && ((enclosingNode.type === "FunctionDeclaration" || enclosingNode.type === "FunctionExpression" || enclosingNode.type === "ArrowFunctionExpression" || enclosingNode.type === "ClassMethod" || enclosingNode.type === "ObjectMethod") && enclosingNode.params.length === 0 || (enclosingNode.type === "CallExpression" || enclosingNode.type === "NewExpression") && enclosingNode.arguments.length === 0)) {
  17863. addDanglingComment$2(enclosingNode, comment);
  17864. return true;
  17865. }
  17866. if (enclosingNode && enclosingNode.type === "MethodDefinition" && enclosingNode.value.params.length === 0) {
  17867. addDanglingComment$2(enclosingNode.value, comment);
  17868. return true;
  17869. }
  17870. return false;
  17871. }
  17872. function handleLastFunctionArgComments(text, precedingNode, enclosingNode, followingNode, comment, options) {
  17873. // Type definitions functions
  17874. if (precedingNode && precedingNode.type === "FunctionTypeParam" && enclosingNode && enclosingNode.type === "FunctionTypeAnnotation" && followingNode && followingNode.type !== "FunctionTypeParam") {
  17875. addTrailingComment$2(precedingNode, comment);
  17876. return true;
  17877. } // Real functions
  17878. 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) === ")") {
  17879. addTrailingComment$2(precedingNode, comment);
  17880. return true;
  17881. }
  17882. if (enclosingNode && enclosingNode.type === "FunctionDeclaration" && followingNode && followingNode.type === "BlockStatement") {
  17883. var functionParamRightParenIndex = function () {
  17884. if (enclosingNode.params.length !== 0) {
  17885. return util.getNextNonSpaceNonCommentCharacterIndexWithStartIndex(text, options.locEnd(util.getLast(enclosingNode.params)));
  17886. }
  17887. var functionParamLeftParenIndex = util.getNextNonSpaceNonCommentCharacterIndexWithStartIndex(text, options.locEnd(enclosingNode.id));
  17888. return util.getNextNonSpaceNonCommentCharacterIndexWithStartIndex(text, functionParamLeftParenIndex + 1);
  17889. }();
  17890. if (options.locStart(comment) > functionParamRightParenIndex) {
  17891. addBlockStatementFirstComment(followingNode, comment);
  17892. return true;
  17893. }
  17894. }
  17895. return false;
  17896. }
  17897. function handleImportSpecifierComments(enclosingNode, comment) {
  17898. if (enclosingNode && enclosingNode.type === "ImportSpecifier") {
  17899. addLeadingComment$2(enclosingNode, comment);
  17900. return true;
  17901. }
  17902. return false;
  17903. }
  17904. function handleLabeledStatementComments(enclosingNode, comment) {
  17905. if (enclosingNode && enclosingNode.type === "LabeledStatement") {
  17906. addLeadingComment$2(enclosingNode, comment);
  17907. return true;
  17908. }
  17909. return false;
  17910. }
  17911. function handleBreakAndContinueStatementComments(enclosingNode, comment) {
  17912. if (enclosingNode && (enclosingNode.type === "ContinueStatement" || enclosingNode.type === "BreakStatement") && !enclosingNode.label) {
  17913. addTrailingComment$2(enclosingNode, comment);
  17914. return true;
  17915. }
  17916. return false;
  17917. }
  17918. function handleCallExpressionComments(precedingNode, enclosingNode, comment) {
  17919. if (enclosingNode && enclosingNode.type === "CallExpression" && precedingNode && enclosingNode.callee === precedingNode && enclosingNode.arguments.length > 0) {
  17920. addLeadingComment$2(enclosingNode.arguments[0], comment);
  17921. return true;
  17922. }
  17923. return false;
  17924. }
  17925. function handleUnionTypeComments(precedingNode, enclosingNode, followingNode, comment) {
  17926. if (enclosingNode && (enclosingNode.type === "UnionTypeAnnotation" || enclosingNode.type === "TSUnionType")) {
  17927. addTrailingComment$2(precedingNode, comment);
  17928. return true;
  17929. }
  17930. return false;
  17931. }
  17932. function handlePropertyComments(enclosingNode, comment) {
  17933. if (enclosingNode && (enclosingNode.type === "Property" || enclosingNode.type === "ObjectProperty")) {
  17934. addLeadingComment$2(enclosingNode, comment);
  17935. return true;
  17936. }
  17937. return false;
  17938. }
  17939. function handleOnlyComments(enclosingNode, ast, comment, isLastComment) {
  17940. // With Flow the enclosingNode is undefined so use the AST instead.
  17941. if (ast && ast.body && ast.body.length === 0) {
  17942. if (isLastComment) {
  17943. addDanglingComment$2(ast, comment);
  17944. } else {
  17945. addLeadingComment$2(ast, comment);
  17946. }
  17947. return true;
  17948. } else if (enclosingNode && enclosingNode.type === "Program" && enclosingNode.body.length === 0 && enclosingNode.directives && enclosingNode.directives.length === 0) {
  17949. if (isLastComment) {
  17950. addDanglingComment$2(enclosingNode, comment);
  17951. } else {
  17952. addLeadingComment$2(enclosingNode, comment);
  17953. }
  17954. return true;
  17955. }
  17956. return false;
  17957. }
  17958. function handleForComments(enclosingNode, precedingNode, comment) {
  17959. if (enclosingNode && (enclosingNode.type === "ForInStatement" || enclosingNode.type === "ForOfStatement")) {
  17960. addLeadingComment$2(enclosingNode, comment);
  17961. return true;
  17962. }
  17963. return false;
  17964. }
  17965. function handleImportDeclarationComments(text, enclosingNode, precedingNode, comment, options) {
  17966. if (precedingNode && precedingNode.type === "ImportSpecifier" && enclosingNode && enclosingNode.type === "ImportDeclaration" && util.hasNewline(text, options.locEnd(comment))) {
  17967. addTrailingComment$2(precedingNode, comment);
  17968. return true;
  17969. }
  17970. return false;
  17971. }
  17972. function handleAssignmentPatternComments(enclosingNode, comment) {
  17973. if (enclosingNode && enclosingNode.type === "AssignmentPattern") {
  17974. addLeadingComment$2(enclosingNode, comment);
  17975. return true;
  17976. }
  17977. return false;
  17978. }
  17979. function handleTypeAliasComments(enclosingNode, followingNode, comment) {
  17980. if (enclosingNode && enclosingNode.type === "TypeAlias") {
  17981. addLeadingComment$2(enclosingNode, comment);
  17982. return true;
  17983. }
  17984. return false;
  17985. }
  17986. function handleVariableDeclaratorComments(enclosingNode, followingNode, comment) {
  17987. if (enclosingNode && (enclosingNode.type === "VariableDeclarator" || enclosingNode.type === "AssignmentExpression") && followingNode && (followingNode.type === "ObjectExpression" || followingNode.type === "ArrayExpression" || followingNode.type === "TemplateLiteral" || followingNode.type === "TaggedTemplateExpression")) {
  17988. addLeadingComment$2(followingNode, comment);
  17989. return true;
  17990. }
  17991. return false;
  17992. }
  17993. function handleTSMappedTypeComments(text, enclosingNode, precedingNode, followingNode, comment) {
  17994. if (!enclosingNode || enclosingNode.type !== "TSMappedType") {
  17995. return false;
  17996. }
  17997. if (followingNode && followingNode.type === "TSTypeParameter" && followingNode.name) {
  17998. addLeadingComment$2(followingNode.name, comment);
  17999. return true;
  18000. }
  18001. if (precedingNode && precedingNode.type === "TSTypeParameter" && precedingNode.constraint) {
  18002. addTrailingComment$2(precedingNode.constraint, comment);
  18003. return true;
  18004. }
  18005. return false;
  18006. }
  18007. function isBlockComment$1(comment) {
  18008. return comment.type === "Block" || comment.type === "CommentBlock";
  18009. }
  18010. function hasLeadingComment$2(node) {
  18011. var fn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () {
  18012. return true;
  18013. };
  18014. if (node.leadingComments) {
  18015. return node.leadingComments.some(fn);
  18016. }
  18017. if (node.comments) {
  18018. return node.comments.some(function (comment) {
  18019. return comment.leading && fn(comment);
  18020. });
  18021. }
  18022. return false;
  18023. }
  18024. var comments$3 = {
  18025. handleOwnLineComment: handleOwnLineComment,
  18026. handleEndOfLineComment: handleEndOfLineComment,
  18027. handleRemainingComment: handleRemainingComment,
  18028. hasLeadingComment: hasLeadingComment$2,
  18029. isBlockComment: isBlockComment$1
  18030. };
  18031. var isBlockComment = comments$3.isBlockComment;
  18032. var hasLeadingComment$1 = comments$3.hasLeadingComment;
  18033. var _require$$1$builders = doc.builders;
  18034. var indent$7 = _require$$1$builders.indent;
  18035. var join$8 = _require$$1$builders.join;
  18036. var hardline$9 = _require$$1$builders.hardline;
  18037. var softline$6 = _require$$1$builders.softline;
  18038. var literalline$4 = _require$$1$builders.literalline;
  18039. var concat$12 = _require$$1$builders.concat;
  18040. var group$11 = _require$$1$builders.group;
  18041. var dedentToRoot$2 = _require$$1$builders.dedentToRoot;
  18042. var _require$$1$utils = doc.utils;
  18043. var mapDoc$5 = _require$$1$utils.mapDoc;
  18044. var stripTrailingHardline$2 = _require$$1$utils.stripTrailingHardline;
  18045. function embed$4(path, print, textToDoc, options) {
  18046. var node = path.getValue();
  18047. var parent = path.getParentNode();
  18048. var parentParent = path.getParentNode(1);
  18049. switch (node.type) {
  18050. case "TemplateLiteral":
  18051. {
  18052. var isCss = [isStyledJsx, isStyledComponents, isCssProp, isAngularComponentStyles].some(function (isIt) {
  18053. return isIt(path);
  18054. });
  18055. if (isCss) {
  18056. // Get full template literal with expressions replaced by placeholders
  18057. var rawQuasis = node.quasis.map(function (q) {
  18058. return q.value.raw;
  18059. });
  18060. var placeholderID = 0;
  18061. var text = rawQuasis.reduce(function (prevVal, currVal, idx) {
  18062. return idx == 0 ? currVal : prevVal + "@prettier-placeholder-" + placeholderID++ + "-id" + currVal;
  18063. }, "");
  18064. var doc$$2 = textToDoc(text, {
  18065. parser: "css"
  18066. });
  18067. return transformCssDoc(doc$$2, path, print);
  18068. }
  18069. /*
  18070. * react-relay and graphql-tag
  18071. * graphql`...`
  18072. * graphql.experimental`...`
  18073. * gql`...`
  18074. *
  18075. * This intentionally excludes Relay Classic tags, as Prettier does not
  18076. * support Relay Classic formatting.
  18077. */
  18078. if (isGraphQL(path)) {
  18079. var expressionDocs = node.expressions ? path.map(print, "expressions") : [];
  18080. var numQuasis = node.quasis.length;
  18081. if (numQuasis === 1 && node.quasis[0].value.raw.trim() === "") {
  18082. return "``";
  18083. }
  18084. var parts = [];
  18085. for (var i = 0; i < numQuasis; i++) {
  18086. var templateElement = node.quasis[i];
  18087. var isFirst = i === 0;
  18088. var isLast = i === numQuasis - 1;
  18089. var _text = templateElement.value.cooked; // Bail out if any of the quasis have an invalid escape sequence
  18090. // (which would make the `cooked` value be `null` or `undefined`)
  18091. if (typeof _text !== "string") {
  18092. return null;
  18093. }
  18094. var lines = _text.split("\n");
  18095. var numLines = lines.length;
  18096. var expressionDoc = expressionDocs[i];
  18097. var startsWithBlankLine = numLines > 2 && lines[0].trim() === "" && lines[1].trim() === "";
  18098. var endsWithBlankLine = numLines > 2 && lines[numLines - 1].trim() === "" && lines[numLines - 2].trim() === "";
  18099. var commentsAndWhitespaceOnly = lines.every(function (line) {
  18100. return /^\s*(?:#[^\r\n]*)?$/.test(line);
  18101. }); // Bail out if an interpolation occurs within a comment.
  18102. if (!isLast && /#[^\r\n]*$/.test(lines[numLines - 1])) {
  18103. return null;
  18104. }
  18105. var _doc = null;
  18106. if (commentsAndWhitespaceOnly) {
  18107. _doc = printGraphqlComments(lines);
  18108. } else {
  18109. _doc = stripTrailingHardline$2(textToDoc(_text, {
  18110. parser: "graphql"
  18111. }));
  18112. }
  18113. if (_doc) {
  18114. _doc = escapeTemplateCharacters(_doc, false);
  18115. if (!isFirst && startsWithBlankLine) {
  18116. parts.push("");
  18117. }
  18118. parts.push(_doc);
  18119. if (!isLast && endsWithBlankLine) {
  18120. parts.push("");
  18121. }
  18122. } else if (!isFirst && !isLast && startsWithBlankLine) {
  18123. parts.push("");
  18124. }
  18125. if (expressionDoc) {
  18126. parts.push(concat$12(["${", expressionDoc, "}"]));
  18127. }
  18128. }
  18129. return concat$12(["`", indent$7(concat$12([hardline$9, join$8(hardline$9, parts)])), hardline$9, "`"]);
  18130. }
  18131. var htmlParser = isHtml(path) ? "html" : isAngularComponentTemplate(path) ? "angular" : undefined;
  18132. if (htmlParser) {
  18133. return printHtmlTemplateLiteral(path, print, textToDoc, htmlParser, options.embeddedInHtml);
  18134. }
  18135. break;
  18136. }
  18137. case "TemplateElement":
  18138. {
  18139. /**
  18140. * md`...`
  18141. * markdown`...`
  18142. */
  18143. if (parentParent && parentParent.type === "TaggedTemplateExpression" && parent.quasis.length === 1 && parentParent.tag.type === "Identifier" && (parentParent.tag.name === "md" || parentParent.tag.name === "markdown")) {
  18144. var _text2 = parent.quasis[0].value.raw.replace(/((?:\\\\)*)\\`/g, function (_, backslashes) {
  18145. return "\\".repeat(backslashes.length / 2) + "`";
  18146. });
  18147. var indentation = getIndentation(_text2);
  18148. var hasIndent = indentation !== "";
  18149. 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]);
  18150. }
  18151. break;
  18152. }
  18153. }
  18154. function printMarkdown(text) {
  18155. var doc$$2 = textToDoc(text, {
  18156. parser: "markdown",
  18157. __inJsTemplate: true
  18158. });
  18159. return stripTrailingHardline$2(escapeTemplateCharacters(doc$$2, true));
  18160. }
  18161. }
  18162. function getIndentation(str) {
  18163. var firstMatchedIndent = str.match(/^([^\S\n]*)\S/m);
  18164. return firstMatchedIndent === null ? "" : firstMatchedIndent[1];
  18165. }
  18166. function uncook(cookedValue) {
  18167. return cookedValue.replace(/([\\`]|\$\{)/g, "\\$1");
  18168. }
  18169. function escapeTemplateCharacters(doc$$2, raw) {
  18170. return mapDoc$5(doc$$2, function (currentDoc) {
  18171. if (!currentDoc.parts) {
  18172. return currentDoc;
  18173. }
  18174. var parts = [];
  18175. currentDoc.parts.forEach(function (part) {
  18176. if (typeof part === "string") {
  18177. parts.push(raw ? part.replace(/(\\*)`/g, "$1$1\\`") : uncook(part));
  18178. } else {
  18179. parts.push(part);
  18180. }
  18181. });
  18182. return Object.assign({}, currentDoc, {
  18183. parts: parts
  18184. });
  18185. });
  18186. }
  18187. function transformCssDoc(quasisDoc, path, print) {
  18188. var parentNode = path.getValue();
  18189. var isEmpty = parentNode.quasis.length === 1 && !parentNode.quasis[0].value.raw.trim();
  18190. if (isEmpty) {
  18191. return "``";
  18192. }
  18193. var expressionDocs = parentNode.expressions ? path.map(print, "expressions") : [];
  18194. var newDoc = replacePlaceholders(quasisDoc, expressionDocs);
  18195. /* istanbul ignore if */
  18196. if (!newDoc) {
  18197. throw new Error("Couldn't insert all the expressions");
  18198. }
  18199. return concat$12(["`", indent$7(concat$12([hardline$9, stripTrailingHardline$2(newDoc)])), softline$6, "`"]);
  18200. } // Search all the placeholders in the quasisDoc tree
  18201. // and replace them with the expression docs one by one
  18202. // returns a new doc with all the placeholders replaced,
  18203. // or null if it couldn't replace any expression
  18204. function replacePlaceholders(quasisDoc, expressionDocs) {
  18205. if (!expressionDocs || !expressionDocs.length) {
  18206. return quasisDoc;
  18207. }
  18208. var expressions = expressionDocs.slice();
  18209. var replaceCounter = 0;
  18210. var newDoc = mapDoc$5(quasisDoc, function (doc$$2) {
  18211. if (!doc$$2 || !doc$$2.parts || !doc$$2.parts.length) {
  18212. return doc$$2;
  18213. }
  18214. var parts = doc$$2.parts;
  18215. var atIndex = parts.indexOf("@");
  18216. var placeholderIndex = atIndex + 1;
  18217. if (atIndex > -1 && typeof parts[placeholderIndex] === "string" && parts[placeholderIndex].startsWith("prettier-placeholder")) {
  18218. // If placeholder is split, join it
  18219. var at = parts[atIndex];
  18220. var placeholder = parts[placeholderIndex];
  18221. var rest = parts.slice(placeholderIndex + 1);
  18222. parts = parts.slice(0, atIndex).concat([at + placeholder]).concat(rest);
  18223. }
  18224. var atPlaceholderIndex = parts.findIndex(function (part) {
  18225. return typeof part === "string" && part.startsWith("@prettier-placeholder");
  18226. });
  18227. if (atPlaceholderIndex > -1) {
  18228. var _placeholder = parts[atPlaceholderIndex];
  18229. var _rest = parts.slice(atPlaceholderIndex + 1);
  18230. var placeholderMatch = _placeholder.match(/@prettier-placeholder-(.+)-id([\s\S]*)/);
  18231. var placeholderID = placeholderMatch[1]; // When the expression has a suffix appended, like:
  18232. // animation: linear ${time}s ease-out;
  18233. var suffix = placeholderMatch[2];
  18234. var expression = expressions[placeholderID];
  18235. replaceCounter++;
  18236. parts = parts.slice(0, atPlaceholderIndex).concat(["${", expression, "}" + suffix]).concat(_rest);
  18237. }
  18238. return Object.assign({}, doc$$2, {
  18239. parts: parts
  18240. });
  18241. });
  18242. return expressions.length === replaceCounter ? newDoc : null;
  18243. }
  18244. function printGraphqlComments(lines) {
  18245. var parts = [];
  18246. var seenComment = false;
  18247. lines.map(function (textLine) {
  18248. return textLine.trim();
  18249. }).forEach(function (textLine, i, array) {
  18250. // Lines are either whitespace only, or a comment (with poential whitespace
  18251. // around it). Drop whitespace-only lines.
  18252. if (textLine === "") {
  18253. return;
  18254. }
  18255. if (array[i - 1] === "" && seenComment) {
  18256. // If a non-first comment is preceded by a blank (whitespace only) line,
  18257. // add in a blank line.
  18258. parts.push(concat$12([hardline$9, textLine]));
  18259. } else {
  18260. parts.push(textLine);
  18261. }
  18262. seenComment = true;
  18263. }); // If `lines` was whitespace only, return `null`.
  18264. return parts.length === 0 ? null : join$8(hardline$9, parts);
  18265. }
  18266. /**
  18267. * Template literal in these contexts:
  18268. * <style jsx>{`div{color:red}`}</style>
  18269. * css``
  18270. * css.global``
  18271. * css.resolve``
  18272. */
  18273. function isStyledJsx(path) {
  18274. var node = path.getValue();
  18275. var parent = path.getParentNode();
  18276. var parentParent = path.getParentNode(1);
  18277. return parentParent && node.quasis && parent.type === "JSXExpressionContainer" && parentParent.type === "JSXElement" && parentParent.openingElement.name.name === "style" && parentParent.openingElement.attributes.some(function (attribute) {
  18278. return attribute.name.name === "jsx";
  18279. }) || parent && parent.type === "TaggedTemplateExpression" && parent.tag.type === "Identifier" && parent.tag.name === "css" || parent && parent.type === "TaggedTemplateExpression" && parent.tag.type === "MemberExpression" && parent.tag.object.name === "css" && (parent.tag.property.name === "global" || parent.tag.property.name === "resolve");
  18280. }
  18281. /**
  18282. * Angular Components can have:
  18283. * - Inline HTML template
  18284. * - Inline CSS styles
  18285. *
  18286. * ...which are both within template literals somewhere
  18287. * inside of the Component decorator factory.
  18288. *
  18289. * E.g.
  18290. * @Component({
  18291. * template: `<div>...</div>`,
  18292. * styles: [`h1 { color: blue; }`]
  18293. * })
  18294. */
  18295. function isAngularComponentStyles(path) {
  18296. return isPathMatch(path, [function (node) {
  18297. return node.type === "TemplateLiteral";
  18298. }, function (node, name) {
  18299. return node.type === "ArrayExpression" && name === "elements";
  18300. }, function (node, name) {
  18301. return node.type === "Property" && node.key.type === "Identifier" && node.key.name === "styles" && name === "value";
  18302. }].concat(getAngularComponentObjectExpressionPredicates()));
  18303. }
  18304. function isAngularComponentTemplate(path) {
  18305. return isPathMatch(path, [function (node) {
  18306. return node.type === "TemplateLiteral";
  18307. }, function (node, name) {
  18308. return node.type === "Property" && node.key.type === "Identifier" && node.key.name === "template" && name === "value";
  18309. }].concat(getAngularComponentObjectExpressionPredicates()));
  18310. }
  18311. function getAngularComponentObjectExpressionPredicates() {
  18312. return [function (node, name) {
  18313. return node.type === "ObjectExpression" && name === "properties";
  18314. }, function (node, name) {
  18315. return node.type === "CallExpression" && node.callee.type === "Identifier" && node.callee.name === "Component" && name === "arguments";
  18316. }, function (node, name) {
  18317. return node.type === "Decorator" && name === "expression";
  18318. }];
  18319. }
  18320. /**
  18321. * styled-components template literals
  18322. */
  18323. function isStyledComponents(path) {
  18324. var parent = path.getParentNode();
  18325. if (!parent || parent.type !== "TaggedTemplateExpression") {
  18326. return false;
  18327. }
  18328. var tag = parent.tag;
  18329. switch (tag.type) {
  18330. case "MemberExpression":
  18331. return (// styled.foo``
  18332. isStyledIdentifier(tag.object) || // Component.extend``
  18333. isStyledExtend(tag)
  18334. );
  18335. case "CallExpression":
  18336. return (// styled(Component)``
  18337. isStyledIdentifier(tag.callee) || tag.callee.type === "MemberExpression" && (tag.callee.object.type === "MemberExpression" && ( // styled.foo.attrs({})``
  18338. isStyledIdentifier(tag.callee.object.object) || // Component.extend.attrs({})``
  18339. isStyledExtend(tag.callee.object)) || // styled(Component).attrs({})``
  18340. tag.callee.object.type === "CallExpression" && isStyledIdentifier(tag.callee.object.callee))
  18341. );
  18342. case "Identifier":
  18343. // css``
  18344. return tag.name === "css";
  18345. default:
  18346. return false;
  18347. }
  18348. }
  18349. /**
  18350. * JSX element with CSS prop
  18351. */
  18352. function isCssProp(path) {
  18353. var parent = path.getParentNode();
  18354. var parentParent = path.getParentNode(1);
  18355. return parentParent && parent.type === "JSXExpressionContainer" && parentParent.type === "JSXAttribute" && parentParent.name.type === "JSXIdentifier" && parentParent.name.name === "css";
  18356. }
  18357. function isStyledIdentifier(node) {
  18358. return node.type === "Identifier" && node.name === "styled";
  18359. }
  18360. function isStyledExtend(node) {
  18361. return /^[A-Z]/.test(node.object.name) && node.property.name === "extend";
  18362. }
  18363. /*
  18364. * react-relay and graphql-tag
  18365. * graphql`...`
  18366. * graphql.experimental`...`
  18367. * gql`...`
  18368. * GraphQL comment block
  18369. *
  18370. * This intentionally excludes Relay Classic tags, as Prettier does not
  18371. * support Relay Classic formatting.
  18372. */
  18373. function isGraphQL(path) {
  18374. var node = path.getValue();
  18375. var parent = path.getParentNode();
  18376. 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");
  18377. }
  18378. function hasLanguageComment(node, languageName) {
  18379. // This checks for a leading comment that is exactly `/* GraphQL */`
  18380. // In order to be in line with other implementations of this comment tag
  18381. // we will not trim the comment value and we will expect exactly one space on
  18382. // either side of the GraphQL string
  18383. // Also see ./clean.js
  18384. return hasLeadingComment$1(node, function (comment) {
  18385. return isBlockComment(comment) && comment.value === " ".concat(languageName, " ");
  18386. });
  18387. }
  18388. function isPathMatch(path, predicateStack) {
  18389. var stack = path.stack.slice();
  18390. var name = null;
  18391. var node = stack.pop();
  18392. var _iteratorNormalCompletion = true;
  18393. var _didIteratorError = false;
  18394. var _iteratorError = undefined;
  18395. try {
  18396. for (var _iterator = predicateStack[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  18397. var predicate = _step.value;
  18398. if (node === undefined) {
  18399. return false;
  18400. } // skip index/array
  18401. if (typeof name === "number") {
  18402. name = stack.pop();
  18403. node = stack.pop();
  18404. }
  18405. if (!predicate(node, name)) {
  18406. return false;
  18407. }
  18408. name = stack.pop();
  18409. node = stack.pop();
  18410. }
  18411. } catch (err) {
  18412. _didIteratorError = true;
  18413. _iteratorError = err;
  18414. } finally {
  18415. try {
  18416. if (!_iteratorNormalCompletion && _iterator.return != null) {
  18417. _iterator.return();
  18418. }
  18419. } finally {
  18420. if (_didIteratorError) {
  18421. throw _iteratorError;
  18422. }
  18423. }
  18424. }
  18425. return true;
  18426. }
  18427. /**
  18428. * - html`...`
  18429. * - HTML comment block
  18430. */
  18431. function isHtml(path) {
  18432. var node = path.getValue();
  18433. return hasLanguageComment(node, "HTML") || isPathMatch(path, [function (node) {
  18434. return node.type === "TemplateLiteral";
  18435. }, function (node, name) {
  18436. return node.type === "TaggedTemplateExpression" && node.tag.type === "Identifier" && node.tag.name === "html" && name === "quasi";
  18437. }]);
  18438. } // The counter is needed to distinguish nested embeds.
  18439. var htmlTemplateLiteralCounter = 0;
  18440. function printHtmlTemplateLiteral(path, print, textToDoc, parser, escapeClosingScriptTag) {
  18441. var node = path.getValue();
  18442. var counter = htmlTemplateLiteralCounter;
  18443. htmlTemplateLiteralCounter = htmlTemplateLiteralCounter + 1 >>> 0;
  18444. var composePlaceholder = function composePlaceholder(index) {
  18445. return "PRETTIER_HTML_PLACEHOLDER_".concat(index, "_").concat(counter, "_IN_JS");
  18446. };
  18447. var text = node.quasis.map(function (quasi, index, quasis) {
  18448. return index === quasis.length - 1 ? quasi.value.cooked : quasi.value.cooked + composePlaceholder(index);
  18449. }).join("");
  18450. var expressionDocs = path.map(print, "expressions");
  18451. if (expressionDocs.length === 0 && text.trim().length === 0) {
  18452. return "``";
  18453. }
  18454. var placeholderRegex = RegExp(composePlaceholder("(\\d+)"), "g");
  18455. var contentDoc = mapDoc$5(stripTrailingHardline$2(textToDoc(text, {
  18456. parser: parser
  18457. })), function (doc$$2) {
  18458. if (typeof doc$$2 !== "string") {
  18459. return doc$$2;
  18460. }
  18461. var parts = [];
  18462. var components = doc$$2.split(placeholderRegex);
  18463. for (var i = 0; i < components.length; i++) {
  18464. var component = components[i];
  18465. if (i % 2 === 0) {
  18466. if (component) {
  18467. component = uncook(component);
  18468. if (escapeClosingScriptTag) {
  18469. component = component.replace(/<\/(script)\b/gi, "<\\/$1");
  18470. }
  18471. parts.push(component);
  18472. }
  18473. continue;
  18474. }
  18475. var placeholderIndex = +component;
  18476. parts.push(concat$12(["${", group$11(expressionDocs[placeholderIndex]), "}"]));
  18477. }
  18478. return concat$12(parts);
  18479. });
  18480. return group$11(concat$12(["`", indent$7(concat$12([hardline$9, group$11(contentDoc)])), softline$6, "`"]));
  18481. }
  18482. var embed_1$2 = embed$4;
  18483. function clean$7(ast, newObj, parent) {
  18484. ["range", "raw", "comments", "leadingComments", "trailingComments", "extra", "start", "end", "flags"].forEach(function (name) {
  18485. delete newObj[name];
  18486. });
  18487. if (ast.type === "BigIntLiteral") {
  18488. newObj.value = newObj.value.toLowerCase();
  18489. } // We remove extra `;` and add them when needed
  18490. if (ast.type === "EmptyStatement") {
  18491. return null;
  18492. } // We move text around, including whitespaces and add {" "}
  18493. if (ast.type === "JSXText") {
  18494. return null;
  18495. }
  18496. if (ast.type === "JSXExpressionContainer" && ast.expression.type === "Literal" && ast.expression.value === " ") {
  18497. return null;
  18498. } // (TypeScript) Ignore `static` in `constructor(static p) {}`
  18499. // and `export` in `constructor(export p) {}`
  18500. if (ast.type === "TSParameterProperty" && ast.accessibility === null && !ast.readonly) {
  18501. return {
  18502. type: "Identifier",
  18503. name: ast.parameter.name,
  18504. typeAnnotation: newObj.parameter.typeAnnotation,
  18505. decorators: newObj.decorators
  18506. };
  18507. } // (TypeScript) ignore empty `specifiers` array
  18508. if (ast.type === "TSNamespaceExportDeclaration" && ast.specifiers && ast.specifiers.length === 0) {
  18509. delete newObj.specifiers;
  18510. } // (TypeScript) bypass TSParenthesizedType
  18511. if (ast.type === "TSParenthesizedType") {
  18512. return newObj.typeAnnotation;
  18513. } // We convert <div></div> to <div />
  18514. if (ast.type === "JSXOpeningElement") {
  18515. delete newObj.selfClosing;
  18516. }
  18517. if (ast.type === "JSXElement") {
  18518. delete newObj.closingElement;
  18519. } // We change {'key': value} into {key: value}
  18520. 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")) {
  18521. delete newObj.key;
  18522. }
  18523. if (ast.type === "OptionalMemberExpression" && ast.optional === false) {
  18524. newObj.type = "MemberExpression";
  18525. delete newObj.optional;
  18526. } // Remove raw and cooked values from TemplateElement when it's CSS
  18527. // styled-jsx
  18528. if (ast.type === "JSXElement" && ast.openingElement.name.name === "style" && ast.openingElement.attributes.some(function (attr) {
  18529. return attr.name.name === "jsx";
  18530. })) {
  18531. var templateLiterals = newObj.children.filter(function (child) {
  18532. return child.type === "JSXExpressionContainer" && child.expression.type === "TemplateLiteral";
  18533. }).map(function (container) {
  18534. return container.expression;
  18535. });
  18536. var quasis = templateLiterals.reduce(function (quasis, templateLiteral) {
  18537. return quasis.concat(templateLiteral.quasis);
  18538. }, []);
  18539. quasis.forEach(function (q) {
  18540. return delete q.value;
  18541. });
  18542. } // CSS template literals in css prop
  18543. if (ast.type === "JSXAttribute" && ast.name.name === "css" && ast.value.type === "JSXExpressionContainer" && ast.value.expression.type === "TemplateLiteral") {
  18544. newObj.value.expression.quasis.forEach(function (q) {
  18545. return delete q.value;
  18546. });
  18547. } // Angular Components: Inline HTML template and Inline CSS styles
  18548. var expression = ast.expression || ast.callee;
  18549. if (ast.type === "Decorator" && expression.type === "CallExpression" && expression.callee.name === "Component" && expression.arguments.length === 1) {
  18550. var astProps = ast.expression.arguments[0].properties;
  18551. newObj.expression.arguments[0].properties.forEach(function (prop, index) {
  18552. var templateLiteral = null;
  18553. switch (astProps[index].key.name) {
  18554. case "styles":
  18555. if (prop.value.type === "ArrayExpression") {
  18556. templateLiteral = prop.value.elements[0];
  18557. }
  18558. break;
  18559. case "template":
  18560. if (prop.value.type === "TemplateLiteral") {
  18561. templateLiteral = prop.value;
  18562. }
  18563. break;
  18564. }
  18565. if (templateLiteral) {
  18566. templateLiteral.quasis.forEach(function (q) {
  18567. return delete q.value;
  18568. });
  18569. }
  18570. });
  18571. } // styled-components, graphql, markdown
  18572. 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")) {
  18573. newObj.quasi.quasis.forEach(function (quasi) {
  18574. return delete quasi.value;
  18575. });
  18576. }
  18577. if (ast.type === "TemplateLiteral") {
  18578. // This checks for a leading comment that is exactly `/* GraphQL */`
  18579. // In order to be in line with other implementations of this comment tag
  18580. // we will not trim the comment value and we will expect exactly one space on
  18581. // either side of the GraphQL string
  18582. // Also see ./embed.js
  18583. var hasLanguageComment = ast.leadingComments && ast.leadingComments.some(function (comment) {
  18584. return comment.type === "CommentBlock" && ["GraphQL", "HTML"].some(function (languageName) {
  18585. return comment.value === " ".concat(languageName, " ");
  18586. });
  18587. });
  18588. if (hasLanguageComment || parent.type === "CallExpression" && parent.callee.name === "graphql") {
  18589. newObj.quasis.forEach(function (quasi) {
  18590. return delete quasi.value;
  18591. });
  18592. }
  18593. }
  18594. }
  18595. var clean_1$2 = clean$7;
  18596. // Flow annotation comments cannot be split across lines. For example:
  18597. //
  18598. // (this /*
  18599. // : any */).foo = 5;
  18600. //
  18601. // is not picked up by Flow (see https://github.com/facebook/flow/issues/7050), so
  18602. // removing the newline would create a type annotation that the user did not intend
  18603. // to create.
  18604. var NON_LINE_TERMINATING_WHITE_SPACE = "(?:(?=.)\\s)";
  18605. var FLOW_SHORTHAND_ANNOTATION = new RegExp("^".concat(NON_LINE_TERMINATING_WHITE_SPACE, "*:"));
  18606. var FLOW_ANNOTATION = new RegExp("^".concat(NON_LINE_TERMINATING_WHITE_SPACE, "*::"));
  18607. function hasFlowShorthandAnnotationComment$2(node) {
  18608. // https://flow.org/en/docs/types/comments/
  18609. // Syntax example: const r = new (window.Request /*: Class<Request> */)("");
  18610. return node.extra && node.extra.parenthesized && node.trailingComments && node.trailingComments[0].value.match(FLOW_SHORTHAND_ANNOTATION);
  18611. }
  18612. function hasFlowAnnotationComment$1(comments) {
  18613. return comments && comments[0].value.match(FLOW_ANNOTATION);
  18614. }
  18615. function hasNode$1(node, fn) {
  18616. if (!node || _typeof(node) !== "object") {
  18617. return false;
  18618. }
  18619. if (Array.isArray(node)) {
  18620. return node.some(function (value) {
  18621. return hasNode$1(value, fn);
  18622. });
  18623. }
  18624. var result = fn(node);
  18625. return typeof result === "boolean" ? result : Object.keys(node).some(function (key) {
  18626. return hasNode$1(node[key], fn);
  18627. });
  18628. }
  18629. function hasNakedLeftSide$2(node) {
  18630. return node.type === "AssignmentExpression" || node.type === "BinaryExpression" || node.type === "LogicalExpression" || node.type === "NGPipeExpression" || node.type === "ConditionalExpression" || node.type === "CallExpression" || node.type === "OptionalCallExpression" || node.type === "MemberExpression" || node.type === "OptionalMemberExpression" || node.type === "SequenceExpression" || node.type === "TaggedTemplateExpression" || node.type === "BindExpression" || node.type === "UpdateExpression" && !node.prefix || node.type === "TSAsExpression" || node.type === "TSNonNullExpression";
  18631. }
  18632. function getLeftSide$1(node) {
  18633. if (node.expressions) {
  18634. return node.expressions[0];
  18635. }
  18636. return node.left || node.test || node.callee || node.object || node.tag || node.argument || node.expression;
  18637. }
  18638. function getLeftSidePathName$2(path, node) {
  18639. if (node.expressions) {
  18640. return ["expressions", 0];
  18641. }
  18642. if (node.left) {
  18643. return ["left"];
  18644. }
  18645. if (node.test) {
  18646. return ["test"];
  18647. }
  18648. if (node.object) {
  18649. return ["object"];
  18650. }
  18651. if (node.callee) {
  18652. return ["callee"];
  18653. }
  18654. if (node.tag) {
  18655. return ["tag"];
  18656. }
  18657. if (node.argument) {
  18658. return ["argument"];
  18659. }
  18660. if (node.expression) {
  18661. return ["expression"];
  18662. }
  18663. throw new Error("Unexpected node has no left side", node);
  18664. }
  18665. var utils$8 = {
  18666. getLeftSide: getLeftSide$1,
  18667. getLeftSidePathName: getLeftSidePathName$2,
  18668. hasNakedLeftSide: hasNakedLeftSide$2,
  18669. hasNode: hasNode$1,
  18670. hasFlowShorthandAnnotationComment: hasFlowShorthandAnnotationComment$2,
  18671. hasFlowAnnotationComment: hasFlowAnnotationComment$1
  18672. };
  18673. var getLeftSidePathName$1 = utils$8.getLeftSidePathName;
  18674. var hasNakedLeftSide$1 = utils$8.hasNakedLeftSide;
  18675. var hasFlowShorthandAnnotationComment$1 = utils$8.hasFlowShorthandAnnotationComment;
  18676. function hasClosureCompilerTypeCastComment(text, path) {
  18677. // https://github.com/google/closure-compiler/wiki/Annotating-Types#type-casts
  18678. // Syntax example: var x = /** @type {string} */ (fruit);
  18679. var n = path.getValue();
  18680. return isParenthesized(n) && (hasTypeCastComment(n) || hasAncestorTypeCastComment(0)); // for sub-item: /** @type {array} */ (numberOrString).map(x => x);
  18681. function hasAncestorTypeCastComment(index) {
  18682. var ancestor = path.getParentNode(index);
  18683. return ancestor && !isParenthesized(ancestor) ? hasTypeCastComment(ancestor) || hasAncestorTypeCastComment(index + 1) : false;
  18684. }
  18685. function hasTypeCastComment(node) {
  18686. return node.comments && node.comments.some(function (comment) {
  18687. return comment.leading && comments$3.isBlockComment(comment) && isTypeCastComment(comment.value);
  18688. });
  18689. }
  18690. function isParenthesized(node) {
  18691. // Closure typecast comments only really make sense when _not_ using
  18692. // typescript or flow parsers, so we take advantage of the babel parser's
  18693. // parenthesized expressions.
  18694. return node.extra && node.extra.parenthesized;
  18695. }
  18696. function isTypeCastComment(comment) {
  18697. var cleaned = comment.trim().split("\n").map(function (line) {
  18698. return line.replace(/^[\s*]+/, "");
  18699. }).join(" ").trim();
  18700. if (!/^@type\s*\{[^]+\}$/.test(cleaned)) {
  18701. return false;
  18702. }
  18703. var isCompletelyClosed = false;
  18704. var unpairedBracketCount = 0;
  18705. var _iteratorNormalCompletion = true;
  18706. var _didIteratorError = false;
  18707. var _iteratorError = undefined;
  18708. try {
  18709. for (var _iterator = cleaned[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  18710. var char = _step.value;
  18711. if (char === "{") {
  18712. if (isCompletelyClosed) {
  18713. return false;
  18714. }
  18715. unpairedBracketCount++;
  18716. } else if (char === "}") {
  18717. if (unpairedBracketCount === 0) {
  18718. return false;
  18719. }
  18720. unpairedBracketCount--;
  18721. if (unpairedBracketCount === 0) {
  18722. isCompletelyClosed = true;
  18723. }
  18724. }
  18725. }
  18726. } catch (err) {
  18727. _didIteratorError = true;
  18728. _iteratorError = err;
  18729. } finally {
  18730. try {
  18731. if (!_iteratorNormalCompletion && _iterator.return != null) {
  18732. _iterator.return();
  18733. }
  18734. } finally {
  18735. if (_didIteratorError) {
  18736. throw _iteratorError;
  18737. }
  18738. }
  18739. }
  18740. return unpairedBracketCount === 0;
  18741. }
  18742. }
  18743. function needsParens(path, options) {
  18744. var parent = path.getParentNode();
  18745. if (!parent) {
  18746. return false;
  18747. }
  18748. var name = path.getName();
  18749. var node = path.getNode(); // If the value of this path is some child of a Node and not a Node
  18750. // itself, then it doesn't need parentheses. Only Node objects (in
  18751. // fact, only Expression nodes) need parentheses.
  18752. if (path.getValue() !== node) {
  18753. return false;
  18754. } // to avoid unexpected `}}` in HTML interpolations
  18755. if (options.__isInHtmlInterpolation && !options.bracketSpacing && endsWithRightBracket(node) && isFollowedByRightBracket(path)) {
  18756. return true;
  18757. } // Only statements don't need parentheses.
  18758. if (isStatement(node)) {
  18759. return false;
  18760. } // Closure compiler requires that type casted expressions to be surrounded by
  18761. // parentheses.
  18762. if (hasClosureCompilerTypeCastComment(options.originalText, path)) {
  18763. return true;
  18764. }
  18765. if ( // Preserve parens if we have a Flow annotation comment, unless we're using the Flow
  18766. // parser. The Flow parser turns Flow comments into type annotation nodes in its
  18767. // AST, which we handle separately.
  18768. options.parser !== "flow" && hasFlowShorthandAnnotationComment$1(path.getValue())) {
  18769. return true;
  18770. } // Identifiers never need parentheses.
  18771. if (node.type === "Identifier") {
  18772. // ...unless those identifiers are embed placeholders. They might be substituted by complex
  18773. // expressions, so the parens around them should not be dropped. Example (JS-in-HTML-in-JS):
  18774. // let tpl = html`<script> f((${expr}) / 2); </script>`;
  18775. // If the inner JS formatter removes the parens, the expression might change its meaning:
  18776. // f((a + b) / 2) vs f(a + b / 2)
  18777. if (node.extra && node.extra.parenthesized && /^PRETTIER_HTML_PLACEHOLDER_\d+_\d+_IN_JS$/.test(node.name)) {
  18778. return true;
  18779. }
  18780. return false;
  18781. }
  18782. if (parent.type === "ParenthesizedExpression") {
  18783. return false;
  18784. } // Add parens around the extends clause of a class. It is needed for almost
  18785. // all expressions.
  18786. 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")) {
  18787. return true;
  18788. } // `export default function` or `export default class` can't be followed by
  18789. // anything after. So an expression like `export default (function(){}).toString()`
  18790. // needs to be followed by a parentheses
  18791. if (parent.type === "ExportDefaultDeclaration") {
  18792. return shouldWrapFunctionForExportDefault(path, options);
  18793. }
  18794. if (parent.type === "Decorator" && parent.expression === node) {
  18795. var hasCallExpression = false;
  18796. var hasMemberExpression = false;
  18797. var current = node;
  18798. while (current) {
  18799. switch (current.type) {
  18800. case "MemberExpression":
  18801. hasMemberExpression = true;
  18802. current = current.object;
  18803. break;
  18804. case "CallExpression":
  18805. if (
  18806. /** @(x().y) */
  18807. hasMemberExpression ||
  18808. /** @(x().y()) */
  18809. hasCallExpression) {
  18810. return true;
  18811. }
  18812. hasCallExpression = true;
  18813. current = current.callee;
  18814. break;
  18815. case "Identifier":
  18816. return false;
  18817. default:
  18818. return true;
  18819. }
  18820. }
  18821. return true;
  18822. }
  18823. if (parent.type === "ArrowFunctionExpression" && parent.body === node && node.type !== "SequenceExpression" && // these have parens added anyway
  18824. util.startsWithNoLookaheadToken(node,
  18825. /* forbidFunctionClassAndDoExpr */
  18826. false) || parent.type === "ExpressionStatement" && util.startsWithNoLookaheadToken(node,
  18827. /* forbidFunctionClassAndDoExpr */
  18828. true)) {
  18829. return true;
  18830. }
  18831. switch (node.type) {
  18832. case "CallExpression":
  18833. {
  18834. var firstParentNotMemberExpression = parent;
  18835. var i = 0; // tagged templates are basically member expressions from a grammar perspective
  18836. // see https://tc39.github.io/ecma262/#prod-MemberExpression
  18837. // so are typescript's non-null assertions, though there's no grammar to point to
  18838. while (firstParentNotMemberExpression && (firstParentNotMemberExpression.type === "MemberExpression" && firstParentNotMemberExpression.object === path.getParentNode(i - 1) || firstParentNotMemberExpression.type === "TaggedTemplateExpression" || firstParentNotMemberExpression.type === "TSNonNullExpression")) {
  18839. firstParentNotMemberExpression = path.getParentNode(++i);
  18840. }
  18841. if (firstParentNotMemberExpression.type === "NewExpression" && firstParentNotMemberExpression.callee === path.getParentNode(i - 1)) {
  18842. return true;
  18843. }
  18844. if (parent.type === "BindExpression" && parent.callee === node) {
  18845. return true;
  18846. }
  18847. return false;
  18848. }
  18849. case "SpreadElement":
  18850. case "SpreadProperty":
  18851. return parent.type === "MemberExpression" && name === "object" && parent.object === node;
  18852. case "UpdateExpression":
  18853. if (parent.type === "UnaryExpression") {
  18854. return node.prefix && (node.operator === "++" && parent.operator === "+" || node.operator === "--" && parent.operator === "-");
  18855. }
  18856. // else fallthrough
  18857. case "UnaryExpression":
  18858. switch (parent.type) {
  18859. case "UnaryExpression":
  18860. return node.operator === parent.operator && (node.operator === "+" || node.operator === "-");
  18861. case "BindExpression":
  18862. return true;
  18863. case "MemberExpression":
  18864. return name === "object" && parent.object === node;
  18865. case "TaggedTemplateExpression":
  18866. return true;
  18867. case "NewExpression":
  18868. case "CallExpression":
  18869. return name === "callee" && parent.callee === node;
  18870. case "BinaryExpression":
  18871. return parent.operator === "**" && name === "left";
  18872. case "TSNonNullExpression":
  18873. return true;
  18874. default:
  18875. return false;
  18876. }
  18877. case "BinaryExpression":
  18878. {
  18879. if (parent.type === "UpdateExpression") {
  18880. return true;
  18881. }
  18882. var isLeftOfAForStatement = function isLeftOfAForStatement(node) {
  18883. var i = 0;
  18884. while (node) {
  18885. var _parent = path.getParentNode(i++);
  18886. if (!_parent) {
  18887. return false;
  18888. }
  18889. if (_parent.type === "ForStatement" && _parent.init === node) {
  18890. return true;
  18891. }
  18892. node = _parent;
  18893. }
  18894. return false;
  18895. };
  18896. if (node.operator === "in" && isLeftOfAForStatement(node)) {
  18897. return true;
  18898. }
  18899. }
  18900. // fallthrough
  18901. case "TSTypeAssertion":
  18902. case "TSAsExpression":
  18903. case "LogicalExpression":
  18904. switch (parent.type) {
  18905. case "ConditionalExpression":
  18906. return node.type === "TSAsExpression";
  18907. case "CallExpression":
  18908. case "NewExpression":
  18909. return name === "callee" && parent.callee === node;
  18910. case "ClassExpression":
  18911. case "ClassDeclaration":
  18912. return name === "superClass" && parent.superClass === node;
  18913. case "TSTypeAssertion":
  18914. case "TaggedTemplateExpression":
  18915. case "UnaryExpression":
  18916. case "JSXSpreadAttribute":
  18917. case "SpreadElement":
  18918. case "SpreadProperty":
  18919. case "BindExpression":
  18920. case "AwaitExpression":
  18921. case "TSAsExpression":
  18922. case "TSNonNullExpression":
  18923. case "UpdateExpression":
  18924. return true;
  18925. case "MemberExpression":
  18926. case "OptionalMemberExpression":
  18927. return name === "object" && parent.object === node;
  18928. case "AssignmentExpression":
  18929. return parent.left === node && (node.type === "TSTypeAssertion" || node.type === "TSAsExpression");
  18930. case "BinaryExpression":
  18931. case "LogicalExpression":
  18932. {
  18933. if (!node.operator && node.type !== "TSTypeAssertion") {
  18934. return true;
  18935. }
  18936. var po = parent.operator;
  18937. var pp = util.getPrecedence(po);
  18938. var no = node.operator;
  18939. var np = util.getPrecedence(no);
  18940. if (pp > np) {
  18941. return true;
  18942. }
  18943. if ((po === "||" || po === "??") && no === "&&") {
  18944. return true;
  18945. }
  18946. if (pp === np && name === "right") {
  18947. assert$3.strictEqual(parent.right, node);
  18948. return true;
  18949. }
  18950. if (pp === np && !util.shouldFlatten(po, no)) {
  18951. return true;
  18952. }
  18953. if (pp < np && no === "%") {
  18954. return po === "+" || po === "-";
  18955. } // Add parenthesis when working with bitwise operators
  18956. // It's not stricly needed but helps with code understanding
  18957. if (util.isBitwiseOperator(po)) {
  18958. return true;
  18959. }
  18960. return false;
  18961. }
  18962. default:
  18963. return false;
  18964. }
  18965. case "TSParenthesizedType":
  18966. {
  18967. var grandParent = path.getParentNode(1);
  18968. /**
  18969. * const foo = (): (() => void) => (): void => null;
  18970. * ^ ^
  18971. */
  18972. if (getUnparenthesizedNode(node).type === "TSFunctionType" && parent.type === "TSTypeAnnotation" && grandParent.type === "ArrowFunctionExpression" && grandParent.returnType === parent) {
  18973. return true;
  18974. }
  18975. 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") {
  18976. return false;
  18977. } // Delegate to inner TSParenthesizedType
  18978. if (node.typeAnnotation.type === "TSParenthesizedType" && parent.type !== "TSArrayType") {
  18979. return false;
  18980. }
  18981. return true;
  18982. }
  18983. case "SequenceExpression":
  18984. switch (parent.type) {
  18985. case "ReturnStatement":
  18986. return false;
  18987. case "ForStatement":
  18988. // Although parentheses wouldn't hurt around sequence
  18989. // expressions in the head of for loops, traditional style
  18990. // dictates that e.g. i++, j++ should not be wrapped with
  18991. // parentheses.
  18992. return false;
  18993. case "ExpressionStatement":
  18994. return name !== "expression";
  18995. case "ArrowFunctionExpression":
  18996. // We do need parentheses, but SequenceExpressions are handled
  18997. // specially when printing bodies of arrow functions.
  18998. return name !== "body";
  18999. default:
  19000. // Otherwise err on the side of overparenthesization, adding
  19001. // explicit exceptions above if this proves overzealous.
  19002. return true;
  19003. }
  19004. case "YieldExpression":
  19005. if (parent.type === "UnaryExpression" || parent.type === "AwaitExpression" || parent.type === "TSAsExpression" || parent.type === "TSNonNullExpression") {
  19006. return true;
  19007. }
  19008. // else fallthrough
  19009. case "AwaitExpression":
  19010. switch (parent.type) {
  19011. case "TaggedTemplateExpression":
  19012. case "UnaryExpression":
  19013. case "BinaryExpression":
  19014. case "LogicalExpression":
  19015. case "SpreadElement":
  19016. case "SpreadProperty":
  19017. case "TSAsExpression":
  19018. case "TSNonNullExpression":
  19019. case "BindExpression":
  19020. case "OptionalMemberExpression":
  19021. return true;
  19022. case "MemberExpression":
  19023. return parent.object === node;
  19024. case "NewExpression":
  19025. case "CallExpression":
  19026. return parent.callee === node;
  19027. case "ConditionalExpression":
  19028. return parent.test === node;
  19029. default:
  19030. return false;
  19031. }
  19032. case "ArrayTypeAnnotation":
  19033. return parent.type === "NullableTypeAnnotation";
  19034. case "IntersectionTypeAnnotation":
  19035. case "UnionTypeAnnotation":
  19036. return parent.type === "ArrayTypeAnnotation" || parent.type === "NullableTypeAnnotation" || parent.type === "IntersectionTypeAnnotation" || parent.type === "UnionTypeAnnotation";
  19037. case "NullableTypeAnnotation":
  19038. return parent.type === "ArrayTypeAnnotation";
  19039. case "FunctionTypeAnnotation":
  19040. {
  19041. var ancestor = parent.type === "NullableTypeAnnotation" ? path.getParentNode(1) : parent;
  19042. return ancestor.type === "UnionTypeAnnotation" || ancestor.type === "IntersectionTypeAnnotation" || ancestor.type === "ArrayTypeAnnotation" || // We should check ancestor's parent to know whether the parentheses
  19043. // are really needed, but since ??T doesn't make sense this check
  19044. // will almost never be true.
  19045. ancestor.type === "NullableTypeAnnotation";
  19046. }
  19047. case "StringLiteral":
  19048. case "NumericLiteral":
  19049. case "Literal":
  19050. if (typeof node.value === "string" && parent.type === "ExpressionStatement" && ( // TypeScript workaround for https://github.com/JamesHenry/typescript-estree/issues/2
  19051. // See corresponding workaround in printer.js case: "Literal"
  19052. options.parser !== "typescript" && !parent.directive || options.parser === "typescript" && options.originalText.substr(options.locStart(node) - 1, 1) === "(")) {
  19053. // To avoid becoming a directive
  19054. var _grandParent = path.getParentNode(1);
  19055. return _grandParent.type === "Program" || _grandParent.type === "BlockStatement";
  19056. }
  19057. return parent.type === "MemberExpression" && typeof node.value === "number" && name === "object" && parent.object === node;
  19058. case "AssignmentExpression":
  19059. {
  19060. var _grandParent2 = path.getParentNode(1);
  19061. if (parent.type === "ArrowFunctionExpression" && parent.body === node) {
  19062. return true;
  19063. } else if (parent.type === "ClassProperty" && parent.key === node && parent.computed) {
  19064. return false;
  19065. } else if (parent.type === "TSPropertySignature" && parent.name === node) {
  19066. return false;
  19067. } else if (parent.type === "ForStatement" && (parent.init === node || parent.update === node)) {
  19068. return false;
  19069. } else if (parent.type === "ExpressionStatement") {
  19070. return node.left.type === "ObjectPattern";
  19071. } else if (parent.type === "TSPropertySignature" && parent.key === node) {
  19072. return false;
  19073. } else if (parent.type === "AssignmentExpression") {
  19074. return false;
  19075. } else if (parent.type === "SequenceExpression" && _grandParent2 && _grandParent2.type === "ForStatement" && (_grandParent2.init === parent || _grandParent2.update === parent)) {
  19076. return false;
  19077. } else if (parent.type === "Property" && parent.value === node) {
  19078. return false;
  19079. } else if (parent.type === "NGChainedExpression") {
  19080. return false;
  19081. }
  19082. return true;
  19083. }
  19084. case "ConditionalExpression":
  19085. switch (parent.type) {
  19086. case "TaggedTemplateExpression":
  19087. case "UnaryExpression":
  19088. case "SpreadElement":
  19089. case "SpreadProperty":
  19090. case "BinaryExpression":
  19091. case "LogicalExpression":
  19092. case "NGPipeExpression":
  19093. case "ExportDefaultDeclaration":
  19094. case "AwaitExpression":
  19095. case "JSXSpreadAttribute":
  19096. case "TSTypeAssertion":
  19097. case "TypeCastExpression":
  19098. case "TSAsExpression":
  19099. case "TSNonNullExpression":
  19100. case "OptionalMemberExpression":
  19101. return true;
  19102. case "NewExpression":
  19103. case "CallExpression":
  19104. return name === "callee" && parent.callee === node;
  19105. case "ConditionalExpression":
  19106. return name === "test" && parent.test === node;
  19107. case "MemberExpression":
  19108. return name === "object" && parent.object === node;
  19109. default:
  19110. return false;
  19111. }
  19112. case "FunctionExpression":
  19113. switch (parent.type) {
  19114. case "NewExpression":
  19115. case "CallExpression":
  19116. return name === "callee";
  19117. // Not strictly necessary, but it's clearer to the reader if IIFEs are wrapped in parentheses.
  19118. case "TaggedTemplateExpression":
  19119. return true;
  19120. // This is basically a kind of IIFE.
  19121. default:
  19122. return false;
  19123. }
  19124. case "ArrowFunctionExpression":
  19125. switch (parent.type) {
  19126. case "CallExpression":
  19127. return name === "callee";
  19128. case "NewExpression":
  19129. return name === "callee";
  19130. case "MemberExpression":
  19131. return name === "object";
  19132. case "TSAsExpression":
  19133. case "BindExpression":
  19134. case "TaggedTemplateExpression":
  19135. case "UnaryExpression":
  19136. case "LogicalExpression":
  19137. case "BinaryExpression":
  19138. case "AwaitExpression":
  19139. case "TSTypeAssertion":
  19140. return true;
  19141. case "ConditionalExpression":
  19142. return name === "test";
  19143. default:
  19144. return false;
  19145. }
  19146. case "ClassExpression":
  19147. switch (parent.type) {
  19148. case "NewExpression":
  19149. return name === "callee" && parent.callee === node;
  19150. default:
  19151. return false;
  19152. }
  19153. case "OptionalMemberExpression":
  19154. return parent.type === "MemberExpression";
  19155. case "MemberExpression":
  19156. if (parent.type === "BindExpression" && name === "callee" && parent.callee === node) {
  19157. var object = node.object;
  19158. while (object) {
  19159. if (object.type === "CallExpression") {
  19160. return true;
  19161. }
  19162. if (object.type !== "MemberExpression" && object.type !== "BindExpression") {
  19163. break;
  19164. }
  19165. object = object.object;
  19166. }
  19167. }
  19168. return false;
  19169. case "BindExpression":
  19170. if (parent.type === "BindExpression" && name === "callee" && parent.callee === node || parent.type === "MemberExpression" && name === "object" && parent.object === node || parent.type === "NewExpression" && name === "callee" && parent.callee === node) {
  19171. return true;
  19172. }
  19173. return false;
  19174. case "NGPipeExpression":
  19175. if (parent.type === "NGRoot" || parent.type === "NGMicrosyntaxExpression" || parent.type === "ObjectProperty" || parent.type === "ArrayExpression" || (parent.type === "CallExpression" || parent.type === "OptionalCallExpression") && parent.arguments[name] === node || parent.type === "NGPipeExpression" && name === "right" || parent.type === "MemberExpression" && name === "property" || parent.type === "AssignmentExpression") {
  19176. return false;
  19177. }
  19178. return true;
  19179. }
  19180. return false;
  19181. }
  19182. function isStatement(node) {
  19183. return node.type === "BlockStatement" || node.type === "BreakStatement" || node.type === "ClassBody" || node.type === "ClassDeclaration" || node.type === "ClassMethod" || node.type === "ClassProperty" || node.type === "ClassPrivateProperty" || node.type === "ContinueStatement" || node.type === "DebuggerStatement" || node.type === "DeclareClass" || node.type === "DeclareExportAllDeclaration" || node.type === "DeclareExportDeclaration" || node.type === "DeclareFunction" || node.type === "DeclareInterface" || node.type === "DeclareModule" || node.type === "DeclareModuleExports" || node.type === "DeclareVariable" || node.type === "DoWhileStatement" || node.type === "ExportAllDeclaration" || node.type === "ExportDefaultDeclaration" || node.type === "ExportNamedDeclaration" || node.type === "ExpressionStatement" || node.type === "ForAwaitStatement" || node.type === "ForInStatement" || node.type === "ForOfStatement" || node.type === "ForStatement" || node.type === "FunctionDeclaration" || node.type === "IfStatement" || node.type === "ImportDeclaration" || node.type === "InterfaceDeclaration" || node.type === "LabeledStatement" || node.type === "MethodDefinition" || node.type === "ReturnStatement" || node.type === "SwitchStatement" || node.type === "ThrowStatement" || node.type === "TryStatement" || node.type === "TSDeclareFunction" || node.type === "TSEnumDeclaration" || node.type === "TSImportEqualsDeclaration" || node.type === "TSInterfaceDeclaration" || node.type === "TSModuleDeclaration" || node.type === "TSNamespaceExportDeclaration" || node.type === "TypeAlias" || node.type === "VariableDeclaration" || node.type === "WhileStatement" || node.type === "WithStatement";
  19184. }
  19185. function getUnparenthesizedNode(node) {
  19186. return node.type === "TSParenthesizedType" ? getUnparenthesizedNode(node.typeAnnotation) : node;
  19187. }
  19188. function endsWithRightBracket(node) {
  19189. switch (node.type) {
  19190. case "ObjectExpression":
  19191. return true;
  19192. default:
  19193. return false;
  19194. }
  19195. }
  19196. function isFollowedByRightBracket(path) {
  19197. var node = path.getValue();
  19198. var parent = path.getParentNode();
  19199. var name = path.getName();
  19200. switch (parent.type) {
  19201. case "NGPipeExpression":
  19202. if (typeof name === "number" && parent.arguments[name] === node && parent.arguments.length - 1 === name) {
  19203. return path.callParent(isFollowedByRightBracket);
  19204. }
  19205. break;
  19206. case "ObjectProperty":
  19207. if (name === "value") {
  19208. var parentParent = path.getParentNode(1);
  19209. return parentParent.properties[parentParent.properties.length - 1] === parent;
  19210. }
  19211. break;
  19212. case "BinaryExpression":
  19213. case "LogicalExpression":
  19214. if (name === "right") {
  19215. return path.callParent(isFollowedByRightBracket);
  19216. }
  19217. break;
  19218. case "ConditionalExpression":
  19219. if (name === "alternate") {
  19220. return path.callParent(isFollowedByRightBracket);
  19221. }
  19222. break;
  19223. case "UnaryExpression":
  19224. if (parent.prefix) {
  19225. return path.callParent(isFollowedByRightBracket);
  19226. }
  19227. break;
  19228. }
  19229. return false;
  19230. }
  19231. function shouldWrapFunctionForExportDefault(path, options) {
  19232. var node = path.getValue();
  19233. var parent = path.getParentNode();
  19234. if (node.type === "FunctionExpression" || node.type === "ClassExpression") {
  19235. return parent.type === "ExportDefaultDeclaration" || // in some cases the function is already wrapped
  19236. // (e.g. `export default (function() {})();`)
  19237. // in this case we don't need to add extra parens
  19238. !needsParens(path, options);
  19239. }
  19240. if (!hasNakedLeftSide$1(node) || parent.type !== "ExportDefaultDeclaration" && needsParens(path, options)) {
  19241. return false;
  19242. }
  19243. return path.call.apply(path, [function (childPath) {
  19244. return shouldWrapFunctionForExportDefault(childPath, options);
  19245. }].concat(getLeftSidePathName$1(path, node)));
  19246. }
  19247. var needsParens_1 = needsParens;
  19248. var _require$$0$builders$6 = doc.builders;
  19249. var concat$13 = _require$$0$builders$6.concat;
  19250. var join$9 = _require$$0$builders$6.join;
  19251. var line$9 = _require$$0$builders$6.line;
  19252. function printHtmlBinding$1(path, options, print) {
  19253. var node = path.getValue();
  19254. if (options.__onHtmlBindingRoot && path.getName() === null) {
  19255. options.__onHtmlBindingRoot(node);
  19256. }
  19257. if (node.type !== "File") {
  19258. return;
  19259. }
  19260. if (options.__isVueForBindingLeft) {
  19261. return path.call(function (functionDeclarationPath) {
  19262. var _functionDeclarationP = functionDeclarationPath.getValue(),
  19263. params = _functionDeclarationP.params;
  19264. return concat$13([params.length > 1 ? "(" : "", join$9(concat$13([",", line$9]), functionDeclarationPath.map(print, "params")), params.length > 1 ? ")" : ""]);
  19265. }, "program", "body", 0);
  19266. }
  19267. if (options.__isVueSlotScope) {
  19268. return path.call(function (functionDeclarationPath) {
  19269. return join$9(concat$13([",", line$9]), functionDeclarationPath.map(print, "params"));
  19270. }, "program", "body", 0);
  19271. }
  19272. } // based on https://github.com/prettier/prettier/blob/master/src/language-html/syntax-vue.js isVueEventBindingExpression()
  19273. function isVueEventBindingExpression$3(node) {
  19274. switch (node.type) {
  19275. case "MemberExpression":
  19276. switch (node.property.type) {
  19277. case "Identifier":
  19278. case "NumericLiteral":
  19279. case "StringLiteral":
  19280. return isVueEventBindingExpression$3(node.object);
  19281. }
  19282. return false;
  19283. case "Identifier":
  19284. return true;
  19285. default:
  19286. return false;
  19287. }
  19288. }
  19289. var htmlBinding = {
  19290. isVueEventBindingExpression: isVueEventBindingExpression$3,
  19291. printHtmlBinding: printHtmlBinding$1
  19292. };
  19293. function preprocess$2(ast, options) {
  19294. switch (options.parser) {
  19295. case "json":
  19296. case "json5":
  19297. case "json-stringify":
  19298. case "__js_expression":
  19299. case "__vue_expression":
  19300. return Object.assign({}, ast, {
  19301. type: options.parser.startsWith("__") ? "JsExpressionRoot" : "JsonRoot",
  19302. node: ast,
  19303. comments: []
  19304. });
  19305. default:
  19306. return ast;
  19307. }
  19308. }
  19309. var preprocess_1$2 = preprocess$2;
  19310. var getParentExportDeclaration$1 = util.getParentExportDeclaration;
  19311. var isExportDeclaration$1 = util.isExportDeclaration;
  19312. var shouldFlatten$1 = util.shouldFlatten;
  19313. var getNextNonSpaceNonCommentCharacter$1 = util.getNextNonSpaceNonCommentCharacter;
  19314. var hasNewline$3 = util.hasNewline;
  19315. var hasNewlineInRange$1 = util.hasNewlineInRange;
  19316. var getLast$3 = util.getLast;
  19317. var getStringWidth$2 = util.getStringWidth;
  19318. var printString$2 = util.printString;
  19319. var printNumber$2 = util.printNumber;
  19320. var hasIgnoreComment$3 = util.hasIgnoreComment;
  19321. var skipWhitespace$1 = util.skipWhitespace;
  19322. var hasNodeIgnoreComment$1 = util.hasNodeIgnoreComment;
  19323. var getPenultimate$1 = util.getPenultimate;
  19324. var startsWithNoLookaheadToken$1 = util.startsWithNoLookaheadToken;
  19325. var getIndentSize$1 = util.getIndentSize;
  19326. var matchAncestorTypes$1 = util.matchAncestorTypes;
  19327. var getPreferredQuote$1 = util.getPreferredQuote;
  19328. var isNextLineEmpty$4 = utilShared.isNextLineEmpty;
  19329. var isNextLineEmptyAfterIndex$1 = utilShared.isNextLineEmptyAfterIndex;
  19330. var getNextNonSpaceNonCommentCharacterIndex$2 = utilShared.getNextNonSpaceNonCommentCharacterIndex;
  19331. var isIdentifierName = utils$2.keyword.isIdentifierNameES5;
  19332. var insertPragma$7 = pragma$2.insertPragma;
  19333. var printHtmlBinding = htmlBinding.printHtmlBinding;
  19334. var isVueEventBindingExpression$2 = htmlBinding.isVueEventBindingExpression;
  19335. var getLeftSide = utils$8.getLeftSide;
  19336. var getLeftSidePathName = utils$8.getLeftSidePathName;
  19337. var hasNakedLeftSide = utils$8.hasNakedLeftSide;
  19338. var hasNode = utils$8.hasNode;
  19339. var hasFlowAnnotationComment = utils$8.hasFlowAnnotationComment;
  19340. var hasFlowShorthandAnnotationComment = utils$8.hasFlowShorthandAnnotationComment;
  19341. var needsQuoteProps = new WeakMap();
  19342. var _require$$6$builders = doc.builders;
  19343. var concat$11 = _require$$6$builders.concat;
  19344. var join$7 = _require$$6$builders.join;
  19345. var line$8 = _require$$6$builders.line;
  19346. var hardline$8 = _require$$6$builders.hardline;
  19347. var softline$5 = _require$$6$builders.softline;
  19348. var literalline$3 = _require$$6$builders.literalline;
  19349. var group$10 = _require$$6$builders.group;
  19350. var indent$6 = _require$$6$builders.indent;
  19351. var align$1 = _require$$6$builders.align;
  19352. var conditionalGroup$1 = _require$$6$builders.conditionalGroup;
  19353. var fill$4 = _require$$6$builders.fill;
  19354. var ifBreak$6 = _require$$6$builders.ifBreak;
  19355. var breakParent$3 = _require$$6$builders.breakParent;
  19356. var lineSuffixBoundary$1 = _require$$6$builders.lineSuffixBoundary;
  19357. var addAlignmentToDoc$2 = _require$$6$builders.addAlignmentToDoc;
  19358. var dedent$3 = _require$$6$builders.dedent;
  19359. var _require$$6$utils = doc.utils;
  19360. var willBreak$1 = _require$$6$utils.willBreak;
  19361. var isLineNext$1 = _require$$6$utils.isLineNext;
  19362. var isEmpty$1 = _require$$6$utils.isEmpty;
  19363. var removeLines$2 = _require$$6$utils.removeLines;
  19364. var printDocToString$1 = doc.printer.printDocToString;
  19365. var uid = 0;
  19366. function shouldPrintComma$1(options, level) {
  19367. level = level || "es5";
  19368. switch (options.trailingComma) {
  19369. case "all":
  19370. if (level === "all") {
  19371. return true;
  19372. }
  19373. // fallthrough
  19374. case "es5":
  19375. if (level === "es5") {
  19376. return true;
  19377. }
  19378. // fallthrough
  19379. case "none":
  19380. default:
  19381. return false;
  19382. }
  19383. }
  19384. function genericPrint$3(path, options, printPath, args) {
  19385. var node = path.getValue();
  19386. var needsParens = false;
  19387. var linesWithoutParens = printPathNoParens(path, options, printPath, args);
  19388. if (!node || isEmpty$1(linesWithoutParens)) {
  19389. return linesWithoutParens;
  19390. }
  19391. var parentExportDecl = getParentExportDeclaration$1(path);
  19392. var decorators = [];
  19393. 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
  19394. } else if (node.decorators && node.decorators.length > 0 && // If the parent node is an export declaration and the decorator
  19395. // was written before the export, the export will be responsible
  19396. // for printing the decorators.
  19397. !(parentExportDecl && options.locStart(parentExportDecl, {
  19398. ignoreDecorators: true
  19399. }) > options.locStart(node.decorators[0]))) {
  19400. var shouldBreak = node.type === "ClassExpression" || node.type === "ClassDeclaration" || hasNewlineBetweenOrAfterDecorators(node, options);
  19401. var separator = shouldBreak ? hardline$8 : line$8;
  19402. path.each(function (decoratorPath) {
  19403. var decorator = decoratorPath.getValue();
  19404. if (decorator.expression) {
  19405. decorator = decorator.expression;
  19406. } else {
  19407. decorator = decorator.callee;
  19408. }
  19409. decorators.push(printPath(decoratorPath), separator);
  19410. }, "decorators");
  19411. if (parentExportDecl) {
  19412. decorators.unshift(hardline$8);
  19413. }
  19414. } 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,
  19415. // otherwise they are printed by the node.declaration
  19416. options.locStart(node, {
  19417. ignoreDecorators: true
  19418. }) > options.locStart(node.declaration.decorators[0])) {
  19419. // Export declarations are responsible for printing any decorators
  19420. // that logically apply to node.declaration.
  19421. path.each(function (decoratorPath) {
  19422. var decorator = decoratorPath.getValue();
  19423. var prefix = decorator.type === "Decorator" ? "" : "@";
  19424. decorators.push(prefix, printPath(decoratorPath), hardline$8);
  19425. }, "declaration", "decorators");
  19426. } else {
  19427. // Nodes with decorators can't have parentheses, so we can avoid
  19428. // computing pathNeedsParens() except in this case.
  19429. needsParens = needsParens_1(path, options);
  19430. }
  19431. var parts = [];
  19432. if (needsParens) {
  19433. parts.unshift("(");
  19434. }
  19435. parts.push(linesWithoutParens);
  19436. if (needsParens) {
  19437. var _node = path.getValue();
  19438. if (hasFlowShorthandAnnotationComment(_node)) {
  19439. parts.push(" /*");
  19440. parts.push(_node.trailingComments[0].value.trimLeft());
  19441. parts.push("*/");
  19442. _node.trailingComments[0].printed = true;
  19443. }
  19444. parts.push(")");
  19445. }
  19446. if (decorators.length > 0) {
  19447. return group$10(concat$11(decorators.concat(parts)));
  19448. }
  19449. return concat$11(parts);
  19450. }
  19451. function hasNewlineBetweenOrAfterDecorators(node, options) {
  19452. return hasNewlineInRange$1(options.originalText, options.locStart(node.decorators[0]), options.locEnd(getLast$3(node.decorators))) || hasNewline$3(options.originalText, options.locEnd(getLast$3(node.decorators)));
  19453. }
  19454. function printDecorators(path, options, print) {
  19455. var node = path.getValue();
  19456. return group$10(concat$11([join$7(line$8, path.map(print, "decorators")), hasNewlineBetweenOrAfterDecorators(node, options) ? hardline$8 : line$8]));
  19457. }
  19458. function hasPrettierIgnore$2(path) {
  19459. return hasIgnoreComment$3(path) || hasJsxIgnoreComment(path);
  19460. }
  19461. function hasJsxIgnoreComment(path) {
  19462. var node = path.getValue();
  19463. var parent = path.getParentNode();
  19464. if (!parent || !node || !isJSXNode(node) || !isJSXNode(parent)) {
  19465. return false;
  19466. } // Lookup the previous sibling, ignoring any empty JSXText elements
  19467. var index = parent.children.indexOf(node);
  19468. var prevSibling = null;
  19469. for (var i = index; i > 0; i--) {
  19470. var candidate = parent.children[i - 1];
  19471. if (candidate.type === "JSXText" && !isMeaningfulJSXText(candidate)) {
  19472. continue;
  19473. }
  19474. prevSibling = candidate;
  19475. break;
  19476. }
  19477. return prevSibling && prevSibling.type === "JSXExpressionContainer" && prevSibling.expression.type === "JSXEmptyExpression" && prevSibling.expression.comments && prevSibling.expression.comments.find(function (comment) {
  19478. return comment.value.trim() === "prettier-ignore";
  19479. });
  19480. }
  19481. /**
  19482. * The following is the shared logic for
  19483. * ternary operators, namely ConditionalExpression
  19484. * and TSConditionalType
  19485. * @typedef {Object} OperatorOptions
  19486. * @property {() => Array<string | Doc>} beforeParts - Parts to print before the `?`.
  19487. * @property {(breakClosingParen: boolean) => Array<string | Doc>} afterParts - Parts to print after the conditional expression.
  19488. * @property {boolean} shouldCheckJsx - Whether to check for and print in JSX mode.
  19489. * @property {string} conditionalNodeType - The type of the conditional expression node, ie "ConditionalExpression" or "TSConditionalType".
  19490. * @property {string} consequentNodePropertyName - The property at which the consequent node can be found on the main node, eg "consequent".
  19491. * @property {string} alternateNodePropertyName - The property at which the alternate node can be found on the main node, eg "alternate".
  19492. * @property {string} testNodePropertyName - The property at which the test node can be found on the main node, eg "test".
  19493. * @property {boolean} breakNested - Whether to break all nested ternaries when one breaks.
  19494. * @param {FastPath} path - The path to the ConditionalExpression/TSConditionalType node.
  19495. * @param {Options} options - Prettier options
  19496. * @param {Function} print - Print function to call recursively
  19497. * @param {OperatorOptions} operatorOptions
  19498. * @returns Doc
  19499. */
  19500. function printTernaryOperator(path, options, print, operatorOptions) {
  19501. var node = path.getValue();
  19502. var testNode = node[operatorOptions.testNodePropertyName];
  19503. var consequentNode = node[operatorOptions.consequentNodePropertyName];
  19504. var alternateNode = node[operatorOptions.alternateNodePropertyName];
  19505. var parts = []; // We print a ConditionalExpression in either "JSX mode" or "normal mode".
  19506. // See tests/jsx/conditional-expression.js for more info.
  19507. var jsxMode = false;
  19508. var parent = path.getParentNode();
  19509. var forceNoIndent = parent.type === operatorOptions.conditionalNodeType; // Find the outermost non-ConditionalExpression parent, and the outermost
  19510. // ConditionalExpression parent. We'll use these to determine if we should
  19511. // print in JSX mode.
  19512. var currentParent;
  19513. var previousParent;
  19514. var i = 0;
  19515. do {
  19516. previousParent = currentParent || node;
  19517. currentParent = path.getParentNode(i);
  19518. i++;
  19519. } while (currentParent && currentParent.type === operatorOptions.conditionalNodeType);
  19520. var firstNonConditionalParent = currentParent || parent;
  19521. var lastConditionalParent = previousParent;
  19522. if (operatorOptions.shouldCheckJsx && (isJSXNode(testNode) || isJSXNode(consequentNode) || isJSXNode(alternateNode) || conditionalExpressionChainContainsJSX(lastConditionalParent))) {
  19523. jsxMode = true;
  19524. forceNoIndent = true; // Even though they don't need parens, we wrap (almost) everything in
  19525. // parens when using ?: within JSX, because the parens are analogous to
  19526. // curly braces in an if statement.
  19527. var wrap = function wrap(doc$$2) {
  19528. return concat$11([ifBreak$6("(", ""), indent$6(concat$11([softline$5, doc$$2])), softline$5, ifBreak$6(")", "")]);
  19529. }; // The only things we don't wrap are:
  19530. // * Nested conditional expressions in alternates
  19531. // * null
  19532. var isNull = function isNull(node) {
  19533. return node.type === "NullLiteral" || node.type === "Literal" && node.value === null;
  19534. };
  19535. 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)));
  19536. } else {
  19537. // normal mode
  19538. 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))]);
  19539. 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));
  19540. } // We want a whole chain of ConditionalExpressions to all
  19541. // break if any of them break. That means we should only group around the
  19542. // outer-most ConditionalExpression.
  19543. var maybeGroup = function maybeGroup(doc$$2) {
  19544. return operatorOptions.breakNested ? parent === firstNonConditionalParent ? group$10(doc$$2) : doc$$2 : group$10(doc$$2);
  19545. }; // Break the closing paren to keep the chain right after it:
  19546. // (a
  19547. // ? b
  19548. // : c
  19549. // ).call()
  19550. var breakClosingParen = !jsxMode && (parent.type === "MemberExpression" || parent.type === "OptionalMemberExpression") && !parent.computed;
  19551. return maybeGroup(concat$11([].concat(function (testDoc) {
  19552. return (
  19553. /**
  19554. * a
  19555. * ? b
  19556. * : multiline
  19557. * test
  19558. * node
  19559. * ^^ align(2)
  19560. * ? d
  19561. * : e
  19562. */
  19563. parent.type === operatorOptions.conditionalNodeType && parent[operatorOptions.alternateNodePropertyName] === node ? align$1(2, testDoc) : testDoc
  19564. );
  19565. }(concat$11(operatorOptions.beforeParts())), forceNoIndent ? concat$11(parts) : indent$6(concat$11(parts)), operatorOptions.afterParts(breakClosingParen))));
  19566. }
  19567. function getTypeScriptMappedTypeModifier(tokenNode, keyword) {
  19568. if (tokenNode === "+") {
  19569. return "+" + keyword;
  19570. } else if (tokenNode === "-") {
  19571. return "-" + keyword;
  19572. }
  19573. return keyword;
  19574. }
  19575. function printPathNoParens(path, options, print, args) {
  19576. var n = path.getValue();
  19577. var semi = options.semi ? ";" : "";
  19578. if (!n) {
  19579. return "";
  19580. }
  19581. if (typeof n === "string") {
  19582. return n;
  19583. }
  19584. var htmlBinding$$1 = printHtmlBinding(path, options, print);
  19585. if (htmlBinding$$1) {
  19586. return htmlBinding$$1;
  19587. }
  19588. var parts = [];
  19589. switch (n.type) {
  19590. case "JsExpressionRoot":
  19591. return path.call(print, "node");
  19592. case "JsonRoot":
  19593. return concat$11([path.call(print, "node"), hardline$8]);
  19594. case "File":
  19595. // Print @babel/parser's InterpreterDirective here so that
  19596. // leading comments on the `Program` node get printed after the hashbang.
  19597. if (n.program && n.program.interpreter) {
  19598. parts.push(path.call(function (programPath) {
  19599. return programPath.call(print, "interpreter");
  19600. }, "program"));
  19601. }
  19602. parts.push(path.call(print, "program"));
  19603. return concat$11(parts);
  19604. case "Program":
  19605. // Babel 6
  19606. if (n.directives) {
  19607. path.each(function (childPath) {
  19608. parts.push(print(childPath), semi, hardline$8);
  19609. if (isNextLineEmpty$4(options.originalText, childPath.getValue(), options)) {
  19610. parts.push(hardline$8);
  19611. }
  19612. }, "directives");
  19613. }
  19614. parts.push(path.call(function (bodyPath) {
  19615. return printStatementSequence(bodyPath, options, print);
  19616. }, "body"));
  19617. parts.push(comments.printDanglingComments(path, options,
  19618. /* sameIndent */
  19619. true)); // Only force a trailing newline if there were any contents.
  19620. if (n.body.length || n.comments) {
  19621. parts.push(hardline$8);
  19622. }
  19623. return concat$11(parts);
  19624. // Babel extension.
  19625. case "EmptyStatement":
  19626. return "";
  19627. case "ExpressionStatement":
  19628. // Detect Flow-parsed directives
  19629. if (n.directive) {
  19630. return concat$11([nodeStr(n.expression, options, true), semi]);
  19631. }
  19632. if (options.parser === "__vue_event_binding") {
  19633. var parent = path.getParentNode();
  19634. if (parent.type === "Program" && parent.body.length === 1 && parent.body[0] === n) {
  19635. return concat$11([path.call(print, "expression"), isVueEventBindingExpression$2(n.expression) ? ";" : ""]);
  19636. }
  19637. } // Do not append semicolon after the only JSX element in a program
  19638. return concat$11([path.call(print, "expression"), isTheOnlyJSXElementInMarkdown(options, path) ? "" : semi]);
  19639. // Babel extension.
  19640. case "ParenthesizedExpression":
  19641. return concat$11(["(", path.call(print, "expression"), ")"]);
  19642. case "AssignmentExpression":
  19643. return printAssignment(n.left, path.call(print, "left"), concat$11([" ", n.operator]), n.right, path.call(print, "right"), options);
  19644. case "BinaryExpression":
  19645. case "LogicalExpression":
  19646. case "NGPipeExpression":
  19647. {
  19648. var _parent = path.getParentNode();
  19649. var parentParent = path.getParentNode(1);
  19650. var isInsideParenthesis = n !== _parent.body && (_parent.type === "IfStatement" || _parent.type === "WhileStatement" || _parent.type === "DoWhileStatement");
  19651. var _parts = printBinaryishExpressions(path, print, options,
  19652. /* isNested */
  19653. false, isInsideParenthesis); // if (
  19654. // this.hasPlugin("dynamicImports") && this.lookahead().type === tt.parenLeft
  19655. // ) {
  19656. //
  19657. // looks super weird, we want to break the children if the parent breaks
  19658. //
  19659. // if (
  19660. // this.hasPlugin("dynamicImports") &&
  19661. // this.lookahead().type === tt.parenLeft
  19662. // ) {
  19663. if (isInsideParenthesis) {
  19664. return concat$11(_parts);
  19665. } // Break between the parens in unaries or in a member expression, i.e.
  19666. //
  19667. // (
  19668. // a &&
  19669. // b &&
  19670. // c
  19671. // ).call()
  19672. if (_parent.type === "UnaryExpression" || (_parent.type === "MemberExpression" || _parent.type === "OptionalMemberExpression") && !_parent.computed) {
  19673. return group$10(concat$11([indent$6(concat$11([softline$5, concat$11(_parts)])), softline$5]));
  19674. } // Avoid indenting sub-expressions in some cases where the first sub-expression is already
  19675. // indented accordingly. We should indent sub-expressions where the first case isn't indented.
  19676. 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";
  19677. var shouldIndentIfInlining = _parent.type === "AssignmentExpression" || _parent.type === "VariableDeclarator" || _parent.type === "ClassProperty" || _parent.type === "TSAbstractClassProperty" || _parent.type === "ClassPrivateProperty" || _parent.type === "ObjectProperty" || _parent.type === "Property";
  19678. var samePrecedenceSubExpression = isBinaryish(n.left) && shouldFlatten$1(n.operator, n.left.operator);
  19679. if (shouldNotIndent || shouldInlineLogicalExpression(n) && !samePrecedenceSubExpression || !shouldInlineLogicalExpression(n) && shouldIndentIfInlining) {
  19680. return group$10(concat$11(_parts));
  19681. }
  19682. if (_parts.length === 0) {
  19683. return "";
  19684. } // If the right part is a JSX node, we include it in a separate group to
  19685. // prevent it breaking the whole chain, so we can print the expression like:
  19686. //
  19687. // foo && bar && (
  19688. // <Foo>
  19689. // <Bar />
  19690. // </Foo>
  19691. // )
  19692. var hasJSX = isJSXNode(n.right);
  19693. var rest = concat$11(hasJSX ? _parts.slice(1, -1) : _parts.slice(1));
  19694. var groupId = Symbol("logicalChain-" + ++uid);
  19695. var chain = group$10(concat$11([// Don't include the initial expression in the indentation
  19696. // level. The first item is guaranteed to be the first
  19697. // left-most expression.
  19698. _parts.length > 0 ? _parts[0] : "", indent$6(rest)]), {
  19699. id: groupId
  19700. });
  19701. if (!hasJSX) {
  19702. return chain;
  19703. }
  19704. var jsxPart = getLast$3(_parts);
  19705. return group$10(concat$11([chain, ifBreak$6(indent$6(jsxPart), jsxPart, {
  19706. groupId: groupId
  19707. })]));
  19708. }
  19709. case "AssignmentPattern":
  19710. return concat$11([path.call(print, "left"), " = ", path.call(print, "right")]);
  19711. case "TSTypeAssertion":
  19712. {
  19713. var shouldBreakAfterCast = !(n.expression.type === "ArrayExpression" || n.expression.type === "ObjectExpression");
  19714. var castGroup = group$10(concat$11(["<", indent$6(concat$11([softline$5, path.call(print, "typeAnnotation")])), softline$5, ">"]));
  19715. var exprContents = concat$11([ifBreak$6("("), indent$6(concat$11([softline$5, path.call(print, "expression")])), softline$5, ifBreak$6(")")]);
  19716. if (shouldBreakAfterCast) {
  19717. return conditionalGroup$1([concat$11([castGroup, path.call(print, "expression")]), concat$11([castGroup, group$10(exprContents, {
  19718. shouldBreak: true
  19719. })]), concat$11([castGroup, path.call(print, "expression")])]);
  19720. }
  19721. return group$10(concat$11([castGroup, path.call(print, "expression")]));
  19722. }
  19723. case "OptionalMemberExpression":
  19724. case "MemberExpression":
  19725. {
  19726. var _parent2 = path.getParentNode();
  19727. var firstNonMemberParent;
  19728. var i = 0;
  19729. do {
  19730. firstNonMemberParent = path.getParentNode(i);
  19731. i++;
  19732. } while (firstNonMemberParent && (firstNonMemberParent.type === "MemberExpression" || firstNonMemberParent.type === "OptionalMemberExpression" || firstNonMemberParent.type === "TSNonNullExpression"));
  19733. 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";
  19734. return concat$11([path.call(print, "object"), shouldInline ? printMemberLookup(path, options, print) : group$10(indent$6(concat$11([softline$5, printMemberLookup(path, options, print)])))]);
  19735. }
  19736. case "MetaProperty":
  19737. return concat$11([path.call(print, "meta"), ".", path.call(print, "property")]);
  19738. case "BindExpression":
  19739. if (n.object) {
  19740. parts.push(path.call(print, "object"));
  19741. }
  19742. parts.push(group$10(indent$6(concat$11([softline$5, printBindExpressionCallee(path, options, print)]))));
  19743. return concat$11(parts);
  19744. case "Identifier":
  19745. {
  19746. return concat$11([n.name, printOptionalToken(path), printTypeAnnotation(path, options, print)]);
  19747. }
  19748. case "SpreadElement":
  19749. case "SpreadElementPattern":
  19750. case "RestProperty":
  19751. case "SpreadProperty":
  19752. case "SpreadPropertyPattern":
  19753. case "RestElement":
  19754. case "ObjectTypeSpreadProperty":
  19755. return concat$11(["...", path.call(print, "argument"), printTypeAnnotation(path, options, print)]);
  19756. case "FunctionDeclaration":
  19757. case "FunctionExpression":
  19758. parts.push(printFunctionDeclaration(path, print, options));
  19759. if (!n.body) {
  19760. parts.push(semi);
  19761. }
  19762. return concat$11(parts);
  19763. case "ArrowFunctionExpression":
  19764. {
  19765. if (n.async) {
  19766. parts.push("async ");
  19767. }
  19768. if (shouldPrintParamsWithoutParens(path, options)) {
  19769. parts.push(path.call(print, "params", 0));
  19770. } else {
  19771. parts.push(group$10(concat$11([printFunctionParams(path, print, options,
  19772. /* expandLast */
  19773. args && (args.expandLastArg || args.expandFirstArg),
  19774. /* printTypeParams */
  19775. true), printReturnType(path, print, options)])));
  19776. }
  19777. var dangling = comments.printDanglingComments(path, options,
  19778. /* sameIndent */
  19779. true, function (comment) {
  19780. var nextCharacter = getNextNonSpaceNonCommentCharacterIndex$2(options.originalText, comment, options);
  19781. return options.originalText.substr(nextCharacter, 2) === "=>";
  19782. });
  19783. if (dangling) {
  19784. parts.push(" ", dangling);
  19785. }
  19786. parts.push(" =>");
  19787. var body = path.call(function (bodyPath) {
  19788. return print(bodyPath, args);
  19789. }, "body"); // We want to always keep these types of nodes on the same line
  19790. // as the arrow.
  19791. 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")) {
  19792. return group$10(concat$11([concat$11(parts), " ", body]));
  19793. } // We handle sequence expressions as the body of arrows specially,
  19794. // so that the required parentheses end up on their own lines.
  19795. if (n.body.type === "SequenceExpression") {
  19796. return group$10(concat$11([concat$11(parts), group$10(concat$11([" (", indent$6(concat$11([softline$5, body])), softline$5, ")"]))]));
  19797. } // if the arrow function is expanded as last argument, we are adding a
  19798. // level of indentation and need to add a softline to align the closing )
  19799. // with the opening (, or if it's inside a JSXExpression (e.g. an attribute)
  19800. // we should align the expression's closing } with the line with the opening {.
  19801. var shouldAddSoftLine = (args && args.expandLastArg || path.getParentNode().type === "JSXExpressionContainer") && !(n.comments && n.comments.length);
  19802. var printTrailingComma = args && args.expandLastArg && shouldPrintComma$1(options, "all"); // In order to avoid confusion between
  19803. // a => a ? a : a
  19804. // a <= a ? a : a
  19805. var shouldAddParens = n.body.type === "ConditionalExpression" && !startsWithNoLookaheadToken$1(n.body,
  19806. /* forbidFunctionAndClass */
  19807. false);
  19808. 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]) : ""]))]));
  19809. }
  19810. case "MethodDefinition":
  19811. case "TSAbstractMethodDefinition":
  19812. if (n.decorators && n.decorators.length !== 0) {
  19813. parts.push(printDecorators(path, options, print));
  19814. }
  19815. if (n.accessibility) {
  19816. parts.push(n.accessibility + " ");
  19817. }
  19818. if (n.static) {
  19819. parts.push("static ");
  19820. }
  19821. if (n.type === "TSAbstractMethodDefinition") {
  19822. parts.push("abstract ");
  19823. }
  19824. parts.push(printMethod(path, options, print));
  19825. return concat$11(parts);
  19826. case "YieldExpression":
  19827. parts.push("yield");
  19828. if (n.delegate) {
  19829. parts.push("*");
  19830. }
  19831. if (n.argument) {
  19832. parts.push(" ", path.call(print, "argument"));
  19833. }
  19834. return concat$11(parts);
  19835. case "AwaitExpression":
  19836. return concat$11(["await ", path.call(print, "argument")]);
  19837. case "ImportSpecifier":
  19838. if (n.importKind) {
  19839. parts.push(path.call(print, "importKind"), " ");
  19840. }
  19841. parts.push(path.call(print, "imported"));
  19842. if (n.local && n.local.name !== n.imported.name) {
  19843. parts.push(" as ", path.call(print, "local"));
  19844. }
  19845. return concat$11(parts);
  19846. case "ExportSpecifier":
  19847. parts.push(path.call(print, "local"));
  19848. if (n.exported && n.exported.name !== n.local.name) {
  19849. parts.push(" as ", path.call(print, "exported"));
  19850. }
  19851. return concat$11(parts);
  19852. case "ImportNamespaceSpecifier":
  19853. parts.push("* as ");
  19854. parts.push(path.call(print, "local"));
  19855. return concat$11(parts);
  19856. case "ImportDefaultSpecifier":
  19857. return path.call(print, "local");
  19858. case "TSExportAssignment":
  19859. return concat$11(["export = ", path.call(print, "expression"), semi]);
  19860. case "ExportDefaultDeclaration":
  19861. case "ExportNamedDeclaration":
  19862. return printExportDeclaration(path, options, print);
  19863. case "ExportAllDeclaration":
  19864. parts.push("export ");
  19865. if (n.exportKind === "type") {
  19866. parts.push("type ");
  19867. }
  19868. parts.push("* from ", path.call(print, "source"), semi);
  19869. return concat$11(parts);
  19870. case "ExportNamespaceSpecifier":
  19871. case "ExportDefaultSpecifier":
  19872. return path.call(print, "exported");
  19873. case "ImportDeclaration":
  19874. {
  19875. parts.push("import ");
  19876. if (n.importKind && n.importKind !== "value") {
  19877. parts.push(n.importKind + " ");
  19878. }
  19879. var standalones = [];
  19880. var grouped = [];
  19881. if (n.specifiers && n.specifiers.length > 0) {
  19882. path.each(function (specifierPath) {
  19883. var value = specifierPath.getValue();
  19884. if (value.type === "ImportDefaultSpecifier" || value.type === "ImportNamespaceSpecifier") {
  19885. standalones.push(print(specifierPath));
  19886. } else {
  19887. grouped.push(print(specifierPath));
  19888. }
  19889. }, "specifiers");
  19890. if (standalones.length > 0) {
  19891. parts.push(join$7(", ", standalones));
  19892. }
  19893. if (standalones.length > 0 && grouped.length > 0) {
  19894. parts.push(", ");
  19895. }
  19896. if (grouped.length === 1 && standalones.length === 0 && n.specifiers && !n.specifiers.some(function (node) {
  19897. return node.comments;
  19898. })) {
  19899. parts.push(concat$11(["{", options.bracketSpacing ? " " : "", concat$11(grouped), options.bracketSpacing ? " " : "", "}"]));
  19900. } else if (grouped.length >= 1) {
  19901. 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, "}"])));
  19902. }
  19903. parts.push(" from ");
  19904. } else if (n.importKind && n.importKind === "type" || // import {} from 'x'
  19905. /{\s*}/.test(options.originalText.slice(options.locStart(n), options.locStart(n.source)))) {
  19906. parts.push("{} from ");
  19907. }
  19908. parts.push(path.call(print, "source"), semi);
  19909. return concat$11(parts);
  19910. }
  19911. case "Import":
  19912. return "import";
  19913. case "TSModuleBlock":
  19914. case "BlockStatement":
  19915. {
  19916. var naked = path.call(function (bodyPath) {
  19917. return printStatementSequence(bodyPath, options, print);
  19918. }, "body");
  19919. var hasContent = n.body.find(function (node) {
  19920. return node.type !== "EmptyStatement";
  19921. });
  19922. var hasDirectives = n.directives && n.directives.length > 0;
  19923. var _parent3 = path.getParentNode();
  19924. var _parentParent = path.getParentNode(1);
  19925. 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")) {
  19926. return "{}";
  19927. }
  19928. parts.push("{"); // Babel 6
  19929. if (hasDirectives) {
  19930. path.each(function (childPath) {
  19931. parts.push(indent$6(concat$11([hardline$8, print(childPath), semi])));
  19932. if (isNextLineEmpty$4(options.originalText, childPath.getValue(), options)) {
  19933. parts.push(hardline$8);
  19934. }
  19935. }, "directives");
  19936. }
  19937. if (hasContent) {
  19938. parts.push(indent$6(concat$11([hardline$8, naked])));
  19939. }
  19940. parts.push(comments.printDanglingComments(path, options));
  19941. parts.push(hardline$8, "}");
  19942. return concat$11(parts);
  19943. }
  19944. case "ReturnStatement":
  19945. parts.push("return");
  19946. if (n.argument) {
  19947. if (returnArgumentHasLeadingComment(options, n.argument)) {
  19948. parts.push(concat$11([" (", indent$6(concat$11([hardline$8, path.call(print, "argument")])), hardline$8, ")"]));
  19949. } else if (n.argument.type === "LogicalExpression" || n.argument.type === "BinaryExpression" || n.argument.type === "SequenceExpression") {
  19950. parts.push(group$10(concat$11([ifBreak$6(" (", " "), indent$6(concat$11([softline$5, path.call(print, "argument")])), softline$5, ifBreak$6(")")])));
  19951. } else {
  19952. parts.push(" ", path.call(print, "argument"));
  19953. }
  19954. }
  19955. if (hasDanglingComments(n)) {
  19956. parts.push(" ", comments.printDanglingComments(path, options,
  19957. /* sameIndent */
  19958. true));
  19959. }
  19960. parts.push(semi);
  19961. return concat$11(parts);
  19962. case "NewExpression":
  19963. case "OptionalCallExpression":
  19964. case "CallExpression":
  19965. {
  19966. var isNew = n.type === "NewExpression";
  19967. var optional = printOptionalToken(path);
  19968. if ( // We want to keep CommonJS- and AMD-style require calls, and AMD-style
  19969. // define calls, as a unit.
  19970. // e.g. `define(["some/lib", (lib) => {`
  19971. !isNew && n.callee.type === "Identifier" && (n.callee.name === "require" || n.callee.name === "define") || // Template literals as single arguments
  19972. n.arguments.length === 1 && isTemplateOnItsOwnLine(n.arguments[0], options.originalText, options) || // Keep test declarations on a single line
  19973. // e.g. `it('long name', () => {`
  19974. !isNew && isTestCall(n, path.getParentNode())) {
  19975. return concat$11([isNew ? "new " : "", path.call(print, "callee"), optional, printFunctionTypeParameters(path, options, print), concat$11(["(", join$7(", ", path.map(print, "arguments")), ")"])]);
  19976. } // Inline Flow annotation comments following Identifiers in Call nodes need to
  19977. // stay with the Identifier. For example:
  19978. //
  19979. // foo /*:: <SomeGeneric> */(bar);
  19980. //
  19981. // Here, we ensure that such comments stay between the Identifier and the Callee.
  19982. var isIdentifierWithFlowAnnotation = n.callee.type === "Identifier" && hasFlowAnnotationComment(n.callee.trailingComments);
  19983. if (isIdentifierWithFlowAnnotation) {
  19984. n.callee.trailingComments[0].printed = true;
  19985. } // We detect calls on member lookups and possibly print them in a
  19986. // special chain format. See `printMemberChain` for more info.
  19987. if (!isNew && isMemberish(n.callee)) {
  19988. return printMemberChain(path, options, print);
  19989. }
  19990. 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)]);
  19991. }
  19992. case "TSInterfaceDeclaration":
  19993. if (isNodeStartingWithDeclare(n, options)) {
  19994. parts.push("declare ");
  19995. }
  19996. parts.push(n.abstract ? "abstract " : "", printTypeScriptModifiers(path, options, print), "interface ", path.call(print, "id"), n.typeParameters ? path.call(print, "typeParameters") : "", " ");
  19997. if (n.extends && n.extends.length) {
  19998. 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"))), " "]))));
  19999. }
  20000. parts.push(path.call(print, "body"));
  20001. return concat$11(parts);
  20002. case "ObjectTypeInternalSlot":
  20003. return concat$11([n.static ? "static " : "", "[[", path.call(print, "id"), "]]", printOptionalToken(path), n.method ? "" : ": ", path.call(print, "value")]);
  20004. case "ObjectExpression":
  20005. case "ObjectPattern":
  20006. case "ObjectTypeAnnotation":
  20007. case "TSInterfaceBody":
  20008. case "TSTypeLiteral":
  20009. {
  20010. var propertiesField;
  20011. if (n.type === "TSTypeLiteral") {
  20012. propertiesField = "members";
  20013. } else if (n.type === "TSInterfaceBody") {
  20014. propertiesField = "body";
  20015. } else {
  20016. propertiesField = "properties";
  20017. }
  20018. var isTypeAnnotation = n.type === "ObjectTypeAnnotation";
  20019. var fields = [];
  20020. if (isTypeAnnotation) {
  20021. fields.push("indexers", "callProperties", "internalSlots");
  20022. }
  20023. fields.push(propertiesField);
  20024. var firstProperty = fields.map(function (field) {
  20025. return n[field][0];
  20026. }).sort(function (a, b) {
  20027. return options.locStart(a) - options.locStart(b);
  20028. })[0];
  20029. var _parent4 = path.getParentNode(0);
  20030. var isFlowInterfaceLikeBody = isTypeAnnotation && _parent4 && (_parent4.type === "InterfaceDeclaration" || _parent4.type === "DeclareInterface" || _parent4.type === "DeclareClass") && path.getName() === "body";
  20031. 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) {
  20032. return property.value && (property.value.type === "ObjectPattern" || property.value.type === "ArrayPattern");
  20033. }) || n.type !== "ObjectPattern" && firstProperty && hasNewlineInRange$1(options.originalText, options.locStart(n), options.locStart(firstProperty));
  20034. var separator = isFlowInterfaceLikeBody ? ";" : n.type === "TSInterfaceBody" || n.type === "TSTypeLiteral" ? ifBreak$6(semi, ";") : ",";
  20035. var leftBrace = n.exact ? "{|" : "{";
  20036. var rightBrace = n.exact ? "|}" : "}"; // Unfortunately, things are grouped together in the ast can be
  20037. // interleaved in the source code. So we need to reorder them before
  20038. // printing them.
  20039. var propsAndLoc = [];
  20040. fields.forEach(function (field) {
  20041. path.each(function (childPath) {
  20042. var node = childPath.getValue();
  20043. propsAndLoc.push({
  20044. node: node,
  20045. printed: print(childPath),
  20046. loc: options.locStart(node)
  20047. });
  20048. }, field);
  20049. });
  20050. var separatorParts = [];
  20051. var props = propsAndLoc.sort(function (a, b) {
  20052. return a.loc - b.loc;
  20053. }).map(function (prop) {
  20054. var result = concat$11(separatorParts.concat(group$10(prop.printed)));
  20055. separatorParts = [separator, line$8];
  20056. if ((prop.node.type === "TSPropertySignature" || prop.node.type === "TSMethodSignature" || prop.node.type === "TSConstructSignatureDeclaration") && hasNodeIgnoreComment$1(prop.node)) {
  20057. separatorParts.shift();
  20058. }
  20059. if (isNextLineEmpty$4(options.originalText, prop.node, options)) {
  20060. separatorParts.push(hardline$8);
  20061. }
  20062. return result;
  20063. });
  20064. if (n.inexact) {
  20065. props.push(concat$11(separatorParts.concat(group$10("..."))));
  20066. }
  20067. var lastElem = getLast$3(n[propertiesField]);
  20068. var canHaveTrailingSeparator = !(lastElem && (lastElem.type === "RestProperty" || lastElem.type === "RestElement" || hasNodeIgnoreComment$1(lastElem) || n.inexact));
  20069. var content;
  20070. if (props.length === 0 && !n.typeAnnotation) {
  20071. if (!hasDanglingComments(n)) {
  20072. return concat$11([leftBrace, rightBrace]);
  20073. }
  20074. content = group$10(concat$11([leftBrace, comments.printDanglingComments(path, options), softline$5, rightBrace, printOptionalToken(path)]));
  20075. } else {
  20076. 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)]);
  20077. } // If we inline the object as first argument of the parent, we don't want
  20078. // to create another group so that the object breaks before the return
  20079. // type
  20080. var parentParentParent = path.getParentNode(2);
  20081. 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) {
  20082. return content;
  20083. }
  20084. return group$10(content, {
  20085. shouldBreak: shouldBreak
  20086. });
  20087. }
  20088. // Babel 6
  20089. case "ObjectProperty": // Non-standard AST node type.
  20090. case "Property":
  20091. if (n.method || n.kind === "get" || n.kind === "set") {
  20092. return printMethod(path, options, print);
  20093. }
  20094. if (n.shorthand) {
  20095. parts.push(path.call(print, "value"));
  20096. } else {
  20097. var printedLeft;
  20098. if (n.computed) {
  20099. printedLeft = concat$11(["[", path.call(print, "key"), "]"]);
  20100. } else {
  20101. printedLeft = printPropertyKey(path, options, print);
  20102. }
  20103. parts.push(printAssignment(n.key, printedLeft, ":", n.value, path.call(print, "value"), options));
  20104. }
  20105. return concat$11(parts);
  20106. // Babel 6
  20107. case "ClassMethod":
  20108. case "ClassPrivateMethod":
  20109. if (n.decorators && n.decorators.length !== 0) {
  20110. parts.push(printDecorators(path, options, print));
  20111. }
  20112. if (n.static) {
  20113. parts.push("static ");
  20114. }
  20115. parts = parts.concat(printObjectMethod(path, options, print));
  20116. return concat$11(parts);
  20117. // Babel 6
  20118. case "ObjectMethod":
  20119. return printObjectMethod(path, options, print);
  20120. case "Decorator":
  20121. return concat$11(["@", path.call(print, "expression"), path.call(print, "callee")]);
  20122. case "ArrayExpression":
  20123. case "ArrayPattern":
  20124. if (n.elements.length === 0) {
  20125. if (!hasDanglingComments(n)) {
  20126. parts.push("[]");
  20127. } else {
  20128. parts.push(group$10(concat$11(["[", comments.printDanglingComments(path, options), softline$5, "]"])));
  20129. }
  20130. } else {
  20131. var _lastElem = getLast$3(n.elements);
  20132. var canHaveTrailingComma = !(_lastElem && _lastElem.type === "RestElement"); // JavaScript allows you to have empty elements in an array which
  20133. // changes its length based on the number of commas. The algorithm
  20134. // is that if the last argument is null, we need to force insert
  20135. // a comma to ensure JavaScript recognizes it.
  20136. // [,].length === 1
  20137. // [1,].length === 1
  20138. // [1,,].length === 2
  20139. //
  20140. // Note that getLast returns null if the array is empty, but
  20141. // we already check for an empty array just above so we are safe
  20142. var needsForcedTrailingComma = canHaveTrailingComma && _lastElem === null;
  20143. 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,
  20144. /* sameIndent */
  20145. true), softline$5, "]"])));
  20146. }
  20147. parts.push(printOptionalToken(path), printTypeAnnotation(path, options, print));
  20148. return concat$11(parts);
  20149. case "SequenceExpression":
  20150. {
  20151. var _parent5 = path.getParentNode(0);
  20152. if (_parent5.type === "ExpressionStatement" || _parent5.type === "ForStatement") {
  20153. // For ExpressionStatements and for-loop heads, which are among
  20154. // the few places a SequenceExpression appears unparenthesized, we want
  20155. // to indent expressions after the first.
  20156. var _parts2 = [];
  20157. path.each(function (p) {
  20158. if (p.getName() === 0) {
  20159. _parts2.push(print(p));
  20160. } else {
  20161. _parts2.push(",", indent$6(concat$11([line$8, print(p)])));
  20162. }
  20163. }, "expressions");
  20164. return group$10(concat$11(_parts2));
  20165. }
  20166. return group$10(concat$11([join$7(concat$11([",", line$8]), path.map(print, "expressions"))]));
  20167. }
  20168. case "ThisExpression":
  20169. return "this";
  20170. case "Super":
  20171. return "super";
  20172. case "NullLiteral":
  20173. // Babel 6 Literal split
  20174. return "null";
  20175. case "RegExpLiteral":
  20176. // Babel 6 Literal split
  20177. return printRegex(n);
  20178. case "NumericLiteral":
  20179. // Babel 6 Literal split
  20180. return printNumber$2(n.extra.raw);
  20181. case "BigIntLiteral":
  20182. return concat$11([printNumber$2(n.extra ? n.extra.rawValue : // TypeScript
  20183. n.value), "n"]);
  20184. case "BooleanLiteral": // Babel 6 Literal split
  20185. case "StringLiteral": // Babel 6 Literal split
  20186. case "Literal":
  20187. {
  20188. if (n.regex) {
  20189. return printRegex(n.regex);
  20190. }
  20191. if (typeof n.value === "number") {
  20192. return printNumber$2(n.raw);
  20193. }
  20194. if (typeof n.value !== "string") {
  20195. return "" + n.value;
  20196. } // TypeScript workaround for https://github.com/JamesHenry/typescript-estree/issues/2
  20197. // See corresponding workaround in needs-parens.js
  20198. var grandParent = path.getParentNode(1);
  20199. var isTypeScriptDirective = options.parser === "typescript" && typeof n.value === "string" && grandParent && (grandParent.type === "Program" || grandParent.type === "BlockStatement");
  20200. return nodeStr(n, options, isTypeScriptDirective);
  20201. }
  20202. case "Directive":
  20203. return path.call(print, "value");
  20204. // Babel 6
  20205. case "DirectiveLiteral":
  20206. return nodeStr(n, options);
  20207. case "UnaryExpression":
  20208. parts.push(n.operator);
  20209. if (/[a-z]$/.test(n.operator)) {
  20210. parts.push(" ");
  20211. }
  20212. parts.push(path.call(print, "argument"));
  20213. return concat$11(parts);
  20214. case "UpdateExpression":
  20215. parts.push(path.call(print, "argument"), n.operator);
  20216. if (n.prefix) {
  20217. parts.reverse();
  20218. }
  20219. return concat$11(parts);
  20220. case "ConditionalExpression":
  20221. return printTernaryOperator(path, options, print, {
  20222. beforeParts: function beforeParts() {
  20223. return [path.call(print, "test")];
  20224. },
  20225. afterParts: function afterParts(breakClosingParen) {
  20226. return [breakClosingParen ? softline$5 : ""];
  20227. },
  20228. shouldCheckJsx: true,
  20229. conditionalNodeType: "ConditionalExpression",
  20230. consequentNodePropertyName: "consequent",
  20231. alternateNodePropertyName: "alternate",
  20232. testNodePropertyName: "test",
  20233. breakNested: true
  20234. });
  20235. case "VariableDeclaration":
  20236. {
  20237. var printed = path.map(function (childPath) {
  20238. return print(childPath);
  20239. }, "declarations"); // We generally want to terminate all variable declarations with a
  20240. // semicolon, except when they in the () part of for loops.
  20241. var parentNode = path.getParentNode();
  20242. var isParentForLoop = parentNode.type === "ForStatement" || parentNode.type === "ForInStatement" || parentNode.type === "ForOfStatement" || parentNode.type === "ForAwaitStatement";
  20243. var hasValue = n.declarations.some(function (decl) {
  20244. return decl.init;
  20245. });
  20246. var firstVariable;
  20247. if (printed.length === 1 && !n.declarations[0].comments) {
  20248. firstVariable = printed[0];
  20249. } else if (printed.length > 0) {
  20250. // Indent first var to comply with eslint one-var rule
  20251. firstVariable = indent$6(printed[0]);
  20252. }
  20253. parts = [isNodeStartingWithDeclare(n, options) ? "declare " : "", n.kind, firstVariable ? concat$11([" ", firstVariable]) : "", indent$6(concat$11(printed.slice(1).map(function (p) {
  20254. return concat$11([",", hasValue && !isParentForLoop ? hardline$8 : line$8, p]);
  20255. })))];
  20256. if (!(isParentForLoop && parentNode.body !== n)) {
  20257. parts.push(semi);
  20258. }
  20259. return group$10(concat$11(parts));
  20260. }
  20261. case "TSTypeAliasDeclaration":
  20262. {
  20263. if (n.declare) {
  20264. parts.push("declare ");
  20265. }
  20266. var _printed = printAssignmentRight(n.id, n.typeAnnotation, n.typeAnnotation && path.call(print, "typeAnnotation"), options);
  20267. parts.push("type ", path.call(print, "id"), path.call(print, "typeParameters"), " =", _printed, semi);
  20268. return group$10(concat$11(parts));
  20269. }
  20270. case "VariableDeclarator":
  20271. return printAssignment(n.id, path.call(print, "id"), " =", n.init, n.init && path.call(print, "init"), options);
  20272. case "WithStatement":
  20273. return group$10(concat$11(["with (", path.call(print, "object"), ")", adjustClause(n.body, path.call(print, "body"))]));
  20274. case "IfStatement":
  20275. {
  20276. var con = adjustClause(n.consequent, path.call(print, "consequent"));
  20277. var opening = group$10(concat$11(["if (", group$10(concat$11([indent$6(concat$11([softline$5, path.call(print, "test")])), softline$5])), ")", con]));
  20278. parts.push(opening);
  20279. if (n.alternate) {
  20280. var commentOnOwnLine = hasTrailingComment(n.consequent) && n.consequent.comments.some(function (comment) {
  20281. return comment.trailing && !comments$3.isBlockComment(comment);
  20282. }) || needsHardlineAfterDanglingComment(n);
  20283. var elseOnSameLine = n.consequent.type === "BlockStatement" && !commentOnOwnLine;
  20284. parts.push(elseOnSameLine ? " " : hardline$8);
  20285. if (hasDanglingComments(n)) {
  20286. parts.push(comments.printDanglingComments(path, options, true), commentOnOwnLine ? hardline$8 : " ");
  20287. }
  20288. parts.push("else", group$10(adjustClause(n.alternate, path.call(print, "alternate"), n.alternate.type === "IfStatement")));
  20289. }
  20290. return concat$11(parts);
  20291. }
  20292. case "ForStatement":
  20293. {
  20294. var _body = adjustClause(n.body, path.call(print, "body")); // We want to keep dangling comments above the loop to stay consistent.
  20295. // Any comment positioned between the for statement and the parentheses
  20296. // is going to be printed before the statement.
  20297. var _dangling = comments.printDanglingComments(path, options,
  20298. /* sameLine */
  20299. true);
  20300. var printedComments = _dangling ? concat$11([_dangling, softline$5]) : "";
  20301. if (!n.init && !n.test && !n.update) {
  20302. return concat$11([printedComments, group$10(concat$11(["for (;;)", _body]))]);
  20303. }
  20304. 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]))]);
  20305. }
  20306. case "WhileStatement":
  20307. 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"))]));
  20308. case "ForInStatement":
  20309. // Note: esprima can't actually parse "for each (".
  20310. 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"))]));
  20311. case "ForOfStatement":
  20312. case "ForAwaitStatement":
  20313. {
  20314. // Babel 7 removed ForAwaitStatement in favor of ForOfStatement
  20315. // with `"await": true`:
  20316. // https://github.com/estree/estree/pull/138
  20317. var isAwait = n.type === "ForAwaitStatement" || n.await;
  20318. return group$10(concat$11(["for", isAwait ? " await" : "", " (", path.call(print, "left"), " of ", path.call(print, "right"), ")", adjustClause(n.body, path.call(print, "body"))]));
  20319. }
  20320. case "DoWhileStatement":
  20321. {
  20322. var clause = adjustClause(n.body, path.call(print, "body"));
  20323. var doBody = group$10(concat$11(["do", clause]));
  20324. parts = [doBody];
  20325. if (n.body.type === "BlockStatement") {
  20326. parts.push(" ");
  20327. } else {
  20328. parts.push(hardline$8);
  20329. }
  20330. parts.push("while (");
  20331. parts.push(group$10(concat$11([indent$6(concat$11([softline$5, path.call(print, "test")])), softline$5])), ")", semi);
  20332. return concat$11(parts);
  20333. }
  20334. case "DoExpression":
  20335. return concat$11(["do ", path.call(print, "body")]);
  20336. case "BreakStatement":
  20337. parts.push("break");
  20338. if (n.label) {
  20339. parts.push(" ", path.call(print, "label"));
  20340. }
  20341. parts.push(semi);
  20342. return concat$11(parts);
  20343. case "ContinueStatement":
  20344. parts.push("continue");
  20345. if (n.label) {
  20346. parts.push(" ", path.call(print, "label"));
  20347. }
  20348. parts.push(semi);
  20349. return concat$11(parts);
  20350. case "LabeledStatement":
  20351. if (n.body.type === "EmptyStatement") {
  20352. return concat$11([path.call(print, "label"), ":;"]);
  20353. }
  20354. return concat$11([path.call(print, "label"), ": ", path.call(print, "body")]);
  20355. case "TryStatement":
  20356. 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")]) : ""]);
  20357. case "CatchClause":
  20358. if (n.param) {
  20359. var hasComments = n.param.comments && n.param.comments.some(function (comment) {
  20360. return !comments$3.isBlockComment(comment) || comment.leading && hasNewline$3(options.originalText, options.locEnd(comment)) || comment.trailing && hasNewline$3(options.originalText, options.locStart(comment), {
  20361. backwards: true
  20362. });
  20363. });
  20364. var param = path.call(print, "param");
  20365. return concat$11(["catch ", hasComments ? concat$11(["(", indent$6(concat$11([softline$5, param])), softline$5, ") "]) : concat$11(["(", param, ") "]), path.call(print, "body")]);
  20366. }
  20367. return concat$11(["catch ", path.call(print, "body")]);
  20368. case "ThrowStatement":
  20369. return concat$11(["throw ", path.call(print, "argument"), semi]);
  20370. // Note: ignoring n.lexical because it has no printing consequences.
  20371. case "SwitchStatement":
  20372. 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) {
  20373. var caseNode = casePath.getValue();
  20374. return concat$11([casePath.call(print), n.cases.indexOf(caseNode) !== n.cases.length - 1 && isNextLineEmpty$4(options.originalText, caseNode, options) ? hardline$8 : ""]);
  20375. }, "cases"))])) : "", hardline$8, "}"]);
  20376. case "SwitchCase":
  20377. {
  20378. if (n.test) {
  20379. parts.push("case ", path.call(print, "test"), ":");
  20380. } else {
  20381. parts.push("default:");
  20382. }
  20383. var consequent = n.consequent.filter(function (node) {
  20384. return node.type !== "EmptyStatement";
  20385. });
  20386. if (consequent.length > 0) {
  20387. var cons = path.call(function (consequentPath) {
  20388. return printStatementSequence(consequentPath, options, print);
  20389. }, "consequent");
  20390. parts.push(consequent.length === 1 && consequent[0].type === "BlockStatement" ? concat$11([" ", cons]) : indent$6(concat$11([hardline$8, cons])));
  20391. }
  20392. return concat$11(parts);
  20393. }
  20394. // JSX extensions below.
  20395. case "DebuggerStatement":
  20396. return concat$11(["debugger", semi]);
  20397. case "JSXAttribute":
  20398. parts.push(path.call(print, "name"));
  20399. if (n.value) {
  20400. var res;
  20401. if (isStringLiteral(n.value)) {
  20402. var raw = rawText(n.value); // Unescape all quotes so we get an accurate preferred quote
  20403. var final = raw.replace(/&apos;/g, "'").replace(/&quot;/g, '"');
  20404. var quote = getPreferredQuote$1(final, options.jsxSingleQuote ? "'" : '"');
  20405. var _escape = quote === "'" ? "&apos;" : "&quot;";
  20406. final = final.slice(1, -1).replace(new RegExp(quote, "g"), _escape);
  20407. res = concat$11([quote, final, quote]);
  20408. } else {
  20409. res = path.call(print, "value");
  20410. }
  20411. parts.push("=", res);
  20412. }
  20413. return concat$11(parts);
  20414. case "JSXIdentifier":
  20415. return "" + n.name;
  20416. case "JSXNamespacedName":
  20417. return join$7(":", [path.call(print, "namespace"), path.call(print, "name")]);
  20418. case "JSXMemberExpression":
  20419. return join$7(".", [path.call(print, "object"), path.call(print, "property")]);
  20420. case "TSQualifiedName":
  20421. return join$7(".", [path.call(print, "left"), path.call(print, "right")]);
  20422. case "JSXSpreadAttribute":
  20423. case "JSXSpreadChild":
  20424. {
  20425. return concat$11(["{", path.call(function (p) {
  20426. var printed = concat$11(["...", print(p)]);
  20427. var n = p.getValue();
  20428. if (!n.comments || !n.comments.length) {
  20429. return printed;
  20430. }
  20431. return concat$11([indent$6(concat$11([softline$5, comments.printComments(p, function () {
  20432. return printed;
  20433. }, options)])), softline$5]);
  20434. }, n.type === "JSXSpreadAttribute" ? "argument" : "expression"), "}"]);
  20435. }
  20436. case "JSXExpressionContainer":
  20437. {
  20438. var _parent6 = path.getParentNode(0);
  20439. var preventInline = _parent6.type === "JSXAttribute" && n.expression.comments && n.expression.comments.length > 0;
  20440. 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)));
  20441. if (_shouldInline) {
  20442. return group$10(concat$11(["{", path.call(print, "expression"), lineSuffixBoundary$1, "}"]));
  20443. }
  20444. return group$10(concat$11(["{", indent$6(concat$11([softline$5, path.call(print, "expression")])), softline$5, lineSuffixBoundary$1, "}"]));
  20445. }
  20446. case "JSXFragment":
  20447. case "JSXElement":
  20448. {
  20449. var elem = comments.printComments(path, function () {
  20450. return printJSXElement(path, options, print);
  20451. }, options);
  20452. return maybeWrapJSXElementInParens(path, elem);
  20453. }
  20454. case "JSXOpeningElement":
  20455. {
  20456. var _n = path.getValue();
  20457. var nameHasComments = _n.name && _n.name.comments && _n.name.comments.length > 0; // Don't break self-closing elements with no attributes and no comments
  20458. if (_n.selfClosing && !_n.attributes.length && !nameHasComments) {
  20459. return concat$11(["<", path.call(print, "name"), path.call(print, "typeParameters"), " />"]);
  20460. } // don't break up opening elements with a single long text attribute
  20461. 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:
  20462. // <div
  20463. // // comment
  20464. // attr="value"
  20465. // >
  20466. // <div
  20467. // attr="value"
  20468. // // comment
  20469. // >
  20470. !nameHasComments && (!_n.attributes[0].comments || !_n.attributes[0].comments.length)) {
  20471. return group$10(concat$11(["<", path.call(print, "name"), path.call(print, "typeParameters"), " ", concat$11(path.map(print, "attributes")), _n.selfClosing ? " />" : ">"]));
  20472. }
  20473. var lastAttrHasTrailingComments = _n.attributes.length && hasTrailingComment(getLast$3(_n.attributes));
  20474. var bracketSameLine = // Simple tags (no attributes and no comment in tag name) should be
  20475. // kept unbroken regardless of `jsxBracketSameLine`
  20476. !_n.attributes.length && !nameHasComments || options.jsxBracketSameLine && ( // We should print the bracket in a new line for the following cases:
  20477. // <div
  20478. // // comment
  20479. // >
  20480. // <div
  20481. // attr // comment
  20482. // >
  20483. !nameHasComments || _n.attributes.length) && !lastAttrHasTrailingComments; // We should print the opening element expanded if any prop value is a
  20484. // string literal with newlines
  20485. var _shouldBreak = _n.attributes && _n.attributes.some(function (attr) {
  20486. return attr.value && isStringLiteral(attr.value) && attr.value.value.includes("\n");
  20487. });
  20488. return group$10(concat$11(["<", path.call(print, "name"), path.call(print, "typeParameters"), concat$11([indent$6(concat$11(path.map(function (attr) {
  20489. return concat$11([line$8, print(attr)]);
  20490. }, "attributes"))), _n.selfClosing ? line$8 : bracketSameLine ? ">" : softline$5]), _n.selfClosing ? "/>" : bracketSameLine ? "" : ">"]), {
  20491. shouldBreak: _shouldBreak
  20492. });
  20493. }
  20494. case "JSXClosingElement":
  20495. return concat$11(["</", path.call(print, "name"), ">"]);
  20496. case "JSXOpeningFragment":
  20497. case "JSXClosingFragment":
  20498. {
  20499. var hasComment = n.comments && n.comments.length;
  20500. var hasOwnLineComment = hasComment && !n.comments.every(comments$3.isBlockComment);
  20501. var isOpeningFragment = n.type === "JSXOpeningFragment";
  20502. return concat$11([isOpeningFragment ? "<" : "</", indent$6(concat$11([hasOwnLineComment ? hardline$8 : hasComment && !isOpeningFragment ? " " : "", comments.printDanglingComments(path, options, true)])), hasOwnLineComment ? hardline$8 : "", ">"]);
  20503. }
  20504. case "JSXText":
  20505. /* istanbul ignore next */
  20506. throw new Error("JSXTest should be handled by JSXElement");
  20507. case "JSXEmptyExpression":
  20508. {
  20509. var requiresHardline = n.comments && !n.comments.every(comments$3.isBlockComment);
  20510. return concat$11([comments.printDanglingComments(path, options,
  20511. /* sameIndent */
  20512. !requiresHardline), requiresHardline ? hardline$8 : ""]);
  20513. }
  20514. case "ClassBody":
  20515. if (!n.comments && n.body.length === 0) {
  20516. return "{}";
  20517. }
  20518. return concat$11(["{", n.body.length > 0 ? indent$6(concat$11([hardline$8, path.call(function (bodyPath) {
  20519. return printStatementSequence(bodyPath, options, print);
  20520. }, "body")])) : comments.printDanglingComments(path, options), hardline$8, "}"]);
  20521. case "ClassProperty":
  20522. case "TSAbstractClassProperty":
  20523. case "ClassPrivateProperty":
  20524. {
  20525. if (n.decorators && n.decorators.length !== 0) {
  20526. parts.push(printDecorators(path, options, print));
  20527. }
  20528. if (n.accessibility) {
  20529. parts.push(n.accessibility + " ");
  20530. }
  20531. if (n.static) {
  20532. parts.push("static ");
  20533. }
  20534. if (n.type === "TSAbstractClassProperty") {
  20535. parts.push("abstract ");
  20536. }
  20537. if (n.readonly) {
  20538. parts.push("readonly ");
  20539. }
  20540. var variance = getFlowVariance(n);
  20541. if (variance) {
  20542. parts.push(variance);
  20543. }
  20544. if (n.computed) {
  20545. parts.push("[", path.call(print, "key"), "]");
  20546. } else {
  20547. parts.push(printPropertyKey(path, options, print));
  20548. }
  20549. parts.push(printOptionalToken(path));
  20550. parts.push(printTypeAnnotation(path, options, print));
  20551. if (n.value) {
  20552. parts.push(" =", printAssignmentRight(n.key, n.value, path.call(print, "value"), options));
  20553. }
  20554. parts.push(semi);
  20555. return group$10(concat$11(parts));
  20556. }
  20557. case "ClassDeclaration":
  20558. case "ClassExpression":
  20559. if (isNodeStartingWithDeclare(n, options)) {
  20560. parts.push("declare ");
  20561. }
  20562. parts.push(concat$11(printClass(path, options, print)));
  20563. return concat$11(parts);
  20564. case "TSInterfaceHeritage":
  20565. parts.push(path.call(print, "expression"));
  20566. if (n.typeParameters) {
  20567. parts.push(path.call(print, "typeParameters"));
  20568. }
  20569. return concat$11(parts);
  20570. case "TemplateElement":
  20571. return join$7(literalline$3, n.value.raw.split(/\r?\n/g));
  20572. case "TemplateLiteral":
  20573. {
  20574. var expressions = path.map(print, "expressions");
  20575. var _parentNode = path.getParentNode();
  20576. if (isJestEachTemplateLiteral(n, _parentNode)) {
  20577. var _printed2 = printJestEachTemplateLiteral(n, expressions, options);
  20578. if (_printed2) {
  20579. return _printed2;
  20580. }
  20581. }
  20582. var isSimple = isSimpleTemplateLiteral(n);
  20583. if (isSimple) {
  20584. expressions = expressions.map(function (doc$$2) {
  20585. return printDocToString$1(doc$$2, Object.assign({}, options, {
  20586. printWidth: Infinity
  20587. })).formatted;
  20588. });
  20589. }
  20590. parts.push("`");
  20591. path.each(function (childPath) {
  20592. var i = childPath.getName();
  20593. parts.push(print(childPath));
  20594. if (i < expressions.length) {
  20595. // For a template literal of the following form:
  20596. // `someQuery {
  20597. // ${call({
  20598. // a,
  20599. // b,
  20600. // })}
  20601. // }`
  20602. // the expression is on its own line (there is a \n in the previous
  20603. // quasi literal), therefore we want to indent the JavaScript
  20604. // expression inside at the beginning of ${ instead of the beginning
  20605. // of the `.
  20606. var tabWidth = options.tabWidth;
  20607. var quasi = childPath.getValue();
  20608. var indentSize = getIndentSize$1(quasi.value.raw, tabWidth);
  20609. var _printed3 = expressions[i];
  20610. if (!isSimple) {
  20611. // Breaks at the template element boundaries (${ and }) are preferred to breaking
  20612. // in the middle of a MemberExpression
  20613. 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") {
  20614. _printed3 = concat$11([indent$6(concat$11([softline$5, _printed3])), softline$5]);
  20615. }
  20616. }
  20617. var aligned = indentSize === 0 && quasi.value.raw.endsWith("\n") ? align$1(-Infinity, _printed3) : addAlignmentToDoc$2(_printed3, indentSize, tabWidth);
  20618. parts.push(group$10(concat$11(["${", aligned, lineSuffixBoundary$1, "}"])));
  20619. }
  20620. }, "quasis");
  20621. parts.push("`");
  20622. return concat$11(parts);
  20623. }
  20624. // These types are unprintable because they serve as abstract
  20625. // supertypes for other (printable) types.
  20626. case "TaggedTemplateExpression":
  20627. return concat$11([path.call(print, "tag"), path.call(print, "typeParameters"), path.call(print, "quasi")]);
  20628. case "Node":
  20629. case "Printable":
  20630. case "SourceLocation":
  20631. case "Position":
  20632. case "Statement":
  20633. case "Function":
  20634. case "Pattern":
  20635. case "Expression":
  20636. case "Declaration":
  20637. case "Specifier":
  20638. case "NamedSpecifier":
  20639. case "Comment":
  20640. case "MemberTypeAnnotation": // Flow
  20641. case "Type":
  20642. /* istanbul ignore next */
  20643. throw new Error("unprintable type: " + JSON.stringify(n.type));
  20644. // Type Annotations for Facebook Flow, typically stripped out or
  20645. // transformed away before printing.
  20646. case "TypeAnnotation":
  20647. case "TSTypeAnnotation":
  20648. if (n.typeAnnotation) {
  20649. return path.call(print, "typeAnnotation");
  20650. }
  20651. /* istanbul ignore next */
  20652. return "";
  20653. case "TSTupleType":
  20654. case "TupleTypeAnnotation":
  20655. {
  20656. var typesField = n.type === "TSTupleType" ? "elementTypes" : "types";
  20657. return group$10(concat$11(["[", indent$6(concat$11([softline$5, printArrayItems(path, options, typesField, print)])), ifBreak$6(shouldPrintComma$1(options, "all") ? "," : ""), comments.printDanglingComments(path, options,
  20658. /* sameIndent */
  20659. true), softline$5, "]"]));
  20660. }
  20661. case "ExistsTypeAnnotation":
  20662. return "*";
  20663. case "EmptyTypeAnnotation":
  20664. return "empty";
  20665. case "AnyTypeAnnotation":
  20666. return "any";
  20667. case "MixedTypeAnnotation":
  20668. return "mixed";
  20669. case "ArrayTypeAnnotation":
  20670. return concat$11([path.call(print, "elementType"), "[]"]);
  20671. case "BooleanTypeAnnotation":
  20672. return "boolean";
  20673. case "BooleanLiteralTypeAnnotation":
  20674. return "" + n.value;
  20675. case "DeclareClass":
  20676. return printFlowDeclaration(path, printClass(path, options, print));
  20677. case "TSDeclareFunction":
  20678. // For TypeScript the TSDeclareFunction node shares the AST
  20679. // structure with FunctionDeclaration
  20680. return concat$11([n.declare ? "declare " : "", printFunctionDeclaration(path, print, options), semi]);
  20681. case "DeclareFunction":
  20682. return printFlowDeclaration(path, ["function ", path.call(print, "id"), n.predicate ? " " : "", path.call(print, "predicate"), semi]);
  20683. case "DeclareModule":
  20684. return printFlowDeclaration(path, ["module ", path.call(print, "id"), " ", path.call(print, "body")]);
  20685. case "DeclareModuleExports":
  20686. return printFlowDeclaration(path, ["module.exports", ": ", path.call(print, "typeAnnotation"), semi]);
  20687. case "DeclareVariable":
  20688. return printFlowDeclaration(path, ["var ", path.call(print, "id"), semi]);
  20689. case "DeclareExportAllDeclaration":
  20690. return concat$11(["declare export * from ", path.call(print, "source")]);
  20691. case "DeclareExportDeclaration":
  20692. return concat$11(["declare ", printExportDeclaration(path, options, print)]);
  20693. case "DeclareOpaqueType":
  20694. case "OpaqueType":
  20695. {
  20696. parts.push("opaque type ", path.call(print, "id"), path.call(print, "typeParameters"));
  20697. if (n.supertype) {
  20698. parts.push(": ", path.call(print, "supertype"));
  20699. }
  20700. if (n.impltype) {
  20701. parts.push(" = ", path.call(print, "impltype"));
  20702. }
  20703. parts.push(semi);
  20704. if (n.type === "DeclareOpaqueType") {
  20705. return printFlowDeclaration(path, parts);
  20706. }
  20707. return concat$11(parts);
  20708. }
  20709. case "FunctionTypeAnnotation":
  20710. case "TSFunctionType":
  20711. {
  20712. // FunctionTypeAnnotation is ambiguous:
  20713. // declare function foo(a: B): void; OR
  20714. // var A: (a: B) => void;
  20715. var _parent7 = path.getParentNode(0);
  20716. var _parentParent2 = path.getParentNode(1);
  20717. var _parentParentParent = path.getParentNode(2);
  20718. 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");
  20719. var needsColon = isArrowFunctionTypeAnnotation && (_parent7.type === "TypeAnnotation" || _parent7.type === "TSTypeAnnotation"); // Sadly we can't put it inside of FastPath::needsColon because we are
  20720. // printing ":" as part of the expression and it would put parenthesis
  20721. // around :(
  20722. var needsParens = needsColon && isArrowFunctionTypeAnnotation && (_parent7.type === "TypeAnnotation" || _parent7.type === "TSTypeAnnotation") && _parentParent2.type === "ArrowFunctionExpression";
  20723. if (isObjectTypePropertyAFunction(_parent7, options)) {
  20724. isArrowFunctionTypeAnnotation = true;
  20725. needsColon = true;
  20726. }
  20727. if (needsParens) {
  20728. parts.push("(");
  20729. }
  20730. parts.push(printFunctionParams(path, print, options,
  20731. /* expandArg */
  20732. false,
  20733. /* printTypeParams */
  20734. true)); // The returnType is not wrapped in a TypeAnnotation, so the colon
  20735. // needs to be added separately.
  20736. if (n.returnType || n.predicate || n.typeAnnotation) {
  20737. parts.push(isArrowFunctionTypeAnnotation ? " => " : ": ", path.call(print, "returnType"), path.call(print, "predicate"), path.call(print, "typeAnnotation"));
  20738. }
  20739. if (needsParens) {
  20740. parts.push(")");
  20741. }
  20742. return group$10(concat$11(parts));
  20743. }
  20744. case "TSRestType":
  20745. return concat$11(["...", path.call(print, "typeAnnotation")]);
  20746. case "TSOptionalType":
  20747. return concat$11([path.call(print, "typeAnnotation"), "?"]);
  20748. case "FunctionTypeParam":
  20749. return concat$11([path.call(print, "name"), printOptionalToken(path), n.name ? ": " : "", path.call(print, "typeAnnotation")]);
  20750. case "GenericTypeAnnotation":
  20751. return concat$11([path.call(print, "id"), path.call(print, "typeParameters")]);
  20752. case "DeclareInterface":
  20753. case "InterfaceDeclaration":
  20754. case "InterfaceTypeAnnotation":
  20755. {
  20756. if (n.type === "DeclareInterface" || isNodeStartingWithDeclare(n, options)) {
  20757. parts.push("declare ");
  20758. }
  20759. parts.push("interface");
  20760. if (n.type === "DeclareInterface" || n.type === "InterfaceDeclaration") {
  20761. parts.push(" ", path.call(print, "id"), path.call(print, "typeParameters"));
  20762. }
  20763. if (n["extends"].length > 0) {
  20764. 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")))]))));
  20765. }
  20766. parts.push(" ", path.call(print, "body"));
  20767. return group$10(concat$11(parts));
  20768. }
  20769. case "ClassImplements":
  20770. case "InterfaceExtends":
  20771. return concat$11([path.call(print, "id"), path.call(print, "typeParameters")]);
  20772. case "TSClassImplements":
  20773. return concat$11([path.call(print, "expression"), path.call(print, "typeParameters")]);
  20774. case "TSIntersectionType":
  20775. case "IntersectionTypeAnnotation":
  20776. {
  20777. var types = path.map(print, "types");
  20778. var result = [];
  20779. var wasIndented = false;
  20780. for (var _i = 0; _i < types.length; ++_i) {
  20781. if (_i === 0) {
  20782. result.push(types[_i]);
  20783. } else if (isObjectType(n.types[_i - 1]) && isObjectType(n.types[_i])) {
  20784. // If both are objects, don't indent
  20785. result.push(concat$11([" & ", wasIndented ? indent$6(types[_i]) : types[_i]]));
  20786. } else if (!isObjectType(n.types[_i - 1]) && !isObjectType(n.types[_i])) {
  20787. // If no object is involved, go to the next line if it breaks
  20788. result.push(indent$6(concat$11([" &", line$8, types[_i]])));
  20789. } else {
  20790. // If you go from object to non-object or vis-versa, then inline it
  20791. if (_i > 1) {
  20792. wasIndented = true;
  20793. }
  20794. result.push(" & ", _i > 1 ? indent$6(types[_i]) : types[_i]);
  20795. }
  20796. }
  20797. return group$10(concat$11(result));
  20798. }
  20799. case "TSUnionType":
  20800. case "UnionTypeAnnotation":
  20801. {
  20802. // single-line variation
  20803. // A | B | C
  20804. // multi-line variation
  20805. // | A
  20806. // | B
  20807. // | C
  20808. var _parent8 = path.getParentNode(); // If there's a leading comment, the parent is doing the indentation
  20809. 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)); // {
  20810. // a: string
  20811. // } | null | void
  20812. // should be inlined and not be printed in the multi-line variant
  20813. var shouldHug = shouldHugType(n); // We want to align the children but without its comment, so it looks like
  20814. // | child1
  20815. // // comment
  20816. // | child2
  20817. var _printed4 = path.map(function (typePath) {
  20818. var printedType = typePath.call(print);
  20819. if (!shouldHug) {
  20820. printedType = align$1(2, printedType);
  20821. }
  20822. return comments.printComments(typePath, function () {
  20823. return printedType;
  20824. }, options);
  20825. }, "types");
  20826. if (shouldHug) {
  20827. return join$7(" | ", _printed4);
  20828. }
  20829. var shouldAddStartLine = shouldIndent && !hasLeadingOwnLineComment(options.originalText, n, options);
  20830. var code = concat$11([ifBreak$6(concat$11([shouldAddStartLine ? line$8 : "", "| "])), join$7(concat$11([line$8, "| "]), _printed4)]);
  20831. var hasParens;
  20832. if (n.type === "TSUnionType") {
  20833. var greatGrandParent = path.getParentNode(2);
  20834. var greatGreatGrandParent = path.getParentNode(3);
  20835. hasParens = greatGrandParent && greatGrandParent.type === "TSParenthesizedType" && greatGreatGrandParent && (greatGreatGrandParent.type === "TSUnionType" || greatGreatGrandParent.type === "TSIntersectionType");
  20836. } else {
  20837. hasParens = needsParens_1(path, options);
  20838. }
  20839. if (hasParens) {
  20840. return group$10(concat$11([indent$6(code), softline$5]));
  20841. }
  20842. return group$10(shouldIndent ? indent$6(code) : code);
  20843. }
  20844. case "NullableTypeAnnotation":
  20845. return concat$11(["?", path.call(print, "typeAnnotation")]);
  20846. case "TSNullKeyword":
  20847. case "NullLiteralTypeAnnotation":
  20848. return "null";
  20849. case "ThisTypeAnnotation":
  20850. return "this";
  20851. case "NumberTypeAnnotation":
  20852. return "number";
  20853. case "ObjectTypeCallProperty":
  20854. if (n.static) {
  20855. parts.push("static ");
  20856. }
  20857. parts.push(path.call(print, "value"));
  20858. return concat$11(parts);
  20859. case "ObjectTypeIndexer":
  20860. {
  20861. var _variance = getFlowVariance(n);
  20862. return concat$11([_variance || "", "[", path.call(print, "id"), n.id ? ": " : "", path.call(print, "key"), "]: ", path.call(print, "value")]);
  20863. }
  20864. case "ObjectTypeProperty":
  20865. {
  20866. var _variance2 = getFlowVariance(n);
  20867. var modifier = "";
  20868. if (n.proto) {
  20869. modifier = "proto ";
  20870. } else if (n.static) {
  20871. modifier = "static ";
  20872. }
  20873. return concat$11([modifier, isGetterOrSetter(n) ? n.kind + " " : "", _variance2 || "", printPropertyKey(path, options, print), printOptionalToken(path), isFunctionNotation(n, options) ? "" : ": ", path.call(print, "value")]);
  20874. }
  20875. case "QualifiedTypeIdentifier":
  20876. return concat$11([path.call(print, "qualification"), ".", path.call(print, "id")]);
  20877. case "StringLiteralTypeAnnotation":
  20878. return nodeStr(n, options);
  20879. case "NumberLiteralTypeAnnotation":
  20880. assert$3.strictEqual(_typeof(n.value), "number");
  20881. if (n.extra != null) {
  20882. return printNumber$2(n.extra.raw);
  20883. }
  20884. return printNumber$2(n.raw);
  20885. case "StringTypeAnnotation":
  20886. return "string";
  20887. case "DeclareTypeAlias":
  20888. case "TypeAlias":
  20889. {
  20890. if (n.type === "DeclareTypeAlias" || isNodeStartingWithDeclare(n, options)) {
  20891. parts.push("declare ");
  20892. }
  20893. var _printed5 = printAssignmentRight(n.id, n.right, path.call(print, "right"), options);
  20894. parts.push("type ", path.call(print, "id"), path.call(print, "typeParameters"), " =", _printed5, semi);
  20895. return group$10(concat$11(parts));
  20896. }
  20897. case "TypeCastExpression":
  20898. {
  20899. var value = path.getValue(); // Flow supports a comment syntax for specifying type annotations: https://flow.org/en/docs/types/comments/.
  20900. // Unfortunately, its parser doesn't differentiate between comment annotations and regular
  20901. // annotations when producing an AST. So to preserve parentheses around type casts that use
  20902. // the comment syntax, we need to hackily read the source itself to see if the code contains
  20903. // a type annotation comment.
  20904. //
  20905. // Note that we're able to use the normal whitespace regex here because the Flow parser has
  20906. // already deemed this AST node to be a type cast. Only the Babel parser needs the
  20907. // non-line-break whitespace regex, which is why hasFlowShorthandAnnotationComment() is
  20908. // implemented differently.
  20909. var commentSyntax = value && value.typeAnnotation && value.typeAnnotation.range && options.originalText.substring(value.typeAnnotation.range[0]).match(/^\/\*\s*:/);
  20910. return concat$11(["(", path.call(print, "expression"), commentSyntax ? " /*" : "", ": ", path.call(print, "typeAnnotation"), commentSyntax ? " */" : "", ")"]);
  20911. }
  20912. case "TypeParameterDeclaration":
  20913. case "TypeParameterInstantiation":
  20914. {
  20915. var _value = path.getValue();
  20916. 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
  20917. // because we know for sure that this is a type definition.
  20918. var _commentSyntax = commentStart >= 0 && options.originalText.substring(commentStart).match(/^\/\*\s*::/);
  20919. if (_commentSyntax) {
  20920. return concat$11(["/*:: ", printTypeParameters(path, options, print, "params"), " */"]);
  20921. }
  20922. return printTypeParameters(path, options, print, "params");
  20923. }
  20924. case "TSTypeParameterDeclaration":
  20925. case "TSTypeParameterInstantiation":
  20926. return printTypeParameters(path, options, print, "params");
  20927. case "TSTypeParameter":
  20928. case "TypeParameter":
  20929. {
  20930. var _parent9 = path.getParentNode();
  20931. if (_parent9.type === "TSMappedType") {
  20932. parts.push("[", path.call(print, "name"));
  20933. if (n.constraint) {
  20934. parts.push(" in ", path.call(print, "constraint"));
  20935. }
  20936. parts.push("]");
  20937. return concat$11(parts);
  20938. }
  20939. var _variance3 = getFlowVariance(n);
  20940. if (_variance3) {
  20941. parts.push(_variance3);
  20942. }
  20943. parts.push(path.call(print, "name"));
  20944. if (n.bound) {
  20945. parts.push(": ");
  20946. parts.push(path.call(print, "bound"));
  20947. }
  20948. if (n.constraint) {
  20949. parts.push(" extends ", path.call(print, "constraint"));
  20950. }
  20951. if (n["default"]) {
  20952. parts.push(" = ", path.call(print, "default"));
  20953. } // Keep comma if the file extension is .tsx and
  20954. // has one type parameter that isn't extend with any types.
  20955. // Because, otherwise formatted result will be invalid as tsx.
  20956. var _grandParent = path.getNode(2);
  20957. if (_parent9.params && _parent9.params.length === 1 && options.filepath && /\.tsx$/i.test(options.filepath) && !n.constraint && _grandParent.type === "ArrowFunctionExpression") {
  20958. parts.push(",");
  20959. }
  20960. return concat$11(parts);
  20961. }
  20962. case "TypeofTypeAnnotation":
  20963. return concat$11(["typeof ", path.call(print, "argument")]);
  20964. case "VoidTypeAnnotation":
  20965. return "void";
  20966. case "InferredPredicate":
  20967. return "%checks";
  20968. // Unhandled types below. If encountered, nodes of these types should
  20969. // be either left alone or desugared into AST types that are fully
  20970. // supported by the pretty-printer.
  20971. case "DeclaredPredicate":
  20972. return concat$11(["%checks(", path.call(print, "value"), ")"]);
  20973. case "TSAbstractKeyword":
  20974. return "abstract";
  20975. case "TSAnyKeyword":
  20976. return "any";
  20977. case "TSAsyncKeyword":
  20978. return "async";
  20979. case "TSBooleanKeyword":
  20980. return "boolean";
  20981. case "TSBigIntKeyword":
  20982. return "bigint";
  20983. case "TSConstKeyword":
  20984. return "const";
  20985. case "TSDeclareKeyword":
  20986. return "declare";
  20987. case "TSExportKeyword":
  20988. return "export";
  20989. case "TSNeverKeyword":
  20990. return "never";
  20991. case "TSNumberKeyword":
  20992. return "number";
  20993. case "TSObjectKeyword":
  20994. return "object";
  20995. case "TSProtectedKeyword":
  20996. return "protected";
  20997. case "TSPrivateKeyword":
  20998. return "private";
  20999. case "TSPublicKeyword":
  21000. return "public";
  21001. case "TSReadonlyKeyword":
  21002. return "readonly";
  21003. case "TSSymbolKeyword":
  21004. return "symbol";
  21005. case "TSStaticKeyword":
  21006. return "static";
  21007. case "TSStringKeyword":
  21008. return "string";
  21009. case "TSUndefinedKeyword":
  21010. return "undefined";
  21011. case "TSUnknownKeyword":
  21012. return "unknown";
  21013. case "TSVoidKeyword":
  21014. return "void";
  21015. case "TSAsExpression":
  21016. return concat$11([path.call(print, "expression"), " as ", path.call(print, "typeAnnotation")]);
  21017. case "TSArrayType":
  21018. return concat$11([path.call(print, "elementType"), "[]"]);
  21019. case "TSPropertySignature":
  21020. {
  21021. if (n.export) {
  21022. parts.push("export ");
  21023. }
  21024. if (n.accessibility) {
  21025. parts.push(n.accessibility + " ");
  21026. }
  21027. if (n.static) {
  21028. parts.push("static ");
  21029. }
  21030. if (n.readonly) {
  21031. parts.push("readonly ");
  21032. }
  21033. if (n.computed) {
  21034. parts.push("[");
  21035. }
  21036. parts.push(printPropertyKey(path, options, print));
  21037. if (n.computed) {
  21038. parts.push("]");
  21039. }
  21040. parts.push(printOptionalToken(path));
  21041. if (n.typeAnnotation) {
  21042. parts.push(": ");
  21043. parts.push(path.call(print, "typeAnnotation"));
  21044. } // This isn't valid semantically, but it's in the AST so we can print it.
  21045. if (n.initializer) {
  21046. parts.push(" = ", path.call(print, "initializer"));
  21047. }
  21048. return concat$11(parts);
  21049. }
  21050. case "TSParameterProperty":
  21051. if (n.accessibility) {
  21052. parts.push(n.accessibility + " ");
  21053. }
  21054. if (n.export) {
  21055. parts.push("export ");
  21056. }
  21057. if (n.static) {
  21058. parts.push("static ");
  21059. }
  21060. if (n.readonly) {
  21061. parts.push("readonly ");
  21062. }
  21063. parts.push(path.call(print, "parameter"));
  21064. return concat$11(parts);
  21065. case "TSTypeReference":
  21066. return concat$11([path.call(print, "typeName"), printTypeParameters(path, options, print, "typeParameters")]);
  21067. case "TSTypeQuery":
  21068. return concat$11(["typeof ", path.call(print, "exprName")]);
  21069. case "TSParenthesizedType":
  21070. {
  21071. return path.call(print, "typeAnnotation");
  21072. }
  21073. case "TSIndexSignature":
  21074. {
  21075. var _parent10 = path.getParentNode();
  21076. 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 : ""]);
  21077. }
  21078. case "TSTypePredicate":
  21079. return concat$11([path.call(print, "parameterName"), " is ", path.call(print, "typeAnnotation")]);
  21080. case "TSNonNullExpression":
  21081. return concat$11([path.call(print, "expression"), "!"]);
  21082. case "TSThisType":
  21083. return "this";
  21084. case "TSImportType":
  21085. return concat$11([!n.isTypeOf ? "" : "typeof ", "import(", path.call(print, "parameter"), ")", !n.qualifier ? "" : concat$11([".", path.call(print, "qualifier")]), printTypeParameters(path, options, print, "typeParameters")]);
  21086. case "TSLiteralType":
  21087. return path.call(print, "literal");
  21088. case "TSIndexedAccessType":
  21089. return concat$11([path.call(print, "objectType"), "[", path.call(print, "indexType"), "]"]);
  21090. case "TSConstructSignatureDeclaration":
  21091. case "TSCallSignatureDeclaration":
  21092. case "TSConstructorType":
  21093. {
  21094. if (n.type !== "TSCallSignatureDeclaration") {
  21095. parts.push("new ");
  21096. }
  21097. parts.push(group$10(printFunctionParams(path, print, options,
  21098. /* expandArg */
  21099. false,
  21100. /* printTypeParams */
  21101. true)));
  21102. if (n.returnType) {
  21103. var isType = n.type === "TSConstructorType";
  21104. parts.push(isType ? " => " : ": ", path.call(print, "returnType"));
  21105. }
  21106. return concat$11(parts);
  21107. }
  21108. case "TSTypeOperator":
  21109. return concat$11([n.operator, " ", path.call(print, "typeAnnotation")]);
  21110. case "TSMappedType":
  21111. {
  21112. var _shouldBreak2 = hasNewlineInRange$1(options.originalText, options.locStart(n), options.locEnd(n));
  21113. 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"), _shouldBreak2 && options.semi ? ";" : ""])), comments.printDanglingComments(path, options,
  21114. /* sameIndent */
  21115. true), options.bracketSpacing ? line$8 : softline$5, "}"]), {
  21116. shouldBreak: _shouldBreak2
  21117. });
  21118. }
  21119. case "TSMethodSignature":
  21120. 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,
  21121. /* expandArg */
  21122. false,
  21123. /* printTypeParams */
  21124. true));
  21125. if (n.returnType) {
  21126. parts.push(": ", path.call(print, "returnType"));
  21127. }
  21128. return group$10(concat$11(parts));
  21129. case "TSNamespaceExportDeclaration":
  21130. parts.push("export as namespace ", path.call(print, "id"));
  21131. if (options.semi) {
  21132. parts.push(";");
  21133. }
  21134. return group$10(concat$11(parts));
  21135. case "TSEnumDeclaration":
  21136. if (isNodeStartingWithDeclare(n, options)) {
  21137. parts.push("declare ");
  21138. }
  21139. if (n.modifiers) {
  21140. parts.push(printTypeScriptModifiers(path, options, print));
  21141. }
  21142. if (n.const) {
  21143. parts.push("const ");
  21144. }
  21145. parts.push("enum ", path.call(print, "id"), " ");
  21146. if (n.members.length === 0) {
  21147. parts.push(group$10(concat$11(["{", comments.printDanglingComments(path, options), softline$5, "}"])));
  21148. } else {
  21149. 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,
  21150. /* sameIndent */
  21151. true), hardline$8, "}"])));
  21152. }
  21153. return concat$11(parts);
  21154. case "TSEnumMember":
  21155. parts.push(path.call(print, "id"));
  21156. if (n.initializer) {
  21157. parts.push(" = ", path.call(print, "initializer"));
  21158. }
  21159. return concat$11(parts);
  21160. case "TSImportEqualsDeclaration":
  21161. if (n.isExport) {
  21162. parts.push("export ");
  21163. }
  21164. parts.push("import ", path.call(print, "id"), " = ", path.call(print, "moduleReference"));
  21165. if (options.semi) {
  21166. parts.push(";");
  21167. }
  21168. return group$10(concat$11(parts));
  21169. case "TSExternalModuleReference":
  21170. return concat$11(["require(", path.call(print, "expression"), ")"]);
  21171. case "TSModuleDeclaration":
  21172. {
  21173. var _parent11 = path.getParentNode();
  21174. var isExternalModule = isLiteral(n.id);
  21175. var parentIsDeclaration = _parent11.type === "TSModuleDeclaration";
  21176. var bodyIsDeclaration = n.body && n.body.type === "TSModuleDeclaration";
  21177. if (parentIsDeclaration) {
  21178. parts.push(".");
  21179. } else {
  21180. if (n.declare === true) {
  21181. parts.push("declare ");
  21182. }
  21183. parts.push(printTypeScriptModifiers(path, options, print));
  21184. var textBetweenNodeAndItsId = options.originalText.slice(options.locStart(n), options.locStart(n.id)); // Global declaration looks like this:
  21185. // (declare)? global { ... }
  21186. var isGlobalDeclaration = n.id.type === "Identifier" && n.id.name === "global" && !/namespace|module/.test(textBetweenNodeAndItsId);
  21187. if (!isGlobalDeclaration) {
  21188. parts.push(isExternalModule || /(^|\s)module(\s|$)/.test(textBetweenNodeAndItsId) ? "module " : "namespace ");
  21189. }
  21190. }
  21191. parts.push(path.call(print, "id"));
  21192. if (bodyIsDeclaration) {
  21193. parts.push(path.call(print, "body"));
  21194. } else if (n.body) {
  21195. parts.push(" ", group$10(path.call(print, "body")));
  21196. } else {
  21197. parts.push(semi);
  21198. }
  21199. return concat$11(parts);
  21200. }
  21201. case "PrivateName":
  21202. return concat$11(["#", path.call(print, "id")]);
  21203. case "TSConditionalType":
  21204. return printTernaryOperator(path, options, print, {
  21205. beforeParts: function beforeParts() {
  21206. return [path.call(print, "checkType"), " ", "extends", " ", path.call(print, "extendsType")];
  21207. },
  21208. afterParts: function afterParts() {
  21209. return [];
  21210. },
  21211. shouldCheckJsx: false,
  21212. conditionalNodeType: "TSConditionalType",
  21213. consequentNodePropertyName: "trueType",
  21214. alternateNodePropertyName: "falseType",
  21215. testNodePropertyName: "checkType",
  21216. breakNested: true
  21217. });
  21218. case "TSInferType":
  21219. return concat$11(["infer", " ", path.call(print, "typeParameter")]);
  21220. case "InterpreterDirective":
  21221. parts.push("#!", n.value, hardline$8);
  21222. if (isNextLineEmpty$4(options.originalText, n, options)) {
  21223. parts.push(hardline$8);
  21224. }
  21225. return concat$11(parts);
  21226. case "NGRoot":
  21227. return concat$11([].concat(path.call(print, "node"), !n.node.comments || n.node.comments.length === 0 ? [] : concat$11([" //", n.node.comments[0].value.trimRight()])));
  21228. case "NGChainedExpression":
  21229. return group$10(join$7(concat$11([";", line$8]), path.map(function (childPath) {
  21230. return hasNgSideEffect(childPath) ? print(childPath) : concat$11(["(", print(childPath), ")"]);
  21231. }, "expressions")));
  21232. case "NGEmptyExpression":
  21233. return "";
  21234. case "NGQuotedExpression":
  21235. return concat$11([n.prefix, ":", n.value]);
  21236. case "NGMicrosyntax":
  21237. return concat$11(path.map(function (childPath, index) {
  21238. return concat$11([index === 0 ? "" : isNgForOf(childPath.getValue(), index, n) ? " " : concat$11([";", line$8]), print(childPath)]);
  21239. }, "body"));
  21240. case "NGMicrosyntaxKey":
  21241. return /^[a-z_$][a-z0-9_$]*(-[a-z_$][a-z0-9_$])*$/i.test(n.name) ? n.name : JSON.stringify(n.name);
  21242. case "NGMicrosyntaxExpression":
  21243. return concat$11([path.call(print, "expression"), n.alias === null ? "" : concat$11([" as ", path.call(print, "alias")])]);
  21244. case "NGMicrosyntaxKeyedExpression":
  21245. {
  21246. var index = path.getName();
  21247. var _parentNode2 = path.getParentNode();
  21248. 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";
  21249. return concat$11([path.call(print, "key"), shouldNotPrintColon ? " " : ": ", path.call(print, "expression")]);
  21250. }
  21251. case "NGMicrosyntaxLet":
  21252. return concat$11(["let ", path.call(print, "key"), n.value === null ? "" : concat$11([" = ", path.call(print, "value")])]);
  21253. case "NGMicrosyntaxAs":
  21254. return concat$11([path.call(print, "key"), " as ", path.call(print, "alias")]);
  21255. default:
  21256. /* istanbul ignore next */
  21257. throw new Error("unknown type: " + JSON.stringify(n.type));
  21258. }
  21259. }
  21260. function isNgForOf(node, index, parentNode) {
  21261. return node.type === "NGMicrosyntaxKeyedExpression" && node.key.name === "of" && index === 1 && parentNode.body[0].type === "NGMicrosyntaxLet" && parentNode.body[0].value === null;
  21262. }
  21263. /** identify if an angular expression seems to have side effects */
  21264. function hasNgSideEffect(path) {
  21265. return hasNode(path.getValue(), function (node) {
  21266. switch (node.type) {
  21267. case undefined:
  21268. return false;
  21269. case "CallExpression":
  21270. case "OptionalCallExpression":
  21271. case "AssignmentExpression":
  21272. return true;
  21273. }
  21274. });
  21275. }
  21276. function printStatementSequence(path, options, print) {
  21277. var printed = [];
  21278. var bodyNode = path.getNode();
  21279. var isClass = bodyNode.type === "ClassBody";
  21280. path.map(function (stmtPath, i) {
  21281. var stmt = stmtPath.getValue(); // Just in case the AST has been modified to contain falsy
  21282. // "statements," it's safer simply to skip them.
  21283. /* istanbul ignore if */
  21284. if (!stmt) {
  21285. return;
  21286. } // Skip printing EmptyStatement nodes to avoid leaving stray
  21287. // semicolons lying around.
  21288. if (stmt.type === "EmptyStatement") {
  21289. return;
  21290. }
  21291. var stmtPrinted = print(stmtPath);
  21292. var text = options.originalText;
  21293. var parts = []; // in no-semi mode, prepend statement with semicolon if it might break ASI
  21294. // don't prepend the only JSX element in a program with semicolon
  21295. if (!options.semi && !isClass && !isTheOnlyJSXElementInMarkdown(options, stmtPath) && stmtNeedsASIProtection(stmtPath, options)) {
  21296. if (stmt.comments && stmt.comments.some(function (comment) {
  21297. return comment.leading;
  21298. })) {
  21299. parts.push(print(stmtPath, {
  21300. needsSemi: true
  21301. }));
  21302. } else {
  21303. parts.push(";", stmtPrinted);
  21304. }
  21305. } else {
  21306. parts.push(stmtPrinted);
  21307. }
  21308. if (!options.semi && isClass) {
  21309. if (classPropMayCauseASIProblems(stmtPath)) {
  21310. parts.push(";");
  21311. } else if (stmt.type === "ClassProperty") {
  21312. var nextChild = bodyNode.body[i + 1];
  21313. if (classChildNeedsASIProtection(nextChild)) {
  21314. parts.push(";");
  21315. }
  21316. }
  21317. }
  21318. if (isNextLineEmpty$4(text, stmt, options) && !isLastStatement(stmtPath)) {
  21319. parts.push(hardline$8);
  21320. }
  21321. printed.push(concat$11(parts));
  21322. });
  21323. return join$7(hardline$8, printed);
  21324. }
  21325. function printPropertyKey(path, options, print) {
  21326. var node = path.getNode();
  21327. var parent = path.getParentNode();
  21328. var key = node.key;
  21329. if (options.quoteProps === "consistent" && !needsQuoteProps.has(parent)) {
  21330. var objectHasStringProp = (parent.properties || parent.body || parent.members).some(function (prop) {
  21331. return !prop.computed && prop.key && isStringLiteral(prop.key) && !isStringPropSafeToCoerceToIdentifier(prop, options);
  21332. });
  21333. needsQuoteProps.set(parent, objectHasStringProp);
  21334. }
  21335. if (key.type === "Identifier" && !node.computed && (options.parser === "json" || options.quoteProps === "consistent" && needsQuoteProps.get(parent))) {
  21336. // a -> "a"
  21337. var prop = printString$2(JSON.stringify(key.name), options);
  21338. return path.call(function (keyPath) {
  21339. return comments.printComments(keyPath, function () {
  21340. return prop;
  21341. }, options);
  21342. }, "key");
  21343. }
  21344. if (!node.computed && isStringPropSafeToCoerceToIdentifier(node, options) && (options.quoteProps === "as-needed" || options.quoteProps === "consistent" && !needsQuoteProps.get(parent))) {
  21345. // 'a' -> a
  21346. return path.call(function (keyPath) {
  21347. return comments.printComments(keyPath, function () {
  21348. return key.value;
  21349. }, options);
  21350. }, "key");
  21351. }
  21352. return path.call(print, "key");
  21353. }
  21354. function printMethod(path, options, print) {
  21355. var node = path.getNode();
  21356. var semi = options.semi ? ";" : "";
  21357. var kind = node.kind;
  21358. var parts = [];
  21359. if (node.type === "ObjectMethod" || node.type === "ClassMethod" || node.type === "ClassPrivateMethod") {
  21360. node.value = node;
  21361. }
  21362. if (node.value.async) {
  21363. parts.push("async ");
  21364. }
  21365. if (!kind || kind === "init" || kind === "method" || kind === "constructor") {
  21366. if (node.value.generator) {
  21367. parts.push("*");
  21368. }
  21369. } else {
  21370. assert$3.ok(kind === "get" || kind === "set");
  21371. parts.push(kind, " ");
  21372. }
  21373. var key = printPropertyKey(path, options, print);
  21374. if (node.computed) {
  21375. key = concat$11(["[", key, "]"]);
  21376. }
  21377. parts.push(key, concat$11(path.call(function (valuePath) {
  21378. return [printFunctionTypeParameters(valuePath, options, print), group$10(concat$11([printFunctionParams(valuePath, print, options), printReturnType(valuePath, print, options)]))];
  21379. }, "value")));
  21380. if (!node.value.body || node.value.body.length === 0) {
  21381. parts.push(semi);
  21382. } else {
  21383. parts.push(" ", path.call(print, "value", "body"));
  21384. }
  21385. return concat$11(parts);
  21386. }
  21387. function couldGroupArg(arg) {
  21388. return arg.type === "ObjectExpression" && (arg.properties.length > 0 || arg.comments) || arg.type === "ArrayExpression" && (arg.elements.length > 0 || arg.comments) || arg.type === "TSTypeAssertion" || arg.type === "TSAsExpression" || arg.type === "FunctionExpression" || arg.type === "ArrowFunctionExpression" && ( // we want to avoid breaking inside composite return types but not simple keywords
  21389. // https://github.com/prettier/prettier/issues/4070
  21390. // export class Thing implements OtherThing {
  21391. // do: (type: Type) => Provider<Prop> = memoize(
  21392. // (type: ObjectType): Provider<Opts> => {}
  21393. // );
  21394. // }
  21395. // https://github.com/prettier/prettier/issues/6099
  21396. // app.get("/", (req, res): void => {
  21397. // res.send("Hello World!");
  21398. // });
  21399. !arg.returnType || !arg.returnType.typeAnnotation || arg.returnType.typeAnnotation.type !== "TSTypeReference") && (arg.body.type === "BlockStatement" || arg.body.type === "ArrowFunctionExpression" || arg.body.type === "ObjectExpression" || arg.body.type === "ArrayExpression" || arg.body.type === "CallExpression" || arg.body.type === "OptionalCallExpression" || arg.body.type === "ConditionalExpression" || isJSXNode(arg.body));
  21400. }
  21401. function shouldGroupLastArg(args) {
  21402. var lastArg = getLast$3(args);
  21403. var penultimateArg = getPenultimate$1(args);
  21404. return !hasLeadingComment(lastArg) && !hasTrailingComment(lastArg) && couldGroupArg(lastArg) && ( // If the last two arguments are of the same type,
  21405. // disable last element expansion.
  21406. !penultimateArg || penultimateArg.type !== lastArg.type);
  21407. }
  21408. function shouldGroupFirstArg(args) {
  21409. if (args.length !== 2) {
  21410. return false;
  21411. }
  21412. var firstArg = args[0];
  21413. var secondArg = args[1];
  21414. 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);
  21415. }
  21416. function isSimpleFlowType(node) {
  21417. var flowTypeAnnotations = ["AnyTypeAnnotation", "NullLiteralTypeAnnotation", "GenericTypeAnnotation", "ThisTypeAnnotation", "NumberTypeAnnotation", "VoidTypeAnnotation", "EmptyTypeAnnotation", "MixedTypeAnnotation", "BooleanTypeAnnotation", "BooleanLiteralTypeAnnotation", "StringTypeAnnotation"];
  21418. return node && flowTypeAnnotations.indexOf(node.type) !== -1 && !(node.type === "GenericTypeAnnotation" && node.typeParameters);
  21419. }
  21420. function isJestEachTemplateLiteral(node, parentNode) {
  21421. /**
  21422. * describe.each`table`(name, fn)
  21423. * describe.only.each`table`(name, fn)
  21424. * describe.skip.each`table`(name, fn)
  21425. * test.each`table`(name, fn)
  21426. * test.only.each`table`(name, fn)
  21427. * test.skip.each`table`(name, fn)
  21428. *
  21429. * Ref: https://github.com/facebook/jest/pull/6102
  21430. */
  21431. var jestEachTriggerRegex = /^[xf]?(describe|it|test)$/;
  21432. return parentNode.type === "TaggedTemplateExpression" && parentNode.quasi === node && parentNode.tag.type === "MemberExpression" && parentNode.tag.property.type === "Identifier" && parentNode.tag.property.name === "each" && (parentNode.tag.object.type === "Identifier" && jestEachTriggerRegex.test(parentNode.tag.object.name) || parentNode.tag.object.type === "MemberExpression" && parentNode.tag.object.property.type === "Identifier" && (parentNode.tag.object.property.name === "only" || parentNode.tag.object.property.name === "skip") && parentNode.tag.object.object.type === "Identifier" && jestEachTriggerRegex.test(parentNode.tag.object.object.name));
  21433. }
  21434. function printJestEachTemplateLiteral(node, expressions, options) {
  21435. /**
  21436. * a | b | expected
  21437. * ${1} | ${1} | ${2}
  21438. * ${1} | ${2} | ${3}
  21439. * ${2} | ${1} | ${3}
  21440. */
  21441. var headerNames = node.quasis[0].value.raw.trim().split(/\s*\|\s*/);
  21442. if (headerNames.length > 1 || headerNames.some(function (headerName) {
  21443. return headerName.length !== 0;
  21444. })) {
  21445. var parts = [];
  21446. var stringifiedExpressions = expressions.map(function (doc$$2) {
  21447. return "${" + printDocToString$1(doc$$2, Object.assign({}, options, {
  21448. printWidth: Infinity,
  21449. endOfLine: "lf"
  21450. })).formatted + "}";
  21451. });
  21452. var tableBody = [{
  21453. hasLineBreak: false,
  21454. cells: []
  21455. }];
  21456. for (var i = 1; i < node.quasis.length; i++) {
  21457. var row = tableBody[tableBody.length - 1];
  21458. var correspondingExpression = stringifiedExpressions[i - 1];
  21459. row.cells.push(correspondingExpression);
  21460. if (correspondingExpression.indexOf("\n") !== -1) {
  21461. row.hasLineBreak = true;
  21462. }
  21463. if (node.quasis[i].value.raw.indexOf("\n") !== -1) {
  21464. tableBody.push({
  21465. hasLineBreak: false,
  21466. cells: []
  21467. });
  21468. }
  21469. }
  21470. var maxColumnCount = tableBody.reduce(function (maxColumnCount, row) {
  21471. return Math.max(maxColumnCount, row.cells.length);
  21472. }, headerNames.length);
  21473. var maxColumnWidths = Array.from(new Array(maxColumnCount), function () {
  21474. return 0;
  21475. });
  21476. var table = [{
  21477. cells: headerNames
  21478. }].concat(tableBody.filter(function (row) {
  21479. return row.cells.length !== 0;
  21480. }));
  21481. table.filter(function (row) {
  21482. return !row.hasLineBreak;
  21483. }).forEach(function (row) {
  21484. row.cells.forEach(function (cell, index) {
  21485. maxColumnWidths[index] = Math.max(maxColumnWidths[index], getStringWidth$2(cell));
  21486. });
  21487. });
  21488. parts.push("`", indent$6(concat$11([hardline$8, join$7(hardline$8, table.map(function (row) {
  21489. return join$7(" | ", row.cells.map(function (cell, index) {
  21490. return row.hasLineBreak ? cell : cell + " ".repeat(maxColumnWidths[index] - getStringWidth$2(cell));
  21491. }));
  21492. }))])), hardline$8, "`");
  21493. return concat$11(parts);
  21494. }
  21495. }
  21496. /** @param node {import("estree").TemplateLiteral} */
  21497. function isSimpleTemplateLiteral(node) {
  21498. if (node.expressions.length === 0) {
  21499. return false;
  21500. }
  21501. return node.expressions.every(function (expr) {
  21502. // Disallow comments since printDocToString can't print them here
  21503. if (expr.comments) {
  21504. return false;
  21505. } // Allow `x` and `this`
  21506. if (expr.type === "Identifier" || expr.type === "ThisExpression") {
  21507. return true;
  21508. } // Allow `a.b.c`, `a.b[c]`, and `this.x.y`
  21509. if ((expr.type === "MemberExpression" || expr.type === "OptionalMemberExpression") && (expr.property.type === "Identifier" || expr.property.type === "Literal")) {
  21510. var ancestor = expr;
  21511. while (ancestor.type === "MemberExpression" || ancestor.type === "OptionalMemberExpression") {
  21512. ancestor = ancestor.object;
  21513. if (ancestor.comments) {
  21514. return false;
  21515. }
  21516. }
  21517. if (ancestor.type === "Identifier" || ancestor.type === "ThisExpression") {
  21518. return true;
  21519. }
  21520. return false;
  21521. }
  21522. return false;
  21523. });
  21524. }
  21525. var functionCompositionFunctionNames = new Set(["pipe", // RxJS, Ramda
  21526. "pipeP", // Ramda
  21527. "pipeK", // Ramda
  21528. "compose", // Ramda, Redux
  21529. "composeFlipped", // Not from any library, but common in Haskell, so supported
  21530. "composeP", // Ramda
  21531. "composeK", // Ramda
  21532. "flow", // Lodash
  21533. "flowRight", // Lodash
  21534. "connect", // Redux
  21535. "createSelector" // Reselect
  21536. ]);
  21537. var ordinaryMethodNames = new Set(["connect" // GObject, MongoDB
  21538. ]);
  21539. function isFunctionCompositionFunction(node) {
  21540. switch (node.type) {
  21541. case "OptionalMemberExpression":
  21542. case "MemberExpression":
  21543. {
  21544. return isFunctionCompositionFunction(node.property) && !ordinaryMethodNames.has(node.property.name);
  21545. }
  21546. case "Identifier":
  21547. {
  21548. return functionCompositionFunctionNames.has(node.name);
  21549. }
  21550. case "StringLiteral":
  21551. case "Literal":
  21552. {
  21553. return functionCompositionFunctionNames.has(node.value);
  21554. }
  21555. }
  21556. }
  21557. function printArgumentsList(path, options, print) {
  21558. var node = path.getValue();
  21559. var args = node.arguments;
  21560. if (args.length === 0) {
  21561. return concat$11(["(", comments.printDanglingComments(path, options,
  21562. /* sameIndent */
  21563. true), ")"]);
  21564. } // useEffect(() => { ... }, [foo, bar, baz])
  21565. 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) {
  21566. return arg.leadingComments || arg.trailingComments;
  21567. })) {
  21568. return concat$11(["(", path.call(print, "arguments", 0), ", ", path.call(print, "arguments", 1), ")"]);
  21569. }
  21570. var anyArgEmptyLine = false;
  21571. var hasEmptyLineFollowingFirstArg = false;
  21572. var lastArgIndex = args.length - 1;
  21573. var printedArguments = path.map(function (argPath, index) {
  21574. var arg = argPath.getNode();
  21575. var parts = [print(argPath)];
  21576. if (index === lastArgIndex) {// do nothing
  21577. } else if (isNextLineEmpty$4(options.originalText, arg, options)) {
  21578. if (index === 0) {
  21579. hasEmptyLineFollowingFirstArg = true;
  21580. }
  21581. anyArgEmptyLine = true;
  21582. parts.push(",", hardline$8, hardline$8);
  21583. } else {
  21584. parts.push(",", line$8);
  21585. }
  21586. return concat$11(parts);
  21587. }, "arguments");
  21588. var maybeTrailingComma = // Dynamic imports cannot have trailing commas
  21589. !(node.callee && node.callee.type === "Import") && shouldPrintComma$1(options, "all") ? "," : "";
  21590. function allArgsBrokenOut() {
  21591. return group$10(concat$11(["(", indent$6(concat$11([line$8, concat$11(printedArguments)])), maybeTrailingComma, line$8, ")"]), {
  21592. shouldBreak: true
  21593. });
  21594. } // We want to get
  21595. // pipe(
  21596. // x => x + 1,
  21597. // x => x - 1
  21598. // )
  21599. // here, but not
  21600. // process.stdout.pipe(socket)
  21601. if (isFunctionCompositionFunction(node.callee) && args.length > 1) {
  21602. return allArgsBrokenOut();
  21603. }
  21604. var shouldGroupFirst = shouldGroupFirstArg(args);
  21605. var shouldGroupLast = shouldGroupLastArg(args);
  21606. if (shouldGroupFirst || shouldGroupLast) {
  21607. 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
  21608. var printedExpanded;
  21609. var i = 0;
  21610. path.each(function (argPath) {
  21611. if (shouldGroupFirst && i === 0) {
  21612. printedExpanded = [concat$11([argPath.call(function (p) {
  21613. return print(p, {
  21614. expandFirstArg: true
  21615. });
  21616. }), printedArguments.length > 1 ? "," : "", hasEmptyLineFollowingFirstArg ? hardline$8 : line$8, hasEmptyLineFollowingFirstArg ? hardline$8 : ""])].concat(printedArguments.slice(1));
  21617. }
  21618. if (shouldGroupLast && i === args.length - 1) {
  21619. printedExpanded = printedArguments.slice(0, -1).concat(argPath.call(function (p) {
  21620. return print(p, {
  21621. expandLastArg: true
  21622. });
  21623. }));
  21624. }
  21625. i++;
  21626. }, "arguments");
  21627. var somePrintedArgumentsWillBreak = printedArguments.some(willBreak$1);
  21628. 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], {
  21629. shouldBreak: true
  21630. }), concat$11(printedExpanded.slice(1)), ")"]) : concat$11(["(", concat$11(printedArguments.slice(0, -1)), group$10(getLast$3(printedExpanded), {
  21631. shouldBreak: true
  21632. }), ")"]), allArgsBrokenOut()], {
  21633. shouldBreak: shouldBreak
  21634. })]);
  21635. }
  21636. return group$10(concat$11(["(", indent$6(concat$11([softline$5, concat$11(printedArguments)])), ifBreak$6(maybeTrailingComma), softline$5, ")"]), {
  21637. shouldBreak: printedArguments.some(willBreak$1) || anyArgEmptyLine
  21638. });
  21639. }
  21640. function printTypeAnnotation(path, options, print) {
  21641. var node = path.getValue();
  21642. if (!node.typeAnnotation) {
  21643. return "";
  21644. }
  21645. var parentNode = path.getParentNode();
  21646. var isDefinite = node.definite || parentNode && parentNode.type === "VariableDeclarator" && parentNode.definite;
  21647. var isFunctionDeclarationIdentifier = parentNode.type === "DeclareFunction" && parentNode.id === node;
  21648. if (isFlowAnnotationComment(options.originalText, node.typeAnnotation, options)) {
  21649. return concat$11([" /*: ", path.call(print, "typeAnnotation"), " */"]);
  21650. }
  21651. return concat$11([isFunctionDeclarationIdentifier ? "" : isDefinite ? "!: " : ": ", path.call(print, "typeAnnotation")]);
  21652. }
  21653. function printFunctionTypeParameters(path, options, print) {
  21654. var fun = path.getValue();
  21655. if (fun.typeArguments) {
  21656. return path.call(print, "typeArguments");
  21657. }
  21658. if (fun.typeParameters) {
  21659. return path.call(print, "typeParameters");
  21660. }
  21661. return "";
  21662. }
  21663. function printFunctionParams(path, print, options, expandArg, printTypeParams) {
  21664. var fun = path.getValue();
  21665. var parent = path.getParentNode();
  21666. var paramsField = fun.parameters ? "parameters" : "params";
  21667. var isParametersInTestCall = isTestCall(parent);
  21668. var shouldHugParameters = shouldHugArguments(fun);
  21669. var shouldExpandParameters = expandArg && !(fun[paramsField] && fun[paramsField].some(function (n) {
  21670. return n.comments;
  21671. }));
  21672. var typeParams = printTypeParams ? printFunctionTypeParameters(path, options, print) : "";
  21673. var printed = [];
  21674. if (fun[paramsField]) {
  21675. var lastArgIndex = fun[paramsField].length - 1;
  21676. printed = path.map(function (childPath, index) {
  21677. var parts = [];
  21678. var param = childPath.getValue();
  21679. parts.push(print(childPath));
  21680. if (index === lastArgIndex) {
  21681. if (fun.rest) {
  21682. parts.push(",", line$8);
  21683. }
  21684. } else if (isParametersInTestCall || shouldHugParameters || shouldExpandParameters) {
  21685. parts.push(", ");
  21686. } else if (isNextLineEmpty$4(options.originalText, param, options)) {
  21687. parts.push(",", hardline$8, hardline$8);
  21688. } else {
  21689. parts.push(",", line$8);
  21690. }
  21691. return concat$11(parts);
  21692. }, paramsField);
  21693. }
  21694. if (fun.rest) {
  21695. printed.push(concat$11(["...", path.call(print, "rest")]));
  21696. }
  21697. if (printed.length === 0) {
  21698. return concat$11([typeParams, "(", comments.printDanglingComments(path, options,
  21699. /* sameIndent */
  21700. true, function (comment) {
  21701. return getNextNonSpaceNonCommentCharacter$1(options.originalText, comment, options.locEnd) === ")";
  21702. }), ")"]);
  21703. }
  21704. var lastParam = getLast$3(fun[paramsField]); // If the parent is a call with the first/last argument expansion and this is the
  21705. // params of the first/last argument, we dont want the arguments to break and instead
  21706. // want the whole expression to be on a new line.
  21707. //
  21708. // Good: Bad:
  21709. // verylongcall( verylongcall((
  21710. // (a, b) => { a,
  21711. // } b,
  21712. // }) ) => {
  21713. // })
  21714. if (shouldExpandParameters) {
  21715. return group$10(concat$11([removeLines$2(typeParams), "(", concat$11(printed.map(removeLines$2)), ")"]));
  21716. } // Single object destructuring should hug
  21717. //
  21718. // function({
  21719. // a,
  21720. // b,
  21721. // c
  21722. // }) {}
  21723. if (shouldHugParameters) {
  21724. return concat$11([typeParams, "(", concat$11(printed), ")"]);
  21725. } // don't break in specs, eg; `it("should maintain parens around done even when long", (done) => {})`
  21726. if (isParametersInTestCall) {
  21727. return concat$11([typeParams, "(", concat$11(printed), ")"]);
  21728. }
  21729. 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;
  21730. if (isFlowShorthandWithOneArg) {
  21731. if (options.arrowParens === "always") {
  21732. return concat$11(["(", concat$11(printed), ")"]);
  21733. }
  21734. return concat$11(printed);
  21735. }
  21736. var canHaveTrailingComma = !(lastParam && lastParam.type === "RestElement") && !fun.rest;
  21737. return concat$11([typeParams, "(", indent$6(concat$11([softline$5, concat$11(printed)])), ifBreak$6(canHaveTrailingComma && shouldPrintComma$1(options, "all") ? "," : ""), softline$5, ")"]);
  21738. }
  21739. function shouldPrintParamsWithoutParens(path, options) {
  21740. if (options.arrowParens === "always") {
  21741. return false;
  21742. }
  21743. if (options.arrowParens === "avoid") {
  21744. var node = path.getValue();
  21745. return canPrintParamsWithoutParens(node);
  21746. } // Fallback default; should be unreachable
  21747. return false;
  21748. }
  21749. function canPrintParamsWithoutParens(node) {
  21750. 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;
  21751. }
  21752. function printFunctionDeclaration(path, print, options) {
  21753. var n = path.getValue();
  21754. var parts = [];
  21755. if (n.async) {
  21756. parts.push("async ");
  21757. }
  21758. parts.push("function");
  21759. if (n.generator) {
  21760. parts.push("*");
  21761. }
  21762. if (n.id) {
  21763. parts.push(" ", path.call(print, "id"));
  21764. }
  21765. parts.push(printFunctionTypeParameters(path, options, print), group$10(concat$11([printFunctionParams(path, print, options), printReturnType(path, print, options)])), n.body ? " " : "", path.call(print, "body"));
  21766. return concat$11(parts);
  21767. }
  21768. function printObjectMethod(path, options, print) {
  21769. var objMethod = path.getValue();
  21770. var parts = [];
  21771. if (objMethod.async) {
  21772. parts.push("async ");
  21773. }
  21774. if (objMethod.generator) {
  21775. parts.push("*");
  21776. }
  21777. if (objMethod.method || objMethod.kind === "get" || objMethod.kind === "set") {
  21778. return printMethod(path, options, print);
  21779. }
  21780. var key = printPropertyKey(path, options, print);
  21781. if (objMethod.computed) {
  21782. parts.push("[", key, "]");
  21783. } else {
  21784. parts.push(key);
  21785. }
  21786. parts.push(printFunctionTypeParameters(path, options, print), group$10(concat$11([printFunctionParams(path, print, options), printReturnType(path, print, options)])), " ", path.call(print, "body"));
  21787. return concat$11(parts);
  21788. }
  21789. function printReturnType(path, print, options) {
  21790. var n = path.getValue();
  21791. var returnType = path.call(print, "returnType");
  21792. if (n.returnType && isFlowAnnotationComment(options.originalText, n.returnType, options)) {
  21793. return concat$11([" /*: ", returnType, " */"]);
  21794. }
  21795. var parts = [returnType]; // prepend colon to TypeScript type annotation
  21796. if (n.returnType && n.returnType.typeAnnotation) {
  21797. parts.unshift(": ");
  21798. }
  21799. if (n.predicate) {
  21800. // The return type will already add the colon, but otherwise we
  21801. // need to do it ourselves
  21802. parts.push(n.returnType ? " " : ": ", path.call(print, "predicate"));
  21803. }
  21804. return concat$11(parts);
  21805. }
  21806. function printExportDeclaration(path, options, print) {
  21807. var decl = path.getValue();
  21808. var semi = options.semi ? ";" : "";
  21809. var parts = ["export "];
  21810. var isDefault = decl["default"] || decl.type === "ExportDefaultDeclaration";
  21811. if (isDefault) {
  21812. parts.push("default ");
  21813. }
  21814. parts.push(comments.printDanglingComments(path, options,
  21815. /* sameIndent */
  21816. true));
  21817. if (needsHardlineAfterDanglingComment(decl)) {
  21818. parts.push(hardline$8);
  21819. }
  21820. if (decl.declaration) {
  21821. parts.push(path.call(print, "declaration"));
  21822. if (isDefault && decl.declaration.type !== "ClassDeclaration" && decl.declaration.type !== "FunctionDeclaration" && decl.declaration.type !== "TSInterfaceDeclaration" && decl.declaration.type !== "DeclareClass" && decl.declaration.type !== "DeclareFunction" && decl.declaration.type !== "TSDeclareFunction") {
  21823. parts.push(semi);
  21824. }
  21825. } else {
  21826. if (decl.specifiers && decl.specifiers.length > 0) {
  21827. var specifiers = [];
  21828. var defaultSpecifiers = [];
  21829. var namespaceSpecifiers = [];
  21830. path.each(function (specifierPath) {
  21831. var specifierType = path.getValue().type;
  21832. if (specifierType === "ExportSpecifier") {
  21833. specifiers.push(print(specifierPath));
  21834. } else if (specifierType === "ExportDefaultSpecifier") {
  21835. defaultSpecifiers.push(print(specifierPath));
  21836. } else if (specifierType === "ExportNamespaceSpecifier") {
  21837. namespaceSpecifiers.push(concat$11(["* as ", print(specifierPath)]));
  21838. }
  21839. }, "specifiers");
  21840. var isNamespaceFollowed = namespaceSpecifiers.length !== 0 && specifiers.length !== 0;
  21841. var isDefaultFollowed = defaultSpecifiers.length !== 0 && (namespaceSpecifiers.length !== 0 || specifiers.length !== 0);
  21842. 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, "}"])) : "");
  21843. } else {
  21844. parts.push("{}");
  21845. }
  21846. if (decl.source) {
  21847. parts.push(" from ", path.call(print, "source"));
  21848. }
  21849. parts.push(semi);
  21850. }
  21851. return concat$11(parts);
  21852. }
  21853. function printFlowDeclaration(path, parts) {
  21854. var parentExportDecl = getParentExportDeclaration$1(path);
  21855. if (parentExportDecl) {
  21856. assert$3.strictEqual(parentExportDecl.type, "DeclareExportDeclaration");
  21857. } else {
  21858. // If the parent node has type DeclareExportDeclaration, then it
  21859. // will be responsible for printing the "declare" token. Otherwise
  21860. // it needs to be printed with this non-exported declaration node.
  21861. parts.unshift("declare ");
  21862. }
  21863. return concat$11(parts);
  21864. }
  21865. function getFlowVariance(path) {
  21866. if (!path.variance) {
  21867. return null;
  21868. } // Babel 7.0 currently uses variance node type, and flow should
  21869. // follow suit soon:
  21870. // https://github.com/babel/babel/issues/4722
  21871. var variance = path.variance.kind || path.variance;
  21872. switch (variance) {
  21873. case "plus":
  21874. return "+";
  21875. case "minus":
  21876. return "-";
  21877. default:
  21878. /* istanbul ignore next */
  21879. return variance;
  21880. }
  21881. }
  21882. function printTypeScriptModifiers(path, options, print) {
  21883. var n = path.getValue();
  21884. if (!n.modifiers || !n.modifiers.length) {
  21885. return "";
  21886. }
  21887. return concat$11([join$7(" ", path.map(print, "modifiers")), " "]);
  21888. }
  21889. function printTypeParameters(path, options, print, paramsKey) {
  21890. var n = path.getValue();
  21891. if (!n[paramsKey]) {
  21892. return "";
  21893. } // for TypeParameterDeclaration typeParameters is a single node
  21894. if (!Array.isArray(n[paramsKey])) {
  21895. return path.call(print, paramsKey);
  21896. }
  21897. var grandparent = path.getNode(2);
  21898. var isParameterInTestCall = grandparent != null && isTestCall(grandparent);
  21899. 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");
  21900. if (shouldInline) {
  21901. return concat$11(["<", join$7(", ", path.map(print, paramsKey)), ">"]);
  21902. }
  21903. 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, ">"]));
  21904. }
  21905. function printClass(path, options, print) {
  21906. var n = path.getValue();
  21907. var parts = [];
  21908. if (n.abstract) {
  21909. parts.push("abstract ");
  21910. }
  21911. parts.push("class");
  21912. if (n.id) {
  21913. parts.push(" ", path.call(print, "id"));
  21914. }
  21915. parts.push(path.call(print, "typeParameters"));
  21916. var partsGroup = [];
  21917. if (n.superClass) {
  21918. var printed = concat$11(["extends ", path.call(print, "superClass"), path.call(print, "superTypeParameters")]); // Keep old behaviour of extends in same line
  21919. // If there is only on extends and there are not comments
  21920. if ((!n.implements || n.implements.length === 0) && (!n.superClass.comments || n.superClass.comments.length === 0)) {
  21921. parts.push(concat$11([" ", path.call(function (superClass) {
  21922. return comments.printComments(superClass, function () {
  21923. return printed;
  21924. }, options);
  21925. }, "superClass")]));
  21926. } else {
  21927. partsGroup.push(group$10(concat$11([line$8, path.call(function (superClass) {
  21928. return comments.printComments(superClass, function () {
  21929. return printed;
  21930. }, options);
  21931. }, "superClass")])));
  21932. }
  21933. } else if (n.extends && n.extends.length > 0) {
  21934. parts.push(" extends ", join$7(", ", path.map(print, "extends")));
  21935. }
  21936. if (n["mixins"] && n["mixins"].length > 0) {
  21937. partsGroup.push(line$8, "mixins ", group$10(indent$6(join$7(concat$11([",", line$8]), path.map(print, "mixins")))));
  21938. }
  21939. if (n["implements"] && n["implements"].length > 0) {
  21940. partsGroup.push(line$8, "implements", group$10(indent$6(concat$11([line$8, join$7(concat$11([",", line$8]), path.map(print, "implements"))]))));
  21941. }
  21942. if (partsGroup.length > 0) {
  21943. parts.push(group$10(indent$6(concat$11(partsGroup))));
  21944. }
  21945. if (n.body && n.body.comments && hasLeadingOwnLineComment(options.originalText, n.body, options)) {
  21946. parts.push(hardline$8);
  21947. } else {
  21948. parts.push(" ");
  21949. }
  21950. parts.push(path.call(print, "body"));
  21951. return parts;
  21952. }
  21953. function printOptionalToken(path) {
  21954. var node = path.getValue();
  21955. if (!node.optional) {
  21956. return "";
  21957. }
  21958. if (node.type === "OptionalCallExpression" || node.type === "OptionalMemberExpression" && node.computed) {
  21959. return "?.";
  21960. }
  21961. return "?";
  21962. }
  21963. function printMemberLookup(path, options, print) {
  21964. var property = path.call(print, "property");
  21965. var n = path.getValue();
  21966. var optional = printOptionalToken(path);
  21967. if (!n.computed) {
  21968. return concat$11([optional, ".", property]);
  21969. }
  21970. if (!n.property || isNumericLiteral(n.property)) {
  21971. return concat$11([optional, "[", property, "]"]);
  21972. }
  21973. return group$10(concat$11([optional, "[", indent$6(concat$11([softline$5, property])), softline$5, "]"]));
  21974. }
  21975. function printBindExpressionCallee(path, options, print) {
  21976. return concat$11(["::", path.call(print, "callee")]);
  21977. } // We detect calls on member expressions specially to format a
  21978. // common pattern better. The pattern we are looking for is this:
  21979. //
  21980. // arr
  21981. // .map(x => x + 1)
  21982. // .filter(x => x > 10)
  21983. // .some(x => x % 2)
  21984. //
  21985. // The way it is structured in the AST is via a nested sequence of
  21986. // MemberExpression and CallExpression. We need to traverse the AST
  21987. // and make groups out of it to print it in the desired way.
  21988. function printMemberChain(path, options, print) {
  21989. // The first phase is to linearize the AST by traversing it down.
  21990. //
  21991. // a().b()
  21992. // has the following AST structure:
  21993. // CallExpression(MemberExpression(CallExpression(Identifier)))
  21994. // and we transform it into
  21995. // [Identifier, CallExpression, MemberExpression, CallExpression]
  21996. var printedNodes = []; // Here we try to retain one typed empty line after each call expression or
  21997. // the first group whether it is in parentheses or not
  21998. function shouldInsertEmptyLineAfter(node) {
  21999. var originalText = options.originalText;
  22000. var nextCharIndex = getNextNonSpaceNonCommentCharacterIndex$2(originalText, node, options);
  22001. var nextChar = originalText.charAt(nextCharIndex); // if it is cut off by a parenthesis, we only account for one typed empty
  22002. // line after that parenthesis
  22003. if (nextChar == ")") {
  22004. return isNextLineEmptyAfterIndex$1(originalText, nextCharIndex + 1, options);
  22005. }
  22006. return isNextLineEmpty$4(originalText, node, options);
  22007. }
  22008. function rec(path) {
  22009. var node = path.getValue();
  22010. if ((node.type === "CallExpression" || node.type === "OptionalCallExpression") && (isMemberish(node.callee) || node.callee.type === "CallExpression" || node.callee.type === "OptionalCallExpression")) {
  22011. printedNodes.unshift({
  22012. node: node,
  22013. printed: concat$11([comments.printComments(path, function () {
  22014. return concat$11([printOptionalToken(path), printFunctionTypeParameters(path, options, print), printArgumentsList(path, options, print)]);
  22015. }, options), shouldInsertEmptyLineAfter(node) ? hardline$8 : ""])
  22016. });
  22017. path.call(function (callee) {
  22018. return rec(callee);
  22019. }, "callee");
  22020. } else if (isMemberish(node)) {
  22021. printedNodes.unshift({
  22022. node: node,
  22023. needsParens: needsParens_1(path, options),
  22024. printed: comments.printComments(path, function () {
  22025. return node.type === "OptionalMemberExpression" || node.type === "MemberExpression" ? printMemberLookup(path, options, print) : printBindExpressionCallee(path, options, print);
  22026. }, options)
  22027. });
  22028. path.call(function (object) {
  22029. return rec(object);
  22030. }, "object");
  22031. } else if (node.type === "TSNonNullExpression") {
  22032. printedNodes.unshift({
  22033. node: node,
  22034. printed: comments.printComments(path, function () {
  22035. return "!";
  22036. }, options)
  22037. });
  22038. path.call(function (expression) {
  22039. return rec(expression);
  22040. }, "expression");
  22041. } else {
  22042. printedNodes.unshift({
  22043. node: node,
  22044. printed: path.call(print)
  22045. });
  22046. }
  22047. } // Note: the comments of the root node have already been printed, so we
  22048. // need to extract this first call without printing them as they would
  22049. // if handled inside of the recursive call.
  22050. var node = path.getValue();
  22051. printedNodes.unshift({
  22052. node: node,
  22053. printed: concat$11([printOptionalToken(path), printFunctionTypeParameters(path, options, print), printArgumentsList(path, options, print)])
  22054. });
  22055. path.call(function (callee) {
  22056. return rec(callee);
  22057. }, "callee"); // Once we have a linear list of printed nodes, we want to create groups out
  22058. // of it.
  22059. //
  22060. // a().b.c().d().e
  22061. // will be grouped as
  22062. // [
  22063. // [Identifier, CallExpression],
  22064. // [MemberExpression, MemberExpression, CallExpression],
  22065. // [MemberExpression, CallExpression],
  22066. // [MemberExpression],
  22067. // ]
  22068. // so that we can print it as
  22069. // a()
  22070. // .b.c()
  22071. // .d()
  22072. // .e
  22073. // The first group is the first node followed by
  22074. // - as many CallExpression as possible
  22075. // < fn()()() >.something()
  22076. // - as many array acessors as possible
  22077. // < fn()[0][1][2] >.something()
  22078. // - then, as many MemberExpression as possible but the last one
  22079. // < this.items >.something()
  22080. var groups = [];
  22081. var currentGroup = [printedNodes[0]];
  22082. var i = 1;
  22083. for (; i < printedNodes.length; ++i) {
  22084. 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)) {
  22085. currentGroup.push(printedNodes[i]);
  22086. } else {
  22087. break;
  22088. }
  22089. }
  22090. if (printedNodes[0].node.type !== "CallExpression" && printedNodes[0].node.type !== "OptionalCallExpression") {
  22091. for (; i + 1 < printedNodes.length; ++i) {
  22092. if (isMemberish(printedNodes[i].node) && isMemberish(printedNodes[i + 1].node)) {
  22093. currentGroup.push(printedNodes[i]);
  22094. } else {
  22095. break;
  22096. }
  22097. }
  22098. }
  22099. groups.push(currentGroup);
  22100. currentGroup = []; // Then, each following group is a sequence of MemberExpression followed by
  22101. // a sequence of CallExpression. To compute it, we keep adding things to the
  22102. // group until we has seen a CallExpression in the past and reach a
  22103. // MemberExpression
  22104. var hasSeenCallExpression = false;
  22105. for (; i < printedNodes.length; ++i) {
  22106. if (hasSeenCallExpression && isMemberish(printedNodes[i].node)) {
  22107. // [0] should be appended at the end of the group instead of the
  22108. // beginning of the next one
  22109. if (printedNodes[i].node.computed && isNumericLiteral(printedNodes[i].node.property)) {
  22110. currentGroup.push(printedNodes[i]);
  22111. continue;
  22112. }
  22113. groups.push(currentGroup);
  22114. currentGroup = [];
  22115. hasSeenCallExpression = false;
  22116. }
  22117. if (printedNodes[i].node.type === "CallExpression" || printedNodes[i].node.type === "OptionalCallExpression") {
  22118. hasSeenCallExpression = true;
  22119. }
  22120. currentGroup.push(printedNodes[i]);
  22121. if (printedNodes[i].node.comments && printedNodes[i].node.comments.some(function (comment) {
  22122. return comment.trailing;
  22123. })) {
  22124. groups.push(currentGroup);
  22125. currentGroup = [];
  22126. hasSeenCallExpression = false;
  22127. }
  22128. }
  22129. if (currentGroup.length > 0) {
  22130. groups.push(currentGroup);
  22131. } // There are cases like Object.keys(), Observable.of(), _.values() where
  22132. // they are the subject of all the chained calls and therefore should
  22133. // be kept on the same line:
  22134. //
  22135. // Object.keys(items)
  22136. // .filter(x => x)
  22137. // .map(x => x)
  22138. //
  22139. // In order to detect those cases, we use an heuristic: if the first
  22140. // node is an identifier with the name starting with a capital
  22141. // letter or just a sequence of _$. The rationale is that they are
  22142. // likely to be factories.
  22143. function isFactory(name) {
  22144. return /^[A-Z]|^[_$]+$/.test(name);
  22145. } // In case the Identifier is shorter than tab width, we can keep the
  22146. // first call in a single line, if it's an ExpressionStatement.
  22147. //
  22148. // d3.scaleLinear()
  22149. // .domain([0, 100])
  22150. // .range([0, width]);
  22151. //
  22152. function isShort(name) {
  22153. return name.length <= options.tabWidth;
  22154. }
  22155. function shouldNotWrap(groups) {
  22156. var parent = path.getParentNode();
  22157. var isExpression = parent && parent.type === "ExpressionStatement";
  22158. var hasComputed = groups[1].length && groups[1][0].node.computed;
  22159. if (groups[0].length === 1) {
  22160. var firstNode = groups[0][0].node;
  22161. return firstNode.type === "ThisExpression" || firstNode.type === "Identifier" && (isFactory(firstNode.name) || isExpression && isShort(firstNode.name) || hasComputed);
  22162. }
  22163. var lastNode = getLast$3(groups[0]).node;
  22164. return (lastNode.type === "MemberExpression" || lastNode.type === "OptionalMemberExpression") && lastNode.property.type === "Identifier" && (isFactory(lastNode.property.name) || hasComputed);
  22165. }
  22166. var shouldMerge = groups.length >= 2 && !groups[1][0].node.comments && shouldNotWrap(groups);
  22167. function printGroup(printedGroup) {
  22168. var printed = printedGroup.map(function (tuple) {
  22169. return tuple.printed;
  22170. }); // Checks if the last node (i.e. the parent node) needs parens and print
  22171. // accordingly
  22172. if (printedGroup.length > 0 && printedGroup[printedGroup.length - 1].needsParens) {
  22173. return concat$11(["("].concat(_toConsumableArray(printed), [")"]));
  22174. }
  22175. return concat$11(printed);
  22176. }
  22177. function printIndentedGroup(groups) {
  22178. if (groups.length === 0) {
  22179. return "";
  22180. }
  22181. return indent$6(group$10(concat$11([hardline$8, join$7(hardline$8, groups.map(printGroup))])));
  22182. }
  22183. var printedGroups = groups.map(printGroup);
  22184. var oneLine = concat$11(printedGroups);
  22185. var cutoff = shouldMerge ? 3 : 2;
  22186. var flatGroups = groups.slice(0, cutoff).reduce(function (res, group) {
  22187. return res.concat(group);
  22188. }, []);
  22189. var hasComment = flatGroups.slice(1, -1).some(function (node) {
  22190. return hasLeadingComment(node.node);
  22191. }) || flatGroups.slice(0, -1).some(function (node) {
  22192. return hasTrailingComment(node.node);
  22193. }) || groups[cutoff] && hasLeadingComment(groups[cutoff][0].node); // If we only have a single `.`, we shouldn't do anything fancy and just
  22194. // render everything concatenated together.
  22195. if (groups.length <= cutoff && !hasComment) {
  22196. return group$10(oneLine);
  22197. } // Find out the last node in the first group and check if it has an
  22198. // empty line after
  22199. var lastNodeBeforeIndent = getLast$3(shouldMerge ? groups.slice(1, 2)[0] : groups[0]).node;
  22200. var shouldHaveEmptyLineBeforeIndent = lastNodeBeforeIndent.type !== "CallExpression" && lastNodeBeforeIndent.type !== "OptionalCallExpression" && shouldInsertEmptyLineAfter(lastNodeBeforeIndent);
  22201. 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))]);
  22202. var callExpressions = printedNodes.map(function (_ref) {
  22203. var node = _ref.node;
  22204. return node;
  22205. }).filter(isCallOrOptionalCallExpression); // We don't want to print in one line if there's:
  22206. // * A comment.
  22207. // * 3 or more chained calls.
  22208. // * Any group but the last one has a hard line.
  22209. // If the last group is a function it's okay to inline if it fits.
  22210. if (hasComment || callExpressions.length >= 3 || printedGroups.slice(0, -1).some(willBreak$1) ||
  22211. /**
  22212. * scopes.filter(scope => scope.value !== '').map((scope, i) => {
  22213. * // multi line content
  22214. * })
  22215. */
  22216. function (lastGroupDoc, lastGroupNode) {
  22217. return isCallOrOptionalCallExpression(lastGroupNode) && willBreak$1(lastGroupDoc);
  22218. }(getLast$3(printedGroups), getLast$3(getLast$3(groups)).node) && callExpressions.slice(0, -1).some(function (n) {
  22219. return n.arguments.some(isFunctionOrArrowExpression);
  22220. })) {
  22221. return group$10(expanded);
  22222. }
  22223. return concat$11([// We only need to check `oneLine` because if `expanded` is chosen
  22224. // that means that the parent group has already been broken
  22225. // naturally
  22226. willBreak$1(oneLine) || shouldHaveEmptyLineBeforeIndent ? breakParent$3 : "", conditionalGroup$1([oneLine, expanded])]);
  22227. }
  22228. function isCallOrOptionalCallExpression(node) {
  22229. return node.type === "CallExpression" || node.type === "OptionalCallExpression";
  22230. }
  22231. function isJSXNode(node) {
  22232. return node.type === "JSXElement" || node.type === "JSXFragment";
  22233. }
  22234. function isEmptyJSXElement(node) {
  22235. if (node.children.length === 0) {
  22236. return true;
  22237. }
  22238. if (node.children.length > 1) {
  22239. return false;
  22240. } // if there is one text child and does not contain any meaningful text
  22241. // we can treat the element as empty.
  22242. var child = node.children[0];
  22243. return isLiteral(child) && !isMeaningfulJSXText(child);
  22244. } // Only space, newline, carriage return, and tab are treated as whitespace
  22245. // inside JSX.
  22246. var jsxWhitespaceChars = " \n\r\t";
  22247. var containsNonJsxWhitespaceRegex = new RegExp("[^" + jsxWhitespaceChars + "]");
  22248. var matchJsxWhitespaceRegex = new RegExp("([" + jsxWhitespaceChars + "]+)"); // Meaningful if it contains non-whitespace characters,
  22249. // or it contains whitespace without a new line.
  22250. function isMeaningfulJSXText(node) {
  22251. return isLiteral(node) && (containsNonJsxWhitespaceRegex.test(rawText(node)) || !/\n/.test(rawText(node)));
  22252. }
  22253. function conditionalExpressionChainContainsJSX(node) {
  22254. return Boolean(getConditionalChainContents(node).find(isJSXNode));
  22255. } // If we have nested conditional expressions, we want to print them in JSX mode
  22256. // if there's at least one JSXElement somewhere in the tree.
  22257. //
  22258. // A conditional expression chain like this should be printed in normal mode,
  22259. // because there aren't JSXElements anywhere in it:
  22260. //
  22261. // isA ? "A" : isB ? "B" : isC ? "C" : "Unknown";
  22262. //
  22263. // But a conditional expression chain like this should be printed in JSX mode,
  22264. // because there is a JSXElement in the last ConditionalExpression:
  22265. //
  22266. // isA ? "A" : isB ? "B" : isC ? "C" : <span className="warning">Unknown</span>;
  22267. //
  22268. // This type of ConditionalExpression chain is structured like this in the AST:
  22269. //
  22270. // ConditionalExpression {
  22271. // test: ...,
  22272. // consequent: ...,
  22273. // alternate: ConditionalExpression {
  22274. // test: ...,
  22275. // consequent: ...,
  22276. // alternate: ConditionalExpression {
  22277. // test: ...,
  22278. // consequent: ...,
  22279. // alternate: ...,
  22280. // }
  22281. // }
  22282. // }
  22283. //
  22284. // We want to traverse over that shape and convert it into a flat structure so
  22285. // that we can find if there's a JSXElement somewhere inside.
  22286. function getConditionalChainContents(node) {
  22287. // Given this code:
  22288. //
  22289. // // Using a ConditionalExpression as the consequent is uncommon, but should
  22290. // // be handled.
  22291. // A ? B : C ? D : E ? F ? G : H : I
  22292. //
  22293. // which has this AST:
  22294. //
  22295. // ConditionalExpression {
  22296. // test: Identifier(A),
  22297. // consequent: Identifier(B),
  22298. // alternate: ConditionalExpression {
  22299. // test: Identifier(C),
  22300. // consequent: Identifier(D),
  22301. // alternate: ConditionalExpression {
  22302. // test: Identifier(E),
  22303. // consequent: ConditionalExpression {
  22304. // test: Identifier(F),
  22305. // consequent: Identifier(G),
  22306. // alternate: Identifier(H),
  22307. // },
  22308. // alternate: Identifier(I),
  22309. // }
  22310. // }
  22311. // }
  22312. //
  22313. // we should return this Array:
  22314. //
  22315. // [
  22316. // Identifier(A),
  22317. // Identifier(B),
  22318. // Identifier(C),
  22319. // Identifier(D),
  22320. // Identifier(E),
  22321. // Identifier(F),
  22322. // Identifier(G),
  22323. // Identifier(H),
  22324. // Identifier(I)
  22325. // ];
  22326. //
  22327. // This loses the information about whether each node was the test,
  22328. // consequent, or alternate, but we don't care about that here- we are only
  22329. // flattening this structure to find if there's any JSXElements inside.
  22330. var nonConditionalExpressions = [];
  22331. function recurse(node) {
  22332. if (node.type === "ConditionalExpression") {
  22333. recurse(node.test);
  22334. recurse(node.consequent);
  22335. recurse(node.alternate);
  22336. } else {
  22337. nonConditionalExpressions.push(node);
  22338. }
  22339. }
  22340. recurse(node);
  22341. return nonConditionalExpressions;
  22342. } // Detect an expression node representing `{" "}`
  22343. function isJSXWhitespaceExpression(node) {
  22344. return node.type === "JSXExpressionContainer" && isLiteral(node.expression) && node.expression.value === " " && !node.expression.comments;
  22345. }
  22346. function separatorNoWhitespace(isFacebookTranslationTag, child, childNode, nextNode) {
  22347. if (isFacebookTranslationTag) {
  22348. return "";
  22349. }
  22350. if (childNode.type === "JSXElement" && !childNode.closingElement || nextNode && nextNode.type === "JSXElement" && !nextNode.closingElement) {
  22351. return child.length === 1 ? softline$5 : hardline$8;
  22352. }
  22353. return softline$5;
  22354. }
  22355. function separatorWithWhitespace(isFacebookTranslationTag, child, childNode, nextNode) {
  22356. if (isFacebookTranslationTag) {
  22357. return hardline$8;
  22358. }
  22359. if (child.length === 1) {
  22360. return childNode.type === "JSXElement" && !childNode.closingElement || nextNode && nextNode.type === "JSXElement" && !nextNode.closingElement ? hardline$8 : softline$5;
  22361. }
  22362. return hardline$8;
  22363. } // JSX Children are strange, mostly for two reasons:
  22364. // 1. JSX reads newlines into string values, instead of skipping them like JS
  22365. // 2. up to one whitespace between elements within a line is significant,
  22366. // but not between lines.
  22367. //
  22368. // Leading, trailing, and lone whitespace all need to
  22369. // turn themselves into the rather ugly `{' '}` when breaking.
  22370. //
  22371. // We print JSX using the `fill` doc primitive.
  22372. // This requires that we give it an array of alternating
  22373. // content and whitespace elements.
  22374. // To ensure this we add dummy `""` content elements as needed.
  22375. function printJSXChildren(path, options, print, jsxWhitespace, isFacebookTranslationTag) {
  22376. var n = path.getValue();
  22377. var children = []; // using `map` instead of `each` because it provides `i`
  22378. path.map(function (childPath, i) {
  22379. var child = childPath.getValue();
  22380. if (isLiteral(child)) {
  22381. var text = rawText(child); // Contains a non-whitespace character
  22382. if (isMeaningfulJSXText(child)) {
  22383. var words = text.split(matchJsxWhitespaceRegex); // Starts with whitespace
  22384. if (words[0] === "") {
  22385. children.push("");
  22386. words.shift();
  22387. if (/\n/.test(words[0])) {
  22388. var next = n.children[i + 1];
  22389. children.push(separatorWithWhitespace(isFacebookTranslationTag, words[1], child, next));
  22390. } else {
  22391. children.push(jsxWhitespace);
  22392. }
  22393. words.shift();
  22394. }
  22395. var endWhitespace; // Ends with whitespace
  22396. if (getLast$3(words) === "") {
  22397. words.pop();
  22398. endWhitespace = words.pop();
  22399. } // This was whitespace only without a new line.
  22400. if (words.length === 0) {
  22401. return;
  22402. }
  22403. words.forEach(function (word, i) {
  22404. if (i % 2 === 1) {
  22405. children.push(line$8);
  22406. } else {
  22407. children.push(word);
  22408. }
  22409. });
  22410. if (endWhitespace !== undefined) {
  22411. if (/\n/.test(endWhitespace)) {
  22412. var _next = n.children[i + 1];
  22413. children.push(separatorWithWhitespace(isFacebookTranslationTag, getLast$3(children), child, _next));
  22414. } else {
  22415. children.push(jsxWhitespace);
  22416. }
  22417. } else {
  22418. var _next2 = n.children[i + 1];
  22419. children.push(separatorNoWhitespace(isFacebookTranslationTag, getLast$3(children), child, _next2));
  22420. }
  22421. } else if (/\n/.test(text)) {
  22422. // Keep (up to one) blank line between tags/expressions/text.
  22423. // Note: We don't keep blank lines between text elements.
  22424. if (text.match(/\n/g).length > 1) {
  22425. children.push("");
  22426. children.push(hardline$8);
  22427. }
  22428. } else {
  22429. children.push("");
  22430. children.push(jsxWhitespace);
  22431. }
  22432. } else {
  22433. var printedChild = print(childPath);
  22434. children.push(printedChild);
  22435. var _next3 = n.children[i + 1];
  22436. var directlyFollowedByMeaningfulText = _next3 && isMeaningfulJSXText(_next3);
  22437. if (directlyFollowedByMeaningfulText) {
  22438. var firstWord = rawText(_next3).trim().split(matchJsxWhitespaceRegex)[0];
  22439. children.push(separatorNoWhitespace(isFacebookTranslationTag, firstWord, child, _next3));
  22440. } else {
  22441. children.push(hardline$8);
  22442. }
  22443. }
  22444. }, "children");
  22445. return children;
  22446. } // JSX expands children from the inside-out, instead of the outside-in.
  22447. // This is both to break children before attributes,
  22448. // and to ensure that when children break, their parents do as well.
  22449. //
  22450. // Any element that is written without any newlines and fits on a single line
  22451. // is left that way.
  22452. // Not only that, any user-written-line containing multiple JSX siblings
  22453. // should also be kept on one line if possible,
  22454. // so each user-written-line is wrapped in its own group.
  22455. //
  22456. // Elements that contain newlines or don't fit on a single line (recursively)
  22457. // are fully-split, using hardline and shouldBreak: true.
  22458. //
  22459. // To support that case properly, all leading and trailing spaces
  22460. // are stripped from the list of children, and replaced with a single hardline.
  22461. function printJSXElement(path, options, print) {
  22462. var n = path.getValue();
  22463. if (n.type === "JSXElement" && isEmptyJSXElement(n)) {
  22464. return concat$11([path.call(print, "openingElement"), path.call(print, "closingElement")]);
  22465. }
  22466. var openingLines = n.type === "JSXElement" ? path.call(print, "openingElement") : path.call(print, "openingFragment");
  22467. var closingLines = n.type === "JSXElement" ? path.call(print, "closingElement") : path.call(print, "closingFragment");
  22468. if (n.children.length === 1 && n.children[0].type === "JSXExpressionContainer" && (n.children[0].expression.type === "TemplateLiteral" || n.children[0].expression.type === "TaggedTemplateExpression")) {
  22469. return concat$11([openingLines, concat$11(path.map(print, "children")), closingLines]);
  22470. } // Convert `{" "}` to text nodes containing a space.
  22471. // This makes it easy to turn them into `jsxWhitespace` which
  22472. // can then print as either a space or `{" "}` when breaking.
  22473. n.children = n.children.map(function (child) {
  22474. if (isJSXWhitespaceExpression(child)) {
  22475. return {
  22476. type: "JSXText",
  22477. value: " ",
  22478. raw: " "
  22479. };
  22480. }
  22481. return child;
  22482. });
  22483. var containsTag = n.children.filter(isJSXNode).length > 0;
  22484. var containsMultipleExpressions = n.children.filter(function (child) {
  22485. return child.type === "JSXExpressionContainer";
  22486. }).length > 1;
  22487. var containsMultipleAttributes = n.type === "JSXElement" && n.openingElement.attributes.length > 1; // Record any breaks. Should never go from true to false, only false to true.
  22488. var forcedBreak = willBreak$1(openingLines) || containsTag || containsMultipleAttributes || containsMultipleExpressions;
  22489. var rawJsxWhitespace = options.singleQuote ? "{' '}" : '{" "}';
  22490. var jsxWhitespace = ifBreak$6(concat$11([rawJsxWhitespace, softline$5]), " ");
  22491. var isFacebookTranslationTag = n.openingElement && n.openingElement.name && n.openingElement.name.name === "fbt";
  22492. var children = printJSXChildren(path, options, print, jsxWhitespace, isFacebookTranslationTag);
  22493. var containsText = n.children.filter(function (child) {
  22494. return isMeaningfulJSXText(child);
  22495. }).length > 0; // We can end up we multiple whitespace elements with empty string
  22496. // content between them.
  22497. // We need to remove empty whitespace and softlines before JSX whitespace
  22498. // to get the correct output.
  22499. for (var i = children.length - 2; i >= 0; i--) {
  22500. var isPairOfEmptyStrings = children[i] === "" && children[i + 1] === "";
  22501. var isPairOfHardlines = children[i] === hardline$8 && children[i + 1] === "" && children[i + 2] === hardline$8;
  22502. var isLineFollowedByJSXWhitespace = (children[i] === softline$5 || children[i] === hardline$8) && children[i + 1] === "" && children[i + 2] === jsxWhitespace;
  22503. var isJSXWhitespaceFollowedByLine = children[i] === jsxWhitespace && children[i + 1] === "" && (children[i + 2] === softline$5 || children[i + 2] === hardline$8);
  22504. var isDoubleJSXWhitespace = children[i] === jsxWhitespace && children[i + 1] === "" && children[i + 2] === jsxWhitespace;
  22505. 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;
  22506. if (isPairOfHardlines && containsText || isPairOfEmptyStrings || isLineFollowedByJSXWhitespace || isDoubleJSXWhitespace || isPairOfHardOrSoftLines) {
  22507. children.splice(i, 2);
  22508. } else if (isJSXWhitespaceFollowedByLine) {
  22509. children.splice(i + 1, 2);
  22510. }
  22511. } // Trim trailing lines (or empty strings)
  22512. while (children.length && (isLineNext$1(getLast$3(children)) || isEmpty$1(getLast$3(children)))) {
  22513. children.pop();
  22514. } // Trim leading lines (or empty strings)
  22515. while (children.length && (isLineNext$1(children[0]) || isEmpty$1(children[0])) && (isLineNext$1(children[1]) || isEmpty$1(children[1]))) {
  22516. children.shift();
  22517. children.shift();
  22518. } // Tweak how we format children if outputting this element over multiple lines.
  22519. // Also detect whether we will force this element to output over multiple lines.
  22520. var multilineChildren = [];
  22521. children.forEach(function (child, i) {
  22522. // There are a number of situations where we need to ensure we display
  22523. // whitespace as `{" "}` when outputting this element over multiple lines.
  22524. if (child === jsxWhitespace) {
  22525. if (i === 1 && children[i - 1] === "") {
  22526. if (children.length === 2) {
  22527. // Solitary whitespace
  22528. multilineChildren.push(rawJsxWhitespace);
  22529. return;
  22530. } // Leading whitespace
  22531. multilineChildren.push(concat$11([rawJsxWhitespace, hardline$8]));
  22532. return;
  22533. } else if (i === children.length - 1) {
  22534. // Trailing whitespace
  22535. multilineChildren.push(rawJsxWhitespace);
  22536. return;
  22537. } else if (children[i - 1] === "" && children[i - 2] === hardline$8) {
  22538. // Whitespace after line break
  22539. multilineChildren.push(rawJsxWhitespace);
  22540. return;
  22541. }
  22542. }
  22543. multilineChildren.push(child);
  22544. if (willBreak$1(child)) {
  22545. forcedBreak = true;
  22546. }
  22547. }); // If there is text we use `fill` to fit as much onto each line as possible.
  22548. // When there is no text (just tags and expressions) we use `group`
  22549. // to output each on a separate line.
  22550. var content = containsText ? fill$4(multilineChildren) : group$10(concat$11(multilineChildren), {
  22551. shouldBreak: true
  22552. });
  22553. var multiLineElem = group$10(concat$11([openingLines, indent$6(concat$11([hardline$8, content])), hardline$8, closingLines]));
  22554. if (forcedBreak) {
  22555. return multiLineElem;
  22556. }
  22557. return conditionalGroup$1([group$10(concat$11([openingLines, concat$11(children), closingLines])), multiLineElem]);
  22558. }
  22559. function maybeWrapJSXElementInParens(path, elem) {
  22560. var parent = path.getParentNode();
  22561. if (!parent) {
  22562. return elem;
  22563. }
  22564. var NO_WRAP_PARENTS = {
  22565. ArrayExpression: true,
  22566. JSXAttribute: true,
  22567. JSXElement: true,
  22568. JSXExpressionContainer: true,
  22569. JSXFragment: true,
  22570. ExpressionStatement: true,
  22571. CallExpression: true,
  22572. OptionalCallExpression: true,
  22573. ConditionalExpression: true,
  22574. JsExpressionRoot: true
  22575. };
  22576. if (NO_WRAP_PARENTS[parent.type]) {
  22577. return elem;
  22578. }
  22579. var shouldBreak = matchAncestorTypes$1(path, ["ArrowFunctionExpression", "CallExpression", "JSXExpressionContainer"]);
  22580. return group$10(concat$11([ifBreak$6("("), indent$6(concat$11([softline$5, elem])), softline$5, ifBreak$6(")")]), {
  22581. shouldBreak: shouldBreak
  22582. });
  22583. }
  22584. function isBinaryish(node) {
  22585. return node.type === "BinaryExpression" || node.type === "LogicalExpression" || node.type === "NGPipeExpression";
  22586. }
  22587. function isMemberish(node) {
  22588. return node.type === "MemberExpression" || node.type === "OptionalMemberExpression" || node.type === "BindExpression" && node.object;
  22589. }
  22590. function shouldInlineLogicalExpression(node) {
  22591. if (node.type !== "LogicalExpression") {
  22592. return false;
  22593. }
  22594. if (node.right.type === "ObjectExpression" && node.right.properties.length !== 0) {
  22595. return true;
  22596. }
  22597. if (node.right.type === "ArrayExpression" && node.right.elements.length !== 0) {
  22598. return true;
  22599. }
  22600. if (isJSXNode(node.right)) {
  22601. return true;
  22602. }
  22603. return false;
  22604. } // For binary expressions to be consistent, we need to group
  22605. // subsequent operators with the same precedence level under a single
  22606. // group. Otherwise they will be nested such that some of them break
  22607. // onto new lines but not all. Operators with the same precedence
  22608. // level should either all break or not. Because we group them by
  22609. // precedence level and the AST is structured based on precedence
  22610. // level, things are naturally broken up correctly, i.e. `&&` is
  22611. // broken before `+`.
  22612. function printBinaryishExpressions(path, print, options, isNested, isInsideParenthesis) {
  22613. var parts = [];
  22614. var node = path.getValue(); // We treat BinaryExpression and LogicalExpression nodes the same.
  22615. if (isBinaryish(node)) {
  22616. // Put all operators with the same precedence level in the same
  22617. // group. The reason we only need to do this with the `left`
  22618. // expression is because given an expression like `1 + 2 - 3`, it
  22619. // is always parsed like `((1 + 2) - 3)`, meaning the `left` side
  22620. // is where the rest of the expression will exist. Binary
  22621. // expressions on the right side mean they have a difference
  22622. // precedence level and should be treated as a separate group, so
  22623. // print them normally. (This doesn't hold for the `**` operator,
  22624. // which is unique in that it is right-associative.)
  22625. if (shouldFlatten$1(node.operator, node.left.operator)) {
  22626. // Flatten them out by recursively calling this function.
  22627. parts = parts.concat(path.call(function (left) {
  22628. return printBinaryishExpressions(left, print, options,
  22629. /* isNested */
  22630. true, isInsideParenthesis);
  22631. }, "left"));
  22632. } else {
  22633. parts.push(path.call(print, "left"));
  22634. }
  22635. var shouldInline = shouldInlineLogicalExpression(node);
  22636. var lineBeforeOperator = (node.operator === "|>" || node.type === "NGPipeExpression" || node.operator === "|" && options.parser === "__vue_expression") && !hasLeadingOwnLineComment(options.originalText, node.right, options);
  22637. var operator = node.type === "NGPipeExpression" ? "|" : node.operator;
  22638. 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) {
  22639. return align$1(2, group$10(arg));
  22640. }))]))) : "";
  22641. 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
  22642. // in order to avoid having a small right part like -1 be on its own line.
  22643. var parent = path.getParentNode();
  22644. var shouldGroup = !(isInsideParenthesis && node.type === "LogicalExpression") && parent.type !== node.type && node.left.type !== node.type && node.right.type !== node.type;
  22645. parts.push(" ", shouldGroup ? group$10(right) : right); // The root comments are already printed, but we need to manually print
  22646. // the other ones since we don't call the normal print on BinaryExpression,
  22647. // only for the left and right parts
  22648. if (isNested && node.comments) {
  22649. parts = comments.printComments(path, function () {
  22650. return concat$11(parts);
  22651. }, options);
  22652. }
  22653. } else {
  22654. // Our stopping case. Simply print the node normally.
  22655. parts.push(path.call(print));
  22656. }
  22657. return parts;
  22658. }
  22659. function printAssignmentRight(leftNode, rightNode, printedRight, options) {
  22660. if (hasLeadingOwnLineComment(options.originalText, rightNode, options)) {
  22661. return indent$6(concat$11([hardline$8, printedRight]));
  22662. }
  22663. 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
  22664. options.parser !== "json" && options.parser !== "json5" || rightNode.type === "SequenceExpression";
  22665. if (canBreak) {
  22666. return group$10(indent$6(concat$11([line$8, printedRight])));
  22667. }
  22668. return concat$11([" ", printedRight]);
  22669. }
  22670. function printAssignment(leftNode, printedLeft, operator, rightNode, printedRight, options) {
  22671. if (!rightNode) {
  22672. return printedLeft;
  22673. }
  22674. var printed = printAssignmentRight(leftNode, rightNode, printedRight, options);
  22675. return group$10(concat$11([printedLeft, operator, printed]));
  22676. }
  22677. function adjustClause(node, clause, forceSpace) {
  22678. if (node.type === "EmptyStatement") {
  22679. return ";";
  22680. }
  22681. if (node.type === "BlockStatement" || forceSpace) {
  22682. return concat$11([" ", clause]);
  22683. }
  22684. return indent$6(concat$11([line$8, clause]));
  22685. }
  22686. function nodeStr(node, options, isFlowOrTypeScriptDirectiveLiteral) {
  22687. var raw = rawText(node);
  22688. var isDirectiveLiteral = isFlowOrTypeScriptDirectiveLiteral || node.type === "DirectiveLiteral";
  22689. return printString$2(raw, options, isDirectiveLiteral);
  22690. }
  22691. function printRegex(node) {
  22692. var flags = node.flags.split("").sort().join("");
  22693. return "/".concat(node.pattern, "/").concat(flags);
  22694. }
  22695. function isLastStatement(path) {
  22696. var parent = path.getParentNode();
  22697. if (!parent) {
  22698. return true;
  22699. }
  22700. var node = path.getValue();
  22701. var body = (parent.body || parent.consequent).filter(function (stmt) {
  22702. return stmt.type !== "EmptyStatement";
  22703. });
  22704. return body && body[body.length - 1] === node;
  22705. }
  22706. function hasLeadingComment(node) {
  22707. return node.comments && node.comments.some(function (comment) {
  22708. return comment.leading;
  22709. });
  22710. }
  22711. function hasTrailingComment(node) {
  22712. return node.comments && node.comments.some(function (comment) {
  22713. return comment.trailing;
  22714. });
  22715. }
  22716. function hasLeadingOwnLineComment(text, node, options) {
  22717. if (isJSXNode(node)) {
  22718. return hasNodeIgnoreComment$1(node);
  22719. }
  22720. var res = node.comments && node.comments.some(function (comment) {
  22721. return comment.leading && hasNewline$3(text, options.locEnd(comment));
  22722. });
  22723. return res;
  22724. }
  22725. function isFlowAnnotationComment(text, typeAnnotation, options) {
  22726. var start = options.locStart(typeAnnotation);
  22727. var end = skipWhitespace$1(text, options.locEnd(typeAnnotation));
  22728. return text.substr(start, 2) === "/*" && text.substr(end, 2) === "*/";
  22729. }
  22730. function exprNeedsASIProtection(path, options) {
  22731. var node = path.getValue();
  22732. 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;
  22733. if (maybeASIProblem) {
  22734. return true;
  22735. }
  22736. if (!hasNakedLeftSide(node)) {
  22737. return false;
  22738. }
  22739. return path.call.apply(path, [function (childPath) {
  22740. return exprNeedsASIProtection(childPath, options);
  22741. }].concat(getLeftSidePathName(path, node)));
  22742. }
  22743. function stmtNeedsASIProtection(path, options) {
  22744. var node = path.getNode();
  22745. if (node.type !== "ExpressionStatement") {
  22746. return false;
  22747. }
  22748. return path.call(function (childPath) {
  22749. return exprNeedsASIProtection(childPath, options);
  22750. }, "expression");
  22751. }
  22752. function classPropMayCauseASIProblems(path) {
  22753. var node = path.getNode();
  22754. if (node.type !== "ClassProperty") {
  22755. return false;
  22756. }
  22757. var name = node.key && node.key.name; // this isn't actually possible yet with most parsers available today
  22758. // so isn't properly tested yet.
  22759. if ((name === "static" || name === "get" || name === "set") && !node.value && !node.typeAnnotation) {
  22760. return true;
  22761. }
  22762. }
  22763. function classChildNeedsASIProtection(node) {
  22764. if (!node) {
  22765. return;
  22766. }
  22767. if (node.static || node.accessibility // TypeScript
  22768. ) {
  22769. return false;
  22770. }
  22771. if (!node.computed) {
  22772. var name = node.key && node.key.name;
  22773. if (name === "in" || name === "instanceof") {
  22774. return true;
  22775. }
  22776. }
  22777. switch (node.type) {
  22778. case "ClassProperty":
  22779. case "TSAbstractClassProperty":
  22780. return node.computed;
  22781. case "MethodDefinition": // Flow
  22782. case "TSAbstractMethodDefinition": // TypeScript
  22783. case "ClassMethod":
  22784. case "ClassPrivateMethod":
  22785. {
  22786. // Babel
  22787. var isAsync = node.value ? node.value.async : node.async;
  22788. var isGenerator = node.value ? node.value.generator : node.generator;
  22789. if (isAsync || node.kind === "get" || node.kind === "set") {
  22790. return false;
  22791. }
  22792. if (node.computed || isGenerator) {
  22793. return true;
  22794. }
  22795. return false;
  22796. }
  22797. default:
  22798. /* istanbul ignore next */
  22799. return false;
  22800. }
  22801. } // This recurses the return argument, looking for the first token
  22802. // (the leftmost leaf node) and, if it (or its parents) has any
  22803. // leadingComments, returns true (so it can be wrapped in parens).
  22804. function returnArgumentHasLeadingComment(options, argument) {
  22805. if (hasLeadingOwnLineComment(options.originalText, argument, options)) {
  22806. return true;
  22807. }
  22808. if (hasNakedLeftSide(argument)) {
  22809. var leftMost = argument;
  22810. var newLeftMost;
  22811. while (newLeftMost = getLeftSide(leftMost)) {
  22812. leftMost = newLeftMost;
  22813. if (hasLeadingOwnLineComment(options.originalText, leftMost, options)) {
  22814. return true;
  22815. }
  22816. }
  22817. }
  22818. return false;
  22819. }
  22820. function isMemberExpressionChain(node) {
  22821. if (node.type !== "MemberExpression" && node.type !== "OptionalMemberExpression") {
  22822. return false;
  22823. }
  22824. if (node.object.type === "Identifier") {
  22825. return true;
  22826. }
  22827. return isMemberExpressionChain(node.object);
  22828. } // Hack to differentiate between the following two which have the same ast
  22829. // type T = { method: () => void };
  22830. // type T = { method(): void };
  22831. function isObjectTypePropertyAFunction(node, options) {
  22832. return (node.type === "ObjectTypeProperty" || node.type === "ObjectTypeInternalSlot") && node.value.type === "FunctionTypeAnnotation" && !node.static && !isFunctionNotation(node, options);
  22833. } // TODO: This is a bad hack and we need a better way to distinguish between
  22834. // arrow functions and otherwise
  22835. function isFunctionNotation(node, options) {
  22836. return isGetterOrSetter(node) || sameLocStart(node, node.value, options);
  22837. }
  22838. function isGetterOrSetter(node) {
  22839. return node.kind === "get" || node.kind === "set";
  22840. }
  22841. function sameLocStart(nodeA, nodeB, options) {
  22842. return options.locStart(nodeA) === options.locStart(nodeB);
  22843. } // Hack to differentiate between the following two which have the same ast
  22844. // declare function f(a): void;
  22845. // var f: (a) => void;
  22846. function isTypeAnnotationAFunction(node, options) {
  22847. return (node.type === "TypeAnnotation" || node.type === "TSTypeAnnotation") && node.typeAnnotation.type === "FunctionTypeAnnotation" && !node.static && !sameLocStart(node, node.typeAnnotation, options);
  22848. }
  22849. function isNodeStartingWithDeclare(node, options) {
  22850. if (!(options.parser === "flow" || options.parser === "typescript")) {
  22851. return false;
  22852. }
  22853. return options.originalText.slice(0, options.locStart(node)).match(/declare[ \t]*$/) || options.originalText.slice(node.range[0], node.range[1]).startsWith("declare ");
  22854. }
  22855. function shouldHugType(node) {
  22856. if (isSimpleFlowType(node) || isObjectType(node)) {
  22857. return true;
  22858. }
  22859. if (node.type === "UnionTypeAnnotation" || node.type === "TSUnionType") {
  22860. var voidCount = node.types.filter(function (n) {
  22861. return n.type === "VoidTypeAnnotation" || n.type === "TSVoidKeyword" || n.type === "NullLiteralTypeAnnotation" || n.type === "TSNullKeyword";
  22862. }).length;
  22863. var objectCount = node.types.filter(function (n) {
  22864. return n.type === "ObjectTypeAnnotation" || n.type === "TSTypeLiteral" || // This is a bit aggressive but captures Array<{x}>
  22865. n.type === "GenericTypeAnnotation" || n.type === "TSTypeReference";
  22866. }).length;
  22867. if (node.types.length - 1 === voidCount && objectCount > 0) {
  22868. return true;
  22869. }
  22870. }
  22871. return false;
  22872. }
  22873. function shouldHugArguments(fun) {
  22874. 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;
  22875. }
  22876. function templateLiteralHasNewLines(template) {
  22877. return template.quasis.some(function (quasi) {
  22878. return quasi.value.raw.includes("\n");
  22879. });
  22880. }
  22881. function isTemplateOnItsOwnLine(n, text, options) {
  22882. return (n.type === "TemplateLiteral" && templateLiteralHasNewLines(n) || n.type === "TaggedTemplateExpression" && templateLiteralHasNewLines(n.quasi)) && !hasNewline$3(text, options.locStart(n), {
  22883. backwards: true
  22884. });
  22885. }
  22886. function printArrayItems(path, options, printPath, print) {
  22887. var printedElements = [];
  22888. var separatorParts = [];
  22889. path.each(function (childPath) {
  22890. printedElements.push(concat$11(separatorParts));
  22891. printedElements.push(group$10(print(childPath)));
  22892. separatorParts = [",", line$8];
  22893. if (childPath.getValue() && isNextLineEmpty$4(options.originalText, childPath.getValue(), options)) {
  22894. separatorParts.push(softline$5);
  22895. }
  22896. }, printPath);
  22897. return concat$11(printedElements);
  22898. }
  22899. function hasDanglingComments(node) {
  22900. return node.comments && node.comments.some(function (comment) {
  22901. return !comment.leading && !comment.trailing;
  22902. });
  22903. }
  22904. function needsHardlineAfterDanglingComment(node) {
  22905. if (!node.comments) {
  22906. return false;
  22907. }
  22908. var lastDanglingComment = getLast$3(node.comments.filter(function (comment) {
  22909. return !comment.leading && !comment.trailing;
  22910. }));
  22911. return lastDanglingComment && !comments$3.isBlockComment(lastDanglingComment);
  22912. }
  22913. function isLiteral(node) {
  22914. 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";
  22915. }
  22916. function isStringPropSafeToCoerceToIdentifier(node, options) {
  22917. return isStringLiteral(node.key) && isIdentifierName(node.key.value) && options.parser !== "json" && !(options.parser === "typescript" && node.type === "ClassProperty");
  22918. }
  22919. function isNumericLiteral(node) {
  22920. return node.type === "NumericLiteral" || node.type === "Literal" && typeof node.value === "number";
  22921. }
  22922. function isStringLiteral(node) {
  22923. return node.type === "StringLiteral" || node.type === "Literal" && typeof node.value === "string";
  22924. }
  22925. function isObjectType(n) {
  22926. return n.type === "ObjectTypeAnnotation" || n.type === "TSTypeLiteral";
  22927. }
  22928. var unitTestRe = /^(skip|[fx]?(it|describe|test))$/; // eg; `describe("some string", (done) => {})`
  22929. function isTestCall(n, parent) {
  22930. if (n.type !== "CallExpression") {
  22931. return false;
  22932. }
  22933. if (n.arguments.length === 1) {
  22934. if (isAngularTestWrapper(n) && parent && isTestCall(parent)) {
  22935. return isFunctionOrArrowExpression(n.arguments[0]);
  22936. }
  22937. if (isUnitTestSetUp(n)) {
  22938. return isAngularTestWrapper(n.arguments[0]);
  22939. }
  22940. } else if (n.arguments.length === 2 || n.arguments.length === 3) {
  22941. if ((n.callee.type === "Identifier" && unitTestRe.test(n.callee.name) || isSkipOrOnlyBlock(n)) && (isTemplateLiteral(n.arguments[0]) || isStringLiteral(n.arguments[0]))) {
  22942. // it("name", () => { ... }, 2500)
  22943. if (n.arguments[2] && !isNumericLiteral(n.arguments[2])) {
  22944. return false;
  22945. }
  22946. return (n.arguments.length === 2 ? isFunctionOrArrowExpression(n.arguments[1]) : isFunctionOrArrowExpressionWithBody(n.arguments[1]) && n.arguments[1].params.length <= 1) || isAngularTestWrapper(n.arguments[1]);
  22947. }
  22948. }
  22949. return false;
  22950. }
  22951. function isSkipOrOnlyBlock(node) {
  22952. 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");
  22953. }
  22954. function isTemplateLiteral(node) {
  22955. return node.type === "TemplateLiteral";
  22956. } // `inject` is used in AngularJS 1.x, `async` in Angular 2+
  22957. // example: https://docs.angularjs.org/guide/unit-testing#using-beforeall-
  22958. function isAngularTestWrapper(node) {
  22959. return (node.type === "CallExpression" || node.type === "OptionalCallExpression") && node.callee.type === "Identifier" && (node.callee.name === "async" || node.callee.name === "inject" || node.callee.name === "fakeAsync");
  22960. }
  22961. function isFunctionOrArrowExpression(node) {
  22962. return node.type === "FunctionExpression" || node.type === "ArrowFunctionExpression";
  22963. }
  22964. function isFunctionOrArrowExpressionWithBody(node) {
  22965. return node.type === "FunctionExpression" || node.type === "ArrowFunctionExpression" && node.body.type === "BlockStatement";
  22966. }
  22967. function isUnitTestSetUp(n) {
  22968. var unitTestSetUpRe = /^(before|after)(Each|All)$/;
  22969. return n.callee.type === "Identifier" && unitTestSetUpRe.test(n.callee.name) && n.arguments.length === 1;
  22970. }
  22971. function isTheOnlyJSXElementInMarkdown(options, path) {
  22972. if (options.parentParser !== "markdown" && options.parentParser !== "mdx") {
  22973. return false;
  22974. }
  22975. var node = path.getNode();
  22976. if (!node.expression || !isJSXNode(node.expression)) {
  22977. return false;
  22978. }
  22979. var parent = path.getParentNode();
  22980. return parent.type === "Program" && parent.body.length == 1;
  22981. }
  22982. function willPrintOwnComments(path
  22983. /*, options */
  22984. ) {
  22985. var node = path.getValue();
  22986. var parent = path.getParentNode();
  22987. 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);
  22988. }
  22989. function canAttachComment$1(node) {
  22990. return node.type && node.type !== "CommentBlock" && node.type !== "CommentLine" && node.type !== "Line" && node.type !== "Block" && node.type !== "EmptyStatement" && node.type !== "TemplateElement" && node.type !== "Import";
  22991. }
  22992. function printComment$2(commentPath, options) {
  22993. var comment = commentPath.getValue();
  22994. switch (comment.type) {
  22995. case "CommentBlock":
  22996. case "Block":
  22997. {
  22998. if (isIndentableBlockComment(comment)) {
  22999. var printed = printIndentableBlockComment(comment); // We need to prevent an edge case of a previous trailing comment
  23000. // printed as a `lineSuffix` which causes the comments to be
  23001. // interleaved. See https://github.com/prettier/prettier/issues/4412
  23002. if (comment.trailing && !hasNewline$3(options.originalText, options.locStart(comment), {
  23003. backwards: true
  23004. })) {
  23005. return concat$11([hardline$8, printed]);
  23006. }
  23007. return printed;
  23008. }
  23009. var isInsideFlowComment = options.originalText.substr(options.locEnd(comment) - 3, 3) === "*-/";
  23010. return "/*" + comment.value + (isInsideFlowComment ? "*-/" : "*/");
  23011. }
  23012. case "CommentLine":
  23013. case "Line":
  23014. // Print shebangs with the proper comment characters
  23015. if (options.originalText.slice(options.locStart(comment)).startsWith("#!")) {
  23016. return "#!" + comment.value.trimRight();
  23017. }
  23018. return "//" + comment.value.trimRight();
  23019. default:
  23020. throw new Error("Not a comment: " + JSON.stringify(comment));
  23021. }
  23022. }
  23023. function isIndentableBlockComment(comment) {
  23024. // If the comment has multiple lines and every line starts with a star
  23025. // we can fix the indentation of each line. The stars in the `/*` and
  23026. // `*/` delimiters are not included in the comment value, so add them
  23027. // back first.
  23028. var lines = "*".concat(comment.value, "*").split("\n");
  23029. return lines.length > 1 && lines.every(function (line) {
  23030. return line.trim()[0] === "*";
  23031. });
  23032. }
  23033. function printIndentableBlockComment(comment) {
  23034. var lines = comment.value.split("\n");
  23035. return concat$11(["/*", join$7(hardline$8, lines.map(function (line, index) {
  23036. return index === 0 ? line.trimRight() : " " + (index < lines.length - 1 ? line.trim() : line.trimLeft());
  23037. })), "*/"]);
  23038. }
  23039. function rawText(node) {
  23040. return node.extra ? node.extra.raw : node.raw;
  23041. }
  23042. function identity$1(x) {
  23043. return x;
  23044. }
  23045. var printerEstree = {
  23046. preprocess: preprocess_1$2,
  23047. print: genericPrint$3,
  23048. embed: embed_1$2,
  23049. insertPragma: insertPragma$7,
  23050. massageAstNode: clean_1$2,
  23051. hasPrettierIgnore: hasPrettierIgnore$2,
  23052. willPrintOwnComments: willPrintOwnComments,
  23053. canAttachComment: canAttachComment$1,
  23054. printComment: printComment$2,
  23055. isBlockComment: comments$3.isBlockComment,
  23056. handleComments: {
  23057. ownLine: comments$3.handleOwnLineComment,
  23058. endOfLine: comments$3.handleEndOfLineComment,
  23059. remaining: comments$3.handleRemainingComment
  23060. }
  23061. };
  23062. var _require$$0$builders$7 = doc.builders;
  23063. var concat$14 = _require$$0$builders$7.concat;
  23064. var hardline$10 = _require$$0$builders$7.hardline;
  23065. var indent$8 = _require$$0$builders$7.indent;
  23066. var join$10 = _require$$0$builders$7.join;
  23067. function genericPrint$4(path, options, print) {
  23068. var node = path.getValue();
  23069. switch (node.type) {
  23070. case "JsonRoot":
  23071. return concat$14([path.call(print, "node"), hardline$10]);
  23072. case "ArrayExpression":
  23073. 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, "]"]);
  23074. case "ObjectExpression":
  23075. 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, "}"]);
  23076. case "ObjectProperty":
  23077. return concat$14([path.call(print, "key"), ": ", path.call(print, "value")]);
  23078. case "UnaryExpression":
  23079. return concat$14([node.operator === "+" ? "" : node.operator, path.call(print, "argument")]);
  23080. case "NullLiteral":
  23081. return "null";
  23082. case "BooleanLiteral":
  23083. return node.value ? "true" : "false";
  23084. case "StringLiteral":
  23085. case "NumericLiteral":
  23086. return JSON.stringify(node.value);
  23087. case "Identifier":
  23088. return JSON.stringify(node.name);
  23089. default:
  23090. /* istanbul ignore next */
  23091. throw new Error("unknown type: " + JSON.stringify(node.type));
  23092. }
  23093. }
  23094. function clean$9(node, newNode
  23095. /*, parent*/
  23096. ) {
  23097. delete newNode.start;
  23098. delete newNode.end;
  23099. delete newNode.extra;
  23100. delete newNode.loc;
  23101. delete newNode.comments;
  23102. if (node.type === "Identifier") {
  23103. return {
  23104. type: "StringLiteral",
  23105. value: node.name
  23106. };
  23107. }
  23108. if (node.type === "UnaryExpression" && node.operator === "+") {
  23109. return newNode.argument;
  23110. }
  23111. }
  23112. var printerEstreeJson = {
  23113. preprocess: preprocess_1$2,
  23114. print: genericPrint$4,
  23115. massageAstNode: clean$9
  23116. };
  23117. var CATEGORY_JAVASCRIPT = "JavaScript"; // format based on https://github.com/prettier/prettier/blob/master/src/main/core-options.js
  23118. var options$12 = {
  23119. arrowParens: {
  23120. since: "1.9.0",
  23121. category: CATEGORY_JAVASCRIPT,
  23122. type: "choice",
  23123. default: "avoid",
  23124. description: "Include parentheses around a sole arrow function parameter.",
  23125. choices: [{
  23126. value: "avoid",
  23127. description: "Omit parens when possible. Example: `x => x`"
  23128. }, {
  23129. value: "always",
  23130. description: "Always include parens. Example: `(x) => x`"
  23131. }]
  23132. },
  23133. bracketSpacing: commonOptions.bracketSpacing,
  23134. jsxBracketSameLine: {
  23135. since: "0.17.0",
  23136. category: CATEGORY_JAVASCRIPT,
  23137. type: "boolean",
  23138. default: false,
  23139. description: "Put > on the last line instead of at a new line."
  23140. },
  23141. semi: {
  23142. since: "1.0.0",
  23143. category: CATEGORY_JAVASCRIPT,
  23144. type: "boolean",
  23145. default: true,
  23146. description: "Print semicolons.",
  23147. oppositeDescription: "Do not print semicolons, except at the beginning of lines which may need them."
  23148. },
  23149. singleQuote: commonOptions.singleQuote,
  23150. jsxSingleQuote: {
  23151. since: "1.15.0",
  23152. category: CATEGORY_JAVASCRIPT,
  23153. type: "boolean",
  23154. default: false,
  23155. description: "Use single quotes in JSX."
  23156. },
  23157. quoteProps: {
  23158. since: "1.17.0",
  23159. category: CATEGORY_JAVASCRIPT,
  23160. type: "choice",
  23161. default: "as-needed",
  23162. description: "Change when properties in objects are quoted.",
  23163. choices: [{
  23164. value: "as-needed",
  23165. description: "Only add quotes around object properties where required."
  23166. }, {
  23167. value: "consistent",
  23168. description: "If at least one property in an object requires quotes, quote all properties."
  23169. }, {
  23170. value: "preserve",
  23171. description: "Respect the input use of quotes in object properties."
  23172. }]
  23173. },
  23174. trailingComma: {
  23175. since: "0.0.0",
  23176. category: CATEGORY_JAVASCRIPT,
  23177. type: "choice",
  23178. default: [{
  23179. since: "0.0.0",
  23180. value: false
  23181. }, {
  23182. since: "0.19.0",
  23183. value: "none"
  23184. }],
  23185. description: "Print trailing commas wherever possible when multi-line.",
  23186. choices: [{
  23187. value: "none",
  23188. description: "No trailing commas."
  23189. }, {
  23190. value: "es5",
  23191. description: "Trailing commas where valid in ES5 (objects, arrays, etc.)"
  23192. }, {
  23193. value: "all",
  23194. description: "Trailing commas wherever possible (including function arguments)."
  23195. }, {
  23196. value: true,
  23197. deprecated: "0.19.0",
  23198. redirect: "es5"
  23199. }, {
  23200. value: false,
  23201. deprecated: "0.19.0",
  23202. redirect: "none"
  23203. }]
  23204. }
  23205. };
  23206. var name$9 = "JavaScript";
  23207. var type$8 = "programming";
  23208. var tmScope$8 = "source.js";
  23209. var aceMode$8 = "javascript";
  23210. var codemirrorMode$4 = "javascript";
  23211. var codemirrorMimeType$4 = "text/javascript";
  23212. var color$3 = "#f1e05a";
  23213. var aliases$2 = ["js", "node"];
  23214. var extensions$8 = [".js", "._js", ".bones", ".es", ".es6", ".frag", ".gs", ".jake", ".jsb", ".jscad", ".jsfl", ".jsm", ".jss", ".mjs", ".njs", ".pac", ".sjs", ".ssjs", ".xsjs", ".xsjslib"];
  23215. var filenames = ["Jakefile"];
  23216. var interpreters = ["node"];
  23217. var languageId$8 = 183;
  23218. var javascript = {
  23219. name: name$9,
  23220. type: type$8,
  23221. tmScope: tmScope$8,
  23222. aceMode: aceMode$8,
  23223. codemirrorMode: codemirrorMode$4,
  23224. codemirrorMimeType: codemirrorMimeType$4,
  23225. color: color$3,
  23226. aliases: aliases$2,
  23227. extensions: extensions$8,
  23228. filenames: filenames,
  23229. interpreters: interpreters,
  23230. languageId: languageId$8
  23231. };
  23232. var javascript$1 = Object.freeze({
  23233. name: name$9,
  23234. type: type$8,
  23235. tmScope: tmScope$8,
  23236. aceMode: aceMode$8,
  23237. codemirrorMode: codemirrorMode$4,
  23238. codemirrorMimeType: codemirrorMimeType$4,
  23239. color: color$3,
  23240. aliases: aliases$2,
  23241. extensions: extensions$8,
  23242. filenames: filenames,
  23243. interpreters: interpreters,
  23244. languageId: languageId$8,
  23245. default: javascript
  23246. });
  23247. var name$10 = "JSX";
  23248. var type$9 = "programming";
  23249. var group$12 = "JavaScript";
  23250. var extensions$9 = [".jsx"];
  23251. var tmScope$9 = "source.js.jsx";
  23252. var aceMode$9 = "javascript";
  23253. var codemirrorMode$5 = "jsx";
  23254. var codemirrorMimeType$5 = "text/jsx";
  23255. var languageId$9 = 178;
  23256. var jsx = {
  23257. name: name$10,
  23258. type: type$9,
  23259. group: group$12,
  23260. extensions: extensions$9,
  23261. tmScope: tmScope$9,
  23262. aceMode: aceMode$9,
  23263. codemirrorMode: codemirrorMode$5,
  23264. codemirrorMimeType: codemirrorMimeType$5,
  23265. languageId: languageId$9
  23266. };
  23267. var jsx$1 = Object.freeze({
  23268. name: name$10,
  23269. type: type$9,
  23270. group: group$12,
  23271. extensions: extensions$9,
  23272. tmScope: tmScope$9,
  23273. aceMode: aceMode$9,
  23274. codemirrorMode: codemirrorMode$5,
  23275. codemirrorMimeType: codemirrorMimeType$5,
  23276. languageId: languageId$9,
  23277. default: jsx
  23278. });
  23279. var name$11 = "TypeScript";
  23280. var type$10 = "programming";
  23281. var color$4 = "#2b7489";
  23282. var aliases$3 = ["ts"];
  23283. var extensions$10 = [".ts", ".tsx"];
  23284. var tmScope$10 = "source.ts";
  23285. var aceMode$10 = "typescript";
  23286. var codemirrorMode$6 = "javascript";
  23287. var codemirrorMimeType$6 = "application/typescript";
  23288. var languageId$10 = 378;
  23289. var typescript = {
  23290. name: name$11,
  23291. type: type$10,
  23292. color: color$4,
  23293. aliases: aliases$3,
  23294. extensions: extensions$10,
  23295. tmScope: tmScope$10,
  23296. aceMode: aceMode$10,
  23297. codemirrorMode: codemirrorMode$6,
  23298. codemirrorMimeType: codemirrorMimeType$6,
  23299. languageId: languageId$10
  23300. };
  23301. var typescript$1 = Object.freeze({
  23302. name: name$11,
  23303. type: type$10,
  23304. color: color$4,
  23305. aliases: aliases$3,
  23306. extensions: extensions$10,
  23307. tmScope: tmScope$10,
  23308. aceMode: aceMode$10,
  23309. codemirrorMode: codemirrorMode$6,
  23310. codemirrorMimeType: codemirrorMimeType$6,
  23311. languageId: languageId$10,
  23312. default: typescript
  23313. });
  23314. var name$12 = "JSON";
  23315. var type$11 = "data";
  23316. var tmScope$11 = "source.json";
  23317. var group$13 = "JavaScript";
  23318. var aceMode$11 = "json";
  23319. var codemirrorMode$7 = "javascript";
  23320. var codemirrorMimeType$7 = "application/json";
  23321. var searchable = false;
  23322. var extensions$11 = [".json", ".avsc", ".geojson", ".gltf", ".JSON-tmLanguage", ".jsonl", ".tfstate", ".tfstate.backup", ".topojson", ".webapp", ".webmanifest"];
  23323. var filenames$1 = [".arcconfig", ".htmlhintrc", ".tern-config", ".tern-project", "composer.lock", "mcmod.info"];
  23324. var languageId$11 = 174;
  23325. var json$5 = {
  23326. name: name$12,
  23327. type: type$11,
  23328. tmScope: tmScope$11,
  23329. group: group$13,
  23330. aceMode: aceMode$11,
  23331. codemirrorMode: codemirrorMode$7,
  23332. codemirrorMimeType: codemirrorMimeType$7,
  23333. searchable: searchable,
  23334. extensions: extensions$11,
  23335. filenames: filenames$1,
  23336. languageId: languageId$11
  23337. };
  23338. var json$6 = Object.freeze({
  23339. name: name$12,
  23340. type: type$11,
  23341. tmScope: tmScope$11,
  23342. group: group$13,
  23343. aceMode: aceMode$11,
  23344. codemirrorMode: codemirrorMode$7,
  23345. codemirrorMimeType: codemirrorMimeType$7,
  23346. searchable: searchable,
  23347. extensions: extensions$11,
  23348. filenames: filenames$1,
  23349. languageId: languageId$11,
  23350. default: json$5
  23351. });
  23352. var name$13 = "JSON with Comments";
  23353. var type$12 = "data";
  23354. var group$14 = "JSON";
  23355. var tmScope$12 = "source.js";
  23356. var aceMode$12 = "javascript";
  23357. var codemirrorMode$8 = "javascript";
  23358. var codemirrorMimeType$8 = "text/javascript";
  23359. var aliases$4 = ["jsonc"];
  23360. 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"];
  23361. var filenames$2 = [".babelrc", ".eslintrc.json", ".jscsrc", ".jshintrc", ".jslintrc", "tsconfig.json"];
  23362. var languageId$12 = 423;
  23363. var jsonWithComments = {
  23364. name: name$13,
  23365. type: type$12,
  23366. group: group$14,
  23367. tmScope: tmScope$12,
  23368. aceMode: aceMode$12,
  23369. codemirrorMode: codemirrorMode$8,
  23370. codemirrorMimeType: codemirrorMimeType$8,
  23371. aliases: aliases$4,
  23372. extensions: extensions$12,
  23373. filenames: filenames$2,
  23374. languageId: languageId$12
  23375. };
  23376. var jsonWithComments$1 = Object.freeze({
  23377. name: name$13,
  23378. type: type$12,
  23379. group: group$14,
  23380. tmScope: tmScope$12,
  23381. aceMode: aceMode$12,
  23382. codemirrorMode: codemirrorMode$8,
  23383. codemirrorMimeType: codemirrorMimeType$8,
  23384. aliases: aliases$4,
  23385. extensions: extensions$12,
  23386. filenames: filenames$2,
  23387. languageId: languageId$12,
  23388. default: jsonWithComments
  23389. });
  23390. var name$14 = "JSON5";
  23391. var type$13 = "data";
  23392. var extensions$13 = [".json5"];
  23393. var tmScope$13 = "source.js";
  23394. var aceMode$13 = "javascript";
  23395. var codemirrorMode$9 = "javascript";
  23396. var codemirrorMimeType$9 = "application/json";
  23397. var languageId$13 = 175;
  23398. var json5 = {
  23399. name: name$14,
  23400. type: type$13,
  23401. extensions: extensions$13,
  23402. tmScope: tmScope$13,
  23403. aceMode: aceMode$13,
  23404. codemirrorMode: codemirrorMode$9,
  23405. codemirrorMimeType: codemirrorMimeType$9,
  23406. languageId: languageId$13
  23407. };
  23408. var json5$1 = Object.freeze({
  23409. name: name$14,
  23410. type: type$13,
  23411. extensions: extensions$13,
  23412. tmScope: tmScope$13,
  23413. aceMode: aceMode$13,
  23414. codemirrorMode: codemirrorMode$9,
  23415. codemirrorMimeType: codemirrorMimeType$9,
  23416. languageId: languageId$13,
  23417. default: json5
  23418. });
  23419. var require$$0$24 = ( javascript$1 && javascript ) || javascript$1;
  23420. var require$$1$10 = ( jsx$1 && jsx ) || jsx$1;
  23421. var require$$2$10 = ( typescript$1 && typescript ) || typescript$1;
  23422. var require$$3$7 = ( json$6 && json$5 ) || json$6;
  23423. var require$$4$4 = ( jsonWithComments$1 && jsonWithComments ) || jsonWithComments$1;
  23424. var require$$5$2 = ( json5$1 && json5 ) || json5$1;
  23425. var languages$4 = [createLanguage(require$$0$24, {
  23426. override: {
  23427. since: "0.0.0",
  23428. parsers: ["babel", "flow"],
  23429. vscodeLanguageIds: ["javascript"]
  23430. },
  23431. extend: {
  23432. interpreters: ["nodejs"]
  23433. }
  23434. }), createLanguage(require$$0$24, {
  23435. override: {
  23436. name: "Flow",
  23437. since: "0.0.0",
  23438. parsers: ["babel", "flow"],
  23439. vscodeLanguageIds: ["javascript"],
  23440. aliases: [],
  23441. filenames: [],
  23442. extensions: [".js.flow"]
  23443. }
  23444. }), createLanguage(require$$1$10, {
  23445. override: {
  23446. since: "0.0.0",
  23447. parsers: ["babel", "flow"],
  23448. vscodeLanguageIds: ["javascriptreact"]
  23449. }
  23450. }), createLanguage(require$$2$10, {
  23451. override: {
  23452. since: "1.4.0",
  23453. parsers: ["typescript"],
  23454. vscodeLanguageIds: ["typescript", "typescriptreact"]
  23455. }
  23456. }), createLanguage(require$$3$7, {
  23457. override: {
  23458. name: "JSON.stringify",
  23459. since: "1.13.0",
  23460. parsers: ["json-stringify"],
  23461. vscodeLanguageIds: ["json"],
  23462. extensions: [],
  23463. // .json file defaults to json instead of json-stringify
  23464. filenames: ["package.json", "package-lock.json", "composer.json"]
  23465. }
  23466. }), createLanguage(require$$3$7, {
  23467. override: {
  23468. since: "1.5.0",
  23469. parsers: ["json"],
  23470. vscodeLanguageIds: ["json"]
  23471. },
  23472. extend: {
  23473. filenames: [".prettierrc"]
  23474. }
  23475. }), createLanguage(require$$4$4, {
  23476. override: {
  23477. since: "1.5.0",
  23478. parsers: ["json"],
  23479. vscodeLanguageIds: ["jsonc"]
  23480. },
  23481. extend: {
  23482. filenames: [".eslintrc"]
  23483. }
  23484. }), createLanguage(require$$5$2, {
  23485. override: {
  23486. since: "1.13.0",
  23487. parsers: ["json5"],
  23488. vscodeLanguageIds: ["json5"]
  23489. }
  23490. })];
  23491. var printers$4 = {
  23492. estree: printerEstree,
  23493. "estree-json": printerEstreeJson
  23494. };
  23495. var languageJs = {
  23496. languages: languages$4,
  23497. options: options$12,
  23498. printers: printers$4
  23499. };
  23500. 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]"};
  23501. var cjkPattern = json$9.cjkPattern;
  23502. var kPattern = json$9.kPattern;
  23503. var punctuationPattern$1 = json$9.punctuationPattern;
  23504. var getLast$4 = util.getLast;
  23505. var INLINE_NODE_TYPES$1 = ["liquidNode", "inlineCode", "emphasis", "strong", "delete", "link", "linkReference", "image", "imageReference", "footnote", "footnoteReference", "sentence", "whitespace", "word", "break", "inlineMath"];
  23506. var INLINE_NODE_WRAPPER_TYPES$1 = INLINE_NODE_TYPES$1.concat(["tableCell", "paragraph", "heading"]);
  23507. var kRegex = new RegExp(kPattern);
  23508. var punctuationRegex = new RegExp(punctuationPattern$1);
  23509. /**
  23510. * split text into whitespaces and words
  23511. * @param {string} text
  23512. * @return {Array<{ type: "whitespace", value: " " | "\n" | "" } | { type: "word", value: string }>}
  23513. */
  23514. function splitText$1(text, options) {
  23515. var KIND_NON_CJK = "non-cjk";
  23516. var KIND_CJ_LETTER = "cj-letter";
  23517. var KIND_K_LETTER = "k-letter";
  23518. var KIND_CJK_PUNCTUATION = "cjk-punctuation";
  23519. var nodes = [];
  23520. (options.proseWrap === "preserve" ? text : text.replace(new RegExp("(".concat(cjkPattern, ")\n(").concat(cjkPattern, ")"), "g"), "$1$2")).split(/([ \t\n]+)/).forEach(function (token, index, tokens) {
  23521. // whitespace
  23522. if (index % 2 === 1) {
  23523. nodes.push({
  23524. type: "whitespace",
  23525. value: /\n/.test(token) ? "\n" : " "
  23526. });
  23527. return;
  23528. } // word separated by whitespace
  23529. if ((index === 0 || index === tokens.length - 1) && token === "") {
  23530. return;
  23531. }
  23532. token.split(new RegExp("(".concat(cjkPattern, ")"))).forEach(function (innerToken, innerIndex, innerTokens) {
  23533. if ((innerIndex === 0 || innerIndex === innerTokens.length - 1) && innerToken === "") {
  23534. return;
  23535. } // non-CJK word
  23536. if (innerIndex % 2 === 0) {
  23537. if (innerToken !== "") {
  23538. appendNode({
  23539. type: "word",
  23540. value: innerToken,
  23541. kind: KIND_NON_CJK,
  23542. hasLeadingPunctuation: punctuationRegex.test(innerToken[0]),
  23543. hasTrailingPunctuation: punctuationRegex.test(getLast$4(innerToken))
  23544. });
  23545. }
  23546. return;
  23547. } // CJK character
  23548. appendNode(punctuationRegex.test(innerToken) ? {
  23549. type: "word",
  23550. value: innerToken,
  23551. kind: KIND_CJK_PUNCTUATION,
  23552. hasLeadingPunctuation: true,
  23553. hasTrailingPunctuation: true
  23554. } : {
  23555. type: "word",
  23556. value: innerToken,
  23557. kind: kRegex.test(innerToken) ? KIND_K_LETTER : KIND_CJ_LETTER,
  23558. hasLeadingPunctuation: false,
  23559. hasTrailingPunctuation: false
  23560. });
  23561. });
  23562. });
  23563. return nodes;
  23564. function appendNode(node) {
  23565. var lastNode = getLast$4(nodes);
  23566. if (lastNode && lastNode.type === "word") {
  23567. 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) {
  23568. nodes.push({
  23569. type: "whitespace",
  23570. value: " "
  23571. });
  23572. } else if (!isBetween(KIND_NON_CJK, KIND_CJK_PUNCTUATION) && // disallow leading/trailing full-width whitespace
  23573. ![lastNode.value, node.value].some(function (value) {
  23574. return /\u3000/.test(value);
  23575. })) {
  23576. nodes.push({
  23577. type: "whitespace",
  23578. value: ""
  23579. });
  23580. }
  23581. }
  23582. nodes.push(node);
  23583. function isBetween(kind1, kind2) {
  23584. return lastNode.kind === kind1 && node.kind === kind2 || lastNode.kind === kind2 && node.kind === kind1;
  23585. }
  23586. }
  23587. }
  23588. function getOrderedListItemInfo$1(orderListItem, originalText) {
  23589. var _originalText$slice$m = originalText.slice(orderListItem.position.start.offset, orderListItem.position.end.offset).match(/^\s*(\d+)(\.|\))(\s*)/),
  23590. _originalText$slice$m2 = _slicedToArray(_originalText$slice$m, 4),
  23591. numberText = _originalText$slice$m2[1],
  23592. marker = _originalText$slice$m2[2],
  23593. leadingSpaces = _originalText$slice$m2[3];
  23594. return {
  23595. numberText: numberText,
  23596. marker: marker,
  23597. leadingSpaces: leadingSpaces
  23598. };
  23599. } // workaround for https://github.com/remarkjs/remark/issues/351
  23600. // leading and trailing newlines are stripped by remark
  23601. function getFencedCodeBlockValue$2(node, originalText) {
  23602. var text = originalText.slice(node.position.start.offset, node.position.end.offset);
  23603. var leadingSpaceCount = text.match(/^\s*/)[0].length;
  23604. var replaceRegex = new RegExp("^\\s{0,".concat(leadingSpaceCount, "}"));
  23605. var lineContents = text.split("\n");
  23606. var markerStyle = text[leadingSpaceCount]; // ` or ~
  23607. 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
  23608. // https://spec.commonmark.org/0.28/#example-93: The closing code fence must be at least as long as the opening fence
  23609. var hasEndMarker = new RegExp("^\\s{0,3}".concat(marker)).test(lineContents[lineContents.length - 1].slice(getIndent(lineContents.length - 1)));
  23610. return lineContents.slice(1, hasEndMarker ? -1 : undefined).map(function (x, i) {
  23611. return x.slice(getIndent(i + 1)).replace(replaceRegex, "");
  23612. }).join("\n");
  23613. function getIndent(lineIndex) {
  23614. return node.position.indent[lineIndex - 1] - 1;
  23615. }
  23616. }
  23617. function mapAst(ast, handler) {
  23618. return function preorder(node, index, parentStack) {
  23619. parentStack = parentStack || [];
  23620. var newNode = Object.assign({}, handler(node, index, parentStack));
  23621. if (newNode.children) {
  23622. newNode.children = newNode.children.map(function (child, index) {
  23623. return preorder(child, index, [newNode].concat(parentStack));
  23624. });
  23625. }
  23626. return newNode;
  23627. }(ast, null, null);
  23628. }
  23629. var utils$10 = {
  23630. mapAst: mapAst,
  23631. splitText: splitText$1,
  23632. punctuationPattern: punctuationPattern$1,
  23633. getFencedCodeBlockValue: getFencedCodeBlockValue$2,
  23634. getOrderedListItemInfo: getOrderedListItemInfo$1,
  23635. INLINE_NODE_TYPES: INLINE_NODE_TYPES$1,
  23636. INLINE_NODE_WRAPPER_TYPES: INLINE_NODE_WRAPPER_TYPES$1
  23637. };
  23638. var _require$$0$builders$9 = doc.builders;
  23639. var hardline$12 = _require$$0$builders$9.hardline;
  23640. var literalline$6 = _require$$0$builders$9.literalline;
  23641. var concat$16 = _require$$0$builders$9.concat;
  23642. var markAsRoot$4 = _require$$0$builders$9.markAsRoot;
  23643. var mapDoc$7 = doc.utils.mapDoc;
  23644. var getFencedCodeBlockValue$1 = utils$10.getFencedCodeBlockValue;
  23645. function embed$6(path, print, textToDoc, options) {
  23646. var node = path.getValue();
  23647. if (node.type === "code" && node.lang !== null) {
  23648. // only look for the first string so as to support [markdown-preview-enhanced](https://shd101wyy.github.io/markdown-preview-enhanced/#/code-chunk)
  23649. var langMatch = node.lang.match(/^[A-Za-z0-9_-]+/);
  23650. var lang = langMatch ? langMatch[0] : "";
  23651. var parser = getParserName(lang);
  23652. if (parser) {
  23653. var styleUnit = options.__inJsTemplate ? "~" : "`";
  23654. var style = styleUnit.repeat(Math.max(3, util.getMaxContinuousCount(node.value, styleUnit) + 1));
  23655. var doc$$2 = textToDoc(getFencedCodeBlockValue$1(node, options.originalText), {
  23656. parser: parser
  23657. });
  23658. return markAsRoot$4(concat$16([style, node.lang, hardline$12, replaceNewlinesWithLiterallines(doc$$2), style]));
  23659. }
  23660. }
  23661. if (node.type === "yaml") {
  23662. return markAsRoot$4(concat$16(["---", hardline$12, node.value && node.value.trim() ? replaceNewlinesWithLiterallines(textToDoc(node.value, {
  23663. parser: "yaml"
  23664. })) : "", "---"]));
  23665. } // MDX
  23666. switch (node.type) {
  23667. case "importExport":
  23668. return textToDoc(node.value, {
  23669. parser: "babel"
  23670. });
  23671. case "jsx":
  23672. return textToDoc(node.value, {
  23673. parser: "__js_expression"
  23674. });
  23675. }
  23676. return null;
  23677. function getParserName(lang) {
  23678. var supportInfo = support.getSupportInfo(null, {
  23679. plugins: options.plugins
  23680. });
  23681. var language = supportInfo.languages.find(function (language) {
  23682. return language.name.toLowerCase() === lang || language.aliases && language.aliases.indexOf(lang) !== -1 || language.extensions && language.extensions.find(function (ext) {
  23683. return ext.substring(1) === lang;
  23684. });
  23685. });
  23686. if (language) {
  23687. return language.parsers[0];
  23688. }
  23689. return null;
  23690. }
  23691. function replaceNewlinesWithLiterallines(doc$$2) {
  23692. return mapDoc$7(doc$$2, function (currentDoc) {
  23693. return typeof currentDoc === "string" && currentDoc.includes("\n") ? concat$16(currentDoc.split(/(\n)/g).map(function (v, i) {
  23694. return i % 2 === 0 ? v : literalline$6;
  23695. })) : currentDoc;
  23696. });
  23697. }
  23698. }
  23699. var embed_1$4 = embed$6;
  23700. var pragma$8 = createCommonjsModule(function (module) {
  23701. "use strict";
  23702. var pragmas = ["format", "prettier"];
  23703. function startWithPragma(text) {
  23704. var pragma = "@(".concat(pragmas.join("|"), ")");
  23705. 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");
  23706. var matched = text.match(regex);
  23707. return matched && matched.index === 0;
  23708. }
  23709. module.exports = {
  23710. startWithPragma: startWithPragma,
  23711. hasPragma: function hasPragma(text) {
  23712. return startWithPragma(frontMatter(text).content.trimLeft());
  23713. },
  23714. insertPragma: function insertPragma(text) {
  23715. var extracted = frontMatter(text);
  23716. var pragma = "<!-- @".concat(pragmas[0], " -->");
  23717. return extracted.frontMatter ? "".concat(extracted.frontMatter.raw, "\n\n").concat(pragma, "\n\n").concat(extracted.content) : "".concat(pragma, "\n\n").concat(extracted.content);
  23718. }
  23719. };
  23720. });
  23721. var getOrderedListItemInfo$2 = utils$10.getOrderedListItemInfo;
  23722. var mapAst$1 = utils$10.mapAst;
  23723. var splitText$2 = utils$10.splitText; // 0x0 ~ 0x10ffff
  23724. var isSingleCharRegex = /^([\u0000-\uffff]|[\ud800-\udbff][\udc00-\udfff])$/;
  23725. function preprocess$4(ast, options) {
  23726. ast = restoreUnescapedCharacter(ast, options);
  23727. ast = mergeContinuousTexts(ast);
  23728. ast = transformInlineCode(ast);
  23729. ast = transformIndentedCodeblockAndMarkItsParentList(ast, options);
  23730. ast = markAlignedList(ast, options);
  23731. ast = splitTextIntoSentences(ast, options);
  23732. ast = transformImportExport(ast);
  23733. ast = mergeContinuousImportExport(ast);
  23734. return ast;
  23735. }
  23736. function transformImportExport(ast) {
  23737. return mapAst$1(ast, function (node) {
  23738. if (node.type !== "import" && node.type !== "export") {
  23739. return node;
  23740. }
  23741. return Object.assign({}, node, {
  23742. type: "importExport"
  23743. });
  23744. });
  23745. }
  23746. function transformInlineCode(ast) {
  23747. return mapAst$1(ast, function (node) {
  23748. if (node.type !== "inlineCode") {
  23749. return node;
  23750. }
  23751. return Object.assign({}, node, {
  23752. value: node.value.replace(/\s+/g, " ")
  23753. });
  23754. });
  23755. }
  23756. function restoreUnescapedCharacter(ast, options) {
  23757. return mapAst$1(ast, function (node) {
  23758. return node.type !== "text" ? node : Object.assign({}, node, {
  23759. value: node.value !== "*" && node.value !== "_" && node.value !== "$" && // handle these cases in printer
  23760. 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
  23761. });
  23762. });
  23763. }
  23764. function mergeContinuousImportExport(ast) {
  23765. return mergeChildren(ast, function (prevNode, node) {
  23766. return prevNode.type === "importExport" && node.type === "importExport";
  23767. }, function (prevNode, node) {
  23768. return {
  23769. type: "importExport",
  23770. value: prevNode.value + "\n\n" + node.value,
  23771. position: {
  23772. start: prevNode.position.start,
  23773. end: node.position.end
  23774. }
  23775. };
  23776. });
  23777. }
  23778. function mergeChildren(ast, shouldMerge, mergeNode) {
  23779. return mapAst$1(ast, function (node) {
  23780. if (!node.children) {
  23781. return node;
  23782. }
  23783. var children = node.children.reduce(function (current, child) {
  23784. var lastChild = current[current.length - 1];
  23785. if (lastChild && shouldMerge(lastChild, child)) {
  23786. current.splice(-1, 1, mergeNode(lastChild, child));
  23787. } else {
  23788. current.push(child);
  23789. }
  23790. return current;
  23791. }, []);
  23792. return Object.assign({}, node, {
  23793. children: children
  23794. });
  23795. });
  23796. }
  23797. function mergeContinuousTexts(ast) {
  23798. return mergeChildren(ast, function (prevNode, node) {
  23799. return prevNode.type === "text" && node.type === "text";
  23800. }, function (prevNode, node) {
  23801. return {
  23802. type: "text",
  23803. value: prevNode.value + node.value,
  23804. position: {
  23805. start: prevNode.position.start,
  23806. end: node.position.end
  23807. }
  23808. };
  23809. });
  23810. }
  23811. function splitTextIntoSentences(ast, options) {
  23812. return mapAst$1(ast, function (node, index, _ref) {
  23813. var _ref2 = _slicedToArray(_ref, 1),
  23814. parentNode = _ref2[0];
  23815. if (node.type !== "text") {
  23816. return node;
  23817. }
  23818. var value = node.value;
  23819. if (parentNode.type === "paragraph") {
  23820. if (index === 0) {
  23821. value = value.trimLeft();
  23822. }
  23823. if (index === parentNode.children.length - 1) {
  23824. value = value.trimRight();
  23825. }
  23826. }
  23827. return {
  23828. type: "sentence",
  23829. position: node.position,
  23830. children: splitText$2(value, options)
  23831. };
  23832. });
  23833. }
  23834. function transformIndentedCodeblockAndMarkItsParentList(ast, options) {
  23835. return mapAst$1(ast, function (node, index, parentStack) {
  23836. if (node.type === "code") {
  23837. // the first char may point to `\n`, e.g. `\n\t\tbar`, just ignore it
  23838. var isIndented = /^\n?( {4,}|\t)/.test(options.originalText.slice(node.position.start.offset, node.position.end.offset));
  23839. node.isIndented = isIndented;
  23840. if (isIndented) {
  23841. for (var i = 0; i < parentStack.length; i++) {
  23842. var parent = parentStack[i]; // no need to check checked items
  23843. if (parent.hasIndentedCodeblock) {
  23844. break;
  23845. }
  23846. if (parent.type === "list") {
  23847. parent.hasIndentedCodeblock = true;
  23848. }
  23849. }
  23850. }
  23851. }
  23852. return node;
  23853. });
  23854. }
  23855. function markAlignedList(ast, options) {
  23856. return mapAst$1(ast, function (node, index, parentStack) {
  23857. if (node.type === "list" && node.children.length !== 0) {
  23858. // if one of its parents is not aligned, it's not possible to be aligned in sub-lists
  23859. for (var i = 0; i < parentStack.length; i++) {
  23860. var parent = parentStack[i];
  23861. if (parent.type === "list" && !parent.isAligned) {
  23862. node.isAligned = false;
  23863. return node;
  23864. }
  23865. }
  23866. node.isAligned = isAligned(node);
  23867. }
  23868. return node;
  23869. });
  23870. function getListItemStart(listItem) {
  23871. return listItem.children.length === 0 ? -1 : listItem.children[0].position.start.column - 1;
  23872. }
  23873. function isAligned(list) {
  23874. if (!list.ordered) {
  23875. /**
  23876. * - 123
  23877. * - 123
  23878. */
  23879. return true;
  23880. }
  23881. var _list$children = _slicedToArray(list.children, 2),
  23882. firstItem = _list$children[0],
  23883. secondItem = _list$children[1];
  23884. var firstInfo = getOrderedListItemInfo$2(firstItem, options.originalText);
  23885. if (firstInfo.leadingSpaces.length > 1) {
  23886. /**
  23887. * 1. 123
  23888. *
  23889. * 1. 123
  23890. * 1. 123
  23891. */
  23892. return true;
  23893. }
  23894. var firstStart = getListItemStart(firstItem);
  23895. if (firstStart === -1) {
  23896. /**
  23897. * 1.
  23898. *
  23899. * 1.
  23900. * 1.
  23901. */
  23902. return false;
  23903. }
  23904. if (list.children.length === 1) {
  23905. /**
  23906. * aligned:
  23907. *
  23908. * 11. 123
  23909. *
  23910. * not aligned:
  23911. *
  23912. * 1. 123
  23913. */
  23914. return firstStart % options.tabWidth === 0;
  23915. }
  23916. var secondStart = getListItemStart(secondItem);
  23917. if (firstStart !== secondStart) {
  23918. /**
  23919. * 11. 123
  23920. * 1. 123
  23921. *
  23922. * 1. 123
  23923. * 11. 123
  23924. */
  23925. return false;
  23926. }
  23927. if (firstStart % options.tabWidth === 0) {
  23928. /**
  23929. * 11. 123
  23930. * 12. 123
  23931. */
  23932. return true;
  23933. }
  23934. /**
  23935. * aligned:
  23936. *
  23937. * 11. 123
  23938. * 1. 123
  23939. *
  23940. * not aligned:
  23941. *
  23942. * 1. 123
  23943. * 2. 123
  23944. */
  23945. var secondInfo = getOrderedListItemInfo$2(secondItem, options.originalText);
  23946. return secondInfo.leadingSpaces.length > 1;
  23947. }
  23948. }
  23949. var preprocess_1$4 = preprocess$4;
  23950. var _require$$0$builders$8 = doc.builders;
  23951. var breakParent$4 = _require$$0$builders$8.breakParent;
  23952. var concat$15 = _require$$0$builders$8.concat;
  23953. var join$11 = _require$$0$builders$8.join;
  23954. var line$10 = _require$$0$builders$8.line;
  23955. var literalline$5 = _require$$0$builders$8.literalline;
  23956. var markAsRoot$3 = _require$$0$builders$8.markAsRoot;
  23957. var hardline$11 = _require$$0$builders$8.hardline;
  23958. var softline$7 = _require$$0$builders$8.softline;
  23959. var ifBreak$7 = _require$$0$builders$8.ifBreak;
  23960. var fill$5 = _require$$0$builders$8.fill;
  23961. var align$2 = _require$$0$builders$8.align;
  23962. var indent$9 = _require$$0$builders$8.indent;
  23963. var group$15 = _require$$0$builders$8.group;
  23964. var mapDoc$6 = doc.utils.mapDoc;
  23965. var printDocToString$2 = doc.printer.printDocToString;
  23966. var getFencedCodeBlockValue = utils$10.getFencedCodeBlockValue;
  23967. var getOrderedListItemInfo = utils$10.getOrderedListItemInfo;
  23968. var splitText = utils$10.splitText;
  23969. var punctuationPattern = utils$10.punctuationPattern;
  23970. var INLINE_NODE_TYPES = utils$10.INLINE_NODE_TYPES;
  23971. var INLINE_NODE_WRAPPER_TYPES = utils$10.INLINE_NODE_WRAPPER_TYPES;
  23972. var replaceEndOfLineWith$2 = util.replaceEndOfLineWith;
  23973. var TRAILING_HARDLINE_NODES = ["importExport"];
  23974. var SINGLE_LINE_NODE_TYPES = ["heading", "tableCell", "link"];
  23975. var SIBLING_NODE_TYPES = ["listItem", "definition", "footnoteDefinition"];
  23976. function genericPrint$5(path, options, print) {
  23977. var node = path.getValue();
  23978. if (shouldRemainTheSameContent(path)) {
  23979. return concat$15(splitText(options.originalText.slice(node.position.start.offset, node.position.end.offset), options).map(function (node) {
  23980. return node.type === "word" ? node.value : node.value === "" ? "" : printLine(path, node.value, options);
  23981. }));
  23982. }
  23983. switch (node.type) {
  23984. case "root":
  23985. if (node.children.length === 0) {
  23986. return "";
  23987. }
  23988. return concat$15([normalizeDoc(printRoot(path, options, print)), TRAILING_HARDLINE_NODES.indexOf(getLastDescendantNode(node).type) === -1 ? hardline$11 : ""]);
  23989. case "paragraph":
  23990. return printChildren$1(path, options, print, {
  23991. postprocessor: fill$5
  23992. });
  23993. case "sentence":
  23994. return printChildren$1(path, options, print);
  23995. case "word":
  23996. return node.value.replace(/[*$]/g, "\\$&") // escape all `*` and `$` (math)
  23997. .replace(new RegExp(["(^|".concat(punctuationPattern, ")(_+)"), "(_+)(".concat(punctuationPattern, "|$)")].join("|"), "g"), function (_, text1, underscore1, underscore2, text2) {
  23998. return (underscore1 ? "".concat(text1).concat(underscore1) : "".concat(underscore2).concat(text2)).replace(/_/g, "\\_");
  23999. });
  24000. // escape all `_` except concating with non-punctuation, e.g. `1_2_3` is not considered emphasis
  24001. case "whitespace":
  24002. {
  24003. var parentNode = path.getParentNode();
  24004. var index = parentNode.children.indexOf(node);
  24005. var nextNode = parentNode.children[index + 1];
  24006. var proseWrap = // leading char that may cause different syntax
  24007. nextNode && /^>|^([-+*]|#{1,6}|[0-9]+[.)])$/.test(nextNode.value) ? "never" : options.proseWrap;
  24008. return printLine(path, node.value, {
  24009. proseWrap: proseWrap
  24010. });
  24011. }
  24012. case "emphasis":
  24013. {
  24014. var _parentNode = path.getParentNode();
  24015. var _index = _parentNode.children.indexOf(node);
  24016. var prevNode = _parentNode.children[_index - 1];
  24017. var _nextNode = _parentNode.children[_index + 1];
  24018. var hasPrevOrNextWord = // `1*2*3` is considered emphais but `1_2_3` is not
  24019. 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;
  24020. var style = hasPrevOrNextWord || getAncestorNode$2(path, "emphasis") ? "*" : "_";
  24021. return concat$15([style, printChildren$1(path, options, print), style]);
  24022. }
  24023. case "strong":
  24024. return concat$15(["**", printChildren$1(path, options, print), "**"]);
  24025. case "delete":
  24026. return concat$15(["~~", printChildren$1(path, options, print), "~~"]);
  24027. case "inlineCode":
  24028. {
  24029. var backtickCount = util.getMinNotPresentContinuousCount(node.value, "`");
  24030. var _style = "`".repeat(backtickCount || 1);
  24031. var gap = backtickCount ? " " : "";
  24032. return concat$15([_style, gap, node.value, gap, _style]);
  24033. }
  24034. case "link":
  24035. switch (options.originalText[node.position.start.offset]) {
  24036. case "<":
  24037. {
  24038. var mailto = "mailto:";
  24039. var url = // <hello@example.com> is parsed as { url: "mailto:hello@example.com" }
  24040. 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;
  24041. return concat$15(["<", url, ">"]);
  24042. }
  24043. case "[":
  24044. return concat$15(["[", printChildren$1(path, options, print), "](", printUrl(node.url, ")"), printTitle(node.title, options), ")"]);
  24045. default:
  24046. return options.originalText.slice(node.position.start.offset, node.position.end.offset);
  24047. }
  24048. case "image":
  24049. return concat$15(["![", node.alt || "", "](", printUrl(node.url, ")"), printTitle(node.title, options), ")"]);
  24050. case "blockquote":
  24051. return concat$15(["> ", align$2("> ", printChildren$1(path, options, print))]);
  24052. case "heading":
  24053. return concat$15(["#".repeat(node.depth) + " ", printChildren$1(path, options, print)]);
  24054. case "code":
  24055. {
  24056. if (node.isIndented) {
  24057. // indented code block
  24058. var alignment = " ".repeat(4);
  24059. return align$2(alignment, concat$15([alignment, concat$15(replaceEndOfLineWith$2(node.value, hardline$11))]));
  24060. } // fenced code block
  24061. var styleUnit = options.__inJsTemplate ? "~" : "`";
  24062. var _style2 = styleUnit.repeat(Math.max(3, util.getMaxContinuousCount(node.value, styleUnit) + 1));
  24063. return concat$15([_style2, node.lang || "", hardline$11, concat$15(replaceEndOfLineWith$2(getFencedCodeBlockValue(node, options.originalText), hardline$11)), hardline$11, _style2]);
  24064. }
  24065. case "yaml":
  24066. case "toml":
  24067. return options.originalText.slice(node.position.start.offset, node.position.end.offset);
  24068. case "html":
  24069. {
  24070. var _parentNode2 = path.getParentNode();
  24071. var value = _parentNode2.type === "root" && util.getLast(_parentNode2.children) === node ? node.value.trimRight() : node.value;
  24072. var isHtmlComment = /^<!--[\s\S]*-->$/.test(value);
  24073. return concat$15(replaceEndOfLineWith$2(value, isHtmlComment ? hardline$11 : markAsRoot$3(literalline$5)));
  24074. }
  24075. case "list":
  24076. {
  24077. var nthSiblingIndex = getNthListSiblingIndex(node, path.getParentNode());
  24078. var isGitDiffFriendlyOrderedList = node.ordered && node.children.length > 1 && +getOrderedListItemInfo(node.children[1], options.originalText).numberText === 1;
  24079. return printChildren$1(path, options, print, {
  24080. processor: function processor(childPath, index) {
  24081. var prefix = getPrefix();
  24082. return concat$15([prefix, align$2(" ".repeat(prefix.length), printListItem(childPath, options, print, prefix))]);
  24083. function getPrefix() {
  24084. var rawPrefix = node.ordered ? (index === 0 ? node.start : isGitDiffFriendlyOrderedList ? 1 : node.start + index) + (nthSiblingIndex % 2 === 0 ? ". " : ") ") : nthSiblingIndex % 2 === 0 ? "- " : "* ";
  24085. return node.isAligned ||
  24086. /* workaround for https://github.com/remarkjs/remark/issues/315 */
  24087. node.hasIndentedCodeblock ? alignListPrefix(rawPrefix, options) : rawPrefix;
  24088. }
  24089. }
  24090. });
  24091. }
  24092. case "thematicBreak":
  24093. {
  24094. var counter = getAncestorCounter$1(path, "list");
  24095. if (counter === -1) {
  24096. return "---";
  24097. }
  24098. var _nthSiblingIndex = getNthListSiblingIndex(path.getParentNode(counter), path.getParentNode(counter + 1));
  24099. return _nthSiblingIndex % 2 === 0 ? "***" : "---";
  24100. }
  24101. case "linkReference":
  24102. return concat$15(["[", printChildren$1(path, options, print), "]", node.referenceType === "full" ? concat$15(["[", node.identifier, "]"]) : node.referenceType === "collapsed" ? "[]" : ""]);
  24103. case "imageReference":
  24104. switch (node.referenceType) {
  24105. case "full":
  24106. return concat$15(["![", node.alt || "", "][", node.identifier, "]"]);
  24107. default:
  24108. return concat$15(["![", node.alt, "]", node.referenceType === "collapsed" ? "[]" : ""]);
  24109. }
  24110. case "definition":
  24111. {
  24112. var lineOrSpace = options.proseWrap === "always" ? line$10 : " ";
  24113. 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)])]))]));
  24114. }
  24115. case "footnote":
  24116. return concat$15(["[^", printChildren$1(path, options, print), "]"]);
  24117. case "footnoteReference":
  24118. return concat$15(["[^", node.identifier, "]"]);
  24119. case "footnoteDefinition":
  24120. {
  24121. var _nextNode2 = path.getParentNode().children[path.getName() + 1];
  24122. 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);
  24123. 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, {
  24124. processor: function processor(childPath, index) {
  24125. return index === 0 ? group$15(concat$15([softline$7, softline$7, childPath.call(print)])) : childPath.call(print);
  24126. }
  24127. })), _nextNode2 && _nextNode2.type === "footnoteDefinition" ? softline$7 : ""]))]);
  24128. }
  24129. case "table":
  24130. return printTable(path, options, print);
  24131. case "tableCell":
  24132. return printChildren$1(path, options, print);
  24133. case "break":
  24134. return /\s/.test(options.originalText[node.position.start.offset]) ? concat$15([" ", markAsRoot$3(literalline$5)]) : concat$15(["\\", hardline$11]);
  24135. case "liquidNode":
  24136. return concat$15(replaceEndOfLineWith$2(node.value, hardline$11));
  24137. // MDX
  24138. case "importExport":
  24139. case "jsx":
  24140. return node.value;
  24141. // fallback to the original text if multiparser failed
  24142. case "math":
  24143. return concat$15(["$$", hardline$11, node.value ? concat$15([concat$15(replaceEndOfLineWith$2(node.value, hardline$11)), hardline$11]) : "", "$$"]);
  24144. case "inlineMath":
  24145. {
  24146. // remark-math trims content but we don't want to remove whitespaces
  24147. // since it's very possible that it's recognized as math accidentally
  24148. return options.originalText.slice(options.locStart(node), options.locEnd(node));
  24149. }
  24150. case "tableRow": // handled in "table"
  24151. case "listItem": // handled in "list"
  24152. default:
  24153. throw new Error("Unknown markdown type ".concat(JSON.stringify(node.type)));
  24154. }
  24155. }
  24156. function printListItem(path, options, print, listPrefix) {
  24157. var node = path.getValue();
  24158. var prefix = node.checked === null ? "" : node.checked ? "[x] " : "[ ] ";
  24159. return concat$15([prefix, printChildren$1(path, options, print, {
  24160. processor: function processor(childPath, index) {
  24161. if (index === 0 && childPath.getValue().type !== "list") {
  24162. return align$2(" ".repeat(prefix.length), childPath.call(print));
  24163. }
  24164. var alignment = " ".repeat(clamp(options.tabWidth - listPrefix.length, 0, 3) // 4+ will cause indented code block
  24165. );
  24166. return concat$15([alignment, align$2(alignment, childPath.call(print))]);
  24167. }
  24168. })]);
  24169. }
  24170. function alignListPrefix(prefix, options) {
  24171. var additionalSpaces = getAdditionalSpaces();
  24172. return prefix + " ".repeat(additionalSpaces >= 4 ? 0 : additionalSpaces // 4+ will cause indented code block
  24173. );
  24174. function getAdditionalSpaces() {
  24175. var restSpaces = prefix.length % options.tabWidth;
  24176. return restSpaces === 0 ? 0 : options.tabWidth - restSpaces;
  24177. }
  24178. }
  24179. function getNthListSiblingIndex(node, parentNode) {
  24180. return getNthSiblingIndex(node, parentNode, function (siblingNode) {
  24181. return siblingNode.ordered === node.ordered;
  24182. });
  24183. }
  24184. function getNthSiblingIndex(node, parentNode, condition) {
  24185. condition = condition || function () {
  24186. return true;
  24187. };
  24188. var index = -1;
  24189. var _iteratorNormalCompletion = true;
  24190. var _didIteratorError = false;
  24191. var _iteratorError = undefined;
  24192. try {
  24193. for (var _iterator = parentNode.children[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  24194. var childNode = _step.value;
  24195. if (childNode.type === node.type && condition(childNode)) {
  24196. index++;
  24197. } else {
  24198. index = -1;
  24199. }
  24200. if (childNode === node) {
  24201. return index;
  24202. }
  24203. }
  24204. } catch (err) {
  24205. _didIteratorError = true;
  24206. _iteratorError = err;
  24207. } finally {
  24208. try {
  24209. if (!_iteratorNormalCompletion && _iterator.return != null) {
  24210. _iterator.return();
  24211. }
  24212. } finally {
  24213. if (_didIteratorError) {
  24214. throw _iteratorError;
  24215. }
  24216. }
  24217. }
  24218. }
  24219. function getAncestorCounter$1(path, typeOrTypes) {
  24220. var types = [].concat(typeOrTypes);
  24221. var counter = -1;
  24222. var ancestorNode;
  24223. while (ancestorNode = path.getParentNode(++counter)) {
  24224. if (types.indexOf(ancestorNode.type) !== -1) {
  24225. return counter;
  24226. }
  24227. }
  24228. return -1;
  24229. }
  24230. function getAncestorNode$2(path, typeOrTypes) {
  24231. var counter = getAncestorCounter$1(path, typeOrTypes);
  24232. return counter === -1 ? null : path.getParentNode(counter);
  24233. }
  24234. function printLine(path, value, options) {
  24235. if (options.proseWrap === "preserve" && value === "\n") {
  24236. return hardline$11;
  24237. }
  24238. var isBreakable = options.proseWrap === "always" && !getAncestorNode$2(path, SINGLE_LINE_NODE_TYPES);
  24239. return value !== "" ? isBreakable ? line$10 : " " : isBreakable ? softline$7 : "";
  24240. }
  24241. function printTable(path, options, print) {
  24242. var hardlineWithoutBreakParent = hardline$11.parts[0];
  24243. var node = path.getValue();
  24244. var contents = []; // { [rowIndex: number]: { [columnIndex: number]: string } }
  24245. path.map(function (rowPath) {
  24246. var rowContents = [];
  24247. rowPath.map(function (cellPath) {
  24248. rowContents.push(printDocToString$2(cellPath.call(print), options).formatted);
  24249. }, "children");
  24250. contents.push(rowContents);
  24251. }, "children"); // Get the width of each column
  24252. var columnMaxWidths = contents.reduce(function (currentWidths, rowContents) {
  24253. return currentWidths.map(function (width, columnIndex) {
  24254. return Math.max(width, util.getStringWidth(rowContents[columnIndex]));
  24255. });
  24256. }, contents[0].map(function () {
  24257. return 3;
  24258. }) // minimum width = 3 (---, :--, :-:, --:)
  24259. );
  24260. var alignedTable = join$11(hardlineWithoutBreakParent, [printRow(contents[0]), printSeparator(), join$11(hardlineWithoutBreakParent, contents.slice(1).map(function (rowContents) {
  24261. return printRow(rowContents);
  24262. }))]);
  24263. if (options.proseWrap !== "never") {
  24264. return concat$15([breakParent$4, alignedTable]);
  24265. } // Only if the --prose-wrap never is set and it exceeds the print width.
  24266. var compactTable = join$11(hardlineWithoutBreakParent, [printRow(contents[0],
  24267. /* isCompact */
  24268. true), printSeparator(
  24269. /* isCompact */
  24270. true), join$11(hardlineWithoutBreakParent, contents.slice(1).map(function (rowContents) {
  24271. return printRow(rowContents,
  24272. /* isCompact */
  24273. true);
  24274. }))]);
  24275. return concat$15([breakParent$4, group$15(ifBreak$7(compactTable, alignedTable))]);
  24276. function printSeparator(isCompact) {
  24277. return concat$15(["| ", join$11(" | ", columnMaxWidths.map(function (width, index) {
  24278. var spaces = isCompact ? 3 : width;
  24279. switch (node.align[index]) {
  24280. case "left":
  24281. return ":" + "-".repeat(spaces - 1);
  24282. case "right":
  24283. return "-".repeat(spaces - 1) + ":";
  24284. case "center":
  24285. return ":" + "-".repeat(spaces - 2) + ":";
  24286. default:
  24287. return "-".repeat(spaces);
  24288. }
  24289. })), " |"]);
  24290. }
  24291. function printRow(rowContents, isCompact) {
  24292. return concat$15(["| ", join$11(" | ", isCompact ? rowContents : rowContents.map(function (rowContent, columnIndex) {
  24293. switch (node.align[columnIndex]) {
  24294. case "right":
  24295. return alignRight(rowContent, columnMaxWidths[columnIndex]);
  24296. case "center":
  24297. return alignCenter(rowContent, columnMaxWidths[columnIndex]);
  24298. default:
  24299. return alignLeft(rowContent, columnMaxWidths[columnIndex]);
  24300. }
  24301. })), " |"]);
  24302. }
  24303. function alignLeft(text, width) {
  24304. var spaces = width - util.getStringWidth(text);
  24305. return concat$15([text, " ".repeat(spaces)]);
  24306. }
  24307. function alignRight(text, width) {
  24308. var spaces = width - util.getStringWidth(text);
  24309. return concat$15([" ".repeat(spaces), text]);
  24310. }
  24311. function alignCenter(text, width) {
  24312. var spaces = width - util.getStringWidth(text);
  24313. var left = Math.floor(spaces / 2);
  24314. var right = spaces - left;
  24315. return concat$15([" ".repeat(left), text, " ".repeat(right)]);
  24316. }
  24317. }
  24318. function printRoot(path, options, print) {
  24319. /** @typedef {{ index: number, offset: number }} IgnorePosition */
  24320. /** @type {Array<{start: IgnorePosition, end: IgnorePosition}>} */
  24321. var ignoreRanges = [];
  24322. /** @type {IgnorePosition | null} */
  24323. var ignoreStart = null;
  24324. var children = path.getValue().children;
  24325. children.forEach(function (childNode, index) {
  24326. switch (isPrettierIgnore$1(childNode)) {
  24327. case "start":
  24328. if (ignoreStart === null) {
  24329. ignoreStart = {
  24330. index: index,
  24331. offset: childNode.position.end.offset
  24332. };
  24333. }
  24334. break;
  24335. case "end":
  24336. if (ignoreStart !== null) {
  24337. ignoreRanges.push({
  24338. start: ignoreStart,
  24339. end: {
  24340. index: index,
  24341. offset: childNode.position.start.offset
  24342. }
  24343. });
  24344. ignoreStart = null;
  24345. }
  24346. break;
  24347. default:
  24348. // do nothing
  24349. break;
  24350. }
  24351. });
  24352. return printChildren$1(path, options, print, {
  24353. processor: function processor(childPath, index) {
  24354. if (ignoreRanges.length !== 0) {
  24355. var ignoreRange = ignoreRanges[0];
  24356. if (index === ignoreRange.start.index) {
  24357. return concat$15([children[ignoreRange.start.index].value, options.originalText.slice(ignoreRange.start.offset, ignoreRange.end.offset), children[ignoreRange.end.index].value]);
  24358. }
  24359. if (ignoreRange.start.index < index && index < ignoreRange.end.index) {
  24360. return false;
  24361. }
  24362. if (index === ignoreRange.end.index) {
  24363. ignoreRanges.shift();
  24364. return false;
  24365. }
  24366. }
  24367. return childPath.call(print);
  24368. }
  24369. });
  24370. }
  24371. function printChildren$1(path, options, print, events) {
  24372. events = events || {};
  24373. var postprocessor = events.postprocessor || concat$15;
  24374. var processor = events.processor || function (childPath) {
  24375. return childPath.call(print);
  24376. };
  24377. var node = path.getValue();
  24378. var parts = [];
  24379. var lastChildNode;
  24380. path.map(function (childPath, index) {
  24381. var childNode = childPath.getValue();
  24382. var result = processor(childPath, index);
  24383. if (result !== false) {
  24384. var data = {
  24385. parts: parts,
  24386. prevNode: lastChildNode,
  24387. parentNode: node,
  24388. options: options
  24389. };
  24390. if (!shouldNotPrePrintHardline(childNode, data)) {
  24391. parts.push(hardline$11);
  24392. if (lastChildNode && TRAILING_HARDLINE_NODES.indexOf(lastChildNode.type) !== -1) {
  24393. if (shouldPrePrintTripleHardline(childNode, data)) {
  24394. parts.push(hardline$11);
  24395. }
  24396. } else {
  24397. if (shouldPrePrintDoubleHardline(childNode, data) || shouldPrePrintTripleHardline(childNode, data)) {
  24398. parts.push(hardline$11);
  24399. }
  24400. if (shouldPrePrintTripleHardline(childNode, data)) {
  24401. parts.push(hardline$11);
  24402. }
  24403. }
  24404. }
  24405. parts.push(result);
  24406. lastChildNode = childNode;
  24407. }
  24408. }, "children");
  24409. return postprocessor(parts);
  24410. }
  24411. function getLastDescendantNode(node) {
  24412. var current = node;
  24413. while (current.children && current.children.length !== 0) {
  24414. current = current.children[current.children.length - 1];
  24415. }
  24416. return current;
  24417. }
  24418. /** @return {false | 'next' | 'start' | 'end'} */
  24419. function isPrettierIgnore$1(node) {
  24420. if (node.type !== "html") {
  24421. return false;
  24422. }
  24423. var match = node.value.match(/^<!--\s*prettier-ignore(?:-(start|end))?\s*-->$/);
  24424. return match === null ? false : match[1] ? match[1] : "next";
  24425. }
  24426. function shouldNotPrePrintHardline(node, data) {
  24427. var isFirstNode = data.parts.length === 0;
  24428. var isInlineNode = INLINE_NODE_TYPES.indexOf(node.type) !== -1;
  24429. var isInlineHTML = node.type === "html" && INLINE_NODE_WRAPPER_TYPES.indexOf(data.parentNode.type) !== -1;
  24430. return isFirstNode || isInlineNode || isInlineHTML;
  24431. }
  24432. function shouldPrePrintDoubleHardline(node, data) {
  24433. var isSequence = (data.prevNode && data.prevNode.type) === node.type;
  24434. var isSiblingNode = isSequence && SIBLING_NODE_TYPES.indexOf(node.type) !== -1;
  24435. var isInTightListItem = data.parentNode.type === "listItem" && !data.parentNode.loose;
  24436. var isPrevNodeLooseListItem = data.prevNode && data.prevNode.type === "listItem" && data.prevNode.loose;
  24437. var isPrevNodePrettierIgnore = isPrettierIgnore$1(data.prevNode) === "next";
  24438. var isBlockHtmlWithoutBlankLineBetweenPrevHtml = node.type === "html" && data.prevNode && data.prevNode.type === "html" && data.prevNode.position.end.line + 1 === node.position.start.line;
  24439. return isPrevNodeLooseListItem || !(isSiblingNode || isInTightListItem || isPrevNodePrettierIgnore || isBlockHtmlWithoutBlankLineBetweenPrevHtml);
  24440. }
  24441. function shouldPrePrintTripleHardline(node, data) {
  24442. var isPrevNodeList = data.prevNode && data.prevNode.type === "list";
  24443. var isIndentedCode = node.type === "code" && node.isIndented;
  24444. return isPrevNodeList && isIndentedCode;
  24445. }
  24446. function shouldRemainTheSameContent(path) {
  24447. var ancestorNode = getAncestorNode$2(path, ["linkReference", "imageReference"]);
  24448. return ancestorNode && (ancestorNode.type !== "linkReference" || ancestorNode.referenceType !== "full");
  24449. }
  24450. function normalizeDoc(doc$$2) {
  24451. return mapDoc$6(doc$$2, function (currentDoc) {
  24452. if (!currentDoc.parts) {
  24453. return currentDoc;
  24454. }
  24455. if (currentDoc.type === "concat" && currentDoc.parts.length === 1) {
  24456. return currentDoc.parts[0];
  24457. }
  24458. var parts = [];
  24459. currentDoc.parts.forEach(function (part) {
  24460. if (part.type === "concat") {
  24461. parts.push.apply(parts, part.parts);
  24462. } else if (part !== "") {
  24463. parts.push(part);
  24464. }
  24465. });
  24466. return Object.assign({}, currentDoc, {
  24467. parts: normalizeParts$2(parts)
  24468. });
  24469. });
  24470. }
  24471. function printUrl(url, dangerousCharOrChars) {
  24472. var dangerousChars = [" "].concat(dangerousCharOrChars || []);
  24473. return new RegExp(dangerousChars.map(function (x) {
  24474. return "\\".concat(x);
  24475. }).join("|")).test(url) ? "<".concat(url, ">") : url;
  24476. }
  24477. function printTitle(title, options, printSpace) {
  24478. if (printSpace == null) {
  24479. printSpace = true;
  24480. }
  24481. if (!title) {
  24482. return "";
  24483. }
  24484. if (printSpace) {
  24485. return " " + printTitle(title, options, false);
  24486. }
  24487. if (title.includes('"') && title.includes("'") && !title.includes(")")) {
  24488. return "(".concat(title, ")"); // avoid escaped quotes
  24489. } // faster than using RegExps: https://jsperf.com/performance-of-match-vs-split
  24490. var singleCount = title.split("'").length - 1;
  24491. var doubleCount = title.split('"').length - 1;
  24492. var quote = singleCount > doubleCount ? '"' : doubleCount > singleCount ? "'" : options.singleQuote ? "'" : '"';
  24493. title = title.replace(new RegExp("(".concat(quote, ")"), "g"), "\\$1");
  24494. return "".concat(quote).concat(title).concat(quote);
  24495. }
  24496. function normalizeParts$2(parts) {
  24497. return parts.reduce(function (current, part) {
  24498. var lastPart = util.getLast(current);
  24499. if (typeof lastPart === "string" && typeof part === "string") {
  24500. current.splice(-1, 1, lastPart + part);
  24501. } else {
  24502. current.push(part);
  24503. }
  24504. return current;
  24505. }, []);
  24506. }
  24507. function clamp(value, min, max) {
  24508. return value < min ? min : value > max ? max : value;
  24509. }
  24510. function clean$10(ast, newObj, parent) {
  24511. delete newObj.position;
  24512. delete newObj.raw; // front-matter
  24513. // for codeblock
  24514. if (ast.type === "code" || ast.type === "yaml" || ast.type === "import" || ast.type === "export" || ast.type === "jsx") {
  24515. delete newObj.value;
  24516. }
  24517. if (ast.type === "list") {
  24518. delete newObj.isAligned;
  24519. } // texts can be splitted or merged
  24520. if (ast.type === "text") {
  24521. return null;
  24522. }
  24523. if (ast.type === "inlineCode") {
  24524. newObj.value = ast.value.replace(/[ \t\n]+/g, " ");
  24525. } // for insert pragma
  24526. 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)) {
  24527. return null;
  24528. }
  24529. }
  24530. function hasPrettierIgnore$3(path) {
  24531. var index = +path.getName();
  24532. if (index === 0) {
  24533. return false;
  24534. }
  24535. var prevNode = path.getParentNode().children[index - 1];
  24536. return isPrettierIgnore$1(prevNode) === "next";
  24537. }
  24538. var printerMarkdown = {
  24539. preprocess: preprocess_1$4,
  24540. print: genericPrint$5,
  24541. embed: embed_1$4,
  24542. massageAstNode: clean$10,
  24543. hasPrettierIgnore: hasPrettierIgnore$3,
  24544. insertPragma: pragma$8.insertPragma
  24545. };
  24546. var options$15 = {
  24547. proseWrap: commonOptions.proseWrap,
  24548. singleQuote: commonOptions.singleQuote
  24549. };
  24550. var name$15 = "Markdown";
  24551. var type$14 = "prose";
  24552. var aliases$5 = ["pandoc"];
  24553. var aceMode$14 = "markdown";
  24554. var codemirrorMode$10 = "gfm";
  24555. var codemirrorMimeType$10 = "text/x-gfm";
  24556. var wrap = true;
  24557. var extensions$14 = [".md", ".markdown", ".mdown", ".mdwn", ".mkd", ".mkdn", ".mkdown", ".ronn", ".workbook"];
  24558. var tmScope$14 = "source.gfm";
  24559. var languageId$14 = 222;
  24560. var markdown = {
  24561. name: name$15,
  24562. type: type$14,
  24563. aliases: aliases$5,
  24564. aceMode: aceMode$14,
  24565. codemirrorMode: codemirrorMode$10,
  24566. codemirrorMimeType: codemirrorMimeType$10,
  24567. wrap: wrap,
  24568. extensions: extensions$14,
  24569. tmScope: tmScope$14,
  24570. languageId: languageId$14
  24571. };
  24572. var markdown$1 = Object.freeze({
  24573. name: name$15,
  24574. type: type$14,
  24575. aliases: aliases$5,
  24576. aceMode: aceMode$14,
  24577. codemirrorMode: codemirrorMode$10,
  24578. codemirrorMimeType: codemirrorMimeType$10,
  24579. wrap: wrap,
  24580. extensions: extensions$14,
  24581. tmScope: tmScope$14,
  24582. languageId: languageId$14,
  24583. default: markdown
  24584. });
  24585. var require$$0$27 = ( markdown$1 && markdown ) || markdown$1;
  24586. var languages$5 = [createLanguage(require$$0$27, {
  24587. override: {
  24588. since: "1.8.0",
  24589. parsers: ["remark"],
  24590. vscodeLanguageIds: ["markdown"]
  24591. },
  24592. extend: {
  24593. filenames: ["README"]
  24594. }
  24595. }), createLanguage({
  24596. name: "MDX",
  24597. extensions: [".mdx"]
  24598. }, // TODO: use linguist data
  24599. {
  24600. override: {
  24601. since: "1.15.0",
  24602. parsers: ["mdx"],
  24603. vscodeLanguageIds: ["mdx"]
  24604. }
  24605. })];
  24606. var printers$5 = {
  24607. mdast: printerMarkdown
  24608. };
  24609. var languageMarkdown = {
  24610. languages: languages$5,
  24611. options: options$15,
  24612. printers: printers$5
  24613. };
  24614. function isPragma$1(text) {
  24615. return /^\s*@(prettier|format)\s*$/.test(text);
  24616. }
  24617. function hasPragma$4(text) {
  24618. return /^\s*#[^\n\S]*@(prettier|format)\s*?(\n|$)/.test(text);
  24619. }
  24620. function insertPragma$9(text) {
  24621. return "# @format\n\n".concat(text);
  24622. }
  24623. var pragma$11 = {
  24624. isPragma: isPragma$1,
  24625. hasPragma: hasPragma$4,
  24626. insertPragma: insertPragma$9
  24627. };
  24628. var getLast$6 = util.getLast;
  24629. function getAncestorCount$1(path, filter) {
  24630. var counter = 0;
  24631. var pathStackLength = path.stack.length - 1;
  24632. for (var i = 0; i < pathStackLength; i++) {
  24633. var value = path.stack[i];
  24634. if (isNode$1(value) && filter(value)) {
  24635. counter++;
  24636. }
  24637. }
  24638. return counter;
  24639. }
  24640. /**
  24641. * @param {any} value
  24642. * @param {string[]=} types
  24643. */
  24644. function isNode$1(value, types) {
  24645. return value && typeof value.type === "string" && (!types || types.indexOf(value.type) !== -1);
  24646. }
  24647. function mapNode$1(node, callback, parent) {
  24648. return callback("children" in node ? Object.assign({}, node, {
  24649. children: node.children.map(function (childNode) {
  24650. return mapNode$1(childNode, callback, node);
  24651. })
  24652. }) : node, parent);
  24653. }
  24654. function defineShortcut$1(x, key, getter) {
  24655. Object.defineProperty(x, key, {
  24656. get: getter,
  24657. enumerable: false
  24658. });
  24659. }
  24660. function isNextLineEmpty$6(node, text) {
  24661. var newlineCount = 0;
  24662. var textLength = text.length;
  24663. for (var i = node.position.end.offset - 1; i < textLength; i++) {
  24664. var char = text[i];
  24665. if (char === "\n") {
  24666. newlineCount++;
  24667. }
  24668. if (newlineCount === 1 && /\S/.test(char)) {
  24669. return false;
  24670. }
  24671. if (newlineCount === 2) {
  24672. return true;
  24673. }
  24674. }
  24675. return false;
  24676. }
  24677. function isLastDescendantNode$1(path) {
  24678. var node = path.getValue();
  24679. switch (node.type) {
  24680. case "tag":
  24681. case "anchor":
  24682. case "comment":
  24683. return false;
  24684. }
  24685. var pathStackLength = path.stack.length;
  24686. for (var i = 1; i < pathStackLength; i++) {
  24687. var item = path.stack[i];
  24688. var parentItem = path.stack[i - 1];
  24689. if (Array.isArray(parentItem) && typeof item === "number" && item !== parentItem.length - 1) {
  24690. return false;
  24691. }
  24692. }
  24693. return true;
  24694. }
  24695. function getLastDescendantNode$2(node) {
  24696. return "children" in node && node.children.length !== 0 ? getLastDescendantNode$2(getLast$6(node.children)) : node;
  24697. }
  24698. function isPrettierIgnore$2(comment) {
  24699. return comment.value.trim() === "prettier-ignore";
  24700. }
  24701. function hasPrettierIgnore$5(path) {
  24702. var node = path.getValue();
  24703. if (node.type === "documentBody") {
  24704. var document = path.getParentNode();
  24705. return hasEndComments$1(document.head) && isPrettierIgnore$2(getLast$6(document.head.endComments));
  24706. }
  24707. return hasLeadingComments$1(node) && isPrettierIgnore$2(getLast$6(node.leadingComments));
  24708. }
  24709. function isEmptyNode$1(node) {
  24710. return (!node.children || node.children.length === 0) && !hasComments(node);
  24711. }
  24712. function hasComments(node) {
  24713. return hasLeadingComments$1(node) || hasMiddleComments$1(node) || hasIndicatorComment$1(node) || hasTrailingComment$2(node) || hasEndComments$1(node);
  24714. }
  24715. function hasLeadingComments$1(node) {
  24716. return node && node.leadingComments && node.leadingComments.length !== 0;
  24717. }
  24718. function hasMiddleComments$1(node) {
  24719. return node && node.middleComments && node.middleComments.length !== 0;
  24720. }
  24721. function hasIndicatorComment$1(node) {
  24722. return node && node.indicatorComment;
  24723. }
  24724. function hasTrailingComment$2(node) {
  24725. return node && node.trailingComment;
  24726. }
  24727. function hasEndComments$1(node) {
  24728. return node && node.endComments && node.endComments.length !== 0;
  24729. }
  24730. /**
  24731. * " a b c d e f " -> [" a b", "c d", "e f "]
  24732. */
  24733. function splitWithSingleSpace(text) {
  24734. var parts = [];
  24735. var lastPart = undefined;
  24736. var _iteratorNormalCompletion = true;
  24737. var _didIteratorError = false;
  24738. var _iteratorError = undefined;
  24739. try {
  24740. for (var _iterator = text.split(/( +)/g)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  24741. var part = _step.value;
  24742. if (part !== " ") {
  24743. if (lastPart === " ") {
  24744. parts.push(part);
  24745. } else {
  24746. parts.push((parts.pop() || "") + part);
  24747. }
  24748. } else if (lastPart === undefined) {
  24749. parts.unshift("");
  24750. }
  24751. lastPart = part;
  24752. }
  24753. } catch (err) {
  24754. _didIteratorError = true;
  24755. _iteratorError = err;
  24756. } finally {
  24757. try {
  24758. if (!_iteratorNormalCompletion && _iterator.return != null) {
  24759. _iterator.return();
  24760. }
  24761. } finally {
  24762. if (_didIteratorError) {
  24763. throw _iteratorError;
  24764. }
  24765. }
  24766. }
  24767. if (lastPart === " ") {
  24768. parts.push((parts.pop() || "") + " ");
  24769. }
  24770. if (parts[0] === "") {
  24771. parts.shift();
  24772. parts.unshift(" " + (parts.shift() || ""));
  24773. }
  24774. return parts;
  24775. }
  24776. function getFlowScalarLineContents$1(nodeType, content, options) {
  24777. var rawLineContents = content.split("\n").map(function (lineContent, index, lineContents) {
  24778. return index === 0 && index === lineContents.length - 1 ? lineContent : index !== 0 && index !== lineContents.length - 1 ? lineContent.trim() : index === 0 ? lineContent.trimRight() : lineContent.trimLeft();
  24779. });
  24780. if (options.proseWrap === "preserve") {
  24781. return rawLineContents.map(function (lineContent) {
  24782. return lineContent.length === 0 ? [] : [lineContent];
  24783. });
  24784. }
  24785. return rawLineContents.map(function (lineContent) {
  24786. return lineContent.length === 0 ? [] : splitWithSingleSpace(lineContent);
  24787. }).reduce(function (reduced, lineContentWords, index) {
  24788. return index !== 0 && rawLineContents[index - 1].length !== 0 && lineContentWords.length !== 0 && !( // trailing backslash in quoteDouble should be preserved
  24789. nodeType === "quoteDouble" && getLast$6(getLast$6(reduced)).endsWith("\\")) ? reduced.concat([reduced.pop().concat(lineContentWords)]) : reduced.concat([lineContentWords]);
  24790. }, []).map(function (lineContentWords) {
  24791. return options.proseWrap === "never" ? [lineContentWords.join(" ")] : lineContentWords;
  24792. });
  24793. }
  24794. function getBlockValueLineContents$1(node, _ref) {
  24795. var parentIndent = _ref.parentIndent,
  24796. isLastDescendant = _ref.isLastDescendant,
  24797. options = _ref.options;
  24798. 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 `|`
  24799. .match(/^[^\n]*?\n([\s\S]*)$/)[1];
  24800. var leadingSpaceCount = node.indent === null ? function (match) {
  24801. return match ? match[1].length : Infinity;
  24802. }(content.match(/^( *)\S/m)) : node.indent - 1 + parentIndent;
  24803. var rawLineContents = content.split("\n").map(function (lineContent) {
  24804. return lineContent.slice(leadingSpaceCount);
  24805. });
  24806. if (options.proseWrap === "preserve" || node.type === "blockLiteral") {
  24807. return removeUnnecessaryTrailingNewlines(rawLineContents.map(function (lineContent) {
  24808. return lineContent.length === 0 ? [] : [lineContent];
  24809. }));
  24810. }
  24811. return removeUnnecessaryTrailingNewlines(rawLineContents.map(function (lineContent) {
  24812. return lineContent.length === 0 ? [] : splitWithSingleSpace(lineContent);
  24813. }).reduce(function (reduced, lineContentWords, index) {
  24814. return index !== 0 && rawLineContents[index - 1].length !== 0 && lineContentWords.length !== 0 && !/^\s/.test(lineContentWords[0]) && !/^\s|\s$/.test(getLast$6(reduced)) ? reduced.concat([reduced.pop().concat(lineContentWords)]) : reduced.concat([lineContentWords]);
  24815. }, []).map(function (lineContentWords) {
  24816. return lineContentWords.reduce(function (reduced, word) {
  24817. return (// disallow trailing spaces
  24818. reduced.length !== 0 && /\s$/.test(getLast$6(reduced)) ? reduced.concat(reduced.pop() + " " + word) : reduced.concat(word)
  24819. );
  24820. }, []);
  24821. }).map(function (lineContentWords) {
  24822. return options.proseWrap === "never" ? [lineContentWords.join(" ")] : lineContentWords;
  24823. }));
  24824. function removeUnnecessaryTrailingNewlines(lineContents) {
  24825. if (node.chomping === "keep") {
  24826. return getLast$6(lineContents).length === 0 ? lineContents.slice(0, -1) : lineContents;
  24827. }
  24828. var trailingNewlineCount = 0;
  24829. for (var i = lineContents.length - 1; i >= 0; i--) {
  24830. if (lineContents[i].length === 0) {
  24831. trailingNewlineCount++;
  24832. } else {
  24833. break;
  24834. }
  24835. }
  24836. return trailingNewlineCount === 0 ? lineContents : trailingNewlineCount >= 2 && !isLastDescendant ? // next empty line
  24837. lineContents.slice(0, -(trailingNewlineCount - 1)) : lineContents.slice(0, -trailingNewlineCount);
  24838. }
  24839. }
  24840. var utils$12 = {
  24841. getLast: getLast$6,
  24842. getAncestorCount: getAncestorCount$1,
  24843. isNode: isNode$1,
  24844. isEmptyNode: isEmptyNode$1,
  24845. mapNode: mapNode$1,
  24846. defineShortcut: defineShortcut$1,
  24847. isNextLineEmpty: isNextLineEmpty$6,
  24848. isLastDescendantNode: isLastDescendantNode$1,
  24849. getBlockValueLineContents: getBlockValueLineContents$1,
  24850. getFlowScalarLineContents: getFlowScalarLineContents$1,
  24851. getLastDescendantNode: getLastDescendantNode$2,
  24852. hasPrettierIgnore: hasPrettierIgnore$5,
  24853. hasLeadingComments: hasLeadingComments$1,
  24854. hasMiddleComments: hasMiddleComments$1,
  24855. hasIndicatorComment: hasIndicatorComment$1,
  24856. hasTrailingComment: hasTrailingComment$2,
  24857. hasEndComments: hasEndComments$1
  24858. };
  24859. var insertPragma$8 = pragma$11.insertPragma;
  24860. var isPragma = pragma$11.isPragma;
  24861. var getAncestorCount = utils$12.getAncestorCount;
  24862. var getBlockValueLineContents = utils$12.getBlockValueLineContents;
  24863. var getFlowScalarLineContents = utils$12.getFlowScalarLineContents;
  24864. var getLast$5 = utils$12.getLast;
  24865. var getLastDescendantNode$1 = utils$12.getLastDescendantNode;
  24866. var hasLeadingComments = utils$12.hasLeadingComments;
  24867. var hasMiddleComments = utils$12.hasMiddleComments;
  24868. var hasIndicatorComment = utils$12.hasIndicatorComment;
  24869. var hasTrailingComment$1 = utils$12.hasTrailingComment;
  24870. var hasEndComments = utils$12.hasEndComments;
  24871. var hasPrettierIgnore$4 = utils$12.hasPrettierIgnore;
  24872. var isLastDescendantNode = utils$12.isLastDescendantNode;
  24873. var isNextLineEmpty$5 = utils$12.isNextLineEmpty;
  24874. var isNode = utils$12.isNode;
  24875. var isEmptyNode = utils$12.isEmptyNode;
  24876. var defineShortcut = utils$12.defineShortcut;
  24877. var mapNode = utils$12.mapNode;
  24878. var docBuilders$3 = doc.builders;
  24879. var conditionalGroup$2 = docBuilders$3.conditionalGroup;
  24880. var breakParent$5 = docBuilders$3.breakParent;
  24881. var concat$17 = docBuilders$3.concat;
  24882. var dedent$4 = docBuilders$3.dedent;
  24883. var dedentToRoot$3 = docBuilders$3.dedentToRoot;
  24884. var fill$6 = docBuilders$3.fill;
  24885. var group$16 = docBuilders$3.group;
  24886. var hardline$13 = docBuilders$3.hardline;
  24887. var ifBreak$8 = docBuilders$3.ifBreak;
  24888. var join$12 = docBuilders$3.join;
  24889. var line$11 = docBuilders$3.line;
  24890. var lineSuffix$2 = docBuilders$3.lineSuffix;
  24891. var literalline$7 = docBuilders$3.literalline;
  24892. var markAsRoot$5 = docBuilders$3.markAsRoot;
  24893. var softline$8 = docBuilders$3.softline;
  24894. var replaceEndOfLineWith$3 = util.replaceEndOfLineWith;
  24895. function preprocess$6(ast) {
  24896. return mapNode(ast, defineShortcuts);
  24897. }
  24898. function defineShortcuts(node) {
  24899. switch (node.type) {
  24900. case "document":
  24901. defineShortcut(node, "head", function () {
  24902. return node.children[0];
  24903. });
  24904. defineShortcut(node, "body", function () {
  24905. return node.children[1];
  24906. });
  24907. break;
  24908. case "documentBody":
  24909. case "sequenceItem":
  24910. case "flowSequenceItem":
  24911. case "mappingKey":
  24912. case "mappingValue":
  24913. defineShortcut(node, "content", function () {
  24914. return node.children[0];
  24915. });
  24916. break;
  24917. case "mappingItem":
  24918. case "flowMappingItem":
  24919. defineShortcut(node, "key", function () {
  24920. return node.children[0];
  24921. });
  24922. defineShortcut(node, "value", function () {
  24923. return node.children[1];
  24924. });
  24925. break;
  24926. }
  24927. return node;
  24928. }
  24929. function genericPrint$6(path, options, print) {
  24930. var node = path.getValue();
  24931. var parentNode = path.getParentNode();
  24932. var tag = !node.tag ? "" : path.call(print, "tag");
  24933. var anchor = !node.anchor ? "" : path.call(print, "anchor");
  24934. var nextEmptyLine = isNode(node, ["mapping", "sequence", "comment", "directive", "mappingItem", "sequenceItem"]) && !isLastDescendantNode(path) ? printNextEmptyLine(path, options.originalText) : "";
  24935. 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$5, 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"))])) : ""]);
  24936. }
  24937. function _print(node, parentNode, path, options, print) {
  24938. switch (node.type) {
  24939. case "root":
  24940. return concat$17([join$12(hardline$13, path.map(function (childPath, index) {
  24941. var document = node.children[index];
  24942. var nextDocument = node.children[index + 1];
  24943. 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, "---"])]);
  24944. }, "children")), node.children.length === 0 || function (lastDescendantNode) {
  24945. return isNode(lastDescendantNode, ["blockLiteral", "blockFolded"]) && lastDescendantNode.chomping === "keep";
  24946. }(getLastDescendantNode$1(node)) ? "" : hardline$13]);
  24947. case "document":
  24948. {
  24949. var nextDocument = parentNode.children[path.getName() + 1];
  24950. 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));
  24951. }
  24952. case "documentHead":
  24953. return join$12(hardline$13, [].concat(path.map(print, "children"), path.map(print, "endComments")));
  24954. case "documentBody":
  24955. {
  24956. var children = join$12(hardline$13, path.map(print, "children")).parts;
  24957. var endComments = join$12(hardline$13, path.map(print, "endComments")).parts;
  24958. var separator = children.length === 0 || endComments.length === 0 ? "" : function (lastDescendantNode) {
  24959. return isNode(lastDescendantNode, ["blockFolded", "blockLiteral"]) ? lastDescendantNode.chomping === "keep" ? // there's already a newline printed at the end of blockValue (chomping=keep, lastDescendant=true)
  24960. "" : // an extra newline for better readability
  24961. concat$17([hardline$13, hardline$13]) : hardline$13;
  24962. }(getLastDescendantNode$1(node));
  24963. return concat$17([].concat(children, separator, endComments));
  24964. }
  24965. case "directive":
  24966. return concat$17(["%", join$12(" ", [node.name].concat(node.parameters))]);
  24967. case "comment":
  24968. return concat$17(["#", node.value]);
  24969. case "alias":
  24970. return concat$17(["*", node.value]);
  24971. case "tag":
  24972. return options.originalText.slice(node.position.start.offset, node.position.end.offset);
  24973. case "anchor":
  24974. return concat$17(["&", node.value]);
  24975. case "plain":
  24976. return printFlowScalarContent(node.type, options.originalText.slice(node.position.start.offset, node.position.end.offset), options);
  24977. case "quoteDouble":
  24978. case "quoteSingle":
  24979. {
  24980. var singleQuote = "'";
  24981. var doubleQuote = '"';
  24982. var raw = options.originalText.slice(node.position.start.offset + 1, node.position.end.offset - 1);
  24983. if (node.type === "quoteSingle" && raw.includes("\\") || node.type === "quoteDouble" && /\\[^"]/.test(raw)) {
  24984. // only quoteDouble can use escape chars
  24985. // and quoteSingle do not need to escape backslashes
  24986. var originalQuote = node.type === "quoteDouble" ? doubleQuote : singleQuote;
  24987. return concat$17([originalQuote, printFlowScalarContent(node.type, raw, options), originalQuote]);
  24988. } else if (raw.includes(doubleQuote)) {
  24989. return concat$17([singleQuote, printFlowScalarContent(node.type, node.type === "quoteDouble" ? raw // double quote needs to be escaped by backslash in quoteDouble
  24990. .replace(/\\"/g, doubleQuote).replace(/'/g, singleQuote.repeat(2)) : raw, options), singleQuote]);
  24991. }
  24992. if (raw.includes(singleQuote)) {
  24993. return concat$17([doubleQuote, printFlowScalarContent(node.type, node.type === "quoteSingle" ? // single quote needs to be escaped by 2 single quotes in quoteSingle
  24994. raw.replace(/''/g, singleQuote) : raw, options), doubleQuote]);
  24995. }
  24996. var quote = options.singleQuote ? singleQuote : doubleQuote;
  24997. return concat$17([quote, printFlowScalarContent(node.type, raw, options), quote]);
  24998. }
  24999. case "blockFolded":
  25000. case "blockLiteral":
  25001. {
  25002. var parentIndent = getAncestorCount(path, function (ancestorNode) {
  25003. return isNode(ancestorNode, ["sequence", "mapping"]);
  25004. });
  25005. var isLastDescendant = isLastDescendantNode(path);
  25006. 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, {
  25007. parentIndent: parentIndent,
  25008. isLastDescendant: isLastDescendant,
  25009. options: options
  25010. }).reduce(function (reduced, lineWords, index, lineContents) {
  25011. 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) : "");
  25012. }, []))))]);
  25013. }
  25014. case "sequence":
  25015. return join$12(hardline$13, path.map(print, "children"));
  25016. case "sequenceItem":
  25017. return concat$17(["- ", align$3(2, !node.content ? "" : path.call(print, "content"))]);
  25018. case "mappingKey":
  25019. return !node.content ? "" : path.call(print, "content");
  25020. case "mappingValue":
  25021. return !node.content ? "" : path.call(print, "content");
  25022. case "mapping":
  25023. return join$12(hardline$13, path.map(print, "children"));
  25024. case "mappingItem":
  25025. case "flowMappingItem":
  25026. {
  25027. var isEmptyMappingKey = isEmptyNode(node.key);
  25028. var isEmptyMappingValue = isEmptyNode(node.value);
  25029. if (isEmptyMappingKey && isEmptyMappingValue) {
  25030. return concat$17([": "]);
  25031. }
  25032. var key = path.call(print, "key");
  25033. var value = path.call(print, "value");
  25034. if (isEmptyMappingValue) {
  25035. 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)]);
  25036. }
  25037. if (isEmptyMappingKey) {
  25038. return concat$17([": ", align$3(2, value)]);
  25039. }
  25040. var groupId = Symbol("mappingKey");
  25041. var forceExplicitKey = hasLeadingComments(node.value) || !isInlineNode(node.key.content);
  25042. return forceExplicitKey ? concat$17(["? ", align$3(2, key), hardline$13, join$12("", path.map(print, "value", "leadingComments").map(function (comment) {
  25043. return concat$17([comment, hardline$13]);
  25044. })), ": ", align$3(2, value)]) : // force singleline
  25045. isSingleLineNode(node.key.content) && !hasLeadingComments(node.key.content) && !hasMiddleComments(node.key.content) && !hasTrailingComment$1(node.key.content) && !hasEndComments(node.key) && !hasLeadingComments(node.value.content) && !hasMiddleComments(node.value.content) && !hasEndComments(node.value) && isAbsolutelyPrintedAsSingleLineNode(node.value.content, options) ? concat$17([key, needsSpaceInFrontOfMappingValue(node) ? " " : "", ": ", value]) : conditionalGroup$2([concat$17([group$16(concat$17([ifBreak$8("? "), group$16(align$3(2, key), {
  25046. id: groupId
  25047. })])), ifBreak$8(concat$17([hardline$13, ": ", align$3(2, value)]), indent(concat$17([needsSpaceInFrontOfMappingValue(node) ? " " : "", ":", hasLeadingComments(node.value.content) || hasEndComments(node.value) && node.value.content && !isNode(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])), {
  25048. groupId: groupId
  25049. })])]);
  25050. }
  25051. case "flowMapping":
  25052. case "flowSequence":
  25053. {
  25054. var openMarker = node.type === "flowMapping" ? "{" : "[";
  25055. var closeMarker = node.type === "flowMapping" ? "}" : "]";
  25056. var bracketSpacing = node.type === "flowMapping" && node.children.length !== 0 && options.bracketSpacing ? line$11 : softline$8;
  25057. var isLastItemEmptyMappingItem = node.children.length !== 0 && function (lastItem) {
  25058. return lastItem.type === "flowMappingItem" && isEmptyNode(lastItem.key) && isEmptyNode(lastItem.value);
  25059. }(getLast$5(node.children));
  25060. return concat$17([openMarker, indent(concat$17([bracketSpacing, concat$17(path.map(function (childPath, index) {
  25061. 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) : ""])]);
  25062. }, "children")), ifBreak$8(",", "")])), isLastItemEmptyMappingItem ? "" : bracketSpacing, closeMarker]);
  25063. }
  25064. case "flowSequenceItem":
  25065. return path.call(print, "content");
  25066. // istanbul ignore next
  25067. default:
  25068. throw new Error("Unexpected node type ".concat(node.type));
  25069. }
  25070. function indent(doc$$2) {
  25071. return docBuilders$3.align(" ".repeat(options.tabWidth), doc$$2);
  25072. }
  25073. }
  25074. function align$3(n, doc$$2) {
  25075. return typeof n === "number" && n > 0 ? docBuilders$3.align(" ".repeat(n), doc$$2) : docBuilders$3.align(n, doc$$2);
  25076. }
  25077. function isInlineNode(node) {
  25078. if (!node) {
  25079. return true;
  25080. }
  25081. switch (node.type) {
  25082. case "plain":
  25083. case "quoteDouble":
  25084. case "quoteSingle":
  25085. case "alias":
  25086. case "flowMapping":
  25087. case "flowSequence":
  25088. return true;
  25089. default:
  25090. return false;
  25091. }
  25092. }
  25093. function isSingleLineNode(node) {
  25094. if (!node) {
  25095. return true;
  25096. }
  25097. switch (node.type) {
  25098. case "plain":
  25099. case "quoteDouble":
  25100. case "quoteSingle":
  25101. return node.position.start.line === node.position.end.line;
  25102. case "alias":
  25103. return true;
  25104. default:
  25105. return false;
  25106. }
  25107. }
  25108. function shouldPrintDocumentBody(document) {
  25109. return document.body.children.length !== 0 || hasEndComments(document.body);
  25110. }
  25111. function shouldPrintDocumentEndMarker(document, nextDocument) {
  25112. return (
  25113. /**
  25114. *... # trailingComment
  25115. */
  25116. hasTrailingComment$1(document) || nextDocument && (
  25117. /**
  25118. * ...
  25119. * %DIRECTIVE
  25120. * ---
  25121. */
  25122. nextDocument.head.children.length !== 0 ||
  25123. /**
  25124. * ...
  25125. * # endComment
  25126. * ---
  25127. */
  25128. hasEndComments(nextDocument.head))
  25129. );
  25130. }
  25131. function shouldPrintDocumentHeadEndMarker(document, nextDocument, root, options) {
  25132. if (
  25133. /**
  25134. * ---
  25135. * preserve the first document head end marker
  25136. */
  25137. root.children[0] === document && /---(\s|$)/.test(options.originalText.slice(options.locStart(document), options.locStart(document) + 4)) ||
  25138. /**
  25139. * %DIRECTIVE
  25140. * ---
  25141. */
  25142. document.head.children.length !== 0 ||
  25143. /**
  25144. * # end comment
  25145. * ---
  25146. */
  25147. hasEndComments(document.head) ||
  25148. /**
  25149. * --- # trailing comment
  25150. */
  25151. hasTrailingComment$1(document.head)) {
  25152. return "head";
  25153. }
  25154. if (shouldPrintDocumentEndMarker(document, nextDocument)) {
  25155. return false;
  25156. }
  25157. return nextDocument ? "root" : false;
  25158. }
  25159. function isAbsolutelyPrintedAsSingleLineNode(node, options) {
  25160. if (!node) {
  25161. return true;
  25162. }
  25163. switch (node.type) {
  25164. case "plain":
  25165. case "quoteSingle":
  25166. case "quoteDouble":
  25167. break;
  25168. case "alias":
  25169. return true;
  25170. default:
  25171. return false;
  25172. }
  25173. if (options.proseWrap === "preserve") {
  25174. return node.position.start.line === node.position.end.line;
  25175. }
  25176. if ( // backslash-newline
  25177. /\\$/m.test(options.originalText.slice(node.position.start.offset, node.position.end.offset))) {
  25178. return false;
  25179. }
  25180. switch (options.proseWrap) {
  25181. case "never":
  25182. return node.value.indexOf("\n") === -1;
  25183. case "always":
  25184. return !/[\n ]/.test(node.value);
  25185. // istanbul ignore next
  25186. default:
  25187. return false;
  25188. }
  25189. }
  25190. function needsSpaceInFrontOfMappingValue(node) {
  25191. return node.key.content && node.key.content.type === "alias";
  25192. }
  25193. function printNextEmptyLine(path, originalText) {
  25194. var node = path.getValue();
  25195. var root = path.stack[0];
  25196. root.isNextEmptyLinePrintedChecklist = root.isNextEmptyLinePrintedChecklist || [];
  25197. if (!root.isNextEmptyLinePrintedChecklist[node.position.end.line]) {
  25198. if (isNextLineEmpty$5(node, originalText)) {
  25199. root.isNextEmptyLinePrintedChecklist[node.position.end.line] = true;
  25200. return softline$8;
  25201. }
  25202. }
  25203. return "";
  25204. }
  25205. function printFlowScalarContent(nodeType, content, options) {
  25206. var lineContents = getFlowScalarLineContents(nodeType, content, options);
  25207. return join$12(hardline$13, lineContents.map(function (lineContentWords) {
  25208. return fill$6(join$12(line$11, lineContentWords).parts);
  25209. }));
  25210. }
  25211. function clean$11(node, newNode
  25212. /*, parent */
  25213. ) {
  25214. if (isNode(newNode)) {
  25215. delete newNode.position;
  25216. switch (newNode.type) {
  25217. case "comment":
  25218. // insert pragma
  25219. if (isPragma(newNode.value)) {
  25220. return null;
  25221. }
  25222. break;
  25223. case "quoteDouble":
  25224. case "quoteSingle":
  25225. newNode.type = "quote";
  25226. break;
  25227. }
  25228. }
  25229. }
  25230. var printerYaml = {
  25231. preprocess: preprocess$6,
  25232. print: genericPrint$6,
  25233. massageAstNode: clean$11,
  25234. insertPragma: insertPragma$8
  25235. };
  25236. var options$18 = {
  25237. bracketSpacing: commonOptions.bracketSpacing,
  25238. singleQuote: commonOptions.singleQuote,
  25239. proseWrap: commonOptions.proseWrap
  25240. };
  25241. var name$16 = "YAML";
  25242. var type$15 = "data";
  25243. var tmScope$15 = "source.yaml";
  25244. var aliases$6 = ["yml"];
  25245. var extensions$15 = [".yml", ".mir", ".reek", ".rviz", ".sublime-syntax", ".syntax", ".yaml", ".yaml-tmlanguage", ".yml.mysql"];
  25246. var filenames$3 = [".clang-format", ".clang-tidy", ".gemrc", "glide.lock"];
  25247. var aceMode$15 = "yaml";
  25248. var codemirrorMode$11 = "yaml";
  25249. var codemirrorMimeType$11 = "text/x-yaml";
  25250. var languageId$15 = 407;
  25251. var yaml = {
  25252. name: name$16,
  25253. type: type$15,
  25254. tmScope: tmScope$15,
  25255. aliases: aliases$6,
  25256. extensions: extensions$15,
  25257. filenames: filenames$3,
  25258. aceMode: aceMode$15,
  25259. codemirrorMode: codemirrorMode$11,
  25260. codemirrorMimeType: codemirrorMimeType$11,
  25261. languageId: languageId$15
  25262. };
  25263. var yaml$1 = Object.freeze({
  25264. name: name$16,
  25265. type: type$15,
  25266. tmScope: tmScope$15,
  25267. aliases: aliases$6,
  25268. extensions: extensions$15,
  25269. filenames: filenames$3,
  25270. aceMode: aceMode$15,
  25271. codemirrorMode: codemirrorMode$11,
  25272. codemirrorMimeType: codemirrorMimeType$11,
  25273. languageId: languageId$15,
  25274. default: yaml
  25275. });
  25276. var require$$0$29 = ( yaml$1 && yaml ) || yaml$1;
  25277. var languages$6 = [createLanguage(require$$0$29, {
  25278. override: {
  25279. since: "1.14.0",
  25280. parsers: ["yaml"],
  25281. vscodeLanguageIds: ["yaml"]
  25282. }
  25283. })];
  25284. var languageYaml = {
  25285. languages: languages$6,
  25286. printers: {
  25287. yaml: printerYaml
  25288. },
  25289. options: options$18
  25290. };
  25291. var version = require$$0.version;
  25292. var getSupportInfo = support.getSupportInfo;
  25293. var internalPlugins = [languageCss, languageGraphql, languageHandlebars, languageHtml, languageJs, languageMarkdown, languageYaml];
  25294. var isArray = Array.isArray || function (arr) {
  25295. return Object.prototype.toString.call(arr) === "[object Array]";
  25296. }; // Luckily `opts` is always the 2nd argument
  25297. function withPlugins(fn) {
  25298. return function () {
  25299. var args = Array.from(arguments);
  25300. var plugins = args[1] && args[1].plugins || [];
  25301. if (!isArray(plugins)) {
  25302. plugins = Object.values(plugins);
  25303. }
  25304. args[1] = Object.assign({}, args[1], {
  25305. plugins: internalPlugins.concat(plugins)
  25306. });
  25307. return fn.apply(null, args);
  25308. };
  25309. }
  25310. var formatWithCursor = withPlugins(core.formatWithCursor);
  25311. var standalone$2 = {
  25312. formatWithCursor: formatWithCursor,
  25313. format: function format(text, opts) {
  25314. return formatWithCursor(text, opts).formatted;
  25315. },
  25316. check: function check(text, opts) {
  25317. var formatted = formatWithCursor(text, opts).formatted;
  25318. return formatted === text;
  25319. },
  25320. doc: doc,
  25321. getSupportInfo: withPlugins(getSupportInfo),
  25322. version: version,
  25323. util: utilShared,
  25324. __debug: {
  25325. parse: withPlugins(core.parse),
  25326. formatAST: withPlugins(core.formatAST),
  25327. formatDoc: withPlugins(core.formatDoc),
  25328. printToDoc: withPlugins(core.printToDoc),
  25329. printDocToString: withPlugins(core.printDocToString)
  25330. }
  25331. };
  25332. var standalone = standalone$2;
  25333. return standalone;
  25334. })));