dep-ae4d20cb.js 220 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568
  1. import require$$0__default from 'fs';
  2. import require$$0 from 'postcss';
  3. import { A as commonjsGlobal } from './dep-f11f7337.js';
  4. import require$$0$1 from 'path';
  5. import require$$5 from 'crypto';
  6. import require$$0$2 from 'util';
  7. import { l as lib } from './dep-07a79996.js';
  8. import { fileURLToPath as __cjs_fileURLToPath } from 'node:url';
  9. import { dirname as __cjs_dirname } from 'node:path';
  10. import { createRequire as __cjs_createRequire } from 'node:module';
  11. const __filename = __cjs_fileURLToPath(import.meta.url);
  12. const __dirname = __cjs_dirname(__filename);
  13. const require = __cjs_createRequire(import.meta.url);
  14. const __require = require;
  15. function _mergeNamespaces(n, m) {
  16. for (var i = 0; i < m.length; i++) {
  17. var e = m[i];
  18. if (typeof e !== 'string' && !Array.isArray(e)) { for (var k in e) {
  19. if (k !== 'default' && !(k in n)) {
  20. n[k] = e[k];
  21. }
  22. } }
  23. }
  24. return n;
  25. }
  26. var build = {exports: {}};
  27. var fs = {};
  28. Object.defineProperty(fs, "__esModule", {
  29. value: true
  30. });
  31. fs.getFileSystem = getFileSystem;
  32. fs.setFileSystem = setFileSystem;
  33. let fileSystem = {
  34. readFile: () => {
  35. throw Error("readFile not implemented");
  36. },
  37. writeFile: () => {
  38. throw Error("writeFile not implemented");
  39. }
  40. };
  41. function setFileSystem(fs) {
  42. fileSystem.readFile = fs.readFile;
  43. fileSystem.writeFile = fs.writeFile;
  44. }
  45. function getFileSystem() {
  46. return fileSystem;
  47. }
  48. var pluginFactory = {};
  49. var unquote$1 = {};
  50. Object.defineProperty(unquote$1, "__esModule", {
  51. value: true
  52. });
  53. unquote$1.default = unquote;
  54. // copied from https://github.com/lakenen/node-unquote
  55. const reg = /['"]/;
  56. function unquote(str) {
  57. if (!str) {
  58. return "";
  59. }
  60. if (reg.test(str.charAt(0))) {
  61. str = str.substr(1);
  62. }
  63. if (reg.test(str.charAt(str.length - 1))) {
  64. str = str.substr(0, str.length - 1);
  65. }
  66. return str;
  67. }
  68. var Parser$1 = {};
  69. const matchValueName = /[$]?[\w-]+/g;
  70. const replaceValueSymbols$2 = (value, replacements) => {
  71. let matches;
  72. while ((matches = matchValueName.exec(value))) {
  73. const replacement = replacements[matches[0]];
  74. if (replacement) {
  75. value =
  76. value.slice(0, matches.index) +
  77. replacement +
  78. value.slice(matchValueName.lastIndex);
  79. matchValueName.lastIndex -= matches[0].length - replacement.length;
  80. }
  81. }
  82. return value;
  83. };
  84. var replaceValueSymbols_1 = replaceValueSymbols$2;
  85. const replaceValueSymbols$1 = replaceValueSymbols_1;
  86. const replaceSymbols$1 = (css, replacements) => {
  87. css.walk((node) => {
  88. if (node.type === "decl" && node.value) {
  89. node.value = replaceValueSymbols$1(node.value.toString(), replacements);
  90. } else if (node.type === "rule" && node.selector) {
  91. node.selector = replaceValueSymbols$1(
  92. node.selector.toString(),
  93. replacements
  94. );
  95. } else if (node.type === "atrule" && node.params) {
  96. node.params = replaceValueSymbols$1(node.params.toString(), replacements);
  97. }
  98. });
  99. };
  100. var replaceSymbols_1 = replaceSymbols$1;
  101. const importPattern = /^:import\(("[^"]*"|'[^']*'|[^"']+)\)$/;
  102. const balancedQuotes = /^("[^"]*"|'[^']*'|[^"']+)$/;
  103. const getDeclsObject = (rule) => {
  104. const object = {};
  105. rule.walkDecls((decl) => {
  106. const before = decl.raws.before ? decl.raws.before.trim() : "";
  107. object[before + decl.prop] = decl.value;
  108. });
  109. return object;
  110. };
  111. /**
  112. *
  113. * @param {string} css
  114. * @param {boolean} removeRules
  115. * @param {'auto' | 'rule' | 'at-rule'} mode
  116. */
  117. const extractICSS$2 = (css, removeRules = true, mode = "auto") => {
  118. const icssImports = {};
  119. const icssExports = {};
  120. function addImports(node, path) {
  121. const unquoted = path.replace(/'|"/g, "");
  122. icssImports[unquoted] = Object.assign(
  123. icssImports[unquoted] || {},
  124. getDeclsObject(node)
  125. );
  126. if (removeRules) {
  127. node.remove();
  128. }
  129. }
  130. function addExports(node) {
  131. Object.assign(icssExports, getDeclsObject(node));
  132. if (removeRules) {
  133. node.remove();
  134. }
  135. }
  136. css.each((node) => {
  137. if (node.type === "rule" && mode !== "at-rule") {
  138. if (node.selector.slice(0, 7) === ":import") {
  139. const matches = importPattern.exec(node.selector);
  140. if (matches) {
  141. addImports(node, matches[1]);
  142. }
  143. }
  144. if (node.selector === ":export") {
  145. addExports(node);
  146. }
  147. }
  148. if (node.type === "atrule" && mode !== "rule") {
  149. if (node.name === "icss-import") {
  150. const matches = balancedQuotes.exec(node.params);
  151. if (matches) {
  152. addImports(node, matches[1]);
  153. }
  154. }
  155. if (node.name === "icss-export") {
  156. addExports(node);
  157. }
  158. }
  159. });
  160. return { icssImports, icssExports };
  161. };
  162. var extractICSS_1 = extractICSS$2;
  163. const createImports = (imports, postcss, mode = "rule") => {
  164. return Object.keys(imports).map((path) => {
  165. const aliases = imports[path];
  166. const declarations = Object.keys(aliases).map((key) =>
  167. postcss.decl({
  168. prop: key,
  169. value: aliases[key],
  170. raws: { before: "\n " },
  171. })
  172. );
  173. const hasDeclarations = declarations.length > 0;
  174. const rule =
  175. mode === "rule"
  176. ? postcss.rule({
  177. selector: `:import('${path}')`,
  178. raws: { after: hasDeclarations ? "\n" : "" },
  179. })
  180. : postcss.atRule({
  181. name: "icss-import",
  182. params: `'${path}'`,
  183. raws: { after: hasDeclarations ? "\n" : "" },
  184. });
  185. if (hasDeclarations) {
  186. rule.append(declarations);
  187. }
  188. return rule;
  189. });
  190. };
  191. const createExports = (exports, postcss, mode = "rule") => {
  192. const declarations = Object.keys(exports).map((key) =>
  193. postcss.decl({
  194. prop: key,
  195. value: exports[key],
  196. raws: { before: "\n " },
  197. })
  198. );
  199. if (declarations.length === 0) {
  200. return [];
  201. }
  202. const rule =
  203. mode === "rule"
  204. ? postcss.rule({
  205. selector: `:export`,
  206. raws: { after: "\n" },
  207. })
  208. : postcss.atRule({
  209. name: "icss-export",
  210. raws: { after: "\n" },
  211. });
  212. rule.append(declarations);
  213. return [rule];
  214. };
  215. const createICSSRules$1 = (imports, exports, postcss, mode) => [
  216. ...createImports(imports, postcss, mode),
  217. ...createExports(exports, postcss, mode),
  218. ];
  219. var createICSSRules_1 = createICSSRules$1;
  220. const replaceValueSymbols = replaceValueSymbols_1;
  221. const replaceSymbols = replaceSymbols_1;
  222. const extractICSS$1 = extractICSS_1;
  223. const createICSSRules = createICSSRules_1;
  224. var src$4 = {
  225. replaceValueSymbols,
  226. replaceSymbols,
  227. extractICSS: extractICSS$1,
  228. createICSSRules,
  229. };
  230. Object.defineProperty(Parser$1, "__esModule", {
  231. value: true
  232. });
  233. Parser$1.default = void 0;
  234. var _icssUtils = src$4;
  235. // Initially copied from https://github.com/css-modules/css-modules-loader-core
  236. const importRegexp = /^:import\((.+)\)$/;
  237. class Parser {
  238. constructor(pathFetcher, trace) {
  239. this.pathFetcher = pathFetcher;
  240. this.plugin = this.plugin.bind(this);
  241. this.exportTokens = {};
  242. this.translations = {};
  243. this.trace = trace;
  244. }
  245. plugin() {
  246. const parser = this;
  247. return {
  248. postcssPlugin: "css-modules-parser",
  249. async OnceExit(css) {
  250. await Promise.all(parser.fetchAllImports(css));
  251. parser.linkImportedSymbols(css);
  252. return parser.extractExports(css);
  253. }
  254. };
  255. }
  256. fetchAllImports(css) {
  257. let imports = [];
  258. css.each(node => {
  259. if (node.type == "rule" && node.selector.match(importRegexp)) {
  260. imports.push(this.fetchImport(node, css.source.input.from, imports.length));
  261. }
  262. });
  263. return imports;
  264. }
  265. linkImportedSymbols(css) {
  266. (0, _icssUtils.replaceSymbols)(css, this.translations);
  267. }
  268. extractExports(css) {
  269. css.each(node => {
  270. if (node.type == "rule" && node.selector == ":export") this.handleExport(node);
  271. });
  272. }
  273. handleExport(exportNode) {
  274. exportNode.each(decl => {
  275. if (decl.type == "decl") {
  276. Object.keys(this.translations).forEach(translation => {
  277. decl.value = decl.value.replace(translation, this.translations[translation]);
  278. });
  279. this.exportTokens[decl.prop] = decl.value;
  280. }
  281. });
  282. exportNode.remove();
  283. }
  284. async fetchImport(importNode, relativeTo, depNr) {
  285. const file = importNode.selector.match(importRegexp)[1];
  286. const depTrace = this.trace + String.fromCharCode(depNr);
  287. const exports = await this.pathFetcher(file, relativeTo, depTrace);
  288. try {
  289. importNode.each(decl => {
  290. if (decl.type == "decl") {
  291. this.translations[decl.prop] = exports[decl.value];
  292. }
  293. });
  294. importNode.remove();
  295. } catch (err) {
  296. console.log(err);
  297. }
  298. }
  299. }
  300. Parser$1.default = Parser;
  301. var saveJSON$1 = {};
  302. Object.defineProperty(saveJSON$1, "__esModule", {
  303. value: true
  304. });
  305. saveJSON$1.default = saveJSON;
  306. var _fs$2 = fs;
  307. function saveJSON(cssFile, json) {
  308. return new Promise((resolve, reject) => {
  309. const {
  310. writeFile
  311. } = (0, _fs$2.getFileSystem)();
  312. writeFile(`${cssFile}.json`, JSON.stringify(json), e => e ? reject(e) : resolve(json));
  313. });
  314. }
  315. var localsConvention = {};
  316. /**
  317. * lodash (Custom Build) <https://lodash.com/>
  318. * Build: `lodash modularize exports="npm" -o ./`
  319. * Copyright jQuery Foundation and other contributors <https://jquery.org/>
  320. * Released under MIT license <https://lodash.com/license>
  321. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  322. * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  323. */
  324. /** Used as references for various `Number` constants. */
  325. var INFINITY = 1 / 0;
  326. /** `Object#toString` result references. */
  327. var symbolTag = '[object Symbol]';
  328. /** Used to match words composed of alphanumeric characters. */
  329. var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
  330. /** Used to match Latin Unicode letters (excluding mathematical operators). */
  331. var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g;
  332. /** Used to compose unicode character classes. */
  333. var rsAstralRange = '\\ud800-\\udfff',
  334. rsComboMarksRange = '\\u0300-\\u036f\\ufe20-\\ufe23',
  335. rsComboSymbolsRange = '\\u20d0-\\u20f0',
  336. rsDingbatRange = '\\u2700-\\u27bf',
  337. rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff',
  338. rsMathOpRange = '\\xac\\xb1\\xd7\\xf7',
  339. rsNonCharRange = '\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf',
  340. rsPunctuationRange = '\\u2000-\\u206f',
  341. rsSpaceRange = ' \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000',
  342. rsUpperRange = 'A-Z\\xc0-\\xd6\\xd8-\\xde',
  343. rsVarRange = '\\ufe0e\\ufe0f',
  344. rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange;
  345. /** Used to compose unicode capture groups. */
  346. var rsApos = "['\u2019]",
  347. rsAstral = '[' + rsAstralRange + ']',
  348. rsBreak = '[' + rsBreakRange + ']',
  349. rsCombo = '[' + rsComboMarksRange + rsComboSymbolsRange + ']',
  350. rsDigits = '\\d+',
  351. rsDingbat = '[' + rsDingbatRange + ']',
  352. rsLower = '[' + rsLowerRange + ']',
  353. rsMisc = '[^' + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + ']',
  354. rsFitz = '\\ud83c[\\udffb-\\udfff]',
  355. rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')',
  356. rsNonAstral = '[^' + rsAstralRange + ']',
  357. rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}',
  358. rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]',
  359. rsUpper = '[' + rsUpperRange + ']',
  360. rsZWJ = '\\u200d';
  361. /** Used to compose unicode regexes. */
  362. var rsLowerMisc = '(?:' + rsLower + '|' + rsMisc + ')',
  363. rsUpperMisc = '(?:' + rsUpper + '|' + rsMisc + ')',
  364. rsOptLowerContr = '(?:' + rsApos + '(?:d|ll|m|re|s|t|ve))?',
  365. rsOptUpperContr = '(?:' + rsApos + '(?:D|LL|M|RE|S|T|VE))?',
  366. reOptMod = rsModifier + '?',
  367. rsOptVar = '[' + rsVarRange + ']?',
  368. rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',
  369. rsSeq = rsOptVar + reOptMod + rsOptJoin,
  370. rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq,
  371. rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')';
  372. /** Used to match apostrophes. */
  373. var reApos = RegExp(rsApos, 'g');
  374. /**
  375. * Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and
  376. * [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols).
  377. */
  378. var reComboMark = RegExp(rsCombo, 'g');
  379. /** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
  380. var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g');
  381. /** Used to match complex or compound words. */
  382. var reUnicodeWord = RegExp([
  383. rsUpper + '?' + rsLower + '+' + rsOptLowerContr + '(?=' + [rsBreak, rsUpper, '$'].join('|') + ')',
  384. rsUpperMisc + '+' + rsOptUpperContr + '(?=' + [rsBreak, rsUpper + rsLowerMisc, '$'].join('|') + ')',
  385. rsUpper + '?' + rsLowerMisc + '+' + rsOptLowerContr,
  386. rsUpper + '+' + rsOptUpperContr,
  387. rsDigits,
  388. rsEmoji
  389. ].join('|'), 'g');
  390. /** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */
  391. var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboMarksRange + rsComboSymbolsRange + rsVarRange + ']');
  392. /** Used to detect strings that need a more robust regexp to match words. */
  393. var reHasUnicodeWord = /[a-z][A-Z]|[A-Z]{2,}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;
  394. /** Used to map Latin Unicode letters to basic Latin letters. */
  395. var deburredLetters = {
  396. // Latin-1 Supplement block.
  397. '\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A',
  398. '\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a',
  399. '\xc7': 'C', '\xe7': 'c',
  400. '\xd0': 'D', '\xf0': 'd',
  401. '\xc8': 'E', '\xc9': 'E', '\xca': 'E', '\xcb': 'E',
  402. '\xe8': 'e', '\xe9': 'e', '\xea': 'e', '\xeb': 'e',
  403. '\xcc': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I',
  404. '\xec': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i',
  405. '\xd1': 'N', '\xf1': 'n',
  406. '\xd2': 'O', '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O',
  407. '\xf2': 'o', '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o',
  408. '\xd9': 'U', '\xda': 'U', '\xdb': 'U', '\xdc': 'U',
  409. '\xf9': 'u', '\xfa': 'u', '\xfb': 'u', '\xfc': 'u',
  410. '\xdd': 'Y', '\xfd': 'y', '\xff': 'y',
  411. '\xc6': 'Ae', '\xe6': 'ae',
  412. '\xde': 'Th', '\xfe': 'th',
  413. '\xdf': 'ss',
  414. // Latin Extended-A block.
  415. '\u0100': 'A', '\u0102': 'A', '\u0104': 'A',
  416. '\u0101': 'a', '\u0103': 'a', '\u0105': 'a',
  417. '\u0106': 'C', '\u0108': 'C', '\u010a': 'C', '\u010c': 'C',
  418. '\u0107': 'c', '\u0109': 'c', '\u010b': 'c', '\u010d': 'c',
  419. '\u010e': 'D', '\u0110': 'D', '\u010f': 'd', '\u0111': 'd',
  420. '\u0112': 'E', '\u0114': 'E', '\u0116': 'E', '\u0118': 'E', '\u011a': 'E',
  421. '\u0113': 'e', '\u0115': 'e', '\u0117': 'e', '\u0119': 'e', '\u011b': 'e',
  422. '\u011c': 'G', '\u011e': 'G', '\u0120': 'G', '\u0122': 'G',
  423. '\u011d': 'g', '\u011f': 'g', '\u0121': 'g', '\u0123': 'g',
  424. '\u0124': 'H', '\u0126': 'H', '\u0125': 'h', '\u0127': 'h',
  425. '\u0128': 'I', '\u012a': 'I', '\u012c': 'I', '\u012e': 'I', '\u0130': 'I',
  426. '\u0129': 'i', '\u012b': 'i', '\u012d': 'i', '\u012f': 'i', '\u0131': 'i',
  427. '\u0134': 'J', '\u0135': 'j',
  428. '\u0136': 'K', '\u0137': 'k', '\u0138': 'k',
  429. '\u0139': 'L', '\u013b': 'L', '\u013d': 'L', '\u013f': 'L', '\u0141': 'L',
  430. '\u013a': 'l', '\u013c': 'l', '\u013e': 'l', '\u0140': 'l', '\u0142': 'l',
  431. '\u0143': 'N', '\u0145': 'N', '\u0147': 'N', '\u014a': 'N',
  432. '\u0144': 'n', '\u0146': 'n', '\u0148': 'n', '\u014b': 'n',
  433. '\u014c': 'O', '\u014e': 'O', '\u0150': 'O',
  434. '\u014d': 'o', '\u014f': 'o', '\u0151': 'o',
  435. '\u0154': 'R', '\u0156': 'R', '\u0158': 'R',
  436. '\u0155': 'r', '\u0157': 'r', '\u0159': 'r',
  437. '\u015a': 'S', '\u015c': 'S', '\u015e': 'S', '\u0160': 'S',
  438. '\u015b': 's', '\u015d': 's', '\u015f': 's', '\u0161': 's',
  439. '\u0162': 'T', '\u0164': 'T', '\u0166': 'T',
  440. '\u0163': 't', '\u0165': 't', '\u0167': 't',
  441. '\u0168': 'U', '\u016a': 'U', '\u016c': 'U', '\u016e': 'U', '\u0170': 'U', '\u0172': 'U',
  442. '\u0169': 'u', '\u016b': 'u', '\u016d': 'u', '\u016f': 'u', '\u0171': 'u', '\u0173': 'u',
  443. '\u0174': 'W', '\u0175': 'w',
  444. '\u0176': 'Y', '\u0177': 'y', '\u0178': 'Y',
  445. '\u0179': 'Z', '\u017b': 'Z', '\u017d': 'Z',
  446. '\u017a': 'z', '\u017c': 'z', '\u017e': 'z',
  447. '\u0132': 'IJ', '\u0133': 'ij',
  448. '\u0152': 'Oe', '\u0153': 'oe',
  449. '\u0149': "'n", '\u017f': 'ss'
  450. };
  451. /** Detect free variable `global` from Node.js. */
  452. var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
  453. /** Detect free variable `self`. */
  454. var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
  455. /** Used as a reference to the global object. */
  456. var root$2 = freeGlobal || freeSelf || Function('return this')();
  457. /**
  458. * A specialized version of `_.reduce` for arrays without support for
  459. * iteratee shorthands.
  460. *
  461. * @private
  462. * @param {Array} [array] The array to iterate over.
  463. * @param {Function} iteratee The function invoked per iteration.
  464. * @param {*} [accumulator] The initial value.
  465. * @param {boolean} [initAccum] Specify using the first element of `array` as
  466. * the initial value.
  467. * @returns {*} Returns the accumulated value.
  468. */
  469. function arrayReduce(array, iteratee, accumulator, initAccum) {
  470. var index = -1,
  471. length = array ? array.length : 0;
  472. if (initAccum && length) {
  473. accumulator = array[++index];
  474. }
  475. while (++index < length) {
  476. accumulator = iteratee(accumulator, array[index], index, array);
  477. }
  478. return accumulator;
  479. }
  480. /**
  481. * Converts an ASCII `string` to an array.
  482. *
  483. * @private
  484. * @param {string} string The string to convert.
  485. * @returns {Array} Returns the converted array.
  486. */
  487. function asciiToArray(string) {
  488. return string.split('');
  489. }
  490. /**
  491. * Splits an ASCII `string` into an array of its words.
  492. *
  493. * @private
  494. * @param {string} The string to inspect.
  495. * @returns {Array} Returns the words of `string`.
  496. */
  497. function asciiWords(string) {
  498. return string.match(reAsciiWord) || [];
  499. }
  500. /**
  501. * The base implementation of `_.propertyOf` without support for deep paths.
  502. *
  503. * @private
  504. * @param {Object} object The object to query.
  505. * @returns {Function} Returns the new accessor function.
  506. */
  507. function basePropertyOf(object) {
  508. return function(key) {
  509. return object == null ? undefined : object[key];
  510. };
  511. }
  512. /**
  513. * Used by `_.deburr` to convert Latin-1 Supplement and Latin Extended-A
  514. * letters to basic Latin letters.
  515. *
  516. * @private
  517. * @param {string} letter The matched letter to deburr.
  518. * @returns {string} Returns the deburred letter.
  519. */
  520. var deburrLetter = basePropertyOf(deburredLetters);
  521. /**
  522. * Checks if `string` contains Unicode symbols.
  523. *
  524. * @private
  525. * @param {string} string The string to inspect.
  526. * @returns {boolean} Returns `true` if a symbol is found, else `false`.
  527. */
  528. function hasUnicode(string) {
  529. return reHasUnicode.test(string);
  530. }
  531. /**
  532. * Checks if `string` contains a word composed of Unicode symbols.
  533. *
  534. * @private
  535. * @param {string} string The string to inspect.
  536. * @returns {boolean} Returns `true` if a word is found, else `false`.
  537. */
  538. function hasUnicodeWord(string) {
  539. return reHasUnicodeWord.test(string);
  540. }
  541. /**
  542. * Converts `string` to an array.
  543. *
  544. * @private
  545. * @param {string} string The string to convert.
  546. * @returns {Array} Returns the converted array.
  547. */
  548. function stringToArray(string) {
  549. return hasUnicode(string)
  550. ? unicodeToArray(string)
  551. : asciiToArray(string);
  552. }
  553. /**
  554. * Converts a Unicode `string` to an array.
  555. *
  556. * @private
  557. * @param {string} string The string to convert.
  558. * @returns {Array} Returns the converted array.
  559. */
  560. function unicodeToArray(string) {
  561. return string.match(reUnicode) || [];
  562. }
  563. /**
  564. * Splits a Unicode `string` into an array of its words.
  565. *
  566. * @private
  567. * @param {string} The string to inspect.
  568. * @returns {Array} Returns the words of `string`.
  569. */
  570. function unicodeWords(string) {
  571. return string.match(reUnicodeWord) || [];
  572. }
  573. /** Used for built-in method references. */
  574. var objectProto = Object.prototype;
  575. /**
  576. * Used to resolve the
  577. * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
  578. * of values.
  579. */
  580. var objectToString = objectProto.toString;
  581. /** Built-in value references. */
  582. var Symbol$1 = root$2.Symbol;
  583. /** Used to convert symbols to primitives and strings. */
  584. var symbolProto = Symbol$1 ? Symbol$1.prototype : undefined,
  585. symbolToString = symbolProto ? symbolProto.toString : undefined;
  586. /**
  587. * The base implementation of `_.slice` without an iteratee call guard.
  588. *
  589. * @private
  590. * @param {Array} array The array to slice.
  591. * @param {number} [start=0] The start position.
  592. * @param {number} [end=array.length] The end position.
  593. * @returns {Array} Returns the slice of `array`.
  594. */
  595. function baseSlice(array, start, end) {
  596. var index = -1,
  597. length = array.length;
  598. if (start < 0) {
  599. start = -start > length ? 0 : (length + start);
  600. }
  601. end = end > length ? length : end;
  602. if (end < 0) {
  603. end += length;
  604. }
  605. length = start > end ? 0 : ((end - start) >>> 0);
  606. start >>>= 0;
  607. var result = Array(length);
  608. while (++index < length) {
  609. result[index] = array[index + start];
  610. }
  611. return result;
  612. }
  613. /**
  614. * The base implementation of `_.toString` which doesn't convert nullish
  615. * values to empty strings.
  616. *
  617. * @private
  618. * @param {*} value The value to process.
  619. * @returns {string} Returns the string.
  620. */
  621. function baseToString(value) {
  622. // Exit early for strings to avoid a performance hit in some environments.
  623. if (typeof value == 'string') {
  624. return value;
  625. }
  626. if (isSymbol(value)) {
  627. return symbolToString ? symbolToString.call(value) : '';
  628. }
  629. var result = (value + '');
  630. return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
  631. }
  632. /**
  633. * Casts `array` to a slice if it's needed.
  634. *
  635. * @private
  636. * @param {Array} array The array to inspect.
  637. * @param {number} start The start position.
  638. * @param {number} [end=array.length] The end position.
  639. * @returns {Array} Returns the cast slice.
  640. */
  641. function castSlice(array, start, end) {
  642. var length = array.length;
  643. end = end === undefined ? length : end;
  644. return (!start && end >= length) ? array : baseSlice(array, start, end);
  645. }
  646. /**
  647. * Creates a function like `_.lowerFirst`.
  648. *
  649. * @private
  650. * @param {string} methodName The name of the `String` case method to use.
  651. * @returns {Function} Returns the new case function.
  652. */
  653. function createCaseFirst(methodName) {
  654. return function(string) {
  655. string = toString(string);
  656. var strSymbols = hasUnicode(string)
  657. ? stringToArray(string)
  658. : undefined;
  659. var chr = strSymbols
  660. ? strSymbols[0]
  661. : string.charAt(0);
  662. var trailing = strSymbols
  663. ? castSlice(strSymbols, 1).join('')
  664. : string.slice(1);
  665. return chr[methodName]() + trailing;
  666. };
  667. }
  668. /**
  669. * Creates a function like `_.camelCase`.
  670. *
  671. * @private
  672. * @param {Function} callback The function to combine each word.
  673. * @returns {Function} Returns the new compounder function.
  674. */
  675. function createCompounder(callback) {
  676. return function(string) {
  677. return arrayReduce(words(deburr(string).replace(reApos, '')), callback, '');
  678. };
  679. }
  680. /**
  681. * Checks if `value` is object-like. A value is object-like if it's not `null`
  682. * and has a `typeof` result of "object".
  683. *
  684. * @static
  685. * @memberOf _
  686. * @since 4.0.0
  687. * @category Lang
  688. * @param {*} value The value to check.
  689. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  690. * @example
  691. *
  692. * _.isObjectLike({});
  693. * // => true
  694. *
  695. * _.isObjectLike([1, 2, 3]);
  696. * // => true
  697. *
  698. * _.isObjectLike(_.noop);
  699. * // => false
  700. *
  701. * _.isObjectLike(null);
  702. * // => false
  703. */
  704. function isObjectLike(value) {
  705. return !!value && typeof value == 'object';
  706. }
  707. /**
  708. * Checks if `value` is classified as a `Symbol` primitive or object.
  709. *
  710. * @static
  711. * @memberOf _
  712. * @since 4.0.0
  713. * @category Lang
  714. * @param {*} value The value to check.
  715. * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
  716. * @example
  717. *
  718. * _.isSymbol(Symbol.iterator);
  719. * // => true
  720. *
  721. * _.isSymbol('abc');
  722. * // => false
  723. */
  724. function isSymbol(value) {
  725. return typeof value == 'symbol' ||
  726. (isObjectLike(value) && objectToString.call(value) == symbolTag);
  727. }
  728. /**
  729. * Converts `value` to a string. An empty string is returned for `null`
  730. * and `undefined` values. The sign of `-0` is preserved.
  731. *
  732. * @static
  733. * @memberOf _
  734. * @since 4.0.0
  735. * @category Lang
  736. * @param {*} value The value to process.
  737. * @returns {string} Returns the string.
  738. * @example
  739. *
  740. * _.toString(null);
  741. * // => ''
  742. *
  743. * _.toString(-0);
  744. * // => '-0'
  745. *
  746. * _.toString([1, 2, 3]);
  747. * // => '1,2,3'
  748. */
  749. function toString(value) {
  750. return value == null ? '' : baseToString(value);
  751. }
  752. /**
  753. * Converts `string` to [camel case](https://en.wikipedia.org/wiki/CamelCase).
  754. *
  755. * @static
  756. * @memberOf _
  757. * @since 3.0.0
  758. * @category String
  759. * @param {string} [string=''] The string to convert.
  760. * @returns {string} Returns the camel cased string.
  761. * @example
  762. *
  763. * _.camelCase('Foo Bar');
  764. * // => 'fooBar'
  765. *
  766. * _.camelCase('--foo-bar--');
  767. * // => 'fooBar'
  768. *
  769. * _.camelCase('__FOO_BAR__');
  770. * // => 'fooBar'
  771. */
  772. var camelCase = createCompounder(function(result, word, index) {
  773. word = word.toLowerCase();
  774. return result + (index ? capitalize(word) : word);
  775. });
  776. /**
  777. * Converts the first character of `string` to upper case and the remaining
  778. * to lower case.
  779. *
  780. * @static
  781. * @memberOf _
  782. * @since 3.0.0
  783. * @category String
  784. * @param {string} [string=''] The string to capitalize.
  785. * @returns {string} Returns the capitalized string.
  786. * @example
  787. *
  788. * _.capitalize('FRED');
  789. * // => 'Fred'
  790. */
  791. function capitalize(string) {
  792. return upperFirst(toString(string).toLowerCase());
  793. }
  794. /**
  795. * Deburrs `string` by converting
  796. * [Latin-1 Supplement](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table)
  797. * and [Latin Extended-A](https://en.wikipedia.org/wiki/Latin_Extended-A)
  798. * letters to basic Latin letters and removing
  799. * [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks).
  800. *
  801. * @static
  802. * @memberOf _
  803. * @since 3.0.0
  804. * @category String
  805. * @param {string} [string=''] The string to deburr.
  806. * @returns {string} Returns the deburred string.
  807. * @example
  808. *
  809. * _.deburr('déjà vu');
  810. * // => 'deja vu'
  811. */
  812. function deburr(string) {
  813. string = toString(string);
  814. return string && string.replace(reLatin, deburrLetter).replace(reComboMark, '');
  815. }
  816. /**
  817. * Converts the first character of `string` to upper case.
  818. *
  819. * @static
  820. * @memberOf _
  821. * @since 4.0.0
  822. * @category String
  823. * @param {string} [string=''] The string to convert.
  824. * @returns {string} Returns the converted string.
  825. * @example
  826. *
  827. * _.upperFirst('fred');
  828. * // => 'Fred'
  829. *
  830. * _.upperFirst('FRED');
  831. * // => 'FRED'
  832. */
  833. var upperFirst = createCaseFirst('toUpperCase');
  834. /**
  835. * Splits `string` into an array of its words.
  836. *
  837. * @static
  838. * @memberOf _
  839. * @since 3.0.0
  840. * @category String
  841. * @param {string} [string=''] The string to inspect.
  842. * @param {RegExp|string} [pattern] The pattern to match words.
  843. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  844. * @returns {Array} Returns the words of `string`.
  845. * @example
  846. *
  847. * _.words('fred, barney, & pebbles');
  848. * // => ['fred', 'barney', 'pebbles']
  849. *
  850. * _.words('fred, barney, & pebbles', /[^, ]+/g);
  851. * // => ['fred', 'barney', '&', 'pebbles']
  852. */
  853. function words(string, pattern, guard) {
  854. string = toString(string);
  855. pattern = guard ? undefined : pattern;
  856. if (pattern === undefined) {
  857. return hasUnicodeWord(string) ? unicodeWords(string) : asciiWords(string);
  858. }
  859. return string.match(pattern) || [];
  860. }
  861. var lodash_camelcase = camelCase;
  862. Object.defineProperty(localsConvention, "__esModule", {
  863. value: true
  864. });
  865. localsConvention.makeLocalsConventionReducer = makeLocalsConventionReducer;
  866. var _lodash = _interopRequireDefault$5(lodash_camelcase);
  867. function _interopRequireDefault$5(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  868. function dashesCamelCase(string) {
  869. return string.replace(/-+(\w)/g, (_, firstLetter) => firstLetter.toUpperCase());
  870. }
  871. function makeLocalsConventionReducer(localsConvention, inputFile) {
  872. const isFunc = typeof localsConvention === "function";
  873. return (tokens, [className, value]) => {
  874. if (isFunc) {
  875. const convention = localsConvention(className, value, inputFile);
  876. tokens[convention] = value;
  877. return tokens;
  878. }
  879. switch (localsConvention) {
  880. case "camelCase":
  881. tokens[className] = value;
  882. tokens[(0, _lodash.default)(className)] = value;
  883. break;
  884. case "camelCaseOnly":
  885. tokens[(0, _lodash.default)(className)] = value;
  886. break;
  887. case "dashes":
  888. tokens[className] = value;
  889. tokens[dashesCamelCase(className)] = value;
  890. break;
  891. case "dashesOnly":
  892. tokens[dashesCamelCase(className)] = value;
  893. break;
  894. }
  895. return tokens;
  896. };
  897. }
  898. var FileSystemLoader$1 = {};
  899. Object.defineProperty(FileSystemLoader$1, "__esModule", {
  900. value: true
  901. });
  902. FileSystemLoader$1.default = void 0;
  903. var _postcss$1 = _interopRequireDefault$4(require$$0);
  904. var _path = _interopRequireDefault$4(require$$0$1);
  905. var _Parser$1 = _interopRequireDefault$4(Parser$1);
  906. var _fs$1 = fs;
  907. function _interopRequireDefault$4(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  908. // Initially copied from https://github.com/css-modules/css-modules-loader-core
  909. class Core {
  910. constructor(plugins) {
  911. this.plugins = plugins || Core.defaultPlugins;
  912. }
  913. async load(sourceString, sourcePath, trace, pathFetcher) {
  914. const parser = new _Parser$1.default(pathFetcher, trace);
  915. const plugins = this.plugins.concat([parser.plugin()]);
  916. const result = await (0, _postcss$1.default)(plugins).process(sourceString, {
  917. from: sourcePath
  918. });
  919. return {
  920. injectableSource: result.css,
  921. exportTokens: parser.exportTokens
  922. };
  923. }
  924. } // Sorts dependencies in the following way:
  925. // AAA comes before AA and A
  926. // AB comes after AA and before A
  927. // All Bs come after all As
  928. // This ensures that the files are always returned in the following order:
  929. // - In the order they were required, except
  930. // - After all their dependencies
  931. const traceKeySorter = (a, b) => {
  932. if (a.length < b.length) {
  933. return a < b.substring(0, a.length) ? -1 : 1;
  934. }
  935. if (a.length > b.length) {
  936. return a.substring(0, b.length) <= b ? -1 : 1;
  937. }
  938. return a < b ? -1 : 1;
  939. };
  940. class FileSystemLoader {
  941. constructor(root, plugins, fileResolve) {
  942. if (root === "/" && process.platform === "win32") {
  943. const cwdDrive = process.cwd().slice(0, 3);
  944. if (!/^[A-Za-z]:\\$/.test(cwdDrive)) {
  945. throw new Error(`Failed to obtain root from "${process.cwd()}".`);
  946. }
  947. root = cwdDrive;
  948. }
  949. this.root = root;
  950. this.fileResolve = fileResolve;
  951. this.sources = {};
  952. this.traces = {};
  953. this.importNr = 0;
  954. this.core = new Core(plugins);
  955. this.tokensByFile = {};
  956. this.fs = (0, _fs$1.getFileSystem)();
  957. }
  958. async fetch(_newPath, relativeTo, _trace) {
  959. const newPath = _newPath.replace(/^["']|["']$/g, "");
  960. const trace = _trace || String.fromCharCode(this.importNr++);
  961. const useFileResolve = typeof this.fileResolve === "function";
  962. const fileResolvedPath = useFileResolve ? await this.fileResolve(newPath, relativeTo) : await Promise.resolve();
  963. if (fileResolvedPath && !_path.default.isAbsolute(fileResolvedPath)) {
  964. throw new Error('The returned path from the "fileResolve" option must be absolute.');
  965. }
  966. const relativeDir = _path.default.dirname(relativeTo);
  967. const rootRelativePath = fileResolvedPath || _path.default.resolve(relativeDir, newPath);
  968. let fileRelativePath = fileResolvedPath || _path.default.resolve(_path.default.resolve(this.root, relativeDir), newPath); // if the path is not relative or absolute, try to resolve it in node_modules
  969. if (!useFileResolve && newPath[0] !== "." && !_path.default.isAbsolute(newPath)) {
  970. try {
  971. fileRelativePath = require.resolve(newPath);
  972. } catch (e) {// noop
  973. }
  974. }
  975. const tokens = this.tokensByFile[fileRelativePath];
  976. if (tokens) return tokens;
  977. return new Promise((resolve, reject) => {
  978. this.fs.readFile(fileRelativePath, "utf-8", async (err, source) => {
  979. if (err) reject(err);
  980. const {
  981. injectableSource,
  982. exportTokens
  983. } = await this.core.load(source, rootRelativePath, trace, this.fetch.bind(this));
  984. this.sources[fileRelativePath] = injectableSource;
  985. this.traces[trace] = fileRelativePath;
  986. this.tokensByFile[fileRelativePath] = exportTokens;
  987. resolve(exportTokens);
  988. });
  989. });
  990. }
  991. get finalSource() {
  992. const traces = this.traces;
  993. const sources = this.sources;
  994. let written = new Set();
  995. return Object.keys(traces).sort(traceKeySorter).map(key => {
  996. const filename = traces[key];
  997. if (written.has(filename)) {
  998. return null;
  999. }
  1000. written.add(filename);
  1001. return sources[filename];
  1002. }).join("");
  1003. }
  1004. }
  1005. FileSystemLoader$1.default = FileSystemLoader;
  1006. var scoping = {};
  1007. var src$3 = {exports: {}};
  1008. const PERMANENT_MARKER = 2;
  1009. const TEMPORARY_MARKER = 1;
  1010. function createError(node, graph) {
  1011. const er = new Error("Nondeterministic import's order");
  1012. const related = graph[node];
  1013. const relatedNode = related.find(
  1014. (relatedNode) => graph[relatedNode].indexOf(node) > -1
  1015. );
  1016. er.nodes = [node, relatedNode];
  1017. return er;
  1018. }
  1019. function walkGraph(node, graph, state, result, strict) {
  1020. if (state[node] === PERMANENT_MARKER) {
  1021. return;
  1022. }
  1023. if (state[node] === TEMPORARY_MARKER) {
  1024. if (strict) {
  1025. return createError(node, graph);
  1026. }
  1027. return;
  1028. }
  1029. state[node] = TEMPORARY_MARKER;
  1030. const children = graph[node];
  1031. const length = children.length;
  1032. for (let i = 0; i < length; ++i) {
  1033. const error = walkGraph(children[i], graph, state, result, strict);
  1034. if (error instanceof Error) {
  1035. return error;
  1036. }
  1037. }
  1038. state[node] = PERMANENT_MARKER;
  1039. result.push(node);
  1040. }
  1041. function topologicalSort$1(graph, strict) {
  1042. const result = [];
  1043. const state = {};
  1044. const nodes = Object.keys(graph);
  1045. const length = nodes.length;
  1046. for (let i = 0; i < length; ++i) {
  1047. const er = walkGraph(nodes[i], graph, state, result, strict);
  1048. if (er instanceof Error) {
  1049. return er;
  1050. }
  1051. }
  1052. return result;
  1053. }
  1054. var topologicalSort_1 = topologicalSort$1;
  1055. const topologicalSort = topologicalSort_1;
  1056. const matchImports$1 = /^(.+?)\s+from\s+(?:"([^"]+)"|'([^']+)'|(global))$/;
  1057. const icssImport = /^:import\((?:"([^"]+)"|'([^']+)')\)/;
  1058. const VISITED_MARKER = 1;
  1059. /**
  1060. * :import('G') {}
  1061. *
  1062. * Rule
  1063. * composes: ... from 'A'
  1064. * composes: ... from 'B'
  1065. * Rule
  1066. * composes: ... from 'A'
  1067. * composes: ... from 'A'
  1068. * composes: ... from 'C'
  1069. *
  1070. * Results in:
  1071. *
  1072. * graph: {
  1073. * G: [],
  1074. * A: [],
  1075. * B: ['A'],
  1076. * C: ['A'],
  1077. * }
  1078. */
  1079. function addImportToGraph(importId, parentId, graph, visited) {
  1080. const siblingsId = parentId + "_" + "siblings";
  1081. const visitedId = parentId + "_" + importId;
  1082. if (visited[visitedId] !== VISITED_MARKER) {
  1083. if (!Array.isArray(visited[siblingsId])) {
  1084. visited[siblingsId] = [];
  1085. }
  1086. const siblings = visited[siblingsId];
  1087. if (Array.isArray(graph[importId])) {
  1088. graph[importId] = graph[importId].concat(siblings);
  1089. } else {
  1090. graph[importId] = siblings.slice();
  1091. }
  1092. visited[visitedId] = VISITED_MARKER;
  1093. siblings.push(importId);
  1094. }
  1095. }
  1096. src$3.exports = (options = {}) => {
  1097. let importIndex = 0;
  1098. const createImportedName =
  1099. typeof options.createImportedName !== "function"
  1100. ? (importName /*, path*/) =>
  1101. `i__imported_${importName.replace(/\W/g, "_")}_${importIndex++}`
  1102. : options.createImportedName;
  1103. const failOnWrongOrder = options.failOnWrongOrder;
  1104. return {
  1105. postcssPlugin: "postcss-modules-extract-imports",
  1106. prepare() {
  1107. const graph = {};
  1108. const visited = {};
  1109. const existingImports = {};
  1110. const importDecls = {};
  1111. const imports = {};
  1112. return {
  1113. Once(root, postcss) {
  1114. // Check the existing imports order and save refs
  1115. root.walkRules((rule) => {
  1116. const matches = icssImport.exec(rule.selector);
  1117. if (matches) {
  1118. const [, /*match*/ doubleQuotePath, singleQuotePath] = matches;
  1119. const importPath = doubleQuotePath || singleQuotePath;
  1120. addImportToGraph(importPath, "root", graph, visited);
  1121. existingImports[importPath] = rule;
  1122. }
  1123. });
  1124. root.walkDecls(/^composes$/, (declaration) => {
  1125. const matches = declaration.value.match(matchImports$1);
  1126. if (!matches) {
  1127. return;
  1128. }
  1129. let tmpSymbols;
  1130. let [
  1131. ,
  1132. /*match*/ symbols,
  1133. doubleQuotePath,
  1134. singleQuotePath,
  1135. global,
  1136. ] = matches;
  1137. if (global) {
  1138. // Composing globals simply means changing these classes to wrap them in global(name)
  1139. tmpSymbols = symbols.split(/\s+/).map((s) => `global(${s})`);
  1140. } else {
  1141. const importPath = doubleQuotePath || singleQuotePath;
  1142. let parent = declaration.parent;
  1143. let parentIndexes = "";
  1144. while (parent.type !== "root") {
  1145. parentIndexes =
  1146. parent.parent.index(parent) + "_" + parentIndexes;
  1147. parent = parent.parent;
  1148. }
  1149. const { selector } = declaration.parent;
  1150. const parentRule = `_${parentIndexes}${selector}`;
  1151. addImportToGraph(importPath, parentRule, graph, visited);
  1152. importDecls[importPath] = declaration;
  1153. imports[importPath] = imports[importPath] || {};
  1154. tmpSymbols = symbols.split(/\s+/).map((s) => {
  1155. if (!imports[importPath][s]) {
  1156. imports[importPath][s] = createImportedName(s, importPath);
  1157. }
  1158. return imports[importPath][s];
  1159. });
  1160. }
  1161. declaration.value = tmpSymbols.join(" ");
  1162. });
  1163. const importsOrder = topologicalSort(graph, failOnWrongOrder);
  1164. if (importsOrder instanceof Error) {
  1165. const importPath = importsOrder.nodes.find((importPath) =>
  1166. // eslint-disable-next-line no-prototype-builtins
  1167. importDecls.hasOwnProperty(importPath)
  1168. );
  1169. const decl = importDecls[importPath];
  1170. throw decl.error(
  1171. "Failed to resolve order of composed modules " +
  1172. importsOrder.nodes
  1173. .map((importPath) => "`" + importPath + "`")
  1174. .join(", ") +
  1175. ".",
  1176. {
  1177. plugin: "postcss-modules-extract-imports",
  1178. word: "composes",
  1179. }
  1180. );
  1181. }
  1182. let lastImportRule;
  1183. importsOrder.forEach((path) => {
  1184. const importedSymbols = imports[path];
  1185. let rule = existingImports[path];
  1186. if (!rule && importedSymbols) {
  1187. rule = postcss.rule({
  1188. selector: `:import("${path}")`,
  1189. raws: { after: "\n" },
  1190. });
  1191. if (lastImportRule) {
  1192. root.insertAfter(lastImportRule, rule);
  1193. } else {
  1194. root.prepend(rule);
  1195. }
  1196. }
  1197. lastImportRule = rule;
  1198. if (!importedSymbols) {
  1199. return;
  1200. }
  1201. Object.keys(importedSymbols).forEach((importedSymbol) => {
  1202. rule.append(
  1203. postcss.decl({
  1204. value: importedSymbol,
  1205. prop: importedSymbols[importedSymbol],
  1206. raws: { before: "\n " },
  1207. })
  1208. );
  1209. });
  1210. });
  1211. },
  1212. };
  1213. },
  1214. };
  1215. };
  1216. src$3.exports.postcss = true;
  1217. var wasmHash = {exports: {}};
  1218. /*
  1219. MIT License http://www.opensource.org/licenses/mit-license.php
  1220. Author Tobias Koppers @sokra
  1221. */
  1222. var hasRequiredWasmHash;
  1223. function requireWasmHash () {
  1224. if (hasRequiredWasmHash) return wasmHash.exports;
  1225. hasRequiredWasmHash = 1;
  1226. // 65536 is the size of a wasm memory page
  1227. // 64 is the maximum chunk size for every possible wasm hash implementation
  1228. // 4 is the maximum number of bytes per char for string encoding (max is utf-8)
  1229. // ~3 makes sure that it's always a block of 4 chars, so avoid partially encoded bytes for base64
  1230. const MAX_SHORT_STRING = Math.floor((65536 - 64) / 4) & ~3;
  1231. class WasmHash {
  1232. /**
  1233. * @param {WebAssembly.Instance} instance wasm instance
  1234. * @param {WebAssembly.Instance[]} instancesPool pool of instances
  1235. * @param {number} chunkSize size of data chunks passed to wasm
  1236. * @param {number} digestSize size of digest returned by wasm
  1237. */
  1238. constructor(instance, instancesPool, chunkSize, digestSize) {
  1239. const exports = /** @type {any} */ (instance.exports);
  1240. exports.init();
  1241. this.exports = exports;
  1242. this.mem = Buffer.from(exports.memory.buffer, 0, 65536);
  1243. this.buffered = 0;
  1244. this.instancesPool = instancesPool;
  1245. this.chunkSize = chunkSize;
  1246. this.digestSize = digestSize;
  1247. }
  1248. reset() {
  1249. this.buffered = 0;
  1250. this.exports.init();
  1251. }
  1252. /**
  1253. * @param {Buffer | string} data data
  1254. * @param {BufferEncoding=} encoding encoding
  1255. * @returns {this} itself
  1256. */
  1257. update(data, encoding) {
  1258. if (typeof data === "string") {
  1259. while (data.length > MAX_SHORT_STRING) {
  1260. this._updateWithShortString(data.slice(0, MAX_SHORT_STRING), encoding);
  1261. data = data.slice(MAX_SHORT_STRING);
  1262. }
  1263. this._updateWithShortString(data, encoding);
  1264. return this;
  1265. }
  1266. this._updateWithBuffer(data);
  1267. return this;
  1268. }
  1269. /**
  1270. * @param {string} data data
  1271. * @param {BufferEncoding=} encoding encoding
  1272. * @returns {void}
  1273. */
  1274. _updateWithShortString(data, encoding) {
  1275. const { exports, buffered, mem, chunkSize } = this;
  1276. let endPos;
  1277. if (data.length < 70) {
  1278. if (!encoding || encoding === "utf-8" || encoding === "utf8") {
  1279. endPos = buffered;
  1280. for (let i = 0; i < data.length; i++) {
  1281. const cc = data.charCodeAt(i);
  1282. if (cc < 0x80) {
  1283. mem[endPos++] = cc;
  1284. } else if (cc < 0x800) {
  1285. mem[endPos] = (cc >> 6) | 0xc0;
  1286. mem[endPos + 1] = (cc & 0x3f) | 0x80;
  1287. endPos += 2;
  1288. } else {
  1289. // bail-out for weird chars
  1290. endPos += mem.write(data.slice(i), endPos, encoding);
  1291. break;
  1292. }
  1293. }
  1294. } else if (encoding === "latin1") {
  1295. endPos = buffered;
  1296. for (let i = 0; i < data.length; i++) {
  1297. const cc = data.charCodeAt(i);
  1298. mem[endPos++] = cc;
  1299. }
  1300. } else {
  1301. endPos = buffered + mem.write(data, buffered, encoding);
  1302. }
  1303. } else {
  1304. endPos = buffered + mem.write(data, buffered, encoding);
  1305. }
  1306. if (endPos < chunkSize) {
  1307. this.buffered = endPos;
  1308. } else {
  1309. const l = endPos & ~(this.chunkSize - 1);
  1310. exports.update(l);
  1311. const newBuffered = endPos - l;
  1312. this.buffered = newBuffered;
  1313. if (newBuffered > 0) {
  1314. mem.copyWithin(0, l, endPos);
  1315. }
  1316. }
  1317. }
  1318. /**
  1319. * @param {Buffer} data data
  1320. * @returns {void}
  1321. */
  1322. _updateWithBuffer(data) {
  1323. const { exports, buffered, mem } = this;
  1324. const length = data.length;
  1325. if (buffered + length < this.chunkSize) {
  1326. data.copy(mem, buffered, 0, length);
  1327. this.buffered += length;
  1328. } else {
  1329. const l = (buffered + length) & ~(this.chunkSize - 1);
  1330. if (l > 65536) {
  1331. let i = 65536 - buffered;
  1332. data.copy(mem, buffered, 0, i);
  1333. exports.update(65536);
  1334. const stop = l - buffered - 65536;
  1335. while (i < stop) {
  1336. data.copy(mem, 0, i, i + 65536);
  1337. exports.update(65536);
  1338. i += 65536;
  1339. }
  1340. data.copy(mem, 0, i, l - buffered);
  1341. exports.update(l - buffered - i);
  1342. } else {
  1343. data.copy(mem, buffered, 0, l - buffered);
  1344. exports.update(l);
  1345. }
  1346. const newBuffered = length + buffered - l;
  1347. this.buffered = newBuffered;
  1348. if (newBuffered > 0) {
  1349. data.copy(mem, 0, length - newBuffered, length);
  1350. }
  1351. }
  1352. }
  1353. digest(type) {
  1354. const { exports, buffered, mem, digestSize } = this;
  1355. exports.final(buffered);
  1356. this.instancesPool.push(this);
  1357. const hex = mem.toString("latin1", 0, digestSize);
  1358. if (type === "hex") {
  1359. return hex;
  1360. }
  1361. if (type === "binary" || !type) {
  1362. return Buffer.from(hex, "hex");
  1363. }
  1364. return Buffer.from(hex, "hex").toString(type);
  1365. }
  1366. }
  1367. const create = (wasmModule, instancesPool, chunkSize, digestSize) => {
  1368. if (instancesPool.length > 0) {
  1369. const old = instancesPool.pop();
  1370. old.reset();
  1371. return old;
  1372. } else {
  1373. return new WasmHash(
  1374. new WebAssembly.Instance(wasmModule),
  1375. instancesPool,
  1376. chunkSize,
  1377. digestSize
  1378. );
  1379. }
  1380. };
  1381. wasmHash.exports = create;
  1382. wasmHash.exports.MAX_SHORT_STRING = MAX_SHORT_STRING;
  1383. return wasmHash.exports;
  1384. }
  1385. /*
  1386. MIT License http://www.opensource.org/licenses/mit-license.php
  1387. Author Tobias Koppers @sokra
  1388. */
  1389. var xxhash64_1;
  1390. var hasRequiredXxhash64;
  1391. function requireXxhash64 () {
  1392. if (hasRequiredXxhash64) return xxhash64_1;
  1393. hasRequiredXxhash64 = 1;
  1394. const create = requireWasmHash();
  1395. //#region wasm code: xxhash64 (../../../assembly/hash/xxhash64.asm.ts) --initialMemory 1
  1396. const xxhash64 = new WebAssembly.Module(
  1397. Buffer.from(
  1398. // 1173 bytes
  1399. "AGFzbQEAAAABCAJgAX8AYAAAAwQDAQAABQMBAAEGGgV+AUIAC34BQgALfgFCAAt+AUIAC34BQgALByIEBGluaXQAAAZ1cGRhdGUAAQVmaW5hbAACBm1lbW9yeQIACrUIAzAAQtbrgu7q/Yn14AAkAELP1tO+0ser2UIkAUIAJAJC+erQ0OfJoeThACQDQgAkBAvUAQIBfwR+IABFBEAPCyMEIACtfCQEIwAhAiMBIQMjAiEEIwMhBQNAIAIgASkDAELP1tO+0ser2UJ+fEIfiUKHla+vmLbem55/fiECIAMgASkDCELP1tO+0ser2UJ+fEIfiUKHla+vmLbem55/fiEDIAQgASkDEELP1tO+0ser2UJ+fEIfiUKHla+vmLbem55/fiEEIAUgASkDGELP1tO+0ser2UJ+fEIfiUKHla+vmLbem55/fiEFIAAgAUEgaiIBSw0ACyACJAAgAyQBIAQkAiAFJAMLqwYCAX8EfiMEQgBSBH4jACICQgGJIwEiA0IHiXwjAiIEQgyJfCMDIgVCEol8IAJCz9bTvtLHq9lCfkIfiUKHla+vmLbem55/foVCh5Wvr5i23puef35CnaO16oOxjYr6AH0gA0LP1tO+0ser2UJ+Qh+JQoeVr6+Ytt6bnn9+hUKHla+vmLbem55/fkKdo7Xqg7GNivoAfSAEQs/W077Sx6vZQn5CH4lCh5Wvr5i23puef36FQoeVr6+Ytt6bnn9+Qp2jteqDsY2K+gB9IAVCz9bTvtLHq9lCfkIfiUKHla+vmLbem55/foVCh5Wvr5i23puef35CnaO16oOxjYr6AH0FQsXP2bLx5brqJwsjBCAArXx8IQIDQCABQQhqIABNBEAgAiABKQMAQs/W077Sx6vZQn5CH4lCh5Wvr5i23puef36FQhuJQoeVr6+Ytt6bnn9+Qp2jteqDsY2K+gB9IQIgAUEIaiEBDAELCyABQQRqIABNBEACfyACIAE1AgBCh5Wvr5i23puef36FQheJQs/W077Sx6vZQn5C+fPd8Zn2masWfCECIAFBBGoLIQELA0AgACABRwRAIAIgATEAAELFz9my8eW66id+hUILiUKHla+vmLbem55/fiECIAFBAWohAQwBCwtBACACIAJCIYiFQs/W077Sx6vZQn4iAiACQh2IhUL5893xmfaZqxZ+IgIgAkIgiIUiAkIgiCIDQv//A4NCIIYgA0KAgPz/D4NCEIiEIgNC/4GAgPAfg0IQhiADQoD+g4CA4D+DQgiIhCIDQo+AvIDwgcAHg0IIhiADQvCBwIeAnoD4AINCBIiEIgNChoyYsODAgYMGfEIEiEKBgoSIkKDAgAGDQid+IANCsODAgYOGjJgwhHw3AwBBCCACQv////8PgyICQv//A4NCIIYgAkKAgPz/D4NCEIiEIgJC/4GAgPAfg0IQhiACQoD+g4CA4D+DQgiIhCICQo+AvIDwgcAHg0IIhiACQvCBwIeAnoD4AINCBIiEIgJChoyYsODAgYMGfEIEiEKBgoSIkKDAgAGDQid+IAJCsODAgYOGjJgwhHw3AwAL",
  1400. "base64"
  1401. )
  1402. );
  1403. //#endregion
  1404. xxhash64_1 = create.bind(null, xxhash64, [], 32, 16);
  1405. return xxhash64_1;
  1406. }
  1407. var BatchedHash_1;
  1408. var hasRequiredBatchedHash;
  1409. function requireBatchedHash () {
  1410. if (hasRequiredBatchedHash) return BatchedHash_1;
  1411. hasRequiredBatchedHash = 1;
  1412. const MAX_SHORT_STRING = requireWasmHash().MAX_SHORT_STRING;
  1413. class BatchedHash {
  1414. constructor(hash) {
  1415. this.string = undefined;
  1416. this.encoding = undefined;
  1417. this.hash = hash;
  1418. }
  1419. /**
  1420. * Update hash {@link https://nodejs.org/api/crypto.html#crypto_hash_update_data_inputencoding}
  1421. * @param {string|Buffer} data data
  1422. * @param {string=} inputEncoding data encoding
  1423. * @returns {this} updated hash
  1424. */
  1425. update(data, inputEncoding) {
  1426. if (this.string !== undefined) {
  1427. if (
  1428. typeof data === "string" &&
  1429. inputEncoding === this.encoding &&
  1430. this.string.length + data.length < MAX_SHORT_STRING
  1431. ) {
  1432. this.string += data;
  1433. return this;
  1434. }
  1435. this.hash.update(this.string, this.encoding);
  1436. this.string = undefined;
  1437. }
  1438. if (typeof data === "string") {
  1439. if (
  1440. data.length < MAX_SHORT_STRING &&
  1441. // base64 encoding is not valid since it may contain padding chars
  1442. (!inputEncoding || !inputEncoding.startsWith("ba"))
  1443. ) {
  1444. this.string = data;
  1445. this.encoding = inputEncoding;
  1446. } else {
  1447. this.hash.update(data, inputEncoding);
  1448. }
  1449. } else {
  1450. this.hash.update(data);
  1451. }
  1452. return this;
  1453. }
  1454. /**
  1455. * Calculates the digest {@link https://nodejs.org/api/crypto.html#crypto_hash_digest_encoding}
  1456. * @param {string=} encoding encoding of the return value
  1457. * @returns {string|Buffer} digest
  1458. */
  1459. digest(encoding) {
  1460. if (this.string !== undefined) {
  1461. this.hash.update(this.string, this.encoding);
  1462. }
  1463. return this.hash.digest(encoding);
  1464. }
  1465. }
  1466. BatchedHash_1 = BatchedHash;
  1467. return BatchedHash_1;
  1468. }
  1469. /*
  1470. MIT License http://www.opensource.org/licenses/mit-license.php
  1471. Author Tobias Koppers @sokra
  1472. */
  1473. var md4_1;
  1474. var hasRequiredMd4;
  1475. function requireMd4 () {
  1476. if (hasRequiredMd4) return md4_1;
  1477. hasRequiredMd4 = 1;
  1478. const create = requireWasmHash();
  1479. //#region wasm code: md4 (../../../assembly/hash/md4.asm.ts) --initialMemory 1
  1480. const md4 = new WebAssembly.Module(
  1481. Buffer.from(
  1482. // 2150 bytes
  1483. "AGFzbQEAAAABCAJgAX8AYAAAAwUEAQAAAAUDAQABBhoFfwFBAAt/AUEAC38BQQALfwFBAAt/AUEACwciBARpbml0AAAGdXBkYXRlAAIFZmluYWwAAwZtZW1vcnkCAAqFEAQmAEGBxpS6BiQBQYnXtv5+JAJB/rnrxXkkA0H2qMmBASQEQQAkAAvMCgEYfyMBIQojAiEGIwMhByMEIQgDQCAAIAVLBEAgBSgCCCINIAcgBiAFKAIEIgsgCCAHIAUoAgAiDCAKIAggBiAHIAhzcXNqakEDdyIDIAYgB3Nxc2pqQQd3IgEgAyAGc3FzampBC3chAiAFKAIUIg8gASACIAUoAhAiCSADIAEgBSgCDCIOIAYgAyACIAEgA3Nxc2pqQRN3IgQgASACc3FzampBA3ciAyACIARzcXNqakEHdyEBIAUoAiAiEiADIAEgBSgCHCIRIAQgAyAFKAIYIhAgAiAEIAEgAyAEc3FzampBC3ciAiABIANzcXNqakETdyIEIAEgAnNxc2pqQQN3IQMgBSgCLCIVIAQgAyAFKAIoIhQgAiAEIAUoAiQiEyABIAIgAyACIARzcXNqakEHdyIBIAMgBHNxc2pqQQt3IgIgASADc3FzampBE3chBCAPIBAgCSAVIBQgEyAFKAI4IhYgAiAEIAUoAjQiFyABIAIgBSgCMCIYIAMgASAEIAEgAnNxc2pqQQN3IgEgAiAEc3FzampBB3ciAiABIARzcXNqakELdyIDIAkgAiAMIAEgBSgCPCIJIAQgASADIAEgAnNxc2pqQRN3IgEgAiADcnEgAiADcXJqakGZ84nUBWpBA3ciAiABIANycSABIANxcmpqQZnzidQFakEFdyIEIAEgAnJxIAEgAnFyaiASakGZ84nUBWpBCXciAyAPIAQgCyACIBggASADIAIgBHJxIAIgBHFyampBmfOJ1AVqQQ13IgEgAyAEcnEgAyAEcXJqakGZ84nUBWpBA3ciAiABIANycSABIANxcmpqQZnzidQFakEFdyIEIAEgAnJxIAEgAnFyampBmfOJ1AVqQQl3IgMgECAEIAIgFyABIAMgAiAEcnEgAiAEcXJqakGZ84nUBWpBDXciASADIARycSADIARxcmogDWpBmfOJ1AVqQQN3IgIgASADcnEgASADcXJqakGZ84nUBWpBBXciBCABIAJycSABIAJxcmpqQZnzidQFakEJdyIDIBEgBCAOIAIgFiABIAMgAiAEcnEgAiAEcXJqakGZ84nUBWpBDXciASADIARycSADIARxcmpqQZnzidQFakEDdyICIAEgA3JxIAEgA3FyampBmfOJ1AVqQQV3IgQgASACcnEgASACcXJqakGZ84nUBWpBCXciAyAMIAIgAyAJIAEgAyACIARycSACIARxcmpqQZnzidQFakENdyIBcyAEc2pqQaHX5/YGakEDdyICIAQgASACcyADc2ogEmpBodfn9gZqQQl3IgRzIAFzampBodfn9gZqQQt3IgMgAiADIBggASADIARzIAJzampBodfn9gZqQQ93IgFzIARzaiANakGh1+f2BmpBA3ciAiAUIAQgASACcyADc2pqQaHX5/YGakEJdyIEcyABc2pqQaHX5/YGakELdyIDIAsgAiADIBYgASADIARzIAJzampBodfn9gZqQQ93IgFzIARzampBodfn9gZqQQN3IgIgEyAEIAEgAnMgA3NqakGh1+f2BmpBCXciBHMgAXNqakGh1+f2BmpBC3chAyAKIA4gAiADIBcgASADIARzIAJzampBodfn9gZqQQ93IgFzIARzampBodfn9gZqQQN3IgJqIQogBiAJIAEgESADIAIgFSAEIAEgAnMgA3NqakGh1+f2BmpBCXciBHMgAXNqakGh1+f2BmpBC3ciAyAEcyACc2pqQaHX5/YGakEPd2ohBiADIAdqIQcgBCAIaiEIIAVBQGshBQwBCwsgCiQBIAYkAiAHJAMgCCQECw0AIAAQASMAIABqJAAL/wQCA38BfiMAIABqrUIDhiEEIABByABqQUBxIgJBCGshAyAAIgFBAWohACABQYABOgAAA0AgACACSUEAIABBB3EbBEAgAEEAOgAAIABBAWohAAwBCwsDQCAAIAJJBEAgAEIANwMAIABBCGohAAwBCwsgAyAENwMAIAIQAUEAIwGtIgRC//8DgyAEQoCA/P8Pg0IQhoQiBEL/gYCA8B+DIARCgP6DgIDgP4NCCIaEIgRCj4C8gPCBwAeDQgiGIARC8IHAh4CegPgAg0IEiIQiBEKGjJiw4MCBgwZ8QgSIQoGChIiQoMCAAYNCJ34gBEKw4MCBg4aMmDCEfDcDAEEIIwKtIgRC//8DgyAEQoCA/P8Pg0IQhoQiBEL/gYCA8B+DIARCgP6DgIDgP4NCCIaEIgRCj4C8gPCBwAeDQgiGIARC8IHAh4CegPgAg0IEiIQiBEKGjJiw4MCBgwZ8QgSIQoGChIiQoMCAAYNCJ34gBEKw4MCBg4aMmDCEfDcDAEEQIwOtIgRC//8DgyAEQoCA/P8Pg0IQhoQiBEL/gYCA8B+DIARCgP6DgIDgP4NCCIaEIgRCj4C8gPCBwAeDQgiGIARC8IHAh4CegPgAg0IEiIQiBEKGjJiw4MCBgwZ8QgSIQoGChIiQoMCAAYNCJ34gBEKw4MCBg4aMmDCEfDcDAEEYIwStIgRC//8DgyAEQoCA/P8Pg0IQhoQiBEL/gYCA8B+DIARCgP6DgIDgP4NCCIaEIgRCj4C8gPCBwAeDQgiGIARC8IHAh4CegPgAg0IEiIQiBEKGjJiw4MCBgwZ8QgSIQoGChIiQoMCAAYNCJ34gBEKw4MCBg4aMmDCEfDcDAAs=",
  1484. "base64"
  1485. )
  1486. );
  1487. //#endregion
  1488. md4_1 = create.bind(null, md4, [], 64, 32);
  1489. return md4_1;
  1490. }
  1491. var BulkUpdateDecorator_1;
  1492. var hasRequiredBulkUpdateDecorator;
  1493. function requireBulkUpdateDecorator () {
  1494. if (hasRequiredBulkUpdateDecorator) return BulkUpdateDecorator_1;
  1495. hasRequiredBulkUpdateDecorator = 1;
  1496. const BULK_SIZE = 2000;
  1497. // We are using an object instead of a Map as this will stay static during the runtime
  1498. // so access to it can be optimized by v8
  1499. const digestCaches = {};
  1500. class BulkUpdateDecorator {
  1501. /**
  1502. * @param {Hash | function(): Hash} hashOrFactory function to create a hash
  1503. * @param {string=} hashKey key for caching
  1504. */
  1505. constructor(hashOrFactory, hashKey) {
  1506. this.hashKey = hashKey;
  1507. if (typeof hashOrFactory === "function") {
  1508. this.hashFactory = hashOrFactory;
  1509. this.hash = undefined;
  1510. } else {
  1511. this.hashFactory = undefined;
  1512. this.hash = hashOrFactory;
  1513. }
  1514. this.buffer = "";
  1515. }
  1516. /**
  1517. * Update hash {@link https://nodejs.org/api/crypto.html#crypto_hash_update_data_inputencoding}
  1518. * @param {string|Buffer} data data
  1519. * @param {string=} inputEncoding data encoding
  1520. * @returns {this} updated hash
  1521. */
  1522. update(data, inputEncoding) {
  1523. if (
  1524. inputEncoding !== undefined ||
  1525. typeof data !== "string" ||
  1526. data.length > BULK_SIZE
  1527. ) {
  1528. if (this.hash === undefined) {
  1529. this.hash = this.hashFactory();
  1530. }
  1531. if (this.buffer.length > 0) {
  1532. this.hash.update(this.buffer);
  1533. this.buffer = "";
  1534. }
  1535. this.hash.update(data, inputEncoding);
  1536. } else {
  1537. this.buffer += data;
  1538. if (this.buffer.length > BULK_SIZE) {
  1539. if (this.hash === undefined) {
  1540. this.hash = this.hashFactory();
  1541. }
  1542. this.hash.update(this.buffer);
  1543. this.buffer = "";
  1544. }
  1545. }
  1546. return this;
  1547. }
  1548. /**
  1549. * Calculates the digest {@link https://nodejs.org/api/crypto.html#crypto_hash_digest_encoding}
  1550. * @param {string=} encoding encoding of the return value
  1551. * @returns {string|Buffer} digest
  1552. */
  1553. digest(encoding) {
  1554. let digestCache;
  1555. const buffer = this.buffer;
  1556. if (this.hash === undefined) {
  1557. // short data for hash, we can use caching
  1558. const cacheKey = `${this.hashKey}-${encoding}`;
  1559. digestCache = digestCaches[cacheKey];
  1560. if (digestCache === undefined) {
  1561. digestCache = digestCaches[cacheKey] = new Map();
  1562. }
  1563. const cacheEntry = digestCache.get(buffer);
  1564. if (cacheEntry !== undefined) {
  1565. return cacheEntry;
  1566. }
  1567. this.hash = this.hashFactory();
  1568. }
  1569. if (buffer.length > 0) {
  1570. this.hash.update(buffer);
  1571. }
  1572. const digestResult = this.hash.digest(encoding);
  1573. if (digestCache !== undefined) {
  1574. digestCache.set(buffer, digestResult);
  1575. }
  1576. return digestResult;
  1577. }
  1578. }
  1579. BulkUpdateDecorator_1 = BulkUpdateDecorator;
  1580. return BulkUpdateDecorator_1;
  1581. }
  1582. const baseEncodeTables = {
  1583. 26: "abcdefghijklmnopqrstuvwxyz",
  1584. 32: "123456789abcdefghjkmnpqrstuvwxyz", // no 0lio
  1585. 36: "0123456789abcdefghijklmnopqrstuvwxyz",
  1586. 49: "abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ", // no lIO
  1587. 52: "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",
  1588. 58: "123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ", // no 0lIO
  1589. 62: "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",
  1590. 64: "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_",
  1591. };
  1592. /**
  1593. * @param {Uint32Array} uint32Array Treated as a long base-0x100000000 number, little endian
  1594. * @param {number} divisor The divisor
  1595. * @return {number} Modulo (remainder) of the division
  1596. */
  1597. function divmod32(uint32Array, divisor) {
  1598. let carry = 0;
  1599. for (let i = uint32Array.length - 1; i >= 0; i--) {
  1600. const value = carry * 0x100000000 + uint32Array[i];
  1601. carry = value % divisor;
  1602. uint32Array[i] = Math.floor(value / divisor);
  1603. }
  1604. return carry;
  1605. }
  1606. function encodeBufferToBase(buffer, base, length) {
  1607. const encodeTable = baseEncodeTables[base];
  1608. if (!encodeTable) {
  1609. throw new Error("Unknown encoding base" + base);
  1610. }
  1611. // Input bits are only enough to generate this many characters
  1612. const limit = Math.ceil((buffer.length * 8) / Math.log2(base));
  1613. length = Math.min(length, limit);
  1614. // Most of the crypto digests (if not all) has length a multiple of 4 bytes.
  1615. // Fewer numbers in the array means faster math.
  1616. const uint32Array = new Uint32Array(Math.ceil(buffer.length / 4));
  1617. // Make sure the input buffer data is copied and is not mutated by reference.
  1618. // divmod32() would corrupt the BulkUpdateDecorator cache otherwise.
  1619. buffer.copy(Buffer.from(uint32Array.buffer));
  1620. let output = "";
  1621. for (let i = 0; i < length; i++) {
  1622. output = encodeTable[divmod32(uint32Array, base)] + output;
  1623. }
  1624. return output;
  1625. }
  1626. let crypto = undefined;
  1627. let createXXHash64 = undefined;
  1628. let createMd4 = undefined;
  1629. let BatchedHash = undefined;
  1630. let BulkUpdateDecorator = undefined;
  1631. function getHashDigest$1(buffer, algorithm, digestType, maxLength) {
  1632. algorithm = algorithm || "xxhash64";
  1633. maxLength = maxLength || 9999;
  1634. let hash;
  1635. if (algorithm === "xxhash64") {
  1636. if (createXXHash64 === undefined) {
  1637. createXXHash64 = requireXxhash64();
  1638. if (BatchedHash === undefined) {
  1639. BatchedHash = requireBatchedHash();
  1640. }
  1641. }
  1642. hash = new BatchedHash(createXXHash64());
  1643. } else if (algorithm === "md4") {
  1644. if (createMd4 === undefined) {
  1645. createMd4 = requireMd4();
  1646. if (BatchedHash === undefined) {
  1647. BatchedHash = requireBatchedHash();
  1648. }
  1649. }
  1650. hash = new BatchedHash(createMd4());
  1651. } else if (algorithm === "native-md4") {
  1652. if (typeof crypto === "undefined") {
  1653. crypto = require$$5;
  1654. if (BulkUpdateDecorator === undefined) {
  1655. BulkUpdateDecorator = requireBulkUpdateDecorator();
  1656. }
  1657. }
  1658. hash = new BulkUpdateDecorator(() => crypto.createHash("md4"), "md4");
  1659. } else {
  1660. if (typeof crypto === "undefined") {
  1661. crypto = require$$5;
  1662. if (BulkUpdateDecorator === undefined) {
  1663. BulkUpdateDecorator = requireBulkUpdateDecorator();
  1664. }
  1665. }
  1666. hash = new BulkUpdateDecorator(
  1667. () => crypto.createHash(algorithm),
  1668. algorithm
  1669. );
  1670. }
  1671. hash.update(buffer);
  1672. if (
  1673. digestType === "base26" ||
  1674. digestType === "base32" ||
  1675. digestType === "base36" ||
  1676. digestType === "base49" ||
  1677. digestType === "base52" ||
  1678. digestType === "base58" ||
  1679. digestType === "base62"
  1680. ) {
  1681. return encodeBufferToBase(hash.digest(), digestType.substr(4), maxLength);
  1682. } else {
  1683. return hash.digest(digestType || "hex").substr(0, maxLength);
  1684. }
  1685. }
  1686. var getHashDigest_1 = getHashDigest$1;
  1687. const path$1 = require$$0$1;
  1688. const getHashDigest = getHashDigest_1;
  1689. function interpolateName$1(loaderContext, name, options = {}) {
  1690. let filename;
  1691. const hasQuery =
  1692. loaderContext.resourceQuery && loaderContext.resourceQuery.length > 1;
  1693. if (typeof name === "function") {
  1694. filename = name(
  1695. loaderContext.resourcePath,
  1696. hasQuery ? loaderContext.resourceQuery : undefined
  1697. );
  1698. } else {
  1699. filename = name || "[hash].[ext]";
  1700. }
  1701. const context = options.context;
  1702. const content = options.content;
  1703. const regExp = options.regExp;
  1704. let ext = "bin";
  1705. let basename = "file";
  1706. let directory = "";
  1707. let folder = "";
  1708. let query = "";
  1709. if (loaderContext.resourcePath) {
  1710. const parsed = path$1.parse(loaderContext.resourcePath);
  1711. let resourcePath = loaderContext.resourcePath;
  1712. if (parsed.ext) {
  1713. ext = parsed.ext.substr(1);
  1714. }
  1715. if (parsed.dir) {
  1716. basename = parsed.name;
  1717. resourcePath = parsed.dir + path$1.sep;
  1718. }
  1719. if (typeof context !== "undefined") {
  1720. directory = path$1
  1721. .relative(context, resourcePath + "_")
  1722. .replace(/\\/g, "/")
  1723. .replace(/\.\.(\/)?/g, "_$1");
  1724. directory = directory.substr(0, directory.length - 1);
  1725. } else {
  1726. directory = resourcePath.replace(/\\/g, "/").replace(/\.\.(\/)?/g, "_$1");
  1727. }
  1728. if (directory.length === 1) {
  1729. directory = "";
  1730. } else if (directory.length > 1) {
  1731. folder = path$1.basename(directory);
  1732. }
  1733. }
  1734. if (loaderContext.resourceQuery && loaderContext.resourceQuery.length > 1) {
  1735. query = loaderContext.resourceQuery;
  1736. const hashIdx = query.indexOf("#");
  1737. if (hashIdx >= 0) {
  1738. query = query.substr(0, hashIdx);
  1739. }
  1740. }
  1741. let url = filename;
  1742. if (content) {
  1743. // Match hash template
  1744. url = url
  1745. // `hash` and `contenthash` are same in `loader-utils` context
  1746. // let's keep `hash` for backward compatibility
  1747. .replace(
  1748. /\[(?:([^:\]]+):)?(?:hash|contenthash)(?::([a-z]+\d*))?(?::(\d+))?\]/gi,
  1749. (all, hashType, digestType, maxLength) =>
  1750. getHashDigest(content, hashType, digestType, parseInt(maxLength, 10))
  1751. );
  1752. }
  1753. url = url
  1754. .replace(/\[ext\]/gi, () => ext)
  1755. .replace(/\[name\]/gi, () => basename)
  1756. .replace(/\[path\]/gi, () => directory)
  1757. .replace(/\[folder\]/gi, () => folder)
  1758. .replace(/\[query\]/gi, () => query);
  1759. if (regExp && loaderContext.resourcePath) {
  1760. const match = loaderContext.resourcePath.match(new RegExp(regExp));
  1761. match &&
  1762. match.forEach((matched, i) => {
  1763. url = url.replace(new RegExp("\\[" + i + "\\]", "ig"), matched);
  1764. });
  1765. }
  1766. if (
  1767. typeof loaderContext.options === "object" &&
  1768. typeof loaderContext.options.customInterpolateName === "function"
  1769. ) {
  1770. url = loaderContext.options.customInterpolateName.call(
  1771. loaderContext,
  1772. url,
  1773. name,
  1774. options
  1775. );
  1776. }
  1777. return url;
  1778. }
  1779. var interpolateName_1 = interpolateName$1;
  1780. var interpolateName = interpolateName_1;
  1781. var path = require$$0$1;
  1782. /**
  1783. * @param {string} pattern
  1784. * @param {object} options
  1785. * @param {string} options.context
  1786. * @param {string} options.hashPrefix
  1787. * @return {function}
  1788. */
  1789. var genericNames = function createGenerator(pattern, options) {
  1790. options = options || {};
  1791. var context =
  1792. options && typeof options.context === "string"
  1793. ? options.context
  1794. : process.cwd();
  1795. var hashPrefix =
  1796. options && typeof options.hashPrefix === "string" ? options.hashPrefix : "";
  1797. /**
  1798. * @param {string} localName Usually a class name
  1799. * @param {string} filepath Absolute path
  1800. * @return {string}
  1801. */
  1802. return function generate(localName, filepath) {
  1803. var name = pattern.replace(/\[local\]/gi, localName);
  1804. var loaderContext = {
  1805. resourcePath: filepath,
  1806. };
  1807. var loaderOptions = {
  1808. content:
  1809. hashPrefix +
  1810. path.relative(context, filepath).replace(/\\/g, "/") +
  1811. "\x00" +
  1812. localName,
  1813. context: context,
  1814. };
  1815. var genericName = interpolateName(loaderContext, name, loaderOptions);
  1816. return genericName
  1817. .replace(new RegExp("[^a-zA-Z0-9\\-_\u00A0-\uFFFF]", "g"), "-")
  1818. .replace(/^((-?[0-9])|--)/, "_$1");
  1819. };
  1820. };
  1821. var src$2 = {exports: {}};
  1822. var dist = {exports: {}};
  1823. var processor = {exports: {}};
  1824. var parser = {exports: {}};
  1825. var root$1 = {exports: {}};
  1826. var container = {exports: {}};
  1827. var node$1 = {exports: {}};
  1828. var util = {};
  1829. var unesc = {exports: {}};
  1830. (function (module, exports) {
  1831. exports.__esModule = true;
  1832. exports["default"] = unesc;
  1833. // Many thanks for this post which made this migration much easier.
  1834. // https://mathiasbynens.be/notes/css-escapes
  1835. /**
  1836. *
  1837. * @param {string} str
  1838. * @returns {[string, number]|undefined}
  1839. */
  1840. function gobbleHex(str) {
  1841. var lower = str.toLowerCase();
  1842. var hex = '';
  1843. var spaceTerminated = false;
  1844. for (var i = 0; i < 6 && lower[i] !== undefined; i++) {
  1845. var code = lower.charCodeAt(i); // check to see if we are dealing with a valid hex char [a-f|0-9]
  1846. var valid = code >= 97 && code <= 102 || code >= 48 && code <= 57; // https://drafts.csswg.org/css-syntax/#consume-escaped-code-point
  1847. spaceTerminated = code === 32;
  1848. if (!valid) {
  1849. break;
  1850. }
  1851. hex += lower[i];
  1852. }
  1853. if (hex.length === 0) {
  1854. return undefined;
  1855. }
  1856. var codePoint = parseInt(hex, 16);
  1857. var isSurrogate = codePoint >= 0xD800 && codePoint <= 0xDFFF; // Add special case for
  1858. // "If this number is zero, or is for a surrogate, or is greater than the maximum allowed code point"
  1859. // https://drafts.csswg.org/css-syntax/#maximum-allowed-code-point
  1860. if (isSurrogate || codePoint === 0x0000 || codePoint > 0x10FFFF) {
  1861. return ["\uFFFD", hex.length + (spaceTerminated ? 1 : 0)];
  1862. }
  1863. return [String.fromCodePoint(codePoint), hex.length + (spaceTerminated ? 1 : 0)];
  1864. }
  1865. var CONTAINS_ESCAPE = /\\/;
  1866. function unesc(str) {
  1867. var needToProcess = CONTAINS_ESCAPE.test(str);
  1868. if (!needToProcess) {
  1869. return str;
  1870. }
  1871. var ret = "";
  1872. for (var i = 0; i < str.length; i++) {
  1873. if (str[i] === "\\") {
  1874. var gobbled = gobbleHex(str.slice(i + 1, i + 7));
  1875. if (gobbled !== undefined) {
  1876. ret += gobbled[0];
  1877. i += gobbled[1];
  1878. continue;
  1879. } // Retain a pair of \\ if double escaped `\\\\`
  1880. // https://github.com/postcss/postcss-selector-parser/commit/268c9a7656fb53f543dc620aa5b73a30ec3ff20e
  1881. if (str[i + 1] === "\\") {
  1882. ret += "\\";
  1883. i++;
  1884. continue;
  1885. } // if \\ is at the end of the string retain it
  1886. // https://github.com/postcss/postcss-selector-parser/commit/01a6b346e3612ce1ab20219acc26abdc259ccefb
  1887. if (str.length === i + 1) {
  1888. ret += str[i];
  1889. }
  1890. continue;
  1891. }
  1892. ret += str[i];
  1893. }
  1894. return ret;
  1895. }
  1896. module.exports = exports.default;
  1897. } (unesc, unesc.exports));
  1898. var getProp = {exports: {}};
  1899. (function (module, exports) {
  1900. exports.__esModule = true;
  1901. exports["default"] = getProp;
  1902. function getProp(obj) {
  1903. for (var _len = arguments.length, props = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  1904. props[_key - 1] = arguments[_key];
  1905. }
  1906. while (props.length > 0) {
  1907. var prop = props.shift();
  1908. if (!obj[prop]) {
  1909. return undefined;
  1910. }
  1911. obj = obj[prop];
  1912. }
  1913. return obj;
  1914. }
  1915. module.exports = exports.default;
  1916. } (getProp, getProp.exports));
  1917. var ensureObject = {exports: {}};
  1918. (function (module, exports) {
  1919. exports.__esModule = true;
  1920. exports["default"] = ensureObject;
  1921. function ensureObject(obj) {
  1922. for (var _len = arguments.length, props = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  1923. props[_key - 1] = arguments[_key];
  1924. }
  1925. while (props.length > 0) {
  1926. var prop = props.shift();
  1927. if (!obj[prop]) {
  1928. obj[prop] = {};
  1929. }
  1930. obj = obj[prop];
  1931. }
  1932. }
  1933. module.exports = exports.default;
  1934. } (ensureObject, ensureObject.exports));
  1935. var stripComments = {exports: {}};
  1936. (function (module, exports) {
  1937. exports.__esModule = true;
  1938. exports["default"] = stripComments;
  1939. function stripComments(str) {
  1940. var s = "";
  1941. var commentStart = str.indexOf("/*");
  1942. var lastEnd = 0;
  1943. while (commentStart >= 0) {
  1944. s = s + str.slice(lastEnd, commentStart);
  1945. var commentEnd = str.indexOf("*/", commentStart + 2);
  1946. if (commentEnd < 0) {
  1947. return s;
  1948. }
  1949. lastEnd = commentEnd + 2;
  1950. commentStart = str.indexOf("/*", lastEnd);
  1951. }
  1952. s = s + str.slice(lastEnd);
  1953. return s;
  1954. }
  1955. module.exports = exports.default;
  1956. } (stripComments, stripComments.exports));
  1957. util.__esModule = true;
  1958. util.stripComments = util.ensureObject = util.getProp = util.unesc = void 0;
  1959. var _unesc = _interopRequireDefault$3(unesc.exports);
  1960. util.unesc = _unesc["default"];
  1961. var _getProp = _interopRequireDefault$3(getProp.exports);
  1962. util.getProp = _getProp["default"];
  1963. var _ensureObject = _interopRequireDefault$3(ensureObject.exports);
  1964. util.ensureObject = _ensureObject["default"];
  1965. var _stripComments = _interopRequireDefault$3(stripComments.exports);
  1966. util.stripComments = _stripComments["default"];
  1967. function _interopRequireDefault$3(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  1968. (function (module, exports) {
  1969. exports.__esModule = true;
  1970. exports["default"] = void 0;
  1971. var _util = util;
  1972. 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); } }
  1973. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  1974. var cloneNode = function cloneNode(obj, parent) {
  1975. if (typeof obj !== 'object' || obj === null) {
  1976. return obj;
  1977. }
  1978. var cloned = new obj.constructor();
  1979. for (var i in obj) {
  1980. if (!obj.hasOwnProperty(i)) {
  1981. continue;
  1982. }
  1983. var value = obj[i];
  1984. var type = typeof value;
  1985. if (i === 'parent' && type === 'object') {
  1986. if (parent) {
  1987. cloned[i] = parent;
  1988. }
  1989. } else if (value instanceof Array) {
  1990. cloned[i] = value.map(function (j) {
  1991. return cloneNode(j, cloned);
  1992. });
  1993. } else {
  1994. cloned[i] = cloneNode(value, cloned);
  1995. }
  1996. }
  1997. return cloned;
  1998. };
  1999. var Node = /*#__PURE__*/function () {
  2000. function Node(opts) {
  2001. if (opts === void 0) {
  2002. opts = {};
  2003. }
  2004. Object.assign(this, opts);
  2005. this.spaces = this.spaces || {};
  2006. this.spaces.before = this.spaces.before || '';
  2007. this.spaces.after = this.spaces.after || '';
  2008. }
  2009. var _proto = Node.prototype;
  2010. _proto.remove = function remove() {
  2011. if (this.parent) {
  2012. this.parent.removeChild(this);
  2013. }
  2014. this.parent = undefined;
  2015. return this;
  2016. };
  2017. _proto.replaceWith = function replaceWith() {
  2018. if (this.parent) {
  2019. for (var index in arguments) {
  2020. this.parent.insertBefore(this, arguments[index]);
  2021. }
  2022. this.remove();
  2023. }
  2024. return this;
  2025. };
  2026. _proto.next = function next() {
  2027. return this.parent.at(this.parent.index(this) + 1);
  2028. };
  2029. _proto.prev = function prev() {
  2030. return this.parent.at(this.parent.index(this) - 1);
  2031. };
  2032. _proto.clone = function clone(overrides) {
  2033. if (overrides === void 0) {
  2034. overrides = {};
  2035. }
  2036. var cloned = cloneNode(this);
  2037. for (var name in overrides) {
  2038. cloned[name] = overrides[name];
  2039. }
  2040. return cloned;
  2041. }
  2042. /**
  2043. * Some non-standard syntax doesn't follow normal escaping rules for css.
  2044. * This allows non standard syntax to be appended to an existing property
  2045. * by specifying the escaped value. By specifying the escaped value,
  2046. * illegal characters are allowed to be directly inserted into css output.
  2047. * @param {string} name the property to set
  2048. * @param {any} value the unescaped value of the property
  2049. * @param {string} valueEscaped optional. the escaped value of the property.
  2050. */
  2051. ;
  2052. _proto.appendToPropertyAndEscape = function appendToPropertyAndEscape(name, value, valueEscaped) {
  2053. if (!this.raws) {
  2054. this.raws = {};
  2055. }
  2056. var originalValue = this[name];
  2057. var originalEscaped = this.raws[name];
  2058. this[name] = originalValue + value; // this may trigger a setter that updates raws, so it has to be set first.
  2059. if (originalEscaped || valueEscaped !== value) {
  2060. this.raws[name] = (originalEscaped || originalValue) + valueEscaped;
  2061. } else {
  2062. delete this.raws[name]; // delete any escaped value that was created by the setter.
  2063. }
  2064. }
  2065. /**
  2066. * Some non-standard syntax doesn't follow normal escaping rules for css.
  2067. * This allows the escaped value to be specified directly, allowing illegal
  2068. * characters to be directly inserted into css output.
  2069. * @param {string} name the property to set
  2070. * @param {any} value the unescaped value of the property
  2071. * @param {string} valueEscaped the escaped value of the property.
  2072. */
  2073. ;
  2074. _proto.setPropertyAndEscape = function setPropertyAndEscape(name, value, valueEscaped) {
  2075. if (!this.raws) {
  2076. this.raws = {};
  2077. }
  2078. this[name] = value; // this may trigger a setter that updates raws, so it has to be set first.
  2079. this.raws[name] = valueEscaped;
  2080. }
  2081. /**
  2082. * When you want a value to passed through to CSS directly. This method
  2083. * deletes the corresponding raw value causing the stringifier to fallback
  2084. * to the unescaped value.
  2085. * @param {string} name the property to set.
  2086. * @param {any} value The value that is both escaped and unescaped.
  2087. */
  2088. ;
  2089. _proto.setPropertyWithoutEscape = function setPropertyWithoutEscape(name, value) {
  2090. this[name] = value; // this may trigger a setter that updates raws, so it has to be set first.
  2091. if (this.raws) {
  2092. delete this.raws[name];
  2093. }
  2094. }
  2095. /**
  2096. *
  2097. * @param {number} line The number (starting with 1)
  2098. * @param {number} column The column number (starting with 1)
  2099. */
  2100. ;
  2101. _proto.isAtPosition = function isAtPosition(line, column) {
  2102. if (this.source && this.source.start && this.source.end) {
  2103. if (this.source.start.line > line) {
  2104. return false;
  2105. }
  2106. if (this.source.end.line < line) {
  2107. return false;
  2108. }
  2109. if (this.source.start.line === line && this.source.start.column > column) {
  2110. return false;
  2111. }
  2112. if (this.source.end.line === line && this.source.end.column < column) {
  2113. return false;
  2114. }
  2115. return true;
  2116. }
  2117. return undefined;
  2118. };
  2119. _proto.stringifyProperty = function stringifyProperty(name) {
  2120. return this.raws && this.raws[name] || this[name];
  2121. };
  2122. _proto.valueToString = function valueToString() {
  2123. return String(this.stringifyProperty("value"));
  2124. };
  2125. _proto.toString = function toString() {
  2126. return [this.rawSpaceBefore, this.valueToString(), this.rawSpaceAfter].join('');
  2127. };
  2128. _createClass(Node, [{
  2129. key: "rawSpaceBefore",
  2130. get: function get() {
  2131. var rawSpace = this.raws && this.raws.spaces && this.raws.spaces.before;
  2132. if (rawSpace === undefined) {
  2133. rawSpace = this.spaces && this.spaces.before;
  2134. }
  2135. return rawSpace || "";
  2136. },
  2137. set: function set(raw) {
  2138. (0, _util.ensureObject)(this, "raws", "spaces");
  2139. this.raws.spaces.before = raw;
  2140. }
  2141. }, {
  2142. key: "rawSpaceAfter",
  2143. get: function get() {
  2144. var rawSpace = this.raws && this.raws.spaces && this.raws.spaces.after;
  2145. if (rawSpace === undefined) {
  2146. rawSpace = this.spaces.after;
  2147. }
  2148. return rawSpace || "";
  2149. },
  2150. set: function set(raw) {
  2151. (0, _util.ensureObject)(this, "raws", "spaces");
  2152. this.raws.spaces.after = raw;
  2153. }
  2154. }]);
  2155. return Node;
  2156. }();
  2157. exports["default"] = Node;
  2158. module.exports = exports.default;
  2159. } (node$1, node$1.exports));
  2160. var types = {};
  2161. types.__esModule = true;
  2162. types.UNIVERSAL = types.ATTRIBUTE = types.CLASS = types.COMBINATOR = types.COMMENT = types.ID = types.NESTING = types.PSEUDO = types.ROOT = types.SELECTOR = types.STRING = types.TAG = void 0;
  2163. var TAG = 'tag';
  2164. types.TAG = TAG;
  2165. var STRING = 'string';
  2166. types.STRING = STRING;
  2167. var SELECTOR = 'selector';
  2168. types.SELECTOR = SELECTOR;
  2169. var ROOT = 'root';
  2170. types.ROOT = ROOT;
  2171. var PSEUDO = 'pseudo';
  2172. types.PSEUDO = PSEUDO;
  2173. var NESTING = 'nesting';
  2174. types.NESTING = NESTING;
  2175. var ID = 'id';
  2176. types.ID = ID;
  2177. var COMMENT = 'comment';
  2178. types.COMMENT = COMMENT;
  2179. var COMBINATOR = 'combinator';
  2180. types.COMBINATOR = COMBINATOR;
  2181. var CLASS = 'class';
  2182. types.CLASS = CLASS;
  2183. var ATTRIBUTE = 'attribute';
  2184. types.ATTRIBUTE = ATTRIBUTE;
  2185. var UNIVERSAL = 'universal';
  2186. types.UNIVERSAL = UNIVERSAL;
  2187. (function (module, exports) {
  2188. exports.__esModule = true;
  2189. exports["default"] = void 0;
  2190. var _node = _interopRequireDefault(node$1.exports);
  2191. var types$1 = _interopRequireWildcard(types);
  2192. function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
  2193. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
  2194. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  2195. 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); }
  2196. 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); }
  2197. 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; }
  2198. 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); } }
  2199. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  2200. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  2201. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  2202. var Container = /*#__PURE__*/function (_Node) {
  2203. _inheritsLoose(Container, _Node);
  2204. function Container(opts) {
  2205. var _this;
  2206. _this = _Node.call(this, opts) || this;
  2207. if (!_this.nodes) {
  2208. _this.nodes = [];
  2209. }
  2210. return _this;
  2211. }
  2212. var _proto = Container.prototype;
  2213. _proto.append = function append(selector) {
  2214. selector.parent = this;
  2215. this.nodes.push(selector);
  2216. return this;
  2217. };
  2218. _proto.prepend = function prepend(selector) {
  2219. selector.parent = this;
  2220. this.nodes.unshift(selector);
  2221. return this;
  2222. };
  2223. _proto.at = function at(index) {
  2224. return this.nodes[index];
  2225. };
  2226. _proto.index = function index(child) {
  2227. if (typeof child === 'number') {
  2228. return child;
  2229. }
  2230. return this.nodes.indexOf(child);
  2231. };
  2232. _proto.removeChild = function removeChild(child) {
  2233. child = this.index(child);
  2234. this.at(child).parent = undefined;
  2235. this.nodes.splice(child, 1);
  2236. var index;
  2237. for (var id in this.indexes) {
  2238. index = this.indexes[id];
  2239. if (index >= child) {
  2240. this.indexes[id] = index - 1;
  2241. }
  2242. }
  2243. return this;
  2244. };
  2245. _proto.removeAll = function removeAll() {
  2246. for (var _iterator = _createForOfIteratorHelperLoose(this.nodes), _step; !(_step = _iterator()).done;) {
  2247. var node = _step.value;
  2248. node.parent = undefined;
  2249. }
  2250. this.nodes = [];
  2251. return this;
  2252. };
  2253. _proto.empty = function empty() {
  2254. return this.removeAll();
  2255. };
  2256. _proto.insertAfter = function insertAfter(oldNode, newNode) {
  2257. newNode.parent = this;
  2258. var oldIndex = this.index(oldNode);
  2259. this.nodes.splice(oldIndex + 1, 0, newNode);
  2260. newNode.parent = this;
  2261. var index;
  2262. for (var id in this.indexes) {
  2263. index = this.indexes[id];
  2264. if (oldIndex <= index) {
  2265. this.indexes[id] = index + 1;
  2266. }
  2267. }
  2268. return this;
  2269. };
  2270. _proto.insertBefore = function insertBefore(oldNode, newNode) {
  2271. newNode.parent = this;
  2272. var oldIndex = this.index(oldNode);
  2273. this.nodes.splice(oldIndex, 0, newNode);
  2274. newNode.parent = this;
  2275. var index;
  2276. for (var id in this.indexes) {
  2277. index = this.indexes[id];
  2278. if (index <= oldIndex) {
  2279. this.indexes[id] = index + 1;
  2280. }
  2281. }
  2282. return this;
  2283. };
  2284. _proto._findChildAtPosition = function _findChildAtPosition(line, col) {
  2285. var found = undefined;
  2286. this.each(function (node) {
  2287. if (node.atPosition) {
  2288. var foundChild = node.atPosition(line, col);
  2289. if (foundChild) {
  2290. found = foundChild;
  2291. return false;
  2292. }
  2293. } else if (node.isAtPosition(line, col)) {
  2294. found = node;
  2295. return false;
  2296. }
  2297. });
  2298. return found;
  2299. }
  2300. /**
  2301. * Return the most specific node at the line and column number given.
  2302. * The source location is based on the original parsed location, locations aren't
  2303. * updated as selector nodes are mutated.
  2304. *
  2305. * Note that this location is relative to the location of the first character
  2306. * of the selector, and not the location of the selector in the overall document
  2307. * when used in conjunction with postcss.
  2308. *
  2309. * If not found, returns undefined.
  2310. * @param {number} line The line number of the node to find. (1-based index)
  2311. * @param {number} col The column number of the node to find. (1-based index)
  2312. */
  2313. ;
  2314. _proto.atPosition = function atPosition(line, col) {
  2315. if (this.isAtPosition(line, col)) {
  2316. return this._findChildAtPosition(line, col) || this;
  2317. } else {
  2318. return undefined;
  2319. }
  2320. };
  2321. _proto._inferEndPosition = function _inferEndPosition() {
  2322. if (this.last && this.last.source && this.last.source.end) {
  2323. this.source = this.source || {};
  2324. this.source.end = this.source.end || {};
  2325. Object.assign(this.source.end, this.last.source.end);
  2326. }
  2327. };
  2328. _proto.each = function each(callback) {
  2329. if (!this.lastEach) {
  2330. this.lastEach = 0;
  2331. }
  2332. if (!this.indexes) {
  2333. this.indexes = {};
  2334. }
  2335. this.lastEach++;
  2336. var id = this.lastEach;
  2337. this.indexes[id] = 0;
  2338. if (!this.length) {
  2339. return undefined;
  2340. }
  2341. var index, result;
  2342. while (this.indexes[id] < this.length) {
  2343. index = this.indexes[id];
  2344. result = callback(this.at(index), index);
  2345. if (result === false) {
  2346. break;
  2347. }
  2348. this.indexes[id] += 1;
  2349. }
  2350. delete this.indexes[id];
  2351. if (result === false) {
  2352. return false;
  2353. }
  2354. };
  2355. _proto.walk = function walk(callback) {
  2356. return this.each(function (node, i) {
  2357. var result = callback(node, i);
  2358. if (result !== false && node.length) {
  2359. result = node.walk(callback);
  2360. }
  2361. if (result === false) {
  2362. return false;
  2363. }
  2364. });
  2365. };
  2366. _proto.walkAttributes = function walkAttributes(callback) {
  2367. var _this2 = this;
  2368. return this.walk(function (selector) {
  2369. if (selector.type === types$1.ATTRIBUTE) {
  2370. return callback.call(_this2, selector);
  2371. }
  2372. });
  2373. };
  2374. _proto.walkClasses = function walkClasses(callback) {
  2375. var _this3 = this;
  2376. return this.walk(function (selector) {
  2377. if (selector.type === types$1.CLASS) {
  2378. return callback.call(_this3, selector);
  2379. }
  2380. });
  2381. };
  2382. _proto.walkCombinators = function walkCombinators(callback) {
  2383. var _this4 = this;
  2384. return this.walk(function (selector) {
  2385. if (selector.type === types$1.COMBINATOR) {
  2386. return callback.call(_this4, selector);
  2387. }
  2388. });
  2389. };
  2390. _proto.walkComments = function walkComments(callback) {
  2391. var _this5 = this;
  2392. return this.walk(function (selector) {
  2393. if (selector.type === types$1.COMMENT) {
  2394. return callback.call(_this5, selector);
  2395. }
  2396. });
  2397. };
  2398. _proto.walkIds = function walkIds(callback) {
  2399. var _this6 = this;
  2400. return this.walk(function (selector) {
  2401. if (selector.type === types$1.ID) {
  2402. return callback.call(_this6, selector);
  2403. }
  2404. });
  2405. };
  2406. _proto.walkNesting = function walkNesting(callback) {
  2407. var _this7 = this;
  2408. return this.walk(function (selector) {
  2409. if (selector.type === types$1.NESTING) {
  2410. return callback.call(_this7, selector);
  2411. }
  2412. });
  2413. };
  2414. _proto.walkPseudos = function walkPseudos(callback) {
  2415. var _this8 = this;
  2416. return this.walk(function (selector) {
  2417. if (selector.type === types$1.PSEUDO) {
  2418. return callback.call(_this8, selector);
  2419. }
  2420. });
  2421. };
  2422. _proto.walkTags = function walkTags(callback) {
  2423. var _this9 = this;
  2424. return this.walk(function (selector) {
  2425. if (selector.type === types$1.TAG) {
  2426. return callback.call(_this9, selector);
  2427. }
  2428. });
  2429. };
  2430. _proto.walkUniversals = function walkUniversals(callback) {
  2431. var _this10 = this;
  2432. return this.walk(function (selector) {
  2433. if (selector.type === types$1.UNIVERSAL) {
  2434. return callback.call(_this10, selector);
  2435. }
  2436. });
  2437. };
  2438. _proto.split = function split(callback) {
  2439. var _this11 = this;
  2440. var current = [];
  2441. return this.reduce(function (memo, node, index) {
  2442. var split = callback.call(_this11, node);
  2443. current.push(node);
  2444. if (split) {
  2445. memo.push(current);
  2446. current = [];
  2447. } else if (index === _this11.length - 1) {
  2448. memo.push(current);
  2449. }
  2450. return memo;
  2451. }, []);
  2452. };
  2453. _proto.map = function map(callback) {
  2454. return this.nodes.map(callback);
  2455. };
  2456. _proto.reduce = function reduce(callback, memo) {
  2457. return this.nodes.reduce(callback, memo);
  2458. };
  2459. _proto.every = function every(callback) {
  2460. return this.nodes.every(callback);
  2461. };
  2462. _proto.some = function some(callback) {
  2463. return this.nodes.some(callback);
  2464. };
  2465. _proto.filter = function filter(callback) {
  2466. return this.nodes.filter(callback);
  2467. };
  2468. _proto.sort = function sort(callback) {
  2469. return this.nodes.sort(callback);
  2470. };
  2471. _proto.toString = function toString() {
  2472. return this.map(String).join('');
  2473. };
  2474. _createClass(Container, [{
  2475. key: "first",
  2476. get: function get() {
  2477. return this.at(0);
  2478. }
  2479. }, {
  2480. key: "last",
  2481. get: function get() {
  2482. return this.at(this.length - 1);
  2483. }
  2484. }, {
  2485. key: "length",
  2486. get: function get() {
  2487. return this.nodes.length;
  2488. }
  2489. }]);
  2490. return Container;
  2491. }(_node["default"]);
  2492. exports["default"] = Container;
  2493. module.exports = exports.default;
  2494. } (container, container.exports));
  2495. (function (module, exports) {
  2496. exports.__esModule = true;
  2497. exports["default"] = void 0;
  2498. var _container = _interopRequireDefault(container.exports);
  2499. var _types = types;
  2500. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  2501. 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); } }
  2502. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  2503. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  2504. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  2505. var Root = /*#__PURE__*/function (_Container) {
  2506. _inheritsLoose(Root, _Container);
  2507. function Root(opts) {
  2508. var _this;
  2509. _this = _Container.call(this, opts) || this;
  2510. _this.type = _types.ROOT;
  2511. return _this;
  2512. }
  2513. var _proto = Root.prototype;
  2514. _proto.toString = function toString() {
  2515. var str = this.reduce(function (memo, selector) {
  2516. memo.push(String(selector));
  2517. return memo;
  2518. }, []).join(',');
  2519. return this.trailingComma ? str + ',' : str;
  2520. };
  2521. _proto.error = function error(message, options) {
  2522. if (this._error) {
  2523. return this._error(message, options);
  2524. } else {
  2525. return new Error(message);
  2526. }
  2527. };
  2528. _createClass(Root, [{
  2529. key: "errorGenerator",
  2530. set: function set(handler) {
  2531. this._error = handler;
  2532. }
  2533. }]);
  2534. return Root;
  2535. }(_container["default"]);
  2536. exports["default"] = Root;
  2537. module.exports = exports.default;
  2538. } (root$1, root$1.exports));
  2539. var selector$1 = {exports: {}};
  2540. (function (module, exports) {
  2541. exports.__esModule = true;
  2542. exports["default"] = void 0;
  2543. var _container = _interopRequireDefault(container.exports);
  2544. var _types = types;
  2545. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  2546. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  2547. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  2548. var Selector = /*#__PURE__*/function (_Container) {
  2549. _inheritsLoose(Selector, _Container);
  2550. function Selector(opts) {
  2551. var _this;
  2552. _this = _Container.call(this, opts) || this;
  2553. _this.type = _types.SELECTOR;
  2554. return _this;
  2555. }
  2556. return Selector;
  2557. }(_container["default"]);
  2558. exports["default"] = Selector;
  2559. module.exports = exports.default;
  2560. } (selector$1, selector$1.exports));
  2561. var className$1 = {exports: {}};
  2562. /*! https://mths.be/cssesc v3.0.0 by @mathias */
  2563. var object = {};
  2564. var hasOwnProperty$1 = object.hasOwnProperty;
  2565. var merge = function merge(options, defaults) {
  2566. if (!options) {
  2567. return defaults;
  2568. }
  2569. var result = {};
  2570. for (var key in defaults) {
  2571. // `if (defaults.hasOwnProperty(key) { … }` is not needed here, since
  2572. // only recognized option names are used.
  2573. result[key] = hasOwnProperty$1.call(options, key) ? options[key] : defaults[key];
  2574. }
  2575. return result;
  2576. };
  2577. var regexAnySingleEscape = /[ -,\.\/:-@\[-\^`\{-~]/;
  2578. var regexSingleEscape = /[ -,\.\/:-@\[\]\^`\{-~]/;
  2579. var regexExcessiveSpaces = /(^|\\+)?(\\[A-F0-9]{1,6})\x20(?![a-fA-F0-9\x20])/g;
  2580. // https://mathiasbynens.be/notes/css-escapes#css
  2581. var cssesc = function cssesc(string, options) {
  2582. options = merge(options, cssesc.options);
  2583. if (options.quotes != 'single' && options.quotes != 'double') {
  2584. options.quotes = 'single';
  2585. }
  2586. var quote = options.quotes == 'double' ? '"' : '\'';
  2587. var isIdentifier = options.isIdentifier;
  2588. var firstChar = string.charAt(0);
  2589. var output = '';
  2590. var counter = 0;
  2591. var length = string.length;
  2592. while (counter < length) {
  2593. var character = string.charAt(counter++);
  2594. var codePoint = character.charCodeAt();
  2595. var value = void 0;
  2596. // If it’s not a printable ASCII character…
  2597. if (codePoint < 0x20 || codePoint > 0x7E) {
  2598. if (codePoint >= 0xD800 && codePoint <= 0xDBFF && counter < length) {
  2599. // It’s a high surrogate, and there is a next character.
  2600. var extra = string.charCodeAt(counter++);
  2601. if ((extra & 0xFC00) == 0xDC00) {
  2602. // next character is low surrogate
  2603. codePoint = ((codePoint & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000;
  2604. } else {
  2605. // It’s an unmatched surrogate; only append this code unit, in case
  2606. // the next code unit is the high surrogate of a surrogate pair.
  2607. counter--;
  2608. }
  2609. }
  2610. value = '\\' + codePoint.toString(16).toUpperCase() + ' ';
  2611. } else {
  2612. if (options.escapeEverything) {
  2613. if (regexAnySingleEscape.test(character)) {
  2614. value = '\\' + character;
  2615. } else {
  2616. value = '\\' + codePoint.toString(16).toUpperCase() + ' ';
  2617. }
  2618. } else if (/[\t\n\f\r\x0B]/.test(character)) {
  2619. value = '\\' + codePoint.toString(16).toUpperCase() + ' ';
  2620. } else if (character == '\\' || !isIdentifier && (character == '"' && quote == character || character == '\'' && quote == character) || isIdentifier && regexSingleEscape.test(character)) {
  2621. value = '\\' + character;
  2622. } else {
  2623. value = character;
  2624. }
  2625. }
  2626. output += value;
  2627. }
  2628. if (isIdentifier) {
  2629. if (/^-[-\d]/.test(output)) {
  2630. output = '\\-' + output.slice(1);
  2631. } else if (/\d/.test(firstChar)) {
  2632. output = '\\3' + firstChar + ' ' + output.slice(1);
  2633. }
  2634. }
  2635. // Remove spaces after `\HEX` escapes that are not followed by a hex digit,
  2636. // since they’re redundant. Note that this is only possible if the escape
  2637. // sequence isn’t preceded by an odd number of backslashes.
  2638. output = output.replace(regexExcessiveSpaces, function ($0, $1, $2) {
  2639. if ($1 && $1.length % 2) {
  2640. // It’s not safe to remove the space, so don’t.
  2641. return $0;
  2642. }
  2643. // Strip the space.
  2644. return ($1 || '') + $2;
  2645. });
  2646. if (!isIdentifier && options.wrap) {
  2647. return quote + output + quote;
  2648. }
  2649. return output;
  2650. };
  2651. // Expose default options (so they can be overridden globally).
  2652. cssesc.options = {
  2653. 'escapeEverything': false,
  2654. 'isIdentifier': false,
  2655. 'quotes': 'single',
  2656. 'wrap': false
  2657. };
  2658. cssesc.version = '3.0.0';
  2659. var cssesc_1 = cssesc;
  2660. (function (module, exports) {
  2661. exports.__esModule = true;
  2662. exports["default"] = void 0;
  2663. var _cssesc = _interopRequireDefault(cssesc_1);
  2664. var _util = util;
  2665. var _node = _interopRequireDefault(node$1.exports);
  2666. var _types = types;
  2667. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  2668. 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); } }
  2669. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  2670. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  2671. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  2672. var ClassName = /*#__PURE__*/function (_Node) {
  2673. _inheritsLoose(ClassName, _Node);
  2674. function ClassName(opts) {
  2675. var _this;
  2676. _this = _Node.call(this, opts) || this;
  2677. _this.type = _types.CLASS;
  2678. _this._constructed = true;
  2679. return _this;
  2680. }
  2681. var _proto = ClassName.prototype;
  2682. _proto.valueToString = function valueToString() {
  2683. return '.' + _Node.prototype.valueToString.call(this);
  2684. };
  2685. _createClass(ClassName, [{
  2686. key: "value",
  2687. get: function get() {
  2688. return this._value;
  2689. },
  2690. set: function set(v) {
  2691. if (this._constructed) {
  2692. var escaped = (0, _cssesc["default"])(v, {
  2693. isIdentifier: true
  2694. });
  2695. if (escaped !== v) {
  2696. (0, _util.ensureObject)(this, "raws");
  2697. this.raws.value = escaped;
  2698. } else if (this.raws) {
  2699. delete this.raws.value;
  2700. }
  2701. }
  2702. this._value = v;
  2703. }
  2704. }]);
  2705. return ClassName;
  2706. }(_node["default"]);
  2707. exports["default"] = ClassName;
  2708. module.exports = exports.default;
  2709. } (className$1, className$1.exports));
  2710. var comment$2 = {exports: {}};
  2711. (function (module, exports) {
  2712. exports.__esModule = true;
  2713. exports["default"] = void 0;
  2714. var _node = _interopRequireDefault(node$1.exports);
  2715. var _types = types;
  2716. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  2717. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  2718. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  2719. var Comment = /*#__PURE__*/function (_Node) {
  2720. _inheritsLoose(Comment, _Node);
  2721. function Comment(opts) {
  2722. var _this;
  2723. _this = _Node.call(this, opts) || this;
  2724. _this.type = _types.COMMENT;
  2725. return _this;
  2726. }
  2727. return Comment;
  2728. }(_node["default"]);
  2729. exports["default"] = Comment;
  2730. module.exports = exports.default;
  2731. } (comment$2, comment$2.exports));
  2732. var id$1 = {exports: {}};
  2733. (function (module, exports) {
  2734. exports.__esModule = true;
  2735. exports["default"] = void 0;
  2736. var _node = _interopRequireDefault(node$1.exports);
  2737. var _types = types;
  2738. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  2739. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  2740. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  2741. var ID = /*#__PURE__*/function (_Node) {
  2742. _inheritsLoose(ID, _Node);
  2743. function ID(opts) {
  2744. var _this;
  2745. _this = _Node.call(this, opts) || this;
  2746. _this.type = _types.ID;
  2747. return _this;
  2748. }
  2749. var _proto = ID.prototype;
  2750. _proto.valueToString = function valueToString() {
  2751. return '#' + _Node.prototype.valueToString.call(this);
  2752. };
  2753. return ID;
  2754. }(_node["default"]);
  2755. exports["default"] = ID;
  2756. module.exports = exports.default;
  2757. } (id$1, id$1.exports));
  2758. var tag$1 = {exports: {}};
  2759. var namespace = {exports: {}};
  2760. (function (module, exports) {
  2761. exports.__esModule = true;
  2762. exports["default"] = void 0;
  2763. var _cssesc = _interopRequireDefault(cssesc_1);
  2764. var _util = util;
  2765. var _node = _interopRequireDefault(node$1.exports);
  2766. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  2767. 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); } }
  2768. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  2769. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  2770. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  2771. var Namespace = /*#__PURE__*/function (_Node) {
  2772. _inheritsLoose(Namespace, _Node);
  2773. function Namespace() {
  2774. return _Node.apply(this, arguments) || this;
  2775. }
  2776. var _proto = Namespace.prototype;
  2777. _proto.qualifiedName = function qualifiedName(value) {
  2778. if (this.namespace) {
  2779. return this.namespaceString + "|" + value;
  2780. } else {
  2781. return value;
  2782. }
  2783. };
  2784. _proto.valueToString = function valueToString() {
  2785. return this.qualifiedName(_Node.prototype.valueToString.call(this));
  2786. };
  2787. _createClass(Namespace, [{
  2788. key: "namespace",
  2789. get: function get() {
  2790. return this._namespace;
  2791. },
  2792. set: function set(namespace) {
  2793. if (namespace === true || namespace === "*" || namespace === "&") {
  2794. this._namespace = namespace;
  2795. if (this.raws) {
  2796. delete this.raws.namespace;
  2797. }
  2798. return;
  2799. }
  2800. var escaped = (0, _cssesc["default"])(namespace, {
  2801. isIdentifier: true
  2802. });
  2803. this._namespace = namespace;
  2804. if (escaped !== namespace) {
  2805. (0, _util.ensureObject)(this, "raws");
  2806. this.raws.namespace = escaped;
  2807. } else if (this.raws) {
  2808. delete this.raws.namespace;
  2809. }
  2810. }
  2811. }, {
  2812. key: "ns",
  2813. get: function get() {
  2814. return this._namespace;
  2815. },
  2816. set: function set(namespace) {
  2817. this.namespace = namespace;
  2818. }
  2819. }, {
  2820. key: "namespaceString",
  2821. get: function get() {
  2822. if (this.namespace) {
  2823. var ns = this.stringifyProperty("namespace");
  2824. if (ns === true) {
  2825. return '';
  2826. } else {
  2827. return ns;
  2828. }
  2829. } else {
  2830. return '';
  2831. }
  2832. }
  2833. }]);
  2834. return Namespace;
  2835. }(_node["default"]);
  2836. exports["default"] = Namespace;
  2837. module.exports = exports.default;
  2838. } (namespace, namespace.exports));
  2839. (function (module, exports) {
  2840. exports.__esModule = true;
  2841. exports["default"] = void 0;
  2842. var _namespace = _interopRequireDefault(namespace.exports);
  2843. var _types = types;
  2844. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  2845. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  2846. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  2847. var Tag = /*#__PURE__*/function (_Namespace) {
  2848. _inheritsLoose(Tag, _Namespace);
  2849. function Tag(opts) {
  2850. var _this;
  2851. _this = _Namespace.call(this, opts) || this;
  2852. _this.type = _types.TAG;
  2853. return _this;
  2854. }
  2855. return Tag;
  2856. }(_namespace["default"]);
  2857. exports["default"] = Tag;
  2858. module.exports = exports.default;
  2859. } (tag$1, tag$1.exports));
  2860. var string$1 = {exports: {}};
  2861. (function (module, exports) {
  2862. exports.__esModule = true;
  2863. exports["default"] = void 0;
  2864. var _node = _interopRequireDefault(node$1.exports);
  2865. var _types = types;
  2866. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  2867. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  2868. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  2869. var String = /*#__PURE__*/function (_Node) {
  2870. _inheritsLoose(String, _Node);
  2871. function String(opts) {
  2872. var _this;
  2873. _this = _Node.call(this, opts) || this;
  2874. _this.type = _types.STRING;
  2875. return _this;
  2876. }
  2877. return String;
  2878. }(_node["default"]);
  2879. exports["default"] = String;
  2880. module.exports = exports.default;
  2881. } (string$1, string$1.exports));
  2882. var pseudo$1 = {exports: {}};
  2883. (function (module, exports) {
  2884. exports.__esModule = true;
  2885. exports["default"] = void 0;
  2886. var _container = _interopRequireDefault(container.exports);
  2887. var _types = types;
  2888. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  2889. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  2890. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  2891. var Pseudo = /*#__PURE__*/function (_Container) {
  2892. _inheritsLoose(Pseudo, _Container);
  2893. function Pseudo(opts) {
  2894. var _this;
  2895. _this = _Container.call(this, opts) || this;
  2896. _this.type = _types.PSEUDO;
  2897. return _this;
  2898. }
  2899. var _proto = Pseudo.prototype;
  2900. _proto.toString = function toString() {
  2901. var params = this.length ? '(' + this.map(String).join(',') + ')' : '';
  2902. return [this.rawSpaceBefore, this.stringifyProperty("value"), params, this.rawSpaceAfter].join('');
  2903. };
  2904. return Pseudo;
  2905. }(_container["default"]);
  2906. exports["default"] = Pseudo;
  2907. module.exports = exports.default;
  2908. } (pseudo$1, pseudo$1.exports));
  2909. var attribute$1 = {};
  2910. /**
  2911. * For Node.js, simply re-export the core `util.deprecate` function.
  2912. */
  2913. var node = require$$0$2.deprecate;
  2914. (function (exports) {
  2915. exports.__esModule = true;
  2916. exports.unescapeValue = unescapeValue;
  2917. exports["default"] = void 0;
  2918. var _cssesc = _interopRequireDefault(cssesc_1);
  2919. var _unesc = _interopRequireDefault(unesc.exports);
  2920. var _namespace = _interopRequireDefault(namespace.exports);
  2921. var _types = types;
  2922. var _CSSESC_QUOTE_OPTIONS;
  2923. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  2924. 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); } }
  2925. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  2926. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  2927. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  2928. var deprecate = node;
  2929. var WRAPPED_IN_QUOTES = /^('|")([^]*)\1$/;
  2930. var warnOfDeprecatedValueAssignment = deprecate(function () {}, "Assigning an attribute a value containing characters that might need to be escaped is deprecated. " + "Call attribute.setValue() instead.");
  2931. var warnOfDeprecatedQuotedAssignment = deprecate(function () {}, "Assigning attr.quoted is deprecated and has no effect. Assign to attr.quoteMark instead.");
  2932. var warnOfDeprecatedConstructor = deprecate(function () {}, "Constructing an Attribute selector with a value without specifying quoteMark is deprecated. Note: The value should be unescaped now.");
  2933. function unescapeValue(value) {
  2934. var deprecatedUsage = false;
  2935. var quoteMark = null;
  2936. var unescaped = value;
  2937. var m = unescaped.match(WRAPPED_IN_QUOTES);
  2938. if (m) {
  2939. quoteMark = m[1];
  2940. unescaped = m[2];
  2941. }
  2942. unescaped = (0, _unesc["default"])(unescaped);
  2943. if (unescaped !== value) {
  2944. deprecatedUsage = true;
  2945. }
  2946. return {
  2947. deprecatedUsage: deprecatedUsage,
  2948. unescaped: unescaped,
  2949. quoteMark: quoteMark
  2950. };
  2951. }
  2952. function handleDeprecatedContructorOpts(opts) {
  2953. if (opts.quoteMark !== undefined) {
  2954. return opts;
  2955. }
  2956. if (opts.value === undefined) {
  2957. return opts;
  2958. }
  2959. warnOfDeprecatedConstructor();
  2960. var _unescapeValue = unescapeValue(opts.value),
  2961. quoteMark = _unescapeValue.quoteMark,
  2962. unescaped = _unescapeValue.unescaped;
  2963. if (!opts.raws) {
  2964. opts.raws = {};
  2965. }
  2966. if (opts.raws.value === undefined) {
  2967. opts.raws.value = opts.value;
  2968. }
  2969. opts.value = unescaped;
  2970. opts.quoteMark = quoteMark;
  2971. return opts;
  2972. }
  2973. var Attribute = /*#__PURE__*/function (_Namespace) {
  2974. _inheritsLoose(Attribute, _Namespace);
  2975. function Attribute(opts) {
  2976. var _this;
  2977. if (opts === void 0) {
  2978. opts = {};
  2979. }
  2980. _this = _Namespace.call(this, handleDeprecatedContructorOpts(opts)) || this;
  2981. _this.type = _types.ATTRIBUTE;
  2982. _this.raws = _this.raws || {};
  2983. Object.defineProperty(_this.raws, 'unquoted', {
  2984. get: deprecate(function () {
  2985. return _this.value;
  2986. }, "attr.raws.unquoted is deprecated. Call attr.value instead."),
  2987. set: deprecate(function () {
  2988. return _this.value;
  2989. }, "Setting attr.raws.unquoted is deprecated and has no effect. attr.value is unescaped by default now.")
  2990. });
  2991. _this._constructed = true;
  2992. return _this;
  2993. }
  2994. /**
  2995. * Returns the Attribute's value quoted such that it would be legal to use
  2996. * in the value of a css file. The original value's quotation setting
  2997. * used for stringification is left unchanged. See `setValue(value, options)`
  2998. * if you want to control the quote settings of a new value for the attribute.
  2999. *
  3000. * You can also change the quotation used for the current value by setting quoteMark.
  3001. *
  3002. * Options:
  3003. * * quoteMark {'"' | "'" | null} - Use this value to quote the value. If this
  3004. * option is not set, the original value for quoteMark will be used. If
  3005. * indeterminate, a double quote is used. The legal values are:
  3006. * * `null` - the value will be unquoted and characters will be escaped as necessary.
  3007. * * `'` - the value will be quoted with a single quote and single quotes are escaped.
  3008. * * `"` - the value will be quoted with a double quote and double quotes are escaped.
  3009. * * preferCurrentQuoteMark {boolean} - if true, prefer the source quote mark
  3010. * over the quoteMark option value.
  3011. * * smart {boolean} - if true, will select a quote mark based on the value
  3012. * and the other options specified here. See the `smartQuoteMark()`
  3013. * method.
  3014. **/
  3015. var _proto = Attribute.prototype;
  3016. _proto.getQuotedValue = function getQuotedValue(options) {
  3017. if (options === void 0) {
  3018. options = {};
  3019. }
  3020. var quoteMark = this._determineQuoteMark(options);
  3021. var cssescopts = CSSESC_QUOTE_OPTIONS[quoteMark];
  3022. var escaped = (0, _cssesc["default"])(this._value, cssescopts);
  3023. return escaped;
  3024. };
  3025. _proto._determineQuoteMark = function _determineQuoteMark(options) {
  3026. return options.smart ? this.smartQuoteMark(options) : this.preferredQuoteMark(options);
  3027. }
  3028. /**
  3029. * Set the unescaped value with the specified quotation options. The value
  3030. * provided must not include any wrapping quote marks -- those quotes will
  3031. * be interpreted as part of the value and escaped accordingly.
  3032. */
  3033. ;
  3034. _proto.setValue = function setValue(value, options) {
  3035. if (options === void 0) {
  3036. options = {};
  3037. }
  3038. this._value = value;
  3039. this._quoteMark = this._determineQuoteMark(options);
  3040. this._syncRawValue();
  3041. }
  3042. /**
  3043. * Intelligently select a quoteMark value based on the value's contents. If
  3044. * the value is a legal CSS ident, it will not be quoted. Otherwise a quote
  3045. * mark will be picked that minimizes the number of escapes.
  3046. *
  3047. * If there's no clear winner, the quote mark from these options is used,
  3048. * then the source quote mark (this is inverted if `preferCurrentQuoteMark` is
  3049. * true). If the quoteMark is unspecified, a double quote is used.
  3050. *
  3051. * @param options This takes the quoteMark and preferCurrentQuoteMark options
  3052. * from the quoteValue method.
  3053. */
  3054. ;
  3055. _proto.smartQuoteMark = function smartQuoteMark(options) {
  3056. var v = this.value;
  3057. var numSingleQuotes = v.replace(/[^']/g, '').length;
  3058. var numDoubleQuotes = v.replace(/[^"]/g, '').length;
  3059. if (numSingleQuotes + numDoubleQuotes === 0) {
  3060. var escaped = (0, _cssesc["default"])(v, {
  3061. isIdentifier: true
  3062. });
  3063. if (escaped === v) {
  3064. return Attribute.NO_QUOTE;
  3065. } else {
  3066. var pref = this.preferredQuoteMark(options);
  3067. if (pref === Attribute.NO_QUOTE) {
  3068. // pick a quote mark that isn't none and see if it's smaller
  3069. var quote = this.quoteMark || options.quoteMark || Attribute.DOUBLE_QUOTE;
  3070. var opts = CSSESC_QUOTE_OPTIONS[quote];
  3071. var quoteValue = (0, _cssesc["default"])(v, opts);
  3072. if (quoteValue.length < escaped.length) {
  3073. return quote;
  3074. }
  3075. }
  3076. return pref;
  3077. }
  3078. } else if (numDoubleQuotes === numSingleQuotes) {
  3079. return this.preferredQuoteMark(options);
  3080. } else if (numDoubleQuotes < numSingleQuotes) {
  3081. return Attribute.DOUBLE_QUOTE;
  3082. } else {
  3083. return Attribute.SINGLE_QUOTE;
  3084. }
  3085. }
  3086. /**
  3087. * Selects the preferred quote mark based on the options and the current quote mark value.
  3088. * If you want the quote mark to depend on the attribute value, call `smartQuoteMark(opts)`
  3089. * instead.
  3090. */
  3091. ;
  3092. _proto.preferredQuoteMark = function preferredQuoteMark(options) {
  3093. var quoteMark = options.preferCurrentQuoteMark ? this.quoteMark : options.quoteMark;
  3094. if (quoteMark === undefined) {
  3095. quoteMark = options.preferCurrentQuoteMark ? options.quoteMark : this.quoteMark;
  3096. }
  3097. if (quoteMark === undefined) {
  3098. quoteMark = Attribute.DOUBLE_QUOTE;
  3099. }
  3100. return quoteMark;
  3101. };
  3102. _proto._syncRawValue = function _syncRawValue() {
  3103. var rawValue = (0, _cssesc["default"])(this._value, CSSESC_QUOTE_OPTIONS[this.quoteMark]);
  3104. if (rawValue === this._value) {
  3105. if (this.raws) {
  3106. delete this.raws.value;
  3107. }
  3108. } else {
  3109. this.raws.value = rawValue;
  3110. }
  3111. };
  3112. _proto._handleEscapes = function _handleEscapes(prop, value) {
  3113. if (this._constructed) {
  3114. var escaped = (0, _cssesc["default"])(value, {
  3115. isIdentifier: true
  3116. });
  3117. if (escaped !== value) {
  3118. this.raws[prop] = escaped;
  3119. } else {
  3120. delete this.raws[prop];
  3121. }
  3122. }
  3123. };
  3124. _proto._spacesFor = function _spacesFor(name) {
  3125. var attrSpaces = {
  3126. before: '',
  3127. after: ''
  3128. };
  3129. var spaces = this.spaces[name] || {};
  3130. var rawSpaces = this.raws.spaces && this.raws.spaces[name] || {};
  3131. return Object.assign(attrSpaces, spaces, rawSpaces);
  3132. };
  3133. _proto._stringFor = function _stringFor(name, spaceName, concat) {
  3134. if (spaceName === void 0) {
  3135. spaceName = name;
  3136. }
  3137. if (concat === void 0) {
  3138. concat = defaultAttrConcat;
  3139. }
  3140. var attrSpaces = this._spacesFor(spaceName);
  3141. return concat(this.stringifyProperty(name), attrSpaces);
  3142. }
  3143. /**
  3144. * returns the offset of the attribute part specified relative to the
  3145. * start of the node of the output string.
  3146. *
  3147. * * "ns" - alias for "namespace"
  3148. * * "namespace" - the namespace if it exists.
  3149. * * "attribute" - the attribute name
  3150. * * "attributeNS" - the start of the attribute or its namespace
  3151. * * "operator" - the match operator of the attribute
  3152. * * "value" - The value (string or identifier)
  3153. * * "insensitive" - the case insensitivity flag;
  3154. * @param part One of the possible values inside an attribute.
  3155. * @returns -1 if the name is invalid or the value doesn't exist in this attribute.
  3156. */
  3157. ;
  3158. _proto.offsetOf = function offsetOf(name) {
  3159. var count = 1;
  3160. var attributeSpaces = this._spacesFor("attribute");
  3161. count += attributeSpaces.before.length;
  3162. if (name === "namespace" || name === "ns") {
  3163. return this.namespace ? count : -1;
  3164. }
  3165. if (name === "attributeNS") {
  3166. return count;
  3167. }
  3168. count += this.namespaceString.length;
  3169. if (this.namespace) {
  3170. count += 1;
  3171. }
  3172. if (name === "attribute") {
  3173. return count;
  3174. }
  3175. count += this.stringifyProperty("attribute").length;
  3176. count += attributeSpaces.after.length;
  3177. var operatorSpaces = this._spacesFor("operator");
  3178. count += operatorSpaces.before.length;
  3179. var operator = this.stringifyProperty("operator");
  3180. if (name === "operator") {
  3181. return operator ? count : -1;
  3182. }
  3183. count += operator.length;
  3184. count += operatorSpaces.after.length;
  3185. var valueSpaces = this._spacesFor("value");
  3186. count += valueSpaces.before.length;
  3187. var value = this.stringifyProperty("value");
  3188. if (name === "value") {
  3189. return value ? count : -1;
  3190. }
  3191. count += value.length;
  3192. count += valueSpaces.after.length;
  3193. var insensitiveSpaces = this._spacesFor("insensitive");
  3194. count += insensitiveSpaces.before.length;
  3195. if (name === "insensitive") {
  3196. return this.insensitive ? count : -1;
  3197. }
  3198. return -1;
  3199. };
  3200. _proto.toString = function toString() {
  3201. var _this2 = this;
  3202. var selector = [this.rawSpaceBefore, '['];
  3203. selector.push(this._stringFor('qualifiedAttribute', 'attribute'));
  3204. if (this.operator && (this.value || this.value === '')) {
  3205. selector.push(this._stringFor('operator'));
  3206. selector.push(this._stringFor('value'));
  3207. selector.push(this._stringFor('insensitiveFlag', 'insensitive', function (attrValue, attrSpaces) {
  3208. if (attrValue.length > 0 && !_this2.quoted && attrSpaces.before.length === 0 && !(_this2.spaces.value && _this2.spaces.value.after)) {
  3209. attrSpaces.before = " ";
  3210. }
  3211. return defaultAttrConcat(attrValue, attrSpaces);
  3212. }));
  3213. }
  3214. selector.push(']');
  3215. selector.push(this.rawSpaceAfter);
  3216. return selector.join('');
  3217. };
  3218. _createClass(Attribute, [{
  3219. key: "quoted",
  3220. get: function get() {
  3221. var qm = this.quoteMark;
  3222. return qm === "'" || qm === '"';
  3223. },
  3224. set: function set(value) {
  3225. warnOfDeprecatedQuotedAssignment();
  3226. }
  3227. /**
  3228. * returns a single (`'`) or double (`"`) quote character if the value is quoted.
  3229. * returns `null` if the value is not quoted.
  3230. * returns `undefined` if the quotation state is unknown (this can happen when
  3231. * the attribute is constructed without specifying a quote mark.)
  3232. */
  3233. }, {
  3234. key: "quoteMark",
  3235. get: function get() {
  3236. return this._quoteMark;
  3237. }
  3238. /**
  3239. * Set the quote mark to be used by this attribute's value.
  3240. * If the quote mark changes, the raw (escaped) value at `attr.raws.value` of the attribute
  3241. * value is updated accordingly.
  3242. *
  3243. * @param {"'" | '"' | null} quoteMark The quote mark or `null` if the value should be unquoted.
  3244. */
  3245. ,
  3246. set: function set(quoteMark) {
  3247. if (!this._constructed) {
  3248. this._quoteMark = quoteMark;
  3249. return;
  3250. }
  3251. if (this._quoteMark !== quoteMark) {
  3252. this._quoteMark = quoteMark;
  3253. this._syncRawValue();
  3254. }
  3255. }
  3256. }, {
  3257. key: "qualifiedAttribute",
  3258. get: function get() {
  3259. return this.qualifiedName(this.raws.attribute || this.attribute);
  3260. }
  3261. }, {
  3262. key: "insensitiveFlag",
  3263. get: function get() {
  3264. return this.insensitive ? 'i' : '';
  3265. }
  3266. }, {
  3267. key: "value",
  3268. get: function get() {
  3269. return this._value;
  3270. }
  3271. /**
  3272. * Before 3.0, the value had to be set to an escaped value including any wrapped
  3273. * quote marks. In 3.0, the semantics of `Attribute.value` changed so that the value
  3274. * is unescaped during parsing and any quote marks are removed.
  3275. *
  3276. * Because the ambiguity of this semantic change, if you set `attr.value = newValue`,
  3277. * a deprecation warning is raised when the new value contains any characters that would
  3278. * require escaping (including if it contains wrapped quotes).
  3279. *
  3280. * Instead, you should call `attr.setValue(newValue, opts)` and pass options that describe
  3281. * how the new value is quoted.
  3282. */
  3283. ,
  3284. set: function set(v) {
  3285. if (this._constructed) {
  3286. var _unescapeValue2 = unescapeValue(v),
  3287. deprecatedUsage = _unescapeValue2.deprecatedUsage,
  3288. unescaped = _unescapeValue2.unescaped,
  3289. quoteMark = _unescapeValue2.quoteMark;
  3290. if (deprecatedUsage) {
  3291. warnOfDeprecatedValueAssignment();
  3292. }
  3293. if (unescaped === this._value && quoteMark === this._quoteMark) {
  3294. return;
  3295. }
  3296. this._value = unescaped;
  3297. this._quoteMark = quoteMark;
  3298. this._syncRawValue();
  3299. } else {
  3300. this._value = v;
  3301. }
  3302. }
  3303. }, {
  3304. key: "attribute",
  3305. get: function get() {
  3306. return this._attribute;
  3307. },
  3308. set: function set(name) {
  3309. this._handleEscapes("attribute", name);
  3310. this._attribute = name;
  3311. }
  3312. }]);
  3313. return Attribute;
  3314. }(_namespace["default"]);
  3315. exports["default"] = Attribute;
  3316. Attribute.NO_QUOTE = null;
  3317. Attribute.SINGLE_QUOTE = "'";
  3318. Attribute.DOUBLE_QUOTE = '"';
  3319. var CSSESC_QUOTE_OPTIONS = (_CSSESC_QUOTE_OPTIONS = {
  3320. "'": {
  3321. quotes: 'single',
  3322. wrap: true
  3323. },
  3324. '"': {
  3325. quotes: 'double',
  3326. wrap: true
  3327. }
  3328. }, _CSSESC_QUOTE_OPTIONS[null] = {
  3329. isIdentifier: true
  3330. }, _CSSESC_QUOTE_OPTIONS);
  3331. function defaultAttrConcat(attrValue, attrSpaces) {
  3332. return "" + attrSpaces.before + attrValue + attrSpaces.after;
  3333. }
  3334. } (attribute$1));
  3335. var universal$1 = {exports: {}};
  3336. (function (module, exports) {
  3337. exports.__esModule = true;
  3338. exports["default"] = void 0;
  3339. var _namespace = _interopRequireDefault(namespace.exports);
  3340. var _types = types;
  3341. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  3342. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  3343. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  3344. var Universal = /*#__PURE__*/function (_Namespace) {
  3345. _inheritsLoose(Universal, _Namespace);
  3346. function Universal(opts) {
  3347. var _this;
  3348. _this = _Namespace.call(this, opts) || this;
  3349. _this.type = _types.UNIVERSAL;
  3350. _this.value = '*';
  3351. return _this;
  3352. }
  3353. return Universal;
  3354. }(_namespace["default"]);
  3355. exports["default"] = Universal;
  3356. module.exports = exports.default;
  3357. } (universal$1, universal$1.exports));
  3358. var combinator$2 = {exports: {}};
  3359. (function (module, exports) {
  3360. exports.__esModule = true;
  3361. exports["default"] = void 0;
  3362. var _node = _interopRequireDefault(node$1.exports);
  3363. var _types = types;
  3364. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  3365. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  3366. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  3367. var Combinator = /*#__PURE__*/function (_Node) {
  3368. _inheritsLoose(Combinator, _Node);
  3369. function Combinator(opts) {
  3370. var _this;
  3371. _this = _Node.call(this, opts) || this;
  3372. _this.type = _types.COMBINATOR;
  3373. return _this;
  3374. }
  3375. return Combinator;
  3376. }(_node["default"]);
  3377. exports["default"] = Combinator;
  3378. module.exports = exports.default;
  3379. } (combinator$2, combinator$2.exports));
  3380. var nesting$1 = {exports: {}};
  3381. (function (module, exports) {
  3382. exports.__esModule = true;
  3383. exports["default"] = void 0;
  3384. var _node = _interopRequireDefault(node$1.exports);
  3385. var _types = types;
  3386. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  3387. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  3388. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  3389. var Nesting = /*#__PURE__*/function (_Node) {
  3390. _inheritsLoose(Nesting, _Node);
  3391. function Nesting(opts) {
  3392. var _this;
  3393. _this = _Node.call(this, opts) || this;
  3394. _this.type = _types.NESTING;
  3395. _this.value = '&';
  3396. return _this;
  3397. }
  3398. return Nesting;
  3399. }(_node["default"]);
  3400. exports["default"] = Nesting;
  3401. module.exports = exports.default;
  3402. } (nesting$1, nesting$1.exports));
  3403. var sortAscending = {exports: {}};
  3404. (function (module, exports) {
  3405. exports.__esModule = true;
  3406. exports["default"] = sortAscending;
  3407. function sortAscending(list) {
  3408. return list.sort(function (a, b) {
  3409. return a - b;
  3410. });
  3411. }
  3412. module.exports = exports.default;
  3413. } (sortAscending, sortAscending.exports));
  3414. var tokenize = {};
  3415. var tokenTypes = {};
  3416. tokenTypes.__esModule = true;
  3417. tokenTypes.combinator = tokenTypes.word = tokenTypes.comment = tokenTypes.str = tokenTypes.tab = tokenTypes.newline = tokenTypes.feed = tokenTypes.cr = tokenTypes.backslash = tokenTypes.bang = tokenTypes.slash = tokenTypes.doubleQuote = tokenTypes.singleQuote = tokenTypes.space = tokenTypes.greaterThan = tokenTypes.pipe = tokenTypes.equals = tokenTypes.plus = tokenTypes.caret = tokenTypes.tilde = tokenTypes.dollar = tokenTypes.closeSquare = tokenTypes.openSquare = tokenTypes.closeParenthesis = tokenTypes.openParenthesis = tokenTypes.semicolon = tokenTypes.colon = tokenTypes.comma = tokenTypes.at = tokenTypes.asterisk = tokenTypes.ampersand = void 0;
  3418. var ampersand = 38; // `&`.charCodeAt(0);
  3419. tokenTypes.ampersand = ampersand;
  3420. var asterisk = 42; // `*`.charCodeAt(0);
  3421. tokenTypes.asterisk = asterisk;
  3422. var at = 64; // `@`.charCodeAt(0);
  3423. tokenTypes.at = at;
  3424. var comma = 44; // `,`.charCodeAt(0);
  3425. tokenTypes.comma = comma;
  3426. var colon = 58; // `:`.charCodeAt(0);
  3427. tokenTypes.colon = colon;
  3428. var semicolon = 59; // `;`.charCodeAt(0);
  3429. tokenTypes.semicolon = semicolon;
  3430. var openParenthesis = 40; // `(`.charCodeAt(0);
  3431. tokenTypes.openParenthesis = openParenthesis;
  3432. var closeParenthesis = 41; // `)`.charCodeAt(0);
  3433. tokenTypes.closeParenthesis = closeParenthesis;
  3434. var openSquare = 91; // `[`.charCodeAt(0);
  3435. tokenTypes.openSquare = openSquare;
  3436. var closeSquare = 93; // `]`.charCodeAt(0);
  3437. tokenTypes.closeSquare = closeSquare;
  3438. var dollar = 36; // `$`.charCodeAt(0);
  3439. tokenTypes.dollar = dollar;
  3440. var tilde = 126; // `~`.charCodeAt(0);
  3441. tokenTypes.tilde = tilde;
  3442. var caret = 94; // `^`.charCodeAt(0);
  3443. tokenTypes.caret = caret;
  3444. var plus = 43; // `+`.charCodeAt(0);
  3445. tokenTypes.plus = plus;
  3446. var equals = 61; // `=`.charCodeAt(0);
  3447. tokenTypes.equals = equals;
  3448. var pipe = 124; // `|`.charCodeAt(0);
  3449. tokenTypes.pipe = pipe;
  3450. var greaterThan = 62; // `>`.charCodeAt(0);
  3451. tokenTypes.greaterThan = greaterThan;
  3452. var space = 32; // ` `.charCodeAt(0);
  3453. tokenTypes.space = space;
  3454. var singleQuote = 39; // `'`.charCodeAt(0);
  3455. tokenTypes.singleQuote = singleQuote;
  3456. var doubleQuote = 34; // `"`.charCodeAt(0);
  3457. tokenTypes.doubleQuote = doubleQuote;
  3458. var slash = 47; // `/`.charCodeAt(0);
  3459. tokenTypes.slash = slash;
  3460. var bang = 33; // `!`.charCodeAt(0);
  3461. tokenTypes.bang = bang;
  3462. var backslash = 92; // '\\'.charCodeAt(0);
  3463. tokenTypes.backslash = backslash;
  3464. var cr = 13; // '\r'.charCodeAt(0);
  3465. tokenTypes.cr = cr;
  3466. var feed = 12; // '\f'.charCodeAt(0);
  3467. tokenTypes.feed = feed;
  3468. var newline = 10; // '\n'.charCodeAt(0);
  3469. tokenTypes.newline = newline;
  3470. var tab = 9; // '\t'.charCodeAt(0);
  3471. // Expose aliases primarily for readability.
  3472. tokenTypes.tab = tab;
  3473. var str = singleQuote; // No good single character representation!
  3474. tokenTypes.str = str;
  3475. var comment$1 = -1;
  3476. tokenTypes.comment = comment$1;
  3477. var word = -2;
  3478. tokenTypes.word = word;
  3479. var combinator$1 = -3;
  3480. tokenTypes.combinator = combinator$1;
  3481. (function (exports) {
  3482. exports.__esModule = true;
  3483. exports["default"] = tokenize;
  3484. exports.FIELDS = void 0;
  3485. var t = _interopRequireWildcard(tokenTypes);
  3486. var _unescapable, _wordDelimiters;
  3487. function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
  3488. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
  3489. var unescapable = (_unescapable = {}, _unescapable[t.tab] = true, _unescapable[t.newline] = true, _unescapable[t.cr] = true, _unescapable[t.feed] = true, _unescapable);
  3490. var wordDelimiters = (_wordDelimiters = {}, _wordDelimiters[t.space] = true, _wordDelimiters[t.tab] = true, _wordDelimiters[t.newline] = true, _wordDelimiters[t.cr] = true, _wordDelimiters[t.feed] = true, _wordDelimiters[t.ampersand] = true, _wordDelimiters[t.asterisk] = true, _wordDelimiters[t.bang] = true, _wordDelimiters[t.comma] = true, _wordDelimiters[t.colon] = true, _wordDelimiters[t.semicolon] = true, _wordDelimiters[t.openParenthesis] = true, _wordDelimiters[t.closeParenthesis] = true, _wordDelimiters[t.openSquare] = true, _wordDelimiters[t.closeSquare] = true, _wordDelimiters[t.singleQuote] = true, _wordDelimiters[t.doubleQuote] = true, _wordDelimiters[t.plus] = true, _wordDelimiters[t.pipe] = true, _wordDelimiters[t.tilde] = true, _wordDelimiters[t.greaterThan] = true, _wordDelimiters[t.equals] = true, _wordDelimiters[t.dollar] = true, _wordDelimiters[t.caret] = true, _wordDelimiters[t.slash] = true, _wordDelimiters);
  3491. var hex = {};
  3492. var hexChars = "0123456789abcdefABCDEF";
  3493. for (var i = 0; i < hexChars.length; i++) {
  3494. hex[hexChars.charCodeAt(i)] = true;
  3495. }
  3496. /**
  3497. * Returns the last index of the bar css word
  3498. * @param {string} css The string in which the word begins
  3499. * @param {number} start The index into the string where word's first letter occurs
  3500. */
  3501. function consumeWord(css, start) {
  3502. var next = start;
  3503. var code;
  3504. do {
  3505. code = css.charCodeAt(next);
  3506. if (wordDelimiters[code]) {
  3507. return next - 1;
  3508. } else if (code === t.backslash) {
  3509. next = consumeEscape(css, next) + 1;
  3510. } else {
  3511. // All other characters are part of the word
  3512. next++;
  3513. }
  3514. } while (next < css.length);
  3515. return next - 1;
  3516. }
  3517. /**
  3518. * Returns the last index of the escape sequence
  3519. * @param {string} css The string in which the sequence begins
  3520. * @param {number} start The index into the string where escape character (`\`) occurs.
  3521. */
  3522. function consumeEscape(css, start) {
  3523. var next = start;
  3524. var code = css.charCodeAt(next + 1);
  3525. if (unescapable[code]) ; else if (hex[code]) {
  3526. var hexDigits = 0; // consume up to 6 hex chars
  3527. do {
  3528. next++;
  3529. hexDigits++;
  3530. code = css.charCodeAt(next + 1);
  3531. } while (hex[code] && hexDigits < 6); // if fewer than 6 hex chars, a trailing space ends the escape
  3532. if (hexDigits < 6 && code === t.space) {
  3533. next++;
  3534. }
  3535. } else {
  3536. // the next char is part of the current word
  3537. next++;
  3538. }
  3539. return next;
  3540. }
  3541. var FIELDS = {
  3542. TYPE: 0,
  3543. START_LINE: 1,
  3544. START_COL: 2,
  3545. END_LINE: 3,
  3546. END_COL: 4,
  3547. START_POS: 5,
  3548. END_POS: 6
  3549. };
  3550. exports.FIELDS = FIELDS;
  3551. function tokenize(input) {
  3552. var tokens = [];
  3553. var css = input.css.valueOf();
  3554. var _css = css,
  3555. length = _css.length;
  3556. var offset = -1;
  3557. var line = 1;
  3558. var start = 0;
  3559. var end = 0;
  3560. var code, content, endColumn, endLine, escaped, escapePos, last, lines, next, nextLine, nextOffset, quote, tokenType;
  3561. function unclosed(what, fix) {
  3562. if (input.safe) {
  3563. // fyi: this is never set to true.
  3564. css += fix;
  3565. next = css.length - 1;
  3566. } else {
  3567. throw input.error('Unclosed ' + what, line, start - offset, start);
  3568. }
  3569. }
  3570. while (start < length) {
  3571. code = css.charCodeAt(start);
  3572. if (code === t.newline) {
  3573. offset = start;
  3574. line += 1;
  3575. }
  3576. switch (code) {
  3577. case t.space:
  3578. case t.tab:
  3579. case t.newline:
  3580. case t.cr:
  3581. case t.feed:
  3582. next = start;
  3583. do {
  3584. next += 1;
  3585. code = css.charCodeAt(next);
  3586. if (code === t.newline) {
  3587. offset = next;
  3588. line += 1;
  3589. }
  3590. } while (code === t.space || code === t.newline || code === t.tab || code === t.cr || code === t.feed);
  3591. tokenType = t.space;
  3592. endLine = line;
  3593. endColumn = next - offset - 1;
  3594. end = next;
  3595. break;
  3596. case t.plus:
  3597. case t.greaterThan:
  3598. case t.tilde:
  3599. case t.pipe:
  3600. next = start;
  3601. do {
  3602. next += 1;
  3603. code = css.charCodeAt(next);
  3604. } while (code === t.plus || code === t.greaterThan || code === t.tilde || code === t.pipe);
  3605. tokenType = t.combinator;
  3606. endLine = line;
  3607. endColumn = start - offset;
  3608. end = next;
  3609. break;
  3610. // Consume these characters as single tokens.
  3611. case t.asterisk:
  3612. case t.ampersand:
  3613. case t.bang:
  3614. case t.comma:
  3615. case t.equals:
  3616. case t.dollar:
  3617. case t.caret:
  3618. case t.openSquare:
  3619. case t.closeSquare:
  3620. case t.colon:
  3621. case t.semicolon:
  3622. case t.openParenthesis:
  3623. case t.closeParenthesis:
  3624. next = start;
  3625. tokenType = code;
  3626. endLine = line;
  3627. endColumn = start - offset;
  3628. end = next + 1;
  3629. break;
  3630. case t.singleQuote:
  3631. case t.doubleQuote:
  3632. quote = code === t.singleQuote ? "'" : '"';
  3633. next = start;
  3634. do {
  3635. escaped = false;
  3636. next = css.indexOf(quote, next + 1);
  3637. if (next === -1) {
  3638. unclosed('quote', quote);
  3639. }
  3640. escapePos = next;
  3641. while (css.charCodeAt(escapePos - 1) === t.backslash) {
  3642. escapePos -= 1;
  3643. escaped = !escaped;
  3644. }
  3645. } while (escaped);
  3646. tokenType = t.str;
  3647. endLine = line;
  3648. endColumn = start - offset;
  3649. end = next + 1;
  3650. break;
  3651. default:
  3652. if (code === t.slash && css.charCodeAt(start + 1) === t.asterisk) {
  3653. next = css.indexOf('*/', start + 2) + 1;
  3654. if (next === 0) {
  3655. unclosed('comment', '*/');
  3656. }
  3657. content = css.slice(start, next + 1);
  3658. lines = content.split('\n');
  3659. last = lines.length - 1;
  3660. if (last > 0) {
  3661. nextLine = line + last;
  3662. nextOffset = next - lines[last].length;
  3663. } else {
  3664. nextLine = line;
  3665. nextOffset = offset;
  3666. }
  3667. tokenType = t.comment;
  3668. line = nextLine;
  3669. endLine = nextLine;
  3670. endColumn = next - nextOffset;
  3671. } else if (code === t.slash) {
  3672. next = start;
  3673. tokenType = code;
  3674. endLine = line;
  3675. endColumn = start - offset;
  3676. end = next + 1;
  3677. } else {
  3678. next = consumeWord(css, start);
  3679. tokenType = t.word;
  3680. endLine = line;
  3681. endColumn = next - offset;
  3682. }
  3683. end = next + 1;
  3684. break;
  3685. } // Ensure that the token structure remains consistent
  3686. tokens.push([tokenType, // [0] Token type
  3687. line, // [1] Starting line
  3688. start - offset, // [2] Starting column
  3689. endLine, // [3] Ending line
  3690. endColumn, // [4] Ending column
  3691. start, // [5] Start position / Source index
  3692. end // [6] End position
  3693. ]); // Reset offset for the next token
  3694. if (nextOffset) {
  3695. offset = nextOffset;
  3696. nextOffset = null;
  3697. }
  3698. start = end;
  3699. }
  3700. return tokens;
  3701. }
  3702. } (tokenize));
  3703. (function (module, exports) {
  3704. exports.__esModule = true;
  3705. exports["default"] = void 0;
  3706. var _root = _interopRequireDefault(root$1.exports);
  3707. var _selector = _interopRequireDefault(selector$1.exports);
  3708. var _className = _interopRequireDefault(className$1.exports);
  3709. var _comment = _interopRequireDefault(comment$2.exports);
  3710. var _id = _interopRequireDefault(id$1.exports);
  3711. var _tag = _interopRequireDefault(tag$1.exports);
  3712. var _string = _interopRequireDefault(string$1.exports);
  3713. var _pseudo = _interopRequireDefault(pseudo$1.exports);
  3714. var _attribute = _interopRequireWildcard(attribute$1);
  3715. var _universal = _interopRequireDefault(universal$1.exports);
  3716. var _combinator = _interopRequireDefault(combinator$2.exports);
  3717. var _nesting = _interopRequireDefault(nesting$1.exports);
  3718. var _sortAscending = _interopRequireDefault(sortAscending.exports);
  3719. var _tokenize = _interopRequireWildcard(tokenize);
  3720. var tokens = _interopRequireWildcard(tokenTypes);
  3721. var types$1 = _interopRequireWildcard(types);
  3722. var _util = util;
  3723. var _WHITESPACE_TOKENS, _Object$assign;
  3724. function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
  3725. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
  3726. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  3727. 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); } }
  3728. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  3729. var WHITESPACE_TOKENS = (_WHITESPACE_TOKENS = {}, _WHITESPACE_TOKENS[tokens.space] = true, _WHITESPACE_TOKENS[tokens.cr] = true, _WHITESPACE_TOKENS[tokens.feed] = true, _WHITESPACE_TOKENS[tokens.newline] = true, _WHITESPACE_TOKENS[tokens.tab] = true, _WHITESPACE_TOKENS);
  3730. var WHITESPACE_EQUIV_TOKENS = Object.assign({}, WHITESPACE_TOKENS, (_Object$assign = {}, _Object$assign[tokens.comment] = true, _Object$assign));
  3731. function tokenStart(token) {
  3732. return {
  3733. line: token[_tokenize.FIELDS.START_LINE],
  3734. column: token[_tokenize.FIELDS.START_COL]
  3735. };
  3736. }
  3737. function tokenEnd(token) {
  3738. return {
  3739. line: token[_tokenize.FIELDS.END_LINE],
  3740. column: token[_tokenize.FIELDS.END_COL]
  3741. };
  3742. }
  3743. function getSource(startLine, startColumn, endLine, endColumn) {
  3744. return {
  3745. start: {
  3746. line: startLine,
  3747. column: startColumn
  3748. },
  3749. end: {
  3750. line: endLine,
  3751. column: endColumn
  3752. }
  3753. };
  3754. }
  3755. function getTokenSource(token) {
  3756. return getSource(token[_tokenize.FIELDS.START_LINE], token[_tokenize.FIELDS.START_COL], token[_tokenize.FIELDS.END_LINE], token[_tokenize.FIELDS.END_COL]);
  3757. }
  3758. function getTokenSourceSpan(startToken, endToken) {
  3759. if (!startToken) {
  3760. return undefined;
  3761. }
  3762. return getSource(startToken[_tokenize.FIELDS.START_LINE], startToken[_tokenize.FIELDS.START_COL], endToken[_tokenize.FIELDS.END_LINE], endToken[_tokenize.FIELDS.END_COL]);
  3763. }
  3764. function unescapeProp(node, prop) {
  3765. var value = node[prop];
  3766. if (typeof value !== "string") {
  3767. return;
  3768. }
  3769. if (value.indexOf("\\") !== -1) {
  3770. (0, _util.ensureObject)(node, 'raws');
  3771. node[prop] = (0, _util.unesc)(value);
  3772. if (node.raws[prop] === undefined) {
  3773. node.raws[prop] = value;
  3774. }
  3775. }
  3776. return node;
  3777. }
  3778. function indexesOf(array, item) {
  3779. var i = -1;
  3780. var indexes = [];
  3781. while ((i = array.indexOf(item, i + 1)) !== -1) {
  3782. indexes.push(i);
  3783. }
  3784. return indexes;
  3785. }
  3786. function uniqs() {
  3787. var list = Array.prototype.concat.apply([], arguments);
  3788. return list.filter(function (item, i) {
  3789. return i === list.indexOf(item);
  3790. });
  3791. }
  3792. var Parser = /*#__PURE__*/function () {
  3793. function Parser(rule, options) {
  3794. if (options === void 0) {
  3795. options = {};
  3796. }
  3797. this.rule = rule;
  3798. this.options = Object.assign({
  3799. lossy: false,
  3800. safe: false
  3801. }, options);
  3802. this.position = 0;
  3803. this.css = typeof this.rule === 'string' ? this.rule : this.rule.selector;
  3804. this.tokens = (0, _tokenize["default"])({
  3805. css: this.css,
  3806. error: this._errorGenerator(),
  3807. safe: this.options.safe
  3808. });
  3809. var rootSource = getTokenSourceSpan(this.tokens[0], this.tokens[this.tokens.length - 1]);
  3810. this.root = new _root["default"]({
  3811. source: rootSource
  3812. });
  3813. this.root.errorGenerator = this._errorGenerator();
  3814. var selector = new _selector["default"]({
  3815. source: {
  3816. start: {
  3817. line: 1,
  3818. column: 1
  3819. }
  3820. }
  3821. });
  3822. this.root.append(selector);
  3823. this.current = selector;
  3824. this.loop();
  3825. }
  3826. var _proto = Parser.prototype;
  3827. _proto._errorGenerator = function _errorGenerator() {
  3828. var _this = this;
  3829. return function (message, errorOptions) {
  3830. if (typeof _this.rule === 'string') {
  3831. return new Error(message);
  3832. }
  3833. return _this.rule.error(message, errorOptions);
  3834. };
  3835. };
  3836. _proto.attribute = function attribute() {
  3837. var attr = [];
  3838. var startingToken = this.currToken;
  3839. this.position++;
  3840. while (this.position < this.tokens.length && this.currToken[_tokenize.FIELDS.TYPE] !== tokens.closeSquare) {
  3841. attr.push(this.currToken);
  3842. this.position++;
  3843. }
  3844. if (this.currToken[_tokenize.FIELDS.TYPE] !== tokens.closeSquare) {
  3845. return this.expected('closing square bracket', this.currToken[_tokenize.FIELDS.START_POS]);
  3846. }
  3847. var len = attr.length;
  3848. var node = {
  3849. source: getSource(startingToken[1], startingToken[2], this.currToken[3], this.currToken[4]),
  3850. sourceIndex: startingToken[_tokenize.FIELDS.START_POS]
  3851. };
  3852. if (len === 1 && !~[tokens.word].indexOf(attr[0][_tokenize.FIELDS.TYPE])) {
  3853. return this.expected('attribute', attr[0][_tokenize.FIELDS.START_POS]);
  3854. }
  3855. var pos = 0;
  3856. var spaceBefore = '';
  3857. var commentBefore = '';
  3858. var lastAdded = null;
  3859. var spaceAfterMeaningfulToken = false;
  3860. while (pos < len) {
  3861. var token = attr[pos];
  3862. var content = this.content(token);
  3863. var next = attr[pos + 1];
  3864. switch (token[_tokenize.FIELDS.TYPE]) {
  3865. case tokens.space:
  3866. // if (
  3867. // len === 1 ||
  3868. // pos === 0 && this.content(next) === '|'
  3869. // ) {
  3870. // return this.expected('attribute', token[TOKEN.START_POS], content);
  3871. // }
  3872. spaceAfterMeaningfulToken = true;
  3873. if (this.options.lossy) {
  3874. break;
  3875. }
  3876. if (lastAdded) {
  3877. (0, _util.ensureObject)(node, 'spaces', lastAdded);
  3878. var prevContent = node.spaces[lastAdded].after || '';
  3879. node.spaces[lastAdded].after = prevContent + content;
  3880. var existingComment = (0, _util.getProp)(node, 'raws', 'spaces', lastAdded, 'after') || null;
  3881. if (existingComment) {
  3882. node.raws.spaces[lastAdded].after = existingComment + content;
  3883. }
  3884. } else {
  3885. spaceBefore = spaceBefore + content;
  3886. commentBefore = commentBefore + content;
  3887. }
  3888. break;
  3889. case tokens.asterisk:
  3890. if (next[_tokenize.FIELDS.TYPE] === tokens.equals) {
  3891. node.operator = content;
  3892. lastAdded = 'operator';
  3893. } else if ((!node.namespace || lastAdded === "namespace" && !spaceAfterMeaningfulToken) && next) {
  3894. if (spaceBefore) {
  3895. (0, _util.ensureObject)(node, 'spaces', 'attribute');
  3896. node.spaces.attribute.before = spaceBefore;
  3897. spaceBefore = '';
  3898. }
  3899. if (commentBefore) {
  3900. (0, _util.ensureObject)(node, 'raws', 'spaces', 'attribute');
  3901. node.raws.spaces.attribute.before = spaceBefore;
  3902. commentBefore = '';
  3903. }
  3904. node.namespace = (node.namespace || "") + content;
  3905. var rawValue = (0, _util.getProp)(node, 'raws', 'namespace') || null;
  3906. if (rawValue) {
  3907. node.raws.namespace += content;
  3908. }
  3909. lastAdded = 'namespace';
  3910. }
  3911. spaceAfterMeaningfulToken = false;
  3912. break;
  3913. case tokens.dollar:
  3914. if (lastAdded === "value") {
  3915. var oldRawValue = (0, _util.getProp)(node, 'raws', 'value');
  3916. node.value += "$";
  3917. if (oldRawValue) {
  3918. node.raws.value = oldRawValue + "$";
  3919. }
  3920. break;
  3921. }
  3922. // Falls through
  3923. case tokens.caret:
  3924. if (next[_tokenize.FIELDS.TYPE] === tokens.equals) {
  3925. node.operator = content;
  3926. lastAdded = 'operator';
  3927. }
  3928. spaceAfterMeaningfulToken = false;
  3929. break;
  3930. case tokens.combinator:
  3931. if (content === '~' && next[_tokenize.FIELDS.TYPE] === tokens.equals) {
  3932. node.operator = content;
  3933. lastAdded = 'operator';
  3934. }
  3935. if (content !== '|') {
  3936. spaceAfterMeaningfulToken = false;
  3937. break;
  3938. }
  3939. if (next[_tokenize.FIELDS.TYPE] === tokens.equals) {
  3940. node.operator = content;
  3941. lastAdded = 'operator';
  3942. } else if (!node.namespace && !node.attribute) {
  3943. node.namespace = true;
  3944. }
  3945. spaceAfterMeaningfulToken = false;
  3946. break;
  3947. case tokens.word:
  3948. if (next && this.content(next) === '|' && attr[pos + 2] && attr[pos + 2][_tokenize.FIELDS.TYPE] !== tokens.equals && // this look-ahead probably fails with comment nodes involved.
  3949. !node.operator && !node.namespace) {
  3950. node.namespace = content;
  3951. lastAdded = 'namespace';
  3952. } else if (!node.attribute || lastAdded === "attribute" && !spaceAfterMeaningfulToken) {
  3953. if (spaceBefore) {
  3954. (0, _util.ensureObject)(node, 'spaces', 'attribute');
  3955. node.spaces.attribute.before = spaceBefore;
  3956. spaceBefore = '';
  3957. }
  3958. if (commentBefore) {
  3959. (0, _util.ensureObject)(node, 'raws', 'spaces', 'attribute');
  3960. node.raws.spaces.attribute.before = commentBefore;
  3961. commentBefore = '';
  3962. }
  3963. node.attribute = (node.attribute || "") + content;
  3964. var _rawValue = (0, _util.getProp)(node, 'raws', 'attribute') || null;
  3965. if (_rawValue) {
  3966. node.raws.attribute += content;
  3967. }
  3968. lastAdded = 'attribute';
  3969. } else if (!node.value && node.value !== "" || lastAdded === "value" && !spaceAfterMeaningfulToken) {
  3970. var _unescaped = (0, _util.unesc)(content);
  3971. var _oldRawValue = (0, _util.getProp)(node, 'raws', 'value') || '';
  3972. var oldValue = node.value || '';
  3973. node.value = oldValue + _unescaped;
  3974. node.quoteMark = null;
  3975. if (_unescaped !== content || _oldRawValue) {
  3976. (0, _util.ensureObject)(node, 'raws');
  3977. node.raws.value = (_oldRawValue || oldValue) + content;
  3978. }
  3979. lastAdded = 'value';
  3980. } else {
  3981. var insensitive = content === 'i' || content === "I";
  3982. if ((node.value || node.value === '') && (node.quoteMark || spaceAfterMeaningfulToken)) {
  3983. node.insensitive = insensitive;
  3984. if (!insensitive || content === "I") {
  3985. (0, _util.ensureObject)(node, 'raws');
  3986. node.raws.insensitiveFlag = content;
  3987. }
  3988. lastAdded = 'insensitive';
  3989. if (spaceBefore) {
  3990. (0, _util.ensureObject)(node, 'spaces', 'insensitive');
  3991. node.spaces.insensitive.before = spaceBefore;
  3992. spaceBefore = '';
  3993. }
  3994. if (commentBefore) {
  3995. (0, _util.ensureObject)(node, 'raws', 'spaces', 'insensitive');
  3996. node.raws.spaces.insensitive.before = commentBefore;
  3997. commentBefore = '';
  3998. }
  3999. } else if (node.value || node.value === '') {
  4000. lastAdded = 'value';
  4001. node.value += content;
  4002. if (node.raws.value) {
  4003. node.raws.value += content;
  4004. }
  4005. }
  4006. }
  4007. spaceAfterMeaningfulToken = false;
  4008. break;
  4009. case tokens.str:
  4010. if (!node.attribute || !node.operator) {
  4011. return this.error("Expected an attribute followed by an operator preceding the string.", {
  4012. index: token[_tokenize.FIELDS.START_POS]
  4013. });
  4014. }
  4015. var _unescapeValue = (0, _attribute.unescapeValue)(content),
  4016. unescaped = _unescapeValue.unescaped,
  4017. quoteMark = _unescapeValue.quoteMark;
  4018. node.value = unescaped;
  4019. node.quoteMark = quoteMark;
  4020. lastAdded = 'value';
  4021. (0, _util.ensureObject)(node, 'raws');
  4022. node.raws.value = content;
  4023. spaceAfterMeaningfulToken = false;
  4024. break;
  4025. case tokens.equals:
  4026. if (!node.attribute) {
  4027. return this.expected('attribute', token[_tokenize.FIELDS.START_POS], content);
  4028. }
  4029. if (node.value) {
  4030. return this.error('Unexpected "=" found; an operator was already defined.', {
  4031. index: token[_tokenize.FIELDS.START_POS]
  4032. });
  4033. }
  4034. node.operator = node.operator ? node.operator + content : content;
  4035. lastAdded = 'operator';
  4036. spaceAfterMeaningfulToken = false;
  4037. break;
  4038. case tokens.comment:
  4039. if (lastAdded) {
  4040. if (spaceAfterMeaningfulToken || next && next[_tokenize.FIELDS.TYPE] === tokens.space || lastAdded === 'insensitive') {
  4041. var lastComment = (0, _util.getProp)(node, 'spaces', lastAdded, 'after') || '';
  4042. var rawLastComment = (0, _util.getProp)(node, 'raws', 'spaces', lastAdded, 'after') || lastComment;
  4043. (0, _util.ensureObject)(node, 'raws', 'spaces', lastAdded);
  4044. node.raws.spaces[lastAdded].after = rawLastComment + content;
  4045. } else {
  4046. var lastValue = node[lastAdded] || '';
  4047. var rawLastValue = (0, _util.getProp)(node, 'raws', lastAdded) || lastValue;
  4048. (0, _util.ensureObject)(node, 'raws');
  4049. node.raws[lastAdded] = rawLastValue + content;
  4050. }
  4051. } else {
  4052. commentBefore = commentBefore + content;
  4053. }
  4054. break;
  4055. default:
  4056. return this.error("Unexpected \"" + content + "\" found.", {
  4057. index: token[_tokenize.FIELDS.START_POS]
  4058. });
  4059. }
  4060. pos++;
  4061. }
  4062. unescapeProp(node, "attribute");
  4063. unescapeProp(node, "namespace");
  4064. this.newNode(new _attribute["default"](node));
  4065. this.position++;
  4066. }
  4067. /**
  4068. * return a node containing meaningless garbage up to (but not including) the specified token position.
  4069. * if the token position is negative, all remaining tokens are consumed.
  4070. *
  4071. * This returns an array containing a single string node if all whitespace,
  4072. * otherwise an array of comment nodes with space before and after.
  4073. *
  4074. * These tokens are not added to the current selector, the caller can add them or use them to amend
  4075. * a previous node's space metadata.
  4076. *
  4077. * In lossy mode, this returns only comments.
  4078. */
  4079. ;
  4080. _proto.parseWhitespaceEquivalentTokens = function parseWhitespaceEquivalentTokens(stopPosition) {
  4081. if (stopPosition < 0) {
  4082. stopPosition = this.tokens.length;
  4083. }
  4084. var startPosition = this.position;
  4085. var nodes = [];
  4086. var space = "";
  4087. var lastComment = undefined;
  4088. do {
  4089. if (WHITESPACE_TOKENS[this.currToken[_tokenize.FIELDS.TYPE]]) {
  4090. if (!this.options.lossy) {
  4091. space += this.content();
  4092. }
  4093. } else if (this.currToken[_tokenize.FIELDS.TYPE] === tokens.comment) {
  4094. var spaces = {};
  4095. if (space) {
  4096. spaces.before = space;
  4097. space = "";
  4098. }
  4099. lastComment = new _comment["default"]({
  4100. value: this.content(),
  4101. source: getTokenSource(this.currToken),
  4102. sourceIndex: this.currToken[_tokenize.FIELDS.START_POS],
  4103. spaces: spaces
  4104. });
  4105. nodes.push(lastComment);
  4106. }
  4107. } while (++this.position < stopPosition);
  4108. if (space) {
  4109. if (lastComment) {
  4110. lastComment.spaces.after = space;
  4111. } else if (!this.options.lossy) {
  4112. var firstToken = this.tokens[startPosition];
  4113. var lastToken = this.tokens[this.position - 1];
  4114. nodes.push(new _string["default"]({
  4115. value: '',
  4116. source: getSource(firstToken[_tokenize.FIELDS.START_LINE], firstToken[_tokenize.FIELDS.START_COL], lastToken[_tokenize.FIELDS.END_LINE], lastToken[_tokenize.FIELDS.END_COL]),
  4117. sourceIndex: firstToken[_tokenize.FIELDS.START_POS],
  4118. spaces: {
  4119. before: space,
  4120. after: ''
  4121. }
  4122. }));
  4123. }
  4124. }
  4125. return nodes;
  4126. }
  4127. /**
  4128. *
  4129. * @param {*} nodes
  4130. */
  4131. ;
  4132. _proto.convertWhitespaceNodesToSpace = function convertWhitespaceNodesToSpace(nodes, requiredSpace) {
  4133. var _this2 = this;
  4134. if (requiredSpace === void 0) {
  4135. requiredSpace = false;
  4136. }
  4137. var space = "";
  4138. var rawSpace = "";
  4139. nodes.forEach(function (n) {
  4140. var spaceBefore = _this2.lossySpace(n.spaces.before, requiredSpace);
  4141. var rawSpaceBefore = _this2.lossySpace(n.rawSpaceBefore, requiredSpace);
  4142. space += spaceBefore + _this2.lossySpace(n.spaces.after, requiredSpace && spaceBefore.length === 0);
  4143. rawSpace += spaceBefore + n.value + _this2.lossySpace(n.rawSpaceAfter, requiredSpace && rawSpaceBefore.length === 0);
  4144. });
  4145. if (rawSpace === space) {
  4146. rawSpace = undefined;
  4147. }
  4148. var result = {
  4149. space: space,
  4150. rawSpace: rawSpace
  4151. };
  4152. return result;
  4153. };
  4154. _proto.isNamedCombinator = function isNamedCombinator(position) {
  4155. if (position === void 0) {
  4156. position = this.position;
  4157. }
  4158. return this.tokens[position + 0] && this.tokens[position + 0][_tokenize.FIELDS.TYPE] === tokens.slash && this.tokens[position + 1] && this.tokens[position + 1][_tokenize.FIELDS.TYPE] === tokens.word && this.tokens[position + 2] && this.tokens[position + 2][_tokenize.FIELDS.TYPE] === tokens.slash;
  4159. };
  4160. _proto.namedCombinator = function namedCombinator() {
  4161. if (this.isNamedCombinator()) {
  4162. var nameRaw = this.content(this.tokens[this.position + 1]);
  4163. var name = (0, _util.unesc)(nameRaw).toLowerCase();
  4164. var raws = {};
  4165. if (name !== nameRaw) {
  4166. raws.value = "/" + nameRaw + "/";
  4167. }
  4168. var node = new _combinator["default"]({
  4169. value: "/" + name + "/",
  4170. source: getSource(this.currToken[_tokenize.FIELDS.START_LINE], this.currToken[_tokenize.FIELDS.START_COL], this.tokens[this.position + 2][_tokenize.FIELDS.END_LINE], this.tokens[this.position + 2][_tokenize.FIELDS.END_COL]),
  4171. sourceIndex: this.currToken[_tokenize.FIELDS.START_POS],
  4172. raws: raws
  4173. });
  4174. this.position = this.position + 3;
  4175. return node;
  4176. } else {
  4177. this.unexpected();
  4178. }
  4179. };
  4180. _proto.combinator = function combinator() {
  4181. var _this3 = this;
  4182. if (this.content() === '|') {
  4183. return this.namespace();
  4184. } // We need to decide between a space that's a descendant combinator and meaningless whitespace at the end of a selector.
  4185. var nextSigTokenPos = this.locateNextMeaningfulToken(this.position);
  4186. if (nextSigTokenPos < 0 || this.tokens[nextSigTokenPos][_tokenize.FIELDS.TYPE] === tokens.comma) {
  4187. var nodes = this.parseWhitespaceEquivalentTokens(nextSigTokenPos);
  4188. if (nodes.length > 0) {
  4189. var last = this.current.last;
  4190. if (last) {
  4191. var _this$convertWhitespa = this.convertWhitespaceNodesToSpace(nodes),
  4192. space = _this$convertWhitespa.space,
  4193. rawSpace = _this$convertWhitespa.rawSpace;
  4194. if (rawSpace !== undefined) {
  4195. last.rawSpaceAfter += rawSpace;
  4196. }
  4197. last.spaces.after += space;
  4198. } else {
  4199. nodes.forEach(function (n) {
  4200. return _this3.newNode(n);
  4201. });
  4202. }
  4203. }
  4204. return;
  4205. }
  4206. var firstToken = this.currToken;
  4207. var spaceOrDescendantSelectorNodes = undefined;
  4208. if (nextSigTokenPos > this.position) {
  4209. spaceOrDescendantSelectorNodes = this.parseWhitespaceEquivalentTokens(nextSigTokenPos);
  4210. }
  4211. var node;
  4212. if (this.isNamedCombinator()) {
  4213. node = this.namedCombinator();
  4214. } else if (this.currToken[_tokenize.FIELDS.TYPE] === tokens.combinator) {
  4215. node = new _combinator["default"]({
  4216. value: this.content(),
  4217. source: getTokenSource(this.currToken),
  4218. sourceIndex: this.currToken[_tokenize.FIELDS.START_POS]
  4219. });
  4220. this.position++;
  4221. } else if (WHITESPACE_TOKENS[this.currToken[_tokenize.FIELDS.TYPE]]) ; else if (!spaceOrDescendantSelectorNodes) {
  4222. this.unexpected();
  4223. }
  4224. if (node) {
  4225. if (spaceOrDescendantSelectorNodes) {
  4226. var _this$convertWhitespa2 = this.convertWhitespaceNodesToSpace(spaceOrDescendantSelectorNodes),
  4227. _space = _this$convertWhitespa2.space,
  4228. _rawSpace = _this$convertWhitespa2.rawSpace;
  4229. node.spaces.before = _space;
  4230. node.rawSpaceBefore = _rawSpace;
  4231. }
  4232. } else {
  4233. // descendant combinator
  4234. var _this$convertWhitespa3 = this.convertWhitespaceNodesToSpace(spaceOrDescendantSelectorNodes, true),
  4235. _space2 = _this$convertWhitespa3.space,
  4236. _rawSpace2 = _this$convertWhitespa3.rawSpace;
  4237. if (!_rawSpace2) {
  4238. _rawSpace2 = _space2;
  4239. }
  4240. var spaces = {};
  4241. var raws = {
  4242. spaces: {}
  4243. };
  4244. if (_space2.endsWith(' ') && _rawSpace2.endsWith(' ')) {
  4245. spaces.before = _space2.slice(0, _space2.length - 1);
  4246. raws.spaces.before = _rawSpace2.slice(0, _rawSpace2.length - 1);
  4247. } else if (_space2.startsWith(' ') && _rawSpace2.startsWith(' ')) {
  4248. spaces.after = _space2.slice(1);
  4249. raws.spaces.after = _rawSpace2.slice(1);
  4250. } else {
  4251. raws.value = _rawSpace2;
  4252. }
  4253. node = new _combinator["default"]({
  4254. value: ' ',
  4255. source: getTokenSourceSpan(firstToken, this.tokens[this.position - 1]),
  4256. sourceIndex: firstToken[_tokenize.FIELDS.START_POS],
  4257. spaces: spaces,
  4258. raws: raws
  4259. });
  4260. }
  4261. if (this.currToken && this.currToken[_tokenize.FIELDS.TYPE] === tokens.space) {
  4262. node.spaces.after = this.optionalSpace(this.content());
  4263. this.position++;
  4264. }
  4265. return this.newNode(node);
  4266. };
  4267. _proto.comma = function comma() {
  4268. if (this.position === this.tokens.length - 1) {
  4269. this.root.trailingComma = true;
  4270. this.position++;
  4271. return;
  4272. }
  4273. this.current._inferEndPosition();
  4274. var selector = new _selector["default"]({
  4275. source: {
  4276. start: tokenStart(this.tokens[this.position + 1])
  4277. }
  4278. });
  4279. this.current.parent.append(selector);
  4280. this.current = selector;
  4281. this.position++;
  4282. };
  4283. _proto.comment = function comment() {
  4284. var current = this.currToken;
  4285. this.newNode(new _comment["default"]({
  4286. value: this.content(),
  4287. source: getTokenSource(current),
  4288. sourceIndex: current[_tokenize.FIELDS.START_POS]
  4289. }));
  4290. this.position++;
  4291. };
  4292. _proto.error = function error(message, opts) {
  4293. throw this.root.error(message, opts);
  4294. };
  4295. _proto.missingBackslash = function missingBackslash() {
  4296. return this.error('Expected a backslash preceding the semicolon.', {
  4297. index: this.currToken[_tokenize.FIELDS.START_POS]
  4298. });
  4299. };
  4300. _proto.missingParenthesis = function missingParenthesis() {
  4301. return this.expected('opening parenthesis', this.currToken[_tokenize.FIELDS.START_POS]);
  4302. };
  4303. _proto.missingSquareBracket = function missingSquareBracket() {
  4304. return this.expected('opening square bracket', this.currToken[_tokenize.FIELDS.START_POS]);
  4305. };
  4306. _proto.unexpected = function unexpected() {
  4307. return this.error("Unexpected '" + this.content() + "'. Escaping special characters with \\ may help.", this.currToken[_tokenize.FIELDS.START_POS]);
  4308. };
  4309. _proto.namespace = function namespace() {
  4310. var before = this.prevToken && this.content(this.prevToken) || true;
  4311. if (this.nextToken[_tokenize.FIELDS.TYPE] === tokens.word) {
  4312. this.position++;
  4313. return this.word(before);
  4314. } else if (this.nextToken[_tokenize.FIELDS.TYPE] === tokens.asterisk) {
  4315. this.position++;
  4316. return this.universal(before);
  4317. }
  4318. };
  4319. _proto.nesting = function nesting() {
  4320. if (this.nextToken) {
  4321. var nextContent = this.content(this.nextToken);
  4322. if (nextContent === "|") {
  4323. this.position++;
  4324. return;
  4325. }
  4326. }
  4327. var current = this.currToken;
  4328. this.newNode(new _nesting["default"]({
  4329. value: this.content(),
  4330. source: getTokenSource(current),
  4331. sourceIndex: current[_tokenize.FIELDS.START_POS]
  4332. }));
  4333. this.position++;
  4334. };
  4335. _proto.parentheses = function parentheses() {
  4336. var last = this.current.last;
  4337. var unbalanced = 1;
  4338. this.position++;
  4339. if (last && last.type === types$1.PSEUDO) {
  4340. var selector = new _selector["default"]({
  4341. source: {
  4342. start: tokenStart(this.tokens[this.position - 1])
  4343. }
  4344. });
  4345. var cache = this.current;
  4346. last.append(selector);
  4347. this.current = selector;
  4348. while (this.position < this.tokens.length && unbalanced) {
  4349. if (this.currToken[_tokenize.FIELDS.TYPE] === tokens.openParenthesis) {
  4350. unbalanced++;
  4351. }
  4352. if (this.currToken[_tokenize.FIELDS.TYPE] === tokens.closeParenthesis) {
  4353. unbalanced--;
  4354. }
  4355. if (unbalanced) {
  4356. this.parse();
  4357. } else {
  4358. this.current.source.end = tokenEnd(this.currToken);
  4359. this.current.parent.source.end = tokenEnd(this.currToken);
  4360. this.position++;
  4361. }
  4362. }
  4363. this.current = cache;
  4364. } else {
  4365. // I think this case should be an error. It's used to implement a basic parse of media queries
  4366. // but I don't think it's a good idea.
  4367. var parenStart = this.currToken;
  4368. var parenValue = "(";
  4369. var parenEnd;
  4370. while (this.position < this.tokens.length && unbalanced) {
  4371. if (this.currToken[_tokenize.FIELDS.TYPE] === tokens.openParenthesis) {
  4372. unbalanced++;
  4373. }
  4374. if (this.currToken[_tokenize.FIELDS.TYPE] === tokens.closeParenthesis) {
  4375. unbalanced--;
  4376. }
  4377. parenEnd = this.currToken;
  4378. parenValue += this.parseParenthesisToken(this.currToken);
  4379. this.position++;
  4380. }
  4381. if (last) {
  4382. last.appendToPropertyAndEscape("value", parenValue, parenValue);
  4383. } else {
  4384. this.newNode(new _string["default"]({
  4385. value: parenValue,
  4386. source: getSource(parenStart[_tokenize.FIELDS.START_LINE], parenStart[_tokenize.FIELDS.START_COL], parenEnd[_tokenize.FIELDS.END_LINE], parenEnd[_tokenize.FIELDS.END_COL]),
  4387. sourceIndex: parenStart[_tokenize.FIELDS.START_POS]
  4388. }));
  4389. }
  4390. }
  4391. if (unbalanced) {
  4392. return this.expected('closing parenthesis', this.currToken[_tokenize.FIELDS.START_POS]);
  4393. }
  4394. };
  4395. _proto.pseudo = function pseudo() {
  4396. var _this4 = this;
  4397. var pseudoStr = '';
  4398. var startingToken = this.currToken;
  4399. while (this.currToken && this.currToken[_tokenize.FIELDS.TYPE] === tokens.colon) {
  4400. pseudoStr += this.content();
  4401. this.position++;
  4402. }
  4403. if (!this.currToken) {
  4404. return this.expected(['pseudo-class', 'pseudo-element'], this.position - 1);
  4405. }
  4406. if (this.currToken[_tokenize.FIELDS.TYPE] === tokens.word) {
  4407. this.splitWord(false, function (first, length) {
  4408. pseudoStr += first;
  4409. _this4.newNode(new _pseudo["default"]({
  4410. value: pseudoStr,
  4411. source: getTokenSourceSpan(startingToken, _this4.currToken),
  4412. sourceIndex: startingToken[_tokenize.FIELDS.START_POS]
  4413. }));
  4414. if (length > 1 && _this4.nextToken && _this4.nextToken[_tokenize.FIELDS.TYPE] === tokens.openParenthesis) {
  4415. _this4.error('Misplaced parenthesis.', {
  4416. index: _this4.nextToken[_tokenize.FIELDS.START_POS]
  4417. });
  4418. }
  4419. });
  4420. } else {
  4421. return this.expected(['pseudo-class', 'pseudo-element'], this.currToken[_tokenize.FIELDS.START_POS]);
  4422. }
  4423. };
  4424. _proto.space = function space() {
  4425. var content = this.content(); // Handle space before and after the selector
  4426. if (this.position === 0 || this.prevToken[_tokenize.FIELDS.TYPE] === tokens.comma || this.prevToken[_tokenize.FIELDS.TYPE] === tokens.openParenthesis || this.current.nodes.every(function (node) {
  4427. return node.type === 'comment';
  4428. })) {
  4429. this.spaces = this.optionalSpace(content);
  4430. this.position++;
  4431. } else if (this.position === this.tokens.length - 1 || this.nextToken[_tokenize.FIELDS.TYPE] === tokens.comma || this.nextToken[_tokenize.FIELDS.TYPE] === tokens.closeParenthesis) {
  4432. this.current.last.spaces.after = this.optionalSpace(content);
  4433. this.position++;
  4434. } else {
  4435. this.combinator();
  4436. }
  4437. };
  4438. _proto.string = function string() {
  4439. var current = this.currToken;
  4440. this.newNode(new _string["default"]({
  4441. value: this.content(),
  4442. source: getTokenSource(current),
  4443. sourceIndex: current[_tokenize.FIELDS.START_POS]
  4444. }));
  4445. this.position++;
  4446. };
  4447. _proto.universal = function universal(namespace) {
  4448. var nextToken = this.nextToken;
  4449. if (nextToken && this.content(nextToken) === '|') {
  4450. this.position++;
  4451. return this.namespace();
  4452. }
  4453. var current = this.currToken;
  4454. this.newNode(new _universal["default"]({
  4455. value: this.content(),
  4456. source: getTokenSource(current),
  4457. sourceIndex: current[_tokenize.FIELDS.START_POS]
  4458. }), namespace);
  4459. this.position++;
  4460. };
  4461. _proto.splitWord = function splitWord(namespace, firstCallback) {
  4462. var _this5 = this;
  4463. var nextToken = this.nextToken;
  4464. var word = this.content();
  4465. while (nextToken && ~[tokens.dollar, tokens.caret, tokens.equals, tokens.word].indexOf(nextToken[_tokenize.FIELDS.TYPE])) {
  4466. this.position++;
  4467. var current = this.content();
  4468. word += current;
  4469. if (current.lastIndexOf('\\') === current.length - 1) {
  4470. var next = this.nextToken;
  4471. if (next && next[_tokenize.FIELDS.TYPE] === tokens.space) {
  4472. word += this.requiredSpace(this.content(next));
  4473. this.position++;
  4474. }
  4475. }
  4476. nextToken = this.nextToken;
  4477. }
  4478. var hasClass = indexesOf(word, '.').filter(function (i) {
  4479. // Allow escaped dot within class name
  4480. var escapedDot = word[i - 1] === '\\'; // Allow decimal numbers percent in @keyframes
  4481. var isKeyframesPercent = /^\d+\.\d+%$/.test(word);
  4482. return !escapedDot && !isKeyframesPercent;
  4483. });
  4484. var hasId = indexesOf(word, '#').filter(function (i) {
  4485. return word[i - 1] !== '\\';
  4486. }); // Eliminate Sass interpolations from the list of id indexes
  4487. var interpolations = indexesOf(word, '#{');
  4488. if (interpolations.length) {
  4489. hasId = hasId.filter(function (hashIndex) {
  4490. return !~interpolations.indexOf(hashIndex);
  4491. });
  4492. }
  4493. var indices = (0, _sortAscending["default"])(uniqs([0].concat(hasClass, hasId)));
  4494. indices.forEach(function (ind, i) {
  4495. var index = indices[i + 1] || word.length;
  4496. var value = word.slice(ind, index);
  4497. if (i === 0 && firstCallback) {
  4498. return firstCallback.call(_this5, value, indices.length);
  4499. }
  4500. var node;
  4501. var current = _this5.currToken;
  4502. var sourceIndex = current[_tokenize.FIELDS.START_POS] + indices[i];
  4503. var source = getSource(current[1], current[2] + ind, current[3], current[2] + (index - 1));
  4504. if (~hasClass.indexOf(ind)) {
  4505. var classNameOpts = {
  4506. value: value.slice(1),
  4507. source: source,
  4508. sourceIndex: sourceIndex
  4509. };
  4510. node = new _className["default"](unescapeProp(classNameOpts, "value"));
  4511. } else if (~hasId.indexOf(ind)) {
  4512. var idOpts = {
  4513. value: value.slice(1),
  4514. source: source,
  4515. sourceIndex: sourceIndex
  4516. };
  4517. node = new _id["default"](unescapeProp(idOpts, "value"));
  4518. } else {
  4519. var tagOpts = {
  4520. value: value,
  4521. source: source,
  4522. sourceIndex: sourceIndex
  4523. };
  4524. unescapeProp(tagOpts, "value");
  4525. node = new _tag["default"](tagOpts);
  4526. }
  4527. _this5.newNode(node, namespace); // Ensure that the namespace is used only once
  4528. namespace = null;
  4529. });
  4530. this.position++;
  4531. };
  4532. _proto.word = function word(namespace) {
  4533. var nextToken = this.nextToken;
  4534. if (nextToken && this.content(nextToken) === '|') {
  4535. this.position++;
  4536. return this.namespace();
  4537. }
  4538. return this.splitWord(namespace);
  4539. };
  4540. _proto.loop = function loop() {
  4541. while (this.position < this.tokens.length) {
  4542. this.parse(true);
  4543. }
  4544. this.current._inferEndPosition();
  4545. return this.root;
  4546. };
  4547. _proto.parse = function parse(throwOnParenthesis) {
  4548. switch (this.currToken[_tokenize.FIELDS.TYPE]) {
  4549. case tokens.space:
  4550. this.space();
  4551. break;
  4552. case tokens.comment:
  4553. this.comment();
  4554. break;
  4555. case tokens.openParenthesis:
  4556. this.parentheses();
  4557. break;
  4558. case tokens.closeParenthesis:
  4559. if (throwOnParenthesis) {
  4560. this.missingParenthesis();
  4561. }
  4562. break;
  4563. case tokens.openSquare:
  4564. this.attribute();
  4565. break;
  4566. case tokens.dollar:
  4567. case tokens.caret:
  4568. case tokens.equals:
  4569. case tokens.word:
  4570. this.word();
  4571. break;
  4572. case tokens.colon:
  4573. this.pseudo();
  4574. break;
  4575. case tokens.comma:
  4576. this.comma();
  4577. break;
  4578. case tokens.asterisk:
  4579. this.universal();
  4580. break;
  4581. case tokens.ampersand:
  4582. this.nesting();
  4583. break;
  4584. case tokens.slash:
  4585. case tokens.combinator:
  4586. this.combinator();
  4587. break;
  4588. case tokens.str:
  4589. this.string();
  4590. break;
  4591. // These cases throw; no break needed.
  4592. case tokens.closeSquare:
  4593. this.missingSquareBracket();
  4594. case tokens.semicolon:
  4595. this.missingBackslash();
  4596. default:
  4597. this.unexpected();
  4598. }
  4599. }
  4600. /**
  4601. * Helpers
  4602. */
  4603. ;
  4604. _proto.expected = function expected(description, index, found) {
  4605. if (Array.isArray(description)) {
  4606. var last = description.pop();
  4607. description = description.join(', ') + " or " + last;
  4608. }
  4609. var an = /^[aeiou]/.test(description[0]) ? 'an' : 'a';
  4610. if (!found) {
  4611. return this.error("Expected " + an + " " + description + ".", {
  4612. index: index
  4613. });
  4614. }
  4615. return this.error("Expected " + an + " " + description + ", found \"" + found + "\" instead.", {
  4616. index: index
  4617. });
  4618. };
  4619. _proto.requiredSpace = function requiredSpace(space) {
  4620. return this.options.lossy ? ' ' : space;
  4621. };
  4622. _proto.optionalSpace = function optionalSpace(space) {
  4623. return this.options.lossy ? '' : space;
  4624. };
  4625. _proto.lossySpace = function lossySpace(space, required) {
  4626. if (this.options.lossy) {
  4627. return required ? ' ' : '';
  4628. } else {
  4629. return space;
  4630. }
  4631. };
  4632. _proto.parseParenthesisToken = function parseParenthesisToken(token) {
  4633. var content = this.content(token);
  4634. if (token[_tokenize.FIELDS.TYPE] === tokens.space) {
  4635. return this.requiredSpace(content);
  4636. } else {
  4637. return content;
  4638. }
  4639. };
  4640. _proto.newNode = function newNode(node, namespace) {
  4641. if (namespace) {
  4642. if (/^ +$/.test(namespace)) {
  4643. if (!this.options.lossy) {
  4644. this.spaces = (this.spaces || '') + namespace;
  4645. }
  4646. namespace = true;
  4647. }
  4648. node.namespace = namespace;
  4649. unescapeProp(node, "namespace");
  4650. }
  4651. if (this.spaces) {
  4652. node.spaces.before = this.spaces;
  4653. this.spaces = '';
  4654. }
  4655. return this.current.append(node);
  4656. };
  4657. _proto.content = function content(token) {
  4658. if (token === void 0) {
  4659. token = this.currToken;
  4660. }
  4661. return this.css.slice(token[_tokenize.FIELDS.START_POS], token[_tokenize.FIELDS.END_POS]);
  4662. };
  4663. /**
  4664. * returns the index of the next non-whitespace, non-comment token.
  4665. * returns -1 if no meaningful token is found.
  4666. */
  4667. _proto.locateNextMeaningfulToken = function locateNextMeaningfulToken(startPosition) {
  4668. if (startPosition === void 0) {
  4669. startPosition = this.position + 1;
  4670. }
  4671. var searchPosition = startPosition;
  4672. while (searchPosition < this.tokens.length) {
  4673. if (WHITESPACE_EQUIV_TOKENS[this.tokens[searchPosition][_tokenize.FIELDS.TYPE]]) {
  4674. searchPosition++;
  4675. continue;
  4676. } else {
  4677. return searchPosition;
  4678. }
  4679. }
  4680. return -1;
  4681. };
  4682. _createClass(Parser, [{
  4683. key: "currToken",
  4684. get: function get() {
  4685. return this.tokens[this.position];
  4686. }
  4687. }, {
  4688. key: "nextToken",
  4689. get: function get() {
  4690. return this.tokens[this.position + 1];
  4691. }
  4692. }, {
  4693. key: "prevToken",
  4694. get: function get() {
  4695. return this.tokens[this.position - 1];
  4696. }
  4697. }]);
  4698. return Parser;
  4699. }();
  4700. exports["default"] = Parser;
  4701. module.exports = exports.default;
  4702. } (parser, parser.exports));
  4703. (function (module, exports) {
  4704. exports.__esModule = true;
  4705. exports["default"] = void 0;
  4706. var _parser = _interopRequireDefault(parser.exports);
  4707. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  4708. var Processor = /*#__PURE__*/function () {
  4709. function Processor(func, options) {
  4710. this.func = func || function noop() {};
  4711. this.funcRes = null;
  4712. this.options = options;
  4713. }
  4714. var _proto = Processor.prototype;
  4715. _proto._shouldUpdateSelector = function _shouldUpdateSelector(rule, options) {
  4716. if (options === void 0) {
  4717. options = {};
  4718. }
  4719. var merged = Object.assign({}, this.options, options);
  4720. if (merged.updateSelector === false) {
  4721. return false;
  4722. } else {
  4723. return typeof rule !== "string";
  4724. }
  4725. };
  4726. _proto._isLossy = function _isLossy(options) {
  4727. if (options === void 0) {
  4728. options = {};
  4729. }
  4730. var merged = Object.assign({}, this.options, options);
  4731. if (merged.lossless === false) {
  4732. return true;
  4733. } else {
  4734. return false;
  4735. }
  4736. };
  4737. _proto._root = function _root(rule, options) {
  4738. if (options === void 0) {
  4739. options = {};
  4740. }
  4741. var parser = new _parser["default"](rule, this._parseOptions(options));
  4742. return parser.root;
  4743. };
  4744. _proto._parseOptions = function _parseOptions(options) {
  4745. return {
  4746. lossy: this._isLossy(options)
  4747. };
  4748. };
  4749. _proto._run = function _run(rule, options) {
  4750. var _this = this;
  4751. if (options === void 0) {
  4752. options = {};
  4753. }
  4754. return new Promise(function (resolve, reject) {
  4755. try {
  4756. var root = _this._root(rule, options);
  4757. Promise.resolve(_this.func(root)).then(function (transform) {
  4758. var string = undefined;
  4759. if (_this._shouldUpdateSelector(rule, options)) {
  4760. string = root.toString();
  4761. rule.selector = string;
  4762. }
  4763. return {
  4764. transform: transform,
  4765. root: root,
  4766. string: string
  4767. };
  4768. }).then(resolve, reject);
  4769. } catch (e) {
  4770. reject(e);
  4771. return;
  4772. }
  4773. });
  4774. };
  4775. _proto._runSync = function _runSync(rule, options) {
  4776. if (options === void 0) {
  4777. options = {};
  4778. }
  4779. var root = this._root(rule, options);
  4780. var transform = this.func(root);
  4781. if (transform && typeof transform.then === "function") {
  4782. throw new Error("Selector processor returned a promise to a synchronous call.");
  4783. }
  4784. var string = undefined;
  4785. if (options.updateSelector && typeof rule !== "string") {
  4786. string = root.toString();
  4787. rule.selector = string;
  4788. }
  4789. return {
  4790. transform: transform,
  4791. root: root,
  4792. string: string
  4793. };
  4794. }
  4795. /**
  4796. * Process rule into a selector AST.
  4797. *
  4798. * @param rule {postcss.Rule | string} The css selector to be processed
  4799. * @param options The options for processing
  4800. * @returns {Promise<parser.Root>} The AST of the selector after processing it.
  4801. */
  4802. ;
  4803. _proto.ast = function ast(rule, options) {
  4804. return this._run(rule, options).then(function (result) {
  4805. return result.root;
  4806. });
  4807. }
  4808. /**
  4809. * Process rule into a selector AST synchronously.
  4810. *
  4811. * @param rule {postcss.Rule | string} The css selector to be processed
  4812. * @param options The options for processing
  4813. * @returns {parser.Root} The AST of the selector after processing it.
  4814. */
  4815. ;
  4816. _proto.astSync = function astSync(rule, options) {
  4817. return this._runSync(rule, options).root;
  4818. }
  4819. /**
  4820. * Process a selector into a transformed value asynchronously
  4821. *
  4822. * @param rule {postcss.Rule | string} The css selector to be processed
  4823. * @param options The options for processing
  4824. * @returns {Promise<any>} The value returned by the processor.
  4825. */
  4826. ;
  4827. _proto.transform = function transform(rule, options) {
  4828. return this._run(rule, options).then(function (result) {
  4829. return result.transform;
  4830. });
  4831. }
  4832. /**
  4833. * Process a selector into a transformed value synchronously.
  4834. *
  4835. * @param rule {postcss.Rule | string} The css selector to be processed
  4836. * @param options The options for processing
  4837. * @returns {any} The value returned by the processor.
  4838. */
  4839. ;
  4840. _proto.transformSync = function transformSync(rule, options) {
  4841. return this._runSync(rule, options).transform;
  4842. }
  4843. /**
  4844. * Process a selector into a new selector string asynchronously.
  4845. *
  4846. * @param rule {postcss.Rule | string} The css selector to be processed
  4847. * @param options The options for processing
  4848. * @returns {string} the selector after processing.
  4849. */
  4850. ;
  4851. _proto.process = function process(rule, options) {
  4852. return this._run(rule, options).then(function (result) {
  4853. return result.string || result.root.toString();
  4854. });
  4855. }
  4856. /**
  4857. * Process a selector into a new selector string synchronously.
  4858. *
  4859. * @param rule {postcss.Rule | string} The css selector to be processed
  4860. * @param options The options for processing
  4861. * @returns {string} the selector after processing.
  4862. */
  4863. ;
  4864. _proto.processSync = function processSync(rule, options) {
  4865. var result = this._runSync(rule, options);
  4866. return result.string || result.root.toString();
  4867. };
  4868. return Processor;
  4869. }();
  4870. exports["default"] = Processor;
  4871. module.exports = exports.default;
  4872. } (processor, processor.exports));
  4873. var selectors = {};
  4874. var constructors = {};
  4875. constructors.__esModule = true;
  4876. constructors.universal = constructors.tag = constructors.string = constructors.selector = constructors.root = constructors.pseudo = constructors.nesting = constructors.id = constructors.comment = constructors.combinator = constructors.className = constructors.attribute = void 0;
  4877. var _attribute = _interopRequireDefault$2(attribute$1);
  4878. var _className = _interopRequireDefault$2(className$1.exports);
  4879. var _combinator = _interopRequireDefault$2(combinator$2.exports);
  4880. var _comment = _interopRequireDefault$2(comment$2.exports);
  4881. var _id = _interopRequireDefault$2(id$1.exports);
  4882. var _nesting = _interopRequireDefault$2(nesting$1.exports);
  4883. var _pseudo = _interopRequireDefault$2(pseudo$1.exports);
  4884. var _root = _interopRequireDefault$2(root$1.exports);
  4885. var _selector = _interopRequireDefault$2(selector$1.exports);
  4886. var _string = _interopRequireDefault$2(string$1.exports);
  4887. var _tag = _interopRequireDefault$2(tag$1.exports);
  4888. var _universal = _interopRequireDefault$2(universal$1.exports);
  4889. function _interopRequireDefault$2(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  4890. var attribute = function attribute(opts) {
  4891. return new _attribute["default"](opts);
  4892. };
  4893. constructors.attribute = attribute;
  4894. var className = function className(opts) {
  4895. return new _className["default"](opts);
  4896. };
  4897. constructors.className = className;
  4898. var combinator = function combinator(opts) {
  4899. return new _combinator["default"](opts);
  4900. };
  4901. constructors.combinator = combinator;
  4902. var comment = function comment(opts) {
  4903. return new _comment["default"](opts);
  4904. };
  4905. constructors.comment = comment;
  4906. var id = function id(opts) {
  4907. return new _id["default"](opts);
  4908. };
  4909. constructors.id = id;
  4910. var nesting = function nesting(opts) {
  4911. return new _nesting["default"](opts);
  4912. };
  4913. constructors.nesting = nesting;
  4914. var pseudo = function pseudo(opts) {
  4915. return new _pseudo["default"](opts);
  4916. };
  4917. constructors.pseudo = pseudo;
  4918. var root = function root(opts) {
  4919. return new _root["default"](opts);
  4920. };
  4921. constructors.root = root;
  4922. var selector = function selector(opts) {
  4923. return new _selector["default"](opts);
  4924. };
  4925. constructors.selector = selector;
  4926. var string = function string(opts) {
  4927. return new _string["default"](opts);
  4928. };
  4929. constructors.string = string;
  4930. var tag = function tag(opts) {
  4931. return new _tag["default"](opts);
  4932. };
  4933. constructors.tag = tag;
  4934. var universal = function universal(opts) {
  4935. return new _universal["default"](opts);
  4936. };
  4937. constructors.universal = universal;
  4938. var guards = {};
  4939. guards.__esModule = true;
  4940. guards.isNode = isNode;
  4941. guards.isPseudoElement = isPseudoElement;
  4942. guards.isPseudoClass = isPseudoClass;
  4943. guards.isContainer = isContainer;
  4944. guards.isNamespace = isNamespace;
  4945. guards.isUniversal = guards.isTag = guards.isString = guards.isSelector = guards.isRoot = guards.isPseudo = guards.isNesting = guards.isIdentifier = guards.isComment = guards.isCombinator = guards.isClassName = guards.isAttribute = void 0;
  4946. var _types = types;
  4947. var _IS_TYPE;
  4948. var IS_TYPE = (_IS_TYPE = {}, _IS_TYPE[_types.ATTRIBUTE] = true, _IS_TYPE[_types.CLASS] = true, _IS_TYPE[_types.COMBINATOR] = true, _IS_TYPE[_types.COMMENT] = true, _IS_TYPE[_types.ID] = true, _IS_TYPE[_types.NESTING] = true, _IS_TYPE[_types.PSEUDO] = true, _IS_TYPE[_types.ROOT] = true, _IS_TYPE[_types.SELECTOR] = true, _IS_TYPE[_types.STRING] = true, _IS_TYPE[_types.TAG] = true, _IS_TYPE[_types.UNIVERSAL] = true, _IS_TYPE);
  4949. function isNode(node) {
  4950. return typeof node === "object" && IS_TYPE[node.type];
  4951. }
  4952. function isNodeType(type, node) {
  4953. return isNode(node) && node.type === type;
  4954. }
  4955. var isAttribute = isNodeType.bind(null, _types.ATTRIBUTE);
  4956. guards.isAttribute = isAttribute;
  4957. var isClassName = isNodeType.bind(null, _types.CLASS);
  4958. guards.isClassName = isClassName;
  4959. var isCombinator = isNodeType.bind(null, _types.COMBINATOR);
  4960. guards.isCombinator = isCombinator;
  4961. var isComment = isNodeType.bind(null, _types.COMMENT);
  4962. guards.isComment = isComment;
  4963. var isIdentifier = isNodeType.bind(null, _types.ID);
  4964. guards.isIdentifier = isIdentifier;
  4965. var isNesting = isNodeType.bind(null, _types.NESTING);
  4966. guards.isNesting = isNesting;
  4967. var isPseudo = isNodeType.bind(null, _types.PSEUDO);
  4968. guards.isPseudo = isPseudo;
  4969. var isRoot = isNodeType.bind(null, _types.ROOT);
  4970. guards.isRoot = isRoot;
  4971. var isSelector = isNodeType.bind(null, _types.SELECTOR);
  4972. guards.isSelector = isSelector;
  4973. var isString = isNodeType.bind(null, _types.STRING);
  4974. guards.isString = isString;
  4975. var isTag = isNodeType.bind(null, _types.TAG);
  4976. guards.isTag = isTag;
  4977. var isUniversal = isNodeType.bind(null, _types.UNIVERSAL);
  4978. guards.isUniversal = isUniversal;
  4979. function isPseudoElement(node) {
  4980. return isPseudo(node) && node.value && (node.value.startsWith("::") || node.value.toLowerCase() === ":before" || node.value.toLowerCase() === ":after" || node.value.toLowerCase() === ":first-letter" || node.value.toLowerCase() === ":first-line");
  4981. }
  4982. function isPseudoClass(node) {
  4983. return isPseudo(node) && !isPseudoElement(node);
  4984. }
  4985. function isContainer(node) {
  4986. return !!(isNode(node) && node.walk);
  4987. }
  4988. function isNamespace(node) {
  4989. return isAttribute(node) || isTag(node);
  4990. }
  4991. (function (exports) {
  4992. exports.__esModule = true;
  4993. var _types = types;
  4994. Object.keys(_types).forEach(function (key) {
  4995. if (key === "default" || key === "__esModule") return;
  4996. if (key in exports && exports[key] === _types[key]) return;
  4997. exports[key] = _types[key];
  4998. });
  4999. var _constructors = constructors;
  5000. Object.keys(_constructors).forEach(function (key) {
  5001. if (key === "default" || key === "__esModule") return;
  5002. if (key in exports && exports[key] === _constructors[key]) return;
  5003. exports[key] = _constructors[key];
  5004. });
  5005. var _guards = guards;
  5006. Object.keys(_guards).forEach(function (key) {
  5007. if (key === "default" || key === "__esModule") return;
  5008. if (key in exports && exports[key] === _guards[key]) return;
  5009. exports[key] = _guards[key];
  5010. });
  5011. } (selectors));
  5012. (function (module, exports) {
  5013. exports.__esModule = true;
  5014. exports["default"] = void 0;
  5015. var _processor = _interopRequireDefault(processor.exports);
  5016. var selectors$1 = _interopRequireWildcard(selectors);
  5017. function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
  5018. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
  5019. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  5020. var parser = function parser(processor) {
  5021. return new _processor["default"](processor);
  5022. };
  5023. Object.assign(parser, selectors$1);
  5024. delete parser.__esModule;
  5025. var _default = parser;
  5026. exports["default"] = _default;
  5027. module.exports = exports.default;
  5028. } (dist, dist.exports));
  5029. const selectorParser$1 = dist.exports;
  5030. const valueParser = lib;
  5031. const { extractICSS } = src$4;
  5032. const isSpacing = (node) => node.type === "combinator" && node.value === " ";
  5033. function normalizeNodeArray(nodes) {
  5034. const array = [];
  5035. nodes.forEach((x) => {
  5036. if (Array.isArray(x)) {
  5037. normalizeNodeArray(x).forEach((item) => {
  5038. array.push(item);
  5039. });
  5040. } else if (x) {
  5041. array.push(x);
  5042. }
  5043. });
  5044. if (array.length > 0 && isSpacing(array[array.length - 1])) {
  5045. array.pop();
  5046. }
  5047. return array;
  5048. }
  5049. function localizeNode(rule, mode, localAliasMap) {
  5050. const transform = (node, context) => {
  5051. if (context.ignoreNextSpacing && !isSpacing(node)) {
  5052. throw new Error("Missing whitespace after " + context.ignoreNextSpacing);
  5053. }
  5054. if (context.enforceNoSpacing && isSpacing(node)) {
  5055. throw new Error("Missing whitespace before " + context.enforceNoSpacing);
  5056. }
  5057. let newNodes;
  5058. switch (node.type) {
  5059. case "root": {
  5060. let resultingGlobal;
  5061. context.hasPureGlobals = false;
  5062. newNodes = node.nodes.map((n) => {
  5063. const nContext = {
  5064. global: context.global,
  5065. lastWasSpacing: true,
  5066. hasLocals: false,
  5067. explicit: false,
  5068. };
  5069. n = transform(n, nContext);
  5070. if (typeof resultingGlobal === "undefined") {
  5071. resultingGlobal = nContext.global;
  5072. } else if (resultingGlobal !== nContext.global) {
  5073. throw new Error(
  5074. 'Inconsistent rule global/local result in rule "' +
  5075. node +
  5076. '" (multiple selectors must result in the same mode for the rule)'
  5077. );
  5078. }
  5079. if (!nContext.hasLocals) {
  5080. context.hasPureGlobals = true;
  5081. }
  5082. return n;
  5083. });
  5084. context.global = resultingGlobal;
  5085. node.nodes = normalizeNodeArray(newNodes);
  5086. break;
  5087. }
  5088. case "selector": {
  5089. newNodes = node.map((childNode) => transform(childNode, context));
  5090. node = node.clone();
  5091. node.nodes = normalizeNodeArray(newNodes);
  5092. break;
  5093. }
  5094. case "combinator": {
  5095. if (isSpacing(node)) {
  5096. if (context.ignoreNextSpacing) {
  5097. context.ignoreNextSpacing = false;
  5098. context.lastWasSpacing = false;
  5099. context.enforceNoSpacing = false;
  5100. return null;
  5101. }
  5102. context.lastWasSpacing = true;
  5103. return node;
  5104. }
  5105. break;
  5106. }
  5107. case "pseudo": {
  5108. let childContext;
  5109. const isNested = !!node.length;
  5110. const isScoped = node.value === ":local" || node.value === ":global";
  5111. const isImportExport =
  5112. node.value === ":import" || node.value === ":export";
  5113. if (isImportExport) {
  5114. context.hasLocals = true;
  5115. // :local(.foo)
  5116. } else if (isNested) {
  5117. if (isScoped) {
  5118. if (node.nodes.length === 0) {
  5119. throw new Error(`${node.value}() can't be empty`);
  5120. }
  5121. if (context.inside) {
  5122. throw new Error(
  5123. `A ${node.value} is not allowed inside of a ${context.inside}(...)`
  5124. );
  5125. }
  5126. childContext = {
  5127. global: node.value === ":global",
  5128. inside: node.value,
  5129. hasLocals: false,
  5130. explicit: true,
  5131. };
  5132. newNodes = node
  5133. .map((childNode) => transform(childNode, childContext))
  5134. .reduce((acc, next) => acc.concat(next.nodes), []);
  5135. if (newNodes.length) {
  5136. const { before, after } = node.spaces;
  5137. const first = newNodes[0];
  5138. const last = newNodes[newNodes.length - 1];
  5139. first.spaces = { before, after: first.spaces.after };
  5140. last.spaces = { before: last.spaces.before, after };
  5141. }
  5142. node = newNodes;
  5143. break;
  5144. } else {
  5145. childContext = {
  5146. global: context.global,
  5147. inside: context.inside,
  5148. lastWasSpacing: true,
  5149. hasLocals: false,
  5150. explicit: context.explicit,
  5151. };
  5152. newNodes = node.map((childNode) =>
  5153. transform(childNode, childContext)
  5154. );
  5155. node = node.clone();
  5156. node.nodes = normalizeNodeArray(newNodes);
  5157. if (childContext.hasLocals) {
  5158. context.hasLocals = true;
  5159. }
  5160. }
  5161. break;
  5162. //:local .foo .bar
  5163. } else if (isScoped) {
  5164. if (context.inside) {
  5165. throw new Error(
  5166. `A ${node.value} is not allowed inside of a ${context.inside}(...)`
  5167. );
  5168. }
  5169. const addBackSpacing = !!node.spaces.before;
  5170. context.ignoreNextSpacing = context.lastWasSpacing
  5171. ? node.value
  5172. : false;
  5173. context.enforceNoSpacing = context.lastWasSpacing
  5174. ? false
  5175. : node.value;
  5176. context.global = node.value === ":global";
  5177. context.explicit = true;
  5178. // because this node has spacing that is lost when we remove it
  5179. // we make up for it by adding an extra combinator in since adding
  5180. // spacing on the parent selector doesn't work
  5181. return addBackSpacing
  5182. ? selectorParser$1.combinator({ value: " " })
  5183. : null;
  5184. }
  5185. break;
  5186. }
  5187. case "id":
  5188. case "class": {
  5189. if (!node.value) {
  5190. throw new Error("Invalid class or id selector syntax");
  5191. }
  5192. if (context.global) {
  5193. break;
  5194. }
  5195. const isImportedValue = localAliasMap.has(node.value);
  5196. const isImportedWithExplicitScope = isImportedValue && context.explicit;
  5197. if (!isImportedValue || isImportedWithExplicitScope) {
  5198. const innerNode = node.clone();
  5199. innerNode.spaces = { before: "", after: "" };
  5200. node = selectorParser$1.pseudo({
  5201. value: ":local",
  5202. nodes: [innerNode],
  5203. spaces: node.spaces,
  5204. });
  5205. context.hasLocals = true;
  5206. }
  5207. break;
  5208. }
  5209. }
  5210. context.lastWasSpacing = false;
  5211. context.ignoreNextSpacing = false;
  5212. context.enforceNoSpacing = false;
  5213. return node;
  5214. };
  5215. const rootContext = {
  5216. global: mode === "global",
  5217. hasPureGlobals: false,
  5218. };
  5219. rootContext.selector = selectorParser$1((root) => {
  5220. transform(root, rootContext);
  5221. }).processSync(rule, { updateSelector: false, lossless: true });
  5222. return rootContext;
  5223. }
  5224. function localizeDeclNode(node, context) {
  5225. switch (node.type) {
  5226. case "word":
  5227. if (context.localizeNextItem) {
  5228. if (!context.localAliasMap.has(node.value)) {
  5229. node.value = ":local(" + node.value + ")";
  5230. context.localizeNextItem = false;
  5231. }
  5232. }
  5233. break;
  5234. case "function":
  5235. if (
  5236. context.options &&
  5237. context.options.rewriteUrl &&
  5238. node.value.toLowerCase() === "url"
  5239. ) {
  5240. node.nodes.map((nestedNode) => {
  5241. if (nestedNode.type !== "string" && nestedNode.type !== "word") {
  5242. return;
  5243. }
  5244. let newUrl = context.options.rewriteUrl(
  5245. context.global,
  5246. nestedNode.value
  5247. );
  5248. switch (nestedNode.type) {
  5249. case "string":
  5250. if (nestedNode.quote === "'") {
  5251. newUrl = newUrl.replace(/(\\)/g, "\\$1").replace(/'/g, "\\'");
  5252. }
  5253. if (nestedNode.quote === '"') {
  5254. newUrl = newUrl.replace(/(\\)/g, "\\$1").replace(/"/g, '\\"');
  5255. }
  5256. break;
  5257. case "word":
  5258. newUrl = newUrl.replace(/("|'|\)|\\)/g, "\\$1");
  5259. break;
  5260. }
  5261. nestedNode.value = newUrl;
  5262. });
  5263. }
  5264. break;
  5265. }
  5266. return node;
  5267. }
  5268. function isWordAFunctionArgument(wordNode, functionNode) {
  5269. return functionNode
  5270. ? functionNode.nodes.some(
  5271. (functionNodeChild) =>
  5272. functionNodeChild.sourceIndex === wordNode.sourceIndex
  5273. )
  5274. : false;
  5275. }
  5276. function localizeDeclarationValues(localize, declaration, context) {
  5277. const valueNodes = valueParser(declaration.value);
  5278. valueNodes.walk((node, index, nodes) => {
  5279. const subContext = {
  5280. options: context.options,
  5281. global: context.global,
  5282. localizeNextItem: localize && !context.global,
  5283. localAliasMap: context.localAliasMap,
  5284. };
  5285. nodes[index] = localizeDeclNode(node, subContext);
  5286. });
  5287. declaration.value = valueNodes.toString();
  5288. }
  5289. function localizeDeclaration(declaration, context) {
  5290. const isAnimation = /animation$/i.test(declaration.prop);
  5291. if (isAnimation) {
  5292. const validIdent = /^-?[_a-z][_a-z0-9-]*$/i;
  5293. /*
  5294. The spec defines some keywords that you can use to describe properties such as the timing
  5295. function. These are still valid animation names, so as long as there is a property that accepts
  5296. a keyword, it is given priority. Only when all the properties that can take a keyword are
  5297. exhausted can the animation name be set to the keyword. I.e.
  5298. animation: infinite infinite;
  5299. The animation will repeat an infinite number of times from the first argument, and will have an
  5300. animation name of infinite from the second.
  5301. */
  5302. const animationKeywords = {
  5303. $alternate: 1,
  5304. "$alternate-reverse": 1,
  5305. $backwards: 1,
  5306. $both: 1,
  5307. $ease: 1,
  5308. "$ease-in": 1,
  5309. "$ease-in-out": 1,
  5310. "$ease-out": 1,
  5311. $forwards: 1,
  5312. $infinite: 1,
  5313. $linear: 1,
  5314. $none: Infinity, // No matter how many times you write none, it will never be an animation name
  5315. $normal: 1,
  5316. $paused: 1,
  5317. $reverse: 1,
  5318. $running: 1,
  5319. "$step-end": 1,
  5320. "$step-start": 1,
  5321. $initial: Infinity,
  5322. $inherit: Infinity,
  5323. $unset: Infinity,
  5324. };
  5325. let parsedAnimationKeywords = {};
  5326. let stepsFunctionNode = null;
  5327. const valueNodes = valueParser(declaration.value).walk((node) => {
  5328. /* If div-token appeared (represents as comma ','), a possibility of an animation-keywords should be reflesh. */
  5329. if (node.type === "div") {
  5330. parsedAnimationKeywords = {};
  5331. }
  5332. if (node.type === "function" && node.value.toLowerCase() === "steps") {
  5333. stepsFunctionNode = node;
  5334. }
  5335. const value =
  5336. node.type === "word" &&
  5337. !isWordAFunctionArgument(node, stepsFunctionNode)
  5338. ? node.value.toLowerCase()
  5339. : null;
  5340. let shouldParseAnimationName = false;
  5341. if (value && validIdent.test(value)) {
  5342. if ("$" + value in animationKeywords) {
  5343. parsedAnimationKeywords["$" + value] =
  5344. "$" + value in parsedAnimationKeywords
  5345. ? parsedAnimationKeywords["$" + value] + 1
  5346. : 0;
  5347. shouldParseAnimationName =
  5348. parsedAnimationKeywords["$" + value] >=
  5349. animationKeywords["$" + value];
  5350. } else {
  5351. shouldParseAnimationName = true;
  5352. }
  5353. }
  5354. const subContext = {
  5355. options: context.options,
  5356. global: context.global,
  5357. localizeNextItem: shouldParseAnimationName && !context.global,
  5358. localAliasMap: context.localAliasMap,
  5359. };
  5360. return localizeDeclNode(node, subContext);
  5361. });
  5362. declaration.value = valueNodes.toString();
  5363. return;
  5364. }
  5365. const isAnimationName = /animation(-name)?$/i.test(declaration.prop);
  5366. if (isAnimationName) {
  5367. return localizeDeclarationValues(true, declaration, context);
  5368. }
  5369. const hasUrl = /url\(/i.test(declaration.value);
  5370. if (hasUrl) {
  5371. return localizeDeclarationValues(false, declaration, context);
  5372. }
  5373. }
  5374. src$2.exports = (options = {}) => {
  5375. if (
  5376. options &&
  5377. options.mode &&
  5378. options.mode !== "global" &&
  5379. options.mode !== "local" &&
  5380. options.mode !== "pure"
  5381. ) {
  5382. throw new Error(
  5383. 'options.mode must be either "global", "local" or "pure" (default "local")'
  5384. );
  5385. }
  5386. const pureMode = options && options.mode === "pure";
  5387. const globalMode = options && options.mode === "global";
  5388. return {
  5389. postcssPlugin: "postcss-modules-local-by-default",
  5390. prepare() {
  5391. const localAliasMap = new Map();
  5392. return {
  5393. Once(root) {
  5394. const { icssImports } = extractICSS(root, false);
  5395. Object.keys(icssImports).forEach((key) => {
  5396. Object.keys(icssImports[key]).forEach((prop) => {
  5397. localAliasMap.set(prop, icssImports[key][prop]);
  5398. });
  5399. });
  5400. root.walkAtRules((atRule) => {
  5401. if (/keyframes$/i.test(atRule.name)) {
  5402. const globalMatch = /^\s*:global\s*\((.+)\)\s*$/.exec(
  5403. atRule.params
  5404. );
  5405. const localMatch = /^\s*:local\s*\((.+)\)\s*$/.exec(
  5406. atRule.params
  5407. );
  5408. let globalKeyframes = globalMode;
  5409. if (globalMatch) {
  5410. if (pureMode) {
  5411. throw atRule.error(
  5412. "@keyframes :global(...) is not allowed in pure mode"
  5413. );
  5414. }
  5415. atRule.params = globalMatch[1];
  5416. globalKeyframes = true;
  5417. } else if (localMatch) {
  5418. atRule.params = localMatch[0];
  5419. globalKeyframes = false;
  5420. } else if (!globalMode) {
  5421. if (atRule.params && !localAliasMap.has(atRule.params)) {
  5422. atRule.params = ":local(" + atRule.params + ")";
  5423. }
  5424. }
  5425. atRule.walkDecls((declaration) => {
  5426. localizeDeclaration(declaration, {
  5427. localAliasMap,
  5428. options: options,
  5429. global: globalKeyframes,
  5430. });
  5431. });
  5432. } else if (atRule.nodes) {
  5433. atRule.nodes.forEach((declaration) => {
  5434. if (declaration.type === "decl") {
  5435. localizeDeclaration(declaration, {
  5436. localAliasMap,
  5437. options: options,
  5438. global: globalMode,
  5439. });
  5440. }
  5441. });
  5442. }
  5443. });
  5444. root.walkRules((rule) => {
  5445. if (
  5446. rule.parent &&
  5447. rule.parent.type === "atrule" &&
  5448. /keyframes$/i.test(rule.parent.name)
  5449. ) {
  5450. // ignore keyframe rules
  5451. return;
  5452. }
  5453. const context = localizeNode(rule, options.mode, localAliasMap);
  5454. context.options = options;
  5455. context.localAliasMap = localAliasMap;
  5456. if (pureMode && context.hasPureGlobals) {
  5457. throw rule.error(
  5458. 'Selector "' +
  5459. rule.selector +
  5460. '" is not pure ' +
  5461. "(pure selectors must contain at least one local class or id)"
  5462. );
  5463. }
  5464. rule.selector = context.selector;
  5465. // Less-syntax mixins parse as rules with no nodes
  5466. if (rule.nodes) {
  5467. rule.nodes.forEach((declaration) =>
  5468. localizeDeclaration(declaration, context)
  5469. );
  5470. }
  5471. });
  5472. },
  5473. };
  5474. },
  5475. };
  5476. };
  5477. src$2.exports.postcss = true;
  5478. const selectorParser = dist.exports;
  5479. const hasOwnProperty = Object.prototype.hasOwnProperty;
  5480. function getSingleLocalNamesForComposes(root) {
  5481. return root.nodes.map((node) => {
  5482. if (node.type !== "selector" || node.nodes.length !== 1) {
  5483. throw new Error(
  5484. `composition is only allowed when selector is single :local class name not in "${root}"`
  5485. );
  5486. }
  5487. node = node.nodes[0];
  5488. if (
  5489. node.type !== "pseudo" ||
  5490. node.value !== ":local" ||
  5491. node.nodes.length !== 1
  5492. ) {
  5493. throw new Error(
  5494. 'composition is only allowed when selector is single :local class name not in "' +
  5495. root +
  5496. '", "' +
  5497. node +
  5498. '" is weird'
  5499. );
  5500. }
  5501. node = node.first;
  5502. if (node.type !== "selector" || node.length !== 1) {
  5503. throw new Error(
  5504. 'composition is only allowed when selector is single :local class name not in "' +
  5505. root +
  5506. '", "' +
  5507. node +
  5508. '" is weird'
  5509. );
  5510. }
  5511. node = node.first;
  5512. if (node.type !== "class") {
  5513. // 'id' is not possible, because you can't compose ids
  5514. throw new Error(
  5515. 'composition is only allowed when selector is single :local class name not in "' +
  5516. root +
  5517. '", "' +
  5518. node +
  5519. '" is weird'
  5520. );
  5521. }
  5522. return node.value;
  5523. });
  5524. }
  5525. const whitespace = "[\\x20\\t\\r\\n\\f]";
  5526. const unescapeRegExp = new RegExp(
  5527. "\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)",
  5528. "ig"
  5529. );
  5530. function unescape(str) {
  5531. return str.replace(unescapeRegExp, (_, escaped, escapedWhitespace) => {
  5532. const high = "0x" + escaped - 0x10000;
  5533. // NaN means non-codepoint
  5534. // Workaround erroneous numeric interpretation of +"0x"
  5535. return high !== high || escapedWhitespace
  5536. ? escaped
  5537. : high < 0
  5538. ? // BMP codepoint
  5539. String.fromCharCode(high + 0x10000)
  5540. : // Supplemental Plane codepoint (surrogate pair)
  5541. String.fromCharCode((high >> 10) | 0xd800, (high & 0x3ff) | 0xdc00);
  5542. });
  5543. }
  5544. const plugin = (options = {}) => {
  5545. const generateScopedName =
  5546. (options && options.generateScopedName) || plugin.generateScopedName;
  5547. const generateExportEntry =
  5548. (options && options.generateExportEntry) || plugin.generateExportEntry;
  5549. const exportGlobals = options && options.exportGlobals;
  5550. return {
  5551. postcssPlugin: "postcss-modules-scope",
  5552. Once(root, { rule }) {
  5553. const exports = Object.create(null);
  5554. function exportScopedName(name, rawName) {
  5555. const scopedName = generateScopedName(
  5556. rawName ? rawName : name,
  5557. root.source.input.from,
  5558. root.source.input.css
  5559. );
  5560. const exportEntry = generateExportEntry(
  5561. rawName ? rawName : name,
  5562. scopedName,
  5563. root.source.input.from,
  5564. root.source.input.css
  5565. );
  5566. const { key, value } = exportEntry;
  5567. exports[key] = exports[key] || [];
  5568. if (exports[key].indexOf(value) < 0) {
  5569. exports[key].push(value);
  5570. }
  5571. return scopedName;
  5572. }
  5573. function localizeNode(node) {
  5574. switch (node.type) {
  5575. case "selector":
  5576. node.nodes = node.map(localizeNode);
  5577. return node;
  5578. case "class":
  5579. return selectorParser.className({
  5580. value: exportScopedName(
  5581. node.value,
  5582. node.raws && node.raws.value ? node.raws.value : null
  5583. ),
  5584. });
  5585. case "id": {
  5586. return selectorParser.id({
  5587. value: exportScopedName(
  5588. node.value,
  5589. node.raws && node.raws.value ? node.raws.value : null
  5590. ),
  5591. });
  5592. }
  5593. }
  5594. throw new Error(
  5595. `${node.type} ("${node}") is not allowed in a :local block`
  5596. );
  5597. }
  5598. function traverseNode(node) {
  5599. switch (node.type) {
  5600. case "pseudo":
  5601. if (node.value === ":local") {
  5602. if (node.nodes.length !== 1) {
  5603. throw new Error('Unexpected comma (",") in :local block');
  5604. }
  5605. const selector = localizeNode(node.first);
  5606. // move the spaces that were around the psuedo selector to the first
  5607. // non-container node
  5608. selector.first.spaces = node.spaces;
  5609. const nextNode = node.next();
  5610. if (
  5611. nextNode &&
  5612. nextNode.type === "combinator" &&
  5613. nextNode.value === " " &&
  5614. /\\[A-F0-9]{1,6}$/.test(selector.last.value)
  5615. ) {
  5616. selector.last.spaces.after = " ";
  5617. }
  5618. node.replaceWith(selector);
  5619. return;
  5620. }
  5621. /* falls through */
  5622. case "root":
  5623. case "selector": {
  5624. node.each(traverseNode);
  5625. break;
  5626. }
  5627. case "id":
  5628. case "class":
  5629. if (exportGlobals) {
  5630. exports[node.value] = [node.value];
  5631. }
  5632. break;
  5633. }
  5634. return node;
  5635. }
  5636. // Find any :import and remember imported names
  5637. const importedNames = {};
  5638. root.walkRules(/^:import\(.+\)$/, (rule) => {
  5639. rule.walkDecls((decl) => {
  5640. importedNames[decl.prop] = true;
  5641. });
  5642. });
  5643. // Find any :local selectors
  5644. root.walkRules((rule) => {
  5645. let parsedSelector = selectorParser().astSync(rule);
  5646. rule.selector = traverseNode(parsedSelector.clone()).toString();
  5647. rule.walkDecls(/composes|compose-with/i, (decl) => {
  5648. const localNames = getSingleLocalNamesForComposes(parsedSelector);
  5649. const classes = decl.value.split(/\s+/);
  5650. classes.forEach((className) => {
  5651. const global = /^global\(([^)]+)\)$/.exec(className);
  5652. if (global) {
  5653. localNames.forEach((exportedName) => {
  5654. exports[exportedName].push(global[1]);
  5655. });
  5656. } else if (hasOwnProperty.call(importedNames, className)) {
  5657. localNames.forEach((exportedName) => {
  5658. exports[exportedName].push(className);
  5659. });
  5660. } else if (hasOwnProperty.call(exports, className)) {
  5661. localNames.forEach((exportedName) => {
  5662. exports[className].forEach((item) => {
  5663. exports[exportedName].push(item);
  5664. });
  5665. });
  5666. } else {
  5667. throw decl.error(
  5668. `referenced class name "${className}" in ${decl.prop} not found`
  5669. );
  5670. }
  5671. });
  5672. decl.remove();
  5673. });
  5674. // Find any :local values
  5675. rule.walkDecls((decl) => {
  5676. if (!/:local\s*\((.+?)\)/.test(decl.value)) {
  5677. return;
  5678. }
  5679. let tokens = decl.value.split(/(,|'[^']*'|"[^"]*")/);
  5680. tokens = tokens.map((token, idx) => {
  5681. if (idx === 0 || tokens[idx - 1] === ",") {
  5682. let result = token;
  5683. const localMatch = /:local\s*\((.+?)\)/.exec(token);
  5684. if (localMatch) {
  5685. const input = localMatch.input;
  5686. const matchPattern = localMatch[0];
  5687. const matchVal = localMatch[1];
  5688. const newVal = exportScopedName(matchVal);
  5689. result = input.replace(matchPattern, newVal);
  5690. } else {
  5691. return token;
  5692. }
  5693. return result;
  5694. } else {
  5695. return token;
  5696. }
  5697. });
  5698. decl.value = tokens.join("");
  5699. });
  5700. });
  5701. // Find any :local keyframes
  5702. root.walkAtRules(/keyframes$/i, (atRule) => {
  5703. const localMatch = /^\s*:local\s*\((.+?)\)\s*$/.exec(atRule.params);
  5704. if (!localMatch) {
  5705. return;
  5706. }
  5707. atRule.params = exportScopedName(localMatch[1]);
  5708. });
  5709. // If we found any :locals, insert an :export rule
  5710. const exportedNames = Object.keys(exports);
  5711. if (exportedNames.length > 0) {
  5712. const exportRule = rule({ selector: ":export" });
  5713. exportedNames.forEach((exportedName) =>
  5714. exportRule.append({
  5715. prop: exportedName,
  5716. value: exports[exportedName].join(" "),
  5717. raws: { before: "\n " },
  5718. })
  5719. );
  5720. root.append(exportRule);
  5721. }
  5722. },
  5723. };
  5724. };
  5725. plugin.postcss = true;
  5726. plugin.generateScopedName = function (name, path) {
  5727. const sanitisedPath = path
  5728. .replace(/\.[^./\\]+$/, "")
  5729. .replace(/[\W_]+/g, "_")
  5730. .replace(/^_|_$/g, "");
  5731. return `_${sanitisedPath}__${name}`.trim();
  5732. };
  5733. plugin.generateExportEntry = function (name, scopedName) {
  5734. return {
  5735. key: unescape(name),
  5736. value: unescape(scopedName),
  5737. };
  5738. };
  5739. var src$1 = plugin;
  5740. function hash(str) {
  5741. var hash = 5381,
  5742. i = str.length;
  5743. while(i) {
  5744. hash = (hash * 33) ^ str.charCodeAt(--i);
  5745. }
  5746. /* JavaScript does bitwise operations (like XOR, above) on 32-bit signed
  5747. * integers. Since we want the results to be always positive, convert the
  5748. * signed int to an unsigned by doing an unsigned bitshift. */
  5749. return hash >>> 0;
  5750. }
  5751. var stringHash = hash;
  5752. var src = {exports: {}};
  5753. const ICSSUtils = src$4;
  5754. const matchImports = /^(.+?|\([\s\S]+?\))\s+from\s+("[^"]*"|'[^']*'|[\w-]+)$/;
  5755. const matchValueDefinition = /(?:\s+|^)([\w-]+):?(.*?)$/;
  5756. const matchImport = /^([\w-]+)(?:\s+as\s+([\w-]+))?/;
  5757. src.exports = (options) => {
  5758. let importIndex = 0;
  5759. const createImportedName =
  5760. (options && options.createImportedName) ||
  5761. ((importName /*, path*/) =>
  5762. `i__const_${importName.replace(/\W/g, "_")}_${importIndex++}`);
  5763. return {
  5764. postcssPlugin: "postcss-modules-values",
  5765. prepare(result) {
  5766. const importAliases = [];
  5767. const definitions = {};
  5768. return {
  5769. Once(root, postcss) {
  5770. root.walkAtRules(/value/i, (atRule) => {
  5771. const matches = atRule.params.match(matchImports);
  5772. if (matches) {
  5773. let [, /*match*/ aliases, path] = matches;
  5774. // We can use constants for path names
  5775. if (definitions[path]) {
  5776. path = definitions[path];
  5777. }
  5778. const imports = aliases
  5779. .replace(/^\(\s*([\s\S]+)\s*\)$/, "$1")
  5780. .split(/\s*,\s*/)
  5781. .map((alias) => {
  5782. const tokens = matchImport.exec(alias);
  5783. if (tokens) {
  5784. const [, /*match*/ theirName, myName = theirName] = tokens;
  5785. const importedName = createImportedName(myName);
  5786. definitions[myName] = importedName;
  5787. return { theirName, importedName };
  5788. } else {
  5789. throw new Error(`@import statement "${alias}" is invalid!`);
  5790. }
  5791. });
  5792. importAliases.push({ path, imports });
  5793. atRule.remove();
  5794. return;
  5795. }
  5796. if (atRule.params.indexOf("@value") !== -1) {
  5797. result.warn("Invalid value definition: " + atRule.params);
  5798. }
  5799. let [, key, value] = `${atRule.params}${atRule.raws.between}`.match(
  5800. matchValueDefinition
  5801. );
  5802. const normalizedValue = value.replace(/\/\*((?!\*\/).*?)\*\//g, "");
  5803. if (normalizedValue.length === 0) {
  5804. result.warn("Invalid value definition: " + atRule.params);
  5805. atRule.remove();
  5806. return;
  5807. }
  5808. let isOnlySpace = /^\s+$/.test(normalizedValue);
  5809. if (!isOnlySpace) {
  5810. value = value.trim();
  5811. }
  5812. // Add to the definitions, knowing that values can refer to each other
  5813. definitions[key] = ICSSUtils.replaceValueSymbols(
  5814. value,
  5815. definitions
  5816. );
  5817. atRule.remove();
  5818. });
  5819. /* If we have no definitions, don't continue */
  5820. if (!Object.keys(definitions).length) {
  5821. return;
  5822. }
  5823. /* Perform replacements */
  5824. ICSSUtils.replaceSymbols(root, definitions);
  5825. /* We want to export anything defined by now, but don't add it to the CSS yet or it well get picked up by the replacement stuff */
  5826. const exportDeclarations = Object.keys(definitions).map((key) =>
  5827. postcss.decl({
  5828. value: definitions[key],
  5829. prop: key,
  5830. raws: { before: "\n " },
  5831. })
  5832. );
  5833. /* Add export rules if any */
  5834. if (exportDeclarations.length > 0) {
  5835. const exportRule = postcss.rule({
  5836. selector: ":export",
  5837. raws: { after: "\n" },
  5838. });
  5839. exportRule.append(exportDeclarations);
  5840. root.prepend(exportRule);
  5841. }
  5842. /* Add import rules */
  5843. importAliases.reverse().forEach(({ path, imports }) => {
  5844. const importRule = postcss.rule({
  5845. selector: `:import(${path})`,
  5846. raws: { after: "\n" },
  5847. });
  5848. imports.forEach(({ theirName, importedName }) => {
  5849. importRule.append({
  5850. value: theirName,
  5851. prop: importedName,
  5852. raws: { before: "\n " },
  5853. });
  5854. });
  5855. root.prepend(importRule);
  5856. });
  5857. },
  5858. };
  5859. },
  5860. };
  5861. };
  5862. src.exports.postcss = true;
  5863. Object.defineProperty(scoping, "__esModule", {
  5864. value: true
  5865. });
  5866. scoping.behaviours = void 0;
  5867. scoping.getDefaultPlugins = getDefaultPlugins;
  5868. scoping.getDefaultScopeBehaviour = getDefaultScopeBehaviour;
  5869. scoping.getScopedNameGenerator = getScopedNameGenerator;
  5870. var _postcssModulesExtractImports = _interopRequireDefault$1(src$3.exports);
  5871. var _genericNames = _interopRequireDefault$1(genericNames);
  5872. var _postcssModulesLocalByDefault = _interopRequireDefault$1(src$2.exports);
  5873. var _postcssModulesScope = _interopRequireDefault$1(src$1);
  5874. var _stringHash = _interopRequireDefault$1(stringHash);
  5875. var _postcssModulesValues = _interopRequireDefault$1(src.exports);
  5876. function _interopRequireDefault$1(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  5877. const behaviours = {
  5878. LOCAL: "local",
  5879. GLOBAL: "global"
  5880. };
  5881. scoping.behaviours = behaviours;
  5882. function getDefaultPlugins({
  5883. behaviour,
  5884. generateScopedName,
  5885. exportGlobals
  5886. }) {
  5887. const scope = (0, _postcssModulesScope.default)({
  5888. generateScopedName,
  5889. exportGlobals
  5890. });
  5891. const plugins = {
  5892. [behaviours.LOCAL]: [_postcssModulesValues.default, (0, _postcssModulesLocalByDefault.default)({
  5893. mode: "local"
  5894. }), _postcssModulesExtractImports.default, scope],
  5895. [behaviours.GLOBAL]: [_postcssModulesValues.default, (0, _postcssModulesLocalByDefault.default)({
  5896. mode: "global"
  5897. }), _postcssModulesExtractImports.default, scope]
  5898. };
  5899. return plugins[behaviour];
  5900. }
  5901. function isValidBehaviour(behaviour) {
  5902. return Object.keys(behaviours).map(key => behaviours[key]).indexOf(behaviour) > -1;
  5903. }
  5904. function getDefaultScopeBehaviour(scopeBehaviour) {
  5905. return scopeBehaviour && isValidBehaviour(scopeBehaviour) ? scopeBehaviour : behaviours.LOCAL;
  5906. }
  5907. function generateScopedNameDefault(name, filename, css) {
  5908. const i = css.indexOf(`.${name}`);
  5909. const lineNumber = css.substr(0, i).split(/[\r\n]/).length;
  5910. const hash = (0, _stringHash.default)(css).toString(36).substr(0, 5);
  5911. return `_${name}_${hash}_${lineNumber}`;
  5912. }
  5913. function getScopedNameGenerator(generateScopedName, hashPrefix) {
  5914. const scopedNameGenerator = generateScopedName || generateScopedNameDefault;
  5915. if (typeof scopedNameGenerator === "function") {
  5916. return scopedNameGenerator;
  5917. }
  5918. return (0, _genericNames.default)(scopedNameGenerator, {
  5919. context: process.cwd(),
  5920. hashPrefix: hashPrefix
  5921. });
  5922. }
  5923. Object.defineProperty(pluginFactory, "__esModule", {
  5924. value: true
  5925. });
  5926. pluginFactory.makePlugin = makePlugin;
  5927. var _postcss = _interopRequireDefault(require$$0);
  5928. var _unquote = _interopRequireDefault(unquote$1);
  5929. var _Parser = _interopRequireDefault(Parser$1);
  5930. var _saveJSON = _interopRequireDefault(saveJSON$1);
  5931. var _localsConvention = localsConvention;
  5932. var _FileSystemLoader = _interopRequireDefault(FileSystemLoader$1);
  5933. var _scoping = scoping;
  5934. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  5935. const PLUGIN_NAME = "postcss-modules";
  5936. function isGlobalModule(globalModules, inputFile) {
  5937. return globalModules.some(regex => inputFile.match(regex));
  5938. }
  5939. function getDefaultPluginsList(opts, inputFile) {
  5940. const globalModulesList = opts.globalModulePaths || null;
  5941. const exportGlobals = opts.exportGlobals || false;
  5942. const defaultBehaviour = (0, _scoping.getDefaultScopeBehaviour)(opts.scopeBehaviour);
  5943. const generateScopedName = (0, _scoping.getScopedNameGenerator)(opts.generateScopedName, opts.hashPrefix);
  5944. if (globalModulesList && isGlobalModule(globalModulesList, inputFile)) {
  5945. return (0, _scoping.getDefaultPlugins)({
  5946. behaviour: _scoping.behaviours.GLOBAL,
  5947. generateScopedName,
  5948. exportGlobals
  5949. });
  5950. }
  5951. return (0, _scoping.getDefaultPlugins)({
  5952. behaviour: defaultBehaviour,
  5953. generateScopedName,
  5954. exportGlobals
  5955. });
  5956. }
  5957. function getLoader(opts, plugins) {
  5958. const root = typeof opts.root === "undefined" ? "/" : opts.root;
  5959. return typeof opts.Loader === "function" ? new opts.Loader(root, plugins, opts.resolve) : new _FileSystemLoader.default(root, plugins, opts.resolve);
  5960. }
  5961. function isOurPlugin(plugin) {
  5962. return plugin.postcssPlugin === PLUGIN_NAME;
  5963. }
  5964. function makePlugin(opts) {
  5965. return {
  5966. postcssPlugin: PLUGIN_NAME,
  5967. async OnceExit(css, {
  5968. result
  5969. }) {
  5970. const getJSON = opts.getJSON || _saveJSON.default;
  5971. const inputFile = css.source.input.file;
  5972. const pluginList = getDefaultPluginsList(opts, inputFile);
  5973. const resultPluginIndex = result.processor.plugins.findIndex(plugin => isOurPlugin(plugin));
  5974. if (resultPluginIndex === -1) {
  5975. throw new Error("Plugin missing from options.");
  5976. }
  5977. const earlierPlugins = result.processor.plugins.slice(0, resultPluginIndex);
  5978. const loaderPlugins = [...earlierPlugins, ...pluginList];
  5979. const loader = getLoader(opts, loaderPlugins);
  5980. const fetcher = async (file, relativeTo, depTrace) => {
  5981. const unquoteFile = (0, _unquote.default)(file);
  5982. return loader.fetch.call(loader, unquoteFile, relativeTo, depTrace);
  5983. };
  5984. const parser = new _Parser.default(fetcher);
  5985. await (0, _postcss.default)([...pluginList, parser.plugin()]).process(css, {
  5986. from: inputFile
  5987. });
  5988. const out = loader.finalSource;
  5989. if (out) css.prepend(out);
  5990. if (opts.localsConvention) {
  5991. const reducer = (0, _localsConvention.makeLocalsConventionReducer)(opts.localsConvention, inputFile);
  5992. parser.exportTokens = Object.entries(parser.exportTokens).reduce(reducer, {});
  5993. }
  5994. result.messages.push({
  5995. type: "export",
  5996. plugin: "postcss-modules",
  5997. exportTokens: parser.exportTokens
  5998. }); // getJSON may return a promise
  5999. return getJSON(css.source.input.file, parser.exportTokens, result.opts.to);
  6000. }
  6001. };
  6002. }
  6003. var _fs = require$$0__default;
  6004. var _fs2 = fs;
  6005. var _pluginFactory = pluginFactory;
  6006. (0, _fs2.setFileSystem)({
  6007. readFile: _fs.readFile,
  6008. writeFile: _fs.writeFile
  6009. });
  6010. build.exports = (opts = {}) => (0, _pluginFactory.makePlugin)(opts);
  6011. var postcss = build.exports.postcss = true;
  6012. var index = /*#__PURE__*/_mergeNamespaces({
  6013. __proto__: null,
  6014. postcss: postcss,
  6015. 'default': build.exports
  6016. }, [build.exports]);
  6017. export { index as i };