css-tree.js 348 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416
  1. /*
  2. * The MIT License (MIT)
  3. * Copyright (C) 2016-2019 by Roman Dvornov
  4. *
  5. * Permission is hereby granted, free of charge, to any person obtaining a copy
  6. * of this software and associated documentation files (the "Software"), to deal
  7. * in the Software without restriction, including without limitation the rights
  8. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. * copies of the Software, and to permit persons to whom the Software is
  10. * furnished to do so, subject to the following conditions:
  11. *
  12. * The above copyright notice and this permission notice shall be included in
  13. * all copies or substantial portions of the Software.
  14. *
  15. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  21. * THE SOFTWARE.
  22. */
  23. // Project page: https://github.com/csstree/csstree
  24. /* eslint-disable no-cond-assign */
  25. /* eslint-disable no-unused-vars */
  26. /* eslint-disable no-redeclare */
  27. /* global singlefile csstree module define window global self require */
  28. this.singlefile.lib.vendor.cssTree = this.singlefile.lib.vendor.cssTree || (() => {
  29. (function (f) { if (typeof exports === "object" && typeof module !== "undefined") { module.exports = f(); } else if (typeof define === "function" && define.amd) { define([], f); } else { var g; if (typeof window !== "undefined") { g = window; } else if (typeof global !== "undefined") { g = global; } else if (typeof self !== "undefined") { g = self; } else { g = this; } g.csstree = f(); } })(function () {
  30. var define, module, exports; return (function () { function r(e, n, t) { function o(i, f) { if (!n[i]) { if (!e[i]) { var c = "function" == typeof require && require; if (!f && c) return c(i, !0); if (u) return u(i, !0); var a = new Error("Cannot find module '" + i + "'"); throw a.code = "MODULE_NOT_FOUND", a; } var p = n[i] = { exports: {} }; e[i][0].call(p.exports, function (r) { var n = e[i][1][r]; return o(n || r); }, p, p.exports, r, e, n, t); } return n[i].exports; } for (var u = "function" == typeof require && require, i = 0; i < t.length; i++)o(t[i]); return o; } return r; })()({
  31. 1: [function (require, module, exports) {
  32. module.exports = { "generic": true, "types": { "absolute-size": "xx-small | x-small | small | medium | large | x-large | xx-large", "alpha-value": "<number> | <percentage>", "angle-percentage": "<angle> | <percentage>", "angular-color-hint": "<angle-percentage>", "angular-color-stop": "<color> && <color-stop-angle>?", "angular-color-stop-list": "[ <angular-color-stop> [, <angular-color-hint> ]? ]# , <angular-color-stop>", "animateable-feature": "scroll-position | contents | <custom-ident>", "attachment": "scroll | fixed | local", "attr()": "attr( <attr-name> <type-or-unit>? [, <attr-fallback> ]? )", "attr-matcher": "[ '~' | '|' | '^' | '$' | '*' ]? '='", "attr-modifier": "i | s", "attribute-selector": "'[' <wq-name> ']' | '[' <wq-name> <attr-matcher> [ <string-token> | <ident-token> ] <attr-modifier>? ']'", "auto-repeat": "repeat( [ auto-fill | auto-fit ] , [ <line-names>? <fixed-size> ]+ <line-names>? )", "auto-track-list": "[ <line-names>? [ <fixed-size> | <fixed-repeat> ] ]* <line-names>? <auto-repeat> [ <line-names>? [ <fixed-size> | <fixed-repeat> ] ]* <line-names>?", "baseline-position": "[ first | last ]? baseline", "basic-shape": "<inset()> | <circle()> | <ellipse()> | <polygon()>", "bg-image": "none | <image>", "bg-layer": "<bg-image> || <bg-position> [ / <bg-size> ]? || <repeat-style> || <attachment> || <box> || <box>", "bg-position": "[ [ left | center | right | top | bottom | <length-percentage> ] | [ left | center | right | <length-percentage> ] [ top | center | bottom | <length-percentage> ] | [ center | [ left | right ] <length-percentage>? ] && [ center | [ top | bottom ] <length-percentage>? ] ]", "bg-size": "[ <length-percentage> | auto ]{1,2} | cover | contain", "blur()": "blur( <length> )", "blend-mode": "normal | multiply | screen | overlay | darken | lighten | color-dodge | color-burn | hard-light | soft-light | difference | exclusion | hue | saturation | color | luminosity", "box": "border-box | padding-box | content-box", "brightness()": "brightness( <number-percentage> )", "calc()": "calc( <calc-sum> )", "calc-sum": "<calc-product> [ [ '+' | '-' ] <calc-product> ]*", "calc-product": "<calc-value> [ '*' <calc-value> | '/' <number> ]*", "calc-value": "<number> | <dimension> | <percentage> | ( <calc-sum> )", "cf-final-image": "<image> | <color>", "cf-mixing-image": "<percentage>? && <image>", "circle()": "circle( [ <shape-radius> ]? [ at <position> ]? )", "clamp()": "clamp( <calc-sum>#{3} )", "class-selector": "'.' <ident-token>", "clip-source": "<url>", "color": "<rgb()> | <rgba()> | <hsl()> | <hsla()> | <hex-color> | <named-color> | currentcolor | <deprecated-system-color>", "color-stop": "<color-stop-length> | <color-stop-angle>", "color-stop-angle": "<angle-percentage>{1,2}", "color-stop-length": "<length-percentage>{1,2}", "color-stop-list": "[ <linear-color-stop> [, <linear-color-hint> ]? ]# , <linear-color-stop>", "combinator": "'>' | '+' | '~' | [ '||' ]", "common-lig-values": "[ common-ligatures | no-common-ligatures ]", "compat": "searchfield | textarea | push-button | button-bevel | slider-horizontal | checkbox | radio | square-button | menulist | menulist-button | listbox | meter | progress-bar", "composite-style": "clear | copy | source-over | source-in | source-out | source-atop | destination-over | destination-in | destination-out | destination-atop | xor", "compositing-operator": "add | subtract | intersect | exclude", "compound-selector": "[ <type-selector>? <subclass-selector>* [ <pseudo-element-selector> <pseudo-class-selector>* ]* ]!", "compound-selector-list": "<compound-selector>#", "complex-selector": "<compound-selector> [ <combinator>? <compound-selector> ]*", "complex-selector-list": "<complex-selector>#", "conic-gradient()": "conic-gradient( [ from <angle> ]? [ at <position> ]? , <angular-color-stop-list> )", "contextual-alt-values": "[ contextual | no-contextual ]", "content-distribution": "space-between | space-around | space-evenly | stretch", "content-list": "[ <string> | contents | <url> | <quote> | <attr()> | counter( <ident> , <'list-style-type'>? ) ]+", "content-position": "center | start | end | flex-start | flex-end", "content-replacement": "<image>", "contrast()": "contrast( [ <number-percentage> ] )", "counter()": "counter( <custom-ident> , [ <counter-style> | none ]? )", "counter-style": "<counter-style-name> | symbols( )", "counter-style-name": "<custom-ident>", "counters()": "counters( <custom-ident> , <string> , [ <counter-style> | none ]? )", "cross-fade()": "cross-fade( <cf-mixing-image> , <cf-final-image>? )", "cubic-bezier-timing-function": "ease | ease-in | ease-out | ease-in-out | cubic-bezier( <number> , <number> , <number> , <number> )", "deprecated-system-color": "ActiveBorder | ActiveCaption | AppWorkspace | Background | ButtonFace | ButtonHighlight | ButtonShadow | ButtonText | CaptionText | GrayText | Highlight | HighlightText | InactiveBorder | InactiveCaption | InactiveCaptionText | InfoBackground | InfoText | Menu | MenuText | Scrollbar | ThreeDDarkShadow | ThreeDFace | ThreeDHighlight | ThreeDLightShadow | ThreeDShadow | Window | WindowFrame | WindowText", "discretionary-lig-values": "[ discretionary-ligatures | no-discretionary-ligatures ]", "display-box": "contents | none", "display-inside": "flow | flow-root | table | flex | grid | ruby", "display-internal": "table-row-group | table-header-group | table-footer-group | table-row | table-cell | table-column-group | table-column | table-caption | ruby-base | ruby-text | ruby-base-container | ruby-text-container", "display-legacy": "inline-block | inline-list-item | inline-table | inline-flex | inline-grid", "display-listitem": "<display-outside>? && [ flow | flow-root ]? && list-item", "display-outside": "block | inline | run-in", "drop-shadow()": "drop-shadow( <length>{2,3} <color>? )", "east-asian-variant-values": "[ jis78 | jis83 | jis90 | jis04 | simplified | traditional ]", "east-asian-width-values": "[ full-width | proportional-width ]", "element()": "element( <id-selector> )", "ellipse()": "ellipse( [ <shape-radius>{2} ]? [ at <position> ]? )", "ending-shape": "circle | ellipse", "env()": "env( <custom-ident> , <declaration-value>? )", "explicit-track-list": "[ <line-names>? <track-size> ]+ <line-names>?", "family-name": "<string> | <custom-ident>+", "feature-tag-value": "<string> [ <integer> | on | off ]?", "feature-type": "@stylistic | @historical-forms | @styleset | @character-variant | @swash | @ornaments | @annotation", "feature-value-block": "<feature-type> '{' <feature-value-declaration-list> '}'", "feature-value-block-list": "<feature-value-block>+", "feature-value-declaration": "<custom-ident> : <integer>+ ;", "feature-value-declaration-list": "<feature-value-declaration>", "feature-value-name": "<custom-ident>", "fill-rule": "nonzero | evenodd", "filter-function": "<blur()> | <brightness()> | <contrast()> | <drop-shadow()> | <grayscale()> | <hue-rotate()> | <invert()> | <opacity()> | <saturate()> | <sepia()>", "filter-function-list": "[ <filter-function> | <url> ]+", "final-bg-layer": "<'background-color'> || <bg-image> || <bg-position> [ / <bg-size> ]? || <repeat-style> || <attachment> || <box> || <box>", "fit-content()": "fit-content( [ <length> | <percentage> ] )", "fixed-breadth": "<length-percentage>", "fixed-repeat": "repeat( [ <positive-integer> ] , [ <line-names>? <fixed-size> ]+ <line-names>? )", "fixed-size": "<fixed-breadth> | minmax( <fixed-breadth> , <track-breadth> ) | minmax( <inflexible-breadth> , <fixed-breadth> )", "font-stretch-absolute": "normal | ultra-condensed | extra-condensed | condensed | semi-condensed | semi-expanded | expanded | extra-expanded | ultra-expanded | <percentage>", "font-variant-css21": "[ normal | small-caps ]", "font-weight-absolute": "normal | bold | <number>", "frequency-percentage": "<frequency> | <percentage>", "general-enclosed": "[ <function-token> <any-value> ) ] | ( <ident> <any-value> )", "generic-family": "serif | sans-serif | cursive | fantasy | monospace | -apple-system", "generic-name": "serif | sans-serif | cursive | fantasy | monospace", "geometry-box": "<shape-box> | fill-box | stroke-box | view-box", "gradient": "<linear-gradient()> | <repeating-linear-gradient()> | <radial-gradient()> | <repeating-radial-gradient()> | <conic-gradient()> | <-legacy-gradient>", "grayscale()": "grayscale( <number-percentage> )", "grid-line": "auto | <custom-ident> | [ <integer> && <custom-ident>? ] | [ span && [ <integer> || <custom-ident> ] ]", "historical-lig-values": "[ historical-ligatures | no-historical-ligatures ]", "hsl()": "hsl( <hue> <percentage> <percentage> [ / <alpha-value> ]? ) | hsl( <hue> , <percentage> , <percentage> , <alpha-value>? )", "hsla()": "hsla( <hue> <percentage> <percentage> [ / <alpha-value> ]? ) | hsla( <hue> , <percentage> , <percentage> , <alpha-value>? )", "hue": "<number> | <angle>", "hue-rotate()": "hue-rotate( <angle> )", "image": "<url> | <image()> | <image-set()> | <element()> | <cross-fade()> | <gradient>", "image()": "image( <image-tags>? [ <image-src>? , <color>? ]! )", "image-set()": "image-set( <image-set-option># )", "image-set-option": "[ <image> | <string> ] <resolution>", "image-src": "<url> | <string>", "image-tags": "ltr | rtl", "inflexible-breadth": "<length> | <percentage> | min-content | max-content | auto", "inset()": "inset( <length-percentage>{1,4} [ round <'border-radius'> ]? )", "invert()": "invert( <number-percentage> )", "keyframes-name": "<custom-ident> | <string>", "keyframe-block": "<keyframe-selector># { <declaration-list> }", "keyframe-block-list": "<keyframe-block>+", "keyframe-selector": "from | to | <percentage>", "leader()": "leader( <leader-type> )", "leader-type": "dotted | solid | space | <string>", "length-percentage": "<length> | <percentage>", "line-names": "'[' <custom-ident>* ']'", "line-name-list": "[ <line-names> | <name-repeat> ]+", "line-style": "none | hidden | dotted | dashed | solid | double | groove | ridge | inset | outset", "line-width": "<length> | thin | medium | thick", "linear-color-hint": "<length-percentage>", "linear-color-stop": "<color> <color-stop-length>?", "linear-gradient()": "linear-gradient( [ <angle> | to <side-or-corner> ]? , <color-stop-list> )", "mask-layer": "<mask-reference> || <position> [ / <bg-size> ]? || <repeat-style> || <geometry-box> || [ <geometry-box> | no-clip ] || <compositing-operator> || <masking-mode>", "mask-position": "[ <length-percentage> | left | center | right ] [ <length-percentage> | top | center | bottom ]?", "mask-reference": "none | <image> | <mask-source>", "mask-source": "<url>", "masking-mode": "alpha | luminance | match-source", "matrix()": "matrix( <number>#{6} )", "matrix3d()": "matrix3d( <number>#{16} )", "max()": "max( <calc-sum># )", "media-and": "<media-in-parens> [ and <media-in-parens> ]+", "media-condition": "<media-not> | <media-and> | <media-or> | <media-in-parens>", "media-condition-without-or": "<media-not> | <media-and> | <media-in-parens>", "media-feature": "( [ <mf-plain> | <mf-boolean> | <mf-range> ] )", "media-in-parens": "( <media-condition> ) | <media-feature> | <general-enclosed>", "media-not": "not <media-in-parens>", "media-or": "<media-in-parens> [ or <media-in-parens> ]+", "media-query": "<media-condition> | [ not | only ]? <media-type> [ and <media-condition-without-or> ]?", "media-query-list": "<media-query>#", "media-type": "<ident>", "mf-boolean": "<mf-name>", "mf-name": "<ident>", "mf-plain": "<mf-name> : <mf-value>", "mf-range": "<mf-name> [ '<' | '>' ]? '='? <mf-value> | <mf-value> [ '<' | '>' ]? '='? <mf-name> | <mf-value> '<' '='? <mf-name> '<' '='? <mf-value> | <mf-value> '>' '='? <mf-name> '>' '='? <mf-value>", "mf-value": "<number> | <dimension> | <ident> | <ratio>", "min()": "min( <calc-sum># )", "minmax()": "minmax( [ <length> | <percentage> | <flex> | min-content | max-content | auto ] , [ <length> | <percentage> | <flex> | min-content | max-content | auto ] )", "named-color": "transparent | aliceblue | antiquewhite | aqua | aquamarine | azure | beige | bisque | black | blanchedalmond | blue | blueviolet | brown | burlywood | cadetblue | chartreuse | chocolate | coral | cornflowerblue | cornsilk | crimson | cyan | darkblue | darkcyan | darkgoldenrod | darkgray | darkgreen | darkgrey | darkkhaki | darkmagenta | darkolivegreen | darkorange | darkorchid | darkred | darksalmon | darkseagreen | darkslateblue | darkslategray | darkslategrey | darkturquoise | darkviolet | deeppink | deepskyblue | dimgray | dimgrey | dodgerblue | firebrick | floralwhite | forestgreen | fuchsia | gainsboro | ghostwhite | gold | goldenrod | gray | green | greenyellow | grey | honeydew | hotpink | indianred | indigo | ivory | khaki | lavender | lavenderblush | lawngreen | lemonchiffon | lightblue | lightcoral | lightcyan | lightgoldenrodyellow | lightgray | lightgreen | lightgrey | lightpink | lightsalmon | lightseagreen | lightskyblue | lightslategray | lightslategrey | lightsteelblue | lightyellow | lime | limegreen | linen | magenta | maroon | mediumaquamarine | mediumblue | mediumorchid | mediumpurple | mediumseagreen | mediumslateblue | mediumspringgreen | mediumturquoise | mediumvioletred | midnightblue | mintcream | mistyrose | moccasin | navajowhite | navy | oldlace | olive | olivedrab | orange | orangered | orchid | palegoldenrod | palegreen | paleturquoise | palevioletred | papayawhip | peachpuff | peru | pink | plum | powderblue | purple | rebeccapurple | red | rosybrown | royalblue | saddlebrown | salmon | sandybrown | seagreen | seashell | sienna | silver | skyblue | slateblue | slategray | slategrey | snow | springgreen | steelblue | tan | teal | thistle | tomato | turquoise | violet | wheat | white | whitesmoke | yellow | yellowgreen | <-non-standard-color>", "namespace-prefix": "<ident>", "ns-prefix": "[ <ident-token> | '*' ]? '|'", "number-percentage": "<number> | <percentage>", "numeric-figure-values": "[ lining-nums | oldstyle-nums ]", "numeric-fraction-values": "[ diagonal-fractions | stacked-fractions ]", "numeric-spacing-values": "[ proportional-nums | tabular-nums ]", "nth": "<an-plus-b> | even | odd", "opacity()": "opacity( [ <number-percentage> ] )", "overflow-position": "unsafe | safe", "outline-radius": "<length> | <percentage>", "page-body": "<declaration>? [ ; <page-body> ]? | <page-margin-box> <page-body>", "page-margin-box": "<page-margin-box-type> '{' <declaration-list> '}'", "page-margin-box-type": "@top-left-corner | @top-left | @top-center | @top-right | @top-right-corner | @bottom-left-corner | @bottom-left | @bottom-center | @bottom-right | @bottom-right-corner | @left-top | @left-middle | @left-bottom | @right-top | @right-middle | @right-bottom", "page-selector-list": "[ <page-selector># ]?", "page-selector": "<pseudo-page>+ | <ident> <pseudo-page>*", "perspective()": "perspective( <length> )", "polygon()": "polygon( <fill-rule>? , [ <length-percentage> <length-percentage> ]# )", "position": "[ [ left | center | right ] || [ top | center | bottom ] | [ left | center | right | <length-percentage> ] [ top | center | bottom | <length-percentage> ]? | [ [ left | right ] <length-percentage> ] && [ [ top | bottom ] <length-percentage> ] ]", "pseudo-class-selector": "':' <ident-token> | ':' <function-token> <any-value> ')'", "pseudo-element-selector": "':' <pseudo-class-selector>", "pseudo-page": ": [ left | right | first | blank ]", "quote": "open-quote | close-quote | no-open-quote | no-close-quote", "radial-gradient()": "radial-gradient( [ <ending-shape> || <size> ]? [ at <position> ]? , <color-stop-list> )", "relative-selector": "<combinator>? <complex-selector>", "relative-selector-list": "<relative-selector>#", "relative-size": "larger | smaller", "repeat-style": "repeat-x | repeat-y | [ repeat | space | round | no-repeat ]{1,2}", "repeating-linear-gradient()": "repeating-linear-gradient( [ <angle> | to <side-or-corner> ]? , <color-stop-list> )", "repeating-radial-gradient()": "repeating-radial-gradient( [ <ending-shape> || <size> ]? [ at <position> ]? , <color-stop-list> )", "rgb()": "rgb( <percentage>{3} [ / <alpha-value> ]? ) | rgb( <number>{3} [ / <alpha-value> ]? ) | rgb( <percentage>#{3} , <alpha-value>? ) | rgb( <number>#{3} , <alpha-value>? )", "rgba()": "rgba( <percentage>{3} [ / <alpha-value> ]? ) | rgba( <number>{3} [ / <alpha-value> ]? ) | rgba( <percentage>#{3} , <alpha-value>? ) | rgba( <number>#{3} , <alpha-value>? )", "rotate()": "rotate( [ <angle> | <zero> ] )", "rotate3d()": "rotate3d( <number> , <number> , <number> , [ <angle> | <zero> ] )", "rotateX()": "rotateX( [ <angle> | <zero> ] )", "rotateY()": "rotateY( [ <angle> | <zero> ] )", "rotateZ()": "rotateZ( [ <angle> | <zero> ] )", "saturate()": "saturate( <number-percentage> )", "scale()": "scale( <number> , <number>? )", "scale3d()": "scale3d( <number> , <number> , <number> )", "scaleX()": "scaleX( <number> )", "scaleY()": "scaleY( <number> )", "scaleZ()": "scaleZ( <number> )", "self-position": "center | start | end | self-start | self-end | flex-start | flex-end", "shape-radius": "<length-percentage> | closest-side | farthest-side", "skew()": "skew( [ <angle> | <zero> ] , [ <angle> | <zero> ]? )", "skewX()": "skewX( [ <angle> | <zero> ] )", "skewY()": "skewY( [ <angle> | <zero> ] )", "sepia()": "sepia( <number-percentage> )", "shadow": "inset? && <length>{2,4} && <color>?", "shadow-t": "[ <length>{2,3} && <color>? ]", "shape": "rect( <top> , <right> , <bottom> , <left> ) | rect( <top> <right> <bottom> <left> )", "shape-box": "<box> | margin-box", "side-or-corner": "[ left | right ] || [ top | bottom ]", "single-animation": "<time> || <timing-function> || <time> || <single-animation-iteration-count> || <single-animation-direction> || <single-animation-fill-mode> || <single-animation-play-state> || [ none | <keyframes-name> ]", "single-animation-direction": "normal | reverse | alternate | alternate-reverse", "single-animation-fill-mode": "none | forwards | backwards | both", "single-animation-iteration-count": "infinite | <number>", "single-animation-play-state": "running | paused", "single-transition": "[ none | <single-transition-property> ] || <time> || <timing-function> || <time>", "single-transition-property": "all | <custom-ident>", "size": "closest-side | farthest-side | closest-corner | farthest-corner | <length> | <length-percentage>{2}", "step-position": "jump-start | jump-end | jump-none | jump-both | start | end", "step-timing-function": "step-start | step-end | steps( <integer> [, <step-position> ]? )", "subclass-selector": "<id-selector> | <class-selector> | <attribute-selector> | <pseudo-class-selector>", "supports-condition": "not <supports-in-parens> | <supports-in-parens> [ and <supports-in-parens> ]* | <supports-in-parens> [ or <supports-in-parens> ]*", "supports-in-parens": "( <supports-condition> ) | <supports-feature> | <general-enclosed>", "supports-feature": "<supports-decl> | <supports-selector-fn>", "supports-decl": "( <declaration> )", "supports-selector-fn": "selector( <complex-selector> )", "symbol": "<string> | <image> | <custom-ident>", "target": "<target-counter()> | <target-counters()> | <target-text()>", "target-counter()": "target-counter( [ <string> | <url> ] , <custom-ident> , <counter-style>? )", "target-counters()": "target-counters( [ <string> | <url> ] , <custom-ident> , <string> , <counter-style>? )", "target-text()": "target-text( [ <string> | <url> ] , [ content | before | after | first-letter ]? )", "time-percentage": "<time> | <percentage>", "timing-function": "linear | <cubic-bezier-timing-function> | <step-timing-function>", "track-breadth": "<length-percentage> | <flex> | min-content | max-content | auto", "track-list": "[ <line-names>? [ <track-size> | <track-repeat> ] ]+ <line-names>?", "track-repeat": "repeat( [ <positive-integer> ] , [ <line-names>? <track-size> ]+ <line-names>? )", "track-size": "<track-breadth> | minmax( <inflexible-breadth> , <track-breadth> ) | fit-content( [ <length> | <percentage> ] )", "transform-function": "<matrix()> | <translate()> | <translateX()> | <translateY()> | <scale()> | <scaleX()> | <scaleY()> | <rotate()> | <skew()> | <skewX()> | <skewY()> | <matrix3d()> | <translate3d()> | <translateZ()> | <scale3d()> | <scaleZ()> | <rotate3d()> | <rotateX()> | <rotateY()> | <rotateZ()> | <perspective()>", "transform-list": "<transform-function>+", "translate()": "translate( <length-percentage> , <length-percentage>? )", "translate3d()": "translate3d( <length-percentage> , <length-percentage> , <length> )", "translateX()": "translateX( <length-percentage> )", "translateY()": "translateY( <length-percentage> )", "translateZ()": "translateZ( <length> )", "type-or-unit": "string | color | url | integer | number | length | angle | time | frequency | cap | ch | em | ex | ic | lh | rlh | rem | vb | vi | vw | vh | vmin | vmax | mm | Q | cm | in | pt | pc | px | deg | grad | rad | turn | ms | s | Hz | kHz | %", "type-selector": "<wq-name> | <ns-prefix>? '*'", "var()": "var( <custom-property-name> , <declaration-value>? )", "viewport-length": "auto | <length-percentage>", "wq-name": "<ns-prefix>? <ident-token>", "-legacy-gradient": "<-webkit-gradient()> | <-legacy-linear-gradient> | <-legacy-repeating-linear-gradient> | <-legacy-radial-gradient> | <-legacy-repeating-radial-gradient>", "-legacy-linear-gradient": "-moz-linear-gradient( <-legacy-linear-gradient-arguments> ) | -webkit-linear-gradient( <-legacy-linear-gradient-arguments> ) | -o-linear-gradient( <-legacy-linear-gradient-arguments> )", "-legacy-repeating-linear-gradient": "-moz-repeating-linear-gradient( <-legacy-linear-gradient-arguments> ) | -webkit-repeating-linear-gradient( <-legacy-linear-gradient-arguments> ) | -o-repeating-linear-gradient( <-legacy-linear-gradient-arguments> )", "-legacy-linear-gradient-arguments": "[ <angle> | <side-or-corner> ]? , <color-stop-list>", "-legacy-radial-gradient": "-moz-radial-gradient( <-legacy-radial-gradient-arguments> ) | -webkit-radial-gradient( <-legacy-radial-gradient-arguments> ) | -o-radial-gradient( <-legacy-radial-gradient-arguments> )", "-legacy-repeating-radial-gradient": "-moz-repeating-radial-gradient( <-legacy-radial-gradient-arguments> ) | -webkit-repeating-radial-gradient( <-legacy-radial-gradient-arguments> ) | -o-repeating-radial-gradient( <-legacy-radial-gradient-arguments> )", "-legacy-radial-gradient-arguments": "[ <position> , ]? [ [ [ <-legacy-radial-gradient-shape> || <-legacy-radial-gradient-size> ] | [ <length> | <percentage> ]{2} ] , ]? <color-stop-list>", "-legacy-radial-gradient-size": "closest-side | closest-corner | farthest-side | farthest-corner | contain | cover", "-legacy-radial-gradient-shape": "circle | ellipse", "-non-standard-font": "-apple-system-body | -apple-system-headline | -apple-system-subheadline | -apple-system-caption1 | -apple-system-caption2 | -apple-system-footnote | -apple-system-short-body | -apple-system-short-headline | -apple-system-short-subheadline | -apple-system-short-caption1 | -apple-system-short-footnote | -apple-system-tall-body", "-non-standard-color": "-moz-ButtonDefault | -moz-ButtonHoverFace | -moz-ButtonHoverText | -moz-CellHighlight | -moz-CellHighlightText | -moz-Combobox | -moz-ComboboxText | -moz-Dialog | -moz-DialogText | -moz-dragtargetzone | -moz-EvenTreeRow | -moz-Field | -moz-FieldText | -moz-html-CellHighlight | -moz-html-CellHighlightText | -moz-mac-accentdarkestshadow | -moz-mac-accentdarkshadow | -moz-mac-accentface | -moz-mac-accentlightesthighlight | -moz-mac-accentlightshadow | -moz-mac-accentregularhighlight | -moz-mac-accentregularshadow | -moz-mac-chrome-active | -moz-mac-chrome-inactive | -moz-mac-focusring | -moz-mac-menuselect | -moz-mac-menushadow | -moz-mac-menutextselect | -moz-MenuHover | -moz-MenuHoverText | -moz-MenuBarText | -moz-MenuBarHoverText | -moz-nativehyperlinktext | -moz-OddTreeRow | -moz-win-communicationstext | -moz-win-mediatext | -moz-activehyperlinktext | -moz-default-background-color | -moz-default-color | -moz-hyperlinktext | -moz-visitedhyperlinktext | -webkit-activelink | -webkit-focus-ring-color | -webkit-link | -webkit-text", "-non-standard-image-rendering": "optimize-contrast | -moz-crisp-edges | -o-crisp-edges | -webkit-optimize-contrast", "-non-standard-overflow": "-moz-scrollbars-none | -moz-scrollbars-horizontal | -moz-scrollbars-vertical | -moz-hidden-unscrollable", "-non-standard-width": "min-intrinsic | intrinsic | -moz-min-content | -moz-max-content | -webkit-min-content | -webkit-max-content", "-webkit-gradient()": "-webkit-gradient( <-webkit-gradient-type> , <-webkit-gradient-point> [, <-webkit-gradient-point> | , <-webkit-gradient-radius> , <-webkit-gradient-point> ] [, <-webkit-gradient-radius> ]? [, <-webkit-gradient-color-stop> ]* )", "-webkit-gradient-color-stop": "from( <color> ) | color-stop( [ <number-zero-one> | <percentage> ] , <color> ) | to( <color> )", "-webkit-gradient-point": "[ left | center | right | <length-percentage> ] [ top | center | bottom | <length-percentage> ]", "-webkit-gradient-radius": "<length> | <percentage>", "-webkit-gradient-type": "linear | radial", "-webkit-mask-box-repeat": "repeat | stretch | round", "-webkit-mask-clip-style": "border | border-box | padding | padding-box | content | content-box | text", "-ms-filter-function-list": "<-ms-filter-function>+", "-ms-filter-function": "<-ms-filter-function-progid> | <-ms-filter-function-legacy>", "-ms-filter-function-progid": "'progid:' [ <ident-token> '.' ]* [ <ident-token> | <function-token> <any-value>? ) ]", "-ms-filter-function-legacy": "<ident-token> | <function-token> <any-value>? )", "-ms-filter": "<string>", "age": "child | young | old", "attr-name": "<wq-name>", "attr-fallback": "<any-value>", "border-radius": "<length-percentage>{1,2}", "bottom": "<length> | auto", "generic-voice": "[ <age>? <gender> <integer>? ]", "gender": "male | female | neutral", "left": "<length> | auto", "mask-image": "<mask-reference>#", "name-repeat": "repeat( [ <positive-integer> | auto-fill ] , <line-names>+ )", "paint": "none | <color> | <url> [ none | <color> ]? | context-fill | context-stroke", "path()": "path( <string> )", "ratio": "<integer> / <integer>", "right": "<length> | auto", "svg-length": "<percentage> | <length> | <number>", "svg-writing-mode": "lr-tb | rl-tb | tb-rl | lr | rl | tb", "top": "<length> | auto", "x": "<number>", "y": "<number>", "declaration": "<ident-token> : <declaration-value>? [ '!' important ]?", "declaration-list": "[ <declaration>? ';' ]* <declaration>?", "url": "url( <string> <url-modifier>* ) | <url-token>", "url-modifier": "<ident> | <function-token> <any-value> )", "number-zero-one": "<number [0,1]>", "number-one-or-greater": "<number [1,∞]>", "positive-integer": "<integer [0,∞]>" }, "properties": { "--*": "<declaration-value>", "-ms-accelerator": "false | true", "-ms-block-progression": "tb | rl | bt | lr", "-ms-content-zoom-chaining": "none | chained", "-ms-content-zooming": "none | zoom", "-ms-content-zoom-limit": "<'-ms-content-zoom-limit-min'> <'-ms-content-zoom-limit-max'>", "-ms-content-zoom-limit-max": "<percentage>", "-ms-content-zoom-limit-min": "<percentage>", "-ms-content-zoom-snap": "<'-ms-content-zoom-snap-type'> || <'-ms-content-zoom-snap-points'>", "-ms-content-zoom-snap-points": "snapInterval( <percentage> , <percentage> ) | snapList( <percentage># )", "-ms-content-zoom-snap-type": "none | proximity | mandatory", "-ms-filter": "<string>", "-ms-flow-from": "[ none | <custom-ident> ]#", "-ms-flow-into": "[ none | <custom-ident> ]#", "-ms-high-contrast-adjust": "auto | none", "-ms-hyphenate-limit-chars": "auto | <integer>{1,3}", "-ms-hyphenate-limit-lines": "no-limit | <integer>", "-ms-hyphenate-limit-zone": "<percentage> | <length>", "-ms-ime-align": "auto | after", "-ms-overflow-style": "auto | none | scrollbar | -ms-autohiding-scrollbar", "-ms-scrollbar-3dlight-color": "<color>", "-ms-scrollbar-arrow-color": "<color>", "-ms-scrollbar-base-color": "<color>", "-ms-scrollbar-darkshadow-color": "<color>", "-ms-scrollbar-face-color": "<color>", "-ms-scrollbar-highlight-color": "<color>", "-ms-scrollbar-shadow-color": "<color>", "-ms-scrollbar-track-color": "<color>", "-ms-scroll-chaining": "chained | none", "-ms-scroll-limit": "<'-ms-scroll-limit-x-min'> <'-ms-scroll-limit-y-min'> <'-ms-scroll-limit-x-max'> <'-ms-scroll-limit-y-max'>", "-ms-scroll-limit-x-max": "auto | <length>", "-ms-scroll-limit-x-min": "<length>", "-ms-scroll-limit-y-max": "auto | <length>", "-ms-scroll-limit-y-min": "<length>", "-ms-scroll-rails": "none | railed", "-ms-scroll-snap-points-x": "snapInterval( <length-percentage> , <length-percentage> ) | snapList( <length-percentage># )", "-ms-scroll-snap-points-y": "snapInterval( <length-percentage> , <length-percentage> ) | snapList( <length-percentage># )", "-ms-scroll-snap-type": "none | proximity | mandatory", "-ms-scroll-snap-x": "<'-ms-scroll-snap-type'> <'-ms-scroll-snap-points-x'>", "-ms-scroll-snap-y": "<'-ms-scroll-snap-type'> <'-ms-scroll-snap-points-y'>", "-ms-scroll-translation": "none | vertical-to-horizontal", "-ms-text-autospace": "none | ideograph-alpha | ideograph-numeric | ideograph-parenthesis | ideograph-space", "-ms-touch-select": "grippers | none", "-ms-user-select": "none | element | text", "-ms-wrap-flow": "auto | both | start | end | maximum | clear", "-ms-wrap-margin": "<length>", "-ms-wrap-through": "wrap | none", "-moz-appearance": "none | button | button-arrow-down | button-arrow-next | button-arrow-previous | button-arrow-up | button-bevel | button-focus | caret | checkbox | checkbox-container | checkbox-label | checkmenuitem | dualbutton | groupbox | listbox | listitem | menuarrow | menubar | menucheckbox | menuimage | menuitem | menuitemtext | menulist | menulist-button | menulist-text | menulist-textfield | menupopup | menuradio | menuseparator | meterbar | meterchunk | progressbar | progressbar-vertical | progresschunk | progresschunk-vertical | radio | radio-container | radio-label | radiomenuitem | range | range-thumb | resizer | resizerpanel | scale-horizontal | scalethumbend | scalethumb-horizontal | scalethumbstart | scalethumbtick | scalethumb-vertical | scale-vertical | scrollbarbutton-down | scrollbarbutton-left | scrollbarbutton-right | scrollbarbutton-up | scrollbarthumb-horizontal | scrollbarthumb-vertical | scrollbartrack-horizontal | scrollbartrack-vertical | searchfield | separator | sheet | spinner | spinner-downbutton | spinner-textfield | spinner-upbutton | splitter | statusbar | statusbarpanel | tab | tabpanel | tabpanels | tab-scroll-arrow-back | tab-scroll-arrow-forward | textfield | textfield-multiline | toolbar | toolbarbutton | toolbarbutton-dropdown | toolbargripper | toolbox | tooltip | treeheader | treeheadercell | treeheadersortarrow | treeitem | treeline | treetwisty | treetwistyopen | treeview | -moz-mac-unified-toolbar | -moz-win-borderless-glass | -moz-win-browsertabbar-toolbox | -moz-win-communicationstext | -moz-win-communications-toolbox | -moz-win-exclude-glass | -moz-win-glass | -moz-win-mediatext | -moz-win-media-toolbox | -moz-window-button-box | -moz-window-button-box-maximized | -moz-window-button-close | -moz-window-button-maximize | -moz-window-button-minimize | -moz-window-button-restore | -moz-window-frame-bottom | -moz-window-frame-left | -moz-window-frame-right | -moz-window-titlebar | -moz-window-titlebar-maximized", "-moz-binding": "<url> | none", "-moz-border-bottom-colors": "<color>+ | none", "-moz-border-left-colors": "<color>+ | none", "-moz-border-right-colors": "<color>+ | none", "-moz-border-top-colors": "<color>+ | none", "-moz-context-properties": "none | [ fill | fill-opacity | stroke | stroke-opacity ]#", "-moz-float-edge": "border-box | content-box | margin-box | padding-box", "-moz-force-broken-image-icon": "<integer>", "-moz-image-region": "<shape> | auto", "-moz-orient": "inline | block | horizontal | vertical", "-moz-outline-radius": "<outline-radius>{1,4} [ / <outline-radius>{1,4} ]?", "-moz-outline-radius-bottomleft": "<outline-radius>", "-moz-outline-radius-bottomright": "<outline-radius>", "-moz-outline-radius-topleft": "<outline-radius>", "-moz-outline-radius-topright": "<outline-radius>", "-moz-stack-sizing": "ignore | stretch-to-fit", "-moz-text-blink": "none | blink", "-moz-user-focus": "ignore | normal | select-after | select-before | select-menu | select-same | select-all | none", "-moz-user-input": "auto | none | enabled | disabled", "-moz-user-modify": "read-only | read-write | write-only", "-moz-window-dragging": "drag | no-drag", "-moz-window-shadow": "default | menu | tooltip | sheet | none", "-webkit-appearance": "none | button | button-bevel | caps-lock-indicator | caret | checkbox | default-button | listbox | listitem | media-fullscreen-button | media-mute-button | media-play-button | media-seek-back-button | media-seek-forward-button | media-slider | media-sliderthumb | menulist | menulist-button | menulist-text | menulist-textfield | push-button | radio | scrollbarbutton-down | scrollbarbutton-left | scrollbarbutton-right | scrollbarbutton-up | scrollbargripper-horizontal | scrollbargripper-vertical | scrollbarthumb-horizontal | scrollbarthumb-vertical | scrollbartrack-horizontal | scrollbartrack-vertical | searchfield | searchfield-cancel-button | searchfield-decoration | searchfield-results-button | searchfield-results-decoration | slider-horizontal | slider-vertical | sliderthumb-horizontal | sliderthumb-vertical | square-button | textarea | textfield", "-webkit-border-before": "<'border-width'> || <'border-style'> || <'color'>", "-webkit-border-before-color": "<'color'>", "-webkit-border-before-style": "<'border-style'>", "-webkit-border-before-width": "<'border-width'>", "-webkit-box-reflect": "[ above | below | right | left ]? <length>? <image>?", "-webkit-line-clamp": "none | <integer>", "-webkit-mask": "[ <mask-reference> || <position> [ / <bg-size> ]? || <repeat-style> || [ <box> | border | padding | content | text ] || [ <box> | border | padding | content ] ]#", "-webkit-mask-attachment": "<attachment>#", "-webkit-mask-clip": "[ <box> | border | padding | content | text ]#", "-webkit-mask-composite": "<composite-style>#", "-webkit-mask-image": "<mask-reference>#", "-webkit-mask-origin": "[ <box> | border | padding | content ]#", "-webkit-mask-position": "<position>#", "-webkit-mask-position-x": "[ <length-percentage> | left | center | right ]#", "-webkit-mask-position-y": "[ <length-percentage> | top | center | bottom ]#", "-webkit-mask-repeat": "<repeat-style>#", "-webkit-mask-repeat-x": "repeat | no-repeat | space | round", "-webkit-mask-repeat-y": "repeat | no-repeat | space | round", "-webkit-mask-size": "<bg-size>#", "-webkit-overflow-scrolling": "auto | touch", "-webkit-tap-highlight-color": "<color>", "-webkit-text-fill-color": "<color>", "-webkit-text-stroke": "<length> || <color>", "-webkit-text-stroke-color": "<color>", "-webkit-text-stroke-width": "<length>", "-webkit-touch-callout": "default | none", "-webkit-user-modify": "read-only | read-write | read-write-plaintext-only", "align-content": "normal | <baseline-position> | <content-distribution> | <overflow-position>? <content-position>", "align-items": "normal | stretch | <baseline-position> | [ <overflow-position>? <self-position> ]", "align-self": "auto | normal | stretch | <baseline-position> | <overflow-position>? <self-position>", "all": "initial | inherit | unset | revert", "animation": "<single-animation>#", "animation-delay": "<time>#", "animation-direction": "<single-animation-direction>#", "animation-duration": "<time>#", "animation-fill-mode": "<single-animation-fill-mode>#", "animation-iteration-count": "<single-animation-iteration-count>#", "animation-name": "[ none | <keyframes-name> ]#", "animation-play-state": "<single-animation-play-state>#", "animation-timing-function": "<timing-function>#", "appearance": "none | auto | button | textfield | <compat>", "azimuth": "<angle> | [ [ left-side | far-left | left | center-left | center | center-right | right | far-right | right-side ] || behind ] | leftwards | rightwards", "backdrop-filter": "none | <filter-function-list>", "backface-visibility": "visible | hidden", "background": "[ <bg-layer> , ]* <final-bg-layer>", "background-attachment": "<attachment>#", "background-blend-mode": "<blend-mode>#", "background-clip": "<box>#", "background-color": "<color>", "background-image": "<bg-image>#", "background-origin": "<box>#", "background-position": "<bg-position>#", "background-position-x": "[ center | [ left | right | x-start | x-end ]? <length-percentage>? ]#", "background-position-y": "[ center | [ top | bottom | y-start | y-end ]? <length-percentage>? ]#", "background-repeat": "<repeat-style>#", "background-size": "<bg-size>#", "block-overflow": "clip | ellipsis | <string>", "block-size": "<'width'>", "border": "<line-width> || <line-style> || <color>", "border-block": "<'border-top-width'> || <'border-top-style'> || <'color'>", "border-block-color": "<'border-top-color'>{1,2}", "border-block-style": "<'border-top-style'>", "border-block-width": "<'border-top-width'>", "border-block-end": "<'border-top-width'> || <'border-top-style'> || <'color'>", "border-block-end-color": "<'border-top-color'>", "border-block-end-style": "<'border-top-style'>", "border-block-end-width": "<'border-top-width'>", "border-block-start": "<'border-top-width'> || <'border-top-style'> || <'color'>", "border-block-start-color": "<'border-top-color'>", "border-block-start-style": "<'border-top-style'>", "border-block-start-width": "<'border-top-width'>", "border-bottom": "<line-width> || <line-style> || <color>", "border-bottom-color": "<'border-top-color'>", "border-bottom-left-radius": "<length-percentage>{1,2}", "border-bottom-right-radius": "<length-percentage>{1,2}", "border-bottom-style": "<line-style>", "border-bottom-width": "<line-width>", "border-collapse": "collapse | separate", "border-color": "<color>{1,4}", "border-end-end-radius": "<length-percentage>{1,2}", "border-end-start-radius": "<length-percentage>{1,2}", "border-image": "<'border-image-source'> || <'border-image-slice'> [ / <'border-image-width'> | / <'border-image-width'>? / <'border-image-outset'> ]? || <'border-image-repeat'>", "border-image-outset": "[ <length> | <number> ]{1,4}", "border-image-repeat": "[ stretch | repeat | round | space ]{1,2}", "border-image-slice": "<number-percentage>{1,4} && fill?", "border-image-source": "none | <image>", "border-image-width": "[ <length-percentage> | <number> | auto ]{1,4}", "border-inline": "<'border-top-width'> || <'border-top-style'> || <'color'>", "border-inline-end": "<'border-top-width'> || <'border-top-style'> || <'color'>", "border-inline-color": "<'border-top-color'>{1,2}", "border-inline-style": "<'border-top-style'>", "border-inline-width": "<'border-top-width'>", "border-inline-end-color": "<'border-top-color'>", "border-inline-end-style": "<'border-top-style'>", "border-inline-end-width": "<'border-top-width'>", "border-inline-start": "<'border-top-width'> || <'border-top-style'> || <'color'>", "border-inline-start-color": "<'border-top-color'>", "border-inline-start-style": "<'border-top-style'>", "border-inline-start-width": "<'border-top-width'>", "border-left": "<line-width> || <line-style> || <color>", "border-left-color": "<color>", "border-left-style": "<line-style>", "border-left-width": "<line-width>", "border-radius": "<length-percentage>{1,4} [ / <length-percentage>{1,4} ]?", "border-right": "<line-width> || <line-style> || <color>", "border-right-color": "<color>", "border-right-style": "<line-style>", "border-right-width": "<line-width>", "border-spacing": "<length> <length>?", "border-start-end-radius": "<length-percentage>{1,2}", "border-start-start-radius": "<length-percentage>{1,2}", "border-style": "<line-style>{1,4}", "border-top": "<line-width> || <line-style> || <color>", "border-top-color": "<color>", "border-top-left-radius": "<length-percentage>{1,2}", "border-top-right-radius": "<length-percentage>{1,2}", "border-top-style": "<line-style>", "border-top-width": "<line-width>", "border-width": "<line-width>{1,4}", "bottom": "<length> | <percentage> | auto", "box-align": "start | center | end | baseline | stretch", "box-decoration-break": "slice | clone", "box-direction": "normal | reverse | inherit", "box-flex": "<number>", "box-flex-group": "<integer>", "box-lines": "single | multiple", "box-ordinal-group": "<integer>", "box-orient": "horizontal | vertical | inline-axis | block-axis | inherit", "box-pack": "start | center | end | justify", "box-shadow": "none | <shadow>#", "box-sizing": "content-box | border-box", "break-after": "auto | avoid | always | all | avoid-page | page | left | right | recto | verso | avoid-column | column | avoid-region | region", "break-before": "auto | avoid | always | all | avoid-page | page | left | right | recto | verso | avoid-column | column | avoid-region | region", "break-inside": "auto | avoid | avoid-page | avoid-column | avoid-region", "caption-side": "top | bottom | block-start | block-end | inline-start | inline-end", "caret-color": "auto | <color>", "clear": "none | left | right | both | inline-start | inline-end", "clip": "<shape> | auto", "clip-path": "<clip-source> | [ <basic-shape> || <geometry-box> ] | none", "color": "<color>", "color-adjust": "economy | exact", "column-count": "<integer> | auto", "column-fill": "auto | balance | balance-all", "column-gap": "normal | <length-percentage>", "column-rule": "<'column-rule-width'> || <'column-rule-style'> || <'column-rule-color'>", "column-rule-color": "<color>", "column-rule-style": "<'border-style'>", "column-rule-width": "<'border-width'>", "column-span": "none | all", "column-width": "<length> | auto", "columns": "<'column-width'> || <'column-count'>", "contain": "none | strict | content | [ size || layout || style || paint ]", "content": "normal | none | [ <content-replacement> | <content-list> ] [ / <string> ]?", "counter-increment": "[ <custom-ident> <integer>? ]+ | none", "counter-reset": "[ <custom-ident> <integer>? ]+ | none", "counter-set": "[ <custom-ident> <integer>? ]+ | none", "cursor": "[ [ <url> [ <x> <y> ]? , ]* [ auto | default | none | context-menu | help | pointer | progress | wait | cell | crosshair | text | vertical-text | alias | copy | move | no-drop | not-allowed | e-resize | n-resize | ne-resize | nw-resize | s-resize | se-resize | sw-resize | w-resize | ew-resize | ns-resize | nesw-resize | nwse-resize | col-resize | row-resize | all-scroll | zoom-in | zoom-out | grab | grabbing | hand | -webkit-grab | -webkit-grabbing | -webkit-zoom-in | -webkit-zoom-out | -moz-grab | -moz-grabbing | -moz-zoom-in | -moz-zoom-out ] ]", "direction": "ltr | rtl", "display": "none | inline | block | list-item | inline-list-item | inline-block | inline-table | table | table-cell | table-column | table-column-group | table-footer-group | table-header-group | table-row | table-row-group | flex | inline-flex | grid | inline-grid | run-in | ruby | ruby-base | ruby-text | ruby-base-container | ruby-text-container | contents | -ms-flexbox | -ms-inline-flexbox | -ms-grid | -ms-inline-grid | -webkit-flex | -webkit-inline-flex | -webkit-box | -webkit-inline-box | -moz-inline-stack | -moz-box | -moz-inline-box", "empty-cells": "show | hide", "filter": "none | <filter-function-list> | <-ms-filter-function-list>", "flex": "none | [ <'flex-grow'> <'flex-shrink'>? || <'flex-basis'> ]", "flex-basis": "content | <'width'>", "flex-direction": "row | row-reverse | column | column-reverse", "flex-flow": "<'flex-direction'> || <'flex-wrap'>", "flex-grow": "<number>", "flex-shrink": "<number>", "flex-wrap": "nowrap | wrap | wrap-reverse", "float": "left | right | none | inline-start | inline-end", "font": "[ [ <'font-style'> || <font-variant-css21> || <'font-weight'> || <'font-stretch'> ]? <'font-size'> [ / <'line-height'> ]? <'font-family'> ] | caption | icon | menu | message-box | small-caption | status-bar", "font-family": "[ <family-name> | <generic-family> ]#", "font-feature-settings": "normal | <feature-tag-value>#", "font-kerning": "auto | normal | none", "font-language-override": "normal | <string>", "font-optical-sizing": "auto | none", "font-variation-settings": "normal | [ <string> <number> ]#", "font-size": "<absolute-size> | <relative-size> | <length-percentage>", "font-size-adjust": "none | <number>", "font-stretch": "<font-stretch-absolute>", "font-style": "normal | italic | oblique <angle>?", "font-synthesis": "none | [ weight || style ]", "font-variant": "normal | none | [ <common-lig-values> || <discretionary-lig-values> || <historical-lig-values> || <contextual-alt-values> || stylistic( <feature-value-name> ) || historical-forms || styleset( <feature-value-name># ) || character-variant( <feature-value-name># ) || swash( <feature-value-name> ) || ornaments( <feature-value-name> ) || annotation( <feature-value-name> ) || [ small-caps | all-small-caps | petite-caps | all-petite-caps | unicase | titling-caps ] || <numeric-figure-values> || <numeric-spacing-values> || <numeric-fraction-values> || ordinal || slashed-zero || <east-asian-variant-values> || <east-asian-width-values> || ruby ]", "font-variant-alternates": "normal | [ stylistic( <feature-value-name> ) || historical-forms || styleset( <feature-value-name># ) || character-variant( <feature-value-name># ) || swash( <feature-value-name> ) || ornaments( <feature-value-name> ) || annotation( <feature-value-name> ) ]", "font-variant-caps": "normal | small-caps | all-small-caps | petite-caps | all-petite-caps | unicase | titling-caps", "font-variant-east-asian": "normal | [ <east-asian-variant-values> || <east-asian-width-values> || ruby ]", "font-variant-ligatures": "normal | none | [ <common-lig-values> || <discretionary-lig-values> || <historical-lig-values> || <contextual-alt-values> ]", "font-variant-numeric": "normal | [ <numeric-figure-values> || <numeric-spacing-values> || <numeric-fraction-values> || ordinal || slashed-zero ]", "font-variant-position": "normal | sub | super", "font-weight": "<font-weight-absolute> | bolder | lighter", "gap": "<'row-gap'> <'column-gap'>?", "grid": "<'grid-template'> | <'grid-template-rows'> / [ auto-flow && dense? ] <'grid-auto-columns'>? | [ auto-flow && dense? ] <'grid-auto-rows'>? / <'grid-template-columns'>", "grid-area": "<grid-line> [ / <grid-line> ]{0,3}", "grid-auto-columns": "<track-size>+", "grid-auto-flow": "[ row | column ] || dense", "grid-auto-rows": "<track-size>+", "grid-column": "<grid-line> [ / <grid-line> ]?", "grid-column-end": "<grid-line>", "grid-column-gap": "<length-percentage>", "grid-column-start": "<grid-line>", "grid-gap": "<'grid-row-gap'> <'grid-column-gap'>?", "grid-row": "<grid-line> [ / <grid-line> ]?", "grid-row-end": "<grid-line>", "grid-row-gap": "<length-percentage>", "grid-row-start": "<grid-line>", "grid-template": "none | [ <'grid-template-rows'> / <'grid-template-columns'> ] | [ <line-names>? <string> <track-size>? <line-names>? ]+ [ / <explicit-track-list> ]?", "grid-template-areas": "none | <string>+", "grid-template-columns": "none | <track-list> | <auto-track-list>", "grid-template-rows": "none | <track-list> | <auto-track-list>", "hanging-punctuation": "none | [ first || [ force-end | allow-end ] || last ]", "height": "[ <length> | <percentage> ] && [ border-box | content-box ]? | available | min-content | max-content | fit-content | auto", "hyphens": "none | manual | auto", "image-orientation": "from-image | <angle> | [ <angle>? flip ]", "image-rendering": "auto | crisp-edges | pixelated | optimizeSpeed | optimizeQuality | <-non-standard-image-rendering>", "image-resolution": "[ from-image || <resolution> ] && snap?", "ime-mode": "auto | normal | active | inactive | disabled", "initial-letter": "normal | [ <number> <integer>? ]", "initial-letter-align": "[ auto | alphabetic | hanging | ideographic ]", "inline-size": "<'width'>", "inset": "<'top'>{1,4}", "inset-block": "<'top'>{1,2}", "inset-block-end": "<'top'>", "inset-block-start": "<'top'>", "inset-inline": "<'top'>{1,2}", "inset-inline-end": "<'top'>", "inset-inline-start": "<'top'>", "isolation": "auto | isolate", "justify-content": "normal | <content-distribution> | <overflow-position>? [ <content-position> | left | right ]", "justify-items": "normal | stretch | <baseline-position> | <overflow-position>? [ <self-position> | left | right ] | legacy | legacy && [ left | right | center ]", "justify-self": "auto | normal | stretch | <baseline-position> | <overflow-position>? [ <self-position> | left | right ]", "left": "<length> | <percentage> | auto", "letter-spacing": "normal | <length-percentage>", "line-break": "auto | loose | normal | strict", "line-clamp": "none | <integer>", "line-height": "normal | <number> | <length> | <percentage>", "line-height-step": "<length>", "list-style": "<'list-style-type'> || <'list-style-position'> || <'list-style-image'>", "list-style-image": "<url> | none", "list-style-position": "inside | outside", "list-style-type": "<counter-style> | <string> | none", "margin": "[ <length> | <percentage> | auto ]{1,4}", "margin-block": "<'margin-left'>{1,2}", "margin-block-end": "<'margin-left'>", "margin-block-start": "<'margin-left'>", "margin-bottom": "<length> | <percentage> | auto", "margin-inline": "<'margin-left'>{1,2}", "margin-inline-end": "<'margin-left'>", "margin-inline-start": "<'margin-left'>", "margin-left": "<length> | <percentage> | auto", "margin-right": "<length> | <percentage> | auto", "margin-top": "<length> | <percentage> | auto", "mask": "<mask-layer>#", "mask-border": "<'mask-border-source'> || <'mask-border-slice'> [ / <'mask-border-width'>? [ / <'mask-border-outset'> ]? ]? || <'mask-border-repeat'> || <'mask-border-mode'>", "mask-border-mode": "luminance | alpha", "mask-border-outset": "[ <length> | <number> ]{1,4}", "mask-border-repeat": "[ stretch | repeat | round | space ]{1,2}", "mask-border-slice": "<number-percentage>{1,4} fill?", "mask-border-source": "none | <image>", "mask-border-width": "[ <length-percentage> | <number> | auto ]{1,4}", "mask-clip": "[ <geometry-box> | no-clip ]#", "mask-composite": "<compositing-operator>#", "mask-image": "<mask-reference>#", "mask-mode": "<masking-mode>#", "mask-origin": "<geometry-box>#", "mask-position": "<position>#", "mask-repeat": "<repeat-style>#", "mask-size": "<bg-size>#", "mask-type": "luminance | alpha", "max-block-size": "<'max-width'>", "max-height": "<length> | <percentage> | none | max-content | min-content | fit-content | fill-available", "max-inline-size": "<'max-width'>", "max-lines": "none | <integer>", "max-width": "<length> | <percentage> | none | max-content | min-content | fit-content | fill-available | <-non-standard-width>", "min-block-size": "<'min-width'>", "min-height": "<length> | <percentage> | auto | max-content | min-content | fit-content | fill-available", "min-inline-size": "<'min-width'>", "min-width": "<length> | <percentage> | auto | max-content | min-content | fit-content | fill-available | <-non-standard-width>", "mix-blend-mode": "<blend-mode>", "object-fit": "fill | contain | cover | none | scale-down", "object-position": "<position>", "offset": "[ <'offset-position'>? [ <'offset-path'> [ <'offset-distance'> || <'offset-rotate'> ]? ]? ]! [ / <'offset-anchor'> ]?", "offset-anchor": "auto | <position>", "offset-distance": "<length-percentage>", "offset-path": "none | ray( [ <angle> && <size>? && contain? ] ) | <path()> | <url> | [ <basic-shape> || <geometry-box> ]", "offset-position": "auto | <position>", "offset-rotate": "[ auto | reverse ] || <angle>", "opacity": "<number-zero-one>", "order": "<integer>", "orphans": "<integer>", "outline": "[ <'outline-color'> || <'outline-style'> || <'outline-width'> ]", "outline-color": "<color> | invert", "outline-offset": "<length>", "outline-style": "auto | <'border-style'>", "outline-width": "<line-width>", "overflow": "[ visible | hidden | clip | scroll | auto ]{1,2} | <-non-standard-overflow>", "overflow-anchor": "auto | none", "overflow-block": "visible | hidden | clip | scroll | auto", "overflow-clip-box": "padding-box | content-box", "overflow-inline": "visible | hidden | clip | scroll | auto", "overflow-wrap": "normal | break-word | anywhere", "overflow-x": "visible | hidden | clip | scroll | auto", "overflow-y": "visible | hidden | clip | scroll | auto", "overscroll-behavior": "[ contain | none | auto ]{1,2}", "overscroll-behavior-x": "contain | none | auto", "overscroll-behavior-y": "contain | none | auto", "padding": "[ <length> | <percentage> ]{1,4}", "padding-block": "<'padding-left'>{1,2}", "padding-block-end": "<'padding-left'>", "padding-block-start": "<'padding-left'>", "padding-bottom": "<length> | <percentage>", "padding-inline": "<'padding-left'>{1,2}", "padding-inline-end": "<'padding-left'>", "padding-inline-start": "<'padding-left'>", "padding-left": "<length> | <percentage>", "padding-right": "<length> | <percentage>", "padding-top": "<length> | <percentage>", "page-break-after": "auto | always | avoid | left | right | recto | verso", "page-break-before": "auto | always | avoid | left | right | recto | verso", "page-break-inside": "auto | avoid", "paint-order": "normal | [ fill || stroke || markers ]", "perspective": "none | <length>", "perspective-origin": "<position>", "place-content": "<'align-content'> <'justify-content'>?", "place-items": "<'align-items'> <'justify-items'>?", "place-self": "<'align-self'> <'justify-self'>?", "pointer-events": "auto | none | visiblePainted | visibleFill | visibleStroke | visible | painted | fill | stroke | all | inherit", "position": "static | relative | absolute | sticky | fixed | -webkit-sticky", "quotes": "none | [ <string> <string> ]+", "resize": "none | both | horizontal | vertical | block | inline", "right": "<length> | <percentage> | auto", "rotate": "none | <angle> | [ x | y | z | <number>{3} ] && <angle>", "row-gap": "normal | <length-percentage>", "ruby-align": "start | center | space-between | space-around", "ruby-merge": "separate | collapse | auto", "ruby-position": "over | under | inter-character", "scale": "none | <number>{1,3}", "scrollbar-color": "auto | dark | light | <color>{2}", "scrollbar-width": "auto | thin | none", "scroll-behavior": "auto | smooth", "scroll-margin": "<length>{1,4}", "scroll-margin-block": "<length>{1,2}", "scroll-margin-block-start": "<length>", "scroll-margin-block-end": "<length>", "scroll-margin-bottom": "<length>", "scroll-margin-inline": "<length>{1,2}", "scroll-margin-inline-start": "<length>", "scroll-margin-inline-end": "<length>", "scroll-margin-left": "<length>", "scroll-margin-right": "<length>", "scroll-margin-top": "<length>", "scroll-padding": "[ auto | <length-percentage> ]{1,4}", "scroll-padding-block": "[ auto | <length-percentage> ]{1,2}", "scroll-padding-block-start": "auto | <length-percentage>", "scroll-padding-block-end": "auto | <length-percentage>", "scroll-padding-bottom": "auto | <length-percentage>", "scroll-padding-inline": "[ auto | <length-percentage> ]{1,2}", "scroll-padding-inline-start": "auto | <length-percentage>", "scroll-padding-inline-end": "auto | <length-percentage>", "scroll-padding-left": "auto | <length-percentage>", "scroll-padding-right": "auto | <length-percentage>", "scroll-padding-top": "auto | <length-percentage>", "scroll-snap-align": "[ none | start | end | center ]{1,2}", "scroll-snap-coordinate": "none | <position>#", "scroll-snap-destination": "<position>", "scroll-snap-points-x": "none | repeat( <length-percentage> )", "scroll-snap-points-y": "none | repeat( <length-percentage> )", "scroll-snap-stop": "normal | always", "scroll-snap-type": "none | [ x | y | block | inline | both ] [ mandatory | proximity ]?", "scroll-snap-type-x": "none | mandatory | proximity", "scroll-snap-type-y": "none | mandatory | proximity", "shape-image-threshold": "<number>", "shape-margin": "<length-percentage>", "shape-outside": "none | <shape-box> || <basic-shape> | <image>", "tab-size": "<integer> | <length>", "table-layout": "auto | fixed", "text-align": "start | end | left | right | center | justify | match-parent", "text-align-last": "auto | start | end | left | right | center | justify", "text-combine-upright": "none | all | [ digits <integer>? ]", "text-decoration": "<'text-decoration-line'> || <'text-decoration-style'> || <'text-decoration-color'>", "text-decoration-color": "<color>", "text-decoration-line": "none | [ underline || overline || line-through || blink ]", "text-decoration-skip": "none | [ objects || [ spaces | [ leading-spaces || trailing-spaces ] ] || edges || box-decoration ]", "text-decoration-skip-ink": "auto | none", "text-decoration-style": "solid | double | dotted | dashed | wavy", "text-emphasis": "<'text-emphasis-style'> || <'text-emphasis-color'>", "text-emphasis-color": "<color>", "text-emphasis-position": "[ over | under ] && [ right | left ]", "text-emphasis-style": "none | [ [ filled | open ] || [ dot | circle | double-circle | triangle | sesame ] ] | <string>", "text-indent": "<length-percentage> && hanging? && each-line?", "text-justify": "auto | inter-character | inter-word | none", "text-orientation": "mixed | upright | sideways", "text-overflow": "[ clip | ellipsis | <string> ]{1,2}", "text-rendering": "auto | optimizeSpeed | optimizeLegibility | geometricPrecision", "text-shadow": "none | <shadow-t>#", "text-size-adjust": "none | auto | <percentage>", "text-transform": "none | capitalize | uppercase | lowercase | full-width | full-size-kana", "text-underline-position": "auto | [ under || [ left | right ] ]", "top": "<length> | <percentage> | auto", "touch-action": "auto | none | [ [ pan-x | pan-left | pan-right ] || [ pan-y | pan-up | pan-down ] || pinch-zoom ] | manipulation", "transform": "none | <transform-list>", "transform-box": "border-box | fill-box | view-box", "transform-origin": "[ <length-percentage> | left | center | right | top | bottom ] | [ [ <length-percentage> | left | center | right ] && [ <length-percentage> | top | center | bottom ] ] <length>?", "transform-style": "flat | preserve-3d", "transition": "<single-transition>#", "transition-delay": "<time>#", "transition-duration": "<time>#", "transition-property": "none | <single-transition-property>#", "transition-timing-function": "<timing-function>#", "translate": "none | <length-percentage> [ <length-percentage> <length>? ]?", "unicode-bidi": "normal | embed | isolate | bidi-override | isolate-override | plaintext | -moz-isolate | -moz-isolate-override | -moz-plaintext | -webkit-isolate", "user-select": "auto | text | none | contain | all", "vertical-align": "baseline | sub | super | text-top | text-bottom | middle | top | bottom | <percentage> | <length>", "visibility": "visible | hidden | collapse", "white-space": "normal | pre | nowrap | pre-wrap | pre-line", "widows": "<integer>", "width": "[ <length> | <percentage> ] && [ border-box | content-box ]? | available | min-content | max-content | fit-content | auto", "will-change": "auto | <animateable-feature>#", "word-break": "normal | break-all | keep-all | break-word", "word-spacing": "normal | <length-percentage>", "word-wrap": "normal | break-word", "writing-mode": "horizontal-tb | vertical-rl | vertical-lr | sideways-rl | sideways-lr | <svg-writing-mode>", "z-index": "auto | <integer>", "zoom": "normal | reset | <number> | <percentage>", "-moz-background-clip": "padding | border", "-moz-border-radius-bottomleft": "<'border-bottom-left-radius'>", "-moz-border-radius-bottomright": "<'border-bottom-right-radius'>", "-moz-border-radius-topleft": "<'border-top-left-radius'>", "-moz-border-radius-topright": "<'border-bottom-right-radius'>", "-moz-osx-font-smoothing": "auto | grayscale", "-moz-user-select": "none | text | all | -moz-none", "-ms-flex-align": "start | end | center | baseline | stretch", "-ms-flex-item-align": "auto | start | end | center | baseline | stretch", "-ms-flex-line-pack": "start | end | center | justify | distribute | stretch", "-ms-flex-negative": "<'flex-shrink'>", "-ms-flex-pack": "start | end | center | justify | distribute", "-ms-flex-order": "<integer>", "-ms-flex-positive": "<'flex-grow'>", "-ms-flex-preferred-size": "<'flex-basis'>", "-ms-interpolation-mode": "nearest-neighbor | bicubic", "-ms-grid-column-align": "start | end | center | stretch", "-ms-grid-row-align": "start | end | center | stretch", "-webkit-background-clip": "[ <box> | border | padding | content | text ]#", "-webkit-column-break-after": "always | auto | avoid", "-webkit-column-break-before": "always | auto | avoid", "-webkit-column-break-inside": "always | auto | avoid", "-webkit-font-smoothing": "auto | none | antialiased | subpixel-antialiased", "-webkit-mask-box-image": "[ <url> | <gradient> | none ] [ <length-percentage>{4} <-webkit-mask-box-repeat>{2} ]?", "-webkit-print-color-adjust": "economy | exact", "-webkit-text-security": "none | circle | disc | square", "-webkit-user-drag": "none | element | auto", "-webkit-user-select": "auto | none | text | all", "alignment-baseline": "auto | baseline | before-edge | text-before-edge | middle | central | after-edge | text-after-edge | ideographic | alphabetic | hanging | mathematical", "baseline-shift": "baseline | sub | super | <svg-length>", "behavior": "<url>+", "clip-rule": "nonzero | evenodd", "cue": "<'cue-before'> <'cue-after'>?", "cue-after": "<url> <decibel>? | none", "cue-before": "<url> <decibel>? | none", "dominant-baseline": "auto | use-script | no-change | reset-size | ideographic | alphabetic | hanging | mathematical | central | middle | text-after-edge | text-before-edge", "fill": "<paint>", "fill-opacity": "<number-zero-one>", "fill-rule": "nonzero | evenodd", "glyph-orientation-horizontal": "<angle>", "glyph-orientation-vertical": "<angle>", "kerning": "auto | <svg-length>", "marker": "none | <url>", "marker-end": "none | <url>", "marker-mid": "none | <url>", "marker-start": "none | <url>", "pause": "<'pause-before'> <'pause-after'>?", "pause-after": "<time> | none | x-weak | weak | medium | strong | x-strong", "pause-before": "<time> | none | x-weak | weak | medium | strong | x-strong", "rest": "<'rest-before'> <'rest-after'>?", "rest-after": "<time> | none | x-weak | weak | medium | strong | x-strong", "rest-before": "<time> | none | x-weak | weak | medium | strong | x-strong", "shape-rendering": "auto | optimizeSpeed | crispEdges | geometricPrecision", "src": "[ <url> [ format( <string># ) ]? | local( <family-name> ) ]#", "speak": "auto | none | normal", "speak-as": "normal | spell-out || digits || [ literal-punctuation | no-punctuation ]", "stroke": "<paint>", "stroke-dasharray": "none | [ <svg-length>+ ]#", "stroke-dashoffset": "<svg-length>", "stroke-linecap": "butt | round | square", "stroke-linejoin": "miter | round | bevel", "stroke-miterlimit": "<number-one-or-greater>", "stroke-opacity": "<number-zero-one>", "stroke-width": "<svg-length>", "text-anchor": "start | middle | end", "unicode-range": "<urange>#", "voice-balance": "<number> | left | center | right | leftwards | rightwards", "voice-duration": "auto | <time>", "voice-family": "[ [ <family-name> | <generic-voice> ] , ]* [ <family-name> | <generic-voice> ] | preserve", "voice-pitch": "<frequency> && absolute | [ [ x-low | low | medium | high | x-high ] || [ <frequency> | <semitones> | <percentage> ] ]", "voice-range": "<frequency> && absolute | [ [ x-low | low | medium | high | x-high ] || [ <frequency> | <semitones> | <percentage> ] ]", "voice-rate": "[ normal | x-slow | slow | medium | fast | x-fast ] || <percentage>", "voice-stress": "normal | strong | moderate | none | reduced", "voice-volume": "silent | [ [ x-soft | soft | medium | loud | x-loud ] || <decibel> ]" } };
  33. }, {}], 2: [function (require, module, exports) {
  34. function createItem(data) {
  35. return {
  36. prev: null,
  37. next: null,
  38. data: data
  39. };
  40. }
  41. function allocateCursor(node, prev, next) {
  42. var cursor;
  43. if (cursors !== null) {
  44. cursor = cursors;
  45. cursors = cursors.cursor;
  46. cursor.prev = prev;
  47. cursor.next = next;
  48. cursor.cursor = node.cursor;
  49. } else {
  50. cursor = {
  51. prev: prev,
  52. next: next,
  53. cursor: node.cursor
  54. };
  55. }
  56. node.cursor = cursor;
  57. return cursor;
  58. }
  59. function releaseCursor(node) {
  60. var cursor = node.cursor;
  61. node.cursor = cursor.cursor;
  62. cursor.prev = null;
  63. cursor.next = null;
  64. cursor.cursor = cursors;
  65. cursors = cursor;
  66. }
  67. var cursors = null;
  68. var List = function () {
  69. this.cursor = null;
  70. this.head = null;
  71. this.tail = null;
  72. };
  73. List.createItem = createItem;
  74. List.prototype.createItem = createItem;
  75. List.prototype.updateCursors = function (prevOld, prevNew, nextOld, nextNew) {
  76. var cursor = this.cursor;
  77. while (cursor !== null) {
  78. if (cursor.prev === prevOld) {
  79. cursor.prev = prevNew;
  80. }
  81. if (cursor.next === nextOld) {
  82. cursor.next = nextNew;
  83. }
  84. cursor = cursor.cursor;
  85. }
  86. };
  87. List.prototype.getSize = function () {
  88. var size = 0;
  89. var cursor = this.head;
  90. while (cursor) {
  91. size++;
  92. cursor = cursor.next;
  93. }
  94. return size;
  95. };
  96. List.prototype.fromArray = function (array) {
  97. var cursor = null;
  98. this.head = null;
  99. for (var i = 0; i < array.length; i++) {
  100. var item = createItem(array[i]);
  101. if (cursor !== null) {
  102. cursor.next = item;
  103. } else {
  104. this.head = item;
  105. }
  106. item.prev = cursor;
  107. cursor = item;
  108. }
  109. this.tail = cursor;
  110. return this;
  111. };
  112. List.prototype.toArray = function () {
  113. var cursor = this.head;
  114. var result = [];
  115. while (cursor) {
  116. result.push(cursor.data);
  117. cursor = cursor.next;
  118. }
  119. return result;
  120. };
  121. List.prototype.toJSON = List.prototype.toArray;
  122. List.prototype.isEmpty = function () {
  123. return this.head === null;
  124. };
  125. List.prototype.first = function () {
  126. return this.head && this.head.data;
  127. };
  128. List.prototype.last = function () {
  129. return this.tail && this.tail.data;
  130. };
  131. List.prototype.each = function (fn, context) {
  132. var item;
  133. if (context === undefined) {
  134. context = this;
  135. }
  136. var cursor = allocateCursor(this, null, this.head);
  137. while (cursor.next !== null) {
  138. item = cursor.next;
  139. cursor.next = item.next;
  140. fn.call(context, item.data, item, this);
  141. }
  142. releaseCursor(this);
  143. };
  144. List.prototype.forEach = List.prototype.each;
  145. List.prototype.eachRight = function (fn, context) {
  146. var item;
  147. if (context === undefined) {
  148. context = this;
  149. }
  150. var cursor = allocateCursor(this, this.tail, null);
  151. while (cursor.prev !== null) {
  152. item = cursor.prev;
  153. cursor.prev = item.prev;
  154. fn.call(context, item.data, item, this);
  155. }
  156. releaseCursor(this);
  157. };
  158. List.prototype.forEachRight = List.prototype.eachRight;
  159. List.prototype.nextUntil = function (start, fn, context) {
  160. if (start === null) {
  161. return;
  162. }
  163. var item;
  164. if (context === undefined) {
  165. context = this;
  166. }
  167. var cursor = allocateCursor(this, null, start);
  168. while (cursor.next !== null) {
  169. item = cursor.next;
  170. cursor.next = item.next;
  171. if (fn.call(context, item.data, item, this)) {
  172. break;
  173. }
  174. }
  175. releaseCursor(this);
  176. };
  177. List.prototype.prevUntil = function (start, fn, context) {
  178. if (start === null) {
  179. return;
  180. }
  181. var item;
  182. if (context === undefined) {
  183. context = this;
  184. }
  185. var cursor = allocateCursor(this, start, null);
  186. while (cursor.prev !== null) {
  187. item = cursor.prev;
  188. cursor.prev = item.prev;
  189. if (fn.call(context, item.data, item, this)) {
  190. break;
  191. }
  192. }
  193. releaseCursor(this);
  194. };
  195. List.prototype.some = function (fn, context) {
  196. var cursor = this.head;
  197. if (context === undefined) {
  198. context = this;
  199. }
  200. while (cursor !== null) {
  201. if (fn.call(context, cursor.data, cursor, this)) {
  202. return true;
  203. }
  204. cursor = cursor.next;
  205. }
  206. return false;
  207. };
  208. List.prototype.map = function (fn, context) {
  209. var result = new List();
  210. var cursor = this.head;
  211. if (context === undefined) {
  212. context = this;
  213. }
  214. while (cursor !== null) {
  215. result.appendData(fn.call(context, cursor.data, cursor, this));
  216. cursor = cursor.next;
  217. }
  218. return result;
  219. };
  220. List.prototype.filter = function (fn, context) {
  221. var result = new List();
  222. var cursor = this.head;
  223. if (context === undefined) {
  224. context = this;
  225. }
  226. while (cursor !== null) {
  227. if (fn.call(context, cursor.data, cursor, this)) {
  228. result.appendData(cursor.data);
  229. }
  230. cursor = cursor.next;
  231. }
  232. return result;
  233. };
  234. List.prototype.clear = function () {
  235. this.head = null;
  236. this.tail = null;
  237. };
  238. List.prototype.copy = function () {
  239. var result = new List();
  240. var cursor = this.head;
  241. while (cursor !== null) {
  242. result.insert(createItem(cursor.data));
  243. cursor = cursor.next;
  244. }
  245. return result;
  246. };
  247. List.prototype.prepend = function (item) {
  248. this.updateCursors(null, item, this.head, item);
  249. if (this.head !== null) {
  250. this.head.prev = item;
  251. item.next = this.head;
  252. } else {
  253. this.tail = item;
  254. }
  255. this.head = item;
  256. return this;
  257. };
  258. List.prototype.prependData = function (data) {
  259. return this.prepend(createItem(data));
  260. };
  261. List.prototype.append = function (item) {
  262. return this.insert(item);
  263. };
  264. List.prototype.appendData = function (data) {
  265. return this.insert(createItem(data));
  266. };
  267. List.prototype.insert = function (item, before) {
  268. if (before !== undefined && before !== null) {
  269. this.updateCursors(before.prev, item, before, item);
  270. if (before.prev === null) {
  271. if (this.head !== before) {
  272. throw new Error("before doesn't belong to list");
  273. }
  274. this.head = item;
  275. before.prev = item;
  276. item.next = before;
  277. this.updateCursors(null, item);
  278. } else {
  279. before.prev.next = item;
  280. item.prev = before.prev;
  281. before.prev = item;
  282. item.next = before;
  283. }
  284. } else {
  285. this.updateCursors(this.tail, item, null, item);
  286. if (this.tail !== null) {
  287. this.tail.next = item;
  288. item.prev = this.tail;
  289. } else {
  290. this.head = item;
  291. }
  292. this.tail = item;
  293. }
  294. return this;
  295. };
  296. List.prototype.insertData = function (data, before) {
  297. return this.insert(createItem(data), before);
  298. };
  299. List.prototype.remove = function (item) {
  300. this.updateCursors(item, item.prev, item, item.next);
  301. if (item.prev !== null) {
  302. item.prev.next = item.next;
  303. } else {
  304. if (this.head !== item) {
  305. throw new Error("item doesn't belong to list");
  306. }
  307. this.head = item.next;
  308. }
  309. if (item.next !== null) {
  310. item.next.prev = item.prev;
  311. } else {
  312. if (this.tail !== item) {
  313. throw new Error("item doesn't belong to list");
  314. }
  315. this.tail = item.prev;
  316. }
  317. item.prev = null;
  318. item.next = null;
  319. return item;
  320. };
  321. List.prototype.push = function (data) {
  322. this.insert(createItem(data));
  323. };
  324. List.prototype.pop = function () {
  325. if (this.tail !== null) {
  326. return this.remove(this.tail);
  327. }
  328. };
  329. List.prototype.unshift = function (data) {
  330. this.prepend(createItem(data));
  331. };
  332. List.prototype.shift = function () {
  333. if (this.head !== null) {
  334. return this.remove(this.head);
  335. }
  336. };
  337. List.prototype.prependList = function (list) {
  338. return this.insertList(list, this.head);
  339. };
  340. List.prototype.appendList = function (list) {
  341. return this.insertList(list);
  342. };
  343. List.prototype.insertList = function (list, before) {
  344. if (list.head === null) {
  345. return this;
  346. }
  347. if (before !== undefined && before !== null) {
  348. this.updateCursors(before.prev, list.tail, before, list.head);
  349. if (before.prev !== null) {
  350. before.prev.next = list.head;
  351. list.head.prev = before.prev;
  352. } else {
  353. this.head = list.head;
  354. }
  355. before.prev = list.tail;
  356. list.tail.next = before;
  357. } else {
  358. this.updateCursors(this.tail, list.tail, null, list.head);
  359. if (this.tail !== null) {
  360. this.tail.next = list.head;
  361. list.head.prev = this.tail;
  362. } else {
  363. this.head = list.head;
  364. }
  365. this.tail = list.tail;
  366. }
  367. list.head = null;
  368. list.tail = null;
  369. return this;
  370. };
  371. List.prototype.replace = function (oldItem, newItemOrList) {
  372. if ("head" in newItemOrList) {
  373. this.insertList(newItemOrList, oldItem);
  374. } else {
  375. this.insert(newItemOrList, oldItem);
  376. }
  377. this.remove(oldItem);
  378. };
  379. module.exports = List;
  380. }, {}], 3: [function (require, module, exports) {
  381. var adoptBuffer = require("./adopt-buffer");
  382. var isBOM = require("../tokenizer").isBOM;
  383. var N = 10;
  384. var F = 12;
  385. var R = 13;
  386. function computeLinesAndColumns(host, source) {
  387. var sourceLength = source.length;
  388. var lines = adoptBuffer(host.lines, sourceLength); // +1
  389. var line = host.startLine;
  390. var columns = adoptBuffer(host.columns, sourceLength);
  391. var column = host.startColumn;
  392. var startOffset = source.length > 0 ? isBOM(source.charCodeAt(0)) : 0;
  393. for (var i = startOffset; i < sourceLength; i++) { // -1
  394. var code = source.charCodeAt(i);
  395. lines[i] = line;
  396. columns[i] = column++;
  397. if (code === N || code === R || code === F) {
  398. if (code === R && i + 1 < sourceLength && source.charCodeAt(i + 1) === N) {
  399. i++;
  400. lines[i] = line;
  401. columns[i] = column;
  402. }
  403. line++;
  404. column = 1;
  405. }
  406. }
  407. lines[i] = line;
  408. columns[i] = column;
  409. host.lines = lines;
  410. host.columns = columns;
  411. }
  412. var OffsetToLocation = function () {
  413. this.lines = null;
  414. this.columns = null;
  415. this.linesAndColumnsComputed = false;
  416. };
  417. OffsetToLocation.prototype = {
  418. setSource: function (source, startOffset, startLine, startColumn) {
  419. this.source = source;
  420. this.startOffset = typeof startOffset === "undefined" ? 0 : startOffset;
  421. this.startLine = typeof startLine === "undefined" ? 1 : startLine;
  422. this.startColumn = typeof startColumn === "undefined" ? 1 : startColumn;
  423. this.linesAndColumnsComputed = false;
  424. },
  425. ensureLinesAndColumnsComputed: function () {
  426. if (!this.linesAndColumnsComputed) {
  427. computeLinesAndColumns(this, this.source);
  428. this.linesAndColumnsComputed = true;
  429. }
  430. },
  431. getLocation: function (offset, filename) {
  432. this.ensureLinesAndColumnsComputed();
  433. return {
  434. source: filename,
  435. offset: this.startOffset + offset,
  436. line: this.lines[offset],
  437. column: this.columns[offset]
  438. };
  439. },
  440. getLocationRange: function (start, end, filename) {
  441. this.ensureLinesAndColumnsComputed();
  442. return {
  443. source: filename,
  444. start: {
  445. offset: this.startOffset + start,
  446. line: this.lines[start],
  447. column: this.columns[start]
  448. },
  449. end: {
  450. offset: this.startOffset + end,
  451. line: this.lines[end],
  452. column: this.columns[end]
  453. }
  454. };
  455. }
  456. };
  457. module.exports = OffsetToLocation;
  458. }, { "../tokenizer": 107, "./adopt-buffer": 6 }], 4: [function (require, module, exports) {
  459. var createCustomError = require("../utils/createCustomError");
  460. var MAX_LINE_LENGTH = 100;
  461. var OFFSET_CORRECTION = 60;
  462. var TAB_REPLACEMENT = " ";
  463. function sourceFragment(error, extraLines) {
  464. function processLines(start, end) {
  465. return lines.slice(start, end).map(function (line, idx) {
  466. var num = String(start + idx + 1);
  467. while (num.length < maxNumLength) {
  468. num = " " + num;
  469. }
  470. return num + " |" + line;
  471. }).join("\n");
  472. }
  473. var lines = error.source.split(/\r\n?|\n|\f/);
  474. var line = error.line;
  475. var column = error.column;
  476. var startLine = Math.max(1, line - extraLines) - 1;
  477. var endLine = Math.min(line + extraLines, lines.length + 1);
  478. var maxNumLength = Math.max(4, String(endLine).length) + 1;
  479. var cutLeft = 0;
  480. column += (TAB_REPLACEMENT.length - 1) * (lines[line - 1].substr(0, column - 1).match(/\t/g) || []).length;
  481. if (column > MAX_LINE_LENGTH) {
  482. cutLeft = column - OFFSET_CORRECTION + 3;
  483. column = OFFSET_CORRECTION - 2;
  484. }
  485. for (var i = startLine; i <= endLine; i++) {
  486. if (i >= 0 && i < lines.length) {
  487. lines[i] = lines[i].replace(/\t/g, TAB_REPLACEMENT);
  488. lines[i] =
  489. (cutLeft > 0 && lines[i].length > cutLeft ? "\u2026" : "") +
  490. lines[i].substr(cutLeft, MAX_LINE_LENGTH - 2) +
  491. (lines[i].length > cutLeft + MAX_LINE_LENGTH - 1 ? "\u2026" : "");
  492. }
  493. }
  494. return [
  495. processLines(startLine, line),
  496. new Array(column + maxNumLength + 2).join("-") + "^",
  497. processLines(line, endLine)
  498. ].filter(Boolean).join("\n");
  499. }
  500. var SyntaxError = function (message, source, offset, line, column) {
  501. var error = createCustomError("SyntaxError", message);
  502. error.source = source;
  503. error.offset = offset;
  504. error.line = line;
  505. error.column = column;
  506. error.sourceFragment = function (extraLines) {
  507. return sourceFragment(error, isNaN(extraLines) ? 0 : extraLines);
  508. };
  509. Object.defineProperty(error, "formattedMessage", {
  510. get: function () {
  511. return (
  512. "Parse error: " + error.message + "\n" +
  513. sourceFragment(error, 2)
  514. );
  515. }
  516. });
  517. error.parseError = {
  518. offset: offset,
  519. line: line,
  520. column: column
  521. };
  522. return error;
  523. };
  524. module.exports = SyntaxError;
  525. }, { "../utils/createCustomError": 110 }], 5: [function (require, module, exports) {
  526. var constants = require("../tokenizer/const");
  527. var TYPE = constants.TYPE;
  528. var NAME = constants.NAME;
  529. var utils = require("../tokenizer/utils");
  530. var cmpStr = utils.cmpStr;
  531. var EOF = TYPE.EOF;
  532. var WHITESPACE = TYPE.WhiteSpace;
  533. var COMMENT = TYPE.Comment;
  534. var OFFSET_MASK = 0x00FFFFFF;
  535. var TYPE_SHIFT = 24;
  536. var TokenStream = function () {
  537. this.offsetAndType = null;
  538. this.balance = null;
  539. this.reset();
  540. };
  541. TokenStream.prototype = {
  542. reset: function () {
  543. this.eof = false;
  544. this.tokenIndex = -1;
  545. this.tokenType = 0;
  546. this.tokenStart = this.firstCharOffset;
  547. this.tokenEnd = this.firstCharOffset;
  548. },
  549. lookupType: function (offset) {
  550. offset += this.tokenIndex;
  551. if (offset < this.tokenCount) {
  552. return this.offsetAndType[offset] >> TYPE_SHIFT;
  553. }
  554. return EOF;
  555. },
  556. lookupOffset: function (offset) {
  557. offset += this.tokenIndex;
  558. if (offset < this.tokenCount) {
  559. return this.offsetAndType[offset - 1] & OFFSET_MASK;
  560. }
  561. return this.source.length;
  562. },
  563. lookupValue: function (offset, referenceStr) {
  564. offset += this.tokenIndex;
  565. if (offset < this.tokenCount) {
  566. return cmpStr(
  567. this.source,
  568. this.offsetAndType[offset - 1] & OFFSET_MASK,
  569. this.offsetAndType[offset] & OFFSET_MASK,
  570. referenceStr
  571. );
  572. }
  573. return false;
  574. },
  575. getTokenStart: function (tokenIndex) {
  576. if (tokenIndex === this.tokenIndex) {
  577. return this.tokenStart;
  578. }
  579. if (tokenIndex > 0) {
  580. return tokenIndex < this.tokenCount
  581. ? this.offsetAndType[tokenIndex - 1] & OFFSET_MASK
  582. : this.offsetAndType[this.tokenCount] & OFFSET_MASK;
  583. }
  584. return this.firstCharOffset;
  585. },
  586. getRawLength: function (startToken, mode) {
  587. var cursor = startToken;
  588. var balanceEnd;
  589. var offset = this.offsetAndType[Math.max(cursor - 1, 0)] & OFFSET_MASK;
  590. var type;
  591. loop:
  592. for (; cursor < this.tokenCount; cursor++) {
  593. balanceEnd = this.balance[cursor];
  594. if (balanceEnd < startToken) {
  595. break loop;
  596. }
  597. type = this.offsetAndType[cursor] >> TYPE_SHIFT;
  598. switch (mode(type, this.source, offset)) {
  599. case 1:
  600. break loop;
  601. case 2:
  602. cursor++;
  603. break loop;
  604. default:
  605. offset = this.offsetAndType[cursor] & OFFSET_MASK;
  606. if (this.balance[balanceEnd] === cursor) {
  607. cursor = balanceEnd;
  608. }
  609. }
  610. }
  611. return cursor - this.tokenIndex;
  612. },
  613. isBalanceEdge: function (pos) {
  614. return this.balance[this.tokenIndex] < pos;
  615. },
  616. isDelim: function (code, offset) {
  617. if (offset) {
  618. return (
  619. this.lookupType(offset) === TYPE.Delim &&
  620. this.source.charCodeAt(this.lookupOffset(offset)) === code
  621. );
  622. }
  623. return (
  624. this.tokenType === TYPE.Delim &&
  625. this.source.charCodeAt(this.tokenStart) === code
  626. );
  627. },
  628. getTokenValue: function () {
  629. return this.source.substring(this.tokenStart, this.tokenEnd);
  630. },
  631. getTokenLength: function () {
  632. return this.tokenEnd - this.tokenStart;
  633. },
  634. substrToCursor: function (start) {
  635. return this.source.substring(start, this.tokenStart);
  636. },
  637. skipWS: function () {
  638. for (var i = this.tokenIndex, skipTokenCount = 0; i < this.tokenCount; i++ , skipTokenCount++) {
  639. if ((this.offsetAndType[i] >> TYPE_SHIFT) !== WHITESPACE) {
  640. break;
  641. }
  642. }
  643. if (skipTokenCount > 0) {
  644. this.skip(skipTokenCount);
  645. }
  646. },
  647. skipSC: function () {
  648. while (this.tokenType === WHITESPACE || this.tokenType === COMMENT) {
  649. this.next();
  650. }
  651. },
  652. skip: function (tokenCount) {
  653. var next = this.tokenIndex + tokenCount;
  654. if (next < this.tokenCount) {
  655. this.tokenIndex = next;
  656. this.tokenStart = this.offsetAndType[next - 1] & OFFSET_MASK;
  657. next = this.offsetAndType[next];
  658. this.tokenType = next >> TYPE_SHIFT;
  659. this.tokenEnd = next & OFFSET_MASK;
  660. } else {
  661. this.tokenIndex = this.tokenCount;
  662. this.next();
  663. }
  664. },
  665. next: function () {
  666. var next = this.tokenIndex + 1;
  667. if (next < this.tokenCount) {
  668. this.tokenIndex = next;
  669. this.tokenStart = this.tokenEnd;
  670. next = this.offsetAndType[next];
  671. this.tokenType = next >> TYPE_SHIFT;
  672. this.tokenEnd = next & OFFSET_MASK;
  673. } else {
  674. this.tokenIndex = this.tokenCount;
  675. this.eof = true;
  676. this.tokenType = EOF;
  677. this.tokenStart = this.tokenEnd = this.source.length;
  678. }
  679. },
  680. dump: function () {
  681. var offset = this.firstCharOffset;
  682. return Array.prototype.slice.call(this.offsetAndType, 0, this.tokenCount).map(function (item, idx) {
  683. var start = offset;
  684. var end = item & OFFSET_MASK;
  685. offset = end;
  686. return {
  687. idx: idx,
  688. type: NAME[item >> TYPE_SHIFT],
  689. chunk: this.source.substring(start, end),
  690. balance: this.balance[idx]
  691. };
  692. }, this);
  693. }
  694. };
  695. module.exports = TokenStream;
  696. }, { "../tokenizer/const": 106, "../tokenizer/utils": 108 }], 6: [function (require, module, exports) {
  697. var MIN_SIZE = 16 * 1024;
  698. var SafeUint32Array = typeof Uint32Array !== "undefined" ? Uint32Array : Array; // fallback on Array when TypedArray is not supported
  699. module.exports = function adoptBuffer(buffer, size) {
  700. if (buffer === null || buffer.length < size) {
  701. return new SafeUint32Array(Math.max(size + 1024, MIN_SIZE));
  702. }
  703. return buffer;
  704. };
  705. }, {}], 7: [function (require, module, exports) {
  706. var List = require("../common/List");
  707. module.exports = function createConvertors(walk) {
  708. return {
  709. fromPlainObject: function (ast) {
  710. walk(ast, {
  711. enter: function (node) {
  712. if (node.children && node.children instanceof List === false) {
  713. node.children = new List().fromArray(node.children);
  714. }
  715. }
  716. });
  717. return ast;
  718. },
  719. toPlainObject: function (ast) {
  720. walk(ast, {
  721. leave: function (node) {
  722. if (node.children && node.children instanceof List) {
  723. node.children = node.children.toArray();
  724. }
  725. }
  726. });
  727. return ast;
  728. }
  729. };
  730. };
  731. }, { "../common/List": 2 }], 8: [function (require, module, exports) {
  732. var sourceMap = require("./sourceMap");
  733. var hasOwnProperty = Object.prototype.hasOwnProperty;
  734. function processChildren(node, delimeter) {
  735. var list = node.children;
  736. var prev = null;
  737. if (typeof delimeter !== "function") {
  738. list.forEach(this.node, this);
  739. } else {
  740. list.forEach(function (node) {
  741. if (prev !== null) {
  742. delimeter.call(this, prev);
  743. }
  744. this.node(node);
  745. prev = node;
  746. }, this);
  747. }
  748. }
  749. module.exports = function createGenerator(config) {
  750. function processNode(node) {
  751. if (hasOwnProperty.call(types, node.type)) {
  752. types[node.type].call(this, node);
  753. } else {
  754. throw new Error("Unknown node type: " + node.type);
  755. }
  756. }
  757. var types = {};
  758. if (config.node) {
  759. for (var name in config.node) {
  760. types[name] = config.node[name].generate;
  761. }
  762. }
  763. return function (node, options) {
  764. var buffer = "";
  765. var handlers = {
  766. children: processChildren,
  767. node: processNode,
  768. chunk: function (chunk) {
  769. buffer += chunk;
  770. },
  771. result: function () {
  772. return buffer;
  773. }
  774. };
  775. if (options) {
  776. if (typeof options.decorator === "function") {
  777. handlers = options.decorator(handlers);
  778. }
  779. if (options.sourceMap) {
  780. handlers = sourceMap(handlers);
  781. }
  782. }
  783. handlers.node(node);
  784. return handlers.result();
  785. };
  786. };
  787. }, { "./sourceMap": 9 }], 9: [function (require, module, exports) {
  788. var SourceMapGenerator = require("source-map").SourceMapGenerator;
  789. var trackNodes = {
  790. Atrule: true,
  791. Selector: true,
  792. Declaration: true
  793. };
  794. module.exports = function generateSourceMap(handlers) {
  795. var map = new SourceMapGenerator();
  796. var line = 1;
  797. var column = 0;
  798. var generated = {
  799. line: 1,
  800. column: 0
  801. };
  802. var original = {
  803. line: 0, // should be zero to add first mapping
  804. column: 0
  805. };
  806. var sourceMappingActive = false;
  807. var activatedGenerated = {
  808. line: 1,
  809. column: 0
  810. };
  811. var activatedMapping = {
  812. generated: activatedGenerated
  813. };
  814. var handlersNode = handlers.node;
  815. handlers.node = function (node) {
  816. if (node.loc && node.loc.start && trackNodes.hasOwnProperty(node.type)) {
  817. var nodeLine = node.loc.start.line;
  818. var nodeColumn = node.loc.start.column - 1;
  819. if (original.line !== nodeLine ||
  820. original.column !== nodeColumn) {
  821. original.line = nodeLine;
  822. original.column = nodeColumn;
  823. generated.line = line;
  824. generated.column = column;
  825. if (sourceMappingActive) {
  826. sourceMappingActive = false;
  827. if (generated.line !== activatedGenerated.line ||
  828. generated.column !== activatedGenerated.column) {
  829. map.addMapping(activatedMapping);
  830. }
  831. }
  832. sourceMappingActive = true;
  833. map.addMapping({
  834. source: node.loc.source,
  835. original: original,
  836. generated: generated
  837. });
  838. }
  839. }
  840. handlersNode.call(this, node);
  841. if (sourceMappingActive && trackNodes.hasOwnProperty(node.type)) {
  842. activatedGenerated.line = line;
  843. activatedGenerated.column = column;
  844. }
  845. };
  846. var handlersChunk = handlers.chunk;
  847. handlers.chunk = function (chunk) {
  848. for (var i = 0; i < chunk.length; i++) {
  849. if (chunk.charCodeAt(i) === 10) { // \n
  850. line++;
  851. column = 0;
  852. } else {
  853. column++;
  854. }
  855. }
  856. handlersChunk(chunk);
  857. };
  858. var handlersResult = handlers.result;
  859. handlers.result = function () {
  860. if (sourceMappingActive) {
  861. map.addMapping(activatedMapping);
  862. }
  863. return {
  864. css: handlersResult(),
  865. map: map
  866. };
  867. };
  868. return handlers;
  869. };
  870. }, { "source-map": 123 }], 10: [function (require, module, exports) {
  871. module.exports = require("./syntax");
  872. }, { "./syntax": 44 }], 11: [function (require, module, exports) {
  873. var SyntaxReferenceError = require("./error").SyntaxReferenceError;
  874. var MatchError = require("./error").MatchError;
  875. var names = require("../utils/names");
  876. var generic = require("./generic");
  877. var parse = require("./grammar/parse");
  878. var generate = require("./grammar/generate");
  879. var walk = require("./grammar/walk");
  880. var prepareTokens = require("./prepare-tokens");
  881. var buildMatchGraph = require("./match-graph").buildMatchGraph;
  882. var matchAsTree = require("./match").matchAsTree;
  883. var trace = require("./trace");
  884. var search = require("./search");
  885. var getStructureFromConfig = require("./structure").getStructureFromConfig;
  886. var cssWideKeywords = buildMatchGraph("inherit | initial | unset");
  887. var cssWideKeywordsWithExpression = buildMatchGraph("inherit | initial | unset | <-ms-legacy-expression>");
  888. function dumpMapSyntax(map, syntaxAsAst) {
  889. var result = {};
  890. for (var name in map) {
  891. if (map[name].syntax) {
  892. result[name] = syntaxAsAst ? map[name].syntax : generate(map[name].syntax);
  893. }
  894. }
  895. return result;
  896. }
  897. function valueHasVar(tokens) {
  898. for (var i = 0; i < tokens.length; i++) {
  899. if (tokens[i].value.toLowerCase() === "var(") {
  900. return true;
  901. }
  902. }
  903. return false;
  904. }
  905. function buildMatchResult(match, error, iterations) {
  906. return {
  907. matched: match,
  908. iterations: iterations,
  909. error: error,
  910. getTrace: trace.getTrace,
  911. isType: trace.isType,
  912. isProperty: trace.isProperty,
  913. isKeyword: trace.isKeyword
  914. };
  915. }
  916. function matchSyntax(lexer, syntax, value, useCommon) {
  917. var tokens = prepareTokens(value, lexer.syntax);
  918. var result;
  919. if (valueHasVar(tokens)) {
  920. return buildMatchResult(null, new Error("Matching for a tree with var() is not supported"));
  921. }
  922. if (useCommon) {
  923. result = matchAsTree(tokens, lexer.valueCommonSyntax, lexer);
  924. }
  925. if (!useCommon || !result.match) {
  926. result = matchAsTree(tokens, syntax.match, lexer);
  927. if (!result.match) {
  928. return buildMatchResult(
  929. null,
  930. new MatchError(result.reason, syntax.syntax, value, result),
  931. result.iterations
  932. );
  933. }
  934. }
  935. return buildMatchResult(result.match, null, result.iterations);
  936. }
  937. var Lexer = function (config, syntax, structure) {
  938. this.valueCommonSyntax = cssWideKeywords;
  939. this.syntax = syntax;
  940. this.generic = false;
  941. this.properties = {};
  942. this.types = {};
  943. this.structure = structure || getStructureFromConfig(config);
  944. if (config) {
  945. if (config.types) {
  946. for (var name in config.types) {
  947. this.addType_(name, config.types[name]);
  948. }
  949. }
  950. if (config.generic) {
  951. this.generic = true;
  952. for (var name in generic) {
  953. this.addType_(name, generic[name]);
  954. }
  955. }
  956. if (config.properties) {
  957. for (var name in config.properties) {
  958. this.addProperty_(name, config.properties[name]);
  959. }
  960. }
  961. }
  962. };
  963. Lexer.prototype = {
  964. structure: {},
  965. checkStructure: function (ast) {
  966. function collectWarning(node, message) {
  967. warns.push({
  968. node: node,
  969. message: message
  970. });
  971. }
  972. var structure = this.structure;
  973. var warns = [];
  974. this.syntax.walk(ast, function (node) {
  975. if (structure.hasOwnProperty(node.type)) {
  976. structure[node.type].check(node, collectWarning);
  977. } else {
  978. collectWarning(node, "Unknown node type `" + node.type + "`");
  979. }
  980. });
  981. return warns.length ? warns : false;
  982. },
  983. createDescriptor: function (syntax, type, name) {
  984. var ref = {
  985. type: type,
  986. name: name
  987. };
  988. var descriptor = {
  989. type: type,
  990. name: name,
  991. syntax: null,
  992. match: null
  993. };
  994. if (typeof syntax === "function") {
  995. descriptor.match = buildMatchGraph(syntax, ref);
  996. } else {
  997. if (typeof syntax === "string") {
  998. Object.defineProperty(descriptor, "syntax", {
  999. get: function () {
  1000. Object.defineProperty(descriptor, "syntax", {
  1001. value: parse(syntax)
  1002. });
  1003. return descriptor.syntax;
  1004. }
  1005. });
  1006. } else {
  1007. descriptor.syntax = syntax;
  1008. }
  1009. Object.defineProperty(descriptor, "match", {
  1010. get: function () {
  1011. Object.defineProperty(descriptor, "match", {
  1012. value: buildMatchGraph(descriptor.syntax, ref)
  1013. });
  1014. return descriptor.match;
  1015. }
  1016. });
  1017. }
  1018. return descriptor;
  1019. },
  1020. addProperty_: function (name, syntax) {
  1021. this.properties[name] = this.createDescriptor(syntax, "Property", name);
  1022. },
  1023. addType_: function (name, syntax) {
  1024. this.types[name] = this.createDescriptor(syntax, "Type", name);
  1025. if (syntax === generic["-ms-legacy-expression"]) {
  1026. this.valueCommonSyntax = cssWideKeywordsWithExpression;
  1027. }
  1028. },
  1029. matchDeclaration: function (node) {
  1030. if (node.type !== "Declaration") {
  1031. return buildMatchResult(null, new Error("Not a Declaration node"));
  1032. }
  1033. return this.matchProperty(node.property, node.value);
  1034. },
  1035. matchProperty: function (propertyName, value) {
  1036. var property = names.property(propertyName);
  1037. if (property.custom) {
  1038. return buildMatchResult(null, new Error("Lexer matching doesn't applicable for custom properties"));
  1039. }
  1040. var propertySyntax = property.vendor
  1041. ? this.getProperty(property.name) || this.getProperty(property.basename)
  1042. : this.getProperty(property.name);
  1043. if (!propertySyntax) {
  1044. return buildMatchResult(null, new SyntaxReferenceError("Unknown property", propertyName));
  1045. }
  1046. return matchSyntax(this, propertySyntax, value, true);
  1047. },
  1048. matchType: function (typeName, value) {
  1049. var typeSyntax = this.getType(typeName);
  1050. if (!typeSyntax) {
  1051. return buildMatchResult(null, new SyntaxReferenceError("Unknown type", typeName));
  1052. }
  1053. return matchSyntax(this, typeSyntax, value, false);
  1054. },
  1055. match: function (syntax, value) {
  1056. if (typeof syntax !== "string" && (!syntax || !syntax.type)) {
  1057. return buildMatchResult(null, new SyntaxReferenceError("Bad syntax"));
  1058. }
  1059. if (typeof syntax === "string" || !syntax.match) {
  1060. syntax = this.createDescriptor(syntax, "Type", "anonymous");
  1061. }
  1062. return matchSyntax(this, syntax, value, false);
  1063. },
  1064. findValueFragments: function (propertyName, value, type, name) {
  1065. return search.matchFragments(this, value, this.matchProperty(propertyName, value), type, name);
  1066. },
  1067. findDeclarationValueFragments: function (declaration, type, name) {
  1068. return search.matchFragments(this, declaration.value, this.matchDeclaration(declaration), type, name);
  1069. },
  1070. findAllFragments: function (ast, type, name) {
  1071. var result = [];
  1072. this.syntax.walk(ast, {
  1073. visit: "Declaration",
  1074. enter: function (declaration) {
  1075. result.push.apply(result, this.findDeclarationValueFragments(declaration, type, name));
  1076. }.bind(this)
  1077. });
  1078. return result;
  1079. },
  1080. getProperty: function (name) {
  1081. return this.properties.hasOwnProperty(name) ? this.properties[name] : null;
  1082. },
  1083. getType: function (name) {
  1084. return this.types.hasOwnProperty(name) ? this.types[name] : null;
  1085. },
  1086. validate: function () {
  1087. function validate(syntax, name, broken, descriptor) {
  1088. if (broken.hasOwnProperty(name)) {
  1089. return broken[name];
  1090. }
  1091. broken[name] = false;
  1092. if (descriptor.syntax !== null) {
  1093. walk(descriptor.syntax, function (node) {
  1094. if (node.type !== "Type" && node.type !== "Property") {
  1095. return;
  1096. }
  1097. var map = node.type === "Type" ? syntax.types : syntax.properties;
  1098. var brokenMap = node.type === "Type" ? brokenTypes : brokenProperties;
  1099. if (!map.hasOwnProperty(node.name) || validate(syntax, node.name, brokenMap, map[node.name])) {
  1100. broken[name] = true;
  1101. }
  1102. }, this);
  1103. }
  1104. }
  1105. var brokenTypes = {};
  1106. var brokenProperties = {};
  1107. for (var key in this.types) {
  1108. validate(this, key, brokenTypes, this.types[key]);
  1109. }
  1110. for (var key in this.properties) {
  1111. validate(this, key, brokenProperties, this.properties[key]);
  1112. }
  1113. brokenTypes = Object.keys(brokenTypes).filter(function (name) {
  1114. return brokenTypes[name];
  1115. });
  1116. brokenProperties = Object.keys(brokenProperties).filter(function (name) {
  1117. return brokenProperties[name];
  1118. });
  1119. if (brokenTypes.length || brokenProperties.length) {
  1120. return {
  1121. types: brokenTypes,
  1122. properties: brokenProperties
  1123. };
  1124. }
  1125. return null;
  1126. },
  1127. dump: function (syntaxAsAst) {
  1128. return {
  1129. generic: this.generic,
  1130. types: dumpMapSyntax(this.types, syntaxAsAst),
  1131. properties: dumpMapSyntax(this.properties, syntaxAsAst)
  1132. };
  1133. },
  1134. toString: function () {
  1135. return JSON.stringify(this.dump());
  1136. }
  1137. };
  1138. module.exports = Lexer;
  1139. }, { "../utils/names": 111, "./error": 12, "./generic": 15, "./grammar/generate": 17, "./grammar/parse": 19, "./grammar/walk": 21, "./match": 23, "./match-graph": 22, "./prepare-tokens": 24, "./search": 25, "./structure": 26, "./trace": 27 }], 12: [function (require, module, exports) {
  1140. var createCustomError = require("../utils/createCustomError");
  1141. var generateGrammar = require("./grammar/generate");
  1142. function fromMatchResult(matchResult) {
  1143. var tokens = matchResult.tokens;
  1144. var longestMatch = matchResult.longestMatch;
  1145. var node = longestMatch < tokens.length ? tokens[longestMatch].node : null;
  1146. var mismatchOffset = -1;
  1147. var entries = 0;
  1148. var css = "";
  1149. for (var i = 0; i < tokens.length; i++) {
  1150. if (i === longestMatch) {
  1151. mismatchOffset = css.length;
  1152. }
  1153. if (node !== null && tokens[i].node === node) {
  1154. if (i <= longestMatch) {
  1155. entries++;
  1156. } else {
  1157. entries = 0;
  1158. }
  1159. }
  1160. css += tokens[i].value;
  1161. }
  1162. return {
  1163. node: node,
  1164. css: css,
  1165. mismatchOffset: mismatchOffset === -1 ? css.length : mismatchOffset,
  1166. last: node === null || entries > 1
  1167. };
  1168. }
  1169. function getLocation(node, point) {
  1170. var loc = node && node.loc && node.loc[point];
  1171. if (loc) {
  1172. return {
  1173. offset: loc.offset,
  1174. line: loc.line,
  1175. column: loc.column
  1176. };
  1177. }
  1178. return null;
  1179. }
  1180. var SyntaxReferenceError = function (type, referenceName) {
  1181. var error = createCustomError(
  1182. "SyntaxReferenceError",
  1183. type + (referenceName ? " `" + referenceName + "`" : "")
  1184. );
  1185. error.reference = referenceName;
  1186. return error;
  1187. };
  1188. var MatchError = function (message, syntax, node, matchResult) {
  1189. var error = createCustomError("SyntaxMatchError", message);
  1190. var details = fromMatchResult(matchResult);
  1191. var mismatchOffset = details.mismatchOffset || 0;
  1192. var badNode = details.node || node;
  1193. var end = getLocation(badNode, "end");
  1194. var start = details.last ? end : getLocation(badNode, "start");
  1195. var css = details.css;
  1196. error.rawMessage = message;
  1197. error.syntax = syntax ? generateGrammar(syntax) : "<generic>";
  1198. error.css = css;
  1199. error.mismatchOffset = mismatchOffset;
  1200. error.loc = {
  1201. source: (badNode && badNode.loc && badNode.loc.source) || "<unknown>",
  1202. start: start,
  1203. end: end
  1204. };
  1205. error.line = start ? start.line : undefined;
  1206. error.column = start ? start.column : undefined;
  1207. error.offset = start ? start.offset : undefined;
  1208. error.message = message + "\n" +
  1209. " syntax: " + error.syntax + "\n" +
  1210. " value: " + (error.css || "<empty string>") + "\n" +
  1211. " --------" + new Array(error.mismatchOffset + 1).join("-") + "^";
  1212. return error;
  1213. };
  1214. module.exports = {
  1215. SyntaxReferenceError: SyntaxReferenceError,
  1216. MatchError: MatchError
  1217. };
  1218. }, { "../utils/createCustomError": 110, "./grammar/generate": 17 }], 13: [function (require, module, exports) {
  1219. var isDigit = require("../tokenizer").isDigit;
  1220. var cmpChar = require("../tokenizer").cmpChar;
  1221. var TYPE = require("../tokenizer").TYPE;
  1222. var DELIM = TYPE.Delim;
  1223. var WHITESPACE = TYPE.WhiteSpace;
  1224. var COMMENT = TYPE.Comment;
  1225. var IDENT = TYPE.Ident;
  1226. var NUMBER = TYPE.Number;
  1227. var DIMENSION = TYPE.Dimension;
  1228. var PLUSSIGN = 0x002B; // U+002B PLUS SIGN (+)
  1229. var HYPHENMINUS = 0x002D; // U+002D HYPHEN-MINUS (-)
  1230. var N = 0x006E; // U+006E LATIN SMALL LETTER N (n)
  1231. var DISALLOW_SIGN = true;
  1232. var ALLOW_SIGN = false;
  1233. function isDelim(token, code) {
  1234. return token !== null && token.type === DELIM && token.value.charCodeAt(0) === code;
  1235. }
  1236. function skipSC(token, offset, getNextToken) {
  1237. while (token !== null && (token.type === WHITESPACE || token.type === COMMENT)) {
  1238. token = getNextToken(++offset);
  1239. }
  1240. return offset;
  1241. }
  1242. function checkInteger(token, valueOffset, disallowSign, offset) {
  1243. if (!token) {
  1244. return 0;
  1245. }
  1246. var code = token.value.charCodeAt(valueOffset);
  1247. if (code === PLUSSIGN || code === HYPHENMINUS) {
  1248. if (disallowSign) {
  1249. return 0;
  1250. }
  1251. valueOffset++;
  1252. }
  1253. for (; valueOffset < token.value.length; valueOffset++) {
  1254. if (!isDigit(token.value.charCodeAt(valueOffset))) {
  1255. return 0;
  1256. }
  1257. }
  1258. return offset + 1;
  1259. }
  1260. function consumeB(token, offset_, getNextToken) {
  1261. var sign = false;
  1262. var offset = skipSC(token, offset_, getNextToken);
  1263. token = getNextToken(offset);
  1264. if (token === null) {
  1265. return offset_;
  1266. }
  1267. if (token.type !== NUMBER) {
  1268. if (isDelim(token, PLUSSIGN) || isDelim(token, HYPHENMINUS)) {
  1269. sign = true;
  1270. offset = skipSC(getNextToken(++offset), offset, getNextToken);
  1271. token = getNextToken(offset);
  1272. if (token === null && token.type !== NUMBER) {
  1273. return 0;
  1274. }
  1275. } else {
  1276. return offset_;
  1277. }
  1278. }
  1279. if (!sign) {
  1280. var code = token.value.charCodeAt(0);
  1281. if (code !== PLUSSIGN && code !== HYPHENMINUS) {
  1282. return 0;
  1283. }
  1284. }
  1285. return checkInteger(token, sign ? 0 : 1, sign, offset);
  1286. }
  1287. module.exports = function anPlusB(token, getNextToken) {
  1288. var offset = 0;
  1289. if (!token) {
  1290. return 0;
  1291. }
  1292. if (token.type === NUMBER) {
  1293. return checkInteger(token, 0, ALLOW_SIGN, offset); // b
  1294. }
  1295. else if (token.type === IDENT && token.value.charCodeAt(0) === HYPHENMINUS) {
  1296. if (!cmpChar(token.value, 1, N)) {
  1297. return 0;
  1298. }
  1299. switch (token.value.length) {
  1300. case 2:
  1301. return consumeB(getNextToken(++offset), offset, getNextToken);
  1302. case 3:
  1303. if (token.value.charCodeAt(2) !== HYPHENMINUS) {
  1304. return 0;
  1305. }
  1306. offset = skipSC(getNextToken(++offset), offset, getNextToken);
  1307. token = getNextToken(offset);
  1308. return checkInteger(token, 0, DISALLOW_SIGN, offset);
  1309. default:
  1310. if (token.value.charCodeAt(2) !== HYPHENMINUS) {
  1311. return 0;
  1312. }
  1313. return checkInteger(token, 3, DISALLOW_SIGN, offset);
  1314. }
  1315. }
  1316. else if (token.type === IDENT || (isDelim(token, PLUSSIGN) && getNextToken(offset + 1).type === IDENT)) {
  1317. if (token.type !== IDENT) {
  1318. token = getNextToken(++offset);
  1319. }
  1320. if (token === null || !cmpChar(token.value, 0, N)) {
  1321. return 0;
  1322. }
  1323. switch (token.value.length) {
  1324. case 1:
  1325. return consumeB(getNextToken(++offset), offset, getNextToken);
  1326. case 2:
  1327. if (token.value.charCodeAt(1) !== HYPHENMINUS) {
  1328. return 0;
  1329. }
  1330. offset = skipSC(getNextToken(++offset), offset, getNextToken);
  1331. token = getNextToken(offset);
  1332. return checkInteger(token, 0, DISALLOW_SIGN, offset);
  1333. default:
  1334. if (token.value.charCodeAt(1) !== HYPHENMINUS) {
  1335. return 0;
  1336. }
  1337. return checkInteger(token, 2, DISALLOW_SIGN, offset);
  1338. }
  1339. }
  1340. else if (token.type === DIMENSION) {
  1341. var code = token.value.charCodeAt(0);
  1342. var sign = code === PLUSSIGN || code === HYPHENMINUS ? 1 : 0;
  1343. for (var i = sign; i < token.value.length; i++) {
  1344. if (!isDigit(token.value.charCodeAt(i))) {
  1345. break;
  1346. }
  1347. }
  1348. if (i === sign) {
  1349. return 0;
  1350. }
  1351. if (!cmpChar(token.value, i, N)) {
  1352. return 0;
  1353. }
  1354. if (i + 1 === token.value.length) {
  1355. return consumeB(getNextToken(++offset), offset, getNextToken);
  1356. } else {
  1357. if (token.value.charCodeAt(i + 1) !== HYPHENMINUS) {
  1358. return 0;
  1359. }
  1360. if (i + 2 === token.value.length) {
  1361. offset = skipSC(getNextToken(++offset), offset, getNextToken);
  1362. token = getNextToken(offset);
  1363. return checkInteger(token, 0, DISALLOW_SIGN, offset);
  1364. }
  1365. else {
  1366. return checkInteger(token, i + 2, DISALLOW_SIGN, offset);
  1367. }
  1368. }
  1369. }
  1370. return 0;
  1371. };
  1372. }, { "../tokenizer": 107 }], 14: [function (require, module, exports) {
  1373. var isHexDigit = require("../tokenizer").isHexDigit;
  1374. var cmpChar = require("../tokenizer").cmpChar;
  1375. var TYPE = require("../tokenizer").TYPE;
  1376. var IDENT = TYPE.Ident;
  1377. var DELIM = TYPE.Delim;
  1378. var NUMBER = TYPE.Number;
  1379. var DIMENSION = TYPE.Dimension;
  1380. var PLUSSIGN = 0x002B; // U+002B PLUS SIGN (+)
  1381. var HYPHENMINUS = 0x002D; // U+002D HYPHEN-MINUS (-)
  1382. var QUESTIONMARK = 0x003F; // U+003F QUESTION MARK (?)
  1383. var U = 0x0075; // U+0075 LATIN SMALL LETTER U (u)
  1384. function isDelim(token, code) {
  1385. return token !== null && token.type === DELIM && token.value.charCodeAt(0) === code;
  1386. }
  1387. function startsWith(token, code) {
  1388. return token.value.charCodeAt(0) === code;
  1389. }
  1390. function hexSequence(token, offset, allowDash) {
  1391. for (var pos = offset, hexlen = 0; pos < token.value.length; pos++) {
  1392. var code = token.value.charCodeAt(pos);
  1393. if (code === HYPHENMINUS && allowDash && hexlen !== 0) {
  1394. if (hexSequence(token, offset + hexlen + 1, false) > 0) {
  1395. return 6; // dissallow following question marks
  1396. }
  1397. return 0; // dash at the ending of a hex sequence is not allowed
  1398. }
  1399. if (!isHexDigit(code)) {
  1400. return 0; // not a hex digit
  1401. }
  1402. if (++hexlen > 6) {
  1403. return 0; // too many hex digits
  1404. }
  1405. }
  1406. return hexlen;
  1407. }
  1408. function withQuestionMarkSequence(consumed, length, getNextToken) {
  1409. if (!consumed) {
  1410. return 0; // nothing consumed
  1411. }
  1412. while (isDelim(getNextToken(length), QUESTIONMARK)) {
  1413. if (++consumed > 6) {
  1414. return 0; // too many question marks
  1415. }
  1416. length++;
  1417. }
  1418. return length;
  1419. }
  1420. module.exports = function urange(token, getNextToken) {
  1421. var length = 0;
  1422. if (token === null || token.type !== IDENT || !cmpChar(token.value, 0, U)) {
  1423. return 0;
  1424. }
  1425. token = getNextToken(++length);
  1426. if (token === null) {
  1427. return 0;
  1428. }
  1429. if (isDelim(token, PLUSSIGN)) {
  1430. token = getNextToken(++length);
  1431. if (token === null) {
  1432. return 0;
  1433. }
  1434. if (token.type === IDENT) {
  1435. return withQuestionMarkSequence(hexSequence(token, 0, true), ++length, getNextToken);
  1436. }
  1437. if (isDelim(token, QUESTIONMARK)) {
  1438. return withQuestionMarkSequence(1, ++length, getNextToken);
  1439. }
  1440. return 0;
  1441. }
  1442. if (token.type === NUMBER) {
  1443. if (!startsWith(token, PLUSSIGN)) {
  1444. return 0;
  1445. }
  1446. var consumedHexLength = hexSequence(token, 1, true);
  1447. if (consumedHexLength === 0) {
  1448. return 0;
  1449. }
  1450. token = getNextToken(++length);
  1451. if (token === null) {
  1452. return length;
  1453. }
  1454. if (token.type === DIMENSION || token.type === NUMBER) {
  1455. if (!startsWith(token, HYPHENMINUS) || !hexSequence(token, 1, false)) {
  1456. return 0;
  1457. }
  1458. return length + 1;
  1459. }
  1460. return withQuestionMarkSequence(consumedHexLength, length, getNextToken);
  1461. }
  1462. if (token.type === DIMENSION) {
  1463. if (!startsWith(token, PLUSSIGN)) {
  1464. return 0;
  1465. }
  1466. return withQuestionMarkSequence(hexSequence(token, 1, true), ++length, getNextToken);
  1467. }
  1468. return 0;
  1469. };
  1470. }, { "../tokenizer": 107 }], 15: [function (require, module, exports) {
  1471. var tokenizer = require("../tokenizer");
  1472. var isIdentifierStart = tokenizer.isIdentifierStart;
  1473. var isHexDigit = tokenizer.isHexDigit;
  1474. var isDigit = tokenizer.isDigit;
  1475. var cmpStr = tokenizer.cmpStr;
  1476. var consumeNumber = tokenizer.consumeNumber;
  1477. var TYPE = tokenizer.TYPE;
  1478. var anPlusB = require("./generic-an-plus-b");
  1479. var urange = require("./generic-urange");
  1480. var cssWideKeywords = ["unset", "initial", "inherit"];
  1481. var calcFunctionNames = ["calc(", "-moz-calc(", "-webkit-calc("];
  1482. var LENGTH = {
  1483. "px": true,
  1484. "mm": true,
  1485. "cm": true,
  1486. "in": true,
  1487. "pt": true,
  1488. "pc": true,
  1489. "q": true,
  1490. "em": true,
  1491. "ex": true,
  1492. "ch": true,
  1493. "rem": true,
  1494. "vh": true,
  1495. "vw": true,
  1496. "vmin": true,
  1497. "vmax": true,
  1498. "vm": true
  1499. };
  1500. var ANGLE = {
  1501. "deg": true,
  1502. "grad": true,
  1503. "rad": true,
  1504. "turn": true
  1505. };
  1506. var TIME = {
  1507. "s": true,
  1508. "ms": true
  1509. };
  1510. var FREQUENCY = {
  1511. "hz": true,
  1512. "khz": true
  1513. };
  1514. var RESOLUTION = {
  1515. "dpi": true,
  1516. "dpcm": true,
  1517. "dppx": true,
  1518. "x": true // https://github.com/w3c/csswg-drafts/issues/461
  1519. };
  1520. var FLEX = {
  1521. "fr": true
  1522. };
  1523. var DECIBEL = {
  1524. "db": true
  1525. };
  1526. var SEMITONES = {
  1527. "st": true
  1528. };
  1529. function charCode(str, index) {
  1530. return index < str.length ? str.charCodeAt(index) : 0;
  1531. }
  1532. function eqStr(actual, expected) {
  1533. return cmpStr(actual, 0, actual.length, expected);
  1534. }
  1535. function eqStrAny(actual, expected) {
  1536. for (var i = 0; i < expected.length; i++) {
  1537. if (eqStr(actual, expected[i])) {
  1538. return true;
  1539. }
  1540. }
  1541. return false;
  1542. }
  1543. function isPostfixIeHack(str, offset) {
  1544. if (offset !== str.length - 2) {
  1545. return false;
  1546. }
  1547. return (
  1548. str.charCodeAt(offset) === 0x005C && // U+005C REVERSE SOLIDUS (\)
  1549. isDigit(str.charCodeAt(offset + 1))
  1550. );
  1551. }
  1552. function outOfRange(opts, value, numEnd) {
  1553. if (opts && opts.type === "Range") {
  1554. var num = Number(
  1555. numEnd !== undefined && numEnd !== value.length
  1556. ? value.substr(0, numEnd)
  1557. : value
  1558. );
  1559. if (isNaN(num)) {
  1560. return true;
  1561. }
  1562. if (opts.min !== null && num < opts.min) {
  1563. return true;
  1564. }
  1565. if (opts.max !== null && num > opts.max) {
  1566. return true;
  1567. }
  1568. }
  1569. return false;
  1570. }
  1571. function consumeFunction(token, getNextToken) {
  1572. var startIdx = token.index;
  1573. var length = 0;
  1574. do {
  1575. length++;
  1576. if (token.balance <= startIdx) {
  1577. break;
  1578. }
  1579. } while (token = getNextToken(length));
  1580. return length;
  1581. }
  1582. function calc(next) {
  1583. return function (token, getNextToken, opts) {
  1584. if (token === null) {
  1585. return 0;
  1586. }
  1587. if (token.type === TYPE.Function && eqStrAny(token.value, calcFunctionNames)) {
  1588. return consumeFunction(token, getNextToken);
  1589. }
  1590. return next(token, getNextToken, opts);
  1591. };
  1592. }
  1593. function tokenType(expectedTokenType) {
  1594. return function (token) {
  1595. if (token === null || token.type !== expectedTokenType) {
  1596. return 0;
  1597. }
  1598. return 1;
  1599. };
  1600. }
  1601. function func(name) {
  1602. name = name + "(";
  1603. return function (token, getNextToken) {
  1604. if (token !== null && eqStr(token.value, name)) {
  1605. return consumeFunction(token, getNextToken);
  1606. }
  1607. return 0;
  1608. };
  1609. }
  1610. function customIdent(token) {
  1611. if (token === null || token.type !== TYPE.Ident) {
  1612. return 0;
  1613. }
  1614. var name = token.value.toLowerCase();
  1615. if (eqStrAny(name, cssWideKeywords)) {
  1616. return 0;
  1617. }
  1618. if (eqStr(name, "default")) {
  1619. return 0;
  1620. }
  1621. return 1;
  1622. }
  1623. function customPropertyName(token) {
  1624. if (token === null || token.type !== TYPE.Ident) {
  1625. return 0;
  1626. }
  1627. if (charCode(token.value, 0) !== 0x002D || charCode(token.value, 1) !== 0x002D) {
  1628. return 0;
  1629. }
  1630. return 1;
  1631. }
  1632. function hexColor(token) {
  1633. if (token === null || token.type !== TYPE.Hash) {
  1634. return 0;
  1635. }
  1636. var length = token.value.length;
  1637. if (length !== 4 && length !== 5 && length !== 7 && length !== 9) {
  1638. return 0;
  1639. }
  1640. for (var i = 1; i < length; i++) {
  1641. if (!isHexDigit(token.value.charCodeAt(i))) {
  1642. return 0;
  1643. }
  1644. }
  1645. return 1;
  1646. }
  1647. function idSelector(token) {
  1648. if (token === null || token.type !== TYPE.Hash) {
  1649. return 0;
  1650. }
  1651. if (!isIdentifierStart(charCode(token.value, 1), charCode(token.value, 2), charCode(token.value, 3))) {
  1652. return 0;
  1653. }
  1654. return 1;
  1655. }
  1656. function declarationValue(token, getNextToken) {
  1657. if (!token) {
  1658. return 0;
  1659. }
  1660. var length = 0;
  1661. var level = 0;
  1662. var startIdx = token.index;
  1663. scan:
  1664. do {
  1665. switch (token.type) {
  1666. case TYPE.BadString:
  1667. case TYPE.BadUrl:
  1668. break scan;
  1669. case TYPE.RightCurlyBracket:
  1670. case TYPE.RightParenthesis:
  1671. case TYPE.RightSquareBracket:
  1672. if (token.balance > token.index || token.balance < startIdx) {
  1673. break scan;
  1674. }
  1675. level--;
  1676. break;
  1677. case TYPE.Semicolon:
  1678. if (level === 0) {
  1679. break scan;
  1680. }
  1681. break;
  1682. case TYPE.Delim:
  1683. if (token.value === "!" && level === 0) {
  1684. break scan;
  1685. }
  1686. break;
  1687. case TYPE.Function:
  1688. case TYPE.LeftParenthesis:
  1689. case TYPE.LeftSquareBracket:
  1690. case TYPE.LeftCurlyBracket:
  1691. level++;
  1692. break;
  1693. }
  1694. length++;
  1695. if (token.balance <= startIdx) {
  1696. break;
  1697. }
  1698. } while (token = getNextToken(length));
  1699. return length;
  1700. }
  1701. function anyValue(token, getNextToken) {
  1702. if (!token) {
  1703. return 0;
  1704. }
  1705. var startIdx = token.index;
  1706. var length = 0;
  1707. scan:
  1708. do {
  1709. switch (token.type) {
  1710. case TYPE.BadString:
  1711. case TYPE.BadUrl:
  1712. break scan;
  1713. case TYPE.RightCurlyBracket:
  1714. case TYPE.RightParenthesis:
  1715. case TYPE.RightSquareBracket:
  1716. if (token.balance > token.index || token.balance < startIdx) {
  1717. break scan;
  1718. }
  1719. break;
  1720. }
  1721. length++;
  1722. if (token.balance <= startIdx) {
  1723. break;
  1724. }
  1725. } while (token = getNextToken(length));
  1726. return length;
  1727. }
  1728. function dimension(type) {
  1729. return function (token, getNextToken, opts) {
  1730. if (token === null || token.type !== TYPE.Dimension) {
  1731. return 0;
  1732. }
  1733. var numberEnd = consumeNumber(token.value, 0);
  1734. if (type !== null) {
  1735. var reverseSolidusOffset = token.value.indexOf("\\", numberEnd);
  1736. var unit = reverseSolidusOffset === -1 || !isPostfixIeHack(token.value, reverseSolidusOffset)
  1737. ? token.value.substr(numberEnd)
  1738. : token.value.substring(numberEnd, reverseSolidusOffset);
  1739. if (type.hasOwnProperty(unit.toLowerCase()) === false) {
  1740. return 0;
  1741. }
  1742. }
  1743. if (outOfRange(opts, token.value, numberEnd)) {
  1744. return 0;
  1745. }
  1746. return 1;
  1747. };
  1748. }
  1749. function percentage(token, getNextToken, opts) {
  1750. if (token === null || token.type !== TYPE.Percentage) {
  1751. return 0;
  1752. }
  1753. if (outOfRange(opts, token.value, token.value.length - 1)) {
  1754. return 0;
  1755. }
  1756. return 1;
  1757. }
  1758. function zero(next) {
  1759. if (typeof next !== "function") {
  1760. next = function () {
  1761. return 0;
  1762. };
  1763. }
  1764. return function (token, getNextToken, opts) {
  1765. if (token !== null && token.type === TYPE.Number) {
  1766. if (Number(token.value) === 0) {
  1767. return 1;
  1768. }
  1769. }
  1770. return next(token, getNextToken, opts);
  1771. };
  1772. }
  1773. function number(token, getNextToken, opts) {
  1774. if (token === null) {
  1775. return 0;
  1776. }
  1777. var numberEnd = consumeNumber(token.value, 0);
  1778. var isNumber = numberEnd === token.value.length;
  1779. if (!isNumber && !isPostfixIeHack(token.value, numberEnd)) {
  1780. return 0;
  1781. }
  1782. if (outOfRange(opts, token.value, numberEnd)) {
  1783. return 0;
  1784. }
  1785. return 1;
  1786. }
  1787. function integer(token, getNextToken, opts) {
  1788. if (token === null || token.type !== TYPE.Number) {
  1789. return 0;
  1790. }
  1791. var i = token.value.charCodeAt(0) === 0x002B || // U+002B PLUS SIGN (+)
  1792. token.value.charCodeAt(0) === 0x002D ? 1 : 0; // U+002D HYPHEN-MINUS (-)
  1793. for (; i < token.value.length; i++) {
  1794. if (!isDigit(token.value.charCodeAt(i))) {
  1795. return 0;
  1796. }
  1797. }
  1798. if (outOfRange(opts, token.value, i)) {
  1799. return 0;
  1800. }
  1801. return 1;
  1802. }
  1803. module.exports = {
  1804. "ident-token": tokenType(TYPE.Ident),
  1805. "function-token": tokenType(TYPE.Function),
  1806. "at-keyword-token": tokenType(TYPE.AtKeyword),
  1807. "hash-token": tokenType(TYPE.Hash),
  1808. "string-token": tokenType(TYPE.String),
  1809. "bad-string-token": tokenType(TYPE.BadString),
  1810. "url-token": tokenType(TYPE.Url),
  1811. "bad-url-token": tokenType(TYPE.BadUrl),
  1812. "delim-token": tokenType(TYPE.Delim),
  1813. "number-token": tokenType(TYPE.Number),
  1814. "percentage-token": tokenType(TYPE.Percentage),
  1815. "dimension-token": tokenType(TYPE.Dimension),
  1816. "whitespace-token": tokenType(TYPE.WhiteSpace),
  1817. "CDO-token": tokenType(TYPE.CDO),
  1818. "CDC-token": tokenType(TYPE.CDC),
  1819. "colon-token": tokenType(TYPE.Colon),
  1820. "semicolon-token": tokenType(TYPE.Semicolon),
  1821. "comma-token": tokenType(TYPE.Comma),
  1822. "[-token": tokenType(TYPE.LeftSquareBracket),
  1823. "]-token": tokenType(TYPE.RightSquareBracket),
  1824. "(-token": tokenType(TYPE.LeftParenthesis),
  1825. ")-token": tokenType(TYPE.RightParenthesis),
  1826. "{-token": tokenType(TYPE.LeftCurlyBracket),
  1827. "}-token": tokenType(TYPE.RightCurlyBracket),
  1828. "string": tokenType(TYPE.String),
  1829. "ident": tokenType(TYPE.Ident),
  1830. "custom-ident": customIdent,
  1831. "custom-property-name": customPropertyName,
  1832. "hex-color": hexColor,
  1833. "id-selector": idSelector, // element( <id-selector> )
  1834. "an-plus-b": anPlusB,
  1835. "urange": urange,
  1836. "declaration-value": declarationValue,
  1837. "any-value": anyValue,
  1838. "dimension": calc(dimension(null)),
  1839. "angle": calc(dimension(ANGLE)),
  1840. "decibel": calc(dimension(DECIBEL)),
  1841. "frequency": calc(dimension(FREQUENCY)),
  1842. "flex": calc(dimension(FLEX)),
  1843. "length": calc(zero(dimension(LENGTH))),
  1844. "resolution": calc(dimension(RESOLUTION)),
  1845. "semitones": calc(dimension(SEMITONES)),
  1846. "time": calc(dimension(TIME)),
  1847. "percentage": calc(percentage),
  1848. "zero": zero(),
  1849. "number": calc(number),
  1850. "integer": calc(integer),
  1851. "-ms-legacy-expression": func("expression")
  1852. };
  1853. }, { "../tokenizer": 107, "./generic-an-plus-b": 13, "./generic-urange": 14 }], 16: [function (require, module, exports) {
  1854. var createCustomError = require("../../utils/createCustomError");
  1855. var SyntaxParseError = function (message, input, offset) {
  1856. var error = createCustomError("SyntaxParseError", message);
  1857. error.input = input;
  1858. error.offset = offset;
  1859. error.rawMessage = message;
  1860. error.message = error.rawMessage + "\n" +
  1861. " " + error.input + "\n" +
  1862. "--" + new Array((error.offset || error.input.length) + 1).join("-") + "^";
  1863. return error;
  1864. };
  1865. module.exports = {
  1866. SyntaxParseError: SyntaxParseError
  1867. };
  1868. }, { "../../utils/createCustomError": 110 }], 17: [function (require, module, exports) {
  1869. function noop(value) {
  1870. return value;
  1871. }
  1872. function generateMultiplier(multiplier) {
  1873. if (multiplier.min === 0 && multiplier.max === 0) {
  1874. return "*";
  1875. }
  1876. if (multiplier.min === 0 && multiplier.max === 1) {
  1877. return "?";
  1878. }
  1879. if (multiplier.min === 1 && multiplier.max === 0) {
  1880. return multiplier.comma ? "#" : "+";
  1881. }
  1882. if (multiplier.min === 1 && multiplier.max === 1) {
  1883. return "";
  1884. }
  1885. return (
  1886. (multiplier.comma ? "#" : "") +
  1887. (multiplier.min === multiplier.max
  1888. ? "{" + multiplier.min + "}"
  1889. : "{" + multiplier.min + "," + (multiplier.max !== 0 ? multiplier.max : "") + "}"
  1890. )
  1891. );
  1892. }
  1893. function generateTypeOpts(node) {
  1894. switch (node.type) {
  1895. case "Range":
  1896. return (
  1897. " [" +
  1898. (node.min === null ? "-∞" : node.min) +
  1899. "," +
  1900. (node.max === null ? "∞" : node.max) +
  1901. "]"
  1902. );
  1903. default:
  1904. throw new Error("Unknown node type `" + node.type + "`");
  1905. }
  1906. }
  1907. function generateSequence(node, forceBraces, decorate) {
  1908. var result = node.terms.map(function (term) {
  1909. return generate(term, forceBraces, decorate);
  1910. }).join(node.combinator === " " ? " " : " " + node.combinator + " ");
  1911. if (node.explicit || forceBraces) {
  1912. result = (result[0] !== "," ? "[ " : "[") + result + " ]";
  1913. }
  1914. return result;
  1915. }
  1916. function generate(node, forceBraces, decorate) {
  1917. var result;
  1918. switch (node.type) {
  1919. case "Group":
  1920. result =
  1921. generateSequence(node, forceBraces, decorate) +
  1922. (node.disallowEmpty ? "!" : "");
  1923. break;
  1924. case "Multiplier":
  1925. return (
  1926. generate(node.term, forceBraces, decorate) +
  1927. decorate(generateMultiplier(node), node)
  1928. );
  1929. case "Type":
  1930. result = "<" + node.name + (node.opts ? decorate(generateTypeOpts(node.opts), node.opts) : "") + ">";
  1931. break;
  1932. case "Property":
  1933. result = "<'" + node.name + "'>";
  1934. break;
  1935. case "Keyword":
  1936. result = node.name;
  1937. break;
  1938. case "AtKeyword":
  1939. result = "@" + node.name;
  1940. break;
  1941. case "Function":
  1942. result = node.name + "(";
  1943. break;
  1944. case "String":
  1945. case "Token":
  1946. result = node.value;
  1947. break;
  1948. case "Comma":
  1949. result = ",";
  1950. break;
  1951. default:
  1952. throw new Error("Unknown node type `" + node.type + "`");
  1953. }
  1954. return decorate(result, node);
  1955. }
  1956. module.exports = function (node, options) {
  1957. var decorate = noop;
  1958. var forceBraces = false;
  1959. if (typeof options === "function") {
  1960. decorate = options;
  1961. } else if (options) {
  1962. forceBraces = Boolean(options.forceBraces);
  1963. if (typeof options.decorate === "function") {
  1964. decorate = options.decorate;
  1965. }
  1966. }
  1967. return generate(node, forceBraces, decorate);
  1968. };
  1969. }, {}], 18: [function (require, module, exports) {
  1970. module.exports = {
  1971. SyntaxParseError: require("./error").SyntaxParseError,
  1972. parse: require("./parse"),
  1973. generate: require("./generate"),
  1974. walk: require("./walk")
  1975. };
  1976. }, { "./error": 16, "./generate": 17, "./parse": 19, "./walk": 21 }], 19: [function (require, module, exports) {
  1977. var Tokenizer = require("./tokenizer");
  1978. var TAB = 9;
  1979. var N = 10;
  1980. var F = 12;
  1981. var R = 13;
  1982. var SPACE = 32;
  1983. var EXCLAMATIONMARK = 33; // !
  1984. var NUMBERSIGN = 35; // #
  1985. var AMPERSAND = 38; // &
  1986. var APOSTROPHE = 39; // '
  1987. var LEFTPARENTHESIS = 40; // (
  1988. var RIGHTPARENTHESIS = 41; // )
  1989. var ASTERISK = 42; // *
  1990. var PLUSSIGN = 43; // +
  1991. var COMMA = 44; // ,
  1992. var HYPERMINUS = 45; // -
  1993. var LESSTHANSIGN = 60; // <
  1994. var GREATERTHANSIGN = 62; // >
  1995. var QUESTIONMARK = 63; // ?
  1996. var COMMERCIALAT = 64; // @
  1997. var LEFTSQUAREBRACKET = 91; // [
  1998. var RIGHTSQUAREBRACKET = 93; // ]
  1999. var LEFTCURLYBRACKET = 123; // {
  2000. var VERTICALLINE = 124; // |
  2001. var RIGHTCURLYBRACKET = 125; // }
  2002. var INFINITY = 8734; // ∞
  2003. var NAME_CHAR = createCharMap(function (ch) {
  2004. return /[a-zA-Z0-9-]/.test(ch);
  2005. });
  2006. var COMBINATOR_PRECEDENCE = {
  2007. " ": 1,
  2008. "&&": 2,
  2009. "||": 3,
  2010. "|": 4
  2011. };
  2012. function createCharMap(fn) {
  2013. var array = typeof Uint32Array === "function" ? new Uint32Array(128) : new Array(128);
  2014. for (var i = 0; i < 128; i++) {
  2015. array[i] = fn(String.fromCharCode(i)) ? 1 : 0;
  2016. }
  2017. return array;
  2018. }
  2019. function scanSpaces(tokenizer) {
  2020. return tokenizer.substringToPos(
  2021. tokenizer.findWsEnd(tokenizer.pos)
  2022. );
  2023. }
  2024. function scanWord(tokenizer) {
  2025. var end = tokenizer.pos;
  2026. for (; end < tokenizer.str.length; end++) {
  2027. var code = tokenizer.str.charCodeAt(end);
  2028. if (code >= 128 || NAME_CHAR[code] === 0) {
  2029. break;
  2030. }
  2031. }
  2032. if (tokenizer.pos === end) {
  2033. tokenizer.error("Expect a keyword");
  2034. }
  2035. return tokenizer.substringToPos(end);
  2036. }
  2037. function scanNumber(tokenizer) {
  2038. var end = tokenizer.pos;
  2039. for (; end < tokenizer.str.length; end++) {
  2040. var code = tokenizer.str.charCodeAt(end);
  2041. if (code < 48 || code > 57) {
  2042. break;
  2043. }
  2044. }
  2045. if (tokenizer.pos === end) {
  2046. tokenizer.error("Expect a number");
  2047. }
  2048. return tokenizer.substringToPos(end);
  2049. }
  2050. function scanString(tokenizer) {
  2051. var end = tokenizer.str.indexOf("'", tokenizer.pos + 1);
  2052. if (end === -1) {
  2053. tokenizer.pos = tokenizer.str.length;
  2054. tokenizer.error("Expect an apostrophe");
  2055. }
  2056. return tokenizer.substringToPos(end + 1);
  2057. }
  2058. function readMultiplierRange(tokenizer) {
  2059. var min = null;
  2060. var max = null;
  2061. tokenizer.eat(LEFTCURLYBRACKET);
  2062. min = scanNumber(tokenizer);
  2063. if (tokenizer.charCode() === COMMA) {
  2064. tokenizer.pos++;
  2065. if (tokenizer.charCode() !== RIGHTCURLYBRACKET) {
  2066. max = scanNumber(tokenizer);
  2067. }
  2068. } else {
  2069. max = min;
  2070. }
  2071. tokenizer.eat(RIGHTCURLYBRACKET);
  2072. return {
  2073. min: Number(min),
  2074. max: max ? Number(max) : 0
  2075. };
  2076. }
  2077. function readMultiplier(tokenizer) {
  2078. var range = null;
  2079. var comma = false;
  2080. switch (tokenizer.charCode()) {
  2081. case ASTERISK:
  2082. tokenizer.pos++;
  2083. range = {
  2084. min: 0,
  2085. max: 0
  2086. };
  2087. break;
  2088. case PLUSSIGN:
  2089. tokenizer.pos++;
  2090. range = {
  2091. min: 1,
  2092. max: 0
  2093. };
  2094. break;
  2095. case QUESTIONMARK:
  2096. tokenizer.pos++;
  2097. range = {
  2098. min: 0,
  2099. max: 1
  2100. };
  2101. break;
  2102. case NUMBERSIGN:
  2103. tokenizer.pos++;
  2104. comma = true;
  2105. if (tokenizer.charCode() === LEFTCURLYBRACKET) {
  2106. range = readMultiplierRange(tokenizer);
  2107. } else {
  2108. range = {
  2109. min: 1,
  2110. max: 0
  2111. };
  2112. }
  2113. break;
  2114. case LEFTCURLYBRACKET:
  2115. range = readMultiplierRange(tokenizer);
  2116. break;
  2117. default:
  2118. return null;
  2119. }
  2120. return {
  2121. type: "Multiplier",
  2122. comma: comma,
  2123. min: range.min,
  2124. max: range.max,
  2125. term: null
  2126. };
  2127. }
  2128. function maybeMultiplied(tokenizer, node) {
  2129. var multiplier = readMultiplier(tokenizer);
  2130. if (multiplier !== null) {
  2131. multiplier.term = node;
  2132. return multiplier;
  2133. }
  2134. return node;
  2135. }
  2136. function maybeToken(tokenizer) {
  2137. var ch = tokenizer.peek();
  2138. if (ch === "") {
  2139. return null;
  2140. }
  2141. return {
  2142. type: "Token",
  2143. value: ch
  2144. };
  2145. }
  2146. function readProperty(tokenizer) {
  2147. var name;
  2148. tokenizer.eat(LESSTHANSIGN);
  2149. tokenizer.eat(APOSTROPHE);
  2150. name = scanWord(tokenizer);
  2151. tokenizer.eat(APOSTROPHE);
  2152. tokenizer.eat(GREATERTHANSIGN);
  2153. return maybeMultiplied(tokenizer, {
  2154. type: "Property",
  2155. name: name
  2156. });
  2157. }
  2158. function readTypeRange(tokenizer) {
  2159. var min = null; // -Infinity
  2160. var max = null; // Infinity
  2161. var sign = 1;
  2162. tokenizer.eat(LEFTSQUAREBRACKET);
  2163. if (tokenizer.charCode() === HYPERMINUS) {
  2164. tokenizer.peek();
  2165. sign = -1;
  2166. }
  2167. if (sign == -1 && tokenizer.charCode() === INFINITY) {
  2168. tokenizer.peek();
  2169. } else {
  2170. min = sign * Number(scanNumber(tokenizer));
  2171. }
  2172. scanSpaces(tokenizer);
  2173. tokenizer.eat(COMMA);
  2174. scanSpaces(tokenizer);
  2175. if (tokenizer.charCode() === INFINITY) {
  2176. tokenizer.peek();
  2177. } else {
  2178. sign = 1;
  2179. if (tokenizer.charCode() === HYPERMINUS) {
  2180. tokenizer.peek();
  2181. sign = -1;
  2182. }
  2183. max = sign * Number(scanNumber(tokenizer));
  2184. }
  2185. tokenizer.eat(RIGHTSQUAREBRACKET);
  2186. if (min === null && max === null) {
  2187. return null;
  2188. }
  2189. return {
  2190. type: "Range",
  2191. min: min,
  2192. max: max
  2193. };
  2194. }
  2195. function readType(tokenizer) {
  2196. var name;
  2197. var opts = null;
  2198. tokenizer.eat(LESSTHANSIGN);
  2199. name = scanWord(tokenizer);
  2200. if (tokenizer.charCode() === LEFTPARENTHESIS &&
  2201. tokenizer.nextCharCode() === RIGHTPARENTHESIS) {
  2202. tokenizer.pos += 2;
  2203. name += "()";
  2204. }
  2205. if (tokenizer.charCodeAt(tokenizer.findWsEnd(tokenizer.pos)) === LEFTSQUAREBRACKET) {
  2206. scanSpaces(tokenizer);
  2207. opts = readTypeRange(tokenizer);
  2208. }
  2209. tokenizer.eat(GREATERTHANSIGN);
  2210. return maybeMultiplied(tokenizer, {
  2211. type: "Type",
  2212. name: name,
  2213. opts: opts
  2214. });
  2215. }
  2216. function readKeywordOrFunction(tokenizer) {
  2217. var name;
  2218. name = scanWord(tokenizer);
  2219. if (tokenizer.charCode() === LEFTPARENTHESIS) {
  2220. tokenizer.pos++;
  2221. return {
  2222. type: "Function",
  2223. name: name
  2224. };
  2225. }
  2226. return maybeMultiplied(tokenizer, {
  2227. type: "Keyword",
  2228. name: name
  2229. });
  2230. }
  2231. function regroupTerms(terms, combinators) {
  2232. function createGroup(terms, combinator) {
  2233. return {
  2234. type: "Group",
  2235. terms: terms,
  2236. combinator: combinator,
  2237. disallowEmpty: false,
  2238. explicit: false
  2239. };
  2240. }
  2241. combinators = Object.keys(combinators).sort(function (a, b) {
  2242. return COMBINATOR_PRECEDENCE[a] - COMBINATOR_PRECEDENCE[b];
  2243. });
  2244. while (combinators.length > 0) {
  2245. var combinator = combinators.shift();
  2246. for (var i = 0, subgroupStart = 0; i < terms.length; i++) {
  2247. var term = terms[i];
  2248. if (term.type === "Combinator") {
  2249. if (term.value === combinator) {
  2250. if (subgroupStart === -1) {
  2251. subgroupStart = i - 1;
  2252. }
  2253. terms.splice(i, 1);
  2254. i--;
  2255. } else {
  2256. if (subgroupStart !== -1 && i - subgroupStart > 1) {
  2257. terms.splice(
  2258. subgroupStart,
  2259. i - subgroupStart,
  2260. createGroup(terms.slice(subgroupStart, i), combinator)
  2261. );
  2262. i = subgroupStart + 1;
  2263. }
  2264. subgroupStart = -1;
  2265. }
  2266. }
  2267. }
  2268. if (subgroupStart !== -1 && combinators.length) {
  2269. terms.splice(
  2270. subgroupStart,
  2271. i - subgroupStart,
  2272. createGroup(terms.slice(subgroupStart, i), combinator)
  2273. );
  2274. }
  2275. }
  2276. return combinator;
  2277. }
  2278. function readImplicitGroup(tokenizer) {
  2279. var terms = [];
  2280. var combinators = {};
  2281. var token;
  2282. var prevToken = null;
  2283. var prevTokenPos = tokenizer.pos;
  2284. while (token = peek(tokenizer)) {
  2285. if (token.type !== "Spaces") {
  2286. if (token.type === "Combinator") {
  2287. if (prevToken === null || prevToken.type === "Combinator") {
  2288. tokenizer.pos = prevTokenPos;
  2289. tokenizer.error("Unexpected combinator");
  2290. }
  2291. combinators[token.value] = true;
  2292. } else if (prevToken !== null && prevToken.type !== "Combinator") {
  2293. combinators[" "] = true; // a b
  2294. terms.push({
  2295. type: "Combinator",
  2296. value: " "
  2297. });
  2298. }
  2299. terms.push(token);
  2300. prevToken = token;
  2301. prevTokenPos = tokenizer.pos;
  2302. }
  2303. }
  2304. if (prevToken !== null && prevToken.type === "Combinator") {
  2305. tokenizer.pos -= prevTokenPos;
  2306. tokenizer.error("Unexpected combinator");
  2307. }
  2308. return {
  2309. type: "Group",
  2310. terms: terms,
  2311. combinator: regroupTerms(terms, combinators) || " ",
  2312. disallowEmpty: false,
  2313. explicit: false
  2314. };
  2315. }
  2316. function readGroup(tokenizer) {
  2317. var result;
  2318. tokenizer.eat(LEFTSQUAREBRACKET);
  2319. result = readImplicitGroup(tokenizer);
  2320. tokenizer.eat(RIGHTSQUAREBRACKET);
  2321. result.explicit = true;
  2322. if (tokenizer.charCode() === EXCLAMATIONMARK) {
  2323. tokenizer.pos++;
  2324. result.disallowEmpty = true;
  2325. }
  2326. return result;
  2327. }
  2328. function peek(tokenizer) {
  2329. var code = tokenizer.charCode();
  2330. if (code < 128 && NAME_CHAR[code] === 1) {
  2331. return readKeywordOrFunction(tokenizer);
  2332. }
  2333. switch (code) {
  2334. case RIGHTSQUAREBRACKET:
  2335. break;
  2336. case LEFTSQUAREBRACKET:
  2337. return maybeMultiplied(tokenizer, readGroup(tokenizer));
  2338. case LESSTHANSIGN:
  2339. return tokenizer.nextCharCode() === APOSTROPHE
  2340. ? readProperty(tokenizer)
  2341. : readType(tokenizer);
  2342. case VERTICALLINE:
  2343. return {
  2344. type: "Combinator",
  2345. value: tokenizer.substringToPos(
  2346. tokenizer.nextCharCode() === VERTICALLINE
  2347. ? tokenizer.pos + 2
  2348. : tokenizer.pos + 1
  2349. )
  2350. };
  2351. case AMPERSAND:
  2352. tokenizer.pos++;
  2353. tokenizer.eat(AMPERSAND);
  2354. return {
  2355. type: "Combinator",
  2356. value: "&&"
  2357. };
  2358. case COMMA:
  2359. tokenizer.pos++;
  2360. return {
  2361. type: "Comma"
  2362. };
  2363. case APOSTROPHE:
  2364. return maybeMultiplied(tokenizer, {
  2365. type: "String",
  2366. value: scanString(tokenizer)
  2367. });
  2368. case SPACE:
  2369. case TAB:
  2370. case N:
  2371. case R:
  2372. case F:
  2373. return {
  2374. type: "Spaces",
  2375. value: scanSpaces(tokenizer)
  2376. };
  2377. case COMMERCIALAT:
  2378. code = tokenizer.nextCharCode();
  2379. if (code < 128 && NAME_CHAR[code] === 1) {
  2380. tokenizer.pos++;
  2381. return {
  2382. type: "AtKeyword",
  2383. name: scanWord(tokenizer)
  2384. };
  2385. }
  2386. return maybeToken(tokenizer);
  2387. case ASTERISK:
  2388. case PLUSSIGN:
  2389. case QUESTIONMARK:
  2390. case NUMBERSIGN:
  2391. case EXCLAMATIONMARK:
  2392. break;
  2393. case LEFTCURLYBRACKET:
  2394. code = tokenizer.nextCharCode();
  2395. if (code < 48 || code > 57) {
  2396. return maybeToken(tokenizer);
  2397. }
  2398. break;
  2399. default:
  2400. return maybeToken(tokenizer);
  2401. }
  2402. }
  2403. function parse(str) {
  2404. var tokenizer = new Tokenizer(str);
  2405. var result = readImplicitGroup(tokenizer);
  2406. if (tokenizer.pos !== str.length) {
  2407. tokenizer.error("Unexpected input");
  2408. }
  2409. if (result.terms.length === 1 && result.terms[0].type === "Group") {
  2410. result = result.terms[0];
  2411. }
  2412. return result;
  2413. }
  2414. parse("[a&&<b>#|<'c'>*||e() f{2} /,(% g#{1,2} h{2,})]!");
  2415. module.exports = parse;
  2416. }, { "./tokenizer": 20 }], 20: [function (require, module, exports) {
  2417. var SyntaxParseError = require("./error").SyntaxParseError;
  2418. var TAB = 9;
  2419. var N = 10;
  2420. var F = 12;
  2421. var R = 13;
  2422. var SPACE = 32;
  2423. var Tokenizer = function (str) {
  2424. this.str = str;
  2425. this.pos = 0;
  2426. };
  2427. Tokenizer.prototype = {
  2428. charCodeAt: function (pos) {
  2429. return pos < this.str.length ? this.str.charCodeAt(pos) : 0;
  2430. },
  2431. charCode: function () {
  2432. return this.charCodeAt(this.pos);
  2433. },
  2434. nextCharCode: function () {
  2435. return this.charCodeAt(this.pos + 1);
  2436. },
  2437. nextNonWsCode: function (pos) {
  2438. return this.charCodeAt(this.findWsEnd(pos));
  2439. },
  2440. findWsEnd: function (pos) {
  2441. for (; pos < this.str.length; pos++) {
  2442. var code = this.str.charCodeAt(pos);
  2443. if (code !== R && code !== N && code !== F && code !== SPACE && code !== TAB) {
  2444. break;
  2445. }
  2446. }
  2447. return pos;
  2448. },
  2449. substringToPos: function (end) {
  2450. return this.str.substring(this.pos, this.pos = end);
  2451. },
  2452. eat: function (code) {
  2453. if (this.charCode() !== code) {
  2454. this.error("Expect `" + String.fromCharCode(code) + "`");
  2455. }
  2456. this.pos++;
  2457. },
  2458. peek: function () {
  2459. return this.pos < this.str.length ? this.str.charAt(this.pos++) : "";
  2460. },
  2461. error: function (message) {
  2462. throw new SyntaxParseError(message, this.str, this.pos);
  2463. }
  2464. };
  2465. module.exports = Tokenizer;
  2466. }, { "./error": 16 }], 21: [function (require, module, exports) {
  2467. var noop = function () { };
  2468. function ensureFunction(value) {
  2469. return typeof value === "function" ? value : noop;
  2470. }
  2471. module.exports = function (node, options, context) {
  2472. function walk(node) {
  2473. enter.call(context, node);
  2474. switch (node.type) {
  2475. case "Group":
  2476. node.terms.forEach(walk);
  2477. break;
  2478. case "Multiplier":
  2479. walk(node.term);
  2480. break;
  2481. case "Type":
  2482. case "Property":
  2483. case "Keyword":
  2484. case "AtKeyword":
  2485. case "Function":
  2486. case "String":
  2487. case "Token":
  2488. case "Comma":
  2489. break;
  2490. default:
  2491. throw new Error("Unknown type: " + node.type);
  2492. }
  2493. leave.call(context, node);
  2494. }
  2495. var enter = noop;
  2496. var leave = noop;
  2497. if (typeof options === "function") {
  2498. enter = options;
  2499. } else if (options) {
  2500. enter = ensureFunction(options.enter);
  2501. leave = ensureFunction(options.leave);
  2502. }
  2503. if (enter === noop && leave === noop) {
  2504. throw new Error("Neither `enter` nor `leave` walker handler is set or both aren't a function");
  2505. }
  2506. walk(node, context);
  2507. };
  2508. }, {}], 22: [function (require, module, exports) {
  2509. var parse = require("./grammar/parse");
  2510. var MATCH = { type: "Match" };
  2511. var MISMATCH = { type: "Mismatch" };
  2512. var DISALLOW_EMPTY = { type: "DisallowEmpty" };
  2513. var LEFTPARENTHESIS = 40; // (
  2514. var RIGHTPARENTHESIS = 41; // )
  2515. function createCondition(match, thenBranch, elseBranch) {
  2516. if (thenBranch === MATCH && elseBranch === MISMATCH) {
  2517. return match;
  2518. }
  2519. if (match === MATCH && thenBranch === MATCH && elseBranch === MATCH) {
  2520. return match;
  2521. }
  2522. if (match.type === "If" && match.else === MISMATCH && thenBranch === MATCH) {
  2523. thenBranch = match.then;
  2524. match = match.match;
  2525. }
  2526. return {
  2527. type: "If",
  2528. match: match,
  2529. then: thenBranch,
  2530. else: elseBranch
  2531. };
  2532. }
  2533. function isFunctionType(name) {
  2534. return (
  2535. name.length > 2 &&
  2536. name.charCodeAt(name.length - 2) === LEFTPARENTHESIS &&
  2537. name.charCodeAt(name.length - 1) === RIGHTPARENTHESIS
  2538. );
  2539. }
  2540. function isEnumCapatible(term) {
  2541. return (
  2542. term.type === "Keyword" ||
  2543. term.type === "AtKeyword" ||
  2544. term.type === "Function" ||
  2545. term.type === "Type" && isFunctionType(term.name)
  2546. );
  2547. }
  2548. function buildGroupMatchGraph(combinator, terms, atLeastOneTermMatched) {
  2549. switch (combinator) {
  2550. case " ":
  2551. var result = MATCH;
  2552. for (var i = terms.length - 1; i >= 0; i--) {
  2553. var term = terms[i];
  2554. result = createCondition(
  2555. term,
  2556. result,
  2557. MISMATCH
  2558. );
  2559. }
  2560. return result;
  2561. case "|":
  2562. var result = MISMATCH;
  2563. var map = null;
  2564. for (var i = terms.length - 1; i >= 0; i--) {
  2565. var term = terms[i];
  2566. if (isEnumCapatible(term)) {
  2567. if (map === null && i > 0 && isEnumCapatible(terms[i - 1])) {
  2568. map = Object.create(null);
  2569. result = createCondition(
  2570. {
  2571. type: "Enum",
  2572. map: map
  2573. },
  2574. MATCH,
  2575. result
  2576. );
  2577. }
  2578. if (map !== null) {
  2579. var key = (isFunctionType(term.name) ? term.name.slice(0, -1) : term.name).toLowerCase();
  2580. if (key in map === false) {
  2581. map[key] = term;
  2582. continue;
  2583. }
  2584. }
  2585. }
  2586. map = null;
  2587. result = createCondition(
  2588. term,
  2589. MATCH,
  2590. result
  2591. );
  2592. }
  2593. return result;
  2594. case "&&":
  2595. if (terms.length > 5) {
  2596. return {
  2597. type: "MatchOnce",
  2598. terms: terms,
  2599. all: true
  2600. };
  2601. }
  2602. var result = MISMATCH;
  2603. for (var i = terms.length - 1; i >= 0; i--) {
  2604. var term = terms[i];
  2605. var thenClause;
  2606. if (terms.length > 1) {
  2607. thenClause = buildGroupMatchGraph(
  2608. combinator,
  2609. terms.filter(function (newGroupTerm) {
  2610. return newGroupTerm !== term;
  2611. }),
  2612. false
  2613. );
  2614. } else {
  2615. thenClause = MATCH;
  2616. }
  2617. result = createCondition(
  2618. term,
  2619. thenClause,
  2620. result
  2621. );
  2622. }
  2623. return result;
  2624. case "||":
  2625. if (terms.length > 5) {
  2626. return {
  2627. type: "MatchOnce",
  2628. terms: terms,
  2629. all: false
  2630. };
  2631. }
  2632. var result = atLeastOneTermMatched ? MATCH : MISMATCH;
  2633. for (var i = terms.length - 1; i >= 0; i--) {
  2634. var term = terms[i];
  2635. var thenClause;
  2636. if (terms.length > 1) {
  2637. thenClause = buildGroupMatchGraph(
  2638. combinator,
  2639. terms.filter(function (newGroupTerm) {
  2640. return newGroupTerm !== term;
  2641. }),
  2642. true
  2643. );
  2644. } else {
  2645. thenClause = MATCH;
  2646. }
  2647. result = createCondition(
  2648. term,
  2649. thenClause,
  2650. result
  2651. );
  2652. }
  2653. return result;
  2654. }
  2655. }
  2656. function buildMultiplierMatchGraph(node) {
  2657. var result = MATCH;
  2658. var matchTerm = buildMatchGraph(node.term);
  2659. if (node.max === 0) {
  2660. matchTerm = createCondition(
  2661. matchTerm,
  2662. DISALLOW_EMPTY,
  2663. MISMATCH
  2664. );
  2665. result = createCondition(
  2666. matchTerm,
  2667. null, // will be a loop
  2668. MISMATCH
  2669. );
  2670. result.then = createCondition(
  2671. MATCH,
  2672. MATCH,
  2673. result // make a loop
  2674. );
  2675. if (node.comma) {
  2676. result.then.else = createCondition(
  2677. { type: "Comma", syntax: node },
  2678. result,
  2679. MISMATCH
  2680. );
  2681. }
  2682. } else {
  2683. for (var i = node.min || 1; i <= node.max; i++) {
  2684. if (node.comma && result !== MATCH) {
  2685. result = createCondition(
  2686. { type: "Comma", syntax: node },
  2687. result,
  2688. MISMATCH
  2689. );
  2690. }
  2691. result = createCondition(
  2692. matchTerm,
  2693. createCondition(
  2694. MATCH,
  2695. MATCH,
  2696. result
  2697. ),
  2698. MISMATCH
  2699. );
  2700. }
  2701. }
  2702. if (node.min === 0) {
  2703. result = createCondition(
  2704. MATCH,
  2705. MATCH,
  2706. result
  2707. );
  2708. } else {
  2709. for (var i = 0; i < node.min - 1; i++) {
  2710. if (node.comma && result !== MATCH) {
  2711. result = createCondition(
  2712. { type: "Comma", syntax: node },
  2713. result,
  2714. MISMATCH
  2715. );
  2716. }
  2717. result = createCondition(
  2718. matchTerm,
  2719. result,
  2720. MISMATCH
  2721. );
  2722. }
  2723. }
  2724. return result;
  2725. }
  2726. function buildMatchGraph(node) {
  2727. if (typeof node === "function") {
  2728. return {
  2729. type: "Generic",
  2730. fn: node
  2731. };
  2732. }
  2733. switch (node.type) {
  2734. case "Group":
  2735. var result = buildGroupMatchGraph(
  2736. node.combinator,
  2737. node.terms.map(buildMatchGraph),
  2738. false
  2739. );
  2740. if (node.disallowEmpty) {
  2741. result = createCondition(
  2742. result,
  2743. DISALLOW_EMPTY,
  2744. MISMATCH
  2745. );
  2746. }
  2747. return result;
  2748. case "Multiplier":
  2749. return buildMultiplierMatchGraph(node);
  2750. case "Type":
  2751. case "Property":
  2752. return {
  2753. type: node.type,
  2754. name: node.name,
  2755. syntax: node
  2756. };
  2757. case "Keyword":
  2758. return {
  2759. type: node.type,
  2760. name: node.name.toLowerCase(),
  2761. syntax: node
  2762. };
  2763. case "AtKeyword":
  2764. return {
  2765. type: node.type,
  2766. name: "@" + node.name.toLowerCase(),
  2767. syntax: node
  2768. };
  2769. case "Function":
  2770. return {
  2771. type: node.type,
  2772. name: node.name.toLowerCase() + "(",
  2773. syntax: node
  2774. };
  2775. case "String":
  2776. if (node.value.length === 3) {
  2777. return {
  2778. type: "Token",
  2779. value: node.value.charAt(1),
  2780. syntax: node
  2781. };
  2782. }
  2783. return {
  2784. type: node.type,
  2785. value: node.value.substr(1, node.value.length - 2).replace(/\\'/g, "'"),
  2786. syntax: node
  2787. };
  2788. case "Token":
  2789. return {
  2790. type: node.type,
  2791. value: node.value,
  2792. syntax: node
  2793. };
  2794. case "Comma":
  2795. return {
  2796. type: node.type,
  2797. syntax: node
  2798. };
  2799. default:
  2800. throw new Error("Unknown node type:", node.type);
  2801. }
  2802. }
  2803. module.exports = {
  2804. MATCH: MATCH,
  2805. MISMATCH: MISMATCH,
  2806. DISALLOW_EMPTY: DISALLOW_EMPTY,
  2807. buildMatchGraph: function (syntaxTree, ref) {
  2808. if (typeof syntaxTree === "string") {
  2809. syntaxTree = parse(syntaxTree);
  2810. }
  2811. return {
  2812. type: "MatchGraph",
  2813. match: buildMatchGraph(syntaxTree),
  2814. syntax: ref || null,
  2815. source: syntaxTree
  2816. };
  2817. }
  2818. };
  2819. }, { "./grammar/parse": 19 }], 23: [function (require, module, exports) {
  2820. var hasOwnProperty = Object.prototype.hasOwnProperty;
  2821. var matchGraph = require("./match-graph");
  2822. var MATCH = matchGraph.MATCH;
  2823. var MISMATCH = matchGraph.MISMATCH;
  2824. var DISALLOW_EMPTY = matchGraph.DISALLOW_EMPTY;
  2825. var TYPE = require("../tokenizer/const").TYPE;
  2826. var STUB = 0;
  2827. var TOKEN = 1;
  2828. var OPEN_SYNTAX = 2;
  2829. var CLOSE_SYNTAX = 3;
  2830. var EXIT_REASON_MATCH = "Match";
  2831. var EXIT_REASON_MISMATCH = "Mismatch";
  2832. var EXIT_REASON_ITERATION_LIMIT = "Maximum iteration number exceeded (please fill an issue on https://github.com/csstree/csstree/issues)";
  2833. var ITERATION_LIMIT = 15000;
  2834. var totalIterationCount = 0;
  2835. function reverseList(list) {
  2836. var prev = null;
  2837. var next = null;
  2838. var item = list;
  2839. while (item !== null) {
  2840. next = item.prev;
  2841. item.prev = prev;
  2842. prev = item;
  2843. item = next;
  2844. }
  2845. return prev;
  2846. }
  2847. function areStringsEqualCaseInsensitive(testStr, referenceStr) {
  2848. if (testStr.length !== referenceStr.length) {
  2849. return false;
  2850. }
  2851. for (var i = 0; i < testStr.length; i++) {
  2852. var testCode = testStr.charCodeAt(i);
  2853. var referenceCode = referenceStr.charCodeAt(i);
  2854. if (testCode >= 0x0041 && testCode <= 0x005A) {
  2855. testCode = testCode | 32;
  2856. }
  2857. if (testCode !== referenceCode) {
  2858. return false;
  2859. }
  2860. }
  2861. return true;
  2862. }
  2863. function isCommaContextStart(token) {
  2864. if (token === null) {
  2865. return true;
  2866. }
  2867. return (
  2868. token.type === TYPE.Comma ||
  2869. token.type === TYPE.Function ||
  2870. token.type === TYPE.LeftParenthesis ||
  2871. token.type === TYPE.LeftSquareBracket ||
  2872. token.type === TYPE.LeftCurlyBracket ||
  2873. token.type === TYPE.Delim
  2874. );
  2875. }
  2876. function isCommaContextEnd(token) {
  2877. if (token === null) {
  2878. return true;
  2879. }
  2880. return (
  2881. token.type === TYPE.RightParenthesis ||
  2882. token.type === TYPE.RightSquareBracket ||
  2883. token.type === TYPE.RightCurlyBracket ||
  2884. token.type === TYPE.Delim
  2885. );
  2886. }
  2887. function internalMatch(tokens, state, syntaxes) {
  2888. function moveToNextToken() {
  2889. do {
  2890. tokenIndex++;
  2891. token = tokenIndex < tokens.length ? tokens[tokenIndex] : null;
  2892. } while (token !== null && (token.type === TYPE.WhiteSpace || token.type === TYPE.Comment));
  2893. }
  2894. function getNextToken(offset) {
  2895. var nextIndex = tokenIndex + offset;
  2896. return nextIndex < tokens.length ? tokens[nextIndex] : null;
  2897. }
  2898. function stateSnapshotFromSyntax(nextState, prev) {
  2899. return {
  2900. nextState: nextState,
  2901. matchStack: matchStack,
  2902. syntaxStack: syntaxStack,
  2903. thenStack: thenStack,
  2904. tokenIndex: tokenIndex,
  2905. prev: prev
  2906. };
  2907. }
  2908. function pushThenStack(nextState) {
  2909. thenStack = {
  2910. nextState: nextState,
  2911. matchStack: matchStack,
  2912. syntaxStack: syntaxStack,
  2913. prev: thenStack
  2914. };
  2915. }
  2916. function pushElseStack(nextState) {
  2917. elseStack = stateSnapshotFromSyntax(nextState, elseStack);
  2918. }
  2919. function addTokenToMatch() {
  2920. matchStack = {
  2921. type: TOKEN,
  2922. syntax: state.syntax,
  2923. token: token,
  2924. prev: matchStack
  2925. };
  2926. moveToNextToken();
  2927. syntaxStash = null;
  2928. if (tokenIndex > longestMatch) {
  2929. longestMatch = tokenIndex;
  2930. }
  2931. }
  2932. function openSyntax() {
  2933. syntaxStack = {
  2934. syntax: state.syntax,
  2935. opts: state.syntax.opts || (syntaxStack !== null && syntaxStack.opts) || null,
  2936. prev: syntaxStack
  2937. };
  2938. matchStack = {
  2939. type: OPEN_SYNTAX,
  2940. syntax: state.syntax,
  2941. token: matchStack.token,
  2942. prev: matchStack
  2943. };
  2944. }
  2945. function closeSyntax() {
  2946. if (matchStack.type === OPEN_SYNTAX) {
  2947. matchStack = matchStack.prev;
  2948. } else {
  2949. matchStack = {
  2950. type: CLOSE_SYNTAX,
  2951. syntax: syntaxStack.syntax,
  2952. token: matchStack.token,
  2953. prev: matchStack
  2954. };
  2955. }
  2956. syntaxStack = syntaxStack.prev;
  2957. }
  2958. var syntaxStack = null;
  2959. var thenStack = null;
  2960. var elseStack = null;
  2961. var syntaxStash = null;
  2962. var iterationCount = 0; // count iterations and prevent infinite loop
  2963. var exitReason = null;
  2964. var token = null;
  2965. var tokenIndex = -1;
  2966. var longestMatch = 0;
  2967. var matchStack = {
  2968. type: STUB,
  2969. syntax: null,
  2970. token: null,
  2971. prev: null
  2972. };
  2973. moveToNextToken();
  2974. while (exitReason === null && ++iterationCount < ITERATION_LIMIT) {
  2975. switch (state.type) {
  2976. case "Match":
  2977. if (thenStack === null) {
  2978. if (token !== null) {
  2979. if (tokenIndex !== tokens.length - 1 || (token.value !== "\\0" && token.value !== "\\9")) {
  2980. state = MISMATCH;
  2981. break;
  2982. }
  2983. }
  2984. exitReason = EXIT_REASON_MATCH;
  2985. break;
  2986. }
  2987. state = thenStack.nextState;
  2988. if (state === DISALLOW_EMPTY) {
  2989. if (thenStack.matchStack === matchStack) {
  2990. state = MISMATCH;
  2991. break;
  2992. } else {
  2993. state = MATCH;
  2994. }
  2995. }
  2996. while (thenStack.syntaxStack !== syntaxStack) {
  2997. closeSyntax();
  2998. }
  2999. thenStack = thenStack.prev;
  3000. break;
  3001. case "Mismatch":
  3002. if (syntaxStash !== null && syntaxStash !== false) {
  3003. if (elseStack === null || tokenIndex > elseStack.tokenIndex) {
  3004. elseStack = syntaxStash;
  3005. syntaxStash = false; // disable stashing
  3006. }
  3007. } else if (elseStack === null) {
  3008. exitReason = EXIT_REASON_MISMATCH;
  3009. break;
  3010. }
  3011. state = elseStack.nextState;
  3012. thenStack = elseStack.thenStack;
  3013. syntaxStack = elseStack.syntaxStack;
  3014. matchStack = elseStack.matchStack;
  3015. tokenIndex = elseStack.tokenIndex;
  3016. token = tokenIndex < tokens.length ? tokens[tokenIndex] : null;
  3017. elseStack = elseStack.prev;
  3018. break;
  3019. case "MatchGraph":
  3020. state = state.match;
  3021. break;
  3022. case "If":
  3023. if (state.else !== MISMATCH) {
  3024. pushElseStack(state.else);
  3025. }
  3026. if (state.then !== MATCH) {
  3027. pushThenStack(state.then);
  3028. }
  3029. state = state.match;
  3030. break;
  3031. case "MatchOnce":
  3032. state = {
  3033. type: "MatchOnceBuffer",
  3034. syntax: state,
  3035. index: 0,
  3036. mask: 0
  3037. };
  3038. break;
  3039. case "MatchOnceBuffer":
  3040. var terms = state.syntax.terms;
  3041. if (state.index === terms.length) {
  3042. if (state.mask === 0 || state.syntax.all) {
  3043. state = MISMATCH;
  3044. break;
  3045. }
  3046. state = MATCH;
  3047. break;
  3048. }
  3049. if (state.mask === (1 << terms.length) - 1) {
  3050. state = MATCH;
  3051. break;
  3052. }
  3053. for (; state.index < terms.length; state.index++) {
  3054. var matchFlag = 1 << state.index;
  3055. if ((state.mask & matchFlag) === 0) {
  3056. pushElseStack(state);
  3057. pushThenStack({
  3058. type: "AddMatchOnce",
  3059. syntax: state.syntax,
  3060. mask: state.mask | matchFlag
  3061. });
  3062. state = terms[state.index++];
  3063. break;
  3064. }
  3065. }
  3066. break;
  3067. case "AddMatchOnce":
  3068. state = {
  3069. type: "MatchOnceBuffer",
  3070. syntax: state.syntax,
  3071. index: 0,
  3072. mask: state.mask
  3073. };
  3074. break;
  3075. case "Enum":
  3076. if (token !== null) {
  3077. var name = token.value.toLowerCase();
  3078. if (name.indexOf("\\") !== -1) {
  3079. name = name.replace(/\\[09].*$/, "");
  3080. }
  3081. if (hasOwnProperty.call(state.map, name)) {
  3082. state = state.map[name];
  3083. break;
  3084. }
  3085. }
  3086. state = MISMATCH;
  3087. break;
  3088. case "Generic":
  3089. var opts = syntaxStack !== null ? syntaxStack.opts : null;
  3090. var lastTokenIndex = tokenIndex + Math.floor(state.fn(token, getNextToken, opts));
  3091. if (!isNaN(lastTokenIndex) && lastTokenIndex > tokenIndex) {
  3092. while (tokenIndex < lastTokenIndex) {
  3093. addTokenToMatch();
  3094. }
  3095. state = MATCH;
  3096. } else {
  3097. state = MISMATCH;
  3098. }
  3099. break;
  3100. case "Type":
  3101. case "Property":
  3102. var syntaxDict = state.type === "Type" ? "types" : "properties";
  3103. var dictSyntax = hasOwnProperty.call(syntaxes, syntaxDict) ? syntaxes[syntaxDict][state.name] : null;
  3104. if (!dictSyntax || !dictSyntax.match) {
  3105. throw new Error(
  3106. "Bad syntax reference: " +
  3107. (state.type === "Type"
  3108. ? "<" + state.name + ">"
  3109. : "<'" + state.name + "'>")
  3110. );
  3111. }
  3112. if (syntaxStash !== false && token !== null && state.type === "Type") {
  3113. var lowPriorityMatching =
  3114. (state.name === "custom-ident" && token.type === TYPE.Ident) ||
  3115. (state.name === "length" && token.value === "0");
  3116. if (lowPriorityMatching) {
  3117. if (syntaxStash === null) {
  3118. syntaxStash = stateSnapshotFromSyntax(state, elseStack);
  3119. }
  3120. state = MISMATCH;
  3121. break;
  3122. }
  3123. }
  3124. openSyntax();
  3125. state = dictSyntax.match;
  3126. break;
  3127. case "Keyword":
  3128. var name = state.name;
  3129. if (token !== null) {
  3130. var keywordName = token.value;
  3131. if (keywordName.indexOf("\\") !== -1) {
  3132. keywordName = keywordName.replace(/\\[09].*$/, "");
  3133. }
  3134. if (areStringsEqualCaseInsensitive(keywordName, name)) {
  3135. addTokenToMatch();
  3136. state = MATCH;
  3137. break;
  3138. }
  3139. }
  3140. state = MISMATCH;
  3141. break;
  3142. case "AtKeyword":
  3143. case "Function":
  3144. if (token !== null && areStringsEqualCaseInsensitive(token.value, state.name)) {
  3145. addTokenToMatch();
  3146. state = MATCH;
  3147. break;
  3148. }
  3149. state = MISMATCH;
  3150. break;
  3151. case "Token":
  3152. if (token !== null && token.value === state.value) {
  3153. addTokenToMatch();
  3154. state = MATCH;
  3155. break;
  3156. }
  3157. state = MISMATCH;
  3158. break;
  3159. case "Comma":
  3160. if (token !== null && token.type === TYPE.Comma) {
  3161. if (isCommaContextStart(matchStack.token)) {
  3162. state = MISMATCH;
  3163. } else {
  3164. addTokenToMatch();
  3165. state = isCommaContextEnd(token) ? MISMATCH : MATCH;
  3166. }
  3167. } else {
  3168. state = isCommaContextStart(matchStack.token) || isCommaContextEnd(token) ? MATCH : MISMATCH;
  3169. }
  3170. break;
  3171. case "String":
  3172. var string = "";
  3173. for (var lastTokenIndex = tokenIndex; lastTokenIndex < tokens.length && string.length < state.value.length; lastTokenIndex++) {
  3174. string += tokens[lastTokenIndex].value;
  3175. }
  3176. if (areStringsEqualCaseInsensitive(string, state.value)) {
  3177. while (tokenIndex < lastTokenIndex) {
  3178. addTokenToMatch();
  3179. }
  3180. state = MATCH;
  3181. } else {
  3182. state = MISMATCH;
  3183. }
  3184. break;
  3185. default:
  3186. throw new Error("Unknown node type: " + state.type);
  3187. }
  3188. }
  3189. totalIterationCount += iterationCount;
  3190. switch (exitReason) {
  3191. case null:
  3192. exitReason = EXIT_REASON_ITERATION_LIMIT;
  3193. matchStack = null;
  3194. break;
  3195. case EXIT_REASON_MATCH:
  3196. while (syntaxStack !== null) {
  3197. closeSyntax();
  3198. }
  3199. break;
  3200. default:
  3201. matchStack = null;
  3202. }
  3203. return {
  3204. tokens: tokens,
  3205. reason: exitReason,
  3206. iterations: iterationCount,
  3207. match: matchStack,
  3208. longestMatch: longestMatch
  3209. };
  3210. }
  3211. function matchAsList(tokens, matchGraph, syntaxes) {
  3212. var matchResult = internalMatch(tokens, matchGraph, syntaxes || {});
  3213. if (matchResult.match !== null) {
  3214. var item = reverseList(matchResult.match).prev;
  3215. matchResult.match = [];
  3216. while (item !== null) {
  3217. switch (item.type) {
  3218. case STUB:
  3219. break;
  3220. case OPEN_SYNTAX:
  3221. case CLOSE_SYNTAX:
  3222. matchResult.match.push({
  3223. type: item.type,
  3224. syntax: item.syntax
  3225. });
  3226. break;
  3227. default:
  3228. matchResult.match.push({
  3229. token: item.token.value,
  3230. node: item.token.node
  3231. });
  3232. break;
  3233. }
  3234. item = item.prev;
  3235. }
  3236. }
  3237. return matchResult;
  3238. }
  3239. function matchAsTree(tokens, matchGraph, syntaxes) {
  3240. var matchResult = internalMatch(tokens, matchGraph, syntaxes || {});
  3241. if (matchResult.match === null) {
  3242. return matchResult;
  3243. }
  3244. var item = matchResult.match;
  3245. var host = matchResult.match = {
  3246. syntax: matchGraph.syntax || null,
  3247. match: []
  3248. };
  3249. var hostStack = [host];
  3250. item = reverseList(item).prev;
  3251. while (item !== null) {
  3252. switch (item.type) {
  3253. case OPEN_SYNTAX:
  3254. host.match.push(host = {
  3255. syntax: item.syntax,
  3256. match: []
  3257. });
  3258. hostStack.push(host);
  3259. break;
  3260. case CLOSE_SYNTAX:
  3261. hostStack.pop();
  3262. host = hostStack[hostStack.length - 1];
  3263. break;
  3264. default:
  3265. host.match.push({
  3266. syntax: item.syntax || null,
  3267. token: item.token.value,
  3268. node: item.token.node
  3269. });
  3270. }
  3271. item = item.prev;
  3272. }
  3273. return matchResult;
  3274. }
  3275. module.exports = {
  3276. matchAsList: matchAsList,
  3277. matchAsTree: matchAsTree,
  3278. getTotalIterationCount: function () {
  3279. return totalIterationCount;
  3280. }
  3281. };
  3282. }, { "../tokenizer/const": 106, "./match-graph": 22 }], 24: [function (require, module, exports) {
  3283. var tokenize = require("../tokenizer");
  3284. var TokenStream = require("../common/TokenStream");
  3285. var tokenStream = new TokenStream();
  3286. var astToTokens = {
  3287. decorator: function (handlers) {
  3288. var curNode = null;
  3289. var prev = { len: 0, node: null };
  3290. var nodes = [prev];
  3291. var buffer = "";
  3292. return {
  3293. children: handlers.children,
  3294. node: function (node) {
  3295. var tmp = curNode;
  3296. curNode = node;
  3297. handlers.node.call(this, node);
  3298. curNode = tmp;
  3299. },
  3300. chunk: function (chunk) {
  3301. buffer += chunk;
  3302. if (prev.node !== curNode) {
  3303. nodes.push({
  3304. len: chunk.length,
  3305. node: curNode
  3306. });
  3307. } else {
  3308. prev.len += chunk.length;
  3309. }
  3310. },
  3311. result: function () {
  3312. return prepareTokens(buffer, nodes);
  3313. }
  3314. };
  3315. }
  3316. };
  3317. function prepareTokens(str, nodes) {
  3318. var tokens = [];
  3319. var nodesOffset = 0;
  3320. var nodesIndex = 0;
  3321. var currentNode = nodes ? nodes[nodesIndex].node : null;
  3322. tokenize(str, tokenStream);
  3323. while (!tokenStream.eof) {
  3324. if (nodes) {
  3325. while (nodesIndex < nodes.length && nodesOffset + nodes[nodesIndex].len <= tokenStream.tokenStart) {
  3326. nodesOffset += nodes[nodesIndex++].len;
  3327. currentNode = nodes[nodesIndex].node;
  3328. }
  3329. }
  3330. tokens.push({
  3331. type: tokenStream.tokenType,
  3332. value: tokenStream.getTokenValue(),
  3333. index: tokenStream.tokenIndex, // TODO: remove it, temporary solution
  3334. balance: tokenStream.balance[tokenStream.tokenIndex], // TODO: remove it, temporary solution
  3335. node: currentNode
  3336. });
  3337. tokenStream.next();
  3338. }
  3339. return tokens;
  3340. }
  3341. module.exports = function (value, syntax) {
  3342. if (typeof value === "string") {
  3343. return prepareTokens(value, null);
  3344. }
  3345. return syntax.generate(value, astToTokens);
  3346. };
  3347. }, { "../common/TokenStream": 5, "../tokenizer": 107 }], 25: [function (require, module, exports) {
  3348. var List = require("../common/List");
  3349. function getFirstMatchNode(matchNode) {
  3350. if ("node" in matchNode) {
  3351. return matchNode.node;
  3352. }
  3353. return getFirstMatchNode(matchNode.match[0]);
  3354. }
  3355. function getLastMatchNode(matchNode) {
  3356. if ("node" in matchNode) {
  3357. return matchNode.node;
  3358. }
  3359. return getLastMatchNode(matchNode.match[matchNode.match.length - 1]);
  3360. }
  3361. function matchFragments(lexer, ast, match, type, name) {
  3362. function findFragments(matchNode) {
  3363. if (matchNode.syntax !== null &&
  3364. matchNode.syntax.type === type &&
  3365. matchNode.syntax.name === name) {
  3366. var start = getFirstMatchNode(matchNode);
  3367. var end = getLastMatchNode(matchNode);
  3368. lexer.syntax.walk(ast, function (node, item, list) {
  3369. if (node === start) {
  3370. var nodes = new List();
  3371. do {
  3372. nodes.appendData(item.data);
  3373. if (item.data === end) {
  3374. break;
  3375. }
  3376. item = item.next;
  3377. } while (item !== null);
  3378. fragments.push({
  3379. parent: list,
  3380. nodes: nodes
  3381. });
  3382. }
  3383. });
  3384. }
  3385. if (Array.isArray(matchNode.match)) {
  3386. matchNode.match.forEach(findFragments);
  3387. }
  3388. }
  3389. var fragments = [];
  3390. if (match.matched !== null) {
  3391. findFragments(match.matched);
  3392. }
  3393. return fragments;
  3394. }
  3395. module.exports = {
  3396. matchFragments: matchFragments
  3397. };
  3398. }, { "../common/List": 2 }], 26: [function (require, module, exports) {
  3399. var List = require("../common/List");
  3400. var hasOwnProperty = Object.prototype.hasOwnProperty;
  3401. function isValidNumber(value) {
  3402. return (
  3403. typeof value === "number" &&
  3404. isFinite(value) &&
  3405. Math.floor(value) === value &&
  3406. value >= 0
  3407. );
  3408. }
  3409. function isValidLocation(loc) {
  3410. return (
  3411. Boolean(loc) &&
  3412. isValidNumber(loc.offset) &&
  3413. isValidNumber(loc.line) &&
  3414. isValidNumber(loc.column)
  3415. );
  3416. }
  3417. function createNodeStructureChecker(type, fields) {
  3418. return function checkNode(node, warn) {
  3419. if (!node || node.constructor !== Object) {
  3420. return warn(node, "Type of node should be an Object");
  3421. }
  3422. for (var key in node) {
  3423. var valid = true;
  3424. if (hasOwnProperty.call(node, key) === false) {
  3425. continue;
  3426. }
  3427. if (key === "type") {
  3428. if (node.type !== type) {
  3429. warn(node, "Wrong node type `" + node.type + "`, expected `" + type + "`");
  3430. }
  3431. } else if (key === "loc") {
  3432. if (node.loc === null) {
  3433. continue;
  3434. } else if (node.loc && node.loc.constructor === Object) {
  3435. if (typeof node.loc.source !== "string") {
  3436. key += ".source";
  3437. } else if (!isValidLocation(node.loc.start)) {
  3438. key += ".start";
  3439. } else if (!isValidLocation(node.loc.end)) {
  3440. key += ".end";
  3441. } else {
  3442. continue;
  3443. }
  3444. }
  3445. valid = false;
  3446. } else if (fields.hasOwnProperty(key)) {
  3447. for (var i = 0, valid = false; !valid && i < fields[key].length; i++) {
  3448. var fieldType = fields[key][i];
  3449. switch (fieldType) {
  3450. case String:
  3451. valid = typeof node[key] === "string";
  3452. break;
  3453. case Boolean:
  3454. valid = typeof node[key] === "boolean";
  3455. break;
  3456. case null:
  3457. valid = node[key] === null;
  3458. break;
  3459. default:
  3460. if (typeof fieldType === "string") {
  3461. valid = node[key] && node[key].type === fieldType;
  3462. } else if (Array.isArray(fieldType)) {
  3463. valid = node[key] instanceof List;
  3464. }
  3465. }
  3466. }
  3467. } else {
  3468. warn(node, "Unknown field `" + key + "` for " + type + " node type");
  3469. }
  3470. if (!valid) {
  3471. warn(node, "Bad value for `" + type + "." + key + "`");
  3472. }
  3473. }
  3474. for (var key in fields) {
  3475. if (hasOwnProperty.call(fields, key) &&
  3476. hasOwnProperty.call(node, key) === false) {
  3477. warn(node, "Field `" + type + "." + key + "` is missed");
  3478. }
  3479. }
  3480. };
  3481. }
  3482. function processStructure(name, nodeType) {
  3483. var structure = nodeType.structure;
  3484. var fields = {
  3485. type: String,
  3486. loc: true
  3487. };
  3488. var docs = {
  3489. type: "\"" + name + "\""
  3490. };
  3491. for (var key in structure) {
  3492. if (hasOwnProperty.call(structure, key) === false) {
  3493. continue;
  3494. }
  3495. var docsTypes = [];
  3496. var fieldTypes = fields[key] = Array.isArray(structure[key])
  3497. ? structure[key].slice()
  3498. : [structure[key]];
  3499. for (var i = 0; i < fieldTypes.length; i++) {
  3500. var fieldType = fieldTypes[i];
  3501. if (fieldType === String || fieldType === Boolean) {
  3502. docsTypes.push(fieldType.name);
  3503. } else if (fieldType === null) {
  3504. docsTypes.push("null");
  3505. } else if (typeof fieldType === "string") {
  3506. docsTypes.push("<" + fieldType + ">");
  3507. } else if (Array.isArray(fieldType)) {
  3508. docsTypes.push("List"); // TODO: use type enum
  3509. } else {
  3510. throw new Error("Wrong value `" + fieldType + "` in `" + name + "." + key + "` structure definition");
  3511. }
  3512. }
  3513. docs[key] = docsTypes.join(" | ");
  3514. }
  3515. return {
  3516. docs: docs,
  3517. check: createNodeStructureChecker(name, fields)
  3518. };
  3519. }
  3520. module.exports = {
  3521. getStructureFromConfig: function (config) {
  3522. var structure = {};
  3523. if (config.node) {
  3524. for (var name in config.node) {
  3525. if (hasOwnProperty.call(config.node, name)) {
  3526. var nodeType = config.node[name];
  3527. if (nodeType.structure) {
  3528. structure[name] = processStructure(name, nodeType);
  3529. } else {
  3530. throw new Error("Missed `structure` field in `" + name + "` node type definition");
  3531. }
  3532. }
  3533. }
  3534. }
  3535. return structure;
  3536. }
  3537. };
  3538. }, { "../common/List": 2 }], 27: [function (require, module, exports) {
  3539. function getTrace(node) {
  3540. function shouldPutToTrace(syntax) {
  3541. if (syntax === null) {
  3542. return false;
  3543. }
  3544. return (
  3545. syntax.type === "Type" ||
  3546. syntax.type === "Property" ||
  3547. syntax.type === "Keyword"
  3548. );
  3549. }
  3550. function hasMatch(matchNode) {
  3551. if (Array.isArray(matchNode.match)) {
  3552. for (var i = 0; i < matchNode.match.length; i++) {
  3553. if (hasMatch(matchNode.match[i])) {
  3554. if (shouldPutToTrace(matchNode.syntax)) {
  3555. result.unshift(matchNode.syntax);
  3556. }
  3557. return true;
  3558. }
  3559. }
  3560. } else if (matchNode.node === node) {
  3561. result = shouldPutToTrace(matchNode.syntax)
  3562. ? [matchNode.syntax]
  3563. : [];
  3564. return true;
  3565. }
  3566. return false;
  3567. }
  3568. var result = null;
  3569. if (this.matched !== null) {
  3570. hasMatch(this.matched);
  3571. }
  3572. return result;
  3573. }
  3574. function testNode(match, node, fn) {
  3575. var trace = getTrace.call(match, node);
  3576. if (trace === null) {
  3577. return false;
  3578. }
  3579. return trace.some(fn);
  3580. }
  3581. function isType(node, type) {
  3582. return testNode(this, node, function (matchNode) {
  3583. return matchNode.type === "Type" && matchNode.name === type;
  3584. });
  3585. }
  3586. function isProperty(node, property) {
  3587. return testNode(this, node, function (matchNode) {
  3588. return matchNode.type === "Property" && matchNode.name === property;
  3589. });
  3590. }
  3591. function isKeyword(node) {
  3592. return testNode(this, node, function (matchNode) {
  3593. return matchNode.type === "Keyword";
  3594. });
  3595. }
  3596. module.exports = {
  3597. getTrace: getTrace,
  3598. isType: isType,
  3599. isProperty: isProperty,
  3600. isKeyword: isKeyword
  3601. };
  3602. }, {}], 28: [function (require, module, exports) {
  3603. var OffsetToLocation = require("../common/OffsetToLocation");
  3604. var SyntaxError = require("../common/SyntaxError");
  3605. var TokenStream = require("../common/TokenStream");
  3606. var List = require("../common/List");
  3607. var tokenize = require("../tokenizer");
  3608. var constants = require("../tokenizer/const");
  3609. var findWhiteSpaceStart = require("../tokenizer/utils").findWhiteSpaceStart;
  3610. var sequence = require("./sequence");
  3611. var noop = function () { };
  3612. var TYPE = constants.TYPE;
  3613. var NAME = constants.NAME;
  3614. var WHITESPACE = TYPE.WhiteSpace;
  3615. var IDENT = TYPE.Ident;
  3616. var FUNCTION = TYPE.Function;
  3617. var URL = TYPE.Url;
  3618. var HASH = TYPE.Hash;
  3619. var PERCENTAGE = TYPE.Percentage;
  3620. var NUMBER = TYPE.Number;
  3621. var NUMBERSIGN = 0x0023; // U+0023 NUMBER SIGN (#)
  3622. var NULL = 0;
  3623. function createParseContext(name) {
  3624. return function () {
  3625. return this[name]();
  3626. };
  3627. }
  3628. function processConfig(config) {
  3629. var parserConfig = {
  3630. context: {},
  3631. scope: {},
  3632. atrule: {},
  3633. pseudo: {}
  3634. };
  3635. if (config.parseContext) {
  3636. for (var name in config.parseContext) {
  3637. switch (typeof config.parseContext[name]) {
  3638. case "function":
  3639. parserConfig.context[name] = config.parseContext[name];
  3640. break;
  3641. case "string":
  3642. parserConfig.context[name] = createParseContext(config.parseContext[name]);
  3643. break;
  3644. }
  3645. }
  3646. }
  3647. if (config.scope) {
  3648. for (var name in config.scope) {
  3649. parserConfig.scope[name] = config.scope[name];
  3650. }
  3651. }
  3652. if (config.atrule) {
  3653. for (var name in config.atrule) {
  3654. var atrule = config.atrule[name];
  3655. if (atrule.parse) {
  3656. parserConfig.atrule[name] = atrule.parse;
  3657. }
  3658. }
  3659. }
  3660. if (config.pseudo) {
  3661. for (var name in config.pseudo) {
  3662. var pseudo = config.pseudo[name];
  3663. if (pseudo.parse) {
  3664. parserConfig.pseudo[name] = pseudo.parse;
  3665. }
  3666. }
  3667. }
  3668. if (config.node) {
  3669. for (var name in config.node) {
  3670. parserConfig[name] = config.node[name].parse;
  3671. }
  3672. }
  3673. return parserConfig;
  3674. }
  3675. module.exports = function createParser(config) {
  3676. var parser = {
  3677. scanner: new TokenStream(),
  3678. locationMap: new OffsetToLocation(),
  3679. filename: "<unknown>",
  3680. needPositions: false,
  3681. onParseError: noop,
  3682. onParseErrorThrow: false,
  3683. parseAtrulePrelude: true,
  3684. parseRulePrelude: true,
  3685. parseValue: true,
  3686. parseCustomProperty: false,
  3687. readSequence: sequence,
  3688. createList: function () {
  3689. return new List();
  3690. },
  3691. createSingleNodeList: function (node) {
  3692. return new List().appendData(node);
  3693. },
  3694. getFirstListNode: function (list) {
  3695. return list && list.first();
  3696. },
  3697. getLastListNode: function (list) {
  3698. return list.last();
  3699. },
  3700. parseWithFallback: function (consumer, fallback) {
  3701. var startToken = this.scanner.tokenIndex;
  3702. try {
  3703. return consumer.call(this);
  3704. } catch (e) {
  3705. if (this.onParseErrorThrow) {
  3706. throw e;
  3707. }
  3708. var fallbackNode = fallback.call(this, startToken);
  3709. this.onParseErrorThrow = true;
  3710. this.onParseError(e, fallbackNode);
  3711. this.onParseErrorThrow = false;
  3712. return fallbackNode;
  3713. }
  3714. },
  3715. lookupNonWSType: function (offset) {
  3716. do {
  3717. var type = this.scanner.lookupType(offset++);
  3718. if (type !== WHITESPACE) {
  3719. return type;
  3720. }
  3721. } while (type !== NULL);
  3722. return NULL;
  3723. },
  3724. eat: function (tokenType) {
  3725. if (this.scanner.tokenType !== tokenType) {
  3726. var offset = this.scanner.tokenStart;
  3727. var message = NAME[tokenType] + " is expected";
  3728. switch (tokenType) {
  3729. case IDENT:
  3730. if (this.scanner.tokenType === FUNCTION || this.scanner.tokenType === URL) {
  3731. offset = this.scanner.tokenEnd - 1;
  3732. message = "Identifier is expected but function found";
  3733. } else {
  3734. message = "Identifier is expected";
  3735. }
  3736. break;
  3737. case HASH:
  3738. if (this.scanner.isDelim(NUMBERSIGN)) {
  3739. this.scanner.next();
  3740. offset++;
  3741. message = "Name is expected";
  3742. }
  3743. break;
  3744. case PERCENTAGE:
  3745. if (this.scanner.tokenType === NUMBER) {
  3746. offset = this.scanner.tokenEnd;
  3747. message = "Percent sign is expected";
  3748. }
  3749. break;
  3750. default:
  3751. if (this.scanner.source.charCodeAt(this.scanner.tokenStart) === tokenType) {
  3752. offset = offset + 1;
  3753. }
  3754. }
  3755. this.error(message, offset);
  3756. }
  3757. this.scanner.next();
  3758. },
  3759. consume: function (tokenType) {
  3760. var value = this.scanner.getTokenValue();
  3761. this.eat(tokenType);
  3762. return value;
  3763. },
  3764. consumeFunctionName: function () {
  3765. var name = this.scanner.source.substring(this.scanner.tokenStart, this.scanner.tokenEnd - 1);
  3766. this.eat(FUNCTION);
  3767. return name;
  3768. },
  3769. getLocation: function (start, end) {
  3770. if (this.needPositions) {
  3771. return this.locationMap.getLocationRange(
  3772. start,
  3773. end,
  3774. this.filename
  3775. );
  3776. }
  3777. return null;
  3778. },
  3779. getLocationFromList: function (list) {
  3780. if (this.needPositions) {
  3781. var head = this.getFirstListNode(list);
  3782. var tail = this.getLastListNode(list);
  3783. return this.locationMap.getLocationRange(
  3784. head !== null ? head.loc.start.offset - this.locationMap.startOffset : this.scanner.tokenStart,
  3785. tail !== null ? tail.loc.end.offset - this.locationMap.startOffset : this.scanner.tokenStart,
  3786. this.filename
  3787. );
  3788. }
  3789. return null;
  3790. },
  3791. error: function (message, offset) {
  3792. var location = typeof offset !== "undefined" && offset < this.scanner.source.length
  3793. ? this.locationMap.getLocation(offset)
  3794. : this.scanner.eof
  3795. ? this.locationMap.getLocation(findWhiteSpaceStart(this.scanner.source, this.scanner.source.length - 1))
  3796. : this.locationMap.getLocation(this.scanner.tokenStart);
  3797. throw new SyntaxError(
  3798. message || "Unexpected input",
  3799. this.scanner.source,
  3800. location.offset,
  3801. location.line,
  3802. location.column
  3803. );
  3804. }
  3805. };
  3806. config = processConfig(config || {});
  3807. for (var key in config) {
  3808. parser[key] = config[key];
  3809. }
  3810. return function (source, options) {
  3811. options = options || {};
  3812. var context = options.context || "default";
  3813. var ast;
  3814. tokenize(source, parser.scanner);
  3815. parser.locationMap.setSource(
  3816. source,
  3817. options.offset,
  3818. options.line,
  3819. options.column
  3820. );
  3821. parser.filename = options.filename || "<unknown>";
  3822. parser.needPositions = Boolean(options.positions);
  3823. parser.onParseError = typeof options.onParseError === "function" ? options.onParseError : noop;
  3824. parser.onParseErrorThrow = false;
  3825. parser.parseAtrulePrelude = "parseAtrulePrelude" in options ? Boolean(options.parseAtrulePrelude) : true;
  3826. parser.parseRulePrelude = "parseRulePrelude" in options ? Boolean(options.parseRulePrelude) : true;
  3827. parser.parseValue = "parseValue" in options ? Boolean(options.parseValue) : true;
  3828. parser.parseCustomProperty = "parseCustomProperty" in options ? Boolean(options.parseCustomProperty) : false;
  3829. if (!parser.context.hasOwnProperty(context)) {
  3830. throw new Error("Unknown context `" + context + "`");
  3831. }
  3832. ast = parser.context[context].call(parser, options);
  3833. if (!parser.scanner.eof) {
  3834. parser.error();
  3835. }
  3836. return ast;
  3837. };
  3838. };
  3839. }, { "../common/List": 2, "../common/OffsetToLocation": 3, "../common/SyntaxError": 4, "../common/TokenStream": 5, "../tokenizer": 107, "../tokenizer/const": 106, "../tokenizer/utils": 108, "./sequence": 29 }], 29: [function (require, module, exports) {
  3840. var TYPE = require("../tokenizer").TYPE;
  3841. var WHITESPACE = TYPE.WhiteSpace;
  3842. var COMMENT = TYPE.Comment;
  3843. module.exports = function readSequence(recognizer) {
  3844. var children = this.createList();
  3845. var child = null;
  3846. var context = {
  3847. recognizer: recognizer,
  3848. space: null,
  3849. ignoreWS: false,
  3850. ignoreWSAfter: false
  3851. };
  3852. this.scanner.skipSC();
  3853. while (!this.scanner.eof) {
  3854. switch (this.scanner.tokenType) {
  3855. case COMMENT:
  3856. this.scanner.next();
  3857. continue;
  3858. case WHITESPACE:
  3859. if (context.ignoreWS) {
  3860. this.scanner.next();
  3861. } else {
  3862. context.space = this.WhiteSpace();
  3863. }
  3864. continue;
  3865. }
  3866. child = recognizer.getNode.call(this, context);
  3867. if (child === undefined) {
  3868. break;
  3869. }
  3870. if (context.space !== null) {
  3871. children.push(context.space);
  3872. context.space = null;
  3873. }
  3874. children.push(child);
  3875. if (context.ignoreWSAfter) {
  3876. context.ignoreWSAfter = false;
  3877. context.ignoreWS = true;
  3878. } else {
  3879. context.ignoreWS = false;
  3880. }
  3881. }
  3882. return children;
  3883. };
  3884. }, { "../tokenizer": 107 }], 30: [function (require, module, exports) {
  3885. module.exports = {
  3886. parse: {
  3887. prelude: null,
  3888. block: function () {
  3889. return this.Block(true);
  3890. }
  3891. }
  3892. };
  3893. }, {}], 31: [function (require, module, exports) {
  3894. var TYPE = require("../../tokenizer").TYPE;
  3895. var STRING = TYPE.String;
  3896. var IDENT = TYPE.Ident;
  3897. var URL = TYPE.Url;
  3898. var FUNCTION = TYPE.Function;
  3899. var LEFTPARENTHESIS = TYPE.LeftParenthesis;
  3900. module.exports = {
  3901. parse: {
  3902. prelude: function () {
  3903. var children = this.createList();
  3904. this.scanner.skipSC();
  3905. switch (this.scanner.tokenType) {
  3906. case STRING:
  3907. children.push(this.String());
  3908. break;
  3909. case URL:
  3910. case FUNCTION:
  3911. children.push(this.Url());
  3912. break;
  3913. default:
  3914. this.error("String or url() is expected");
  3915. }
  3916. if (this.lookupNonWSType(0) === IDENT ||
  3917. this.lookupNonWSType(0) === LEFTPARENTHESIS) {
  3918. children.push(this.WhiteSpace());
  3919. children.push(this.MediaQueryList());
  3920. }
  3921. return children;
  3922. },
  3923. block: null
  3924. }
  3925. };
  3926. }, { "../../tokenizer": 107 }], 32: [function (require, module, exports) {
  3927. module.exports = {
  3928. "font-face": require("./font-face"),
  3929. "import": require("./import"),
  3930. "media": require("./media"),
  3931. "page": require("./page"),
  3932. "supports": require("./supports")
  3933. };
  3934. }, { "./font-face": 30, "./import": 31, "./media": 33, "./page": 34, "./supports": 35 }], 33: [function (require, module, exports) {
  3935. module.exports = {
  3936. parse: {
  3937. prelude: function () {
  3938. return this.createSingleNodeList(
  3939. this.MediaQueryList()
  3940. );
  3941. },
  3942. block: function () {
  3943. return this.Block(false);
  3944. }
  3945. }
  3946. };
  3947. }, {}], 34: [function (require, module, exports) {
  3948. module.exports = {
  3949. parse: {
  3950. prelude: function () {
  3951. return this.createSingleNodeList(
  3952. this.SelectorList()
  3953. );
  3954. },
  3955. block: function () {
  3956. return this.Block(true);
  3957. }
  3958. }
  3959. };
  3960. }, {}], 35: [function (require, module, exports) {
  3961. var TYPE = require("../../tokenizer").TYPE;
  3962. var WHITESPACE = TYPE.WhiteSpace;
  3963. var COMMENT = TYPE.Comment;
  3964. var IDENT = TYPE.Ident;
  3965. var FUNCTION = TYPE.Function;
  3966. var COLON = TYPE.Colon;
  3967. var LEFTPARENTHESIS = TYPE.LeftParenthesis;
  3968. function consumeRaw() {
  3969. return this.createSingleNodeList(
  3970. this.Raw(this.scanner.tokenIndex, null, false)
  3971. );
  3972. }
  3973. function parentheses() {
  3974. this.scanner.skipSC();
  3975. if (this.scanner.tokenType === IDENT &&
  3976. this.lookupNonWSType(1) === COLON) {
  3977. return this.createSingleNodeList(
  3978. this.Declaration()
  3979. );
  3980. }
  3981. return readSequence.call(this);
  3982. }
  3983. function readSequence() {
  3984. var children = this.createList();
  3985. var space = null;
  3986. var child;
  3987. this.scanner.skipSC();
  3988. scan:
  3989. while (!this.scanner.eof) {
  3990. switch (this.scanner.tokenType) {
  3991. case WHITESPACE:
  3992. space = this.WhiteSpace();
  3993. continue;
  3994. case COMMENT:
  3995. this.scanner.next();
  3996. continue;
  3997. case FUNCTION:
  3998. child = this.Function(consumeRaw, this.scope.AtrulePrelude);
  3999. break;
  4000. case IDENT:
  4001. child = this.Identifier();
  4002. break;
  4003. case LEFTPARENTHESIS:
  4004. child = this.Parentheses(parentheses, this.scope.AtrulePrelude);
  4005. break;
  4006. default:
  4007. break scan;
  4008. }
  4009. if (space !== null) {
  4010. children.push(space);
  4011. space = null;
  4012. }
  4013. children.push(child);
  4014. }
  4015. return children;
  4016. }
  4017. module.exports = {
  4018. parse: {
  4019. prelude: function () {
  4020. var children = readSequence.call(this);
  4021. if (this.getFirstListNode(children) === null) {
  4022. this.error("Condition is expected");
  4023. }
  4024. return children;
  4025. },
  4026. block: function () {
  4027. return this.Block(false);
  4028. }
  4029. }
  4030. };
  4031. }, { "../../tokenizer": 107 }], 36: [function (require, module, exports) {
  4032. var data = require("../../../data");
  4033. module.exports = {
  4034. generic: true,
  4035. types: data.types,
  4036. properties: data.properties,
  4037. node: require("../node")
  4038. };
  4039. }, { "../../../data": 1, "../node": 85 }], 37: [function (require, module, exports) {
  4040. var hasOwnProperty = Object.prototype.hasOwnProperty;
  4041. var shape = {
  4042. generic: true,
  4043. types: {},
  4044. properties: {},
  4045. parseContext: {},
  4046. scope: {},
  4047. atrule: ["parse"],
  4048. pseudo: ["parse"],
  4049. node: ["name", "structure", "parse", "generate", "walkContext"]
  4050. };
  4051. function isObject(value) {
  4052. return value && value.constructor === Object;
  4053. }
  4054. function copy(value) {
  4055. if (isObject(value)) {
  4056. var res = {};
  4057. for (var key in value) {
  4058. if (hasOwnProperty.call(value, key)) {
  4059. res[key] = value[key];
  4060. }
  4061. }
  4062. return res;
  4063. } else {
  4064. return value;
  4065. }
  4066. }
  4067. function extend(dest, src) {
  4068. for (var key in src) {
  4069. if (hasOwnProperty.call(src, key)) {
  4070. if (isObject(dest[key])) {
  4071. extend(dest[key], copy(src[key]));
  4072. } else {
  4073. dest[key] = copy(src[key]);
  4074. }
  4075. }
  4076. }
  4077. }
  4078. function mix(dest, src, shape) {
  4079. for (var key in shape) {
  4080. if (hasOwnProperty.call(shape, key) === false) {
  4081. continue;
  4082. }
  4083. if (shape[key] === true) {
  4084. if (key in src) {
  4085. if (hasOwnProperty.call(src, key)) {
  4086. dest[key] = copy(src[key]);
  4087. }
  4088. }
  4089. } else if (shape[key]) {
  4090. if (isObject(shape[key])) {
  4091. var res = {};
  4092. extend(res, dest[key]);
  4093. extend(res, src[key]);
  4094. dest[key] = res;
  4095. } else if (Array.isArray(shape[key])) {
  4096. var res = {};
  4097. var innerShape = shape[key].reduce(function (s, k) {
  4098. s[k] = true;
  4099. return s;
  4100. }, {});
  4101. for (var name in dest[key]) {
  4102. if (hasOwnProperty.call(dest[key], name)) {
  4103. res[name] = {};
  4104. if (dest[key] && dest[key][name]) {
  4105. mix(res[name], dest[key][name], innerShape);
  4106. }
  4107. }
  4108. }
  4109. for (var name in src[key]) {
  4110. if (hasOwnProperty.call(src[key], name)) {
  4111. if (!res[name]) {
  4112. res[name] = {};
  4113. }
  4114. if (src[key] && src[key][name]) {
  4115. mix(res[name], src[key][name], innerShape);
  4116. }
  4117. }
  4118. }
  4119. dest[key] = res;
  4120. }
  4121. }
  4122. }
  4123. return dest;
  4124. }
  4125. module.exports = function (dest, src) {
  4126. return mix(dest, src, shape);
  4127. };
  4128. }, {}], 38: [function (require, module, exports) {
  4129. module.exports = {
  4130. parseContext: {
  4131. default: "StyleSheet",
  4132. stylesheet: "StyleSheet",
  4133. atrule: "Atrule",
  4134. atrulePrelude: function (options) {
  4135. return this.AtrulePrelude(options.atrule ? String(options.atrule) : null);
  4136. },
  4137. mediaQueryList: "MediaQueryList",
  4138. mediaQuery: "MediaQuery",
  4139. rule: "Rule",
  4140. selectorList: "SelectorList",
  4141. selector: "Selector",
  4142. block: function () {
  4143. return this.Block(true);
  4144. },
  4145. declarationList: "DeclarationList",
  4146. declaration: "Declaration",
  4147. value: "Value"
  4148. },
  4149. scope: require("../scope"),
  4150. atrule: require("../atrule"),
  4151. pseudo: require("../pseudo"),
  4152. node: require("../node")
  4153. };
  4154. }, { "../atrule": 32, "../node": 85, "../pseudo": 91, "../scope": 102 }], 39: [function (require, module, exports) {
  4155. module.exports = {
  4156. node: require("../node")
  4157. };
  4158. }, { "../node": 85 }], 40: [function (require, module, exports) {
  4159. var List = require("../common/List");
  4160. var SyntaxError = require("../common/SyntaxError");
  4161. var TokenStream = require("../common/TokenStream");
  4162. var Lexer = require("../lexer/Lexer");
  4163. var grammar = require("../lexer/grammar");
  4164. var tokenize = require("../tokenizer");
  4165. var createParser = require("../parser/create");
  4166. var createGenerator = require("../generator/create");
  4167. var createConvertor = require("../convertor/create");
  4168. var createWalker = require("../walker/create");
  4169. var clone = require("../utils/clone");
  4170. var names = require("../utils/names");
  4171. var mix = require("./config/mix");
  4172. function assign(dest, src) {
  4173. for (var key in src) {
  4174. dest[key] = src[key];
  4175. }
  4176. return dest;
  4177. }
  4178. function createSyntax(config) {
  4179. var parse = createParser(config);
  4180. var walk = createWalker(config);
  4181. var generate = createGenerator(config);
  4182. var convert = createConvertor(walk);
  4183. var syntax = {
  4184. List: List,
  4185. SyntaxError: SyntaxError,
  4186. TokenStream: TokenStream,
  4187. Lexer: Lexer,
  4188. vendorPrefix: names.vendorPrefix,
  4189. keyword: names.keyword,
  4190. property: names.property,
  4191. isCustomProperty: names.isCustomProperty,
  4192. grammar: grammar,
  4193. lexer: null,
  4194. createLexer: function (config) {
  4195. return new Lexer(config, syntax, syntax.lexer.structure);
  4196. },
  4197. tokenize: tokenize,
  4198. parse: parse,
  4199. walk: walk,
  4200. generate: generate,
  4201. clone: clone,
  4202. fromPlainObject: convert.fromPlainObject,
  4203. toPlainObject: convert.toPlainObject,
  4204. createSyntax: function (config) {
  4205. return createSyntax(mix({}, config));
  4206. },
  4207. fork: function (extension) {
  4208. var base = mix({}, config); // copy of config
  4209. return createSyntax(
  4210. typeof extension === "function"
  4211. ? extension(base, assign)
  4212. : mix(base, extension)
  4213. );
  4214. }
  4215. };
  4216. syntax.lexer = new Lexer({
  4217. generic: true,
  4218. types: config.types,
  4219. properties: config.properties,
  4220. node: config.node
  4221. }, syntax);
  4222. return syntax;
  4223. }
  4224. exports.create = function (config) {
  4225. return createSyntax(mix({}, config));
  4226. };
  4227. }, { "../common/List": 2, "../common/SyntaxError": 4, "../common/TokenStream": 5, "../convertor/create": 7, "../generator/create": 8, "../lexer/Lexer": 11, "../lexer/grammar": 18, "../parser/create": 28, "../tokenizer": 107, "../utils/clone": 109, "../utils/names": 111, "../walker/create": 112, "./config/mix": 37 }], 41: [function (require, module, exports) {
  4228. module.exports = function () {
  4229. this.scanner.skipSC();
  4230. var children = this.createSingleNodeList(
  4231. this.IdSelector()
  4232. );
  4233. this.scanner.skipSC();
  4234. return children;
  4235. };
  4236. }, {}], 42: [function (require, module, exports) {
  4237. module.exports = function () {
  4238. return this.createSingleNodeList(
  4239. this.Raw(this.scanner.tokenIndex, null, false)
  4240. );
  4241. };
  4242. }, {}], 43: [function (require, module, exports) {
  4243. var TYPE = require("../../tokenizer").TYPE;
  4244. var rawMode = require("../node/Raw").mode;
  4245. var COMMA = TYPE.Comma;
  4246. module.exports = function () {
  4247. var children = this.createList();
  4248. this.scanner.skipSC();
  4249. children.push(this.Identifier());
  4250. this.scanner.skipSC();
  4251. if (this.scanner.tokenType === COMMA) {
  4252. children.push(this.Operator());
  4253. children.push(this.parseCustomProperty
  4254. ? this.Value(null)
  4255. : this.Raw(this.scanner.tokenIndex, rawMode.exclamationMarkOrSemicolon, false)
  4256. );
  4257. }
  4258. return children;
  4259. };
  4260. }, { "../../tokenizer": 107, "../node/Raw": 74 }], 44: [function (require, module, exports) {
  4261. function merge() {
  4262. var dest = {};
  4263. for (var i = 0; i < arguments.length; i++) {
  4264. var src = arguments[i];
  4265. for (var key in src) {
  4266. dest[key] = src[key];
  4267. }
  4268. }
  4269. return dest;
  4270. }
  4271. module.exports = require("./create").create(
  4272. merge(
  4273. require("./config/lexer"),
  4274. require("./config/parser"),
  4275. require("./config/walker")
  4276. )
  4277. );
  4278. }, { "./config/lexer": 36, "./config/parser": 38, "./config/walker": 39, "./create": 40 }], 45: [function (require, module, exports) {
  4279. var cmpChar = require("../../tokenizer").cmpChar;
  4280. var isDigit = require("../../tokenizer").isDigit;
  4281. var TYPE = require("../../tokenizer").TYPE;
  4282. var WHITESPACE = TYPE.WhiteSpace;
  4283. var COMMENT = TYPE.Comment;
  4284. var IDENT = TYPE.Ident;
  4285. var NUMBER = TYPE.Number;
  4286. var DIMENSION = TYPE.Dimension;
  4287. var PLUSSIGN = 0x002B; // U+002B PLUS SIGN (+)
  4288. var HYPHENMINUS = 0x002D; // U+002D HYPHEN-MINUS (-)
  4289. var N = 0x006E; // U+006E LATIN SMALL LETTER N (n)
  4290. var DISALLOW_SIGN = true;
  4291. var ALLOW_SIGN = false;
  4292. function checkInteger(offset, disallowSign) {
  4293. var pos = this.scanner.tokenStart + offset;
  4294. var code = this.scanner.source.charCodeAt(pos);
  4295. if (code === PLUSSIGN || code === HYPHENMINUS) {
  4296. if (disallowSign) {
  4297. this.error("Number sign is not allowed");
  4298. }
  4299. pos++;
  4300. }
  4301. for (; pos < this.scanner.tokenEnd; pos++) {
  4302. if (!isDigit(this.scanner.source.charCodeAt(pos))) {
  4303. this.error("Integer is expected", pos);
  4304. }
  4305. }
  4306. }
  4307. function checkTokenIsInteger(disallowSign) {
  4308. return checkInteger.call(this, 0, disallowSign);
  4309. }
  4310. function expectCharCode(offset, code) {
  4311. if (!cmpChar(this.scanner.source, this.scanner.tokenStart + offset, code)) {
  4312. var msg = "";
  4313. switch (code) {
  4314. case N:
  4315. msg = "N is expected";
  4316. break;
  4317. case HYPHENMINUS:
  4318. msg = "HyphenMinus is expected";
  4319. break;
  4320. }
  4321. this.error(msg, this.scanner.tokenStart + offset);
  4322. }
  4323. }
  4324. function consumeB() {
  4325. var offset = 0;
  4326. var sign = 0;
  4327. var type = this.scanner.tokenType;
  4328. while (type === WHITESPACE || type === COMMENT) {
  4329. type = this.scanner.lookupType(++offset);
  4330. }
  4331. if (type !== NUMBER) {
  4332. if (this.scanner.isDelim(PLUSSIGN, offset) ||
  4333. this.scanner.isDelim(HYPHENMINUS, offset)) {
  4334. sign = this.scanner.isDelim(PLUSSIGN, offset) ? PLUSSIGN : HYPHENMINUS;
  4335. do {
  4336. type = this.scanner.lookupType(++offset);
  4337. } while (type === WHITESPACE || type === COMMENT);
  4338. if (type !== NUMBER) {
  4339. this.scanner.skip(offset);
  4340. checkTokenIsInteger.call(this, DISALLOW_SIGN);
  4341. }
  4342. } else {
  4343. return null;
  4344. }
  4345. }
  4346. if (offset > 0) {
  4347. this.scanner.skip(offset);
  4348. }
  4349. if (sign === 0) {
  4350. type = this.scanner.source.charCodeAt(this.scanner.tokenStart);
  4351. if (type !== PLUSSIGN && type !== HYPHENMINUS) {
  4352. this.error("Number sign is expected");
  4353. }
  4354. }
  4355. checkTokenIsInteger.call(this, sign !== 0);
  4356. return sign === HYPHENMINUS ? "-" + this.consume(NUMBER) : this.consume(NUMBER);
  4357. }
  4358. module.exports = {
  4359. name: "AnPlusB",
  4360. structure: {
  4361. a: [String, null],
  4362. b: [String, null]
  4363. },
  4364. parse: function () {
  4365. var start = this.scanner.tokenStart;
  4366. var a = null;
  4367. var b = null;
  4368. if (this.scanner.tokenType === NUMBER) {
  4369. checkTokenIsInteger.call(this, ALLOW_SIGN);
  4370. b = this.consume(NUMBER);
  4371. }
  4372. else if (this.scanner.tokenType === IDENT && cmpChar(this.scanner.source, this.scanner.tokenStart, HYPHENMINUS)) {
  4373. a = "-1";
  4374. expectCharCode.call(this, 1, N);
  4375. switch (this.scanner.getTokenLength()) {
  4376. case 2:
  4377. this.scanner.next();
  4378. b = consumeB.call(this);
  4379. break;
  4380. case 3:
  4381. expectCharCode.call(this, 2, HYPHENMINUS);
  4382. this.scanner.next();
  4383. this.scanner.skipSC();
  4384. checkTokenIsInteger.call(this, DISALLOW_SIGN);
  4385. b = "-" + this.consume(NUMBER);
  4386. break;
  4387. default:
  4388. expectCharCode.call(this, 2, HYPHENMINUS);
  4389. checkInteger.call(this, 3, DISALLOW_SIGN);
  4390. this.scanner.next();
  4391. b = this.scanner.substrToCursor(start + 2);
  4392. }
  4393. }
  4394. else if (this.scanner.tokenType === IDENT || (this.scanner.isDelim(PLUSSIGN) && this.scanner.lookupType(1) === IDENT)) {
  4395. var sign = 0;
  4396. a = "1";
  4397. if (this.scanner.isDelim(PLUSSIGN)) {
  4398. sign = 1;
  4399. this.scanner.next();
  4400. }
  4401. expectCharCode.call(this, 0, N);
  4402. switch (this.scanner.getTokenLength()) {
  4403. case 1:
  4404. this.scanner.next();
  4405. b = consumeB.call(this);
  4406. break;
  4407. case 2:
  4408. expectCharCode.call(this, 1, HYPHENMINUS);
  4409. this.scanner.next();
  4410. this.scanner.skipSC();
  4411. checkTokenIsInteger.call(this, DISALLOW_SIGN);
  4412. b = "-" + this.consume(NUMBER);
  4413. break;
  4414. default:
  4415. expectCharCode.call(this, 1, HYPHENMINUS);
  4416. checkInteger.call(this, 2, DISALLOW_SIGN);
  4417. this.scanner.next();
  4418. b = this.scanner.substrToCursor(start + sign + 1);
  4419. }
  4420. }
  4421. else if (this.scanner.tokenType === DIMENSION) {
  4422. var code = this.scanner.source.charCodeAt(this.scanner.tokenStart);
  4423. var sign = code === PLUSSIGN || code === HYPHENMINUS;
  4424. for (var i = this.scanner.tokenStart + sign; i < this.scanner.tokenEnd; i++) {
  4425. if (!isDigit(this.scanner.source.charCodeAt(i))) {
  4426. break;
  4427. }
  4428. }
  4429. if (i === this.scanner.tokenStart + sign) {
  4430. this.error("Integer is expected", this.scanner.tokenStart + sign);
  4431. }
  4432. expectCharCode.call(this, i - this.scanner.tokenStart, N);
  4433. a = this.scanner.source.substring(start, i);
  4434. if (i + 1 === this.scanner.tokenEnd) {
  4435. this.scanner.next();
  4436. b = consumeB.call(this);
  4437. } else {
  4438. expectCharCode.call(this, i - this.scanner.tokenStart + 1, HYPHENMINUS);
  4439. if (i + 2 === this.scanner.tokenEnd) {
  4440. this.scanner.next();
  4441. this.scanner.skipSC();
  4442. checkTokenIsInteger.call(this, DISALLOW_SIGN);
  4443. b = "-" + this.consume(NUMBER);
  4444. }
  4445. else {
  4446. checkInteger.call(this, i - this.scanner.tokenStart + 2, DISALLOW_SIGN);
  4447. this.scanner.next();
  4448. b = this.scanner.substrToCursor(i + 1);
  4449. }
  4450. }
  4451. } else {
  4452. this.error();
  4453. }
  4454. if (a !== null && a.charCodeAt(0) === PLUSSIGN) {
  4455. a = a.substr(1);
  4456. }
  4457. if (b !== null && b.charCodeAt(0) === PLUSSIGN) {
  4458. b = b.substr(1);
  4459. }
  4460. return {
  4461. type: "AnPlusB",
  4462. loc: this.getLocation(start, this.scanner.tokenStart),
  4463. a: a,
  4464. b: b
  4465. };
  4466. },
  4467. generate: function (node) {
  4468. var a = node.a !== null && node.a !== undefined;
  4469. var b = node.b !== null && node.b !== undefined;
  4470. if (a) {
  4471. this.chunk(
  4472. node.a === "+1" ? "+n" :
  4473. node.a === "1" ? "n" :
  4474. node.a === "-1" ? "-n" :
  4475. node.a + "n"
  4476. );
  4477. if (b) {
  4478. b = String(node.b);
  4479. if (b.charAt(0) === "-" || b.charAt(0) === "+") {
  4480. this.chunk(b.charAt(0));
  4481. this.chunk(b.substr(1));
  4482. } else {
  4483. this.chunk("+");
  4484. this.chunk(b);
  4485. }
  4486. }
  4487. } else {
  4488. this.chunk(String(node.b));
  4489. }
  4490. }
  4491. };
  4492. }, { "../../tokenizer": 107 }], 46: [function (require, module, exports) {
  4493. var TYPE = require("../../tokenizer").TYPE;
  4494. var rawMode = require("./Raw").mode;
  4495. var ATKEYWORD = TYPE.AtKeyword;
  4496. var SEMICOLON = TYPE.Semicolon;
  4497. var LEFTCURLYBRACKET = TYPE.LeftCurlyBracket;
  4498. var RIGHTCURLYBRACKET = TYPE.RightCurlyBracket;
  4499. function consumeRaw(startToken) {
  4500. return this.Raw(startToken, rawMode.leftCurlyBracketOrSemicolon, true);
  4501. }
  4502. function isDeclarationBlockAtrule() {
  4503. for (var offset = 1, type; type = this.scanner.lookupType(offset); offset++) {
  4504. if (type === RIGHTCURLYBRACKET) {
  4505. return true;
  4506. }
  4507. if (type === LEFTCURLYBRACKET ||
  4508. type === ATKEYWORD) {
  4509. return false;
  4510. }
  4511. }
  4512. return false;
  4513. }
  4514. module.exports = {
  4515. name: "Atrule",
  4516. structure: {
  4517. name: String,
  4518. prelude: ["AtrulePrelude", "Raw", null],
  4519. block: ["Block", null]
  4520. },
  4521. parse: function () {
  4522. var start = this.scanner.tokenStart;
  4523. var name;
  4524. var nameLowerCase;
  4525. var prelude = null;
  4526. var block = null;
  4527. this.eat(ATKEYWORD);
  4528. name = this.scanner.substrToCursor(start + 1);
  4529. nameLowerCase = name.toLowerCase();
  4530. this.scanner.skipSC();
  4531. if (this.scanner.eof === false &&
  4532. this.scanner.tokenType !== LEFTCURLYBRACKET &&
  4533. this.scanner.tokenType !== SEMICOLON) {
  4534. if (this.parseAtrulePrelude) {
  4535. prelude = this.parseWithFallback(this.AtrulePrelude.bind(this, name), consumeRaw);
  4536. if (prelude.type === "AtrulePrelude" && prelude.children.head === null) {
  4537. prelude = null;
  4538. }
  4539. } else {
  4540. prelude = consumeRaw.call(this, this.scanner.tokenIndex);
  4541. }
  4542. this.scanner.skipSC();
  4543. }
  4544. switch (this.scanner.tokenType) {
  4545. case SEMICOLON:
  4546. this.scanner.next();
  4547. break;
  4548. case LEFTCURLYBRACKET:
  4549. if (this.atrule.hasOwnProperty(nameLowerCase) &&
  4550. typeof this.atrule[nameLowerCase].block === "function") {
  4551. block = this.atrule[nameLowerCase].block.call(this);
  4552. } else {
  4553. block = this.Block(isDeclarationBlockAtrule.call(this));
  4554. }
  4555. break;
  4556. }
  4557. return {
  4558. type: "Atrule",
  4559. loc: this.getLocation(start, this.scanner.tokenStart),
  4560. name: name,
  4561. prelude: prelude,
  4562. block: block
  4563. };
  4564. },
  4565. generate: function (node) {
  4566. this.chunk("@");
  4567. this.chunk(node.name);
  4568. if (node.prelude !== null) {
  4569. this.chunk(" ");
  4570. this.node(node.prelude);
  4571. }
  4572. if (node.block) {
  4573. this.node(node.block);
  4574. } else {
  4575. this.chunk(";");
  4576. }
  4577. },
  4578. walkContext: "atrule"
  4579. };
  4580. }, { "../../tokenizer": 107, "./Raw": 74 }], 47: [function (require, module, exports) {
  4581. var TYPE = require("../../tokenizer").TYPE;
  4582. var SEMICOLON = TYPE.Semicolon;
  4583. var LEFTCURLYBRACKET = TYPE.LeftCurlyBracket;
  4584. module.exports = {
  4585. name: "AtrulePrelude",
  4586. structure: {
  4587. children: [[]]
  4588. },
  4589. parse: function (name) {
  4590. var children = null;
  4591. if (name !== null) {
  4592. name = name.toLowerCase();
  4593. }
  4594. this.scanner.skipSC();
  4595. if (this.atrule.hasOwnProperty(name) &&
  4596. typeof this.atrule[name].prelude === "function") {
  4597. children = this.atrule[name].prelude.call(this);
  4598. } else {
  4599. children = this.readSequence(this.scope.AtrulePrelude);
  4600. }
  4601. this.scanner.skipSC();
  4602. if (this.scanner.eof !== true &&
  4603. this.scanner.tokenType !== LEFTCURLYBRACKET &&
  4604. this.scanner.tokenType !== SEMICOLON) {
  4605. this.error("Semicolon or block is expected");
  4606. }
  4607. if (children === null) {
  4608. children = this.createList();
  4609. }
  4610. return {
  4611. type: "AtrulePrelude",
  4612. loc: this.getLocationFromList(children),
  4613. children: children
  4614. };
  4615. },
  4616. generate: function (node) {
  4617. this.children(node);
  4618. },
  4619. walkContext: "atrulePrelude"
  4620. };
  4621. }, { "../../tokenizer": 107 }], 48: [function (require, module, exports) {
  4622. var TYPE = require("../../tokenizer").TYPE;
  4623. var IDENT = TYPE.Ident;
  4624. var STRING = TYPE.String;
  4625. var COLON = TYPE.Colon;
  4626. var LEFTSQUAREBRACKET = TYPE.LeftSquareBracket;
  4627. var RIGHTSQUAREBRACKET = TYPE.RightSquareBracket;
  4628. var DOLLARSIGN = 0x0024; // U+0024 DOLLAR SIGN ($)
  4629. var ASTERISK = 0x002A; // U+002A ASTERISK (*)
  4630. var EQUALSSIGN = 0x003D; // U+003D EQUALS SIGN (=)
  4631. var CIRCUMFLEXACCENT = 0x005E; // U+005E (^)
  4632. var VERTICALLINE = 0x007C; // U+007C VERTICAL LINE (|)
  4633. var TILDE = 0x007E; // U+007E TILDE (~)
  4634. function getAttributeName() {
  4635. if (this.scanner.eof) {
  4636. this.error("Unexpected end of input");
  4637. }
  4638. var start = this.scanner.tokenStart;
  4639. var expectIdent = false;
  4640. var checkColon = true;
  4641. if (this.scanner.isDelim(ASTERISK)) {
  4642. expectIdent = true;
  4643. checkColon = false;
  4644. this.scanner.next();
  4645. } else if (!this.scanner.isDelim(VERTICALLINE)) {
  4646. this.eat(IDENT);
  4647. }
  4648. if (this.scanner.isDelim(VERTICALLINE)) {
  4649. if (this.scanner.source.charCodeAt(this.scanner.tokenStart + 1) !== EQUALSSIGN) {
  4650. this.scanner.next();
  4651. this.eat(IDENT);
  4652. } else if (expectIdent) {
  4653. this.error("Identifier is expected", this.scanner.tokenEnd);
  4654. }
  4655. } else if (expectIdent) {
  4656. this.error("Vertical line is expected");
  4657. }
  4658. if (checkColon && this.scanner.tokenType === COLON) {
  4659. this.scanner.next();
  4660. this.eat(IDENT);
  4661. }
  4662. return {
  4663. type: "Identifier",
  4664. loc: this.getLocation(start, this.scanner.tokenStart),
  4665. name: this.scanner.substrToCursor(start)
  4666. };
  4667. }
  4668. function getOperator() {
  4669. var start = this.scanner.tokenStart;
  4670. var code = this.scanner.source.charCodeAt(start);
  4671. if (code !== EQUALSSIGN && // =
  4672. code !== TILDE && // ~=
  4673. code !== CIRCUMFLEXACCENT && // ^=
  4674. code !== DOLLARSIGN && // $=
  4675. code !== ASTERISK && // *=
  4676. code !== VERTICALLINE // |=
  4677. ) {
  4678. this.error("Attribute selector (=, ~=, ^=, $=, *=, |=) is expected");
  4679. }
  4680. this.scanner.next();
  4681. if (code !== EQUALSSIGN) {
  4682. if (!this.scanner.isDelim(EQUALSSIGN)) {
  4683. this.error("Equal sign is expected");
  4684. }
  4685. this.scanner.next();
  4686. }
  4687. return this.scanner.substrToCursor(start);
  4688. }
  4689. module.exports = {
  4690. name: "AttributeSelector",
  4691. structure: {
  4692. name: "Identifier",
  4693. matcher: [String, null],
  4694. value: ["String", "Identifier", null],
  4695. flags: [String, null]
  4696. },
  4697. parse: function () {
  4698. var start = this.scanner.tokenStart;
  4699. var name;
  4700. var matcher = null;
  4701. var value = null;
  4702. var flags = null;
  4703. this.eat(LEFTSQUAREBRACKET);
  4704. this.scanner.skipSC();
  4705. name = getAttributeName.call(this);
  4706. this.scanner.skipSC();
  4707. if (this.scanner.tokenType !== RIGHTSQUAREBRACKET) {
  4708. if (this.scanner.tokenType !== IDENT) {
  4709. matcher = getOperator.call(this);
  4710. this.scanner.skipSC();
  4711. value = this.scanner.tokenType === STRING
  4712. ? this.String()
  4713. : this.Identifier();
  4714. this.scanner.skipSC();
  4715. }
  4716. if (this.scanner.tokenType === IDENT) {
  4717. flags = this.scanner.getTokenValue();
  4718. this.scanner.next();
  4719. this.scanner.skipSC();
  4720. }
  4721. }
  4722. this.eat(RIGHTSQUAREBRACKET);
  4723. return {
  4724. type: "AttributeSelector",
  4725. loc: this.getLocation(start, this.scanner.tokenStart),
  4726. name: name,
  4727. matcher: matcher,
  4728. value: value,
  4729. flags: flags
  4730. };
  4731. },
  4732. generate: function (node) {
  4733. var flagsPrefix = " ";
  4734. this.chunk("[");
  4735. this.node(node.name);
  4736. if (node.matcher !== null) {
  4737. this.chunk(node.matcher);
  4738. if (node.value !== null) {
  4739. this.node(node.value);
  4740. if (node.value.type === "String") {
  4741. flagsPrefix = "";
  4742. }
  4743. }
  4744. }
  4745. if (node.flags !== null) {
  4746. this.chunk(flagsPrefix);
  4747. this.chunk(node.flags);
  4748. }
  4749. this.chunk("]");
  4750. }
  4751. };
  4752. }, { "../../tokenizer": 107 }], 49: [function (require, module, exports) {
  4753. var TYPE = require("../../tokenizer").TYPE;
  4754. var rawMode = require("./Raw").mode;
  4755. var WHITESPACE = TYPE.WhiteSpace;
  4756. var COMMENT = TYPE.Comment;
  4757. var SEMICOLON = TYPE.Semicolon;
  4758. var ATKEYWORD = TYPE.AtKeyword;
  4759. var LEFTCURLYBRACKET = TYPE.LeftCurlyBracket;
  4760. var RIGHTCURLYBRACKET = TYPE.RightCurlyBracket;
  4761. function consumeRaw(startToken) {
  4762. return this.Raw(startToken, null, true);
  4763. }
  4764. function consumeRule() {
  4765. return this.parseWithFallback(this.Rule, consumeRaw);
  4766. }
  4767. function consumeRawDeclaration(startToken) {
  4768. return this.Raw(startToken, rawMode.semicolonIncluded, true);
  4769. }
  4770. function consumeDeclaration() {
  4771. if (this.scanner.tokenType === SEMICOLON) {
  4772. return consumeRawDeclaration.call(this, this.scanner.tokenIndex);
  4773. }
  4774. var node = this.parseWithFallback(this.Declaration, consumeRawDeclaration);
  4775. if (this.scanner.tokenType === SEMICOLON) {
  4776. this.scanner.next();
  4777. }
  4778. return node;
  4779. }
  4780. module.exports = {
  4781. name: "Block",
  4782. structure: {
  4783. children: [[
  4784. "Atrule",
  4785. "Rule",
  4786. "Declaration"
  4787. ]]
  4788. },
  4789. parse: function (isDeclaration) {
  4790. var consumer = isDeclaration ? consumeDeclaration : consumeRule;
  4791. var start = this.scanner.tokenStart;
  4792. var children = this.createList();
  4793. this.eat(LEFTCURLYBRACKET);
  4794. scan:
  4795. while (!this.scanner.eof) {
  4796. switch (this.scanner.tokenType) {
  4797. case RIGHTCURLYBRACKET:
  4798. break scan;
  4799. case WHITESPACE:
  4800. case COMMENT:
  4801. this.scanner.next();
  4802. break;
  4803. case ATKEYWORD:
  4804. children.push(this.parseWithFallback(this.Atrule, consumeRaw));
  4805. break;
  4806. default:
  4807. children.push(consumer.call(this));
  4808. }
  4809. }
  4810. if (!this.scanner.eof) {
  4811. this.eat(RIGHTCURLYBRACKET);
  4812. }
  4813. return {
  4814. type: "Block",
  4815. loc: this.getLocation(start, this.scanner.tokenStart),
  4816. children: children
  4817. };
  4818. },
  4819. generate: function (node) {
  4820. this.chunk("{");
  4821. this.children(node, function (prev) {
  4822. if (prev.type === "Declaration") {
  4823. this.chunk(";");
  4824. }
  4825. });
  4826. this.chunk("}");
  4827. },
  4828. walkContext: "block"
  4829. };
  4830. }, { "../../tokenizer": 107, "./Raw": 74 }], 50: [function (require, module, exports) {
  4831. var TYPE = require("../../tokenizer").TYPE;
  4832. var LEFTSQUAREBRACKET = TYPE.LeftSquareBracket;
  4833. var RIGHTSQUAREBRACKET = TYPE.RightSquareBracket;
  4834. module.exports = {
  4835. name: "Brackets",
  4836. structure: {
  4837. children: [[]]
  4838. },
  4839. parse: function (readSequence, recognizer) {
  4840. var start = this.scanner.tokenStart;
  4841. var children = null;
  4842. this.eat(LEFTSQUAREBRACKET);
  4843. children = readSequence.call(this, recognizer);
  4844. if (!this.scanner.eof) {
  4845. this.eat(RIGHTSQUAREBRACKET);
  4846. }
  4847. return {
  4848. type: "Brackets",
  4849. loc: this.getLocation(start, this.scanner.tokenStart),
  4850. children: children
  4851. };
  4852. },
  4853. generate: function (node) {
  4854. this.chunk("[");
  4855. this.children(node);
  4856. this.chunk("]");
  4857. }
  4858. };
  4859. }, { "../../tokenizer": 107 }], 51: [function (require, module, exports) {
  4860. var CDC = require("../../tokenizer").TYPE.CDC;
  4861. module.exports = {
  4862. name: "CDC",
  4863. structure: [],
  4864. parse: function () {
  4865. var start = this.scanner.tokenStart;
  4866. this.eat(CDC); // -->
  4867. return {
  4868. type: "CDC",
  4869. loc: this.getLocation(start, this.scanner.tokenStart)
  4870. };
  4871. },
  4872. generate: function () {
  4873. this.chunk("-->");
  4874. }
  4875. };
  4876. }, { "../../tokenizer": 107 }], 52: [function (require, module, exports) {
  4877. var CDO = require("../../tokenizer").TYPE.CDO;
  4878. module.exports = {
  4879. name: "CDO",
  4880. structure: [],
  4881. parse: function () {
  4882. var start = this.scanner.tokenStart;
  4883. this.eat(CDO); // <!--
  4884. return {
  4885. type: "CDO",
  4886. loc: this.getLocation(start, this.scanner.tokenStart)
  4887. };
  4888. },
  4889. generate: function () {
  4890. this.chunk("<!--");
  4891. }
  4892. };
  4893. }, { "../../tokenizer": 107 }], 53: [function (require, module, exports) {
  4894. var TYPE = require("../../tokenizer").TYPE;
  4895. var IDENT = TYPE.Ident;
  4896. var FULLSTOP = 0x002E; // U+002E FULL STOP (.)
  4897. module.exports = {
  4898. name: "ClassSelector",
  4899. structure: {
  4900. name: String
  4901. },
  4902. parse: function () {
  4903. if (!this.scanner.isDelim(FULLSTOP)) {
  4904. this.error("Full stop is expected");
  4905. }
  4906. this.scanner.next();
  4907. return {
  4908. type: "ClassSelector",
  4909. loc: this.getLocation(this.scanner.tokenStart - 1, this.scanner.tokenEnd),
  4910. name: this.consume(IDENT)
  4911. };
  4912. },
  4913. generate: function (node) {
  4914. this.chunk(".");
  4915. this.chunk(node.name);
  4916. }
  4917. };
  4918. }, { "../../tokenizer": 107 }], 54: [function (require, module, exports) {
  4919. var TYPE = require("../../tokenizer").TYPE;
  4920. var IDENT = TYPE.Ident;
  4921. var PLUSSIGN = 0x002B; // U+002B PLUS SIGN (+)
  4922. var SOLIDUS = 0x002F; // U+002F SOLIDUS (/)
  4923. var GREATERTHANSIGN = 0x003E; // U+003E GREATER-THAN SIGN (>)
  4924. var TILDE = 0x007E; // U+007E TILDE (~)
  4925. module.exports = {
  4926. name: "Combinator",
  4927. structure: {
  4928. name: String
  4929. },
  4930. parse: function () {
  4931. var start = this.scanner.tokenStart;
  4932. var code = this.scanner.source.charCodeAt(this.scanner.tokenStart);
  4933. switch (code) {
  4934. case GREATERTHANSIGN:
  4935. case PLUSSIGN:
  4936. case TILDE:
  4937. this.scanner.next();
  4938. break;
  4939. case SOLIDUS:
  4940. this.scanner.next();
  4941. if (this.scanner.tokenType !== IDENT || this.scanner.lookupValue(0, "deep") === false) {
  4942. this.error("Identifier `deep` is expected");
  4943. }
  4944. this.scanner.next();
  4945. if (!this.scanner.isDelim(SOLIDUS)) {
  4946. this.error("Solidus is expected");
  4947. }
  4948. this.scanner.next();
  4949. break;
  4950. default:
  4951. this.error("Combinator is expected");
  4952. }
  4953. return {
  4954. type: "Combinator",
  4955. loc: this.getLocation(start, this.scanner.tokenStart),
  4956. name: this.scanner.substrToCursor(start)
  4957. };
  4958. },
  4959. generate: function (node) {
  4960. this.chunk(node.name);
  4961. }
  4962. };
  4963. }, { "../../tokenizer": 107 }], 55: [function (require, module, exports) {
  4964. var TYPE = require("../../tokenizer").TYPE;
  4965. var COMMENT = TYPE.Comment;
  4966. var ASTERISK = 0x002A; // U+002A ASTERISK (*)
  4967. var SOLIDUS = 0x002F; // U+002F SOLIDUS (/)
  4968. module.exports = {
  4969. name: "Comment",
  4970. structure: {
  4971. value: String
  4972. },
  4973. parse: function () {
  4974. var start = this.scanner.tokenStart;
  4975. var end = this.scanner.tokenEnd;
  4976. this.eat(COMMENT);
  4977. if ((end - start + 2) >= 2 &&
  4978. this.scanner.source.charCodeAt(end - 2) === ASTERISK &&
  4979. this.scanner.source.charCodeAt(end - 1) === SOLIDUS) {
  4980. end -= 2;
  4981. }
  4982. return {
  4983. type: "Comment",
  4984. loc: this.getLocation(start, this.scanner.tokenStart),
  4985. value: this.scanner.source.substring(start + 2, end)
  4986. };
  4987. },
  4988. generate: function (node) {
  4989. this.chunk("");
  4990. }
  4991. };
  4992. }, { "../../tokenizer": 107 }], 56: [function (require, module, exports) {
  4993. var isCustomProperty = require("../../utils/names").isCustomProperty;
  4994. var TYPE = require("../../tokenizer").TYPE;
  4995. var rawMode = require("./Raw").mode;
  4996. var IDENT = TYPE.Ident;
  4997. var HASH = TYPE.Hash;
  4998. var COLON = TYPE.Colon;
  4999. var SEMICOLON = TYPE.Semicolon;
  5000. var DELIM = TYPE.Delim;
  5001. var EXCLAMATIONMARK = 0x0021; // U+0021 EXCLAMATION MARK (!)
  5002. var NUMBERSIGN = 0x0023; // U+0023 NUMBER SIGN (#)
  5003. var DOLLARSIGN = 0x0024; // U+0024 DOLLAR SIGN ($)
  5004. var AMPERSAND = 0x0026; // U+0026 ANPERSAND (&)
  5005. var ASTERISK = 0x002A; // U+002A ASTERISK (*)
  5006. var PLUSSIGN = 0x002B; // U+002B PLUS SIGN (+)
  5007. var SOLIDUS = 0x002F; // U+002F SOLIDUS (/)
  5008. function consumeValueRaw(startToken) {
  5009. return this.Raw(startToken, rawMode.exclamationMarkOrSemicolon, true);
  5010. }
  5011. function consumeCustomPropertyRaw(startToken) {
  5012. return this.Raw(startToken, rawMode.exclamationMarkOrSemicolon, false);
  5013. }
  5014. function consumeValue() {
  5015. var startValueToken = this.scanner.tokenIndex;
  5016. var value = this.Value();
  5017. if (value.type !== "Raw" &&
  5018. this.scanner.eof === false &&
  5019. this.scanner.tokenType !== SEMICOLON &&
  5020. this.scanner.isDelim(EXCLAMATIONMARK) === false &&
  5021. this.scanner.isBalanceEdge(startValueToken) === false) {
  5022. this.error();
  5023. }
  5024. return value;
  5025. }
  5026. module.exports = {
  5027. name: "Declaration",
  5028. structure: {
  5029. important: [Boolean, String],
  5030. property: String,
  5031. value: ["Value", "Raw"]
  5032. },
  5033. parse: function () {
  5034. var start = this.scanner.tokenStart;
  5035. var startToken = this.scanner.tokenIndex;
  5036. var property = readProperty.call(this);
  5037. var customProperty = isCustomProperty(property);
  5038. var parseValue = customProperty ? this.parseCustomProperty : this.parseValue;
  5039. var consumeRaw = customProperty ? consumeCustomPropertyRaw : consumeValueRaw;
  5040. var important = false;
  5041. var value;
  5042. this.scanner.skipSC();
  5043. this.eat(COLON);
  5044. if (!customProperty) {
  5045. this.scanner.skipSC();
  5046. }
  5047. if (parseValue) {
  5048. value = this.parseWithFallback(consumeValue, consumeRaw);
  5049. } else {
  5050. value = consumeRaw.call(this, this.scanner.tokenIndex);
  5051. }
  5052. if (this.scanner.isDelim(EXCLAMATIONMARK)) {
  5053. important = getImportant.call(this);
  5054. this.scanner.skipSC();
  5055. }
  5056. if (this.scanner.eof === false &&
  5057. this.scanner.tokenType !== SEMICOLON &&
  5058. this.scanner.isBalanceEdge(startToken) === false) {
  5059. this.error();
  5060. }
  5061. return {
  5062. type: "Declaration",
  5063. loc: this.getLocation(start, this.scanner.tokenStart),
  5064. important: important,
  5065. property: property,
  5066. value: value
  5067. };
  5068. },
  5069. generate: function (node) {
  5070. this.chunk(node.property);
  5071. this.chunk(":");
  5072. this.node(node.value);
  5073. if (node.important) {
  5074. this.chunk(node.important === true ? "!important" : "!" + node.important);
  5075. }
  5076. },
  5077. walkContext: "declaration"
  5078. };
  5079. function readProperty() {
  5080. var start = this.scanner.tokenStart;
  5081. var prefix = 0;
  5082. if (this.scanner.tokenType === DELIM) {
  5083. switch (this.scanner.source.charCodeAt(this.scanner.tokenStart)) {
  5084. case ASTERISK:
  5085. case DOLLARSIGN:
  5086. case PLUSSIGN:
  5087. case NUMBERSIGN:
  5088. case AMPERSAND:
  5089. this.scanner.next();
  5090. break;
  5091. case SOLIDUS:
  5092. this.scanner.next();
  5093. if (this.scanner.isDelim(SOLIDUS)) {
  5094. this.scanner.next();
  5095. }
  5096. break;
  5097. }
  5098. }
  5099. if (prefix) {
  5100. this.scanner.skip(prefix);
  5101. }
  5102. if (this.scanner.tokenType === HASH) {
  5103. this.eat(HASH);
  5104. } else {
  5105. this.eat(IDENT);
  5106. }
  5107. return this.scanner.substrToCursor(start);
  5108. }
  5109. function getImportant() {
  5110. this.eat(DELIM);
  5111. this.scanner.skipSC();
  5112. var important = this.consume(IDENT);
  5113. return important === "important" ? true : important;
  5114. }
  5115. }, { "../../tokenizer": 107, "../../utils/names": 111, "./Raw": 74 }], 57: [function (require, module, exports) {
  5116. var TYPE = require("../../tokenizer").TYPE;
  5117. var rawMode = require("./Raw").mode;
  5118. var WHITESPACE = TYPE.WhiteSpace;
  5119. var COMMENT = TYPE.Comment;
  5120. var SEMICOLON = TYPE.Semicolon;
  5121. function consumeRaw(startToken) {
  5122. return this.Raw(startToken, rawMode.semicolonIncluded, true);
  5123. }
  5124. module.exports = {
  5125. name: "DeclarationList",
  5126. structure: {
  5127. children: [[
  5128. "Declaration"
  5129. ]]
  5130. },
  5131. parse: function () {
  5132. var children = this.createList();
  5133. while (!this.scanner.eof) {
  5134. switch (this.scanner.tokenType) {
  5135. case WHITESPACE:
  5136. case COMMENT:
  5137. case SEMICOLON:
  5138. this.scanner.next();
  5139. break;
  5140. default:
  5141. children.push(this.parseWithFallback(this.Declaration, consumeRaw));
  5142. }
  5143. }
  5144. return {
  5145. type: "DeclarationList",
  5146. loc: this.getLocationFromList(children),
  5147. children: children
  5148. };
  5149. },
  5150. generate: function (node) {
  5151. this.children(node, function (prev) {
  5152. if (prev.type === "Declaration") {
  5153. this.chunk(";");
  5154. }
  5155. });
  5156. }
  5157. };
  5158. }, { "../../tokenizer": 107, "./Raw": 74 }], 58: [function (require, module, exports) {
  5159. var consumeNumber = require("../../tokenizer/utils").consumeNumber;
  5160. var TYPE = require("../../tokenizer").TYPE;
  5161. var DIMENSION = TYPE.Dimension;
  5162. module.exports = {
  5163. name: "Dimension",
  5164. structure: {
  5165. value: String,
  5166. unit: String
  5167. },
  5168. parse: function () {
  5169. var start = this.scanner.tokenStart;
  5170. var numberEnd = consumeNumber(this.scanner.source, start);
  5171. this.eat(DIMENSION);
  5172. return {
  5173. type: "Dimension",
  5174. loc: this.getLocation(start, this.scanner.tokenStart),
  5175. value: this.scanner.source.substring(start, numberEnd),
  5176. unit: this.scanner.source.substring(numberEnd, this.scanner.tokenStart)
  5177. };
  5178. },
  5179. generate: function (node) {
  5180. this.chunk(node.value);
  5181. this.chunk(node.unit);
  5182. }
  5183. };
  5184. }, { "../../tokenizer": 107, "../../tokenizer/utils": 108 }], 59: [function (require, module, exports) {
  5185. var TYPE = require("../../tokenizer").TYPE;
  5186. var RIGHTPARENTHESIS = TYPE.RightParenthesis;
  5187. module.exports = {
  5188. name: "Function",
  5189. structure: {
  5190. name: String,
  5191. children: [[]]
  5192. },
  5193. parse: function (readSequence, recognizer) {
  5194. var start = this.scanner.tokenStart;
  5195. var name = this.consumeFunctionName();
  5196. var nameLowerCase = name.toLowerCase();
  5197. var children;
  5198. children = recognizer.hasOwnProperty(nameLowerCase)
  5199. ? recognizer[nameLowerCase].call(this, recognizer)
  5200. : readSequence.call(this, recognizer);
  5201. if (!this.scanner.eof) {
  5202. this.eat(RIGHTPARENTHESIS);
  5203. }
  5204. return {
  5205. type: "Function",
  5206. loc: this.getLocation(start, this.scanner.tokenStart),
  5207. name: name,
  5208. children: children
  5209. };
  5210. },
  5211. generate: function (node) {
  5212. this.chunk(node.name);
  5213. this.chunk("(");
  5214. this.children(node);
  5215. this.chunk(")");
  5216. },
  5217. walkContext: "function"
  5218. };
  5219. }, { "../../tokenizer": 107 }], 60: [function (require, module, exports) {
  5220. var TYPE = require("../../tokenizer").TYPE;
  5221. var HASH = TYPE.Hash;
  5222. module.exports = {
  5223. name: "HexColor",
  5224. structure: {
  5225. value: String
  5226. },
  5227. parse: function () {
  5228. var start = this.scanner.tokenStart;
  5229. this.eat(HASH);
  5230. return {
  5231. type: "HexColor",
  5232. loc: this.getLocation(start, this.scanner.tokenStart),
  5233. value: this.scanner.substrToCursor(start + 1)
  5234. };
  5235. },
  5236. generate: function (node) {
  5237. this.chunk("#");
  5238. this.chunk(node.value);
  5239. }
  5240. };
  5241. }, { "../../tokenizer": 107 }], 61: [function (require, module, exports) {
  5242. var TYPE = require("../../tokenizer").TYPE;
  5243. var HASH = TYPE.Hash;
  5244. module.exports = {
  5245. name: "IdSelector",
  5246. structure: {
  5247. name: String
  5248. },
  5249. parse: function () {
  5250. var start = this.scanner.tokenStart;
  5251. this.eat(HASH);
  5252. return {
  5253. type: "IdSelector",
  5254. loc: this.getLocation(start, this.scanner.tokenStart),
  5255. name: this.scanner.substrToCursor(start + 1)
  5256. };
  5257. },
  5258. generate: function (node) {
  5259. this.chunk("#");
  5260. this.chunk(node.name);
  5261. }
  5262. };
  5263. }, { "../../tokenizer": 107 }], 62: [function (require, module, exports) {
  5264. var TYPE = require("../../tokenizer").TYPE;
  5265. var IDENT = TYPE.Ident;
  5266. module.exports = {
  5267. name: "Identifier",
  5268. structure: {
  5269. name: String
  5270. },
  5271. parse: function () {
  5272. return {
  5273. type: "Identifier",
  5274. loc: this.getLocation(this.scanner.tokenStart, this.scanner.tokenEnd),
  5275. name: this.consume(IDENT)
  5276. };
  5277. },
  5278. generate: function (node) {
  5279. this.chunk(node.name);
  5280. }
  5281. };
  5282. }, { "../../tokenizer": 107 }], 63: [function (require, module, exports) {
  5283. var TYPE = require("../../tokenizer").TYPE;
  5284. var IDENT = TYPE.Ident;
  5285. var NUMBER = TYPE.Number;
  5286. var DIMENSION = TYPE.Dimension;
  5287. var LEFTPARENTHESIS = TYPE.LeftParenthesis;
  5288. var RIGHTPARENTHESIS = TYPE.RightParenthesis;
  5289. var COLON = TYPE.Colon;
  5290. var DELIM = TYPE.Delim;
  5291. module.exports = {
  5292. name: "MediaFeature",
  5293. structure: {
  5294. name: String,
  5295. value: ["Identifier", "Number", "Dimension", "Ratio", null]
  5296. },
  5297. parse: function () {
  5298. var start = this.scanner.tokenStart;
  5299. var name;
  5300. var value = null;
  5301. this.eat(LEFTPARENTHESIS);
  5302. this.scanner.skipSC();
  5303. name = this.consume(IDENT);
  5304. this.scanner.skipSC();
  5305. if (this.scanner.tokenType !== RIGHTPARENTHESIS) {
  5306. this.eat(COLON);
  5307. this.scanner.skipSC();
  5308. switch (this.scanner.tokenType) {
  5309. case NUMBER:
  5310. if (this.lookupNonWSType(1) === DELIM) {
  5311. value = this.Ratio();
  5312. } else {
  5313. value = this.Number();
  5314. }
  5315. break;
  5316. case DIMENSION:
  5317. value = this.Dimension();
  5318. break;
  5319. case IDENT:
  5320. value = this.Identifier();
  5321. break;
  5322. default:
  5323. this.error("Number, dimension, ratio or identifier is expected");
  5324. }
  5325. this.scanner.skipSC();
  5326. }
  5327. this.eat(RIGHTPARENTHESIS);
  5328. return {
  5329. type: "MediaFeature",
  5330. loc: this.getLocation(start, this.scanner.tokenStart),
  5331. name: name,
  5332. value: value
  5333. };
  5334. },
  5335. generate: function (node) {
  5336. this.chunk("(");
  5337. this.chunk(node.name);
  5338. if (node.value !== null) {
  5339. this.chunk(":");
  5340. this.node(node.value);
  5341. }
  5342. this.chunk(")");
  5343. }
  5344. };
  5345. }, { "../../tokenizer": 107 }], 64: [function (require, module, exports) {
  5346. var TYPE = require("../../tokenizer").TYPE;
  5347. var WHITESPACE = TYPE.WhiteSpace;
  5348. var COMMENT = TYPE.Comment;
  5349. var IDENT = TYPE.Ident;
  5350. var LEFTPARENTHESIS = TYPE.LeftParenthesis;
  5351. module.exports = {
  5352. name: "MediaQuery",
  5353. structure: {
  5354. children: [[
  5355. "Identifier",
  5356. "MediaFeature",
  5357. "WhiteSpace"
  5358. ]]
  5359. },
  5360. parse: function () {
  5361. this.scanner.skipSC();
  5362. var children = this.createList();
  5363. var child = null;
  5364. var space = null;
  5365. scan:
  5366. while (!this.scanner.eof) {
  5367. switch (this.scanner.tokenType) {
  5368. case COMMENT:
  5369. this.scanner.next();
  5370. continue;
  5371. case WHITESPACE:
  5372. space = this.WhiteSpace();
  5373. continue;
  5374. case IDENT:
  5375. child = this.Identifier();
  5376. break;
  5377. case LEFTPARENTHESIS:
  5378. child = this.MediaFeature();
  5379. break;
  5380. default:
  5381. break scan;
  5382. }
  5383. if (space !== null) {
  5384. children.push(space);
  5385. space = null;
  5386. }
  5387. children.push(child);
  5388. }
  5389. if (child === null) {
  5390. this.error("Identifier or parenthesis is expected");
  5391. }
  5392. return {
  5393. type: "MediaQuery",
  5394. loc: this.getLocationFromList(children),
  5395. children: children
  5396. };
  5397. },
  5398. generate: function (node) {
  5399. this.children(node);
  5400. }
  5401. };
  5402. }, { "../../tokenizer": 107 }], 65: [function (require, module, exports) {
  5403. var COMMA = require("../../tokenizer").TYPE.Comma;
  5404. module.exports = {
  5405. name: "MediaQueryList",
  5406. structure: {
  5407. children: [[
  5408. "MediaQuery"
  5409. ]]
  5410. },
  5411. parse: function (relative) {
  5412. var children = this.createList();
  5413. this.scanner.skipSC();
  5414. while (!this.scanner.eof) {
  5415. children.push(this.MediaQuery(relative));
  5416. if (this.scanner.tokenType !== COMMA) {
  5417. break;
  5418. }
  5419. this.scanner.next();
  5420. }
  5421. return {
  5422. type: "MediaQueryList",
  5423. loc: this.getLocationFromList(children),
  5424. children: children
  5425. };
  5426. },
  5427. generate: function (node) {
  5428. this.children(node, function () {
  5429. this.chunk(",");
  5430. });
  5431. }
  5432. };
  5433. }, { "../../tokenizer": 107 }], 66: [function (require, module, exports) {
  5434. module.exports = {
  5435. name: "Nth",
  5436. structure: {
  5437. nth: ["AnPlusB", "Identifier"],
  5438. selector: ["SelectorList", null]
  5439. },
  5440. parse: function (allowOfClause) {
  5441. this.scanner.skipSC();
  5442. var start = this.scanner.tokenStart;
  5443. var end = start;
  5444. var selector = null;
  5445. var query;
  5446. if (this.scanner.lookupValue(0, "odd") || this.scanner.lookupValue(0, "even")) {
  5447. query = this.Identifier();
  5448. } else {
  5449. query = this.AnPlusB();
  5450. }
  5451. this.scanner.skipSC();
  5452. if (allowOfClause && this.scanner.lookupValue(0, "of")) {
  5453. this.scanner.next();
  5454. selector = this.SelectorList();
  5455. if (this.needPositions) {
  5456. end = this.getLastListNode(selector.children).loc.end.offset;
  5457. }
  5458. } else {
  5459. if (this.needPositions) {
  5460. end = query.loc.end.offset;
  5461. }
  5462. }
  5463. return {
  5464. type: "Nth",
  5465. loc: this.getLocation(start, end),
  5466. nth: query,
  5467. selector: selector
  5468. };
  5469. },
  5470. generate: function (node) {
  5471. this.node(node.nth);
  5472. if (node.selector !== null) {
  5473. this.chunk(" of ");
  5474. this.node(node.selector);
  5475. }
  5476. }
  5477. };
  5478. }, {}], 67: [function (require, module, exports) {
  5479. var NUMBER = require("../../tokenizer").TYPE.Number;
  5480. module.exports = {
  5481. name: "Number",
  5482. structure: {
  5483. value: String
  5484. },
  5485. parse: function () {
  5486. return {
  5487. type: "Number",
  5488. loc: this.getLocation(this.scanner.tokenStart, this.scanner.tokenEnd),
  5489. value: this.consume(NUMBER)
  5490. };
  5491. },
  5492. generate: function (node) {
  5493. this.chunk(node.value);
  5494. }
  5495. };
  5496. }, { "../../tokenizer": 107 }], 68: [function (require, module, exports) {
  5497. module.exports = {
  5498. name: "Operator",
  5499. structure: {
  5500. value: String
  5501. },
  5502. parse: function () {
  5503. var start = this.scanner.tokenStart;
  5504. this.scanner.next();
  5505. return {
  5506. type: "Operator",
  5507. loc: this.getLocation(start, this.scanner.tokenStart),
  5508. value: this.scanner.substrToCursor(start)
  5509. };
  5510. },
  5511. generate: function (node) {
  5512. this.chunk(node.value);
  5513. }
  5514. };
  5515. }, {}], 69: [function (require, module, exports) {
  5516. var TYPE = require("../../tokenizer").TYPE;
  5517. var LEFTPARENTHESIS = TYPE.LeftParenthesis;
  5518. var RIGHTPARENTHESIS = TYPE.RightParenthesis;
  5519. module.exports = {
  5520. name: "Parentheses",
  5521. structure: {
  5522. children: [[]]
  5523. },
  5524. parse: function (readSequence, recognizer) {
  5525. var start = this.scanner.tokenStart;
  5526. var children = null;
  5527. this.eat(LEFTPARENTHESIS);
  5528. children = readSequence.call(this, recognizer);
  5529. if (!this.scanner.eof) {
  5530. this.eat(RIGHTPARENTHESIS);
  5531. }
  5532. return {
  5533. type: "Parentheses",
  5534. loc: this.getLocation(start, this.scanner.tokenStart),
  5535. children: children
  5536. };
  5537. },
  5538. generate: function (node) {
  5539. this.chunk("(");
  5540. this.children(node);
  5541. this.chunk(")");
  5542. }
  5543. };
  5544. }, { "../../tokenizer": 107 }], 70: [function (require, module, exports) {
  5545. var consumeNumber = require("../../tokenizer/utils").consumeNumber;
  5546. var TYPE = require("../../tokenizer").TYPE;
  5547. var PERCENTAGE = TYPE.Percentage;
  5548. module.exports = {
  5549. name: "Percentage",
  5550. structure: {
  5551. value: String
  5552. },
  5553. parse: function () {
  5554. var start = this.scanner.tokenStart;
  5555. var numberEnd = consumeNumber(this.scanner.source, start);
  5556. this.eat(PERCENTAGE);
  5557. return {
  5558. type: "Percentage",
  5559. loc: this.getLocation(start, this.scanner.tokenStart),
  5560. value: this.scanner.source.substring(start, numberEnd)
  5561. };
  5562. },
  5563. generate: function (node) {
  5564. this.chunk(node.value);
  5565. this.chunk("%");
  5566. }
  5567. };
  5568. }, { "../../tokenizer": 107, "../../tokenizer/utils": 108 }], 71: [function (require, module, exports) {
  5569. var TYPE = require("../../tokenizer").TYPE;
  5570. var IDENT = TYPE.Ident;
  5571. var FUNCTION = TYPE.Function;
  5572. var COLON = TYPE.Colon;
  5573. var RIGHTPARENTHESIS = TYPE.RightParenthesis;
  5574. module.exports = {
  5575. name: "PseudoClassSelector",
  5576. structure: {
  5577. name: String,
  5578. children: [["Raw"], null]
  5579. },
  5580. parse: function () {
  5581. var start = this.scanner.tokenStart;
  5582. var children = null;
  5583. var name;
  5584. var nameLowerCase;
  5585. this.eat(COLON);
  5586. if (this.scanner.tokenType === FUNCTION) {
  5587. name = this.consumeFunctionName();
  5588. nameLowerCase = name.toLowerCase();
  5589. if (this.pseudo.hasOwnProperty(nameLowerCase)) {
  5590. this.scanner.skipSC();
  5591. children = this.pseudo[nameLowerCase].call(this);
  5592. this.scanner.skipSC();
  5593. } else {
  5594. children = this.createList();
  5595. children.push(
  5596. this.Raw(this.scanner.tokenIndex, null, false)
  5597. );
  5598. }
  5599. this.eat(RIGHTPARENTHESIS);
  5600. } else {
  5601. name = this.consume(IDENT);
  5602. }
  5603. return {
  5604. type: "PseudoClassSelector",
  5605. loc: this.getLocation(start, this.scanner.tokenStart),
  5606. name: name,
  5607. children: children
  5608. };
  5609. },
  5610. generate: function (node) {
  5611. this.chunk(":");
  5612. this.chunk(node.name);
  5613. if (node.children !== null) {
  5614. this.chunk("(");
  5615. this.children(node);
  5616. this.chunk(")");
  5617. }
  5618. },
  5619. walkContext: "function"
  5620. };
  5621. }, { "../../tokenizer": 107 }], 72: [function (require, module, exports) {
  5622. var TYPE = require("../../tokenizer").TYPE;
  5623. var IDENT = TYPE.Ident;
  5624. var FUNCTION = TYPE.Function;
  5625. var COLON = TYPE.Colon;
  5626. var RIGHTPARENTHESIS = TYPE.RightParenthesis;
  5627. module.exports = {
  5628. name: "PseudoElementSelector",
  5629. structure: {
  5630. name: String,
  5631. children: [["Raw"], null]
  5632. },
  5633. parse: function () {
  5634. var start = this.scanner.tokenStart;
  5635. var children = null;
  5636. var name;
  5637. var nameLowerCase;
  5638. this.eat(COLON);
  5639. this.eat(COLON);
  5640. if (this.scanner.tokenType === FUNCTION) {
  5641. name = this.consumeFunctionName();
  5642. nameLowerCase = name.toLowerCase();
  5643. if (this.pseudo.hasOwnProperty(nameLowerCase)) {
  5644. this.scanner.skipSC();
  5645. children = this.pseudo[nameLowerCase].call(this);
  5646. this.scanner.skipSC();
  5647. } else {
  5648. children = this.createList();
  5649. children.push(
  5650. this.Raw(this.scanner.tokenIndex, null, false)
  5651. );
  5652. }
  5653. this.eat(RIGHTPARENTHESIS);
  5654. } else {
  5655. name = this.consume(IDENT);
  5656. }
  5657. return {
  5658. type: "PseudoElementSelector",
  5659. loc: this.getLocation(start, this.scanner.tokenStart),
  5660. name: name,
  5661. children: children
  5662. };
  5663. },
  5664. generate: function (node) {
  5665. this.chunk("::");
  5666. this.chunk(node.name);
  5667. if (node.children !== null) {
  5668. this.chunk("(");
  5669. this.children(node);
  5670. this.chunk(")");
  5671. }
  5672. },
  5673. walkContext: "function"
  5674. };
  5675. }, { "../../tokenizer": 107 }], 73: [function (require, module, exports) {
  5676. var isDigit = require("../../tokenizer").isDigit;
  5677. var TYPE = require("../../tokenizer").TYPE;
  5678. var NUMBER = TYPE.Number;
  5679. var DELIM = TYPE.Delim;
  5680. var SOLIDUS = 0x002F; // U+002F SOLIDUS (/)
  5681. var FULLSTOP = 0x002E; // U+002E FULL STOP (.)
  5682. function consumeNumber() {
  5683. this.scanner.skipWS();
  5684. var value = this.consume(NUMBER);
  5685. for (var i = 0; i < value.length; i++) {
  5686. var code = value.charCodeAt(i);
  5687. if (!isDigit(code) && code !== FULLSTOP) {
  5688. this.error("Unsigned number is expected", this.scanner.tokenStart - value.length + i);
  5689. }
  5690. }
  5691. if (Number(value) === 0) {
  5692. this.error("Zero number is not allowed", this.scanner.tokenStart - value.length);
  5693. }
  5694. return value;
  5695. }
  5696. module.exports = {
  5697. name: "Ratio",
  5698. structure: {
  5699. left: String,
  5700. right: String
  5701. },
  5702. parse: function () {
  5703. var start = this.scanner.tokenStart;
  5704. var left = consumeNumber.call(this);
  5705. var right;
  5706. this.scanner.skipWS();
  5707. if (!this.scanner.isDelim(SOLIDUS)) {
  5708. this.error("Solidus is expected");
  5709. }
  5710. this.eat(DELIM);
  5711. right = consumeNumber.call(this);
  5712. return {
  5713. type: "Ratio",
  5714. loc: this.getLocation(start, this.scanner.tokenStart),
  5715. left: left,
  5716. right: right
  5717. };
  5718. },
  5719. generate: function (node) {
  5720. this.chunk(node.left);
  5721. this.chunk("/");
  5722. this.chunk(node.right);
  5723. }
  5724. };
  5725. }, { "../../tokenizer": 107 }], 74: [function (require, module, exports) {
  5726. var tokenizer = require("../../tokenizer");
  5727. var TYPE = tokenizer.TYPE;
  5728. var WhiteSpace = TYPE.WhiteSpace;
  5729. var Semicolon = TYPE.Semicolon;
  5730. var LeftCurlyBracket = TYPE.LeftCurlyBracket;
  5731. var Delim = TYPE.Delim;
  5732. var EXCLAMATIONMARK = 0x0021; // U+0021 EXCLAMATION MARK (!)
  5733. function getOffsetExcludeWS() {
  5734. if (this.scanner.tokenIndex > 0) {
  5735. if (this.scanner.lookupType(-1) === WhiteSpace) {
  5736. return this.scanner.tokenIndex > 1
  5737. ? this.scanner.getTokenStart(this.scanner.tokenIndex - 1)
  5738. : this.scanner.firstCharOffset;
  5739. }
  5740. }
  5741. return this.scanner.tokenStart;
  5742. }
  5743. function balanceEnd() {
  5744. return 0;
  5745. }
  5746. function leftCurlyBracket(tokenType) {
  5747. return tokenType === LeftCurlyBracket ? 1 : 0;
  5748. }
  5749. function leftCurlyBracketOrSemicolon(tokenType) {
  5750. return tokenType === LeftCurlyBracket || tokenType === Semicolon ? 1 : 0;
  5751. }
  5752. function exclamationMarkOrSemicolon(tokenType, source, offset) {
  5753. if (tokenType === Delim && source.charCodeAt(offset) === EXCLAMATIONMARK) {
  5754. return 1;
  5755. }
  5756. return tokenType === Semicolon ? 1 : 0;
  5757. }
  5758. function semicolonIncluded(tokenType) {
  5759. return tokenType === Semicolon ? 2 : 0;
  5760. }
  5761. module.exports = {
  5762. name: "Raw",
  5763. structure: {
  5764. value: String
  5765. },
  5766. parse: function (startToken, mode, excludeWhiteSpace) {
  5767. var startOffset = this.scanner.getTokenStart(startToken);
  5768. var endOffset;
  5769. this.scanner.skip(
  5770. this.scanner.getRawLength(startToken, mode || balanceEnd)
  5771. );
  5772. if (excludeWhiteSpace && this.scanner.tokenStart > startOffset) {
  5773. endOffset = getOffsetExcludeWS.call(this);
  5774. } else {
  5775. endOffset = this.scanner.tokenStart;
  5776. }
  5777. return {
  5778. type: "Raw",
  5779. loc: this.getLocation(startOffset, endOffset),
  5780. value: this.scanner.source.substring(startOffset, endOffset)
  5781. };
  5782. },
  5783. generate: function (node) {
  5784. this.chunk(node.value);
  5785. },
  5786. mode: {
  5787. default: balanceEnd,
  5788. leftCurlyBracket: leftCurlyBracket,
  5789. leftCurlyBracketOrSemicolon: leftCurlyBracketOrSemicolon,
  5790. exclamationMarkOrSemicolon: exclamationMarkOrSemicolon,
  5791. semicolonIncluded: semicolonIncluded
  5792. }
  5793. };
  5794. }, { "../../tokenizer": 107 }], 75: [function (require, module, exports) {
  5795. var TYPE = require("../../tokenizer").TYPE;
  5796. var rawMode = require("./Raw").mode;
  5797. var LEFTCURLYBRACKET = TYPE.LeftCurlyBracket;
  5798. function consumeRaw(startToken) {
  5799. return this.Raw(startToken, rawMode.leftCurlyBracket, true);
  5800. }
  5801. function consumePrelude() {
  5802. var prelude = this.SelectorList();
  5803. if (prelude.type !== "Raw" &&
  5804. this.scanner.eof === false &&
  5805. this.scanner.tokenType !== LEFTCURLYBRACKET) {
  5806. this.error();
  5807. }
  5808. return prelude;
  5809. }
  5810. module.exports = {
  5811. name: "Rule",
  5812. structure: {
  5813. prelude: ["SelectorList", "Raw"],
  5814. block: ["Block"]
  5815. },
  5816. parse: function () {
  5817. var startToken = this.scanner.tokenIndex;
  5818. var startOffset = this.scanner.tokenStart;
  5819. var prelude;
  5820. var block;
  5821. if (this.parseRulePrelude) {
  5822. prelude = this.parseWithFallback(consumePrelude, consumeRaw);
  5823. } else {
  5824. prelude = consumeRaw.call(this, startToken);
  5825. }
  5826. block = this.Block(true);
  5827. return {
  5828. type: "Rule",
  5829. loc: this.getLocation(startOffset, this.scanner.tokenStart),
  5830. prelude: prelude,
  5831. block: block
  5832. };
  5833. },
  5834. generate: function (node) {
  5835. this.node(node.prelude);
  5836. this.node(node.block);
  5837. },
  5838. walkContext: "rule"
  5839. };
  5840. }, { "../../tokenizer": 107, "./Raw": 74 }], 76: [function (require, module, exports) {
  5841. module.exports = {
  5842. name: "Selector",
  5843. structure: {
  5844. children: [[
  5845. "TypeSelector",
  5846. "IdSelector",
  5847. "ClassSelector",
  5848. "AttributeSelector",
  5849. "PseudoClassSelector",
  5850. "PseudoElementSelector",
  5851. "Combinator",
  5852. "WhiteSpace"
  5853. ]]
  5854. },
  5855. parse: function () {
  5856. var children = this.readSequence(this.scope.Selector);
  5857. if (this.getFirstListNode(children) === null) {
  5858. this.error("Selector is expected");
  5859. }
  5860. return {
  5861. type: "Selector",
  5862. loc: this.getLocationFromList(children),
  5863. children: children
  5864. };
  5865. },
  5866. generate: function (node) {
  5867. this.children(node);
  5868. }
  5869. };
  5870. }, {}], 77: [function (require, module, exports) {
  5871. var TYPE = require("../../tokenizer").TYPE;
  5872. var COMMA = TYPE.Comma;
  5873. module.exports = {
  5874. name: "SelectorList",
  5875. structure: {
  5876. children: [[
  5877. "Selector",
  5878. "Raw"
  5879. ]]
  5880. },
  5881. parse: function () {
  5882. var children = this.createList();
  5883. while (!this.scanner.eof) {
  5884. children.push(this.Selector());
  5885. if (this.scanner.tokenType === COMMA) {
  5886. this.scanner.next();
  5887. continue;
  5888. }
  5889. break;
  5890. }
  5891. return {
  5892. type: "SelectorList",
  5893. loc: this.getLocationFromList(children),
  5894. children: children
  5895. };
  5896. },
  5897. generate: function (node) {
  5898. this.children(node, function () {
  5899. this.chunk(",");
  5900. });
  5901. },
  5902. walkContext: "selector"
  5903. };
  5904. }, { "../../tokenizer": 107 }], 78: [function (require, module, exports) {
  5905. var STRING = require("../../tokenizer").TYPE.String;
  5906. module.exports = {
  5907. name: "String",
  5908. structure: {
  5909. value: String
  5910. },
  5911. parse: function () {
  5912. return {
  5913. type: "String",
  5914. loc: this.getLocation(this.scanner.tokenStart, this.scanner.tokenEnd),
  5915. value: this.consume(STRING)
  5916. };
  5917. },
  5918. generate: function (node) {
  5919. this.chunk(node.value);
  5920. }
  5921. };
  5922. }, { "../../tokenizer": 107 }], 79: [function (require, module, exports) {
  5923. var TYPE = require("../../tokenizer").TYPE;
  5924. var WHITESPACE = TYPE.WhiteSpace;
  5925. var COMMENT = TYPE.Comment;
  5926. var ATKEYWORD = TYPE.AtKeyword;
  5927. var CDO = TYPE.CDO;
  5928. var CDC = TYPE.CDC;
  5929. var EXCLAMATIONMARK = 0x0021; // U+0021 EXCLAMATION MARK (!)
  5930. function consumeRaw(startToken) {
  5931. return this.Raw(startToken, null, false);
  5932. }
  5933. module.exports = {
  5934. name: "StyleSheet",
  5935. structure: {
  5936. children: [[
  5937. "Comment",
  5938. "CDO",
  5939. "CDC",
  5940. "Atrule",
  5941. "Rule",
  5942. "Raw"
  5943. ]]
  5944. },
  5945. parse: function () {
  5946. var start = this.scanner.tokenStart;
  5947. var children = this.createList();
  5948. var child;
  5949. while (!this.scanner.eof) {
  5950. switch (this.scanner.tokenType) {
  5951. case WHITESPACE:
  5952. this.scanner.next();
  5953. continue;
  5954. case COMMENT:
  5955. if (this.scanner.source.charCodeAt(this.scanner.tokenStart + 2) !== EXCLAMATIONMARK) {
  5956. this.scanner.next();
  5957. continue;
  5958. }
  5959. child = this.Comment();
  5960. break;
  5961. case CDO: // <!--
  5962. child = this.CDO();
  5963. break;
  5964. case CDC: // -->
  5965. child = this.CDC();
  5966. break;
  5967. case ATKEYWORD:
  5968. child = this.parseWithFallback(this.Atrule, consumeRaw);
  5969. break;
  5970. default:
  5971. child = this.parseWithFallback(this.Rule, consumeRaw);
  5972. }
  5973. children.push(child);
  5974. }
  5975. return {
  5976. type: "StyleSheet",
  5977. loc: this.getLocation(start, this.scanner.tokenStart),
  5978. children: children
  5979. };
  5980. },
  5981. generate: function (node) {
  5982. this.children(node);
  5983. },
  5984. walkContext: "stylesheet"
  5985. };
  5986. }, { "../../tokenizer": 107 }], 80: [function (require, module, exports) {
  5987. var TYPE = require("../../tokenizer").TYPE;
  5988. var IDENT = TYPE.Ident;
  5989. var ASTERISK = 0x002A; // U+002A ASTERISK (*)
  5990. var VERTICALLINE = 0x007C; // U+007C VERTICAL LINE (|)
  5991. function eatIdentifierOrAsterisk() {
  5992. if (this.scanner.tokenType !== IDENT &&
  5993. this.scanner.isDelim(ASTERISK) === false) {
  5994. this.error("Identifier or asterisk is expected");
  5995. }
  5996. this.scanner.next();
  5997. }
  5998. module.exports = {
  5999. name: "TypeSelector",
  6000. structure: {
  6001. name: String
  6002. },
  6003. parse: function () {
  6004. var start = this.scanner.tokenStart;
  6005. if (this.scanner.isDelim(VERTICALLINE)) {
  6006. this.scanner.next();
  6007. eatIdentifierOrAsterisk.call(this);
  6008. } else {
  6009. eatIdentifierOrAsterisk.call(this);
  6010. if (this.scanner.isDelim(VERTICALLINE)) {
  6011. this.scanner.next();
  6012. eatIdentifierOrAsterisk.call(this);
  6013. }
  6014. }
  6015. return {
  6016. type: "TypeSelector",
  6017. loc: this.getLocation(start, this.scanner.tokenStart),
  6018. name: this.scanner.substrToCursor(start)
  6019. };
  6020. },
  6021. generate: function (node) {
  6022. this.chunk(node.name);
  6023. }
  6024. };
  6025. }, { "../../tokenizer": 107 }], 81: [function (require, module, exports) {
  6026. var isHexDigit = require("../../tokenizer").isHexDigit;
  6027. var cmpChar = require("../../tokenizer").cmpChar;
  6028. var TYPE = require("../../tokenizer").TYPE;
  6029. var NAME = require("../../tokenizer").NAME;
  6030. var IDENT = TYPE.Ident;
  6031. var NUMBER = TYPE.Number;
  6032. var DIMENSION = TYPE.Dimension;
  6033. var PLUSSIGN = 0x002B; // U+002B PLUS SIGN (+)
  6034. var HYPHENMINUS = 0x002D; // U+002D HYPHEN-MINUS (-)
  6035. var QUESTIONMARK = 0x003F; // U+003F QUESTION MARK (?)
  6036. var U = 0x0075; // U+0075 LATIN SMALL LETTER U (u)
  6037. function eatHexSequence(offset, allowDash) {
  6038. for (var pos = this.scanner.tokenStart + offset, len = 0; pos < this.scanner.tokenEnd; pos++) {
  6039. var code = this.scanner.source.charCodeAt(pos);
  6040. if (code === HYPHENMINUS && allowDash && len !== 0) {
  6041. if (eatHexSequence.call(this, offset + len + 1, false) === 0) {
  6042. this.error();
  6043. }
  6044. return -1;
  6045. }
  6046. if (!isHexDigit(code)) {
  6047. this.error(
  6048. allowDash && len !== 0
  6049. ? "HyphenMinus" + (len < 6 ? " or hex digit" : "") + " is expected"
  6050. : (len < 6 ? "Hex digit is expected" : "Unexpected input"),
  6051. pos
  6052. );
  6053. }
  6054. if (++len > 6) {
  6055. this.error("Too many hex digits", pos);
  6056. }
  6057. }
  6058. this.scanner.next();
  6059. return len;
  6060. }
  6061. function eatQuestionMarkSequence(max) {
  6062. var count = 0;
  6063. while (this.scanner.isDelim(QUESTIONMARK)) {
  6064. if (++count > max) {
  6065. this.error("Too many question marks");
  6066. }
  6067. this.scanner.next();
  6068. }
  6069. }
  6070. function startsWith(code) {
  6071. if (this.scanner.source.charCodeAt(this.scanner.tokenStart) !== code) {
  6072. this.error(NAME[code] + " is expected");
  6073. }
  6074. }
  6075. function scanUnicodeRange() {
  6076. var hexLength = 0;
  6077. if (this.scanner.isDelim(PLUSSIGN)) {
  6078. this.scanner.next();
  6079. if (this.scanner.tokenType === IDENT) {
  6080. hexLength = eatHexSequence.call(this, 0, true);
  6081. if (hexLength > 0) {
  6082. eatQuestionMarkSequence.call(this, 6 - hexLength);
  6083. }
  6084. return;
  6085. }
  6086. if (this.scanner.isDelim(QUESTIONMARK)) {
  6087. this.scanner.next();
  6088. eatQuestionMarkSequence.call(this, 5);
  6089. return;
  6090. }
  6091. this.error("Hex digit or question mark is expected");
  6092. return;
  6093. }
  6094. if (this.scanner.tokenType === NUMBER) {
  6095. startsWith.call(this, PLUSSIGN);
  6096. hexLength = eatHexSequence.call(this, 1, true);
  6097. if (this.scanner.isDelim(QUESTIONMARK)) {
  6098. eatQuestionMarkSequence.call(this, 6 - hexLength);
  6099. return;
  6100. }
  6101. if (this.scanner.tokenType === DIMENSION ||
  6102. this.scanner.tokenType === NUMBER) {
  6103. startsWith.call(this, HYPHENMINUS);
  6104. eatHexSequence.call(this, 1, false);
  6105. return;
  6106. }
  6107. return;
  6108. }
  6109. if (this.scanner.tokenType === DIMENSION) {
  6110. startsWith.call(this, PLUSSIGN);
  6111. hexLength = eatHexSequence.call(this, 1, true);
  6112. if (hexLength > 0) {
  6113. eatQuestionMarkSequence.call(this, 6 - hexLength);
  6114. }
  6115. return;
  6116. }
  6117. this.error();
  6118. }
  6119. module.exports = {
  6120. name: "UnicodeRange",
  6121. structure: {
  6122. value: String
  6123. },
  6124. parse: function () {
  6125. var start = this.scanner.tokenStart;
  6126. if (!cmpChar(this.scanner.source, start, U)) {
  6127. this.error("U is expected");
  6128. }
  6129. if (!cmpChar(this.scanner.source, start + 1, PLUSSIGN)) {
  6130. this.error("Plus sign is expected");
  6131. }
  6132. this.scanner.next();
  6133. scanUnicodeRange.call(this);
  6134. return {
  6135. type: "UnicodeRange",
  6136. loc: this.getLocation(start, this.scanner.tokenStart),
  6137. value: this.scanner.substrToCursor(start)
  6138. };
  6139. },
  6140. generate: function (node) {
  6141. this.chunk(node.value);
  6142. }
  6143. };
  6144. }, { "../../tokenizer": 107 }], 82: [function (require, module, exports) {
  6145. var isWhiteSpace = require("../../tokenizer").isWhiteSpace;
  6146. var cmpStr = require("../../tokenizer").cmpStr;
  6147. var TYPE = require("../../tokenizer").TYPE;
  6148. var FUNCTION = TYPE.Function;
  6149. var URL = TYPE.Url;
  6150. var RIGHTPARENTHESIS = TYPE.RightParenthesis;
  6151. module.exports = {
  6152. name: "Url",
  6153. structure: {
  6154. value: ["String", "Raw"]
  6155. },
  6156. parse: function () {
  6157. var start = this.scanner.tokenStart;
  6158. var value;
  6159. switch (this.scanner.tokenType) {
  6160. case URL:
  6161. var rawStart = start + 4;
  6162. var rawEnd = this.scanner.tokenEnd - 1;
  6163. while (rawStart < rawEnd && isWhiteSpace(this.scanner.source.charCodeAt(rawStart))) {
  6164. rawStart++;
  6165. }
  6166. while (rawStart < rawEnd && isWhiteSpace(this.scanner.source.charCodeAt(rawEnd - 1))) {
  6167. rawEnd--;
  6168. }
  6169. value = {
  6170. type: "Raw",
  6171. loc: this.getLocation(rawStart, rawEnd),
  6172. value: this.scanner.source.substring(rawStart, rawEnd)
  6173. };
  6174. this.eat(URL);
  6175. break;
  6176. case FUNCTION:
  6177. if (!cmpStr(this.scanner.source, this.scanner.tokenStart, this.scanner.tokenEnd, "url(")) {
  6178. this.error("Function name must be `url`");
  6179. }
  6180. this.eat(FUNCTION);
  6181. this.scanner.skipSC();
  6182. value = this.String();
  6183. this.scanner.skipSC();
  6184. this.eat(RIGHTPARENTHESIS);
  6185. break;
  6186. default:
  6187. this.error("Url or Function is expected");
  6188. }
  6189. return {
  6190. type: "Url",
  6191. loc: this.getLocation(start, this.scanner.tokenStart),
  6192. value: value
  6193. };
  6194. },
  6195. generate: function (node) {
  6196. this.chunk("url");
  6197. this.chunk("(");
  6198. this.node(node.value);
  6199. this.chunk(")");
  6200. }
  6201. };
  6202. }, { "../../tokenizer": 107 }], 83: [function (require, module, exports) {
  6203. module.exports = {
  6204. name: "Value",
  6205. structure: {
  6206. children: [[]]
  6207. },
  6208. parse: function () {
  6209. var start = this.scanner.tokenStart;
  6210. var children = this.readSequence(this.scope.Value);
  6211. return {
  6212. type: "Value",
  6213. loc: this.getLocation(start, this.scanner.tokenStart),
  6214. children: children
  6215. };
  6216. },
  6217. generate: function (node) {
  6218. this.children(node);
  6219. }
  6220. };
  6221. }, {}], 84: [function (require, module, exports) {
  6222. var WHITESPACE = require("../../tokenizer").TYPE.WhiteSpace;
  6223. var SPACE = Object.freeze({
  6224. type: "WhiteSpace",
  6225. loc: null,
  6226. value: " "
  6227. });
  6228. module.exports = {
  6229. name: "WhiteSpace",
  6230. structure: {
  6231. value: String
  6232. },
  6233. parse: function () {
  6234. this.eat(WHITESPACE);
  6235. return SPACE;
  6236. },
  6237. generate: function (node) {
  6238. this.chunk(node.value);
  6239. }
  6240. };
  6241. }, { "../../tokenizer": 107 }], 85: [function (require, module, exports) {
  6242. module.exports = {
  6243. AnPlusB: require("./AnPlusB"),
  6244. Atrule: require("./Atrule"),
  6245. AtrulePrelude: require("./AtrulePrelude"),
  6246. AttributeSelector: require("./AttributeSelector"),
  6247. Block: require("./Block"),
  6248. Brackets: require("./Brackets"),
  6249. CDC: require("./CDC"),
  6250. CDO: require("./CDO"),
  6251. ClassSelector: require("./ClassSelector"),
  6252. Combinator: require("./Combinator"),
  6253. Comment: require("./Comment"),
  6254. Declaration: require("./Declaration"),
  6255. DeclarationList: require("./DeclarationList"),
  6256. Dimension: require("./Dimension"),
  6257. Function: require("./Function"),
  6258. HexColor: require("./HexColor"),
  6259. Identifier: require("./Identifier"),
  6260. IdSelector: require("./IdSelector"),
  6261. MediaFeature: require("./MediaFeature"),
  6262. MediaQuery: require("./MediaQuery"),
  6263. MediaQueryList: require("./MediaQueryList"),
  6264. Nth: require("./Nth"),
  6265. Number: require("./Number"),
  6266. Operator: require("./Operator"),
  6267. Parentheses: require("./Parentheses"),
  6268. Percentage: require("./Percentage"),
  6269. PseudoClassSelector: require("./PseudoClassSelector"),
  6270. PseudoElementSelector: require("./PseudoElementSelector"),
  6271. Ratio: require("./Ratio"),
  6272. Raw: require("./Raw"),
  6273. Rule: require("./Rule"),
  6274. Selector: require("./Selector"),
  6275. SelectorList: require("./SelectorList"),
  6276. String: require("./String"),
  6277. StyleSheet: require("./StyleSheet"),
  6278. TypeSelector: require("./TypeSelector"),
  6279. UnicodeRange: require("./UnicodeRange"),
  6280. Url: require("./Url"),
  6281. Value: require("./Value"),
  6282. WhiteSpace: require("./WhiteSpace")
  6283. };
  6284. }, { "./AnPlusB": 45, "./Atrule": 46, "./AtrulePrelude": 47, "./AttributeSelector": 48, "./Block": 49, "./Brackets": 50, "./CDC": 51, "./CDO": 52, "./ClassSelector": 53, "./Combinator": 54, "./Comment": 55, "./Declaration": 56, "./DeclarationList": 57, "./Dimension": 58, "./Function": 59, "./HexColor": 60, "./IdSelector": 61, "./Identifier": 62, "./MediaFeature": 63, "./MediaQuery": 64, "./MediaQueryList": 65, "./Nth": 66, "./Number": 67, "./Operator": 68, "./Parentheses": 69, "./Percentage": 70, "./PseudoClassSelector": 71, "./PseudoElementSelector": 72, "./Ratio": 73, "./Raw": 74, "./Rule": 75, "./Selector": 76, "./SelectorList": 77, "./String": 78, "./StyleSheet": 79, "./TypeSelector": 80, "./UnicodeRange": 81, "./Url": 82, "./Value": 83, "./WhiteSpace": 84 }], 86: [function (require, module, exports) {
  6285. var DISALLOW_OF_CLAUSE = false;
  6286. module.exports = {
  6287. parse: function nth() {
  6288. return this.createSingleNodeList(
  6289. this.Nth(DISALLOW_OF_CLAUSE)
  6290. );
  6291. }
  6292. };
  6293. }, {}], 87: [function (require, module, exports) {
  6294. var ALLOW_OF_CLAUSE = true;
  6295. module.exports = {
  6296. parse: function nthWithOfClause() {
  6297. return this.createSingleNodeList(
  6298. this.Nth(ALLOW_OF_CLAUSE)
  6299. );
  6300. }
  6301. };
  6302. }, {}], 88: [function (require, module, exports) {
  6303. module.exports = {
  6304. parse: function selectorList() {
  6305. return this.createSingleNodeList(
  6306. this.SelectorList()
  6307. );
  6308. }
  6309. };
  6310. }, {}], 89: [function (require, module, exports) {
  6311. module.exports = {
  6312. parse: function () {
  6313. return this.createSingleNodeList(
  6314. this.Identifier()
  6315. );
  6316. }
  6317. };
  6318. }, {}], 90: [function (require, module, exports) {
  6319. module.exports = {
  6320. parse: function () {
  6321. return this.createSingleNodeList(
  6322. this.SelectorList()
  6323. );
  6324. }
  6325. };
  6326. }, {}], 91: [function (require, module, exports) {
  6327. module.exports = {
  6328. "dir": require("./dir"),
  6329. "has": require("./has"),
  6330. "lang": require("./lang"),
  6331. "matches": require("./matches"),
  6332. "not": require("./not"),
  6333. "nth-child": require("./nth-child"),
  6334. "nth-last-child": require("./nth-last-child"),
  6335. "nth-last-of-type": require("./nth-last-of-type"),
  6336. "nth-of-type": require("./nth-of-type"),
  6337. "slotted": require("./slotted")
  6338. };
  6339. }, { "./dir": 89, "./has": 90, "./lang": 92, "./matches": 93, "./not": 94, "./nth-child": 95, "./nth-last-child": 96, "./nth-last-of-type": 97, "./nth-of-type": 98, "./slotted": 99 }], 92: [function (require, module, exports) {
  6340. arguments[4][89][0].apply(exports, arguments);
  6341. }, { "dup": 89 }], 93: [function (require, module, exports) {
  6342. module.exports = require("./common/selectorList");
  6343. }, { "./common/selectorList": 88 }], 94: [function (require, module, exports) {
  6344. arguments[4][93][0].apply(exports, arguments);
  6345. }, { "./common/selectorList": 88, "dup": 93 }], 95: [function (require, module, exports) {
  6346. module.exports = require("./common/nthWithOfClause");
  6347. }, { "./common/nthWithOfClause": 87 }], 96: [function (require, module, exports) {
  6348. arguments[4][95][0].apply(exports, arguments);
  6349. }, { "./common/nthWithOfClause": 87, "dup": 95 }], 97: [function (require, module, exports) {
  6350. module.exports = require("./common/nth");
  6351. }, { "./common/nth": 86 }], 98: [function (require, module, exports) {
  6352. arguments[4][97][0].apply(exports, arguments);
  6353. }, { "./common/nth": 86, "dup": 97 }], 99: [function (require, module, exports) {
  6354. module.exports = {
  6355. parse: function compoundSelector() {
  6356. return this.createSingleNodeList(
  6357. this.Selector()
  6358. );
  6359. }
  6360. };
  6361. }, {}], 100: [function (require, module, exports) {
  6362. module.exports = {
  6363. getNode: require("./default")
  6364. };
  6365. }, { "./default": 101 }], 101: [function (require, module, exports) {
  6366. var cmpChar = require("../../tokenizer").cmpChar;
  6367. var cmpStr = require("../../tokenizer").cmpStr;
  6368. var TYPE = require("../../tokenizer").TYPE;
  6369. var IDENT = TYPE.Ident;
  6370. var STRING = TYPE.String;
  6371. var NUMBER = TYPE.Number;
  6372. var FUNCTION = TYPE.Function;
  6373. var URL = TYPE.Url;
  6374. var HASH = TYPE.Hash;
  6375. var DIMENSION = TYPE.Dimension;
  6376. var PERCENTAGE = TYPE.Percentage;
  6377. var LEFTPARENTHESIS = TYPE.LeftParenthesis;
  6378. var LEFTSQUAREBRACKET = TYPE.LeftSquareBracket;
  6379. var COMMA = TYPE.Comma;
  6380. var DELIM = TYPE.Delim;
  6381. var NUMBERSIGN = 0x0023; // U+0023 NUMBER SIGN (#)
  6382. var ASTERISK = 0x002A; // U+002A ASTERISK (*)
  6383. var PLUSSIGN = 0x002B; // U+002B PLUS SIGN (+)
  6384. var HYPHENMINUS = 0x002D; // U+002D HYPHEN-MINUS (-)
  6385. var SOLIDUS = 0x002F; // U+002F SOLIDUS (/)
  6386. var U = 0x0075; // U+0075 LATIN SMALL LETTER U (u)
  6387. module.exports = function defaultRecognizer(context) {
  6388. switch (this.scanner.tokenType) {
  6389. case HASH:
  6390. return this.HexColor();
  6391. case COMMA:
  6392. context.space = null;
  6393. context.ignoreWSAfter = true;
  6394. return this.Operator();
  6395. case LEFTPARENTHESIS:
  6396. return this.Parentheses(this.readSequence, context.recognizer);
  6397. case LEFTSQUAREBRACKET:
  6398. return this.Brackets(this.readSequence, context.recognizer);
  6399. case STRING:
  6400. return this.String();
  6401. case DIMENSION:
  6402. return this.Dimension();
  6403. case PERCENTAGE:
  6404. return this.Percentage();
  6405. case NUMBER:
  6406. return this.Number();
  6407. case FUNCTION:
  6408. return cmpStr(this.scanner.source, this.scanner.tokenStart, this.scanner.tokenEnd, "url(")
  6409. ? this.Url()
  6410. : this.Function(this.readSequence, context.recognizer);
  6411. case URL:
  6412. return this.Url();
  6413. case IDENT:
  6414. if (cmpChar(this.scanner.source, this.scanner.tokenStart, U) &&
  6415. cmpChar(this.scanner.source, this.scanner.tokenStart + 1, PLUSSIGN)) {
  6416. return this.UnicodeRange();
  6417. } else {
  6418. return this.Identifier();
  6419. }
  6420. case DELIM:
  6421. var code = this.scanner.source.charCodeAt(this.scanner.tokenStart);
  6422. if (code === SOLIDUS ||
  6423. code === ASTERISK ||
  6424. code === PLUSSIGN ||
  6425. code === HYPHENMINUS) {
  6426. return this.Operator(); // TODO: replace with Delim
  6427. }
  6428. if (code === NUMBERSIGN) {
  6429. this.error("Hex or identifier is expected", this.scanner.tokenStart + 1);
  6430. }
  6431. break;
  6432. }
  6433. };
  6434. }, { "../../tokenizer": 107 }], 102: [function (require, module, exports) {
  6435. module.exports = {
  6436. AtrulePrelude: require("./atrulePrelude"),
  6437. Selector: require("./selector"),
  6438. Value: require("./value")
  6439. };
  6440. }, { "./atrulePrelude": 100, "./selector": 103, "./value": 104 }], 103: [function (require, module, exports) {
  6441. var TYPE = require("../../tokenizer").TYPE;
  6442. var DELIM = TYPE.Delim;
  6443. var IDENT = TYPE.Ident;
  6444. var DIMENSION = TYPE.Dimension;
  6445. var PERCENTAGE = TYPE.Percentage;
  6446. var NUMBER = TYPE.Number;
  6447. var HASH = TYPE.Hash;
  6448. var COLON = TYPE.Colon;
  6449. var LEFTSQUAREBRACKET = TYPE.LeftSquareBracket;
  6450. var NUMBERSIGN = 0x0023; // U+0023 NUMBER SIGN (#)
  6451. var ASTERISK = 0x002A; // U+002A ASTERISK (*)
  6452. var PLUSSIGN = 0x002B; // U+002B PLUS SIGN (+)
  6453. var SOLIDUS = 0x002F; // U+002F SOLIDUS (/)
  6454. var FULLSTOP = 0x002E; // U+002E FULL STOP (.)
  6455. var GREATERTHANSIGN = 0x003E; // U+003E GREATER-THAN SIGN (>)
  6456. var VERTICALLINE = 0x007C; // U+007C VERTICAL LINE (|)
  6457. var TILDE = 0x007E; // U+007E TILDE (~)
  6458. function getNode(context) {
  6459. switch (this.scanner.tokenType) {
  6460. case LEFTSQUAREBRACKET:
  6461. return this.AttributeSelector();
  6462. case HASH:
  6463. return this.IdSelector();
  6464. case COLON:
  6465. if (this.scanner.lookupType(1) === COLON) {
  6466. return this.PseudoElementSelector();
  6467. } else {
  6468. return this.PseudoClassSelector();
  6469. }
  6470. case IDENT:
  6471. return this.TypeSelector();
  6472. case NUMBER:
  6473. case PERCENTAGE:
  6474. return this.Percentage();
  6475. case DIMENSION:
  6476. if (this.scanner.source.charCodeAt(this.scanner.tokenStart) === FULLSTOP) {
  6477. this.error("Identifier is expected", this.scanner.tokenStart + 1);
  6478. }
  6479. break;
  6480. case DELIM:
  6481. var code = this.scanner.source.charCodeAt(this.scanner.tokenStart);
  6482. switch (code) {
  6483. case PLUSSIGN:
  6484. case GREATERTHANSIGN:
  6485. case TILDE:
  6486. context.space = null;
  6487. context.ignoreWSAfter = true;
  6488. return this.Combinator();
  6489. case SOLIDUS: // /deep/
  6490. return this.Combinator();
  6491. case FULLSTOP:
  6492. return this.ClassSelector();
  6493. case ASTERISK:
  6494. case VERTICALLINE:
  6495. return this.TypeSelector();
  6496. case NUMBERSIGN:
  6497. return this.IdSelector();
  6498. }
  6499. break;
  6500. }
  6501. }
  6502. module.exports = {
  6503. getNode: getNode
  6504. };
  6505. }, { "../../tokenizer": 107 }], 104: [function (require, module, exports) {
  6506. module.exports = {
  6507. getNode: require("./default"),
  6508. "-moz-element": require("../function/element"),
  6509. "element": require("../function/element"),
  6510. "expression": require("../function/expression"),
  6511. "var": require("../function/var")
  6512. };
  6513. }, { "../function/element": 41, "../function/expression": 42, "../function/var": 43, "./default": 101 }], 105: [function (require, module, exports) {
  6514. var EOF = 0;
  6515. function isDigit(code) {
  6516. return code >= 0x0030 && code <= 0x0039;
  6517. }
  6518. function isHexDigit(code) {
  6519. return (
  6520. isDigit(code) || // 0 .. 9
  6521. (code >= 0x0041 && code <= 0x0046) || // A .. F
  6522. (code >= 0x0061 && code <= 0x0066) // a .. f
  6523. );
  6524. }
  6525. function isUppercaseLetter(code) {
  6526. return code >= 0x0041 && code <= 0x005A;
  6527. }
  6528. function isLowercaseLetter(code) {
  6529. return code >= 0x0061 && code <= 0x007A;
  6530. }
  6531. function isLetter(code) {
  6532. return isUppercaseLetter(code) || isLowercaseLetter(code);
  6533. }
  6534. function isNonAscii(code) {
  6535. return code >= 0x0080;
  6536. }
  6537. function isNameStart(code) {
  6538. return isLetter(code) || isNonAscii(code) || code === 0x005F;
  6539. }
  6540. function isName(code) {
  6541. return isNameStart(code) || isDigit(code) || code === 0x002D;
  6542. }
  6543. function isNonPrintable(code) {
  6544. return (
  6545. (code >= 0x0000 && code <= 0x0008) ||
  6546. (code === 0x000B) ||
  6547. (code >= 0x000E && code <= 0x001F) ||
  6548. (code === 0x007F)
  6549. );
  6550. }
  6551. function isNewline(code) {
  6552. return code === 0x000A || code === 0x000D || code === 0x000C;
  6553. }
  6554. function isWhiteSpace(code) {
  6555. return isNewline(code) || code === 0x0020 || code === 0x0009;
  6556. }
  6557. function isValidEscape(first, second) {
  6558. if (first !== 0x005C) {
  6559. return false;
  6560. }
  6561. if (isNewline(second) || second === EOF) {
  6562. return false;
  6563. }
  6564. return true;
  6565. }
  6566. function isIdentifierStart(first, second, third) {
  6567. if (first === 0x002D) {
  6568. return (
  6569. isNameStart(second) ||
  6570. second === 0x002D ||
  6571. isValidEscape(second, third)
  6572. );
  6573. }
  6574. if (isNameStart(first)) {
  6575. return true;
  6576. }
  6577. if (first === 0x005C) {
  6578. return isValidEscape(first, second);
  6579. }
  6580. return false;
  6581. }
  6582. function isNumberStart(first, second, third) {
  6583. if (first === 0x002B || first === 0x002D) {
  6584. if (isDigit(second)) {
  6585. return 2;
  6586. }
  6587. return second === 0x002E && isDigit(third) ? 3 : 0;
  6588. }
  6589. if (first === 0x002E) {
  6590. return isDigit(second) ? 2 : 0;
  6591. }
  6592. if (isDigit(first)) {
  6593. return 1;
  6594. }
  6595. return 0;
  6596. }
  6597. function isBOM(code) {
  6598. if (code === 0xFEFF) {
  6599. return 1;
  6600. }
  6601. if (code === 0xFFFE) {
  6602. return 1;
  6603. }
  6604. return 0;
  6605. }
  6606. var CATEGORY = new Array(0x80);
  6607. charCodeCategory.Eof = 0x80;
  6608. charCodeCategory.WhiteSpace = 0x82;
  6609. charCodeCategory.Digit = 0x83;
  6610. charCodeCategory.NameStart = 0x84;
  6611. charCodeCategory.NonPrintable = 0x85;
  6612. for (var i = 0; i < CATEGORY.length; i++) {
  6613. switch (true) {
  6614. case isWhiteSpace(i):
  6615. CATEGORY[i] = charCodeCategory.WhiteSpace;
  6616. break;
  6617. case isDigit(i):
  6618. CATEGORY[i] = charCodeCategory.Digit;
  6619. break;
  6620. case isNameStart(i):
  6621. CATEGORY[i] = charCodeCategory.NameStart;
  6622. break;
  6623. case isNonPrintable(i):
  6624. CATEGORY[i] = charCodeCategory.NonPrintable;
  6625. break;
  6626. default:
  6627. CATEGORY[i] = i || charCodeCategory.Eof;
  6628. }
  6629. }
  6630. function charCodeCategory(code) {
  6631. return code < 0x80 ? CATEGORY[code] : charCodeCategory.NameStart;
  6632. }
  6633. module.exports = {
  6634. isDigit: isDigit,
  6635. isHexDigit: isHexDigit,
  6636. isUppercaseLetter: isUppercaseLetter,
  6637. isLowercaseLetter: isLowercaseLetter,
  6638. isLetter: isLetter,
  6639. isNonAscii: isNonAscii,
  6640. isNameStart: isNameStart,
  6641. isName: isName,
  6642. isNonPrintable: isNonPrintable,
  6643. isNewline: isNewline,
  6644. isWhiteSpace: isWhiteSpace,
  6645. isValidEscape: isValidEscape,
  6646. isIdentifierStart: isIdentifierStart,
  6647. isNumberStart: isNumberStart,
  6648. isBOM: isBOM,
  6649. charCodeCategory: charCodeCategory
  6650. };
  6651. }, {}], 106: [function (require, module, exports) {
  6652. var TYPE = {
  6653. EOF: 0, // <EOF-token>
  6654. Ident: 1, // <ident-token>
  6655. Function: 2, // <function-token>
  6656. AtKeyword: 3, // <at-keyword-token>
  6657. Hash: 4, // <hash-token>
  6658. String: 5, // <string-token>
  6659. BadString: 6, // <bad-string-token>
  6660. Url: 7, // <url-token>
  6661. BadUrl: 8, // <bad-url-token>
  6662. Delim: 9, // <delim-token>
  6663. Number: 10, // <number-token>
  6664. Percentage: 11, // <percentage-token>
  6665. Dimension: 12, // <dimension-token>
  6666. WhiteSpace: 13, // <whitespace-token>
  6667. CDO: 14, // <CDO-token>
  6668. CDC: 15, // <CDC-token>
  6669. Colon: 16, // <colon-token> :
  6670. Semicolon: 17, // <semicolon-token> ;
  6671. Comma: 18, // <comma-token> ,
  6672. LeftSquareBracket: 19, // <[-token>
  6673. RightSquareBracket: 20, // <]-token>
  6674. LeftParenthesis: 21, // <(-token>
  6675. RightParenthesis: 22, // <)-token>
  6676. LeftCurlyBracket: 23, // <{-token>
  6677. RightCurlyBracket: 24, // <}-token>
  6678. Comment: 25
  6679. };
  6680. var NAME = Object.keys(TYPE).reduce(function (result, key) {
  6681. result[TYPE[key]] = key;
  6682. return result;
  6683. }, {});
  6684. module.exports = {
  6685. TYPE: TYPE,
  6686. NAME: NAME
  6687. };
  6688. }, {}], 107: [function (require, module, exports) {
  6689. var TokenStream = require("../common/TokenStream");
  6690. var adoptBuffer = require("../common/adopt-buffer");
  6691. var constants = require("./const");
  6692. var TYPE = constants.TYPE;
  6693. var charCodeDefinitions = require("./char-code-definitions");
  6694. var isNewline = charCodeDefinitions.isNewline;
  6695. var isName = charCodeDefinitions.isName;
  6696. var isValidEscape = charCodeDefinitions.isValidEscape;
  6697. var isNumberStart = charCodeDefinitions.isNumberStart;
  6698. var isIdentifierStart = charCodeDefinitions.isIdentifierStart;
  6699. var charCodeCategory = charCodeDefinitions.charCodeCategory;
  6700. var isBOM = charCodeDefinitions.isBOM;
  6701. var utils = require("./utils");
  6702. var cmpStr = utils.cmpStr;
  6703. var getNewlineLength = utils.getNewlineLength;
  6704. var findWhiteSpaceEnd = utils.findWhiteSpaceEnd;
  6705. var consumeEscaped = utils.consumeEscaped;
  6706. var consumeName = utils.consumeName;
  6707. var consumeNumber = utils.consumeNumber;
  6708. var consumeBadUrlRemnants = utils.consumeBadUrlRemnants;
  6709. var OFFSET_MASK = 0x00FFFFFF;
  6710. var TYPE_SHIFT = 24;
  6711. function tokenize(source, stream) {
  6712. function getCharCode(offset) {
  6713. return offset < sourceLength ? source.charCodeAt(offset) : 0;
  6714. }
  6715. function consumeNumericToken() {
  6716. offset = consumeNumber(source, offset);
  6717. if (isIdentifierStart(getCharCode(offset), getCharCode(offset + 1), getCharCode(offset + 2))) {
  6718. type = TYPE.Dimension;
  6719. offset = consumeName(source, offset);
  6720. return;
  6721. }
  6722. if (getCharCode(offset) === 0x0025) {
  6723. type = TYPE.Percentage;
  6724. offset++;
  6725. return;
  6726. }
  6727. type = TYPE.Number;
  6728. }
  6729. function consumeIdentLikeToken() {
  6730. const nameStartOffset = offset;
  6731. offset = consumeName(source, offset);
  6732. if (cmpStr(source, nameStartOffset, offset, "url") && getCharCode(offset) === 0x0028) {
  6733. offset = findWhiteSpaceEnd(source, offset + 1);
  6734. if (getCharCode(offset) === 0x0022 ||
  6735. getCharCode(offset) === 0x0027) {
  6736. type = TYPE.Function;
  6737. offset = nameStartOffset + 4;
  6738. return;
  6739. }
  6740. consumeUrlToken();
  6741. return;
  6742. }
  6743. if (getCharCode(offset) === 0x0028) {
  6744. type = TYPE.Function;
  6745. offset++;
  6746. return;
  6747. }
  6748. type = TYPE.Ident;
  6749. }
  6750. function consumeStringToken(endingCodePoint) {
  6751. if (!endingCodePoint) {
  6752. endingCodePoint = getCharCode(offset++);
  6753. }
  6754. type = TYPE.String;
  6755. for (; offset < source.length; offset++) {
  6756. var code = source.charCodeAt(offset);
  6757. switch (charCodeCategory(code)) {
  6758. case endingCodePoint:
  6759. offset++;
  6760. return;
  6761. case charCodeCategory.Eof:
  6762. return;
  6763. case charCodeCategory.WhiteSpace:
  6764. if (isNewline(code)) {
  6765. offset += getNewlineLength(source, offset, code);
  6766. type = TYPE.BadString;
  6767. return;
  6768. }
  6769. break;
  6770. case 0x005C:
  6771. if (offset === source.length - 1) {
  6772. break;
  6773. }
  6774. var nextCode = getCharCode(offset + 1);
  6775. if (isNewline(nextCode)) {
  6776. offset += getNewlineLength(source, offset + 1, nextCode);
  6777. } else if (isValidEscape(code, nextCode)) {
  6778. offset = consumeEscaped(source, offset) - 1;
  6779. }
  6780. break;
  6781. }
  6782. }
  6783. }
  6784. function consumeUrlToken() {
  6785. type = TYPE.Url;
  6786. offset = findWhiteSpaceEnd(source, offset);
  6787. for (; offset < source.length; offset++) {
  6788. var code = source.charCodeAt(offset);
  6789. switch (charCodeCategory(code)) {
  6790. case 0x0029:
  6791. offset++;
  6792. return;
  6793. case charCodeCategory.Eof:
  6794. return;
  6795. case charCodeCategory.WhiteSpace:
  6796. offset = findWhiteSpaceEnd(source, offset);
  6797. if (getCharCode(offset) === 0x0029 || offset >= source.length) {
  6798. if (offset < source.length) {
  6799. offset++;
  6800. }
  6801. return;
  6802. }
  6803. offset = consumeBadUrlRemnants(source, offset);
  6804. type = TYPE.BadUrl;
  6805. return;
  6806. case 0x0022:
  6807. case 0x0027:
  6808. case 0x0028:
  6809. case charCodeCategory.NonPrintable:
  6810. offset = consumeBadUrlRemnants(source, offset);
  6811. type = TYPE.BadUrl;
  6812. return;
  6813. case 0x005C:
  6814. if (isValidEscape(code, getCharCode(offset + 1))) {
  6815. offset = consumeEscaped(source, offset) - 1;
  6816. break;
  6817. }
  6818. offset = consumeBadUrlRemnants(source, offset);
  6819. type = TYPE.BadUrl;
  6820. return;
  6821. }
  6822. }
  6823. }
  6824. if (!stream) {
  6825. stream = new TokenStream();
  6826. }
  6827. source = String(source || "");
  6828. var sourceLength = source.length;
  6829. var offsetAndType = adoptBuffer(stream.offsetAndType, sourceLength + 1); // +1 because of eof-token
  6830. var balance = adoptBuffer(stream.balance, sourceLength + 1);
  6831. var tokenCount = 0;
  6832. var start = isBOM(getCharCode(0));
  6833. var offset = start;
  6834. var balanceCloseType = 0;
  6835. var balanceStart = 0;
  6836. var balancePrev = 0;
  6837. while (offset < sourceLength) {
  6838. var code = source.charCodeAt(offset);
  6839. var type = 0;
  6840. balance[tokenCount] = sourceLength;
  6841. switch (charCodeCategory(code)) {
  6842. case charCodeCategory.WhiteSpace:
  6843. type = TYPE.WhiteSpace;
  6844. offset = findWhiteSpaceEnd(source, offset + 1);
  6845. break;
  6846. case 0x0022:
  6847. consumeStringToken();
  6848. break;
  6849. case 0x0023:
  6850. if (isName(getCharCode(offset + 1)) || isValidEscape(getCharCode(offset + 1), getCharCode(offset + 2))) {
  6851. type = TYPE.Hash;
  6852. offset = consumeName(source, offset + 1);
  6853. } else {
  6854. type = TYPE.Delim;
  6855. offset++;
  6856. }
  6857. break;
  6858. case 0x0027:
  6859. consumeStringToken();
  6860. break;
  6861. case 0x0028:
  6862. type = TYPE.LeftParenthesis;
  6863. offset++;
  6864. break;
  6865. case 0x0029:
  6866. type = TYPE.RightParenthesis;
  6867. offset++;
  6868. break;
  6869. case 0x002B:
  6870. if (isNumberStart(code, getCharCode(offset + 1), getCharCode(offset + 2))) {
  6871. consumeNumericToken();
  6872. } else {
  6873. type = TYPE.Delim;
  6874. offset++;
  6875. }
  6876. break;
  6877. case 0x002C:
  6878. type = TYPE.Comma;
  6879. offset++;
  6880. break;
  6881. case 0x002D:
  6882. if (isNumberStart(code, getCharCode(offset + 1), getCharCode(offset + 2))) {
  6883. consumeNumericToken();
  6884. } else {
  6885. if (getCharCode(offset + 1) === 0x002D &&
  6886. getCharCode(offset + 2) === 0x003E) {
  6887. type = TYPE.CDC;
  6888. offset = offset + 3;
  6889. } else {
  6890. if (isIdentifierStart(code, getCharCode(offset + 1), getCharCode(offset + 2))) {
  6891. consumeIdentLikeToken();
  6892. } else {
  6893. type = TYPE.Delim;
  6894. offset++;
  6895. }
  6896. }
  6897. }
  6898. break;
  6899. case 0x002E:
  6900. if (isNumberStart(code, getCharCode(offset + 1), getCharCode(offset + 2))) {
  6901. consumeNumericToken();
  6902. } else {
  6903. type = TYPE.Delim;
  6904. offset++;
  6905. }
  6906. break;
  6907. case 0x002F:
  6908. if (getCharCode(offset + 1) === 0x002A) {
  6909. type = TYPE.Comment;
  6910. offset = source.indexOf("*/", offset + 2) + 2;
  6911. if (offset === 1) {
  6912. offset = source.length;
  6913. }
  6914. } else {
  6915. type = TYPE.Delim;
  6916. offset++;
  6917. }
  6918. break;
  6919. case 0x003A:
  6920. type = TYPE.Colon;
  6921. offset++;
  6922. break;
  6923. case 0x003B:
  6924. type = TYPE.Semicolon;
  6925. offset++;
  6926. break;
  6927. case 0x003C:
  6928. if (getCharCode(offset + 1) === 0x0021 &&
  6929. getCharCode(offset + 2) === 0x002D &&
  6930. getCharCode(offset + 3) === 0x002D) {
  6931. type = TYPE.CDO;
  6932. offset = offset + 4;
  6933. } else {
  6934. type = TYPE.Delim;
  6935. offset++;
  6936. }
  6937. break;
  6938. case 0x0040:
  6939. if (isIdentifierStart(getCharCode(offset + 1), getCharCode(offset + 2), getCharCode(offset + 3))) {
  6940. type = TYPE.AtKeyword;
  6941. offset = consumeName(source, offset + 1);
  6942. } else {
  6943. type = TYPE.Delim;
  6944. offset++;
  6945. }
  6946. break;
  6947. case 0x005B:
  6948. type = TYPE.LeftSquareBracket;
  6949. offset++;
  6950. break;
  6951. case 0x005C:
  6952. if (isValidEscape(code, getCharCode(offset + 1))) {
  6953. consumeIdentLikeToken();
  6954. } else {
  6955. type = TYPE.Delim;
  6956. offset++;
  6957. }
  6958. break;
  6959. case 0x005D:
  6960. type = TYPE.RightSquareBracket;
  6961. offset++;
  6962. break;
  6963. case 0x007B:
  6964. type = TYPE.LeftCurlyBracket;
  6965. offset++;
  6966. break;
  6967. case 0x007D:
  6968. type = TYPE.RightCurlyBracket;
  6969. offset++;
  6970. break;
  6971. case charCodeCategory.Digit:
  6972. consumeNumericToken();
  6973. break;
  6974. case charCodeCategory.NameStart:
  6975. consumeIdentLikeToken();
  6976. break;
  6977. case charCodeCategory.Eof:
  6978. break;
  6979. default:
  6980. type = TYPE.Delim;
  6981. offset++;
  6982. }
  6983. switch (type) {
  6984. case balanceCloseType:
  6985. balancePrev = balanceStart & OFFSET_MASK;
  6986. balanceStart = balance[balancePrev];
  6987. balanceCloseType = balanceStart >> TYPE_SHIFT;
  6988. balance[tokenCount] = balancePrev;
  6989. balance[balancePrev++] = tokenCount;
  6990. for (; balancePrev < tokenCount; balancePrev++) {
  6991. if (balance[balancePrev] === sourceLength) {
  6992. balance[balancePrev] = tokenCount;
  6993. }
  6994. }
  6995. break;
  6996. case TYPE.LeftParenthesis:
  6997. case TYPE.Function:
  6998. balance[tokenCount] = balanceStart;
  6999. balanceCloseType = TYPE.RightParenthesis;
  7000. balanceStart = (balanceCloseType << TYPE_SHIFT) | tokenCount;
  7001. break;
  7002. case TYPE.LeftSquareBracket:
  7003. balance[tokenCount] = balanceStart;
  7004. balanceCloseType = TYPE.RightSquareBracket;
  7005. balanceStart = (balanceCloseType << TYPE_SHIFT) | tokenCount;
  7006. break;
  7007. case TYPE.LeftCurlyBracket:
  7008. balance[tokenCount] = balanceStart;
  7009. balanceCloseType = TYPE.RightCurlyBracket;
  7010. balanceStart = (balanceCloseType << TYPE_SHIFT) | tokenCount;
  7011. break;
  7012. }
  7013. offsetAndType[tokenCount++] = (type << TYPE_SHIFT) | offset;
  7014. }
  7015. offsetAndType[tokenCount] = (TYPE.EOF << TYPE_SHIFT) | offset; // <EOF-token>
  7016. balance[tokenCount] = sourceLength;
  7017. balance[sourceLength] = sourceLength; // prevents false positive balance match with any token
  7018. while (balanceStart !== 0) {
  7019. balancePrev = balanceStart & OFFSET_MASK;
  7020. balanceStart = balance[balancePrev];
  7021. balance[balancePrev] = sourceLength;
  7022. }
  7023. stream.source = source;
  7024. stream.firstCharOffset = start;
  7025. stream.offsetAndType = offsetAndType;
  7026. stream.tokenCount = tokenCount;
  7027. stream.balance = balance;
  7028. stream.reset();
  7029. stream.next();
  7030. return stream;
  7031. }
  7032. Object.keys(constants).forEach(function (key) {
  7033. tokenize[key] = constants[key];
  7034. });
  7035. Object.keys(charCodeDefinitions).forEach(function (key) {
  7036. tokenize[key] = charCodeDefinitions[key];
  7037. });
  7038. Object.keys(utils).forEach(function (key) {
  7039. tokenize[key] = utils[key];
  7040. });
  7041. module.exports = tokenize;
  7042. }, { "../common/TokenStream": 5, "../common/adopt-buffer": 6, "./char-code-definitions": 105, "./const": 106, "./utils": 108 }], 108: [function (require, module, exports) {
  7043. var charCodeDef = require("./char-code-definitions");
  7044. var isDigit = charCodeDef.isDigit;
  7045. var isHexDigit = charCodeDef.isHexDigit;
  7046. var isUppercaseLetter = charCodeDef.isUppercaseLetter;
  7047. var isName = charCodeDef.isName;
  7048. var isWhiteSpace = charCodeDef.isWhiteSpace;
  7049. var isValidEscape = charCodeDef.isValidEscape;
  7050. function getCharCode(source, offset) {
  7051. return offset < source.length ? source.charCodeAt(offset) : 0;
  7052. }
  7053. function getNewlineLength(source, offset, code) {
  7054. if (code === 13 && getCharCode(source, offset + 1) === 10) {
  7055. return 2;
  7056. }
  7057. return 1;
  7058. }
  7059. function cmpChar(testStr, offset, referenceCode) {
  7060. var code = testStr.charCodeAt(offset);
  7061. if (isUppercaseLetter(code)) {
  7062. code = code | 32;
  7063. }
  7064. return code === referenceCode;
  7065. }
  7066. function cmpStr(testStr, start, end, referenceStr) {
  7067. if (end - start !== referenceStr.length) {
  7068. return false;
  7069. }
  7070. if (start < 0 || end > testStr.length) {
  7071. return false;
  7072. }
  7073. for (var i = start; i < end; i++) {
  7074. var testCode = testStr.charCodeAt(i);
  7075. var referenceCode = referenceStr.charCodeAt(i - start);
  7076. if (isUppercaseLetter(testCode)) {
  7077. testCode = testCode | 32;
  7078. }
  7079. if (testCode !== referenceCode) {
  7080. return false;
  7081. }
  7082. }
  7083. return true;
  7084. }
  7085. function findWhiteSpaceStart(source, offset) {
  7086. for (; offset >= 0; offset--) {
  7087. if (!isWhiteSpace(source.charCodeAt(offset))) {
  7088. break;
  7089. }
  7090. }
  7091. return offset + 1;
  7092. }
  7093. function findWhiteSpaceEnd(source, offset) {
  7094. for (; offset < source.length; offset++) {
  7095. if (!isWhiteSpace(source.charCodeAt(offset))) {
  7096. break;
  7097. }
  7098. }
  7099. return offset;
  7100. }
  7101. function findDecimalNumberEnd(source, offset) {
  7102. for (; offset < source.length; offset++) {
  7103. if (!isDigit(source.charCodeAt(offset))) {
  7104. break;
  7105. }
  7106. }
  7107. return offset;
  7108. }
  7109. function consumeEscaped(source, offset) {
  7110. offset += 2;
  7111. if (isHexDigit(getCharCode(source, offset - 1))) {
  7112. for (var maxOffset = Math.min(source.length, offset + 5); offset < maxOffset; offset++) {
  7113. if (!isHexDigit(getCharCode(source, offset))) {
  7114. break;
  7115. }
  7116. }
  7117. var code = getCharCode(source, offset);
  7118. if (isWhiteSpace(code)) {
  7119. offset += getNewlineLength(source, offset, code);
  7120. }
  7121. }
  7122. return offset;
  7123. }
  7124. function consumeName(source, offset) {
  7125. for (; offset < source.length; offset++) {
  7126. var code = source.charCodeAt(offset);
  7127. if (isName(code)) {
  7128. continue;
  7129. }
  7130. if (isValidEscape(code, getCharCode(source, offset + 1))) {
  7131. offset = consumeEscaped(source, offset) - 1;
  7132. continue;
  7133. }
  7134. break;
  7135. }
  7136. return offset;
  7137. }
  7138. function consumeNumber(source, offset) {
  7139. var code = source.charCodeAt(offset);
  7140. if (code === 0x002B || code === 0x002D) {
  7141. code = source.charCodeAt(offset += 1);
  7142. }
  7143. if (isDigit(code)) {
  7144. offset = findDecimalNumberEnd(source, offset + 1);
  7145. code = source.charCodeAt(offset);
  7146. }
  7147. if (code === 0x002E && isDigit(source.charCodeAt(offset + 1))) {
  7148. code = source.charCodeAt(offset += 2);
  7149. offset = findDecimalNumberEnd(source, offset);
  7150. }
  7151. if (cmpChar(source, offset, 101)) {
  7152. var sign = 0;
  7153. code = source.charCodeAt(offset + 1);
  7154. if (code === 0x002D || code === 0x002B) {
  7155. sign = 1;
  7156. code = source.charCodeAt(offset + 2);
  7157. }
  7158. if (isDigit(code)) {
  7159. offset = findDecimalNumberEnd(source, offset + 1 + sign + 1);
  7160. }
  7161. }
  7162. return offset;
  7163. }
  7164. function consumeBadUrlRemnants(source, offset) {
  7165. for (; offset < source.length; offset++) {
  7166. var code = source.charCodeAt(offset);
  7167. if (code === 0x0029) {
  7168. offset++;
  7169. break;
  7170. }
  7171. if (isValidEscape(code, getCharCode(source, offset + 1))) {
  7172. offset = consumeEscaped(source, offset);
  7173. }
  7174. }
  7175. return offset;
  7176. }
  7177. module.exports = {
  7178. consumeEscaped: consumeEscaped,
  7179. consumeName: consumeName,
  7180. consumeNumber: consumeNumber,
  7181. consumeBadUrlRemnants: consumeBadUrlRemnants,
  7182. cmpChar: cmpChar,
  7183. cmpStr: cmpStr,
  7184. getNewlineLength: getNewlineLength,
  7185. findWhiteSpaceStart: findWhiteSpaceStart,
  7186. findWhiteSpaceEnd: findWhiteSpaceEnd
  7187. };
  7188. }, { "./char-code-definitions": 105 }], 109: [function (require, module, exports) {
  7189. var List = require("../common/List");
  7190. module.exports = function clone(node) {
  7191. var result = {};
  7192. for (var key in node) {
  7193. var value = node[key];
  7194. if (value) {
  7195. if (Array.isArray(value) || value instanceof List) {
  7196. value = value.map(clone);
  7197. } else if (value.constructor === Object) {
  7198. value = clone(value);
  7199. }
  7200. }
  7201. result[key] = value;
  7202. }
  7203. return result;
  7204. };
  7205. }, { "../common/List": 2 }], 110: [function (require, module, exports) {
  7206. module.exports = function createCustomError(name, message) {
  7207. var error = Object.create(SyntaxError.prototype);
  7208. var errorStack = new Error();
  7209. error.name = name;
  7210. error.message = message;
  7211. Object.defineProperty(error, "stack", {
  7212. get: function () {
  7213. return (errorStack.stack || "").replace(/^(.+\n){1,3}/, name + ": " + message + "\n");
  7214. }
  7215. });
  7216. return error;
  7217. };
  7218. }, {}], 111: [function (require, module, exports) {
  7219. var hasOwnProperty = Object.prototype.hasOwnProperty;
  7220. var keywords = Object.create(null);
  7221. var properties = Object.create(null);
  7222. var HYPHENMINUS = 45; // '-'.charCodeAt()
  7223. function isCustomProperty(str, offset) {
  7224. offset = offset || 0;
  7225. return str.length - offset >= 2 &&
  7226. str.charCodeAt(offset) === HYPHENMINUS &&
  7227. str.charCodeAt(offset + 1) === HYPHENMINUS;
  7228. }
  7229. function getVendorPrefix(str, offset) {
  7230. offset = offset || 0;
  7231. if (str.length - offset >= 3) {
  7232. if (str.charCodeAt(offset) === HYPHENMINUS &&
  7233. str.charCodeAt(offset + 1) !== HYPHENMINUS) {
  7234. var secondDashIndex = str.indexOf("-", offset + 2);
  7235. if (secondDashIndex !== -1) {
  7236. return str.substring(offset, secondDashIndex + 1);
  7237. }
  7238. }
  7239. }
  7240. return "";
  7241. }
  7242. function getKeywordDescriptor(keyword) {
  7243. if (hasOwnProperty.call(keywords, keyword)) {
  7244. return keywords[keyword];
  7245. }
  7246. var name = keyword.toLowerCase();
  7247. if (hasOwnProperty.call(keywords, name)) {
  7248. return keywords[keyword] = keywords[name];
  7249. }
  7250. var custom = isCustomProperty(name, 0);
  7251. var vendor = !custom ? getVendorPrefix(name, 0) : "";
  7252. return keywords[keyword] = Object.freeze({
  7253. basename: name.substr(vendor.length),
  7254. name: name,
  7255. vendor: vendor,
  7256. prefix: vendor,
  7257. custom: custom
  7258. });
  7259. }
  7260. function getPropertyDescriptor(property) {
  7261. if (hasOwnProperty.call(properties, property)) {
  7262. return properties[property];
  7263. }
  7264. var name = property;
  7265. var hack = property[0];
  7266. if (hack === "/") {
  7267. hack = property[1] === "/" ? "//" : "/";
  7268. } else if (hack !== "_" &&
  7269. hack !== "*" &&
  7270. hack !== "$" &&
  7271. hack !== "#" &&
  7272. hack !== "+" &&
  7273. hack !== "&") {
  7274. hack = "";
  7275. }
  7276. var custom = isCustomProperty(name, hack.length);
  7277. if (!custom) {
  7278. name = name.toLowerCase();
  7279. if (hasOwnProperty.call(properties, name)) {
  7280. return properties[property] = properties[name];
  7281. }
  7282. }
  7283. var vendor = !custom ? getVendorPrefix(name, hack.length) : "";
  7284. var prefix = name.substr(0, hack.length + vendor.length);
  7285. return properties[property] = Object.freeze({
  7286. basename: name.substr(prefix.length),
  7287. name: name.substr(hack.length),
  7288. hack: hack,
  7289. vendor: vendor,
  7290. prefix: prefix,
  7291. custom: custom
  7292. });
  7293. }
  7294. module.exports = {
  7295. keyword: getKeywordDescriptor,
  7296. property: getPropertyDescriptor,
  7297. isCustomProperty: isCustomProperty,
  7298. vendorPrefix: getVendorPrefix
  7299. };
  7300. }, {}], 112: [function (require, module, exports) {
  7301. var hasOwnProperty = Object.prototype.hasOwnProperty;
  7302. var noop = function () { };
  7303. function ensureFunction(value) {
  7304. return typeof value === "function" ? value : noop;
  7305. }
  7306. function invokeForType(fn, type) {
  7307. return function (node, item, list) {
  7308. if (node.type === type) {
  7309. fn.call(this, node, item, list);
  7310. }
  7311. };
  7312. }
  7313. function getWalkersFromStructure(name, nodeType) {
  7314. var structure = nodeType.structure;
  7315. var walkers = [];
  7316. for (var key in structure) {
  7317. if (hasOwnProperty.call(structure, key) === false) {
  7318. continue;
  7319. }
  7320. var fieldTypes = structure[key];
  7321. var walker = {
  7322. name: key,
  7323. type: false,
  7324. nullable: false
  7325. };
  7326. if (!Array.isArray(structure[key])) {
  7327. fieldTypes = [structure[key]];
  7328. }
  7329. for (var i = 0; i < fieldTypes.length; i++) {
  7330. var fieldType = fieldTypes[i];
  7331. if (fieldType === null) {
  7332. walker.nullable = true;
  7333. } else if (typeof fieldType === "string") {
  7334. walker.type = "node";
  7335. } else if (Array.isArray(fieldType)) {
  7336. walker.type = "list";
  7337. }
  7338. }
  7339. if (walker.type) {
  7340. walkers.push(walker);
  7341. }
  7342. }
  7343. if (walkers.length) {
  7344. return {
  7345. context: nodeType.walkContext,
  7346. fields: walkers
  7347. };
  7348. }
  7349. return null;
  7350. }
  7351. function getTypesFromConfig(config) {
  7352. var types = {};
  7353. for (var name in config.node) {
  7354. if (hasOwnProperty.call(config.node, name)) {
  7355. var nodeType = config.node[name];
  7356. if (!nodeType.structure) {
  7357. throw new Error("Missed `structure` field in `" + name + "` node type definition");
  7358. }
  7359. types[name] = getWalkersFromStructure(name, nodeType);
  7360. }
  7361. }
  7362. return types;
  7363. }
  7364. function createTypeIterator(config, reverse) {
  7365. var fields = reverse ? config.fields.slice().reverse() : config.fields;
  7366. var body = fields.map(function (field) {
  7367. var ref = "node." + field.name;
  7368. var line;
  7369. if (field.type === "list") {
  7370. line = reverse
  7371. ? ref + ".forEachRight(walk);"
  7372. : ref + ".forEach(walk);";
  7373. } else {
  7374. line = "walk(" + ref + ");";
  7375. }
  7376. if (field.nullable) {
  7377. line = "if (" + ref + ") {\n " + line + "}";
  7378. }
  7379. return line;
  7380. });
  7381. if (config.context) {
  7382. body = [].concat(
  7383. "var old = context." + config.context + ";",
  7384. "context." + config.context + " = node;",
  7385. body,
  7386. "context." + config.context + " = old;"
  7387. );
  7388. }
  7389. return new Function("node", "context", "walk", body.join("\n"));
  7390. }
  7391. function createFastTraveralMap(iterators) {
  7392. return {
  7393. Atrule: {
  7394. StyleSheet: iterators.StyleSheet,
  7395. Atrule: iterators.Atrule,
  7396. Rule: iterators.Rule,
  7397. Block: iterators.Block
  7398. },
  7399. Rule: {
  7400. StyleSheet: iterators.StyleSheet,
  7401. Atrule: iterators.Atrule,
  7402. Rule: iterators.Rule,
  7403. Block: iterators.Block
  7404. },
  7405. Declaration: {
  7406. StyleSheet: iterators.StyleSheet,
  7407. Atrule: iterators.Atrule,
  7408. Rule: iterators.Rule,
  7409. Block: iterators.Block
  7410. }
  7411. };
  7412. }
  7413. module.exports = function createWalker(config) {
  7414. var types = getTypesFromConfig(config);
  7415. var iteratorsNatural = {};
  7416. var iteratorsReverse = {};
  7417. for (var name in types) {
  7418. if (hasOwnProperty.call(types, name) && types[name] !== null) {
  7419. iteratorsNatural[name] = createTypeIterator(types[name], false);
  7420. iteratorsReverse[name] = createTypeIterator(types[name], true);
  7421. }
  7422. }
  7423. var fastTraversalIteratorsNatural = createFastTraveralMap(iteratorsNatural);
  7424. var fastTraversalIteratorsReverse = createFastTraveralMap(iteratorsReverse);
  7425. return function walk(root, options) {
  7426. function walkNode(node, item, list) {
  7427. enter.call(context, node, item, list);
  7428. if (iterators.hasOwnProperty(node.type)) {
  7429. iterators[node.type](node, context, walkNode);
  7430. }
  7431. leave.call(context, node, item, list);
  7432. }
  7433. var enter = noop;
  7434. var leave = noop;
  7435. var iterators = iteratorsNatural;
  7436. var context = {
  7437. root: root,
  7438. stylesheet: null,
  7439. atrule: null,
  7440. atrulePrelude: null,
  7441. rule: null,
  7442. selector: null,
  7443. block: null,
  7444. declaration: null,
  7445. function: null
  7446. };
  7447. if (typeof options === "function") {
  7448. enter = options;
  7449. } else if (options) {
  7450. enter = ensureFunction(options.enter);
  7451. leave = ensureFunction(options.leave);
  7452. if (options.reverse) {
  7453. iterators = iteratorsReverse;
  7454. }
  7455. if (options.visit) {
  7456. if (fastTraversalIteratorsNatural.hasOwnProperty(options.visit)) {
  7457. iterators = options.reverse
  7458. ? fastTraversalIteratorsReverse[options.visit]
  7459. : fastTraversalIteratorsNatural[options.visit];
  7460. } else if (!types.hasOwnProperty(options.visit)) {
  7461. throw new Error("Bad value `" + options.visit + "` for `visit` option (should be: " + Object.keys(types).join(", ") + ")");
  7462. }
  7463. enter = invokeForType(enter, options.visit);
  7464. leave = invokeForType(leave, options.visit);
  7465. }
  7466. }
  7467. if (enter === noop && leave === noop) {
  7468. throw new Error("Neither `enter` nor `leave` walker handler is set or both aren't a function");
  7469. }
  7470. if (options.reverse) {
  7471. var tmp = enter;
  7472. enter = leave;
  7473. leave = tmp;
  7474. }
  7475. walkNode(root);
  7476. };
  7477. };
  7478. }, {}], 113: [function (require, module, exports) {
  7479. var util = require("./util");
  7480. var has = Object.prototype.hasOwnProperty;
  7481. var hasNativeMap = typeof Map !== "undefined";
  7482. function ArraySet() {
  7483. this._array = [];
  7484. this._set = hasNativeMap ? new Map() : Object.create(null);
  7485. }
  7486. ArraySet.fromArray = function ArraySet_fromArray(aArray, aAllowDuplicates) {
  7487. var set = new ArraySet();
  7488. for (var i = 0, len = aArray.length; i < len; i++) {
  7489. set.add(aArray[i], aAllowDuplicates);
  7490. }
  7491. return set;
  7492. };
  7493. ArraySet.prototype.size = function ArraySet_size() {
  7494. return hasNativeMap ? this._set.size : Object.getOwnPropertyNames(this._set).length;
  7495. };
  7496. ArraySet.prototype.add = function ArraySet_add(aStr, aAllowDuplicates) {
  7497. var sStr = hasNativeMap ? aStr : util.toSetString(aStr);
  7498. var isDuplicate = hasNativeMap ? this.has(aStr) : has.call(this._set, sStr);
  7499. var idx = this._array.length;
  7500. if (!isDuplicate || aAllowDuplicates) {
  7501. this._array.push(aStr);
  7502. }
  7503. if (!isDuplicate) {
  7504. if (hasNativeMap) {
  7505. this._set.set(aStr, idx);
  7506. } else {
  7507. this._set[sStr] = idx;
  7508. }
  7509. }
  7510. };
  7511. ArraySet.prototype.has = function ArraySet_has(aStr) {
  7512. if (hasNativeMap) {
  7513. return this._set.has(aStr);
  7514. } else {
  7515. var sStr = util.toSetString(aStr);
  7516. return has.call(this._set, sStr);
  7517. }
  7518. };
  7519. ArraySet.prototype.indexOf = function ArraySet_indexOf(aStr) {
  7520. if (hasNativeMap) {
  7521. var idx = this._set.get(aStr);
  7522. if (idx >= 0) {
  7523. return idx;
  7524. }
  7525. } else {
  7526. var sStr = util.toSetString(aStr);
  7527. if (has.call(this._set, sStr)) {
  7528. return this._set[sStr];
  7529. }
  7530. }
  7531. throw new Error("\"" + aStr + "\" is not in the set.");
  7532. };
  7533. ArraySet.prototype.at = function ArraySet_at(aIdx) {
  7534. if (aIdx >= 0 && aIdx < this._array.length) {
  7535. return this._array[aIdx];
  7536. }
  7537. throw new Error("No element indexed by " + aIdx);
  7538. };
  7539. ArraySet.prototype.toArray = function ArraySet_toArray() {
  7540. return this._array.slice();
  7541. };
  7542. exports.ArraySet = ArraySet;
  7543. }, { "./util": 122 }], 114: [function (require, module, exports) {
  7544. var base64 = require("./base64");
  7545. var VLQ_BASE_SHIFT = 5;
  7546. var VLQ_BASE = 1 << VLQ_BASE_SHIFT;
  7547. var VLQ_BASE_MASK = VLQ_BASE - 1;
  7548. var VLQ_CONTINUATION_BIT = VLQ_BASE;
  7549. function toVLQSigned(aValue) {
  7550. return aValue < 0
  7551. ? ((-aValue) << 1) + 1
  7552. : (aValue << 1) + 0;
  7553. }
  7554. function fromVLQSigned(aValue) {
  7555. var isNegative = (aValue & 1) === 1;
  7556. var shifted = aValue >> 1;
  7557. return isNegative
  7558. ? -shifted
  7559. : shifted;
  7560. }
  7561. exports.encode = function base64VLQ_encode(aValue) {
  7562. var encoded = "";
  7563. var digit;
  7564. var vlq = toVLQSigned(aValue);
  7565. do {
  7566. digit = vlq & VLQ_BASE_MASK;
  7567. vlq >>>= VLQ_BASE_SHIFT;
  7568. if (vlq > 0) {
  7569. digit |= VLQ_CONTINUATION_BIT;
  7570. }
  7571. encoded += base64.encode(digit);
  7572. } while (vlq > 0);
  7573. return encoded;
  7574. };
  7575. exports.decode = function base64VLQ_decode(aStr, aIndex, aOutParam) {
  7576. var strLen = aStr.length;
  7577. var result = 0;
  7578. var shift = 0;
  7579. var continuation, digit;
  7580. do {
  7581. if (aIndex >= strLen) {
  7582. throw new Error("Expected more digits in base 64 VLQ value.");
  7583. }
  7584. digit = base64.decode(aStr.charCodeAt(aIndex++));
  7585. if (digit === -1) {
  7586. throw new Error("Invalid base64 digit: " + aStr.charAt(aIndex - 1));
  7587. }
  7588. continuation = !!(digit & VLQ_CONTINUATION_BIT);
  7589. digit &= VLQ_BASE_MASK;
  7590. result = result + (digit << shift);
  7591. shift += VLQ_BASE_SHIFT;
  7592. } while (continuation);
  7593. aOutParam.value = fromVLQSigned(result);
  7594. aOutParam.rest = aIndex;
  7595. };
  7596. }, { "./base64": 115 }], 115: [function (require, module, exports) {
  7597. var intToCharMap = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");
  7598. exports.encode = function (number) {
  7599. if (0 <= number && number < intToCharMap.length) {
  7600. return intToCharMap[number];
  7601. }
  7602. throw new TypeError("Must be between 0 and 63: " + number);
  7603. };
  7604. exports.decode = function (charCode) {
  7605. var bigA = 65; // 'A'
  7606. var bigZ = 90; // 'Z'
  7607. var littleA = 97; // 'a'
  7608. var littleZ = 122; // 'z'
  7609. var zero = 48; // '0'
  7610. var nine = 57; // '9'
  7611. var plus = 43; // '+'
  7612. var slash = 47; // '/'
  7613. var littleOffset = 26;
  7614. var numberOffset = 52;
  7615. if (bigA <= charCode && charCode <= bigZ) {
  7616. return (charCode - bigA);
  7617. }
  7618. if (littleA <= charCode && charCode <= littleZ) {
  7619. return (charCode - littleA + littleOffset);
  7620. }
  7621. if (zero <= charCode && charCode <= nine) {
  7622. return (charCode - zero + numberOffset);
  7623. }
  7624. if (charCode == plus) {
  7625. return 62;
  7626. }
  7627. if (charCode == slash) {
  7628. return 63;
  7629. }
  7630. return -1;
  7631. };
  7632. }, {}], 116: [function (require, module, exports) {
  7633. exports.GREATEST_LOWER_BOUND = 1;
  7634. exports.LEAST_UPPER_BOUND = 2;
  7635. function recursiveSearch(aLow, aHigh, aNeedle, aHaystack, aCompare, aBias) {
  7636. var mid = Math.floor((aHigh - aLow) / 2) + aLow;
  7637. var cmp = aCompare(aNeedle, aHaystack[mid], true);
  7638. if (cmp === 0) {
  7639. return mid;
  7640. }
  7641. else if (cmp > 0) {
  7642. if (aHigh - mid > 1) {
  7643. return recursiveSearch(mid, aHigh, aNeedle, aHaystack, aCompare, aBias);
  7644. }
  7645. if (aBias == exports.LEAST_UPPER_BOUND) {
  7646. return aHigh < aHaystack.length ? aHigh : -1;
  7647. } else {
  7648. return mid;
  7649. }
  7650. }
  7651. else {
  7652. if (mid - aLow > 1) {
  7653. return recursiveSearch(aLow, mid, aNeedle, aHaystack, aCompare, aBias);
  7654. }
  7655. if (aBias == exports.LEAST_UPPER_BOUND) {
  7656. return mid;
  7657. } else {
  7658. return aLow < 0 ? -1 : aLow;
  7659. }
  7660. }
  7661. }
  7662. exports.search = function search(aNeedle, aHaystack, aCompare, aBias) {
  7663. if (aHaystack.length === 0) {
  7664. return -1;
  7665. }
  7666. var index = recursiveSearch(-1, aHaystack.length, aNeedle, aHaystack,
  7667. aCompare, aBias || exports.GREATEST_LOWER_BOUND);
  7668. if (index < 0) {
  7669. return -1;
  7670. }
  7671. while (index - 1 >= 0) {
  7672. if (aCompare(aHaystack[index], aHaystack[index - 1], true) !== 0) {
  7673. break;
  7674. }
  7675. --index;
  7676. }
  7677. return index;
  7678. };
  7679. }, {}], 117: [function (require, module, exports) {
  7680. var util = require("./util");
  7681. function generatedPositionAfter(mappingA, mappingB) {
  7682. var lineA = mappingA.generatedLine;
  7683. var lineB = mappingB.generatedLine;
  7684. var columnA = mappingA.generatedColumn;
  7685. var columnB = mappingB.generatedColumn;
  7686. return lineB > lineA || lineB == lineA && columnB >= columnA ||
  7687. util.compareByGeneratedPositionsInflated(mappingA, mappingB) <= 0;
  7688. }
  7689. function MappingList() {
  7690. this._array = [];
  7691. this._sorted = true;
  7692. this._last = { generatedLine: -1, generatedColumn: 0 };
  7693. }
  7694. MappingList.prototype.unsortedForEach =
  7695. function MappingList_forEach(aCallback, aThisArg) {
  7696. this._array.forEach(aCallback, aThisArg);
  7697. };
  7698. MappingList.prototype.add = function MappingList_add(aMapping) {
  7699. if (generatedPositionAfter(this._last, aMapping)) {
  7700. this._last = aMapping;
  7701. this._array.push(aMapping);
  7702. } else {
  7703. this._sorted = false;
  7704. this._array.push(aMapping);
  7705. }
  7706. };
  7707. MappingList.prototype.toArray = function MappingList_toArray() {
  7708. if (!this._sorted) {
  7709. this._array.sort(util.compareByGeneratedPositionsInflated);
  7710. this._sorted = true;
  7711. }
  7712. return this._array;
  7713. };
  7714. exports.MappingList = MappingList;
  7715. }, { "./util": 122 }], 118: [function (require, module, exports) {
  7716. function swap(ary, x, y) {
  7717. var temp = ary[x];
  7718. ary[x] = ary[y];
  7719. ary[y] = temp;
  7720. }
  7721. function randomIntInRange(low, high) {
  7722. return Math.round(low + (Math.random() * (high - low)));
  7723. }
  7724. function doQuickSort(ary, comparator, p, r) {
  7725. if (p < r) {
  7726. var pivotIndex = randomIntInRange(p, r);
  7727. var i = p - 1;
  7728. swap(ary, pivotIndex, r);
  7729. var pivot = ary[r];
  7730. for (var j = p; j < r; j++) {
  7731. if (comparator(ary[j], pivot) <= 0) {
  7732. i += 1;
  7733. swap(ary, i, j);
  7734. }
  7735. }
  7736. swap(ary, i + 1, j);
  7737. var q = i + 1;
  7738. doQuickSort(ary, comparator, p, q - 1);
  7739. doQuickSort(ary, comparator, q + 1, r);
  7740. }
  7741. }
  7742. exports.quickSort = function (ary, comparator) {
  7743. doQuickSort(ary, comparator, 0, ary.length - 1);
  7744. };
  7745. }, {}], 119: [function (require, module, exports) {
  7746. var util = require("./util");
  7747. var binarySearch = require("./binary-search");
  7748. var ArraySet = require("./array-set").ArraySet;
  7749. var base64VLQ = require("./base64-vlq");
  7750. var quickSort = require("./quick-sort").quickSort;
  7751. function SourceMapConsumer(aSourceMap) {
  7752. var sourceMap = aSourceMap;
  7753. if (typeof aSourceMap === "string") {
  7754. sourceMap = JSON.parse(aSourceMap.replace(/^\)\]\}'/, ""));
  7755. }
  7756. return sourceMap.sections != null
  7757. ? new IndexedSourceMapConsumer(sourceMap)
  7758. : new BasicSourceMapConsumer(sourceMap);
  7759. }
  7760. SourceMapConsumer.fromSourceMap = function (aSourceMap) {
  7761. return BasicSourceMapConsumer.fromSourceMap(aSourceMap);
  7762. };
  7763. SourceMapConsumer.prototype._version = 3;
  7764. SourceMapConsumer.prototype.__generatedMappings = null;
  7765. Object.defineProperty(SourceMapConsumer.prototype, "_generatedMappings", {
  7766. get: function () {
  7767. if (!this.__generatedMappings) {
  7768. this._parseMappings(this._mappings, this.sourceRoot);
  7769. }
  7770. return this.__generatedMappings;
  7771. }
  7772. });
  7773. SourceMapConsumer.prototype.__originalMappings = null;
  7774. Object.defineProperty(SourceMapConsumer.prototype, "_originalMappings", {
  7775. get: function () {
  7776. if (!this.__originalMappings) {
  7777. this._parseMappings(this._mappings, this.sourceRoot);
  7778. }
  7779. return this.__originalMappings;
  7780. }
  7781. });
  7782. SourceMapConsumer.prototype._charIsMappingSeparator =
  7783. function SourceMapConsumer_charIsMappingSeparator(aStr, index) {
  7784. var c = aStr.charAt(index);
  7785. return c === ";" || c === ",";
  7786. };
  7787. SourceMapConsumer.prototype._parseMappings =
  7788. function SourceMapConsumer_parseMappings(aStr, aSourceRoot) {
  7789. throw new Error("Subclasses must implement _parseMappings");
  7790. };
  7791. SourceMapConsumer.GENERATED_ORDER = 1;
  7792. SourceMapConsumer.ORIGINAL_ORDER = 2;
  7793. SourceMapConsumer.GREATEST_LOWER_BOUND = 1;
  7794. SourceMapConsumer.LEAST_UPPER_BOUND = 2;
  7795. SourceMapConsumer.prototype.eachMapping =
  7796. function SourceMapConsumer_eachMapping(aCallback, aContext, aOrder) {
  7797. var context = aContext || null;
  7798. var order = aOrder || SourceMapConsumer.GENERATED_ORDER;
  7799. var mappings;
  7800. switch (order) {
  7801. case SourceMapConsumer.GENERATED_ORDER:
  7802. mappings = this._generatedMappings;
  7803. break;
  7804. case SourceMapConsumer.ORIGINAL_ORDER:
  7805. mappings = this._originalMappings;
  7806. break;
  7807. default:
  7808. throw new Error("Unknown order of iteration.");
  7809. }
  7810. var sourceRoot = this.sourceRoot;
  7811. mappings.map(function (mapping) {
  7812. var source = mapping.source === null ? null : this._sources.at(mapping.source);
  7813. if (source != null && sourceRoot != null) {
  7814. source = util.join(sourceRoot, source);
  7815. }
  7816. return {
  7817. source: source,
  7818. generatedLine: mapping.generatedLine,
  7819. generatedColumn: mapping.generatedColumn,
  7820. originalLine: mapping.originalLine,
  7821. originalColumn: mapping.originalColumn,
  7822. name: mapping.name === null ? null : this._names.at(mapping.name)
  7823. };
  7824. }, this).forEach(aCallback, context);
  7825. };
  7826. SourceMapConsumer.prototype.allGeneratedPositionsFor =
  7827. function SourceMapConsumer_allGeneratedPositionsFor(aArgs) {
  7828. var line = util.getArg(aArgs, "line");
  7829. var needle = {
  7830. source: util.getArg(aArgs, "source"),
  7831. originalLine: line,
  7832. originalColumn: util.getArg(aArgs, "column", 0)
  7833. };
  7834. if (this.sourceRoot != null) {
  7835. needle.source = util.relative(this.sourceRoot, needle.source);
  7836. }
  7837. if (!this._sources.has(needle.source)) {
  7838. return [];
  7839. }
  7840. needle.source = this._sources.indexOf(needle.source);
  7841. var mappings = [];
  7842. var index = this._findMapping(needle,
  7843. this._originalMappings,
  7844. "originalLine",
  7845. "originalColumn",
  7846. util.compareByOriginalPositions,
  7847. binarySearch.LEAST_UPPER_BOUND);
  7848. if (index >= 0) {
  7849. var mapping = this._originalMappings[index];
  7850. if (aArgs.column === undefined) {
  7851. var originalLine = mapping.originalLine;
  7852. while (mapping && mapping.originalLine === originalLine) {
  7853. mappings.push({
  7854. line: util.getArg(mapping, "generatedLine", null),
  7855. column: util.getArg(mapping, "generatedColumn", null),
  7856. lastColumn: util.getArg(mapping, "lastGeneratedColumn", null)
  7857. });
  7858. mapping = this._originalMappings[++index];
  7859. }
  7860. } else {
  7861. var originalColumn = mapping.originalColumn;
  7862. while (mapping &&
  7863. mapping.originalLine === line &&
  7864. mapping.originalColumn == originalColumn) {
  7865. mappings.push({
  7866. line: util.getArg(mapping, "generatedLine", null),
  7867. column: util.getArg(mapping, "generatedColumn", null),
  7868. lastColumn: util.getArg(mapping, "lastGeneratedColumn", null)
  7869. });
  7870. mapping = this._originalMappings[++index];
  7871. }
  7872. }
  7873. }
  7874. return mappings;
  7875. };
  7876. exports.SourceMapConsumer = SourceMapConsumer;
  7877. function BasicSourceMapConsumer(aSourceMap) {
  7878. var sourceMap = aSourceMap;
  7879. if (typeof aSourceMap === "string") {
  7880. sourceMap = JSON.parse(aSourceMap.replace(/^\)\]\}'/, ""));
  7881. }
  7882. var version = util.getArg(sourceMap, "version");
  7883. var sources = util.getArg(sourceMap, "sources");
  7884. var names = util.getArg(sourceMap, "names", []);
  7885. var sourceRoot = util.getArg(sourceMap, "sourceRoot", null);
  7886. var sourcesContent = util.getArg(sourceMap, "sourcesContent", null);
  7887. var mappings = util.getArg(sourceMap, "mappings");
  7888. var file = util.getArg(sourceMap, "file", null);
  7889. if (version != this._version) {
  7890. throw new Error("Unsupported version: " + version);
  7891. }
  7892. sources = sources
  7893. .map(String)
  7894. .map(util.normalize)
  7895. .map(function (source) {
  7896. return sourceRoot && util.isAbsolute(sourceRoot) && util.isAbsolute(source)
  7897. ? util.relative(sourceRoot, source)
  7898. : source;
  7899. });
  7900. this._names = ArraySet.fromArray(names.map(String), true);
  7901. this._sources = ArraySet.fromArray(sources, true);
  7902. this.sourceRoot = sourceRoot;
  7903. this.sourcesContent = sourcesContent;
  7904. this._mappings = mappings;
  7905. this.file = file;
  7906. }
  7907. BasicSourceMapConsumer.prototype = Object.create(SourceMapConsumer.prototype);
  7908. BasicSourceMapConsumer.prototype.consumer = SourceMapConsumer;
  7909. BasicSourceMapConsumer.fromSourceMap =
  7910. function SourceMapConsumer_fromSourceMap(aSourceMap) {
  7911. var smc = Object.create(BasicSourceMapConsumer.prototype);
  7912. var names = smc._names = ArraySet.fromArray(aSourceMap._names.toArray(), true);
  7913. var sources = smc._sources = ArraySet.fromArray(aSourceMap._sources.toArray(), true);
  7914. smc.sourceRoot = aSourceMap._sourceRoot;
  7915. smc.sourcesContent = aSourceMap._generateSourcesContent(smc._sources.toArray(),
  7916. smc.sourceRoot);
  7917. smc.file = aSourceMap._file;
  7918. var generatedMappings = aSourceMap._mappings.toArray().slice();
  7919. var destGeneratedMappings = smc.__generatedMappings = [];
  7920. var destOriginalMappings = smc.__originalMappings = [];
  7921. for (var i = 0, length = generatedMappings.length; i < length; i++) {
  7922. var srcMapping = generatedMappings[i];
  7923. var destMapping = new Mapping;
  7924. destMapping.generatedLine = srcMapping.generatedLine;
  7925. destMapping.generatedColumn = srcMapping.generatedColumn;
  7926. if (srcMapping.source) {
  7927. destMapping.source = sources.indexOf(srcMapping.source);
  7928. destMapping.originalLine = srcMapping.originalLine;
  7929. destMapping.originalColumn = srcMapping.originalColumn;
  7930. if (srcMapping.name) {
  7931. destMapping.name = names.indexOf(srcMapping.name);
  7932. }
  7933. destOriginalMappings.push(destMapping);
  7934. }
  7935. destGeneratedMappings.push(destMapping);
  7936. }
  7937. quickSort(smc.__originalMappings, util.compareByOriginalPositions);
  7938. return smc;
  7939. };
  7940. BasicSourceMapConsumer.prototype._version = 3;
  7941. Object.defineProperty(BasicSourceMapConsumer.prototype, "sources", {
  7942. get: function () {
  7943. return this._sources.toArray().map(function (s) {
  7944. return this.sourceRoot != null ? util.join(this.sourceRoot, s) : s;
  7945. }, this);
  7946. }
  7947. });
  7948. function Mapping() {
  7949. this.generatedLine = 0;
  7950. this.generatedColumn = 0;
  7951. this.source = null;
  7952. this.originalLine = null;
  7953. this.originalColumn = null;
  7954. this.name = null;
  7955. }
  7956. BasicSourceMapConsumer.prototype._parseMappings =
  7957. function SourceMapConsumer_parseMappings(aStr, aSourceRoot) {
  7958. var generatedLine = 1;
  7959. var previousGeneratedColumn = 0;
  7960. var previousOriginalLine = 0;
  7961. var previousOriginalColumn = 0;
  7962. var previousSource = 0;
  7963. var previousName = 0;
  7964. var length = aStr.length;
  7965. var index = 0;
  7966. var cachedSegments = {};
  7967. var temp = {};
  7968. var originalMappings = [];
  7969. var generatedMappings = [];
  7970. var mapping, str, segment, end, value;
  7971. while (index < length) {
  7972. if (aStr.charAt(index) === ";") {
  7973. generatedLine++;
  7974. index++;
  7975. previousGeneratedColumn = 0;
  7976. }
  7977. else if (aStr.charAt(index) === ",") {
  7978. index++;
  7979. }
  7980. else {
  7981. mapping = new Mapping();
  7982. mapping.generatedLine = generatedLine;
  7983. for (end = index; end < length; end++) {
  7984. if (this._charIsMappingSeparator(aStr, end)) {
  7985. break;
  7986. }
  7987. }
  7988. str = aStr.slice(index, end);
  7989. segment = cachedSegments[str];
  7990. if (segment) {
  7991. index += str.length;
  7992. } else {
  7993. segment = [];
  7994. while (index < end) {
  7995. base64VLQ.decode(aStr, index, temp);
  7996. value = temp.value;
  7997. index = temp.rest;
  7998. segment.push(value);
  7999. }
  8000. if (segment.length === 2) {
  8001. throw new Error("Found a source, but no line and column");
  8002. }
  8003. if (segment.length === 3) {
  8004. throw new Error("Found a source and line, but no column");
  8005. }
  8006. cachedSegments[str] = segment;
  8007. }
  8008. mapping.generatedColumn = previousGeneratedColumn + segment[0];
  8009. previousGeneratedColumn = mapping.generatedColumn;
  8010. if (segment.length > 1) {
  8011. mapping.source = previousSource + segment[1];
  8012. previousSource += segment[1];
  8013. mapping.originalLine = previousOriginalLine + segment[2];
  8014. previousOriginalLine = mapping.originalLine;
  8015. mapping.originalLine += 1;
  8016. mapping.originalColumn = previousOriginalColumn + segment[3];
  8017. previousOriginalColumn = mapping.originalColumn;
  8018. if (segment.length > 4) {
  8019. mapping.name = previousName + segment[4];
  8020. previousName += segment[4];
  8021. }
  8022. }
  8023. generatedMappings.push(mapping);
  8024. if (typeof mapping.originalLine === "number") {
  8025. originalMappings.push(mapping);
  8026. }
  8027. }
  8028. }
  8029. quickSort(generatedMappings, util.compareByGeneratedPositionsDeflated);
  8030. this.__generatedMappings = generatedMappings;
  8031. quickSort(originalMappings, util.compareByOriginalPositions);
  8032. this.__originalMappings = originalMappings;
  8033. };
  8034. BasicSourceMapConsumer.prototype._findMapping =
  8035. function SourceMapConsumer_findMapping(aNeedle, aMappings, aLineName,
  8036. aColumnName, aComparator, aBias) {
  8037. if (aNeedle[aLineName] <= 0) {
  8038. throw new TypeError("Line must be greater than or equal to 1, got "
  8039. + aNeedle[aLineName]);
  8040. }
  8041. if (aNeedle[aColumnName] < 0) {
  8042. throw new TypeError("Column must be greater than or equal to 0, got "
  8043. + aNeedle[aColumnName]);
  8044. }
  8045. return binarySearch.search(aNeedle, aMappings, aComparator, aBias);
  8046. };
  8047. BasicSourceMapConsumer.prototype.computeColumnSpans =
  8048. function SourceMapConsumer_computeColumnSpans() {
  8049. for (var index = 0; index < this._generatedMappings.length; ++index) {
  8050. var mapping = this._generatedMappings[index];
  8051. if (index + 1 < this._generatedMappings.length) {
  8052. var nextMapping = this._generatedMappings[index + 1];
  8053. if (mapping.generatedLine === nextMapping.generatedLine) {
  8054. mapping.lastGeneratedColumn = nextMapping.generatedColumn - 1;
  8055. continue;
  8056. }
  8057. }
  8058. mapping.lastGeneratedColumn = Infinity;
  8059. }
  8060. };
  8061. BasicSourceMapConsumer.prototype.originalPositionFor =
  8062. function SourceMapConsumer_originalPositionFor(aArgs) {
  8063. var needle = {
  8064. generatedLine: util.getArg(aArgs, "line"),
  8065. generatedColumn: util.getArg(aArgs, "column")
  8066. };
  8067. var index = this._findMapping(
  8068. needle,
  8069. this._generatedMappings,
  8070. "generatedLine",
  8071. "generatedColumn",
  8072. util.compareByGeneratedPositionsDeflated,
  8073. util.getArg(aArgs, "bias", SourceMapConsumer.GREATEST_LOWER_BOUND)
  8074. );
  8075. if (index >= 0) {
  8076. var mapping = this._generatedMappings[index];
  8077. if (mapping.generatedLine === needle.generatedLine) {
  8078. var source = util.getArg(mapping, "source", null);
  8079. if (source !== null) {
  8080. source = this._sources.at(source);
  8081. if (this.sourceRoot != null) {
  8082. source = util.join(this.sourceRoot, source);
  8083. }
  8084. }
  8085. var name = util.getArg(mapping, "name", null);
  8086. if (name !== null) {
  8087. name = this._names.at(name);
  8088. }
  8089. return {
  8090. source: source,
  8091. line: util.getArg(mapping, "originalLine", null),
  8092. column: util.getArg(mapping, "originalColumn", null),
  8093. name: name
  8094. };
  8095. }
  8096. }
  8097. return {
  8098. source: null,
  8099. line: null,
  8100. column: null,
  8101. name: null
  8102. };
  8103. };
  8104. BasicSourceMapConsumer.prototype.hasContentsOfAllSources =
  8105. function BasicSourceMapConsumer_hasContentsOfAllSources() {
  8106. if (!this.sourcesContent) {
  8107. return false;
  8108. }
  8109. return this.sourcesContent.length >= this._sources.size() &&
  8110. !this.sourcesContent.some(function (sc) { return sc == null; });
  8111. };
  8112. BasicSourceMapConsumer.prototype.sourceContentFor =
  8113. function SourceMapConsumer_sourceContentFor(aSource, nullOnMissing) {
  8114. if (!this.sourcesContent) {
  8115. return null;
  8116. }
  8117. if (this.sourceRoot != null) {
  8118. aSource = util.relative(this.sourceRoot, aSource);
  8119. }
  8120. if (this._sources.has(aSource)) {
  8121. return this.sourcesContent[this._sources.indexOf(aSource)];
  8122. }
  8123. var url;
  8124. if (this.sourceRoot != null
  8125. && (url = util.urlParse(this.sourceRoot))) {
  8126. var fileUriAbsPath = aSource.replace(/^file:\/\//, "");
  8127. if (url.scheme == "file"
  8128. && this._sources.has(fileUriAbsPath)) {
  8129. return this.sourcesContent[this._sources.indexOf(fileUriAbsPath)];
  8130. }
  8131. if ((!url.path || url.path == "/")
  8132. && this._sources.has("/" + aSource)) {
  8133. return this.sourcesContent[this._sources.indexOf("/" + aSource)];
  8134. }
  8135. }
  8136. if (nullOnMissing) {
  8137. return null;
  8138. }
  8139. else {
  8140. throw new Error("\"" + aSource + "\" is not in the SourceMap.");
  8141. }
  8142. };
  8143. BasicSourceMapConsumer.prototype.generatedPositionFor =
  8144. function SourceMapConsumer_generatedPositionFor(aArgs) {
  8145. var source = util.getArg(aArgs, "source");
  8146. if (this.sourceRoot != null) {
  8147. source = util.relative(this.sourceRoot, source);
  8148. }
  8149. if (!this._sources.has(source)) {
  8150. return {
  8151. line: null,
  8152. column: null,
  8153. lastColumn: null
  8154. };
  8155. }
  8156. source = this._sources.indexOf(source);
  8157. var needle = {
  8158. source: source,
  8159. originalLine: util.getArg(aArgs, "line"),
  8160. originalColumn: util.getArg(aArgs, "column")
  8161. };
  8162. var index = this._findMapping(
  8163. needle,
  8164. this._originalMappings,
  8165. "originalLine",
  8166. "originalColumn",
  8167. util.compareByOriginalPositions,
  8168. util.getArg(aArgs, "bias", SourceMapConsumer.GREATEST_LOWER_BOUND)
  8169. );
  8170. if (index >= 0) {
  8171. var mapping = this._originalMappings[index];
  8172. if (mapping.source === needle.source) {
  8173. return {
  8174. line: util.getArg(mapping, "generatedLine", null),
  8175. column: util.getArg(mapping, "generatedColumn", null),
  8176. lastColumn: util.getArg(mapping, "lastGeneratedColumn", null)
  8177. };
  8178. }
  8179. }
  8180. return {
  8181. line: null,
  8182. column: null,
  8183. lastColumn: null
  8184. };
  8185. };
  8186. exports.BasicSourceMapConsumer = BasicSourceMapConsumer;
  8187. function IndexedSourceMapConsumer(aSourceMap) {
  8188. var sourceMap = aSourceMap;
  8189. if (typeof aSourceMap === "string") {
  8190. sourceMap = JSON.parse(aSourceMap.replace(/^\)\]\}'/, ""));
  8191. }
  8192. var version = util.getArg(sourceMap, "version");
  8193. var sections = util.getArg(sourceMap, "sections");
  8194. if (version != this._version) {
  8195. throw new Error("Unsupported version: " + version);
  8196. }
  8197. this._sources = new ArraySet();
  8198. this._names = new ArraySet();
  8199. var lastOffset = {
  8200. line: -1,
  8201. column: 0
  8202. };
  8203. this._sections = sections.map(function (s) {
  8204. if (s.url) {
  8205. throw new Error("Support for url field in sections not implemented.");
  8206. }
  8207. var offset = util.getArg(s, "offset");
  8208. var offsetLine = util.getArg(offset, "line");
  8209. var offsetColumn = util.getArg(offset, "column");
  8210. if (offsetLine < lastOffset.line ||
  8211. (offsetLine === lastOffset.line && offsetColumn < lastOffset.column)) {
  8212. throw new Error("Section offsets must be ordered and non-overlapping.");
  8213. }
  8214. lastOffset = offset;
  8215. return {
  8216. generatedOffset: {
  8217. generatedLine: offsetLine + 1,
  8218. generatedColumn: offsetColumn + 1
  8219. },
  8220. consumer: new SourceMapConsumer(util.getArg(s, "map"))
  8221. };
  8222. });
  8223. }
  8224. IndexedSourceMapConsumer.prototype = Object.create(SourceMapConsumer.prototype);
  8225. IndexedSourceMapConsumer.prototype.constructor = SourceMapConsumer;
  8226. IndexedSourceMapConsumer.prototype._version = 3;
  8227. Object.defineProperty(IndexedSourceMapConsumer.prototype, "sources", {
  8228. get: function () {
  8229. var sources = [];
  8230. for (var i = 0; i < this._sections.length; i++) {
  8231. for (var j = 0; j < this._sections[i].consumer.sources.length; j++) {
  8232. sources.push(this._sections[i].consumer.sources[j]);
  8233. }
  8234. }
  8235. return sources;
  8236. }
  8237. });
  8238. IndexedSourceMapConsumer.prototype.originalPositionFor =
  8239. function IndexedSourceMapConsumer_originalPositionFor(aArgs) {
  8240. var needle = {
  8241. generatedLine: util.getArg(aArgs, "line"),
  8242. generatedColumn: util.getArg(aArgs, "column")
  8243. };
  8244. var sectionIndex = binarySearch.search(needle, this._sections,
  8245. function (needle, section) {
  8246. var cmp = needle.generatedLine - section.generatedOffset.generatedLine;
  8247. if (cmp) {
  8248. return cmp;
  8249. }
  8250. return (needle.generatedColumn -
  8251. section.generatedOffset.generatedColumn);
  8252. });
  8253. var section = this._sections[sectionIndex];
  8254. if (!section) {
  8255. return {
  8256. source: null,
  8257. line: null,
  8258. column: null,
  8259. name: null
  8260. };
  8261. }
  8262. return section.consumer.originalPositionFor({
  8263. line: needle.generatedLine -
  8264. (section.generatedOffset.generatedLine - 1),
  8265. column: needle.generatedColumn -
  8266. (section.generatedOffset.generatedLine === needle.generatedLine
  8267. ? section.generatedOffset.generatedColumn - 1
  8268. : 0),
  8269. bias: aArgs.bias
  8270. });
  8271. };
  8272. IndexedSourceMapConsumer.prototype.hasContentsOfAllSources =
  8273. function IndexedSourceMapConsumer_hasContentsOfAllSources() {
  8274. return this._sections.every(function (s) {
  8275. return s.consumer.hasContentsOfAllSources();
  8276. });
  8277. };
  8278. IndexedSourceMapConsumer.prototype.sourceContentFor =
  8279. function IndexedSourceMapConsumer_sourceContentFor(aSource, nullOnMissing) {
  8280. for (var i = 0; i < this._sections.length; i++) {
  8281. var section = this._sections[i];
  8282. var content = section.consumer.sourceContentFor(aSource, true);
  8283. if (content) {
  8284. return content;
  8285. }
  8286. }
  8287. if (nullOnMissing) {
  8288. return null;
  8289. }
  8290. else {
  8291. throw new Error("\"" + aSource + "\" is not in the SourceMap.");
  8292. }
  8293. };
  8294. IndexedSourceMapConsumer.prototype.generatedPositionFor =
  8295. function IndexedSourceMapConsumer_generatedPositionFor(aArgs) {
  8296. for (var i = 0; i < this._sections.length; i++) {
  8297. var section = this._sections[i];
  8298. if (section.consumer.sources.indexOf(util.getArg(aArgs, "source")) === -1) {
  8299. continue;
  8300. }
  8301. var generatedPosition = section.consumer.generatedPositionFor(aArgs);
  8302. if (generatedPosition) {
  8303. var ret = {
  8304. line: generatedPosition.line +
  8305. (section.generatedOffset.generatedLine - 1),
  8306. column: generatedPosition.column +
  8307. (section.generatedOffset.generatedLine === generatedPosition.line
  8308. ? section.generatedOffset.generatedColumn - 1
  8309. : 0)
  8310. };
  8311. return ret;
  8312. }
  8313. }
  8314. return {
  8315. line: null,
  8316. column: null
  8317. };
  8318. };
  8319. IndexedSourceMapConsumer.prototype._parseMappings =
  8320. function IndexedSourceMapConsumer_parseMappings(aStr, aSourceRoot) {
  8321. this.__generatedMappings = [];
  8322. this.__originalMappings = [];
  8323. for (var i = 0; i < this._sections.length; i++) {
  8324. var section = this._sections[i];
  8325. var sectionMappings = section.consumer._generatedMappings;
  8326. for (var j = 0; j < sectionMappings.length; j++) {
  8327. var mapping = sectionMappings[j];
  8328. var source = section.consumer._sources.at(mapping.source);
  8329. if (section.consumer.sourceRoot !== null) {
  8330. source = util.join(section.consumer.sourceRoot, source);
  8331. }
  8332. this._sources.add(source);
  8333. source = this._sources.indexOf(source);
  8334. var name = section.consumer._names.at(mapping.name);
  8335. this._names.add(name);
  8336. name = this._names.indexOf(name);
  8337. var adjustedMapping = {
  8338. source: source,
  8339. generatedLine: mapping.generatedLine +
  8340. (section.generatedOffset.generatedLine - 1),
  8341. generatedColumn: mapping.generatedColumn +
  8342. (section.generatedOffset.generatedLine === mapping.generatedLine
  8343. ? section.generatedOffset.generatedColumn - 1
  8344. : 0),
  8345. originalLine: mapping.originalLine,
  8346. originalColumn: mapping.originalColumn,
  8347. name: name
  8348. };
  8349. this.__generatedMappings.push(adjustedMapping);
  8350. if (typeof adjustedMapping.originalLine === "number") {
  8351. this.__originalMappings.push(adjustedMapping);
  8352. }
  8353. }
  8354. }
  8355. quickSort(this.__generatedMappings, util.compareByGeneratedPositionsDeflated);
  8356. quickSort(this.__originalMappings, util.compareByOriginalPositions);
  8357. };
  8358. exports.IndexedSourceMapConsumer = IndexedSourceMapConsumer;
  8359. }, { "./array-set": 113, "./base64-vlq": 114, "./binary-search": 116, "./quick-sort": 118, "./util": 122 }], 120: [function (require, module, exports) {
  8360. var base64VLQ = require("./base64-vlq");
  8361. var util = require("./util");
  8362. var ArraySet = require("./array-set").ArraySet;
  8363. var MappingList = require("./mapping-list").MappingList;
  8364. function SourceMapGenerator(aArgs) {
  8365. if (!aArgs) {
  8366. aArgs = {};
  8367. }
  8368. this._file = util.getArg(aArgs, "file", null);
  8369. this._sourceRoot = util.getArg(aArgs, "sourceRoot", null);
  8370. this._skipValidation = util.getArg(aArgs, "skipValidation", false);
  8371. this._sources = new ArraySet();
  8372. this._names = new ArraySet();
  8373. this._mappings = new MappingList();
  8374. this._sourcesContents = null;
  8375. }
  8376. SourceMapGenerator.prototype._version = 3;
  8377. SourceMapGenerator.fromSourceMap =
  8378. function SourceMapGenerator_fromSourceMap(aSourceMapConsumer) {
  8379. var sourceRoot = aSourceMapConsumer.sourceRoot;
  8380. var generator = new SourceMapGenerator({
  8381. file: aSourceMapConsumer.file,
  8382. sourceRoot: sourceRoot
  8383. });
  8384. aSourceMapConsumer.eachMapping(function (mapping) {
  8385. var newMapping = {
  8386. generated: {
  8387. line: mapping.generatedLine,
  8388. column: mapping.generatedColumn
  8389. }
  8390. };
  8391. if (mapping.source != null) {
  8392. newMapping.source = mapping.source;
  8393. if (sourceRoot != null) {
  8394. newMapping.source = util.relative(sourceRoot, newMapping.source);
  8395. }
  8396. newMapping.original = {
  8397. line: mapping.originalLine,
  8398. column: mapping.originalColumn
  8399. };
  8400. if (mapping.name != null) {
  8401. newMapping.name = mapping.name;
  8402. }
  8403. }
  8404. generator.addMapping(newMapping);
  8405. });
  8406. aSourceMapConsumer.sources.forEach(function (sourceFile) {
  8407. var content = aSourceMapConsumer.sourceContentFor(sourceFile);
  8408. if (content != null) {
  8409. generator.setSourceContent(sourceFile, content);
  8410. }
  8411. });
  8412. return generator;
  8413. };
  8414. SourceMapGenerator.prototype.addMapping =
  8415. function SourceMapGenerator_addMapping(aArgs) {
  8416. var generated = util.getArg(aArgs, "generated");
  8417. var original = util.getArg(aArgs, "original", null);
  8418. var source = util.getArg(aArgs, "source", null);
  8419. var name = util.getArg(aArgs, "name", null);
  8420. if (!this._skipValidation) {
  8421. this._validateMapping(generated, original, source, name);
  8422. }
  8423. if (source != null) {
  8424. source = String(source);
  8425. if (!this._sources.has(source)) {
  8426. this._sources.add(source);
  8427. }
  8428. }
  8429. if (name != null) {
  8430. name = String(name);
  8431. if (!this._names.has(name)) {
  8432. this._names.add(name);
  8433. }
  8434. }
  8435. this._mappings.add({
  8436. generatedLine: generated.line,
  8437. generatedColumn: generated.column,
  8438. originalLine: original != null && original.line,
  8439. originalColumn: original != null && original.column,
  8440. source: source,
  8441. name: name
  8442. });
  8443. };
  8444. SourceMapGenerator.prototype.setSourceContent =
  8445. function SourceMapGenerator_setSourceContent(aSourceFile, aSourceContent) {
  8446. var source = aSourceFile;
  8447. if (this._sourceRoot != null) {
  8448. source = util.relative(this._sourceRoot, source);
  8449. }
  8450. if (aSourceContent != null) {
  8451. if (!this._sourcesContents) {
  8452. this._sourcesContents = Object.create(null);
  8453. }
  8454. this._sourcesContents[util.toSetString(source)] = aSourceContent;
  8455. } else if (this._sourcesContents) {
  8456. delete this._sourcesContents[util.toSetString(source)];
  8457. if (Object.keys(this._sourcesContents).length === 0) {
  8458. this._sourcesContents = null;
  8459. }
  8460. }
  8461. };
  8462. SourceMapGenerator.prototype.applySourceMap =
  8463. function SourceMapGenerator_applySourceMap(aSourceMapConsumer, aSourceFile, aSourceMapPath) {
  8464. var sourceFile = aSourceFile;
  8465. if (aSourceFile == null) {
  8466. if (aSourceMapConsumer.file == null) {
  8467. throw new Error(
  8468. "SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, " +
  8469. "or the source map's \"file\" property. Both were omitted."
  8470. );
  8471. }
  8472. sourceFile = aSourceMapConsumer.file;
  8473. }
  8474. var sourceRoot = this._sourceRoot;
  8475. if (sourceRoot != null) {
  8476. sourceFile = util.relative(sourceRoot, sourceFile);
  8477. }
  8478. var newSources = new ArraySet();
  8479. var newNames = new ArraySet();
  8480. this._mappings.unsortedForEach(function (mapping) {
  8481. if (mapping.source === sourceFile && mapping.originalLine != null) {
  8482. var original = aSourceMapConsumer.originalPositionFor({
  8483. line: mapping.originalLine,
  8484. column: mapping.originalColumn
  8485. });
  8486. if (original.source != null) {
  8487. mapping.source = original.source;
  8488. if (aSourceMapPath != null) {
  8489. mapping.source = util.join(aSourceMapPath, mapping.source);
  8490. }
  8491. if (sourceRoot != null) {
  8492. mapping.source = util.relative(sourceRoot, mapping.source);
  8493. }
  8494. mapping.originalLine = original.line;
  8495. mapping.originalColumn = original.column;
  8496. if (original.name != null) {
  8497. mapping.name = original.name;
  8498. }
  8499. }
  8500. }
  8501. var source = mapping.source;
  8502. if (source != null && !newSources.has(source)) {
  8503. newSources.add(source);
  8504. }
  8505. var name = mapping.name;
  8506. if (name != null && !newNames.has(name)) {
  8507. newNames.add(name);
  8508. }
  8509. }, this);
  8510. this._sources = newSources;
  8511. this._names = newNames;
  8512. aSourceMapConsumer.sources.forEach(function (sourceFile) {
  8513. var content = aSourceMapConsumer.sourceContentFor(sourceFile);
  8514. if (content != null) {
  8515. if (aSourceMapPath != null) {
  8516. sourceFile = util.join(aSourceMapPath, sourceFile);
  8517. }
  8518. if (sourceRoot != null) {
  8519. sourceFile = util.relative(sourceRoot, sourceFile);
  8520. }
  8521. this.setSourceContent(sourceFile, content);
  8522. }
  8523. }, this);
  8524. };
  8525. SourceMapGenerator.prototype._validateMapping =
  8526. function SourceMapGenerator_validateMapping(aGenerated, aOriginal, aSource,
  8527. aName) {
  8528. if (aOriginal && typeof aOriginal.line !== "number" && typeof aOriginal.column !== "number") {
  8529. throw new Error(
  8530. "original.line and original.column are not numbers -- you probably meant to omit " +
  8531. "the original mapping entirely and only map the generated position. If so, pass " +
  8532. "null for the original mapping instead of an object with empty or null values."
  8533. );
  8534. }
  8535. if (aGenerated && "line" in aGenerated && "column" in aGenerated
  8536. && aGenerated.line > 0 && aGenerated.column >= 0
  8537. && !aOriginal && !aSource && !aName) {
  8538. return;
  8539. }
  8540. else if (aGenerated && "line" in aGenerated && "column" in aGenerated
  8541. && aOriginal && "line" in aOriginal && "column" in aOriginal
  8542. && aGenerated.line > 0 && aGenerated.column >= 0
  8543. && aOriginal.line > 0 && aOriginal.column >= 0
  8544. && aSource) {
  8545. return;
  8546. }
  8547. else {
  8548. throw new Error("Invalid mapping: " + JSON.stringify({
  8549. generated: aGenerated,
  8550. source: aSource,
  8551. original: aOriginal,
  8552. name: aName
  8553. }));
  8554. }
  8555. };
  8556. SourceMapGenerator.prototype._serializeMappings =
  8557. function SourceMapGenerator_serializeMappings() {
  8558. var previousGeneratedColumn = 0;
  8559. var previousGeneratedLine = 1;
  8560. var previousOriginalColumn = 0;
  8561. var previousOriginalLine = 0;
  8562. var previousName = 0;
  8563. var previousSource = 0;
  8564. var result = "";
  8565. var next;
  8566. var mapping;
  8567. var nameIdx;
  8568. var sourceIdx;
  8569. var mappings = this._mappings.toArray();
  8570. for (var i = 0, len = mappings.length; i < len; i++) {
  8571. mapping = mappings[i];
  8572. next = "";
  8573. if (mapping.generatedLine !== previousGeneratedLine) {
  8574. previousGeneratedColumn = 0;
  8575. while (mapping.generatedLine !== previousGeneratedLine) {
  8576. next += ";";
  8577. previousGeneratedLine++;
  8578. }
  8579. }
  8580. else {
  8581. if (i > 0) {
  8582. if (!util.compareByGeneratedPositionsInflated(mapping, mappings[i - 1])) {
  8583. continue;
  8584. }
  8585. next += ",";
  8586. }
  8587. }
  8588. next += base64VLQ.encode(mapping.generatedColumn
  8589. - previousGeneratedColumn);
  8590. previousGeneratedColumn = mapping.generatedColumn;
  8591. if (mapping.source != null) {
  8592. sourceIdx = this._sources.indexOf(mapping.source);
  8593. next += base64VLQ.encode(sourceIdx - previousSource);
  8594. previousSource = sourceIdx;
  8595. next += base64VLQ.encode(mapping.originalLine - 1
  8596. - previousOriginalLine);
  8597. previousOriginalLine = mapping.originalLine - 1;
  8598. next += base64VLQ.encode(mapping.originalColumn
  8599. - previousOriginalColumn);
  8600. previousOriginalColumn = mapping.originalColumn;
  8601. if (mapping.name != null) {
  8602. nameIdx = this._names.indexOf(mapping.name);
  8603. next += base64VLQ.encode(nameIdx - previousName);
  8604. previousName = nameIdx;
  8605. }
  8606. }
  8607. result += next;
  8608. }
  8609. return result;
  8610. };
  8611. SourceMapGenerator.prototype._generateSourcesContent =
  8612. function SourceMapGenerator_generateSourcesContent(aSources, aSourceRoot) {
  8613. return aSources.map(function (source) {
  8614. if (!this._sourcesContents) {
  8615. return null;
  8616. }
  8617. if (aSourceRoot != null) {
  8618. source = util.relative(aSourceRoot, source);
  8619. }
  8620. var key = util.toSetString(source);
  8621. return Object.prototype.hasOwnProperty.call(this._sourcesContents, key)
  8622. ? this._sourcesContents[key]
  8623. : null;
  8624. }, this);
  8625. };
  8626. SourceMapGenerator.prototype.toJSON =
  8627. function SourceMapGenerator_toJSON() {
  8628. var map = {
  8629. version: this._version,
  8630. sources: this._sources.toArray(),
  8631. names: this._names.toArray(),
  8632. mappings: this._serializeMappings()
  8633. };
  8634. if (this._file != null) {
  8635. map.file = this._file;
  8636. }
  8637. if (this._sourceRoot != null) {
  8638. map.sourceRoot = this._sourceRoot;
  8639. }
  8640. if (this._sourcesContents) {
  8641. map.sourcesContent = this._generateSourcesContent(map.sources, map.sourceRoot);
  8642. }
  8643. return map;
  8644. };
  8645. SourceMapGenerator.prototype.toString =
  8646. function SourceMapGenerator_toString() {
  8647. return JSON.stringify(this.toJSON());
  8648. };
  8649. exports.SourceMapGenerator = SourceMapGenerator;
  8650. }, { "./array-set": 113, "./base64-vlq": 114, "./mapping-list": 117, "./util": 122 }], 121: [function (require, module, exports) {
  8651. var SourceMapGenerator = require("./source-map-generator").SourceMapGenerator;
  8652. var util = require("./util");
  8653. var REGEX_NEWLINE = /(\r?\n)/;
  8654. var NEWLINE_CODE = 10;
  8655. var isSourceNode = "$$$isSourceNode$$$";
  8656. function SourceNode(aLine, aColumn, aSource, aChunks, aName) {
  8657. this.children = [];
  8658. this.sourceContents = {};
  8659. this.line = aLine == null ? null : aLine;
  8660. this.column = aColumn == null ? null : aColumn;
  8661. this.source = aSource == null ? null : aSource;
  8662. this.name = aName == null ? null : aName;
  8663. this[isSourceNode] = true;
  8664. if (aChunks != null) this.add(aChunks);
  8665. }
  8666. SourceNode.fromStringWithSourceMap =
  8667. function SourceNode_fromStringWithSourceMap(aGeneratedCode, aSourceMapConsumer, aRelativePath) {
  8668. var node = new SourceNode();
  8669. var remainingLines = aGeneratedCode.split(REGEX_NEWLINE);
  8670. var remainingLinesIndex = 0;
  8671. var shiftNextLine = function () {
  8672. var lineContents = getNextLine();
  8673. var newLine = getNextLine() || "";
  8674. return lineContents + newLine;
  8675. function getNextLine() {
  8676. return remainingLinesIndex < remainingLines.length ?
  8677. remainingLines[remainingLinesIndex++] : undefined;
  8678. }
  8679. };
  8680. var lastGeneratedLine = 1, lastGeneratedColumn = 0;
  8681. var lastMapping = null;
  8682. aSourceMapConsumer.eachMapping(function (mapping) {
  8683. if (lastMapping !== null) {
  8684. if (lastGeneratedLine < mapping.generatedLine) {
  8685. addMappingWithCode(lastMapping, shiftNextLine());
  8686. lastGeneratedLine++;
  8687. lastGeneratedColumn = 0;
  8688. } else {
  8689. var nextLine = remainingLines[remainingLinesIndex];
  8690. var code = nextLine.substr(0, mapping.generatedColumn -
  8691. lastGeneratedColumn);
  8692. remainingLines[remainingLinesIndex] = nextLine.substr(mapping.generatedColumn -
  8693. lastGeneratedColumn);
  8694. lastGeneratedColumn = mapping.generatedColumn;
  8695. addMappingWithCode(lastMapping, code);
  8696. lastMapping = mapping;
  8697. return;
  8698. }
  8699. }
  8700. while (lastGeneratedLine < mapping.generatedLine) {
  8701. node.add(shiftNextLine());
  8702. lastGeneratedLine++;
  8703. }
  8704. if (lastGeneratedColumn < mapping.generatedColumn) {
  8705. var nextLine = remainingLines[remainingLinesIndex];
  8706. node.add(nextLine.substr(0, mapping.generatedColumn));
  8707. remainingLines[remainingLinesIndex] = nextLine.substr(mapping.generatedColumn);
  8708. lastGeneratedColumn = mapping.generatedColumn;
  8709. }
  8710. lastMapping = mapping;
  8711. }, this);
  8712. if (remainingLinesIndex < remainingLines.length) {
  8713. if (lastMapping) {
  8714. addMappingWithCode(lastMapping, shiftNextLine());
  8715. }
  8716. node.add(remainingLines.splice(remainingLinesIndex).join(""));
  8717. }
  8718. aSourceMapConsumer.sources.forEach(function (sourceFile) {
  8719. var content = aSourceMapConsumer.sourceContentFor(sourceFile);
  8720. if (content != null) {
  8721. if (aRelativePath != null) {
  8722. sourceFile = util.join(aRelativePath, sourceFile);
  8723. }
  8724. node.setSourceContent(sourceFile, content);
  8725. }
  8726. });
  8727. return node;
  8728. function addMappingWithCode(mapping, code) {
  8729. if (mapping === null || mapping.source === undefined) {
  8730. node.add(code);
  8731. } else {
  8732. var source = aRelativePath
  8733. ? util.join(aRelativePath, mapping.source)
  8734. : mapping.source;
  8735. node.add(new SourceNode(mapping.originalLine,
  8736. mapping.originalColumn,
  8737. source,
  8738. code,
  8739. mapping.name));
  8740. }
  8741. }
  8742. };
  8743. SourceNode.prototype.add = function SourceNode_add(aChunk) {
  8744. if (Array.isArray(aChunk)) {
  8745. aChunk.forEach(function (chunk) {
  8746. this.add(chunk);
  8747. }, this);
  8748. }
  8749. else if (aChunk[isSourceNode] || typeof aChunk === "string") {
  8750. if (aChunk) {
  8751. this.children.push(aChunk);
  8752. }
  8753. }
  8754. else {
  8755. throw new TypeError(
  8756. "Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk
  8757. );
  8758. }
  8759. return this;
  8760. };
  8761. SourceNode.prototype.prepend = function SourceNode_prepend(aChunk) {
  8762. if (Array.isArray(aChunk)) {
  8763. for (var i = aChunk.length - 1; i >= 0; i--) {
  8764. this.prepend(aChunk[i]);
  8765. }
  8766. }
  8767. else if (aChunk[isSourceNode] || typeof aChunk === "string") {
  8768. this.children.unshift(aChunk);
  8769. }
  8770. else {
  8771. throw new TypeError(
  8772. "Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk
  8773. );
  8774. }
  8775. return this;
  8776. };
  8777. SourceNode.prototype.walk = function SourceNode_walk(aFn) {
  8778. var chunk;
  8779. for (var i = 0, len = this.children.length; i < len; i++) {
  8780. chunk = this.children[i];
  8781. if (chunk[isSourceNode]) {
  8782. chunk.walk(aFn);
  8783. }
  8784. else {
  8785. if (chunk !== "") {
  8786. aFn(chunk, {
  8787. source: this.source,
  8788. line: this.line,
  8789. column: this.column,
  8790. name: this.name
  8791. });
  8792. }
  8793. }
  8794. }
  8795. };
  8796. SourceNode.prototype.join = function SourceNode_join(aSep) {
  8797. var newChildren;
  8798. var i;
  8799. var len = this.children.length;
  8800. if (len > 0) {
  8801. newChildren = [];
  8802. for (i = 0; i < len - 1; i++) {
  8803. newChildren.push(this.children[i]);
  8804. newChildren.push(aSep);
  8805. }
  8806. newChildren.push(this.children[i]);
  8807. this.children = newChildren;
  8808. }
  8809. return this;
  8810. };
  8811. SourceNode.prototype.replaceRight = function SourceNode_replaceRight(aPattern, aReplacement) {
  8812. var lastChild = this.children[this.children.length - 1];
  8813. if (lastChild[isSourceNode]) {
  8814. lastChild.replaceRight(aPattern, aReplacement);
  8815. }
  8816. else if (typeof lastChild === "string") {
  8817. this.children[this.children.length - 1] = lastChild.replace(aPattern, aReplacement);
  8818. }
  8819. else {
  8820. this.children.push("".replace(aPattern, aReplacement));
  8821. }
  8822. return this;
  8823. };
  8824. SourceNode.prototype.setSourceContent =
  8825. function SourceNode_setSourceContent(aSourceFile, aSourceContent) {
  8826. this.sourceContents[util.toSetString(aSourceFile)] = aSourceContent;
  8827. };
  8828. SourceNode.prototype.walkSourceContents =
  8829. function SourceNode_walkSourceContents(aFn) {
  8830. for (var i = 0, len = this.children.length; i < len; i++) {
  8831. if (this.children[i][isSourceNode]) {
  8832. this.children[i].walkSourceContents(aFn);
  8833. }
  8834. }
  8835. var sources = Object.keys(this.sourceContents);
  8836. for (var i = 0, len = sources.length; i < len; i++) {
  8837. aFn(util.fromSetString(sources[i]), this.sourceContents[sources[i]]);
  8838. }
  8839. };
  8840. SourceNode.prototype.toString = function SourceNode_toString() {
  8841. var str = "";
  8842. this.walk(function (chunk) {
  8843. str += chunk;
  8844. });
  8845. return str;
  8846. };
  8847. SourceNode.prototype.toStringWithSourceMap = function SourceNode_toStringWithSourceMap(aArgs) {
  8848. var generated = {
  8849. code: "",
  8850. line: 1,
  8851. column: 0
  8852. };
  8853. var map = new SourceMapGenerator(aArgs);
  8854. var sourceMappingActive = false;
  8855. var lastOriginalSource = null;
  8856. var lastOriginalLine = null;
  8857. var lastOriginalColumn = null;
  8858. var lastOriginalName = null;
  8859. this.walk(function (chunk, original) {
  8860. generated.code += chunk;
  8861. if (original.source !== null
  8862. && original.line !== null
  8863. && original.column !== null) {
  8864. if (lastOriginalSource !== original.source
  8865. || lastOriginalLine !== original.line
  8866. || lastOriginalColumn !== original.column
  8867. || lastOriginalName !== original.name) {
  8868. map.addMapping({
  8869. source: original.source,
  8870. original: {
  8871. line: original.line,
  8872. column: original.column
  8873. },
  8874. generated: {
  8875. line: generated.line,
  8876. column: generated.column
  8877. },
  8878. name: original.name
  8879. });
  8880. }
  8881. lastOriginalSource = original.source;
  8882. lastOriginalLine = original.line;
  8883. lastOriginalColumn = original.column;
  8884. lastOriginalName = original.name;
  8885. sourceMappingActive = true;
  8886. } else if (sourceMappingActive) {
  8887. map.addMapping({
  8888. generated: {
  8889. line: generated.line,
  8890. column: generated.column
  8891. }
  8892. });
  8893. lastOriginalSource = null;
  8894. sourceMappingActive = false;
  8895. }
  8896. for (var idx = 0, length = chunk.length; idx < length; idx++) {
  8897. if (chunk.charCodeAt(idx) === NEWLINE_CODE) {
  8898. generated.line++;
  8899. generated.column = 0;
  8900. if (idx + 1 === length) {
  8901. lastOriginalSource = null;
  8902. sourceMappingActive = false;
  8903. } else if (sourceMappingActive) {
  8904. map.addMapping({
  8905. source: original.source,
  8906. original: {
  8907. line: original.line,
  8908. column: original.column
  8909. },
  8910. generated: {
  8911. line: generated.line,
  8912. column: generated.column
  8913. },
  8914. name: original.name
  8915. });
  8916. }
  8917. } else {
  8918. generated.column++;
  8919. }
  8920. }
  8921. });
  8922. this.walkSourceContents(function (sourceFile, sourceContent) {
  8923. map.setSourceContent(sourceFile, sourceContent);
  8924. });
  8925. return { code: generated.code, map: map };
  8926. };
  8927. exports.SourceNode = SourceNode;
  8928. }, { "./source-map-generator": 120, "./util": 122 }], 122: [function (require, module, exports) {
  8929. function getArg(aArgs, aName, aDefaultValue) {
  8930. if (aName in aArgs) {
  8931. return aArgs[aName];
  8932. } else if (arguments.length === 3) {
  8933. return aDefaultValue;
  8934. } else {
  8935. throw new Error("\"" + aName + "\" is a required argument.");
  8936. }
  8937. }
  8938. exports.getArg = getArg;
  8939. var urlRegexp = /^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.]*)(?::(\d+))?(\S*)$/;
  8940. var dataUrlRegexp = /^data:.+,.+$/;
  8941. function urlParse(aUrl) {
  8942. var match = aUrl.match(urlRegexp);
  8943. if (!match) {
  8944. return null;
  8945. }
  8946. return {
  8947. scheme: match[1],
  8948. auth: match[2],
  8949. host: match[3],
  8950. port: match[4],
  8951. path: match[5]
  8952. };
  8953. }
  8954. exports.urlParse = urlParse;
  8955. function urlGenerate(aParsedUrl) {
  8956. var url = "";
  8957. if (aParsedUrl.scheme) {
  8958. url += aParsedUrl.scheme + ":";
  8959. }
  8960. url += "//";
  8961. if (aParsedUrl.auth) {
  8962. url += aParsedUrl.auth + "@";
  8963. }
  8964. if (aParsedUrl.host) {
  8965. url += aParsedUrl.host;
  8966. }
  8967. if (aParsedUrl.port) {
  8968. url += ":" + aParsedUrl.port;
  8969. }
  8970. if (aParsedUrl.path) {
  8971. url += aParsedUrl.path;
  8972. }
  8973. return url;
  8974. }
  8975. exports.urlGenerate = urlGenerate;
  8976. function normalize(aPath) {
  8977. var path = aPath;
  8978. var url = urlParse(aPath);
  8979. if (url) {
  8980. if (!url.path) {
  8981. return aPath;
  8982. }
  8983. path = url.path;
  8984. }
  8985. var isAbsolute = exports.isAbsolute(path);
  8986. var parts = path.split(/\/+/);
  8987. for (var part, up = 0, i = parts.length - 1; i >= 0; i--) {
  8988. part = parts[i];
  8989. if (part === ".") {
  8990. parts.splice(i, 1);
  8991. } else if (part === "..") {
  8992. up++;
  8993. } else if (up > 0) {
  8994. if (part === "") {
  8995. parts.splice(i + 1, up);
  8996. up = 0;
  8997. } else {
  8998. parts.splice(i, 2);
  8999. up--;
  9000. }
  9001. }
  9002. }
  9003. path = parts.join("/");
  9004. if (path === "") {
  9005. path = isAbsolute ? "/" : ".";
  9006. }
  9007. if (url) {
  9008. url.path = path;
  9009. return urlGenerate(url);
  9010. }
  9011. return path;
  9012. }
  9013. exports.normalize = normalize;
  9014. function join(aRoot, aPath) {
  9015. if (aRoot === "") {
  9016. aRoot = ".";
  9017. }
  9018. if (aPath === "") {
  9019. aPath = ".";
  9020. }
  9021. var aPathUrl = urlParse(aPath);
  9022. var aRootUrl = urlParse(aRoot);
  9023. if (aRootUrl) {
  9024. aRoot = aRootUrl.path || "/";
  9025. }
  9026. if (aPathUrl && !aPathUrl.scheme) {
  9027. if (aRootUrl) {
  9028. aPathUrl.scheme = aRootUrl.scheme;
  9029. }
  9030. return urlGenerate(aPathUrl);
  9031. }
  9032. if (aPathUrl || aPath.match(dataUrlRegexp)) {
  9033. return aPath;
  9034. }
  9035. if (aRootUrl && !aRootUrl.host && !aRootUrl.path) {
  9036. aRootUrl.host = aPath;
  9037. return urlGenerate(aRootUrl);
  9038. }
  9039. var joined = aPath.charAt(0) === "/"
  9040. ? aPath
  9041. : normalize(aRoot.replace(/\/+$/, "") + "/" + aPath);
  9042. if (aRootUrl) {
  9043. aRootUrl.path = joined;
  9044. return urlGenerate(aRootUrl);
  9045. }
  9046. return joined;
  9047. }
  9048. exports.join = join;
  9049. exports.isAbsolute = function (aPath) {
  9050. return aPath.charAt(0) === "/" || !!aPath.match(urlRegexp);
  9051. };
  9052. function relative(aRoot, aPath) {
  9053. if (aRoot === "") {
  9054. aRoot = ".";
  9055. }
  9056. aRoot = aRoot.replace(/\/$/, "");
  9057. var level = 0;
  9058. while (aPath.indexOf(aRoot + "/") !== 0) {
  9059. var index = aRoot.lastIndexOf("/");
  9060. if (index < 0) {
  9061. return aPath;
  9062. }
  9063. aRoot = aRoot.slice(0, index);
  9064. if (aRoot.match(/^([^/]+:\/)?\/*$/)) {
  9065. return aPath;
  9066. }
  9067. ++level;
  9068. }
  9069. return Array(level + 1).join("../") + aPath.substr(aRoot.length + 1);
  9070. }
  9071. exports.relative = relative;
  9072. var supportsNullProto = (function () {
  9073. var obj = Object.create(null);
  9074. return !("__proto__" in obj);
  9075. }());
  9076. function identity(s) {
  9077. return s;
  9078. }
  9079. function toSetString(aStr) {
  9080. if (isProtoString(aStr)) {
  9081. return "$" + aStr;
  9082. }
  9083. return aStr;
  9084. }
  9085. exports.toSetString = supportsNullProto ? identity : toSetString;
  9086. function fromSetString(aStr) {
  9087. if (isProtoString(aStr)) {
  9088. return aStr.slice(1);
  9089. }
  9090. return aStr;
  9091. }
  9092. exports.fromSetString = supportsNullProto ? identity : fromSetString;
  9093. function isProtoString(s) {
  9094. if (!s) {
  9095. return false;
  9096. }
  9097. var length = s.length;
  9098. if (length < 9) {
  9099. return false;
  9100. }
  9101. if (s.charCodeAt(length - 1) !== 95 ||
  9102. s.charCodeAt(length - 2) !== 95 ||
  9103. s.charCodeAt(length - 3) !== 111 ||
  9104. s.charCodeAt(length - 4) !== 116 ||
  9105. s.charCodeAt(length - 5) !== 111 ||
  9106. s.charCodeAt(length - 6) !== 114 ||
  9107. s.charCodeAt(length - 7) !== 112 ||
  9108. s.charCodeAt(length - 8) !== 95 ||
  9109. s.charCodeAt(length - 9) !== 95) {
  9110. return false;
  9111. }
  9112. for (var i = length - 10; i >= 0; i--) {
  9113. if (s.charCodeAt(i) !== 36) {
  9114. return false;
  9115. }
  9116. }
  9117. return true;
  9118. }
  9119. function compareByOriginalPositions(mappingA, mappingB, onlyCompareOriginal) {
  9120. var cmp = mappingA.source - mappingB.source;
  9121. if (cmp !== 0) {
  9122. return cmp;
  9123. }
  9124. cmp = mappingA.originalLine - mappingB.originalLine;
  9125. if (cmp !== 0) {
  9126. return cmp;
  9127. }
  9128. cmp = mappingA.originalColumn - mappingB.originalColumn;
  9129. if (cmp !== 0 || onlyCompareOriginal) {
  9130. return cmp;
  9131. }
  9132. cmp = mappingA.generatedColumn - mappingB.generatedColumn;
  9133. if (cmp !== 0) {
  9134. return cmp;
  9135. }
  9136. cmp = mappingA.generatedLine - mappingB.generatedLine;
  9137. if (cmp !== 0) {
  9138. return cmp;
  9139. }
  9140. return mappingA.name - mappingB.name;
  9141. }
  9142. exports.compareByOriginalPositions = compareByOriginalPositions;
  9143. function compareByGeneratedPositionsDeflated(mappingA, mappingB, onlyCompareGenerated) {
  9144. var cmp = mappingA.generatedLine - mappingB.generatedLine;
  9145. if (cmp !== 0) {
  9146. return cmp;
  9147. }
  9148. cmp = mappingA.generatedColumn - mappingB.generatedColumn;
  9149. if (cmp !== 0 || onlyCompareGenerated) {
  9150. return cmp;
  9151. }
  9152. cmp = mappingA.source - mappingB.source;
  9153. if (cmp !== 0) {
  9154. return cmp;
  9155. }
  9156. cmp = mappingA.originalLine - mappingB.originalLine;
  9157. if (cmp !== 0) {
  9158. return cmp;
  9159. }
  9160. cmp = mappingA.originalColumn - mappingB.originalColumn;
  9161. if (cmp !== 0) {
  9162. return cmp;
  9163. }
  9164. return mappingA.name - mappingB.name;
  9165. }
  9166. exports.compareByGeneratedPositionsDeflated = compareByGeneratedPositionsDeflated;
  9167. function strcmp(aStr1, aStr2) {
  9168. if (aStr1 === aStr2) {
  9169. return 0;
  9170. }
  9171. if (aStr1 > aStr2) {
  9172. return 1;
  9173. }
  9174. return -1;
  9175. }
  9176. function compareByGeneratedPositionsInflated(mappingA, mappingB) {
  9177. var cmp = mappingA.generatedLine - mappingB.generatedLine;
  9178. if (cmp !== 0) {
  9179. return cmp;
  9180. }
  9181. cmp = mappingA.generatedColumn - mappingB.generatedColumn;
  9182. if (cmp !== 0) {
  9183. return cmp;
  9184. }
  9185. cmp = strcmp(mappingA.source, mappingB.source);
  9186. if (cmp !== 0) {
  9187. return cmp;
  9188. }
  9189. cmp = mappingA.originalLine - mappingB.originalLine;
  9190. if (cmp !== 0) {
  9191. return cmp;
  9192. }
  9193. cmp = mappingA.originalColumn - mappingB.originalColumn;
  9194. if (cmp !== 0) {
  9195. return cmp;
  9196. }
  9197. return strcmp(mappingA.name, mappingB.name);
  9198. }
  9199. exports.compareByGeneratedPositionsInflated = compareByGeneratedPositionsInflated;
  9200. }, {}], 123: [function (require, module, exports) {
  9201. exports.SourceMapGenerator = require("./lib/source-map-generator").SourceMapGenerator;
  9202. exports.SourceMapConsumer = require("./lib/source-map-consumer").SourceMapConsumer;
  9203. exports.SourceNode = require("./lib/source-node").SourceNode;
  9204. }, { "./lib/source-map-consumer": 119, "./lib/source-map-generator": 120, "./lib/source-node": 121 }]
  9205. }, {}, [10])(10);
  9206. });
  9207. return csstree;
  9208. })();