csstree.js 432 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606
  1. (function (global, factory) {
  2. typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
  3. typeof define === 'function' && define.amd ? define(factory) :
  4. (global = global || self, global.csstree = factory());
  5. }(this, (function () { 'use strict';
  6. //
  7. // list
  8. // ┌──────┐
  9. // ┌──────────────┼─head │
  10. // │ │ tail─┼──────────────┐
  11. // │ └──────┘ │
  12. // ▼ ▼
  13. // item item item item
  14. // ┌──────┐ ┌──────┐ ┌──────┐ ┌──────┐
  15. // null ◀──┼─prev │◀───┼─prev │◀───┼─prev │◀───┼─prev │
  16. // │ next─┼───▶│ next─┼───▶│ next─┼───▶│ next─┼──▶ null
  17. // ├──────┤ ├──────┤ ├──────┤ ├──────┤
  18. // │ data │ │ data │ │ data │ │ data │
  19. // └──────┘ └──────┘ └──────┘ └──────┘
  20. //
  21. function createItem(data) {
  22. return {
  23. prev: null,
  24. next: null,
  25. data: data
  26. };
  27. }
  28. function allocateCursor(node, prev, next) {
  29. var cursor;
  30. if (cursors !== null) {
  31. cursor = cursors;
  32. cursors = cursors.cursor;
  33. cursor.prev = prev;
  34. cursor.next = next;
  35. cursor.cursor = node.cursor;
  36. } else {
  37. cursor = {
  38. prev: prev,
  39. next: next,
  40. cursor: node.cursor
  41. };
  42. }
  43. node.cursor = cursor;
  44. return cursor;
  45. }
  46. function releaseCursor(node) {
  47. var cursor = node.cursor;
  48. node.cursor = cursor.cursor;
  49. cursor.prev = null;
  50. cursor.next = null;
  51. cursor.cursor = cursors;
  52. cursors = cursor;
  53. }
  54. var cursors = null;
  55. var List = function() {
  56. this.cursor = null;
  57. this.head = null;
  58. this.tail = null;
  59. };
  60. List.createItem = createItem;
  61. List.prototype.createItem = createItem;
  62. List.prototype.updateCursors = function(prevOld, prevNew, nextOld, nextNew) {
  63. var cursor = this.cursor;
  64. while (cursor !== null) {
  65. if (cursor.prev === prevOld) {
  66. cursor.prev = prevNew;
  67. }
  68. if (cursor.next === nextOld) {
  69. cursor.next = nextNew;
  70. }
  71. cursor = cursor.cursor;
  72. }
  73. };
  74. List.prototype.getSize = function() {
  75. var size = 0;
  76. var cursor = this.head;
  77. while (cursor) {
  78. size++;
  79. cursor = cursor.next;
  80. }
  81. return size;
  82. };
  83. List.prototype.fromArray = function(array) {
  84. var cursor = null;
  85. this.head = null;
  86. for (var i = 0; i < array.length; i++) {
  87. var item = createItem(array[i]);
  88. if (cursor !== null) {
  89. cursor.next = item;
  90. } else {
  91. this.head = item;
  92. }
  93. item.prev = cursor;
  94. cursor = item;
  95. }
  96. this.tail = cursor;
  97. return this;
  98. };
  99. List.prototype.toArray = function() {
  100. var cursor = this.head;
  101. var result = [];
  102. while (cursor) {
  103. result.push(cursor.data);
  104. cursor = cursor.next;
  105. }
  106. return result;
  107. };
  108. List.prototype.toJSON = List.prototype.toArray;
  109. List.prototype.isEmpty = function() {
  110. return this.head === null;
  111. };
  112. List.prototype.first = function() {
  113. return this.head && this.head.data;
  114. };
  115. List.prototype.last = function() {
  116. return this.tail && this.tail.data;
  117. };
  118. List.prototype.each = function(fn, context) {
  119. var item;
  120. if (context === undefined) {
  121. context = this;
  122. }
  123. // push cursor
  124. var cursor = allocateCursor(this, null, this.head);
  125. while (cursor.next !== null) {
  126. item = cursor.next;
  127. cursor.next = item.next;
  128. fn.call(context, item.data, item, this);
  129. }
  130. // pop cursor
  131. releaseCursor(this);
  132. };
  133. List.prototype.forEach = List.prototype.each;
  134. List.prototype.eachRight = function(fn, context) {
  135. var item;
  136. if (context === undefined) {
  137. context = this;
  138. }
  139. // push cursor
  140. var cursor = allocateCursor(this, this.tail, null);
  141. while (cursor.prev !== null) {
  142. item = cursor.prev;
  143. cursor.prev = item.prev;
  144. fn.call(context, item.data, item, this);
  145. }
  146. // pop cursor
  147. releaseCursor(this);
  148. };
  149. List.prototype.forEachRight = List.prototype.eachRight;
  150. List.prototype.reduce = function(fn, initialValue, context) {
  151. var item;
  152. if (context === undefined) {
  153. context = this;
  154. }
  155. // push cursor
  156. var cursor = allocateCursor(this, null, this.head);
  157. var acc = initialValue;
  158. while (cursor.next !== null) {
  159. item = cursor.next;
  160. cursor.next = item.next;
  161. acc = fn.call(context, acc, item.data, item, this);
  162. }
  163. // pop cursor
  164. releaseCursor(this);
  165. return acc;
  166. };
  167. List.prototype.reduceRight = function(fn, initialValue, context) {
  168. var item;
  169. if (context === undefined) {
  170. context = this;
  171. }
  172. // push cursor
  173. var cursor = allocateCursor(this, this.tail, null);
  174. var acc = initialValue;
  175. while (cursor.prev !== null) {
  176. item = cursor.prev;
  177. cursor.prev = item.prev;
  178. acc = fn.call(context, acc, item.data, item, this);
  179. }
  180. // pop cursor
  181. releaseCursor(this);
  182. return acc;
  183. };
  184. List.prototype.nextUntil = function(start, fn, context) {
  185. if (start === null) {
  186. return;
  187. }
  188. var item;
  189. if (context === undefined) {
  190. context = this;
  191. }
  192. // push cursor
  193. var cursor = allocateCursor(this, null, start);
  194. while (cursor.next !== null) {
  195. item = cursor.next;
  196. cursor.next = item.next;
  197. if (fn.call(context, item.data, item, this)) {
  198. break;
  199. }
  200. }
  201. // pop cursor
  202. releaseCursor(this);
  203. };
  204. List.prototype.prevUntil = function(start, fn, context) {
  205. if (start === null) {
  206. return;
  207. }
  208. var item;
  209. if (context === undefined) {
  210. context = this;
  211. }
  212. // push cursor
  213. var cursor = allocateCursor(this, start, null);
  214. while (cursor.prev !== null) {
  215. item = cursor.prev;
  216. cursor.prev = item.prev;
  217. if (fn.call(context, item.data, item, this)) {
  218. break;
  219. }
  220. }
  221. // pop cursor
  222. releaseCursor(this);
  223. };
  224. List.prototype.some = function(fn, context) {
  225. var cursor = this.head;
  226. if (context === undefined) {
  227. context = this;
  228. }
  229. while (cursor !== null) {
  230. if (fn.call(context, cursor.data, cursor, this)) {
  231. return true;
  232. }
  233. cursor = cursor.next;
  234. }
  235. return false;
  236. };
  237. List.prototype.map = function(fn, context) {
  238. var result = new List();
  239. var cursor = this.head;
  240. if (context === undefined) {
  241. context = this;
  242. }
  243. while (cursor !== null) {
  244. result.appendData(fn.call(context, cursor.data, cursor, this));
  245. cursor = cursor.next;
  246. }
  247. return result;
  248. };
  249. List.prototype.filter = function(fn, context) {
  250. var result = new List();
  251. var cursor = this.head;
  252. if (context === undefined) {
  253. context = this;
  254. }
  255. while (cursor !== null) {
  256. if (fn.call(context, cursor.data, cursor, this)) {
  257. result.appendData(cursor.data);
  258. }
  259. cursor = cursor.next;
  260. }
  261. return result;
  262. };
  263. List.prototype.clear = function() {
  264. this.head = null;
  265. this.tail = null;
  266. };
  267. List.prototype.copy = function() {
  268. var result = new List();
  269. var cursor = this.head;
  270. while (cursor !== null) {
  271. result.insert(createItem(cursor.data));
  272. cursor = cursor.next;
  273. }
  274. return result;
  275. };
  276. List.prototype.prepend = function(item) {
  277. // head
  278. // ^
  279. // item
  280. this.updateCursors(null, item, this.head, item);
  281. // insert to the beginning of the list
  282. if (this.head !== null) {
  283. // new item <- first item
  284. this.head.prev = item;
  285. // new item -> first item
  286. item.next = this.head;
  287. } else {
  288. // if list has no head, then it also has no tail
  289. // in this case tail points to the new item
  290. this.tail = item;
  291. }
  292. // head always points to new item
  293. this.head = item;
  294. return this;
  295. };
  296. List.prototype.prependData = function(data) {
  297. return this.prepend(createItem(data));
  298. };
  299. List.prototype.append = function(item) {
  300. return this.insert(item);
  301. };
  302. List.prototype.appendData = function(data) {
  303. return this.insert(createItem(data));
  304. };
  305. List.prototype.insert = function(item, before) {
  306. if (before !== undefined && before !== null) {
  307. // prev before
  308. // ^
  309. // item
  310. this.updateCursors(before.prev, item, before, item);
  311. if (before.prev === null) {
  312. // insert to the beginning of list
  313. if (this.head !== before) {
  314. throw new Error('before doesn\'t belong to list');
  315. }
  316. // since head points to before therefore list doesn't empty
  317. // no need to check tail
  318. this.head = item;
  319. before.prev = item;
  320. item.next = before;
  321. this.updateCursors(null, item);
  322. } else {
  323. // insert between two items
  324. before.prev.next = item;
  325. item.prev = before.prev;
  326. before.prev = item;
  327. item.next = before;
  328. }
  329. } else {
  330. // tail
  331. // ^
  332. // item
  333. this.updateCursors(this.tail, item, null, item);
  334. // insert to the ending of the list
  335. if (this.tail !== null) {
  336. // last item -> new item
  337. this.tail.next = item;
  338. // last item <- new item
  339. item.prev = this.tail;
  340. } else {
  341. // if list has no tail, then it also has no head
  342. // in this case head points to new item
  343. this.head = item;
  344. }
  345. // tail always points to new item
  346. this.tail = item;
  347. }
  348. return this;
  349. };
  350. List.prototype.insertData = function(data, before) {
  351. return this.insert(createItem(data), before);
  352. };
  353. List.prototype.remove = function(item) {
  354. // item
  355. // ^
  356. // prev next
  357. this.updateCursors(item, item.prev, item, item.next);
  358. if (item.prev !== null) {
  359. item.prev.next = item.next;
  360. } else {
  361. if (this.head !== item) {
  362. throw new Error('item doesn\'t belong to list');
  363. }
  364. this.head = item.next;
  365. }
  366. if (item.next !== null) {
  367. item.next.prev = item.prev;
  368. } else {
  369. if (this.tail !== item) {
  370. throw new Error('item doesn\'t belong to list');
  371. }
  372. this.tail = item.prev;
  373. }
  374. item.prev = null;
  375. item.next = null;
  376. return item;
  377. };
  378. List.prototype.push = function(data) {
  379. this.insert(createItem(data));
  380. };
  381. List.prototype.pop = function() {
  382. if (this.tail !== null) {
  383. return this.remove(this.tail);
  384. }
  385. };
  386. List.prototype.unshift = function(data) {
  387. this.prepend(createItem(data));
  388. };
  389. List.prototype.shift = function() {
  390. if (this.head !== null) {
  391. return this.remove(this.head);
  392. }
  393. };
  394. List.prototype.prependList = function(list) {
  395. return this.insertList(list, this.head);
  396. };
  397. List.prototype.appendList = function(list) {
  398. return this.insertList(list);
  399. };
  400. List.prototype.insertList = function(list, before) {
  401. // ignore empty lists
  402. if (list.head === null) {
  403. return this;
  404. }
  405. if (before !== undefined && before !== null) {
  406. this.updateCursors(before.prev, list.tail, before, list.head);
  407. // insert in the middle of dist list
  408. if (before.prev !== null) {
  409. // before.prev <-> list.head
  410. before.prev.next = list.head;
  411. list.head.prev = before.prev;
  412. } else {
  413. this.head = list.head;
  414. }
  415. before.prev = list.tail;
  416. list.tail.next = before;
  417. } else {
  418. this.updateCursors(this.tail, list.tail, null, list.head);
  419. // insert to end of the list
  420. if (this.tail !== null) {
  421. // if destination list has a tail, then it also has a head,
  422. // but head doesn't change
  423. // dest tail -> source head
  424. this.tail.next = list.head;
  425. // dest tail <- source head
  426. list.head.prev = this.tail;
  427. } else {
  428. // if list has no a tail, then it also has no a head
  429. // in this case points head to new item
  430. this.head = list.head;
  431. }
  432. // tail always start point to new item
  433. this.tail = list.tail;
  434. }
  435. list.head = null;
  436. list.tail = null;
  437. return this;
  438. };
  439. List.prototype.replace = function(oldItem, newItemOrList) {
  440. if ('head' in newItemOrList) {
  441. this.insertList(newItemOrList, oldItem);
  442. } else {
  443. this.insert(newItemOrList, oldItem);
  444. }
  445. this.remove(oldItem);
  446. };
  447. var List_1 = List;
  448. var createCustomError = function createCustomError(name, message) {
  449. // use Object.create(), because some VMs prevent setting line/column otherwise
  450. // (iOS Safari 10 even throws an exception)
  451. var error = Object.create(SyntaxError.prototype);
  452. var errorStack = new Error();
  453. error.name = name;
  454. error.message = message;
  455. Object.defineProperty(error, 'stack', {
  456. get: function() {
  457. return (errorStack.stack || '').replace(/^(.+\n){1,3}/, name + ': ' + message + '\n');
  458. }
  459. });
  460. return error;
  461. };
  462. var MAX_LINE_LENGTH = 100;
  463. var OFFSET_CORRECTION = 60;
  464. var TAB_REPLACEMENT = ' ';
  465. function sourceFragment(error, extraLines) {
  466. function processLines(start, end) {
  467. return lines.slice(start, end).map(function(line, idx) {
  468. var num = String(start + idx + 1);
  469. while (num.length < maxNumLength) {
  470. num = ' ' + num;
  471. }
  472. return num + ' |' + line;
  473. }).join('\n');
  474. }
  475. var lines = error.source.split(/\r\n?|\n|\f/);
  476. var line = error.line;
  477. var column = error.column;
  478. var startLine = Math.max(1, line - extraLines) - 1;
  479. var endLine = Math.min(line + extraLines, lines.length + 1);
  480. var maxNumLength = Math.max(4, String(endLine).length) + 1;
  481. var cutLeft = 0;
  482. // column correction according to replaced tab before column
  483. column += (TAB_REPLACEMENT.length - 1) * (lines[line - 1].substr(0, column - 1).match(/\t/g) || []).length;
  484. if (column > MAX_LINE_LENGTH) {
  485. cutLeft = column - OFFSET_CORRECTION + 3;
  486. column = OFFSET_CORRECTION - 2;
  487. }
  488. for (var i = startLine; i <= endLine; i++) {
  489. if (i >= 0 && i < lines.length) {
  490. lines[i] = lines[i].replace(/\t/g, TAB_REPLACEMENT);
  491. lines[i] =
  492. (cutLeft > 0 && lines[i].length > cutLeft ? '\u2026' : '') +
  493. lines[i].substr(cutLeft, MAX_LINE_LENGTH - 2) +
  494. (lines[i].length > cutLeft + MAX_LINE_LENGTH - 1 ? '\u2026' : '');
  495. }
  496. }
  497. return [
  498. processLines(startLine, line),
  499. new Array(column + maxNumLength + 2).join('-') + '^',
  500. processLines(line, endLine)
  501. ].filter(Boolean).join('\n');
  502. }
  503. var SyntaxError$1 = function(message, source, offset, line, column) {
  504. var error = createCustomError('SyntaxError', message);
  505. error.source = source;
  506. error.offset = offset;
  507. error.line = line;
  508. error.column = column;
  509. error.sourceFragment = function(extraLines) {
  510. return sourceFragment(error, isNaN(extraLines) ? 0 : extraLines);
  511. };
  512. Object.defineProperty(error, 'formattedMessage', {
  513. get: function() {
  514. return (
  515. 'Parse error: ' + error.message + '\n' +
  516. sourceFragment(error, 2)
  517. );
  518. }
  519. });
  520. // for backward capability
  521. error.parseError = {
  522. offset: offset,
  523. line: line,
  524. column: column
  525. };
  526. return error;
  527. };
  528. var _SyntaxError = SyntaxError$1;
  529. // CSS Syntax Module Level 3
  530. // https://www.w3.org/TR/css-syntax-3/
  531. var TYPE = {
  532. EOF: 0, // <EOF-token>
  533. Ident: 1, // <ident-token>
  534. Function: 2, // <function-token>
  535. AtKeyword: 3, // <at-keyword-token>
  536. Hash: 4, // <hash-token>
  537. String: 5, // <string-token>
  538. BadString: 6, // <bad-string-token>
  539. Url: 7, // <url-token>
  540. BadUrl: 8, // <bad-url-token>
  541. Delim: 9, // <delim-token>
  542. Number: 10, // <number-token>
  543. Percentage: 11, // <percentage-token>
  544. Dimension: 12, // <dimension-token>
  545. WhiteSpace: 13, // <whitespace-token>
  546. CDO: 14, // <CDO-token>
  547. CDC: 15, // <CDC-token>
  548. Colon: 16, // <colon-token> :
  549. Semicolon: 17, // <semicolon-token> ;
  550. Comma: 18, // <comma-token> ,
  551. LeftSquareBracket: 19, // <[-token>
  552. RightSquareBracket: 20, // <]-token>
  553. LeftParenthesis: 21, // <(-token>
  554. RightParenthesis: 22, // <)-token>
  555. LeftCurlyBracket: 23, // <{-token>
  556. RightCurlyBracket: 24, // <}-token>
  557. Comment: 25
  558. };
  559. var NAME = Object.keys(TYPE).reduce(function(result, key) {
  560. result[TYPE[key]] = key;
  561. return result;
  562. }, {});
  563. var _const = {
  564. TYPE: TYPE,
  565. NAME: NAME
  566. };
  567. var EOF = 0;
  568. // https://drafts.csswg.org/css-syntax-3/
  569. // § 4.2. Definitions
  570. // digit
  571. // A code point between U+0030 DIGIT ZERO (0) and U+0039 DIGIT NINE (9).
  572. function isDigit(code) {
  573. return code >= 0x0030 && code <= 0x0039;
  574. }
  575. // hex digit
  576. // A digit, or a code point between U+0041 LATIN CAPITAL LETTER A (A) and U+0046 LATIN CAPITAL LETTER F (F),
  577. // or a code point between U+0061 LATIN SMALL LETTER A (a) and U+0066 LATIN SMALL LETTER F (f).
  578. function isHexDigit(code) {
  579. return (
  580. isDigit(code) || // 0 .. 9
  581. (code >= 0x0041 && code <= 0x0046) || // A .. F
  582. (code >= 0x0061 && code <= 0x0066) // a .. f
  583. );
  584. }
  585. // uppercase letter
  586. // A code point between U+0041 LATIN CAPITAL LETTER A (A) and U+005A LATIN CAPITAL LETTER Z (Z).
  587. function isUppercaseLetter(code) {
  588. return code >= 0x0041 && code <= 0x005A;
  589. }
  590. // lowercase letter
  591. // A code point between U+0061 LATIN SMALL LETTER A (a) and U+007A LATIN SMALL LETTER Z (z).
  592. function isLowercaseLetter(code) {
  593. return code >= 0x0061 && code <= 0x007A;
  594. }
  595. // letter
  596. // An uppercase letter or a lowercase letter.
  597. function isLetter(code) {
  598. return isUppercaseLetter(code) || isLowercaseLetter(code);
  599. }
  600. // non-ASCII code point
  601. // A code point with a value equal to or greater than U+0080 <control>.
  602. function isNonAscii(code) {
  603. return code >= 0x0080;
  604. }
  605. // name-start code point
  606. // A letter, a non-ASCII code point, or U+005F LOW LINE (_).
  607. function isNameStart(code) {
  608. return isLetter(code) || isNonAscii(code) || code === 0x005F;
  609. }
  610. // name code point
  611. // A name-start code point, a digit, or U+002D HYPHEN-MINUS (-).
  612. function isName(code) {
  613. return isNameStart(code) || isDigit(code) || code === 0x002D;
  614. }
  615. // non-printable code point
  616. // A code point between U+0000 NULL and U+0008 BACKSPACE, or U+000B LINE TABULATION,
  617. // or a code point between U+000E SHIFT OUT and U+001F INFORMATION SEPARATOR ONE, or U+007F DELETE.
  618. function isNonPrintable(code) {
  619. return (
  620. (code >= 0x0000 && code <= 0x0008) ||
  621. (code === 0x000B) ||
  622. (code >= 0x000E && code <= 0x001F) ||
  623. (code === 0x007F)
  624. );
  625. }
  626. // newline
  627. // U+000A LINE FEED. Note that U+000D CARRIAGE RETURN and U+000C FORM FEED are not included in this definition,
  628. // as they are converted to U+000A LINE FEED during preprocessing.
  629. // TODO: we doesn't do a preprocessing, so check a code point for U+000D CARRIAGE RETURN and U+000C FORM FEED
  630. function isNewline(code) {
  631. return code === 0x000A || code === 0x000D || code === 0x000C;
  632. }
  633. // whitespace
  634. // A newline, U+0009 CHARACTER TABULATION, or U+0020 SPACE.
  635. function isWhiteSpace(code) {
  636. return isNewline(code) || code === 0x0020 || code === 0x0009;
  637. }
  638. // § 4.3.8. Check if two code points are a valid escape
  639. function isValidEscape(first, second) {
  640. // If the first code point is not U+005C REVERSE SOLIDUS (\), return false.
  641. if (first !== 0x005C) {
  642. return false;
  643. }
  644. // Otherwise, if the second code point is a newline or EOF, return false.
  645. if (isNewline(second) || second === EOF) {
  646. return false;
  647. }
  648. // Otherwise, return true.
  649. return true;
  650. }
  651. // § 4.3.9. Check if three code points would start an identifier
  652. function isIdentifierStart(first, second, third) {
  653. // Look at the first code point:
  654. // U+002D HYPHEN-MINUS
  655. if (first === 0x002D) {
  656. // If the second code point is a name-start code point or a U+002D HYPHEN-MINUS,
  657. // or the second and third code points are a valid escape, return true. Otherwise, return false.
  658. return (
  659. isNameStart(second) ||
  660. second === 0x002D ||
  661. isValidEscape(second, third)
  662. );
  663. }
  664. // name-start code point
  665. if (isNameStart(first)) {
  666. // Return true.
  667. return true;
  668. }
  669. // U+005C REVERSE SOLIDUS (\)
  670. if (first === 0x005C) {
  671. // If the first and second code points are a valid escape, return true. Otherwise, return false.
  672. return isValidEscape(first, second);
  673. }
  674. // anything else
  675. // Return false.
  676. return false;
  677. }
  678. // § 4.3.10. Check if three code points would start a number
  679. function isNumberStart(first, second, third) {
  680. // Look at the first code point:
  681. // U+002B PLUS SIGN (+)
  682. // U+002D HYPHEN-MINUS (-)
  683. if (first === 0x002B || first === 0x002D) {
  684. // If the second code point is a digit, return true.
  685. if (isDigit(second)) {
  686. return 2;
  687. }
  688. // Otherwise, if the second code point is a U+002E FULL STOP (.)
  689. // and the third code point is a digit, return true.
  690. // Otherwise, return false.
  691. return second === 0x002E && isDigit(third) ? 3 : 0;
  692. }
  693. // U+002E FULL STOP (.)
  694. if (first === 0x002E) {
  695. // If the second code point is a digit, return true. Otherwise, return false.
  696. return isDigit(second) ? 2 : 0;
  697. }
  698. // digit
  699. if (isDigit(first)) {
  700. // Return true.
  701. return 1;
  702. }
  703. // anything else
  704. // Return false.
  705. return 0;
  706. }
  707. //
  708. // Misc
  709. //
  710. // detect BOM (https://en.wikipedia.org/wiki/Byte_order_mark)
  711. function isBOM(code) {
  712. // UTF-16BE
  713. if (code === 0xFEFF) {
  714. return 1;
  715. }
  716. // UTF-16LE
  717. if (code === 0xFFFE) {
  718. return 1;
  719. }
  720. return 0;
  721. }
  722. // Fast code category
  723. //
  724. // https://drafts.csswg.org/css-syntax/#tokenizer-definitions
  725. // > non-ASCII code point
  726. // > A code point with a value equal to or greater than U+0080 <control>
  727. // > name-start code point
  728. // > A letter, a non-ASCII code point, or U+005F LOW LINE (_).
  729. // > name code point
  730. // > A name-start code point, a digit, or U+002D HYPHEN-MINUS (-)
  731. // That means only ASCII code points has a special meaning and we define a maps for 0..127 codes only
  732. var CATEGORY = new Array(0x80);
  733. charCodeCategory.Eof = 0x80;
  734. charCodeCategory.WhiteSpace = 0x82;
  735. charCodeCategory.Digit = 0x83;
  736. charCodeCategory.NameStart = 0x84;
  737. charCodeCategory.NonPrintable = 0x85;
  738. for (var i = 0; i < CATEGORY.length; i++) {
  739. switch (true) {
  740. case isWhiteSpace(i):
  741. CATEGORY[i] = charCodeCategory.WhiteSpace;
  742. break;
  743. case isDigit(i):
  744. CATEGORY[i] = charCodeCategory.Digit;
  745. break;
  746. case isNameStart(i):
  747. CATEGORY[i] = charCodeCategory.NameStart;
  748. break;
  749. case isNonPrintable(i):
  750. CATEGORY[i] = charCodeCategory.NonPrintable;
  751. break;
  752. default:
  753. CATEGORY[i] = i || charCodeCategory.Eof;
  754. }
  755. }
  756. function charCodeCategory(code) {
  757. return code < 0x80 ? CATEGORY[code] : charCodeCategory.NameStart;
  758. }
  759. var charCodeDefinitions = {
  760. isDigit: isDigit,
  761. isHexDigit: isHexDigit,
  762. isUppercaseLetter: isUppercaseLetter,
  763. isLowercaseLetter: isLowercaseLetter,
  764. isLetter: isLetter,
  765. isNonAscii: isNonAscii,
  766. isNameStart: isNameStart,
  767. isName: isName,
  768. isNonPrintable: isNonPrintable,
  769. isNewline: isNewline,
  770. isWhiteSpace: isWhiteSpace,
  771. isValidEscape: isValidEscape,
  772. isIdentifierStart: isIdentifierStart,
  773. isNumberStart: isNumberStart,
  774. isBOM: isBOM,
  775. charCodeCategory: charCodeCategory
  776. };
  777. var isDigit$1 = charCodeDefinitions.isDigit;
  778. var isHexDigit$1 = charCodeDefinitions.isHexDigit;
  779. var isUppercaseLetter$1 = charCodeDefinitions.isUppercaseLetter;
  780. var isName$1 = charCodeDefinitions.isName;
  781. var isWhiteSpace$1 = charCodeDefinitions.isWhiteSpace;
  782. var isValidEscape$1 = charCodeDefinitions.isValidEscape;
  783. function getCharCode(source, offset) {
  784. return offset < source.length ? source.charCodeAt(offset) : 0;
  785. }
  786. function getNewlineLength(source, offset, code) {
  787. if (code === 13 /* \r */ && getCharCode(source, offset + 1) === 10 /* \n */) {
  788. return 2;
  789. }
  790. return 1;
  791. }
  792. function cmpChar(testStr, offset, referenceCode) {
  793. var code = testStr.charCodeAt(offset);
  794. // code.toLowerCase() for A..Z
  795. if (isUppercaseLetter$1(code)) {
  796. code = code | 32;
  797. }
  798. return code === referenceCode;
  799. }
  800. function cmpStr(testStr, start, end, referenceStr) {
  801. if (end - start !== referenceStr.length) {
  802. return false;
  803. }
  804. if (start < 0 || end > testStr.length) {
  805. return false;
  806. }
  807. for (var i = start; i < end; i++) {
  808. var testCode = testStr.charCodeAt(i);
  809. var referenceCode = referenceStr.charCodeAt(i - start);
  810. // testCode.toLowerCase() for A..Z
  811. if (isUppercaseLetter$1(testCode)) {
  812. testCode = testCode | 32;
  813. }
  814. if (testCode !== referenceCode) {
  815. return false;
  816. }
  817. }
  818. return true;
  819. }
  820. function findWhiteSpaceStart(source, offset) {
  821. for (; offset >= 0; offset--) {
  822. if (!isWhiteSpace$1(source.charCodeAt(offset))) {
  823. break;
  824. }
  825. }
  826. return offset + 1;
  827. }
  828. function findWhiteSpaceEnd(source, offset) {
  829. for (; offset < source.length; offset++) {
  830. if (!isWhiteSpace$1(source.charCodeAt(offset))) {
  831. break;
  832. }
  833. }
  834. return offset;
  835. }
  836. function findDecimalNumberEnd(source, offset) {
  837. for (; offset < source.length; offset++) {
  838. if (!isDigit$1(source.charCodeAt(offset))) {
  839. break;
  840. }
  841. }
  842. return offset;
  843. }
  844. // § 4.3.7. Consume an escaped code point
  845. function consumeEscaped(source, offset) {
  846. // It assumes that the U+005C REVERSE SOLIDUS (\) has already been consumed and
  847. // that the next input code point has already been verified to be part of a valid escape.
  848. offset += 2;
  849. // hex digit
  850. if (isHexDigit$1(getCharCode(source, offset - 1))) {
  851. // Consume as many hex digits as possible, but no more than 5.
  852. // Note that this means 1-6 hex digits have been consumed in total.
  853. for (var maxOffset = Math.min(source.length, offset + 5); offset < maxOffset; offset++) {
  854. if (!isHexDigit$1(getCharCode(source, offset))) {
  855. break;
  856. }
  857. }
  858. // If the next input code point is whitespace, consume it as well.
  859. var code = getCharCode(source, offset);
  860. if (isWhiteSpace$1(code)) {
  861. offset += getNewlineLength(source, offset, code);
  862. }
  863. }
  864. return offset;
  865. }
  866. // §4.3.11. Consume a name
  867. // Note: This algorithm does not do the verification of the first few code points that are necessary
  868. // to ensure the returned code points would constitute an <ident-token>. If that is the intended use,
  869. // ensure that the stream starts with an identifier before calling this algorithm.
  870. function consumeName(source, offset) {
  871. // Let result initially be an empty string.
  872. // Repeatedly consume the next input code point from the stream:
  873. for (; offset < source.length; offset++) {
  874. var code = source.charCodeAt(offset);
  875. // name code point
  876. if (isName$1(code)) {
  877. // Append the code point to result.
  878. continue;
  879. }
  880. // the stream starts with a valid escape
  881. if (isValidEscape$1(code, getCharCode(source, offset + 1))) {
  882. // Consume an escaped code point. Append the returned code point to result.
  883. offset = consumeEscaped(source, offset) - 1;
  884. continue;
  885. }
  886. // anything else
  887. // Reconsume the current input code point. Return result.
  888. break;
  889. }
  890. return offset;
  891. }
  892. // §4.3.12. Consume a number
  893. function consumeNumber(source, offset) {
  894. var code = source.charCodeAt(offset);
  895. // 2. If the next input code point is U+002B PLUS SIGN (+) or U+002D HYPHEN-MINUS (-),
  896. // consume it and append it to repr.
  897. if (code === 0x002B || code === 0x002D) {
  898. code = source.charCodeAt(offset += 1);
  899. }
  900. // 3. While the next input code point is a digit, consume it and append it to repr.
  901. if (isDigit$1(code)) {
  902. offset = findDecimalNumberEnd(source, offset + 1);
  903. code = source.charCodeAt(offset);
  904. }
  905. // 4. If the next 2 input code points are U+002E FULL STOP (.) followed by a digit, then:
  906. if (code === 0x002E && isDigit$1(source.charCodeAt(offset + 1))) {
  907. // 4.1 Consume them.
  908. // 4.2 Append them to repr.
  909. code = source.charCodeAt(offset += 2);
  910. // 4.3 Set type to "number".
  911. // TODO
  912. // 4.4 While the next input code point is a digit, consume it and append it to repr.
  913. offset = findDecimalNumberEnd(source, offset);
  914. }
  915. // 5. If the next 2 or 3 input code points are U+0045 LATIN CAPITAL LETTER E (E)
  916. // or U+0065 LATIN SMALL LETTER E (e), ... , followed by a digit, then:
  917. if (cmpChar(source, offset, 101 /* e */)) {
  918. var sign = 0;
  919. code = source.charCodeAt(offset + 1);
  920. // ... optionally followed by U+002D HYPHEN-MINUS (-) or U+002B PLUS SIGN (+) ...
  921. if (code === 0x002D || code === 0x002B) {
  922. sign = 1;
  923. code = source.charCodeAt(offset + 2);
  924. }
  925. // ... followed by a digit
  926. if (isDigit$1(code)) {
  927. // 5.1 Consume them.
  928. // 5.2 Append them to repr.
  929. // 5.3 Set type to "number".
  930. // TODO
  931. // 5.4 While the next input code point is a digit, consume it and append it to repr.
  932. offset = findDecimalNumberEnd(source, offset + 1 + sign + 1);
  933. }
  934. }
  935. return offset;
  936. }
  937. // § 4.3.14. Consume the remnants of a bad url
  938. // ... its sole use is to consume enough of the input stream to reach a recovery point
  939. // where normal tokenizing can resume.
  940. function consumeBadUrlRemnants(source, offset) {
  941. // Repeatedly consume the next input code point from the stream:
  942. for (; offset < source.length; offset++) {
  943. var code = source.charCodeAt(offset);
  944. // U+0029 RIGHT PARENTHESIS ())
  945. // EOF
  946. if (code === 0x0029) {
  947. // Return.
  948. offset++;
  949. break;
  950. }
  951. if (isValidEscape$1(code, getCharCode(source, offset + 1))) {
  952. // Consume an escaped code point.
  953. // Note: This allows an escaped right parenthesis ("\)") to be encountered
  954. // without ending the <bad-url-token>. This is otherwise identical to
  955. // the "anything else" clause.
  956. offset = consumeEscaped(source, offset);
  957. }
  958. }
  959. return offset;
  960. }
  961. var utils = {
  962. consumeEscaped: consumeEscaped,
  963. consumeName: consumeName,
  964. consumeNumber: consumeNumber,
  965. consumeBadUrlRemnants: consumeBadUrlRemnants,
  966. cmpChar: cmpChar,
  967. cmpStr: cmpStr,
  968. getNewlineLength: getNewlineLength,
  969. findWhiteSpaceStart: findWhiteSpaceStart,
  970. findWhiteSpaceEnd: findWhiteSpaceEnd
  971. };
  972. var TYPE$1 = _const.TYPE;
  973. var NAME$1 = _const.NAME;
  974. var cmpStr$1 = utils.cmpStr;
  975. var EOF$1 = TYPE$1.EOF;
  976. var WHITESPACE = TYPE$1.WhiteSpace;
  977. var COMMENT = TYPE$1.Comment;
  978. var OFFSET_MASK = 0x00FFFFFF;
  979. var TYPE_SHIFT = 24;
  980. var TokenStream = function() {
  981. this.offsetAndType = null;
  982. this.balance = null;
  983. this.reset();
  984. };
  985. TokenStream.prototype = {
  986. reset: function() {
  987. this.eof = false;
  988. this.tokenIndex = -1;
  989. this.tokenType = 0;
  990. this.tokenStart = this.firstCharOffset;
  991. this.tokenEnd = this.firstCharOffset;
  992. },
  993. lookupType: function(offset) {
  994. offset += this.tokenIndex;
  995. if (offset < this.tokenCount) {
  996. return this.offsetAndType[offset] >> TYPE_SHIFT;
  997. }
  998. return EOF$1;
  999. },
  1000. lookupOffset: function(offset) {
  1001. offset += this.tokenIndex;
  1002. if (offset < this.tokenCount) {
  1003. return this.offsetAndType[offset - 1] & OFFSET_MASK;
  1004. }
  1005. return this.source.length;
  1006. },
  1007. lookupValue: function(offset, referenceStr) {
  1008. offset += this.tokenIndex;
  1009. if (offset < this.tokenCount) {
  1010. return cmpStr$1(
  1011. this.source,
  1012. this.offsetAndType[offset - 1] & OFFSET_MASK,
  1013. this.offsetAndType[offset] & OFFSET_MASK,
  1014. referenceStr
  1015. );
  1016. }
  1017. return false;
  1018. },
  1019. getTokenStart: function(tokenIndex) {
  1020. if (tokenIndex === this.tokenIndex) {
  1021. return this.tokenStart;
  1022. }
  1023. if (tokenIndex > 0) {
  1024. return tokenIndex < this.tokenCount
  1025. ? this.offsetAndType[tokenIndex - 1] & OFFSET_MASK
  1026. : this.offsetAndType[this.tokenCount] & OFFSET_MASK;
  1027. }
  1028. return this.firstCharOffset;
  1029. },
  1030. // TODO: -> skipUntilBalanced
  1031. getRawLength: function(startToken, mode) {
  1032. var cursor = startToken;
  1033. var balanceEnd;
  1034. var offset = this.offsetAndType[Math.max(cursor - 1, 0)] & OFFSET_MASK;
  1035. var type;
  1036. loop:
  1037. for (; cursor < this.tokenCount; cursor++) {
  1038. balanceEnd = this.balance[cursor];
  1039. // stop scanning on balance edge that points to offset before start token
  1040. if (balanceEnd < startToken) {
  1041. break loop;
  1042. }
  1043. type = this.offsetAndType[cursor] >> TYPE_SHIFT;
  1044. // check token is stop type
  1045. switch (mode(type, this.source, offset)) {
  1046. case 1:
  1047. break loop;
  1048. case 2:
  1049. cursor++;
  1050. break loop;
  1051. default:
  1052. // fast forward to the end of balanced block
  1053. if (this.balance[balanceEnd] === cursor) {
  1054. cursor = balanceEnd;
  1055. }
  1056. offset = this.offsetAndType[cursor] & OFFSET_MASK;
  1057. }
  1058. }
  1059. return cursor - this.tokenIndex;
  1060. },
  1061. isBalanceEdge: function(pos) {
  1062. return this.balance[this.tokenIndex] < pos;
  1063. },
  1064. isDelim: function(code, offset) {
  1065. if (offset) {
  1066. return (
  1067. this.lookupType(offset) === TYPE$1.Delim &&
  1068. this.source.charCodeAt(this.lookupOffset(offset)) === code
  1069. );
  1070. }
  1071. return (
  1072. this.tokenType === TYPE$1.Delim &&
  1073. this.source.charCodeAt(this.tokenStart) === code
  1074. );
  1075. },
  1076. getTokenValue: function() {
  1077. return this.source.substring(this.tokenStart, this.tokenEnd);
  1078. },
  1079. getTokenLength: function() {
  1080. return this.tokenEnd - this.tokenStart;
  1081. },
  1082. substrToCursor: function(start) {
  1083. return this.source.substring(start, this.tokenStart);
  1084. },
  1085. skipWS: function() {
  1086. for (var i = this.tokenIndex, skipTokenCount = 0; i < this.tokenCount; i++, skipTokenCount++) {
  1087. if ((this.offsetAndType[i] >> TYPE_SHIFT) !== WHITESPACE) {
  1088. break;
  1089. }
  1090. }
  1091. if (skipTokenCount > 0) {
  1092. this.skip(skipTokenCount);
  1093. }
  1094. },
  1095. skipSC: function() {
  1096. while (this.tokenType === WHITESPACE || this.tokenType === COMMENT) {
  1097. this.next();
  1098. }
  1099. },
  1100. skip: function(tokenCount) {
  1101. var next = this.tokenIndex + tokenCount;
  1102. if (next < this.tokenCount) {
  1103. this.tokenIndex = next;
  1104. this.tokenStart = this.offsetAndType[next - 1] & OFFSET_MASK;
  1105. next = this.offsetAndType[next];
  1106. this.tokenType = next >> TYPE_SHIFT;
  1107. this.tokenEnd = next & OFFSET_MASK;
  1108. } else {
  1109. this.tokenIndex = this.tokenCount;
  1110. this.next();
  1111. }
  1112. },
  1113. next: function() {
  1114. var next = this.tokenIndex + 1;
  1115. if (next < this.tokenCount) {
  1116. this.tokenIndex = next;
  1117. this.tokenStart = this.tokenEnd;
  1118. next = this.offsetAndType[next];
  1119. this.tokenType = next >> TYPE_SHIFT;
  1120. this.tokenEnd = next & OFFSET_MASK;
  1121. } else {
  1122. this.tokenIndex = this.tokenCount;
  1123. this.eof = true;
  1124. this.tokenType = EOF$1;
  1125. this.tokenStart = this.tokenEnd = this.source.length;
  1126. }
  1127. },
  1128. forEachToken(fn) {
  1129. for (var i = 0, offset = this.firstCharOffset; i < this.tokenCount; i++) {
  1130. var start = offset;
  1131. var item = this.offsetAndType[i];
  1132. var end = item & OFFSET_MASK;
  1133. var type = item >> TYPE_SHIFT;
  1134. offset = end;
  1135. fn(type, start, end, i);
  1136. }
  1137. },
  1138. dump() {
  1139. var tokens = new Array(this.tokenCount);
  1140. this.forEachToken((type, start, end, index) => {
  1141. tokens[index] = {
  1142. idx: index,
  1143. type: NAME$1[type],
  1144. chunk: this.source.substring(start, end),
  1145. balance: this.balance[index]
  1146. };
  1147. });
  1148. return tokens;
  1149. }
  1150. };
  1151. var TokenStream_1 = TokenStream;
  1152. function noop(value) {
  1153. return value;
  1154. }
  1155. function generateMultiplier(multiplier) {
  1156. if (multiplier.min === 0 && multiplier.max === 0) {
  1157. return '*';
  1158. }
  1159. if (multiplier.min === 0 && multiplier.max === 1) {
  1160. return '?';
  1161. }
  1162. if (multiplier.min === 1 && multiplier.max === 0) {
  1163. return multiplier.comma ? '#' : '+';
  1164. }
  1165. if (multiplier.min === 1 && multiplier.max === 1) {
  1166. return '';
  1167. }
  1168. return (
  1169. (multiplier.comma ? '#' : '') +
  1170. (multiplier.min === multiplier.max
  1171. ? '{' + multiplier.min + '}'
  1172. : '{' + multiplier.min + ',' + (multiplier.max !== 0 ? multiplier.max : '') + '}'
  1173. )
  1174. );
  1175. }
  1176. function generateTypeOpts(node) {
  1177. switch (node.type) {
  1178. case 'Range':
  1179. return (
  1180. ' [' +
  1181. (node.min === null ? '-∞' : node.min) +
  1182. ',' +
  1183. (node.max === null ? '∞' : node.max) +
  1184. ']'
  1185. );
  1186. default:
  1187. throw new Error('Unknown node type `' + node.type + '`');
  1188. }
  1189. }
  1190. function generateSequence(node, decorate, forceBraces, compact) {
  1191. var combinator = node.combinator === ' ' || compact ? node.combinator : ' ' + node.combinator + ' ';
  1192. var result = node.terms.map(function(term) {
  1193. return generate(term, decorate, forceBraces, compact);
  1194. }).join(combinator);
  1195. if (node.explicit || forceBraces) {
  1196. result = (compact || result[0] === ',' ? '[' : '[ ') + result + (compact ? ']' : ' ]');
  1197. }
  1198. return result;
  1199. }
  1200. function generate(node, decorate, forceBraces, compact) {
  1201. var result;
  1202. switch (node.type) {
  1203. case 'Group':
  1204. result =
  1205. generateSequence(node, decorate, forceBraces, compact) +
  1206. (node.disallowEmpty ? '!' : '');
  1207. break;
  1208. case 'Multiplier':
  1209. // return since node is a composition
  1210. return (
  1211. generate(node.term, decorate, forceBraces, compact) +
  1212. decorate(generateMultiplier(node), node)
  1213. );
  1214. case 'Type':
  1215. result = '<' + node.name + (node.opts ? decorate(generateTypeOpts(node.opts), node.opts) : '') + '>';
  1216. break;
  1217. case 'Property':
  1218. result = '<\'' + node.name + '\'>';
  1219. break;
  1220. case 'Keyword':
  1221. result = node.name;
  1222. break;
  1223. case 'AtKeyword':
  1224. result = '@' + node.name;
  1225. break;
  1226. case 'Function':
  1227. result = node.name + '(';
  1228. break;
  1229. case 'String':
  1230. case 'Token':
  1231. result = node.value;
  1232. break;
  1233. case 'Comma':
  1234. result = ',';
  1235. break;
  1236. default:
  1237. throw new Error('Unknown node type `' + node.type + '`');
  1238. }
  1239. return decorate(result, node);
  1240. }
  1241. var generate_1 = function(node, options) {
  1242. var decorate = noop;
  1243. var forceBraces = false;
  1244. var compact = false;
  1245. if (typeof options === 'function') {
  1246. decorate = options;
  1247. } else if (options) {
  1248. forceBraces = Boolean(options.forceBraces);
  1249. compact = Boolean(options.compact);
  1250. if (typeof options.decorate === 'function') {
  1251. decorate = options.decorate;
  1252. }
  1253. }
  1254. return generate(node, decorate, forceBraces, compact);
  1255. };
  1256. const defaultLoc = { offset: 0, line: 1, column: 1 };
  1257. function locateMismatch(matchResult, node) {
  1258. const tokens = matchResult.tokens;
  1259. const longestMatch = matchResult.longestMatch;
  1260. const mismatchNode = longestMatch < tokens.length ? tokens[longestMatch].node || null : null;
  1261. const badNode = mismatchNode !== node ? mismatchNode : null;
  1262. let mismatchOffset = 0;
  1263. let mismatchLength = 0;
  1264. let entries = 0;
  1265. let css = '';
  1266. let start;
  1267. let end;
  1268. for (let i = 0; i < tokens.length; i++) {
  1269. const token = tokens[i].value;
  1270. if (i === longestMatch) {
  1271. mismatchLength = token.length;
  1272. mismatchOffset = css.length;
  1273. }
  1274. if (badNode !== null && tokens[i].node === badNode) {
  1275. if (i <= longestMatch) {
  1276. entries++;
  1277. } else {
  1278. entries = 0;
  1279. }
  1280. }
  1281. css += token;
  1282. }
  1283. if (longestMatch === tokens.length || entries > 1) { // last
  1284. start = fromLoc(badNode || node, 'end') || buildLoc(defaultLoc, css);
  1285. end = buildLoc(start);
  1286. } else {
  1287. start = fromLoc(badNode, 'start') ||
  1288. buildLoc(fromLoc(node, 'start') || defaultLoc, css.slice(0, mismatchOffset));
  1289. end = fromLoc(badNode, 'end') ||
  1290. buildLoc(start, css.substr(mismatchOffset, mismatchLength));
  1291. }
  1292. return {
  1293. css,
  1294. mismatchOffset,
  1295. mismatchLength,
  1296. start,
  1297. end
  1298. };
  1299. }
  1300. function fromLoc(node, point) {
  1301. const value = node && node.loc && node.loc[point];
  1302. if (value) {
  1303. return 'line' in value ? buildLoc(value) : value;
  1304. }
  1305. return null;
  1306. }
  1307. function buildLoc({ offset, line, column }, extra) {
  1308. const loc = {
  1309. offset,
  1310. line,
  1311. column
  1312. };
  1313. if (extra) {
  1314. const lines = extra.split(/\n|\r\n?|\f/);
  1315. loc.offset += extra.length;
  1316. loc.line += lines.length - 1;
  1317. loc.column = lines.length === 1 ? loc.column + extra.length : lines.pop().length + 1;
  1318. }
  1319. return loc;
  1320. }
  1321. const SyntaxReferenceError = function(type, referenceName) {
  1322. const error = createCustomError(
  1323. 'SyntaxReferenceError',
  1324. type + (referenceName ? ' `' + referenceName + '`' : '')
  1325. );
  1326. error.reference = referenceName;
  1327. return error;
  1328. };
  1329. const SyntaxMatchError = function(message, syntax, node, matchResult) {
  1330. const error = createCustomError('SyntaxMatchError', message);
  1331. const {
  1332. css,
  1333. mismatchOffset,
  1334. mismatchLength,
  1335. start,
  1336. end
  1337. } = locateMismatch(matchResult, node);
  1338. error.rawMessage = message;
  1339. error.syntax = syntax ? generate_1(syntax) : '<generic>';
  1340. error.css = css;
  1341. error.mismatchOffset = mismatchOffset;
  1342. error.mismatchLength = mismatchLength;
  1343. error.message = message + '\n' +
  1344. ' syntax: ' + error.syntax + '\n' +
  1345. ' value: ' + (css || '<empty string>') + '\n' +
  1346. ' --------' + new Array(error.mismatchOffset + 1).join('-') + '^';
  1347. Object.assign(error, start);
  1348. error.loc = {
  1349. source: (node && node.loc && node.loc.source) || '<unknown>',
  1350. start,
  1351. end
  1352. };
  1353. return error;
  1354. };
  1355. var error = {
  1356. SyntaxReferenceError,
  1357. SyntaxMatchError
  1358. };
  1359. var hasOwnProperty = Object.prototype.hasOwnProperty;
  1360. var keywords = Object.create(null);
  1361. var properties = Object.create(null);
  1362. var HYPHENMINUS = 45; // '-'.charCodeAt()
  1363. function isCustomProperty(str, offset) {
  1364. offset = offset || 0;
  1365. return str.length - offset >= 2 &&
  1366. str.charCodeAt(offset) === HYPHENMINUS &&
  1367. str.charCodeAt(offset + 1) === HYPHENMINUS;
  1368. }
  1369. function getVendorPrefix(str, offset) {
  1370. offset = offset || 0;
  1371. // verdor prefix should be at least 3 chars length
  1372. if (str.length - offset >= 3) {
  1373. // vendor prefix starts with hyper minus following non-hyper minus
  1374. if (str.charCodeAt(offset) === HYPHENMINUS &&
  1375. str.charCodeAt(offset + 1) !== HYPHENMINUS) {
  1376. // vendor prefix should contain a hyper minus at the ending
  1377. var secondDashIndex = str.indexOf('-', offset + 2);
  1378. if (secondDashIndex !== -1) {
  1379. return str.substring(offset, secondDashIndex + 1);
  1380. }
  1381. }
  1382. }
  1383. return '';
  1384. }
  1385. function getKeywordDescriptor(keyword) {
  1386. if (hasOwnProperty.call(keywords, keyword)) {
  1387. return keywords[keyword];
  1388. }
  1389. var name = keyword.toLowerCase();
  1390. if (hasOwnProperty.call(keywords, name)) {
  1391. return keywords[keyword] = keywords[name];
  1392. }
  1393. var custom = isCustomProperty(name, 0);
  1394. var vendor = !custom ? getVendorPrefix(name, 0) : '';
  1395. return keywords[keyword] = Object.freeze({
  1396. basename: name.substr(vendor.length),
  1397. name: name,
  1398. vendor: vendor,
  1399. prefix: vendor,
  1400. custom: custom
  1401. });
  1402. }
  1403. function getPropertyDescriptor(property) {
  1404. if (hasOwnProperty.call(properties, property)) {
  1405. return properties[property];
  1406. }
  1407. var name = property;
  1408. var hack = property[0];
  1409. if (hack === '/') {
  1410. hack = property[1] === '/' ? '//' : '/';
  1411. } else if (hack !== '_' &&
  1412. hack !== '*' &&
  1413. hack !== '$' &&
  1414. hack !== '#' &&
  1415. hack !== '+' &&
  1416. hack !== '&') {
  1417. hack = '';
  1418. }
  1419. var custom = isCustomProperty(name, hack.length);
  1420. // re-use result when possible (the same as for lower case)
  1421. if (!custom) {
  1422. name = name.toLowerCase();
  1423. if (hasOwnProperty.call(properties, name)) {
  1424. return properties[property] = properties[name];
  1425. }
  1426. }
  1427. var vendor = !custom ? getVendorPrefix(name, hack.length) : '';
  1428. var prefix = name.substr(0, hack.length + vendor.length);
  1429. return properties[property] = Object.freeze({
  1430. basename: name.substr(prefix.length),
  1431. name: name.substr(hack.length),
  1432. hack: hack,
  1433. vendor: vendor,
  1434. prefix: prefix,
  1435. custom: custom
  1436. });
  1437. }
  1438. var names = {
  1439. keyword: getKeywordDescriptor,
  1440. property: getPropertyDescriptor,
  1441. isCustomProperty: isCustomProperty,
  1442. vendorPrefix: getVendorPrefix
  1443. };
  1444. var MIN_SIZE = 16 * 1024;
  1445. var SafeUint32Array = typeof Uint32Array !== 'undefined' ? Uint32Array : Array; // fallback on Array when TypedArray is not supported
  1446. var adoptBuffer = function adoptBuffer(buffer, size) {
  1447. if (buffer === null || buffer.length < size) {
  1448. return new SafeUint32Array(Math.max(size + 1024, MIN_SIZE));
  1449. }
  1450. return buffer;
  1451. };
  1452. var TYPE$2 = _const.TYPE;
  1453. var isNewline$1 = charCodeDefinitions.isNewline;
  1454. var isName$2 = charCodeDefinitions.isName;
  1455. var isValidEscape$2 = charCodeDefinitions.isValidEscape;
  1456. var isNumberStart$1 = charCodeDefinitions.isNumberStart;
  1457. var isIdentifierStart$1 = charCodeDefinitions.isIdentifierStart;
  1458. var charCodeCategory$1 = charCodeDefinitions.charCodeCategory;
  1459. var isBOM$1 = charCodeDefinitions.isBOM;
  1460. var cmpStr$2 = utils.cmpStr;
  1461. var getNewlineLength$1 = utils.getNewlineLength;
  1462. var findWhiteSpaceEnd$1 = utils.findWhiteSpaceEnd;
  1463. var consumeEscaped$1 = utils.consumeEscaped;
  1464. var consumeName$1 = utils.consumeName;
  1465. var consumeNumber$1 = utils.consumeNumber;
  1466. var consumeBadUrlRemnants$1 = utils.consumeBadUrlRemnants;
  1467. var OFFSET_MASK$1 = 0x00FFFFFF;
  1468. var TYPE_SHIFT$1 = 24;
  1469. function tokenize(source, stream) {
  1470. function getCharCode(offset) {
  1471. return offset < sourceLength ? source.charCodeAt(offset) : 0;
  1472. }
  1473. // § 4.3.3. Consume a numeric token
  1474. function consumeNumericToken() {
  1475. // Consume a number and let number be the result.
  1476. offset = consumeNumber$1(source, offset);
  1477. // If the next 3 input code points would start an identifier, then:
  1478. if (isIdentifierStart$1(getCharCode(offset), getCharCode(offset + 1), getCharCode(offset + 2))) {
  1479. // Create a <dimension-token> with the same value and type flag as number, and a unit set initially to the empty string.
  1480. // Consume a name. Set the <dimension-token>’s unit to the returned value.
  1481. // Return the <dimension-token>.
  1482. type = TYPE$2.Dimension;
  1483. offset = consumeName$1(source, offset);
  1484. return;
  1485. }
  1486. // Otherwise, if the next input code point is U+0025 PERCENTAGE SIGN (%), consume it.
  1487. if (getCharCode(offset) === 0x0025) {
  1488. // Create a <percentage-token> with the same value as number, and return it.
  1489. type = TYPE$2.Percentage;
  1490. offset++;
  1491. return;
  1492. }
  1493. // Otherwise, create a <number-token> with the same value and type flag as number, and return it.
  1494. type = TYPE$2.Number;
  1495. }
  1496. // § 4.3.4. Consume an ident-like token
  1497. function consumeIdentLikeToken() {
  1498. const nameStartOffset = offset;
  1499. // Consume a name, and let string be the result.
  1500. offset = consumeName$1(source, offset);
  1501. // If string’s value is an ASCII case-insensitive match for "url",
  1502. // and the next input code point is U+0028 LEFT PARENTHESIS ((), consume it.
  1503. if (cmpStr$2(source, nameStartOffset, offset, 'url') && getCharCode(offset) === 0x0028) {
  1504. // While the next two input code points are whitespace, consume the next input code point.
  1505. offset = findWhiteSpaceEnd$1(source, offset + 1);
  1506. // If the next one or two input code points are U+0022 QUOTATION MARK ("), U+0027 APOSTROPHE ('),
  1507. // or whitespace followed by U+0022 QUOTATION MARK (") or U+0027 APOSTROPHE ('),
  1508. // then create a <function-token> with its value set to string and return it.
  1509. if (getCharCode(offset) === 0x0022 ||
  1510. getCharCode(offset) === 0x0027) {
  1511. type = TYPE$2.Function;
  1512. offset = nameStartOffset + 4;
  1513. return;
  1514. }
  1515. // Otherwise, consume a url token, and return it.
  1516. consumeUrlToken();
  1517. return;
  1518. }
  1519. // Otherwise, if the next input code point is U+0028 LEFT PARENTHESIS ((), consume it.
  1520. // Create a <function-token> with its value set to string and return it.
  1521. if (getCharCode(offset) === 0x0028) {
  1522. type = TYPE$2.Function;
  1523. offset++;
  1524. return;
  1525. }
  1526. // Otherwise, create an <ident-token> with its value set to string and return it.
  1527. type = TYPE$2.Ident;
  1528. }
  1529. // § 4.3.5. Consume a string token
  1530. function consumeStringToken(endingCodePoint) {
  1531. // This algorithm may be called with an ending code point, which denotes the code point
  1532. // that ends the string. If an ending code point is not specified,
  1533. // the current input code point is used.
  1534. if (!endingCodePoint) {
  1535. endingCodePoint = getCharCode(offset++);
  1536. }
  1537. // Initially create a <string-token> with its value set to the empty string.
  1538. type = TYPE$2.String;
  1539. // Repeatedly consume the next input code point from the stream:
  1540. for (; offset < source.length; offset++) {
  1541. var code = source.charCodeAt(offset);
  1542. switch (charCodeCategory$1(code)) {
  1543. // ending code point
  1544. case endingCodePoint:
  1545. // Return the <string-token>.
  1546. offset++;
  1547. return;
  1548. // EOF
  1549. case charCodeCategory$1.Eof:
  1550. // This is a parse error. Return the <string-token>.
  1551. return;
  1552. // newline
  1553. case charCodeCategory$1.WhiteSpace:
  1554. if (isNewline$1(code)) {
  1555. // This is a parse error. Reconsume the current input code point,
  1556. // create a <bad-string-token>, and return it.
  1557. offset += getNewlineLength$1(source, offset, code);
  1558. type = TYPE$2.BadString;
  1559. return;
  1560. }
  1561. break;
  1562. // U+005C REVERSE SOLIDUS (\)
  1563. case 0x005C:
  1564. // If the next input code point is EOF, do nothing.
  1565. if (offset === source.length - 1) {
  1566. break;
  1567. }
  1568. var nextCode = getCharCode(offset + 1);
  1569. // Otherwise, if the next input code point is a newline, consume it.
  1570. if (isNewline$1(nextCode)) {
  1571. offset += getNewlineLength$1(source, offset + 1, nextCode);
  1572. } else if (isValidEscape$2(code, nextCode)) {
  1573. // Otherwise, (the stream starts with a valid escape) consume
  1574. // an escaped code point and append the returned code point to
  1575. // the <string-token>’s value.
  1576. offset = consumeEscaped$1(source, offset) - 1;
  1577. }
  1578. break;
  1579. // anything else
  1580. // Append the current input code point to the <string-token>’s value.
  1581. }
  1582. }
  1583. }
  1584. // § 4.3.6. Consume a url token
  1585. // Note: This algorithm assumes that the initial "url(" has already been consumed.
  1586. // This algorithm also assumes that it’s being called to consume an "unquoted" value, like url(foo).
  1587. // A quoted value, like url("foo"), is parsed as a <function-token>. Consume an ident-like token
  1588. // automatically handles this distinction; this algorithm shouldn’t be called directly otherwise.
  1589. function consumeUrlToken() {
  1590. // Initially create a <url-token> with its value set to the empty string.
  1591. type = TYPE$2.Url;
  1592. // Consume as much whitespace as possible.
  1593. offset = findWhiteSpaceEnd$1(source, offset);
  1594. // Repeatedly consume the next input code point from the stream:
  1595. for (; offset < source.length; offset++) {
  1596. var code = source.charCodeAt(offset);
  1597. switch (charCodeCategory$1(code)) {
  1598. // U+0029 RIGHT PARENTHESIS ())
  1599. case 0x0029:
  1600. // Return the <url-token>.
  1601. offset++;
  1602. return;
  1603. // EOF
  1604. case charCodeCategory$1.Eof:
  1605. // This is a parse error. Return the <url-token>.
  1606. return;
  1607. // whitespace
  1608. case charCodeCategory$1.WhiteSpace:
  1609. // Consume as much whitespace as possible.
  1610. offset = findWhiteSpaceEnd$1(source, offset);
  1611. // If the next input code point is U+0029 RIGHT PARENTHESIS ()) or EOF,
  1612. // consume it and return the <url-token>
  1613. // (if EOF was encountered, this is a parse error);
  1614. if (getCharCode(offset) === 0x0029 || offset >= source.length) {
  1615. if (offset < source.length) {
  1616. offset++;
  1617. }
  1618. return;
  1619. }
  1620. // otherwise, consume the remnants of a bad url, create a <bad-url-token>,
  1621. // and return it.
  1622. offset = consumeBadUrlRemnants$1(source, offset);
  1623. type = TYPE$2.BadUrl;
  1624. return;
  1625. // U+0022 QUOTATION MARK (")
  1626. // U+0027 APOSTROPHE (')
  1627. // U+0028 LEFT PARENTHESIS (()
  1628. // non-printable code point
  1629. case 0x0022:
  1630. case 0x0027:
  1631. case 0x0028:
  1632. case charCodeCategory$1.NonPrintable:
  1633. // This is a parse error. Consume the remnants of a bad url,
  1634. // create a <bad-url-token>, and return it.
  1635. offset = consumeBadUrlRemnants$1(source, offset);
  1636. type = TYPE$2.BadUrl;
  1637. return;
  1638. // U+005C REVERSE SOLIDUS (\)
  1639. case 0x005C:
  1640. // If the stream starts with a valid escape, consume an escaped code point and
  1641. // append the returned code point to the <url-token>’s value.
  1642. if (isValidEscape$2(code, getCharCode(offset + 1))) {
  1643. offset = consumeEscaped$1(source, offset) - 1;
  1644. break;
  1645. }
  1646. // Otherwise, this is a parse error. Consume the remnants of a bad url,
  1647. // create a <bad-url-token>, and return it.
  1648. offset = consumeBadUrlRemnants$1(source, offset);
  1649. type = TYPE$2.BadUrl;
  1650. return;
  1651. // anything else
  1652. // Append the current input code point to the <url-token>’s value.
  1653. }
  1654. }
  1655. }
  1656. if (!stream) {
  1657. stream = new TokenStream_1();
  1658. }
  1659. // ensure source is a string
  1660. source = String(source || '');
  1661. var sourceLength = source.length;
  1662. var offsetAndType = adoptBuffer(stream.offsetAndType, sourceLength + 1); // +1 because of eof-token
  1663. var balance = adoptBuffer(stream.balance, sourceLength + 1);
  1664. var tokenCount = 0;
  1665. var start = isBOM$1(getCharCode(0));
  1666. var offset = start;
  1667. var balanceCloseType = 0;
  1668. var balanceStart = 0;
  1669. var balancePrev = 0;
  1670. // https://drafts.csswg.org/css-syntax-3/#consume-token
  1671. // § 4.3.1. Consume a token
  1672. while (offset < sourceLength) {
  1673. var code = source.charCodeAt(offset);
  1674. var type = 0;
  1675. balance[tokenCount] = sourceLength;
  1676. switch (charCodeCategory$1(code)) {
  1677. // whitespace
  1678. case charCodeCategory$1.WhiteSpace:
  1679. // Consume as much whitespace as possible. Return a <whitespace-token>.
  1680. type = TYPE$2.WhiteSpace;
  1681. offset = findWhiteSpaceEnd$1(source, offset + 1);
  1682. break;
  1683. // U+0022 QUOTATION MARK (")
  1684. case 0x0022:
  1685. // Consume a string token and return it.
  1686. consumeStringToken();
  1687. break;
  1688. // U+0023 NUMBER SIGN (#)
  1689. case 0x0023:
  1690. // If the next input code point is a name code point or the next two input code points are a valid escape, then:
  1691. if (isName$2(getCharCode(offset + 1)) || isValidEscape$2(getCharCode(offset + 1), getCharCode(offset + 2))) {
  1692. // Create a <hash-token>.
  1693. type = TYPE$2.Hash;
  1694. // If the next 3 input code points would start an identifier, set the <hash-token>’s type flag to "id".
  1695. // if (isIdentifierStart(getCharCode(offset + 1), getCharCode(offset + 2), getCharCode(offset + 3))) {
  1696. // // TODO: set id flag
  1697. // }
  1698. // Consume a name, and set the <hash-token>’s value to the returned string.
  1699. offset = consumeName$1(source, offset + 1);
  1700. // Return the <hash-token>.
  1701. } else {
  1702. // Otherwise, return a <delim-token> with its value set to the current input code point.
  1703. type = TYPE$2.Delim;
  1704. offset++;
  1705. }
  1706. break;
  1707. // U+0027 APOSTROPHE (')
  1708. case 0x0027:
  1709. // Consume a string token and return it.
  1710. consumeStringToken();
  1711. break;
  1712. // U+0028 LEFT PARENTHESIS (()
  1713. case 0x0028:
  1714. // Return a <(-token>.
  1715. type = TYPE$2.LeftParenthesis;
  1716. offset++;
  1717. break;
  1718. // U+0029 RIGHT PARENTHESIS ())
  1719. case 0x0029:
  1720. // Return a <)-token>.
  1721. type = TYPE$2.RightParenthesis;
  1722. offset++;
  1723. break;
  1724. // U+002B PLUS SIGN (+)
  1725. case 0x002B:
  1726. // If the input stream starts with a number, ...
  1727. if (isNumberStart$1(code, getCharCode(offset + 1), getCharCode(offset + 2))) {
  1728. // ... reconsume the current input code point, consume a numeric token, and return it.
  1729. consumeNumericToken();
  1730. } else {
  1731. // Otherwise, return a <delim-token> with its value set to the current input code point.
  1732. type = TYPE$2.Delim;
  1733. offset++;
  1734. }
  1735. break;
  1736. // U+002C COMMA (,)
  1737. case 0x002C:
  1738. // Return a <comma-token>.
  1739. type = TYPE$2.Comma;
  1740. offset++;
  1741. break;
  1742. // U+002D HYPHEN-MINUS (-)
  1743. case 0x002D:
  1744. // If the input stream starts with a number, reconsume the current input code point, consume a numeric token, and return it.
  1745. if (isNumberStart$1(code, getCharCode(offset + 1), getCharCode(offset + 2))) {
  1746. consumeNumericToken();
  1747. } else {
  1748. // Otherwise, if the next 2 input code points are U+002D HYPHEN-MINUS U+003E GREATER-THAN SIGN (->), consume them and return a <CDC-token>.
  1749. if (getCharCode(offset + 1) === 0x002D &&
  1750. getCharCode(offset + 2) === 0x003E) {
  1751. type = TYPE$2.CDC;
  1752. offset = offset + 3;
  1753. } else {
  1754. // Otherwise, if the input stream starts with an identifier, ...
  1755. if (isIdentifierStart$1(code, getCharCode(offset + 1), getCharCode(offset + 2))) {
  1756. // ... reconsume the current input code point, consume an ident-like token, and return it.
  1757. consumeIdentLikeToken();
  1758. } else {
  1759. // Otherwise, return a <delim-token> with its value set to the current input code point.
  1760. type = TYPE$2.Delim;
  1761. offset++;
  1762. }
  1763. }
  1764. }
  1765. break;
  1766. // U+002E FULL STOP (.)
  1767. case 0x002E:
  1768. // If the input stream starts with a number, ...
  1769. if (isNumberStart$1(code, getCharCode(offset + 1), getCharCode(offset + 2))) {
  1770. // ... reconsume the current input code point, consume a numeric token, and return it.
  1771. consumeNumericToken();
  1772. } else {
  1773. // Otherwise, return a <delim-token> with its value set to the current input code point.
  1774. type = TYPE$2.Delim;
  1775. offset++;
  1776. }
  1777. break;
  1778. // U+002F SOLIDUS (/)
  1779. case 0x002F:
  1780. // If the next two input code point are U+002F SOLIDUS (/) followed by a U+002A ASTERISK (*),
  1781. if (getCharCode(offset + 1) === 0x002A) {
  1782. // ... consume them and all following code points up to and including the first U+002A ASTERISK (*)
  1783. // followed by a U+002F SOLIDUS (/), or up to an EOF code point.
  1784. type = TYPE$2.Comment;
  1785. offset = source.indexOf('*/', offset + 2) + 2;
  1786. if (offset === 1) {
  1787. offset = source.length;
  1788. }
  1789. } else {
  1790. type = TYPE$2.Delim;
  1791. offset++;
  1792. }
  1793. break;
  1794. // U+003A COLON (:)
  1795. case 0x003A:
  1796. // Return a <colon-token>.
  1797. type = TYPE$2.Colon;
  1798. offset++;
  1799. break;
  1800. // U+003B SEMICOLON (;)
  1801. case 0x003B:
  1802. // Return a <semicolon-token>.
  1803. type = TYPE$2.Semicolon;
  1804. offset++;
  1805. break;
  1806. // U+003C LESS-THAN SIGN (<)
  1807. case 0x003C:
  1808. // If the next 3 input code points are U+0021 EXCLAMATION MARK U+002D HYPHEN-MINUS U+002D HYPHEN-MINUS (!--), ...
  1809. if (getCharCode(offset + 1) === 0x0021 &&
  1810. getCharCode(offset + 2) === 0x002D &&
  1811. getCharCode(offset + 3) === 0x002D) {
  1812. // ... consume them and return a <CDO-token>.
  1813. type = TYPE$2.CDO;
  1814. offset = offset + 4;
  1815. } else {
  1816. // Otherwise, return a <delim-token> with its value set to the current input code point.
  1817. type = TYPE$2.Delim;
  1818. offset++;
  1819. }
  1820. break;
  1821. // U+0040 COMMERCIAL AT (@)
  1822. case 0x0040:
  1823. // If the next 3 input code points would start an identifier, ...
  1824. if (isIdentifierStart$1(getCharCode(offset + 1), getCharCode(offset + 2), getCharCode(offset + 3))) {
  1825. // ... consume a name, create an <at-keyword-token> with its value set to the returned value, and return it.
  1826. type = TYPE$2.AtKeyword;
  1827. offset = consumeName$1(source, offset + 1);
  1828. } else {
  1829. // Otherwise, return a <delim-token> with its value set to the current input code point.
  1830. type = TYPE$2.Delim;
  1831. offset++;
  1832. }
  1833. break;
  1834. // U+005B LEFT SQUARE BRACKET ([)
  1835. case 0x005B:
  1836. // Return a <[-token>.
  1837. type = TYPE$2.LeftSquareBracket;
  1838. offset++;
  1839. break;
  1840. // U+005C REVERSE SOLIDUS (\)
  1841. case 0x005C:
  1842. // If the input stream starts with a valid escape, ...
  1843. if (isValidEscape$2(code, getCharCode(offset + 1))) {
  1844. // ... reconsume the current input code point, consume an ident-like token, and return it.
  1845. consumeIdentLikeToken();
  1846. } else {
  1847. // Otherwise, this is a parse error. Return a <delim-token> with its value set to the current input code point.
  1848. type = TYPE$2.Delim;
  1849. offset++;
  1850. }
  1851. break;
  1852. // U+005D RIGHT SQUARE BRACKET (])
  1853. case 0x005D:
  1854. // Return a <]-token>.
  1855. type = TYPE$2.RightSquareBracket;
  1856. offset++;
  1857. break;
  1858. // U+007B LEFT CURLY BRACKET ({)
  1859. case 0x007B:
  1860. // Return a <{-token>.
  1861. type = TYPE$2.LeftCurlyBracket;
  1862. offset++;
  1863. break;
  1864. // U+007D RIGHT CURLY BRACKET (})
  1865. case 0x007D:
  1866. // Return a <}-token>.
  1867. type = TYPE$2.RightCurlyBracket;
  1868. offset++;
  1869. break;
  1870. // digit
  1871. case charCodeCategory$1.Digit:
  1872. // Reconsume the current input code point, consume a numeric token, and return it.
  1873. consumeNumericToken();
  1874. break;
  1875. // name-start code point
  1876. case charCodeCategory$1.NameStart:
  1877. // Reconsume the current input code point, consume an ident-like token, and return it.
  1878. consumeIdentLikeToken();
  1879. break;
  1880. // EOF
  1881. case charCodeCategory$1.Eof:
  1882. // Return an <EOF-token>.
  1883. break;
  1884. // anything else
  1885. default:
  1886. // Return a <delim-token> with its value set to the current input code point.
  1887. type = TYPE$2.Delim;
  1888. offset++;
  1889. }
  1890. switch (type) {
  1891. case balanceCloseType:
  1892. balancePrev = balanceStart & OFFSET_MASK$1;
  1893. balanceStart = balance[balancePrev];
  1894. balanceCloseType = balanceStart >> TYPE_SHIFT$1;
  1895. balance[tokenCount] = balancePrev;
  1896. balance[balancePrev++] = tokenCount;
  1897. for (; balancePrev < tokenCount; balancePrev++) {
  1898. if (balance[balancePrev] === sourceLength) {
  1899. balance[balancePrev] = tokenCount;
  1900. }
  1901. }
  1902. break;
  1903. case TYPE$2.LeftParenthesis:
  1904. case TYPE$2.Function:
  1905. balance[tokenCount] = balanceStart;
  1906. balanceCloseType = TYPE$2.RightParenthesis;
  1907. balanceStart = (balanceCloseType << TYPE_SHIFT$1) | tokenCount;
  1908. break;
  1909. case TYPE$2.LeftSquareBracket:
  1910. balance[tokenCount] = balanceStart;
  1911. balanceCloseType = TYPE$2.RightSquareBracket;
  1912. balanceStart = (balanceCloseType << TYPE_SHIFT$1) | tokenCount;
  1913. break;
  1914. case TYPE$2.LeftCurlyBracket:
  1915. balance[tokenCount] = balanceStart;
  1916. balanceCloseType = TYPE$2.RightCurlyBracket;
  1917. balanceStart = (balanceCloseType << TYPE_SHIFT$1) | tokenCount;
  1918. break;
  1919. }
  1920. offsetAndType[tokenCount++] = (type << TYPE_SHIFT$1) | offset;
  1921. }
  1922. // finalize buffers
  1923. offsetAndType[tokenCount] = (TYPE$2.EOF << TYPE_SHIFT$1) | offset; // <EOF-token>
  1924. balance[tokenCount] = sourceLength;
  1925. balance[sourceLength] = sourceLength; // prevents false positive balance match with any token
  1926. while (balanceStart !== 0) {
  1927. balancePrev = balanceStart & OFFSET_MASK$1;
  1928. balanceStart = balance[balancePrev];
  1929. balance[balancePrev] = sourceLength;
  1930. }
  1931. // update stream
  1932. stream.source = source;
  1933. stream.firstCharOffset = start;
  1934. stream.offsetAndType = offsetAndType;
  1935. stream.tokenCount = tokenCount;
  1936. stream.balance = balance;
  1937. stream.reset();
  1938. stream.next();
  1939. return stream;
  1940. }
  1941. // extend tokenizer with constants
  1942. Object.keys(_const).forEach(function(key) {
  1943. tokenize[key] = _const[key];
  1944. });
  1945. // extend tokenizer with static methods from utils
  1946. Object.keys(charCodeDefinitions).forEach(function(key) {
  1947. tokenize[key] = charCodeDefinitions[key];
  1948. });
  1949. Object.keys(utils).forEach(function(key) {
  1950. tokenize[key] = utils[key];
  1951. });
  1952. var tokenizer = tokenize;
  1953. var isDigit$2 = tokenizer.isDigit;
  1954. var cmpChar$1 = tokenizer.cmpChar;
  1955. var TYPE$3 = tokenizer.TYPE;
  1956. var DELIM = TYPE$3.Delim;
  1957. var WHITESPACE$1 = TYPE$3.WhiteSpace;
  1958. var COMMENT$1 = TYPE$3.Comment;
  1959. var IDENT = TYPE$3.Ident;
  1960. var NUMBER = TYPE$3.Number;
  1961. var DIMENSION = TYPE$3.Dimension;
  1962. var PLUSSIGN = 0x002B; // U+002B PLUS SIGN (+)
  1963. var HYPHENMINUS$1 = 0x002D; // U+002D HYPHEN-MINUS (-)
  1964. var N = 0x006E; // U+006E LATIN SMALL LETTER N (n)
  1965. var DISALLOW_SIGN = true;
  1966. var ALLOW_SIGN = false;
  1967. function isDelim(token, code) {
  1968. return token !== null && token.type === DELIM && token.value.charCodeAt(0) === code;
  1969. }
  1970. function skipSC(token, offset, getNextToken) {
  1971. while (token !== null && (token.type === WHITESPACE$1 || token.type === COMMENT$1)) {
  1972. token = getNextToken(++offset);
  1973. }
  1974. return offset;
  1975. }
  1976. function checkInteger(token, valueOffset, disallowSign, offset) {
  1977. if (!token) {
  1978. return 0;
  1979. }
  1980. var code = token.value.charCodeAt(valueOffset);
  1981. if (code === PLUSSIGN || code === HYPHENMINUS$1) {
  1982. if (disallowSign) {
  1983. // Number sign is not allowed
  1984. return 0;
  1985. }
  1986. valueOffset++;
  1987. }
  1988. for (; valueOffset < token.value.length; valueOffset++) {
  1989. if (!isDigit$2(token.value.charCodeAt(valueOffset))) {
  1990. // Integer is expected
  1991. return 0;
  1992. }
  1993. }
  1994. return offset + 1;
  1995. }
  1996. // ... <signed-integer>
  1997. // ... ['+' | '-'] <signless-integer>
  1998. function consumeB(token, offset_, getNextToken) {
  1999. var sign = false;
  2000. var offset = skipSC(token, offset_, getNextToken);
  2001. token = getNextToken(offset);
  2002. if (token === null) {
  2003. return offset_;
  2004. }
  2005. if (token.type !== NUMBER) {
  2006. if (isDelim(token, PLUSSIGN) || isDelim(token, HYPHENMINUS$1)) {
  2007. sign = true;
  2008. offset = skipSC(getNextToken(++offset), offset, getNextToken);
  2009. token = getNextToken(offset);
  2010. if (token === null && token.type !== NUMBER) {
  2011. return 0;
  2012. }
  2013. } else {
  2014. return offset_;
  2015. }
  2016. }
  2017. if (!sign) {
  2018. var code = token.value.charCodeAt(0);
  2019. if (code !== PLUSSIGN && code !== HYPHENMINUS$1) {
  2020. // Number sign is expected
  2021. return 0;
  2022. }
  2023. }
  2024. return checkInteger(token, sign ? 0 : 1, sign, offset);
  2025. }
  2026. // An+B microsyntax https://www.w3.org/TR/css-syntax-3/#anb
  2027. var genericAnPlusB = function anPlusB(token, getNextToken) {
  2028. /* eslint-disable brace-style*/
  2029. var offset = 0;
  2030. if (!token) {
  2031. return 0;
  2032. }
  2033. // <integer>
  2034. if (token.type === NUMBER) {
  2035. return checkInteger(token, 0, ALLOW_SIGN, offset); // b
  2036. }
  2037. // -n
  2038. // -n <signed-integer>
  2039. // -n ['+' | '-'] <signless-integer>
  2040. // -n- <signless-integer>
  2041. // <dashndashdigit-ident>
  2042. else if (token.type === IDENT && token.value.charCodeAt(0) === HYPHENMINUS$1) {
  2043. // expect 1st char is N
  2044. if (!cmpChar$1(token.value, 1, N)) {
  2045. return 0;
  2046. }
  2047. switch (token.value.length) {
  2048. // -n
  2049. // -n <signed-integer>
  2050. // -n ['+' | '-'] <signless-integer>
  2051. case 2:
  2052. return consumeB(getNextToken(++offset), offset, getNextToken);
  2053. // -n- <signless-integer>
  2054. case 3:
  2055. if (token.value.charCodeAt(2) !== HYPHENMINUS$1) {
  2056. return 0;
  2057. }
  2058. offset = skipSC(getNextToken(++offset), offset, getNextToken);
  2059. token = getNextToken(offset);
  2060. return checkInteger(token, 0, DISALLOW_SIGN, offset);
  2061. // <dashndashdigit-ident>
  2062. default:
  2063. if (token.value.charCodeAt(2) !== HYPHENMINUS$1) {
  2064. return 0;
  2065. }
  2066. return checkInteger(token, 3, DISALLOW_SIGN, offset);
  2067. }
  2068. }
  2069. // '+'? n
  2070. // '+'? n <signed-integer>
  2071. // '+'? n ['+' | '-'] <signless-integer>
  2072. // '+'? n- <signless-integer>
  2073. // '+'? <ndashdigit-ident>
  2074. else if (token.type === IDENT || (isDelim(token, PLUSSIGN) && getNextToken(offset + 1).type === IDENT)) {
  2075. // just ignore a plus
  2076. if (token.type !== IDENT) {
  2077. token = getNextToken(++offset);
  2078. }
  2079. if (token === null || !cmpChar$1(token.value, 0, N)) {
  2080. return 0;
  2081. }
  2082. switch (token.value.length) {
  2083. // '+'? n
  2084. // '+'? n <signed-integer>
  2085. // '+'? n ['+' | '-'] <signless-integer>
  2086. case 1:
  2087. return consumeB(getNextToken(++offset), offset, getNextToken);
  2088. // '+'? n- <signless-integer>
  2089. case 2:
  2090. if (token.value.charCodeAt(1) !== HYPHENMINUS$1) {
  2091. return 0;
  2092. }
  2093. offset = skipSC(getNextToken(++offset), offset, getNextToken);
  2094. token = getNextToken(offset);
  2095. return checkInteger(token, 0, DISALLOW_SIGN, offset);
  2096. // '+'? <ndashdigit-ident>
  2097. default:
  2098. if (token.value.charCodeAt(1) !== HYPHENMINUS$1) {
  2099. return 0;
  2100. }
  2101. return checkInteger(token, 2, DISALLOW_SIGN, offset);
  2102. }
  2103. }
  2104. // <ndashdigit-dimension>
  2105. // <ndash-dimension> <signless-integer>
  2106. // <n-dimension>
  2107. // <n-dimension> <signed-integer>
  2108. // <n-dimension> ['+' | '-'] <signless-integer>
  2109. else if (token.type === DIMENSION) {
  2110. var code = token.value.charCodeAt(0);
  2111. var sign = code === PLUSSIGN || code === HYPHENMINUS$1 ? 1 : 0;
  2112. for (var i = sign; i < token.value.length; i++) {
  2113. if (!isDigit$2(token.value.charCodeAt(i))) {
  2114. break;
  2115. }
  2116. }
  2117. if (i === sign) {
  2118. // Integer is expected
  2119. return 0;
  2120. }
  2121. if (!cmpChar$1(token.value, i, N)) {
  2122. return 0;
  2123. }
  2124. // <n-dimension>
  2125. // <n-dimension> <signed-integer>
  2126. // <n-dimension> ['+' | '-'] <signless-integer>
  2127. if (i + 1 === token.value.length) {
  2128. return consumeB(getNextToken(++offset), offset, getNextToken);
  2129. } else {
  2130. if (token.value.charCodeAt(i + 1) !== HYPHENMINUS$1) {
  2131. return 0;
  2132. }
  2133. // <ndash-dimension> <signless-integer>
  2134. if (i + 2 === token.value.length) {
  2135. offset = skipSC(getNextToken(++offset), offset, getNextToken);
  2136. token = getNextToken(offset);
  2137. return checkInteger(token, 0, DISALLOW_SIGN, offset);
  2138. }
  2139. // <ndashdigit-dimension>
  2140. else {
  2141. return checkInteger(token, i + 2, DISALLOW_SIGN, offset);
  2142. }
  2143. }
  2144. }
  2145. return 0;
  2146. };
  2147. var isHexDigit$2 = tokenizer.isHexDigit;
  2148. var cmpChar$2 = tokenizer.cmpChar;
  2149. var TYPE$4 = tokenizer.TYPE;
  2150. var IDENT$1 = TYPE$4.Ident;
  2151. var DELIM$1 = TYPE$4.Delim;
  2152. var NUMBER$1 = TYPE$4.Number;
  2153. var DIMENSION$1 = TYPE$4.Dimension;
  2154. var PLUSSIGN$1 = 0x002B; // U+002B PLUS SIGN (+)
  2155. var HYPHENMINUS$2 = 0x002D; // U+002D HYPHEN-MINUS (-)
  2156. var QUESTIONMARK = 0x003F; // U+003F QUESTION MARK (?)
  2157. var U = 0x0075; // U+0075 LATIN SMALL LETTER U (u)
  2158. function isDelim$1(token, code) {
  2159. return token !== null && token.type === DELIM$1 && token.value.charCodeAt(0) === code;
  2160. }
  2161. function startsWith(token, code) {
  2162. return token.value.charCodeAt(0) === code;
  2163. }
  2164. function hexSequence(token, offset, allowDash) {
  2165. for (var pos = offset, hexlen = 0; pos < token.value.length; pos++) {
  2166. var code = token.value.charCodeAt(pos);
  2167. if (code === HYPHENMINUS$2 && allowDash && hexlen !== 0) {
  2168. if (hexSequence(token, offset + hexlen + 1, false) > 0) {
  2169. return 6; // dissallow following question marks
  2170. }
  2171. return 0; // dash at the ending of a hex sequence is not allowed
  2172. }
  2173. if (!isHexDigit$2(code)) {
  2174. return 0; // not a hex digit
  2175. }
  2176. if (++hexlen > 6) {
  2177. return 0; // too many hex digits
  2178. } }
  2179. return hexlen;
  2180. }
  2181. function withQuestionMarkSequence(consumed, length, getNextToken) {
  2182. if (!consumed) {
  2183. return 0; // nothing consumed
  2184. }
  2185. while (isDelim$1(getNextToken(length), QUESTIONMARK)) {
  2186. if (++consumed > 6) {
  2187. return 0; // too many question marks
  2188. }
  2189. length++;
  2190. }
  2191. return length;
  2192. }
  2193. // https://drafts.csswg.org/css-syntax/#urange
  2194. // Informally, the <urange> production has three forms:
  2195. // U+0001
  2196. // Defines a range consisting of a single code point, in this case the code point "1".
  2197. // U+0001-00ff
  2198. // Defines a range of codepoints between the first and the second value, in this case
  2199. // the range between "1" and "ff" (255 in decimal) inclusive.
  2200. // U+00??
  2201. // Defines a range of codepoints where the "?" characters range over all hex digits,
  2202. // in this case defining the same as the value U+0000-00ff.
  2203. // In each form, a maximum of 6 digits is allowed for each hexadecimal number (if you treat "?" as a hexadecimal digit).
  2204. //
  2205. // <urange> =
  2206. // u '+' <ident-token> '?'* |
  2207. // u <dimension-token> '?'* |
  2208. // u <number-token> '?'* |
  2209. // u <number-token> <dimension-token> |
  2210. // u <number-token> <number-token> |
  2211. // u '+' '?'+
  2212. var genericUrange = function urange(token, getNextToken) {
  2213. var length = 0;
  2214. // should start with `u` or `U`
  2215. if (token === null || token.type !== IDENT$1 || !cmpChar$2(token.value, 0, U)) {
  2216. return 0;
  2217. }
  2218. token = getNextToken(++length);
  2219. if (token === null) {
  2220. return 0;
  2221. }
  2222. // u '+' <ident-token> '?'*
  2223. // u '+' '?'+
  2224. if (isDelim$1(token, PLUSSIGN$1)) {
  2225. token = getNextToken(++length);
  2226. if (token === null) {
  2227. return 0;
  2228. }
  2229. if (token.type === IDENT$1) {
  2230. // u '+' <ident-token> '?'*
  2231. return withQuestionMarkSequence(hexSequence(token, 0, true), ++length, getNextToken);
  2232. }
  2233. if (isDelim$1(token, QUESTIONMARK)) {
  2234. // u '+' '?'+
  2235. return withQuestionMarkSequence(1, ++length, getNextToken);
  2236. }
  2237. // Hex digit or question mark is expected
  2238. return 0;
  2239. }
  2240. // u <number-token> '?'*
  2241. // u <number-token> <dimension-token>
  2242. // u <number-token> <number-token>
  2243. if (token.type === NUMBER$1) {
  2244. if (!startsWith(token, PLUSSIGN$1)) {
  2245. return 0;
  2246. }
  2247. var consumedHexLength = hexSequence(token, 1, true);
  2248. if (consumedHexLength === 0) {
  2249. return 0;
  2250. }
  2251. token = getNextToken(++length);
  2252. if (token === null) {
  2253. // u <number-token> <eof>
  2254. return length;
  2255. }
  2256. if (token.type === DIMENSION$1 || token.type === NUMBER$1) {
  2257. // u <number-token> <dimension-token>
  2258. // u <number-token> <number-token>
  2259. if (!startsWith(token, HYPHENMINUS$2) || !hexSequence(token, 1, false)) {
  2260. return 0;
  2261. }
  2262. return length + 1;
  2263. }
  2264. // u <number-token> '?'*
  2265. return withQuestionMarkSequence(consumedHexLength, length, getNextToken);
  2266. }
  2267. // u <dimension-token> '?'*
  2268. if (token.type === DIMENSION$1) {
  2269. if (!startsWith(token, PLUSSIGN$1)) {
  2270. return 0;
  2271. }
  2272. return withQuestionMarkSequence(hexSequence(token, 1, true), ++length, getNextToken);
  2273. }
  2274. return 0;
  2275. };
  2276. var isIdentifierStart$2 = tokenizer.isIdentifierStart;
  2277. var isHexDigit$3 = tokenizer.isHexDigit;
  2278. var isDigit$3 = tokenizer.isDigit;
  2279. var cmpStr$3 = tokenizer.cmpStr;
  2280. var consumeNumber$2 = tokenizer.consumeNumber;
  2281. var TYPE$5 = tokenizer.TYPE;
  2282. var cssWideKeywords = ['unset', 'initial', 'inherit'];
  2283. var calcFunctionNames = ['calc(', '-moz-calc(', '-webkit-calc('];
  2284. // https://www.w3.org/TR/css-values-3/#lengths
  2285. var LENGTH = {
  2286. // absolute length units
  2287. 'px': true,
  2288. 'mm': true,
  2289. 'cm': true,
  2290. 'in': true,
  2291. 'pt': true,
  2292. 'pc': true,
  2293. 'q': true,
  2294. // relative length units
  2295. 'em': true,
  2296. 'ex': true,
  2297. 'ch': true,
  2298. 'rem': true,
  2299. // viewport-percentage lengths
  2300. 'vh': true,
  2301. 'vw': true,
  2302. 'vmin': true,
  2303. 'vmax': true,
  2304. 'vm': true
  2305. };
  2306. var ANGLE = {
  2307. 'deg': true,
  2308. 'grad': true,
  2309. 'rad': true,
  2310. 'turn': true
  2311. };
  2312. var TIME = {
  2313. 's': true,
  2314. 'ms': true
  2315. };
  2316. var FREQUENCY = {
  2317. 'hz': true,
  2318. 'khz': true
  2319. };
  2320. // https://www.w3.org/TR/css-values-3/#resolution (https://drafts.csswg.org/css-values/#resolution)
  2321. var RESOLUTION = {
  2322. 'dpi': true,
  2323. 'dpcm': true,
  2324. 'dppx': true,
  2325. 'x': true // https://github.com/w3c/csswg-drafts/issues/461
  2326. };
  2327. // https://drafts.csswg.org/css-grid/#fr-unit
  2328. var FLEX = {
  2329. 'fr': true
  2330. };
  2331. // https://www.w3.org/TR/css3-speech/#mixing-props-voice-volume
  2332. var DECIBEL = {
  2333. 'db': true
  2334. };
  2335. // https://www.w3.org/TR/css3-speech/#voice-props-voice-pitch
  2336. var SEMITONES = {
  2337. 'st': true
  2338. };
  2339. // safe char code getter
  2340. function charCode(str, index) {
  2341. return index < str.length ? str.charCodeAt(index) : 0;
  2342. }
  2343. function eqStr(actual, expected) {
  2344. return cmpStr$3(actual, 0, actual.length, expected);
  2345. }
  2346. function eqStrAny(actual, expected) {
  2347. for (var i = 0; i < expected.length; i++) {
  2348. if (eqStr(actual, expected[i])) {
  2349. return true;
  2350. }
  2351. }
  2352. return false;
  2353. }
  2354. // IE postfix hack, i.e. 123\0 or 123px\9
  2355. function isPostfixIeHack(str, offset) {
  2356. if (offset !== str.length - 2) {
  2357. return false;
  2358. }
  2359. return (
  2360. str.charCodeAt(offset) === 0x005C && // U+005C REVERSE SOLIDUS (\)
  2361. isDigit$3(str.charCodeAt(offset + 1))
  2362. );
  2363. }
  2364. function outOfRange(opts, value, numEnd) {
  2365. if (opts && opts.type === 'Range') {
  2366. var num = Number(
  2367. numEnd !== undefined && numEnd !== value.length
  2368. ? value.substr(0, numEnd)
  2369. : value
  2370. );
  2371. if (isNaN(num)) {
  2372. return true;
  2373. }
  2374. if (opts.min !== null && num < opts.min) {
  2375. return true;
  2376. }
  2377. if (opts.max !== null && num > opts.max) {
  2378. return true;
  2379. }
  2380. }
  2381. return false;
  2382. }
  2383. function consumeFunction(token, getNextToken) {
  2384. var startIdx = token.index;
  2385. var length = 0;
  2386. // balanced token consuming
  2387. do {
  2388. length++;
  2389. if (token.balance <= startIdx) {
  2390. break;
  2391. }
  2392. } while (token = getNextToken(length));
  2393. return length;
  2394. }
  2395. // TODO: implement
  2396. // can be used wherever <length>, <frequency>, <angle>, <time>, <percentage>, <number>, or <integer> values are allowed
  2397. // https://drafts.csswg.org/css-values/#calc-notation
  2398. function calc(next) {
  2399. return function(token, getNextToken, opts) {
  2400. if (token === null) {
  2401. return 0;
  2402. }
  2403. if (token.type === TYPE$5.Function && eqStrAny(token.value, calcFunctionNames)) {
  2404. return consumeFunction(token, getNextToken);
  2405. }
  2406. return next(token, getNextToken, opts);
  2407. };
  2408. }
  2409. function tokenType(expectedTokenType) {
  2410. return function(token) {
  2411. if (token === null || token.type !== expectedTokenType) {
  2412. return 0;
  2413. }
  2414. return 1;
  2415. };
  2416. }
  2417. function func(name) {
  2418. name = name + '(';
  2419. return function(token, getNextToken) {
  2420. if (token !== null && eqStr(token.value, name)) {
  2421. return consumeFunction(token, getNextToken);
  2422. }
  2423. return 0;
  2424. };
  2425. }
  2426. // =========================
  2427. // Complex types
  2428. //
  2429. // https://drafts.csswg.org/css-values-4/#custom-idents
  2430. // 4.2. Author-defined Identifiers: the <custom-ident> type
  2431. // Some properties accept arbitrary author-defined identifiers as a component value.
  2432. // This generic data type is denoted by <custom-ident>, and represents any valid CSS identifier
  2433. // that would not be misinterpreted as a pre-defined keyword in that property’s value definition.
  2434. //
  2435. // See also: https://developer.mozilla.org/en-US/docs/Web/CSS/custom-ident
  2436. function customIdent(token) {
  2437. if (token === null || token.type !== TYPE$5.Ident) {
  2438. return 0;
  2439. }
  2440. var name = token.value.toLowerCase();
  2441. // The CSS-wide keywords are not valid <custom-ident>s
  2442. if (eqStrAny(name, cssWideKeywords)) {
  2443. return 0;
  2444. }
  2445. // The default keyword is reserved and is also not a valid <custom-ident>
  2446. if (eqStr(name, 'default')) {
  2447. return 0;
  2448. }
  2449. // TODO: ignore property specific keywords (as described https://developer.mozilla.org/en-US/docs/Web/CSS/custom-ident)
  2450. // Specifications using <custom-ident> must specify clearly what other keywords
  2451. // are excluded from <custom-ident>, if any—for example by saying that any pre-defined keywords
  2452. // in that property’s value definition are excluded. Excluded keywords are excluded
  2453. // in all ASCII case permutations.
  2454. return 1;
  2455. }
  2456. // https://drafts.csswg.org/css-variables/#typedef-custom-property-name
  2457. // A custom property is any property whose name starts with two dashes (U+002D HYPHEN-MINUS), like --foo.
  2458. // The <custom-property-name> production corresponds to this: it’s defined as any valid identifier
  2459. // that starts with two dashes, except -- itself, which is reserved for future use by CSS.
  2460. // NOTE: Current implementation treat `--` as a valid name since most (all?) major browsers treat it as valid.
  2461. function customPropertyName(token) {
  2462. // ... defined as any valid identifier
  2463. if (token === null || token.type !== TYPE$5.Ident) {
  2464. return 0;
  2465. }
  2466. // ... that starts with two dashes (U+002D HYPHEN-MINUS)
  2467. if (charCode(token.value, 0) !== 0x002D || charCode(token.value, 1) !== 0x002D) {
  2468. return 0;
  2469. }
  2470. return 1;
  2471. }
  2472. // https://drafts.csswg.org/css-color-4/#hex-notation
  2473. // The syntax of a <hex-color> is a <hash-token> token whose value consists of 3, 4, 6, or 8 hexadecimal digits.
  2474. // In other words, a hex color is written as a hash character, "#", followed by some number of digits 0-9 or
  2475. // letters a-f (the case of the letters doesn’t matter - #00ff00 is identical to #00FF00).
  2476. function hexColor(token) {
  2477. if (token === null || token.type !== TYPE$5.Hash) {
  2478. return 0;
  2479. }
  2480. var length = token.value.length;
  2481. // valid values (length): #rgb (4), #rgba (5), #rrggbb (7), #rrggbbaa (9)
  2482. if (length !== 4 && length !== 5 && length !== 7 && length !== 9) {
  2483. return 0;
  2484. }
  2485. for (var i = 1; i < length; i++) {
  2486. if (!isHexDigit$3(token.value.charCodeAt(i))) {
  2487. return 0;
  2488. }
  2489. }
  2490. return 1;
  2491. }
  2492. function idSelector(token) {
  2493. if (token === null || token.type !== TYPE$5.Hash) {
  2494. return 0;
  2495. }
  2496. if (!isIdentifierStart$2(charCode(token.value, 1), charCode(token.value, 2), charCode(token.value, 3))) {
  2497. return 0;
  2498. }
  2499. return 1;
  2500. }
  2501. // https://drafts.csswg.org/css-syntax/#any-value
  2502. // It represents the entirety of what a valid declaration can have as its value.
  2503. function declarationValue(token, getNextToken) {
  2504. if (!token) {
  2505. return 0;
  2506. }
  2507. var length = 0;
  2508. var level = 0;
  2509. var startIdx = token.index;
  2510. // The <declaration-value> production matches any sequence of one or more tokens,
  2511. // so long as the sequence ...
  2512. scan:
  2513. do {
  2514. switch (token.type) {
  2515. // ... does not contain <bad-string-token>, <bad-url-token>,
  2516. case TYPE$5.BadString:
  2517. case TYPE$5.BadUrl:
  2518. break scan;
  2519. // ... unmatched <)-token>, <]-token>, or <}-token>,
  2520. case TYPE$5.RightCurlyBracket:
  2521. case TYPE$5.RightParenthesis:
  2522. case TYPE$5.RightSquareBracket:
  2523. if (token.balance > token.index || token.balance < startIdx) {
  2524. break scan;
  2525. }
  2526. level--;
  2527. break;
  2528. // ... or top-level <semicolon-token> tokens
  2529. case TYPE$5.Semicolon:
  2530. if (level === 0) {
  2531. break scan;
  2532. }
  2533. break;
  2534. // ... or <delim-token> tokens with a value of "!"
  2535. case TYPE$5.Delim:
  2536. if (token.value === '!' && level === 0) {
  2537. break scan;
  2538. }
  2539. break;
  2540. case TYPE$5.Function:
  2541. case TYPE$5.LeftParenthesis:
  2542. case TYPE$5.LeftSquareBracket:
  2543. case TYPE$5.LeftCurlyBracket:
  2544. level++;
  2545. break;
  2546. }
  2547. length++;
  2548. // until balance closing
  2549. if (token.balance <= startIdx) {
  2550. break;
  2551. }
  2552. } while (token = getNextToken(length));
  2553. return length;
  2554. }
  2555. // https://drafts.csswg.org/css-syntax/#any-value
  2556. // The <any-value> production is identical to <declaration-value>, but also
  2557. // allows top-level <semicolon-token> tokens and <delim-token> tokens
  2558. // with a value of "!". It represents the entirety of what valid CSS can be in any context.
  2559. function anyValue(token, getNextToken) {
  2560. if (!token) {
  2561. return 0;
  2562. }
  2563. var startIdx = token.index;
  2564. var length = 0;
  2565. // The <any-value> production matches any sequence of one or more tokens,
  2566. // so long as the sequence ...
  2567. scan:
  2568. do {
  2569. switch (token.type) {
  2570. // ... does not contain <bad-string-token>, <bad-url-token>,
  2571. case TYPE$5.BadString:
  2572. case TYPE$5.BadUrl:
  2573. break scan;
  2574. // ... unmatched <)-token>, <]-token>, or <}-token>,
  2575. case TYPE$5.RightCurlyBracket:
  2576. case TYPE$5.RightParenthesis:
  2577. case TYPE$5.RightSquareBracket:
  2578. if (token.balance > token.index || token.balance < startIdx) {
  2579. break scan;
  2580. }
  2581. break;
  2582. }
  2583. length++;
  2584. // until balance closing
  2585. if (token.balance <= startIdx) {
  2586. break;
  2587. }
  2588. } while (token = getNextToken(length));
  2589. return length;
  2590. }
  2591. // =========================
  2592. // Dimensions
  2593. //
  2594. function dimension(type) {
  2595. return function(token, getNextToken, opts) {
  2596. if (token === null || token.type !== TYPE$5.Dimension) {
  2597. return 0;
  2598. }
  2599. var numberEnd = consumeNumber$2(token.value, 0);
  2600. // check unit
  2601. if (type !== null) {
  2602. // check for IE postfix hack, i.e. 123px\0 or 123px\9
  2603. var reverseSolidusOffset = token.value.indexOf('\\', numberEnd);
  2604. var unit = reverseSolidusOffset === -1 || !isPostfixIeHack(token.value, reverseSolidusOffset)
  2605. ? token.value.substr(numberEnd)
  2606. : token.value.substring(numberEnd, reverseSolidusOffset);
  2607. if (type.hasOwnProperty(unit.toLowerCase()) === false) {
  2608. return 0;
  2609. }
  2610. }
  2611. // check range if specified
  2612. if (outOfRange(opts, token.value, numberEnd)) {
  2613. return 0;
  2614. }
  2615. return 1;
  2616. };
  2617. }
  2618. // =========================
  2619. // Percentage
  2620. //
  2621. // §5.5. Percentages: the <percentage> type
  2622. // https://drafts.csswg.org/css-values-4/#percentages
  2623. function percentage(token, getNextToken, opts) {
  2624. // ... corresponds to the <percentage-token> production
  2625. if (token === null || token.type !== TYPE$5.Percentage) {
  2626. return 0;
  2627. }
  2628. // check range if specified
  2629. if (outOfRange(opts, token.value, token.value.length - 1)) {
  2630. return 0;
  2631. }
  2632. return 1;
  2633. }
  2634. // =========================
  2635. // Numeric
  2636. //
  2637. // https://drafts.csswg.org/css-values-4/#numbers
  2638. // The value <zero> represents a literal number with the value 0. Expressions that merely
  2639. // evaluate to a <number> with the value 0 (for example, calc(0)) do not match <zero>;
  2640. // only literal <number-token>s do.
  2641. function zero(next) {
  2642. if (typeof next !== 'function') {
  2643. next = function() {
  2644. return 0;
  2645. };
  2646. }
  2647. return function(token, getNextToken, opts) {
  2648. if (token !== null && token.type === TYPE$5.Number) {
  2649. if (Number(token.value) === 0) {
  2650. return 1;
  2651. }
  2652. }
  2653. return next(token, getNextToken, opts);
  2654. };
  2655. }
  2656. // § 5.3. Real Numbers: the <number> type
  2657. // https://drafts.csswg.org/css-values-4/#numbers
  2658. // Number values are denoted by <number>, and represent real numbers, possibly with a fractional component.
  2659. // ... It corresponds to the <number-token> production
  2660. function number(token, getNextToken, opts) {
  2661. if (token === null) {
  2662. return 0;
  2663. }
  2664. var numberEnd = consumeNumber$2(token.value, 0);
  2665. var isNumber = numberEnd === token.value.length;
  2666. if (!isNumber && !isPostfixIeHack(token.value, numberEnd)) {
  2667. return 0;
  2668. }
  2669. // check range if specified
  2670. if (outOfRange(opts, token.value, numberEnd)) {
  2671. return 0;
  2672. }
  2673. return 1;
  2674. }
  2675. // §5.2. Integers: the <integer> type
  2676. // https://drafts.csswg.org/css-values-4/#integers
  2677. function integer(token, getNextToken, opts) {
  2678. // ... corresponds to a subset of the <number-token> production
  2679. if (token === null || token.type !== TYPE$5.Number) {
  2680. return 0;
  2681. }
  2682. // The first digit of an integer may be immediately preceded by `-` or `+` to indicate the integer’s sign.
  2683. var i = token.value.charCodeAt(0) === 0x002B || // U+002B PLUS SIGN (+)
  2684. token.value.charCodeAt(0) === 0x002D ? 1 : 0; // U+002D HYPHEN-MINUS (-)
  2685. // When written literally, an integer is one or more decimal digits 0 through 9 ...
  2686. for (; i < token.value.length; i++) {
  2687. if (!isDigit$3(token.value.charCodeAt(i))) {
  2688. return 0;
  2689. }
  2690. }
  2691. // check range if specified
  2692. if (outOfRange(opts, token.value, i)) {
  2693. return 0;
  2694. }
  2695. return 1;
  2696. }
  2697. var generic = {
  2698. // token types
  2699. 'ident-token': tokenType(TYPE$5.Ident),
  2700. 'function-token': tokenType(TYPE$5.Function),
  2701. 'at-keyword-token': tokenType(TYPE$5.AtKeyword),
  2702. 'hash-token': tokenType(TYPE$5.Hash),
  2703. 'string-token': tokenType(TYPE$5.String),
  2704. 'bad-string-token': tokenType(TYPE$5.BadString),
  2705. 'url-token': tokenType(TYPE$5.Url),
  2706. 'bad-url-token': tokenType(TYPE$5.BadUrl),
  2707. 'delim-token': tokenType(TYPE$5.Delim),
  2708. 'number-token': tokenType(TYPE$5.Number),
  2709. 'percentage-token': tokenType(TYPE$5.Percentage),
  2710. 'dimension-token': tokenType(TYPE$5.Dimension),
  2711. 'whitespace-token': tokenType(TYPE$5.WhiteSpace),
  2712. 'CDO-token': tokenType(TYPE$5.CDO),
  2713. 'CDC-token': tokenType(TYPE$5.CDC),
  2714. 'colon-token': tokenType(TYPE$5.Colon),
  2715. 'semicolon-token': tokenType(TYPE$5.Semicolon),
  2716. 'comma-token': tokenType(TYPE$5.Comma),
  2717. '[-token': tokenType(TYPE$5.LeftSquareBracket),
  2718. ']-token': tokenType(TYPE$5.RightSquareBracket),
  2719. '(-token': tokenType(TYPE$5.LeftParenthesis),
  2720. ')-token': tokenType(TYPE$5.RightParenthesis),
  2721. '{-token': tokenType(TYPE$5.LeftCurlyBracket),
  2722. '}-token': tokenType(TYPE$5.RightCurlyBracket),
  2723. // token type aliases
  2724. 'string': tokenType(TYPE$5.String),
  2725. 'ident': tokenType(TYPE$5.Ident),
  2726. // complex types
  2727. 'custom-ident': customIdent,
  2728. 'custom-property-name': customPropertyName,
  2729. 'hex-color': hexColor,
  2730. 'id-selector': idSelector, // element( <id-selector> )
  2731. 'an-plus-b': genericAnPlusB,
  2732. 'urange': genericUrange,
  2733. 'declaration-value': declarationValue,
  2734. 'any-value': anyValue,
  2735. // dimensions
  2736. 'dimension': calc(dimension(null)),
  2737. 'angle': calc(dimension(ANGLE)),
  2738. 'decibel': calc(dimension(DECIBEL)),
  2739. 'frequency': calc(dimension(FREQUENCY)),
  2740. 'flex': calc(dimension(FLEX)),
  2741. 'length': calc(zero(dimension(LENGTH))),
  2742. 'resolution': calc(dimension(RESOLUTION)),
  2743. 'semitones': calc(dimension(SEMITONES)),
  2744. 'time': calc(dimension(TIME)),
  2745. // percentage
  2746. 'percentage': calc(percentage),
  2747. // numeric
  2748. 'zero': zero(),
  2749. 'number': calc(number),
  2750. 'integer': calc(integer),
  2751. // old IE stuff
  2752. '-ms-legacy-expression': func('expression')
  2753. };
  2754. var _SyntaxError$1 = function SyntaxError(message, input, offset) {
  2755. var error = createCustomError('SyntaxError', message);
  2756. error.input = input;
  2757. error.offset = offset;
  2758. error.rawMessage = message;
  2759. error.message = error.rawMessage + '\n' +
  2760. ' ' + error.input + '\n' +
  2761. '--' + new Array((error.offset || error.input.length) + 1).join('-') + '^';
  2762. return error;
  2763. };
  2764. var TAB = 9;
  2765. var N$1 = 10;
  2766. var F = 12;
  2767. var R = 13;
  2768. var SPACE = 32;
  2769. var Tokenizer = function(str) {
  2770. this.str = str;
  2771. this.pos = 0;
  2772. };
  2773. Tokenizer.prototype = {
  2774. charCodeAt: function(pos) {
  2775. return pos < this.str.length ? this.str.charCodeAt(pos) : 0;
  2776. },
  2777. charCode: function() {
  2778. return this.charCodeAt(this.pos);
  2779. },
  2780. nextCharCode: function() {
  2781. return this.charCodeAt(this.pos + 1);
  2782. },
  2783. nextNonWsCode: function(pos) {
  2784. return this.charCodeAt(this.findWsEnd(pos));
  2785. },
  2786. findWsEnd: function(pos) {
  2787. for (; pos < this.str.length; pos++) {
  2788. var code = this.str.charCodeAt(pos);
  2789. if (code !== R && code !== N$1 && code !== F && code !== SPACE && code !== TAB) {
  2790. break;
  2791. }
  2792. }
  2793. return pos;
  2794. },
  2795. substringToPos: function(end) {
  2796. return this.str.substring(this.pos, this.pos = end);
  2797. },
  2798. eat: function(code) {
  2799. if (this.charCode() !== code) {
  2800. this.error('Expect `' + String.fromCharCode(code) + '`');
  2801. }
  2802. this.pos++;
  2803. },
  2804. peek: function() {
  2805. return this.pos < this.str.length ? this.str.charAt(this.pos++) : '';
  2806. },
  2807. error: function(message) {
  2808. throw new _SyntaxError$1(message, this.str, this.pos);
  2809. }
  2810. };
  2811. var tokenizer$1 = Tokenizer;
  2812. var TAB$1 = 9;
  2813. var N$2 = 10;
  2814. var F$1 = 12;
  2815. var R$1 = 13;
  2816. var SPACE$1 = 32;
  2817. var EXCLAMATIONMARK = 33; // !
  2818. var NUMBERSIGN = 35; // #
  2819. var AMPERSAND = 38; // &
  2820. var APOSTROPHE = 39; // '
  2821. var LEFTPARENTHESIS = 40; // (
  2822. var RIGHTPARENTHESIS = 41; // )
  2823. var ASTERISK = 42; // *
  2824. var PLUSSIGN$2 = 43; // +
  2825. var COMMA = 44; // ,
  2826. var HYPERMINUS = 45; // -
  2827. var LESSTHANSIGN = 60; // <
  2828. var GREATERTHANSIGN = 62; // >
  2829. var QUESTIONMARK$1 = 63; // ?
  2830. var COMMERCIALAT = 64; // @
  2831. var LEFTSQUAREBRACKET = 91; // [
  2832. var RIGHTSQUAREBRACKET = 93; // ]
  2833. var LEFTCURLYBRACKET = 123; // {
  2834. var VERTICALLINE = 124; // |
  2835. var RIGHTCURLYBRACKET = 125; // }
  2836. var INFINITY = 8734; // ∞
  2837. var NAME_CHAR = createCharMap(function(ch) {
  2838. return /[a-zA-Z0-9\-]/.test(ch);
  2839. });
  2840. var COMBINATOR_PRECEDENCE = {
  2841. ' ': 1,
  2842. '&&': 2,
  2843. '||': 3,
  2844. '|': 4
  2845. };
  2846. function createCharMap(fn) {
  2847. var array = typeof Uint32Array === 'function' ? new Uint32Array(128) : new Array(128);
  2848. for (var i = 0; i < 128; i++) {
  2849. array[i] = fn(String.fromCharCode(i)) ? 1 : 0;
  2850. }
  2851. return array;
  2852. }
  2853. function scanSpaces(tokenizer) {
  2854. return tokenizer.substringToPos(
  2855. tokenizer.findWsEnd(tokenizer.pos)
  2856. );
  2857. }
  2858. function scanWord(tokenizer) {
  2859. var end = tokenizer.pos;
  2860. for (; end < tokenizer.str.length; end++) {
  2861. var code = tokenizer.str.charCodeAt(end);
  2862. if (code >= 128 || NAME_CHAR[code] === 0) {
  2863. break;
  2864. }
  2865. }
  2866. if (tokenizer.pos === end) {
  2867. tokenizer.error('Expect a keyword');
  2868. }
  2869. return tokenizer.substringToPos(end);
  2870. }
  2871. function scanNumber(tokenizer) {
  2872. var end = tokenizer.pos;
  2873. for (; end < tokenizer.str.length; end++) {
  2874. var code = tokenizer.str.charCodeAt(end);
  2875. if (code < 48 || code > 57) {
  2876. break;
  2877. }
  2878. }
  2879. if (tokenizer.pos === end) {
  2880. tokenizer.error('Expect a number');
  2881. }
  2882. return tokenizer.substringToPos(end);
  2883. }
  2884. function scanString(tokenizer) {
  2885. var end = tokenizer.str.indexOf('\'', tokenizer.pos + 1);
  2886. if (end === -1) {
  2887. tokenizer.pos = tokenizer.str.length;
  2888. tokenizer.error('Expect an apostrophe');
  2889. }
  2890. return tokenizer.substringToPos(end + 1);
  2891. }
  2892. function readMultiplierRange(tokenizer) {
  2893. var min = null;
  2894. var max = null;
  2895. tokenizer.eat(LEFTCURLYBRACKET);
  2896. min = scanNumber(tokenizer);
  2897. if (tokenizer.charCode() === COMMA) {
  2898. tokenizer.pos++;
  2899. if (tokenizer.charCode() !== RIGHTCURLYBRACKET) {
  2900. max = scanNumber(tokenizer);
  2901. }
  2902. } else {
  2903. max = min;
  2904. }
  2905. tokenizer.eat(RIGHTCURLYBRACKET);
  2906. return {
  2907. min: Number(min),
  2908. max: max ? Number(max) : 0
  2909. };
  2910. }
  2911. function readMultiplier(tokenizer) {
  2912. var range = null;
  2913. var comma = false;
  2914. switch (tokenizer.charCode()) {
  2915. case ASTERISK:
  2916. tokenizer.pos++;
  2917. range = {
  2918. min: 0,
  2919. max: 0
  2920. };
  2921. break;
  2922. case PLUSSIGN$2:
  2923. tokenizer.pos++;
  2924. range = {
  2925. min: 1,
  2926. max: 0
  2927. };
  2928. break;
  2929. case QUESTIONMARK$1:
  2930. tokenizer.pos++;
  2931. range = {
  2932. min: 0,
  2933. max: 1
  2934. };
  2935. break;
  2936. case NUMBERSIGN:
  2937. tokenizer.pos++;
  2938. comma = true;
  2939. if (tokenizer.charCode() === LEFTCURLYBRACKET) {
  2940. range = readMultiplierRange(tokenizer);
  2941. } else {
  2942. range = {
  2943. min: 1,
  2944. max: 0
  2945. };
  2946. }
  2947. break;
  2948. case LEFTCURLYBRACKET:
  2949. range = readMultiplierRange(tokenizer);
  2950. break;
  2951. default:
  2952. return null;
  2953. }
  2954. return {
  2955. type: 'Multiplier',
  2956. comma: comma,
  2957. min: range.min,
  2958. max: range.max,
  2959. term: null
  2960. };
  2961. }
  2962. function maybeMultiplied(tokenizer, node) {
  2963. var multiplier = readMultiplier(tokenizer);
  2964. if (multiplier !== null) {
  2965. multiplier.term = node;
  2966. return multiplier;
  2967. }
  2968. return node;
  2969. }
  2970. function maybeToken(tokenizer) {
  2971. var ch = tokenizer.peek();
  2972. if (ch === '') {
  2973. return null;
  2974. }
  2975. return {
  2976. type: 'Token',
  2977. value: ch
  2978. };
  2979. }
  2980. function readProperty(tokenizer) {
  2981. var name;
  2982. tokenizer.eat(LESSTHANSIGN);
  2983. tokenizer.eat(APOSTROPHE);
  2984. name = scanWord(tokenizer);
  2985. tokenizer.eat(APOSTROPHE);
  2986. tokenizer.eat(GREATERTHANSIGN);
  2987. return maybeMultiplied(tokenizer, {
  2988. type: 'Property',
  2989. name: name
  2990. });
  2991. }
  2992. // https://drafts.csswg.org/css-values-3/#numeric-ranges
  2993. // 4.1. Range Restrictions and Range Definition Notation
  2994. //
  2995. // Range restrictions can be annotated in the numeric type notation using CSS bracketed
  2996. // range notation—[min,max]—within the angle brackets, after the identifying keyword,
  2997. // indicating a closed range between (and including) min and max.
  2998. // For example, <integer [0, 10]> indicates an integer between 0 and 10, inclusive.
  2999. function readTypeRange(tokenizer) {
  3000. // use null for Infinity to make AST format JSON serializable/deserializable
  3001. var min = null; // -Infinity
  3002. var max = null; // Infinity
  3003. var sign = 1;
  3004. tokenizer.eat(LEFTSQUAREBRACKET);
  3005. if (tokenizer.charCode() === HYPERMINUS) {
  3006. tokenizer.peek();
  3007. sign = -1;
  3008. }
  3009. if (sign == -1 && tokenizer.charCode() === INFINITY) {
  3010. tokenizer.peek();
  3011. } else {
  3012. min = sign * Number(scanNumber(tokenizer));
  3013. }
  3014. scanSpaces(tokenizer);
  3015. tokenizer.eat(COMMA);
  3016. scanSpaces(tokenizer);
  3017. if (tokenizer.charCode() === INFINITY) {
  3018. tokenizer.peek();
  3019. } else {
  3020. sign = 1;
  3021. if (tokenizer.charCode() === HYPERMINUS) {
  3022. tokenizer.peek();
  3023. sign = -1;
  3024. }
  3025. max = sign * Number(scanNumber(tokenizer));
  3026. }
  3027. tokenizer.eat(RIGHTSQUAREBRACKET);
  3028. // If no range is indicated, either by using the bracketed range notation
  3029. // or in the property description, then [−∞,∞] is assumed.
  3030. if (min === null && max === null) {
  3031. return null;
  3032. }
  3033. return {
  3034. type: 'Range',
  3035. min: min,
  3036. max: max
  3037. };
  3038. }
  3039. function readType(tokenizer) {
  3040. var name;
  3041. var opts = null;
  3042. tokenizer.eat(LESSTHANSIGN);
  3043. name = scanWord(tokenizer);
  3044. if (tokenizer.charCode() === LEFTPARENTHESIS &&
  3045. tokenizer.nextCharCode() === RIGHTPARENTHESIS) {
  3046. tokenizer.pos += 2;
  3047. name += '()';
  3048. }
  3049. if (tokenizer.charCodeAt(tokenizer.findWsEnd(tokenizer.pos)) === LEFTSQUAREBRACKET) {
  3050. scanSpaces(tokenizer);
  3051. opts = readTypeRange(tokenizer);
  3052. }
  3053. tokenizer.eat(GREATERTHANSIGN);
  3054. return maybeMultiplied(tokenizer, {
  3055. type: 'Type',
  3056. name: name,
  3057. opts: opts
  3058. });
  3059. }
  3060. function readKeywordOrFunction(tokenizer) {
  3061. var name;
  3062. name = scanWord(tokenizer);
  3063. if (tokenizer.charCode() === LEFTPARENTHESIS) {
  3064. tokenizer.pos++;
  3065. return {
  3066. type: 'Function',
  3067. name: name
  3068. };
  3069. }
  3070. return maybeMultiplied(tokenizer, {
  3071. type: 'Keyword',
  3072. name: name
  3073. });
  3074. }
  3075. function regroupTerms(terms, combinators) {
  3076. function createGroup(terms, combinator) {
  3077. return {
  3078. type: 'Group',
  3079. terms: terms,
  3080. combinator: combinator,
  3081. disallowEmpty: false,
  3082. explicit: false
  3083. };
  3084. }
  3085. combinators = Object.keys(combinators).sort(function(a, b) {
  3086. return COMBINATOR_PRECEDENCE[a] - COMBINATOR_PRECEDENCE[b];
  3087. });
  3088. while (combinators.length > 0) {
  3089. var combinator = combinators.shift();
  3090. for (var i = 0, subgroupStart = 0; i < terms.length; i++) {
  3091. var term = terms[i];
  3092. if (term.type === 'Combinator') {
  3093. if (term.value === combinator) {
  3094. if (subgroupStart === -1) {
  3095. subgroupStart = i - 1;
  3096. }
  3097. terms.splice(i, 1);
  3098. i--;
  3099. } else {
  3100. if (subgroupStart !== -1 && i - subgroupStart > 1) {
  3101. terms.splice(
  3102. subgroupStart,
  3103. i - subgroupStart,
  3104. createGroup(terms.slice(subgroupStart, i), combinator)
  3105. );
  3106. i = subgroupStart + 1;
  3107. }
  3108. subgroupStart = -1;
  3109. }
  3110. }
  3111. }
  3112. if (subgroupStart !== -1 && combinators.length) {
  3113. terms.splice(
  3114. subgroupStart,
  3115. i - subgroupStart,
  3116. createGroup(terms.slice(subgroupStart, i), combinator)
  3117. );
  3118. }
  3119. }
  3120. return combinator;
  3121. }
  3122. function readImplicitGroup(tokenizer) {
  3123. var terms = [];
  3124. var combinators = {};
  3125. var token;
  3126. var prevToken = null;
  3127. var prevTokenPos = tokenizer.pos;
  3128. while (token = peek(tokenizer)) {
  3129. if (token.type !== 'Spaces') {
  3130. if (token.type === 'Combinator') {
  3131. // check for combinator in group beginning and double combinator sequence
  3132. if (prevToken === null || prevToken.type === 'Combinator') {
  3133. tokenizer.pos = prevTokenPos;
  3134. tokenizer.error('Unexpected combinator');
  3135. }
  3136. combinators[token.value] = true;
  3137. } else if (prevToken !== null && prevToken.type !== 'Combinator') {
  3138. combinators[' '] = true; // a b
  3139. terms.push({
  3140. type: 'Combinator',
  3141. value: ' '
  3142. });
  3143. }
  3144. terms.push(token);
  3145. prevToken = token;
  3146. prevTokenPos = tokenizer.pos;
  3147. }
  3148. }
  3149. // check for combinator in group ending
  3150. if (prevToken !== null && prevToken.type === 'Combinator') {
  3151. tokenizer.pos -= prevTokenPos;
  3152. tokenizer.error('Unexpected combinator');
  3153. }
  3154. return {
  3155. type: 'Group',
  3156. terms: terms,
  3157. combinator: regroupTerms(terms, combinators) || ' ',
  3158. disallowEmpty: false,
  3159. explicit: false
  3160. };
  3161. }
  3162. function readGroup(tokenizer) {
  3163. var result;
  3164. tokenizer.eat(LEFTSQUAREBRACKET);
  3165. result = readImplicitGroup(tokenizer);
  3166. tokenizer.eat(RIGHTSQUAREBRACKET);
  3167. result.explicit = true;
  3168. if (tokenizer.charCode() === EXCLAMATIONMARK) {
  3169. tokenizer.pos++;
  3170. result.disallowEmpty = true;
  3171. }
  3172. return result;
  3173. }
  3174. function peek(tokenizer) {
  3175. var code = tokenizer.charCode();
  3176. if (code < 128 && NAME_CHAR[code] === 1) {
  3177. return readKeywordOrFunction(tokenizer);
  3178. }
  3179. switch (code) {
  3180. case RIGHTSQUAREBRACKET:
  3181. // don't eat, stop scan a group
  3182. break;
  3183. case LEFTSQUAREBRACKET:
  3184. return maybeMultiplied(tokenizer, readGroup(tokenizer));
  3185. case LESSTHANSIGN:
  3186. return tokenizer.nextCharCode() === APOSTROPHE
  3187. ? readProperty(tokenizer)
  3188. : readType(tokenizer);
  3189. case VERTICALLINE:
  3190. return {
  3191. type: 'Combinator',
  3192. value: tokenizer.substringToPos(
  3193. tokenizer.nextCharCode() === VERTICALLINE
  3194. ? tokenizer.pos + 2
  3195. : tokenizer.pos + 1
  3196. )
  3197. };
  3198. case AMPERSAND:
  3199. tokenizer.pos++;
  3200. tokenizer.eat(AMPERSAND);
  3201. return {
  3202. type: 'Combinator',
  3203. value: '&&'
  3204. };
  3205. case COMMA:
  3206. tokenizer.pos++;
  3207. return {
  3208. type: 'Comma'
  3209. };
  3210. case APOSTROPHE:
  3211. return maybeMultiplied(tokenizer, {
  3212. type: 'String',
  3213. value: scanString(tokenizer)
  3214. });
  3215. case SPACE$1:
  3216. case TAB$1:
  3217. case N$2:
  3218. case R$1:
  3219. case F$1:
  3220. return {
  3221. type: 'Spaces',
  3222. value: scanSpaces(tokenizer)
  3223. };
  3224. case COMMERCIALAT:
  3225. code = tokenizer.nextCharCode();
  3226. if (code < 128 && NAME_CHAR[code] === 1) {
  3227. tokenizer.pos++;
  3228. return {
  3229. type: 'AtKeyword',
  3230. name: scanWord(tokenizer)
  3231. };
  3232. }
  3233. return maybeToken(tokenizer);
  3234. case ASTERISK:
  3235. case PLUSSIGN$2:
  3236. case QUESTIONMARK$1:
  3237. case NUMBERSIGN:
  3238. case EXCLAMATIONMARK:
  3239. // prohibited tokens (used as a multiplier start)
  3240. break;
  3241. case LEFTCURLYBRACKET:
  3242. // LEFTCURLYBRACKET is allowed since mdn/data uses it w/o quoting
  3243. // check next char isn't a number, because it's likely a disjoined multiplier
  3244. code = tokenizer.nextCharCode();
  3245. if (code < 48 || code > 57) {
  3246. return maybeToken(tokenizer);
  3247. }
  3248. break;
  3249. default:
  3250. return maybeToken(tokenizer);
  3251. }
  3252. }
  3253. function parse(source) {
  3254. var tokenizer = new tokenizer$1(source);
  3255. var result = readImplicitGroup(tokenizer);
  3256. if (tokenizer.pos !== source.length) {
  3257. tokenizer.error('Unexpected input');
  3258. }
  3259. // reduce redundant groups with single group term
  3260. if (result.terms.length === 1 && result.terms[0].type === 'Group') {
  3261. result = result.terms[0];
  3262. }
  3263. return result;
  3264. }
  3265. // warm up parse to elimitate code branches that never execute
  3266. // fix soft deoptimizations (insufficient type feedback)
  3267. parse('[a&&<b>#|<\'c\'>*||e() f{2} /,(% g#{1,2} h{2,})]!');
  3268. var parse_1 = parse;
  3269. var noop$1 = function() {};
  3270. function ensureFunction(value) {
  3271. return typeof value === 'function' ? value : noop$1;
  3272. }
  3273. var walk = function(node, options, context) {
  3274. function walk(node) {
  3275. enter.call(context, node);
  3276. switch (node.type) {
  3277. case 'Group':
  3278. node.terms.forEach(walk);
  3279. break;
  3280. case 'Multiplier':
  3281. walk(node.term);
  3282. break;
  3283. case 'Type':
  3284. case 'Property':
  3285. case 'Keyword':
  3286. case 'AtKeyword':
  3287. case 'Function':
  3288. case 'String':
  3289. case 'Token':
  3290. case 'Comma':
  3291. break;
  3292. default:
  3293. throw new Error('Unknown type: ' + node.type);
  3294. }
  3295. leave.call(context, node);
  3296. }
  3297. var enter = noop$1;
  3298. var leave = noop$1;
  3299. if (typeof options === 'function') {
  3300. enter = options;
  3301. } else if (options) {
  3302. enter = ensureFunction(options.enter);
  3303. leave = ensureFunction(options.leave);
  3304. }
  3305. if (enter === noop$1 && leave === noop$1) {
  3306. throw new Error('Neither `enter` nor `leave` walker handler is set or both aren\'t a function');
  3307. }
  3308. walk(node);
  3309. };
  3310. var tokenStream = new TokenStream_1();
  3311. var astToTokens = {
  3312. decorator: function(handlers) {
  3313. var curNode = null;
  3314. var prev = { len: 0, node: null };
  3315. var nodes = [prev];
  3316. var buffer = '';
  3317. return {
  3318. children: handlers.children,
  3319. node: function(node) {
  3320. var tmp = curNode;
  3321. curNode = node;
  3322. handlers.node.call(this, node);
  3323. curNode = tmp;
  3324. },
  3325. chunk: function(chunk) {
  3326. buffer += chunk;
  3327. if (prev.node !== curNode) {
  3328. nodes.push({
  3329. len: chunk.length,
  3330. node: curNode
  3331. });
  3332. } else {
  3333. prev.len += chunk.length;
  3334. }
  3335. },
  3336. result: function() {
  3337. return prepareTokens(buffer, nodes);
  3338. }
  3339. };
  3340. }
  3341. };
  3342. function prepareTokens(str, nodes) {
  3343. var tokens = [];
  3344. var nodesOffset = 0;
  3345. var nodesIndex = 0;
  3346. var currentNode = nodes ? nodes[nodesIndex].node : null;
  3347. tokenizer(str, tokenStream);
  3348. while (!tokenStream.eof) {
  3349. if (nodes) {
  3350. while (nodesIndex < nodes.length && nodesOffset + nodes[nodesIndex].len <= tokenStream.tokenStart) {
  3351. nodesOffset += nodes[nodesIndex++].len;
  3352. currentNode = nodes[nodesIndex].node;
  3353. }
  3354. }
  3355. tokens.push({
  3356. type: tokenStream.tokenType,
  3357. value: tokenStream.getTokenValue(),
  3358. index: tokenStream.tokenIndex, // TODO: remove it, temporary solution
  3359. balance: tokenStream.balance[tokenStream.tokenIndex], // TODO: remove it, temporary solution
  3360. node: currentNode
  3361. });
  3362. tokenStream.next();
  3363. // console.log({ ...tokens[tokens.length - 1], node: undefined });
  3364. }
  3365. return tokens;
  3366. }
  3367. var prepareTokens_1 = function(value, syntax) {
  3368. if (typeof value === 'string') {
  3369. return prepareTokens(value, null);
  3370. }
  3371. return syntax.generate(value, astToTokens);
  3372. };
  3373. var MATCH = { type: 'Match' };
  3374. var MISMATCH = { type: 'Mismatch' };
  3375. var DISALLOW_EMPTY = { type: 'DisallowEmpty' };
  3376. var LEFTPARENTHESIS$1 = 40; // (
  3377. var RIGHTPARENTHESIS$1 = 41; // )
  3378. function createCondition(match, thenBranch, elseBranch) {
  3379. // reduce node count
  3380. if (thenBranch === MATCH && elseBranch === MISMATCH) {
  3381. return match;
  3382. }
  3383. if (match === MATCH && thenBranch === MATCH && elseBranch === MATCH) {
  3384. return match;
  3385. }
  3386. if (match.type === 'If' && match.else === MISMATCH && thenBranch === MATCH) {
  3387. thenBranch = match.then;
  3388. match = match.match;
  3389. }
  3390. return {
  3391. type: 'If',
  3392. match: match,
  3393. then: thenBranch,
  3394. else: elseBranch
  3395. };
  3396. }
  3397. function isFunctionType(name) {
  3398. return (
  3399. name.length > 2 &&
  3400. name.charCodeAt(name.length - 2) === LEFTPARENTHESIS$1 &&
  3401. name.charCodeAt(name.length - 1) === RIGHTPARENTHESIS$1
  3402. );
  3403. }
  3404. function isEnumCapatible(term) {
  3405. return (
  3406. term.type === 'Keyword' ||
  3407. term.type === 'AtKeyword' ||
  3408. term.type === 'Function' ||
  3409. term.type === 'Type' && isFunctionType(term.name)
  3410. );
  3411. }
  3412. function buildGroupMatchGraph(combinator, terms, atLeastOneTermMatched) {
  3413. switch (combinator) {
  3414. case ' ':
  3415. // Juxtaposing components means that all of them must occur, in the given order.
  3416. //
  3417. // a b c
  3418. // =
  3419. // match a
  3420. // then match b
  3421. // then match c
  3422. // then MATCH
  3423. // else MISMATCH
  3424. // else MISMATCH
  3425. // else MISMATCH
  3426. var result = MATCH;
  3427. for (var i = terms.length - 1; i >= 0; i--) {
  3428. var term = terms[i];
  3429. result = createCondition(
  3430. term,
  3431. result,
  3432. MISMATCH
  3433. );
  3434. }
  3435. return result;
  3436. case '|':
  3437. // A bar (|) separates two or more alternatives: exactly one of them must occur.
  3438. //
  3439. // a | b | c
  3440. // =
  3441. // match a
  3442. // then MATCH
  3443. // else match b
  3444. // then MATCH
  3445. // else match c
  3446. // then MATCH
  3447. // else MISMATCH
  3448. var result = MISMATCH;
  3449. var map = null;
  3450. for (var i = terms.length - 1; i >= 0; i--) {
  3451. var term = terms[i];
  3452. // reduce sequence of keywords into a Enum
  3453. if (isEnumCapatible(term)) {
  3454. if (map === null && i > 0 && isEnumCapatible(terms[i - 1])) {
  3455. map = Object.create(null);
  3456. result = createCondition(
  3457. {
  3458. type: 'Enum',
  3459. map: map
  3460. },
  3461. MATCH,
  3462. result
  3463. );
  3464. }
  3465. if (map !== null) {
  3466. var key = (isFunctionType(term.name) ? term.name.slice(0, -1) : term.name).toLowerCase();
  3467. if (key in map === false) {
  3468. map[key] = term;
  3469. continue;
  3470. }
  3471. }
  3472. }
  3473. map = null;
  3474. // create a new conditonal node
  3475. result = createCondition(
  3476. term,
  3477. MATCH,
  3478. result
  3479. );
  3480. }
  3481. return result;
  3482. case '&&':
  3483. // A double ampersand (&&) separates two or more components,
  3484. // all of which must occur, in any order.
  3485. // Use MatchOnce for groups with a large number of terms,
  3486. // since &&-groups produces at least N!-node trees
  3487. if (terms.length > 5) {
  3488. return {
  3489. type: 'MatchOnce',
  3490. terms: terms,
  3491. all: true
  3492. };
  3493. }
  3494. // Use a combination tree for groups with small number of terms
  3495. //
  3496. // a && b && c
  3497. // =
  3498. // match a
  3499. // then [b && c]
  3500. // else match b
  3501. // then [a && c]
  3502. // else match c
  3503. // then [a && b]
  3504. // else MISMATCH
  3505. //
  3506. // a && b
  3507. // =
  3508. // match a
  3509. // then match b
  3510. // then MATCH
  3511. // else MISMATCH
  3512. // else match b
  3513. // then match a
  3514. // then MATCH
  3515. // else MISMATCH
  3516. // else MISMATCH
  3517. var result = MISMATCH;
  3518. for (var i = terms.length - 1; i >= 0; i--) {
  3519. var term = terms[i];
  3520. var thenClause;
  3521. if (terms.length > 1) {
  3522. thenClause = buildGroupMatchGraph(
  3523. combinator,
  3524. terms.filter(function(newGroupTerm) {
  3525. return newGroupTerm !== term;
  3526. }),
  3527. false
  3528. );
  3529. } else {
  3530. thenClause = MATCH;
  3531. }
  3532. result = createCondition(
  3533. term,
  3534. thenClause,
  3535. result
  3536. );
  3537. }
  3538. return result;
  3539. case '||':
  3540. // A double bar (||) separates two or more options:
  3541. // one or more of them must occur, in any order.
  3542. // Use MatchOnce for groups with a large number of terms,
  3543. // since ||-groups produces at least N!-node trees
  3544. if (terms.length > 5) {
  3545. return {
  3546. type: 'MatchOnce',
  3547. terms: terms,
  3548. all: false
  3549. };
  3550. }
  3551. // Use a combination tree for groups with small number of terms
  3552. //
  3553. // a || b || c
  3554. // =
  3555. // match a
  3556. // then [b || c]
  3557. // else match b
  3558. // then [a || c]
  3559. // else match c
  3560. // then [a || b]
  3561. // else MISMATCH
  3562. //
  3563. // a || b
  3564. // =
  3565. // match a
  3566. // then match b
  3567. // then MATCH
  3568. // else MATCH
  3569. // else match b
  3570. // then match a
  3571. // then MATCH
  3572. // else MATCH
  3573. // else MISMATCH
  3574. var result = atLeastOneTermMatched ? MATCH : MISMATCH;
  3575. for (var i = terms.length - 1; i >= 0; i--) {
  3576. var term = terms[i];
  3577. var thenClause;
  3578. if (terms.length > 1) {
  3579. thenClause = buildGroupMatchGraph(
  3580. combinator,
  3581. terms.filter(function(newGroupTerm) {
  3582. return newGroupTerm !== term;
  3583. }),
  3584. true
  3585. );
  3586. } else {
  3587. thenClause = MATCH;
  3588. }
  3589. result = createCondition(
  3590. term,
  3591. thenClause,
  3592. result
  3593. );
  3594. }
  3595. return result;
  3596. }
  3597. }
  3598. function buildMultiplierMatchGraph(node) {
  3599. var result = MATCH;
  3600. var matchTerm = buildMatchGraph(node.term);
  3601. if (node.max === 0) {
  3602. // disable repeating of empty match to prevent infinite loop
  3603. matchTerm = createCondition(
  3604. matchTerm,
  3605. DISALLOW_EMPTY,
  3606. MISMATCH
  3607. );
  3608. // an occurrence count is not limited, make a cycle;
  3609. // to collect more terms on each following matching mismatch
  3610. result = createCondition(
  3611. matchTerm,
  3612. null, // will be a loop
  3613. MISMATCH
  3614. );
  3615. result.then = createCondition(
  3616. MATCH,
  3617. MATCH,
  3618. result // make a loop
  3619. );
  3620. if (node.comma) {
  3621. result.then.else = createCondition(
  3622. { type: 'Comma', syntax: node },
  3623. result,
  3624. MISMATCH
  3625. );
  3626. }
  3627. } else {
  3628. // create a match node chain for [min .. max] interval with optional matches
  3629. for (var i = node.min || 1; i <= node.max; i++) {
  3630. if (node.comma && result !== MATCH) {
  3631. result = createCondition(
  3632. { type: 'Comma', syntax: node },
  3633. result,
  3634. MISMATCH
  3635. );
  3636. }
  3637. result = createCondition(
  3638. matchTerm,
  3639. createCondition(
  3640. MATCH,
  3641. MATCH,
  3642. result
  3643. ),
  3644. MISMATCH
  3645. );
  3646. }
  3647. }
  3648. if (node.min === 0) {
  3649. // allow zero match
  3650. result = createCondition(
  3651. MATCH,
  3652. MATCH,
  3653. result
  3654. );
  3655. } else {
  3656. // create a match node chain to collect [0 ... min - 1] required matches
  3657. for (var i = 0; i < node.min - 1; i++) {
  3658. if (node.comma && result !== MATCH) {
  3659. result = createCondition(
  3660. { type: 'Comma', syntax: node },
  3661. result,
  3662. MISMATCH
  3663. );
  3664. }
  3665. result = createCondition(
  3666. matchTerm,
  3667. result,
  3668. MISMATCH
  3669. );
  3670. }
  3671. }
  3672. return result;
  3673. }
  3674. function buildMatchGraph(node) {
  3675. if (typeof node === 'function') {
  3676. return {
  3677. type: 'Generic',
  3678. fn: node
  3679. };
  3680. }
  3681. switch (node.type) {
  3682. case 'Group':
  3683. var result = buildGroupMatchGraph(
  3684. node.combinator,
  3685. node.terms.map(buildMatchGraph),
  3686. false
  3687. );
  3688. if (node.disallowEmpty) {
  3689. result = createCondition(
  3690. result,
  3691. DISALLOW_EMPTY,
  3692. MISMATCH
  3693. );
  3694. }
  3695. return result;
  3696. case 'Multiplier':
  3697. return buildMultiplierMatchGraph(node);
  3698. case 'Type':
  3699. case 'Property':
  3700. return {
  3701. type: node.type,
  3702. name: node.name,
  3703. syntax: node
  3704. };
  3705. case 'Keyword':
  3706. return {
  3707. type: node.type,
  3708. name: node.name.toLowerCase(),
  3709. syntax: node
  3710. };
  3711. case 'AtKeyword':
  3712. return {
  3713. type: node.type,
  3714. name: '@' + node.name.toLowerCase(),
  3715. syntax: node
  3716. };
  3717. case 'Function':
  3718. return {
  3719. type: node.type,
  3720. name: node.name.toLowerCase() + '(',
  3721. syntax: node
  3722. };
  3723. case 'String':
  3724. // convert a one char length String to a Token
  3725. if (node.value.length === 3) {
  3726. return {
  3727. type: 'Token',
  3728. value: node.value.charAt(1),
  3729. syntax: node
  3730. };
  3731. }
  3732. // otherwise use it as is
  3733. return {
  3734. type: node.type,
  3735. value: node.value.substr(1, node.value.length - 2).replace(/\\'/g, '\''),
  3736. syntax: node
  3737. };
  3738. case 'Token':
  3739. return {
  3740. type: node.type,
  3741. value: node.value,
  3742. syntax: node
  3743. };
  3744. case 'Comma':
  3745. return {
  3746. type: node.type,
  3747. syntax: node
  3748. };
  3749. default:
  3750. throw new Error('Unknown node type:', node.type);
  3751. }
  3752. }
  3753. var matchGraph = {
  3754. MATCH: MATCH,
  3755. MISMATCH: MISMATCH,
  3756. DISALLOW_EMPTY: DISALLOW_EMPTY,
  3757. buildMatchGraph: function(syntaxTree, ref) {
  3758. if (typeof syntaxTree === 'string') {
  3759. syntaxTree = parse_1(syntaxTree);
  3760. }
  3761. return {
  3762. type: 'MatchGraph',
  3763. match: buildMatchGraph(syntaxTree),
  3764. syntax: ref || null,
  3765. source: syntaxTree
  3766. };
  3767. }
  3768. };
  3769. var hasOwnProperty$1 = Object.prototype.hasOwnProperty;
  3770. var MATCH$1 = matchGraph.MATCH;
  3771. var MISMATCH$1 = matchGraph.MISMATCH;
  3772. var DISALLOW_EMPTY$1 = matchGraph.DISALLOW_EMPTY;
  3773. var TYPE$6 = _const.TYPE;
  3774. var STUB = 0;
  3775. var TOKEN = 1;
  3776. var OPEN_SYNTAX = 2;
  3777. var CLOSE_SYNTAX = 3;
  3778. var EXIT_REASON_MATCH = 'Match';
  3779. var EXIT_REASON_MISMATCH = 'Mismatch';
  3780. var EXIT_REASON_ITERATION_LIMIT = 'Maximum iteration number exceeded (please fill an issue on https://github.com/csstree/csstree/issues)';
  3781. var ITERATION_LIMIT = 15000;
  3782. var totalIterationCount = 0;
  3783. function reverseList(list) {
  3784. var prev = null;
  3785. var next = null;
  3786. var item = list;
  3787. while (item !== null) {
  3788. next = item.prev;
  3789. item.prev = prev;
  3790. prev = item;
  3791. item = next;
  3792. }
  3793. return prev;
  3794. }
  3795. function areStringsEqualCaseInsensitive(testStr, referenceStr) {
  3796. if (testStr.length !== referenceStr.length) {
  3797. return false;
  3798. }
  3799. for (var i = 0; i < testStr.length; i++) {
  3800. var testCode = testStr.charCodeAt(i);
  3801. var referenceCode = referenceStr.charCodeAt(i);
  3802. // testCode.toLowerCase() for U+0041 LATIN CAPITAL LETTER A (A) .. U+005A LATIN CAPITAL LETTER Z (Z).
  3803. if (testCode >= 0x0041 && testCode <= 0x005A) {
  3804. testCode = testCode | 32;
  3805. }
  3806. if (testCode !== referenceCode) {
  3807. return false;
  3808. }
  3809. }
  3810. return true;
  3811. }
  3812. function isContextEdgeDelim(token) {
  3813. if (token.type !== TYPE$6.Delim) {
  3814. return false;
  3815. }
  3816. // Fix matching for unicode-range: U+30??, U+FF00-FF9F
  3817. // Probably we need to check out previous match instead
  3818. return token.value !== '?';
  3819. }
  3820. function isCommaContextStart(token) {
  3821. if (token === null) {
  3822. return true;
  3823. }
  3824. return (
  3825. token.type === TYPE$6.Comma ||
  3826. token.type === TYPE$6.Function ||
  3827. token.type === TYPE$6.LeftParenthesis ||
  3828. token.type === TYPE$6.LeftSquareBracket ||
  3829. token.type === TYPE$6.LeftCurlyBracket ||
  3830. isContextEdgeDelim(token)
  3831. );
  3832. }
  3833. function isCommaContextEnd(token) {
  3834. if (token === null) {
  3835. return true;
  3836. }
  3837. return (
  3838. token.type === TYPE$6.RightParenthesis ||
  3839. token.type === TYPE$6.RightSquareBracket ||
  3840. token.type === TYPE$6.RightCurlyBracket ||
  3841. token.type === TYPE$6.Delim
  3842. );
  3843. }
  3844. function internalMatch(tokens, state, syntaxes) {
  3845. function moveToNextToken() {
  3846. do {
  3847. tokenIndex++;
  3848. token = tokenIndex < tokens.length ? tokens[tokenIndex] : null;
  3849. } while (token !== null && (token.type === TYPE$6.WhiteSpace || token.type === TYPE$6.Comment));
  3850. }
  3851. function getNextToken(offset) {
  3852. var nextIndex = tokenIndex + offset;
  3853. return nextIndex < tokens.length ? tokens[nextIndex] : null;
  3854. }
  3855. function stateSnapshotFromSyntax(nextState, prev) {
  3856. return {
  3857. nextState: nextState,
  3858. matchStack: matchStack,
  3859. syntaxStack: syntaxStack,
  3860. thenStack: thenStack,
  3861. tokenIndex: tokenIndex,
  3862. prev: prev
  3863. };
  3864. }
  3865. function pushThenStack(nextState) {
  3866. thenStack = {
  3867. nextState: nextState,
  3868. matchStack: matchStack,
  3869. syntaxStack: syntaxStack,
  3870. prev: thenStack
  3871. };
  3872. }
  3873. function pushElseStack(nextState) {
  3874. elseStack = stateSnapshotFromSyntax(nextState, elseStack);
  3875. }
  3876. function addTokenToMatch() {
  3877. matchStack = {
  3878. type: TOKEN,
  3879. syntax: state.syntax,
  3880. token: token,
  3881. prev: matchStack
  3882. };
  3883. moveToNextToken();
  3884. syntaxStash = null;
  3885. if (tokenIndex > longestMatch) {
  3886. longestMatch = tokenIndex;
  3887. }
  3888. }
  3889. function openSyntax() {
  3890. syntaxStack = {
  3891. syntax: state.syntax,
  3892. opts: state.syntax.opts || (syntaxStack !== null && syntaxStack.opts) || null,
  3893. prev: syntaxStack
  3894. };
  3895. matchStack = {
  3896. type: OPEN_SYNTAX,
  3897. syntax: state.syntax,
  3898. token: matchStack.token,
  3899. prev: matchStack
  3900. };
  3901. }
  3902. function closeSyntax() {
  3903. if (matchStack.type === OPEN_SYNTAX) {
  3904. matchStack = matchStack.prev;
  3905. } else {
  3906. matchStack = {
  3907. type: CLOSE_SYNTAX,
  3908. syntax: syntaxStack.syntax,
  3909. token: matchStack.token,
  3910. prev: matchStack
  3911. };
  3912. }
  3913. syntaxStack = syntaxStack.prev;
  3914. }
  3915. var syntaxStack = null;
  3916. var thenStack = null;
  3917. var elseStack = null;
  3918. // null – stashing allowed, nothing stashed
  3919. // false – stashing disabled, nothing stashed
  3920. // anithing else – fail stashable syntaxes, some syntax stashed
  3921. var syntaxStash = null;
  3922. var iterationCount = 0; // count iterations and prevent infinite loop
  3923. var exitReason = null;
  3924. var token = null;
  3925. var tokenIndex = -1;
  3926. var longestMatch = 0;
  3927. var matchStack = {
  3928. type: STUB,
  3929. syntax: null,
  3930. token: null,
  3931. prev: null
  3932. };
  3933. moveToNextToken();
  3934. while (exitReason === null && ++iterationCount < ITERATION_LIMIT) {
  3935. // function mapList(list, fn) {
  3936. // var result = [];
  3937. // while (list) {
  3938. // result.unshift(fn(list));
  3939. // list = list.prev;
  3940. // }
  3941. // return result;
  3942. // }
  3943. // console.log('--\n',
  3944. // '#' + iterationCount,
  3945. // require('util').inspect({
  3946. // match: mapList(matchStack, x => x.type === TOKEN ? x.token && x.token.value : x.syntax ? ({ [OPEN_SYNTAX]: '<', [CLOSE_SYNTAX]: '</' }[x.type] || x.type) + '!' + x.syntax.name : null),
  3947. // token: token && token.value,
  3948. // tokenIndex,
  3949. // syntax: syntax.type + (syntax.id ? ' #' + syntax.id : '')
  3950. // }, { depth: null })
  3951. // );
  3952. switch (state.type) {
  3953. case 'Match':
  3954. if (thenStack === null) {
  3955. // turn to MISMATCH when some tokens left unmatched
  3956. if (token !== null) {
  3957. // doesn't mismatch if just one token left and it's an IE hack
  3958. if (tokenIndex !== tokens.length - 1 || (token.value !== '\\0' && token.value !== '\\9')) {
  3959. state = MISMATCH$1;
  3960. break;
  3961. }
  3962. }
  3963. // break the main loop, return a result - MATCH
  3964. exitReason = EXIT_REASON_MATCH;
  3965. break;
  3966. }
  3967. // go to next syntax (`then` branch)
  3968. state = thenStack.nextState;
  3969. // check match is not empty
  3970. if (state === DISALLOW_EMPTY$1) {
  3971. if (thenStack.matchStack === matchStack) {
  3972. state = MISMATCH$1;
  3973. break;
  3974. } else {
  3975. state = MATCH$1;
  3976. }
  3977. }
  3978. // close syntax if needed
  3979. while (thenStack.syntaxStack !== syntaxStack) {
  3980. closeSyntax();
  3981. }
  3982. // pop stack
  3983. thenStack = thenStack.prev;
  3984. break;
  3985. case 'Mismatch':
  3986. // when some syntax is stashed
  3987. if (syntaxStash !== null && syntaxStash !== false) {
  3988. // there is no else branches or a branch reduce match stack
  3989. if (elseStack === null || tokenIndex > elseStack.tokenIndex) {
  3990. // restore state from the stash
  3991. elseStack = syntaxStash;
  3992. syntaxStash = false; // disable stashing
  3993. }
  3994. } else if (elseStack === null) {
  3995. // no else branches -> break the main loop
  3996. // return a result - MISMATCH
  3997. exitReason = EXIT_REASON_MISMATCH;
  3998. break;
  3999. }
  4000. // go to next syntax (`else` branch)
  4001. state = elseStack.nextState;
  4002. // restore all the rest stack states
  4003. thenStack = elseStack.thenStack;
  4004. syntaxStack = elseStack.syntaxStack;
  4005. matchStack = elseStack.matchStack;
  4006. tokenIndex = elseStack.tokenIndex;
  4007. token = tokenIndex < tokens.length ? tokens[tokenIndex] : null;
  4008. // pop stack
  4009. elseStack = elseStack.prev;
  4010. break;
  4011. case 'MatchGraph':
  4012. state = state.match;
  4013. break;
  4014. case 'If':
  4015. // IMPORTANT: else stack push must go first,
  4016. // since it stores the state of thenStack before changes
  4017. if (state.else !== MISMATCH$1) {
  4018. pushElseStack(state.else);
  4019. }
  4020. if (state.then !== MATCH$1) {
  4021. pushThenStack(state.then);
  4022. }
  4023. state = state.match;
  4024. break;
  4025. case 'MatchOnce':
  4026. state = {
  4027. type: 'MatchOnceBuffer',
  4028. syntax: state,
  4029. index: 0,
  4030. mask: 0
  4031. };
  4032. break;
  4033. case 'MatchOnceBuffer':
  4034. var terms = state.syntax.terms;
  4035. if (state.index === terms.length) {
  4036. // no matches at all or it's required all terms to be matched
  4037. if (state.mask === 0 || state.syntax.all) {
  4038. state = MISMATCH$1;
  4039. break;
  4040. }
  4041. // a partial match is ok
  4042. state = MATCH$1;
  4043. break;
  4044. }
  4045. // all terms are matched
  4046. if (state.mask === (1 << terms.length) - 1) {
  4047. state = MATCH$1;
  4048. break;
  4049. }
  4050. for (; state.index < terms.length; state.index++) {
  4051. var matchFlag = 1 << state.index;
  4052. if ((state.mask & matchFlag) === 0) {
  4053. // IMPORTANT: else stack push must go first,
  4054. // since it stores the state of thenStack before changes
  4055. pushElseStack(state);
  4056. pushThenStack({
  4057. type: 'AddMatchOnce',
  4058. syntax: state.syntax,
  4059. mask: state.mask | matchFlag
  4060. });
  4061. // match
  4062. state = terms[state.index++];
  4063. break;
  4064. }
  4065. }
  4066. break;
  4067. case 'AddMatchOnce':
  4068. state = {
  4069. type: 'MatchOnceBuffer',
  4070. syntax: state.syntax,
  4071. index: 0,
  4072. mask: state.mask
  4073. };
  4074. break;
  4075. case 'Enum':
  4076. if (token !== null) {
  4077. var name = token.value.toLowerCase();
  4078. // drop \0 and \9 hack from keyword name
  4079. if (name.indexOf('\\') !== -1) {
  4080. name = name.replace(/\\[09].*$/, '');
  4081. }
  4082. if (hasOwnProperty$1.call(state.map, name)) {
  4083. state = state.map[name];
  4084. break;
  4085. }
  4086. }
  4087. state = MISMATCH$1;
  4088. break;
  4089. case 'Generic':
  4090. var opts = syntaxStack !== null ? syntaxStack.opts : null;
  4091. var lastTokenIndex = tokenIndex + Math.floor(state.fn(token, getNextToken, opts));
  4092. if (!isNaN(lastTokenIndex) && lastTokenIndex > tokenIndex) {
  4093. while (tokenIndex < lastTokenIndex) {
  4094. addTokenToMatch();
  4095. }
  4096. state = MATCH$1;
  4097. } else {
  4098. state = MISMATCH$1;
  4099. }
  4100. break;
  4101. case 'Type':
  4102. case 'Property':
  4103. var syntaxDict = state.type === 'Type' ? 'types' : 'properties';
  4104. var dictSyntax = hasOwnProperty$1.call(syntaxes, syntaxDict) ? syntaxes[syntaxDict][state.name] : null;
  4105. if (!dictSyntax || !dictSyntax.match) {
  4106. throw new Error(
  4107. 'Bad syntax reference: ' +
  4108. (state.type === 'Type'
  4109. ? '<' + state.name + '>'
  4110. : '<\'' + state.name + '\'>')
  4111. );
  4112. }
  4113. // stash a syntax for types with low priority
  4114. if (syntaxStash !== false && token !== null && state.type === 'Type') {
  4115. var lowPriorityMatching =
  4116. // https://drafts.csswg.org/css-values-4/#custom-idents
  4117. // When parsing positionally-ambiguous keywords in a property value, a <custom-ident> production
  4118. // can only claim the keyword if no other unfulfilled production can claim it.
  4119. (state.name === 'custom-ident' && token.type === TYPE$6.Ident) ||
  4120. // https://drafts.csswg.org/css-values-4/#lengths
  4121. // ... if a `0` could be parsed as either a <number> or a <length> in a property (such as line-height),
  4122. // it must parse as a <number>
  4123. (state.name === 'length' && token.value === '0');
  4124. if (lowPriorityMatching) {
  4125. if (syntaxStash === null) {
  4126. syntaxStash = stateSnapshotFromSyntax(state, elseStack);
  4127. }
  4128. state = MISMATCH$1;
  4129. break;
  4130. }
  4131. }
  4132. openSyntax();
  4133. state = dictSyntax.match;
  4134. break;
  4135. case 'Keyword':
  4136. var name = state.name;
  4137. if (token !== null) {
  4138. var keywordName = token.value;
  4139. // drop \0 and \9 hack from keyword name
  4140. if (keywordName.indexOf('\\') !== -1) {
  4141. keywordName = keywordName.replace(/\\[09].*$/, '');
  4142. }
  4143. if (areStringsEqualCaseInsensitive(keywordName, name)) {
  4144. addTokenToMatch();
  4145. state = MATCH$1;
  4146. break;
  4147. }
  4148. }
  4149. state = MISMATCH$1;
  4150. break;
  4151. case 'AtKeyword':
  4152. case 'Function':
  4153. if (token !== null && areStringsEqualCaseInsensitive(token.value, state.name)) {
  4154. addTokenToMatch();
  4155. state = MATCH$1;
  4156. break;
  4157. }
  4158. state = MISMATCH$1;
  4159. break;
  4160. case 'Token':
  4161. if (token !== null && token.value === state.value) {
  4162. addTokenToMatch();
  4163. state = MATCH$1;
  4164. break;
  4165. }
  4166. state = MISMATCH$1;
  4167. break;
  4168. case 'Comma':
  4169. if (token !== null && token.type === TYPE$6.Comma) {
  4170. if (isCommaContextStart(matchStack.token)) {
  4171. state = MISMATCH$1;
  4172. } else {
  4173. addTokenToMatch();
  4174. state = isCommaContextEnd(token) ? MISMATCH$1 : MATCH$1;
  4175. }
  4176. } else {
  4177. state = isCommaContextStart(matchStack.token) || isCommaContextEnd(token) ? MATCH$1 : MISMATCH$1;
  4178. }
  4179. break;
  4180. case 'String':
  4181. var string = '';
  4182. for (var lastTokenIndex = tokenIndex; lastTokenIndex < tokens.length && string.length < state.value.length; lastTokenIndex++) {
  4183. string += tokens[lastTokenIndex].value;
  4184. }
  4185. if (areStringsEqualCaseInsensitive(string, state.value)) {
  4186. while (tokenIndex < lastTokenIndex) {
  4187. addTokenToMatch();
  4188. }
  4189. state = MATCH$1;
  4190. } else {
  4191. state = MISMATCH$1;
  4192. }
  4193. break;
  4194. default:
  4195. throw new Error('Unknown node type: ' + state.type);
  4196. }
  4197. }
  4198. totalIterationCount += iterationCount;
  4199. switch (exitReason) {
  4200. case null:
  4201. console.warn('[csstree-match] BREAK after ' + ITERATION_LIMIT + ' iterations');
  4202. exitReason = EXIT_REASON_ITERATION_LIMIT;
  4203. matchStack = null;
  4204. break;
  4205. case EXIT_REASON_MATCH:
  4206. while (syntaxStack !== null) {
  4207. closeSyntax();
  4208. }
  4209. break;
  4210. default:
  4211. matchStack = null;
  4212. }
  4213. return {
  4214. tokens: tokens,
  4215. reason: exitReason,
  4216. iterations: iterationCount,
  4217. match: matchStack,
  4218. longestMatch: longestMatch
  4219. };
  4220. }
  4221. function matchAsList(tokens, matchGraph, syntaxes) {
  4222. var matchResult = internalMatch(tokens, matchGraph, syntaxes || {});
  4223. if (matchResult.match !== null) {
  4224. var item = reverseList(matchResult.match).prev;
  4225. matchResult.match = [];
  4226. while (item !== null) {
  4227. switch (item.type) {
  4228. case STUB:
  4229. break;
  4230. case OPEN_SYNTAX:
  4231. case CLOSE_SYNTAX:
  4232. matchResult.match.push({
  4233. type: item.type,
  4234. syntax: item.syntax
  4235. });
  4236. break;
  4237. default:
  4238. matchResult.match.push({
  4239. token: item.token.value,
  4240. node: item.token.node
  4241. });
  4242. break;
  4243. }
  4244. item = item.prev;
  4245. }
  4246. }
  4247. return matchResult;
  4248. }
  4249. function matchAsTree(tokens, matchGraph, syntaxes) {
  4250. var matchResult = internalMatch(tokens, matchGraph, syntaxes || {});
  4251. if (matchResult.match === null) {
  4252. return matchResult;
  4253. }
  4254. var item = matchResult.match;
  4255. var host = matchResult.match = {
  4256. syntax: matchGraph.syntax || null,
  4257. match: []
  4258. };
  4259. var hostStack = [host];
  4260. // revert a list and start with 2nd item since 1st is a stub item
  4261. item = reverseList(item).prev;
  4262. // build a tree
  4263. while (item !== null) {
  4264. switch (item.type) {
  4265. case OPEN_SYNTAX:
  4266. host.match.push(host = {
  4267. syntax: item.syntax,
  4268. match: []
  4269. });
  4270. hostStack.push(host);
  4271. break;
  4272. case CLOSE_SYNTAX:
  4273. hostStack.pop();
  4274. host = hostStack[hostStack.length - 1];
  4275. break;
  4276. default:
  4277. host.match.push({
  4278. syntax: item.syntax || null,
  4279. token: item.token.value,
  4280. node: item.token.node
  4281. });
  4282. }
  4283. item = item.prev;
  4284. }
  4285. return matchResult;
  4286. }
  4287. var match = {
  4288. matchAsList: matchAsList,
  4289. matchAsTree: matchAsTree,
  4290. getTotalIterationCount: function() {
  4291. return totalIterationCount;
  4292. }
  4293. };
  4294. function getTrace(node) {
  4295. function shouldPutToTrace(syntax) {
  4296. if (syntax === null) {
  4297. return false;
  4298. }
  4299. return (
  4300. syntax.type === 'Type' ||
  4301. syntax.type === 'Property' ||
  4302. syntax.type === 'Keyword'
  4303. );
  4304. }
  4305. function hasMatch(matchNode) {
  4306. if (Array.isArray(matchNode.match)) {
  4307. // use for-loop for better perfomance
  4308. for (var i = 0; i < matchNode.match.length; i++) {
  4309. if (hasMatch(matchNode.match[i])) {
  4310. if (shouldPutToTrace(matchNode.syntax)) {
  4311. result.unshift(matchNode.syntax);
  4312. }
  4313. return true;
  4314. }
  4315. }
  4316. } else if (matchNode.node === node) {
  4317. result = shouldPutToTrace(matchNode.syntax)
  4318. ? [matchNode.syntax]
  4319. : [];
  4320. return true;
  4321. }
  4322. return false;
  4323. }
  4324. var result = null;
  4325. if (this.matched !== null) {
  4326. hasMatch(this.matched);
  4327. }
  4328. return result;
  4329. }
  4330. function testNode(match, node, fn) {
  4331. var trace = getTrace.call(match, node);
  4332. if (trace === null) {
  4333. return false;
  4334. }
  4335. return trace.some(fn);
  4336. }
  4337. function isType(node, type) {
  4338. return testNode(this, node, function(matchNode) {
  4339. return matchNode.type === 'Type' && matchNode.name === type;
  4340. });
  4341. }
  4342. function isProperty(node, property) {
  4343. return testNode(this, node, function(matchNode) {
  4344. return matchNode.type === 'Property' && matchNode.name === property;
  4345. });
  4346. }
  4347. function isKeyword(node) {
  4348. return testNode(this, node, function(matchNode) {
  4349. return matchNode.type === 'Keyword';
  4350. });
  4351. }
  4352. var trace = {
  4353. getTrace: getTrace,
  4354. isType: isType,
  4355. isProperty: isProperty,
  4356. isKeyword: isKeyword
  4357. };
  4358. function getFirstMatchNode(matchNode) {
  4359. if ('node' in matchNode) {
  4360. return matchNode.node;
  4361. }
  4362. return getFirstMatchNode(matchNode.match[0]);
  4363. }
  4364. function getLastMatchNode(matchNode) {
  4365. if ('node' in matchNode) {
  4366. return matchNode.node;
  4367. }
  4368. return getLastMatchNode(matchNode.match[matchNode.match.length - 1]);
  4369. }
  4370. function matchFragments(lexer, ast, match, type, name) {
  4371. function findFragments(matchNode) {
  4372. if (matchNode.syntax !== null &&
  4373. matchNode.syntax.type === type &&
  4374. matchNode.syntax.name === name) {
  4375. var start = getFirstMatchNode(matchNode);
  4376. var end = getLastMatchNode(matchNode);
  4377. lexer.syntax.walk(ast, function(node, item, list) {
  4378. if (node === start) {
  4379. var nodes = new List_1();
  4380. do {
  4381. nodes.appendData(item.data);
  4382. if (item.data === end) {
  4383. break;
  4384. }
  4385. item = item.next;
  4386. } while (item !== null);
  4387. fragments.push({
  4388. parent: list,
  4389. nodes: nodes
  4390. });
  4391. }
  4392. });
  4393. }
  4394. if (Array.isArray(matchNode.match)) {
  4395. matchNode.match.forEach(findFragments);
  4396. }
  4397. }
  4398. var fragments = [];
  4399. if (match.matched !== null) {
  4400. findFragments(match.matched);
  4401. }
  4402. return fragments;
  4403. }
  4404. var search = {
  4405. matchFragments: matchFragments
  4406. };
  4407. var hasOwnProperty$2 = Object.prototype.hasOwnProperty;
  4408. function isValidNumber(value) {
  4409. // Number.isInteger(value) && value >= 0
  4410. return (
  4411. typeof value === 'number' &&
  4412. isFinite(value) &&
  4413. Math.floor(value) === value &&
  4414. value >= 0
  4415. );
  4416. }
  4417. function isValidLocation(loc) {
  4418. return (
  4419. Boolean(loc) &&
  4420. isValidNumber(loc.offset) &&
  4421. isValidNumber(loc.line) &&
  4422. isValidNumber(loc.column)
  4423. );
  4424. }
  4425. function createNodeStructureChecker(type, fields) {
  4426. return function checkNode(node, warn) {
  4427. if (!node || node.constructor !== Object) {
  4428. return warn(node, 'Type of node should be an Object');
  4429. }
  4430. for (var key in node) {
  4431. var valid = true;
  4432. if (hasOwnProperty$2.call(node, key) === false) {
  4433. continue;
  4434. }
  4435. if (key === 'type') {
  4436. if (node.type !== type) {
  4437. warn(node, 'Wrong node type `' + node.type + '`, expected `' + type + '`');
  4438. }
  4439. } else if (key === 'loc') {
  4440. if (node.loc === null) {
  4441. continue;
  4442. } else if (node.loc && node.loc.constructor === Object) {
  4443. if (typeof node.loc.source !== 'string') {
  4444. key += '.source';
  4445. } else if (!isValidLocation(node.loc.start)) {
  4446. key += '.start';
  4447. } else if (!isValidLocation(node.loc.end)) {
  4448. key += '.end';
  4449. } else {
  4450. continue;
  4451. }
  4452. }
  4453. valid = false;
  4454. } else if (fields.hasOwnProperty(key)) {
  4455. for (var i = 0, valid = false; !valid && i < fields[key].length; i++) {
  4456. var fieldType = fields[key][i];
  4457. switch (fieldType) {
  4458. case String:
  4459. valid = typeof node[key] === 'string';
  4460. break;
  4461. case Boolean:
  4462. valid = typeof node[key] === 'boolean';
  4463. break;
  4464. case null:
  4465. valid = node[key] === null;
  4466. break;
  4467. default:
  4468. if (typeof fieldType === 'string') {
  4469. valid = node[key] && node[key].type === fieldType;
  4470. } else if (Array.isArray(fieldType)) {
  4471. valid = node[key] instanceof List_1;
  4472. }
  4473. }
  4474. }
  4475. } else {
  4476. warn(node, 'Unknown field `' + key + '` for ' + type + ' node type');
  4477. }
  4478. if (!valid) {
  4479. warn(node, 'Bad value for `' + type + '.' + key + '`');
  4480. }
  4481. }
  4482. for (var key in fields) {
  4483. if (hasOwnProperty$2.call(fields, key) &&
  4484. hasOwnProperty$2.call(node, key) === false) {
  4485. warn(node, 'Field `' + type + '.' + key + '` is missed');
  4486. }
  4487. }
  4488. };
  4489. }
  4490. function processStructure(name, nodeType) {
  4491. var structure = nodeType.structure;
  4492. var fields = {
  4493. type: String,
  4494. loc: true
  4495. };
  4496. var docs = {
  4497. type: '"' + name + '"'
  4498. };
  4499. for (var key in structure) {
  4500. if (hasOwnProperty$2.call(structure, key) === false) {
  4501. continue;
  4502. }
  4503. var docsTypes = [];
  4504. var fieldTypes = fields[key] = Array.isArray(structure[key])
  4505. ? structure[key].slice()
  4506. : [structure[key]];
  4507. for (var i = 0; i < fieldTypes.length; i++) {
  4508. var fieldType = fieldTypes[i];
  4509. if (fieldType === String || fieldType === Boolean) {
  4510. docsTypes.push(fieldType.name);
  4511. } else if (fieldType === null) {
  4512. docsTypes.push('null');
  4513. } else if (typeof fieldType === 'string') {
  4514. docsTypes.push('<' + fieldType + '>');
  4515. } else if (Array.isArray(fieldType)) {
  4516. docsTypes.push('List'); // TODO: use type enum
  4517. } else {
  4518. throw new Error('Wrong value `' + fieldType + '` in `' + name + '.' + key + '` structure definition');
  4519. }
  4520. }
  4521. docs[key] = docsTypes.join(' | ');
  4522. }
  4523. return {
  4524. docs: docs,
  4525. check: createNodeStructureChecker(name, fields)
  4526. };
  4527. }
  4528. var structure = {
  4529. getStructureFromConfig: function(config) {
  4530. var structure = {};
  4531. if (config.node) {
  4532. for (var name in config.node) {
  4533. if (hasOwnProperty$2.call(config.node, name)) {
  4534. var nodeType = config.node[name];
  4535. if (nodeType.structure) {
  4536. structure[name] = processStructure(name, nodeType);
  4537. } else {
  4538. throw new Error('Missed `structure` field in `' + name + '` node type definition');
  4539. }
  4540. }
  4541. }
  4542. }
  4543. return structure;
  4544. }
  4545. };
  4546. var SyntaxReferenceError$1 = error.SyntaxReferenceError;
  4547. var SyntaxMatchError$1 = error.SyntaxMatchError;
  4548. var buildMatchGraph$1 = matchGraph.buildMatchGraph;
  4549. var matchAsTree$1 = match.matchAsTree;
  4550. var getStructureFromConfig = structure.getStructureFromConfig;
  4551. var cssWideKeywords$1 = buildMatchGraph$1('inherit | initial | unset');
  4552. var cssWideKeywordsWithExpression = buildMatchGraph$1('inherit | initial | unset | <-ms-legacy-expression>');
  4553. function dumpMapSyntax(map, compact, syntaxAsAst) {
  4554. var result = {};
  4555. for (var name in map) {
  4556. if (map[name].syntax) {
  4557. result[name] = syntaxAsAst
  4558. ? map[name].syntax
  4559. : generate_1(map[name].syntax, { compact: compact });
  4560. }
  4561. }
  4562. return result;
  4563. }
  4564. function dumpAtruleMapSyntax(map, compact, syntaxAsAst) {
  4565. const result = {};
  4566. for (const [name, atrule] of Object.entries(map)) {
  4567. result[name] = {
  4568. prelude: atrule.prelude && (
  4569. syntaxAsAst
  4570. ? atrule.prelude.syntax
  4571. : generate_1(atrule.prelude.syntax, { compact })
  4572. ),
  4573. descriptors: atrule.descriptors && dumpMapSyntax(atrule.descriptors, compact, syntaxAsAst)
  4574. };
  4575. }
  4576. return result;
  4577. }
  4578. function valueHasVar(tokens) {
  4579. for (var i = 0; i < tokens.length; i++) {
  4580. if (tokens[i].value.toLowerCase() === 'var(') {
  4581. return true;
  4582. }
  4583. }
  4584. return false;
  4585. }
  4586. function buildMatchResult(match, error, iterations) {
  4587. return {
  4588. matched: match,
  4589. iterations: iterations,
  4590. error: error,
  4591. getTrace: trace.getTrace,
  4592. isType: trace.isType,
  4593. isProperty: trace.isProperty,
  4594. isKeyword: trace.isKeyword
  4595. };
  4596. }
  4597. function matchSyntax(lexer, syntax, value, useCommon) {
  4598. var tokens = prepareTokens_1(value, lexer.syntax);
  4599. var result;
  4600. if (valueHasVar(tokens)) {
  4601. return buildMatchResult(null, new Error('Matching for a tree with var() is not supported'));
  4602. }
  4603. if (useCommon) {
  4604. result = matchAsTree$1(tokens, lexer.valueCommonSyntax, lexer);
  4605. }
  4606. if (!useCommon || !result.match) {
  4607. result = matchAsTree$1(tokens, syntax.match, lexer);
  4608. if (!result.match) {
  4609. return buildMatchResult(
  4610. null,
  4611. new SyntaxMatchError$1(result.reason, syntax.syntax, value, result),
  4612. result.iterations
  4613. );
  4614. }
  4615. }
  4616. return buildMatchResult(result.match, null, result.iterations);
  4617. }
  4618. var Lexer = function(config, syntax, structure) {
  4619. this.valueCommonSyntax = cssWideKeywords$1;
  4620. this.syntax = syntax;
  4621. this.generic = false;
  4622. this.atrules = {};
  4623. this.properties = {};
  4624. this.types = {};
  4625. this.structure = structure || getStructureFromConfig(config);
  4626. if (config) {
  4627. if (config.types) {
  4628. for (var name in config.types) {
  4629. this.addType_(name, config.types[name]);
  4630. }
  4631. }
  4632. if (config.generic) {
  4633. this.generic = true;
  4634. for (var name in generic) {
  4635. this.addType_(name, generic[name]);
  4636. }
  4637. }
  4638. if (config.atrules) {
  4639. for (var name in config.atrules) {
  4640. this.addAtrule_(name, config.atrules[name]);
  4641. }
  4642. }
  4643. if (config.properties) {
  4644. for (var name in config.properties) {
  4645. this.addProperty_(name, config.properties[name]);
  4646. }
  4647. }
  4648. }
  4649. };
  4650. Lexer.prototype = {
  4651. structure: {},
  4652. checkStructure: function(ast) {
  4653. function collectWarning(node, message) {
  4654. warns.push({
  4655. node: node,
  4656. message: message
  4657. });
  4658. }
  4659. var structure = this.structure;
  4660. var warns = [];
  4661. this.syntax.walk(ast, function(node) {
  4662. if (structure.hasOwnProperty(node.type)) {
  4663. structure[node.type].check(node, collectWarning);
  4664. } else {
  4665. collectWarning(node, 'Unknown node type `' + node.type + '`');
  4666. }
  4667. });
  4668. return warns.length ? warns : false;
  4669. },
  4670. createDescriptor: function(syntax, type, name, parent = null) {
  4671. var ref = {
  4672. type: type,
  4673. name: name
  4674. };
  4675. var descriptor = {
  4676. type: type,
  4677. name: name,
  4678. parent: parent,
  4679. syntax: null,
  4680. match: null
  4681. };
  4682. if (typeof syntax === 'function') {
  4683. descriptor.match = buildMatchGraph$1(syntax, ref);
  4684. } else {
  4685. if (typeof syntax === 'string') {
  4686. // lazy parsing on first access
  4687. Object.defineProperty(descriptor, 'syntax', {
  4688. get: function() {
  4689. Object.defineProperty(descriptor, 'syntax', {
  4690. value: parse_1(syntax)
  4691. });
  4692. return descriptor.syntax;
  4693. }
  4694. });
  4695. } else {
  4696. descriptor.syntax = syntax;
  4697. }
  4698. // lazy graph build on first access
  4699. Object.defineProperty(descriptor, 'match', {
  4700. get: function() {
  4701. Object.defineProperty(descriptor, 'match', {
  4702. value: buildMatchGraph$1(descriptor.syntax, ref)
  4703. });
  4704. return descriptor.match;
  4705. }
  4706. });
  4707. }
  4708. return descriptor;
  4709. },
  4710. addAtrule_: function(name, syntax) {
  4711. if (!syntax) {
  4712. return;
  4713. }
  4714. this.atrules[name] = {
  4715. type: 'Atrule',
  4716. name: name,
  4717. prelude: syntax.prelude ? this.createDescriptor(syntax.prelude, 'AtrulePrelude', name) : null,
  4718. descriptors: syntax.descriptors
  4719. ? Object.keys(syntax.descriptors).reduce((res, descName) => {
  4720. res[descName] = this.createDescriptor(syntax.descriptors[descName], 'AtruleDescriptor', descName, name);
  4721. return res;
  4722. }, {})
  4723. : null
  4724. };
  4725. },
  4726. addProperty_: function(name, syntax) {
  4727. if (!syntax) {
  4728. return;
  4729. }
  4730. this.properties[name] = this.createDescriptor(syntax, 'Property', name);
  4731. },
  4732. addType_: function(name, syntax) {
  4733. if (!syntax) {
  4734. return;
  4735. }
  4736. this.types[name] = this.createDescriptor(syntax, 'Type', name);
  4737. if (syntax === generic['-ms-legacy-expression']) {
  4738. this.valueCommonSyntax = cssWideKeywordsWithExpression;
  4739. }
  4740. },
  4741. checkAtruleName: function(atruleName) {
  4742. if (!this.getAtrule(atruleName)) {
  4743. return new SyntaxReferenceError$1('Unknown at-rule', '@' + atruleName);
  4744. }
  4745. },
  4746. checkAtrulePrelude: function(atruleName, prelude) {
  4747. let error = this.checkAtruleName(atruleName);
  4748. if (error) {
  4749. return error;
  4750. }
  4751. var atrule = this.getAtrule(atruleName);
  4752. if (!atrule.prelude && prelude) {
  4753. return new SyntaxError('At-rule `@' + atruleName + '` should not contain a prelude');
  4754. }
  4755. if (atrule.prelude && !prelude) {
  4756. return new SyntaxError('At-rule `@' + atruleName + '` should contain a prelude');
  4757. }
  4758. },
  4759. checkAtruleDescriptorName: function(atruleName, descriptorName) {
  4760. let error = this.checkAtruleName(atruleName);
  4761. if (error) {
  4762. return error;
  4763. }
  4764. var atrule = this.getAtrule(atruleName);
  4765. var descriptor = names.keyword(descriptorName);
  4766. if (!atrule.descriptors) {
  4767. return new SyntaxError('At-rule `@' + atruleName + '` has no known descriptors');
  4768. }
  4769. if (!atrule.descriptors[descriptor.name] &&
  4770. !atrule.descriptors[descriptor.basename]) {
  4771. return new SyntaxReferenceError$1('Unknown at-rule descriptor', descriptorName);
  4772. }
  4773. },
  4774. checkPropertyName: function(propertyName) {
  4775. var property = names.property(propertyName);
  4776. // don't match syntax for a custom property
  4777. if (property.custom) {
  4778. return new Error('Lexer matching doesn\'t applicable for custom properties');
  4779. }
  4780. if (!this.getProperty(propertyName)) {
  4781. return new SyntaxReferenceError$1('Unknown property', propertyName);
  4782. }
  4783. },
  4784. matchAtrulePrelude: function(atruleName, prelude) {
  4785. var error = this.checkAtrulePrelude(atruleName, prelude);
  4786. if (error) {
  4787. return buildMatchResult(null, error);
  4788. }
  4789. if (!prelude) {
  4790. return buildMatchResult(null, null);
  4791. }
  4792. return matchSyntax(this, this.getAtrule(atruleName).prelude, prelude, false);
  4793. },
  4794. matchAtruleDescriptor: function(atruleName, descriptorName, value) {
  4795. var error = this.checkAtruleDescriptorName(atruleName, descriptorName);
  4796. if (error) {
  4797. return buildMatchResult(null, error);
  4798. }
  4799. var atrule = this.getAtrule(atruleName);
  4800. var descriptor = names.keyword(descriptorName);
  4801. return matchSyntax(this, atrule.descriptors[descriptor.name] || atrule.descriptors[descriptor.basename], value, false);
  4802. },
  4803. matchDeclaration: function(node) {
  4804. if (node.type !== 'Declaration') {
  4805. return buildMatchResult(null, new Error('Not a Declaration node'));
  4806. }
  4807. return this.matchProperty(node.property, node.value);
  4808. },
  4809. matchProperty: function(propertyName, value) {
  4810. var error = this.checkPropertyName(propertyName);
  4811. if (error) {
  4812. return buildMatchResult(null, error);
  4813. }
  4814. return matchSyntax(this, this.getProperty(propertyName), value, true);
  4815. },
  4816. matchType: function(typeName, value) {
  4817. var typeSyntax = this.getType(typeName);
  4818. if (!typeSyntax) {
  4819. return buildMatchResult(null, new SyntaxReferenceError$1('Unknown type', typeName));
  4820. }
  4821. return matchSyntax(this, typeSyntax, value, false);
  4822. },
  4823. match: function(syntax, value) {
  4824. if (typeof syntax !== 'string' && (!syntax || !syntax.type)) {
  4825. return buildMatchResult(null, new SyntaxReferenceError$1('Bad syntax'));
  4826. }
  4827. if (typeof syntax === 'string' || !syntax.match) {
  4828. syntax = this.createDescriptor(syntax, 'Type', 'anonymous');
  4829. }
  4830. return matchSyntax(this, syntax, value, false);
  4831. },
  4832. findValueFragments: function(propertyName, value, type, name) {
  4833. return search.matchFragments(this, value, this.matchProperty(propertyName, value), type, name);
  4834. },
  4835. findDeclarationValueFragments: function(declaration, type, name) {
  4836. return search.matchFragments(this, declaration.value, this.matchDeclaration(declaration), type, name);
  4837. },
  4838. findAllFragments: function(ast, type, name) {
  4839. var result = [];
  4840. this.syntax.walk(ast, {
  4841. visit: 'Declaration',
  4842. enter: function(declaration) {
  4843. result.push.apply(result, this.findDeclarationValueFragments(declaration, type, name));
  4844. }.bind(this)
  4845. });
  4846. return result;
  4847. },
  4848. getAtrule: function(atruleName, fallbackBasename = true) {
  4849. var atrule = names.keyword(atruleName);
  4850. var atruleEntry = atrule.vendor && fallbackBasename
  4851. ? this.atrules[atrule.name] || this.atrules[atrule.basename]
  4852. : this.atrules[atrule.name];
  4853. return atruleEntry || null;
  4854. },
  4855. getAtrulePrelude: function(atruleName, fallbackBasename = true) {
  4856. const atrule = this.getAtrule(atruleName, fallbackBasename);
  4857. return atrule && atrule.prelude || null;
  4858. },
  4859. getAtruleDescriptor: function(atruleName, name) {
  4860. return this.atrules.hasOwnProperty(atruleName) && this.atrules.declarators
  4861. ? this.atrules[atruleName].declarators[name] || null
  4862. : null;
  4863. },
  4864. getProperty: function(propertyName, fallbackBasename = true) {
  4865. var property = names.property(propertyName);
  4866. var propertyEntry = property.vendor && fallbackBasename
  4867. ? this.properties[property.name] || this.properties[property.basename]
  4868. : this.properties[property.name];
  4869. return propertyEntry || null;
  4870. },
  4871. getType: function(name) {
  4872. return this.types.hasOwnProperty(name) ? this.types[name] : null;
  4873. },
  4874. validate: function() {
  4875. function validate(syntax, name, broken, descriptor) {
  4876. if (broken.hasOwnProperty(name)) {
  4877. return broken[name];
  4878. }
  4879. broken[name] = false;
  4880. if (descriptor.syntax !== null) {
  4881. walk(descriptor.syntax, function(node) {
  4882. if (node.type !== 'Type' && node.type !== 'Property') {
  4883. return;
  4884. }
  4885. var map = node.type === 'Type' ? syntax.types : syntax.properties;
  4886. var brokenMap = node.type === 'Type' ? brokenTypes : brokenProperties;
  4887. if (!map.hasOwnProperty(node.name) || validate(syntax, node.name, brokenMap, map[node.name])) {
  4888. broken[name] = true;
  4889. }
  4890. }, this);
  4891. }
  4892. }
  4893. var brokenTypes = {};
  4894. var brokenProperties = {};
  4895. for (var key in this.types) {
  4896. validate(this, key, brokenTypes, this.types[key]);
  4897. }
  4898. for (var key in this.properties) {
  4899. validate(this, key, brokenProperties, this.properties[key]);
  4900. }
  4901. brokenTypes = Object.keys(brokenTypes).filter(function(name) {
  4902. return brokenTypes[name];
  4903. });
  4904. brokenProperties = Object.keys(brokenProperties).filter(function(name) {
  4905. return brokenProperties[name];
  4906. });
  4907. if (brokenTypes.length || brokenProperties.length) {
  4908. return {
  4909. types: brokenTypes,
  4910. properties: brokenProperties
  4911. };
  4912. }
  4913. return null;
  4914. },
  4915. dump: function(syntaxAsAst, pretty) {
  4916. return {
  4917. generic: this.generic,
  4918. types: dumpMapSyntax(this.types, !pretty, syntaxAsAst),
  4919. properties: dumpMapSyntax(this.properties, !pretty, syntaxAsAst),
  4920. atrules: dumpAtruleMapSyntax(this.atrules, !pretty, syntaxAsAst)
  4921. };
  4922. },
  4923. toString: function() {
  4924. return JSON.stringify(this.dump());
  4925. }
  4926. };
  4927. var Lexer_1 = Lexer;
  4928. var definitionSyntax = {
  4929. SyntaxError: _SyntaxError$1,
  4930. parse: parse_1,
  4931. generate: generate_1,
  4932. walk: walk
  4933. };
  4934. var isBOM$2 = tokenizer.isBOM;
  4935. var N$3 = 10;
  4936. var F$2 = 12;
  4937. var R$2 = 13;
  4938. function computeLinesAndColumns(host, source) {
  4939. var sourceLength = source.length;
  4940. var lines = adoptBuffer(host.lines, sourceLength); // +1
  4941. var line = host.startLine;
  4942. var columns = adoptBuffer(host.columns, sourceLength);
  4943. var column = host.startColumn;
  4944. var startOffset = source.length > 0 ? isBOM$2(source.charCodeAt(0)) : 0;
  4945. for (var i = startOffset; i < sourceLength; i++) { // -1
  4946. var code = source.charCodeAt(i);
  4947. lines[i] = line;
  4948. columns[i] = column++;
  4949. if (code === N$3 || code === R$2 || code === F$2) {
  4950. if (code === R$2 && i + 1 < sourceLength && source.charCodeAt(i + 1) === N$3) {
  4951. i++;
  4952. lines[i] = line;
  4953. columns[i] = column;
  4954. }
  4955. line++;
  4956. column = 1;
  4957. }
  4958. }
  4959. lines[i] = line;
  4960. columns[i] = column;
  4961. host.lines = lines;
  4962. host.columns = columns;
  4963. }
  4964. var OffsetToLocation = function() {
  4965. this.lines = null;
  4966. this.columns = null;
  4967. this.linesAndColumnsComputed = false;
  4968. };
  4969. OffsetToLocation.prototype = {
  4970. setSource: function(source, startOffset, startLine, startColumn) {
  4971. this.source = source;
  4972. this.startOffset = typeof startOffset === 'undefined' ? 0 : startOffset;
  4973. this.startLine = typeof startLine === 'undefined' ? 1 : startLine;
  4974. this.startColumn = typeof startColumn === 'undefined' ? 1 : startColumn;
  4975. this.linesAndColumnsComputed = false;
  4976. },
  4977. ensureLinesAndColumnsComputed: function() {
  4978. if (!this.linesAndColumnsComputed) {
  4979. computeLinesAndColumns(this, this.source);
  4980. this.linesAndColumnsComputed = true;
  4981. }
  4982. },
  4983. getLocation: function(offset, filename) {
  4984. this.ensureLinesAndColumnsComputed();
  4985. return {
  4986. source: filename,
  4987. offset: this.startOffset + offset,
  4988. line: this.lines[offset],
  4989. column: this.columns[offset]
  4990. };
  4991. },
  4992. getLocationRange: function(start, end, filename) {
  4993. this.ensureLinesAndColumnsComputed();
  4994. return {
  4995. source: filename,
  4996. start: {
  4997. offset: this.startOffset + start,
  4998. line: this.lines[start],
  4999. column: this.columns[start]
  5000. },
  5001. end: {
  5002. offset: this.startOffset + end,
  5003. line: this.lines[end],
  5004. column: this.columns[end]
  5005. }
  5006. };
  5007. }
  5008. };
  5009. var OffsetToLocation_1 = OffsetToLocation;
  5010. var TYPE$7 = tokenizer.TYPE;
  5011. var WHITESPACE$2 = TYPE$7.WhiteSpace;
  5012. var COMMENT$2 = TYPE$7.Comment;
  5013. var sequence = function readSequence(recognizer) {
  5014. var children = this.createList();
  5015. var child = null;
  5016. var context = {
  5017. recognizer: recognizer,
  5018. space: null,
  5019. ignoreWS: false,
  5020. ignoreWSAfter: false
  5021. };
  5022. this.scanner.skipSC();
  5023. while (!this.scanner.eof) {
  5024. switch (this.scanner.tokenType) {
  5025. case COMMENT$2:
  5026. this.scanner.next();
  5027. continue;
  5028. case WHITESPACE$2:
  5029. if (context.ignoreWS) {
  5030. this.scanner.next();
  5031. } else {
  5032. context.space = this.WhiteSpace();
  5033. }
  5034. continue;
  5035. }
  5036. child = recognizer.getNode.call(this, context);
  5037. if (child === undefined) {
  5038. break;
  5039. }
  5040. if (context.space !== null) {
  5041. children.push(context.space);
  5042. context.space = null;
  5043. }
  5044. children.push(child);
  5045. if (context.ignoreWSAfter) {
  5046. context.ignoreWSAfter = false;
  5047. context.ignoreWS = true;
  5048. } else {
  5049. context.ignoreWS = false;
  5050. }
  5051. }
  5052. return children;
  5053. };
  5054. var { findWhiteSpaceStart: findWhiteSpaceStart$1, cmpStr: cmpStr$4 } = utils;
  5055. var noop$2 = function() {};
  5056. var TYPE$8 = _const.TYPE;
  5057. var NAME$2 = _const.NAME;
  5058. var WHITESPACE$3 = TYPE$8.WhiteSpace;
  5059. var COMMENT$3 = TYPE$8.Comment;
  5060. var IDENT$2 = TYPE$8.Ident;
  5061. var FUNCTION = TYPE$8.Function;
  5062. var URL = TYPE$8.Url;
  5063. var HASH = TYPE$8.Hash;
  5064. var PERCENTAGE = TYPE$8.Percentage;
  5065. var NUMBER$2 = TYPE$8.Number;
  5066. var NUMBERSIGN$1 = 0x0023; // U+0023 NUMBER SIGN (#)
  5067. var NULL = 0;
  5068. function createParseContext(name) {
  5069. return function() {
  5070. return this[name]();
  5071. };
  5072. }
  5073. function processConfig(config) {
  5074. var parserConfig = {
  5075. context: {},
  5076. scope: {},
  5077. atrule: {},
  5078. pseudo: {}
  5079. };
  5080. if (config.parseContext) {
  5081. for (var name in config.parseContext) {
  5082. switch (typeof config.parseContext[name]) {
  5083. case 'function':
  5084. parserConfig.context[name] = config.parseContext[name];
  5085. break;
  5086. case 'string':
  5087. parserConfig.context[name] = createParseContext(config.parseContext[name]);
  5088. break;
  5089. }
  5090. }
  5091. }
  5092. if (config.scope) {
  5093. for (var name in config.scope) {
  5094. parserConfig.scope[name] = config.scope[name];
  5095. }
  5096. }
  5097. if (config.atrule) {
  5098. for (var name in config.atrule) {
  5099. var atrule = config.atrule[name];
  5100. if (atrule.parse) {
  5101. parserConfig.atrule[name] = atrule.parse;
  5102. }
  5103. }
  5104. }
  5105. if (config.pseudo) {
  5106. for (var name in config.pseudo) {
  5107. var pseudo = config.pseudo[name];
  5108. if (pseudo.parse) {
  5109. parserConfig.pseudo[name] = pseudo.parse;
  5110. }
  5111. }
  5112. }
  5113. if (config.node) {
  5114. for (var name in config.node) {
  5115. parserConfig[name] = config.node[name].parse;
  5116. }
  5117. }
  5118. return parserConfig;
  5119. }
  5120. var create = function createParser(config) {
  5121. var parser = {
  5122. scanner: new TokenStream_1(),
  5123. locationMap: new OffsetToLocation_1(),
  5124. filename: '<unknown>',
  5125. needPositions: false,
  5126. onParseError: noop$2,
  5127. onParseErrorThrow: false,
  5128. parseAtrulePrelude: true,
  5129. parseRulePrelude: true,
  5130. parseValue: true,
  5131. parseCustomProperty: false,
  5132. readSequence: sequence,
  5133. createList: function() {
  5134. return new List_1();
  5135. },
  5136. createSingleNodeList: function(node) {
  5137. return new List_1().appendData(node);
  5138. },
  5139. getFirstListNode: function(list) {
  5140. return list && list.first();
  5141. },
  5142. getLastListNode: function(list) {
  5143. return list.last();
  5144. },
  5145. parseWithFallback: function(consumer, fallback) {
  5146. var startToken = this.scanner.tokenIndex;
  5147. try {
  5148. return consumer.call(this);
  5149. } catch (e) {
  5150. if (this.onParseErrorThrow) {
  5151. throw e;
  5152. }
  5153. var fallbackNode = fallback.call(this, startToken);
  5154. this.onParseErrorThrow = true;
  5155. this.onParseError(e, fallbackNode);
  5156. this.onParseErrorThrow = false;
  5157. return fallbackNode;
  5158. }
  5159. },
  5160. lookupNonWSType: function(offset) {
  5161. do {
  5162. var type = this.scanner.lookupType(offset++);
  5163. if (type !== WHITESPACE$3) {
  5164. return type;
  5165. }
  5166. } while (type !== NULL);
  5167. return NULL;
  5168. },
  5169. eat: function(tokenType) {
  5170. if (this.scanner.tokenType !== tokenType) {
  5171. var offset = this.scanner.tokenStart;
  5172. var message = NAME$2[tokenType] + ' is expected';
  5173. // tweak message and offset
  5174. switch (tokenType) {
  5175. case IDENT$2:
  5176. // when identifier is expected but there is a function or url
  5177. if (this.scanner.tokenType === FUNCTION || this.scanner.tokenType === URL) {
  5178. offset = this.scanner.tokenEnd - 1;
  5179. message = 'Identifier is expected but function found';
  5180. } else {
  5181. message = 'Identifier is expected';
  5182. }
  5183. break;
  5184. case HASH:
  5185. if (this.scanner.isDelim(NUMBERSIGN$1)) {
  5186. this.scanner.next();
  5187. offset++;
  5188. message = 'Name is expected';
  5189. }
  5190. break;
  5191. case PERCENTAGE:
  5192. if (this.scanner.tokenType === NUMBER$2) {
  5193. offset = this.scanner.tokenEnd;
  5194. message = 'Percent sign is expected';
  5195. }
  5196. break;
  5197. default:
  5198. // when test type is part of another token show error for current position + 1
  5199. // e.g. eat(HYPHENMINUS) will fail on "-foo", but pointing on "-" is odd
  5200. if (this.scanner.source.charCodeAt(this.scanner.tokenStart) === tokenType) {
  5201. offset = offset + 1;
  5202. }
  5203. }
  5204. this.error(message, offset);
  5205. }
  5206. this.scanner.next();
  5207. },
  5208. consume: function(tokenType) {
  5209. var value = this.scanner.getTokenValue();
  5210. this.eat(tokenType);
  5211. return value;
  5212. },
  5213. consumeFunctionName: function() {
  5214. var name = this.scanner.source.substring(this.scanner.tokenStart, this.scanner.tokenEnd - 1);
  5215. this.eat(FUNCTION);
  5216. return name;
  5217. },
  5218. getLocation: function(start, end) {
  5219. if (this.needPositions) {
  5220. return this.locationMap.getLocationRange(
  5221. start,
  5222. end,
  5223. this.filename
  5224. );
  5225. }
  5226. return null;
  5227. },
  5228. getLocationFromList: function(list) {
  5229. if (this.needPositions) {
  5230. var head = this.getFirstListNode(list);
  5231. var tail = this.getLastListNode(list);
  5232. return this.locationMap.getLocationRange(
  5233. head !== null ? head.loc.start.offset - this.locationMap.startOffset : this.scanner.tokenStart,
  5234. tail !== null ? tail.loc.end.offset - this.locationMap.startOffset : this.scanner.tokenStart,
  5235. this.filename
  5236. );
  5237. }
  5238. return null;
  5239. },
  5240. error: function(message, offset) {
  5241. var location = typeof offset !== 'undefined' && offset < this.scanner.source.length
  5242. ? this.locationMap.getLocation(offset)
  5243. : this.scanner.eof
  5244. ? this.locationMap.getLocation(findWhiteSpaceStart$1(this.scanner.source, this.scanner.source.length - 1))
  5245. : this.locationMap.getLocation(this.scanner.tokenStart);
  5246. throw new _SyntaxError(
  5247. message || 'Unexpected input',
  5248. this.scanner.source,
  5249. location.offset,
  5250. location.line,
  5251. location.column
  5252. );
  5253. }
  5254. };
  5255. config = processConfig(config || {});
  5256. for (var key in config) {
  5257. parser[key] = config[key];
  5258. }
  5259. return function(source, options) {
  5260. options = options || {};
  5261. var context = options.context || 'default';
  5262. var onComment = options.onComment;
  5263. var ast;
  5264. tokenizer(source, parser.scanner);
  5265. parser.locationMap.setSource(
  5266. source,
  5267. options.offset,
  5268. options.line,
  5269. options.column
  5270. );
  5271. parser.filename = options.filename || '<unknown>';
  5272. parser.needPositions = Boolean(options.positions);
  5273. parser.onParseError = typeof options.onParseError === 'function' ? options.onParseError : noop$2;
  5274. parser.onParseErrorThrow = false;
  5275. parser.parseAtrulePrelude = 'parseAtrulePrelude' in options ? Boolean(options.parseAtrulePrelude) : true;
  5276. parser.parseRulePrelude = 'parseRulePrelude' in options ? Boolean(options.parseRulePrelude) : true;
  5277. parser.parseValue = 'parseValue' in options ? Boolean(options.parseValue) : true;
  5278. parser.parseCustomProperty = 'parseCustomProperty' in options ? Boolean(options.parseCustomProperty) : false;
  5279. if (!parser.context.hasOwnProperty(context)) {
  5280. throw new Error('Unknown context `' + context + '`');
  5281. }
  5282. if (typeof onComment === 'function') {
  5283. parser.scanner.forEachToken((type, start, end) => {
  5284. if (type === COMMENT$3) {
  5285. const loc = parser.getLocation(start, end);
  5286. const value = cmpStr$4(source, end - 2, end, '*/')
  5287. ? source.slice(start + 2, end - 2)
  5288. : source.slice(start + 2, end);
  5289. onComment(value, loc);
  5290. }
  5291. });
  5292. }
  5293. ast = parser.context[context].call(parser, options);
  5294. if (!parser.scanner.eof) {
  5295. parser.error();
  5296. }
  5297. return ast;
  5298. };
  5299. };
  5300. /* -*- Mode: js; js-indent-level: 2; -*- */
  5301. /*
  5302. * Copyright 2011 Mozilla Foundation and contributors
  5303. * Licensed under the New BSD license. See LICENSE or:
  5304. * http://opensource.org/licenses/BSD-3-Clause
  5305. */
  5306. var intToCharMap = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'.split('');
  5307. /**
  5308. * Encode an integer in the range of 0 to 63 to a single base 64 digit.
  5309. */
  5310. var encode = function (number) {
  5311. if (0 <= number && number < intToCharMap.length) {
  5312. return intToCharMap[number];
  5313. }
  5314. throw new TypeError("Must be between 0 and 63: " + number);
  5315. };
  5316. /**
  5317. * Decode a single base 64 character code digit to an integer. Returns -1 on
  5318. * failure.
  5319. */
  5320. var decode = function (charCode) {
  5321. var bigA = 65; // 'A'
  5322. var bigZ = 90; // 'Z'
  5323. var littleA = 97; // 'a'
  5324. var littleZ = 122; // 'z'
  5325. var zero = 48; // '0'
  5326. var nine = 57; // '9'
  5327. var plus = 43; // '+'
  5328. var slash = 47; // '/'
  5329. var littleOffset = 26;
  5330. var numberOffset = 52;
  5331. // 0 - 25: ABCDEFGHIJKLMNOPQRSTUVWXYZ
  5332. if (bigA <= charCode && charCode <= bigZ) {
  5333. return (charCode - bigA);
  5334. }
  5335. // 26 - 51: abcdefghijklmnopqrstuvwxyz
  5336. if (littleA <= charCode && charCode <= littleZ) {
  5337. return (charCode - littleA + littleOffset);
  5338. }
  5339. // 52 - 61: 0123456789
  5340. if (zero <= charCode && charCode <= nine) {
  5341. return (charCode - zero + numberOffset);
  5342. }
  5343. // 62: +
  5344. if (charCode == plus) {
  5345. return 62;
  5346. }
  5347. // 63: /
  5348. if (charCode == slash) {
  5349. return 63;
  5350. }
  5351. // Invalid base64 digit.
  5352. return -1;
  5353. };
  5354. var base64 = {
  5355. encode: encode,
  5356. decode: decode
  5357. };
  5358. /* -*- Mode: js; js-indent-level: 2; -*- */
  5359. /*
  5360. * Copyright 2011 Mozilla Foundation and contributors
  5361. * Licensed under the New BSD license. See LICENSE or:
  5362. * http://opensource.org/licenses/BSD-3-Clause
  5363. *
  5364. * Based on the Base 64 VLQ implementation in Closure Compiler:
  5365. * https://code.google.com/p/closure-compiler/source/browse/trunk/src/com/google/debugging/sourcemap/Base64VLQ.java
  5366. *
  5367. * Copyright 2011 The Closure Compiler Authors. All rights reserved.
  5368. * Redistribution and use in source and binary forms, with or without
  5369. * modification, are permitted provided that the following conditions are
  5370. * met:
  5371. *
  5372. * * Redistributions of source code must retain the above copyright
  5373. * notice, this list of conditions and the following disclaimer.
  5374. * * Redistributions in binary form must reproduce the above
  5375. * copyright notice, this list of conditions and the following
  5376. * disclaimer in the documentation and/or other materials provided
  5377. * with the distribution.
  5378. * * Neither the name of Google Inc. nor the names of its
  5379. * contributors may be used to endorse or promote products derived
  5380. * from this software without specific prior written permission.
  5381. *
  5382. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  5383. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  5384. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  5385. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  5386. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  5387. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  5388. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  5389. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  5390. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  5391. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  5392. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  5393. */
  5394. // A single base 64 digit can contain 6 bits of data. For the base 64 variable
  5395. // length quantities we use in the source map spec, the first bit is the sign,
  5396. // the next four bits are the actual value, and the 6th bit is the
  5397. // continuation bit. The continuation bit tells us whether there are more
  5398. // digits in this value following this digit.
  5399. //
  5400. // Continuation
  5401. // | Sign
  5402. // | |
  5403. // V V
  5404. // 101011
  5405. var VLQ_BASE_SHIFT = 5;
  5406. // binary: 100000
  5407. var VLQ_BASE = 1 << VLQ_BASE_SHIFT;
  5408. // binary: 011111
  5409. var VLQ_BASE_MASK = VLQ_BASE - 1;
  5410. // binary: 100000
  5411. var VLQ_CONTINUATION_BIT = VLQ_BASE;
  5412. /**
  5413. * Converts from a two-complement value to a value where the sign bit is
  5414. * placed in the least significant bit. For example, as decimals:
  5415. * 1 becomes 2 (10 binary), -1 becomes 3 (11 binary)
  5416. * 2 becomes 4 (100 binary), -2 becomes 5 (101 binary)
  5417. */
  5418. function toVLQSigned(aValue) {
  5419. return aValue < 0
  5420. ? ((-aValue) << 1) + 1
  5421. : (aValue << 1) + 0;
  5422. }
  5423. /**
  5424. * Converts to a two-complement value from a value where the sign bit is
  5425. * placed in the least significant bit. For example, as decimals:
  5426. * 2 (10 binary) becomes 1, 3 (11 binary) becomes -1
  5427. * 4 (100 binary) becomes 2, 5 (101 binary) becomes -2
  5428. */
  5429. function fromVLQSigned(aValue) {
  5430. var isNegative = (aValue & 1) === 1;
  5431. var shifted = aValue >> 1;
  5432. return isNegative
  5433. ? -shifted
  5434. : shifted;
  5435. }
  5436. /**
  5437. * Returns the base 64 VLQ encoded value.
  5438. */
  5439. var encode$1 = function base64VLQ_encode(aValue) {
  5440. var encoded = "";
  5441. var digit;
  5442. var vlq = toVLQSigned(aValue);
  5443. do {
  5444. digit = vlq & VLQ_BASE_MASK;
  5445. vlq >>>= VLQ_BASE_SHIFT;
  5446. if (vlq > 0) {
  5447. // There are still more digits in this value, so we must make sure the
  5448. // continuation bit is marked.
  5449. digit |= VLQ_CONTINUATION_BIT;
  5450. }
  5451. encoded += base64.encode(digit);
  5452. } while (vlq > 0);
  5453. return encoded;
  5454. };
  5455. /**
  5456. * Decodes the next base 64 VLQ value from the given string and returns the
  5457. * value and the rest of the string via the out parameter.
  5458. */
  5459. var decode$1 = function base64VLQ_decode(aStr, aIndex, aOutParam) {
  5460. var strLen = aStr.length;
  5461. var result = 0;
  5462. var shift = 0;
  5463. var continuation, digit;
  5464. do {
  5465. if (aIndex >= strLen) {
  5466. throw new Error("Expected more digits in base 64 VLQ value.");
  5467. }
  5468. digit = base64.decode(aStr.charCodeAt(aIndex++));
  5469. if (digit === -1) {
  5470. throw new Error("Invalid base64 digit: " + aStr.charAt(aIndex - 1));
  5471. }
  5472. continuation = !!(digit & VLQ_CONTINUATION_BIT);
  5473. digit &= VLQ_BASE_MASK;
  5474. result = result + (digit << shift);
  5475. shift += VLQ_BASE_SHIFT;
  5476. } while (continuation);
  5477. aOutParam.value = fromVLQSigned(result);
  5478. aOutParam.rest = aIndex;
  5479. };
  5480. var base64Vlq = {
  5481. encode: encode$1,
  5482. decode: decode$1
  5483. };
  5484. function createCommonjsModule(fn, module) {
  5485. return module = { exports: {} }, fn(module, module.exports), module.exports;
  5486. }
  5487. function getCjsExportFromNamespace (n) {
  5488. return n && n['default'] || n;
  5489. }
  5490. var util = createCommonjsModule(function (module, exports) {
  5491. /* -*- Mode: js; js-indent-level: 2; -*- */
  5492. /*
  5493. * Copyright 2011 Mozilla Foundation and contributors
  5494. * Licensed under the New BSD license. See LICENSE or:
  5495. * http://opensource.org/licenses/BSD-3-Clause
  5496. */
  5497. /**
  5498. * This is a helper function for getting values from parameter/options
  5499. * objects.
  5500. *
  5501. * @param args The object we are extracting values from
  5502. * @param name The name of the property we are getting.
  5503. * @param defaultValue An optional value to return if the property is missing
  5504. * from the object. If this is not specified and the property is missing, an
  5505. * error will be thrown.
  5506. */
  5507. function getArg(aArgs, aName, aDefaultValue) {
  5508. if (aName in aArgs) {
  5509. return aArgs[aName];
  5510. } else if (arguments.length === 3) {
  5511. return aDefaultValue;
  5512. } else {
  5513. throw new Error('"' + aName + '" is a required argument.');
  5514. }
  5515. }
  5516. exports.getArg = getArg;
  5517. var urlRegexp = /^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.-]*)(?::(\d+))?(.*)$/;
  5518. var dataUrlRegexp = /^data:.+\,.+$/;
  5519. function urlParse(aUrl) {
  5520. var match = aUrl.match(urlRegexp);
  5521. if (!match) {
  5522. return null;
  5523. }
  5524. return {
  5525. scheme: match[1],
  5526. auth: match[2],
  5527. host: match[3],
  5528. port: match[4],
  5529. path: match[5]
  5530. };
  5531. }
  5532. exports.urlParse = urlParse;
  5533. function urlGenerate(aParsedUrl) {
  5534. var url = '';
  5535. if (aParsedUrl.scheme) {
  5536. url += aParsedUrl.scheme + ':';
  5537. }
  5538. url += '//';
  5539. if (aParsedUrl.auth) {
  5540. url += aParsedUrl.auth + '@';
  5541. }
  5542. if (aParsedUrl.host) {
  5543. url += aParsedUrl.host;
  5544. }
  5545. if (aParsedUrl.port) {
  5546. url += ":" + aParsedUrl.port;
  5547. }
  5548. if (aParsedUrl.path) {
  5549. url += aParsedUrl.path;
  5550. }
  5551. return url;
  5552. }
  5553. exports.urlGenerate = urlGenerate;
  5554. /**
  5555. * Normalizes a path, or the path portion of a URL:
  5556. *
  5557. * - Replaces consecutive slashes with one slash.
  5558. * - Removes unnecessary '.' parts.
  5559. * - Removes unnecessary '<dir>/..' parts.
  5560. *
  5561. * Based on code in the Node.js 'path' core module.
  5562. *
  5563. * @param aPath The path or url to normalize.
  5564. */
  5565. function normalize(aPath) {
  5566. var path = aPath;
  5567. var url = urlParse(aPath);
  5568. if (url) {
  5569. if (!url.path) {
  5570. return aPath;
  5571. }
  5572. path = url.path;
  5573. }
  5574. var isAbsolute = exports.isAbsolute(path);
  5575. var parts = path.split(/\/+/);
  5576. for (var part, up = 0, i = parts.length - 1; i >= 0; i--) {
  5577. part = parts[i];
  5578. if (part === '.') {
  5579. parts.splice(i, 1);
  5580. } else if (part === '..') {
  5581. up++;
  5582. } else if (up > 0) {
  5583. if (part === '') {
  5584. // The first part is blank if the path is absolute. Trying to go
  5585. // above the root is a no-op. Therefore we can remove all '..' parts
  5586. // directly after the root.
  5587. parts.splice(i + 1, up);
  5588. up = 0;
  5589. } else {
  5590. parts.splice(i, 2);
  5591. up--;
  5592. }
  5593. }
  5594. }
  5595. path = parts.join('/');
  5596. if (path === '') {
  5597. path = isAbsolute ? '/' : '.';
  5598. }
  5599. if (url) {
  5600. url.path = path;
  5601. return urlGenerate(url);
  5602. }
  5603. return path;
  5604. }
  5605. exports.normalize = normalize;
  5606. /**
  5607. * Joins two paths/URLs.
  5608. *
  5609. * @param aRoot The root path or URL.
  5610. * @param aPath The path or URL to be joined with the root.
  5611. *
  5612. * - If aPath is a URL or a data URI, aPath is returned, unless aPath is a
  5613. * scheme-relative URL: Then the scheme of aRoot, if any, is prepended
  5614. * first.
  5615. * - Otherwise aPath is a path. If aRoot is a URL, then its path portion
  5616. * is updated with the result and aRoot is returned. Otherwise the result
  5617. * is returned.
  5618. * - If aPath is absolute, the result is aPath.
  5619. * - Otherwise the two paths are joined with a slash.
  5620. * - Joining for example 'http://' and 'www.example.com' is also supported.
  5621. */
  5622. function join(aRoot, aPath) {
  5623. if (aRoot === "") {
  5624. aRoot = ".";
  5625. }
  5626. if (aPath === "") {
  5627. aPath = ".";
  5628. }
  5629. var aPathUrl = urlParse(aPath);
  5630. var aRootUrl = urlParse(aRoot);
  5631. if (aRootUrl) {
  5632. aRoot = aRootUrl.path || '/';
  5633. }
  5634. // `join(foo, '//www.example.org')`
  5635. if (aPathUrl && !aPathUrl.scheme) {
  5636. if (aRootUrl) {
  5637. aPathUrl.scheme = aRootUrl.scheme;
  5638. }
  5639. return urlGenerate(aPathUrl);
  5640. }
  5641. if (aPathUrl || aPath.match(dataUrlRegexp)) {
  5642. return aPath;
  5643. }
  5644. // `join('http://', 'www.example.com')`
  5645. if (aRootUrl && !aRootUrl.host && !aRootUrl.path) {
  5646. aRootUrl.host = aPath;
  5647. return urlGenerate(aRootUrl);
  5648. }
  5649. var joined = aPath.charAt(0) === '/'
  5650. ? aPath
  5651. : normalize(aRoot.replace(/\/+$/, '') + '/' + aPath);
  5652. if (aRootUrl) {
  5653. aRootUrl.path = joined;
  5654. return urlGenerate(aRootUrl);
  5655. }
  5656. return joined;
  5657. }
  5658. exports.join = join;
  5659. exports.isAbsolute = function (aPath) {
  5660. return aPath.charAt(0) === '/' || urlRegexp.test(aPath);
  5661. };
  5662. /**
  5663. * Make a path relative to a URL or another path.
  5664. *
  5665. * @param aRoot The root path or URL.
  5666. * @param aPath The path or URL to be made relative to aRoot.
  5667. */
  5668. function relative(aRoot, aPath) {
  5669. if (aRoot === "") {
  5670. aRoot = ".";
  5671. }
  5672. aRoot = aRoot.replace(/\/$/, '');
  5673. // It is possible for the path to be above the root. In this case, simply
  5674. // checking whether the root is a prefix of the path won't work. Instead, we
  5675. // need to remove components from the root one by one, until either we find
  5676. // a prefix that fits, or we run out of components to remove.
  5677. var level = 0;
  5678. while (aPath.indexOf(aRoot + '/') !== 0) {
  5679. var index = aRoot.lastIndexOf("/");
  5680. if (index < 0) {
  5681. return aPath;
  5682. }
  5683. // If the only part of the root that is left is the scheme (i.e. http://,
  5684. // file:///, etc.), one or more slashes (/), or simply nothing at all, we
  5685. // have exhausted all components, so the path is not relative to the root.
  5686. aRoot = aRoot.slice(0, index);
  5687. if (aRoot.match(/^([^\/]+:\/)?\/*$/)) {
  5688. return aPath;
  5689. }
  5690. ++level;
  5691. }
  5692. // Make sure we add a "../" for each component we removed from the root.
  5693. return Array(level + 1).join("../") + aPath.substr(aRoot.length + 1);
  5694. }
  5695. exports.relative = relative;
  5696. var supportsNullProto = (function () {
  5697. var obj = Object.create(null);
  5698. return !('__proto__' in obj);
  5699. }());
  5700. function identity (s) {
  5701. return s;
  5702. }
  5703. /**
  5704. * Because behavior goes wacky when you set `__proto__` on objects, we
  5705. * have to prefix all the strings in our set with an arbitrary character.
  5706. *
  5707. * See https://github.com/mozilla/source-map/pull/31 and
  5708. * https://github.com/mozilla/source-map/issues/30
  5709. *
  5710. * @param String aStr
  5711. */
  5712. function toSetString(aStr) {
  5713. if (isProtoString(aStr)) {
  5714. return '$' + aStr;
  5715. }
  5716. return aStr;
  5717. }
  5718. exports.toSetString = supportsNullProto ? identity : toSetString;
  5719. function fromSetString(aStr) {
  5720. if (isProtoString(aStr)) {
  5721. return aStr.slice(1);
  5722. }
  5723. return aStr;
  5724. }
  5725. exports.fromSetString = supportsNullProto ? identity : fromSetString;
  5726. function isProtoString(s) {
  5727. if (!s) {
  5728. return false;
  5729. }
  5730. var length = s.length;
  5731. if (length < 9 /* "__proto__".length */) {
  5732. return false;
  5733. }
  5734. if (s.charCodeAt(length - 1) !== 95 /* '_' */ ||
  5735. s.charCodeAt(length - 2) !== 95 /* '_' */ ||
  5736. s.charCodeAt(length - 3) !== 111 /* 'o' */ ||
  5737. s.charCodeAt(length - 4) !== 116 /* 't' */ ||
  5738. s.charCodeAt(length - 5) !== 111 /* 'o' */ ||
  5739. s.charCodeAt(length - 6) !== 114 /* 'r' */ ||
  5740. s.charCodeAt(length - 7) !== 112 /* 'p' */ ||
  5741. s.charCodeAt(length - 8) !== 95 /* '_' */ ||
  5742. s.charCodeAt(length - 9) !== 95 /* '_' */) {
  5743. return false;
  5744. }
  5745. for (var i = length - 10; i >= 0; i--) {
  5746. if (s.charCodeAt(i) !== 36 /* '$' */) {
  5747. return false;
  5748. }
  5749. }
  5750. return true;
  5751. }
  5752. /**
  5753. * Comparator between two mappings where the original positions are compared.
  5754. *
  5755. * Optionally pass in `true` as `onlyCompareGenerated` to consider two
  5756. * mappings with the same original source/line/column, but different generated
  5757. * line and column the same. Useful when searching for a mapping with a
  5758. * stubbed out mapping.
  5759. */
  5760. function compareByOriginalPositions(mappingA, mappingB, onlyCompareOriginal) {
  5761. var cmp = strcmp(mappingA.source, mappingB.source);
  5762. if (cmp !== 0) {
  5763. return cmp;
  5764. }
  5765. cmp = mappingA.originalLine - mappingB.originalLine;
  5766. if (cmp !== 0) {
  5767. return cmp;
  5768. }
  5769. cmp = mappingA.originalColumn - mappingB.originalColumn;
  5770. if (cmp !== 0 || onlyCompareOriginal) {
  5771. return cmp;
  5772. }
  5773. cmp = mappingA.generatedColumn - mappingB.generatedColumn;
  5774. if (cmp !== 0) {
  5775. return cmp;
  5776. }
  5777. cmp = mappingA.generatedLine - mappingB.generatedLine;
  5778. if (cmp !== 0) {
  5779. return cmp;
  5780. }
  5781. return strcmp(mappingA.name, mappingB.name);
  5782. }
  5783. exports.compareByOriginalPositions = compareByOriginalPositions;
  5784. /**
  5785. * Comparator between two mappings with deflated source and name indices where
  5786. * the generated positions are compared.
  5787. *
  5788. * Optionally pass in `true` as `onlyCompareGenerated` to consider two
  5789. * mappings with the same generated line and column, but different
  5790. * source/name/original line and column the same. Useful when searching for a
  5791. * mapping with a stubbed out mapping.
  5792. */
  5793. function compareByGeneratedPositionsDeflated(mappingA, mappingB, onlyCompareGenerated) {
  5794. var cmp = mappingA.generatedLine - mappingB.generatedLine;
  5795. if (cmp !== 0) {
  5796. return cmp;
  5797. }
  5798. cmp = mappingA.generatedColumn - mappingB.generatedColumn;
  5799. if (cmp !== 0 || onlyCompareGenerated) {
  5800. return cmp;
  5801. }
  5802. cmp = strcmp(mappingA.source, mappingB.source);
  5803. if (cmp !== 0) {
  5804. return cmp;
  5805. }
  5806. cmp = mappingA.originalLine - mappingB.originalLine;
  5807. if (cmp !== 0) {
  5808. return cmp;
  5809. }
  5810. cmp = mappingA.originalColumn - mappingB.originalColumn;
  5811. if (cmp !== 0) {
  5812. return cmp;
  5813. }
  5814. return strcmp(mappingA.name, mappingB.name);
  5815. }
  5816. exports.compareByGeneratedPositionsDeflated = compareByGeneratedPositionsDeflated;
  5817. function strcmp(aStr1, aStr2) {
  5818. if (aStr1 === aStr2) {
  5819. return 0;
  5820. }
  5821. if (aStr1 === null) {
  5822. return 1; // aStr2 !== null
  5823. }
  5824. if (aStr2 === null) {
  5825. return -1; // aStr1 !== null
  5826. }
  5827. if (aStr1 > aStr2) {
  5828. return 1;
  5829. }
  5830. return -1;
  5831. }
  5832. /**
  5833. * Comparator between two mappings with inflated source and name strings where
  5834. * the generated positions are compared.
  5835. */
  5836. function compareByGeneratedPositionsInflated(mappingA, mappingB) {
  5837. var cmp = mappingA.generatedLine - mappingB.generatedLine;
  5838. if (cmp !== 0) {
  5839. return cmp;
  5840. }
  5841. cmp = mappingA.generatedColumn - mappingB.generatedColumn;
  5842. if (cmp !== 0) {
  5843. return cmp;
  5844. }
  5845. cmp = strcmp(mappingA.source, mappingB.source);
  5846. if (cmp !== 0) {
  5847. return cmp;
  5848. }
  5849. cmp = mappingA.originalLine - mappingB.originalLine;
  5850. if (cmp !== 0) {
  5851. return cmp;
  5852. }
  5853. cmp = mappingA.originalColumn - mappingB.originalColumn;
  5854. if (cmp !== 0) {
  5855. return cmp;
  5856. }
  5857. return strcmp(mappingA.name, mappingB.name);
  5858. }
  5859. exports.compareByGeneratedPositionsInflated = compareByGeneratedPositionsInflated;
  5860. /**
  5861. * Strip any JSON XSSI avoidance prefix from the string (as documented
  5862. * in the source maps specification), and then parse the string as
  5863. * JSON.
  5864. */
  5865. function parseSourceMapInput(str) {
  5866. return JSON.parse(str.replace(/^\)]}'[^\n]*\n/, ''));
  5867. }
  5868. exports.parseSourceMapInput = parseSourceMapInput;
  5869. /**
  5870. * Compute the URL of a source given the the source root, the source's
  5871. * URL, and the source map's URL.
  5872. */
  5873. function computeSourceURL(sourceRoot, sourceURL, sourceMapURL) {
  5874. sourceURL = sourceURL || '';
  5875. if (sourceRoot) {
  5876. // This follows what Chrome does.
  5877. if (sourceRoot[sourceRoot.length - 1] !== '/' && sourceURL[0] !== '/') {
  5878. sourceRoot += '/';
  5879. }
  5880. // The spec says:
  5881. // Line 4: An optional source root, useful for relocating source
  5882. // files on a server or removing repeated values in the
  5883. // “sources” entry. This value is prepended to the individual
  5884. // entries in the “source” field.
  5885. sourceURL = sourceRoot + sourceURL;
  5886. }
  5887. // Historically, SourceMapConsumer did not take the sourceMapURL as
  5888. // a parameter. This mode is still somewhat supported, which is why
  5889. // this code block is conditional. However, it's preferable to pass
  5890. // the source map URL to SourceMapConsumer, so that this function
  5891. // can implement the source URL resolution algorithm as outlined in
  5892. // the spec. This block is basically the equivalent of:
  5893. // new URL(sourceURL, sourceMapURL).toString()
  5894. // ... except it avoids using URL, which wasn't available in the
  5895. // older releases of node still supported by this library.
  5896. //
  5897. // The spec says:
  5898. // If the sources are not absolute URLs after prepending of the
  5899. // “sourceRoot”, the sources are resolved relative to the
  5900. // SourceMap (like resolving script src in a html document).
  5901. if (sourceMapURL) {
  5902. var parsed = urlParse(sourceMapURL);
  5903. if (!parsed) {
  5904. throw new Error("sourceMapURL could not be parsed");
  5905. }
  5906. if (parsed.path) {
  5907. // Strip the last path component, but keep the "/".
  5908. var index = parsed.path.lastIndexOf('/');
  5909. if (index >= 0) {
  5910. parsed.path = parsed.path.substring(0, index + 1);
  5911. }
  5912. }
  5913. sourceURL = join(urlGenerate(parsed), sourceURL);
  5914. }
  5915. return normalize(sourceURL);
  5916. }
  5917. exports.computeSourceURL = computeSourceURL;
  5918. });
  5919. var util_1 = util.getArg;
  5920. var util_2 = util.urlParse;
  5921. var util_3 = util.urlGenerate;
  5922. var util_4 = util.normalize;
  5923. var util_5 = util.join;
  5924. var util_6 = util.isAbsolute;
  5925. var util_7 = util.relative;
  5926. var util_8 = util.toSetString;
  5927. var util_9 = util.fromSetString;
  5928. var util_10 = util.compareByOriginalPositions;
  5929. var util_11 = util.compareByGeneratedPositionsDeflated;
  5930. var util_12 = util.compareByGeneratedPositionsInflated;
  5931. var util_13 = util.parseSourceMapInput;
  5932. var util_14 = util.computeSourceURL;
  5933. /* -*- Mode: js; js-indent-level: 2; -*- */
  5934. /*
  5935. * Copyright 2011 Mozilla Foundation and contributors
  5936. * Licensed under the New BSD license. See LICENSE or:
  5937. * http://opensource.org/licenses/BSD-3-Clause
  5938. */
  5939. var has = Object.prototype.hasOwnProperty;
  5940. var hasNativeMap = typeof Map !== "undefined";
  5941. /**
  5942. * A data structure which is a combination of an array and a set. Adding a new
  5943. * member is O(1), testing for membership is O(1), and finding the index of an
  5944. * element is O(1). Removing elements from the set is not supported. Only
  5945. * strings are supported for membership.
  5946. */
  5947. function ArraySet() {
  5948. this._array = [];
  5949. this._set = hasNativeMap ? new Map() : Object.create(null);
  5950. }
  5951. /**
  5952. * Static method for creating ArraySet instances from an existing array.
  5953. */
  5954. ArraySet.fromArray = function ArraySet_fromArray(aArray, aAllowDuplicates) {
  5955. var set = new ArraySet();
  5956. for (var i = 0, len = aArray.length; i < len; i++) {
  5957. set.add(aArray[i], aAllowDuplicates);
  5958. }
  5959. return set;
  5960. };
  5961. /**
  5962. * Return how many unique items are in this ArraySet. If duplicates have been
  5963. * added, than those do not count towards the size.
  5964. *
  5965. * @returns Number
  5966. */
  5967. ArraySet.prototype.size = function ArraySet_size() {
  5968. return hasNativeMap ? this._set.size : Object.getOwnPropertyNames(this._set).length;
  5969. };
  5970. /**
  5971. * Add the given string to this set.
  5972. *
  5973. * @param String aStr
  5974. */
  5975. ArraySet.prototype.add = function ArraySet_add(aStr, aAllowDuplicates) {
  5976. var sStr = hasNativeMap ? aStr : util.toSetString(aStr);
  5977. var isDuplicate = hasNativeMap ? this.has(aStr) : has.call(this._set, sStr);
  5978. var idx = this._array.length;
  5979. if (!isDuplicate || aAllowDuplicates) {
  5980. this._array.push(aStr);
  5981. }
  5982. if (!isDuplicate) {
  5983. if (hasNativeMap) {
  5984. this._set.set(aStr, idx);
  5985. } else {
  5986. this._set[sStr] = idx;
  5987. }
  5988. }
  5989. };
  5990. /**
  5991. * Is the given string a member of this set?
  5992. *
  5993. * @param String aStr
  5994. */
  5995. ArraySet.prototype.has = function ArraySet_has(aStr) {
  5996. if (hasNativeMap) {
  5997. return this._set.has(aStr);
  5998. } else {
  5999. var sStr = util.toSetString(aStr);
  6000. return has.call(this._set, sStr);
  6001. }
  6002. };
  6003. /**
  6004. * What is the index of the given string in the array?
  6005. *
  6006. * @param String aStr
  6007. */
  6008. ArraySet.prototype.indexOf = function ArraySet_indexOf(aStr) {
  6009. if (hasNativeMap) {
  6010. var idx = this._set.get(aStr);
  6011. if (idx >= 0) {
  6012. return idx;
  6013. }
  6014. } else {
  6015. var sStr = util.toSetString(aStr);
  6016. if (has.call(this._set, sStr)) {
  6017. return this._set[sStr];
  6018. }
  6019. }
  6020. throw new Error('"' + aStr + '" is not in the set.');
  6021. };
  6022. /**
  6023. * What is the element at the given index?
  6024. *
  6025. * @param Number aIdx
  6026. */
  6027. ArraySet.prototype.at = function ArraySet_at(aIdx) {
  6028. if (aIdx >= 0 && aIdx < this._array.length) {
  6029. return this._array[aIdx];
  6030. }
  6031. throw new Error('No element indexed by ' + aIdx);
  6032. };
  6033. /**
  6034. * Returns the array representation of this set (which has the proper indices
  6035. * indicated by indexOf). Note that this is a copy of the internal array used
  6036. * for storing the members so that no one can mess with internal state.
  6037. */
  6038. ArraySet.prototype.toArray = function ArraySet_toArray() {
  6039. return this._array.slice();
  6040. };
  6041. var ArraySet_1 = ArraySet;
  6042. var arraySet = {
  6043. ArraySet: ArraySet_1
  6044. };
  6045. /* -*- Mode: js; js-indent-level: 2; -*- */
  6046. /*
  6047. * Copyright 2014 Mozilla Foundation and contributors
  6048. * Licensed under the New BSD license. See LICENSE or:
  6049. * http://opensource.org/licenses/BSD-3-Clause
  6050. */
  6051. /**
  6052. * Determine whether mappingB is after mappingA with respect to generated
  6053. * position.
  6054. */
  6055. function generatedPositionAfter(mappingA, mappingB) {
  6056. // Optimized for most common case
  6057. var lineA = mappingA.generatedLine;
  6058. var lineB = mappingB.generatedLine;
  6059. var columnA = mappingA.generatedColumn;
  6060. var columnB = mappingB.generatedColumn;
  6061. return lineB > lineA || lineB == lineA && columnB >= columnA ||
  6062. util.compareByGeneratedPositionsInflated(mappingA, mappingB) <= 0;
  6063. }
  6064. /**
  6065. * A data structure to provide a sorted view of accumulated mappings in a
  6066. * performance conscious manner. It trades a neglibable overhead in general
  6067. * case for a large speedup in case of mappings being added in order.
  6068. */
  6069. function MappingList() {
  6070. this._array = [];
  6071. this._sorted = true;
  6072. // Serves as infimum
  6073. this._last = {generatedLine: -1, generatedColumn: 0};
  6074. }
  6075. /**
  6076. * Iterate through internal items. This method takes the same arguments that
  6077. * `Array.prototype.forEach` takes.
  6078. *
  6079. * NOTE: The order of the mappings is NOT guaranteed.
  6080. */
  6081. MappingList.prototype.unsortedForEach =
  6082. function MappingList_forEach(aCallback, aThisArg) {
  6083. this._array.forEach(aCallback, aThisArg);
  6084. };
  6085. /**
  6086. * Add the given source mapping.
  6087. *
  6088. * @param Object aMapping
  6089. */
  6090. MappingList.prototype.add = function MappingList_add(aMapping) {
  6091. if (generatedPositionAfter(this._last, aMapping)) {
  6092. this._last = aMapping;
  6093. this._array.push(aMapping);
  6094. } else {
  6095. this._sorted = false;
  6096. this._array.push(aMapping);
  6097. }
  6098. };
  6099. /**
  6100. * Returns the flat, sorted array of mappings. The mappings are sorted by
  6101. * generated position.
  6102. *
  6103. * WARNING: This method returns internal data without copying, for
  6104. * performance. The return value must NOT be mutated, and should be treated as
  6105. * an immutable borrow. If you want to take ownership, you must make your own
  6106. * copy.
  6107. */
  6108. MappingList.prototype.toArray = function MappingList_toArray() {
  6109. if (!this._sorted) {
  6110. this._array.sort(util.compareByGeneratedPositionsInflated);
  6111. this._sorted = true;
  6112. }
  6113. return this._array;
  6114. };
  6115. var MappingList_1 = MappingList;
  6116. var mappingList = {
  6117. MappingList: MappingList_1
  6118. };
  6119. /* -*- Mode: js; js-indent-level: 2; -*- */
  6120. /*
  6121. * Copyright 2011 Mozilla Foundation and contributors
  6122. * Licensed under the New BSD license. See LICENSE or:
  6123. * http://opensource.org/licenses/BSD-3-Clause
  6124. */
  6125. var ArraySet$1 = arraySet.ArraySet;
  6126. var MappingList$1 = mappingList.MappingList;
  6127. /**
  6128. * An instance of the SourceMapGenerator represents a source map which is
  6129. * being built incrementally. You may pass an object with the following
  6130. * properties:
  6131. *
  6132. * - file: The filename of the generated source.
  6133. * - sourceRoot: A root for all relative URLs in this source map.
  6134. */
  6135. function SourceMapGenerator(aArgs) {
  6136. if (!aArgs) {
  6137. aArgs = {};
  6138. }
  6139. this._file = util.getArg(aArgs, 'file', null);
  6140. this._sourceRoot = util.getArg(aArgs, 'sourceRoot', null);
  6141. this._skipValidation = util.getArg(aArgs, 'skipValidation', false);
  6142. this._sources = new ArraySet$1();
  6143. this._names = new ArraySet$1();
  6144. this._mappings = new MappingList$1();
  6145. this._sourcesContents = null;
  6146. }
  6147. SourceMapGenerator.prototype._version = 3;
  6148. /**
  6149. * Creates a new SourceMapGenerator based on a SourceMapConsumer
  6150. *
  6151. * @param aSourceMapConsumer The SourceMap.
  6152. */
  6153. SourceMapGenerator.fromSourceMap =
  6154. function SourceMapGenerator_fromSourceMap(aSourceMapConsumer) {
  6155. var sourceRoot = aSourceMapConsumer.sourceRoot;
  6156. var generator = new SourceMapGenerator({
  6157. file: aSourceMapConsumer.file,
  6158. sourceRoot: sourceRoot
  6159. });
  6160. aSourceMapConsumer.eachMapping(function (mapping) {
  6161. var newMapping = {
  6162. generated: {
  6163. line: mapping.generatedLine,
  6164. column: mapping.generatedColumn
  6165. }
  6166. };
  6167. if (mapping.source != null) {
  6168. newMapping.source = mapping.source;
  6169. if (sourceRoot != null) {
  6170. newMapping.source = util.relative(sourceRoot, newMapping.source);
  6171. }
  6172. newMapping.original = {
  6173. line: mapping.originalLine,
  6174. column: mapping.originalColumn
  6175. };
  6176. if (mapping.name != null) {
  6177. newMapping.name = mapping.name;
  6178. }
  6179. }
  6180. generator.addMapping(newMapping);
  6181. });
  6182. aSourceMapConsumer.sources.forEach(function (sourceFile) {
  6183. var sourceRelative = sourceFile;
  6184. if (sourceRoot !== null) {
  6185. sourceRelative = util.relative(sourceRoot, sourceFile);
  6186. }
  6187. if (!generator._sources.has(sourceRelative)) {
  6188. generator._sources.add(sourceRelative);
  6189. }
  6190. var content = aSourceMapConsumer.sourceContentFor(sourceFile);
  6191. if (content != null) {
  6192. generator.setSourceContent(sourceFile, content);
  6193. }
  6194. });
  6195. return generator;
  6196. };
  6197. /**
  6198. * Add a single mapping from original source line and column to the generated
  6199. * source's line and column for this source map being created. The mapping
  6200. * object should have the following properties:
  6201. *
  6202. * - generated: An object with the generated line and column positions.
  6203. * - original: An object with the original line and column positions.
  6204. * - source: The original source file (relative to the sourceRoot).
  6205. * - name: An optional original token name for this mapping.
  6206. */
  6207. SourceMapGenerator.prototype.addMapping =
  6208. function SourceMapGenerator_addMapping(aArgs) {
  6209. var generated = util.getArg(aArgs, 'generated');
  6210. var original = util.getArg(aArgs, 'original', null);
  6211. var source = util.getArg(aArgs, 'source', null);
  6212. var name = util.getArg(aArgs, 'name', null);
  6213. if (!this._skipValidation) {
  6214. this._validateMapping(generated, original, source, name);
  6215. }
  6216. if (source != null) {
  6217. source = String(source);
  6218. if (!this._sources.has(source)) {
  6219. this._sources.add(source);
  6220. }
  6221. }
  6222. if (name != null) {
  6223. name = String(name);
  6224. if (!this._names.has(name)) {
  6225. this._names.add(name);
  6226. }
  6227. }
  6228. this._mappings.add({
  6229. generatedLine: generated.line,
  6230. generatedColumn: generated.column,
  6231. originalLine: original != null && original.line,
  6232. originalColumn: original != null && original.column,
  6233. source: source,
  6234. name: name
  6235. });
  6236. };
  6237. /**
  6238. * Set the source content for a source file.
  6239. */
  6240. SourceMapGenerator.prototype.setSourceContent =
  6241. function SourceMapGenerator_setSourceContent(aSourceFile, aSourceContent) {
  6242. var source = aSourceFile;
  6243. if (this._sourceRoot != null) {
  6244. source = util.relative(this._sourceRoot, source);
  6245. }
  6246. if (aSourceContent != null) {
  6247. // Add the source content to the _sourcesContents map.
  6248. // Create a new _sourcesContents map if the property is null.
  6249. if (!this._sourcesContents) {
  6250. this._sourcesContents = Object.create(null);
  6251. }
  6252. this._sourcesContents[util.toSetString(source)] = aSourceContent;
  6253. } else if (this._sourcesContents) {
  6254. // Remove the source file from the _sourcesContents map.
  6255. // If the _sourcesContents map is empty, set the property to null.
  6256. delete this._sourcesContents[util.toSetString(source)];
  6257. if (Object.keys(this._sourcesContents).length === 0) {
  6258. this._sourcesContents = null;
  6259. }
  6260. }
  6261. };
  6262. /**
  6263. * Applies the mappings of a sub-source-map for a specific source file to the
  6264. * source map being generated. Each mapping to the supplied source file is
  6265. * rewritten using the supplied source map. Note: The resolution for the
  6266. * resulting mappings is the minimium of this map and the supplied map.
  6267. *
  6268. * @param aSourceMapConsumer The source map to be applied.
  6269. * @param aSourceFile Optional. The filename of the source file.
  6270. * If omitted, SourceMapConsumer's file property will be used.
  6271. * @param aSourceMapPath Optional. The dirname of the path to the source map
  6272. * to be applied. If relative, it is relative to the SourceMapConsumer.
  6273. * This parameter is needed when the two source maps aren't in the same
  6274. * directory, and the source map to be applied contains relative source
  6275. * paths. If so, those relative source paths need to be rewritten
  6276. * relative to the SourceMapGenerator.
  6277. */
  6278. SourceMapGenerator.prototype.applySourceMap =
  6279. function SourceMapGenerator_applySourceMap(aSourceMapConsumer, aSourceFile, aSourceMapPath) {
  6280. var sourceFile = aSourceFile;
  6281. // If aSourceFile is omitted, we will use the file property of the SourceMap
  6282. if (aSourceFile == null) {
  6283. if (aSourceMapConsumer.file == null) {
  6284. throw new Error(
  6285. 'SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, ' +
  6286. 'or the source map\'s "file" property. Both were omitted.'
  6287. );
  6288. }
  6289. sourceFile = aSourceMapConsumer.file;
  6290. }
  6291. var sourceRoot = this._sourceRoot;
  6292. // Make "sourceFile" relative if an absolute Url is passed.
  6293. if (sourceRoot != null) {
  6294. sourceFile = util.relative(sourceRoot, sourceFile);
  6295. }
  6296. // Applying the SourceMap can add and remove items from the sources and
  6297. // the names array.
  6298. var newSources = new ArraySet$1();
  6299. var newNames = new ArraySet$1();
  6300. // Find mappings for the "sourceFile"
  6301. this._mappings.unsortedForEach(function (mapping) {
  6302. if (mapping.source === sourceFile && mapping.originalLine != null) {
  6303. // Check if it can be mapped by the source map, then update the mapping.
  6304. var original = aSourceMapConsumer.originalPositionFor({
  6305. line: mapping.originalLine,
  6306. column: mapping.originalColumn
  6307. });
  6308. if (original.source != null) {
  6309. // Copy mapping
  6310. mapping.source = original.source;
  6311. if (aSourceMapPath != null) {
  6312. mapping.source = util.join(aSourceMapPath, mapping.source);
  6313. }
  6314. if (sourceRoot != null) {
  6315. mapping.source = util.relative(sourceRoot, mapping.source);
  6316. }
  6317. mapping.originalLine = original.line;
  6318. mapping.originalColumn = original.column;
  6319. if (original.name != null) {
  6320. mapping.name = original.name;
  6321. }
  6322. }
  6323. }
  6324. var source = mapping.source;
  6325. if (source != null && !newSources.has(source)) {
  6326. newSources.add(source);
  6327. }
  6328. var name = mapping.name;
  6329. if (name != null && !newNames.has(name)) {
  6330. newNames.add(name);
  6331. }
  6332. }, this);
  6333. this._sources = newSources;
  6334. this._names = newNames;
  6335. // Copy sourcesContents of applied map.
  6336. aSourceMapConsumer.sources.forEach(function (sourceFile) {
  6337. var content = aSourceMapConsumer.sourceContentFor(sourceFile);
  6338. if (content != null) {
  6339. if (aSourceMapPath != null) {
  6340. sourceFile = util.join(aSourceMapPath, sourceFile);
  6341. }
  6342. if (sourceRoot != null) {
  6343. sourceFile = util.relative(sourceRoot, sourceFile);
  6344. }
  6345. this.setSourceContent(sourceFile, content);
  6346. }
  6347. }, this);
  6348. };
  6349. /**
  6350. * A mapping can have one of the three levels of data:
  6351. *
  6352. * 1. Just the generated position.
  6353. * 2. The Generated position, original position, and original source.
  6354. * 3. Generated and original position, original source, as well as a name
  6355. * token.
  6356. *
  6357. * To maintain consistency, we validate that any new mapping being added falls
  6358. * in to one of these categories.
  6359. */
  6360. SourceMapGenerator.prototype._validateMapping =
  6361. function SourceMapGenerator_validateMapping(aGenerated, aOriginal, aSource,
  6362. aName) {
  6363. // When aOriginal is truthy but has empty values for .line and .column,
  6364. // it is most likely a programmer error. In this case we throw a very
  6365. // specific error message to try to guide them the right way.
  6366. // For example: https://github.com/Polymer/polymer-bundler/pull/519
  6367. if (aOriginal && typeof aOriginal.line !== 'number' && typeof aOriginal.column !== 'number') {
  6368. throw new Error(
  6369. 'original.line and original.column are not numbers -- you probably meant to omit ' +
  6370. 'the original mapping entirely and only map the generated position. If so, pass ' +
  6371. 'null for the original mapping instead of an object with empty or null values.'
  6372. );
  6373. }
  6374. if (aGenerated && 'line' in aGenerated && 'column' in aGenerated
  6375. && aGenerated.line > 0 && aGenerated.column >= 0
  6376. && !aOriginal && !aSource && !aName) {
  6377. // Case 1.
  6378. return;
  6379. }
  6380. else if (aGenerated && 'line' in aGenerated && 'column' in aGenerated
  6381. && aOriginal && 'line' in aOriginal && 'column' in aOriginal
  6382. && aGenerated.line > 0 && aGenerated.column >= 0
  6383. && aOriginal.line > 0 && aOriginal.column >= 0
  6384. && aSource) {
  6385. // Cases 2 and 3.
  6386. return;
  6387. }
  6388. else {
  6389. throw new Error('Invalid mapping: ' + JSON.stringify({
  6390. generated: aGenerated,
  6391. source: aSource,
  6392. original: aOriginal,
  6393. name: aName
  6394. }));
  6395. }
  6396. };
  6397. /**
  6398. * Serialize the accumulated mappings in to the stream of base 64 VLQs
  6399. * specified by the source map format.
  6400. */
  6401. SourceMapGenerator.prototype._serializeMappings =
  6402. function SourceMapGenerator_serializeMappings() {
  6403. var previousGeneratedColumn = 0;
  6404. var previousGeneratedLine = 1;
  6405. var previousOriginalColumn = 0;
  6406. var previousOriginalLine = 0;
  6407. var previousName = 0;
  6408. var previousSource = 0;
  6409. var result = '';
  6410. var next;
  6411. var mapping;
  6412. var nameIdx;
  6413. var sourceIdx;
  6414. var mappings = this._mappings.toArray();
  6415. for (var i = 0, len = mappings.length; i < len; i++) {
  6416. mapping = mappings[i];
  6417. next = '';
  6418. if (mapping.generatedLine !== previousGeneratedLine) {
  6419. previousGeneratedColumn = 0;
  6420. while (mapping.generatedLine !== previousGeneratedLine) {
  6421. next += ';';
  6422. previousGeneratedLine++;
  6423. }
  6424. }
  6425. else {
  6426. if (i > 0) {
  6427. if (!util.compareByGeneratedPositionsInflated(mapping, mappings[i - 1])) {
  6428. continue;
  6429. }
  6430. next += ',';
  6431. }
  6432. }
  6433. next += base64Vlq.encode(mapping.generatedColumn
  6434. - previousGeneratedColumn);
  6435. previousGeneratedColumn = mapping.generatedColumn;
  6436. if (mapping.source != null) {
  6437. sourceIdx = this._sources.indexOf(mapping.source);
  6438. next += base64Vlq.encode(sourceIdx - previousSource);
  6439. previousSource = sourceIdx;
  6440. // lines are stored 0-based in SourceMap spec version 3
  6441. next += base64Vlq.encode(mapping.originalLine - 1
  6442. - previousOriginalLine);
  6443. previousOriginalLine = mapping.originalLine - 1;
  6444. next += base64Vlq.encode(mapping.originalColumn
  6445. - previousOriginalColumn);
  6446. previousOriginalColumn = mapping.originalColumn;
  6447. if (mapping.name != null) {
  6448. nameIdx = this._names.indexOf(mapping.name);
  6449. next += base64Vlq.encode(nameIdx - previousName);
  6450. previousName = nameIdx;
  6451. }
  6452. }
  6453. result += next;
  6454. }
  6455. return result;
  6456. };
  6457. SourceMapGenerator.prototype._generateSourcesContent =
  6458. function SourceMapGenerator_generateSourcesContent(aSources, aSourceRoot) {
  6459. return aSources.map(function (source) {
  6460. if (!this._sourcesContents) {
  6461. return null;
  6462. }
  6463. if (aSourceRoot != null) {
  6464. source = util.relative(aSourceRoot, source);
  6465. }
  6466. var key = util.toSetString(source);
  6467. return Object.prototype.hasOwnProperty.call(this._sourcesContents, key)
  6468. ? this._sourcesContents[key]
  6469. : null;
  6470. }, this);
  6471. };
  6472. /**
  6473. * Externalize the source map.
  6474. */
  6475. SourceMapGenerator.prototype.toJSON =
  6476. function SourceMapGenerator_toJSON() {
  6477. var map = {
  6478. version: this._version,
  6479. sources: this._sources.toArray(),
  6480. names: this._names.toArray(),
  6481. mappings: this._serializeMappings()
  6482. };
  6483. if (this._file != null) {
  6484. map.file = this._file;
  6485. }
  6486. if (this._sourceRoot != null) {
  6487. map.sourceRoot = this._sourceRoot;
  6488. }
  6489. if (this._sourcesContents) {
  6490. map.sourcesContent = this._generateSourcesContent(map.sources, map.sourceRoot);
  6491. }
  6492. return map;
  6493. };
  6494. /**
  6495. * Render the source map being generated to a string.
  6496. */
  6497. SourceMapGenerator.prototype.toString =
  6498. function SourceMapGenerator_toString() {
  6499. return JSON.stringify(this.toJSON());
  6500. };
  6501. var SourceMapGenerator_1 = SourceMapGenerator;
  6502. var sourceMapGenerator = {
  6503. SourceMapGenerator: SourceMapGenerator_1
  6504. };
  6505. var SourceMapGenerator$1 = sourceMapGenerator.SourceMapGenerator;
  6506. var trackNodes = {
  6507. Atrule: true,
  6508. Selector: true,
  6509. Declaration: true
  6510. };
  6511. var sourceMap = function generateSourceMap(handlers) {
  6512. var map = new SourceMapGenerator$1();
  6513. var line = 1;
  6514. var column = 0;
  6515. var generated = {
  6516. line: 1,
  6517. column: 0
  6518. };
  6519. var original = {
  6520. line: 0, // should be zero to add first mapping
  6521. column: 0
  6522. };
  6523. var sourceMappingActive = false;
  6524. var activatedGenerated = {
  6525. line: 1,
  6526. column: 0
  6527. };
  6528. var activatedMapping = {
  6529. generated: activatedGenerated
  6530. };
  6531. var handlersNode = handlers.node;
  6532. handlers.node = function(node) {
  6533. if (node.loc && node.loc.start && trackNodes.hasOwnProperty(node.type)) {
  6534. var nodeLine = node.loc.start.line;
  6535. var nodeColumn = node.loc.start.column - 1;
  6536. if (original.line !== nodeLine ||
  6537. original.column !== nodeColumn) {
  6538. original.line = nodeLine;
  6539. original.column = nodeColumn;
  6540. generated.line = line;
  6541. generated.column = column;
  6542. if (sourceMappingActive) {
  6543. sourceMappingActive = false;
  6544. if (generated.line !== activatedGenerated.line ||
  6545. generated.column !== activatedGenerated.column) {
  6546. map.addMapping(activatedMapping);
  6547. }
  6548. }
  6549. sourceMappingActive = true;
  6550. map.addMapping({
  6551. source: node.loc.source,
  6552. original: original,
  6553. generated: generated
  6554. });
  6555. }
  6556. }
  6557. handlersNode.call(this, node);
  6558. if (sourceMappingActive && trackNodes.hasOwnProperty(node.type)) {
  6559. activatedGenerated.line = line;
  6560. activatedGenerated.column = column;
  6561. }
  6562. };
  6563. var handlersChunk = handlers.chunk;
  6564. handlers.chunk = function(chunk) {
  6565. for (var i = 0; i < chunk.length; i++) {
  6566. if (chunk.charCodeAt(i) === 10) { // \n
  6567. line++;
  6568. column = 0;
  6569. } else {
  6570. column++;
  6571. }
  6572. }
  6573. handlersChunk(chunk);
  6574. };
  6575. var handlersResult = handlers.result;
  6576. handlers.result = function() {
  6577. if (sourceMappingActive) {
  6578. map.addMapping(activatedMapping);
  6579. }
  6580. return {
  6581. css: handlersResult(),
  6582. map: map
  6583. };
  6584. };
  6585. return handlers;
  6586. };
  6587. var hasOwnProperty$3 = Object.prototype.hasOwnProperty;
  6588. function processChildren(node, delimeter) {
  6589. var list = node.children;
  6590. var prev = null;
  6591. if (typeof delimeter !== 'function') {
  6592. list.forEach(this.node, this);
  6593. } else {
  6594. list.forEach(function(node) {
  6595. if (prev !== null) {
  6596. delimeter.call(this, prev);
  6597. }
  6598. this.node(node);
  6599. prev = node;
  6600. }, this);
  6601. }
  6602. }
  6603. var create$1 = function createGenerator(config) {
  6604. function processNode(node) {
  6605. if (hasOwnProperty$3.call(types, node.type)) {
  6606. types[node.type].call(this, node);
  6607. } else {
  6608. throw new Error('Unknown node type: ' + node.type);
  6609. }
  6610. }
  6611. var types = {};
  6612. if (config.node) {
  6613. for (var name in config.node) {
  6614. types[name] = config.node[name].generate;
  6615. }
  6616. }
  6617. return function(node, options) {
  6618. var buffer = '';
  6619. var handlers = {
  6620. children: processChildren,
  6621. node: processNode,
  6622. chunk: function(chunk) {
  6623. buffer += chunk;
  6624. },
  6625. result: function() {
  6626. return buffer;
  6627. }
  6628. };
  6629. if (options) {
  6630. if (typeof options.decorator === 'function') {
  6631. handlers = options.decorator(handlers);
  6632. }
  6633. if (options.sourceMap) {
  6634. handlers = sourceMap(handlers);
  6635. }
  6636. }
  6637. handlers.node(node);
  6638. return handlers.result();
  6639. };
  6640. };
  6641. var create$2 = function createConvertors(walk) {
  6642. return {
  6643. fromPlainObject: function(ast) {
  6644. walk(ast, {
  6645. enter: function(node) {
  6646. if (node.children && node.children instanceof List_1 === false) {
  6647. node.children = new List_1().fromArray(node.children);
  6648. }
  6649. }
  6650. });
  6651. return ast;
  6652. },
  6653. toPlainObject: function(ast) {
  6654. walk(ast, {
  6655. leave: function(node) {
  6656. if (node.children && node.children instanceof List_1) {
  6657. node.children = node.children.toArray();
  6658. }
  6659. }
  6660. });
  6661. return ast;
  6662. }
  6663. };
  6664. };
  6665. var hasOwnProperty$4 = Object.prototype.hasOwnProperty;
  6666. var noop$3 = function() {};
  6667. function ensureFunction$1(value) {
  6668. return typeof value === 'function' ? value : noop$3;
  6669. }
  6670. function invokeForType(fn, type) {
  6671. return function(node, item, list) {
  6672. if (node.type === type) {
  6673. fn.call(this, node, item, list);
  6674. }
  6675. };
  6676. }
  6677. function getWalkersFromStructure(name, nodeType) {
  6678. var structure = nodeType.structure;
  6679. var walkers = [];
  6680. for (var key in structure) {
  6681. if (hasOwnProperty$4.call(structure, key) === false) {
  6682. continue;
  6683. }
  6684. var fieldTypes = structure[key];
  6685. var walker = {
  6686. name: key,
  6687. type: false,
  6688. nullable: false
  6689. };
  6690. if (!Array.isArray(structure[key])) {
  6691. fieldTypes = [structure[key]];
  6692. }
  6693. for (var i = 0; i < fieldTypes.length; i++) {
  6694. var fieldType = fieldTypes[i];
  6695. if (fieldType === null) {
  6696. walker.nullable = true;
  6697. } else if (typeof fieldType === 'string') {
  6698. walker.type = 'node';
  6699. } else if (Array.isArray(fieldType)) {
  6700. walker.type = 'list';
  6701. }
  6702. }
  6703. if (walker.type) {
  6704. walkers.push(walker);
  6705. }
  6706. }
  6707. if (walkers.length) {
  6708. return {
  6709. context: nodeType.walkContext,
  6710. fields: walkers
  6711. };
  6712. }
  6713. return null;
  6714. }
  6715. function getTypesFromConfig(config) {
  6716. var types = {};
  6717. for (var name in config.node) {
  6718. if (hasOwnProperty$4.call(config.node, name)) {
  6719. var nodeType = config.node[name];
  6720. if (!nodeType.structure) {
  6721. throw new Error('Missed `structure` field in `' + name + '` node type definition');
  6722. }
  6723. types[name] = getWalkersFromStructure(name, nodeType);
  6724. }
  6725. }
  6726. return types;
  6727. }
  6728. function createTypeIterator(config, reverse) {
  6729. var fields = config.fields.slice();
  6730. var contextName = config.context;
  6731. var useContext = typeof contextName === 'string';
  6732. if (reverse) {
  6733. fields.reverse();
  6734. }
  6735. return function(node, context, walk, walkReducer) {
  6736. var prevContextValue;
  6737. if (useContext) {
  6738. prevContextValue = context[contextName];
  6739. context[contextName] = node;
  6740. }
  6741. for (var i = 0; i < fields.length; i++) {
  6742. var field = fields[i];
  6743. var ref = node[field.name];
  6744. if (!field.nullable || ref) {
  6745. if (field.type === 'list') {
  6746. var breakWalk = reverse
  6747. ? ref.reduceRight(walkReducer, false)
  6748. : ref.reduce(walkReducer, false);
  6749. if (breakWalk) {
  6750. return true;
  6751. }
  6752. } else if (walk(ref)) {
  6753. return true;
  6754. }
  6755. }
  6756. }
  6757. if (useContext) {
  6758. context[contextName] = prevContextValue;
  6759. }
  6760. };
  6761. }
  6762. function createFastTraveralMap(iterators) {
  6763. return {
  6764. Atrule: {
  6765. StyleSheet: iterators.StyleSheet,
  6766. Atrule: iterators.Atrule,
  6767. Rule: iterators.Rule,
  6768. Block: iterators.Block
  6769. },
  6770. Rule: {
  6771. StyleSheet: iterators.StyleSheet,
  6772. Atrule: iterators.Atrule,
  6773. Rule: iterators.Rule,
  6774. Block: iterators.Block
  6775. },
  6776. Declaration: {
  6777. StyleSheet: iterators.StyleSheet,
  6778. Atrule: iterators.Atrule,
  6779. Rule: iterators.Rule,
  6780. Block: iterators.Block,
  6781. DeclarationList: iterators.DeclarationList
  6782. }
  6783. };
  6784. }
  6785. var create$3 = function createWalker(config) {
  6786. var types = getTypesFromConfig(config);
  6787. var iteratorsNatural = {};
  6788. var iteratorsReverse = {};
  6789. var breakWalk = Symbol('break-walk');
  6790. var skipNode = Symbol('skip-node');
  6791. for (var name in types) {
  6792. if (hasOwnProperty$4.call(types, name) && types[name] !== null) {
  6793. iteratorsNatural[name] = createTypeIterator(types[name], false);
  6794. iteratorsReverse[name] = createTypeIterator(types[name], true);
  6795. }
  6796. }
  6797. var fastTraversalIteratorsNatural = createFastTraveralMap(iteratorsNatural);
  6798. var fastTraversalIteratorsReverse = createFastTraveralMap(iteratorsReverse);
  6799. var walk = function(root, options) {
  6800. function walkNode(node, item, list) {
  6801. var enterRet = enter.call(context, node, item, list);
  6802. if (enterRet === breakWalk) {
  6803. debugger;
  6804. return true;
  6805. }
  6806. if (enterRet === skipNode) {
  6807. return false;
  6808. }
  6809. if (iterators.hasOwnProperty(node.type)) {
  6810. if (iterators[node.type](node, context, walkNode, walkReducer)) {
  6811. return true;
  6812. }
  6813. }
  6814. if (leave.call(context, node, item, list) === breakWalk) {
  6815. return true;
  6816. }
  6817. return false;
  6818. }
  6819. var walkReducer = (ret, data, item, list) => ret || walkNode(data, item, list);
  6820. var enter = noop$3;
  6821. var leave = noop$3;
  6822. var iterators = iteratorsNatural;
  6823. var context = {
  6824. break: breakWalk,
  6825. skip: skipNode,
  6826. root: root,
  6827. stylesheet: null,
  6828. atrule: null,
  6829. atrulePrelude: null,
  6830. rule: null,
  6831. selector: null,
  6832. block: null,
  6833. declaration: null,
  6834. function: null
  6835. };
  6836. if (typeof options === 'function') {
  6837. enter = options;
  6838. } else if (options) {
  6839. enter = ensureFunction$1(options.enter);
  6840. leave = ensureFunction$1(options.leave);
  6841. if (options.reverse) {
  6842. iterators = iteratorsReverse;
  6843. }
  6844. if (options.visit) {
  6845. if (fastTraversalIteratorsNatural.hasOwnProperty(options.visit)) {
  6846. iterators = options.reverse
  6847. ? fastTraversalIteratorsReverse[options.visit]
  6848. : fastTraversalIteratorsNatural[options.visit];
  6849. } else if (!types.hasOwnProperty(options.visit)) {
  6850. throw new Error('Bad value `' + options.visit + '` for `visit` option (should be: ' + Object.keys(types).join(', ') + ')');
  6851. }
  6852. enter = invokeForType(enter, options.visit);
  6853. leave = invokeForType(leave, options.visit);
  6854. }
  6855. }
  6856. if (enter === noop$3 && leave === noop$3) {
  6857. throw new Error('Neither `enter` nor `leave` walker handler is set or both aren\'t a function');
  6858. }
  6859. walkNode(root);
  6860. };
  6861. walk.break = breakWalk;
  6862. walk.skip = skipNode;
  6863. walk.find = function(ast, fn) {
  6864. var found = null;
  6865. walk(ast, function(node, item, list) {
  6866. if (fn.call(this, node, item, list)) {
  6867. found = node;
  6868. return breakWalk;
  6869. }
  6870. });
  6871. return found;
  6872. };
  6873. walk.findLast = function(ast, fn) {
  6874. var found = null;
  6875. walk(ast, {
  6876. reverse: true,
  6877. enter: function(node, item, list) {
  6878. if (fn.call(this, node, item, list)) {
  6879. found = node;
  6880. return breakWalk;
  6881. }
  6882. }
  6883. });
  6884. return found;
  6885. };
  6886. walk.findAll = function(ast, fn) {
  6887. var found = [];
  6888. walk(ast, function(node, item, list) {
  6889. if (fn.call(this, node, item, list)) {
  6890. found.push(node);
  6891. }
  6892. });
  6893. return found;
  6894. };
  6895. return walk;
  6896. };
  6897. var clone = function clone(node) {
  6898. var result = {};
  6899. for (var key in node) {
  6900. var value = node[key];
  6901. if (value) {
  6902. if (Array.isArray(value) || value instanceof List_1) {
  6903. value = value.map(clone);
  6904. } else if (value.constructor === Object) {
  6905. value = clone(value);
  6906. }
  6907. }
  6908. result[key] = value;
  6909. }
  6910. return result;
  6911. };
  6912. const hasOwnProperty$5 = Object.prototype.hasOwnProperty;
  6913. const shape = {
  6914. generic: true,
  6915. types: appendOrAssign,
  6916. atrules: {
  6917. prelude: appendOrAssignOrNull,
  6918. descriptors: appendOrAssignOrNull
  6919. },
  6920. properties: appendOrAssign,
  6921. parseContext: assign,
  6922. scope: deepAssign,
  6923. atrule: ['parse'],
  6924. pseudo: ['parse'],
  6925. node: ['name', 'structure', 'parse', 'generate', 'walkContext']
  6926. };
  6927. function isObject(value) {
  6928. return value && value.constructor === Object;
  6929. }
  6930. function copy(value) {
  6931. return isObject(value)
  6932. ? Object.assign({}, value)
  6933. : value;
  6934. }
  6935. function assign(dest, src) {
  6936. return Object.assign(dest, src);
  6937. }
  6938. function deepAssign(dest, src) {
  6939. for (const key in src) {
  6940. if (hasOwnProperty$5.call(src, key)) {
  6941. if (isObject(dest[key])) {
  6942. deepAssign(dest[key], copy(src[key]));
  6943. } else {
  6944. dest[key] = copy(src[key]);
  6945. }
  6946. }
  6947. }
  6948. return dest;
  6949. }
  6950. function append(a, b) {
  6951. if (typeof b === 'string' && /^\s*\|/.test(b)) {
  6952. return typeof a === 'string'
  6953. ? a + b
  6954. : b.replace(/^\s*\|\s*/, '');
  6955. }
  6956. return b || null;
  6957. }
  6958. function appendOrAssign(a, b) {
  6959. if (typeof b === 'string') {
  6960. return append(a, b);
  6961. }
  6962. const result = Object.assign({}, a);
  6963. for (let key in b) {
  6964. if (hasOwnProperty$5.call(b, key)) {
  6965. result[key] = append(hasOwnProperty$5.call(a, key) ? a[key] : undefined, b[key]);
  6966. }
  6967. }
  6968. return result;
  6969. }
  6970. function appendOrAssignOrNull(a, b) {
  6971. const result = appendOrAssign(a, b);
  6972. return !isObject(result) || Object.keys(result).length
  6973. ? result
  6974. : null;
  6975. }
  6976. function mix(dest, src, shape) {
  6977. for (const key in shape) {
  6978. if (hasOwnProperty$5.call(shape, key) === false) {
  6979. continue;
  6980. }
  6981. if (shape[key] === true) {
  6982. if (key in src) {
  6983. if (hasOwnProperty$5.call(src, key)) {
  6984. dest[key] = copy(src[key]);
  6985. }
  6986. }
  6987. } else if (shape[key]) {
  6988. if (typeof shape[key] === 'function') {
  6989. const fn = shape[key];
  6990. dest[key] = fn({}, dest[key]);
  6991. dest[key] = fn(dest[key] || {}, src[key]);
  6992. } else if (isObject(shape[key])) {
  6993. const result = {};
  6994. for (let name in dest[key]) {
  6995. result[name] = mix({}, dest[key][name], shape[key]);
  6996. }
  6997. for (let name in src[key]) {
  6998. result[name] = mix(result[name] || {}, src[key][name], shape[key]);
  6999. }
  7000. dest[key] = result;
  7001. } else if (Array.isArray(shape[key])) {
  7002. const res = {};
  7003. const innerShape = shape[key].reduce(function(s, k) {
  7004. s[k] = true;
  7005. return s;
  7006. }, {});
  7007. for (const [name, value] of Object.entries(dest[key] || {})) {
  7008. res[name] = {};
  7009. if (value) {
  7010. mix(res[name], value, innerShape);
  7011. }
  7012. }
  7013. for (const name in src[key]) {
  7014. if (hasOwnProperty$5.call(src[key], name)) {
  7015. if (!res[name]) {
  7016. res[name] = {};
  7017. }
  7018. if (src[key] && src[key][name]) {
  7019. mix(res[name], src[key][name], innerShape);
  7020. }
  7021. }
  7022. }
  7023. dest[key] = res;
  7024. }
  7025. }
  7026. }
  7027. return dest;
  7028. }
  7029. var mix_1 = (dest, src) => mix(dest, src, shape);
  7030. function createSyntax(config) {
  7031. var parse = create(config);
  7032. var walk = create$3(config);
  7033. var generate = create$1(config);
  7034. var convert = create$2(walk);
  7035. var syntax = {
  7036. List: List_1,
  7037. SyntaxError: _SyntaxError,
  7038. TokenStream: TokenStream_1,
  7039. Lexer: Lexer_1,
  7040. vendorPrefix: names.vendorPrefix,
  7041. keyword: names.keyword,
  7042. property: names.property,
  7043. isCustomProperty: names.isCustomProperty,
  7044. definitionSyntax: definitionSyntax,
  7045. lexer: null,
  7046. createLexer: function(config) {
  7047. return new Lexer_1(config, syntax, syntax.lexer.structure);
  7048. },
  7049. tokenize: tokenizer,
  7050. parse: parse,
  7051. walk: walk,
  7052. generate: generate,
  7053. find: walk.find,
  7054. findLast: walk.findLast,
  7055. findAll: walk.findAll,
  7056. clone: clone,
  7057. fromPlainObject: convert.fromPlainObject,
  7058. toPlainObject: convert.toPlainObject,
  7059. createSyntax: function(config) {
  7060. return createSyntax(mix_1({}, config));
  7061. },
  7062. fork: function(extension) {
  7063. var base = mix_1({}, config); // copy of config
  7064. return createSyntax(
  7065. typeof extension === 'function'
  7066. ? extension(base, Object.assign)
  7067. : mix_1(base, extension)
  7068. );
  7069. }
  7070. };
  7071. syntax.lexer = new Lexer_1({
  7072. generic: true,
  7073. types: config.types,
  7074. atrules: config.atrules,
  7075. properties: config.properties,
  7076. node: config.node
  7077. }, syntax);
  7078. return syntax;
  7079. }
  7080. var create_1 = function(config) {
  7081. return createSyntax(mix_1({}, config));
  7082. };
  7083. var create$4 = {
  7084. create: create_1
  7085. };
  7086. var data = {
  7087. "generic": true,
  7088. "types": {
  7089. "absolute-size": "xx-small|x-small|small|medium|large|x-large|xx-large|xxx-large",
  7090. "alpha-value": "<number>|<percentage>",
  7091. "angle-percentage": "<angle>|<percentage>",
  7092. "angular-color-hint": "<angle-percentage>",
  7093. "angular-color-stop": "<color>&&<color-stop-angle>?",
  7094. "angular-color-stop-list": "[<angular-color-stop> [, <angular-color-hint>]?]# , <angular-color-stop>",
  7095. "animateable-feature": "scroll-position|contents|<custom-ident>",
  7096. "attachment": "scroll|fixed|local",
  7097. "attr()": "attr( <attr-name> <type-or-unit>? [, <attr-fallback>]? )",
  7098. "attr-matcher": "['~'|'|'|'^'|'$'|'*']? '='",
  7099. "attr-modifier": "i|s",
  7100. "attribute-selector": "'[' <wq-name> ']'|'[' <wq-name> <attr-matcher> [<string-token>|<ident-token>] <attr-modifier>? ']'",
  7101. "auto-repeat": "repeat( [auto-fill|auto-fit] , [<line-names>? <fixed-size>]+ <line-names>? )",
  7102. "auto-track-list": "[<line-names>? [<fixed-size>|<fixed-repeat>]]* <line-names>? <auto-repeat> [<line-names>? [<fixed-size>|<fixed-repeat>]]* <line-names>?",
  7103. "baseline-position": "[first|last]? baseline",
  7104. "basic-shape": "<inset()>|<circle()>|<ellipse()>|<polygon()>|<path()>",
  7105. "bg-image": "none|<image>",
  7106. "bg-layer": "<bg-image>||<bg-position> [/ <bg-size>]?||<repeat-style>||<attachment>||<box>||<box>",
  7107. "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>?]]",
  7108. "bg-size": "[<length-percentage>|auto]{1,2}|cover|contain",
  7109. "blur()": "blur( <length> )",
  7110. "blend-mode": "normal|multiply|screen|overlay|darken|lighten|color-dodge|color-burn|hard-light|soft-light|difference|exclusion|hue|saturation|color|luminosity",
  7111. "box": "border-box|padding-box|content-box",
  7112. "brightness()": "brightness( <number-percentage> )",
  7113. "calc()": "calc( <calc-sum> )",
  7114. "calc-sum": "<calc-product> [['+'|'-'] <calc-product>]*",
  7115. "calc-product": "<calc-value> ['*' <calc-value>|'/' <number>]*",
  7116. "calc-value": "<number>|<dimension>|<percentage>|( <calc-sum> )",
  7117. "cf-final-image": "<image>|<color>",
  7118. "cf-mixing-image": "<percentage>?&&<image>",
  7119. "circle()": "circle( [<shape-radius>]? [at <position>]? )",
  7120. "clamp()": "clamp( <calc-sum>#{3} )",
  7121. "class-selector": "'.' <ident-token>",
  7122. "clip-source": "<url>",
  7123. "color": "<rgb()>|<rgba()>|<hsl()>|<hsla()>|<hex-color>|<named-color>|currentcolor|<deprecated-system-color>",
  7124. "color-stop": "<color-stop-length>|<color-stop-angle>",
  7125. "color-stop-angle": "<angle-percentage>{1,2}",
  7126. "color-stop-length": "<length-percentage>{1,2}",
  7127. "color-stop-list": "[<linear-color-stop> [, <linear-color-hint>]?]# , <linear-color-stop>",
  7128. "combinator": "'>'|'+'|'~'|['||']",
  7129. "common-lig-values": "[common-ligatures|no-common-ligatures]",
  7130. "compat-auto": "searchfield|textarea|push-button|slider-horizontal|checkbox|radio|square-button|menulist|listbox|meter|progress-bar|button",
  7131. "composite-style": "clear|copy|source-over|source-in|source-out|source-atop|destination-over|destination-in|destination-out|destination-atop|xor",
  7132. "compositing-operator": "add|subtract|intersect|exclude",
  7133. "compound-selector": "[<type-selector>? <subclass-selector>* [<pseudo-element-selector> <pseudo-class-selector>*]*]!",
  7134. "compound-selector-list": "<compound-selector>#",
  7135. "complex-selector": "<compound-selector> [<combinator>? <compound-selector>]*",
  7136. "complex-selector-list": "<complex-selector>#",
  7137. "conic-gradient()": "conic-gradient( [from <angle>]? [at <position>]? , <angular-color-stop-list> )",
  7138. "contextual-alt-values": "[contextual|no-contextual]",
  7139. "content-distribution": "space-between|space-around|space-evenly|stretch",
  7140. "content-list": "[<string>|contents|<image>|<quote>|<target>|<leader()>|<attr()>|counter( <ident> , <'list-style-type'>? )]+",
  7141. "content-position": "center|start|end|flex-start|flex-end",
  7142. "content-replacement": "<image>",
  7143. "contrast()": "contrast( [<number-percentage>] )",
  7144. "counter()": "counter( <custom-ident> , <counter-style>? )",
  7145. "counter-style": "<counter-style-name>|symbols( )",
  7146. "counter-style-name": "<custom-ident>",
  7147. "counters()": "counters( <custom-ident> , <string> , <counter-style>? )",
  7148. "cross-fade()": "cross-fade( <cf-mixing-image> , <cf-final-image>? )",
  7149. "cubic-bezier-timing-function": "ease|ease-in|ease-out|ease-in-out|cubic-bezier( <number [0,1]> , <number> , <number [0,1]> , <number> )",
  7150. "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",
  7151. "discretionary-lig-values": "[discretionary-ligatures|no-discretionary-ligatures]",
  7152. "display-box": "contents|none",
  7153. "display-inside": "flow|flow-root|table|flex|grid|ruby",
  7154. "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",
  7155. "display-legacy": "inline-block|inline-list-item|inline-table|inline-flex|inline-grid",
  7156. "display-listitem": "<display-outside>?&&[flow|flow-root]?&&list-item",
  7157. "display-outside": "block|inline|run-in",
  7158. "drop-shadow()": "drop-shadow( <length>{2,3} <color>? )",
  7159. "east-asian-variant-values": "[jis78|jis83|jis90|jis04|simplified|traditional]",
  7160. "east-asian-width-values": "[full-width|proportional-width]",
  7161. "element()": "element( <custom-ident> , [first|start|last|first-except]? )|element( <id-selector> )",
  7162. "ellipse()": "ellipse( [<shape-radius>{2}]? [at <position>]? )",
  7163. "ending-shape": "circle|ellipse",
  7164. "env()": "env( <custom-ident> , <declaration-value>? )",
  7165. "explicit-track-list": "[<line-names>? <track-size>]+ <line-names>?",
  7166. "family-name": "<string>|<custom-ident>+",
  7167. "feature-tag-value": "<string> [<integer>|on|off]?",
  7168. "feature-type": "@stylistic|@historical-forms|@styleset|@character-variant|@swash|@ornaments|@annotation",
  7169. "feature-value-block": "<feature-type> '{' <feature-value-declaration-list> '}'",
  7170. "feature-value-block-list": "<feature-value-block>+",
  7171. "feature-value-declaration": "<custom-ident> : <integer>+ ;",
  7172. "feature-value-declaration-list": "<feature-value-declaration>",
  7173. "feature-value-name": "<custom-ident>",
  7174. "fill-rule": "nonzero|evenodd",
  7175. "filter-function": "<blur()>|<brightness()>|<contrast()>|<drop-shadow()>|<grayscale()>|<hue-rotate()>|<invert()>|<opacity()>|<saturate()>|<sepia()>",
  7176. "filter-function-list": "[<filter-function>|<url>]+",
  7177. "final-bg-layer": "<'background-color'>||<bg-image>||<bg-position> [/ <bg-size>]?||<repeat-style>||<attachment>||<box>||<box>",
  7178. "fit-content()": "fit-content( [<length>|<percentage>] )",
  7179. "fixed-breadth": "<length-percentage>",
  7180. "fixed-repeat": "repeat( [<positive-integer>] , [<line-names>? <fixed-size>]+ <line-names>? )",
  7181. "fixed-size": "<fixed-breadth>|minmax( <fixed-breadth> , <track-breadth> )|minmax( <inflexible-breadth> , <fixed-breadth> )",
  7182. "font-stretch-absolute": "normal|ultra-condensed|extra-condensed|condensed|semi-condensed|semi-expanded|expanded|extra-expanded|ultra-expanded|<percentage>",
  7183. "font-variant-css21": "[normal|small-caps]",
  7184. "font-weight-absolute": "normal|bold|<number [1,1000]>",
  7185. "frequency-percentage": "<frequency>|<percentage>",
  7186. "general-enclosed": "[<function-token> <any-value> )]|( <ident> <any-value> )",
  7187. "generic-family": "serif|sans-serif|cursive|fantasy|monospace|-apple-system",
  7188. "generic-name": "serif|sans-serif|cursive|fantasy|monospace",
  7189. "geometry-box": "<shape-box>|fill-box|stroke-box|view-box",
  7190. "gradient": "<linear-gradient()>|<repeating-linear-gradient()>|<radial-gradient()>|<repeating-radial-gradient()>|<conic-gradient()>|<-legacy-gradient>",
  7191. "grayscale()": "grayscale( <number-percentage> )",
  7192. "grid-line": "auto|<custom-ident>|[<integer>&&<custom-ident>?]|[span&&[<integer>||<custom-ident>]]",
  7193. "historical-lig-values": "[historical-ligatures|no-historical-ligatures]",
  7194. "hsl()": "hsl( <hue> <percentage> <percentage> [/ <alpha-value>]? )|hsl( <hue> , <percentage> , <percentage> , <alpha-value>? )",
  7195. "hsla()": "hsla( <hue> <percentage> <percentage> [/ <alpha-value>]? )|hsla( <hue> , <percentage> , <percentage> , <alpha-value>? )",
  7196. "hue": "<number>|<angle>",
  7197. "hue-rotate()": "hue-rotate( <angle> )",
  7198. "image": "<url>|<image()>|<image-set()>|<element()>|<paint()>|<cross-fade()>|<gradient>",
  7199. "image()": "image( <image-tags>? [<image-src>? , <color>?]! )",
  7200. "image-set()": "image-set( <image-set-option># )",
  7201. "image-set-option": "[<image>|<string>] <resolution>",
  7202. "image-src": "<url>|<string>",
  7203. "image-tags": "ltr|rtl",
  7204. "inflexible-breadth": "<length>|<percentage>|min-content|max-content|auto",
  7205. "inset()": "inset( <length-percentage>{1,4} [round <'border-radius'>]? )",
  7206. "invert()": "invert( <number-percentage> )",
  7207. "keyframes-name": "<custom-ident>|<string>",
  7208. "keyframe-block": "<keyframe-selector># { <declaration-list> }",
  7209. "keyframe-block-list": "<keyframe-block>+",
  7210. "keyframe-selector": "from|to|<percentage>",
  7211. "leader()": "leader( <leader-type> )",
  7212. "leader-type": "dotted|solid|space|<string>",
  7213. "length-percentage": "<length>|<percentage>",
  7214. "line-names": "'[' <custom-ident>* ']'",
  7215. "line-name-list": "[<line-names>|<name-repeat>]+",
  7216. "line-style": "none|hidden|dotted|dashed|solid|double|groove|ridge|inset|outset",
  7217. "line-width": "<length>|thin|medium|thick",
  7218. "linear-color-hint": "<length-percentage>",
  7219. "linear-color-stop": "<color> <color-stop-length>?",
  7220. "linear-gradient()": "linear-gradient( [<angle>|to <side-or-corner>]? , <color-stop-list> )",
  7221. "mask-layer": "<mask-reference>||<position> [/ <bg-size>]?||<repeat-style>||<geometry-box>||[<geometry-box>|no-clip]||<compositing-operator>||<masking-mode>",
  7222. "mask-position": "[<length-percentage>|left|center|right] [<length-percentage>|top|center|bottom]?",
  7223. "mask-reference": "none|<image>|<mask-source>",
  7224. "mask-source": "<url>",
  7225. "masking-mode": "alpha|luminance|match-source",
  7226. "matrix()": "matrix( <number>#{6} )",
  7227. "matrix3d()": "matrix3d( <number>#{16} )",
  7228. "max()": "max( <calc-sum># )",
  7229. "media-and": "<media-in-parens> [and <media-in-parens>]+",
  7230. "media-condition": "<media-not>|<media-and>|<media-or>|<media-in-parens>",
  7231. "media-condition-without-or": "<media-not>|<media-and>|<media-in-parens>",
  7232. "media-feature": "( [<mf-plain>|<mf-boolean>|<mf-range>] )",
  7233. "media-in-parens": "( <media-condition> )|<media-feature>|<general-enclosed>",
  7234. "media-not": "not <media-in-parens>",
  7235. "media-or": "<media-in-parens> [or <media-in-parens>]+",
  7236. "media-query": "<media-condition>|[not|only]? <media-type> [and <media-condition-without-or>]?",
  7237. "media-query-list": "<media-query>#",
  7238. "media-type": "<ident>",
  7239. "mf-boolean": "<mf-name>",
  7240. "mf-name": "<ident>",
  7241. "mf-plain": "<mf-name> : <mf-value>",
  7242. "mf-range": "<mf-name> ['<'|'>']? '='? <mf-value>|<mf-value> ['<'|'>']? '='? <mf-name>|<mf-value> '<' '='? <mf-name> '<' '='? <mf-value>|<mf-value> '>' '='? <mf-name> '>' '='? <mf-value>",
  7243. "mf-value": "<number>|<dimension>|<ident>|<ratio>",
  7244. "min()": "min( <calc-sum># )",
  7245. "minmax()": "minmax( [<length>|<percentage>|min-content|max-content|auto] , [<length>|<percentage>|<flex>|min-content|max-content|auto] )",
  7246. "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>",
  7247. "namespace-prefix": "<ident>",
  7248. "ns-prefix": "[<ident-token>|'*']? '|'",
  7249. "number-percentage": "<number>|<percentage>",
  7250. "numeric-figure-values": "[lining-nums|oldstyle-nums]",
  7251. "numeric-fraction-values": "[diagonal-fractions|stacked-fractions]",
  7252. "numeric-spacing-values": "[proportional-nums|tabular-nums]",
  7253. "nth": "<an-plus-b>|even|odd",
  7254. "opacity()": "opacity( [<number-percentage>] )",
  7255. "overflow-position": "unsafe|safe",
  7256. "outline-radius": "<length>|<percentage>",
  7257. "page-body": "<declaration>? [; <page-body>]?|<page-margin-box> <page-body>",
  7258. "page-margin-box": "<page-margin-box-type> '{' <declaration-list> '}'",
  7259. "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",
  7260. "page-selector-list": "[<page-selector>#]?",
  7261. "page-selector": "<pseudo-page>+|<ident> <pseudo-page>*",
  7262. "path()": "path( [<fill-rule> ,]? <string> )",
  7263. "paint()": "paint( <ident> , <declaration-value>? )",
  7264. "perspective()": "perspective( <length> )",
  7265. "polygon()": "polygon( <fill-rule>? , [<length-percentage> <length-percentage>]# )",
  7266. "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>]]",
  7267. "pseudo-class-selector": "':' <ident-token>|':' <function-token> <any-value> ')'",
  7268. "pseudo-element-selector": "':' <pseudo-class-selector>",
  7269. "pseudo-page": ": [left|right|first|blank]",
  7270. "quote": "open-quote|close-quote|no-open-quote|no-close-quote",
  7271. "radial-gradient()": "radial-gradient( [<ending-shape>||<size>]? [at <position>]? , <color-stop-list> )",
  7272. "relative-selector": "<combinator>? <complex-selector>",
  7273. "relative-selector-list": "<relative-selector>#",
  7274. "relative-size": "larger|smaller",
  7275. "repeat-style": "repeat-x|repeat-y|[repeat|space|round|no-repeat]{1,2}",
  7276. "repeating-linear-gradient()": "repeating-linear-gradient( [<angle>|to <side-or-corner>]? , <color-stop-list> )",
  7277. "repeating-radial-gradient()": "repeating-radial-gradient( [<ending-shape>||<size>]? [at <position>]? , <color-stop-list> )",
  7278. "rgb()": "rgb( <percentage>{3} [/ <alpha-value>]? )|rgb( <number>{3} [/ <alpha-value>]? )|rgb( <percentage>#{3} , <alpha-value>? )|rgb( <number>#{3} , <alpha-value>? )",
  7279. "rgba()": "rgba( <percentage>{3} [/ <alpha-value>]? )|rgba( <number>{3} [/ <alpha-value>]? )|rgba( <percentage>#{3} , <alpha-value>? )|rgba( <number>#{3} , <alpha-value>? )",
  7280. "rotate()": "rotate( [<angle>|<zero>] )",
  7281. "rotate3d()": "rotate3d( <number> , <number> , <number> , [<angle>|<zero>] )",
  7282. "rotateX()": "rotateX( [<angle>|<zero>] )",
  7283. "rotateY()": "rotateY( [<angle>|<zero>] )",
  7284. "rotateZ()": "rotateZ( [<angle>|<zero>] )",
  7285. "saturate()": "saturate( <number-percentage> )",
  7286. "scale()": "scale( <number> , <number>? )",
  7287. "scale3d()": "scale3d( <number> , <number> , <number> )",
  7288. "scaleX()": "scaleX( <number> )",
  7289. "scaleY()": "scaleY( <number> )",
  7290. "scaleZ()": "scaleZ( <number> )",
  7291. "self-position": "center|start|end|self-start|self-end|flex-start|flex-end",
  7292. "shape-radius": "<length-percentage>|closest-side|farthest-side",
  7293. "skew()": "skew( [<angle>|<zero>] , [<angle>|<zero>]? )",
  7294. "skewX()": "skewX( [<angle>|<zero>] )",
  7295. "skewY()": "skewY( [<angle>|<zero>] )",
  7296. "sepia()": "sepia( <number-percentage> )",
  7297. "shadow": "inset?&&<length>{2,4}&&<color>?",
  7298. "shadow-t": "[<length>{2,3}&&<color>?]",
  7299. "shape": "rect( <top> , <right> , <bottom> , <left> )|rect( <top> <right> <bottom> <left> )",
  7300. "shape-box": "<box>|margin-box",
  7301. "side-or-corner": "[left|right]||[top|bottom]",
  7302. "single-animation": "<time>||<timing-function>||<time>||<single-animation-iteration-count>||<single-animation-direction>||<single-animation-fill-mode>||<single-animation-play-state>||[none|<keyframes-name>]",
  7303. "single-animation-direction": "normal|reverse|alternate|alternate-reverse",
  7304. "single-animation-fill-mode": "none|forwards|backwards|both",
  7305. "single-animation-iteration-count": "infinite|<number>",
  7306. "single-animation-play-state": "running|paused",
  7307. "single-transition": "[none|<single-transition-property>]||<time>||<timing-function>||<time>",
  7308. "single-transition-property": "all|<custom-ident>",
  7309. "size": "closest-side|farthest-side|closest-corner|farthest-corner|<length>|<length-percentage>{2}",
  7310. "step-position": "jump-start|jump-end|jump-none|jump-both|start|end",
  7311. "step-timing-function": "step-start|step-end|steps( <integer> [, <step-position>]? )",
  7312. "subclass-selector": "<id-selector>|<class-selector>|<attribute-selector>|<pseudo-class-selector>",
  7313. "supports-condition": "not <supports-in-parens>|<supports-in-parens> [and <supports-in-parens>]*|<supports-in-parens> [or <supports-in-parens>]*",
  7314. "supports-in-parens": "( <supports-condition> )|<supports-feature>|<general-enclosed>",
  7315. "supports-feature": "<supports-decl>|<supports-selector-fn>",
  7316. "supports-decl": "( <declaration> )",
  7317. "supports-selector-fn": "selector( <complex-selector> )",
  7318. "symbol": "<string>|<image>|<custom-ident>",
  7319. "target": "<target-counter()>|<target-counters()>|<target-text()>",
  7320. "target-counter()": "target-counter( [<string>|<url>] , <custom-ident> , <counter-style>? )",
  7321. "target-counters()": "target-counters( [<string>|<url>] , <custom-ident> , <string> , <counter-style>? )",
  7322. "target-text()": "target-text( [<string>|<url>] , [content|before|after|first-letter]? )",
  7323. "time-percentage": "<time>|<percentage>",
  7324. "timing-function": "linear|<cubic-bezier-timing-function>|<step-timing-function>",
  7325. "track-breadth": "<length-percentage>|<flex>|min-content|max-content|auto",
  7326. "track-list": "[<line-names>? [<track-size>|<track-repeat>]]+ <line-names>?",
  7327. "track-repeat": "repeat( [<positive-integer>] , [<line-names>? <track-size>]+ <line-names>? )",
  7328. "track-size": "<track-breadth>|minmax( <inflexible-breadth> , <track-breadth> )|fit-content( [<length>|<percentage>] )",
  7329. "transform-function": "<matrix()>|<translate()>|<translateX()>|<translateY()>|<scale()>|<scaleX()>|<scaleY()>|<rotate()>|<skew()>|<skewX()>|<skewY()>|<matrix3d()>|<translate3d()>|<translateZ()>|<scale3d()>|<scaleZ()>|<rotate3d()>|<rotateX()>|<rotateY()>|<rotateZ()>|<perspective()>",
  7330. "transform-list": "<transform-function>+",
  7331. "translate()": "translate( <length-percentage> , <length-percentage>? )",
  7332. "translate3d()": "translate3d( <length-percentage> , <length-percentage> , <length> )",
  7333. "translateX()": "translateX( <length-percentage> )",
  7334. "translateY()": "translateY( <length-percentage> )",
  7335. "translateZ()": "translateZ( <length> )",
  7336. "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|%",
  7337. "type-selector": "<wq-name>|<ns-prefix>? '*'",
  7338. "var()": "var( <custom-property-name> , <declaration-value>? )",
  7339. "viewport-length": "auto|<length-percentage>",
  7340. "wq-name": "<ns-prefix>? <ident-token>",
  7341. "-legacy-gradient": "<-webkit-gradient()>|<-legacy-linear-gradient>|<-legacy-repeating-linear-gradient>|<-legacy-radial-gradient>|<-legacy-repeating-radial-gradient>",
  7342. "-legacy-linear-gradient": "-moz-linear-gradient( <-legacy-linear-gradient-arguments> )|-webkit-linear-gradient( <-legacy-linear-gradient-arguments> )|-o-linear-gradient( <-legacy-linear-gradient-arguments> )",
  7343. "-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> )",
  7344. "-legacy-linear-gradient-arguments": "[<angle>|<side-or-corner>]? , <color-stop-list>",
  7345. "-legacy-radial-gradient": "-moz-radial-gradient( <-legacy-radial-gradient-arguments> )|-webkit-radial-gradient( <-legacy-radial-gradient-arguments> )|-o-radial-gradient( <-legacy-radial-gradient-arguments> )",
  7346. "-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> )",
  7347. "-legacy-radial-gradient-arguments": "[<position> ,]? [[[<-legacy-radial-gradient-shape>||<-legacy-radial-gradient-size>]|[<length>|<percentage>]{2}] ,]? <color-stop-list>",
  7348. "-legacy-radial-gradient-size": "closest-side|closest-corner|farthest-side|farthest-corner|contain|cover",
  7349. "-legacy-radial-gradient-shape": "circle|ellipse",
  7350. "-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",
  7351. "-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",
  7352. "-non-standard-image-rendering": "optimize-contrast|-moz-crisp-edges|-o-crisp-edges|-webkit-optimize-contrast",
  7353. "-non-standard-overflow": "-moz-scrollbars-none|-moz-scrollbars-horizontal|-moz-scrollbars-vertical|-moz-hidden-unscrollable",
  7354. "-non-standard-width": "fill-available|min-intrinsic|intrinsic|-moz-available|-moz-fit-content|-moz-min-content|-moz-max-content|-webkit-min-content|-webkit-max-content",
  7355. "-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>]* )",
  7356. "-webkit-gradient-color-stop": "from( <color> )|color-stop( [<number-zero-one>|<percentage>] , <color> )|to( <color> )",
  7357. "-webkit-gradient-point": "[left|center|right|<length-percentage>] [top|center|bottom|<length-percentage>]",
  7358. "-webkit-gradient-radius": "<length>|<percentage>",
  7359. "-webkit-gradient-type": "linear|radial",
  7360. "-webkit-mask-box-repeat": "repeat|stretch|round",
  7361. "-webkit-mask-clip-style": "border|border-box|padding|padding-box|content|content-box|text",
  7362. "-ms-filter-function-list": "<-ms-filter-function>+",
  7363. "-ms-filter-function": "<-ms-filter-function-progid>|<-ms-filter-function-legacy>",
  7364. "-ms-filter-function-progid": "'progid:' [<ident-token> '.']* [<ident-token>|<function-token> <any-value>? )]",
  7365. "-ms-filter-function-legacy": "<ident-token>|<function-token> <any-value>? )",
  7366. "-ms-filter": "<string>",
  7367. "age": "child|young|old",
  7368. "attr-name": "<wq-name>",
  7369. "attr-fallback": "<any-value>",
  7370. "border-radius": "<length-percentage>{1,2}",
  7371. "bottom": "<length>|auto",
  7372. "generic-voice": "[<age>? <gender> <integer>?]",
  7373. "gender": "male|female|neutral",
  7374. "left": "<length>|auto",
  7375. "mask-image": "<mask-reference>#",
  7376. "name-repeat": "repeat( [<positive-integer>|auto-fill] , <line-names>+ )",
  7377. "paint": "none|<color>|<url> [none|<color>]?|context-fill|context-stroke",
  7378. "page-size": "A5|A4|A3|B5|B4|JIS-B5|JIS-B4|letter|legal|ledger",
  7379. "ratio": "<integer> / <integer>",
  7380. "right": "<length>|auto",
  7381. "svg-length": "<percentage>|<length>|<number>",
  7382. "svg-writing-mode": "lr-tb|rl-tb|tb-rl|lr|rl|tb",
  7383. "top": "<length>|auto",
  7384. "track-group": "'(' [<string>* <track-minmax> <string>*]+ ')' ['[' <positive-integer> ']']?|<track-minmax>",
  7385. "track-list-v0": "[<string>* <track-group> <string>*]+|none",
  7386. "track-minmax": "minmax( <track-breadth> , <track-breadth> )|auto|<track-breadth>|fit-content",
  7387. "x": "<number>",
  7388. "y": "<number>",
  7389. "declaration": "<ident-token> : <declaration-value>? ['!' important]?",
  7390. "declaration-list": "[<declaration>? ';']* <declaration>?",
  7391. "url": "url( <string> <url-modifier>* )|<url-token>",
  7392. "url-modifier": "<ident>|<function-token> <any-value> )",
  7393. "number-zero-one": "<number [0,1]>",
  7394. "number-one-or-greater": "<number [1,∞]>",
  7395. "positive-integer": "<integer [0,∞]>",
  7396. "-non-standard-display": "-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"
  7397. },
  7398. "properties": {
  7399. "--*": "<declaration-value>",
  7400. "-ms-accelerator": "false|true",
  7401. "-ms-block-progression": "tb|rl|bt|lr",
  7402. "-ms-content-zoom-chaining": "none|chained",
  7403. "-ms-content-zooming": "none|zoom",
  7404. "-ms-content-zoom-limit": "<'-ms-content-zoom-limit-min'> <'-ms-content-zoom-limit-max'>",
  7405. "-ms-content-zoom-limit-max": "<percentage>",
  7406. "-ms-content-zoom-limit-min": "<percentage>",
  7407. "-ms-content-zoom-snap": "<'-ms-content-zoom-snap-type'>||<'-ms-content-zoom-snap-points'>",
  7408. "-ms-content-zoom-snap-points": "snapInterval( <percentage> , <percentage> )|snapList( <percentage># )",
  7409. "-ms-content-zoom-snap-type": "none|proximity|mandatory",
  7410. "-ms-filter": "<string>",
  7411. "-ms-flow-from": "[none|<custom-ident>]#",
  7412. "-ms-flow-into": "[none|<custom-ident>]#",
  7413. "-ms-grid-columns": "none|<track-list>|<auto-track-list>",
  7414. "-ms-grid-rows": "none|<track-list>|<auto-track-list>",
  7415. "-ms-high-contrast-adjust": "auto|none",
  7416. "-ms-hyphenate-limit-chars": "auto|<integer>{1,3}",
  7417. "-ms-hyphenate-limit-lines": "no-limit|<integer>",
  7418. "-ms-hyphenate-limit-zone": "<percentage>|<length>",
  7419. "-ms-ime-align": "auto|after",
  7420. "-ms-overflow-style": "auto|none|scrollbar|-ms-autohiding-scrollbar",
  7421. "-ms-scrollbar-3dlight-color": "<color>",
  7422. "-ms-scrollbar-arrow-color": "<color>",
  7423. "-ms-scrollbar-base-color": "<color>",
  7424. "-ms-scrollbar-darkshadow-color": "<color>",
  7425. "-ms-scrollbar-face-color": "<color>",
  7426. "-ms-scrollbar-highlight-color": "<color>",
  7427. "-ms-scrollbar-shadow-color": "<color>",
  7428. "-ms-scrollbar-track-color": "<color>",
  7429. "-ms-scroll-chaining": "chained|none",
  7430. "-ms-scroll-limit": "<'-ms-scroll-limit-x-min'> <'-ms-scroll-limit-y-min'> <'-ms-scroll-limit-x-max'> <'-ms-scroll-limit-y-max'>",
  7431. "-ms-scroll-limit-x-max": "auto|<length>",
  7432. "-ms-scroll-limit-x-min": "<length>",
  7433. "-ms-scroll-limit-y-max": "auto|<length>",
  7434. "-ms-scroll-limit-y-min": "<length>",
  7435. "-ms-scroll-rails": "none|railed",
  7436. "-ms-scroll-snap-points-x": "snapInterval( <length-percentage> , <length-percentage> )|snapList( <length-percentage># )",
  7437. "-ms-scroll-snap-points-y": "snapInterval( <length-percentage> , <length-percentage> )|snapList( <length-percentage># )",
  7438. "-ms-scroll-snap-type": "none|proximity|mandatory",
  7439. "-ms-scroll-snap-x": "<'-ms-scroll-snap-type'> <'-ms-scroll-snap-points-x'>",
  7440. "-ms-scroll-snap-y": "<'-ms-scroll-snap-type'> <'-ms-scroll-snap-points-y'>",
  7441. "-ms-scroll-translation": "none|vertical-to-horizontal",
  7442. "-ms-text-autospace": "none|ideograph-alpha|ideograph-numeric|ideograph-parenthesis|ideograph-space",
  7443. "-ms-touch-select": "grippers|none",
  7444. "-ms-user-select": "none|element|text",
  7445. "-ms-wrap-flow": "auto|both|start|end|maximum|clear",
  7446. "-ms-wrap-margin": "<length>",
  7447. "-ms-wrap-through": "wrap|none",
  7448. "-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",
  7449. "-moz-binding": "<url>|none",
  7450. "-moz-border-bottom-colors": "<color>+|none",
  7451. "-moz-border-left-colors": "<color>+|none",
  7452. "-moz-border-right-colors": "<color>+|none",
  7453. "-moz-border-top-colors": "<color>+|none",
  7454. "-moz-context-properties": "none|[fill|fill-opacity|stroke|stroke-opacity]#",
  7455. "-moz-float-edge": "border-box|content-box|margin-box|padding-box",
  7456. "-moz-force-broken-image-icon": "<integer [0,1]>",
  7457. "-moz-image-region": "<shape>|auto",
  7458. "-moz-orient": "inline|block|horizontal|vertical",
  7459. "-moz-outline-radius": "<outline-radius>{1,4} [/ <outline-radius>{1,4}]?",
  7460. "-moz-outline-radius-bottomleft": "<outline-radius>",
  7461. "-moz-outline-radius-bottomright": "<outline-radius>",
  7462. "-moz-outline-radius-topleft": "<outline-radius>",
  7463. "-moz-outline-radius-topright": "<outline-radius>",
  7464. "-moz-stack-sizing": "ignore|stretch-to-fit",
  7465. "-moz-text-blink": "none|blink",
  7466. "-moz-user-focus": "ignore|normal|select-after|select-before|select-menu|select-same|select-all|none",
  7467. "-moz-user-input": "auto|none|enabled|disabled",
  7468. "-moz-user-modify": "read-only|read-write|write-only",
  7469. "-moz-window-dragging": "drag|no-drag",
  7470. "-moz-window-shadow": "default|menu|tooltip|sheet|none",
  7471. "-webkit-appearance": "none|button|button-bevel|caps-lock-indicator|caret|checkbox|default-button|inner-spin-button|listbox|listitem|media-controls-background|media-controls-fullscreen-background|media-current-time-display|media-enter-fullscreen-button|media-exit-fullscreen-button|media-fullscreen-button|media-mute-button|media-overlay-play-button|media-play-button|media-seek-back-button|media-seek-forward-button|media-slider|media-sliderthumb|media-time-remaining-display|media-toggle-closed-captions-button|media-volume-slider|media-volume-slider-container|media-volume-sliderthumb|menulist|menulist-button|menulist-text|menulist-textfield|meter|progress-bar|progress-bar-value|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|-apple-pay-button",
  7472. "-webkit-border-before": "<'border-width'>||<'border-style'>||<'color'>",
  7473. "-webkit-border-before-color": "<'color'>",
  7474. "-webkit-border-before-style": "<'border-style'>",
  7475. "-webkit-border-before-width": "<'border-width'>",
  7476. "-webkit-box-reflect": "[above|below|right|left]? <length>? <image>?",
  7477. "-webkit-line-clamp": "none|<integer>",
  7478. "-webkit-mask": "[<mask-reference>||<position> [/ <bg-size>]?||<repeat-style>||[<box>|border|padding|content|text]||[<box>|border|padding|content]]#",
  7479. "-webkit-mask-attachment": "<attachment>#",
  7480. "-webkit-mask-clip": "[<box>|border|padding|content|text]#",
  7481. "-webkit-mask-composite": "<composite-style>#",
  7482. "-webkit-mask-image": "<mask-reference>#",
  7483. "-webkit-mask-origin": "[<box>|border|padding|content]#",
  7484. "-webkit-mask-position": "<position>#",
  7485. "-webkit-mask-position-x": "[<length-percentage>|left|center|right]#",
  7486. "-webkit-mask-position-y": "[<length-percentage>|top|center|bottom]#",
  7487. "-webkit-mask-repeat": "<repeat-style>#",
  7488. "-webkit-mask-repeat-x": "repeat|no-repeat|space|round",
  7489. "-webkit-mask-repeat-y": "repeat|no-repeat|space|round",
  7490. "-webkit-mask-size": "<bg-size>#",
  7491. "-webkit-overflow-scrolling": "auto|touch",
  7492. "-webkit-tap-highlight-color": "<color>",
  7493. "-webkit-text-fill-color": "<color>",
  7494. "-webkit-text-stroke": "<length>||<color>",
  7495. "-webkit-text-stroke-color": "<color>",
  7496. "-webkit-text-stroke-width": "<length>",
  7497. "-webkit-touch-callout": "default|none",
  7498. "-webkit-user-modify": "read-only|read-write|read-write-plaintext-only",
  7499. "align-content": "normal|<baseline-position>|<content-distribution>|<overflow-position>? <content-position>",
  7500. "align-items": "normal|stretch|<baseline-position>|[<overflow-position>? <self-position>]",
  7501. "align-self": "auto|normal|stretch|<baseline-position>|<overflow-position>? <self-position>",
  7502. "align-tracks": "[normal|<baseline-position>|<content-distribution>|<overflow-position>? <content-position>]#",
  7503. "all": "initial|inherit|unset|revert",
  7504. "animation": "<single-animation>#",
  7505. "animation-delay": "<time>#",
  7506. "animation-direction": "<single-animation-direction>#",
  7507. "animation-duration": "<time>#",
  7508. "animation-fill-mode": "<single-animation-fill-mode>#",
  7509. "animation-iteration-count": "<single-animation-iteration-count>#",
  7510. "animation-name": "[none|<keyframes-name>]#",
  7511. "animation-play-state": "<single-animation-play-state>#",
  7512. "animation-timing-function": "<timing-function>#",
  7513. "appearance": "none|auto|textfield|menulist-button|<compat-auto>",
  7514. "aspect-ratio": "auto|<ratio>",
  7515. "azimuth": "<angle>|[[left-side|far-left|left|center-left|center|center-right|right|far-right|right-side]||behind]|leftwards|rightwards",
  7516. "backdrop-filter": "none|<filter-function-list>",
  7517. "backface-visibility": "visible|hidden",
  7518. "background": "[<bg-layer> ,]* <final-bg-layer>",
  7519. "background-attachment": "<attachment>#",
  7520. "background-blend-mode": "<blend-mode>#",
  7521. "background-clip": "<box>#",
  7522. "background-color": "<color>",
  7523. "background-image": "<bg-image>#",
  7524. "background-origin": "<box>#",
  7525. "background-position": "<bg-position>#",
  7526. "background-position-x": "[center|[[left|right|x-start|x-end]? <length-percentage>?]!]#",
  7527. "background-position-y": "[center|[[top|bottom|y-start|y-end]? <length-percentage>?]!]#",
  7528. "background-repeat": "<repeat-style>#",
  7529. "background-size": "<bg-size>#",
  7530. "block-overflow": "clip|ellipsis|<string>",
  7531. "block-size": "<'width'>",
  7532. "border": "<line-width>||<line-style>||<color>",
  7533. "border-block": "<'border-top-width'>||<'border-top-style'>||<'color'>",
  7534. "border-block-color": "<'border-top-color'>{1,2}",
  7535. "border-block-style": "<'border-top-style'>",
  7536. "border-block-width": "<'border-top-width'>",
  7537. "border-block-end": "<'border-top-width'>||<'border-top-style'>||<'color'>",
  7538. "border-block-end-color": "<'border-top-color'>",
  7539. "border-block-end-style": "<'border-top-style'>",
  7540. "border-block-end-width": "<'border-top-width'>",
  7541. "border-block-start": "<'border-top-width'>||<'border-top-style'>||<'color'>",
  7542. "border-block-start-color": "<'border-top-color'>",
  7543. "border-block-start-style": "<'border-top-style'>",
  7544. "border-block-start-width": "<'border-top-width'>",
  7545. "border-bottom": "<line-width>||<line-style>||<color>",
  7546. "border-bottom-color": "<'border-top-color'>",
  7547. "border-bottom-left-radius": "<length-percentage>{1,2}",
  7548. "border-bottom-right-radius": "<length-percentage>{1,2}",
  7549. "border-bottom-style": "<line-style>",
  7550. "border-bottom-width": "<line-width>",
  7551. "border-collapse": "collapse|separate",
  7552. "border-color": "<color>{1,4}",
  7553. "border-end-end-radius": "<length-percentage>{1,2}",
  7554. "border-end-start-radius": "<length-percentage>{1,2}",
  7555. "border-image": "<'border-image-source'>||<'border-image-slice'> [/ <'border-image-width'>|/ <'border-image-width'>? / <'border-image-outset'>]?||<'border-image-repeat'>",
  7556. "border-image-outset": "[<length>|<number>]{1,4}",
  7557. "border-image-repeat": "[stretch|repeat|round|space]{1,2}",
  7558. "border-image-slice": "<number-percentage>{1,4}&&fill?",
  7559. "border-image-source": "none|<image>",
  7560. "border-image-width": "[<length-percentage>|<number>|auto]{1,4}",
  7561. "border-inline": "<'border-top-width'>||<'border-top-style'>||<'color'>",
  7562. "border-inline-end": "<'border-top-width'>||<'border-top-style'>||<'color'>",
  7563. "border-inline-color": "<'border-top-color'>{1,2}",
  7564. "border-inline-style": "<'border-top-style'>",
  7565. "border-inline-width": "<'border-top-width'>",
  7566. "border-inline-end-color": "<'border-top-color'>",
  7567. "border-inline-end-style": "<'border-top-style'>",
  7568. "border-inline-end-width": "<'border-top-width'>",
  7569. "border-inline-start": "<'border-top-width'>||<'border-top-style'>||<'color'>",
  7570. "border-inline-start-color": "<'border-top-color'>",
  7571. "border-inline-start-style": "<'border-top-style'>",
  7572. "border-inline-start-width": "<'border-top-width'>",
  7573. "border-left": "<line-width>||<line-style>||<color>",
  7574. "border-left-color": "<color>",
  7575. "border-left-style": "<line-style>",
  7576. "border-left-width": "<line-width>",
  7577. "border-radius": "<length-percentage>{1,4} [/ <length-percentage>{1,4}]?",
  7578. "border-right": "<line-width>||<line-style>||<color>",
  7579. "border-right-color": "<color>",
  7580. "border-right-style": "<line-style>",
  7581. "border-right-width": "<line-width>",
  7582. "border-spacing": "<length> <length>?",
  7583. "border-start-end-radius": "<length-percentage>{1,2}",
  7584. "border-start-start-radius": "<length-percentage>{1,2}",
  7585. "border-style": "<line-style>{1,4}",
  7586. "border-top": "<line-width>||<line-style>||<color>",
  7587. "border-top-color": "<color>",
  7588. "border-top-left-radius": "<length-percentage>{1,2}",
  7589. "border-top-right-radius": "<length-percentage>{1,2}",
  7590. "border-top-style": "<line-style>",
  7591. "border-top-width": "<line-width>",
  7592. "border-width": "<line-width>{1,4}",
  7593. "bottom": "<length>|<percentage>|auto",
  7594. "box-align": "start|center|end|baseline|stretch",
  7595. "box-decoration-break": "slice|clone",
  7596. "box-direction": "normal|reverse|inherit",
  7597. "box-flex": "<number>",
  7598. "box-flex-group": "<integer>",
  7599. "box-lines": "single|multiple",
  7600. "box-ordinal-group": "<integer>",
  7601. "box-orient": "horizontal|vertical|inline-axis|block-axis|inherit",
  7602. "box-pack": "start|center|end|justify",
  7603. "box-shadow": "none|<shadow>#",
  7604. "box-sizing": "content-box|border-box",
  7605. "break-after": "auto|avoid|always|all|avoid-page|page|left|right|recto|verso|avoid-column|column|avoid-region|region",
  7606. "break-before": "auto|avoid|always|all|avoid-page|page|left|right|recto|verso|avoid-column|column|avoid-region|region",
  7607. "break-inside": "auto|avoid|avoid-page|avoid-column|avoid-region",
  7608. "caption-side": "top|bottom|block-start|block-end|inline-start|inline-end",
  7609. "caret-color": "auto|<color>",
  7610. "clear": "none|left|right|both|inline-start|inline-end",
  7611. "clip": "<shape>|auto",
  7612. "clip-path": "<clip-source>|[<basic-shape>||<geometry-box>]|none",
  7613. "color": "<color>",
  7614. "color-adjust": "economy|exact",
  7615. "column-count": "<integer>|auto",
  7616. "column-fill": "auto|balance|balance-all",
  7617. "column-gap": "normal|<length-percentage>",
  7618. "column-rule": "<'column-rule-width'>||<'column-rule-style'>||<'column-rule-color'>",
  7619. "column-rule-color": "<color>",
  7620. "column-rule-style": "<'border-style'>",
  7621. "column-rule-width": "<'border-width'>",
  7622. "column-span": "none|all",
  7623. "column-width": "<length>|auto",
  7624. "columns": "<'column-width'>||<'column-count'>",
  7625. "contain": "none|strict|content|[size||layout||style||paint]",
  7626. "content": "normal|none|[<content-replacement>|<content-list>] [/ <string>]?",
  7627. "counter-increment": "[<custom-ident> <integer>?]+|none",
  7628. "counter-reset": "[<custom-ident> <integer>?]+|none",
  7629. "counter-set": "[<custom-ident> <integer>?]+|none",
  7630. "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]]",
  7631. "direction": "ltr|rtl",
  7632. "display": "[<display-outside>||<display-inside>]|<display-listitem>|<display-internal>|<display-box>|<display-legacy>|<-non-standard-display>",
  7633. "empty-cells": "show|hide",
  7634. "filter": "none|<filter-function-list>|<-ms-filter-function-list>",
  7635. "flex": "none|[<'flex-grow'> <'flex-shrink'>?||<'flex-basis'>]",
  7636. "flex-basis": "content|<'width'>",
  7637. "flex-direction": "row|row-reverse|column|column-reverse",
  7638. "flex-flow": "<'flex-direction'>||<'flex-wrap'>",
  7639. "flex-grow": "<number>",
  7640. "flex-shrink": "<number>",
  7641. "flex-wrap": "nowrap|wrap|wrap-reverse",
  7642. "float": "left|right|none|inline-start|inline-end",
  7643. "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",
  7644. "font-family": "[<family-name>|<generic-family>]#",
  7645. "font-feature-settings": "normal|<feature-tag-value>#",
  7646. "font-kerning": "auto|normal|none",
  7647. "font-language-override": "normal|<string>",
  7648. "font-optical-sizing": "auto|none",
  7649. "font-variation-settings": "normal|[<string> <number>]#",
  7650. "font-size": "<absolute-size>|<relative-size>|<length-percentage>",
  7651. "font-size-adjust": "none|<number>",
  7652. "font-smooth": "auto|never|always|<absolute-size>|<length>",
  7653. "font-stretch": "<font-stretch-absolute>",
  7654. "font-style": "normal|italic|oblique <angle>?",
  7655. "font-synthesis": "none|[weight||style]",
  7656. "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]",
  7657. "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> )]",
  7658. "font-variant-caps": "normal|small-caps|all-small-caps|petite-caps|all-petite-caps|unicase|titling-caps",
  7659. "font-variant-east-asian": "normal|[<east-asian-variant-values>||<east-asian-width-values>||ruby]",
  7660. "font-variant-ligatures": "normal|none|[<common-lig-values>||<discretionary-lig-values>||<historical-lig-values>||<contextual-alt-values>]",
  7661. "font-variant-numeric": "normal|[<numeric-figure-values>||<numeric-spacing-values>||<numeric-fraction-values>||ordinal||slashed-zero]",
  7662. "font-variant-position": "normal|sub|super",
  7663. "font-weight": "<font-weight-absolute>|bolder|lighter",
  7664. "gap": "<'row-gap'> <'column-gap'>?",
  7665. "grid": "<'grid-template'>|<'grid-template-rows'> / [auto-flow&&dense?] <'grid-auto-columns'>?|[auto-flow&&dense?] <'grid-auto-rows'>? / <'grid-template-columns'>",
  7666. "grid-area": "<grid-line> [/ <grid-line>]{0,3}",
  7667. "grid-auto-columns": "<track-size>+",
  7668. "grid-auto-flow": "[row|column]||dense",
  7669. "grid-auto-rows": "<track-size>+",
  7670. "grid-column": "<grid-line> [/ <grid-line>]?",
  7671. "grid-column-end": "<grid-line>",
  7672. "grid-column-gap": "<length-percentage>",
  7673. "grid-column-start": "<grid-line>",
  7674. "grid-gap": "<'grid-row-gap'> <'grid-column-gap'>?",
  7675. "grid-row": "<grid-line> [/ <grid-line>]?",
  7676. "grid-row-end": "<grid-line>",
  7677. "grid-row-gap": "<length-percentage>",
  7678. "grid-row-start": "<grid-line>",
  7679. "grid-template": "none|[<'grid-template-rows'> / <'grid-template-columns'>]|[<line-names>? <string> <track-size>? <line-names>?]+ [/ <explicit-track-list>]?",
  7680. "grid-template-areas": "none|<string>+",
  7681. "grid-template-columns": "none|<track-list>|<auto-track-list>|subgrid <line-name-list>?",
  7682. "grid-template-rows": "none|<track-list>|<auto-track-list>|subgrid <line-name-list>?",
  7683. "hanging-punctuation": "none|[first||[force-end|allow-end]||last]",
  7684. "height": "auto|<length>|<percentage>|min-content|max-content|fit-content( <length-percentage> )",
  7685. "hyphens": "none|manual|auto",
  7686. "image-orientation": "from-image|<angle>|[<angle>? flip]",
  7687. "image-rendering": "auto|crisp-edges|pixelated|optimizeSpeed|optimizeQuality|<-non-standard-image-rendering>",
  7688. "image-resolution": "[from-image||<resolution>]&&snap?",
  7689. "ime-mode": "auto|normal|active|inactive|disabled",
  7690. "initial-letter": "normal|[<number> <integer>?]",
  7691. "initial-letter-align": "[auto|alphabetic|hanging|ideographic]",
  7692. "inline-size": "<'width'>",
  7693. "inset": "<'top'>{1,4}",
  7694. "inset-block": "<'top'>{1,2}",
  7695. "inset-block-end": "<'top'>",
  7696. "inset-block-start": "<'top'>",
  7697. "inset-inline": "<'top'>{1,2}",
  7698. "inset-inline-end": "<'top'>",
  7699. "inset-inline-start": "<'top'>",
  7700. "isolation": "auto|isolate",
  7701. "justify-content": "normal|<content-distribution>|<overflow-position>? [<content-position>|left|right]",
  7702. "justify-items": "normal|stretch|<baseline-position>|<overflow-position>? [<self-position>|left|right]|legacy|legacy&&[left|right|center]",
  7703. "justify-self": "auto|normal|stretch|<baseline-position>|<overflow-position>? [<self-position>|left|right]",
  7704. "justify-tracks": "[normal|<content-distribution>|<overflow-position>? [<content-position>|left|right]]#",
  7705. "left": "<length>|<percentage>|auto",
  7706. "letter-spacing": "normal|<length-percentage>",
  7707. "line-break": "auto|loose|normal|strict|anywhere",
  7708. "line-clamp": "none|<integer>",
  7709. "line-height": "normal|<number>|<length>|<percentage>",
  7710. "line-height-step": "<length>",
  7711. "list-style": "<'list-style-type'>||<'list-style-position'>||<'list-style-image'>",
  7712. "list-style-image": "<url>|none",
  7713. "list-style-position": "inside|outside",
  7714. "list-style-type": "<counter-style>|<string>|none",
  7715. "margin": "[<length>|<percentage>|auto]{1,4}",
  7716. "margin-block": "<'margin-left'>{1,2}",
  7717. "margin-block-end": "<'margin-left'>",
  7718. "margin-block-start": "<'margin-left'>",
  7719. "margin-bottom": "<length>|<percentage>|auto",
  7720. "margin-inline": "<'margin-left'>{1,2}",
  7721. "margin-inline-end": "<'margin-left'>",
  7722. "margin-inline-start": "<'margin-left'>",
  7723. "margin-left": "<length>|<percentage>|auto",
  7724. "margin-right": "<length>|<percentage>|auto",
  7725. "margin-top": "<length>|<percentage>|auto",
  7726. "margin-trim": "none|in-flow|all",
  7727. "mask": "<mask-layer>#",
  7728. "mask-border": "<'mask-border-source'>||<'mask-border-slice'> [/ <'mask-border-width'>? [/ <'mask-border-outset'>]?]?||<'mask-border-repeat'>||<'mask-border-mode'>",
  7729. "mask-border-mode": "luminance|alpha",
  7730. "mask-border-outset": "[<length>|<number>]{1,4}",
  7731. "mask-border-repeat": "[stretch|repeat|round|space]{1,2}",
  7732. "mask-border-slice": "<number-percentage>{1,4} fill?",
  7733. "mask-border-source": "none|<image>",
  7734. "mask-border-width": "[<length-percentage>|<number>|auto]{1,4}",
  7735. "mask-clip": "[<geometry-box>|no-clip]#",
  7736. "mask-composite": "<compositing-operator>#",
  7737. "mask-image": "<mask-reference>#",
  7738. "mask-mode": "<masking-mode>#",
  7739. "mask-origin": "<geometry-box>#",
  7740. "mask-position": "<position>#",
  7741. "mask-repeat": "<repeat-style>#",
  7742. "mask-size": "<bg-size>#",
  7743. "mask-type": "luminance|alpha",
  7744. "masonry-auto-flow": "[pack|next]||[definite-first|ordered]",
  7745. "math-style": "normal|compact",
  7746. "max-block-size": "<'max-width'>",
  7747. "max-height": "none|<length-percentage>|min-content|max-content|fit-content( <length-percentage> )",
  7748. "max-inline-size": "<'max-width'>",
  7749. "max-lines": "none|<integer>",
  7750. "max-width": "none|<length-percentage>|min-content|max-content|fit-content( <length-percentage> )|<-non-standard-width>",
  7751. "min-block-size": "<'min-width'>",
  7752. "min-height": "auto|<length>|<percentage>|min-content|max-content|fit-content( <length-percentage> )",
  7753. "min-inline-size": "<'min-width'>",
  7754. "min-width": "auto|<length-percentage>|min-content|max-content|fit-content( <length-percentage> )|<-non-standard-width>",
  7755. "mix-blend-mode": "<blend-mode>",
  7756. "object-fit": "fill|contain|cover|none|scale-down",
  7757. "object-position": "<position>",
  7758. "offset": "[<'offset-position'>? [<'offset-path'> [<'offset-distance'>||<'offset-rotate'>]?]?]! [/ <'offset-anchor'>]?",
  7759. "offset-anchor": "auto|<position>",
  7760. "offset-distance": "<length-percentage>",
  7761. "offset-path": "none|ray( [<angle>&&<size>&&contain?] )|<path()>|<url>|[<basic-shape>||<geometry-box>]",
  7762. "offset-position": "auto|<position>",
  7763. "offset-rotate": "[auto|reverse]||<angle>",
  7764. "opacity": "<alpha-value>",
  7765. "order": "<integer>",
  7766. "orphans": "<integer>",
  7767. "outline": "[<'outline-color'>||<'outline-style'>||<'outline-width'>]",
  7768. "outline-color": "<color>|invert",
  7769. "outline-offset": "<length>",
  7770. "outline-style": "auto|<'border-style'>",
  7771. "outline-width": "<line-width>",
  7772. "overflow": "[visible|hidden|clip|scroll|auto]{1,2}|<-non-standard-overflow>",
  7773. "overflow-anchor": "auto|none",
  7774. "overflow-block": "visible|hidden|clip|scroll|auto",
  7775. "overflow-clip-box": "padding-box|content-box",
  7776. "overflow-inline": "visible|hidden|clip|scroll|auto",
  7777. "overflow-wrap": "normal|break-word|anywhere",
  7778. "overflow-x": "visible|hidden|clip|scroll|auto",
  7779. "overflow-y": "visible|hidden|clip|scroll|auto",
  7780. "overscroll-behavior": "[contain|none|auto]{1,2}",
  7781. "overscroll-behavior-block": "contain|none|auto",
  7782. "overscroll-behavior-inline": "contain|none|auto",
  7783. "overscroll-behavior-x": "contain|none|auto",
  7784. "overscroll-behavior-y": "contain|none|auto",
  7785. "padding": "[<length>|<percentage>]{1,4}",
  7786. "padding-block": "<'padding-left'>{1,2}",
  7787. "padding-block-end": "<'padding-left'>",
  7788. "padding-block-start": "<'padding-left'>",
  7789. "padding-bottom": "<length>|<percentage>",
  7790. "padding-inline": "<'padding-left'>{1,2}",
  7791. "padding-inline-end": "<'padding-left'>",
  7792. "padding-inline-start": "<'padding-left'>",
  7793. "padding-left": "<length>|<percentage>",
  7794. "padding-right": "<length>|<percentage>",
  7795. "padding-top": "<length>|<percentage>",
  7796. "page-break-after": "auto|always|avoid|left|right|recto|verso",
  7797. "page-break-before": "auto|always|avoid|left|right|recto|verso",
  7798. "page-break-inside": "auto|avoid",
  7799. "paint-order": "normal|[fill||stroke||markers]",
  7800. "perspective": "none|<length>",
  7801. "perspective-origin": "<position>",
  7802. "place-content": "<'align-content'> <'justify-content'>?",
  7803. "place-items": "<'align-items'> <'justify-items'>?",
  7804. "place-self": "<'align-self'> <'justify-self'>?",
  7805. "pointer-events": "auto|none|visiblePainted|visibleFill|visibleStroke|visible|painted|fill|stroke|all|inherit",
  7806. "position": "static|relative|absolute|sticky|fixed|-webkit-sticky",
  7807. "quotes": "none|auto|[<string> <string>]+",
  7808. "resize": "none|both|horizontal|vertical|block|inline",
  7809. "right": "<length>|<percentage>|auto",
  7810. "rotate": "none|<angle>|[x|y|z|<number>{3}]&&<angle>",
  7811. "row-gap": "normal|<length-percentage>",
  7812. "ruby-align": "start|center|space-between|space-around",
  7813. "ruby-merge": "separate|collapse|auto",
  7814. "ruby-position": "over|under|inter-character",
  7815. "scale": "none|<number>{1,3}",
  7816. "scrollbar-color": "auto|dark|light|<color>{2}",
  7817. "scrollbar-gutter": "auto|[stable|always]&&both?&&force?",
  7818. "scrollbar-width": "auto|thin|none",
  7819. "scroll-behavior": "auto|smooth",
  7820. "scroll-margin": "<length>{1,4}",
  7821. "scroll-margin-block": "<length>{1,2}",
  7822. "scroll-margin-block-start": "<length>",
  7823. "scroll-margin-block-end": "<length>",
  7824. "scroll-margin-bottom": "<length>",
  7825. "scroll-margin-inline": "<length>{1,2}",
  7826. "scroll-margin-inline-start": "<length>",
  7827. "scroll-margin-inline-end": "<length>",
  7828. "scroll-margin-left": "<length>",
  7829. "scroll-margin-right": "<length>",
  7830. "scroll-margin-top": "<length>",
  7831. "scroll-padding": "[auto|<length-percentage>]{1,4}",
  7832. "scroll-padding-block": "[auto|<length-percentage>]{1,2}",
  7833. "scroll-padding-block-start": "auto|<length-percentage>",
  7834. "scroll-padding-block-end": "auto|<length-percentage>",
  7835. "scroll-padding-bottom": "auto|<length-percentage>",
  7836. "scroll-padding-inline": "[auto|<length-percentage>]{1,2}",
  7837. "scroll-padding-inline-start": "auto|<length-percentage>",
  7838. "scroll-padding-inline-end": "auto|<length-percentage>",
  7839. "scroll-padding-left": "auto|<length-percentage>",
  7840. "scroll-padding-right": "auto|<length-percentage>",
  7841. "scroll-padding-top": "auto|<length-percentage>",
  7842. "scroll-snap-align": "[none|start|end|center]{1,2}",
  7843. "scroll-snap-coordinate": "none|<position>#",
  7844. "scroll-snap-destination": "<position>",
  7845. "scroll-snap-points-x": "none|repeat( <length-percentage> )",
  7846. "scroll-snap-points-y": "none|repeat( <length-percentage> )",
  7847. "scroll-snap-stop": "normal|always",
  7848. "scroll-snap-type": "none|[x|y|block|inline|both] [mandatory|proximity]?",
  7849. "scroll-snap-type-x": "none|mandatory|proximity",
  7850. "scroll-snap-type-y": "none|mandatory|proximity",
  7851. "shape-image-threshold": "<alpha-value>",
  7852. "shape-margin": "<length-percentage>",
  7853. "shape-outside": "none|<shape-box>||<basic-shape>|<image>",
  7854. "tab-size": "<integer>|<length>",
  7855. "table-layout": "auto|fixed",
  7856. "text-align": "start|end|left|right|center|justify|match-parent",
  7857. "text-align-last": "auto|start|end|left|right|center|justify",
  7858. "text-combine-upright": "none|all|[digits <integer>?]",
  7859. "text-decoration": "<'text-decoration-line'>||<'text-decoration-style'>||<'text-decoration-color'>||<'text-decoration-thickness'>",
  7860. "text-decoration-color": "<color>",
  7861. "text-decoration-line": "none|[underline||overline||line-through||blink]|spelling-error|grammar-error",
  7862. "text-decoration-skip": "none|[objects||[spaces|[leading-spaces||trailing-spaces]]||edges||box-decoration]",
  7863. "text-decoration-skip-ink": "auto|all|none",
  7864. "text-decoration-style": "solid|double|dotted|dashed|wavy",
  7865. "text-decoration-thickness": "auto|from-font|<length>|<percentage>",
  7866. "text-emphasis": "<'text-emphasis-style'>||<'text-emphasis-color'>",
  7867. "text-emphasis-color": "<color>",
  7868. "text-emphasis-position": "[over|under]&&[right|left]",
  7869. "text-emphasis-style": "none|[[filled|open]||[dot|circle|double-circle|triangle|sesame]]|<string>",
  7870. "text-indent": "<length-percentage>&&hanging?&&each-line?",
  7871. "text-justify": "auto|inter-character|inter-word|none",
  7872. "text-orientation": "mixed|upright|sideways",
  7873. "text-overflow": "[clip|ellipsis|<string>]{1,2}",
  7874. "text-rendering": "auto|optimizeSpeed|optimizeLegibility|geometricPrecision",
  7875. "text-shadow": "none|<shadow-t>#",
  7876. "text-size-adjust": "none|auto|<percentage>",
  7877. "text-transform": "none|capitalize|uppercase|lowercase|full-width|full-size-kana",
  7878. "text-underline-offset": "auto|<length>|<percentage>",
  7879. "text-underline-position": "auto|from-font|[under||[left|right]]",
  7880. "top": "<length>|<percentage>|auto",
  7881. "touch-action": "auto|none|[[pan-x|pan-left|pan-right]||[pan-y|pan-up|pan-down]||pinch-zoom]|manipulation",
  7882. "transform": "none|<transform-list>",
  7883. "transform-box": "content-box|border-box|fill-box|stroke-box|view-box",
  7884. "transform-origin": "[<length-percentage>|left|center|right|top|bottom]|[[<length-percentage>|left|center|right]&&[<length-percentage>|top|center|bottom]] <length>?",
  7885. "transform-style": "flat|preserve-3d",
  7886. "transition": "<single-transition>#",
  7887. "transition-delay": "<time>#",
  7888. "transition-duration": "<time>#",
  7889. "transition-property": "none|<single-transition-property>#",
  7890. "transition-timing-function": "<timing-function>#",
  7891. "translate": "none|<length-percentage> [<length-percentage> <length>?]?",
  7892. "unicode-bidi": "normal|embed|isolate|bidi-override|isolate-override|plaintext|-moz-isolate|-moz-isolate-override|-moz-plaintext|-webkit-isolate|-webkit-isolate-override|-webkit-plaintext",
  7893. "user-select": "auto|text|none|contain|all",
  7894. "vertical-align": "baseline|sub|super|text-top|text-bottom|middle|top|bottom|<percentage>|<length>",
  7895. "visibility": "visible|hidden|collapse",
  7896. "white-space": "normal|pre|nowrap|pre-wrap|pre-line|break-spaces",
  7897. "widows": "<integer>",
  7898. "width": "auto|<length>|<percentage>|min-content|max-content|fit-content( <length-percentage> )|fit-content|-moz-fit-content|-webkit-fit-content",
  7899. "will-change": "auto|<animateable-feature>#",
  7900. "word-break": "normal|break-all|keep-all|break-word",
  7901. "word-spacing": "normal|<length-percentage>",
  7902. "word-wrap": "normal|break-word",
  7903. "writing-mode": "horizontal-tb|vertical-rl|vertical-lr|sideways-rl|sideways-lr|<svg-writing-mode>",
  7904. "z-index": "auto|<integer>",
  7905. "zoom": "normal|reset|<number>|<percentage>",
  7906. "-moz-background-clip": "padding|border",
  7907. "-moz-border-radius-bottomleft": "<'border-bottom-left-radius'>",
  7908. "-moz-border-radius-bottomright": "<'border-bottom-right-radius'>",
  7909. "-moz-border-radius-topleft": "<'border-top-left-radius'>",
  7910. "-moz-border-radius-topright": "<'border-bottom-right-radius'>",
  7911. "-moz-control-character-visibility": "visible|hidden",
  7912. "-moz-osx-font-smoothing": "auto|grayscale",
  7913. "-moz-user-select": "none|text|all|-moz-none",
  7914. "-ms-flex-align": "start|end|center|baseline|stretch",
  7915. "-ms-flex-item-align": "auto|start|end|center|baseline|stretch",
  7916. "-ms-flex-line-pack": "start|end|center|justify|distribute|stretch",
  7917. "-ms-flex-negative": "<'flex-shrink'>",
  7918. "-ms-flex-pack": "start|end|center|justify|distribute",
  7919. "-ms-flex-order": "<integer>",
  7920. "-ms-flex-positive": "<'flex-grow'>",
  7921. "-ms-flex-preferred-size": "<'flex-basis'>",
  7922. "-ms-interpolation-mode": "nearest-neighbor|bicubic",
  7923. "-ms-grid-column-align": "start|end|center|stretch",
  7924. "-ms-grid-row-align": "start|end|center|stretch",
  7925. "-ms-hyphenate-limit-last": "none|always|column|page|spread",
  7926. "-webkit-background-clip": "[<box>|border|padding|content|text]#",
  7927. "-webkit-column-break-after": "always|auto|avoid",
  7928. "-webkit-column-break-before": "always|auto|avoid",
  7929. "-webkit-column-break-inside": "always|auto|avoid",
  7930. "-webkit-font-smoothing": "auto|none|antialiased|subpixel-antialiased",
  7931. "-webkit-mask-box-image": "[<url>|<gradient>|none] [<length-percentage>{4} <-webkit-mask-box-repeat>{2}]?",
  7932. "-webkit-print-color-adjust": "economy|exact",
  7933. "-webkit-text-security": "none|circle|disc|square",
  7934. "-webkit-user-drag": "none|element|auto",
  7935. "-webkit-user-select": "auto|none|text|all",
  7936. "alignment-baseline": "auto|baseline|before-edge|text-before-edge|middle|central|after-edge|text-after-edge|ideographic|alphabetic|hanging|mathematical",
  7937. "baseline-shift": "baseline|sub|super|<svg-length>",
  7938. "behavior": "<url>+",
  7939. "clip-rule": "nonzero|evenodd",
  7940. "cue": "<'cue-before'> <'cue-after'>?",
  7941. "cue-after": "<url> <decibel>?|none",
  7942. "cue-before": "<url> <decibel>?|none",
  7943. "dominant-baseline": "auto|use-script|no-change|reset-size|ideographic|alphabetic|hanging|mathematical|central|middle|text-after-edge|text-before-edge",
  7944. "fill": "<paint>",
  7945. "fill-opacity": "<number-zero-one>",
  7946. "fill-rule": "nonzero|evenodd",
  7947. "glyph-orientation-horizontal": "<angle>",
  7948. "glyph-orientation-vertical": "<angle>",
  7949. "kerning": "auto|<svg-length>",
  7950. "marker": "none|<url>",
  7951. "marker-end": "none|<url>",
  7952. "marker-mid": "none|<url>",
  7953. "marker-start": "none|<url>",
  7954. "pause": "<'pause-before'> <'pause-after'>?",
  7955. "pause-after": "<time>|none|x-weak|weak|medium|strong|x-strong",
  7956. "pause-before": "<time>|none|x-weak|weak|medium|strong|x-strong",
  7957. "rest": "<'rest-before'> <'rest-after'>?",
  7958. "rest-after": "<time>|none|x-weak|weak|medium|strong|x-strong",
  7959. "rest-before": "<time>|none|x-weak|weak|medium|strong|x-strong",
  7960. "shape-rendering": "auto|optimizeSpeed|crispEdges|geometricPrecision",
  7961. "src": "[<url> [format( <string># )]?|local( <family-name> )]#",
  7962. "speak": "auto|none|normal",
  7963. "speak-as": "normal|spell-out||digits||[literal-punctuation|no-punctuation]",
  7964. "stroke": "<paint>",
  7965. "stroke-dasharray": "none|[<svg-length>+]#",
  7966. "stroke-dashoffset": "<svg-length>",
  7967. "stroke-linecap": "butt|round|square",
  7968. "stroke-linejoin": "miter|round|bevel",
  7969. "stroke-miterlimit": "<number-one-or-greater>",
  7970. "stroke-opacity": "<number-zero-one>",
  7971. "stroke-width": "<svg-length>",
  7972. "text-anchor": "start|middle|end",
  7973. "unicode-range": "<urange>#",
  7974. "voice-balance": "<number>|left|center|right|leftwards|rightwards",
  7975. "voice-duration": "auto|<time>",
  7976. "voice-family": "[[<family-name>|<generic-voice>] ,]* [<family-name>|<generic-voice>]|preserve",
  7977. "voice-pitch": "<frequency>&&absolute|[[x-low|low|medium|high|x-high]||[<frequency>|<semitones>|<percentage>]]",
  7978. "voice-range": "<frequency>&&absolute|[[x-low|low|medium|high|x-high]||[<frequency>|<semitones>|<percentage>]]",
  7979. "voice-rate": "[normal|x-slow|slow|medium|fast|x-fast]||<percentage>",
  7980. "voice-stress": "normal|strong|moderate|none|reduced",
  7981. "voice-volume": "silent|[[x-soft|soft|medium|loud|x-loud]||<decibel>]"
  7982. },
  7983. "atrules": {
  7984. "charset": {
  7985. "prelude": "<string>",
  7986. "descriptors": null
  7987. },
  7988. "counter-style": {
  7989. "prelude": "<counter-style-name>",
  7990. "descriptors": {
  7991. "additive-symbols": "[<integer>&&<symbol>]#",
  7992. "fallback": "<counter-style-name>",
  7993. "negative": "<symbol> <symbol>?",
  7994. "pad": "<integer>&&<symbol>",
  7995. "prefix": "<symbol>",
  7996. "range": "[[<integer>|infinite]{2}]#|auto",
  7997. "speak-as": "auto|bullets|numbers|words|spell-out|<counter-style-name>",
  7998. "suffix": "<symbol>",
  7999. "symbols": "<symbol>+",
  8000. "system": "cyclic|numeric|alphabetic|symbolic|additive|[fixed <integer>?]|[extends <counter-style-name>]"
  8001. }
  8002. },
  8003. "document": {
  8004. "prelude": "[<url>|url-prefix( <string> )|domain( <string> )|media-document( <string> )|regexp( <string> )]#",
  8005. "descriptors": null
  8006. },
  8007. "font-face": {
  8008. "prelude": null,
  8009. "descriptors": {
  8010. "font-display": "[auto|block|swap|fallback|optional]",
  8011. "font-family": "<family-name>",
  8012. "font-feature-settings": "normal|<feature-tag-value>#",
  8013. "font-variation-settings": "normal|[<string> <number>]#",
  8014. "font-stretch": "<font-stretch-absolute>{1,2}",
  8015. "font-style": "normal|italic|oblique <angle>{0,2}",
  8016. "font-weight": "<font-weight-absolute>{1,2}",
  8017. "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]",
  8018. "src": "[<url> [format( <string># )]?|local( <family-name> )]#",
  8019. "unicode-range": "<urange>#"
  8020. }
  8021. },
  8022. "font-feature-values": {
  8023. "prelude": "<family-name>#",
  8024. "descriptors": null
  8025. },
  8026. "import": {
  8027. "prelude": "[<string>|<url>] [<media-query-list>]?",
  8028. "descriptors": null
  8029. },
  8030. "keyframes": {
  8031. "prelude": "<keyframes-name>",
  8032. "descriptors": null
  8033. },
  8034. "media": {
  8035. "prelude": "<media-query-list>",
  8036. "descriptors": null
  8037. },
  8038. "namespace": {
  8039. "prelude": "<namespace-prefix>? [<string>|<url>]",
  8040. "descriptors": null
  8041. },
  8042. "page": {
  8043. "prelude": "<page-selector-list>",
  8044. "descriptors": {
  8045. "bleed": "auto|<length>",
  8046. "marks": "none|[crop||cross]",
  8047. "size": "<length>{1,2}|auto|[<page-size>||[portrait|landscape]]"
  8048. }
  8049. },
  8050. "property": {
  8051. "prelude": "<custom-property-name>",
  8052. "descriptors": {
  8053. "syntax": "<string>",
  8054. "inherits": "true|false",
  8055. "initial-value": "<string>"
  8056. }
  8057. },
  8058. "supports": {
  8059. "prelude": "<supports-condition>",
  8060. "descriptors": null
  8061. },
  8062. "viewport": {
  8063. "prelude": null,
  8064. "descriptors": {
  8065. "height": "<viewport-length>{1,2}",
  8066. "max-height": "<viewport-length>",
  8067. "max-width": "<viewport-length>",
  8068. "max-zoom": "auto|<number>|<percentage>",
  8069. "min-height": "<viewport-length>",
  8070. "min-width": "<viewport-length>",
  8071. "min-zoom": "auto|<number>|<percentage>",
  8072. "orientation": "auto|portrait|landscape",
  8073. "user-zoom": "zoom|fixed",
  8074. "viewport-fit": "auto|contain|cover",
  8075. "width": "<viewport-length>{1,2}",
  8076. "zoom": "auto|<number>|<percentage>"
  8077. }
  8078. }
  8079. }
  8080. };
  8081. var cmpChar$3 = tokenizer.cmpChar;
  8082. var isDigit$4 = tokenizer.isDigit;
  8083. var TYPE$9 = tokenizer.TYPE;
  8084. var WHITESPACE$4 = TYPE$9.WhiteSpace;
  8085. var COMMENT$4 = TYPE$9.Comment;
  8086. var IDENT$3 = TYPE$9.Ident;
  8087. var NUMBER$3 = TYPE$9.Number;
  8088. var DIMENSION$2 = TYPE$9.Dimension;
  8089. var PLUSSIGN$3 = 0x002B; // U+002B PLUS SIGN (+)
  8090. var HYPHENMINUS$3 = 0x002D; // U+002D HYPHEN-MINUS (-)
  8091. var N$4 = 0x006E; // U+006E LATIN SMALL LETTER N (n)
  8092. var DISALLOW_SIGN$1 = true;
  8093. var ALLOW_SIGN$1 = false;
  8094. function checkInteger$1(offset, disallowSign) {
  8095. var pos = this.scanner.tokenStart + offset;
  8096. var code = this.scanner.source.charCodeAt(pos);
  8097. if (code === PLUSSIGN$3 || code === HYPHENMINUS$3) {
  8098. if (disallowSign) {
  8099. this.error('Number sign is not allowed');
  8100. }
  8101. pos++;
  8102. }
  8103. for (; pos < this.scanner.tokenEnd; pos++) {
  8104. if (!isDigit$4(this.scanner.source.charCodeAt(pos))) {
  8105. this.error('Integer is expected', pos);
  8106. }
  8107. }
  8108. }
  8109. function checkTokenIsInteger(disallowSign) {
  8110. return checkInteger$1.call(this, 0, disallowSign);
  8111. }
  8112. function expectCharCode(offset, code) {
  8113. if (!cmpChar$3(this.scanner.source, this.scanner.tokenStart + offset, code)) {
  8114. var msg = '';
  8115. switch (code) {
  8116. case N$4:
  8117. msg = 'N is expected';
  8118. break;
  8119. case HYPHENMINUS$3:
  8120. msg = 'HyphenMinus is expected';
  8121. break;
  8122. }
  8123. this.error(msg, this.scanner.tokenStart + offset);
  8124. }
  8125. }
  8126. // ... <signed-integer>
  8127. // ... ['+' | '-'] <signless-integer>
  8128. function consumeB$1() {
  8129. var offset = 0;
  8130. var sign = 0;
  8131. var type = this.scanner.tokenType;
  8132. while (type === WHITESPACE$4 || type === COMMENT$4) {
  8133. type = this.scanner.lookupType(++offset);
  8134. }
  8135. if (type !== NUMBER$3) {
  8136. if (this.scanner.isDelim(PLUSSIGN$3, offset) ||
  8137. this.scanner.isDelim(HYPHENMINUS$3, offset)) {
  8138. sign = this.scanner.isDelim(PLUSSIGN$3, offset) ? PLUSSIGN$3 : HYPHENMINUS$3;
  8139. do {
  8140. type = this.scanner.lookupType(++offset);
  8141. } while (type === WHITESPACE$4 || type === COMMENT$4);
  8142. if (type !== NUMBER$3) {
  8143. this.scanner.skip(offset);
  8144. checkTokenIsInteger.call(this, DISALLOW_SIGN$1);
  8145. }
  8146. } else {
  8147. return null;
  8148. }
  8149. }
  8150. if (offset > 0) {
  8151. this.scanner.skip(offset);
  8152. }
  8153. if (sign === 0) {
  8154. type = this.scanner.source.charCodeAt(this.scanner.tokenStart);
  8155. if (type !== PLUSSIGN$3 && type !== HYPHENMINUS$3) {
  8156. this.error('Number sign is expected');
  8157. }
  8158. }
  8159. checkTokenIsInteger.call(this, sign !== 0);
  8160. return sign === HYPHENMINUS$3 ? '-' + this.consume(NUMBER$3) : this.consume(NUMBER$3);
  8161. }
  8162. // An+B microsyntax https://www.w3.org/TR/css-syntax-3/#anb
  8163. var AnPlusB = {
  8164. name: 'AnPlusB',
  8165. structure: {
  8166. a: [String, null],
  8167. b: [String, null]
  8168. },
  8169. parse: function() {
  8170. /* eslint-disable brace-style*/
  8171. var start = this.scanner.tokenStart;
  8172. var a = null;
  8173. var b = null;
  8174. // <integer>
  8175. if (this.scanner.tokenType === NUMBER$3) {
  8176. checkTokenIsInteger.call(this, ALLOW_SIGN$1);
  8177. b = this.consume(NUMBER$3);
  8178. }
  8179. // -n
  8180. // -n <signed-integer>
  8181. // -n ['+' | '-'] <signless-integer>
  8182. // -n- <signless-integer>
  8183. // <dashndashdigit-ident>
  8184. else if (this.scanner.tokenType === IDENT$3 && cmpChar$3(this.scanner.source, this.scanner.tokenStart, HYPHENMINUS$3)) {
  8185. a = '-1';
  8186. expectCharCode.call(this, 1, N$4);
  8187. switch (this.scanner.getTokenLength()) {
  8188. // -n
  8189. // -n <signed-integer>
  8190. // -n ['+' | '-'] <signless-integer>
  8191. case 2:
  8192. this.scanner.next();
  8193. b = consumeB$1.call(this);
  8194. break;
  8195. // -n- <signless-integer>
  8196. case 3:
  8197. expectCharCode.call(this, 2, HYPHENMINUS$3);
  8198. this.scanner.next();
  8199. this.scanner.skipSC();
  8200. checkTokenIsInteger.call(this, DISALLOW_SIGN$1);
  8201. b = '-' + this.consume(NUMBER$3);
  8202. break;
  8203. // <dashndashdigit-ident>
  8204. default:
  8205. expectCharCode.call(this, 2, HYPHENMINUS$3);
  8206. checkInteger$1.call(this, 3, DISALLOW_SIGN$1);
  8207. this.scanner.next();
  8208. b = this.scanner.substrToCursor(start + 2);
  8209. }
  8210. }
  8211. // '+'? n
  8212. // '+'? n <signed-integer>
  8213. // '+'? n ['+' | '-'] <signless-integer>
  8214. // '+'? n- <signless-integer>
  8215. // '+'? <ndashdigit-ident>
  8216. else if (this.scanner.tokenType === IDENT$3 || (this.scanner.isDelim(PLUSSIGN$3) && this.scanner.lookupType(1) === IDENT$3)) {
  8217. var sign = 0;
  8218. a = '1';
  8219. // just ignore a plus
  8220. if (this.scanner.isDelim(PLUSSIGN$3)) {
  8221. sign = 1;
  8222. this.scanner.next();
  8223. }
  8224. expectCharCode.call(this, 0, N$4);
  8225. switch (this.scanner.getTokenLength()) {
  8226. // '+'? n
  8227. // '+'? n <signed-integer>
  8228. // '+'? n ['+' | '-'] <signless-integer>
  8229. case 1:
  8230. this.scanner.next();
  8231. b = consumeB$1.call(this);
  8232. break;
  8233. // '+'? n- <signless-integer>
  8234. case 2:
  8235. expectCharCode.call(this, 1, HYPHENMINUS$3);
  8236. this.scanner.next();
  8237. this.scanner.skipSC();
  8238. checkTokenIsInteger.call(this, DISALLOW_SIGN$1);
  8239. b = '-' + this.consume(NUMBER$3);
  8240. break;
  8241. // '+'? <ndashdigit-ident>
  8242. default:
  8243. expectCharCode.call(this, 1, HYPHENMINUS$3);
  8244. checkInteger$1.call(this, 2, DISALLOW_SIGN$1);
  8245. this.scanner.next();
  8246. b = this.scanner.substrToCursor(start + sign + 1);
  8247. }
  8248. }
  8249. // <ndashdigit-dimension>
  8250. // <ndash-dimension> <signless-integer>
  8251. // <n-dimension>
  8252. // <n-dimension> <signed-integer>
  8253. // <n-dimension> ['+' | '-'] <signless-integer>
  8254. else if (this.scanner.tokenType === DIMENSION$2) {
  8255. var code = this.scanner.source.charCodeAt(this.scanner.tokenStart);
  8256. var sign = code === PLUSSIGN$3 || code === HYPHENMINUS$3;
  8257. for (var i = this.scanner.tokenStart + sign; i < this.scanner.tokenEnd; i++) {
  8258. if (!isDigit$4(this.scanner.source.charCodeAt(i))) {
  8259. break;
  8260. }
  8261. }
  8262. if (i === this.scanner.tokenStart + sign) {
  8263. this.error('Integer is expected', this.scanner.tokenStart + sign);
  8264. }
  8265. expectCharCode.call(this, i - this.scanner.tokenStart, N$4);
  8266. a = this.scanner.source.substring(start, i);
  8267. // <n-dimension>
  8268. // <n-dimension> <signed-integer>
  8269. // <n-dimension> ['+' | '-'] <signless-integer>
  8270. if (i + 1 === this.scanner.tokenEnd) {
  8271. this.scanner.next();
  8272. b = consumeB$1.call(this);
  8273. } else {
  8274. expectCharCode.call(this, i - this.scanner.tokenStart + 1, HYPHENMINUS$3);
  8275. // <ndash-dimension> <signless-integer>
  8276. if (i + 2 === this.scanner.tokenEnd) {
  8277. this.scanner.next();
  8278. this.scanner.skipSC();
  8279. checkTokenIsInteger.call(this, DISALLOW_SIGN$1);
  8280. b = '-' + this.consume(NUMBER$3);
  8281. }
  8282. // <ndashdigit-dimension>
  8283. else {
  8284. checkInteger$1.call(this, i - this.scanner.tokenStart + 2, DISALLOW_SIGN$1);
  8285. this.scanner.next();
  8286. b = this.scanner.substrToCursor(i + 1);
  8287. }
  8288. }
  8289. } else {
  8290. this.error();
  8291. }
  8292. if (a !== null && a.charCodeAt(0) === PLUSSIGN$3) {
  8293. a = a.substr(1);
  8294. }
  8295. if (b !== null && b.charCodeAt(0) === PLUSSIGN$3) {
  8296. b = b.substr(1);
  8297. }
  8298. return {
  8299. type: 'AnPlusB',
  8300. loc: this.getLocation(start, this.scanner.tokenStart),
  8301. a: a,
  8302. b: b
  8303. };
  8304. },
  8305. generate: function(node) {
  8306. var a = node.a !== null && node.a !== undefined;
  8307. var b = node.b !== null && node.b !== undefined;
  8308. if (a) {
  8309. this.chunk(
  8310. node.a === '+1' ? '+n' : // eslint-disable-line operator-linebreak, indent
  8311. node.a === '1' ? 'n' : // eslint-disable-line operator-linebreak, indent
  8312. node.a === '-1' ? '-n' : // eslint-disable-line operator-linebreak, indent
  8313. node.a + 'n' // eslint-disable-line operator-linebreak, indent
  8314. );
  8315. if (b) {
  8316. b = String(node.b);
  8317. if (b.charAt(0) === '-' || b.charAt(0) === '+') {
  8318. this.chunk(b.charAt(0));
  8319. this.chunk(b.substr(1));
  8320. } else {
  8321. this.chunk('+');
  8322. this.chunk(b);
  8323. }
  8324. }
  8325. } else {
  8326. this.chunk(String(node.b));
  8327. }
  8328. }
  8329. };
  8330. var TYPE$a = tokenizer.TYPE;
  8331. var WhiteSpace = TYPE$a.WhiteSpace;
  8332. var Semicolon = TYPE$a.Semicolon;
  8333. var LeftCurlyBracket = TYPE$a.LeftCurlyBracket;
  8334. var Delim = TYPE$a.Delim;
  8335. var EXCLAMATIONMARK$1 = 0x0021; // U+0021 EXCLAMATION MARK (!)
  8336. function getOffsetExcludeWS() {
  8337. if (this.scanner.tokenIndex > 0) {
  8338. if (this.scanner.lookupType(-1) === WhiteSpace) {
  8339. return this.scanner.tokenIndex > 1
  8340. ? this.scanner.getTokenStart(this.scanner.tokenIndex - 1)
  8341. : this.scanner.firstCharOffset;
  8342. }
  8343. }
  8344. return this.scanner.tokenStart;
  8345. }
  8346. // 0, 0, false
  8347. function balanceEnd() {
  8348. return 0;
  8349. }
  8350. // LEFTCURLYBRACKET, 0, false
  8351. function leftCurlyBracket(tokenType) {
  8352. return tokenType === LeftCurlyBracket ? 1 : 0;
  8353. }
  8354. // LEFTCURLYBRACKET, SEMICOLON, false
  8355. function leftCurlyBracketOrSemicolon(tokenType) {
  8356. return tokenType === LeftCurlyBracket || tokenType === Semicolon ? 1 : 0;
  8357. }
  8358. // EXCLAMATIONMARK, SEMICOLON, false
  8359. function exclamationMarkOrSemicolon(tokenType, source, offset) {
  8360. if (tokenType === Delim && source.charCodeAt(offset) === EXCLAMATIONMARK$1) {
  8361. return 1;
  8362. }
  8363. return tokenType === Semicolon ? 1 : 0;
  8364. }
  8365. // 0, SEMICOLON, true
  8366. function semicolonIncluded(tokenType) {
  8367. return tokenType === Semicolon ? 2 : 0;
  8368. }
  8369. var Raw = {
  8370. name: 'Raw',
  8371. structure: {
  8372. value: String
  8373. },
  8374. parse: function(startToken, mode, excludeWhiteSpace) {
  8375. var startOffset = this.scanner.getTokenStart(startToken);
  8376. var endOffset;
  8377. this.scanner.skip(
  8378. this.scanner.getRawLength(startToken, mode || balanceEnd)
  8379. );
  8380. if (excludeWhiteSpace && this.scanner.tokenStart > startOffset) {
  8381. endOffset = getOffsetExcludeWS.call(this);
  8382. } else {
  8383. endOffset = this.scanner.tokenStart;
  8384. }
  8385. return {
  8386. type: 'Raw',
  8387. loc: this.getLocation(startOffset, endOffset),
  8388. value: this.scanner.source.substring(startOffset, endOffset)
  8389. };
  8390. },
  8391. generate: function(node) {
  8392. this.chunk(node.value);
  8393. },
  8394. mode: {
  8395. default: balanceEnd,
  8396. leftCurlyBracket: leftCurlyBracket,
  8397. leftCurlyBracketOrSemicolon: leftCurlyBracketOrSemicolon,
  8398. exclamationMarkOrSemicolon: exclamationMarkOrSemicolon,
  8399. semicolonIncluded: semicolonIncluded
  8400. }
  8401. };
  8402. var TYPE$b = tokenizer.TYPE;
  8403. var rawMode = Raw.mode;
  8404. var ATKEYWORD = TYPE$b.AtKeyword;
  8405. var SEMICOLON = TYPE$b.Semicolon;
  8406. var LEFTCURLYBRACKET$1 = TYPE$b.LeftCurlyBracket;
  8407. var RIGHTCURLYBRACKET$1 = TYPE$b.RightCurlyBracket;
  8408. function consumeRaw(startToken) {
  8409. return this.Raw(startToken, rawMode.leftCurlyBracketOrSemicolon, true);
  8410. }
  8411. function isDeclarationBlockAtrule() {
  8412. for (var offset = 1, type; type = this.scanner.lookupType(offset); offset++) {
  8413. if (type === RIGHTCURLYBRACKET$1) {
  8414. return true;
  8415. }
  8416. if (type === LEFTCURLYBRACKET$1 ||
  8417. type === ATKEYWORD) {
  8418. return false;
  8419. }
  8420. }
  8421. return false;
  8422. }
  8423. var Atrule = {
  8424. name: 'Atrule',
  8425. structure: {
  8426. name: String,
  8427. prelude: ['AtrulePrelude', 'Raw', null],
  8428. block: ['Block', null]
  8429. },
  8430. parse: function() {
  8431. var start = this.scanner.tokenStart;
  8432. var name;
  8433. var nameLowerCase;
  8434. var prelude = null;
  8435. var block = null;
  8436. this.eat(ATKEYWORD);
  8437. name = this.scanner.substrToCursor(start + 1);
  8438. nameLowerCase = name.toLowerCase();
  8439. this.scanner.skipSC();
  8440. // parse prelude
  8441. if (this.scanner.eof === false &&
  8442. this.scanner.tokenType !== LEFTCURLYBRACKET$1 &&
  8443. this.scanner.tokenType !== SEMICOLON) {
  8444. if (this.parseAtrulePrelude) {
  8445. prelude = this.parseWithFallback(this.AtrulePrelude.bind(this, name), consumeRaw);
  8446. // turn empty AtrulePrelude into null
  8447. if (prelude.type === 'AtrulePrelude' && prelude.children.head === null) {
  8448. prelude = null;
  8449. }
  8450. } else {
  8451. prelude = consumeRaw.call(this, this.scanner.tokenIndex);
  8452. }
  8453. this.scanner.skipSC();
  8454. }
  8455. switch (this.scanner.tokenType) {
  8456. case SEMICOLON:
  8457. this.scanner.next();
  8458. break;
  8459. case LEFTCURLYBRACKET$1:
  8460. if (this.atrule.hasOwnProperty(nameLowerCase) &&
  8461. typeof this.atrule[nameLowerCase].block === 'function') {
  8462. block = this.atrule[nameLowerCase].block.call(this);
  8463. } else {
  8464. // TODO: should consume block content as Raw?
  8465. block = this.Block(isDeclarationBlockAtrule.call(this));
  8466. }
  8467. break;
  8468. }
  8469. return {
  8470. type: 'Atrule',
  8471. loc: this.getLocation(start, this.scanner.tokenStart),
  8472. name: name,
  8473. prelude: prelude,
  8474. block: block
  8475. };
  8476. },
  8477. generate: function(node) {
  8478. this.chunk('@');
  8479. this.chunk(node.name);
  8480. if (node.prelude !== null) {
  8481. this.chunk(' ');
  8482. this.node(node.prelude);
  8483. }
  8484. if (node.block) {
  8485. this.node(node.block);
  8486. } else {
  8487. this.chunk(';');
  8488. }
  8489. },
  8490. walkContext: 'atrule'
  8491. };
  8492. var TYPE$c = tokenizer.TYPE;
  8493. var SEMICOLON$1 = TYPE$c.Semicolon;
  8494. var LEFTCURLYBRACKET$2 = TYPE$c.LeftCurlyBracket;
  8495. var AtrulePrelude = {
  8496. name: 'AtrulePrelude',
  8497. structure: {
  8498. children: [[]]
  8499. },
  8500. parse: function(name) {
  8501. var children = null;
  8502. if (name !== null) {
  8503. name = name.toLowerCase();
  8504. }
  8505. this.scanner.skipSC();
  8506. if (this.atrule.hasOwnProperty(name) &&
  8507. typeof this.atrule[name].prelude === 'function') {
  8508. // custom consumer
  8509. children = this.atrule[name].prelude.call(this);
  8510. } else {
  8511. // default consumer
  8512. children = this.readSequence(this.scope.AtrulePrelude);
  8513. }
  8514. this.scanner.skipSC();
  8515. if (this.scanner.eof !== true &&
  8516. this.scanner.tokenType !== LEFTCURLYBRACKET$2 &&
  8517. this.scanner.tokenType !== SEMICOLON$1) {
  8518. this.error('Semicolon or block is expected');
  8519. }
  8520. if (children === null) {
  8521. children = this.createList();
  8522. }
  8523. return {
  8524. type: 'AtrulePrelude',
  8525. loc: this.getLocationFromList(children),
  8526. children: children
  8527. };
  8528. },
  8529. generate: function(node) {
  8530. this.children(node);
  8531. },
  8532. walkContext: 'atrulePrelude'
  8533. };
  8534. var TYPE$d = tokenizer.TYPE;
  8535. var IDENT$4 = TYPE$d.Ident;
  8536. var STRING = TYPE$d.String;
  8537. var COLON = TYPE$d.Colon;
  8538. var LEFTSQUAREBRACKET$1 = TYPE$d.LeftSquareBracket;
  8539. var RIGHTSQUAREBRACKET$1 = TYPE$d.RightSquareBracket;
  8540. var DOLLARSIGN = 0x0024; // U+0024 DOLLAR SIGN ($)
  8541. var ASTERISK$1 = 0x002A; // U+002A ASTERISK (*)
  8542. var EQUALSSIGN = 0x003D; // U+003D EQUALS SIGN (=)
  8543. var CIRCUMFLEXACCENT = 0x005E; // U+005E (^)
  8544. var VERTICALLINE$1 = 0x007C; // U+007C VERTICAL LINE (|)
  8545. var TILDE = 0x007E; // U+007E TILDE (~)
  8546. function getAttributeName() {
  8547. if (this.scanner.eof) {
  8548. this.error('Unexpected end of input');
  8549. }
  8550. var start = this.scanner.tokenStart;
  8551. var expectIdent = false;
  8552. var checkColon = true;
  8553. if (this.scanner.isDelim(ASTERISK$1)) {
  8554. expectIdent = true;
  8555. checkColon = false;
  8556. this.scanner.next();
  8557. } else if (!this.scanner.isDelim(VERTICALLINE$1)) {
  8558. this.eat(IDENT$4);
  8559. }
  8560. if (this.scanner.isDelim(VERTICALLINE$1)) {
  8561. if (this.scanner.source.charCodeAt(this.scanner.tokenStart + 1) !== EQUALSSIGN) {
  8562. this.scanner.next();
  8563. this.eat(IDENT$4);
  8564. } else if (expectIdent) {
  8565. this.error('Identifier is expected', this.scanner.tokenEnd);
  8566. }
  8567. } else if (expectIdent) {
  8568. this.error('Vertical line is expected');
  8569. }
  8570. if (checkColon && this.scanner.tokenType === COLON) {
  8571. this.scanner.next();
  8572. this.eat(IDENT$4);
  8573. }
  8574. return {
  8575. type: 'Identifier',
  8576. loc: this.getLocation(start, this.scanner.tokenStart),
  8577. name: this.scanner.substrToCursor(start)
  8578. };
  8579. }
  8580. function getOperator() {
  8581. var start = this.scanner.tokenStart;
  8582. var code = this.scanner.source.charCodeAt(start);
  8583. if (code !== EQUALSSIGN && // =
  8584. code !== TILDE && // ~=
  8585. code !== CIRCUMFLEXACCENT && // ^=
  8586. code !== DOLLARSIGN && // $=
  8587. code !== ASTERISK$1 && // *=
  8588. code !== VERTICALLINE$1 // |=
  8589. ) {
  8590. this.error('Attribute selector (=, ~=, ^=, $=, *=, |=) is expected');
  8591. }
  8592. this.scanner.next();
  8593. if (code !== EQUALSSIGN) {
  8594. if (!this.scanner.isDelim(EQUALSSIGN)) {
  8595. this.error('Equal sign is expected');
  8596. }
  8597. this.scanner.next();
  8598. }
  8599. return this.scanner.substrToCursor(start);
  8600. }
  8601. // '[' <wq-name> ']'
  8602. // '[' <wq-name> <attr-matcher> [ <string-token> | <ident-token> ] <attr-modifier>? ']'
  8603. var AttributeSelector = {
  8604. name: 'AttributeSelector',
  8605. structure: {
  8606. name: 'Identifier',
  8607. matcher: [String, null],
  8608. value: ['String', 'Identifier', null],
  8609. flags: [String, null]
  8610. },
  8611. parse: function() {
  8612. var start = this.scanner.tokenStart;
  8613. var name;
  8614. var matcher = null;
  8615. var value = null;
  8616. var flags = null;
  8617. this.eat(LEFTSQUAREBRACKET$1);
  8618. this.scanner.skipSC();
  8619. name = getAttributeName.call(this);
  8620. this.scanner.skipSC();
  8621. if (this.scanner.tokenType !== RIGHTSQUAREBRACKET$1) {
  8622. // avoid case `[name i]`
  8623. if (this.scanner.tokenType !== IDENT$4) {
  8624. matcher = getOperator.call(this);
  8625. this.scanner.skipSC();
  8626. value = this.scanner.tokenType === STRING
  8627. ? this.String()
  8628. : this.Identifier();
  8629. this.scanner.skipSC();
  8630. }
  8631. // attribute flags
  8632. if (this.scanner.tokenType === IDENT$4) {
  8633. flags = this.scanner.getTokenValue();
  8634. this.scanner.next();
  8635. this.scanner.skipSC();
  8636. }
  8637. }
  8638. this.eat(RIGHTSQUAREBRACKET$1);
  8639. return {
  8640. type: 'AttributeSelector',
  8641. loc: this.getLocation(start, this.scanner.tokenStart),
  8642. name: name,
  8643. matcher: matcher,
  8644. value: value,
  8645. flags: flags
  8646. };
  8647. },
  8648. generate: function(node) {
  8649. var flagsPrefix = ' ';
  8650. this.chunk('[');
  8651. this.node(node.name);
  8652. if (node.matcher !== null) {
  8653. this.chunk(node.matcher);
  8654. if (node.value !== null) {
  8655. this.node(node.value);
  8656. // space between string and flags is not required
  8657. if (node.value.type === 'String') {
  8658. flagsPrefix = '';
  8659. }
  8660. }
  8661. }
  8662. if (node.flags !== null) {
  8663. this.chunk(flagsPrefix);
  8664. this.chunk(node.flags);
  8665. }
  8666. this.chunk(']');
  8667. }
  8668. };
  8669. var TYPE$e = tokenizer.TYPE;
  8670. var rawMode$1 = Raw.mode;
  8671. var WHITESPACE$5 = TYPE$e.WhiteSpace;
  8672. var COMMENT$5 = TYPE$e.Comment;
  8673. var SEMICOLON$2 = TYPE$e.Semicolon;
  8674. var ATKEYWORD$1 = TYPE$e.AtKeyword;
  8675. var LEFTCURLYBRACKET$3 = TYPE$e.LeftCurlyBracket;
  8676. var RIGHTCURLYBRACKET$2 = TYPE$e.RightCurlyBracket;
  8677. function consumeRaw$1(startToken) {
  8678. return this.Raw(startToken, null, true);
  8679. }
  8680. function consumeRule() {
  8681. return this.parseWithFallback(this.Rule, consumeRaw$1);
  8682. }
  8683. function consumeRawDeclaration(startToken) {
  8684. return this.Raw(startToken, rawMode$1.semicolonIncluded, true);
  8685. }
  8686. function consumeDeclaration() {
  8687. if (this.scanner.tokenType === SEMICOLON$2) {
  8688. return consumeRawDeclaration.call(this, this.scanner.tokenIndex);
  8689. }
  8690. var node = this.parseWithFallback(this.Declaration, consumeRawDeclaration);
  8691. if (this.scanner.tokenType === SEMICOLON$2) {
  8692. this.scanner.next();
  8693. }
  8694. return node;
  8695. }
  8696. var Block = {
  8697. name: 'Block',
  8698. structure: {
  8699. children: [[
  8700. 'Atrule',
  8701. 'Rule',
  8702. 'Declaration'
  8703. ]]
  8704. },
  8705. parse: function(isDeclaration) {
  8706. var consumer = isDeclaration ? consumeDeclaration : consumeRule;
  8707. var start = this.scanner.tokenStart;
  8708. var children = this.createList();
  8709. this.eat(LEFTCURLYBRACKET$3);
  8710. scan:
  8711. while (!this.scanner.eof) {
  8712. switch (this.scanner.tokenType) {
  8713. case RIGHTCURLYBRACKET$2:
  8714. break scan;
  8715. case WHITESPACE$5:
  8716. case COMMENT$5:
  8717. this.scanner.next();
  8718. break;
  8719. case ATKEYWORD$1:
  8720. children.push(this.parseWithFallback(this.Atrule, consumeRaw$1));
  8721. break;
  8722. default:
  8723. children.push(consumer.call(this));
  8724. }
  8725. }
  8726. if (!this.scanner.eof) {
  8727. this.eat(RIGHTCURLYBRACKET$2);
  8728. }
  8729. return {
  8730. type: 'Block',
  8731. loc: this.getLocation(start, this.scanner.tokenStart),
  8732. children: children
  8733. };
  8734. },
  8735. generate: function(node) {
  8736. this.chunk('{');
  8737. this.children(node, function(prev) {
  8738. if (prev.type === 'Declaration') {
  8739. this.chunk(';');
  8740. }
  8741. });
  8742. this.chunk('}');
  8743. },
  8744. walkContext: 'block'
  8745. };
  8746. var TYPE$f = tokenizer.TYPE;
  8747. var LEFTSQUAREBRACKET$2 = TYPE$f.LeftSquareBracket;
  8748. var RIGHTSQUAREBRACKET$2 = TYPE$f.RightSquareBracket;
  8749. var Brackets = {
  8750. name: 'Brackets',
  8751. structure: {
  8752. children: [[]]
  8753. },
  8754. parse: function(readSequence, recognizer) {
  8755. var start = this.scanner.tokenStart;
  8756. var children = null;
  8757. this.eat(LEFTSQUAREBRACKET$2);
  8758. children = readSequence.call(this, recognizer);
  8759. if (!this.scanner.eof) {
  8760. this.eat(RIGHTSQUAREBRACKET$2);
  8761. }
  8762. return {
  8763. type: 'Brackets',
  8764. loc: this.getLocation(start, this.scanner.tokenStart),
  8765. children: children
  8766. };
  8767. },
  8768. generate: function(node) {
  8769. this.chunk('[');
  8770. this.children(node);
  8771. this.chunk(']');
  8772. }
  8773. };
  8774. var CDC = tokenizer.TYPE.CDC;
  8775. var CDC_1 = {
  8776. name: 'CDC',
  8777. structure: [],
  8778. parse: function() {
  8779. var start = this.scanner.tokenStart;
  8780. this.eat(CDC); // -->
  8781. return {
  8782. type: 'CDC',
  8783. loc: this.getLocation(start, this.scanner.tokenStart)
  8784. };
  8785. },
  8786. generate: function() {
  8787. this.chunk('-->');
  8788. }
  8789. };
  8790. var CDO = tokenizer.TYPE.CDO;
  8791. var CDO_1 = {
  8792. name: 'CDO',
  8793. structure: [],
  8794. parse: function() {
  8795. var start = this.scanner.tokenStart;
  8796. this.eat(CDO); // <!--
  8797. return {
  8798. type: 'CDO',
  8799. loc: this.getLocation(start, this.scanner.tokenStart)
  8800. };
  8801. },
  8802. generate: function() {
  8803. this.chunk('<!--');
  8804. }
  8805. };
  8806. var TYPE$g = tokenizer.TYPE;
  8807. var IDENT$5 = TYPE$g.Ident;
  8808. var FULLSTOP = 0x002E; // U+002E FULL STOP (.)
  8809. // '.' ident
  8810. var ClassSelector = {
  8811. name: 'ClassSelector',
  8812. structure: {
  8813. name: String
  8814. },
  8815. parse: function() {
  8816. if (!this.scanner.isDelim(FULLSTOP)) {
  8817. this.error('Full stop is expected');
  8818. }
  8819. this.scanner.next();
  8820. return {
  8821. type: 'ClassSelector',
  8822. loc: this.getLocation(this.scanner.tokenStart - 1, this.scanner.tokenEnd),
  8823. name: this.consume(IDENT$5)
  8824. };
  8825. },
  8826. generate: function(node) {
  8827. this.chunk('.');
  8828. this.chunk(node.name);
  8829. }
  8830. };
  8831. var TYPE$h = tokenizer.TYPE;
  8832. var IDENT$6 = TYPE$h.Ident;
  8833. var PLUSSIGN$4 = 0x002B; // U+002B PLUS SIGN (+)
  8834. var SOLIDUS = 0x002F; // U+002F SOLIDUS (/)
  8835. var GREATERTHANSIGN$1 = 0x003E; // U+003E GREATER-THAN SIGN (>)
  8836. var TILDE$1 = 0x007E; // U+007E TILDE (~)
  8837. // + | > | ~ | /deep/
  8838. var Combinator = {
  8839. name: 'Combinator',
  8840. structure: {
  8841. name: String
  8842. },
  8843. parse: function() {
  8844. var start = this.scanner.tokenStart;
  8845. var code = this.scanner.source.charCodeAt(this.scanner.tokenStart);
  8846. switch (code) {
  8847. case GREATERTHANSIGN$1:
  8848. case PLUSSIGN$4:
  8849. case TILDE$1:
  8850. this.scanner.next();
  8851. break;
  8852. case SOLIDUS:
  8853. this.scanner.next();
  8854. if (this.scanner.tokenType !== IDENT$6 || this.scanner.lookupValue(0, 'deep') === false) {
  8855. this.error('Identifier `deep` is expected');
  8856. }
  8857. this.scanner.next();
  8858. if (!this.scanner.isDelim(SOLIDUS)) {
  8859. this.error('Solidus is expected');
  8860. }
  8861. this.scanner.next();
  8862. break;
  8863. default:
  8864. this.error('Combinator is expected');
  8865. }
  8866. return {
  8867. type: 'Combinator',
  8868. loc: this.getLocation(start, this.scanner.tokenStart),
  8869. name: this.scanner.substrToCursor(start)
  8870. };
  8871. },
  8872. generate: function(node) {
  8873. this.chunk(node.name);
  8874. }
  8875. };
  8876. var TYPE$i = tokenizer.TYPE;
  8877. var COMMENT$6 = TYPE$i.Comment;
  8878. var ASTERISK$2 = 0x002A; // U+002A ASTERISK (*)
  8879. var SOLIDUS$1 = 0x002F; // U+002F SOLIDUS (/)
  8880. // '/*' .* '*/'
  8881. var Comment = {
  8882. name: 'Comment',
  8883. structure: {
  8884. value: String
  8885. },
  8886. parse: function() {
  8887. var start = this.scanner.tokenStart;
  8888. var end = this.scanner.tokenEnd;
  8889. this.eat(COMMENT$6);
  8890. if ((end - start + 2) >= 2 &&
  8891. this.scanner.source.charCodeAt(end - 2) === ASTERISK$2 &&
  8892. this.scanner.source.charCodeAt(end - 1) === SOLIDUS$1) {
  8893. end -= 2;
  8894. }
  8895. return {
  8896. type: 'Comment',
  8897. loc: this.getLocation(start, this.scanner.tokenStart),
  8898. value: this.scanner.source.substring(start + 2, end)
  8899. };
  8900. },
  8901. generate: function(node) {
  8902. this.chunk('/*');
  8903. this.chunk(node.value);
  8904. this.chunk('*/');
  8905. }
  8906. };
  8907. var isCustomProperty$1 = names.isCustomProperty;
  8908. var TYPE$j = tokenizer.TYPE;
  8909. var rawMode$2 = Raw.mode;
  8910. var IDENT$7 = TYPE$j.Ident;
  8911. var HASH$1 = TYPE$j.Hash;
  8912. var COLON$1 = TYPE$j.Colon;
  8913. var SEMICOLON$3 = TYPE$j.Semicolon;
  8914. var DELIM$2 = TYPE$j.Delim;
  8915. var WHITESPACE$6 = TYPE$j.WhiteSpace;
  8916. var EXCLAMATIONMARK$2 = 0x0021; // U+0021 EXCLAMATION MARK (!)
  8917. var NUMBERSIGN$2 = 0x0023; // U+0023 NUMBER SIGN (#)
  8918. var DOLLARSIGN$1 = 0x0024; // U+0024 DOLLAR SIGN ($)
  8919. var AMPERSAND$1 = 0x0026; // U+0026 ANPERSAND (&)
  8920. var ASTERISK$3 = 0x002A; // U+002A ASTERISK (*)
  8921. var PLUSSIGN$5 = 0x002B; // U+002B PLUS SIGN (+)
  8922. var SOLIDUS$2 = 0x002F; // U+002F SOLIDUS (/)
  8923. function consumeValueRaw(startToken) {
  8924. return this.Raw(startToken, rawMode$2.exclamationMarkOrSemicolon, true);
  8925. }
  8926. function consumeCustomPropertyRaw(startToken) {
  8927. return this.Raw(startToken, rawMode$2.exclamationMarkOrSemicolon, false);
  8928. }
  8929. function consumeValue() {
  8930. var startValueToken = this.scanner.tokenIndex;
  8931. var value = this.Value();
  8932. if (value.type !== 'Raw' &&
  8933. this.scanner.eof === false &&
  8934. this.scanner.tokenType !== SEMICOLON$3 &&
  8935. this.scanner.isDelim(EXCLAMATIONMARK$2) === false &&
  8936. this.scanner.isBalanceEdge(startValueToken) === false) {
  8937. this.error();
  8938. }
  8939. return value;
  8940. }
  8941. var Declaration = {
  8942. name: 'Declaration',
  8943. structure: {
  8944. important: [Boolean, String],
  8945. property: String,
  8946. value: ['Value', 'Raw']
  8947. },
  8948. parse: function() {
  8949. var start = this.scanner.tokenStart;
  8950. var startToken = this.scanner.tokenIndex;
  8951. var property = readProperty$1.call(this);
  8952. var customProperty = isCustomProperty$1(property);
  8953. var parseValue = customProperty ? this.parseCustomProperty : this.parseValue;
  8954. var consumeRaw = customProperty ? consumeCustomPropertyRaw : consumeValueRaw;
  8955. var important = false;
  8956. var value;
  8957. this.scanner.skipSC();
  8958. this.eat(COLON$1);
  8959. const valueStart = this.scanner.tokenIndex;
  8960. if (!customProperty) {
  8961. this.scanner.skipSC();
  8962. }
  8963. if (parseValue) {
  8964. value = this.parseWithFallback(consumeValue, consumeRaw);
  8965. } else {
  8966. value = consumeRaw.call(this, this.scanner.tokenIndex);
  8967. }
  8968. if (customProperty && value.type === 'Value' && value.children.isEmpty()) {
  8969. for (let offset = valueStart - this.scanner.tokenIndex; offset <= 0; offset++) {
  8970. if (this.scanner.lookupType(offset) === WHITESPACE$6) {
  8971. value.children.appendData({
  8972. type: 'WhiteSpace',
  8973. loc: null,
  8974. value: ' '
  8975. });
  8976. break;
  8977. }
  8978. }
  8979. }
  8980. if (this.scanner.isDelim(EXCLAMATIONMARK$2)) {
  8981. important = getImportant.call(this);
  8982. this.scanner.skipSC();
  8983. }
  8984. // Do not include semicolon to range per spec
  8985. // https://drafts.csswg.org/css-syntax/#declaration-diagram
  8986. if (this.scanner.eof === false &&
  8987. this.scanner.tokenType !== SEMICOLON$3 &&
  8988. this.scanner.isBalanceEdge(startToken) === false) {
  8989. this.error();
  8990. }
  8991. return {
  8992. type: 'Declaration',
  8993. loc: this.getLocation(start, this.scanner.tokenStart),
  8994. important: important,
  8995. property: property,
  8996. value: value
  8997. };
  8998. },
  8999. generate: function(node) {
  9000. this.chunk(node.property);
  9001. this.chunk(':');
  9002. this.node(node.value);
  9003. if (node.important) {
  9004. this.chunk(node.important === true ? '!important' : '!' + node.important);
  9005. }
  9006. },
  9007. walkContext: 'declaration'
  9008. };
  9009. function readProperty$1() {
  9010. var start = this.scanner.tokenStart;
  9011. // hacks
  9012. if (this.scanner.tokenType === DELIM$2) {
  9013. switch (this.scanner.source.charCodeAt(this.scanner.tokenStart)) {
  9014. case ASTERISK$3:
  9015. case DOLLARSIGN$1:
  9016. case PLUSSIGN$5:
  9017. case NUMBERSIGN$2:
  9018. case AMPERSAND$1:
  9019. this.scanner.next();
  9020. break;
  9021. // TODO: not sure we should support this hack
  9022. case SOLIDUS$2:
  9023. this.scanner.next();
  9024. if (this.scanner.isDelim(SOLIDUS$2)) {
  9025. this.scanner.next();
  9026. }
  9027. break;
  9028. }
  9029. }
  9030. if (this.scanner.tokenType === HASH$1) {
  9031. this.eat(HASH$1);
  9032. } else {
  9033. this.eat(IDENT$7);
  9034. }
  9035. return this.scanner.substrToCursor(start);
  9036. }
  9037. // ! ws* important
  9038. function getImportant() {
  9039. this.eat(DELIM$2);
  9040. this.scanner.skipSC();
  9041. var important = this.consume(IDENT$7);
  9042. // store original value in case it differ from `important`
  9043. // for better original source restoring and hacks like `!ie` support
  9044. return important === 'important' ? true : important;
  9045. }
  9046. var TYPE$k = tokenizer.TYPE;
  9047. var rawMode$3 = Raw.mode;
  9048. var WHITESPACE$7 = TYPE$k.WhiteSpace;
  9049. var COMMENT$7 = TYPE$k.Comment;
  9050. var SEMICOLON$4 = TYPE$k.Semicolon;
  9051. function consumeRaw$2(startToken) {
  9052. return this.Raw(startToken, rawMode$3.semicolonIncluded, true);
  9053. }
  9054. var DeclarationList = {
  9055. name: 'DeclarationList',
  9056. structure: {
  9057. children: [[
  9058. 'Declaration'
  9059. ]]
  9060. },
  9061. parse: function() {
  9062. var children = this.createList();
  9063. while (!this.scanner.eof) {
  9064. switch (this.scanner.tokenType) {
  9065. case WHITESPACE$7:
  9066. case COMMENT$7:
  9067. case SEMICOLON$4:
  9068. this.scanner.next();
  9069. break;
  9070. default:
  9071. children.push(this.parseWithFallback(this.Declaration, consumeRaw$2));
  9072. }
  9073. }
  9074. return {
  9075. type: 'DeclarationList',
  9076. loc: this.getLocationFromList(children),
  9077. children: children
  9078. };
  9079. },
  9080. generate: function(node) {
  9081. this.children(node, function(prev) {
  9082. if (prev.type === 'Declaration') {
  9083. this.chunk(';');
  9084. }
  9085. });
  9086. }
  9087. };
  9088. var consumeNumber$3 = utils.consumeNumber;
  9089. var TYPE$l = tokenizer.TYPE;
  9090. var DIMENSION$3 = TYPE$l.Dimension;
  9091. var Dimension = {
  9092. name: 'Dimension',
  9093. structure: {
  9094. value: String,
  9095. unit: String
  9096. },
  9097. parse: function() {
  9098. var start = this.scanner.tokenStart;
  9099. var numberEnd = consumeNumber$3(this.scanner.source, start);
  9100. this.eat(DIMENSION$3);
  9101. return {
  9102. type: 'Dimension',
  9103. loc: this.getLocation(start, this.scanner.tokenStart),
  9104. value: this.scanner.source.substring(start, numberEnd),
  9105. unit: this.scanner.source.substring(numberEnd, this.scanner.tokenStart)
  9106. };
  9107. },
  9108. generate: function(node) {
  9109. this.chunk(node.value);
  9110. this.chunk(node.unit);
  9111. }
  9112. };
  9113. var TYPE$m = tokenizer.TYPE;
  9114. var RIGHTPARENTHESIS$2 = TYPE$m.RightParenthesis;
  9115. // <function-token> <sequence> )
  9116. var _Function = {
  9117. name: 'Function',
  9118. structure: {
  9119. name: String,
  9120. children: [[]]
  9121. },
  9122. parse: function(readSequence, recognizer) {
  9123. var start = this.scanner.tokenStart;
  9124. var name = this.consumeFunctionName();
  9125. var nameLowerCase = name.toLowerCase();
  9126. var children;
  9127. children = recognizer.hasOwnProperty(nameLowerCase)
  9128. ? recognizer[nameLowerCase].call(this, recognizer)
  9129. : readSequence.call(this, recognizer);
  9130. if (!this.scanner.eof) {
  9131. this.eat(RIGHTPARENTHESIS$2);
  9132. }
  9133. return {
  9134. type: 'Function',
  9135. loc: this.getLocation(start, this.scanner.tokenStart),
  9136. name: name,
  9137. children: children
  9138. };
  9139. },
  9140. generate: function(node) {
  9141. this.chunk(node.name);
  9142. this.chunk('(');
  9143. this.children(node);
  9144. this.chunk(')');
  9145. },
  9146. walkContext: 'function'
  9147. };
  9148. var TYPE$n = tokenizer.TYPE;
  9149. var HASH$2 = TYPE$n.Hash;
  9150. // '#' ident
  9151. var Hash = {
  9152. name: 'Hash',
  9153. structure: {
  9154. value: String
  9155. },
  9156. parse: function() {
  9157. var start = this.scanner.tokenStart;
  9158. this.eat(HASH$2);
  9159. return {
  9160. type: 'Hash',
  9161. loc: this.getLocation(start, this.scanner.tokenStart),
  9162. value: this.scanner.substrToCursor(start + 1)
  9163. };
  9164. },
  9165. generate: function(node) {
  9166. this.chunk('#');
  9167. this.chunk(node.value);
  9168. }
  9169. };
  9170. var TYPE$o = tokenizer.TYPE;
  9171. var IDENT$8 = TYPE$o.Ident;
  9172. var Identifier = {
  9173. name: 'Identifier',
  9174. structure: {
  9175. name: String
  9176. },
  9177. parse: function() {
  9178. return {
  9179. type: 'Identifier',
  9180. loc: this.getLocation(this.scanner.tokenStart, this.scanner.tokenEnd),
  9181. name: this.consume(IDENT$8)
  9182. };
  9183. },
  9184. generate: function(node) {
  9185. this.chunk(node.name);
  9186. }
  9187. };
  9188. var TYPE$p = tokenizer.TYPE;
  9189. var HASH$3 = TYPE$p.Hash;
  9190. // <hash-token>
  9191. var IdSelector = {
  9192. name: 'IdSelector',
  9193. structure: {
  9194. name: String
  9195. },
  9196. parse: function() {
  9197. var start = this.scanner.tokenStart;
  9198. // TODO: check value is an ident
  9199. this.eat(HASH$3);
  9200. return {
  9201. type: 'IdSelector',
  9202. loc: this.getLocation(start, this.scanner.tokenStart),
  9203. name: this.scanner.substrToCursor(start + 1)
  9204. };
  9205. },
  9206. generate: function(node) {
  9207. this.chunk('#');
  9208. this.chunk(node.name);
  9209. }
  9210. };
  9211. var TYPE$q = tokenizer.TYPE;
  9212. var IDENT$9 = TYPE$q.Ident;
  9213. var NUMBER$4 = TYPE$q.Number;
  9214. var DIMENSION$4 = TYPE$q.Dimension;
  9215. var LEFTPARENTHESIS$2 = TYPE$q.LeftParenthesis;
  9216. var RIGHTPARENTHESIS$3 = TYPE$q.RightParenthesis;
  9217. var COLON$2 = TYPE$q.Colon;
  9218. var DELIM$3 = TYPE$q.Delim;
  9219. var MediaFeature = {
  9220. name: 'MediaFeature',
  9221. structure: {
  9222. name: String,
  9223. value: ['Identifier', 'Number', 'Dimension', 'Ratio', null]
  9224. },
  9225. parse: function() {
  9226. var start = this.scanner.tokenStart;
  9227. var name;
  9228. var value = null;
  9229. this.eat(LEFTPARENTHESIS$2);
  9230. this.scanner.skipSC();
  9231. name = this.consume(IDENT$9);
  9232. this.scanner.skipSC();
  9233. if (this.scanner.tokenType !== RIGHTPARENTHESIS$3) {
  9234. this.eat(COLON$2);
  9235. this.scanner.skipSC();
  9236. switch (this.scanner.tokenType) {
  9237. case NUMBER$4:
  9238. if (this.lookupNonWSType(1) === DELIM$3) {
  9239. value = this.Ratio();
  9240. } else {
  9241. value = this.Number();
  9242. }
  9243. break;
  9244. case DIMENSION$4:
  9245. value = this.Dimension();
  9246. break;
  9247. case IDENT$9:
  9248. value = this.Identifier();
  9249. break;
  9250. default:
  9251. this.error('Number, dimension, ratio or identifier is expected');
  9252. }
  9253. this.scanner.skipSC();
  9254. }
  9255. this.eat(RIGHTPARENTHESIS$3);
  9256. return {
  9257. type: 'MediaFeature',
  9258. loc: this.getLocation(start, this.scanner.tokenStart),
  9259. name: name,
  9260. value: value
  9261. };
  9262. },
  9263. generate: function(node) {
  9264. this.chunk('(');
  9265. this.chunk(node.name);
  9266. if (node.value !== null) {
  9267. this.chunk(':');
  9268. this.node(node.value);
  9269. }
  9270. this.chunk(')');
  9271. }
  9272. };
  9273. var TYPE$r = tokenizer.TYPE;
  9274. var WHITESPACE$8 = TYPE$r.WhiteSpace;
  9275. var COMMENT$8 = TYPE$r.Comment;
  9276. var IDENT$a = TYPE$r.Ident;
  9277. var LEFTPARENTHESIS$3 = TYPE$r.LeftParenthesis;
  9278. var MediaQuery = {
  9279. name: 'MediaQuery',
  9280. structure: {
  9281. children: [[
  9282. 'Identifier',
  9283. 'MediaFeature',
  9284. 'WhiteSpace'
  9285. ]]
  9286. },
  9287. parse: function() {
  9288. this.scanner.skipSC();
  9289. var children = this.createList();
  9290. var child = null;
  9291. var space = null;
  9292. scan:
  9293. while (!this.scanner.eof) {
  9294. switch (this.scanner.tokenType) {
  9295. case COMMENT$8:
  9296. this.scanner.next();
  9297. continue;
  9298. case WHITESPACE$8:
  9299. space = this.WhiteSpace();
  9300. continue;
  9301. case IDENT$a:
  9302. child = this.Identifier();
  9303. break;
  9304. case LEFTPARENTHESIS$3:
  9305. child = this.MediaFeature();
  9306. break;
  9307. default:
  9308. break scan;
  9309. }
  9310. if (space !== null) {
  9311. children.push(space);
  9312. space = null;
  9313. }
  9314. children.push(child);
  9315. }
  9316. if (child === null) {
  9317. this.error('Identifier or parenthesis is expected');
  9318. }
  9319. return {
  9320. type: 'MediaQuery',
  9321. loc: this.getLocationFromList(children),
  9322. children: children
  9323. };
  9324. },
  9325. generate: function(node) {
  9326. this.children(node);
  9327. }
  9328. };
  9329. var COMMA$1 = tokenizer.TYPE.Comma;
  9330. var MediaQueryList = {
  9331. name: 'MediaQueryList',
  9332. structure: {
  9333. children: [[
  9334. 'MediaQuery'
  9335. ]]
  9336. },
  9337. parse: function(relative) {
  9338. var children = this.createList();
  9339. this.scanner.skipSC();
  9340. while (!this.scanner.eof) {
  9341. children.push(this.MediaQuery(relative));
  9342. if (this.scanner.tokenType !== COMMA$1) {
  9343. break;
  9344. }
  9345. this.scanner.next();
  9346. }
  9347. return {
  9348. type: 'MediaQueryList',
  9349. loc: this.getLocationFromList(children),
  9350. children: children
  9351. };
  9352. },
  9353. generate: function(node) {
  9354. this.children(node, function() {
  9355. this.chunk(',');
  9356. });
  9357. }
  9358. };
  9359. var Nth = {
  9360. name: 'Nth',
  9361. structure: {
  9362. nth: ['AnPlusB', 'Identifier'],
  9363. selector: ['SelectorList', null]
  9364. },
  9365. parse: function(allowOfClause) {
  9366. this.scanner.skipSC();
  9367. var start = this.scanner.tokenStart;
  9368. var end = start;
  9369. var selector = null;
  9370. var query;
  9371. if (this.scanner.lookupValue(0, 'odd') || this.scanner.lookupValue(0, 'even')) {
  9372. query = this.Identifier();
  9373. } else {
  9374. query = this.AnPlusB();
  9375. }
  9376. this.scanner.skipSC();
  9377. if (allowOfClause && this.scanner.lookupValue(0, 'of')) {
  9378. this.scanner.next();
  9379. selector = this.SelectorList();
  9380. if (this.needPositions) {
  9381. end = this.getLastListNode(selector.children).loc.end.offset;
  9382. }
  9383. } else {
  9384. if (this.needPositions) {
  9385. end = query.loc.end.offset;
  9386. }
  9387. }
  9388. return {
  9389. type: 'Nth',
  9390. loc: this.getLocation(start, end),
  9391. nth: query,
  9392. selector: selector
  9393. };
  9394. },
  9395. generate: function(node) {
  9396. this.node(node.nth);
  9397. if (node.selector !== null) {
  9398. this.chunk(' of ');
  9399. this.node(node.selector);
  9400. }
  9401. }
  9402. };
  9403. var NUMBER$5 = tokenizer.TYPE.Number;
  9404. var _Number = {
  9405. name: 'Number',
  9406. structure: {
  9407. value: String
  9408. },
  9409. parse: function() {
  9410. return {
  9411. type: 'Number',
  9412. loc: this.getLocation(this.scanner.tokenStart, this.scanner.tokenEnd),
  9413. value: this.consume(NUMBER$5)
  9414. };
  9415. },
  9416. generate: function(node) {
  9417. this.chunk(node.value);
  9418. }
  9419. };
  9420. // '/' | '*' | ',' | ':' | '+' | '-'
  9421. var Operator = {
  9422. name: 'Operator',
  9423. structure: {
  9424. value: String
  9425. },
  9426. parse: function() {
  9427. var start = this.scanner.tokenStart;
  9428. this.scanner.next();
  9429. return {
  9430. type: 'Operator',
  9431. loc: this.getLocation(start, this.scanner.tokenStart),
  9432. value: this.scanner.substrToCursor(start)
  9433. };
  9434. },
  9435. generate: function(node) {
  9436. this.chunk(node.value);
  9437. }
  9438. };
  9439. var TYPE$s = tokenizer.TYPE;
  9440. var LEFTPARENTHESIS$4 = TYPE$s.LeftParenthesis;
  9441. var RIGHTPARENTHESIS$4 = TYPE$s.RightParenthesis;
  9442. var Parentheses = {
  9443. name: 'Parentheses',
  9444. structure: {
  9445. children: [[]]
  9446. },
  9447. parse: function(readSequence, recognizer) {
  9448. var start = this.scanner.tokenStart;
  9449. var children = null;
  9450. this.eat(LEFTPARENTHESIS$4);
  9451. children = readSequence.call(this, recognizer);
  9452. if (!this.scanner.eof) {
  9453. this.eat(RIGHTPARENTHESIS$4);
  9454. }
  9455. return {
  9456. type: 'Parentheses',
  9457. loc: this.getLocation(start, this.scanner.tokenStart),
  9458. children: children
  9459. };
  9460. },
  9461. generate: function(node) {
  9462. this.chunk('(');
  9463. this.children(node);
  9464. this.chunk(')');
  9465. }
  9466. };
  9467. var consumeNumber$4 = utils.consumeNumber;
  9468. var TYPE$t = tokenizer.TYPE;
  9469. var PERCENTAGE$1 = TYPE$t.Percentage;
  9470. var Percentage = {
  9471. name: 'Percentage',
  9472. structure: {
  9473. value: String
  9474. },
  9475. parse: function() {
  9476. var start = this.scanner.tokenStart;
  9477. var numberEnd = consumeNumber$4(this.scanner.source, start);
  9478. this.eat(PERCENTAGE$1);
  9479. return {
  9480. type: 'Percentage',
  9481. loc: this.getLocation(start, this.scanner.tokenStart),
  9482. value: this.scanner.source.substring(start, numberEnd)
  9483. };
  9484. },
  9485. generate: function(node) {
  9486. this.chunk(node.value);
  9487. this.chunk('%');
  9488. }
  9489. };
  9490. var TYPE$u = tokenizer.TYPE;
  9491. var IDENT$b = TYPE$u.Ident;
  9492. var FUNCTION$1 = TYPE$u.Function;
  9493. var COLON$3 = TYPE$u.Colon;
  9494. var RIGHTPARENTHESIS$5 = TYPE$u.RightParenthesis;
  9495. // : [ <ident> | <function-token> <any-value>? ) ]
  9496. var PseudoClassSelector = {
  9497. name: 'PseudoClassSelector',
  9498. structure: {
  9499. name: String,
  9500. children: [['Raw'], null]
  9501. },
  9502. parse: function() {
  9503. var start = this.scanner.tokenStart;
  9504. var children = null;
  9505. var name;
  9506. var nameLowerCase;
  9507. this.eat(COLON$3);
  9508. if (this.scanner.tokenType === FUNCTION$1) {
  9509. name = this.consumeFunctionName();
  9510. nameLowerCase = name.toLowerCase();
  9511. if (this.pseudo.hasOwnProperty(nameLowerCase)) {
  9512. this.scanner.skipSC();
  9513. children = this.pseudo[nameLowerCase].call(this);
  9514. this.scanner.skipSC();
  9515. } else {
  9516. children = this.createList();
  9517. children.push(
  9518. this.Raw(this.scanner.tokenIndex, null, false)
  9519. );
  9520. }
  9521. this.eat(RIGHTPARENTHESIS$5);
  9522. } else {
  9523. name = this.consume(IDENT$b);
  9524. }
  9525. return {
  9526. type: 'PseudoClassSelector',
  9527. loc: this.getLocation(start, this.scanner.tokenStart),
  9528. name: name,
  9529. children: children
  9530. };
  9531. },
  9532. generate: function(node) {
  9533. this.chunk(':');
  9534. this.chunk(node.name);
  9535. if (node.children !== null) {
  9536. this.chunk('(');
  9537. this.children(node);
  9538. this.chunk(')');
  9539. }
  9540. },
  9541. walkContext: 'function'
  9542. };
  9543. var TYPE$v = tokenizer.TYPE;
  9544. var IDENT$c = TYPE$v.Ident;
  9545. var FUNCTION$2 = TYPE$v.Function;
  9546. var COLON$4 = TYPE$v.Colon;
  9547. var RIGHTPARENTHESIS$6 = TYPE$v.RightParenthesis;
  9548. // :: [ <ident> | <function-token> <any-value>? ) ]
  9549. var PseudoElementSelector = {
  9550. name: 'PseudoElementSelector',
  9551. structure: {
  9552. name: String,
  9553. children: [['Raw'], null]
  9554. },
  9555. parse: function() {
  9556. var start = this.scanner.tokenStart;
  9557. var children = null;
  9558. var name;
  9559. var nameLowerCase;
  9560. this.eat(COLON$4);
  9561. this.eat(COLON$4);
  9562. if (this.scanner.tokenType === FUNCTION$2) {
  9563. name = this.consumeFunctionName();
  9564. nameLowerCase = name.toLowerCase();
  9565. if (this.pseudo.hasOwnProperty(nameLowerCase)) {
  9566. this.scanner.skipSC();
  9567. children = this.pseudo[nameLowerCase].call(this);
  9568. this.scanner.skipSC();
  9569. } else {
  9570. children = this.createList();
  9571. children.push(
  9572. this.Raw(this.scanner.tokenIndex, null, false)
  9573. );
  9574. }
  9575. this.eat(RIGHTPARENTHESIS$6);
  9576. } else {
  9577. name = this.consume(IDENT$c);
  9578. }
  9579. return {
  9580. type: 'PseudoElementSelector',
  9581. loc: this.getLocation(start, this.scanner.tokenStart),
  9582. name: name,
  9583. children: children
  9584. };
  9585. },
  9586. generate: function(node) {
  9587. this.chunk('::');
  9588. this.chunk(node.name);
  9589. if (node.children !== null) {
  9590. this.chunk('(');
  9591. this.children(node);
  9592. this.chunk(')');
  9593. }
  9594. },
  9595. walkContext: 'function'
  9596. };
  9597. var isDigit$5 = tokenizer.isDigit;
  9598. var TYPE$w = tokenizer.TYPE;
  9599. var NUMBER$6 = TYPE$w.Number;
  9600. var DELIM$4 = TYPE$w.Delim;
  9601. var SOLIDUS$3 = 0x002F; // U+002F SOLIDUS (/)
  9602. var FULLSTOP$1 = 0x002E; // U+002E FULL STOP (.)
  9603. // Terms of <ratio> should be a positive numbers (not zero or negative)
  9604. // (see https://drafts.csswg.org/mediaqueries-3/#values)
  9605. // However, -o-min-device-pixel-ratio takes fractional values as a ratio's term
  9606. // and this is using by various sites. Therefore we relax checking on parse
  9607. // to test a term is unsigned number without an exponent part.
  9608. // Additional checking may be applied on lexer validation.
  9609. function consumeNumber$5() {
  9610. this.scanner.skipWS();
  9611. var value = this.consume(NUMBER$6);
  9612. for (var i = 0; i < value.length; i++) {
  9613. var code = value.charCodeAt(i);
  9614. if (!isDigit$5(code) && code !== FULLSTOP$1) {
  9615. this.error('Unsigned number is expected', this.scanner.tokenStart - value.length + i);
  9616. }
  9617. }
  9618. if (Number(value) === 0) {
  9619. this.error('Zero number is not allowed', this.scanner.tokenStart - value.length);
  9620. }
  9621. return value;
  9622. }
  9623. // <positive-integer> S* '/' S* <positive-integer>
  9624. var Ratio = {
  9625. name: 'Ratio',
  9626. structure: {
  9627. left: String,
  9628. right: String
  9629. },
  9630. parse: function() {
  9631. var start = this.scanner.tokenStart;
  9632. var left = consumeNumber$5.call(this);
  9633. var right;
  9634. this.scanner.skipWS();
  9635. if (!this.scanner.isDelim(SOLIDUS$3)) {
  9636. this.error('Solidus is expected');
  9637. }
  9638. this.eat(DELIM$4);
  9639. right = consumeNumber$5.call(this);
  9640. return {
  9641. type: 'Ratio',
  9642. loc: this.getLocation(start, this.scanner.tokenStart),
  9643. left: left,
  9644. right: right
  9645. };
  9646. },
  9647. generate: function(node) {
  9648. this.chunk(node.left);
  9649. this.chunk('/');
  9650. this.chunk(node.right);
  9651. }
  9652. };
  9653. var TYPE$x = tokenizer.TYPE;
  9654. var rawMode$4 = Raw.mode;
  9655. var LEFTCURLYBRACKET$4 = TYPE$x.LeftCurlyBracket;
  9656. function consumeRaw$3(startToken) {
  9657. return this.Raw(startToken, rawMode$4.leftCurlyBracket, true);
  9658. }
  9659. function consumePrelude() {
  9660. var prelude = this.SelectorList();
  9661. if (prelude.type !== 'Raw' &&
  9662. this.scanner.eof === false &&
  9663. this.scanner.tokenType !== LEFTCURLYBRACKET$4) {
  9664. this.error();
  9665. }
  9666. return prelude;
  9667. }
  9668. var Rule = {
  9669. name: 'Rule',
  9670. structure: {
  9671. prelude: ['SelectorList', 'Raw'],
  9672. block: ['Block']
  9673. },
  9674. parse: function() {
  9675. var startToken = this.scanner.tokenIndex;
  9676. var startOffset = this.scanner.tokenStart;
  9677. var prelude;
  9678. var block;
  9679. if (this.parseRulePrelude) {
  9680. prelude = this.parseWithFallback(consumePrelude, consumeRaw$3);
  9681. } else {
  9682. prelude = consumeRaw$3.call(this, startToken);
  9683. }
  9684. block = this.Block(true);
  9685. return {
  9686. type: 'Rule',
  9687. loc: this.getLocation(startOffset, this.scanner.tokenStart),
  9688. prelude: prelude,
  9689. block: block
  9690. };
  9691. },
  9692. generate: function(node) {
  9693. this.node(node.prelude);
  9694. this.node(node.block);
  9695. },
  9696. walkContext: 'rule'
  9697. };
  9698. var Selector = {
  9699. name: 'Selector',
  9700. structure: {
  9701. children: [[
  9702. 'TypeSelector',
  9703. 'IdSelector',
  9704. 'ClassSelector',
  9705. 'AttributeSelector',
  9706. 'PseudoClassSelector',
  9707. 'PseudoElementSelector',
  9708. 'Combinator',
  9709. 'WhiteSpace'
  9710. ]]
  9711. },
  9712. parse: function() {
  9713. var children = this.readSequence(this.scope.Selector);
  9714. // nothing were consumed
  9715. if (this.getFirstListNode(children) === null) {
  9716. this.error('Selector is expected');
  9717. }
  9718. return {
  9719. type: 'Selector',
  9720. loc: this.getLocationFromList(children),
  9721. children: children
  9722. };
  9723. },
  9724. generate: function(node) {
  9725. this.children(node);
  9726. }
  9727. };
  9728. var TYPE$y = tokenizer.TYPE;
  9729. var COMMA$2 = TYPE$y.Comma;
  9730. var SelectorList = {
  9731. name: 'SelectorList',
  9732. structure: {
  9733. children: [[
  9734. 'Selector',
  9735. 'Raw'
  9736. ]]
  9737. },
  9738. parse: function() {
  9739. var children = this.createList();
  9740. while (!this.scanner.eof) {
  9741. children.push(this.Selector());
  9742. if (this.scanner.tokenType === COMMA$2) {
  9743. this.scanner.next();
  9744. continue;
  9745. }
  9746. break;
  9747. }
  9748. return {
  9749. type: 'SelectorList',
  9750. loc: this.getLocationFromList(children),
  9751. children: children
  9752. };
  9753. },
  9754. generate: function(node) {
  9755. this.children(node, function() {
  9756. this.chunk(',');
  9757. });
  9758. },
  9759. walkContext: 'selector'
  9760. };
  9761. var STRING$1 = tokenizer.TYPE.String;
  9762. var _String = {
  9763. name: 'String',
  9764. structure: {
  9765. value: String
  9766. },
  9767. parse: function() {
  9768. return {
  9769. type: 'String',
  9770. loc: this.getLocation(this.scanner.tokenStart, this.scanner.tokenEnd),
  9771. value: this.consume(STRING$1)
  9772. };
  9773. },
  9774. generate: function(node) {
  9775. this.chunk(node.value);
  9776. }
  9777. };
  9778. var TYPE$z = tokenizer.TYPE;
  9779. var WHITESPACE$9 = TYPE$z.WhiteSpace;
  9780. var COMMENT$9 = TYPE$z.Comment;
  9781. var ATKEYWORD$2 = TYPE$z.AtKeyword;
  9782. var CDO$1 = TYPE$z.CDO;
  9783. var CDC$1 = TYPE$z.CDC;
  9784. var EXCLAMATIONMARK$3 = 0x0021; // U+0021 EXCLAMATION MARK (!)
  9785. function consumeRaw$4(startToken) {
  9786. return this.Raw(startToken, null, false);
  9787. }
  9788. var StyleSheet = {
  9789. name: 'StyleSheet',
  9790. structure: {
  9791. children: [[
  9792. 'Comment',
  9793. 'CDO',
  9794. 'CDC',
  9795. 'Atrule',
  9796. 'Rule',
  9797. 'Raw'
  9798. ]]
  9799. },
  9800. parse: function() {
  9801. var start = this.scanner.tokenStart;
  9802. var children = this.createList();
  9803. var child;
  9804. while (!this.scanner.eof) {
  9805. switch (this.scanner.tokenType) {
  9806. case WHITESPACE$9:
  9807. this.scanner.next();
  9808. continue;
  9809. case COMMENT$9:
  9810. // ignore comments except exclamation comments (i.e. /*! .. */) on top level
  9811. if (this.scanner.source.charCodeAt(this.scanner.tokenStart + 2) !== EXCLAMATIONMARK$3) {
  9812. this.scanner.next();
  9813. continue;
  9814. }
  9815. child = this.Comment();
  9816. break;
  9817. case CDO$1: // <!--
  9818. child = this.CDO();
  9819. break;
  9820. case CDC$1: // -->
  9821. child = this.CDC();
  9822. break;
  9823. // CSS Syntax Module Level 3
  9824. // §2.2 Error handling
  9825. // At the "top level" of a stylesheet, an <at-keyword-token> starts an at-rule.
  9826. case ATKEYWORD$2:
  9827. child = this.parseWithFallback(this.Atrule, consumeRaw$4);
  9828. break;
  9829. // Anything else starts a qualified rule ...
  9830. default:
  9831. child = this.parseWithFallback(this.Rule, consumeRaw$4);
  9832. }
  9833. children.push(child);
  9834. }
  9835. return {
  9836. type: 'StyleSheet',
  9837. loc: this.getLocation(start, this.scanner.tokenStart),
  9838. children: children
  9839. };
  9840. },
  9841. generate: function(node) {
  9842. this.children(node);
  9843. },
  9844. walkContext: 'stylesheet'
  9845. };
  9846. var TYPE$A = tokenizer.TYPE;
  9847. var IDENT$d = TYPE$A.Ident;
  9848. var ASTERISK$4 = 0x002A; // U+002A ASTERISK (*)
  9849. var VERTICALLINE$2 = 0x007C; // U+007C VERTICAL LINE (|)
  9850. function eatIdentifierOrAsterisk() {
  9851. if (this.scanner.tokenType !== IDENT$d &&
  9852. this.scanner.isDelim(ASTERISK$4) === false) {
  9853. this.error('Identifier or asterisk is expected');
  9854. }
  9855. this.scanner.next();
  9856. }
  9857. // ident
  9858. // ident|ident
  9859. // ident|*
  9860. // *
  9861. // *|ident
  9862. // *|*
  9863. // |ident
  9864. // |*
  9865. var TypeSelector = {
  9866. name: 'TypeSelector',
  9867. structure: {
  9868. name: String
  9869. },
  9870. parse: function() {
  9871. var start = this.scanner.tokenStart;
  9872. if (this.scanner.isDelim(VERTICALLINE$2)) {
  9873. this.scanner.next();
  9874. eatIdentifierOrAsterisk.call(this);
  9875. } else {
  9876. eatIdentifierOrAsterisk.call(this);
  9877. if (this.scanner.isDelim(VERTICALLINE$2)) {
  9878. this.scanner.next();
  9879. eatIdentifierOrAsterisk.call(this);
  9880. }
  9881. }
  9882. return {
  9883. type: 'TypeSelector',
  9884. loc: this.getLocation(start, this.scanner.tokenStart),
  9885. name: this.scanner.substrToCursor(start)
  9886. };
  9887. },
  9888. generate: function(node) {
  9889. this.chunk(node.name);
  9890. }
  9891. };
  9892. var isHexDigit$4 = tokenizer.isHexDigit;
  9893. var cmpChar$4 = tokenizer.cmpChar;
  9894. var TYPE$B = tokenizer.TYPE;
  9895. var NAME$3 = tokenizer.NAME;
  9896. var IDENT$e = TYPE$B.Ident;
  9897. var NUMBER$7 = TYPE$B.Number;
  9898. var DIMENSION$5 = TYPE$B.Dimension;
  9899. var PLUSSIGN$6 = 0x002B; // U+002B PLUS SIGN (+)
  9900. var HYPHENMINUS$4 = 0x002D; // U+002D HYPHEN-MINUS (-)
  9901. var QUESTIONMARK$2 = 0x003F; // U+003F QUESTION MARK (?)
  9902. var U$1 = 0x0075; // U+0075 LATIN SMALL LETTER U (u)
  9903. function eatHexSequence(offset, allowDash) {
  9904. for (var pos = this.scanner.tokenStart + offset, len = 0; pos < this.scanner.tokenEnd; pos++) {
  9905. var code = this.scanner.source.charCodeAt(pos);
  9906. if (code === HYPHENMINUS$4 && allowDash && len !== 0) {
  9907. if (eatHexSequence.call(this, offset + len + 1, false) === 0) {
  9908. this.error();
  9909. }
  9910. return -1;
  9911. }
  9912. if (!isHexDigit$4(code)) {
  9913. this.error(
  9914. allowDash && len !== 0
  9915. ? 'HyphenMinus' + (len < 6 ? ' or hex digit' : '') + ' is expected'
  9916. : (len < 6 ? 'Hex digit is expected' : 'Unexpected input'),
  9917. pos
  9918. );
  9919. }
  9920. if (++len > 6) {
  9921. this.error('Too many hex digits', pos);
  9922. } }
  9923. this.scanner.next();
  9924. return len;
  9925. }
  9926. function eatQuestionMarkSequence(max) {
  9927. var count = 0;
  9928. while (this.scanner.isDelim(QUESTIONMARK$2)) {
  9929. if (++count > max) {
  9930. this.error('Too many question marks');
  9931. }
  9932. this.scanner.next();
  9933. }
  9934. }
  9935. function startsWith$1(code) {
  9936. if (this.scanner.source.charCodeAt(this.scanner.tokenStart) !== code) {
  9937. this.error(NAME$3[code] + ' is expected');
  9938. }
  9939. }
  9940. // https://drafts.csswg.org/css-syntax/#urange
  9941. // Informally, the <urange> production has three forms:
  9942. // U+0001
  9943. // Defines a range consisting of a single code point, in this case the code point "1".
  9944. // U+0001-00ff
  9945. // Defines a range of codepoints between the first and the second value, in this case
  9946. // the range between "1" and "ff" (255 in decimal) inclusive.
  9947. // U+00??
  9948. // Defines a range of codepoints where the "?" characters range over all hex digits,
  9949. // in this case defining the same as the value U+0000-00ff.
  9950. // In each form, a maximum of 6 digits is allowed for each hexadecimal number (if you treat "?" as a hexadecimal digit).
  9951. //
  9952. // <urange> =
  9953. // u '+' <ident-token> '?'* |
  9954. // u <dimension-token> '?'* |
  9955. // u <number-token> '?'* |
  9956. // u <number-token> <dimension-token> |
  9957. // u <number-token> <number-token> |
  9958. // u '+' '?'+
  9959. function scanUnicodeRange() {
  9960. var hexLength = 0;
  9961. // u '+' <ident-token> '?'*
  9962. // u '+' '?'+
  9963. if (this.scanner.isDelim(PLUSSIGN$6)) {
  9964. this.scanner.next();
  9965. if (this.scanner.tokenType === IDENT$e) {
  9966. hexLength = eatHexSequence.call(this, 0, true);
  9967. if (hexLength > 0) {
  9968. eatQuestionMarkSequence.call(this, 6 - hexLength);
  9969. }
  9970. return;
  9971. }
  9972. if (this.scanner.isDelim(QUESTIONMARK$2)) {
  9973. this.scanner.next();
  9974. eatQuestionMarkSequence.call(this, 5);
  9975. return;
  9976. }
  9977. this.error('Hex digit or question mark is expected');
  9978. return;
  9979. }
  9980. // u <number-token> '?'*
  9981. // u <number-token> <dimension-token>
  9982. // u <number-token> <number-token>
  9983. if (this.scanner.tokenType === NUMBER$7) {
  9984. startsWith$1.call(this, PLUSSIGN$6);
  9985. hexLength = eatHexSequence.call(this, 1, true);
  9986. if (this.scanner.isDelim(QUESTIONMARK$2)) {
  9987. eatQuestionMarkSequence.call(this, 6 - hexLength);
  9988. return;
  9989. }
  9990. if (this.scanner.tokenType === DIMENSION$5 ||
  9991. this.scanner.tokenType === NUMBER$7) {
  9992. startsWith$1.call(this, HYPHENMINUS$4);
  9993. eatHexSequence.call(this, 1, false);
  9994. return;
  9995. }
  9996. return;
  9997. }
  9998. // u <dimension-token> '?'*
  9999. if (this.scanner.tokenType === DIMENSION$5) {
  10000. startsWith$1.call(this, PLUSSIGN$6);
  10001. hexLength = eatHexSequence.call(this, 1, true);
  10002. if (hexLength > 0) {
  10003. eatQuestionMarkSequence.call(this, 6 - hexLength);
  10004. }
  10005. return;
  10006. }
  10007. this.error();
  10008. }
  10009. var UnicodeRange = {
  10010. name: 'UnicodeRange',
  10011. structure: {
  10012. value: String
  10013. },
  10014. parse: function() {
  10015. var start = this.scanner.tokenStart;
  10016. // U or u
  10017. if (!cmpChar$4(this.scanner.source, start, U$1)) {
  10018. this.error('U is expected');
  10019. }
  10020. if (!cmpChar$4(this.scanner.source, start + 1, PLUSSIGN$6)) {
  10021. this.error('Plus sign is expected');
  10022. }
  10023. this.scanner.next();
  10024. scanUnicodeRange.call(this);
  10025. return {
  10026. type: 'UnicodeRange',
  10027. loc: this.getLocation(start, this.scanner.tokenStart),
  10028. value: this.scanner.substrToCursor(start)
  10029. };
  10030. },
  10031. generate: function(node) {
  10032. this.chunk(node.value);
  10033. }
  10034. };
  10035. var isWhiteSpace$2 = tokenizer.isWhiteSpace;
  10036. var cmpStr$5 = tokenizer.cmpStr;
  10037. var TYPE$C = tokenizer.TYPE;
  10038. var FUNCTION$3 = TYPE$C.Function;
  10039. var URL$1 = TYPE$C.Url;
  10040. var RIGHTPARENTHESIS$7 = TYPE$C.RightParenthesis;
  10041. // <url-token> | <function-token> <string> )
  10042. var Url = {
  10043. name: 'Url',
  10044. structure: {
  10045. value: ['String', 'Raw']
  10046. },
  10047. parse: function() {
  10048. var start = this.scanner.tokenStart;
  10049. var value;
  10050. switch (this.scanner.tokenType) {
  10051. case URL$1:
  10052. var rawStart = start + 4;
  10053. var rawEnd = this.scanner.tokenEnd - 1;
  10054. while (rawStart < rawEnd && isWhiteSpace$2(this.scanner.source.charCodeAt(rawStart))) {
  10055. rawStart++;
  10056. }
  10057. while (rawStart < rawEnd && isWhiteSpace$2(this.scanner.source.charCodeAt(rawEnd - 1))) {
  10058. rawEnd--;
  10059. }
  10060. value = {
  10061. type: 'Raw',
  10062. loc: this.getLocation(rawStart, rawEnd),
  10063. value: this.scanner.source.substring(rawStart, rawEnd)
  10064. };
  10065. this.eat(URL$1);
  10066. break;
  10067. case FUNCTION$3:
  10068. if (!cmpStr$5(this.scanner.source, this.scanner.tokenStart, this.scanner.tokenEnd, 'url(')) {
  10069. this.error('Function name must be `url`');
  10070. }
  10071. this.eat(FUNCTION$3);
  10072. this.scanner.skipSC();
  10073. value = this.String();
  10074. this.scanner.skipSC();
  10075. this.eat(RIGHTPARENTHESIS$7);
  10076. break;
  10077. default:
  10078. this.error('Url or Function is expected');
  10079. }
  10080. return {
  10081. type: 'Url',
  10082. loc: this.getLocation(start, this.scanner.tokenStart),
  10083. value: value
  10084. };
  10085. },
  10086. generate: function(node) {
  10087. this.chunk('url');
  10088. this.chunk('(');
  10089. this.node(node.value);
  10090. this.chunk(')');
  10091. }
  10092. };
  10093. var Value = {
  10094. name: 'Value',
  10095. structure: {
  10096. children: [[]]
  10097. },
  10098. parse: function() {
  10099. var start = this.scanner.tokenStart;
  10100. var children = this.readSequence(this.scope.Value);
  10101. return {
  10102. type: 'Value',
  10103. loc: this.getLocation(start, this.scanner.tokenStart),
  10104. children: children
  10105. };
  10106. },
  10107. generate: function(node) {
  10108. this.children(node);
  10109. }
  10110. };
  10111. var WHITESPACE$a = tokenizer.TYPE.WhiteSpace;
  10112. var SPACE$2 = Object.freeze({
  10113. type: 'WhiteSpace',
  10114. loc: null,
  10115. value: ' '
  10116. });
  10117. var WhiteSpace$1 = {
  10118. name: 'WhiteSpace',
  10119. structure: {
  10120. value: String
  10121. },
  10122. parse: function() {
  10123. this.eat(WHITESPACE$a);
  10124. return SPACE$2;
  10125. // return {
  10126. // type: 'WhiteSpace',
  10127. // loc: this.getLocation(this.scanner.tokenStart, this.scanner.tokenEnd),
  10128. // value: this.consume(WHITESPACE)
  10129. // };
  10130. },
  10131. generate: function(node) {
  10132. this.chunk(node.value);
  10133. }
  10134. };
  10135. var node = {
  10136. AnPlusB: AnPlusB,
  10137. Atrule: Atrule,
  10138. AtrulePrelude: AtrulePrelude,
  10139. AttributeSelector: AttributeSelector,
  10140. Block: Block,
  10141. Brackets: Brackets,
  10142. CDC: CDC_1,
  10143. CDO: CDO_1,
  10144. ClassSelector: ClassSelector,
  10145. Combinator: Combinator,
  10146. Comment: Comment,
  10147. Declaration: Declaration,
  10148. DeclarationList: DeclarationList,
  10149. Dimension: Dimension,
  10150. Function: _Function,
  10151. Hash: Hash,
  10152. Identifier: Identifier,
  10153. IdSelector: IdSelector,
  10154. MediaFeature: MediaFeature,
  10155. MediaQuery: MediaQuery,
  10156. MediaQueryList: MediaQueryList,
  10157. Nth: Nth,
  10158. Number: _Number,
  10159. Operator: Operator,
  10160. Parentheses: Parentheses,
  10161. Percentage: Percentage,
  10162. PseudoClassSelector: PseudoClassSelector,
  10163. PseudoElementSelector: PseudoElementSelector,
  10164. Ratio: Ratio,
  10165. Raw: Raw,
  10166. Rule: Rule,
  10167. Selector: Selector,
  10168. SelectorList: SelectorList,
  10169. String: _String,
  10170. StyleSheet: StyleSheet,
  10171. TypeSelector: TypeSelector,
  10172. UnicodeRange: UnicodeRange,
  10173. Url: Url,
  10174. Value: Value,
  10175. WhiteSpace: WhiteSpace$1
  10176. };
  10177. var lexer = {
  10178. generic: true,
  10179. types: data.types,
  10180. atrules: data.atrules,
  10181. properties: data.properties,
  10182. node: node
  10183. };
  10184. var cmpChar$5 = tokenizer.cmpChar;
  10185. var cmpStr$6 = tokenizer.cmpStr;
  10186. var TYPE$D = tokenizer.TYPE;
  10187. var IDENT$f = TYPE$D.Ident;
  10188. var STRING$2 = TYPE$D.String;
  10189. var NUMBER$8 = TYPE$D.Number;
  10190. var FUNCTION$4 = TYPE$D.Function;
  10191. var URL$2 = TYPE$D.Url;
  10192. var HASH$4 = TYPE$D.Hash;
  10193. var DIMENSION$6 = TYPE$D.Dimension;
  10194. var PERCENTAGE$2 = TYPE$D.Percentage;
  10195. var LEFTPARENTHESIS$5 = TYPE$D.LeftParenthesis;
  10196. var LEFTSQUAREBRACKET$3 = TYPE$D.LeftSquareBracket;
  10197. var COMMA$3 = TYPE$D.Comma;
  10198. var DELIM$5 = TYPE$D.Delim;
  10199. var NUMBERSIGN$3 = 0x0023; // U+0023 NUMBER SIGN (#)
  10200. var ASTERISK$5 = 0x002A; // U+002A ASTERISK (*)
  10201. var PLUSSIGN$7 = 0x002B; // U+002B PLUS SIGN (+)
  10202. var HYPHENMINUS$5 = 0x002D; // U+002D HYPHEN-MINUS (-)
  10203. var SOLIDUS$4 = 0x002F; // U+002F SOLIDUS (/)
  10204. var U$2 = 0x0075; // U+0075 LATIN SMALL LETTER U (u)
  10205. var _default = function defaultRecognizer(context) {
  10206. switch (this.scanner.tokenType) {
  10207. case HASH$4:
  10208. return this.Hash();
  10209. case COMMA$3:
  10210. context.space = null;
  10211. context.ignoreWSAfter = true;
  10212. return this.Operator();
  10213. case LEFTPARENTHESIS$5:
  10214. return this.Parentheses(this.readSequence, context.recognizer);
  10215. case LEFTSQUAREBRACKET$3:
  10216. return this.Brackets(this.readSequence, context.recognizer);
  10217. case STRING$2:
  10218. return this.String();
  10219. case DIMENSION$6:
  10220. return this.Dimension();
  10221. case PERCENTAGE$2:
  10222. return this.Percentage();
  10223. case NUMBER$8:
  10224. return this.Number();
  10225. case FUNCTION$4:
  10226. return cmpStr$6(this.scanner.source, this.scanner.tokenStart, this.scanner.tokenEnd, 'url(')
  10227. ? this.Url()
  10228. : this.Function(this.readSequence, context.recognizer);
  10229. case URL$2:
  10230. return this.Url();
  10231. case IDENT$f:
  10232. // check for unicode range, it should start with u+ or U+
  10233. if (cmpChar$5(this.scanner.source, this.scanner.tokenStart, U$2) &&
  10234. cmpChar$5(this.scanner.source, this.scanner.tokenStart + 1, PLUSSIGN$7)) {
  10235. return this.UnicodeRange();
  10236. } else {
  10237. return this.Identifier();
  10238. }
  10239. case DELIM$5:
  10240. var code = this.scanner.source.charCodeAt(this.scanner.tokenStart);
  10241. if (code === SOLIDUS$4 ||
  10242. code === ASTERISK$5 ||
  10243. code === PLUSSIGN$7 ||
  10244. code === HYPHENMINUS$5) {
  10245. return this.Operator(); // TODO: replace with Delim
  10246. }
  10247. // TODO: produce a node with Delim node type
  10248. if (code === NUMBERSIGN$3) {
  10249. this.error('Hex or identifier is expected', this.scanner.tokenStart + 1);
  10250. }
  10251. break;
  10252. }
  10253. };
  10254. var atrulePrelude = {
  10255. getNode: _default
  10256. };
  10257. var TYPE$E = tokenizer.TYPE;
  10258. var DELIM$6 = TYPE$E.Delim;
  10259. var IDENT$g = TYPE$E.Ident;
  10260. var DIMENSION$7 = TYPE$E.Dimension;
  10261. var PERCENTAGE$3 = TYPE$E.Percentage;
  10262. var NUMBER$9 = TYPE$E.Number;
  10263. var HASH$5 = TYPE$E.Hash;
  10264. var COLON$5 = TYPE$E.Colon;
  10265. var LEFTSQUAREBRACKET$4 = TYPE$E.LeftSquareBracket;
  10266. var NUMBERSIGN$4 = 0x0023; // U+0023 NUMBER SIGN (#)
  10267. var ASTERISK$6 = 0x002A; // U+002A ASTERISK (*)
  10268. var PLUSSIGN$8 = 0x002B; // U+002B PLUS SIGN (+)
  10269. var SOLIDUS$5 = 0x002F; // U+002F SOLIDUS (/)
  10270. var FULLSTOP$2 = 0x002E; // U+002E FULL STOP (.)
  10271. var GREATERTHANSIGN$2 = 0x003E; // U+003E GREATER-THAN SIGN (>)
  10272. var VERTICALLINE$3 = 0x007C; // U+007C VERTICAL LINE (|)
  10273. var TILDE$2 = 0x007E; // U+007E TILDE (~)
  10274. function getNode(context) {
  10275. switch (this.scanner.tokenType) {
  10276. case LEFTSQUAREBRACKET$4:
  10277. return this.AttributeSelector();
  10278. case HASH$5:
  10279. return this.IdSelector();
  10280. case COLON$5:
  10281. if (this.scanner.lookupType(1) === COLON$5) {
  10282. return this.PseudoElementSelector();
  10283. } else {
  10284. return this.PseudoClassSelector();
  10285. }
  10286. case IDENT$g:
  10287. return this.TypeSelector();
  10288. case NUMBER$9:
  10289. case PERCENTAGE$3:
  10290. return this.Percentage();
  10291. case DIMENSION$7:
  10292. // throws when .123ident
  10293. if (this.scanner.source.charCodeAt(this.scanner.tokenStart) === FULLSTOP$2) {
  10294. this.error('Identifier is expected', this.scanner.tokenStart + 1);
  10295. }
  10296. break;
  10297. case DELIM$6:
  10298. var code = this.scanner.source.charCodeAt(this.scanner.tokenStart);
  10299. switch (code) {
  10300. case PLUSSIGN$8:
  10301. case GREATERTHANSIGN$2:
  10302. case TILDE$2:
  10303. context.space = null;
  10304. context.ignoreWSAfter = true;
  10305. return this.Combinator();
  10306. case SOLIDUS$5: // /deep/
  10307. return this.Combinator();
  10308. case FULLSTOP$2:
  10309. return this.ClassSelector();
  10310. case ASTERISK$6:
  10311. case VERTICALLINE$3:
  10312. return this.TypeSelector();
  10313. case NUMBERSIGN$4:
  10314. return this.IdSelector();
  10315. }
  10316. break;
  10317. }
  10318. }
  10319. var selector = {
  10320. getNode: getNode
  10321. };
  10322. // legacy IE function
  10323. // expression( <any-value> )
  10324. var expression = function() {
  10325. return this.createSingleNodeList(
  10326. this.Raw(this.scanner.tokenIndex, null, false)
  10327. );
  10328. };
  10329. var TYPE$F = tokenizer.TYPE;
  10330. var rawMode$5 = Raw.mode;
  10331. var COMMA$4 = TYPE$F.Comma;
  10332. var WHITESPACE$b = TYPE$F.WhiteSpace;
  10333. // var( <ident> , <value>? )
  10334. var _var = function() {
  10335. var children = this.createList();
  10336. this.scanner.skipSC();
  10337. // NOTE: Don't check more than a first argument is an ident, rest checks are for lexer
  10338. children.push(this.Identifier());
  10339. this.scanner.skipSC();
  10340. if (this.scanner.tokenType === COMMA$4) {
  10341. children.push(this.Operator());
  10342. const startIndex = this.scanner.tokenIndex;
  10343. const value = this.parseCustomProperty
  10344. ? this.Value(null)
  10345. : this.Raw(this.scanner.tokenIndex, rawMode$5.exclamationMarkOrSemicolon, false);
  10346. if (value.type === 'Value' && value.children.isEmpty()) {
  10347. for (let offset = startIndex - this.scanner.tokenIndex; offset <= 0; offset++) {
  10348. if (this.scanner.lookupType(offset) === WHITESPACE$b) {
  10349. value.children.appendData({
  10350. type: 'WhiteSpace',
  10351. loc: null,
  10352. value: ' '
  10353. });
  10354. break;
  10355. }
  10356. }
  10357. }
  10358. children.push(value);
  10359. }
  10360. return children;
  10361. };
  10362. var value = {
  10363. getNode: _default,
  10364. 'expression': expression,
  10365. 'var': _var
  10366. };
  10367. var scope = {
  10368. AtrulePrelude: atrulePrelude,
  10369. Selector: selector,
  10370. Value: value
  10371. };
  10372. var fontFace = {
  10373. parse: {
  10374. prelude: null,
  10375. block: function() {
  10376. return this.Block(true);
  10377. }
  10378. }
  10379. };
  10380. var TYPE$G = tokenizer.TYPE;
  10381. var STRING$3 = TYPE$G.String;
  10382. var IDENT$h = TYPE$G.Ident;
  10383. var URL$3 = TYPE$G.Url;
  10384. var FUNCTION$5 = TYPE$G.Function;
  10385. var LEFTPARENTHESIS$6 = TYPE$G.LeftParenthesis;
  10386. var _import = {
  10387. parse: {
  10388. prelude: function() {
  10389. var children = this.createList();
  10390. this.scanner.skipSC();
  10391. switch (this.scanner.tokenType) {
  10392. case STRING$3:
  10393. children.push(this.String());
  10394. break;
  10395. case URL$3:
  10396. case FUNCTION$5:
  10397. children.push(this.Url());
  10398. break;
  10399. default:
  10400. this.error('String or url() is expected');
  10401. }
  10402. if (this.lookupNonWSType(0) === IDENT$h ||
  10403. this.lookupNonWSType(0) === LEFTPARENTHESIS$6) {
  10404. children.push(this.WhiteSpace());
  10405. children.push(this.MediaQueryList());
  10406. }
  10407. return children;
  10408. },
  10409. block: null
  10410. }
  10411. };
  10412. var media = {
  10413. parse: {
  10414. prelude: function() {
  10415. return this.createSingleNodeList(
  10416. this.MediaQueryList()
  10417. );
  10418. },
  10419. block: function() {
  10420. return this.Block(false);
  10421. }
  10422. }
  10423. };
  10424. var page = {
  10425. parse: {
  10426. prelude: function() {
  10427. return this.createSingleNodeList(
  10428. this.SelectorList()
  10429. );
  10430. },
  10431. block: function() {
  10432. return this.Block(true);
  10433. }
  10434. }
  10435. };
  10436. var TYPE$H = tokenizer.TYPE;
  10437. var WHITESPACE$c = TYPE$H.WhiteSpace;
  10438. var COMMENT$a = TYPE$H.Comment;
  10439. var IDENT$i = TYPE$H.Ident;
  10440. var FUNCTION$6 = TYPE$H.Function;
  10441. var COLON$6 = TYPE$H.Colon;
  10442. var LEFTPARENTHESIS$7 = TYPE$H.LeftParenthesis;
  10443. function consumeRaw$5() {
  10444. return this.createSingleNodeList(
  10445. this.Raw(this.scanner.tokenIndex, null, false)
  10446. );
  10447. }
  10448. function parentheses() {
  10449. this.scanner.skipSC();
  10450. if (this.scanner.tokenType === IDENT$i &&
  10451. this.lookupNonWSType(1) === COLON$6) {
  10452. return this.createSingleNodeList(
  10453. this.Declaration()
  10454. );
  10455. }
  10456. return readSequence.call(this);
  10457. }
  10458. function readSequence() {
  10459. var children = this.createList();
  10460. var space = null;
  10461. var child;
  10462. this.scanner.skipSC();
  10463. scan:
  10464. while (!this.scanner.eof) {
  10465. switch (this.scanner.tokenType) {
  10466. case WHITESPACE$c:
  10467. space = this.WhiteSpace();
  10468. continue;
  10469. case COMMENT$a:
  10470. this.scanner.next();
  10471. continue;
  10472. case FUNCTION$6:
  10473. child = this.Function(consumeRaw$5, this.scope.AtrulePrelude);
  10474. break;
  10475. case IDENT$i:
  10476. child = this.Identifier();
  10477. break;
  10478. case LEFTPARENTHESIS$7:
  10479. child = this.Parentheses(parentheses, this.scope.AtrulePrelude);
  10480. break;
  10481. default:
  10482. break scan;
  10483. }
  10484. if (space !== null) {
  10485. children.push(space);
  10486. space = null;
  10487. }
  10488. children.push(child);
  10489. }
  10490. return children;
  10491. }
  10492. var supports = {
  10493. parse: {
  10494. prelude: function() {
  10495. var children = readSequence.call(this);
  10496. if (this.getFirstListNode(children) === null) {
  10497. this.error('Condition is expected');
  10498. }
  10499. return children;
  10500. },
  10501. block: function() {
  10502. return this.Block(false);
  10503. }
  10504. }
  10505. };
  10506. var atrule = {
  10507. 'font-face': fontFace,
  10508. 'import': _import,
  10509. 'media': media,
  10510. 'page': page,
  10511. 'supports': supports
  10512. };
  10513. var dir = {
  10514. parse: function() {
  10515. return this.createSingleNodeList(
  10516. this.Identifier()
  10517. );
  10518. }
  10519. };
  10520. var has$1 = {
  10521. parse: function() {
  10522. return this.createSingleNodeList(
  10523. this.SelectorList()
  10524. );
  10525. }
  10526. };
  10527. var lang = {
  10528. parse: function() {
  10529. return this.createSingleNodeList(
  10530. this.Identifier()
  10531. );
  10532. }
  10533. };
  10534. var selectorList = {
  10535. parse: function selectorList() {
  10536. return this.createSingleNodeList(
  10537. this.SelectorList()
  10538. );
  10539. }
  10540. };
  10541. var matches = selectorList;
  10542. var not = selectorList;
  10543. var ALLOW_OF_CLAUSE = true;
  10544. var nthWithOfClause = {
  10545. parse: function nthWithOfClause() {
  10546. return this.createSingleNodeList(
  10547. this.Nth(ALLOW_OF_CLAUSE)
  10548. );
  10549. }
  10550. };
  10551. var nthChild = nthWithOfClause;
  10552. var nthLastChild = nthWithOfClause;
  10553. var DISALLOW_OF_CLAUSE = false;
  10554. var nth = {
  10555. parse: function nth() {
  10556. return this.createSingleNodeList(
  10557. this.Nth(DISALLOW_OF_CLAUSE)
  10558. );
  10559. }
  10560. };
  10561. var nthLastOfType = nth;
  10562. var nthOfType = nth;
  10563. var slotted = {
  10564. parse: function compoundSelector() {
  10565. return this.createSingleNodeList(
  10566. this.Selector()
  10567. );
  10568. }
  10569. };
  10570. var pseudo = {
  10571. 'dir': dir,
  10572. 'has': has$1,
  10573. 'lang': lang,
  10574. 'matches': matches,
  10575. 'not': not,
  10576. 'nth-child': nthChild,
  10577. 'nth-last-child': nthLastChild,
  10578. 'nth-last-of-type': nthLastOfType,
  10579. 'nth-of-type': nthOfType,
  10580. 'slotted': slotted
  10581. };
  10582. var parser = {
  10583. parseContext: {
  10584. default: 'StyleSheet',
  10585. stylesheet: 'StyleSheet',
  10586. atrule: 'Atrule',
  10587. atrulePrelude: function(options) {
  10588. return this.AtrulePrelude(options.atrule ? String(options.atrule) : null);
  10589. },
  10590. mediaQueryList: 'MediaQueryList',
  10591. mediaQuery: 'MediaQuery',
  10592. rule: 'Rule',
  10593. selectorList: 'SelectorList',
  10594. selector: 'Selector',
  10595. block: function() {
  10596. return this.Block(true);
  10597. },
  10598. declarationList: 'DeclarationList',
  10599. declaration: 'Declaration',
  10600. value: 'Value'
  10601. },
  10602. scope: scope,
  10603. atrule: atrule,
  10604. pseudo: pseudo,
  10605. node: node
  10606. };
  10607. var walker = {
  10608. node: node
  10609. };
  10610. var version = "1.1.3";
  10611. var _package = {
  10612. version: version
  10613. };
  10614. var _package$1 = /*#__PURE__*/Object.freeze({
  10615. __proto__: null,
  10616. version: version,
  10617. 'default': _package
  10618. });
  10619. var require$$4 = getCjsExportFromNamespace(_package$1);
  10620. function merge() {
  10621. var dest = {};
  10622. for (var i = 0; i < arguments.length; i++) {
  10623. var src = arguments[i];
  10624. for (var key in src) {
  10625. dest[key] = src[key];
  10626. }
  10627. }
  10628. return dest;
  10629. }
  10630. var syntax = create$4.create(
  10631. merge(
  10632. lexer,
  10633. parser,
  10634. walker
  10635. )
  10636. );
  10637. var version$1 = require$$4.version;
  10638. syntax.version = version$1;
  10639. var lib = syntax;
  10640. return lib;
  10641. })));