sanitize-html-es2015.js 679 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346
  1. (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.sanitizeHtml = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
  2. 'use strict'
  3. exports.byteLength = byteLength
  4. exports.toByteArray = toByteArray
  5. exports.fromByteArray = fromByteArray
  6. var lookup = []
  7. var revLookup = []
  8. var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
  9. var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
  10. for (var i = 0, len = code.length; i < len; ++i) {
  11. lookup[i] = code[i]
  12. revLookup[code.charCodeAt(i)] = i
  13. }
  14. // Support decoding URL-safe base64 strings, as Node.js does.
  15. // See: https://en.wikipedia.org/wiki/Base64#URL_applications
  16. revLookup['-'.charCodeAt(0)] = 62
  17. revLookup['_'.charCodeAt(0)] = 63
  18. function getLens (b64) {
  19. var len = b64.length
  20. if (len % 4 > 0) {
  21. throw new Error('Invalid string. Length must be a multiple of 4')
  22. }
  23. // Trim off extra bytes after placeholder bytes are found
  24. // See: https://github.com/beatgammit/base64-js/issues/42
  25. var validLen = b64.indexOf('=')
  26. if (validLen === -1) validLen = len
  27. var placeHoldersLen = validLen === len
  28. ? 0
  29. : 4 - (validLen % 4)
  30. return [validLen, placeHoldersLen]
  31. }
  32. // base64 is 4/3 + up to two characters of the original data
  33. function byteLength (b64) {
  34. var lens = getLens(b64)
  35. var validLen = lens[0]
  36. var placeHoldersLen = lens[1]
  37. return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
  38. }
  39. function _byteLength (b64, validLen, placeHoldersLen) {
  40. return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
  41. }
  42. function toByteArray (b64) {
  43. var tmp
  44. var lens = getLens(b64)
  45. var validLen = lens[0]
  46. var placeHoldersLen = lens[1]
  47. var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))
  48. var curByte = 0
  49. // if there are placeholders, only get up to the last complete 4 chars
  50. var len = placeHoldersLen > 0
  51. ? validLen - 4
  52. : validLen
  53. var i
  54. for (i = 0; i < len; i += 4) {
  55. tmp =
  56. (revLookup[b64.charCodeAt(i)] << 18) |
  57. (revLookup[b64.charCodeAt(i + 1)] << 12) |
  58. (revLookup[b64.charCodeAt(i + 2)] << 6) |
  59. revLookup[b64.charCodeAt(i + 3)]
  60. arr[curByte++] = (tmp >> 16) & 0xFF
  61. arr[curByte++] = (tmp >> 8) & 0xFF
  62. arr[curByte++] = tmp & 0xFF
  63. }
  64. if (placeHoldersLen === 2) {
  65. tmp =
  66. (revLookup[b64.charCodeAt(i)] << 2) |
  67. (revLookup[b64.charCodeAt(i + 1)] >> 4)
  68. arr[curByte++] = tmp & 0xFF
  69. }
  70. if (placeHoldersLen === 1) {
  71. tmp =
  72. (revLookup[b64.charCodeAt(i)] << 10) |
  73. (revLookup[b64.charCodeAt(i + 1)] << 4) |
  74. (revLookup[b64.charCodeAt(i + 2)] >> 2)
  75. arr[curByte++] = (tmp >> 8) & 0xFF
  76. arr[curByte++] = tmp & 0xFF
  77. }
  78. return arr
  79. }
  80. function tripletToBase64 (num) {
  81. return lookup[num >> 18 & 0x3F] +
  82. lookup[num >> 12 & 0x3F] +
  83. lookup[num >> 6 & 0x3F] +
  84. lookup[num & 0x3F]
  85. }
  86. function encodeChunk (uint8, start, end) {
  87. var tmp
  88. var output = []
  89. for (var i = start; i < end; i += 3) {
  90. tmp =
  91. ((uint8[i] << 16) & 0xFF0000) +
  92. ((uint8[i + 1] << 8) & 0xFF00) +
  93. (uint8[i + 2] & 0xFF)
  94. output.push(tripletToBase64(tmp))
  95. }
  96. return output.join('')
  97. }
  98. function fromByteArray (uint8) {
  99. var tmp
  100. var len = uint8.length
  101. var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
  102. var parts = []
  103. var maxChunkLength = 16383 // must be multiple of 3
  104. // go through the array every three bytes, we'll deal with trailing stuff later
  105. for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
  106. parts.push(encodeChunk(
  107. uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)
  108. ))
  109. }
  110. // pad the end with zeros, but make sure to not forget the extra bytes
  111. if (extraBytes === 1) {
  112. tmp = uint8[len - 1]
  113. parts.push(
  114. lookup[tmp >> 2] +
  115. lookup[(tmp << 4) & 0x3F] +
  116. '=='
  117. )
  118. } else if (extraBytes === 2) {
  119. tmp = (uint8[len - 2] << 8) + uint8[len - 1]
  120. parts.push(
  121. lookup[tmp >> 10] +
  122. lookup[(tmp >> 4) & 0x3F] +
  123. lookup[(tmp << 2) & 0x3F] +
  124. '='
  125. )
  126. }
  127. return parts.join('')
  128. }
  129. },{}],2:[function(require,module,exports){
  130. },{}],3:[function(require,module,exports){
  131. (function (Buffer){
  132. /*!
  133. * The buffer module from node.js, for the browser.
  134. *
  135. * @author Feross Aboukhadijeh <https://feross.org>
  136. * @license MIT
  137. */
  138. /* eslint-disable no-proto */
  139. 'use strict'
  140. var base64 = require('base64-js')
  141. var ieee754 = require('ieee754')
  142. exports.Buffer = Buffer
  143. exports.SlowBuffer = SlowBuffer
  144. exports.INSPECT_MAX_BYTES = 50
  145. var K_MAX_LENGTH = 0x7fffffff
  146. exports.kMaxLength = K_MAX_LENGTH
  147. /**
  148. * If `Buffer.TYPED_ARRAY_SUPPORT`:
  149. * === true Use Uint8Array implementation (fastest)
  150. * === false Print warning and recommend using `buffer` v4.x which has an Object
  151. * implementation (most compatible, even IE6)
  152. *
  153. * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
  154. * Opera 11.6+, iOS 4.2+.
  155. *
  156. * We report that the browser does not support typed arrays if the are not subclassable
  157. * using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array`
  158. * (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support
  159. * for __proto__ and has a buggy typed array implementation.
  160. */
  161. Buffer.TYPED_ARRAY_SUPPORT = typedArraySupport()
  162. if (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== 'undefined' &&
  163. typeof console.error === 'function') {
  164. console.error(
  165. 'This browser lacks typed array (Uint8Array) support which is required by ' +
  166. '`buffer` v5.x. Use `buffer` v4.x if you require old browser support.'
  167. )
  168. }
  169. function typedArraySupport () {
  170. // Can typed array instances can be augmented?
  171. try {
  172. var arr = new Uint8Array(1)
  173. arr.__proto__ = { __proto__: Uint8Array.prototype, foo: function () { return 42 } }
  174. return arr.foo() === 42
  175. } catch (e) {
  176. return false
  177. }
  178. }
  179. Object.defineProperty(Buffer.prototype, 'parent', {
  180. enumerable: true,
  181. get: function () {
  182. if (!Buffer.isBuffer(this)) return undefined
  183. return this.buffer
  184. }
  185. })
  186. Object.defineProperty(Buffer.prototype, 'offset', {
  187. enumerable: true,
  188. get: function () {
  189. if (!Buffer.isBuffer(this)) return undefined
  190. return this.byteOffset
  191. }
  192. })
  193. function createBuffer (length) {
  194. if (length > K_MAX_LENGTH) {
  195. throw new RangeError('The value "' + length + '" is invalid for option "size"')
  196. }
  197. // Return an augmented `Uint8Array` instance
  198. var buf = new Uint8Array(length)
  199. buf.__proto__ = Buffer.prototype
  200. return buf
  201. }
  202. /**
  203. * The Buffer constructor returns instances of `Uint8Array` that have their
  204. * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
  205. * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
  206. * and the `Uint8Array` methods. Square bracket notation works as expected -- it
  207. * returns a single octet.
  208. *
  209. * The `Uint8Array` prototype remains unmodified.
  210. */
  211. function Buffer (arg, encodingOrOffset, length) {
  212. // Common case.
  213. if (typeof arg === 'number') {
  214. if (typeof encodingOrOffset === 'string') {
  215. throw new TypeError(
  216. 'The "string" argument must be of type string. Received type number'
  217. )
  218. }
  219. return allocUnsafe(arg)
  220. }
  221. return from(arg, encodingOrOffset, length)
  222. }
  223. // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97
  224. if (typeof Symbol !== 'undefined' && Symbol.species != null &&
  225. Buffer[Symbol.species] === Buffer) {
  226. Object.defineProperty(Buffer, Symbol.species, {
  227. value: null,
  228. configurable: true,
  229. enumerable: false,
  230. writable: false
  231. })
  232. }
  233. Buffer.poolSize = 8192 // not used by this implementation
  234. function from (value, encodingOrOffset, length) {
  235. if (typeof value === 'string') {
  236. return fromString(value, encodingOrOffset)
  237. }
  238. if (ArrayBuffer.isView(value)) {
  239. return fromArrayLike(value)
  240. }
  241. if (value == null) {
  242. throw TypeError(
  243. 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +
  244. 'or Array-like Object. Received type ' + (typeof value)
  245. )
  246. }
  247. if (isInstance(value, ArrayBuffer) ||
  248. (value && isInstance(value.buffer, ArrayBuffer))) {
  249. return fromArrayBuffer(value, encodingOrOffset, length)
  250. }
  251. if (typeof value === 'number') {
  252. throw new TypeError(
  253. 'The "value" argument must not be of type number. Received type number'
  254. )
  255. }
  256. var valueOf = value.valueOf && value.valueOf()
  257. if (valueOf != null && valueOf !== value) {
  258. return Buffer.from(valueOf, encodingOrOffset, length)
  259. }
  260. var b = fromObject(value)
  261. if (b) return b
  262. if (typeof Symbol !== 'undefined' && Symbol.toPrimitive != null &&
  263. typeof value[Symbol.toPrimitive] === 'function') {
  264. return Buffer.from(
  265. value[Symbol.toPrimitive]('string'), encodingOrOffset, length
  266. )
  267. }
  268. throw new TypeError(
  269. 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +
  270. 'or Array-like Object. Received type ' + (typeof value)
  271. )
  272. }
  273. /**
  274. * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
  275. * if value is a number.
  276. * Buffer.from(str[, encoding])
  277. * Buffer.from(array)
  278. * Buffer.from(buffer)
  279. * Buffer.from(arrayBuffer[, byteOffset[, length]])
  280. **/
  281. Buffer.from = function (value, encodingOrOffset, length) {
  282. return from(value, encodingOrOffset, length)
  283. }
  284. // Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug:
  285. // https://github.com/feross/buffer/pull/148
  286. Buffer.prototype.__proto__ = Uint8Array.prototype
  287. Buffer.__proto__ = Uint8Array
  288. function assertSize (size) {
  289. if (typeof size !== 'number') {
  290. throw new TypeError('"size" argument must be of type number')
  291. } else if (size < 0) {
  292. throw new RangeError('The value "' + size + '" is invalid for option "size"')
  293. }
  294. }
  295. function alloc (size, fill, encoding) {
  296. assertSize(size)
  297. if (size <= 0) {
  298. return createBuffer(size)
  299. }
  300. if (fill !== undefined) {
  301. // Only pay attention to encoding if it's a string. This
  302. // prevents accidentally sending in a number that would
  303. // be interpretted as a start offset.
  304. return typeof encoding === 'string'
  305. ? createBuffer(size).fill(fill, encoding)
  306. : createBuffer(size).fill(fill)
  307. }
  308. return createBuffer(size)
  309. }
  310. /**
  311. * Creates a new filled Buffer instance.
  312. * alloc(size[, fill[, encoding]])
  313. **/
  314. Buffer.alloc = function (size, fill, encoding) {
  315. return alloc(size, fill, encoding)
  316. }
  317. function allocUnsafe (size) {
  318. assertSize(size)
  319. return createBuffer(size < 0 ? 0 : checked(size) | 0)
  320. }
  321. /**
  322. * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
  323. * */
  324. Buffer.allocUnsafe = function (size) {
  325. return allocUnsafe(size)
  326. }
  327. /**
  328. * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
  329. */
  330. Buffer.allocUnsafeSlow = function (size) {
  331. return allocUnsafe(size)
  332. }
  333. function fromString (string, encoding) {
  334. if (typeof encoding !== 'string' || encoding === '') {
  335. encoding = 'utf8'
  336. }
  337. if (!Buffer.isEncoding(encoding)) {
  338. throw new TypeError('Unknown encoding: ' + encoding)
  339. }
  340. var length = byteLength(string, encoding) | 0
  341. var buf = createBuffer(length)
  342. var actual = buf.write(string, encoding)
  343. if (actual !== length) {
  344. // Writing a hex string, for example, that contains invalid characters will
  345. // cause everything after the first invalid character to be ignored. (e.g.
  346. // 'abxxcd' will be treated as 'ab')
  347. buf = buf.slice(0, actual)
  348. }
  349. return buf
  350. }
  351. function fromArrayLike (array) {
  352. var length = array.length < 0 ? 0 : checked(array.length) | 0
  353. var buf = createBuffer(length)
  354. for (var i = 0; i < length; i += 1) {
  355. buf[i] = array[i] & 255
  356. }
  357. return buf
  358. }
  359. function fromArrayBuffer (array, byteOffset, length) {
  360. if (byteOffset < 0 || array.byteLength < byteOffset) {
  361. throw new RangeError('"offset" is outside of buffer bounds')
  362. }
  363. if (array.byteLength < byteOffset + (length || 0)) {
  364. throw new RangeError('"length" is outside of buffer bounds')
  365. }
  366. var buf
  367. if (byteOffset === undefined && length === undefined) {
  368. buf = new Uint8Array(array)
  369. } else if (length === undefined) {
  370. buf = new Uint8Array(array, byteOffset)
  371. } else {
  372. buf = new Uint8Array(array, byteOffset, length)
  373. }
  374. // Return an augmented `Uint8Array` instance
  375. buf.__proto__ = Buffer.prototype
  376. return buf
  377. }
  378. function fromObject (obj) {
  379. if (Buffer.isBuffer(obj)) {
  380. var len = checked(obj.length) | 0
  381. var buf = createBuffer(len)
  382. if (buf.length === 0) {
  383. return buf
  384. }
  385. obj.copy(buf, 0, 0, len)
  386. return buf
  387. }
  388. if (obj.length !== undefined) {
  389. if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) {
  390. return createBuffer(0)
  391. }
  392. return fromArrayLike(obj)
  393. }
  394. if (obj.type === 'Buffer' && Array.isArray(obj.data)) {
  395. return fromArrayLike(obj.data)
  396. }
  397. }
  398. function checked (length) {
  399. // Note: cannot use `length < K_MAX_LENGTH` here because that fails when
  400. // length is NaN (which is otherwise coerced to zero.)
  401. if (length >= K_MAX_LENGTH) {
  402. throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
  403. 'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes')
  404. }
  405. return length | 0
  406. }
  407. function SlowBuffer (length) {
  408. if (+length != length) { // eslint-disable-line eqeqeq
  409. length = 0
  410. }
  411. return Buffer.alloc(+length)
  412. }
  413. Buffer.isBuffer = function isBuffer (b) {
  414. return b != null && b._isBuffer === true &&
  415. b !== Buffer.prototype // so Buffer.isBuffer(Buffer.prototype) will be false
  416. }
  417. Buffer.compare = function compare (a, b) {
  418. if (isInstance(a, Uint8Array)) a = Buffer.from(a, a.offset, a.byteLength)
  419. if (isInstance(b, Uint8Array)) b = Buffer.from(b, b.offset, b.byteLength)
  420. if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
  421. throw new TypeError(
  422. 'The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array'
  423. )
  424. }
  425. if (a === b) return 0
  426. var x = a.length
  427. var y = b.length
  428. for (var i = 0, len = Math.min(x, y); i < len; ++i) {
  429. if (a[i] !== b[i]) {
  430. x = a[i]
  431. y = b[i]
  432. break
  433. }
  434. }
  435. if (x < y) return -1
  436. if (y < x) return 1
  437. return 0
  438. }
  439. Buffer.isEncoding = function isEncoding (encoding) {
  440. switch (String(encoding).toLowerCase()) {
  441. case 'hex':
  442. case 'utf8':
  443. case 'utf-8':
  444. case 'ascii':
  445. case 'latin1':
  446. case 'binary':
  447. case 'base64':
  448. case 'ucs2':
  449. case 'ucs-2':
  450. case 'utf16le':
  451. case 'utf-16le':
  452. return true
  453. default:
  454. return false
  455. }
  456. }
  457. Buffer.concat = function concat (list, length) {
  458. if (!Array.isArray(list)) {
  459. throw new TypeError('"list" argument must be an Array of Buffers')
  460. }
  461. if (list.length === 0) {
  462. return Buffer.alloc(0)
  463. }
  464. var i
  465. if (length === undefined) {
  466. length = 0
  467. for (i = 0; i < list.length; ++i) {
  468. length += list[i].length
  469. }
  470. }
  471. var buffer = Buffer.allocUnsafe(length)
  472. var pos = 0
  473. for (i = 0; i < list.length; ++i) {
  474. var buf = list[i]
  475. if (isInstance(buf, Uint8Array)) {
  476. buf = Buffer.from(buf)
  477. }
  478. if (!Buffer.isBuffer(buf)) {
  479. throw new TypeError('"list" argument must be an Array of Buffers')
  480. }
  481. buf.copy(buffer, pos)
  482. pos += buf.length
  483. }
  484. return buffer
  485. }
  486. function byteLength (string, encoding) {
  487. if (Buffer.isBuffer(string)) {
  488. return string.length
  489. }
  490. if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) {
  491. return string.byteLength
  492. }
  493. if (typeof string !== 'string') {
  494. throw new TypeError(
  495. 'The "string" argument must be one of type string, Buffer, or ArrayBuffer. ' +
  496. 'Received type ' + typeof string
  497. )
  498. }
  499. var len = string.length
  500. var mustMatch = (arguments.length > 2 && arguments[2] === true)
  501. if (!mustMatch && len === 0) return 0
  502. // Use a for loop to avoid recursion
  503. var loweredCase = false
  504. for (;;) {
  505. switch (encoding) {
  506. case 'ascii':
  507. case 'latin1':
  508. case 'binary':
  509. return len
  510. case 'utf8':
  511. case 'utf-8':
  512. return utf8ToBytes(string).length
  513. case 'ucs2':
  514. case 'ucs-2':
  515. case 'utf16le':
  516. case 'utf-16le':
  517. return len * 2
  518. case 'hex':
  519. return len >>> 1
  520. case 'base64':
  521. return base64ToBytes(string).length
  522. default:
  523. if (loweredCase) {
  524. return mustMatch ? -1 : utf8ToBytes(string).length // assume utf8
  525. }
  526. encoding = ('' + encoding).toLowerCase()
  527. loweredCase = true
  528. }
  529. }
  530. }
  531. Buffer.byteLength = byteLength
  532. function slowToString (encoding, start, end) {
  533. var loweredCase = false
  534. // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
  535. // property of a typed array.
  536. // This behaves neither like String nor Uint8Array in that we set start/end
  537. // to their upper/lower bounds if the value passed is out of range.
  538. // undefined is handled specially as per ECMA-262 6th Edition,
  539. // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
  540. if (start === undefined || start < 0) {
  541. start = 0
  542. }
  543. // Return early if start > this.length. Done here to prevent potential uint32
  544. // coercion fail below.
  545. if (start > this.length) {
  546. return ''
  547. }
  548. if (end === undefined || end > this.length) {
  549. end = this.length
  550. }
  551. if (end <= 0) {
  552. return ''
  553. }
  554. // Force coersion to uint32. This will also coerce falsey/NaN values to 0.
  555. end >>>= 0
  556. start >>>= 0
  557. if (end <= start) {
  558. return ''
  559. }
  560. if (!encoding) encoding = 'utf8'
  561. while (true) {
  562. switch (encoding) {
  563. case 'hex':
  564. return hexSlice(this, start, end)
  565. case 'utf8':
  566. case 'utf-8':
  567. return utf8Slice(this, start, end)
  568. case 'ascii':
  569. return asciiSlice(this, start, end)
  570. case 'latin1':
  571. case 'binary':
  572. return latin1Slice(this, start, end)
  573. case 'base64':
  574. return base64Slice(this, start, end)
  575. case 'ucs2':
  576. case 'ucs-2':
  577. case 'utf16le':
  578. case 'utf-16le':
  579. return utf16leSlice(this, start, end)
  580. default:
  581. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  582. encoding = (encoding + '').toLowerCase()
  583. loweredCase = true
  584. }
  585. }
  586. }
  587. // This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package)
  588. // to detect a Buffer instance. It's not possible to use `instanceof Buffer`
  589. // reliably in a browserify context because there could be multiple different
  590. // copies of the 'buffer' package in use. This method works even for Buffer
  591. // instances that were created from another copy of the `buffer` package.
  592. // See: https://github.com/feross/buffer/issues/154
  593. Buffer.prototype._isBuffer = true
  594. function swap (b, n, m) {
  595. var i = b[n]
  596. b[n] = b[m]
  597. b[m] = i
  598. }
  599. Buffer.prototype.swap16 = function swap16 () {
  600. var len = this.length
  601. if (len % 2 !== 0) {
  602. throw new RangeError('Buffer size must be a multiple of 16-bits')
  603. }
  604. for (var i = 0; i < len; i += 2) {
  605. swap(this, i, i + 1)
  606. }
  607. return this
  608. }
  609. Buffer.prototype.swap32 = function swap32 () {
  610. var len = this.length
  611. if (len % 4 !== 0) {
  612. throw new RangeError('Buffer size must be a multiple of 32-bits')
  613. }
  614. for (var i = 0; i < len; i += 4) {
  615. swap(this, i, i + 3)
  616. swap(this, i + 1, i + 2)
  617. }
  618. return this
  619. }
  620. Buffer.prototype.swap64 = function swap64 () {
  621. var len = this.length
  622. if (len % 8 !== 0) {
  623. throw new RangeError('Buffer size must be a multiple of 64-bits')
  624. }
  625. for (var i = 0; i < len; i += 8) {
  626. swap(this, i, i + 7)
  627. swap(this, i + 1, i + 6)
  628. swap(this, i + 2, i + 5)
  629. swap(this, i + 3, i + 4)
  630. }
  631. return this
  632. }
  633. Buffer.prototype.toString = function toString () {
  634. var length = this.length
  635. if (length === 0) return ''
  636. if (arguments.length === 0) return utf8Slice(this, 0, length)
  637. return slowToString.apply(this, arguments)
  638. }
  639. Buffer.prototype.toLocaleString = Buffer.prototype.toString
  640. Buffer.prototype.equals = function equals (b) {
  641. if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
  642. if (this === b) return true
  643. return Buffer.compare(this, b) === 0
  644. }
  645. Buffer.prototype.inspect = function inspect () {
  646. var str = ''
  647. var max = exports.INSPECT_MAX_BYTES
  648. str = this.toString('hex', 0, max).replace(/(.{2})/g, '$1 ').trim()
  649. if (this.length > max) str += ' ... '
  650. return '<Buffer ' + str + '>'
  651. }
  652. Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
  653. if (isInstance(target, Uint8Array)) {
  654. target = Buffer.from(target, target.offset, target.byteLength)
  655. }
  656. if (!Buffer.isBuffer(target)) {
  657. throw new TypeError(
  658. 'The "target" argument must be one of type Buffer or Uint8Array. ' +
  659. 'Received type ' + (typeof target)
  660. )
  661. }
  662. if (start === undefined) {
  663. start = 0
  664. }
  665. if (end === undefined) {
  666. end = target ? target.length : 0
  667. }
  668. if (thisStart === undefined) {
  669. thisStart = 0
  670. }
  671. if (thisEnd === undefined) {
  672. thisEnd = this.length
  673. }
  674. if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
  675. throw new RangeError('out of range index')
  676. }
  677. if (thisStart >= thisEnd && start >= end) {
  678. return 0
  679. }
  680. if (thisStart >= thisEnd) {
  681. return -1
  682. }
  683. if (start >= end) {
  684. return 1
  685. }
  686. start >>>= 0
  687. end >>>= 0
  688. thisStart >>>= 0
  689. thisEnd >>>= 0
  690. if (this === target) return 0
  691. var x = thisEnd - thisStart
  692. var y = end - start
  693. var len = Math.min(x, y)
  694. var thisCopy = this.slice(thisStart, thisEnd)
  695. var targetCopy = target.slice(start, end)
  696. for (var i = 0; i < len; ++i) {
  697. if (thisCopy[i] !== targetCopy[i]) {
  698. x = thisCopy[i]
  699. y = targetCopy[i]
  700. break
  701. }
  702. }
  703. if (x < y) return -1
  704. if (y < x) return 1
  705. return 0
  706. }
  707. // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
  708. // OR the last index of `val` in `buffer` at offset <= `byteOffset`.
  709. //
  710. // Arguments:
  711. // - buffer - a Buffer to search
  712. // - val - a string, Buffer, or number
  713. // - byteOffset - an index into `buffer`; will be clamped to an int32
  714. // - encoding - an optional encoding, relevant is val is a string
  715. // - dir - true for indexOf, false for lastIndexOf
  716. function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
  717. // Empty buffer means no match
  718. if (buffer.length === 0) return -1
  719. // Normalize byteOffset
  720. if (typeof byteOffset === 'string') {
  721. encoding = byteOffset
  722. byteOffset = 0
  723. } else if (byteOffset > 0x7fffffff) {
  724. byteOffset = 0x7fffffff
  725. } else if (byteOffset < -0x80000000) {
  726. byteOffset = -0x80000000
  727. }
  728. byteOffset = +byteOffset // Coerce to Number.
  729. if (numberIsNaN(byteOffset)) {
  730. // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
  731. byteOffset = dir ? 0 : (buffer.length - 1)
  732. }
  733. // Normalize byteOffset: negative offsets start from the end of the buffer
  734. if (byteOffset < 0) byteOffset = buffer.length + byteOffset
  735. if (byteOffset >= buffer.length) {
  736. if (dir) return -1
  737. else byteOffset = buffer.length - 1
  738. } else if (byteOffset < 0) {
  739. if (dir) byteOffset = 0
  740. else return -1
  741. }
  742. // Normalize val
  743. if (typeof val === 'string') {
  744. val = Buffer.from(val, encoding)
  745. }
  746. // Finally, search either indexOf (if dir is true) or lastIndexOf
  747. if (Buffer.isBuffer(val)) {
  748. // Special case: looking for empty string/buffer always fails
  749. if (val.length === 0) {
  750. return -1
  751. }
  752. return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
  753. } else if (typeof val === 'number') {
  754. val = val & 0xFF // Search for a byte value [0-255]
  755. if (typeof Uint8Array.prototype.indexOf === 'function') {
  756. if (dir) {
  757. return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
  758. } else {
  759. return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
  760. }
  761. }
  762. return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)
  763. }
  764. throw new TypeError('val must be string, number or Buffer')
  765. }
  766. function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
  767. var indexSize = 1
  768. var arrLength = arr.length
  769. var valLength = val.length
  770. if (encoding !== undefined) {
  771. encoding = String(encoding).toLowerCase()
  772. if (encoding === 'ucs2' || encoding === 'ucs-2' ||
  773. encoding === 'utf16le' || encoding === 'utf-16le') {
  774. if (arr.length < 2 || val.length < 2) {
  775. return -1
  776. }
  777. indexSize = 2
  778. arrLength /= 2
  779. valLength /= 2
  780. byteOffset /= 2
  781. }
  782. }
  783. function read (buf, i) {
  784. if (indexSize === 1) {
  785. return buf[i]
  786. } else {
  787. return buf.readUInt16BE(i * indexSize)
  788. }
  789. }
  790. var i
  791. if (dir) {
  792. var foundIndex = -1
  793. for (i = byteOffset; i < arrLength; i++) {
  794. if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
  795. if (foundIndex === -1) foundIndex = i
  796. if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
  797. } else {
  798. if (foundIndex !== -1) i -= i - foundIndex
  799. foundIndex = -1
  800. }
  801. }
  802. } else {
  803. if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength
  804. for (i = byteOffset; i >= 0; i--) {
  805. var found = true
  806. for (var j = 0; j < valLength; j++) {
  807. if (read(arr, i + j) !== read(val, j)) {
  808. found = false
  809. break
  810. }
  811. }
  812. if (found) return i
  813. }
  814. }
  815. return -1
  816. }
  817. Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
  818. return this.indexOf(val, byteOffset, encoding) !== -1
  819. }
  820. Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
  821. return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
  822. }
  823. Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
  824. return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
  825. }
  826. function hexWrite (buf, string, offset, length) {
  827. offset = Number(offset) || 0
  828. var remaining = buf.length - offset
  829. if (!length) {
  830. length = remaining
  831. } else {
  832. length = Number(length)
  833. if (length > remaining) {
  834. length = remaining
  835. }
  836. }
  837. var strLen = string.length
  838. if (length > strLen / 2) {
  839. length = strLen / 2
  840. }
  841. for (var i = 0; i < length; ++i) {
  842. var parsed = parseInt(string.substr(i * 2, 2), 16)
  843. if (numberIsNaN(parsed)) return i
  844. buf[offset + i] = parsed
  845. }
  846. return i
  847. }
  848. function utf8Write (buf, string, offset, length) {
  849. return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
  850. }
  851. function asciiWrite (buf, string, offset, length) {
  852. return blitBuffer(asciiToBytes(string), buf, offset, length)
  853. }
  854. function latin1Write (buf, string, offset, length) {
  855. return asciiWrite(buf, string, offset, length)
  856. }
  857. function base64Write (buf, string, offset, length) {
  858. return blitBuffer(base64ToBytes(string), buf, offset, length)
  859. }
  860. function ucs2Write (buf, string, offset, length) {
  861. return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
  862. }
  863. Buffer.prototype.write = function write (string, offset, length, encoding) {
  864. // Buffer#write(string)
  865. if (offset === undefined) {
  866. encoding = 'utf8'
  867. length = this.length
  868. offset = 0
  869. // Buffer#write(string, encoding)
  870. } else if (length === undefined && typeof offset === 'string') {
  871. encoding = offset
  872. length = this.length
  873. offset = 0
  874. // Buffer#write(string, offset[, length][, encoding])
  875. } else if (isFinite(offset)) {
  876. offset = offset >>> 0
  877. if (isFinite(length)) {
  878. length = length >>> 0
  879. if (encoding === undefined) encoding = 'utf8'
  880. } else {
  881. encoding = length
  882. length = undefined
  883. }
  884. } else {
  885. throw new Error(
  886. 'Buffer.write(string, encoding, offset[, length]) is no longer supported'
  887. )
  888. }
  889. var remaining = this.length - offset
  890. if (length === undefined || length > remaining) length = remaining
  891. if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
  892. throw new RangeError('Attempt to write outside buffer bounds')
  893. }
  894. if (!encoding) encoding = 'utf8'
  895. var loweredCase = false
  896. for (;;) {
  897. switch (encoding) {
  898. case 'hex':
  899. return hexWrite(this, string, offset, length)
  900. case 'utf8':
  901. case 'utf-8':
  902. return utf8Write(this, string, offset, length)
  903. case 'ascii':
  904. return asciiWrite(this, string, offset, length)
  905. case 'latin1':
  906. case 'binary':
  907. return latin1Write(this, string, offset, length)
  908. case 'base64':
  909. // Warning: maxLength not taken into account in base64Write
  910. return base64Write(this, string, offset, length)
  911. case 'ucs2':
  912. case 'ucs-2':
  913. case 'utf16le':
  914. case 'utf-16le':
  915. return ucs2Write(this, string, offset, length)
  916. default:
  917. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  918. encoding = ('' + encoding).toLowerCase()
  919. loweredCase = true
  920. }
  921. }
  922. }
  923. Buffer.prototype.toJSON = function toJSON () {
  924. return {
  925. type: 'Buffer',
  926. data: Array.prototype.slice.call(this._arr || this, 0)
  927. }
  928. }
  929. function base64Slice (buf, start, end) {
  930. if (start === 0 && end === buf.length) {
  931. return base64.fromByteArray(buf)
  932. } else {
  933. return base64.fromByteArray(buf.slice(start, end))
  934. }
  935. }
  936. function utf8Slice (buf, start, end) {
  937. end = Math.min(buf.length, end)
  938. var res = []
  939. var i = start
  940. while (i < end) {
  941. var firstByte = buf[i]
  942. var codePoint = null
  943. var bytesPerSequence = (firstByte > 0xEF) ? 4
  944. : (firstByte > 0xDF) ? 3
  945. : (firstByte > 0xBF) ? 2
  946. : 1
  947. if (i + bytesPerSequence <= end) {
  948. var secondByte, thirdByte, fourthByte, tempCodePoint
  949. switch (bytesPerSequence) {
  950. case 1:
  951. if (firstByte < 0x80) {
  952. codePoint = firstByte
  953. }
  954. break
  955. case 2:
  956. secondByte = buf[i + 1]
  957. if ((secondByte & 0xC0) === 0x80) {
  958. tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
  959. if (tempCodePoint > 0x7F) {
  960. codePoint = tempCodePoint
  961. }
  962. }
  963. break
  964. case 3:
  965. secondByte = buf[i + 1]
  966. thirdByte = buf[i + 2]
  967. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
  968. tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
  969. if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
  970. codePoint = tempCodePoint
  971. }
  972. }
  973. break
  974. case 4:
  975. secondByte = buf[i + 1]
  976. thirdByte = buf[i + 2]
  977. fourthByte = buf[i + 3]
  978. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
  979. tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
  980. if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
  981. codePoint = tempCodePoint
  982. }
  983. }
  984. }
  985. }
  986. if (codePoint === null) {
  987. // we did not generate a valid codePoint so insert a
  988. // replacement char (U+FFFD) and advance only 1 byte
  989. codePoint = 0xFFFD
  990. bytesPerSequence = 1
  991. } else if (codePoint > 0xFFFF) {
  992. // encode to utf16 (surrogate pair dance)
  993. codePoint -= 0x10000
  994. res.push(codePoint >>> 10 & 0x3FF | 0xD800)
  995. codePoint = 0xDC00 | codePoint & 0x3FF
  996. }
  997. res.push(codePoint)
  998. i += bytesPerSequence
  999. }
  1000. return decodeCodePointsArray(res)
  1001. }
  1002. // Based on http://stackoverflow.com/a/22747272/680742, the browser with
  1003. // the lowest limit is Chrome, with 0x10000 args.
  1004. // We go 1 magnitude less, for safety
  1005. var MAX_ARGUMENTS_LENGTH = 0x1000
  1006. function decodeCodePointsArray (codePoints) {
  1007. var len = codePoints.length
  1008. if (len <= MAX_ARGUMENTS_LENGTH) {
  1009. return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
  1010. }
  1011. // Decode in chunks to avoid "call stack size exceeded".
  1012. var res = ''
  1013. var i = 0
  1014. while (i < len) {
  1015. res += String.fromCharCode.apply(
  1016. String,
  1017. codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
  1018. )
  1019. }
  1020. return res
  1021. }
  1022. function asciiSlice (buf, start, end) {
  1023. var ret = ''
  1024. end = Math.min(buf.length, end)
  1025. for (var i = start; i < end; ++i) {
  1026. ret += String.fromCharCode(buf[i] & 0x7F)
  1027. }
  1028. return ret
  1029. }
  1030. function latin1Slice (buf, start, end) {
  1031. var ret = ''
  1032. end = Math.min(buf.length, end)
  1033. for (var i = start; i < end; ++i) {
  1034. ret += String.fromCharCode(buf[i])
  1035. }
  1036. return ret
  1037. }
  1038. function hexSlice (buf, start, end) {
  1039. var len = buf.length
  1040. if (!start || start < 0) start = 0
  1041. if (!end || end < 0 || end > len) end = len
  1042. var out = ''
  1043. for (var i = start; i < end; ++i) {
  1044. out += toHex(buf[i])
  1045. }
  1046. return out
  1047. }
  1048. function utf16leSlice (buf, start, end) {
  1049. var bytes = buf.slice(start, end)
  1050. var res = ''
  1051. for (var i = 0; i < bytes.length; i += 2) {
  1052. res += String.fromCharCode(bytes[i] + (bytes[i + 1] * 256))
  1053. }
  1054. return res
  1055. }
  1056. Buffer.prototype.slice = function slice (start, end) {
  1057. var len = this.length
  1058. start = ~~start
  1059. end = end === undefined ? len : ~~end
  1060. if (start < 0) {
  1061. start += len
  1062. if (start < 0) start = 0
  1063. } else if (start > len) {
  1064. start = len
  1065. }
  1066. if (end < 0) {
  1067. end += len
  1068. if (end < 0) end = 0
  1069. } else if (end > len) {
  1070. end = len
  1071. }
  1072. if (end < start) end = start
  1073. var newBuf = this.subarray(start, end)
  1074. // Return an augmented `Uint8Array` instance
  1075. newBuf.__proto__ = Buffer.prototype
  1076. return newBuf
  1077. }
  1078. /*
  1079. * Need to make sure that buffer isn't trying to write out of bounds.
  1080. */
  1081. function checkOffset (offset, ext, length) {
  1082. if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
  1083. if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
  1084. }
  1085. Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
  1086. offset = offset >>> 0
  1087. byteLength = byteLength >>> 0
  1088. if (!noAssert) checkOffset(offset, byteLength, this.length)
  1089. var val = this[offset]
  1090. var mul = 1
  1091. var i = 0
  1092. while (++i < byteLength && (mul *= 0x100)) {
  1093. val += this[offset + i] * mul
  1094. }
  1095. return val
  1096. }
  1097. Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
  1098. offset = offset >>> 0
  1099. byteLength = byteLength >>> 0
  1100. if (!noAssert) {
  1101. checkOffset(offset, byteLength, this.length)
  1102. }
  1103. var val = this[offset + --byteLength]
  1104. var mul = 1
  1105. while (byteLength > 0 && (mul *= 0x100)) {
  1106. val += this[offset + --byteLength] * mul
  1107. }
  1108. return val
  1109. }
  1110. Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
  1111. offset = offset >>> 0
  1112. if (!noAssert) checkOffset(offset, 1, this.length)
  1113. return this[offset]
  1114. }
  1115. Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
  1116. offset = offset >>> 0
  1117. if (!noAssert) checkOffset(offset, 2, this.length)
  1118. return this[offset] | (this[offset + 1] << 8)
  1119. }
  1120. Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
  1121. offset = offset >>> 0
  1122. if (!noAssert) checkOffset(offset, 2, this.length)
  1123. return (this[offset] << 8) | this[offset + 1]
  1124. }
  1125. Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
  1126. offset = offset >>> 0
  1127. if (!noAssert) checkOffset(offset, 4, this.length)
  1128. return ((this[offset]) |
  1129. (this[offset + 1] << 8) |
  1130. (this[offset + 2] << 16)) +
  1131. (this[offset + 3] * 0x1000000)
  1132. }
  1133. Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
  1134. offset = offset >>> 0
  1135. if (!noAssert) checkOffset(offset, 4, this.length)
  1136. return (this[offset] * 0x1000000) +
  1137. ((this[offset + 1] << 16) |
  1138. (this[offset + 2] << 8) |
  1139. this[offset + 3])
  1140. }
  1141. Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
  1142. offset = offset >>> 0
  1143. byteLength = byteLength >>> 0
  1144. if (!noAssert) checkOffset(offset, byteLength, this.length)
  1145. var val = this[offset]
  1146. var mul = 1
  1147. var i = 0
  1148. while (++i < byteLength && (mul *= 0x100)) {
  1149. val += this[offset + i] * mul
  1150. }
  1151. mul *= 0x80
  1152. if (val >= mul) val -= Math.pow(2, 8 * byteLength)
  1153. return val
  1154. }
  1155. Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
  1156. offset = offset >>> 0
  1157. byteLength = byteLength >>> 0
  1158. if (!noAssert) checkOffset(offset, byteLength, this.length)
  1159. var i = byteLength
  1160. var mul = 1
  1161. var val = this[offset + --i]
  1162. while (i > 0 && (mul *= 0x100)) {
  1163. val += this[offset + --i] * mul
  1164. }
  1165. mul *= 0x80
  1166. if (val >= mul) val -= Math.pow(2, 8 * byteLength)
  1167. return val
  1168. }
  1169. Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
  1170. offset = offset >>> 0
  1171. if (!noAssert) checkOffset(offset, 1, this.length)
  1172. if (!(this[offset] & 0x80)) return (this[offset])
  1173. return ((0xff - this[offset] + 1) * -1)
  1174. }
  1175. Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
  1176. offset = offset >>> 0
  1177. if (!noAssert) checkOffset(offset, 2, this.length)
  1178. var val = this[offset] | (this[offset + 1] << 8)
  1179. return (val & 0x8000) ? val | 0xFFFF0000 : val
  1180. }
  1181. Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
  1182. offset = offset >>> 0
  1183. if (!noAssert) checkOffset(offset, 2, this.length)
  1184. var val = this[offset + 1] | (this[offset] << 8)
  1185. return (val & 0x8000) ? val | 0xFFFF0000 : val
  1186. }
  1187. Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
  1188. offset = offset >>> 0
  1189. if (!noAssert) checkOffset(offset, 4, this.length)
  1190. return (this[offset]) |
  1191. (this[offset + 1] << 8) |
  1192. (this[offset + 2] << 16) |
  1193. (this[offset + 3] << 24)
  1194. }
  1195. Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
  1196. offset = offset >>> 0
  1197. if (!noAssert) checkOffset(offset, 4, this.length)
  1198. return (this[offset] << 24) |
  1199. (this[offset + 1] << 16) |
  1200. (this[offset + 2] << 8) |
  1201. (this[offset + 3])
  1202. }
  1203. Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
  1204. offset = offset >>> 0
  1205. if (!noAssert) checkOffset(offset, 4, this.length)
  1206. return ieee754.read(this, offset, true, 23, 4)
  1207. }
  1208. Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
  1209. offset = offset >>> 0
  1210. if (!noAssert) checkOffset(offset, 4, this.length)
  1211. return ieee754.read(this, offset, false, 23, 4)
  1212. }
  1213. Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
  1214. offset = offset >>> 0
  1215. if (!noAssert) checkOffset(offset, 8, this.length)
  1216. return ieee754.read(this, offset, true, 52, 8)
  1217. }
  1218. Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
  1219. offset = offset >>> 0
  1220. if (!noAssert) checkOffset(offset, 8, this.length)
  1221. return ieee754.read(this, offset, false, 52, 8)
  1222. }
  1223. function checkInt (buf, value, offset, ext, max, min) {
  1224. if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
  1225. if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
  1226. if (offset + ext > buf.length) throw new RangeError('Index out of range')
  1227. }
  1228. Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
  1229. value = +value
  1230. offset = offset >>> 0
  1231. byteLength = byteLength >>> 0
  1232. if (!noAssert) {
  1233. var maxBytes = Math.pow(2, 8 * byteLength) - 1
  1234. checkInt(this, value, offset, byteLength, maxBytes, 0)
  1235. }
  1236. var mul = 1
  1237. var i = 0
  1238. this[offset] = value & 0xFF
  1239. while (++i < byteLength && (mul *= 0x100)) {
  1240. this[offset + i] = (value / mul) & 0xFF
  1241. }
  1242. return offset + byteLength
  1243. }
  1244. Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
  1245. value = +value
  1246. offset = offset >>> 0
  1247. byteLength = byteLength >>> 0
  1248. if (!noAssert) {
  1249. var maxBytes = Math.pow(2, 8 * byteLength) - 1
  1250. checkInt(this, value, offset, byteLength, maxBytes, 0)
  1251. }
  1252. var i = byteLength - 1
  1253. var mul = 1
  1254. this[offset + i] = value & 0xFF
  1255. while (--i >= 0 && (mul *= 0x100)) {
  1256. this[offset + i] = (value / mul) & 0xFF
  1257. }
  1258. return offset + byteLength
  1259. }
  1260. Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
  1261. value = +value
  1262. offset = offset >>> 0
  1263. if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
  1264. this[offset] = (value & 0xff)
  1265. return offset + 1
  1266. }
  1267. Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
  1268. value = +value
  1269. offset = offset >>> 0
  1270. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
  1271. this[offset] = (value & 0xff)
  1272. this[offset + 1] = (value >>> 8)
  1273. return offset + 2
  1274. }
  1275. Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
  1276. value = +value
  1277. offset = offset >>> 0
  1278. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
  1279. this[offset] = (value >>> 8)
  1280. this[offset + 1] = (value & 0xff)
  1281. return offset + 2
  1282. }
  1283. Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
  1284. value = +value
  1285. offset = offset >>> 0
  1286. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
  1287. this[offset + 3] = (value >>> 24)
  1288. this[offset + 2] = (value >>> 16)
  1289. this[offset + 1] = (value >>> 8)
  1290. this[offset] = (value & 0xff)
  1291. return offset + 4
  1292. }
  1293. Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
  1294. value = +value
  1295. offset = offset >>> 0
  1296. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
  1297. this[offset] = (value >>> 24)
  1298. this[offset + 1] = (value >>> 16)
  1299. this[offset + 2] = (value >>> 8)
  1300. this[offset + 3] = (value & 0xff)
  1301. return offset + 4
  1302. }
  1303. Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
  1304. value = +value
  1305. offset = offset >>> 0
  1306. if (!noAssert) {
  1307. var limit = Math.pow(2, (8 * byteLength) - 1)
  1308. checkInt(this, value, offset, byteLength, limit - 1, -limit)
  1309. }
  1310. var i = 0
  1311. var mul = 1
  1312. var sub = 0
  1313. this[offset] = value & 0xFF
  1314. while (++i < byteLength && (mul *= 0x100)) {
  1315. if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
  1316. sub = 1
  1317. }
  1318. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
  1319. }
  1320. return offset + byteLength
  1321. }
  1322. Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
  1323. value = +value
  1324. offset = offset >>> 0
  1325. if (!noAssert) {
  1326. var limit = Math.pow(2, (8 * byteLength) - 1)
  1327. checkInt(this, value, offset, byteLength, limit - 1, -limit)
  1328. }
  1329. var i = byteLength - 1
  1330. var mul = 1
  1331. var sub = 0
  1332. this[offset + i] = value & 0xFF
  1333. while (--i >= 0 && (mul *= 0x100)) {
  1334. if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
  1335. sub = 1
  1336. }
  1337. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
  1338. }
  1339. return offset + byteLength
  1340. }
  1341. Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
  1342. value = +value
  1343. offset = offset >>> 0
  1344. if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
  1345. if (value < 0) value = 0xff + value + 1
  1346. this[offset] = (value & 0xff)
  1347. return offset + 1
  1348. }
  1349. Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
  1350. value = +value
  1351. offset = offset >>> 0
  1352. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
  1353. this[offset] = (value & 0xff)
  1354. this[offset + 1] = (value >>> 8)
  1355. return offset + 2
  1356. }
  1357. Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
  1358. value = +value
  1359. offset = offset >>> 0
  1360. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
  1361. this[offset] = (value >>> 8)
  1362. this[offset + 1] = (value & 0xff)
  1363. return offset + 2
  1364. }
  1365. Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
  1366. value = +value
  1367. offset = offset >>> 0
  1368. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
  1369. this[offset] = (value & 0xff)
  1370. this[offset + 1] = (value >>> 8)
  1371. this[offset + 2] = (value >>> 16)
  1372. this[offset + 3] = (value >>> 24)
  1373. return offset + 4
  1374. }
  1375. Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
  1376. value = +value
  1377. offset = offset >>> 0
  1378. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
  1379. if (value < 0) value = 0xffffffff + value + 1
  1380. this[offset] = (value >>> 24)
  1381. this[offset + 1] = (value >>> 16)
  1382. this[offset + 2] = (value >>> 8)
  1383. this[offset + 3] = (value & 0xff)
  1384. return offset + 4
  1385. }
  1386. function checkIEEE754 (buf, value, offset, ext, max, min) {
  1387. if (offset + ext > buf.length) throw new RangeError('Index out of range')
  1388. if (offset < 0) throw new RangeError('Index out of range')
  1389. }
  1390. function writeFloat (buf, value, offset, littleEndian, noAssert) {
  1391. value = +value
  1392. offset = offset >>> 0
  1393. if (!noAssert) {
  1394. checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
  1395. }
  1396. ieee754.write(buf, value, offset, littleEndian, 23, 4)
  1397. return offset + 4
  1398. }
  1399. Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
  1400. return writeFloat(this, value, offset, true, noAssert)
  1401. }
  1402. Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
  1403. return writeFloat(this, value, offset, false, noAssert)
  1404. }
  1405. function writeDouble (buf, value, offset, littleEndian, noAssert) {
  1406. value = +value
  1407. offset = offset >>> 0
  1408. if (!noAssert) {
  1409. checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
  1410. }
  1411. ieee754.write(buf, value, offset, littleEndian, 52, 8)
  1412. return offset + 8
  1413. }
  1414. Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
  1415. return writeDouble(this, value, offset, true, noAssert)
  1416. }
  1417. Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
  1418. return writeDouble(this, value, offset, false, noAssert)
  1419. }
  1420. // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
  1421. Buffer.prototype.copy = function copy (target, targetStart, start, end) {
  1422. if (!Buffer.isBuffer(target)) throw new TypeError('argument should be a Buffer')
  1423. if (!start) start = 0
  1424. if (!end && end !== 0) end = this.length
  1425. if (targetStart >= target.length) targetStart = target.length
  1426. if (!targetStart) targetStart = 0
  1427. if (end > 0 && end < start) end = start
  1428. // Copy 0 bytes; we're done
  1429. if (end === start) return 0
  1430. if (target.length === 0 || this.length === 0) return 0
  1431. // Fatal error conditions
  1432. if (targetStart < 0) {
  1433. throw new RangeError('targetStart out of bounds')
  1434. }
  1435. if (start < 0 || start >= this.length) throw new RangeError('Index out of range')
  1436. if (end < 0) throw new RangeError('sourceEnd out of bounds')
  1437. // Are we oob?
  1438. if (end > this.length) end = this.length
  1439. if (target.length - targetStart < end - start) {
  1440. end = target.length - targetStart + start
  1441. }
  1442. var len = end - start
  1443. if (this === target && typeof Uint8Array.prototype.copyWithin === 'function') {
  1444. // Use built-in when available, missing from IE11
  1445. this.copyWithin(targetStart, start, end)
  1446. } else if (this === target && start < targetStart && targetStart < end) {
  1447. // descending copy from end
  1448. for (var i = len - 1; i >= 0; --i) {
  1449. target[i + targetStart] = this[i + start]
  1450. }
  1451. } else {
  1452. Uint8Array.prototype.set.call(
  1453. target,
  1454. this.subarray(start, end),
  1455. targetStart
  1456. )
  1457. }
  1458. return len
  1459. }
  1460. // Usage:
  1461. // buffer.fill(number[, offset[, end]])
  1462. // buffer.fill(buffer[, offset[, end]])
  1463. // buffer.fill(string[, offset[, end]][, encoding])
  1464. Buffer.prototype.fill = function fill (val, start, end, encoding) {
  1465. // Handle string cases:
  1466. if (typeof val === 'string') {
  1467. if (typeof start === 'string') {
  1468. encoding = start
  1469. start = 0
  1470. end = this.length
  1471. } else if (typeof end === 'string') {
  1472. encoding = end
  1473. end = this.length
  1474. }
  1475. if (encoding !== undefined && typeof encoding !== 'string') {
  1476. throw new TypeError('encoding must be a string')
  1477. }
  1478. if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
  1479. throw new TypeError('Unknown encoding: ' + encoding)
  1480. }
  1481. if (val.length === 1) {
  1482. var code = val.charCodeAt(0)
  1483. if ((encoding === 'utf8' && code < 128) ||
  1484. encoding === 'latin1') {
  1485. // Fast path: If `val` fits into a single byte, use that numeric value.
  1486. val = code
  1487. }
  1488. }
  1489. } else if (typeof val === 'number') {
  1490. val = val & 255
  1491. }
  1492. // Invalid ranges are not set to a default, so can range check early.
  1493. if (start < 0 || this.length < start || this.length < end) {
  1494. throw new RangeError('Out of range index')
  1495. }
  1496. if (end <= start) {
  1497. return this
  1498. }
  1499. start = start >>> 0
  1500. end = end === undefined ? this.length : end >>> 0
  1501. if (!val) val = 0
  1502. var i
  1503. if (typeof val === 'number') {
  1504. for (i = start; i < end; ++i) {
  1505. this[i] = val
  1506. }
  1507. } else {
  1508. var bytes = Buffer.isBuffer(val)
  1509. ? val
  1510. : Buffer.from(val, encoding)
  1511. var len = bytes.length
  1512. if (len === 0) {
  1513. throw new TypeError('The value "' + val +
  1514. '" is invalid for argument "value"')
  1515. }
  1516. for (i = 0; i < end - start; ++i) {
  1517. this[i + start] = bytes[i % len]
  1518. }
  1519. }
  1520. return this
  1521. }
  1522. // HELPER FUNCTIONS
  1523. // ================
  1524. var INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g
  1525. function base64clean (str) {
  1526. // Node takes equal signs as end of the Base64 encoding
  1527. str = str.split('=')[0]
  1528. // Node strips out invalid characters like \n and \t from the string, base64-js does not
  1529. str = str.trim().replace(INVALID_BASE64_RE, '')
  1530. // Node converts strings with length < 2 to ''
  1531. if (str.length < 2) return ''
  1532. // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
  1533. while (str.length % 4 !== 0) {
  1534. str = str + '='
  1535. }
  1536. return str
  1537. }
  1538. function toHex (n) {
  1539. if (n < 16) return '0' + n.toString(16)
  1540. return n.toString(16)
  1541. }
  1542. function utf8ToBytes (string, units) {
  1543. units = units || Infinity
  1544. var codePoint
  1545. var length = string.length
  1546. var leadSurrogate = null
  1547. var bytes = []
  1548. for (var i = 0; i < length; ++i) {
  1549. codePoint = string.charCodeAt(i)
  1550. // is surrogate component
  1551. if (codePoint > 0xD7FF && codePoint < 0xE000) {
  1552. // last char was a lead
  1553. if (!leadSurrogate) {
  1554. // no lead yet
  1555. if (codePoint > 0xDBFF) {
  1556. // unexpected trail
  1557. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  1558. continue
  1559. } else if (i + 1 === length) {
  1560. // unpaired lead
  1561. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  1562. continue
  1563. }
  1564. // valid lead
  1565. leadSurrogate = codePoint
  1566. continue
  1567. }
  1568. // 2 leads in a row
  1569. if (codePoint < 0xDC00) {
  1570. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  1571. leadSurrogate = codePoint
  1572. continue
  1573. }
  1574. // valid surrogate pair
  1575. codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
  1576. } else if (leadSurrogate) {
  1577. // valid bmp char, but last char was a lead
  1578. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  1579. }
  1580. leadSurrogate = null
  1581. // encode utf8
  1582. if (codePoint < 0x80) {
  1583. if ((units -= 1) < 0) break
  1584. bytes.push(codePoint)
  1585. } else if (codePoint < 0x800) {
  1586. if ((units -= 2) < 0) break
  1587. bytes.push(
  1588. codePoint >> 0x6 | 0xC0,
  1589. codePoint & 0x3F | 0x80
  1590. )
  1591. } else if (codePoint < 0x10000) {
  1592. if ((units -= 3) < 0) break
  1593. bytes.push(
  1594. codePoint >> 0xC | 0xE0,
  1595. codePoint >> 0x6 & 0x3F | 0x80,
  1596. codePoint & 0x3F | 0x80
  1597. )
  1598. } else if (codePoint < 0x110000) {
  1599. if ((units -= 4) < 0) break
  1600. bytes.push(
  1601. codePoint >> 0x12 | 0xF0,
  1602. codePoint >> 0xC & 0x3F | 0x80,
  1603. codePoint >> 0x6 & 0x3F | 0x80,
  1604. codePoint & 0x3F | 0x80
  1605. )
  1606. } else {
  1607. throw new Error('Invalid code point')
  1608. }
  1609. }
  1610. return bytes
  1611. }
  1612. function asciiToBytes (str) {
  1613. var byteArray = []
  1614. for (var i = 0; i < str.length; ++i) {
  1615. // Node's code seems to be doing this and not & 0x7F..
  1616. byteArray.push(str.charCodeAt(i) & 0xFF)
  1617. }
  1618. return byteArray
  1619. }
  1620. function utf16leToBytes (str, units) {
  1621. var c, hi, lo
  1622. var byteArray = []
  1623. for (var i = 0; i < str.length; ++i) {
  1624. if ((units -= 2) < 0) break
  1625. c = str.charCodeAt(i)
  1626. hi = c >> 8
  1627. lo = c % 256
  1628. byteArray.push(lo)
  1629. byteArray.push(hi)
  1630. }
  1631. return byteArray
  1632. }
  1633. function base64ToBytes (str) {
  1634. return base64.toByteArray(base64clean(str))
  1635. }
  1636. function blitBuffer (src, dst, offset, length) {
  1637. for (var i = 0; i < length; ++i) {
  1638. if ((i + offset >= dst.length) || (i >= src.length)) break
  1639. dst[i + offset] = src[i]
  1640. }
  1641. return i
  1642. }
  1643. // ArrayBuffer or Uint8Array objects from other contexts (i.e. iframes) do not pass
  1644. // the `instanceof` check but they should be treated as of that type.
  1645. // See: https://github.com/feross/buffer/issues/166
  1646. function isInstance (obj, type) {
  1647. return obj instanceof type ||
  1648. (obj != null && obj.constructor != null && obj.constructor.name != null &&
  1649. obj.constructor.name === type.name)
  1650. }
  1651. function numberIsNaN (obj) {
  1652. // For IE11 support
  1653. return obj !== obj // eslint-disable-line no-self-compare
  1654. }
  1655. }).call(this,require("buffer").Buffer)
  1656. },{"base64-js":1,"buffer":3,"ieee754":32}],4:[function(require,module,exports){
  1657. "use strict";
  1658. Object.defineProperty(exports, "__esModule", { value: true });
  1659. exports.attributeNames = exports.elementNames = void 0;
  1660. exports.elementNames = new Map([
  1661. ["altglyph", "altGlyph"],
  1662. ["altglyphdef", "altGlyphDef"],
  1663. ["altglyphitem", "altGlyphItem"],
  1664. ["animatecolor", "animateColor"],
  1665. ["animatemotion", "animateMotion"],
  1666. ["animatetransform", "animateTransform"],
  1667. ["clippath", "clipPath"],
  1668. ["feblend", "feBlend"],
  1669. ["fecolormatrix", "feColorMatrix"],
  1670. ["fecomponenttransfer", "feComponentTransfer"],
  1671. ["fecomposite", "feComposite"],
  1672. ["feconvolvematrix", "feConvolveMatrix"],
  1673. ["fediffuselighting", "feDiffuseLighting"],
  1674. ["fedisplacementmap", "feDisplacementMap"],
  1675. ["fedistantlight", "feDistantLight"],
  1676. ["fedropshadow", "feDropShadow"],
  1677. ["feflood", "feFlood"],
  1678. ["fefunca", "feFuncA"],
  1679. ["fefuncb", "feFuncB"],
  1680. ["fefuncg", "feFuncG"],
  1681. ["fefuncr", "feFuncR"],
  1682. ["fegaussianblur", "feGaussianBlur"],
  1683. ["feimage", "feImage"],
  1684. ["femerge", "feMerge"],
  1685. ["femergenode", "feMergeNode"],
  1686. ["femorphology", "feMorphology"],
  1687. ["feoffset", "feOffset"],
  1688. ["fepointlight", "fePointLight"],
  1689. ["fespecularlighting", "feSpecularLighting"],
  1690. ["fespotlight", "feSpotLight"],
  1691. ["fetile", "feTile"],
  1692. ["feturbulence", "feTurbulence"],
  1693. ["foreignobject", "foreignObject"],
  1694. ["glyphref", "glyphRef"],
  1695. ["lineargradient", "linearGradient"],
  1696. ["radialgradient", "radialGradient"],
  1697. ["textpath", "textPath"],
  1698. ]);
  1699. exports.attributeNames = new Map([
  1700. ["definitionurl", "definitionURL"],
  1701. ["attributename", "attributeName"],
  1702. ["attributetype", "attributeType"],
  1703. ["basefrequency", "baseFrequency"],
  1704. ["baseprofile", "baseProfile"],
  1705. ["calcmode", "calcMode"],
  1706. ["clippathunits", "clipPathUnits"],
  1707. ["diffuseconstant", "diffuseConstant"],
  1708. ["edgemode", "edgeMode"],
  1709. ["filterunits", "filterUnits"],
  1710. ["glyphref", "glyphRef"],
  1711. ["gradienttransform", "gradientTransform"],
  1712. ["gradientunits", "gradientUnits"],
  1713. ["kernelmatrix", "kernelMatrix"],
  1714. ["kernelunitlength", "kernelUnitLength"],
  1715. ["keypoints", "keyPoints"],
  1716. ["keysplines", "keySplines"],
  1717. ["keytimes", "keyTimes"],
  1718. ["lengthadjust", "lengthAdjust"],
  1719. ["limitingconeangle", "limitingConeAngle"],
  1720. ["markerheight", "markerHeight"],
  1721. ["markerunits", "markerUnits"],
  1722. ["markerwidth", "markerWidth"],
  1723. ["maskcontentunits", "maskContentUnits"],
  1724. ["maskunits", "maskUnits"],
  1725. ["numoctaves", "numOctaves"],
  1726. ["pathlength", "pathLength"],
  1727. ["patterncontentunits", "patternContentUnits"],
  1728. ["patterntransform", "patternTransform"],
  1729. ["patternunits", "patternUnits"],
  1730. ["pointsatx", "pointsAtX"],
  1731. ["pointsaty", "pointsAtY"],
  1732. ["pointsatz", "pointsAtZ"],
  1733. ["preservealpha", "preserveAlpha"],
  1734. ["preserveaspectratio", "preserveAspectRatio"],
  1735. ["primitiveunits", "primitiveUnits"],
  1736. ["refx", "refX"],
  1737. ["refy", "refY"],
  1738. ["repeatcount", "repeatCount"],
  1739. ["repeatdur", "repeatDur"],
  1740. ["requiredextensions", "requiredExtensions"],
  1741. ["requiredfeatures", "requiredFeatures"],
  1742. ["specularconstant", "specularConstant"],
  1743. ["specularexponent", "specularExponent"],
  1744. ["spreadmethod", "spreadMethod"],
  1745. ["startoffset", "startOffset"],
  1746. ["stddeviation", "stdDeviation"],
  1747. ["stitchtiles", "stitchTiles"],
  1748. ["surfacescale", "surfaceScale"],
  1749. ["systemlanguage", "systemLanguage"],
  1750. ["tablevalues", "tableValues"],
  1751. ["targetx", "targetX"],
  1752. ["targety", "targetY"],
  1753. ["textlength", "textLength"],
  1754. ["viewbox", "viewBox"],
  1755. ["viewtarget", "viewTarget"],
  1756. ["xchannelselector", "xChannelSelector"],
  1757. ["ychannelselector", "yChannelSelector"],
  1758. ["zoomandpan", "zoomAndPan"],
  1759. ]);
  1760. },{}],5:[function(require,module,exports){
  1761. "use strict";
  1762. var __assign = (this && this.__assign) || function () {
  1763. __assign = Object.assign || function(t) {
  1764. for (var s, i = 1, n = arguments.length; i < n; i++) {
  1765. s = arguments[i];
  1766. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
  1767. t[p] = s[p];
  1768. }
  1769. return t;
  1770. };
  1771. return __assign.apply(this, arguments);
  1772. };
  1773. var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
  1774. if (k2 === undefined) k2 = k;
  1775. Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
  1776. }) : (function(o, m, k, k2) {
  1777. if (k2 === undefined) k2 = k;
  1778. o[k2] = m[k];
  1779. }));
  1780. var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
  1781. Object.defineProperty(o, "default", { enumerable: true, value: v });
  1782. }) : function(o, v) {
  1783. o["default"] = v;
  1784. });
  1785. var __importStar = (this && this.__importStar) || function (mod) {
  1786. if (mod && mod.__esModule) return mod;
  1787. var result = {};
  1788. if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
  1789. __setModuleDefault(result, mod);
  1790. return result;
  1791. };
  1792. Object.defineProperty(exports, "__esModule", { value: true });
  1793. /*
  1794. * Module dependencies
  1795. */
  1796. var ElementType = __importStar(require("domelementtype"));
  1797. var entities_1 = require("entities");
  1798. /*
  1799. * Mixed-case SVG and MathML tags & attributes
  1800. * recognized by the HTML parser, see
  1801. * https://html.spec.whatwg.org/multipage/parsing.html#parsing-main-inforeign
  1802. */
  1803. var foreignNames_1 = require("./foreignNames");
  1804. var unencodedElements = new Set([
  1805. "style",
  1806. "script",
  1807. "xmp",
  1808. "iframe",
  1809. "noembed",
  1810. "noframes",
  1811. "plaintext",
  1812. "noscript",
  1813. ]);
  1814. /**
  1815. * Format attributes
  1816. */
  1817. function formatAttributes(attributes, opts) {
  1818. if (!attributes)
  1819. return;
  1820. return Object.keys(attributes)
  1821. .map(function (key) {
  1822. var _a, _b;
  1823. var value = (_a = attributes[key]) !== null && _a !== void 0 ? _a : "";
  1824. if (opts.xmlMode === "foreign") {
  1825. /* Fix up mixed-case attribute names */
  1826. key = (_b = foreignNames_1.attributeNames.get(key)) !== null && _b !== void 0 ? _b : key;
  1827. }
  1828. if (!opts.emptyAttrs && !opts.xmlMode && value === "") {
  1829. return key;
  1830. }
  1831. return key + "=\"" + (opts.decodeEntities ? entities_1.encodeXML(value) : value.replace(/"/g, "&quot;")) + "\"";
  1832. })
  1833. .join(" ");
  1834. }
  1835. /**
  1836. * Self-enclosing tags
  1837. */
  1838. var singleTag = new Set([
  1839. "area",
  1840. "base",
  1841. "basefont",
  1842. "br",
  1843. "col",
  1844. "command",
  1845. "embed",
  1846. "frame",
  1847. "hr",
  1848. "img",
  1849. "input",
  1850. "isindex",
  1851. "keygen",
  1852. "link",
  1853. "meta",
  1854. "param",
  1855. "source",
  1856. "track",
  1857. "wbr",
  1858. ]);
  1859. /**
  1860. * Renders a DOM node or an array of DOM nodes to a string.
  1861. *
  1862. * Can be thought of as the equivalent of the `outerHTML` of the passed node(s).
  1863. *
  1864. * @param node Node to be rendered.
  1865. * @param options Changes serialization behavior
  1866. */
  1867. function render(node, options) {
  1868. if (options === void 0) { options = {}; }
  1869. // TODO: This is a bit hacky.
  1870. var nodes = Array.isArray(node) || node.cheerio ? node : [node];
  1871. var output = "";
  1872. for (var i = 0; i < nodes.length; i++) {
  1873. output += renderNode(nodes[i], options);
  1874. }
  1875. return output;
  1876. }
  1877. exports.default = render;
  1878. function renderNode(node, options) {
  1879. switch (node.type) {
  1880. case "root":
  1881. return render(node.children, options);
  1882. case ElementType.Directive:
  1883. return renderDirective(node);
  1884. case ElementType.Comment:
  1885. return renderComment(node);
  1886. case ElementType.CDATA:
  1887. return renderCdata(node);
  1888. default:
  1889. return ElementType.isTag(node)
  1890. ? renderTag(node, options)
  1891. : renderText(node, options);
  1892. }
  1893. }
  1894. var foreignModeIntegrationPoints = new Set([
  1895. "mi",
  1896. "mo",
  1897. "mn",
  1898. "ms",
  1899. "mtext",
  1900. "annotation-xml",
  1901. "foreignObject",
  1902. "desc",
  1903. "title",
  1904. ]);
  1905. var foreignElements = new Set(["svg", "math"]);
  1906. function renderTag(elem, opts) {
  1907. var _a;
  1908. // Handle SVG / MathML in HTML
  1909. if (opts.xmlMode === "foreign") {
  1910. /* Fix up mixed-case element names */
  1911. elem.name = (_a = foreignNames_1.elementNames.get(elem.name)) !== null && _a !== void 0 ? _a : elem.name;
  1912. /* Exit foreign mode at integration points */
  1913. if (elem.parent &&
  1914. foreignModeIntegrationPoints.has(elem.parent.name)) {
  1915. opts = __assign(__assign({}, opts), { xmlMode: false });
  1916. }
  1917. }
  1918. if (!opts.xmlMode && foreignElements.has(elem.name)) {
  1919. opts = __assign(__assign({}, opts), { xmlMode: "foreign" });
  1920. }
  1921. var tag = "<" + elem.name;
  1922. var attribs = formatAttributes(elem.attribs, opts);
  1923. if (attribs) {
  1924. tag += " " + attribs;
  1925. }
  1926. if (elem.children.length === 0 &&
  1927. (opts.xmlMode
  1928. ? // In XML mode or foreign mode, and user hasn't explicitly turned off self-closing tags
  1929. opts.selfClosingTags !== false
  1930. : // User explicitly asked for self-closing tags, even in HTML mode
  1931. opts.selfClosingTags && singleTag.has(elem.name))) {
  1932. if (!opts.xmlMode)
  1933. tag += " ";
  1934. tag += "/>";
  1935. }
  1936. else {
  1937. tag += ">";
  1938. if (elem.children.length > 0) {
  1939. tag += render(elem.children, opts);
  1940. }
  1941. if (opts.xmlMode || !singleTag.has(elem.name)) {
  1942. tag += "</" + elem.name + ">";
  1943. }
  1944. }
  1945. return tag;
  1946. }
  1947. function renderDirective(elem) {
  1948. return "<" + elem.data + ">";
  1949. }
  1950. function renderText(elem, opts) {
  1951. var data = elem.data || "";
  1952. // If entities weren't decoded, no need to encode them back
  1953. if (opts.decodeEntities &&
  1954. !(elem.parent && unencodedElements.has(elem.parent.name))) {
  1955. data = entities_1.encodeXML(data);
  1956. }
  1957. return data;
  1958. }
  1959. function renderCdata(elem) {
  1960. return "<![CDATA[" + elem.children[0].data + "]]>";
  1961. }
  1962. function renderComment(elem) {
  1963. return "<!--" + elem.data + "-->";
  1964. }
  1965. },{"./foreignNames":4,"domelementtype":6,"entities":20}],6:[function(require,module,exports){
  1966. "use strict";
  1967. Object.defineProperty(exports, "__esModule", { value: true });
  1968. exports.Doctype = exports.CDATA = exports.Tag = exports.Style = exports.Script = exports.Comment = exports.Directive = exports.Text = exports.isTag = void 0;
  1969. /**
  1970. * Tests whether an element is a tag or not.
  1971. *
  1972. * @param elem Element to test
  1973. */
  1974. function isTag(elem) {
  1975. return (elem.type === "tag" /* Tag */ ||
  1976. elem.type === "script" /* Script */ ||
  1977. elem.type === "style" /* Style */);
  1978. }
  1979. exports.isTag = isTag;
  1980. // Exports for backwards compatibility
  1981. /** Type for Text */
  1982. exports.Text = "text" /* Text */;
  1983. /** Type for <? ... ?> */
  1984. exports.Directive = "directive" /* Directive */;
  1985. /** Type for <!-- ... --> */
  1986. exports.Comment = "comment" /* Comment */;
  1987. /** Type for <script> tags */
  1988. exports.Script = "script" /* Script */;
  1989. /** Type for <style> tags */
  1990. exports.Style = "style" /* Style */;
  1991. /** Type for Any tag */
  1992. exports.Tag = "tag" /* Tag */;
  1993. /** Type for <![CDATA[ ... ]]> */
  1994. exports.CDATA = "cdata" /* CDATA */;
  1995. /** Type for <!doctype ...> */
  1996. exports.Doctype = "doctype" /* Doctype */;
  1997. },{}],7:[function(require,module,exports){
  1998. "use strict";
  1999. Object.defineProperty(exports, "__esModule", { value: true });
  2000. var node_1 = require("./node");
  2001. exports.Node = node_1.Node;
  2002. exports.Element = node_1.Element;
  2003. exports.DataNode = node_1.DataNode;
  2004. exports.NodeWithChildren = node_1.NodeWithChildren;
  2005. var reWhitespace = /\s+/g;
  2006. // Default options
  2007. var defaultOpts = {
  2008. normalizeWhitespace: false,
  2009. withStartIndices: false,
  2010. withEndIndices: false
  2011. };
  2012. var DomHandler = /** @class */ (function () {
  2013. /**
  2014. * Initiate a new DomHandler.
  2015. *
  2016. * @param callback Called once parsing has completed.
  2017. * @param options Settings for the handler.
  2018. * @param elementCB Callback whenever a tag is closed.
  2019. */
  2020. function DomHandler(callback, options, elementCB) {
  2021. /** The constructed DOM */
  2022. this.dom = [];
  2023. /** Indicated whether parsing has been completed. */
  2024. this._done = false;
  2025. /** Stack of open tags. */
  2026. this._tagStack = [];
  2027. /** A data node that is still being written to. */
  2028. this._lastNode = null;
  2029. /** Reference to the parser instance. Used for location information. */
  2030. this._parser = null;
  2031. // Make it possible to skip arguments, for backwards-compatibility
  2032. if (typeof options === "function") {
  2033. elementCB = options;
  2034. options = defaultOpts;
  2035. }
  2036. if (typeof callback === "object") {
  2037. options = callback;
  2038. callback = undefined;
  2039. }
  2040. this._callback = callback || null;
  2041. this._options = options || defaultOpts;
  2042. this._elementCB = elementCB || null;
  2043. }
  2044. DomHandler.prototype.onparserinit = function (parser) {
  2045. this._parser = parser;
  2046. };
  2047. // Resets the handler back to starting state
  2048. DomHandler.prototype.onreset = function () {
  2049. this.dom = [];
  2050. this._done = false;
  2051. this._tagStack = [];
  2052. this._lastNode = null;
  2053. this._parser = this._parser || null;
  2054. };
  2055. // Signals the handler that parsing is done
  2056. DomHandler.prototype.onend = function () {
  2057. if (this._done)
  2058. return;
  2059. this._done = true;
  2060. this._parser = null;
  2061. this.handleCallback(null);
  2062. };
  2063. DomHandler.prototype.onerror = function (error) {
  2064. this.handleCallback(error);
  2065. };
  2066. DomHandler.prototype.onclosetag = function () {
  2067. this._lastNode = null;
  2068. // If(this._tagStack.pop().name !== name) this.handleCallback(Error("Tagname didn't match!"));
  2069. var elem = this._tagStack.pop();
  2070. if (!elem || !this._parser) {
  2071. return;
  2072. }
  2073. if (this._options.withEndIndices) {
  2074. elem.endIndex = this._parser.endIndex;
  2075. }
  2076. if (this._elementCB)
  2077. this._elementCB(elem);
  2078. };
  2079. DomHandler.prototype.onopentag = function (name, attribs) {
  2080. var element = new node_1.Element(name, attribs);
  2081. this.addNode(element);
  2082. this._tagStack.push(element);
  2083. };
  2084. DomHandler.prototype.ontext = function (data) {
  2085. var normalize = this._options.normalizeWhitespace;
  2086. var _lastNode = this._lastNode;
  2087. if (_lastNode && _lastNode.type === "text" /* Text */) {
  2088. if (normalize) {
  2089. _lastNode.data = (_lastNode.data + data).replace(reWhitespace, " ");
  2090. }
  2091. else {
  2092. _lastNode.data += data;
  2093. }
  2094. }
  2095. else {
  2096. if (normalize) {
  2097. data = data.replace(reWhitespace, " ");
  2098. }
  2099. var node = new node_1.DataNode("text" /* Text */, data);
  2100. this.addNode(node);
  2101. this._lastNode = node;
  2102. }
  2103. };
  2104. DomHandler.prototype.oncomment = function (data) {
  2105. if (this._lastNode && this._lastNode.type === "comment" /* Comment */) {
  2106. this._lastNode.data += data;
  2107. return;
  2108. }
  2109. var node = new node_1.DataNode("comment" /* Comment */, data);
  2110. this.addNode(node);
  2111. this._lastNode = node;
  2112. };
  2113. DomHandler.prototype.oncommentend = function () {
  2114. this._lastNode = null;
  2115. };
  2116. DomHandler.prototype.oncdatastart = function () {
  2117. var text = new node_1.DataNode("text" /* Text */, "");
  2118. var node = new node_1.NodeWithChildren("cdata" /* CDATA */, [text]);
  2119. this.addNode(node);
  2120. text.parent = node;
  2121. this._lastNode = text;
  2122. };
  2123. DomHandler.prototype.oncdataend = function () {
  2124. this._lastNode = null;
  2125. };
  2126. DomHandler.prototype.onprocessinginstruction = function (name, data) {
  2127. var node = new node_1.ProcessingInstruction(name, data);
  2128. this.addNode(node);
  2129. };
  2130. DomHandler.prototype.handleCallback = function (error) {
  2131. if (typeof this._callback === "function") {
  2132. this._callback(error, this.dom);
  2133. }
  2134. else if (error) {
  2135. throw error;
  2136. }
  2137. };
  2138. DomHandler.prototype.addNode = function (node) {
  2139. var parent = this._tagStack[this._tagStack.length - 1];
  2140. var siblings = parent ? parent.children : this.dom;
  2141. var previousSibling = siblings[siblings.length - 1];
  2142. if (this._parser) {
  2143. if (this._options.withStartIndices) {
  2144. node.startIndex = this._parser.startIndex;
  2145. }
  2146. if (this._options.withEndIndices) {
  2147. node.endIndex = this._parser.endIndex;
  2148. }
  2149. }
  2150. siblings.push(node);
  2151. if (previousSibling) {
  2152. node.prev = previousSibling;
  2153. previousSibling.next = node;
  2154. }
  2155. if (parent) {
  2156. node.parent = parent;
  2157. }
  2158. this._lastNode = null;
  2159. };
  2160. DomHandler.prototype.addDataNode = function (node) {
  2161. this.addNode(node);
  2162. this._lastNode = node;
  2163. };
  2164. return DomHandler;
  2165. }());
  2166. exports.DomHandler = DomHandler;
  2167. exports.default = DomHandler;
  2168. },{"./node":8}],8:[function(require,module,exports){
  2169. "use strict";
  2170. var __extends = (this && this.__extends) || (function () {
  2171. var extendStatics = function (d, b) {
  2172. extendStatics = Object.setPrototypeOf ||
  2173. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  2174. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  2175. return extendStatics(d, b);
  2176. };
  2177. return function (d, b) {
  2178. extendStatics(d, b);
  2179. function __() { this.constructor = d; }
  2180. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  2181. };
  2182. })();
  2183. Object.defineProperty(exports, "__esModule", { value: true });
  2184. var nodeTypes = new Map([
  2185. ["tag" /* Tag */, 1],
  2186. ["script" /* Script */, 1],
  2187. ["style" /* Style */, 1],
  2188. ["directive" /* Directive */, 1],
  2189. ["text" /* Text */, 3],
  2190. ["cdata" /* CDATA */, 4],
  2191. ["comment" /* Comment */, 8]
  2192. ]);
  2193. // This object will be used as the prototype for Nodes when creating a
  2194. // DOM-Level-1-compliant structure.
  2195. var Node = /** @class */ (function () {
  2196. /**
  2197. *
  2198. * @param type The type of the node.
  2199. */
  2200. function Node(type) {
  2201. this.type = type;
  2202. /** Parent of the node */
  2203. this.parent = null;
  2204. /** Previous sibling */
  2205. this.prev = null;
  2206. /** Next sibling */
  2207. this.next = null;
  2208. /** The start index of the node. Requires `withStartIndices` on the handler to be `true. */
  2209. this.startIndex = null;
  2210. /** The end index of the node. Requires `withEndIndices` on the handler to be `true. */
  2211. this.endIndex = null;
  2212. }
  2213. Object.defineProperty(Node.prototype, "nodeType", {
  2214. // Read-only aliases
  2215. get: function () {
  2216. return nodeTypes.get(this.type) || 1;
  2217. },
  2218. enumerable: true,
  2219. configurable: true
  2220. });
  2221. Object.defineProperty(Node.prototype, "parentNode", {
  2222. // Read-write aliases for properties
  2223. get: function () {
  2224. return this.parent || null;
  2225. },
  2226. set: function (parent) {
  2227. this.parent = parent;
  2228. },
  2229. enumerable: true,
  2230. configurable: true
  2231. });
  2232. Object.defineProperty(Node.prototype, "previousSibling", {
  2233. get: function () {
  2234. return this.prev || null;
  2235. },
  2236. set: function (prev) {
  2237. this.prev = prev;
  2238. },
  2239. enumerable: true,
  2240. configurable: true
  2241. });
  2242. Object.defineProperty(Node.prototype, "nextSibling", {
  2243. get: function () {
  2244. return this.next || null;
  2245. },
  2246. set: function (next) {
  2247. this.next = next;
  2248. },
  2249. enumerable: true,
  2250. configurable: true
  2251. });
  2252. return Node;
  2253. }());
  2254. exports.Node = Node;
  2255. var DataNode = /** @class */ (function (_super) {
  2256. __extends(DataNode, _super);
  2257. /**
  2258. *
  2259. * @param type The type of the node
  2260. * @param data The content of the data node
  2261. */
  2262. function DataNode(type, data) {
  2263. var _this = _super.call(this, type) || this;
  2264. _this.data = data;
  2265. return _this;
  2266. }
  2267. Object.defineProperty(DataNode.prototype, "nodeValue", {
  2268. get: function () {
  2269. return this.data;
  2270. },
  2271. set: function (data) {
  2272. this.data = data;
  2273. },
  2274. enumerable: true,
  2275. configurable: true
  2276. });
  2277. return DataNode;
  2278. }(Node));
  2279. exports.DataNode = DataNode;
  2280. var ProcessingInstruction = /** @class */ (function (_super) {
  2281. __extends(ProcessingInstruction, _super);
  2282. function ProcessingInstruction(name, data) {
  2283. var _this = _super.call(this, "directive" /* Directive */, data) || this;
  2284. _this.name = name;
  2285. return _this;
  2286. }
  2287. return ProcessingInstruction;
  2288. }(DataNode));
  2289. exports.ProcessingInstruction = ProcessingInstruction;
  2290. var NodeWithChildren = /** @class */ (function (_super) {
  2291. __extends(NodeWithChildren, _super);
  2292. /**
  2293. *
  2294. * @param type Type of the node.
  2295. * @param children Children of the node. Only certain node types can have children.
  2296. */
  2297. function NodeWithChildren(type, children) {
  2298. var _this = _super.call(this, type) || this;
  2299. _this.children = children;
  2300. return _this;
  2301. }
  2302. Object.defineProperty(NodeWithChildren.prototype, "firstChild", {
  2303. // Aliases
  2304. get: function () {
  2305. return this.children[0] || null;
  2306. },
  2307. enumerable: true,
  2308. configurable: true
  2309. });
  2310. Object.defineProperty(NodeWithChildren.prototype, "lastChild", {
  2311. get: function () {
  2312. return this.children[this.children.length - 1] || null;
  2313. },
  2314. enumerable: true,
  2315. configurable: true
  2316. });
  2317. Object.defineProperty(NodeWithChildren.prototype, "childNodes", {
  2318. get: function () {
  2319. return this.children;
  2320. },
  2321. set: function (children) {
  2322. this.children = children;
  2323. },
  2324. enumerable: true,
  2325. configurable: true
  2326. });
  2327. return NodeWithChildren;
  2328. }(Node));
  2329. exports.NodeWithChildren = NodeWithChildren;
  2330. var Element = /** @class */ (function (_super) {
  2331. __extends(Element, _super);
  2332. /**
  2333. *
  2334. * @param name Name of the tag, eg. `div`, `span`
  2335. * @param attribs Object mapping attribute names to attribute values
  2336. */
  2337. function Element(name, attribs) {
  2338. var _this = _super.call(this, name === "script"
  2339. ? "script" /* Script */
  2340. : name === "style"
  2341. ? "style" /* Style */
  2342. : "tag" /* Tag */, []) || this;
  2343. _this.name = name;
  2344. _this.attribs = attribs;
  2345. _this.attribs = attribs;
  2346. return _this;
  2347. }
  2348. Object.defineProperty(Element.prototype, "tagName", {
  2349. // DOM Level 1 aliases
  2350. get: function () {
  2351. return this.name;
  2352. },
  2353. set: function (name) {
  2354. this.name = name;
  2355. },
  2356. enumerable: true,
  2357. configurable: true
  2358. });
  2359. return Element;
  2360. }(NodeWithChildren));
  2361. exports.Element = Element;
  2362. },{}],9:[function(require,module,exports){
  2363. "use strict";
  2364. Object.defineProperty(exports, "__esModule", { value: true });
  2365. exports.uniqueSort = exports.compareDocumentPosition = exports.removeSubsets = void 0;
  2366. var tagtypes_1 = require("./tagtypes");
  2367. /**
  2368. * Given an array of nodes, remove any member that is contained by another.
  2369. *
  2370. * @param nodes Nodes to filter.
  2371. */
  2372. function removeSubsets(nodes) {
  2373. var idx = nodes.length;
  2374. /*
  2375. * Check if each node (or one of its ancestors) is already contained in the
  2376. * array.
  2377. */
  2378. while (--idx >= 0) {
  2379. var node = nodes[idx];
  2380. /*
  2381. * Remove the node if it is not unique.
  2382. * We are going through the array from the end, so we only
  2383. * have to check nodes that preceed the node under consideration in the array.
  2384. */
  2385. if (idx > 0 && nodes.lastIndexOf(node, idx - 1) >= 0) {
  2386. nodes.splice(idx, 1);
  2387. continue;
  2388. }
  2389. for (var ancestor = node.parent; ancestor; ancestor = ancestor.parent) {
  2390. if (nodes.includes(ancestor)) {
  2391. nodes.splice(idx, 1);
  2392. break;
  2393. }
  2394. }
  2395. }
  2396. return nodes;
  2397. }
  2398. exports.removeSubsets = removeSubsets;
  2399. /**
  2400. * Compare the position of one node against another node in any other document.
  2401. * The return value is a bitmask with the following values:
  2402. *
  2403. * document order:
  2404. * > There is an ordering, document order, defined on all the nodes in the
  2405. * > document corresponding to the order in which the first character of the
  2406. * > XML representation of each node occurs in the XML representation of the
  2407. * > document after expansion of general entities. Thus, the document element
  2408. * > node will be the first node. Element nodes occur before their children.
  2409. * > Thus, document order orders element nodes in order of the occurrence of
  2410. * > their start-tag in the XML (after expansion of entities). The attribute
  2411. * > nodes of an element occur after the element and before its children. The
  2412. * > relative order of attribute nodes is implementation-dependent./
  2413. *
  2414. * Source:
  2415. * http://www.w3.org/TR/DOM-Level-3-Core/glossary.html#dt-document-order
  2416. * @param nodaA The first node to use in the comparison
  2417. * @param nodeB The second node to use in the comparison
  2418. *
  2419. * @return A bitmask describing the input nodes' relative position.
  2420. *
  2421. * See http://dom.spec.whatwg.org/#dom-node-comparedocumentposition for
  2422. * a description of these values.
  2423. */
  2424. function compareDocumentPosition(nodeA, nodeB) {
  2425. var aParents = [];
  2426. var bParents = [];
  2427. if (nodeA === nodeB) {
  2428. return 0;
  2429. }
  2430. var current = tagtypes_1.hasChildren(nodeA) ? nodeA : nodeA.parent;
  2431. while (current) {
  2432. aParents.unshift(current);
  2433. current = current.parent;
  2434. }
  2435. current = tagtypes_1.hasChildren(nodeB) ? nodeB : nodeB.parent;
  2436. while (current) {
  2437. bParents.unshift(current);
  2438. current = current.parent;
  2439. }
  2440. var maxIdx = Math.min(aParents.length, bParents.length);
  2441. var idx = 0;
  2442. while (idx < maxIdx && aParents[idx] === bParents[idx]) {
  2443. idx++;
  2444. }
  2445. if (idx === 0) {
  2446. return 1 /* DISCONNECTED */;
  2447. }
  2448. var sharedParent = aParents[idx - 1];
  2449. var siblings = sharedParent.children;
  2450. var aSibling = aParents[idx];
  2451. var bSibling = bParents[idx];
  2452. if (siblings.indexOf(aSibling) > siblings.indexOf(bSibling)) {
  2453. if (sharedParent === nodeB) {
  2454. return 4 /* FOLLOWING */ | 16 /* CONTAINED_BY */;
  2455. }
  2456. return 4 /* FOLLOWING */;
  2457. }
  2458. if (sharedParent === nodeA) {
  2459. return 2 /* PRECEDING */ | 8 /* CONTAINS */;
  2460. }
  2461. return 2 /* PRECEDING */;
  2462. }
  2463. exports.compareDocumentPosition = compareDocumentPosition;
  2464. /**
  2465. * Sort an array of nodes based on their relative position in the document and
  2466. * remove any duplicate nodes. If the array contains nodes that do not belong
  2467. * to the same document, sort order is unspecified.
  2468. *
  2469. * @param nodes Array of DOM nodes
  2470. * @returns collection of unique nodes, sorted in document order
  2471. */
  2472. function uniqueSort(nodes) {
  2473. nodes = nodes.filter(function (node, i, arr) { return !arr.includes(node, i + 1); });
  2474. nodes.sort(function (a, b) {
  2475. var relative = compareDocumentPosition(a, b);
  2476. if (relative & 2 /* PRECEDING */) {
  2477. return -1;
  2478. }
  2479. else if (relative & 4 /* FOLLOWING */) {
  2480. return 1;
  2481. }
  2482. return 0;
  2483. });
  2484. return nodes;
  2485. }
  2486. exports.uniqueSort = uniqueSort;
  2487. },{"./tagtypes":15}],10:[function(require,module,exports){
  2488. "use strict";
  2489. var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
  2490. if (k2 === undefined) k2 = k;
  2491. Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
  2492. }) : (function(o, m, k, k2) {
  2493. if (k2 === undefined) k2 = k;
  2494. o[k2] = m[k];
  2495. }));
  2496. var __exportStar = (this && this.__exportStar) || function(m, exports) {
  2497. for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
  2498. };
  2499. Object.defineProperty(exports, "__esModule", { value: true });
  2500. __exportStar(require("./stringify"), exports);
  2501. __exportStar(require("./traversal"), exports);
  2502. __exportStar(require("./manipulation"), exports);
  2503. __exportStar(require("./querying"), exports);
  2504. __exportStar(require("./legacy"), exports);
  2505. __exportStar(require("./helpers"), exports);
  2506. __exportStar(require("./tagtypes"), exports);
  2507. },{"./helpers":9,"./legacy":11,"./manipulation":12,"./querying":13,"./stringify":14,"./tagtypes":15,"./traversal":16}],11:[function(require,module,exports){
  2508. "use strict";
  2509. Object.defineProperty(exports, "__esModule", { value: true });
  2510. exports.getElementsByTagType = exports.getElementsByTagName = exports.getElementById = exports.getElements = exports.testElement = void 0;
  2511. var querying_1 = require("./querying");
  2512. var tagtypes_1 = require("./tagtypes");
  2513. function isTextNode(node) {
  2514. return node.type === "text" /* Text */;
  2515. }
  2516. var Checks = {
  2517. tag_name: function (name) {
  2518. if (typeof name === "function") {
  2519. return function (elem) { return tagtypes_1.isTag(elem) && name(elem.name); };
  2520. }
  2521. else if (name === "*") {
  2522. return tagtypes_1.isTag;
  2523. }
  2524. return function (elem) { return tagtypes_1.isTag(elem) && elem.name === name; };
  2525. },
  2526. tag_type: function (type) {
  2527. if (typeof type === "function") {
  2528. return function (elem) { return type(elem.type); };
  2529. }
  2530. return function (elem) { return elem.type === type; };
  2531. },
  2532. tag_contains: function (data) {
  2533. if (typeof data === "function") {
  2534. return function (elem) { return isTextNode(elem) && data(elem.data); };
  2535. }
  2536. return function (elem) { return isTextNode(elem) && elem.data === data; };
  2537. },
  2538. };
  2539. function getAttribCheck(attrib, value) {
  2540. if (typeof value === "function") {
  2541. return function (elem) { return tagtypes_1.isTag(elem) && value(elem.attribs[attrib]); };
  2542. }
  2543. return function (elem) { return tagtypes_1.isTag(elem) && elem.attribs[attrib] === value; };
  2544. }
  2545. function combineFuncs(a, b) {
  2546. return function (elem) { return a(elem) || b(elem); };
  2547. }
  2548. function compileTest(options) {
  2549. var funcs = Object.keys(options).map(function (key) {
  2550. var value = options[key];
  2551. return key in Checks
  2552. ? Checks[key](value)
  2553. : getAttribCheck(key, value);
  2554. });
  2555. return funcs.length === 0 ? null : funcs.reduce(combineFuncs);
  2556. }
  2557. function testElement(options, element) {
  2558. var test = compileTest(options);
  2559. return test ? test(element) : true;
  2560. }
  2561. exports.testElement = testElement;
  2562. function getElements(options, element, recurse, limit) {
  2563. if (limit === void 0) { limit = Infinity; }
  2564. var test = compileTest(options);
  2565. return test ? querying_1.filter(test, element, recurse, limit) : [];
  2566. }
  2567. exports.getElements = getElements;
  2568. function getElementById(id, element, recurse) {
  2569. if (recurse === void 0) { recurse = true; }
  2570. if (!Array.isArray(element))
  2571. element = [element];
  2572. return querying_1.findOne(getAttribCheck("id", id), element, recurse);
  2573. }
  2574. exports.getElementById = getElementById;
  2575. function getElementsByTagName(name, element, recurse, limit) {
  2576. if (limit === void 0) { limit = Infinity; }
  2577. return querying_1.filter(Checks.tag_name(name), element, recurse, limit);
  2578. }
  2579. exports.getElementsByTagName = getElementsByTagName;
  2580. function getElementsByTagType(type, element, recurse, limit) {
  2581. if (recurse === void 0) { recurse = true; }
  2582. if (limit === void 0) { limit = Infinity; }
  2583. return querying_1.filter(Checks.tag_type(type), element, recurse, limit);
  2584. }
  2585. exports.getElementsByTagType = getElementsByTagType;
  2586. },{"./querying":13,"./tagtypes":15}],12:[function(require,module,exports){
  2587. "use strict";
  2588. Object.defineProperty(exports, "__esModule", { value: true });
  2589. exports.prepend = exports.append = exports.appendChild = exports.replaceElement = exports.removeElement = void 0;
  2590. /**
  2591. * Remove an element from the dom
  2592. *
  2593. * @param elem The element to be removed
  2594. */
  2595. function removeElement(elem) {
  2596. if (elem.prev)
  2597. elem.prev.next = elem.next;
  2598. if (elem.next)
  2599. elem.next.prev = elem.prev;
  2600. if (elem.parent) {
  2601. var childs = elem.parent.children;
  2602. childs.splice(childs.lastIndexOf(elem), 1);
  2603. }
  2604. }
  2605. exports.removeElement = removeElement;
  2606. /**
  2607. * Replace an element in the dom
  2608. *
  2609. * @param elem The element to be replaced
  2610. * @param replacement The element to be added
  2611. */
  2612. function replaceElement(elem, replacement) {
  2613. var prev = (replacement.prev = elem.prev);
  2614. if (prev) {
  2615. prev.next = replacement;
  2616. }
  2617. var next = (replacement.next = elem.next);
  2618. if (next) {
  2619. next.prev = replacement;
  2620. }
  2621. var parent = (replacement.parent = elem.parent);
  2622. if (parent) {
  2623. var childs = parent.children;
  2624. childs[childs.lastIndexOf(elem)] = replacement;
  2625. }
  2626. }
  2627. exports.replaceElement = replaceElement;
  2628. /**
  2629. * Append a child to an element
  2630. *
  2631. * @param elem The element to append to
  2632. * @param child The element to be added as a child
  2633. */
  2634. function appendChild(elem, child) {
  2635. removeElement(child);
  2636. child.parent = elem;
  2637. if (elem.children.push(child) !== 1) {
  2638. var sibling = elem.children[elem.children.length - 2];
  2639. sibling.next = child;
  2640. child.prev = sibling;
  2641. child.next = null;
  2642. }
  2643. }
  2644. exports.appendChild = appendChild;
  2645. /**
  2646. * Append an element after another
  2647. *
  2648. * @param elem The element to append to
  2649. * @param next The element be added
  2650. */
  2651. function append(elem, next) {
  2652. removeElement(next);
  2653. var parent = elem.parent;
  2654. var currNext = elem.next;
  2655. next.next = currNext;
  2656. next.prev = elem;
  2657. elem.next = next;
  2658. next.parent = parent;
  2659. if (currNext) {
  2660. currNext.prev = next;
  2661. if (parent) {
  2662. var childs = parent.children;
  2663. childs.splice(childs.lastIndexOf(currNext), 0, next);
  2664. }
  2665. }
  2666. else if (parent) {
  2667. parent.children.push(next);
  2668. }
  2669. }
  2670. exports.append = append;
  2671. /**
  2672. * Prepend an element before another
  2673. *
  2674. * @param elem The element to append to
  2675. * @param prev The element be added
  2676. */
  2677. function prepend(elem, prev) {
  2678. var parent = elem.parent;
  2679. if (parent) {
  2680. var childs = parent.children;
  2681. childs.splice(childs.lastIndexOf(elem), 0, prev);
  2682. }
  2683. if (elem.prev) {
  2684. elem.prev.next = prev;
  2685. }
  2686. prev.parent = parent;
  2687. prev.prev = elem.prev;
  2688. prev.next = elem;
  2689. elem.prev = prev;
  2690. }
  2691. exports.prepend = prepend;
  2692. },{}],13:[function(require,module,exports){
  2693. "use strict";
  2694. Object.defineProperty(exports, "__esModule", { value: true });
  2695. exports.findAll = exports.existsOne = exports.findOne = exports.findOneChild = exports.find = exports.filter = void 0;
  2696. var tagtypes_1 = require("./tagtypes");
  2697. /**
  2698. * Search a node and its children for nodes passing a test function.
  2699. *
  2700. * @param test Function to test nodes on.
  2701. * @param element Element to search. Will be included in the result set if it matches.
  2702. * @param recurse Also consider child nodes.
  2703. * @param limit Maximum number of nodes to return.
  2704. */
  2705. function filter(test, node, recurse, limit) {
  2706. if (recurse === void 0) { recurse = true; }
  2707. if (limit === void 0) { limit = Infinity; }
  2708. if (!Array.isArray(node))
  2709. node = [node];
  2710. return find(test, node, recurse, limit);
  2711. }
  2712. exports.filter = filter;
  2713. /**
  2714. * Like `filter`, but only works on an array of nodes.
  2715. *
  2716. * @param test Function to test nodes on.
  2717. * @param nodes Array of nodes to search.
  2718. * @param recurse Also consider child nodes.
  2719. * @param limit Maximum number of nodes to return.
  2720. */
  2721. function find(test, nodes, recurse, limit) {
  2722. var result = [];
  2723. for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) {
  2724. var elem = nodes_1[_i];
  2725. if (test(elem)) {
  2726. result.push(elem);
  2727. if (--limit <= 0)
  2728. break;
  2729. }
  2730. if (recurse && tagtypes_1.hasChildren(elem) && elem.children.length > 0) {
  2731. var children = find(test, elem.children, recurse, limit);
  2732. result.push.apply(result, children);
  2733. limit -= children.length;
  2734. if (limit <= 0)
  2735. break;
  2736. }
  2737. }
  2738. return result;
  2739. }
  2740. exports.find = find;
  2741. /**
  2742. * Finds the first element inside of an array that matches a test function.
  2743. *
  2744. * @param test Function to test nodes on.
  2745. * @param nodes Array of nodes to search.
  2746. */
  2747. function findOneChild(test, nodes) {
  2748. return nodes.find(test);
  2749. }
  2750. exports.findOneChild = findOneChild;
  2751. /**
  2752. * Finds one element in a tree that passes a test.
  2753. *
  2754. * @param test Function to test nodes on.
  2755. * @param nodes Array of nodes to search.
  2756. * @param recurse Also consider child nodes.
  2757. */
  2758. function findOne(test, nodes, recurse) {
  2759. if (recurse === void 0) { recurse = true; }
  2760. var elem = null;
  2761. for (var i = 0; i < nodes.length && !elem; i++) {
  2762. var checked = nodes[i];
  2763. if (!tagtypes_1.isTag(checked)) {
  2764. continue;
  2765. }
  2766. else if (test(checked)) {
  2767. elem = checked;
  2768. }
  2769. else if (recurse && checked.children.length > 0) {
  2770. elem = findOne(test, checked.children);
  2771. }
  2772. }
  2773. return elem;
  2774. }
  2775. exports.findOne = findOne;
  2776. /**
  2777. * Returns whether a tree of nodes contains at least one node passing a test.
  2778. *
  2779. * @param test Function to test nodes on.
  2780. * @param nodes Array of nodes to search.
  2781. */
  2782. function existsOne(test, nodes) {
  2783. return nodes.some(function (checked) {
  2784. return tagtypes_1.isTag(checked) &&
  2785. (test(checked) ||
  2786. (checked.children.length > 0 &&
  2787. existsOne(test, checked.children)));
  2788. });
  2789. }
  2790. exports.existsOne = existsOne;
  2791. /**
  2792. * Search and array of nodes and its children for nodes passing a test function.
  2793. *
  2794. * Same as `find`, only with less options, leading to reduced complexity.
  2795. *
  2796. * @param test Function to test nodes on.
  2797. * @param nodes Array of nodes to search.
  2798. */
  2799. function findAll(test, nodes) {
  2800. var _a;
  2801. var result = [];
  2802. var stack = nodes.filter(tagtypes_1.isTag);
  2803. var elem;
  2804. while ((elem = stack.shift())) {
  2805. var children = (_a = elem.children) === null || _a === void 0 ? void 0 : _a.filter(tagtypes_1.isTag);
  2806. if (children && children.length > 0) {
  2807. stack.unshift.apply(stack, children);
  2808. }
  2809. if (test(elem))
  2810. result.push(elem);
  2811. }
  2812. return result;
  2813. }
  2814. exports.findAll = findAll;
  2815. },{"./tagtypes":15}],14:[function(require,module,exports){
  2816. "use strict";
  2817. var __importDefault = (this && this.__importDefault) || function (mod) {
  2818. return (mod && mod.__esModule) ? mod : { "default": mod };
  2819. };
  2820. Object.defineProperty(exports, "__esModule", { value: true });
  2821. exports.getText = exports.getInnerHTML = exports.getOuterHTML = void 0;
  2822. var tagtypes_1 = require("./tagtypes");
  2823. var dom_serializer_1 = __importDefault(require("dom-serializer"));
  2824. function getOuterHTML(node, options) {
  2825. return dom_serializer_1.default(node, options);
  2826. }
  2827. exports.getOuterHTML = getOuterHTML;
  2828. function getInnerHTML(node, options) {
  2829. return tagtypes_1.hasChildren(node)
  2830. ? node.children.map(function (node) { return getOuterHTML(node, options); }).join("")
  2831. : "";
  2832. }
  2833. exports.getInnerHTML = getInnerHTML;
  2834. function getText(node) {
  2835. if (Array.isArray(node))
  2836. return node.map(getText).join("");
  2837. if (tagtypes_1.isTag(node))
  2838. return node.name === "br" ? "\n" : getText(node.children);
  2839. if (tagtypes_1.isCDATA(node))
  2840. return getText(node.children);
  2841. if (tagtypes_1.isText(node))
  2842. return node.data;
  2843. return "";
  2844. }
  2845. exports.getText = getText;
  2846. },{"./tagtypes":15,"dom-serializer":5}],15:[function(require,module,exports){
  2847. "use strict";
  2848. Object.defineProperty(exports, "__esModule", { value: true });
  2849. exports.hasChildren = exports.isComment = exports.isText = exports.isCDATA = exports.isTag = void 0;
  2850. var domelementtype_1 = require("domelementtype");
  2851. function isTag(node) {
  2852. return domelementtype_1.isTag(node);
  2853. }
  2854. exports.isTag = isTag;
  2855. function isCDATA(node) {
  2856. return node.type === "cdata" /* CDATA */;
  2857. }
  2858. exports.isCDATA = isCDATA;
  2859. function isText(node) {
  2860. return node.type === "text" /* Text */;
  2861. }
  2862. exports.isText = isText;
  2863. function isComment(node) {
  2864. return node.type === "comment" /* Comment */;
  2865. }
  2866. exports.isComment = isComment;
  2867. function hasChildren(node) {
  2868. return Object.prototype.hasOwnProperty.call(node, "children");
  2869. }
  2870. exports.hasChildren = hasChildren;
  2871. },{"domelementtype":6}],16:[function(require,module,exports){
  2872. "use strict";
  2873. Object.defineProperty(exports, "__esModule", { value: true });
  2874. exports.nextElementSibling = exports.getName = exports.hasAttrib = exports.getAttributeValue = exports.getSiblings = exports.getParent = exports.getChildren = void 0;
  2875. function getChildren(elem) {
  2876. return elem.children || null;
  2877. }
  2878. exports.getChildren = getChildren;
  2879. function getParent(elem) {
  2880. return elem.parent || null;
  2881. }
  2882. exports.getParent = getParent;
  2883. function getSiblings(elem) {
  2884. var parent = getParent(elem);
  2885. return parent ? getChildren(parent) : [elem];
  2886. }
  2887. exports.getSiblings = getSiblings;
  2888. function getAttributeValue(elem, name) {
  2889. var _a;
  2890. return (_a = elem.attribs) === null || _a === void 0 ? void 0 : _a[name];
  2891. }
  2892. exports.getAttributeValue = getAttributeValue;
  2893. function hasAttrib(elem, name) {
  2894. return (!!elem.attribs &&
  2895. Object.prototype.hasOwnProperty.call(elem.attribs, name) &&
  2896. elem.attribs[name] != null);
  2897. }
  2898. exports.hasAttrib = hasAttrib;
  2899. /**
  2900. * Returns the name property of an element
  2901. *
  2902. * @param elem The element to get the name for
  2903. */
  2904. function getName(elem) {
  2905. return elem.name;
  2906. }
  2907. exports.getName = getName;
  2908. function nextElementSibling(elem) {
  2909. var node = elem.next;
  2910. while (node !== null && node.type !== "tag")
  2911. node = node.next;
  2912. return node;
  2913. }
  2914. exports.nextElementSibling = nextElementSibling;
  2915. },{}],17:[function(require,module,exports){
  2916. "use strict";
  2917. var __importDefault = (this && this.__importDefault) || function (mod) {
  2918. return (mod && mod.__esModule) ? mod : { "default": mod };
  2919. };
  2920. Object.defineProperty(exports, "__esModule", { value: true });
  2921. exports.decodeHTML = exports.decodeHTMLStrict = exports.decodeXML = void 0;
  2922. var entities_json_1 = __importDefault(require("./maps/entities.json"));
  2923. var legacy_json_1 = __importDefault(require("./maps/legacy.json"));
  2924. var xml_json_1 = __importDefault(require("./maps/xml.json"));
  2925. var decode_codepoint_1 = __importDefault(require("./decode_codepoint"));
  2926. exports.decodeXML = getStrictDecoder(xml_json_1.default);
  2927. exports.decodeHTMLStrict = getStrictDecoder(entities_json_1.default);
  2928. function getStrictDecoder(map) {
  2929. var keys = Object.keys(map).join("|");
  2930. var replace = getReplacer(map);
  2931. keys += "|#[xX][\\da-fA-F]+|#\\d+";
  2932. var re = new RegExp("&(?:" + keys + ");", "g");
  2933. return function (str) { return String(str).replace(re, replace); };
  2934. }
  2935. var sorter = function (a, b) { return (a < b ? 1 : -1); };
  2936. exports.decodeHTML = (function () {
  2937. var legacy = Object.keys(legacy_json_1.default).sort(sorter);
  2938. var keys = Object.keys(entities_json_1.default).sort(sorter);
  2939. for (var i = 0, j = 0; i < keys.length; i++) {
  2940. if (legacy[j] === keys[i]) {
  2941. keys[i] += ";?";
  2942. j++;
  2943. }
  2944. else {
  2945. keys[i] += ";";
  2946. }
  2947. }
  2948. var re = new RegExp("&(?:" + keys.join("|") + "|#[xX][\\da-fA-F]+;?|#\\d+;?)", "g");
  2949. var replace = getReplacer(entities_json_1.default);
  2950. function replacer(str) {
  2951. if (str.substr(-1) !== ";")
  2952. str += ";";
  2953. return replace(str);
  2954. }
  2955. //TODO consider creating a merged map
  2956. return function (str) { return String(str).replace(re, replacer); };
  2957. })();
  2958. function getReplacer(map) {
  2959. return function replace(str) {
  2960. if (str.charAt(1) === "#") {
  2961. var secondChar = str.charAt(2);
  2962. if (secondChar === "X" || secondChar === "x") {
  2963. return decode_codepoint_1.default(parseInt(str.substr(3), 16));
  2964. }
  2965. return decode_codepoint_1.default(parseInt(str.substr(2), 10));
  2966. }
  2967. return map[str.slice(1, -1)];
  2968. };
  2969. }
  2970. },{"./decode_codepoint":18,"./maps/entities.json":22,"./maps/legacy.json":23,"./maps/xml.json":24}],18:[function(require,module,exports){
  2971. "use strict";
  2972. var __importDefault = (this && this.__importDefault) || function (mod) {
  2973. return (mod && mod.__esModule) ? mod : { "default": mod };
  2974. };
  2975. Object.defineProperty(exports, "__esModule", { value: true });
  2976. var decode_json_1 = __importDefault(require("./maps/decode.json"));
  2977. // modified version of https://github.com/mathiasbynens/he/blob/master/src/he.js#L94-L119
  2978. function decodeCodePoint(codePoint) {
  2979. if ((codePoint >= 0xd800 && codePoint <= 0xdfff) || codePoint > 0x10ffff) {
  2980. return "\uFFFD";
  2981. }
  2982. if (codePoint in decode_json_1.default) {
  2983. codePoint = decode_json_1.default[codePoint];
  2984. }
  2985. var output = "";
  2986. if (codePoint > 0xffff) {
  2987. codePoint -= 0x10000;
  2988. output += String.fromCharCode(((codePoint >>> 10) & 0x3ff) | 0xd800);
  2989. codePoint = 0xdc00 | (codePoint & 0x3ff);
  2990. }
  2991. output += String.fromCharCode(codePoint);
  2992. return output;
  2993. }
  2994. exports.default = decodeCodePoint;
  2995. },{"./maps/decode.json":21}],19:[function(require,module,exports){
  2996. "use strict";
  2997. var __importDefault = (this && this.__importDefault) || function (mod) {
  2998. return (mod && mod.__esModule) ? mod : { "default": mod };
  2999. };
  3000. Object.defineProperty(exports, "__esModule", { value: true });
  3001. exports.escape = exports.encodeHTML = exports.encodeXML = void 0;
  3002. var xml_json_1 = __importDefault(require("./maps/xml.json"));
  3003. var inverseXML = getInverseObj(xml_json_1.default);
  3004. var xmlReplacer = getInverseReplacer(inverseXML);
  3005. exports.encodeXML = getInverse(inverseXML, xmlReplacer);
  3006. var entities_json_1 = __importDefault(require("./maps/entities.json"));
  3007. var inverseHTML = getInverseObj(entities_json_1.default);
  3008. var htmlReplacer = getInverseReplacer(inverseHTML);
  3009. exports.encodeHTML = getInverse(inverseHTML, htmlReplacer);
  3010. function getInverseObj(obj) {
  3011. return Object.keys(obj)
  3012. .sort()
  3013. .reduce(function (inverse, name) {
  3014. inverse[obj[name]] = "&" + name + ";";
  3015. return inverse;
  3016. }, {});
  3017. }
  3018. function getInverseReplacer(inverse) {
  3019. var single = [];
  3020. var multiple = [];
  3021. for (var _i = 0, _a = Object.keys(inverse); _i < _a.length; _i++) {
  3022. var k = _a[_i];
  3023. if (k.length === 1) {
  3024. // Add value to single array
  3025. single.push("\\" + k);
  3026. }
  3027. else {
  3028. // Add value to multiple array
  3029. multiple.push(k);
  3030. }
  3031. }
  3032. // Add ranges to single characters.
  3033. single.sort();
  3034. for (var start = 0; start < single.length - 1; start++) {
  3035. // Find the end of a run of characters
  3036. var end = start;
  3037. while (end < single.length - 1 &&
  3038. single[end].charCodeAt(1) + 1 === single[end + 1].charCodeAt(1)) {
  3039. end += 1;
  3040. }
  3041. var count = 1 + end - start;
  3042. // We want to replace at least three characters
  3043. if (count < 3)
  3044. continue;
  3045. single.splice(start, count, single[start] + "-" + single[end]);
  3046. }
  3047. multiple.unshift("[" + single.join("") + "]");
  3048. return new RegExp(multiple.join("|"), "g");
  3049. }
  3050. var reNonASCII = /(?:[\x80-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])/g;
  3051. function singleCharReplacer(c) {
  3052. // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
  3053. return "&#x" + c.codePointAt(0).toString(16).toUpperCase() + ";";
  3054. }
  3055. function getInverse(inverse, re) {
  3056. return function (data) {
  3057. return data
  3058. .replace(re, function (name) { return inverse[name]; })
  3059. .replace(reNonASCII, singleCharReplacer);
  3060. };
  3061. }
  3062. var reXmlChars = getInverseReplacer(inverseXML);
  3063. function escape(data) {
  3064. return data
  3065. .replace(reXmlChars, singleCharReplacer)
  3066. .replace(reNonASCII, singleCharReplacer);
  3067. }
  3068. exports.escape = escape;
  3069. },{"./maps/entities.json":22,"./maps/xml.json":24}],20:[function(require,module,exports){
  3070. "use strict";
  3071. Object.defineProperty(exports, "__esModule", { value: true });
  3072. exports.encode = exports.decodeStrict = exports.decode = void 0;
  3073. var decode_1 = require("./decode");
  3074. var encode_1 = require("./encode");
  3075. /**
  3076. * Decodes a string with entities.
  3077. *
  3078. * @param data String to decode.
  3079. * @param level Optional level to decode at. 0 = XML, 1 = HTML. Default is 0.
  3080. */
  3081. function decode(data, level) {
  3082. return (!level || level <= 0 ? decode_1.decodeXML : decode_1.decodeHTML)(data);
  3083. }
  3084. exports.decode = decode;
  3085. /**
  3086. * Decodes a string with entities. Does not allow missing trailing semicolons for entities.
  3087. *
  3088. * @param data String to decode.
  3089. * @param level Optional level to decode at. 0 = XML, 1 = HTML. Default is 0.
  3090. */
  3091. function decodeStrict(data, level) {
  3092. return (!level || level <= 0 ? decode_1.decodeXML : decode_1.decodeHTMLStrict)(data);
  3093. }
  3094. exports.decodeStrict = decodeStrict;
  3095. /**
  3096. * Encodes a string with entities.
  3097. *
  3098. * @param data String to encode.
  3099. * @param level Optional level to encode at. 0 = XML, 1 = HTML. Default is 0.
  3100. */
  3101. function encode(data, level) {
  3102. return (!level || level <= 0 ? encode_1.encodeXML : encode_1.encodeHTML)(data);
  3103. }
  3104. exports.encode = encode;
  3105. var encode_2 = require("./encode");
  3106. Object.defineProperty(exports, "encodeXML", { enumerable: true, get: function () { return encode_2.encodeXML; } });
  3107. Object.defineProperty(exports, "encodeHTML", { enumerable: true, get: function () { return encode_2.encodeHTML; } });
  3108. Object.defineProperty(exports, "escape", { enumerable: true, get: function () { return encode_2.escape; } });
  3109. // Legacy aliases
  3110. Object.defineProperty(exports, "encodeHTML4", { enumerable: true, get: function () { return encode_2.encodeHTML; } });
  3111. Object.defineProperty(exports, "encodeHTML5", { enumerable: true, get: function () { return encode_2.encodeHTML; } });
  3112. var decode_2 = require("./decode");
  3113. Object.defineProperty(exports, "decodeXML", { enumerable: true, get: function () { return decode_2.decodeXML; } });
  3114. Object.defineProperty(exports, "decodeHTML", { enumerable: true, get: function () { return decode_2.decodeHTML; } });
  3115. Object.defineProperty(exports, "decodeHTMLStrict", { enumerable: true, get: function () { return decode_2.decodeHTMLStrict; } });
  3116. // Legacy aliases
  3117. Object.defineProperty(exports, "decodeHTML4", { enumerable: true, get: function () { return decode_2.decodeHTML; } });
  3118. Object.defineProperty(exports, "decodeHTML5", { enumerable: true, get: function () { return decode_2.decodeHTML; } });
  3119. Object.defineProperty(exports, "decodeHTML4Strict", { enumerable: true, get: function () { return decode_2.decodeHTMLStrict; } });
  3120. Object.defineProperty(exports, "decodeHTML5Strict", { enumerable: true, get: function () { return decode_2.decodeHTMLStrict; } });
  3121. Object.defineProperty(exports, "decodeXMLStrict", { enumerable: true, get: function () { return decode_2.decodeXML; } });
  3122. },{"./decode":17,"./encode":19}],21:[function(require,module,exports){
  3123. module.exports={
  3124. "0": 65533,
  3125. "128": 8364,
  3126. "130": 8218,
  3127. "131": 402,
  3128. "132": 8222,
  3129. "133": 8230,
  3130. "134": 8224,
  3131. "135": 8225,
  3132. "136": 710,
  3133. "137": 8240,
  3134. "138": 352,
  3135. "139": 8249,
  3136. "140": 338,
  3137. "142": 381,
  3138. "145": 8216,
  3139. "146": 8217,
  3140. "147": 8220,
  3141. "148": 8221,
  3142. "149": 8226,
  3143. "150": 8211,
  3144. "151": 8212,
  3145. "152": 732,
  3146. "153": 8482,
  3147. "154": 353,
  3148. "155": 8250,
  3149. "156": 339,
  3150. "158": 382,
  3151. "159": 376
  3152. }
  3153. },{}],22:[function(require,module,exports){
  3154. module.exports={ "Aacute": "\u00C1", "aacute": "\u00E1", "Abreve": "\u0102", "abreve": "\u0103", "ac": "\u223E", "acd": "\u223F", "acE": "\u223E\u0333", "Acirc": "\u00C2", "acirc": "\u00E2", "acute": "\u00B4", "Acy": "\u0410", "acy": "\u0430", "AElig": "\u00C6", "aelig": "\u00E6", "af": "\u2061", "Afr": "\uD835\uDD04", "afr": "\uD835\uDD1E", "Agrave": "\u00C0", "agrave": "\u00E0", "alefsym": "\u2135", "aleph": "\u2135", "Alpha": "\u0391", "alpha": "\u03B1", "Amacr": "\u0100", "amacr": "\u0101", "amalg": "\u2A3F", "amp": "&", "AMP": "&", "andand": "\u2A55", "And": "\u2A53", "and": "\u2227", "andd": "\u2A5C", "andslope": "\u2A58", "andv": "\u2A5A", "ang": "\u2220", "ange": "\u29A4", "angle": "\u2220", "angmsdaa": "\u29A8", "angmsdab": "\u29A9", "angmsdac": "\u29AA", "angmsdad": "\u29AB", "angmsdae": "\u29AC", "angmsdaf": "\u29AD", "angmsdag": "\u29AE", "angmsdah": "\u29AF", "angmsd": "\u2221", "angrt": "\u221F", "angrtvb": "\u22BE", "angrtvbd": "\u299D", "angsph": "\u2222", "angst": "\u00C5", "angzarr": "\u237C", "Aogon": "\u0104", "aogon": "\u0105", "Aopf": "\uD835\uDD38", "aopf": "\uD835\uDD52", "apacir": "\u2A6F", "ap": "\u2248", "apE": "\u2A70", "ape": "\u224A", "apid": "\u224B", "apos": "'", "ApplyFunction": "\u2061", "approx": "\u2248", "approxeq": "\u224A", "Aring": "\u00C5", "aring": "\u00E5", "Ascr": "\uD835\uDC9C", "ascr": "\uD835\uDCB6", "Assign": "\u2254", "ast": "*", "asymp": "\u2248", "asympeq": "\u224D", "Atilde": "\u00C3", "atilde": "\u00E3", "Auml": "\u00C4", "auml": "\u00E4", "awconint": "\u2233", "awint": "\u2A11", "backcong": "\u224C", "backepsilon": "\u03F6", "backprime": "\u2035", "backsim": "\u223D", "backsimeq": "\u22CD", "Backslash": "\u2216", "Barv": "\u2AE7", "barvee": "\u22BD", "barwed": "\u2305", "Barwed": "\u2306", "barwedge": "\u2305", "bbrk": "\u23B5", "bbrktbrk": "\u23B6", "bcong": "\u224C", "Bcy": "\u0411", "bcy": "\u0431", "bdquo": "\u201E", "becaus": "\u2235", "because": "\u2235", "Because": "\u2235", "bemptyv": "\u29B0", "bepsi": "\u03F6", "bernou": "\u212C", "Bernoullis": "\u212C", "Beta": "\u0392", "beta": "\u03B2", "beth": "\u2136", "between": "\u226C", "Bfr": "\uD835\uDD05", "bfr": "\uD835\uDD1F", "bigcap": "\u22C2", "bigcirc": "\u25EF", "bigcup": "\u22C3", "bigodot": "\u2A00", "bigoplus": "\u2A01", "bigotimes": "\u2A02", "bigsqcup": "\u2A06", "bigstar": "\u2605", "bigtriangledown": "\u25BD", "bigtriangleup": "\u25B3", "biguplus": "\u2A04", "bigvee": "\u22C1", "bigwedge": "\u22C0", "bkarow": "\u290D", "blacklozenge": "\u29EB", "blacksquare": "\u25AA", "blacktriangle": "\u25B4", "blacktriangledown": "\u25BE", "blacktriangleleft": "\u25C2", "blacktriangleright": "\u25B8", "blank": "\u2423", "blk12": "\u2592", "blk14": "\u2591", "blk34": "\u2593", "block": "\u2588", "bne": "=\u20E5", "bnequiv": "\u2261\u20E5", "bNot": "\u2AED", "bnot": "\u2310", "Bopf": "\uD835\uDD39", "bopf": "\uD835\uDD53", "bot": "\u22A5", "bottom": "\u22A5", "bowtie": "\u22C8", "boxbox": "\u29C9", "boxdl": "\u2510", "boxdL": "\u2555", "boxDl": "\u2556", "boxDL": "\u2557", "boxdr": "\u250C", "boxdR": "\u2552", "boxDr": "\u2553", "boxDR": "\u2554", "boxh": "\u2500", "boxH": "\u2550", "boxhd": "\u252C", "boxHd": "\u2564", "boxhD": "\u2565", "boxHD": "\u2566", "boxhu": "\u2534", "boxHu": "\u2567", "boxhU": "\u2568", "boxHU": "\u2569", "boxminus": "\u229F", "boxplus": "\u229E", "boxtimes": "\u22A0", "boxul": "\u2518", "boxuL": "\u255B", "boxUl": "\u255C", "boxUL": "\u255D", "boxur": "\u2514", "boxuR": "\u2558", "boxUr": "\u2559", "boxUR": "\u255A", "boxv": "\u2502", "boxV": "\u2551", "boxvh": "\u253C", "boxvH": "\u256A", "boxVh": "\u256B", "boxVH": "\u256C", "boxvl": "\u2524", "boxvL": "\u2561", "boxVl": "\u2562", "boxVL": "\u2563", "boxvr": "\u251C", "boxvR": "\u255E", "boxVr": "\u255F", "boxVR": "\u2560", "bprime": "\u2035", "breve": "\u02D8", "Breve": "\u02D8", "brvbar": "\u00A6", "bscr": "\uD835\uDCB7", "Bscr": "\u212C", "bsemi": "\u204F", "bsim": "\u223D", "bsime": "\u22CD", "bsolb": "\u29C5", "bsol": "\\", "bsolhsub": "\u27C8", "bull": "\u2022", "bullet": "\u2022", "bump": "\u224E", "bumpE": "\u2AAE", "bumpe": "\u224F", "Bumpeq": "\u224E", "bumpeq": "\u224F", "Cacute": "\u0106", "cacute": "\u0107", "capand": "\u2A44", "capbrcup": "\u2A49", "capcap": "\u2A4B", "cap": "\u2229", "Cap": "\u22D2", "capcup": "\u2A47", "capdot": "\u2A40", "CapitalDifferentialD": "\u2145", "caps": "\u2229\uFE00", "caret": "\u2041", "caron": "\u02C7", "Cayleys": "\u212D", "ccaps": "\u2A4D", "Ccaron": "\u010C", "ccaron": "\u010D", "Ccedil": "\u00C7", "ccedil": "\u00E7", "Ccirc": "\u0108", "ccirc": "\u0109", "Cconint": "\u2230", "ccups": "\u2A4C", "ccupssm": "\u2A50", "Cdot": "\u010A", "cdot": "\u010B", "cedil": "\u00B8", "Cedilla": "\u00B8", "cemptyv": "\u29B2", "cent": "\u00A2", "centerdot": "\u00B7", "CenterDot": "\u00B7", "cfr": "\uD835\uDD20", "Cfr": "\u212D", "CHcy": "\u0427", "chcy": "\u0447", "check": "\u2713", "checkmark": "\u2713", "Chi": "\u03A7", "chi": "\u03C7", "circ": "\u02C6", "circeq": "\u2257", "circlearrowleft": "\u21BA", "circlearrowright": "\u21BB", "circledast": "\u229B", "circledcirc": "\u229A", "circleddash": "\u229D", "CircleDot": "\u2299", "circledR": "\u00AE", "circledS": "\u24C8", "CircleMinus": "\u2296", "CirclePlus": "\u2295", "CircleTimes": "\u2297", "cir": "\u25CB", "cirE": "\u29C3", "cire": "\u2257", "cirfnint": "\u2A10", "cirmid": "\u2AEF", "cirscir": "\u29C2", "ClockwiseContourIntegral": "\u2232", "CloseCurlyDoubleQuote": "\u201D", "CloseCurlyQuote": "\u2019", "clubs": "\u2663", "clubsuit": "\u2663", "colon": ":", "Colon": "\u2237", "Colone": "\u2A74", "colone": "\u2254", "coloneq": "\u2254", "comma": ",", "commat": "@", "comp": "\u2201", "compfn": "\u2218", "complement": "\u2201", "complexes": "\u2102", "cong": "\u2245", "congdot": "\u2A6D", "Congruent": "\u2261", "conint": "\u222E", "Conint": "\u222F", "ContourIntegral": "\u222E", "copf": "\uD835\uDD54", "Copf": "\u2102", "coprod": "\u2210", "Coproduct": "\u2210", "copy": "\u00A9", "COPY": "\u00A9", "copysr": "\u2117", "CounterClockwiseContourIntegral": "\u2233", "crarr": "\u21B5", "cross": "\u2717", "Cross": "\u2A2F", "Cscr": "\uD835\uDC9E", "cscr": "\uD835\uDCB8", "csub": "\u2ACF", "csube": "\u2AD1", "csup": "\u2AD0", "csupe": "\u2AD2", "ctdot": "\u22EF", "cudarrl": "\u2938", "cudarrr": "\u2935", "cuepr": "\u22DE", "cuesc": "\u22DF", "cularr": "\u21B6", "cularrp": "\u293D", "cupbrcap": "\u2A48", "cupcap": "\u2A46", "CupCap": "\u224D", "cup": "\u222A", "Cup": "\u22D3", "cupcup": "\u2A4A", "cupdot": "\u228D", "cupor": "\u2A45", "cups": "\u222A\uFE00", "curarr": "\u21B7", "curarrm": "\u293C", "curlyeqprec": "\u22DE", "curlyeqsucc": "\u22DF", "curlyvee": "\u22CE", "curlywedge": "\u22CF", "curren": "\u00A4", "curvearrowleft": "\u21B6", "curvearrowright": "\u21B7", "cuvee": "\u22CE", "cuwed": "\u22CF", "cwconint": "\u2232", "cwint": "\u2231", "cylcty": "\u232D", "dagger": "\u2020", "Dagger": "\u2021", "daleth": "\u2138", "darr": "\u2193", "Darr": "\u21A1", "dArr": "\u21D3", "dash": "\u2010", "Dashv": "\u2AE4", "dashv": "\u22A3", "dbkarow": "\u290F", "dblac": "\u02DD", "Dcaron": "\u010E", "dcaron": "\u010F", "Dcy": "\u0414", "dcy": "\u0434", "ddagger": "\u2021", "ddarr": "\u21CA", "DD": "\u2145", "dd": "\u2146", "DDotrahd": "\u2911", "ddotseq": "\u2A77", "deg": "\u00B0", "Del": "\u2207", "Delta": "\u0394", "delta": "\u03B4", "demptyv": "\u29B1", "dfisht": "\u297F", "Dfr": "\uD835\uDD07", "dfr": "\uD835\uDD21", "dHar": "\u2965", "dharl": "\u21C3", "dharr": "\u21C2", "DiacriticalAcute": "\u00B4", "DiacriticalDot": "\u02D9", "DiacriticalDoubleAcute": "\u02DD", "DiacriticalGrave": "`", "DiacriticalTilde": "\u02DC", "diam": "\u22C4", "diamond": "\u22C4", "Diamond": "\u22C4", "diamondsuit": "\u2666", "diams": "\u2666", "die": "\u00A8", "DifferentialD": "\u2146", "digamma": "\u03DD", "disin": "\u22F2", "div": "\u00F7", "divide": "\u00F7", "divideontimes": "\u22C7", "divonx": "\u22C7", "DJcy": "\u0402", "djcy": "\u0452", "dlcorn": "\u231E", "dlcrop": "\u230D", "dollar": "$", "Dopf": "\uD835\uDD3B", "dopf": "\uD835\uDD55", "Dot": "\u00A8", "dot": "\u02D9", "DotDot": "\u20DC", "doteq": "\u2250", "doteqdot": "\u2251", "DotEqual": "\u2250", "dotminus": "\u2238", "dotplus": "\u2214", "dotsquare": "\u22A1", "doublebarwedge": "\u2306", "DoubleContourIntegral": "\u222F", "DoubleDot": "\u00A8", "DoubleDownArrow": "\u21D3", "DoubleLeftArrow": "\u21D0", "DoubleLeftRightArrow": "\u21D4", "DoubleLeftTee": "\u2AE4", "DoubleLongLeftArrow": "\u27F8", "DoubleLongLeftRightArrow": "\u27FA", "DoubleLongRightArrow": "\u27F9", "DoubleRightArrow": "\u21D2", "DoubleRightTee": "\u22A8", "DoubleUpArrow": "\u21D1", "DoubleUpDownArrow": "\u21D5", "DoubleVerticalBar": "\u2225", "DownArrowBar": "\u2913", "downarrow": "\u2193", "DownArrow": "\u2193", "Downarrow": "\u21D3", "DownArrowUpArrow": "\u21F5", "DownBreve": "\u0311", "downdownarrows": "\u21CA", "downharpoonleft": "\u21C3", "downharpoonright": "\u21C2", "DownLeftRightVector": "\u2950", "DownLeftTeeVector": "\u295E", "DownLeftVectorBar": "\u2956", "DownLeftVector": "\u21BD", "DownRightTeeVector": "\u295F", "DownRightVectorBar": "\u2957", "DownRightVector": "\u21C1", "DownTeeArrow": "\u21A7", "DownTee": "\u22A4", "drbkarow": "\u2910", "drcorn": "\u231F", "drcrop": "\u230C", "Dscr": "\uD835\uDC9F", "dscr": "\uD835\uDCB9", "DScy": "\u0405", "dscy": "\u0455", "dsol": "\u29F6", "Dstrok": "\u0110", "dstrok": "\u0111", "dtdot": "\u22F1", "dtri": "\u25BF", "dtrif": "\u25BE", "duarr": "\u21F5", "duhar": "\u296F", "dwangle": "\u29A6", "DZcy": "\u040F", "dzcy": "\u045F", "dzigrarr": "\u27FF", "Eacute": "\u00C9", "eacute": "\u00E9", "easter": "\u2A6E", "Ecaron": "\u011A", "ecaron": "\u011B", "Ecirc": "\u00CA", "ecirc": "\u00EA", "ecir": "\u2256", "ecolon": "\u2255", "Ecy": "\u042D", "ecy": "\u044D", "eDDot": "\u2A77", "Edot": "\u0116", "edot": "\u0117", "eDot": "\u2251", "ee": "\u2147", "efDot": "\u2252", "Efr": "\uD835\uDD08", "efr": "\uD835\uDD22", "eg": "\u2A9A", "Egrave": "\u00C8", "egrave": "\u00E8", "egs": "\u2A96", "egsdot": "\u2A98", "el": "\u2A99", "Element": "\u2208", "elinters": "\u23E7", "ell": "\u2113", "els": "\u2A95", "elsdot": "\u2A97", "Emacr": "\u0112", "emacr": "\u0113", "empty": "\u2205", "emptyset": "\u2205", "EmptySmallSquare": "\u25FB", "emptyv": "\u2205", "EmptyVerySmallSquare": "\u25AB", "emsp13": "\u2004", "emsp14": "\u2005", "emsp": "\u2003", "ENG": "\u014A", "eng": "\u014B", "ensp": "\u2002", "Eogon": "\u0118", "eogon": "\u0119", "Eopf": "\uD835\uDD3C", "eopf": "\uD835\uDD56", "epar": "\u22D5", "eparsl": "\u29E3", "eplus": "\u2A71", "epsi": "\u03B5", "Epsilon": "\u0395", "epsilon": "\u03B5", "epsiv": "\u03F5", "eqcirc": "\u2256", "eqcolon": "\u2255", "eqsim": "\u2242", "eqslantgtr": "\u2A96", "eqslantless": "\u2A95", "Equal": "\u2A75", "equals": "=", "EqualTilde": "\u2242", "equest": "\u225F", "Equilibrium": "\u21CC", "equiv": "\u2261", "equivDD": "\u2A78", "eqvparsl": "\u29E5", "erarr": "\u2971", "erDot": "\u2253", "escr": "\u212F", "Escr": "\u2130", "esdot": "\u2250", "Esim": "\u2A73", "esim": "\u2242", "Eta": "\u0397", "eta": "\u03B7", "ETH": "\u00D0", "eth": "\u00F0", "Euml": "\u00CB", "euml": "\u00EB", "euro": "\u20AC", "excl": "!", "exist": "\u2203", "Exists": "\u2203", "expectation": "\u2130", "exponentiale": "\u2147", "ExponentialE": "\u2147", "fallingdotseq": "\u2252", "Fcy": "\u0424", "fcy": "\u0444", "female": "\u2640", "ffilig": "\uFB03", "fflig": "\uFB00", "ffllig": "\uFB04", "Ffr": "\uD835\uDD09", "ffr": "\uD835\uDD23", "filig": "\uFB01", "FilledSmallSquare": "\u25FC", "FilledVerySmallSquare": "\u25AA", "fjlig": "fj", "flat": "\u266D", "fllig": "\uFB02", "fltns": "\u25B1", "fnof": "\u0192", "Fopf": "\uD835\uDD3D", "fopf": "\uD835\uDD57", "forall": "\u2200", "ForAll": "\u2200", "fork": "\u22D4", "forkv": "\u2AD9", "Fouriertrf": "\u2131", "fpartint": "\u2A0D", "frac12": "\u00BD", "frac13": "\u2153", "frac14": "\u00BC", "frac15": "\u2155", "frac16": "\u2159", "frac18": "\u215B", "frac23": "\u2154", "frac25": "\u2156", "frac34": "\u00BE", "frac35": "\u2157", "frac38": "\u215C", "frac45": "\u2158", "frac56": "\u215A", "frac58": "\u215D", "frac78": "\u215E", "frasl": "\u2044", "frown": "\u2322", "fscr": "\uD835\uDCBB", "Fscr": "\u2131", "gacute": "\u01F5", "Gamma": "\u0393", "gamma": "\u03B3", "Gammad": "\u03DC", "gammad": "\u03DD", "gap": "\u2A86", "Gbreve": "\u011E", "gbreve": "\u011F", "Gcedil": "\u0122", "Gcirc": "\u011C", "gcirc": "\u011D", "Gcy": "\u0413", "gcy": "\u0433", "Gdot": "\u0120", "gdot": "\u0121", "ge": "\u2265", "gE": "\u2267", "gEl": "\u2A8C", "gel": "\u22DB", "geq": "\u2265", "geqq": "\u2267", "geqslant": "\u2A7E", "gescc": "\u2AA9", "ges": "\u2A7E", "gesdot": "\u2A80", "gesdoto": "\u2A82", "gesdotol": "\u2A84", "gesl": "\u22DB\uFE00", "gesles": "\u2A94", "Gfr": "\uD835\uDD0A", "gfr": "\uD835\uDD24", "gg": "\u226B", "Gg": "\u22D9", "ggg": "\u22D9", "gimel": "\u2137", "GJcy": "\u0403", "gjcy": "\u0453", "gla": "\u2AA5", "gl": "\u2277", "glE": "\u2A92", "glj": "\u2AA4", "gnap": "\u2A8A", "gnapprox": "\u2A8A", "gne": "\u2A88", "gnE": "\u2269", "gneq": "\u2A88", "gneqq": "\u2269", "gnsim": "\u22E7", "Gopf": "\uD835\uDD3E", "gopf": "\uD835\uDD58", "grave": "`", "GreaterEqual": "\u2265", "GreaterEqualLess": "\u22DB", "GreaterFullEqual": "\u2267", "GreaterGreater": "\u2AA2", "GreaterLess": "\u2277", "GreaterSlantEqual": "\u2A7E", "GreaterTilde": "\u2273", "Gscr": "\uD835\uDCA2", "gscr": "\u210A", "gsim": "\u2273", "gsime": "\u2A8E", "gsiml": "\u2A90", "gtcc": "\u2AA7", "gtcir": "\u2A7A", "gt": ">", "GT": ">", "Gt": "\u226B", "gtdot": "\u22D7", "gtlPar": "\u2995", "gtquest": "\u2A7C", "gtrapprox": "\u2A86", "gtrarr": "\u2978", "gtrdot": "\u22D7", "gtreqless": "\u22DB", "gtreqqless": "\u2A8C", "gtrless": "\u2277", "gtrsim": "\u2273", "gvertneqq": "\u2269\uFE00", "gvnE": "\u2269\uFE00", "Hacek": "\u02C7", "hairsp": "\u200A", "half": "\u00BD", "hamilt": "\u210B", "HARDcy": "\u042A", "hardcy": "\u044A", "harrcir": "\u2948", "harr": "\u2194", "hArr": "\u21D4", "harrw": "\u21AD", "Hat": "^", "hbar": "\u210F", "Hcirc": "\u0124", "hcirc": "\u0125", "hearts": "\u2665", "heartsuit": "\u2665", "hellip": "\u2026", "hercon": "\u22B9", "hfr": "\uD835\uDD25", "Hfr": "\u210C", "HilbertSpace": "\u210B", "hksearow": "\u2925", "hkswarow": "\u2926", "hoarr": "\u21FF", "homtht": "\u223B", "hookleftarrow": "\u21A9", "hookrightarrow": "\u21AA", "hopf": "\uD835\uDD59", "Hopf": "\u210D", "horbar": "\u2015", "HorizontalLine": "\u2500", "hscr": "\uD835\uDCBD", "Hscr": "\u210B", "hslash": "\u210F", "Hstrok": "\u0126", "hstrok": "\u0127", "HumpDownHump": "\u224E", "HumpEqual": "\u224F", "hybull": "\u2043", "hyphen": "\u2010", "Iacute": "\u00CD", "iacute": "\u00ED", "ic": "\u2063", "Icirc": "\u00CE", "icirc": "\u00EE", "Icy": "\u0418", "icy": "\u0438", "Idot": "\u0130", "IEcy": "\u0415", "iecy": "\u0435", "iexcl": "\u00A1", "iff": "\u21D4", "ifr": "\uD835\uDD26", "Ifr": "\u2111", "Igrave": "\u00CC", "igrave": "\u00EC", "ii": "\u2148", "iiiint": "\u2A0C", "iiint": "\u222D", "iinfin": "\u29DC", "iiota": "\u2129", "IJlig": "\u0132", "ijlig": "\u0133", "Imacr": "\u012A", "imacr": "\u012B", "image": "\u2111", "ImaginaryI": "\u2148", "imagline": "\u2110", "imagpart": "\u2111", "imath": "\u0131", "Im": "\u2111", "imof": "\u22B7", "imped": "\u01B5", "Implies": "\u21D2", "incare": "\u2105", "in": "\u2208", "infin": "\u221E", "infintie": "\u29DD", "inodot": "\u0131", "intcal": "\u22BA", "int": "\u222B", "Int": "\u222C", "integers": "\u2124", "Integral": "\u222B", "intercal": "\u22BA", "Intersection": "\u22C2", "intlarhk": "\u2A17", "intprod": "\u2A3C", "InvisibleComma": "\u2063", "InvisibleTimes": "\u2062", "IOcy": "\u0401", "iocy": "\u0451", "Iogon": "\u012E", "iogon": "\u012F", "Iopf": "\uD835\uDD40", "iopf": "\uD835\uDD5A", "Iota": "\u0399", "iota": "\u03B9", "iprod": "\u2A3C", "iquest": "\u00BF", "iscr": "\uD835\uDCBE", "Iscr": "\u2110", "isin": "\u2208", "isindot": "\u22F5", "isinE": "\u22F9", "isins": "\u22F4", "isinsv": "\u22F3", "isinv": "\u2208", "it": "\u2062", "Itilde": "\u0128", "itilde": "\u0129", "Iukcy": "\u0406", "iukcy": "\u0456", "Iuml": "\u00CF", "iuml": "\u00EF", "Jcirc": "\u0134", "jcirc": "\u0135", "Jcy": "\u0419", "jcy": "\u0439", "Jfr": "\uD835\uDD0D", "jfr": "\uD835\uDD27", "jmath": "\u0237", "Jopf": "\uD835\uDD41", "jopf": "\uD835\uDD5B", "Jscr": "\uD835\uDCA5", "jscr": "\uD835\uDCBF", "Jsercy": "\u0408", "jsercy": "\u0458", "Jukcy": "\u0404", "jukcy": "\u0454", "Kappa": "\u039A", "kappa": "\u03BA", "kappav": "\u03F0", "Kcedil": "\u0136", "kcedil": "\u0137", "Kcy": "\u041A", "kcy": "\u043A", "Kfr": "\uD835\uDD0E", "kfr": "\uD835\uDD28", "kgreen": "\u0138", "KHcy": "\u0425", "khcy": "\u0445", "KJcy": "\u040C", "kjcy": "\u045C", "Kopf": "\uD835\uDD42", "kopf": "\uD835\uDD5C", "Kscr": "\uD835\uDCA6", "kscr": "\uD835\uDCC0", "lAarr": "\u21DA", "Lacute": "\u0139", "lacute": "\u013A", "laemptyv": "\u29B4", "lagran": "\u2112", "Lambda": "\u039B", "lambda": "\u03BB", "lang": "\u27E8", "Lang": "\u27EA", "langd": "\u2991", "langle": "\u27E8", "lap": "\u2A85", "Laplacetrf": "\u2112", "laquo": "\u00AB", "larrb": "\u21E4", "larrbfs": "\u291F", "larr": "\u2190", "Larr": "\u219E", "lArr": "\u21D0", "larrfs": "\u291D", "larrhk": "\u21A9", "larrlp": "\u21AB", "larrpl": "\u2939", "larrsim": "\u2973", "larrtl": "\u21A2", "latail": "\u2919", "lAtail": "\u291B", "lat": "\u2AAB", "late": "\u2AAD", "lates": "\u2AAD\uFE00", "lbarr": "\u290C", "lBarr": "\u290E", "lbbrk": "\u2772", "lbrace": "{", "lbrack": "[", "lbrke": "\u298B", "lbrksld": "\u298F", "lbrkslu": "\u298D", "Lcaron": "\u013D", "lcaron": "\u013E", "Lcedil": "\u013B", "lcedil": "\u013C", "lceil": "\u2308", "lcub": "{", "Lcy": "\u041B", "lcy": "\u043B", "ldca": "\u2936", "ldquo": "\u201C", "ldquor": "\u201E", "ldrdhar": "\u2967", "ldrushar": "\u294B", "ldsh": "\u21B2", "le": "\u2264", "lE": "\u2266", "LeftAngleBracket": "\u27E8", "LeftArrowBar": "\u21E4", "leftarrow": "\u2190", "LeftArrow": "\u2190", "Leftarrow": "\u21D0", "LeftArrowRightArrow": "\u21C6", "leftarrowtail": "\u21A2", "LeftCeiling": "\u2308", "LeftDoubleBracket": "\u27E6", "LeftDownTeeVector": "\u2961", "LeftDownVectorBar": "\u2959", "LeftDownVector": "\u21C3", "LeftFloor": "\u230A", "leftharpoondown": "\u21BD", "leftharpoonup": "\u21BC", "leftleftarrows": "\u21C7", "leftrightarrow": "\u2194", "LeftRightArrow": "\u2194", "Leftrightarrow": "\u21D4", "leftrightarrows": "\u21C6", "leftrightharpoons": "\u21CB", "leftrightsquigarrow": "\u21AD", "LeftRightVector": "\u294E", "LeftTeeArrow": "\u21A4", "LeftTee": "\u22A3", "LeftTeeVector": "\u295A", "leftthreetimes": "\u22CB", "LeftTriangleBar": "\u29CF", "LeftTriangle": "\u22B2", "LeftTriangleEqual": "\u22B4", "LeftUpDownVector": "\u2951", "LeftUpTeeVector": "\u2960", "LeftUpVectorBar": "\u2958", "LeftUpVector": "\u21BF", "LeftVectorBar": "\u2952", "LeftVector": "\u21BC", "lEg": "\u2A8B", "leg": "\u22DA", "leq": "\u2264", "leqq": "\u2266", "leqslant": "\u2A7D", "lescc": "\u2AA8", "les": "\u2A7D", "lesdot": "\u2A7F", "lesdoto": "\u2A81", "lesdotor": "\u2A83", "lesg": "\u22DA\uFE00", "lesges": "\u2A93", "lessapprox": "\u2A85", "lessdot": "\u22D6", "lesseqgtr": "\u22DA", "lesseqqgtr": "\u2A8B", "LessEqualGreater": "\u22DA", "LessFullEqual": "\u2266", "LessGreater": "\u2276", "lessgtr": "\u2276", "LessLess": "\u2AA1", "lesssim": "\u2272", "LessSlantEqual": "\u2A7D", "LessTilde": "\u2272", "lfisht": "\u297C", "lfloor": "\u230A", "Lfr": "\uD835\uDD0F", "lfr": "\uD835\uDD29", "lg": "\u2276", "lgE": "\u2A91", "lHar": "\u2962", "lhard": "\u21BD", "lharu": "\u21BC", "lharul": "\u296A", "lhblk": "\u2584", "LJcy": "\u0409", "ljcy": "\u0459", "llarr": "\u21C7", "ll": "\u226A", "Ll": "\u22D8", "llcorner": "\u231E", "Lleftarrow": "\u21DA", "llhard": "\u296B", "lltri": "\u25FA", "Lmidot": "\u013F", "lmidot": "\u0140", "lmoustache": "\u23B0", "lmoust": "\u23B0", "lnap": "\u2A89", "lnapprox": "\u2A89", "lne": "\u2A87", "lnE": "\u2268", "lneq": "\u2A87", "lneqq": "\u2268", "lnsim": "\u22E6", "loang": "\u27EC", "loarr": "\u21FD", "lobrk": "\u27E6", "longleftarrow": "\u27F5", "LongLeftArrow": "\u27F5", "Longleftarrow": "\u27F8", "longleftrightarrow": "\u27F7", "LongLeftRightArrow": "\u27F7", "Longleftrightarrow": "\u27FA", "longmapsto": "\u27FC", "longrightarrow": "\u27F6", "LongRightArrow": "\u27F6", "Longrightarrow": "\u27F9", "looparrowleft": "\u21AB", "looparrowright": "\u21AC", "lopar": "\u2985", "Lopf": "\uD835\uDD43", "lopf": "\uD835\uDD5D", "loplus": "\u2A2D", "lotimes": "\u2A34", "lowast": "\u2217", "lowbar": "_", "LowerLeftArrow": "\u2199", "LowerRightArrow": "\u2198", "loz": "\u25CA", "lozenge": "\u25CA", "lozf": "\u29EB", "lpar": "(", "lparlt": "\u2993", "lrarr": "\u21C6", "lrcorner": "\u231F", "lrhar": "\u21CB", "lrhard": "\u296D", "lrm": "\u200E", "lrtri": "\u22BF", "lsaquo": "\u2039", "lscr": "\uD835\uDCC1", "Lscr": "\u2112", "lsh": "\u21B0", "Lsh": "\u21B0", "lsim": "\u2272", "lsime": "\u2A8D", "lsimg": "\u2A8F", "lsqb": "[", "lsquo": "\u2018", "lsquor": "\u201A", "Lstrok": "\u0141", "lstrok": "\u0142", "ltcc": "\u2AA6", "ltcir": "\u2A79", "lt": "<", "LT": "<", "Lt": "\u226A", "ltdot": "\u22D6", "lthree": "\u22CB", "ltimes": "\u22C9", "ltlarr": "\u2976", "ltquest": "\u2A7B", "ltri": "\u25C3", "ltrie": "\u22B4", "ltrif": "\u25C2", "ltrPar": "\u2996", "lurdshar": "\u294A", "luruhar": "\u2966", "lvertneqq": "\u2268\uFE00", "lvnE": "\u2268\uFE00", "macr": "\u00AF", "male": "\u2642", "malt": "\u2720", "maltese": "\u2720", "Map": "\u2905", "map": "\u21A6", "mapsto": "\u21A6", "mapstodown": "\u21A7", "mapstoleft": "\u21A4", "mapstoup": "\u21A5", "marker": "\u25AE", "mcomma": "\u2A29", "Mcy": "\u041C", "mcy": "\u043C", "mdash": "\u2014", "mDDot": "\u223A", "measuredangle": "\u2221", "MediumSpace": "\u205F", "Mellintrf": "\u2133", "Mfr": "\uD835\uDD10", "mfr": "\uD835\uDD2A", "mho": "\u2127", "micro": "\u00B5", "midast": "*", "midcir": "\u2AF0", "mid": "\u2223", "middot": "\u00B7", "minusb": "\u229F", "minus": "\u2212", "minusd": "\u2238", "minusdu": "\u2A2A", "MinusPlus": "\u2213", "mlcp": "\u2ADB", "mldr": "\u2026", "mnplus": "\u2213", "models": "\u22A7", "Mopf": "\uD835\uDD44", "mopf": "\uD835\uDD5E", "mp": "\u2213", "mscr": "\uD835\uDCC2", "Mscr": "\u2133", "mstpos": "\u223E", "Mu": "\u039C", "mu": "\u03BC", "multimap": "\u22B8", "mumap": "\u22B8", "nabla": "\u2207", "Nacute": "\u0143", "nacute": "\u0144", "nang": "\u2220\u20D2", "nap": "\u2249", "napE": "\u2A70\u0338", "napid": "\u224B\u0338", "napos": "\u0149", "napprox": "\u2249", "natural": "\u266E", "naturals": "\u2115", "natur": "\u266E", "nbsp": "\u00A0", "nbump": "\u224E\u0338", "nbumpe": "\u224F\u0338", "ncap": "\u2A43", "Ncaron": "\u0147", "ncaron": "\u0148", "Ncedil": "\u0145", "ncedil": "\u0146", "ncong": "\u2247", "ncongdot": "\u2A6D\u0338", "ncup": "\u2A42", "Ncy": "\u041D", "ncy": "\u043D", "ndash": "\u2013", "nearhk": "\u2924", "nearr": "\u2197", "neArr": "\u21D7", "nearrow": "\u2197", "ne": "\u2260", "nedot": "\u2250\u0338", "NegativeMediumSpace": "\u200B", "NegativeThickSpace": "\u200B", "NegativeThinSpace": "\u200B", "NegativeVeryThinSpace": "\u200B", "nequiv": "\u2262", "nesear": "\u2928", "nesim": "\u2242\u0338", "NestedGreaterGreater": "\u226B", "NestedLessLess": "\u226A", "NewLine": "\n", "nexist": "\u2204", "nexists": "\u2204", "Nfr": "\uD835\uDD11", "nfr": "\uD835\uDD2B", "ngE": "\u2267\u0338", "nge": "\u2271", "ngeq": "\u2271", "ngeqq": "\u2267\u0338", "ngeqslant": "\u2A7E\u0338", "nges": "\u2A7E\u0338", "nGg": "\u22D9\u0338", "ngsim": "\u2275", "nGt": "\u226B\u20D2", "ngt": "\u226F", "ngtr": "\u226F", "nGtv": "\u226B\u0338", "nharr": "\u21AE", "nhArr": "\u21CE", "nhpar": "\u2AF2", "ni": "\u220B", "nis": "\u22FC", "nisd": "\u22FA", "niv": "\u220B", "NJcy": "\u040A", "njcy": "\u045A", "nlarr": "\u219A", "nlArr": "\u21CD", "nldr": "\u2025", "nlE": "\u2266\u0338", "nle": "\u2270", "nleftarrow": "\u219A", "nLeftarrow": "\u21CD", "nleftrightarrow": "\u21AE", "nLeftrightarrow": "\u21CE", "nleq": "\u2270", "nleqq": "\u2266\u0338", "nleqslant": "\u2A7D\u0338", "nles": "\u2A7D\u0338", "nless": "\u226E", "nLl": "\u22D8\u0338", "nlsim": "\u2274", "nLt": "\u226A\u20D2", "nlt": "\u226E", "nltri": "\u22EA", "nltrie": "\u22EC", "nLtv": "\u226A\u0338", "nmid": "\u2224", "NoBreak": "\u2060", "NonBreakingSpace": "\u00A0", "nopf": "\uD835\uDD5F", "Nopf": "\u2115", "Not": "\u2AEC", "not": "\u00AC", "NotCongruent": "\u2262", "NotCupCap": "\u226D", "NotDoubleVerticalBar": "\u2226", "NotElement": "\u2209", "NotEqual": "\u2260", "NotEqualTilde": "\u2242\u0338", "NotExists": "\u2204", "NotGreater": "\u226F", "NotGreaterEqual": "\u2271", "NotGreaterFullEqual": "\u2267\u0338", "NotGreaterGreater": "\u226B\u0338", "NotGreaterLess": "\u2279", "NotGreaterSlantEqual": "\u2A7E\u0338", "NotGreaterTilde": "\u2275", "NotHumpDownHump": "\u224E\u0338", "NotHumpEqual": "\u224F\u0338", "notin": "\u2209", "notindot": "\u22F5\u0338", "notinE": "\u22F9\u0338", "notinva": "\u2209", "notinvb": "\u22F7", "notinvc": "\u22F6", "NotLeftTriangleBar": "\u29CF\u0338", "NotLeftTriangle": "\u22EA", "NotLeftTriangleEqual": "\u22EC", "NotLess": "\u226E", "NotLessEqual": "\u2270", "NotLessGreater": "\u2278", "NotLessLess": "\u226A\u0338", "NotLessSlantEqual": "\u2A7D\u0338", "NotLessTilde": "\u2274", "NotNestedGreaterGreater": "\u2AA2\u0338", "NotNestedLessLess": "\u2AA1\u0338", "notni": "\u220C", "notniva": "\u220C", "notnivb": "\u22FE", "notnivc": "\u22FD", "NotPrecedes": "\u2280", "NotPrecedesEqual": "\u2AAF\u0338", "NotPrecedesSlantEqual": "\u22E0", "NotReverseElement": "\u220C", "NotRightTriangleBar": "\u29D0\u0338", "NotRightTriangle": "\u22EB", "NotRightTriangleEqual": "\u22ED", "NotSquareSubset": "\u228F\u0338", "NotSquareSubsetEqual": "\u22E2", "NotSquareSuperset": "\u2290\u0338", "NotSquareSupersetEqual": "\u22E3", "NotSubset": "\u2282\u20D2", "NotSubsetEqual": "\u2288", "NotSucceeds": "\u2281", "NotSucceedsEqual": "\u2AB0\u0338", "NotSucceedsSlantEqual": "\u22E1", "NotSucceedsTilde": "\u227F\u0338", "NotSuperset": "\u2283\u20D2", "NotSupersetEqual": "\u2289", "NotTilde": "\u2241", "NotTildeEqual": "\u2244", "NotTildeFullEqual": "\u2247", "NotTildeTilde": "\u2249", "NotVerticalBar": "\u2224", "nparallel": "\u2226", "npar": "\u2226", "nparsl": "\u2AFD\u20E5", "npart": "\u2202\u0338", "npolint": "\u2A14", "npr": "\u2280", "nprcue": "\u22E0", "nprec": "\u2280", "npreceq": "\u2AAF\u0338", "npre": "\u2AAF\u0338", "nrarrc": "\u2933\u0338", "nrarr": "\u219B", "nrArr": "\u21CF", "nrarrw": "\u219D\u0338", "nrightarrow": "\u219B", "nRightarrow": "\u21CF", "nrtri": "\u22EB", "nrtrie": "\u22ED", "nsc": "\u2281", "nsccue": "\u22E1", "nsce": "\u2AB0\u0338", "Nscr": "\uD835\uDCA9", "nscr": "\uD835\uDCC3", "nshortmid": "\u2224", "nshortparallel": "\u2226", "nsim": "\u2241", "nsime": "\u2244", "nsimeq": "\u2244", "nsmid": "\u2224", "nspar": "\u2226", "nsqsube": "\u22E2", "nsqsupe": "\u22E3", "nsub": "\u2284", "nsubE": "\u2AC5\u0338", "nsube": "\u2288", "nsubset": "\u2282\u20D2", "nsubseteq": "\u2288", "nsubseteqq": "\u2AC5\u0338", "nsucc": "\u2281", "nsucceq": "\u2AB0\u0338", "nsup": "\u2285", "nsupE": "\u2AC6\u0338", "nsupe": "\u2289", "nsupset": "\u2283\u20D2", "nsupseteq": "\u2289", "nsupseteqq": "\u2AC6\u0338", "ntgl": "\u2279", "Ntilde": "\u00D1", "ntilde": "\u00F1", "ntlg": "\u2278", "ntriangleleft": "\u22EA", "ntrianglelefteq": "\u22EC", "ntriangleright": "\u22EB", "ntrianglerighteq": "\u22ED", "Nu": "\u039D", "nu": "\u03BD", "num": "#", "numero": "\u2116", "numsp": "\u2007", "nvap": "\u224D\u20D2", "nvdash": "\u22AC", "nvDash": "\u22AD", "nVdash": "\u22AE", "nVDash": "\u22AF", "nvge": "\u2265\u20D2", "nvgt": ">\u20D2", "nvHarr": "\u2904", "nvinfin": "\u29DE", "nvlArr": "\u2902", "nvle": "\u2264\u20D2", "nvlt": "<\u20D2", "nvltrie": "\u22B4\u20D2", "nvrArr": "\u2903", "nvrtrie": "\u22B5\u20D2", "nvsim": "\u223C\u20D2", "nwarhk": "\u2923", "nwarr": "\u2196", "nwArr": "\u21D6", "nwarrow": "\u2196", "nwnear": "\u2927", "Oacute": "\u00D3", "oacute": "\u00F3", "oast": "\u229B", "Ocirc": "\u00D4", "ocirc": "\u00F4", "ocir": "\u229A", "Ocy": "\u041E", "ocy": "\u043E", "odash": "\u229D", "Odblac": "\u0150", "odblac": "\u0151", "odiv": "\u2A38", "odot": "\u2299", "odsold": "\u29BC", "OElig": "\u0152", "oelig": "\u0153", "ofcir": "\u29BF", "Ofr": "\uD835\uDD12", "ofr": "\uD835\uDD2C", "ogon": "\u02DB", "Ograve": "\u00D2", "ograve": "\u00F2", "ogt": "\u29C1", "ohbar": "\u29B5", "ohm": "\u03A9", "oint": "\u222E", "olarr": "\u21BA", "olcir": "\u29BE", "olcross": "\u29BB", "oline": "\u203E", "olt": "\u29C0", "Omacr": "\u014C", "omacr": "\u014D", "Omega": "\u03A9", "omega": "\u03C9", "Omicron": "\u039F", "omicron": "\u03BF", "omid": "\u29B6", "ominus": "\u2296", "Oopf": "\uD835\uDD46", "oopf": "\uD835\uDD60", "opar": "\u29B7", "OpenCurlyDoubleQuote": "\u201C", "OpenCurlyQuote": "\u2018", "operp": "\u29B9", "oplus": "\u2295", "orarr": "\u21BB", "Or": "\u2A54", "or": "\u2228", "ord": "\u2A5D", "order": "\u2134", "orderof": "\u2134", "ordf": "\u00AA", "ordm": "\u00BA", "origof": "\u22B6", "oror": "\u2A56", "orslope": "\u2A57", "orv": "\u2A5B", "oS": "\u24C8", "Oscr": "\uD835\uDCAA", "oscr": "\u2134", "Oslash": "\u00D8", "oslash": "\u00F8", "osol": "\u2298", "Otilde": "\u00D5", "otilde": "\u00F5", "otimesas": "\u2A36", "Otimes": "\u2A37", "otimes": "\u2297", "Ouml": "\u00D6", "ouml": "\u00F6", "ovbar": "\u233D", "OverBar": "\u203E", "OverBrace": "\u23DE", "OverBracket": "\u23B4", "OverParenthesis": "\u23DC", "para": "\u00B6", "parallel": "\u2225", "par": "\u2225", "parsim": "\u2AF3", "parsl": "\u2AFD", "part": "\u2202", "PartialD": "\u2202", "Pcy": "\u041F", "pcy": "\u043F", "percnt": "%", "period": ".", "permil": "\u2030", "perp": "\u22A5", "pertenk": "\u2031", "Pfr": "\uD835\uDD13", "pfr": "\uD835\uDD2D", "Phi": "\u03A6", "phi": "\u03C6", "phiv": "\u03D5", "phmmat": "\u2133", "phone": "\u260E", "Pi": "\u03A0", "pi": "\u03C0", "pitchfork": "\u22D4", "piv": "\u03D6", "planck": "\u210F", "planckh": "\u210E", "plankv": "\u210F", "plusacir": "\u2A23", "plusb": "\u229E", "pluscir": "\u2A22", "plus": "+", "plusdo": "\u2214", "plusdu": "\u2A25", "pluse": "\u2A72", "PlusMinus": "\u00B1", "plusmn": "\u00B1", "plussim": "\u2A26", "plustwo": "\u2A27", "pm": "\u00B1", "Poincareplane": "\u210C", "pointint": "\u2A15", "popf": "\uD835\uDD61", "Popf": "\u2119", "pound": "\u00A3", "prap": "\u2AB7", "Pr": "\u2ABB", "pr": "\u227A", "prcue": "\u227C", "precapprox": "\u2AB7", "prec": "\u227A", "preccurlyeq": "\u227C", "Precedes": "\u227A", "PrecedesEqual": "\u2AAF", "PrecedesSlantEqual": "\u227C", "PrecedesTilde": "\u227E", "preceq": "\u2AAF", "precnapprox": "\u2AB9", "precneqq": "\u2AB5", "precnsim": "\u22E8", "pre": "\u2AAF", "prE": "\u2AB3", "precsim": "\u227E", "prime": "\u2032", "Prime": "\u2033", "primes": "\u2119", "prnap": "\u2AB9", "prnE": "\u2AB5", "prnsim": "\u22E8", "prod": "\u220F", "Product": "\u220F", "profalar": "\u232E", "profline": "\u2312", "profsurf": "\u2313", "prop": "\u221D", "Proportional": "\u221D", "Proportion": "\u2237", "propto": "\u221D", "prsim": "\u227E", "prurel": "\u22B0", "Pscr": "\uD835\uDCAB", "pscr": "\uD835\uDCC5", "Psi": "\u03A8", "psi": "\u03C8", "puncsp": "\u2008", "Qfr": "\uD835\uDD14", "qfr": "\uD835\uDD2E", "qint": "\u2A0C", "qopf": "\uD835\uDD62", "Qopf": "\u211A", "qprime": "\u2057", "Qscr": "\uD835\uDCAC", "qscr": "\uD835\uDCC6", "quaternions": "\u210D", "quatint": "\u2A16", "quest": "?", "questeq": "\u225F", "quot": "\"", "QUOT": "\"", "rAarr": "\u21DB", "race": "\u223D\u0331", "Racute": "\u0154", "racute": "\u0155", "radic": "\u221A", "raemptyv": "\u29B3", "rang": "\u27E9", "Rang": "\u27EB", "rangd": "\u2992", "range": "\u29A5", "rangle": "\u27E9", "raquo": "\u00BB", "rarrap": "\u2975", "rarrb": "\u21E5", "rarrbfs": "\u2920", "rarrc": "\u2933", "rarr": "\u2192", "Rarr": "\u21A0", "rArr": "\u21D2", "rarrfs": "\u291E", "rarrhk": "\u21AA", "rarrlp": "\u21AC", "rarrpl": "\u2945", "rarrsim": "\u2974", "Rarrtl": "\u2916", "rarrtl": "\u21A3", "rarrw": "\u219D", "ratail": "\u291A", "rAtail": "\u291C", "ratio": "\u2236", "rationals": "\u211A", "rbarr": "\u290D", "rBarr": "\u290F", "RBarr": "\u2910", "rbbrk": "\u2773", "rbrace": "}", "rbrack": "]", "rbrke": "\u298C", "rbrksld": "\u298E", "rbrkslu": "\u2990", "Rcaron": "\u0158", "rcaron": "\u0159", "Rcedil": "\u0156", "rcedil": "\u0157", "rceil": "\u2309", "rcub": "}", "Rcy": "\u0420", "rcy": "\u0440", "rdca": "\u2937", "rdldhar": "\u2969", "rdquo": "\u201D", "rdquor": "\u201D", "rdsh": "\u21B3", "real": "\u211C", "realine": "\u211B", "realpart": "\u211C", "reals": "\u211D", "Re": "\u211C", "rect": "\u25AD", "reg": "\u00AE", "REG": "\u00AE", "ReverseElement": "\u220B", "ReverseEquilibrium": "\u21CB", "ReverseUpEquilibrium": "\u296F", "rfisht": "\u297D", "rfloor": "\u230B", "rfr": "\uD835\uDD2F", "Rfr": "\u211C", "rHar": "\u2964", "rhard": "\u21C1", "rharu": "\u21C0", "rharul": "\u296C", "Rho": "\u03A1", "rho": "\u03C1", "rhov": "\u03F1", "RightAngleBracket": "\u27E9", "RightArrowBar": "\u21E5", "rightarrow": "\u2192", "RightArrow": "\u2192", "Rightarrow": "\u21D2", "RightArrowLeftArrow": "\u21C4", "rightarrowtail": "\u21A3", "RightCeiling": "\u2309", "RightDoubleBracket": "\u27E7", "RightDownTeeVector": "\u295D", "RightDownVectorBar": "\u2955", "RightDownVector": "\u21C2", "RightFloor": "\u230B", "rightharpoondown": "\u21C1", "rightharpoonup": "\u21C0", "rightleftarrows": "\u21C4", "rightleftharpoons": "\u21CC", "rightrightarrows": "\u21C9", "rightsquigarrow": "\u219D", "RightTeeArrow": "\u21A6", "RightTee": "\u22A2", "RightTeeVector": "\u295B", "rightthreetimes": "\u22CC", "RightTriangleBar": "\u29D0", "RightTriangle": "\u22B3", "RightTriangleEqual": "\u22B5", "RightUpDownVector": "\u294F", "RightUpTeeVector": "\u295C", "RightUpVectorBar": "\u2954", "RightUpVector": "\u21BE", "RightVectorBar": "\u2953", "RightVector": "\u21C0", "ring": "\u02DA", "risingdotseq": "\u2253", "rlarr": "\u21C4", "rlhar": "\u21CC", "rlm": "\u200F", "rmoustache": "\u23B1", "rmoust": "\u23B1", "rnmid": "\u2AEE", "roang": "\u27ED", "roarr": "\u21FE", "robrk": "\u27E7", "ropar": "\u2986", "ropf": "\uD835\uDD63", "Ropf": "\u211D", "roplus": "\u2A2E", "rotimes": "\u2A35", "RoundImplies": "\u2970", "rpar": ")", "rpargt": "\u2994", "rppolint": "\u2A12", "rrarr": "\u21C9", "Rrightarrow": "\u21DB", "rsaquo": "\u203A", "rscr": "\uD835\uDCC7", "Rscr": "\u211B", "rsh": "\u21B1", "Rsh": "\u21B1", "rsqb": "]", "rsquo": "\u2019", "rsquor": "\u2019", "rthree": "\u22CC", "rtimes": "\u22CA", "rtri": "\u25B9", "rtrie": "\u22B5", "rtrif": "\u25B8", "rtriltri": "\u29CE", "RuleDelayed": "\u29F4", "ruluhar": "\u2968", "rx": "\u211E", "Sacute": "\u015A", "sacute": "\u015B", "sbquo": "\u201A", "scap": "\u2AB8", "Scaron": "\u0160", "scaron": "\u0161", "Sc": "\u2ABC", "sc": "\u227B", "sccue": "\u227D", "sce": "\u2AB0", "scE": "\u2AB4", "Scedil": "\u015E", "scedil": "\u015F", "Scirc": "\u015C", "scirc": "\u015D", "scnap": "\u2ABA", "scnE": "\u2AB6", "scnsim": "\u22E9", "scpolint": "\u2A13", "scsim": "\u227F", "Scy": "\u0421", "scy": "\u0441", "sdotb": "\u22A1", "sdot": "\u22C5", "sdote": "\u2A66", "searhk": "\u2925", "searr": "\u2198", "seArr": "\u21D8", "searrow": "\u2198", "sect": "\u00A7", "semi": ";", "seswar": "\u2929", "setminus": "\u2216", "setmn": "\u2216", "sext": "\u2736", "Sfr": "\uD835\uDD16", "sfr": "\uD835\uDD30", "sfrown": "\u2322", "sharp": "\u266F", "SHCHcy": "\u0429", "shchcy": "\u0449", "SHcy": "\u0428", "shcy": "\u0448", "ShortDownArrow": "\u2193", "ShortLeftArrow": "\u2190", "shortmid": "\u2223", "shortparallel": "\u2225", "ShortRightArrow": "\u2192", "ShortUpArrow": "\u2191", "shy": "\u00AD", "Sigma": "\u03A3", "sigma": "\u03C3", "sigmaf": "\u03C2", "sigmav": "\u03C2", "sim": "\u223C", "simdot": "\u2A6A", "sime": "\u2243", "simeq": "\u2243", "simg": "\u2A9E", "simgE": "\u2AA0", "siml": "\u2A9D", "simlE": "\u2A9F", "simne": "\u2246", "simplus": "\u2A24", "simrarr": "\u2972", "slarr": "\u2190", "SmallCircle": "\u2218", "smallsetminus": "\u2216", "smashp": "\u2A33", "smeparsl": "\u29E4", "smid": "\u2223", "smile": "\u2323", "smt": "\u2AAA", "smte": "\u2AAC", "smtes": "\u2AAC\uFE00", "SOFTcy": "\u042C", "softcy": "\u044C", "solbar": "\u233F", "solb": "\u29C4", "sol": "/", "Sopf": "\uD835\uDD4A", "sopf": "\uD835\uDD64", "spades": "\u2660", "spadesuit": "\u2660", "spar": "\u2225", "sqcap": "\u2293", "sqcaps": "\u2293\uFE00", "sqcup": "\u2294", "sqcups": "\u2294\uFE00", "Sqrt": "\u221A", "sqsub": "\u228F", "sqsube": "\u2291", "sqsubset": "\u228F", "sqsubseteq": "\u2291", "sqsup": "\u2290", "sqsupe": "\u2292", "sqsupset": "\u2290", "sqsupseteq": "\u2292", "square": "\u25A1", "Square": "\u25A1", "SquareIntersection": "\u2293", "SquareSubset": "\u228F", "SquareSubsetEqual": "\u2291", "SquareSuperset": "\u2290", "SquareSupersetEqual": "\u2292", "SquareUnion": "\u2294", "squarf": "\u25AA", "squ": "\u25A1", "squf": "\u25AA", "srarr": "\u2192", "Sscr": "\uD835\uDCAE", "sscr": "\uD835\uDCC8", "ssetmn": "\u2216", "ssmile": "\u2323", "sstarf": "\u22C6", "Star": "\u22C6", "star": "\u2606", "starf": "\u2605", "straightepsilon": "\u03F5", "straightphi": "\u03D5", "strns": "\u00AF", "sub": "\u2282", "Sub": "\u22D0", "subdot": "\u2ABD", "subE": "\u2AC5", "sube": "\u2286", "subedot": "\u2AC3", "submult": "\u2AC1", "subnE": "\u2ACB", "subne": "\u228A", "subplus": "\u2ABF", "subrarr": "\u2979", "subset": "\u2282", "Subset": "\u22D0", "subseteq": "\u2286", "subseteqq": "\u2AC5", "SubsetEqual": "\u2286", "subsetneq": "\u228A", "subsetneqq": "\u2ACB", "subsim": "\u2AC7", "subsub": "\u2AD5", "subsup": "\u2AD3", "succapprox": "\u2AB8", "succ": "\u227B", "succcurlyeq": "\u227D", "Succeeds": "\u227B", "SucceedsEqual": "\u2AB0", "SucceedsSlantEqual": "\u227D", "SucceedsTilde": "\u227F", "succeq": "\u2AB0", "succnapprox": "\u2ABA", "succneqq": "\u2AB6", "succnsim": "\u22E9", "succsim": "\u227F", "SuchThat": "\u220B", "sum": "\u2211", "Sum": "\u2211", "sung": "\u266A", "sup1": "\u00B9", "sup2": "\u00B2", "sup3": "\u00B3", "sup": "\u2283", "Sup": "\u22D1", "supdot": "\u2ABE", "supdsub": "\u2AD8", "supE": "\u2AC6", "supe": "\u2287", "supedot": "\u2AC4", "Superset": "\u2283", "SupersetEqual": "\u2287", "suphsol": "\u27C9", "suphsub": "\u2AD7", "suplarr": "\u297B", "supmult": "\u2AC2", "supnE": "\u2ACC", "supne": "\u228B", "supplus": "\u2AC0", "supset": "\u2283", "Supset": "\u22D1", "supseteq": "\u2287", "supseteqq": "\u2AC6", "supsetneq": "\u228B", "supsetneqq": "\u2ACC", "supsim": "\u2AC8", "supsub": "\u2AD4", "supsup": "\u2AD6", "swarhk": "\u2926", "swarr": "\u2199", "swArr": "\u21D9", "swarrow": "\u2199", "swnwar": "\u292A", "szlig": "\u00DF", "Tab": "\t", "target": "\u2316", "Tau": "\u03A4", "tau": "\u03C4", "tbrk": "\u23B4", "Tcaron": "\u0164", "tcaron": "\u0165", "Tcedil": "\u0162", "tcedil": "\u0163", "Tcy": "\u0422", "tcy": "\u0442", "tdot": "\u20DB", "telrec": "\u2315", "Tfr": "\uD835\uDD17", "tfr": "\uD835\uDD31", "there4": "\u2234", "therefore": "\u2234", "Therefore": "\u2234", "Theta": "\u0398", "theta": "\u03B8", "thetasym": "\u03D1", "thetav": "\u03D1", "thickapprox": "\u2248", "thicksim": "\u223C", "ThickSpace": "\u205F\u200A", "ThinSpace": "\u2009", "thinsp": "\u2009", "thkap": "\u2248", "thksim": "\u223C", "THORN": "\u00DE", "thorn": "\u00FE", "tilde": "\u02DC", "Tilde": "\u223C", "TildeEqual": "\u2243", "TildeFullEqual": "\u2245", "TildeTilde": "\u2248", "timesbar": "\u2A31", "timesb": "\u22A0", "times": "\u00D7", "timesd": "\u2A30", "tint": "\u222D", "toea": "\u2928", "topbot": "\u2336", "topcir": "\u2AF1", "top": "\u22A4", "Topf": "\uD835\uDD4B", "topf": "\uD835\uDD65", "topfork": "\u2ADA", "tosa": "\u2929", "tprime": "\u2034", "trade": "\u2122", "TRADE": "\u2122", "triangle": "\u25B5", "triangledown": "\u25BF", "triangleleft": "\u25C3", "trianglelefteq": "\u22B4", "triangleq": "\u225C", "triangleright": "\u25B9", "trianglerighteq": "\u22B5", "tridot": "\u25EC", "trie": "\u225C", "triminus": "\u2A3A", "TripleDot": "\u20DB", "triplus": "\u2A39", "trisb": "\u29CD", "tritime": "\u2A3B", "trpezium": "\u23E2", "Tscr": "\uD835\uDCAF", "tscr": "\uD835\uDCC9", "TScy": "\u0426", "tscy": "\u0446", "TSHcy": "\u040B", "tshcy": "\u045B", "Tstrok": "\u0166", "tstrok": "\u0167", "twixt": "\u226C", "twoheadleftarrow": "\u219E", "twoheadrightarrow": "\u21A0", "Uacute": "\u00DA", "uacute": "\u00FA", "uarr": "\u2191", "Uarr": "\u219F", "uArr": "\u21D1", "Uarrocir": "\u2949", "Ubrcy": "\u040E", "ubrcy": "\u045E", "Ubreve": "\u016C", "ubreve": "\u016D", "Ucirc": "\u00DB", "ucirc": "\u00FB", "Ucy": "\u0423", "ucy": "\u0443", "udarr": "\u21C5", "Udblac": "\u0170", "udblac": "\u0171", "udhar": "\u296E", "ufisht": "\u297E", "Ufr": "\uD835\uDD18", "ufr": "\uD835\uDD32", "Ugrave": "\u00D9", "ugrave": "\u00F9", "uHar": "\u2963", "uharl": "\u21BF", "uharr": "\u21BE", "uhblk": "\u2580", "ulcorn": "\u231C", "ulcorner": "\u231C", "ulcrop": "\u230F", "ultri": "\u25F8", "Umacr": "\u016A", "umacr": "\u016B", "uml": "\u00A8", "UnderBar": "_", "UnderBrace": "\u23DF", "UnderBracket": "\u23B5", "UnderParenthesis": "\u23DD", "Union": "\u22C3", "UnionPlus": "\u228E", "Uogon": "\u0172", "uogon": "\u0173", "Uopf": "\uD835\uDD4C", "uopf": "\uD835\uDD66", "UpArrowBar": "\u2912", "uparrow": "\u2191", "UpArrow": "\u2191", "Uparrow": "\u21D1", "UpArrowDownArrow": "\u21C5", "updownarrow": "\u2195", "UpDownArrow": "\u2195", "Updownarrow": "\u21D5", "UpEquilibrium": "\u296E", "upharpoonleft": "\u21BF", "upharpoonright": "\u21BE", "uplus": "\u228E", "UpperLeftArrow": "\u2196", "UpperRightArrow": "\u2197", "upsi": "\u03C5", "Upsi": "\u03D2", "upsih": "\u03D2", "Upsilon": "\u03A5", "upsilon": "\u03C5", "UpTeeArrow": "\u21A5", "UpTee": "\u22A5", "upuparrows": "\u21C8", "urcorn": "\u231D", "urcorner": "\u231D", "urcrop": "\u230E", "Uring": "\u016E", "uring": "\u016F", "urtri": "\u25F9", "Uscr": "\uD835\uDCB0", "uscr": "\uD835\uDCCA", "utdot": "\u22F0", "Utilde": "\u0168", "utilde": "\u0169", "utri": "\u25B5", "utrif": "\u25B4", "uuarr": "\u21C8", "Uuml": "\u00DC", "uuml": "\u00FC", "uwangle": "\u29A7", "vangrt": "\u299C", "varepsilon": "\u03F5", "varkappa": "\u03F0", "varnothing": "\u2205", "varphi": "\u03D5", "varpi": "\u03D6", "varpropto": "\u221D", "varr": "\u2195", "vArr": "\u21D5", "varrho": "\u03F1", "varsigma": "\u03C2", "varsubsetneq": "\u228A\uFE00", "varsubsetneqq": "\u2ACB\uFE00", "varsupsetneq": "\u228B\uFE00", "varsupsetneqq": "\u2ACC\uFE00", "vartheta": "\u03D1", "vartriangleleft": "\u22B2", "vartriangleright": "\u22B3", "vBar": "\u2AE8", "Vbar": "\u2AEB", "vBarv": "\u2AE9", "Vcy": "\u0412", "vcy": "\u0432", "vdash": "\u22A2", "vDash": "\u22A8", "Vdash": "\u22A9", "VDash": "\u22AB", "Vdashl": "\u2AE6", "veebar": "\u22BB", "vee": "\u2228", "Vee": "\u22C1", "veeeq": "\u225A", "vellip": "\u22EE", "verbar": "|", "Verbar": "\u2016", "vert": "|", "Vert": "\u2016", "VerticalBar": "\u2223", "VerticalLine": "|", "VerticalSeparator": "\u2758", "VerticalTilde": "\u2240", "VeryThinSpace": "\u200A", "Vfr": "\uD835\uDD19", "vfr": "\uD835\uDD33", "vltri": "\u22B2", "vnsub": "\u2282\u20D2", "vnsup": "\u2283\u20D2", "Vopf": "\uD835\uDD4D", "vopf": "\uD835\uDD67", "vprop": "\u221D", "vrtri": "\u22B3", "Vscr": "\uD835\uDCB1", "vscr": "\uD835\uDCCB", "vsubnE": "\u2ACB\uFE00", "vsubne": "\u228A\uFE00", "vsupnE": "\u2ACC\uFE00", "vsupne": "\u228B\uFE00", "Vvdash": "\u22AA", "vzigzag": "\u299A", "Wcirc": "\u0174", "wcirc": "\u0175", "wedbar": "\u2A5F", "wedge": "\u2227", "Wedge": "\u22C0", "wedgeq": "\u2259", "weierp": "\u2118", "Wfr": "\uD835\uDD1A", "wfr": "\uD835\uDD34", "Wopf": "\uD835\uDD4E", "wopf": "\uD835\uDD68", "wp": "\u2118", "wr": "\u2240", "wreath": "\u2240", "Wscr": "\uD835\uDCB2", "wscr": "\uD835\uDCCC", "xcap": "\u22C2", "xcirc": "\u25EF", "xcup": "\u22C3", "xdtri": "\u25BD", "Xfr": "\uD835\uDD1B", "xfr": "\uD835\uDD35", "xharr": "\u27F7", "xhArr": "\u27FA", "Xi": "\u039E", "xi": "\u03BE", "xlarr": "\u27F5", "xlArr": "\u27F8", "xmap": "\u27FC", "xnis": "\u22FB", "xodot": "\u2A00", "Xopf": "\uD835\uDD4F", "xopf": "\uD835\uDD69", "xoplus": "\u2A01", "xotime": "\u2A02", "xrarr": "\u27F6", "xrArr": "\u27F9", "Xscr": "\uD835\uDCB3", "xscr": "\uD835\uDCCD", "xsqcup": "\u2A06", "xuplus": "\u2A04", "xutri": "\u25B3", "xvee": "\u22C1", "xwedge": "\u22C0", "Yacute": "\u00DD", "yacute": "\u00FD", "YAcy": "\u042F", "yacy": "\u044F", "Ycirc": "\u0176", "ycirc": "\u0177", "Ycy": "\u042B", "ycy": "\u044B", "yen": "\u00A5", "Yfr": "\uD835\uDD1C", "yfr": "\uD835\uDD36", "YIcy": "\u0407", "yicy": "\u0457", "Yopf": "\uD835\uDD50", "yopf": "\uD835\uDD6A", "Yscr": "\uD835\uDCB4", "yscr": "\uD835\uDCCE", "YUcy": "\u042E", "yucy": "\u044E", "yuml": "\u00FF", "Yuml": "\u0178", "Zacute": "\u0179", "zacute": "\u017A", "Zcaron": "\u017D", "zcaron": "\u017E", "Zcy": "\u0417", "zcy": "\u0437", "Zdot": "\u017B", "zdot": "\u017C", "zeetrf": "\u2128", "ZeroWidthSpace": "\u200B", "Zeta": "\u0396", "zeta": "\u03B6", "zfr": "\uD835\uDD37", "Zfr": "\u2128", "ZHcy": "\u0416", "zhcy": "\u0436", "zigrarr": "\u21DD", "zopf": "\uD835\uDD6B", "Zopf": "\u2124", "Zscr": "\uD835\uDCB5", "zscr": "\uD835\uDCCF", "zwj": "\u200D", "zwnj": "\u200C" }
  3155. },{}],23:[function(require,module,exports){
  3156. module.exports={ "Aacute": "\u00C1", "aacute": "\u00E1", "Acirc": "\u00C2", "acirc": "\u00E2", "acute": "\u00B4", "AElig": "\u00C6", "aelig": "\u00E6", "Agrave": "\u00C0", "agrave": "\u00E0", "amp": "&", "AMP": "&", "Aring": "\u00C5", "aring": "\u00E5", "Atilde": "\u00C3", "atilde": "\u00E3", "Auml": "\u00C4", "auml": "\u00E4", "brvbar": "\u00A6", "Ccedil": "\u00C7", "ccedil": "\u00E7", "cedil": "\u00B8", "cent": "\u00A2", "copy": "\u00A9", "COPY": "\u00A9", "curren": "\u00A4", "deg": "\u00B0", "divide": "\u00F7", "Eacute": "\u00C9", "eacute": "\u00E9", "Ecirc": "\u00CA", "ecirc": "\u00EA", "Egrave": "\u00C8", "egrave": "\u00E8", "ETH": "\u00D0", "eth": "\u00F0", "Euml": "\u00CB", "euml": "\u00EB", "frac12": "\u00BD", "frac14": "\u00BC", "frac34": "\u00BE", "gt": ">", "GT": ">", "Iacute": "\u00CD", "iacute": "\u00ED", "Icirc": "\u00CE", "icirc": "\u00EE", "iexcl": "\u00A1", "Igrave": "\u00CC", "igrave": "\u00EC", "iquest": "\u00BF", "Iuml": "\u00CF", "iuml": "\u00EF", "laquo": "\u00AB", "lt": "<", "LT": "<", "macr": "\u00AF", "micro": "\u00B5", "middot": "\u00B7", "nbsp": "\u00A0", "not": "\u00AC", "Ntilde": "\u00D1", "ntilde": "\u00F1", "Oacute": "\u00D3", "oacute": "\u00F3", "Ocirc": "\u00D4", "ocirc": "\u00F4", "Ograve": "\u00D2", "ograve": "\u00F2", "ordf": "\u00AA", "ordm": "\u00BA", "Oslash": "\u00D8", "oslash": "\u00F8", "Otilde": "\u00D5", "otilde": "\u00F5", "Ouml": "\u00D6", "ouml": "\u00F6", "para": "\u00B6", "plusmn": "\u00B1", "pound": "\u00A3", "quot": "\"", "QUOT": "\"", "raquo": "\u00BB", "reg": "\u00AE", "REG": "\u00AE", "sect": "\u00A7", "shy": "\u00AD", "sup1": "\u00B9", "sup2": "\u00B2", "sup3": "\u00B3", "szlig": "\u00DF", "THORN": "\u00DE", "thorn": "\u00FE", "times": "\u00D7", "Uacute": "\u00DA", "uacute": "\u00FA", "Ucirc": "\u00DB", "ucirc": "\u00FB", "Ugrave": "\u00D9", "ugrave": "\u00F9", "uml": "\u00A8", "Uuml": "\u00DC", "uuml": "\u00FC", "Yacute": "\u00DD", "yacute": "\u00FD", "yen": "\u00A5", "yuml": "\u00FF" }
  3157. },{}],24:[function(require,module,exports){
  3158. module.exports={ "amp": "&", "apos": "'", "gt": ">", "lt": "<", "quot": "\"" }
  3159. },{}],25:[function(require,module,exports){
  3160. // Copyright Joyent, Inc. and other Node contributors.
  3161. //
  3162. // Permission is hereby granted, free of charge, to any person obtaining a
  3163. // copy of this software and associated documentation files (the
  3164. // "Software"), to deal in the Software without restriction, including
  3165. // without limitation the rights to use, copy, modify, merge, publish,
  3166. // distribute, sublicense, and/or sell copies of the Software, and to permit
  3167. // persons to whom the Software is furnished to do so, subject to the
  3168. // following conditions:
  3169. //
  3170. // The above copyright notice and this permission notice shall be included
  3171. // in all copies or substantial portions of the Software.
  3172. //
  3173. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  3174. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  3175. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  3176. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  3177. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  3178. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  3179. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  3180. var objectCreate = Object.create || objectCreatePolyfill
  3181. var objectKeys = Object.keys || objectKeysPolyfill
  3182. var bind = Function.prototype.bind || functionBindPolyfill
  3183. function EventEmitter() {
  3184. if (!this._events || !Object.prototype.hasOwnProperty.call(this, '_events')) {
  3185. this._events = objectCreate(null);
  3186. this._eventsCount = 0;
  3187. }
  3188. this._maxListeners = this._maxListeners || undefined;
  3189. }
  3190. module.exports = EventEmitter;
  3191. // Backwards-compat with node 0.10.x
  3192. EventEmitter.EventEmitter = EventEmitter;
  3193. EventEmitter.prototype._events = undefined;
  3194. EventEmitter.prototype._maxListeners = undefined;
  3195. // By default EventEmitters will print a warning if more than 10 listeners are
  3196. // added to it. This is a useful default which helps finding memory leaks.
  3197. var defaultMaxListeners = 10;
  3198. var hasDefineProperty;
  3199. try {
  3200. var o = {};
  3201. if (Object.defineProperty) Object.defineProperty(o, 'x', { value: 0 });
  3202. hasDefineProperty = o.x === 0;
  3203. } catch (err) { hasDefineProperty = false }
  3204. if (hasDefineProperty) {
  3205. Object.defineProperty(EventEmitter, 'defaultMaxListeners', {
  3206. enumerable: true,
  3207. get: function() {
  3208. return defaultMaxListeners;
  3209. },
  3210. set: function(arg) {
  3211. // check whether the input is a positive number (whose value is zero or
  3212. // greater and not a NaN).
  3213. if (typeof arg !== 'number' || arg < 0 || arg !== arg)
  3214. throw new TypeError('"defaultMaxListeners" must be a positive number');
  3215. defaultMaxListeners = arg;
  3216. }
  3217. });
  3218. } else {
  3219. EventEmitter.defaultMaxListeners = defaultMaxListeners;
  3220. }
  3221. // Obviously not all Emitters should be limited to 10. This function allows
  3222. // that to be increased. Set to zero for unlimited.
  3223. EventEmitter.prototype.setMaxListeners = function setMaxListeners(n) {
  3224. if (typeof n !== 'number' || n < 0 || isNaN(n))
  3225. throw new TypeError('"n" argument must be a positive number');
  3226. this._maxListeners = n;
  3227. return this;
  3228. };
  3229. function $getMaxListeners(that) {
  3230. if (that._maxListeners === undefined)
  3231. return EventEmitter.defaultMaxListeners;
  3232. return that._maxListeners;
  3233. }
  3234. EventEmitter.prototype.getMaxListeners = function getMaxListeners() {
  3235. return $getMaxListeners(this);
  3236. };
  3237. // These standalone emit* functions are used to optimize calling of event
  3238. // handlers for fast cases because emit() itself often has a variable number of
  3239. // arguments and can be deoptimized because of that. These functions always have
  3240. // the same number of arguments and thus do not get deoptimized, so the code
  3241. // inside them can execute faster.
  3242. function emitNone(handler, isFn, self) {
  3243. if (isFn)
  3244. handler.call(self);
  3245. else {
  3246. var len = handler.length;
  3247. var listeners = arrayClone(handler, len);
  3248. for (var i = 0; i < len; ++i)
  3249. listeners[i].call(self);
  3250. }
  3251. }
  3252. function emitOne(handler, isFn, self, arg1) {
  3253. if (isFn)
  3254. handler.call(self, arg1);
  3255. else {
  3256. var len = handler.length;
  3257. var listeners = arrayClone(handler, len);
  3258. for (var i = 0; i < len; ++i)
  3259. listeners[i].call(self, arg1);
  3260. }
  3261. }
  3262. function emitTwo(handler, isFn, self, arg1, arg2) {
  3263. if (isFn)
  3264. handler.call(self, arg1, arg2);
  3265. else {
  3266. var len = handler.length;
  3267. var listeners = arrayClone(handler, len);
  3268. for (var i = 0; i < len; ++i)
  3269. listeners[i].call(self, arg1, arg2);
  3270. }
  3271. }
  3272. function emitThree(handler, isFn, self, arg1, arg2, arg3) {
  3273. if (isFn)
  3274. handler.call(self, arg1, arg2, arg3);
  3275. else {
  3276. var len = handler.length;
  3277. var listeners = arrayClone(handler, len);
  3278. for (var i = 0; i < len; ++i)
  3279. listeners[i].call(self, arg1, arg2, arg3);
  3280. }
  3281. }
  3282. function emitMany(handler, isFn, self, args) {
  3283. if (isFn)
  3284. handler.apply(self, args);
  3285. else {
  3286. var len = handler.length;
  3287. var listeners = arrayClone(handler, len);
  3288. for (var i = 0; i < len; ++i)
  3289. listeners[i].apply(self, args);
  3290. }
  3291. }
  3292. EventEmitter.prototype.emit = function emit(type) {
  3293. var er, handler, len, args, i, events;
  3294. var doError = (type === 'error');
  3295. events = this._events;
  3296. if (events)
  3297. doError = (doError && events.error == null);
  3298. else if (!doError)
  3299. return false;
  3300. // If there is no 'error' event listener then throw.
  3301. if (doError) {
  3302. if (arguments.length > 1)
  3303. er = arguments[1];
  3304. if (er instanceof Error) {
  3305. throw er; // Unhandled 'error' event
  3306. } else {
  3307. // At least give some kind of context to the user
  3308. var err = new Error('Unhandled "error" event. (' + er + ')');
  3309. err.context = er;
  3310. throw err;
  3311. }
  3312. return false;
  3313. }
  3314. handler = events[type];
  3315. if (!handler)
  3316. return false;
  3317. var isFn = typeof handler === 'function';
  3318. len = arguments.length;
  3319. switch (len) {
  3320. // fast cases
  3321. case 1:
  3322. emitNone(handler, isFn, this);
  3323. break;
  3324. case 2:
  3325. emitOne(handler, isFn, this, arguments[1]);
  3326. break;
  3327. case 3:
  3328. emitTwo(handler, isFn, this, arguments[1], arguments[2]);
  3329. break;
  3330. case 4:
  3331. emitThree(handler, isFn, this, arguments[1], arguments[2], arguments[3]);
  3332. break;
  3333. // slower
  3334. default:
  3335. args = new Array(len - 1);
  3336. for (i = 1; i < len; i++)
  3337. args[i - 1] = arguments[i];
  3338. emitMany(handler, isFn, this, args);
  3339. }
  3340. return true;
  3341. };
  3342. function _addListener(target, type, listener, prepend) {
  3343. var m;
  3344. var events;
  3345. var existing;
  3346. if (typeof listener !== 'function')
  3347. throw new TypeError('"listener" argument must be a function');
  3348. events = target._events;
  3349. if (!events) {
  3350. events = target._events = objectCreate(null);
  3351. target._eventsCount = 0;
  3352. } else {
  3353. // To avoid recursion in the case that type === "newListener"! Before
  3354. // adding it to the listeners, first emit "newListener".
  3355. if (events.newListener) {
  3356. target.emit('newListener', type,
  3357. listener.listener ? listener.listener : listener);
  3358. // Re-assign `events` because a newListener handler could have caused the
  3359. // this._events to be assigned to a new object
  3360. events = target._events;
  3361. }
  3362. existing = events[type];
  3363. }
  3364. if (!existing) {
  3365. // Optimize the case of one listener. Don't need the extra array object.
  3366. existing = events[type] = listener;
  3367. ++target._eventsCount;
  3368. } else {
  3369. if (typeof existing === 'function') {
  3370. // Adding the second element, need to change to array.
  3371. existing = events[type] =
  3372. prepend ? [listener, existing] : [existing, listener];
  3373. } else {
  3374. // If we've already got an array, just append.
  3375. if (prepend) {
  3376. existing.unshift(listener);
  3377. } else {
  3378. existing.push(listener);
  3379. }
  3380. }
  3381. // Check for listener leak
  3382. if (!existing.warned) {
  3383. m = $getMaxListeners(target);
  3384. if (m && m > 0 && existing.length > m) {
  3385. existing.warned = true;
  3386. var w = new Error('Possible EventEmitter memory leak detected. ' +
  3387. existing.length + ' "' + String(type) + '" listeners ' +
  3388. 'added. Use emitter.setMaxListeners() to ' +
  3389. 'increase limit.');
  3390. w.name = 'MaxListenersExceededWarning';
  3391. w.emitter = target;
  3392. w.type = type;
  3393. w.count = existing.length;
  3394. if (typeof console === 'object' && console.warn) {
  3395. console.warn('%s: %s', w.name, w.message);
  3396. }
  3397. }
  3398. }
  3399. }
  3400. return target;
  3401. }
  3402. EventEmitter.prototype.addListener = function addListener(type, listener) {
  3403. return _addListener(this, type, listener, false);
  3404. };
  3405. EventEmitter.prototype.on = EventEmitter.prototype.addListener;
  3406. EventEmitter.prototype.prependListener =
  3407. function prependListener(type, listener) {
  3408. return _addListener(this, type, listener, true);
  3409. };
  3410. function onceWrapper() {
  3411. if (!this.fired) {
  3412. this.target.removeListener(this.type, this.wrapFn);
  3413. this.fired = true;
  3414. switch (arguments.length) {
  3415. case 0:
  3416. return this.listener.call(this.target);
  3417. case 1:
  3418. return this.listener.call(this.target, arguments[0]);
  3419. case 2:
  3420. return this.listener.call(this.target, arguments[0], arguments[1]);
  3421. case 3:
  3422. return this.listener.call(this.target, arguments[0], arguments[1],
  3423. arguments[2]);
  3424. default:
  3425. var args = new Array(arguments.length);
  3426. for (var i = 0; i < args.length; ++i)
  3427. args[i] = arguments[i];
  3428. this.listener.apply(this.target, args);
  3429. }
  3430. }
  3431. }
  3432. function _onceWrap(target, type, listener) {
  3433. var state = { fired: false, wrapFn: undefined, target: target, type: type, listener: listener };
  3434. var wrapped = bind.call(onceWrapper, state);
  3435. wrapped.listener = listener;
  3436. state.wrapFn = wrapped;
  3437. return wrapped;
  3438. }
  3439. EventEmitter.prototype.once = function once(type, listener) {
  3440. if (typeof listener !== 'function')
  3441. throw new TypeError('"listener" argument must be a function');
  3442. this.on(type, _onceWrap(this, type, listener));
  3443. return this;
  3444. };
  3445. EventEmitter.prototype.prependOnceListener =
  3446. function prependOnceListener(type, listener) {
  3447. if (typeof listener !== 'function')
  3448. throw new TypeError('"listener" argument must be a function');
  3449. this.prependListener(type, _onceWrap(this, type, listener));
  3450. return this;
  3451. };
  3452. // Emits a 'removeListener' event if and only if the listener was removed.
  3453. EventEmitter.prototype.removeListener =
  3454. function removeListener(type, listener) {
  3455. var list, events, position, i, originalListener;
  3456. if (typeof listener !== 'function')
  3457. throw new TypeError('"listener" argument must be a function');
  3458. events = this._events;
  3459. if (!events)
  3460. return this;
  3461. list = events[type];
  3462. if (!list)
  3463. return this;
  3464. if (list === listener || list.listener === listener) {
  3465. if (--this._eventsCount === 0)
  3466. this._events = objectCreate(null);
  3467. else {
  3468. delete events[type];
  3469. if (events.removeListener)
  3470. this.emit('removeListener', type, list.listener || listener);
  3471. }
  3472. } else if (typeof list !== 'function') {
  3473. position = -1;
  3474. for (i = list.length - 1; i >= 0; i--) {
  3475. if (list[i] === listener || list[i].listener === listener) {
  3476. originalListener = list[i].listener;
  3477. position = i;
  3478. break;
  3479. }
  3480. }
  3481. if (position < 0)
  3482. return this;
  3483. if (position === 0)
  3484. list.shift();
  3485. else
  3486. spliceOne(list, position);
  3487. if (list.length === 1)
  3488. events[type] = list[0];
  3489. if (events.removeListener)
  3490. this.emit('removeListener', type, originalListener || listener);
  3491. }
  3492. return this;
  3493. };
  3494. EventEmitter.prototype.removeAllListeners =
  3495. function removeAllListeners(type) {
  3496. var listeners, events, i;
  3497. events = this._events;
  3498. if (!events)
  3499. return this;
  3500. // not listening for removeListener, no need to emit
  3501. if (!events.removeListener) {
  3502. if (arguments.length === 0) {
  3503. this._events = objectCreate(null);
  3504. this._eventsCount = 0;
  3505. } else if (events[type]) {
  3506. if (--this._eventsCount === 0)
  3507. this._events = objectCreate(null);
  3508. else
  3509. delete events[type];
  3510. }
  3511. return this;
  3512. }
  3513. // emit removeListener for all listeners on all events
  3514. if (arguments.length === 0) {
  3515. var keys = objectKeys(events);
  3516. var key;
  3517. for (i = 0; i < keys.length; ++i) {
  3518. key = keys[i];
  3519. if (key === 'removeListener') continue;
  3520. this.removeAllListeners(key);
  3521. }
  3522. this.removeAllListeners('removeListener');
  3523. this._events = objectCreate(null);
  3524. this._eventsCount = 0;
  3525. return this;
  3526. }
  3527. listeners = events[type];
  3528. if (typeof listeners === 'function') {
  3529. this.removeListener(type, listeners);
  3530. } else if (listeners) {
  3531. // LIFO order
  3532. for (i = listeners.length - 1; i >= 0; i--) {
  3533. this.removeListener(type, listeners[i]);
  3534. }
  3535. }
  3536. return this;
  3537. };
  3538. function _listeners(target, type, unwrap) {
  3539. var events = target._events;
  3540. if (!events)
  3541. return [];
  3542. var evlistener = events[type];
  3543. if (!evlistener)
  3544. return [];
  3545. if (typeof evlistener === 'function')
  3546. return unwrap ? [evlistener.listener || evlistener] : [evlistener];
  3547. return unwrap ? unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length);
  3548. }
  3549. EventEmitter.prototype.listeners = function listeners(type) {
  3550. return _listeners(this, type, true);
  3551. };
  3552. EventEmitter.prototype.rawListeners = function rawListeners(type) {
  3553. return _listeners(this, type, false);
  3554. };
  3555. EventEmitter.listenerCount = function(emitter, type) {
  3556. if (typeof emitter.listenerCount === 'function') {
  3557. return emitter.listenerCount(type);
  3558. } else {
  3559. return listenerCount.call(emitter, type);
  3560. }
  3561. };
  3562. EventEmitter.prototype.listenerCount = listenerCount;
  3563. function listenerCount(type) {
  3564. var events = this._events;
  3565. if (events) {
  3566. var evlistener = events[type];
  3567. if (typeof evlistener === 'function') {
  3568. return 1;
  3569. } else if (evlistener) {
  3570. return evlistener.length;
  3571. }
  3572. }
  3573. return 0;
  3574. }
  3575. EventEmitter.prototype.eventNames = function eventNames() {
  3576. return this._eventsCount > 0 ? Reflect.ownKeys(this._events) : [];
  3577. };
  3578. // About 1.5x faster than the two-arg version of Array#splice().
  3579. function spliceOne(list, index) {
  3580. for (var i = index, k = i + 1, n = list.length; k < n; i += 1, k += 1)
  3581. list[i] = list[k];
  3582. list.pop();
  3583. }
  3584. function arrayClone(arr, n) {
  3585. var copy = new Array(n);
  3586. for (var i = 0; i < n; ++i)
  3587. copy[i] = arr[i];
  3588. return copy;
  3589. }
  3590. function unwrapListeners(arr) {
  3591. var ret = new Array(arr.length);
  3592. for (var i = 0; i < ret.length; ++i) {
  3593. ret[i] = arr[i].listener || arr[i];
  3594. }
  3595. return ret;
  3596. }
  3597. function objectCreatePolyfill(proto) {
  3598. var F = function() {};
  3599. F.prototype = proto;
  3600. return new F;
  3601. }
  3602. function objectKeysPolyfill(obj) {
  3603. var keys = [];
  3604. for (var k in obj) if (Object.prototype.hasOwnProperty.call(obj, k)) {
  3605. keys.push(k);
  3606. }
  3607. return k;
  3608. }
  3609. function functionBindPolyfill(context) {
  3610. var fn = this;
  3611. return function () {
  3612. return fn.apply(context, arguments);
  3613. };
  3614. }
  3615. },{}],26:[function(require,module,exports){
  3616. "use strict";
  3617. var __extends = (this && this.__extends) || (function () {
  3618. var extendStatics = function (d, b) {
  3619. extendStatics = Object.setPrototypeOf ||
  3620. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  3621. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  3622. return extendStatics(d, b);
  3623. };
  3624. return function (d, b) {
  3625. extendStatics(d, b);
  3626. function __() { this.constructor = d; }
  3627. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  3628. };
  3629. })();
  3630. var __importDefault = (this && this.__importDefault) || function (mod) {
  3631. return (mod && mod.__esModule) ? mod : { "default": mod };
  3632. };
  3633. Object.defineProperty(exports, "__esModule", { value: true });
  3634. var MultiplexHandler_1 = __importDefault(require("./MultiplexHandler"));
  3635. var CollectingHandler = /** @class */ (function (_super) {
  3636. __extends(CollectingHandler, _super);
  3637. function CollectingHandler(cbs) {
  3638. if (cbs === void 0) { cbs = {}; }
  3639. var _this = _super.call(this, function (name) {
  3640. var _a;
  3641. var args = [];
  3642. for (var _i = 1; _i < arguments.length; _i++) {
  3643. args[_i - 1] = arguments[_i];
  3644. }
  3645. _this.events.push([name].concat(args));
  3646. // @ts-ignore
  3647. if (_this._cbs[name])
  3648. (_a = _this._cbs)[name].apply(_a, args);
  3649. }) || this;
  3650. _this._cbs = cbs;
  3651. _this.events = [];
  3652. return _this;
  3653. }
  3654. CollectingHandler.prototype.onreset = function () {
  3655. this.events = [];
  3656. if (this._cbs.onreset)
  3657. this._cbs.onreset();
  3658. };
  3659. CollectingHandler.prototype.restart = function () {
  3660. var _a;
  3661. if (this._cbs.onreset)
  3662. this._cbs.onreset();
  3663. for (var i = 0; i < this.events.length; i++) {
  3664. var _b = this.events[i], name_1 = _b[0], args = _b.slice(1);
  3665. if (!this._cbs[name_1]) {
  3666. continue;
  3667. }
  3668. // @ts-ignore
  3669. (_a = this._cbs)[name_1].apply(_a, args);
  3670. }
  3671. };
  3672. return CollectingHandler;
  3673. }(MultiplexHandler_1.default));
  3674. exports.CollectingHandler = CollectingHandler;
  3675. },{"./MultiplexHandler":28}],27:[function(require,module,exports){
  3676. "use strict";
  3677. var __extends = (this && this.__extends) || (function () {
  3678. var extendStatics = function (d, b) {
  3679. extendStatics = Object.setPrototypeOf ||
  3680. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  3681. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  3682. return extendStatics(d, b);
  3683. };
  3684. return function (d, b) {
  3685. extendStatics(d, b);
  3686. function __() { this.constructor = d; }
  3687. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  3688. };
  3689. })();
  3690. var __importDefault = (this && this.__importDefault) || function (mod) {
  3691. return (mod && mod.__esModule) ? mod : { "default": mod };
  3692. };
  3693. var __importStar = (this && this.__importStar) || function (mod) {
  3694. if (mod && mod.__esModule) return mod;
  3695. var result = {};
  3696. if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  3697. result["default"] = mod;
  3698. return result;
  3699. };
  3700. Object.defineProperty(exports, "__esModule", { value: true });
  3701. var domhandler_1 = __importDefault(require("domhandler"));
  3702. var DomUtils = __importStar(require("domutils"));
  3703. var Parser_1 = require("./Parser");
  3704. //TODO: Consume data as it is coming in
  3705. var FeedHandler = /** @class */ (function (_super) {
  3706. __extends(FeedHandler, _super);
  3707. /**
  3708. *
  3709. * @param callback
  3710. * @param options
  3711. */
  3712. function FeedHandler(callback, options) {
  3713. var _this = this;
  3714. if (typeof callback === "object" && callback !== null) {
  3715. callback = undefined;
  3716. options = callback;
  3717. }
  3718. _this = _super.call(this, callback, options) || this;
  3719. return _this;
  3720. }
  3721. FeedHandler.prototype.onend = function () {
  3722. var feed = {};
  3723. var feedRoot = getOneElement(isValidFeed, this.dom);
  3724. if (feedRoot) {
  3725. if (feedRoot.name === "feed") {
  3726. var childs = feedRoot.children;
  3727. feed.type = "atom";
  3728. addConditionally(feed, "id", "id", childs);
  3729. addConditionally(feed, "title", "title", childs);
  3730. var href = getAttribute("href", getOneElement("link", childs));
  3731. if (href) {
  3732. feed.link = href;
  3733. }
  3734. addConditionally(feed, "description", "subtitle", childs);
  3735. var updated = fetch("updated", childs);
  3736. if (updated) {
  3737. feed.updated = new Date(updated);
  3738. }
  3739. addConditionally(feed, "author", "email", childs, true);
  3740. feed.items = getElements("entry", childs).map(function (item) {
  3741. var entry = {};
  3742. var children = item.children;
  3743. addConditionally(entry, "id", "id", children);
  3744. addConditionally(entry, "title", "title", children);
  3745. var href = getAttribute("href", getOneElement("link", children));
  3746. if (href) {
  3747. entry.link = href;
  3748. }
  3749. var description = fetch("summary", children) ||
  3750. fetch("content", children);
  3751. if (description) {
  3752. entry.description = description;
  3753. }
  3754. var pubDate = fetch("updated", children);
  3755. if (pubDate) {
  3756. entry.pubDate = new Date(pubDate);
  3757. }
  3758. return entry;
  3759. });
  3760. }
  3761. else {
  3762. var childs = getOneElement("channel", feedRoot.children)
  3763. .children;
  3764. feed.type = feedRoot.name.substr(0, 3);
  3765. feed.id = "";
  3766. addConditionally(feed, "title", "title", childs);
  3767. addConditionally(feed, "link", "link", childs);
  3768. addConditionally(feed, "description", "description", childs);
  3769. var updated = fetch("lastBuildDate", childs);
  3770. if (updated) {
  3771. feed.updated = new Date(updated);
  3772. }
  3773. addConditionally(feed, "author", "managingEditor", childs, true);
  3774. feed.items = getElements("item", feedRoot.children).map(function (item) {
  3775. var entry = {};
  3776. var children = item.children;
  3777. addConditionally(entry, "id", "guid", children);
  3778. addConditionally(entry, "title", "title", children);
  3779. addConditionally(entry, "link", "link", children);
  3780. addConditionally(entry, "description", "description", children);
  3781. var pubDate = fetch("pubDate", children);
  3782. if (pubDate)
  3783. entry.pubDate = new Date(pubDate);
  3784. return entry;
  3785. });
  3786. }
  3787. }
  3788. this.feed = feed;
  3789. this.handleCallback(feedRoot ? null : Error("couldn't find root of feed"));
  3790. };
  3791. return FeedHandler;
  3792. }(domhandler_1.default));
  3793. exports.FeedHandler = FeedHandler;
  3794. function getElements(what, where) {
  3795. return DomUtils.getElementsByTagName(what, where, true);
  3796. }
  3797. function getOneElement(what, where) {
  3798. return DomUtils.getElementsByTagName(what, where, true, 1)[0];
  3799. }
  3800. function fetch(what, where, recurse) {
  3801. if (recurse === void 0) { recurse = false; }
  3802. return DomUtils.getText(DomUtils.getElementsByTagName(what, where, recurse, 1)).trim();
  3803. }
  3804. function getAttribute(name, elem) {
  3805. if (!elem) {
  3806. return null;
  3807. }
  3808. var attribs = elem.attribs;
  3809. return attribs[name];
  3810. }
  3811. function addConditionally(obj, prop, what, where, recurse) {
  3812. if (recurse === void 0) { recurse = false; }
  3813. var tmp = fetch(what, where, recurse);
  3814. // @ts-ignore
  3815. if (tmp)
  3816. obj[prop] = tmp;
  3817. }
  3818. function isValidFeed(value) {
  3819. return value === "rss" || value === "feed" || value === "rdf:RDF";
  3820. }
  3821. var defaultOptions = { xmlMode: true };
  3822. /**
  3823. * Parse a feed.
  3824. *
  3825. * @param feed The feed that should be parsed, as a string.
  3826. * @param options Optionally, options for parsing. When using this option, you probably want to set `xmlMode` to `true`.
  3827. */
  3828. function parseFeed(feed, options) {
  3829. if (options === void 0) { options = defaultOptions; }
  3830. var handler = new FeedHandler(options);
  3831. new Parser_1.Parser(handler, options).end(feed);
  3832. return handler.feed;
  3833. }
  3834. exports.parseFeed = parseFeed;
  3835. },{"./Parser":29,"domhandler":7,"domutils":10}],28:[function(require,module,exports){
  3836. "use strict";
  3837. Object.defineProperty(exports, "__esModule", { value: true });
  3838. /**
  3839. * Calls a specific handler function for all events that are encountered.
  3840. *
  3841. * @param func — The function to multiplex all events to.
  3842. */
  3843. var MultiplexHandler = /** @class */ (function () {
  3844. function MultiplexHandler(func) {
  3845. this._func = func;
  3846. }
  3847. /* Format: eventname: number of arguments */
  3848. MultiplexHandler.prototype.onattribute = function (name, value) {
  3849. this._func("onattribute", name, value);
  3850. };
  3851. MultiplexHandler.prototype.oncdatastart = function () {
  3852. this._func("oncdatastart");
  3853. };
  3854. MultiplexHandler.prototype.oncdataend = function () {
  3855. this._func("oncdataend");
  3856. };
  3857. MultiplexHandler.prototype.ontext = function (text) {
  3858. this._func("ontext", text);
  3859. };
  3860. MultiplexHandler.prototype.onprocessinginstruction = function (name, value) {
  3861. this._func("onprocessinginstruction", name, value);
  3862. };
  3863. MultiplexHandler.prototype.oncomment = function (comment) {
  3864. this._func("oncomment", comment);
  3865. };
  3866. MultiplexHandler.prototype.oncommentend = function () {
  3867. this._func("oncommentend");
  3868. };
  3869. MultiplexHandler.prototype.onclosetag = function (name) {
  3870. this._func("onclosetag", name);
  3871. };
  3872. MultiplexHandler.prototype.onopentag = function (name, attribs) {
  3873. this._func("onopentag", name, attribs);
  3874. };
  3875. MultiplexHandler.prototype.onopentagname = function (name) {
  3876. this._func("onopentagname", name);
  3877. };
  3878. MultiplexHandler.prototype.onerror = function (error) {
  3879. this._func("onerror", error);
  3880. };
  3881. MultiplexHandler.prototype.onend = function () {
  3882. this._func("onend");
  3883. };
  3884. MultiplexHandler.prototype.onparserinit = function (parser) {
  3885. this._func("onparserinit", parser);
  3886. };
  3887. MultiplexHandler.prototype.onreset = function () {
  3888. this._func("onreset");
  3889. };
  3890. return MultiplexHandler;
  3891. }());
  3892. exports.default = MultiplexHandler;
  3893. },{}],29:[function(require,module,exports){
  3894. "use strict";
  3895. var __extends = (this && this.__extends) || (function () {
  3896. var extendStatics = function (d, b) {
  3897. extendStatics = Object.setPrototypeOf ||
  3898. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  3899. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  3900. return extendStatics(d, b);
  3901. };
  3902. return function (d, b) {
  3903. extendStatics(d, b);
  3904. function __() { this.constructor = d; }
  3905. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  3906. };
  3907. })();
  3908. var __importDefault = (this && this.__importDefault) || function (mod) {
  3909. return (mod && mod.__esModule) ? mod : { "default": mod };
  3910. };
  3911. Object.defineProperty(exports, "__esModule", { value: true });
  3912. var Tokenizer_1 = __importDefault(require("./Tokenizer"));
  3913. var events_1 = require("events");
  3914. var formTags = new Set([
  3915. "input",
  3916. "option",
  3917. "optgroup",
  3918. "select",
  3919. "button",
  3920. "datalist",
  3921. "textarea"
  3922. ]);
  3923. var pTag = new Set(["p"]);
  3924. var openImpliesClose = {
  3925. tr: new Set(["tr", "th", "td"]),
  3926. th: new Set(["th"]),
  3927. td: new Set(["thead", "th", "td"]),
  3928. body: new Set(["head", "link", "script"]),
  3929. li: new Set(["li"]),
  3930. p: pTag,
  3931. h1: pTag,
  3932. h2: pTag,
  3933. h3: pTag,
  3934. h4: pTag,
  3935. h5: pTag,
  3936. h6: pTag,
  3937. select: formTags,
  3938. input: formTags,
  3939. output: formTags,
  3940. button: formTags,
  3941. datalist: formTags,
  3942. textarea: formTags,
  3943. option: new Set(["option"]),
  3944. optgroup: new Set(["optgroup", "option"]),
  3945. dd: new Set(["dt", "dd"]),
  3946. dt: new Set(["dt", "dd"]),
  3947. address: pTag,
  3948. article: pTag,
  3949. aside: pTag,
  3950. blockquote: pTag,
  3951. details: pTag,
  3952. div: pTag,
  3953. dl: pTag,
  3954. fieldset: pTag,
  3955. figcaption: pTag,
  3956. figure: pTag,
  3957. footer: pTag,
  3958. form: pTag,
  3959. header: pTag,
  3960. hr: pTag,
  3961. main: pTag,
  3962. nav: pTag,
  3963. ol: pTag,
  3964. pre: pTag,
  3965. section: pTag,
  3966. table: pTag,
  3967. ul: pTag,
  3968. rt: new Set(["rt", "rp"]),
  3969. rp: new Set(["rt", "rp"]),
  3970. tbody: new Set(["thead", "tbody"]),
  3971. tfoot: new Set(["thead", "tbody"])
  3972. };
  3973. var voidElements = new Set([
  3974. "area",
  3975. "base",
  3976. "basefont",
  3977. "br",
  3978. "col",
  3979. "command",
  3980. "embed",
  3981. "frame",
  3982. "hr",
  3983. "img",
  3984. "input",
  3985. "isindex",
  3986. "keygen",
  3987. "link",
  3988. "meta",
  3989. "param",
  3990. "source",
  3991. "track",
  3992. "wbr"
  3993. ]);
  3994. var foreignContextElements = new Set(["math", "svg"]);
  3995. var htmlIntegrationElements = new Set([
  3996. "mi",
  3997. "mo",
  3998. "mn",
  3999. "ms",
  4000. "mtext",
  4001. "annotation-xml",
  4002. "foreignObject",
  4003. "desc",
  4004. "title"
  4005. ]);
  4006. var reNameEnd = /\s|\//;
  4007. var Parser = /** @class */ (function (_super) {
  4008. __extends(Parser, _super);
  4009. function Parser(cbs, options) {
  4010. var _this = _super.call(this) || this;
  4011. _this._tagname = "";
  4012. _this._attribname = "";
  4013. _this._attribvalue = "";
  4014. _this._attribs = null;
  4015. _this._stack = [];
  4016. _this._foreignContext = [];
  4017. _this.startIndex = 0;
  4018. _this.endIndex = null;
  4019. // Aliases for backwards compatibility
  4020. _this.parseChunk = Parser.prototype.write;
  4021. _this.done = Parser.prototype.end;
  4022. _this._options = options || {};
  4023. _this._cbs = cbs || {};
  4024. _this._tagname = "";
  4025. _this._attribname = "";
  4026. _this._attribvalue = "";
  4027. _this._attribs = null;
  4028. _this._stack = [];
  4029. _this._foreignContext = [];
  4030. _this.startIndex = 0;
  4031. _this.endIndex = null;
  4032. _this._lowerCaseTagNames =
  4033. "lowerCaseTags" in _this._options
  4034. ? !!_this._options.lowerCaseTags
  4035. : !_this._options.xmlMode;
  4036. _this._lowerCaseAttributeNames =
  4037. "lowerCaseAttributeNames" in _this._options
  4038. ? !!_this._options.lowerCaseAttributeNames
  4039. : !_this._options.xmlMode;
  4040. _this._tokenizer = new (_this._options.Tokenizer || Tokenizer_1.default)(_this._options, _this);
  4041. if (_this._cbs.onparserinit)
  4042. _this._cbs.onparserinit(_this);
  4043. return _this;
  4044. }
  4045. Parser.prototype._updatePosition = function (initialOffset) {
  4046. if (this.endIndex === null) {
  4047. if (this._tokenizer._sectionStart <= initialOffset) {
  4048. this.startIndex = 0;
  4049. }
  4050. else {
  4051. this.startIndex = this._tokenizer._sectionStart - initialOffset;
  4052. }
  4053. }
  4054. else
  4055. this.startIndex = this.endIndex + 1;
  4056. this.endIndex = this._tokenizer.getAbsoluteIndex();
  4057. };
  4058. //Tokenizer event handlers
  4059. Parser.prototype.ontext = function (data) {
  4060. this._updatePosition(1);
  4061. // @ts-ignore
  4062. this.endIndex--;
  4063. if (this._cbs.ontext)
  4064. this._cbs.ontext(data);
  4065. };
  4066. Parser.prototype.onopentagname = function (name) {
  4067. if (this._lowerCaseTagNames) {
  4068. name = name.toLowerCase();
  4069. }
  4070. this._tagname = name;
  4071. if (!this._options.xmlMode &&
  4072. Object.prototype.hasOwnProperty.call(openImpliesClose, name)) {
  4073. for (var el = void 0;
  4074. // @ts-ignore
  4075. openImpliesClose[name].has((el = this._stack[this._stack.length - 1])); this.onclosetag(el))
  4076. ;
  4077. }
  4078. if (this._options.xmlMode || !voidElements.has(name)) {
  4079. this._stack.push(name);
  4080. if (foreignContextElements.has(name)) {
  4081. this._foreignContext.push(true);
  4082. }
  4083. else if (htmlIntegrationElements.has(name)) {
  4084. this._foreignContext.push(false);
  4085. }
  4086. }
  4087. if (this._cbs.onopentagname)
  4088. this._cbs.onopentagname(name);
  4089. if (this._cbs.onopentag)
  4090. this._attribs = {};
  4091. };
  4092. Parser.prototype.onopentagend = function () {
  4093. this._updatePosition(1);
  4094. if (this._attribs) {
  4095. if (this._cbs.onopentag) {
  4096. this._cbs.onopentag(this._tagname, this._attribs);
  4097. }
  4098. this._attribs = null;
  4099. }
  4100. if (!this._options.xmlMode &&
  4101. this._cbs.onclosetag &&
  4102. voidElements.has(this._tagname)) {
  4103. this._cbs.onclosetag(this._tagname);
  4104. }
  4105. this._tagname = "";
  4106. };
  4107. Parser.prototype.onclosetag = function (name) {
  4108. this._updatePosition(1);
  4109. if (this._lowerCaseTagNames) {
  4110. name = name.toLowerCase();
  4111. }
  4112. if (foreignContextElements.has(name) ||
  4113. htmlIntegrationElements.has(name)) {
  4114. this._foreignContext.pop();
  4115. }
  4116. if (this._stack.length &&
  4117. (this._options.xmlMode || !voidElements.has(name))) {
  4118. var pos = this._stack.lastIndexOf(name);
  4119. if (pos !== -1) {
  4120. if (this._cbs.onclosetag) {
  4121. pos = this._stack.length - pos;
  4122. // @ts-ignore
  4123. while (pos--)
  4124. this._cbs.onclosetag(this._stack.pop());
  4125. }
  4126. else
  4127. this._stack.length = pos;
  4128. }
  4129. else if (name === "p" && !this._options.xmlMode) {
  4130. this.onopentagname(name);
  4131. this._closeCurrentTag();
  4132. }
  4133. }
  4134. else if (!this._options.xmlMode && (name === "br" || name === "p")) {
  4135. this.onopentagname(name);
  4136. this._closeCurrentTag();
  4137. }
  4138. };
  4139. Parser.prototype.onselfclosingtag = function () {
  4140. if (this._options.xmlMode ||
  4141. this._options.recognizeSelfClosing ||
  4142. this._foreignContext[this._foreignContext.length - 1]) {
  4143. this._closeCurrentTag();
  4144. }
  4145. else {
  4146. this.onopentagend();
  4147. }
  4148. };
  4149. Parser.prototype._closeCurrentTag = function () {
  4150. var name = this._tagname;
  4151. this.onopentagend();
  4152. //self-closing tags will be on the top of the stack
  4153. //(cheaper check than in onclosetag)
  4154. if (this._stack[this._stack.length - 1] === name) {
  4155. if (this._cbs.onclosetag) {
  4156. this._cbs.onclosetag(name);
  4157. }
  4158. this._stack.pop();
  4159. }
  4160. };
  4161. Parser.prototype.onattribname = function (name) {
  4162. if (this._lowerCaseAttributeNames) {
  4163. name = name.toLowerCase();
  4164. }
  4165. this._attribname = name;
  4166. };
  4167. Parser.prototype.onattribdata = function (value) {
  4168. this._attribvalue += value;
  4169. };
  4170. Parser.prototype.onattribend = function () {
  4171. if (this._cbs.onattribute)
  4172. this._cbs.onattribute(this._attribname, this._attribvalue);
  4173. if (this._attribs &&
  4174. !Object.prototype.hasOwnProperty.call(this._attribs, this._attribname)) {
  4175. this._attribs[this._attribname] = this._attribvalue;
  4176. }
  4177. this._attribname = "";
  4178. this._attribvalue = "";
  4179. };
  4180. Parser.prototype._getInstructionName = function (value) {
  4181. var idx = value.search(reNameEnd);
  4182. var name = idx < 0 ? value : value.substr(0, idx);
  4183. if (this._lowerCaseTagNames) {
  4184. name = name.toLowerCase();
  4185. }
  4186. return name;
  4187. };
  4188. Parser.prototype.ondeclaration = function (value) {
  4189. if (this._cbs.onprocessinginstruction) {
  4190. var name_1 = this._getInstructionName(value);
  4191. this._cbs.onprocessinginstruction("!" + name_1, "!" + value);
  4192. }
  4193. };
  4194. Parser.prototype.onprocessinginstruction = function (value) {
  4195. if (this._cbs.onprocessinginstruction) {
  4196. var name_2 = this._getInstructionName(value);
  4197. this._cbs.onprocessinginstruction("?" + name_2, "?" + value);
  4198. }
  4199. };
  4200. Parser.prototype.oncomment = function (value) {
  4201. this._updatePosition(4);
  4202. if (this._cbs.oncomment)
  4203. this._cbs.oncomment(value);
  4204. if (this._cbs.oncommentend)
  4205. this._cbs.oncommentend();
  4206. };
  4207. Parser.prototype.oncdata = function (value) {
  4208. this._updatePosition(1);
  4209. if (this._options.xmlMode || this._options.recognizeCDATA) {
  4210. if (this._cbs.oncdatastart)
  4211. this._cbs.oncdatastart();
  4212. if (this._cbs.ontext)
  4213. this._cbs.ontext(value);
  4214. if (this._cbs.oncdataend)
  4215. this._cbs.oncdataend();
  4216. }
  4217. else {
  4218. this.oncomment("[CDATA[" + value + "]]");
  4219. }
  4220. };
  4221. Parser.prototype.onerror = function (err) {
  4222. if (this._cbs.onerror)
  4223. this._cbs.onerror(err);
  4224. };
  4225. Parser.prototype.onend = function () {
  4226. if (this._cbs.onclosetag) {
  4227. for (var i = this._stack.length; i > 0; this._cbs.onclosetag(this._stack[--i]))
  4228. ;
  4229. }
  4230. if (this._cbs.onend)
  4231. this._cbs.onend();
  4232. };
  4233. //Resets the parser to a blank state, ready to parse a new HTML document
  4234. Parser.prototype.reset = function () {
  4235. if (this._cbs.onreset)
  4236. this._cbs.onreset();
  4237. this._tokenizer.reset();
  4238. this._tagname = "";
  4239. this._attribname = "";
  4240. this._attribs = null;
  4241. this._stack = [];
  4242. if (this._cbs.onparserinit)
  4243. this._cbs.onparserinit(this);
  4244. };
  4245. //Parses a complete HTML document and pushes it to the handler
  4246. Parser.prototype.parseComplete = function (data) {
  4247. this.reset();
  4248. this.end(data);
  4249. };
  4250. Parser.prototype.write = function (chunk) {
  4251. this._tokenizer.write(chunk);
  4252. };
  4253. Parser.prototype.end = function (chunk) {
  4254. this._tokenizer.end(chunk);
  4255. };
  4256. Parser.prototype.pause = function () {
  4257. this._tokenizer.pause();
  4258. };
  4259. Parser.prototype.resume = function () {
  4260. this._tokenizer.resume();
  4261. };
  4262. return Parser;
  4263. }(events_1.EventEmitter));
  4264. exports.Parser = Parser;
  4265. },{"./Tokenizer":30,"events":25}],30:[function(require,module,exports){
  4266. "use strict";
  4267. var __importDefault = (this && this.__importDefault) || function (mod) {
  4268. return (mod && mod.__esModule) ? mod : { "default": mod };
  4269. };
  4270. Object.defineProperty(exports, "__esModule", { value: true });
  4271. var decode_codepoint_1 = __importDefault(require("entities/lib/decode_codepoint"));
  4272. var entities_json_1 = __importDefault(require("entities/lib/maps/entities.json"));
  4273. var legacy_json_1 = __importDefault(require("entities/lib/maps/legacy.json"));
  4274. var xml_json_1 = __importDefault(require("entities/lib/maps/xml.json"));
  4275. function whitespace(c) {
  4276. return c === " " || c === "\n" || c === "\t" || c === "\f" || c === "\r";
  4277. }
  4278. function ifElseState(upper, SUCCESS, FAILURE) {
  4279. var lower = upper.toLowerCase();
  4280. if (upper === lower) {
  4281. return function (t, c) {
  4282. if (c === lower) {
  4283. t._state = SUCCESS;
  4284. }
  4285. else {
  4286. t._state = FAILURE;
  4287. t._index--;
  4288. }
  4289. };
  4290. }
  4291. else {
  4292. return function (t, c) {
  4293. if (c === lower || c === upper) {
  4294. t._state = SUCCESS;
  4295. }
  4296. else {
  4297. t._state = FAILURE;
  4298. t._index--;
  4299. }
  4300. };
  4301. }
  4302. }
  4303. function consumeSpecialNameChar(upper, NEXT_STATE) {
  4304. var lower = upper.toLowerCase();
  4305. return function (t, c) {
  4306. if (c === lower || c === upper) {
  4307. t._state = NEXT_STATE;
  4308. }
  4309. else {
  4310. t._state = 3 /* InTagName */;
  4311. t._index--; //consume the token again
  4312. }
  4313. };
  4314. }
  4315. var stateBeforeCdata1 = ifElseState("C", 23 /* BeforeCdata2 */, 16 /* InDeclaration */);
  4316. var stateBeforeCdata2 = ifElseState("D", 24 /* BeforeCdata3 */, 16 /* InDeclaration */);
  4317. var stateBeforeCdata3 = ifElseState("A", 25 /* BeforeCdata4 */, 16 /* InDeclaration */);
  4318. var stateBeforeCdata4 = ifElseState("T", 26 /* BeforeCdata5 */, 16 /* InDeclaration */);
  4319. var stateBeforeCdata5 = ifElseState("A", 27 /* BeforeCdata6 */, 16 /* InDeclaration */);
  4320. var stateBeforeScript1 = consumeSpecialNameChar("R", 34 /* BeforeScript2 */);
  4321. var stateBeforeScript2 = consumeSpecialNameChar("I", 35 /* BeforeScript3 */);
  4322. var stateBeforeScript3 = consumeSpecialNameChar("P", 36 /* BeforeScript4 */);
  4323. var stateBeforeScript4 = consumeSpecialNameChar("T", 37 /* BeforeScript5 */);
  4324. var stateAfterScript1 = ifElseState("R", 39 /* AfterScript2 */, 1 /* Text */);
  4325. var stateAfterScript2 = ifElseState("I", 40 /* AfterScript3 */, 1 /* Text */);
  4326. var stateAfterScript3 = ifElseState("P", 41 /* AfterScript4 */, 1 /* Text */);
  4327. var stateAfterScript4 = ifElseState("T", 42 /* AfterScript5 */, 1 /* Text */);
  4328. var stateBeforeStyle1 = consumeSpecialNameChar("Y", 44 /* BeforeStyle2 */);
  4329. var stateBeforeStyle2 = consumeSpecialNameChar("L", 45 /* BeforeStyle3 */);
  4330. var stateBeforeStyle3 = consumeSpecialNameChar("E", 46 /* BeforeStyle4 */);
  4331. var stateAfterStyle1 = ifElseState("Y", 48 /* AfterStyle2 */, 1 /* Text */);
  4332. var stateAfterStyle2 = ifElseState("L", 49 /* AfterStyle3 */, 1 /* Text */);
  4333. var stateAfterStyle3 = ifElseState("E", 50 /* AfterStyle4 */, 1 /* Text */);
  4334. var stateBeforeEntity = ifElseState("#", 52 /* BeforeNumericEntity */, 53 /* InNamedEntity */);
  4335. var stateBeforeNumericEntity = ifElseState("X", 55 /* InHexEntity */, 54 /* InNumericEntity */);
  4336. var Tokenizer = /** @class */ (function () {
  4337. function Tokenizer(options, cbs) {
  4338. /** The current state the tokenizer is in. */
  4339. this._state = 1 /* Text */;
  4340. /** The read buffer. */
  4341. this._buffer = "";
  4342. /** The beginning of the section that is currently being read. */
  4343. this._sectionStart = 0;
  4344. /** The index within the buffer that we are currently looking at. */
  4345. this._index = 0;
  4346. /**
  4347. * Data that has already been processed will be removed from the buffer occasionally.
  4348. * `_bufferOffset` keeps track of how many characters have been removed, to make sure position information is accurate.
  4349. */
  4350. this._bufferOffset = 0;
  4351. /** Some behavior, eg. when decoding entities, is done while we are in another state. This keeps track of the other state type. */
  4352. this._baseState = 1 /* Text */;
  4353. /** For special parsing behavior inside of script and style tags. */
  4354. this._special = 1 /* None */;
  4355. /** Indicates whether the tokenizer has been paused. */
  4356. this._running = true;
  4357. /** Indicates whether the tokenizer has finished running / `.end` has been called. */
  4358. this._ended = false;
  4359. this._cbs = cbs;
  4360. this._xmlMode = !!(options && options.xmlMode);
  4361. this._decodeEntities = !!(options && options.decodeEntities);
  4362. }
  4363. Tokenizer.prototype.reset = function () {
  4364. this._state = 1 /* Text */;
  4365. this._buffer = "";
  4366. this._sectionStart = 0;
  4367. this._index = 0;
  4368. this._bufferOffset = 0;
  4369. this._baseState = 1 /* Text */;
  4370. this._special = 1 /* None */;
  4371. this._running = true;
  4372. this._ended = false;
  4373. };
  4374. Tokenizer.prototype._stateText = function (c) {
  4375. if (c === "<") {
  4376. if (this._index > this._sectionStart) {
  4377. this._cbs.ontext(this._getSection());
  4378. }
  4379. this._state = 2 /* BeforeTagName */;
  4380. this._sectionStart = this._index;
  4381. }
  4382. else if (this._decodeEntities &&
  4383. this._special === 1 /* None */ &&
  4384. c === "&") {
  4385. if (this._index > this._sectionStart) {
  4386. this._cbs.ontext(this._getSection());
  4387. }
  4388. this._baseState = 1 /* Text */;
  4389. this._state = 51 /* BeforeEntity */;
  4390. this._sectionStart = this._index;
  4391. }
  4392. };
  4393. Tokenizer.prototype._stateBeforeTagName = function (c) {
  4394. if (c === "/") {
  4395. this._state = 5 /* BeforeClosingTagName */;
  4396. }
  4397. else if (c === "<") {
  4398. this._cbs.ontext(this._getSection());
  4399. this._sectionStart = this._index;
  4400. }
  4401. else if (c === ">" ||
  4402. this._special !== 1 /* None */ ||
  4403. whitespace(c)) {
  4404. this._state = 1 /* Text */;
  4405. }
  4406. else if (c === "!") {
  4407. this._state = 15 /* BeforeDeclaration */;
  4408. this._sectionStart = this._index + 1;
  4409. }
  4410. else if (c === "?") {
  4411. this._state = 17 /* InProcessingInstruction */;
  4412. this._sectionStart = this._index + 1;
  4413. }
  4414. else {
  4415. this._state =
  4416. !this._xmlMode && (c === "s" || c === "S")
  4417. ? 31 /* BeforeSpecial */
  4418. : 3 /* InTagName */;
  4419. this._sectionStart = this._index;
  4420. }
  4421. };
  4422. Tokenizer.prototype._stateInTagName = function (c) {
  4423. if (c === "/" || c === ">" || whitespace(c)) {
  4424. this._emitToken("onopentagname");
  4425. this._state = 8 /* BeforeAttributeName */;
  4426. this._index--;
  4427. }
  4428. };
  4429. Tokenizer.prototype._stateBeforeClosingTagName = function (c) {
  4430. if (whitespace(c)) {
  4431. // ignore
  4432. }
  4433. else if (c === ">") {
  4434. this._state = 1 /* Text */;
  4435. }
  4436. else if (this._special !== 1 /* None */) {
  4437. if (c === "s" || c === "S") {
  4438. this._state = 32 /* BeforeSpecialEnd */;
  4439. }
  4440. else {
  4441. this._state = 1 /* Text */;
  4442. this._index--;
  4443. }
  4444. }
  4445. else {
  4446. this._state = 6 /* InClosingTagName */;
  4447. this._sectionStart = this._index;
  4448. }
  4449. };
  4450. Tokenizer.prototype._stateInClosingTagName = function (c) {
  4451. if (c === ">" || whitespace(c)) {
  4452. this._emitToken("onclosetag");
  4453. this._state = 7 /* AfterClosingTagName */;
  4454. this._index--;
  4455. }
  4456. };
  4457. Tokenizer.prototype._stateAfterClosingTagName = function (c) {
  4458. //skip everything until ">"
  4459. if (c === ">") {
  4460. this._state = 1 /* Text */;
  4461. this._sectionStart = this._index + 1;
  4462. }
  4463. };
  4464. Tokenizer.prototype._stateBeforeAttributeName = function (c) {
  4465. if (c === ">") {
  4466. this._cbs.onopentagend();
  4467. this._state = 1 /* Text */;
  4468. this._sectionStart = this._index + 1;
  4469. }
  4470. else if (c === "/") {
  4471. this._state = 4 /* InSelfClosingTag */;
  4472. }
  4473. else if (!whitespace(c)) {
  4474. this._state = 9 /* InAttributeName */;
  4475. this._sectionStart = this._index;
  4476. }
  4477. };
  4478. Tokenizer.prototype._stateInSelfClosingTag = function (c) {
  4479. if (c === ">") {
  4480. this._cbs.onselfclosingtag();
  4481. this._state = 1 /* Text */;
  4482. this._sectionStart = this._index + 1;
  4483. }
  4484. else if (!whitespace(c)) {
  4485. this._state = 8 /* BeforeAttributeName */;
  4486. this._index--;
  4487. }
  4488. };
  4489. Tokenizer.prototype._stateInAttributeName = function (c) {
  4490. if (c === "=" || c === "/" || c === ">" || whitespace(c)) {
  4491. this._cbs.onattribname(this._getSection());
  4492. this._sectionStart = -1;
  4493. this._state = 10 /* AfterAttributeName */;
  4494. this._index--;
  4495. }
  4496. };
  4497. Tokenizer.prototype._stateAfterAttributeName = function (c) {
  4498. if (c === "=") {
  4499. this._state = 11 /* BeforeAttributeValue */;
  4500. }
  4501. else if (c === "/" || c === ">") {
  4502. this._cbs.onattribend();
  4503. this._state = 8 /* BeforeAttributeName */;
  4504. this._index--;
  4505. }
  4506. else if (!whitespace(c)) {
  4507. this._cbs.onattribend();
  4508. this._state = 9 /* InAttributeName */;
  4509. this._sectionStart = this._index;
  4510. }
  4511. };
  4512. Tokenizer.prototype._stateBeforeAttributeValue = function (c) {
  4513. if (c === '"') {
  4514. this._state = 12 /* InAttributeValueDq */;
  4515. this._sectionStart = this._index + 1;
  4516. }
  4517. else if (c === "'") {
  4518. this._state = 13 /* InAttributeValueSq */;
  4519. this._sectionStart = this._index + 1;
  4520. }
  4521. else if (!whitespace(c)) {
  4522. this._state = 14 /* InAttributeValueNq */;
  4523. this._sectionStart = this._index;
  4524. this._index--; //reconsume token
  4525. }
  4526. };
  4527. Tokenizer.prototype._stateInAttributeValueDoubleQuotes = function (c) {
  4528. if (c === '"') {
  4529. this._emitToken("onattribdata");
  4530. this._cbs.onattribend();
  4531. this._state = 8 /* BeforeAttributeName */;
  4532. }
  4533. else if (this._decodeEntities && c === "&") {
  4534. this._emitToken("onattribdata");
  4535. this._baseState = this._state;
  4536. this._state = 51 /* BeforeEntity */;
  4537. this._sectionStart = this._index;
  4538. }
  4539. };
  4540. Tokenizer.prototype._stateInAttributeValueSingleQuotes = function (c) {
  4541. if (c === "'") {
  4542. this._emitToken("onattribdata");
  4543. this._cbs.onattribend();
  4544. this._state = 8 /* BeforeAttributeName */;
  4545. }
  4546. else if (this._decodeEntities && c === "&") {
  4547. this._emitToken("onattribdata");
  4548. this._baseState = this._state;
  4549. this._state = 51 /* BeforeEntity */;
  4550. this._sectionStart = this._index;
  4551. }
  4552. };
  4553. Tokenizer.prototype._stateInAttributeValueNoQuotes = function (c) {
  4554. if (whitespace(c) || c === ">") {
  4555. this._emitToken("onattribdata");
  4556. this._cbs.onattribend();
  4557. this._state = 8 /* BeforeAttributeName */;
  4558. this._index--;
  4559. }
  4560. else if (this._decodeEntities && c === "&") {
  4561. this._emitToken("onattribdata");
  4562. this._baseState = this._state;
  4563. this._state = 51 /* BeforeEntity */;
  4564. this._sectionStart = this._index;
  4565. }
  4566. };
  4567. Tokenizer.prototype._stateBeforeDeclaration = function (c) {
  4568. this._state =
  4569. c === "["
  4570. ? 22 /* BeforeCdata1 */
  4571. : c === "-"
  4572. ? 18 /* BeforeComment */
  4573. : 16 /* InDeclaration */;
  4574. };
  4575. Tokenizer.prototype._stateInDeclaration = function (c) {
  4576. if (c === ">") {
  4577. this._cbs.ondeclaration(this._getSection());
  4578. this._state = 1 /* Text */;
  4579. this._sectionStart = this._index + 1;
  4580. }
  4581. };
  4582. Tokenizer.prototype._stateInProcessingInstruction = function (c) {
  4583. if (c === ">") {
  4584. this._cbs.onprocessinginstruction(this._getSection());
  4585. this._state = 1 /* Text */;
  4586. this._sectionStart = this._index + 1;
  4587. }
  4588. };
  4589. Tokenizer.prototype._stateBeforeComment = function (c) {
  4590. if (c === "-") {
  4591. this._state = 19 /* InComment */;
  4592. this._sectionStart = this._index + 1;
  4593. }
  4594. else {
  4595. this._state = 16 /* InDeclaration */;
  4596. }
  4597. };
  4598. Tokenizer.prototype._stateInComment = function (c) {
  4599. if (c === "-")
  4600. this._state = 20 /* AfterComment1 */;
  4601. };
  4602. Tokenizer.prototype._stateAfterComment1 = function (c) {
  4603. if (c === "-") {
  4604. this._state = 21 /* AfterComment2 */;
  4605. }
  4606. else {
  4607. this._state = 19 /* InComment */;
  4608. }
  4609. };
  4610. Tokenizer.prototype._stateAfterComment2 = function (c) {
  4611. if (c === ">") {
  4612. //remove 2 trailing chars
  4613. this._cbs.oncomment(this._buffer.substring(this._sectionStart, this._index - 2));
  4614. this._state = 1 /* Text */;
  4615. this._sectionStart = this._index + 1;
  4616. }
  4617. else if (c !== "-") {
  4618. this._state = 19 /* InComment */;
  4619. }
  4620. // else: stay in AFTER_COMMENT_2 (`--->`)
  4621. };
  4622. Tokenizer.prototype._stateBeforeCdata6 = function (c) {
  4623. if (c === "[") {
  4624. this._state = 28 /* InCdata */;
  4625. this._sectionStart = this._index + 1;
  4626. }
  4627. else {
  4628. this._state = 16 /* InDeclaration */;
  4629. this._index--;
  4630. }
  4631. };
  4632. Tokenizer.prototype._stateInCdata = function (c) {
  4633. if (c === "]")
  4634. this._state = 29 /* AfterCdata1 */;
  4635. };
  4636. Tokenizer.prototype._stateAfterCdata1 = function (c) {
  4637. if (c === "]")
  4638. this._state = 30 /* AfterCdata2 */;
  4639. else
  4640. this._state = 28 /* InCdata */;
  4641. };
  4642. Tokenizer.prototype._stateAfterCdata2 = function (c) {
  4643. if (c === ">") {
  4644. //remove 2 trailing chars
  4645. this._cbs.oncdata(this._buffer.substring(this._sectionStart, this._index - 2));
  4646. this._state = 1 /* Text */;
  4647. this._sectionStart = this._index + 1;
  4648. }
  4649. else if (c !== "]") {
  4650. this._state = 28 /* InCdata */;
  4651. }
  4652. //else: stay in AFTER_CDATA_2 (`]]]>`)
  4653. };
  4654. Tokenizer.prototype._stateBeforeSpecial = function (c) {
  4655. if (c === "c" || c === "C") {
  4656. this._state = 33 /* BeforeScript1 */;
  4657. }
  4658. else if (c === "t" || c === "T") {
  4659. this._state = 43 /* BeforeStyle1 */;
  4660. }
  4661. else {
  4662. this._state = 3 /* InTagName */;
  4663. this._index--; //consume the token again
  4664. }
  4665. };
  4666. Tokenizer.prototype._stateBeforeSpecialEnd = function (c) {
  4667. if (this._special === 2 /* Script */ && (c === "c" || c === "C")) {
  4668. this._state = 38 /* AfterScript1 */;
  4669. }
  4670. else if (this._special === 3 /* Style */ &&
  4671. (c === "t" || c === "T")) {
  4672. this._state = 47 /* AfterStyle1 */;
  4673. }
  4674. else
  4675. this._state = 1 /* Text */;
  4676. };
  4677. Tokenizer.prototype._stateBeforeScript5 = function (c) {
  4678. if (c === "/" || c === ">" || whitespace(c)) {
  4679. this._special = 2 /* Script */;
  4680. }
  4681. this._state = 3 /* InTagName */;
  4682. this._index--; //consume the token again
  4683. };
  4684. Tokenizer.prototype._stateAfterScript5 = function (c) {
  4685. if (c === ">" || whitespace(c)) {
  4686. this._special = 1 /* None */;
  4687. this._state = 6 /* InClosingTagName */;
  4688. this._sectionStart = this._index - 6;
  4689. this._index--; //reconsume the token
  4690. }
  4691. else
  4692. this._state = 1 /* Text */;
  4693. };
  4694. Tokenizer.prototype._stateBeforeStyle4 = function (c) {
  4695. if (c === "/" || c === ">" || whitespace(c)) {
  4696. this._special = 3 /* Style */;
  4697. }
  4698. this._state = 3 /* InTagName */;
  4699. this._index--; //consume the token again
  4700. };
  4701. Tokenizer.prototype._stateAfterStyle4 = function (c) {
  4702. if (c === ">" || whitespace(c)) {
  4703. this._special = 1 /* None */;
  4704. this._state = 6 /* InClosingTagName */;
  4705. this._sectionStart = this._index - 5;
  4706. this._index--; //reconsume the token
  4707. }
  4708. else
  4709. this._state = 1 /* Text */;
  4710. };
  4711. //for entities terminated with a semicolon
  4712. Tokenizer.prototype._parseNamedEntityStrict = function () {
  4713. //offset = 1
  4714. if (this._sectionStart + 1 < this._index) {
  4715. var entity = this._buffer.substring(this._sectionStart + 1, this._index), map = this._xmlMode ? xml_json_1.default : entities_json_1.default;
  4716. if (Object.prototype.hasOwnProperty.call(map, entity)) {
  4717. // @ts-ignore
  4718. this._emitPartial(map[entity]);
  4719. this._sectionStart = this._index + 1;
  4720. }
  4721. }
  4722. };
  4723. //parses legacy entities (without trailing semicolon)
  4724. Tokenizer.prototype._parseLegacyEntity = function () {
  4725. var start = this._sectionStart + 1;
  4726. var limit = this._index - start;
  4727. if (limit > 6)
  4728. limit = 6; // The max length of legacy entities is 6
  4729. while (limit >= 2) {
  4730. // The min length of legacy entities is 2
  4731. var entity = this._buffer.substr(start, limit);
  4732. if (Object.prototype.hasOwnProperty.call(legacy_json_1.default, entity)) {
  4733. // @ts-ignore
  4734. this._emitPartial(legacy_json_1.default[entity]);
  4735. this._sectionStart += limit + 1;
  4736. return;
  4737. }
  4738. else {
  4739. limit--;
  4740. }
  4741. }
  4742. };
  4743. Tokenizer.prototype._stateInNamedEntity = function (c) {
  4744. if (c === ";") {
  4745. this._parseNamedEntityStrict();
  4746. if (this._sectionStart + 1 < this._index && !this._xmlMode) {
  4747. this._parseLegacyEntity();
  4748. }
  4749. this._state = this._baseState;
  4750. }
  4751. else if ((c < "a" || c > "z") &&
  4752. (c < "A" || c > "Z") &&
  4753. (c < "0" || c > "9")) {
  4754. if (this._xmlMode || this._sectionStart + 1 === this._index) {
  4755. // ignore
  4756. }
  4757. else if (this._baseState !== 1 /* Text */) {
  4758. if (c !== "=") {
  4759. this._parseNamedEntityStrict();
  4760. }
  4761. }
  4762. else {
  4763. this._parseLegacyEntity();
  4764. }
  4765. this._state = this._baseState;
  4766. this._index--;
  4767. }
  4768. };
  4769. Tokenizer.prototype._decodeNumericEntity = function (offset, base) {
  4770. var sectionStart = this._sectionStart + offset;
  4771. if (sectionStart !== this._index) {
  4772. //parse entity
  4773. var entity = this._buffer.substring(sectionStart, this._index);
  4774. var parsed = parseInt(entity, base);
  4775. this._emitPartial(decode_codepoint_1.default(parsed));
  4776. this._sectionStart = this._index;
  4777. }
  4778. else {
  4779. this._sectionStart--;
  4780. }
  4781. this._state = this._baseState;
  4782. };
  4783. Tokenizer.prototype._stateInNumericEntity = function (c) {
  4784. if (c === ";") {
  4785. this._decodeNumericEntity(2, 10);
  4786. this._sectionStart++;
  4787. }
  4788. else if (c < "0" || c > "9") {
  4789. if (!this._xmlMode) {
  4790. this._decodeNumericEntity(2, 10);
  4791. }
  4792. else {
  4793. this._state = this._baseState;
  4794. }
  4795. this._index--;
  4796. }
  4797. };
  4798. Tokenizer.prototype._stateInHexEntity = function (c) {
  4799. if (c === ";") {
  4800. this._decodeNumericEntity(3, 16);
  4801. this._sectionStart++;
  4802. }
  4803. else if ((c < "a" || c > "f") &&
  4804. (c < "A" || c > "F") &&
  4805. (c < "0" || c > "9")) {
  4806. if (!this._xmlMode) {
  4807. this._decodeNumericEntity(3, 16);
  4808. }
  4809. else {
  4810. this._state = this._baseState;
  4811. }
  4812. this._index--;
  4813. }
  4814. };
  4815. Tokenizer.prototype._cleanup = function () {
  4816. if (this._sectionStart < 0) {
  4817. this._buffer = "";
  4818. this._bufferOffset += this._index;
  4819. this._index = 0;
  4820. }
  4821. else if (this._running) {
  4822. if (this._state === 1 /* Text */) {
  4823. if (this._sectionStart !== this._index) {
  4824. this._cbs.ontext(this._buffer.substr(this._sectionStart));
  4825. }
  4826. this._buffer = "";
  4827. this._bufferOffset += this._index;
  4828. this._index = 0;
  4829. }
  4830. else if (this._sectionStart === this._index) {
  4831. //the section just started
  4832. this._buffer = "";
  4833. this._bufferOffset += this._index;
  4834. this._index = 0;
  4835. }
  4836. else {
  4837. //remove everything unnecessary
  4838. this._buffer = this._buffer.substr(this._sectionStart);
  4839. this._index -= this._sectionStart;
  4840. this._bufferOffset += this._sectionStart;
  4841. }
  4842. this._sectionStart = 0;
  4843. }
  4844. };
  4845. //TODO make events conditional
  4846. Tokenizer.prototype.write = function (chunk) {
  4847. if (this._ended)
  4848. this._cbs.onerror(Error(".write() after done!"));
  4849. this._buffer += chunk;
  4850. this._parse();
  4851. };
  4852. // Iterates through the buffer, calling the function corresponding to the current state.
  4853. // States that are more likely to be hit are higher up, as a performance improvement.
  4854. Tokenizer.prototype._parse = function () {
  4855. while (this._index < this._buffer.length && this._running) {
  4856. var c = this._buffer.charAt(this._index);
  4857. if (this._state === 1 /* Text */) {
  4858. this._stateText(c);
  4859. }
  4860. else if (this._state === 12 /* InAttributeValueDq */) {
  4861. this._stateInAttributeValueDoubleQuotes(c);
  4862. }
  4863. else if (this._state === 9 /* InAttributeName */) {
  4864. this._stateInAttributeName(c);
  4865. }
  4866. else if (this._state === 19 /* InComment */) {
  4867. this._stateInComment(c);
  4868. }
  4869. else if (this._state === 8 /* BeforeAttributeName */) {
  4870. this._stateBeforeAttributeName(c);
  4871. }
  4872. else if (this._state === 3 /* InTagName */) {
  4873. this._stateInTagName(c);
  4874. }
  4875. else if (this._state === 6 /* InClosingTagName */) {
  4876. this._stateInClosingTagName(c);
  4877. }
  4878. else if (this._state === 2 /* BeforeTagName */) {
  4879. this._stateBeforeTagName(c);
  4880. }
  4881. else if (this._state === 10 /* AfterAttributeName */) {
  4882. this._stateAfterAttributeName(c);
  4883. }
  4884. else if (this._state === 13 /* InAttributeValueSq */) {
  4885. this._stateInAttributeValueSingleQuotes(c);
  4886. }
  4887. else if (this._state === 11 /* BeforeAttributeValue */) {
  4888. this._stateBeforeAttributeValue(c);
  4889. }
  4890. else if (this._state === 5 /* BeforeClosingTagName */) {
  4891. this._stateBeforeClosingTagName(c);
  4892. }
  4893. else if (this._state === 7 /* AfterClosingTagName */) {
  4894. this._stateAfterClosingTagName(c);
  4895. }
  4896. else if (this._state === 31 /* BeforeSpecial */) {
  4897. this._stateBeforeSpecial(c);
  4898. }
  4899. else if (this._state === 20 /* AfterComment1 */) {
  4900. this._stateAfterComment1(c);
  4901. }
  4902. else if (this._state === 14 /* InAttributeValueNq */) {
  4903. this._stateInAttributeValueNoQuotes(c);
  4904. }
  4905. else if (this._state === 4 /* InSelfClosingTag */) {
  4906. this._stateInSelfClosingTag(c);
  4907. }
  4908. else if (this._state === 16 /* InDeclaration */) {
  4909. this._stateInDeclaration(c);
  4910. }
  4911. else if (this._state === 15 /* BeforeDeclaration */) {
  4912. this._stateBeforeDeclaration(c);
  4913. }
  4914. else if (this._state === 21 /* AfterComment2 */) {
  4915. this._stateAfterComment2(c);
  4916. }
  4917. else if (this._state === 18 /* BeforeComment */) {
  4918. this._stateBeforeComment(c);
  4919. }
  4920. else if (this._state === 32 /* BeforeSpecialEnd */) {
  4921. this._stateBeforeSpecialEnd(c);
  4922. }
  4923. else if (this._state === 38 /* AfterScript1 */) {
  4924. stateAfterScript1(this, c);
  4925. }
  4926. else if (this._state === 39 /* AfterScript2 */) {
  4927. stateAfterScript2(this, c);
  4928. }
  4929. else if (this._state === 40 /* AfterScript3 */) {
  4930. stateAfterScript3(this, c);
  4931. }
  4932. else if (this._state === 33 /* BeforeScript1 */) {
  4933. stateBeforeScript1(this, c);
  4934. }
  4935. else if (this._state === 34 /* BeforeScript2 */) {
  4936. stateBeforeScript2(this, c);
  4937. }
  4938. else if (this._state === 35 /* BeforeScript3 */) {
  4939. stateBeforeScript3(this, c);
  4940. }
  4941. else if (this._state === 36 /* BeforeScript4 */) {
  4942. stateBeforeScript4(this, c);
  4943. }
  4944. else if (this._state === 37 /* BeforeScript5 */) {
  4945. this._stateBeforeScript5(c);
  4946. }
  4947. else if (this._state === 41 /* AfterScript4 */) {
  4948. stateAfterScript4(this, c);
  4949. }
  4950. else if (this._state === 42 /* AfterScript5 */) {
  4951. this._stateAfterScript5(c);
  4952. }
  4953. else if (this._state === 43 /* BeforeStyle1 */) {
  4954. stateBeforeStyle1(this, c);
  4955. }
  4956. else if (this._state === 28 /* InCdata */) {
  4957. this._stateInCdata(c);
  4958. }
  4959. else if (this._state === 44 /* BeforeStyle2 */) {
  4960. stateBeforeStyle2(this, c);
  4961. }
  4962. else if (this._state === 45 /* BeforeStyle3 */) {
  4963. stateBeforeStyle3(this, c);
  4964. }
  4965. else if (this._state === 46 /* BeforeStyle4 */) {
  4966. this._stateBeforeStyle4(c);
  4967. }
  4968. else if (this._state === 47 /* AfterStyle1 */) {
  4969. stateAfterStyle1(this, c);
  4970. }
  4971. else if (this._state === 48 /* AfterStyle2 */) {
  4972. stateAfterStyle2(this, c);
  4973. }
  4974. else if (this._state === 49 /* AfterStyle3 */) {
  4975. stateAfterStyle3(this, c);
  4976. }
  4977. else if (this._state === 50 /* AfterStyle4 */) {
  4978. this._stateAfterStyle4(c);
  4979. }
  4980. else if (this._state === 17 /* InProcessingInstruction */) {
  4981. this._stateInProcessingInstruction(c);
  4982. }
  4983. else if (this._state === 53 /* InNamedEntity */) {
  4984. this._stateInNamedEntity(c);
  4985. }
  4986. else if (this._state === 22 /* BeforeCdata1 */) {
  4987. stateBeforeCdata1(this, c);
  4988. }
  4989. else if (this._state === 51 /* BeforeEntity */) {
  4990. stateBeforeEntity(this, c);
  4991. }
  4992. else if (this._state === 23 /* BeforeCdata2 */) {
  4993. stateBeforeCdata2(this, c);
  4994. }
  4995. else if (this._state === 24 /* BeforeCdata3 */) {
  4996. stateBeforeCdata3(this, c);
  4997. }
  4998. else if (this._state === 29 /* AfterCdata1 */) {
  4999. this._stateAfterCdata1(c);
  5000. }
  5001. else if (this._state === 30 /* AfterCdata2 */) {
  5002. this._stateAfterCdata2(c);
  5003. }
  5004. else if (this._state === 25 /* BeforeCdata4 */) {
  5005. stateBeforeCdata4(this, c);
  5006. }
  5007. else if (this._state === 26 /* BeforeCdata5 */) {
  5008. stateBeforeCdata5(this, c);
  5009. }
  5010. else if (this._state === 27 /* BeforeCdata6 */) {
  5011. this._stateBeforeCdata6(c);
  5012. }
  5013. else if (this._state === 55 /* InHexEntity */) {
  5014. this._stateInHexEntity(c);
  5015. }
  5016. else if (this._state === 54 /* InNumericEntity */) {
  5017. this._stateInNumericEntity(c);
  5018. }
  5019. else if (this._state === 52 /* BeforeNumericEntity */) {
  5020. stateBeforeNumericEntity(this, c);
  5021. }
  5022. else {
  5023. this._cbs.onerror(Error("unknown _state"), this._state);
  5024. }
  5025. this._index++;
  5026. }
  5027. this._cleanup();
  5028. };
  5029. Tokenizer.prototype.pause = function () {
  5030. this._running = false;
  5031. };
  5032. Tokenizer.prototype.resume = function () {
  5033. this._running = true;
  5034. if (this._index < this._buffer.length) {
  5035. this._parse();
  5036. }
  5037. if (this._ended) {
  5038. this._finish();
  5039. }
  5040. };
  5041. Tokenizer.prototype.end = function (chunk) {
  5042. if (this._ended)
  5043. this._cbs.onerror(Error(".end() after done!"));
  5044. if (chunk)
  5045. this.write(chunk);
  5046. this._ended = true;
  5047. if (this._running)
  5048. this._finish();
  5049. };
  5050. Tokenizer.prototype._finish = function () {
  5051. //if there is remaining data, emit it in a reasonable way
  5052. if (this._sectionStart < this._index) {
  5053. this._handleTrailingData();
  5054. }
  5055. this._cbs.onend();
  5056. };
  5057. Tokenizer.prototype._handleTrailingData = function () {
  5058. var data = this._buffer.substr(this._sectionStart);
  5059. if (this._state === 28 /* InCdata */ ||
  5060. this._state === 29 /* AfterCdata1 */ ||
  5061. this._state === 30 /* AfterCdata2 */) {
  5062. this._cbs.oncdata(data);
  5063. }
  5064. else if (this._state === 19 /* InComment */ ||
  5065. this._state === 20 /* AfterComment1 */ ||
  5066. this._state === 21 /* AfterComment2 */) {
  5067. this._cbs.oncomment(data);
  5068. }
  5069. else if (this._state === 53 /* InNamedEntity */ && !this._xmlMode) {
  5070. this._parseLegacyEntity();
  5071. if (this._sectionStart < this._index) {
  5072. this._state = this._baseState;
  5073. this._handleTrailingData();
  5074. }
  5075. }
  5076. else if (this._state === 54 /* InNumericEntity */ && !this._xmlMode) {
  5077. this._decodeNumericEntity(2, 10);
  5078. if (this._sectionStart < this._index) {
  5079. this._state = this._baseState;
  5080. this._handleTrailingData();
  5081. }
  5082. }
  5083. else if (this._state === 55 /* InHexEntity */ && !this._xmlMode) {
  5084. this._decodeNumericEntity(3, 16);
  5085. if (this._sectionStart < this._index) {
  5086. this._state = this._baseState;
  5087. this._handleTrailingData();
  5088. }
  5089. }
  5090. else if (this._state !== 3 /* InTagName */ &&
  5091. this._state !== 8 /* BeforeAttributeName */ &&
  5092. this._state !== 11 /* BeforeAttributeValue */ &&
  5093. this._state !== 10 /* AfterAttributeName */ &&
  5094. this._state !== 9 /* InAttributeName */ &&
  5095. this._state !== 13 /* InAttributeValueSq */ &&
  5096. this._state !== 12 /* InAttributeValueDq */ &&
  5097. this._state !== 14 /* InAttributeValueNq */ &&
  5098. this._state !== 6 /* InClosingTagName */) {
  5099. this._cbs.ontext(data);
  5100. }
  5101. //else, ignore remaining data
  5102. //TODO add a way to remove current tag
  5103. };
  5104. Tokenizer.prototype.getAbsoluteIndex = function () {
  5105. return this._bufferOffset + this._index;
  5106. };
  5107. Tokenizer.prototype._getSection = function () {
  5108. return this._buffer.substring(this._sectionStart, this._index);
  5109. };
  5110. Tokenizer.prototype._emitToken = function (name) {
  5111. this._cbs[name](this._getSection());
  5112. this._sectionStart = -1;
  5113. };
  5114. Tokenizer.prototype._emitPartial = function (value) {
  5115. if (this._baseState !== 1 /* Text */) {
  5116. this._cbs.onattribdata(value); //TODO implement the new event
  5117. }
  5118. else {
  5119. this._cbs.ontext(value);
  5120. }
  5121. };
  5122. return Tokenizer;
  5123. }());
  5124. exports.default = Tokenizer;
  5125. },{"entities/lib/decode_codepoint":18,"entities/lib/maps/entities.json":22,"entities/lib/maps/legacy.json":23,"entities/lib/maps/xml.json":24}],31:[function(require,module,exports){
  5126. "use strict";
  5127. function __export(m) {
  5128. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  5129. }
  5130. var __importStar = (this && this.__importStar) || function (mod) {
  5131. if (mod && mod.__esModule) return mod;
  5132. var result = {};
  5133. if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  5134. result["default"] = mod;
  5135. return result;
  5136. };
  5137. Object.defineProperty(exports, "__esModule", { value: true });
  5138. var Parser_1 = require("./Parser");
  5139. exports.Parser = Parser_1.Parser;
  5140. var domhandler_1 = require("domhandler");
  5141. exports.DomHandler = domhandler_1.DomHandler;
  5142. exports.DefaultHandler = domhandler_1.DomHandler;
  5143. // Helper methods
  5144. /**
  5145. * Parses data, returns the resulting DOM.
  5146. *
  5147. * @param data The data that should be parsed.
  5148. * @param options Optional options for the parser and DOM builder.
  5149. */
  5150. function parseDOM(data, options) {
  5151. var handler = new domhandler_1.DomHandler(void 0, options);
  5152. new Parser_1.Parser(handler, options).end(data);
  5153. return handler.dom;
  5154. }
  5155. exports.parseDOM = parseDOM;
  5156. /**
  5157. * Creates a parser instance, with an attached DOM handler.
  5158. *
  5159. * @param cb A callback that will be called once parsing has been completed.
  5160. * @param options Optional options for the parser and DOM builder.
  5161. * @param elementCb An optional callback that will be called every time a tag has been completed inside of the DOM.
  5162. */
  5163. function createDomStream(cb, options, elementCb) {
  5164. var handler = new domhandler_1.DomHandler(cb, options, elementCb);
  5165. return new Parser_1.Parser(handler, options);
  5166. }
  5167. exports.createDomStream = createDomStream;
  5168. var Tokenizer_1 = require("./Tokenizer");
  5169. exports.Tokenizer = Tokenizer_1.default;
  5170. var ElementType = __importStar(require("domelementtype"));
  5171. exports.ElementType = ElementType;
  5172. /**
  5173. * List of all events that the parser emits.
  5174. *
  5175. * Format: eventname: number of arguments.
  5176. */
  5177. exports.EVENTS = {
  5178. attribute: 2,
  5179. cdatastart: 0,
  5180. cdataend: 0,
  5181. text: 1,
  5182. processinginstruction: 2,
  5183. comment: 1,
  5184. commentend: 0,
  5185. closetag: 1,
  5186. opentag: 2,
  5187. opentagname: 1,
  5188. error: 1,
  5189. end: 0
  5190. };
  5191. /*
  5192. All of the following exports exist for backwards-compatibility.
  5193. They should probably be removed eventually.
  5194. */
  5195. __export(require("./FeedHandler"));
  5196. __export(require("./WritableStream"));
  5197. __export(require("./CollectingHandler"));
  5198. var DomUtils = __importStar(require("domutils"));
  5199. exports.DomUtils = DomUtils;
  5200. var FeedHandler_1 = require("./FeedHandler");
  5201. exports.RssHandler = FeedHandler_1.FeedHandler;
  5202. },{"./CollectingHandler":26,"./FeedHandler":27,"./Parser":29,"./Tokenizer":30,"./WritableStream":2,"domelementtype":6,"domhandler":7,"domutils":10}],32:[function(require,module,exports){
  5203. exports.read = function (buffer, offset, isLE, mLen, nBytes) {
  5204. var e, m
  5205. var eLen = (nBytes * 8) - mLen - 1
  5206. var eMax = (1 << eLen) - 1
  5207. var eBias = eMax >> 1
  5208. var nBits = -7
  5209. var i = isLE ? (nBytes - 1) : 0
  5210. var d = isLE ? -1 : 1
  5211. var s = buffer[offset + i]
  5212. i += d
  5213. e = s & ((1 << (-nBits)) - 1)
  5214. s >>= (-nBits)
  5215. nBits += eLen
  5216. for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}
  5217. m = e & ((1 << (-nBits)) - 1)
  5218. e >>= (-nBits)
  5219. nBits += mLen
  5220. for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}
  5221. if (e === 0) {
  5222. e = 1 - eBias
  5223. } else if (e === eMax) {
  5224. return m ? NaN : ((s ? -1 : 1) * Infinity)
  5225. } else {
  5226. m = m + Math.pow(2, mLen)
  5227. e = e - eBias
  5228. }
  5229. return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
  5230. }
  5231. exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
  5232. var e, m, c
  5233. var eLen = (nBytes * 8) - mLen - 1
  5234. var eMax = (1 << eLen) - 1
  5235. var eBias = eMax >> 1
  5236. var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
  5237. var i = isLE ? 0 : (nBytes - 1)
  5238. var d = isLE ? 1 : -1
  5239. var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
  5240. value = Math.abs(value)
  5241. if (isNaN(value) || value === Infinity) {
  5242. m = isNaN(value) ? 1 : 0
  5243. e = eMax
  5244. } else {
  5245. e = Math.floor(Math.log(value) / Math.LN2)
  5246. if (value * (c = Math.pow(2, -e)) < 1) {
  5247. e--
  5248. c *= 2
  5249. }
  5250. if (e + eBias >= 1) {
  5251. value += rt / c
  5252. } else {
  5253. value += rt * Math.pow(2, 1 - eBias)
  5254. }
  5255. if (value * c >= 2) {
  5256. e++
  5257. c /= 2
  5258. }
  5259. if (e + eBias >= eMax) {
  5260. m = 0
  5261. e = eMax
  5262. } else if (e + eBias >= 1) {
  5263. m = ((value * c) - 1) * Math.pow(2, mLen)
  5264. e = e + eBias
  5265. } else {
  5266. m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
  5267. e = 0
  5268. }
  5269. }
  5270. for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
  5271. e = (e << mLen) | m
  5272. eLen += mLen
  5273. for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
  5274. buffer[offset + i - d] |= s * 128
  5275. }
  5276. },{}],33:[function(require,module,exports){
  5277. var getNative = require('./_getNative'),
  5278. root = require('./_root');
  5279. /* Built-in method references that are verified to be native. */
  5280. var DataView = getNative(root, 'DataView');
  5281. module.exports = DataView;
  5282. },{"./_getNative":93,"./_root":130}],34:[function(require,module,exports){
  5283. var hashClear = require('./_hashClear'),
  5284. hashDelete = require('./_hashDelete'),
  5285. hashGet = require('./_hashGet'),
  5286. hashHas = require('./_hashHas'),
  5287. hashSet = require('./_hashSet');
  5288. /**
  5289. * Creates a hash object.
  5290. *
  5291. * @private
  5292. * @constructor
  5293. * @param {Array} [entries] The key-value pairs to cache.
  5294. */
  5295. function Hash(entries) {
  5296. var index = -1,
  5297. length = entries == null ? 0 : entries.length;
  5298. this.clear();
  5299. while (++index < length) {
  5300. var entry = entries[index];
  5301. this.set(entry[0], entry[1]);
  5302. }
  5303. }
  5304. // Add methods to `Hash`.
  5305. Hash.prototype.clear = hashClear;
  5306. Hash.prototype['delete'] = hashDelete;
  5307. Hash.prototype.get = hashGet;
  5308. Hash.prototype.has = hashHas;
  5309. Hash.prototype.set = hashSet;
  5310. module.exports = Hash;
  5311. },{"./_hashClear":100,"./_hashDelete":101,"./_hashGet":102,"./_hashHas":103,"./_hashSet":104}],35:[function(require,module,exports){
  5312. var listCacheClear = require('./_listCacheClear'),
  5313. listCacheDelete = require('./_listCacheDelete'),
  5314. listCacheGet = require('./_listCacheGet'),
  5315. listCacheHas = require('./_listCacheHas'),
  5316. listCacheSet = require('./_listCacheSet');
  5317. /**
  5318. * Creates an list cache object.
  5319. *
  5320. * @private
  5321. * @constructor
  5322. * @param {Array} [entries] The key-value pairs to cache.
  5323. */
  5324. function ListCache(entries) {
  5325. var index = -1,
  5326. length = entries == null ? 0 : entries.length;
  5327. this.clear();
  5328. while (++index < length) {
  5329. var entry = entries[index];
  5330. this.set(entry[0], entry[1]);
  5331. }
  5332. }
  5333. // Add methods to `ListCache`.
  5334. ListCache.prototype.clear = listCacheClear;
  5335. ListCache.prototype['delete'] = listCacheDelete;
  5336. ListCache.prototype.get = listCacheGet;
  5337. ListCache.prototype.has = listCacheHas;
  5338. ListCache.prototype.set = listCacheSet;
  5339. module.exports = ListCache;
  5340. },{"./_listCacheClear":113,"./_listCacheDelete":114,"./_listCacheGet":115,"./_listCacheHas":116,"./_listCacheSet":117}],36:[function(require,module,exports){
  5341. var getNative = require('./_getNative'),
  5342. root = require('./_root');
  5343. /* Built-in method references that are verified to be native. */
  5344. var Map = getNative(root, 'Map');
  5345. module.exports = Map;
  5346. },{"./_getNative":93,"./_root":130}],37:[function(require,module,exports){
  5347. var mapCacheClear = require('./_mapCacheClear'),
  5348. mapCacheDelete = require('./_mapCacheDelete'),
  5349. mapCacheGet = require('./_mapCacheGet'),
  5350. mapCacheHas = require('./_mapCacheHas'),
  5351. mapCacheSet = require('./_mapCacheSet');
  5352. /**
  5353. * Creates a map cache object to store key-value pairs.
  5354. *
  5355. * @private
  5356. * @constructor
  5357. * @param {Array} [entries] The key-value pairs to cache.
  5358. */
  5359. function MapCache(entries) {
  5360. var index = -1,
  5361. length = entries == null ? 0 : entries.length;
  5362. this.clear();
  5363. while (++index < length) {
  5364. var entry = entries[index];
  5365. this.set(entry[0], entry[1]);
  5366. }
  5367. }
  5368. // Add methods to `MapCache`.
  5369. MapCache.prototype.clear = mapCacheClear;
  5370. MapCache.prototype['delete'] = mapCacheDelete;
  5371. MapCache.prototype.get = mapCacheGet;
  5372. MapCache.prototype.has = mapCacheHas;
  5373. MapCache.prototype.set = mapCacheSet;
  5374. module.exports = MapCache;
  5375. },{"./_mapCacheClear":118,"./_mapCacheDelete":119,"./_mapCacheGet":120,"./_mapCacheHas":121,"./_mapCacheSet":122}],38:[function(require,module,exports){
  5376. var getNative = require('./_getNative'),
  5377. root = require('./_root');
  5378. /* Built-in method references that are verified to be native. */
  5379. var Promise = getNative(root, 'Promise');
  5380. module.exports = Promise;
  5381. },{"./_getNative":93,"./_root":130}],39:[function(require,module,exports){
  5382. var getNative = require('./_getNative'),
  5383. root = require('./_root');
  5384. /* Built-in method references that are verified to be native. */
  5385. var Set = getNative(root, 'Set');
  5386. module.exports = Set;
  5387. },{"./_getNative":93,"./_root":130}],40:[function(require,module,exports){
  5388. var ListCache = require('./_ListCache'),
  5389. stackClear = require('./_stackClear'),
  5390. stackDelete = require('./_stackDelete'),
  5391. stackGet = require('./_stackGet'),
  5392. stackHas = require('./_stackHas'),
  5393. stackSet = require('./_stackSet');
  5394. /**
  5395. * Creates a stack cache object to store key-value pairs.
  5396. *
  5397. * @private
  5398. * @constructor
  5399. * @param {Array} [entries] The key-value pairs to cache.
  5400. */
  5401. function Stack(entries) {
  5402. var data = this.__data__ = new ListCache(entries);
  5403. this.size = data.size;
  5404. }
  5405. // Add methods to `Stack`.
  5406. Stack.prototype.clear = stackClear;
  5407. Stack.prototype['delete'] = stackDelete;
  5408. Stack.prototype.get = stackGet;
  5409. Stack.prototype.has = stackHas;
  5410. Stack.prototype.set = stackSet;
  5411. module.exports = Stack;
  5412. },{"./_ListCache":35,"./_stackClear":134,"./_stackDelete":135,"./_stackGet":136,"./_stackHas":137,"./_stackSet":138}],41:[function(require,module,exports){
  5413. var root = require('./_root');
  5414. /** Built-in value references. */
  5415. var Symbol = root.Symbol;
  5416. module.exports = Symbol;
  5417. },{"./_root":130}],42:[function(require,module,exports){
  5418. var root = require('./_root');
  5419. /** Built-in value references. */
  5420. var Uint8Array = root.Uint8Array;
  5421. module.exports = Uint8Array;
  5422. },{"./_root":130}],43:[function(require,module,exports){
  5423. var getNative = require('./_getNative'),
  5424. root = require('./_root');
  5425. /* Built-in method references that are verified to be native. */
  5426. var WeakMap = getNative(root, 'WeakMap');
  5427. module.exports = WeakMap;
  5428. },{"./_getNative":93,"./_root":130}],44:[function(require,module,exports){
  5429. /**
  5430. * A faster alternative to `Function#apply`, this function invokes `func`
  5431. * with the `this` binding of `thisArg` and the arguments of `args`.
  5432. *
  5433. * @private
  5434. * @param {Function} func The function to invoke.
  5435. * @param {*} thisArg The `this` binding of `func`.
  5436. * @param {Array} args The arguments to invoke `func` with.
  5437. * @returns {*} Returns the result of `func`.
  5438. */
  5439. function apply(func, thisArg, args) {
  5440. switch (args.length) {
  5441. case 0: return func.call(thisArg);
  5442. case 1: return func.call(thisArg, args[0]);
  5443. case 2: return func.call(thisArg, args[0], args[1]);
  5444. case 3: return func.call(thisArg, args[0], args[1], args[2]);
  5445. }
  5446. return func.apply(thisArg, args);
  5447. }
  5448. module.exports = apply;
  5449. },{}],45:[function(require,module,exports){
  5450. /**
  5451. * A specialized version of `_.forEach` for arrays without support for
  5452. * iteratee shorthands.
  5453. *
  5454. * @private
  5455. * @param {Array} [array] The array to iterate over.
  5456. * @param {Function} iteratee The function invoked per iteration.
  5457. * @returns {Array} Returns `array`.
  5458. */
  5459. function arrayEach(array, iteratee) {
  5460. var index = -1,
  5461. length = array == null ? 0 : array.length;
  5462. while (++index < length) {
  5463. if (iteratee(array[index], index, array) === false) {
  5464. break;
  5465. }
  5466. }
  5467. return array;
  5468. }
  5469. module.exports = arrayEach;
  5470. },{}],46:[function(require,module,exports){
  5471. /**
  5472. * A specialized version of `_.filter` for arrays without support for
  5473. * iteratee shorthands.
  5474. *
  5475. * @private
  5476. * @param {Array} [array] The array to iterate over.
  5477. * @param {Function} predicate The function invoked per iteration.
  5478. * @returns {Array} Returns the new filtered array.
  5479. */
  5480. function arrayFilter(array, predicate) {
  5481. var index = -1,
  5482. length = array == null ? 0 : array.length,
  5483. resIndex = 0,
  5484. result = [];
  5485. while (++index < length) {
  5486. var value = array[index];
  5487. if (predicate(value, index, array)) {
  5488. result[resIndex++] = value;
  5489. }
  5490. }
  5491. return result;
  5492. }
  5493. module.exports = arrayFilter;
  5494. },{}],47:[function(require,module,exports){
  5495. var baseTimes = require('./_baseTimes'),
  5496. isArguments = require('./isArguments'),
  5497. isArray = require('./isArray'),
  5498. isBuffer = require('./isBuffer'),
  5499. isIndex = require('./_isIndex'),
  5500. isTypedArray = require('./isTypedArray');
  5501. /** Used for built-in method references. */
  5502. var objectProto = Object.prototype;
  5503. /** Used to check objects for own properties. */
  5504. var hasOwnProperty = objectProto.hasOwnProperty;
  5505. /**
  5506. * Creates an array of the enumerable property names of the array-like `value`.
  5507. *
  5508. * @private
  5509. * @param {*} value The value to query.
  5510. * @param {boolean} inherited Specify returning inherited property names.
  5511. * @returns {Array} Returns the array of property names.
  5512. */
  5513. function arrayLikeKeys(value, inherited) {
  5514. var isArr = isArray(value),
  5515. isArg = !isArr && isArguments(value),
  5516. isBuff = !isArr && !isArg && isBuffer(value),
  5517. isType = !isArr && !isArg && !isBuff && isTypedArray(value),
  5518. skipIndexes = isArr || isArg || isBuff || isType,
  5519. result = skipIndexes ? baseTimes(value.length, String) : [],
  5520. length = result.length;
  5521. for (var key in value) {
  5522. if ((inherited || hasOwnProperty.call(value, key)) &&
  5523. !(skipIndexes && (
  5524. // Safari 9 has enumerable `arguments.length` in strict mode.
  5525. key == 'length' ||
  5526. // Node.js 0.10 has enumerable non-index properties on buffers.
  5527. (isBuff && (key == 'offset' || key == 'parent')) ||
  5528. // PhantomJS 2 has enumerable non-index properties on typed arrays.
  5529. (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
  5530. // Skip index properties.
  5531. isIndex(key, length)
  5532. ))) {
  5533. result.push(key);
  5534. }
  5535. }
  5536. return result;
  5537. }
  5538. module.exports = arrayLikeKeys;
  5539. },{"./_baseTimes":72,"./_isIndex":108,"./isArguments":145,"./isArray":146,"./isBuffer":149,"./isTypedArray":159}],48:[function(require,module,exports){
  5540. /**
  5541. * A specialized version of `_.map` for arrays without support for iteratee
  5542. * shorthands.
  5543. *
  5544. * @private
  5545. * @param {Array} [array] The array to iterate over.
  5546. * @param {Function} iteratee The function invoked per iteration.
  5547. * @returns {Array} Returns the new mapped array.
  5548. */
  5549. function arrayMap(array, iteratee) {
  5550. var index = -1,
  5551. length = array == null ? 0 : array.length,
  5552. result = Array(length);
  5553. while (++index < length) {
  5554. result[index] = iteratee(array[index], index, array);
  5555. }
  5556. return result;
  5557. }
  5558. module.exports = arrayMap;
  5559. },{}],49:[function(require,module,exports){
  5560. /**
  5561. * Appends the elements of `values` to `array`.
  5562. *
  5563. * @private
  5564. * @param {Array} array The array to modify.
  5565. * @param {Array} values The values to append.
  5566. * @returns {Array} Returns `array`.
  5567. */
  5568. function arrayPush(array, values) {
  5569. var index = -1,
  5570. length = values.length,
  5571. offset = array.length;
  5572. while (++index < length) {
  5573. array[offset + index] = values[index];
  5574. }
  5575. return array;
  5576. }
  5577. module.exports = arrayPush;
  5578. },{}],50:[function(require,module,exports){
  5579. var baseAssignValue = require('./_baseAssignValue'),
  5580. eq = require('./eq');
  5581. /**
  5582. * This function is like `assignValue` except that it doesn't assign
  5583. * `undefined` values.
  5584. *
  5585. * @private
  5586. * @param {Object} object The object to modify.
  5587. * @param {string} key The key of the property to assign.
  5588. * @param {*} value The value to assign.
  5589. */
  5590. function assignMergeValue(object, key, value) {
  5591. if ((value !== undefined && !eq(object[key], value)) ||
  5592. (value === undefined && !(key in object))) {
  5593. baseAssignValue(object, key, value);
  5594. }
  5595. }
  5596. module.exports = assignMergeValue;
  5597. },{"./_baseAssignValue":55,"./eq":142}],51:[function(require,module,exports){
  5598. var baseAssignValue = require('./_baseAssignValue'),
  5599. eq = require('./eq');
  5600. /** Used for built-in method references. */
  5601. var objectProto = Object.prototype;
  5602. /** Used to check objects for own properties. */
  5603. var hasOwnProperty = objectProto.hasOwnProperty;
  5604. /**
  5605. * Assigns `value` to `key` of `object` if the existing value is not equivalent
  5606. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  5607. * for equality comparisons.
  5608. *
  5609. * @private
  5610. * @param {Object} object The object to modify.
  5611. * @param {string} key The key of the property to assign.
  5612. * @param {*} value The value to assign.
  5613. */
  5614. function assignValue(object, key, value) {
  5615. var objValue = object[key];
  5616. if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||
  5617. (value === undefined && !(key in object))) {
  5618. baseAssignValue(object, key, value);
  5619. }
  5620. }
  5621. module.exports = assignValue;
  5622. },{"./_baseAssignValue":55,"./eq":142}],52:[function(require,module,exports){
  5623. var eq = require('./eq');
  5624. /**
  5625. * Gets the index at which the `key` is found in `array` of key-value pairs.
  5626. *
  5627. * @private
  5628. * @param {Array} array The array to inspect.
  5629. * @param {*} key The key to search for.
  5630. * @returns {number} Returns the index of the matched value, else `-1`.
  5631. */
  5632. function assocIndexOf(array, key) {
  5633. var length = array.length;
  5634. while (length--) {
  5635. if (eq(array[length][0], key)) {
  5636. return length;
  5637. }
  5638. }
  5639. return -1;
  5640. }
  5641. module.exports = assocIndexOf;
  5642. },{"./eq":142}],53:[function(require,module,exports){
  5643. var copyObject = require('./_copyObject'),
  5644. keys = require('./keys');
  5645. /**
  5646. * The base implementation of `_.assign` without support for multiple sources
  5647. * or `customizer` functions.
  5648. *
  5649. * @private
  5650. * @param {Object} object The destination object.
  5651. * @param {Object} source The source object.
  5652. * @returns {Object} Returns `object`.
  5653. */
  5654. function baseAssign(object, source) {
  5655. return object && copyObject(source, keys(source), object);
  5656. }
  5657. module.exports = baseAssign;
  5658. },{"./_copyObject":82,"./keys":160}],54:[function(require,module,exports){
  5659. var copyObject = require('./_copyObject'),
  5660. keysIn = require('./keysIn');
  5661. /**
  5662. * The base implementation of `_.assignIn` without support for multiple sources
  5663. * or `customizer` functions.
  5664. *
  5665. * @private
  5666. * @param {Object} object The destination object.
  5667. * @param {Object} source The source object.
  5668. * @returns {Object} Returns `object`.
  5669. */
  5670. function baseAssignIn(object, source) {
  5671. return object && copyObject(source, keysIn(source), object);
  5672. }
  5673. module.exports = baseAssignIn;
  5674. },{"./_copyObject":82,"./keysIn":161}],55:[function(require,module,exports){
  5675. var defineProperty = require('./_defineProperty');
  5676. /**
  5677. * The base implementation of `assignValue` and `assignMergeValue` without
  5678. * value checks.
  5679. *
  5680. * @private
  5681. * @param {Object} object The object to modify.
  5682. * @param {string} key The key of the property to assign.
  5683. * @param {*} value The value to assign.
  5684. */
  5685. function baseAssignValue(object, key, value) {
  5686. if (key == '__proto__' && defineProperty) {
  5687. defineProperty(object, key, {
  5688. 'configurable': true,
  5689. 'enumerable': true,
  5690. 'value': value,
  5691. 'writable': true
  5692. });
  5693. } else {
  5694. object[key] = value;
  5695. }
  5696. }
  5697. module.exports = baseAssignValue;
  5698. },{"./_defineProperty":88}],56:[function(require,module,exports){
  5699. var Stack = require('./_Stack'),
  5700. arrayEach = require('./_arrayEach'),
  5701. assignValue = require('./_assignValue'),
  5702. baseAssign = require('./_baseAssign'),
  5703. baseAssignIn = require('./_baseAssignIn'),
  5704. cloneBuffer = require('./_cloneBuffer'),
  5705. copyArray = require('./_copyArray'),
  5706. copySymbols = require('./_copySymbols'),
  5707. copySymbolsIn = require('./_copySymbolsIn'),
  5708. getAllKeys = require('./_getAllKeys'),
  5709. getAllKeysIn = require('./_getAllKeysIn'),
  5710. getTag = require('./_getTag'),
  5711. initCloneArray = require('./_initCloneArray'),
  5712. initCloneByTag = require('./_initCloneByTag'),
  5713. initCloneObject = require('./_initCloneObject'),
  5714. isArray = require('./isArray'),
  5715. isBuffer = require('./isBuffer'),
  5716. isMap = require('./isMap'),
  5717. isObject = require('./isObject'),
  5718. isSet = require('./isSet'),
  5719. keys = require('./keys'),
  5720. keysIn = require('./keysIn');
  5721. /** Used to compose bitmasks for cloning. */
  5722. var CLONE_DEEP_FLAG = 1,
  5723. CLONE_FLAT_FLAG = 2,
  5724. CLONE_SYMBOLS_FLAG = 4;
  5725. /** `Object#toString` result references. */
  5726. var argsTag = '[object Arguments]',
  5727. arrayTag = '[object Array]',
  5728. boolTag = '[object Boolean]',
  5729. dateTag = '[object Date]',
  5730. errorTag = '[object Error]',
  5731. funcTag = '[object Function]',
  5732. genTag = '[object GeneratorFunction]',
  5733. mapTag = '[object Map]',
  5734. numberTag = '[object Number]',
  5735. objectTag = '[object Object]',
  5736. regexpTag = '[object RegExp]',
  5737. setTag = '[object Set]',
  5738. stringTag = '[object String]',
  5739. symbolTag = '[object Symbol]',
  5740. weakMapTag = '[object WeakMap]';
  5741. var arrayBufferTag = '[object ArrayBuffer]',
  5742. dataViewTag = '[object DataView]',
  5743. float32Tag = '[object Float32Array]',
  5744. float64Tag = '[object Float64Array]',
  5745. int8Tag = '[object Int8Array]',
  5746. int16Tag = '[object Int16Array]',
  5747. int32Tag = '[object Int32Array]',
  5748. uint8Tag = '[object Uint8Array]',
  5749. uint8ClampedTag = '[object Uint8ClampedArray]',
  5750. uint16Tag = '[object Uint16Array]',
  5751. uint32Tag = '[object Uint32Array]';
  5752. /** Used to identify `toStringTag` values supported by `_.clone`. */
  5753. var cloneableTags = {};
  5754. cloneableTags[argsTag] = cloneableTags[arrayTag] =
  5755. cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] =
  5756. cloneableTags[boolTag] = cloneableTags[dateTag] =
  5757. cloneableTags[float32Tag] = cloneableTags[float64Tag] =
  5758. cloneableTags[int8Tag] = cloneableTags[int16Tag] =
  5759. cloneableTags[int32Tag] = cloneableTags[mapTag] =
  5760. cloneableTags[numberTag] = cloneableTags[objectTag] =
  5761. cloneableTags[regexpTag] = cloneableTags[setTag] =
  5762. cloneableTags[stringTag] = cloneableTags[symbolTag] =
  5763. cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] =
  5764. cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true;
  5765. cloneableTags[errorTag] = cloneableTags[funcTag] =
  5766. cloneableTags[weakMapTag] = false;
  5767. /**
  5768. * The base implementation of `_.clone` and `_.cloneDeep` which tracks
  5769. * traversed objects.
  5770. *
  5771. * @private
  5772. * @param {*} value The value to clone.
  5773. * @param {boolean} bitmask The bitmask flags.
  5774. * 1 - Deep clone
  5775. * 2 - Flatten inherited properties
  5776. * 4 - Clone symbols
  5777. * @param {Function} [customizer] The function to customize cloning.
  5778. * @param {string} [key] The key of `value`.
  5779. * @param {Object} [object] The parent object of `value`.
  5780. * @param {Object} [stack] Tracks traversed objects and their clone counterparts.
  5781. * @returns {*} Returns the cloned value.
  5782. */
  5783. function baseClone(value, bitmask, customizer, key, object, stack) {
  5784. var result,
  5785. isDeep = bitmask & CLONE_DEEP_FLAG,
  5786. isFlat = bitmask & CLONE_FLAT_FLAG,
  5787. isFull = bitmask & CLONE_SYMBOLS_FLAG;
  5788. if (customizer) {
  5789. result = object ? customizer(value, key, object, stack) : customizer(value);
  5790. }
  5791. if (result !== undefined) {
  5792. return result;
  5793. }
  5794. if (!isObject(value)) {
  5795. return value;
  5796. }
  5797. var isArr = isArray(value);
  5798. if (isArr) {
  5799. result = initCloneArray(value);
  5800. if (!isDeep) {
  5801. return copyArray(value, result);
  5802. }
  5803. } else {
  5804. var tag = getTag(value),
  5805. isFunc = tag == funcTag || tag == genTag;
  5806. if (isBuffer(value)) {
  5807. return cloneBuffer(value, isDeep);
  5808. }
  5809. if (tag == objectTag || tag == argsTag || (isFunc && !object)) {
  5810. result = (isFlat || isFunc) ? {} : initCloneObject(value);
  5811. if (!isDeep) {
  5812. return isFlat
  5813. ? copySymbolsIn(value, baseAssignIn(result, value))
  5814. : copySymbols(value, baseAssign(result, value));
  5815. }
  5816. } else {
  5817. if (!cloneableTags[tag]) {
  5818. return object ? value : {};
  5819. }
  5820. result = initCloneByTag(value, tag, isDeep);
  5821. }
  5822. }
  5823. // Check for circular references and return its corresponding clone.
  5824. stack || (stack = new Stack);
  5825. var stacked = stack.get(value);
  5826. if (stacked) {
  5827. return stacked;
  5828. }
  5829. stack.set(value, result);
  5830. if (isSet(value)) {
  5831. value.forEach(function(subValue) {
  5832. result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack));
  5833. });
  5834. } else if (isMap(value)) {
  5835. value.forEach(function(subValue, key) {
  5836. result.set(key, baseClone(subValue, bitmask, customizer, key, value, stack));
  5837. });
  5838. }
  5839. var keysFunc = isFull
  5840. ? (isFlat ? getAllKeysIn : getAllKeys)
  5841. : (isFlat ? keysIn : keys);
  5842. var props = isArr ? undefined : keysFunc(value);
  5843. arrayEach(props || value, function(subValue, key) {
  5844. if (props) {
  5845. key = subValue;
  5846. subValue = value[key];
  5847. }
  5848. // Recursively populate clone (susceptible to call stack limits).
  5849. assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack));
  5850. });
  5851. return result;
  5852. }
  5853. module.exports = baseClone;
  5854. },{"./_Stack":40,"./_arrayEach":45,"./_assignValue":51,"./_baseAssign":53,"./_baseAssignIn":54,"./_cloneBuffer":76,"./_copyArray":81,"./_copySymbols":83,"./_copySymbolsIn":84,"./_getAllKeys":90,"./_getAllKeysIn":91,"./_getTag":98,"./_initCloneArray":105,"./_initCloneByTag":106,"./_initCloneObject":107,"./isArray":146,"./isBuffer":149,"./isMap":152,"./isObject":153,"./isSet":156,"./keys":160,"./keysIn":161}],57:[function(require,module,exports){
  5855. var isObject = require('./isObject');
  5856. /** Built-in value references. */
  5857. var objectCreate = Object.create;
  5858. /**
  5859. * The base implementation of `_.create` without support for assigning
  5860. * properties to the created object.
  5861. *
  5862. * @private
  5863. * @param {Object} proto The object to inherit from.
  5864. * @returns {Object} Returns the new object.
  5865. */
  5866. var baseCreate = (function() {
  5867. function object() {}
  5868. return function(proto) {
  5869. if (!isObject(proto)) {
  5870. return {};
  5871. }
  5872. if (objectCreate) {
  5873. return objectCreate(proto);
  5874. }
  5875. object.prototype = proto;
  5876. var result = new object;
  5877. object.prototype = undefined;
  5878. return result;
  5879. };
  5880. }());
  5881. module.exports = baseCreate;
  5882. },{"./isObject":153}],58:[function(require,module,exports){
  5883. var createBaseFor = require('./_createBaseFor');
  5884. /**
  5885. * The base implementation of `baseForOwn` which iterates over `object`
  5886. * properties returned by `keysFunc` and invokes `iteratee` for each property.
  5887. * Iteratee functions may exit iteration early by explicitly returning `false`.
  5888. *
  5889. * @private
  5890. * @param {Object} object The object to iterate over.
  5891. * @param {Function} iteratee The function invoked per iteration.
  5892. * @param {Function} keysFunc The function to get the keys of `object`.
  5893. * @returns {Object} Returns `object`.
  5894. */
  5895. var baseFor = createBaseFor();
  5896. module.exports = baseFor;
  5897. },{"./_createBaseFor":87}],59:[function(require,module,exports){
  5898. var arrayPush = require('./_arrayPush'),
  5899. isArray = require('./isArray');
  5900. /**
  5901. * The base implementation of `getAllKeys` and `getAllKeysIn` which uses
  5902. * `keysFunc` and `symbolsFunc` to get the enumerable property names and
  5903. * symbols of `object`.
  5904. *
  5905. * @private
  5906. * @param {Object} object The object to query.
  5907. * @param {Function} keysFunc The function to get the keys of `object`.
  5908. * @param {Function} symbolsFunc The function to get the symbols of `object`.
  5909. * @returns {Array} Returns the array of property names and symbols.
  5910. */
  5911. function baseGetAllKeys(object, keysFunc, symbolsFunc) {
  5912. var result = keysFunc(object);
  5913. return isArray(object) ? result : arrayPush(result, symbolsFunc(object));
  5914. }
  5915. module.exports = baseGetAllKeys;
  5916. },{"./_arrayPush":49,"./isArray":146}],60:[function(require,module,exports){
  5917. var Symbol = require('./_Symbol'),
  5918. getRawTag = require('./_getRawTag'),
  5919. objectToString = require('./_objectToString');
  5920. /** `Object#toString` result references. */
  5921. var nullTag = '[object Null]',
  5922. undefinedTag = '[object Undefined]';
  5923. /** Built-in value references. */
  5924. var symToStringTag = Symbol ? Symbol.toStringTag : undefined;
  5925. /**
  5926. * The base implementation of `getTag` without fallbacks for buggy environments.
  5927. *
  5928. * @private
  5929. * @param {*} value The value to query.
  5930. * @returns {string} Returns the `toStringTag`.
  5931. */
  5932. function baseGetTag(value) {
  5933. if (value == null) {
  5934. return value === undefined ? undefinedTag : nullTag;
  5935. }
  5936. return (symToStringTag && symToStringTag in Object(value))
  5937. ? getRawTag(value)
  5938. : objectToString(value);
  5939. }
  5940. module.exports = baseGetTag;
  5941. },{"./_Symbol":41,"./_getRawTag":95,"./_objectToString":127}],61:[function(require,module,exports){
  5942. var baseGetTag = require('./_baseGetTag'),
  5943. isObjectLike = require('./isObjectLike');
  5944. /** `Object#toString` result references. */
  5945. var argsTag = '[object Arguments]';
  5946. /**
  5947. * The base implementation of `_.isArguments`.
  5948. *
  5949. * @private
  5950. * @param {*} value The value to check.
  5951. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  5952. */
  5953. function baseIsArguments(value) {
  5954. return isObjectLike(value) && baseGetTag(value) == argsTag;
  5955. }
  5956. module.exports = baseIsArguments;
  5957. },{"./_baseGetTag":60,"./isObjectLike":154}],62:[function(require,module,exports){
  5958. var getTag = require('./_getTag'),
  5959. isObjectLike = require('./isObjectLike');
  5960. /** `Object#toString` result references. */
  5961. var mapTag = '[object Map]';
  5962. /**
  5963. * The base implementation of `_.isMap` without Node.js optimizations.
  5964. *
  5965. * @private
  5966. * @param {*} value The value to check.
  5967. * @returns {boolean} Returns `true` if `value` is a map, else `false`.
  5968. */
  5969. function baseIsMap(value) {
  5970. return isObjectLike(value) && getTag(value) == mapTag;
  5971. }
  5972. module.exports = baseIsMap;
  5973. },{"./_getTag":98,"./isObjectLike":154}],63:[function(require,module,exports){
  5974. var isFunction = require('./isFunction'),
  5975. isMasked = require('./_isMasked'),
  5976. isObject = require('./isObject'),
  5977. toSource = require('./_toSource');
  5978. /**
  5979. * Used to match `RegExp`
  5980. * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
  5981. */
  5982. var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
  5983. /** Used to detect host constructors (Safari). */
  5984. var reIsHostCtor = /^\[object .+?Constructor\]$/;
  5985. /** Used for built-in method references. */
  5986. var funcProto = Function.prototype,
  5987. objectProto = Object.prototype;
  5988. /** Used to resolve the decompiled source of functions. */
  5989. var funcToString = funcProto.toString;
  5990. /** Used to check objects for own properties. */
  5991. var hasOwnProperty = objectProto.hasOwnProperty;
  5992. /** Used to detect if a method is native. */
  5993. var reIsNative = RegExp('^' +
  5994. funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
  5995. .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
  5996. );
  5997. /**
  5998. * The base implementation of `_.isNative` without bad shim checks.
  5999. *
  6000. * @private
  6001. * @param {*} value The value to check.
  6002. * @returns {boolean} Returns `true` if `value` is a native function,
  6003. * else `false`.
  6004. */
  6005. function baseIsNative(value) {
  6006. if (!isObject(value) || isMasked(value)) {
  6007. return false;
  6008. }
  6009. var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
  6010. return pattern.test(toSource(value));
  6011. }
  6012. module.exports = baseIsNative;
  6013. },{"./_isMasked":111,"./_toSource":139,"./isFunction":150,"./isObject":153}],64:[function(require,module,exports){
  6014. var getTag = require('./_getTag'),
  6015. isObjectLike = require('./isObjectLike');
  6016. /** `Object#toString` result references. */
  6017. var setTag = '[object Set]';
  6018. /**
  6019. * The base implementation of `_.isSet` without Node.js optimizations.
  6020. *
  6021. * @private
  6022. * @param {*} value The value to check.
  6023. * @returns {boolean} Returns `true` if `value` is a set, else `false`.
  6024. */
  6025. function baseIsSet(value) {
  6026. return isObjectLike(value) && getTag(value) == setTag;
  6027. }
  6028. module.exports = baseIsSet;
  6029. },{"./_getTag":98,"./isObjectLike":154}],65:[function(require,module,exports){
  6030. var baseGetTag = require('./_baseGetTag'),
  6031. isLength = require('./isLength'),
  6032. isObjectLike = require('./isObjectLike');
  6033. /** `Object#toString` result references. */
  6034. var argsTag = '[object Arguments]',
  6035. arrayTag = '[object Array]',
  6036. boolTag = '[object Boolean]',
  6037. dateTag = '[object Date]',
  6038. errorTag = '[object Error]',
  6039. funcTag = '[object Function]',
  6040. mapTag = '[object Map]',
  6041. numberTag = '[object Number]',
  6042. objectTag = '[object Object]',
  6043. regexpTag = '[object RegExp]',
  6044. setTag = '[object Set]',
  6045. stringTag = '[object String]',
  6046. weakMapTag = '[object WeakMap]';
  6047. var arrayBufferTag = '[object ArrayBuffer]',
  6048. dataViewTag = '[object DataView]',
  6049. float32Tag = '[object Float32Array]',
  6050. float64Tag = '[object Float64Array]',
  6051. int8Tag = '[object Int8Array]',
  6052. int16Tag = '[object Int16Array]',
  6053. int32Tag = '[object Int32Array]',
  6054. uint8Tag = '[object Uint8Array]',
  6055. uint8ClampedTag = '[object Uint8ClampedArray]',
  6056. uint16Tag = '[object Uint16Array]',
  6057. uint32Tag = '[object Uint32Array]';
  6058. /** Used to identify `toStringTag` values of typed arrays. */
  6059. var typedArrayTags = {};
  6060. typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
  6061. typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
  6062. typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
  6063. typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
  6064. typedArrayTags[uint32Tag] = true;
  6065. typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
  6066. typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
  6067. typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
  6068. typedArrayTags[errorTag] = typedArrayTags[funcTag] =
  6069. typedArrayTags[mapTag] = typedArrayTags[numberTag] =
  6070. typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
  6071. typedArrayTags[setTag] = typedArrayTags[stringTag] =
  6072. typedArrayTags[weakMapTag] = false;
  6073. /**
  6074. * The base implementation of `_.isTypedArray` without Node.js optimizations.
  6075. *
  6076. * @private
  6077. * @param {*} value The value to check.
  6078. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  6079. */
  6080. function baseIsTypedArray(value) {
  6081. return isObjectLike(value) &&
  6082. isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
  6083. }
  6084. module.exports = baseIsTypedArray;
  6085. },{"./_baseGetTag":60,"./isLength":151,"./isObjectLike":154}],66:[function(require,module,exports){
  6086. var isPrototype = require('./_isPrototype'),
  6087. nativeKeys = require('./_nativeKeys');
  6088. /** Used for built-in method references. */
  6089. var objectProto = Object.prototype;
  6090. /** Used to check objects for own properties. */
  6091. var hasOwnProperty = objectProto.hasOwnProperty;
  6092. /**
  6093. * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
  6094. *
  6095. * @private
  6096. * @param {Object} object The object to query.
  6097. * @returns {Array} Returns the array of property names.
  6098. */
  6099. function baseKeys(object) {
  6100. if (!isPrototype(object)) {
  6101. return nativeKeys(object);
  6102. }
  6103. var result = [];
  6104. for (var key in Object(object)) {
  6105. if (hasOwnProperty.call(object, key) && key != 'constructor') {
  6106. result.push(key);
  6107. }
  6108. }
  6109. return result;
  6110. }
  6111. module.exports = baseKeys;
  6112. },{"./_isPrototype":112,"./_nativeKeys":124}],67:[function(require,module,exports){
  6113. var isObject = require('./isObject'),
  6114. isPrototype = require('./_isPrototype'),
  6115. nativeKeysIn = require('./_nativeKeysIn');
  6116. /** Used for built-in method references. */
  6117. var objectProto = Object.prototype;
  6118. /** Used to check objects for own properties. */
  6119. var hasOwnProperty = objectProto.hasOwnProperty;
  6120. /**
  6121. * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.
  6122. *
  6123. * @private
  6124. * @param {Object} object The object to query.
  6125. * @returns {Array} Returns the array of property names.
  6126. */
  6127. function baseKeysIn(object) {
  6128. if (!isObject(object)) {
  6129. return nativeKeysIn(object);
  6130. }
  6131. var isProto = isPrototype(object),
  6132. result = [];
  6133. for (var key in object) {
  6134. if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
  6135. result.push(key);
  6136. }
  6137. }
  6138. return result;
  6139. }
  6140. module.exports = baseKeysIn;
  6141. },{"./_isPrototype":112,"./_nativeKeysIn":125,"./isObject":153}],68:[function(require,module,exports){
  6142. var Stack = require('./_Stack'),
  6143. assignMergeValue = require('./_assignMergeValue'),
  6144. baseFor = require('./_baseFor'),
  6145. baseMergeDeep = require('./_baseMergeDeep'),
  6146. isObject = require('./isObject'),
  6147. keysIn = require('./keysIn'),
  6148. safeGet = require('./_safeGet');
  6149. /**
  6150. * The base implementation of `_.merge` without support for multiple sources.
  6151. *
  6152. * @private
  6153. * @param {Object} object The destination object.
  6154. * @param {Object} source The source object.
  6155. * @param {number} srcIndex The index of `source`.
  6156. * @param {Function} [customizer] The function to customize merged values.
  6157. * @param {Object} [stack] Tracks traversed source values and their merged
  6158. * counterparts.
  6159. */
  6160. function baseMerge(object, source, srcIndex, customizer, stack) {
  6161. if (object === source) {
  6162. return;
  6163. }
  6164. baseFor(source, function(srcValue, key) {
  6165. stack || (stack = new Stack);
  6166. if (isObject(srcValue)) {
  6167. baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
  6168. }
  6169. else {
  6170. var newValue = customizer
  6171. ? customizer(safeGet(object, key), srcValue, (key + ''), object, source, stack)
  6172. : undefined;
  6173. if (newValue === undefined) {
  6174. newValue = srcValue;
  6175. }
  6176. assignMergeValue(object, key, newValue);
  6177. }
  6178. }, keysIn);
  6179. }
  6180. module.exports = baseMerge;
  6181. },{"./_Stack":40,"./_assignMergeValue":50,"./_baseFor":58,"./_baseMergeDeep":69,"./_safeGet":131,"./isObject":153,"./keysIn":161}],69:[function(require,module,exports){
  6182. var assignMergeValue = require('./_assignMergeValue'),
  6183. cloneBuffer = require('./_cloneBuffer'),
  6184. cloneTypedArray = require('./_cloneTypedArray'),
  6185. copyArray = require('./_copyArray'),
  6186. initCloneObject = require('./_initCloneObject'),
  6187. isArguments = require('./isArguments'),
  6188. isArray = require('./isArray'),
  6189. isArrayLikeObject = require('./isArrayLikeObject'),
  6190. isBuffer = require('./isBuffer'),
  6191. isFunction = require('./isFunction'),
  6192. isObject = require('./isObject'),
  6193. isPlainObject = require('./isPlainObject'),
  6194. isTypedArray = require('./isTypedArray'),
  6195. safeGet = require('./_safeGet'),
  6196. toPlainObject = require('./toPlainObject');
  6197. /**
  6198. * A specialized version of `baseMerge` for arrays and objects which performs
  6199. * deep merges and tracks traversed objects enabling objects with circular
  6200. * references to be merged.
  6201. *
  6202. * @private
  6203. * @param {Object} object The destination object.
  6204. * @param {Object} source The source object.
  6205. * @param {string} key The key of the value to merge.
  6206. * @param {number} srcIndex The index of `source`.
  6207. * @param {Function} mergeFunc The function to merge values.
  6208. * @param {Function} [customizer] The function to customize assigned values.
  6209. * @param {Object} [stack] Tracks traversed source values and their merged
  6210. * counterparts.
  6211. */
  6212. function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {
  6213. var objValue = safeGet(object, key),
  6214. srcValue = safeGet(source, key),
  6215. stacked = stack.get(srcValue);
  6216. if (stacked) {
  6217. assignMergeValue(object, key, stacked);
  6218. return;
  6219. }
  6220. var newValue = customizer
  6221. ? customizer(objValue, srcValue, (key + ''), object, source, stack)
  6222. : undefined;
  6223. var isCommon = newValue === undefined;
  6224. if (isCommon) {
  6225. var isArr = isArray(srcValue),
  6226. isBuff = !isArr && isBuffer(srcValue),
  6227. isTyped = !isArr && !isBuff && isTypedArray(srcValue);
  6228. newValue = srcValue;
  6229. if (isArr || isBuff || isTyped) {
  6230. if (isArray(objValue)) {
  6231. newValue = objValue;
  6232. }
  6233. else if (isArrayLikeObject(objValue)) {
  6234. newValue = copyArray(objValue);
  6235. }
  6236. else if (isBuff) {
  6237. isCommon = false;
  6238. newValue = cloneBuffer(srcValue, true);
  6239. }
  6240. else if (isTyped) {
  6241. isCommon = false;
  6242. newValue = cloneTypedArray(srcValue, true);
  6243. }
  6244. else {
  6245. newValue = [];
  6246. }
  6247. }
  6248. else if (isPlainObject(srcValue) || isArguments(srcValue)) {
  6249. newValue = objValue;
  6250. if (isArguments(objValue)) {
  6251. newValue = toPlainObject(objValue);
  6252. }
  6253. else if (!isObject(objValue) || isFunction(objValue)) {
  6254. newValue = initCloneObject(srcValue);
  6255. }
  6256. }
  6257. else {
  6258. isCommon = false;
  6259. }
  6260. }
  6261. if (isCommon) {
  6262. // Recursively merge objects and arrays (susceptible to call stack limits).
  6263. stack.set(srcValue, newValue);
  6264. mergeFunc(newValue, srcValue, srcIndex, customizer, stack);
  6265. stack['delete'](srcValue);
  6266. }
  6267. assignMergeValue(object, key, newValue);
  6268. }
  6269. module.exports = baseMergeDeep;
  6270. },{"./_assignMergeValue":50,"./_cloneBuffer":76,"./_cloneTypedArray":80,"./_copyArray":81,"./_initCloneObject":107,"./_safeGet":131,"./isArguments":145,"./isArray":146,"./isArrayLikeObject":148,"./isBuffer":149,"./isFunction":150,"./isObject":153,"./isPlainObject":155,"./isTypedArray":159,"./toPlainObject":165}],70:[function(require,module,exports){
  6271. var identity = require('./identity'),
  6272. overRest = require('./_overRest'),
  6273. setToString = require('./_setToString');
  6274. /**
  6275. * The base implementation of `_.rest` which doesn't validate or coerce arguments.
  6276. *
  6277. * @private
  6278. * @param {Function} func The function to apply a rest parameter to.
  6279. * @param {number} [start=func.length-1] The start position of the rest parameter.
  6280. * @returns {Function} Returns the new function.
  6281. */
  6282. function baseRest(func, start) {
  6283. return setToString(overRest(func, start, identity), func + '');
  6284. }
  6285. module.exports = baseRest;
  6286. },{"./_overRest":129,"./_setToString":132,"./identity":144}],71:[function(require,module,exports){
  6287. var constant = require('./constant'),
  6288. defineProperty = require('./_defineProperty'),
  6289. identity = require('./identity');
  6290. /**
  6291. * The base implementation of `setToString` without support for hot loop shorting.
  6292. *
  6293. * @private
  6294. * @param {Function} func The function to modify.
  6295. * @param {Function} string The `toString` result.
  6296. * @returns {Function} Returns `func`.
  6297. */
  6298. var baseSetToString = !defineProperty ? identity : function(func, string) {
  6299. return defineProperty(func, 'toString', {
  6300. 'configurable': true,
  6301. 'enumerable': false,
  6302. 'value': constant(string),
  6303. 'writable': true
  6304. });
  6305. };
  6306. module.exports = baseSetToString;
  6307. },{"./_defineProperty":88,"./constant":141,"./identity":144}],72:[function(require,module,exports){
  6308. /**
  6309. * The base implementation of `_.times` without support for iteratee shorthands
  6310. * or max array length checks.
  6311. *
  6312. * @private
  6313. * @param {number} n The number of times to invoke `iteratee`.
  6314. * @param {Function} iteratee The function invoked per iteration.
  6315. * @returns {Array} Returns the array of results.
  6316. */
  6317. function baseTimes(n, iteratee) {
  6318. var index = -1,
  6319. result = Array(n);
  6320. while (++index < n) {
  6321. result[index] = iteratee(index);
  6322. }
  6323. return result;
  6324. }
  6325. module.exports = baseTimes;
  6326. },{}],73:[function(require,module,exports){
  6327. var Symbol = require('./_Symbol'),
  6328. arrayMap = require('./_arrayMap'),
  6329. isArray = require('./isArray'),
  6330. isSymbol = require('./isSymbol');
  6331. /** Used as references for various `Number` constants. */
  6332. var INFINITY = 1 / 0;
  6333. /** Used to convert symbols to primitives and strings. */
  6334. var symbolProto = Symbol ? Symbol.prototype : undefined,
  6335. symbolToString = symbolProto ? symbolProto.toString : undefined;
  6336. /**
  6337. * The base implementation of `_.toString` which doesn't convert nullish
  6338. * values to empty strings.
  6339. *
  6340. * @private
  6341. * @param {*} value The value to process.
  6342. * @returns {string} Returns the string.
  6343. */
  6344. function baseToString(value) {
  6345. // Exit early for strings to avoid a performance hit in some environments.
  6346. if (typeof value == 'string') {
  6347. return value;
  6348. }
  6349. if (isArray(value)) {
  6350. // Recursively convert values (susceptible to call stack limits).
  6351. return arrayMap(value, baseToString) + '';
  6352. }
  6353. if (isSymbol(value)) {
  6354. return symbolToString ? symbolToString.call(value) : '';
  6355. }
  6356. var result = (value + '');
  6357. return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
  6358. }
  6359. module.exports = baseToString;
  6360. },{"./_Symbol":41,"./_arrayMap":48,"./isArray":146,"./isSymbol":158}],74:[function(require,module,exports){
  6361. /**
  6362. * The base implementation of `_.unary` without support for storing metadata.
  6363. *
  6364. * @private
  6365. * @param {Function} func The function to cap arguments for.
  6366. * @returns {Function} Returns the new capped function.
  6367. */
  6368. function baseUnary(func) {
  6369. return function(value) {
  6370. return func(value);
  6371. };
  6372. }
  6373. module.exports = baseUnary;
  6374. },{}],75:[function(require,module,exports){
  6375. var Uint8Array = require('./_Uint8Array');
  6376. /**
  6377. * Creates a clone of `arrayBuffer`.
  6378. *
  6379. * @private
  6380. * @param {ArrayBuffer} arrayBuffer The array buffer to clone.
  6381. * @returns {ArrayBuffer} Returns the cloned array buffer.
  6382. */
  6383. function cloneArrayBuffer(arrayBuffer) {
  6384. var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
  6385. new Uint8Array(result).set(new Uint8Array(arrayBuffer));
  6386. return result;
  6387. }
  6388. module.exports = cloneArrayBuffer;
  6389. },{"./_Uint8Array":42}],76:[function(require,module,exports){
  6390. var root = require('./_root');
  6391. /** Detect free variable `exports`. */
  6392. var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
  6393. /** Detect free variable `module`. */
  6394. var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
  6395. /** Detect the popular CommonJS extension `module.exports`. */
  6396. var moduleExports = freeModule && freeModule.exports === freeExports;
  6397. /** Built-in value references. */
  6398. var Buffer = moduleExports ? root.Buffer : undefined,
  6399. allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined;
  6400. /**
  6401. * Creates a clone of `buffer`.
  6402. *
  6403. * @private
  6404. * @param {Buffer} buffer The buffer to clone.
  6405. * @param {boolean} [isDeep] Specify a deep clone.
  6406. * @returns {Buffer} Returns the cloned buffer.
  6407. */
  6408. function cloneBuffer(buffer, isDeep) {
  6409. if (isDeep) {
  6410. return buffer.slice();
  6411. }
  6412. var length = buffer.length,
  6413. result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
  6414. buffer.copy(result);
  6415. return result;
  6416. }
  6417. module.exports = cloneBuffer;
  6418. },{"./_root":130}],77:[function(require,module,exports){
  6419. var cloneArrayBuffer = require('./_cloneArrayBuffer');
  6420. /**
  6421. * Creates a clone of `dataView`.
  6422. *
  6423. * @private
  6424. * @param {Object} dataView The data view to clone.
  6425. * @param {boolean} [isDeep] Specify a deep clone.
  6426. * @returns {Object} Returns the cloned data view.
  6427. */
  6428. function cloneDataView(dataView, isDeep) {
  6429. var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer;
  6430. return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
  6431. }
  6432. module.exports = cloneDataView;
  6433. },{"./_cloneArrayBuffer":75}],78:[function(require,module,exports){
  6434. /** Used to match `RegExp` flags from their coerced string values. */
  6435. var reFlags = /\w*$/;
  6436. /**
  6437. * Creates a clone of `regexp`.
  6438. *
  6439. * @private
  6440. * @param {Object} regexp The regexp to clone.
  6441. * @returns {Object} Returns the cloned regexp.
  6442. */
  6443. function cloneRegExp(regexp) {
  6444. var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
  6445. result.lastIndex = regexp.lastIndex;
  6446. return result;
  6447. }
  6448. module.exports = cloneRegExp;
  6449. },{}],79:[function(require,module,exports){
  6450. var Symbol = require('./_Symbol');
  6451. /** Used to convert symbols to primitives and strings. */
  6452. var symbolProto = Symbol ? Symbol.prototype : undefined,
  6453. symbolValueOf = symbolProto ? symbolProto.valueOf : undefined;
  6454. /**
  6455. * Creates a clone of the `symbol` object.
  6456. *
  6457. * @private
  6458. * @param {Object} symbol The symbol object to clone.
  6459. * @returns {Object} Returns the cloned symbol object.
  6460. */
  6461. function cloneSymbol(symbol) {
  6462. return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};
  6463. }
  6464. module.exports = cloneSymbol;
  6465. },{"./_Symbol":41}],80:[function(require,module,exports){
  6466. var cloneArrayBuffer = require('./_cloneArrayBuffer');
  6467. /**
  6468. * Creates a clone of `typedArray`.
  6469. *
  6470. * @private
  6471. * @param {Object} typedArray The typed array to clone.
  6472. * @param {boolean} [isDeep] Specify a deep clone.
  6473. * @returns {Object} Returns the cloned typed array.
  6474. */
  6475. function cloneTypedArray(typedArray, isDeep) {
  6476. var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
  6477. return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
  6478. }
  6479. module.exports = cloneTypedArray;
  6480. },{"./_cloneArrayBuffer":75}],81:[function(require,module,exports){
  6481. /**
  6482. * Copies the values of `source` to `array`.
  6483. *
  6484. * @private
  6485. * @param {Array} source The array to copy values from.
  6486. * @param {Array} [array=[]] The array to copy values to.
  6487. * @returns {Array} Returns `array`.
  6488. */
  6489. function copyArray(source, array) {
  6490. var index = -1,
  6491. length = source.length;
  6492. array || (array = Array(length));
  6493. while (++index < length) {
  6494. array[index] = source[index];
  6495. }
  6496. return array;
  6497. }
  6498. module.exports = copyArray;
  6499. },{}],82:[function(require,module,exports){
  6500. var assignValue = require('./_assignValue'),
  6501. baseAssignValue = require('./_baseAssignValue');
  6502. /**
  6503. * Copies properties of `source` to `object`.
  6504. *
  6505. * @private
  6506. * @param {Object} source The object to copy properties from.
  6507. * @param {Array} props The property identifiers to copy.
  6508. * @param {Object} [object={}] The object to copy properties to.
  6509. * @param {Function} [customizer] The function to customize copied values.
  6510. * @returns {Object} Returns `object`.
  6511. */
  6512. function copyObject(source, props, object, customizer) {
  6513. var isNew = !object;
  6514. object || (object = {});
  6515. var index = -1,
  6516. length = props.length;
  6517. while (++index < length) {
  6518. var key = props[index];
  6519. var newValue = customizer
  6520. ? customizer(object[key], source[key], key, object, source)
  6521. : undefined;
  6522. if (newValue === undefined) {
  6523. newValue = source[key];
  6524. }
  6525. if (isNew) {
  6526. baseAssignValue(object, key, newValue);
  6527. } else {
  6528. assignValue(object, key, newValue);
  6529. }
  6530. }
  6531. return object;
  6532. }
  6533. module.exports = copyObject;
  6534. },{"./_assignValue":51,"./_baseAssignValue":55}],83:[function(require,module,exports){
  6535. var copyObject = require('./_copyObject'),
  6536. getSymbols = require('./_getSymbols');
  6537. /**
  6538. * Copies own symbols of `source` to `object`.
  6539. *
  6540. * @private
  6541. * @param {Object} source The object to copy symbols from.
  6542. * @param {Object} [object={}] The object to copy symbols to.
  6543. * @returns {Object} Returns `object`.
  6544. */
  6545. function copySymbols(source, object) {
  6546. return copyObject(source, getSymbols(source), object);
  6547. }
  6548. module.exports = copySymbols;
  6549. },{"./_copyObject":82,"./_getSymbols":96}],84:[function(require,module,exports){
  6550. var copyObject = require('./_copyObject'),
  6551. getSymbolsIn = require('./_getSymbolsIn');
  6552. /**
  6553. * Copies own and inherited symbols of `source` to `object`.
  6554. *
  6555. * @private
  6556. * @param {Object} source The object to copy symbols from.
  6557. * @param {Object} [object={}] The object to copy symbols to.
  6558. * @returns {Object} Returns `object`.
  6559. */
  6560. function copySymbolsIn(source, object) {
  6561. return copyObject(source, getSymbolsIn(source), object);
  6562. }
  6563. module.exports = copySymbolsIn;
  6564. },{"./_copyObject":82,"./_getSymbolsIn":97}],85:[function(require,module,exports){
  6565. var root = require('./_root');
  6566. /** Used to detect overreaching core-js shims. */
  6567. var coreJsData = root['__core-js_shared__'];
  6568. module.exports = coreJsData;
  6569. },{"./_root":130}],86:[function(require,module,exports){
  6570. var baseRest = require('./_baseRest'),
  6571. isIterateeCall = require('./_isIterateeCall');
  6572. /**
  6573. * Creates a function like `_.assign`.
  6574. *
  6575. * @private
  6576. * @param {Function} assigner The function to assign values.
  6577. * @returns {Function} Returns the new assigner function.
  6578. */
  6579. function createAssigner(assigner) {
  6580. return baseRest(function(object, sources) {
  6581. var index = -1,
  6582. length = sources.length,
  6583. customizer = length > 1 ? sources[length - 1] : undefined,
  6584. guard = length > 2 ? sources[2] : undefined;
  6585. customizer = (assigner.length > 3 && typeof customizer == 'function')
  6586. ? (length--, customizer)
  6587. : undefined;
  6588. if (guard && isIterateeCall(sources[0], sources[1], guard)) {
  6589. customizer = length < 3 ? undefined : customizer;
  6590. length = 1;
  6591. }
  6592. object = Object(object);
  6593. while (++index < length) {
  6594. var source = sources[index];
  6595. if (source) {
  6596. assigner(object, source, index, customizer);
  6597. }
  6598. }
  6599. return object;
  6600. });
  6601. }
  6602. module.exports = createAssigner;
  6603. },{"./_baseRest":70,"./_isIterateeCall":109}],87:[function(require,module,exports){
  6604. /**
  6605. * Creates a base function for methods like `_.forIn` and `_.forOwn`.
  6606. *
  6607. * @private
  6608. * @param {boolean} [fromRight] Specify iterating from right to left.
  6609. * @returns {Function} Returns the new base function.
  6610. */
  6611. function createBaseFor(fromRight) {
  6612. return function(object, iteratee, keysFunc) {
  6613. var index = -1,
  6614. iterable = Object(object),
  6615. props = keysFunc(object),
  6616. length = props.length;
  6617. while (length--) {
  6618. var key = props[fromRight ? length : ++index];
  6619. if (iteratee(iterable[key], key, iterable) === false) {
  6620. break;
  6621. }
  6622. }
  6623. return object;
  6624. };
  6625. }
  6626. module.exports = createBaseFor;
  6627. },{}],88:[function(require,module,exports){
  6628. var getNative = require('./_getNative');
  6629. var defineProperty = (function() {
  6630. try {
  6631. var func = getNative(Object, 'defineProperty');
  6632. func({}, '', {});
  6633. return func;
  6634. } catch (e) {}
  6635. }());
  6636. module.exports = defineProperty;
  6637. },{"./_getNative":93}],89:[function(require,module,exports){
  6638. (function (global){
  6639. /** Detect free variable `global` from Node.js. */
  6640. var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
  6641. module.exports = freeGlobal;
  6642. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  6643. },{}],90:[function(require,module,exports){
  6644. var baseGetAllKeys = require('./_baseGetAllKeys'),
  6645. getSymbols = require('./_getSymbols'),
  6646. keys = require('./keys');
  6647. /**
  6648. * Creates an array of own enumerable property names and symbols of `object`.
  6649. *
  6650. * @private
  6651. * @param {Object} object The object to query.
  6652. * @returns {Array} Returns the array of property names and symbols.
  6653. */
  6654. function getAllKeys(object) {
  6655. return baseGetAllKeys(object, keys, getSymbols);
  6656. }
  6657. module.exports = getAllKeys;
  6658. },{"./_baseGetAllKeys":59,"./_getSymbols":96,"./keys":160}],91:[function(require,module,exports){
  6659. var baseGetAllKeys = require('./_baseGetAllKeys'),
  6660. getSymbolsIn = require('./_getSymbolsIn'),
  6661. keysIn = require('./keysIn');
  6662. /**
  6663. * Creates an array of own and inherited enumerable property names and
  6664. * symbols of `object`.
  6665. *
  6666. * @private
  6667. * @param {Object} object The object to query.
  6668. * @returns {Array} Returns the array of property names and symbols.
  6669. */
  6670. function getAllKeysIn(object) {
  6671. return baseGetAllKeys(object, keysIn, getSymbolsIn);
  6672. }
  6673. module.exports = getAllKeysIn;
  6674. },{"./_baseGetAllKeys":59,"./_getSymbolsIn":97,"./keysIn":161}],92:[function(require,module,exports){
  6675. var isKeyable = require('./_isKeyable');
  6676. /**
  6677. * Gets the data for `map`.
  6678. *
  6679. * @private
  6680. * @param {Object} map The map to query.
  6681. * @param {string} key The reference key.
  6682. * @returns {*} Returns the map data.
  6683. */
  6684. function getMapData(map, key) {
  6685. var data = map.__data__;
  6686. return isKeyable(key)
  6687. ? data[typeof key == 'string' ? 'string' : 'hash']
  6688. : data.map;
  6689. }
  6690. module.exports = getMapData;
  6691. },{"./_isKeyable":110}],93:[function(require,module,exports){
  6692. var baseIsNative = require('./_baseIsNative'),
  6693. getValue = require('./_getValue');
  6694. /**
  6695. * Gets the native function at `key` of `object`.
  6696. *
  6697. * @private
  6698. * @param {Object} object The object to query.
  6699. * @param {string} key The key of the method to get.
  6700. * @returns {*} Returns the function if it's native, else `undefined`.
  6701. */
  6702. function getNative(object, key) {
  6703. var value = getValue(object, key);
  6704. return baseIsNative(value) ? value : undefined;
  6705. }
  6706. module.exports = getNative;
  6707. },{"./_baseIsNative":63,"./_getValue":99}],94:[function(require,module,exports){
  6708. var overArg = require('./_overArg');
  6709. /** Built-in value references. */
  6710. var getPrototype = overArg(Object.getPrototypeOf, Object);
  6711. module.exports = getPrototype;
  6712. },{"./_overArg":128}],95:[function(require,module,exports){
  6713. var Symbol = require('./_Symbol');
  6714. /** Used for built-in method references. */
  6715. var objectProto = Object.prototype;
  6716. /** Used to check objects for own properties. */
  6717. var hasOwnProperty = objectProto.hasOwnProperty;
  6718. /**
  6719. * Used to resolve the
  6720. * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
  6721. * of values.
  6722. */
  6723. var nativeObjectToString = objectProto.toString;
  6724. /** Built-in value references. */
  6725. var symToStringTag = Symbol ? Symbol.toStringTag : undefined;
  6726. /**
  6727. * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
  6728. *
  6729. * @private
  6730. * @param {*} value The value to query.
  6731. * @returns {string} Returns the raw `toStringTag`.
  6732. */
  6733. function getRawTag(value) {
  6734. var isOwn = hasOwnProperty.call(value, symToStringTag),
  6735. tag = value[symToStringTag];
  6736. try {
  6737. value[symToStringTag] = undefined;
  6738. var unmasked = true;
  6739. } catch (e) {}
  6740. var result = nativeObjectToString.call(value);
  6741. if (unmasked) {
  6742. if (isOwn) {
  6743. value[symToStringTag] = tag;
  6744. } else {
  6745. delete value[symToStringTag];
  6746. }
  6747. }
  6748. return result;
  6749. }
  6750. module.exports = getRawTag;
  6751. },{"./_Symbol":41}],96:[function(require,module,exports){
  6752. var arrayFilter = require('./_arrayFilter'),
  6753. stubArray = require('./stubArray');
  6754. /** Used for built-in method references. */
  6755. var objectProto = Object.prototype;
  6756. /** Built-in value references. */
  6757. var propertyIsEnumerable = objectProto.propertyIsEnumerable;
  6758. /* Built-in method references for those with the same name as other `lodash` methods. */
  6759. var nativeGetSymbols = Object.getOwnPropertySymbols;
  6760. /**
  6761. * Creates an array of the own enumerable symbols of `object`.
  6762. *
  6763. * @private
  6764. * @param {Object} object The object to query.
  6765. * @returns {Array} Returns the array of symbols.
  6766. */
  6767. var getSymbols = !nativeGetSymbols ? stubArray : function(object) {
  6768. if (object == null) {
  6769. return [];
  6770. }
  6771. object = Object(object);
  6772. return arrayFilter(nativeGetSymbols(object), function(symbol) {
  6773. return propertyIsEnumerable.call(object, symbol);
  6774. });
  6775. };
  6776. module.exports = getSymbols;
  6777. },{"./_arrayFilter":46,"./stubArray":163}],97:[function(require,module,exports){
  6778. var arrayPush = require('./_arrayPush'),
  6779. getPrototype = require('./_getPrototype'),
  6780. getSymbols = require('./_getSymbols'),
  6781. stubArray = require('./stubArray');
  6782. /* Built-in method references for those with the same name as other `lodash` methods. */
  6783. var nativeGetSymbols = Object.getOwnPropertySymbols;
  6784. /**
  6785. * Creates an array of the own and inherited enumerable symbols of `object`.
  6786. *
  6787. * @private
  6788. * @param {Object} object The object to query.
  6789. * @returns {Array} Returns the array of symbols.
  6790. */
  6791. var getSymbolsIn = !nativeGetSymbols ? stubArray : function(object) {
  6792. var result = [];
  6793. while (object) {
  6794. arrayPush(result, getSymbols(object));
  6795. object = getPrototype(object);
  6796. }
  6797. return result;
  6798. };
  6799. module.exports = getSymbolsIn;
  6800. },{"./_arrayPush":49,"./_getPrototype":94,"./_getSymbols":96,"./stubArray":163}],98:[function(require,module,exports){
  6801. var DataView = require('./_DataView'),
  6802. Map = require('./_Map'),
  6803. Promise = require('./_Promise'),
  6804. Set = require('./_Set'),
  6805. WeakMap = require('./_WeakMap'),
  6806. baseGetTag = require('./_baseGetTag'),
  6807. toSource = require('./_toSource');
  6808. /** `Object#toString` result references. */
  6809. var mapTag = '[object Map]',
  6810. objectTag = '[object Object]',
  6811. promiseTag = '[object Promise]',
  6812. setTag = '[object Set]',
  6813. weakMapTag = '[object WeakMap]';
  6814. var dataViewTag = '[object DataView]';
  6815. /** Used to detect maps, sets, and weakmaps. */
  6816. var dataViewCtorString = toSource(DataView),
  6817. mapCtorString = toSource(Map),
  6818. promiseCtorString = toSource(Promise),
  6819. setCtorString = toSource(Set),
  6820. weakMapCtorString = toSource(WeakMap);
  6821. /**
  6822. * Gets the `toStringTag` of `value`.
  6823. *
  6824. * @private
  6825. * @param {*} value The value to query.
  6826. * @returns {string} Returns the `toStringTag`.
  6827. */
  6828. var getTag = baseGetTag;
  6829. // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
  6830. if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||
  6831. (Map && getTag(new Map) != mapTag) ||
  6832. (Promise && getTag(Promise.resolve()) != promiseTag) ||
  6833. (Set && getTag(new Set) != setTag) ||
  6834. (WeakMap && getTag(new WeakMap) != weakMapTag)) {
  6835. getTag = function(value) {
  6836. var result = baseGetTag(value),
  6837. Ctor = result == objectTag ? value.constructor : undefined,
  6838. ctorString = Ctor ? toSource(Ctor) : '';
  6839. if (ctorString) {
  6840. switch (ctorString) {
  6841. case dataViewCtorString: return dataViewTag;
  6842. case mapCtorString: return mapTag;
  6843. case promiseCtorString: return promiseTag;
  6844. case setCtorString: return setTag;
  6845. case weakMapCtorString: return weakMapTag;
  6846. }
  6847. }
  6848. return result;
  6849. };
  6850. }
  6851. module.exports = getTag;
  6852. },{"./_DataView":33,"./_Map":36,"./_Promise":38,"./_Set":39,"./_WeakMap":43,"./_baseGetTag":60,"./_toSource":139}],99:[function(require,module,exports){
  6853. /**
  6854. * Gets the value at `key` of `object`.
  6855. *
  6856. * @private
  6857. * @param {Object} [object] The object to query.
  6858. * @param {string} key The key of the property to get.
  6859. * @returns {*} Returns the property value.
  6860. */
  6861. function getValue(object, key) {
  6862. return object == null ? undefined : object[key];
  6863. }
  6864. module.exports = getValue;
  6865. },{}],100:[function(require,module,exports){
  6866. var nativeCreate = require('./_nativeCreate');
  6867. /**
  6868. * Removes all key-value entries from the hash.
  6869. *
  6870. * @private
  6871. * @name clear
  6872. * @memberOf Hash
  6873. */
  6874. function hashClear() {
  6875. this.__data__ = nativeCreate ? nativeCreate(null) : {};
  6876. this.size = 0;
  6877. }
  6878. module.exports = hashClear;
  6879. },{"./_nativeCreate":123}],101:[function(require,module,exports){
  6880. /**
  6881. * Removes `key` and its value from the hash.
  6882. *
  6883. * @private
  6884. * @name delete
  6885. * @memberOf Hash
  6886. * @param {Object} hash The hash to modify.
  6887. * @param {string} key The key of the value to remove.
  6888. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  6889. */
  6890. function hashDelete(key) {
  6891. var result = this.has(key) && delete this.__data__[key];
  6892. this.size -= result ? 1 : 0;
  6893. return result;
  6894. }
  6895. module.exports = hashDelete;
  6896. },{}],102:[function(require,module,exports){
  6897. var nativeCreate = require('./_nativeCreate');
  6898. /** Used to stand-in for `undefined` hash values. */
  6899. var HASH_UNDEFINED = '__lodash_hash_undefined__';
  6900. /** Used for built-in method references. */
  6901. var objectProto = Object.prototype;
  6902. /** Used to check objects for own properties. */
  6903. var hasOwnProperty = objectProto.hasOwnProperty;
  6904. /**
  6905. * Gets the hash value for `key`.
  6906. *
  6907. * @private
  6908. * @name get
  6909. * @memberOf Hash
  6910. * @param {string} key The key of the value to get.
  6911. * @returns {*} Returns the entry value.
  6912. */
  6913. function hashGet(key) {
  6914. var data = this.__data__;
  6915. if (nativeCreate) {
  6916. var result = data[key];
  6917. return result === HASH_UNDEFINED ? undefined : result;
  6918. }
  6919. return hasOwnProperty.call(data, key) ? data[key] : undefined;
  6920. }
  6921. module.exports = hashGet;
  6922. },{"./_nativeCreate":123}],103:[function(require,module,exports){
  6923. var nativeCreate = require('./_nativeCreate');
  6924. /** Used for built-in method references. */
  6925. var objectProto = Object.prototype;
  6926. /** Used to check objects for own properties. */
  6927. var hasOwnProperty = objectProto.hasOwnProperty;
  6928. /**
  6929. * Checks if a hash value for `key` exists.
  6930. *
  6931. * @private
  6932. * @name has
  6933. * @memberOf Hash
  6934. * @param {string} key The key of the entry to check.
  6935. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  6936. */
  6937. function hashHas(key) {
  6938. var data = this.__data__;
  6939. return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key);
  6940. }
  6941. module.exports = hashHas;
  6942. },{"./_nativeCreate":123}],104:[function(require,module,exports){
  6943. var nativeCreate = require('./_nativeCreate');
  6944. /** Used to stand-in for `undefined` hash values. */
  6945. var HASH_UNDEFINED = '__lodash_hash_undefined__';
  6946. /**
  6947. * Sets the hash `key` to `value`.
  6948. *
  6949. * @private
  6950. * @name set
  6951. * @memberOf Hash
  6952. * @param {string} key The key of the value to set.
  6953. * @param {*} value The value to set.
  6954. * @returns {Object} Returns the hash instance.
  6955. */
  6956. function hashSet(key, value) {
  6957. var data = this.__data__;
  6958. this.size += this.has(key) ? 0 : 1;
  6959. data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
  6960. return this;
  6961. }
  6962. module.exports = hashSet;
  6963. },{"./_nativeCreate":123}],105:[function(require,module,exports){
  6964. /** Used for built-in method references. */
  6965. var objectProto = Object.prototype;
  6966. /** Used to check objects for own properties. */
  6967. var hasOwnProperty = objectProto.hasOwnProperty;
  6968. /**
  6969. * Initializes an array clone.
  6970. *
  6971. * @private
  6972. * @param {Array} array The array to clone.
  6973. * @returns {Array} Returns the initialized clone.
  6974. */
  6975. function initCloneArray(array) {
  6976. var length = array.length,
  6977. result = new array.constructor(length);
  6978. // Add properties assigned by `RegExp#exec`.
  6979. if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) {
  6980. result.index = array.index;
  6981. result.input = array.input;
  6982. }
  6983. return result;
  6984. }
  6985. module.exports = initCloneArray;
  6986. },{}],106:[function(require,module,exports){
  6987. var cloneArrayBuffer = require('./_cloneArrayBuffer'),
  6988. cloneDataView = require('./_cloneDataView'),
  6989. cloneRegExp = require('./_cloneRegExp'),
  6990. cloneSymbol = require('./_cloneSymbol'),
  6991. cloneTypedArray = require('./_cloneTypedArray');
  6992. /** `Object#toString` result references. */
  6993. var boolTag = '[object Boolean]',
  6994. dateTag = '[object Date]',
  6995. mapTag = '[object Map]',
  6996. numberTag = '[object Number]',
  6997. regexpTag = '[object RegExp]',
  6998. setTag = '[object Set]',
  6999. stringTag = '[object String]',
  7000. symbolTag = '[object Symbol]';
  7001. var arrayBufferTag = '[object ArrayBuffer]',
  7002. dataViewTag = '[object DataView]',
  7003. float32Tag = '[object Float32Array]',
  7004. float64Tag = '[object Float64Array]',
  7005. int8Tag = '[object Int8Array]',
  7006. int16Tag = '[object Int16Array]',
  7007. int32Tag = '[object Int32Array]',
  7008. uint8Tag = '[object Uint8Array]',
  7009. uint8ClampedTag = '[object Uint8ClampedArray]',
  7010. uint16Tag = '[object Uint16Array]',
  7011. uint32Tag = '[object Uint32Array]';
  7012. /**
  7013. * Initializes an object clone based on its `toStringTag`.
  7014. *
  7015. * **Note:** This function only supports cloning values with tags of
  7016. * `Boolean`, `Date`, `Error`, `Map`, `Number`, `RegExp`, `Set`, or `String`.
  7017. *
  7018. * @private
  7019. * @param {Object} object The object to clone.
  7020. * @param {string} tag The `toStringTag` of the object to clone.
  7021. * @param {boolean} [isDeep] Specify a deep clone.
  7022. * @returns {Object} Returns the initialized clone.
  7023. */
  7024. function initCloneByTag(object, tag, isDeep) {
  7025. var Ctor = object.constructor;
  7026. switch (tag) {
  7027. case arrayBufferTag:
  7028. return cloneArrayBuffer(object);
  7029. case boolTag:
  7030. case dateTag:
  7031. return new Ctor(+object);
  7032. case dataViewTag:
  7033. return cloneDataView(object, isDeep);
  7034. case float32Tag: case float64Tag:
  7035. case int8Tag: case int16Tag: case int32Tag:
  7036. case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag:
  7037. return cloneTypedArray(object, isDeep);
  7038. case mapTag:
  7039. return new Ctor;
  7040. case numberTag:
  7041. case stringTag:
  7042. return new Ctor(object);
  7043. case regexpTag:
  7044. return cloneRegExp(object);
  7045. case setTag:
  7046. return new Ctor;
  7047. case symbolTag:
  7048. return cloneSymbol(object);
  7049. }
  7050. }
  7051. module.exports = initCloneByTag;
  7052. },{"./_cloneArrayBuffer":75,"./_cloneDataView":77,"./_cloneRegExp":78,"./_cloneSymbol":79,"./_cloneTypedArray":80}],107:[function(require,module,exports){
  7053. var baseCreate = require('./_baseCreate'),
  7054. getPrototype = require('./_getPrototype'),
  7055. isPrototype = require('./_isPrototype');
  7056. /**
  7057. * Initializes an object clone.
  7058. *
  7059. * @private
  7060. * @param {Object} object The object to clone.
  7061. * @returns {Object} Returns the initialized clone.
  7062. */
  7063. function initCloneObject(object) {
  7064. return (typeof object.constructor == 'function' && !isPrototype(object))
  7065. ? baseCreate(getPrototype(object))
  7066. : {};
  7067. }
  7068. module.exports = initCloneObject;
  7069. },{"./_baseCreate":57,"./_getPrototype":94,"./_isPrototype":112}],108:[function(require,module,exports){
  7070. /** Used as references for various `Number` constants. */
  7071. var MAX_SAFE_INTEGER = 9007199254740991;
  7072. /** Used to detect unsigned integer values. */
  7073. var reIsUint = /^(?:0|[1-9]\d*)$/;
  7074. /**
  7075. * Checks if `value` is a valid array-like index.
  7076. *
  7077. * @private
  7078. * @param {*} value The value to check.
  7079. * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
  7080. * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
  7081. */
  7082. function isIndex(value, length) {
  7083. var type = typeof value;
  7084. length = length == null ? MAX_SAFE_INTEGER : length;
  7085. return !!length &&
  7086. (type == 'number' ||
  7087. (type != 'symbol' && reIsUint.test(value))) &&
  7088. (value > -1 && value % 1 == 0 && value < length);
  7089. }
  7090. module.exports = isIndex;
  7091. },{}],109:[function(require,module,exports){
  7092. var eq = require('./eq'),
  7093. isArrayLike = require('./isArrayLike'),
  7094. isIndex = require('./_isIndex'),
  7095. isObject = require('./isObject');
  7096. /**
  7097. * Checks if the given arguments are from an iteratee call.
  7098. *
  7099. * @private
  7100. * @param {*} value The potential iteratee value argument.
  7101. * @param {*} index The potential iteratee index or key argument.
  7102. * @param {*} object The potential iteratee object argument.
  7103. * @returns {boolean} Returns `true` if the arguments are from an iteratee call,
  7104. * else `false`.
  7105. */
  7106. function isIterateeCall(value, index, object) {
  7107. if (!isObject(object)) {
  7108. return false;
  7109. }
  7110. var type = typeof index;
  7111. if (type == 'number'
  7112. ? (isArrayLike(object) && isIndex(index, object.length))
  7113. : (type == 'string' && index in object)
  7114. ) {
  7115. return eq(object[index], value);
  7116. }
  7117. return false;
  7118. }
  7119. module.exports = isIterateeCall;
  7120. },{"./_isIndex":108,"./eq":142,"./isArrayLike":147,"./isObject":153}],110:[function(require,module,exports){
  7121. /**
  7122. * Checks if `value` is suitable for use as unique object key.
  7123. *
  7124. * @private
  7125. * @param {*} value The value to check.
  7126. * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
  7127. */
  7128. function isKeyable(value) {
  7129. var type = typeof value;
  7130. return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
  7131. ? (value !== '__proto__')
  7132. : (value === null);
  7133. }
  7134. module.exports = isKeyable;
  7135. },{}],111:[function(require,module,exports){
  7136. var coreJsData = require('./_coreJsData');
  7137. /** Used to detect methods masquerading as native. */
  7138. var maskSrcKey = (function() {
  7139. var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
  7140. return uid ? ('Symbol(src)_1.' + uid) : '';
  7141. }());
  7142. /**
  7143. * Checks if `func` has its source masked.
  7144. *
  7145. * @private
  7146. * @param {Function} func The function to check.
  7147. * @returns {boolean} Returns `true` if `func` is masked, else `false`.
  7148. */
  7149. function isMasked(func) {
  7150. return !!maskSrcKey && (maskSrcKey in func);
  7151. }
  7152. module.exports = isMasked;
  7153. },{"./_coreJsData":85}],112:[function(require,module,exports){
  7154. /** Used for built-in method references. */
  7155. var objectProto = Object.prototype;
  7156. /**
  7157. * Checks if `value` is likely a prototype object.
  7158. *
  7159. * @private
  7160. * @param {*} value The value to check.
  7161. * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
  7162. */
  7163. function isPrototype(value) {
  7164. var Ctor = value && value.constructor,
  7165. proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
  7166. return value === proto;
  7167. }
  7168. module.exports = isPrototype;
  7169. },{}],113:[function(require,module,exports){
  7170. /**
  7171. * Removes all key-value entries from the list cache.
  7172. *
  7173. * @private
  7174. * @name clear
  7175. * @memberOf ListCache
  7176. */
  7177. function listCacheClear() {
  7178. this.__data__ = [];
  7179. this.size = 0;
  7180. }
  7181. module.exports = listCacheClear;
  7182. },{}],114:[function(require,module,exports){
  7183. var assocIndexOf = require('./_assocIndexOf');
  7184. /** Used for built-in method references. */
  7185. var arrayProto = Array.prototype;
  7186. /** Built-in value references. */
  7187. var splice = arrayProto.splice;
  7188. /**
  7189. * Removes `key` and its value from the list cache.
  7190. *
  7191. * @private
  7192. * @name delete
  7193. * @memberOf ListCache
  7194. * @param {string} key The key of the value to remove.
  7195. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  7196. */
  7197. function listCacheDelete(key) {
  7198. var data = this.__data__,
  7199. index = assocIndexOf(data, key);
  7200. if (index < 0) {
  7201. return false;
  7202. }
  7203. var lastIndex = data.length - 1;
  7204. if (index == lastIndex) {
  7205. data.pop();
  7206. } else {
  7207. splice.call(data, index, 1);
  7208. }
  7209. --this.size;
  7210. return true;
  7211. }
  7212. module.exports = listCacheDelete;
  7213. },{"./_assocIndexOf":52}],115:[function(require,module,exports){
  7214. var assocIndexOf = require('./_assocIndexOf');
  7215. /**
  7216. * Gets the list cache value for `key`.
  7217. *
  7218. * @private
  7219. * @name get
  7220. * @memberOf ListCache
  7221. * @param {string} key The key of the value to get.
  7222. * @returns {*} Returns the entry value.
  7223. */
  7224. function listCacheGet(key) {
  7225. var data = this.__data__,
  7226. index = assocIndexOf(data, key);
  7227. return index < 0 ? undefined : data[index][1];
  7228. }
  7229. module.exports = listCacheGet;
  7230. },{"./_assocIndexOf":52}],116:[function(require,module,exports){
  7231. var assocIndexOf = require('./_assocIndexOf');
  7232. /**
  7233. * Checks if a list cache value for `key` exists.
  7234. *
  7235. * @private
  7236. * @name has
  7237. * @memberOf ListCache
  7238. * @param {string} key The key of the entry to check.
  7239. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  7240. */
  7241. function listCacheHas(key) {
  7242. return assocIndexOf(this.__data__, key) > -1;
  7243. }
  7244. module.exports = listCacheHas;
  7245. },{"./_assocIndexOf":52}],117:[function(require,module,exports){
  7246. var assocIndexOf = require('./_assocIndexOf');
  7247. /**
  7248. * Sets the list cache `key` to `value`.
  7249. *
  7250. * @private
  7251. * @name set
  7252. * @memberOf ListCache
  7253. * @param {string} key The key of the value to set.
  7254. * @param {*} value The value to set.
  7255. * @returns {Object} Returns the list cache instance.
  7256. */
  7257. function listCacheSet(key, value) {
  7258. var data = this.__data__,
  7259. index = assocIndexOf(data, key);
  7260. if (index < 0) {
  7261. ++this.size;
  7262. data.push([key, value]);
  7263. } else {
  7264. data[index][1] = value;
  7265. }
  7266. return this;
  7267. }
  7268. module.exports = listCacheSet;
  7269. },{"./_assocIndexOf":52}],118:[function(require,module,exports){
  7270. var Hash = require('./_Hash'),
  7271. ListCache = require('./_ListCache'),
  7272. Map = require('./_Map');
  7273. /**
  7274. * Removes all key-value entries from the map.
  7275. *
  7276. * @private
  7277. * @name clear
  7278. * @memberOf MapCache
  7279. */
  7280. function mapCacheClear() {
  7281. this.size = 0;
  7282. this.__data__ = {
  7283. 'hash': new Hash,
  7284. 'map': new (Map || ListCache),
  7285. 'string': new Hash
  7286. };
  7287. }
  7288. module.exports = mapCacheClear;
  7289. },{"./_Hash":34,"./_ListCache":35,"./_Map":36}],119:[function(require,module,exports){
  7290. var getMapData = require('./_getMapData');
  7291. /**
  7292. * Removes `key` and its value from the map.
  7293. *
  7294. * @private
  7295. * @name delete
  7296. * @memberOf MapCache
  7297. * @param {string} key The key of the value to remove.
  7298. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  7299. */
  7300. function mapCacheDelete(key) {
  7301. var result = getMapData(this, key)['delete'](key);
  7302. this.size -= result ? 1 : 0;
  7303. return result;
  7304. }
  7305. module.exports = mapCacheDelete;
  7306. },{"./_getMapData":92}],120:[function(require,module,exports){
  7307. var getMapData = require('./_getMapData');
  7308. /**
  7309. * Gets the map value for `key`.
  7310. *
  7311. * @private
  7312. * @name get
  7313. * @memberOf MapCache
  7314. * @param {string} key The key of the value to get.
  7315. * @returns {*} Returns the entry value.
  7316. */
  7317. function mapCacheGet(key) {
  7318. return getMapData(this, key).get(key);
  7319. }
  7320. module.exports = mapCacheGet;
  7321. },{"./_getMapData":92}],121:[function(require,module,exports){
  7322. var getMapData = require('./_getMapData');
  7323. /**
  7324. * Checks if a map value for `key` exists.
  7325. *
  7326. * @private
  7327. * @name has
  7328. * @memberOf MapCache
  7329. * @param {string} key The key of the entry to check.
  7330. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  7331. */
  7332. function mapCacheHas(key) {
  7333. return getMapData(this, key).has(key);
  7334. }
  7335. module.exports = mapCacheHas;
  7336. },{"./_getMapData":92}],122:[function(require,module,exports){
  7337. var getMapData = require('./_getMapData');
  7338. /**
  7339. * Sets the map `key` to `value`.
  7340. *
  7341. * @private
  7342. * @name set
  7343. * @memberOf MapCache
  7344. * @param {string} key The key of the value to set.
  7345. * @param {*} value The value to set.
  7346. * @returns {Object} Returns the map cache instance.
  7347. */
  7348. function mapCacheSet(key, value) {
  7349. var data = getMapData(this, key),
  7350. size = data.size;
  7351. data.set(key, value);
  7352. this.size += data.size == size ? 0 : 1;
  7353. return this;
  7354. }
  7355. module.exports = mapCacheSet;
  7356. },{"./_getMapData":92}],123:[function(require,module,exports){
  7357. var getNative = require('./_getNative');
  7358. /* Built-in method references that are verified to be native. */
  7359. var nativeCreate = getNative(Object, 'create');
  7360. module.exports = nativeCreate;
  7361. },{"./_getNative":93}],124:[function(require,module,exports){
  7362. var overArg = require('./_overArg');
  7363. /* Built-in method references for those with the same name as other `lodash` methods. */
  7364. var nativeKeys = overArg(Object.keys, Object);
  7365. module.exports = nativeKeys;
  7366. },{"./_overArg":128}],125:[function(require,module,exports){
  7367. /**
  7368. * This function is like
  7369. * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  7370. * except that it includes inherited enumerable properties.
  7371. *
  7372. * @private
  7373. * @param {Object} object The object to query.
  7374. * @returns {Array} Returns the array of property names.
  7375. */
  7376. function nativeKeysIn(object) {
  7377. var result = [];
  7378. if (object != null) {
  7379. for (var key in Object(object)) {
  7380. result.push(key);
  7381. }
  7382. }
  7383. return result;
  7384. }
  7385. module.exports = nativeKeysIn;
  7386. },{}],126:[function(require,module,exports){
  7387. var freeGlobal = require('./_freeGlobal');
  7388. /** Detect free variable `exports`. */
  7389. var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
  7390. /** Detect free variable `module`. */
  7391. var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
  7392. /** Detect the popular CommonJS extension `module.exports`. */
  7393. var moduleExports = freeModule && freeModule.exports === freeExports;
  7394. /** Detect free variable `process` from Node.js. */
  7395. var freeProcess = moduleExports && freeGlobal.process;
  7396. /** Used to access faster Node.js helpers. */
  7397. var nodeUtil = (function() {
  7398. try {
  7399. // Use `util.types` for Node.js 10+.
  7400. var types = freeModule && freeModule.require && freeModule.require('util').types;
  7401. if (types) {
  7402. return types;
  7403. }
  7404. // Legacy `process.binding('util')` for Node.js < 10.
  7405. return freeProcess && freeProcess.binding && freeProcess.binding('util');
  7406. } catch (e) {}
  7407. }());
  7408. module.exports = nodeUtil;
  7409. },{"./_freeGlobal":89}],127:[function(require,module,exports){
  7410. /** Used for built-in method references. */
  7411. var objectProto = Object.prototype;
  7412. /**
  7413. * Used to resolve the
  7414. * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
  7415. * of values.
  7416. */
  7417. var nativeObjectToString = objectProto.toString;
  7418. /**
  7419. * Converts `value` to a string using `Object.prototype.toString`.
  7420. *
  7421. * @private
  7422. * @param {*} value The value to convert.
  7423. * @returns {string} Returns the converted string.
  7424. */
  7425. function objectToString(value) {
  7426. return nativeObjectToString.call(value);
  7427. }
  7428. module.exports = objectToString;
  7429. },{}],128:[function(require,module,exports){
  7430. /**
  7431. * Creates a unary function that invokes `func` with its argument transformed.
  7432. *
  7433. * @private
  7434. * @param {Function} func The function to wrap.
  7435. * @param {Function} transform The argument transform.
  7436. * @returns {Function} Returns the new function.
  7437. */
  7438. function overArg(func, transform) {
  7439. return function(arg) {
  7440. return func(transform(arg));
  7441. };
  7442. }
  7443. module.exports = overArg;
  7444. },{}],129:[function(require,module,exports){
  7445. var apply = require('./_apply');
  7446. /* Built-in method references for those with the same name as other `lodash` methods. */
  7447. var nativeMax = Math.max;
  7448. /**
  7449. * A specialized version of `baseRest` which transforms the rest array.
  7450. *
  7451. * @private
  7452. * @param {Function} func The function to apply a rest parameter to.
  7453. * @param {number} [start=func.length-1] The start position of the rest parameter.
  7454. * @param {Function} transform The rest array transform.
  7455. * @returns {Function} Returns the new function.
  7456. */
  7457. function overRest(func, start, transform) {
  7458. start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
  7459. return function() {
  7460. var args = arguments,
  7461. index = -1,
  7462. length = nativeMax(args.length - start, 0),
  7463. array = Array(length);
  7464. while (++index < length) {
  7465. array[index] = args[start + index];
  7466. }
  7467. index = -1;
  7468. var otherArgs = Array(start + 1);
  7469. while (++index < start) {
  7470. otherArgs[index] = args[index];
  7471. }
  7472. otherArgs[start] = transform(array);
  7473. return apply(func, this, otherArgs);
  7474. };
  7475. }
  7476. module.exports = overRest;
  7477. },{"./_apply":44}],130:[function(require,module,exports){
  7478. var freeGlobal = require('./_freeGlobal');
  7479. /** Detect free variable `self`. */
  7480. var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
  7481. /** Used as a reference to the global object. */
  7482. var root = freeGlobal || freeSelf || Function('return this')();
  7483. module.exports = root;
  7484. },{"./_freeGlobal":89}],131:[function(require,module,exports){
  7485. /**
  7486. * Gets the value at `key`, unless `key` is "__proto__" or "constructor".
  7487. *
  7488. * @private
  7489. * @param {Object} object The object to query.
  7490. * @param {string} key The key of the property to get.
  7491. * @returns {*} Returns the property value.
  7492. */
  7493. function safeGet(object, key) {
  7494. if (key === 'constructor' && typeof object[key] === 'function') {
  7495. return;
  7496. }
  7497. if (key == '__proto__') {
  7498. return;
  7499. }
  7500. return object[key];
  7501. }
  7502. module.exports = safeGet;
  7503. },{}],132:[function(require,module,exports){
  7504. var baseSetToString = require('./_baseSetToString'),
  7505. shortOut = require('./_shortOut');
  7506. /**
  7507. * Sets the `toString` method of `func` to return `string`.
  7508. *
  7509. * @private
  7510. * @param {Function} func The function to modify.
  7511. * @param {Function} string The `toString` result.
  7512. * @returns {Function} Returns `func`.
  7513. */
  7514. var setToString = shortOut(baseSetToString);
  7515. module.exports = setToString;
  7516. },{"./_baseSetToString":71,"./_shortOut":133}],133:[function(require,module,exports){
  7517. /** Used to detect hot functions by number of calls within a span of milliseconds. */
  7518. var HOT_COUNT = 800,
  7519. HOT_SPAN = 16;
  7520. /* Built-in method references for those with the same name as other `lodash` methods. */
  7521. var nativeNow = Date.now;
  7522. /**
  7523. * Creates a function that'll short out and invoke `identity` instead
  7524. * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN`
  7525. * milliseconds.
  7526. *
  7527. * @private
  7528. * @param {Function} func The function to restrict.
  7529. * @returns {Function} Returns the new shortable function.
  7530. */
  7531. function shortOut(func) {
  7532. var count = 0,
  7533. lastCalled = 0;
  7534. return function() {
  7535. var stamp = nativeNow(),
  7536. remaining = HOT_SPAN - (stamp - lastCalled);
  7537. lastCalled = stamp;
  7538. if (remaining > 0) {
  7539. if (++count >= HOT_COUNT) {
  7540. return arguments[0];
  7541. }
  7542. } else {
  7543. count = 0;
  7544. }
  7545. return func.apply(undefined, arguments);
  7546. };
  7547. }
  7548. module.exports = shortOut;
  7549. },{}],134:[function(require,module,exports){
  7550. var ListCache = require('./_ListCache');
  7551. /**
  7552. * Removes all key-value entries from the stack.
  7553. *
  7554. * @private
  7555. * @name clear
  7556. * @memberOf Stack
  7557. */
  7558. function stackClear() {
  7559. this.__data__ = new ListCache;
  7560. this.size = 0;
  7561. }
  7562. module.exports = stackClear;
  7563. },{"./_ListCache":35}],135:[function(require,module,exports){
  7564. /**
  7565. * Removes `key` and its value from the stack.
  7566. *
  7567. * @private
  7568. * @name delete
  7569. * @memberOf Stack
  7570. * @param {string} key The key of the value to remove.
  7571. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  7572. */
  7573. function stackDelete(key) {
  7574. var data = this.__data__,
  7575. result = data['delete'](key);
  7576. this.size = data.size;
  7577. return result;
  7578. }
  7579. module.exports = stackDelete;
  7580. },{}],136:[function(require,module,exports){
  7581. /**
  7582. * Gets the stack value for `key`.
  7583. *
  7584. * @private
  7585. * @name get
  7586. * @memberOf Stack
  7587. * @param {string} key The key of the value to get.
  7588. * @returns {*} Returns the entry value.
  7589. */
  7590. function stackGet(key) {
  7591. return this.__data__.get(key);
  7592. }
  7593. module.exports = stackGet;
  7594. },{}],137:[function(require,module,exports){
  7595. /**
  7596. * Checks if a stack value for `key` exists.
  7597. *
  7598. * @private
  7599. * @name has
  7600. * @memberOf Stack
  7601. * @param {string} key The key of the entry to check.
  7602. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  7603. */
  7604. function stackHas(key) {
  7605. return this.__data__.has(key);
  7606. }
  7607. module.exports = stackHas;
  7608. },{}],138:[function(require,module,exports){
  7609. var ListCache = require('./_ListCache'),
  7610. Map = require('./_Map'),
  7611. MapCache = require('./_MapCache');
  7612. /** Used as the size to enable large array optimizations. */
  7613. var LARGE_ARRAY_SIZE = 200;
  7614. /**
  7615. * Sets the stack `key` to `value`.
  7616. *
  7617. * @private
  7618. * @name set
  7619. * @memberOf Stack
  7620. * @param {string} key The key of the value to set.
  7621. * @param {*} value The value to set.
  7622. * @returns {Object} Returns the stack cache instance.
  7623. */
  7624. function stackSet(key, value) {
  7625. var data = this.__data__;
  7626. if (data instanceof ListCache) {
  7627. var pairs = data.__data__;
  7628. if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
  7629. pairs.push([key, value]);
  7630. this.size = ++data.size;
  7631. return this;
  7632. }
  7633. data = this.__data__ = new MapCache(pairs);
  7634. }
  7635. data.set(key, value);
  7636. this.size = data.size;
  7637. return this;
  7638. }
  7639. module.exports = stackSet;
  7640. },{"./_ListCache":35,"./_Map":36,"./_MapCache":37}],139:[function(require,module,exports){
  7641. /** Used for built-in method references. */
  7642. var funcProto = Function.prototype;
  7643. /** Used to resolve the decompiled source of functions. */
  7644. var funcToString = funcProto.toString;
  7645. /**
  7646. * Converts `func` to its source code.
  7647. *
  7648. * @private
  7649. * @param {Function} func The function to convert.
  7650. * @returns {string} Returns the source code.
  7651. */
  7652. function toSource(func) {
  7653. if (func != null) {
  7654. try {
  7655. return funcToString.call(func);
  7656. } catch (e) {}
  7657. try {
  7658. return (func + '');
  7659. } catch (e) {}
  7660. }
  7661. return '';
  7662. }
  7663. module.exports = toSource;
  7664. },{}],140:[function(require,module,exports){
  7665. var baseClone = require('./_baseClone');
  7666. /** Used to compose bitmasks for cloning. */
  7667. var CLONE_DEEP_FLAG = 1,
  7668. CLONE_SYMBOLS_FLAG = 4;
  7669. /**
  7670. * This method is like `_.clone` except that it recursively clones `value`.
  7671. *
  7672. * @static
  7673. * @memberOf _
  7674. * @since 1.0.0
  7675. * @category Lang
  7676. * @param {*} value The value to recursively clone.
  7677. * @returns {*} Returns the deep cloned value.
  7678. * @see _.clone
  7679. * @example
  7680. *
  7681. * var objects = [{ 'a': 1 }, { 'b': 2 }];
  7682. *
  7683. * var deep = _.cloneDeep(objects);
  7684. * console.log(deep[0] === objects[0]);
  7685. * // => false
  7686. */
  7687. function cloneDeep(value) {
  7688. return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG);
  7689. }
  7690. module.exports = cloneDeep;
  7691. },{"./_baseClone":56}],141:[function(require,module,exports){
  7692. /**
  7693. * Creates a function that returns `value`.
  7694. *
  7695. * @static
  7696. * @memberOf _
  7697. * @since 2.4.0
  7698. * @category Util
  7699. * @param {*} value The value to return from the new function.
  7700. * @returns {Function} Returns the new constant function.
  7701. * @example
  7702. *
  7703. * var objects = _.times(2, _.constant({ 'a': 1 }));
  7704. *
  7705. * console.log(objects);
  7706. * // => [{ 'a': 1 }, { 'a': 1 }]
  7707. *
  7708. * console.log(objects[0] === objects[1]);
  7709. * // => true
  7710. */
  7711. function constant(value) {
  7712. return function() {
  7713. return value;
  7714. };
  7715. }
  7716. module.exports = constant;
  7717. },{}],142:[function(require,module,exports){
  7718. /**
  7719. * Performs a
  7720. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  7721. * comparison between two values to determine if they are equivalent.
  7722. *
  7723. * @static
  7724. * @memberOf _
  7725. * @since 4.0.0
  7726. * @category Lang
  7727. * @param {*} value The value to compare.
  7728. * @param {*} other The other value to compare.
  7729. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  7730. * @example
  7731. *
  7732. * var object = { 'a': 1 };
  7733. * var other = { 'a': 1 };
  7734. *
  7735. * _.eq(object, object);
  7736. * // => true
  7737. *
  7738. * _.eq(object, other);
  7739. * // => false
  7740. *
  7741. * _.eq('a', 'a');
  7742. * // => true
  7743. *
  7744. * _.eq('a', Object('a'));
  7745. * // => false
  7746. *
  7747. * _.eq(NaN, NaN);
  7748. * // => true
  7749. */
  7750. function eq(value, other) {
  7751. return value === other || (value !== value && other !== other);
  7752. }
  7753. module.exports = eq;
  7754. },{}],143:[function(require,module,exports){
  7755. var toString = require('./toString');
  7756. /**
  7757. * Used to match `RegExp`
  7758. * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
  7759. */
  7760. var reRegExpChar = /[\\^$.*+?()[\]{}|]/g,
  7761. reHasRegExpChar = RegExp(reRegExpChar.source);
  7762. /**
  7763. * Escapes the `RegExp` special characters "^", "$", "\", ".", "*", "+",
  7764. * "?", "(", ")", "[", "]", "{", "}", and "|" in `string`.
  7765. *
  7766. * @static
  7767. * @memberOf _
  7768. * @since 3.0.0
  7769. * @category String
  7770. * @param {string} [string=''] The string to escape.
  7771. * @returns {string} Returns the escaped string.
  7772. * @example
  7773. *
  7774. * _.escapeRegExp('[lodash](https://lodash.com/)');
  7775. * // => '\[lodash\]\(https://lodash\.com/\)'
  7776. */
  7777. function escapeRegExp(string) {
  7778. string = toString(string);
  7779. return (string && reHasRegExpChar.test(string))
  7780. ? string.replace(reRegExpChar, '\\$&')
  7781. : string;
  7782. }
  7783. module.exports = escapeRegExp;
  7784. },{"./toString":166}],144:[function(require,module,exports){
  7785. /**
  7786. * This method returns the first argument it receives.
  7787. *
  7788. * @static
  7789. * @since 0.1.0
  7790. * @memberOf _
  7791. * @category Util
  7792. * @param {*} value Any value.
  7793. * @returns {*} Returns `value`.
  7794. * @example
  7795. *
  7796. * var object = { 'a': 1 };
  7797. *
  7798. * console.log(_.identity(object) === object);
  7799. * // => true
  7800. */
  7801. function identity(value) {
  7802. return value;
  7803. }
  7804. module.exports = identity;
  7805. },{}],145:[function(require,module,exports){
  7806. var baseIsArguments = require('./_baseIsArguments'),
  7807. isObjectLike = require('./isObjectLike');
  7808. /** Used for built-in method references. */
  7809. var objectProto = Object.prototype;
  7810. /** Used to check objects for own properties. */
  7811. var hasOwnProperty = objectProto.hasOwnProperty;
  7812. /** Built-in value references. */
  7813. var propertyIsEnumerable = objectProto.propertyIsEnumerable;
  7814. /**
  7815. * Checks if `value` is likely an `arguments` object.
  7816. *
  7817. * @static
  7818. * @memberOf _
  7819. * @since 0.1.0
  7820. * @category Lang
  7821. * @param {*} value The value to check.
  7822. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  7823. * else `false`.
  7824. * @example
  7825. *
  7826. * _.isArguments(function() { return arguments; }());
  7827. * // => true
  7828. *
  7829. * _.isArguments([1, 2, 3]);
  7830. * // => false
  7831. */
  7832. var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
  7833. return isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&
  7834. !propertyIsEnumerable.call(value, 'callee');
  7835. };
  7836. module.exports = isArguments;
  7837. },{"./_baseIsArguments":61,"./isObjectLike":154}],146:[function(require,module,exports){
  7838. /**
  7839. * Checks if `value` is classified as an `Array` object.
  7840. *
  7841. * @static
  7842. * @memberOf _
  7843. * @since 0.1.0
  7844. * @category Lang
  7845. * @param {*} value The value to check.
  7846. * @returns {boolean} Returns `true` if `value` is an array, else `false`.
  7847. * @example
  7848. *
  7849. * _.isArray([1, 2, 3]);
  7850. * // => true
  7851. *
  7852. * _.isArray(document.body.children);
  7853. * // => false
  7854. *
  7855. * _.isArray('abc');
  7856. * // => false
  7857. *
  7858. * _.isArray(_.noop);
  7859. * // => false
  7860. */
  7861. var isArray = Array.isArray;
  7862. module.exports = isArray;
  7863. },{}],147:[function(require,module,exports){
  7864. var isFunction = require('./isFunction'),
  7865. isLength = require('./isLength');
  7866. /**
  7867. * Checks if `value` is array-like. A value is considered array-like if it's
  7868. * not a function and has a `value.length` that's an integer greater than or
  7869. * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
  7870. *
  7871. * @static
  7872. * @memberOf _
  7873. * @since 4.0.0
  7874. * @category Lang
  7875. * @param {*} value The value to check.
  7876. * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
  7877. * @example
  7878. *
  7879. * _.isArrayLike([1, 2, 3]);
  7880. * // => true
  7881. *
  7882. * _.isArrayLike(document.body.children);
  7883. * // => true
  7884. *
  7885. * _.isArrayLike('abc');
  7886. * // => true
  7887. *
  7888. * _.isArrayLike(_.noop);
  7889. * // => false
  7890. */
  7891. function isArrayLike(value) {
  7892. return value != null && isLength(value.length) && !isFunction(value);
  7893. }
  7894. module.exports = isArrayLike;
  7895. },{"./isFunction":150,"./isLength":151}],148:[function(require,module,exports){
  7896. var isArrayLike = require('./isArrayLike'),
  7897. isObjectLike = require('./isObjectLike');
  7898. /**
  7899. * This method is like `_.isArrayLike` except that it also checks if `value`
  7900. * is an object.
  7901. *
  7902. * @static
  7903. * @memberOf _
  7904. * @since 4.0.0
  7905. * @category Lang
  7906. * @param {*} value The value to check.
  7907. * @returns {boolean} Returns `true` if `value` is an array-like object,
  7908. * else `false`.
  7909. * @example
  7910. *
  7911. * _.isArrayLikeObject([1, 2, 3]);
  7912. * // => true
  7913. *
  7914. * _.isArrayLikeObject(document.body.children);
  7915. * // => true
  7916. *
  7917. * _.isArrayLikeObject('abc');
  7918. * // => false
  7919. *
  7920. * _.isArrayLikeObject(_.noop);
  7921. * // => false
  7922. */
  7923. function isArrayLikeObject(value) {
  7924. return isObjectLike(value) && isArrayLike(value);
  7925. }
  7926. module.exports = isArrayLikeObject;
  7927. },{"./isArrayLike":147,"./isObjectLike":154}],149:[function(require,module,exports){
  7928. var root = require('./_root'),
  7929. stubFalse = require('./stubFalse');
  7930. /** Detect free variable `exports`. */
  7931. var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
  7932. /** Detect free variable `module`. */
  7933. var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
  7934. /** Detect the popular CommonJS extension `module.exports`. */
  7935. var moduleExports = freeModule && freeModule.exports === freeExports;
  7936. /** Built-in value references. */
  7937. var Buffer = moduleExports ? root.Buffer : undefined;
  7938. /* Built-in method references for those with the same name as other `lodash` methods. */
  7939. var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined;
  7940. /**
  7941. * Checks if `value` is a buffer.
  7942. *
  7943. * @static
  7944. * @memberOf _
  7945. * @since 4.3.0
  7946. * @category Lang
  7947. * @param {*} value The value to check.
  7948. * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
  7949. * @example
  7950. *
  7951. * _.isBuffer(new Buffer(2));
  7952. * // => true
  7953. *
  7954. * _.isBuffer(new Uint8Array(2));
  7955. * // => false
  7956. */
  7957. var isBuffer = nativeIsBuffer || stubFalse;
  7958. module.exports = isBuffer;
  7959. },{"./_root":130,"./stubFalse":164}],150:[function(require,module,exports){
  7960. var baseGetTag = require('./_baseGetTag'),
  7961. isObject = require('./isObject');
  7962. /** `Object#toString` result references. */
  7963. var asyncTag = '[object AsyncFunction]',
  7964. funcTag = '[object Function]',
  7965. genTag = '[object GeneratorFunction]',
  7966. proxyTag = '[object Proxy]';
  7967. /**
  7968. * Checks if `value` is classified as a `Function` object.
  7969. *
  7970. * @static
  7971. * @memberOf _
  7972. * @since 0.1.0
  7973. * @category Lang
  7974. * @param {*} value The value to check.
  7975. * @returns {boolean} Returns `true` if `value` is a function, else `false`.
  7976. * @example
  7977. *
  7978. * _.isFunction(_);
  7979. * // => true
  7980. *
  7981. * _.isFunction(/abc/);
  7982. * // => false
  7983. */
  7984. function isFunction(value) {
  7985. if (!isObject(value)) {
  7986. return false;
  7987. }
  7988. // The use of `Object#toString` avoids issues with the `typeof` operator
  7989. // in Safari 9 which returns 'object' for typed arrays and other constructors.
  7990. var tag = baseGetTag(value);
  7991. return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
  7992. }
  7993. module.exports = isFunction;
  7994. },{"./_baseGetTag":60,"./isObject":153}],151:[function(require,module,exports){
  7995. /** Used as references for various `Number` constants. */
  7996. var MAX_SAFE_INTEGER = 9007199254740991;
  7997. /**
  7998. * Checks if `value` is a valid array-like length.
  7999. *
  8000. * **Note:** This method is loosely based on
  8001. * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
  8002. *
  8003. * @static
  8004. * @memberOf _
  8005. * @since 4.0.0
  8006. * @category Lang
  8007. * @param {*} value The value to check.
  8008. * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
  8009. * @example
  8010. *
  8011. * _.isLength(3);
  8012. * // => true
  8013. *
  8014. * _.isLength(Number.MIN_VALUE);
  8015. * // => false
  8016. *
  8017. * _.isLength(Infinity);
  8018. * // => false
  8019. *
  8020. * _.isLength('3');
  8021. * // => false
  8022. */
  8023. function isLength(value) {
  8024. return typeof value == 'number' &&
  8025. value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
  8026. }
  8027. module.exports = isLength;
  8028. },{}],152:[function(require,module,exports){
  8029. var baseIsMap = require('./_baseIsMap'),
  8030. baseUnary = require('./_baseUnary'),
  8031. nodeUtil = require('./_nodeUtil');
  8032. /* Node.js helper references. */
  8033. var nodeIsMap = nodeUtil && nodeUtil.isMap;
  8034. /**
  8035. * Checks if `value` is classified as a `Map` object.
  8036. *
  8037. * @static
  8038. * @memberOf _
  8039. * @since 4.3.0
  8040. * @category Lang
  8041. * @param {*} value The value to check.
  8042. * @returns {boolean} Returns `true` if `value` is a map, else `false`.
  8043. * @example
  8044. *
  8045. * _.isMap(new Map);
  8046. * // => true
  8047. *
  8048. * _.isMap(new WeakMap);
  8049. * // => false
  8050. */
  8051. var isMap = nodeIsMap ? baseUnary(nodeIsMap) : baseIsMap;
  8052. module.exports = isMap;
  8053. },{"./_baseIsMap":62,"./_baseUnary":74,"./_nodeUtil":126}],153:[function(require,module,exports){
  8054. /**
  8055. * Checks if `value` is the
  8056. * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
  8057. * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  8058. *
  8059. * @static
  8060. * @memberOf _
  8061. * @since 0.1.0
  8062. * @category Lang
  8063. * @param {*} value The value to check.
  8064. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  8065. * @example
  8066. *
  8067. * _.isObject({});
  8068. * // => true
  8069. *
  8070. * _.isObject([1, 2, 3]);
  8071. * // => true
  8072. *
  8073. * _.isObject(_.noop);
  8074. * // => true
  8075. *
  8076. * _.isObject(null);
  8077. * // => false
  8078. */
  8079. function isObject(value) {
  8080. var type = typeof value;
  8081. return value != null && (type == 'object' || type == 'function');
  8082. }
  8083. module.exports = isObject;
  8084. },{}],154:[function(require,module,exports){
  8085. /**
  8086. * Checks if `value` is object-like. A value is object-like if it's not `null`
  8087. * and has a `typeof` result of "object".
  8088. *
  8089. * @static
  8090. * @memberOf _
  8091. * @since 4.0.0
  8092. * @category Lang
  8093. * @param {*} value The value to check.
  8094. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  8095. * @example
  8096. *
  8097. * _.isObjectLike({});
  8098. * // => true
  8099. *
  8100. * _.isObjectLike([1, 2, 3]);
  8101. * // => true
  8102. *
  8103. * _.isObjectLike(_.noop);
  8104. * // => false
  8105. *
  8106. * _.isObjectLike(null);
  8107. * // => false
  8108. */
  8109. function isObjectLike(value) {
  8110. return value != null && typeof value == 'object';
  8111. }
  8112. module.exports = isObjectLike;
  8113. },{}],155:[function(require,module,exports){
  8114. var baseGetTag = require('./_baseGetTag'),
  8115. getPrototype = require('./_getPrototype'),
  8116. isObjectLike = require('./isObjectLike');
  8117. /** `Object#toString` result references. */
  8118. var objectTag = '[object Object]';
  8119. /** Used for built-in method references. */
  8120. var funcProto = Function.prototype,
  8121. objectProto = Object.prototype;
  8122. /** Used to resolve the decompiled source of functions. */
  8123. var funcToString = funcProto.toString;
  8124. /** Used to check objects for own properties. */
  8125. var hasOwnProperty = objectProto.hasOwnProperty;
  8126. /** Used to infer the `Object` constructor. */
  8127. var objectCtorString = funcToString.call(Object);
  8128. /**
  8129. * Checks if `value` is a plain object, that is, an object created by the
  8130. * `Object` constructor or one with a `[[Prototype]]` of `null`.
  8131. *
  8132. * @static
  8133. * @memberOf _
  8134. * @since 0.8.0
  8135. * @category Lang
  8136. * @param {*} value The value to check.
  8137. * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
  8138. * @example
  8139. *
  8140. * function Foo() {
  8141. * this.a = 1;
  8142. * }
  8143. *
  8144. * _.isPlainObject(new Foo);
  8145. * // => false
  8146. *
  8147. * _.isPlainObject([1, 2, 3]);
  8148. * // => false
  8149. *
  8150. * _.isPlainObject({ 'x': 0, 'y': 0 });
  8151. * // => true
  8152. *
  8153. * _.isPlainObject(Object.create(null));
  8154. * // => true
  8155. */
  8156. function isPlainObject(value) {
  8157. if (!isObjectLike(value) || baseGetTag(value) != objectTag) {
  8158. return false;
  8159. }
  8160. var proto = getPrototype(value);
  8161. if (proto === null) {
  8162. return true;
  8163. }
  8164. var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor;
  8165. return typeof Ctor == 'function' && Ctor instanceof Ctor &&
  8166. funcToString.call(Ctor) == objectCtorString;
  8167. }
  8168. module.exports = isPlainObject;
  8169. },{"./_baseGetTag":60,"./_getPrototype":94,"./isObjectLike":154}],156:[function(require,module,exports){
  8170. var baseIsSet = require('./_baseIsSet'),
  8171. baseUnary = require('./_baseUnary'),
  8172. nodeUtil = require('./_nodeUtil');
  8173. /* Node.js helper references. */
  8174. var nodeIsSet = nodeUtil && nodeUtil.isSet;
  8175. /**
  8176. * Checks if `value` is classified as a `Set` object.
  8177. *
  8178. * @static
  8179. * @memberOf _
  8180. * @since 4.3.0
  8181. * @category Lang
  8182. * @param {*} value The value to check.
  8183. * @returns {boolean} Returns `true` if `value` is a set, else `false`.
  8184. * @example
  8185. *
  8186. * _.isSet(new Set);
  8187. * // => true
  8188. *
  8189. * _.isSet(new WeakSet);
  8190. * // => false
  8191. */
  8192. var isSet = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet;
  8193. module.exports = isSet;
  8194. },{"./_baseIsSet":64,"./_baseUnary":74,"./_nodeUtil":126}],157:[function(require,module,exports){
  8195. var baseGetTag = require('./_baseGetTag'),
  8196. isArray = require('./isArray'),
  8197. isObjectLike = require('./isObjectLike');
  8198. /** `Object#toString` result references. */
  8199. var stringTag = '[object String]';
  8200. /**
  8201. * Checks if `value` is classified as a `String` primitive or object.
  8202. *
  8203. * @static
  8204. * @since 0.1.0
  8205. * @memberOf _
  8206. * @category Lang
  8207. * @param {*} value The value to check.
  8208. * @returns {boolean} Returns `true` if `value` is a string, else `false`.
  8209. * @example
  8210. *
  8211. * _.isString('abc');
  8212. * // => true
  8213. *
  8214. * _.isString(1);
  8215. * // => false
  8216. */
  8217. function isString(value) {
  8218. return typeof value == 'string' ||
  8219. (!isArray(value) && isObjectLike(value) && baseGetTag(value) == stringTag);
  8220. }
  8221. module.exports = isString;
  8222. },{"./_baseGetTag":60,"./isArray":146,"./isObjectLike":154}],158:[function(require,module,exports){
  8223. var baseGetTag = require('./_baseGetTag'),
  8224. isObjectLike = require('./isObjectLike');
  8225. /** `Object#toString` result references. */
  8226. var symbolTag = '[object Symbol]';
  8227. /**
  8228. * Checks if `value` is classified as a `Symbol` primitive or object.
  8229. *
  8230. * @static
  8231. * @memberOf _
  8232. * @since 4.0.0
  8233. * @category Lang
  8234. * @param {*} value The value to check.
  8235. * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
  8236. * @example
  8237. *
  8238. * _.isSymbol(Symbol.iterator);
  8239. * // => true
  8240. *
  8241. * _.isSymbol('abc');
  8242. * // => false
  8243. */
  8244. function isSymbol(value) {
  8245. return typeof value == 'symbol' ||
  8246. (isObjectLike(value) && baseGetTag(value) == symbolTag);
  8247. }
  8248. module.exports = isSymbol;
  8249. },{"./_baseGetTag":60,"./isObjectLike":154}],159:[function(require,module,exports){
  8250. var baseIsTypedArray = require('./_baseIsTypedArray'),
  8251. baseUnary = require('./_baseUnary'),
  8252. nodeUtil = require('./_nodeUtil');
  8253. /* Node.js helper references. */
  8254. var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
  8255. /**
  8256. * Checks if `value` is classified as a typed array.
  8257. *
  8258. * @static
  8259. * @memberOf _
  8260. * @since 3.0.0
  8261. * @category Lang
  8262. * @param {*} value The value to check.
  8263. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  8264. * @example
  8265. *
  8266. * _.isTypedArray(new Uint8Array);
  8267. * // => true
  8268. *
  8269. * _.isTypedArray([]);
  8270. * // => false
  8271. */
  8272. var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
  8273. module.exports = isTypedArray;
  8274. },{"./_baseIsTypedArray":65,"./_baseUnary":74,"./_nodeUtil":126}],160:[function(require,module,exports){
  8275. var arrayLikeKeys = require('./_arrayLikeKeys'),
  8276. baseKeys = require('./_baseKeys'),
  8277. isArrayLike = require('./isArrayLike');
  8278. /**
  8279. * Creates an array of the own enumerable property names of `object`.
  8280. *
  8281. * **Note:** Non-object values are coerced to objects. See the
  8282. * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  8283. * for more details.
  8284. *
  8285. * @static
  8286. * @since 0.1.0
  8287. * @memberOf _
  8288. * @category Object
  8289. * @param {Object} object The object to query.
  8290. * @returns {Array} Returns the array of property names.
  8291. * @example
  8292. *
  8293. * function Foo() {
  8294. * this.a = 1;
  8295. * this.b = 2;
  8296. * }
  8297. *
  8298. * Foo.prototype.c = 3;
  8299. *
  8300. * _.keys(new Foo);
  8301. * // => ['a', 'b'] (iteration order is not guaranteed)
  8302. *
  8303. * _.keys('hi');
  8304. * // => ['0', '1']
  8305. */
  8306. function keys(object) {
  8307. return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
  8308. }
  8309. module.exports = keys;
  8310. },{"./_arrayLikeKeys":47,"./_baseKeys":66,"./isArrayLike":147}],161:[function(require,module,exports){
  8311. var arrayLikeKeys = require('./_arrayLikeKeys'),
  8312. baseKeysIn = require('./_baseKeysIn'),
  8313. isArrayLike = require('./isArrayLike');
  8314. /**
  8315. * Creates an array of the own and inherited enumerable property names of `object`.
  8316. *
  8317. * **Note:** Non-object values are coerced to objects.
  8318. *
  8319. * @static
  8320. * @memberOf _
  8321. * @since 3.0.0
  8322. * @category Object
  8323. * @param {Object} object The object to query.
  8324. * @returns {Array} Returns the array of property names.
  8325. * @example
  8326. *
  8327. * function Foo() {
  8328. * this.a = 1;
  8329. * this.b = 2;
  8330. * }
  8331. *
  8332. * Foo.prototype.c = 3;
  8333. *
  8334. * _.keysIn(new Foo);
  8335. * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
  8336. */
  8337. function keysIn(object) {
  8338. return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object);
  8339. }
  8340. module.exports = keysIn;
  8341. },{"./_arrayLikeKeys":47,"./_baseKeysIn":67,"./isArrayLike":147}],162:[function(require,module,exports){
  8342. var baseMerge = require('./_baseMerge'),
  8343. createAssigner = require('./_createAssigner');
  8344. /**
  8345. * This method is like `_.merge` except that it accepts `customizer` which
  8346. * is invoked to produce the merged values of the destination and source
  8347. * properties. If `customizer` returns `undefined`, merging is handled by the
  8348. * method instead. The `customizer` is invoked with six arguments:
  8349. * (objValue, srcValue, key, object, source, stack).
  8350. *
  8351. * **Note:** This method mutates `object`.
  8352. *
  8353. * @static
  8354. * @memberOf _
  8355. * @since 4.0.0
  8356. * @category Object
  8357. * @param {Object} object The destination object.
  8358. * @param {...Object} sources The source objects.
  8359. * @param {Function} customizer The function to customize assigned values.
  8360. * @returns {Object} Returns `object`.
  8361. * @example
  8362. *
  8363. * function customizer(objValue, srcValue) {
  8364. * if (_.isArray(objValue)) {
  8365. * return objValue.concat(srcValue);
  8366. * }
  8367. * }
  8368. *
  8369. * var object = { 'a': [1], 'b': [2] };
  8370. * var other = { 'a': [3], 'b': [4] };
  8371. *
  8372. * _.mergeWith(object, other, customizer);
  8373. * // => { 'a': [1, 3], 'b': [2, 4] }
  8374. */
  8375. var mergeWith = createAssigner(function(object, source, srcIndex, customizer) {
  8376. baseMerge(object, source, srcIndex, customizer);
  8377. });
  8378. module.exports = mergeWith;
  8379. },{"./_baseMerge":68,"./_createAssigner":86}],163:[function(require,module,exports){
  8380. /**
  8381. * This method returns a new empty array.
  8382. *
  8383. * @static
  8384. * @memberOf _
  8385. * @since 4.13.0
  8386. * @category Util
  8387. * @returns {Array} Returns the new empty array.
  8388. * @example
  8389. *
  8390. * var arrays = _.times(2, _.stubArray);
  8391. *
  8392. * console.log(arrays);
  8393. * // => [[], []]
  8394. *
  8395. * console.log(arrays[0] === arrays[1]);
  8396. * // => false
  8397. */
  8398. function stubArray() {
  8399. return [];
  8400. }
  8401. module.exports = stubArray;
  8402. },{}],164:[function(require,module,exports){
  8403. /**
  8404. * This method returns `false`.
  8405. *
  8406. * @static
  8407. * @memberOf _
  8408. * @since 4.13.0
  8409. * @category Util
  8410. * @returns {boolean} Returns `false`.
  8411. * @example
  8412. *
  8413. * _.times(2, _.stubFalse);
  8414. * // => [false, false]
  8415. */
  8416. function stubFalse() {
  8417. return false;
  8418. }
  8419. module.exports = stubFalse;
  8420. },{}],165:[function(require,module,exports){
  8421. var copyObject = require('./_copyObject'),
  8422. keysIn = require('./keysIn');
  8423. /**
  8424. * Converts `value` to a plain object flattening inherited enumerable string
  8425. * keyed properties of `value` to own properties of the plain object.
  8426. *
  8427. * @static
  8428. * @memberOf _
  8429. * @since 3.0.0
  8430. * @category Lang
  8431. * @param {*} value The value to convert.
  8432. * @returns {Object} Returns the converted plain object.
  8433. * @example
  8434. *
  8435. * function Foo() {
  8436. * this.b = 2;
  8437. * }
  8438. *
  8439. * Foo.prototype.c = 3;
  8440. *
  8441. * _.assign({ 'a': 1 }, new Foo);
  8442. * // => { 'a': 1, 'b': 2 }
  8443. *
  8444. * _.assign({ 'a': 1 }, _.toPlainObject(new Foo));
  8445. * // => { 'a': 1, 'b': 2, 'c': 3 }
  8446. */
  8447. function toPlainObject(value) {
  8448. return copyObject(value, keysIn(value));
  8449. }
  8450. module.exports = toPlainObject;
  8451. },{"./_copyObject":82,"./keysIn":161}],166:[function(require,module,exports){
  8452. var baseToString = require('./_baseToString');
  8453. /**
  8454. * Converts `value` to a string. An empty string is returned for `null`
  8455. * and `undefined` values. The sign of `-0` is preserved.
  8456. *
  8457. * @static
  8458. * @memberOf _
  8459. * @since 4.0.0
  8460. * @category Lang
  8461. * @param {*} value The value to convert.
  8462. * @returns {string} Returns the converted string.
  8463. * @example
  8464. *
  8465. * _.toString(null);
  8466. * // => ''
  8467. *
  8468. * _.toString(-0);
  8469. * // => '-0'
  8470. *
  8471. * _.toString([1, 2, 3]);
  8472. * // => '1,2,3'
  8473. */
  8474. function toString(value) {
  8475. return value == null ? '' : baseToString(value);
  8476. }
  8477. module.exports = toString;
  8478. },{"./_baseToString":73}],167:[function(require,module,exports){
  8479. /**
  8480. * Srcset Parser
  8481. *
  8482. * By Alex Bell | MIT License
  8483. *
  8484. * JS Parser for the string value that appears in markup <img srcset="here">
  8485. *
  8486. * @returns Array [{url: _, d: _, w: _, h:_}, ...]
  8487. *
  8488. * Based super duper closely on the reference algorithm at:
  8489. * https://html.spec.whatwg.org/multipage/embedded-content.html#parse-a-srcset-attribute
  8490. *
  8491. * Most comments are copied in directly from the spec
  8492. * (except for comments in parens).
  8493. */
  8494. (function (root, factory) {
  8495. if (typeof define === 'function' && define.amd) {
  8496. // AMD. Register as an anonymous module.
  8497. define([], factory);
  8498. } else if (typeof module === 'object' && module.exports) {
  8499. // Node. Does not work with strict CommonJS, but
  8500. // only CommonJS-like environments that support module.exports,
  8501. // like Node.
  8502. module.exports = factory();
  8503. } else {
  8504. // Browser globals (root is window)
  8505. root.parseSrcset = factory();
  8506. }
  8507. }(this, function () {
  8508. // 1. Let input be the value passed to this algorithm.
  8509. return function (input) {
  8510. // UTILITY FUNCTIONS
  8511. // Manual is faster than RegEx
  8512. // http://bjorn.tipling.com/state-and-regular-expressions-in-javascript
  8513. // http://jsperf.com/whitespace-character/5
  8514. function isSpace(c) {
  8515. return (c === "\u0020" || // space
  8516. c === "\u0009" || // horizontal tab
  8517. c === "\u000A" || // new line
  8518. c === "\u000C" || // form feed
  8519. c === "\u000D"); // carriage return
  8520. }
  8521. function collectCharacters(regEx) {
  8522. var chars,
  8523. match = regEx.exec(input.substring(pos));
  8524. if (match) {
  8525. chars = match[ 0 ];
  8526. pos += chars.length;
  8527. return chars;
  8528. }
  8529. }
  8530. var inputLength = input.length,
  8531. // (Don't use \s, to avoid matching non-breaking space)
  8532. regexLeadingSpaces = /^[ \t\n\r\u000c]+/,
  8533. regexLeadingCommasOrSpaces = /^[, \t\n\r\u000c]+/,
  8534. regexLeadingNotSpaces = /^[^ \t\n\r\u000c]+/,
  8535. regexTrailingCommas = /[,]+$/,
  8536. regexNonNegativeInteger = /^\d+$/,
  8537. // ( Positive or negative or unsigned integers or decimals, without or without exponents.
  8538. // Must include at least one digit.
  8539. // According to spec tests any decimal point must be followed by a digit.
  8540. // No leading plus sign is allowed.)
  8541. // https://html.spec.whatwg.org/multipage/infrastructure.html#valid-floating-point-number
  8542. regexFloatingPoint = /^-?(?:[0-9]+|[0-9]*\.[0-9]+)(?:[eE][+-]?[0-9]+)?$/,
  8543. url,
  8544. descriptors,
  8545. currentDescriptor,
  8546. state,
  8547. c,
  8548. // 2. Let position be a pointer into input, initially pointing at the start
  8549. // of the string.
  8550. pos = 0,
  8551. // 3. Let candidates be an initially empty source set.
  8552. candidates = [];
  8553. // 4. Splitting loop: Collect a sequence of characters that are space
  8554. // characters or U+002C COMMA characters. If any U+002C COMMA characters
  8555. // were collected, that is a parse error.
  8556. while (true) {
  8557. collectCharacters(regexLeadingCommasOrSpaces);
  8558. // 5. If position is past the end of input, return candidates and abort these steps.
  8559. if (pos >= inputLength) {
  8560. return candidates; // (we're done, this is the sole return path)
  8561. }
  8562. // 6. Collect a sequence of characters that are not space characters,
  8563. // and let that be url.
  8564. url = collectCharacters(regexLeadingNotSpaces);
  8565. // 7. Let descriptors be a new empty list.
  8566. descriptors = [];
  8567. // 8. If url ends with a U+002C COMMA character (,), follow these substeps:
  8568. // (1). Remove all trailing U+002C COMMA characters from url. If this removed
  8569. // more than one character, that is a parse error.
  8570. if (url.slice(-1) === ",") {
  8571. url = url.replace(regexTrailingCommas, "");
  8572. // (Jump ahead to step 9 to skip tokenization and just push the candidate).
  8573. parseDescriptors();
  8574. // Otherwise, follow these substeps:
  8575. } else {
  8576. tokenize();
  8577. } // (close else of step 8)
  8578. // 16. Return to the step labeled splitting loop.
  8579. } // (Close of big while loop.)
  8580. /**
  8581. * Tokenizes descriptor properties prior to parsing
  8582. * Returns undefined.
  8583. */
  8584. function tokenize() {
  8585. // 8.1. Descriptor tokeniser: Skip whitespace
  8586. collectCharacters(regexLeadingSpaces);
  8587. // 8.2. Let current descriptor be the empty string.
  8588. currentDescriptor = "";
  8589. // 8.3. Let state be in descriptor.
  8590. state = "in descriptor";
  8591. while (true) {
  8592. // 8.4. Let c be the character at position.
  8593. c = input.charAt(pos);
  8594. // Do the following depending on the value of state.
  8595. // For the purpose of this step, "EOF" is a special character representing
  8596. // that position is past the end of input.
  8597. // In descriptor
  8598. if (state === "in descriptor") {
  8599. // Do the following, depending on the value of c:
  8600. // Space character
  8601. // If current descriptor is not empty, append current descriptor to
  8602. // descriptors and let current descriptor be the empty string.
  8603. // Set state to after descriptor.
  8604. if (isSpace(c)) {
  8605. if (currentDescriptor) {
  8606. descriptors.push(currentDescriptor);
  8607. currentDescriptor = "";
  8608. state = "after descriptor";
  8609. }
  8610. // U+002C COMMA (,)
  8611. // Advance position to the next character in input. If current descriptor
  8612. // is not empty, append current descriptor to descriptors. Jump to the step
  8613. // labeled descriptor parser.
  8614. } else if (c === ",") {
  8615. pos += 1;
  8616. if (currentDescriptor) {
  8617. descriptors.push(currentDescriptor);
  8618. }
  8619. parseDescriptors();
  8620. return;
  8621. // U+0028 LEFT PARENTHESIS (()
  8622. // Append c to current descriptor. Set state to in parens.
  8623. } else if (c === "\u0028") {
  8624. currentDescriptor = currentDescriptor + c;
  8625. state = "in parens";
  8626. // EOF
  8627. // If current descriptor is not empty, append current descriptor to
  8628. // descriptors. Jump to the step labeled descriptor parser.
  8629. } else if (c === "") {
  8630. if (currentDescriptor) {
  8631. descriptors.push(currentDescriptor);
  8632. }
  8633. parseDescriptors();
  8634. return;
  8635. // Anything else
  8636. // Append c to current descriptor.
  8637. } else {
  8638. currentDescriptor = currentDescriptor + c;
  8639. }
  8640. // (end "in descriptor"
  8641. // In parens
  8642. } else if (state === "in parens") {
  8643. // U+0029 RIGHT PARENTHESIS ())
  8644. // Append c to current descriptor. Set state to in descriptor.
  8645. if (c === ")") {
  8646. currentDescriptor = currentDescriptor + c;
  8647. state = "in descriptor";
  8648. // EOF
  8649. // Append current descriptor to descriptors. Jump to the step labeled
  8650. // descriptor parser.
  8651. } else if (c === "") {
  8652. descriptors.push(currentDescriptor);
  8653. parseDescriptors();
  8654. return;
  8655. // Anything else
  8656. // Append c to current descriptor.
  8657. } else {
  8658. currentDescriptor = currentDescriptor + c;
  8659. }
  8660. // After descriptor
  8661. } else if (state === "after descriptor") {
  8662. // Do the following, depending on the value of c:
  8663. // Space character: Stay in this state.
  8664. if (isSpace(c)) {
  8665. // EOF: Jump to the step labeled descriptor parser.
  8666. } else if (c === "") {
  8667. parseDescriptors();
  8668. return;
  8669. // Anything else
  8670. // Set state to in descriptor. Set position to the previous character in input.
  8671. } else {
  8672. state = "in descriptor";
  8673. pos -= 1;
  8674. }
  8675. }
  8676. // Advance position to the next character in input.
  8677. pos += 1;
  8678. // Repeat this step.
  8679. } // (close while true loop)
  8680. }
  8681. /**
  8682. * Adds descriptor properties to a candidate, pushes to the candidates array
  8683. * @return undefined
  8684. */
  8685. // Declared outside of the while loop so that it's only created once.
  8686. function parseDescriptors() {
  8687. // 9. Descriptor parser: Let error be no.
  8688. var pError = false,
  8689. // 10. Let width be absent.
  8690. // 11. Let density be absent.
  8691. // 12. Let future-compat-h be absent. (We're implementing it now as h)
  8692. w, d, h, i,
  8693. candidate = {},
  8694. desc, lastChar, value, intVal, floatVal;
  8695. // 13. For each descriptor in descriptors, run the appropriate set of steps
  8696. // from the following list:
  8697. for (i = 0 ; i < descriptors.length; i++) {
  8698. desc = descriptors[ i ];
  8699. lastChar = desc[ desc.length - 1 ];
  8700. value = desc.substring(0, desc.length - 1);
  8701. intVal = parseInt(value, 10);
  8702. floatVal = parseFloat(value);
  8703. // If the descriptor consists of a valid non-negative integer followed by
  8704. // a U+0077 LATIN SMALL LETTER W character
  8705. if (regexNonNegativeInteger.test(value) && (lastChar === "w")) {
  8706. // If width and density are not both absent, then let error be yes.
  8707. if (w || d) {pError = true;}
  8708. // Apply the rules for parsing non-negative integers to the descriptor.
  8709. // If the result is zero, let error be yes.
  8710. // Otherwise, let width be the result.
  8711. if (intVal === 0) {pError = true;} else {w = intVal;}
  8712. // If the descriptor consists of a valid floating-point number followed by
  8713. // a U+0078 LATIN SMALL LETTER X character
  8714. } else if (regexFloatingPoint.test(value) && (lastChar === "x")) {
  8715. // If width, density and future-compat-h are not all absent, then let error
  8716. // be yes.
  8717. if (w || d || h) {pError = true;}
  8718. // Apply the rules for parsing floating-point number values to the descriptor.
  8719. // If the result is less than zero, let error be yes. Otherwise, let density
  8720. // be the result.
  8721. if (floatVal < 0) {pError = true;} else {d = floatVal;}
  8722. // If the descriptor consists of a valid non-negative integer followed by
  8723. // a U+0068 LATIN SMALL LETTER H character
  8724. } else if (regexNonNegativeInteger.test(value) && (lastChar === "h")) {
  8725. // If height and density are not both absent, then let error be yes.
  8726. if (h || d) {pError = true;}
  8727. // Apply the rules for parsing non-negative integers to the descriptor.
  8728. // If the result is zero, let error be yes. Otherwise, let future-compat-h
  8729. // be the result.
  8730. if (intVal === 0) {pError = true;} else {h = intVal;}
  8731. // Anything else, Let error be yes.
  8732. } else {pError = true;}
  8733. } // (close step 13 for loop)
  8734. // 15. If error is still no, then append a new image source to candidates whose
  8735. // URL is url, associated with a width width if not absent and a pixel
  8736. // density density if not absent. Otherwise, there is a parse error.
  8737. if (!pError) {
  8738. candidate.url = url;
  8739. if (w) { candidate.w = w;}
  8740. if (d) { candidate.d = d;}
  8741. if (h) { candidate.h = h;}
  8742. candidates.push(candidate);
  8743. } else if (console && console.log) {
  8744. console.log("Invalid srcset descriptor found in '" +
  8745. input + "' at '" + desc + "'.");
  8746. }
  8747. } // (close parseDescriptors fn)
  8748. }
  8749. }));
  8750. },{}],168:[function(require,module,exports){
  8751. (function (process){
  8752. // .dirname, .basename, and .extname methods are extracted from Node.js v8.11.1,
  8753. // backported and transplited with Babel, with backwards-compat fixes
  8754. // Copyright Joyent, Inc. and other Node contributors.
  8755. //
  8756. // Permission is hereby granted, free of charge, to any person obtaining a
  8757. // copy of this software and associated documentation files (the
  8758. // "Software"), to deal in the Software without restriction, including
  8759. // without limitation the rights to use, copy, modify, merge, publish,
  8760. // distribute, sublicense, and/or sell copies of the Software, and to permit
  8761. // persons to whom the Software is furnished to do so, subject to the
  8762. // following conditions:
  8763. //
  8764. // The above copyright notice and this permission notice shall be included
  8765. // in all copies or substantial portions of the Software.
  8766. //
  8767. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  8768. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  8769. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  8770. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  8771. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  8772. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  8773. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  8774. // resolves . and .. elements in a path array with directory names there
  8775. // must be no slashes, empty elements, or device names (c:\) in the array
  8776. // (so also no leading and trailing slashes - it does not distinguish
  8777. // relative and absolute paths)
  8778. function normalizeArray(parts, allowAboveRoot) {
  8779. // if the path tries to go above the root, `up` ends up > 0
  8780. var up = 0;
  8781. for (var i = parts.length - 1; i >= 0; i--) {
  8782. var last = parts[i];
  8783. if (last === '.') {
  8784. parts.splice(i, 1);
  8785. } else if (last === '..') {
  8786. parts.splice(i, 1);
  8787. up++;
  8788. } else if (up) {
  8789. parts.splice(i, 1);
  8790. up--;
  8791. }
  8792. }
  8793. // if the path is allowed to go above the root, restore leading ..s
  8794. if (allowAboveRoot) {
  8795. for (; up--; up) {
  8796. parts.unshift('..');
  8797. }
  8798. }
  8799. return parts;
  8800. }
  8801. // path.resolve([from ...], to)
  8802. // posix version
  8803. exports.resolve = function() {
  8804. var resolvedPath = '',
  8805. resolvedAbsolute = false;
  8806. for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
  8807. var path = (i >= 0) ? arguments[i] : process.cwd();
  8808. // Skip empty and invalid entries
  8809. if (typeof path !== 'string') {
  8810. throw new TypeError('Arguments to path.resolve must be strings');
  8811. } else if (!path) {
  8812. continue;
  8813. }
  8814. resolvedPath = path + '/' + resolvedPath;
  8815. resolvedAbsolute = path.charAt(0) === '/';
  8816. }
  8817. // At this point the path should be resolved to a full absolute path, but
  8818. // handle relative paths to be safe (might happen when process.cwd() fails)
  8819. // Normalize the path
  8820. resolvedPath = normalizeArray(filter(resolvedPath.split('/'), function(p) {
  8821. return !!p;
  8822. }), !resolvedAbsolute).join('/');
  8823. return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';
  8824. };
  8825. // path.normalize(path)
  8826. // posix version
  8827. exports.normalize = function(path) {
  8828. var isAbsolute = exports.isAbsolute(path),
  8829. trailingSlash = substr(path, -1) === '/';
  8830. // Normalize the path
  8831. path = normalizeArray(filter(path.split('/'), function(p) {
  8832. return !!p;
  8833. }), !isAbsolute).join('/');
  8834. if (!path && !isAbsolute) {
  8835. path = '.';
  8836. }
  8837. if (path && trailingSlash) {
  8838. path += '/';
  8839. }
  8840. return (isAbsolute ? '/' : '') + path;
  8841. };
  8842. // posix version
  8843. exports.isAbsolute = function(path) {
  8844. return path.charAt(0) === '/';
  8845. };
  8846. // posix version
  8847. exports.join = function() {
  8848. var paths = Array.prototype.slice.call(arguments, 0);
  8849. return exports.normalize(filter(paths, function(p, index) {
  8850. if (typeof p !== 'string') {
  8851. throw new TypeError('Arguments to path.join must be strings');
  8852. }
  8853. return p;
  8854. }).join('/'));
  8855. };
  8856. // path.relative(from, to)
  8857. // posix version
  8858. exports.relative = function(from, to) {
  8859. from = exports.resolve(from).substr(1);
  8860. to = exports.resolve(to).substr(1);
  8861. function trim(arr) {
  8862. var start = 0;
  8863. for (; start < arr.length; start++) {
  8864. if (arr[start] !== '') break;
  8865. }
  8866. var end = arr.length - 1;
  8867. for (; end >= 0; end--) {
  8868. if (arr[end] !== '') break;
  8869. }
  8870. if (start > end) return [];
  8871. return arr.slice(start, end - start + 1);
  8872. }
  8873. var fromParts = trim(from.split('/'));
  8874. var toParts = trim(to.split('/'));
  8875. var length = Math.min(fromParts.length, toParts.length);
  8876. var samePartsLength = length;
  8877. for (var i = 0; i < length; i++) {
  8878. if (fromParts[i] !== toParts[i]) {
  8879. samePartsLength = i;
  8880. break;
  8881. }
  8882. }
  8883. var outputParts = [];
  8884. for (var i = samePartsLength; i < fromParts.length; i++) {
  8885. outputParts.push('..');
  8886. }
  8887. outputParts = outputParts.concat(toParts.slice(samePartsLength));
  8888. return outputParts.join('/');
  8889. };
  8890. exports.sep = '/';
  8891. exports.delimiter = ':';
  8892. exports.dirname = function (path) {
  8893. if (typeof path !== 'string') path = path + '';
  8894. if (path.length === 0) return '.';
  8895. var code = path.charCodeAt(0);
  8896. var hasRoot = code === 47 /*/*/;
  8897. var end = -1;
  8898. var matchedSlash = true;
  8899. for (var i = path.length - 1; i >= 1; --i) {
  8900. code = path.charCodeAt(i);
  8901. if (code === 47 /*/*/) {
  8902. if (!matchedSlash) {
  8903. end = i;
  8904. break;
  8905. }
  8906. } else {
  8907. // We saw the first non-path separator
  8908. matchedSlash = false;
  8909. }
  8910. }
  8911. if (end === -1) return hasRoot ? '/' : '.';
  8912. if (hasRoot && end === 1) {
  8913. // return '//';
  8914. // Backwards-compat fix:
  8915. return '/';
  8916. }
  8917. return path.slice(0, end);
  8918. };
  8919. function basename(path) {
  8920. if (typeof path !== 'string') path = path + '';
  8921. var start = 0;
  8922. var end = -1;
  8923. var matchedSlash = true;
  8924. var i;
  8925. for (i = path.length - 1; i >= 0; --i) {
  8926. if (path.charCodeAt(i) === 47 /*/*/) {
  8927. // If we reached a path separator that was not part of a set of path
  8928. // separators at the end of the string, stop now
  8929. if (!matchedSlash) {
  8930. start = i + 1;
  8931. break;
  8932. }
  8933. } else if (end === -1) {
  8934. // We saw the first non-path separator, mark this as the end of our
  8935. // path component
  8936. matchedSlash = false;
  8937. end = i + 1;
  8938. }
  8939. }
  8940. if (end === -1) return '';
  8941. return path.slice(start, end);
  8942. }
  8943. // Uses a mixed approach for backwards-compatibility, as ext behavior changed
  8944. // in new Node.js versions, so only basename() above is backported here
  8945. exports.basename = function (path, ext) {
  8946. var f = basename(path);
  8947. if (ext && f.substr(-1 * ext.length) === ext) {
  8948. f = f.substr(0, f.length - ext.length);
  8949. }
  8950. return f;
  8951. };
  8952. exports.extname = function (path) {
  8953. if (typeof path !== 'string') path = path + '';
  8954. var startDot = -1;
  8955. var startPart = 0;
  8956. var end = -1;
  8957. var matchedSlash = true;
  8958. // Track the state of characters (if any) we see before our first dot and
  8959. // after any path separator we find
  8960. var preDotState = 0;
  8961. for (var i = path.length - 1; i >= 0; --i) {
  8962. var code = path.charCodeAt(i);
  8963. if (code === 47 /*/*/) {
  8964. // If we reached a path separator that was not part of a set of path
  8965. // separators at the end of the string, stop now
  8966. if (!matchedSlash) {
  8967. startPart = i + 1;
  8968. break;
  8969. }
  8970. continue;
  8971. }
  8972. if (end === -1) {
  8973. // We saw the first non-path separator, mark this as the end of our
  8974. // extension
  8975. matchedSlash = false;
  8976. end = i + 1;
  8977. }
  8978. if (code === 46 /*.*/) {
  8979. // If this is our first dot, mark it as the start of our extension
  8980. if (startDot === -1)
  8981. startDot = i;
  8982. else if (preDotState !== 1)
  8983. preDotState = 1;
  8984. } else if (startDot !== -1) {
  8985. // We saw a non-dot and non-path separator before our dot, so we should
  8986. // have a good chance at having a non-empty extension
  8987. preDotState = -1;
  8988. }
  8989. }
  8990. if (startDot === -1 || end === -1 ||
  8991. // We saw a non-dot character immediately before the dot
  8992. preDotState === 0 ||
  8993. // The (right-most) trimmed path component is exactly '..'
  8994. preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {
  8995. return '';
  8996. }
  8997. return path.slice(startDot, end);
  8998. };
  8999. function filter (xs, f) {
  9000. if (xs.filter) return xs.filter(f);
  9001. var res = [];
  9002. for (var i = 0; i < xs.length; i++) {
  9003. if (f(xs[i], i, xs)) res.push(xs[i]);
  9004. }
  9005. return res;
  9006. }
  9007. // String.prototype.substr - negative index don't work in IE8
  9008. var substr = 'ab'.substr(-1) === 'b'
  9009. ? function (str, start, len) { return str.substr(start, len) }
  9010. : function (str, start, len) {
  9011. if (start < 0) start = str.length + start;
  9012. return str.substr(start, len);
  9013. }
  9014. ;
  9015. }).call(this,require('_process'))
  9016. },{"_process":193}],169:[function(require,module,exports){
  9017. "use strict";
  9018. exports.__esModule = true;
  9019. exports.default = void 0;
  9020. var _container = _interopRequireDefault(require("./container"));
  9021. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  9022. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  9023. /**
  9024. * Represents an at-rule.
  9025. *
  9026. * If it’s followed in the CSS by a {} block, this node will have
  9027. * a nodes property representing its children.
  9028. *
  9029. * @extends Container
  9030. *
  9031. * @example
  9032. * const root = postcss.parse('@charset "UTF-8"; @media print {}')
  9033. *
  9034. * const charset = root.first
  9035. * charset.type //=> 'atrule'
  9036. * charset.nodes //=> undefined
  9037. *
  9038. * const media = root.last
  9039. * media.nodes //=> []
  9040. */
  9041. var AtRule = /*#__PURE__*/function (_Container) {
  9042. _inheritsLoose(AtRule, _Container);
  9043. function AtRule(defaults) {
  9044. var _this;
  9045. _this = _Container.call(this, defaults) || this;
  9046. _this.type = 'atrule';
  9047. return _this;
  9048. }
  9049. var _proto = AtRule.prototype;
  9050. _proto.append = function append() {
  9051. var _Container$prototype$;
  9052. if (!this.nodes) this.nodes = [];
  9053. for (var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++) {
  9054. children[_key] = arguments[_key];
  9055. }
  9056. return (_Container$prototype$ = _Container.prototype.append).call.apply(_Container$prototype$, [this].concat(children));
  9057. };
  9058. _proto.prepend = function prepend() {
  9059. var _Container$prototype$2;
  9060. if (!this.nodes) this.nodes = [];
  9061. for (var _len2 = arguments.length, children = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
  9062. children[_key2] = arguments[_key2];
  9063. }
  9064. return (_Container$prototype$2 = _Container.prototype.prepend).call.apply(_Container$prototype$2, [this].concat(children));
  9065. }
  9066. /**
  9067. * @memberof AtRule#
  9068. * @member {string} name The at-rule’s name immediately follows the `@`.
  9069. *
  9070. * @example
  9071. * const root = postcss.parse('@media print {}')
  9072. * media.name //=> 'media'
  9073. * const media = root.first
  9074. */
  9075. /**
  9076. * @memberof AtRule#
  9077. * @member {string} params The at-rule’s parameters, the values
  9078. * that follow the at-rule’s name but precede
  9079. * any {} block.
  9080. *
  9081. * @example
  9082. * const root = postcss.parse('@media print, screen {}')
  9083. * const media = root.first
  9084. * media.params //=> 'print, screen'
  9085. */
  9086. /**
  9087. * @memberof AtRule#
  9088. * @member {object} raws Information to generate byte-to-byte equal
  9089. * node string as it was in the origin input.
  9090. *
  9091. * Every parser saves its own properties,
  9092. * but the default CSS parser uses:
  9093. *
  9094. * * `before`: the space symbols before the node. It also stores `*`
  9095. * and `_` symbols before the declaration (IE hack).
  9096. * * `after`: the space symbols after the last child of the node
  9097. * to the end of the node.
  9098. * * `between`: the symbols between the property and value
  9099. * for declarations, selector and `{` for rules, or last parameter
  9100. * and `{` for at-rules.
  9101. * * `semicolon`: contains true if the last child has
  9102. * an (optional) semicolon.
  9103. * * `afterName`: the space between the at-rule name and its parameters.
  9104. *
  9105. * PostCSS cleans at-rule parameters from comments and extra spaces,
  9106. * but it stores origin content in raws properties.
  9107. * As such, if you don’t change a declaration’s value,
  9108. * PostCSS will use the raw value with comments.
  9109. *
  9110. * @example
  9111. * const root = postcss.parse(' @media\nprint {\n}')
  9112. * root.first.first.raws //=> { before: ' ',
  9113. * // between: ' ',
  9114. * // afterName: '\n',
  9115. * // after: '\n' }
  9116. */
  9117. ;
  9118. return AtRule;
  9119. }(_container.default);
  9120. var _default = AtRule;
  9121. exports.default = _default;
  9122. module.exports = exports.default;
  9123. },{"./container":171}],170:[function(require,module,exports){
  9124. "use strict";
  9125. exports.__esModule = true;
  9126. exports.default = void 0;
  9127. var _node = _interopRequireDefault(require("./node"));
  9128. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  9129. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  9130. /**
  9131. * Represents a comment between declarations or statements (rule and at-rules).
  9132. *
  9133. * Comments inside selectors, at-rule parameters, or declaration values
  9134. * will be stored in the `raws` properties explained above.
  9135. *
  9136. * @extends Node
  9137. */
  9138. var Comment = /*#__PURE__*/function (_Node) {
  9139. _inheritsLoose(Comment, _Node);
  9140. function Comment(defaults) {
  9141. var _this;
  9142. _this = _Node.call(this, defaults) || this;
  9143. _this.type = 'comment';
  9144. return _this;
  9145. }
  9146. /**
  9147. * @memberof Comment#
  9148. * @member {string} text The comment’s text.
  9149. */
  9150. /**
  9151. * @memberof Comment#
  9152. * @member {object} raws Information to generate byte-to-byte equal
  9153. * node string as it was in the origin input.
  9154. *
  9155. * Every parser saves its own properties,
  9156. * but the default CSS parser uses:
  9157. *
  9158. * * `before`: the space symbols before the node.
  9159. * * `left`: the space symbols between `/*` and the comment’s text.
  9160. * * `right`: the space symbols between the comment’s text.
  9161. */
  9162. return Comment;
  9163. }(_node.default);
  9164. var _default = Comment;
  9165. exports.default = _default;
  9166. module.exports = exports.default;
  9167. },{"./node":178}],171:[function(require,module,exports){
  9168. "use strict";
  9169. exports.__esModule = true;
  9170. exports.default = void 0;
  9171. var _declaration = _interopRequireDefault(require("./declaration"));
  9172. var _comment = _interopRequireDefault(require("./comment"));
  9173. var _node = _interopRequireDefault(require("./node"));
  9174. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  9175. function _createForOfIteratorHelperLoose(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } it = o[Symbol.iterator](); return it.next.bind(it); }
  9176. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  9177. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  9178. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  9179. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  9180. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  9181. function cleanSource(nodes) {
  9182. return nodes.map(function (i) {
  9183. if (i.nodes) i.nodes = cleanSource(i.nodes);
  9184. delete i.source;
  9185. return i;
  9186. });
  9187. }
  9188. /**
  9189. * The {@link Root}, {@link AtRule}, and {@link Rule} container nodes
  9190. * inherit some common methods to help work with their children.
  9191. *
  9192. * Note that all containers can store any content. If you write a rule inside
  9193. * a rule, PostCSS will parse it.
  9194. *
  9195. * @extends Node
  9196. * @abstract
  9197. */
  9198. var Container = /*#__PURE__*/function (_Node) {
  9199. _inheritsLoose(Container, _Node);
  9200. function Container() {
  9201. return _Node.apply(this, arguments) || this;
  9202. }
  9203. var _proto = Container.prototype;
  9204. _proto.push = function push(child) {
  9205. child.parent = this;
  9206. this.nodes.push(child);
  9207. return this;
  9208. }
  9209. /**
  9210. * Iterates through the container’s immediate children,
  9211. * calling `callback` for each child.
  9212. *
  9213. * Returning `false` in the callback will break iteration.
  9214. *
  9215. * This method only iterates through the container’s immediate children.
  9216. * If you need to recursively iterate through all the container’s descendant
  9217. * nodes, use {@link Container#walk}.
  9218. *
  9219. * Unlike the for `{}`-cycle or `Array#forEach` this iterator is safe
  9220. * if you are mutating the array of child nodes during iteration.
  9221. * PostCSS will adjust the current index to match the mutations.
  9222. *
  9223. * @param {childIterator} callback Iterator receives each node and index.
  9224. *
  9225. * @return {false|undefined} Returns `false` if iteration was broke.
  9226. *
  9227. * @example
  9228. * const root = postcss.parse('a { color: black; z-index: 1 }')
  9229. * const rule = root.first
  9230. *
  9231. * for (const decl of rule.nodes) {
  9232. * decl.cloneBefore({ prop: '-webkit-' + decl.prop })
  9233. * // Cycle will be infinite, because cloneBefore moves the current node
  9234. * // to the next index
  9235. * }
  9236. *
  9237. * rule.each(decl => {
  9238. * decl.cloneBefore({ prop: '-webkit-' + decl.prop })
  9239. * // Will be executed only for color and z-index
  9240. * })
  9241. */
  9242. ;
  9243. _proto.each = function each(callback) {
  9244. if (!this.lastEach) this.lastEach = 0;
  9245. if (!this.indexes) this.indexes = {};
  9246. this.lastEach += 1;
  9247. var id = this.lastEach;
  9248. this.indexes[id] = 0;
  9249. if (!this.nodes) return undefined;
  9250. var index, result;
  9251. while (this.indexes[id] < this.nodes.length) {
  9252. index = this.indexes[id];
  9253. result = callback(this.nodes[index], index);
  9254. if (result === false) break;
  9255. this.indexes[id] += 1;
  9256. }
  9257. delete this.indexes[id];
  9258. return result;
  9259. }
  9260. /**
  9261. * Traverses the container’s descendant nodes, calling callback
  9262. * for each node.
  9263. *
  9264. * Like container.each(), this method is safe to use
  9265. * if you are mutating arrays during iteration.
  9266. *
  9267. * If you only need to iterate through the container’s immediate children,
  9268. * use {@link Container#each}.
  9269. *
  9270. * @param {childIterator} callback Iterator receives each node and index.
  9271. *
  9272. * @return {false|undefined} Returns `false` if iteration was broke.
  9273. *
  9274. * @example
  9275. * root.walk(node => {
  9276. * // Traverses all descendant nodes.
  9277. * })
  9278. */
  9279. ;
  9280. _proto.walk = function walk(callback) {
  9281. return this.each(function (child, i) {
  9282. var result;
  9283. try {
  9284. result = callback(child, i);
  9285. } catch (e) {
  9286. e.postcssNode = child;
  9287. if (e.stack && child.source && /\n\s{4}at /.test(e.stack)) {
  9288. var s = child.source;
  9289. e.stack = e.stack.replace(/\n\s{4}at /, "$&" + s.input.from + ":" + s.start.line + ":" + s.start.column + "$&");
  9290. }
  9291. throw e;
  9292. }
  9293. if (result !== false && child.walk) {
  9294. result = child.walk(callback);
  9295. }
  9296. return result;
  9297. });
  9298. }
  9299. /**
  9300. * Traverses the container’s descendant nodes, calling callback
  9301. * for each declaration node.
  9302. *
  9303. * If you pass a filter, iteration will only happen over declarations
  9304. * with matching properties.
  9305. *
  9306. * Like {@link Container#each}, this method is safe
  9307. * to use if you are mutating arrays during iteration.
  9308. *
  9309. * @param {string|RegExp} [prop] String or regular expression
  9310. * to filter declarations by property name.
  9311. * @param {childIterator} callback Iterator receives each node and index.
  9312. *
  9313. * @return {false|undefined} Returns `false` if iteration was broke.
  9314. *
  9315. * @example
  9316. * root.walkDecls(decl => {
  9317. * checkPropertySupport(decl.prop)
  9318. * })
  9319. *
  9320. * root.walkDecls('border-radius', decl => {
  9321. * decl.remove()
  9322. * })
  9323. *
  9324. * root.walkDecls(/^background/, decl => {
  9325. * decl.value = takeFirstColorFromGradient(decl.value)
  9326. * })
  9327. */
  9328. ;
  9329. _proto.walkDecls = function walkDecls(prop, callback) {
  9330. if (!callback) {
  9331. callback = prop;
  9332. return this.walk(function (child, i) {
  9333. if (child.type === 'decl') {
  9334. return callback(child, i);
  9335. }
  9336. });
  9337. }
  9338. if (prop instanceof RegExp) {
  9339. return this.walk(function (child, i) {
  9340. if (child.type === 'decl' && prop.test(child.prop)) {
  9341. return callback(child, i);
  9342. }
  9343. });
  9344. }
  9345. return this.walk(function (child, i) {
  9346. if (child.type === 'decl' && child.prop === prop) {
  9347. return callback(child, i);
  9348. }
  9349. });
  9350. }
  9351. /**
  9352. * Traverses the container’s descendant nodes, calling callback
  9353. * for each rule node.
  9354. *
  9355. * If you pass a filter, iteration will only happen over rules
  9356. * with matching selectors.
  9357. *
  9358. * Like {@link Container#each}, this method is safe
  9359. * to use if you are mutating arrays during iteration.
  9360. *
  9361. * @param {string|RegExp} [selector] String or regular expression
  9362. * to filter rules by selector.
  9363. * @param {childIterator} callback Iterator receives each node and index.
  9364. *
  9365. * @return {false|undefined} returns `false` if iteration was broke.
  9366. *
  9367. * @example
  9368. * const selectors = []
  9369. * root.walkRules(rule => {
  9370. * selectors.push(rule.selector)
  9371. * })
  9372. * console.log(`Your CSS uses ${ selectors.length } selectors`)
  9373. */
  9374. ;
  9375. _proto.walkRules = function walkRules(selector, callback) {
  9376. if (!callback) {
  9377. callback = selector;
  9378. return this.walk(function (child, i) {
  9379. if (child.type === 'rule') {
  9380. return callback(child, i);
  9381. }
  9382. });
  9383. }
  9384. if (selector instanceof RegExp) {
  9385. return this.walk(function (child, i) {
  9386. if (child.type === 'rule' && selector.test(child.selector)) {
  9387. return callback(child, i);
  9388. }
  9389. });
  9390. }
  9391. return this.walk(function (child, i) {
  9392. if (child.type === 'rule' && child.selector === selector) {
  9393. return callback(child, i);
  9394. }
  9395. });
  9396. }
  9397. /**
  9398. * Traverses the container’s descendant nodes, calling callback
  9399. * for each at-rule node.
  9400. *
  9401. * If you pass a filter, iteration will only happen over at-rules
  9402. * that have matching names.
  9403. *
  9404. * Like {@link Container#each}, this method is safe
  9405. * to use if you are mutating arrays during iteration.
  9406. *
  9407. * @param {string|RegExp} [name] String or regular expression
  9408. * to filter at-rules by name.
  9409. * @param {childIterator} callback Iterator receives each node and index.
  9410. *
  9411. * @return {false|undefined} Returns `false` if iteration was broke.
  9412. *
  9413. * @example
  9414. * root.walkAtRules(rule => {
  9415. * if (isOld(rule.name)) rule.remove()
  9416. * })
  9417. *
  9418. * let first = false
  9419. * root.walkAtRules('charset', rule => {
  9420. * if (!first) {
  9421. * first = true
  9422. * } else {
  9423. * rule.remove()
  9424. * }
  9425. * })
  9426. */
  9427. ;
  9428. _proto.walkAtRules = function walkAtRules(name, callback) {
  9429. if (!callback) {
  9430. callback = name;
  9431. return this.walk(function (child, i) {
  9432. if (child.type === 'atrule') {
  9433. return callback(child, i);
  9434. }
  9435. });
  9436. }
  9437. if (name instanceof RegExp) {
  9438. return this.walk(function (child, i) {
  9439. if (child.type === 'atrule' && name.test(child.name)) {
  9440. return callback(child, i);
  9441. }
  9442. });
  9443. }
  9444. return this.walk(function (child, i) {
  9445. if (child.type === 'atrule' && child.name === name) {
  9446. return callback(child, i);
  9447. }
  9448. });
  9449. }
  9450. /**
  9451. * Traverses the container’s descendant nodes, calling callback
  9452. * for each comment node.
  9453. *
  9454. * Like {@link Container#each}, this method is safe
  9455. * to use if you are mutating arrays during iteration.
  9456. *
  9457. * @param {childIterator} callback Iterator receives each node and index.
  9458. *
  9459. * @return {false|undefined} Returns `false` if iteration was broke.
  9460. *
  9461. * @example
  9462. * root.walkComments(comment => {
  9463. * comment.remove()
  9464. * })
  9465. */
  9466. ;
  9467. _proto.walkComments = function walkComments(callback) {
  9468. return this.walk(function (child, i) {
  9469. if (child.type === 'comment') {
  9470. return callback(child, i);
  9471. }
  9472. });
  9473. }
  9474. /**
  9475. * Inserts new nodes to the end of the container.
  9476. *
  9477. * @param {...(Node|object|string|Node[])} children New nodes.
  9478. *
  9479. * @return {Node} This node for methods chain.
  9480. *
  9481. * @example
  9482. * const decl1 = postcss.decl({ prop: 'color', value: 'black' })
  9483. * const decl2 = postcss.decl({ prop: 'background-color', value: 'white' })
  9484. * rule.append(decl1, decl2)
  9485. *
  9486. * root.append({ name: 'charset', params: '"UTF-8"' }) // at-rule
  9487. * root.append({ selector: 'a' }) // rule
  9488. * rule.append({ prop: 'color', value: 'black' }) // declaration
  9489. * rule.append({ text: 'Comment' }) // comment
  9490. *
  9491. * root.append('a {}')
  9492. * root.first.append('color: black; z-index: 1')
  9493. */
  9494. ;
  9495. _proto.append = function append() {
  9496. for (var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++) {
  9497. children[_key] = arguments[_key];
  9498. }
  9499. for (var _i = 0, _children = children; _i < _children.length; _i++) {
  9500. var child = _children[_i];
  9501. var nodes = this.normalize(child, this.last);
  9502. for (var _iterator = _createForOfIteratorHelperLoose(nodes), _step; !(_step = _iterator()).done;) {
  9503. var node = _step.value;
  9504. this.nodes.push(node);
  9505. }
  9506. }
  9507. return this;
  9508. }
  9509. /**
  9510. * Inserts new nodes to the start of the container.
  9511. *
  9512. * @param {...(Node|object|string|Node[])} children New nodes.
  9513. *
  9514. * @return {Node} This node for methods chain.
  9515. *
  9516. * @example
  9517. * const decl1 = postcss.decl({ prop: 'color', value: 'black' })
  9518. * const decl2 = postcss.decl({ prop: 'background-color', value: 'white' })
  9519. * rule.prepend(decl1, decl2)
  9520. *
  9521. * root.append({ name: 'charset', params: '"UTF-8"' }) // at-rule
  9522. * root.append({ selector: 'a' }) // rule
  9523. * rule.append({ prop: 'color', value: 'black' }) // declaration
  9524. * rule.append({ text: 'Comment' }) // comment
  9525. *
  9526. * root.append('a {}')
  9527. * root.first.append('color: black; z-index: 1')
  9528. */
  9529. ;
  9530. _proto.prepend = function prepend() {
  9531. for (var _len2 = arguments.length, children = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
  9532. children[_key2] = arguments[_key2];
  9533. }
  9534. children = children.reverse();
  9535. for (var _iterator2 = _createForOfIteratorHelperLoose(children), _step2; !(_step2 = _iterator2()).done;) {
  9536. var child = _step2.value;
  9537. var nodes = this.normalize(child, this.first, 'prepend').reverse();
  9538. for (var _iterator3 = _createForOfIteratorHelperLoose(nodes), _step3; !(_step3 = _iterator3()).done;) {
  9539. var node = _step3.value;
  9540. this.nodes.unshift(node);
  9541. }
  9542. for (var id in this.indexes) {
  9543. this.indexes[id] = this.indexes[id] + nodes.length;
  9544. }
  9545. }
  9546. return this;
  9547. };
  9548. _proto.cleanRaws = function cleanRaws(keepBetween) {
  9549. _Node.prototype.cleanRaws.call(this, keepBetween);
  9550. if (this.nodes) {
  9551. for (var _iterator4 = _createForOfIteratorHelperLoose(this.nodes), _step4; !(_step4 = _iterator4()).done;) {
  9552. var node = _step4.value;
  9553. node.cleanRaws(keepBetween);
  9554. }
  9555. }
  9556. }
  9557. /**
  9558. * Insert new node before old node within the container.
  9559. *
  9560. * @param {Node|number} exist Child or child’s index.
  9561. * @param {Node|object|string|Node[]} add New node.
  9562. *
  9563. * @return {Node} This node for methods chain.
  9564. *
  9565. * @example
  9566. * rule.insertBefore(decl, decl.clone({ prop: '-webkit-' + decl.prop }))
  9567. */
  9568. ;
  9569. _proto.insertBefore = function insertBefore(exist, add) {
  9570. exist = this.index(exist);
  9571. var type = exist === 0 ? 'prepend' : false;
  9572. var nodes = this.normalize(add, this.nodes[exist], type).reverse();
  9573. for (var _iterator5 = _createForOfIteratorHelperLoose(nodes), _step5; !(_step5 = _iterator5()).done;) {
  9574. var node = _step5.value;
  9575. this.nodes.splice(exist, 0, node);
  9576. }
  9577. var index;
  9578. for (var id in this.indexes) {
  9579. index = this.indexes[id];
  9580. if (exist <= index) {
  9581. this.indexes[id] = index + nodes.length;
  9582. }
  9583. }
  9584. return this;
  9585. }
  9586. /**
  9587. * Insert new node after old node within the container.
  9588. *
  9589. * @param {Node|number} exist Child or child’s index.
  9590. * @param {Node|object|string|Node[]} add New node.
  9591. *
  9592. * @return {Node} This node for methods chain.
  9593. */
  9594. ;
  9595. _proto.insertAfter = function insertAfter(exist, add) {
  9596. exist = this.index(exist);
  9597. var nodes = this.normalize(add, this.nodes[exist]).reverse();
  9598. for (var _iterator6 = _createForOfIteratorHelperLoose(nodes), _step6; !(_step6 = _iterator6()).done;) {
  9599. var node = _step6.value;
  9600. this.nodes.splice(exist + 1, 0, node);
  9601. }
  9602. var index;
  9603. for (var id in this.indexes) {
  9604. index = this.indexes[id];
  9605. if (exist < index) {
  9606. this.indexes[id] = index + nodes.length;
  9607. }
  9608. }
  9609. return this;
  9610. }
  9611. /**
  9612. * Removes node from the container and cleans the parent properties
  9613. * from the node and its children.
  9614. *
  9615. * @param {Node|number} child Child or child’s index.
  9616. *
  9617. * @return {Node} This node for methods chain
  9618. *
  9619. * @example
  9620. * rule.nodes.length //=> 5
  9621. * rule.removeChild(decl)
  9622. * rule.nodes.length //=> 4
  9623. * decl.parent //=> undefined
  9624. */
  9625. ;
  9626. _proto.removeChild = function removeChild(child) {
  9627. child = this.index(child);
  9628. this.nodes[child].parent = undefined;
  9629. this.nodes.splice(child, 1);
  9630. var index;
  9631. for (var id in this.indexes) {
  9632. index = this.indexes[id];
  9633. if (index >= child) {
  9634. this.indexes[id] = index - 1;
  9635. }
  9636. }
  9637. return this;
  9638. }
  9639. /**
  9640. * Removes all children from the container
  9641. * and cleans their parent properties.
  9642. *
  9643. * @return {Node} This node for methods chain.
  9644. *
  9645. * @example
  9646. * rule.removeAll()
  9647. * rule.nodes.length //=> 0
  9648. */
  9649. ;
  9650. _proto.removeAll = function removeAll() {
  9651. for (var _iterator7 = _createForOfIteratorHelperLoose(this.nodes), _step7; !(_step7 = _iterator7()).done;) {
  9652. var node = _step7.value;
  9653. node.parent = undefined;
  9654. }
  9655. this.nodes = [];
  9656. return this;
  9657. }
  9658. /**
  9659. * Passes all declaration values within the container that match pattern
  9660. * through callback, replacing those values with the returned result
  9661. * of callback.
  9662. *
  9663. * This method is useful if you are using a custom unit or function
  9664. * and need to iterate through all values.
  9665. *
  9666. * @param {string|RegExp} pattern Replace pattern.
  9667. * @param {object} opts Options to speed up the search.
  9668. * @param {string|string[]} opts.props An array of property names.
  9669. * @param {string} opts.fast String that’s used to narrow down
  9670. * values and speed up the regexp search.
  9671. * @param {function|string} callback String to replace pattern or callback
  9672. * that returns a new value. The callback
  9673. * will receive the same arguments
  9674. * as those passed to a function parameter
  9675. * of `String#replace`.
  9676. *
  9677. * @return {Node} This node for methods chain.
  9678. *
  9679. * @example
  9680. * root.replaceValues(/\d+rem/, { fast: 'rem' }, string => {
  9681. * return 15 * parseInt(string) + 'px'
  9682. * })
  9683. */
  9684. ;
  9685. _proto.replaceValues = function replaceValues(pattern, opts, callback) {
  9686. if (!callback) {
  9687. callback = opts;
  9688. opts = {};
  9689. }
  9690. this.walkDecls(function (decl) {
  9691. if (opts.props && opts.props.indexOf(decl.prop) === -1) return;
  9692. if (opts.fast && decl.value.indexOf(opts.fast) === -1) return;
  9693. decl.value = decl.value.replace(pattern, callback);
  9694. });
  9695. return this;
  9696. }
  9697. /**
  9698. * Returns `true` if callback returns `true`
  9699. * for all of the container’s children.
  9700. *
  9701. * @param {childCondition} condition Iterator returns true or false.
  9702. *
  9703. * @return {boolean} Is every child pass condition.
  9704. *
  9705. * @example
  9706. * const noPrefixes = rule.every(i => i.prop[0] !== '-')
  9707. */
  9708. ;
  9709. _proto.every = function every(condition) {
  9710. return this.nodes.every(condition);
  9711. }
  9712. /**
  9713. * Returns `true` if callback returns `true` for (at least) one
  9714. * of the container’s children.
  9715. *
  9716. * @param {childCondition} condition Iterator returns true or false.
  9717. *
  9718. * @return {boolean} Is some child pass condition.
  9719. *
  9720. * @example
  9721. * const hasPrefix = rule.some(i => i.prop[0] === '-')
  9722. */
  9723. ;
  9724. _proto.some = function some(condition) {
  9725. return this.nodes.some(condition);
  9726. }
  9727. /**
  9728. * Returns a `child`’s index within the {@link Container#nodes} array.
  9729. *
  9730. * @param {Node} child Child of the current container.
  9731. *
  9732. * @return {number} Child index.
  9733. *
  9734. * @example
  9735. * rule.index( rule.nodes[2] ) //=> 2
  9736. */
  9737. ;
  9738. _proto.index = function index(child) {
  9739. if (typeof child === 'number') {
  9740. return child;
  9741. }
  9742. return this.nodes.indexOf(child);
  9743. }
  9744. /**
  9745. * The container’s first child.
  9746. *
  9747. * @type {Node}
  9748. *
  9749. * @example
  9750. * rule.first === rules.nodes[0]
  9751. */
  9752. ;
  9753. _proto.normalize = function normalize(nodes, sample) {
  9754. var _this = this;
  9755. if (typeof nodes === 'string') {
  9756. var parse = require('./parse');
  9757. nodes = cleanSource(parse(nodes).nodes);
  9758. } else if (Array.isArray(nodes)) {
  9759. nodes = nodes.slice(0);
  9760. for (var _iterator8 = _createForOfIteratorHelperLoose(nodes), _step8; !(_step8 = _iterator8()).done;) {
  9761. var i = _step8.value;
  9762. if (i.parent) i.parent.removeChild(i, 'ignore');
  9763. }
  9764. } else if (nodes.type === 'root') {
  9765. nodes = nodes.nodes.slice(0);
  9766. for (var _iterator9 = _createForOfIteratorHelperLoose(nodes), _step9; !(_step9 = _iterator9()).done;) {
  9767. var _i2 = _step9.value;
  9768. if (_i2.parent) _i2.parent.removeChild(_i2, 'ignore');
  9769. }
  9770. } else if (nodes.type) {
  9771. nodes = [nodes];
  9772. } else if (nodes.prop) {
  9773. if (typeof nodes.value === 'undefined') {
  9774. throw new Error('Value field is missed in node creation');
  9775. } else if (typeof nodes.value !== 'string') {
  9776. nodes.value = String(nodes.value);
  9777. }
  9778. nodes = [new _declaration.default(nodes)];
  9779. } else if (nodes.selector) {
  9780. var Rule = require('./rule');
  9781. nodes = [new Rule(nodes)];
  9782. } else if (nodes.name) {
  9783. var AtRule = require('./at-rule');
  9784. nodes = [new AtRule(nodes)];
  9785. } else if (nodes.text) {
  9786. nodes = [new _comment.default(nodes)];
  9787. } else {
  9788. throw new Error('Unknown node type in node creation');
  9789. }
  9790. var processed = nodes.map(function (i) {
  9791. if (i.parent) i.parent.removeChild(i);
  9792. if (typeof i.raws.before === 'undefined') {
  9793. if (sample && typeof sample.raws.before !== 'undefined') {
  9794. i.raws.before = sample.raws.before.replace(/[^\s]/g, '');
  9795. }
  9796. }
  9797. i.parent = _this;
  9798. return i;
  9799. });
  9800. return processed;
  9801. }
  9802. /**
  9803. * @memberof Container#
  9804. * @member {Node[]} nodes An array containing the container’s children.
  9805. *
  9806. * @example
  9807. * const root = postcss.parse('a { color: black }')
  9808. * root.nodes.length //=> 1
  9809. * root.nodes[0].selector //=> 'a'
  9810. * root.nodes[0].nodes[0].prop //=> 'color'
  9811. */
  9812. ;
  9813. _createClass(Container, [{
  9814. key: "first",
  9815. get: function get() {
  9816. if (!this.nodes) return undefined;
  9817. return this.nodes[0];
  9818. }
  9819. /**
  9820. * The container’s last child.
  9821. *
  9822. * @type {Node}
  9823. *
  9824. * @example
  9825. * rule.last === rule.nodes[rule.nodes.length - 1]
  9826. */
  9827. }, {
  9828. key: "last",
  9829. get: function get() {
  9830. if (!this.nodes) return undefined;
  9831. return this.nodes[this.nodes.length - 1];
  9832. }
  9833. }]);
  9834. return Container;
  9835. }(_node.default);
  9836. var _default = Container;
  9837. /**
  9838. * @callback childCondition
  9839. * @param {Node} node Container child.
  9840. * @param {number} index Child index.
  9841. * @param {Node[]} nodes All container children.
  9842. * @return {boolean}
  9843. */
  9844. /**
  9845. * @callback childIterator
  9846. * @param {Node} node Container child.
  9847. * @param {number} index Child index.
  9848. * @return {false|undefined} Returning `false` will break iteration.
  9849. */
  9850. exports.default = _default;
  9851. module.exports = exports.default;
  9852. },{"./at-rule":169,"./comment":170,"./declaration":173,"./node":178,"./parse":179,"./rule":186}],172:[function(require,module,exports){
  9853. "use strict";
  9854. exports.__esModule = true;
  9855. exports.default = void 0;
  9856. var _supportsColor = _interopRequireDefault(require("supports-color"));
  9857. var _chalk = _interopRequireDefault(require("chalk"));
  9858. var _terminalHighlight = _interopRequireDefault(require("./terminal-highlight"));
  9859. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  9860. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  9861. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  9862. function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }
  9863. function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }
  9864. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  9865. function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; }
  9866. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  9867. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  9868. /**
  9869. * The CSS parser throws this error for broken CSS.
  9870. *
  9871. * Custom parsers can throw this error for broken custom syntax using
  9872. * the {@link Node#error} method.
  9873. *
  9874. * PostCSS will use the input source map to detect the original error location.
  9875. * If you wrote a Sass file, compiled it to CSS and then parsed it with PostCSS,
  9876. * PostCSS will show the original position in the Sass file.
  9877. *
  9878. * If you need the position in the PostCSS input
  9879. * (e.g., to debug the previous compiler), use `error.input.file`.
  9880. *
  9881. * @example
  9882. * // Catching and checking syntax error
  9883. * try {
  9884. * postcss.parse('a{')
  9885. * } catch (error) {
  9886. * if (error.name === 'CssSyntaxError') {
  9887. * error //=> CssSyntaxError
  9888. * }
  9889. * }
  9890. *
  9891. * @example
  9892. * // Raising error from plugin
  9893. * throw node.error('Unknown variable', { plugin: 'postcss-vars' })
  9894. */
  9895. var CssSyntaxError = /*#__PURE__*/function (_Error) {
  9896. _inheritsLoose(CssSyntaxError, _Error);
  9897. /**
  9898. * @param {string} message Error message.
  9899. * @param {number} [line] Source line of the error.
  9900. * @param {number} [column] Source column of the error.
  9901. * @param {string} [source] Source code of the broken file.
  9902. * @param {string} [file] Absolute path to the broken file.
  9903. * @param {string} [plugin] PostCSS plugin name, if error came from plugin.
  9904. */
  9905. function CssSyntaxError(message, line, column, source, file, plugin) {
  9906. var _this;
  9907. _this = _Error.call(this, message) || this;
  9908. /**
  9909. * Always equal to `'CssSyntaxError'`. You should always check error type
  9910. * by `error.name === 'CssSyntaxError'`
  9911. * instead of `error instanceof CssSyntaxError`,
  9912. * because npm could have several PostCSS versions.
  9913. *
  9914. * @type {string}
  9915. *
  9916. * @example
  9917. * if (error.name === 'CssSyntaxError') {
  9918. * error //=> CssSyntaxError
  9919. * }
  9920. */
  9921. _this.name = 'CssSyntaxError';
  9922. /**
  9923. * Error message.
  9924. *
  9925. * @type {string}
  9926. *
  9927. * @example
  9928. * error.message //=> 'Unclosed block'
  9929. */
  9930. _this.reason = message;
  9931. if (file) {
  9932. /**
  9933. * Absolute path to the broken file.
  9934. *
  9935. * @type {string}
  9936. *
  9937. * @example
  9938. * error.file //=> 'a.sass'
  9939. * error.input.file //=> 'a.css'
  9940. */
  9941. _this.file = file;
  9942. }
  9943. if (source) {
  9944. /**
  9945. * Source code of the broken file.
  9946. *
  9947. * @type {string}
  9948. *
  9949. * @example
  9950. * error.source //=> 'a { b {} }'
  9951. * error.input.column //=> 'a b { }'
  9952. */
  9953. _this.source = source;
  9954. }
  9955. if (plugin) {
  9956. /**
  9957. * Plugin name, if error came from plugin.
  9958. *
  9959. * @type {string}
  9960. *
  9961. * @example
  9962. * error.plugin //=> 'postcss-vars'
  9963. */
  9964. _this.plugin = plugin;
  9965. }
  9966. if (typeof line !== 'undefined' && typeof column !== 'undefined') {
  9967. /**
  9968. * Source line of the error.
  9969. *
  9970. * @type {number}
  9971. *
  9972. * @example
  9973. * error.line //=> 2
  9974. * error.input.line //=> 4
  9975. */
  9976. _this.line = line;
  9977. /**
  9978. * Source column of the error.
  9979. *
  9980. * @type {number}
  9981. *
  9982. * @example
  9983. * error.column //=> 1
  9984. * error.input.column //=> 4
  9985. */
  9986. _this.column = column;
  9987. }
  9988. _this.setMessage();
  9989. if (Error.captureStackTrace) {
  9990. Error.captureStackTrace(_assertThisInitialized(_this), CssSyntaxError);
  9991. }
  9992. return _this;
  9993. }
  9994. var _proto = CssSyntaxError.prototype;
  9995. _proto.setMessage = function setMessage() {
  9996. /**
  9997. * Full error text in the GNU error format
  9998. * with plugin, file, line and column.
  9999. *
  10000. * @type {string}
  10001. *
  10002. * @example
  10003. * error.message //=> 'a.css:1:1: Unclosed block'
  10004. */
  10005. this.message = this.plugin ? this.plugin + ': ' : '';
  10006. this.message += this.file ? this.file : '<css input>';
  10007. if (typeof this.line !== 'undefined') {
  10008. this.message += ':' + this.line + ':' + this.column;
  10009. }
  10010. this.message += ': ' + this.reason;
  10011. }
  10012. /**
  10013. * Returns a few lines of CSS source that caused the error.
  10014. *
  10015. * If the CSS has an input source map without `sourceContent`,
  10016. * this method will return an empty string.
  10017. *
  10018. * @param {boolean} [color] Whether arrow will be colored red by terminal
  10019. * color codes. By default, PostCSS will detect
  10020. * color support by `process.stdout.isTTY`
  10021. * and `process.env.NODE_DISABLE_COLORS`.
  10022. *
  10023. * @example
  10024. * error.showSourceCode() //=> " 4 | }
  10025. * // 5 | a {
  10026. * // > 6 | bad
  10027. * // | ^
  10028. * // 7 | }
  10029. * // 8 | b {"
  10030. *
  10031. * @return {string} Few lines of CSS source that caused the error.
  10032. */
  10033. ;
  10034. _proto.showSourceCode = function showSourceCode(color) {
  10035. var _this2 = this;
  10036. if (!this.source) return '';
  10037. var css = this.source;
  10038. if (_terminalHighlight.default) {
  10039. if (typeof color === 'undefined') color = _supportsColor.default.stdout;
  10040. if (color) css = (0, _terminalHighlight.default)(css);
  10041. }
  10042. var lines = css.split(/\r?\n/);
  10043. var start = Math.max(this.line - 3, 0);
  10044. var end = Math.min(this.line + 2, lines.length);
  10045. var maxWidth = String(end).length;
  10046. function mark(text) {
  10047. if (color && _chalk.default.red) {
  10048. return _chalk.default.red.bold(text);
  10049. }
  10050. return text;
  10051. }
  10052. function aside(text) {
  10053. if (color && _chalk.default.gray) {
  10054. return _chalk.default.gray(text);
  10055. }
  10056. return text;
  10057. }
  10058. return lines.slice(start, end).map(function (line, index) {
  10059. var number = start + 1 + index;
  10060. var gutter = ' ' + (' ' + number).slice(-maxWidth) + ' | ';
  10061. if (number === _this2.line) {
  10062. var spacing = aside(gutter.replace(/\d/g, ' ')) + line.slice(0, _this2.column - 1).replace(/[^\t]/g, ' ');
  10063. return mark('>') + aside(gutter) + line + '\n ' + spacing + mark('^');
  10064. }
  10065. return ' ' + aside(gutter) + line;
  10066. }).join('\n');
  10067. }
  10068. /**
  10069. * Returns error position, message and source code of the broken part.
  10070. *
  10071. * @example
  10072. * error.toString() //=> "CssSyntaxError: app.css:1:1: Unclosed block
  10073. * // > 1 | a {
  10074. * // | ^"
  10075. *
  10076. * @return {string} Error position, message and source code.
  10077. */
  10078. ;
  10079. _proto.toString = function toString() {
  10080. var code = this.showSourceCode();
  10081. if (code) {
  10082. code = '\n\n' + code + '\n';
  10083. }
  10084. return this.name + ': ' + this.message + code;
  10085. }
  10086. /**
  10087. * @memberof CssSyntaxError#
  10088. * @member {Input} input Input object with PostCSS internal information
  10089. * about input file. If input has source map
  10090. * from previous tool, PostCSS will use origin
  10091. * (for example, Sass) source. You can use this
  10092. * object to get PostCSS input source.
  10093. *
  10094. * @example
  10095. * error.input.file //=> 'a.css'
  10096. * error.file //=> 'a.sass'
  10097. */
  10098. ;
  10099. return CssSyntaxError;
  10100. }( /*#__PURE__*/_wrapNativeSuper(Error));
  10101. var _default = CssSyntaxError;
  10102. exports.default = _default;
  10103. module.exports = exports.default;
  10104. },{"./terminal-highlight":2,"chalk":2,"supports-color":2}],173:[function(require,module,exports){
  10105. "use strict";
  10106. exports.__esModule = true;
  10107. exports.default = void 0;
  10108. var _node = _interopRequireDefault(require("./node"));
  10109. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  10110. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  10111. /**
  10112. * Represents a CSS declaration.
  10113. *
  10114. * @extends Node
  10115. *
  10116. * @example
  10117. * const root = postcss.parse('a { color: black }')
  10118. * const decl = root.first.first
  10119. * decl.type //=> 'decl'
  10120. * decl.toString() //=> ' color: black'
  10121. */
  10122. var Declaration = /*#__PURE__*/function (_Node) {
  10123. _inheritsLoose(Declaration, _Node);
  10124. function Declaration(defaults) {
  10125. var _this;
  10126. _this = _Node.call(this, defaults) || this;
  10127. _this.type = 'decl';
  10128. return _this;
  10129. }
  10130. /**
  10131. * @memberof Declaration#
  10132. * @member {string} prop The declaration’s property name.
  10133. *
  10134. * @example
  10135. * const root = postcss.parse('a { color: black }')
  10136. * const decl = root.first.first
  10137. * decl.prop //=> 'color'
  10138. */
  10139. /**
  10140. * @memberof Declaration#
  10141. * @member {string} value The declaration’s value.
  10142. *
  10143. * @example
  10144. * const root = postcss.parse('a { color: black }')
  10145. * const decl = root.first.first
  10146. * decl.value //=> 'black'
  10147. */
  10148. /**
  10149. * @memberof Declaration#
  10150. * @member {boolean} important `true` if the declaration
  10151. * has an !important annotation.
  10152. *
  10153. * @example
  10154. * const root = postcss.parse('a { color: black !important; color: red }')
  10155. * root.first.first.important //=> true
  10156. * root.first.last.important //=> undefined
  10157. */
  10158. /**
  10159. * @memberof Declaration#
  10160. * @member {object} raws Information to generate byte-to-byte equal
  10161. * node string as it was in the origin input.
  10162. *
  10163. * Every parser saves its own properties,
  10164. * but the default CSS parser uses:
  10165. *
  10166. * * `before`: the space symbols before the node. It also stores `*`
  10167. * and `_` symbols before the declaration (IE hack).
  10168. * * `between`: the symbols between the property and value
  10169. * for declarations.
  10170. * * `important`: the content of the important statement,
  10171. * if it is not just `!important`.
  10172. *
  10173. * PostCSS cleans declaration from comments and extra spaces,
  10174. * but it stores origin content in raws properties.
  10175. * As such, if you don’t change a declaration’s value,
  10176. * PostCSS will use the raw value with comments.
  10177. *
  10178. * @example
  10179. * const root = postcss.parse('a {\n color:black\n}')
  10180. * root.first.first.raws //=> { before: '\n ', between: ':' }
  10181. */
  10182. return Declaration;
  10183. }(_node.default);
  10184. var _default = Declaration;
  10185. exports.default = _default;
  10186. module.exports = exports.default;
  10187. },{"./node":178}],174:[function(require,module,exports){
  10188. "use strict";
  10189. exports.__esModule = true;
  10190. exports.default = void 0;
  10191. var _path = _interopRequireDefault(require("path"));
  10192. var _cssSyntaxError = _interopRequireDefault(require("./css-syntax-error"));
  10193. var _previousMap = _interopRequireDefault(require("./previous-map"));
  10194. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  10195. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  10196. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  10197. var sequence = 0;
  10198. /**
  10199. * Represents the source CSS.
  10200. *
  10201. * @example
  10202. * const root = postcss.parse(css, { from: file })
  10203. * const input = root.source.input
  10204. */
  10205. var Input = /*#__PURE__*/function () {
  10206. /**
  10207. * @param {string} css Input CSS source.
  10208. * @param {object} [opts] {@link Processor#process} options.
  10209. */
  10210. function Input(css, opts) {
  10211. if (opts === void 0) {
  10212. opts = {};
  10213. }
  10214. if (css === null || typeof css === 'undefined' || typeof css === 'object' && !css.toString) {
  10215. throw new Error("PostCSS received " + css + " instead of CSS string");
  10216. }
  10217. /**
  10218. * Input CSS source
  10219. *
  10220. * @type {string}
  10221. *
  10222. * @example
  10223. * const input = postcss.parse('a{}', { from: file }).input
  10224. * input.css //=> "a{}"
  10225. */
  10226. this.css = css.toString();
  10227. if (this.css[0] === "\uFEFF" || this.css[0] === "\uFFFE") {
  10228. this.hasBOM = true;
  10229. this.css = this.css.slice(1);
  10230. } else {
  10231. this.hasBOM = false;
  10232. }
  10233. if (opts.from) {
  10234. if (/^\w+:\/\//.test(opts.from) || _path.default.isAbsolute(opts.from)) {
  10235. /**
  10236. * The absolute path to the CSS source file defined
  10237. * with the `from` option.
  10238. *
  10239. * @type {string}
  10240. *
  10241. * @example
  10242. * const root = postcss.parse(css, { from: 'a.css' })
  10243. * root.source.input.file //=> '/home/ai/a.css'
  10244. */
  10245. this.file = opts.from;
  10246. } else {
  10247. this.file = _path.default.resolve(opts.from);
  10248. }
  10249. }
  10250. var map = new _previousMap.default(this.css, opts);
  10251. if (map.text) {
  10252. /**
  10253. * The input source map passed from a compilation step before PostCSS
  10254. * (for example, from Sass compiler).
  10255. *
  10256. * @type {PreviousMap}
  10257. *
  10258. * @example
  10259. * root.source.input.map.consumer().sources //=> ['a.sass']
  10260. */
  10261. this.map = map;
  10262. var file = map.consumer().file;
  10263. if (!this.file && file) this.file = this.mapResolve(file);
  10264. }
  10265. if (!this.file) {
  10266. sequence += 1;
  10267. /**
  10268. * The unique ID of the CSS source. It will be created if `from` option
  10269. * is not provided (because PostCSS does not know the file path).
  10270. *
  10271. * @type {string}
  10272. *
  10273. * @example
  10274. * const root = postcss.parse(css)
  10275. * root.source.input.file //=> undefined
  10276. * root.source.input.id //=> "<input css 1>"
  10277. */
  10278. this.id = '<input css ' + sequence + '>';
  10279. }
  10280. if (this.map) this.map.file = this.from;
  10281. }
  10282. var _proto = Input.prototype;
  10283. _proto.error = function error(message, line, column, opts) {
  10284. if (opts === void 0) {
  10285. opts = {};
  10286. }
  10287. var result;
  10288. var origin = this.origin(line, column);
  10289. if (origin) {
  10290. result = new _cssSyntaxError.default(message, origin.line, origin.column, origin.source, origin.file, opts.plugin);
  10291. } else {
  10292. result = new _cssSyntaxError.default(message, line, column, this.css, this.file, opts.plugin);
  10293. }
  10294. result.input = {
  10295. line: line,
  10296. column: column,
  10297. source: this.css
  10298. };
  10299. if (this.file) result.input.file = this.file;
  10300. return result;
  10301. }
  10302. /**
  10303. * Reads the input source map and returns a symbol position
  10304. * in the input source (e.g., in a Sass file that was compiled
  10305. * to CSS before being passed to PostCSS).
  10306. *
  10307. * @param {number} line Line in input CSS.
  10308. * @param {number} column Column in input CSS.
  10309. *
  10310. * @return {filePosition} Position in input source.
  10311. *
  10312. * @example
  10313. * root.source.input.origin(1, 1) //=> { file: 'a.css', line: 3, column: 1 }
  10314. */
  10315. ;
  10316. _proto.origin = function origin(line, column) {
  10317. if (!this.map) return false;
  10318. var consumer = this.map.consumer();
  10319. var from = consumer.originalPositionFor({
  10320. line: line,
  10321. column: column
  10322. });
  10323. if (!from.source) return false;
  10324. var result = {
  10325. file: this.mapResolve(from.source),
  10326. line: from.line,
  10327. column: from.column
  10328. };
  10329. var source = consumer.sourceContentFor(from.source);
  10330. if (source) result.source = source;
  10331. return result;
  10332. };
  10333. _proto.mapResolve = function mapResolve(file) {
  10334. if (/^\w+:\/\//.test(file)) {
  10335. return file;
  10336. }
  10337. return _path.default.resolve(this.map.consumer().sourceRoot || '.', file);
  10338. }
  10339. /**
  10340. * The CSS source identifier. Contains {@link Input#file} if the user
  10341. * set the `from` option, or {@link Input#id} if they did not.
  10342. *
  10343. * @type {string}
  10344. *
  10345. * @example
  10346. * const root = postcss.parse(css, { from: 'a.css' })
  10347. * root.source.input.from //=> "/home/ai/a.css"
  10348. *
  10349. * const root = postcss.parse(css)
  10350. * root.source.input.from //=> "<input css 1>"
  10351. */
  10352. ;
  10353. _createClass(Input, [{
  10354. key: "from",
  10355. get: function get() {
  10356. return this.file || this.id;
  10357. }
  10358. }]);
  10359. return Input;
  10360. }();
  10361. var _default = Input;
  10362. /**
  10363. * @typedef {object} filePosition
  10364. * @property {string} file Path to file.
  10365. * @property {number} line Source line in file.
  10366. * @property {number} column Source column in file.
  10367. */
  10368. exports.default = _default;
  10369. module.exports = exports.default;
  10370. },{"./css-syntax-error":172,"./previous-map":182,"path":168}],175:[function(require,module,exports){
  10371. (function (process){
  10372. "use strict";
  10373. exports.__esModule = true;
  10374. exports.default = void 0;
  10375. var _mapGenerator = _interopRequireDefault(require("./map-generator"));
  10376. var _stringify2 = _interopRequireDefault(require("./stringify"));
  10377. var _warnOnce = _interopRequireDefault(require("./warn-once"));
  10378. var _result = _interopRequireDefault(require("./result"));
  10379. var _parse = _interopRequireDefault(require("./parse"));
  10380. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  10381. function _createForOfIteratorHelperLoose(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } it = o[Symbol.iterator](); return it.next.bind(it); }
  10382. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  10383. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  10384. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  10385. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  10386. function isPromise(obj) {
  10387. return typeof obj === 'object' && typeof obj.then === 'function';
  10388. }
  10389. /**
  10390. * A Promise proxy for the result of PostCSS transformations.
  10391. *
  10392. * A `LazyResult` instance is returned by {@link Processor#process}.
  10393. *
  10394. * @example
  10395. * const lazy = postcss([autoprefixer]).process(css)
  10396. */
  10397. var LazyResult = /*#__PURE__*/function () {
  10398. function LazyResult(processor, css, opts) {
  10399. this.stringified = false;
  10400. this.processed = false;
  10401. var root;
  10402. if (typeof css === 'object' && css !== null && css.type === 'root') {
  10403. root = css;
  10404. } else if (css instanceof LazyResult || css instanceof _result.default) {
  10405. root = css.root;
  10406. if (css.map) {
  10407. if (typeof opts.map === 'undefined') opts.map = {};
  10408. if (!opts.map.inline) opts.map.inline = false;
  10409. opts.map.prev = css.map;
  10410. }
  10411. } else {
  10412. var parser = _parse.default;
  10413. if (opts.syntax) parser = opts.syntax.parse;
  10414. if (opts.parser) parser = opts.parser;
  10415. if (parser.parse) parser = parser.parse;
  10416. try {
  10417. root = parser(css, opts);
  10418. } catch (error) {
  10419. this.error = error;
  10420. }
  10421. }
  10422. this.result = new _result.default(processor, root, opts);
  10423. }
  10424. /**
  10425. * Returns a {@link Processor} instance, which will be used
  10426. * for CSS transformations.
  10427. *
  10428. * @type {Processor}
  10429. */
  10430. var _proto = LazyResult.prototype;
  10431. /**
  10432. * Processes input CSS through synchronous plugins
  10433. * and calls {@link Result#warnings()}.
  10434. *
  10435. * @return {Warning[]} Warnings from plugins.
  10436. */
  10437. _proto.warnings = function warnings() {
  10438. return this.sync().warnings();
  10439. }
  10440. /**
  10441. * Alias for the {@link LazyResult#css} property.
  10442. *
  10443. * @example
  10444. * lazy + '' === lazy.css
  10445. *
  10446. * @return {string} Output CSS.
  10447. */
  10448. ;
  10449. _proto.toString = function toString() {
  10450. return this.css;
  10451. }
  10452. /**
  10453. * Processes input CSS through synchronous and asynchronous plugins
  10454. * and calls `onFulfilled` with a Result instance. If a plugin throws
  10455. * an error, the `onRejected` callback will be executed.
  10456. *
  10457. * It implements standard Promise API.
  10458. *
  10459. * @param {onFulfilled} onFulfilled Callback will be executed
  10460. * when all plugins will finish work.
  10461. * @param {onRejected} onRejected Callback will be executed on any error.
  10462. *
  10463. * @return {Promise} Promise API to make queue.
  10464. *
  10465. * @example
  10466. * postcss([autoprefixer]).process(css, { from: cssPath }).then(result => {
  10467. * console.log(result.css)
  10468. * })
  10469. */
  10470. ;
  10471. _proto.then = function then(onFulfilled, onRejected) {
  10472. if (process.env.NODE_ENV !== 'production') {
  10473. if (!('from' in this.opts)) {
  10474. (0, _warnOnce.default)('Without `from` option PostCSS could generate wrong source map ' + 'and will not find Browserslist config. Set it to CSS file path ' + 'or to `undefined` to prevent this warning.');
  10475. }
  10476. }
  10477. return this.async().then(onFulfilled, onRejected);
  10478. }
  10479. /**
  10480. * Processes input CSS through synchronous and asynchronous plugins
  10481. * and calls onRejected for each error thrown in any plugin.
  10482. *
  10483. * It implements standard Promise API.
  10484. *
  10485. * @param {onRejected} onRejected Callback will be executed on any error.
  10486. *
  10487. * @return {Promise} Promise API to make queue.
  10488. *
  10489. * @example
  10490. * postcss([autoprefixer]).process(css).then(result => {
  10491. * console.log(result.css)
  10492. * }).catch(error => {
  10493. * console.error(error)
  10494. * })
  10495. */
  10496. ;
  10497. _proto.catch = function _catch(onRejected) {
  10498. return this.async().catch(onRejected);
  10499. }
  10500. /**
  10501. * Processes input CSS through synchronous and asynchronous plugins
  10502. * and calls onFinally on any error or when all plugins will finish work.
  10503. *
  10504. * It implements standard Promise API.
  10505. *
  10506. * @param {onFinally} onFinally Callback will be executed on any error or
  10507. * when all plugins will finish work.
  10508. *
  10509. * @return {Promise} Promise API to make queue.
  10510. *
  10511. * @example
  10512. * postcss([autoprefixer]).process(css).finally(() => {
  10513. * console.log('processing ended')
  10514. * })
  10515. */
  10516. ;
  10517. _proto.finally = function _finally(onFinally) {
  10518. return this.async().then(onFinally, onFinally);
  10519. };
  10520. _proto.handleError = function handleError(error, plugin) {
  10521. try {
  10522. this.error = error;
  10523. if (error.name === 'CssSyntaxError' && !error.plugin) {
  10524. error.plugin = plugin.postcssPlugin;
  10525. error.setMessage();
  10526. } else if (plugin.postcssVersion) {
  10527. if (process.env.NODE_ENV !== 'production') {
  10528. var pluginName = plugin.postcssPlugin;
  10529. var pluginVer = plugin.postcssVersion;
  10530. var runtimeVer = this.result.processor.version;
  10531. var a = pluginVer.split('.');
  10532. var b = runtimeVer.split('.');
  10533. if (a[0] !== b[0] || parseInt(a[1]) > parseInt(b[1])) {
  10534. console.error('Unknown error from PostCSS plugin. Your current PostCSS ' + 'version is ' + runtimeVer + ', but ' + pluginName + ' uses ' + pluginVer + '. Perhaps this is the source of the error below.');
  10535. }
  10536. }
  10537. }
  10538. } catch (err) {
  10539. if (console && console.error) console.error(err);
  10540. }
  10541. };
  10542. _proto.asyncTick = function asyncTick(resolve, reject) {
  10543. var _this = this;
  10544. if (this.plugin >= this.processor.plugins.length) {
  10545. this.processed = true;
  10546. return resolve();
  10547. }
  10548. try {
  10549. var plugin = this.processor.plugins[this.plugin];
  10550. var promise = this.run(plugin);
  10551. this.plugin += 1;
  10552. if (isPromise(promise)) {
  10553. promise.then(function () {
  10554. _this.asyncTick(resolve, reject);
  10555. }).catch(function (error) {
  10556. _this.handleError(error, plugin);
  10557. _this.processed = true;
  10558. reject(error);
  10559. });
  10560. } else {
  10561. this.asyncTick(resolve, reject);
  10562. }
  10563. } catch (error) {
  10564. this.processed = true;
  10565. reject(error);
  10566. }
  10567. };
  10568. _proto.async = function async() {
  10569. var _this2 = this;
  10570. if (this.processed) {
  10571. return new Promise(function (resolve, reject) {
  10572. if (_this2.error) {
  10573. reject(_this2.error);
  10574. } else {
  10575. resolve(_this2.stringify());
  10576. }
  10577. });
  10578. }
  10579. if (this.processing) {
  10580. return this.processing;
  10581. }
  10582. this.processing = new Promise(function (resolve, reject) {
  10583. if (_this2.error) return reject(_this2.error);
  10584. _this2.plugin = 0;
  10585. _this2.asyncTick(resolve, reject);
  10586. }).then(function () {
  10587. _this2.processed = true;
  10588. return _this2.stringify();
  10589. });
  10590. return this.processing;
  10591. };
  10592. _proto.sync = function sync() {
  10593. if (this.processed) return this.result;
  10594. this.processed = true;
  10595. if (this.processing) {
  10596. throw new Error('Use process(css).then(cb) to work with async plugins');
  10597. }
  10598. if (this.error) throw this.error;
  10599. for (var _iterator = _createForOfIteratorHelperLoose(this.result.processor.plugins), _step; !(_step = _iterator()).done;) {
  10600. var plugin = _step.value;
  10601. var promise = this.run(plugin);
  10602. if (isPromise(promise)) {
  10603. throw new Error('Use process(css).then(cb) to work with async plugins');
  10604. }
  10605. }
  10606. return this.result;
  10607. };
  10608. _proto.run = function run(plugin) {
  10609. this.result.lastPlugin = plugin;
  10610. try {
  10611. return plugin(this.result.root, this.result);
  10612. } catch (error) {
  10613. this.handleError(error, plugin);
  10614. throw error;
  10615. }
  10616. };
  10617. _proto.stringify = function stringify() {
  10618. if (this.stringified) return this.result;
  10619. this.stringified = true;
  10620. this.sync();
  10621. var opts = this.result.opts;
  10622. var str = _stringify2.default;
  10623. if (opts.syntax) str = opts.syntax.stringify;
  10624. if (opts.stringifier) str = opts.stringifier;
  10625. if (str.stringify) str = str.stringify;
  10626. var map = new _mapGenerator.default(str, this.result.root, this.result.opts);
  10627. var data = map.generate();
  10628. this.result.css = data[0];
  10629. this.result.map = data[1];
  10630. return this.result;
  10631. };
  10632. _createClass(LazyResult, [{
  10633. key: "processor",
  10634. get: function get() {
  10635. return this.result.processor;
  10636. }
  10637. /**
  10638. * Options from the {@link Processor#process} call.
  10639. *
  10640. * @type {processOptions}
  10641. */
  10642. }, {
  10643. key: "opts",
  10644. get: function get() {
  10645. return this.result.opts;
  10646. }
  10647. /**
  10648. * Processes input CSS through synchronous plugins, converts `Root`
  10649. * to a CSS string and returns {@link Result#css}.
  10650. *
  10651. * This property will only work with synchronous plugins.
  10652. * If the processor contains any asynchronous plugins
  10653. * it will throw an error. This is why this method is only
  10654. * for debug purpose, you should always use {@link LazyResult#then}.
  10655. *
  10656. * @type {string}
  10657. * @see Result#css
  10658. */
  10659. }, {
  10660. key: "css",
  10661. get: function get() {
  10662. return this.stringify().css;
  10663. }
  10664. /**
  10665. * An alias for the `css` property. Use it with syntaxes
  10666. * that generate non-CSS output.
  10667. *
  10668. * This property will only work with synchronous plugins.
  10669. * If the processor contains any asynchronous plugins
  10670. * it will throw an error. This is why this method is only
  10671. * for debug purpose, you should always use {@link LazyResult#then}.
  10672. *
  10673. * @type {string}
  10674. * @see Result#content
  10675. */
  10676. }, {
  10677. key: "content",
  10678. get: function get() {
  10679. return this.stringify().content;
  10680. }
  10681. /**
  10682. * Processes input CSS through synchronous plugins
  10683. * and returns {@link Result#map}.
  10684. *
  10685. * This property will only work with synchronous plugins.
  10686. * If the processor contains any asynchronous plugins
  10687. * it will throw an error. This is why this method is only
  10688. * for debug purpose, you should always use {@link LazyResult#then}.
  10689. *
  10690. * @type {SourceMapGenerator}
  10691. * @see Result#map
  10692. */
  10693. }, {
  10694. key: "map",
  10695. get: function get() {
  10696. return this.stringify().map;
  10697. }
  10698. /**
  10699. * Processes input CSS through synchronous plugins
  10700. * and returns {@link Result#root}.
  10701. *
  10702. * This property will only work with synchronous plugins. If the processor
  10703. * contains any asynchronous plugins it will throw an error.
  10704. *
  10705. * This is why this method is only for debug purpose,
  10706. * you should always use {@link LazyResult#then}.
  10707. *
  10708. * @type {Root}
  10709. * @see Result#root
  10710. */
  10711. }, {
  10712. key: "root",
  10713. get: function get() {
  10714. return this.sync().root;
  10715. }
  10716. /**
  10717. * Processes input CSS through synchronous plugins
  10718. * and returns {@link Result#messages}.
  10719. *
  10720. * This property will only work with synchronous plugins. If the processor
  10721. * contains any asynchronous plugins it will throw an error.
  10722. *
  10723. * This is why this method is only for debug purpose,
  10724. * you should always use {@link LazyResult#then}.
  10725. *
  10726. * @type {Message[]}
  10727. * @see Result#messages
  10728. */
  10729. }, {
  10730. key: "messages",
  10731. get: function get() {
  10732. return this.sync().messages;
  10733. }
  10734. }]);
  10735. return LazyResult;
  10736. }();
  10737. var _default = LazyResult;
  10738. /**
  10739. * @callback onFulfilled
  10740. * @param {Result} result
  10741. */
  10742. /**
  10743. * @callback onRejected
  10744. * @param {Error} error
  10745. */
  10746. exports.default = _default;
  10747. module.exports = exports.default;
  10748. }).call(this,require('_process'))
  10749. },{"./map-generator":177,"./parse":179,"./result":184,"./stringify":188,"./warn-once":191,"_process":193}],176:[function(require,module,exports){
  10750. "use strict";
  10751. exports.__esModule = true;
  10752. exports.default = void 0;
  10753. /**
  10754. * Contains helpers for safely splitting lists of CSS values,
  10755. * preserving parentheses and quotes.
  10756. *
  10757. * @example
  10758. * const list = postcss.list
  10759. *
  10760. * @namespace list
  10761. */
  10762. var list = {
  10763. split: function split(string, separators, last) {
  10764. var array = [];
  10765. var current = '';
  10766. var split = false;
  10767. var func = 0;
  10768. var quote = false;
  10769. var escape = false;
  10770. for (var i = 0; i < string.length; i++) {
  10771. var letter = string[i];
  10772. if (quote) {
  10773. if (escape) {
  10774. escape = false;
  10775. } else if (letter === '\\') {
  10776. escape = true;
  10777. } else if (letter === quote) {
  10778. quote = false;
  10779. }
  10780. } else if (letter === '"' || letter === '\'') {
  10781. quote = letter;
  10782. } else if (letter === '(') {
  10783. func += 1;
  10784. } else if (letter === ')') {
  10785. if (func > 0) func -= 1;
  10786. } else if (func === 0) {
  10787. if (separators.indexOf(letter) !== -1) split = true;
  10788. }
  10789. if (split) {
  10790. if (current !== '') array.push(current.trim());
  10791. current = '';
  10792. split = false;
  10793. } else {
  10794. current += letter;
  10795. }
  10796. }
  10797. if (last || current !== '') array.push(current.trim());
  10798. return array;
  10799. },
  10800. /**
  10801. * Safely splits space-separated values (such as those for `background`,
  10802. * `border-radius`, and other shorthand properties).
  10803. *
  10804. * @param {string} string Space-separated values.
  10805. *
  10806. * @return {string[]} Split values.
  10807. *
  10808. * @example
  10809. * postcss.list.space('1px calc(10% + 1px)') //=> ['1px', 'calc(10% + 1px)']
  10810. */
  10811. space: function space(string) {
  10812. var spaces = [' ', '\n', '\t'];
  10813. return list.split(string, spaces);
  10814. },
  10815. /**
  10816. * Safely splits comma-separated values (such as those for `transition-*`
  10817. * and `background` properties).
  10818. *
  10819. * @param {string} string Comma-separated values.
  10820. *
  10821. * @return {string[]} Split values.
  10822. *
  10823. * @example
  10824. * postcss.list.comma('black, linear-gradient(white, black)')
  10825. * //=> ['black', 'linear-gradient(white, black)']
  10826. */
  10827. comma: function comma(string) {
  10828. return list.split(string, [','], true);
  10829. }
  10830. };
  10831. var _default = list;
  10832. exports.default = _default;
  10833. module.exports = exports.default;
  10834. },{}],177:[function(require,module,exports){
  10835. (function (Buffer){
  10836. "use strict";
  10837. exports.__esModule = true;
  10838. exports.default = void 0;
  10839. var _sourceMap = _interopRequireDefault(require("source-map"));
  10840. var _path = _interopRequireDefault(require("path"));
  10841. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  10842. function _createForOfIteratorHelperLoose(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } it = o[Symbol.iterator](); return it.next.bind(it); }
  10843. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  10844. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  10845. var MapGenerator = /*#__PURE__*/function () {
  10846. function MapGenerator(stringify, root, opts) {
  10847. this.stringify = stringify;
  10848. this.mapOpts = opts.map || {};
  10849. this.root = root;
  10850. this.opts = opts;
  10851. }
  10852. var _proto = MapGenerator.prototype;
  10853. _proto.isMap = function isMap() {
  10854. if (typeof this.opts.map !== 'undefined') {
  10855. return !!this.opts.map;
  10856. }
  10857. return this.previous().length > 0;
  10858. };
  10859. _proto.previous = function previous() {
  10860. var _this = this;
  10861. if (!this.previousMaps) {
  10862. this.previousMaps = [];
  10863. this.root.walk(function (node) {
  10864. if (node.source && node.source.input.map) {
  10865. var map = node.source.input.map;
  10866. if (_this.previousMaps.indexOf(map) === -1) {
  10867. _this.previousMaps.push(map);
  10868. }
  10869. }
  10870. });
  10871. }
  10872. return this.previousMaps;
  10873. };
  10874. _proto.isInline = function isInline() {
  10875. if (typeof this.mapOpts.inline !== 'undefined') {
  10876. return this.mapOpts.inline;
  10877. }
  10878. var annotation = this.mapOpts.annotation;
  10879. if (typeof annotation !== 'undefined' && annotation !== true) {
  10880. return false;
  10881. }
  10882. if (this.previous().length) {
  10883. return this.previous().some(function (i) {
  10884. return i.inline;
  10885. });
  10886. }
  10887. return true;
  10888. };
  10889. _proto.isSourcesContent = function isSourcesContent() {
  10890. if (typeof this.mapOpts.sourcesContent !== 'undefined') {
  10891. return this.mapOpts.sourcesContent;
  10892. }
  10893. if (this.previous().length) {
  10894. return this.previous().some(function (i) {
  10895. return i.withContent();
  10896. });
  10897. }
  10898. return true;
  10899. };
  10900. _proto.clearAnnotation = function clearAnnotation() {
  10901. if (this.mapOpts.annotation === false) return;
  10902. var node;
  10903. for (var i = this.root.nodes.length - 1; i >= 0; i--) {
  10904. node = this.root.nodes[i];
  10905. if (node.type !== 'comment') continue;
  10906. if (node.text.indexOf('# sourceMappingURL=') === 0) {
  10907. this.root.removeChild(i);
  10908. }
  10909. }
  10910. };
  10911. _proto.setSourcesContent = function setSourcesContent() {
  10912. var _this2 = this;
  10913. var already = {};
  10914. this.root.walk(function (node) {
  10915. if (node.source) {
  10916. var from = node.source.input.from;
  10917. if (from && !already[from]) {
  10918. already[from] = true;
  10919. var relative = _this2.relative(from);
  10920. _this2.map.setSourceContent(relative, node.source.input.css);
  10921. }
  10922. }
  10923. });
  10924. };
  10925. _proto.applyPrevMaps = function applyPrevMaps() {
  10926. for (var _iterator = _createForOfIteratorHelperLoose(this.previous()), _step; !(_step = _iterator()).done;) {
  10927. var prev = _step.value;
  10928. var from = this.relative(prev.file);
  10929. var root = prev.root || _path.default.dirname(prev.file);
  10930. var map = void 0;
  10931. if (this.mapOpts.sourcesContent === false) {
  10932. map = new _sourceMap.default.SourceMapConsumer(prev.text);
  10933. if (map.sourcesContent) {
  10934. map.sourcesContent = map.sourcesContent.map(function () {
  10935. return null;
  10936. });
  10937. }
  10938. } else {
  10939. map = prev.consumer();
  10940. }
  10941. this.map.applySourceMap(map, from, this.relative(root));
  10942. }
  10943. };
  10944. _proto.isAnnotation = function isAnnotation() {
  10945. if (this.isInline()) {
  10946. return true;
  10947. }
  10948. if (typeof this.mapOpts.annotation !== 'undefined') {
  10949. return this.mapOpts.annotation;
  10950. }
  10951. if (this.previous().length) {
  10952. return this.previous().some(function (i) {
  10953. return i.annotation;
  10954. });
  10955. }
  10956. return true;
  10957. };
  10958. _proto.toBase64 = function toBase64(str) {
  10959. if (Buffer) {
  10960. return Buffer.from(str).toString('base64');
  10961. }
  10962. return window.btoa(unescape(encodeURIComponent(str)));
  10963. };
  10964. _proto.addAnnotation = function addAnnotation() {
  10965. var content;
  10966. if (this.isInline()) {
  10967. content = 'data:application/json;base64,' + this.toBase64(this.map.toString());
  10968. } else if (typeof this.mapOpts.annotation === 'string') {
  10969. content = this.mapOpts.annotation;
  10970. } else {
  10971. content = this.outputFile() + '.map';
  10972. }
  10973. var eol = '\n';
  10974. if (this.css.indexOf('\r\n') !== -1) eol = '\r\n';
  10975. this.css += eol + '/*# sourceMappingURL=' + content + ' */';
  10976. };
  10977. _proto.outputFile = function outputFile() {
  10978. if (this.opts.to) {
  10979. return this.relative(this.opts.to);
  10980. }
  10981. if (this.opts.from) {
  10982. return this.relative(this.opts.from);
  10983. }
  10984. return 'to.css';
  10985. };
  10986. _proto.generateMap = function generateMap() {
  10987. this.generateString();
  10988. if (this.isSourcesContent()) this.setSourcesContent();
  10989. if (this.previous().length > 0) this.applyPrevMaps();
  10990. if (this.isAnnotation()) this.addAnnotation();
  10991. if (this.isInline()) {
  10992. return [this.css];
  10993. }
  10994. return [this.css, this.map];
  10995. };
  10996. _proto.relative = function relative(file) {
  10997. if (file.indexOf('<') === 0) return file;
  10998. if (/^\w+:\/\//.test(file)) return file;
  10999. var from = this.opts.to ? _path.default.dirname(this.opts.to) : '.';
  11000. if (typeof this.mapOpts.annotation === 'string') {
  11001. from = _path.default.dirname(_path.default.resolve(from, this.mapOpts.annotation));
  11002. }
  11003. file = _path.default.relative(from, file);
  11004. if (_path.default.sep === '\\') {
  11005. return file.replace(/\\/g, '/');
  11006. }
  11007. return file;
  11008. };
  11009. _proto.sourcePath = function sourcePath(node) {
  11010. if (this.mapOpts.from) {
  11011. return this.mapOpts.from;
  11012. }
  11013. return this.relative(node.source.input.from);
  11014. };
  11015. _proto.generateString = function generateString() {
  11016. var _this3 = this;
  11017. this.css = '';
  11018. this.map = new _sourceMap.default.SourceMapGenerator({
  11019. file: this.outputFile()
  11020. });
  11021. var line = 1;
  11022. var column = 1;
  11023. var lines, last;
  11024. this.stringify(this.root, function (str, node, type) {
  11025. _this3.css += str;
  11026. if (node && type !== 'end') {
  11027. if (node.source && node.source.start) {
  11028. _this3.map.addMapping({
  11029. source: _this3.sourcePath(node),
  11030. generated: {
  11031. line: line,
  11032. column: column - 1
  11033. },
  11034. original: {
  11035. line: node.source.start.line,
  11036. column: node.source.start.column - 1
  11037. }
  11038. });
  11039. } else {
  11040. _this3.map.addMapping({
  11041. source: '<no source>',
  11042. original: {
  11043. line: 1,
  11044. column: 0
  11045. },
  11046. generated: {
  11047. line: line,
  11048. column: column - 1
  11049. }
  11050. });
  11051. }
  11052. }
  11053. lines = str.match(/\n/g);
  11054. if (lines) {
  11055. line += lines.length;
  11056. last = str.lastIndexOf('\n');
  11057. column = str.length - last;
  11058. } else {
  11059. column += str.length;
  11060. }
  11061. if (node && type !== 'start') {
  11062. var p = node.parent || {
  11063. raws: {}
  11064. };
  11065. if (node.type !== 'decl' || node !== p.last || p.raws.semicolon) {
  11066. if (node.source && node.source.end) {
  11067. _this3.map.addMapping({
  11068. source: _this3.sourcePath(node),
  11069. generated: {
  11070. line: line,
  11071. column: column - 2
  11072. },
  11073. original: {
  11074. line: node.source.end.line,
  11075. column: node.source.end.column - 1
  11076. }
  11077. });
  11078. } else {
  11079. _this3.map.addMapping({
  11080. source: '<no source>',
  11081. original: {
  11082. line: 1,
  11083. column: 0
  11084. },
  11085. generated: {
  11086. line: line,
  11087. column: column - 1
  11088. }
  11089. });
  11090. }
  11091. }
  11092. }
  11093. });
  11094. };
  11095. _proto.generate = function generate() {
  11096. this.clearAnnotation();
  11097. if (this.isMap()) {
  11098. return this.generateMap();
  11099. }
  11100. var result = '';
  11101. this.stringify(this.root, function (i) {
  11102. result += i;
  11103. });
  11104. return [result];
  11105. };
  11106. return MapGenerator;
  11107. }();
  11108. var _default = MapGenerator;
  11109. exports.default = _default;
  11110. module.exports = exports.default;
  11111. }).call(this,require("buffer").Buffer)
  11112. },{"buffer":3,"path":168,"source-map":208}],178:[function(require,module,exports){
  11113. (function (process){
  11114. "use strict";
  11115. exports.__esModule = true;
  11116. exports.default = void 0;
  11117. var _cssSyntaxError = _interopRequireDefault(require("./css-syntax-error"));
  11118. var _stringifier = _interopRequireDefault(require("./stringifier"));
  11119. var _stringify = _interopRequireDefault(require("./stringify"));
  11120. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  11121. function cloneNode(obj, parent) {
  11122. var cloned = new obj.constructor();
  11123. for (var i in obj) {
  11124. if (!obj.hasOwnProperty(i)) continue;
  11125. var value = obj[i];
  11126. var type = typeof value;
  11127. if (i === 'parent' && type === 'object') {
  11128. if (parent) cloned[i] = parent;
  11129. } else if (i === 'source') {
  11130. cloned[i] = value;
  11131. } else if (value instanceof Array) {
  11132. cloned[i] = value.map(function (j) {
  11133. return cloneNode(j, cloned);
  11134. });
  11135. } else {
  11136. if (type === 'object' && value !== null) value = cloneNode(value);
  11137. cloned[i] = value;
  11138. }
  11139. }
  11140. return cloned;
  11141. }
  11142. /**
  11143. * All node classes inherit the following common methods.
  11144. *
  11145. * @abstract
  11146. */
  11147. var Node = /*#__PURE__*/function () {
  11148. /**
  11149. * @param {object} [defaults] Value for node properties.
  11150. */
  11151. function Node(defaults) {
  11152. if (defaults === void 0) {
  11153. defaults = {};
  11154. }
  11155. this.raws = {};
  11156. if (process.env.NODE_ENV !== 'production') {
  11157. if (typeof defaults !== 'object' && typeof defaults !== 'undefined') {
  11158. throw new Error('PostCSS nodes constructor accepts object, not ' + JSON.stringify(defaults));
  11159. }
  11160. }
  11161. for (var name in defaults) {
  11162. this[name] = defaults[name];
  11163. }
  11164. }
  11165. /**
  11166. * Returns a `CssSyntaxError` instance containing the original position
  11167. * of the node in the source, showing line and column numbers and also
  11168. * a small excerpt to facilitate debugging.
  11169. *
  11170. * If present, an input source map will be used to get the original position
  11171. * of the source, even from a previous compilation step
  11172. * (e.g., from Sass compilation).
  11173. *
  11174. * This method produces very useful error messages.
  11175. *
  11176. * @param {string} message Error description.
  11177. * @param {object} [opts] Options.
  11178. * @param {string} opts.plugin Plugin name that created this error.
  11179. * PostCSS will set it automatically.
  11180. * @param {string} opts.word A word inside a node’s string that should
  11181. * be highlighted as the source of the error.
  11182. * @param {number} opts.index An index inside a node’s string that should
  11183. * be highlighted as the source of the error.
  11184. *
  11185. * @return {CssSyntaxError} Error object to throw it.
  11186. *
  11187. * @example
  11188. * if (!variables[name]) {
  11189. * throw decl.error('Unknown variable ' + name, { word: name })
  11190. * // CssSyntaxError: postcss-vars:a.sass:4:3: Unknown variable $black
  11191. * // color: $black
  11192. * // a
  11193. * // ^
  11194. * // background: white
  11195. * }
  11196. */
  11197. var _proto = Node.prototype;
  11198. _proto.error = function error(message, opts) {
  11199. if (opts === void 0) {
  11200. opts = {};
  11201. }
  11202. if (this.source) {
  11203. var pos = this.positionBy(opts);
  11204. return this.source.input.error(message, pos.line, pos.column, opts);
  11205. }
  11206. return new _cssSyntaxError.default(message);
  11207. }
  11208. /**
  11209. * This method is provided as a convenience wrapper for {@link Result#warn}.
  11210. *
  11211. * @param {Result} result The {@link Result} instance
  11212. * that will receive the warning.
  11213. * @param {string} text Warning message.
  11214. * @param {object} [opts] Options
  11215. * @param {string} opts.plugin Plugin name that created this warning.
  11216. * PostCSS will set it automatically.
  11217. * @param {string} opts.word A word inside a node’s string that should
  11218. * be highlighted as the source of the warning.
  11219. * @param {number} opts.index An index inside a node’s string that should
  11220. * be highlighted as the source of the warning.
  11221. *
  11222. * @return {Warning} Created warning object.
  11223. *
  11224. * @example
  11225. * const plugin = postcss.plugin('postcss-deprecated', () => {
  11226. * return (root, result) => {
  11227. * root.walkDecls('bad', decl => {
  11228. * decl.warn(result, 'Deprecated property bad')
  11229. * })
  11230. * }
  11231. * })
  11232. */
  11233. ;
  11234. _proto.warn = function warn(result, text, opts) {
  11235. var data = {
  11236. node: this
  11237. };
  11238. for (var i in opts) {
  11239. data[i] = opts[i];
  11240. }
  11241. return result.warn(text, data);
  11242. }
  11243. /**
  11244. * Removes the node from its parent and cleans the parent properties
  11245. * from the node and its children.
  11246. *
  11247. * @example
  11248. * if (decl.prop.match(/^-webkit-/)) {
  11249. * decl.remove()
  11250. * }
  11251. *
  11252. * @return {Node} Node to make calls chain.
  11253. */
  11254. ;
  11255. _proto.remove = function remove() {
  11256. if (this.parent) {
  11257. this.parent.removeChild(this);
  11258. }
  11259. this.parent = undefined;
  11260. return this;
  11261. }
  11262. /**
  11263. * Returns a CSS string representing the node.
  11264. *
  11265. * @param {stringifier|syntax} [stringifier] A syntax to use
  11266. * in string generation.
  11267. *
  11268. * @return {string} CSS string of this node.
  11269. *
  11270. * @example
  11271. * postcss.rule({ selector: 'a' }).toString() //=> "a {}"
  11272. */
  11273. ;
  11274. _proto.toString = function toString(stringifier) {
  11275. if (stringifier === void 0) {
  11276. stringifier = _stringify.default;
  11277. }
  11278. if (stringifier.stringify) stringifier = stringifier.stringify;
  11279. var result = '';
  11280. stringifier(this, function (i) {
  11281. result += i;
  11282. });
  11283. return result;
  11284. }
  11285. /**
  11286. * Returns an exact clone of the node.
  11287. *
  11288. * The resulting cloned node and its (cloned) children will retain
  11289. * code style properties.
  11290. *
  11291. * @param {object} [overrides] New properties to override in the clone.
  11292. *
  11293. * @example
  11294. * decl.raws.before //=> "\n "
  11295. * const cloned = decl.clone({ prop: '-moz-' + decl.prop })
  11296. * cloned.raws.before //=> "\n "
  11297. * cloned.toString() //=> -moz-transform: scale(0)
  11298. *
  11299. * @return {Node} Clone of the node.
  11300. */
  11301. ;
  11302. _proto.clone = function clone(overrides) {
  11303. if (overrides === void 0) {
  11304. overrides = {};
  11305. }
  11306. var cloned = cloneNode(this);
  11307. for (var name in overrides) {
  11308. cloned[name] = overrides[name];
  11309. }
  11310. return cloned;
  11311. }
  11312. /**
  11313. * Shortcut to clone the node and insert the resulting cloned node
  11314. * before the current node.
  11315. *
  11316. * @param {object} [overrides] Mew properties to override in the clone.
  11317. *
  11318. * @example
  11319. * decl.cloneBefore({ prop: '-moz-' + decl.prop })
  11320. *
  11321. * @return {Node} New node
  11322. */
  11323. ;
  11324. _proto.cloneBefore = function cloneBefore(overrides) {
  11325. if (overrides === void 0) {
  11326. overrides = {};
  11327. }
  11328. var cloned = this.clone(overrides);
  11329. this.parent.insertBefore(this, cloned);
  11330. return cloned;
  11331. }
  11332. /**
  11333. * Shortcut to clone the node and insert the resulting cloned node
  11334. * after the current node.
  11335. *
  11336. * @param {object} [overrides] New properties to override in the clone.
  11337. *
  11338. * @return {Node} New node.
  11339. */
  11340. ;
  11341. _proto.cloneAfter = function cloneAfter(overrides) {
  11342. if (overrides === void 0) {
  11343. overrides = {};
  11344. }
  11345. var cloned = this.clone(overrides);
  11346. this.parent.insertAfter(this, cloned);
  11347. return cloned;
  11348. }
  11349. /**
  11350. * Inserts node(s) before the current node and removes the current node.
  11351. *
  11352. * @param {...Node} nodes Mode(s) to replace current one.
  11353. *
  11354. * @example
  11355. * if (atrule.name === 'mixin') {
  11356. * atrule.replaceWith(mixinRules[atrule.params])
  11357. * }
  11358. *
  11359. * @return {Node} Current node to methods chain.
  11360. */
  11361. ;
  11362. _proto.replaceWith = function replaceWith() {
  11363. if (this.parent) {
  11364. for (var _len = arguments.length, nodes = new Array(_len), _key = 0; _key < _len; _key++) {
  11365. nodes[_key] = arguments[_key];
  11366. }
  11367. for (var _i = 0, _nodes = nodes; _i < _nodes.length; _i++) {
  11368. var node = _nodes[_i];
  11369. this.parent.insertBefore(this, node);
  11370. }
  11371. this.remove();
  11372. }
  11373. return this;
  11374. }
  11375. /**
  11376. * Returns the next child of the node’s parent.
  11377. * Returns `undefined` if the current node is the last child.
  11378. *
  11379. * @return {Node|undefined} Next node.
  11380. *
  11381. * @example
  11382. * if (comment.text === 'delete next') {
  11383. * const next = comment.next()
  11384. * if (next) {
  11385. * next.remove()
  11386. * }
  11387. * }
  11388. */
  11389. ;
  11390. _proto.next = function next() {
  11391. if (!this.parent) return undefined;
  11392. var index = this.parent.index(this);
  11393. return this.parent.nodes[index + 1];
  11394. }
  11395. /**
  11396. * Returns the previous child of the node’s parent.
  11397. * Returns `undefined` if the current node is the first child.
  11398. *
  11399. * @return {Node|undefined} Previous node.
  11400. *
  11401. * @example
  11402. * const annotation = decl.prev()
  11403. * if (annotation.type === 'comment') {
  11404. * readAnnotation(annotation.text)
  11405. * }
  11406. */
  11407. ;
  11408. _proto.prev = function prev() {
  11409. if (!this.parent) return undefined;
  11410. var index = this.parent.index(this);
  11411. return this.parent.nodes[index - 1];
  11412. }
  11413. /**
  11414. * Insert new node before current node to current node’s parent.
  11415. *
  11416. * Just alias for `node.parent.insertBefore(node, add)`.
  11417. *
  11418. * @param {Node|object|string|Node[]} add New node.
  11419. *
  11420. * @return {Node} This node for methods chain.
  11421. *
  11422. * @example
  11423. * decl.before('content: ""')
  11424. */
  11425. ;
  11426. _proto.before = function before(add) {
  11427. this.parent.insertBefore(this, add);
  11428. return this;
  11429. }
  11430. /**
  11431. * Insert new node after current node to current node’s parent.
  11432. *
  11433. * Just alias for `node.parent.insertAfter(node, add)`.
  11434. *
  11435. * @param {Node|object|string|Node[]} add New node.
  11436. *
  11437. * @return {Node} This node for methods chain.
  11438. *
  11439. * @example
  11440. * decl.after('color: black')
  11441. */
  11442. ;
  11443. _proto.after = function after(add) {
  11444. this.parent.insertAfter(this, add);
  11445. return this;
  11446. };
  11447. _proto.toJSON = function toJSON() {
  11448. var fixed = {};
  11449. for (var name in this) {
  11450. if (!this.hasOwnProperty(name)) continue;
  11451. if (name === 'parent') continue;
  11452. var value = this[name];
  11453. if (value instanceof Array) {
  11454. fixed[name] = value.map(function (i) {
  11455. if (typeof i === 'object' && i.toJSON) {
  11456. return i.toJSON();
  11457. } else {
  11458. return i;
  11459. }
  11460. });
  11461. } else if (typeof value === 'object' && value.toJSON) {
  11462. fixed[name] = value.toJSON();
  11463. } else {
  11464. fixed[name] = value;
  11465. }
  11466. }
  11467. return fixed;
  11468. }
  11469. /**
  11470. * Returns a {@link Node#raws} value. If the node is missing
  11471. * the code style property (because the node was manually built or cloned),
  11472. * PostCSS will try to autodetect the code style property by looking
  11473. * at other nodes in the tree.
  11474. *
  11475. * @param {string} prop Name of code style property.
  11476. * @param {string} [defaultType] Name of default value, it can be missed
  11477. * if the value is the same as prop.
  11478. *
  11479. * @example
  11480. * const root = postcss.parse('a { background: white }')
  11481. * root.nodes[0].append({ prop: 'color', value: 'black' })
  11482. * root.nodes[0].nodes[1].raws.before //=> undefined
  11483. * root.nodes[0].nodes[1].raw('before') //=> ' '
  11484. *
  11485. * @return {string} Code style value.
  11486. */
  11487. ;
  11488. _proto.raw = function raw(prop, defaultType) {
  11489. var str = new _stringifier.default();
  11490. return str.raw(this, prop, defaultType);
  11491. }
  11492. /**
  11493. * Finds the Root instance of the node’s tree.
  11494. *
  11495. * @example
  11496. * root.nodes[0].nodes[0].root() === root
  11497. *
  11498. * @return {Root} Root parent.
  11499. */
  11500. ;
  11501. _proto.root = function root() {
  11502. var result = this;
  11503. while (result.parent) {
  11504. result = result.parent;
  11505. }
  11506. return result;
  11507. }
  11508. /**
  11509. * Clear the code style properties for the node and its children.
  11510. *
  11511. * @param {boolean} [keepBetween] Keep the raws.between symbols.
  11512. *
  11513. * @return {undefined}
  11514. *
  11515. * @example
  11516. * node.raws.before //=> ' '
  11517. * node.cleanRaws()
  11518. * node.raws.before //=> undefined
  11519. */
  11520. ;
  11521. _proto.cleanRaws = function cleanRaws(keepBetween) {
  11522. delete this.raws.before;
  11523. delete this.raws.after;
  11524. if (!keepBetween) delete this.raws.between;
  11525. };
  11526. _proto.positionInside = function positionInside(index) {
  11527. var string = this.toString();
  11528. var column = this.source.start.column;
  11529. var line = this.source.start.line;
  11530. for (var i = 0; i < index; i++) {
  11531. if (string[i] === '\n') {
  11532. column = 1;
  11533. line += 1;
  11534. } else {
  11535. column += 1;
  11536. }
  11537. }
  11538. return {
  11539. line: line,
  11540. column: column
  11541. };
  11542. };
  11543. _proto.positionBy = function positionBy(opts) {
  11544. var pos = this.source.start;
  11545. if (opts.index) {
  11546. pos = this.positionInside(opts.index);
  11547. } else if (opts.word) {
  11548. var index = this.toString().indexOf(opts.word);
  11549. if (index !== -1) pos = this.positionInside(index);
  11550. }
  11551. return pos;
  11552. }
  11553. /**
  11554. * @memberof Node#
  11555. * @member {string} type String representing the node’s type.
  11556. * Possible values are `root`, `atrule`, `rule`,
  11557. * `decl`, or `comment`.
  11558. *
  11559. * @example
  11560. * postcss.decl({ prop: 'color', value: 'black' }).type //=> 'decl'
  11561. */
  11562. /**
  11563. * @memberof Node#
  11564. * @member {Container} parent The node’s parent node.
  11565. *
  11566. * @example
  11567. * root.nodes[0].parent === root
  11568. */
  11569. /**
  11570. * @memberof Node#
  11571. * @member {source} source The input source of the node.
  11572. *
  11573. * The property is used in source map generation.
  11574. *
  11575. * If you create a node manually (e.g., with `postcss.decl()`),
  11576. * that node will not have a `source` property and will be absent
  11577. * from the source map. For this reason, the plugin developer should
  11578. * consider cloning nodes to create new ones (in which case the new node’s
  11579. * source will reference the original, cloned node) or setting
  11580. * the `source` property manually.
  11581. *
  11582. * ```js
  11583. * // Bad
  11584. * const prefixed = postcss.decl({
  11585. * prop: '-moz-' + decl.prop,
  11586. * value: decl.value
  11587. * })
  11588. *
  11589. * // Good
  11590. * const prefixed = decl.clone({ prop: '-moz-' + decl.prop })
  11591. * ```
  11592. *
  11593. * ```js
  11594. * if (atrule.name === 'add-link') {
  11595. * const rule = postcss.rule({ selector: 'a', source: atrule.source })
  11596. * atrule.parent.insertBefore(atrule, rule)
  11597. * }
  11598. * ```
  11599. *
  11600. * @example
  11601. * decl.source.input.from //=> '/home/ai/a.sass'
  11602. * decl.source.start //=> { line: 10, column: 2 }
  11603. * decl.source.end //=> { line: 10, column: 12 }
  11604. */
  11605. /**
  11606. * @memberof Node#
  11607. * @member {object} raws Information to generate byte-to-byte equal
  11608. * node string as it was in the origin input.
  11609. *
  11610. * Every parser saves its own properties,
  11611. * but the default CSS parser uses:
  11612. *
  11613. * * `before`: the space symbols before the node. It also stores `*`
  11614. * and `_` symbols before the declaration (IE hack).
  11615. * * `after`: the space symbols after the last child of the node
  11616. * to the end of the node.
  11617. * * `between`: the symbols between the property and value
  11618. * for declarations, selector and `{` for rules, or last parameter
  11619. * and `{` for at-rules.
  11620. * * `semicolon`: contains true if the last child has
  11621. * an (optional) semicolon.
  11622. * * `afterName`: the space between the at-rule name and its parameters.
  11623. * * `left`: the space symbols between `/*` and the comment’s text.
  11624. * * `right`: the space symbols between the comment’s text
  11625. * and <code>*&#47;</code>.
  11626. * * `important`: the content of the important statement,
  11627. * if it is not just `!important`.
  11628. *
  11629. * PostCSS cleans selectors, declaration values and at-rule parameters
  11630. * from comments and extra spaces, but it stores origin content in raws
  11631. * properties. As such, if you don’t change a declaration’s value,
  11632. * PostCSS will use the raw value with comments.
  11633. *
  11634. * @example
  11635. * const root = postcss.parse('a {\n color:black\n}')
  11636. * root.first.first.raws //=> { before: '\n ', between: ':' }
  11637. */
  11638. ;
  11639. return Node;
  11640. }();
  11641. var _default = Node;
  11642. /**
  11643. * @typedef {object} position
  11644. * @property {number} line Source line in file.
  11645. * @property {number} column Source column in file.
  11646. */
  11647. /**
  11648. * @typedef {object} source
  11649. * @property {Input} input {@link Input} with input file
  11650. * @property {position} start The starting position of the node’s source.
  11651. * @property {position} end The ending position of the node’s source.
  11652. */
  11653. exports.default = _default;
  11654. module.exports = exports.default;
  11655. }).call(this,require('_process'))
  11656. },{"./css-syntax-error":172,"./stringifier":187,"./stringify":188,"_process":193}],179:[function(require,module,exports){
  11657. (function (process){
  11658. "use strict";
  11659. exports.__esModule = true;
  11660. exports.default = void 0;
  11661. var _parser = _interopRequireDefault(require("./parser"));
  11662. var _input = _interopRequireDefault(require("./input"));
  11663. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  11664. function parse(css, opts) {
  11665. var input = new _input.default(css, opts);
  11666. var parser = new _parser.default(input);
  11667. try {
  11668. parser.parse();
  11669. } catch (e) {
  11670. if (process.env.NODE_ENV !== 'production') {
  11671. if (e.name === 'CssSyntaxError' && opts && opts.from) {
  11672. if (/\.scss$/i.test(opts.from)) {
  11673. e.message += '\nYou tried to parse SCSS with ' + 'the standard CSS parser; ' + 'try again with the postcss-scss parser';
  11674. } else if (/\.sass/i.test(opts.from)) {
  11675. e.message += '\nYou tried to parse Sass with ' + 'the standard CSS parser; ' + 'try again with the postcss-sass parser';
  11676. } else if (/\.less$/i.test(opts.from)) {
  11677. e.message += '\nYou tried to parse Less with ' + 'the standard CSS parser; ' + 'try again with the postcss-less parser';
  11678. }
  11679. }
  11680. }
  11681. throw e;
  11682. }
  11683. return parser.root;
  11684. }
  11685. var _default = parse;
  11686. exports.default = _default;
  11687. module.exports = exports.default;
  11688. }).call(this,require('_process'))
  11689. },{"./input":174,"./parser":180,"_process":193}],180:[function(require,module,exports){
  11690. "use strict";
  11691. exports.__esModule = true;
  11692. exports.default = void 0;
  11693. var _declaration = _interopRequireDefault(require("./declaration"));
  11694. var _tokenize = _interopRequireDefault(require("./tokenize"));
  11695. var _comment = _interopRequireDefault(require("./comment"));
  11696. var _atRule = _interopRequireDefault(require("./at-rule"));
  11697. var _root = _interopRequireDefault(require("./root"));
  11698. var _rule = _interopRequireDefault(require("./rule"));
  11699. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  11700. var Parser = /*#__PURE__*/function () {
  11701. function Parser(input) {
  11702. this.input = input;
  11703. this.root = new _root.default();
  11704. this.current = this.root;
  11705. this.spaces = '';
  11706. this.semicolon = false;
  11707. this.createTokenizer();
  11708. this.root.source = {
  11709. input: input,
  11710. start: {
  11711. line: 1,
  11712. column: 1
  11713. }
  11714. };
  11715. }
  11716. var _proto = Parser.prototype;
  11717. _proto.createTokenizer = function createTokenizer() {
  11718. this.tokenizer = (0, _tokenize.default)(this.input);
  11719. };
  11720. _proto.parse = function parse() {
  11721. var token;
  11722. while (!this.tokenizer.endOfFile()) {
  11723. token = this.tokenizer.nextToken();
  11724. switch (token[0]) {
  11725. case 'space':
  11726. this.spaces += token[1];
  11727. break;
  11728. case ';':
  11729. this.freeSemicolon(token);
  11730. break;
  11731. case '}':
  11732. this.end(token);
  11733. break;
  11734. case 'comment':
  11735. this.comment(token);
  11736. break;
  11737. case 'at-word':
  11738. this.atrule(token);
  11739. break;
  11740. case '{':
  11741. this.emptyRule(token);
  11742. break;
  11743. default:
  11744. this.other(token);
  11745. break;
  11746. }
  11747. }
  11748. this.endFile();
  11749. };
  11750. _proto.comment = function comment(token) {
  11751. var node = new _comment.default();
  11752. this.init(node, token[2], token[3]);
  11753. node.source.end = {
  11754. line: token[4],
  11755. column: token[5]
  11756. };
  11757. var text = token[1].slice(2, -2);
  11758. if (/^\s*$/.test(text)) {
  11759. node.text = '';
  11760. node.raws.left = text;
  11761. node.raws.right = '';
  11762. } else {
  11763. var match = text.match(/^(\s*)([^]*[^\s])(\s*)$/);
  11764. node.text = match[2];
  11765. node.raws.left = match[1];
  11766. node.raws.right = match[3];
  11767. }
  11768. };
  11769. _proto.emptyRule = function emptyRule(token) {
  11770. var node = new _rule.default();
  11771. this.init(node, token[2], token[3]);
  11772. node.selector = '';
  11773. node.raws.between = '';
  11774. this.current = node;
  11775. };
  11776. _proto.other = function other(start) {
  11777. var end = false;
  11778. var type = null;
  11779. var colon = false;
  11780. var bracket = null;
  11781. var brackets = [];
  11782. var tokens = [];
  11783. var token = start;
  11784. while (token) {
  11785. type = token[0];
  11786. tokens.push(token);
  11787. if (type === '(' || type === '[') {
  11788. if (!bracket) bracket = token;
  11789. brackets.push(type === '(' ? ')' : ']');
  11790. } else if (brackets.length === 0) {
  11791. if (type === ';') {
  11792. if (colon) {
  11793. this.decl(tokens);
  11794. return;
  11795. } else {
  11796. break;
  11797. }
  11798. } else if (type === '{') {
  11799. this.rule(tokens);
  11800. return;
  11801. } else if (type === '}') {
  11802. this.tokenizer.back(tokens.pop());
  11803. end = true;
  11804. break;
  11805. } else if (type === ':') {
  11806. colon = true;
  11807. }
  11808. } else if (type === brackets[brackets.length - 1]) {
  11809. brackets.pop();
  11810. if (brackets.length === 0) bracket = null;
  11811. }
  11812. token = this.tokenizer.nextToken();
  11813. }
  11814. if (this.tokenizer.endOfFile()) end = true;
  11815. if (brackets.length > 0) this.unclosedBracket(bracket);
  11816. if (end && colon) {
  11817. while (tokens.length) {
  11818. token = tokens[tokens.length - 1][0];
  11819. if (token !== 'space' && token !== 'comment') break;
  11820. this.tokenizer.back(tokens.pop());
  11821. }
  11822. this.decl(tokens);
  11823. } else {
  11824. this.unknownWord(tokens);
  11825. }
  11826. };
  11827. _proto.rule = function rule(tokens) {
  11828. tokens.pop();
  11829. var node = new _rule.default();
  11830. this.init(node, tokens[0][2], tokens[0][3]);
  11831. node.raws.between = this.spacesAndCommentsFromEnd(tokens);
  11832. this.raw(node, 'selector', tokens);
  11833. this.current = node;
  11834. };
  11835. _proto.decl = function decl(tokens) {
  11836. var node = new _declaration.default();
  11837. this.init(node);
  11838. var last = tokens[tokens.length - 1];
  11839. if (last[0] === ';') {
  11840. this.semicolon = true;
  11841. tokens.pop();
  11842. }
  11843. if (last[4]) {
  11844. node.source.end = {
  11845. line: last[4],
  11846. column: last[5]
  11847. };
  11848. } else {
  11849. node.source.end = {
  11850. line: last[2],
  11851. column: last[3]
  11852. };
  11853. }
  11854. while (tokens[0][0] !== 'word') {
  11855. if (tokens.length === 1) this.unknownWord(tokens);
  11856. node.raws.before += tokens.shift()[1];
  11857. }
  11858. node.source.start = {
  11859. line: tokens[0][2],
  11860. column: tokens[0][3]
  11861. };
  11862. node.prop = '';
  11863. while (tokens.length) {
  11864. var type = tokens[0][0];
  11865. if (type === ':' || type === 'space' || type === 'comment') {
  11866. break;
  11867. }
  11868. node.prop += tokens.shift()[1];
  11869. }
  11870. node.raws.between = '';
  11871. var token;
  11872. while (tokens.length) {
  11873. token = tokens.shift();
  11874. if (token[0] === ':') {
  11875. node.raws.between += token[1];
  11876. break;
  11877. } else {
  11878. if (token[0] === 'word' && /\w/.test(token[1])) {
  11879. this.unknownWord([token]);
  11880. }
  11881. node.raws.between += token[1];
  11882. }
  11883. }
  11884. if (node.prop[0] === '_' || node.prop[0] === '*') {
  11885. node.raws.before += node.prop[0];
  11886. node.prop = node.prop.slice(1);
  11887. }
  11888. node.raws.between += this.spacesAndCommentsFromStart(tokens);
  11889. this.precheckMissedSemicolon(tokens);
  11890. for (var i = tokens.length - 1; i > 0; i--) {
  11891. token = tokens[i];
  11892. if (token[1].toLowerCase() === '!important') {
  11893. node.important = true;
  11894. var string = this.stringFrom(tokens, i);
  11895. string = this.spacesFromEnd(tokens) + string;
  11896. if (string !== ' !important') node.raws.important = string;
  11897. break;
  11898. } else if (token[1].toLowerCase() === 'important') {
  11899. var cache = tokens.slice(0);
  11900. var str = '';
  11901. for (var j = i; j > 0; j--) {
  11902. var _type = cache[j][0];
  11903. if (str.trim().indexOf('!') === 0 && _type !== 'space') {
  11904. break;
  11905. }
  11906. str = cache.pop()[1] + str;
  11907. }
  11908. if (str.trim().indexOf('!') === 0) {
  11909. node.important = true;
  11910. node.raws.important = str;
  11911. tokens = cache;
  11912. }
  11913. }
  11914. if (token[0] !== 'space' && token[0] !== 'comment') {
  11915. break;
  11916. }
  11917. }
  11918. this.raw(node, 'value', tokens);
  11919. if (node.value.indexOf(':') !== -1) this.checkMissedSemicolon(tokens);
  11920. };
  11921. _proto.atrule = function atrule(token) {
  11922. var node = new _atRule.default();
  11923. node.name = token[1].slice(1);
  11924. if (node.name === '') {
  11925. this.unnamedAtrule(node, token);
  11926. }
  11927. this.init(node, token[2], token[3]);
  11928. var prev;
  11929. var shift;
  11930. var last = false;
  11931. var open = false;
  11932. var params = [];
  11933. while (!this.tokenizer.endOfFile()) {
  11934. token = this.tokenizer.nextToken();
  11935. if (token[0] === ';') {
  11936. node.source.end = {
  11937. line: token[2],
  11938. column: token[3]
  11939. };
  11940. this.semicolon = true;
  11941. break;
  11942. } else if (token[0] === '{') {
  11943. open = true;
  11944. break;
  11945. } else if (token[0] === '}') {
  11946. if (params.length > 0) {
  11947. shift = params.length - 1;
  11948. prev = params[shift];
  11949. while (prev && prev[0] === 'space') {
  11950. prev = params[--shift];
  11951. }
  11952. if (prev) {
  11953. node.source.end = {
  11954. line: prev[4],
  11955. column: prev[5]
  11956. };
  11957. }
  11958. }
  11959. this.end(token);
  11960. break;
  11961. } else {
  11962. params.push(token);
  11963. }
  11964. if (this.tokenizer.endOfFile()) {
  11965. last = true;
  11966. break;
  11967. }
  11968. }
  11969. node.raws.between = this.spacesAndCommentsFromEnd(params);
  11970. if (params.length) {
  11971. node.raws.afterName = this.spacesAndCommentsFromStart(params);
  11972. this.raw(node, 'params', params);
  11973. if (last) {
  11974. token = params[params.length - 1];
  11975. node.source.end = {
  11976. line: token[4],
  11977. column: token[5]
  11978. };
  11979. this.spaces = node.raws.between;
  11980. node.raws.between = '';
  11981. }
  11982. } else {
  11983. node.raws.afterName = '';
  11984. node.params = '';
  11985. }
  11986. if (open) {
  11987. node.nodes = [];
  11988. this.current = node;
  11989. }
  11990. };
  11991. _proto.end = function end(token) {
  11992. if (this.current.nodes && this.current.nodes.length) {
  11993. this.current.raws.semicolon = this.semicolon;
  11994. }
  11995. this.semicolon = false;
  11996. this.current.raws.after = (this.current.raws.after || '') + this.spaces;
  11997. this.spaces = '';
  11998. if (this.current.parent) {
  11999. this.current.source.end = {
  12000. line: token[2],
  12001. column: token[3]
  12002. };
  12003. this.current = this.current.parent;
  12004. } else {
  12005. this.unexpectedClose(token);
  12006. }
  12007. };
  12008. _proto.endFile = function endFile() {
  12009. if (this.current.parent) this.unclosedBlock();
  12010. if (this.current.nodes && this.current.nodes.length) {
  12011. this.current.raws.semicolon = this.semicolon;
  12012. }
  12013. this.current.raws.after = (this.current.raws.after || '') + this.spaces;
  12014. };
  12015. _proto.freeSemicolon = function freeSemicolon(token) {
  12016. this.spaces += token[1];
  12017. if (this.current.nodes) {
  12018. var prev = this.current.nodes[this.current.nodes.length - 1];
  12019. if (prev && prev.type === 'rule' && !prev.raws.ownSemicolon) {
  12020. prev.raws.ownSemicolon = this.spaces;
  12021. this.spaces = '';
  12022. }
  12023. }
  12024. } // Helpers
  12025. ;
  12026. _proto.init = function init(node, line, column) {
  12027. this.current.push(node);
  12028. node.source = {
  12029. start: {
  12030. line: line,
  12031. column: column
  12032. },
  12033. input: this.input
  12034. };
  12035. node.raws.before = this.spaces;
  12036. this.spaces = '';
  12037. if (node.type !== 'comment') this.semicolon = false;
  12038. };
  12039. _proto.raw = function raw(node, prop, tokens) {
  12040. var token, type;
  12041. var length = tokens.length;
  12042. var value = '';
  12043. var clean = true;
  12044. var next, prev;
  12045. var pattern = /^([.|#])?([\w])+/i;
  12046. for (var i = 0; i < length; i += 1) {
  12047. token = tokens[i];
  12048. type = token[0];
  12049. if (type === 'comment' && node.type === 'rule') {
  12050. prev = tokens[i - 1];
  12051. next = tokens[i + 1];
  12052. if (prev[0] !== 'space' && next[0] !== 'space' && pattern.test(prev[1]) && pattern.test(next[1])) {
  12053. value += token[1];
  12054. } else {
  12055. clean = false;
  12056. }
  12057. continue;
  12058. }
  12059. if (type === 'comment' || type === 'space' && i === length - 1) {
  12060. clean = false;
  12061. } else {
  12062. value += token[1];
  12063. }
  12064. }
  12065. if (!clean) {
  12066. var raw = tokens.reduce(function (all, i) {
  12067. return all + i[1];
  12068. }, '');
  12069. node.raws[prop] = {
  12070. value: value,
  12071. raw: raw
  12072. };
  12073. }
  12074. node[prop] = value;
  12075. };
  12076. _proto.spacesAndCommentsFromEnd = function spacesAndCommentsFromEnd(tokens) {
  12077. var lastTokenType;
  12078. var spaces = '';
  12079. while (tokens.length) {
  12080. lastTokenType = tokens[tokens.length - 1][0];
  12081. if (lastTokenType !== 'space' && lastTokenType !== 'comment') break;
  12082. spaces = tokens.pop()[1] + spaces;
  12083. }
  12084. return spaces;
  12085. };
  12086. _proto.spacesAndCommentsFromStart = function spacesAndCommentsFromStart(tokens) {
  12087. var next;
  12088. var spaces = '';
  12089. while (tokens.length) {
  12090. next = tokens[0][0];
  12091. if (next !== 'space' && next !== 'comment') break;
  12092. spaces += tokens.shift()[1];
  12093. }
  12094. return spaces;
  12095. };
  12096. _proto.spacesFromEnd = function spacesFromEnd(tokens) {
  12097. var lastTokenType;
  12098. var spaces = '';
  12099. while (tokens.length) {
  12100. lastTokenType = tokens[tokens.length - 1][0];
  12101. if (lastTokenType !== 'space') break;
  12102. spaces = tokens.pop()[1] + spaces;
  12103. }
  12104. return spaces;
  12105. };
  12106. _proto.stringFrom = function stringFrom(tokens, from) {
  12107. var result = '';
  12108. for (var i = from; i < tokens.length; i++) {
  12109. result += tokens[i][1];
  12110. }
  12111. tokens.splice(from, tokens.length - from);
  12112. return result;
  12113. };
  12114. _proto.colon = function colon(tokens) {
  12115. var brackets = 0;
  12116. var token, type, prev;
  12117. for (var i = 0; i < tokens.length; i++) {
  12118. token = tokens[i];
  12119. type = token[0];
  12120. if (type === '(') {
  12121. brackets += 1;
  12122. }
  12123. if (type === ')') {
  12124. brackets -= 1;
  12125. }
  12126. if (brackets === 0 && type === ':') {
  12127. if (!prev) {
  12128. this.doubleColon(token);
  12129. } else if (prev[0] === 'word' && prev[1] === 'progid') {
  12130. continue;
  12131. } else {
  12132. return i;
  12133. }
  12134. }
  12135. prev = token;
  12136. }
  12137. return false;
  12138. } // Errors
  12139. ;
  12140. _proto.unclosedBracket = function unclosedBracket(bracket) {
  12141. throw this.input.error('Unclosed bracket', bracket[2], bracket[3]);
  12142. };
  12143. _proto.unknownWord = function unknownWord(tokens) {
  12144. throw this.input.error('Unknown word', tokens[0][2], tokens[0][3]);
  12145. };
  12146. _proto.unexpectedClose = function unexpectedClose(token) {
  12147. throw this.input.error('Unexpected }', token[2], token[3]);
  12148. };
  12149. _proto.unclosedBlock = function unclosedBlock() {
  12150. var pos = this.current.source.start;
  12151. throw this.input.error('Unclosed block', pos.line, pos.column);
  12152. };
  12153. _proto.doubleColon = function doubleColon(token) {
  12154. throw this.input.error('Double colon', token[2], token[3]);
  12155. };
  12156. _proto.unnamedAtrule = function unnamedAtrule(node, token) {
  12157. throw this.input.error('At-rule without name', token[2], token[3]);
  12158. };
  12159. _proto.precheckMissedSemicolon = function precheckMissedSemicolon()
  12160. /* tokens */
  12161. {// Hook for Safe Parser
  12162. };
  12163. _proto.checkMissedSemicolon = function checkMissedSemicolon(tokens) {
  12164. var colon = this.colon(tokens);
  12165. if (colon === false) return;
  12166. var founded = 0;
  12167. var token;
  12168. for (var j = colon - 1; j >= 0; j--) {
  12169. token = tokens[j];
  12170. if (token[0] !== 'space') {
  12171. founded += 1;
  12172. if (founded === 2) break;
  12173. }
  12174. }
  12175. throw this.input.error('Missed semicolon', token[2], token[3]);
  12176. };
  12177. return Parser;
  12178. }();
  12179. exports.default = Parser;
  12180. module.exports = exports.default;
  12181. },{"./at-rule":169,"./comment":170,"./declaration":173,"./root":185,"./rule":186,"./tokenize":189}],181:[function(require,module,exports){
  12182. "use strict";
  12183. exports.__esModule = true;
  12184. exports.default = void 0;
  12185. var _declaration = _interopRequireDefault(require("./declaration"));
  12186. var _processor = _interopRequireDefault(require("./processor"));
  12187. var _stringify = _interopRequireDefault(require("./stringify"));
  12188. var _comment = _interopRequireDefault(require("./comment"));
  12189. var _atRule = _interopRequireDefault(require("./at-rule"));
  12190. var _vendor = _interopRequireDefault(require("./vendor"));
  12191. var _parse = _interopRequireDefault(require("./parse"));
  12192. var _list = _interopRequireDefault(require("./list"));
  12193. var _rule = _interopRequireDefault(require("./rule"));
  12194. var _root = _interopRequireDefault(require("./root"));
  12195. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  12196. /**
  12197. * Create a new {@link Processor} instance that will apply `plugins`
  12198. * as CSS processors.
  12199. *
  12200. * @param {Array.<Plugin|pluginFunction>|Processor} plugins PostCSS plugins.
  12201. * See {@link Processor#use} for plugin format.
  12202. *
  12203. * @return {Processor} Processor to process multiple CSS.
  12204. *
  12205. * @example
  12206. * import postcss from 'postcss'
  12207. *
  12208. * postcss(plugins).process(css, { from, to }).then(result => {
  12209. * console.log(result.css)
  12210. * })
  12211. *
  12212. * @namespace postcss
  12213. */
  12214. function postcss() {
  12215. for (var _len = arguments.length, plugins = new Array(_len), _key = 0; _key < _len; _key++) {
  12216. plugins[_key] = arguments[_key];
  12217. }
  12218. if (plugins.length === 1 && Array.isArray(plugins[0])) {
  12219. plugins = plugins[0];
  12220. }
  12221. return new _processor.default(plugins);
  12222. }
  12223. /**
  12224. * Creates a PostCSS plugin with a standard API.
  12225. *
  12226. * The newly-wrapped function will provide both the name and PostCSS
  12227. * version of the plugin.
  12228. *
  12229. * ```js
  12230. * const processor = postcss([replace])
  12231. * processor.plugins[0].postcssPlugin //=> 'postcss-replace'
  12232. * processor.plugins[0].postcssVersion //=> '6.0.0'
  12233. * ```
  12234. *
  12235. * The plugin function receives 2 arguments: {@link Root}
  12236. * and {@link Result} instance. The function should mutate the provided
  12237. * `Root` node. Alternatively, you can create a new `Root` node
  12238. * and override the `result.root` property.
  12239. *
  12240. * ```js
  12241. * const cleaner = postcss.plugin('postcss-cleaner', () => {
  12242. * return (root, result) => {
  12243. * result.root = postcss.root()
  12244. * }
  12245. * })
  12246. * ```
  12247. *
  12248. * As a convenience, plugins also expose a `process` method so that you can use
  12249. * them as standalone tools.
  12250. *
  12251. * ```js
  12252. * cleaner.process(css, processOpts, pluginOpts)
  12253. * // This is equivalent to:
  12254. * postcss([ cleaner(pluginOpts) ]).process(css, processOpts)
  12255. * ```
  12256. *
  12257. * Asynchronous plugins should return a `Promise` instance.
  12258. *
  12259. * ```js
  12260. * postcss.plugin('postcss-import', () => {
  12261. * return (root, result) => {
  12262. * return new Promise( (resolve, reject) => {
  12263. * fs.readFile('base.css', (base) => {
  12264. * root.prepend(base)
  12265. * resolve()
  12266. * })
  12267. * })
  12268. * }
  12269. * })
  12270. * ```
  12271. *
  12272. * Add warnings using the {@link Node#warn} method.
  12273. * Send data to other plugins using the {@link Result#messages} array.
  12274. *
  12275. * ```js
  12276. * postcss.plugin('postcss-caniuse-test', () => {
  12277. * return (root, result) => {
  12278. * root.walkDecls(decl => {
  12279. * if (!caniuse.support(decl.prop)) {
  12280. * decl.warn(result, 'Some browsers do not support ' + decl.prop)
  12281. * }
  12282. * })
  12283. * }
  12284. * })
  12285. * ```
  12286. *
  12287. * @param {string} name PostCSS plugin name. Same as in `name`
  12288. * property in `package.json`. It will be saved
  12289. * in `plugin.postcssPlugin` property.
  12290. * @param {function} initializer Will receive plugin options
  12291. * and should return {@link pluginFunction}
  12292. *
  12293. * @return {Plugin} PostCSS plugin.
  12294. */
  12295. postcss.plugin = function plugin(name, initializer) {
  12296. function creator() {
  12297. var transformer = initializer.apply(void 0, arguments);
  12298. transformer.postcssPlugin = name;
  12299. transformer.postcssVersion = new _processor.default().version;
  12300. return transformer;
  12301. }
  12302. var cache;
  12303. Object.defineProperty(creator, 'postcss', {
  12304. get: function get() {
  12305. if (!cache) cache = creator();
  12306. return cache;
  12307. }
  12308. });
  12309. creator.process = function (css, processOpts, pluginOpts) {
  12310. return postcss([creator(pluginOpts)]).process(css, processOpts);
  12311. };
  12312. return creator;
  12313. };
  12314. /**
  12315. * Default function to convert a node tree into a CSS string.
  12316. *
  12317. * @param {Node} node Start node for stringifing. Usually {@link Root}.
  12318. * @param {builder} builder Function to concatenate CSS from node’s parts
  12319. * or generate string and source map.
  12320. *
  12321. * @return {void}
  12322. *
  12323. * @function
  12324. */
  12325. postcss.stringify = _stringify.default;
  12326. /**
  12327. * Parses source css and returns a new {@link Root} node,
  12328. * which contains the source CSS nodes.
  12329. *
  12330. * @param {string|toString} css String with input CSS or any object
  12331. * with toString() method, like a Buffer
  12332. * @param {processOptions} [opts] Options with only `from` and `map` keys.
  12333. *
  12334. * @return {Root} PostCSS AST.
  12335. *
  12336. * @example
  12337. * // Simple CSS concatenation with source map support
  12338. * const root1 = postcss.parse(css1, { from: file1 })
  12339. * const root2 = postcss.parse(css2, { from: file2 })
  12340. * root1.append(root2).toResult().css
  12341. *
  12342. * @function
  12343. */
  12344. postcss.parse = _parse.default;
  12345. /**
  12346. * Contains the {@link vendor} module.
  12347. *
  12348. * @type {vendor}
  12349. *
  12350. * @example
  12351. * postcss.vendor.unprefixed('-moz-tab') //=> ['tab']
  12352. */
  12353. postcss.vendor = _vendor.default;
  12354. /**
  12355. * Contains the {@link list} module.
  12356. *
  12357. * @member {list}
  12358. *
  12359. * @example
  12360. * postcss.list.space('5px calc(10% + 5px)') //=> ['5px', 'calc(10% + 5px)']
  12361. */
  12362. postcss.list = _list.default;
  12363. /**
  12364. * Creates a new {@link Comment} node.
  12365. *
  12366. * @param {object} [defaults] Properties for the new node.
  12367. *
  12368. * @return {Comment} New comment node
  12369. *
  12370. * @example
  12371. * postcss.comment({ text: 'test' })
  12372. */
  12373. postcss.comment = function (defaults) {
  12374. return new _comment.default(defaults);
  12375. };
  12376. /**
  12377. * Creates a new {@link AtRule} node.
  12378. *
  12379. * @param {object} [defaults] Properties for the new node.
  12380. *
  12381. * @return {AtRule} new at-rule node
  12382. *
  12383. * @example
  12384. * postcss.atRule({ name: 'charset' }).toString() //=> "@charset"
  12385. */
  12386. postcss.atRule = function (defaults) {
  12387. return new _atRule.default(defaults);
  12388. };
  12389. /**
  12390. * Creates a new {@link Declaration} node.
  12391. *
  12392. * @param {object} [defaults] Properties for the new node.
  12393. *
  12394. * @return {Declaration} new declaration node
  12395. *
  12396. * @example
  12397. * postcss.decl({ prop: 'color', value: 'red' }).toString() //=> "color: red"
  12398. */
  12399. postcss.decl = function (defaults) {
  12400. return new _declaration.default(defaults);
  12401. };
  12402. /**
  12403. * Creates a new {@link Rule} node.
  12404. *
  12405. * @param {object} [defaults] Properties for the new node.
  12406. *
  12407. * @return {Rule} new rule node
  12408. *
  12409. * @example
  12410. * postcss.rule({ selector: 'a' }).toString() //=> "a {\n}"
  12411. */
  12412. postcss.rule = function (defaults) {
  12413. return new _rule.default(defaults);
  12414. };
  12415. /**
  12416. * Creates a new {@link Root} node.
  12417. *
  12418. * @param {object} [defaults] Properties for the new node.
  12419. *
  12420. * @return {Root} new root node.
  12421. *
  12422. * @example
  12423. * postcss.root({ after: '\n' }).toString() //=> "\n"
  12424. */
  12425. postcss.root = function (defaults) {
  12426. return new _root.default(defaults);
  12427. };
  12428. var _default = postcss;
  12429. exports.default = _default;
  12430. module.exports = exports.default;
  12431. },{"./at-rule":169,"./comment":170,"./declaration":173,"./list":176,"./parse":179,"./processor":183,"./root":185,"./rule":186,"./stringify":188,"./vendor":190}],182:[function(require,module,exports){
  12432. (function (Buffer){
  12433. "use strict";
  12434. exports.__esModule = true;
  12435. exports.default = void 0;
  12436. var _sourceMap = _interopRequireDefault(require("source-map"));
  12437. var _path = _interopRequireDefault(require("path"));
  12438. var _fs = _interopRequireDefault(require("fs"));
  12439. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  12440. function fromBase64(str) {
  12441. if (Buffer) {
  12442. return Buffer.from(str, 'base64').toString();
  12443. } else {
  12444. return window.atob(str);
  12445. }
  12446. }
  12447. /**
  12448. * Source map information from input CSS.
  12449. * For example, source map after Sass compiler.
  12450. *
  12451. * This class will automatically find source map in input CSS or in file system
  12452. * near input file (according `from` option).
  12453. *
  12454. * @example
  12455. * const root = postcss.parse(css, { from: 'a.sass.css' })
  12456. * root.input.map //=> PreviousMap
  12457. */
  12458. var PreviousMap = /*#__PURE__*/function () {
  12459. /**
  12460. * @param {string} css Input CSS source.
  12461. * @param {processOptions} [opts] {@link Processor#process} options.
  12462. */
  12463. function PreviousMap(css, opts) {
  12464. this.loadAnnotation(css);
  12465. /**
  12466. * Was source map inlined by data-uri to input CSS.
  12467. *
  12468. * @type {boolean}
  12469. */
  12470. this.inline = this.startWith(this.annotation, 'data:');
  12471. var prev = opts.map ? opts.map.prev : undefined;
  12472. var text = this.loadMap(opts.from, prev);
  12473. if (text) this.text = text;
  12474. }
  12475. /**
  12476. * Create a instance of `SourceMapGenerator` class
  12477. * from the `source-map` library to work with source map information.
  12478. *
  12479. * It is lazy method, so it will create object only on first call
  12480. * and then it will use cache.
  12481. *
  12482. * @return {SourceMapGenerator} Object with source map information.
  12483. */
  12484. var _proto = PreviousMap.prototype;
  12485. _proto.consumer = function consumer() {
  12486. if (!this.consumerCache) {
  12487. this.consumerCache = new _sourceMap.default.SourceMapConsumer(this.text);
  12488. }
  12489. return this.consumerCache;
  12490. }
  12491. /**
  12492. * Does source map contains `sourcesContent` with input source text.
  12493. *
  12494. * @return {boolean} Is `sourcesContent` present.
  12495. */
  12496. ;
  12497. _proto.withContent = function withContent() {
  12498. return !!(this.consumer().sourcesContent && this.consumer().sourcesContent.length > 0);
  12499. };
  12500. _proto.startWith = function startWith(string, start) {
  12501. if (!string) return false;
  12502. return string.substr(0, start.length) === start;
  12503. };
  12504. _proto.getAnnotationURL = function getAnnotationURL(sourceMapString) {
  12505. return sourceMapString.match(/\/\*\s*# sourceMappingURL=(.*)\s*\*\//)[1].trim();
  12506. };
  12507. _proto.loadAnnotation = function loadAnnotation(css) {
  12508. var annotations = css.match(/\/\*\s*# sourceMappingURL=(.*)\s*\*\//mg);
  12509. if (annotations && annotations.length > 0) {
  12510. // Locate the last sourceMappingURL to avoid picking up
  12511. // sourceMappingURLs from comments, strings, etc.
  12512. var lastAnnotation = annotations[annotations.length - 1];
  12513. if (lastAnnotation) {
  12514. this.annotation = this.getAnnotationURL(lastAnnotation);
  12515. }
  12516. }
  12517. };
  12518. _proto.decodeInline = function decodeInline(text) {
  12519. var baseCharsetUri = /^data:application\/json;charset=utf-?8;base64,/;
  12520. var baseUri = /^data:application\/json;base64,/;
  12521. var uri = 'data:application/json,';
  12522. if (this.startWith(text, uri)) {
  12523. return decodeURIComponent(text.substr(uri.length));
  12524. }
  12525. if (baseCharsetUri.test(text) || baseUri.test(text)) {
  12526. return fromBase64(text.substr(RegExp.lastMatch.length));
  12527. }
  12528. var encoding = text.match(/data:application\/json;([^,]+),/)[1];
  12529. throw new Error('Unsupported source map encoding ' + encoding);
  12530. };
  12531. _proto.loadMap = function loadMap(file, prev) {
  12532. if (prev === false) return false;
  12533. if (prev) {
  12534. if (typeof prev === 'string') {
  12535. return prev;
  12536. } else if (typeof prev === 'function') {
  12537. var prevPath = prev(file);
  12538. if (prevPath && _fs.default.existsSync && _fs.default.existsSync(prevPath)) {
  12539. return _fs.default.readFileSync(prevPath, 'utf-8').toString().trim();
  12540. } else {
  12541. throw new Error('Unable to load previous source map: ' + prevPath.toString());
  12542. }
  12543. } else if (prev instanceof _sourceMap.default.SourceMapConsumer) {
  12544. return _sourceMap.default.SourceMapGenerator.fromSourceMap(prev).toString();
  12545. } else if (prev instanceof _sourceMap.default.SourceMapGenerator) {
  12546. return prev.toString();
  12547. } else if (this.isMap(prev)) {
  12548. return JSON.stringify(prev);
  12549. } else {
  12550. throw new Error('Unsupported previous source map format: ' + prev.toString());
  12551. }
  12552. } else if (this.inline) {
  12553. return this.decodeInline(this.annotation);
  12554. } else if (this.annotation) {
  12555. var map = this.annotation;
  12556. if (file) map = _path.default.join(_path.default.dirname(file), map);
  12557. this.root = _path.default.dirname(map);
  12558. if (_fs.default.existsSync && _fs.default.existsSync(map)) {
  12559. return _fs.default.readFileSync(map, 'utf-8').toString().trim();
  12560. } else {
  12561. return false;
  12562. }
  12563. }
  12564. };
  12565. _proto.isMap = function isMap(map) {
  12566. if (typeof map !== 'object') return false;
  12567. return typeof map.mappings === 'string' || typeof map._mappings === 'string';
  12568. };
  12569. return PreviousMap;
  12570. }();
  12571. var _default = PreviousMap;
  12572. exports.default = _default;
  12573. module.exports = exports.default;
  12574. }).call(this,require("buffer").Buffer)
  12575. },{"buffer":3,"fs":2,"path":168,"source-map":208}],183:[function(require,module,exports){
  12576. (function (process){
  12577. "use strict";
  12578. exports.__esModule = true;
  12579. exports.default = void 0;
  12580. var _lazyResult = _interopRequireDefault(require("./lazy-result"));
  12581. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  12582. function _createForOfIteratorHelperLoose(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } it = o[Symbol.iterator](); return it.next.bind(it); }
  12583. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  12584. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  12585. /**
  12586. * Contains plugins to process CSS. Create one `Processor` instance,
  12587. * initialize its plugins, and then use that instance on numerous CSS files.
  12588. *
  12589. * @example
  12590. * const processor = postcss([autoprefixer, precss])
  12591. * processor.process(css1).then(result => console.log(result.css))
  12592. * processor.process(css2).then(result => console.log(result.css))
  12593. */
  12594. var Processor = /*#__PURE__*/function () {
  12595. /**
  12596. * @param {Array.<Plugin|pluginFunction>|Processor} plugins PostCSS plugins.
  12597. * See {@link Processor#use} for plugin format.
  12598. */
  12599. function Processor(plugins) {
  12600. if (plugins === void 0) {
  12601. plugins = [];
  12602. }
  12603. /**
  12604. * Current PostCSS version.
  12605. *
  12606. * @type {string}
  12607. *
  12608. * @example
  12609. * if (result.processor.version.split('.')[0] !== '6') {
  12610. * throw new Error('This plugin works only with PostCSS 6')
  12611. * }
  12612. */
  12613. this.version = '7.0.34';
  12614. /**
  12615. * Plugins added to this processor.
  12616. *
  12617. * @type {pluginFunction[]}
  12618. *
  12619. * @example
  12620. * const processor = postcss([autoprefixer, precss])
  12621. * processor.plugins.length //=> 2
  12622. */
  12623. this.plugins = this.normalize(plugins);
  12624. }
  12625. /**
  12626. * Adds a plugin to be used as a CSS processor.
  12627. *
  12628. * PostCSS plugin can be in 4 formats:
  12629. * * A plugin created by {@link postcss.plugin} method.
  12630. * * A function. PostCSS will pass the function a @{link Root}
  12631. * as the first argument and current {@link Result} instance
  12632. * as the second.
  12633. * * An object with a `postcss` method. PostCSS will use that method
  12634. * as described in #2.
  12635. * * Another {@link Processor} instance. PostCSS will copy plugins
  12636. * from that instance into this one.
  12637. *
  12638. * Plugins can also be added by passing them as arguments when creating
  12639. * a `postcss` instance (see [`postcss(plugins)`]).
  12640. *
  12641. * Asynchronous plugins should return a `Promise` instance.
  12642. *
  12643. * @param {Plugin|pluginFunction|Processor} plugin PostCSS plugin
  12644. * or {@link Processor}
  12645. * with plugins.
  12646. *
  12647. * @example
  12648. * const processor = postcss()
  12649. * .use(autoprefixer)
  12650. * .use(precss)
  12651. *
  12652. * @return {Processes} Current processor to make methods chain.
  12653. */
  12654. var _proto = Processor.prototype;
  12655. _proto.use = function use(plugin) {
  12656. this.plugins = this.plugins.concat(this.normalize([plugin]));
  12657. return this;
  12658. }
  12659. /**
  12660. * Parses source CSS and returns a {@link LazyResult} Promise proxy.
  12661. * Because some plugins can be asynchronous it doesn’t make
  12662. * any transformations. Transformations will be applied
  12663. * in the {@link LazyResult} methods.
  12664. *
  12665. * @param {string|toString|Result} css String with input CSS or any object
  12666. * with a `toString()` method,
  12667. * like a Buffer. Optionally, send
  12668. * a {@link Result} instance
  12669. * and the processor will take
  12670. * the {@link Root} from it.
  12671. * @param {processOptions} [opts] Options.
  12672. *
  12673. * @return {LazyResult} Promise proxy.
  12674. *
  12675. * @example
  12676. * processor.process(css, { from: 'a.css', to: 'a.out.css' })
  12677. * .then(result => {
  12678. * console.log(result.css)
  12679. * })
  12680. */
  12681. ;
  12682. _proto.process = function (_process) {
  12683. function process(_x) {
  12684. return _process.apply(this, arguments);
  12685. }
  12686. process.toString = function () {
  12687. return _process.toString();
  12688. };
  12689. return process;
  12690. }(function (css, opts) {
  12691. if (opts === void 0) {
  12692. opts = {};
  12693. }
  12694. if (this.plugins.length === 0 && opts.parser === opts.stringifier) {
  12695. if (process.env.NODE_ENV !== 'production') {
  12696. if (typeof console !== 'undefined' && console.warn) {
  12697. console.warn('You did not set any plugins, parser, or stringifier. ' + 'Right now, PostCSS does nothing. Pick plugins for your case ' + 'on https://www.postcss.parts/ and use them in postcss.config.js.');
  12698. }
  12699. }
  12700. }
  12701. return new _lazyResult.default(this, css, opts);
  12702. });
  12703. _proto.normalize = function normalize(plugins) {
  12704. var normalized = [];
  12705. for (var _iterator = _createForOfIteratorHelperLoose(plugins), _step; !(_step = _iterator()).done;) {
  12706. var i = _step.value;
  12707. if (i.postcss === true) {
  12708. var plugin = i();
  12709. throw new Error('PostCSS plugin ' + plugin.postcssPlugin + ' requires PostCSS 8. Update PostCSS or downgrade this plugin.');
  12710. }
  12711. if (i.postcss) i = i.postcss;
  12712. if (typeof i === 'object' && Array.isArray(i.plugins)) {
  12713. normalized = normalized.concat(i.plugins);
  12714. } else if (typeof i === 'function') {
  12715. normalized.push(i);
  12716. } else if (typeof i === 'object' && (i.parse || i.stringify)) {
  12717. if (process.env.NODE_ENV !== 'production') {
  12718. throw new Error('PostCSS syntaxes cannot be used as plugins. Instead, please use ' + 'one of the syntax/parser/stringifier options as outlined ' + 'in your PostCSS runner documentation.');
  12719. }
  12720. } else if (typeof i === 'object' && i.postcssPlugin) {
  12721. throw new Error('PostCSS plugin ' + i.postcssPlugin + ' requires PostCSS 8. Update PostCSS or downgrade this plugin.');
  12722. } else {
  12723. throw new Error(i + ' is not a PostCSS plugin');
  12724. }
  12725. }
  12726. return normalized;
  12727. };
  12728. return Processor;
  12729. }();
  12730. var _default = Processor;
  12731. /**
  12732. * @callback builder
  12733. * @param {string} part Part of generated CSS connected to this node.
  12734. * @param {Node} node AST node.
  12735. * @param {"start"|"end"} [type] Node’s part type.
  12736. */
  12737. /**
  12738. * @callback parser
  12739. *
  12740. * @param {string|toString} css String with input CSS or any object
  12741. * with toString() method, like a Buffer.
  12742. * @param {processOptions} [opts] Options with only `from` and `map` keys.
  12743. *
  12744. * @return {Root} PostCSS AST
  12745. */
  12746. /**
  12747. * @callback stringifier
  12748. *
  12749. * @param {Node} node Start node for stringifing. Usually {@link Root}.
  12750. * @param {builder} builder Function to concatenate CSS from node’s parts
  12751. * or generate string and source map.
  12752. *
  12753. * @return {void}
  12754. */
  12755. /**
  12756. * @typedef {object} syntax
  12757. * @property {parser} parse Function to generate AST by string.
  12758. * @property {stringifier} stringify Function to generate string by AST.
  12759. */
  12760. /**
  12761. * @typedef {object} toString
  12762. * @property {function} toString
  12763. */
  12764. /**
  12765. * @callback pluginFunction
  12766. * @param {Root} root Parsed input CSS.
  12767. * @param {Result} result Result to set warnings or check other plugins.
  12768. */
  12769. /**
  12770. * @typedef {object} Plugin
  12771. * @property {function} postcss PostCSS plugin function.
  12772. */
  12773. /**
  12774. * @typedef {object} processOptions
  12775. * @property {string} from The path of the CSS source file.
  12776. * You should always set `from`,
  12777. * because it is used in source map
  12778. * generation and syntax error messages.
  12779. * @property {string} to The path where you’ll put the output
  12780. * CSS file. You should always set `to`
  12781. * to generate correct source maps.
  12782. * @property {parser} parser Function to generate AST by string.
  12783. * @property {stringifier} stringifier Class to generate string by AST.
  12784. * @property {syntax} syntax Object with `parse` and `stringify`.
  12785. * @property {object} map Source map options.
  12786. * @property {boolean} map.inline Does source map should
  12787. * be embedded in the output
  12788. * CSS as a base64-encoded
  12789. * comment.
  12790. * @property {string|object|false|function} map.prev Source map content
  12791. * from a previous
  12792. * processing step
  12793. * (for example, Sass).
  12794. * PostCSS will try to find
  12795. * previous map automatically,
  12796. * so you could disable it by
  12797. * `false` value.
  12798. * @property {boolean} map.sourcesContent Does PostCSS should set
  12799. * the origin content to map.
  12800. * @property {string|false} map.annotation Does PostCSS should set
  12801. * annotation comment to map.
  12802. * @property {string} map.from Override `from` in map’s
  12803. * sources`.
  12804. */
  12805. exports.default = _default;
  12806. module.exports = exports.default;
  12807. }).call(this,require('_process'))
  12808. },{"./lazy-result":175,"_process":193}],184:[function(require,module,exports){
  12809. "use strict";
  12810. exports.__esModule = true;
  12811. exports.default = void 0;
  12812. var _warning = _interopRequireDefault(require("./warning"));
  12813. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  12814. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  12815. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  12816. /**
  12817. * Provides the result of the PostCSS transformations.
  12818. *
  12819. * A Result instance is returned by {@link LazyResult#then}
  12820. * or {@link Root#toResult} methods.
  12821. *
  12822. * @example
  12823. * postcss([autoprefixer]).process(css).then(result => {
  12824. * console.log(result.css)
  12825. * })
  12826. *
  12827. * @example
  12828. * const result2 = postcss.parse(css).toResult()
  12829. */
  12830. var Result = /*#__PURE__*/function () {
  12831. /**
  12832. * @param {Processor} processor Processor used for this transformation.
  12833. * @param {Root} root Root node after all transformations.
  12834. * @param {processOptions} opts Options from the {@link Processor#process}
  12835. * or {@link Root#toResult}.
  12836. */
  12837. function Result(processor, root, opts) {
  12838. /**
  12839. * The Processor instance used for this transformation.
  12840. *
  12841. * @type {Processor}
  12842. *
  12843. * @example
  12844. * for (const plugin of result.processor.plugins) {
  12845. * if (plugin.postcssPlugin === 'postcss-bad') {
  12846. * throw 'postcss-good is incompatible with postcss-bad'
  12847. * }
  12848. * })
  12849. */
  12850. this.processor = processor;
  12851. /**
  12852. * Contains messages from plugins (e.g., warnings or custom messages).
  12853. * Each message should have type and plugin properties.
  12854. *
  12855. * @type {Message[]}
  12856. *
  12857. * @example
  12858. * postcss.plugin('postcss-min-browser', () => {
  12859. * return (root, result) => {
  12860. * const browsers = detectMinBrowsersByCanIUse(root)
  12861. * result.messages.push({
  12862. * type: 'min-browser',
  12863. * plugin: 'postcss-min-browser',
  12864. * browsers
  12865. * })
  12866. * }
  12867. * })
  12868. */
  12869. this.messages = [];
  12870. /**
  12871. * Root node after all transformations.
  12872. *
  12873. * @type {Root}
  12874. *
  12875. * @example
  12876. * root.toResult().root === root
  12877. */
  12878. this.root = root;
  12879. /**
  12880. * Options from the {@link Processor#process} or {@link Root#toResult} call
  12881. * that produced this Result instance.
  12882. *
  12883. * @type {processOptions}
  12884. *
  12885. * @example
  12886. * root.toResult(opts).opts === opts
  12887. */
  12888. this.opts = opts;
  12889. /**
  12890. * A CSS string representing of {@link Result#root}.
  12891. *
  12892. * @type {string}
  12893. *
  12894. * @example
  12895. * postcss.parse('a{}').toResult().css //=> "a{}"
  12896. */
  12897. this.css = undefined;
  12898. /**
  12899. * An instance of `SourceMapGenerator` class from the `source-map` library,
  12900. * representing changes to the {@link Result#root} instance.
  12901. *
  12902. * @type {SourceMapGenerator}
  12903. *
  12904. * @example
  12905. * result.map.toJSON() //=> { version: 3, file: 'a.css', … }
  12906. *
  12907. * @example
  12908. * if (result.map) {
  12909. * fs.writeFileSync(result.opts.to + '.map', result.map.toString())
  12910. * }
  12911. */
  12912. this.map = undefined;
  12913. }
  12914. /**
  12915. * Returns for @{link Result#css} content.
  12916. *
  12917. * @example
  12918. * result + '' === result.css
  12919. *
  12920. * @return {string} String representing of {@link Result#root}.
  12921. */
  12922. var _proto = Result.prototype;
  12923. _proto.toString = function toString() {
  12924. return this.css;
  12925. }
  12926. /**
  12927. * Creates an instance of {@link Warning} and adds it
  12928. * to {@link Result#messages}.
  12929. *
  12930. * @param {string} text Warning message.
  12931. * @param {Object} [opts] Warning options.
  12932. * @param {Node} opts.node CSS node that caused the warning.
  12933. * @param {string} opts.word Word in CSS source that caused the warning.
  12934. * @param {number} opts.index Index in CSS node string that caused
  12935. * the warning.
  12936. * @param {string} opts.plugin Name of the plugin that created
  12937. * this warning. {@link Result#warn} fills
  12938. * this property automatically.
  12939. *
  12940. * @return {Warning} Created warning.
  12941. */
  12942. ;
  12943. _proto.warn = function warn(text, opts) {
  12944. if (opts === void 0) {
  12945. opts = {};
  12946. }
  12947. if (!opts.plugin) {
  12948. if (this.lastPlugin && this.lastPlugin.postcssPlugin) {
  12949. opts.plugin = this.lastPlugin.postcssPlugin;
  12950. }
  12951. }
  12952. var warning = new _warning.default(text, opts);
  12953. this.messages.push(warning);
  12954. return warning;
  12955. }
  12956. /**
  12957. * Returns warnings from plugins. Filters {@link Warning} instances
  12958. * from {@link Result#messages}.
  12959. *
  12960. * @example
  12961. * result.warnings().forEach(warn => {
  12962. * console.warn(warn.toString())
  12963. * })
  12964. *
  12965. * @return {Warning[]} Warnings from plugins.
  12966. */
  12967. ;
  12968. _proto.warnings = function warnings() {
  12969. return this.messages.filter(function (i) {
  12970. return i.type === 'warning';
  12971. });
  12972. }
  12973. /**
  12974. * An alias for the {@link Result#css} property.
  12975. * Use it with syntaxes that generate non-CSS output.
  12976. *
  12977. * @type {string}
  12978. *
  12979. * @example
  12980. * result.css === result.content
  12981. */
  12982. ;
  12983. _createClass(Result, [{
  12984. key: "content",
  12985. get: function get() {
  12986. return this.css;
  12987. }
  12988. }]);
  12989. return Result;
  12990. }();
  12991. var _default = Result;
  12992. /**
  12993. * @typedef {object} Message
  12994. * @property {string} type Message type.
  12995. * @property {string} plugin Source PostCSS plugin name.
  12996. */
  12997. exports.default = _default;
  12998. module.exports = exports.default;
  12999. },{"./warning":192}],185:[function(require,module,exports){
  13000. "use strict";
  13001. exports.__esModule = true;
  13002. exports.default = void 0;
  13003. var _container = _interopRequireDefault(require("./container"));
  13004. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  13005. function _createForOfIteratorHelperLoose(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } it = o[Symbol.iterator](); return it.next.bind(it); }
  13006. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  13007. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  13008. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  13009. /**
  13010. * Represents a CSS file and contains all its parsed nodes.
  13011. *
  13012. * @extends Container
  13013. *
  13014. * @example
  13015. * const root = postcss.parse('a{color:black} b{z-index:2}')
  13016. * root.type //=> 'root'
  13017. * root.nodes.length //=> 2
  13018. */
  13019. var Root = /*#__PURE__*/function (_Container) {
  13020. _inheritsLoose(Root, _Container);
  13021. function Root(defaults) {
  13022. var _this;
  13023. _this = _Container.call(this, defaults) || this;
  13024. _this.type = 'root';
  13025. if (!_this.nodes) _this.nodes = [];
  13026. return _this;
  13027. }
  13028. var _proto = Root.prototype;
  13029. _proto.removeChild = function removeChild(child, ignore) {
  13030. var index = this.index(child);
  13031. if (!ignore && index === 0 && this.nodes.length > 1) {
  13032. this.nodes[1].raws.before = this.nodes[index].raws.before;
  13033. }
  13034. return _Container.prototype.removeChild.call(this, child);
  13035. };
  13036. _proto.normalize = function normalize(child, sample, type) {
  13037. var nodes = _Container.prototype.normalize.call(this, child);
  13038. if (sample) {
  13039. if (type === 'prepend') {
  13040. if (this.nodes.length > 1) {
  13041. sample.raws.before = this.nodes[1].raws.before;
  13042. } else {
  13043. delete sample.raws.before;
  13044. }
  13045. } else if (this.first !== sample) {
  13046. for (var _iterator = _createForOfIteratorHelperLoose(nodes), _step; !(_step = _iterator()).done;) {
  13047. var node = _step.value;
  13048. node.raws.before = sample.raws.before;
  13049. }
  13050. }
  13051. }
  13052. return nodes;
  13053. }
  13054. /**
  13055. * Returns a {@link Result} instance representing the root’s CSS.
  13056. *
  13057. * @param {processOptions} [opts] Options with only `to` and `map` keys.
  13058. *
  13059. * @return {Result} Result with current root’s CSS.
  13060. *
  13061. * @example
  13062. * const root1 = postcss.parse(css1, { from: 'a.css' })
  13063. * const root2 = postcss.parse(css2, { from: 'b.css' })
  13064. * root1.append(root2)
  13065. * const result = root1.toResult({ to: 'all.css', map: true })
  13066. */
  13067. ;
  13068. _proto.toResult = function toResult(opts) {
  13069. if (opts === void 0) {
  13070. opts = {};
  13071. }
  13072. var LazyResult = require('./lazy-result');
  13073. var Processor = require('./processor');
  13074. var lazy = new LazyResult(new Processor(), this, opts);
  13075. return lazy.stringify();
  13076. }
  13077. /**
  13078. * @memberof Root#
  13079. * @member {object} raws Information to generate byte-to-byte equal
  13080. * node string as it was in the origin input.
  13081. *
  13082. * Every parser saves its own properties,
  13083. * but the default CSS parser uses:
  13084. *
  13085. * * `after`: the space symbols after the last child to the end of file.
  13086. * * `semicolon`: is the last child has an (optional) semicolon.
  13087. *
  13088. * @example
  13089. * postcss.parse('a {}\n').raws //=> { after: '\n' }
  13090. * postcss.parse('a {}').raws //=> { after: '' }
  13091. */
  13092. ;
  13093. return Root;
  13094. }(_container.default);
  13095. var _default = Root;
  13096. exports.default = _default;
  13097. module.exports = exports.default;
  13098. },{"./container":171,"./lazy-result":175,"./processor":183}],186:[function(require,module,exports){
  13099. "use strict";
  13100. exports.__esModule = true;
  13101. exports.default = void 0;
  13102. var _container = _interopRequireDefault(require("./container"));
  13103. var _list = _interopRequireDefault(require("./list"));
  13104. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  13105. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  13106. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  13107. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  13108. /**
  13109. * Represents a CSS rule: a selector followed by a declaration block.
  13110. *
  13111. * @extends Container
  13112. *
  13113. * @example
  13114. * const root = postcss.parse('a{}')
  13115. * const rule = root.first
  13116. * rule.type //=> 'rule'
  13117. * rule.toString() //=> 'a{}'
  13118. */
  13119. var Rule = /*#__PURE__*/function (_Container) {
  13120. _inheritsLoose(Rule, _Container);
  13121. function Rule(defaults) {
  13122. var _this;
  13123. _this = _Container.call(this, defaults) || this;
  13124. _this.type = 'rule';
  13125. if (!_this.nodes) _this.nodes = [];
  13126. return _this;
  13127. }
  13128. /**
  13129. * An array containing the rule’s individual selectors.
  13130. * Groups of selectors are split at commas.
  13131. *
  13132. * @type {string[]}
  13133. *
  13134. * @example
  13135. * const root = postcss.parse('a, b { }')
  13136. * const rule = root.first
  13137. *
  13138. * rule.selector //=> 'a, b'
  13139. * rule.selectors //=> ['a', 'b']
  13140. *
  13141. * rule.selectors = ['a', 'strong']
  13142. * rule.selector //=> 'a, strong'
  13143. */
  13144. _createClass(Rule, [{
  13145. key: "selectors",
  13146. get: function get() {
  13147. return _list.default.comma(this.selector);
  13148. },
  13149. set: function set(values) {
  13150. var match = this.selector ? this.selector.match(/,\s*/) : null;
  13151. var sep = match ? match[0] : ',' + this.raw('between', 'beforeOpen');
  13152. this.selector = values.join(sep);
  13153. }
  13154. /**
  13155. * @memberof Rule#
  13156. * @member {string} selector The rule’s full selector represented
  13157. * as a string.
  13158. *
  13159. * @example
  13160. * const root = postcss.parse('a, b { }')
  13161. * const rule = root.first
  13162. * rule.selector //=> 'a, b'
  13163. */
  13164. /**
  13165. * @memberof Rule#
  13166. * @member {object} raws Information to generate byte-to-byte equal
  13167. * node string as it was in the origin input.
  13168. *
  13169. * Every parser saves its own properties,
  13170. * but the default CSS parser uses:
  13171. *
  13172. * * `before`: the space symbols before the node. It also stores `*`
  13173. * and `_` symbols before the declaration (IE hack).
  13174. * * `after`: the space symbols after the last child of the node
  13175. * to the end of the node.
  13176. * * `between`: the symbols between the property and value
  13177. * for declarations, selector and `{` for rules, or last parameter
  13178. * and `{` for at-rules.
  13179. * * `semicolon`: contains `true` if the last child has
  13180. * an (optional) semicolon.
  13181. * * `ownSemicolon`: contains `true` if there is semicolon after rule.
  13182. *
  13183. * PostCSS cleans selectors from comments and extra spaces,
  13184. * but it stores origin content in raws properties.
  13185. * As such, if you don’t change a declaration’s value,
  13186. * PostCSS will use the raw value with comments.
  13187. *
  13188. * @example
  13189. * const root = postcss.parse('a {\n color:black\n}')
  13190. * root.first.first.raws //=> { before: '', between: ' ', after: '\n' }
  13191. */
  13192. }]);
  13193. return Rule;
  13194. }(_container.default);
  13195. var _default = Rule;
  13196. exports.default = _default;
  13197. module.exports = exports.default;
  13198. },{"./container":171,"./list":176}],187:[function(require,module,exports){
  13199. "use strict";
  13200. exports.__esModule = true;
  13201. exports.default = void 0;
  13202. var DEFAULT_RAW = {
  13203. colon: ': ',
  13204. indent: ' ',
  13205. beforeDecl: '\n',
  13206. beforeRule: '\n',
  13207. beforeOpen: ' ',
  13208. beforeClose: '\n',
  13209. beforeComment: '\n',
  13210. after: '\n',
  13211. emptyBody: '',
  13212. commentLeft: ' ',
  13213. commentRight: ' ',
  13214. semicolon: false
  13215. };
  13216. function capitalize(str) {
  13217. return str[0].toUpperCase() + str.slice(1);
  13218. }
  13219. var Stringifier = /*#__PURE__*/function () {
  13220. function Stringifier(builder) {
  13221. this.builder = builder;
  13222. }
  13223. var _proto = Stringifier.prototype;
  13224. _proto.stringify = function stringify(node, semicolon) {
  13225. this[node.type](node, semicolon);
  13226. };
  13227. _proto.root = function root(node) {
  13228. this.body(node);
  13229. if (node.raws.after) this.builder(node.raws.after);
  13230. };
  13231. _proto.comment = function comment(node) {
  13232. var left = this.raw(node, 'left', 'commentLeft');
  13233. var right = this.raw(node, 'right', 'commentRight');
  13234. this.builder('/*' + left + node.text + right + '*/', node);
  13235. };
  13236. _proto.decl = function decl(node, semicolon) {
  13237. var between = this.raw(node, 'between', 'colon');
  13238. var string = node.prop + between + this.rawValue(node, 'value');
  13239. if (node.important) {
  13240. string += node.raws.important || ' !important';
  13241. }
  13242. if (semicolon) string += ';';
  13243. this.builder(string, node);
  13244. };
  13245. _proto.rule = function rule(node) {
  13246. this.block(node, this.rawValue(node, 'selector'));
  13247. if (node.raws.ownSemicolon) {
  13248. this.builder(node.raws.ownSemicolon, node, 'end');
  13249. }
  13250. };
  13251. _proto.atrule = function atrule(node, semicolon) {
  13252. var name = '@' + node.name;
  13253. var params = node.params ? this.rawValue(node, 'params') : '';
  13254. if (typeof node.raws.afterName !== 'undefined') {
  13255. name += node.raws.afterName;
  13256. } else if (params) {
  13257. name += ' ';
  13258. }
  13259. if (node.nodes) {
  13260. this.block(node, name + params);
  13261. } else {
  13262. var end = (node.raws.between || '') + (semicolon ? ';' : '');
  13263. this.builder(name + params + end, node);
  13264. }
  13265. };
  13266. _proto.body = function body(node) {
  13267. var last = node.nodes.length - 1;
  13268. while (last > 0) {
  13269. if (node.nodes[last].type !== 'comment') break;
  13270. last -= 1;
  13271. }
  13272. var semicolon = this.raw(node, 'semicolon');
  13273. for (var i = 0; i < node.nodes.length; i++) {
  13274. var child = node.nodes[i];
  13275. var before = this.raw(child, 'before');
  13276. if (before) this.builder(before);
  13277. this.stringify(child, last !== i || semicolon);
  13278. }
  13279. };
  13280. _proto.block = function block(node, start) {
  13281. var between = this.raw(node, 'between', 'beforeOpen');
  13282. this.builder(start + between + '{', node, 'start');
  13283. var after;
  13284. if (node.nodes && node.nodes.length) {
  13285. this.body(node);
  13286. after = this.raw(node, 'after');
  13287. } else {
  13288. after = this.raw(node, 'after', 'emptyBody');
  13289. }
  13290. if (after) this.builder(after);
  13291. this.builder('}', node, 'end');
  13292. };
  13293. _proto.raw = function raw(node, own, detect) {
  13294. var value;
  13295. if (!detect) detect = own; // Already had
  13296. if (own) {
  13297. value = node.raws[own];
  13298. if (typeof value !== 'undefined') return value;
  13299. }
  13300. var parent = node.parent; // Hack for first rule in CSS
  13301. if (detect === 'before') {
  13302. if (!parent || parent.type === 'root' && parent.first === node) {
  13303. return '';
  13304. }
  13305. } // Floating child without parent
  13306. if (!parent) return DEFAULT_RAW[detect]; // Detect style by other nodes
  13307. var root = node.root();
  13308. if (!root.rawCache) root.rawCache = {};
  13309. if (typeof root.rawCache[detect] !== 'undefined') {
  13310. return root.rawCache[detect];
  13311. }
  13312. if (detect === 'before' || detect === 'after') {
  13313. return this.beforeAfter(node, detect);
  13314. } else {
  13315. var method = 'raw' + capitalize(detect);
  13316. if (this[method]) {
  13317. value = this[method](root, node);
  13318. } else {
  13319. root.walk(function (i) {
  13320. value = i.raws[own];
  13321. if (typeof value !== 'undefined') return false;
  13322. });
  13323. }
  13324. }
  13325. if (typeof value === 'undefined') value = DEFAULT_RAW[detect];
  13326. root.rawCache[detect] = value;
  13327. return value;
  13328. };
  13329. _proto.rawSemicolon = function rawSemicolon(root) {
  13330. var value;
  13331. root.walk(function (i) {
  13332. if (i.nodes && i.nodes.length && i.last.type === 'decl') {
  13333. value = i.raws.semicolon;
  13334. if (typeof value !== 'undefined') return false;
  13335. }
  13336. });
  13337. return value;
  13338. };
  13339. _proto.rawEmptyBody = function rawEmptyBody(root) {
  13340. var value;
  13341. root.walk(function (i) {
  13342. if (i.nodes && i.nodes.length === 0) {
  13343. value = i.raws.after;
  13344. if (typeof value !== 'undefined') return false;
  13345. }
  13346. });
  13347. return value;
  13348. };
  13349. _proto.rawIndent = function rawIndent(root) {
  13350. if (root.raws.indent) return root.raws.indent;
  13351. var value;
  13352. root.walk(function (i) {
  13353. var p = i.parent;
  13354. if (p && p !== root && p.parent && p.parent === root) {
  13355. if (typeof i.raws.before !== 'undefined') {
  13356. var parts = i.raws.before.split('\n');
  13357. value = parts[parts.length - 1];
  13358. value = value.replace(/[^\s]/g, '');
  13359. return false;
  13360. }
  13361. }
  13362. });
  13363. return value;
  13364. };
  13365. _proto.rawBeforeComment = function rawBeforeComment(root, node) {
  13366. var value;
  13367. root.walkComments(function (i) {
  13368. if (typeof i.raws.before !== 'undefined') {
  13369. value = i.raws.before;
  13370. if (value.indexOf('\n') !== -1) {
  13371. value = value.replace(/[^\n]+$/, '');
  13372. }
  13373. return false;
  13374. }
  13375. });
  13376. if (typeof value === 'undefined') {
  13377. value = this.raw(node, null, 'beforeDecl');
  13378. } else if (value) {
  13379. value = value.replace(/[^\s]/g, '');
  13380. }
  13381. return value;
  13382. };
  13383. _proto.rawBeforeDecl = function rawBeforeDecl(root, node) {
  13384. var value;
  13385. root.walkDecls(function (i) {
  13386. if (typeof i.raws.before !== 'undefined') {
  13387. value = i.raws.before;
  13388. if (value.indexOf('\n') !== -1) {
  13389. value = value.replace(/[^\n]+$/, '');
  13390. }
  13391. return false;
  13392. }
  13393. });
  13394. if (typeof value === 'undefined') {
  13395. value = this.raw(node, null, 'beforeRule');
  13396. } else if (value) {
  13397. value = value.replace(/[^\s]/g, '');
  13398. }
  13399. return value;
  13400. };
  13401. _proto.rawBeforeRule = function rawBeforeRule(root) {
  13402. var value;
  13403. root.walk(function (i) {
  13404. if (i.nodes && (i.parent !== root || root.first !== i)) {
  13405. if (typeof i.raws.before !== 'undefined') {
  13406. value = i.raws.before;
  13407. if (value.indexOf('\n') !== -1) {
  13408. value = value.replace(/[^\n]+$/, '');
  13409. }
  13410. return false;
  13411. }
  13412. }
  13413. });
  13414. if (value) value = value.replace(/[^\s]/g, '');
  13415. return value;
  13416. };
  13417. _proto.rawBeforeClose = function rawBeforeClose(root) {
  13418. var value;
  13419. root.walk(function (i) {
  13420. if (i.nodes && i.nodes.length > 0) {
  13421. if (typeof i.raws.after !== 'undefined') {
  13422. value = i.raws.after;
  13423. if (value.indexOf('\n') !== -1) {
  13424. value = value.replace(/[^\n]+$/, '');
  13425. }
  13426. return false;
  13427. }
  13428. }
  13429. });
  13430. if (value) value = value.replace(/[^\s]/g, '');
  13431. return value;
  13432. };
  13433. _proto.rawBeforeOpen = function rawBeforeOpen(root) {
  13434. var value;
  13435. root.walk(function (i) {
  13436. if (i.type !== 'decl') {
  13437. value = i.raws.between;
  13438. if (typeof value !== 'undefined') return false;
  13439. }
  13440. });
  13441. return value;
  13442. };
  13443. _proto.rawColon = function rawColon(root) {
  13444. var value;
  13445. root.walkDecls(function (i) {
  13446. if (typeof i.raws.between !== 'undefined') {
  13447. value = i.raws.between.replace(/[^\s:]/g, '');
  13448. return false;
  13449. }
  13450. });
  13451. return value;
  13452. };
  13453. _proto.beforeAfter = function beforeAfter(node, detect) {
  13454. var value;
  13455. if (node.type === 'decl') {
  13456. value = this.raw(node, null, 'beforeDecl');
  13457. } else if (node.type === 'comment') {
  13458. value = this.raw(node, null, 'beforeComment');
  13459. } else if (detect === 'before') {
  13460. value = this.raw(node, null, 'beforeRule');
  13461. } else {
  13462. value = this.raw(node, null, 'beforeClose');
  13463. }
  13464. var buf = node.parent;
  13465. var depth = 0;
  13466. while (buf && buf.type !== 'root') {
  13467. depth += 1;
  13468. buf = buf.parent;
  13469. }
  13470. if (value.indexOf('\n') !== -1) {
  13471. var indent = this.raw(node, null, 'indent');
  13472. if (indent.length) {
  13473. for (var step = 0; step < depth; step++) {
  13474. value += indent;
  13475. }
  13476. }
  13477. }
  13478. return value;
  13479. };
  13480. _proto.rawValue = function rawValue(node, prop) {
  13481. var value = node[prop];
  13482. var raw = node.raws[prop];
  13483. if (raw && raw.value === value) {
  13484. return raw.raw;
  13485. }
  13486. return value;
  13487. };
  13488. return Stringifier;
  13489. }();
  13490. var _default = Stringifier;
  13491. exports.default = _default;
  13492. module.exports = exports.default;
  13493. },{}],188:[function(require,module,exports){
  13494. "use strict";
  13495. exports.__esModule = true;
  13496. exports.default = void 0;
  13497. var _stringifier = _interopRequireDefault(require("./stringifier"));
  13498. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  13499. function stringify(node, builder) {
  13500. var str = new _stringifier.default(builder);
  13501. str.stringify(node);
  13502. }
  13503. var _default = stringify;
  13504. exports.default = _default;
  13505. module.exports = exports.default;
  13506. },{"./stringifier":187}],189:[function(require,module,exports){
  13507. "use strict";
  13508. exports.__esModule = true;
  13509. exports.default = tokenizer;
  13510. var SINGLE_QUOTE = '\''.charCodeAt(0);
  13511. var DOUBLE_QUOTE = '"'.charCodeAt(0);
  13512. var BACKSLASH = '\\'.charCodeAt(0);
  13513. var SLASH = '/'.charCodeAt(0);
  13514. var NEWLINE = '\n'.charCodeAt(0);
  13515. var SPACE = ' '.charCodeAt(0);
  13516. var FEED = '\f'.charCodeAt(0);
  13517. var TAB = '\t'.charCodeAt(0);
  13518. var CR = '\r'.charCodeAt(0);
  13519. var OPEN_SQUARE = '['.charCodeAt(0);
  13520. var CLOSE_SQUARE = ']'.charCodeAt(0);
  13521. var OPEN_PARENTHESES = '('.charCodeAt(0);
  13522. var CLOSE_PARENTHESES = ')'.charCodeAt(0);
  13523. var OPEN_CURLY = '{'.charCodeAt(0);
  13524. var CLOSE_CURLY = '}'.charCodeAt(0);
  13525. var SEMICOLON = ';'.charCodeAt(0);
  13526. var ASTERISK = '*'.charCodeAt(0);
  13527. var COLON = ':'.charCodeAt(0);
  13528. var AT = '@'.charCodeAt(0);
  13529. var RE_AT_END = /[ \n\t\r\f{}()'"\\;/[\]#]/g;
  13530. var RE_WORD_END = /[ \n\t\r\f(){}:;@!'"\\\][#]|\/(?=\*)/g;
  13531. var RE_BAD_BRACKET = /.[\\/("'\n]/;
  13532. var RE_HEX_ESCAPE = /[a-f0-9]/i;
  13533. function tokenizer(input, options) {
  13534. if (options === void 0) {
  13535. options = {};
  13536. }
  13537. var css = input.css.valueOf();
  13538. var ignore = options.ignoreErrors;
  13539. var code, next, quote, lines, last, content, escape;
  13540. var nextLine, nextOffset, escaped, escapePos, prev, n, currentToken;
  13541. var length = css.length;
  13542. var offset = -1;
  13543. var line = 1;
  13544. var pos = 0;
  13545. var buffer = [];
  13546. var returned = [];
  13547. function position() {
  13548. return pos;
  13549. }
  13550. function unclosed(what) {
  13551. throw input.error('Unclosed ' + what, line, pos - offset);
  13552. }
  13553. function endOfFile() {
  13554. return returned.length === 0 && pos >= length;
  13555. }
  13556. function nextToken(opts) {
  13557. if (returned.length) return returned.pop();
  13558. if (pos >= length) return;
  13559. var ignoreUnclosed = opts ? opts.ignoreUnclosed : false;
  13560. code = css.charCodeAt(pos);
  13561. if (code === NEWLINE || code === FEED || code === CR && css.charCodeAt(pos + 1) !== NEWLINE) {
  13562. offset = pos;
  13563. line += 1;
  13564. }
  13565. switch (code) {
  13566. case NEWLINE:
  13567. case SPACE:
  13568. case TAB:
  13569. case CR:
  13570. case FEED:
  13571. next = pos;
  13572. do {
  13573. next += 1;
  13574. code = css.charCodeAt(next);
  13575. if (code === NEWLINE) {
  13576. offset = next;
  13577. line += 1;
  13578. }
  13579. } while (code === SPACE || code === NEWLINE || code === TAB || code === CR || code === FEED);
  13580. currentToken = ['space', css.slice(pos, next)];
  13581. pos = next - 1;
  13582. break;
  13583. case OPEN_SQUARE:
  13584. case CLOSE_SQUARE:
  13585. case OPEN_CURLY:
  13586. case CLOSE_CURLY:
  13587. case COLON:
  13588. case SEMICOLON:
  13589. case CLOSE_PARENTHESES:
  13590. var controlChar = String.fromCharCode(code);
  13591. currentToken = [controlChar, controlChar, line, pos - offset];
  13592. break;
  13593. case OPEN_PARENTHESES:
  13594. prev = buffer.length ? buffer.pop()[1] : '';
  13595. n = css.charCodeAt(pos + 1);
  13596. if (prev === 'url' && n !== SINGLE_QUOTE && n !== DOUBLE_QUOTE && n !== SPACE && n !== NEWLINE && n !== TAB && n !== FEED && n !== CR) {
  13597. next = pos;
  13598. do {
  13599. escaped = false;
  13600. next = css.indexOf(')', next + 1);
  13601. if (next === -1) {
  13602. if (ignore || ignoreUnclosed) {
  13603. next = pos;
  13604. break;
  13605. } else {
  13606. unclosed('bracket');
  13607. }
  13608. }
  13609. escapePos = next;
  13610. while (css.charCodeAt(escapePos - 1) === BACKSLASH) {
  13611. escapePos -= 1;
  13612. escaped = !escaped;
  13613. }
  13614. } while (escaped);
  13615. currentToken = ['brackets', css.slice(pos, next + 1), line, pos - offset, line, next - offset];
  13616. pos = next;
  13617. } else {
  13618. next = css.indexOf(')', pos + 1);
  13619. content = css.slice(pos, next + 1);
  13620. if (next === -1 || RE_BAD_BRACKET.test(content)) {
  13621. currentToken = ['(', '(', line, pos - offset];
  13622. } else {
  13623. currentToken = ['brackets', content, line, pos - offset, line, next - offset];
  13624. pos = next;
  13625. }
  13626. }
  13627. break;
  13628. case SINGLE_QUOTE:
  13629. case DOUBLE_QUOTE:
  13630. quote = code === SINGLE_QUOTE ? '\'' : '"';
  13631. next = pos;
  13632. do {
  13633. escaped = false;
  13634. next = css.indexOf(quote, next + 1);
  13635. if (next === -1) {
  13636. if (ignore || ignoreUnclosed) {
  13637. next = pos + 1;
  13638. break;
  13639. } else {
  13640. unclosed('string');
  13641. }
  13642. }
  13643. escapePos = next;
  13644. while (css.charCodeAt(escapePos - 1) === BACKSLASH) {
  13645. escapePos -= 1;
  13646. escaped = !escaped;
  13647. }
  13648. } while (escaped);
  13649. content = css.slice(pos, next + 1);
  13650. lines = content.split('\n');
  13651. last = lines.length - 1;
  13652. if (last > 0) {
  13653. nextLine = line + last;
  13654. nextOffset = next - lines[last].length;
  13655. } else {
  13656. nextLine = line;
  13657. nextOffset = offset;
  13658. }
  13659. currentToken = ['string', css.slice(pos, next + 1), line, pos - offset, nextLine, next - nextOffset];
  13660. offset = nextOffset;
  13661. line = nextLine;
  13662. pos = next;
  13663. break;
  13664. case AT:
  13665. RE_AT_END.lastIndex = pos + 1;
  13666. RE_AT_END.test(css);
  13667. if (RE_AT_END.lastIndex === 0) {
  13668. next = css.length - 1;
  13669. } else {
  13670. next = RE_AT_END.lastIndex - 2;
  13671. }
  13672. currentToken = ['at-word', css.slice(pos, next + 1), line, pos - offset, line, next - offset];
  13673. pos = next;
  13674. break;
  13675. case BACKSLASH:
  13676. next = pos;
  13677. escape = true;
  13678. while (css.charCodeAt(next + 1) === BACKSLASH) {
  13679. next += 1;
  13680. escape = !escape;
  13681. }
  13682. code = css.charCodeAt(next + 1);
  13683. if (escape && code !== SLASH && code !== SPACE && code !== NEWLINE && code !== TAB && code !== CR && code !== FEED) {
  13684. next += 1;
  13685. if (RE_HEX_ESCAPE.test(css.charAt(next))) {
  13686. while (RE_HEX_ESCAPE.test(css.charAt(next + 1))) {
  13687. next += 1;
  13688. }
  13689. if (css.charCodeAt(next + 1) === SPACE) {
  13690. next += 1;
  13691. }
  13692. }
  13693. }
  13694. currentToken = ['word', css.slice(pos, next + 1), line, pos - offset, line, next - offset];
  13695. pos = next;
  13696. break;
  13697. default:
  13698. if (code === SLASH && css.charCodeAt(pos + 1) === ASTERISK) {
  13699. next = css.indexOf('*/', pos + 2) + 1;
  13700. if (next === 0) {
  13701. if (ignore || ignoreUnclosed) {
  13702. next = css.length;
  13703. } else {
  13704. unclosed('comment');
  13705. }
  13706. }
  13707. content = css.slice(pos, next + 1);
  13708. lines = content.split('\n');
  13709. last = lines.length - 1;
  13710. if (last > 0) {
  13711. nextLine = line + last;
  13712. nextOffset = next - lines[last].length;
  13713. } else {
  13714. nextLine = line;
  13715. nextOffset = offset;
  13716. }
  13717. currentToken = ['comment', content, line, pos - offset, nextLine, next - nextOffset];
  13718. offset = nextOffset;
  13719. line = nextLine;
  13720. pos = next;
  13721. } else {
  13722. RE_WORD_END.lastIndex = pos + 1;
  13723. RE_WORD_END.test(css);
  13724. if (RE_WORD_END.lastIndex === 0) {
  13725. next = css.length - 1;
  13726. } else {
  13727. next = RE_WORD_END.lastIndex - 2;
  13728. }
  13729. currentToken = ['word', css.slice(pos, next + 1), line, pos - offset, line, next - offset];
  13730. buffer.push(currentToken);
  13731. pos = next;
  13732. }
  13733. break;
  13734. }
  13735. pos++;
  13736. return currentToken;
  13737. }
  13738. function back(token) {
  13739. returned.push(token);
  13740. }
  13741. return {
  13742. back: back,
  13743. nextToken: nextToken,
  13744. endOfFile: endOfFile,
  13745. position: position
  13746. };
  13747. }
  13748. module.exports = exports.default;
  13749. },{}],190:[function(require,module,exports){
  13750. "use strict";
  13751. exports.__esModule = true;
  13752. exports.default = void 0;
  13753. /**
  13754. * Contains helpers for working with vendor prefixes.
  13755. *
  13756. * @example
  13757. * const vendor = postcss.vendor
  13758. *
  13759. * @namespace vendor
  13760. */
  13761. var vendor = {
  13762. /**
  13763. * Returns the vendor prefix extracted from an input string.
  13764. *
  13765. * @param {string} prop String with or without vendor prefix.
  13766. *
  13767. * @return {string} vendor prefix or empty string
  13768. *
  13769. * @example
  13770. * postcss.vendor.prefix('-moz-tab-size') //=> '-moz-'
  13771. * postcss.vendor.prefix('tab-size') //=> ''
  13772. */
  13773. prefix: function prefix(prop) {
  13774. var match = prop.match(/^(-\w+-)/);
  13775. if (match) {
  13776. return match[0];
  13777. }
  13778. return '';
  13779. },
  13780. /**
  13781. * Returns the input string stripped of its vendor prefix.
  13782. *
  13783. * @param {string} prop String with or without vendor prefix.
  13784. *
  13785. * @return {string} String name without vendor prefixes.
  13786. *
  13787. * @example
  13788. * postcss.vendor.unprefixed('-moz-tab-size') //=> 'tab-size'
  13789. */
  13790. unprefixed: function unprefixed(prop) {
  13791. return prop.replace(/^-\w+-/, '');
  13792. }
  13793. };
  13794. var _default = vendor;
  13795. exports.default = _default;
  13796. module.exports = exports.default;
  13797. },{}],191:[function(require,module,exports){
  13798. "use strict";
  13799. exports.__esModule = true;
  13800. exports.default = warnOnce;
  13801. var printed = {};
  13802. function warnOnce(message) {
  13803. if (printed[message]) return;
  13804. printed[message] = true;
  13805. if (typeof console !== 'undefined' && console.warn) {
  13806. console.warn(message);
  13807. }
  13808. }
  13809. module.exports = exports.default;
  13810. },{}],192:[function(require,module,exports){
  13811. "use strict";
  13812. exports.__esModule = true;
  13813. exports.default = void 0;
  13814. /**
  13815. * Represents a plugin’s warning. It can be created using {@link Node#warn}.
  13816. *
  13817. * @example
  13818. * if (decl.important) {
  13819. * decl.warn(result, 'Avoid !important', { word: '!important' })
  13820. * }
  13821. */
  13822. var Warning = /*#__PURE__*/function () {
  13823. /**
  13824. * @param {string} text Warning message.
  13825. * @param {Object} [opts] Warning options.
  13826. * @param {Node} opts.node CSS node that caused the warning.
  13827. * @param {string} opts.word Word in CSS source that caused the warning.
  13828. * @param {number} opts.index Index in CSS node string that caused
  13829. * the warning.
  13830. * @param {string} opts.plugin Name of the plugin that created
  13831. * this warning. {@link Result#warn} fills
  13832. * this property automatically.
  13833. */
  13834. function Warning(text, opts) {
  13835. if (opts === void 0) {
  13836. opts = {};
  13837. }
  13838. /**
  13839. * Type to filter warnings from {@link Result#messages}.
  13840. * Always equal to `"warning"`.
  13841. *
  13842. * @type {string}
  13843. *
  13844. * @example
  13845. * const nonWarning = result.messages.filter(i => i.type !== 'warning')
  13846. */
  13847. this.type = 'warning';
  13848. /**
  13849. * The warning message.
  13850. *
  13851. * @type {string}
  13852. *
  13853. * @example
  13854. * warning.text //=> 'Try to avoid !important'
  13855. */
  13856. this.text = text;
  13857. if (opts.node && opts.node.source) {
  13858. var pos = opts.node.positionBy(opts);
  13859. /**
  13860. * Line in the input file with this warning’s source.
  13861. * @type {number}
  13862. *
  13863. * @example
  13864. * warning.line //=> 5
  13865. */
  13866. this.line = pos.line;
  13867. /**
  13868. * Column in the input file with this warning’s source.
  13869. *
  13870. * @type {number}
  13871. *
  13872. * @example
  13873. * warning.column //=> 6
  13874. */
  13875. this.column = pos.column;
  13876. }
  13877. for (var opt in opts) {
  13878. this[opt] = opts[opt];
  13879. }
  13880. }
  13881. /**
  13882. * Returns a warning position and message.
  13883. *
  13884. * @example
  13885. * warning.toString() //=> 'postcss-lint:a.css:10:14: Avoid !important'
  13886. *
  13887. * @return {string} Warning position and message.
  13888. */
  13889. var _proto = Warning.prototype;
  13890. _proto.toString = function toString() {
  13891. if (this.node) {
  13892. return this.node.error(this.text, {
  13893. plugin: this.plugin,
  13894. index: this.index,
  13895. word: this.word
  13896. }).message;
  13897. }
  13898. if (this.plugin) {
  13899. return this.plugin + ': ' + this.text;
  13900. }
  13901. return this.text;
  13902. }
  13903. /**
  13904. * @memberof Warning#
  13905. * @member {string} plugin The name of the plugin that created
  13906. * it will fill this property automatically.
  13907. * this warning. When you call {@link Node#warn}
  13908. *
  13909. * @example
  13910. * warning.plugin //=> 'postcss-important'
  13911. */
  13912. /**
  13913. * @memberof Warning#
  13914. * @member {Node} node Contains the CSS node that caused the warning.
  13915. *
  13916. * @example
  13917. * warning.node.toString() //=> 'color: white !important'
  13918. */
  13919. ;
  13920. return Warning;
  13921. }();
  13922. var _default = Warning;
  13923. exports.default = _default;
  13924. module.exports = exports.default;
  13925. },{}],193:[function(require,module,exports){
  13926. // shim for using process in browser
  13927. var process = module.exports = {};
  13928. // cached from whatever global is present so that test runners that stub it
  13929. // don't break things. But we need to wrap it in a try catch in case it is
  13930. // wrapped in strict mode code which doesn't define any globals. It's inside a
  13931. // function because try/catches deoptimize in certain engines.
  13932. var cachedSetTimeout;
  13933. var cachedClearTimeout;
  13934. function defaultSetTimout() {
  13935. throw new Error('setTimeout has not been defined');
  13936. }
  13937. function defaultClearTimeout () {
  13938. throw new Error('clearTimeout has not been defined');
  13939. }
  13940. (function () {
  13941. try {
  13942. if (typeof setTimeout === 'function') {
  13943. cachedSetTimeout = setTimeout;
  13944. } else {
  13945. cachedSetTimeout = defaultSetTimout;
  13946. }
  13947. } catch (e) {
  13948. cachedSetTimeout = defaultSetTimout;
  13949. }
  13950. try {
  13951. if (typeof clearTimeout === 'function') {
  13952. cachedClearTimeout = clearTimeout;
  13953. } else {
  13954. cachedClearTimeout = defaultClearTimeout;
  13955. }
  13956. } catch (e) {
  13957. cachedClearTimeout = defaultClearTimeout;
  13958. }
  13959. } ())
  13960. function runTimeout(fun) {
  13961. if (cachedSetTimeout === setTimeout) {
  13962. //normal enviroments in sane situations
  13963. return setTimeout(fun, 0);
  13964. }
  13965. // if setTimeout wasn't available but was latter defined
  13966. if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
  13967. cachedSetTimeout = setTimeout;
  13968. return setTimeout(fun, 0);
  13969. }
  13970. try {
  13971. // when when somebody has screwed with setTimeout but no I.E. maddness
  13972. return cachedSetTimeout(fun, 0);
  13973. } catch(e){
  13974. try {
  13975. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  13976. return cachedSetTimeout.call(null, fun, 0);
  13977. } catch(e){
  13978. // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
  13979. return cachedSetTimeout.call(this, fun, 0);
  13980. }
  13981. }
  13982. }
  13983. function runClearTimeout(marker) {
  13984. if (cachedClearTimeout === clearTimeout) {
  13985. //normal enviroments in sane situations
  13986. return clearTimeout(marker);
  13987. }
  13988. // if clearTimeout wasn't available but was latter defined
  13989. if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
  13990. cachedClearTimeout = clearTimeout;
  13991. return clearTimeout(marker);
  13992. }
  13993. try {
  13994. // when when somebody has screwed with setTimeout but no I.E. maddness
  13995. return cachedClearTimeout(marker);
  13996. } catch (e){
  13997. try {
  13998. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  13999. return cachedClearTimeout.call(null, marker);
  14000. } catch (e){
  14001. // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
  14002. // Some versions of I.E. have different rules for clearTimeout vs setTimeout
  14003. return cachedClearTimeout.call(this, marker);
  14004. }
  14005. }
  14006. }
  14007. var queue = [];
  14008. var draining = false;
  14009. var currentQueue;
  14010. var queueIndex = -1;
  14011. function cleanUpNextTick() {
  14012. if (!draining || !currentQueue) {
  14013. return;
  14014. }
  14015. draining = false;
  14016. if (currentQueue.length) {
  14017. queue = currentQueue.concat(queue);
  14018. } else {
  14019. queueIndex = -1;
  14020. }
  14021. if (queue.length) {
  14022. drainQueue();
  14023. }
  14024. }
  14025. function drainQueue() {
  14026. if (draining) {
  14027. return;
  14028. }
  14029. var timeout = runTimeout(cleanUpNextTick);
  14030. draining = true;
  14031. var len = queue.length;
  14032. while(len) {
  14033. currentQueue = queue;
  14034. queue = [];
  14035. while (++queueIndex < len) {
  14036. if (currentQueue) {
  14037. currentQueue[queueIndex].run();
  14038. }
  14039. }
  14040. queueIndex = -1;
  14041. len = queue.length;
  14042. }
  14043. currentQueue = null;
  14044. draining = false;
  14045. runClearTimeout(timeout);
  14046. }
  14047. process.nextTick = function (fun) {
  14048. var args = new Array(arguments.length - 1);
  14049. if (arguments.length > 1) {
  14050. for (var i = 1; i < arguments.length; i++) {
  14051. args[i - 1] = arguments[i];
  14052. }
  14053. }
  14054. queue.push(new Item(fun, args));
  14055. if (queue.length === 1 && !draining) {
  14056. runTimeout(drainQueue);
  14057. }
  14058. };
  14059. // v8 likes predictible objects
  14060. function Item(fun, array) {
  14061. this.fun = fun;
  14062. this.array = array;
  14063. }
  14064. Item.prototype.run = function () {
  14065. this.fun.apply(null, this.array);
  14066. };
  14067. process.title = 'browser';
  14068. process.browser = true;
  14069. process.env = {};
  14070. process.argv = [];
  14071. process.version = ''; // empty string to avoid regexp issues
  14072. process.versions = {};
  14073. function noop() {}
  14074. process.on = noop;
  14075. process.addListener = noop;
  14076. process.once = noop;
  14077. process.off = noop;
  14078. process.removeListener = noop;
  14079. process.removeAllListeners = noop;
  14080. process.emit = noop;
  14081. process.prependListener = noop;
  14082. process.prependOnceListener = noop;
  14083. process.listeners = function (name) { return [] }
  14084. process.binding = function (name) {
  14085. throw new Error('process.binding is not supported');
  14086. };
  14087. process.cwd = function () { return '/' };
  14088. process.chdir = function (dir) {
  14089. throw new Error('process.chdir is not supported');
  14090. };
  14091. process.umask = function() { return 0; };
  14092. },{}],194:[function(require,module,exports){
  14093. (function (global){
  14094. /*! https://mths.be/punycode v1.4.1 by @mathias */
  14095. ;(function(root) {
  14096. /** Detect free variables */
  14097. var freeExports = typeof exports == 'object' && exports &&
  14098. !exports.nodeType && exports;
  14099. var freeModule = typeof module == 'object' && module &&
  14100. !module.nodeType && module;
  14101. var freeGlobal = typeof global == 'object' && global;
  14102. if (
  14103. freeGlobal.global === freeGlobal ||
  14104. freeGlobal.window === freeGlobal ||
  14105. freeGlobal.self === freeGlobal
  14106. ) {
  14107. root = freeGlobal;
  14108. }
  14109. /**
  14110. * The `punycode` object.
  14111. * @name punycode
  14112. * @type Object
  14113. */
  14114. var punycode,
  14115. /** Highest positive signed 32-bit float value */
  14116. maxInt = 2147483647, // aka. 0x7FFFFFFF or 2^31-1
  14117. /** Bootstring parameters */
  14118. base = 36,
  14119. tMin = 1,
  14120. tMax = 26,
  14121. skew = 38,
  14122. damp = 700,
  14123. initialBias = 72,
  14124. initialN = 128, // 0x80
  14125. delimiter = '-', // '\x2D'
  14126. /** Regular expressions */
  14127. regexPunycode = /^xn--/,
  14128. regexNonASCII = /[^\x20-\x7E]/, // unprintable ASCII chars + non-ASCII chars
  14129. regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g, // RFC 3490 separators
  14130. /** Error messages */
  14131. errors = {
  14132. 'overflow': 'Overflow: input needs wider integers to process',
  14133. 'not-basic': 'Illegal input >= 0x80 (not a basic code point)',
  14134. 'invalid-input': 'Invalid input'
  14135. },
  14136. /** Convenience shortcuts */
  14137. baseMinusTMin = base - tMin,
  14138. floor = Math.floor,
  14139. stringFromCharCode = String.fromCharCode,
  14140. /** Temporary variable */
  14141. key;
  14142. /*--------------------------------------------------------------------------*/
  14143. /**
  14144. * A generic error utility function.
  14145. * @private
  14146. * @param {String} type The error type.
  14147. * @returns {Error} Throws a `RangeError` with the applicable error message.
  14148. */
  14149. function error(type) {
  14150. throw new RangeError(errors[type]);
  14151. }
  14152. /**
  14153. * A generic `Array#map` utility function.
  14154. * @private
  14155. * @param {Array} array The array to iterate over.
  14156. * @param {Function} callback The function that gets called for every array
  14157. * item.
  14158. * @returns {Array} A new array of values returned by the callback function.
  14159. */
  14160. function map(array, fn) {
  14161. var length = array.length;
  14162. var result = [];
  14163. while (length--) {
  14164. result[length] = fn(array[length]);
  14165. }
  14166. return result;
  14167. }
  14168. /**
  14169. * A simple `Array#map`-like wrapper to work with domain name strings or email
  14170. * addresses.
  14171. * @private
  14172. * @param {String} domain The domain name or email address.
  14173. * @param {Function} callback The function that gets called for every
  14174. * character.
  14175. * @returns {Array} A new string of characters returned by the callback
  14176. * function.
  14177. */
  14178. function mapDomain(string, fn) {
  14179. var parts = string.split('@');
  14180. var result = '';
  14181. if (parts.length > 1) {
  14182. // In email addresses, only the domain name should be punycoded. Leave
  14183. // the local part (i.e. everything up to `@`) intact.
  14184. result = parts[0] + '@';
  14185. string = parts[1];
  14186. }
  14187. // Avoid `split(regex)` for IE8 compatibility. See #17.
  14188. string = string.replace(regexSeparators, '\x2E');
  14189. var labels = string.split('.');
  14190. var encoded = map(labels, fn).join('.');
  14191. return result + encoded;
  14192. }
  14193. /**
  14194. * Creates an array containing the numeric code points of each Unicode
  14195. * character in the string. While JavaScript uses UCS-2 internally,
  14196. * this function will convert a pair of surrogate halves (each of which
  14197. * UCS-2 exposes as separate characters) into a single code point,
  14198. * matching UTF-16.
  14199. * @see `punycode.ucs2.encode`
  14200. * @see <https://mathiasbynens.be/notes/javascript-encoding>
  14201. * @memberOf punycode.ucs2
  14202. * @name decode
  14203. * @param {String} string The Unicode input string (UCS-2).
  14204. * @returns {Array} The new array of code points.
  14205. */
  14206. function ucs2decode(string) {
  14207. var output = [],
  14208. counter = 0,
  14209. length = string.length,
  14210. value,
  14211. extra;
  14212. while (counter < length) {
  14213. value = string.charCodeAt(counter++);
  14214. if (value >= 0xD800 && value <= 0xDBFF && counter < length) {
  14215. // high surrogate, and there is a next character
  14216. extra = string.charCodeAt(counter++);
  14217. if ((extra & 0xFC00) == 0xDC00) { // low surrogate
  14218. output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
  14219. } else {
  14220. // unmatched surrogate; only append this code unit, in case the next
  14221. // code unit is the high surrogate of a surrogate pair
  14222. output.push(value);
  14223. counter--;
  14224. }
  14225. } else {
  14226. output.push(value);
  14227. }
  14228. }
  14229. return output;
  14230. }
  14231. /**
  14232. * Creates a string based on an array of numeric code points.
  14233. * @see `punycode.ucs2.decode`
  14234. * @memberOf punycode.ucs2
  14235. * @name encode
  14236. * @param {Array} codePoints The array of numeric code points.
  14237. * @returns {String} The new Unicode string (UCS-2).
  14238. */
  14239. function ucs2encode(array) {
  14240. return map(array, function(value) {
  14241. var output = '';
  14242. if (value > 0xFFFF) {
  14243. value -= 0x10000;
  14244. output += stringFromCharCode(value >>> 10 & 0x3FF | 0xD800);
  14245. value = 0xDC00 | value & 0x3FF;
  14246. }
  14247. output += stringFromCharCode(value);
  14248. return output;
  14249. }).join('');
  14250. }
  14251. /**
  14252. * Converts a basic code point into a digit/integer.
  14253. * @see `digitToBasic()`
  14254. * @private
  14255. * @param {Number} codePoint The basic numeric code point value.
  14256. * @returns {Number} The numeric value of a basic code point (for use in
  14257. * representing integers) in the range `0` to `base - 1`, or `base` if
  14258. * the code point does not represent a value.
  14259. */
  14260. function basicToDigit(codePoint) {
  14261. if (codePoint - 48 < 10) {
  14262. return codePoint - 22;
  14263. }
  14264. if (codePoint - 65 < 26) {
  14265. return codePoint - 65;
  14266. }
  14267. if (codePoint - 97 < 26) {
  14268. return codePoint - 97;
  14269. }
  14270. return base;
  14271. }
  14272. /**
  14273. * Converts a digit/integer into a basic code point.
  14274. * @see `basicToDigit()`
  14275. * @private
  14276. * @param {Number} digit The numeric value of a basic code point.
  14277. * @returns {Number} The basic code point whose value (when used for
  14278. * representing integers) is `digit`, which needs to be in the range
  14279. * `0` to `base - 1`. If `flag` is non-zero, the uppercase form is
  14280. * used; else, the lowercase form is used. The behavior is undefined
  14281. * if `flag` is non-zero and `digit` has no uppercase form.
  14282. */
  14283. function digitToBasic(digit, flag) {
  14284. // 0..25 map to ASCII a..z or A..Z
  14285. // 26..35 map to ASCII 0..9
  14286. return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5);
  14287. }
  14288. /**
  14289. * Bias adaptation function as per section 3.4 of RFC 3492.
  14290. * https://tools.ietf.org/html/rfc3492#section-3.4
  14291. * @private
  14292. */
  14293. function adapt(delta, numPoints, firstTime) {
  14294. var k = 0;
  14295. delta = firstTime ? floor(delta / damp) : delta >> 1;
  14296. delta += floor(delta / numPoints);
  14297. for (/* no initialization */; delta > baseMinusTMin * tMax >> 1; k += base) {
  14298. delta = floor(delta / baseMinusTMin);
  14299. }
  14300. return floor(k + (baseMinusTMin + 1) * delta / (delta + skew));
  14301. }
  14302. /**
  14303. * Converts a Punycode string of ASCII-only symbols to a string of Unicode
  14304. * symbols.
  14305. * @memberOf punycode
  14306. * @param {String} input The Punycode string of ASCII-only symbols.
  14307. * @returns {String} The resulting string of Unicode symbols.
  14308. */
  14309. function decode(input) {
  14310. // Don't use UCS-2
  14311. var output = [],
  14312. inputLength = input.length,
  14313. out,
  14314. i = 0,
  14315. n = initialN,
  14316. bias = initialBias,
  14317. basic,
  14318. j,
  14319. index,
  14320. oldi,
  14321. w,
  14322. k,
  14323. digit,
  14324. t,
  14325. /** Cached calculation results */
  14326. baseMinusT;
  14327. // Handle the basic code points: let `basic` be the number of input code
  14328. // points before the last delimiter, or `0` if there is none, then copy
  14329. // the first basic code points to the output.
  14330. basic = input.lastIndexOf(delimiter);
  14331. if (basic < 0) {
  14332. basic = 0;
  14333. }
  14334. for (j = 0; j < basic; ++j) {
  14335. // if it's not a basic code point
  14336. if (input.charCodeAt(j) >= 0x80) {
  14337. error('not-basic');
  14338. }
  14339. output.push(input.charCodeAt(j));
  14340. }
  14341. // Main decoding loop: start just after the last delimiter if any basic code
  14342. // points were copied; start at the beginning otherwise.
  14343. for (index = basic > 0 ? basic + 1 : 0; index < inputLength; /* no final expression */) {
  14344. // `index` is the index of the next character to be consumed.
  14345. // Decode a generalized variable-length integer into `delta`,
  14346. // which gets added to `i`. The overflow checking is easier
  14347. // if we increase `i` as we go, then subtract off its starting
  14348. // value at the end to obtain `delta`.
  14349. for (oldi = i, w = 1, k = base; /* no condition */; k += base) {
  14350. if (index >= inputLength) {
  14351. error('invalid-input');
  14352. }
  14353. digit = basicToDigit(input.charCodeAt(index++));
  14354. if (digit >= base || digit > floor((maxInt - i) / w)) {
  14355. error('overflow');
  14356. }
  14357. i += digit * w;
  14358. t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);
  14359. if (digit < t) {
  14360. break;
  14361. }
  14362. baseMinusT = base - t;
  14363. if (w > floor(maxInt / baseMinusT)) {
  14364. error('overflow');
  14365. }
  14366. w *= baseMinusT;
  14367. }
  14368. out = output.length + 1;
  14369. bias = adapt(i - oldi, out, oldi == 0);
  14370. // `i` was supposed to wrap around from `out` to `0`,
  14371. // incrementing `n` each time, so we'll fix that now:
  14372. if (floor(i / out) > maxInt - n) {
  14373. error('overflow');
  14374. }
  14375. n += floor(i / out);
  14376. i %= out;
  14377. // Insert `n` at position `i` of the output
  14378. output.splice(i++, 0, n);
  14379. }
  14380. return ucs2encode(output);
  14381. }
  14382. /**
  14383. * Converts a string of Unicode symbols (e.g. a domain name label) to a
  14384. * Punycode string of ASCII-only symbols.
  14385. * @memberOf punycode
  14386. * @param {String} input The string of Unicode symbols.
  14387. * @returns {String} The resulting Punycode string of ASCII-only symbols.
  14388. */
  14389. function encode(input) {
  14390. var n,
  14391. delta,
  14392. handledCPCount,
  14393. basicLength,
  14394. bias,
  14395. j,
  14396. m,
  14397. q,
  14398. k,
  14399. t,
  14400. currentValue,
  14401. output = [],
  14402. /** `inputLength` will hold the number of code points in `input`. */
  14403. inputLength,
  14404. /** Cached calculation results */
  14405. handledCPCountPlusOne,
  14406. baseMinusT,
  14407. qMinusT;
  14408. // Convert the input in UCS-2 to Unicode
  14409. input = ucs2decode(input);
  14410. // Cache the length
  14411. inputLength = input.length;
  14412. // Initialize the state
  14413. n = initialN;
  14414. delta = 0;
  14415. bias = initialBias;
  14416. // Handle the basic code points
  14417. for (j = 0; j < inputLength; ++j) {
  14418. currentValue = input[j];
  14419. if (currentValue < 0x80) {
  14420. output.push(stringFromCharCode(currentValue));
  14421. }
  14422. }
  14423. handledCPCount = basicLength = output.length;
  14424. // `handledCPCount` is the number of code points that have been handled;
  14425. // `basicLength` is the number of basic code points.
  14426. // Finish the basic string - if it is not empty - with a delimiter
  14427. if (basicLength) {
  14428. output.push(delimiter);
  14429. }
  14430. // Main encoding loop:
  14431. while (handledCPCount < inputLength) {
  14432. // All non-basic code points < n have been handled already. Find the next
  14433. // larger one:
  14434. for (m = maxInt, j = 0; j < inputLength; ++j) {
  14435. currentValue = input[j];
  14436. if (currentValue >= n && currentValue < m) {
  14437. m = currentValue;
  14438. }
  14439. }
  14440. // Increase `delta` enough to advance the decoder's <n,i> state to <m,0>,
  14441. // but guard against overflow
  14442. handledCPCountPlusOne = handledCPCount + 1;
  14443. if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) {
  14444. error('overflow');
  14445. }
  14446. delta += (m - n) * handledCPCountPlusOne;
  14447. n = m;
  14448. for (j = 0; j < inputLength; ++j) {
  14449. currentValue = input[j];
  14450. if (currentValue < n && ++delta > maxInt) {
  14451. error('overflow');
  14452. }
  14453. if (currentValue == n) {
  14454. // Represent delta as a generalized variable-length integer
  14455. for (q = delta, k = base; /* no condition */; k += base) {
  14456. t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);
  14457. if (q < t) {
  14458. break;
  14459. }
  14460. qMinusT = q - t;
  14461. baseMinusT = base - t;
  14462. output.push(
  14463. stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0))
  14464. );
  14465. q = floor(qMinusT / baseMinusT);
  14466. }
  14467. output.push(stringFromCharCode(digitToBasic(q, 0)));
  14468. bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength);
  14469. delta = 0;
  14470. ++handledCPCount;
  14471. }
  14472. }
  14473. ++delta;
  14474. ++n;
  14475. }
  14476. return output.join('');
  14477. }
  14478. /**
  14479. * Converts a Punycode string representing a domain name or an email address
  14480. * to Unicode. Only the Punycoded parts of the input will be converted, i.e.
  14481. * it doesn't matter if you call it on a string that has already been
  14482. * converted to Unicode.
  14483. * @memberOf punycode
  14484. * @param {String} input The Punycoded domain name or email address to
  14485. * convert to Unicode.
  14486. * @returns {String} The Unicode representation of the given Punycode
  14487. * string.
  14488. */
  14489. function toUnicode(input) {
  14490. return mapDomain(input, function(string) {
  14491. return regexPunycode.test(string)
  14492. ? decode(string.slice(4).toLowerCase())
  14493. : string;
  14494. });
  14495. }
  14496. /**
  14497. * Converts a Unicode string representing a domain name or an email address to
  14498. * Punycode. Only the non-ASCII parts of the domain name will be converted,
  14499. * i.e. it doesn't matter if you call it with a domain that's already in
  14500. * ASCII.
  14501. * @memberOf punycode
  14502. * @param {String} input The domain name or email address to convert, as a
  14503. * Unicode string.
  14504. * @returns {String} The Punycode representation of the given domain name or
  14505. * email address.
  14506. */
  14507. function toASCII(input) {
  14508. return mapDomain(input, function(string) {
  14509. return regexNonASCII.test(string)
  14510. ? 'xn--' + encode(string)
  14511. : string;
  14512. });
  14513. }
  14514. /*--------------------------------------------------------------------------*/
  14515. /** Define the public API */
  14516. punycode = {
  14517. /**
  14518. * A string representing the current Punycode.js version number.
  14519. * @memberOf punycode
  14520. * @type String
  14521. */
  14522. 'version': '1.4.1',
  14523. /**
  14524. * An object of methods to convert from JavaScript's internal character
  14525. * representation (UCS-2) to Unicode code points, and back.
  14526. * @see <https://mathiasbynens.be/notes/javascript-encoding>
  14527. * @memberOf punycode
  14528. * @type Object
  14529. */
  14530. 'ucs2': {
  14531. 'decode': ucs2decode,
  14532. 'encode': ucs2encode
  14533. },
  14534. 'decode': decode,
  14535. 'encode': encode,
  14536. 'toASCII': toASCII,
  14537. 'toUnicode': toUnicode
  14538. };
  14539. /** Expose `punycode` */
  14540. // Some AMD build optimizers, like r.js, check for specific condition patterns
  14541. // like the following:
  14542. if (
  14543. typeof define == 'function' &&
  14544. typeof define.amd == 'object' &&
  14545. define.amd
  14546. ) {
  14547. define('punycode', function() {
  14548. return punycode;
  14549. });
  14550. } else if (freeExports && freeModule) {
  14551. if (module.exports == freeExports) {
  14552. // in Node.js, io.js, or RingoJS v0.8.0+
  14553. freeModule.exports = punycode;
  14554. } else {
  14555. // in Narwhal or RingoJS v0.7.0-
  14556. for (key in punycode) {
  14557. punycode.hasOwnProperty(key) && (freeExports[key] = punycode[key]);
  14558. }
  14559. }
  14560. } else {
  14561. // in Rhino or a web browser
  14562. root.punycode = punycode;
  14563. }
  14564. }(this));
  14565. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  14566. },{}],195:[function(require,module,exports){
  14567. // Copyright Joyent, Inc. and other Node contributors.
  14568. //
  14569. // Permission is hereby granted, free of charge, to any person obtaining a
  14570. // copy of this software and associated documentation files (the
  14571. // "Software"), to deal in the Software without restriction, including
  14572. // without limitation the rights to use, copy, modify, merge, publish,
  14573. // distribute, sublicense, and/or sell copies of the Software, and to permit
  14574. // persons to whom the Software is furnished to do so, subject to the
  14575. // following conditions:
  14576. //
  14577. // The above copyright notice and this permission notice shall be included
  14578. // in all copies or substantial portions of the Software.
  14579. //
  14580. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  14581. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  14582. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  14583. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  14584. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  14585. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  14586. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  14587. 'use strict';
  14588. // If obj.hasOwnProperty has been overridden, then calling
  14589. // obj.hasOwnProperty(prop) will break.
  14590. // See: https://github.com/joyent/node/issues/1707
  14591. function hasOwnProperty(obj, prop) {
  14592. return Object.prototype.hasOwnProperty.call(obj, prop);
  14593. }
  14594. module.exports = function(qs, sep, eq, options) {
  14595. sep = sep || '&';
  14596. eq = eq || '=';
  14597. var obj = {};
  14598. if (typeof qs !== 'string' || qs.length === 0) {
  14599. return obj;
  14600. }
  14601. var regexp = /\+/g;
  14602. qs = qs.split(sep);
  14603. var maxKeys = 1000;
  14604. if (options && typeof options.maxKeys === 'number') {
  14605. maxKeys = options.maxKeys;
  14606. }
  14607. var len = qs.length;
  14608. // maxKeys <= 0 means that we should not limit keys count
  14609. if (maxKeys > 0 && len > maxKeys) {
  14610. len = maxKeys;
  14611. }
  14612. for (var i = 0; i < len; ++i) {
  14613. var x = qs[i].replace(regexp, '%20'),
  14614. idx = x.indexOf(eq),
  14615. kstr, vstr, k, v;
  14616. if (idx >= 0) {
  14617. kstr = x.substr(0, idx);
  14618. vstr = x.substr(idx + 1);
  14619. } else {
  14620. kstr = x;
  14621. vstr = '';
  14622. }
  14623. k = decodeURIComponent(kstr);
  14624. v = decodeURIComponent(vstr);
  14625. if (!hasOwnProperty(obj, k)) {
  14626. obj[k] = v;
  14627. } else if (isArray(obj[k])) {
  14628. obj[k].push(v);
  14629. } else {
  14630. obj[k] = [obj[k], v];
  14631. }
  14632. }
  14633. return obj;
  14634. };
  14635. var isArray = Array.isArray || function (xs) {
  14636. return Object.prototype.toString.call(xs) === '[object Array]';
  14637. };
  14638. },{}],196:[function(require,module,exports){
  14639. // Copyright Joyent, Inc. and other Node contributors.
  14640. //
  14641. // Permission is hereby granted, free of charge, to any person obtaining a
  14642. // copy of this software and associated documentation files (the
  14643. // "Software"), to deal in the Software without restriction, including
  14644. // without limitation the rights to use, copy, modify, merge, publish,
  14645. // distribute, sublicense, and/or sell copies of the Software, and to permit
  14646. // persons to whom the Software is furnished to do so, subject to the
  14647. // following conditions:
  14648. //
  14649. // The above copyright notice and this permission notice shall be included
  14650. // in all copies or substantial portions of the Software.
  14651. //
  14652. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  14653. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  14654. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  14655. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  14656. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  14657. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  14658. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  14659. 'use strict';
  14660. var stringifyPrimitive = function(v) {
  14661. switch (typeof v) {
  14662. case 'string':
  14663. return v;
  14664. case 'boolean':
  14665. return v ? 'true' : 'false';
  14666. case 'number':
  14667. return isFinite(v) ? v : '';
  14668. default:
  14669. return '';
  14670. }
  14671. };
  14672. module.exports = function(obj, sep, eq, name) {
  14673. sep = sep || '&';
  14674. eq = eq || '=';
  14675. if (obj === null) {
  14676. obj = undefined;
  14677. }
  14678. if (typeof obj === 'object') {
  14679. return map(objectKeys(obj), function(k) {
  14680. var ks = encodeURIComponent(stringifyPrimitive(k)) + eq;
  14681. if (isArray(obj[k])) {
  14682. return map(obj[k], function(v) {
  14683. return ks + encodeURIComponent(stringifyPrimitive(v));
  14684. }).join(sep);
  14685. } else {
  14686. return ks + encodeURIComponent(stringifyPrimitive(obj[k]));
  14687. }
  14688. }).join(sep);
  14689. }
  14690. if (!name) return '';
  14691. return encodeURIComponent(stringifyPrimitive(name)) + eq +
  14692. encodeURIComponent(stringifyPrimitive(obj));
  14693. };
  14694. var isArray = Array.isArray || function (xs) {
  14695. return Object.prototype.toString.call(xs) === '[object Array]';
  14696. };
  14697. function map (xs, f) {
  14698. if (xs.map) return xs.map(f);
  14699. var res = [];
  14700. for (var i = 0; i < xs.length; i++) {
  14701. res.push(f(xs[i], i));
  14702. }
  14703. return res;
  14704. }
  14705. var objectKeys = Object.keys || function (obj) {
  14706. var res = [];
  14707. for (var key in obj) {
  14708. if (Object.prototype.hasOwnProperty.call(obj, key)) res.push(key);
  14709. }
  14710. return res;
  14711. };
  14712. },{}],197:[function(require,module,exports){
  14713. 'use strict';
  14714. exports.decode = exports.parse = require('./decode');
  14715. exports.encode = exports.stringify = require('./encode');
  14716. },{"./decode":195,"./encode":196}],198:[function(require,module,exports){
  14717. /* -*- Mode: js; js-indent-level: 2; -*- */
  14718. /*
  14719. * Copyright 2011 Mozilla Foundation and contributors
  14720. * Licensed under the New BSD license. See LICENSE or:
  14721. * http://opensource.org/licenses/BSD-3-Clause
  14722. */
  14723. var util = require('./util');
  14724. var has = Object.prototype.hasOwnProperty;
  14725. var hasNativeMap = typeof Map !== "undefined";
  14726. /**
  14727. * A data structure which is a combination of an array and a set. Adding a new
  14728. * member is O(1), testing for membership is O(1), and finding the index of an
  14729. * element is O(1). Removing elements from the set is not supported. Only
  14730. * strings are supported for membership.
  14731. */
  14732. function ArraySet() {
  14733. this._array = [];
  14734. this._set = hasNativeMap ? new Map() : Object.create(null);
  14735. }
  14736. /**
  14737. * Static method for creating ArraySet instances from an existing array.
  14738. */
  14739. ArraySet.fromArray = function ArraySet_fromArray(aArray, aAllowDuplicates) {
  14740. var set = new ArraySet();
  14741. for (var i = 0, len = aArray.length; i < len; i++) {
  14742. set.add(aArray[i], aAllowDuplicates);
  14743. }
  14744. return set;
  14745. };
  14746. /**
  14747. * Return how many unique items are in this ArraySet. If duplicates have been
  14748. * added, than those do not count towards the size.
  14749. *
  14750. * @returns Number
  14751. */
  14752. ArraySet.prototype.size = function ArraySet_size() {
  14753. return hasNativeMap ? this._set.size : Object.getOwnPropertyNames(this._set).length;
  14754. };
  14755. /**
  14756. * Add the given string to this set.
  14757. *
  14758. * @param String aStr
  14759. */
  14760. ArraySet.prototype.add = function ArraySet_add(aStr, aAllowDuplicates) {
  14761. var sStr = hasNativeMap ? aStr : util.toSetString(aStr);
  14762. var isDuplicate = hasNativeMap ? this.has(aStr) : has.call(this._set, sStr);
  14763. var idx = this._array.length;
  14764. if (!isDuplicate || aAllowDuplicates) {
  14765. this._array.push(aStr);
  14766. }
  14767. if (!isDuplicate) {
  14768. if (hasNativeMap) {
  14769. this._set.set(aStr, idx);
  14770. } else {
  14771. this._set[sStr] = idx;
  14772. }
  14773. }
  14774. };
  14775. /**
  14776. * Is the given string a member of this set?
  14777. *
  14778. * @param String aStr
  14779. */
  14780. ArraySet.prototype.has = function ArraySet_has(aStr) {
  14781. if (hasNativeMap) {
  14782. return this._set.has(aStr);
  14783. } else {
  14784. var sStr = util.toSetString(aStr);
  14785. return has.call(this._set, sStr);
  14786. }
  14787. };
  14788. /**
  14789. * What is the index of the given string in the array?
  14790. *
  14791. * @param String aStr
  14792. */
  14793. ArraySet.prototype.indexOf = function ArraySet_indexOf(aStr) {
  14794. if (hasNativeMap) {
  14795. var idx = this._set.get(aStr);
  14796. if (idx >= 0) {
  14797. return idx;
  14798. }
  14799. } else {
  14800. var sStr = util.toSetString(aStr);
  14801. if (has.call(this._set, sStr)) {
  14802. return this._set[sStr];
  14803. }
  14804. }
  14805. throw new Error('"' + aStr + '" is not in the set.');
  14806. };
  14807. /**
  14808. * What is the element at the given index?
  14809. *
  14810. * @param Number aIdx
  14811. */
  14812. ArraySet.prototype.at = function ArraySet_at(aIdx) {
  14813. if (aIdx >= 0 && aIdx < this._array.length) {
  14814. return this._array[aIdx];
  14815. }
  14816. throw new Error('No element indexed by ' + aIdx);
  14817. };
  14818. /**
  14819. * Returns the array representation of this set (which has the proper indices
  14820. * indicated by indexOf). Note that this is a copy of the internal array used
  14821. * for storing the members so that no one can mess with internal state.
  14822. */
  14823. ArraySet.prototype.toArray = function ArraySet_toArray() {
  14824. return this._array.slice();
  14825. };
  14826. exports.ArraySet = ArraySet;
  14827. },{"./util":207}],199:[function(require,module,exports){
  14828. /* -*- Mode: js; js-indent-level: 2; -*- */
  14829. /*
  14830. * Copyright 2011 Mozilla Foundation and contributors
  14831. * Licensed under the New BSD license. See LICENSE or:
  14832. * http://opensource.org/licenses/BSD-3-Clause
  14833. *
  14834. * Based on the Base 64 VLQ implementation in Closure Compiler:
  14835. * https://code.google.com/p/closure-compiler/source/browse/trunk/src/com/google/debugging/sourcemap/Base64VLQ.java
  14836. *
  14837. * Copyright 2011 The Closure Compiler Authors. All rights reserved.
  14838. * Redistribution and use in source and binary forms, with or without
  14839. * modification, are permitted provided that the following conditions are
  14840. * met:
  14841. *
  14842. * * Redistributions of source code must retain the above copyright
  14843. * notice, this list of conditions and the following disclaimer.
  14844. * * Redistributions in binary form must reproduce the above
  14845. * copyright notice, this list of conditions and the following
  14846. * disclaimer in the documentation and/or other materials provided
  14847. * with the distribution.
  14848. * * Neither the name of Google Inc. nor the names of its
  14849. * contributors may be used to endorse or promote products derived
  14850. * from this software without specific prior written permission.
  14851. *
  14852. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  14853. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  14854. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  14855. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  14856. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  14857. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  14858. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  14859. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  14860. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  14861. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  14862. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  14863. */
  14864. var base64 = require('./base64');
  14865. // A single base 64 digit can contain 6 bits of data. For the base 64 variable
  14866. // length quantities we use in the source map spec, the first bit is the sign,
  14867. // the next four bits are the actual value, and the 6th bit is the
  14868. // continuation bit. The continuation bit tells us whether there are more
  14869. // digits in this value following this digit.
  14870. //
  14871. // Continuation
  14872. // | Sign
  14873. // | |
  14874. // V V
  14875. // 101011
  14876. var VLQ_BASE_SHIFT = 5;
  14877. // binary: 100000
  14878. var VLQ_BASE = 1 << VLQ_BASE_SHIFT;
  14879. // binary: 011111
  14880. var VLQ_BASE_MASK = VLQ_BASE - 1;
  14881. // binary: 100000
  14882. var VLQ_CONTINUATION_BIT = VLQ_BASE;
  14883. /**
  14884. * Converts from a two-complement value to a value where the sign bit is
  14885. * placed in the least significant bit. For example, as decimals:
  14886. * 1 becomes 2 (10 binary), -1 becomes 3 (11 binary)
  14887. * 2 becomes 4 (100 binary), -2 becomes 5 (101 binary)
  14888. */
  14889. function toVLQSigned(aValue) {
  14890. return aValue < 0
  14891. ? ((-aValue) << 1) + 1
  14892. : (aValue << 1) + 0;
  14893. }
  14894. /**
  14895. * Converts to a two-complement value from a value where the sign bit is
  14896. * placed in the least significant bit. For example, as decimals:
  14897. * 2 (10 binary) becomes 1, 3 (11 binary) becomes -1
  14898. * 4 (100 binary) becomes 2, 5 (101 binary) becomes -2
  14899. */
  14900. function fromVLQSigned(aValue) {
  14901. var isNegative = (aValue & 1) === 1;
  14902. var shifted = aValue >> 1;
  14903. return isNegative
  14904. ? -shifted
  14905. : shifted;
  14906. }
  14907. /**
  14908. * Returns the base 64 VLQ encoded value.
  14909. */
  14910. exports.encode = function base64VLQ_encode(aValue) {
  14911. var encoded = "";
  14912. var digit;
  14913. var vlq = toVLQSigned(aValue);
  14914. do {
  14915. digit = vlq & VLQ_BASE_MASK;
  14916. vlq >>>= VLQ_BASE_SHIFT;
  14917. if (vlq > 0) {
  14918. // There are still more digits in this value, so we must make sure the
  14919. // continuation bit is marked.
  14920. digit |= VLQ_CONTINUATION_BIT;
  14921. }
  14922. encoded += base64.encode(digit);
  14923. } while (vlq > 0);
  14924. return encoded;
  14925. };
  14926. /**
  14927. * Decodes the next base 64 VLQ value from the given string and returns the
  14928. * value and the rest of the string via the out parameter.
  14929. */
  14930. exports.decode = function base64VLQ_decode(aStr, aIndex, aOutParam) {
  14931. var strLen = aStr.length;
  14932. var result = 0;
  14933. var shift = 0;
  14934. var continuation, digit;
  14935. do {
  14936. if (aIndex >= strLen) {
  14937. throw new Error("Expected more digits in base 64 VLQ value.");
  14938. }
  14939. digit = base64.decode(aStr.charCodeAt(aIndex++));
  14940. if (digit === -1) {
  14941. throw new Error("Invalid base64 digit: " + aStr.charAt(aIndex - 1));
  14942. }
  14943. continuation = !!(digit & VLQ_CONTINUATION_BIT);
  14944. digit &= VLQ_BASE_MASK;
  14945. result = result + (digit << shift);
  14946. shift += VLQ_BASE_SHIFT;
  14947. } while (continuation);
  14948. aOutParam.value = fromVLQSigned(result);
  14949. aOutParam.rest = aIndex;
  14950. };
  14951. },{"./base64":200}],200:[function(require,module,exports){
  14952. /* -*- Mode: js; js-indent-level: 2; -*- */
  14953. /*
  14954. * Copyright 2011 Mozilla Foundation and contributors
  14955. * Licensed under the New BSD license. See LICENSE or:
  14956. * http://opensource.org/licenses/BSD-3-Clause
  14957. */
  14958. var intToCharMap = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'.split('');
  14959. /**
  14960. * Encode an integer in the range of 0 to 63 to a single base 64 digit.
  14961. */
  14962. exports.encode = function (number) {
  14963. if (0 <= number && number < intToCharMap.length) {
  14964. return intToCharMap[number];
  14965. }
  14966. throw new TypeError("Must be between 0 and 63: " + number);
  14967. };
  14968. /**
  14969. * Decode a single base 64 character code digit to an integer. Returns -1 on
  14970. * failure.
  14971. */
  14972. exports.decode = function (charCode) {
  14973. var bigA = 65; // 'A'
  14974. var bigZ = 90; // 'Z'
  14975. var littleA = 97; // 'a'
  14976. var littleZ = 122; // 'z'
  14977. var zero = 48; // '0'
  14978. var nine = 57; // '9'
  14979. var plus = 43; // '+'
  14980. var slash = 47; // '/'
  14981. var littleOffset = 26;
  14982. var numberOffset = 52;
  14983. // 0 - 25: ABCDEFGHIJKLMNOPQRSTUVWXYZ
  14984. if (bigA <= charCode && charCode <= bigZ) {
  14985. return (charCode - bigA);
  14986. }
  14987. // 26 - 51: abcdefghijklmnopqrstuvwxyz
  14988. if (littleA <= charCode && charCode <= littleZ) {
  14989. return (charCode - littleA + littleOffset);
  14990. }
  14991. // 52 - 61: 0123456789
  14992. if (zero <= charCode && charCode <= nine) {
  14993. return (charCode - zero + numberOffset);
  14994. }
  14995. // 62: +
  14996. if (charCode == plus) {
  14997. return 62;
  14998. }
  14999. // 63: /
  15000. if (charCode == slash) {
  15001. return 63;
  15002. }
  15003. // Invalid base64 digit.
  15004. return -1;
  15005. };
  15006. },{}],201:[function(require,module,exports){
  15007. /* -*- Mode: js; js-indent-level: 2; -*- */
  15008. /*
  15009. * Copyright 2011 Mozilla Foundation and contributors
  15010. * Licensed under the New BSD license. See LICENSE or:
  15011. * http://opensource.org/licenses/BSD-3-Clause
  15012. */
  15013. exports.GREATEST_LOWER_BOUND = 1;
  15014. exports.LEAST_UPPER_BOUND = 2;
  15015. /**
  15016. * Recursive implementation of binary search.
  15017. *
  15018. * @param aLow Indices here and lower do not contain the needle.
  15019. * @param aHigh Indices here and higher do not contain the needle.
  15020. * @param aNeedle The element being searched for.
  15021. * @param aHaystack The non-empty array being searched.
  15022. * @param aCompare Function which takes two elements and returns -1, 0, or 1.
  15023. * @param aBias Either 'binarySearch.GREATEST_LOWER_BOUND' or
  15024. * 'binarySearch.LEAST_UPPER_BOUND'. Specifies whether to return the
  15025. * closest element that is smaller than or greater than the one we are
  15026. * searching for, respectively, if the exact element cannot be found.
  15027. */
  15028. function recursiveSearch(aLow, aHigh, aNeedle, aHaystack, aCompare, aBias) {
  15029. // This function terminates when one of the following is true:
  15030. //
  15031. // 1. We find the exact element we are looking for.
  15032. //
  15033. // 2. We did not find the exact element, but we can return the index of
  15034. // the next-closest element.
  15035. //
  15036. // 3. We did not find the exact element, and there is no next-closest
  15037. // element than the one we are searching for, so we return -1.
  15038. var mid = Math.floor((aHigh - aLow) / 2) + aLow;
  15039. var cmp = aCompare(aNeedle, aHaystack[mid], true);
  15040. if (cmp === 0) {
  15041. // Found the element we are looking for.
  15042. return mid;
  15043. }
  15044. else if (cmp > 0) {
  15045. // Our needle is greater than aHaystack[mid].
  15046. if (aHigh - mid > 1) {
  15047. // The element is in the upper half.
  15048. return recursiveSearch(mid, aHigh, aNeedle, aHaystack, aCompare, aBias);
  15049. }
  15050. // The exact needle element was not found in this haystack. Determine if
  15051. // we are in termination case (3) or (2) and return the appropriate thing.
  15052. if (aBias == exports.LEAST_UPPER_BOUND) {
  15053. return aHigh < aHaystack.length ? aHigh : -1;
  15054. } else {
  15055. return mid;
  15056. }
  15057. }
  15058. else {
  15059. // Our needle is less than aHaystack[mid].
  15060. if (mid - aLow > 1) {
  15061. // The element is in the lower half.
  15062. return recursiveSearch(aLow, mid, aNeedle, aHaystack, aCompare, aBias);
  15063. }
  15064. // we are in termination case (3) or (2) and return the appropriate thing.
  15065. if (aBias == exports.LEAST_UPPER_BOUND) {
  15066. return mid;
  15067. } else {
  15068. return aLow < 0 ? -1 : aLow;
  15069. }
  15070. }
  15071. }
  15072. /**
  15073. * This is an implementation of binary search which will always try and return
  15074. * the index of the closest element if there is no exact hit. This is because
  15075. * mappings between original and generated line/col pairs are single points,
  15076. * and there is an implicit region between each of them, so a miss just means
  15077. * that you aren't on the very start of a region.
  15078. *
  15079. * @param aNeedle The element you are looking for.
  15080. * @param aHaystack The array that is being searched.
  15081. * @param aCompare A function which takes the needle and an element in the
  15082. * array and returns -1, 0, or 1 depending on whether the needle is less
  15083. * than, equal to, or greater than the element, respectively.
  15084. * @param aBias Either 'binarySearch.GREATEST_LOWER_BOUND' or
  15085. * 'binarySearch.LEAST_UPPER_BOUND'. Specifies whether to return the
  15086. * closest element that is smaller than or greater than the one we are
  15087. * searching for, respectively, if the exact element cannot be found.
  15088. * Defaults to 'binarySearch.GREATEST_LOWER_BOUND'.
  15089. */
  15090. exports.search = function search(aNeedle, aHaystack, aCompare, aBias) {
  15091. if (aHaystack.length === 0) {
  15092. return -1;
  15093. }
  15094. var index = recursiveSearch(-1, aHaystack.length, aNeedle, aHaystack,
  15095. aCompare, aBias || exports.GREATEST_LOWER_BOUND);
  15096. if (index < 0) {
  15097. return -1;
  15098. }
  15099. // We have found either the exact element, or the next-closest element than
  15100. // the one we are searching for. However, there may be more than one such
  15101. // element. Make sure we always return the smallest of these.
  15102. while (index - 1 >= 0) {
  15103. if (aCompare(aHaystack[index], aHaystack[index - 1], true) !== 0) {
  15104. break;
  15105. }
  15106. --index;
  15107. }
  15108. return index;
  15109. };
  15110. },{}],202:[function(require,module,exports){
  15111. /* -*- Mode: js; js-indent-level: 2; -*- */
  15112. /*
  15113. * Copyright 2014 Mozilla Foundation and contributors
  15114. * Licensed under the New BSD license. See LICENSE or:
  15115. * http://opensource.org/licenses/BSD-3-Clause
  15116. */
  15117. var util = require('./util');
  15118. /**
  15119. * Determine whether mappingB is after mappingA with respect to generated
  15120. * position.
  15121. */
  15122. function generatedPositionAfter(mappingA, mappingB) {
  15123. // Optimized for most common case
  15124. var lineA = mappingA.generatedLine;
  15125. var lineB = mappingB.generatedLine;
  15126. var columnA = mappingA.generatedColumn;
  15127. var columnB = mappingB.generatedColumn;
  15128. return lineB > lineA || lineB == lineA && columnB >= columnA ||
  15129. util.compareByGeneratedPositionsInflated(mappingA, mappingB) <= 0;
  15130. }
  15131. /**
  15132. * A data structure to provide a sorted view of accumulated mappings in a
  15133. * performance conscious manner. It trades a neglibable overhead in general
  15134. * case for a large speedup in case of mappings being added in order.
  15135. */
  15136. function MappingList() {
  15137. this._array = [];
  15138. this._sorted = true;
  15139. // Serves as infimum
  15140. this._last = {generatedLine: -1, generatedColumn: 0};
  15141. }
  15142. /**
  15143. * Iterate through internal items. This method takes the same arguments that
  15144. * `Array.prototype.forEach` takes.
  15145. *
  15146. * NOTE: The order of the mappings is NOT guaranteed.
  15147. */
  15148. MappingList.prototype.unsortedForEach =
  15149. function MappingList_forEach(aCallback, aThisArg) {
  15150. this._array.forEach(aCallback, aThisArg);
  15151. };
  15152. /**
  15153. * Add the given source mapping.
  15154. *
  15155. * @param Object aMapping
  15156. */
  15157. MappingList.prototype.add = function MappingList_add(aMapping) {
  15158. if (generatedPositionAfter(this._last, aMapping)) {
  15159. this._last = aMapping;
  15160. this._array.push(aMapping);
  15161. } else {
  15162. this._sorted = false;
  15163. this._array.push(aMapping);
  15164. }
  15165. };
  15166. /**
  15167. * Returns the flat, sorted array of mappings. The mappings are sorted by
  15168. * generated position.
  15169. *
  15170. * WARNING: This method returns internal data without copying, for
  15171. * performance. The return value must NOT be mutated, and should be treated as
  15172. * an immutable borrow. If you want to take ownership, you must make your own
  15173. * copy.
  15174. */
  15175. MappingList.prototype.toArray = function MappingList_toArray() {
  15176. if (!this._sorted) {
  15177. this._array.sort(util.compareByGeneratedPositionsInflated);
  15178. this._sorted = true;
  15179. }
  15180. return this._array;
  15181. };
  15182. exports.MappingList = MappingList;
  15183. },{"./util":207}],203:[function(require,module,exports){
  15184. /* -*- Mode: js; js-indent-level: 2; -*- */
  15185. /*
  15186. * Copyright 2011 Mozilla Foundation and contributors
  15187. * Licensed under the New BSD license. See LICENSE or:
  15188. * http://opensource.org/licenses/BSD-3-Clause
  15189. */
  15190. // It turns out that some (most?) JavaScript engines don't self-host
  15191. // `Array.prototype.sort`. This makes sense because C++ will likely remain
  15192. // faster than JS when doing raw CPU-intensive sorting. However, when using a
  15193. // custom comparator function, calling back and forth between the VM's C++ and
  15194. // JIT'd JS is rather slow *and* loses JIT type information, resulting in
  15195. // worse generated code for the comparator function than would be optimal. In
  15196. // fact, when sorting with a comparator, these costs outweigh the benefits of
  15197. // sorting in C++. By using our own JS-implemented Quick Sort (below), we get
  15198. // a ~3500ms mean speed-up in `bench/bench.html`.
  15199. /**
  15200. * Swap the elements indexed by `x` and `y` in the array `ary`.
  15201. *
  15202. * @param {Array} ary
  15203. * The array.
  15204. * @param {Number} x
  15205. * The index of the first item.
  15206. * @param {Number} y
  15207. * The index of the second item.
  15208. */
  15209. function swap(ary, x, y) {
  15210. var temp = ary[x];
  15211. ary[x] = ary[y];
  15212. ary[y] = temp;
  15213. }
  15214. /**
  15215. * Returns a random integer within the range `low .. high` inclusive.
  15216. *
  15217. * @param {Number} low
  15218. * The lower bound on the range.
  15219. * @param {Number} high
  15220. * The upper bound on the range.
  15221. */
  15222. function randomIntInRange(low, high) {
  15223. return Math.round(low + (Math.random() * (high - low)));
  15224. }
  15225. /**
  15226. * The Quick Sort algorithm.
  15227. *
  15228. * @param {Array} ary
  15229. * An array to sort.
  15230. * @param {function} comparator
  15231. * Function to use to compare two items.
  15232. * @param {Number} p
  15233. * Start index of the array
  15234. * @param {Number} r
  15235. * End index of the array
  15236. */
  15237. function doQuickSort(ary, comparator, p, r) {
  15238. // If our lower bound is less than our upper bound, we (1) partition the
  15239. // array into two pieces and (2) recurse on each half. If it is not, this is
  15240. // the empty array and our base case.
  15241. if (p < r) {
  15242. // (1) Partitioning.
  15243. //
  15244. // The partitioning chooses a pivot between `p` and `r` and moves all
  15245. // elements that are less than or equal to the pivot to the before it, and
  15246. // all the elements that are greater than it after it. The effect is that
  15247. // once partition is done, the pivot is in the exact place it will be when
  15248. // the array is put in sorted order, and it will not need to be moved
  15249. // again. This runs in O(n) time.
  15250. // Always choose a random pivot so that an input array which is reverse
  15251. // sorted does not cause O(n^2) running time.
  15252. var pivotIndex = randomIntInRange(p, r);
  15253. var i = p - 1;
  15254. swap(ary, pivotIndex, r);
  15255. var pivot = ary[r];
  15256. // Immediately after `j` is incremented in this loop, the following hold
  15257. // true:
  15258. //
  15259. // * Every element in `ary[p .. i]` is less than or equal to the pivot.
  15260. //
  15261. // * Every element in `ary[i+1 .. j-1]` is greater than the pivot.
  15262. for (var j = p; j < r; j++) {
  15263. if (comparator(ary[j], pivot) <= 0) {
  15264. i += 1;
  15265. swap(ary, i, j);
  15266. }
  15267. }
  15268. swap(ary, i + 1, j);
  15269. var q = i + 1;
  15270. // (2) Recurse on each half.
  15271. doQuickSort(ary, comparator, p, q - 1);
  15272. doQuickSort(ary, comparator, q + 1, r);
  15273. }
  15274. }
  15275. /**
  15276. * Sort the given array in-place with the given comparator function.
  15277. *
  15278. * @param {Array} ary
  15279. * An array to sort.
  15280. * @param {function} comparator
  15281. * Function to use to compare two items.
  15282. */
  15283. exports.quickSort = function (ary, comparator) {
  15284. doQuickSort(ary, comparator, 0, ary.length - 1);
  15285. };
  15286. },{}],204:[function(require,module,exports){
  15287. /* -*- Mode: js; js-indent-level: 2; -*- */
  15288. /*
  15289. * Copyright 2011 Mozilla Foundation and contributors
  15290. * Licensed under the New BSD license. See LICENSE or:
  15291. * http://opensource.org/licenses/BSD-3-Clause
  15292. */
  15293. var util = require('./util');
  15294. var binarySearch = require('./binary-search');
  15295. var ArraySet = require('./array-set').ArraySet;
  15296. var base64VLQ = require('./base64-vlq');
  15297. var quickSort = require('./quick-sort').quickSort;
  15298. function SourceMapConsumer(aSourceMap, aSourceMapURL) {
  15299. var sourceMap = aSourceMap;
  15300. if (typeof aSourceMap === 'string') {
  15301. sourceMap = util.parseSourceMapInput(aSourceMap);
  15302. }
  15303. return sourceMap.sections != null
  15304. ? new IndexedSourceMapConsumer(sourceMap, aSourceMapURL)
  15305. : new BasicSourceMapConsumer(sourceMap, aSourceMapURL);
  15306. }
  15307. SourceMapConsumer.fromSourceMap = function(aSourceMap, aSourceMapURL) {
  15308. return BasicSourceMapConsumer.fromSourceMap(aSourceMap, aSourceMapURL);
  15309. }
  15310. /**
  15311. * The version of the source mapping spec that we are consuming.
  15312. */
  15313. SourceMapConsumer.prototype._version = 3;
  15314. // `__generatedMappings` and `__originalMappings` are arrays that hold the
  15315. // parsed mapping coordinates from the source map's "mappings" attribute. They
  15316. // are lazily instantiated, accessed via the `_generatedMappings` and
  15317. // `_originalMappings` getters respectively, and we only parse the mappings
  15318. // and create these arrays once queried for a source location. We jump through
  15319. // these hoops because there can be many thousands of mappings, and parsing
  15320. // them is expensive, so we only want to do it if we must.
  15321. //
  15322. // Each object in the arrays is of the form:
  15323. //
  15324. // {
  15325. // generatedLine: The line number in the generated code,
  15326. // generatedColumn: The column number in the generated code,
  15327. // source: The path to the original source file that generated this
  15328. // chunk of code,
  15329. // originalLine: The line number in the original source that
  15330. // corresponds to this chunk of generated code,
  15331. // originalColumn: The column number in the original source that
  15332. // corresponds to this chunk of generated code,
  15333. // name: The name of the original symbol which generated this chunk of
  15334. // code.
  15335. // }
  15336. //
  15337. // All properties except for `generatedLine` and `generatedColumn` can be
  15338. // `null`.
  15339. //
  15340. // `_generatedMappings` is ordered by the generated positions.
  15341. //
  15342. // `_originalMappings` is ordered by the original positions.
  15343. SourceMapConsumer.prototype.__generatedMappings = null;
  15344. Object.defineProperty(SourceMapConsumer.prototype, '_generatedMappings', {
  15345. configurable: true,
  15346. enumerable: true,
  15347. get: function () {
  15348. if (!this.__generatedMappings) {
  15349. this._parseMappings(this._mappings, this.sourceRoot);
  15350. }
  15351. return this.__generatedMappings;
  15352. }
  15353. });
  15354. SourceMapConsumer.prototype.__originalMappings = null;
  15355. Object.defineProperty(SourceMapConsumer.prototype, '_originalMappings', {
  15356. configurable: true,
  15357. enumerable: true,
  15358. get: function () {
  15359. if (!this.__originalMappings) {
  15360. this._parseMappings(this._mappings, this.sourceRoot);
  15361. }
  15362. return this.__originalMappings;
  15363. }
  15364. });
  15365. SourceMapConsumer.prototype._charIsMappingSeparator =
  15366. function SourceMapConsumer_charIsMappingSeparator(aStr, index) {
  15367. var c = aStr.charAt(index);
  15368. return c === ";" || c === ",";
  15369. };
  15370. /**
  15371. * Parse the mappings in a string in to a data structure which we can easily
  15372. * query (the ordered arrays in the `this.__generatedMappings` and
  15373. * `this.__originalMappings` properties).
  15374. */
  15375. SourceMapConsumer.prototype._parseMappings =
  15376. function SourceMapConsumer_parseMappings(aStr, aSourceRoot) {
  15377. throw new Error("Subclasses must implement _parseMappings");
  15378. };
  15379. SourceMapConsumer.GENERATED_ORDER = 1;
  15380. SourceMapConsumer.ORIGINAL_ORDER = 2;
  15381. SourceMapConsumer.GREATEST_LOWER_BOUND = 1;
  15382. SourceMapConsumer.LEAST_UPPER_BOUND = 2;
  15383. /**
  15384. * Iterate over each mapping between an original source/line/column and a
  15385. * generated line/column in this source map.
  15386. *
  15387. * @param Function aCallback
  15388. * The function that is called with each mapping.
  15389. * @param Object aContext
  15390. * Optional. If specified, this object will be the value of `this` every
  15391. * time that `aCallback` is called.
  15392. * @param aOrder
  15393. * Either `SourceMapConsumer.GENERATED_ORDER` or
  15394. * `SourceMapConsumer.ORIGINAL_ORDER`. Specifies whether you want to
  15395. * iterate over the mappings sorted by the generated file's line/column
  15396. * order or the original's source/line/column order, respectively. Defaults to
  15397. * `SourceMapConsumer.GENERATED_ORDER`.
  15398. */
  15399. SourceMapConsumer.prototype.eachMapping =
  15400. function SourceMapConsumer_eachMapping(aCallback, aContext, aOrder) {
  15401. var context = aContext || null;
  15402. var order = aOrder || SourceMapConsumer.GENERATED_ORDER;
  15403. var mappings;
  15404. switch (order) {
  15405. case SourceMapConsumer.GENERATED_ORDER:
  15406. mappings = this._generatedMappings;
  15407. break;
  15408. case SourceMapConsumer.ORIGINAL_ORDER:
  15409. mappings = this._originalMappings;
  15410. break;
  15411. default:
  15412. throw new Error("Unknown order of iteration.");
  15413. }
  15414. var sourceRoot = this.sourceRoot;
  15415. mappings.map(function (mapping) {
  15416. var source = mapping.source === null ? null : this._sources.at(mapping.source);
  15417. source = util.computeSourceURL(sourceRoot, source, this._sourceMapURL);
  15418. return {
  15419. source: source,
  15420. generatedLine: mapping.generatedLine,
  15421. generatedColumn: mapping.generatedColumn,
  15422. originalLine: mapping.originalLine,
  15423. originalColumn: mapping.originalColumn,
  15424. name: mapping.name === null ? null : this._names.at(mapping.name)
  15425. };
  15426. }, this).forEach(aCallback, context);
  15427. };
  15428. /**
  15429. * Returns all generated line and column information for the original source,
  15430. * line, and column provided. If no column is provided, returns all mappings
  15431. * corresponding to a either the line we are searching for or the next
  15432. * closest line that has any mappings. Otherwise, returns all mappings
  15433. * corresponding to the given line and either the column we are searching for
  15434. * or the next closest column that has any offsets.
  15435. *
  15436. * The only argument is an object with the following properties:
  15437. *
  15438. * - source: The filename of the original source.
  15439. * - line: The line number in the original source. The line number is 1-based.
  15440. * - column: Optional. the column number in the original source.
  15441. * The column number is 0-based.
  15442. *
  15443. * and an array of objects is returned, each with the following properties:
  15444. *
  15445. * - line: The line number in the generated source, or null. The
  15446. * line number is 1-based.
  15447. * - column: The column number in the generated source, or null.
  15448. * The column number is 0-based.
  15449. */
  15450. SourceMapConsumer.prototype.allGeneratedPositionsFor =
  15451. function SourceMapConsumer_allGeneratedPositionsFor(aArgs) {
  15452. var line = util.getArg(aArgs, 'line');
  15453. // When there is no exact match, BasicSourceMapConsumer.prototype._findMapping
  15454. // returns the index of the closest mapping less than the needle. By
  15455. // setting needle.originalColumn to 0, we thus find the last mapping for
  15456. // the given line, provided such a mapping exists.
  15457. var needle = {
  15458. source: util.getArg(aArgs, 'source'),
  15459. originalLine: line,
  15460. originalColumn: util.getArg(aArgs, 'column', 0)
  15461. };
  15462. needle.source = this._findSourceIndex(needle.source);
  15463. if (needle.source < 0) {
  15464. return [];
  15465. }
  15466. var mappings = [];
  15467. var index = this._findMapping(needle,
  15468. this._originalMappings,
  15469. "originalLine",
  15470. "originalColumn",
  15471. util.compareByOriginalPositions,
  15472. binarySearch.LEAST_UPPER_BOUND);
  15473. if (index >= 0) {
  15474. var mapping = this._originalMappings[index];
  15475. if (aArgs.column === undefined) {
  15476. var originalLine = mapping.originalLine;
  15477. // Iterate until either we run out of mappings, or we run into
  15478. // a mapping for a different line than the one we found. Since
  15479. // mappings are sorted, this is guaranteed to find all mappings for
  15480. // the line we found.
  15481. while (mapping && mapping.originalLine === originalLine) {
  15482. mappings.push({
  15483. line: util.getArg(mapping, 'generatedLine', null),
  15484. column: util.getArg(mapping, 'generatedColumn', null),
  15485. lastColumn: util.getArg(mapping, 'lastGeneratedColumn', null)
  15486. });
  15487. mapping = this._originalMappings[++index];
  15488. }
  15489. } else {
  15490. var originalColumn = mapping.originalColumn;
  15491. // Iterate until either we run out of mappings, or we run into
  15492. // a mapping for a different line than the one we were searching for.
  15493. // Since mappings are sorted, this is guaranteed to find all mappings for
  15494. // the line we are searching for.
  15495. while (mapping &&
  15496. mapping.originalLine === line &&
  15497. mapping.originalColumn == originalColumn) {
  15498. mappings.push({
  15499. line: util.getArg(mapping, 'generatedLine', null),
  15500. column: util.getArg(mapping, 'generatedColumn', null),
  15501. lastColumn: util.getArg(mapping, 'lastGeneratedColumn', null)
  15502. });
  15503. mapping = this._originalMappings[++index];
  15504. }
  15505. }
  15506. }
  15507. return mappings;
  15508. };
  15509. exports.SourceMapConsumer = SourceMapConsumer;
  15510. /**
  15511. * A BasicSourceMapConsumer instance represents a parsed source map which we can
  15512. * query for information about the original file positions by giving it a file
  15513. * position in the generated source.
  15514. *
  15515. * The first parameter is the raw source map (either as a JSON string, or
  15516. * already parsed to an object). According to the spec, source maps have the
  15517. * following attributes:
  15518. *
  15519. * - version: Which version of the source map spec this map is following.
  15520. * - sources: An array of URLs to the original source files.
  15521. * - names: An array of identifiers which can be referrenced by individual mappings.
  15522. * - sourceRoot: Optional. The URL root from which all sources are relative.
  15523. * - sourcesContent: Optional. An array of contents of the original source files.
  15524. * - mappings: A string of base64 VLQs which contain the actual mappings.
  15525. * - file: Optional. The generated file this source map is associated with.
  15526. *
  15527. * Here is an example source map, taken from the source map spec[0]:
  15528. *
  15529. * {
  15530. * version : 3,
  15531. * file: "out.js",
  15532. * sourceRoot : "",
  15533. * sources: ["foo.js", "bar.js"],
  15534. * names: ["src", "maps", "are", "fun"],
  15535. * mappings: "AA,AB;;ABCDE;"
  15536. * }
  15537. *
  15538. * The second parameter, if given, is a string whose value is the URL
  15539. * at which the source map was found. This URL is used to compute the
  15540. * sources array.
  15541. *
  15542. * [0]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit?pli=1#
  15543. */
  15544. function BasicSourceMapConsumer(aSourceMap, aSourceMapURL) {
  15545. var sourceMap = aSourceMap;
  15546. if (typeof aSourceMap === 'string') {
  15547. sourceMap = util.parseSourceMapInput(aSourceMap);
  15548. }
  15549. var version = util.getArg(sourceMap, 'version');
  15550. var sources = util.getArg(sourceMap, 'sources');
  15551. // Sass 3.3 leaves out the 'names' array, so we deviate from the spec (which
  15552. // requires the array) to play nice here.
  15553. var names = util.getArg(sourceMap, 'names', []);
  15554. var sourceRoot = util.getArg(sourceMap, 'sourceRoot', null);
  15555. var sourcesContent = util.getArg(sourceMap, 'sourcesContent', null);
  15556. var mappings = util.getArg(sourceMap, 'mappings');
  15557. var file = util.getArg(sourceMap, 'file', null);
  15558. // Once again, Sass deviates from the spec and supplies the version as a
  15559. // string rather than a number, so we use loose equality checking here.
  15560. if (version != this._version) {
  15561. throw new Error('Unsupported version: ' + version);
  15562. }
  15563. if (sourceRoot) {
  15564. sourceRoot = util.normalize(sourceRoot);
  15565. }
  15566. sources = sources
  15567. .map(String)
  15568. // Some source maps produce relative source paths like "./foo.js" instead of
  15569. // "foo.js". Normalize these first so that future comparisons will succeed.
  15570. // See bugzil.la/1090768.
  15571. .map(util.normalize)
  15572. // Always ensure that absolute sources are internally stored relative to
  15573. // the source root, if the source root is absolute. Not doing this would
  15574. // be particularly problematic when the source root is a prefix of the
  15575. // source (valid, but why??). See github issue #199 and bugzil.la/1188982.
  15576. .map(function (source) {
  15577. return sourceRoot && util.isAbsolute(sourceRoot) && util.isAbsolute(source)
  15578. ? util.relative(sourceRoot, source)
  15579. : source;
  15580. });
  15581. // Pass `true` below to allow duplicate names and sources. While source maps
  15582. // are intended to be compressed and deduplicated, the TypeScript compiler
  15583. // sometimes generates source maps with duplicates in them. See Github issue
  15584. // #72 and bugzil.la/889492.
  15585. this._names = ArraySet.fromArray(names.map(String), true);
  15586. this._sources = ArraySet.fromArray(sources, true);
  15587. this._absoluteSources = this._sources.toArray().map(function (s) {
  15588. return util.computeSourceURL(sourceRoot, s, aSourceMapURL);
  15589. });
  15590. this.sourceRoot = sourceRoot;
  15591. this.sourcesContent = sourcesContent;
  15592. this._mappings = mappings;
  15593. this._sourceMapURL = aSourceMapURL;
  15594. this.file = file;
  15595. }
  15596. BasicSourceMapConsumer.prototype = Object.create(SourceMapConsumer.prototype);
  15597. BasicSourceMapConsumer.prototype.consumer = SourceMapConsumer;
  15598. /**
  15599. * Utility function to find the index of a source. Returns -1 if not
  15600. * found.
  15601. */
  15602. BasicSourceMapConsumer.prototype._findSourceIndex = function(aSource) {
  15603. var relativeSource = aSource;
  15604. if (this.sourceRoot != null) {
  15605. relativeSource = util.relative(this.sourceRoot, relativeSource);
  15606. }
  15607. if (this._sources.has(relativeSource)) {
  15608. return this._sources.indexOf(relativeSource);
  15609. }
  15610. // Maybe aSource is an absolute URL as returned by |sources|. In
  15611. // this case we can't simply undo the transform.
  15612. var i;
  15613. for (i = 0; i < this._absoluteSources.length; ++i) {
  15614. if (this._absoluteSources[i] == aSource) {
  15615. return i;
  15616. }
  15617. }
  15618. return -1;
  15619. };
  15620. /**
  15621. * Create a BasicSourceMapConsumer from a SourceMapGenerator.
  15622. *
  15623. * @param SourceMapGenerator aSourceMap
  15624. * The source map that will be consumed.
  15625. * @param String aSourceMapURL
  15626. * The URL at which the source map can be found (optional)
  15627. * @returns BasicSourceMapConsumer
  15628. */
  15629. BasicSourceMapConsumer.fromSourceMap =
  15630. function SourceMapConsumer_fromSourceMap(aSourceMap, aSourceMapURL) {
  15631. var smc = Object.create(BasicSourceMapConsumer.prototype);
  15632. var names = smc._names = ArraySet.fromArray(aSourceMap._names.toArray(), true);
  15633. var sources = smc._sources = ArraySet.fromArray(aSourceMap._sources.toArray(), true);
  15634. smc.sourceRoot = aSourceMap._sourceRoot;
  15635. smc.sourcesContent = aSourceMap._generateSourcesContent(smc._sources.toArray(),
  15636. smc.sourceRoot);
  15637. smc.file = aSourceMap._file;
  15638. smc._sourceMapURL = aSourceMapURL;
  15639. smc._absoluteSources = smc._sources.toArray().map(function (s) {
  15640. return util.computeSourceURL(smc.sourceRoot, s, aSourceMapURL);
  15641. });
  15642. // Because we are modifying the entries (by converting string sources and
  15643. // names to indices into the sources and names ArraySets), we have to make
  15644. // a copy of the entry or else bad things happen. Shared mutable state
  15645. // strikes again! See github issue #191.
  15646. var generatedMappings = aSourceMap._mappings.toArray().slice();
  15647. var destGeneratedMappings = smc.__generatedMappings = [];
  15648. var destOriginalMappings = smc.__originalMappings = [];
  15649. for (var i = 0, length = generatedMappings.length; i < length; i++) {
  15650. var srcMapping = generatedMappings[i];
  15651. var destMapping = new Mapping;
  15652. destMapping.generatedLine = srcMapping.generatedLine;
  15653. destMapping.generatedColumn = srcMapping.generatedColumn;
  15654. if (srcMapping.source) {
  15655. destMapping.source = sources.indexOf(srcMapping.source);
  15656. destMapping.originalLine = srcMapping.originalLine;
  15657. destMapping.originalColumn = srcMapping.originalColumn;
  15658. if (srcMapping.name) {
  15659. destMapping.name = names.indexOf(srcMapping.name);
  15660. }
  15661. destOriginalMappings.push(destMapping);
  15662. }
  15663. destGeneratedMappings.push(destMapping);
  15664. }
  15665. quickSort(smc.__originalMappings, util.compareByOriginalPositions);
  15666. return smc;
  15667. };
  15668. /**
  15669. * The version of the source mapping spec that we are consuming.
  15670. */
  15671. BasicSourceMapConsumer.prototype._version = 3;
  15672. /**
  15673. * The list of original sources.
  15674. */
  15675. Object.defineProperty(BasicSourceMapConsumer.prototype, 'sources', {
  15676. get: function () {
  15677. return this._absoluteSources.slice();
  15678. }
  15679. });
  15680. /**
  15681. * Provide the JIT with a nice shape / hidden class.
  15682. */
  15683. function Mapping() {
  15684. this.generatedLine = 0;
  15685. this.generatedColumn = 0;
  15686. this.source = null;
  15687. this.originalLine = null;
  15688. this.originalColumn = null;
  15689. this.name = null;
  15690. }
  15691. /**
  15692. * Parse the mappings in a string in to a data structure which we can easily
  15693. * query (the ordered arrays in the `this.__generatedMappings` and
  15694. * `this.__originalMappings` properties).
  15695. */
  15696. BasicSourceMapConsumer.prototype._parseMappings =
  15697. function SourceMapConsumer_parseMappings(aStr, aSourceRoot) {
  15698. var generatedLine = 1;
  15699. var previousGeneratedColumn = 0;
  15700. var previousOriginalLine = 0;
  15701. var previousOriginalColumn = 0;
  15702. var previousSource = 0;
  15703. var previousName = 0;
  15704. var length = aStr.length;
  15705. var index = 0;
  15706. var cachedSegments = {};
  15707. var temp = {};
  15708. var originalMappings = [];
  15709. var generatedMappings = [];
  15710. var mapping, str, segment, end, value;
  15711. while (index < length) {
  15712. if (aStr.charAt(index) === ';') {
  15713. generatedLine++;
  15714. index++;
  15715. previousGeneratedColumn = 0;
  15716. }
  15717. else if (aStr.charAt(index) === ',') {
  15718. index++;
  15719. }
  15720. else {
  15721. mapping = new Mapping();
  15722. mapping.generatedLine = generatedLine;
  15723. // Because each offset is encoded relative to the previous one,
  15724. // many segments often have the same encoding. We can exploit this
  15725. // fact by caching the parsed variable length fields of each segment,
  15726. // allowing us to avoid a second parse if we encounter the same
  15727. // segment again.
  15728. for (end = index; end < length; end++) {
  15729. if (this._charIsMappingSeparator(aStr, end)) {
  15730. break;
  15731. }
  15732. }
  15733. str = aStr.slice(index, end);
  15734. segment = cachedSegments[str];
  15735. if (segment) {
  15736. index += str.length;
  15737. } else {
  15738. segment = [];
  15739. while (index < end) {
  15740. base64VLQ.decode(aStr, index, temp);
  15741. value = temp.value;
  15742. index = temp.rest;
  15743. segment.push(value);
  15744. }
  15745. if (segment.length === 2) {
  15746. throw new Error('Found a source, but no line and column');
  15747. }
  15748. if (segment.length === 3) {
  15749. throw new Error('Found a source and line, but no column');
  15750. }
  15751. cachedSegments[str] = segment;
  15752. }
  15753. // Generated column.
  15754. mapping.generatedColumn = previousGeneratedColumn + segment[0];
  15755. previousGeneratedColumn = mapping.generatedColumn;
  15756. if (segment.length > 1) {
  15757. // Original source.
  15758. mapping.source = previousSource + segment[1];
  15759. previousSource += segment[1];
  15760. // Original line.
  15761. mapping.originalLine = previousOriginalLine + segment[2];
  15762. previousOriginalLine = mapping.originalLine;
  15763. // Lines are stored 0-based
  15764. mapping.originalLine += 1;
  15765. // Original column.
  15766. mapping.originalColumn = previousOriginalColumn + segment[3];
  15767. previousOriginalColumn = mapping.originalColumn;
  15768. if (segment.length > 4) {
  15769. // Original name.
  15770. mapping.name = previousName + segment[4];
  15771. previousName += segment[4];
  15772. }
  15773. }
  15774. generatedMappings.push(mapping);
  15775. if (typeof mapping.originalLine === 'number') {
  15776. originalMappings.push(mapping);
  15777. }
  15778. }
  15779. }
  15780. quickSort(generatedMappings, util.compareByGeneratedPositionsDeflated);
  15781. this.__generatedMappings = generatedMappings;
  15782. quickSort(originalMappings, util.compareByOriginalPositions);
  15783. this.__originalMappings = originalMappings;
  15784. };
  15785. /**
  15786. * Find the mapping that best matches the hypothetical "needle" mapping that
  15787. * we are searching for in the given "haystack" of mappings.
  15788. */
  15789. BasicSourceMapConsumer.prototype._findMapping =
  15790. function SourceMapConsumer_findMapping(aNeedle, aMappings, aLineName,
  15791. aColumnName, aComparator, aBias) {
  15792. // To return the position we are searching for, we must first find the
  15793. // mapping for the given position and then return the opposite position it
  15794. // points to. Because the mappings are sorted, we can use binary search to
  15795. // find the best mapping.
  15796. if (aNeedle[aLineName] <= 0) {
  15797. throw new TypeError('Line must be greater than or equal to 1, got '
  15798. + aNeedle[aLineName]);
  15799. }
  15800. if (aNeedle[aColumnName] < 0) {
  15801. throw new TypeError('Column must be greater than or equal to 0, got '
  15802. + aNeedle[aColumnName]);
  15803. }
  15804. return binarySearch.search(aNeedle, aMappings, aComparator, aBias);
  15805. };
  15806. /**
  15807. * Compute the last column for each generated mapping. The last column is
  15808. * inclusive.
  15809. */
  15810. BasicSourceMapConsumer.prototype.computeColumnSpans =
  15811. function SourceMapConsumer_computeColumnSpans() {
  15812. for (var index = 0; index < this._generatedMappings.length; ++index) {
  15813. var mapping = this._generatedMappings[index];
  15814. // Mappings do not contain a field for the last generated columnt. We
  15815. // can come up with an optimistic estimate, however, by assuming that
  15816. // mappings are contiguous (i.e. given two consecutive mappings, the
  15817. // first mapping ends where the second one starts).
  15818. if (index + 1 < this._generatedMappings.length) {
  15819. var nextMapping = this._generatedMappings[index + 1];
  15820. if (mapping.generatedLine === nextMapping.generatedLine) {
  15821. mapping.lastGeneratedColumn = nextMapping.generatedColumn - 1;
  15822. continue;
  15823. }
  15824. }
  15825. // The last mapping for each line spans the entire line.
  15826. mapping.lastGeneratedColumn = Infinity;
  15827. }
  15828. };
  15829. /**
  15830. * Returns the original source, line, and column information for the generated
  15831. * source's line and column positions provided. The only argument is an object
  15832. * with the following properties:
  15833. *
  15834. * - line: The line number in the generated source. The line number
  15835. * is 1-based.
  15836. * - column: The column number in the generated source. The column
  15837. * number is 0-based.
  15838. * - bias: Either 'SourceMapConsumer.GREATEST_LOWER_BOUND' or
  15839. * 'SourceMapConsumer.LEAST_UPPER_BOUND'. Specifies whether to return the
  15840. * closest element that is smaller than or greater than the one we are
  15841. * searching for, respectively, if the exact element cannot be found.
  15842. * Defaults to 'SourceMapConsumer.GREATEST_LOWER_BOUND'.
  15843. *
  15844. * and an object is returned with the following properties:
  15845. *
  15846. * - source: The original source file, or null.
  15847. * - line: The line number in the original source, or null. The
  15848. * line number is 1-based.
  15849. * - column: The column number in the original source, or null. The
  15850. * column number is 0-based.
  15851. * - name: The original identifier, or null.
  15852. */
  15853. BasicSourceMapConsumer.prototype.originalPositionFor =
  15854. function SourceMapConsumer_originalPositionFor(aArgs) {
  15855. var needle = {
  15856. generatedLine: util.getArg(aArgs, 'line'),
  15857. generatedColumn: util.getArg(aArgs, 'column')
  15858. };
  15859. var index = this._findMapping(
  15860. needle,
  15861. this._generatedMappings,
  15862. "generatedLine",
  15863. "generatedColumn",
  15864. util.compareByGeneratedPositionsDeflated,
  15865. util.getArg(aArgs, 'bias', SourceMapConsumer.GREATEST_LOWER_BOUND)
  15866. );
  15867. if (index >= 0) {
  15868. var mapping = this._generatedMappings[index];
  15869. if (mapping.generatedLine === needle.generatedLine) {
  15870. var source = util.getArg(mapping, 'source', null);
  15871. if (source !== null) {
  15872. source = this._sources.at(source);
  15873. source = util.computeSourceURL(this.sourceRoot, source, this._sourceMapURL);
  15874. }
  15875. var name = util.getArg(mapping, 'name', null);
  15876. if (name !== null) {
  15877. name = this._names.at(name);
  15878. }
  15879. return {
  15880. source: source,
  15881. line: util.getArg(mapping, 'originalLine', null),
  15882. column: util.getArg(mapping, 'originalColumn', null),
  15883. name: name
  15884. };
  15885. }
  15886. }
  15887. return {
  15888. source: null,
  15889. line: null,
  15890. column: null,
  15891. name: null
  15892. };
  15893. };
  15894. /**
  15895. * Return true if we have the source content for every source in the source
  15896. * map, false otherwise.
  15897. */
  15898. BasicSourceMapConsumer.prototype.hasContentsOfAllSources =
  15899. function BasicSourceMapConsumer_hasContentsOfAllSources() {
  15900. if (!this.sourcesContent) {
  15901. return false;
  15902. }
  15903. return this.sourcesContent.length >= this._sources.size() &&
  15904. !this.sourcesContent.some(function (sc) { return sc == null; });
  15905. };
  15906. /**
  15907. * Returns the original source content. The only argument is the url of the
  15908. * original source file. Returns null if no original source content is
  15909. * available.
  15910. */
  15911. BasicSourceMapConsumer.prototype.sourceContentFor =
  15912. function SourceMapConsumer_sourceContentFor(aSource, nullOnMissing) {
  15913. if (!this.sourcesContent) {
  15914. return null;
  15915. }
  15916. var index = this._findSourceIndex(aSource);
  15917. if (index >= 0) {
  15918. return this.sourcesContent[index];
  15919. }
  15920. var relativeSource = aSource;
  15921. if (this.sourceRoot != null) {
  15922. relativeSource = util.relative(this.sourceRoot, relativeSource);
  15923. }
  15924. var url;
  15925. if (this.sourceRoot != null
  15926. && (url = util.urlParse(this.sourceRoot))) {
  15927. // XXX: file:// URIs and absolute paths lead to unexpected behavior for
  15928. // many users. We can help them out when they expect file:// URIs to
  15929. // behave like it would if they were running a local HTTP server. See
  15930. // https://bugzilla.mozilla.org/show_bug.cgi?id=885597.
  15931. var fileUriAbsPath = relativeSource.replace(/^file:\/\//, "");
  15932. if (url.scheme == "file"
  15933. && this._sources.has(fileUriAbsPath)) {
  15934. return this.sourcesContent[this._sources.indexOf(fileUriAbsPath)]
  15935. }
  15936. if ((!url.path || url.path == "/")
  15937. && this._sources.has("/" + relativeSource)) {
  15938. return this.sourcesContent[this._sources.indexOf("/" + relativeSource)];
  15939. }
  15940. }
  15941. // This function is used recursively from
  15942. // IndexedSourceMapConsumer.prototype.sourceContentFor. In that case, we
  15943. // don't want to throw if we can't find the source - we just want to
  15944. // return null, so we provide a flag to exit gracefully.
  15945. if (nullOnMissing) {
  15946. return null;
  15947. }
  15948. else {
  15949. throw new Error('"' + relativeSource + '" is not in the SourceMap.');
  15950. }
  15951. };
  15952. /**
  15953. * Returns the generated line and column information for the original source,
  15954. * line, and column positions provided. The only argument is an object with
  15955. * the following properties:
  15956. *
  15957. * - source: The filename of the original source.
  15958. * - line: The line number in the original source. The line number
  15959. * is 1-based.
  15960. * - column: The column number in the original source. The column
  15961. * number is 0-based.
  15962. * - bias: Either 'SourceMapConsumer.GREATEST_LOWER_BOUND' or
  15963. * 'SourceMapConsumer.LEAST_UPPER_BOUND'. Specifies whether to return the
  15964. * closest element that is smaller than or greater than the one we are
  15965. * searching for, respectively, if the exact element cannot be found.
  15966. * Defaults to 'SourceMapConsumer.GREATEST_LOWER_BOUND'.
  15967. *
  15968. * and an object is returned with the following properties:
  15969. *
  15970. * - line: The line number in the generated source, or null. The
  15971. * line number is 1-based.
  15972. * - column: The column number in the generated source, or null.
  15973. * The column number is 0-based.
  15974. */
  15975. BasicSourceMapConsumer.prototype.generatedPositionFor =
  15976. function SourceMapConsumer_generatedPositionFor(aArgs) {
  15977. var source = util.getArg(aArgs, 'source');
  15978. source = this._findSourceIndex(source);
  15979. if (source < 0) {
  15980. return {
  15981. line: null,
  15982. column: null,
  15983. lastColumn: null
  15984. };
  15985. }
  15986. var needle = {
  15987. source: source,
  15988. originalLine: util.getArg(aArgs, 'line'),
  15989. originalColumn: util.getArg(aArgs, 'column')
  15990. };
  15991. var index = this._findMapping(
  15992. needle,
  15993. this._originalMappings,
  15994. "originalLine",
  15995. "originalColumn",
  15996. util.compareByOriginalPositions,
  15997. util.getArg(aArgs, 'bias', SourceMapConsumer.GREATEST_LOWER_BOUND)
  15998. );
  15999. if (index >= 0) {
  16000. var mapping = this._originalMappings[index];
  16001. if (mapping.source === needle.source) {
  16002. return {
  16003. line: util.getArg(mapping, 'generatedLine', null),
  16004. column: util.getArg(mapping, 'generatedColumn', null),
  16005. lastColumn: util.getArg(mapping, 'lastGeneratedColumn', null)
  16006. };
  16007. }
  16008. }
  16009. return {
  16010. line: null,
  16011. column: null,
  16012. lastColumn: null
  16013. };
  16014. };
  16015. exports.BasicSourceMapConsumer = BasicSourceMapConsumer;
  16016. /**
  16017. * An IndexedSourceMapConsumer instance represents a parsed source map which
  16018. * we can query for information. It differs from BasicSourceMapConsumer in
  16019. * that it takes "indexed" source maps (i.e. ones with a "sections" field) as
  16020. * input.
  16021. *
  16022. * The first parameter is a raw source map (either as a JSON string, or already
  16023. * parsed to an object). According to the spec for indexed source maps, they
  16024. * have the following attributes:
  16025. *
  16026. * - version: Which version of the source map spec this map is following.
  16027. * - file: Optional. The generated file this source map is associated with.
  16028. * - sections: A list of section definitions.
  16029. *
  16030. * Each value under the "sections" field has two fields:
  16031. * - offset: The offset into the original specified at which this section
  16032. * begins to apply, defined as an object with a "line" and "column"
  16033. * field.
  16034. * - map: A source map definition. This source map could also be indexed,
  16035. * but doesn't have to be.
  16036. *
  16037. * Instead of the "map" field, it's also possible to have a "url" field
  16038. * specifying a URL to retrieve a source map from, but that's currently
  16039. * unsupported.
  16040. *
  16041. * Here's an example source map, taken from the source map spec[0], but
  16042. * modified to omit a section which uses the "url" field.
  16043. *
  16044. * {
  16045. * version : 3,
  16046. * file: "app.js",
  16047. * sections: [{
  16048. * offset: {line:100, column:10},
  16049. * map: {
  16050. * version : 3,
  16051. * file: "section.js",
  16052. * sources: ["foo.js", "bar.js"],
  16053. * names: ["src", "maps", "are", "fun"],
  16054. * mappings: "AAAA,E;;ABCDE;"
  16055. * }
  16056. * }],
  16057. * }
  16058. *
  16059. * The second parameter, if given, is a string whose value is the URL
  16060. * at which the source map was found. This URL is used to compute the
  16061. * sources array.
  16062. *
  16063. * [0]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit#heading=h.535es3xeprgt
  16064. */
  16065. function IndexedSourceMapConsumer(aSourceMap, aSourceMapURL) {
  16066. var sourceMap = aSourceMap;
  16067. if (typeof aSourceMap === 'string') {
  16068. sourceMap = util.parseSourceMapInput(aSourceMap);
  16069. }
  16070. var version = util.getArg(sourceMap, 'version');
  16071. var sections = util.getArg(sourceMap, 'sections');
  16072. if (version != this._version) {
  16073. throw new Error('Unsupported version: ' + version);
  16074. }
  16075. this._sources = new ArraySet();
  16076. this._names = new ArraySet();
  16077. var lastOffset = {
  16078. line: -1,
  16079. column: 0
  16080. };
  16081. this._sections = sections.map(function (s) {
  16082. if (s.url) {
  16083. // The url field will require support for asynchronicity.
  16084. // See https://github.com/mozilla/source-map/issues/16
  16085. throw new Error('Support for url field in sections not implemented.');
  16086. }
  16087. var offset = util.getArg(s, 'offset');
  16088. var offsetLine = util.getArg(offset, 'line');
  16089. var offsetColumn = util.getArg(offset, 'column');
  16090. if (offsetLine < lastOffset.line ||
  16091. (offsetLine === lastOffset.line && offsetColumn < lastOffset.column)) {
  16092. throw new Error('Section offsets must be ordered and non-overlapping.');
  16093. }
  16094. lastOffset = offset;
  16095. return {
  16096. generatedOffset: {
  16097. // The offset fields are 0-based, but we use 1-based indices when
  16098. // encoding/decoding from VLQ.
  16099. generatedLine: offsetLine + 1,
  16100. generatedColumn: offsetColumn + 1
  16101. },
  16102. consumer: new SourceMapConsumer(util.getArg(s, 'map'), aSourceMapURL)
  16103. }
  16104. });
  16105. }
  16106. IndexedSourceMapConsumer.prototype = Object.create(SourceMapConsumer.prototype);
  16107. IndexedSourceMapConsumer.prototype.constructor = SourceMapConsumer;
  16108. /**
  16109. * The version of the source mapping spec that we are consuming.
  16110. */
  16111. IndexedSourceMapConsumer.prototype._version = 3;
  16112. /**
  16113. * The list of original sources.
  16114. */
  16115. Object.defineProperty(IndexedSourceMapConsumer.prototype, 'sources', {
  16116. get: function () {
  16117. var sources = [];
  16118. for (var i = 0; i < this._sections.length; i++) {
  16119. for (var j = 0; j < this._sections[i].consumer.sources.length; j++) {
  16120. sources.push(this._sections[i].consumer.sources[j]);
  16121. }
  16122. }
  16123. return sources;
  16124. }
  16125. });
  16126. /**
  16127. * Returns the original source, line, and column information for the generated
  16128. * source's line and column positions provided. The only argument is an object
  16129. * with the following properties:
  16130. *
  16131. * - line: The line number in the generated source. The line number
  16132. * is 1-based.
  16133. * - column: The column number in the generated source. The column
  16134. * number is 0-based.
  16135. *
  16136. * and an object is returned with the following properties:
  16137. *
  16138. * - source: The original source file, or null.
  16139. * - line: The line number in the original source, or null. The
  16140. * line number is 1-based.
  16141. * - column: The column number in the original source, or null. The
  16142. * column number is 0-based.
  16143. * - name: The original identifier, or null.
  16144. */
  16145. IndexedSourceMapConsumer.prototype.originalPositionFor =
  16146. function IndexedSourceMapConsumer_originalPositionFor(aArgs) {
  16147. var needle = {
  16148. generatedLine: util.getArg(aArgs, 'line'),
  16149. generatedColumn: util.getArg(aArgs, 'column')
  16150. };
  16151. // Find the section containing the generated position we're trying to map
  16152. // to an original position.
  16153. var sectionIndex = binarySearch.search(needle, this._sections,
  16154. function(needle, section) {
  16155. var cmp = needle.generatedLine - section.generatedOffset.generatedLine;
  16156. if (cmp) {
  16157. return cmp;
  16158. }
  16159. return (needle.generatedColumn -
  16160. section.generatedOffset.generatedColumn);
  16161. });
  16162. var section = this._sections[sectionIndex];
  16163. if (!section) {
  16164. return {
  16165. source: null,
  16166. line: null,
  16167. column: null,
  16168. name: null
  16169. };
  16170. }
  16171. return section.consumer.originalPositionFor({
  16172. line: needle.generatedLine -
  16173. (section.generatedOffset.generatedLine - 1),
  16174. column: needle.generatedColumn -
  16175. (section.generatedOffset.generatedLine === needle.generatedLine
  16176. ? section.generatedOffset.generatedColumn - 1
  16177. : 0),
  16178. bias: aArgs.bias
  16179. });
  16180. };
  16181. /**
  16182. * Return true if we have the source content for every source in the source
  16183. * map, false otherwise.
  16184. */
  16185. IndexedSourceMapConsumer.prototype.hasContentsOfAllSources =
  16186. function IndexedSourceMapConsumer_hasContentsOfAllSources() {
  16187. return this._sections.every(function (s) {
  16188. return s.consumer.hasContentsOfAllSources();
  16189. });
  16190. };
  16191. /**
  16192. * Returns the original source content. The only argument is the url of the
  16193. * original source file. Returns null if no original source content is
  16194. * available.
  16195. */
  16196. IndexedSourceMapConsumer.prototype.sourceContentFor =
  16197. function IndexedSourceMapConsumer_sourceContentFor(aSource, nullOnMissing) {
  16198. for (var i = 0; i < this._sections.length; i++) {
  16199. var section = this._sections[i];
  16200. var content = section.consumer.sourceContentFor(aSource, true);
  16201. if (content) {
  16202. return content;
  16203. }
  16204. }
  16205. if (nullOnMissing) {
  16206. return null;
  16207. }
  16208. else {
  16209. throw new Error('"' + aSource + '" is not in the SourceMap.');
  16210. }
  16211. };
  16212. /**
  16213. * Returns the generated line and column information for the original source,
  16214. * line, and column positions provided. The only argument is an object with
  16215. * the following properties:
  16216. *
  16217. * - source: The filename of the original source.
  16218. * - line: The line number in the original source. The line number
  16219. * is 1-based.
  16220. * - column: The column number in the original source. The column
  16221. * number is 0-based.
  16222. *
  16223. * and an object is returned with the following properties:
  16224. *
  16225. * - line: The line number in the generated source, or null. The
  16226. * line number is 1-based.
  16227. * - column: The column number in the generated source, or null.
  16228. * The column number is 0-based.
  16229. */
  16230. IndexedSourceMapConsumer.prototype.generatedPositionFor =
  16231. function IndexedSourceMapConsumer_generatedPositionFor(aArgs) {
  16232. for (var i = 0; i < this._sections.length; i++) {
  16233. var section = this._sections[i];
  16234. // Only consider this section if the requested source is in the list of
  16235. // sources of the consumer.
  16236. if (section.consumer._findSourceIndex(util.getArg(aArgs, 'source')) === -1) {
  16237. continue;
  16238. }
  16239. var generatedPosition = section.consumer.generatedPositionFor(aArgs);
  16240. if (generatedPosition) {
  16241. var ret = {
  16242. line: generatedPosition.line +
  16243. (section.generatedOffset.generatedLine - 1),
  16244. column: generatedPosition.column +
  16245. (section.generatedOffset.generatedLine === generatedPosition.line
  16246. ? section.generatedOffset.generatedColumn - 1
  16247. : 0)
  16248. };
  16249. return ret;
  16250. }
  16251. }
  16252. return {
  16253. line: null,
  16254. column: null
  16255. };
  16256. };
  16257. /**
  16258. * Parse the mappings in a string in to a data structure which we can easily
  16259. * query (the ordered arrays in the `this.__generatedMappings` and
  16260. * `this.__originalMappings` properties).
  16261. */
  16262. IndexedSourceMapConsumer.prototype._parseMappings =
  16263. function IndexedSourceMapConsumer_parseMappings(aStr, aSourceRoot) {
  16264. this.__generatedMappings = [];
  16265. this.__originalMappings = [];
  16266. for (var i = 0; i < this._sections.length; i++) {
  16267. var section = this._sections[i];
  16268. var sectionMappings = section.consumer._generatedMappings;
  16269. for (var j = 0; j < sectionMappings.length; j++) {
  16270. var mapping = sectionMappings[j];
  16271. var source = section.consumer._sources.at(mapping.source);
  16272. source = util.computeSourceURL(section.consumer.sourceRoot, source, this._sourceMapURL);
  16273. this._sources.add(source);
  16274. source = this._sources.indexOf(source);
  16275. var name = null;
  16276. if (mapping.name) {
  16277. name = section.consumer._names.at(mapping.name);
  16278. this._names.add(name);
  16279. name = this._names.indexOf(name);
  16280. }
  16281. // The mappings coming from the consumer for the section have
  16282. // generated positions relative to the start of the section, so we
  16283. // need to offset them to be relative to the start of the concatenated
  16284. // generated file.
  16285. var adjustedMapping = {
  16286. source: source,
  16287. generatedLine: mapping.generatedLine +
  16288. (section.generatedOffset.generatedLine - 1),
  16289. generatedColumn: mapping.generatedColumn +
  16290. (section.generatedOffset.generatedLine === mapping.generatedLine
  16291. ? section.generatedOffset.generatedColumn - 1
  16292. : 0),
  16293. originalLine: mapping.originalLine,
  16294. originalColumn: mapping.originalColumn,
  16295. name: name
  16296. };
  16297. this.__generatedMappings.push(adjustedMapping);
  16298. if (typeof adjustedMapping.originalLine === 'number') {
  16299. this.__originalMappings.push(adjustedMapping);
  16300. }
  16301. }
  16302. }
  16303. quickSort(this.__generatedMappings, util.compareByGeneratedPositionsDeflated);
  16304. quickSort(this.__originalMappings, util.compareByOriginalPositions);
  16305. };
  16306. exports.IndexedSourceMapConsumer = IndexedSourceMapConsumer;
  16307. },{"./array-set":198,"./base64-vlq":199,"./binary-search":201,"./quick-sort":203,"./util":207}],205:[function(require,module,exports){
  16308. /* -*- Mode: js; js-indent-level: 2; -*- */
  16309. /*
  16310. * Copyright 2011 Mozilla Foundation and contributors
  16311. * Licensed under the New BSD license. See LICENSE or:
  16312. * http://opensource.org/licenses/BSD-3-Clause
  16313. */
  16314. var base64VLQ = require('./base64-vlq');
  16315. var util = require('./util');
  16316. var ArraySet = require('./array-set').ArraySet;
  16317. var MappingList = require('./mapping-list').MappingList;
  16318. /**
  16319. * An instance of the SourceMapGenerator represents a source map which is
  16320. * being built incrementally. You may pass an object with the following
  16321. * properties:
  16322. *
  16323. * - file: The filename of the generated source.
  16324. * - sourceRoot: A root for all relative URLs in this source map.
  16325. */
  16326. function SourceMapGenerator(aArgs) {
  16327. if (!aArgs) {
  16328. aArgs = {};
  16329. }
  16330. this._file = util.getArg(aArgs, 'file', null);
  16331. this._sourceRoot = util.getArg(aArgs, 'sourceRoot', null);
  16332. this._skipValidation = util.getArg(aArgs, 'skipValidation', false);
  16333. this._sources = new ArraySet();
  16334. this._names = new ArraySet();
  16335. this._mappings = new MappingList();
  16336. this._sourcesContents = null;
  16337. }
  16338. SourceMapGenerator.prototype._version = 3;
  16339. /**
  16340. * Creates a new SourceMapGenerator based on a SourceMapConsumer
  16341. *
  16342. * @param aSourceMapConsumer The SourceMap.
  16343. */
  16344. SourceMapGenerator.fromSourceMap =
  16345. function SourceMapGenerator_fromSourceMap(aSourceMapConsumer) {
  16346. var sourceRoot = aSourceMapConsumer.sourceRoot;
  16347. var generator = new SourceMapGenerator({
  16348. file: aSourceMapConsumer.file,
  16349. sourceRoot: sourceRoot
  16350. });
  16351. aSourceMapConsumer.eachMapping(function (mapping) {
  16352. var newMapping = {
  16353. generated: {
  16354. line: mapping.generatedLine,
  16355. column: mapping.generatedColumn
  16356. }
  16357. };
  16358. if (mapping.source != null) {
  16359. newMapping.source = mapping.source;
  16360. if (sourceRoot != null) {
  16361. newMapping.source = util.relative(sourceRoot, newMapping.source);
  16362. }
  16363. newMapping.original = {
  16364. line: mapping.originalLine,
  16365. column: mapping.originalColumn
  16366. };
  16367. if (mapping.name != null) {
  16368. newMapping.name = mapping.name;
  16369. }
  16370. }
  16371. generator.addMapping(newMapping);
  16372. });
  16373. aSourceMapConsumer.sources.forEach(function (sourceFile) {
  16374. var sourceRelative = sourceFile;
  16375. if (sourceRoot !== null) {
  16376. sourceRelative = util.relative(sourceRoot, sourceFile);
  16377. }
  16378. if (!generator._sources.has(sourceRelative)) {
  16379. generator._sources.add(sourceRelative);
  16380. }
  16381. var content = aSourceMapConsumer.sourceContentFor(sourceFile);
  16382. if (content != null) {
  16383. generator.setSourceContent(sourceFile, content);
  16384. }
  16385. });
  16386. return generator;
  16387. };
  16388. /**
  16389. * Add a single mapping from original source line and column to the generated
  16390. * source's line and column for this source map being created. The mapping
  16391. * object should have the following properties:
  16392. *
  16393. * - generated: An object with the generated line and column positions.
  16394. * - original: An object with the original line and column positions.
  16395. * - source: The original source file (relative to the sourceRoot).
  16396. * - name: An optional original token name for this mapping.
  16397. */
  16398. SourceMapGenerator.prototype.addMapping =
  16399. function SourceMapGenerator_addMapping(aArgs) {
  16400. var generated = util.getArg(aArgs, 'generated');
  16401. var original = util.getArg(aArgs, 'original', null);
  16402. var source = util.getArg(aArgs, 'source', null);
  16403. var name = util.getArg(aArgs, 'name', null);
  16404. if (!this._skipValidation) {
  16405. this._validateMapping(generated, original, source, name);
  16406. }
  16407. if (source != null) {
  16408. source = String(source);
  16409. if (!this._sources.has(source)) {
  16410. this._sources.add(source);
  16411. }
  16412. }
  16413. if (name != null) {
  16414. name = String(name);
  16415. if (!this._names.has(name)) {
  16416. this._names.add(name);
  16417. }
  16418. }
  16419. this._mappings.add({
  16420. generatedLine: generated.line,
  16421. generatedColumn: generated.column,
  16422. originalLine: original != null && original.line,
  16423. originalColumn: original != null && original.column,
  16424. source: source,
  16425. name: name
  16426. });
  16427. };
  16428. /**
  16429. * Set the source content for a source file.
  16430. */
  16431. SourceMapGenerator.prototype.setSourceContent =
  16432. function SourceMapGenerator_setSourceContent(aSourceFile, aSourceContent) {
  16433. var source = aSourceFile;
  16434. if (this._sourceRoot != null) {
  16435. source = util.relative(this._sourceRoot, source);
  16436. }
  16437. if (aSourceContent != null) {
  16438. // Add the source content to the _sourcesContents map.
  16439. // Create a new _sourcesContents map if the property is null.
  16440. if (!this._sourcesContents) {
  16441. this._sourcesContents = Object.create(null);
  16442. }
  16443. this._sourcesContents[util.toSetString(source)] = aSourceContent;
  16444. } else if (this._sourcesContents) {
  16445. // Remove the source file from the _sourcesContents map.
  16446. // If the _sourcesContents map is empty, set the property to null.
  16447. delete this._sourcesContents[util.toSetString(source)];
  16448. if (Object.keys(this._sourcesContents).length === 0) {
  16449. this._sourcesContents = null;
  16450. }
  16451. }
  16452. };
  16453. /**
  16454. * Applies the mappings of a sub-source-map for a specific source file to the
  16455. * source map being generated. Each mapping to the supplied source file is
  16456. * rewritten using the supplied source map. Note: The resolution for the
  16457. * resulting mappings is the minimium of this map and the supplied map.
  16458. *
  16459. * @param aSourceMapConsumer The source map to be applied.
  16460. * @param aSourceFile Optional. The filename of the source file.
  16461. * If omitted, SourceMapConsumer's file property will be used.
  16462. * @param aSourceMapPath Optional. The dirname of the path to the source map
  16463. * to be applied. If relative, it is relative to the SourceMapConsumer.
  16464. * This parameter is needed when the two source maps aren't in the same
  16465. * directory, and the source map to be applied contains relative source
  16466. * paths. If so, those relative source paths need to be rewritten
  16467. * relative to the SourceMapGenerator.
  16468. */
  16469. SourceMapGenerator.prototype.applySourceMap =
  16470. function SourceMapGenerator_applySourceMap(aSourceMapConsumer, aSourceFile, aSourceMapPath) {
  16471. var sourceFile = aSourceFile;
  16472. // If aSourceFile is omitted, we will use the file property of the SourceMap
  16473. if (aSourceFile == null) {
  16474. if (aSourceMapConsumer.file == null) {
  16475. throw new Error(
  16476. 'SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, ' +
  16477. 'or the source map\'s "file" property. Both were omitted.'
  16478. );
  16479. }
  16480. sourceFile = aSourceMapConsumer.file;
  16481. }
  16482. var sourceRoot = this._sourceRoot;
  16483. // Make "sourceFile" relative if an absolute Url is passed.
  16484. if (sourceRoot != null) {
  16485. sourceFile = util.relative(sourceRoot, sourceFile);
  16486. }
  16487. // Applying the SourceMap can add and remove items from the sources and
  16488. // the names array.
  16489. var newSources = new ArraySet();
  16490. var newNames = new ArraySet();
  16491. // Find mappings for the "sourceFile"
  16492. this._mappings.unsortedForEach(function (mapping) {
  16493. if (mapping.source === sourceFile && mapping.originalLine != null) {
  16494. // Check if it can be mapped by the source map, then update the mapping.
  16495. var original = aSourceMapConsumer.originalPositionFor({
  16496. line: mapping.originalLine,
  16497. column: mapping.originalColumn
  16498. });
  16499. if (original.source != null) {
  16500. // Copy mapping
  16501. mapping.source = original.source;
  16502. if (aSourceMapPath != null) {
  16503. mapping.source = util.join(aSourceMapPath, mapping.source)
  16504. }
  16505. if (sourceRoot != null) {
  16506. mapping.source = util.relative(sourceRoot, mapping.source);
  16507. }
  16508. mapping.originalLine = original.line;
  16509. mapping.originalColumn = original.column;
  16510. if (original.name != null) {
  16511. mapping.name = original.name;
  16512. }
  16513. }
  16514. }
  16515. var source = mapping.source;
  16516. if (source != null && !newSources.has(source)) {
  16517. newSources.add(source);
  16518. }
  16519. var name = mapping.name;
  16520. if (name != null && !newNames.has(name)) {
  16521. newNames.add(name);
  16522. }
  16523. }, this);
  16524. this._sources = newSources;
  16525. this._names = newNames;
  16526. // Copy sourcesContents of applied map.
  16527. aSourceMapConsumer.sources.forEach(function (sourceFile) {
  16528. var content = aSourceMapConsumer.sourceContentFor(sourceFile);
  16529. if (content != null) {
  16530. if (aSourceMapPath != null) {
  16531. sourceFile = util.join(aSourceMapPath, sourceFile);
  16532. }
  16533. if (sourceRoot != null) {
  16534. sourceFile = util.relative(sourceRoot, sourceFile);
  16535. }
  16536. this.setSourceContent(sourceFile, content);
  16537. }
  16538. }, this);
  16539. };
  16540. /**
  16541. * A mapping can have one of the three levels of data:
  16542. *
  16543. * 1. Just the generated position.
  16544. * 2. The Generated position, original position, and original source.
  16545. * 3. Generated and original position, original source, as well as a name
  16546. * token.
  16547. *
  16548. * To maintain consistency, we validate that any new mapping being added falls
  16549. * in to one of these categories.
  16550. */
  16551. SourceMapGenerator.prototype._validateMapping =
  16552. function SourceMapGenerator_validateMapping(aGenerated, aOriginal, aSource,
  16553. aName) {
  16554. // When aOriginal is truthy but has empty values for .line and .column,
  16555. // it is most likely a programmer error. In this case we throw a very
  16556. // specific error message to try to guide them the right way.
  16557. // For example: https://github.com/Polymer/polymer-bundler/pull/519
  16558. if (aOriginal && typeof aOriginal.line !== 'number' && typeof aOriginal.column !== 'number') {
  16559. throw new Error(
  16560. 'original.line and original.column are not numbers -- you probably meant to omit ' +
  16561. 'the original mapping entirely and only map the generated position. If so, pass ' +
  16562. 'null for the original mapping instead of an object with empty or null values.'
  16563. );
  16564. }
  16565. if (aGenerated && 'line' in aGenerated && 'column' in aGenerated
  16566. && aGenerated.line > 0 && aGenerated.column >= 0
  16567. && !aOriginal && !aSource && !aName) {
  16568. // Case 1.
  16569. return;
  16570. }
  16571. else if (aGenerated && 'line' in aGenerated && 'column' in aGenerated
  16572. && aOriginal && 'line' in aOriginal && 'column' in aOriginal
  16573. && aGenerated.line > 0 && aGenerated.column >= 0
  16574. && aOriginal.line > 0 && aOriginal.column >= 0
  16575. && aSource) {
  16576. // Cases 2 and 3.
  16577. return;
  16578. }
  16579. else {
  16580. throw new Error('Invalid mapping: ' + JSON.stringify({
  16581. generated: aGenerated,
  16582. source: aSource,
  16583. original: aOriginal,
  16584. name: aName
  16585. }));
  16586. }
  16587. };
  16588. /**
  16589. * Serialize the accumulated mappings in to the stream of base 64 VLQs
  16590. * specified by the source map format.
  16591. */
  16592. SourceMapGenerator.prototype._serializeMappings =
  16593. function SourceMapGenerator_serializeMappings() {
  16594. var previousGeneratedColumn = 0;
  16595. var previousGeneratedLine = 1;
  16596. var previousOriginalColumn = 0;
  16597. var previousOriginalLine = 0;
  16598. var previousName = 0;
  16599. var previousSource = 0;
  16600. var result = '';
  16601. var next;
  16602. var mapping;
  16603. var nameIdx;
  16604. var sourceIdx;
  16605. var mappings = this._mappings.toArray();
  16606. for (var i = 0, len = mappings.length; i < len; i++) {
  16607. mapping = mappings[i];
  16608. next = ''
  16609. if (mapping.generatedLine !== previousGeneratedLine) {
  16610. previousGeneratedColumn = 0;
  16611. while (mapping.generatedLine !== previousGeneratedLine) {
  16612. next += ';';
  16613. previousGeneratedLine++;
  16614. }
  16615. }
  16616. else {
  16617. if (i > 0) {
  16618. if (!util.compareByGeneratedPositionsInflated(mapping, mappings[i - 1])) {
  16619. continue;
  16620. }
  16621. next += ',';
  16622. }
  16623. }
  16624. next += base64VLQ.encode(mapping.generatedColumn
  16625. - previousGeneratedColumn);
  16626. previousGeneratedColumn = mapping.generatedColumn;
  16627. if (mapping.source != null) {
  16628. sourceIdx = this._sources.indexOf(mapping.source);
  16629. next += base64VLQ.encode(sourceIdx - previousSource);
  16630. previousSource = sourceIdx;
  16631. // lines are stored 0-based in SourceMap spec version 3
  16632. next += base64VLQ.encode(mapping.originalLine - 1
  16633. - previousOriginalLine);
  16634. previousOriginalLine = mapping.originalLine - 1;
  16635. next += base64VLQ.encode(mapping.originalColumn
  16636. - previousOriginalColumn);
  16637. previousOriginalColumn = mapping.originalColumn;
  16638. if (mapping.name != null) {
  16639. nameIdx = this._names.indexOf(mapping.name);
  16640. next += base64VLQ.encode(nameIdx - previousName);
  16641. previousName = nameIdx;
  16642. }
  16643. }
  16644. result += next;
  16645. }
  16646. return result;
  16647. };
  16648. SourceMapGenerator.prototype._generateSourcesContent =
  16649. function SourceMapGenerator_generateSourcesContent(aSources, aSourceRoot) {
  16650. return aSources.map(function (source) {
  16651. if (!this._sourcesContents) {
  16652. return null;
  16653. }
  16654. if (aSourceRoot != null) {
  16655. source = util.relative(aSourceRoot, source);
  16656. }
  16657. var key = util.toSetString(source);
  16658. return Object.prototype.hasOwnProperty.call(this._sourcesContents, key)
  16659. ? this._sourcesContents[key]
  16660. : null;
  16661. }, this);
  16662. };
  16663. /**
  16664. * Externalize the source map.
  16665. */
  16666. SourceMapGenerator.prototype.toJSON =
  16667. function SourceMapGenerator_toJSON() {
  16668. var map = {
  16669. version: this._version,
  16670. sources: this._sources.toArray(),
  16671. names: this._names.toArray(),
  16672. mappings: this._serializeMappings()
  16673. };
  16674. if (this._file != null) {
  16675. map.file = this._file;
  16676. }
  16677. if (this._sourceRoot != null) {
  16678. map.sourceRoot = this._sourceRoot;
  16679. }
  16680. if (this._sourcesContents) {
  16681. map.sourcesContent = this._generateSourcesContent(map.sources, map.sourceRoot);
  16682. }
  16683. return map;
  16684. };
  16685. /**
  16686. * Render the source map being generated to a string.
  16687. */
  16688. SourceMapGenerator.prototype.toString =
  16689. function SourceMapGenerator_toString() {
  16690. return JSON.stringify(this.toJSON());
  16691. };
  16692. exports.SourceMapGenerator = SourceMapGenerator;
  16693. },{"./array-set":198,"./base64-vlq":199,"./mapping-list":202,"./util":207}],206:[function(require,module,exports){
  16694. /* -*- Mode: js; js-indent-level: 2; -*- */
  16695. /*
  16696. * Copyright 2011 Mozilla Foundation and contributors
  16697. * Licensed under the New BSD license. See LICENSE or:
  16698. * http://opensource.org/licenses/BSD-3-Clause
  16699. */
  16700. var SourceMapGenerator = require('./source-map-generator').SourceMapGenerator;
  16701. var util = require('./util');
  16702. // Matches a Windows-style `\r\n` newline or a `\n` newline used by all other
  16703. // operating systems these days (capturing the result).
  16704. var REGEX_NEWLINE = /(\r?\n)/;
  16705. // Newline character code for charCodeAt() comparisons
  16706. var NEWLINE_CODE = 10;
  16707. // Private symbol for identifying `SourceNode`s when multiple versions of
  16708. // the source-map library are loaded. This MUST NOT CHANGE across
  16709. // versions!
  16710. var isSourceNode = "$$$isSourceNode$$$";
  16711. /**
  16712. * SourceNodes provide a way to abstract over interpolating/concatenating
  16713. * snippets of generated JavaScript source code while maintaining the line and
  16714. * column information associated with the original source code.
  16715. *
  16716. * @param aLine The original line number.
  16717. * @param aColumn The original column number.
  16718. * @param aSource The original source's filename.
  16719. * @param aChunks Optional. An array of strings which are snippets of
  16720. * generated JS, or other SourceNodes.
  16721. * @param aName The original identifier.
  16722. */
  16723. function SourceNode(aLine, aColumn, aSource, aChunks, aName) {
  16724. this.children = [];
  16725. this.sourceContents = {};
  16726. this.line = aLine == null ? null : aLine;
  16727. this.column = aColumn == null ? null : aColumn;
  16728. this.source = aSource == null ? null : aSource;
  16729. this.name = aName == null ? null : aName;
  16730. this[isSourceNode] = true;
  16731. if (aChunks != null) this.add(aChunks);
  16732. }
  16733. /**
  16734. * Creates a SourceNode from generated code and a SourceMapConsumer.
  16735. *
  16736. * @param aGeneratedCode The generated code
  16737. * @param aSourceMapConsumer The SourceMap for the generated code
  16738. * @param aRelativePath Optional. The path that relative sources in the
  16739. * SourceMapConsumer should be relative to.
  16740. */
  16741. SourceNode.fromStringWithSourceMap =
  16742. function SourceNode_fromStringWithSourceMap(aGeneratedCode, aSourceMapConsumer, aRelativePath) {
  16743. // The SourceNode we want to fill with the generated code
  16744. // and the SourceMap
  16745. var node = new SourceNode();
  16746. // All even indices of this array are one line of the generated code,
  16747. // while all odd indices are the newlines between two adjacent lines
  16748. // (since `REGEX_NEWLINE` captures its match).
  16749. // Processed fragments are accessed by calling `shiftNextLine`.
  16750. var remainingLines = aGeneratedCode.split(REGEX_NEWLINE);
  16751. var remainingLinesIndex = 0;
  16752. var shiftNextLine = function() {
  16753. var lineContents = getNextLine();
  16754. // The last line of a file might not have a newline.
  16755. var newLine = getNextLine() || "";
  16756. return lineContents + newLine;
  16757. function getNextLine() {
  16758. return remainingLinesIndex < remainingLines.length ?
  16759. remainingLines[remainingLinesIndex++] : undefined;
  16760. }
  16761. };
  16762. // We need to remember the position of "remainingLines"
  16763. var lastGeneratedLine = 1, lastGeneratedColumn = 0;
  16764. // The generate SourceNodes we need a code range.
  16765. // To extract it current and last mapping is used.
  16766. // Here we store the last mapping.
  16767. var lastMapping = null;
  16768. aSourceMapConsumer.eachMapping(function (mapping) {
  16769. if (lastMapping !== null) {
  16770. // We add the code from "lastMapping" to "mapping":
  16771. // First check if there is a new line in between.
  16772. if (lastGeneratedLine < mapping.generatedLine) {
  16773. // Associate first line with "lastMapping"
  16774. addMappingWithCode(lastMapping, shiftNextLine());
  16775. lastGeneratedLine++;
  16776. lastGeneratedColumn = 0;
  16777. // The remaining code is added without mapping
  16778. } else {
  16779. // There is no new line in between.
  16780. // Associate the code between "lastGeneratedColumn" and
  16781. // "mapping.generatedColumn" with "lastMapping"
  16782. var nextLine = remainingLines[remainingLinesIndex] || '';
  16783. var code = nextLine.substr(0, mapping.generatedColumn -
  16784. lastGeneratedColumn);
  16785. remainingLines[remainingLinesIndex] = nextLine.substr(mapping.generatedColumn -
  16786. lastGeneratedColumn);
  16787. lastGeneratedColumn = mapping.generatedColumn;
  16788. addMappingWithCode(lastMapping, code);
  16789. // No more remaining code, continue
  16790. lastMapping = mapping;
  16791. return;
  16792. }
  16793. }
  16794. // We add the generated code until the first mapping
  16795. // to the SourceNode without any mapping.
  16796. // Each line is added as separate string.
  16797. while (lastGeneratedLine < mapping.generatedLine) {
  16798. node.add(shiftNextLine());
  16799. lastGeneratedLine++;
  16800. }
  16801. if (lastGeneratedColumn < mapping.generatedColumn) {
  16802. var nextLine = remainingLines[remainingLinesIndex] || '';
  16803. node.add(nextLine.substr(0, mapping.generatedColumn));
  16804. remainingLines[remainingLinesIndex] = nextLine.substr(mapping.generatedColumn);
  16805. lastGeneratedColumn = mapping.generatedColumn;
  16806. }
  16807. lastMapping = mapping;
  16808. }, this);
  16809. // We have processed all mappings.
  16810. if (remainingLinesIndex < remainingLines.length) {
  16811. if (lastMapping) {
  16812. // Associate the remaining code in the current line with "lastMapping"
  16813. addMappingWithCode(lastMapping, shiftNextLine());
  16814. }
  16815. // and add the remaining lines without any mapping
  16816. node.add(remainingLines.splice(remainingLinesIndex).join(""));
  16817. }
  16818. // Copy sourcesContent into SourceNode
  16819. aSourceMapConsumer.sources.forEach(function (sourceFile) {
  16820. var content = aSourceMapConsumer.sourceContentFor(sourceFile);
  16821. if (content != null) {
  16822. if (aRelativePath != null) {
  16823. sourceFile = util.join(aRelativePath, sourceFile);
  16824. }
  16825. node.setSourceContent(sourceFile, content);
  16826. }
  16827. });
  16828. return node;
  16829. function addMappingWithCode(mapping, code) {
  16830. if (mapping === null || mapping.source === undefined) {
  16831. node.add(code);
  16832. } else {
  16833. var source = aRelativePath
  16834. ? util.join(aRelativePath, mapping.source)
  16835. : mapping.source;
  16836. node.add(new SourceNode(mapping.originalLine,
  16837. mapping.originalColumn,
  16838. source,
  16839. code,
  16840. mapping.name));
  16841. }
  16842. }
  16843. };
  16844. /**
  16845. * Add a chunk of generated JS to this source node.
  16846. *
  16847. * @param aChunk A string snippet of generated JS code, another instance of
  16848. * SourceNode, or an array where each member is one of those things.
  16849. */
  16850. SourceNode.prototype.add = function SourceNode_add(aChunk) {
  16851. if (Array.isArray(aChunk)) {
  16852. aChunk.forEach(function (chunk) {
  16853. this.add(chunk);
  16854. }, this);
  16855. }
  16856. else if (aChunk[isSourceNode] || typeof aChunk === "string") {
  16857. if (aChunk) {
  16858. this.children.push(aChunk);
  16859. }
  16860. }
  16861. else {
  16862. throw new TypeError(
  16863. "Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk
  16864. );
  16865. }
  16866. return this;
  16867. };
  16868. /**
  16869. * Add a chunk of generated JS to the beginning of this source node.
  16870. *
  16871. * @param aChunk A string snippet of generated JS code, another instance of
  16872. * SourceNode, or an array where each member is one of those things.
  16873. */
  16874. SourceNode.prototype.prepend = function SourceNode_prepend(aChunk) {
  16875. if (Array.isArray(aChunk)) {
  16876. for (var i = aChunk.length-1; i >= 0; i--) {
  16877. this.prepend(aChunk[i]);
  16878. }
  16879. }
  16880. else if (aChunk[isSourceNode] || typeof aChunk === "string") {
  16881. this.children.unshift(aChunk);
  16882. }
  16883. else {
  16884. throw new TypeError(
  16885. "Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk
  16886. );
  16887. }
  16888. return this;
  16889. };
  16890. /**
  16891. * Walk over the tree of JS snippets in this node and its children. The
  16892. * walking function is called once for each snippet of JS and is passed that
  16893. * snippet and the its original associated source's line/column location.
  16894. *
  16895. * @param aFn The traversal function.
  16896. */
  16897. SourceNode.prototype.walk = function SourceNode_walk(aFn) {
  16898. var chunk;
  16899. for (var i = 0, len = this.children.length; i < len; i++) {
  16900. chunk = this.children[i];
  16901. if (chunk[isSourceNode]) {
  16902. chunk.walk(aFn);
  16903. }
  16904. else {
  16905. if (chunk !== '') {
  16906. aFn(chunk, { source: this.source,
  16907. line: this.line,
  16908. column: this.column,
  16909. name: this.name });
  16910. }
  16911. }
  16912. }
  16913. };
  16914. /**
  16915. * Like `String.prototype.join` except for SourceNodes. Inserts `aStr` between
  16916. * each of `this.children`.
  16917. *
  16918. * @param aSep The separator.
  16919. */
  16920. SourceNode.prototype.join = function SourceNode_join(aSep) {
  16921. var newChildren;
  16922. var i;
  16923. var len = this.children.length;
  16924. if (len > 0) {
  16925. newChildren = [];
  16926. for (i = 0; i < len-1; i++) {
  16927. newChildren.push(this.children[i]);
  16928. newChildren.push(aSep);
  16929. }
  16930. newChildren.push(this.children[i]);
  16931. this.children = newChildren;
  16932. }
  16933. return this;
  16934. };
  16935. /**
  16936. * Call String.prototype.replace on the very right-most source snippet. Useful
  16937. * for trimming whitespace from the end of a source node, etc.
  16938. *
  16939. * @param aPattern The pattern to replace.
  16940. * @param aReplacement The thing to replace the pattern with.
  16941. */
  16942. SourceNode.prototype.replaceRight = function SourceNode_replaceRight(aPattern, aReplacement) {
  16943. var lastChild = this.children[this.children.length - 1];
  16944. if (lastChild[isSourceNode]) {
  16945. lastChild.replaceRight(aPattern, aReplacement);
  16946. }
  16947. else if (typeof lastChild === 'string') {
  16948. this.children[this.children.length - 1] = lastChild.replace(aPattern, aReplacement);
  16949. }
  16950. else {
  16951. this.children.push(''.replace(aPattern, aReplacement));
  16952. }
  16953. return this;
  16954. };
  16955. /**
  16956. * Set the source content for a source file. This will be added to the SourceMapGenerator
  16957. * in the sourcesContent field.
  16958. *
  16959. * @param aSourceFile The filename of the source file
  16960. * @param aSourceContent The content of the source file
  16961. */
  16962. SourceNode.prototype.setSourceContent =
  16963. function SourceNode_setSourceContent(aSourceFile, aSourceContent) {
  16964. this.sourceContents[util.toSetString(aSourceFile)] = aSourceContent;
  16965. };
  16966. /**
  16967. * Walk over the tree of SourceNodes. The walking function is called for each
  16968. * source file content and is passed the filename and source content.
  16969. *
  16970. * @param aFn The traversal function.
  16971. */
  16972. SourceNode.prototype.walkSourceContents =
  16973. function SourceNode_walkSourceContents(aFn) {
  16974. for (var i = 0, len = this.children.length; i < len; i++) {
  16975. if (this.children[i][isSourceNode]) {
  16976. this.children[i].walkSourceContents(aFn);
  16977. }
  16978. }
  16979. var sources = Object.keys(this.sourceContents);
  16980. for (var i = 0, len = sources.length; i < len; i++) {
  16981. aFn(util.fromSetString(sources[i]), this.sourceContents[sources[i]]);
  16982. }
  16983. };
  16984. /**
  16985. * Return the string representation of this source node. Walks over the tree
  16986. * and concatenates all the various snippets together to one string.
  16987. */
  16988. SourceNode.prototype.toString = function SourceNode_toString() {
  16989. var str = "";
  16990. this.walk(function (chunk) {
  16991. str += chunk;
  16992. });
  16993. return str;
  16994. };
  16995. /**
  16996. * Returns the string representation of this source node along with a source
  16997. * map.
  16998. */
  16999. SourceNode.prototype.toStringWithSourceMap = function SourceNode_toStringWithSourceMap(aArgs) {
  17000. var generated = {
  17001. code: "",
  17002. line: 1,
  17003. column: 0
  17004. };
  17005. var map = new SourceMapGenerator(aArgs);
  17006. var sourceMappingActive = false;
  17007. var lastOriginalSource = null;
  17008. var lastOriginalLine = null;
  17009. var lastOriginalColumn = null;
  17010. var lastOriginalName = null;
  17011. this.walk(function (chunk, original) {
  17012. generated.code += chunk;
  17013. if (original.source !== null
  17014. && original.line !== null
  17015. && original.column !== null) {
  17016. if(lastOriginalSource !== original.source
  17017. || lastOriginalLine !== original.line
  17018. || lastOriginalColumn !== original.column
  17019. || lastOriginalName !== original.name) {
  17020. map.addMapping({
  17021. source: original.source,
  17022. original: {
  17023. line: original.line,
  17024. column: original.column
  17025. },
  17026. generated: {
  17027. line: generated.line,
  17028. column: generated.column
  17029. },
  17030. name: original.name
  17031. });
  17032. }
  17033. lastOriginalSource = original.source;
  17034. lastOriginalLine = original.line;
  17035. lastOriginalColumn = original.column;
  17036. lastOriginalName = original.name;
  17037. sourceMappingActive = true;
  17038. } else if (sourceMappingActive) {
  17039. map.addMapping({
  17040. generated: {
  17041. line: generated.line,
  17042. column: generated.column
  17043. }
  17044. });
  17045. lastOriginalSource = null;
  17046. sourceMappingActive = false;
  17047. }
  17048. for (var idx = 0, length = chunk.length; idx < length; idx++) {
  17049. if (chunk.charCodeAt(idx) === NEWLINE_CODE) {
  17050. generated.line++;
  17051. generated.column = 0;
  17052. // Mappings end at eol
  17053. if (idx + 1 === length) {
  17054. lastOriginalSource = null;
  17055. sourceMappingActive = false;
  17056. } else if (sourceMappingActive) {
  17057. map.addMapping({
  17058. source: original.source,
  17059. original: {
  17060. line: original.line,
  17061. column: original.column
  17062. },
  17063. generated: {
  17064. line: generated.line,
  17065. column: generated.column
  17066. },
  17067. name: original.name
  17068. });
  17069. }
  17070. } else {
  17071. generated.column++;
  17072. }
  17073. }
  17074. });
  17075. this.walkSourceContents(function (sourceFile, sourceContent) {
  17076. map.setSourceContent(sourceFile, sourceContent);
  17077. });
  17078. return { code: generated.code, map: map };
  17079. };
  17080. exports.SourceNode = SourceNode;
  17081. },{"./source-map-generator":205,"./util":207}],207:[function(require,module,exports){
  17082. /* -*- Mode: js; js-indent-level: 2; -*- */
  17083. /*
  17084. * Copyright 2011 Mozilla Foundation and contributors
  17085. * Licensed under the New BSD license. See LICENSE or:
  17086. * http://opensource.org/licenses/BSD-3-Clause
  17087. */
  17088. /**
  17089. * This is a helper function for getting values from parameter/options
  17090. * objects.
  17091. *
  17092. * @param args The object we are extracting values from
  17093. * @param name The name of the property we are getting.
  17094. * @param defaultValue An optional value to return if the property is missing
  17095. * from the object. If this is not specified and the property is missing, an
  17096. * error will be thrown.
  17097. */
  17098. function getArg(aArgs, aName, aDefaultValue) {
  17099. if (aName in aArgs) {
  17100. return aArgs[aName];
  17101. } else if (arguments.length === 3) {
  17102. return aDefaultValue;
  17103. } else {
  17104. throw new Error('"' + aName + '" is a required argument.');
  17105. }
  17106. }
  17107. exports.getArg = getArg;
  17108. var urlRegexp = /^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.-]*)(?::(\d+))?(.*)$/;
  17109. var dataUrlRegexp = /^data:.+\,.+$/;
  17110. function urlParse(aUrl) {
  17111. var match = aUrl.match(urlRegexp);
  17112. if (!match) {
  17113. return null;
  17114. }
  17115. return {
  17116. scheme: match[1],
  17117. auth: match[2],
  17118. host: match[3],
  17119. port: match[4],
  17120. path: match[5]
  17121. };
  17122. }
  17123. exports.urlParse = urlParse;
  17124. function urlGenerate(aParsedUrl) {
  17125. var url = '';
  17126. if (aParsedUrl.scheme) {
  17127. url += aParsedUrl.scheme + ':';
  17128. }
  17129. url += '//';
  17130. if (aParsedUrl.auth) {
  17131. url += aParsedUrl.auth + '@';
  17132. }
  17133. if (aParsedUrl.host) {
  17134. url += aParsedUrl.host;
  17135. }
  17136. if (aParsedUrl.port) {
  17137. url += ":" + aParsedUrl.port
  17138. }
  17139. if (aParsedUrl.path) {
  17140. url += aParsedUrl.path;
  17141. }
  17142. return url;
  17143. }
  17144. exports.urlGenerate = urlGenerate;
  17145. /**
  17146. * Normalizes a path, or the path portion of a URL:
  17147. *
  17148. * - Replaces consecutive slashes with one slash.
  17149. * - Removes unnecessary '.' parts.
  17150. * - Removes unnecessary '<dir>/..' parts.
  17151. *
  17152. * Based on code in the Node.js 'path' core module.
  17153. *
  17154. * @param aPath The path or url to normalize.
  17155. */
  17156. function normalize(aPath) {
  17157. var path = aPath;
  17158. var url = urlParse(aPath);
  17159. if (url) {
  17160. if (!url.path) {
  17161. return aPath;
  17162. }
  17163. path = url.path;
  17164. }
  17165. var isAbsolute = exports.isAbsolute(path);
  17166. var parts = path.split(/\/+/);
  17167. for (var part, up = 0, i = parts.length - 1; i >= 0; i--) {
  17168. part = parts[i];
  17169. if (part === '.') {
  17170. parts.splice(i, 1);
  17171. } else if (part === '..') {
  17172. up++;
  17173. } else if (up > 0) {
  17174. if (part === '') {
  17175. // The first part is blank if the path is absolute. Trying to go
  17176. // above the root is a no-op. Therefore we can remove all '..' parts
  17177. // directly after the root.
  17178. parts.splice(i + 1, up);
  17179. up = 0;
  17180. } else {
  17181. parts.splice(i, 2);
  17182. up--;
  17183. }
  17184. }
  17185. }
  17186. path = parts.join('/');
  17187. if (path === '') {
  17188. path = isAbsolute ? '/' : '.';
  17189. }
  17190. if (url) {
  17191. url.path = path;
  17192. return urlGenerate(url);
  17193. }
  17194. return path;
  17195. }
  17196. exports.normalize = normalize;
  17197. /**
  17198. * Joins two paths/URLs.
  17199. *
  17200. * @param aRoot The root path or URL.
  17201. * @param aPath The path or URL to be joined with the root.
  17202. *
  17203. * - If aPath is a URL or a data URI, aPath is returned, unless aPath is a
  17204. * scheme-relative URL: Then the scheme of aRoot, if any, is prepended
  17205. * first.
  17206. * - Otherwise aPath is a path. If aRoot is a URL, then its path portion
  17207. * is updated with the result and aRoot is returned. Otherwise the result
  17208. * is returned.
  17209. * - If aPath is absolute, the result is aPath.
  17210. * - Otherwise the two paths are joined with a slash.
  17211. * - Joining for example 'http://' and 'www.example.com' is also supported.
  17212. */
  17213. function join(aRoot, aPath) {
  17214. if (aRoot === "") {
  17215. aRoot = ".";
  17216. }
  17217. if (aPath === "") {
  17218. aPath = ".";
  17219. }
  17220. var aPathUrl = urlParse(aPath);
  17221. var aRootUrl = urlParse(aRoot);
  17222. if (aRootUrl) {
  17223. aRoot = aRootUrl.path || '/';
  17224. }
  17225. // `join(foo, '//www.example.org')`
  17226. if (aPathUrl && !aPathUrl.scheme) {
  17227. if (aRootUrl) {
  17228. aPathUrl.scheme = aRootUrl.scheme;
  17229. }
  17230. return urlGenerate(aPathUrl);
  17231. }
  17232. if (aPathUrl || aPath.match(dataUrlRegexp)) {
  17233. return aPath;
  17234. }
  17235. // `join('http://', 'www.example.com')`
  17236. if (aRootUrl && !aRootUrl.host && !aRootUrl.path) {
  17237. aRootUrl.host = aPath;
  17238. return urlGenerate(aRootUrl);
  17239. }
  17240. var joined = aPath.charAt(0) === '/'
  17241. ? aPath
  17242. : normalize(aRoot.replace(/\/+$/, '') + '/' + aPath);
  17243. if (aRootUrl) {
  17244. aRootUrl.path = joined;
  17245. return urlGenerate(aRootUrl);
  17246. }
  17247. return joined;
  17248. }
  17249. exports.join = join;
  17250. exports.isAbsolute = function (aPath) {
  17251. return aPath.charAt(0) === '/' || urlRegexp.test(aPath);
  17252. };
  17253. /**
  17254. * Make a path relative to a URL or another path.
  17255. *
  17256. * @param aRoot The root path or URL.
  17257. * @param aPath The path or URL to be made relative to aRoot.
  17258. */
  17259. function relative(aRoot, aPath) {
  17260. if (aRoot === "") {
  17261. aRoot = ".";
  17262. }
  17263. aRoot = aRoot.replace(/\/$/, '');
  17264. // It is possible for the path to be above the root. In this case, simply
  17265. // checking whether the root is a prefix of the path won't work. Instead, we
  17266. // need to remove components from the root one by one, until either we find
  17267. // a prefix that fits, or we run out of components to remove.
  17268. var level = 0;
  17269. while (aPath.indexOf(aRoot + '/') !== 0) {
  17270. var index = aRoot.lastIndexOf("/");
  17271. if (index < 0) {
  17272. return aPath;
  17273. }
  17274. // If the only part of the root that is left is the scheme (i.e. http://,
  17275. // file:///, etc.), one or more slashes (/), or simply nothing at all, we
  17276. // have exhausted all components, so the path is not relative to the root.
  17277. aRoot = aRoot.slice(0, index);
  17278. if (aRoot.match(/^([^\/]+:\/)?\/*$/)) {
  17279. return aPath;
  17280. }
  17281. ++level;
  17282. }
  17283. // Make sure we add a "../" for each component we removed from the root.
  17284. return Array(level + 1).join("../") + aPath.substr(aRoot.length + 1);
  17285. }
  17286. exports.relative = relative;
  17287. var supportsNullProto = (function () {
  17288. var obj = Object.create(null);
  17289. return !('__proto__' in obj);
  17290. }());
  17291. function identity (s) {
  17292. return s;
  17293. }
  17294. /**
  17295. * Because behavior goes wacky when you set `__proto__` on objects, we
  17296. * have to prefix all the strings in our set with an arbitrary character.
  17297. *
  17298. * See https://github.com/mozilla/source-map/pull/31 and
  17299. * https://github.com/mozilla/source-map/issues/30
  17300. *
  17301. * @param String aStr
  17302. */
  17303. function toSetString(aStr) {
  17304. if (isProtoString(aStr)) {
  17305. return '$' + aStr;
  17306. }
  17307. return aStr;
  17308. }
  17309. exports.toSetString = supportsNullProto ? identity : toSetString;
  17310. function fromSetString(aStr) {
  17311. if (isProtoString(aStr)) {
  17312. return aStr.slice(1);
  17313. }
  17314. return aStr;
  17315. }
  17316. exports.fromSetString = supportsNullProto ? identity : fromSetString;
  17317. function isProtoString(s) {
  17318. if (!s) {
  17319. return false;
  17320. }
  17321. var length = s.length;
  17322. if (length < 9 /* "__proto__".length */) {
  17323. return false;
  17324. }
  17325. if (s.charCodeAt(length - 1) !== 95 /* '_' */ ||
  17326. s.charCodeAt(length - 2) !== 95 /* '_' */ ||
  17327. s.charCodeAt(length - 3) !== 111 /* 'o' */ ||
  17328. s.charCodeAt(length - 4) !== 116 /* 't' */ ||
  17329. s.charCodeAt(length - 5) !== 111 /* 'o' */ ||
  17330. s.charCodeAt(length - 6) !== 114 /* 'r' */ ||
  17331. s.charCodeAt(length - 7) !== 112 /* 'p' */ ||
  17332. s.charCodeAt(length - 8) !== 95 /* '_' */ ||
  17333. s.charCodeAt(length - 9) !== 95 /* '_' */) {
  17334. return false;
  17335. }
  17336. for (var i = length - 10; i >= 0; i--) {
  17337. if (s.charCodeAt(i) !== 36 /* '$' */) {
  17338. return false;
  17339. }
  17340. }
  17341. return true;
  17342. }
  17343. /**
  17344. * Comparator between two mappings where the original positions are compared.
  17345. *
  17346. * Optionally pass in `true` as `onlyCompareGenerated` to consider two
  17347. * mappings with the same original source/line/column, but different generated
  17348. * line and column the same. Useful when searching for a mapping with a
  17349. * stubbed out mapping.
  17350. */
  17351. function compareByOriginalPositions(mappingA, mappingB, onlyCompareOriginal) {
  17352. var cmp = strcmp(mappingA.source, mappingB.source);
  17353. if (cmp !== 0) {
  17354. return cmp;
  17355. }
  17356. cmp = mappingA.originalLine - mappingB.originalLine;
  17357. if (cmp !== 0) {
  17358. return cmp;
  17359. }
  17360. cmp = mappingA.originalColumn - mappingB.originalColumn;
  17361. if (cmp !== 0 || onlyCompareOriginal) {
  17362. return cmp;
  17363. }
  17364. cmp = mappingA.generatedColumn - mappingB.generatedColumn;
  17365. if (cmp !== 0) {
  17366. return cmp;
  17367. }
  17368. cmp = mappingA.generatedLine - mappingB.generatedLine;
  17369. if (cmp !== 0) {
  17370. return cmp;
  17371. }
  17372. return strcmp(mappingA.name, mappingB.name);
  17373. }
  17374. exports.compareByOriginalPositions = compareByOriginalPositions;
  17375. /**
  17376. * Comparator between two mappings with deflated source and name indices where
  17377. * the generated positions are compared.
  17378. *
  17379. * Optionally pass in `true` as `onlyCompareGenerated` to consider two
  17380. * mappings with the same generated line and column, but different
  17381. * source/name/original line and column the same. Useful when searching for a
  17382. * mapping with a stubbed out mapping.
  17383. */
  17384. function compareByGeneratedPositionsDeflated(mappingA, mappingB, onlyCompareGenerated) {
  17385. var cmp = mappingA.generatedLine - mappingB.generatedLine;
  17386. if (cmp !== 0) {
  17387. return cmp;
  17388. }
  17389. cmp = mappingA.generatedColumn - mappingB.generatedColumn;
  17390. if (cmp !== 0 || onlyCompareGenerated) {
  17391. return cmp;
  17392. }
  17393. cmp = strcmp(mappingA.source, mappingB.source);
  17394. if (cmp !== 0) {
  17395. return cmp;
  17396. }
  17397. cmp = mappingA.originalLine - mappingB.originalLine;
  17398. if (cmp !== 0) {
  17399. return cmp;
  17400. }
  17401. cmp = mappingA.originalColumn - mappingB.originalColumn;
  17402. if (cmp !== 0) {
  17403. return cmp;
  17404. }
  17405. return strcmp(mappingA.name, mappingB.name);
  17406. }
  17407. exports.compareByGeneratedPositionsDeflated = compareByGeneratedPositionsDeflated;
  17408. function strcmp(aStr1, aStr2) {
  17409. if (aStr1 === aStr2) {
  17410. return 0;
  17411. }
  17412. if (aStr1 === null) {
  17413. return 1; // aStr2 !== null
  17414. }
  17415. if (aStr2 === null) {
  17416. return -1; // aStr1 !== null
  17417. }
  17418. if (aStr1 > aStr2) {
  17419. return 1;
  17420. }
  17421. return -1;
  17422. }
  17423. /**
  17424. * Comparator between two mappings with inflated source and name strings where
  17425. * the generated positions are compared.
  17426. */
  17427. function compareByGeneratedPositionsInflated(mappingA, mappingB) {
  17428. var cmp = mappingA.generatedLine - mappingB.generatedLine;
  17429. if (cmp !== 0) {
  17430. return cmp;
  17431. }
  17432. cmp = mappingA.generatedColumn - mappingB.generatedColumn;
  17433. if (cmp !== 0) {
  17434. return cmp;
  17435. }
  17436. cmp = strcmp(mappingA.source, mappingB.source);
  17437. if (cmp !== 0) {
  17438. return cmp;
  17439. }
  17440. cmp = mappingA.originalLine - mappingB.originalLine;
  17441. if (cmp !== 0) {
  17442. return cmp;
  17443. }
  17444. cmp = mappingA.originalColumn - mappingB.originalColumn;
  17445. if (cmp !== 0) {
  17446. return cmp;
  17447. }
  17448. return strcmp(mappingA.name, mappingB.name);
  17449. }
  17450. exports.compareByGeneratedPositionsInflated = compareByGeneratedPositionsInflated;
  17451. /**
  17452. * Strip any JSON XSSI avoidance prefix from the string (as documented
  17453. * in the source maps specification), and then parse the string as
  17454. * JSON.
  17455. */
  17456. function parseSourceMapInput(str) {
  17457. return JSON.parse(str.replace(/^\)]}'[^\n]*\n/, ''));
  17458. }
  17459. exports.parseSourceMapInput = parseSourceMapInput;
  17460. /**
  17461. * Compute the URL of a source given the the source root, the source's
  17462. * URL, and the source map's URL.
  17463. */
  17464. function computeSourceURL(sourceRoot, sourceURL, sourceMapURL) {
  17465. sourceURL = sourceURL || '';
  17466. if (sourceRoot) {
  17467. // This follows what Chrome does.
  17468. if (sourceRoot[sourceRoot.length - 1] !== '/' && sourceURL[0] !== '/') {
  17469. sourceRoot += '/';
  17470. }
  17471. // The spec says:
  17472. // Line 4: An optional source root, useful for relocating source
  17473. // files on a server or removing repeated values in the
  17474. // “sources” entry. This value is prepended to the individual
  17475. // entries in the “source” field.
  17476. sourceURL = sourceRoot + sourceURL;
  17477. }
  17478. // Historically, SourceMapConsumer did not take the sourceMapURL as
  17479. // a parameter. This mode is still somewhat supported, which is why
  17480. // this code block is conditional. However, it's preferable to pass
  17481. // the source map URL to SourceMapConsumer, so that this function
  17482. // can implement the source URL resolution algorithm as outlined in
  17483. // the spec. This block is basically the equivalent of:
  17484. // new URL(sourceURL, sourceMapURL).toString()
  17485. // ... except it avoids using URL, which wasn't available in the
  17486. // older releases of node still supported by this library.
  17487. //
  17488. // The spec says:
  17489. // If the sources are not absolute URLs after prepending of the
  17490. // “sourceRoot”, the sources are resolved relative to the
  17491. // SourceMap (like resolving script src in a html document).
  17492. if (sourceMapURL) {
  17493. var parsed = urlParse(sourceMapURL);
  17494. if (!parsed) {
  17495. throw new Error("sourceMapURL could not be parsed");
  17496. }
  17497. if (parsed.path) {
  17498. // Strip the last path component, but keep the "/".
  17499. var index = parsed.path.lastIndexOf('/');
  17500. if (index >= 0) {
  17501. parsed.path = parsed.path.substring(0, index + 1);
  17502. }
  17503. }
  17504. sourceURL = join(urlGenerate(parsed), sourceURL);
  17505. }
  17506. return normalize(sourceURL);
  17507. }
  17508. exports.computeSourceURL = computeSourceURL;
  17509. },{}],208:[function(require,module,exports){
  17510. /*
  17511. * Copyright 2009-2011 Mozilla Foundation and contributors
  17512. * Licensed under the New BSD license. See LICENSE.txt or:
  17513. * http://opensource.org/licenses/BSD-3-Clause
  17514. */
  17515. exports.SourceMapGenerator = require('./lib/source-map-generator').SourceMapGenerator;
  17516. exports.SourceMapConsumer = require('./lib/source-map-consumer').SourceMapConsumer;
  17517. exports.SourceNode = require('./lib/source-node').SourceNode;
  17518. },{"./lib/source-map-consumer":204,"./lib/source-map-generator":205,"./lib/source-node":206}],209:[function(require,module,exports){
  17519. // Copyright Joyent, Inc. and other Node contributors.
  17520. //
  17521. // Permission is hereby granted, free of charge, to any person obtaining a
  17522. // copy of this software and associated documentation files (the
  17523. // "Software"), to deal in the Software without restriction, including
  17524. // without limitation the rights to use, copy, modify, merge, publish,
  17525. // distribute, sublicense, and/or sell copies of the Software, and to permit
  17526. // persons to whom the Software is furnished to do so, subject to the
  17527. // following conditions:
  17528. //
  17529. // The above copyright notice and this permission notice shall be included
  17530. // in all copies or substantial portions of the Software.
  17531. //
  17532. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  17533. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  17534. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  17535. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  17536. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  17537. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  17538. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  17539. 'use strict';
  17540. var punycode = require('punycode');
  17541. var util = require('./util');
  17542. exports.parse = urlParse;
  17543. exports.resolve = urlResolve;
  17544. exports.resolveObject = urlResolveObject;
  17545. exports.format = urlFormat;
  17546. exports.Url = Url;
  17547. function Url() {
  17548. this.protocol = null;
  17549. this.slashes = null;
  17550. this.auth = null;
  17551. this.host = null;
  17552. this.port = null;
  17553. this.hostname = null;
  17554. this.hash = null;
  17555. this.search = null;
  17556. this.query = null;
  17557. this.pathname = null;
  17558. this.path = null;
  17559. this.href = null;
  17560. }
  17561. // Reference: RFC 3986, RFC 1808, RFC 2396
  17562. // define these here so at least they only have to be
  17563. // compiled once on the first module load.
  17564. var protocolPattern = /^([a-z0-9.+-]+:)/i,
  17565. portPattern = /:[0-9]*$/,
  17566. // Special case for a simple path URL
  17567. simplePathPattern = /^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,
  17568. // RFC 2396: characters reserved for delimiting URLs.
  17569. // We actually just auto-escape these.
  17570. delims = ['<', '>', '"', '`', ' ', '\r', '\n', '\t'],
  17571. // RFC 2396: characters not allowed for various reasons.
  17572. unwise = ['{', '}', '|', '\\', '^', '`'].concat(delims),
  17573. // Allowed by RFCs, but cause of XSS attacks. Always escape these.
  17574. autoEscape = ['\''].concat(unwise),
  17575. // Characters that are never ever allowed in a hostname.
  17576. // Note that any invalid chars are also handled, but these
  17577. // are the ones that are *expected* to be seen, so we fast-path
  17578. // them.
  17579. nonHostChars = ['%', '/', '?', ';', '#'].concat(autoEscape),
  17580. hostEndingChars = ['/', '?', '#'],
  17581. hostnameMaxLen = 255,
  17582. hostnamePartPattern = /^[+a-z0-9A-Z_-]{0,63}$/,
  17583. hostnamePartStart = /^([+a-z0-9A-Z_-]{0,63})(.*)$/,
  17584. // protocols that can allow "unsafe" and "unwise" chars.
  17585. unsafeProtocol = {
  17586. 'javascript': true,
  17587. 'javascript:': true
  17588. },
  17589. // protocols that never have a hostname.
  17590. hostlessProtocol = {
  17591. 'javascript': true,
  17592. 'javascript:': true
  17593. },
  17594. // protocols that always contain a // bit.
  17595. slashedProtocol = {
  17596. 'http': true,
  17597. 'https': true,
  17598. 'ftp': true,
  17599. 'gopher': true,
  17600. 'file': true,
  17601. 'http:': true,
  17602. 'https:': true,
  17603. 'ftp:': true,
  17604. 'gopher:': true,
  17605. 'file:': true
  17606. },
  17607. querystring = require('querystring');
  17608. function urlParse(url, parseQueryString, slashesDenoteHost) {
  17609. if (url && util.isObject(url) && url instanceof Url) return url;
  17610. var u = new Url;
  17611. u.parse(url, parseQueryString, slashesDenoteHost);
  17612. return u;
  17613. }
  17614. Url.prototype.parse = function(url, parseQueryString, slashesDenoteHost) {
  17615. if (!util.isString(url)) {
  17616. throw new TypeError("Parameter 'url' must be a string, not " + typeof url);
  17617. }
  17618. // Copy chrome, IE, opera backslash-handling behavior.
  17619. // Back slashes before the query string get converted to forward slashes
  17620. // See: https://code.google.com/p/chromium/issues/detail?id=25916
  17621. var queryIndex = url.indexOf('?'),
  17622. splitter =
  17623. (queryIndex !== -1 && queryIndex < url.indexOf('#')) ? '?' : '#',
  17624. uSplit = url.split(splitter),
  17625. slashRegex = /\\/g;
  17626. uSplit[0] = uSplit[0].replace(slashRegex, '/');
  17627. url = uSplit.join(splitter);
  17628. var rest = url;
  17629. // trim before proceeding.
  17630. // This is to support parse stuff like " http://foo.com \n"
  17631. rest = rest.trim();
  17632. if (!slashesDenoteHost && url.split('#').length === 1) {
  17633. // Try fast path regexp
  17634. var simplePath = simplePathPattern.exec(rest);
  17635. if (simplePath) {
  17636. this.path = rest;
  17637. this.href = rest;
  17638. this.pathname = simplePath[1];
  17639. if (simplePath[2]) {
  17640. this.search = simplePath[2];
  17641. if (parseQueryString) {
  17642. this.query = querystring.parse(this.search.substr(1));
  17643. } else {
  17644. this.query = this.search.substr(1);
  17645. }
  17646. } else if (parseQueryString) {
  17647. this.search = '';
  17648. this.query = {};
  17649. }
  17650. return this;
  17651. }
  17652. }
  17653. var proto = protocolPattern.exec(rest);
  17654. if (proto) {
  17655. proto = proto[0];
  17656. var lowerProto = proto.toLowerCase();
  17657. this.protocol = lowerProto;
  17658. rest = rest.substr(proto.length);
  17659. }
  17660. // figure out if it's got a host
  17661. // user@server is *always* interpreted as a hostname, and url
  17662. // resolution will treat //foo/bar as host=foo,path=bar because that's
  17663. // how the browser resolves relative URLs.
  17664. if (slashesDenoteHost || proto || rest.match(/^\/\/[^@\/]+@[^@\/]+/)) {
  17665. var slashes = rest.substr(0, 2) === '//';
  17666. if (slashes && !(proto && hostlessProtocol[proto])) {
  17667. rest = rest.substr(2);
  17668. this.slashes = true;
  17669. }
  17670. }
  17671. if (!hostlessProtocol[proto] &&
  17672. (slashes || (proto && !slashedProtocol[proto]))) {
  17673. // there's a hostname.
  17674. // the first instance of /, ?, ;, or # ends the host.
  17675. //
  17676. // If there is an @ in the hostname, then non-host chars *are* allowed
  17677. // to the left of the last @ sign, unless some host-ending character
  17678. // comes *before* the @-sign.
  17679. // URLs are obnoxious.
  17680. //
  17681. // ex:
  17682. // http://a@b@c/ => user:a@b host:c
  17683. // http://a@b?@c => user:a host:c path:/?@c
  17684. // v0.12 TODO(isaacs): This is not quite how Chrome does things.
  17685. // Review our test case against browsers more comprehensively.
  17686. // find the first instance of any hostEndingChars
  17687. var hostEnd = -1;
  17688. for (var i = 0; i < hostEndingChars.length; i++) {
  17689. var hec = rest.indexOf(hostEndingChars[i]);
  17690. if (hec !== -1 && (hostEnd === -1 || hec < hostEnd))
  17691. hostEnd = hec;
  17692. }
  17693. // at this point, either we have an explicit point where the
  17694. // auth portion cannot go past, or the last @ char is the decider.
  17695. var auth, atSign;
  17696. if (hostEnd === -1) {
  17697. // atSign can be anywhere.
  17698. atSign = rest.lastIndexOf('@');
  17699. } else {
  17700. // atSign must be in auth portion.
  17701. // http://a@b/c@d => host:b auth:a path:/c@d
  17702. atSign = rest.lastIndexOf('@', hostEnd);
  17703. }
  17704. // Now we have a portion which is definitely the auth.
  17705. // Pull that off.
  17706. if (atSign !== -1) {
  17707. auth = rest.slice(0, atSign);
  17708. rest = rest.slice(atSign + 1);
  17709. this.auth = decodeURIComponent(auth);
  17710. }
  17711. // the host is the remaining to the left of the first non-host char
  17712. hostEnd = -1;
  17713. for (var i = 0; i < nonHostChars.length; i++) {
  17714. var hec = rest.indexOf(nonHostChars[i]);
  17715. if (hec !== -1 && (hostEnd === -1 || hec < hostEnd))
  17716. hostEnd = hec;
  17717. }
  17718. // if we still have not hit it, then the entire thing is a host.
  17719. if (hostEnd === -1)
  17720. hostEnd = rest.length;
  17721. this.host = rest.slice(0, hostEnd);
  17722. rest = rest.slice(hostEnd);
  17723. // pull out port.
  17724. this.parseHost();
  17725. // we've indicated that there is a hostname,
  17726. // so even if it's empty, it has to be present.
  17727. this.hostname = this.hostname || '';
  17728. // if hostname begins with [ and ends with ]
  17729. // assume that it's an IPv6 address.
  17730. var ipv6Hostname = this.hostname[0] === '[' &&
  17731. this.hostname[this.hostname.length - 1] === ']';
  17732. // validate a little.
  17733. if (!ipv6Hostname) {
  17734. var hostparts = this.hostname.split(/\./);
  17735. for (var i = 0, l = hostparts.length; i < l; i++) {
  17736. var part = hostparts[i];
  17737. if (!part) continue;
  17738. if (!part.match(hostnamePartPattern)) {
  17739. var newpart = '';
  17740. for (var j = 0, k = part.length; j < k; j++) {
  17741. if (part.charCodeAt(j) > 127) {
  17742. // we replace non-ASCII char with a temporary placeholder
  17743. // we need this to make sure size of hostname is not
  17744. // broken by replacing non-ASCII by nothing
  17745. newpart += 'x';
  17746. } else {
  17747. newpart += part[j];
  17748. }
  17749. }
  17750. // we test again with ASCII char only
  17751. if (!newpart.match(hostnamePartPattern)) {
  17752. var validParts = hostparts.slice(0, i);
  17753. var notHost = hostparts.slice(i + 1);
  17754. var bit = part.match(hostnamePartStart);
  17755. if (bit) {
  17756. validParts.push(bit[1]);
  17757. notHost.unshift(bit[2]);
  17758. }
  17759. if (notHost.length) {
  17760. rest = '/' + notHost.join('.') + rest;
  17761. }
  17762. this.hostname = validParts.join('.');
  17763. break;
  17764. }
  17765. }
  17766. }
  17767. }
  17768. if (this.hostname.length > hostnameMaxLen) {
  17769. this.hostname = '';
  17770. } else {
  17771. // hostnames are always lower case.
  17772. this.hostname = this.hostname.toLowerCase();
  17773. }
  17774. if (!ipv6Hostname) {
  17775. // IDNA Support: Returns a punycoded representation of "domain".
  17776. // It only converts parts of the domain name that
  17777. // have non-ASCII characters, i.e. it doesn't matter if
  17778. // you call it with a domain that already is ASCII-only.
  17779. this.hostname = punycode.toASCII(this.hostname);
  17780. }
  17781. var p = this.port ? ':' + this.port : '';
  17782. var h = this.hostname || '';
  17783. this.host = h + p;
  17784. this.href += this.host;
  17785. // strip [ and ] from the hostname
  17786. // the host field still retains them, though
  17787. if (ipv6Hostname) {
  17788. this.hostname = this.hostname.substr(1, this.hostname.length - 2);
  17789. if (rest[0] !== '/') {
  17790. rest = '/' + rest;
  17791. }
  17792. }
  17793. }
  17794. // now rest is set to the post-host stuff.
  17795. // chop off any delim chars.
  17796. if (!unsafeProtocol[lowerProto]) {
  17797. // First, make 100% sure that any "autoEscape" chars get
  17798. // escaped, even if encodeURIComponent doesn't think they
  17799. // need to be.
  17800. for (var i = 0, l = autoEscape.length; i < l; i++) {
  17801. var ae = autoEscape[i];
  17802. if (rest.indexOf(ae) === -1)
  17803. continue;
  17804. var esc = encodeURIComponent(ae);
  17805. if (esc === ae) {
  17806. esc = escape(ae);
  17807. }
  17808. rest = rest.split(ae).join(esc);
  17809. }
  17810. }
  17811. // chop off from the tail first.
  17812. var hash = rest.indexOf('#');
  17813. if (hash !== -1) {
  17814. // got a fragment string.
  17815. this.hash = rest.substr(hash);
  17816. rest = rest.slice(0, hash);
  17817. }
  17818. var qm = rest.indexOf('?');
  17819. if (qm !== -1) {
  17820. this.search = rest.substr(qm);
  17821. this.query = rest.substr(qm + 1);
  17822. if (parseQueryString) {
  17823. this.query = querystring.parse(this.query);
  17824. }
  17825. rest = rest.slice(0, qm);
  17826. } else if (parseQueryString) {
  17827. // no query string, but parseQueryString still requested
  17828. this.search = '';
  17829. this.query = {};
  17830. }
  17831. if (rest) this.pathname = rest;
  17832. if (slashedProtocol[lowerProto] &&
  17833. this.hostname && !this.pathname) {
  17834. this.pathname = '/';
  17835. }
  17836. //to support http.request
  17837. if (this.pathname || this.search) {
  17838. var p = this.pathname || '';
  17839. var s = this.search || '';
  17840. this.path = p + s;
  17841. }
  17842. // finally, reconstruct the href based on what has been validated.
  17843. this.href = this.format();
  17844. return this;
  17845. };
  17846. // format a parsed object into a url string
  17847. function urlFormat(obj) {
  17848. // ensure it's an object, and not a string url.
  17849. // If it's an obj, this is a no-op.
  17850. // this way, you can call url_format() on strings
  17851. // to clean up potentially wonky urls.
  17852. if (util.isString(obj)) obj = urlParse(obj);
  17853. if (!(obj instanceof Url)) return Url.prototype.format.call(obj);
  17854. return obj.format();
  17855. }
  17856. Url.prototype.format = function() {
  17857. var auth = this.auth || '';
  17858. if (auth) {
  17859. auth = encodeURIComponent(auth);
  17860. auth = auth.replace(/%3A/i, ':');
  17861. auth += '@';
  17862. }
  17863. var protocol = this.protocol || '',
  17864. pathname = this.pathname || '',
  17865. hash = this.hash || '',
  17866. host = false,
  17867. query = '';
  17868. if (this.host) {
  17869. host = auth + this.host;
  17870. } else if (this.hostname) {
  17871. host = auth + (this.hostname.indexOf(':') === -1 ?
  17872. this.hostname :
  17873. '[' + this.hostname + ']');
  17874. if (this.port) {
  17875. host += ':' + this.port;
  17876. }
  17877. }
  17878. if (this.query &&
  17879. util.isObject(this.query) &&
  17880. Object.keys(this.query).length) {
  17881. query = querystring.stringify(this.query);
  17882. }
  17883. var search = this.search || (query && ('?' + query)) || '';
  17884. if (protocol && protocol.substr(-1) !== ':') protocol += ':';
  17885. // only the slashedProtocols get the //. Not mailto:, xmpp:, etc.
  17886. // unless they had them to begin with.
  17887. if (this.slashes ||
  17888. (!protocol || slashedProtocol[protocol]) && host !== false) {
  17889. host = '//' + (host || '');
  17890. if (pathname && pathname.charAt(0) !== '/') pathname = '/' + pathname;
  17891. } else if (!host) {
  17892. host = '';
  17893. }
  17894. if (hash && hash.charAt(0) !== '#') hash = '#' + hash;
  17895. if (search && search.charAt(0) !== '?') search = '?' + search;
  17896. pathname = pathname.replace(/[?#]/g, function(match) {
  17897. return encodeURIComponent(match);
  17898. });
  17899. search = search.replace('#', '%23');
  17900. return protocol + host + pathname + search + hash;
  17901. };
  17902. function urlResolve(source, relative) {
  17903. return urlParse(source, false, true).resolve(relative);
  17904. }
  17905. Url.prototype.resolve = function(relative) {
  17906. return this.resolveObject(urlParse(relative, false, true)).format();
  17907. };
  17908. function urlResolveObject(source, relative) {
  17909. if (!source) return relative;
  17910. return urlParse(source, false, true).resolveObject(relative);
  17911. }
  17912. Url.prototype.resolveObject = function(relative) {
  17913. if (util.isString(relative)) {
  17914. var rel = new Url();
  17915. rel.parse(relative, false, true);
  17916. relative = rel;
  17917. }
  17918. var result = new Url();
  17919. var tkeys = Object.keys(this);
  17920. for (var tk = 0; tk < tkeys.length; tk++) {
  17921. var tkey = tkeys[tk];
  17922. result[tkey] = this[tkey];
  17923. }
  17924. // hash is always overridden, no matter what.
  17925. // even href="" will remove it.
  17926. result.hash = relative.hash;
  17927. // if the relative url is empty, then there's nothing left to do here.
  17928. if (relative.href === '') {
  17929. result.href = result.format();
  17930. return result;
  17931. }
  17932. // hrefs like //foo/bar always cut to the protocol.
  17933. if (relative.slashes && !relative.protocol) {
  17934. // take everything except the protocol from relative
  17935. var rkeys = Object.keys(relative);
  17936. for (var rk = 0; rk < rkeys.length; rk++) {
  17937. var rkey = rkeys[rk];
  17938. if (rkey !== 'protocol')
  17939. result[rkey] = relative[rkey];
  17940. }
  17941. //urlParse appends trailing / to urls like http://www.example.com
  17942. if (slashedProtocol[result.protocol] &&
  17943. result.hostname && !result.pathname) {
  17944. result.path = result.pathname = '/';
  17945. }
  17946. result.href = result.format();
  17947. return result;
  17948. }
  17949. if (relative.protocol && relative.protocol !== result.protocol) {
  17950. // if it's a known url protocol, then changing
  17951. // the protocol does weird things
  17952. // first, if it's not file:, then we MUST have a host,
  17953. // and if there was a path
  17954. // to begin with, then we MUST have a path.
  17955. // if it is file:, then the host is dropped,
  17956. // because that's known to be hostless.
  17957. // anything else is assumed to be absolute.
  17958. if (!slashedProtocol[relative.protocol]) {
  17959. var keys = Object.keys(relative);
  17960. for (var v = 0; v < keys.length; v++) {
  17961. var k = keys[v];
  17962. result[k] = relative[k];
  17963. }
  17964. result.href = result.format();
  17965. return result;
  17966. }
  17967. result.protocol = relative.protocol;
  17968. if (!relative.host && !hostlessProtocol[relative.protocol]) {
  17969. var relPath = (relative.pathname || '').split('/');
  17970. while (relPath.length && !(relative.host = relPath.shift()));
  17971. if (!relative.host) relative.host = '';
  17972. if (!relative.hostname) relative.hostname = '';
  17973. if (relPath[0] !== '') relPath.unshift('');
  17974. if (relPath.length < 2) relPath.unshift('');
  17975. result.pathname = relPath.join('/');
  17976. } else {
  17977. result.pathname = relative.pathname;
  17978. }
  17979. result.search = relative.search;
  17980. result.query = relative.query;
  17981. result.host = relative.host || '';
  17982. result.auth = relative.auth;
  17983. result.hostname = relative.hostname || relative.host;
  17984. result.port = relative.port;
  17985. // to support http.request
  17986. if (result.pathname || result.search) {
  17987. var p = result.pathname || '';
  17988. var s = result.search || '';
  17989. result.path = p + s;
  17990. }
  17991. result.slashes = result.slashes || relative.slashes;
  17992. result.href = result.format();
  17993. return result;
  17994. }
  17995. var isSourceAbs = (result.pathname && result.pathname.charAt(0) === '/'),
  17996. isRelAbs = (
  17997. relative.host ||
  17998. relative.pathname && relative.pathname.charAt(0) === '/'
  17999. ),
  18000. mustEndAbs = (isRelAbs || isSourceAbs ||
  18001. (result.host && relative.pathname)),
  18002. removeAllDots = mustEndAbs,
  18003. srcPath = result.pathname && result.pathname.split('/') || [],
  18004. relPath = relative.pathname && relative.pathname.split('/') || [],
  18005. psychotic = result.protocol && !slashedProtocol[result.protocol];
  18006. // if the url is a non-slashed url, then relative
  18007. // links like ../.. should be able
  18008. // to crawl up to the hostname, as well. This is strange.
  18009. // result.protocol has already been set by now.
  18010. // Later on, put the first path part into the host field.
  18011. if (psychotic) {
  18012. result.hostname = '';
  18013. result.port = null;
  18014. if (result.host) {
  18015. if (srcPath[0] === '') srcPath[0] = result.host;
  18016. else srcPath.unshift(result.host);
  18017. }
  18018. result.host = '';
  18019. if (relative.protocol) {
  18020. relative.hostname = null;
  18021. relative.port = null;
  18022. if (relative.host) {
  18023. if (relPath[0] === '') relPath[0] = relative.host;
  18024. else relPath.unshift(relative.host);
  18025. }
  18026. relative.host = null;
  18027. }
  18028. mustEndAbs = mustEndAbs && (relPath[0] === '' || srcPath[0] === '');
  18029. }
  18030. if (isRelAbs) {
  18031. // it's absolute.
  18032. result.host = (relative.host || relative.host === '') ?
  18033. relative.host : result.host;
  18034. result.hostname = (relative.hostname || relative.hostname === '') ?
  18035. relative.hostname : result.hostname;
  18036. result.search = relative.search;
  18037. result.query = relative.query;
  18038. srcPath = relPath;
  18039. // fall through to the dot-handling below.
  18040. } else if (relPath.length) {
  18041. // it's relative
  18042. // throw away the existing file, and take the new path instead.
  18043. if (!srcPath) srcPath = [];
  18044. srcPath.pop();
  18045. srcPath = srcPath.concat(relPath);
  18046. result.search = relative.search;
  18047. result.query = relative.query;
  18048. } else if (!util.isNullOrUndefined(relative.search)) {
  18049. // just pull out the search.
  18050. // like href='?foo'.
  18051. // Put this after the other two cases because it simplifies the booleans
  18052. if (psychotic) {
  18053. result.hostname = result.host = srcPath.shift();
  18054. //occationaly the auth can get stuck only in host
  18055. //this especially happens in cases like
  18056. //url.resolveObject('mailto:local1@domain1', 'local2@domain2')
  18057. var authInHost = result.host && result.host.indexOf('@') > 0 ?
  18058. result.host.split('@') : false;
  18059. if (authInHost) {
  18060. result.auth = authInHost.shift();
  18061. result.host = result.hostname = authInHost.shift();
  18062. }
  18063. }
  18064. result.search = relative.search;
  18065. result.query = relative.query;
  18066. //to support http.request
  18067. if (!util.isNull(result.pathname) || !util.isNull(result.search)) {
  18068. result.path = (result.pathname ? result.pathname : '') +
  18069. (result.search ? result.search : '');
  18070. }
  18071. result.href = result.format();
  18072. return result;
  18073. }
  18074. if (!srcPath.length) {
  18075. // no path at all. easy.
  18076. // we've already handled the other stuff above.
  18077. result.pathname = null;
  18078. //to support http.request
  18079. if (result.search) {
  18080. result.path = '/' + result.search;
  18081. } else {
  18082. result.path = null;
  18083. }
  18084. result.href = result.format();
  18085. return result;
  18086. }
  18087. // if a url ENDs in . or .., then it must get a trailing slash.
  18088. // however, if it ends in anything else non-slashy,
  18089. // then it must NOT get a trailing slash.
  18090. var last = srcPath.slice(-1)[0];
  18091. var hasTrailingSlash = (
  18092. (result.host || relative.host || srcPath.length > 1) &&
  18093. (last === '.' || last === '..') || last === '');
  18094. // strip single dots, resolve double dots to parent dir
  18095. // if the path tries to go above the root, `up` ends up > 0
  18096. var up = 0;
  18097. for (var i = srcPath.length; i >= 0; i--) {
  18098. last = srcPath[i];
  18099. if (last === '.') {
  18100. srcPath.splice(i, 1);
  18101. } else if (last === '..') {
  18102. srcPath.splice(i, 1);
  18103. up++;
  18104. } else if (up) {
  18105. srcPath.splice(i, 1);
  18106. up--;
  18107. }
  18108. }
  18109. // if the path is allowed to go above the root, restore leading ..s
  18110. if (!mustEndAbs && !removeAllDots) {
  18111. for (; up--; up) {
  18112. srcPath.unshift('..');
  18113. }
  18114. }
  18115. if (mustEndAbs && srcPath[0] !== '' &&
  18116. (!srcPath[0] || srcPath[0].charAt(0) !== '/')) {
  18117. srcPath.unshift('');
  18118. }
  18119. if (hasTrailingSlash && (srcPath.join('/').substr(-1) !== '/')) {
  18120. srcPath.push('');
  18121. }
  18122. var isAbsolute = srcPath[0] === '' ||
  18123. (srcPath[0] && srcPath[0].charAt(0) === '/');
  18124. // put the host back
  18125. if (psychotic) {
  18126. result.hostname = result.host = isAbsolute ? '' :
  18127. srcPath.length ? srcPath.shift() : '';
  18128. //occationaly the auth can get stuck only in host
  18129. //this especially happens in cases like
  18130. //url.resolveObject('mailto:local1@domain1', 'local2@domain2')
  18131. var authInHost = result.host && result.host.indexOf('@') > 0 ?
  18132. result.host.split('@') : false;
  18133. if (authInHost) {
  18134. result.auth = authInHost.shift();
  18135. result.host = result.hostname = authInHost.shift();
  18136. }
  18137. }
  18138. mustEndAbs = mustEndAbs || (result.host && srcPath.length);
  18139. if (mustEndAbs && !isAbsolute) {
  18140. srcPath.unshift('');
  18141. }
  18142. if (!srcPath.length) {
  18143. result.pathname = null;
  18144. result.path = null;
  18145. } else {
  18146. result.pathname = srcPath.join('/');
  18147. }
  18148. //to support request.http
  18149. if (!util.isNull(result.pathname) || !util.isNull(result.search)) {
  18150. result.path = (result.pathname ? result.pathname : '') +
  18151. (result.search ? result.search : '');
  18152. }
  18153. result.auth = relative.auth || result.auth;
  18154. result.slashes = result.slashes || relative.slashes;
  18155. result.href = result.format();
  18156. return result;
  18157. };
  18158. Url.prototype.parseHost = function() {
  18159. var host = this.host;
  18160. var port = portPattern.exec(host);
  18161. if (port) {
  18162. port = port[0];
  18163. if (port !== ':') {
  18164. this.port = port.substr(1);
  18165. }
  18166. host = host.substr(0, host.length - port.length);
  18167. }
  18168. if (host) this.hostname = host;
  18169. };
  18170. },{"./util":210,"punycode":194,"querystring":197}],210:[function(require,module,exports){
  18171. 'use strict';
  18172. module.exports = {
  18173. isString: function(arg) {
  18174. return typeof(arg) === 'string';
  18175. },
  18176. isObject: function(arg) {
  18177. return typeof(arg) === 'object' && arg !== null;
  18178. },
  18179. isNull: function(arg) {
  18180. return arg === null;
  18181. },
  18182. isNullOrUndefined: function(arg) {
  18183. return arg == null;
  18184. }
  18185. };
  18186. },{}],211:[function(require,module,exports){
  18187. /* eslint-disable no-useless-escape */
  18188. var htmlparser = require('htmlparser2');
  18189. var quoteRegexp = require('lodash/escapeRegExp');
  18190. var cloneDeep = require('lodash/cloneDeep');
  18191. var mergeWith = require('lodash/mergeWith');
  18192. var isString = require('lodash/isString');
  18193. var isPlainObject = require('lodash/isPlainObject');
  18194. var parseSrcset = require('parse-srcset');
  18195. var postcss = require('postcss');
  18196. var url = require('url');
  18197. // Tags that can conceivably represent stand-alone media.
  18198. var mediaTags = [
  18199. 'img', 'audio', 'video', 'picture', 'svg',
  18200. 'object', 'map', 'iframe', 'embed'
  18201. ];
  18202. // Tags that are inherently vulnerable to being used in XSS attacks.
  18203. var vulnerableTags = [ 'script', 'style' ];
  18204. function each(obj, cb) {
  18205. if (obj) {
  18206. Object.keys(obj).forEach(function (key) {
  18207. cb(obj[key], key);
  18208. });
  18209. }
  18210. }
  18211. // Avoid false positives with .__proto__, .hasOwnProperty, etc.
  18212. function has(obj, key) {
  18213. return ({}).hasOwnProperty.call(obj, key);
  18214. }
  18215. // Returns those elements of `a` for which `cb(a)` returns truthy
  18216. function filter(a, cb) {
  18217. var n = [];
  18218. each(a, function(v) {
  18219. if (cb(v)) {
  18220. n.push(v);
  18221. }
  18222. });
  18223. return n;
  18224. }
  18225. function isEmptyObject(obj) {
  18226. for (var key in obj) {
  18227. if (has(obj, key)) {
  18228. return false;
  18229. }
  18230. }
  18231. return true;
  18232. }
  18233. function stringifySrcset(parsedSrcset) {
  18234. return parsedSrcset.map(function(part) {
  18235. if (!part.url) {
  18236. throw new Error('URL missing');
  18237. }
  18238. return (
  18239. part.url +
  18240. (part.w ? ` ${part.w}w` : '') +
  18241. (part.h ? ` ${part.h}h` : '') +
  18242. (part.d ? ` ${part.d}x` : '')
  18243. );
  18244. }).join(', ');
  18245. }
  18246. module.exports = sanitizeHtml;
  18247. // A valid attribute name.
  18248. // We use a tolerant definition based on the set of strings defined by
  18249. // html.spec.whatwg.org/multipage/parsing.html#before-attribute-name-state
  18250. // and html.spec.whatwg.org/multipage/parsing.html#attribute-name-state .
  18251. // The characters accepted are ones which can be appended to the attribute
  18252. // name buffer without triggering a parse error:
  18253. // * unexpected-equals-sign-before-attribute-name
  18254. // * unexpected-null-character
  18255. // * unexpected-character-in-attribute-name
  18256. // We exclude the empty string because it's impossible to get to the after
  18257. // attribute name state with an empty attribute name buffer.
  18258. const VALID_HTML_ATTRIBUTE_NAME = /^[^\0\t\n\f\r /<=>]+$/;
  18259. // Ignore the _recursing flag; it's there for recursive
  18260. // invocation as a guard against this exploit:
  18261. // https://github.com/fb55/htmlparser2/issues/105
  18262. function sanitizeHtml(html, options, _recursing) {
  18263. var result = '';
  18264. // Used for hot swapping the result variable with an empty string in order to "capture" the text written to it.
  18265. var tempResult = '';
  18266. function Frame(tag, attribs) {
  18267. var that = this;
  18268. this.tag = tag;
  18269. this.attribs = attribs || {};
  18270. this.tagPosition = result.length;
  18271. this.text = ''; // Node inner text
  18272. this.mediaChildren = [];
  18273. this.updateParentNodeText = function() {
  18274. if (stack.length) {
  18275. var parentFrame = stack[stack.length - 1];
  18276. parentFrame.text += that.text;
  18277. }
  18278. };
  18279. this.updateParentNodeMediaChildren = function() {
  18280. if (stack.length && mediaTags.indexOf(this.tag) > -1) {
  18281. var parentFrame = stack[stack.length - 1];
  18282. parentFrame.mediaChildren.push(this.tag);
  18283. }
  18284. };
  18285. }
  18286. if (!options) {
  18287. options = sanitizeHtml.defaults;
  18288. options.parser = htmlParserDefaults;
  18289. } else {
  18290. options = Object.assign({}, sanitizeHtml.defaults, options);
  18291. if (options.parser) {
  18292. options.parser = Object.assign({}, htmlParserDefaults, options.parser);
  18293. } else {
  18294. options.parser = htmlParserDefaults;
  18295. }
  18296. }
  18297. // vulnerableTags
  18298. vulnerableTags.forEach(function (tag) {
  18299. if (
  18300. options.allowedTags && options.allowedTags.indexOf(tag) > -1 &&
  18301. !options.allowVulnerableTags
  18302. ) {
  18303. // eslint-disable-next-line no-console
  18304. console.warn(`\n\n⚠️ Your \`allowedTags\` option includes, \`${tag}\`, which is inherently\nvulnerable to XSS attacks. Please remove it from \`allowedTags\`.\nOr, to disable this warning, add the \`allowVulnerableTags\` option\nand ensure you are accounting for this risk.\n\n`);
  18305. }
  18306. });
  18307. // Tags that contain something other than HTML, or where discarding
  18308. // the text when the tag is disallowed makes sense for other reasons.
  18309. // If we are not allowing these tags, we should drop their content too.
  18310. // For other tags you would drop the tag but keep its content.
  18311. var nonTextTagsArray = options.nonTextTags || [
  18312. 'script',
  18313. 'style',
  18314. 'textarea',
  18315. 'option'
  18316. ];
  18317. var allowedAttributesMap;
  18318. var allowedAttributesGlobMap;
  18319. if (options.allowedAttributes) {
  18320. allowedAttributesMap = {};
  18321. allowedAttributesGlobMap = {};
  18322. each(options.allowedAttributes, function(attributes, tag) {
  18323. allowedAttributesMap[tag] = [];
  18324. var globRegex = [];
  18325. attributes.forEach(function(obj) {
  18326. if (isString(obj) && obj.indexOf('*') >= 0) {
  18327. globRegex.push(quoteRegexp(obj).replace(/\\\*/g, '.*'));
  18328. } else {
  18329. allowedAttributesMap[tag].push(obj);
  18330. }
  18331. });
  18332. allowedAttributesGlobMap[tag] = new RegExp('^(' + globRegex.join('|') + ')$');
  18333. });
  18334. }
  18335. var allowedClassesMap = {};
  18336. each(options.allowedClasses, function(classes, tag) {
  18337. // Implicitly allows the class attribute
  18338. if (allowedAttributesMap) {
  18339. if (!has(allowedAttributesMap, tag)) {
  18340. allowedAttributesMap[tag] = [];
  18341. }
  18342. allowedAttributesMap[tag].push('class');
  18343. }
  18344. allowedClassesMap[tag] = classes;
  18345. });
  18346. var transformTagsMap = {};
  18347. var transformTagsAll;
  18348. each(options.transformTags, function(transform, tag) {
  18349. var transFun;
  18350. if (typeof transform === 'function') {
  18351. transFun = transform;
  18352. } else if (typeof transform === 'string') {
  18353. transFun = sanitizeHtml.simpleTransform(transform);
  18354. }
  18355. if (tag === '*') {
  18356. transformTagsAll = transFun;
  18357. } else {
  18358. transformTagsMap[tag] = transFun;
  18359. }
  18360. });
  18361. var depth;
  18362. var stack;
  18363. var skipMap;
  18364. var transformMap;
  18365. var skipText;
  18366. var skipTextDepth;
  18367. var addedText = false;
  18368. initializeState();
  18369. var parser = new htmlparser.Parser({
  18370. onopentag: function(name, attribs) {
  18371. // If `enforceHtmlBoundary` is `true` and this has found the opening
  18372. // `html` tag, reset the state.
  18373. if (options.enforceHtmlBoundary && name === 'html') {
  18374. initializeState();
  18375. }
  18376. if (skipText) {
  18377. skipTextDepth++;
  18378. return;
  18379. }
  18380. var frame = new Frame(name, attribs);
  18381. stack.push(frame);
  18382. var skip = false;
  18383. var hasText = !!frame.text;
  18384. var transformedTag;
  18385. if (has(transformTagsMap, name)) {
  18386. transformedTag = transformTagsMap[name](name, attribs);
  18387. frame.attribs = attribs = transformedTag.attribs;
  18388. if (transformedTag.text !== undefined) {
  18389. frame.innerText = transformedTag.text;
  18390. }
  18391. if (name !== transformedTag.tagName) {
  18392. frame.name = name = transformedTag.tagName;
  18393. transformMap[depth] = transformedTag.tagName;
  18394. }
  18395. }
  18396. if (transformTagsAll) {
  18397. transformedTag = transformTagsAll(name, attribs);
  18398. frame.attribs = attribs = transformedTag.attribs;
  18399. if (name !== transformedTag.tagName) {
  18400. frame.name = name = transformedTag.tagName;
  18401. transformMap[depth] = transformedTag.tagName;
  18402. }
  18403. }
  18404. if ((options.allowedTags && options.allowedTags.indexOf(name) === -1) || (options.disallowedTagsMode === 'recursiveEscape' && !isEmptyObject(skipMap))) {
  18405. skip = true;
  18406. skipMap[depth] = true;
  18407. if (options.disallowedTagsMode === 'discard') {
  18408. if (nonTextTagsArray.indexOf(name) !== -1) {
  18409. skipText = true;
  18410. skipTextDepth = 1;
  18411. }
  18412. }
  18413. skipMap[depth] = true;
  18414. }
  18415. depth++;
  18416. if (skip) {
  18417. if (options.disallowedTagsMode === 'discard') {
  18418. // We want the contents but not this tag
  18419. return;
  18420. }
  18421. tempResult = result;
  18422. result = '';
  18423. }
  18424. result += '<' + name;
  18425. if (!allowedAttributesMap || has(allowedAttributesMap, name) || allowedAttributesMap['*']) {
  18426. each(attribs, function(value, a) {
  18427. if (!VALID_HTML_ATTRIBUTE_NAME.test(a)) {
  18428. // This prevents part of an attribute name in the output from being
  18429. // interpreted as the end of an attribute, or end of a tag.
  18430. delete frame.attribs[a];
  18431. return;
  18432. }
  18433. var parsed;
  18434. // check allowedAttributesMap for the element and attribute and modify the value
  18435. // as necessary if there are specific values defined.
  18436. var passedAllowedAttributesMapCheck = false;
  18437. if (!allowedAttributesMap ||
  18438. (has(allowedAttributesMap, name) && allowedAttributesMap[name].indexOf(a) !== -1) ||
  18439. (allowedAttributesMap['*'] && allowedAttributesMap['*'].indexOf(a) !== -1) ||
  18440. (has(allowedAttributesGlobMap, name) && allowedAttributesGlobMap[name].test(a)) ||
  18441. (allowedAttributesGlobMap['*'] && allowedAttributesGlobMap['*'].test(a))) {
  18442. passedAllowedAttributesMapCheck = true;
  18443. } else if (allowedAttributesMap && allowedAttributesMap[name]) {
  18444. for (const o of allowedAttributesMap[name]) {
  18445. if (isPlainObject(o) && o.name && (o.name === a)) {
  18446. passedAllowedAttributesMapCheck = true;
  18447. var newValue = '';
  18448. if (o.multiple === true) {
  18449. // verify the values that are allowed
  18450. const splitStrArray = value.split(' ');
  18451. for (const s of splitStrArray) {
  18452. if (o.values.indexOf(s) !== -1) {
  18453. if (newValue === '') {
  18454. newValue = s;
  18455. } else {
  18456. newValue += ' ' + s;
  18457. }
  18458. }
  18459. }
  18460. } else if (o.values.indexOf(value) >= 0) {
  18461. // verified an allowed value matches the entire attribute value
  18462. newValue = value;
  18463. }
  18464. value = newValue;
  18465. }
  18466. }
  18467. }
  18468. if (passedAllowedAttributesMapCheck) {
  18469. if (options.allowedSchemesAppliedToAttributes.indexOf(a) !== -1) {
  18470. if (naughtyHref(name, value)) {
  18471. delete frame.attribs[a];
  18472. return;
  18473. }
  18474. }
  18475. if (name === 'iframe' && a === 'src') {
  18476. var allowed = true;
  18477. try {
  18478. // naughtyHref is in charge of whether protocol relative URLs
  18479. // are cool. We should just accept them.
  18480. // eslint-disable-next-line node/no-deprecated-api
  18481. parsed = url.parse(value, false, true);
  18482. var isRelativeUrl = parsed && parsed.host === null && parsed.protocol === null;
  18483. if (isRelativeUrl) {
  18484. // default value of allowIframeRelativeUrls is true
  18485. // unless allowedIframeHostnames or allowedIframeDomains specified
  18486. allowed = has(options, 'allowIframeRelativeUrls')
  18487. ? options.allowIframeRelativeUrls
  18488. : (!options.allowedIframeHostnames && !options.allowedIframeDomains);
  18489. } else if (options.allowedIframeHostnames || options.allowedIframeDomains) {
  18490. var allowedHostname = (options.allowedIframeHostnames || []).find(function (hostname) {
  18491. return hostname === parsed.hostname;
  18492. });
  18493. var allowedDomain = (options.allowedIframeDomains || []).find(function(domain) {
  18494. return parsed.hostname === domain || parsed.hostname.endsWith(`.${domain}`);
  18495. });
  18496. allowed = allowedHostname || allowedDomain;
  18497. }
  18498. } catch (e) {
  18499. // Unparseable iframe src
  18500. allowed = false;
  18501. }
  18502. if (!allowed) {
  18503. delete frame.attribs[a];
  18504. return;
  18505. }
  18506. }
  18507. if (a === 'srcset') {
  18508. try {
  18509. parsed = parseSrcset(value);
  18510. each(parsed, function(value) {
  18511. if (naughtyHref('srcset', value.url)) {
  18512. value.evil = true;
  18513. }
  18514. });
  18515. parsed = filter(parsed, function(v) {
  18516. return !v.evil;
  18517. });
  18518. if (!parsed.length) {
  18519. delete frame.attribs[a];
  18520. return;
  18521. } else {
  18522. value = stringifySrcset(filter(parsed, function(v) {
  18523. return !v.evil;
  18524. }));
  18525. frame.attribs[a] = value;
  18526. }
  18527. } catch (e) {
  18528. // Unparseable srcset
  18529. delete frame.attribs[a];
  18530. return;
  18531. }
  18532. }
  18533. if (a === 'class') {
  18534. value = filterClasses(value, allowedClassesMap[name]);
  18535. if (!value.length) {
  18536. delete frame.attribs[a];
  18537. return;
  18538. }
  18539. }
  18540. if (a === 'style') {
  18541. try {
  18542. var abstractSyntaxTree = postcss.parse(name + ' {' + value + '}');
  18543. var filteredAST = filterCss(abstractSyntaxTree, options.allowedStyles);
  18544. value = stringifyStyleAttributes(filteredAST);
  18545. if (value.length === 0) {
  18546. delete frame.attribs[a];
  18547. return;
  18548. }
  18549. } catch (e) {
  18550. delete frame.attribs[a];
  18551. return;
  18552. }
  18553. }
  18554. result += ' ' + a;
  18555. if (value && value.length) {
  18556. result += '="' + escapeHtml(value, true) + '"';
  18557. }
  18558. } else {
  18559. delete frame.attribs[a];
  18560. }
  18561. });
  18562. }
  18563. if (options.selfClosing.indexOf(name) !== -1) {
  18564. result += ' />';
  18565. } else {
  18566. result += '>';
  18567. if (frame.innerText && !hasText && !options.textFilter) {
  18568. result += frame.innerText;
  18569. addedText = true;
  18570. }
  18571. }
  18572. if (skip) {
  18573. result = tempResult + escapeHtml(result);
  18574. tempResult = '';
  18575. }
  18576. },
  18577. ontext: function(text) {
  18578. if (skipText) {
  18579. return;
  18580. }
  18581. var lastFrame = stack[stack.length - 1];
  18582. var tag;
  18583. if (lastFrame) {
  18584. tag = lastFrame.tag;
  18585. // If inner text was set by transform function then let's use it
  18586. text = lastFrame.innerText !== undefined ? lastFrame.innerText : text;
  18587. }
  18588. if (options.disallowedTagsMode === 'discard' && ((tag === 'script') || (tag === 'style'))) {
  18589. // htmlparser2 gives us these as-is. Escaping them ruins the content. Allowing
  18590. // script tags is, by definition, game over for XSS protection, so if that's
  18591. // your concern, don't allow them. The same is essentially true for style tags
  18592. // which have their own collection of XSS vectors.
  18593. result += text;
  18594. } else {
  18595. var escaped = escapeHtml(text, false);
  18596. if (options.textFilter && !addedText) {
  18597. result += options.textFilter(escaped, tag);
  18598. } else if (!addedText) {
  18599. result += escaped;
  18600. }
  18601. }
  18602. if (stack.length) {
  18603. var frame = stack[stack.length - 1];
  18604. frame.text += text;
  18605. }
  18606. },
  18607. onclosetag: function(name) {
  18608. if (skipText) {
  18609. skipTextDepth--;
  18610. if (!skipTextDepth) {
  18611. skipText = false;
  18612. } else {
  18613. return;
  18614. }
  18615. }
  18616. var frame = stack.pop();
  18617. if (!frame) {
  18618. // Do not crash on bad markup
  18619. return;
  18620. }
  18621. skipText = options.enforceHtmlBoundary ? name === 'html' : false;
  18622. depth--;
  18623. var skip = skipMap[depth];
  18624. if (skip) {
  18625. delete skipMap[depth];
  18626. if (options.disallowedTagsMode === 'discard') {
  18627. frame.updateParentNodeText();
  18628. return;
  18629. }
  18630. tempResult = result;
  18631. result = '';
  18632. }
  18633. if (transformMap[depth]) {
  18634. name = transformMap[depth];
  18635. delete transformMap[depth];
  18636. }
  18637. if (options.exclusiveFilter && options.exclusiveFilter(frame)) {
  18638. result = result.substr(0, frame.tagPosition);
  18639. return;
  18640. }
  18641. frame.updateParentNodeMediaChildren();
  18642. frame.updateParentNodeText();
  18643. if (options.selfClosing.indexOf(name) !== -1) {
  18644. // Already output />
  18645. if (skip) {
  18646. result = tempResult;
  18647. tempResult = '';
  18648. }
  18649. return;
  18650. }
  18651. result += '</' + name + '>';
  18652. if (skip) {
  18653. result = tempResult + escapeHtml(result);
  18654. tempResult = '';
  18655. }
  18656. }
  18657. }, options.parser);
  18658. parser.write(html);
  18659. parser.end();
  18660. return result;
  18661. function initializeState() {
  18662. result = '';
  18663. depth = 0;
  18664. stack = [];
  18665. skipMap = {};
  18666. transformMap = {};
  18667. skipText = false;
  18668. skipTextDepth = 0;
  18669. }
  18670. function escapeHtml(s, quote) {
  18671. if (typeof (s) !== 'string') {
  18672. s = s + '';
  18673. }
  18674. if (options.parser.decodeEntities) {
  18675. s = s.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/\>/g, '&gt;');
  18676. if (quote) {
  18677. s = s.replace(/\"/g, '&quot;');
  18678. }
  18679. }
  18680. // TODO: this is inadequate because it will pass `&0;`. This approach
  18681. // will not work, each & must be considered with regard to whether it
  18682. // is followed by a 100% syntactically valid entity or not, and escaped
  18683. // if it is not. If this bothers you, don't set parser.decodeEntities
  18684. // to false. (The default is true.)
  18685. s = s.replace(/&(?![a-zA-Z0-9#]{1,20};)/g, '&amp;') // Match ampersands not part of existing HTML entity
  18686. .replace(/</g, '&lt;')
  18687. .replace(/\>/g, '&gt;');
  18688. if (quote) {
  18689. s = s.replace(/\"/g, '&quot;');
  18690. }
  18691. return s;
  18692. }
  18693. function naughtyHref(name, href) {
  18694. // Browsers ignore character codes of 32 (space) and below in a surprising
  18695. // number of situations. Start reading here:
  18696. // https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#Embedded_tab
  18697. // eslint-disable-next-line no-control-regex
  18698. href = href.replace(/[\x00-\x20]+/g, '');
  18699. // Clobber any comments in URLs, which the browser might
  18700. // interpret inside an XML data island, allowing
  18701. // a javascript: URL to be snuck through
  18702. href = href.replace(/<\!\-\-.*?\-\-\>/g, '');
  18703. // Case insensitive so we don't get faked out by JAVASCRIPT #1
  18704. var matches = href.match(/^([a-zA-Z]+)\:/);
  18705. if (!matches) {
  18706. // Protocol-relative URL starting with any combination of '/' and '\'
  18707. if (href.match(/^[\/\\]{2}/)) {
  18708. return !options.allowProtocolRelative;
  18709. }
  18710. // No scheme
  18711. return false;
  18712. }
  18713. var scheme = matches[1].toLowerCase();
  18714. if (has(options.allowedSchemesByTag, name)) {
  18715. return options.allowedSchemesByTag[name].indexOf(scheme) === -1;
  18716. }
  18717. return !options.allowedSchemes || options.allowedSchemes.indexOf(scheme) === -1;
  18718. }
  18719. /**
  18720. * Filters user input css properties by whitelisted regex attributes.
  18721. *
  18722. * @param {object} abstractSyntaxTree - Object representation of CSS attributes.
  18723. * @property {array[Declaration]} abstractSyntaxTree.nodes[0] - Each object cointains prop and value key, i.e { prop: 'color', value: 'red' }.
  18724. * @param {object} allowedStyles - Keys are properties (i.e color), value is list of permitted regex rules (i.e /green/i).
  18725. * @return {object} - Abstract Syntax Tree with filtered style attributes.
  18726. */
  18727. function filterCss(abstractSyntaxTree, allowedStyles) {
  18728. if (!allowedStyles) {
  18729. return abstractSyntaxTree;
  18730. }
  18731. var filteredAST = cloneDeep(abstractSyntaxTree);
  18732. var astRules = abstractSyntaxTree.nodes[0];
  18733. var selectedRule;
  18734. // Merge global and tag-specific styles into new AST.
  18735. if (allowedStyles[astRules.selector] && allowedStyles['*']) {
  18736. selectedRule = mergeWith(
  18737. cloneDeep(allowedStyles[astRules.selector]),
  18738. allowedStyles['*'],
  18739. function(objValue, srcValue) {
  18740. if (Array.isArray(objValue)) {
  18741. return objValue.concat(srcValue);
  18742. }
  18743. }
  18744. );
  18745. } else {
  18746. selectedRule = allowedStyles[astRules.selector] || allowedStyles['*'];
  18747. }
  18748. if (selectedRule) {
  18749. filteredAST.nodes[0].nodes = astRules.nodes.reduce(filterDeclarations(selectedRule), []);
  18750. }
  18751. return filteredAST;
  18752. }
  18753. /**
  18754. * Extracts the style attribues from an AbstractSyntaxTree and formats those
  18755. * values in the inline style attribute format.
  18756. *
  18757. * @param {AbstractSyntaxTree} filteredAST
  18758. * @return {string} - Example: "color:yellow;text-align:center;font-family:helvetica;"
  18759. */
  18760. function stringifyStyleAttributes(filteredAST) {
  18761. return filteredAST.nodes[0].nodes
  18762. .reduce(function(extractedAttributes, attributeObject) {
  18763. extractedAttributes.push(
  18764. attributeObject.prop + ':' + attributeObject.value
  18765. );
  18766. return extractedAttributes;
  18767. }, [])
  18768. .join(';');
  18769. }
  18770. /**
  18771. * Filters the existing attributes for the given property. Discards any attributes
  18772. * which don't match the whitelist.
  18773. *
  18774. * @param {object} selectedRule - Example: { color: red, font-family: helvetica }
  18775. * @param {array} allowedDeclarationsList - List of declarations which pass whitelisting.
  18776. * @param {object} attributeObject - Object representing the current css property.
  18777. * @property {string} attributeObject.type - Typically 'declaration'.
  18778. * @property {string} attributeObject.prop - The CSS property, i.e 'color'.
  18779. * @property {string} attributeObject.value - The corresponding value to the css property, i.e 'red'.
  18780. * @return {function} - When used in Array.reduce, will return an array of Declaration objects
  18781. */
  18782. function filterDeclarations(selectedRule) {
  18783. return function (allowedDeclarationsList, attributeObject) {
  18784. // If this property is whitelisted...
  18785. if (has(selectedRule, attributeObject.prop)) {
  18786. var matchesRegex = selectedRule[attributeObject.prop].some(function(regularExpression) {
  18787. return regularExpression.test(attributeObject.value);
  18788. });
  18789. if (matchesRegex) {
  18790. allowedDeclarationsList.push(attributeObject);
  18791. }
  18792. }
  18793. return allowedDeclarationsList;
  18794. };
  18795. }
  18796. function filterClasses(classes, allowed) {
  18797. if (!allowed) {
  18798. // The class attribute is allowed without filtering on this tag
  18799. return classes;
  18800. }
  18801. classes = classes.split(/\s+/);
  18802. return classes.filter(function(clss) {
  18803. return allowed.indexOf(clss) !== -1;
  18804. }).join(' ');
  18805. }
  18806. }
  18807. // Defaults are accessible to you so that you can use them as a starting point
  18808. // programmatically if you wish
  18809. var htmlParserDefaults = {
  18810. decodeEntities: true
  18811. };
  18812. sanitizeHtml.defaults = {
  18813. allowedTags: [ 'h3', 'h4', 'h5', 'h6', 'blockquote', 'p', 'a', 'ul', 'ol',
  18814. 'nl', 'li', 'b', 'i', 'strong', 'em', 'strike', 'abbr', 'code', 'hr', 'br', 'div',
  18815. 'table', 'thead', 'caption', 'tbody', 'tr', 'th', 'td', 'pre', 'iframe' ],
  18816. disallowedTagsMode: 'discard',
  18817. allowedAttributes: {
  18818. a: [ 'href', 'name', 'target' ],
  18819. // We don't currently allow img itself by default, but this
  18820. // would make sense if we did. You could add srcset here,
  18821. // and if you do the URL is checked for safety
  18822. img: [ 'src' ]
  18823. },
  18824. // Lots of these won't come up by default because we don't allow them
  18825. selfClosing: [ 'img', 'br', 'hr', 'area', 'base', 'basefont', 'input', 'link', 'meta' ],
  18826. // URL schemes we permit
  18827. allowedSchemes: [ 'http', 'https', 'ftp', 'mailto' ],
  18828. allowedSchemesByTag: {},
  18829. allowedSchemesAppliedToAttributes: [ 'href', 'src', 'cite' ],
  18830. allowProtocolRelative: true,
  18831. enforceHtmlBoundary: false
  18832. };
  18833. sanitizeHtml.simpleTransform = function(newTagName, newAttribs, merge) {
  18834. merge = (merge === undefined) ? true : merge;
  18835. newAttribs = newAttribs || {};
  18836. return function(tagName, attribs) {
  18837. var attrib;
  18838. if (merge) {
  18839. for (attrib in newAttribs) {
  18840. attribs[attrib] = newAttribs[attrib];
  18841. }
  18842. } else {
  18843. attribs = newAttribs;
  18844. }
  18845. return {
  18846. tagName: newTagName,
  18847. attribs: attribs
  18848. };
  18849. };
  18850. };
  18851. },{"htmlparser2":31,"lodash/cloneDeep":140,"lodash/escapeRegExp":143,"lodash/isPlainObject":155,"lodash/isString":157,"lodash/mergeWith":162,"parse-srcset":167,"postcss":181,"url":209}]},{},[211])(211)
  18852. });