UNPKG

lightfold

Version:

lightweight scaffolding and archiving utility CLI.

1 lines 159 kB
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).csstree=t()}(this,(function(){"use strict";function e(e){return{prev:null,next:null,data:e}}function t(e,t,n){var i;return null!==r?(i=r,r=r.cursor,i.prev=t,i.next=n,i.cursor=e.cursor):i={prev:t,next:n,cursor:e.cursor},e.cursor=i,i}function n(e){var t=e.cursor;e.cursor=t.cursor,t.prev=null,t.next=null,t.cursor=r,r=t}var r=null,i=function(){this.cursor=null,this.head=null,this.tail=null};i.createItem=e,i.prototype.createItem=e,i.prototype.updateCursors=function(e,t,n,r){for(var i=this.cursor;null!==i;)i.prev===e&&(i.prev=t),i.next===n&&(i.next=r),i=i.cursor},i.prototype.getSize=function(){for(var e=0,t=this.head;t;)e++,t=t.next;return e},i.prototype.fromArray=function(t){var n=null;this.head=null;for(var r=0;r<t.length;r++){var i=e(t[r]);null!==n?n.next=i:this.head=i,i.prev=n,n=i}return this.tail=n,this},i.prototype.toArray=function(){for(var e=this.head,t=[];e;)t.push(e.data),e=e.next;return t},i.prototype.toJSON=i.prototype.toArray,i.prototype.isEmpty=function(){return null===this.head},i.prototype.first=function(){return this.head&&this.head.data},i.prototype.last=function(){return this.tail&&this.tail.data},i.prototype.each=function(e,r){var i;void 0===r&&(r=this);for(var a=t(this,null,this.head);null!==a.next;)i=a.next,a.next=i.next,e.call(r,i.data,i,this);n(this)},i.prototype.forEach=i.prototype.each,i.prototype.eachRight=function(e,r){var i;void 0===r&&(r=this);for(var a=t(this,this.tail,null);null!==a.prev;)i=a.prev,a.prev=i.prev,e.call(r,i.data,i,this);n(this)},i.prototype.forEachRight=i.prototype.eachRight,i.prototype.nextUntil=function(e,r,i){if(null!==e){var a;void 0===i&&(i=this);for(var o=t(this,null,e);null!==o.next&&(a=o.next,o.next=a.next,!r.call(i,a.data,a,this)););n(this)}},i.prototype.prevUntil=function(e,r,i){if(null!==e){var a;void 0===i&&(i=this);for(var o=t(this,e,null);null!==o.prev&&(a=o.prev,o.prev=a.prev,!r.call(i,a.data,a,this)););n(this)}},i.prototype.some=function(e,t){var n=this.head;for(void 0===t&&(t=this);null!==n;){if(e.call(t,n.data,n,this))return!0;n=n.next}return!1},i.prototype.map=function(e,t){var n=new i,r=this.head;for(void 0===t&&(t=this);null!==r;)n.appendData(e.call(t,r.data,r,this)),r=r.next;return n},i.prototype.filter=function(e,t){var n=new i,r=this.head;for(void 0===t&&(t=this);null!==r;)e.call(t,r.data,r,this)&&n.appendData(r.data),r=r.next;return n},i.prototype.clear=function(){this.head=null,this.tail=null},i.prototype.copy=function(){for(var t=new i,n=this.head;null!==n;)t.insert(e(n.data)),n=n.next;return t},i.prototype.prepend=function(e){return this.updateCursors(null,e,this.head,e),null!==this.head?(this.head.prev=e,e.next=this.head):this.tail=e,this.head=e,this},i.prototype.prependData=function(t){return this.prepend(e(t))},i.prototype.append=function(e){return this.insert(e)},i.prototype.appendData=function(t){return this.insert(e(t))},i.prototype.insert=function(e,t){if(null!=t)if(this.updateCursors(t.prev,e,t,e),null===t.prev){if(this.head!==t)throw new Error("before doesn't belong to list");this.head=e,t.prev=e,e.next=t,this.updateCursors(null,e)}else t.prev.next=e,e.prev=t.prev,t.prev=e,e.next=t;else this.updateCursors(this.tail,e,null,e),null!==this.tail?(this.tail.next=e,e.prev=this.tail):this.head=e,this.tail=e;return this},i.prototype.insertData=function(t,n){return this.insert(e(t),n)},i.prototype.remove=function(e){if(this.updateCursors(e,e.prev,e,e.next),null!==e.prev)e.prev.next=e.next;else{if(this.head!==e)throw new Error("item doesn't belong to list");this.head=e.next}if(null!==e.next)e.next.prev=e.prev;else{if(this.tail!==e)throw new Error("item doesn't belong to list");this.tail=e.prev}return e.prev=null,e.next=null,e},i.prototype.push=function(t){this.insert(e(t))},i.prototype.pop=function(){if(null!==this.tail)return this.remove(this.tail)},i.prototype.unshift=function(t){this.prepend(e(t))},i.prototype.shift=function(){if(null!==this.head)return this.remove(this.head)},i.prototype.prependList=function(e){return this.insertList(e,this.head)},i.prototype.appendList=function(e){return this.insertList(e)},i.prototype.insertList=function(e,t){return null===e.head?this:(null!=t?(this.updateCursors(t.prev,e.tail,t,e.head),null!==t.prev?(t.prev.next=e.head,e.head.prev=t.prev):this.head=e.head,t.prev=e.tail,e.tail.next=t):(this.updateCursors(this.tail,e.tail,null,e.head),null!==this.tail?(this.tail.next=e.head,e.head.prev=this.tail):this.head=e.head,this.tail=e.tail),e.head=null,e.tail=null,this)},i.prototype.replace=function(e,t){"head"in t?this.insertList(t,e):this.insert(t,e),this.remove(e)};var a=i,o=function(e,t){var n=Object.create(SyntaxError.prototype),r=new Error;return n.name=e,n.message=t,Object.defineProperty(n,"stack",{get:function(){return(r.stack||"").replace(/^(.+\n){1,3}/,e+": "+t+"\n")}}),n},s=100,l=60,c=" ";function u(e,t){function n(e,t){return r.slice(e,t).map((function(t,n){for(var r=String(e+n+1);r.length<h;)r=" "+r;return r+" |"+t})).join("\n")}var r=e.source.split(/\r\n?|\n|\f/),i=e.line,a=e.column,o=Math.max(1,i-t)-1,u=Math.min(i+t,r.length+1),h=Math.max(4,String(u).length)+1,p=0;(a+=(c.length-1)*(r[i-1].substr(0,a-1).match(/\t/g)||[]).length)>s&&(p=a-l+3,a=l-2);for(var d=o;d<=u;d++)d>=0&&d<r.length&&(r[d]=r[d].replace(/\t/g,c),r[d]=(p>0&&r[d].length>p?"…":"")+r[d].substr(p,s-2)+(r[d].length>p+s-1?"…":""));return[n(o,i),new Array(a+h+2).join("-")+"^",n(i,u)].filter(Boolean).join("\n")}var h=function(e,t,n,r,i){var a=o("SyntaxError",e);return a.source=t,a.offset=n,a.line=r,a.column=i,a.sourceFragment=function(e){return u(a,isNaN(e)?0:e)},Object.defineProperty(a,"formattedMessage",{get:function(){return"Parse error: "+a.message+"\n"+u(a,2)}}),a.parseError={offset:n,line:r,column:i},a},p={EOF:0,Ident:1,Function:2,AtKeyword:3,Hash:4,String:5,BadString:6,Url:7,BadUrl:8,Delim:9,Number:10,Percentage:11,Dimension:12,WhiteSpace:13,CDO:14,CDC:15,Colon:16,Semicolon:17,Comma:18,LeftSquareBracket:19,RightSquareBracket:20,LeftParenthesis:21,RightParenthesis:22,LeftCurlyBracket:23,RightCurlyBracket:24,Comment:25},d=Object.keys(p).reduce((function(e,t){return e[p[t]]=t,e}),{}),m={TYPE:p,NAME:d},g=0;function f(e){return e>=48&&e<=57}function b(e){return e>=65&&e<=90}function y(e){return e>=97&&e<=122}function k(e){return b(e)||y(e)}function v(e){return e>=128}function x(e){return k(e)||v(e)||95===e}function w(e){return e>=0&&e<=8||11===e||e>=14&&e<=31||127===e}function S(e){return 10===e||13===e||12===e}function C(e){return S(e)||32===e||9===e}function z(e,t){return 92===e&&(!S(t)&&t!==g)}var A=new Array(128);T.Eof=128,T.WhiteSpace=130,T.Digit=131,T.NameStart=132,T.NonPrintable=133;for(var P=0;P<A.length;P++)switch(!0){case C(P):A[P]=T.WhiteSpace;break;case f(P):A[P]=T.Digit;break;case x(P):A[P]=T.NameStart;break;case w(P):A[P]=T.NonPrintable;break;default:A[P]=P||T.Eof}function T(e){return e<128?A[e]:T.NameStart}var L={isDigit:f,isHexDigit:function(e){return f(e)||e>=65&&e<=70||e>=97&&e<=102},isUppercaseLetter:b,isLowercaseLetter:y,isLetter:k,isNonAscii:v,isNameStart:x,isName:function(e){return x(e)||f(e)||45===e},isNonPrintable:w,isNewline:S,isWhiteSpace:C,isValidEscape:z,isIdentifierStart:function(e,t,n){return 45===e?x(t)||45===t||z(t,n):!!x(e)||92===e&&z(e,t)},isNumberStart:function(e,t,n){return 43===e||45===e?f(t)?2:46===t&&f(n)?3:0:46===e?f(t)?2:0:f(e)?1:0},isBOM:function(e){return 65279===e?1:65534===e?1:0},charCodeCategory:T},E=L.isDigit,O=L.isHexDigit,D=L.isUppercaseLetter,B=L.isName,I=L.isWhiteSpace,N=L.isValidEscape;function M(e,t){return t<e.length?e.charCodeAt(t):0}function R(e,t,n){return 13===n&&10===M(e,t+1)?2:1}function _(e,t,n){var r=e.charCodeAt(t);return D(r)&&(r|=32),r===n}function j(e,t){for(;t<e.length&&E(e.charCodeAt(t));t++);return t}function F(e,t){if(O(M(e,(t+=2)-1))){for(var n=Math.min(e.length,t+5);t<n&&O(M(e,t));t++);var r=M(e,t);I(r)&&(t+=R(e,t,r))}return t}var W={consumeEscaped:F,consumeName:function(e,t){for(;t<e.length;t++){var n=e.charCodeAt(t);if(!B(n)){if(!N(n,M(e,t+1)))break;t=F(e,t)-1}}return t},consumeNumber:function(e,t){var n=e.charCodeAt(t);if(43!==n&&45!==n||(n=e.charCodeAt(t+=1)),E(n)&&(t=j(e,t+1),n=e.charCodeAt(t)),46===n&&E(e.charCodeAt(t+1))&&(n=e.charCodeAt(t+=2),t=j(e,t)),_(e,t,101)){var r=0;45!==(n=e.charCodeAt(t+1))&&43!==n||(r=1,n=e.charCodeAt(t+2)),E(n)&&(t=j(e,t+1+r+1))}return t},consumeBadUrlRemnants:function(e,t){for(;t<e.length;t++){var n=e.charCodeAt(t);if(41===n){t++;break}N(n,M(e,t+1))&&(t=F(e,t))}return t},cmpChar:_,cmpStr:function(e,t,n,r){if(n-t!==r.length)return!1;if(t<0||n>e.length)return!1;for(var i=t;i<n;i++){var a=e.charCodeAt(i),o=r.charCodeAt(i-t);if(D(a)&&(a|=32),a!==o)return!1}return!0},getNewlineLength:R,findWhiteSpaceStart:function(e,t){for(;t>=0&&I(e.charCodeAt(t));t--);return t+1},findWhiteSpaceEnd:function(e,t){for(;t<e.length&&I(e.charCodeAt(t));t++);return t}},q=m.TYPE,Y=m.NAME,U=W.cmpStr,H=q.EOF,V=q.WhiteSpace,G=q.Comment,K=function(){this.offsetAndType=null,this.balance=null,this.reset()};K.prototype={reset:function(){this.eof=!1,this.tokenIndex=-1,this.tokenType=0,this.tokenStart=this.firstCharOffset,this.tokenEnd=this.firstCharOffset},lookupType:function(e){return(e+=this.tokenIndex)<this.tokenCount?this.offsetAndType[e]>>24:H},lookupOffset:function(e){return(e+=this.tokenIndex)<this.tokenCount?16777215&this.offsetAndType[e-1]:this.source.length},lookupValue:function(e,t){return(e+=this.tokenIndex)<this.tokenCount&&U(this.source,16777215&this.offsetAndType[e-1],16777215&this.offsetAndType[e],t)},getTokenStart:function(e){return e===this.tokenIndex?this.tokenStart:e>0?e<this.tokenCount?16777215&this.offsetAndType[e-1]:16777215&this.offsetAndType[this.tokenCount]:this.firstCharOffset},getRawLength:function(e,t){var n,r=e,i=16777215&this.offsetAndType[Math.max(r-1,0)];e:for(;r<this.tokenCount&&!((n=this.balance[r])<e);r++)switch(t(this.offsetAndType[r]>>24,this.source,i)){case 1:break e;case 2:r++;break e;default:i=16777215&this.offsetAndType[r],this.balance[n]===r&&(r=n)}return r-this.tokenIndex},isBalanceEdge:function(e){return this.balance[this.tokenIndex]<e},isDelim:function(e,t){return t?this.lookupType(t)===q.Delim&&this.source.charCodeAt(this.lookupOffset(t))===e:this.tokenType===q.Delim&&this.source.charCodeAt(this.tokenStart)===e},getTokenValue:function(){return this.source.substring(this.tokenStart,this.tokenEnd)},getTokenLength:function(){return this.tokenEnd-this.tokenStart},substrToCursor:function(e){return this.source.substring(e,this.tokenStart)},skipWS:function(){for(var e=this.tokenIndex,t=0;e<this.tokenCount&&this.offsetAndType[e]>>24===V;e++,t++);t>0&&this.skip(t)},skipSC:function(){for(;this.tokenType===V||this.tokenType===G;)this.next()},skip:function(e){var t=this.tokenIndex+e;t<this.tokenCount?(this.tokenIndex=t,this.tokenStart=16777215&this.offsetAndType[t-1],t=this.offsetAndType[t],this.tokenType=t>>24,this.tokenEnd=16777215&t):(this.tokenIndex=this.tokenCount,this.next())},next:function(){var e=this.tokenIndex+1;e<this.tokenCount?(this.tokenIndex=e,this.tokenStart=this.tokenEnd,e=this.offsetAndType[e],this.tokenType=e>>24,this.tokenEnd=16777215&e):(this.tokenIndex=this.tokenCount,this.eof=!0,this.tokenType=H,this.tokenStart=this.tokenEnd=this.source.length)},dump:function(){var e=this.firstCharOffset;return Array.prototype.slice.call(this.offsetAndType,0,this.tokenCount).map((function(t,n){var r=e,i=16777215&t;return e=i,{idx:n,type:Y[t>>24],chunk:this.source.substring(r,i),balance:this.balance[n]}}),this)}};var Q=K;function X(e){return e}function Z(e,t,n,r){var i,a;switch(e.type){case"Group":i=function(e,t,n,r){var i=" "===e.combinator||r?e.combinator:" "+e.combinator+" ",a=e.terms.map((function(e){return Z(e,t,n,r)})).join(i);return(e.explicit||n)&&(a=(r||","===a[0]?"[":"[ ")+a+(r?"]":" ]")),a}(e,t,n,r)+(e.disallowEmpty?"!":"");break;case"Multiplier":return Z(e.term,t,n,r)+t(0===(a=e).min&&0===a.max?"*":0===a.min&&1===a.max?"?":1===a.min&&0===a.max?a.comma?"#":"+":1===a.min&&1===a.max?"":(a.comma?"#":"")+(a.min===a.max?"{"+a.min+"}":"{"+a.min+","+(0!==a.max?a.max:"")+"}"),e);case"Type":i="<"+e.name+(e.opts?t(function(e){switch(e.type){case"Range":return" ["+(null===e.min?"-∞":e.min)+","+(null===e.max?"∞":e.max)+"]";default:throw new Error("Unknown node type `"+e.type+"`")}}(e.opts),e.opts):"")+">";break;case"Property":i="<'"+e.name+"'>";break;case"Keyword":i=e.name;break;case"AtKeyword":i="@"+e.name;break;case"Function":i=e.name+"(";break;case"String":case"Token":i=e.value;break;case"Comma":i=",";break;default:throw new Error("Unknown node type `"+e.type+"`")}return t(i,e)}var $=function(e,t){var n=X,r=!1,i=!1;return"function"==typeof t?n=t:t&&(r=Boolean(t.forceBraces),i=Boolean(t.compact),"function"==typeof t.decorate&&(n=t.decorate)),Z(e,n,r,i)};function J(e,t){var n=e&&e.loc&&e.loc[t];return n?{offset:n.offset,line:n.line,column:n.column}:null}var ee=function(e,t){var n=o("SyntaxReferenceError",e+(t?" `"+t+"`":""));return n.reference=t,n},te=function(e,t,n,r){var i=o("SyntaxMatchError",e),a=function(e){for(var t=e.tokens,n=e.longestMatch,r=n<t.length?t[n].node:null,i=-1,a=0,o="",s=0;s<t.length;s++)s===n&&(i=o.length),null!==r&&t[s].node===r&&(s<=n?a++:a=0),o+=t[s].value;return{node:r,css:o,mismatchOffset:-1===i?o.length:i,last:null===r||a>1}}(r),s=a.mismatchOffset||0,l=a.node||n,c=J(l,"end"),u=a.last?c:J(l,"start"),h=a.css;return i.rawMessage=e,i.syntax=t?$(t):"<generic>",i.css=h,i.mismatchOffset=s,i.loc={source:l&&l.loc&&l.loc.source||"<unknown>",start:u,end:c},i.line=u?u.line:void 0,i.column=u?u.column:void 0,i.offset=u?u.offset:void 0,i.message=e+"\n syntax: "+i.syntax+"\n value: "+(i.css||"<empty string>")+"\n --------"+new Array(i.mismatchOffset+1).join("-")+"^",i},ne=Object.prototype.hasOwnProperty,re=Object.create(null),ie=Object.create(null),ae=45;function oe(e,t){return t=t||0,e.length-t>=2&&e.charCodeAt(t)===ae&&e.charCodeAt(t+1)===ae}function se(e,t){if(t=t||0,e.length-t>=3&&e.charCodeAt(t)===ae&&e.charCodeAt(t+1)!==ae){var n=e.indexOf("-",t+2);if(-1!==n)return e.substring(t,n+1)}return""}var le={keyword:function(e){if(ne.call(re,e))return re[e];var t=e.toLowerCase();if(ne.call(re,t))return re[e]=re[t];var n=oe(t,0),r=n?"":se(t,0);return re[e]=Object.freeze({basename:t.substr(r.length),name:t,vendor:r,prefix:r,custom:n})},property:function(e){if(ne.call(ie,e))return ie[e];var t=e,n=e[0];"/"===n?n="/"===e[1]?"//":"/":"_"!==n&&"*"!==n&&"$"!==n&&"#"!==n&&"+"!==n&&"&"!==n&&(n="");var r=oe(t,n.length);if(!r&&(t=t.toLowerCase(),ne.call(ie,t)))return ie[e]=ie[t];var i=r?"":se(t,n.length),a=t.substr(0,n.length+i.length);return ie[e]=Object.freeze({basename:t.substr(a.length),name:t.substr(n.length),hack:n,vendor:i,prefix:a,custom:r})},isCustomProperty:oe,vendorPrefix:se},ce="undefined"!=typeof Uint32Array?Uint32Array:Array,ue=function(e,t){return null===e||e.length<t?new ce(Math.max(t+1024,16384)):e},he=m.TYPE,pe=L.isNewline,de=L.isName,me=L.isValidEscape,ge=L.isNumberStart,fe=L.isIdentifierStart,be=L.charCodeCategory,ye=L.isBOM,ke=W.cmpStr,ve=W.getNewlineLength,xe=W.findWhiteSpaceEnd,we=W.consumeEscaped,Se=W.consumeName,Ce=W.consumeNumber,ze=W.consumeBadUrlRemnants,Ae=16777215,Pe=24;function Te(e,t){function n(t){return t<o?e.charCodeAt(t):0}function r(){return h=Ce(e,h),fe(n(h),n(h+1),n(h+2))?(f=he.Dimension,void(h=Se(e,h))):37===n(h)?(f=he.Percentage,void h++):void(f=he.Number)}function i(){const t=h;return h=Se(e,h),ke(e,t,h,"url")&&40===n(h)?34===n(h=xe(e,h+1))||39===n(h)?(f=he.Function,void(h=t+4)):void function(){for(f=he.Url,h=xe(e,h);h<e.length;h++){var t=e.charCodeAt(h);switch(be(t)){case 41:return void h++;case be.Eof:return;case be.WhiteSpace:return 41===n(h=xe(e,h))||h>=e.length?void(h<e.length&&h++):(h=ze(e,h),void(f=he.BadUrl));case 34:case 39:case 40:case be.NonPrintable:return h=ze(e,h),void(f=he.BadUrl);case 92:if(me(t,n(h+1))){h=we(e,h)-1;break}return h=ze(e,h),void(f=he.BadUrl)}}}():40===n(h)?(f=he.Function,void h++):void(f=he.Ident)}function a(t){for(t||(t=n(h++)),f=he.String;h<e.length;h++){var r=e.charCodeAt(h);switch(be(r)){case t:return void h++;case be.Eof:return;case be.WhiteSpace:if(pe(r))return h+=ve(e,h,r),void(f=he.BadString);break;case 92:if(h===e.length-1)break;var i=n(h+1);pe(i)?h+=ve(e,h+1,i):me(r,i)&&(h=we(e,h)-1)}}}t||(t=new Q);for(var o=(e=String(e||"")).length,s=ue(t.offsetAndType,o+1),l=ue(t.balance,o+1),c=0,u=ye(n(0)),h=u,p=0,d=0,m=0;h<o;){var g=e.charCodeAt(h),f=0;switch(l[c]=o,be(g)){case be.WhiteSpace:f=he.WhiteSpace,h=xe(e,h+1);break;case 34:a();break;case 35:de(n(h+1))||me(n(h+1),n(h+2))?(f=he.Hash,h=Se(e,h+1)):(f=he.Delim,h++);break;case 39:a();break;case 40:f=he.LeftParenthesis,h++;break;case 41:f=he.RightParenthesis,h++;break;case 43:ge(g,n(h+1),n(h+2))?r():(f=he.Delim,h++);break;case 44:f=he.Comma,h++;break;case 45:ge(g,n(h+1),n(h+2))?r():45===n(h+1)&&62===n(h+2)?(f=he.CDC,h+=3):fe(g,n(h+1),n(h+2))?i():(f=he.Delim,h++);break;case 46:ge(g,n(h+1),n(h+2))?r():(f=he.Delim,h++);break;case 47:42===n(h+1)?(f=he.Comment,1===(h=e.indexOf("*/",h+2)+2)&&(h=e.length)):(f=he.Delim,h++);break;case 58:f=he.Colon,h++;break;case 59:f=he.Semicolon,h++;break;case 60:33===n(h+1)&&45===n(h+2)&&45===n(h+3)?(f=he.CDO,h+=4):(f=he.Delim,h++);break;case 64:fe(n(h+1),n(h+2),n(h+3))?(f=he.AtKeyword,h=Se(e,h+1)):(f=he.Delim,h++);break;case 91:f=he.LeftSquareBracket,h++;break;case 92:me(g,n(h+1))?i():(f=he.Delim,h++);break;case 93:f=he.RightSquareBracket,h++;break;case 123:f=he.LeftCurlyBracket,h++;break;case 125:f=he.RightCurlyBracket,h++;break;case be.Digit:r();break;case be.NameStart:i();break;case be.Eof:break;default:f=he.Delim,h++}switch(f){case p:for(p=(d=l[m=d&Ae])>>Pe,l[c]=m,l[m++]=c;m<c;m++)l[m]===o&&(l[m]=c);break;case he.LeftParenthesis:case he.Function:l[c]=d,d=(p=he.RightParenthesis)<<Pe|c;break;case he.LeftSquareBracket:l[c]=d,d=(p=he.RightSquareBracket)<<Pe|c;break;case he.LeftCurlyBracket:l[c]=d,d=(p=he.RightCurlyBracket)<<Pe|c}s[c++]=f<<Pe|h}for(s[c]=he.EOF<<Pe|h,l[c]=o,l[o]=o;0!==d;)d=l[m=d&Ae],l[m]=o;return t.source=e,t.firstCharOffset=u,t.offsetAndType=s,t.tokenCount=c,t.balance=l,t.reset(),t.next(),t}Object.keys(m).forEach((function(e){Te[e]=m[e]})),Object.keys(L).forEach((function(e){Te[e]=L[e]})),Object.keys(W).forEach((function(e){Te[e]=W[e]}));var Le=Te,Ee=Le.isDigit,Oe=Le.cmpChar,De=Le.TYPE,Be=De.Delim,Ie=De.WhiteSpace,Ne=De.Comment,Me=De.Ident,Re=De.Number,_e=De.Dimension,je=43,Fe=45;function We(e,t){return null!==e&&e.type===Be&&e.value.charCodeAt(0)===t}function qe(e,t,n){for(;null!==e&&(e.type===Ie||e.type===Ne);)e=n(++t);return t}function Ye(e,t,n,r){if(!e)return 0;var i=e.value.charCodeAt(t);if(i===je||i===Fe){if(n)return 0;t++}for(;t<e.value.length;t++)if(!Ee(e.value.charCodeAt(t)))return 0;return r+1}function Ue(e,t,n){var r=!1,i=qe(e,t,n);if(null===(e=n(i)))return t;if(e.type!==Re){if(!We(e,je)&&!We(e,Fe))return t;if(r=!0,i=qe(n(++i),i,n),null===(e=n(i))&&e.type!==Re)return 0}if(!r){var a=e.value.charCodeAt(0);if(a!==je&&a!==Fe)return 0}return Ye(e,r?0:1,r,i)}var He=Le.isHexDigit,Ve=Le.cmpChar,Ge=Le.TYPE,Ke=Ge.Ident,Qe=Ge.Delim,Xe=Ge.Number,Ze=Ge.Dimension,$e=45,Je=63;function et(e,t){return null!==e&&e.type===Qe&&e.value.charCodeAt(0)===t}function tt(e,t){return e.value.charCodeAt(0)===t}function nt(e,t,n){for(var r=t,i=0;r<e.value.length;r++){var a=e.value.charCodeAt(r);if(a===$e&&n&&0!==i)return nt(e,t+i+1,!1)>0?6:0;if(!He(a))return 0;if(++i>6)return 0}return i}function rt(e,t,n){if(!e)return 0;for(;et(n(t),Je);){if(++e>6)return 0;t++}return t}var it=Le.isIdentifierStart,at=Le.isHexDigit,ot=Le.isDigit,st=Le.cmpStr,lt=Le.consumeNumber,ct=Le.TYPE,ut=["unset","initial","inherit"],ht=["calc(","-moz-calc(","-webkit-calc("];function pt(e,t){return t<e.length?e.charCodeAt(t):0}function dt(e,t){return st(e,0,e.length,t)}function mt(e,t){for(var n=0;n<t.length;n++)if(dt(e,t[n]))return!0;return!1}function gt(e,t){return t===e.length-2&&(92===e.charCodeAt(t)&&ot(e.charCodeAt(t+1)))}function ft(e,t,n){if(e&&"Range"===e.type){var r=Number(void 0!==n&&n!==t.length?t.substr(0,n):t);if(isNaN(r))return!0;if(null!==e.min&&r<e.min)return!0;if(null!==e.max&&r>e.max)return!0}return!1}function bt(e,t){var n=e.index,r=0;do{if(r++,e.balance<=n)break}while(e=t(r));return r}function yt(e){return function(t,n,r){return null===t?0:t.type===ct.Function&&mt(t.value,ht)?bt(t,n):e(t,n,r)}}function kt(e){return function(t){return null===t||t.type!==e?0:1}}function vt(e){return function(t,n,r){if(null===t||t.type!==ct.Dimension)return 0;var i=lt(t.value,0);if(null!==e){var a=t.value.indexOf("\\",i),o=-1!==a&&gt(t.value,a)?t.value.substring(i,a):t.value.substr(i);if(!1===e.hasOwnProperty(o.toLowerCase()))return 0}return ft(r,t.value,i)?0:1}}function xt(e){return"function"!=typeof e&&(e=function(){return 0}),function(t,n,r){return null!==t&&t.type===ct.Number&&0===Number(t.value)?1:e(t,n,r)}}var wt,St={"ident-token":kt(ct.Ident),"function-token":kt(ct.Function),"at-keyword-token":kt(ct.AtKeyword),"hash-token":kt(ct.Hash),"string-token":kt(ct.String),"bad-string-token":kt(ct.BadString),"url-token":kt(ct.Url),"bad-url-token":kt(ct.BadUrl),"delim-token":kt(ct.Delim),"number-token":kt(ct.Number),"percentage-token":kt(ct.Percentage),"dimension-token":kt(ct.Dimension),"whitespace-token":kt(ct.WhiteSpace),"CDO-token":kt(ct.CDO),"CDC-token":kt(ct.CDC),"colon-token":kt(ct.Colon),"semicolon-token":kt(ct.Semicolon),"comma-token":kt(ct.Comma),"[-token":kt(ct.LeftSquareBracket),"]-token":kt(ct.RightSquareBracket),"(-token":kt(ct.LeftParenthesis),")-token":kt(ct.RightParenthesis),"{-token":kt(ct.LeftCurlyBracket),"}-token":kt(ct.RightCurlyBracket),string:kt(ct.String),ident:kt(ct.Ident),"custom-ident":function(e){if(null===e||e.type!==ct.Ident)return 0;var t=e.value.toLowerCase();return mt(t,ut)?0:dt(t,"default")?0:1},"custom-property-name":function(e){return null===e||e.type!==ct.Ident?0:45!==pt(e.value,0)||45!==pt(e.value,1)?0:1},"hex-color":function(e){if(null===e||e.type!==ct.Hash)return 0;var t=e.value.length;if(4!==t&&5!==t&&7!==t&&9!==t)return 0;for(var n=1;n<t;n++)if(!at(e.value.charCodeAt(n)))return 0;return 1},"id-selector":function(e){return null===e||e.type!==ct.Hash?0:it(pt(e.value,1),pt(e.value,2),pt(e.value,3))?1:0},"an-plus-b":function(e,t){var n=0;if(!e)return 0;if(e.type===Re)return Ye(e,0,!1,n);if(e.type===Me&&e.value.charCodeAt(0)===Fe){if(!Oe(e.value,1,110))return 0;switch(e.value.length){case 2:return Ue(t(++n),n,t);case 3:return e.value.charCodeAt(2)!==Fe?0:(n=qe(t(++n),n,t),Ye(e=t(n),0,!0,n));default:return e.value.charCodeAt(2)!==Fe?0:Ye(e,3,!0,n)}}else if(e.type===Me||We(e,je)&&t(n+1).type===Me){if(e.type!==Me&&(e=t(++n)),null===e||!Oe(e.value,0,110))return 0;switch(e.value.length){case 1:return Ue(t(++n),n,t);case 2:return e.value.charCodeAt(1)!==Fe?0:(n=qe(t(++n),n,t),Ye(e=t(n),0,!0,n));default:return e.value.charCodeAt(1)!==Fe?0:Ye(e,2,!0,n)}}else if(e.type===_e){for(var r=e.value.charCodeAt(0),i=r===je||r===Fe?1:0,a=i;a<e.value.length&&Ee(e.value.charCodeAt(a));a++);return a===i?0:Oe(e.value,a,110)?a+1===e.value.length?Ue(t(++n),n,t):e.value.charCodeAt(a+1)!==Fe?0:a+2===e.value.length?(n=qe(t(++n),n,t),Ye(e=t(n),0,!0,n)):Ye(e,a+2,!0,n):0}return 0},urange:function(e,t){var n=0;if(null===e||e.type!==Ke||!Ve(e.value,0,117))return 0;if(null===(e=t(++n)))return 0;if(et(e,43))return null===(e=t(++n))?0:e.type===Ke?rt(nt(e,0,!0),++n,t):et(e,Je)?rt(1,++n,t):0;if(e.type===Xe){if(!tt(e,43))return 0;var r=nt(e,1,!0);return 0===r?0:null===(e=t(++n))?n:e.type===Ze||e.type===Xe?tt(e,$e)&&nt(e,1,!1)?n+1:0:rt(r,n,t)}return e.type===Ze&&tt(e,43)?rt(nt(e,1,!0),++n,t):0},"declaration-value":function(e,t){if(!e)return 0;var n=0,r=0,i=e.index;e:do{switch(e.type){case ct.BadString:case ct.BadUrl:break e;case ct.RightCurlyBracket:case ct.RightParenthesis:case ct.RightSquareBracket:if(e.balance>e.index||e.balance<i)break e;r--;break;case ct.Semicolon:if(0===r)break e;break;case ct.Delim:if("!"===e.value&&0===r)break e;break;case ct.Function:case ct.LeftParenthesis:case ct.LeftSquareBracket:case ct.LeftCurlyBracket:r++}if(n++,e.balance<=i)break}while(e=t(n));return n},"any-value":function(e,t){if(!e)return 0;var n=e.index,r=0;e:do{switch(e.type){case ct.BadString:case ct.BadUrl:break e;case ct.RightCurlyBracket:case ct.RightParenthesis:case ct.RightSquareBracket:if(e.balance>e.index||e.balance<n)break e}if(r++,e.balance<=n)break}while(e=t(r));return r},dimension:yt(vt(null)),angle:yt(vt({deg:!0,grad:!0,rad:!0,turn:!0})),decibel:yt(vt({db:!0})),frequency:yt(vt({hz:!0,khz:!0})),flex:yt(vt({fr:!0})),length:yt(xt(vt({px:!0,mm:!0,cm:!0,in:!0,pt:!0,pc:!0,q:!0,em:!0,ex:!0,ch:!0,rem:!0,vh:!0,vw:!0,vmin:!0,vmax:!0,vm:!0}))),resolution:yt(vt({dpi:!0,dpcm:!0,dppx:!0,x:!0})),semitones:yt(vt({st:!0})),time:yt(vt({s:!0,ms:!0})),percentage:yt((function(e,t,n){return null===e||e.type!==ct.Percentage?0:ft(n,e.value,e.value.length-1)?0:1})),zero:xt(),number:yt((function(e,t,n){if(null===e)return 0;var r=lt(e.value,0);return r===e.value.length||gt(e.value,r)?ft(n,e.value,r)?0:1:0})),integer:yt((function(e,t,n){if(null===e||e.type!==ct.Number)return 0;for(var r=43===e.value.charCodeAt(0)||45===e.value.charCodeAt(0)?1:0;r<e.value.length;r++)if(!ot(e.value.charCodeAt(r)))return 0;return ft(n,e.value,r)?0:1})),"-ms-legacy-expression":(wt="expression",wt+="(",function(e,t){return null!==e&&dt(e.value,wt)?bt(e,t):0})},Ct=function(e,t,n){var r=o("SyntaxError",e);return r.input=t,r.offset=n,r.rawMessage=e,r.message=r.rawMessage+"\n "+r.input+"\n--"+new Array((r.offset||r.input.length)+1).join("-")+"^",r},zt=function(e){this.str=e,this.pos=0};zt.prototype={charCodeAt:function(e){return e<this.str.length?this.str.charCodeAt(e):0},charCode:function(){return this.charCodeAt(this.pos)},nextCharCode:function(){return this.charCodeAt(this.pos+1)},nextNonWsCode:function(e){return this.charCodeAt(this.findWsEnd(e))},findWsEnd:function(e){for(;e<this.str.length;e++){var t=this.str.charCodeAt(e);if(13!==t&&10!==t&&12!==t&&32!==t&&9!==t)break}return e},substringToPos:function(e){return this.str.substring(this.pos,this.pos=e)},eat:function(e){this.charCode()!==e&&this.error("Expect `"+String.fromCharCode(e)+"`"),this.pos++},peek:function(){return this.pos<this.str.length?this.str.charAt(this.pos++):""},error:function(e){throw new Ct(e,this.str,this.pos)}};var At=zt,Pt=9,Tt=10,Lt=12,Et=13,Ot=32,Dt=33,Bt=35,It=38,Nt=39,Mt=40,Rt=41,_t=42,jt=43,Ft=44,Wt=45,qt=60,Yt=62,Ut=63,Ht=64,Vt=91,Gt=93,Kt=123,Qt=124,Xt=125,Zt=8734,$t=function(e){for(var t="function"==typeof Uint32Array?new Uint32Array(128):new Array(128),n=0;n<128;n++)t[n]=e(String.fromCharCode(n))?1:0;return t}((function(e){return/[a-zA-Z0-9\-]/.test(e)})),Jt={" ":1,"&&":2,"||":3,"|":4};function en(e){return e.substringToPos(e.findWsEnd(e.pos))}function tn(e){for(var t=e.pos;t<e.str.length;t++){var n=e.str.charCodeAt(t);if(n>=128||0===$t[n])break}return e.pos===t&&e.error("Expect a keyword"),e.substringToPos(t)}function nn(e){for(var t=e.pos;t<e.str.length;t++){var n=e.str.charCodeAt(t);if(n<48||n>57)break}return e.pos===t&&e.error("Expect a number"),e.substringToPos(t)}function rn(e){var t=e.str.indexOf("'",e.pos+1);return-1===t&&(e.pos=e.str.length,e.error("Expect an apostrophe")),e.substringToPos(t+1)}function an(e){var t,n=null;return e.eat(Kt),t=nn(e),e.charCode()===Ft?(e.pos++,e.charCode()!==Xt&&(n=nn(e))):n=t,e.eat(Xt),{min:Number(t),max:n?Number(n):0}}function on(e,t){var n=function(e){var t=null,n=!1;switch(e.charCode()){case _t:e.pos++,t={min:0,max:0};break;case jt:e.pos++,t={min:1,max:0};break;case Ut:e.pos++,t={min:0,max:1};break;case Bt:e.pos++,n=!0,t=e.charCode()===Kt?an(e):{min:1,max:0};break;case Kt:t=an(e);break;default:return null}return{type:"Multiplier",comma:n,min:t.min,max:t.max,term:null}}(e);return null!==n?(n.term=t,n):t}function sn(e){var t=e.peek();return""===t?null:{type:"Token",value:t}}function ln(e){var t,n=null;return e.eat(qt),t=tn(e),e.charCode()===Mt&&e.nextCharCode()===Rt&&(e.pos+=2,t+="()"),e.charCodeAt(e.findWsEnd(e.pos))===Vt&&(en(e),n=function(e){var t=null,n=null,r=1;return e.eat(Vt),e.charCode()===Wt&&(e.peek(),r=-1),-1==r&&e.charCode()===Zt?e.peek():t=r*Number(nn(e)),en(e),e.eat(Ft),en(e),e.charCode()===Zt?e.peek():(r=1,e.charCode()===Wt&&(e.peek(),r=-1),n=r*Number(nn(e))),e.eat(Gt),null===t&&null===n?null:{type:"Range",min:t,max:n}}(e)),e.eat(Yt),on(e,{type:"Type",name:t,opts:n})}function cn(e,t){function n(e,t){return{type:"Group",terms:e,combinator:t,disallowEmpty:!1,explicit:!1}}for(t=Object.keys(t).sort((function(e,t){return Jt[e]-Jt[t]}));t.length>0;){for(var r=t.shift(),i=0,a=0;i<e.length;i++){var o=e[i];"Combinator"===o.type&&(o.value===r?(-1===a&&(a=i-1),e.splice(i,1),i--):(-1!==a&&i-a>1&&(e.splice(a,i-a,n(e.slice(a,i),r)),i=a+1),a=-1))}-1!==a&&t.length&&e.splice(a,i-a,n(e.slice(a,i),r))}return r}function un(e){for(var t,n=[],r={},i=null,a=e.pos;t=hn(e);)"Spaces"!==t.type&&("Combinator"===t.type?(null!==i&&"Combinator"!==i.type||(e.pos=a,e.error("Unexpected combinator")),r[t.value]=!0):null!==i&&"Combinator"!==i.type&&(r[" "]=!0,n.push({type:"Combinator",value:" "})),n.push(t),i=t,a=e.pos);return null!==i&&"Combinator"===i.type&&(e.pos-=a,e.error("Unexpected combinator")),{type:"Group",terms:n,combinator:cn(n,r)||" ",disallowEmpty:!1,explicit:!1}}function hn(e){var t=e.charCode();if(t<128&&1===$t[t])return function(e){var t;return t=tn(e),e.charCode()===Mt?(e.pos++,{type:"Function",name:t}):on(e,{type:"Keyword",name:t})}(e);switch(t){case Gt:break;case Vt:return on(e,function(e){var t;return e.eat(Vt),t=un(e),e.eat(Gt),t.explicit=!0,e.charCode()===Dt&&(e.pos++,t.disallowEmpty=!0),t}(e));case qt:return e.nextCharCode()===Nt?function(e){var t;return e.eat(qt),e.eat(Nt),t=tn(e),e.eat(Nt),e.eat(Yt),on(e,{type:"Property",name:t})}(e):ln(e);case Qt:return{type:"Combinator",value:e.substringToPos(e.nextCharCode()===Qt?e.pos+2:e.pos+1)};case It:return e.pos++,e.eat(It),{type:"Combinator",value:"&&"};case Ft:return e.pos++,{type:"Comma"};case Nt:return on(e,{type:"String",value:rn(e)});case Ot:case Pt:case Tt:case Et:case Lt:return{type:"Spaces",value:en(e)};case Ht:return(t=e.nextCharCode())<128&&1===$t[t]?(e.pos++,{type:"AtKeyword",name:tn(e)}):sn(e);case _t:case jt:case Ut:case Bt:case Dt:break;case Kt:if((t=e.nextCharCode())<48||t>57)return sn(e);break;default:return sn(e)}}function pn(e){var t=new At(e),n=un(t);return t.pos!==e.length&&t.error("Unexpected input"),1===n.terms.length&&"Group"===n.terms[0].type&&(n=n.terms[0]),n}pn("[a&&<b>#|<'c'>*||e() f{2} /,(% g#{1,2} h{2,})]!");var dn=pn,mn=function(){};function gn(e){return"function"==typeof e?e:mn}var fn=function(e,t,n){var r=mn,i=mn;if("function"==typeof t?r=t:t&&(r=gn(t.enter),i=gn(t.leave)),r===mn&&i===mn)throw new Error("Neither `enter` nor `leave` walker handler is set or both aren't a function");!function e(t){switch(r.call(n,t),t.type){case"Group":t.terms.forEach(e);break;case"Multiplier":e(t.term);break;case"Type":case"Property":case"Keyword":case"AtKeyword":case"Function":case"String":case"Token":case"Comma":break;default:throw new Error("Unknown type: "+t.type)}i.call(n,t)}(e)},bn=new Q,yn={decorator:function(e){var t=null,n={len:0,node:null},r=[n],i="";return{children:e.children,node:function(n){var r=t;t=n,e.node.call(this,n),t=r},chunk:function(e){i+=e,n.node!==t?r.push({len:e.length,node:t}):n.len+=e.length},result:function(){return kn(i,r)}}}};function kn(e,t){var n=[],r=0,i=0,a=t?t[i].node:null;for(Le(e,bn);!bn.eof;){if(t)for(;i<t.length&&r+t[i].len<=bn.tokenStart;)r+=t[i++].len,a=t[i].node;n.push({type:bn.tokenType,value:bn.getTokenValue(),index:bn.tokenIndex,balance:bn.balance[bn.tokenIndex],node:a}),bn.next()}return n}var vn=function(e,t){return"string"==typeof e?kn(e,null):t.generate(e,yn)},xn={type:"Match"},wn={type:"Mismatch"},Sn={type:"DisallowEmpty"},Cn=40,zn=41;function An(e,t,n){return t===xn&&n===wn?e:e===xn&&t===xn&&n===xn?e:("If"===e.type&&e.else===wn&&t===xn&&(t=e.then,e=e.match),{type:"If",match:e,then:t,else:n})}function Pn(e){return e.length>2&&e.charCodeAt(e.length-2)===Cn&&e.charCodeAt(e.length-1)===zn}function Tn(e){return"Keyword"===e.type||"AtKeyword"===e.type||"Function"===e.type||"Type"===e.type&&Pn(e.name)}function Ln(e){if("function"==typeof e)return{type:"Generic",fn:e};switch(e.type){case"Group":var t=function e(t,n,r){switch(t){case" ":for(var i=xn,a=n.length-1;a>=0;a--){i=An(l=n[a],i,wn)}return i;case"|":i=wn;var o=null;for(a=n.length-1;a>=0;a--){if(Tn(l=n[a])&&(null===o&&a>0&&Tn(n[a-1])&&(i=An({type:"Enum",map:o=Object.create(null)},xn,i)),null!==o)){var s=(Pn(l.name)?l.name.slice(0,-1):l.name).toLowerCase();if(s in o==!1){o[s]=l;continue}}o=null,i=An(l,xn,i)}return i;case"&&":if(n.length>5)return{type:"MatchOnce",terms:n,all:!0};for(i=wn,a=n.length-1;a>=0;a--){var l=n[a];c=n.length>1?e(t,n.filter((function(e){return e!==l})),!1):xn,i=An(l,c,i)}return i;case"||":if(n.length>5)return{type:"MatchOnce",terms:n,all:!1};for(i=r?xn:wn,a=n.length-1;a>=0;a--){var c;l=n[a];c=n.length>1?e(t,n.filter((function(e){return e!==l})),!0):xn,i=An(l,c,i)}return i}}(e.combinator,e.terms.map(Ln),!1);return e.disallowEmpty&&(t=An(t,Sn,wn)),t;case"Multiplier":return function(e){var t=xn,n=Ln(e.term);if(0===e.max)n=An(n,Sn,wn),(t=An(n,null,wn)).then=An(xn,xn,t),e.comma&&(t.then.else=An({type:"Comma",syntax:e},t,wn));else for(var r=e.min||1;r<=e.max;r++)e.comma&&t!==xn&&(t=An({type:"Comma",syntax:e},t,wn)),t=An(n,An(xn,xn,t),wn);if(0===e.min)t=An(xn,xn,t);else for(r=0;r<e.min-1;r++)e.comma&&t!==xn&&(t=An({type:"Comma",syntax:e},t,wn)),t=An(n,t,wn);return t}(e);case"Type":case"Property":return{type:e.type,name:e.name,syntax:e};case"Keyword":return{type:e.type,name:e.name.toLowerCase(),syntax:e};case"AtKeyword":return{type:e.type,name:"@"+e.name.toLowerCase(),syntax:e};case"Function":return{type:e.type,name:e.name.toLowerCase()+"(",syntax:e};case"String":return 3===e.value.length?{type:"Token",value:e.value.charAt(1),syntax:e}:{type:e.type,value:e.value.substr(1,e.value.length-2).replace(/\\'/g,"'"),syntax:e};case"Token":return{type:e.type,value:e.value,syntax:e};case"Comma":return{type:e.type,syntax:e};default:throw new Error("Unknown node type:",e.type)}}var En={MATCH:xn,MISMATCH:wn,DISALLOW_EMPTY:Sn,buildMatchGraph:function(e,t){return"string"==typeof e&&(e=dn(e)),{type:"MatchGraph",match:Ln(e),syntax:t||null,source:e}}},On=Object.prototype.hasOwnProperty,Dn=En.MATCH,Bn=En.MISMATCH,In=En.DISALLOW_EMPTY,Nn=m.TYPE,Mn=0,Rn=1,_n=2,jn=3,Fn="Match",Wn="Mismatch",qn="Maximum iteration number exceeded (please fill an issue on https://github.com/csstree/csstree/issues)",Yn=15e3;function Un(e){for(var t=null,n=null,r=e;null!==r;)n=r.prev,r.prev=t,t=r,r=n;return t}function Hn(e,t){if(e.length!==t.length)return!1;for(var n=0;n<e.length;n++){var r=e.charCodeAt(n);if(r>=65&&r<=90&&(r|=32),r!==t.charCodeAt(n))return!1}return!0}function Vn(e){return null===e||(e.type===Nn.Comma||e.type===Nn.Function||e.type===Nn.LeftParenthesis||e.type===Nn.LeftSquareBracket||e.type===Nn.LeftCurlyBracket||e.type===Nn.Delim)}function Gn(e){return null===e||(e.type===Nn.RightParenthesis||e.type===Nn.RightSquareBracket||e.type===Nn.RightCurlyBracket||e.type===Nn.Delim)}function Kn(e,t,n){function r(){do{f=++b<e.length?e[b]:null}while(null!==f&&(f.type===Nn.WhiteSpace||f.type===Nn.Comment))}function i(t){var n=b+t;return n<e.length?e[n]:null}function a(e,t){return{nextState:e,matchStack:k,syntaxStack:u,thenStack:h,tokenIndex:b,prev:t}}function o(e){h={nextState:e,matchStack:k,syntaxStack:u,prev:h}}function s(e){p=a(e,p)}function l(){k={type:Rn,syntax:t.syntax,token:f,prev:k},r(),d=null,b>y&&(y=b)}function c(){k=k.type===_n?k.prev:{type:jn,syntax:u.syntax,token:k.token,prev:k},u=u.prev}var u=null,h=null,p=null,d=null,m=0,g=null,f=null,b=-1,y=0,k={type:Mn,syntax:null,token:null,prev:null};for(r();null===g&&++m<Yn;)switch(t.type){case"Match":if(null===h){if(null!==f&&(b!==e.length-1||"\\0"!==f.value&&"\\9"!==f.value)){t=Bn;break}g=Fn;break}if((t=h.nextState)===In){if(h.matchStack===k){t=Bn;break}t=Dn}for(;h.syntaxStack!==u;)c();h=h.prev;break;case"Mismatch":if(null!==d&&!1!==d)(null===p||b>p.tokenIndex)&&(p=d,d=!1);else if(null===p){g=Wn;break}t=p.nextState,h=p.thenStack,u=p.syntaxStack,k=p.matchStack,b=p.tokenIndex,f=b<e.length?e[b]:null,p=p.prev;break;case"MatchGraph":t=t.match;break;case"If":t.else!==Bn&&s(t.else),t.then!==Dn&&o(t.then),t=t.match;break;case"MatchOnce":t={type:"MatchOnceBuffer",syntax:t,index:0,mask:0};break;case"MatchOnceBuffer":var v=t.syntax.terms;if(t.index===v.length){if(0===t.mask||t.syntax.all){t=Bn;break}t=Dn;break}if(t.mask===(1<<v.length)-1){t=Dn;break}for(;t.index<v.length;t.index++){var x=1<<t.index;if(0==(t.mask&x)){s(t),o({type:"AddMatchOnce",syntax:t.syntax,mask:t.mask|x}),t=v[t.index++];break}}break;case"AddMatchOnce":t={type:"MatchOnceBuffer",syntax:t.syntax,index:0,mask:t.mask};break;case"Enum":if(null!==f)if(-1!==(A=f.value.toLowerCase()).indexOf("\\")&&(A=A.replace(/\\[09].*$/,"")),On.call(t.map,A)){t=t.map[A];break}t=Bn;break;case"Generic":var w=null!==u?u.opts:null,S=b+Math.floor(t.fn(f,i,w));if(!isNaN(S)&&S>b){for(;b<S;)l();t=Dn}else t=Bn;break;case"Type":case"Property":var C="Type"===t.type?"types":"properties",z=On.call(n,C)?n[C][t.name]:null;if(!z||!z.match)throw new Error("Bad syntax reference: "+("Type"===t.type?"<"+t.name+">":"<'"+t.name+"'>"));if(!1!==d&&null!==f&&"Type"===t.type)if("custom-ident"===t.name&&f.type===Nn.Ident||"length"===t.name&&"0"===f.value){null===d&&(d=a(t,p)),t=Bn;break}u={syntax:t.syntax,opts:t.syntax.opts||null!==u&&u.opts||null,prev:u},k={type:_n,syntax:t.syntax,token:k.token,prev:k},t=z.match;break;case"Keyword":var A=t.name;if(null!==f){var P=f.value;if(-1!==P.indexOf("\\")&&(P=P.replace(/\\[09].*$/,"")),Hn(P,A)){l(),t=Dn;break}}t=Bn;break;case"AtKeyword":case"Function":if(null!==f&&Hn(f.value,t.name)){l(),t=Dn;break}t=Bn;break;case"Token":if(null!==f&&f.value===t.value){l(),t=Dn;break}t=Bn;break;case"Comma":null!==f&&f.type===Nn.Comma?Vn(k.token)?t=Bn:(l(),t=Gn(f)?Bn:Dn):t=Vn(k.token)||Gn(f)?Dn:Bn;break;case"String":var T="";for(S=b;S<e.length&&T.length<t.value.length;S++)T+=e[S].value;if(Hn(T,t.value)){for(;b<S;)l();t=Dn}else t=Bn;break;default:throw new Error("Unknown node type: "+t.type)}switch(m,g){case null:console.warn("[csstree-match] BREAK after "+Yn+" iterations"),g=qn,k=null;break;case Fn:for(;null!==u;)c();break;default:k=null}return{tokens:e,reason:g,iterations:m,match:k,longestMatch:y}}var Qn=function(e,t,n){var r=Kn(e,t,n||{});if(null===r.match)return r;var i=r.match,a=r.match={syntax:t.syntax||null,match:[]},o=[a];for(i=Un(i).prev;null!==i;){switch(i.type){case _n:a.match.push(a={syntax:i.syntax,match:[]}),o.push(a);break;case jn:o.pop(),a=o[o.length-1];break;default:a.match.push({syntax:i.syntax||null,token:i.token.value,node:i.token.node})}i=i.prev}return r};function Xn(e){function t(e){return null!==e&&("Type"===e.type||"Property"===e.type||"Keyword"===e.type)}var n=null;return null!==this.matched&&function r(i){if(Array.isArray(i.match)){for(var a=0;a<i.match.length;a++)if(r(i.match[a]))return t(i.syntax)&&n.unshift(i.syntax),!0}else if(i.node===e)return n=t(i.syntax)?[i.syntax]:[],!0;return!1}(this.matched),n}function Zn(e,t,n){var r=Xn.call(e,t);return null!==r&&r.some(n)}var $n={getTrace:Xn,isType:function(e,t){return Zn(this,e,(function(e){return"Type"===e.type&&e.name===t}))},isProperty:function(e,t){return Zn(this,e,(function(e){return"Property"===e.type&&e.name===t}))},isKeyword:function(e){return Zn(this,e,(function(e){return"Keyword"===e.type}))}};var Jn={matchFragments:function(e,t,n,r,i){var o=[];return null!==n.matched&&function n(s){if(null!==s.syntax&&s.syntax.type===r&&s.syntax.name===i){var l=function e(t){return"node"in t?t.node:e(t.match[0])}(s),c=function e(t){return"node"in t?t.node:e(t.match[t.match.length-1])}(s);e.syntax.walk(t,(function(e,t,n){if(e===l){var r=new a;do{if(r.appendData(t.data),t.data===c)break;t=t.next}while(null!==t);o.push({parent:n,nodes:r})}}))}Array.isArray(s.match)&&s.match.forEach(n)}(n.matched),o}},er=Object.prototype.hasOwnProperty;function tr(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e&&e>=0}function nr(e){return Boolean(e)&&tr(e.offset)&&tr(e.line)&&tr(e.column)}function rr(e,t){return function(n,r){if(!n||n.constructor!==Object)return r(n,"Type of node should be an Object");for(var i in n){var o=!0;if(!1!==er.call(n,i)){if("type"===i)n.type!==e&&r(n,"Wrong node type `"+n.type+"`, expected `"+e+"`");else if("loc"===i){if(null===n.loc)continue;if(n.loc&&n.loc.constructor===Object)if("string"!=typeof n.loc.source)i+=".source";else if(nr(n.loc.start)){if(nr(n.loc.end))continue;i+=".end"}else i+=".start";o=!1}else if(t.hasOwnProperty(i)){var s=0;for(o=!1;!o&&s<t[i].length;s++){var l=t[i][s];switch(l){case String:o="string"==typeof n[i];break;case Boolean:o="boolean"==typeof n[i];break;case null:o=null===n[i];break;default:"string"==typeof l?o=n[i]&&n[i].type===l:Array.isArray(l)&&(o=n[i]instanceof a)}}}else r(n,"Unknown field `"+i+"` for "+e+" node type");o||r(n,"Bad value for `"+e+"."+i+"`")}}for(var i in t)er.call(t,i)&&!1===er.call(n,i)&&r(n,"Field `"+e+"."+i+"` is missed")}}function ir(e,t){var n=t.structure,r={type:String,loc:!0},i={type:'"'+e+'"'};for(var a in n)if(!1!==er.call(n,a)){for(var o=[],s=r[a]=Array.isArray(n[a])?n[a].slice():[n[a]],l=0;l<s.length;l++){var c=s[l];if(c===String||c===Boolean)o.push(c.name);else if(null===c)o.push("null");else if("string"==typeof c)o.push("<"+c+">");else{if(!Array.isArray(c))throw new Error("Wrong value `"+c+"` in `"+e+"."+a+"` structure definition");o.push("List")}}i[a]=o.join(" | ")}return{docs:i,check:rr(e,r)}}var ar=ee,or=te,sr=En.buildMatchGraph,lr=Qn,cr=function(e){var t={};if(e.node)for(var n in e.node)if(er.call(e.node,n)){var r=e.node[n];if(!r.structure)throw new Error("Missed `structure` field in `"+n+"` node type definition");t[n]=ir(n,r)}return t},ur=sr("inherit | initial | unset"),hr=sr("inherit | initial | unset | <-ms-legacy-expression>");function pr(e,t,n){var r={};for(var i in e)e[i].syntax&&(r[i]=n?e[i].syntax:$(e[i].syntax,{compact:t}));return r}function dr(e,t,n){return{matched:e,iterations:n,error:t,getTrace:$n.getTrace,isType:$n.isType,isProperty:$n.isProperty,isKeyword:$n.isKeyword}}function mr(e,t,n,r){var i,a=vn(n,e.syntax);return function(e){for(var t=0;t<e.length;t++)if("var("===e[t].value.toLowerCase())return!0;return!1}(a)?dr(null,new Error("Matching for a tree with var() is not supported")):(r&&(i=lr(a,e.valueCommonSyntax,e)),r&&i.match||(i=lr(a,t.match,e)).match?dr(i.match,null,i.iterations):dr(null,new or(i.reason,t.syntax,n,i),i.iterations))}var gr=function(e,t,n){if(this.valueCommonSyntax=ur,this.syntax=t,this.generic=!1,this.properties={},this.types={},this.structure=n||cr(e),e){if(e.types)for(var r in e.types)this.addType_(r,e.types[r]);if(e.generic)for(var r in this.generic=!0,St)this.addType_(r,St[r]);if(e.properties)for(var r in e.properties)this.addProperty_(r,e.properties[r])}};gr.prototype={structure:{},checkStructure:function(e){function t(e,t){r.push({node:e,message:t})}var n=this.structure,r=[];return this.syntax.walk(e,(function(e){n.hasOwnProperty(e.type)?n[e.type].check(e,t):t(e,"Unknown node type `"+e.type+"`")})),!!r.length&&r},createDescriptor:function(e,t,n){var r={type:t,name:n},i={type:t,name:n,syntax:null,match:null};return"function"==typeof e?i.match=sr(e,r):("string"==typeof e?Object.defineProperty(i,"syntax",{get:function(){return Object.defineProperty(i,"syntax",{value:dn(e)}),i.syntax}}):i.syntax=e,Object.defineProperty(i,"match",{get:function(){return Object.defineProperty(i,"match",{value:sr(i.syntax,r)}),i.match}})),i},addProperty_:function(e,t){this.properties[e]=this.createDescriptor(t,"Property",e)},addType_:function(e,t){this.types[e]=this.createDescriptor(t,"Type",e),t===St["-ms-legacy-expression"]&&(this.valueCommonSyntax=hr)},matchDeclaration:function(e){return"Declaration"!==e.type?dr(null,new Error("Not a Declaration node")):this.matchProperty(e.property,e.value)},matchProperty:function(e,t){var n=le.property(e);if(n.custom)return dr(null,new Error("Lexer matching doesn't applicable for custom properties"));var r=n.vendor?this.getProperty(n.name)||this.getProperty(n.basename):this.getProperty(n.name);return r?mr(this,r,t,!0):dr(null,new ar("Unknown property",e))},matchType:function(e,t){var n=this.getType(e);return n?mr(this,n,t,!1):dr(null,new ar("Unknown type",e))},match:function(e,t){return"string"==typeof e||e&&e.type?("string"!=typeof e&&e.match||(e=this.createDescriptor(e,"Type","anonymous")),mr(this,e,t,!1)):dr(null,new ar("Bad syntax"))},findValueFragments:function(e,t,n,r){return Jn.matchFragments(this,t,this.matchProperty(e,t),n,r)},findDeclarationValueFragments:function(e,t,n){return Jn.matchFragments(this,e.value,this.matchDeclaration(e),t,n)},findAllFragments:function(e,t,n){var r=[];return this.syntax.walk(e,{visit:"Declaration",enter:function(e){r.push.apply(r,this.findDeclarationValueFragments(e,t,n))}.bind(this)}),r},getProperty:function(e){return this.properties.hasOwnProperty(e)?this.properties[e]:null},getType:function(e){return this.types.hasOwnProperty(e)?this.types[e]:null},validate:function(){function e(r,i,a,o){if(a.hasOwnProperty(i))return a[i];a[i]=!1,null!==o.syntax&&fn(o.syntax,(function(o){if("Type"===o.type||"Property"===o.type){var s="Type"===o.type?r.types:r.properties,l="Type"===o.type?t:n;s.hasOwnProperty(o.name)&&!e(r,o.name,l,s[o.name])||(a[i]=!0)}}),this)}var t={},n={};for(var r in this.types)e(this,r,t,this.types[r]);for(var r in this.properties)e(this,r,n,this.properties[r]);return t=Object.keys(t).filter((function(e){return t[e]})),n=Object.keys(n).filter((function(e){return n[e]})),t.length||n.length?{types:t,properties:n}:null},dump:function(e,t){return{generic:this.generic,types:pr(this.types,!t,e),properties:pr(this.properties,!t,e)}},toString:function(){return JSON.stringify(this.dump())}};var fr=gr,br={SyntaxError:Ct,parse:dn,generate:$,walk:fn},yr=Le.isBOM,kr=10,vr=12,xr=13;var wr=function(){this.lines=null,this.columns=null,this.linesAndColumnsComputed=!1};wr.prototype={setSource:function(e,t,n,r){this.source=e,this.startOffset=void 0===t?0:t,this.startLine=void 0===n?1:n,this.startColumn=void 0===r?1:r,this.linesAndColumnsComputed=!1},ensureLinesAndColumnsComputed:function(){this.linesAndColumnsComputed||(!function(e,t){for(var n=t.length,r=ue(e.lines,n),i=e.startLine,a=ue(e.columns,n),o=e.startColumn,s=t.length>0?yr(t.charCodeAt(0)):0;s<n;s++){var l=t.charCodeAt(s);r[s]=i,a[s]=o++,l!==kr&&l!==xr&&l!==vr||(l===xr&&s+1<n&&t.charCodeAt(s+1)===kr&&(r[++s]=i,a[s]=o),i++,o=1)}r[s]=i,a[s]=o,e.lines=r,e.columns=a}(this,this.source),this.linesAndColumnsComputed=!0)},getLocation:function(e,t){return this.ensureLinesAndColumnsComputed(),{source:t,offset:this.startOffset+e,line:this.lines[e],column:this.columns[e]}},getLocationRange:function(e,t,n){return this.ensureLinesAndColumnsComputed(),{source:n,start:{offset:this.startOffset+e,line:this.lines[e],column:this.columns[e]},end:{offset:this.startOffset+t,line:this.lines[t],column:this.columns[t]}}}};var Sr=wr,Cr=Le.TYPE,zr=Cr.WhiteSpace,Ar=Cr.Comment,Pr=function(e){var t=this.createList(),n=null,r={recognizer:e,space:null,ignoreWS:!1,ignoreWSAfter:!1};for(this.scanner.skipSC();!this.scanner.eof;){switch(this.scanner.tokenType){case Ar:this.scanner.next();continue;case zr:r.ignoreWS?this.scanner.next():r.space=this.WhiteSpace();continue}if(void 0===(n=e.getNode.call(this,r)))break;null!==r.space&&(t.push(r.space),r.space=null),t.push(n),r.ignoreWSAfter?(r.ignoreWSAfter=!1,r.ignoreWS=!0):r.ignoreWS=!1}return t},Tr=W.findWhiteSpaceStart,Lr=function(){},Er=m.TYPE,Or=m.NAME,Dr=Er.WhiteSpace,Br=Er.Ident,Ir=Er.Function,Nr=Er.Url,Mr=Er.Hash,Rr=Er.Percentage,_r=Er.Number;function jr(e){return function(){return this[e]()}}var Fr=function(e){var t={scanner:new Q,locationMap:new Sr,filename:"<unknown>",needPositions:!1,onParseError:Lr,onParseErrorThrow:!1,parseAtrulePrelude:!0,parseRulePrelude:!0,parseValue:!0,parseCustomProperty:!1,readSequence:Pr,createList:function(){return new a},createSingleNodeList:function(e){return(new a).appendData(e)},getFirstListNode:function(e){return e&&e.first()},getLastListNode:function(e){return e.last()},parseWithFallback:function(e,t){var n=this.scanner.tokenIndex;try{return e.call(this)}catch(e){if(this.onParseErrorThrow)throw e;var r=t.call(this,n);return this.onParseErrorThrow=!0,this.onParseError(e,r),this.onParseErrorThrow=!1,r}},lookupNonWSType:function(e){do{var t=this.scanner.lookupType(e++);if(t!==Dr)return t}while(0!==t);return 0},eat:function(e){if(this.scanner.tokenType!==e){var t=this.scanner.tokenStart,n=Or[e]+" is expected";switch(e){case Br:this.scanner.tokenType===Ir||this.scanner.tokenType===Nr?(t=this.scanner.tokenEnd-1,n="Identifier is expected but function found"):n="Identifier is expected";break;case Mr:this.scanner.isDelim(35)&&(this.scanner.next(),t++,n="Name is expected");break;case Rr:this.scanner.tokenType===_r&&(t=this.scanner.tokenEnd,n="Percent sign is expected");break;default:this.scanner.source.charCodeAt(this.scanner.tokenStart)===e&&(t+=1)}this.error(n,t)}this.scanner.next()},consume:function(e){var t=this.scanner.getTokenValue();return this.eat(e),t},consumeFunctionName:function(){var e=this.scanner.source.substring(this.scanner.tokenStart,this.scanner.tokenEnd-1);return this.eat(Ir),e},getLocation:function(e,t){return this.needPositions?this.locationMap.getLocationRange(e,t,this.filename):null},getLocationFromList:function(e){if(this.needPositions){var t=this.getFirstListNode(e),n=this.getLastListNode(e);return this.locationMap.getLocationRange(null!==t?t.loc.start.offset-this.locationMap.startOffset:this.scanner.tokenStart,null!==n?n.loc.end.offset-this.locationMap.startOffset:this.scanner.tokenStart,this.filename)}return null},error:function(e,t){var n=void 0!==t&&t<this.scanner.source.length?this.locationMap.getLocation(t):this.scanner.eof?this.locationMap.getLocation(Tr(this.scanner.source,this.scanner.source.length-1)):this.locationMap.getLocati