chunk-utils-source-map.2be5aa48.mjs 234 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445
  1. import { s as slash, j as notNullish } from './chunk-mock-date.2917be60.mjs';
  2. import { p as picocolors } from './chunk-constants.71e8a211.mjs';
  3. var build = {};
  4. var ansiStyles$1 = {exports: {}};
  5. (function (module) {
  6. const ANSI_BACKGROUND_OFFSET = 10;
  7. const wrapAnsi256 = (offset = 0) => code => `\u001B[${38 + offset};5;${code}m`;
  8. const wrapAnsi16m = (offset = 0) => (red, green, blue) => `\u001B[${38 + offset};2;${red};${green};${blue}m`;
  9. function assembleStyles() {
  10. const codes = new Map();
  11. const styles = {
  12. modifier: {
  13. reset: [0, 0],
  14. // 21 isn't widely supported and 22 does the same thing
  15. bold: [1, 22],
  16. dim: [2, 22],
  17. italic: [3, 23],
  18. underline: [4, 24],
  19. overline: [53, 55],
  20. inverse: [7, 27],
  21. hidden: [8, 28],
  22. strikethrough: [9, 29]
  23. },
  24. color: {
  25. black: [30, 39],
  26. red: [31, 39],
  27. green: [32, 39],
  28. yellow: [33, 39],
  29. blue: [34, 39],
  30. magenta: [35, 39],
  31. cyan: [36, 39],
  32. white: [37, 39],
  33. // Bright color
  34. blackBright: [90, 39],
  35. redBright: [91, 39],
  36. greenBright: [92, 39],
  37. yellowBright: [93, 39],
  38. blueBright: [94, 39],
  39. magentaBright: [95, 39],
  40. cyanBright: [96, 39],
  41. whiteBright: [97, 39]
  42. },
  43. bgColor: {
  44. bgBlack: [40, 49],
  45. bgRed: [41, 49],
  46. bgGreen: [42, 49],
  47. bgYellow: [43, 49],
  48. bgBlue: [44, 49],
  49. bgMagenta: [45, 49],
  50. bgCyan: [46, 49],
  51. bgWhite: [47, 49],
  52. // Bright color
  53. bgBlackBright: [100, 49],
  54. bgRedBright: [101, 49],
  55. bgGreenBright: [102, 49],
  56. bgYellowBright: [103, 49],
  57. bgBlueBright: [104, 49],
  58. bgMagentaBright: [105, 49],
  59. bgCyanBright: [106, 49],
  60. bgWhiteBright: [107, 49]
  61. }
  62. };
  63. // Alias bright black as gray (and grey)
  64. styles.color.gray = styles.color.blackBright;
  65. styles.bgColor.bgGray = styles.bgColor.bgBlackBright;
  66. styles.color.grey = styles.color.blackBright;
  67. styles.bgColor.bgGrey = styles.bgColor.bgBlackBright;
  68. for (const [groupName, group] of Object.entries(styles)) {
  69. for (const [styleName, style] of Object.entries(group)) {
  70. styles[styleName] = {
  71. open: `\u001B[${style[0]}m`,
  72. close: `\u001B[${style[1]}m`
  73. };
  74. group[styleName] = styles[styleName];
  75. codes.set(style[0], style[1]);
  76. }
  77. Object.defineProperty(styles, groupName, {
  78. value: group,
  79. enumerable: false
  80. });
  81. }
  82. Object.defineProperty(styles, 'codes', {
  83. value: codes,
  84. enumerable: false
  85. });
  86. styles.color.close = '\u001B[39m';
  87. styles.bgColor.close = '\u001B[49m';
  88. styles.color.ansi256 = wrapAnsi256();
  89. styles.color.ansi16m = wrapAnsi16m();
  90. styles.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET);
  91. styles.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET);
  92. // From https://github.com/Qix-/color-convert/blob/3f0e0d4e92e235796ccb17f6e85c72094a651f49/conversions.js
  93. Object.defineProperties(styles, {
  94. rgbToAnsi256: {
  95. value: (red, green, blue) => {
  96. // We use the extended greyscale palette here, with the exception of
  97. // black and white. normal palette only has 4 greyscale shades.
  98. if (red === green && green === blue) {
  99. if (red < 8) {
  100. return 16;
  101. }
  102. if (red > 248) {
  103. return 231;
  104. }
  105. return Math.round(((red - 8) / 247) * 24) + 232;
  106. }
  107. return 16 +
  108. (36 * Math.round(red / 255 * 5)) +
  109. (6 * Math.round(green / 255 * 5)) +
  110. Math.round(blue / 255 * 5);
  111. },
  112. enumerable: false
  113. },
  114. hexToRgb: {
  115. value: hex => {
  116. const matches = /(?<colorString>[a-f\d]{6}|[a-f\d]{3})/i.exec(hex.toString(16));
  117. if (!matches) {
  118. return [0, 0, 0];
  119. }
  120. let {colorString} = matches.groups;
  121. if (colorString.length === 3) {
  122. colorString = colorString.split('').map(character => character + character).join('');
  123. }
  124. const integer = Number.parseInt(colorString, 16);
  125. return [
  126. (integer >> 16) & 0xFF,
  127. (integer >> 8) & 0xFF,
  128. integer & 0xFF
  129. ];
  130. },
  131. enumerable: false
  132. },
  133. hexToAnsi256: {
  134. value: hex => styles.rgbToAnsi256(...styles.hexToRgb(hex)),
  135. enumerable: false
  136. }
  137. });
  138. return styles;
  139. }
  140. // Make the export immutable
  141. Object.defineProperty(module, 'exports', {
  142. enumerable: true,
  143. get: assembleStyles
  144. });
  145. } (ansiStyles$1));
  146. var collections = {};
  147. Object.defineProperty(collections, '__esModule', {
  148. value: true
  149. });
  150. collections.printIteratorEntries = printIteratorEntries;
  151. collections.printIteratorValues = printIteratorValues;
  152. collections.printListItems = printListItems;
  153. collections.printObjectProperties = printObjectProperties;
  154. /**
  155. * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
  156. *
  157. * This source code is licensed under the MIT license found in the
  158. * LICENSE file in the root directory of this source tree.
  159. *
  160. */
  161. const getKeysOfEnumerableProperties = (object, compareKeys) => {
  162. const keys = Object.keys(object).sort(compareKeys);
  163. if (Object.getOwnPropertySymbols) {
  164. Object.getOwnPropertySymbols(object).forEach(symbol => {
  165. if (Object.getOwnPropertyDescriptor(object, symbol).enumerable) {
  166. keys.push(symbol);
  167. }
  168. });
  169. }
  170. return keys;
  171. };
  172. /**
  173. * Return entries (for example, of a map)
  174. * with spacing, indentation, and comma
  175. * without surrounding punctuation (for example, braces)
  176. */
  177. function printIteratorEntries(
  178. iterator,
  179. config,
  180. indentation,
  181. depth,
  182. refs,
  183. printer, // Too bad, so sad that separator for ECMAScript Map has been ' => '
  184. // What a distracting diff if you change a data structure to/from
  185. // ECMAScript Object or Immutable.Map/OrderedMap which use the default.
  186. separator = ': '
  187. ) {
  188. let result = '';
  189. let current = iterator.next();
  190. if (!current.done) {
  191. result += config.spacingOuter;
  192. const indentationNext = indentation + config.indent;
  193. while (!current.done) {
  194. const name = printer(
  195. current.value[0],
  196. config,
  197. indentationNext,
  198. depth,
  199. refs
  200. );
  201. const value = printer(
  202. current.value[1],
  203. config,
  204. indentationNext,
  205. depth,
  206. refs
  207. );
  208. result += indentationNext + name + separator + value;
  209. current = iterator.next();
  210. if (!current.done) {
  211. result += ',' + config.spacingInner;
  212. } else if (!config.min) {
  213. result += ',';
  214. }
  215. }
  216. result += config.spacingOuter + indentation;
  217. }
  218. return result;
  219. }
  220. /**
  221. * Return values (for example, of a set)
  222. * with spacing, indentation, and comma
  223. * without surrounding punctuation (braces or brackets)
  224. */
  225. function printIteratorValues(
  226. iterator,
  227. config,
  228. indentation,
  229. depth,
  230. refs,
  231. printer
  232. ) {
  233. let result = '';
  234. let current = iterator.next();
  235. if (!current.done) {
  236. result += config.spacingOuter;
  237. const indentationNext = indentation + config.indent;
  238. while (!current.done) {
  239. result +=
  240. indentationNext +
  241. printer(current.value, config, indentationNext, depth, refs);
  242. current = iterator.next();
  243. if (!current.done) {
  244. result += ',' + config.spacingInner;
  245. } else if (!config.min) {
  246. result += ',';
  247. }
  248. }
  249. result += config.spacingOuter + indentation;
  250. }
  251. return result;
  252. }
  253. /**
  254. * Return items (for example, of an array)
  255. * with spacing, indentation, and comma
  256. * without surrounding punctuation (for example, brackets)
  257. **/
  258. function printListItems(list, config, indentation, depth, refs, printer) {
  259. let result = '';
  260. if (list.length) {
  261. result += config.spacingOuter;
  262. const indentationNext = indentation + config.indent;
  263. for (let i = 0; i < list.length; i++) {
  264. result += indentationNext;
  265. if (i in list) {
  266. result += printer(list[i], config, indentationNext, depth, refs);
  267. }
  268. if (i < list.length - 1) {
  269. result += ',' + config.spacingInner;
  270. } else if (!config.min) {
  271. result += ',';
  272. }
  273. }
  274. result += config.spacingOuter + indentation;
  275. }
  276. return result;
  277. }
  278. /**
  279. * Return properties of an object
  280. * with spacing, indentation, and comma
  281. * without surrounding punctuation (for example, braces)
  282. */
  283. function printObjectProperties(val, config, indentation, depth, refs, printer) {
  284. let result = '';
  285. const keys = getKeysOfEnumerableProperties(val, config.compareKeys);
  286. if (keys.length) {
  287. result += config.spacingOuter;
  288. const indentationNext = indentation + config.indent;
  289. for (let i = 0; i < keys.length; i++) {
  290. const key = keys[i];
  291. const name = printer(key, config, indentationNext, depth, refs);
  292. const value = printer(val[key], config, indentationNext, depth, refs);
  293. result += indentationNext + name + ': ' + value;
  294. if (i < keys.length - 1) {
  295. result += ',' + config.spacingInner;
  296. } else if (!config.min) {
  297. result += ',';
  298. }
  299. }
  300. result += config.spacingOuter + indentation;
  301. }
  302. return result;
  303. }
  304. var AsymmetricMatcher$1 = {};
  305. Object.defineProperty(AsymmetricMatcher$1, '__esModule', {
  306. value: true
  307. });
  308. AsymmetricMatcher$1.test = AsymmetricMatcher$1.serialize = AsymmetricMatcher$1.default = void 0;
  309. var _collections$3 = collections;
  310. var global$1 = (function () {
  311. if (typeof globalThis !== 'undefined') {
  312. return globalThis;
  313. } else if (typeof global$1 !== 'undefined') {
  314. return global$1;
  315. } else if (typeof self !== 'undefined') {
  316. return self;
  317. } else if (typeof window !== 'undefined') {
  318. return window;
  319. } else {
  320. return Function('return this')();
  321. }
  322. })();
  323. var Symbol$2 = global$1['jest-symbol-do-not-touch'] || global$1.Symbol;
  324. const asymmetricMatcher =
  325. typeof Symbol$2 === 'function' && Symbol$2.for
  326. ? Symbol$2.for('jest.asymmetricMatcher')
  327. : 0x1357a5;
  328. const SPACE$2 = ' ';
  329. const serialize$6 = (val, config, indentation, depth, refs, printer) => {
  330. const stringedValue = val.toString();
  331. if (
  332. stringedValue === 'ArrayContaining' ||
  333. stringedValue === 'ArrayNotContaining'
  334. ) {
  335. if (++depth > config.maxDepth) {
  336. return '[' + stringedValue + ']';
  337. }
  338. return (
  339. stringedValue +
  340. SPACE$2 +
  341. '[' +
  342. (0, _collections$3.printListItems)(
  343. val.sample,
  344. config,
  345. indentation,
  346. depth,
  347. refs,
  348. printer
  349. ) +
  350. ']'
  351. );
  352. }
  353. if (
  354. stringedValue === 'ObjectContaining' ||
  355. stringedValue === 'ObjectNotContaining'
  356. ) {
  357. if (++depth > config.maxDepth) {
  358. return '[' + stringedValue + ']';
  359. }
  360. return (
  361. stringedValue +
  362. SPACE$2 +
  363. '{' +
  364. (0, _collections$3.printObjectProperties)(
  365. val.sample,
  366. config,
  367. indentation,
  368. depth,
  369. refs,
  370. printer
  371. ) +
  372. '}'
  373. );
  374. }
  375. if (
  376. stringedValue === 'StringMatching' ||
  377. stringedValue === 'StringNotMatching'
  378. ) {
  379. return (
  380. stringedValue +
  381. SPACE$2 +
  382. printer(val.sample, config, indentation, depth, refs)
  383. );
  384. }
  385. if (
  386. stringedValue === 'StringContaining' ||
  387. stringedValue === 'StringNotContaining'
  388. ) {
  389. return (
  390. stringedValue +
  391. SPACE$2 +
  392. printer(val.sample, config, indentation, depth, refs)
  393. );
  394. }
  395. return val.toAsymmetricMatcher();
  396. };
  397. AsymmetricMatcher$1.serialize = serialize$6;
  398. const test$6 = val => val && val.$$typeof === asymmetricMatcher;
  399. AsymmetricMatcher$1.test = test$6;
  400. const plugin$6 = {
  401. serialize: serialize$6,
  402. test: test$6
  403. };
  404. var _default$7 = plugin$6;
  405. AsymmetricMatcher$1.default = _default$7;
  406. var ConvertAnsi = {};
  407. var ansiRegex$1 = ({onlyFirst = false} = {}) => {
  408. const pattern = [
  409. '[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)',
  410. '(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))'
  411. ].join('|');
  412. return new RegExp(pattern, onlyFirst ? undefined : 'g');
  413. };
  414. Object.defineProperty(ConvertAnsi, '__esModule', {
  415. value: true
  416. });
  417. ConvertAnsi.test = ConvertAnsi.serialize = ConvertAnsi.default = void 0;
  418. var _ansiRegex = _interopRequireDefault$2(ansiRegex$1);
  419. var _ansiStyles$1 = _interopRequireDefault$2(ansiStyles$1.exports);
  420. function _interopRequireDefault$2(obj) {
  421. return obj && obj.__esModule ? obj : {default: obj};
  422. }
  423. /**
  424. * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
  425. *
  426. * This source code is licensed under the MIT license found in the
  427. * LICENSE file in the root directory of this source tree.
  428. */
  429. const toHumanReadableAnsi = text =>
  430. text.replace((0, _ansiRegex.default)(), match => {
  431. switch (match) {
  432. case _ansiStyles$1.default.red.close:
  433. case _ansiStyles$1.default.green.close:
  434. case _ansiStyles$1.default.cyan.close:
  435. case _ansiStyles$1.default.gray.close:
  436. case _ansiStyles$1.default.white.close:
  437. case _ansiStyles$1.default.yellow.close:
  438. case _ansiStyles$1.default.bgRed.close:
  439. case _ansiStyles$1.default.bgGreen.close:
  440. case _ansiStyles$1.default.bgYellow.close:
  441. case _ansiStyles$1.default.inverse.close:
  442. case _ansiStyles$1.default.dim.close:
  443. case _ansiStyles$1.default.bold.close:
  444. case _ansiStyles$1.default.reset.open:
  445. case _ansiStyles$1.default.reset.close:
  446. return '</>';
  447. case _ansiStyles$1.default.red.open:
  448. return '<red>';
  449. case _ansiStyles$1.default.green.open:
  450. return '<green>';
  451. case _ansiStyles$1.default.cyan.open:
  452. return '<cyan>';
  453. case _ansiStyles$1.default.gray.open:
  454. return '<gray>';
  455. case _ansiStyles$1.default.white.open:
  456. return '<white>';
  457. case _ansiStyles$1.default.yellow.open:
  458. return '<yellow>';
  459. case _ansiStyles$1.default.bgRed.open:
  460. return '<bgRed>';
  461. case _ansiStyles$1.default.bgGreen.open:
  462. return '<bgGreen>';
  463. case _ansiStyles$1.default.bgYellow.open:
  464. return '<bgYellow>';
  465. case _ansiStyles$1.default.inverse.open:
  466. return '<inverse>';
  467. case _ansiStyles$1.default.dim.open:
  468. return '<dim>';
  469. case _ansiStyles$1.default.bold.open:
  470. return '<bold>';
  471. default:
  472. return '';
  473. }
  474. });
  475. const test$5 = val =>
  476. typeof val === 'string' && !!val.match((0, _ansiRegex.default)());
  477. ConvertAnsi.test = test$5;
  478. const serialize$5 = (val, config, indentation, depth, refs, printer) =>
  479. printer(toHumanReadableAnsi(val), config, indentation, depth, refs);
  480. ConvertAnsi.serialize = serialize$5;
  481. const plugin$5 = {
  482. serialize: serialize$5,
  483. test: test$5
  484. };
  485. var _default$6 = plugin$5;
  486. ConvertAnsi.default = _default$6;
  487. var DOMCollection$1 = {};
  488. Object.defineProperty(DOMCollection$1, '__esModule', {
  489. value: true
  490. });
  491. DOMCollection$1.test = DOMCollection$1.serialize = DOMCollection$1.default = void 0;
  492. var _collections$2 = collections;
  493. /**
  494. * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
  495. *
  496. * This source code is licensed under the MIT license found in the
  497. * LICENSE file in the root directory of this source tree.
  498. */
  499. /* eslint-disable local/ban-types-eventually */
  500. const SPACE$1 = ' ';
  501. const OBJECT_NAMES = ['DOMStringMap', 'NamedNodeMap'];
  502. const ARRAY_REGEXP = /^(HTML\w*Collection|NodeList)$/;
  503. const testName = name =>
  504. OBJECT_NAMES.indexOf(name) !== -1 || ARRAY_REGEXP.test(name);
  505. const test$4 = val =>
  506. val &&
  507. val.constructor &&
  508. !!val.constructor.name &&
  509. testName(val.constructor.name);
  510. DOMCollection$1.test = test$4;
  511. const isNamedNodeMap = collection =>
  512. collection.constructor.name === 'NamedNodeMap';
  513. const serialize$4 = (collection, config, indentation, depth, refs, printer) => {
  514. const name = collection.constructor.name;
  515. if (++depth > config.maxDepth) {
  516. return '[' + name + ']';
  517. }
  518. return (
  519. (config.min ? '' : name + SPACE$1) +
  520. (OBJECT_NAMES.indexOf(name) !== -1
  521. ? '{' +
  522. (0, _collections$2.printObjectProperties)(
  523. isNamedNodeMap(collection)
  524. ? Array.from(collection).reduce((props, attribute) => {
  525. props[attribute.name] = attribute.value;
  526. return props;
  527. }, {})
  528. : {...collection},
  529. config,
  530. indentation,
  531. depth,
  532. refs,
  533. printer
  534. ) +
  535. '}'
  536. : '[' +
  537. (0, _collections$2.printListItems)(
  538. Array.from(collection),
  539. config,
  540. indentation,
  541. depth,
  542. refs,
  543. printer
  544. ) +
  545. ']')
  546. );
  547. };
  548. DOMCollection$1.serialize = serialize$4;
  549. const plugin$4 = {
  550. serialize: serialize$4,
  551. test: test$4
  552. };
  553. var _default$5 = plugin$4;
  554. DOMCollection$1.default = _default$5;
  555. var DOMElement$1 = {};
  556. var markup = {};
  557. var escapeHTML$1 = {};
  558. Object.defineProperty(escapeHTML$1, '__esModule', {
  559. value: true
  560. });
  561. escapeHTML$1.default = escapeHTML;
  562. /**
  563. * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
  564. *
  565. * This source code is licensed under the MIT license found in the
  566. * LICENSE file in the root directory of this source tree.
  567. */
  568. function escapeHTML(str) {
  569. return str.replace(/</g, '&lt;').replace(/>/g, '&gt;');
  570. }
  571. Object.defineProperty(markup, '__esModule', {
  572. value: true
  573. });
  574. markup.printText =
  575. markup.printProps =
  576. markup.printElementAsLeaf =
  577. markup.printElement =
  578. markup.printComment =
  579. markup.printChildren =
  580. void 0;
  581. var _escapeHTML = _interopRequireDefault$1(escapeHTML$1);
  582. function _interopRequireDefault$1(obj) {
  583. return obj && obj.__esModule ? obj : {default: obj};
  584. }
  585. /**
  586. * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
  587. *
  588. * This source code is licensed under the MIT license found in the
  589. * LICENSE file in the root directory of this source tree.
  590. */
  591. // Return empty string if keys is empty.
  592. const printProps = (keys, props, config, indentation, depth, refs, printer) => {
  593. const indentationNext = indentation + config.indent;
  594. const colors = config.colors;
  595. return keys
  596. .map(key => {
  597. const value = props[key];
  598. let printed = printer(value, config, indentationNext, depth, refs);
  599. if (typeof value !== 'string') {
  600. if (printed.indexOf('\n') !== -1) {
  601. printed =
  602. config.spacingOuter +
  603. indentationNext +
  604. printed +
  605. config.spacingOuter +
  606. indentation;
  607. }
  608. printed = '{' + printed + '}';
  609. }
  610. return (
  611. config.spacingInner +
  612. indentation +
  613. colors.prop.open +
  614. key +
  615. colors.prop.close +
  616. '=' +
  617. colors.value.open +
  618. printed +
  619. colors.value.close
  620. );
  621. })
  622. .join('');
  623. }; // Return empty string if children is empty.
  624. markup.printProps = printProps;
  625. const printChildren = (children, config, indentation, depth, refs, printer) =>
  626. children
  627. .map(
  628. child =>
  629. config.spacingOuter +
  630. indentation +
  631. (typeof child === 'string'
  632. ? printText(child, config)
  633. : printer(child, config, indentation, depth, refs))
  634. )
  635. .join('');
  636. markup.printChildren = printChildren;
  637. const printText = (text, config) => {
  638. const contentColor = config.colors.content;
  639. return (
  640. contentColor.open + (0, _escapeHTML.default)(text) + contentColor.close
  641. );
  642. };
  643. markup.printText = printText;
  644. const printComment = (comment, config) => {
  645. const commentColor = config.colors.comment;
  646. return (
  647. commentColor.open +
  648. '<!--' +
  649. (0, _escapeHTML.default)(comment) +
  650. '-->' +
  651. commentColor.close
  652. );
  653. }; // Separate the functions to format props, children, and element,
  654. // so a plugin could override a particular function, if needed.
  655. // Too bad, so sad: the traditional (but unnecessary) space
  656. // in a self-closing tagColor requires a second test of printedProps.
  657. markup.printComment = printComment;
  658. const printElement = (
  659. type,
  660. printedProps,
  661. printedChildren,
  662. config,
  663. indentation
  664. ) => {
  665. const tagColor = config.colors.tag;
  666. return (
  667. tagColor.open +
  668. '<' +
  669. type +
  670. (printedProps &&
  671. tagColor.close +
  672. printedProps +
  673. config.spacingOuter +
  674. indentation +
  675. tagColor.open) +
  676. (printedChildren
  677. ? '>' +
  678. tagColor.close +
  679. printedChildren +
  680. config.spacingOuter +
  681. indentation +
  682. tagColor.open +
  683. '</' +
  684. type
  685. : (printedProps && !config.min ? '' : ' ') + '/') +
  686. '>' +
  687. tagColor.close
  688. );
  689. };
  690. markup.printElement = printElement;
  691. const printElementAsLeaf = (type, config) => {
  692. const tagColor = config.colors.tag;
  693. return (
  694. tagColor.open +
  695. '<' +
  696. type +
  697. tagColor.close +
  698. ' …' +
  699. tagColor.open +
  700. ' />' +
  701. tagColor.close
  702. );
  703. };
  704. markup.printElementAsLeaf = printElementAsLeaf;
  705. Object.defineProperty(DOMElement$1, '__esModule', {
  706. value: true
  707. });
  708. DOMElement$1.test = DOMElement$1.serialize = DOMElement$1.default = void 0;
  709. var _markup$2 = markup;
  710. /**
  711. * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
  712. *
  713. * This source code is licensed under the MIT license found in the
  714. * LICENSE file in the root directory of this source tree.
  715. */
  716. const ELEMENT_NODE = 1;
  717. const TEXT_NODE = 3;
  718. const COMMENT_NODE = 8;
  719. const FRAGMENT_NODE = 11;
  720. const ELEMENT_REGEXP = /^((HTML|SVG)\w*)?Element$/;
  721. const testHasAttribute = val => {
  722. try {
  723. return typeof val.hasAttribute === 'function' && val.hasAttribute('is');
  724. } catch {
  725. return false;
  726. }
  727. };
  728. const testNode = val => {
  729. const constructorName = val.constructor.name;
  730. const {nodeType, tagName} = val;
  731. const isCustomElement =
  732. (typeof tagName === 'string' && tagName.includes('-')) ||
  733. testHasAttribute(val);
  734. return (
  735. (nodeType === ELEMENT_NODE &&
  736. (ELEMENT_REGEXP.test(constructorName) || isCustomElement)) ||
  737. (nodeType === TEXT_NODE && constructorName === 'Text') ||
  738. (nodeType === COMMENT_NODE && constructorName === 'Comment') ||
  739. (nodeType === FRAGMENT_NODE && constructorName === 'DocumentFragment')
  740. );
  741. };
  742. const test$3 = val => {
  743. var _val$constructor;
  744. return (
  745. (val === null || val === void 0
  746. ? void 0
  747. : (_val$constructor = val.constructor) === null ||
  748. _val$constructor === void 0
  749. ? void 0
  750. : _val$constructor.name) && testNode(val)
  751. );
  752. };
  753. DOMElement$1.test = test$3;
  754. function nodeIsText(node) {
  755. return node.nodeType === TEXT_NODE;
  756. }
  757. function nodeIsComment(node) {
  758. return node.nodeType === COMMENT_NODE;
  759. }
  760. function nodeIsFragment(node) {
  761. return node.nodeType === FRAGMENT_NODE;
  762. }
  763. const serialize$3 = (node, config, indentation, depth, refs, printer) => {
  764. if (nodeIsText(node)) {
  765. return (0, _markup$2.printText)(node.data, config);
  766. }
  767. if (nodeIsComment(node)) {
  768. return (0, _markup$2.printComment)(node.data, config);
  769. }
  770. const type = nodeIsFragment(node)
  771. ? 'DocumentFragment'
  772. : node.tagName.toLowerCase();
  773. if (++depth > config.maxDepth) {
  774. return (0, _markup$2.printElementAsLeaf)(type, config);
  775. }
  776. return (0, _markup$2.printElement)(
  777. type,
  778. (0, _markup$2.printProps)(
  779. nodeIsFragment(node)
  780. ? []
  781. : Array.from(node.attributes)
  782. .map(attr => attr.name)
  783. .sort(),
  784. nodeIsFragment(node)
  785. ? {}
  786. : Array.from(node.attributes).reduce((props, attribute) => {
  787. props[attribute.name] = attribute.value;
  788. return props;
  789. }, {}),
  790. config,
  791. indentation + config.indent,
  792. depth,
  793. refs,
  794. printer
  795. ),
  796. (0, _markup$2.printChildren)(
  797. Array.prototype.slice.call(node.childNodes || node.children),
  798. config,
  799. indentation + config.indent,
  800. depth,
  801. refs,
  802. printer
  803. ),
  804. config,
  805. indentation
  806. );
  807. };
  808. DOMElement$1.serialize = serialize$3;
  809. const plugin$3 = {
  810. serialize: serialize$3,
  811. test: test$3
  812. };
  813. var _default$4 = plugin$3;
  814. DOMElement$1.default = _default$4;
  815. var Immutable$1 = {};
  816. Object.defineProperty(Immutable$1, '__esModule', {
  817. value: true
  818. });
  819. Immutable$1.test = Immutable$1.serialize = Immutable$1.default = void 0;
  820. var _collections$1 = collections;
  821. /**
  822. * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
  823. *
  824. * This source code is licensed under the MIT license found in the
  825. * LICENSE file in the root directory of this source tree.
  826. */
  827. // SENTINEL constants are from https://github.com/facebook/immutable-js
  828. const IS_ITERABLE_SENTINEL = '@@__IMMUTABLE_ITERABLE__@@';
  829. const IS_LIST_SENTINEL = '@@__IMMUTABLE_LIST__@@';
  830. const IS_KEYED_SENTINEL = '@@__IMMUTABLE_KEYED__@@';
  831. const IS_MAP_SENTINEL = '@@__IMMUTABLE_MAP__@@';
  832. const IS_ORDERED_SENTINEL = '@@__IMMUTABLE_ORDERED__@@';
  833. const IS_RECORD_SENTINEL = '@@__IMMUTABLE_RECORD__@@'; // immutable v4
  834. const IS_SEQ_SENTINEL = '@@__IMMUTABLE_SEQ__@@';
  835. const IS_SET_SENTINEL = '@@__IMMUTABLE_SET__@@';
  836. const IS_STACK_SENTINEL = '@@__IMMUTABLE_STACK__@@';
  837. const getImmutableName = name => 'Immutable.' + name;
  838. const printAsLeaf = name => '[' + name + ']';
  839. const SPACE = ' ';
  840. const LAZY = '…'; // Seq is lazy if it calls a method like filter
  841. const printImmutableEntries = (
  842. val,
  843. config,
  844. indentation,
  845. depth,
  846. refs,
  847. printer,
  848. type
  849. ) =>
  850. ++depth > config.maxDepth
  851. ? printAsLeaf(getImmutableName(type))
  852. : getImmutableName(type) +
  853. SPACE +
  854. '{' +
  855. (0, _collections$1.printIteratorEntries)(
  856. val.entries(),
  857. config,
  858. indentation,
  859. depth,
  860. refs,
  861. printer
  862. ) +
  863. '}'; // Record has an entries method because it is a collection in immutable v3.
  864. // Return an iterator for Immutable Record from version v3 or v4.
  865. function getRecordEntries(val) {
  866. let i = 0;
  867. return {
  868. next() {
  869. if (i < val._keys.length) {
  870. const key = val._keys[i++];
  871. return {
  872. done: false,
  873. value: [key, val.get(key)]
  874. };
  875. }
  876. return {
  877. done: true,
  878. value: undefined
  879. };
  880. }
  881. };
  882. }
  883. const printImmutableRecord = (
  884. val,
  885. config,
  886. indentation,
  887. depth,
  888. refs,
  889. printer
  890. ) => {
  891. // _name property is defined only for an Immutable Record instance
  892. // which was constructed with a second optional descriptive name arg
  893. const name = getImmutableName(val._name || 'Record');
  894. return ++depth > config.maxDepth
  895. ? printAsLeaf(name)
  896. : name +
  897. SPACE +
  898. '{' +
  899. (0, _collections$1.printIteratorEntries)(
  900. getRecordEntries(val),
  901. config,
  902. indentation,
  903. depth,
  904. refs,
  905. printer
  906. ) +
  907. '}';
  908. };
  909. const printImmutableSeq = (val, config, indentation, depth, refs, printer) => {
  910. const name = getImmutableName('Seq');
  911. if (++depth > config.maxDepth) {
  912. return printAsLeaf(name);
  913. }
  914. if (val[IS_KEYED_SENTINEL]) {
  915. return (
  916. name +
  917. SPACE +
  918. '{' + // from Immutable collection of entries or from ECMAScript object
  919. (val._iter || val._object
  920. ? (0, _collections$1.printIteratorEntries)(
  921. val.entries(),
  922. config,
  923. indentation,
  924. depth,
  925. refs,
  926. printer
  927. )
  928. : LAZY) +
  929. '}'
  930. );
  931. }
  932. return (
  933. name +
  934. SPACE +
  935. '[' +
  936. (val._iter || // from Immutable collection of values
  937. val._array || // from ECMAScript array
  938. val._collection || // from ECMAScript collection in immutable v4
  939. val._iterable // from ECMAScript collection in immutable v3
  940. ? (0, _collections$1.printIteratorValues)(
  941. val.values(),
  942. config,
  943. indentation,
  944. depth,
  945. refs,
  946. printer
  947. )
  948. : LAZY) +
  949. ']'
  950. );
  951. };
  952. const printImmutableValues = (
  953. val,
  954. config,
  955. indentation,
  956. depth,
  957. refs,
  958. printer,
  959. type
  960. ) =>
  961. ++depth > config.maxDepth
  962. ? printAsLeaf(getImmutableName(type))
  963. : getImmutableName(type) +
  964. SPACE +
  965. '[' +
  966. (0, _collections$1.printIteratorValues)(
  967. val.values(),
  968. config,
  969. indentation,
  970. depth,
  971. refs,
  972. printer
  973. ) +
  974. ']';
  975. const serialize$2 = (val, config, indentation, depth, refs, printer) => {
  976. if (val[IS_MAP_SENTINEL]) {
  977. return printImmutableEntries(
  978. val,
  979. config,
  980. indentation,
  981. depth,
  982. refs,
  983. printer,
  984. val[IS_ORDERED_SENTINEL] ? 'OrderedMap' : 'Map'
  985. );
  986. }
  987. if (val[IS_LIST_SENTINEL]) {
  988. return printImmutableValues(
  989. val,
  990. config,
  991. indentation,
  992. depth,
  993. refs,
  994. printer,
  995. 'List'
  996. );
  997. }
  998. if (val[IS_SET_SENTINEL]) {
  999. return printImmutableValues(
  1000. val,
  1001. config,
  1002. indentation,
  1003. depth,
  1004. refs,
  1005. printer,
  1006. val[IS_ORDERED_SENTINEL] ? 'OrderedSet' : 'Set'
  1007. );
  1008. }
  1009. if (val[IS_STACK_SENTINEL]) {
  1010. return printImmutableValues(
  1011. val,
  1012. config,
  1013. indentation,
  1014. depth,
  1015. refs,
  1016. printer,
  1017. 'Stack'
  1018. );
  1019. }
  1020. if (val[IS_SEQ_SENTINEL]) {
  1021. return printImmutableSeq(val, config, indentation, depth, refs, printer);
  1022. } // For compatibility with immutable v3 and v4, let record be the default.
  1023. return printImmutableRecord(val, config, indentation, depth, refs, printer);
  1024. }; // Explicitly comparing sentinel properties to true avoids false positive
  1025. // when mock identity-obj-proxy returns the key as the value for any key.
  1026. Immutable$1.serialize = serialize$2;
  1027. const test$2 = val =>
  1028. val &&
  1029. (val[IS_ITERABLE_SENTINEL] === true || val[IS_RECORD_SENTINEL] === true);
  1030. Immutable$1.test = test$2;
  1031. const plugin$2 = {
  1032. serialize: serialize$2,
  1033. test: test$2
  1034. };
  1035. var _default$3 = plugin$2;
  1036. Immutable$1.default = _default$3;
  1037. var ReactElement$1 = {};
  1038. var reactIs = {exports: {}};
  1039. var reactIs_production_min = {};
  1040. /** @license React v17.0.2
  1041. * react-is.production.min.js
  1042. *
  1043. * Copyright (c) Facebook, Inc. and its affiliates.
  1044. *
  1045. * This source code is licensed under the MIT license found in the
  1046. * LICENSE file in the root directory of this source tree.
  1047. */
  1048. var hasRequiredReactIs_production_min;
  1049. function requireReactIs_production_min () {
  1050. if (hasRequiredReactIs_production_min) return reactIs_production_min;
  1051. hasRequiredReactIs_production_min = 1;
  1052. var b=60103,c=60106,d=60107,e=60108,f=60114,g=60109,h=60110,k=60112,l=60113,m=60120,n=60115,p=60116,q=60121,r=60122,u=60117,v=60129,w=60131;
  1053. if("function"===typeof Symbol&&Symbol.for){var x=Symbol.for;b=x("react.element");c=x("react.portal");d=x("react.fragment");e=x("react.strict_mode");f=x("react.profiler");g=x("react.provider");h=x("react.context");k=x("react.forward_ref");l=x("react.suspense");m=x("react.suspense_list");n=x("react.memo");p=x("react.lazy");q=x("react.block");r=x("react.server.block");u=x("react.fundamental");v=x("react.debug_trace_mode");w=x("react.legacy_hidden");}
  1054. function y(a){if("object"===typeof a&&null!==a){var t=a.$$typeof;switch(t){case b:switch(a=a.type,a){case d:case f:case e:case l:case m:return a;default:switch(a=a&&a.$$typeof,a){case h:case k:case p:case n:case g:return a;default:return t}}case c:return t}}}var z=g,A=b,B=k,C=d,D=p,E=n,F=c,G=f,H=e,I=l;reactIs_production_min.ContextConsumer=h;reactIs_production_min.ContextProvider=z;reactIs_production_min.Element=A;reactIs_production_min.ForwardRef=B;reactIs_production_min.Fragment=C;reactIs_production_min.Lazy=D;reactIs_production_min.Memo=E;reactIs_production_min.Portal=F;reactIs_production_min.Profiler=G;reactIs_production_min.StrictMode=H;
  1055. reactIs_production_min.Suspense=I;reactIs_production_min.isAsyncMode=function(){return !1};reactIs_production_min.isConcurrentMode=function(){return !1};reactIs_production_min.isContextConsumer=function(a){return y(a)===h};reactIs_production_min.isContextProvider=function(a){return y(a)===g};reactIs_production_min.isElement=function(a){return "object"===typeof a&&null!==a&&a.$$typeof===b};reactIs_production_min.isForwardRef=function(a){return y(a)===k};reactIs_production_min.isFragment=function(a){return y(a)===d};reactIs_production_min.isLazy=function(a){return y(a)===p};reactIs_production_min.isMemo=function(a){return y(a)===n};
  1056. reactIs_production_min.isPortal=function(a){return y(a)===c};reactIs_production_min.isProfiler=function(a){return y(a)===f};reactIs_production_min.isStrictMode=function(a){return y(a)===e};reactIs_production_min.isSuspense=function(a){return y(a)===l};reactIs_production_min.isValidElementType=function(a){return "string"===typeof a||"function"===typeof a||a===d||a===f||a===v||a===e||a===l||a===m||a===w||"object"===typeof a&&null!==a&&(a.$$typeof===p||a.$$typeof===n||a.$$typeof===g||a.$$typeof===h||a.$$typeof===k||a.$$typeof===u||a.$$typeof===q||a[0]===r)?!0:!1};
  1057. reactIs_production_min.typeOf=y;
  1058. return reactIs_production_min;
  1059. }
  1060. var reactIs_development = {};
  1061. /** @license React v17.0.2
  1062. * react-is.development.js
  1063. *
  1064. * Copyright (c) Facebook, Inc. and its affiliates.
  1065. *
  1066. * This source code is licensed under the MIT license found in the
  1067. * LICENSE file in the root directory of this source tree.
  1068. */
  1069. var hasRequiredReactIs_development;
  1070. function requireReactIs_development () {
  1071. if (hasRequiredReactIs_development) return reactIs_development;
  1072. hasRequiredReactIs_development = 1;
  1073. if (process.env.NODE_ENV !== "production") {
  1074. (function() {
  1075. // ATTENTION
  1076. // When adding new symbols to this file,
  1077. // Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols'
  1078. // The Symbol used to tag the ReactElement-like types. If there is no native Symbol
  1079. // nor polyfill, then a plain number is used for performance.
  1080. var REACT_ELEMENT_TYPE = 0xeac7;
  1081. var REACT_PORTAL_TYPE = 0xeaca;
  1082. var REACT_FRAGMENT_TYPE = 0xeacb;
  1083. var REACT_STRICT_MODE_TYPE = 0xeacc;
  1084. var REACT_PROFILER_TYPE = 0xead2;
  1085. var REACT_PROVIDER_TYPE = 0xeacd;
  1086. var REACT_CONTEXT_TYPE = 0xeace;
  1087. var REACT_FORWARD_REF_TYPE = 0xead0;
  1088. var REACT_SUSPENSE_TYPE = 0xead1;
  1089. var REACT_SUSPENSE_LIST_TYPE = 0xead8;
  1090. var REACT_MEMO_TYPE = 0xead3;
  1091. var REACT_LAZY_TYPE = 0xead4;
  1092. var REACT_BLOCK_TYPE = 0xead9;
  1093. var REACT_SERVER_BLOCK_TYPE = 0xeada;
  1094. var REACT_FUNDAMENTAL_TYPE = 0xead5;
  1095. var REACT_DEBUG_TRACING_MODE_TYPE = 0xeae1;
  1096. var REACT_LEGACY_HIDDEN_TYPE = 0xeae3;
  1097. if (typeof Symbol === 'function' && Symbol.for) {
  1098. var symbolFor = Symbol.for;
  1099. REACT_ELEMENT_TYPE = symbolFor('react.element');
  1100. REACT_PORTAL_TYPE = symbolFor('react.portal');
  1101. REACT_FRAGMENT_TYPE = symbolFor('react.fragment');
  1102. REACT_STRICT_MODE_TYPE = symbolFor('react.strict_mode');
  1103. REACT_PROFILER_TYPE = symbolFor('react.profiler');
  1104. REACT_PROVIDER_TYPE = symbolFor('react.provider');
  1105. REACT_CONTEXT_TYPE = symbolFor('react.context');
  1106. REACT_FORWARD_REF_TYPE = symbolFor('react.forward_ref');
  1107. REACT_SUSPENSE_TYPE = symbolFor('react.suspense');
  1108. REACT_SUSPENSE_LIST_TYPE = symbolFor('react.suspense_list');
  1109. REACT_MEMO_TYPE = symbolFor('react.memo');
  1110. REACT_LAZY_TYPE = symbolFor('react.lazy');
  1111. REACT_BLOCK_TYPE = symbolFor('react.block');
  1112. REACT_SERVER_BLOCK_TYPE = symbolFor('react.server.block');
  1113. REACT_FUNDAMENTAL_TYPE = symbolFor('react.fundamental');
  1114. symbolFor('react.scope');
  1115. symbolFor('react.opaque.id');
  1116. REACT_DEBUG_TRACING_MODE_TYPE = symbolFor('react.debug_trace_mode');
  1117. symbolFor('react.offscreen');
  1118. REACT_LEGACY_HIDDEN_TYPE = symbolFor('react.legacy_hidden');
  1119. }
  1120. // Filter certain DOM attributes (e.g. src, href) if their values are empty strings.
  1121. var enableScopeAPI = false; // Experimental Create Event Handle API.
  1122. function isValidElementType(type) {
  1123. if (typeof type === 'string' || typeof type === 'function') {
  1124. return true;
  1125. } // Note: typeof might be other than 'symbol' or 'number' (e.g. if it's a polyfill).
  1126. if (type === REACT_FRAGMENT_TYPE || type === REACT_PROFILER_TYPE || type === REACT_DEBUG_TRACING_MODE_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || type === REACT_LEGACY_HIDDEN_TYPE || enableScopeAPI ) {
  1127. return true;
  1128. }
  1129. if (typeof type === 'object' && type !== null) {
  1130. if (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_BLOCK_TYPE || type[0] === REACT_SERVER_BLOCK_TYPE) {
  1131. return true;
  1132. }
  1133. }
  1134. return false;
  1135. }
  1136. function typeOf(object) {
  1137. if (typeof object === 'object' && object !== null) {
  1138. var $$typeof = object.$$typeof;
  1139. switch ($$typeof) {
  1140. case REACT_ELEMENT_TYPE:
  1141. var type = object.type;
  1142. switch (type) {
  1143. case REACT_FRAGMENT_TYPE:
  1144. case REACT_PROFILER_TYPE:
  1145. case REACT_STRICT_MODE_TYPE:
  1146. case REACT_SUSPENSE_TYPE:
  1147. case REACT_SUSPENSE_LIST_TYPE:
  1148. return type;
  1149. default:
  1150. var $$typeofType = type && type.$$typeof;
  1151. switch ($$typeofType) {
  1152. case REACT_CONTEXT_TYPE:
  1153. case REACT_FORWARD_REF_TYPE:
  1154. case REACT_LAZY_TYPE:
  1155. case REACT_MEMO_TYPE:
  1156. case REACT_PROVIDER_TYPE:
  1157. return $$typeofType;
  1158. default:
  1159. return $$typeof;
  1160. }
  1161. }
  1162. case REACT_PORTAL_TYPE:
  1163. return $$typeof;
  1164. }
  1165. }
  1166. return undefined;
  1167. }
  1168. var ContextConsumer = REACT_CONTEXT_TYPE;
  1169. var ContextProvider = REACT_PROVIDER_TYPE;
  1170. var Element = REACT_ELEMENT_TYPE;
  1171. var ForwardRef = REACT_FORWARD_REF_TYPE;
  1172. var Fragment = REACT_FRAGMENT_TYPE;
  1173. var Lazy = REACT_LAZY_TYPE;
  1174. var Memo = REACT_MEMO_TYPE;
  1175. var Portal = REACT_PORTAL_TYPE;
  1176. var Profiler = REACT_PROFILER_TYPE;
  1177. var StrictMode = REACT_STRICT_MODE_TYPE;
  1178. var Suspense = REACT_SUSPENSE_TYPE;
  1179. var hasWarnedAboutDeprecatedIsAsyncMode = false;
  1180. var hasWarnedAboutDeprecatedIsConcurrentMode = false; // AsyncMode should be deprecated
  1181. function isAsyncMode(object) {
  1182. {
  1183. if (!hasWarnedAboutDeprecatedIsAsyncMode) {
  1184. hasWarnedAboutDeprecatedIsAsyncMode = true; // Using console['warn'] to evade Babel and ESLint
  1185. console['warn']('The ReactIs.isAsyncMode() alias has been deprecated, ' + 'and will be removed in React 18+.');
  1186. }
  1187. }
  1188. return false;
  1189. }
  1190. function isConcurrentMode(object) {
  1191. {
  1192. if (!hasWarnedAboutDeprecatedIsConcurrentMode) {
  1193. hasWarnedAboutDeprecatedIsConcurrentMode = true; // Using console['warn'] to evade Babel and ESLint
  1194. console['warn']('The ReactIs.isConcurrentMode() alias has been deprecated, ' + 'and will be removed in React 18+.');
  1195. }
  1196. }
  1197. return false;
  1198. }
  1199. function isContextConsumer(object) {
  1200. return typeOf(object) === REACT_CONTEXT_TYPE;
  1201. }
  1202. function isContextProvider(object) {
  1203. return typeOf(object) === REACT_PROVIDER_TYPE;
  1204. }
  1205. function isElement(object) {
  1206. return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
  1207. }
  1208. function isForwardRef(object) {
  1209. return typeOf(object) === REACT_FORWARD_REF_TYPE;
  1210. }
  1211. function isFragment(object) {
  1212. return typeOf(object) === REACT_FRAGMENT_TYPE;
  1213. }
  1214. function isLazy(object) {
  1215. return typeOf(object) === REACT_LAZY_TYPE;
  1216. }
  1217. function isMemo(object) {
  1218. return typeOf(object) === REACT_MEMO_TYPE;
  1219. }
  1220. function isPortal(object) {
  1221. return typeOf(object) === REACT_PORTAL_TYPE;
  1222. }
  1223. function isProfiler(object) {
  1224. return typeOf(object) === REACT_PROFILER_TYPE;
  1225. }
  1226. function isStrictMode(object) {
  1227. return typeOf(object) === REACT_STRICT_MODE_TYPE;
  1228. }
  1229. function isSuspense(object) {
  1230. return typeOf(object) === REACT_SUSPENSE_TYPE;
  1231. }
  1232. reactIs_development.ContextConsumer = ContextConsumer;
  1233. reactIs_development.ContextProvider = ContextProvider;
  1234. reactIs_development.Element = Element;
  1235. reactIs_development.ForwardRef = ForwardRef;
  1236. reactIs_development.Fragment = Fragment;
  1237. reactIs_development.Lazy = Lazy;
  1238. reactIs_development.Memo = Memo;
  1239. reactIs_development.Portal = Portal;
  1240. reactIs_development.Profiler = Profiler;
  1241. reactIs_development.StrictMode = StrictMode;
  1242. reactIs_development.Suspense = Suspense;
  1243. reactIs_development.isAsyncMode = isAsyncMode;
  1244. reactIs_development.isConcurrentMode = isConcurrentMode;
  1245. reactIs_development.isContextConsumer = isContextConsumer;
  1246. reactIs_development.isContextProvider = isContextProvider;
  1247. reactIs_development.isElement = isElement;
  1248. reactIs_development.isForwardRef = isForwardRef;
  1249. reactIs_development.isFragment = isFragment;
  1250. reactIs_development.isLazy = isLazy;
  1251. reactIs_development.isMemo = isMemo;
  1252. reactIs_development.isPortal = isPortal;
  1253. reactIs_development.isProfiler = isProfiler;
  1254. reactIs_development.isStrictMode = isStrictMode;
  1255. reactIs_development.isSuspense = isSuspense;
  1256. reactIs_development.isValidElementType = isValidElementType;
  1257. reactIs_development.typeOf = typeOf;
  1258. })();
  1259. }
  1260. return reactIs_development;
  1261. }
  1262. (function (module) {
  1263. if (process.env.NODE_ENV === 'production') {
  1264. module.exports = requireReactIs_production_min();
  1265. } else {
  1266. module.exports = requireReactIs_development();
  1267. }
  1268. } (reactIs));
  1269. Object.defineProperty(ReactElement$1, '__esModule', {
  1270. value: true
  1271. });
  1272. ReactElement$1.test = ReactElement$1.serialize = ReactElement$1.default = void 0;
  1273. var ReactIs = _interopRequireWildcard(reactIs.exports);
  1274. var _markup$1 = markup;
  1275. function _getRequireWildcardCache(nodeInterop) {
  1276. if (typeof WeakMap !== 'function') return null;
  1277. var cacheBabelInterop = new WeakMap();
  1278. var cacheNodeInterop = new WeakMap();
  1279. return (_getRequireWildcardCache = function (nodeInterop) {
  1280. return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
  1281. })(nodeInterop);
  1282. }
  1283. function _interopRequireWildcard(obj, nodeInterop) {
  1284. if (!nodeInterop && obj && obj.__esModule) {
  1285. return obj;
  1286. }
  1287. if (obj === null || (typeof obj !== 'object' && typeof obj !== 'function')) {
  1288. return {default: obj};
  1289. }
  1290. var cache = _getRequireWildcardCache(nodeInterop);
  1291. if (cache && cache.has(obj)) {
  1292. return cache.get(obj);
  1293. }
  1294. var newObj = {};
  1295. var hasPropertyDescriptor =
  1296. Object.defineProperty && Object.getOwnPropertyDescriptor;
  1297. for (var key in obj) {
  1298. if (key !== 'default' && Object.prototype.hasOwnProperty.call(obj, key)) {
  1299. var desc = hasPropertyDescriptor
  1300. ? Object.getOwnPropertyDescriptor(obj, key)
  1301. : null;
  1302. if (desc && (desc.get || desc.set)) {
  1303. Object.defineProperty(newObj, key, desc);
  1304. } else {
  1305. newObj[key] = obj[key];
  1306. }
  1307. }
  1308. }
  1309. newObj.default = obj;
  1310. if (cache) {
  1311. cache.set(obj, newObj);
  1312. }
  1313. return newObj;
  1314. }
  1315. /**
  1316. * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
  1317. *
  1318. * This source code is licensed under the MIT license found in the
  1319. * LICENSE file in the root directory of this source tree.
  1320. */
  1321. // Given element.props.children, or subtree during recursive traversal,
  1322. // return flattened array of children.
  1323. const getChildren = (arg, children = []) => {
  1324. if (Array.isArray(arg)) {
  1325. arg.forEach(item => {
  1326. getChildren(item, children);
  1327. });
  1328. } else if (arg != null && arg !== false) {
  1329. children.push(arg);
  1330. }
  1331. return children;
  1332. };
  1333. const getType = element => {
  1334. const type = element.type;
  1335. if (typeof type === 'string') {
  1336. return type;
  1337. }
  1338. if (typeof type === 'function') {
  1339. return type.displayName || type.name || 'Unknown';
  1340. }
  1341. if (ReactIs.isFragment(element)) {
  1342. return 'React.Fragment';
  1343. }
  1344. if (ReactIs.isSuspense(element)) {
  1345. return 'React.Suspense';
  1346. }
  1347. if (typeof type === 'object' && type !== null) {
  1348. if (ReactIs.isContextProvider(element)) {
  1349. return 'Context.Provider';
  1350. }
  1351. if (ReactIs.isContextConsumer(element)) {
  1352. return 'Context.Consumer';
  1353. }
  1354. if (ReactIs.isForwardRef(element)) {
  1355. if (type.displayName) {
  1356. return type.displayName;
  1357. }
  1358. const functionName = type.render.displayName || type.render.name || '';
  1359. return functionName !== ''
  1360. ? 'ForwardRef(' + functionName + ')'
  1361. : 'ForwardRef';
  1362. }
  1363. if (ReactIs.isMemo(element)) {
  1364. const functionName =
  1365. type.displayName || type.type.displayName || type.type.name || '';
  1366. return functionName !== '' ? 'Memo(' + functionName + ')' : 'Memo';
  1367. }
  1368. }
  1369. return 'UNDEFINED';
  1370. };
  1371. const getPropKeys$1 = element => {
  1372. const {props} = element;
  1373. return Object.keys(props)
  1374. .filter(key => key !== 'children' && props[key] !== undefined)
  1375. .sort();
  1376. };
  1377. const serialize$1 = (element, config, indentation, depth, refs, printer) =>
  1378. ++depth > config.maxDepth
  1379. ? (0, _markup$1.printElementAsLeaf)(getType(element), config)
  1380. : (0, _markup$1.printElement)(
  1381. getType(element),
  1382. (0, _markup$1.printProps)(
  1383. getPropKeys$1(element),
  1384. element.props,
  1385. config,
  1386. indentation + config.indent,
  1387. depth,
  1388. refs,
  1389. printer
  1390. ),
  1391. (0, _markup$1.printChildren)(
  1392. getChildren(element.props.children),
  1393. config,
  1394. indentation + config.indent,
  1395. depth,
  1396. refs,
  1397. printer
  1398. ),
  1399. config,
  1400. indentation
  1401. );
  1402. ReactElement$1.serialize = serialize$1;
  1403. const test$1 = val => val != null && ReactIs.isElement(val);
  1404. ReactElement$1.test = test$1;
  1405. const plugin$1 = {
  1406. serialize: serialize$1,
  1407. test: test$1
  1408. };
  1409. var _default$2 = plugin$1;
  1410. ReactElement$1.default = _default$2;
  1411. var ReactTestComponent$1 = {};
  1412. Object.defineProperty(ReactTestComponent$1, '__esModule', {
  1413. value: true
  1414. });
  1415. ReactTestComponent$1.test = ReactTestComponent$1.serialize = ReactTestComponent$1.default = void 0;
  1416. var _markup = markup;
  1417. var global = (function () {
  1418. if (typeof globalThis !== 'undefined') {
  1419. return globalThis;
  1420. } else if (typeof global !== 'undefined') {
  1421. return global;
  1422. } else if (typeof self !== 'undefined') {
  1423. return self;
  1424. } else if (typeof window !== 'undefined') {
  1425. return window;
  1426. } else {
  1427. return Function('return this')();
  1428. }
  1429. })();
  1430. var Symbol$1 = global['jest-symbol-do-not-touch'] || global.Symbol;
  1431. const testSymbol =
  1432. typeof Symbol$1 === 'function' && Symbol$1.for
  1433. ? Symbol$1.for('react.test.json')
  1434. : 0xea71357;
  1435. const getPropKeys = object => {
  1436. const {props} = object;
  1437. return props
  1438. ? Object.keys(props)
  1439. .filter(key => props[key] !== undefined)
  1440. .sort()
  1441. : [];
  1442. };
  1443. const serialize = (object, config, indentation, depth, refs, printer) =>
  1444. ++depth > config.maxDepth
  1445. ? (0, _markup.printElementAsLeaf)(object.type, config)
  1446. : (0, _markup.printElement)(
  1447. object.type,
  1448. object.props
  1449. ? (0, _markup.printProps)(
  1450. getPropKeys(object),
  1451. object.props,
  1452. config,
  1453. indentation + config.indent,
  1454. depth,
  1455. refs,
  1456. printer
  1457. )
  1458. : '',
  1459. object.children
  1460. ? (0, _markup.printChildren)(
  1461. object.children,
  1462. config,
  1463. indentation + config.indent,
  1464. depth,
  1465. refs,
  1466. printer
  1467. )
  1468. : '',
  1469. config,
  1470. indentation
  1471. );
  1472. ReactTestComponent$1.serialize = serialize;
  1473. const test = val => val && val.$$typeof === testSymbol;
  1474. ReactTestComponent$1.test = test;
  1475. const plugin = {
  1476. serialize,
  1477. test
  1478. };
  1479. var _default$1 = plugin;
  1480. ReactTestComponent$1.default = _default$1;
  1481. Object.defineProperty(build, '__esModule', {
  1482. value: true
  1483. });
  1484. build.default = build.DEFAULT_OPTIONS = void 0;
  1485. var format_1 = build.format = format;
  1486. var plugins_1 = build.plugins = void 0;
  1487. var _ansiStyles = _interopRequireDefault(ansiStyles$1.exports);
  1488. var _collections = collections;
  1489. var _AsymmetricMatcher = _interopRequireDefault(
  1490. AsymmetricMatcher$1
  1491. );
  1492. var _ConvertAnsi = _interopRequireDefault(ConvertAnsi);
  1493. var _DOMCollection = _interopRequireDefault(DOMCollection$1);
  1494. var _DOMElement = _interopRequireDefault(DOMElement$1);
  1495. var _Immutable = _interopRequireDefault(Immutable$1);
  1496. var _ReactElement = _interopRequireDefault(ReactElement$1);
  1497. var _ReactTestComponent = _interopRequireDefault(
  1498. ReactTestComponent$1
  1499. );
  1500. function _interopRequireDefault(obj) {
  1501. return obj && obj.__esModule ? obj : {default: obj};
  1502. }
  1503. /**
  1504. * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
  1505. *
  1506. * This source code is licensed under the MIT license found in the
  1507. * LICENSE file in the root directory of this source tree.
  1508. */
  1509. /* eslint-disable local/ban-types-eventually */
  1510. const toString = Object.prototype.toString;
  1511. const toISOString = Date.prototype.toISOString;
  1512. const errorToString = Error.prototype.toString;
  1513. const regExpToString = RegExp.prototype.toString;
  1514. /**
  1515. * Explicitly comparing typeof constructor to function avoids undefined as name
  1516. * when mock identity-obj-proxy returns the key as the value for any key.
  1517. */
  1518. const getConstructorName = val =>
  1519. (typeof val.constructor === 'function' && val.constructor.name) || 'Object';
  1520. /* global window */
  1521. /** Is val is equal to global window object? Works even if it does not exist :) */
  1522. const isWindow = val => typeof window !== 'undefined' && val === window;
  1523. const SYMBOL_REGEXP = /^Symbol\((.*)\)(.*)$/;
  1524. const NEWLINE_REGEXP = /\n/gi;
  1525. class PrettyFormatPluginError extends Error {
  1526. constructor(message, stack) {
  1527. super(message);
  1528. this.stack = stack;
  1529. this.name = this.constructor.name;
  1530. }
  1531. }
  1532. function isToStringedArrayType(toStringed) {
  1533. return (
  1534. toStringed === '[object Array]' ||
  1535. toStringed === '[object ArrayBuffer]' ||
  1536. toStringed === '[object DataView]' ||
  1537. toStringed === '[object Float32Array]' ||
  1538. toStringed === '[object Float64Array]' ||
  1539. toStringed === '[object Int8Array]' ||
  1540. toStringed === '[object Int16Array]' ||
  1541. toStringed === '[object Int32Array]' ||
  1542. toStringed === '[object Uint8Array]' ||
  1543. toStringed === '[object Uint8ClampedArray]' ||
  1544. toStringed === '[object Uint16Array]' ||
  1545. toStringed === '[object Uint32Array]'
  1546. );
  1547. }
  1548. function printNumber(val) {
  1549. return Object.is(val, -0) ? '-0' : String(val);
  1550. }
  1551. function printBigInt(val) {
  1552. return String(`${val}n`);
  1553. }
  1554. function printFunction(val, printFunctionName) {
  1555. if (!printFunctionName) {
  1556. return '[Function]';
  1557. }
  1558. return '[Function ' + (val.name || 'anonymous') + ']';
  1559. }
  1560. function printSymbol(val) {
  1561. return String(val).replace(SYMBOL_REGEXP, 'Symbol($1)');
  1562. }
  1563. function printError(val) {
  1564. return '[' + errorToString.call(val) + ']';
  1565. }
  1566. /**
  1567. * The first port of call for printing an object, handles most of the
  1568. * data-types in JS.
  1569. */
  1570. function printBasicValue(val, printFunctionName, escapeRegex, escapeString) {
  1571. if (val === true || val === false) {
  1572. return '' + val;
  1573. }
  1574. if (val === undefined) {
  1575. return 'undefined';
  1576. }
  1577. if (val === null) {
  1578. return 'null';
  1579. }
  1580. const typeOf = typeof val;
  1581. if (typeOf === 'number') {
  1582. return printNumber(val);
  1583. }
  1584. if (typeOf === 'bigint') {
  1585. return printBigInt(val);
  1586. }
  1587. if (typeOf === 'string') {
  1588. if (escapeString) {
  1589. return '"' + val.replace(/"|\\/g, '\\$&') + '"';
  1590. }
  1591. return '"' + val + '"';
  1592. }
  1593. if (typeOf === 'function') {
  1594. return printFunction(val, printFunctionName);
  1595. }
  1596. if (typeOf === 'symbol') {
  1597. return printSymbol(val);
  1598. }
  1599. const toStringed = toString.call(val);
  1600. if (toStringed === '[object WeakMap]') {
  1601. return 'WeakMap {}';
  1602. }
  1603. if (toStringed === '[object WeakSet]') {
  1604. return 'WeakSet {}';
  1605. }
  1606. if (
  1607. toStringed === '[object Function]' ||
  1608. toStringed === '[object GeneratorFunction]'
  1609. ) {
  1610. return printFunction(val, printFunctionName);
  1611. }
  1612. if (toStringed === '[object Symbol]') {
  1613. return printSymbol(val);
  1614. }
  1615. if (toStringed === '[object Date]') {
  1616. return isNaN(+val) ? 'Date { NaN }' : toISOString.call(val);
  1617. }
  1618. if (toStringed === '[object Error]') {
  1619. return printError(val);
  1620. }
  1621. if (toStringed === '[object RegExp]') {
  1622. if (escapeRegex) {
  1623. // https://github.com/benjamingr/RegExp.escape/blob/main/polyfill.js
  1624. return regExpToString.call(val).replace(/[\\^$*+?.()|[\]{}]/g, '\\$&');
  1625. }
  1626. return regExpToString.call(val);
  1627. }
  1628. if (val instanceof Error) {
  1629. return printError(val);
  1630. }
  1631. return null;
  1632. }
  1633. /**
  1634. * Handles more complex objects ( such as objects with circular references.
  1635. * maps and sets etc )
  1636. */
  1637. function printComplexValue(
  1638. val,
  1639. config,
  1640. indentation,
  1641. depth,
  1642. refs,
  1643. hasCalledToJSON
  1644. ) {
  1645. if (refs.indexOf(val) !== -1) {
  1646. return '[Circular]';
  1647. }
  1648. refs = refs.slice();
  1649. refs.push(val);
  1650. const hitMaxDepth = ++depth > config.maxDepth;
  1651. const min = config.min;
  1652. if (
  1653. config.callToJSON &&
  1654. !hitMaxDepth &&
  1655. val.toJSON &&
  1656. typeof val.toJSON === 'function' &&
  1657. !hasCalledToJSON
  1658. ) {
  1659. return printer(val.toJSON(), config, indentation, depth, refs, true);
  1660. }
  1661. const toStringed = toString.call(val);
  1662. if (toStringed === '[object Arguments]') {
  1663. return hitMaxDepth
  1664. ? '[Arguments]'
  1665. : (min ? '' : 'Arguments ') +
  1666. '[' +
  1667. (0, _collections.printListItems)(
  1668. val,
  1669. config,
  1670. indentation,
  1671. depth,
  1672. refs,
  1673. printer
  1674. ) +
  1675. ']';
  1676. }
  1677. if (isToStringedArrayType(toStringed)) {
  1678. return hitMaxDepth
  1679. ? '[' + val.constructor.name + ']'
  1680. : (min
  1681. ? ''
  1682. : !config.printBasicPrototype && val.constructor.name === 'Array'
  1683. ? ''
  1684. : val.constructor.name + ' ') +
  1685. '[' +
  1686. (0, _collections.printListItems)(
  1687. val,
  1688. config,
  1689. indentation,
  1690. depth,
  1691. refs,
  1692. printer
  1693. ) +
  1694. ']';
  1695. }
  1696. if (toStringed === '[object Map]') {
  1697. return hitMaxDepth
  1698. ? '[Map]'
  1699. : 'Map {' +
  1700. (0, _collections.printIteratorEntries)(
  1701. val.entries(),
  1702. config,
  1703. indentation,
  1704. depth,
  1705. refs,
  1706. printer,
  1707. ' => '
  1708. ) +
  1709. '}';
  1710. }
  1711. if (toStringed === '[object Set]') {
  1712. return hitMaxDepth
  1713. ? '[Set]'
  1714. : 'Set {' +
  1715. (0, _collections.printIteratorValues)(
  1716. val.values(),
  1717. config,
  1718. indentation,
  1719. depth,
  1720. refs,
  1721. printer
  1722. ) +
  1723. '}';
  1724. } // Avoid failure to serialize global window object in jsdom test environment.
  1725. // For example, not even relevant if window is prop of React element.
  1726. return hitMaxDepth || isWindow(val)
  1727. ? '[' + getConstructorName(val) + ']'
  1728. : (min
  1729. ? ''
  1730. : !config.printBasicPrototype && getConstructorName(val) === 'Object'
  1731. ? ''
  1732. : getConstructorName(val) + ' ') +
  1733. '{' +
  1734. (0, _collections.printObjectProperties)(
  1735. val,
  1736. config,
  1737. indentation,
  1738. depth,
  1739. refs,
  1740. printer
  1741. ) +
  1742. '}';
  1743. }
  1744. function isNewPlugin(plugin) {
  1745. return plugin.serialize != null;
  1746. }
  1747. function printPlugin(plugin, val, config, indentation, depth, refs) {
  1748. let printed;
  1749. try {
  1750. printed = isNewPlugin(plugin)
  1751. ? plugin.serialize(val, config, indentation, depth, refs, printer)
  1752. : plugin.print(
  1753. val,
  1754. valChild => printer(valChild, config, indentation, depth, refs),
  1755. str => {
  1756. const indentationNext = indentation + config.indent;
  1757. return (
  1758. indentationNext +
  1759. str.replace(NEWLINE_REGEXP, '\n' + indentationNext)
  1760. );
  1761. },
  1762. {
  1763. edgeSpacing: config.spacingOuter,
  1764. min: config.min,
  1765. spacing: config.spacingInner
  1766. },
  1767. config.colors
  1768. );
  1769. } catch (error) {
  1770. throw new PrettyFormatPluginError(error.message, error.stack);
  1771. }
  1772. if (typeof printed !== 'string') {
  1773. throw new Error(
  1774. `pretty-format: Plugin must return type "string" but instead returned "${typeof printed}".`
  1775. );
  1776. }
  1777. return printed;
  1778. }
  1779. function findPlugin(plugins, val) {
  1780. for (let p = 0; p < plugins.length; p++) {
  1781. try {
  1782. if (plugins[p].test(val)) {
  1783. return plugins[p];
  1784. }
  1785. } catch (error) {
  1786. throw new PrettyFormatPluginError(error.message, error.stack);
  1787. }
  1788. }
  1789. return null;
  1790. }
  1791. function printer(val, config, indentation, depth, refs, hasCalledToJSON) {
  1792. const plugin = findPlugin(config.plugins, val);
  1793. if (plugin !== null) {
  1794. return printPlugin(plugin, val, config, indentation, depth, refs);
  1795. }
  1796. const basicResult = printBasicValue(
  1797. val,
  1798. config.printFunctionName,
  1799. config.escapeRegex,
  1800. config.escapeString
  1801. );
  1802. if (basicResult !== null) {
  1803. return basicResult;
  1804. }
  1805. return printComplexValue(
  1806. val,
  1807. config,
  1808. indentation,
  1809. depth,
  1810. refs,
  1811. hasCalledToJSON
  1812. );
  1813. }
  1814. const DEFAULT_THEME = {
  1815. comment: 'gray',
  1816. content: 'reset',
  1817. prop: 'yellow',
  1818. tag: 'cyan',
  1819. value: 'green'
  1820. };
  1821. const DEFAULT_THEME_KEYS = Object.keys(DEFAULT_THEME);
  1822. const DEFAULT_OPTIONS = {
  1823. callToJSON: true,
  1824. compareKeys: undefined,
  1825. escapeRegex: false,
  1826. escapeString: true,
  1827. highlight: false,
  1828. indent: 2,
  1829. maxDepth: Infinity,
  1830. min: false,
  1831. plugins: [],
  1832. printBasicPrototype: true,
  1833. printFunctionName: true,
  1834. theme: DEFAULT_THEME
  1835. };
  1836. build.DEFAULT_OPTIONS = DEFAULT_OPTIONS;
  1837. function validateOptions(options) {
  1838. Object.keys(options).forEach(key => {
  1839. if (!DEFAULT_OPTIONS.hasOwnProperty(key)) {
  1840. throw new Error(`pretty-format: Unknown option "${key}".`);
  1841. }
  1842. });
  1843. if (options.min && options.indent !== undefined && options.indent !== 0) {
  1844. throw new Error(
  1845. 'pretty-format: Options "min" and "indent" cannot be used together.'
  1846. );
  1847. }
  1848. if (options.theme !== undefined) {
  1849. if (options.theme === null) {
  1850. throw new Error('pretty-format: Option "theme" must not be null.');
  1851. }
  1852. if (typeof options.theme !== 'object') {
  1853. throw new Error(
  1854. `pretty-format: Option "theme" must be of type "object" but instead received "${typeof options.theme}".`
  1855. );
  1856. }
  1857. }
  1858. }
  1859. const getColorsHighlight = options =>
  1860. DEFAULT_THEME_KEYS.reduce((colors, key) => {
  1861. const value =
  1862. options.theme && options.theme[key] !== undefined
  1863. ? options.theme[key]
  1864. : DEFAULT_THEME[key];
  1865. const color = value && _ansiStyles.default[value];
  1866. if (
  1867. color &&
  1868. typeof color.close === 'string' &&
  1869. typeof color.open === 'string'
  1870. ) {
  1871. colors[key] = color;
  1872. } else {
  1873. throw new Error(
  1874. `pretty-format: Option "theme" has a key "${key}" whose value "${value}" is undefined in ansi-styles.`
  1875. );
  1876. }
  1877. return colors;
  1878. }, Object.create(null));
  1879. const getColorsEmpty = () =>
  1880. DEFAULT_THEME_KEYS.reduce((colors, key) => {
  1881. colors[key] = {
  1882. close: '',
  1883. open: ''
  1884. };
  1885. return colors;
  1886. }, Object.create(null));
  1887. const getPrintFunctionName = options =>
  1888. options && options.printFunctionName !== undefined
  1889. ? options.printFunctionName
  1890. : DEFAULT_OPTIONS.printFunctionName;
  1891. const getEscapeRegex = options =>
  1892. options && options.escapeRegex !== undefined
  1893. ? options.escapeRegex
  1894. : DEFAULT_OPTIONS.escapeRegex;
  1895. const getEscapeString = options =>
  1896. options && options.escapeString !== undefined
  1897. ? options.escapeString
  1898. : DEFAULT_OPTIONS.escapeString;
  1899. const getConfig = options => {
  1900. var _options$printBasicPr;
  1901. return {
  1902. callToJSON:
  1903. options && options.callToJSON !== undefined
  1904. ? options.callToJSON
  1905. : DEFAULT_OPTIONS.callToJSON,
  1906. colors:
  1907. options && options.highlight
  1908. ? getColorsHighlight(options)
  1909. : getColorsEmpty(),
  1910. compareKeys:
  1911. options && typeof options.compareKeys === 'function'
  1912. ? options.compareKeys
  1913. : DEFAULT_OPTIONS.compareKeys,
  1914. escapeRegex: getEscapeRegex(options),
  1915. escapeString: getEscapeString(options),
  1916. indent:
  1917. options && options.min
  1918. ? ''
  1919. : createIndent(
  1920. options && options.indent !== undefined
  1921. ? options.indent
  1922. : DEFAULT_OPTIONS.indent
  1923. ),
  1924. maxDepth:
  1925. options && options.maxDepth !== undefined
  1926. ? options.maxDepth
  1927. : DEFAULT_OPTIONS.maxDepth,
  1928. min:
  1929. options && options.min !== undefined ? options.min : DEFAULT_OPTIONS.min,
  1930. plugins:
  1931. options && options.plugins !== undefined
  1932. ? options.plugins
  1933. : DEFAULT_OPTIONS.plugins,
  1934. printBasicPrototype:
  1935. (_options$printBasicPr =
  1936. options === null || options === void 0
  1937. ? void 0
  1938. : options.printBasicPrototype) !== null &&
  1939. _options$printBasicPr !== void 0
  1940. ? _options$printBasicPr
  1941. : true,
  1942. printFunctionName: getPrintFunctionName(options),
  1943. spacingInner: options && options.min ? ' ' : '\n',
  1944. spacingOuter: options && options.min ? '' : '\n'
  1945. };
  1946. };
  1947. function createIndent(indent) {
  1948. return new Array(indent + 1).join(' ');
  1949. }
  1950. /**
  1951. * Returns a presentation string of your `val` object
  1952. * @param val any potential JavaScript object
  1953. * @param options Custom settings
  1954. */
  1955. function format(val, options) {
  1956. if (options) {
  1957. validateOptions(options);
  1958. if (options.plugins) {
  1959. const plugin = findPlugin(options.plugins, val);
  1960. if (plugin !== null) {
  1961. return printPlugin(plugin, val, getConfig(options), '', 0, []);
  1962. }
  1963. }
  1964. }
  1965. const basicResult = printBasicValue(
  1966. val,
  1967. getPrintFunctionName(options),
  1968. getEscapeRegex(options),
  1969. getEscapeString(options)
  1970. );
  1971. if (basicResult !== null) {
  1972. return basicResult;
  1973. }
  1974. return printComplexValue(val, getConfig(options), '', 0, []);
  1975. }
  1976. const plugins = {
  1977. AsymmetricMatcher: _AsymmetricMatcher.default,
  1978. ConvertAnsi: _ConvertAnsi.default,
  1979. DOMCollection: _DOMCollection.default,
  1980. DOMElement: _DOMElement.default,
  1981. Immutable: _Immutable.default,
  1982. ReactElement: _ReactElement.default,
  1983. ReactTestComponent: _ReactTestComponent.default
  1984. };
  1985. plugins_1 = build.plugins = plugins;
  1986. var _default = format;
  1987. build.default = _default;
  1988. var sourceMapGenerator = {};
  1989. var base64Vlq = {};
  1990. var base64$1 = {};
  1991. /* -*- Mode: js; js-indent-level: 2; -*- */
  1992. /*
  1993. * Copyright 2011 Mozilla Foundation and contributors
  1994. * Licensed under the New BSD license. See LICENSE or:
  1995. * http://opensource.org/licenses/BSD-3-Clause
  1996. */
  1997. var intToCharMap = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'.split('');
  1998. /**
  1999. * Encode an integer in the range of 0 to 63 to a single base 64 digit.
  2000. */
  2001. base64$1.encode = function (number) {
  2002. if (0 <= number && number < intToCharMap.length) {
  2003. return intToCharMap[number];
  2004. }
  2005. throw new TypeError("Must be between 0 and 63: " + number);
  2006. };
  2007. /**
  2008. * Decode a single base 64 character code digit to an integer. Returns -1 on
  2009. * failure.
  2010. */
  2011. base64$1.decode = function (charCode) {
  2012. var bigA = 65; // 'A'
  2013. var bigZ = 90; // 'Z'
  2014. var littleA = 97; // 'a'
  2015. var littleZ = 122; // 'z'
  2016. var zero = 48; // '0'
  2017. var nine = 57; // '9'
  2018. var plus = 43; // '+'
  2019. var slash = 47; // '/'
  2020. var littleOffset = 26;
  2021. var numberOffset = 52;
  2022. // 0 - 25: ABCDEFGHIJKLMNOPQRSTUVWXYZ
  2023. if (bigA <= charCode && charCode <= bigZ) {
  2024. return (charCode - bigA);
  2025. }
  2026. // 26 - 51: abcdefghijklmnopqrstuvwxyz
  2027. if (littleA <= charCode && charCode <= littleZ) {
  2028. return (charCode - littleA + littleOffset);
  2029. }
  2030. // 52 - 61: 0123456789
  2031. if (zero <= charCode && charCode <= nine) {
  2032. return (charCode - zero + numberOffset);
  2033. }
  2034. // 62: +
  2035. if (charCode == plus) {
  2036. return 62;
  2037. }
  2038. // 63: /
  2039. if (charCode == slash) {
  2040. return 63;
  2041. }
  2042. // Invalid base64 digit.
  2043. return -1;
  2044. };
  2045. /* -*- Mode: js; js-indent-level: 2; -*- */
  2046. /*
  2047. * Copyright 2011 Mozilla Foundation and contributors
  2048. * Licensed under the New BSD license. See LICENSE or:
  2049. * http://opensource.org/licenses/BSD-3-Clause
  2050. *
  2051. * Based on the Base 64 VLQ implementation in Closure Compiler:
  2052. * https://code.google.com/p/closure-compiler/source/browse/trunk/src/com/google/debugging/sourcemap/Base64VLQ.java
  2053. *
  2054. * Copyright 2011 The Closure Compiler Authors. All rights reserved.
  2055. * Redistribution and use in source and binary forms, with or without
  2056. * modification, are permitted provided that the following conditions are
  2057. * met:
  2058. *
  2059. * * Redistributions of source code must retain the above copyright
  2060. * notice, this list of conditions and the following disclaimer.
  2061. * * Redistributions in binary form must reproduce the above
  2062. * copyright notice, this list of conditions and the following
  2063. * disclaimer in the documentation and/or other materials provided
  2064. * with the distribution.
  2065. * * Neither the name of Google Inc. nor the names of its
  2066. * contributors may be used to endorse or promote products derived
  2067. * from this software without specific prior written permission.
  2068. *
  2069. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  2070. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  2071. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  2072. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  2073. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  2074. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  2075. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  2076. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  2077. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  2078. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  2079. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  2080. */
  2081. var base64 = base64$1;
  2082. // A single base 64 digit can contain 6 bits of data. For the base 64 variable
  2083. // length quantities we use in the source map spec, the first bit is the sign,
  2084. // the next four bits are the actual value, and the 6th bit is the
  2085. // continuation bit. The continuation bit tells us whether there are more
  2086. // digits in this value following this digit.
  2087. //
  2088. // Continuation
  2089. // | Sign
  2090. // | |
  2091. // V V
  2092. // 101011
  2093. var VLQ_BASE_SHIFT = 5;
  2094. // binary: 100000
  2095. var VLQ_BASE = 1 << VLQ_BASE_SHIFT;
  2096. // binary: 011111
  2097. var VLQ_BASE_MASK = VLQ_BASE - 1;
  2098. // binary: 100000
  2099. var VLQ_CONTINUATION_BIT = VLQ_BASE;
  2100. /**
  2101. * Converts from a two-complement value to a value where the sign bit is
  2102. * placed in the least significant bit. For example, as decimals:
  2103. * 1 becomes 2 (10 binary), -1 becomes 3 (11 binary)
  2104. * 2 becomes 4 (100 binary), -2 becomes 5 (101 binary)
  2105. */
  2106. function toVLQSigned(aValue) {
  2107. return aValue < 0
  2108. ? ((-aValue) << 1) + 1
  2109. : (aValue << 1) + 0;
  2110. }
  2111. /**
  2112. * Converts to a two-complement value from a value where the sign bit is
  2113. * placed in the least significant bit. For example, as decimals:
  2114. * 2 (10 binary) becomes 1, 3 (11 binary) becomes -1
  2115. * 4 (100 binary) becomes 2, 5 (101 binary) becomes -2
  2116. */
  2117. function fromVLQSigned(aValue) {
  2118. var isNegative = (aValue & 1) === 1;
  2119. var shifted = aValue >> 1;
  2120. return isNegative
  2121. ? -shifted
  2122. : shifted;
  2123. }
  2124. /**
  2125. * Returns the base 64 VLQ encoded value.
  2126. */
  2127. base64Vlq.encode = function base64VLQ_encode(aValue) {
  2128. var encoded = "";
  2129. var digit;
  2130. var vlq = toVLQSigned(aValue);
  2131. do {
  2132. digit = vlq & VLQ_BASE_MASK;
  2133. vlq >>>= VLQ_BASE_SHIFT;
  2134. if (vlq > 0) {
  2135. // There are still more digits in this value, so we must make sure the
  2136. // continuation bit is marked.
  2137. digit |= VLQ_CONTINUATION_BIT;
  2138. }
  2139. encoded += base64.encode(digit);
  2140. } while (vlq > 0);
  2141. return encoded;
  2142. };
  2143. /**
  2144. * Decodes the next base 64 VLQ value from the given string and returns the
  2145. * value and the rest of the string via the out parameter.
  2146. */
  2147. base64Vlq.decode = function base64VLQ_decode(aStr, aIndex, aOutParam) {
  2148. var strLen = aStr.length;
  2149. var result = 0;
  2150. var shift = 0;
  2151. var continuation, digit;
  2152. do {
  2153. if (aIndex >= strLen) {
  2154. throw new Error("Expected more digits in base 64 VLQ value.");
  2155. }
  2156. digit = base64.decode(aStr.charCodeAt(aIndex++));
  2157. if (digit === -1) {
  2158. throw new Error("Invalid base64 digit: " + aStr.charAt(aIndex - 1));
  2159. }
  2160. continuation = !!(digit & VLQ_CONTINUATION_BIT);
  2161. digit &= VLQ_BASE_MASK;
  2162. result = result + (digit << shift);
  2163. shift += VLQ_BASE_SHIFT;
  2164. } while (continuation);
  2165. aOutParam.value = fromVLQSigned(result);
  2166. aOutParam.rest = aIndex;
  2167. };
  2168. var util$5 = {};
  2169. /* -*- Mode: js; js-indent-level: 2; -*- */
  2170. (function (exports) {
  2171. /*
  2172. * Copyright 2011 Mozilla Foundation and contributors
  2173. * Licensed under the New BSD license. See LICENSE or:
  2174. * http://opensource.org/licenses/BSD-3-Clause
  2175. */
  2176. /**
  2177. * This is a helper function for getting values from parameter/options
  2178. * objects.
  2179. *
  2180. * @param args The object we are extracting values from
  2181. * @param name The name of the property we are getting.
  2182. * @param defaultValue An optional value to return if the property is missing
  2183. * from the object. If this is not specified and the property is missing, an
  2184. * error will be thrown.
  2185. */
  2186. function getArg(aArgs, aName, aDefaultValue) {
  2187. if (aName in aArgs) {
  2188. return aArgs[aName];
  2189. } else if (arguments.length === 3) {
  2190. return aDefaultValue;
  2191. } else {
  2192. throw new Error('"' + aName + '" is a required argument.');
  2193. }
  2194. }
  2195. exports.getArg = getArg;
  2196. var urlRegexp = /^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.-]*)(?::(\d+))?(.*)$/;
  2197. var dataUrlRegexp = /^data:.+\,.+$/;
  2198. function urlParse(aUrl) {
  2199. var match = aUrl.match(urlRegexp);
  2200. if (!match) {
  2201. return null;
  2202. }
  2203. return {
  2204. scheme: match[1],
  2205. auth: match[2],
  2206. host: match[3],
  2207. port: match[4],
  2208. path: match[5]
  2209. };
  2210. }
  2211. exports.urlParse = urlParse;
  2212. function urlGenerate(aParsedUrl) {
  2213. var url = '';
  2214. if (aParsedUrl.scheme) {
  2215. url += aParsedUrl.scheme + ':';
  2216. }
  2217. url += '//';
  2218. if (aParsedUrl.auth) {
  2219. url += aParsedUrl.auth + '@';
  2220. }
  2221. if (aParsedUrl.host) {
  2222. url += aParsedUrl.host;
  2223. }
  2224. if (aParsedUrl.port) {
  2225. url += ":" + aParsedUrl.port;
  2226. }
  2227. if (aParsedUrl.path) {
  2228. url += aParsedUrl.path;
  2229. }
  2230. return url;
  2231. }
  2232. exports.urlGenerate = urlGenerate;
  2233. var MAX_CACHED_INPUTS = 32;
  2234. /**
  2235. * Takes some function `f(input) -> result` and returns a memoized version of
  2236. * `f`.
  2237. *
  2238. * We keep at most `MAX_CACHED_INPUTS` memoized results of `f` alive. The
  2239. * memoization is a dumb-simple, linear least-recently-used cache.
  2240. */
  2241. function lruMemoize(f) {
  2242. var cache = [];
  2243. return function(input) {
  2244. for (var i = 0; i < cache.length; i++) {
  2245. if (cache[i].input === input) {
  2246. var temp = cache[0];
  2247. cache[0] = cache[i];
  2248. cache[i] = temp;
  2249. return cache[0].result;
  2250. }
  2251. }
  2252. var result = f(input);
  2253. cache.unshift({
  2254. input,
  2255. result,
  2256. });
  2257. if (cache.length > MAX_CACHED_INPUTS) {
  2258. cache.pop();
  2259. }
  2260. return result;
  2261. };
  2262. }
  2263. /**
  2264. * Normalizes a path, or the path portion of a URL:
  2265. *
  2266. * - Replaces consecutive slashes with one slash.
  2267. * - Removes unnecessary '.' parts.
  2268. * - Removes unnecessary '<dir>/..' parts.
  2269. *
  2270. * Based on code in the Node.js 'path' core module.
  2271. *
  2272. * @param aPath The path or url to normalize.
  2273. */
  2274. var normalize = lruMemoize(function normalize(aPath) {
  2275. var path = aPath;
  2276. var url = urlParse(aPath);
  2277. if (url) {
  2278. if (!url.path) {
  2279. return aPath;
  2280. }
  2281. path = url.path;
  2282. }
  2283. var isAbsolute = exports.isAbsolute(path);
  2284. // Split the path into parts between `/` characters. This is much faster than
  2285. // using `.split(/\/+/g)`.
  2286. var parts = [];
  2287. var start = 0;
  2288. var i = 0;
  2289. while (true) {
  2290. start = i;
  2291. i = path.indexOf("/", start);
  2292. if (i === -1) {
  2293. parts.push(path.slice(start));
  2294. break;
  2295. } else {
  2296. parts.push(path.slice(start, i));
  2297. while (i < path.length && path[i] === "/") {
  2298. i++;
  2299. }
  2300. }
  2301. }
  2302. for (var part, up = 0, i = parts.length - 1; i >= 0; i--) {
  2303. part = parts[i];
  2304. if (part === '.') {
  2305. parts.splice(i, 1);
  2306. } else if (part === '..') {
  2307. up++;
  2308. } else if (up > 0) {
  2309. if (part === '') {
  2310. // The first part is blank if the path is absolute. Trying to go
  2311. // above the root is a no-op. Therefore we can remove all '..' parts
  2312. // directly after the root.
  2313. parts.splice(i + 1, up);
  2314. up = 0;
  2315. } else {
  2316. parts.splice(i, 2);
  2317. up--;
  2318. }
  2319. }
  2320. }
  2321. path = parts.join('/');
  2322. if (path === '') {
  2323. path = isAbsolute ? '/' : '.';
  2324. }
  2325. if (url) {
  2326. url.path = path;
  2327. return urlGenerate(url);
  2328. }
  2329. return path;
  2330. });
  2331. exports.normalize = normalize;
  2332. /**
  2333. * Joins two paths/URLs.
  2334. *
  2335. * @param aRoot The root path or URL.
  2336. * @param aPath The path or URL to be joined with the root.
  2337. *
  2338. * - If aPath is a URL or a data URI, aPath is returned, unless aPath is a
  2339. * scheme-relative URL: Then the scheme of aRoot, if any, is prepended
  2340. * first.
  2341. * - Otherwise aPath is a path. If aRoot is a URL, then its path portion
  2342. * is updated with the result and aRoot is returned. Otherwise the result
  2343. * is returned.
  2344. * - If aPath is absolute, the result is aPath.
  2345. * - Otherwise the two paths are joined with a slash.
  2346. * - Joining for example 'http://' and 'www.example.com' is also supported.
  2347. */
  2348. function join(aRoot, aPath) {
  2349. if (aRoot === "") {
  2350. aRoot = ".";
  2351. }
  2352. if (aPath === "") {
  2353. aPath = ".";
  2354. }
  2355. var aPathUrl = urlParse(aPath);
  2356. var aRootUrl = urlParse(aRoot);
  2357. if (aRootUrl) {
  2358. aRoot = aRootUrl.path || '/';
  2359. }
  2360. // `join(foo, '//www.example.org')`
  2361. if (aPathUrl && !aPathUrl.scheme) {
  2362. if (aRootUrl) {
  2363. aPathUrl.scheme = aRootUrl.scheme;
  2364. }
  2365. return urlGenerate(aPathUrl);
  2366. }
  2367. if (aPathUrl || aPath.match(dataUrlRegexp)) {
  2368. return aPath;
  2369. }
  2370. // `join('http://', 'www.example.com')`
  2371. if (aRootUrl && !aRootUrl.host && !aRootUrl.path) {
  2372. aRootUrl.host = aPath;
  2373. return urlGenerate(aRootUrl);
  2374. }
  2375. var joined = aPath.charAt(0) === '/'
  2376. ? aPath
  2377. : normalize(aRoot.replace(/\/+$/, '') + '/' + aPath);
  2378. if (aRootUrl) {
  2379. aRootUrl.path = joined;
  2380. return urlGenerate(aRootUrl);
  2381. }
  2382. return joined;
  2383. }
  2384. exports.join = join;
  2385. exports.isAbsolute = function (aPath) {
  2386. return aPath.charAt(0) === '/' || urlRegexp.test(aPath);
  2387. };
  2388. /**
  2389. * Make a path relative to a URL or another path.
  2390. *
  2391. * @param aRoot The root path or URL.
  2392. * @param aPath The path or URL to be made relative to aRoot.
  2393. */
  2394. function relative(aRoot, aPath) {
  2395. if (aRoot === "") {
  2396. aRoot = ".";
  2397. }
  2398. aRoot = aRoot.replace(/\/$/, '');
  2399. // It is possible for the path to be above the root. In this case, simply
  2400. // checking whether the root is a prefix of the path won't work. Instead, we
  2401. // need to remove components from the root one by one, until either we find
  2402. // a prefix that fits, or we run out of components to remove.
  2403. var level = 0;
  2404. while (aPath.indexOf(aRoot + '/') !== 0) {
  2405. var index = aRoot.lastIndexOf("/");
  2406. if (index < 0) {
  2407. return aPath;
  2408. }
  2409. // If the only part of the root that is left is the scheme (i.e. http://,
  2410. // file:///, etc.), one or more slashes (/), or simply nothing at all, we
  2411. // have exhausted all components, so the path is not relative to the root.
  2412. aRoot = aRoot.slice(0, index);
  2413. if (aRoot.match(/^([^\/]+:\/)?\/*$/)) {
  2414. return aPath;
  2415. }
  2416. ++level;
  2417. }
  2418. // Make sure we add a "../" for each component we removed from the root.
  2419. return Array(level + 1).join("../") + aPath.substr(aRoot.length + 1);
  2420. }
  2421. exports.relative = relative;
  2422. var supportsNullProto = (function () {
  2423. var obj = Object.create(null);
  2424. return !('__proto__' in obj);
  2425. }());
  2426. function identity (s) {
  2427. return s;
  2428. }
  2429. /**
  2430. * Because behavior goes wacky when you set `__proto__` on objects, we
  2431. * have to prefix all the strings in our set with an arbitrary character.
  2432. *
  2433. * See https://github.com/mozilla/source-map/pull/31 and
  2434. * https://github.com/mozilla/source-map/issues/30
  2435. *
  2436. * @param String aStr
  2437. */
  2438. function toSetString(aStr) {
  2439. if (isProtoString(aStr)) {
  2440. return '$' + aStr;
  2441. }
  2442. return aStr;
  2443. }
  2444. exports.toSetString = supportsNullProto ? identity : toSetString;
  2445. function fromSetString(aStr) {
  2446. if (isProtoString(aStr)) {
  2447. return aStr.slice(1);
  2448. }
  2449. return aStr;
  2450. }
  2451. exports.fromSetString = supportsNullProto ? identity : fromSetString;
  2452. function isProtoString(s) {
  2453. if (!s) {
  2454. return false;
  2455. }
  2456. var length = s.length;
  2457. if (length < 9 /* "__proto__".length */) {
  2458. return false;
  2459. }
  2460. if (s.charCodeAt(length - 1) !== 95 /* '_' */ ||
  2461. s.charCodeAt(length - 2) !== 95 /* '_' */ ||
  2462. s.charCodeAt(length - 3) !== 111 /* 'o' */ ||
  2463. s.charCodeAt(length - 4) !== 116 /* 't' */ ||
  2464. s.charCodeAt(length - 5) !== 111 /* 'o' */ ||
  2465. s.charCodeAt(length - 6) !== 114 /* 'r' */ ||
  2466. s.charCodeAt(length - 7) !== 112 /* 'p' */ ||
  2467. s.charCodeAt(length - 8) !== 95 /* '_' */ ||
  2468. s.charCodeAt(length - 9) !== 95 /* '_' */) {
  2469. return false;
  2470. }
  2471. for (var i = length - 10; i >= 0; i--) {
  2472. if (s.charCodeAt(i) !== 36 /* '$' */) {
  2473. return false;
  2474. }
  2475. }
  2476. return true;
  2477. }
  2478. /**
  2479. * Comparator between two mappings where the original positions are compared.
  2480. *
  2481. * Optionally pass in `true` as `onlyCompareGenerated` to consider two
  2482. * mappings with the same original source/line/column, but different generated
  2483. * line and column the same. Useful when searching for a mapping with a
  2484. * stubbed out mapping.
  2485. */
  2486. function compareByOriginalPositions(mappingA, mappingB, onlyCompareOriginal) {
  2487. var cmp = strcmp(mappingA.source, mappingB.source);
  2488. if (cmp !== 0) {
  2489. return cmp;
  2490. }
  2491. cmp = mappingA.originalLine - mappingB.originalLine;
  2492. if (cmp !== 0) {
  2493. return cmp;
  2494. }
  2495. cmp = mappingA.originalColumn - mappingB.originalColumn;
  2496. if (cmp !== 0 || onlyCompareOriginal) {
  2497. return cmp;
  2498. }
  2499. cmp = mappingA.generatedColumn - mappingB.generatedColumn;
  2500. if (cmp !== 0) {
  2501. return cmp;
  2502. }
  2503. cmp = mappingA.generatedLine - mappingB.generatedLine;
  2504. if (cmp !== 0) {
  2505. return cmp;
  2506. }
  2507. return strcmp(mappingA.name, mappingB.name);
  2508. }
  2509. exports.compareByOriginalPositions = compareByOriginalPositions;
  2510. function compareByOriginalPositionsNoSource(mappingA, mappingB, onlyCompareOriginal) {
  2511. var cmp;
  2512. cmp = mappingA.originalLine - mappingB.originalLine;
  2513. if (cmp !== 0) {
  2514. return cmp;
  2515. }
  2516. cmp = mappingA.originalColumn - mappingB.originalColumn;
  2517. if (cmp !== 0 || onlyCompareOriginal) {
  2518. return cmp;
  2519. }
  2520. cmp = mappingA.generatedColumn - mappingB.generatedColumn;
  2521. if (cmp !== 0) {
  2522. return cmp;
  2523. }
  2524. cmp = mappingA.generatedLine - mappingB.generatedLine;
  2525. if (cmp !== 0) {
  2526. return cmp;
  2527. }
  2528. return strcmp(mappingA.name, mappingB.name);
  2529. }
  2530. exports.compareByOriginalPositionsNoSource = compareByOriginalPositionsNoSource;
  2531. /**
  2532. * Comparator between two mappings with deflated source and name indices where
  2533. * the generated positions are compared.
  2534. *
  2535. * Optionally pass in `true` as `onlyCompareGenerated` to consider two
  2536. * mappings with the same generated line and column, but different
  2537. * source/name/original line and column the same. Useful when searching for a
  2538. * mapping with a stubbed out mapping.
  2539. */
  2540. function compareByGeneratedPositionsDeflated(mappingA, mappingB, onlyCompareGenerated) {
  2541. var cmp = mappingA.generatedLine - mappingB.generatedLine;
  2542. if (cmp !== 0) {
  2543. return cmp;
  2544. }
  2545. cmp = mappingA.generatedColumn - mappingB.generatedColumn;
  2546. if (cmp !== 0 || onlyCompareGenerated) {
  2547. return cmp;
  2548. }
  2549. cmp = strcmp(mappingA.source, mappingB.source);
  2550. if (cmp !== 0) {
  2551. return cmp;
  2552. }
  2553. cmp = mappingA.originalLine - mappingB.originalLine;
  2554. if (cmp !== 0) {
  2555. return cmp;
  2556. }
  2557. cmp = mappingA.originalColumn - mappingB.originalColumn;
  2558. if (cmp !== 0) {
  2559. return cmp;
  2560. }
  2561. return strcmp(mappingA.name, mappingB.name);
  2562. }
  2563. exports.compareByGeneratedPositionsDeflated = compareByGeneratedPositionsDeflated;
  2564. function compareByGeneratedPositionsDeflatedNoLine(mappingA, mappingB, onlyCompareGenerated) {
  2565. var cmp = mappingA.generatedColumn - mappingB.generatedColumn;
  2566. if (cmp !== 0 || onlyCompareGenerated) {
  2567. return cmp;
  2568. }
  2569. cmp = strcmp(mappingA.source, mappingB.source);
  2570. if (cmp !== 0) {
  2571. return cmp;
  2572. }
  2573. cmp = mappingA.originalLine - mappingB.originalLine;
  2574. if (cmp !== 0) {
  2575. return cmp;
  2576. }
  2577. cmp = mappingA.originalColumn - mappingB.originalColumn;
  2578. if (cmp !== 0) {
  2579. return cmp;
  2580. }
  2581. return strcmp(mappingA.name, mappingB.name);
  2582. }
  2583. exports.compareByGeneratedPositionsDeflatedNoLine = compareByGeneratedPositionsDeflatedNoLine;
  2584. function strcmp(aStr1, aStr2) {
  2585. if (aStr1 === aStr2) {
  2586. return 0;
  2587. }
  2588. if (aStr1 === null) {
  2589. return 1; // aStr2 !== null
  2590. }
  2591. if (aStr2 === null) {
  2592. return -1; // aStr1 !== null
  2593. }
  2594. if (aStr1 > aStr2) {
  2595. return 1;
  2596. }
  2597. return -1;
  2598. }
  2599. /**
  2600. * Comparator between two mappings with inflated source and name strings where
  2601. * the generated positions are compared.
  2602. */
  2603. function compareByGeneratedPositionsInflated(mappingA, mappingB) {
  2604. var cmp = mappingA.generatedLine - mappingB.generatedLine;
  2605. if (cmp !== 0) {
  2606. return cmp;
  2607. }
  2608. cmp = mappingA.generatedColumn - mappingB.generatedColumn;
  2609. if (cmp !== 0) {
  2610. return cmp;
  2611. }
  2612. cmp = strcmp(mappingA.source, mappingB.source);
  2613. if (cmp !== 0) {
  2614. return cmp;
  2615. }
  2616. cmp = mappingA.originalLine - mappingB.originalLine;
  2617. if (cmp !== 0) {
  2618. return cmp;
  2619. }
  2620. cmp = mappingA.originalColumn - mappingB.originalColumn;
  2621. if (cmp !== 0) {
  2622. return cmp;
  2623. }
  2624. return strcmp(mappingA.name, mappingB.name);
  2625. }
  2626. exports.compareByGeneratedPositionsInflated = compareByGeneratedPositionsInflated;
  2627. /**
  2628. * Strip any JSON XSSI avoidance prefix from the string (as documented
  2629. * in the source maps specification), and then parse the string as
  2630. * JSON.
  2631. */
  2632. function parseSourceMapInput(str) {
  2633. return JSON.parse(str.replace(/^\)]}'[^\n]*\n/, ''));
  2634. }
  2635. exports.parseSourceMapInput = parseSourceMapInput;
  2636. /**
  2637. * Compute the URL of a source given the the source root, the source's
  2638. * URL, and the source map's URL.
  2639. */
  2640. function computeSourceURL(sourceRoot, sourceURL, sourceMapURL) {
  2641. sourceURL = sourceURL || '';
  2642. if (sourceRoot) {
  2643. // This follows what Chrome does.
  2644. if (sourceRoot[sourceRoot.length - 1] !== '/' && sourceURL[0] !== '/') {
  2645. sourceRoot += '/';
  2646. }
  2647. // The spec says:
  2648. // Line 4: An optional source root, useful for relocating source
  2649. // files on a server or removing repeated values in the
  2650. // “sources” entry. This value is prepended to the individual
  2651. // entries in the “source” field.
  2652. sourceURL = sourceRoot + sourceURL;
  2653. }
  2654. // Historically, SourceMapConsumer did not take the sourceMapURL as
  2655. // a parameter. This mode is still somewhat supported, which is why
  2656. // this code block is conditional. However, it's preferable to pass
  2657. // the source map URL to SourceMapConsumer, so that this function
  2658. // can implement the source URL resolution algorithm as outlined in
  2659. // the spec. This block is basically the equivalent of:
  2660. // new URL(sourceURL, sourceMapURL).toString()
  2661. // ... except it avoids using URL, which wasn't available in the
  2662. // older releases of node still supported by this library.
  2663. //
  2664. // The spec says:
  2665. // If the sources are not absolute URLs after prepending of the
  2666. // “sourceRoot”, the sources are resolved relative to the
  2667. // SourceMap (like resolving script src in a html document).
  2668. if (sourceMapURL) {
  2669. var parsed = urlParse(sourceMapURL);
  2670. if (!parsed) {
  2671. throw new Error("sourceMapURL could not be parsed");
  2672. }
  2673. if (parsed.path) {
  2674. // Strip the last path component, but keep the "/".
  2675. var index = parsed.path.lastIndexOf('/');
  2676. if (index >= 0) {
  2677. parsed.path = parsed.path.substring(0, index + 1);
  2678. }
  2679. }
  2680. sourceURL = join(urlGenerate(parsed), sourceURL);
  2681. }
  2682. return normalize(sourceURL);
  2683. }
  2684. exports.computeSourceURL = computeSourceURL;
  2685. } (util$5));
  2686. var arraySet = {};
  2687. /* -*- Mode: js; js-indent-level: 2; -*- */
  2688. /*
  2689. * Copyright 2011 Mozilla Foundation and contributors
  2690. * Licensed under the New BSD license. See LICENSE or:
  2691. * http://opensource.org/licenses/BSD-3-Clause
  2692. */
  2693. var util$4 = util$5;
  2694. var has = Object.prototype.hasOwnProperty;
  2695. var hasNativeMap = typeof Map !== "undefined";
  2696. /**
  2697. * A data structure which is a combination of an array and a set. Adding a new
  2698. * member is O(1), testing for membership is O(1), and finding the index of an
  2699. * element is O(1). Removing elements from the set is not supported. Only
  2700. * strings are supported for membership.
  2701. */
  2702. function ArraySet$2() {
  2703. this._array = [];
  2704. this._set = hasNativeMap ? new Map() : Object.create(null);
  2705. }
  2706. /**
  2707. * Static method for creating ArraySet instances from an existing array.
  2708. */
  2709. ArraySet$2.fromArray = function ArraySet_fromArray(aArray, aAllowDuplicates) {
  2710. var set = new ArraySet$2();
  2711. for (var i = 0, len = aArray.length; i < len; i++) {
  2712. set.add(aArray[i], aAllowDuplicates);
  2713. }
  2714. return set;
  2715. };
  2716. /**
  2717. * Return how many unique items are in this ArraySet. If duplicates have been
  2718. * added, than those do not count towards the size.
  2719. *
  2720. * @returns Number
  2721. */
  2722. ArraySet$2.prototype.size = function ArraySet_size() {
  2723. return hasNativeMap ? this._set.size : Object.getOwnPropertyNames(this._set).length;
  2724. };
  2725. /**
  2726. * Add the given string to this set.
  2727. *
  2728. * @param String aStr
  2729. */
  2730. ArraySet$2.prototype.add = function ArraySet_add(aStr, aAllowDuplicates) {
  2731. var sStr = hasNativeMap ? aStr : util$4.toSetString(aStr);
  2732. var isDuplicate = hasNativeMap ? this.has(aStr) : has.call(this._set, sStr);
  2733. var idx = this._array.length;
  2734. if (!isDuplicate || aAllowDuplicates) {
  2735. this._array.push(aStr);
  2736. }
  2737. if (!isDuplicate) {
  2738. if (hasNativeMap) {
  2739. this._set.set(aStr, idx);
  2740. } else {
  2741. this._set[sStr] = idx;
  2742. }
  2743. }
  2744. };
  2745. /**
  2746. * Is the given string a member of this set?
  2747. *
  2748. * @param String aStr
  2749. */
  2750. ArraySet$2.prototype.has = function ArraySet_has(aStr) {
  2751. if (hasNativeMap) {
  2752. return this._set.has(aStr);
  2753. } else {
  2754. var sStr = util$4.toSetString(aStr);
  2755. return has.call(this._set, sStr);
  2756. }
  2757. };
  2758. /**
  2759. * What is the index of the given string in the array?
  2760. *
  2761. * @param String aStr
  2762. */
  2763. ArraySet$2.prototype.indexOf = function ArraySet_indexOf(aStr) {
  2764. if (hasNativeMap) {
  2765. var idx = this._set.get(aStr);
  2766. if (idx >= 0) {
  2767. return idx;
  2768. }
  2769. } else {
  2770. var sStr = util$4.toSetString(aStr);
  2771. if (has.call(this._set, sStr)) {
  2772. return this._set[sStr];
  2773. }
  2774. }
  2775. throw new Error('"' + aStr + '" is not in the set.');
  2776. };
  2777. /**
  2778. * What is the element at the given index?
  2779. *
  2780. * @param Number aIdx
  2781. */
  2782. ArraySet$2.prototype.at = function ArraySet_at(aIdx) {
  2783. if (aIdx >= 0 && aIdx < this._array.length) {
  2784. return this._array[aIdx];
  2785. }
  2786. throw new Error('No element indexed by ' + aIdx);
  2787. };
  2788. /**
  2789. * Returns the array representation of this set (which has the proper indices
  2790. * indicated by indexOf). Note that this is a copy of the internal array used
  2791. * for storing the members so that no one can mess with internal state.
  2792. */
  2793. ArraySet$2.prototype.toArray = function ArraySet_toArray() {
  2794. return this._array.slice();
  2795. };
  2796. arraySet.ArraySet = ArraySet$2;
  2797. var mappingList = {};
  2798. /* -*- Mode: js; js-indent-level: 2; -*- */
  2799. /*
  2800. * Copyright 2014 Mozilla Foundation and contributors
  2801. * Licensed under the New BSD license. See LICENSE or:
  2802. * http://opensource.org/licenses/BSD-3-Clause
  2803. */
  2804. var util$3 = util$5;
  2805. /**
  2806. * Determine whether mappingB is after mappingA with respect to generated
  2807. * position.
  2808. */
  2809. function generatedPositionAfter(mappingA, mappingB) {
  2810. // Optimized for most common case
  2811. var lineA = mappingA.generatedLine;
  2812. var lineB = mappingB.generatedLine;
  2813. var columnA = mappingA.generatedColumn;
  2814. var columnB = mappingB.generatedColumn;
  2815. return lineB > lineA || lineB == lineA && columnB >= columnA ||
  2816. util$3.compareByGeneratedPositionsInflated(mappingA, mappingB) <= 0;
  2817. }
  2818. /**
  2819. * A data structure to provide a sorted view of accumulated mappings in a
  2820. * performance conscious manner. It trades a neglibable overhead in general
  2821. * case for a large speedup in case of mappings being added in order.
  2822. */
  2823. function MappingList$1() {
  2824. this._array = [];
  2825. this._sorted = true;
  2826. // Serves as infimum
  2827. this._last = {generatedLine: -1, generatedColumn: 0};
  2828. }
  2829. /**
  2830. * Iterate through internal items. This method takes the same arguments that
  2831. * `Array.prototype.forEach` takes.
  2832. *
  2833. * NOTE: The order of the mappings is NOT guaranteed.
  2834. */
  2835. MappingList$1.prototype.unsortedForEach =
  2836. function MappingList_forEach(aCallback, aThisArg) {
  2837. this._array.forEach(aCallback, aThisArg);
  2838. };
  2839. /**
  2840. * Add the given source mapping.
  2841. *
  2842. * @param Object aMapping
  2843. */
  2844. MappingList$1.prototype.add = function MappingList_add(aMapping) {
  2845. if (generatedPositionAfter(this._last, aMapping)) {
  2846. this._last = aMapping;
  2847. this._array.push(aMapping);
  2848. } else {
  2849. this._sorted = false;
  2850. this._array.push(aMapping);
  2851. }
  2852. };
  2853. /**
  2854. * Returns the flat, sorted array of mappings. The mappings are sorted by
  2855. * generated position.
  2856. *
  2857. * WARNING: This method returns internal data without copying, for
  2858. * performance. The return value must NOT be mutated, and should be treated as
  2859. * an immutable borrow. If you want to take ownership, you must make your own
  2860. * copy.
  2861. */
  2862. MappingList$1.prototype.toArray = function MappingList_toArray() {
  2863. if (!this._sorted) {
  2864. this._array.sort(util$3.compareByGeneratedPositionsInflated);
  2865. this._sorted = true;
  2866. }
  2867. return this._array;
  2868. };
  2869. mappingList.MappingList = MappingList$1;
  2870. /* -*- Mode: js; js-indent-level: 2; -*- */
  2871. /*
  2872. * Copyright 2011 Mozilla Foundation and contributors
  2873. * Licensed under the New BSD license. See LICENSE or:
  2874. * http://opensource.org/licenses/BSD-3-Clause
  2875. */
  2876. var base64VLQ$1 = base64Vlq;
  2877. var util$2 = util$5;
  2878. var ArraySet$1 = arraySet.ArraySet;
  2879. var MappingList = mappingList.MappingList;
  2880. /**
  2881. * An instance of the SourceMapGenerator represents a source map which is
  2882. * being built incrementally. You may pass an object with the following
  2883. * properties:
  2884. *
  2885. * - file: The filename of the generated source.
  2886. * - sourceRoot: A root for all relative URLs in this source map.
  2887. */
  2888. function SourceMapGenerator$1(aArgs) {
  2889. if (!aArgs) {
  2890. aArgs = {};
  2891. }
  2892. this._file = util$2.getArg(aArgs, 'file', null);
  2893. this._sourceRoot = util$2.getArg(aArgs, 'sourceRoot', null);
  2894. this._skipValidation = util$2.getArg(aArgs, 'skipValidation', false);
  2895. this._sources = new ArraySet$1();
  2896. this._names = new ArraySet$1();
  2897. this._mappings = new MappingList();
  2898. this._sourcesContents = null;
  2899. }
  2900. SourceMapGenerator$1.prototype._version = 3;
  2901. /**
  2902. * Creates a new SourceMapGenerator based on a SourceMapConsumer
  2903. *
  2904. * @param aSourceMapConsumer The SourceMap.
  2905. */
  2906. SourceMapGenerator$1.fromSourceMap =
  2907. function SourceMapGenerator_fromSourceMap(aSourceMapConsumer) {
  2908. var sourceRoot = aSourceMapConsumer.sourceRoot;
  2909. var generator = new SourceMapGenerator$1({
  2910. file: aSourceMapConsumer.file,
  2911. sourceRoot: sourceRoot
  2912. });
  2913. aSourceMapConsumer.eachMapping(function (mapping) {
  2914. var newMapping = {
  2915. generated: {
  2916. line: mapping.generatedLine,
  2917. column: mapping.generatedColumn
  2918. }
  2919. };
  2920. if (mapping.source != null) {
  2921. newMapping.source = mapping.source;
  2922. if (sourceRoot != null) {
  2923. newMapping.source = util$2.relative(sourceRoot, newMapping.source);
  2924. }
  2925. newMapping.original = {
  2926. line: mapping.originalLine,
  2927. column: mapping.originalColumn
  2928. };
  2929. if (mapping.name != null) {
  2930. newMapping.name = mapping.name;
  2931. }
  2932. }
  2933. generator.addMapping(newMapping);
  2934. });
  2935. aSourceMapConsumer.sources.forEach(function (sourceFile) {
  2936. var sourceRelative = sourceFile;
  2937. if (sourceRoot !== null) {
  2938. sourceRelative = util$2.relative(sourceRoot, sourceFile);
  2939. }
  2940. if (!generator._sources.has(sourceRelative)) {
  2941. generator._sources.add(sourceRelative);
  2942. }
  2943. var content = aSourceMapConsumer.sourceContentFor(sourceFile);
  2944. if (content != null) {
  2945. generator.setSourceContent(sourceFile, content);
  2946. }
  2947. });
  2948. return generator;
  2949. };
  2950. /**
  2951. * Add a single mapping from original source line and column to the generated
  2952. * source's line and column for this source map being created. The mapping
  2953. * object should have the following properties:
  2954. *
  2955. * - generated: An object with the generated line and column positions.
  2956. * - original: An object with the original line and column positions.
  2957. * - source: The original source file (relative to the sourceRoot).
  2958. * - name: An optional original token name for this mapping.
  2959. */
  2960. SourceMapGenerator$1.prototype.addMapping =
  2961. function SourceMapGenerator_addMapping(aArgs) {
  2962. var generated = util$2.getArg(aArgs, 'generated');
  2963. var original = util$2.getArg(aArgs, 'original', null);
  2964. var source = util$2.getArg(aArgs, 'source', null);
  2965. var name = util$2.getArg(aArgs, 'name', null);
  2966. if (!this._skipValidation) {
  2967. this._validateMapping(generated, original, source, name);
  2968. }
  2969. if (source != null) {
  2970. source = String(source);
  2971. if (!this._sources.has(source)) {
  2972. this._sources.add(source);
  2973. }
  2974. }
  2975. if (name != null) {
  2976. name = String(name);
  2977. if (!this._names.has(name)) {
  2978. this._names.add(name);
  2979. }
  2980. }
  2981. this._mappings.add({
  2982. generatedLine: generated.line,
  2983. generatedColumn: generated.column,
  2984. originalLine: original != null && original.line,
  2985. originalColumn: original != null && original.column,
  2986. source: source,
  2987. name: name
  2988. });
  2989. };
  2990. /**
  2991. * Set the source content for a source file.
  2992. */
  2993. SourceMapGenerator$1.prototype.setSourceContent =
  2994. function SourceMapGenerator_setSourceContent(aSourceFile, aSourceContent) {
  2995. var source = aSourceFile;
  2996. if (this._sourceRoot != null) {
  2997. source = util$2.relative(this._sourceRoot, source);
  2998. }
  2999. if (aSourceContent != null) {
  3000. // Add the source content to the _sourcesContents map.
  3001. // Create a new _sourcesContents map if the property is null.
  3002. if (!this._sourcesContents) {
  3003. this._sourcesContents = Object.create(null);
  3004. }
  3005. this._sourcesContents[util$2.toSetString(source)] = aSourceContent;
  3006. } else if (this._sourcesContents) {
  3007. // Remove the source file from the _sourcesContents map.
  3008. // If the _sourcesContents map is empty, set the property to null.
  3009. delete this._sourcesContents[util$2.toSetString(source)];
  3010. if (Object.keys(this._sourcesContents).length === 0) {
  3011. this._sourcesContents = null;
  3012. }
  3013. }
  3014. };
  3015. /**
  3016. * Applies the mappings of a sub-source-map for a specific source file to the
  3017. * source map being generated. Each mapping to the supplied source file is
  3018. * rewritten using the supplied source map. Note: The resolution for the
  3019. * resulting mappings is the minimium of this map and the supplied map.
  3020. *
  3021. * @param aSourceMapConsumer The source map to be applied.
  3022. * @param aSourceFile Optional. The filename of the source file.
  3023. * If omitted, SourceMapConsumer's file property will be used.
  3024. * @param aSourceMapPath Optional. The dirname of the path to the source map
  3025. * to be applied. If relative, it is relative to the SourceMapConsumer.
  3026. * This parameter is needed when the two source maps aren't in the same
  3027. * directory, and the source map to be applied contains relative source
  3028. * paths. If so, those relative source paths need to be rewritten
  3029. * relative to the SourceMapGenerator.
  3030. */
  3031. SourceMapGenerator$1.prototype.applySourceMap =
  3032. function SourceMapGenerator_applySourceMap(aSourceMapConsumer, aSourceFile, aSourceMapPath) {
  3033. var sourceFile = aSourceFile;
  3034. // If aSourceFile is omitted, we will use the file property of the SourceMap
  3035. if (aSourceFile == null) {
  3036. if (aSourceMapConsumer.file == null) {
  3037. throw new Error(
  3038. 'SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, ' +
  3039. 'or the source map\'s "file" property. Both were omitted.'
  3040. );
  3041. }
  3042. sourceFile = aSourceMapConsumer.file;
  3043. }
  3044. var sourceRoot = this._sourceRoot;
  3045. // Make "sourceFile" relative if an absolute Url is passed.
  3046. if (sourceRoot != null) {
  3047. sourceFile = util$2.relative(sourceRoot, sourceFile);
  3048. }
  3049. // Applying the SourceMap can add and remove items from the sources and
  3050. // the names array.
  3051. var newSources = new ArraySet$1();
  3052. var newNames = new ArraySet$1();
  3053. // Find mappings for the "sourceFile"
  3054. this._mappings.unsortedForEach(function (mapping) {
  3055. if (mapping.source === sourceFile && mapping.originalLine != null) {
  3056. // Check if it can be mapped by the source map, then update the mapping.
  3057. var original = aSourceMapConsumer.originalPositionFor({
  3058. line: mapping.originalLine,
  3059. column: mapping.originalColumn
  3060. });
  3061. if (original.source != null) {
  3062. // Copy mapping
  3063. mapping.source = original.source;
  3064. if (aSourceMapPath != null) {
  3065. mapping.source = util$2.join(aSourceMapPath, mapping.source);
  3066. }
  3067. if (sourceRoot != null) {
  3068. mapping.source = util$2.relative(sourceRoot, mapping.source);
  3069. }
  3070. mapping.originalLine = original.line;
  3071. mapping.originalColumn = original.column;
  3072. if (original.name != null) {
  3073. mapping.name = original.name;
  3074. }
  3075. }
  3076. }
  3077. var source = mapping.source;
  3078. if (source != null && !newSources.has(source)) {
  3079. newSources.add(source);
  3080. }
  3081. var name = mapping.name;
  3082. if (name != null && !newNames.has(name)) {
  3083. newNames.add(name);
  3084. }
  3085. }, this);
  3086. this._sources = newSources;
  3087. this._names = newNames;
  3088. // Copy sourcesContents of applied map.
  3089. aSourceMapConsumer.sources.forEach(function (sourceFile) {
  3090. var content = aSourceMapConsumer.sourceContentFor(sourceFile);
  3091. if (content != null) {
  3092. if (aSourceMapPath != null) {
  3093. sourceFile = util$2.join(aSourceMapPath, sourceFile);
  3094. }
  3095. if (sourceRoot != null) {
  3096. sourceFile = util$2.relative(sourceRoot, sourceFile);
  3097. }
  3098. this.setSourceContent(sourceFile, content);
  3099. }
  3100. }, this);
  3101. };
  3102. /**
  3103. * A mapping can have one of the three levels of data:
  3104. *
  3105. * 1. Just the generated position.
  3106. * 2. The Generated position, original position, and original source.
  3107. * 3. Generated and original position, original source, as well as a name
  3108. * token.
  3109. *
  3110. * To maintain consistency, we validate that any new mapping being added falls
  3111. * in to one of these categories.
  3112. */
  3113. SourceMapGenerator$1.prototype._validateMapping =
  3114. function SourceMapGenerator_validateMapping(aGenerated, aOriginal, aSource,
  3115. aName) {
  3116. // When aOriginal is truthy but has empty values for .line and .column,
  3117. // it is most likely a programmer error. In this case we throw a very
  3118. // specific error message to try to guide them the right way.
  3119. // For example: https://github.com/Polymer/polymer-bundler/pull/519
  3120. if (aOriginal && typeof aOriginal.line !== 'number' && typeof aOriginal.column !== 'number') {
  3121. throw new Error(
  3122. 'original.line and original.column are not numbers -- you probably meant to omit ' +
  3123. 'the original mapping entirely and only map the generated position. If so, pass ' +
  3124. 'null for the original mapping instead of an object with empty or null values.'
  3125. );
  3126. }
  3127. if (aGenerated && 'line' in aGenerated && 'column' in aGenerated
  3128. && aGenerated.line > 0 && aGenerated.column >= 0
  3129. && !aOriginal && !aSource && !aName) {
  3130. // Case 1.
  3131. return;
  3132. }
  3133. else if (aGenerated && 'line' in aGenerated && 'column' in aGenerated
  3134. && aOriginal && 'line' in aOriginal && 'column' in aOriginal
  3135. && aGenerated.line > 0 && aGenerated.column >= 0
  3136. && aOriginal.line > 0 && aOriginal.column >= 0
  3137. && aSource) {
  3138. // Cases 2 and 3.
  3139. return;
  3140. }
  3141. else {
  3142. throw new Error('Invalid mapping: ' + JSON.stringify({
  3143. generated: aGenerated,
  3144. source: aSource,
  3145. original: aOriginal,
  3146. name: aName
  3147. }));
  3148. }
  3149. };
  3150. /**
  3151. * Serialize the accumulated mappings in to the stream of base 64 VLQs
  3152. * specified by the source map format.
  3153. */
  3154. SourceMapGenerator$1.prototype._serializeMappings =
  3155. function SourceMapGenerator_serializeMappings() {
  3156. var previousGeneratedColumn = 0;
  3157. var previousGeneratedLine = 1;
  3158. var previousOriginalColumn = 0;
  3159. var previousOriginalLine = 0;
  3160. var previousName = 0;
  3161. var previousSource = 0;
  3162. var result = '';
  3163. var next;
  3164. var mapping;
  3165. var nameIdx;
  3166. var sourceIdx;
  3167. var mappings = this._mappings.toArray();
  3168. for (var i = 0, len = mappings.length; i < len; i++) {
  3169. mapping = mappings[i];
  3170. next = '';
  3171. if (mapping.generatedLine !== previousGeneratedLine) {
  3172. previousGeneratedColumn = 0;
  3173. while (mapping.generatedLine !== previousGeneratedLine) {
  3174. next += ';';
  3175. previousGeneratedLine++;
  3176. }
  3177. }
  3178. else {
  3179. if (i > 0) {
  3180. if (!util$2.compareByGeneratedPositionsInflated(mapping, mappings[i - 1])) {
  3181. continue;
  3182. }
  3183. next += ',';
  3184. }
  3185. }
  3186. next += base64VLQ$1.encode(mapping.generatedColumn
  3187. - previousGeneratedColumn);
  3188. previousGeneratedColumn = mapping.generatedColumn;
  3189. if (mapping.source != null) {
  3190. sourceIdx = this._sources.indexOf(mapping.source);
  3191. next += base64VLQ$1.encode(sourceIdx - previousSource);
  3192. previousSource = sourceIdx;
  3193. // lines are stored 0-based in SourceMap spec version 3
  3194. next += base64VLQ$1.encode(mapping.originalLine - 1
  3195. - previousOriginalLine);
  3196. previousOriginalLine = mapping.originalLine - 1;
  3197. next += base64VLQ$1.encode(mapping.originalColumn
  3198. - previousOriginalColumn);
  3199. previousOriginalColumn = mapping.originalColumn;
  3200. if (mapping.name != null) {
  3201. nameIdx = this._names.indexOf(mapping.name);
  3202. next += base64VLQ$1.encode(nameIdx - previousName);
  3203. previousName = nameIdx;
  3204. }
  3205. }
  3206. result += next;
  3207. }
  3208. return result;
  3209. };
  3210. SourceMapGenerator$1.prototype._generateSourcesContent =
  3211. function SourceMapGenerator_generateSourcesContent(aSources, aSourceRoot) {
  3212. return aSources.map(function (source) {
  3213. if (!this._sourcesContents) {
  3214. return null;
  3215. }
  3216. if (aSourceRoot != null) {
  3217. source = util$2.relative(aSourceRoot, source);
  3218. }
  3219. var key = util$2.toSetString(source);
  3220. return Object.prototype.hasOwnProperty.call(this._sourcesContents, key)
  3221. ? this._sourcesContents[key]
  3222. : null;
  3223. }, this);
  3224. };
  3225. /**
  3226. * Externalize the source map.
  3227. */
  3228. SourceMapGenerator$1.prototype.toJSON =
  3229. function SourceMapGenerator_toJSON() {
  3230. var map = {
  3231. version: this._version,
  3232. sources: this._sources.toArray(),
  3233. names: this._names.toArray(),
  3234. mappings: this._serializeMappings()
  3235. };
  3236. if (this._file != null) {
  3237. map.file = this._file;
  3238. }
  3239. if (this._sourceRoot != null) {
  3240. map.sourceRoot = this._sourceRoot;
  3241. }
  3242. if (this._sourcesContents) {
  3243. map.sourcesContent = this._generateSourcesContent(map.sources, map.sourceRoot);
  3244. }
  3245. return map;
  3246. };
  3247. /**
  3248. * Render the source map being generated to a string.
  3249. */
  3250. SourceMapGenerator$1.prototype.toString =
  3251. function SourceMapGenerator_toString() {
  3252. return JSON.stringify(this.toJSON());
  3253. };
  3254. sourceMapGenerator.SourceMapGenerator = SourceMapGenerator$1;
  3255. var sourceMapConsumer = {};
  3256. var binarySearch$1 = {};
  3257. /* -*- Mode: js; js-indent-level: 2; -*- */
  3258. (function (exports) {
  3259. /*
  3260. * Copyright 2011 Mozilla Foundation and contributors
  3261. * Licensed under the New BSD license. See LICENSE or:
  3262. * http://opensource.org/licenses/BSD-3-Clause
  3263. */
  3264. exports.GREATEST_LOWER_BOUND = 1;
  3265. exports.LEAST_UPPER_BOUND = 2;
  3266. /**
  3267. * Recursive implementation of binary search.
  3268. *
  3269. * @param aLow Indices here and lower do not contain the needle.
  3270. * @param aHigh Indices here and higher do not contain the needle.
  3271. * @param aNeedle The element being searched for.
  3272. * @param aHaystack The non-empty array being searched.
  3273. * @param aCompare Function which takes two elements and returns -1, 0, or 1.
  3274. * @param aBias Either 'binarySearch.GREATEST_LOWER_BOUND' or
  3275. * 'binarySearch.LEAST_UPPER_BOUND'. Specifies whether to return the
  3276. * closest element that is smaller than or greater than the one we are
  3277. * searching for, respectively, if the exact element cannot be found.
  3278. */
  3279. function recursiveSearch(aLow, aHigh, aNeedle, aHaystack, aCompare, aBias) {
  3280. // This function terminates when one of the following is true:
  3281. //
  3282. // 1. We find the exact element we are looking for.
  3283. //
  3284. // 2. We did not find the exact element, but we can return the index of
  3285. // the next-closest element.
  3286. //
  3287. // 3. We did not find the exact element, and there is no next-closest
  3288. // element than the one we are searching for, so we return -1.
  3289. var mid = Math.floor((aHigh - aLow) / 2) + aLow;
  3290. var cmp = aCompare(aNeedle, aHaystack[mid], true);
  3291. if (cmp === 0) {
  3292. // Found the element we are looking for.
  3293. return mid;
  3294. }
  3295. else if (cmp > 0) {
  3296. // Our needle is greater than aHaystack[mid].
  3297. if (aHigh - mid > 1) {
  3298. // The element is in the upper half.
  3299. return recursiveSearch(mid, aHigh, aNeedle, aHaystack, aCompare, aBias);
  3300. }
  3301. // The exact needle element was not found in this haystack. Determine if
  3302. // we are in termination case (3) or (2) and return the appropriate thing.
  3303. if (aBias == exports.LEAST_UPPER_BOUND) {
  3304. return aHigh < aHaystack.length ? aHigh : -1;
  3305. } else {
  3306. return mid;
  3307. }
  3308. }
  3309. else {
  3310. // Our needle is less than aHaystack[mid].
  3311. if (mid - aLow > 1) {
  3312. // The element is in the lower half.
  3313. return recursiveSearch(aLow, mid, aNeedle, aHaystack, aCompare, aBias);
  3314. }
  3315. // we are in termination case (3) or (2) and return the appropriate thing.
  3316. if (aBias == exports.LEAST_UPPER_BOUND) {
  3317. return mid;
  3318. } else {
  3319. return aLow < 0 ? -1 : aLow;
  3320. }
  3321. }
  3322. }
  3323. /**
  3324. * This is an implementation of binary search which will always try and return
  3325. * the index of the closest element if there is no exact hit. This is because
  3326. * mappings between original and generated line/col pairs are single points,
  3327. * and there is an implicit region between each of them, so a miss just means
  3328. * that you aren't on the very start of a region.
  3329. *
  3330. * @param aNeedle The element you are looking for.
  3331. * @param aHaystack The array that is being searched.
  3332. * @param aCompare A function which takes the needle and an element in the
  3333. * array and returns -1, 0, or 1 depending on whether the needle is less
  3334. * than, equal to, or greater than the element, respectively.
  3335. * @param aBias Either 'binarySearch.GREATEST_LOWER_BOUND' or
  3336. * 'binarySearch.LEAST_UPPER_BOUND'. Specifies whether to return the
  3337. * closest element that is smaller than or greater than the one we are
  3338. * searching for, respectively, if the exact element cannot be found.
  3339. * Defaults to 'binarySearch.GREATEST_LOWER_BOUND'.
  3340. */
  3341. exports.search = function search(aNeedle, aHaystack, aCompare, aBias) {
  3342. if (aHaystack.length === 0) {
  3343. return -1;
  3344. }
  3345. var index = recursiveSearch(-1, aHaystack.length, aNeedle, aHaystack,
  3346. aCompare, aBias || exports.GREATEST_LOWER_BOUND);
  3347. if (index < 0) {
  3348. return -1;
  3349. }
  3350. // We have found either the exact element, or the next-closest element than
  3351. // the one we are searching for. However, there may be more than one such
  3352. // element. Make sure we always return the smallest of these.
  3353. while (index - 1 >= 0) {
  3354. if (aCompare(aHaystack[index], aHaystack[index - 1], true) !== 0) {
  3355. break;
  3356. }
  3357. --index;
  3358. }
  3359. return index;
  3360. };
  3361. } (binarySearch$1));
  3362. var quickSort$1 = {};
  3363. /* -*- Mode: js; js-indent-level: 2; -*- */
  3364. /*
  3365. * Copyright 2011 Mozilla Foundation and contributors
  3366. * Licensed under the New BSD license. See LICENSE or:
  3367. * http://opensource.org/licenses/BSD-3-Clause
  3368. */
  3369. // It turns out that some (most?) JavaScript engines don't self-host
  3370. // `Array.prototype.sort`. This makes sense because C++ will likely remain
  3371. // faster than JS when doing raw CPU-intensive sorting. However, when using a
  3372. // custom comparator function, calling back and forth between the VM's C++ and
  3373. // JIT'd JS is rather slow *and* loses JIT type information, resulting in
  3374. // worse generated code for the comparator function than would be optimal. In
  3375. // fact, when sorting with a comparator, these costs outweigh the benefits of
  3376. // sorting in C++. By using our own JS-implemented Quick Sort (below), we get
  3377. // a ~3500ms mean speed-up in `bench/bench.html`.
  3378. function SortTemplate(comparator) {
  3379. /**
  3380. * Swap the elements indexed by `x` and `y` in the array `ary`.
  3381. *
  3382. * @param {Array} ary
  3383. * The array.
  3384. * @param {Number} x
  3385. * The index of the first item.
  3386. * @param {Number} y
  3387. * The index of the second item.
  3388. */
  3389. function swap(ary, x, y) {
  3390. var temp = ary[x];
  3391. ary[x] = ary[y];
  3392. ary[y] = temp;
  3393. }
  3394. /**
  3395. * Returns a random integer within the range `low .. high` inclusive.
  3396. *
  3397. * @param {Number} low
  3398. * The lower bound on the range.
  3399. * @param {Number} high
  3400. * The upper bound on the range.
  3401. */
  3402. function randomIntInRange(low, high) {
  3403. return Math.round(low + (Math.random() * (high - low)));
  3404. }
  3405. /**
  3406. * The Quick Sort algorithm.
  3407. *
  3408. * @param {Array} ary
  3409. * An array to sort.
  3410. * @param {function} comparator
  3411. * Function to use to compare two items.
  3412. * @param {Number} p
  3413. * Start index of the array
  3414. * @param {Number} r
  3415. * End index of the array
  3416. */
  3417. function doQuickSort(ary, comparator, p, r) {
  3418. // If our lower bound is less than our upper bound, we (1) partition the
  3419. // array into two pieces and (2) recurse on each half. If it is not, this is
  3420. // the empty array and our base case.
  3421. if (p < r) {
  3422. // (1) Partitioning.
  3423. //
  3424. // The partitioning chooses a pivot between `p` and `r` and moves all
  3425. // elements that are less than or equal to the pivot to the before it, and
  3426. // all the elements that are greater than it after it. The effect is that
  3427. // once partition is done, the pivot is in the exact place it will be when
  3428. // the array is put in sorted order, and it will not need to be moved
  3429. // again. This runs in O(n) time.
  3430. // Always choose a random pivot so that an input array which is reverse
  3431. // sorted does not cause O(n^2) running time.
  3432. var pivotIndex = randomIntInRange(p, r);
  3433. var i = p - 1;
  3434. swap(ary, pivotIndex, r);
  3435. var pivot = ary[r];
  3436. // Immediately after `j` is incremented in this loop, the following hold
  3437. // true:
  3438. //
  3439. // * Every element in `ary[p .. i]` is less than or equal to the pivot.
  3440. //
  3441. // * Every element in `ary[i+1 .. j-1]` is greater than the pivot.
  3442. for (var j = p; j < r; j++) {
  3443. if (comparator(ary[j], pivot, false) <= 0) {
  3444. i += 1;
  3445. swap(ary, i, j);
  3446. }
  3447. }
  3448. swap(ary, i + 1, j);
  3449. var q = i + 1;
  3450. // (2) Recurse on each half.
  3451. doQuickSort(ary, comparator, p, q - 1);
  3452. doQuickSort(ary, comparator, q + 1, r);
  3453. }
  3454. }
  3455. return doQuickSort;
  3456. }
  3457. function cloneSort(comparator) {
  3458. let template = SortTemplate.toString();
  3459. let templateFn = new Function(`return ${template}`)();
  3460. return templateFn(comparator);
  3461. }
  3462. /**
  3463. * Sort the given array in-place with the given comparator function.
  3464. *
  3465. * @param {Array} ary
  3466. * An array to sort.
  3467. * @param {function} comparator
  3468. * Function to use to compare two items.
  3469. */
  3470. let sortCache = new WeakMap();
  3471. quickSort$1.quickSort = function (ary, comparator, start = 0) {
  3472. let doQuickSort = sortCache.get(comparator);
  3473. if (doQuickSort === void 0) {
  3474. doQuickSort = cloneSort(comparator);
  3475. sortCache.set(comparator, doQuickSort);
  3476. }
  3477. doQuickSort(ary, comparator, start, ary.length - 1);
  3478. };
  3479. /* -*- Mode: js; js-indent-level: 2; -*- */
  3480. /*
  3481. * Copyright 2011 Mozilla Foundation and contributors
  3482. * Licensed under the New BSD license. See LICENSE or:
  3483. * http://opensource.org/licenses/BSD-3-Clause
  3484. */
  3485. var util$1 = util$5;
  3486. var binarySearch = binarySearch$1;
  3487. var ArraySet = arraySet.ArraySet;
  3488. var base64VLQ = base64Vlq;
  3489. var quickSort = quickSort$1.quickSort;
  3490. function SourceMapConsumer$1(aSourceMap, aSourceMapURL) {
  3491. var sourceMap = aSourceMap;
  3492. if (typeof aSourceMap === 'string') {
  3493. sourceMap = util$1.parseSourceMapInput(aSourceMap);
  3494. }
  3495. return sourceMap.sections != null
  3496. ? new IndexedSourceMapConsumer(sourceMap, aSourceMapURL)
  3497. : new BasicSourceMapConsumer(sourceMap, aSourceMapURL);
  3498. }
  3499. SourceMapConsumer$1.fromSourceMap = function(aSourceMap, aSourceMapURL) {
  3500. return BasicSourceMapConsumer.fromSourceMap(aSourceMap, aSourceMapURL);
  3501. };
  3502. /**
  3503. * The version of the source mapping spec that we are consuming.
  3504. */
  3505. SourceMapConsumer$1.prototype._version = 3;
  3506. // `__generatedMappings` and `__originalMappings` are arrays that hold the
  3507. // parsed mapping coordinates from the source map's "mappings" attribute. They
  3508. // are lazily instantiated, accessed via the `_generatedMappings` and
  3509. // `_originalMappings` getters respectively, and we only parse the mappings
  3510. // and create these arrays once queried for a source location. We jump through
  3511. // these hoops because there can be many thousands of mappings, and parsing
  3512. // them is expensive, so we only want to do it if we must.
  3513. //
  3514. // Each object in the arrays is of the form:
  3515. //
  3516. // {
  3517. // generatedLine: The line number in the generated code,
  3518. // generatedColumn: The column number in the generated code,
  3519. // source: The path to the original source file that generated this
  3520. // chunk of code,
  3521. // originalLine: The line number in the original source that
  3522. // corresponds to this chunk of generated code,
  3523. // originalColumn: The column number in the original source that
  3524. // corresponds to this chunk of generated code,
  3525. // name: The name of the original symbol which generated this chunk of
  3526. // code.
  3527. // }
  3528. //
  3529. // All properties except for `generatedLine` and `generatedColumn` can be
  3530. // `null`.
  3531. //
  3532. // `_generatedMappings` is ordered by the generated positions.
  3533. //
  3534. // `_originalMappings` is ordered by the original positions.
  3535. SourceMapConsumer$1.prototype.__generatedMappings = null;
  3536. Object.defineProperty(SourceMapConsumer$1.prototype, '_generatedMappings', {
  3537. configurable: true,
  3538. enumerable: true,
  3539. get: function () {
  3540. if (!this.__generatedMappings) {
  3541. this._parseMappings(this._mappings, this.sourceRoot);
  3542. }
  3543. return this.__generatedMappings;
  3544. }
  3545. });
  3546. SourceMapConsumer$1.prototype.__originalMappings = null;
  3547. Object.defineProperty(SourceMapConsumer$1.prototype, '_originalMappings', {
  3548. configurable: true,
  3549. enumerable: true,
  3550. get: function () {
  3551. if (!this.__originalMappings) {
  3552. this._parseMappings(this._mappings, this.sourceRoot);
  3553. }
  3554. return this.__originalMappings;
  3555. }
  3556. });
  3557. SourceMapConsumer$1.prototype._charIsMappingSeparator =
  3558. function SourceMapConsumer_charIsMappingSeparator(aStr, index) {
  3559. var c = aStr.charAt(index);
  3560. return c === ";" || c === ",";
  3561. };
  3562. /**
  3563. * Parse the mappings in a string in to a data structure which we can easily
  3564. * query (the ordered arrays in the `this.__generatedMappings` and
  3565. * `this.__originalMappings` properties).
  3566. */
  3567. SourceMapConsumer$1.prototype._parseMappings =
  3568. function SourceMapConsumer_parseMappings(aStr, aSourceRoot) {
  3569. throw new Error("Subclasses must implement _parseMappings");
  3570. };
  3571. SourceMapConsumer$1.GENERATED_ORDER = 1;
  3572. SourceMapConsumer$1.ORIGINAL_ORDER = 2;
  3573. SourceMapConsumer$1.GREATEST_LOWER_BOUND = 1;
  3574. SourceMapConsumer$1.LEAST_UPPER_BOUND = 2;
  3575. /**
  3576. * Iterate over each mapping between an original source/line/column and a
  3577. * generated line/column in this source map.
  3578. *
  3579. * @param Function aCallback
  3580. * The function that is called with each mapping.
  3581. * @param Object aContext
  3582. * Optional. If specified, this object will be the value of `this` every
  3583. * time that `aCallback` is called.
  3584. * @param aOrder
  3585. * Either `SourceMapConsumer.GENERATED_ORDER` or
  3586. * `SourceMapConsumer.ORIGINAL_ORDER`. Specifies whether you want to
  3587. * iterate over the mappings sorted by the generated file's line/column
  3588. * order or the original's source/line/column order, respectively. Defaults to
  3589. * `SourceMapConsumer.GENERATED_ORDER`.
  3590. */
  3591. SourceMapConsumer$1.prototype.eachMapping =
  3592. function SourceMapConsumer_eachMapping(aCallback, aContext, aOrder) {
  3593. var context = aContext || null;
  3594. var order = aOrder || SourceMapConsumer$1.GENERATED_ORDER;
  3595. var mappings;
  3596. switch (order) {
  3597. case SourceMapConsumer$1.GENERATED_ORDER:
  3598. mappings = this._generatedMappings;
  3599. break;
  3600. case SourceMapConsumer$1.ORIGINAL_ORDER:
  3601. mappings = this._originalMappings;
  3602. break;
  3603. default:
  3604. throw new Error("Unknown order of iteration.");
  3605. }
  3606. var sourceRoot = this.sourceRoot;
  3607. var boundCallback = aCallback.bind(context);
  3608. var names = this._names;
  3609. var sources = this._sources;
  3610. var sourceMapURL = this._sourceMapURL;
  3611. for (var i = 0, n = mappings.length; i < n; i++) {
  3612. var mapping = mappings[i];
  3613. var source = mapping.source === null ? null : sources.at(mapping.source);
  3614. source = util$1.computeSourceURL(sourceRoot, source, sourceMapURL);
  3615. boundCallback({
  3616. source: source,
  3617. generatedLine: mapping.generatedLine,
  3618. generatedColumn: mapping.generatedColumn,
  3619. originalLine: mapping.originalLine,
  3620. originalColumn: mapping.originalColumn,
  3621. name: mapping.name === null ? null : names.at(mapping.name)
  3622. });
  3623. }
  3624. };
  3625. /**
  3626. * Returns all generated line and column information for the original source,
  3627. * line, and column provided. If no column is provided, returns all mappings
  3628. * corresponding to a either the line we are searching for or the next
  3629. * closest line that has any mappings. Otherwise, returns all mappings
  3630. * corresponding to the given line and either the column we are searching for
  3631. * or the next closest column that has any offsets.
  3632. *
  3633. * The only argument is an object with the following properties:
  3634. *
  3635. * - source: The filename of the original source.
  3636. * - line: The line number in the original source. The line number is 1-based.
  3637. * - column: Optional. the column number in the original source.
  3638. * The column number is 0-based.
  3639. *
  3640. * and an array of objects is returned, each with the following properties:
  3641. *
  3642. * - line: The line number in the generated source, or null. The
  3643. * line number is 1-based.
  3644. * - column: The column number in the generated source, or null.
  3645. * The column number is 0-based.
  3646. */
  3647. SourceMapConsumer$1.prototype.allGeneratedPositionsFor =
  3648. function SourceMapConsumer_allGeneratedPositionsFor(aArgs) {
  3649. var line = util$1.getArg(aArgs, 'line');
  3650. // When there is no exact match, BasicSourceMapConsumer.prototype._findMapping
  3651. // returns the index of the closest mapping less than the needle. By
  3652. // setting needle.originalColumn to 0, we thus find the last mapping for
  3653. // the given line, provided such a mapping exists.
  3654. var needle = {
  3655. source: util$1.getArg(aArgs, 'source'),
  3656. originalLine: line,
  3657. originalColumn: util$1.getArg(aArgs, 'column', 0)
  3658. };
  3659. needle.source = this._findSourceIndex(needle.source);
  3660. if (needle.source < 0) {
  3661. return [];
  3662. }
  3663. var mappings = [];
  3664. var index = this._findMapping(needle,
  3665. this._originalMappings,
  3666. "originalLine",
  3667. "originalColumn",
  3668. util$1.compareByOriginalPositions,
  3669. binarySearch.LEAST_UPPER_BOUND);
  3670. if (index >= 0) {
  3671. var mapping = this._originalMappings[index];
  3672. if (aArgs.column === undefined) {
  3673. var originalLine = mapping.originalLine;
  3674. // Iterate until either we run out of mappings, or we run into
  3675. // a mapping for a different line than the one we found. Since
  3676. // mappings are sorted, this is guaranteed to find all mappings for
  3677. // the line we found.
  3678. while (mapping && mapping.originalLine === originalLine) {
  3679. mappings.push({
  3680. line: util$1.getArg(mapping, 'generatedLine', null),
  3681. column: util$1.getArg(mapping, 'generatedColumn', null),
  3682. lastColumn: util$1.getArg(mapping, 'lastGeneratedColumn', null)
  3683. });
  3684. mapping = this._originalMappings[++index];
  3685. }
  3686. } else {
  3687. var originalColumn = mapping.originalColumn;
  3688. // Iterate until either we run out of mappings, or we run into
  3689. // a mapping for a different line than the one we were searching for.
  3690. // Since mappings are sorted, this is guaranteed to find all mappings for
  3691. // the line we are searching for.
  3692. while (mapping &&
  3693. mapping.originalLine === line &&
  3694. mapping.originalColumn == originalColumn) {
  3695. mappings.push({
  3696. line: util$1.getArg(mapping, 'generatedLine', null),
  3697. column: util$1.getArg(mapping, 'generatedColumn', null),
  3698. lastColumn: util$1.getArg(mapping, 'lastGeneratedColumn', null)
  3699. });
  3700. mapping = this._originalMappings[++index];
  3701. }
  3702. }
  3703. }
  3704. return mappings;
  3705. };
  3706. sourceMapConsumer.SourceMapConsumer = SourceMapConsumer$1;
  3707. /**
  3708. * A BasicSourceMapConsumer instance represents a parsed source map which we can
  3709. * query for information about the original file positions by giving it a file
  3710. * position in the generated source.
  3711. *
  3712. * The first parameter is the raw source map (either as a JSON string, or
  3713. * already parsed to an object). According to the spec, source maps have the
  3714. * following attributes:
  3715. *
  3716. * - version: Which version of the source map spec this map is following.
  3717. * - sources: An array of URLs to the original source files.
  3718. * - names: An array of identifiers which can be referrenced by individual mappings.
  3719. * - sourceRoot: Optional. The URL root from which all sources are relative.
  3720. * - sourcesContent: Optional. An array of contents of the original source files.
  3721. * - mappings: A string of base64 VLQs which contain the actual mappings.
  3722. * - file: Optional. The generated file this source map is associated with.
  3723. *
  3724. * Here is an example source map, taken from the source map spec[0]:
  3725. *
  3726. * {
  3727. * version : 3,
  3728. * file: "out.js",
  3729. * sourceRoot : "",
  3730. * sources: ["foo.js", "bar.js"],
  3731. * names: ["src", "maps", "are", "fun"],
  3732. * mappings: "AA,AB;;ABCDE;"
  3733. * }
  3734. *
  3735. * The second parameter, if given, is a string whose value is the URL
  3736. * at which the source map was found. This URL is used to compute the
  3737. * sources array.
  3738. *
  3739. * [0]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit?pli=1#
  3740. */
  3741. function BasicSourceMapConsumer(aSourceMap, aSourceMapURL) {
  3742. var sourceMap = aSourceMap;
  3743. if (typeof aSourceMap === 'string') {
  3744. sourceMap = util$1.parseSourceMapInput(aSourceMap);
  3745. }
  3746. var version = util$1.getArg(sourceMap, 'version');
  3747. var sources = util$1.getArg(sourceMap, 'sources');
  3748. // Sass 3.3 leaves out the 'names' array, so we deviate from the spec (which
  3749. // requires the array) to play nice here.
  3750. var names = util$1.getArg(sourceMap, 'names', []);
  3751. var sourceRoot = util$1.getArg(sourceMap, 'sourceRoot', null);
  3752. var sourcesContent = util$1.getArg(sourceMap, 'sourcesContent', null);
  3753. var mappings = util$1.getArg(sourceMap, 'mappings');
  3754. var file = util$1.getArg(sourceMap, 'file', null);
  3755. // Once again, Sass deviates from the spec and supplies the version as a
  3756. // string rather than a number, so we use loose equality checking here.
  3757. if (version != this._version) {
  3758. throw new Error('Unsupported version: ' + version);
  3759. }
  3760. if (sourceRoot) {
  3761. sourceRoot = util$1.normalize(sourceRoot);
  3762. }
  3763. sources = sources
  3764. .map(String)
  3765. // Some source maps produce relative source paths like "./foo.js" instead of
  3766. // "foo.js". Normalize these first so that future comparisons will succeed.
  3767. // See bugzil.la/1090768.
  3768. .map(util$1.normalize)
  3769. // Always ensure that absolute sources are internally stored relative to
  3770. // the source root, if the source root is absolute. Not doing this would
  3771. // be particularly problematic when the source root is a prefix of the
  3772. // source (valid, but why??). See github issue #199 and bugzil.la/1188982.
  3773. .map(function (source) {
  3774. return sourceRoot && util$1.isAbsolute(sourceRoot) && util$1.isAbsolute(source)
  3775. ? util$1.relative(sourceRoot, source)
  3776. : source;
  3777. });
  3778. // Pass `true` below to allow duplicate names and sources. While source maps
  3779. // are intended to be compressed and deduplicated, the TypeScript compiler
  3780. // sometimes generates source maps with duplicates in them. See Github issue
  3781. // #72 and bugzil.la/889492.
  3782. this._names = ArraySet.fromArray(names.map(String), true);
  3783. this._sources = ArraySet.fromArray(sources, true);
  3784. this._absoluteSources = this._sources.toArray().map(function (s) {
  3785. return util$1.computeSourceURL(sourceRoot, s, aSourceMapURL);
  3786. });
  3787. this.sourceRoot = sourceRoot;
  3788. this.sourcesContent = sourcesContent;
  3789. this._mappings = mappings;
  3790. this._sourceMapURL = aSourceMapURL;
  3791. this.file = file;
  3792. }
  3793. BasicSourceMapConsumer.prototype = Object.create(SourceMapConsumer$1.prototype);
  3794. BasicSourceMapConsumer.prototype.consumer = SourceMapConsumer$1;
  3795. /**
  3796. * Utility function to find the index of a source. Returns -1 if not
  3797. * found.
  3798. */
  3799. BasicSourceMapConsumer.prototype._findSourceIndex = function(aSource) {
  3800. var relativeSource = aSource;
  3801. if (this.sourceRoot != null) {
  3802. relativeSource = util$1.relative(this.sourceRoot, relativeSource);
  3803. }
  3804. if (this._sources.has(relativeSource)) {
  3805. return this._sources.indexOf(relativeSource);
  3806. }
  3807. // Maybe aSource is an absolute URL as returned by |sources|. In
  3808. // this case we can't simply undo the transform.
  3809. var i;
  3810. for (i = 0; i < this._absoluteSources.length; ++i) {
  3811. if (this._absoluteSources[i] == aSource) {
  3812. return i;
  3813. }
  3814. }
  3815. return -1;
  3816. };
  3817. /**
  3818. * Create a BasicSourceMapConsumer from a SourceMapGenerator.
  3819. *
  3820. * @param SourceMapGenerator aSourceMap
  3821. * The source map that will be consumed.
  3822. * @param String aSourceMapURL
  3823. * The URL at which the source map can be found (optional)
  3824. * @returns BasicSourceMapConsumer
  3825. */
  3826. BasicSourceMapConsumer.fromSourceMap =
  3827. function SourceMapConsumer_fromSourceMap(aSourceMap, aSourceMapURL) {
  3828. var smc = Object.create(BasicSourceMapConsumer.prototype);
  3829. var names = smc._names = ArraySet.fromArray(aSourceMap._names.toArray(), true);
  3830. var sources = smc._sources = ArraySet.fromArray(aSourceMap._sources.toArray(), true);
  3831. smc.sourceRoot = aSourceMap._sourceRoot;
  3832. smc.sourcesContent = aSourceMap._generateSourcesContent(smc._sources.toArray(),
  3833. smc.sourceRoot);
  3834. smc.file = aSourceMap._file;
  3835. smc._sourceMapURL = aSourceMapURL;
  3836. smc._absoluteSources = smc._sources.toArray().map(function (s) {
  3837. return util$1.computeSourceURL(smc.sourceRoot, s, aSourceMapURL);
  3838. });
  3839. // Because we are modifying the entries (by converting string sources and
  3840. // names to indices into the sources and names ArraySets), we have to make
  3841. // a copy of the entry or else bad things happen. Shared mutable state
  3842. // strikes again! See github issue #191.
  3843. var generatedMappings = aSourceMap._mappings.toArray().slice();
  3844. var destGeneratedMappings = smc.__generatedMappings = [];
  3845. var destOriginalMappings = smc.__originalMappings = [];
  3846. for (var i = 0, length = generatedMappings.length; i < length; i++) {
  3847. var srcMapping = generatedMappings[i];
  3848. var destMapping = new Mapping;
  3849. destMapping.generatedLine = srcMapping.generatedLine;
  3850. destMapping.generatedColumn = srcMapping.generatedColumn;
  3851. if (srcMapping.source) {
  3852. destMapping.source = sources.indexOf(srcMapping.source);
  3853. destMapping.originalLine = srcMapping.originalLine;
  3854. destMapping.originalColumn = srcMapping.originalColumn;
  3855. if (srcMapping.name) {
  3856. destMapping.name = names.indexOf(srcMapping.name);
  3857. }
  3858. destOriginalMappings.push(destMapping);
  3859. }
  3860. destGeneratedMappings.push(destMapping);
  3861. }
  3862. quickSort(smc.__originalMappings, util$1.compareByOriginalPositions);
  3863. return smc;
  3864. };
  3865. /**
  3866. * The version of the source mapping spec that we are consuming.
  3867. */
  3868. BasicSourceMapConsumer.prototype._version = 3;
  3869. /**
  3870. * The list of original sources.
  3871. */
  3872. Object.defineProperty(BasicSourceMapConsumer.prototype, 'sources', {
  3873. get: function () {
  3874. return this._absoluteSources.slice();
  3875. }
  3876. });
  3877. /**
  3878. * Provide the JIT with a nice shape / hidden class.
  3879. */
  3880. function Mapping() {
  3881. this.generatedLine = 0;
  3882. this.generatedColumn = 0;
  3883. this.source = null;
  3884. this.originalLine = null;
  3885. this.originalColumn = null;
  3886. this.name = null;
  3887. }
  3888. /**
  3889. * Parse the mappings in a string in to a data structure which we can easily
  3890. * query (the ordered arrays in the `this.__generatedMappings` and
  3891. * `this.__originalMappings` properties).
  3892. */
  3893. const compareGenerated = util$1.compareByGeneratedPositionsDeflatedNoLine;
  3894. function sortGenerated(array, start) {
  3895. let l = array.length;
  3896. let n = array.length - start;
  3897. if (n <= 1) {
  3898. return;
  3899. } else if (n == 2) {
  3900. let a = array[start];
  3901. let b = array[start + 1];
  3902. if (compareGenerated(a, b) > 0) {
  3903. array[start] = b;
  3904. array[start + 1] = a;
  3905. }
  3906. } else if (n < 20) {
  3907. for (let i = start; i < l; i++) {
  3908. for (let j = i; j > start; j--) {
  3909. let a = array[j - 1];
  3910. let b = array[j];
  3911. if (compareGenerated(a, b) <= 0) {
  3912. break;
  3913. }
  3914. array[j - 1] = b;
  3915. array[j] = a;
  3916. }
  3917. }
  3918. } else {
  3919. quickSort(array, compareGenerated, start);
  3920. }
  3921. }
  3922. BasicSourceMapConsumer.prototype._parseMappings =
  3923. function SourceMapConsumer_parseMappings(aStr, aSourceRoot) {
  3924. var generatedLine = 1;
  3925. var previousGeneratedColumn = 0;
  3926. var previousOriginalLine = 0;
  3927. var previousOriginalColumn = 0;
  3928. var previousSource = 0;
  3929. var previousName = 0;
  3930. var length = aStr.length;
  3931. var index = 0;
  3932. var temp = {};
  3933. var originalMappings = [];
  3934. var generatedMappings = [];
  3935. var mapping, segment, end, value;
  3936. let subarrayStart = 0;
  3937. while (index < length) {
  3938. if (aStr.charAt(index) === ';') {
  3939. generatedLine++;
  3940. index++;
  3941. previousGeneratedColumn = 0;
  3942. sortGenerated(generatedMappings, subarrayStart);
  3943. subarrayStart = generatedMappings.length;
  3944. }
  3945. else if (aStr.charAt(index) === ',') {
  3946. index++;
  3947. }
  3948. else {
  3949. mapping = new Mapping();
  3950. mapping.generatedLine = generatedLine;
  3951. for (end = index; end < length; end++) {
  3952. if (this._charIsMappingSeparator(aStr, end)) {
  3953. break;
  3954. }
  3955. }
  3956. aStr.slice(index, end);
  3957. segment = [];
  3958. while (index < end) {
  3959. base64VLQ.decode(aStr, index, temp);
  3960. value = temp.value;
  3961. index = temp.rest;
  3962. segment.push(value);
  3963. }
  3964. if (segment.length === 2) {
  3965. throw new Error('Found a source, but no line and column');
  3966. }
  3967. if (segment.length === 3) {
  3968. throw new Error('Found a source and line, but no column');
  3969. }
  3970. // Generated column.
  3971. mapping.generatedColumn = previousGeneratedColumn + segment[0];
  3972. previousGeneratedColumn = mapping.generatedColumn;
  3973. if (segment.length > 1) {
  3974. // Original source.
  3975. mapping.source = previousSource + segment[1];
  3976. previousSource += segment[1];
  3977. // Original line.
  3978. mapping.originalLine = previousOriginalLine + segment[2];
  3979. previousOriginalLine = mapping.originalLine;
  3980. // Lines are stored 0-based
  3981. mapping.originalLine += 1;
  3982. // Original column.
  3983. mapping.originalColumn = previousOriginalColumn + segment[3];
  3984. previousOriginalColumn = mapping.originalColumn;
  3985. if (segment.length > 4) {
  3986. // Original name.
  3987. mapping.name = previousName + segment[4];
  3988. previousName += segment[4];
  3989. }
  3990. }
  3991. generatedMappings.push(mapping);
  3992. if (typeof mapping.originalLine === 'number') {
  3993. let currentSource = mapping.source;
  3994. while (originalMappings.length <= currentSource) {
  3995. originalMappings.push(null);
  3996. }
  3997. if (originalMappings[currentSource] === null) {
  3998. originalMappings[currentSource] = [];
  3999. }
  4000. originalMappings[currentSource].push(mapping);
  4001. }
  4002. }
  4003. }
  4004. sortGenerated(generatedMappings, subarrayStart);
  4005. this.__generatedMappings = generatedMappings;
  4006. for (var i = 0; i < originalMappings.length; i++) {
  4007. if (originalMappings[i] != null) {
  4008. quickSort(originalMappings[i], util$1.compareByOriginalPositionsNoSource);
  4009. }
  4010. }
  4011. this.__originalMappings = [].concat(...originalMappings);
  4012. };
  4013. /**
  4014. * Find the mapping that best matches the hypothetical "needle" mapping that
  4015. * we are searching for in the given "haystack" of mappings.
  4016. */
  4017. BasicSourceMapConsumer.prototype._findMapping =
  4018. function SourceMapConsumer_findMapping(aNeedle, aMappings, aLineName,
  4019. aColumnName, aComparator, aBias) {
  4020. // To return the position we are searching for, we must first find the
  4021. // mapping for the given position and then return the opposite position it
  4022. // points to. Because the mappings are sorted, we can use binary search to
  4023. // find the best mapping.
  4024. if (aNeedle[aLineName] <= 0) {
  4025. throw new TypeError('Line must be greater than or equal to 1, got '
  4026. + aNeedle[aLineName]);
  4027. }
  4028. if (aNeedle[aColumnName] < 0) {
  4029. throw new TypeError('Column must be greater than or equal to 0, got '
  4030. + aNeedle[aColumnName]);
  4031. }
  4032. return binarySearch.search(aNeedle, aMappings, aComparator, aBias);
  4033. };
  4034. /**
  4035. * Compute the last column for each generated mapping. The last column is
  4036. * inclusive.
  4037. */
  4038. BasicSourceMapConsumer.prototype.computeColumnSpans =
  4039. function SourceMapConsumer_computeColumnSpans() {
  4040. for (var index = 0; index < this._generatedMappings.length; ++index) {
  4041. var mapping = this._generatedMappings[index];
  4042. // Mappings do not contain a field for the last generated columnt. We
  4043. // can come up with an optimistic estimate, however, by assuming that
  4044. // mappings are contiguous (i.e. given two consecutive mappings, the
  4045. // first mapping ends where the second one starts).
  4046. if (index + 1 < this._generatedMappings.length) {
  4047. var nextMapping = this._generatedMappings[index + 1];
  4048. if (mapping.generatedLine === nextMapping.generatedLine) {
  4049. mapping.lastGeneratedColumn = nextMapping.generatedColumn - 1;
  4050. continue;
  4051. }
  4052. }
  4053. // The last mapping for each line spans the entire line.
  4054. mapping.lastGeneratedColumn = Infinity;
  4055. }
  4056. };
  4057. /**
  4058. * Returns the original source, line, and column information for the generated
  4059. * source's line and column positions provided. The only argument is an object
  4060. * with the following properties:
  4061. *
  4062. * - line: The line number in the generated source. The line number
  4063. * is 1-based.
  4064. * - column: The column number in the generated source. The column
  4065. * number is 0-based.
  4066. * - bias: Either 'SourceMapConsumer.GREATEST_LOWER_BOUND' or
  4067. * 'SourceMapConsumer.LEAST_UPPER_BOUND'. Specifies whether to return the
  4068. * closest element that is smaller than or greater than the one we are
  4069. * searching for, respectively, if the exact element cannot be found.
  4070. * Defaults to 'SourceMapConsumer.GREATEST_LOWER_BOUND'.
  4071. *
  4072. * and an object is returned with the following properties:
  4073. *
  4074. * - source: The original source file, or null.
  4075. * - line: The line number in the original source, or null. The
  4076. * line number is 1-based.
  4077. * - column: The column number in the original source, or null. The
  4078. * column number is 0-based.
  4079. * - name: The original identifier, or null.
  4080. */
  4081. BasicSourceMapConsumer.prototype.originalPositionFor =
  4082. function SourceMapConsumer_originalPositionFor(aArgs) {
  4083. var needle = {
  4084. generatedLine: util$1.getArg(aArgs, 'line'),
  4085. generatedColumn: util$1.getArg(aArgs, 'column')
  4086. };
  4087. var index = this._findMapping(
  4088. needle,
  4089. this._generatedMappings,
  4090. "generatedLine",
  4091. "generatedColumn",
  4092. util$1.compareByGeneratedPositionsDeflated,
  4093. util$1.getArg(aArgs, 'bias', SourceMapConsumer$1.GREATEST_LOWER_BOUND)
  4094. );
  4095. if (index >= 0) {
  4096. var mapping = this._generatedMappings[index];
  4097. if (mapping.generatedLine === needle.generatedLine) {
  4098. var source = util$1.getArg(mapping, 'source', null);
  4099. if (source !== null) {
  4100. source = this._sources.at(source);
  4101. source = util$1.computeSourceURL(this.sourceRoot, source, this._sourceMapURL);
  4102. }
  4103. var name = util$1.getArg(mapping, 'name', null);
  4104. if (name !== null) {
  4105. name = this._names.at(name);
  4106. }
  4107. return {
  4108. source: source,
  4109. line: util$1.getArg(mapping, 'originalLine', null),
  4110. column: util$1.getArg(mapping, 'originalColumn', null),
  4111. name: name
  4112. };
  4113. }
  4114. }
  4115. return {
  4116. source: null,
  4117. line: null,
  4118. column: null,
  4119. name: null
  4120. };
  4121. };
  4122. /**
  4123. * Return true if we have the source content for every source in the source
  4124. * map, false otherwise.
  4125. */
  4126. BasicSourceMapConsumer.prototype.hasContentsOfAllSources =
  4127. function BasicSourceMapConsumer_hasContentsOfAllSources() {
  4128. if (!this.sourcesContent) {
  4129. return false;
  4130. }
  4131. return this.sourcesContent.length >= this._sources.size() &&
  4132. !this.sourcesContent.some(function (sc) { return sc == null; });
  4133. };
  4134. /**
  4135. * Returns the original source content. The only argument is the url of the
  4136. * original source file. Returns null if no original source content is
  4137. * available.
  4138. */
  4139. BasicSourceMapConsumer.prototype.sourceContentFor =
  4140. function SourceMapConsumer_sourceContentFor(aSource, nullOnMissing) {
  4141. if (!this.sourcesContent) {
  4142. return null;
  4143. }
  4144. var index = this._findSourceIndex(aSource);
  4145. if (index >= 0) {
  4146. return this.sourcesContent[index];
  4147. }
  4148. var relativeSource = aSource;
  4149. if (this.sourceRoot != null) {
  4150. relativeSource = util$1.relative(this.sourceRoot, relativeSource);
  4151. }
  4152. var url;
  4153. if (this.sourceRoot != null
  4154. && (url = util$1.urlParse(this.sourceRoot))) {
  4155. // XXX: file:// URIs and absolute paths lead to unexpected behavior for
  4156. // many users. We can help them out when they expect file:// URIs to
  4157. // behave like it would if they were running a local HTTP server. See
  4158. // https://bugzilla.mozilla.org/show_bug.cgi?id=885597.
  4159. var fileUriAbsPath = relativeSource.replace(/^file:\/\//, "");
  4160. if (url.scheme == "file"
  4161. && this._sources.has(fileUriAbsPath)) {
  4162. return this.sourcesContent[this._sources.indexOf(fileUriAbsPath)]
  4163. }
  4164. if ((!url.path || url.path == "/")
  4165. && this._sources.has("/" + relativeSource)) {
  4166. return this.sourcesContent[this._sources.indexOf("/" + relativeSource)];
  4167. }
  4168. }
  4169. // This function is used recursively from
  4170. // IndexedSourceMapConsumer.prototype.sourceContentFor. In that case, we
  4171. // don't want to throw if we can't find the source - we just want to
  4172. // return null, so we provide a flag to exit gracefully.
  4173. if (nullOnMissing) {
  4174. return null;
  4175. }
  4176. else {
  4177. throw new Error('"' + relativeSource + '" is not in the SourceMap.');
  4178. }
  4179. };
  4180. /**
  4181. * Returns the generated line and column information for the original source,
  4182. * line, and column positions provided. The only argument is an object with
  4183. * the following properties:
  4184. *
  4185. * - source: The filename of the original source.
  4186. * - line: The line number in the original source. The line number
  4187. * is 1-based.
  4188. * - column: The column number in the original source. The column
  4189. * number is 0-based.
  4190. * - bias: Either 'SourceMapConsumer.GREATEST_LOWER_BOUND' or
  4191. * 'SourceMapConsumer.LEAST_UPPER_BOUND'. Specifies whether to return the
  4192. * closest element that is smaller than or greater than the one we are
  4193. * searching for, respectively, if the exact element cannot be found.
  4194. * Defaults to 'SourceMapConsumer.GREATEST_LOWER_BOUND'.
  4195. *
  4196. * and an object is returned with the following properties:
  4197. *
  4198. * - line: The line number in the generated source, or null. The
  4199. * line number is 1-based.
  4200. * - column: The column number in the generated source, or null.
  4201. * The column number is 0-based.
  4202. */
  4203. BasicSourceMapConsumer.prototype.generatedPositionFor =
  4204. function SourceMapConsumer_generatedPositionFor(aArgs) {
  4205. var source = util$1.getArg(aArgs, 'source');
  4206. source = this._findSourceIndex(source);
  4207. if (source < 0) {
  4208. return {
  4209. line: null,
  4210. column: null,
  4211. lastColumn: null
  4212. };
  4213. }
  4214. var needle = {
  4215. source: source,
  4216. originalLine: util$1.getArg(aArgs, 'line'),
  4217. originalColumn: util$1.getArg(aArgs, 'column')
  4218. };
  4219. var index = this._findMapping(
  4220. needle,
  4221. this._originalMappings,
  4222. "originalLine",
  4223. "originalColumn",
  4224. util$1.compareByOriginalPositions,
  4225. util$1.getArg(aArgs, 'bias', SourceMapConsumer$1.GREATEST_LOWER_BOUND)
  4226. );
  4227. if (index >= 0) {
  4228. var mapping = this._originalMappings[index];
  4229. if (mapping.source === needle.source) {
  4230. return {
  4231. line: util$1.getArg(mapping, 'generatedLine', null),
  4232. column: util$1.getArg(mapping, 'generatedColumn', null),
  4233. lastColumn: util$1.getArg(mapping, 'lastGeneratedColumn', null)
  4234. };
  4235. }
  4236. }
  4237. return {
  4238. line: null,
  4239. column: null,
  4240. lastColumn: null
  4241. };
  4242. };
  4243. sourceMapConsumer.BasicSourceMapConsumer = BasicSourceMapConsumer;
  4244. /**
  4245. * An IndexedSourceMapConsumer instance represents a parsed source map which
  4246. * we can query for information. It differs from BasicSourceMapConsumer in
  4247. * that it takes "indexed" source maps (i.e. ones with a "sections" field) as
  4248. * input.
  4249. *
  4250. * The first parameter is a raw source map (either as a JSON string, or already
  4251. * parsed to an object). According to the spec for indexed source maps, they
  4252. * have the following attributes:
  4253. *
  4254. * - version: Which version of the source map spec this map is following.
  4255. * - file: Optional. The generated file this source map is associated with.
  4256. * - sections: A list of section definitions.
  4257. *
  4258. * Each value under the "sections" field has two fields:
  4259. * - offset: The offset into the original specified at which this section
  4260. * begins to apply, defined as an object with a "line" and "column"
  4261. * field.
  4262. * - map: A source map definition. This source map could also be indexed,
  4263. * but doesn't have to be.
  4264. *
  4265. * Instead of the "map" field, it's also possible to have a "url" field
  4266. * specifying a URL to retrieve a source map from, but that's currently
  4267. * unsupported.
  4268. *
  4269. * Here's an example source map, taken from the source map spec[0], but
  4270. * modified to omit a section which uses the "url" field.
  4271. *
  4272. * {
  4273. * version : 3,
  4274. * file: "app.js",
  4275. * sections: [{
  4276. * offset: {line:100, column:10},
  4277. * map: {
  4278. * version : 3,
  4279. * file: "section.js",
  4280. * sources: ["foo.js", "bar.js"],
  4281. * names: ["src", "maps", "are", "fun"],
  4282. * mappings: "AAAA,E;;ABCDE;"
  4283. * }
  4284. * }],
  4285. * }
  4286. *
  4287. * The second parameter, if given, is a string whose value is the URL
  4288. * at which the source map was found. This URL is used to compute the
  4289. * sources array.
  4290. *
  4291. * [0]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit#heading=h.535es3xeprgt
  4292. */
  4293. function IndexedSourceMapConsumer(aSourceMap, aSourceMapURL) {
  4294. var sourceMap = aSourceMap;
  4295. if (typeof aSourceMap === 'string') {
  4296. sourceMap = util$1.parseSourceMapInput(aSourceMap);
  4297. }
  4298. var version = util$1.getArg(sourceMap, 'version');
  4299. var sections = util$1.getArg(sourceMap, 'sections');
  4300. if (version != this._version) {
  4301. throw new Error('Unsupported version: ' + version);
  4302. }
  4303. this._sources = new ArraySet();
  4304. this._names = new ArraySet();
  4305. var lastOffset = {
  4306. line: -1,
  4307. column: 0
  4308. };
  4309. this._sections = sections.map(function (s) {
  4310. if (s.url) {
  4311. // The url field will require support for asynchronicity.
  4312. // See https://github.com/mozilla/source-map/issues/16
  4313. throw new Error('Support for url field in sections not implemented.');
  4314. }
  4315. var offset = util$1.getArg(s, 'offset');
  4316. var offsetLine = util$1.getArg(offset, 'line');
  4317. var offsetColumn = util$1.getArg(offset, 'column');
  4318. if (offsetLine < lastOffset.line ||
  4319. (offsetLine === lastOffset.line && offsetColumn < lastOffset.column)) {
  4320. throw new Error('Section offsets must be ordered and non-overlapping.');
  4321. }
  4322. lastOffset = offset;
  4323. return {
  4324. generatedOffset: {
  4325. // The offset fields are 0-based, but we use 1-based indices when
  4326. // encoding/decoding from VLQ.
  4327. generatedLine: offsetLine + 1,
  4328. generatedColumn: offsetColumn + 1
  4329. },
  4330. consumer: new SourceMapConsumer$1(util$1.getArg(s, 'map'), aSourceMapURL)
  4331. }
  4332. });
  4333. }
  4334. IndexedSourceMapConsumer.prototype = Object.create(SourceMapConsumer$1.prototype);
  4335. IndexedSourceMapConsumer.prototype.constructor = SourceMapConsumer$1;
  4336. /**
  4337. * The version of the source mapping spec that we are consuming.
  4338. */
  4339. IndexedSourceMapConsumer.prototype._version = 3;
  4340. /**
  4341. * The list of original sources.
  4342. */
  4343. Object.defineProperty(IndexedSourceMapConsumer.prototype, 'sources', {
  4344. get: function () {
  4345. var sources = [];
  4346. for (var i = 0; i < this._sections.length; i++) {
  4347. for (var j = 0; j < this._sections[i].consumer.sources.length; j++) {
  4348. sources.push(this._sections[i].consumer.sources[j]);
  4349. }
  4350. }
  4351. return sources;
  4352. }
  4353. });
  4354. /**
  4355. * Returns the original source, line, and column information for the generated
  4356. * source's line and column positions provided. The only argument is an object
  4357. * with the following properties:
  4358. *
  4359. * - line: The line number in the generated source. The line number
  4360. * is 1-based.
  4361. * - column: The column number in the generated source. The column
  4362. * number is 0-based.
  4363. *
  4364. * and an object is returned with the following properties:
  4365. *
  4366. * - source: The original source file, or null.
  4367. * - line: The line number in the original source, or null. The
  4368. * line number is 1-based.
  4369. * - column: The column number in the original source, or null. The
  4370. * column number is 0-based.
  4371. * - name: The original identifier, or null.
  4372. */
  4373. IndexedSourceMapConsumer.prototype.originalPositionFor =
  4374. function IndexedSourceMapConsumer_originalPositionFor(aArgs) {
  4375. var needle = {
  4376. generatedLine: util$1.getArg(aArgs, 'line'),
  4377. generatedColumn: util$1.getArg(aArgs, 'column')
  4378. };
  4379. // Find the section containing the generated position we're trying to map
  4380. // to an original position.
  4381. var sectionIndex = binarySearch.search(needle, this._sections,
  4382. function(needle, section) {
  4383. var cmp = needle.generatedLine - section.generatedOffset.generatedLine;
  4384. if (cmp) {
  4385. return cmp;
  4386. }
  4387. return (needle.generatedColumn -
  4388. section.generatedOffset.generatedColumn);
  4389. });
  4390. var section = this._sections[sectionIndex];
  4391. if (!section) {
  4392. return {
  4393. source: null,
  4394. line: null,
  4395. column: null,
  4396. name: null
  4397. };
  4398. }
  4399. return section.consumer.originalPositionFor({
  4400. line: needle.generatedLine -
  4401. (section.generatedOffset.generatedLine - 1),
  4402. column: needle.generatedColumn -
  4403. (section.generatedOffset.generatedLine === needle.generatedLine
  4404. ? section.generatedOffset.generatedColumn - 1
  4405. : 0),
  4406. bias: aArgs.bias
  4407. });
  4408. };
  4409. /**
  4410. * Return true if we have the source content for every source in the source
  4411. * map, false otherwise.
  4412. */
  4413. IndexedSourceMapConsumer.prototype.hasContentsOfAllSources =
  4414. function IndexedSourceMapConsumer_hasContentsOfAllSources() {
  4415. return this._sections.every(function (s) {
  4416. return s.consumer.hasContentsOfAllSources();
  4417. });
  4418. };
  4419. /**
  4420. * Returns the original source content. The only argument is the url of the
  4421. * original source file. Returns null if no original source content is
  4422. * available.
  4423. */
  4424. IndexedSourceMapConsumer.prototype.sourceContentFor =
  4425. function IndexedSourceMapConsumer_sourceContentFor(aSource, nullOnMissing) {
  4426. for (var i = 0; i < this._sections.length; i++) {
  4427. var section = this._sections[i];
  4428. var content = section.consumer.sourceContentFor(aSource, true);
  4429. if (content) {
  4430. return content;
  4431. }
  4432. }
  4433. if (nullOnMissing) {
  4434. return null;
  4435. }
  4436. else {
  4437. throw new Error('"' + aSource + '" is not in the SourceMap.');
  4438. }
  4439. };
  4440. /**
  4441. * Returns the generated line and column information for the original source,
  4442. * line, and column positions provided. The only argument is an object with
  4443. * the following properties:
  4444. *
  4445. * - source: The filename of the original source.
  4446. * - line: The line number in the original source. The line number
  4447. * is 1-based.
  4448. * - column: The column number in the original source. The column
  4449. * number is 0-based.
  4450. *
  4451. * and an object is returned with the following properties:
  4452. *
  4453. * - line: The line number in the generated source, or null. The
  4454. * line number is 1-based.
  4455. * - column: The column number in the generated source, or null.
  4456. * The column number is 0-based.
  4457. */
  4458. IndexedSourceMapConsumer.prototype.generatedPositionFor =
  4459. function IndexedSourceMapConsumer_generatedPositionFor(aArgs) {
  4460. for (var i = 0; i < this._sections.length; i++) {
  4461. var section = this._sections[i];
  4462. // Only consider this section if the requested source is in the list of
  4463. // sources of the consumer.
  4464. if (section.consumer._findSourceIndex(util$1.getArg(aArgs, 'source')) === -1) {
  4465. continue;
  4466. }
  4467. var generatedPosition = section.consumer.generatedPositionFor(aArgs);
  4468. if (generatedPosition) {
  4469. var ret = {
  4470. line: generatedPosition.line +
  4471. (section.generatedOffset.generatedLine - 1),
  4472. column: generatedPosition.column +
  4473. (section.generatedOffset.generatedLine === generatedPosition.line
  4474. ? section.generatedOffset.generatedColumn - 1
  4475. : 0)
  4476. };
  4477. return ret;
  4478. }
  4479. }
  4480. return {
  4481. line: null,
  4482. column: null
  4483. };
  4484. };
  4485. /**
  4486. * Parse the mappings in a string in to a data structure which we can easily
  4487. * query (the ordered arrays in the `this.__generatedMappings` and
  4488. * `this.__originalMappings` properties).
  4489. */
  4490. IndexedSourceMapConsumer.prototype._parseMappings =
  4491. function IndexedSourceMapConsumer_parseMappings(aStr, aSourceRoot) {
  4492. this.__generatedMappings = [];
  4493. this.__originalMappings = [];
  4494. for (var i = 0; i < this._sections.length; i++) {
  4495. var section = this._sections[i];
  4496. var sectionMappings = section.consumer._generatedMappings;
  4497. for (var j = 0; j < sectionMappings.length; j++) {
  4498. var mapping = sectionMappings[j];
  4499. var source = section.consumer._sources.at(mapping.source);
  4500. source = util$1.computeSourceURL(section.consumer.sourceRoot, source, this._sourceMapURL);
  4501. this._sources.add(source);
  4502. source = this._sources.indexOf(source);
  4503. var name = null;
  4504. if (mapping.name) {
  4505. name = section.consumer._names.at(mapping.name);
  4506. this._names.add(name);
  4507. name = this._names.indexOf(name);
  4508. }
  4509. // The mappings coming from the consumer for the section have
  4510. // generated positions relative to the start of the section, so we
  4511. // need to offset them to be relative to the start of the concatenated
  4512. // generated file.
  4513. var adjustedMapping = {
  4514. source: source,
  4515. generatedLine: mapping.generatedLine +
  4516. (section.generatedOffset.generatedLine - 1),
  4517. generatedColumn: mapping.generatedColumn +
  4518. (section.generatedOffset.generatedLine === mapping.generatedLine
  4519. ? section.generatedOffset.generatedColumn - 1
  4520. : 0),
  4521. originalLine: mapping.originalLine,
  4522. originalColumn: mapping.originalColumn,
  4523. name: name
  4524. };
  4525. this.__generatedMappings.push(adjustedMapping);
  4526. if (typeof adjustedMapping.originalLine === 'number') {
  4527. this.__originalMappings.push(adjustedMapping);
  4528. }
  4529. }
  4530. }
  4531. quickSort(this.__generatedMappings, util$1.compareByGeneratedPositionsDeflated);
  4532. quickSort(this.__originalMappings, util$1.compareByOriginalPositions);
  4533. };
  4534. sourceMapConsumer.IndexedSourceMapConsumer = IndexedSourceMapConsumer;
  4535. /* -*- Mode: js; js-indent-level: 2; -*- */
  4536. /*
  4537. * Copyright 2011 Mozilla Foundation and contributors
  4538. * Licensed under the New BSD license. See LICENSE or:
  4539. * http://opensource.org/licenses/BSD-3-Clause
  4540. */
  4541. var SourceMapGenerator = sourceMapGenerator.SourceMapGenerator;
  4542. var util = util$5;
  4543. // Matches a Windows-style `\r\n` newline or a `\n` newline used by all other
  4544. // operating systems these days (capturing the result).
  4545. var REGEX_NEWLINE = /(\r?\n)/;
  4546. // Newline character code for charCodeAt() comparisons
  4547. var NEWLINE_CODE = 10;
  4548. // Private symbol for identifying `SourceNode`s when multiple versions of
  4549. // the source-map library are loaded. This MUST NOT CHANGE across
  4550. // versions!
  4551. var isSourceNode = "$$$isSourceNode$$$";
  4552. /**
  4553. * SourceNodes provide a way to abstract over interpolating/concatenating
  4554. * snippets of generated JavaScript source code while maintaining the line and
  4555. * column information associated with the original source code.
  4556. *
  4557. * @param aLine The original line number.
  4558. * @param aColumn The original column number.
  4559. * @param aSource The original source's filename.
  4560. * @param aChunks Optional. An array of strings which are snippets of
  4561. * generated JS, or other SourceNodes.
  4562. * @param aName The original identifier.
  4563. */
  4564. function SourceNode(aLine, aColumn, aSource, aChunks, aName) {
  4565. this.children = [];
  4566. this.sourceContents = {};
  4567. this.line = aLine == null ? null : aLine;
  4568. this.column = aColumn == null ? null : aColumn;
  4569. this.source = aSource == null ? null : aSource;
  4570. this.name = aName == null ? null : aName;
  4571. this[isSourceNode] = true;
  4572. if (aChunks != null) this.add(aChunks);
  4573. }
  4574. /**
  4575. * Creates a SourceNode from generated code and a SourceMapConsumer.
  4576. *
  4577. * @param aGeneratedCode The generated code
  4578. * @param aSourceMapConsumer The SourceMap for the generated code
  4579. * @param aRelativePath Optional. The path that relative sources in the
  4580. * SourceMapConsumer should be relative to.
  4581. */
  4582. SourceNode.fromStringWithSourceMap =
  4583. function SourceNode_fromStringWithSourceMap(aGeneratedCode, aSourceMapConsumer, aRelativePath) {
  4584. // The SourceNode we want to fill with the generated code
  4585. // and the SourceMap
  4586. var node = new SourceNode();
  4587. // All even indices of this array are one line of the generated code,
  4588. // while all odd indices are the newlines between two adjacent lines
  4589. // (since `REGEX_NEWLINE` captures its match).
  4590. // Processed fragments are accessed by calling `shiftNextLine`.
  4591. var remainingLines = aGeneratedCode.split(REGEX_NEWLINE);
  4592. var remainingLinesIndex = 0;
  4593. var shiftNextLine = function() {
  4594. var lineContents = getNextLine();
  4595. // The last line of a file might not have a newline.
  4596. var newLine = getNextLine() || "";
  4597. return lineContents + newLine;
  4598. function getNextLine() {
  4599. return remainingLinesIndex < remainingLines.length ?
  4600. remainingLines[remainingLinesIndex++] : undefined;
  4601. }
  4602. };
  4603. // We need to remember the position of "remainingLines"
  4604. var lastGeneratedLine = 1, lastGeneratedColumn = 0;
  4605. // The generate SourceNodes we need a code range.
  4606. // To extract it current and last mapping is used.
  4607. // Here we store the last mapping.
  4608. var lastMapping = null;
  4609. aSourceMapConsumer.eachMapping(function (mapping) {
  4610. if (lastMapping !== null) {
  4611. // We add the code from "lastMapping" to "mapping":
  4612. // First check if there is a new line in between.
  4613. if (lastGeneratedLine < mapping.generatedLine) {
  4614. // Associate first line with "lastMapping"
  4615. addMappingWithCode(lastMapping, shiftNextLine());
  4616. lastGeneratedLine++;
  4617. lastGeneratedColumn = 0;
  4618. // The remaining code is added without mapping
  4619. } else {
  4620. // There is no new line in between.
  4621. // Associate the code between "lastGeneratedColumn" and
  4622. // "mapping.generatedColumn" with "lastMapping"
  4623. var nextLine = remainingLines[remainingLinesIndex] || '';
  4624. var code = nextLine.substr(0, mapping.generatedColumn -
  4625. lastGeneratedColumn);
  4626. remainingLines[remainingLinesIndex] = nextLine.substr(mapping.generatedColumn -
  4627. lastGeneratedColumn);
  4628. lastGeneratedColumn = mapping.generatedColumn;
  4629. addMappingWithCode(lastMapping, code);
  4630. // No more remaining code, continue
  4631. lastMapping = mapping;
  4632. return;
  4633. }
  4634. }
  4635. // We add the generated code until the first mapping
  4636. // to the SourceNode without any mapping.
  4637. // Each line is added as separate string.
  4638. while (lastGeneratedLine < mapping.generatedLine) {
  4639. node.add(shiftNextLine());
  4640. lastGeneratedLine++;
  4641. }
  4642. if (lastGeneratedColumn < mapping.generatedColumn) {
  4643. var nextLine = remainingLines[remainingLinesIndex] || '';
  4644. node.add(nextLine.substr(0, mapping.generatedColumn));
  4645. remainingLines[remainingLinesIndex] = nextLine.substr(mapping.generatedColumn);
  4646. lastGeneratedColumn = mapping.generatedColumn;
  4647. }
  4648. lastMapping = mapping;
  4649. }, this);
  4650. // We have processed all mappings.
  4651. if (remainingLinesIndex < remainingLines.length) {
  4652. if (lastMapping) {
  4653. // Associate the remaining code in the current line with "lastMapping"
  4654. addMappingWithCode(lastMapping, shiftNextLine());
  4655. }
  4656. // and add the remaining lines without any mapping
  4657. node.add(remainingLines.splice(remainingLinesIndex).join(""));
  4658. }
  4659. // Copy sourcesContent into SourceNode
  4660. aSourceMapConsumer.sources.forEach(function (sourceFile) {
  4661. var content = aSourceMapConsumer.sourceContentFor(sourceFile);
  4662. if (content != null) {
  4663. if (aRelativePath != null) {
  4664. sourceFile = util.join(aRelativePath, sourceFile);
  4665. }
  4666. node.setSourceContent(sourceFile, content);
  4667. }
  4668. });
  4669. return node;
  4670. function addMappingWithCode(mapping, code) {
  4671. if (mapping === null || mapping.source === undefined) {
  4672. node.add(code);
  4673. } else {
  4674. var source = aRelativePath
  4675. ? util.join(aRelativePath, mapping.source)
  4676. : mapping.source;
  4677. node.add(new SourceNode(mapping.originalLine,
  4678. mapping.originalColumn,
  4679. source,
  4680. code,
  4681. mapping.name));
  4682. }
  4683. }
  4684. };
  4685. /**
  4686. * Add a chunk of generated JS to this source node.
  4687. *
  4688. * @param aChunk A string snippet of generated JS code, another instance of
  4689. * SourceNode, or an array where each member is one of those things.
  4690. */
  4691. SourceNode.prototype.add = function SourceNode_add(aChunk) {
  4692. if (Array.isArray(aChunk)) {
  4693. aChunk.forEach(function (chunk) {
  4694. this.add(chunk);
  4695. }, this);
  4696. }
  4697. else if (aChunk[isSourceNode] || typeof aChunk === "string") {
  4698. if (aChunk) {
  4699. this.children.push(aChunk);
  4700. }
  4701. }
  4702. else {
  4703. throw new TypeError(
  4704. "Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk
  4705. );
  4706. }
  4707. return this;
  4708. };
  4709. /**
  4710. * Add a chunk of generated JS to the beginning of this source node.
  4711. *
  4712. * @param aChunk A string snippet of generated JS code, another instance of
  4713. * SourceNode, or an array where each member is one of those things.
  4714. */
  4715. SourceNode.prototype.prepend = function SourceNode_prepend(aChunk) {
  4716. if (Array.isArray(aChunk)) {
  4717. for (var i = aChunk.length-1; i >= 0; i--) {
  4718. this.prepend(aChunk[i]);
  4719. }
  4720. }
  4721. else if (aChunk[isSourceNode] || typeof aChunk === "string") {
  4722. this.children.unshift(aChunk);
  4723. }
  4724. else {
  4725. throw new TypeError(
  4726. "Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk
  4727. );
  4728. }
  4729. return this;
  4730. };
  4731. /**
  4732. * Walk over the tree of JS snippets in this node and its children. The
  4733. * walking function is called once for each snippet of JS and is passed that
  4734. * snippet and the its original associated source's line/column location.
  4735. *
  4736. * @param aFn The traversal function.
  4737. */
  4738. SourceNode.prototype.walk = function SourceNode_walk(aFn) {
  4739. var chunk;
  4740. for (var i = 0, len = this.children.length; i < len; i++) {
  4741. chunk = this.children[i];
  4742. if (chunk[isSourceNode]) {
  4743. chunk.walk(aFn);
  4744. }
  4745. else {
  4746. if (chunk !== '') {
  4747. aFn(chunk, { source: this.source,
  4748. line: this.line,
  4749. column: this.column,
  4750. name: this.name });
  4751. }
  4752. }
  4753. }
  4754. };
  4755. /**
  4756. * Like `String.prototype.join` except for SourceNodes. Inserts `aStr` between
  4757. * each of `this.children`.
  4758. *
  4759. * @param aSep The separator.
  4760. */
  4761. SourceNode.prototype.join = function SourceNode_join(aSep) {
  4762. var newChildren;
  4763. var i;
  4764. var len = this.children.length;
  4765. if (len > 0) {
  4766. newChildren = [];
  4767. for (i = 0; i < len-1; i++) {
  4768. newChildren.push(this.children[i]);
  4769. newChildren.push(aSep);
  4770. }
  4771. newChildren.push(this.children[i]);
  4772. this.children = newChildren;
  4773. }
  4774. return this;
  4775. };
  4776. /**
  4777. * Call String.prototype.replace on the very right-most source snippet. Useful
  4778. * for trimming whitespace from the end of a source node, etc.
  4779. *
  4780. * @param aPattern The pattern to replace.
  4781. * @param aReplacement The thing to replace the pattern with.
  4782. */
  4783. SourceNode.prototype.replaceRight = function SourceNode_replaceRight(aPattern, aReplacement) {
  4784. var lastChild = this.children[this.children.length - 1];
  4785. if (lastChild[isSourceNode]) {
  4786. lastChild.replaceRight(aPattern, aReplacement);
  4787. }
  4788. else if (typeof lastChild === 'string') {
  4789. this.children[this.children.length - 1] = lastChild.replace(aPattern, aReplacement);
  4790. }
  4791. else {
  4792. this.children.push(''.replace(aPattern, aReplacement));
  4793. }
  4794. return this;
  4795. };
  4796. /**
  4797. * Set the source content for a source file. This will be added to the SourceMapGenerator
  4798. * in the sourcesContent field.
  4799. *
  4800. * @param aSourceFile The filename of the source file
  4801. * @param aSourceContent The content of the source file
  4802. */
  4803. SourceNode.prototype.setSourceContent =
  4804. function SourceNode_setSourceContent(aSourceFile, aSourceContent) {
  4805. this.sourceContents[util.toSetString(aSourceFile)] = aSourceContent;
  4806. };
  4807. /**
  4808. * Walk over the tree of SourceNodes. The walking function is called for each
  4809. * source file content and is passed the filename and source content.
  4810. *
  4811. * @param aFn The traversal function.
  4812. */
  4813. SourceNode.prototype.walkSourceContents =
  4814. function SourceNode_walkSourceContents(aFn) {
  4815. for (var i = 0, len = this.children.length; i < len; i++) {
  4816. if (this.children[i][isSourceNode]) {
  4817. this.children[i].walkSourceContents(aFn);
  4818. }
  4819. }
  4820. var sources = Object.keys(this.sourceContents);
  4821. for (var i = 0, len = sources.length; i < len; i++) {
  4822. aFn(util.fromSetString(sources[i]), this.sourceContents[sources[i]]);
  4823. }
  4824. };
  4825. /**
  4826. * Return the string representation of this source node. Walks over the tree
  4827. * and concatenates all the various snippets together to one string.
  4828. */
  4829. SourceNode.prototype.toString = function SourceNode_toString() {
  4830. var str = "";
  4831. this.walk(function (chunk) {
  4832. str += chunk;
  4833. });
  4834. return str;
  4835. };
  4836. /**
  4837. * Returns the string representation of this source node along with a source
  4838. * map.
  4839. */
  4840. SourceNode.prototype.toStringWithSourceMap = function SourceNode_toStringWithSourceMap(aArgs) {
  4841. var generated = {
  4842. code: "",
  4843. line: 1,
  4844. column: 0
  4845. };
  4846. var map = new SourceMapGenerator(aArgs);
  4847. var sourceMappingActive = false;
  4848. var lastOriginalSource = null;
  4849. var lastOriginalLine = null;
  4850. var lastOriginalColumn = null;
  4851. var lastOriginalName = null;
  4852. this.walk(function (chunk, original) {
  4853. generated.code += chunk;
  4854. if (original.source !== null
  4855. && original.line !== null
  4856. && original.column !== null) {
  4857. if(lastOriginalSource !== original.source
  4858. || lastOriginalLine !== original.line
  4859. || lastOriginalColumn !== original.column
  4860. || lastOriginalName !== original.name) {
  4861. map.addMapping({
  4862. source: original.source,
  4863. original: {
  4864. line: original.line,
  4865. column: original.column
  4866. },
  4867. generated: {
  4868. line: generated.line,
  4869. column: generated.column
  4870. },
  4871. name: original.name
  4872. });
  4873. }
  4874. lastOriginalSource = original.source;
  4875. lastOriginalLine = original.line;
  4876. lastOriginalColumn = original.column;
  4877. lastOriginalName = original.name;
  4878. sourceMappingActive = true;
  4879. } else if (sourceMappingActive) {
  4880. map.addMapping({
  4881. generated: {
  4882. line: generated.line,
  4883. column: generated.column
  4884. }
  4885. });
  4886. lastOriginalSource = null;
  4887. sourceMappingActive = false;
  4888. }
  4889. for (var idx = 0, length = chunk.length; idx < length; idx++) {
  4890. if (chunk.charCodeAt(idx) === NEWLINE_CODE) {
  4891. generated.line++;
  4892. generated.column = 0;
  4893. // Mappings end at eol
  4894. if (idx + 1 === length) {
  4895. lastOriginalSource = null;
  4896. sourceMappingActive = false;
  4897. } else if (sourceMappingActive) {
  4898. map.addMapping({
  4899. source: original.source,
  4900. original: {
  4901. line: original.line,
  4902. column: original.column
  4903. },
  4904. generated: {
  4905. line: generated.line,
  4906. column: generated.column
  4907. },
  4908. name: original.name
  4909. });
  4910. }
  4911. } else {
  4912. generated.column++;
  4913. }
  4914. }
  4915. });
  4916. this.walkSourceContents(function (sourceFile, sourceContent) {
  4917. map.setSourceContent(sourceFile, sourceContent);
  4918. });
  4919. return { code: generated.code, map: map };
  4920. };
  4921. /*
  4922. * Copyright 2009-2011 Mozilla Foundation and contributors
  4923. * Licensed under the New BSD license. See LICENSE.txt or:
  4924. * http://opensource.org/licenses/BSD-3-Clause
  4925. */
  4926. var SourceMapConsumer = sourceMapConsumer.SourceMapConsumer;
  4927. const lineSplitRE = /\r?\n/;
  4928. function getOriginalPos(map, { line, column }) {
  4929. return new Promise((resolve) => {
  4930. if (!map)
  4931. return resolve(null);
  4932. const consumer = new SourceMapConsumer(map);
  4933. const pos = consumer.originalPositionFor({ line, column });
  4934. if (pos.line != null && pos.column != null)
  4935. resolve(pos);
  4936. else
  4937. resolve(null);
  4938. });
  4939. }
  4940. async function interpretSourcePos(stackFrames, ctx) {
  4941. var _a;
  4942. for (const frame of stackFrames) {
  4943. if ("sourcePos" in frame)
  4944. continue;
  4945. const transformResult = (_a = ctx.server.moduleGraph.getModuleById(frame.file)) == null ? void 0 : _a.ssrTransformResult;
  4946. if (!transformResult)
  4947. continue;
  4948. const sourcePos = await getOriginalPos(transformResult.map, frame);
  4949. if (sourcePos)
  4950. frame.sourcePos = sourcePos;
  4951. }
  4952. return stackFrames;
  4953. }
  4954. const stackIgnorePatterns = [
  4955. "node:internal",
  4956. "/vitest/dist/",
  4957. "/node_modules/chai/",
  4958. "/node_modules/tinypool/",
  4959. "/node_modules/tinyspy/"
  4960. ];
  4961. function extractLocation(urlLike) {
  4962. if (!urlLike.includes(":"))
  4963. return [urlLike];
  4964. const regExp = /(.+?)(?::(\d+))?(?::(\d+))?$/;
  4965. const parts = regExp.exec(urlLike.replace(/[()]/g, ""));
  4966. if (!parts)
  4967. return [urlLike];
  4968. return [parts[1], parts[2] || void 0, parts[3] || void 0];
  4969. }
  4970. function parseStacktrace(e, full = false) {
  4971. if (e.stacks)
  4972. return e.stacks;
  4973. const stackStr = e.stack || e.stackStr || "";
  4974. const stackFrames = stackStr.split("\n").map((raw) => {
  4975. let line = raw.trim();
  4976. if (line.includes("(eval "))
  4977. line = line.replace(/eval code/g, "eval").replace(/(\(eval at [^()]*)|(,.*$)/g, "");
  4978. let sanitizedLine = line.replace(/^\s+/, "").replace(/\(eval code/g, "(").replace(/^.*?\s+/, "");
  4979. const location = sanitizedLine.match(/ (\(.+\)$)/);
  4980. sanitizedLine = location ? sanitizedLine.replace(location[0], "") : sanitizedLine;
  4981. const [url, lineNumber, columnNumber] = extractLocation(location ? location[1] : sanitizedLine);
  4982. let method = location && sanitizedLine || "";
  4983. let file = url && ["eval", "<anonymous>"].includes(url) ? void 0 : url;
  4984. if (!file || !lineNumber || !columnNumber)
  4985. return null;
  4986. if (method.startsWith("async "))
  4987. method = method.slice(6);
  4988. if (file.startsWith("file://"))
  4989. file = file.slice(7);
  4990. if (!full && stackIgnorePatterns.some((p) => file && file.includes(p)))
  4991. return null;
  4992. return {
  4993. method,
  4994. file: slash(file),
  4995. line: parseInt(lineNumber),
  4996. column: parseInt(columnNumber)
  4997. };
  4998. }).filter(notNullish);
  4999. e.stacks = stackFrames;
  5000. return stackFrames;
  5001. }
  5002. function posToNumber(source, pos) {
  5003. if (typeof pos === "number")
  5004. return pos;
  5005. const lines = source.split(lineSplitRE);
  5006. const { line, column } = pos;
  5007. let start = 0;
  5008. if (line > lines.length)
  5009. return source.length;
  5010. for (let i = 0; i < line - 1; i++)
  5011. start += lines[i].length + 1;
  5012. return start + column;
  5013. }
  5014. function numberToPos(source, offset) {
  5015. if (typeof offset !== "number")
  5016. return offset;
  5017. if (offset > source.length) {
  5018. throw new Error(
  5019. `offset is longer than source length! offset ${offset} > length ${source.length}`
  5020. );
  5021. }
  5022. const lines = source.split(lineSplitRE);
  5023. let counted = 0;
  5024. let line = 0;
  5025. let column = 0;
  5026. for (; line < lines.length; line++) {
  5027. const lineLength = lines[line].length + 1;
  5028. if (counted + lineLength >= offset) {
  5029. column = offset - counted + 1;
  5030. break;
  5031. }
  5032. counted += lineLength;
  5033. }
  5034. return { line: line + 1, column };
  5035. }
  5036. function Diff() {}
  5037. Diff.prototype = {
  5038. diff: function diff(oldString, newString) {
  5039. var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  5040. var callback = options.callback;
  5041. if (typeof options === 'function') {
  5042. callback = options;
  5043. options = {};
  5044. }
  5045. this.options = options;
  5046. var self = this;
  5047. function done(value) {
  5048. if (callback) {
  5049. setTimeout(function () {
  5050. callback(undefined, value);
  5051. }, 0);
  5052. return true;
  5053. } else {
  5054. return value;
  5055. }
  5056. } // Allow subclasses to massage the input prior to running
  5057. oldString = this.castInput(oldString);
  5058. newString = this.castInput(newString);
  5059. oldString = this.removeEmpty(this.tokenize(oldString));
  5060. newString = this.removeEmpty(this.tokenize(newString));
  5061. var newLen = newString.length,
  5062. oldLen = oldString.length;
  5063. var editLength = 1;
  5064. var maxEditLength = newLen + oldLen;
  5065. if (options.maxEditLength) {
  5066. maxEditLength = Math.min(maxEditLength, options.maxEditLength);
  5067. }
  5068. var bestPath = [{
  5069. newPos: -1,
  5070. components: []
  5071. }]; // Seed editLength = 0, i.e. the content starts with the same values
  5072. var oldPos = this.extractCommon(bestPath[0], newString, oldString, 0);
  5073. if (bestPath[0].newPos + 1 >= newLen && oldPos + 1 >= oldLen) {
  5074. // Identity per the equality and tokenizer
  5075. return done([{
  5076. value: this.join(newString),
  5077. count: newString.length
  5078. }]);
  5079. } // Main worker method. checks all permutations of a given edit length for acceptance.
  5080. function execEditLength() {
  5081. for (var diagonalPath = -1 * editLength; diagonalPath <= editLength; diagonalPath += 2) {
  5082. var basePath = void 0;
  5083. var addPath = bestPath[diagonalPath - 1],
  5084. removePath = bestPath[diagonalPath + 1],
  5085. _oldPos = (removePath ? removePath.newPos : 0) - diagonalPath;
  5086. if (addPath) {
  5087. // No one else is going to attempt to use this value, clear it
  5088. bestPath[diagonalPath - 1] = undefined;
  5089. }
  5090. var canAdd = addPath && addPath.newPos + 1 < newLen,
  5091. canRemove = removePath && 0 <= _oldPos && _oldPos < oldLen;
  5092. if (!canAdd && !canRemove) {
  5093. // If this path is a terminal then prune
  5094. bestPath[diagonalPath] = undefined;
  5095. continue;
  5096. } // Select the diagonal that we want to branch from. We select the prior
  5097. // path whose position in the new string is the farthest from the origin
  5098. // and does not pass the bounds of the diff graph
  5099. if (!canAdd || canRemove && addPath.newPos < removePath.newPos) {
  5100. basePath = clonePath(removePath);
  5101. self.pushComponent(basePath.components, undefined, true);
  5102. } else {
  5103. basePath = addPath; // No need to clone, we've pulled it from the list
  5104. basePath.newPos++;
  5105. self.pushComponent(basePath.components, true, undefined);
  5106. }
  5107. _oldPos = self.extractCommon(basePath, newString, oldString, diagonalPath); // If we have hit the end of both strings, then we are done
  5108. if (basePath.newPos + 1 >= newLen && _oldPos + 1 >= oldLen) {
  5109. return done(buildValues(self, basePath.components, newString, oldString, self.useLongestToken));
  5110. } else {
  5111. // Otherwise track this path as a potential candidate and continue.
  5112. bestPath[diagonalPath] = basePath;
  5113. }
  5114. }
  5115. editLength++;
  5116. } // Performs the length of edit iteration. Is a bit fugly as this has to support the
  5117. // sync and async mode which is never fun. Loops over execEditLength until a value
  5118. // is produced, or until the edit length exceeds options.maxEditLength (if given),
  5119. // in which case it will return undefined.
  5120. if (callback) {
  5121. (function exec() {
  5122. setTimeout(function () {
  5123. if (editLength > maxEditLength) {
  5124. return callback();
  5125. }
  5126. if (!execEditLength()) {
  5127. exec();
  5128. }
  5129. }, 0);
  5130. })();
  5131. } else {
  5132. while (editLength <= maxEditLength) {
  5133. var ret = execEditLength();
  5134. if (ret) {
  5135. return ret;
  5136. }
  5137. }
  5138. }
  5139. },
  5140. pushComponent: function pushComponent(components, added, removed) {
  5141. var last = components[components.length - 1];
  5142. if (last && last.added === added && last.removed === removed) {
  5143. // We need to clone here as the component clone operation is just
  5144. // as shallow array clone
  5145. components[components.length - 1] = {
  5146. count: last.count + 1,
  5147. added: added,
  5148. removed: removed
  5149. };
  5150. } else {
  5151. components.push({
  5152. count: 1,
  5153. added: added,
  5154. removed: removed
  5155. });
  5156. }
  5157. },
  5158. extractCommon: function extractCommon(basePath, newString, oldString, diagonalPath) {
  5159. var newLen = newString.length,
  5160. oldLen = oldString.length,
  5161. newPos = basePath.newPos,
  5162. oldPos = newPos - diagonalPath,
  5163. commonCount = 0;
  5164. while (newPos + 1 < newLen && oldPos + 1 < oldLen && this.equals(newString[newPos + 1], oldString[oldPos + 1])) {
  5165. newPos++;
  5166. oldPos++;
  5167. commonCount++;
  5168. }
  5169. if (commonCount) {
  5170. basePath.components.push({
  5171. count: commonCount
  5172. });
  5173. }
  5174. basePath.newPos = newPos;
  5175. return oldPos;
  5176. },
  5177. equals: function equals(left, right) {
  5178. if (this.options.comparator) {
  5179. return this.options.comparator(left, right);
  5180. } else {
  5181. return left === right || this.options.ignoreCase && left.toLowerCase() === right.toLowerCase();
  5182. }
  5183. },
  5184. removeEmpty: function removeEmpty(array) {
  5185. var ret = [];
  5186. for (var i = 0; i < array.length; i++) {
  5187. if (array[i]) {
  5188. ret.push(array[i]);
  5189. }
  5190. }
  5191. return ret;
  5192. },
  5193. castInput: function castInput(value) {
  5194. return value;
  5195. },
  5196. tokenize: function tokenize(value) {
  5197. return value.split('');
  5198. },
  5199. join: function join(chars) {
  5200. return chars.join('');
  5201. }
  5202. };
  5203. function buildValues(diff, components, newString, oldString, useLongestToken) {
  5204. var componentPos = 0,
  5205. componentLen = components.length,
  5206. newPos = 0,
  5207. oldPos = 0;
  5208. for (; componentPos < componentLen; componentPos++) {
  5209. var component = components[componentPos];
  5210. if (!component.removed) {
  5211. if (!component.added && useLongestToken) {
  5212. var value = newString.slice(newPos, newPos + component.count);
  5213. value = value.map(function (value, i) {
  5214. var oldValue = oldString[oldPos + i];
  5215. return oldValue.length > value.length ? oldValue : value;
  5216. });
  5217. component.value = diff.join(value);
  5218. } else {
  5219. component.value = diff.join(newString.slice(newPos, newPos + component.count));
  5220. }
  5221. newPos += component.count; // Common case
  5222. if (!component.added) {
  5223. oldPos += component.count;
  5224. }
  5225. } else {
  5226. component.value = diff.join(oldString.slice(oldPos, oldPos + component.count));
  5227. oldPos += component.count; // Reverse add and remove so removes are output first to match common convention
  5228. // The diffing algorithm is tied to add then remove output and this is the simplest
  5229. // route to get the desired output with minimal overhead.
  5230. if (componentPos && components[componentPos - 1].added) {
  5231. var tmp = components[componentPos - 1];
  5232. components[componentPos - 1] = components[componentPos];
  5233. components[componentPos] = tmp;
  5234. }
  5235. }
  5236. } // Special case handle for when one terminal is ignored (i.e. whitespace).
  5237. // For this case we merge the terminal into the prior string and drop the change.
  5238. // This is only available for string mode.
  5239. var lastComponent = components[componentLen - 1];
  5240. if (componentLen > 1 && typeof lastComponent.value === 'string' && (lastComponent.added || lastComponent.removed) && diff.equals('', lastComponent.value)) {
  5241. components[componentLen - 2].value += lastComponent.value;
  5242. components.pop();
  5243. }
  5244. return components;
  5245. }
  5246. function clonePath(path) {
  5247. return {
  5248. newPos: path.newPos,
  5249. components: path.components.slice(0)
  5250. };
  5251. }
  5252. //
  5253. // Ranges and exceptions:
  5254. // Latin-1 Supplement, 0080–00FF
  5255. // - U+00D7 × Multiplication sign
  5256. // - U+00F7 ÷ Division sign
  5257. // Latin Extended-A, 0100–017F
  5258. // Latin Extended-B, 0180–024F
  5259. // IPA Extensions, 0250–02AF
  5260. // Spacing Modifier Letters, 02B0–02FF
  5261. // - U+02C7 ˇ &#711; Caron
  5262. // - U+02D8 ˘ &#728; Breve
  5263. // - U+02D9 ˙ &#729; Dot Above
  5264. // - U+02DA ˚ &#730; Ring Above
  5265. // - U+02DB ˛ &#731; Ogonek
  5266. // - U+02DC ˜ &#732; Small Tilde
  5267. // - U+02DD ˝ &#733; Double Acute Accent
  5268. // Latin Extended Additional, 1E00–1EFF
  5269. var extendedWordChars = /^[A-Za-z\xC0-\u02C6\u02C8-\u02D7\u02DE-\u02FF\u1E00-\u1EFF]+$/;
  5270. var reWhitespace = /\S/;
  5271. var wordDiff = new Diff();
  5272. wordDiff.equals = function (left, right) {
  5273. if (this.options.ignoreCase) {
  5274. left = left.toLowerCase();
  5275. right = right.toLowerCase();
  5276. }
  5277. return left === right || this.options.ignoreWhitespace && !reWhitespace.test(left) && !reWhitespace.test(right);
  5278. };
  5279. wordDiff.tokenize = function (value) {
  5280. // All whitespace symbols except newline group into one token, each newline - in separate token
  5281. var tokens = value.split(/([^\S\r\n]+|[()[\]{}'"\r\n]|\b)/); // Join the boundary splits that we do not consider to be boundaries. This is primarily the extended Latin character set.
  5282. for (var i = 0; i < tokens.length - 1; i++) {
  5283. // If we have an empty string in the next field and we have only word chars before and after, merge
  5284. if (!tokens[i + 1] && tokens[i + 2] && extendedWordChars.test(tokens[i]) && extendedWordChars.test(tokens[i + 2])) {
  5285. tokens[i] += tokens[i + 2];
  5286. tokens.splice(i + 1, 2);
  5287. i--;
  5288. }
  5289. }
  5290. return tokens;
  5291. };
  5292. var lineDiff = new Diff();
  5293. lineDiff.tokenize = function (value) {
  5294. var retLines = [],
  5295. linesAndNewlines = value.split(/(\n|\r\n)/); // Ignore the final empty token that occurs if the string ends with a new line
  5296. if (!linesAndNewlines[linesAndNewlines.length - 1]) {
  5297. linesAndNewlines.pop();
  5298. } // Merge the content and line separators into single tokens
  5299. for (var i = 0; i < linesAndNewlines.length; i++) {
  5300. var line = linesAndNewlines[i];
  5301. if (i % 2 && !this.options.newlineIsToken) {
  5302. retLines[retLines.length - 1] += line;
  5303. } else {
  5304. if (this.options.ignoreWhitespace) {
  5305. line = line.trim();
  5306. }
  5307. retLines.push(line);
  5308. }
  5309. }
  5310. return retLines;
  5311. };
  5312. function diffLines(oldStr, newStr, callback) {
  5313. return lineDiff.diff(oldStr, newStr, callback);
  5314. }
  5315. var sentenceDiff = new Diff();
  5316. sentenceDiff.tokenize = function (value) {
  5317. return value.split(/(\S.+?[.!?])(?=\s+|$)/);
  5318. };
  5319. var cssDiff = new Diff();
  5320. cssDiff.tokenize = function (value) {
  5321. return value.split(/([{}:;,]|\s+)/);
  5322. };
  5323. function _typeof(obj) {
  5324. "@babel/helpers - typeof";
  5325. if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
  5326. _typeof = function (obj) {
  5327. return typeof obj;
  5328. };
  5329. } else {
  5330. _typeof = function (obj) {
  5331. return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
  5332. };
  5333. }
  5334. return _typeof(obj);
  5335. }
  5336. function _toConsumableArray(arr) {
  5337. return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
  5338. }
  5339. function _arrayWithoutHoles(arr) {
  5340. if (Array.isArray(arr)) return _arrayLikeToArray(arr);
  5341. }
  5342. function _iterableToArray(iter) {
  5343. if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter);
  5344. }
  5345. function _unsupportedIterableToArray(o, minLen) {
  5346. if (!o) return;
  5347. if (typeof o === "string") return _arrayLikeToArray(o, minLen);
  5348. var n = Object.prototype.toString.call(o).slice(8, -1);
  5349. if (n === "Object" && o.constructor) n = o.constructor.name;
  5350. if (n === "Map" || n === "Set") return Array.from(o);
  5351. if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
  5352. }
  5353. function _arrayLikeToArray(arr, len) {
  5354. if (len == null || len > arr.length) len = arr.length;
  5355. for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
  5356. return arr2;
  5357. }
  5358. function _nonIterableSpread() {
  5359. throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  5360. }
  5361. var objectPrototypeToString = Object.prototype.toString;
  5362. var jsonDiff = new Diff(); // Discriminate between two lines of pretty-printed, serialized JSON where one of them has a
  5363. // dangling comma and the other doesn't. Turns out including the dangling comma yields the nicest output:
  5364. jsonDiff.useLongestToken = true;
  5365. jsonDiff.tokenize = lineDiff.tokenize;
  5366. jsonDiff.castInput = function (value) {
  5367. var _this$options = this.options,
  5368. undefinedReplacement = _this$options.undefinedReplacement,
  5369. _this$options$stringi = _this$options.stringifyReplacer,
  5370. stringifyReplacer = _this$options$stringi === void 0 ? function (k, v) {
  5371. return typeof v === 'undefined' ? undefinedReplacement : v;
  5372. } : _this$options$stringi;
  5373. return typeof value === 'string' ? value : JSON.stringify(canonicalize(value, null, null, stringifyReplacer), stringifyReplacer, ' ');
  5374. };
  5375. jsonDiff.equals = function (left, right) {
  5376. return Diff.prototype.equals.call(jsonDiff, left.replace(/,([\r\n])/g, '$1'), right.replace(/,([\r\n])/g, '$1'));
  5377. };
  5378. // object that is already on the "stack" of items being processed. Accepts an optional replacer
  5379. function canonicalize(obj, stack, replacementStack, replacer, key) {
  5380. stack = stack || [];
  5381. replacementStack = replacementStack || [];
  5382. if (replacer) {
  5383. obj = replacer(key, obj);
  5384. }
  5385. var i;
  5386. for (i = 0; i < stack.length; i += 1) {
  5387. if (stack[i] === obj) {
  5388. return replacementStack[i];
  5389. }
  5390. }
  5391. var canonicalizedObj;
  5392. if ('[object Array]' === objectPrototypeToString.call(obj)) {
  5393. stack.push(obj);
  5394. canonicalizedObj = new Array(obj.length);
  5395. replacementStack.push(canonicalizedObj);
  5396. for (i = 0; i < obj.length; i += 1) {
  5397. canonicalizedObj[i] = canonicalize(obj[i], stack, replacementStack, replacer, key);
  5398. }
  5399. stack.pop();
  5400. replacementStack.pop();
  5401. return canonicalizedObj;
  5402. }
  5403. if (obj && obj.toJSON) {
  5404. obj = obj.toJSON();
  5405. }
  5406. if (_typeof(obj) === 'object' && obj !== null) {
  5407. stack.push(obj);
  5408. canonicalizedObj = {};
  5409. replacementStack.push(canonicalizedObj);
  5410. var sortedKeys = [],
  5411. _key;
  5412. for (_key in obj) {
  5413. /* istanbul ignore else */
  5414. if (obj.hasOwnProperty(_key)) {
  5415. sortedKeys.push(_key);
  5416. }
  5417. }
  5418. sortedKeys.sort();
  5419. for (i = 0; i < sortedKeys.length; i += 1) {
  5420. _key = sortedKeys[i];
  5421. canonicalizedObj[_key] = canonicalize(obj[_key], stack, replacementStack, replacer, _key);
  5422. }
  5423. stack.pop();
  5424. replacementStack.pop();
  5425. } else {
  5426. canonicalizedObj = obj;
  5427. }
  5428. return canonicalizedObj;
  5429. }
  5430. var arrayDiff = new Diff();
  5431. arrayDiff.tokenize = function (value) {
  5432. return value.slice();
  5433. };
  5434. arrayDiff.join = arrayDiff.removeEmpty = function (value) {
  5435. return value;
  5436. };
  5437. function structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
  5438. if (!options) {
  5439. options = {};
  5440. }
  5441. if (typeof options.context === 'undefined') {
  5442. options.context = 4;
  5443. }
  5444. var diff = diffLines(oldStr, newStr, options);
  5445. if (!diff) {
  5446. return;
  5447. }
  5448. diff.push({
  5449. value: '',
  5450. lines: []
  5451. }); // Append an empty value to make cleanup easier
  5452. function contextLines(lines) {
  5453. return lines.map(function (entry) {
  5454. return ' ' + entry;
  5455. });
  5456. }
  5457. var hunks = [];
  5458. var oldRangeStart = 0,
  5459. newRangeStart = 0,
  5460. curRange = [],
  5461. oldLine = 1,
  5462. newLine = 1;
  5463. var _loop = function _loop(i) {
  5464. var current = diff[i],
  5465. lines = current.lines || current.value.replace(/\n$/, '').split('\n');
  5466. current.lines = lines;
  5467. if (current.added || current.removed) {
  5468. var _curRange;
  5469. // If we have previous context, start with that
  5470. if (!oldRangeStart) {
  5471. var prev = diff[i - 1];
  5472. oldRangeStart = oldLine;
  5473. newRangeStart = newLine;
  5474. if (prev) {
  5475. curRange = options.context > 0 ? contextLines(prev.lines.slice(-options.context)) : [];
  5476. oldRangeStart -= curRange.length;
  5477. newRangeStart -= curRange.length;
  5478. }
  5479. } // Output our changes
  5480. (_curRange = curRange).push.apply(_curRange, _toConsumableArray(lines.map(function (entry) {
  5481. return (current.added ? '+' : '-') + entry;
  5482. }))); // Track the updated file position
  5483. if (current.added) {
  5484. newLine += lines.length;
  5485. } else {
  5486. oldLine += lines.length;
  5487. }
  5488. } else {
  5489. // Identical context lines. Track line changes
  5490. if (oldRangeStart) {
  5491. // Close out any changes that have been output (or join overlapping)
  5492. if (lines.length <= options.context * 2 && i < diff.length - 2) {
  5493. var _curRange2;
  5494. // Overlapping
  5495. (_curRange2 = curRange).push.apply(_curRange2, _toConsumableArray(contextLines(lines)));
  5496. } else {
  5497. var _curRange3;
  5498. // end the range and output
  5499. var contextSize = Math.min(lines.length, options.context);
  5500. (_curRange3 = curRange).push.apply(_curRange3, _toConsumableArray(contextLines(lines.slice(0, contextSize))));
  5501. var hunk = {
  5502. oldStart: oldRangeStart,
  5503. oldLines: oldLine - oldRangeStart + contextSize,
  5504. newStart: newRangeStart,
  5505. newLines: newLine - newRangeStart + contextSize,
  5506. lines: curRange
  5507. };
  5508. if (i >= diff.length - 2 && lines.length <= options.context) {
  5509. // EOF is inside this hunk
  5510. var oldEOFNewline = /\n$/.test(oldStr);
  5511. var newEOFNewline = /\n$/.test(newStr);
  5512. var noNlBeforeAdds = lines.length == 0 && curRange.length > hunk.oldLines;
  5513. if (!oldEOFNewline && noNlBeforeAdds && oldStr.length > 0) {
  5514. // special case: old has no eol and no trailing context; no-nl can end up before adds
  5515. // however, if the old file is empty, do not output the no-nl line
  5516. curRange.splice(hunk.oldLines, 0, '\\ No newline at end of file');
  5517. }
  5518. if (!oldEOFNewline && !noNlBeforeAdds || !newEOFNewline) {
  5519. curRange.push('\\ No newline at end of file');
  5520. }
  5521. }
  5522. hunks.push(hunk);
  5523. oldRangeStart = 0;
  5524. newRangeStart = 0;
  5525. curRange = [];
  5526. }
  5527. }
  5528. oldLine += lines.length;
  5529. newLine += lines.length;
  5530. }
  5531. };
  5532. for (var i = 0; i < diff.length; i++) {
  5533. _loop(i);
  5534. }
  5535. return {
  5536. oldFileName: oldFileName,
  5537. newFileName: newFileName,
  5538. oldHeader: oldHeader,
  5539. newHeader: newHeader,
  5540. hunks: hunks
  5541. };
  5542. }
  5543. function formatPatch(diff) {
  5544. var ret = [];
  5545. if (diff.oldFileName == diff.newFileName) {
  5546. ret.push('Index: ' + diff.oldFileName);
  5547. }
  5548. ret.push('===================================================================');
  5549. ret.push('--- ' + diff.oldFileName + (typeof diff.oldHeader === 'undefined' ? '' : '\t' + diff.oldHeader));
  5550. ret.push('+++ ' + diff.newFileName + (typeof diff.newHeader === 'undefined' ? '' : '\t' + diff.newHeader));
  5551. for (var i = 0; i < diff.hunks.length; i++) {
  5552. var hunk = diff.hunks[i]; // Unified Diff Format quirk: If the chunk size is 0,
  5553. // the first number is one lower than one would expect.
  5554. // https://www.artima.com/weblogs/viewpost.jsp?thread=164293
  5555. if (hunk.oldLines === 0) {
  5556. hunk.oldStart -= 1;
  5557. }
  5558. if (hunk.newLines === 0) {
  5559. hunk.newStart -= 1;
  5560. }
  5561. ret.push('@@ -' + hunk.oldStart + ',' + hunk.oldLines + ' +' + hunk.newStart + ',' + hunk.newLines + ' @@');
  5562. ret.push.apply(ret, hunk.lines);
  5563. }
  5564. return ret.join('\n') + '\n';
  5565. }
  5566. function createTwoFilesPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
  5567. return formatPatch(structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options));
  5568. }
  5569. function createPatch(fileName, oldStr, newStr, oldHeader, newHeader, options) {
  5570. return createTwoFilesPatch(fileName, fileName, oldStr, newStr, oldHeader, newHeader, options);
  5571. }
  5572. /* eslint-disable yoda */
  5573. function isFullwidthCodePoint(codePoint) {
  5574. if (!Number.isInteger(codePoint)) {
  5575. return false;
  5576. }
  5577. // Code points are derived from:
  5578. // https://unicode.org/Public/UNIDATA/EastAsianWidth.txt
  5579. return codePoint >= 0x1100 && (
  5580. codePoint <= 0x115F || // Hangul Jamo
  5581. codePoint === 0x2329 || // LEFT-POINTING ANGLE BRACKET
  5582. codePoint === 0x232A || // RIGHT-POINTING ANGLE BRACKET
  5583. // CJK Radicals Supplement .. Enclosed CJK Letters and Months
  5584. (0x2E80 <= codePoint && codePoint <= 0x3247 && codePoint !== 0x303F) ||
  5585. // Enclosed CJK Letters and Months .. CJK Unified Ideographs Extension A
  5586. (0x3250 <= codePoint && codePoint <= 0x4DBF) ||
  5587. // CJK Unified Ideographs .. Yi Radicals
  5588. (0x4E00 <= codePoint && codePoint <= 0xA4C6) ||
  5589. // Hangul Jamo Extended-A
  5590. (0xA960 <= codePoint && codePoint <= 0xA97C) ||
  5591. // Hangul Syllables
  5592. (0xAC00 <= codePoint && codePoint <= 0xD7A3) ||
  5593. // CJK Compatibility Ideographs
  5594. (0xF900 <= codePoint && codePoint <= 0xFAFF) ||
  5595. // Vertical Forms
  5596. (0xFE10 <= codePoint && codePoint <= 0xFE19) ||
  5597. // CJK Compatibility Forms .. Small Form Variants
  5598. (0xFE30 <= codePoint && codePoint <= 0xFE6B) ||
  5599. // Halfwidth and Fullwidth Forms
  5600. (0xFF01 <= codePoint && codePoint <= 0xFF60) ||
  5601. (0xFFE0 <= codePoint && codePoint <= 0xFFE6) ||
  5602. // Kana Supplement
  5603. (0x1B000 <= codePoint && codePoint <= 0x1B001) ||
  5604. // Enclosed Ideographic Supplement
  5605. (0x1F200 <= codePoint && codePoint <= 0x1F251) ||
  5606. // CJK Unified Ideographs Extension B .. Tertiary Ideographic Plane
  5607. (0x20000 <= codePoint && codePoint <= 0x3FFFD)
  5608. );
  5609. }
  5610. const ANSI_BACKGROUND_OFFSET = 10;
  5611. const wrapAnsi16 = (offset = 0) => code => `\u001B[${code + offset}m`;
  5612. const wrapAnsi256 = (offset = 0) => code => `\u001B[${38 + offset};5;${code}m`;
  5613. const wrapAnsi16m = (offset = 0) => (red, green, blue) => `\u001B[${38 + offset};2;${red};${green};${blue}m`;
  5614. function assembleStyles() {
  5615. const codes = new Map();
  5616. const styles = {
  5617. modifier: {
  5618. reset: [0, 0],
  5619. // 21 isn't widely supported and 22 does the same thing
  5620. bold: [1, 22],
  5621. dim: [2, 22],
  5622. italic: [3, 23],
  5623. underline: [4, 24],
  5624. overline: [53, 55],
  5625. inverse: [7, 27],
  5626. hidden: [8, 28],
  5627. strikethrough: [9, 29]
  5628. },
  5629. color: {
  5630. black: [30, 39],
  5631. red: [31, 39],
  5632. green: [32, 39],
  5633. yellow: [33, 39],
  5634. blue: [34, 39],
  5635. magenta: [35, 39],
  5636. cyan: [36, 39],
  5637. white: [37, 39],
  5638. // Bright color
  5639. blackBright: [90, 39],
  5640. redBright: [91, 39],
  5641. greenBright: [92, 39],
  5642. yellowBright: [93, 39],
  5643. blueBright: [94, 39],
  5644. magentaBright: [95, 39],
  5645. cyanBright: [96, 39],
  5646. whiteBright: [97, 39]
  5647. },
  5648. bgColor: {
  5649. bgBlack: [40, 49],
  5650. bgRed: [41, 49],
  5651. bgGreen: [42, 49],
  5652. bgYellow: [43, 49],
  5653. bgBlue: [44, 49],
  5654. bgMagenta: [45, 49],
  5655. bgCyan: [46, 49],
  5656. bgWhite: [47, 49],
  5657. // Bright color
  5658. bgBlackBright: [100, 49],
  5659. bgRedBright: [101, 49],
  5660. bgGreenBright: [102, 49],
  5661. bgYellowBright: [103, 49],
  5662. bgBlueBright: [104, 49],
  5663. bgMagentaBright: [105, 49],
  5664. bgCyanBright: [106, 49],
  5665. bgWhiteBright: [107, 49]
  5666. }
  5667. };
  5668. // Alias bright black as gray (and grey)
  5669. styles.color.gray = styles.color.blackBright;
  5670. styles.bgColor.bgGray = styles.bgColor.bgBlackBright;
  5671. styles.color.grey = styles.color.blackBright;
  5672. styles.bgColor.bgGrey = styles.bgColor.bgBlackBright;
  5673. for (const [groupName, group] of Object.entries(styles)) {
  5674. for (const [styleName, style] of Object.entries(group)) {
  5675. styles[styleName] = {
  5676. open: `\u001B[${style[0]}m`,
  5677. close: `\u001B[${style[1]}m`
  5678. };
  5679. group[styleName] = styles[styleName];
  5680. codes.set(style[0], style[1]);
  5681. }
  5682. Object.defineProperty(styles, groupName, {
  5683. value: group,
  5684. enumerable: false
  5685. });
  5686. }
  5687. Object.defineProperty(styles, 'codes', {
  5688. value: codes,
  5689. enumerable: false
  5690. });
  5691. styles.color.close = '\u001B[39m';
  5692. styles.bgColor.close = '\u001B[49m';
  5693. styles.color.ansi = wrapAnsi16();
  5694. styles.color.ansi256 = wrapAnsi256();
  5695. styles.color.ansi16m = wrapAnsi16m();
  5696. styles.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET);
  5697. styles.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET);
  5698. styles.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET);
  5699. // From https://github.com/Qix-/color-convert/blob/3f0e0d4e92e235796ccb17f6e85c72094a651f49/conversions.js
  5700. Object.defineProperties(styles, {
  5701. rgbToAnsi256: {
  5702. value: (red, green, blue) => {
  5703. // We use the extended greyscale palette here, with the exception of
  5704. // black and white. normal palette only has 4 greyscale shades.
  5705. if (red === green && green === blue) {
  5706. if (red < 8) {
  5707. return 16;
  5708. }
  5709. if (red > 248) {
  5710. return 231;
  5711. }
  5712. return Math.round(((red - 8) / 247) * 24) + 232;
  5713. }
  5714. return 16 +
  5715. (36 * Math.round(red / 255 * 5)) +
  5716. (6 * Math.round(green / 255 * 5)) +
  5717. Math.round(blue / 255 * 5);
  5718. },
  5719. enumerable: false
  5720. },
  5721. hexToRgb: {
  5722. value: hex => {
  5723. const matches = /(?<colorString>[a-f\d]{6}|[a-f\d]{3})/i.exec(hex.toString(16));
  5724. if (!matches) {
  5725. return [0, 0, 0];
  5726. }
  5727. let {colorString} = matches.groups;
  5728. if (colorString.length === 3) {
  5729. colorString = colorString.split('').map(character => character + character).join('');
  5730. }
  5731. const integer = Number.parseInt(colorString, 16);
  5732. return [
  5733. (integer >> 16) & 0xFF,
  5734. (integer >> 8) & 0xFF,
  5735. integer & 0xFF
  5736. ];
  5737. },
  5738. enumerable: false
  5739. },
  5740. hexToAnsi256: {
  5741. value: hex => styles.rgbToAnsi256(...styles.hexToRgb(hex)),
  5742. enumerable: false
  5743. },
  5744. ansi256ToAnsi: {
  5745. value: code => {
  5746. if (code < 8) {
  5747. return 30 + code;
  5748. }
  5749. if (code < 16) {
  5750. return 90 + (code - 8);
  5751. }
  5752. let red;
  5753. let green;
  5754. let blue;
  5755. if (code >= 232) {
  5756. red = (((code - 232) * 10) + 8) / 255;
  5757. green = red;
  5758. blue = red;
  5759. } else {
  5760. code -= 16;
  5761. const remainder = code % 36;
  5762. red = Math.floor(code / 36) / 5;
  5763. green = Math.floor(remainder / 6) / 5;
  5764. blue = (remainder % 6) / 5;
  5765. }
  5766. const value = Math.max(red, green, blue) * 2;
  5767. if (value === 0) {
  5768. return 30;
  5769. }
  5770. let result = 30 + ((Math.round(blue) << 2) | (Math.round(green) << 1) | Math.round(red));
  5771. if (value === 2) {
  5772. result += 60;
  5773. }
  5774. return result;
  5775. },
  5776. enumerable: false
  5777. },
  5778. rgbToAnsi: {
  5779. value: (red, green, blue) => styles.ansi256ToAnsi(styles.rgbToAnsi256(red, green, blue)),
  5780. enumerable: false
  5781. },
  5782. hexToAnsi: {
  5783. value: hex => styles.ansi256ToAnsi(styles.hexToAnsi256(hex)),
  5784. enumerable: false
  5785. }
  5786. });
  5787. return styles;
  5788. }
  5789. const ansiStyles = assembleStyles();
  5790. const astralRegex = /^[\uD800-\uDBFF][\uDC00-\uDFFF]$/;
  5791. const ESCAPES = [
  5792. '\u001B',
  5793. '\u009B'
  5794. ];
  5795. const wrapAnsi = code => `${ESCAPES[0]}[${code}m`;
  5796. const checkAnsi = (ansiCodes, isEscapes, endAnsiCode) => {
  5797. let output = [];
  5798. ansiCodes = [...ansiCodes];
  5799. for (let ansiCode of ansiCodes) {
  5800. const ansiCodeOrigin = ansiCode;
  5801. if (ansiCode.includes(';')) {
  5802. ansiCode = ansiCode.split(';')[0][0] + '0';
  5803. }
  5804. const item = ansiStyles.codes.get(Number.parseInt(ansiCode, 10));
  5805. if (item) {
  5806. const indexEscape = ansiCodes.indexOf(item.toString());
  5807. if (indexEscape === -1) {
  5808. output.push(wrapAnsi(isEscapes ? item : ansiCodeOrigin));
  5809. } else {
  5810. ansiCodes.splice(indexEscape, 1);
  5811. }
  5812. } else if (isEscapes) {
  5813. output.push(wrapAnsi(0));
  5814. break;
  5815. } else {
  5816. output.push(wrapAnsi(ansiCodeOrigin));
  5817. }
  5818. }
  5819. if (isEscapes) {
  5820. output = output.filter((element, index) => output.indexOf(element) === index);
  5821. if (endAnsiCode !== undefined) {
  5822. const fistEscapeCode = wrapAnsi(ansiStyles.codes.get(Number.parseInt(endAnsiCode, 10)));
  5823. // TODO: Remove the use of `.reduce` here.
  5824. // eslint-disable-next-line unicorn/no-array-reduce
  5825. output = output.reduce((current, next) => next === fistEscapeCode ? [next, ...current] : [...current, next], []);
  5826. }
  5827. }
  5828. return output.join('');
  5829. };
  5830. function sliceAnsi(string, begin, end) {
  5831. const characters = [...string];
  5832. const ansiCodes = [];
  5833. let stringEnd = typeof end === 'number' ? end : characters.length;
  5834. let isInsideEscape = false;
  5835. let ansiCode;
  5836. let visible = 0;
  5837. let output = '';
  5838. for (const [index, character] of characters.entries()) {
  5839. let leftEscape = false;
  5840. if (ESCAPES.includes(character)) {
  5841. const code = /\d[^m]*/.exec(string.slice(index, index + 18));
  5842. ansiCode = code && code.length > 0 ? code[0] : undefined;
  5843. if (visible < stringEnd) {
  5844. isInsideEscape = true;
  5845. if (ansiCode !== undefined) {
  5846. ansiCodes.push(ansiCode);
  5847. }
  5848. }
  5849. } else if (isInsideEscape && character === 'm') {
  5850. isInsideEscape = false;
  5851. leftEscape = true;
  5852. }
  5853. if (!isInsideEscape && !leftEscape) {
  5854. visible++;
  5855. }
  5856. if (!astralRegex.test(character) && isFullwidthCodePoint(character.codePointAt())) {
  5857. visible++;
  5858. if (typeof end !== 'number') {
  5859. stringEnd++;
  5860. }
  5861. }
  5862. if (visible > begin && visible <= stringEnd) {
  5863. output += character;
  5864. } else if (visible === begin && !isInsideEscape && ansiCode !== undefined) {
  5865. output = checkAnsi(ansiCodes);
  5866. } else if (visible >= stringEnd) {
  5867. output += checkAnsi(ansiCodes, true, ansiCode);
  5868. break;
  5869. }
  5870. }
  5871. return output;
  5872. }
  5873. function ansiRegex({onlyFirst = false} = {}) {
  5874. const pattern = [
  5875. '[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)',
  5876. '(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))'
  5877. ].join('|');
  5878. return new RegExp(pattern, onlyFirst ? undefined : 'g');
  5879. }
  5880. function stripAnsi(string) {
  5881. if (typeof string !== 'string') {
  5882. throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``);
  5883. }
  5884. return string.replace(ansiRegex(), '');
  5885. }
  5886. var eastasianwidth = {exports: {}};
  5887. (function (module) {
  5888. var eaw = {};
  5889. {
  5890. module.exports = eaw;
  5891. }
  5892. eaw.eastAsianWidth = function(character) {
  5893. var x = character.charCodeAt(0);
  5894. var y = (character.length == 2) ? character.charCodeAt(1) : 0;
  5895. var codePoint = x;
  5896. if ((0xD800 <= x && x <= 0xDBFF) && (0xDC00 <= y && y <= 0xDFFF)) {
  5897. x &= 0x3FF;
  5898. y &= 0x3FF;
  5899. codePoint = (x << 10) | y;
  5900. codePoint += 0x10000;
  5901. }
  5902. if ((0x3000 == codePoint) ||
  5903. (0xFF01 <= codePoint && codePoint <= 0xFF60) ||
  5904. (0xFFE0 <= codePoint && codePoint <= 0xFFE6)) {
  5905. return 'F';
  5906. }
  5907. if ((0x20A9 == codePoint) ||
  5908. (0xFF61 <= codePoint && codePoint <= 0xFFBE) ||
  5909. (0xFFC2 <= codePoint && codePoint <= 0xFFC7) ||
  5910. (0xFFCA <= codePoint && codePoint <= 0xFFCF) ||
  5911. (0xFFD2 <= codePoint && codePoint <= 0xFFD7) ||
  5912. (0xFFDA <= codePoint && codePoint <= 0xFFDC) ||
  5913. (0xFFE8 <= codePoint && codePoint <= 0xFFEE)) {
  5914. return 'H';
  5915. }
  5916. if ((0x1100 <= codePoint && codePoint <= 0x115F) ||
  5917. (0x11A3 <= codePoint && codePoint <= 0x11A7) ||
  5918. (0x11FA <= codePoint && codePoint <= 0x11FF) ||
  5919. (0x2329 <= codePoint && codePoint <= 0x232A) ||
  5920. (0x2E80 <= codePoint && codePoint <= 0x2E99) ||
  5921. (0x2E9B <= codePoint && codePoint <= 0x2EF3) ||
  5922. (0x2F00 <= codePoint && codePoint <= 0x2FD5) ||
  5923. (0x2FF0 <= codePoint && codePoint <= 0x2FFB) ||
  5924. (0x3001 <= codePoint && codePoint <= 0x303E) ||
  5925. (0x3041 <= codePoint && codePoint <= 0x3096) ||
  5926. (0x3099 <= codePoint && codePoint <= 0x30FF) ||
  5927. (0x3105 <= codePoint && codePoint <= 0x312D) ||
  5928. (0x3131 <= codePoint && codePoint <= 0x318E) ||
  5929. (0x3190 <= codePoint && codePoint <= 0x31BA) ||
  5930. (0x31C0 <= codePoint && codePoint <= 0x31E3) ||
  5931. (0x31F0 <= codePoint && codePoint <= 0x321E) ||
  5932. (0x3220 <= codePoint && codePoint <= 0x3247) ||
  5933. (0x3250 <= codePoint && codePoint <= 0x32FE) ||
  5934. (0x3300 <= codePoint && codePoint <= 0x4DBF) ||
  5935. (0x4E00 <= codePoint && codePoint <= 0xA48C) ||
  5936. (0xA490 <= codePoint && codePoint <= 0xA4C6) ||
  5937. (0xA960 <= codePoint && codePoint <= 0xA97C) ||
  5938. (0xAC00 <= codePoint && codePoint <= 0xD7A3) ||
  5939. (0xD7B0 <= codePoint && codePoint <= 0xD7C6) ||
  5940. (0xD7CB <= codePoint && codePoint <= 0xD7FB) ||
  5941. (0xF900 <= codePoint && codePoint <= 0xFAFF) ||
  5942. (0xFE10 <= codePoint && codePoint <= 0xFE19) ||
  5943. (0xFE30 <= codePoint && codePoint <= 0xFE52) ||
  5944. (0xFE54 <= codePoint && codePoint <= 0xFE66) ||
  5945. (0xFE68 <= codePoint && codePoint <= 0xFE6B) ||
  5946. (0x1B000 <= codePoint && codePoint <= 0x1B001) ||
  5947. (0x1F200 <= codePoint && codePoint <= 0x1F202) ||
  5948. (0x1F210 <= codePoint && codePoint <= 0x1F23A) ||
  5949. (0x1F240 <= codePoint && codePoint <= 0x1F248) ||
  5950. (0x1F250 <= codePoint && codePoint <= 0x1F251) ||
  5951. (0x20000 <= codePoint && codePoint <= 0x2F73F) ||
  5952. (0x2B740 <= codePoint && codePoint <= 0x2FFFD) ||
  5953. (0x30000 <= codePoint && codePoint <= 0x3FFFD)) {
  5954. return 'W';
  5955. }
  5956. if ((0x0020 <= codePoint && codePoint <= 0x007E) ||
  5957. (0x00A2 <= codePoint && codePoint <= 0x00A3) ||
  5958. (0x00A5 <= codePoint && codePoint <= 0x00A6) ||
  5959. (0x00AC == codePoint) ||
  5960. (0x00AF == codePoint) ||
  5961. (0x27E6 <= codePoint && codePoint <= 0x27ED) ||
  5962. (0x2985 <= codePoint && codePoint <= 0x2986)) {
  5963. return 'Na';
  5964. }
  5965. if ((0x00A1 == codePoint) ||
  5966. (0x00A4 == codePoint) ||
  5967. (0x00A7 <= codePoint && codePoint <= 0x00A8) ||
  5968. (0x00AA == codePoint) ||
  5969. (0x00AD <= codePoint && codePoint <= 0x00AE) ||
  5970. (0x00B0 <= codePoint && codePoint <= 0x00B4) ||
  5971. (0x00B6 <= codePoint && codePoint <= 0x00BA) ||
  5972. (0x00BC <= codePoint && codePoint <= 0x00BF) ||
  5973. (0x00C6 == codePoint) ||
  5974. (0x00D0 == codePoint) ||
  5975. (0x00D7 <= codePoint && codePoint <= 0x00D8) ||
  5976. (0x00DE <= codePoint && codePoint <= 0x00E1) ||
  5977. (0x00E6 == codePoint) ||
  5978. (0x00E8 <= codePoint && codePoint <= 0x00EA) ||
  5979. (0x00EC <= codePoint && codePoint <= 0x00ED) ||
  5980. (0x00F0 == codePoint) ||
  5981. (0x00F2 <= codePoint && codePoint <= 0x00F3) ||
  5982. (0x00F7 <= codePoint && codePoint <= 0x00FA) ||
  5983. (0x00FC == codePoint) ||
  5984. (0x00FE == codePoint) ||
  5985. (0x0101 == codePoint) ||
  5986. (0x0111 == codePoint) ||
  5987. (0x0113 == codePoint) ||
  5988. (0x011B == codePoint) ||
  5989. (0x0126 <= codePoint && codePoint <= 0x0127) ||
  5990. (0x012B == codePoint) ||
  5991. (0x0131 <= codePoint && codePoint <= 0x0133) ||
  5992. (0x0138 == codePoint) ||
  5993. (0x013F <= codePoint && codePoint <= 0x0142) ||
  5994. (0x0144 == codePoint) ||
  5995. (0x0148 <= codePoint && codePoint <= 0x014B) ||
  5996. (0x014D == codePoint) ||
  5997. (0x0152 <= codePoint && codePoint <= 0x0153) ||
  5998. (0x0166 <= codePoint && codePoint <= 0x0167) ||
  5999. (0x016B == codePoint) ||
  6000. (0x01CE == codePoint) ||
  6001. (0x01D0 == codePoint) ||
  6002. (0x01D2 == codePoint) ||
  6003. (0x01D4 == codePoint) ||
  6004. (0x01D6 == codePoint) ||
  6005. (0x01D8 == codePoint) ||
  6006. (0x01DA == codePoint) ||
  6007. (0x01DC == codePoint) ||
  6008. (0x0251 == codePoint) ||
  6009. (0x0261 == codePoint) ||
  6010. (0x02C4 == codePoint) ||
  6011. (0x02C7 == codePoint) ||
  6012. (0x02C9 <= codePoint && codePoint <= 0x02CB) ||
  6013. (0x02CD == codePoint) ||
  6014. (0x02D0 == codePoint) ||
  6015. (0x02D8 <= codePoint && codePoint <= 0x02DB) ||
  6016. (0x02DD == codePoint) ||
  6017. (0x02DF == codePoint) ||
  6018. (0x0300 <= codePoint && codePoint <= 0x036F) ||
  6019. (0x0391 <= codePoint && codePoint <= 0x03A1) ||
  6020. (0x03A3 <= codePoint && codePoint <= 0x03A9) ||
  6021. (0x03B1 <= codePoint && codePoint <= 0x03C1) ||
  6022. (0x03C3 <= codePoint && codePoint <= 0x03C9) ||
  6023. (0x0401 == codePoint) ||
  6024. (0x0410 <= codePoint && codePoint <= 0x044F) ||
  6025. (0x0451 == codePoint) ||
  6026. (0x2010 == codePoint) ||
  6027. (0x2013 <= codePoint && codePoint <= 0x2016) ||
  6028. (0x2018 <= codePoint && codePoint <= 0x2019) ||
  6029. (0x201C <= codePoint && codePoint <= 0x201D) ||
  6030. (0x2020 <= codePoint && codePoint <= 0x2022) ||
  6031. (0x2024 <= codePoint && codePoint <= 0x2027) ||
  6032. (0x2030 == codePoint) ||
  6033. (0x2032 <= codePoint && codePoint <= 0x2033) ||
  6034. (0x2035 == codePoint) ||
  6035. (0x203B == codePoint) ||
  6036. (0x203E == codePoint) ||
  6037. (0x2074 == codePoint) ||
  6038. (0x207F == codePoint) ||
  6039. (0x2081 <= codePoint && codePoint <= 0x2084) ||
  6040. (0x20AC == codePoint) ||
  6041. (0x2103 == codePoint) ||
  6042. (0x2105 == codePoint) ||
  6043. (0x2109 == codePoint) ||
  6044. (0x2113 == codePoint) ||
  6045. (0x2116 == codePoint) ||
  6046. (0x2121 <= codePoint && codePoint <= 0x2122) ||
  6047. (0x2126 == codePoint) ||
  6048. (0x212B == codePoint) ||
  6049. (0x2153 <= codePoint && codePoint <= 0x2154) ||
  6050. (0x215B <= codePoint && codePoint <= 0x215E) ||
  6051. (0x2160 <= codePoint && codePoint <= 0x216B) ||
  6052. (0x2170 <= codePoint && codePoint <= 0x2179) ||
  6053. (0x2189 == codePoint) ||
  6054. (0x2190 <= codePoint && codePoint <= 0x2199) ||
  6055. (0x21B8 <= codePoint && codePoint <= 0x21B9) ||
  6056. (0x21D2 == codePoint) ||
  6057. (0x21D4 == codePoint) ||
  6058. (0x21E7 == codePoint) ||
  6059. (0x2200 == codePoint) ||
  6060. (0x2202 <= codePoint && codePoint <= 0x2203) ||
  6061. (0x2207 <= codePoint && codePoint <= 0x2208) ||
  6062. (0x220B == codePoint) ||
  6063. (0x220F == codePoint) ||
  6064. (0x2211 == codePoint) ||
  6065. (0x2215 == codePoint) ||
  6066. (0x221A == codePoint) ||
  6067. (0x221D <= codePoint && codePoint <= 0x2220) ||
  6068. (0x2223 == codePoint) ||
  6069. (0x2225 == codePoint) ||
  6070. (0x2227 <= codePoint && codePoint <= 0x222C) ||
  6071. (0x222E == codePoint) ||
  6072. (0x2234 <= codePoint && codePoint <= 0x2237) ||
  6073. (0x223C <= codePoint && codePoint <= 0x223D) ||
  6074. (0x2248 == codePoint) ||
  6075. (0x224C == codePoint) ||
  6076. (0x2252 == codePoint) ||
  6077. (0x2260 <= codePoint && codePoint <= 0x2261) ||
  6078. (0x2264 <= codePoint && codePoint <= 0x2267) ||
  6079. (0x226A <= codePoint && codePoint <= 0x226B) ||
  6080. (0x226E <= codePoint && codePoint <= 0x226F) ||
  6081. (0x2282 <= codePoint && codePoint <= 0x2283) ||
  6082. (0x2286 <= codePoint && codePoint <= 0x2287) ||
  6083. (0x2295 == codePoint) ||
  6084. (0x2299 == codePoint) ||
  6085. (0x22A5 == codePoint) ||
  6086. (0x22BF == codePoint) ||
  6087. (0x2312 == codePoint) ||
  6088. (0x2460 <= codePoint && codePoint <= 0x24E9) ||
  6089. (0x24EB <= codePoint && codePoint <= 0x254B) ||
  6090. (0x2550 <= codePoint && codePoint <= 0x2573) ||
  6091. (0x2580 <= codePoint && codePoint <= 0x258F) ||
  6092. (0x2592 <= codePoint && codePoint <= 0x2595) ||
  6093. (0x25A0 <= codePoint && codePoint <= 0x25A1) ||
  6094. (0x25A3 <= codePoint && codePoint <= 0x25A9) ||
  6095. (0x25B2 <= codePoint && codePoint <= 0x25B3) ||
  6096. (0x25B6 <= codePoint && codePoint <= 0x25B7) ||
  6097. (0x25BC <= codePoint && codePoint <= 0x25BD) ||
  6098. (0x25C0 <= codePoint && codePoint <= 0x25C1) ||
  6099. (0x25C6 <= codePoint && codePoint <= 0x25C8) ||
  6100. (0x25CB == codePoint) ||
  6101. (0x25CE <= codePoint && codePoint <= 0x25D1) ||
  6102. (0x25E2 <= codePoint && codePoint <= 0x25E5) ||
  6103. (0x25EF == codePoint) ||
  6104. (0x2605 <= codePoint && codePoint <= 0x2606) ||
  6105. (0x2609 == codePoint) ||
  6106. (0x260E <= codePoint && codePoint <= 0x260F) ||
  6107. (0x2614 <= codePoint && codePoint <= 0x2615) ||
  6108. (0x261C == codePoint) ||
  6109. (0x261E == codePoint) ||
  6110. (0x2640 == codePoint) ||
  6111. (0x2642 == codePoint) ||
  6112. (0x2660 <= codePoint && codePoint <= 0x2661) ||
  6113. (0x2663 <= codePoint && codePoint <= 0x2665) ||
  6114. (0x2667 <= codePoint && codePoint <= 0x266A) ||
  6115. (0x266C <= codePoint && codePoint <= 0x266D) ||
  6116. (0x266F == codePoint) ||
  6117. (0x269E <= codePoint && codePoint <= 0x269F) ||
  6118. (0x26BE <= codePoint && codePoint <= 0x26BF) ||
  6119. (0x26C4 <= codePoint && codePoint <= 0x26CD) ||
  6120. (0x26CF <= codePoint && codePoint <= 0x26E1) ||
  6121. (0x26E3 == codePoint) ||
  6122. (0x26E8 <= codePoint && codePoint <= 0x26FF) ||
  6123. (0x273D == codePoint) ||
  6124. (0x2757 == codePoint) ||
  6125. (0x2776 <= codePoint && codePoint <= 0x277F) ||
  6126. (0x2B55 <= codePoint && codePoint <= 0x2B59) ||
  6127. (0x3248 <= codePoint && codePoint <= 0x324F) ||
  6128. (0xE000 <= codePoint && codePoint <= 0xF8FF) ||
  6129. (0xFE00 <= codePoint && codePoint <= 0xFE0F) ||
  6130. (0xFFFD == codePoint) ||
  6131. (0x1F100 <= codePoint && codePoint <= 0x1F10A) ||
  6132. (0x1F110 <= codePoint && codePoint <= 0x1F12D) ||
  6133. (0x1F130 <= codePoint && codePoint <= 0x1F169) ||
  6134. (0x1F170 <= codePoint && codePoint <= 0x1F19A) ||
  6135. (0xE0100 <= codePoint && codePoint <= 0xE01EF) ||
  6136. (0xF0000 <= codePoint && codePoint <= 0xFFFFD) ||
  6137. (0x100000 <= codePoint && codePoint <= 0x10FFFD)) {
  6138. return 'A';
  6139. }
  6140. return 'N';
  6141. };
  6142. eaw.characterLength = function(character) {
  6143. var code = this.eastAsianWidth(character);
  6144. if (code == 'F' || code == 'W' || code == 'A') {
  6145. return 2;
  6146. } else {
  6147. return 1;
  6148. }
  6149. };
  6150. // Split a string considering surrogate-pairs.
  6151. function stringToArray(string) {
  6152. return string.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g) || [];
  6153. }
  6154. eaw.length = function(string) {
  6155. var characters = stringToArray(string);
  6156. var len = 0;
  6157. for (var i = 0; i < characters.length; i++) {
  6158. len = len + this.characterLength(characters[i]);
  6159. }
  6160. return len;
  6161. };
  6162. eaw.slice = function(text, start, end) {
  6163. textLen = eaw.length(text);
  6164. start = start ? start : 0;
  6165. end = end ? end : 1;
  6166. if (start < 0) {
  6167. start = textLen + start;
  6168. }
  6169. if (end < 0) {
  6170. end = textLen + end;
  6171. }
  6172. var result = '';
  6173. var eawLen = 0;
  6174. var chars = stringToArray(text);
  6175. for (var i = 0; i < chars.length; i++) {
  6176. var char = chars[i];
  6177. var charLen = eaw.length(char);
  6178. if (eawLen >= start - (charLen == 2 ? 1 : 0)) {
  6179. if (eawLen + charLen <= end) {
  6180. result += char;
  6181. } else {
  6182. break;
  6183. }
  6184. }
  6185. eawLen += charLen;
  6186. }
  6187. return result;
  6188. };
  6189. } (eastasianwidth));
  6190. var eastAsianWidth = eastasianwidth.exports;
  6191. var emojiRegex = function () {
  6192. // https://mths.be/emoji
  6193. return /\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67)\uDB40\uDC7F|(?:\uD83E\uDDD1\uD83C\uDFFF\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFC-\uDFFF])|\uD83D\uDC68(?:\uD83C\uDFFB(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|[\u2695\u2696\u2708]\uFE0F|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))?|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\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\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])\uFE0F|\u200D(?:(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D[\uDC66\uDC67])|\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC)?|(?:\uD83D\uDC69(?:\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69]))|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC69(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83E\uDDD1(?:\u200D(?:\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDE36\u200D\uD83C\uDF2B|\uD83C\uDFF3\uFE0F\u200D\u26A7|\uD83D\uDC3B\u200D\u2744|(?:(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\uD83C\uDFF4\u200D\u2620|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])\u200D[\u2640\u2642]|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u2600-\u2604\u260E\u2611\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26B0\u26B1\u26C8\u26CF\u26D1\u26D3\u26E9\u26F0\u26F1\u26F4\u26F7\u26F8\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u3030\u303D\u3297\u3299]|\uD83C[\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]|\uD83D[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3])\uFE0F|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDE35\u200D\uD83D\uDCAB|\uD83D\uDE2E\u200D\uD83D\uDCA8|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83E\uDDD1(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83D\uDC69(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF6\uD83C\uDDE6|\uD83C\uDDF4\uD83C\uDDF2|\uD83D\uDC08\u200D\u2B1B|\u2764\uFE0F\u200D(?:\uD83D\uDD25|\uD83E\uDE79)|\uD83D\uDC41\uFE0F|\uD83C\uDFF3\uFE0F|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|[#\*0-9]\uFE0F\u20E3|\u2764\uFE0F|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|\uD83C\uDFF4|(?:[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270C\u270D]|\uD83D[\uDD74\uDD90])(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC08\uDC15\uDC3B\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE2E\uDE35\uDE36\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5]|\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD]|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF]|[\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\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0D\uDD0E\uDD10-\uDD17\uDD1D\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78\uDD7A-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCB\uDDD0\uDDE0-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6]|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])|(?:[#\*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\u26A7\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5-\uDED7\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDD77\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g;
  6194. };
  6195. function stringWidth(string, options = {}) {
  6196. if (typeof string !== 'string' || string.length === 0) {
  6197. return 0;
  6198. }
  6199. options = {
  6200. ambiguousIsNarrow: true,
  6201. ...options
  6202. };
  6203. string = stripAnsi(string);
  6204. if (string.length === 0) {
  6205. return 0;
  6206. }
  6207. string = string.replace(emojiRegex(), ' ');
  6208. const ambiguousCharacterWidth = options.ambiguousIsNarrow ? 1 : 2;
  6209. let width = 0;
  6210. for (const character of string) {
  6211. const codePoint = character.codePointAt(0);
  6212. // Ignore control characters
  6213. if (codePoint <= 0x1F || (codePoint >= 0x7F && codePoint <= 0x9F)) {
  6214. continue;
  6215. }
  6216. // Ignore combining characters
  6217. if (codePoint >= 0x300 && codePoint <= 0x36F) {
  6218. continue;
  6219. }
  6220. const code = eastAsianWidth.eastAsianWidth(character);
  6221. switch (code) {
  6222. case 'F':
  6223. case 'W':
  6224. width += 2;
  6225. break;
  6226. case 'A':
  6227. width += ambiguousCharacterWidth;
  6228. break;
  6229. default:
  6230. width += 1;
  6231. }
  6232. }
  6233. return width;
  6234. }
  6235. function getIndexOfNearestSpace(string, wantedIndex, shouldSearchRight) {
  6236. if (string.charAt(wantedIndex) === ' ') {
  6237. return wantedIndex;
  6238. }
  6239. for (let index = 1; index <= 3; index++) {
  6240. if (shouldSearchRight) {
  6241. if (string.charAt(wantedIndex + index) === ' ') {
  6242. return wantedIndex + index;
  6243. }
  6244. } else if (string.charAt(wantedIndex - index) === ' ') {
  6245. return wantedIndex - index;
  6246. }
  6247. }
  6248. return wantedIndex;
  6249. }
  6250. function cliTruncate(text, columns, options) {
  6251. options = {
  6252. position: 'end',
  6253. preferTruncationOnSpace: false,
  6254. truncationCharacter: '…',
  6255. ...options,
  6256. };
  6257. const {position, space, preferTruncationOnSpace} = options;
  6258. let {truncationCharacter} = options;
  6259. if (typeof text !== 'string') {
  6260. throw new TypeError(`Expected \`input\` to be a string, got ${typeof text}`);
  6261. }
  6262. if (typeof columns !== 'number') {
  6263. throw new TypeError(`Expected \`columns\` to be a number, got ${typeof columns}`);
  6264. }
  6265. if (columns < 1) {
  6266. return '';
  6267. }
  6268. if (columns === 1) {
  6269. return truncationCharacter;
  6270. }
  6271. const length = stringWidth(text);
  6272. if (length <= columns) {
  6273. return text;
  6274. }
  6275. if (position === 'start') {
  6276. if (preferTruncationOnSpace) {
  6277. const nearestSpace = getIndexOfNearestSpace(text, length - columns + 1, true);
  6278. return truncationCharacter + sliceAnsi(text, nearestSpace, length).trim();
  6279. }
  6280. if (space === true) {
  6281. truncationCharacter += ' ';
  6282. }
  6283. return truncationCharacter + sliceAnsi(text, length - columns + stringWidth(truncationCharacter), length);
  6284. }
  6285. if (position === 'middle') {
  6286. if (space === true) {
  6287. truncationCharacter = ` ${truncationCharacter} `;
  6288. }
  6289. const half = Math.floor(columns / 2);
  6290. if (preferTruncationOnSpace) {
  6291. const spaceNearFirstBreakPoint = getIndexOfNearestSpace(text, half);
  6292. const spaceNearSecondBreakPoint = getIndexOfNearestSpace(text, length - (columns - half) + 1, true);
  6293. return sliceAnsi(text, 0, spaceNearFirstBreakPoint) + truncationCharacter + sliceAnsi(text, spaceNearSecondBreakPoint, length).trim();
  6294. }
  6295. return (
  6296. sliceAnsi(text, 0, half)
  6297. + truncationCharacter
  6298. + sliceAnsi(text, length - (columns - half) + stringWidth(truncationCharacter), length)
  6299. );
  6300. }
  6301. if (position === 'end') {
  6302. if (preferTruncationOnSpace) {
  6303. const nearestSpace = getIndexOfNearestSpace(text, columns - 1);
  6304. return sliceAnsi(text, 0, nearestSpace) + truncationCharacter;
  6305. }
  6306. if (space === true) {
  6307. truncationCharacter = ` ${truncationCharacter}`;
  6308. }
  6309. return sliceAnsi(text, 0, columns - stringWidth(truncationCharacter)) + truncationCharacter;
  6310. }
  6311. throw new Error(`Expected \`options.position\` to be either \`start\`, \`middle\` or \`end\`, got ${position}`);
  6312. }
  6313. function formatLine(line, outputTruncateLength) {
  6314. var _a;
  6315. return cliTruncate(line, (outputTruncateLength ?? (((_a = process.stdout) == null ? void 0 : _a.columns) || 80)) - 4);
  6316. }
  6317. function unifiedDiff(actual, expected, options = {}) {
  6318. if (actual === expected)
  6319. return "";
  6320. const { outputTruncateLength, outputDiffLines, showLegend = true } = options;
  6321. const indent = " ";
  6322. const diffLimit = outputDiffLines || 15;
  6323. const counts = {
  6324. "+": 0,
  6325. "-": 0
  6326. };
  6327. let previousState = null;
  6328. let previousCount = 0;
  6329. function preprocess(line) {
  6330. if (!line || line.match(/\\ No newline/))
  6331. return;
  6332. const char = line[0];
  6333. if ("-+".includes(char)) {
  6334. if (previousState !== char) {
  6335. previousState = char;
  6336. previousCount = 0;
  6337. }
  6338. previousCount++;
  6339. counts[char]++;
  6340. if (previousCount === diffLimit)
  6341. return picocolors.exports.dim(`${char} ...`);
  6342. else if (previousCount > diffLimit)
  6343. return;
  6344. }
  6345. return line;
  6346. }
  6347. const msg = createPatch("string", expected, actual);
  6348. const lines = msg.split("\n").slice(5).map(preprocess).filter(Boolean);
  6349. const isCompact = counts["+"] === 1 && counts["-"] === 1 && lines.length === 2;
  6350. let formatted = lines.map((line) => {
  6351. line = line.replace(/\\"/g, '"');
  6352. if (line[0] === "-") {
  6353. line = formatLine(line.slice(1), outputTruncateLength);
  6354. if (isCompact)
  6355. return picocolors.exports.green(line);
  6356. return picocolors.exports.green(`- ${formatLine(line, outputTruncateLength)}`);
  6357. }
  6358. if (line[0] === "+") {
  6359. line = formatLine(line.slice(1), outputTruncateLength);
  6360. if (isCompact)
  6361. return picocolors.exports.red(line);
  6362. return picocolors.exports.red(`+ ${formatLine(line, outputTruncateLength)}`);
  6363. }
  6364. if (line.match(/@@/))
  6365. return "--";
  6366. return ` ${line}`;
  6367. });
  6368. if (showLegend) {
  6369. if (isCompact) {
  6370. formatted = [
  6371. `${picocolors.exports.green("- Expected")} ${formatted[0]}`,
  6372. `${picocolors.exports.red("+ Received")} ${formatted[1]}`
  6373. ];
  6374. } else {
  6375. if (formatted[0].includes('"'))
  6376. formatted[0] = formatted[0].replace('"', "");
  6377. const last = formatted.length - 1;
  6378. if (formatted[last].endsWith('"'))
  6379. formatted[last] = formatted[last].slice(0, formatted[last].length - 1);
  6380. formatted.unshift(
  6381. picocolors.exports.green(`- Expected - ${counts["-"]}`),
  6382. picocolors.exports.red(`+ Received + ${counts["+"]}`),
  6383. ""
  6384. );
  6385. }
  6386. }
  6387. return formatted.map((i) => indent + i).join("\n");
  6388. }
  6389. const EXPECTED_COLOR = picocolors.exports.green;
  6390. const RECEIVED_COLOR = picocolors.exports.red;
  6391. const INVERTED_COLOR = picocolors.exports.inverse;
  6392. const BOLD_WEIGHT = picocolors.exports.bold;
  6393. const DIM_COLOR = picocolors.exports.dim;
  6394. const {
  6395. AsymmetricMatcher,
  6396. DOMCollection,
  6397. DOMElement,
  6398. Immutable,
  6399. ReactElement,
  6400. ReactTestComponent
  6401. } = plugins_1;
  6402. const PLUGINS = [
  6403. ReactTestComponent,
  6404. ReactElement,
  6405. DOMElement,
  6406. DOMCollection,
  6407. Immutable,
  6408. AsymmetricMatcher
  6409. ];
  6410. function matcherHint(matcherName, received = "received", expected = "expected", options = {}) {
  6411. const {
  6412. comment = "",
  6413. expectedColor = EXPECTED_COLOR,
  6414. isDirectExpectCall = false,
  6415. isNot = false,
  6416. promise = "",
  6417. receivedColor = RECEIVED_COLOR,
  6418. secondArgument = "",
  6419. secondArgumentColor = EXPECTED_COLOR
  6420. } = options;
  6421. let hint = "";
  6422. let dimString = "expect";
  6423. if (!isDirectExpectCall && received !== "") {
  6424. hint += DIM_COLOR(`${dimString}(`) + receivedColor(received);
  6425. dimString = ")";
  6426. }
  6427. if (promise !== "") {
  6428. hint += DIM_COLOR(`${dimString}.`) + promise;
  6429. dimString = "";
  6430. }
  6431. if (isNot) {
  6432. hint += `${DIM_COLOR(`${dimString}.`)}not`;
  6433. dimString = "";
  6434. }
  6435. if (matcherName.includes(".")) {
  6436. dimString += matcherName;
  6437. } else {
  6438. hint += DIM_COLOR(`${dimString}.`) + matcherName;
  6439. dimString = "";
  6440. }
  6441. if (expected === "") {
  6442. dimString += "()";
  6443. } else {
  6444. hint += DIM_COLOR(`${dimString}(`) + expectedColor(expected);
  6445. if (secondArgument)
  6446. hint += DIM_COLOR(", ") + secondArgumentColor(secondArgument);
  6447. dimString = ")";
  6448. }
  6449. if (comment !== "")
  6450. dimString += ` // ${comment}`;
  6451. if (dimString !== "")
  6452. hint += DIM_COLOR(dimString);
  6453. return hint;
  6454. }
  6455. const SPACE_SYMBOL = "\xB7";
  6456. const replaceTrailingSpaces = (text) => text.replace(/\s+$/gm, (spaces) => SPACE_SYMBOL.repeat(spaces.length));
  6457. function stringify(object, maxDepth = 10, options) {
  6458. const MAX_LENGTH = 1e4;
  6459. let result;
  6460. try {
  6461. result = format_1(object, {
  6462. maxDepth,
  6463. plugins: PLUGINS,
  6464. ...options
  6465. });
  6466. } catch {
  6467. result = format_1(object, {
  6468. callToJSON: false,
  6469. maxDepth,
  6470. plugins: PLUGINS,
  6471. ...options
  6472. });
  6473. }
  6474. return result.length >= MAX_LENGTH && maxDepth > 1 ? stringify(object, Math.floor(maxDepth / 2)) : result;
  6475. }
  6476. const printReceived = (object) => RECEIVED_COLOR(replaceTrailingSpaces(stringify(object)));
  6477. const printExpected = (value) => EXPECTED_COLOR(replaceTrailingSpaces(stringify(value)));
  6478. function diff(a, b, options) {
  6479. return unifiedDiff(stringify(b), stringify(a));
  6480. }
  6481. var matcherUtils = /*#__PURE__*/Object.freeze({
  6482. __proto__: null,
  6483. EXPECTED_COLOR: EXPECTED_COLOR,
  6484. RECEIVED_COLOR: RECEIVED_COLOR,
  6485. INVERTED_COLOR: INVERTED_COLOR,
  6486. BOLD_WEIGHT: BOLD_WEIGHT,
  6487. DIM_COLOR: DIM_COLOR,
  6488. matcherHint: matcherHint,
  6489. stringify: stringify,
  6490. printReceived: printReceived,
  6491. printExpected: printExpected,
  6492. diff: diff
  6493. });
  6494. export { plugins_1 as a, posToNumber as b, stripAnsi as c, cliTruncate as d, stringWidth as e, format_1 as f, getOriginalPos as g, ansiStyles as h, interpretSourcePos as i, sliceAnsi as j, lineSplitRE as l, matcherUtils as m, numberToPos as n, parseStacktrace as p, stringify as s, unifiedDiff as u };