SiteOrigin CSS - Version 1.1.2

Version Description

  • 11 November 2016 =
  • Ignore anything other than actual rules in media query subrules.
  • Removed depreciated jQuery function.
  • Updated CSSLint library.
  • Updated minicolors.
Download this release

Release Info

Developer gpriday
Plugin Icon 128x128 SiteOrigin CSS
Version 1.1.2
Comparing to
See all releases

Code changes from version 1.1.1 to 1.1.2

css/admin.css CHANGED
@@ -335,7 +335,7 @@
335
  padding: 5px 8px;
336
  }
337
  #so-custom-css-properties .sections .fields-table .minicolors input {
338
- padding-left: 30px;
339
  }
340
  #so-custom-css-properties .sections .fields-table .select {
341
  display: block;
335
  padding: 5px 8px;
336
  }
337
  #so-custom-css-properties .sections .fields-table .minicolors input {
338
+ padding: 14px 0 14px 30px;
339
  }
340
  #so-custom-css-properties .sections .fields-table .select {
341
  display: block;
js/URI.min.js CHANGED
@@ -1 +1 @@
1
- !function(t,r){"use strict";t.URI=r(t.punycode,t.IPv6,t.SecondLevelDomains,t)}(this,function(t,r,e,s){"use strict";function n(t,r){var e=arguments.length>=1,s=arguments.length>=2;if(!(this instanceof n))return e?s?new n(t,r):new n(t):new n;if(void 0===t){if(e)throw new TypeError("undefined is not a valid argument for URI");t="undefined"!=typeof location?location.href+"":""}return this.href(t),void 0!==r?this.absoluteTo(r):this}function a(t){return t.replace(/([.*+?^=!:${}()|[\]\/\\])/g,"\\$1")}function i(t){return void 0===t?"Undefined":String(Object.prototype.toString.call(t)).slice(8,-1)}function o(t){return"Array"===i(t)}function h(t,r){var e,s,n={};if("RegExp"===i(r))n=null;else if(o(r))for(e=0,s=r.length;e<s;e++)n[r[e]]=!0;else n[r]=!0;for(e=0,s=t.length;e<s;e++){var a=n&&void 0!==n[t[e]]||!n&&r.test(t[e]);a&&(t.splice(e,1),s--,e--)}return t}function u(t,r){var e,s;if(o(r)){for(e=0,s=r.length;e<s;e++)if(!u(t,r[e]))return!1;return!0}var n=i(r);for(e=0,s=t.length;e<s;e++)if("RegExp"===n){if("string"==typeof t[e]&&t[e].match(r))return!0}else if(t[e]===r)return!0;return!1}function p(t,r){if(!o(t)||!o(r))return!1;if(t.length!==r.length)return!1;t.sort(),r.sort();for(var e=0,s=t.length;e<s;e++)if(t[e]!==r[e])return!1;return!0}function c(t){var r=/^\/+|\/+$/g;return t.replace(r,"")}function l(t){return escape(t)}function d(t){return encodeURIComponent(t).replace(/[!'()*]/g,l).replace(/\*/g,"%2A")}function f(t){return function(r,e){return void 0===r?this._parts[t]||"":(this._parts[t]=r||null,this.build(!e),this)}}function m(t,r){return function(e,s){return void 0===e?this._parts[t]||"":(null!==e&&(e+="",e.charAt(0)===r&&(e=e.substring(1))),this._parts[t]=e,this.build(!s),this)}}var g=s&&s.URI;n.version="1.18.1";var _=n.prototype,y=Object.prototype.hasOwnProperty;n._parts=function(){return{protocol:null,username:null,password:null,hostname:null,urn:null,port:null,path:null,query:null,fragment:null,duplicateQueryParameters:n.duplicateQueryParameters,escapeQuerySpace:n.escapeQuerySpace}},n.duplicateQueryParameters=!1,n.escapeQuerySpace=!0,n.protocol_expression=/^[a-z][a-z0-9.+-]*$/i,n.idn_expression=/[^a-z0-9\.-]/i,n.punycode_expression=/(xn--)/i,n.ip4_expression=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/,n.ip6_expression=/^\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$/,n.find_uri_expression=/\b((?:[a-z][\w-]+:(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))/gi,n.findUri={start:/\b(?:([a-z][a-z0-9.+-]*:\/\/)|www\.)/gi,end:/[\s\r\n]|$/,trim:/[`!()\[\]{};:'".,<>?«»“”„‘’]+$/},n.defaultPorts={http:"80",https:"443",ftp:"21",gopher:"70",ws:"80",wss:"443"},n.invalid_hostname_characters=/[^a-zA-Z0-9\.-]/,n.domAttributes={a:"href",blockquote:"cite",link:"href",base:"href",script:"src",form:"action",img:"src",area:"href",iframe:"src",embed:"src",source:"src",track:"src",input:"src",audio:"src",video:"src"},n.getDomAttribute=function(t){if(t&&t.nodeName){var r=t.nodeName.toLowerCase();if("input"!==r||"image"===t.type)return n.domAttributes[r]}},n.encode=d,n.decode=decodeURIComponent,n.iso8859=function(){n.encode=escape,n.decode=unescape},n.unicode=function(){n.encode=d,n.decode=decodeURIComponent},n.characters={pathname:{encode:{expression:/%(24|26|2B|2C|3B|3D|3A|40)/gi,map:{"%24":"$","%26":"&","%2B":"+","%2C":",","%3B":";","%3D":"=","%3A":":","%40":"@"}},decode:{expression:/[\/\?#]/g,map:{"/":"%2F","?":"%3F","#":"%23"}}},reserved:{encode:{expression:/%(21|23|24|26|27|28|29|2A|2B|2C|2F|3A|3B|3D|3F|40|5B|5D)/gi,map:{"%3A":":","%2F":"/","%3F":"?","%23":"#","%5B":"[","%5D":"]","%40":"@","%21":"!","%24":"$","%26":"&","%27":"'","%28":"(","%29":")","%2A":"*","%2B":"+","%2C":",","%3B":";","%3D":"="}}},urnpath:{encode:{expression:/%(21|24|27|28|29|2A|2B|2C|3B|3D|40)/gi,map:{"%21":"!","%24":"$","%27":"'","%28":"(","%29":")","%2A":"*","%2B":"+","%2C":",","%3B":";","%3D":"=","%40":"@"}},decode:{expression:/[\/\?#:]/g,map:{"/":"%2F","?":"%3F","#":"%23",":":"%3A"}}}},n.encodeQuery=function(t,r){var e=n.encode(t+"");return void 0===r&&(r=n.escapeQuerySpace),r?e.replace(/%20/g,"+"):e},n.decodeQuery=function(t,r){t+="",void 0===r&&(r=n.escapeQuerySpace);try{return n.decode(r?t.replace(/\+/g,"%20"):t)}catch(r){return t}};var v,b={encode:"encode",decode:"decode"},w=function(t,r){return function(e){try{return n[r](e+"").replace(n.characters[t][r].expression,function(e){return n.characters[t][r].map[e]})}catch(t){return e}}};for(v in b)n[v+"PathSegment"]=w("pathname",b[v]),n[v+"UrnPathSegment"]=w("urnpath",b[v]);var Q=function(t,r,e){return function(s){var a;a=e?function(t){return n[r](n[e](t))}:n[r];for(var i=(s+"").split(t),o=0,h=i.length;o<h;o++)i[o]=a(i[o]);return i.join(t)}};n.decodePath=Q("/","decodePathSegment"),n.decodeUrnPath=Q(":","decodeUrnPathSegment"),n.recodePath=Q("/","encodePathSegment","decode"),n.recodeUrnPath=Q(":","encodeUrnPathSegment","decode"),n.encodeReserved=w("reserved","encode"),n.parse=function(t,r){var e;return r||(r={}),e=t.indexOf("#"),e>-1&&(r.fragment=t.substring(e+1)||null,t=t.substring(0,e)),e=t.indexOf("?"),e>-1&&(r.query=t.substring(e+1)||null,t=t.substring(0,e)),"//"===t.substring(0,2)?(r.protocol=null,t=t.substring(2),t=n.parseAuthority(t,r)):(e=t.indexOf(":"),e>-1&&(r.protocol=t.substring(0,e)||null,r.protocol&&!r.protocol.match(n.protocol_expression)?r.protocol=void 0:"//"===t.substring(e+1,e+3)?(t=t.substring(e+3),t=n.parseAuthority(t,r)):(t=t.substring(e+1),r.urn=!0))),r.path=t,r},n.parseHost=function(t,r){t=t.replace(/\\/g,"/");var e,s,n=t.indexOf("/");if(n===-1&&(n=t.length),"["===t.charAt(0))e=t.indexOf("]"),r.hostname=t.substring(1,e)||null,r.port=t.substring(e+2,n)||null,"/"===r.port&&(r.port=null);else{var a=t.indexOf(":"),i=t.indexOf("/"),o=t.indexOf(":",a+1);o!==-1&&(i===-1||o<i)?(r.hostname=t.substring(0,n)||null,r.port=null):(s=t.substring(0,n).split(":"),r.hostname=s[0]||null,r.port=s[1]||null)}return r.hostname&&"/"!==t.substring(n).charAt(0)&&(n++,t="/"+t),t.substring(n)||"/"},n.parseAuthority=function(t,r){return t=n.parseUserinfo(t,r),n.parseHost(t,r)},n.parseUserinfo=function(t,r){var e,s=t.indexOf("/"),a=t.lastIndexOf("@",s>-1?s:t.length-1);return a>-1&&(s===-1||a<s)?(e=t.substring(0,a).split(":"),r.username=e[0]?n.decode(e[0]):null,e.shift(),r.password=e[0]?n.decode(e.join(":")):null,t=t.substring(a+1)):(r.username=null,r.password=null),t},n.parseQuery=function(t,r){if(!t)return{};if(t=t.replace(/&+/g,"&").replace(/^\?*&*|&+$/g,""),!t)return{};for(var e,s,a,i={},o=t.split("&"),h=o.length,u=0;u<h;u++)e=o[u].split("="),s=n.decodeQuery(e.shift(),r),a=e.length?n.decodeQuery(e.join("="),r):null,y.call(i,s)?("string"!=typeof i[s]&&null!==i[s]||(i[s]=[i[s]]),i[s].push(a)):i[s]=a;return i},n.build=function(t){var r="";return t.protocol&&(r+=t.protocol+":"),t.urn||!r&&!t.hostname||(r+="//"),r+=n.buildAuthority(t)||"","string"==typeof t.path&&("/"!==t.path.charAt(0)&&"string"==typeof t.hostname&&(r+="/"),r+=t.path),"string"==typeof t.query&&t.query&&(r+="?"+t.query),"string"==typeof t.fragment&&t.fragment&&(r+="#"+t.fragment),r},n.buildHost=function(t){var r="";return t.hostname?(r+=n.ip6_expression.test(t.hostname)?"["+t.hostname+"]":t.hostname,t.port&&(r+=":"+t.port),r):""},n.buildAuthority=function(t){return n.buildUserinfo(t)+n.buildHost(t)},n.buildUserinfo=function(t){var r="";return t.username&&(r+=n.encode(t.username)),t.password&&(r+=":"+n.encode(t.password)),r&&(r+="@"),r},n.buildQuery=function(t,r,e){var s,a,i,h,u="";for(a in t)if(y.call(t,a)&&a)if(o(t[a]))for(s={},i=0,h=t[a].length;i<h;i++)void 0!==t[a][i]&&void 0===s[t[a][i]+""]&&(u+="&"+n.buildQueryParameter(a,t[a][i],e),r!==!0&&(s[t[a][i]+""]=!0));else void 0!==t[a]&&(u+="&"+n.buildQueryParameter(a,t[a],e));return u.substring(1)},n.buildQueryParameter=function(t,r,e){return n.encodeQuery(t,e)+(null!==r?"="+n.encodeQuery(r,e):"")},n.addQuery=function(t,r,e){if("object"==typeof r)for(var s in r)y.call(r,s)&&n.addQuery(t,s,r[s]);else{if("string"!=typeof r)throw new TypeError("URI.addQuery() accepts an object, string as the name parameter");if(void 0===t[r])return void(t[r]=e);"string"==typeof t[r]&&(t[r]=[t[r]]),o(e)||(e=[e]),t[r]=(t[r]||[]).concat(e)}},n.removeQuery=function(t,r,e){var s,a,u;if(o(r))for(s=0,a=r.length;s<a;s++)t[r[s]]=void 0;else if("RegExp"===i(r))for(u in t)r.test(u)&&(t[u]=void 0);else if("object"==typeof r)for(u in r)y.call(r,u)&&n.removeQuery(t,u,r[u]);else{if("string"!=typeof r)throw new TypeError("URI.removeQuery() accepts an object, string, RegExp as the first parameter");void 0!==e?"RegExp"===i(e)?!o(t[r])&&e.test(t[r])?t[r]=void 0:t[r]=h(t[r],e):t[r]!==String(e)||o(e)&&1!==e.length?o(t[r])&&(t[r]=h(t[r],e)):t[r]=void 0:t[r]=void 0}},n.hasQuery=function(t,r,e,s){switch(i(r)){case"String":break;case"RegExp":for(var a in t)if(y.call(t,a)&&r.test(a)&&(void 0===e||n.hasQuery(t,a,e)))return!0;return!1;case"Object":for(var h in r)if(y.call(r,h)&&!n.hasQuery(t,h,r[h]))return!1;return!0;default:throw new TypeError("URI.hasQuery() accepts a string, regular expression or object as the name parameter")}switch(i(e)){case"Undefined":return r in t;case"Boolean":var c=Boolean(o(t[r])?t[r].length:t[r]);return e===c;case"Function":return!!e(t[r],r,t);case"Array":if(!o(t[r]))return!1;var l=s?u:p;return l(t[r],e);case"RegExp":return o(t[r])?!!s&&u(t[r],e):Boolean(t[r]&&t[r].match(e));case"Number":e=String(e);case"String":return o(t[r])?!!s&&u(t[r],e):t[r]===e;default:throw new TypeError("URI.hasQuery() accepts undefined, boolean, string, number, RegExp, Function as the value parameter")}},n.joinPaths=function(){for(var t=[],r=[],e=0,s=0;s<arguments.length;s++){var a=new n(arguments[s]);t.push(a);for(var i=a.segment(),o=0;o<i.length;o++)"string"==typeof i[o]&&r.push(i[o]),i[o]&&e++}if(!r.length||!e)return new n("");var h=new n("").segment(r);return""!==t[0].path()&&"/"!==t[0].path().slice(0,1)||h.path("/"+h.path()),h.normalize()},n.commonPath=function(t,r){var e,s=Math.min(t.length,r.length);for(e=0;e<s;e++)if(t.charAt(e)!==r.charAt(e)){e--;break}return e<1?t.charAt(0)===r.charAt(0)&&"/"===t.charAt(0)?"/":"":("/"===t.charAt(e)&&"/"===r.charAt(e)||(e=t.substring(0,e).lastIndexOf("/")),t.substring(0,e+1))},n.withinString=function(t,r,e){e||(e={});var s=e.start||n.findUri.start,a=e.end||n.findUri.end,i=e.trim||n.findUri.trim,o=/[a-z0-9-]=["']?$/i;for(s.lastIndex=0;;){var h=s.exec(t);if(!h)break;var u=h.index;if(e.ignoreHtml){var p=t.slice(Math.max(u-3,0),u);if(p&&o.test(p))continue}var c=u+t.slice(u).search(a),l=t.slice(u,c).replace(i,"");if(!e.ignore||!e.ignore.test(l)){c=u+l.length;var d=r(l,u,c,t);t=t.slice(0,u)+d+t.slice(c),s.lastIndex=u+d.length}}return s.lastIndex=0,t},n.ensureValidHostname=function(r){if(r.match(n.invalid_hostname_characters)){if(!t)throw new TypeError('Hostname "'+r+'" contains characters other than [A-Z0-9.-] and Punycode.js is not available');if(t.toASCII(r).match(n.invalid_hostname_characters))throw new TypeError('Hostname "'+r+'" contains characters other than [A-Z0-9.-]')}},n.noConflict=function(t){if(t){var r={URI:this.noConflict()};return s.URITemplate&&"function"==typeof s.URITemplate.noConflict&&(r.URITemplate=s.URITemplate.noConflict()),s.IPv6&&"function"==typeof s.IPv6.noConflict&&(r.IPv6=s.IPv6.noConflict()),s.SecondLevelDomains&&"function"==typeof s.SecondLevelDomains.noConflict&&(r.SecondLevelDomains=s.SecondLevelDomains.noConflict()),r}return s.URI===this&&(s.URI=g),this},_.build=function(t){return t===!0?this._deferred_build=!0:(void 0===t||this._deferred_build)&&(this._string=n.build(this._parts),this._deferred_build=!1),this},_.clone=function(){return new n(this)},_.valueOf=_.toString=function(){return this.build(!1)._string},_.protocol=f("protocol"),_.username=f("username"),_.password=f("password"),_.hostname=f("hostname"),_.port=f("port"),_.query=m("query","?"),_.fragment=m("fragment","#"),_.search=function(t,r){var e=this.query(t,r);return"string"==typeof e&&e.length?"?"+e:e},_.hash=function(t,r){var e=this.fragment(t,r);return"string"==typeof e&&e.length?"#"+e:e},_.pathname=function(t,r){if(void 0===t||t===!0){var e=this._parts.path||(this._parts.hostname?"/":"");return t?(this._parts.urn?n.decodeUrnPath:n.decodePath)(e):e}return this._parts.urn?this._parts.path=t?n.recodeUrnPath(t):"":this._parts.path=t?n.recodePath(t):"/",this.build(!r),this},_.path=_.pathname,_.href=function(t,r){var e;if(void 0===t)return this.toString();this._string="",this._parts=n._parts();var s=t instanceof n,a="object"==typeof t&&(t.hostname||t.path||t.pathname);if(t.nodeName){var i=n.getDomAttribute(t);t=t[i]||"",a=!1}if(!s&&a&&void 0!==t.pathname&&(t=t.toString()),"string"==typeof t||t instanceof String)this._parts=n.parse(String(t),this._parts);else{if(!s&&!a)throw new TypeError("invalid input");var o=s?t._parts:t;for(e in o)y.call(this._parts,e)&&(this._parts[e]=o[e])}return this.build(!r),this},_.is=function(t){var r=!1,s=!1,a=!1,i=!1,o=!1,h=!1,u=!1,p=!this._parts.urn;switch(this._parts.hostname&&(p=!1,s=n.ip4_expression.test(this._parts.hostname),a=n.ip6_expression.test(this._parts.hostname),r=s||a,i=!r,o=i&&e&&e.has(this._parts.hostname),h=i&&n.idn_expression.test(this._parts.hostname),u=i&&n.punycode_expression.test(this._parts.hostname)),t.toLowerCase()){case"relative":return p;case"absolute":return!p;case"domain":case"name":return i;case"sld":return o;case"ip":return r;case"ip4":case"ipv4":case"inet4":return s;case"ip6":case"ipv6":case"inet6":return a;case"idn":return h;case"url":return!this._parts.urn;case"urn":return!!this._parts.urn;case"punycode":return u}return null};var A=_.protocol,P=_.port,x=_.hostname;_.protocol=function(t,r){if(void 0!==t&&t&&(t=t.replace(/:(\/\/)?$/,""),!t.match(n.protocol_expression)))throw new TypeError('Protocol "'+t+"\" contains characters other than [A-Z0-9.+-] or doesn't start with [A-Z]");return A.call(this,t,r)},_.scheme=_.protocol,_.port=function(t,r){if(this._parts.urn)return void 0===t?"":this;if(void 0!==t&&(0===t&&(t=null),t&&(t+="",":"===t.charAt(0)&&(t=t.substring(1)),t.match(/[^0-9]/))))throw new TypeError('Port "'+t+'" contains characters other than [0-9]');return P.call(this,t,r)},_.hostname=function(t,r){if(this._parts.urn)return void 0===t?"":this;if(void 0!==t){var e={},s=n.parseHost(t,e);if("/"!==s)throw new TypeError('Hostname "'+t+'" contains characters other than [A-Z0-9.-]');t=e.hostname}return x.call(this,t,r)},_.origin=function(t,r){if(this._parts.urn)return void 0===t?"":this;if(void 0===t){var e=this.protocol(),s=this.authority();return s?(e?e+"://":"")+this.authority():""}var a=n(t);return this.protocol(a.protocol()).authority(a.authority()).build(!r),this},_.host=function(t,r){if(this._parts.urn)return void 0===t?"":this;if(void 0===t)return this._parts.hostname?n.buildHost(this._parts):"";var e=n.parseHost(t,this._parts);if("/"!==e)throw new TypeError('Hostname "'+t+'" contains characters other than [A-Z0-9.-]');return this.build(!r),this},_.authority=function(t,r){if(this._parts.urn)return void 0===t?"":this;if(void 0===t)return this._parts.hostname?n.buildAuthority(this._parts):"";var e=n.parseAuthority(t,this._parts);if("/"!==e)throw new TypeError('Hostname "'+t+'" contains characters other than [A-Z0-9.-]');return this.build(!r),this},_.userinfo=function(t,r){if(this._parts.urn)return void 0===t?"":this;if(void 0===t){var e=n.buildUserinfo(this._parts);return e?e.substring(0,e.length-1):e}return"@"!==t[t.length-1]&&(t+="@"),n.parseUserinfo(t,this._parts),this.build(!r),this},_.resource=function(t,r){var e;return void 0===t?this.path()+this.search()+this.hash():(e=n.parse(t),this._parts.path=e.path,this._parts.query=e.query,this._parts.fragment=e.fragment,this.build(!r),this)},_.subdomain=function(t,r){if(this._parts.urn)return void 0===t?"":this;if(void 0===t){if(!this._parts.hostname||this.is("IP"))return"";var e=this._parts.hostname.length-this.domain().length-1;return this._parts.hostname.substring(0,e)||""}var s=this._parts.hostname.length-this.domain().length,i=this._parts.hostname.substring(0,s),o=new RegExp("^"+a(i));return t&&"."!==t.charAt(t.length-1)&&(t+="."),t&&n.ensureValidHostname(t),this._parts.hostname=this._parts.hostname.replace(o,t),this.build(!r),this},_.domain=function(t,r){if(this._parts.urn)return void 0===t?"":this;if("boolean"==typeof t&&(r=t,t=void 0),void 0===t){if(!this._parts.hostname||this.is("IP"))return"";var e=this._parts.hostname.match(/\./g);if(e&&e.length<2)return this._parts.hostname;var s=this._parts.hostname.length-this.tld(r).length-1;return s=this._parts.hostname.lastIndexOf(".",s-1)+1,this._parts.hostname.substring(s)||""}if(!t)throw new TypeError("cannot set domain empty");if(n.ensureValidHostname(t),!this._parts.hostname||this.is("IP"))this._parts.hostname=t;else{var i=new RegExp(a(this.domain())+"$");this._parts.hostname=this._parts.hostname.replace(i,t)}return this.build(!r),this},_.tld=function(t,r){if(this._parts.urn)return void 0===t?"":this;if("boolean"==typeof t&&(r=t,t=void 0),void 0===t){if(!this._parts.hostname||this.is("IP"))return"";var s=this._parts.hostname.lastIndexOf("."),n=this._parts.hostname.substring(s+1);return r!==!0&&e&&e.list[n.toLowerCase()]?e.get(this._parts.hostname)||n:n}var i;if(!t)throw new TypeError("cannot set TLD empty");if(t.match(/[^a-zA-Z0-9-]/)){if(!e||!e.is(t))throw new TypeError('TLD "'+t+'" contains characters other than [A-Z0-9]');i=new RegExp(a(this.tld())+"$"),this._parts.hostname=this._parts.hostname.replace(i,t)}else{if(!this._parts.hostname||this.is("IP"))throw new ReferenceError("cannot set TLD on non-domain host");i=new RegExp(a(this.tld())+"$"),this._parts.hostname=this._parts.hostname.replace(i,t)}return this.build(!r),this},_.directory=function(t,r){if(this._parts.urn)return void 0===t?"":this;if(void 0===t||t===!0){if(!this._parts.path&&!this._parts.hostname)return"";if("/"===this._parts.path)return"/";var e=this._parts.path.length-this.filename().length-1,s=this._parts.path.substring(0,e)||(this._parts.hostname?"/":"");return t?n.decodePath(s):s}var i=this._parts.path.length-this.filename().length,o=this._parts.path.substring(0,i),h=new RegExp("^"+a(o));return this.is("relative")||(t||(t="/"),"/"!==t.charAt(0)&&(t="/"+t)),t&&"/"!==t.charAt(t.length-1)&&(t+="/"),t=n.recodePath(t),this._parts.path=this._parts.path.replace(h,t),this.build(!r),this},_.filename=function(t,r){if(this._parts.urn)return void 0===t?"":this;if(void 0===t||t===!0){if(!this._parts.path||"/"===this._parts.path)return"";var e=this._parts.path.lastIndexOf("/"),s=this._parts.path.substring(e+1);return t?n.decodePathSegment(s):s}var i=!1;"/"===t.charAt(0)&&(t=t.substring(1)),t.match(/\.?\//)&&(i=!0);var o=new RegExp(a(this.filename())+"$");return t=n.recodePath(t),this._parts.path=this._parts.path.replace(o,t),i?this.normalizePath(r):this.build(!r),this},_.suffix=function(t,r){if(this._parts.urn)return void 0===t?"":this;if(void 0===t||t===!0){if(!this._parts.path||"/"===this._parts.path)return"";var e,s,i=this.filename(),o=i.lastIndexOf(".");return o===-1?"":(e=i.substring(o+1),s=/^[a-z0-9%]+$/i.test(e)?e:"",t?n.decodePathSegment(s):s)}"."===t.charAt(0)&&(t=t.substring(1));var h,u=this.suffix();if(u)h=t?new RegExp(a(u)+"$"):new RegExp(a("."+u)+"$");else{if(!t)return this;this._parts.path+="."+n.recodePath(t)}return h&&(t=n.recodePath(t),this._parts.path=this._parts.path.replace(h,t)),this.build(!r),this},_.segment=function(t,r,e){var s=this._parts.urn?":":"/",n=this.path(),a="/"===n.substring(0,1),i=n.split(s);if(void 0!==t&&"number"!=typeof t&&(e=r,r=t,t=void 0),void 0!==t&&"number"!=typeof t)throw new Error('Bad segment "'+t+'", must be 0-based integer');if(a&&i.shift(),t<0&&(t=Math.max(i.length+t,0)),void 0===r)return void 0===t?i:i[t];if(null===t||void 0===i[t])if(o(r)){i=[];for(var h=0,u=r.length;h<u;h++)(r[h].length||i.length&&i[i.length-1].length)&&(i.length&&!i[i.length-1].length&&i.pop(),i.push(c(r[h])))}else(r||"string"==typeof r)&&(r=c(r),""===i[i.length-1]?i[i.length-1]=r:i.push(r));else r?i[t]=c(r):i.splice(t,1);return a&&i.unshift(""),this.path(i.join(s),e)},_.segmentCoded=function(t,r,e){var s,a,i;if("number"!=typeof t&&(e=r,r=t,t=void 0),void 0===r){if(s=this.segment(t,r,e),o(s))for(a=0,i=s.length;a<i;a++)s[a]=n.decode(s[a]);else s=void 0!==s?n.decode(s):void 0;return s}if(o(r))for(a=0,i=r.length;a<i;a++)r[a]=n.encode(r[a]);else r="string"==typeof r||r instanceof String?n.encode(r):r;return this.segment(t,r,e)};var S=_.query;return _.query=function(t,r){if(t===!0)return n.parseQuery(this._parts.query,this._parts.escapeQuerySpace);if("function"==typeof t){var e=n.parseQuery(this._parts.query,this._parts.escapeQuerySpace),s=t.call(this,e);return this._parts.query=n.buildQuery(s||e,this._parts.duplicateQueryParameters,this._parts.escapeQuerySpace),this.build(!r),this}return void 0!==t&&"string"!=typeof t?(this._parts.query=n.buildQuery(t,this._parts.duplicateQueryParameters,this._parts.escapeQuerySpace),this.build(!r),this):S.call(this,t,r)},_.setQuery=function(t,r,e){var s=n.parseQuery(this._parts.query,this._parts.escapeQuerySpace);if("string"==typeof t||t instanceof String)s[t]=void 0!==r?r:null;else{if("object"!=typeof t)throw new TypeError("URI.addQuery() accepts an object, string as the name parameter");for(var a in t)y.call(t,a)&&(s[a]=t[a])}return this._parts.query=n.buildQuery(s,this._parts.duplicateQueryParameters,this._parts.escapeQuerySpace),"string"!=typeof t&&(e=r),this.build(!e),this},_.addQuery=function(t,r,e){var s=n.parseQuery(this._parts.query,this._parts.escapeQuerySpace);return n.addQuery(s,t,void 0===r?null:r),this._parts.query=n.buildQuery(s,this._parts.duplicateQueryParameters,this._parts.escapeQuerySpace),"string"!=typeof t&&(e=r),this.build(!e),this},_.removeQuery=function(t,r,e){var s=n.parseQuery(this._parts.query,this._parts.escapeQuerySpace);return n.removeQuery(s,t,r),this._parts.query=n.buildQuery(s,this._parts.duplicateQueryParameters,this._parts.escapeQuerySpace),"string"!=typeof t&&(e=r),this.build(!e),this},_.hasQuery=function(t,r,e){var s=n.parseQuery(this._parts.query,this._parts.escapeQuerySpace);return n.hasQuery(s,t,r,e)},_.setSearch=_.setQuery,_.addSearch=_.addQuery,_.removeSearch=_.removeQuery,_.hasSearch=_.hasQuery,_.normalize=function(){return this._parts.urn?this.normalizeProtocol(!1).normalizePath(!1).normalizeQuery(!1).normalizeFragment(!1).build():this.normalizeProtocol(!1).normalizeHostname(!1).normalizePort(!1).normalizePath(!1).normalizeQuery(!1).normalizeFragment(!1).build()},_.normalizeProtocol=function(t){return"string"==typeof this._parts.protocol&&(this._parts.protocol=this._parts.protocol.toLowerCase(),this.build(!t)),this},_.normalizeHostname=function(e){return this._parts.hostname&&(this.is("IDN")&&t?this._parts.hostname=t.toASCII(this._parts.hostname):this.is("IPv6")&&r&&(this._parts.hostname=r.best(this._parts.hostname)),this._parts.hostname=this._parts.hostname.toLowerCase(),this.build(!e)),this},_.normalizePort=function(t){return"string"==typeof this._parts.protocol&&this._parts.port===n.defaultPorts[this._parts.protocol]&&(this._parts.port=null,this.build(!t)),this},_.normalizePath=function(t){var r=this._parts.path;if(!r)return this;if(this._parts.urn)return this._parts.path=n.recodeUrnPath(this._parts.path),this.build(!t),this;if("/"===this._parts.path)return this;r=n.recodePath(r);var e,s,a,i="";for("/"!==r.charAt(0)&&(e=!0,r="/"+r),"/.."!==r.slice(-3)&&"/."!==r.slice(-2)||(r+="/"),r=r.replace(/(\/(\.\/)+)|(\/\.$)/g,"/").replace(/\/{2,}/g,"/"),e&&(i=r.substring(1).match(/^(\.\.\/)+/)||"",i&&(i=i[0]));;){if(s=r.search(/\/\.\.(\/|$)/),s===-1)break;0!==s?(a=r.substring(0,s).lastIndexOf("/"),a===-1&&(a=s),r=r.substring(0,a)+r.substring(s+3)):r=r.substring(3)}return e&&this.is("relative")&&(r=i+r.substring(1)),this._parts.path=r,this.build(!t),this},_.normalizePathname=_.normalizePath,_.normalizeQuery=function(t){return"string"==typeof this._parts.query&&(this._parts.query.length?this.query(n.parseQuery(this._parts.query,this._parts.escapeQuerySpace)):this._parts.query=null,this.build(!t)),this},_.normalizeFragment=function(t){return this._parts.fragment||(this._parts.fragment=null,this.build(!t)),this},_.normalizeSearch=_.normalizeQuery,_.normalizeHash=_.normalizeFragment,_.iso8859=function(){var t=n.encode,r=n.decode;n.encode=escape,n.decode=decodeURIComponent;try{this.normalize()}finally{n.encode=t,n.decode=r}return this},_.unicode=function(){var t=n.encode,r=n.decode;n.encode=d,n.decode=unescape;try{this.normalize()}finally{n.encode=t,n.decode=r}return this},_.readable=function(){var r=this.clone();r.username("").password("").normalize();var e="";if(r._parts.protocol&&(e+=r._parts.protocol+"://"),r._parts.hostname&&(r.is("punycode")&&t?(e+=t.toUnicode(r._parts.hostname),r._parts.port&&(e+=":"+r._parts.port)):e+=r.host()),r._parts.hostname&&r._parts.path&&"/"!==r._parts.path.charAt(0)&&(e+="/"),e+=r.path(!0),r._parts.query){for(var s="",a=0,i=r._parts.query.split("&"),o=i.length;a<o;a++){var h=(i[a]||"").split("=");s+="&"+n.decodeQuery(h[0],this._parts.escapeQuerySpace).replace(/&/g,"%26"),void 0!==h[1]&&(s+="="+n.decodeQuery(h[1],this._parts.escapeQuerySpace).replace(/&/g,"%26"))}e+="?"+s.substring(1)}return e+=n.decodeQuery(r.hash(),!0)},_.absoluteTo=function(t){var r,e,s,a=this.clone(),i=["protocol","username","password","hostname","port"];if(this._parts.urn)throw new Error("URNs do not have any generally defined hierarchical components");if(t instanceof n||(t=new n(t)),a._parts.protocol||(a._parts.protocol=t._parts.protocol),this._parts.hostname)return a;for(e=0;s=i[e];e++)a._parts[s]=t._parts[s];return a._parts.path?".."===a._parts.path.substring(-2)&&(a._parts.path+="/"):(a._parts.path=t._parts.path,a._parts.query||(a._parts.query=t._parts.query)),"/"!==a.path().charAt(0)&&(r=t.directory(),r=r?r:0===t.path().indexOf("/")?"/":"",a._parts.path=(r?r+"/":"")+a._parts.path,a.normalizePath()),a.build(),a},_.relativeTo=function(t){var r,e,s,a,i,o=this.clone().normalize();if(o._parts.urn)throw new Error("URNs do not have any generally defined hierarchical components");if(t=new n(t).normalize(),r=o._parts,e=t._parts,a=o.path(),i=t.path(),"/"!==a.charAt(0))throw new Error("URI is already relative");if("/"!==i.charAt(0))throw new Error("Cannot calculate a URI relative to another relative URI");if(r.protocol===e.protocol&&(r.protocol=null),r.username!==e.username||r.password!==e.password)return o.build();if(null!==r.protocol||null!==r.username||null!==r.password)return o.build();if(r.hostname!==e.hostname||r.port!==e.port)return o.build();if(r.hostname=null,r.port=null,a===i)return r.path="",o.build();if(s=n.commonPath(a,i),!s)return o.build();var h=e.path.substring(s.length).replace(/[^\/]*$/,"").replace(/.*?\//g,"../");return r.path=h+r.path.substring(s.length)||"./",o.build()},_.equals=function(t){var r,e,s,a=this.clone(),i=new n(t),h={},u={},c={};if(a.normalize(),i.normalize(),a.toString()===i.toString())return!0;if(r=a.query(),e=i.query(),a.query(""),i.query(""),a.toString()!==i.toString())return!1;if(r.length!==e.length)return!1;h=n.parseQuery(r,this._parts.escapeQuerySpace),u=n.parseQuery(e,this._parts.escapeQuerySpace);for(s in h)if(y.call(h,s)){if(o(h[s])){if(!p(h[s],u[s]))return!1}else if(h[s]!==u[s])return!1;c[s]=!0}for(s in u)if(y.call(u,s)&&!c[s])return!1;return!0},_.duplicateQueryParameters=function(t){return this._parts.duplicateQueryParameters=!!t,this},_.escapeQuerySpace=function(t){return this._parts.escapeQuerySpace=!!t,this},n});
1
+ !function(t,r){"use strict";t.URI=r(t.punycode,t.IPv6,t.SecondLevelDomains,t)}(this,function(t,r,e,s){"use strict";function n(t,r){var e=arguments.length>=1,s=arguments.length>=2;if(!(this instanceof n))return e?s?new n(t,r):new n(t):new n;if(void 0===t){if(e)throw new TypeError("undefined is not a valid argument for URI");t="undefined"!=typeof location?location.href+"":""}return this.href(t),void 0!==r?this.absoluteTo(r):this}function a(t){return t.replace(/([.*+?^=!:${}()|[\]\/\\])/g,"\\$1")}function i(t){return void 0===t?"Undefined":String(Object.prototype.toString.call(t)).slice(8,-1)}function o(t){return"Array"===i(t)}function h(t,r){var e,s,n={};if("RegExp"===i(r))n=null;else if(o(r))for(e=0,s=r.length;e<s;e++)n[r[e]]=!0;else n[r]=!0;for(e=0,s=t.length;e<s;e++){var a=n&&void 0!==n[t[e]]||!n&&r.test(t[e]);a&&(t.splice(e,1),s--,e--)}return t}function u(t,r){var e,s;if(o(r)){for(e=0,s=r.length;e<s;e++)if(!u(t,r[e]))return!1;return!0}var n=i(r);for(e=0,s=t.length;e<s;e++)if("RegExp"===n){if("string"==typeof t[e]&&t[e].match(r))return!0}else if(t[e]===r)return!0;return!1}function p(t,r){if(!o(t)||!o(r))return!1;if(t.length!==r.length)return!1;t.sort(),r.sort();for(var e=0,s=t.length;e<s;e++)if(t[e]!==r[e])return!1;return!0}function c(t){var r=/^\/+|\/+$/g;return t.replace(r,"")}function l(t){return escape(t)}function d(t){return encodeURIComponent(t).replace(/[!'()*]/g,l).replace(/\*/g,"%2A")}function f(t){return function(r,e){return void 0===r?this._parts[t]||"":(this._parts[t]=r||null,this.build(!e),this)}}function m(t,r){return function(e,s){return void 0===e?this._parts[t]||"":(null!==e&&(e+="",e.charAt(0)===r&&(e=e.substring(1))),this._parts[t]=e,this.build(!s),this)}}var g=s&&s.URI;n.version="1.18.1";var _=n.prototype,y=Object.prototype.hasOwnProperty;n._parts=function(){return{protocol:null,username:null,password:null,hostname:null,urn:null,port:null,path:null,query:null,fragment:null,duplicateQueryParameters:n.duplicateQueryParameters,escapeQuerySpace:n.escapeQuerySpace}},n.duplicateQueryParameters=!1,n.escapeQuerySpace=!0,n.protocol_expression=/^[a-z][a-z0-9.+-]*$/i,n.idn_expression=/[^a-z0-9\.-]/i,n.punycode_expression=/(xn--)/i,n.ip4_expression=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/,n.ip6_expression=/^\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$/,n.find_uri_expression=/\b((?:[a-z][\w-]+:(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))/gi,n.findUri={start:/\b(?:([a-z][a-z0-9.+-]*:\/\/)|www\.)/gi,end:/[\s\r\n]|$/,trim:/[`!()\[\]{};:'".,<>?«»“”„‘’]+$/},n.defaultPorts={http:"80",https:"443",ftp:"21",gopher:"70",ws:"80",wss:"443"},n.invalid_hostname_characters=/[^a-zA-Z0-9\.-]/,n.domAttributes={a:"href",blockquote:"cite",link:"href",base:"href",script:"src",form:"action",img:"src",area:"href",iframe:"src",embed:"src",source:"src",track:"src",input:"src",audio:"src",video:"src"},n.getDomAttribute=function(t){if(t&&t.nodeName){var r=t.nodeName.toLowerCase();if("input"!==r||"image"===t.type)return n.domAttributes[r]}},n.encode=d,n.decode=decodeURIComponent,n.iso8859=function(){n.encode=escape,n.decode=unescape},n.unicode=function(){n.encode=d,n.decode=decodeURIComponent},n.characters={pathname:{encode:{expression:/%(24|26|2B|2C|3B|3D|3A|40)/gi,map:{"%24":"$","%26":"&","%2B":"+","%2C":",","%3B":";","%3D":"=","%3A":":","%40":"@"}},decode:{expression:/[\/\?#]/g,map:{"/":"%2F","?":"%3F","#":"%23"}}},reserved:{encode:{expression:/%(21|23|24|26|27|28|29|2A|2B|2C|2F|3A|3B|3D|3F|40|5B|5D)/gi,map:{"%3A":":","%2F":"/","%3F":"?","%23":"#","%5B":"[","%5D":"]","%40":"@","%21":"!","%24":"$","%26":"&","%27":"'","%28":"(","%29":")","%2A":"*","%2B":"+","%2C":",","%3B":";","%3D":"="}}},urnpath:{encode:{expression:/%(21|24|27|28|29|2A|2B|2C|3B|3D|40)/gi,map:{"%21":"!","%24":"$","%27":"'","%28":"(","%29":")","%2A":"*","%2B":"+","%2C":",","%3B":";","%3D":"=","%40":"@"}},decode:{expression:/[\/\?#:]/g,map:{"/":"%2F","?":"%3F","#":"%23",":":"%3A"}}}},n.encodeQuery=function(t,r){var e=n.encode(t+"");return void 0===r&&(r=n.escapeQuerySpace),r?e.replace(/%20/g,"+"):e},n.decodeQuery=function(t,r){t+="",void 0===r&&(r=n.escapeQuerySpace);try{return n.decode(r?t.replace(/\+/g,"%20"):t)}catch(e){return t}};var v,b={encode:"encode",decode:"decode"},w=function(t,r){return function(e){try{return n[r](e+"").replace(n.characters[t][r].expression,function(e){return n.characters[t][r].map[e]})}catch(s){return e}}};for(v in b)n[v+"PathSegment"]=w("pathname",b[v]),n[v+"UrnPathSegment"]=w("urnpath",b[v]);var Q=function(t,r,e){return function(s){var a;a=e?function(t){return n[r](n[e](t))}:n[r];for(var i=(s+"").split(t),o=0,h=i.length;o<h;o++)i[o]=a(i[o]);return i.join(t)}};n.decodePath=Q("/","decodePathSegment"),n.decodeUrnPath=Q(":","decodeUrnPathSegment"),n.recodePath=Q("/","encodePathSegment","decode"),n.recodeUrnPath=Q(":","encodeUrnPathSegment","decode"),n.encodeReserved=w("reserved","encode"),n.parse=function(t,r){var e;return r||(r={}),e=t.indexOf("#"),e>-1&&(r.fragment=t.substring(e+1)||null,t=t.substring(0,e)),e=t.indexOf("?"),e>-1&&(r.query=t.substring(e+1)||null,t=t.substring(0,e)),"//"===t.substring(0,2)?(r.protocol=null,t=t.substring(2),t=n.parseAuthority(t,r)):(e=t.indexOf(":"),e>-1&&(r.protocol=t.substring(0,e)||null,r.protocol&&!r.protocol.match(n.protocol_expression)?r.protocol=void 0:"//"===t.substring(e+1,e+3)?(t=t.substring(e+3),t=n.parseAuthority(t,r)):(t=t.substring(e+1),r.urn=!0))),r.path=t,r},n.parseHost=function(t,r){t=t.replace(/\\/g,"/");var e,s,n=t.indexOf("/");if(n===-1&&(n=t.length),"["===t.charAt(0))e=t.indexOf("]"),r.hostname=t.substring(1,e)||null,r.port=t.substring(e+2,n)||null,"/"===r.port&&(r.port=null);else{var a=t.indexOf(":"),i=t.indexOf("/"),o=t.indexOf(":",a+1);o!==-1&&(i===-1||o<i)?(r.hostname=t.substring(0,n)||null,r.port=null):(s=t.substring(0,n).split(":"),r.hostname=s[0]||null,r.port=s[1]||null)}return r.hostname&&"/"!==t.substring(n).charAt(0)&&(n++,t="/"+t),t.substring(n)||"/"},n.parseAuthority=function(t,r){return t=n.parseUserinfo(t,r),n.parseHost(t,r)},n.parseUserinfo=function(t,r){var e,s=t.indexOf("/"),a=t.lastIndexOf("@",s>-1?s:t.length-1);return a>-1&&(s===-1||a<s)?(e=t.substring(0,a).split(":"),r.username=e[0]?n.decode(e[0]):null,e.shift(),r.password=e[0]?n.decode(e.join(":")):null,t=t.substring(a+1)):(r.username=null,r.password=null),t},n.parseQuery=function(t,r){if(!t)return{};if(t=t.replace(/&+/g,"&").replace(/^\?*&*|&+$/g,""),!t)return{};for(var e,s,a,i={},o=t.split("&"),h=o.length,u=0;u<h;u++)e=o[u].split("="),s=n.decodeQuery(e.shift(),r),a=e.length?n.decodeQuery(e.join("="),r):null,y.call(i,s)?("string"!=typeof i[s]&&null!==i[s]||(i[s]=[i[s]]),i[s].push(a)):i[s]=a;return i},n.build=function(t){var r="";return t.protocol&&(r+=t.protocol+":"),t.urn||!r&&!t.hostname||(r+="//"),r+=n.buildAuthority(t)||"","string"==typeof t.path&&("/"!==t.path.charAt(0)&&"string"==typeof t.hostname&&(r+="/"),r+=t.path),"string"==typeof t.query&&t.query&&(r+="?"+t.query),"string"==typeof t.fragment&&t.fragment&&(r+="#"+t.fragment),r},n.buildHost=function(t){var r="";return t.hostname?(r+=n.ip6_expression.test(t.hostname)?"["+t.hostname+"]":t.hostname,t.port&&(r+=":"+t.port),r):""},n.buildAuthority=function(t){return n.buildUserinfo(t)+n.buildHost(t)},n.buildUserinfo=function(t){var r="";return t.username&&(r+=n.encode(t.username)),t.password&&(r+=":"+n.encode(t.password)),r&&(r+="@"),r},n.buildQuery=function(t,r,e){var s,a,i,h,u="";for(a in t)if(y.call(t,a)&&a)if(o(t[a]))for(s={},i=0,h=t[a].length;i<h;i++)void 0!==t[a][i]&&void 0===s[t[a][i]+""]&&(u+="&"+n.buildQueryParameter(a,t[a][i],e),r!==!0&&(s[t[a][i]+""]=!0));else void 0!==t[a]&&(u+="&"+n.buildQueryParameter(a,t[a],e));return u.substring(1)},n.buildQueryParameter=function(t,r,e){return n.encodeQuery(t,e)+(null!==r?"="+n.encodeQuery(r,e):"")},n.addQuery=function(t,r,e){if("object"==typeof r)for(var s in r)y.call(r,s)&&n.addQuery(t,s,r[s]);else{if("string"!=typeof r)throw new TypeError("URI.addQuery() accepts an object, string as the name parameter");if(void 0===t[r])return void(t[r]=e);"string"==typeof t[r]&&(t[r]=[t[r]]),o(e)||(e=[e]),t[r]=(t[r]||[]).concat(e)}},n.removeQuery=function(t,r,e){var s,a,u;if(o(r))for(s=0,a=r.length;s<a;s++)t[r[s]]=void 0;else if("RegExp"===i(r))for(u in t)r.test(u)&&(t[u]=void 0);else if("object"==typeof r)for(u in r)y.call(r,u)&&n.removeQuery(t,u,r[u]);else{if("string"!=typeof r)throw new TypeError("URI.removeQuery() accepts an object, string, RegExp as the first parameter");void 0!==e?"RegExp"===i(e)?!o(t[r])&&e.test(t[r])?t[r]=void 0:t[r]=h(t[r],e):t[r]!==String(e)||o(e)&&1!==e.length?o(t[r])&&(t[r]=h(t[r],e)):t[r]=void 0:t[r]=void 0}},n.hasQuery=function(t,r,e,s){switch(i(r)){case"String":break;case"RegExp":for(var a in t)if(y.call(t,a)&&r.test(a)&&(void 0===e||n.hasQuery(t,a,e)))return!0;return!1;case"Object":for(var h in r)if(y.call(r,h)&&!n.hasQuery(t,h,r[h]))return!1;return!0;default:throw new TypeError("URI.hasQuery() accepts a string, regular expression or object as the name parameter")}switch(i(e)){case"Undefined":return r in t;case"Boolean":var c=Boolean(o(t[r])?t[r].length:t[r]);return e===c;case"Function":return!!e(t[r],r,t);case"Array":if(!o(t[r]))return!1;var l=s?u:p;return l(t[r],e);case"RegExp":return o(t[r])?!!s&&u(t[r],e):Boolean(t[r]&&t[r].match(e));case"Number":e=String(e);case"String":return o(t[r])?!!s&&u(t[r],e):t[r]===e;default:throw new TypeError("URI.hasQuery() accepts undefined, boolean, string, number, RegExp, Function as the value parameter")}},n.joinPaths=function(){for(var t=[],r=[],e=0,s=0;s<arguments.length;s++){var a=new n(arguments[s]);t.push(a);for(var i=a.segment(),o=0;o<i.length;o++)"string"==typeof i[o]&&r.push(i[o]),i[o]&&e++}if(!r.length||!e)return new n("");var h=new n("").segment(r);return""!==t[0].path()&&"/"!==t[0].path().slice(0,1)||h.path("/"+h.path()),h.normalize()},n.commonPath=function(t,r){var e,s=Math.min(t.length,r.length);for(e=0;e<s;e++)if(t.charAt(e)!==r.charAt(e)){e--;break}return e<1?t.charAt(0)===r.charAt(0)&&"/"===t.charAt(0)?"/":"":("/"===t.charAt(e)&&"/"===r.charAt(e)||(e=t.substring(0,e).lastIndexOf("/")),t.substring(0,e+1))},n.withinString=function(t,r,e){e||(e={});var s=e.start||n.findUri.start,a=e.end||n.findUri.end,i=e.trim||n.findUri.trim,o=/[a-z0-9-]=["']?$/i;for(s.lastIndex=0;;){var h=s.exec(t);if(!h)break;var u=h.index;if(e.ignoreHtml){var p=t.slice(Math.max(u-3,0),u);if(p&&o.test(p))continue}var c=u+t.slice(u).search(a),l=t.slice(u,c).replace(i,"");if(!e.ignore||!e.ignore.test(l)){c=u+l.length;var d=r(l,u,c,t);t=t.slice(0,u)+d+t.slice(c),s.lastIndex=u+d.length}}return s.lastIndex=0,t},n.ensureValidHostname=function(r){if(r.match(n.invalid_hostname_characters)){if(!t)throw new TypeError('Hostname "'+r+'" contains characters other than [A-Z0-9.-] and Punycode.js is not available');if(t.toASCII(r).match(n.invalid_hostname_characters))throw new TypeError('Hostname "'+r+'" contains characters other than [A-Z0-9.-]')}},n.noConflict=function(t){if(t){var r={URI:this.noConflict()};return s.URITemplate&&"function"==typeof s.URITemplate.noConflict&&(r.URITemplate=s.URITemplate.noConflict()),s.IPv6&&"function"==typeof s.IPv6.noConflict&&(r.IPv6=s.IPv6.noConflict()),s.SecondLevelDomains&&"function"==typeof s.SecondLevelDomains.noConflict&&(r.SecondLevelDomains=s.SecondLevelDomains.noConflict()),r}return s.URI===this&&(s.URI=g),this},_.build=function(t){return t===!0?this._deferred_build=!0:(void 0===t||this._deferred_build)&&(this._string=n.build(this._parts),this._deferred_build=!1),this},_.clone=function(){return new n(this)},_.valueOf=_.toString=function(){return this.build(!1)._string},_.protocol=f("protocol"),_.username=f("username"),_.password=f("password"),_.hostname=f("hostname"),_.port=f("port"),_.query=m("query","?"),_.fragment=m("fragment","#"),_.search=function(t,r){var e=this.query(t,r);return"string"==typeof e&&e.length?"?"+e:e},_.hash=function(t,r){var e=this.fragment(t,r);return"string"==typeof e&&e.length?"#"+e:e},_.pathname=function(t,r){if(void 0===t||t===!0){var e=this._parts.path||(this._parts.hostname?"/":"");return t?(this._parts.urn?n.decodeUrnPath:n.decodePath)(e):e}return this._parts.urn?this._parts.path=t?n.recodeUrnPath(t):"":this._parts.path=t?n.recodePath(t):"/",this.build(!r),this},_.path=_.pathname,_.href=function(t,r){var e;if(void 0===t)return this.toString();this._string="",this._parts=n._parts();var s=t instanceof n,a="object"==typeof t&&(t.hostname||t.path||t.pathname);if(t.nodeName){var i=n.getDomAttribute(t);t=t[i]||"",a=!1}if(!s&&a&&void 0!==t.pathname&&(t=t.toString()),"string"==typeof t||t instanceof String)this._parts=n.parse(String(t),this._parts);else{if(!s&&!a)throw new TypeError("invalid input");var o=s?t._parts:t;for(e in o)y.call(this._parts,e)&&(this._parts[e]=o[e])}return this.build(!r),this},_.is=function(t){var r=!1,s=!1,a=!1,i=!1,o=!1,h=!1,u=!1,p=!this._parts.urn;switch(this._parts.hostname&&(p=!1,s=n.ip4_expression.test(this._parts.hostname),a=n.ip6_expression.test(this._parts.hostname),r=s||a,i=!r,o=i&&e&&e.has(this._parts.hostname),h=i&&n.idn_expression.test(this._parts.hostname),u=i&&n.punycode_expression.test(this._parts.hostname)),t.toLowerCase()){case"relative":return p;case"absolute":return!p;case"domain":case"name":return i;case"sld":return o;case"ip":return r;case"ip4":case"ipv4":case"inet4":return s;case"ip6":case"ipv6":case"inet6":return a;case"idn":return h;case"url":return!this._parts.urn;case"urn":return!!this._parts.urn;case"punycode":return u}return null};var A=_.protocol,P=_.port,x=_.hostname;_.protocol=function(t,r){if(void 0!==t&&t&&(t=t.replace(/:(\/\/)?$/,""),!t.match(n.protocol_expression)))throw new TypeError('Protocol "'+t+"\" contains characters other than [A-Z0-9.+-] or doesn't start with [A-Z]");return A.call(this,t,r)},_.scheme=_.protocol,_.port=function(t,r){if(this._parts.urn)return void 0===t?"":this;if(void 0!==t&&(0===t&&(t=null),t&&(t+="",":"===t.charAt(0)&&(t=t.substring(1)),t.match(/[^0-9]/))))throw new TypeError('Port "'+t+'" contains characters other than [0-9]');return P.call(this,t,r)},_.hostname=function(t,r){if(this._parts.urn)return void 0===t?"":this;if(void 0!==t){var e={},s=n.parseHost(t,e);if("/"!==s)throw new TypeError('Hostname "'+t+'" contains characters other than [A-Z0-9.-]');t=e.hostname}return x.call(this,t,r)},_.origin=function(t,r){if(this._parts.urn)return void 0===t?"":this;if(void 0===t){var e=this.protocol(),s=this.authority();return s?(e?e+"://":"")+this.authority():""}var a=n(t);return this.protocol(a.protocol()).authority(a.authority()).build(!r),this},_.host=function(t,r){if(this._parts.urn)return void 0===t?"":this;if(void 0===t)return this._parts.hostname?n.buildHost(this._parts):"";var e=n.parseHost(t,this._parts);if("/"!==e)throw new TypeError('Hostname "'+t+'" contains characters other than [A-Z0-9.-]');return this.build(!r),this},_.authority=function(t,r){if(this._parts.urn)return void 0===t?"":this;if(void 0===t)return this._parts.hostname?n.buildAuthority(this._parts):"";var e=n.parseAuthority(t,this._parts);if("/"!==e)throw new TypeError('Hostname "'+t+'" contains characters other than [A-Z0-9.-]');return this.build(!r),this},_.userinfo=function(t,r){if(this._parts.urn)return void 0===t?"":this;if(void 0===t){var e=n.buildUserinfo(this._parts);return e?e.substring(0,e.length-1):e}return"@"!==t[t.length-1]&&(t+="@"),n.parseUserinfo(t,this._parts),this.build(!r),this},_.resource=function(t,r){var e;return void 0===t?this.path()+this.search()+this.hash():(e=n.parse(t),this._parts.path=e.path,this._parts.query=e.query,this._parts.fragment=e.fragment,this.build(!r),this)},_.subdomain=function(t,r){if(this._parts.urn)return void 0===t?"":this;if(void 0===t){if(!this._parts.hostname||this.is("IP"))return"";var e=this._parts.hostname.length-this.domain().length-1;return this._parts.hostname.substring(0,e)||""}var s=this._parts.hostname.length-this.domain().length,i=this._parts.hostname.substring(0,s),o=new RegExp("^"+a(i));return t&&"."!==t.charAt(t.length-1)&&(t+="."),t&&n.ensureValidHostname(t),this._parts.hostname=this._parts.hostname.replace(o,t),this.build(!r),this},_.domain=function(t,r){if(this._parts.urn)return void 0===t?"":this;if("boolean"==typeof t&&(r=t,t=void 0),void 0===t){if(!this._parts.hostname||this.is("IP"))return"";var e=this._parts.hostname.match(/\./g);if(e&&e.length<2)return this._parts.hostname;var s=this._parts.hostname.length-this.tld(r).length-1;return s=this._parts.hostname.lastIndexOf(".",s-1)+1,this._parts.hostname.substring(s)||""}if(!t)throw new TypeError("cannot set domain empty");if(n.ensureValidHostname(t),!this._parts.hostname||this.is("IP"))this._parts.hostname=t;else{var i=new RegExp(a(this.domain())+"$");this._parts.hostname=this._parts.hostname.replace(i,t)}return this.build(!r),this},_.tld=function(t,r){if(this._parts.urn)return void 0===t?"":this;if("boolean"==typeof t&&(r=t,t=void 0),void 0===t){if(!this._parts.hostname||this.is("IP"))return"";var s=this._parts.hostname.lastIndexOf("."),n=this._parts.hostname.substring(s+1);return r!==!0&&e&&e.list[n.toLowerCase()]?e.get(this._parts.hostname)||n:n}var i;if(!t)throw new TypeError("cannot set TLD empty");if(t.match(/[^a-zA-Z0-9-]/)){if(!e||!e.is(t))throw new TypeError('TLD "'+t+'" contains characters other than [A-Z0-9]');i=new RegExp(a(this.tld())+"$"),this._parts.hostname=this._parts.hostname.replace(i,t)}else{if(!this._parts.hostname||this.is("IP"))throw new ReferenceError("cannot set TLD on non-domain host");i=new RegExp(a(this.tld())+"$"),this._parts.hostname=this._parts.hostname.replace(i,t)}return this.build(!r),this},_.directory=function(t,r){if(this._parts.urn)return void 0===t?"":this;if(void 0===t||t===!0){if(!this._parts.path&&!this._parts.hostname)return"";if("/"===this._parts.path)return"/";var e=this._parts.path.length-this.filename().length-1,s=this._parts.path.substring(0,e)||(this._parts.hostname?"/":"");return t?n.decodePath(s):s}var i=this._parts.path.length-this.filename().length,o=this._parts.path.substring(0,i),h=new RegExp("^"+a(o));return this.is("relative")||(t||(t="/"),"/"!==t.charAt(0)&&(t="/"+t)),t&&"/"!==t.charAt(t.length-1)&&(t+="/"),t=n.recodePath(t),this._parts.path=this._parts.path.replace(h,t),this.build(!r),this},_.filename=function(t,r){if(this._parts.urn)return void 0===t?"":this;if(void 0===t||t===!0){if(!this._parts.path||"/"===this._parts.path)return"";var e=this._parts.path.lastIndexOf("/"),s=this._parts.path.substring(e+1);return t?n.decodePathSegment(s):s}var i=!1;"/"===t.charAt(0)&&(t=t.substring(1)),t.match(/\.?\//)&&(i=!0);var o=new RegExp(a(this.filename())+"$");return t=n.recodePath(t),this._parts.path=this._parts.path.replace(o,t),i?this.normalizePath(r):this.build(!r),this},_.suffix=function(t,r){if(this._parts.urn)return void 0===t?"":this;if(void 0===t||t===!0){if(!this._parts.path||"/"===this._parts.path)return"";var e,s,i=this.filename(),o=i.lastIndexOf(".");return o===-1?"":(e=i.substring(o+1),s=/^[a-z0-9%]+$/i.test(e)?e:"",t?n.decodePathSegment(s):s)}"."===t.charAt(0)&&(t=t.substring(1));var h,u=this.suffix();if(u)h=t?new RegExp(a(u)+"$"):new RegExp(a("."+u)+"$");else{if(!t)return this;this._parts.path+="."+n.recodePath(t)}return h&&(t=n.recodePath(t),this._parts.path=this._parts.path.replace(h,t)),this.build(!r),this},_.segment=function(t,r,e){var s=this._parts.urn?":":"/",n=this.path(),a="/"===n.substring(0,1),i=n.split(s);if(void 0!==t&&"number"!=typeof t&&(e=r,r=t,t=void 0),void 0!==t&&"number"!=typeof t)throw new Error('Bad segment "'+t+'", must be 0-based integer');if(a&&i.shift(),t<0&&(t=Math.max(i.length+t,0)),void 0===r)return void 0===t?i:i[t];if(null===t||void 0===i[t])if(o(r)){i=[];for(var h=0,u=r.length;h<u;h++)(r[h].length||i.length&&i[i.length-1].length)&&(i.length&&!i[i.length-1].length&&i.pop(),i.push(c(r[h])))}else(r||"string"==typeof r)&&(r=c(r),""===i[i.length-1]?i[i.length-1]=r:i.push(r));else r?i[t]=c(r):i.splice(t,1);return a&&i.unshift(""),this.path(i.join(s),e)},_.segmentCoded=function(t,r,e){var s,a,i;if("number"!=typeof t&&(e=r,r=t,t=void 0),void 0===r){if(s=this.segment(t,r,e),o(s))for(a=0,i=s.length;a<i;a++)s[a]=n.decode(s[a]);else s=void 0!==s?n.decode(s):void 0;return s}if(o(r))for(a=0,i=r.length;a<i;a++)r[a]=n.encode(r[a]);else r="string"==typeof r||r instanceof String?n.encode(r):r;return this.segment(t,r,e)};var S=_.query;return _.query=function(t,r){if(t===!0)return n.parseQuery(this._parts.query,this._parts.escapeQuerySpace);if("function"==typeof t){var e=n.parseQuery(this._parts.query,this._parts.escapeQuerySpace),s=t.call(this,e);return this._parts.query=n.buildQuery(s||e,this._parts.duplicateQueryParameters,this._parts.escapeQuerySpace),this.build(!r),this}return void 0!==t&&"string"!=typeof t?(this._parts.query=n.buildQuery(t,this._parts.duplicateQueryParameters,this._parts.escapeQuerySpace),this.build(!r),this):S.call(this,t,r)},_.setQuery=function(t,r,e){var s=n.parseQuery(this._parts.query,this._parts.escapeQuerySpace);if("string"==typeof t||t instanceof String)s[t]=void 0!==r?r:null;else{if("object"!=typeof t)throw new TypeError("URI.addQuery() accepts an object, string as the name parameter");for(var a in t)y.call(t,a)&&(s[a]=t[a])}return this._parts.query=n.buildQuery(s,this._parts.duplicateQueryParameters,this._parts.escapeQuerySpace),"string"!=typeof t&&(e=r),this.build(!e),this},_.addQuery=function(t,r,e){var s=n.parseQuery(this._parts.query,this._parts.escapeQuerySpace);return n.addQuery(s,t,void 0===r?null:r),this._parts.query=n.buildQuery(s,this._parts.duplicateQueryParameters,this._parts.escapeQuerySpace),"string"!=typeof t&&(e=r),this.build(!e),this},_.removeQuery=function(t,r,e){var s=n.parseQuery(this._parts.query,this._parts.escapeQuerySpace);return n.removeQuery(s,t,r),this._parts.query=n.buildQuery(s,this._parts.duplicateQueryParameters,this._parts.escapeQuerySpace),"string"!=typeof t&&(e=r),this.build(!e),this},_.hasQuery=function(t,r,e){var s=n.parseQuery(this._parts.query,this._parts.escapeQuerySpace);return n.hasQuery(s,t,r,e)},_.setSearch=_.setQuery,_.addSearch=_.addQuery,_.removeSearch=_.removeQuery,_.hasSearch=_.hasQuery,_.normalize=function(){return this._parts.urn?this.normalizeProtocol(!1).normalizePath(!1).normalizeQuery(!1).normalizeFragment(!1).build():this.normalizeProtocol(!1).normalizeHostname(!1).normalizePort(!1).normalizePath(!1).normalizeQuery(!1).normalizeFragment(!1).build()},_.normalizeProtocol=function(t){return"string"==typeof this._parts.protocol&&(this._parts.protocol=this._parts.protocol.toLowerCase(),this.build(!t)),this},_.normalizeHostname=function(e){return this._parts.hostname&&(this.is("IDN")&&t?this._parts.hostname=t.toASCII(this._parts.hostname):this.is("IPv6")&&r&&(this._parts.hostname=r.best(this._parts.hostname)),this._parts.hostname=this._parts.hostname.toLowerCase(),this.build(!e)),this},_.normalizePort=function(t){return"string"==typeof this._parts.protocol&&this._parts.port===n.defaultPorts[this._parts.protocol]&&(this._parts.port=null,this.build(!t)),this},_.normalizePath=function(t){var r=this._parts.path;if(!r)return this;if(this._parts.urn)return this._parts.path=n.recodeUrnPath(this._parts.path),this.build(!t),this;if("/"===this._parts.path)return this;r=n.recodePath(r);var e,s,a,i="";for("/"!==r.charAt(0)&&(e=!0,r="/"+r),"/.."!==r.slice(-3)&&"/."!==r.slice(-2)||(r+="/"),r=r.replace(/(\/(\.\/)+)|(\/\.$)/g,"/").replace(/\/{2,}/g,"/"),e&&(i=r.substring(1).match(/^(\.\.\/)+/)||"",i&&(i=i[0]));;){if(s=r.search(/\/\.\.(\/|$)/),s===-1)break;0!==s?(a=r.substring(0,s).lastIndexOf("/"),a===-1&&(a=s),r=r.substring(0,a)+r.substring(s+3)):r=r.substring(3)}return e&&this.is("relative")&&(r=i+r.substring(1)),this._parts.path=r,this.build(!t),this},_.normalizePathname=_.normalizePath,_.normalizeQuery=function(t){return"string"==typeof this._parts.query&&(this._parts.query.length?this.query(n.parseQuery(this._parts.query,this._parts.escapeQuerySpace)):this._parts.query=null,this.build(!t)),this},_.normalizeFragment=function(t){return this._parts.fragment||(this._parts.fragment=null,this.build(!t)),this},_.normalizeSearch=_.normalizeQuery,_.normalizeHash=_.normalizeFragment,_.iso8859=function(){var t=n.encode,r=n.decode;n.encode=escape,n.decode=decodeURIComponent;try{this.normalize()}finally{n.encode=t,n.decode=r}return this},_.unicode=function(){var t=n.encode,r=n.decode;n.encode=d,n.decode=unescape;try{this.normalize()}finally{n.encode=t,n.decode=r}return this},_.readable=function(){var r=this.clone();r.username("").password("").normalize();var e="";if(r._parts.protocol&&(e+=r._parts.protocol+"://"),r._parts.hostname&&(r.is("punycode")&&t?(e+=t.toUnicode(r._parts.hostname),r._parts.port&&(e+=":"+r._parts.port)):e+=r.host()),r._parts.hostname&&r._parts.path&&"/"!==r._parts.path.charAt(0)&&(e+="/"),e+=r.path(!0),r._parts.query){for(var s="",a=0,i=r._parts.query.split("&"),o=i.length;a<o;a++){var h=(i[a]||"").split("=");s+="&"+n.decodeQuery(h[0],this._parts.escapeQuerySpace).replace(/&/g,"%26"),void 0!==h[1]&&(s+="="+n.decodeQuery(h[1],this._parts.escapeQuerySpace).replace(/&/g,"%26"))}e+="?"+s.substring(1)}return e+=n.decodeQuery(r.hash(),!0)},_.absoluteTo=function(t){var r,e,s,a=this.clone(),i=["protocol","username","password","hostname","port"];if(this._parts.urn)throw new Error("URNs do not have any generally defined hierarchical components");if(t instanceof n||(t=new n(t)),a._parts.protocol||(a._parts.protocol=t._parts.protocol),this._parts.hostname)return a;for(e=0;s=i[e];e++)a._parts[s]=t._parts[s];return a._parts.path?".."===a._parts.path.substring(-2)&&(a._parts.path+="/"):(a._parts.path=t._parts.path,a._parts.query||(a._parts.query=t._parts.query)),"/"!==a.path().charAt(0)&&(r=t.directory(),r=r?r:0===t.path().indexOf("/")?"/":"",a._parts.path=(r?r+"/":"")+a._parts.path,a.normalizePath()),a.build(),a},_.relativeTo=function(t){var r,e,s,a,i,o=this.clone().normalize();if(o._parts.urn)throw new Error("URNs do not have any generally defined hierarchical components");if(t=new n(t).normalize(),r=o._parts,e=t._parts,a=o.path(),i=t.path(),"/"!==a.charAt(0))throw new Error("URI is already relative");if("/"!==i.charAt(0))throw new Error("Cannot calculate a URI relative to another relative URI");if(r.protocol===e.protocol&&(r.protocol=null),r.username!==e.username||r.password!==e.password)return o.build();if(null!==r.protocol||null!==r.username||null!==r.password)return o.build();if(r.hostname!==e.hostname||r.port!==e.port)return o.build();if(r.hostname=null,r.port=null,a===i)return r.path="",o.build();if(s=n.commonPath(a,i),!s)return o.build();var h=e.path.substring(s.length).replace(/[^\/]*$/,"").replace(/.*?\//g,"../");return r.path=h+r.path.substring(s.length)||"./",o.build()},_.equals=function(t){var r,e,s,a=this.clone(),i=new n(t),h={},u={},c={};if(a.normalize(),i.normalize(),a.toString()===i.toString())return!0;if(r=a.query(),e=i.query(),a.query(""),i.query(""),a.toString()!==i.toString())return!1;if(r.length!==e.length)return!1;h=n.parseQuery(r,this._parts.escapeQuerySpace),u=n.parseQuery(e,this._parts.escapeQuerySpace);for(s in h)if(y.call(h,s)){if(o(h[s])){if(!p(h[s],u[s]))return!1}else if(h[s]!==u[s])return!1;c[s]=!0}for(s in u)if(y.call(u,s)&&!c[s])return!1;return!0},_.duplicateQueryParameters=function(t){return this._parts.duplicateQueryParameters=!!t,this},_.escapeQuerySpace=function(t){return this._parts.escapeQuerySpace=!!t,this},n});
js/css.js CHANGED
@@ -4252,7 +4252,7 @@ define(function (require, exports, module) {
4252
  },{"amdefine":26}],26:[function(require,module,exports){
4253
  (function (process,__filename){
4254
  /** vim: et:ts=4:sw=4:sts=4
4255
- * @license amdefine 1.0.0 Copyright (c) 2011-2015, The Dojo Foundation All Rights Reserved.
4256
  * Available via the MIT or new BSD license.
4257
  * see: http://github.com/jrburke/amdefine for details
4258
  */
4252
  },{"amdefine":26}],26:[function(require,module,exports){
4253
  (function (process,__filename){
4254
  /** vim: et:ts=4:sw=4:sts=4
4255
+ * @license amdefine 1.0.1 Copyright (c) 2011-2016, The Dojo Foundation All Rights Reserved.
4256
  * Available via the MIT or new BSD license.
4257
  * see: http://github.com/jrburke/amdefine for details
4258
  */
js/css.min.js CHANGED
@@ -1,2 +1,2 @@
1
- !function e(t,n,r){function i(s,u){if(!n[s]){if(!t[s]){var a="function"==typeof require&&require;if(!u&&a)return a(s,!0);if(o)return o(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var l=n[s]={exports:{}};t[s][0].call(l.exports,function(e){var n=t[s][1][e];return i(n?n:e)},l,l.exports,e,t,n,r)}return n[s].exports}for(var o="function"==typeof require&&require,s=0;s<r.length;s++)i(r[s]);return i}({1:[function(e,t,n){},{}],2:[function(e,t,n){(function(e){function t(e,t){for(var n=0,r=e.length-1;r>=0;r--){var i=e[r];"."===i?e.splice(r,1):".."===i?(e.splice(r,1),n++):n&&(e.splice(r,1),n--)}if(t)for(;n--;n)e.unshift("..");return e}function r(e,t){if(e.filter)return e.filter(t);for(var n=[],r=0;r<e.length;r++)t(e[r],r,e)&&n.push(e[r]);return n}var i=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,o=function(e){return i.exec(e).slice(1)};n.resolve=function(){for(var n="",i=!1,o=arguments.length-1;o>=-1&&!i;o--){var s=o>=0?arguments[o]:e.cwd();if("string"!=typeof s)throw new TypeError("Arguments to path.resolve must be strings");s&&(n=s+"/"+n,i="/"===s.charAt(0))}return n=t(r(n.split("/"),function(e){return!!e}),!i).join("/"),(i?"/":"")+n||"."},n.normalize=function(e){var i=n.isAbsolute(e),o="/"===s(e,-1);return e=t(r(e.split("/"),function(e){return!!e}),!i).join("/"),e||i||(e="."),e&&o&&(e+="/"),(i?"/":"")+e},n.isAbsolute=function(e){return"/"===e.charAt(0)},n.join=function(){var e=Array.prototype.slice.call(arguments,0);return n.normalize(r(e,function(e,t){if("string"!=typeof e)throw new TypeError("Arguments to path.join must be strings");return e}).join("/"))},n.relative=function(e,t){function r(e){for(var t=0;t<e.length&&""===e[t];t++);for(var n=e.length-1;n>=0&&""===e[n];n--);return t>n?[]:e.slice(t,n-t+1)}e=n.resolve(e).substr(1),t=n.resolve(t).substr(1);for(var i=r(e.split("/")),o=r(t.split("/")),s=Math.min(i.length,o.length),u=s,a=0;a<s;a++)if(i[a]!==o[a]){u=a;break}for(var c=[],a=u;a<i.length;a++)c.push("..");return c=c.concat(o.slice(u)),c.join("/")},n.sep="/",n.delimiter=":",n.dirname=function(e){var t=o(e),n=t[0],r=t[1];return n||r?(r&&(r=r.substr(0,r.length-1)),n+r):"."},n.basename=function(e,t){var n=o(e)[2];return t&&n.substr(-1*t.length)===t&&(n=n.substr(0,n.length-t.length)),n},n.extname=function(e){return o(e)[3]};var s="b"==="ab".substr(-1)?function(e,t,n){return e.substr(t,n)}:function(e,t,n){return t<0&&(t=e.length+t),e.substr(t,n)}}).call(this,e("_process"))},{_process:3}],3:[function(e,t,n){function r(){throw new Error("setTimeout has not been defined")}function i(){throw new Error("clearTimeout has not been defined")}function o(e){if(p===setTimeout)return setTimeout(e,0);if((p===r||!p)&&setTimeout)return p=setTimeout,setTimeout(e,0);try{return p(e,0)}catch(t){try{return p.call(null,e,0)}catch(t){return p.call(this,e,0)}}}function s(e){if(f===clearTimeout)return clearTimeout(e);if((f===i||!f)&&clearTimeout)return f=clearTimeout,clearTimeout(e);try{return f(e)}catch(t){try{return f.call(null,e)}catch(t){return f.call(this,e)}}}function u(){d&&m&&(d=!1,m.length?g=m.concat(g):v=-1,g.length&&a())}function a(){if(!d){var e=o(u);d=!0;for(var t=g.length;t;){for(m=g,g=[];++v<t;)m&&m[v].run();v=-1,t=g.length}m=null,d=!1,s(e)}}function c(e,t){this.fun=e,this.array=t}function l(){}var p,f,h=t.exports={};!function(){try{p="function"==typeof setTimeout?setTimeout:r}catch(e){p=r}try{f="function"==typeof clearTimeout?clearTimeout:i}catch(e){f=i}}();var m,g=[],d=!1,v=-1;h.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];g.push(new c(e,t)),1!==g.length||d||o(a)},c.prototype.run=function(){this.fun.apply(null,this.array)},h.title="browser",h.browser=!0,h.env={},h.argv=[],h.version="",h.versions={},h.on=l,h.addListener=l,h.once=l,h.off=l,h.removeListener=l,h.removeAllListeners=l,h.emit=l,h.binding=function(e){throw new Error("process.binding is not supported")},h.cwd=function(){return"/"},h.chdir=function(e){throw new Error("process.chdir is not supported")},h.umask=function(){return 0}},{}],4:[function(e,t,n){window.css=e("css")},{css:5}],5:[function(e,t,n){n.parse=e("./lib/parse"),n.stringify=e("./lib/stringify")},{"./lib/parse":6,"./lib/stringify":10}],6:[function(e,t,n){function r(e){return e?e.replace(/^\s+|\s+$/g,""):""}function i(e,t){var n=e&&"string"==typeof e.type,r=n?e:t;for(var o in e){var s=e[o];Array.isArray(s)?s.forEach(function(e){i(e,r)}):s&&"object"==typeof s&&i(s,r)}return n&&Object.defineProperty(e,"parent",{configurable:!0,writable:!0,enumerable:!1,value:t||null}),e}var o=/\/\*[^*]*\*+([^\/*][^*]*\*+)*\//g;t.exports=function(e,t){function n(e){var t=e.match(/\n/g);t&&(T+=t.length);var n=e.lastIndexOf("\n");k=~n?e.length-n:k+e.length}function s(){var e={line:T,column:k};return function(t){return t.position=new u(e),m(),t}}function u(e){this.start=e,this.end={line:T,column:k},this.source=t.source}function a(n){var r=new Error(t.source+":"+T+":"+k+": "+n);if(r.reason=n,r.filename=t.source,r.line=T,r.column=k,r.source=e,!t.silent)throw r;P.push(r)}function c(){var e=f();return{type:"stylesheet",stylesheet:{rules:e,parsingErrors:P}}}function l(){return h(/^{\s*/)}function p(){return h(/^}/)}function f(){var t,n=[];for(m(),g(n);e.length&&"}"!=e.charAt(0)&&(t=O()||j());)t!==!1&&(n.push(t),g(n));return n}function h(t){var r=t.exec(e);if(r){var i=r[0];return n(i),e=e.slice(i.length),r}}function m(){h(/^\s*/)}function g(e){var t;for(e=e||[];t=d();)t!==!1&&e.push(t);return e}function d(){var t=s();if("/"==e.charAt(0)&&"*"==e.charAt(1)){for(var r=2;""!=e.charAt(r)&&("*"!=e.charAt(r)||"/"!=e.charAt(r+1));)++r;if(r+=2,""===e.charAt(r-1))return a("End of comment missing");var i=e.slice(2,r-2);return k+=2,n(i),e=e.slice(r),k+=2,t({type:"comment",comment:i})}}function v(){var e=h(/^([^{]+)/);if(e)return r(e[0]).replace(/\/\*([^*]|[\r\n]|(\*+([^*\/]|[\r\n])))*\*\/+/g,"").replace(/"(?:\\"|[^"])*"|'(?:\\'|[^'])*'/g,function(e){return e.replace(/,/g,"‌")}).split(/\s*(?![^(]*\)),\s*/).map(function(e){return e.replace(/\u200C/g,",")})}function y(){var e=s(),t=h(/^(\*?[-#\/\*\\\w]+(\[[0-9a-z_-]+\])?)\s*/);if(t){if(t=r(t[0]),!h(/^:\s*/))return a("property missing ':'");var n=h(/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^\)]*?\)|[^};])+)/),i=e({type:"declaration",property:t.replace(o,""),value:n?r(n[0]).replace(o,""):""});return h(/^[;\s]*/),i}}function _(){var e=[];if(!l())return a("missing '{'");g(e);for(var t;t=y();)t!==!1&&(e.push(t),g(e));return p()?e:a("missing '}'")}function C(){for(var e,t=[],n=s();e=h(/^((\d+\.\d+|\.\d+|\d+)%?|[a-z]+)\s*/);)t.push(e[1]),h(/^,\s*/);if(t.length)return n({type:"keyframe",values:t,declarations:_()})}function w(){var e=s(),t=h(/^@([-\w]+)?keyframes\s*/);if(t){var n=t[1],t=h(/^([-\w]+)\s*/);if(!t)return a("@keyframes missing name");var r=t[1];if(!l())return a("@keyframes missing '{'");for(var i,o=g();i=C();)o.push(i),o=o.concat(g());return p()?e({type:"keyframes",name:r,vendor:n,keyframes:o}):a("@keyframes missing '}'")}}function S(){var e=s(),t=h(/^@supports *([^{]+)/);if(t){var n=r(t[1]);if(!l())return a("@supports missing '{'");var i=g().concat(f());return p()?e({type:"supports",supports:n,rules:i}):a("@supports missing '}'")}}function A(){var e=s(),t=h(/^@host\s*/);if(t){if(!l())return a("@host missing '{'");var n=g().concat(f());return p()?e({type:"host",rules:n}):a("@host missing '}'")}}function M(){var e=s(),t=h(/^@media *([^{]+)/);if(t){var n=r(t[1]);if(!l())return a("@media missing '{'");var i=g().concat(f());return p()?e({type:"media",media:n,rules:i}):a("@media missing '}'")}}function b(){var e=s(),t=h(/^@custom-media\s+(--[^\s]+)\s*([^{;]+);/);if(t)return e({type:"custom-media",name:r(t[1]),media:r(t[2])})}function R(){var e=s(),t=h(/^@page */);if(t){var n=v()||[];if(!l())return a("@page missing '{'");for(var r,i=g();r=y();)i.push(r),i=i.concat(g());return p()?e({type:"page",selectors:n,declarations:i}):a("@page missing '}'")}}function x(){var e=s(),t=h(/^@([-\w]+)?document *([^{]+)/);if(t){var n=r(t[1]),i=r(t[2]);if(!l())return a("@document missing '{'");var o=g().concat(f());return p()?e({type:"document",document:i,vendor:n,rules:o}):a("@document missing '}'")}}function E(){var e=s(),t=h(/^@font-face\s*/);if(t){if(!l())return a("@font-face missing '{'");for(var n,r=g();n=y();)r.push(n),r=r.concat(g());return p()?e({type:"font-face",declarations:r}):a("@font-face missing '}'")}}function L(e){var t=new RegExp("^@"+e+"\\s*([^;]+);");return function(){var n=s(),r=h(t);if(r){var i={type:e};return i[e]=r[1].trim(),n(i)}}}function O(){if("@"==e[0])return w()||M()||b()||S()||G()||N()||V()||x()||R()||A()||E()}function j(){var e=s(),t=v();return t?(g(),e({type:"rule",selectors:t,declarations:_()})):a("selector missing")}t=t||{};var T=1,k=1;u.prototype.content=e;var P=[],G=L("import"),N=L("charset"),V=L("namespace");return i(c())}},{}],7:[function(e,t,n){function r(e){this.options=e||{}}t.exports=r,r.prototype.emit=function(e){return e},r.prototype.visit=function(e){return this[e.type](e)},r.prototype.mapVisit=function(e,t){var n="";t=t||"";for(var r=0,i=e.length;r<i;r++)n+=this.visit(e[r]),t&&r<i-1&&(n+=this.emit(t));return n}},{}],8:[function(e,t,n){function r(e){i.call(this,e)}var i=e("./compiler"),o=e("inherits");t.exports=r,o(r,i),r.prototype.compile=function(e){return e.stylesheet.rules.map(this.visit,this).join("")},r.prototype.comment=function(e){return this.emit("",e.position)},r.prototype.import=function(e){return this.emit("@import "+e.import+";",e.position)},r.prototype.media=function(e){return this.emit("@media "+e.media,e.position)+this.emit("{")+this.mapVisit(e.rules)+this.emit("}")},r.prototype.document=function(e){var t="@"+(e.vendor||"")+"document "+e.document;return this.emit(t,e.position)+this.emit("{")+this.mapVisit(e.rules)+this.emit("}")},r.prototype.charset=function(e){return this.emit("@charset "+e.charset+";",e.position)},r.prototype.namespace=function(e){return this.emit("@namespace "+e.namespace+";",e.position)},r.prototype.supports=function(e){return this.emit("@supports "+e.supports,e.position)+this.emit("{")+this.mapVisit(e.rules)+this.emit("}")},r.prototype.keyframes=function(e){return this.emit("@"+(e.vendor||"")+"keyframes "+e.name,e.position)+this.emit("{")+this.mapVisit(e.keyframes)+this.emit("}")},r.prototype.keyframe=function(e){var t=e.declarations;return this.emit(e.values.join(","),e.position)+this.emit("{")+this.mapVisit(t)+this.emit("}")},r.prototype.page=function(e){var t=e.selectors.length?e.selectors.join(", "):"";return this.emit("@page "+t,e.position)+this.emit("{")+this.mapVisit(e.declarations)+this.emit("}")},r.prototype["font-face"]=function(e){return this.emit("@font-face",e.position)+this.emit("{")+this.mapVisit(e.declarations)+this.emit("}")},r.prototype.host=function(e){return this.emit("@host",e.position)+this.emit("{")+this.mapVisit(e.rules)+this.emit("}")},r.prototype["custom-media"]=function(e){return this.emit("@custom-media "+e.name+" "+e.media+";",e.position)},r.prototype.rule=function(e){var t=e.declarations;return t.length?this.emit(e.selectors.join(","),e.position)+this.emit("{")+this.mapVisit(t)+this.emit("}"):""},r.prototype.declaration=function(e){return this.emit(e.property+":"+e.value,e.position)+this.emit(";")}},{"./compiler":7,inherits:12}],9:[function(e,t,n){function r(e){e=e||{},i.call(this,e),this.indentation=e.indent}var i=e("./compiler"),o=e("inherits");t.exports=r,o(r,i),r.prototype.compile=function(e){return this.stylesheet(e)},r.prototype.stylesheet=function(e){return this.mapVisit(e.stylesheet.rules,"\n\n")},r.prototype.comment=function(e){return this.emit(this.indent()+"/*"+e.comment+"*/",e.position)},r.prototype.import=function(e){return this.emit("@import "+e.import+";",e.position)},r.prototype.media=function(e){return this.emit("@media "+e.media,e.position)+this.emit(" {\n"+this.indent(1))+this.mapVisit(e.rules,"\n\n")+this.emit(this.indent(-1)+"\n}")},r.prototype.document=function(e){var t="@"+(e.vendor||"")+"document "+e.document;return this.emit(t,e.position)+this.emit(" {\n"+this.indent(1))+this.mapVisit(e.rules,"\n\n")+this.emit(this.indent(-1)+"\n}")},r.prototype.charset=function(e){return this.emit("@charset "+e.charset+";",e.position)},r.prototype.namespace=function(e){return this.emit("@namespace "+e.namespace+";",e.position)},r.prototype.supports=function(e){return this.emit("@supports "+e.supports,e.position)+this.emit(" {\n"+this.indent(1))+this.mapVisit(e.rules,"\n\n")+this.emit(this.indent(-1)+"\n}")},r.prototype.keyframes=function(e){return this.emit("@"+(e.vendor||"")+"keyframes "+e.name,e.position)+this.emit(" {\n"+this.indent(1))+this.mapVisit(e.keyframes,"\n")+this.emit(this.indent(-1)+"}")},r.prototype.keyframe=function(e){var t=e.declarations;return this.emit(this.indent())+this.emit(e.values.join(", "),e.position)+this.emit(" {\n"+this.indent(1))+this.mapVisit(t,"\n")+this.emit(this.indent(-1)+"\n"+this.indent()+"}\n")},r.prototype.page=function(e){var t=e.selectors.length?e.selectors.join(", ")+" ":"";return this.emit("@page "+t,e.position)+this.emit("{\n")+this.emit(this.indent(1))+this.mapVisit(e.declarations,"\n")+this.emit(this.indent(-1))+this.emit("\n}")},r.prototype["font-face"]=function(e){return this.emit("@font-face ",e.position)+this.emit("{\n")+this.emit(this.indent(1))+this.mapVisit(e.declarations,"\n")+this.emit(this.indent(-1))+this.emit("\n}")},r.prototype.host=function(e){return this.emit("@host",e.position)+this.emit(" {\n"+this.indent(1))+this.mapVisit(e.rules,"\n\n")+this.emit(this.indent(-1)+"\n}")},r.prototype["custom-media"]=function(e){return this.emit("@custom-media "+e.name+" "+e.media+";",e.position)},r.prototype.rule=function(e){var t=this.indent(),n=e.declarations;return n.length?this.emit(e.selectors.map(function(e){return t+e}).join(",\n"),e.position)+this.emit(" {\n")+this.emit(this.indent(1))+this.mapVisit(n,"\n")+this.emit(this.indent(-1))+this.emit("\n"+this.indent()+"}"):""},r.prototype.declaration=function(e){return this.emit(this.indent())+this.emit(e.property+": "+e.value,e.position)+this.emit(";")},r.prototype.indent=function(e){return this.level=this.level||1,null!=e?(this.level+=e,""):Array(this.level).join(this.indentation||" ")}},{"./compiler":7,inherits:12}],10:[function(e,t,n){var r=e("./compress"),i=e("./identity");t.exports=function(t,n){n=n||{};var o=n.compress?new r(n):new i(n);if(n.sourcemap){var s=e("./source-map-support");s(o);var u=o.compile(t);o.applySourceMaps();var a="generator"===n.sourcemap?o.map:o.map.toJSON();return{code:u,map:a}}var u=o.compile(t);return u}},{"./compress":8,"./identity":9,"./source-map-support":11}],11:[function(e,t,n){function r(e){e._comment=e.comment,e.map=new i,e.position={line:1,column:1},e.files={};for(var t in n)e[t]=n[t]}var i=e("source-map").SourceMapGenerator,o=e("source-map").SourceMapConsumer,s=e("source-map-resolve"),u=e("urix"),a=e("fs"),c=e("path");t.exports=r,n.updatePosition=function(e){var t=e.match(/\n/g);t&&(this.position.line+=t.length);var n=e.lastIndexOf("\n");this.position.column=~n?e.length-n:this.position.column+e.length},n.emit=function(e,t){if(t){var n=u(t.source||"source.css");this.map.addMapping({source:n,generated:{line:this.position.line,column:Math.max(this.position.column-1,0)},original:{line:t.start.line,column:t.start.column-1}}),this.addFile(n,t)}return this.updatePosition(e),e},n.addFile=function(e,t){"string"==typeof t.content&&(Object.prototype.hasOwnProperty.call(this.files,e)||(this.files[e]=t.content))},n.applySourceMaps=function(){Object.keys(this.files).forEach(function(e){var t=this.files[e];if(this.map.setSourceContent(e,t),this.options.inputSourcemaps!==!1){var n=s.resolveSync(t,e,a.readFileSync);if(n){var r=new o(n.map),i=n.sourcesRelativeTo;this.map.applySourceMap(r,e,u(c.dirname(i)))}}},this)},n.comment=function(e){return/^# sourceMappingURL=/.test(e.comment)?this.emit("",e.position):this._comment(e)}},{fs:1,path:2,"source-map":16,"source-map-resolve":15,urix:27}],12:[function(e,t,n){"function"==typeof Object.create?t.exports=function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:t.exports=function(e,t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}},{}],13:[function(e,t,n){void function(e,r){"function"==typeof define&&define.amd?define(r):"object"==typeof n?t.exports=r():e.resolveUrl=r()}(this,function(){function e(){var e=arguments.length;if(0===e)throw new Error("resolveUrl requires at least one argument; got none.");var t=document.createElement("base");if(t.href=arguments[0],1===e)return t.href;var n=document.getElementsByTagName("head")[0];n.insertBefore(t,n.firstChild);for(var r,i=document.createElement("a"),o=1;o<e;o++)i.href=arguments[o],r=i.href,t.href=r;return n.removeChild(t),r}return e})},{}],14:[function(e,t,n){void function(e,r){"function"==typeof define&&define.amd?define(r):"object"==typeof n?t.exports=r():e.sourceMappingURL=r()}(this,function(){var e=/[#@] sourceMappingURL=([^\s'"]*)/,t=RegExp("(?:/\\*(?:\\s*\r?\n(?://)?)?(?:"+e.source+")\\s*\\*/|//(?:"+e.source+"))\\s*$");return{regex:t,_innerRegex:e,getFrom:function(e){var n=e.match(t);return n?n[1]||n[2]||"":null},existsIn:function(e){return t.test(e)},removeFrom:function(e){return e.replace(t,"")},insertBefore:function(e,n){var r=e.match(t);return r?e.slice(0,r.index)+n+e.slice(r.index):e+n}}})},{}],15:[function(e,t,n){void function(r,i){if("function"==typeof define&&define.amd)define(["source-map-url","resolve-url"],i);else if("object"==typeof n){var o=e("source-map-url"),s=e("resolve-url");t.exports=i(o,s)}else r.sourceMapResolve=i(r.sourceMappingURL,r.resolveUrl)}(this,function(e,t){function n(e,t,n){setImmediate(function(){e(t,n)})}function r(e){return JSON.parse(e.replace(/^\)\]\}'/,""))}function i(e,t,i,o){var u;try{u=s(e,t)}catch(e){return n(o,e)}return!u||u.map?n(o,null,u):void i(u.url,function(e,t){if(e)return o(e);try{u.map=r(String(t))}catch(e){return o(e)}o(null,u)})}function o(e,t,n){var i=s(e,t);return!i||i.map?i:(i.map=r(String(n(i.url))),i)}function s(n,i){var o=e.getFrom(n);if(!o)return null;var s=o.match(f);if(s){var u=s[1],a=s[2],c=s[3];if(!h.test(u))throw new Error("Unuseful data uri mime type: "+(u||"text/plain"));return{sourceMappingURL:o,url:null,sourcesRelativeTo:i,map:r(";base64"===a?atob(c):decodeURIComponent(c))}}var l=t(i,o);return{sourceMappingURL:o,url:l,sourcesRelativeTo:l,map:null}}function u(e,t,r,i,o){"function"==typeof i&&(o=i,i={});var s=e.sources.length,u=!1,a={sourcesResolved:[],sourcesContent:[]},l=function(e){if(!u){if(e)return u=!0,o(e);s--,0===s&&o(null,a)}};c(e,t,i,function(e,t,i){a.sourcesResolved[i]=e,"string"==typeof t?(a.sourcesContent[i]=t,n(l,null)):r(e,function(e,t){a.sourcesContent[i]=String(t),l(e)})})}function a(e,t,n,r){var i={sourcesResolved:[],sourcesContent:[]};return c(e,t,r,function(e,t,r){i.sourcesResolved[r]=e,null!==n&&("string"==typeof t?i.sourcesContent[r]=t:i.sourcesContent[r]=String(n(e)))}),i}function c(e,n,r,i){r=r||{};for(var o,s,u=0,a=e.sources.length;u<a;u++)o=e.sourceRoot&&!r.ignoreSourceRoot?t(n,e.sourceRoot.replace(m,"/"),e.sources[u]):t(n,e.sources[u]),s=(e.sourcesContent||[])[u],i(o,s,u)}function l(e,t,n,r,o){"function"==typeof r&&(o=r,r={}),i(e,t,n,function(e,t){return e?o(e):t?void u(t.map,t.sourcesRelativeTo,n,r,function(e,n){return e?o(e):(t.sourcesResolved=n.sourcesResolved,t.sourcesContent=n.sourcesContent,void o(null,t))}):o(null,null)})}function p(e,t,n,r){var i=o(e,t,n);if(!i)return null;var s=a(i.map,i.sourcesRelativeTo,n,r);return i.sourcesResolved=s.sourcesResolved,i.sourcesContent=s.sourcesContent,i}var f=/^data:([^,;]*)(;[^,;]*)*(?:,(.*))?$/,h=/^(?:application|text)\/json$/,m=/\/?$/;return{resolveSourceMap:i,resolveSourceMapSync:o,resolveSources:u,resolveSourcesSync:a,resolve:l,resolveSync:p}})},{"resolve-url":13,"source-map-url":14}],16:[function(e,t,n){n.SourceMapGenerator=e("./source-map/source-map-generator").SourceMapGenerator,n.SourceMapConsumer=e("./source-map/source-map-consumer").SourceMapConsumer,n.SourceNode=e("./source-map/source-node").SourceNode},{"./source-map/source-map-consumer":22,"./source-map/source-map-generator":23,"./source-map/source-node":24}],17:[function(e,t,n){if("function"!=typeof r)var r=e("amdefine")(t,e);r(function(e,t,n){function r(){this._array=[],this._set={}}var i=e("./util");r.fromArray=function(e,t){for(var n=new r,i=0,o=e.length;i<o;i++)n.add(e[i],t);return n},r.prototype.add=function(e,t){var n=this.has(e),r=this._array.length;n&&!t||this._array.push(e),n||(this._set[i.toSetString(e)]=r)},r.prototype.has=function(e){return Object.prototype.hasOwnProperty.call(this._set,i.toSetString(e))},r.prototype.indexOf=function(e){if(this.has(e))return this._set[i.toSetString(e)];throw new Error('"'+e+'" is not in the set.')},r.prototype.at=function(e){if(e>=0&&e<this._array.length)return this._array[e];throw new Error("No element indexed by "+e)},r.prototype.toArray=function(){return this._array.slice()},t.ArraySet=r})},{"./util":25,amdefine:26}],18:[function(e,t,n){if("function"!=typeof r)var r=e("amdefine")(t,e);r(function(e,t,n){function r(e){return e<0?(-e<<1)+1:(e<<1)+0}function i(e){var t=1===(1&e),n=e>>1;return t?-n:n}var o=e("./base64"),s=5,u=1<<s,a=u-1,c=u;t.encode=function(e){var t,n="",i=r(e);do t=i&a,i>>>=s,i>0&&(t|=c),n+=o.encode(t);while(i>0);return n},t.decode=function(e,t){var n,r,u=0,l=e.length,p=0,f=0;do{if(u>=l)throw new Error("Expected more digits in base 64 VLQ value.");r=o.decode(e.charAt(u++)),n=!!(r&c),r&=a,p+=r<<f,f+=s}while(n);t.value=i(p),t.rest=e.slice(u)}})},{"./base64":19,amdefine:26}],19:[function(e,t,n){if("function"!=typeof r)var r=e("amdefine")(t,e);r(function(e,t,n){var r={},i={};"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("").forEach(function(e,t){r[e]=t,i[t]=e}),t.encode=function(e){if(e in i)return i[e];throw new TypeError("Must be between 0 and 63: "+e)},t.decode=function(e){if(e in r)return r[e];throw new TypeError("Not a valid base 64 digit: "+e)}})},{amdefine:26}],20:[function(e,t,n){if("function"!=typeof r)var r=e("amdefine")(t,e);r(function(e,t,n){function r(e,t,n,i,o){var s=Math.floor((t-e)/2)+e,u=o(n,i[s],!0);return 0===u?s:u>0?t-s>1?r(s,t,n,i,o):s:s-e>1?r(e,s,n,i,o):e<0?-1:e}t.search=function(e,t,n){return 0===t.length?-1:r(-1,t.length,e,t,n)}})},{amdefine:26}],21:[function(e,t,n){if("function"!=typeof r)var r=e("amdefine")(t,e);r(function(e,t,n){function r(e,t){var n=e.generatedLine,r=t.generatedLine,i=e.generatedColumn,s=t.generatedColumn;return r>n||r==n&&s>=i||o.compareByGeneratedPositions(e,t)<=0}function i(){this._array=[],this._sorted=!0,this._last={generatedLine:-1,generatedColumn:0}}var o=e("./util");i.prototype.unsortedForEach=function(e,t){this._array.forEach(e,t)},i.prototype.add=function(e){r(this._last,e)?(this._last=e,this._array.push(e)):(this._sorted=!1,this._array.push(e))},i.prototype.toArray=function(){return this._sorted||(this._array.sort(o.compareByGeneratedPositions),this._sorted=!0),this._array},t.MappingList=i})},{"./util":25,amdefine:26}],22:[function(e,t,n){if("function"!=typeof r)var r=e("amdefine")(t,e);r(function(e,t,n){function r(e){var t=e;"string"==typeof e&&(t=JSON.parse(e.replace(/^\)\]\}'/,"")));var n=i.getArg(t,"version"),r=i.getArg(t,"sources"),o=i.getArg(t,"names",[]),u=i.getArg(t,"sourceRoot",null),a=i.getArg(t,"sourcesContent",null),c=i.getArg(t,"mappings"),l=i.getArg(t,"file",null);if(n!=this._version)throw new Error("Unsupported version: "+n);r=r.map(i.normalize),this._names=s.fromArray(o,!0),this._sources=s.fromArray(r,!0),this.sourceRoot=u,this.sourcesContent=a,this._mappings=c,this.file=l}var i=e("./util"),o=e("./binary-search"),s=e("./array-set").ArraySet,u=e("./base64-vlq");r.fromSourceMap=function(e){var t=Object.create(r.prototype);return t._names=s.fromArray(e._names.toArray(),!0),t._sources=s.fromArray(e._sources.toArray(),!0),t.sourceRoot=e._sourceRoot,t.sourcesContent=e._generateSourcesContent(t._sources.toArray(),t.sourceRoot),t.file=e._file,t.__generatedMappings=e._mappings.toArray().slice(),t.__originalMappings=e._mappings.toArray().slice().sort(i.compareByOriginalPositions),t},r.prototype._version=3,Object.defineProperty(r.prototype,"sources",{get:function(){return this._sources.toArray().map(function(e){return null!=this.sourceRoot?i.join(this.sourceRoot,e):e},this)}}),r.prototype.__generatedMappings=null,Object.defineProperty(r.prototype,"_generatedMappings",{get:function(){return this.__generatedMappings||(this.__generatedMappings=[],this.__originalMappings=[],this._parseMappings(this._mappings,this.sourceRoot)),this.__generatedMappings}}),r.prototype.__originalMappings=null,Object.defineProperty(r.prototype,"_originalMappings",{get:function(){return this.__originalMappings||(this.__generatedMappings=[],this.__originalMappings=[],this._parseMappings(this._mappings,this.sourceRoot)),this.__originalMappings}}),r.prototype._nextCharIsMappingSeparator=function(e){var t=e.charAt(0);return";"===t||","===t},r.prototype._parseMappings=function(e,t){for(var n,r=1,o=0,s=0,a=0,c=0,l=0,p=e,f={};p.length>0;)if(";"===p.charAt(0))r++,p=p.slice(1),o=0;else if(","===p.charAt(0))p=p.slice(1);else{if(n={},n.generatedLine=r,u.decode(p,f),n.generatedColumn=o+f.value,o=n.generatedColumn,p=f.rest,p.length>0&&!this._nextCharIsMappingSeparator(p)){if(u.decode(p,f),n.source=this._sources.at(c+f.value),c+=f.value,p=f.rest,0===p.length||this._nextCharIsMappingSeparator(p))throw new Error("Found a source, but no line and column");if(u.decode(p,f),n.originalLine=s+f.value,s=n.originalLine,n.originalLine+=1,p=f.rest,0===p.length||this._nextCharIsMappingSeparator(p))throw new Error("Found a source and line, but no column");u.decode(p,f),n.originalColumn=a+f.value,a=n.originalColumn,p=f.rest,p.length>0&&!this._nextCharIsMappingSeparator(p)&&(u.decode(p,f),n.name=this._names.at(l+f.value),l+=f.value,p=f.rest)}this.__generatedMappings.push(n),"number"==typeof n.originalLine&&this.__originalMappings.push(n)}this.__generatedMappings.sort(i.compareByGeneratedPositions),this.__originalMappings.sort(i.compareByOriginalPositions)},r.prototype._findMapping=function(e,t,n,r,i){if(e[n]<=0)throw new TypeError("Line must be greater than or equal to 1, got "+e[n]);if(e[r]<0)throw new TypeError("Column must be greater than or equal to 0, got "+e[r]);return o.search(e,t,i)},r.prototype.computeColumnSpans=function(){for(var e=0;e<this._generatedMappings.length;++e){var t=this._generatedMappings[e];if(e+1<this._generatedMappings.length){var n=this._generatedMappings[e+1];if(t.generatedLine===n.generatedLine){t.lastGeneratedColumn=n.generatedColumn-1;continue}}t.lastGeneratedColumn=1/0}},r.prototype.originalPositionFor=function(e){var t={generatedLine:i.getArg(e,"line"),generatedColumn:i.getArg(e,"column")},n=this._findMapping(t,this._generatedMappings,"generatedLine","generatedColumn",i.compareByGeneratedPositions);if(n>=0){var r=this._generatedMappings[n];if(r.generatedLine===t.generatedLine){var o=i.getArg(r,"source",null);return null!=o&&null!=this.sourceRoot&&(o=i.join(this.sourceRoot,o)),{source:o,line:i.getArg(r,"originalLine",null),column:i.getArg(r,"originalColumn",null),name:i.getArg(r,"name",null)}}}return{source:null,line:null,column:null,name:null}},r.prototype.sourceContentFor=function(e){if(!this.sourcesContent)return null;if(null!=this.sourceRoot&&(e=i.relative(this.sourceRoot,e)),this._sources.has(e))return this.sourcesContent[this._sources.indexOf(e)];var t;if(null!=this.sourceRoot&&(t=i.urlParse(this.sourceRoot))){var n=e.replace(/^file:\/\//,"");if("file"==t.scheme&&this._sources.has(n))return this.sourcesContent[this._sources.indexOf(n)];if((!t.path||"/"==t.path)&&this._sources.has("/"+e))return this.sourcesContent[this._sources.indexOf("/"+e)]}throw new Error('"'+e+'" is not in the SourceMap.')},r.prototype.generatedPositionFor=function(e){var t={source:i.getArg(e,"source"),originalLine:i.getArg(e,"line"),originalColumn:i.getArg(e,"column")};null!=this.sourceRoot&&(t.source=i.relative(this.sourceRoot,t.source));var n=this._findMapping(t,this._originalMappings,"originalLine","originalColumn",i.compareByOriginalPositions);if(n>=0){var r=this._originalMappings[n];return{line:i.getArg(r,"generatedLine",null),column:i.getArg(r,"generatedColumn",null),lastColumn:i.getArg(r,"lastGeneratedColumn",null)}}return{line:null,column:null,lastColumn:null}},r.prototype.allGeneratedPositionsFor=function(e){var t={source:i.getArg(e,"source"),originalLine:i.getArg(e,"line"),originalColumn:1/0};null!=this.sourceRoot&&(t.source=i.relative(this.sourceRoot,t.source));var n=[],r=this._findMapping(t,this._originalMappings,"originalLine","originalColumn",i.compareByOriginalPositions);if(r>=0)for(var o=this._originalMappings[r];o&&o.originalLine===t.originalLine;)n.push({line:i.getArg(o,"generatedLine",null),column:i.getArg(o,"generatedColumn",null),lastColumn:i.getArg(o,"lastGeneratedColumn",null)}),o=this._originalMappings[--r];return n.reverse()},r.GENERATED_ORDER=1,r.ORIGINAL_ORDER=2,r.prototype.eachMapping=function(e,t,n){var o,s=t||null,u=n||r.GENERATED_ORDER;switch(u){case r.GENERATED_ORDER:o=this._generatedMappings;break;case r.ORIGINAL_ORDER:o=this._originalMappings;break;default:throw new Error("Unknown order of iteration.")}var a=this.sourceRoot;o.map(function(e){var t=e.source;return null!=t&&null!=a&&(t=i.join(a,t)),{source:t,generatedLine:e.generatedLine,generatedColumn:e.generatedColumn,originalLine:e.originalLine,originalColumn:e.originalColumn,name:e.name}}).forEach(e,s)},t.SourceMapConsumer=r})},{"./array-set":17,"./base64-vlq":18,"./binary-search":20,"./util":25,amdefine:26}],23:[function(e,t,n){if("function"!=typeof r)var r=e("amdefine")(t,e);r(function(e,t,n){function r(e){e||(e={}),this._file=o.getArg(e,"file",null),this._sourceRoot=o.getArg(e,"sourceRoot",null),this._skipValidation=o.getArg(e,"skipValidation",!1),this._sources=new s,this._names=new s,this._mappings=new u,this._sourcesContents=null}var i=e("./base64-vlq"),o=e("./util"),s=e("./array-set").ArraySet,u=e("./mapping-list").MappingList;r.prototype._version=3,r.fromSourceMap=function(e){var t=e.sourceRoot,n=new r({file:e.file,sourceRoot:t});return e.eachMapping(function(e){var r={generated:{line:e.generatedLine,column:e.generatedColumn}};null!=e.source&&(r.source=e.source,null!=t&&(r.source=o.relative(t,r.source)),r.original={line:e.originalLine,column:e.originalColumn},null!=e.name&&(r.name=e.name)),n.addMapping(r)}),e.sources.forEach(function(t){var r=e.sourceContentFor(t);null!=r&&n.setSourceContent(t,r)}),n},r.prototype.addMapping=function(e){var t=o.getArg(e,"generated"),n=o.getArg(e,"original",null),r=o.getArg(e,"source",null),i=o.getArg(e,"name",null);this._skipValidation||this._validateMapping(t,n,r,i),null==r||this._sources.has(r)||this._sources.add(r),null==i||this._names.has(i)||this._names.add(i),this._mappings.add({generatedLine:t.line,generatedColumn:t.column,originalLine:null!=n&&n.line,originalColumn:null!=n&&n.column,source:r,name:i})},r.prototype.setSourceContent=function(e,t){var n=e;null!=this._sourceRoot&&(n=o.relative(this._sourceRoot,n)),null!=t?(this._sourcesContents||(this._sourcesContents={}),this._sourcesContents[o.toSetString(n)]=t):this._sourcesContents&&(delete this._sourcesContents[o.toSetString(n)],0===Object.keys(this._sourcesContents).length&&(this._sourcesContents=null))},r.prototype.applySourceMap=function(e,t,n){var r=t;if(null==t){if(null==e.file)throw new Error('SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, or the source map\'s "file" property. Both were omitted.');r=e.file}var i=this._sourceRoot;null!=i&&(r=o.relative(i,r));var u=new s,a=new s;this._mappings.unsortedForEach(function(t){if(t.source===r&&null!=t.originalLine){var s=e.originalPositionFor({line:t.originalLine,column:t.originalColumn});null!=s.source&&(t.source=s.source,null!=n&&(t.source=o.join(n,t.source)),null!=i&&(t.source=o.relative(i,t.source)),t.originalLine=s.line,
2
  t.originalColumn=s.column,null!=s.name&&(t.name=s.name))}var c=t.source;null==c||u.has(c)||u.add(c);var l=t.name;null==l||a.has(l)||a.add(l)},this),this._sources=u,this._names=a,e.sources.forEach(function(t){var r=e.sourceContentFor(t);null!=r&&(null!=n&&(t=o.join(n,t)),null!=i&&(t=o.relative(i,t)),this.setSourceContent(t,r))},this)},r.prototype._validateMapping=function(e,t,n,r){if((!(e&&"line"in e&&"column"in e&&e.line>0&&e.column>=0)||t||n||r)&&!(e&&"line"in e&&"column"in e&&t&&"line"in t&&"column"in t&&e.line>0&&e.column>=0&&t.line>0&&t.column>=0&&n))throw new Error("Invalid mapping: "+JSON.stringify({generated:e,source:n,original:t,name:r}))},r.prototype._serializeMappings=function(){for(var e,t=0,n=1,r=0,s=0,u=0,a=0,c="",l=this._mappings.toArray(),p=0,f=l.length;p<f;p++){if(e=l[p],e.generatedLine!==n)for(t=0;e.generatedLine!==n;)c+=";",n++;else if(p>0){if(!o.compareByGeneratedPositions(e,l[p-1]))continue;c+=","}c+=i.encode(e.generatedColumn-t),t=e.generatedColumn,null!=e.source&&(c+=i.encode(this._sources.indexOf(e.source)-a),a=this._sources.indexOf(e.source),c+=i.encode(e.originalLine-1-s),s=e.originalLine-1,c+=i.encode(e.originalColumn-r),r=e.originalColumn,null!=e.name&&(c+=i.encode(this._names.indexOf(e.name)-u),u=this._names.indexOf(e.name)))}return c},r.prototype._generateSourcesContent=function(e,t){return e.map(function(e){if(!this._sourcesContents)return null;null!=t&&(e=o.relative(t,e));var n=o.toSetString(e);return Object.prototype.hasOwnProperty.call(this._sourcesContents,n)?this._sourcesContents[n]:null},this)},r.prototype.toJSON=function(){var e={version:this._version,sources:this._sources.toArray(),names:this._names.toArray(),mappings:this._serializeMappings()};return null!=this._file&&(e.file=this._file),null!=this._sourceRoot&&(e.sourceRoot=this._sourceRoot),this._sourcesContents&&(e.sourcesContent=this._generateSourcesContent(e.sources,e.sourceRoot)),e},r.prototype.toString=function(){return JSON.stringify(this)},t.SourceMapGenerator=r})},{"./array-set":17,"./base64-vlq":18,"./mapping-list":21,"./util":25,amdefine:26}],24:[function(e,t,n){if("function"!=typeof r)var r=e("amdefine")(t,e);r(function(e,t,n){function r(e,t,n,r,i){this.children=[],this.sourceContents={},this.line=null==e?null:e,this.column=null==t?null:t,this.source=null==n?null:n,this.name=null==i?null:i,this[a]=!0,null!=r&&this.add(r)}var i=e("./source-map-generator").SourceMapGenerator,o=e("./util"),s=/(\r?\n)/,u=10,a="$$$isSourceNode$$$";r.fromStringWithSourceMap=function(e,t,n){function i(e,t){if(null===e||void 0===e.source)u.add(t);else{var i=n?o.join(n,e.source):e.source;u.add(new r(e.originalLine,e.originalColumn,i,t,e.name))}}var u=new r,a=e.split(s),c=function(){var e=a.shift(),t=a.shift()||"";return e+t},l=1,p=0,f=null;return t.eachMapping(function(e){if(null!==f){if(!(l<e.generatedLine)){var t=a[0],n=t.substr(0,e.generatedColumn-p);return a[0]=t.substr(e.generatedColumn-p),p=e.generatedColumn,i(f,n),void(f=e)}var n="";i(f,c()),l++,p=0}for(;l<e.generatedLine;)u.add(c()),l++;if(p<e.generatedColumn){var t=a[0];u.add(t.substr(0,e.generatedColumn)),a[0]=t.substr(e.generatedColumn),p=e.generatedColumn}f=e},this),a.length>0&&(f&&i(f,c()),u.add(a.join(""))),t.sources.forEach(function(e){var r=t.sourceContentFor(e);null!=r&&(null!=n&&(e=o.join(n,e)),u.setSourceContent(e,r))}),u},r.prototype.add=function(e){if(Array.isArray(e))e.forEach(function(e){this.add(e)},this);else{if(!e[a]&&"string"!=typeof e)throw new TypeError("Expected a SourceNode, string, or an array of SourceNodes and strings. Got "+e);e&&this.children.push(e)}return this},r.prototype.prepend=function(e){if(Array.isArray(e))for(var t=e.length-1;t>=0;t--)this.prepend(e[t]);else{if(!e[a]&&"string"!=typeof e)throw new TypeError("Expected a SourceNode, string, or an array of SourceNodes and strings. Got "+e);this.children.unshift(e)}return this},r.prototype.walk=function(e){for(var t,n=0,r=this.children.length;n<r;n++)t=this.children[n],t[a]?t.walk(e):""!==t&&e(t,{source:this.source,line:this.line,column:this.column,name:this.name})},r.prototype.join=function(e){var t,n,r=this.children.length;if(r>0){for(t=[],n=0;n<r-1;n++)t.push(this.children[n]),t.push(e);t.push(this.children[n]),this.children=t}return this},r.prototype.replaceRight=function(e,t){var n=this.children[this.children.length-1];return n[a]?n.replaceRight(e,t):"string"==typeof n?this.children[this.children.length-1]=n.replace(e,t):this.children.push("".replace(e,t)),this},r.prototype.setSourceContent=function(e,t){this.sourceContents[o.toSetString(e)]=t},r.prototype.walkSourceContents=function(e){for(var t=0,n=this.children.length;t<n;t++)this.children[t][a]&&this.children[t].walkSourceContents(e);for(var r=Object.keys(this.sourceContents),t=0,n=r.length;t<n;t++)e(o.fromSetString(r[t]),this.sourceContents[r[t]])},r.prototype.toString=function(){var e="";return this.walk(function(t){e+=t}),e},r.prototype.toStringWithSourceMap=function(e){var t={code:"",line:1,column:0},n=new i(e),r=!1,o=null,s=null,a=null,c=null;return this.walk(function(e,i){t.code+=e,null!==i.source&&null!==i.line&&null!==i.column?(o===i.source&&s===i.line&&a===i.column&&c===i.name||n.addMapping({source:i.source,original:{line:i.line,column:i.column},generated:{line:t.line,column:t.column},name:i.name}),o=i.source,s=i.line,a=i.column,c=i.name,r=!0):r&&(n.addMapping({generated:{line:t.line,column:t.column}}),o=null,r=!1);for(var l=0,p=e.length;l<p;l++)e.charCodeAt(l)===u?(t.line++,t.column=0,l+1===p?(o=null,r=!1):r&&n.addMapping({source:i.source,original:{line:i.line,column:i.column},generated:{line:t.line,column:t.column},name:i.name})):t.column++}),this.walkSourceContents(function(e,t){n.setSourceContent(e,t)}),{code:t.code,map:n}},t.SourceNode=r})},{"./source-map-generator":23,"./util":25,amdefine:26}],25:[function(e,t,n){if("function"!=typeof r)var r=e("amdefine")(t,e);r(function(e,t,n){function r(e,t,n){if(t in e)return e[t];if(3===arguments.length)return n;throw new Error('"'+t+'" is a required argument.')}function i(e){var t=e.match(m);return t?{scheme:t[1],auth:t[2],host:t[3],port:t[4],path:t[5]}:null}function o(e){var t="";return e.scheme&&(t+=e.scheme+":"),t+="//",e.auth&&(t+=e.auth+"@"),e.host&&(t+=e.host),e.port&&(t+=":"+e.port),e.path&&(t+=e.path),t}function s(e){var t=e,n=i(e);if(n){if(!n.path)return e;t=n.path}for(var r,s="/"===t.charAt(0),u=t.split(/\/+/),a=0,c=u.length-1;c>=0;c--)r=u[c],"."===r?u.splice(c,1):".."===r?a++:a>0&&(""===r?(u.splice(c+1,a),a=0):(u.splice(c,2),a--));return t=u.join("/"),""===t&&(t=s?"/":"."),n?(n.path=t,o(n)):t}function u(e,t){""===e&&(e="."),""===t&&(t=".");var n=i(t),r=i(e);if(r&&(e=r.path||"/"),n&&!n.scheme)return r&&(n.scheme=r.scheme),o(n);if(n||t.match(g))return t;if(r&&!r.host&&!r.path)return r.host=t,o(r);var u="/"===t.charAt(0)?t:s(e.replace(/\/+$/,"")+"/"+t);return r?(r.path=u,o(r)):u}function a(e,t){""===e&&(e="."),e=e.replace(/\/$/,"");var n=i(e);return"/"==t.charAt(0)&&n&&"/"==n.path?t.slice(1):0===t.indexOf(e+"/")?t.substr(e.length+1):t}function c(e){return"$"+e}function l(e){return e.substr(1)}function p(e,t){var n=e||"",r=t||"";return(n>r)-(n<r)}function f(e,t,n){var r;return(r=p(e.source,t.source))?r:(r=e.originalLine-t.originalLine)?r:(r=e.originalColumn-t.originalColumn,r||n?r:(r=p(e.name,t.name))?r:(r=e.generatedLine-t.generatedLine,r?r:e.generatedColumn-t.generatedColumn))}function h(e,t,n){var r;return(r=e.generatedLine-t.generatedLine)?r:(r=e.generatedColumn-t.generatedColumn,r||n?r:(r=p(e.source,t.source))?r:(r=e.originalLine-t.originalLine)?r:(r=e.originalColumn-t.originalColumn,r?r:p(e.name,t.name)))}t.getArg=r;var m=/^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.]*)(?::(\d+))?(\S*)$/,g=/^data:.+\,.+$/;t.urlParse=i,t.urlGenerate=o,t.normalize=s,t.join=u,t.relative=a,t.toSetString=c,t.fromSetString=l,t.compareByOriginalPositions=f,t.compareByGeneratedPositions=h})},{amdefine:26}],26:[function(e,t,n){(function(n,r){"use strict";function i(t,i){function o(e){var t,n;for(t=0;e[t];t+=1)if(n=e[t],"."===n)e.splice(t,1),t-=1;else if(".."===n){if(1===t&&(".."===e[2]||".."===e[0]))break;t>0&&(e.splice(t-1,2),t-=2)}}function s(e,t){var n;return e&&"."===e.charAt(0)&&t&&(n=t.split("/"),n=n.slice(0,n.length-1),n=n.concat(e.split("/")),o(n),e=n.join("/")),e}function u(e){return function(t){return s(t,e)}}function a(e){function t(t){m[e]=t}return t.fromText=function(e,t){throw new Error("amdefine does not implement load.fromText")},t}function c(e,n,o){var s,u,a,c;if(e)u=m[e]={},a={id:e,uri:r,exports:u},s=p(i,u,a,e);else{if(g)throw new Error("amdefine with no module ID cannot be called more than once per file.");g=!0,u=t.exports,a=t,s=p(i,u,a,t.id)}n&&(n=n.map(function(e){return s(e)})),c="function"==typeof o?o.apply(a.exports,n):o,void 0!==c&&(a.exports=c,e&&(m[e]=a.exports))}function l(e,t,n){Array.isArray(e)?(n=t,t=e,e=void 0):"string"!=typeof e&&(n=e,e=t=void 0),t&&!Array.isArray(t)&&(n=t,t=void 0),t||(t=["require","exports","module"]),e?h[e]=[e,t,n]:c(e,t,n)}var p,f,h={},m={},g=!1,d=e("path");return p=function(e,t,r,i){function o(o,s){return"string"==typeof o?f(e,t,r,o,i):(o=o.map(function(n){return f(e,t,r,n,i)}),void(s&&n.nextTick(function(){s.apply(null,o)})))}return o.toUrl=function(e){return 0===e.indexOf(".")?s(e,d.dirname(r.filename)):e},o},i=i||function(){return t.require.apply(t,arguments)},f=function(e,t,n,r,i){var o,l,g=r.indexOf("!"),d=r;if(g===-1){if(r=s(r,i),"require"===r)return p(e,t,n,i);if("exports"===r)return t;if("module"===r)return n;if(m.hasOwnProperty(r))return m[r];if(h[r])return c.apply(null,h[r]),m[r];if(e)return e(d);throw new Error("No module with ID: "+r)}return o=r.substring(0,g),r=r.substring(g+1,r.length),l=f(e,t,n,o,i),r=l.normalize?l.normalize(r,u(i)):s(r,i),m[r]?m[r]:(l.load(r,p(e,t,n,i),a(r),{}),m[r])},l.require=function(e){return m[e]?m[e]:h[e]?(c.apply(null,h[e]),m[e]):void 0},l.amd={},l}t.exports=i}).call(this,e("_process"),"/node_modules/css/node_modules/source-map/node_modules/amdefine/amdefine.js")},{_process:3,path:2}],27:[function(e,t,n){function r(e){return"\\"===i.sep?e.replace(/\\/g,"/").replace(/^[a-z]:\/?/i,"/"):e}var i=e("path");t.exports=r},{path:2}]},{},[4]);
1
+ !function e(t,n,r){function i(s,u){if(!n[s]){if(!t[s]){var a="function"==typeof require&&require;if(!u&&a)return a(s,!0);if(o)return o(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var l=n[s]={exports:{}};t[s][0].call(l.exports,function(e){var n=t[s][1][e];return i(n?n:e)},l,l.exports,e,t,n,r)}return n[s].exports}for(var o="function"==typeof require&&require,s=0;s<r.length;s++)i(r[s]);return i}({1:[function(e,t,n){},{}],2:[function(e,t,n){(function(e){function t(e,t){for(var n=0,r=e.length-1;r>=0;r--){var i=e[r];"."===i?e.splice(r,1):".."===i?(e.splice(r,1),n++):n&&(e.splice(r,1),n--)}if(t)for(;n--;n)e.unshift("..");return e}function r(e,t){if(e.filter)return e.filter(t);for(var n=[],r=0;r<e.length;r++)t(e[r],r,e)&&n.push(e[r]);return n}var i=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,o=function(e){return i.exec(e).slice(1)};n.resolve=function(){for(var n="",i=!1,o=arguments.length-1;o>=-1&&!i;o--){var s=o>=0?arguments[o]:e.cwd();if("string"!=typeof s)throw new TypeError("Arguments to path.resolve must be strings");s&&(n=s+"/"+n,i="/"===s.charAt(0))}return n=t(r(n.split("/"),function(e){return!!e}),!i).join("/"),(i?"/":"")+n||"."},n.normalize=function(e){var i=n.isAbsolute(e),o="/"===s(e,-1);return e=t(r(e.split("/"),function(e){return!!e}),!i).join("/"),e||i||(e="."),e&&o&&(e+="/"),(i?"/":"")+e},n.isAbsolute=function(e){return"/"===e.charAt(0)},n.join=function(){var e=Array.prototype.slice.call(arguments,0);return n.normalize(r(e,function(e,t){if("string"!=typeof e)throw new TypeError("Arguments to path.join must be strings");return e}).join("/"))},n.relative=function(e,t){function r(e){for(var t=0;t<e.length&&""===e[t];t++);for(var n=e.length-1;n>=0&&""===e[n];n--);return t>n?[]:e.slice(t,n-t+1)}e=n.resolve(e).substr(1),t=n.resolve(t).substr(1);for(var i=r(e.split("/")),o=r(t.split("/")),s=Math.min(i.length,o.length),u=s,a=0;a<s;a++)if(i[a]!==o[a]){u=a;break}for(var c=[],a=u;a<i.length;a++)c.push("..");return c=c.concat(o.slice(u)),c.join("/")},n.sep="/",n.delimiter=":",n.dirname=function(e){var t=o(e),n=t[0],r=t[1];return n||r?(r&&(r=r.substr(0,r.length-1)),n+r):"."},n.basename=function(e,t){var n=o(e)[2];return t&&n.substr(-1*t.length)===t&&(n=n.substr(0,n.length-t.length)),n},n.extname=function(e){return o(e)[3]};var s="b"==="ab".substr(-1)?function(e,t,n){return e.substr(t,n)}:function(e,t,n){return t<0&&(t=e.length+t),e.substr(t,n)}}).call(this,e("_process"))},{_process:3}],3:[function(e,t,n){function r(){throw new Error("setTimeout has not been defined")}function i(){throw new Error("clearTimeout has not been defined")}function o(e){if(p===setTimeout)return setTimeout(e,0);if((p===r||!p)&&setTimeout)return p=setTimeout,setTimeout(e,0);try{return p(e,0)}catch(t){try{return p.call(null,e,0)}catch(t){return p.call(this,e,0)}}}function s(e){if(f===clearTimeout)return clearTimeout(e);if((f===i||!f)&&clearTimeout)return f=clearTimeout,clearTimeout(e);try{return f(e)}catch(t){try{return f.call(null,e)}catch(t){return f.call(this,e)}}}function u(){d&&m&&(d=!1,m.length?g=m.concat(g):v=-1,g.length&&a())}function a(){if(!d){var e=o(u);d=!0;for(var t=g.length;t;){for(m=g,g=[];++v<t;)m&&m[v].run();v=-1,t=g.length}m=null,d=!1,s(e)}}function c(e,t){this.fun=e,this.array=t}function l(){}var p,f,h=t.exports={};!function(){try{p="function"==typeof setTimeout?setTimeout:r}catch(e){p=r}try{f="function"==typeof clearTimeout?clearTimeout:i}catch(e){f=i}}();var m,g=[],d=!1,v=-1;h.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];g.push(new c(e,t)),1!==g.length||d||o(a)},c.prototype.run=function(){this.fun.apply(null,this.array)},h.title="browser",h.browser=!0,h.env={},h.argv=[],h.version="",h.versions={},h.on=l,h.addListener=l,h.once=l,h.off=l,h.removeListener=l,h.removeAllListeners=l,h.emit=l,h.binding=function(e){throw new Error("process.binding is not supported")},h.cwd=function(){return"/"},h.chdir=function(e){throw new Error("process.chdir is not supported")},h.umask=function(){return 0}},{}],4:[function(e,t,n){window.css=e("css")},{css:5}],5:[function(e,t,n){n.parse=e("./lib/parse"),n.stringify=e("./lib/stringify")},{"./lib/parse":6,"./lib/stringify":10}],6:[function(e,t,n){function r(e){return e?e.replace(/^\s+|\s+$/g,""):""}function i(e,t){var n=e&&"string"==typeof e.type,r=n?e:t;for(var o in e){var s=e[o];Array.isArray(s)?s.forEach(function(e){i(e,r)}):s&&"object"==typeof s&&i(s,r)}return n&&Object.defineProperty(e,"parent",{configurable:!0,writable:!0,enumerable:!1,value:t||null}),e}var o=/\/\*[^*]*\*+([^\/*][^*]*\*+)*\//g;t.exports=function(e,t){function n(e){var t=e.match(/\n/g);t&&(T+=t.length);var n=e.lastIndexOf("\n");k=~n?e.length-n:k+e.length}function s(){var e={line:T,column:k};return function(t){return t.position=new u(e),m(),t}}function u(e){this.start=e,this.end={line:T,column:k},this.source=t.source}function a(n){var r=new Error(t.source+":"+T+":"+k+": "+n);if(r.reason=n,r.filename=t.source,r.line=T,r.column=k,r.source=e,!t.silent)throw r;P.push(r)}function c(){var e=f();return{type:"stylesheet",stylesheet:{rules:e,parsingErrors:P}}}function l(){return h(/^{\s*/)}function p(){return h(/^}/)}function f(){var t,n=[];for(m(),g(n);e.length&&"}"!=e.charAt(0)&&(t=O()||j());)t!==!1&&(n.push(t),g(n));return n}function h(t){var r=t.exec(e);if(r){var i=r[0];return n(i),e=e.slice(i.length),r}}function m(){h(/^\s*/)}function g(e){var t;for(e=e||[];t=d();)t!==!1&&e.push(t);return e}function d(){var t=s();if("/"==e.charAt(0)&&"*"==e.charAt(1)){for(var r=2;""!=e.charAt(r)&&("*"!=e.charAt(r)||"/"!=e.charAt(r+1));)++r;if(r+=2,""===e.charAt(r-1))return a("End of comment missing");var i=e.slice(2,r-2);return k+=2,n(i),e=e.slice(r),k+=2,t({type:"comment",comment:i})}}function v(){var e=h(/^([^{]+)/);if(e)return r(e[0]).replace(/\/\*([^*]|[\r\n]|(\*+([^*\/]|[\r\n])))*\*\/+/g,"").replace(/"(?:\\"|[^"])*"|'(?:\\'|[^'])*'/g,function(e){return e.replace(/,/g,"‌")}).split(/\s*(?![^(]*\)),\s*/).map(function(e){return e.replace(/\u200C/g,",")})}function y(){var e=s(),t=h(/^(\*?[-#\/\*\\\w]+(\[[0-9a-z_-]+\])?)\s*/);if(t){if(t=r(t[0]),!h(/^:\s*/))return a("property missing ':'");var n=h(/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^\)]*?\)|[^};])+)/),i=e({type:"declaration",property:t.replace(o,""),value:n?r(n[0]).replace(o,""):""});return h(/^[;\s]*/),i}}function _(){var e=[];if(!l())return a("missing '{'");g(e);for(var t;t=y();)t!==!1&&(e.push(t),g(e));return p()?e:a("missing '}'")}function C(){for(var e,t=[],n=s();e=h(/^((\d+\.\d+|\.\d+|\d+)%?|[a-z]+)\s*/);)t.push(e[1]),h(/^,\s*/);if(t.length)return n({type:"keyframe",values:t,declarations:_()})}function w(){var e=s(),t=h(/^@([-\w]+)?keyframes\s*/);if(t){var n=t[1],t=h(/^([-\w]+)\s*/);if(!t)return a("@keyframes missing name");var r=t[1];if(!l())return a("@keyframes missing '{'");for(var i,o=g();i=C();)o.push(i),o=o.concat(g());return p()?e({type:"keyframes",name:r,vendor:n,keyframes:o}):a("@keyframes missing '}'")}}function S(){var e=s(),t=h(/^@supports *([^{]+)/);if(t){var n=r(t[1]);if(!l())return a("@supports missing '{'");var i=g().concat(f());return p()?e({type:"supports",supports:n,rules:i}):a("@supports missing '}'")}}function A(){var e=s(),t=h(/^@host\s*/);if(t){if(!l())return a("@host missing '{'");var n=g().concat(f());return p()?e({type:"host",rules:n}):a("@host missing '}'")}}function M(){var e=s(),t=h(/^@media *([^{]+)/);if(t){var n=r(t[1]);if(!l())return a("@media missing '{'");var i=g().concat(f());return p()?e({type:"media",media:n,rules:i}):a("@media missing '}'")}}function b(){var e=s(),t=h(/^@custom-media\s+(--[^\s]+)\s*([^{;]+);/);if(t)return e({type:"custom-media",name:r(t[1]),media:r(t[2])})}function R(){var e=s(),t=h(/^@page */);if(t){var n=v()||[];if(!l())return a("@page missing '{'");for(var r,i=g();r=y();)i.push(r),i=i.concat(g());return p()?e({type:"page",selectors:n,declarations:i}):a("@page missing '}'")}}function x(){var e=s(),t=h(/^@([-\w]+)?document *([^{]+)/);if(t){var n=r(t[1]),i=r(t[2]);if(!l())return a("@document missing '{'");var o=g().concat(f());return p()?e({type:"document",document:i,vendor:n,rules:o}):a("@document missing '}'")}}function E(){var e=s(),t=h(/^@font-face\s*/);if(t){if(!l())return a("@font-face missing '{'");for(var n,r=g();n=y();)r.push(n),r=r.concat(g());return p()?e({type:"font-face",declarations:r}):a("@font-face missing '}'")}}function L(e){var t=new RegExp("^@"+e+"\\s*([^;]+);");return function(){var n=s(),r=h(t);if(r){var i={type:e};return i[e]=r[1].trim(),n(i)}}}function O(){if("@"==e[0])return w()||M()||b()||S()||G()||N()||V()||x()||R()||A()||E()}function j(){var e=s(),t=v();return t?(g(),e({type:"rule",selectors:t,declarations:_()})):a("selector missing")}t=t||{};var T=1,k=1;u.prototype.content=e;var P=[],G=L("import"),N=L("charset"),V=L("namespace");return i(c())}},{}],7:[function(e,t,n){function r(e){this.options=e||{}}t.exports=r,r.prototype.emit=function(e){return e},r.prototype.visit=function(e){return this[e.type](e)},r.prototype.mapVisit=function(e,t){var n="";t=t||"";for(var r=0,i=e.length;r<i;r++)n+=this.visit(e[r]),t&&r<i-1&&(n+=this.emit(t));return n}},{}],8:[function(e,t,n){function r(e){i.call(this,e)}var i=e("./compiler"),o=e("inherits");t.exports=r,o(r,i),r.prototype.compile=function(e){return e.stylesheet.rules.map(this.visit,this).join("")},r.prototype.comment=function(e){return this.emit("",e.position)},r.prototype["import"]=function(e){return this.emit("@import "+e["import"]+";",e.position)},r.prototype.media=function(e){return this.emit("@media "+e.media,e.position)+this.emit("{")+this.mapVisit(e.rules)+this.emit("}")},r.prototype.document=function(e){var t="@"+(e.vendor||"")+"document "+e.document;return this.emit(t,e.position)+this.emit("{")+this.mapVisit(e.rules)+this.emit("}")},r.prototype.charset=function(e){return this.emit("@charset "+e.charset+";",e.position)},r.prototype.namespace=function(e){return this.emit("@namespace "+e.namespace+";",e.position)},r.prototype.supports=function(e){return this.emit("@supports "+e.supports,e.position)+this.emit("{")+this.mapVisit(e.rules)+this.emit("}")},r.prototype.keyframes=function(e){return this.emit("@"+(e.vendor||"")+"keyframes "+e.name,e.position)+this.emit("{")+this.mapVisit(e.keyframes)+this.emit("}")},r.prototype.keyframe=function(e){var t=e.declarations;return this.emit(e.values.join(","),e.position)+this.emit("{")+this.mapVisit(t)+this.emit("}")},r.prototype.page=function(e){var t=e.selectors.length?e.selectors.join(", "):"";return this.emit("@page "+t,e.position)+this.emit("{")+this.mapVisit(e.declarations)+this.emit("}")},r.prototype["font-face"]=function(e){return this.emit("@font-face",e.position)+this.emit("{")+this.mapVisit(e.declarations)+this.emit("}")},r.prototype.host=function(e){return this.emit("@host",e.position)+this.emit("{")+this.mapVisit(e.rules)+this.emit("}")},r.prototype["custom-media"]=function(e){return this.emit("@custom-media "+e.name+" "+e.media+";",e.position)},r.prototype.rule=function(e){var t=e.declarations;return t.length?this.emit(e.selectors.join(","),e.position)+this.emit("{")+this.mapVisit(t)+this.emit("}"):""},r.prototype.declaration=function(e){return this.emit(e.property+":"+e.value,e.position)+this.emit(";")}},{"./compiler":7,inherits:12}],9:[function(e,t,n){function r(e){e=e||{},i.call(this,e),this.indentation=e.indent}var i=e("./compiler"),o=e("inherits");t.exports=r,o(r,i),r.prototype.compile=function(e){return this.stylesheet(e)},r.prototype.stylesheet=function(e){return this.mapVisit(e.stylesheet.rules,"\n\n")},r.prototype.comment=function(e){return this.emit(this.indent()+"/*"+e.comment+"*/",e.position)},r.prototype["import"]=function(e){return this.emit("@import "+e["import"]+";",e.position)},r.prototype.media=function(e){return this.emit("@media "+e.media,e.position)+this.emit(" {\n"+this.indent(1))+this.mapVisit(e.rules,"\n\n")+this.emit(this.indent(-1)+"\n}")},r.prototype.document=function(e){var t="@"+(e.vendor||"")+"document "+e.document;return this.emit(t,e.position)+this.emit(" {\n"+this.indent(1))+this.mapVisit(e.rules,"\n\n")+this.emit(this.indent(-1)+"\n}")},r.prototype.charset=function(e){return this.emit("@charset "+e.charset+";",e.position)},r.prototype.namespace=function(e){return this.emit("@namespace "+e.namespace+";",e.position)},r.prototype.supports=function(e){return this.emit("@supports "+e.supports,e.position)+this.emit(" {\n"+this.indent(1))+this.mapVisit(e.rules,"\n\n")+this.emit(this.indent(-1)+"\n}")},r.prototype.keyframes=function(e){return this.emit("@"+(e.vendor||"")+"keyframes "+e.name,e.position)+this.emit(" {\n"+this.indent(1))+this.mapVisit(e.keyframes,"\n")+this.emit(this.indent(-1)+"}")},r.prototype.keyframe=function(e){var t=e.declarations;return this.emit(this.indent())+this.emit(e.values.join(", "),e.position)+this.emit(" {\n"+this.indent(1))+this.mapVisit(t,"\n")+this.emit(this.indent(-1)+"\n"+this.indent()+"}\n")},r.prototype.page=function(e){var t=e.selectors.length?e.selectors.join(", ")+" ":"";return this.emit("@page "+t,e.position)+this.emit("{\n")+this.emit(this.indent(1))+this.mapVisit(e.declarations,"\n")+this.emit(this.indent(-1))+this.emit("\n}")},r.prototype["font-face"]=function(e){return this.emit("@font-face ",e.position)+this.emit("{\n")+this.emit(this.indent(1))+this.mapVisit(e.declarations,"\n")+this.emit(this.indent(-1))+this.emit("\n}")},r.prototype.host=function(e){return this.emit("@host",e.position)+this.emit(" {\n"+this.indent(1))+this.mapVisit(e.rules,"\n\n")+this.emit(this.indent(-1)+"\n}")},r.prototype["custom-media"]=function(e){return this.emit("@custom-media "+e.name+" "+e.media+";",e.position)},r.prototype.rule=function(e){var t=this.indent(),n=e.declarations;return n.length?this.emit(e.selectors.map(function(e){return t+e}).join(",\n"),e.position)+this.emit(" {\n")+this.emit(this.indent(1))+this.mapVisit(n,"\n")+this.emit(this.indent(-1))+this.emit("\n"+this.indent()+"}"):""},r.prototype.declaration=function(e){return this.emit(this.indent())+this.emit(e.property+": "+e.value,e.position)+this.emit(";")},r.prototype.indent=function(e){return this.level=this.level||1,null!=e?(this.level+=e,""):Array(this.level).join(this.indentation||" ")}},{"./compiler":7,inherits:12}],10:[function(e,t,n){var r=e("./compress"),i=e("./identity");t.exports=function(t,n){n=n||{};var o=n.compress?new r(n):new i(n);if(n.sourcemap){var s=e("./source-map-support");s(o);var u=o.compile(t);o.applySourceMaps();var a="generator"===n.sourcemap?o.map:o.map.toJSON();return{code:u,map:a}}var u=o.compile(t);return u}},{"./compress":8,"./identity":9,"./source-map-support":11}],11:[function(e,t,n){function r(e){e._comment=e.comment,e.map=new i,e.position={line:1,column:1},e.files={};for(var t in n)e[t]=n[t]}var i=e("source-map").SourceMapGenerator,o=e("source-map").SourceMapConsumer,s=e("source-map-resolve"),u=e("urix"),a=e("fs"),c=e("path");t.exports=r,n.updatePosition=function(e){var t=e.match(/\n/g);t&&(this.position.line+=t.length);var n=e.lastIndexOf("\n");this.position.column=~n?e.length-n:this.position.column+e.length},n.emit=function(e,t){if(t){var n=u(t.source||"source.css");this.map.addMapping({source:n,generated:{line:this.position.line,column:Math.max(this.position.column-1,0)},original:{line:t.start.line,column:t.start.column-1}}),this.addFile(n,t)}return this.updatePosition(e),e},n.addFile=function(e,t){"string"==typeof t.content&&(Object.prototype.hasOwnProperty.call(this.files,e)||(this.files[e]=t.content))},n.applySourceMaps=function(){Object.keys(this.files).forEach(function(e){var t=this.files[e];if(this.map.setSourceContent(e,t),this.options.inputSourcemaps!==!1){var n=s.resolveSync(t,e,a.readFileSync);if(n){var r=new o(n.map),i=n.sourcesRelativeTo;this.map.applySourceMap(r,e,u(c.dirname(i)))}}},this)},n.comment=function(e){return/^# sourceMappingURL=/.test(e.comment)?this.emit("",e.position):this._comment(e)}},{fs:1,path:2,"source-map":16,"source-map-resolve":15,urix:27}],12:[function(e,t,n){"function"==typeof Object.create?t.exports=function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:t.exports=function(e,t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}},{}],13:[function(e,t,n){void function(e,r){"function"==typeof define&&define.amd?define(r):"object"==typeof n?t.exports=r():e.resolveUrl=r()}(this,function(){function e(){var e=arguments.length;if(0===e)throw new Error("resolveUrl requires at least one argument; got none.");var t=document.createElement("base");if(t.href=arguments[0],1===e)return t.href;var n=document.getElementsByTagName("head")[0];n.insertBefore(t,n.firstChild);for(var r,i=document.createElement("a"),o=1;o<e;o++)i.href=arguments[o],r=i.href,t.href=r;return n.removeChild(t),r}return e})},{}],14:[function(e,t,n){void function(e,r){"function"==typeof define&&define.amd?define(r):"object"==typeof n?t.exports=r():e.sourceMappingURL=r()}(this,function(){var e=/[#@] sourceMappingURL=([^\s'"]*)/,t=RegExp("(?:/\\*(?:\\s*\r?\n(?://)?)?(?:"+e.source+")\\s*\\*/|//(?:"+e.source+"))\\s*$");return{regex:t,_innerRegex:e,getFrom:function(e){var n=e.match(t);return n?n[1]||n[2]||"":null},existsIn:function(e){return t.test(e)},removeFrom:function(e){return e.replace(t,"")},insertBefore:function(e,n){var r=e.match(t);return r?e.slice(0,r.index)+n+e.slice(r.index):e+n}}})},{}],15:[function(e,t,n){void function(r,i){if("function"==typeof define&&define.amd)define(["source-map-url","resolve-url"],i);else if("object"==typeof n){var o=e("source-map-url"),s=e("resolve-url");t.exports=i(o,s)}else r.sourceMapResolve=i(r.sourceMappingURL,r.resolveUrl)}(this,function(e,t){function n(e,t,n){setImmediate(function(){e(t,n)})}function r(e){return JSON.parse(e.replace(/^\)\]\}'/,""))}function i(e,t,i,o){var u;try{u=s(e,t)}catch(a){return n(o,a)}return!u||u.map?n(o,null,u):void i(u.url,function(e,t){if(e)return o(e);try{u.map=r(String(t))}catch(e){return o(e)}o(null,u)})}function o(e,t,n){var i=s(e,t);return!i||i.map?i:(i.map=r(String(n(i.url))),i)}function s(n,i){var o=e.getFrom(n);if(!o)return null;var s=o.match(f);if(s){var u=s[1],a=s[2],c=s[3];if(!h.test(u))throw new Error("Unuseful data uri mime type: "+(u||"text/plain"));return{sourceMappingURL:o,url:null,sourcesRelativeTo:i,map:r(";base64"===a?atob(c):decodeURIComponent(c))}}var l=t(i,o);return{sourceMappingURL:o,url:l,sourcesRelativeTo:l,map:null}}function u(e,t,r,i,o){"function"==typeof i&&(o=i,i={});var s=e.sources.length,u=!1,a={sourcesResolved:[],sourcesContent:[]},l=function(e){if(!u){if(e)return u=!0,o(e);s--,0===s&&o(null,a)}};c(e,t,i,function(e,t,i){a.sourcesResolved[i]=e,"string"==typeof t?(a.sourcesContent[i]=t,n(l,null)):r(e,function(e,t){a.sourcesContent[i]=String(t),l(e)})})}function a(e,t,n,r){var i={sourcesResolved:[],sourcesContent:[]};return c(e,t,r,function(e,t,r){i.sourcesResolved[r]=e,null!==n&&("string"==typeof t?i.sourcesContent[r]=t:i.sourcesContent[r]=String(n(e)))}),i}function c(e,n,r,i){r=r||{};for(var o,s,u=0,a=e.sources.length;u<a;u++)o=e.sourceRoot&&!r.ignoreSourceRoot?t(n,e.sourceRoot.replace(m,"/"),e.sources[u]):t(n,e.sources[u]),s=(e.sourcesContent||[])[u],i(o,s,u)}function l(e,t,n,r,o){"function"==typeof r&&(o=r,r={}),i(e,t,n,function(e,t){return e?o(e):t?void u(t.map,t.sourcesRelativeTo,n,r,function(e,n){return e?o(e):(t.sourcesResolved=n.sourcesResolved,t.sourcesContent=n.sourcesContent,void o(null,t))}):o(null,null)})}function p(e,t,n,r){var i=o(e,t,n);if(!i)return null;var s=a(i.map,i.sourcesRelativeTo,n,r);return i.sourcesResolved=s.sourcesResolved,i.sourcesContent=s.sourcesContent,i}var f=/^data:([^,;]*)(;[^,;]*)*(?:,(.*))?$/,h=/^(?:application|text)\/json$/,m=/\/?$/;return{resolveSourceMap:i,resolveSourceMapSync:o,resolveSources:u,resolveSourcesSync:a,resolve:l,resolveSync:p}})},{"resolve-url":13,"source-map-url":14}],16:[function(e,t,n){n.SourceMapGenerator=e("./source-map/source-map-generator").SourceMapGenerator,n.SourceMapConsumer=e("./source-map/source-map-consumer").SourceMapConsumer,n.SourceNode=e("./source-map/source-node").SourceNode},{"./source-map/source-map-consumer":22,"./source-map/source-map-generator":23,"./source-map/source-node":24}],17:[function(e,t,n){if("function"!=typeof r)var r=e("amdefine")(t,e);r(function(e,t,n){function r(){this._array=[],this._set={}}var i=e("./util");r.fromArray=function(e,t){for(var n=new r,i=0,o=e.length;i<o;i++)n.add(e[i],t);return n},r.prototype.add=function(e,t){var n=this.has(e),r=this._array.length;n&&!t||this._array.push(e),n||(this._set[i.toSetString(e)]=r)},r.prototype.has=function(e){return Object.prototype.hasOwnProperty.call(this._set,i.toSetString(e))},r.prototype.indexOf=function(e){if(this.has(e))return this._set[i.toSetString(e)];throw new Error('"'+e+'" is not in the set.')},r.prototype.at=function(e){if(e>=0&&e<this._array.length)return this._array[e];throw new Error("No element indexed by "+e)},r.prototype.toArray=function(){return this._array.slice()},t.ArraySet=r})},{"./util":25,amdefine:26}],18:[function(e,t,n){if("function"!=typeof r)var r=e("amdefine")(t,e);r(function(e,t,n){function r(e){return e<0?(-e<<1)+1:(e<<1)+0}function i(e){var t=1===(1&e),n=e>>1;return t?-n:n}var o=e("./base64"),s=5,u=1<<s,a=u-1,c=u;t.encode=function(e){var t,n="",i=r(e);do t=i&a,i>>>=s,i>0&&(t|=c),n+=o.encode(t);while(i>0);return n},t.decode=function(e,t){var n,r,u=0,l=e.length,p=0,f=0;do{if(u>=l)throw new Error("Expected more digits in base 64 VLQ value.");r=o.decode(e.charAt(u++)),n=!!(r&c),r&=a,p+=r<<f,f+=s}while(n);t.value=i(p),t.rest=e.slice(u)}})},{"./base64":19,amdefine:26}],19:[function(e,t,n){if("function"!=typeof r)var r=e("amdefine")(t,e);r(function(e,t,n){var r={},i={};"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("").forEach(function(e,t){r[e]=t,i[t]=e}),t.encode=function(e){if(e in i)return i[e];throw new TypeError("Must be between 0 and 63: "+e)},t.decode=function(e){if(e in r)return r[e];throw new TypeError("Not a valid base 64 digit: "+e)}})},{amdefine:26}],20:[function(e,t,n){if("function"!=typeof r)var r=e("amdefine")(t,e);r(function(e,t,n){function r(e,t,n,i,o){var s=Math.floor((t-e)/2)+e,u=o(n,i[s],!0);return 0===u?s:u>0?t-s>1?r(s,t,n,i,o):s:s-e>1?r(e,s,n,i,o):e<0?-1:e}t.search=function(e,t,n){return 0===t.length?-1:r(-1,t.length,e,t,n)}})},{amdefine:26}],21:[function(e,t,n){if("function"!=typeof r)var r=e("amdefine")(t,e);r(function(e,t,n){function r(e,t){var n=e.generatedLine,r=t.generatedLine,i=e.generatedColumn,s=t.generatedColumn;return r>n||r==n&&s>=i||o.compareByGeneratedPositions(e,t)<=0}function i(){this._array=[],this._sorted=!0,this._last={generatedLine:-1,generatedColumn:0}}var o=e("./util");i.prototype.unsortedForEach=function(e,t){this._array.forEach(e,t)},i.prototype.add=function(e){r(this._last,e)?(this._last=e,this._array.push(e)):(this._sorted=!1,this._array.push(e))},i.prototype.toArray=function(){return this._sorted||(this._array.sort(o.compareByGeneratedPositions),this._sorted=!0),this._array},t.MappingList=i})},{"./util":25,amdefine:26}],22:[function(e,t,n){if("function"!=typeof r)var r=e("amdefine")(t,e);r(function(e,t,n){function r(e){var t=e;"string"==typeof e&&(t=JSON.parse(e.replace(/^\)\]\}'/,"")));var n=i.getArg(t,"version"),r=i.getArg(t,"sources"),o=i.getArg(t,"names",[]),u=i.getArg(t,"sourceRoot",null),a=i.getArg(t,"sourcesContent",null),c=i.getArg(t,"mappings"),l=i.getArg(t,"file",null);if(n!=this._version)throw new Error("Unsupported version: "+n);r=r.map(i.normalize),this._names=s.fromArray(o,!0),this._sources=s.fromArray(r,!0),this.sourceRoot=u,this.sourcesContent=a,this._mappings=c,this.file=l}var i=e("./util"),o=e("./binary-search"),s=e("./array-set").ArraySet,u=e("./base64-vlq");r.fromSourceMap=function(e){var t=Object.create(r.prototype);return t._names=s.fromArray(e._names.toArray(),!0),t._sources=s.fromArray(e._sources.toArray(),!0),t.sourceRoot=e._sourceRoot,t.sourcesContent=e._generateSourcesContent(t._sources.toArray(),t.sourceRoot),t.file=e._file,t.__generatedMappings=e._mappings.toArray().slice(),t.__originalMappings=e._mappings.toArray().slice().sort(i.compareByOriginalPositions),t},r.prototype._version=3,Object.defineProperty(r.prototype,"sources",{get:function(){return this._sources.toArray().map(function(e){return null!=this.sourceRoot?i.join(this.sourceRoot,e):e},this)}}),r.prototype.__generatedMappings=null,Object.defineProperty(r.prototype,"_generatedMappings",{get:function(){return this.__generatedMappings||(this.__generatedMappings=[],this.__originalMappings=[],this._parseMappings(this._mappings,this.sourceRoot)),this.__generatedMappings}}),r.prototype.__originalMappings=null,Object.defineProperty(r.prototype,"_originalMappings",{get:function(){return this.__originalMappings||(this.__generatedMappings=[],this.__originalMappings=[],this._parseMappings(this._mappings,this.sourceRoot)),this.__originalMappings}}),r.prototype._nextCharIsMappingSeparator=function(e){var t=e.charAt(0);return";"===t||","===t},r.prototype._parseMappings=function(e,t){for(var n,r=1,o=0,s=0,a=0,c=0,l=0,p=e,f={};p.length>0;)if(";"===p.charAt(0))r++,p=p.slice(1),o=0;else if(","===p.charAt(0))p=p.slice(1);else{if(n={},n.generatedLine=r,u.decode(p,f),n.generatedColumn=o+f.value,o=n.generatedColumn,p=f.rest,p.length>0&&!this._nextCharIsMappingSeparator(p)){if(u.decode(p,f),n.source=this._sources.at(c+f.value),c+=f.value,p=f.rest,0===p.length||this._nextCharIsMappingSeparator(p))throw new Error("Found a source, but no line and column");if(u.decode(p,f),n.originalLine=s+f.value,s=n.originalLine,n.originalLine+=1,p=f.rest,0===p.length||this._nextCharIsMappingSeparator(p))throw new Error("Found a source and line, but no column");u.decode(p,f),n.originalColumn=a+f.value,a=n.originalColumn,p=f.rest,p.length>0&&!this._nextCharIsMappingSeparator(p)&&(u.decode(p,f),n.name=this._names.at(l+f.value),l+=f.value,p=f.rest)}this.__generatedMappings.push(n),"number"==typeof n.originalLine&&this.__originalMappings.push(n)}this.__generatedMappings.sort(i.compareByGeneratedPositions),this.__originalMappings.sort(i.compareByOriginalPositions)},r.prototype._findMapping=function(e,t,n,r,i){if(e[n]<=0)throw new TypeError("Line must be greater than or equal to 1, got "+e[n]);if(e[r]<0)throw new TypeError("Column must be greater than or equal to 0, got "+e[r]);return o.search(e,t,i)},r.prototype.computeColumnSpans=function(){for(var e=0;e<this._generatedMappings.length;++e){var t=this._generatedMappings[e];if(e+1<this._generatedMappings.length){var n=this._generatedMappings[e+1];if(t.generatedLine===n.generatedLine){t.lastGeneratedColumn=n.generatedColumn-1;continue}}t.lastGeneratedColumn=1/0}},r.prototype.originalPositionFor=function(e){var t={generatedLine:i.getArg(e,"line"),generatedColumn:i.getArg(e,"column")},n=this._findMapping(t,this._generatedMappings,"generatedLine","generatedColumn",i.compareByGeneratedPositions);if(n>=0){var r=this._generatedMappings[n];if(r.generatedLine===t.generatedLine){var o=i.getArg(r,"source",null);return null!=o&&null!=this.sourceRoot&&(o=i.join(this.sourceRoot,o)),{source:o,line:i.getArg(r,"originalLine",null),column:i.getArg(r,"originalColumn",null),name:i.getArg(r,"name",null)}}}return{source:null,line:null,column:null,name:null}},r.prototype.sourceContentFor=function(e){if(!this.sourcesContent)return null;if(null!=this.sourceRoot&&(e=i.relative(this.sourceRoot,e)),this._sources.has(e))return this.sourcesContent[this._sources.indexOf(e)];var t;if(null!=this.sourceRoot&&(t=i.urlParse(this.sourceRoot))){var n=e.replace(/^file:\/\//,"");if("file"==t.scheme&&this._sources.has(n))return this.sourcesContent[this._sources.indexOf(n)];if((!t.path||"/"==t.path)&&this._sources.has("/"+e))return this.sourcesContent[this._sources.indexOf("/"+e)]}throw new Error('"'+e+'" is not in the SourceMap.')},r.prototype.generatedPositionFor=function(e){var t={source:i.getArg(e,"source"),originalLine:i.getArg(e,"line"),originalColumn:i.getArg(e,"column")};null!=this.sourceRoot&&(t.source=i.relative(this.sourceRoot,t.source));var n=this._findMapping(t,this._originalMappings,"originalLine","originalColumn",i.compareByOriginalPositions);if(n>=0){var r=this._originalMappings[n];return{line:i.getArg(r,"generatedLine",null),column:i.getArg(r,"generatedColumn",null),lastColumn:i.getArg(r,"lastGeneratedColumn",null)}}return{line:null,column:null,lastColumn:null}},r.prototype.allGeneratedPositionsFor=function(e){var t={source:i.getArg(e,"source"),originalLine:i.getArg(e,"line"),originalColumn:1/0};null!=this.sourceRoot&&(t.source=i.relative(this.sourceRoot,t.source));var n=[],r=this._findMapping(t,this._originalMappings,"originalLine","originalColumn",i.compareByOriginalPositions);if(r>=0)for(var o=this._originalMappings[r];o&&o.originalLine===t.originalLine;)n.push({line:i.getArg(o,"generatedLine",null),column:i.getArg(o,"generatedColumn",null),lastColumn:i.getArg(o,"lastGeneratedColumn",null)}),o=this._originalMappings[--r];return n.reverse()},r.GENERATED_ORDER=1,r.ORIGINAL_ORDER=2,r.prototype.eachMapping=function(e,t,n){var o,s=t||null,u=n||r.GENERATED_ORDER;switch(u){case r.GENERATED_ORDER:o=this._generatedMappings;break;case r.ORIGINAL_ORDER:o=this._originalMappings;break;default:throw new Error("Unknown order of iteration.")}var a=this.sourceRoot;o.map(function(e){var t=e.source;return null!=t&&null!=a&&(t=i.join(a,t)),{source:t,generatedLine:e.generatedLine,generatedColumn:e.generatedColumn,originalLine:e.originalLine,originalColumn:e.originalColumn,name:e.name}}).forEach(e,s)},t.SourceMapConsumer=r})},{"./array-set":17,"./base64-vlq":18,"./binary-search":20,"./util":25,amdefine:26}],23:[function(e,t,n){if("function"!=typeof r)var r=e("amdefine")(t,e);r(function(e,t,n){function r(e){e||(e={}),this._file=o.getArg(e,"file",null),this._sourceRoot=o.getArg(e,"sourceRoot",null),this._skipValidation=o.getArg(e,"skipValidation",!1),this._sources=new s,this._names=new s,this._mappings=new u,this._sourcesContents=null}var i=e("./base64-vlq"),o=e("./util"),s=e("./array-set").ArraySet,u=e("./mapping-list").MappingList;r.prototype._version=3,r.fromSourceMap=function(e){var t=e.sourceRoot,n=new r({file:e.file,sourceRoot:t});return e.eachMapping(function(e){var r={generated:{line:e.generatedLine,column:e.generatedColumn}};null!=e.source&&(r.source=e.source,null!=t&&(r.source=o.relative(t,r.source)),r.original={line:e.originalLine,column:e.originalColumn},null!=e.name&&(r.name=e.name)),n.addMapping(r)}),e.sources.forEach(function(t){var r=e.sourceContentFor(t);null!=r&&n.setSourceContent(t,r)}),n},r.prototype.addMapping=function(e){var t=o.getArg(e,"generated"),n=o.getArg(e,"original",null),r=o.getArg(e,"source",null),i=o.getArg(e,"name",null);this._skipValidation||this._validateMapping(t,n,r,i),null==r||this._sources.has(r)||this._sources.add(r),null==i||this._names.has(i)||this._names.add(i),this._mappings.add({generatedLine:t.line,generatedColumn:t.column,originalLine:null!=n&&n.line,originalColumn:null!=n&&n.column,source:r,name:i})},r.prototype.setSourceContent=function(e,t){var n=e;null!=this._sourceRoot&&(n=o.relative(this._sourceRoot,n)),null!=t?(this._sourcesContents||(this._sourcesContents={}),this._sourcesContents[o.toSetString(n)]=t):this._sourcesContents&&(delete this._sourcesContents[o.toSetString(n)],0===Object.keys(this._sourcesContents).length&&(this._sourcesContents=null))},r.prototype.applySourceMap=function(e,t,n){var r=t;if(null==t){if(null==e.file)throw new Error('SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, or the source map\'s "file" property. Both were omitted.');r=e.file}var i=this._sourceRoot;null!=i&&(r=o.relative(i,r));var u=new s,a=new s;this._mappings.unsortedForEach(function(t){if(t.source===r&&null!=t.originalLine){var s=e.originalPositionFor({line:t.originalLine,column:t.originalColumn});null!=s.source&&(t.source=s.source,null!=n&&(t.source=o.join(n,t.source)),null!=i&&(t.source=o.relative(i,t.source)),t.originalLine=s.line,
2
  t.originalColumn=s.column,null!=s.name&&(t.name=s.name))}var c=t.source;null==c||u.has(c)||u.add(c);var l=t.name;null==l||a.has(l)||a.add(l)},this),this._sources=u,this._names=a,e.sources.forEach(function(t){var r=e.sourceContentFor(t);null!=r&&(null!=n&&(t=o.join(n,t)),null!=i&&(t=o.relative(i,t)),this.setSourceContent(t,r))},this)},r.prototype._validateMapping=function(e,t,n,r){if((!(e&&"line"in e&&"column"in e&&e.line>0&&e.column>=0)||t||n||r)&&!(e&&"line"in e&&"column"in e&&t&&"line"in t&&"column"in t&&e.line>0&&e.column>=0&&t.line>0&&t.column>=0&&n))throw new Error("Invalid mapping: "+JSON.stringify({generated:e,source:n,original:t,name:r}))},r.prototype._serializeMappings=function(){for(var e,t=0,n=1,r=0,s=0,u=0,a=0,c="",l=this._mappings.toArray(),p=0,f=l.length;p<f;p++){if(e=l[p],e.generatedLine!==n)for(t=0;e.generatedLine!==n;)c+=";",n++;else if(p>0){if(!o.compareByGeneratedPositions(e,l[p-1]))continue;c+=","}c+=i.encode(e.generatedColumn-t),t=e.generatedColumn,null!=e.source&&(c+=i.encode(this._sources.indexOf(e.source)-a),a=this._sources.indexOf(e.source),c+=i.encode(e.originalLine-1-s),s=e.originalLine-1,c+=i.encode(e.originalColumn-r),r=e.originalColumn,null!=e.name&&(c+=i.encode(this._names.indexOf(e.name)-u),u=this._names.indexOf(e.name)))}return c},r.prototype._generateSourcesContent=function(e,t){return e.map(function(e){if(!this._sourcesContents)return null;null!=t&&(e=o.relative(t,e));var n=o.toSetString(e);return Object.prototype.hasOwnProperty.call(this._sourcesContents,n)?this._sourcesContents[n]:null},this)},r.prototype.toJSON=function(){var e={version:this._version,sources:this._sources.toArray(),names:this._names.toArray(),mappings:this._serializeMappings()};return null!=this._file&&(e.file=this._file),null!=this._sourceRoot&&(e.sourceRoot=this._sourceRoot),this._sourcesContents&&(e.sourcesContent=this._generateSourcesContent(e.sources,e.sourceRoot)),e},r.prototype.toString=function(){return JSON.stringify(this)},t.SourceMapGenerator=r})},{"./array-set":17,"./base64-vlq":18,"./mapping-list":21,"./util":25,amdefine:26}],24:[function(e,t,n){if("function"!=typeof r)var r=e("amdefine")(t,e);r(function(e,t,n){function r(e,t,n,r,i){this.children=[],this.sourceContents={},this.line=null==e?null:e,this.column=null==t?null:t,this.source=null==n?null:n,this.name=null==i?null:i,this[a]=!0,null!=r&&this.add(r)}var i=e("./source-map-generator").SourceMapGenerator,o=e("./util"),s=/(\r?\n)/,u=10,a="$$$isSourceNode$$$";r.fromStringWithSourceMap=function(e,t,n){function i(e,t){if(null===e||void 0===e.source)u.add(t);else{var i=n?o.join(n,e.source):e.source;u.add(new r(e.originalLine,e.originalColumn,i,t,e.name))}}var u=new r,a=e.split(s),c=function(){var e=a.shift(),t=a.shift()||"";return e+t},l=1,p=0,f=null;return t.eachMapping(function(e){if(null!==f){if(!(l<e.generatedLine)){var t=a[0],n=t.substr(0,e.generatedColumn-p);return a[0]=t.substr(e.generatedColumn-p),p=e.generatedColumn,i(f,n),void(f=e)}var n="";i(f,c()),l++,p=0}for(;l<e.generatedLine;)u.add(c()),l++;if(p<e.generatedColumn){var t=a[0];u.add(t.substr(0,e.generatedColumn)),a[0]=t.substr(e.generatedColumn),p=e.generatedColumn}f=e},this),a.length>0&&(f&&i(f,c()),u.add(a.join(""))),t.sources.forEach(function(e){var r=t.sourceContentFor(e);null!=r&&(null!=n&&(e=o.join(n,e)),u.setSourceContent(e,r))}),u},r.prototype.add=function(e){if(Array.isArray(e))e.forEach(function(e){this.add(e)},this);else{if(!e[a]&&"string"!=typeof e)throw new TypeError("Expected a SourceNode, string, or an array of SourceNodes and strings. Got "+e);e&&this.children.push(e)}return this},r.prototype.prepend=function(e){if(Array.isArray(e))for(var t=e.length-1;t>=0;t--)this.prepend(e[t]);else{if(!e[a]&&"string"!=typeof e)throw new TypeError("Expected a SourceNode, string, or an array of SourceNodes and strings. Got "+e);this.children.unshift(e)}return this},r.prototype.walk=function(e){for(var t,n=0,r=this.children.length;n<r;n++)t=this.children[n],t[a]?t.walk(e):""!==t&&e(t,{source:this.source,line:this.line,column:this.column,name:this.name})},r.prototype.join=function(e){var t,n,r=this.children.length;if(r>0){for(t=[],n=0;n<r-1;n++)t.push(this.children[n]),t.push(e);t.push(this.children[n]),this.children=t}return this},r.prototype.replaceRight=function(e,t){var n=this.children[this.children.length-1];return n[a]?n.replaceRight(e,t):"string"==typeof n?this.children[this.children.length-1]=n.replace(e,t):this.children.push("".replace(e,t)),this},r.prototype.setSourceContent=function(e,t){this.sourceContents[o.toSetString(e)]=t},r.prototype.walkSourceContents=function(e){for(var t=0,n=this.children.length;t<n;t++)this.children[t][a]&&this.children[t].walkSourceContents(e);for(var r=Object.keys(this.sourceContents),t=0,n=r.length;t<n;t++)e(o.fromSetString(r[t]),this.sourceContents[r[t]])},r.prototype.toString=function(){var e="";return this.walk(function(t){e+=t}),e},r.prototype.toStringWithSourceMap=function(e){var t={code:"",line:1,column:0},n=new i(e),r=!1,o=null,s=null,a=null,c=null;return this.walk(function(e,i){t.code+=e,null!==i.source&&null!==i.line&&null!==i.column?(o===i.source&&s===i.line&&a===i.column&&c===i.name||n.addMapping({source:i.source,original:{line:i.line,column:i.column},generated:{line:t.line,column:t.column},name:i.name}),o=i.source,s=i.line,a=i.column,c=i.name,r=!0):r&&(n.addMapping({generated:{line:t.line,column:t.column}}),o=null,r=!1);for(var l=0,p=e.length;l<p;l++)e.charCodeAt(l)===u?(t.line++,t.column=0,l+1===p?(o=null,r=!1):r&&n.addMapping({source:i.source,original:{line:i.line,column:i.column},generated:{line:t.line,column:t.column},name:i.name})):t.column++}),this.walkSourceContents(function(e,t){n.setSourceContent(e,t)}),{code:t.code,map:n}},t.SourceNode=r})},{"./source-map-generator":23,"./util":25,amdefine:26}],25:[function(e,t,n){if("function"!=typeof r)var r=e("amdefine")(t,e);r(function(e,t,n){function r(e,t,n){if(t in e)return e[t];if(3===arguments.length)return n;throw new Error('"'+t+'" is a required argument.')}function i(e){var t=e.match(m);return t?{scheme:t[1],auth:t[2],host:t[3],port:t[4],path:t[5]}:null}function o(e){var t="";return e.scheme&&(t+=e.scheme+":"),t+="//",e.auth&&(t+=e.auth+"@"),e.host&&(t+=e.host),e.port&&(t+=":"+e.port),e.path&&(t+=e.path),t}function s(e){var t=e,n=i(e);if(n){if(!n.path)return e;t=n.path}for(var r,s="/"===t.charAt(0),u=t.split(/\/+/),a=0,c=u.length-1;c>=0;c--)r=u[c],"."===r?u.splice(c,1):".."===r?a++:a>0&&(""===r?(u.splice(c+1,a),a=0):(u.splice(c,2),a--));return t=u.join("/"),""===t&&(t=s?"/":"."),n?(n.path=t,o(n)):t}function u(e,t){""===e&&(e="."),""===t&&(t=".");var n=i(t),r=i(e);if(r&&(e=r.path||"/"),n&&!n.scheme)return r&&(n.scheme=r.scheme),o(n);if(n||t.match(g))return t;if(r&&!r.host&&!r.path)return r.host=t,o(r);var u="/"===t.charAt(0)?t:s(e.replace(/\/+$/,"")+"/"+t);return r?(r.path=u,o(r)):u}function a(e,t){""===e&&(e="."),e=e.replace(/\/$/,"");var n=i(e);return"/"==t.charAt(0)&&n&&"/"==n.path?t.slice(1):0===t.indexOf(e+"/")?t.substr(e.length+1):t}function c(e){return"$"+e}function l(e){return e.substr(1)}function p(e,t){var n=e||"",r=t||"";return(n>r)-(n<r)}function f(e,t,n){var r;return(r=p(e.source,t.source))?r:(r=e.originalLine-t.originalLine)?r:(r=e.originalColumn-t.originalColumn,r||n?r:(r=p(e.name,t.name))?r:(r=e.generatedLine-t.generatedLine,r?r:e.generatedColumn-t.generatedColumn))}function h(e,t,n){var r;return(r=e.generatedLine-t.generatedLine)?r:(r=e.generatedColumn-t.generatedColumn,r||n?r:(r=p(e.source,t.source))?r:(r=e.originalLine-t.originalLine)?r:(r=e.originalColumn-t.originalColumn,r?r:p(e.name,t.name)))}t.getArg=r;var m=/^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.]*)(?::(\d+))?(\S*)$/,g=/^data:.+\,.+$/;t.urlParse=i,t.urlGenerate=o,t.normalize=s,t.join=u,t.relative=a,t.toSetString=c,t.fromSetString=l,t.compareByOriginalPositions=f,t.compareByGeneratedPositions=h})},{amdefine:26}],26:[function(e,t,n){(function(n,r){"use strict";function i(t,i){function o(e){var t,n;for(t=0;e[t];t+=1)if(n=e[t],"."===n)e.splice(t,1),t-=1;else if(".."===n){if(1===t&&(".."===e[2]||".."===e[0]))break;t>0&&(e.splice(t-1,2),t-=2)}}function s(e,t){var n;return e&&"."===e.charAt(0)&&t&&(n=t.split("/"),n=n.slice(0,n.length-1),n=n.concat(e.split("/")),o(n),e=n.join("/")),e}function u(e){return function(t){return s(t,e)}}function a(e){function t(t){m[e]=t}return t.fromText=function(e,t){throw new Error("amdefine does not implement load.fromText")},t}function c(e,n,o){var s,u,a,c;if(e)u=m[e]={},a={id:e,uri:r,exports:u},s=p(i,u,a,e);else{if(g)throw new Error("amdefine with no module ID cannot be called more than once per file.");g=!0,u=t.exports,a=t,s=p(i,u,a,t.id)}n&&(n=n.map(function(e){return s(e)})),c="function"==typeof o?o.apply(a.exports,n):o,void 0!==c&&(a.exports=c,e&&(m[e]=a.exports))}function l(e,t,n){Array.isArray(e)?(n=t,t=e,e=void 0):"string"!=typeof e&&(n=e,e=t=void 0),t&&!Array.isArray(t)&&(n=t,t=void 0),t||(t=["require","exports","module"]),e?h[e]=[e,t,n]:c(e,t,n)}var p,f,h={},m={},g=!1,d=e("path");return p=function(e,t,r,i){function o(o,s){return"string"==typeof o?f(e,t,r,o,i):(o=o.map(function(n){return f(e,t,r,n,i)}),void(s&&n.nextTick(function(){s.apply(null,o)})))}return o.toUrl=function(e){return 0===e.indexOf(".")?s(e,d.dirname(r.filename)):e},o},i=i||function(){return t.require.apply(t,arguments)},f=function(e,t,n,r,i){var o,l,g=r.indexOf("!"),d=r;if(g===-1){if(r=s(r,i),"require"===r)return p(e,t,n,i);if("exports"===r)return t;if("module"===r)return n;if(m.hasOwnProperty(r))return m[r];if(h[r])return c.apply(null,h[r]),m[r];if(e)return e(d);throw new Error("No module with ID: "+r)}return o=r.substring(0,g),r=r.substring(g+1,r.length),l=f(e,t,n,o,i),r=l.normalize?l.normalize(r,u(i)):s(r,i),m[r]?m[r]:(l.load(r,p(e,t,n,i),a(r),{}),m[r])},l.require=function(e){return m[e]?m[e]:h[e]?(c.apply(null,h[e]),m[e]):void 0},l.amd={},l}t.exports=i}).call(this,e("_process"),"/node_modules/css/node_modules/source-map/node_modules/amdefine/amdefine.js")},{_process:3,path:2}],27:[function(e,t,n){function r(e){return"\\"===i.sep?e.replace(/\\/g,"/").replace(/^[a-z]:\/?/i,"/"):e}var i=e("path");t.exports=r},{path:2}]},{},[4]);
js/csslint.js CHANGED
@@ -1,9 +1,9 @@
1
  /*!
2
- CSSLint
3
- Copyright (c) 2013 Nicole Sullivan and Nicholas C. Zakas. All rights reserved.
4
 
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
  in the Software without restriction, including without limitation the rights
8
  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
  copies of the Software, and to permit persons to whom the Software is
@@ -12,7 +12,7 @@ furnished to do so, subject to the following conditions:
12
  The above copyright notice and this permission notice shall be included in
13
  all copies or substantial portions of the Software.
14
 
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
@@ -21,12 +21,14 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
  THE SOFTWARE.
22
 
23
  */
24
- /* Build: v0.10.0 15-August-2013 01:07:22 */
25
- var exports = exports || {};
26
  var CSSLint = (function(){
 
 
 
27
  /*!
28
  Parser-Lib
29
- Copyright (c) 2009-2011 Nicholas C. Zakas. All rights reserved.
30
 
31
  Permission is hereby granted, free of charge, to any person obtaining a copy
32
  of this software and associated documentation files (the "Software"), to deal
@@ -45,6390 +47,7431 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
45
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
46
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
47
  THE SOFTWARE.
48
-
49
  */
50
- /* Version v0.2.3, Build time: 19-June-2013 11:16:15 */
51
- var parserlib = {};
52
- (function(){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
53
 
 
 
 
 
 
 
 
 
54
 
55
  /**
56
- * A generic base to inherit from for any object
57
- * that needs event handling.
58
- * @class EventTarget
 
59
  * @constructor
 
 
 
60
  */
61
- function EventTarget(){
 
 
62
 
63
  /**
64
- * The array of listeners for various events.
65
- * @type Object
66
- * @property _listeners
67
- * @private
68
  */
69
- this._listeners = {};
 
 
 
 
 
 
 
 
 
 
 
 
70
  }
71
 
72
- EventTarget.prototype = {
 
73
 
74
- //restore constructor
75
- constructor: EventTarget,
76
 
77
- /**
78
- * Adds a listener for a given event type.
79
- * @param {String} type The type of event to add a listener for.
80
- * @param {Function} listener The function to call when the event occurs.
81
- * @return {void}
82
- * @method addListener
83
- */
84
- addListener: function(type, listener){
85
- if (!this._listeners[type]){
86
- this._listeners[type] = [];
87
- }
88
 
89
- this._listeners[type].push(listener);
90
- },
91
 
92
- /**
93
- * Fires an event based on the passed-in object.
94
- * @param {Object|String} event An object with at least a 'type' attribute
95
- * or a string indicating the event name.
96
- * @return {void}
97
- * @method fire
98
- */
99
- fire: function(event){
100
- if (typeof event == "string"){
101
- event = { type: event };
102
- }
103
- if (typeof event.target != "undefined"){
104
- event.target = this;
105
- }
106
 
107
- if (typeof event.type == "undefined"){
108
- throw new Error("Event object missing 'type' property.");
 
 
 
 
 
 
 
 
 
 
 
 
 
 
109
  }
 
 
 
 
 
 
110
 
111
- if (this._listeners[event.type]){
 
 
 
 
 
 
 
112
 
113
- //create a copy of the array and use that so listeners can't chane
114
- var listeners = this._listeners[event.type].concat();
115
- for (var i=0, len=listeners.length; i < len; i++){
116
- listeners[i].call(this, event);
117
- }
 
 
 
 
118
  }
119
- },
120
-
121
- /**
122
- * Removes a listener for a given event type.
123
- * @param {String} type The type of event to remove a listener from.
124
- * @param {Function} listener The function to remove from the event.
125
- * @return {void}
126
- * @method removeListener
127
- */
128
- removeListener: function(type, listener){
129
- if (this._listeners[type]){
130
- var listeners = this._listeners[type];
131
- for (var i=0, len=listeners.length; i < len; i++){
132
- if (listeners[i] === listener){
133
- listeners.splice(i, 1);
134
- break;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
135
  }
136
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
137
 
 
 
 
 
 
 
 
 
 
 
138
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
139
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
140
  }
141
  };
 
 
 
 
 
 
 
 
 
 
142
  /**
143
- * Convenient way to read through strings.
144
- * @namespace parserlib.util
145
- * @class StringReader
 
146
  * @constructor
147
- * @param {String} text The text to read.
 
148
  */
149
- function StringReader(text){
 
 
150
 
151
  /**
152
- * The input text with line endings normalized.
153
- * @property _input
154
  * @type String
155
- * @private
156
  */
157
- this._input = text.replace(/\n\r?/g, "\n");
158
-
159
 
160
  /**
161
- * The row for the character to be read next.
162
- * @property _line
163
- * @type int
164
- * @private
165
  */
166
- this._line = 1;
 
167
 
 
 
168
 
169
- /**
170
- * The column for the character to be read next.
171
- * @property _col
172
- * @type int
173
- * @private
174
- */
175
- this._col = 1;
176
 
177
- /**
178
- * The index of the character in the input to be read next.
179
- * @property _cursor
180
- * @type int
181
- * @private
182
- */
183
- this._cursor = 0;
184
- }
185
 
186
- StringReader.prototype = {
187
 
188
- //restore constructor
189
- constructor: StringReader,
190
 
191
- //-------------------------------------------------------------------------
192
- // Position info
193
- //-------------------------------------------------------------------------
194
 
195
- /**
196
- * Returns the column of the character to be read next.
197
- * @return {int} The column of the character to be read next.
198
- * @method getCol
199
- */
200
- getCol: function(){
201
- return this._col;
202
- },
 
 
 
 
 
 
 
203
 
204
  /**
205
- * Returns the row of the character to be read next.
206
- * @return {int} The row of the character to be read next.
207
- * @method getLine
208
  */
209
- getLine: function(){
210
- return this._line ;
211
- },
212
 
213
  /**
214
- * Determines if you're at the end of the input.
215
- * @return {Boolean} True if there's no more input, false otherwise.
216
- * @method eof
217
  */
218
- eof: function(){
219
- return (this._cursor == this._input.length);
220
- },
221
-
222
- //-------------------------------------------------------------------------
223
- // Basic reading
224
- //-------------------------------------------------------------------------
225
 
226
  /**
227
- * Reads the next character without advancing the cursor.
228
- * @param {int} count How many characters to look ahead (default is 1).
229
- * @return {String} The next character or null if there is no next character.
230
- * @method peek
231
  */
232
- peek: function(count){
233
- var c = null;
234
- count = (typeof count == "undefined" ? 1 : count);
235
 
236
- //if we're not at the end of the input...
237
- if (this._cursor < this._input.length){
238
 
239
- //get character and increment cursor and column
240
- c = this._input.charAt(this._cursor + count - 1);
241
- }
242
 
243
- return c;
244
- },
245
 
246
- /**
247
- * Reads the next character from the input and adjusts the row and column
248
- * accordingly.
249
- * @return {String} The next character or null if there is no next character.
250
- * @method read
251
- */
252
- read: function(){
253
- var c = null;
254
 
255
- //if we're not at the end of the input...
256
- if (this._cursor < this._input.length){
257
 
258
- //if the last character was a newline, increment row count
259
- //and reset column count
260
- if (this._input.charAt(this._cursor) == "\n"){
261
- this._line++;
262
- this._col=1;
263
- } else {
264
- this._col++;
265
- }
266
 
267
- //get character and increment cursor and column
268
- c = this._input.charAt(this._cursor++);
269
- }
 
 
 
 
 
 
 
 
 
270
 
271
- return c;
272
- },
 
 
 
 
 
 
 
 
 
 
 
273
 
274
- //-------------------------------------------------------------------------
275
- // Misc
276
- //-------------------------------------------------------------------------
277
 
278
- /**
279
- * Saves the current location so it can be returned to later.
280
- * @method mark
281
- * @return {void}
282
- */
283
- mark: function(){
284
- this._bookmark = {
285
- cursor: this._cursor,
286
- line: this._line,
287
- col: this._col
288
- };
289
- },
290
 
291
- reset: function(){
292
- if (this._bookmark){
293
- this._cursor = this._bookmark.cursor;
294
- this._line = this._bookmark.line;
295
- this._col = this._bookmark.col;
296
- delete this._bookmark;
297
- }
298
- },
299
 
300
- //-------------------------------------------------------------------------
301
- // Advanced reading
302
- //-------------------------------------------------------------------------
303
 
304
- /**
305
- * Reads up to and including the given string. Throws an error if that
306
- * string is not found.
307
- * @param {String} pattern The string to read.
308
- * @return {String} The string when it is found.
309
- * @throws Error when the string pattern is not found.
310
- * @method readTo
311
- */
312
- readTo: function(pattern){
 
 
313
 
314
- var buffer = "",
315
- c;
316
 
317
- /*
318
- * First, buffer must be the same length as the pattern.
319
- * Then, buffer must end with the pattern or else reach the
320
- * end of the input.
321
- */
322
- while (buffer.length < pattern.length || buffer.lastIndexOf(pattern) != buffer.length - pattern.length){
323
- c = this.read();
324
- if (c){
325
- buffer += c;
326
- } else {
327
- throw new Error("Expected \"" + pattern + "\" at line " + this._line + ", col " + this._col + ".");
328
- }
329
- }
330
 
331
- return buffer;
 
332
 
333
- },
 
 
 
 
 
 
 
 
 
 
334
 
335
- /**
336
- * Reads characters while each character causes the given
337
- * filter function to return true. The function is passed
338
- * in each character and either returns true to continue
339
- * reading or false to stop.
340
- * @param {Function} filter The function to read on each character.
341
- * @return {String} The string made up of all characters that passed the
342
- * filter check.
343
- * @method readWhile
344
- */
345
- readWhile: function(filter){
346
 
347
- var buffer = "",
348
- c = this.read();
349
 
350
- while(c !== null && filter(c)){
351
- buffer += c;
352
- c = this.read();
353
- }
 
 
 
 
354
 
355
- return buffer;
 
 
 
356
 
357
- },
358
 
359
- /**
360
- * Reads characters that match either text or a regular expression and
361
- * returns those characters. If a match is found, the row and column
362
- * are adjusted; if no match is found, the reader's state is unchanged.
363
- * reading or false to stop.
364
- * @param {String|RegExp} matchter If a string, then the literal string
365
- * value is searched for. If a regular expression, then any string
366
- * matching the pattern is search for.
367
- * @return {String} The string made up of all characters that matched or
368
- * null if there was no match.
369
- * @method readMatch
370
- */
371
- readMatch: function(matcher){
372
 
373
- var source = this._input.substring(this._cursor),
374
- value = null;
375
 
376
- //if it's a string, just do a straight match
377
- if (typeof matcher == "string"){
378
- if (source.indexOf(matcher) === 0){
379
- value = this.readCount(matcher.length);
380
- }
381
- } else if (matcher instanceof RegExp){
382
- if (matcher.test(source)){
383
- value = this.readCount(RegExp.lastMatch.length);
384
- }
385
- }
386
 
387
- return value;
388
- },
 
 
 
389
 
 
 
390
 
391
- /**
392
- * Reads a given number of characters. If the end of the input is reached,
393
- * it reads only the remaining characters and does not throw an error.
394
- * @param {int} count The number of characters to read.
395
- * @return {String} The string made up the read characters.
396
- * @method readCount
397
- */
398
- readCount: function(count){
399
- var buffer = "";
400
 
401
- while(count--){
402
- buffer += this.read();
403
- }
404
 
405
- return buffer;
406
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
407
 
408
- };
409
- /**
410
- * Type to use when a syntax error occurs.
411
- * @class SyntaxError
412
- * @namespace parserlib.util
413
- * @constructor
414
- * @param {String} message The error message.
415
- * @param {int} line The line at which the error occurred.
416
- * @param {int} col The column at which the error occurred.
417
- */
418
- function SyntaxError(message, line, col){
419
 
420
- /**
421
- * The column at which the error occurred.
422
- * @type int
423
- * @property col
424
- */
425
- this.col = col;
426
 
427
- /**
428
- * The line at which the error occurred.
429
- * @type int
430
- * @property line
431
- */
432
- this.line = line;
433
 
434
- /**
435
- * The text representation of the unit.
436
- * @type String
437
- * @property text
438
- */
439
- this.message = message;
 
 
 
 
440
 
441
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
442
 
443
- //inherit from Error
444
- SyntaxError.prototype = new Error();
445
- /**
446
- * Base type to represent a single syntactic unit.
447
- * @class SyntaxUnit
448
- * @namespace parserlib.util
449
- * @constructor
450
- * @param {String} text The text of the unit.
451
- * @param {int} line The line of text on which the unit resides.
452
- * @param {int} col The column of text on which the unit resides.
453
- */
454
- function SyntaxUnit(text, line, col, type){
 
 
 
455
 
 
 
456
 
457
- /**
458
- * The column of text on which the unit resides.
459
- * @type int
460
- * @property col
461
- */
462
- this.col = col;
463
 
464
- /**
465
- * The line of text on which the unit resides.
466
- * @type int
467
- * @property line
468
- */
469
- this.line = line;
470
 
471
- /**
472
- * The text representation of the unit.
473
- * @type String
474
- * @property text
475
- */
476
- this.text = text;
477
 
478
- /**
479
- * The type of syntax unit.
480
- * @type int
481
- * @property type
482
- */
483
- this.type = type;
484
- }
485
 
486
- /**
487
- * Create a new syntax unit based solely on the given token.
488
- * Convenience method for creating a new syntax unit when
489
- * it represents a single token instead of multiple.
490
- * @param {Object} token The token object to represent.
491
- * @return {parserlib.util.SyntaxUnit} The object representing the token.
492
- * @static
493
- * @method fromToken
494
- */
495
- SyntaxUnit.fromToken = function(token){
496
- return new SyntaxUnit(token.value, token.startLine, token.startCol);
497
- };
498
 
499
- SyntaxUnit.prototype = {
 
500
 
501
- //restore constructor
502
- constructor: SyntaxUnit,
503
 
504
- /**
505
- * Returns the text representation of the unit.
506
- * @return {String} The text representation of the unit.
507
- * @method valueOf
508
- */
509
- valueOf: function(){
510
- return this.toString();
511
- },
 
 
512
 
513
- /**
514
- * Returns the text representation of the unit.
515
- * @return {String} The text representation of the unit.
516
- * @method toString
517
- */
518
- toString: function(){
519
- return this.text;
520
- }
521
 
522
- };
523
- /*global StringReader, SyntaxError*/
 
 
524
 
525
- /**
526
- * Generic TokenStream providing base functionality.
527
- * @class TokenStreamBase
528
- * @namespace parserlib.util
529
- * @constructor
530
- * @param {String|StringReader} input The text to tokenize or a reader from
531
- * which to read the input.
532
- */
533
- function TokenStreamBase(input, tokenData){
534
 
535
- /**
536
- * The string reader for easy access to the text.
537
- * @type StringReader
538
- * @property _reader
539
- * @private
540
- */
541
- this._reader = input ? new StringReader(input.toString()) : null;
542
 
543
- /**
544
- * Token object for the last consumed token.
545
- * @type Token
546
- * @property _token
547
- * @private
548
- */
549
- this._token = null;
550
 
551
- /**
552
- * The array of token information.
553
- * @type Array
554
- * @property _tokenData
555
- * @private
556
- */
557
- this._tokenData = tokenData;
558
 
559
- /**
560
- * Lookahead token buffer.
561
- * @type Array
562
- * @property _lt
563
- * @private
564
- */
565
- this._lt = [];
566
 
567
- /**
568
- * Lookahead token buffer index.
569
- * @type int
570
- * @property _ltIndex
571
- * @private
572
- */
573
- this._ltIndex = 0;
574
 
575
- this._ltIndexCache = [];
576
- }
 
 
 
 
 
 
 
577
 
578
- /**
579
- * Accepts an array of token information and outputs
580
- * an array of token data containing key-value mappings
581
- * and matching functions that the TokenStream needs.
582
- * @param {Array} tokens An array of token descriptors.
583
- * @return {Array} An array of processed token data.
584
- * @method createTokenData
585
- * @static
586
- */
587
- TokenStreamBase.createTokenData = function(tokens){
588
 
589
- var nameMap = [],
590
- typeMap = {},
591
- tokenData = tokens.concat([]),
592
- i = 0,
593
- len = tokenData.length+1;
594
 
595
- tokenData.UNKNOWN = -1;
596
- tokenData.unshift({name:"EOF"});
 
 
 
597
 
598
- for (; i < len; i++){
599
- nameMap.push(tokenData[i].name);
600
- tokenData[tokenData[i].name] = i;
601
- if (tokenData[i].text){
602
- typeMap[tokenData[i].text] = i;
603
- }
604
- }
605
 
606
- tokenData.name = function(tt){
607
- return nameMap[tt];
608
- };
 
 
609
 
610
- tokenData.type = function(c){
611
- return typeMap[c];
612
- };
 
613
 
614
- return tokenData;
615
- };
616
 
617
- TokenStreamBase.prototype = {
618
 
619
- //restore constructor
620
- constructor: TokenStreamBase,
 
621
 
622
- //-------------------------------------------------------------------------
623
- // Matching methods
624
- //-------------------------------------------------------------------------
 
 
 
 
 
 
625
 
626
- /**
627
- * Determines if the next token matches the given token type.
628
- * If so, that token is consumed; if not, the token is placed
629
- * back onto the token stream. You can pass in any number of
630
- * token types and this will return true if any of the token
631
- * types is found.
632
- * @param {int|int[]} tokenTypes Either a single token type or an array of
633
- * token types that the next token might be. If an array is passed,
634
- * it's assumed that the token can be any of these.
635
- * @param {variant} channel (Optional) The channel to read from. If not
636
- * provided, reads from the default (unnamed) channel.
637
- * @return {Boolean} True if the token type matches, false if not.
638
- * @method match
639
- */
640
- match: function(tokenTypes, channel){
641
 
642
- //always convert to an array, makes things easier
643
- if (!(tokenTypes instanceof Array)){
644
- tokenTypes = [tokenTypes];
645
- }
 
 
 
 
 
646
 
647
- var tt = this.get(channel),
648
- i = 0,
649
- len = tokenTypes.length;
650
 
651
- while(i < len){
652
- if (tt == tokenTypes[i++]){
653
- return true;
654
- }
655
- }
656
 
657
- //no match found, put the token back
658
- this.unget();
659
- return false;
660
- },
661
 
662
- /**
663
- * Determines if the next token matches the given token type.
664
- * If so, that token is consumed; if not, an error is thrown.
665
- * @param {int|int[]} tokenTypes Either a single token type or an array of
666
- * token types that the next token should be. If an array is passed,
667
- * it's assumed that the token must be one of these.
668
- * @param {variant} channel (Optional) The channel to read from. If not
669
- * provided, reads from the default (unnamed) channel.
670
- * @return {void}
671
- * @method mustMatch
672
- */
673
- mustMatch: function(tokenTypes, channel){
674
 
675
- var token;
 
 
 
 
676
 
677
- //always convert to an array, makes things easier
678
- if (!(tokenTypes instanceof Array)){
679
- tokenTypes = [tokenTypes];
680
- }
681
 
682
- if (!this.match.apply(this, arguments)){
683
- token = this.LT(1);
684
- throw new SyntaxError("Expected " + this._tokenData[tokenTypes[0]].name +
685
- " at line " + token.startLine + ", col " + token.startCol + ".", token.startLine, token.startCol);
686
- }
687
- },
 
688
 
689
- //-------------------------------------------------------------------------
690
- // Consuming methods
691
- //-------------------------------------------------------------------------
 
 
 
 
 
 
692
 
693
- /**
694
- * Keeps reading from the token stream until either one of the specified
695
- * token types is found or until the end of the input is reached.
696
- * @param {int|int[]} tokenTypes Either a single token type or an array of
697
- * token types that the next token should be. If an array is passed,
698
- * it's assumed that the token must be one of these.
699
- * @param {variant} channel (Optional) The channel to read from. If not
700
- * provided, reads from the default (unnamed) channel.
701
- * @return {void}
702
- * @method advance
703
- */
704
- advance: function(tokenTypes, channel){
705
 
706
- while(this.LA(0) !== 0 && !this.match(tokenTypes, channel)){
707
- this.get();
708
- }
 
 
 
 
 
 
709
 
710
- return this.LA(0);
711
- },
 
 
 
 
 
 
 
 
 
712
 
713
- /**
714
- * Consumes the next token from the token stream.
715
- * @return {int} The token type of the token that was just consumed.
716
- * @method get
717
- */
718
- get: function(channel){
 
 
 
719
 
720
- var tokenInfo = this._tokenData,
721
- reader = this._reader,
722
- value,
723
- i =0,
724
- len = tokenInfo.length,
725
- found = false,
726
- token,
727
- info;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
728
 
729
- //check the lookahead buffer first
730
- if (this._lt.length && this._ltIndex >= 0 && this._ltIndex < this._lt.length){
 
 
 
 
 
731
 
732
- i++;
733
- this._token = this._lt[this._ltIndex++];
734
- info = tokenInfo[this._token.type];
 
 
 
 
735
 
736
- //obey channels logic
737
- while((info.channel !== undefined && channel !== info.channel) &&
738
- this._ltIndex < this._lt.length){
739
- this._token = this._lt[this._ltIndex++];
740
- info = tokenInfo[this._token.type];
741
- i++;
742
- }
 
 
 
743
 
744
- //here be dragons
745
- if ((info.channel === undefined || channel === info.channel) &&
746
- this._ltIndex <= this._lt.length){
747
- this._ltIndexCache.push(i);
748
- return this._token.type;
749
- }
750
- }
751
 
752
- //call token retriever method
753
- token = this._getToken();
754
 
755
- //if it should be hidden, don't save a token
756
- if (token.type > -1 && !tokenInfo[token.type].hide){
757
 
758
- //apply token channel
759
- token.channel = tokenInfo[token.type].channel;
760
 
761
- //save for later
762
- this._token = token;
763
- this._lt.push(token);
 
 
 
764
 
765
- //save space that will be moved (must be done before array is truncated)
766
- this._ltIndexCache.push(this._lt.length - this._ltIndex + i);
 
 
 
 
 
 
 
 
 
 
 
 
 
767
 
768
- //keep the buffer under 5 items
769
- if (this._lt.length > 5){
770
- this._lt.shift();
771
- }
772
 
773
- //also keep the shift buffer under 5 items
774
- if (this._ltIndexCache.length > 5){
775
- this._ltIndexCache.shift();
776
- }
 
 
 
777
 
778
- //update lookahead index
779
- this._ltIndex = this._lt.length;
780
- }
781
 
782
- /*
783
- * Skip to the next token if:
784
- * 1. The token type is marked as hidden.
785
- * 2. The token type has a channel specified and it isn't the current channel.
786
- */
787
- info = tokenInfo[token.type];
788
- if (info &&
789
- (info.hide ||
790
- (info.channel !== undefined && channel !== info.channel))){
791
- return this.get(channel);
792
- } else {
793
- //return just the type
794
- return token.type;
795
- }
796
- },
797
 
798
- /**
799
- * Looks ahead a certain number of tokens and returns the token type at
800
- * that position. This will throw an error if you lookahead past the
801
- * end of input, past the size of the lookahead buffer, or back past
802
- * the first token in the lookahead buffer.
803
- * @param {int} The index of the token type to retrieve. 0 for the
804
- * current token, 1 for the next, -1 for the previous, etc.
805
- * @return {int} The token type of the token in the given position.
806
- * @method LA
807
- */
808
- LA: function(index){
809
- var total = index,
810
- tt;
811
- if (index > 0){
812
- //TODO: Store 5 somewhere
813
- if (index > 5){
814
- throw new Error("Too much lookahead.");
815
- }
816
 
817
- //get all those tokens
818
- while(total){
819
- tt = this.get();
820
- total--;
821
- }
822
 
823
- //unget all those tokens
824
- while(total < index){
825
- this.unget();
826
- total++;
827
- }
828
- } else if (index < 0){
829
 
830
- if(this._lt[this._ltIndex+index]){
831
- tt = this._lt[this._ltIndex+index].type;
832
- } else {
833
- throw new Error("Too much lookbehind.");
834
- }
835
 
836
- } else {
837
- tt = this._token.type;
838
- }
839
 
840
- return tt;
 
 
841
 
842
- },
 
 
 
 
 
 
 
 
 
 
 
 
843
 
844
- /**
845
- * Looks ahead a certain number of tokens and returns the token at
846
- * that position. This will throw an error if you lookahead past the
847
- * end of input, past the size of the lookahead buffer, or back past
848
- * the first token in the lookahead buffer.
849
- * @param {int} The index of the token type to retrieve. 0 for the
850
- * current token, 1 for the next, -1 for the previous, etc.
851
- * @return {Object} The token of the token in the given position.
852
- * @method LA
853
- */
854
- LT: function(index){
855
 
856
- //lookahead first to prime the token buffer
857
- this.LA(index);
 
 
 
 
 
 
858
 
859
- //now find the token, subtract one because _ltIndex is already at the next index
860
- return this._lt[this._ltIndex+index-1];
861
- },
862
 
863
- /**
864
- * Returns the token type for the next token in the stream without
865
- * consuming it.
866
- * @return {int} The token type of the next token in the stream.
867
- * @method peek
868
- */
869
- peek: function(){
870
- return this.LA(1);
871
- },
 
 
872
 
873
- /**
874
- * Returns the actual token object for the last consumed token.
875
- * @return {Token} The token object for the last consumed token.
876
- * @method token
877
- */
878
- token: function(){
879
- return this._token;
880
- },
881
 
882
- /**
883
- * Returns the name of the token for the given token type.
884
- * @param {int} tokenType The type of token to get the name of.
885
- * @return {String} The name of the token or "UNKNOWN_TOKEN" for any
886
- * invalid token type.
887
- * @method tokenName
888
- */
889
- tokenName: function(tokenType){
890
- if (tokenType < 0 || tokenType > this._tokenData.length){
891
- return "UNKNOWN_TOKEN";
892
- } else {
893
- return this._tokenData[tokenType].name;
894
- }
895
- },
896
 
897
- /**
898
- * Returns the token type value for the given token name.
899
- * @param {String} tokenName The name of the token whose value should be returned.
900
- * @return {int} The token type value for the given token name or -1
901
- * for an unknown token.
902
- * @method tokenName
903
- */
904
- tokenType: function(tokenName){
905
- return this._tokenData[tokenName] || -1;
906
- },
907
 
908
- /**
909
- * Returns the last consumed token to the token stream.
910
- * @method unget
911
- */
912
- unget: function(){
913
- //if (this._ltIndex > -1){
914
- if (this._ltIndexCache.length){
915
- this._ltIndex -= this._ltIndexCache.pop();//--;
916
- this._token = this._lt[this._ltIndex - 1];
917
- } else {
918
- throw new Error("Too much lookahead.");
919
- }
920
- }
921
 
922
- };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
923
 
 
924
 
 
 
925
 
 
 
 
 
 
926
 
927
- parserlib.util = {
928
- StringReader: StringReader,
929
- SyntaxError : SyntaxError,
930
- SyntaxUnit : SyntaxUnit,
931
- EventTarget : EventTarget,
932
- TokenStreamBase : TokenStreamBase
933
- };
934
- })();
935
 
 
 
936
 
937
- /*
938
- Parser-Lib
939
- Copyright (c) 2009-2011 Nicholas C. Zakas. All rights reserved.
 
 
 
 
 
940
 
941
- Permission is hereby granted, free of charge, to any person obtaining a copy
942
- of this software and associated documentation files (the "Software"), to deal
943
- in the Software without restriction, including without limitation the rights
944
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
945
- copies of the Software, and to permit persons to whom the Software is
946
- furnished to do so, subject to the following conditions:
947
 
948
- The above copyright notice and this permission notice shall be included in
949
- all copies or substantial portions of the Software.
950
 
951
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
952
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
953
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
954
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
955
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
956
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
957
- THE SOFTWARE.
958
 
959
- */
960
- /* Version v0.2.3, Build time: 19-June-2013 11:16:15 */
961
- (function(){
962
- var EventTarget = parserlib.util.EventTarget,
963
- TokenStreamBase = parserlib.util.TokenStreamBase,
964
- StringReader = parserlib.util.StringReader,
965
- SyntaxError = parserlib.util.SyntaxError,
966
- SyntaxUnit = parserlib.util.SyntaxUnit;
 
 
 
 
 
967
 
 
 
 
 
968
 
969
- var Colors = {
970
- aliceblue :"#f0f8ff",
971
- antiquewhite :"#faebd7",
972
- aqua :"#00ffff",
973
- aquamarine :"#7fffd4",
974
- azure :"#f0ffff",
975
- beige :"#f5f5dc",
976
- bisque :"#ffe4c4",
977
- black :"#000000",
978
- blanchedalmond :"#ffebcd",
979
- blue :"#0000ff",
980
- blueviolet :"#8a2be2",
981
- brown :"#a52a2a",
982
- burlywood :"#deb887",
983
- cadetblue :"#5f9ea0",
984
- chartreuse :"#7fff00",
985
- chocolate :"#d2691e",
986
- coral :"#ff7f50",
987
- cornflowerblue :"#6495ed",
988
- cornsilk :"#fff8dc",
989
- crimson :"#dc143c",
990
- cyan :"#00ffff",
991
- darkblue :"#00008b",
992
- darkcyan :"#008b8b",
993
- darkgoldenrod :"#b8860b",
994
- darkgray :"#a9a9a9",
995
- darkgreen :"#006400",
996
- darkkhaki :"#bdb76b",
997
- darkmagenta :"#8b008b",
998
- darkolivegreen :"#556b2f",
999
- darkorange :"#ff8c00",
1000
- darkorchid :"#9932cc",
1001
- darkred :"#8b0000",
1002
- darksalmon :"#e9967a",
1003
- darkseagreen :"#8fbc8f",
1004
- darkslateblue :"#483d8b",
1005
- darkslategray :"#2f4f4f",
1006
- darkturquoise :"#00ced1",
1007
- darkviolet :"#9400d3",
1008
- deeppink :"#ff1493",
1009
- deepskyblue :"#00bfff",
1010
- dimgray :"#696969",
1011
- dodgerblue :"#1e90ff",
1012
- firebrick :"#b22222",
1013
- floralwhite :"#fffaf0",
1014
- forestgreen :"#228b22",
1015
- fuchsia :"#ff00ff",
1016
- gainsboro :"#dcdcdc",
1017
- ghostwhite :"#f8f8ff",
1018
- gold :"#ffd700",
1019
- goldenrod :"#daa520",
1020
- gray :"#808080",
1021
- green :"#008000",
1022
- greenyellow :"#adff2f",
1023
- honeydew :"#f0fff0",
1024
- hotpink :"#ff69b4",
1025
- indianred :"#cd5c5c",
1026
- indigo :"#4b0082",
1027
- ivory :"#fffff0",
1028
- khaki :"#f0e68c",
1029
- lavender :"#e6e6fa",
1030
- lavenderblush :"#fff0f5",
1031
- lawngreen :"#7cfc00",
1032
- lemonchiffon :"#fffacd",
1033
- lightblue :"#add8e6",
1034
- lightcoral :"#f08080",
1035
- lightcyan :"#e0ffff",
1036
- lightgoldenrodyellow :"#fafad2",
1037
- lightgray :"#d3d3d3",
1038
- lightgreen :"#90ee90",
1039
- lightpink :"#ffb6c1",
1040
- lightsalmon :"#ffa07a",
1041
- lightseagreen :"#20b2aa",
1042
- lightskyblue :"#87cefa",
1043
- lightslategray :"#778899",
1044
- lightsteelblue :"#b0c4de",
1045
- lightyellow :"#ffffe0",
1046
- lime :"#00ff00",
1047
- limegreen :"#32cd32",
1048
- linen :"#faf0e6",
1049
- magenta :"#ff00ff",
1050
- maroon :"#800000",
1051
- mediumaquamarine:"#66cdaa",
1052
- mediumblue :"#0000cd",
1053
- mediumorchid :"#ba55d3",
1054
- mediumpurple :"#9370d8",
1055
- mediumseagreen :"#3cb371",
1056
- mediumslateblue :"#7b68ee",
1057
- mediumspringgreen :"#00fa9a",
1058
- mediumturquoise :"#48d1cc",
1059
- mediumvioletred :"#c71585",
1060
- midnightblue :"#191970",
1061
- mintcream :"#f5fffa",
1062
- mistyrose :"#ffe4e1",
1063
- moccasin :"#ffe4b5",
1064
- navajowhite :"#ffdead",
1065
- navy :"#000080",
1066
- oldlace :"#fdf5e6",
1067
- olive :"#808000",
1068
- olivedrab :"#6b8e23",
1069
- orange :"#ffa500",
1070
- orangered :"#ff4500",
1071
- orchid :"#da70d6",
1072
- palegoldenrod :"#eee8aa",
1073
- palegreen :"#98fb98",
1074
- paleturquoise :"#afeeee",
1075
- palevioletred :"#d87093",
1076
- papayawhip :"#ffefd5",
1077
- peachpuff :"#ffdab9",
1078
- peru :"#cd853f",
1079
- pink :"#ffc0cb",
1080
- plum :"#dda0dd",
1081
- powderblue :"#b0e0e6",
1082
- purple :"#800080",
1083
- red :"#ff0000",
1084
- rosybrown :"#bc8f8f",
1085
- royalblue :"#4169e1",
1086
- saddlebrown :"#8b4513",
1087
- salmon :"#fa8072",
1088
- sandybrown :"#f4a460",
1089
- seagreen :"#2e8b57",
1090
- seashell :"#fff5ee",
1091
- sienna :"#a0522d",
1092
- silver :"#c0c0c0",
1093
- skyblue :"#87ceeb",
1094
- slateblue :"#6a5acd",
1095
- slategray :"#708090",
1096
- snow :"#fffafa",
1097
- springgreen :"#00ff7f",
1098
- steelblue :"#4682b4",
1099
- tan :"#d2b48c",
1100
- teal :"#008080",
1101
- thistle :"#d8bfd8",
1102
- tomato :"#ff6347",
1103
- turquoise :"#40e0d0",
1104
- violet :"#ee82ee",
1105
- wheat :"#f5deb3",
1106
- white :"#ffffff",
1107
- whitesmoke :"#f5f5f5",
1108
- yellow :"#ffff00",
1109
- yellowgreen :"#9acd32",
1110
- //CSS2 system colors http://www.w3.org/TR/css3-color/#css2-system
1111
- activeBorder :"Active window border.",
1112
- activecaption :"Active window caption.",
1113
- appworkspace :"Background color of multiple document interface.",
1114
- background :"Desktop background.",
1115
- buttonface :"The face background color for 3-D elements that appear 3-D due to one layer of surrounding border.",
1116
- buttonhighlight :"The color of the border facing the light source for 3-D elements that appear 3-D due to one layer of surrounding border.",
1117
- buttonshadow :"The color of the border away from the light source for 3-D elements that appear 3-D due to one layer of surrounding border.",
1118
- buttontext :"Text on push buttons.",
1119
- captiontext :"Text in caption, size box, and scrollbar arrow box.",
1120
- graytext :"Grayed (disabled) text. This color is set to #000 if the current display driver does not support a solid gray color.",
1121
- highlight :"Item(s) selected in a control.",
1122
- highlighttext :"Text of item(s) selected in a control.",
1123
- inactiveborder :"Inactive window border.",
1124
- inactivecaption :"Inactive window caption.",
1125
- inactivecaptiontext :"Color of text in an inactive caption.",
1126
- infobackground :"Background color for tooltip controls.",
1127
- infotext :"Text color for tooltip controls.",
1128
- menu :"Menu background.",
1129
- menutext :"Text in menus.",
1130
- scrollbar :"Scroll bar gray area.",
1131
- threeddarkshadow :"The color of the darker (generally outer) of the two borders away from the light source for 3-D elements that appear 3-D due to two concentric layers of surrounding border.",
1132
- threedface :"The face background color for 3-D elements that appear 3-D due to two concentric layers of surrounding border.",
1133
- threedhighlight :"The color of the lighter (generally outer) of the two borders facing the light source for 3-D elements that appear 3-D due to two concentric layers of surrounding border.",
1134
- threedlightshadow :"The color of the darker (generally inner) of the two borders facing the light source for 3-D elements that appear 3-D due to two concentric layers of surrounding border.",
1135
- threedshadow :"The color of the lighter (generally inner) of the two borders away from the light source for 3-D elements that appear 3-D due to two concentric layers of surrounding border.",
1136
- window :"Window background.",
1137
- windowframe :"Window frame.",
1138
- windowtext :"Text in windows."
1139
- };
1140
- /*global SyntaxUnit, Parser*/
1141
- /**
1142
- * Represents a selector combinator (whitespace, +, >).
1143
- * @namespace parserlib.css
1144
- * @class Combinator
1145
- * @extends parserlib.util.SyntaxUnit
1146
- * @constructor
1147
- * @param {String} text The text representation of the unit.
1148
- * @param {int} line The line of text on which the unit resides.
1149
- * @param {int} col The column of text on which the unit resides.
1150
- */
1151
- function Combinator(text, line, col){
1152
 
1153
- SyntaxUnit.call(this, text, line, col, Parser.COMBINATOR_TYPE);
 
1154
 
1155
- /**
1156
- * The type of modifier.
1157
- * @type String
1158
- * @property type
1159
- */
1160
- this.type = "unknown";
1161
 
1162
- //pretty simple
1163
- if (/^\s+$/.test(text)){
1164
- this.type = "descendant";
1165
- } else if (text == ">"){
1166
- this.type = "child";
1167
- } else if (text == "+"){
1168
- this.type = "adjacent-sibling";
1169
- } else if (text == "~"){
1170
- this.type = "sibling";
1171
- }
1172
 
1173
- }
1174
 
1175
- Combinator.prototype = new SyntaxUnit();
1176
- Combinator.prototype.constructor = Combinator;
 
 
 
 
 
1177
 
 
1178
 
1179
- /*global SyntaxUnit, Parser*/
1180
- /**
1181
- * Represents a media feature, such as max-width:500.
1182
- * @namespace parserlib.css
1183
- * @class MediaFeature
1184
- * @extends parserlib.util.SyntaxUnit
1185
- * @constructor
1186
- * @param {SyntaxUnit} name The name of the feature.
1187
- * @param {SyntaxUnit} value The value of the feature or null if none.
1188
- */
1189
- function MediaFeature(name, value){
1190
 
1191
- SyntaxUnit.call(this, "(" + name + (value !== null ? ":" + value : "") + ")", name.startLine, name.startCol, Parser.MEDIA_FEATURE_TYPE);
1192
 
1193
- /**
1194
- * The name of the media feature
1195
- * @type String
1196
- * @property name
1197
- */
1198
- this.name = name;
 
 
 
 
 
1199
 
1200
- /**
1201
- * The value for the feature or null if there is none.
1202
- * @type SyntaxUnit
1203
- * @property value
1204
- */
1205
- this.value = value;
1206
- }
1207
 
1208
- MediaFeature.prototype = new SyntaxUnit();
1209
- MediaFeature.prototype.constructor = MediaFeature;
 
 
 
 
1210
 
 
1211
 
1212
- /*global SyntaxUnit, Parser*/
1213
- /**
1214
- * Represents an individual media query.
1215
- * @namespace parserlib.css
1216
- * @class MediaQuery
1217
- * @extends parserlib.util.SyntaxUnit
1218
- * @constructor
1219
- * @param {String} modifier The modifier "not" or "only" (or null).
1220
- * @param {String} mediaType The type of media (i.e., "print").
1221
- * @param {Array} parts Array of selectors parts making up this selector.
1222
- * @param {int} line The line of text on which the unit resides.
1223
- * @param {int} col The column of text on which the unit resides.
1224
- */
1225
- function MediaQuery(modifier, mediaType, features, line, col){
1226
 
1227
- SyntaxUnit.call(this, (modifier ? modifier + " ": "") + (mediaType ? mediaType : "") + (mediaType && features.length > 0 ? " and " : "") + features.join(" and "), line, col, Parser.MEDIA_QUERY_TYPE);
 
1228
 
1229
- /**
1230
- * The media modifier ("not" or "only")
1231
- * @type String
1232
- * @property modifier
1233
- */
1234
- this.modifier = modifier;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1235
 
1236
- /**
1237
- * The mediaType (i.e., "print")
1238
- * @type String
1239
- * @property mediaType
1240
- */
1241
- this.mediaType = mediaType;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1242
 
1243
- /**
1244
- * The parts that make up the selector.
1245
- * @type Array
1246
- * @property features
1247
- */
1248
- this.features = features;
1249
 
1250
- }
 
 
 
 
 
 
 
1251
 
1252
- MediaQuery.prototype = new SyntaxUnit();
1253
- MediaQuery.prototype.constructor = MediaQuery;
 
 
 
 
1254
 
 
 
1255
 
1256
- /*global Tokens, TokenStream, SyntaxError, Properties, Validation, ValidationError, SyntaxUnit,
1257
- PropertyValue, PropertyValuePart, SelectorPart, SelectorSubPart, Selector,
1258
- PropertyName, Combinator, MediaFeature, MediaQuery, EventTarget */
 
 
 
1259
 
1260
- /**
1261
- * A CSS3 parser.
1262
- * @namespace parserlib.css
1263
- * @class Parser
1264
- * @constructor
1265
- * @param {Object} options (Optional) Various options for the parser:
1266
- * starHack (true|false) to allow IE6 star hack as valid,
1267
- * underscoreHack (true|false) to interpret leading underscores
1268
- * as IE6-7 targeting for known properties, ieFilters (true|false)
1269
- * to indicate that IE < 8 filters should be accepted and not throw
1270
- * syntax errors.
1271
- */
1272
- function Parser(options){
1273
 
1274
- //inherit event functionality
1275
- EventTarget.call(this);
1276
 
 
 
 
 
 
 
 
1277
 
1278
- this.options = options || {};
 
1279
 
1280
- this._tokenStream = null;
1281
- }
 
 
 
 
1282
 
1283
- //Static constants
1284
- Parser.DEFAULT_TYPE = 0;
1285
- Parser.COMBINATOR_TYPE = 1;
1286
- Parser.MEDIA_FEATURE_TYPE = 2;
1287
- Parser.MEDIA_QUERY_TYPE = 3;
1288
- Parser.PROPERTY_NAME_TYPE = 4;
1289
- Parser.PROPERTY_VALUE_TYPE = 5;
1290
- Parser.PROPERTY_VALUE_PART_TYPE = 6;
1291
- Parser.SELECTOR_TYPE = 7;
1292
- Parser.SELECTOR_PART_TYPE = 8;
1293
- Parser.SELECTOR_SUB_PART_TYPE = 9;
1294
 
1295
- Parser.prototype = function(){
1296
 
1297
- var proto = new EventTarget(), //new prototype
1298
- prop,
1299
- additions = {
 
 
1300
 
1301
- //restore constructor
1302
- constructor: Parser,
 
1303
 
1304
- //instance constants - yuck
1305
- DEFAULT_TYPE : 0,
1306
- COMBINATOR_TYPE : 1,
1307
- MEDIA_FEATURE_TYPE : 2,
1308
- MEDIA_QUERY_TYPE : 3,
1309
- PROPERTY_NAME_TYPE : 4,
1310
- PROPERTY_VALUE_TYPE : 5,
1311
- PROPERTY_VALUE_PART_TYPE : 6,
1312
- SELECTOR_TYPE : 7,
1313
- SELECTOR_PART_TYPE : 8,
1314
- SELECTOR_SUB_PART_TYPE : 9,
1315
 
1316
- //-----------------------------------------------------------------
1317
- // Grammar
1318
- //-----------------------------------------------------------------
1319
 
1320
- _stylesheet: function(){
1321
 
1322
  /*
1323
- * stylesheet
1324
- * : [ CHARSET_SYM S* STRING S* ';' ]?
1325
- * [S|CDO|CDC]* [ import [S|CDO|CDC]* ]*
1326
- * [ namespace [S|CDO|CDC]* ]*
1327
- * [ [ ruleset | media | page | font_face | keyframes ] [S|CDO|CDC]* ]*
1328
  * ;
1329
  */
1330
 
1331
- var tokenStream = this._tokenStream,
1332
- charset = null,
1333
- count,
1334
- token,
1335
- tt;
1336
 
1337
- this.fire("startstylesheet");
 
 
 
 
 
1338
 
1339
- //try to read character set
1340
- this._charset();
1341
 
1342
- this._skipCruft();
 
 
 
 
1343
 
1344
- //try to read imports - may be more than one
1345
- while (tokenStream.peek() == Tokens.IMPORT_SYM){
1346
- this._import();
1347
- this._skipCruft();
1348
- }
 
 
1349
 
1350
- //try to read namespaces - may be more than one
1351
- while (tokenStream.peek() == Tokens.NAMESPACE_SYM){
1352
- this._namespace();
1353
- this._skipCruft();
 
 
 
1354
  }
1355
 
1356
- //get the next token
1357
- tt = tokenStream.peek();
1358
-
1359
- //try to read the rest
1360
- while(tt > Tokens.EOF){
1361
 
1362
- try {
 
 
 
 
1363
 
1364
- switch(tt){
1365
- case Tokens.MEDIA_SYM:
1366
- this._media();
1367
- this._skipCruft();
1368
- break;
1369
- case Tokens.PAGE_SYM:
1370
- this._page();
1371
- this._skipCruft();
1372
- break;
1373
- case Tokens.FONT_FACE_SYM:
1374
- this._font_face();
1375
- this._skipCruft();
1376
- break;
1377
- case Tokens.KEYFRAMES_SYM:
1378
- this._keyframes();
1379
- this._skipCruft();
1380
- break;
1381
- case Tokens.VIEWPORT_SYM:
1382
- this._viewport();
1383
- this._skipCruft();
1384
- break;
1385
- case Tokens.UNKNOWN_SYM: //unknown @ rule
1386
- tokenStream.get();
1387
- if (!this.options.strict){
1388
 
1389
- //fire error event
1390
- this.fire({
1391
- type: "error",
1392
- error: null,
1393
- message: "Unknown @ rule: " + tokenStream.LT(0).value + ".",
1394
- line: tokenStream.LT(0).startLine,
1395
- col: tokenStream.LT(0).startCol
1396
- });
1397
 
1398
- //skip braces
1399
- count=0;
1400
- while (tokenStream.advance([Tokens.LBRACE, Tokens.RBRACE]) == Tokens.LBRACE){
1401
- count++; //keep track of nesting depth
1402
- }
 
 
 
1403
 
1404
- while(count){
1405
- tokenStream.advance([Tokens.RBRACE]);
1406
- count--;
1407
- }
1408
 
1409
- } else {
1410
- //not a syntax error, rethrow it
1411
- throw new SyntaxError("Unknown @ rule.", tokenStream.LT(0).startLine, tokenStream.LT(0).startCol);
1412
- }
1413
- break;
1414
- case Tokens.S:
1415
- this._readWhitespace();
1416
- break;
1417
- default:
1418
- if(!this._ruleset()){
1419
 
1420
- //error handling for known issues
1421
- switch(tt){
1422
- case Tokens.CHARSET_SYM:
1423
- token = tokenStream.LT(1);
1424
- this._charset(false);
1425
- throw new SyntaxError("@charset not allowed here.", token.startLine, token.startCol);
1426
- case Tokens.IMPORT_SYM:
1427
- token = tokenStream.LT(1);
1428
- this._import(false);
1429
- throw new SyntaxError("@import not allowed here.", token.startLine, token.startCol);
1430
- case Tokens.NAMESPACE_SYM:
1431
- token = tokenStream.LT(1);
1432
- this._namespace(false);
1433
- throw new SyntaxError("@namespace not allowed here.", token.startLine, token.startCol);
1434
- default:
1435
- tokenStream.get(); //get the last token
1436
- this._unexpectedToken(tokenStream.token());
1437
- }
1438
 
1439
- }
1440
- }
1441
- } catch(ex) {
1442
- if (ex instanceof SyntaxError && !this.options.strict){
1443
- this.fire({
1444
- type: "error",
1445
- error: ex,
1446
- message: ex.message,
1447
- line: ex.line,
1448
- col: ex.col
1449
- });
 
 
1450
  } else {
 
1451
  throw ex;
1452
  }
1453
- }
1454
 
1455
- tt = tokenStream.peek();
1456
- }
 
 
1457
 
1458
- if (tt != Tokens.EOF){
1459
- this._unexpectedToken(tokenStream.token());
1460
  }
1461
 
1462
- this.fire("endstylesheet");
1463
- },
1464
 
1465
- _charset: function(emit){
1466
- var tokenStream = this._tokenStream,
1467
- charset,
1468
- token,
1469
- line,
1470
- col;
1471
 
1472
- if (tokenStream.match(Tokens.CHARSET_SYM)){
1473
- line = tokenStream.token().startLine;
1474
- col = tokenStream.token().startCol;
1475
 
1476
- this._readWhitespace();
1477
- tokenStream.mustMatch(Tokens.STRING);
 
 
 
 
1478
 
1479
- token = tokenStream.token();
1480
- charset = token.value;
1481
 
1482
- this._readWhitespace();
1483
- tokenStream.mustMatch(Tokens.SEMICOLON);
1484
 
1485
- if (emit !== false){
1486
- this.fire({
1487
- type: "charset",
1488
- charset:charset,
1489
- line: line,
1490
- col: col
1491
- });
1492
- }
1493
- }
1494
  },
1495
 
1496
- _import: function(emit){
 
 
1497
  /*
1498
- * import
1499
- * : IMPORT_SYM S*
1500
- * [STRING|URI] S* media_query_list? ';' S*
1501
  */
1502
-
1503
  var tokenStream = this._tokenStream,
1504
- tt,
1505
- uri,
1506
- importToken,
1507
- mediaList = [];
1508
-
1509
- //read import symbol
1510
- tokenStream.mustMatch(Tokens.IMPORT_SYM);
1511
- importToken = tokenStream.token();
1512
- this._readWhitespace();
1513
-
1514
- tokenStream.mustMatch([Tokens.STRING, Tokens.URI]);
1515
-
1516
- //grab the URI value
1517
- uri = tokenStream.token().value.replace(/(?:url\()?["']([^"']+)["']\)?/, "$1");
1518
-
1519
- this._readWhitespace();
1520
-
1521
- mediaList = this._media_query_list();
1522
 
1523
- //must end with a semicolon
1524
- tokenStream.mustMatch(Tokens.SEMICOLON);
1525
- this._readWhitespace();
1526
 
1527
- if (emit !== false){
1528
- this.fire({
1529
- type: "import",
1530
- uri: uri,
1531
- media: mediaList,
1532
- line: importToken.startLine,
1533
- col: importToken.startCol
1534
- });
 
 
1535
  }
1536
 
 
1537
  },
1538
 
1539
- _namespace: function(emit){
 
1540
  /*
1541
- * namespace
1542
- * : NAMESPACE_SYM S* [namespace_prefix S*]? [STRING|URI] S* ';' S*
 
1543
  */
1544
 
1545
  var tokenStream = this._tokenStream,
1546
- line,
1547
- col,
1548
- prefix,
1549
- uri;
1550
-
1551
- //read import symbol
1552
- tokenStream.mustMatch(Tokens.NAMESPACE_SYM);
1553
- line = tokenStream.token().startLine;
1554
- col = tokenStream.token().startCol;
1555
- this._readWhitespace();
1556
 
1557
- //it's a namespace prefix - no _namespace_prefix() method because it's just an IDENT
1558
- if (tokenStream.match(Tokens.IDENT)){
1559
- prefix = tokenStream.token().value;
1560
- this._readWhitespace();
1561
  }
1562
 
1563
- tokenStream.mustMatch([Tokens.STRING, Tokens.URI]);
1564
- /*if (!tokenStream.match(Tokens.STRING)){
1565
- tokenStream.mustMatch(Tokens.URI);
1566
- }*/
1567
 
1568
- //grab the URI value
1569
- uri = tokenStream.token().value.replace(/(?:url\()?["']([^"']+)["']\)?/, "$1");
1570
 
1571
- this._readWhitespace();
 
1572
 
1573
- //must end with a semicolon
1574
- tokenStream.mustMatch(Tokens.SEMICOLON);
1575
- this._readWhitespace();
1576
 
1577
- if (emit !== false){
1578
- this.fire({
1579
- type: "namespace",
1580
- prefix: prefix,
1581
- uri: uri,
1582
- line: line,
1583
- col: col
1584
- });
1585
- }
1586
 
1587
- },
 
 
 
1588
 
1589
- _media: function(){
1590
- /*
1591
- * media
1592
- * : MEDIA_SYM S* media_query_list S* '{' S* ruleset* '}' S*
1593
- * ;
1594
- */
1595
- var tokenStream = this._tokenStream,
1596
- line,
1597
- col,
1598
- mediaList;// = [];
1599
 
1600
- //look for @media
1601
- tokenStream.mustMatch(Tokens.MEDIA_SYM);
1602
- line = tokenStream.token().startLine;
1603
- col = tokenStream.token().startCol;
1604
 
1605
- this._readWhitespace();
 
1606
 
1607
- mediaList = this._media_query_list();
 
 
 
 
 
 
1608
 
1609
- tokenStream.mustMatch(Tokens.LBRACE);
1610
- this._readWhitespace();
 
 
 
1611
 
1612
- this.fire({
1613
- type: "startmedia",
1614
- media: mediaList,
1615
- line: line,
1616
- col: col
1617
- });
1618
 
1619
- while(true) {
1620
- if (tokenStream.peek() == Tokens.PAGE_SYM){
1621
- this._page();
1622
- } else if (tokenStream.peek() == Tokens.FONT_FACE_SYM){
1623
- this._font_face();
1624
- } else if (!this._ruleset()){
1625
- break;
1626
  }
1627
- }
1628
-
1629
- tokenStream.mustMatch(Tokens.RBRACE);
1630
- this._readWhitespace();
1631
 
1632
- this.fire({
1633
- type: "endmedia",
1634
- media: mediaList,
1635
- line: line,
1636
- col: col
1637
- });
1638
  },
1639
 
1640
-
1641
- //CSS3 Media Queries
1642
- _media_query_list: function(){
1643
  /*
1644
- * media_query_list
1645
- * : S* [media_query [ ',' S* media_query ]* ]?
 
 
1646
  * ;
1647
  */
 
1648
  var tokenStream = this._tokenStream,
1649
- mediaList = [];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1650
 
1651
 
1652
- this._readWhitespace();
 
 
1653
 
1654
- if (tokenStream.peek() == Tokens.IDENT || tokenStream.peek() == Tokens.LPAREN){
1655
- mediaList.push(this._media_query());
 
1656
  }
1657
 
1658
- while(tokenStream.match(Tokens.COMMA)){
1659
- this._readWhitespace();
1660
- mediaList.push(this._media_query());
1661
  }
1662
 
1663
- return mediaList;
1664
- },
1665
 
1666
- /*
1667
- * Note: "expression" in the grammar maps to the _media_expression
1668
- * method.
 
1669
 
1670
- */
1671
- _media_query: function(){
1672
- /*
1673
- * media_query
1674
- * : [ONLY | NOT]? S* media_type S* [ AND S* expression ]*
1675
- * | expression [ AND S* expression ]*
1676
- * ;
1677
- */
1678
- var tokenStream = this._tokenStream,
1679
- type = null,
1680
- ident = null,
1681
- token = null,
1682
- expressions = [];
1683
 
1684
- if (tokenStream.match(Tokens.IDENT)){
1685
- ident = tokenStream.token().value.toLowerCase();
1686
 
1687
- //since there's no custom tokens for these, need to manually check
1688
- if (ident != "only" && ident != "not"){
1689
- tokenStream.unget();
1690
- ident = null;
 
 
1691
  } else {
1692
- token = tokenStream.token();
 
 
 
1693
  }
1694
  }
1695
 
1696
- this._readWhitespace();
1697
 
1698
- if (tokenStream.peek() == Tokens.IDENT){
1699
- type = this._media_type();
1700
- if (token === null){
1701
- token = tokenStream.token();
1702
- }
1703
- } else if (tokenStream.peek() == Tokens.LPAREN){
1704
- if (token === null){
1705
- token = tokenStream.LT(1);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1706
  }
1707
- expressions.push(this._media_expression());
1708
- }
1709
 
1710
- if (type === null && expressions.length === 0){
1711
  return null;
1712
  } else {
1713
- this._readWhitespace();
1714
- while (tokenStream.match(Tokens.IDENT)){
1715
- if (tokenStream.token().value.toLowerCase() != "and"){
1716
- this._unexpectedToken(tokenStream.token());
1717
- }
1718
-
1719
- this._readWhitespace();
1720
- expressions.push(this._media_expression());
1721
  }
 
1722
  }
1723
-
1724
- return new MediaQuery(ident, type, expressions, token.startLine, token.startCol);
1725
  },
1726
 
1727
- //CSS3 Media Queries
1728
- _media_type: function(){
1729
  /*
1730
- * media_type
1731
- * : IDENT
1732
  * ;
1733
  */
1734
- return this._media_feature();
1735
- },
1736
 
1737
- /**
1738
- * Note: in CSS3 Media Queries, this is called "expression".
1739
- * Renamed here to avoid conflict with CSS3 Selectors
1740
- * definition of "expression". Also note that "expr" in the
1741
- * grammar now maps to "expression" from CSS3 selectors.
1742
- * @method _media_expression
1743
- * @private
1744
- */
1745
- _media_expression: function(){
1746
- /*
1747
- * expression
1748
- * : '(' S* media_feature S* [ ':' S* expr ]? ')' S*
1749
- * ;
1750
- */
1751
  var tokenStream = this._tokenStream,
1752
- feature = null,
1753
- token,
1754
- expression = null;
1755
-
1756
- tokenStream.mustMatch(Tokens.LPAREN);
1757
-
1758
- feature = this._media_feature();
1759
- this._readWhitespace();
1760
 
1761
- if (tokenStream.match(Tokens.COLON)){
1762
- this._readWhitespace();
1763
- token = tokenStream.LT(1);
1764
- expression = this._expression();
 
 
1765
  }
1766
 
1767
- tokenStream.mustMatch(Tokens.RPAREN);
1768
- this._readWhitespace();
1769
-
1770
- return new MediaFeature(feature, (expression ? new SyntaxUnit(expression, token.startLine, token.startCol) : null));
1771
  },
1772
 
1773
- //CSS3 Media Queries
1774
- _media_feature: function(){
1775
  /*
1776
- * media_feature
1777
  * : IDENT
1778
  * ;
1779
  */
1780
- var tokenStream = this._tokenStream;
1781
-
1782
- tokenStream.mustMatch(Tokens.IDENT);
1783
-
1784
- return SyntaxUnit.fromToken(tokenStream.token());
1785
- },
1786
 
1787
- //CSS3 Paged Media
1788
- _page: function(){
1789
- /*
1790
- * page:
1791
- * PAGE_SYM S* IDENT? pseudo_page? S*
1792
- * '{' S* [ declaration | margin ]? [ ';' S* [ declaration | margin ]? ]* '}' S*
1793
- * ;
1794
- */
1795
  var tokenStream = this._tokenStream,
1796
- line,
1797
- col,
1798
- identifier = null,
1799
- pseudoPage = null;
1800
-
1801
- //look for @page
1802
- tokenStream.mustMatch(Tokens.PAGE_SYM);
1803
- line = tokenStream.token().startLine;
1804
- col = tokenStream.token().startCol;
1805
-
1806
- this._readWhitespace();
1807
-
1808
- if (tokenStream.match(Tokens.IDENT)){
1809
- identifier = tokenStream.token().value;
1810
 
1811
- //The value 'auto' may not be used as a page name and MUST be treated as a syntax error.
1812
- if (identifier.toLowerCase() === "auto"){
1813
- this._unexpectedToken(tokenStream.token());
1814
- }
1815
- }
1816
 
1817
- //see if there's a colon upcoming
1818
- if (tokenStream.peek() == Tokens.COLON){
1819
- pseudoPage = this._pseudo_page();
1820
  }
1821
-
1822
- this._readWhitespace();
1823
-
1824
- this.fire({
1825
- type: "startpage",
1826
- id: identifier,
1827
- pseudo: pseudoPage,
1828
- line: line,
1829
- col: col
1830
- });
1831
-
1832
- this._readDeclarations(true, true);
1833
-
1834
- this.fire({
1835
- type: "endpage",
1836
- id: identifier,
1837
- pseudo: pseudoPage,
1838
- line: line,
1839
- col: col
1840
- });
1841
-
1842
  },
1843
 
1844
- //CSS3 Paged Media
1845
- _margin: function(){
1846
  /*
1847
- * margin :
1848
- * margin_sym S* '{' declaration [ ';' S* declaration? ]* '}' S*
1849
- * ;
1850
  */
1851
  var tokenStream = this._tokenStream,
1852
- line,
1853
- col,
1854
- marginSym = this._margin_sym();
1855
-
1856
- if (marginSym){
1857
- line = tokenStream.token().startLine;
1858
- col = tokenStream.token().startCol;
1859
-
1860
- this.fire({
1861
- type: "startpagemargin",
1862
- margin: marginSym,
1863
- line: line,
1864
- col: col
1865
- });
1866
-
1867
- this._readDeclarations(true);
1868
-
1869
- this.fire({
1870
- type: "endpagemargin",
1871
- margin: marginSym,
1872
- line: line,
1873
- col: col
1874
- });
1875
- return true;
1876
- } else {
1877
- return false;
1878
- }
1879
- },
1880
 
1881
- //CSS3 Paged Media
1882
- _margin_sym: function(){
1883
 
1884
- /*
1885
- * margin_sym :
1886
- * TOPLEFTCORNER_SYM |
1887
- * TOPLEFT_SYM |
1888
- * TOPCENTER_SYM |
1889
- * TOPRIGHT_SYM |
1890
- * TOPRIGHTCORNER_SYM |
1891
- * BOTTOMLEFTCORNER_SYM |
1892
- * BOTTOMLEFT_SYM |
1893
- * BOTTOMCENTER_SYM |
1894
- * BOTTOMRIGHT_SYM |
1895
- * BOTTOMRIGHTCORNER_SYM |
1896
- * LEFTTOP_SYM |
1897
- * LEFTMIDDLE_SYM |
1898
- * LEFTBOTTOM_SYM |
1899
- * RIGHTTOP_SYM |
1900
- * RIGHTMIDDLE_SYM |
1901
- * RIGHTBOTTOM_SYM
1902
- * ;
1903
- */
1904
 
1905
- var tokenStream = this._tokenStream;
 
1906
 
1907
- if(tokenStream.match([Tokens.TOPLEFTCORNER_SYM, Tokens.TOPLEFT_SYM,
1908
- Tokens.TOPCENTER_SYM, Tokens.TOPRIGHT_SYM, Tokens.TOPRIGHTCORNER_SYM,
1909
- Tokens.BOTTOMLEFTCORNER_SYM, Tokens.BOTTOMLEFT_SYM,
1910
- Tokens.BOTTOMCENTER_SYM, Tokens.BOTTOMRIGHT_SYM,
1911
- Tokens.BOTTOMRIGHTCORNER_SYM, Tokens.LEFTTOP_SYM,
1912
- Tokens.LEFTMIDDLE_SYM, Tokens.LEFTBOTTOM_SYM, Tokens.RIGHTTOP_SYM,
1913
- Tokens.RIGHTMIDDLE_SYM, Tokens.RIGHTBOTTOM_SYM]))
1914
- {
1915
- return SyntaxUnit.fromToken(tokenStream.token());
1916
- } else {
1917
- return null;
1918
  }
1919
 
 
1920
  },
1921
 
1922
- _pseudo_page: function(){
 
1923
  /*
1924
- * pseudo_page
1925
- * : ':' IDENT
1926
  * ;
1927
  */
 
 
 
1928
 
1929
- var tokenStream = this._tokenStream;
 
 
 
1930
 
1931
- tokenStream.mustMatch(Tokens.COLON);
1932
- tokenStream.mustMatch(Tokens.IDENT);
 
1933
 
1934
- //TODO: CSS3 Paged Media says only "left", "center", and "right" are allowed
1935
 
1936
- return tokenStream.token().value;
1937
  },
1938
 
1939
- _font_face: function(){
 
1940
  /*
1941
- * font_face
1942
- * : FONT_FACE_SYM S*
1943
- * '{' S* declaration [ ';' S* declaration ]* '}' S*
 
 
 
 
 
 
1944
  * ;
1945
  */
 
1946
  var tokenStream = this._tokenStream,
1947
- line,
1948
- col;
 
1949
 
1950
- //look for @page
1951
- tokenStream.mustMatch(Tokens.FONT_FACE_SYM);
1952
- line = tokenStream.token().startLine;
1953
- col = tokenStream.token().startCol;
1954
 
1955
- this._readWhitespace();
1956
 
1957
- this.fire({
1958
- type: "startfontface",
1959
- line: line,
1960
- col: col
1961
- });
1962
 
1963
- this._readDeclarations(true);
 
 
1964
 
1965
- this.fire({
1966
- type: "endfontface",
1967
- line: line,
1968
- col: col
1969
- });
 
 
 
 
 
 
 
 
 
 
 
 
1970
  },
1971
 
1972
- _viewport: function(){
 
 
1973
  /*
1974
- * viewport
1975
- * : VIEWPORT_SYM S*
1976
- * '{' S* declaration? [ ';' S* declaration? ]* '}' S*
1977
  * ;
1978
  */
1979
- var tokenStream = this._tokenStream,
 
 
 
1980
  line,
1981
  col;
1982
 
1983
- tokenStream.mustMatch(Tokens.VIEWPORT_SYM);
1984
- line = tokenStream.token().startLine;
1985
- col = tokenStream.token().startCol;
1986
-
1987
- this._readWhitespace();
1988
 
1989
- this.fire({
1990
- type: "startviewport",
1991
- line: line,
1992
- col: col
1993
- });
1994
 
1995
- this._readDeclarations(true);
 
 
 
 
 
 
 
 
1996
 
1997
- this.fire({
1998
- type: "endviewport",
1999
- line: line,
2000
- col: col
2001
- });
 
 
 
2002
 
 
2003
  },
2004
 
2005
- _operator: function(inFunction){
2006
-
2007
  /*
2008
- * operator (outside function)
2009
- * : '/' S* | ',' S* | /( empty )/
2010
- * operator (inside function)
2011
- * : '/' S* | '+' S* | '*' S* | '-' S* /( empty )/
2012
- * ;
2013
- */
2014
 
2015
  var tokenStream = this._tokenStream,
2016
- token = null;
2017
 
2018
- if (tokenStream.match([Tokens.SLASH, Tokens.COMMA]) ||
2019
- (inFunction && tokenStream.match([Tokens.PLUS, Tokens.STAR, Tokens.MINUS]))){
2020
- token = tokenStream.token();
2021
- this._readWhitespace();
 
 
2022
  }
2023
- return token ? PropertyValuePart.fromToken(token) : null;
2024
 
 
2025
  },
2026
 
2027
- _combinator: function(){
2028
-
2029
  /*
2030
- * combinator
2031
- * : PLUS S* | GREATER S* | TILDE S* | S+
2032
- * ;
2033
  */
2034
 
2035
  var tokenStream = this._tokenStream,
2036
- value = null,
2037
- token;
2038
 
2039
- if(tokenStream.match([Tokens.PLUS, Tokens.GREATER, Tokens.TILDE])){
2040
- token = tokenStream.token();
2041
- value = new Combinator(token.value, token.startLine, token.startCol);
2042
- this._readWhitespace();
 
 
 
2043
  }
2044
 
2045
- return value;
2046
- },
2047
 
2048
- _unary_operator: function(){
2049
 
 
 
2050
  /*
2051
- * unary_operator
2052
- * : '-' | '+'
2053
- * ;
2054
  */
2055
 
2056
- var tokenStream = this._tokenStream;
 
 
 
 
 
2057
 
2058
- if (tokenStream.match([Tokens.MINUS, Tokens.PLUS])){
2059
- return tokenStream.token().value;
2060
- } else {
2061
- return null;
 
 
 
 
 
 
 
 
 
2062
  }
2063
- },
2064
 
2065
- _property: function(){
 
2066
 
 
 
2067
  /*
2068
- * property
2069
- * : IDENT S*
2070
  * ;
2071
  */
2072
 
2073
  var tokenStream = this._tokenStream,
2074
- value = null,
2075
- hack = null,
2076
- tokenValue,
2077
- token,
 
 
 
 
 
 
 
 
 
 
 
2078
  line,
2079
- col;
 
2080
 
2081
- //check for star hack - throws error if not allowed
2082
- if (tokenStream.peek() == Tokens.STAR && this.options.starHack){
2083
- tokenStream.get();
2084
- token = tokenStream.token();
2085
- hack = token.value;
2086
- line = token.startLine;
2087
- col = token.startCol;
2088
- }
2089
 
2090
- if(tokenStream.match(Tokens.IDENT)){
2091
- token = tokenStream.token();
2092
- tokenValue = token.value;
2093
 
2094
- //check for underscore hack - no error if not allowed because it's valid CSS syntax
2095
- if (tokenValue.charAt(0) == "_" && this.options.underscoreHack){
2096
- hack = "_";
2097
- tokenValue = tokenValue.substring(1);
2098
- }
 
 
 
2099
 
2100
- value = new PropertyName(tokenValue, hack, (line||token.startLine), (col||token.startCol));
2101
- this._readWhitespace();
 
 
 
2102
  }
2103
 
2104
- return value;
2105
  },
2106
 
2107
- //Augmented with CSS3 Selectors
2108
- _ruleset: function(){
2109
  /*
2110
- * ruleset
2111
- * : selectors_group
2112
- * '{' S* declaration? [ ';' S* declaration? ]* '}' S*
2113
  * ;
2114
  */
2115
 
2116
  var tokenStream = this._tokenStream,
2117
- tt,
2118
- selectors;
2119
-
 
 
2120
 
2121
- /*
2122
- * Error Recovery: If even a single selector fails to parse,
2123
- * then the entire ruleset should be thrown away.
2124
- */
2125
- try {
2126
- selectors = this._selectors_group();
2127
- } catch (ex){
2128
- if (ex instanceof SyntaxError && !this.options.strict){
2129
 
2130
- //fire error event
2131
- this.fire({
2132
- type: "error",
2133
- error: ex,
2134
- message: ex.message,
2135
- line: ex.line,
2136
- col: ex.col
2137
- });
2138
 
2139
- //skip over everything until closing brace
2140
- tt = tokenStream.advance([Tokens.RBRACE]);
2141
- if (tt == Tokens.RBRACE){
2142
- //if there's a right brace, the rule is finished so don't do anything
2143
- } else {
2144
- //otherwise, rethrow the error because it wasn't handled properly
2145
- throw ex;
2146
- }
2147
 
2148
- } else {
2149
- //not a syntax error, rethrow it
2150
- throw ex;
2151
  }
2152
 
2153
- //trigger parser to continue
2154
- return true;
2155
- }
2156
 
2157
- //if it got here, all selectors parsed
2158
- if (selectors){
 
 
 
 
 
 
2159
 
2160
- this.fire({
2161
- type: "startrule",
2162
- selectors: selectors,
2163
- line: selectors[0].line,
2164
- col: selectors[0].col
2165
- });
2166
 
2167
- this._readDeclarations(true);
 
 
 
 
2168
 
2169
  this.fire({
2170
- type: "endrule",
2171
- selectors: selectors,
2172
- line: selectors[0].line,
2173
- col: selectors[0].col
 
 
 
2174
  });
2175
 
 
 
 
2176
  }
2177
-
2178
- return selectors;
2179
-
2180
  },
2181
 
2182
- //CSS3 Selectors
2183
- _selectors_group: function(){
2184
-
2185
  /*
2186
- * selectors_group
2187
- * : selector [ COMMA S* selector ]*
2188
  * ;
2189
  */
2190
- var tokenStream = this._tokenStream,
2191
- selectors = [],
2192
- selector;
2193
-
2194
- selector = this._selector();
2195
- if (selector !== null){
2196
 
2197
- selectors.push(selector);
2198
- while(tokenStream.match(Tokens.COMMA)){
2199
- this._readWhitespace();
2200
- selector = this._selector();
2201
- if (selector !== null){
2202
- selectors.push(selector);
2203
- } else {
2204
- this._unexpectedToken(tokenStream.LT(1));
2205
- }
2206
- }
2207
- }
2208
 
2209
- return selectors.length ? selectors : null;
 
2210
  },
2211
 
2212
- //CSS3 Selectors
2213
- _selector: function(){
2214
  /*
2215
- * selector
2216
- * : simple_selector_sequence [ combinator simple_selector_sequence ]*
2217
  * ;
2218
  */
2219
 
2220
- var tokenStream = this._tokenStream,
2221
- selector = [],
2222
- nextSelector = null,
2223
- combinator = null,
2224
- ws = null;
2225
-
2226
- //if there's no simple selector, then there's no selector
2227
- nextSelector = this._simple_selector_sequence();
2228
- if (nextSelector === null){
2229
- return null;
2230
- }
2231
-
2232
- selector.push(nextSelector);
2233
-
2234
- do {
2235
-
2236
- //look for a combinator
2237
- combinator = this._combinator();
2238
-
2239
- if (combinator !== null){
2240
- selector.push(combinator);
2241
- nextSelector = this._simple_selector_sequence();
2242
-
2243
- //there must be a next selector
2244
- if (nextSelector === null){
2245
- this._unexpectedToken(tokenStream.LT(1));
2246
- } else {
2247
-
2248
- //nextSelector is an instance of SelectorPart
2249
- selector.push(nextSelector);
2250
- }
2251
- } else {
2252
 
2253
- //if there's not whitespace, we're done
2254
- if (this._readWhitespace()){
2255
 
2256
- //add whitespace separator
2257
- ws = new Combinator(tokenStream.token().value, tokenStream.token().startLine, tokenStream.token().startCol);
2258
 
2259
- //combinator is not required
2260
- combinator = this._combinator();
2261
 
2262
- //selector is required if there's a combinator
2263
- nextSelector = this._simple_selector_sequence();
2264
- if (nextSelector === null){
2265
- if (combinator !== null){
2266
- this._unexpectedToken(tokenStream.LT(1));
2267
- }
2268
- } else {
 
2269
 
2270
- if (combinator !== null){
2271
- selector.push(combinator);
2272
- } else {
2273
- selector.push(ws);
2274
- }
2275
 
2276
- selector.push(nextSelector);
2277
- }
2278
- } else {
2279
  break;
 
 
2280
  }
 
 
2281
 
2282
- }
2283
- } while(true);
 
 
2284
 
2285
- return new Selector(selector, selector[0].line, selector[0].col);
2286
  },
2287
 
2288
- //CSS3 Selectors
2289
- _simple_selector_sequence: function(){
2290
  /*
2291
- * simple_selector_sequence
2292
- * : [ type_selector | universal ]
2293
- * [ HASH | class | attrib | pseudo | negation ]*
2294
- * | [ HASH | class | attrib | pseudo | negation ]+
 
2295
  * ;
2296
  */
2297
 
2298
  var tokenStream = this._tokenStream,
 
 
 
 
 
 
 
2299
 
2300
- //parts of a simple selector
2301
- elementName = null,
2302
- modifiers = [],
 
 
 
2303
 
2304
- //complete selector text
2305
- selectorText= "",
2306
 
2307
- //the different parts after the element name to search for
2308
- components = [
2309
- //HASH
2310
- function(){
2311
- return tokenStream.match(Tokens.HASH) ?
2312
- new SelectorSubPart(tokenStream.token().value, "id", tokenStream.token().startLine, tokenStream.token().startCol) :
2313
- null;
2314
- },
2315
- this._class,
2316
- this._attrib,
2317
- this._pseudo,
2318
- this._negation
2319
- ],
2320
- i = 0,
2321
- len = components.length,
2322
- component = null,
2323
- found = false,
2324
- line,
2325
- col;
2326
 
 
 
2327
 
2328
- //get starting line and column for the selector
2329
- line = tokenStream.LT(1).startLine;
2330
- col = tokenStream.LT(1).startCol;
 
 
 
 
 
 
 
2331
 
2332
- elementName = this._type_selector();
2333
- if (!elementName){
2334
- elementName = this._universal();
2335
- }
2336
 
2337
- if (elementName !== null){
2338
- selectorText += elementName;
2339
- }
 
 
 
 
 
 
 
2340
 
2341
- while(true){
 
 
2342
 
2343
- //whitespace means we're done
2344
- if (tokenStream.peek() === Tokens.S){
2345
- break;
2346
- }
 
2347
 
2348
- //check for each component
2349
- while(i < len && component === null){
2350
- component = components[i++].call(this);
2351
- }
2352
 
2353
- if (component === null){
 
 
 
 
 
 
 
 
 
2354
 
2355
- //we don't have a selector
2356
- if (selectorText === ""){
2357
  return null;
2358
- } else {
2359
- break;
2360
- }
2361
  } else {
2362
- i = 0;
2363
- modifiers.push(component);
2364
- selectorText += component.toString();
2365
- component = null;
 
2366
  }
2367
- }
2368
 
 
2369
 
2370
- return selectorText !== "" ?
2371
- new SelectorPart(elementName, modifiers, selectorText, line, col) :
2372
  null;
 
2373
  },
2374
 
2375
- //CSS3 Selectors
2376
- _type_selector: function(){
2377
  /*
2378
- * type_selector
2379
- * : [ namespace_prefix ]? element_name
2380
  * ;
2381
  */
2382
 
2383
  var tokenStream = this._tokenStream,
2384
- ns = this._namespace_prefix(),
2385
- elementName = this._element_name();
 
2386
 
2387
- if (!elementName){
2388
- /*
2389
- * Need to back out the namespace that was read due to both
2390
- * type_selector and universal reading namespace_prefix
2391
- * first. Kind of hacky, but only way I can figure out
2392
- * right now how to not change the grammar.
2393
- */
2394
- if (ns){
2395
- tokenStream.unget();
2396
- if (ns.length > 1){
2397
- tokenStream.unget();
2398
- }
2399
- }
2400
 
2401
- return null;
2402
- } else {
2403
- if (ns){
2404
- elementName.text = ns + elementName.text;
2405
- elementName.col -= ns.length;
2406
- }
2407
- return elementName;
2408
- }
2409
- },
2410
 
2411
- //CSS3 Selectors
2412
- _class: function(){
2413
- /*
2414
- * class
2415
- * : '.' IDENT
2416
- * ;
2417
- */
2418
 
2419
- var tokenStream = this._tokenStream,
2420
- token;
 
 
2421
 
2422
- if (tokenStream.match(Tokens.DOT)){
2423
- tokenStream.mustMatch(Tokens.IDENT);
2424
- token = tokenStream.token();
2425
- return new SelectorSubPart("." + token.value, "class", token.startLine, token.startCol - 1);
2426
- } else {
2427
- return null;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2428
  }
2429
 
 
2430
  },
2431
 
2432
- //CSS3 Selectors
2433
- _element_name: function(){
2434
- /*
2435
- * element_name
2436
- * : IDENT
2437
  * ;
2438
  */
2439
 
2440
  var tokenStream = this._tokenStream,
2441
- token;
 
2442
 
2443
- if (tokenStream.match(Tokens.IDENT)){
2444
- token = tokenStream.token();
2445
- return new SelectorSubPart(token.value, "elementName", token.startLine, token.startCol);
2446
 
2447
- } else {
2448
- return null;
2449
- }
2450
- },
2451
 
2452
- //CSS3 Selectors
2453
- _namespace_prefix: function(){
2454
- /*
2455
- * namespace_prefix
2456
- * : [ IDENT | '*' ]? '|'
2457
- * ;
2458
- */
2459
- var tokenStream = this._tokenStream,
2460
- value = "";
2461
 
2462
- //verify that this is a namespace prefix
2463
- if (tokenStream.LA(1) === Tokens.PIPE || tokenStream.LA(2) === Tokens.PIPE){
 
 
2464
 
2465
- if(tokenStream.match([Tokens.IDENT, Tokens.STAR])){
2466
- value += tokenStream.token().value;
2467
- }
2468
 
2469
- tokenStream.mustMatch(Tokens.PIPE);
2470
- value += "|";
 
 
 
 
 
 
 
 
 
2471
 
 
 
 
2472
  }
2473
 
2474
- return value.length ? value : null;
2475
  },
2476
 
2477
- //CSS3 Selectors
2478
- _universal: function(){
2479
  /*
2480
- * universal
2481
- * : [ namespace_prefix ]? '*'
 
 
 
 
2482
  * ;
2483
  */
 
2484
  var tokenStream = this._tokenStream,
2485
- value = "",
2486
- ns;
2487
 
2488
- ns = this._namespace_prefix();
2489
- if(ns){
2490
- value += ns;
2491
- }
2492
 
2493
- if(tokenStream.match(Tokens.STAR)){
2494
- value += "*";
 
 
 
 
 
 
2495
  }
2496
 
2497
- return value.length ? value : null;
 
 
 
 
 
2498
 
2499
- },
2500
 
2501
- //CSS3 Selectors
2502
- _attrib: function(){
2503
  /*
2504
- * attrib
2505
- * : '[' S* [ namespace_prefix ]? IDENT S*
2506
- * [ [ PREFIXMATCH |
2507
- * SUFFIXMATCH |
2508
- * SUBSTRINGMATCH |
2509
- * '=' |
2510
- * INCLUDES |
2511
- * DASHMATCH ] S* [ IDENT | STRING ] S*
2512
- * ]? ']'
2513
  * ;
2514
  */
2515
-
2516
  var tokenStream = this._tokenStream,
2517
- value = null,
2518
- ns,
2519
- token;
 
2520
 
2521
- if (tokenStream.match(Tokens.LBRACKET)){
2522
- token = tokenStream.token();
2523
- value = token.value;
2524
- value += this._readWhitespace();
 
2525
 
2526
- ns = this._namespace_prefix();
 
2527
 
2528
- if (ns){
2529
- value += ns;
2530
- }
2531
 
2532
- tokenStream.mustMatch(Tokens.IDENT);
2533
- value += tokenStream.token().value;
2534
- value += this._readWhitespace();
 
 
 
 
2535
 
2536
- if(tokenStream.match([Tokens.PREFIXMATCH, Tokens.SUFFIXMATCH, Tokens.SUBSTRINGMATCH,
2537
- Tokens.EQUALS, Tokens.INCLUDES, Tokens.DASHMATCH])){
2538
 
2539
- value += tokenStream.token().value;
2540
- value += this._readWhitespace();
 
 
 
 
2541
 
2542
- tokenStream.mustMatch([Tokens.IDENT, Tokens.STRING]);
2543
- value += tokenStream.token().value;
2544
- value += this._readWhitespace();
2545
- }
 
 
 
2546
 
2547
- tokenStream.mustMatch(Tokens.RBRACKET);
 
 
2548
 
2549
- return new SelectorSubPart(value + "]", "attribute", token.startLine, token.startCol);
2550
- } else {
2551
- return null;
2552
- }
2553
  },
2554
 
2555
- //CSS3 Selectors
2556
- _pseudo: function(){
2557
 
2558
  /*
2559
- * pseudo
2560
- * : ':' ':'? [ IDENT | functional_pseudo ]
 
2561
  * ;
2562
  */
 
2563
 
2564
- var tokenStream = this._tokenStream,
2565
- pseudo = null,
2566
- colons = ":",
2567
- line,
2568
- col;
2569
-
2570
- if (tokenStream.match(Tokens.COLON)){
2571
-
2572
- if (tokenStream.match(Tokens.COLON)){
2573
- colons += ":";
2574
- }
2575
-
2576
- if (tokenStream.match(Tokens.IDENT)){
2577
- pseudo = tokenStream.token().value;
2578
- line = tokenStream.token().startLine;
2579
- col = tokenStream.token().startCol - colons.length;
2580
- } else if (tokenStream.peek() == Tokens.FUNCTION){
2581
- line = tokenStream.LT(1).startLine;
2582
- col = tokenStream.LT(1).startCol - colons.length;
2583
- pseudo = this._functional_pseudo();
2584
- }
2585
-
2586
- if (pseudo){
2587
- pseudo = new SelectorSubPart(colons + pseudo, "pseudo", line, col);
2588
- }
2589
- }
2590
-
2591
- return pseudo;
2592
  },
2593
 
2594
- //CSS3 Selectors
2595
- _functional_pseudo: function(){
2596
  /*
2597
- * functional_pseudo
2598
- * : FUNCTION S* expression ')'
 
2599
  * ;
2600
- */
 
2601
 
2602
- var tokenStream = this._tokenStream,
2603
- value = null;
 
 
 
 
2604
 
2605
- if(tokenStream.match(Tokens.FUNCTION)){
2606
- value = tokenStream.token().value;
2607
- value += this._readWhitespace();
2608
- value += this._expression();
2609
- tokenStream.mustMatch(Tokens.RPAREN);
2610
- value += ")";
2611
- }
 
2612
 
2613
- return value;
2614
  },
2615
 
2616
- //CSS3 Selectors
2617
- _expression: function(){
2618
  /*
2619
- * expression
2620
- * : [ [ PLUS | '-' | DIMENSION | NUMBER | STRING | IDENT ] S* ]+
2621
  * ;
2622
  */
2623
-
2624
  var tokenStream = this._tokenStream,
2625
- value = "";
2626
 
2627
- while(tokenStream.match([Tokens.PLUS, Tokens.MINUS, Tokens.DIMENSION,
2628
- Tokens.NUMBER, Tokens.STRING, Tokens.IDENT, Tokens.LENGTH,
2629
- Tokens.FREQ, Tokens.ANGLE, Tokens.TIME,
2630
- Tokens.RESOLUTION, Tokens.SLASH])){
2631
 
2632
- value += tokenStream.token().value;
2633
- value += this._readWhitespace();
2634
- }
2635
 
2636
- return value.length ? value : null;
 
 
 
 
2637
 
 
2638
  },
2639
 
2640
- //CSS3 Selectors
2641
- _negation: function(){
2642
  /*
2643
- * negation
2644
- * : NOT S* negation_arg S* ')'
 
 
 
2645
  * ;
2646
  */
2647
 
2648
  var tokenStream = this._tokenStream,
2649
- line,
2650
- col,
2651
- value = "",
2652
- arg,
2653
- subpart = null;
2654
 
2655
- if (tokenStream.match(Tokens.NOT)){
2656
- value = tokenStream.token().value;
2657
- line = tokenStream.token().startLine;
2658
- col = tokenStream.token().startCol;
2659
- value += this._readWhitespace();
2660
- arg = this._negation_arg();
2661
- value += arg;
2662
- value += this._readWhitespace();
2663
- tokenStream.match(Tokens.RPAREN);
2664
- value += tokenStream.token().value;
2665
 
2666
- subpart = new SelectorSubPart(value, "not", line, col);
2667
- subpart.args.push(arg);
 
 
 
2668
  }
2669
 
2670
- return subpart;
 
2671
  },
2672
 
2673
- //CSS3 Selectors
2674
- _negation_arg: function(){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2675
  /*
2676
- * negation_arg
2677
- * : type_selector | universal | HASH | class | attrib | pseudo
2678
- * ;
 
 
 
 
2679
  */
2680
-
2681
  var tokenStream = this._tokenStream,
2682
- args = [
2683
- this._type_selector,
2684
- this._universal,
2685
- function(){
2686
- return tokenStream.match(Tokens.HASH) ?
2687
- new SelectorSubPart(tokenStream.token().value, "id", tokenStream.token().startLine, tokenStream.token().startCol) :
2688
- null;
2689
- },
2690
- this._class,
2691
- this._attrib,
2692
- this._pseudo
2693
- ],
2694
- arg = null,
2695
- i = 0,
2696
- len = args.length,
2697
- elementName,
2698
- line,
2699
- col,
2700
- part;
2701
 
2702
- line = tokenStream.LT(1).startLine;
2703
- col = tokenStream.LT(1).startCol;
2704
 
2705
- while(i < len && arg === null){
2706
 
2707
- arg = args[i].call(this);
2708
- i++;
2709
  }
2710
 
2711
- //must be a negation arg
2712
- if (arg === null){
2713
- this._unexpectedToken(tokenStream.LT(1));
2714
- }
2715
 
2716
- //it's an element name
2717
- if (arg.type == "elementName"){
2718
- part = new SelectorPart(arg, [], arg.toString(), line, col);
2719
- } else {
2720
- part = new SelectorPart(null, [arg], arg.toString(), line, col);
2721
- }
2722
 
2723
- return part;
2724
- },
 
 
 
 
 
 
 
 
 
2725
 
2726
- _declaration: function(){
 
 
 
 
2727
 
2728
- /*
2729
- * declaration
2730
- * : property ':' S* expr prio?
2731
- * | /( empty )/
2732
- * ;
2733
- */
2734
 
2735
- var tokenStream = this._tokenStream,
2736
- property = null,
2737
- expr = null,
2738
- prio = null,
2739
- error = null,
2740
- invalid = null,
2741
- propertyName= "";
 
 
 
 
2742
 
2743
- property = this._property();
2744
- if (property !== null){
 
 
 
 
 
 
 
 
2745
 
2746
- tokenStream.mustMatch(Tokens.COLON);
2747
- this._readWhitespace();
 
 
 
2748
 
2749
- expr = this._expr();
2750
 
2751
- //if there's no parts for the value, it's an error
2752
- if (!expr || expr.length === 0){
2753
- this._unexpectedToken(tokenStream.LT(1));
2754
- }
 
 
 
 
 
 
2755
 
2756
- prio = this._prio();
 
2757
 
2758
- /*
2759
- * If hacks should be allowed, then only check the root
2760
- * property. If hacks should not be allowed, treat
2761
- * _property or *property as invalid properties.
2762
- */
2763
- propertyName = property.toString();
2764
- if (this.options.starHack && property.hack == "*" ||
2765
- this.options.underscoreHack && property.hack == "_") {
2766
 
2767
- propertyName = property.text;
2768
- }
2769
 
2770
- try {
2771
- this._validateProperty(propertyName, expr);
2772
- } catch (ex) {
2773
- invalid = ex;
2774
- }
2775
 
2776
- this.fire({
2777
- type: "property",
2778
- property: property,
2779
- value: expr,
2780
- important: prio,
2781
- line: property.line,
2782
- col: property.col,
2783
- invalid: invalid
2784
- });
 
2785
 
2786
- return true;
2787
- } else {
2788
- return false;
 
 
 
 
 
 
2789
  }
2790
  },
2791
 
2792
- _prio: function(){
2793
- /*
2794
- * prio
2795
- * : IMPORTANT_SYM S*
2796
- * ;
2797
- */
2798
 
2799
- var tokenStream = this._tokenStream,
2800
- result = tokenStream.match(Tokens.IMPORTANT_SYM);
 
2801
 
2802
- this._readWhitespace();
2803
- return result;
 
2804
  },
2805
 
2806
- _expr: function(inFunction){
2807
- /*
2808
- * expr
2809
- * : term [ operator term ]*
2810
- * ;
2811
- */
2812
 
2813
- var tokenStream = this._tokenStream,
2814
- values = [],
2815
- //valueParts = [],
2816
- value = null,
2817
- operator = null;
2818
 
2819
- value = this._term();
2820
- if (value !== null){
2821
 
2822
- values.push(value);
 
 
2823
 
2824
- do {
2825
- operator = this._operator(inFunction);
 
 
 
 
 
2826
 
2827
- //if there's an operator, keep building up the value parts
2828
- if (operator){
2829
- values.push(operator);
2830
- } /*else {
2831
- //if there's not an operator, you have a full value
2832
- values.push(new PropertyValue(valueParts, valueParts[0].line, valueParts[0].col));
2833
- valueParts = [];
2834
- }*/
2835
 
2836
- value = this._term();
2837
 
2838
- if (value === null){
2839
- break;
2840
- } else {
2841
- values.push(value);
2842
- }
2843
- } while(true);
2844
- }
2845
 
2846
- //cleanup
2847
- /*if (valueParts.length){
2848
- values.push(new PropertyValue(valueParts, valueParts[0].line, valueParts[0].col));
2849
- }*/
2850
 
2851
- return values.length > 0 ? new PropertyValue(values, values[0].line, values[0].col) : null;
 
2852
  },
2853
 
2854
- _term: function(){
 
 
 
 
 
 
 
 
2855
 
2856
- /*
2857
- * term
2858
- * : unary_operator?
2859
- * [ NUMBER S* | PERCENTAGE S* | LENGTH S* | ANGLE S* |
2860
- * TIME S* | FREQ S* | function | ie_function ]
2861
- * | STRING S* | IDENT S* | URI S* | UNICODERANGE S* | hexcolor
2862
- * ;
2863
- */
2864
 
2865
- var tokenStream = this._tokenStream,
2866
- unary = null,
2867
- value = null,
2868
- token,
2869
- line,
2870
- col;
2871
 
2872
- //returns the operator or null
2873
- unary = this._unary_operator();
2874
- if (unary !== null){
2875
- line = tokenStream.token().startLine;
2876
- col = tokenStream.token().startCol;
2877
- }
2878
 
2879
- //exception for IE filters
2880
- if (tokenStream.peek() == Tokens.IE_FUNCTION && this.options.ieFilters){
2881
 
2882
- value = this._ie_function();
2883
- if (unary === null){
2884
- line = tokenStream.token().startLine;
2885
- col = tokenStream.token().startCol;
2886
- }
2887
 
2888
- //see if there's a simple match
2889
- } else if (tokenStream.match([Tokens.NUMBER, Tokens.PERCENTAGE, Tokens.LENGTH,
2890
- Tokens.ANGLE, Tokens.TIME,
2891
- Tokens.FREQ, Tokens.STRING, Tokens.IDENT, Tokens.URI, Tokens.UNICODE_RANGE])){
 
 
 
 
2892
 
2893
- value = tokenStream.token().value;
2894
- if (unary === null){
2895
- line = tokenStream.token().startLine;
2896
- col = tokenStream.token().startCol;
2897
- }
2898
- this._readWhitespace();
2899
- } else {
2900
 
2901
- //see if it's a color
2902
- token = this._hexcolor();
2903
- if (token === null){
2904
 
2905
- //if there's no unary, get the start of the next token for line/col info
2906
- if (unary === null){
2907
- line = tokenStream.LT(1).startLine;
2908
- col = tokenStream.LT(1).startCol;
2909
- }
2910
 
2911
- //has to be a function
2912
- if (value === null){
2913
 
2914
- /*
2915
- * This checks for alpha(opacity=0) style of IE
2916
- * functions. IE_FUNCTION only presents progid: style.
2917
- */
2918
- if (tokenStream.LA(3) == Tokens.EQUALS && this.options.ieFilters){
2919
- value = this._ie_function();
2920
- } else {
2921
- value = this._function();
2922
- }
2923
- }
2924
 
2925
- /*if (value === null){
2926
- return null;
2927
- //throw new Error("Expected identifier at line " + tokenStream.token().startLine + ", character " + tokenStream.token().startCol + ".");
2928
- }*/
2929
 
2930
- } else {
2931
- value = token.value;
2932
- if (unary === null){
2933
- line = token.startLine;
2934
- col = token.startCol;
2935
- }
2936
- }
 
 
 
 
 
 
2937
 
2938
- }
 
 
 
 
 
2939
 
2940
- return value !== null ?
2941
- new PropertyValuePart(unary !== null ? unary + value : value, line, col) :
2942
- null;
2943
 
2944
- },
2945
 
2946
- _function: function(){
 
 
 
 
 
2947
 
2948
- /*
2949
- * function
2950
- * : FUNCTION S* expr ')' S*
2951
- * ;
2952
- */
2953
 
2954
- var tokenStream = this._tokenStream,
2955
- functionText = null,
2956
- expr = null,
2957
- lt;
2958
 
2959
- if (tokenStream.match(Tokens.FUNCTION)){
2960
- functionText = tokenStream.token().value;
2961
- this._readWhitespace();
2962
- expr = this._expr(true);
2963
- functionText += expr;
2964
 
2965
- //START: Horrible hack in case it's an IE filter
2966
- if (this.options.ieFilters && tokenStream.peek() == Tokens.EQUALS){
2967
- do {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2968
 
2969
- if (this._readWhitespace()){
2970
- functionText += tokenStream.token().value;
2971
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2972
 
2973
- //might be second time in the loop
2974
- if (tokenStream.LA(0) == Tokens.COMMA){
2975
- functionText += tokenStream.token().value;
2976
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2977
 
2978
- tokenStream.match(Tokens.IDENT);
2979
- functionText += tokenStream.token().value;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2980
 
2981
- tokenStream.match(Tokens.EQUALS);
2982
- functionText += tokenStream.token().value;
 
 
 
 
 
 
 
 
2983
 
2984
- //functionText += this._term();
2985
- lt = tokenStream.peek();
2986
- while(lt != Tokens.COMMA && lt != Tokens.S && lt != Tokens.RPAREN){
2987
- tokenStream.get();
2988
- functionText += tokenStream.token().value;
2989
- lt = tokenStream.peek();
2990
- }
2991
- } while(tokenStream.match([Tokens.COMMA, Tokens.S]));
2992
- }
2993
 
2994
- //END: Horrible Hack
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2995
 
2996
- tokenStream.match(Tokens.RPAREN);
2997
- functionText += ")";
2998
- this._readWhitespace();
2999
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3000
 
3001
- return functionText;
3002
- },
 
 
 
 
 
 
 
3003
 
3004
- _ie_function: function(){
 
 
 
 
 
 
3005
 
3006
- /* (My own extension)
3007
- * ie_function
3008
- * : IE_FUNCTION S* IDENT '=' term [S* ','? IDENT '=' term]+ ')' S*
3009
- * ;
3010
- */
3011
 
3012
- var tokenStream = this._tokenStream,
3013
- functionText = null,
3014
- expr = null,
3015
- lt;
3016
 
3017
- //IE function can begin like a regular function, too
3018
- if (tokenStream.match([Tokens.IE_FUNCTION, Tokens.FUNCTION])){
3019
- functionText = tokenStream.token().value;
 
 
 
 
 
 
 
 
 
 
3020
 
3021
- do {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3022
 
3023
- if (this._readWhitespace()){
3024
- functionText += tokenStream.token().value;
3025
- }
 
 
 
3026
 
3027
- //might be second time in the loop
3028
- if (tokenStream.LA(0) == Tokens.COMMA){
3029
- functionText += tokenStream.token().value;
3030
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
3031
 
3032
- tokenStream.match(Tokens.IDENT);
3033
- functionText += tokenStream.token().value;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3034
 
3035
- tokenStream.match(Tokens.EQUALS);
3036
- functionText += tokenStream.token().value;
3037
 
3038
- //functionText += this._term();
3039
- lt = tokenStream.peek();
3040
- while(lt != Tokens.COMMA && lt != Tokens.S && lt != Tokens.RPAREN){
3041
- tokenStream.get();
3042
- functionText += tokenStream.token().value;
3043
- lt = tokenStream.peek();
3044
- }
3045
- } while(tokenStream.match([Tokens.COMMA, Tokens.S]));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3046
 
3047
- tokenStream.match(Tokens.RPAREN);
3048
- functionText += ")";
3049
- this._readWhitespace();
3050
- }
3051
 
3052
- return functionText;
3053
- },
 
 
 
 
 
 
 
 
 
 
3054
 
3055
- _hexcolor: function(){
3056
- /*
3057
- * There is a constraint on the color that it must
3058
- * have either 3 or 6 hex-digits (i.e., [0-9a-fA-F])
3059
- * after the "#"; e.g., "#000" is OK, but "#abcd" is not.
3060
- *
3061
- * hexcolor
3062
- * : HASH S*
3063
- * ;
3064
- */
3065
 
3066
- var tokenStream = this._tokenStream,
3067
- token = null,
3068
- color;
 
3069
 
3070
- if(tokenStream.match(Tokens.HASH)){
 
3071
 
3072
- //need to do some validation here
3073
 
3074
- token = tokenStream.token();
3075
- color = token.value;
3076
- if (!/#[a-f0-9]{3,6}/i.test(color)){
3077
- throw new SyntaxError("Expected a hex color but found '" + color + "' at line " + token.startLine + ", col " + token.startCol + ".", token.startLine, token.startCol);
3078
- }
3079
- this._readWhitespace();
3080
- }
3081
 
3082
- return token;
3083
- },
3084
 
3085
- //-----------------------------------------------------------------
3086
- // Animations methods
3087
- //-----------------------------------------------------------------
 
 
 
 
 
 
 
 
 
3088
 
3089
- _keyframes: function(){
3090
 
3091
- /*
3092
- * keyframes:
3093
- * : KEYFRAMES_SYM S* keyframe_name S* '{' S* keyframe_rule* '}' {
3094
- * ;
3095
- */
3096
- var tokenStream = this._tokenStream,
3097
- token,
3098
- tt,
3099
- name,
3100
- prefix = "";
3101
 
3102
- tokenStream.mustMatch(Tokens.KEYFRAMES_SYM);
3103
- token = tokenStream.token();
3104
- if (/^@\-([^\-]+)\-/.test(token.value)) {
3105
- prefix = RegExp.$1;
3106
- }
3107
 
3108
- this._readWhitespace();
3109
- name = this._keyframe_name();
 
 
 
3110
 
3111
- this._readWhitespace();
3112
- tokenStream.mustMatch(Tokens.LBRACE);
3113
 
3114
- this.fire({
3115
- type: "startkeyframes",
3116
- name: name,
3117
- prefix: prefix,
3118
- line: token.startLine,
3119
- col: token.startCol
3120
- });
3121
 
3122
- this._readWhitespace();
3123
- tt = tokenStream.peek();
3124
 
3125
- //check for key
3126
- while(tt == Tokens.IDENT || tt == Tokens.PERCENTAGE) {
3127
- this._keyframe_rule();
3128
- this._readWhitespace();
3129
- tt = tokenStream.peek();
3130
- }
3131
 
3132
- this.fire({
3133
- type: "endkeyframes",
3134
- name: name,
3135
- prefix: prefix,
3136
- line: token.startLine,
3137
- col: token.startCol
3138
- });
 
 
 
 
 
 
3139
 
3140
- this._readWhitespace();
3141
- tokenStream.mustMatch(Tokens.RBRACE);
3142
 
3143
- },
 
 
 
 
 
3144
 
3145
- _keyframe_name: function(){
3146
 
3147
- /*
3148
- * keyframe_name:
3149
- * : IDENT
3150
- * | STRING
3151
- * ;
3152
- */
3153
- var tokenStream = this._tokenStream,
3154
- token;
3155
 
3156
- tokenStream.mustMatch([Tokens.IDENT, Tokens.STRING]);
3157
- return SyntaxUnit.fromToken(tokenStream.token());
3158
- },
3159
 
3160
- _keyframe_rule: function(){
 
3161
 
3162
- /*
3163
- * keyframe_rule:
3164
- * : key_list S*
3165
- * '{' S* declaration [ ';' S* declaration ]* '}' S*
3166
- * ;
3167
- */
3168
- var tokenStream = this._tokenStream,
3169
- token,
3170
- keyList = this._key_list();
3171
 
3172
- this.fire({
3173
- type: "startkeyframerule",
3174
- keys: keyList,
3175
- line: keyList[0].line,
3176
- col: keyList[0].col
3177
- });
 
 
 
3178
 
3179
- this._readDeclarations(true);
 
 
 
 
 
 
3180
 
3181
- this.fire({
3182
- type: "endkeyframerule",
3183
- keys: keyList,
3184
- line: keyList[0].line,
3185
- col: keyList[0].col
3186
- });
 
3187
 
3188
- },
 
 
 
 
 
 
3189
 
3190
- _key_list: function(){
 
 
 
 
 
3191
 
3192
- /*
3193
- * key_list:
3194
- * : key [ S* ',' S* key]*
3195
- * ;
3196
- */
3197
- var tokenStream = this._tokenStream,
3198
- token,
3199
- key,
3200
- keyList = [];
3201
 
3202
- //must be least one key
3203
- keyList.push(this._key());
 
 
 
 
 
 
3204
 
3205
- this._readWhitespace();
 
 
 
 
 
 
 
3206
 
3207
- while(tokenStream.match(Tokens.COMMA)){
3208
- this._readWhitespace();
3209
- keyList.push(this._key());
3210
- this._readWhitespace();
3211
- }
 
 
 
3212
 
3213
- return keyList;
3214
- },
 
 
 
 
 
 
 
3215
 
3216
- _key: function(){
3217
- /*
3218
- * There is a restriction that IDENT can be only "from" or "to".
3219
- *
3220
- * key
3221
- * : PERCENTAGE
3222
- * | IDENT
3223
- * ;
3224
- */
 
3225
 
3226
- var tokenStream = this._tokenStream,
3227
- token;
 
 
 
 
 
 
 
 
3228
 
3229
- if (tokenStream.match(Tokens.PERCENTAGE)){
3230
- return SyntaxUnit.fromToken(tokenStream.token());
3231
- } else if (tokenStream.match(Tokens.IDENT)){
3232
- token = tokenStream.token();
 
 
 
 
 
 
3233
 
3234
- if (/from|to/i.test(token.value)){
3235
- return SyntaxUnit.fromToken(token);
3236
- }
 
 
 
 
 
 
 
3237
 
3238
- tokenStream.unget();
3239
- }
 
 
 
 
 
 
3240
 
3241
- //if it gets here, there wasn't a valid token, so time to explode
3242
- this._unexpectedToken(tokenStream.LT(1));
3243
- },
3244
 
3245
- //-----------------------------------------------------------------
3246
- // Helper methods
3247
- //-----------------------------------------------------------------
3248
 
3249
- /**
3250
- * Not part of CSS grammar, but useful for skipping over
3251
- * combination of white space and HTML-style comments.
3252
- * @return {void}
3253
- * @method _skipCruft
3254
- * @private
3255
- */
3256
- _skipCruft: function(){
3257
- while(this._tokenStream.match([Tokens.S, Tokens.CDO, Tokens.CDC])){
3258
- //noop
3259
- }
3260
- },
3261
 
3262
- /**
3263
- * Not part of CSS grammar, but this pattern occurs frequently
3264
- * in the official CSS grammar. Split out here to eliminate
3265
- * duplicate code.
3266
- * @param {Boolean} checkStart Indicates if the rule should check
3267
- * for the left brace at the beginning.
3268
- * @param {Boolean} readMargins Indicates if the rule should check
3269
- * for margin patterns.
3270
- * @return {void}
3271
- * @method _readDeclarations
3272
- * @private
3273
- */
3274
- _readDeclarations: function(checkStart, readMargins){
3275
- /*
3276
- * Reads the pattern
3277
- * S* '{' S* declaration [ ';' S* declaration ]* '}' S*
3278
- * or
3279
- * S* '{' S* [ declaration | margin ]? [ ';' S* [ declaration | margin ]? ]* '}' S*
3280
- * Note that this is how it is described in CSS3 Paged Media, but is actually incorrect.
3281
- * A semicolon is only necessary following a declaration is there's another declaration
3282
- * or margin afterwards.
3283
- */
3284
- var tokenStream = this._tokenStream,
3285
- tt;
3286
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3287
 
3288
- this._readWhitespace();
3289
 
3290
- if (checkStart){
3291
- tokenStream.mustMatch(Tokens.LBRACE);
3292
- }
 
 
 
3293
 
3294
- this._readWhitespace();
3295
 
3296
- try {
3297
 
3298
- while(true){
 
 
 
 
3299
 
3300
- if (tokenStream.match(Tokens.SEMICOLON) || (readMargins && this._margin())){
3301
- //noop
3302
- } else if (this._declaration()){
3303
- if (!tokenStream.match(Tokens.SEMICOLON)){
3304
- break;
3305
- }
3306
- } else {
3307
- break;
3308
- }
3309
 
3310
- //if ((!this._margin() && !this._declaration()) || !tokenStream.match(Tokens.SEMICOLON)){
3311
- // break;
3312
- //}
3313
- this._readWhitespace();
3314
- }
 
 
 
 
 
 
 
 
 
 
 
3315
 
3316
- tokenStream.mustMatch(Tokens.RBRACE);
3317
- this._readWhitespace();
 
3318
 
3319
- } catch (ex) {
3320
- if (ex instanceof SyntaxError && !this.options.strict){
 
 
 
3321
 
3322
- //fire error event
3323
- this.fire({
3324
- type: "error",
3325
- error: ex,
3326
- message: ex.message,
3327
- line: ex.line,
3328
- col: ex.col
3329
- });
3330
 
3331
- //see if there's another declaration
3332
- tt = tokenStream.advance([Tokens.SEMICOLON, Tokens.RBRACE]);
3333
- if (tt == Tokens.SEMICOLON){
3334
- //if there's a semicolon, then there might be another declaration
3335
- this._readDeclarations(false, readMargins);
3336
- } else if (tt != Tokens.RBRACE){
3337
- //if there's a right brace, the rule is finished so don't do anything
3338
- //otherwise, rethrow the error because it wasn't handled properly
3339
- throw ex;
3340
- }
3341
 
3342
- } else {
3343
- //not a syntax error, rethrow it
3344
- throw ex;
3345
- }
3346
- }
3347
 
3348
- },
3349
 
3350
- /**
3351
- * In some cases, you can end up with two white space tokens in a
3352
- * row. Instead of making a change in every function that looks for
3353
- * white space, this function is used to match as much white space
3354
- * as necessary.
3355
- * @method _readWhitespace
3356
- * @return {String} The white space if found, empty string if not.
3357
- * @private
3358
- */
3359
- _readWhitespace: function(){
3360
 
3361
- var tokenStream = this._tokenStream,
3362
- ws = "";
 
 
 
 
 
 
 
3363
 
3364
- while(tokenStream.match(Tokens.S)){
3365
- ws += tokenStream.token().value;
3366
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3367
 
3368
- return ws;
3369
- },
3370
 
 
 
3371
 
3372
- /**
3373
- * Throws an error when an unexpected token is found.
3374
- * @param {Object} token The token that was found.
3375
- * @method _unexpectedToken
3376
- * @return {void}
3377
- * @private
3378
- */
3379
- _unexpectedToken: function(token){
3380
- throw new SyntaxError("Unexpected token '" + token.value + "' at line " + token.startLine + ", col " + token.startCol + ".", token.startLine, token.startCol);
3381
- },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3382
 
3383
- /**
3384
- * Helper method used for parsing subparts of a style sheet.
3385
- * @return {void}
3386
- * @method _verifyEnd
3387
- * @private
3388
- */
3389
- _verifyEnd: function(){
3390
- if (this._tokenStream.LA(1) != Tokens.EOF){
3391
- this._unexpectedToken(this._tokenStream.LT(1));
3392
- }
3393
- },
 
 
 
 
 
3394
 
3395
- //-----------------------------------------------------------------
3396
- // Validation methods
3397
- //-----------------------------------------------------------------
3398
- _validateProperty: function(property, value){
3399
- Validation.validate(property, value);
3400
- },
 
 
 
 
 
 
 
 
 
 
 
 
3401
 
3402
- //-----------------------------------------------------------------
3403
- // Parsing methods
3404
- //-----------------------------------------------------------------
3405
 
3406
- parse: function(input){
3407
- this._tokenStream = new TokenStream(input, Tokens);
3408
- this._stylesheet();
3409
- },
 
 
 
3410
 
3411
- parseStyleSheet: function(input){
3412
- //just passthrough
3413
- return this.parse(input);
3414
- },
3415
 
3416
- parseMediaQuery: function(input){
3417
- this._tokenStream = new TokenStream(input, Tokens);
3418
- var result = this._media_query();
3419
 
3420
- //if there's anything more, then it's an invalid selector
3421
- this._verifyEnd();
3422
 
3423
- //otherwise return result
3424
- return result;
3425
- },
3426
 
3427
- /**
3428
- * Parses a property value (everything after the semicolon).
3429
- * @return {parserlib.css.PropertyValue} The property value.
3430
- * @throws parserlib.util.SyntaxError If an unexpected token is found.
3431
- * @method parserPropertyValue
3432
- */
3433
- parsePropertyValue: function(input){
3434
 
3435
- this._tokenStream = new TokenStream(input, Tokens);
3436
- this._readWhitespace();
3437
 
3438
- var result = this._expr();
 
 
 
 
 
 
 
 
 
 
 
3439
 
3440
- //okay to have a trailing white space
3441
- this._readWhitespace();
3442
 
3443
- //if there's anything more, then it's an invalid selector
3444
- this._verifyEnd();
 
 
 
 
3445
 
3446
- //otherwise return result
3447
- return result;
3448
- },
 
 
 
3449
 
3450
- /**
3451
- * Parses a complete CSS rule, including selectors and
3452
- * properties.
3453
- * @param {String} input The text to parser.
3454
- * @return {Boolean} True if the parse completed successfully, false if not.
3455
- * @method parseRule
3456
- */
3457
- parseRule: function(input){
3458
- this._tokenStream = new TokenStream(input, Tokens);
3459
 
3460
- //skip any leading white space
3461
- this._readWhitespace();
3462
 
3463
- var result = this._ruleset();
3464
 
3465
- //skip any trailing white space
3466
- this._readWhitespace();
3467
 
3468
- //if there's anything more, then it's an invalid selector
3469
- this._verifyEnd();
3470
 
3471
- //otherwise return result
3472
- return result;
3473
- },
3474
 
3475
- /**
3476
- * Parses a single CSS selector (no comma)
3477
- * @param {String} input The text to parse as a CSS selector.
3478
- * @return {Selector} An object representing the selector.
3479
- * @throws parserlib.util.SyntaxError If an unexpected token is found.
3480
- * @method parseSelector
3481
- */
3482
- parseSelector: function(input){
3483
 
3484
- this._tokenStream = new TokenStream(input, Tokens);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3485
 
3486
- //skip any leading white space
3487
- this._readWhitespace();
3488
 
3489
- var result = this._selector();
 
 
 
 
 
 
3490
 
3491
- //skip any trailing white space
3492
- this._readWhitespace();
 
 
 
 
 
3493
 
3494
- //if there's anything more, then it's an invalid selector
3495
- this._verifyEnd();
3496
 
3497
- //otherwise return result
3498
- return result;
3499
- },
3500
 
3501
- /**
3502
- * Parses an HTML style attribute: a set of CSS declarations
3503
- * separated by semicolons.
3504
- * @param {String} input The text to parse as a style attribute
3505
- * @return {void}
3506
- * @method parseStyleAttribute
3507
- */
3508
- parseStyleAttribute: function(input){
3509
- input += "}"; // for error recovery in _readDeclarations()
3510
- this._tokenStream = new TokenStream(input, Tokens);
3511
- this._readDeclarations();
3512
- }
3513
- };
3514
 
3515
- //copy over onto prototype
3516
- for (prop in additions){
3517
- if (additions.hasOwnProperty(prop)){
3518
- proto[prop] = additions[prop];
3519
- }
3520
- }
3521
 
3522
- return proto;
3523
- }();
3524
 
 
3525
 
3526
- /*
3527
- nth
3528
- : S* [ ['-'|'+']? INTEGER? {N} [ S* ['-'|'+'] S* INTEGER ]? |
3529
- ['-'|'+']? INTEGER | {O}{D}{D} | {E}{V}{E}{N} ] S*
3530
- ;
3531
- */
3532
 
3533
- /*global Validation, ValidationTypes, ValidationError*/
3534
- var Properties = {
 
 
 
 
 
 
 
 
 
 
 
3535
 
3536
- //A
3537
- "alignment-adjust" : "auto | baseline | before-edge | text-before-edge | middle | central | after-edge | text-after-edge | ideographic | alphabetic | hanging | mathematical | <percentage> | <length>",
3538
- "alignment-baseline" : "baseline | use-script | before-edge | text-before-edge | after-edge | text-after-edge | central | middle | ideographic | alphabetic | hanging | mathematical",
3539
- "animation" : 1,
3540
- "animation-delay" : { multi: "<time>", comma: true },
3541
- "animation-direction" : { multi: "normal | alternate", comma: true },
3542
- "animation-duration" : { multi: "<time>", comma: true },
3543
- "animation-iteration-count" : { multi: "<number> | infinite", comma: true },
3544
- "animation-name" : { multi: "none | <ident>", comma: true },
3545
- "animation-play-state" : { multi: "running | paused", comma: true },
3546
- "animation-timing-function" : 1,
3547
 
3548
- //vendor prefixed
3549
- "-moz-animation-delay" : { multi: "<time>", comma: true },
3550
- "-moz-animation-direction" : { multi: "normal | alternate", comma: true },
3551
- "-moz-animation-duration" : { multi: "<time>", comma: true },
3552
- "-moz-animation-iteration-count" : { multi: "<number> | infinite", comma: true },
3553
- "-moz-animation-name" : { multi: "none | <ident>", comma: true },
3554
- "-moz-animation-play-state" : { multi: "running | paused", comma: true },
3555
-
3556
- "-ms-animation-delay" : { multi: "<time>", comma: true },
3557
- "-ms-animation-direction" : { multi: "normal | alternate", comma: true },
3558
- "-ms-animation-duration" : { multi: "<time>", comma: true },
3559
- "-ms-animation-iteration-count" : { multi: "<number> | infinite", comma: true },
3560
- "-ms-animation-name" : { multi: "none | <ident>", comma: true },
3561
- "-ms-animation-play-state" : { multi: "running | paused", comma: true },
3562
-
3563
- "-webkit-animation-delay" : { multi: "<time>", comma: true },
3564
- "-webkit-animation-direction" : { multi: "normal | alternate", comma: true },
3565
- "-webkit-animation-duration" : { multi: "<time>", comma: true },
3566
- "-webkit-animation-iteration-count" : { multi: "<number> | infinite", comma: true },
3567
- "-webkit-animation-name" : { multi: "none | <ident>", comma: true },
3568
- "-webkit-animation-play-state" : { multi: "running | paused", comma: true },
3569
-
3570
- "-o-animation-delay" : { multi: "<time>", comma: true },
3571
- "-o-animation-direction" : { multi: "normal | alternate", comma: true },
3572
- "-o-animation-duration" : { multi: "<time>", comma: true },
3573
- "-o-animation-iteration-count" : { multi: "<number> | infinite", comma: true },
3574
- "-o-animation-name" : { multi: "none | <ident>", comma: true },
3575
- "-o-animation-play-state" : { multi: "running | paused", comma: true },
3576
-
3577
- "appearance" : "icon | window | desktop | workspace | document | tooltip | dialog | button | push-button | hyperlink | radio-button | checkbox | menu-item | tab | menu | menubar | pull-down-menu | pop-up-menu | list-menu | radio-group | checkbox-group | outline-tree | range | field | combo-box | signature | password | normal | none | inherit",
3578
- "azimuth" : function (expression) {
3579
- var simple = "<angle> | leftwards | rightwards | inherit",
3580
- direction = "left-side | far-left | left | center-left | center | center-right | right | far-right | right-side",
3581
- behind = false,
3582
- valid = false,
3583
- part;
3584
 
3585
- if (!ValidationTypes.isAny(expression, simple)) {
3586
- if (ValidationTypes.isAny(expression, "behind")) {
3587
- behind = true;
3588
- valid = true;
3589
- }
 
3590
 
3591
- if (ValidationTypes.isAny(expression, direction)) {
3592
- valid = true;
3593
- if (!behind) {
3594
- ValidationTypes.isAny(expression, "behind");
3595
- }
3596
- }
3597
- }
3598
 
3599
- if (expression.hasNext()) {
3600
- part = expression.next();
3601
- if (valid) {
3602
- throw new ValidationError("Expected end of value but found '" + part + "'.", part.line, part.col);
3603
- } else {
3604
- throw new ValidationError("Expected (<'azimuth'>) but found '" + part + "'.", part.line, part.col);
3605
- }
3606
- }
3607
- },
3608
 
3609
- //B
3610
- "backface-visibility" : "visible | hidden",
3611
- "background" : 1,
3612
- "background-attachment" : { multi: "<attachment>", comma: true },
3613
- "background-clip" : { multi: "<box>", comma: true },
3614
- "background-color" : "<color> | inherit",
3615
- "background-image" : { multi: "<bg-image>", comma: true },
3616
- "background-origin" : { multi: "<box>", comma: true },
3617
- "background-position" : { multi: "<bg-position>", comma: true },
3618
- "background-repeat" : { multi: "<repeat-style>" },
3619
- "background-size" : { multi: "<bg-size>", comma: true },
3620
- "baseline-shift" : "baseline | sub | super | <percentage> | <length>",
3621
- "behavior" : 1,
3622
- "binding" : 1,
3623
- "bleed" : "<length>",
3624
- "bookmark-label" : "<content> | <attr> | <string>",
3625
- "bookmark-level" : "none | <integer>",
3626
- "bookmark-state" : "open | closed",
3627
- "bookmark-target" : "none | <uri> | <attr>",
3628
- "border" : "<border-width> || <border-style> || <color>",
3629
- "border-bottom" : "<border-width> || <border-style> || <color>",
3630
- "border-bottom-color" : "<color> | inherit",
3631
- "border-bottom-left-radius" : "<x-one-radius>",
3632
- "border-bottom-right-radius" : "<x-one-radius>",
3633
- "border-bottom-style" : "<border-style>",
3634
- "border-bottom-width" : "<border-width>",
3635
- "border-collapse" : "collapse | separate | inherit",
3636
- "border-color" : { multi: "<color> | inherit", max: 4 },
3637
- "border-image" : 1,
3638
- "border-image-outset" : { multi: "<length> | <number>", max: 4 },
3639
- "border-image-repeat" : { multi: "stretch | repeat | round", max: 2 },
3640
- "border-image-slice" : function(expression) {
3641
-
3642
- var valid = false,
3643
- numeric = "<number> | <percentage>",
3644
- fill = false,
3645
- count = 0,
3646
- max = 4,
3647
- part;
3648
 
3649
- if (ValidationTypes.isAny(expression, "fill")) {
3650
- fill = true;
3651
- valid = true;
3652
- }
3653
 
3654
- while (expression.hasNext() && count < max) {
3655
- valid = ValidationTypes.isAny(expression, numeric);
3656
- if (!valid) {
3657
- break;
3658
- }
3659
- count++;
3660
- }
3661
 
 
 
3662
 
3663
- if (!fill) {
3664
- ValidationTypes.isAny(expression, "fill");
3665
- } else {
3666
- valid = true;
3667
- }
 
 
 
 
 
 
 
 
 
 
 
3668
 
3669
- if (expression.hasNext()) {
3670
- part = expression.next();
3671
- if (valid) {
3672
- throw new ValidationError("Expected end of value but found '" + part + "'.", part.line, part.col);
3673
- } else {
3674
- throw new ValidationError("Expected ([<number> | <percentage>]{1,4} && fill?) but found '" + part + "'.", part.line, part.col);
3675
- }
3676
- }
3677
- },
3678
- "border-image-source" : "<image> | none",
3679
- "border-image-width" : { multi: "<length> | <percentage> | <number> | auto", max: 4 },
3680
- "border-left" : "<border-width> || <border-style> || <color>",
3681
- "border-left-color" : "<color> | inherit",
3682
- "border-left-style" : "<border-style>",
3683
- "border-left-width" : "<border-width>",
3684
- "border-radius" : function(expression) {
3685
-
3686
- var valid = false,
3687
- simple = "<length> | <percentage> | inherit",
3688
- slash = false,
3689
- fill = false,
3690
- count = 0,
3691
- max = 8,
3692
- part;
3693
 
3694
- while (expression.hasNext() && count < max) {
3695
- valid = ValidationTypes.isAny(expression, simple);
3696
- if (!valid) {
 
 
 
 
 
 
3697
 
3698
- if (expression.peek() == "/" && count > 0 && !slash) {
3699
- slash = true;
3700
- max = count + 5;
3701
- expression.next();
3702
- } else {
3703
- break;
3704
- }
3705
  }
3706
- count++;
3707
  }
3708
 
3709
- if (expression.hasNext()) {
3710
- part = expression.next();
3711
- if (valid) {
3712
- throw new ValidationError("Expected end of value but found '" + part + "'.", part.line, part.col);
3713
- } else {
3714
- throw new ValidationError("Expected (<'border-radius'>) but found '" + part + "'.", part.line, part.col);
3715
- }
3716
- }
3717
  },
3718
- "border-right" : "<border-width> || <border-style> || <color>",
3719
- "border-right-color" : "<color> | inherit",
3720
- "border-right-style" : "<border-style>",
3721
- "border-right-width" : "<border-width>",
3722
- "border-spacing" : { multi: "<length> | inherit", max: 2 },
3723
- "border-style" : { multi: "<border-style>", max: 4 },
3724
- "border-top" : "<border-width> || <border-style> || <color>",
3725
- "border-top-color" : "<color> | inherit",
3726
- "border-top-left-radius" : "<x-one-radius>",
3727
- "border-top-right-radius" : "<x-one-radius>",
3728
- "border-top-style" : "<border-style>",
3729
- "border-top-width" : "<border-width>",
3730
- "border-width" : { multi: "<border-width>", max: 4 },
3731
- "bottom" : "<margin-width> | inherit",
3732
- "box-align" : "start | end | center | baseline | stretch", //http://www.w3.org/TR/2009/WD-css3-flexbox-20090723/
3733
- "box-decoration-break" : "slice |clone",
3734
- "box-direction" : "normal | reverse | inherit",
3735
- "box-flex" : "<number>",
3736
- "box-flex-group" : "<integer>",
3737
- "box-lines" : "single | multiple",
3738
- "box-ordinal-group" : "<integer>",
3739
- "box-orient" : "horizontal | vertical | inline-axis | block-axis | inherit",
3740
- "box-pack" : "start | end | center | justify",
3741
- "box-shadow" : function (expression) {
3742
- var result = false,
3743
- part;
3744
 
3745
- if (!ValidationTypes.isAny(expression, "none")) {
3746
- Validation.multiProperty("<shadow>", expression, true, Infinity);
3747
- } else {
3748
- if (expression.hasNext()) {
3749
- part = expression.next();
3750
- throw new ValidationError("Expected end of value but found '" + part + "'.", part.line, part.col);
3751
- }
3752
- }
3753
  },
3754
- "box-sizing" : "content-box | border-box | inherit",
3755
- "break-after" : "auto | always | avoid | left | right | page | column | avoid-page | avoid-column",
3756
- "break-before" : "auto | always | avoid | left | right | page | column | avoid-page | avoid-column",
3757
- "break-inside" : "auto | avoid | avoid-page | avoid-column",
3758
-
3759
- //C
3760
- "caption-side" : "top | bottom | inherit",
3761
- "clear" : "none | right | left | both | inherit",
3762
- "clip" : 1,
3763
- "color" : "<color> | inherit",
3764
- "color-profile" : 1,
3765
- "column-count" : "<integer> | auto", //http://www.w3.org/TR/css3-multicol/
3766
- "column-fill" : "auto | balance",
3767
- "column-gap" : "<length> | normal",
3768
- "column-rule" : "<border-width> || <border-style> || <color>",
3769
- "column-rule-color" : "<color>",
3770
- "column-rule-style" : "<border-style>",
3771
- "column-rule-width" : "<border-width>",
3772
- "column-span" : "none | all",
3773
- "column-width" : "<length> | auto",
3774
- "columns" : 1,
3775
- "content" : 1,
3776
- "counter-increment" : 1,
3777
- "counter-reset" : 1,
3778
- "crop" : "<shape> | auto",
3779
- "cue" : "cue-after | cue-before | inherit",
3780
- "cue-after" : 1,
3781
- "cue-before" : 1,
3782
- "cursor" : 1,
3783
-
3784
- //D
3785
- "direction" : "ltr | rtl | inherit",
3786
- "display" : "inline | block | list-item | inline-block | table | inline-table | table-row-group | table-header-group | table-footer-group | table-row | table-column-group | table-column | table-cell | table-caption | box | inline-box | grid | inline-grid | none | inherit | -moz-box | -moz-inline-block | -moz-inline-box | -moz-inline-grid | -moz-inline-stack | -moz-inline-table | -moz-grid | -moz-grid-group | -moz-grid-line | -moz-groupbox | -moz-deck | -moz-popup | -moz-stack | -moz-marker | -webkit-box | -webkit-inline-box",
3787
- "dominant-baseline" : 1,
3788
- "drop-initial-after-adjust" : "central | middle | after-edge | text-after-edge | ideographic | alphabetic | mathematical | <percentage> | <length>",
3789
- "drop-initial-after-align" : "baseline | use-script | before-edge | text-before-edge | after-edge | text-after-edge | central | middle | ideographic | alphabetic | hanging | mathematical",
3790
- "drop-initial-before-adjust" : "before-edge | text-before-edge | central | middle | hanging | mathematical | <percentage> | <length>",
3791
- "drop-initial-before-align" : "caps-height | baseline | use-script | before-edge | text-before-edge | after-edge | text-after-edge | central | middle | ideographic | alphabetic | hanging | mathematical",
3792
- "drop-initial-size" : "auto | line | <length> | <percentage>",
3793
- "drop-initial-value" : "initial | <integer>",
3794
-
3795
- //E
3796
- "elevation" : "<angle> | below | level | above | higher | lower | inherit",
3797
- "empty-cells" : "show | hide | inherit",
3798
 
3799
- //F
3800
- "filter" : 1,
3801
- "fit" : "fill | hidden | meet | slice",
3802
- "fit-position" : 1,
3803
- "float" : "left | right | none | inherit",
3804
- "float-offset" : 1,
3805
- "font" : 1,
3806
- "font-family" : 1,
3807
- "font-size" : "<absolute-size> | <relative-size> | <length> | <percentage> | inherit",
3808
- "font-size-adjust" : "<number> | none | inherit",
3809
- "font-stretch" : "normal | ultra-condensed | extra-condensed | condensed | semi-condensed | semi-expanded | expanded | extra-expanded | ultra-expanded | inherit",
3810
- "font-style" : "normal | italic | oblique | inherit",
3811
- "font-variant" : "normal | small-caps | inherit",
3812
- "font-weight" : "normal | bold | bolder | lighter | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | inherit",
3813
 
3814
- //G
3815
- "grid-cell-stacking" : "columns | rows | layer",
3816
- "grid-column" : 1,
3817
- "grid-columns" : 1,
3818
- "grid-column-align" : "start | end | center | stretch",
3819
- "grid-column-sizing" : 1,
3820
- "grid-column-span" : "<integer>",
3821
- "grid-flow" : "none | rows | columns",
3822
- "grid-layer" : "<integer>",
3823
- "grid-row" : 1,
3824
- "grid-rows" : 1,
3825
- "grid-row-align" : "start | end | center | stretch",
3826
- "grid-row-span" : "<integer>",
3827
- "grid-row-sizing" : 1,
3828
 
3829
- //H
3830
- "hanging-punctuation" : 1,
3831
- "height" : "<margin-width> | inherit",
3832
- "hyphenate-after" : "<integer> | auto",
3833
- "hyphenate-before" : "<integer> | auto",
3834
- "hyphenate-character" : "<string> | auto",
3835
- "hyphenate-lines" : "no-limit | <integer>",
3836
- "hyphenate-resource" : 1,
3837
- "hyphens" : "none | manual | auto",
3838
 
3839
- //I
3840
- "icon" : 1,
3841
- "image-orientation" : "angle | auto",
3842
- "image-rendering" : 1,
3843
- "image-resolution" : 1,
3844
- "inline-box-align" : "initial | last | <integer>",
3845
 
3846
- //L
3847
- "left" : "<margin-width> | inherit",
3848
- "letter-spacing" : "<length> | normal | inherit",
3849
- "line-height" : "<number> | <length> | <percentage> | normal | inherit",
3850
- "line-break" : "auto | loose | normal | strict",
3851
- "line-stacking" : 1,
3852
- "line-stacking-ruby" : "exclude-ruby | include-ruby",
3853
- "line-stacking-shift" : "consider-shifts | disregard-shifts",
3854
- "line-stacking-strategy" : "inline-line-height | block-line-height | max-height | grid-height",
3855
- "list-style" : 1,
3856
- "list-style-image" : "<uri> | none | inherit",
3857
- "list-style-position" : "inside | outside | inherit",
3858
- "list-style-type" : "disc | circle | square | decimal | decimal-leading-zero | lower-roman | upper-roman | lower-greek | lower-latin | upper-latin | armenian | georgian | lower-alpha | upper-alpha | none | inherit",
3859
 
3860
- //M
3861
- "margin" : { multi: "<margin-width> | inherit", max: 4 },
3862
- "margin-bottom" : "<margin-width> | inherit",
3863
- "margin-left" : "<margin-width> | inherit",
3864
- "margin-right" : "<margin-width> | inherit",
3865
- "margin-top" : "<margin-width> | inherit",
3866
- "mark" : 1,
3867
- "mark-after" : 1,
3868
- "mark-before" : 1,
3869
- "marks" : 1,
3870
- "marquee-direction" : 1,
3871
- "marquee-play-count" : 1,
3872
- "marquee-speed" : 1,
3873
- "marquee-style" : 1,
3874
- "max-height" : "<length> | <percentage> | none | inherit",
3875
- "max-width" : "<length> | <percentage> | none | inherit",
3876
- "min-height" : "<length> | <percentage> | inherit",
3877
- "min-width" : "<length> | <percentage> | inherit",
3878
- "move-to" : 1,
3879
 
3880
- //N
3881
- "nav-down" : 1,
3882
- "nav-index" : 1,
3883
- "nav-left" : 1,
3884
- "nav-right" : 1,
3885
- "nav-up" : 1,
3886
 
3887
- //O
3888
- "opacity" : "<number> | inherit",
3889
- "orphans" : "<integer> | inherit",
3890
- "outline" : 1,
3891
- "outline-color" : "<color> | invert | inherit",
3892
- "outline-offset" : 1,
3893
- "outline-style" : "<border-style> | inherit",
3894
- "outline-width" : "<border-width> | inherit",
3895
- "overflow" : "visible | hidden | scroll | auto | inherit",
3896
- "overflow-style" : 1,
3897
- "overflow-x" : 1,
3898
- "overflow-y" : 1,
3899
 
3900
- //P
3901
- "padding" : { multi: "<padding-width> | inherit", max: 4 },
3902
- "padding-bottom" : "<padding-width> | inherit",
3903
- "padding-left" : "<padding-width> | inherit",
3904
- "padding-right" : "<padding-width> | inherit",
3905
- "padding-top" : "<padding-width> | inherit",
3906
- "page" : 1,
3907
- "page-break-after" : "auto | always | avoid | left | right | inherit",
3908
- "page-break-before" : "auto | always | avoid | left | right | inherit",
3909
- "page-break-inside" : "auto | avoid | inherit",
3910
- "page-policy" : 1,
3911
- "pause" : 1,
3912
- "pause-after" : 1,
3913
- "pause-before" : 1,
3914
- "perspective" : 1,
3915
- "perspective-origin" : 1,
3916
- "phonemes" : 1,
3917
- "pitch" : 1,
3918
- "pitch-range" : 1,
3919
- "play-during" : 1,
3920
- "pointer-events" : "auto | none | visiblePainted | visibleFill | visibleStroke | visible | painted | fill | stroke | all | inherit",
3921
- "position" : "static | relative | absolute | fixed | inherit",
3922
- "presentation-level" : 1,
3923
- "punctuation-trim" : 1,
3924
 
3925
- //Q
3926
- "quotes" : 1,
 
 
 
 
 
3927
 
3928
- //R
3929
- "rendering-intent" : 1,
3930
- "resize" : 1,
3931
- "rest" : 1,
3932
- "rest-after" : 1,
3933
- "rest-before" : 1,
3934
- "richness" : 1,
3935
- "right" : "<margin-width> | inherit",
3936
- "rotation" : 1,
3937
- "rotation-point" : 1,
3938
- "ruby-align" : 1,
3939
- "ruby-overhang" : 1,
3940
- "ruby-position" : 1,
3941
- "ruby-span" : 1,
3942
 
3943
- //S
3944
- "size" : 1,
3945
- "speak" : "normal | none | spell-out | inherit",
3946
- "speak-header" : "once | always | inherit",
3947
- "speak-numeral" : "digits | continuous | inherit",
3948
- "speak-punctuation" : "code | none | inherit",
3949
- "speech-rate" : 1,
3950
- "src" : 1,
3951
- "stress" : 1,
3952
- "string-set" : 1,
3953
 
3954
- "table-layout" : "auto | fixed | inherit",
3955
- "tab-size" : "<integer> | <length>",
3956
- "target" : 1,
3957
- "target-name" : 1,
3958
- "target-new" : 1,
3959
- "target-position" : 1,
3960
- "text-align" : "left | right | center | justify | inherit" ,
3961
- "text-align-last" : 1,
3962
- "text-decoration" : 1,
3963
- "text-emphasis" : 1,
3964
- "text-height" : 1,
3965
- "text-indent" : "<length> | <percentage> | inherit",
3966
- "text-justify" : "auto | none | inter-word | inter-ideograph | inter-cluster | distribute | kashida",
3967
- "text-outline" : 1,
3968
- "text-overflow" : 1,
3969
- "text-rendering" : "auto | optimizeSpeed | optimizeLegibility | geometricPrecision | inherit",
3970
- "text-shadow" : 1,
3971
- "text-transform" : "capitalize | uppercase | lowercase | none | inherit",
3972
- "text-wrap" : "normal | none | avoid",
3973
- "top" : "<margin-width> | inherit",
3974
- "transform" : 1,
3975
- "transform-origin" : 1,
3976
- "transform-style" : 1,
3977
- "transition" : 1,
3978
- "transition-delay" : 1,
3979
- "transition-duration" : 1,
3980
- "transition-property" : 1,
3981
- "transition-timing-function" : 1,
3982
 
3983
- //U
3984
- "unicode-bidi" : "normal | embed | bidi-override | inherit",
3985
- "user-modify" : "read-only | read-write | write-only | inherit",
3986
- "user-select" : "none | text | toggle | element | elements | all | inherit",
3987
 
3988
- //V
3989
- "vertical-align" : "auto | use-script | baseline | sub | super | top | text-top | central | middle | bottom | text-bottom | <percentage> | <length>",
3990
- "visibility" : "visible | hidden | collapse | inherit",
3991
- "voice-balance" : 1,
3992
- "voice-duration" : 1,
3993
- "voice-family" : 1,
3994
- "voice-pitch" : 1,
3995
- "voice-pitch-range" : 1,
3996
- "voice-rate" : 1,
3997
- "voice-stress" : 1,
3998
- "voice-volume" : 1,
3999
- "volume" : 1,
4000
 
4001
- //W
4002
- "white-space" : "normal | pre | nowrap | pre-wrap | pre-line | inherit | -pre-wrap | -o-pre-wrap | -moz-pre-wrap | -hp-pre-wrap", //http://perishablepress.com/wrapping-content/
4003
- "white-space-collapse" : 1,
4004
- "widows" : "<integer> | inherit",
4005
- "width" : "<length> | <percentage> | auto | inherit" ,
4006
- "word-break" : "normal | keep-all | break-all",
4007
- "word-spacing" : "<length> | normal | inherit",
4008
- "word-wrap" : 1,
4009
 
4010
- //Z
4011
- "z-index" : "<integer> | auto | inherit",
4012
- "zoom" : "<number> | <percentage> | normal"
4013
- };
4014
 
4015
- /*global SyntaxUnit, Parser*/
4016
- /**
4017
- * Represents a selector combinator (whitespace, +, >).
4018
- * @namespace parserlib.css
4019
- * @class PropertyName
4020
- * @extends parserlib.util.SyntaxUnit
4021
- * @constructor
4022
- * @param {String} text The text representation of the unit.
4023
- * @param {String} hack The type of IE hack applied ("*", "_", or null).
4024
- * @param {int} line The line of text on which the unit resides.
4025
- * @param {int} col The column of text on which the unit resides.
4026
- */
4027
- function PropertyName(text, hack, line, col){
4028
 
4029
- SyntaxUnit.call(this, text, line, col, Parser.PROPERTY_NAME_TYPE);
 
 
 
 
 
 
 
4030
 
4031
- /**
4032
- * The type of IE hack applied ("*", "_", or null).
4033
- * @type String
4034
- * @property hack
4035
- */
4036
- this.hack = hack;
4037
 
 
 
4038
  }
4039
 
4040
- PropertyName.prototype = new SyntaxUnit();
4041
- PropertyName.prototype.constructor = PropertyName;
4042
- PropertyName.prototype.toString = function(){
4043
- return (this.hack ? this.hack : "") + this.text;
4044
- };
4045
 
4046
- /*global SyntaxUnit, Parser*/
4047
- /**
4048
- * Represents a single part of a CSS property value, meaning that it represents
4049
- * just everything single part between ":" and ";". If there are multiple values
4050
- * separated by commas, this type represents just one of the values.
4051
- * @param {String[]} parts An array of value parts making up this value.
4052
- * @param {int} line The line of text on which the unit resides.
4053
- * @param {int} col The column of text on which the unit resides.
4054
- * @namespace parserlib.css
4055
- * @class PropertyValue
4056
- * @extends parserlib.util.SyntaxUnit
4057
- * @constructor
4058
- */
4059
- function PropertyValue(parts, line, col){
4060
 
4061
- SyntaxUnit.call(this, parts.join(" "), line, col, Parser.PROPERTY_VALUE_TYPE);
 
 
4062
 
4063
- /**
4064
- * The parts that make up the selector.
4065
- * @type Array
4066
- * @property parts
4067
- */
4068
- this.parts = parts;
4069
 
 
 
4070
  }
4071
 
4072
- PropertyValue.prototype = new SyntaxUnit();
4073
- PropertyValue.prototype.constructor = PropertyValue;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4074
 
4075
 
4076
- /*global SyntaxUnit, Parser*/
4077
  /**
4078
- * A utility class that allows for easy iteration over the various parts of a
4079
- * property value.
4080
- * @param {parserlib.css.PropertyValue} value The property value to iterate over.
4081
- * @namespace parserlib.css
4082
- * @class PropertyValueIterator
4083
  * @constructor
 
 
4084
  */
4085
- function PropertyValueIterator(value){
 
 
4086
 
4087
- /**
4088
- * Iterator value
4089
- * @type int
4090
- * @property _i
4091
- * @private
4092
- */
4093
- this._i = 0;
4094
 
4095
  /**
4096
- * The parts that make up the value.
4097
- * @type Array
4098
- * @property _parts
 
4099
  * @private
4100
  */
4101
- this._parts = value.parts;
4102
 
4103
- /**
4104
- * Keeps track of bookmarks along the way.
4105
- * @type Array
4106
- * @property _marks
4107
- * @private
4108
- */
4109
- this._marks = [];
4110
 
4111
- /**
4112
- * Holds the original property value.
4113
- * @type parserlib.css.PropertyValue
4114
- * @property value
4115
- */
4116
- this.value = value;
4117
 
4118
- }
4119
 
4120
- /**
4121
- * Returns the total number of parts in the value.
4122
- * @return {int} The total number of parts in the value.
4123
- * @method count
4124
- */
4125
- PropertyValueIterator.prototype.count = function(){
4126
- return this._parts.length;
4127
- };
4128
 
4129
- /**
4130
- * Indicates if the iterator is positioned at the first item.
4131
- * @return {Boolean} True if positioned at first item, false if not.
4132
- * @method isFirst
4133
- */
4134
- PropertyValueIterator.prototype.isFirst = function(){
4135
- return this._i === 0;
4136
- };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4137
 
4138
- /**
4139
- * Indicates if there are more parts of the property value.
4140
- * @return {Boolean} True if there are more parts, false if not.
4141
- * @method hasNext
4142
- */
4143
- PropertyValueIterator.prototype.hasNext = function(){
4144
- return (this._i < this._parts.length);
4145
- };
4146
 
4147
- /**
4148
- * Marks the current spot in the iteration so it can be restored to
4149
- * later on.
4150
- * @return {void}
4151
- * @method mark
4152
- */
4153
- PropertyValueIterator.prototype.mark = function(){
4154
- this._marks.push(this._i);
4155
- };
4156
 
4157
- /**
4158
- * Returns the next part of the property value or null if there is no next
4159
- * part. Does not move the internal counter forward.
4160
- * @return {parserlib.css.PropertyValuePart} The next part of the property value or null if there is no next
4161
- * part.
4162
- * @method peek
4163
- */
4164
- PropertyValueIterator.prototype.peek = function(count){
4165
- return this.hasNext() ? this._parts[this._i + (count || 0)] : null;
4166
- };
4167
 
4168
- /**
4169
- * Returns the next part of the property value or null if there is no next
4170
- * part.
4171
- * @return {parserlib.css.PropertyValuePart} The next part of the property value or null if there is no next
4172
- * part.
4173
- * @method next
4174
- */
4175
- PropertyValueIterator.prototype.next = function(){
4176
- return this.hasNext() ? this._parts[this._i++] : null;
4177
- };
4178
 
4179
- /**
4180
- * Returns the previous part of the property value or null if there is no
4181
- * previous part.
4182
- * @return {parserlib.css.PropertyValuePart} The previous part of the
4183
- * property value or null if there is no next part.
4184
- * @method previous
4185
- */
4186
- PropertyValueIterator.prototype.previous = function(){
4187
- return this._i > 0 ? this._parts[--this._i] : null;
4188
- };
 
 
4189
 
4190
- /**
4191
- * Restores the last saved bookmark.
4192
- * @return {void}
4193
- * @method restore
4194
- */
4195
- PropertyValueIterator.prototype.restore = function(){
4196
- if (this._marks.length){
4197
- this._i = this._marks.pop();
4198
- }
4199
- };
 
 
 
 
4200
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4201
 
4202
- /*global SyntaxUnit, Parser, Colors*/
4203
- /**
4204
- * Represents a single part of a CSS property value, meaning that it represents
4205
- * just one part of the data between ":" and ";".
4206
- * @param {String} text The text representation of the unit.
4207
- * @param {int} line The line of text on which the unit resides.
4208
- * @param {int} col The column of text on which the unit resides.
4209
- * @namespace parserlib.css
4210
- * @class PropertyValuePart
4211
- * @extends parserlib.util.SyntaxUnit
4212
- * @constructor
4213
- */
4214
- function PropertyValuePart(text, line, col){
4215
 
4216
- SyntaxUnit.call(this, text, line, col, Parser.PROPERTY_VALUE_PART_TYPE);
 
 
 
 
 
 
 
 
 
 
 
 
 
4217
 
4218
- /**
4219
- * Indicates the type of value unit.
4220
- * @type String
4221
- * @property type
4222
- */
4223
- this.type = "unknown";
4224
 
4225
- //figure out what type of data it is
 
 
 
4226
 
4227
- var temp;
 
 
4228
 
4229
- //it is a measurement?
4230
- if (/^([+\-]?[\d\.]+)([a-z]+)$/i.test(text)){ //dimension
4231
- this.type = "dimension";
4232
- this.value = +RegExp.$1;
4233
- this.units = RegExp.$2;
4234
 
4235
- //try to narrow down
4236
- switch(this.units.toLowerCase()){
 
4237
 
4238
- case "em":
4239
- case "rem":
4240
- case "ex":
4241
- case "px":
4242
- case "cm":
4243
- case "mm":
4244
- case "in":
4245
- case "pt":
4246
- case "pc":
4247
- case "ch":
4248
- case "vh":
4249
- case "vw":
4250
- case "vm":
4251
- this.type = "length";
4252
- break;
 
 
 
4253
 
4254
- case "deg":
4255
- case "rad":
4256
- case "grad":
4257
- this.type = "angle";
4258
- break;
 
 
 
 
 
 
 
4259
 
4260
- case "ms":
4261
- case "s":
4262
- this.type = "time";
4263
- break;
4264
 
4265
- case "hz":
4266
- case "khz":
4267
- this.type = "frequency";
4268
- break;
 
 
 
 
 
 
 
 
 
 
4269
 
4270
- case "dpi":
4271
- case "dpcm":
4272
- this.type = "resolution";
4273
- break;
 
 
 
 
4274
 
4275
- //default
 
 
 
4276
 
 
 
 
 
 
 
 
 
 
4277
  }
4278
 
4279
- } else if (/^([+\-]?[\d\.]+)%$/i.test(text)){ //percentage
4280
- this.type = "percentage";
4281
- this.value = +RegExp.$1;
4282
- } else if (/^([+\-]?[\d\.]+)%$/i.test(text)){ //percentage
4283
- this.type = "percentage";
4284
- this.value = +RegExp.$1;
4285
- } else if (/^([+\-]?\d+)$/i.test(text)){ //integer
4286
- this.type = "integer";
4287
- this.value = +RegExp.$1;
4288
- } else if (/^([+\-]?[\d\.]+)$/i.test(text)){ //number
4289
- this.type = "number";
4290
- this.value = +RegExp.$1;
4291
 
4292
- } else if (/^#([a-f0-9]{3,6})/i.test(text)){ //hexcolor
4293
- this.type = "color";
4294
- temp = RegExp.$1;
4295
- if (temp.length == 3){
4296
- this.red = parseInt(temp.charAt(0)+temp.charAt(0),16);
4297
- this.green = parseInt(temp.charAt(1)+temp.charAt(1),16);
4298
- this.blue = parseInt(temp.charAt(2)+temp.charAt(2),16);
 
 
 
 
 
 
 
 
 
4299
  } else {
4300
- this.red = parseInt(temp.substring(0,2),16);
4301
- this.green = parseInt(temp.substring(2,4),16);
4302
- this.blue = parseInt(temp.substring(4,6),16);
4303
  }
4304
- } else if (/^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/i.test(text)){ //rgb() color with absolute numbers
4305
- this.type = "color";
4306
- this.red = +RegExp.$1;
4307
- this.green = +RegExp.$2;
4308
- this.blue = +RegExp.$3;
4309
- } else if (/^rgb\(\s*(\d+)%\s*,\s*(\d+)%\s*,\s*(\d+)%\s*\)/i.test(text)){ //rgb() color with percentages
4310
- this.type = "color";
4311
- this.red = +RegExp.$1 * 255 / 100;
4312
- this.green = +RegExp.$2 * 255 / 100;
4313
- this.blue = +RegExp.$3 * 255 / 100;
4314
- } else if (/^rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*([\d\.]+)\s*\)/i.test(text)){ //rgba() color with absolute numbers
4315
- this.type = "color";
4316
- this.red = +RegExp.$1;
4317
- this.green = +RegExp.$2;
4318
- this.blue = +RegExp.$3;
4319
- this.alpha = +RegExp.$4;
4320
- } else if (/^rgba\(\s*(\d+)%\s*,\s*(\d+)%\s*,\s*(\d+)%\s*,\s*([\d\.]+)\s*\)/i.test(text)){ //rgba() color with percentages
4321
- this.type = "color";
4322
- this.red = +RegExp.$1 * 255 / 100;
4323
- this.green = +RegExp.$2 * 255 / 100;
4324
- this.blue = +RegExp.$3 * 255 / 100;
4325
- this.alpha = +RegExp.$4;
4326
- } else if (/^hsl\(\s*(\d+)\s*,\s*(\d+)%\s*,\s*(\d+)%\s*\)/i.test(text)){ //hsl()
4327
- this.type = "color";
4328
- this.hue = +RegExp.$1;
4329
- this.saturation = +RegExp.$2 / 100;
4330
- this.lightness = +RegExp.$3 / 100;
4331
- } else if (/^hsla\(\s*(\d+)\s*,\s*(\d+)%\s*,\s*(\d+)%\s*,\s*([\d\.]+)\s*\)/i.test(text)){ //hsla() color with percentages
4332
- this.type = "color";
4333
- this.hue = +RegExp.$1;
4334
- this.saturation = +RegExp.$2 / 100;
4335
- this.lightness = +RegExp.$3 / 100;
4336
- this.alpha = +RegExp.$4;
4337
- } else if (/^url\(["']?([^\)"']+)["']?\)/i.test(text)){ //URI
4338
- this.type = "uri";
4339
- this.uri = RegExp.$1;
4340
- } else if (/^([^\(]+)\(/i.test(text)){
4341
- this.type = "function";
4342
- this.name = RegExp.$1;
4343
- this.value = text;
4344
- } else if (/^["'][^"']*["']/.test(text)){ //string
4345
- this.type = "string";
4346
- this.value = eval(text);
4347
- } else if (Colors[text.toLowerCase()]){ //named color
4348
- this.type = "color";
4349
- temp = Colors[text.toLowerCase()].substring(1);
4350
- this.red = parseInt(temp.substring(0,2),16);
4351
- this.green = parseInt(temp.substring(2,4),16);
4352
- this.blue = parseInt(temp.substring(4,6),16);
4353
- } else if (/^[\,\/]$/.test(text)){
4354
- this.type = "operator";
4355
- this.value = text;
4356
- } else if (/^[a-z\-\u0080-\uFFFF][a-z0-9\-\u0080-\uFFFF]*$/i.test(text)){
4357
- this.type = "identifier";
4358
- this.value = text;
4359
- }
4360
 
4361
- }
 
4362
 
4363
- PropertyValuePart.prototype = new SyntaxUnit();
4364
- PropertyValuePart.prototype.constructor = PropertyValuePart;
 
 
 
 
 
 
 
 
 
 
4365
 
4366
- /**
4367
- * Create a new syntax unit based solely on the given token.
4368
- * Convenience method for creating a new syntax unit when
4369
- * it represents a single token instead of multiple.
4370
- * @param {Object} token The token object to represent.
4371
- * @return {parserlib.css.PropertyValuePart} The object representing the token.
4372
- * @static
4373
- * @method fromToken
4374
- */
4375
- PropertyValuePart.fromToken = function(token){
4376
- return new PropertyValuePart(token.value, token.startLine, token.startCol);
4377
- };
4378
- var Pseudos = {
4379
- ":first-letter": 1,
4380
- ":first-line": 1,
4381
- ":before": 1,
4382
- ":after": 1
4383
- };
4384
 
4385
- Pseudos.ELEMENT = 1;
4386
- Pseudos.CLASS = 2;
 
 
 
 
 
 
 
 
 
 
 
 
4387
 
4388
- Pseudos.isElement = function(pseudo){
4389
- return pseudo.indexOf("::") === 0 || Pseudos[pseudo.toLowerCase()] == Pseudos.ELEMENT;
4390
- };
4391
- /*global SyntaxUnit, Parser, Specificity*/
4392
- /**
4393
- * Represents an entire single selector, including all parts but not
4394
- * including multiple selectors (those separated by commas).
4395
- * @namespace parserlib.css
4396
- * @class Selector
4397
- * @extends parserlib.util.SyntaxUnit
4398
- * @constructor
4399
- * @param {Array} parts Array of selectors parts making up this selector.
4400
- * @param {int} line The line of text on which the unit resides.
4401
- * @param {int} col The column of text on which the unit resides.
4402
- */
4403
- function Selector(parts, line, col){
4404
 
4405
- SyntaxUnit.call(this, parts.join(" "), line, col, Parser.SELECTOR_TYPE);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4406
 
4407
  /**
4408
- * The parts that make up the selector.
4409
- * @type Array
4410
- * @property parts
 
 
 
 
 
4411
  */
4412
- this.parts = parts;
 
 
 
 
 
 
 
 
 
 
 
 
 
4413
 
4414
  /**
4415
- * The specificity of the selector.
4416
- * @type parserlib.css.Specificity
4417
- * @property specificity
 
 
 
 
 
4418
  */
4419
- this.specificity = Specificity.calculate(this);
 
 
4420
 
4421
- }
 
4422
 
4423
- Selector.prototype = new SyntaxUnit();
4424
- Selector.prototype.constructor = Selector;
 
 
 
 
 
4425
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4426
 
4427
- /*global SyntaxUnit, Parser*/
4428
- /**
4429
- * Represents a single part of a selector string, meaning a single set of
4430
- * element name and modifiers. This does not include combinators such as
4431
- * spaces, +, >, etc.
4432
- * @namespace parserlib.css
4433
- * @class SelectorPart
4434
- * @extends parserlib.util.SyntaxUnit
4435
- * @constructor
4436
- * @param {String} elementName The element name in the selector or null
4437
- * if there is no element name.
4438
- * @param {Array} modifiers Array of individual modifiers for the element.
4439
- * May be empty if there are none.
4440
- * @param {String} text The text representation of the unit.
4441
- * @param {int} line The line of text on which the unit resides.
4442
- * @param {int} col The column of text on which the unit resides.
4443
- */
4444
- function SelectorPart(elementName, modifiers, text, line, col){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4445
 
4446
- SyntaxUnit.call(this, text, line, col, Parser.SELECTOR_PART_TYPE);
 
4447
 
4448
- /**
4449
- * The tag name of the element to which this part
4450
- * of the selector affects.
4451
- * @type String
4452
- * @property elementName
4453
- */
4454
- this.elementName = elementName;
4455
 
4456
- /**
4457
- * The parts that come after the element name, such as class names, IDs,
4458
- * pseudo classes/elements, etc.
4459
- * @type Array
4460
- * @property modifiers
4461
- */
4462
- this.modifiers = modifiers;
4463
 
4464
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4465
 
4466
- SelectorPart.prototype = new SyntaxUnit();
4467
- SelectorPart.prototype.constructor = SelectorPart;
 
 
 
4468
 
 
 
4469
 
4470
- /*global SyntaxUnit, Parser*/
4471
- /**
4472
- * Represents a selector modifier string, meaning a class name, element name,
4473
- * element ID, pseudo rule, etc.
4474
- * @namespace parserlib.css
4475
- * @class SelectorSubPart
4476
- * @extends parserlib.util.SyntaxUnit
4477
- * @constructor
4478
- * @param {String} text The text representation of the unit.
4479
- * @param {String} type The type of selector modifier.
4480
- * @param {int} line The line of text on which the unit resides.
4481
- * @param {int} col The column of text on which the unit resides.
4482
- */
4483
- function SelectorSubPart(text, type, line, col){
4484
 
4485
- SyntaxUnit.call(this, text, line, col, Parser.SELECTOR_SUB_PART_TYPE);
 
4486
 
4487
  /**
4488
- * The type of modifier.
4489
- * @type String
4490
- * @property type
 
 
 
 
 
4491
  */
4492
- this.type = type;
 
 
 
 
 
 
 
 
 
 
 
 
 
4493
 
4494
  /**
4495
- * Some subparts have arguments, this represents them.
4496
- * @type Array
4497
- * @property args
 
 
 
 
 
 
4498
  */
4499
- this.args = [];
4500
-
4501
- }
 
 
 
4502
 
4503
- SelectorSubPart.prototype = new SyntaxUnit();
4504
- SelectorSubPart.prototype.constructor = SelectorSubPart;
 
4505
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4506
 
4507
- /*global Pseudos, SelectorPart*/
4508
- /**
4509
- * Represents a selector's specificity.
4510
- * @namespace parserlib.css
4511
- * @class Specificity
4512
- * @constructor
4513
- * @param {int} a Should be 1 for inline styles, zero for stylesheet styles
4514
- * @param {int} b Number of ID selectors
4515
- * @param {int} c Number of classes and pseudo classes
4516
- * @param {int} d Number of element names and pseudo elements
4517
- */
4518
- function Specificity(a, b, c, d){
4519
- this.a = a;
4520
- this.b = b;
4521
- this.c = c;
4522
- this.d = d;
4523
- }
4524
 
4525
- Specificity.prototype = {
4526
- constructor: Specificity,
4527
 
4528
  /**
4529
- * Compare this specificity to another.
4530
- * @param {Specificity} other The other specificity to compare to.
4531
- * @return {int} -1 if the other specificity is larger, 1 if smaller, 0 if equal.
4532
- * @method compare
 
 
 
 
 
 
 
4533
  */
4534
- compare: function(other){
4535
- var comps = ["a", "b", "c", "d"],
4536
- i, len;
 
 
 
 
4537
 
4538
- for (i=0, len=comps.length; i < len; i++){
4539
- if (this[comps[i]] < other[comps[i]]){
4540
- return -1;
4541
- } else if (this[comps[i]] > other[comps[i]]){
4542
- return 1;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4543
  }
 
4544
  }
4545
 
4546
- return 0;
4547
- },
 
 
4548
 
4549
- /**
4550
- * Creates a numeric value for the specificity.
4551
- * @return {int} The numeric value for the specificity.
4552
- * @method valueOf
4553
- */
4554
- valueOf: function(){
4555
- return (this.a * 1000) + (this.b * 100) + (this.c * 10) + this.d;
4556
  },
4557
 
4558
- /**
4559
- * Returns a string representation for specificity.
4560
- * @return {String} The string representation of specificity.
4561
- * @method toString
4562
- */
4563
- toString: function(){
4564
- return this.a + "," + this.b + "," + this.c + "," + this.d;
4565
- }
4566
 
4567
- };
 
 
 
 
4568
 
4569
- /**
4570
- * Calculates the specificity of the given selector.
4571
- * @param {parserlib.css.Selector} The selector to calculate specificity for.
4572
- * @return {parserlib.css.Specificity} The specificity of the selector.
4573
- * @static
4574
- * @method calculate
4575
- */
4576
- Specificity.calculate = function(selector){
4577
 
4578
- var i, len,
4579
- part,
4580
- b=0, c=0, d=0;
4581
 
4582
- function updateValues(part){
 
4583
 
4584
- var i, j, len, num,
4585
- elementName = part.elementName ? part.elementName.text : "",
4586
- modifier;
 
4587
 
4588
- if (elementName && elementName.charAt(elementName.length-1) != "*") {
4589
- d++;
 
 
 
 
 
 
 
 
4590
  }
4591
 
4592
- for (i=0, len=part.modifiers.length; i < len; i++){
4593
- modifier = part.modifiers[i];
4594
- switch(modifier.type){
4595
- case "class":
4596
- case "attribute":
4597
- c++;
4598
- break;
4599
 
4600
- case "id":
4601
- b++;
4602
- break;
 
 
 
 
 
 
 
 
 
 
 
4603
 
4604
- case "pseudo":
4605
- if (Pseudos.isElement(modifier.text)){
4606
- d++;
4607
- } else {
4608
- c++;
4609
- }
4610
- break;
4611
 
4612
- case "not":
4613
- for (j=0, num=modifier.args.length; j < num; j++){
4614
- updateValues(modifier.args[j]);
4615
- }
4616
- }
4617
- }
4618
- }
4619
 
4620
- for (i=0, len=selector.parts.length; i < len; i++){
4621
- part = selector.parts[i];
 
 
4622
 
4623
- if (part instanceof SelectorPart){
4624
- updateValues(part);
 
 
 
4625
  }
4626
- }
4627
 
4628
- return new Specificity(0, b, c, d);
4629
- };
 
 
 
 
 
 
4630
 
4631
- /*global Tokens, TokenStreamBase*/
4632
 
4633
- var h = /^[0-9a-fA-F]$/,
4634
- nonascii = /^[\u0080-\uFFFF]$/,
4635
- nl = /\n|\r\n|\r|\f/;
4636
 
4637
- //-----------------------------------------------------------------------------
4638
- // Helper functions
4639
- //-----------------------------------------------------------------------------
 
4640
 
 
 
 
 
 
4641
 
4642
- function isHexDigit(c){
4643
- return c !== null && h.test(c);
4644
- }
 
 
 
 
4645
 
4646
- function isDigit(c){
4647
- return c !== null && /\d/.test(c);
4648
- }
4649
 
4650
- function isWhitespace(c){
4651
- return c !== null && /\s/.test(c);
4652
- }
 
 
 
 
 
 
 
 
 
 
4653
 
4654
- function isNewLine(c){
4655
- return c !== null && nl.test(c);
4656
- }
4657
 
4658
- function isNameStart(c){
4659
- return c !== null && (/[a-z_\u0080-\uFFFF\\]/i.test(c));
4660
- }
4661
 
4662
- function isNameChar(c){
4663
- return c !== null && (isNameStart(c) || /[0-9\-\\]/.test(c));
4664
- }
 
 
4665
 
4666
- function isIdentStart(c){
4667
- return c !== null && (isNameStart(c) || /\-\\/.test(c));
4668
- }
 
 
 
4669
 
4670
- function mix(receiver, supplier){
4671
- for (var prop in supplier){
4672
- if (supplier.hasOwnProperty(prop)){
4673
- receiver[prop] = supplier[prop];
4674
  }
4675
- }
4676
- return receiver;
4677
- }
4678
 
4679
- //-----------------------------------------------------------------------------
4680
- // CSS Token Stream
4681
- //-----------------------------------------------------------------------------
4682
-
4683
-
4684
- /**
4685
- * A token stream that produces CSS tokens.
4686
- * @param {String|Reader} input The source of text to tokenize.
4687
- * @constructor
4688
- * @class TokenStream
4689
- * @namespace parserlib.css
4690
- */
4691
- function TokenStream(input){
4692
- TokenStreamBase.call(this, input, Tokens);
4693
- }
4694
 
4695
- TokenStream.prototype = mix(new TokenStreamBase(), {
4696
 
4697
- /**
4698
- * Overrides the TokenStreamBase method of the same name
4699
- * to produce CSS tokens.
4700
- * @param {variant} channel The name of the channel to use
4701
- * for the next token.
4702
- * @return {Object} A token object representing the next token.
4703
- * @method _getToken
4704
- * @private
4705
- */
4706
- _getToken: function(channel){
4707
 
4708
- var c,
4709
- reader = this._reader,
4710
- token = null,
4711
- startLine = reader.getLine(),
4712
- startCol = reader.getCol();
 
 
 
4713
 
4714
- c = reader.read();
 
 
 
 
 
 
4715
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4716
 
4717
- while(c){
4718
- switch(c){
4719
 
4720
- /*
4721
- * Potential tokens:
4722
- * - COMMENT
4723
- * - SLASH
4724
- * - CHAR
4725
- */
4726
- case "/":
4727
 
4728
- if(reader.peek() == "*"){
4729
- token = this.commentToken(c, startLine, startCol);
4730
- } else {
4731
- token = this.charToken(c, startLine, startCol);
4732
- }
 
4733
  break;
 
 
 
 
 
 
 
4734
 
4735
- /*
4736
- * Potential tokens:
4737
- * - DASHMATCH
4738
- * - INCLUDES
4739
- * - PREFIXMATCH
4740
- * - SUFFIXMATCH
4741
- * - SUBSTRINGMATCH
4742
- * - CHAR
4743
- */
4744
- case "|":
4745
- case "~":
4746
- case "^":
4747
- case "$":
4748
- case "*":
4749
- if(reader.peek() == "="){
4750
- token = this.comparisonToken(c, startLine, startCol);
4751
- } else {
4752
- token = this.charToken(c, startLine, startCol);
4753
- }
4754
- break;
4755
 
4756
- /*
4757
- * Potential tokens:
4758
- * - STRING
4759
- * - INVALID
4760
- */
4761
- case "\"":
4762
- case "'":
4763
- token = this.stringToken(c, startLine, startCol);
4764
- break;
4765
 
4766
- /*
4767
- * Potential tokens:
4768
- * - HASH
4769
- * - CHAR
4770
- */
4771
- case "#":
4772
- if (isNameChar(reader.peek())){
4773
- token = this.hashToken(c, startLine, startCol);
4774
- } else {
4775
- token = this.charToken(c, startLine, startCol);
4776
- }
4777
- break;
4778
 
4779
- /*
4780
- * Potential tokens:
4781
- * - DOT
4782
- * - NUMBER
4783
- * - DIMENSION
4784
- * - PERCENTAGE
4785
- */
4786
- case ".":
4787
- if (isDigit(reader.peek())){
4788
- token = this.numberToken(c, startLine, startCol);
4789
- } else {
4790
- token = this.charToken(c, startLine, startCol);
4791
- }
4792
- break;
 
 
 
 
 
 
 
4793
 
4794
- /*
4795
- * Potential tokens:
4796
- * - CDC
4797
- * - MINUS
4798
- * - NUMBER
4799
- * - DIMENSION
4800
- * - PERCENTAGE
4801
- */
4802
- case "-":
4803
- if (reader.peek() == "-"){ //could be closing HTML-style comment
4804
- token = this.htmlCommentEndToken(c, startLine, startCol);
4805
- } else if (isNameStart(reader.peek())){
4806
- token = this.identOrFunctionToken(c, startLine, startCol);
4807
- } else {
4808
- token = this.charToken(c, startLine, startCol);
4809
- }
4810
- break;
4811
 
4812
- /*
4813
- * Potential tokens:
4814
- * - IMPORTANT_SYM
4815
- * - CHAR
4816
- */
4817
- case "!":
4818
- token = this.importantToken(c, startLine, startCol);
4819
- break;
4820
 
4821
- /*
4822
- * Any at-keyword or CHAR
4823
- */
4824
- case "@":
4825
- token = this.atRuleToken(c, startLine, startCol);
4826
  break;
 
4827
 
4828
- /*
4829
- * Potential tokens:
4830
- * - NOT
4831
- * - CHAR
4832
- */
4833
- case ":":
4834
- token = this.notToken(c, startLine, startCol);
4835
- break;
4836
 
4837
- /*
4838
- * Potential tokens:
4839
- * - CDO
4840
- * - CHAR
4841
- */
4842
- case "<":
4843
- token = this.htmlCommentStartToken(c, startLine, startCol);
4844
- break;
4845
 
4846
- /*
4847
- * Potential tokens:
4848
- * - UNICODE_RANGE
4849
- * - URL
4850
- * - CHAR
4851
- */
4852
- case "U":
4853
- case "u":
4854
- if (reader.peek() == "+"){
4855
- token = this.unicodeRangeToken(c, startLine, startCol);
4856
- break;
4857
- }
4858
- /* falls through */
4859
- default:
4860
 
4861
- /*
4862
- * Potential tokens:
4863
- * - NUMBER
4864
- * - DIMENSION
4865
- * - LENGTH
4866
- * - FREQ
4867
- * - TIME
4868
- * - EMS
4869
- * - EXS
4870
- * - ANGLE
4871
- */
4872
- if (isDigit(c)){
4873
- token = this.numberToken(c, startLine, startCol);
4874
- } else
4875
 
4876
- /*
4877
- * Potential tokens:
4878
- * - S
4879
- */
4880
- if (isWhitespace(c)){
4881
- token = this.whitespaceToken(c, startLine, startCol);
4882
- } else
4883
 
4884
- /*
4885
- * Potential tokens:
4886
- * - IDENT
4887
- */
4888
- if (isIdentStart(c)){
4889
- token = this.identOrFunctionToken(c, startLine, startCol);
4890
- } else
4891
 
4892
- /*
4893
- * Potential tokens:
4894
- * - CHAR
4895
- * - PLUS
4896
- */
4897
- {
4898
- token = this.charToken(c, startLine, startCol);
4899
- }
4900
 
 
 
 
4901
 
 
 
 
4902
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4903
 
 
 
4904
 
 
 
4905
 
4906
- }
 
 
 
 
 
 
 
4907
 
4908
- //make sure this token is wanted
4909
- //TODO: check channel
4910
- break;
4911
- }
4912
 
4913
- if (!token && c === null){
4914
- token = this.createToken(Tokens.EOF,null,startLine,startCol);
4915
- }
4916
 
4917
- return token;
4918
- },
 
4919
 
4920
- //-------------------------------------------------------------------------
4921
- // Methods to create tokens
4922
- //-------------------------------------------------------------------------
4923
 
4924
- /**
4925
- * Produces a token based on available data and the current
4926
- * reader position information. This method is called by other
4927
- * private methods to create tokens and is never called directly.
4928
- * @param {int} tt The token type.
4929
- * @param {String} value The text value of the token.
4930
- * @param {int} startLine The beginning line for the character.
4931
- * @param {int} startCol The beginning column for the character.
4932
- * @param {Object} options (Optional) Specifies a channel property
4933
- * to indicate that a different channel should be scanned
4934
- * and/or a hide property indicating that the token should
4935
- * be hidden.
4936
- * @return {Object} A token object.
4937
- * @method createToken
4938
  */
4939
- createToken: function(tt, value, startLine, startCol, options){
4940
- var reader = this._reader;
4941
- options = options || {};
 
 
 
 
 
 
 
 
 
 
 
 
 
4942
 
4943
- return {
4944
- value: value,
4945
- type: tt,
4946
- channel: options.channel,
4947
- hide: options.hide || false,
4948
- startLine: startLine,
4949
- startCol: startCol,
4950
- endLine: reader.getLine(),
4951
- endCol: reader.getCol()
4952
- };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4953
  },
4954
 
4955
- //-------------------------------------------------------------------------
4956
- // Methods to create specific tokens
4957
- //-------------------------------------------------------------------------
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4958
 
4959
- /**
4960
- * Produces a token for any at-rule. If the at-rule is unknown, then
4961
- * the token is for a single "@" character.
4962
- * @param {String} first The first character for the token.
4963
- * @param {int} startLine The beginning line for the character.
4964
- * @param {int} startCol The beginning column for the character.
4965
- * @return {Object} A token object.
4966
- * @method atRuleToken
4967
- */
4968
- atRuleToken: function(first, startLine, startCol){
4969
- var rule = first,
4970
- reader = this._reader,
4971
- tt = Tokens.CHAR,
4972
- valid = false,
4973
- ident,
4974
- c;
4975
 
4976
- /*
4977
- * First, mark where we are. There are only four @ rules,
4978
- * so anything else is really just an invalid token.
4979
- * Basically, if this doesn't match one of the known @
4980
- * rules, just return '@' as an unknown token and allow
4981
- * parsing to continue after that point.
4982
- */
4983
- reader.mark();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4984
 
4985
- //try to find the at-keyword
4986
- ident = this.readName();
4987
- rule = first + ident;
4988
- tt = Tokens.type(rule.toLowerCase());
 
4989
 
4990
- //if it's not valid, use the first character only and reset the reader
4991
- if (tt == Tokens.CHAR || tt == Tokens.UNKNOWN){
4992
- if (rule.length > 1){
4993
- tt = Tokens.UNKNOWN_SYM;
4994
- } else {
4995
- tt = Tokens.CHAR;
4996
- rule = first;
4997
- reader.reset();
4998
  }
 
 
 
 
4999
  }
5000
 
5001
- return this.createToken(tt, rule, startLine, startCol);
5002
  },
5003
 
5004
- /**
5005
- * Produces a character token based on the given character
5006
- * and location in the stream. If there's a special (non-standard)
5007
- * token name, this is used; otherwise CHAR is used.
5008
- * @param {String} c The character for the token.
5009
- * @param {int} startLine The beginning line for the character.
5010
- * @param {int} startCol The beginning column for the character.
5011
- * @return {Object} A token object.
5012
- * @method charToken
5013
- */
5014
- charToken: function(c, startLine, startCol){
5015
- var tt = Tokens.type(c);
5016
 
5017
- if (tt == -1){
5018
- tt = Tokens.CHAR;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5019
  }
5020
 
5021
- return this.createToken(tt, c, startLine, startCol);
5022
- },
5023
 
5024
- /**
5025
- * Produces a character token based on the given character
5026
- * and location in the stream. If there's a special (non-standard)
5027
- * token name, this is used; otherwise CHAR is used.
5028
- * @param {String} first The first character for the token.
5029
- * @param {int} startLine The beginning line for the character.
5030
- * @param {int} startCol The beginning column for the character.
5031
- * @return {Object} A token object.
5032
- * @method commentToken
5033
- */
5034
- commentToken: function(first, startLine, startCol){
5035
- var reader = this._reader,
5036
- comment = this.readComment(first);
5037
 
5038
- return this.createToken(Tokens.COMMENT, comment, startLine, startCol);
5039
- },
5040
 
5041
- /**
5042
- * Produces a comparison token based on the given character
5043
- * and location in the stream. The next character must be
5044
- * read and is already known to be an equals sign.
5045
- * @param {String} c The character for the token.
5046
- * @param {int} startLine The beginning line for the character.
5047
- * @param {int} startCol The beginning column for the character.
5048
- * @return {Object} A token object.
5049
- * @method comparisonToken
5050
- */
5051
- comparisonToken: function(c, startLine, startCol){
5052
- var reader = this._reader,
5053
- comparison = c + reader.read(),
5054
- tt = Tokens.type(comparison) || Tokens.CHAR;
5055
 
5056
- return this.createToken(tt, comparison, startLine, startCol);
5057
- },
 
 
 
 
 
 
 
 
5058
 
5059
  /**
5060
- * Produces a hash token based on the specified information. The
5061
- * first character provided is the pound sign (#) and then this
5062
- * method reads a name afterward.
5063
- * @param {String} first The first character (#) in the hash name.
5064
- * @param {int} startLine The beginning line for the character.
5065
- * @param {int} startCol The beginning column for the character.
5066
- * @return {Object} A token object.
5067
- * @method hashToken
5068
  */
5069
- hashToken: function(first, startLine, startCol){
5070
- var reader = this._reader,
5071
- name = this.readName(first);
5072
 
5073
- return this.createToken(Tokens.HASH, name, startLine, startCol);
5074
- },
 
 
 
 
5075
 
5076
  /**
5077
- * Produces a CDO or CHAR token based on the specified information. The
5078
- * first character is provided and the rest is read by the function to determine
5079
- * the correct token to create.
5080
- * @param {String} first The first character in the token.
5081
- * @param {int} startLine The beginning line for the character.
5082
- * @param {int} startCol The beginning column for the character.
5083
- * @return {Object} A token object.
5084
- * @method htmlCommentStartToken
5085
  */
5086
- htmlCommentStartToken: function(first, startLine, startCol){
5087
- var reader = this._reader,
5088
- text = first;
5089
 
5090
- reader.mark();
5091
- text += reader.readCount(3);
5092
 
5093
- if (text == "<!--"){
5094
- return this.createToken(Tokens.CDO, text, startLine, startCol);
5095
- } else {
5096
- reader.reset();
5097
- return this.charToken(first, startLine, startCol);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5098
  }
 
 
5099
  },
5100
 
5101
- /**
5102
- * Produces a CDC or CHAR token based on the specified information. The
5103
- * first character is provided and the rest is read by the function to determine
5104
- * the correct token to create.
5105
- * @param {String} first The first character in the token.
5106
- * @param {int} startLine The beginning line for the character.
5107
- * @param {int} startCol The beginning column for the character.
5108
- * @return {Object} A token object.
5109
- * @method htmlCommentEndToken
5110
- */
5111
- htmlCommentEndToken: function(first, startLine, startCol){
5112
- var reader = this._reader,
5113
- text = first;
5114
 
5115
- reader.mark();
5116
- text += reader.readCount(2);
 
5117
 
5118
- if (text == "-->"){
5119
- return this.createToken(Tokens.CDC, text, startLine, startCol);
5120
- } else {
5121
- reader.reset();
5122
- return this.charToken(first, startLine, startCol);
5123
  }
 
5124
  },
5125
 
5126
  /**
5127
- * Produces an IDENT or FUNCTION token based on the specified information. The
5128
- * first character is provided and the rest is read by the function to determine
5129
- * the correct token to create.
5130
- * @param {String} first The first character in the identifier.
5131
- * @param {int} startLine The beginning line for the character.
5132
- * @param {int} startCol The beginning column for the character.
5133
- * @return {Object} A token object.
5134
- * @method identOrFunctionToken
5135
  */
5136
- identOrFunctionToken: function(first, startLine, startCol){
5137
- var reader = this._reader,
5138
- ident = this.readName(first),
5139
- tt = Tokens.IDENT;
5140
-
5141
- //if there's a left paren immediately after, it's a URI or function
5142
- if (reader.peek() == "("){
5143
- ident += reader.read();
5144
- if (ident.toLowerCase() == "url("){
5145
- tt = Tokens.URI;
5146
- ident = this.readURI(ident);
5147
-
5148
- //didn't find a valid URL or there's no closing paren
5149
- if (ident.toLowerCase() == "url("){
5150
- tt = Tokens.FUNCTION;
5151
- }
5152
- } else {
5153
- tt = Tokens.FUNCTION;
5154
- }
5155
- } else if (reader.peek() == ":"){ //might be an IE function
5156
 
5157
- //IE-specific functions always being with progid:
5158
- if (ident.toLowerCase() == "progid"){
5159
- ident += reader.readTo("(");
5160
- tt = Tokens.IE_FUNCTION;
5161
- }
5162
  }
5163
 
5164
- return this.createToken(tt, ident, startLine, startCol);
5165
  },
5166
 
5167
  /**
5168
- * Produces an IMPORTANT_SYM or CHAR token based on the specified information. The
5169
- * first character is provided and the rest is read by the function to determine
5170
- * the correct token to create.
5171
- * @param {String} first The first character in the token.
5172
- * @param {int} startLine The beginning line for the character.
5173
- * @param {int} startCol The beginning column for the character.
5174
- * @return {Object} A token object.
5175
- * @method importantToken
5176
  */
5177
- importantToken: function(first, startLine, startCol){
5178
- var reader = this._reader,
5179
- important = first,
5180
- tt = Tokens.CHAR,
5181
- temp,
5182
- c;
5183
-
5184
- reader.mark();
5185
- c = reader.read();
5186
 
5187
- while(c){
 
 
5188
 
5189
- //there can be a comment in here
5190
- if (c == "/"){
5191
 
5192
- //if the next character isn't a star, then this isn't a valid !important token
5193
- if (reader.peek() != "*"){
5194
- break;
5195
- } else {
5196
- temp = this.readComment(c);
5197
- if (temp === ""){ //broken!
5198
- break;
5199
- }
5200
- }
5201
- } else if (isWhitespace(c)){
5202
- important += c + this.readWhitespace();
5203
- } else if (/i/i.test(c)){
5204
- temp = reader.readCount(8);
5205
- if (/mportant/i.test(temp)){
5206
- important += c + temp;
5207
- tt = Tokens.IMPORTANT_SYM;
5208
 
5209
- }
5210
- break; //we're done
5211
- } else {
5212
- break;
 
 
 
 
 
5213
  }
5214
-
5215
- c = reader.read();
5216
- }
5217
-
5218
- if (tt == Tokens.CHAR){
5219
- reader.reset();
5220
- return this.charToken(first, startLine, startCol);
5221
  } else {
5222
- return this.createToken(tt, important, startLine, startCol);
5223
  }
5224
 
5225
-
5226
  },
5227
 
5228
- /**
5229
- * Produces a NOT or CHAR token based on the specified information. The
5230
- * first character is provided and the rest is read by the function to determine
5231
- * the correct token to create.
5232
- * @param {String} first The first character in the token.
5233
- * @param {int} startLine The beginning line for the character.
5234
- * @param {int} startCol The beginning column for the character.
5235
- * @return {Object} A token object.
5236
- * @method notToken
5237
- */
5238
- notToken: function(first, startLine, startCol){
5239
- var reader = this._reader,
5240
- text = first;
5241
 
5242
- reader.mark();
5243
- text += reader.readCount(4);
5244
 
5245
- if (text.toLowerCase() == ":not("){
5246
- return this.createToken(Tokens.NOT, text, startLine, startCol);
5247
- } else {
5248
- reader.reset();
5249
- return this.charToken(first, startLine, startCol);
5250
- }
5251
- },
5252
 
5253
- /**
5254
- * Produces a number token based on the given character
5255
- * and location in the stream. This may return a token of
5256
- * NUMBER, EMS, EXS, LENGTH, ANGLE, TIME, FREQ, DIMENSION,
5257
- * or PERCENTAGE.
5258
- * @param {String} first The first character for the token.
5259
- * @param {int} startLine The beginning line for the character.
5260
- * @param {int} startCol The beginning column for the character.
5261
- * @return {Object} A token object.
5262
- * @method numberToken
5263
- */
5264
- numberToken: function(first, startLine, startCol){
5265
- var reader = this._reader,
5266
- value = this.readNumber(first),
5267
- ident,
5268
- tt = Tokens.NUMBER,
5269
- c = reader.peek();
5270
 
5271
- if (isIdentStart(c)){
5272
- ident = this.readName(reader.read());
5273
- value += ident;
 
5274
 
5275
- if (/^em$|^ex$|^px$|^gd$|^rem$|^vw$|^vh$|^vm$|^ch$|^cm$|^mm$|^in$|^pt$|^pc$/i.test(ident)){
5276
- tt = Tokens.LENGTH;
5277
- } else if (/^deg|^rad$|^grad$/i.test(ident)){
5278
- tt = Tokens.ANGLE;
5279
- } else if (/^ms$|^s$/i.test(ident)){
5280
- tt = Tokens.TIME;
5281
- } else if (/^hz$|^khz$/i.test(ident)){
5282
- tt = Tokens.FREQ;
5283
- } else if (/^dpi$|^dpcm$/i.test(ident)){
5284
- tt = Tokens.RESOLUTION;
5285
- } else {
5286
- tt = Tokens.DIMENSION;
5287
- }
5288
 
5289
- } else if (c == "%"){
5290
- value += reader.read();
5291
- tt = Tokens.PERCENTAGE;
5292
- }
5293
 
5294
- return this.createToken(tt, value, startLine, startCol);
5295
- },
5296
 
5297
- /**
5298
- * Produces a string token based on the given character
5299
- * and location in the stream. Since strings may be indicated
5300
- * by single or double quotes, a failure to match starting
5301
- * and ending quotes results in an INVALID token being generated.
5302
- * The first character in the string is passed in and then
5303
- * the rest are read up to and including the final quotation mark.
5304
- * @param {String} first The first character in the string.
5305
- * @param {int} startLine The beginning line for the character.
5306
- * @param {int} startCol The beginning column for the character.
5307
- * @return {Object} A token object.
5308
- * @method stringToken
5309
- */
5310
- stringToken: function(first, startLine, startCol){
5311
- var delim = first,
5312
- string = first,
5313
- reader = this._reader,
5314
- prev = first,
5315
- tt = Tokens.STRING,
5316
- c = reader.read();
5317
 
5318
- while(c){
5319
- string += c;
5320
 
5321
- //if the delimiter is found with an escapement, we're done.
5322
- if (c == delim && prev != "\\"){
5323
- break;
5324
- }
5325
 
5326
- //if there's a newline without an escapement, it's an invalid string
5327
- if (isNewLine(reader.peek()) && c != "\\"){
5328
- tt = Tokens.INVALID;
5329
- break;
5330
- }
5331
 
5332
- //save previous and get next
5333
- prev = c;
5334
- c = reader.read();
5335
- }
5336
 
5337
- //if c is null, that means we're out of input and the string was never closed
5338
- if (c === null){
5339
- tt = Tokens.INVALID;
5340
- }
5341
 
5342
- return this.createToken(tt, string, startLine, startCol);
5343
- },
 
5344
 
5345
- unicodeRangeToken: function(first, startLine, startCol){
5346
- var reader = this._reader,
5347
- value = first,
5348
- temp,
5349
- tt = Tokens.CHAR;
5350
 
5351
- //then it should be a unicode range
5352
- if (reader.peek() == "+"){
5353
- reader.mark();
5354
- value += reader.read();
5355
- value += this.readUnicodeRangePart(true);
5356
 
5357
- //ensure there's an actual unicode range here
5358
- if (value.length == 2){
5359
- reader.reset();
5360
- } else {
 
 
5361
 
5362
- tt = Tokens.UNICODE_RANGE;
 
 
5363
 
5364
- //if there's a ? in the first part, there can't be a second part
5365
- if (value.indexOf("?") == -1){
 
 
 
5366
 
5367
- if (reader.peek() == "-"){
5368
- reader.mark();
5369
- temp = reader.read();
5370
- temp += this.readUnicodeRangePart(false);
5371
 
5372
- //if there's not another value, back up and just take the first
5373
- if (temp.length == 1){
5374
- reader.reset();
5375
- } else {
5376
- value += temp;
5377
- }
5378
- }
5379
 
5380
- }
5381
- }
5382
- }
5383
 
5384
- return this.createToken(tt, value, startLine, startCol);
5385
- },
5386
 
5387
- /**
5388
- * Produces a S token based on the specified information. Since whitespace
5389
- * may have multiple characters, this consumes all whitespace characters
5390
- * into a single token.
5391
- * @param {String} first The first character in the token.
5392
- * @param {int} startLine The beginning line for the character.
5393
- * @param {int} startCol The beginning column for the character.
5394
- * @return {Object} A token object.
5395
- * @method whitespaceToken
5396
- */
5397
- whitespaceToken: function(first, startLine, startCol){
5398
- var reader = this._reader,
5399
- value = first + this.readWhitespace();
5400
- return this.createToken(Tokens.S, value, startLine, startCol);
5401
- },
5402
 
 
 
5403
 
 
 
 
 
5404
 
 
5405
 
5406
- //-------------------------------------------------------------------------
5407
- // Methods to read values from the string stream
5408
- //-------------------------------------------------------------------------
5409
 
5410
- readUnicodeRangePart: function(allowQuestionMark){
5411
- var reader = this._reader,
5412
- part = "",
5413
- c = reader.peek();
5414
 
5415
- //first read hex digits
5416
- while(isHexDigit(c) && part.length < 6){
5417
- reader.read();
5418
- part += c;
5419
- c = reader.peek();
5420
- }
5421
 
5422
- //then read question marks if allowed
5423
- if (allowQuestionMark){
5424
- while(c == "?" && part.length < 6){
5425
- reader.read();
5426
- part += c;
5427
- c = reader.peek();
5428
- }
5429
- }
5430
 
5431
- //there can't be any other characters after this point
5432
 
5433
- return part;
5434
- },
 
5435
 
5436
- readWhitespace: function(){
5437
- var reader = this._reader,
5438
- whitespace = "",
5439
- c = reader.peek();
5440
 
5441
- while(isWhitespace(c)){
5442
- reader.read();
5443
- whitespace += c;
5444
- c = reader.peek();
5445
- }
5446
 
5447
- return whitespace;
5448
- },
5449
- readNumber: function(first){
5450
- var reader = this._reader,
5451
- number = first,
5452
- hasDot = (first == "."),
5453
- c = reader.peek();
5454
 
 
 
 
5455
 
5456
- while(c){
5457
- if (isDigit(c)){
5458
- number += reader.read();
5459
- } else if (c == "."){
5460
- if (hasDot){
5461
- break;
5462
- } else {
5463
- hasDot = true;
5464
- number += reader.read();
5465
- }
5466
  } else {
5467
- break;
5468
  }
 
5469
 
5470
- c = reader.peek();
5471
- }
 
5472
 
5473
- return number;
5474
- },
5475
- readString: function(){
5476
- var reader = this._reader,
5477
- delim = reader.read(),
5478
- string = delim,
5479
- prev = delim,
5480
- c = reader.peek();
5481
 
5482
- while(c){
5483
- c = reader.read();
5484
- string += c;
5485
 
5486
- //if the delimiter is found with an escapement, we're done.
5487
- if (c == delim && prev != "\\"){
5488
- break;
5489
- }
5490
 
5491
- //if there's a newline without an escapement, it's an invalid string
5492
- if (isNewLine(reader.peek()) && c != "\\"){
5493
- string = "";
5494
- break;
5495
- }
5496
 
5497
- //save previous and get next
5498
- prev = c;
5499
- c = reader.peek();
5500
- }
5501
 
5502
- //if c is null, that means we're out of input and the string was never closed
5503
- if (c === null){
5504
- string = "";
5505
- }
5506
 
5507
- return string;
5508
- },
5509
- readURI: function(first){
5510
- var reader = this._reader,
5511
- uri = first,
5512
- inner = "",
5513
- c = reader.peek();
5514
 
5515
- reader.mark();
5516
 
5517
- //skip whitespace before
5518
- while(c && isWhitespace(c)){
5519
- reader.read();
5520
- c = reader.peek();
5521
- }
5522
 
5523
- //it's a string
5524
- if (c == "'" || c == "\""){
5525
- inner = this.readString();
5526
- } else {
5527
- inner = this.readURL();
5528
- }
5529
 
5530
- c = reader.peek();
5531
 
5532
- //skip whitespace after
5533
- while(c && isWhitespace(c)){
5534
- reader.read();
5535
- c = reader.peek();
5536
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5537
 
5538
- //if there was no inner value or the next character isn't closing paren, it's not a URI
5539
- if (inner === "" || c != ")"){
5540
- uri = first;
5541
- reader.reset();
5542
- } else {
5543
- uri += inner + reader.read();
5544
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5545
 
5546
- return uri;
5547
- },
5548
- readURL: function(){
5549
- var reader = this._reader,
5550
- url = "",
5551
- c = reader.peek();
5552
 
5553
- //TODO: Check for escape and nonascii
5554
- while (/^[!#$%&\\*-~]$/.test(c)){
5555
- url += reader.read();
5556
- c = reader.peek();
5557
- }
5558
 
5559
- return url;
 
 
 
 
 
 
5560
 
5561
- },
5562
- readName: function(first){
5563
- var reader = this._reader,
5564
- ident = first || "",
5565
- c = reader.peek();
 
 
 
5566
 
5567
- while(true){
5568
- if (c == "\\"){
5569
- ident += this.readEscape(reader.read());
5570
- c = reader.peek();
5571
- } else if(c && isNameChar(c)){
5572
- ident += reader.read();
5573
- c = reader.peek();
5574
- } else {
5575
- break;
5576
- }
 
 
 
 
 
5577
  }
5578
 
5579
- return ident;
5580
  },
5581
 
5582
- readEscape: function(first){
5583
- var reader = this._reader,
5584
- cssEscape = first || "",
5585
- i = 0,
5586
- c = reader.peek();
5587
-
5588
- if (isHexDigit(c)){
5589
- do {
5590
- cssEscape += reader.read();
5591
- c = reader.peek();
5592
- } while(c && isHexDigit(c) && ++i < 6);
5593
  }
5594
-
5595
- if (cssEscape.length == 3 && /\s/.test(c) ||
5596
- cssEscape.length == 7 || cssEscape.length == 1){
5597
- reader.read();
5598
- } else {
5599
- c = "";
5600
  }
5601
 
5602
- return cssEscape + c;
5603
- },
 
5604
 
5605
- readComment: function(first){
5606
- var reader = this._reader,
5607
- comment = first || "",
5608
- c = reader.read();
5609
 
5610
- if (c == "*"){
5611
- while(c){
5612
- comment += c;
 
 
 
 
5613
 
5614
- //look for end of comment
5615
- if (comment.length > 2 && c == "*" && reader.peek() == "/"){
5616
- comment += reader.read();
 
 
 
 
 
 
 
 
 
 
5617
  break;
5618
  }
5619
-
5620
- c = reader.read();
5621
  }
5622
 
5623
- return comment;
5624
- } else {
5625
- return "";
5626
- }
5627
 
 
5628
  }
5629
- });
5630
 
 
 
5631
 
5632
- var Tokens = [
5633
 
5634
- /*
5635
- * The following token names are defined in CSS3 Grammar: http://www.w3.org/TR/css3-syntax/#lexical
 
 
 
 
 
 
 
 
 
 
 
 
5636
  */
 
5637
 
5638
- //HTML-style comments
5639
- { name: "CDO"},
5640
- { name: "CDC"},
5641
 
5642
- //ignorables
5643
- { name: "S", whitespace: true/*, channel: "ws"*/},
5644
- { name: "COMMENT", comment: true, hide: true, channel: "comment" },
 
 
 
 
5645
 
5646
- //attribute equality
5647
- { name: "INCLUDES", text: "~="},
5648
- { name: "DASHMATCH", text: "|="},
5649
- { name: "PREFIXMATCH", text: "^="},
5650
- { name: "SUFFIXMATCH", text: "$="},
5651
- { name: "SUBSTRINGMATCH", text: "*="},
5652
-
5653
- //identifier types
5654
- { name: "STRING"},
5655
- { name: "IDENT"},
5656
- { name: "HASH"},
5657
-
5658
- //at-keywords
5659
- { name: "IMPORT_SYM", text: "@import"},
5660
- { name: "PAGE_SYM", text: "@page"},
5661
- { name: "MEDIA_SYM", text: "@media"},
5662
- { name: "FONT_FACE_SYM", text: "@font-face"},
5663
- { name: "CHARSET_SYM", text: "@charset"},
5664
- { name: "NAMESPACE_SYM", text: "@namespace"},
5665
- { name: "VIEWPORT_SYM", text: "@viewport"},
5666
- { name: "UNKNOWN_SYM" },
5667
- //{ name: "ATKEYWORD"},
5668
 
5669
- //CSS3 animations
5670
- { name: "KEYFRAMES_SYM", text: [ "@keyframes", "@-webkit-keyframes", "@-moz-keyframes", "@-o-keyframes" ] },
 
 
 
 
 
5671
 
5672
- //important symbol
5673
- { name: "IMPORTANT_SYM"},
 
 
 
 
 
 
5674
 
5675
- //measurements
5676
- { name: "LENGTH"},
5677
- { name: "ANGLE"},
5678
- { name: "TIME"},
5679
- { name: "FREQ"},
5680
- { name: "DIMENSION"},
5681
- { name: "PERCENTAGE"},
5682
- { name: "NUMBER"},
5683
 
5684
- //functions
5685
- { name: "URI"},
5686
- { name: "FUNCTION"},
5687
 
5688
- //Unicode ranges
5689
- { name: "UNICODE_RANGE"},
 
5690
 
5691
- /*
5692
- * The following token names are defined in CSS3 Selectors: http://www.w3.org/TR/css3-selectors/#selector-syntax
 
 
5693
  */
 
 
 
5694
 
5695
- //invalid string
5696
- { name: "INVALID"},
 
 
 
 
 
 
5697
 
5698
- //combinators
5699
- { name: "PLUS", text: "+" },
5700
- { name: "GREATER", text: ">"},
5701
- { name: "COMMA", text: ","},
5702
- { name: "TILDE", text: "~"},
 
 
 
5703
 
5704
- //modifier
5705
- { name: "NOT"},
 
5706
 
5707
- /*
5708
- * Defined in CSS3 Paged Media
 
 
 
5709
  */
5710
- { name: "TOPLEFTCORNER_SYM", text: "@top-left-corner"},
5711
- { name: "TOPLEFT_SYM", text: "@top-left"},
5712
- { name: "TOPCENTER_SYM", text: "@top-center"},
5713
- { name: "TOPRIGHT_SYM", text: "@top-right"},
5714
- { name: "TOPRIGHTCORNER_SYM", text: "@top-right-corner"},
5715
- { name: "BOTTOMLEFTCORNER_SYM", text: "@bottom-left-corner"},
5716
- { name: "BOTTOMLEFT_SYM", text: "@bottom-left"},
5717
- { name: "BOTTOMCENTER_SYM", text: "@bottom-center"},
5718
- { name: "BOTTOMRIGHT_SYM", text: "@bottom-right"},
5719
- { name: "BOTTOMRIGHTCORNER_SYM", text: "@bottom-right-corner"},
5720
- { name: "LEFTTOP_SYM", text: "@left-top"},
5721
- { name: "LEFTMIDDLE_SYM", text: "@left-middle"},
5722
- { name: "LEFTBOTTOM_SYM", text: "@left-bottom"},
5723
- { name: "RIGHTTOP_SYM", text: "@right-top"},
5724
- { name: "RIGHTMIDDLE_SYM", text: "@right-middle"},
5725
- { name: "RIGHTBOTTOM_SYM", text: "@right-bottom"},
5726
 
5727
- /*
5728
- * The following token names are defined in CSS3 Media Queries: http://www.w3.org/TR/css3-mediaqueries/#syntax
5729
- */
5730
- /*{ name: "MEDIA_ONLY", state: "media"},
5731
- { name: "MEDIA_NOT", state: "media"},
5732
- { name: "MEDIA_AND", state: "media"},*/
5733
- { name: "RESOLUTION", state: "media"},
5734
 
5735
- /*
5736
- * The following token names are not defined in any CSS specification but are used by the lexer.
 
 
 
 
 
 
 
 
 
 
5737
  */
 
 
5738
 
5739
- //not a real token, but useful for stupid IE filters
5740
- { name: "IE_FUNCTION" },
5741
 
5742
- //part of CSS3 grammar but not the Flex code
5743
- { name: "CHAR" },
 
 
 
 
 
 
5744
 
5745
- //TODO: Needed?
5746
- //Not defined as tokens, but might as well be
5747
- {
5748
- name: "PIPE",
5749
- text: "|"
5750
- },
5751
- {
5752
- name: "SLASH",
5753
- text: "/"
5754
- },
5755
- {
5756
- name: "MINUS",
5757
- text: "-"
5758
- },
5759
- {
5760
- name: "STAR",
5761
- text: "*"
5762
- },
5763
 
5764
- {
5765
- name: "LBRACE",
5766
- text: "{"
5767
- },
5768
- {
5769
- name: "RBRACE",
5770
- text: "}"
5771
- },
5772
- {
5773
- name: "LBRACKET",
5774
- text: "["
5775
- },
5776
- {
5777
- name: "RBRACKET",
5778
- text: "]"
5779
- },
5780
- {
5781
- name: "EQUALS",
5782
- text: "="
5783
- },
5784
- {
5785
- name: "COLON",
5786
- text: ":"
5787
- },
5788
- {
5789
- name: "SEMICOLON",
5790
- text: ";"
5791
  },
5792
 
5793
- {
5794
- name: "LPAREN",
5795
- text: "("
 
 
 
 
 
 
 
 
 
 
 
 
5796
  },
5797
- {
5798
- name: "RPAREN",
5799
- text: ")"
 
 
 
 
 
5800
  },
5801
- {
5802
- name: "DOT",
5803
- text: "."
5804
- }
5805
- ];
5806
 
5807
- (function(){
 
 
5808
 
5809
- var nameMap = [],
5810
- typeMap = {};
 
 
 
 
 
 
 
5811
 
5812
- Tokens.UNKNOWN = -1;
5813
- Tokens.unshift({name:"EOF"});
5814
- for (var i=0, len = Tokens.length; i < len; i++){
5815
- nameMap.push(Tokens[i].name);
5816
- Tokens[Tokens[i].name] = i;
5817
- if (Tokens[i].text){
5818
- if (Tokens[i].text instanceof Array){
5819
- for (var j=0; j < Tokens[i].text.length; j++){
5820
- typeMap[Tokens[i].text[j]] = i;
5821
- }
 
 
5822
  } else {
5823
- typeMap[Tokens[i].text] = i;
5824
  }
5825
  }
5826
- }
5827
 
5828
- Tokens.name = function(tt){
5829
- return nameMap[tt];
5830
- };
5831
 
5832
- Tokens.type = function(c){
5833
- return typeMap[c] || -1;
5834
- };
5835
 
5836
- })();
 
 
 
 
 
 
 
 
 
 
5837
 
 
 
5838
 
 
 
 
 
5839
 
 
5840
 
5841
- //This file will likely change a lot! Very experimental!
5842
- /*global Properties, ValidationTypes, ValidationError, PropertyValueIterator */
5843
- var Validation = {
5844
 
5845
- validate: function(property, value){
 
 
 
 
 
 
 
 
 
 
 
 
5846
 
5847
- //normalize name
5848
- var name = property.toString().toLowerCase(),
5849
- parts = value.parts,
5850
- expression = new PropertyValueIterator(value),
5851
- spec = Properties[name],
5852
- part,
5853
- valid,
5854
- j, count,
5855
- msg,
5856
- types,
5857
- last,
5858
- literals,
5859
- max, multi, group;
5860
 
5861
- if (!spec) {
5862
- if (name.indexOf("-") !== 0){ //vendor prefixed are ok
5863
- throw new ValidationError("Unknown property '" + property + "'.", property.line, property.col);
 
5864
  }
5865
- } else if (typeof spec != "number"){
5866
-
5867
- //initialization
5868
- if (typeof spec == "string"){
5869
- if (spec.indexOf("||") > -1) {
5870
- this.groupProperty(spec, expression);
5871
- } else {
5872
- this.singleProperty(spec, expression, 1);
5873
- }
5874
-
5875
- } else if (spec.multi) {
5876
- this.multiProperty(spec.multi, expression, spec.comma, spec.max || Infinity);
5877
- } else if (typeof spec == "function") {
5878
- spec(expression);
5879
  }
5880
-
5881
  }
5882
 
 
5883
  },
5884
 
5885
- singleProperty: function(types, expression, max, partial) {
5886
 
5887
- var result = false,
5888
- value = expression.value,
5889
- count = 0,
5890
- part;
 
 
 
 
 
5891
 
5892
- while (expression.hasNext() && count < max) {
5893
- result = ValidationTypes.isAny(expression, types);
5894
- if (!result) {
5895
- break;
5896
- }
5897
- count++;
5898
  }
5899
 
5900
- if (!result) {
5901
- if (expression.hasNext() && !expression.isFirst()) {
5902
- part = expression.peek();
5903
- throw new ValidationError("Expected end of value but found '" + part + "'.", part.line, part.col);
5904
- } else {
5905
- throw new ValidationError("Expected (" + types + ") but found '" + value + "'.", value.line, value.col);
5906
- }
5907
- } else if (expression.hasNext()) {
5908
- part = expression.next();
5909
- throw new ValidationError("Expected end of value but found '" + part + "'.", part.line, part.col);
5910
- }
5911
 
5912
- },
5913
 
5914
- multiProperty: function (types, expression, comma, max) {
 
5915
 
5916
- var result = false,
5917
- value = expression.value,
5918
- count = 0,
5919
- sep = false,
5920
- part;
5921
 
5922
- while(expression.hasNext() && !result && count < max) {
5923
- if (ValidationTypes.isAny(expression, types)) {
5924
- count++;
5925
- if (!expression.hasNext()) {
5926
- result = true;
 
 
 
 
 
 
 
5927
 
5928
- } else if (comma) {
5929
- if (expression.peek() == ",") {
5930
- part = expression.next();
5931
- } else {
5932
- break;
5933
- }
5934
- }
5935
- } else {
5936
- break;
5937
 
5938
- }
5939
- }
 
 
 
 
5940
 
5941
- if (!result) {
5942
- if (expression.hasNext() && !expression.isFirst()) {
5943
- part = expression.peek();
5944
- throw new ValidationError("Expected end of value but found '" + part + "'.", part.line, part.col);
5945
- } else {
5946
- part = expression.previous();
5947
- if (comma && part == ",") {
5948
- throw new ValidationError("Expected end of value but found '" + part + "'.", part.line, part.col);
5949
- } else {
5950
- throw new ValidationError("Expected (" + types + ") but found '" + value + "'.", value.line, value.col);
5951
- }
5952
- }
5953
 
5954
- } else if (expression.hasNext()) {
5955
- part = expression.next();
5956
- throw new ValidationError("Expected end of value but found '" + part + "'.", part.line, part.col);
5957
- }
5958
 
5959
- },
 
 
5960
 
5961
- groupProperty: function (types, expression, comma) {
 
5962
 
5963
- var result = false,
5964
- value = expression.value,
5965
- typeCount = types.split("||").length,
5966
- groups = { count: 0 },
5967
- partial = false,
5968
- name,
5969
- part;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5970
 
5971
- while(expression.hasNext() && !result) {
5972
- name = ValidationTypes.isAnyOfGroup(expression, types);
5973
- if (name) {
 
 
 
 
 
 
 
 
5974
 
5975
- //no dupes
5976
- if (groups[name]) {
5977
- break;
5978
- } else {
5979
- groups[name] = 1;
5980
- groups.count++;
5981
- partial = true;
 
5982
 
5983
- if (groups.count == typeCount || !expression.hasNext()) {
5984
- result = true;
5985
- }
5986
- }
5987
- } else {
5988
- break;
5989
- }
5990
- }
5991
 
5992
- if (!result) {
5993
- if (partial && expression.hasNext()) {
5994
- part = expression.peek();
5995
- throw new ValidationError("Expected end of value but found '" + part + "'.", part.line, part.col);
5996
- } else {
5997
- throw new ValidationError("Expected (" + types + ") but found '" + value + "'.", value.line, value.col);
5998
- }
5999
- } else if (expression.hasNext()) {
6000
- part = expression.next();
6001
- throw new ValidationError("Expected end of value but found '" + part + "'.", part.line, part.col);
6002
- }
6003
- }
6004
 
 
6005
 
 
 
6006
 
6007
- };
6008
  /**
6009
- * Type to use when a validation error occurs.
6010
- * @class ValidationError
6011
  * @namespace parserlib.util
6012
  * @constructor
6013
- * @param {String} message The error message.
6014
- * @param {int} line The line at which the error occurred.
6015
- * @param {int} col The column at which the error occurred.
6016
  */
6017
- function ValidationError(message, line, col){
6018
 
6019
  /**
6020
- * The column at which the error occurred.
6021
- * @type int
6022
- * @property col
 
6023
  */
6024
- this.col = col;
6025
 
6026
  /**
6027
- * The line at which the error occurred.
6028
- * @type int
6029
- * @property line
 
6030
  */
6031
- this.line = line;
6032
 
6033
  /**
6034
- * The text representation of the unit.
6035
- * @type String
6036
- * @property text
 
6037
  */
6038
- this.message = message;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6039
 
 
6040
  }
6041
 
6042
- //inherit from Error
6043
- ValidationError.prototype = new Error();
6044
- //This file will likely change a lot! Very experimental!
6045
- /*global Properties, Validation, ValidationError, PropertyValueIterator, console*/
6046
- var ValidationTypes = {
 
 
 
 
 
6047
 
6048
- isLiteral: function (part, literals) {
6049
- var text = part.text.toString().toLowerCase(),
6050
- args = literals.split(" | "),
6051
- i, len, found = false;
 
6052
 
6053
- for (i=0,len=args.length; i < len && !found; i++){
6054
- if (text == args[i].toLowerCase()){
6055
- found = true;
6056
- }
 
 
 
 
6057
  }
 
6058
 
6059
- return found;
6060
- },
 
6061
 
6062
- isSimple: function(type) {
6063
- return !!this.simple[type];
6064
- },
6065
 
6066
- isComplex: function(type) {
6067
- return !!this.complex[type];
6068
- },
6069
 
6070
- /**
6071
- * Determines if the next part(s) of the given expression
6072
- * are any of the given types.
6073
- */
6074
- isAny: function (expression, types) {
6075
- var args = types.split(" | "),
6076
- i, len, found = false;
6077
 
6078
- for (i=0,len=args.length; i < len && !found && expression.hasNext(); i++){
6079
- found = this.isType(expression, args[i]);
6080
- }
6081
 
6082
- return found;
6083
- },
 
6084
 
6085
  /**
6086
- * Determines if the next part(s) of the given expression
6087
- * are one of a group.
 
 
 
 
 
 
 
 
 
 
6088
  */
6089
- isAnyOfGroup: function(expression, types) {
6090
- var args = types.split(" || "),
6091
- i, len, found = false;
6092
 
6093
- for (i=0,len=args.length; i < len && !found; i++){
6094
- found = this.isType(expression, args[i]);
 
6095
  }
6096
 
6097
- return found ? args[i-1] : false;
6098
- },
6099
-
6100
- /**
6101
- * Determines if the next part(s) of the given expression
6102
- * are of a given type.
6103
- */
6104
- isType: function (expression, type) {
6105
- var part = expression.peek(),
6106
- result = false;
6107
 
6108
- if (type.charAt(0) != "<") {
6109
- result = this.isLiteral(part, type);
6110
- if (result) {
6111
- expression.next();
6112
- }
6113
- } else if (this.simple[type]) {
6114
- result = this.simple[type](part);
6115
- if (result) {
6116
- expression.next();
6117
  }
6118
- } else {
6119
- result = this.complex[type](expression);
6120
  }
6121
 
6122
- return result;
 
 
6123
  },
6124
 
 
 
 
 
 
 
 
 
 
 
6125
 
 
6126
 
6127
- simple: {
6128
-
6129
- "<absolute-size>": function(part){
6130
- return ValidationTypes.isLiteral(part, "xx-small | x-small | small | medium | large | x-large | xx-large");
6131
- },
6132
-
6133
- "<attachment>": function(part){
6134
- return ValidationTypes.isLiteral(part, "scroll | fixed | local");
6135
- },
6136
-
6137
- "<attr>": function(part){
6138
- return part.type == "function" && part.name == "attr";
6139
- },
6140
-
6141
- "<bg-image>": function(part){
6142
- return this["<image>"](part) || this["<gradient>"](part) || part == "none";
6143
- },
6144
 
6145
- "<gradient>": function(part) {
6146
- return part.type == "function" && /^(?:\-(?:ms|moz|o|webkit)\-)?(?:repeating\-)?(?:radial\-|linear\-)?gradient/i.test(part);
6147
- },
 
 
 
6148
 
6149
- "<box>": function(part){
6150
- return ValidationTypes.isLiteral(part, "padding-box | border-box | content-box");
6151
- },
6152
 
6153
- "<content>": function(part){
6154
- return part.type == "function" && part.name == "content";
6155
- },
 
 
 
 
 
 
 
 
 
6156
 
6157
- "<relative-size>": function(part){
6158
- return ValidationTypes.isLiteral(part, "smaller | larger");
6159
- },
6160
 
6161
- //any identifier
6162
- "<ident>": function(part){
6163
- return part.type == "identifier";
6164
- },
6165
 
6166
- "<length>": function(part){
6167
- if (part.type == "function" && /^(?:\-(?:ms|moz|o|webkit)\-)?calc/i.test(part)){
6168
- return true;
6169
- }else{
6170
- return part.type == "length" || part.type == "number" || part.type == "integer" || part == "0";
6171
- }
6172
- },
6173
 
6174
- "<color>": function(part){
6175
- return part.type == "color" || part == "transparent";
6176
- },
 
6177
 
6178
- "<number>": function(part){
6179
- return part.type == "number" || this["<integer>"](part);
6180
- },
6181
 
6182
- "<integer>": function(part){
6183
- return part.type == "integer";
6184
- },
6185
 
6186
- "<line>": function(part){
6187
- return part.type == "integer";
6188
- },
 
 
 
 
6189
 
6190
- "<angle>": function(part){
6191
- return part.type == "angle";
6192
- },
 
 
 
 
6193
 
6194
- "<uri>": function(part){
6195
- return part.type == "uri";
6196
- },
6197
 
6198
- "<image>": function(part){
6199
- return this["<uri>"](part);
6200
- },
6201
 
6202
- "<percentage>": function(part){
6203
- return part.type == "percentage" || part == "0";
6204
- },
6205
 
6206
- "<border-width>": function(part){
6207
- return this["<length>"](part) || ValidationTypes.isLiteral(part, "thin | medium | thick");
6208
- },
6209
 
6210
- "<border-style>": function(part){
6211
- return ValidationTypes.isLiteral(part, "none | hidden | dotted | dashed | solid | double | groove | ridge | inset | outset");
6212
- },
6213
 
6214
- "<margin-width>": function(part){
6215
- return this["<length>"](part) || this["<percentage>"](part) || ValidationTypes.isLiteral(part, "auto");
6216
- },
 
6217
 
6218
- "<padding-width>": function(part){
6219
- return this["<length>"](part) || this["<percentage>"](part);
6220
- },
 
6221
 
6222
- "<shape>": function(part){
6223
- return part.type == "function" && (part.name == "rect" || part.name == "inset-rect");
6224
- },
6225
 
6226
- "<time>": function(part) {
6227
- return part.type == "time";
 
 
 
 
 
 
 
 
 
 
 
6228
  }
6229
  },
6230
 
6231
- complex: {
6232
-
6233
- "<bg-position>": function(expression){
6234
- var types = this,
6235
- result = false,
6236
- numeric = "<percentage> | <length>",
6237
- xDir = "left | right",
6238
- yDir = "top | bottom",
6239
- count = 0,
6240
- hasNext = function() {
6241
- return expression.hasNext() && expression.peek() != ",";
6242
- };
 
 
 
 
 
 
6243
 
6244
- while (expression.peek(count) && expression.peek(count) != ",") {
6245
- count++;
 
 
6246
  }
6247
 
6248
- /*
6249
- <position> = [
6250
- [ left | center | right | top | bottom | <percentage> | <length> ]
6251
- |
6252
- [ left | center | right | <percentage> | <length> ]
6253
- [ top | center | bottom | <percentage> | <length> ]
6254
- |
6255
- [ center | [ left | right ] [ <percentage> | <length> ]? ] &&
6256
- [ center | [ top | bottom ] [ <percentage> | <length> ]? ]
6257
- ]
6258
- */
6259
 
6260
- if (count < 3) {
6261
- if (ValidationTypes.isAny(expression, xDir + " | center | " + numeric)) {
6262
- result = true;
6263
- ValidationTypes.isAny(expression, yDir + " | center | " + numeric);
6264
- } else if (ValidationTypes.isAny(expression, yDir)) {
6265
- result = true;
6266
- ValidationTypes.isAny(expression, xDir + " | center");
6267
- }
6268
  } else {
6269
- if (ValidationTypes.isAny(expression, xDir)) {
6270
- if (ValidationTypes.isAny(expression, yDir)) {
6271
- result = true;
6272
- ValidationTypes.isAny(expression, numeric);
6273
- } else if (ValidationTypes.isAny(expression, numeric)) {
6274
- if (ValidationTypes.isAny(expression, yDir)) {
6275
- result = true;
6276
- ValidationTypes.isAny(expression, numeric);
6277
- } else if (ValidationTypes.isAny(expression, "center")) {
6278
- result = true;
6279
- }
6280
- }
6281
- } else if (ValidationTypes.isAny(expression, yDir)) {
6282
- if (ValidationTypes.isAny(expression, xDir)) {
6283
- result = true;
6284
- ValidationTypes.isAny(expression, numeric);
6285
- } else if (ValidationTypes.isAny(expression, numeric)) {
6286
- if (ValidationTypes.isAny(expression, xDir)) {
6287
- result = true;
6288
- ValidationTypes.isAny(expression, numeric);
6289
- } else if (ValidationTypes.isAny(expression, "center")) {
6290
- result = true;
6291
- }
6292
- }
6293
- } else if (ValidationTypes.isAny(expression, "center")) {
6294
- if (ValidationTypes.isAny(expression, xDir + " | " + yDir)) {
6295
- result = true;
6296
- ValidationTypes.isAny(expression, numeric);
6297
- }
6298
- }
6299
  }
6300
 
6301
- return result;
6302
- },
 
6303
 
6304
- "<bg-size>": function(expression){
6305
- //<bg-size> = [ <length> | <percentage> | auto ]{1,2} | cover | contain
6306
- var types = this,
6307
- result = false,
6308
- numeric = "<percentage> | <length> | auto",
6309
- part,
6310
- i, len;
6311
 
6312
- if (ValidationTypes.isAny(expression, "cover | contain")) {
6313
- result = true;
6314
- } else if (ValidationTypes.isAny(expression, numeric)) {
6315
- result = true;
6316
- ValidationTypes.isAny(expression, numeric);
6317
- }
6318
 
6319
- return result;
6320
- },
 
 
 
 
 
 
 
 
 
6321
 
6322
- "<repeat-style>": function(expression){
6323
- //repeat-x | repeat-y | [repeat | space | round | no-repeat]{1,2}
6324
- var result = false,
6325
- values = "repeat | space | round | no-repeat",
6326
- part;
6327
 
6328
- if (expression.hasNext()){
6329
- part = expression.next();
 
6330
 
6331
- if (ValidationTypes.isLiteral(part, "repeat-x | repeat-y")) {
6332
- result = true;
6333
- } else if (ValidationTypes.isLiteral(part, values)) {
6334
- result = true;
 
 
 
 
 
6335
 
6336
- if (expression.hasNext() && ValidationTypes.isLiteral(expression.peek(), values)) {
6337
- expression.next();
6338
- }
6339
- }
6340
- }
 
 
 
6341
 
6342
- return result;
 
 
 
 
 
 
 
 
 
 
 
 
 
6343
 
6344
- },
 
 
 
 
 
 
 
 
 
6345
 
6346
- "<shadow>": function(expression) {
6347
- //inset? && [ <length>{2,4} && <color>? ]
6348
- var result = false,
6349
- count = 0,
6350
- inset = false,
6351
- color = false,
6352
- part;
 
 
 
 
 
 
6353
 
6354
- if (expression.hasNext()) {
6355
 
6356
- if (ValidationTypes.isAny(expression, "inset")){
6357
- inset = true;
6358
- }
6359
 
6360
- if (ValidationTypes.isAny(expression, "<color>")) {
6361
- color = true;
6362
- }
6363
 
6364
- while (ValidationTypes.isAny(expression, "<length>") && count < 4) {
6365
- count++;
6366
- }
 
 
 
 
6367
 
 
 
6368
 
6369
- if (expression.hasNext()) {
6370
- if (!color) {
6371
- ValidationTypes.isAny(expression, "<color>");
6372
- }
6373
 
6374
- if (!inset) {
6375
- ValidationTypes.isAny(expression, "inset");
6376
- }
6377
 
6378
- }
 
 
 
6379
 
6380
- result = (count >= 2 && count <= 4);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6381
 
6382
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6383
 
6384
- return result;
6385
- },
6386
 
6387
- "<x-one-radius>": function(expression) {
6388
- //[ <length> | <percentage> ] [ <length> | <percentage> ]?
6389
- var result = false,
6390
- simple = "<length> | <percentage> | inherit";
 
 
6391
 
6392
- if (ValidationTypes.isAny(expression, simple)){
6393
- result = true;
6394
- ValidationTypes.isAny(expression, simple);
6395
- }
 
6396
 
6397
- return result;
6398
- }
 
 
6399
  }
6400
- };
6401
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6402
 
 
6403
 
6404
- parserlib.css = {
6405
- Colors :Colors,
6406
- Combinator :Combinator,
6407
- Parser :Parser,
6408
- PropertyName :PropertyName,
6409
- PropertyValue :PropertyValue,
6410
- PropertyValuePart :PropertyValuePart,
6411
- MediaFeature :MediaFeature,
6412
- MediaQuery :MediaQuery,
6413
- Selector :Selector,
6414
- SelectorPart :SelectorPart,
6415
- SelectorSubPart :SelectorSubPart,
6416
- Specificity :Specificity,
6417
- TokenStream :TokenStream,
6418
- Tokens :Tokens,
6419
- ValidationError :ValidationError
6420
  };
6421
- })();
6422
 
 
 
 
 
6423
 
 
 
 
 
6424
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6425
 
6426
- (function(){
6427
- for(var prop in parserlib){
6428
- exports[prop] = parserlib[prop];
6429
- }
6430
  })();
6431
 
 
 
 
6432
 
6433
  /**
6434
  * Main CSSLint object.
@@ -6436,15 +7479,19 @@ exports[prop] = parserlib[prop];
6436
  * @static
6437
  * @extends parserlib.util.EventTarget
6438
  */
6439
- /*global parserlib, Reporter*/
6440
- var CSSLint = (function(){
 
 
 
 
6441
 
6442
  var rules = [],
6443
  formatters = [],
6444
- embeddedRuleset = /\/\*csslint([^\*]*)\*\//,
6445
  api = new parserlib.util.EventTarget();
6446
 
6447
- api.version = "0.10.0";
6448
 
6449
  //-------------------------------------------------------------------------
6450
  // Rule Management
@@ -6455,7 +7502,7 @@ var CSSLint = (function(){
6455
  * @param {Object} rule The rule to add.
6456
  * @method addRule
6457
  */
6458
- api.addRule = function(rule){
6459
  rules.push(rule);
6460
  rules[rule.id] = rule;
6461
  };
@@ -6464,7 +7511,7 @@ var CSSLint = (function(){
6464
  * Clears all rule from the engine.
6465
  * @method clearRules
6466
  */
6467
- api.clearRules = function(){
6468
  rules = [];
6469
  };
6470
 
@@ -6473,8 +7520,8 @@ var CSSLint = (function(){
6473
  * @return An array of rule objects.
6474
  * @method getRules
6475
  */
6476
- api.getRules = function(){
6477
- return [].concat(rules).sort(function(a,b){
6478
  return a.id > b.id ? 1 : 0;
6479
  });
6480
  };
@@ -6489,8 +7536,8 @@ var CSSLint = (function(){
6489
  i = 0,
6490
  len = rules.length;
6491
 
6492
- while (i < len){
6493
- ruleset[rules[i++].id] = 1; //by default, everything is a warning
6494
  }
6495
 
6496
  return ruleset;
@@ -6503,7 +7550,7 @@ var CSSLint = (function(){
6503
  * @return {Object} A ruleset object.
6504
  * @method getEmbeddedRuleset
6505
  */
6506
- function applyEmbeddedRuleset(text, ruleset){
6507
  var valueMap,
6508
  embedded = text && text.match(embeddedRuleset),
6509
  rules = embedded && embedded[1];
@@ -6519,7 +7566,7 @@ var CSSLint = (function(){
6519
  "0": 0 // explicit ignore
6520
  };
6521
 
6522
- rules.toLowerCase().split(",").forEach(function(rule){
6523
  var pair = rule.split(":"),
6524
  property = pair[0] || "",
6525
  value = pair[1] || "";
@@ -6551,7 +7598,7 @@ var CSSLint = (function(){
6551
  * @return {Object} The formatter or undefined.
6552
  * @method getFormatter
6553
  */
6554
- api.getFormatter = function(formatId){
6555
  return formatters[formatId];
6556
  };
6557
 
@@ -6568,7 +7615,7 @@ var CSSLint = (function(){
6568
  var formatter = this.getFormatter(formatId),
6569
  result = null;
6570
 
6571
- if (formatter){
6572
  result = formatter.startFormat();
6573
  result += formatter.formatResults(results, filename, options || {});
6574
  result += formatter.endFormat();
@@ -6583,7 +7630,7 @@ var CSSLint = (function(){
6583
  * @return {Boolean} True if the format exists, false if not.
6584
  * @method hasFormat
6585
  */
6586
- api.hasFormat = function(formatId){
6587
  return formatters.hasOwnProperty(formatId);
6588
  };
6589
 
@@ -6600,40 +7647,86 @@ var CSSLint = (function(){
6600
  * @return {Object} Results of the verification.
6601
  * @method verify
6602
  */
6603
- api.verify = function(text, ruleset){
6604
 
6605
- var i = 0,
6606
- len = rules.length,
6607
  reporter,
6608
  lines,
 
 
6609
  report,
6610
- parser = new parserlib.css.Parser({ starHack: true, ieFilters: true,
6611
- underscoreHack: true, strict: false });
 
 
 
 
6612
 
6613
  // normalize line endings
6614
- lines = text.replace(/\n\r?/g, "$split$").split('$split$');
6615
 
6616
- if (!ruleset){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6617
  ruleset = this.getRuleset();
6618
  }
6619
 
6620
- if (embeddedRuleset.test(text)){
 
 
6621
  ruleset = applyEmbeddedRuleset(text, ruleset);
6622
  }
6623
 
6624
- reporter = new Reporter(lines, ruleset);
6625
 
6626
- ruleset.errors = 2; //always report parsing errors as errors
6627
- for (i in ruleset){
6628
- if(ruleset.hasOwnProperty(i) && ruleset[i]){
6629
- if (rules[i]){
6630
  rules[i].init(parser, reporter);
6631
  }
6632
  }
6633
  }
6634
 
6635
 
6636
- //capture most horrible error type
6637
  try {
6638
  parser.parse(text);
6639
  } catch (ex) {
@@ -6643,14 +7736,16 @@ var CSSLint = (function(){
6643
  report = {
6644
  messages : reporter.messages,
6645
  stats : reporter.stats,
6646
- ruleset : reporter.ruleset
 
 
6647
  };
6648
 
6649
- //sort by line numbers, rollups at the bottom
6650
- report.messages.sort(function (a, b){
6651
- if (a.rollup && !b.rollup){
6652
  return 1;
6653
- } else if (!a.rollup && b.rollup){
6654
  return -1;
6655
  } else {
6656
  return a.line - b.line;
@@ -6668,7 +7763,6 @@ var CSSLint = (function(){
6668
 
6669
  })();
6670
 
6671
- /*global CSSLint*/
6672
  /**
6673
  * An instance of Report is used to report results of the
6674
  * verification back to the main API.
@@ -6677,8 +7771,11 @@ var CSSLint = (function(){
6677
  * @param {String[]} lines The text lines of the source.
6678
  * @param {Object} ruleset The set of rules to work with, including if
6679
  * they are errors or warnings.
 
 
6680
  */
6681
- function Reporter(lines, ruleset){
 
6682
 
6683
  /**
6684
  * List of messages being reported.
@@ -6709,11 +7806,31 @@ function Reporter(lines, ruleset){
6709
  * @type Object
6710
  */
6711
  this.ruleset = ruleset;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6712
  }
6713
 
6714
  Reporter.prototype = {
6715
 
6716
- //restore constructor
6717
  constructor: Reporter,
6718
 
6719
  /**
@@ -6724,7 +7841,8 @@ Reporter.prototype = {
6724
  * @param {Object} rule The rule this message relates to.
6725
  * @method error
6726
  */
6727
- error: function(message, line, col, rule){
 
6728
  this.messages.push({
6729
  type : "error",
6730
  line : line,
@@ -6744,7 +7862,8 @@ Reporter.prototype = {
6744
  * @method warn
6745
  * @deprecated Use report instead.
6746
  */
6747
- warn: function(message, line, col, rule){
 
6748
  this.report(message, line, col, rule);
6749
  },
6750
 
@@ -6756,9 +7875,26 @@ Reporter.prototype = {
6756
  * @param {Object} rule The rule this message relates to.
6757
  * @method report
6758
  */
6759
- report: function(message, line, col, rule){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6760
  this.messages.push({
6761
- type : this.ruleset[rule.id] == 2 ? "error" : "warning",
6762
  line : line,
6763
  col : col,
6764
  message : message,
@@ -6775,7 +7911,8 @@ Reporter.prototype = {
6775
  * @param {Object} rule The rule this message relates to.
6776
  * @method info
6777
  */
6778
- info: function(message, line, col, rule){
 
6779
  this.messages.push({
6780
  type : "info",
6781
  line : line,
@@ -6792,7 +7929,8 @@ Reporter.prototype = {
6792
  * @param {Object} rule The rule this message relates to.
6793
  * @method rollupError
6794
  */
6795
- rollupError: function(message, rule){
 
6796
  this.messages.push({
6797
  type : "error",
6798
  rollup : true,
@@ -6807,7 +7945,8 @@ Reporter.prototype = {
6807
  * @param {Object} rule The rule this message relates to.
6808
  * @method rollupWarn
6809
  */
6810
- rollupWarn: function(message, rule){
 
6811
  this.messages.push({
6812
  type : "warning",
6813
  rollup : true,
@@ -6822,16 +7961,15 @@ Reporter.prototype = {
6822
  * @param {Variant} value The value of the stat.
6823
  * @method stat
6824
  */
6825
- stat: function(name, value){
 
6826
  this.stats[name] = value;
6827
  }
6828
  };
6829
 
6830
- //expose for testing purposes
6831
  CSSLint._Reporter = Reporter;
6832
 
6833
- /*global CSSLint*/
6834
-
6835
  /*
6836
  * Utility functions that make life easier.
6837
  */
@@ -6839,16 +7977,17 @@ CSSLint.Util = {
6839
  /*
6840
  * Adds all properties from supplier onto receiver,
6841
  * overwriting if the same name already exists on
6842
- * reciever.
6843
  * @param {Object} The object to receive the properties.
6844
  * @param {Object} The object to provide the properties.
6845
  * @return {Object} The receiver
6846
  */
6847
- mix: function(receiver, supplier){
 
6848
  var prop;
6849
 
6850
- for (prop in supplier){
6851
- if (supplier.hasOwnProperty(prop)){
6852
  receiver[prop] = supplier[prop];
6853
  }
6854
  }
@@ -6862,12 +8001,13 @@ CSSLint.Util = {
6862
  * @param {Variant} value The value to search for.
6863
  * @return {int} The index of the value if found, -1 if not.
6864
  */
6865
- indexOf: function(values, value){
6866
- if (values.indexOf){
 
6867
  return values.indexOf(value);
6868
  } else {
6869
- for (var i=0, len=values.length; i < len; i++){
6870
- if (values[i] === value){
6871
  return i;
6872
  }
6873
  }
@@ -6882,31 +8022,35 @@ CSSLint.Util = {
6882
  * @return {void}
6883
  */
6884
  forEach: function(values, func) {
6885
- if (values.forEach){
 
6886
  return values.forEach(func);
6887
  } else {
6888
- for (var i=0, len=values.length; i < len; i++){
6889
  func(values[i], i, values);
6890
  }
6891
  }
6892
  }
6893
  };
6894
- /*global CSSLint*/
6895
  /*
6896
  * Rule: Don't use adjoining classes (.foo.bar).
6897
  */
 
6898
  CSSLint.addRule({
6899
 
6900
- //rule information
6901
  id: "adjoining-classes",
6902
  name: "Disallow adjoining classes",
6903
  desc: "Don't use adjoining classes.",
 
6904
  browsers: "IE6",
6905
 
6906
- //initialization
6907
- init: function(parser, reporter){
 
6908
  var rule = this;
6909
- parser.addListener("startrule", function(event){
6910
  var selectors = event.selectors,
6911
  selector,
6912
  part,
@@ -6914,19 +8058,19 @@ CSSLint.addRule({
6914
  classCount,
6915
  i, j, k;
6916
 
6917
- for (i=0; i < selectors.length; i++){
6918
  selector = selectors[i];
6919
- for (j=0; j < selector.parts.length; j++){
6920
  part = selector.parts[j];
6921
- if (part.type == parser.SELECTOR_PART_TYPE){
6922
  classCount = 0;
6923
- for (k=0; k < part.modifiers.length; k++){
6924
  modifier = part.modifiers[k];
6925
- if (modifier.type == "class"){
6926
  classCount++;
6927
  }
6928
  if (classCount > 1){
6929
- reporter.report("Don't use adjoining classes.", part.line, part.col, rule);
6930
  }
6931
  }
6932
  }
@@ -6936,21 +8080,22 @@ CSSLint.addRule({
6936
  }
6937
 
6938
  });
6939
- /*global CSSLint*/
6940
 
6941
  /*
6942
  * Rule: Don't use width or height when using padding or border.
6943
  */
6944
  CSSLint.addRule({
6945
 
6946
- //rule information
6947
  id: "box-model",
6948
  name: "Beware of broken box size",
6949
  desc: "Don't use width or height when using padding or border.",
 
6950
  browsers: "All",
6951
 
6952
- //initialization
6953
- init: function(parser, reporter){
 
6954
  var rule = this,
6955
  widthProperties = {
6956
  border: 1,
@@ -6971,33 +8116,33 @@ CSSLint.addRule({
6971
  properties,
6972
  boxSizing = false;
6973
 
6974
- function startRule(){
6975
  properties = {};
6976
  boxSizing = false;
6977
  }
6978
 
6979
- function endRule(){
6980
  var prop, value;
6981
 
6982
  if (!boxSizing) {
6983
- if (properties.height){
6984
- for (prop in heightProperties){
6985
- if (heightProperties.hasOwnProperty(prop) && properties[prop]){
6986
  value = properties[prop].value;
6987
- //special case for padding
6988
- if (!(prop == "padding" && value.parts.length === 2 && value.parts[0].value === 0)){
6989
  reporter.report("Using height with " + prop + " can sometimes make elements larger than you expect.", properties[prop].line, properties[prop].col, rule);
6990
  }
6991
  }
6992
  }
6993
  }
6994
 
6995
- if (properties.width){
6996
- for (prop in widthProperties){
6997
- if (widthProperties.hasOwnProperty(prop) && properties[prop]){
6998
  value = properties[prop].value;
6999
 
7000
- if (!(prop == "padding" && value.parts.length === 2 && value.parts[1].value === 0)){
7001
  reporter.report("Using width with " + prop + " can sometimes make elements larger than you expect.", properties[prop].line, properties[prop].col, rule);
7002
  }
7003
  }
@@ -7011,18 +8156,23 @@ CSSLint.addRule({
7011
  parser.addListener("startpage", startRule);
7012
  parser.addListener("startpagemargin", startRule);
7013
  parser.addListener("startkeyframerule", startRule);
 
7014
 
7015
- parser.addListener("property", function(event){
7016
  var name = event.property.text.toLowerCase();
7017
 
7018
- if (heightProperties[name] || widthProperties[name]){
7019
- if (!/^0\S*$/.test(event.value) && !(name == "border" && event.value == "none")){
7020
- properties[name] = { line: event.property.line, col: event.property.col, value: event.value };
 
 
 
 
7021
  }
7022
  } else {
7023
- if (/^(width|height)/i.test(name) && /^(length|percentage)/.test(event.value.parts[0].type)){
7024
  properties[name] = 1;
7025
- } else if (name == "box-sizing") {
7026
  boxSizing = true;
7027
  }
7028
  }
@@ -7034,79 +8184,84 @@ CSSLint.addRule({
7034
  parser.addListener("endpage", endRule);
7035
  parser.addListener("endpagemargin", endRule);
7036
  parser.addListener("endkeyframerule", endRule);
 
7037
  }
7038
 
7039
  });
7040
- /*global CSSLint*/
7041
 
7042
  /*
7043
  * Rule: box-sizing doesn't work in IE6 and IE7.
7044
  */
 
7045
  CSSLint.addRule({
7046
 
7047
- //rule information
7048
  id: "box-sizing",
7049
  name: "Disallow use of box-sizing",
7050
  desc: "The box-sizing properties isn't supported in IE6 and IE7.",
 
7051
  browsers: "IE6, IE7",
7052
  tags: ["Compatibility"],
7053
 
7054
- //initialization
7055
- init: function(parser, reporter){
 
7056
  var rule = this;
7057
 
7058
- parser.addListener("property", function(event){
7059
  var name = event.property.text.toLowerCase();
7060
 
7061
- if (name == "box-sizing"){
7062
  reporter.report("The box-sizing property isn't supported in IE6 and IE7.", event.line, event.col, rule);
7063
  }
7064
  });
7065
  }
7066
 
7067
  });
 
7068
  /*
7069
  * Rule: Use the bulletproof @font-face syntax to avoid 404's in old IE
7070
  * (http://www.fontspring.com/blog/the-new-bulletproof-font-face-syntax)
7071
  */
7072
- /*global CSSLint*/
7073
  CSSLint.addRule({
7074
 
7075
- //rule information
7076
  id: "bulletproof-font-face",
7077
  name: "Use the bulletproof @font-face syntax",
7078
  desc: "Use the bulletproof @font-face syntax to avoid 404's in old IE (http://www.fontspring.com/blog/the-new-bulletproof-font-face-syntax).",
 
7079
  browsers: "All",
7080
 
7081
- //initialization
7082
- init: function(parser, reporter){
 
7083
  var rule = this,
7084
- count = 0,
7085
  fontFaceRule = false,
7086
- firstSrc = true,
7087
- ruleFailed = false,
7088
  line, col;
7089
 
7090
  // Mark the start of a @font-face declaration so we only test properties inside it
7091
- parser.addListener("startfontface", function(event){
7092
  fontFaceRule = true;
7093
  });
7094
 
7095
- parser.addListener("property", function(event){
7096
  // If we aren't inside an @font-face declaration then just return
7097
  if (!fontFaceRule) {
7098
  return;
7099
  }
7100
 
7101
  var propertyName = event.property.toString().toLowerCase(),
7102
- value = event.value.toString();
7103
 
7104
  // Set the line and col numbers for use in the endfontface listener
7105
  line = event.line;
7106
- col = event.col;
7107
 
7108
  // This is the property that we care about, we can ignore the rest
7109
- if (propertyName === 'src') {
7110
  var regex = /^\s?url\(['"].+\.eot\?.*['"]\)\s*format\(['"]embedded-opentype['"]\).*$/i;
7111
 
7112
  // We need to handle the advanced syntax with two src properties
@@ -7122,7 +8277,7 @@ CSSLint.addRule({
7122
  });
7123
 
7124
  // Back to normal rules that we don't need to test
7125
- parser.addListener("endfontface", function(event){
7126
  fontFaceRule = false;
7127
 
7128
  if (ruleFailed) {
@@ -7131,21 +8286,24 @@ CSSLint.addRule({
7131
  });
7132
  }
7133
  });
 
7134
  /*
7135
  * Rule: Include all compatible vendor prefixes to reach a wider
7136
  * range of users.
7137
  */
7138
- /*global CSSLint*/
7139
  CSSLint.addRule({
7140
 
7141
- //rule information
7142
  id: "compatible-vendor-prefixes",
7143
  name: "Require compatible vendor prefixes",
7144
  desc: "Include all compatible vendor prefixes to reach a wider range of users.",
 
7145
  browsers: "All",
7146
 
7147
- //initialization
7148
  init: function (parser, reporter) {
 
7149
  var rule = this,
7150
  compatiblePrefixes,
7151
  properties,
@@ -7160,15 +8318,15 @@ CSSLint.addRule({
7160
 
7161
  // See http://peter.sh/experiments/vendor-prefixed-css-property-overview/ for details
7162
  compatiblePrefixes = {
7163
- "animation" : "webkit moz",
7164
- "animation-delay" : "webkit moz",
7165
- "animation-direction" : "webkit moz",
7166
- "animation-duration" : "webkit moz",
7167
- "animation-fill-mode" : "webkit moz",
7168
- "animation-iteration-count" : "webkit moz",
7169
- "animation-name" : "webkit moz",
7170
- "animation-play-state" : "webkit moz",
7171
- "animation-timing-function" : "webkit moz",
7172
  "appearance" : "webkit moz",
7173
  "border-end" : "webkit moz",
7174
  "border-end-color" : "webkit moz",
@@ -7187,8 +8345,8 @@ CSSLint.addRule({
7187
  "box-ordinal-group" : "webkit moz ms",
7188
  "box-orient" : "webkit moz ms",
7189
  "box-pack" : "webkit moz ms",
7190
- "box-sizing" : "webkit moz",
7191
- "box-shadow" : "webkit moz",
7192
  "column-count" : "webkit moz ms",
7193
  "column-gap" : "webkit moz ms",
7194
  "column-rule" : "webkit moz ms",
@@ -7206,13 +8364,13 @@ CSSLint.addRule({
7206
  "padding-start" : "webkit moz",
7207
  "tab-size" : "moz o",
7208
  "text-size-adjust" : "webkit ms",
7209
- "transform" : "webkit moz ms o",
7210
- "transform-origin" : "webkit moz ms o",
7211
- "transition" : "webkit moz o",
7212
- "transition-delay" : "webkit moz o",
7213
- "transition-duration" : "webkit moz o",
7214
- "transition-property" : "webkit moz o",
7215
- "transition-timing-function" : "webkit moz o",
7216
  "user-modify" : "webkit moz",
7217
  "user-select" : "webkit moz ms",
7218
  "word-break" : "epub ms",
@@ -7223,9 +8381,9 @@ CSSLint.addRule({
7223
  for (prop in compatiblePrefixes) {
7224
  if (compatiblePrefixes.hasOwnProperty(prop)) {
7225
  variations = [];
7226
- prefixed = compatiblePrefixes[prop].split(' ');
7227
  for (i = 0, len = prefixed.length; i < len; i++) {
7228
- variations.push('-' + prefixed[i] + '-' + prop);
7229
  }
7230
  compatiblePrefixes[prop] = variations;
7231
  arrayPush.apply(applyTo, variations);
@@ -7240,7 +8398,7 @@ CSSLint.addRule({
7240
  inKeyFrame = event.prefix || true;
7241
  });
7242
 
7243
- parser.addListener("endkeyframes", function (event) {
7244
  inKeyFrame = false;
7245
  });
7246
 
@@ -7249,14 +8407,14 @@ CSSLint.addRule({
7249
  if (CSSLint.Util.indexOf(applyTo, name.text) > -1) {
7250
 
7251
  // e.g., -moz-transform is okay to be alone in @-moz-keyframes
7252
- if (!inKeyFrame || typeof inKeyFrame != "string" ||
7253
  name.text.indexOf("-" + inKeyFrame + "-") !== 0) {
7254
  properties.push(name);
7255
  }
7256
  }
7257
  });
7258
 
7259
- parser.addListener("endrule", function (event) {
7260
  if (!properties.length) {
7261
  return;
7262
  }
@@ -7282,8 +8440,8 @@ CSSLint.addRule({
7282
  if (CSSLint.Util.indexOf(variations, name.text) > -1) {
7283
  if (!propertyGroups[prop]) {
7284
  propertyGroups[prop] = {
7285
- full : variations.slice(0),
7286
- actual : [],
7287
  actualNodes: []
7288
  };
7289
  }
@@ -7306,7 +8464,7 @@ CSSLint.addRule({
7306
  for (i = 0, len = full.length; i < len; i++) {
7307
  item = full[i];
7308
  if (CSSLint.Util.indexOf(actual, item) === -1) {
7309
- propertiesSpecified = (actual.length === 1) ? actual[0] : (actual.length == 2) ? actual.join(" and ") : actual.join(", ");
7310
  reporter.report("The property " + item + " is compatible with " + propertiesSpecified + " and should be included as well.", value.actualNodes[0].line, value.actualNodes[0].col, rule);
7311
  }
7312
  }
@@ -7317,6 +8475,7 @@ CSSLint.addRule({
7317
  });
7318
  }
7319
  });
 
7320
  /*
7321
  * Rule: Certain properties don't play well with certain display values.
7322
  * - float should not be used with inline-block
@@ -7324,17 +8483,19 @@ CSSLint.addRule({
7324
  * - vertical-align should not be used with block
7325
  * - margin, float should not be used with table-*
7326
  */
7327
- /*global CSSLint*/
7328
  CSSLint.addRule({
7329
 
7330
- //rule information
7331
  id: "display-property-grouping",
7332
  name: "Require properties appropriate for display",
7333
  desc: "Certain properties shouldn't be used with certain display property values.",
 
7334
  browsers: "All",
7335
 
7336
- //initialization
7337
- init: function(parser, reporter){
 
7338
  var rule = this;
7339
 
7340
  var propertiesToCheck = {
@@ -7356,26 +8517,26 @@ CSSLint.addRule({
7356
  },
7357
  properties;
7358
 
7359
- function reportProperty(name, display, msg){
7360
- if (properties[name]){
7361
- if (typeof propertiesToCheck[name] != "string" || properties[name].value.toLowerCase() != propertiesToCheck[name]){
7362
  reporter.report(msg || name + " can't be used with display: " + display + ".", properties[name].line, properties[name].col, rule);
7363
  }
7364
  }
7365
  }
7366
 
7367
- function startRule(){
7368
  properties = {};
7369
  }
7370
 
7371
- function endRule(){
7372
 
7373
  var display = properties.display ? properties.display.value : null;
7374
- if (display){
7375
- switch(display){
7376
 
7377
  case "inline":
7378
- //height, width, margin-top, margin-bottom, float should not be used with inline
7379
  reportProperty("height", display);
7380
  reportProperty("width", display);
7381
  reportProperty("margin", display);
@@ -7385,18 +8546,18 @@ CSSLint.addRule({
7385
  break;
7386
 
7387
  case "block":
7388
- //vertical-align should not be used with block
7389
  reportProperty("vertical-align", display);
7390
  break;
7391
 
7392
  case "inline-block":
7393
- //float should not be used with inline-block
7394
  reportProperty("float", display);
7395
  break;
7396
 
7397
  default:
7398
- //margin, float should not be used with table
7399
- if (display.indexOf("table-") === 0){
7400
  reportProperty("margin", display);
7401
  reportProperty("margin-left", display);
7402
  reportProperty("margin-right", display);
@@ -7405,7 +8566,7 @@ CSSLint.addRule({
7405
  reportProperty("float", display);
7406
  }
7407
 
7408
- //otherwise do nothing
7409
  }
7410
  }
7411
 
@@ -7416,12 +8577,17 @@ CSSLint.addRule({
7416
  parser.addListener("startkeyframerule", startRule);
7417
  parser.addListener("startpagemargin", startRule);
7418
  parser.addListener("startpage", startRule);
 
7419
 
7420
- parser.addListener("property", function(event){
7421
  var name = event.property.text.toLowerCase();
7422
 
7423
- if (propertiesToCheck[name]){
7424
- properties[name] = { value: event.value.text, line: event.property.line, col: event.property.col };
 
 
 
 
7425
  }
7426
  });
7427
 
@@ -7430,39 +8596,42 @@ CSSLint.addRule({
7430
  parser.addListener("endkeyframerule", endRule);
7431
  parser.addListener("endpagemargin", endRule);
7432
  parser.addListener("endpage", endRule);
 
7433
 
7434
  }
7435
 
7436
  });
 
7437
  /*
7438
  * Rule: Disallow duplicate background-images (using url).
7439
  */
7440
- /*global CSSLint*/
7441
  CSSLint.addRule({
7442
 
7443
- //rule information
7444
  id: "duplicate-background-images",
7445
  name: "Disallow duplicate background images",
7446
  desc: "Every background-image should be unique. Use a common class for e.g. sprites.",
 
7447
  browsers: "All",
7448
 
7449
- //initialization
7450
- init: function(parser, reporter){
 
7451
  var rule = this,
7452
  stack = {};
7453
 
7454
- parser.addListener("property", function(event){
7455
  var name = event.property.text,
7456
  value = event.value,
7457
  i, len;
7458
 
7459
  if (name.match(/background/i)) {
7460
  for (i=0, len=value.parts.length; i < len; i++) {
7461
- if (value.parts[i].type == 'uri') {
7462
- if (typeof stack[value.parts[i].uri] === 'undefined') {
7463
  stack[value.parts[i].uri] = event;
7464
- }
7465
- else {
7466
  reporter.report("Background image '" + value.parts[i].uri + "' was used multiple times, first declared at line " + stack[value.parts[i].uri].line + ", col " + stack[value.parts[i].uri].col + ".", event.line, event.col, rule);
7467
  }
7468
  }
@@ -7471,26 +8640,29 @@ CSSLint.addRule({
7471
  });
7472
  }
7473
  });
 
7474
  /*
7475
  * Rule: Duplicate properties must appear one after the other. If an already-defined
7476
  * property appears somewhere else in the rule, then it's likely an error.
7477
  */
7478
- /*global CSSLint*/
7479
  CSSLint.addRule({
7480
 
7481
- //rule information
7482
  id: "duplicate-properties",
7483
  name: "Disallow duplicate properties",
7484
  desc: "Duplicate properties must appear one after the other.",
 
7485
  browsers: "All",
7486
 
7487
- //initialization
7488
- init: function(parser, reporter){
 
7489
  var rule = this,
7490
  properties,
7491
  lastProperty;
7492
 
7493
- function startRule(event){
7494
  properties = {};
7495
  }
7496
 
@@ -7499,12 +8671,13 @@ CSSLint.addRule({
7499
  parser.addListener("startpage", startRule);
7500
  parser.addListener("startpagemargin", startRule);
7501
  parser.addListener("startkeyframerule", startRule);
 
7502
 
7503
- parser.addListener("property", function(event){
7504
  var property = event.property,
7505
  name = property.text.toLowerCase();
7506
 
7507
- if (properties[name] && (lastProperty != name || properties[name] == event.value.text)){
7508
  reporter.report("Duplicate property '" + event.property + "' found.", event.line, event.col, rule);
7509
  }
7510
 
@@ -7517,57 +8690,62 @@ CSSLint.addRule({
7517
  }
7518
 
7519
  });
 
7520
  /*
7521
  * Rule: Style rules without any properties defined should be removed.
7522
  */
7523
- /*global CSSLint*/
7524
  CSSLint.addRule({
7525
 
7526
- //rule information
7527
  id: "empty-rules",
7528
  name: "Disallow empty rules",
7529
  desc: "Rules without any properties specified should be removed.",
 
7530
  browsers: "All",
7531
 
7532
- //initialization
7533
- init: function(parser, reporter){
 
7534
  var rule = this,
7535
  count = 0;
7536
 
7537
- parser.addListener("startrule", function(){
7538
  count=0;
7539
  });
7540
 
7541
- parser.addListener("property", function(){
7542
  count++;
7543
  });
7544
 
7545
- parser.addListener("endrule", function(event){
7546
  var selectors = event.selectors;
7547
- if (count === 0){
7548
  reporter.report("Rule is empty.", selectors[0].line, selectors[0].col, rule);
7549
  }
7550
  });
7551
  }
7552
 
7553
  });
 
7554
  /*
7555
  * Rule: There should be no syntax errors. (Duh.)
7556
  */
7557
- /*global CSSLint*/
7558
  CSSLint.addRule({
7559
 
7560
- //rule information
7561
  id: "errors",
7562
  name: "Parsing Errors",
7563
  desc: "This rule looks for recoverable syntax errors.",
7564
  browsers: "All",
7565
 
7566
- //initialization
7567
- init: function(parser, reporter){
 
7568
  var rule = this;
7569
 
7570
- parser.addListener("error", function(event){
7571
  reporter.error(event.message, event.line, event.col, rule);
7572
  });
7573
 
@@ -7575,17 +8753,18 @@ CSSLint.addRule({
7575
 
7576
  });
7577
 
7578
- /*global CSSLint*/
7579
  CSSLint.addRule({
7580
 
7581
- //rule information
7582
  id: "fallback-colors",
7583
  name: "Require fallback colors",
7584
  desc: "For older browsers that don't support RGBA, HSL, or HSLA, provide a fallback color.",
 
7585
  browsers: "IE6,IE7,IE8",
7586
 
7587
- //initialization
7588
- init: function(parser, reporter){
 
7589
  var rule = this,
7590
  lastProperty,
7591
  propertiesToCheck = {
@@ -7602,11 +8781,9 @@ CSSLint.addRule({
7602
  "border-bottom": 1,
7603
  "border-left": 1,
7604
  "background-color": 1
7605
- },
7606
- properties;
7607
 
7608
- function startRule(event){
7609
- properties = {};
7610
  lastProperty = null;
7611
  }
7612
 
@@ -7615,8 +8792,9 @@ CSSLint.addRule({
7615
  parser.addListener("startpage", startRule);
7616
  parser.addListener("startpagemargin", startRule);
7617
  parser.addListener("startkeyframerule", startRule);
 
7618
 
7619
- parser.addListener("property", function(event){
7620
  var property = event.property,
7621
  name = property.text.toLowerCase(),
7622
  parts = event.value.parts,
@@ -7624,16 +8802,16 @@ CSSLint.addRule({
7624
  colorType = "",
7625
  len = parts.length;
7626
 
7627
- if(propertiesToCheck[name]){
7628
- while(i < len){
7629
- if (parts[i].type == "color"){
7630
- if ("alpha" in parts[i] || "hue" in parts[i]){
7631
 
7632
- if (/([^\)]+)\(/.test(parts[i])){
7633
  colorType = RegExp.$1.toUpperCase();
7634
  }
7635
 
7636
- if (!lastProperty || (lastProperty.property.text.toLowerCase() != name || lastProperty.colorType != "compat")){
7637
  reporter.report("Fallback " + name + " (hex or RGB) should precede " + colorType + " " + name + ".", event.line, event.col, rule);
7638
  }
7639
  } else {
@@ -7651,125 +8829,136 @@ CSSLint.addRule({
7651
  }
7652
 
7653
  });
 
7654
  /*
7655
  * Rule: You shouldn't use more than 10 floats. If you do, there's probably
7656
  * room for some abstraction.
7657
  */
7658
- /*global CSSLint*/
7659
  CSSLint.addRule({
7660
 
7661
- //rule information
7662
  id: "floats",
7663
  name: "Disallow too many floats",
7664
  desc: "This rule tests if the float property is used too many times",
 
7665
  browsers: "All",
7666
 
7667
- //initialization
7668
- init: function(parser, reporter){
 
7669
  var rule = this;
7670
  var count = 0;
7671
 
7672
- //count how many times "float" is used
7673
- parser.addListener("property", function(event){
7674
- if (event.property.text.toLowerCase() == "float" &&
7675
- event.value.text.toLowerCase() != "none"){
7676
  count++;
7677
  }
7678
  });
7679
 
7680
- //report the results
7681
- parser.addListener("endstylesheet", function(){
7682
  reporter.stat("floats", count);
7683
- if (count >= 10){
7684
  reporter.rollupWarn("Too many floats (" + count + "), you're probably using them for layout. Consider using a grid system instead.", rule);
7685
  }
7686
  });
7687
  }
7688
 
7689
  });
 
7690
  /*
7691
  * Rule: Avoid too many @font-face declarations in the same stylesheet.
7692
  */
7693
- /*global CSSLint*/
7694
  CSSLint.addRule({
7695
 
7696
- //rule information
7697
  id: "font-faces",
7698
  name: "Don't use too many web fonts",
7699
  desc: "Too many different web fonts in the same stylesheet.",
 
7700
  browsers: "All",
7701
 
7702
- //initialization
7703
- init: function(parser, reporter){
 
7704
  var rule = this,
7705
  count = 0;
7706
 
7707
 
7708
- parser.addListener("startfontface", function(){
7709
  count++;
7710
  });
7711
 
7712
- parser.addListener("endstylesheet", function(){
7713
- if (count > 5){
7714
  reporter.rollupWarn("Too many @font-face declarations (" + count + ").", rule);
7715
  }
7716
  });
7717
  }
7718
 
7719
  });
 
7720
  /*
7721
  * Rule: You shouldn't need more than 9 font-size declarations.
7722
  */
7723
 
7724
- /*global CSSLint*/
7725
  CSSLint.addRule({
7726
 
7727
- //rule information
7728
  id: "font-sizes",
7729
  name: "Disallow too many font sizes",
7730
  desc: "Checks the number of font-size declarations.",
 
7731
  browsers: "All",
7732
 
7733
- //initialization
7734
- init: function(parser, reporter){
 
7735
  var rule = this,
7736
  count = 0;
7737
 
7738
- //check for use of "font-size"
7739
- parser.addListener("property", function(event){
7740
- if (event.property == "font-size"){
7741
  count++;
7742
  }
7743
  });
7744
 
7745
- //report the results
7746
- parser.addListener("endstylesheet", function(){
7747
  reporter.stat("font-sizes", count);
7748
- if (count >= 10){
7749
  reporter.rollupWarn("Too many font-size declarations (" + count + "), abstraction needed.", rule);
7750
  }
7751
  });
7752
  }
7753
 
7754
  });
 
7755
  /*
7756
  * Rule: When using a vendor-prefixed gradient, make sure to use them all.
7757
  */
7758
- /*global CSSLint*/
7759
  CSSLint.addRule({
7760
 
7761
- //rule information
7762
  id: "gradients",
7763
  name: "Require all gradient definitions",
7764
  desc: "When using a vendor-prefixed gradient, make sure to use them all.",
 
7765
  browsers: "All",
7766
 
7767
- //initialization
7768
- init: function(parser, reporter){
 
7769
  var rule = this,
7770
  gradients;
7771
 
7772
- parser.addListener("startrule", function(){
7773
  gradients = {
7774
  moz: 0,
7775
  webkit: 0,
@@ -7778,36 +8967,36 @@ CSSLint.addRule({
7778
  };
7779
  });
7780
 
7781
- parser.addListener("property", function(event){
7782
 
7783
- if (/\-(moz|o|webkit)(?:\-(?:linear|radial))\-gradient/i.test(event.value)){
7784
  gradients[RegExp.$1] = 1;
7785
- } else if (/\-webkit\-gradient/i.test(event.value)){
7786
  gradients.oldWebkit = 1;
7787
  }
7788
 
7789
  });
7790
 
7791
- parser.addListener("endrule", function(event){
7792
  var missing = [];
7793
 
7794
- if (!gradients.moz){
7795
  missing.push("Firefox 3.6+");
7796
  }
7797
 
7798
- if (!gradients.webkit){
7799
  missing.push("Webkit (Safari 5+, Chrome)");
7800
  }
7801
 
7802
- if (!gradients.oldWebkit){
7803
  missing.push("Old Webkit (Safari 4+, Chrome)");
7804
  }
7805
 
7806
- if (!gradients.o){
7807
  missing.push("Opera 11.1+");
7808
  }
7809
 
7810
- if (missing.length && missing.length < 4){
7811
  reporter.report("Missing vendor-prefixed CSS gradients for " + missing.join(", ") + ".", event.selectors[0].line, event.selectors[0].col, rule);
7812
  }
7813
 
@@ -7820,19 +9009,21 @@ CSSLint.addRule({
7820
  /*
7821
  * Rule: Don't use IDs for selectors.
7822
  */
7823
- /*global CSSLint*/
7824
  CSSLint.addRule({
7825
 
7826
- //rule information
7827
  id: "ids",
7828
  name: "Disallow IDs in selectors",
7829
  desc: "Selectors should not contain IDs.",
 
7830
  browsers: "All",
7831
 
7832
- //initialization
7833
- init: function(parser, reporter){
 
7834
  var rule = this;
7835
- parser.addListener("startrule", function(event){
7836
  var selectors = event.selectors,
7837
  selector,
7838
  part,
@@ -7840,25 +9031,25 @@ CSSLint.addRule({
7840
  idCount,
7841
  i, j, k;
7842
 
7843
- for (i=0; i < selectors.length; i++){
7844
  selector = selectors[i];
7845
  idCount = 0;
7846
 
7847
- for (j=0; j < selector.parts.length; j++){
7848
  part = selector.parts[j];
7849
- if (part.type == parser.SELECTOR_PART_TYPE){
7850
- for (k=0; k < part.modifiers.length; k++){
7851
  modifier = part.modifiers[k];
7852
- if (modifier.type == "id"){
7853
  idCount++;
7854
  }
7855
  }
7856
  }
7857
  }
7858
 
7859
- if (idCount == 1){
7860
  reporter.report("Don't use IDs in selectors.", selector.line, selector.col, rule);
7861
- } else if (idCount > 1){
7862
  reporter.report(idCount + " IDs in the selector, really?", selector.line, selector.col, rule);
7863
  }
7864
  }
@@ -7867,85 +9058,136 @@ CSSLint.addRule({
7867
  }
7868
 
7869
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7870
  /*
7871
  * Rule: Don't use @import, use <link> instead.
7872
  */
7873
- /*global CSSLint*/
7874
  CSSLint.addRule({
7875
 
7876
- //rule information
7877
  id: "import",
7878
  name: "Disallow @import",
7879
  desc: "Don't use @import, use <link> instead.",
 
7880
  browsers: "All",
7881
 
7882
- //initialization
7883
- init: function(parser, reporter){
 
7884
  var rule = this;
7885
 
7886
- parser.addListener("import", function(event){
7887
  reporter.report("@import prevents parallel downloads, use <link> instead.", event.line, event.col, rule);
7888
  });
7889
 
7890
  }
7891
 
7892
  });
 
7893
  /*
7894
  * Rule: Make sure !important is not overused, this could lead to specificity
7895
  * war. Display a warning on !important declarations, an error if it's
7896
  * used more at least 10 times.
7897
  */
7898
- /*global CSSLint*/
7899
  CSSLint.addRule({
7900
 
7901
- //rule information
7902
  id: "important",
7903
  name: "Disallow !important",
7904
  desc: "Be careful when using !important declaration",
 
7905
  browsers: "All",
7906
 
7907
- //initialization
7908
- init: function(parser, reporter){
 
7909
  var rule = this,
7910
  count = 0;
7911
 
7912
- //warn that important is used and increment the declaration counter
7913
- parser.addListener("property", function(event){
7914
- if (event.important === true){
7915
  count++;
7916
  reporter.report("Use of !important", event.line, event.col, rule);
7917
  }
7918
  });
7919
 
7920
- //if there are more than 10, show an error
7921
- parser.addListener("endstylesheet", function(){
7922
  reporter.stat("important", count);
7923
- if (count >= 10){
7924
  reporter.rollupWarn("Too many !important declarations (" + count + "), try to use less than 10 to avoid specificity issues.", rule);
7925
  }
7926
  });
7927
  }
7928
 
7929
  });
 
7930
  /*
7931
  * Rule: Properties should be known (listed in CSS3 specification) or
7932
  * be a vendor-prefixed property.
7933
  */
7934
- /*global CSSLint*/
7935
  CSSLint.addRule({
7936
 
7937
- //rule information
7938
  id: "known-properties",
7939
  name: "Require use of known properties",
7940
  desc: "Properties should be known (listed in CSS3 specification) or be a vendor-prefixed property.",
 
7941
  browsers: "All",
7942
 
7943
- //initialization
7944
- init: function(parser, reporter){
 
7945
  var rule = this;
7946
 
7947
- parser.addListener("property", function(event){
7948
- var name = event.property.text.toLowerCase();
7949
 
7950
  // the check is handled entirely by the parser-lib (https://github.com/nzakas/parser-lib)
7951
  if (event.invalid) {
@@ -7956,27 +9198,85 @@ CSSLint.addRule({
7956
  }
7957
 
7958
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7959
  /*
7960
  * Rule: outline: none or outline: 0 should only be used in a :focus rule
7961
  * and only if there are other properties in the same rule.
7962
  */
7963
- /*global CSSLint*/
7964
  CSSLint.addRule({
7965
 
7966
- //rule information
7967
  id: "outline-none",
7968
  name: "Disallow outline: none",
7969
  desc: "Use of outline: none or outline: 0 should be limited to :focus rules.",
 
7970
  browsers: "All",
7971
  tags: ["Accessibility"],
7972
 
7973
- //initialization
7974
- init: function(parser, reporter){
 
7975
  var rule = this,
7976
  lastRule;
7977
 
7978
- function startRule(event){
7979
- if (event.selectors){
7980
  lastRule = {
7981
  line: event.line,
7982
  col: event.col,
@@ -7989,12 +9289,12 @@ CSSLint.addRule({
7989
  }
7990
  }
7991
 
7992
- function endRule(event){
7993
- if (lastRule){
7994
- if (lastRule.outline){
7995
- if (lastRule.selectors.toString().toLowerCase().indexOf(":focus") == -1){
7996
  reporter.report("Outlines should only be modified using :focus.", lastRule.line, lastRule.col, rule);
7997
- } else if (lastRule.propCount == 1) {
7998
  reporter.report("Outlines shouldn't be hidden unless other visual changes are made.", lastRule.line, lastRule.col, rule);
7999
  }
8000
  }
@@ -8006,14 +9306,15 @@ CSSLint.addRule({
8006
  parser.addListener("startpage", startRule);
8007
  parser.addListener("startpagemargin", startRule);
8008
  parser.addListener("startkeyframerule", startRule);
 
8009
 
8010
- parser.addListener("property", function(event){
8011
  var name = event.property.text.toLowerCase(),
8012
  value = event.value;
8013
 
8014
- if (lastRule){
8015
  lastRule.propCount++;
8016
- if (name == "outline" && (value == "none" || value == "0")){
8017
  lastRule.outline = true;
8018
  }
8019
  }
@@ -8025,50 +9326,57 @@ CSSLint.addRule({
8025
  parser.addListener("endpage", endRule);
8026
  parser.addListener("endpagemargin", endRule);
8027
  parser.addListener("endkeyframerule", endRule);
 
8028
 
8029
  }
8030
 
8031
  });
 
8032
  /*
8033
  * Rule: Don't use classes or IDs with elements (a.foo or a#foo).
8034
  */
8035
- /*global CSSLint*/
8036
  CSSLint.addRule({
8037
 
8038
- //rule information
8039
  id: "overqualified-elements",
8040
  name: "Disallow overqualified elements",
8041
  desc: "Don't use classes or IDs with elements (a.foo or a#foo).",
 
8042
  browsers: "All",
8043
 
8044
- //initialization
8045
- init: function(parser, reporter){
 
8046
  var rule = this,
8047
  classes = {};
8048
 
8049
- parser.addListener("startrule", function(event){
8050
  var selectors = event.selectors,
8051
  selector,
8052
  part,
8053
  modifier,
8054
  i, j, k;
8055
 
8056
- for (i=0; i < selectors.length; i++){
8057
  selector = selectors[i];
8058
 
8059
- for (j=0; j < selector.parts.length; j++){
8060
  part = selector.parts[j];
8061
- if (part.type == parser.SELECTOR_PART_TYPE){
8062
- for (k=0; k < part.modifiers.length; k++){
8063
  modifier = part.modifiers[k];
8064
- if (part.elementName && modifier.type == "id"){
8065
  reporter.report("Element (" + part + ") is overqualified, just use " + modifier + " without element name.", part.line, part.col, rule);
8066
- } else if (modifier.type == "class"){
8067
 
8068
- if (!classes[modifier]){
8069
  classes[modifier] = [];
8070
  }
8071
- classes[modifier].push({ modifier: modifier, part: part });
 
 
 
8072
  }
8073
  }
8074
  }
@@ -8076,14 +9384,14 @@ CSSLint.addRule({
8076
  }
8077
  });
8078
 
8079
- parser.addListener("endstylesheet", function(){
8080
 
8081
  var prop;
8082
- for (prop in classes){
8083
- if (classes.hasOwnProperty(prop)){
8084
 
8085
- //one use means that this is overqualified
8086
- if (classes[prop].length == 1 && classes[prop][0].part.elementName){
8087
  reporter.report("Element (" + classes[prop][0].part + ") is overqualified, just use " + classes[prop][0].modifier + " without element name.", classes[prop][0].part.line, classes[prop][0].part.col, rule);
8088
  }
8089
  }
@@ -8092,35 +9400,38 @@ CSSLint.addRule({
8092
  }
8093
 
8094
  });
 
8095
  /*
8096
  * Rule: Headings (h1-h6) should not be qualified (namespaced).
8097
  */
8098
- /*global CSSLint*/
8099
  CSSLint.addRule({
8100
 
8101
- //rule information
8102
  id: "qualified-headings",
8103
  name: "Disallow qualified headings",
8104
  desc: "Headings should not be qualified (namespaced).",
 
8105
  browsers: "All",
8106
 
8107
- //initialization
8108
- init: function(parser, reporter){
 
8109
  var rule = this;
8110
 
8111
- parser.addListener("startrule", function(event){
8112
  var selectors = event.selectors,
8113
  selector,
8114
  part,
8115
  i, j;
8116
 
8117
- for (i=0; i < selectors.length; i++){
8118
  selector = selectors[i];
8119
 
8120
- for (j=0; j < selector.parts.length; j++){
8121
  part = selector.parts[j];
8122
- if (part.type == parser.SELECTOR_PART_TYPE){
8123
- if (part.elementName && /h[1-6]/.test(part.elementName.toString()) && j > 0){
8124
  reporter.report("Heading (" + part.elementName + ") should not be qualified.", part.line, part.col, rule);
8125
  }
8126
  }
@@ -8130,38 +9441,41 @@ CSSLint.addRule({
8130
  }
8131
 
8132
  });
 
8133
  /*
8134
  * Rule: Selectors that look like regular expressions are slow and should be avoided.
8135
  */
8136
- /*global CSSLint*/
8137
  CSSLint.addRule({
8138
 
8139
- //rule information
8140
  id: "regex-selectors",
8141
  name: "Disallow selectors that look like regexs",
8142
  desc: "Selectors that look like regular expressions are slow and should be avoided.",
 
8143
  browsers: "All",
8144
 
8145
- //initialization
8146
- init: function(parser, reporter){
 
8147
  var rule = this;
8148
 
8149
- parser.addListener("startrule", function(event){
8150
  var selectors = event.selectors,
8151
  selector,
8152
  part,
8153
  modifier,
8154
  i, j, k;
8155
 
8156
- for (i=0; i < selectors.length; i++){
8157
  selector = selectors[i];
8158
- for (j=0; j < selector.parts.length; j++){
8159
  part = selector.parts[j];
8160
- if (part.type == parser.SELECTOR_PART_TYPE){
8161
- for (k=0; k < part.modifiers.length; k++){
8162
  modifier = part.modifiers[k];
8163
- if (modifier.type == "attribute"){
8164
- if (/([\~\|\^\$\*]=)/.test(modifier)){
8165
  reporter.report("Attribute selectors with " + RegExp.$1 + " are slow!", modifier.line, modifier.col, rule);
8166
  }
8167
  }
@@ -8174,57 +9488,60 @@ CSSLint.addRule({
8174
  }
8175
 
8176
  });
 
8177
  /*
8178
  * Rule: Total number of rules should not exceed x.
8179
  */
8180
- /*global CSSLint*/
8181
  CSSLint.addRule({
8182
 
8183
- //rule information
8184
  id: "rules-count",
8185
  name: "Rules Count",
8186
  desc: "Track how many rules there are.",
8187
  browsers: "All",
8188
 
8189
- //initialization
8190
- init: function(parser, reporter){
8191
- var rule = this,
8192
- count = 0;
8193
 
8194
- //count each rule
8195
- parser.addListener("startrule", function(){
8196
  count++;
8197
  });
8198
 
8199
- parser.addListener("endstylesheet", function(){
8200
  reporter.stat("rule-count", count);
8201
  });
8202
  }
8203
 
8204
  });
 
8205
  /*
8206
  * Rule: Warn people with approaching the IE 4095 limit
8207
  */
8208
- /*global CSSLint*/
8209
  CSSLint.addRule({
8210
 
8211
- //rule information
8212
  id: "selector-max-approaching",
8213
  name: "Warn when approaching the 4095 selector limit for IE",
8214
  desc: "Will warn when selector count is >= 3800 selectors.",
8215
  browsers: "IE",
8216
 
8217
- //initialization
8218
  init: function(parser, reporter) {
 
8219
  var rule = this, count = 0;
8220
 
8221
- parser.addListener('startrule', function(event) {
8222
  count += event.selectors.length;
8223
  });
8224
 
8225
  parser.addListener("endstylesheet", function() {
8226
  if (count >= 3800) {
8227
- reporter.report("You have " + count + " selectors. Internet Explorer supports a maximum of 4095 selectors per stylesheet. Consider refactoring.",0,0,rule);
8228
  }
8229
  });
8230
  }
@@ -8234,46 +9551,95 @@ CSSLint.addRule({
8234
  /*
8235
  * Rule: Warn people past the IE 4095 limit
8236
  */
8237
- /*global CSSLint*/
8238
  CSSLint.addRule({
8239
 
8240
- //rule information
8241
  id: "selector-max",
8242
  name: "Error when past the 4095 selector limit for IE",
8243
  desc: "Will error when selector count is > 4095.",
8244
  browsers: "IE",
8245
 
8246
- //initialization
8247
- init: function(parser, reporter){
 
8248
  var rule = this, count = 0;
8249
 
8250
- parser.addListener('startrule',function(event) {
8251
  count += event.selectors.length;
8252
  });
8253
 
8254
  parser.addListener("endstylesheet", function() {
8255
  if (count > 4095) {
8256
- reporter.report("You have " + count + " selectors. Internet Explorer supports a maximum of 4095 selectors per stylesheet. Consider refactoring.",0,0,rule);
8257
  }
8258
  });
8259
  }
8260
 
8261
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8262
  /*
8263
  * Rule: Use shorthand properties where possible.
8264
  *
8265
  */
8266
- /*global CSSLint*/
8267
  CSSLint.addRule({
8268
 
8269
- //rule information
8270
  id: "shorthand",
8271
  name: "Require shorthand properties",
8272
  desc: "Use shorthand properties where possible.",
 
8273
  browsers: "All",
8274
 
8275
- //initialization
8276
- init: function(parser, reporter){
 
8277
  var rule = this,
8278
  prop, i, len,
8279
  propertiesToCheck = {},
@@ -8293,34 +9659,34 @@ CSSLint.addRule({
8293
  ]
8294
  };
8295
 
8296
- //initialize propertiesToCheck
8297
- for (prop in mapping){
8298
- if (mapping.hasOwnProperty(prop)){
8299
- for (i=0, len=mapping[prop].length; i < len; i++){
8300
  propertiesToCheck[mapping[prop][i]] = prop;
8301
  }
8302
  }
8303
  }
8304
 
8305
- function startRule(event){
8306
  properties = {};
8307
  }
8308
 
8309
- //event handler for end of rules
8310
- function endRule(event){
8311
 
8312
  var prop, i, len, total;
8313
 
8314
- //check which properties this rule has
8315
- for (prop in mapping){
8316
- if (mapping.hasOwnProperty(prop)){
8317
  total=0;
8318
 
8319
- for (i=0, len=mapping[prop].length; i < len; i++){
8320
  total += properties[mapping[prop][i]] ? 1 : 0;
8321
  }
8322
 
8323
- if (total == mapping[prop].length){
8324
  reporter.report("The properties " + mapping[prop].join(", ") + " can be replaced by " + prop + ".", event.line, event.col, rule);
8325
  }
8326
  }
@@ -8330,12 +9696,11 @@ CSSLint.addRule({
8330
  parser.addListener("startrule", startRule);
8331
  parser.addListener("startfontface", startRule);
8332
 
8333
- //check for use of "font-size"
8334
- parser.addListener("property", function(event){
8335
- var name = event.property.toString().toLowerCase(),
8336
- value = event.value.parts[0].value;
8337
 
8338
- if (propertiesToCheck[name]){
8339
  properties[name] = 1;
8340
  }
8341
  });
@@ -8346,61 +9711,67 @@ CSSLint.addRule({
8346
  }
8347
 
8348
  });
 
8349
  /*
8350
  * Rule: Don't use properties with a star prefix.
8351
  *
8352
  */
8353
- /*global CSSLint*/
8354
  CSSLint.addRule({
8355
 
8356
- //rule information
8357
  id: "star-property-hack",
8358
  name: "Disallow properties with a star prefix",
8359
  desc: "Checks for the star property hack (targets IE6/7)",
 
8360
  browsers: "All",
8361
 
8362
- //initialization
8363
- init: function(parser, reporter){
 
8364
  var rule = this;
8365
 
8366
- //check if property name starts with "*"
8367
- parser.addListener("property", function(event){
8368
  var property = event.property;
8369
 
8370
- if (property.hack == "*") {
8371
  reporter.report("Property with star prefix found.", event.property.line, event.property.col, rule);
8372
  }
8373
  });
8374
  }
8375
  });
 
8376
  /*
8377
  * Rule: Don't use text-indent for image replacement if you need to support rtl.
8378
  *
8379
  */
8380
- /*global CSSLint*/
8381
  CSSLint.addRule({
8382
 
8383
- //rule information
8384
  id: "text-indent",
8385
  name: "Disallow negative text-indent",
8386
  desc: "Checks for text indent less than -99px",
 
8387
  browsers: "All",
8388
 
8389
- //initialization
8390
- init: function(parser, reporter){
 
8391
  var rule = this,
8392
  textIndent,
8393
  direction;
8394
 
8395
 
8396
- function startRule(event){
8397
  textIndent = false;
8398
  direction = "inherit";
8399
  }
8400
 
8401
- //event handler for end of rules
8402
- function endRule(event){
8403
- if (textIndent && direction != "ltr"){
8404
  reporter.report("Negative text-indent doesn't work well with RTL. If you use text-indent for image replacement explicitly set direction for that item to ltr.", textIndent.line, textIndent.col, rule);
8405
  }
8406
  }
@@ -8408,14 +9779,14 @@ CSSLint.addRule({
8408
  parser.addListener("startrule", startRule);
8409
  parser.addListener("startfontface", startRule);
8410
 
8411
- //check for use of "font-size"
8412
- parser.addListener("property", function(event){
8413
  var name = event.property.toString().toLowerCase(),
8414
  value = event.value;
8415
 
8416
- if (name == "text-indent" && value.parts[0].value < -99){
8417
  textIndent = event.property;
8418
- } else if (name == "direction" && value == "ltr"){
8419
  direction = "ltr";
8420
  }
8421
  });
@@ -8426,79 +9797,85 @@ CSSLint.addRule({
8426
  }
8427
 
8428
  });
 
8429
  /*
8430
  * Rule: Don't use properties with a underscore prefix.
8431
  *
8432
  */
8433
- /*global CSSLint*/
8434
  CSSLint.addRule({
8435
 
8436
- //rule information
8437
  id: "underscore-property-hack",
8438
  name: "Disallow properties with an underscore prefix",
8439
  desc: "Checks for the underscore property hack (targets IE6)",
 
8440
  browsers: "All",
8441
 
8442
- //initialization
8443
- init: function(parser, reporter){
 
8444
  var rule = this;
8445
 
8446
- //check if property name starts with "_"
8447
- parser.addListener("property", function(event){
8448
  var property = event.property;
8449
 
8450
- if (property.hack == "_") {
8451
  reporter.report("Property with underscore prefix found.", event.property.line, event.property.col, rule);
8452
  }
8453
  });
8454
  }
8455
  });
 
8456
  /*
8457
  * Rule: Headings (h1-h6) should be defined only once.
8458
  */
8459
- /*global CSSLint*/
8460
  CSSLint.addRule({
8461
 
8462
- //rule information
8463
  id: "unique-headings",
8464
  name: "Headings should only be defined once",
8465
  desc: "Headings should be defined only once.",
 
8466
  browsers: "All",
8467
 
8468
- //initialization
8469
- init: function(parser, reporter){
 
8470
  var rule = this;
8471
 
8472
- var headings = {
8473
- h1: 0,
8474
- h2: 0,
8475
- h3: 0,
8476
- h4: 0,
8477
- h5: 0,
8478
- h6: 0
8479
- };
8480
 
8481
- parser.addListener("startrule", function(event){
8482
  var selectors = event.selectors,
8483
  selector,
8484
  part,
8485
  pseudo,
8486
  i, j;
8487
 
8488
- for (i=0; i < selectors.length; i++){
8489
  selector = selectors[i];
8490
  part = selector.parts[selector.parts.length-1];
8491
 
8492
- if (part.elementName && /(h[1-6])/i.test(part.elementName.toString())){
8493
 
8494
- for (j=0; j < part.modifiers.length; j++){
8495
- if (part.modifiers[j].type == "pseudo"){
8496
  pseudo = true;
8497
  break;
8498
  }
8499
  }
8500
 
8501
- if (!pseudo){
8502
  headings[RegExp.$1]++;
8503
  if (headings[RegExp.$1] > 1) {
8504
  reporter.report("Heading (" + part.elementName + ") has already been defined.", part.line, part.col, rule);
@@ -8508,53 +9885,55 @@ CSSLint.addRule({
8508
  }
8509
  });
8510
 
8511
- parser.addListener("endstylesheet", function(event){
8512
  var prop,
8513
  messages = [];
8514
 
8515
- for (prop in headings){
8516
- if (headings.hasOwnProperty(prop)){
8517
- if (headings[prop] > 1){
8518
  messages.push(headings[prop] + " " + prop + "s");
8519
  }
8520
  }
8521
  }
8522
 
8523
- if (messages.length){
8524
  reporter.rollupWarn("You have " + messages.join(", ") + " defined in this stylesheet.", rule);
8525
  }
8526
  });
8527
  }
8528
 
8529
  });
 
8530
  /*
8531
  * Rule: Don't use universal selector because it's slow.
8532
  */
8533
- /*global CSSLint*/
8534
  CSSLint.addRule({
8535
 
8536
- //rule information
8537
  id: "universal-selector",
8538
  name: "Disallow universal selector",
8539
  desc: "The universal selector (*) is known to be slow.",
 
8540
  browsers: "All",
8541
 
8542
- //initialization
8543
- init: function(parser, reporter){
 
8544
  var rule = this;
8545
 
8546
- parser.addListener("startrule", function(event){
8547
  var selectors = event.selectors,
8548
  selector,
8549
  part,
8550
- modifier,
8551
- i, j, k;
8552
 
8553
- for (i=0; i < selectors.length; i++){
8554
  selector = selectors[i];
8555
 
8556
  part = selector.parts[selector.parts.length-1];
8557
- if (part.elementName == "*"){
8558
  reporter.report(rule.desc, part.line, part.col, rule);
8559
  }
8560
  }
@@ -8562,39 +9941,55 @@ CSSLint.addRule({
8562
  }
8563
 
8564
  });
 
8565
  /*
8566
  * Rule: Don't use unqualified attribute selectors because they're just like universal selectors.
8567
  */
8568
- /*global CSSLint*/
8569
  CSSLint.addRule({
8570
 
8571
- //rule information
8572
  id: "unqualified-attributes",
8573
  name: "Disallow unqualified attribute selectors",
8574
  desc: "Unqualified attribute selectors are known to be slow.",
 
8575
  browsers: "All",
8576
 
8577
- //initialization
8578
- init: function(parser, reporter){
 
 
8579
  var rule = this;
8580
 
8581
- parser.addListener("startrule", function(event){
8582
 
8583
  var selectors = event.selectors,
 
8584
  selector,
8585
  part,
8586
  modifier,
8587
- i, j, k;
8588
 
8589
- for (i=0; i < selectors.length; i++){
8590
  selector = selectors[i];
8591
 
8592
  part = selector.parts[selector.parts.length-1];
8593
- if (part.type == parser.SELECTOR_PART_TYPE){
8594
- for (k=0; k < part.modifiers.length; k++){
8595
  modifier = part.modifiers[k];
8596
- if (modifier.type == "attribute" && (!part.elementName || part.elementName == "*")){
8597
- reporter.report(rule.desc, part.line, part.col, rule);
 
 
 
 
 
 
 
 
 
 
 
8598
  }
8599
  }
8600
  }
@@ -8604,21 +9999,24 @@ CSSLint.addRule({
8604
  }
8605
 
8606
  });
 
8607
  /*
8608
  * Rule: When using a vendor-prefixed property, make sure to
8609
  * include the standard one.
8610
  */
8611
- /*global CSSLint*/
8612
  CSSLint.addRule({
8613
 
8614
- //rule information
8615
  id: "vendor-prefix",
8616
  name: "Require standard property with vendor prefix",
8617
  desc: "When using a vendor-prefixed property, make sure to include the standard one.",
 
8618
  browsers: "All",
8619
 
8620
- //initialization
8621
- init: function(parser, reporter){
 
8622
  var rule = this,
8623
  properties,
8624
  num,
@@ -8668,54 +10066,53 @@ CSSLint.addRule({
8668
  "-moz-box-shadow": "box-shadow",
8669
  "-webkit-box-shadow": "box-shadow",
8670
 
8671
- "-moz-transform" : "transform",
8672
- "-webkit-transform" : "transform",
8673
- "-o-transform" : "transform",
8674
- "-ms-transform" : "transform",
8675
 
8676
- "-moz-transform-origin" : "transform-origin",
8677
- "-webkit-transform-origin" : "transform-origin",
8678
- "-o-transform-origin" : "transform-origin",
8679
- "-ms-transform-origin" : "transform-origin",
8680
 
8681
- "-moz-box-sizing" : "box-sizing",
8682
- "-webkit-box-sizing" : "box-sizing",
8683
-
8684
- "-moz-user-select" : "user-select",
8685
- "-khtml-user-select" : "user-select",
8686
- "-webkit-user-select" : "user-select"
8687
  };
8688
 
8689
- //event handler for beginning of rules
8690
- function startRule(){
8691
  properties = {};
8692
- num=1;
8693
  }
8694
 
8695
- //event handler for end of rules
8696
- function endRule(event){
8697
  var prop,
8698
- i, len,
8699
- standard,
8700
  needed,
8701
  actual,
8702
  needsStandard = [];
8703
 
8704
- for (prop in properties){
8705
- if (propertiesToCheck[prop]){
8706
- needsStandard.push({ actual: prop, needed: propertiesToCheck[prop]});
 
 
 
8707
  }
8708
  }
8709
 
8710
- for (i=0, len=needsStandard.length; i < len; i++){
8711
  needed = needsStandard[i].needed;
8712
  actual = needsStandard[i].actual;
8713
 
8714
- if (!properties[needed]){
8715
  reporter.report("Missing standard property '" + needed + "' to go along with '" + actual + "'.", properties[actual][0].name.line, properties[actual][0].name.col, rule);
8716
  } else {
8717
- //make sure standard property is last
8718
- if (properties[needed][0].pos < properties[actual][0].pos){
8719
  reporter.report("Standard property '" + needed + "' should come after vendor-prefixed property '" + actual + "'.", properties[actual][0].name.line, properties[actual][0].name.col, rule);
8720
  }
8721
  }
@@ -8728,15 +10125,20 @@ CSSLint.addRule({
8728
  parser.addListener("startpage", startRule);
8729
  parser.addListener("startpagemargin", startRule);
8730
  parser.addListener("startkeyframerule", startRule);
 
8731
 
8732
- parser.addListener("property", function(event){
8733
  var name = event.property.text.toLowerCase();
8734
 
8735
- if (!properties[name]){
8736
  properties[name] = [];
8737
  }
8738
 
8739
- properties[name].push({ name: event.property, value : event.value, pos:num++ });
 
 
 
 
8740
  });
8741
 
8742
  parser.addListener("endrule", endRule);
@@ -8744,33 +10146,37 @@ CSSLint.addRule({
8744
  parser.addListener("endpage", endRule);
8745
  parser.addListener("endpagemargin", endRule);
8746
  parser.addListener("endkeyframerule", endRule);
 
8747
  }
8748
 
8749
  });
 
8750
  /*
8751
  * Rule: You don't need to specify units when a value is 0.
8752
  */
8753
- /*global CSSLint*/
8754
  CSSLint.addRule({
8755
 
8756
- //rule information
8757
  id: "zero-units",
8758
  name: "Disallow units for 0 values",
8759
  desc: "You don't need to specify units when a value is 0.",
 
8760
  browsers: "All",
8761
 
8762
- //initialization
8763
- init: function(parser, reporter){
 
8764
  var rule = this;
8765
 
8766
- //count how many times "float" is used
8767
- parser.addListener("property", function(event){
8768
  var parts = event.value.parts,
8769
  i = 0,
8770
  len = parts.length;
8771
 
8772
- while(i < len){
8773
- if ((parts[i].units || parts[i].type == "percentage") && parts[i].value === 0 && parts[i].type != "time"){
8774
  reporter.report("Values of 0 shouldn't have units specified.", parts[i].line, parts[i].col, rule);
8775
  }
8776
  i++;
@@ -8781,8 +10187,9 @@ CSSLint.addRule({
8781
  }
8782
 
8783
  });
8784
- /*global CSSLint*/
8785
  (function() {
 
8786
 
8787
  /**
8788
  * Replace special characters before write to output.
@@ -8801,7 +10208,7 @@ CSSLint.addRule({
8801
  return "";
8802
  }
8803
 
8804
- return str.replace(/[\"&><]/g, function(match) {
8805
  switch (match) {
8806
  case "\"":
8807
  return "&quot;";
@@ -8816,7 +10223,7 @@ CSSLint.addRule({
8816
  };
8817
 
8818
  CSSLint.addFormatter({
8819
- //format information
8820
  id: "checkstyle-xml",
8821
  name: "Checkstyle XML format",
8822
 
@@ -8824,7 +10231,7 @@ CSSLint.addRule({
8824
  * Return opening root XML tag.
8825
  * @return {String} to prepend before all results
8826
  */
8827
- startFormat: function(){
8828
  return "<?xml version=\"1.0\" encoding=\"utf-8\"?><checkstyle>";
8829
  },
8830
 
@@ -8832,7 +10239,7 @@ CSSLint.addRule({
8832
  * Return closing root XML tag.
8833
  * @return {String} to append after all results
8834
  */
8835
- endFormat: function(){
8836
  return "</checkstyle>";
8837
  },
8838
 
@@ -8853,7 +10260,7 @@ CSSLint.addRule({
8853
  * @param options {Object} (UNUSED for now) specifies special handling of output
8854
  * @return {String} output for results
8855
  */
8856
- formatResults: function(results, filename, options) {
8857
  var messages = results.messages,
8858
  output = [];
8859
 
@@ -8865,20 +10272,19 @@ CSSLint.addRule({
8865
  * @return rule source as {String}
8866
  */
8867
  var generateSource = function(rule) {
8868
- if (!rule || !('name' in rule)) {
8869
  return "";
8870
  }
8871
- return 'net.csslint.' + rule.name.replace(/\s/g,'');
8872
  };
8873
 
8874
 
8875
-
8876
  if (messages.length > 0) {
8877
  output.push("<file name=\""+filename+"\">");
8878
- CSSLint.Util.forEach(messages, function (message, i) {
8879
- //ignore rollups for now
8880
  if (!message.rollup) {
8881
- output.push("<error line=\"" + message.line + "\" column=\"" + message.col + "\" severity=\"" + message.type + "\"" +
8882
  " message=\"" + xmlEscape(message.message) + "\" source=\"" + generateSource(message.rule) +"\"/>");
8883
  }
8884
  });
@@ -8890,9 +10296,9 @@ CSSLint.addRule({
8890
  });
8891
 
8892
  }());
8893
- /*global CSSLint*/
8894
  CSSLint.addFormatter({
8895
- //format information
8896
  id: "compact",
8897
  name: "Compact, 'porcelain' format",
8898
 
@@ -8901,6 +10307,7 @@ CSSLint.addFormatter({
8901
  * @return {String} to prepend before all results
8902
  */
8903
  startFormat: function() {
 
8904
  return "";
8905
  },
8906
 
@@ -8909,6 +10316,7 @@ CSSLint.addFormatter({
8909
  * @return {String} to append after all results
8910
  */
8911
  endFormat: function() {
 
8912
  return "";
8913
  },
8914
 
@@ -8920,6 +10328,7 @@ CSSLint.addFormatter({
8920
  * @return {String} output for results
8921
  */
8922
  formatResults: function(results, filename, options) {
 
8923
  var messages = results.messages,
8924
  output = "";
8925
  options = options || {};
@@ -8937,21 +10346,21 @@ CSSLint.addFormatter({
8937
  return options.quiet ? "" : filename + ": Lint Free!";
8938
  }
8939
 
8940
- CSSLint.Util.forEach(messages, function(message, i) {
8941
  if (message.rollup) {
8942
- output += filename + ": " + capitalize(message.type) + " - " + message.message + "\n";
8943
  } else {
8944
- output += filename + ": " + "line " + message.line +
8945
- ", col " + message.col + ", " + capitalize(message.type) + " - " + message.message + "\n";
8946
  }
8947
  });
8948
 
8949
  return output;
8950
  }
8951
  });
8952
- /*global CSSLint*/
8953
  CSSLint.addFormatter({
8954
- //format information
8955
  id: "csslint-xml",
8956
  name: "CSSLint XML format",
8957
 
@@ -8959,7 +10368,8 @@ CSSLint.addFormatter({
8959
  * Return opening root XML tag.
8960
  * @return {String} to prepend before all results
8961
  */
8962
- startFormat: function(){
 
8963
  return "<?xml version=\"1.0\" encoding=\"utf-8\"?><csslint>";
8964
  },
8965
 
@@ -8967,7 +10377,8 @@ CSSLint.addFormatter({
8967
  * Return closing root XML tag.
8968
  * @return {String} to append after all results
8969
  */
8970
- endFormat: function(){
 
8971
  return "</csslint>";
8972
  },
8973
 
@@ -8978,7 +10389,8 @@ CSSLint.addFormatter({
8978
  * @param options {Object} (UNUSED for now) specifies special handling of output
8979
  * @return {String} output for results
8980
  */
8981
- formatResults: function(results, filename, options) {
 
8982
  var messages = results.messages,
8983
  output = [];
8984
 
@@ -8998,12 +10410,12 @@ CSSLint.addFormatter({
8998
  if (!str || str.constructor !== String) {
8999
  return "";
9000
  }
9001
- return str.replace(/\"/g, "'").replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
9002
  };
9003
 
9004
  if (messages.length > 0) {
9005
  output.push("<file name=\""+filename+"\">");
9006
- CSSLint.Util.forEach(messages, function (message, i) {
9007
  if (message.rollup) {
9008
  output.push("<issue severity=\"" + message.type + "\" reason=\"" + escapeSpecialCharacters(message.message) + "\" evidence=\"" + escapeSpecialCharacters(message.evidence) + "\"/>");
9009
  } else {
@@ -9017,9 +10429,62 @@ CSSLint.addFormatter({
9017
  return output.join("");
9018
  }
9019
  });
9020
- /*global CSSLint*/
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9021
  CSSLint.addFormatter({
9022
- //format information
9023
  id: "junit-xml",
9024
  name: "JUNIT XML format",
9025
 
@@ -9027,7 +10492,8 @@ CSSLint.addFormatter({
9027
  * Return opening root XML tag.
9028
  * @return {String} to prepend before all results
9029
  */
9030
- startFormat: function(){
 
9031
  return "<?xml version=\"1.0\" encoding=\"utf-8\"?><testsuites>";
9032
  },
9033
 
@@ -9036,6 +10502,7 @@ CSSLint.addFormatter({
9036
  * @return {String} to append after all results
9037
  */
9038
  endFormat: function() {
 
9039
  return "</testsuites>";
9040
  },
9041
 
@@ -9046,13 +10513,14 @@ CSSLint.addFormatter({
9046
  * @param options {Object} (UNUSED for now) specifies special handling of output
9047
  * @return {String} output for results
9048
  */
9049
- formatResults: function(results, filename, options) {
 
9050
 
9051
  var messages = results.messages,
9052
  output = [],
9053
  tests = {
9054
- 'error': 0,
9055
- 'failure': 0
9056
  };
9057
 
9058
  /**
@@ -9063,10 +10531,10 @@ CSSLint.addFormatter({
9063
  * @return rule source as {String}
9064
  */
9065
  var generateSource = function(rule) {
9066
- if (!rule || !('name' in rule)) {
9067
  return "";
9068
  }
9069
- return 'net.csslint.' + rule.name.replace(/\s/g,'');
9070
  };
9071
 
9072
  /**
@@ -9086,25 +10554,25 @@ CSSLint.addFormatter({
9086
  return "";
9087
  }
9088
 
9089
- return str.replace(/\"/g, "'").replace(/</g, "&lt;").replace(/>/g, "&gt;");
9090
 
9091
  };
9092
 
9093
  if (messages.length > 0) {
9094
 
9095
- messages.forEach(function (message, i) {
9096
 
9097
  // since junit has no warning class
9098
  // all issues as errors
9099
- var type = message.type === 'warning' ? 'error' : message.type;
9100
 
9101
- //ignore rollups for now
9102
  if (!message.rollup) {
9103
 
9104
- // build the test case seperately, once joined
9105
  // we'll add it to a custom array filtered by type
9106
  output.push("<testcase time=\"0\" name=\"" + generateSource(message.rule) + "\">");
9107
- output.push("<" + type + " message=\"" + escapeSpecialCharacters(message.message) + "\"><![CDATA[" + message.line + ':' + message.col + ':' + escapeSpecialCharacters(message.evidence) + "]]></" + type + ">");
9108
  output.push("</testcase>");
9109
 
9110
  tests[type] += 1;
@@ -9122,9 +10590,9 @@ CSSLint.addFormatter({
9122
 
9123
  }
9124
  });
9125
- /*global CSSLint*/
9126
  CSSLint.addFormatter({
9127
- //format information
9128
  id: "lint-xml",
9129
  name: "Lint XML format",
9130
 
@@ -9132,7 +10600,8 @@ CSSLint.addFormatter({
9132
  * Return opening root XML tag.
9133
  * @return {String} to prepend before all results
9134
  */
9135
- startFormat: function(){
 
9136
  return "<?xml version=\"1.0\" encoding=\"utf-8\"?><lint>";
9137
  },
9138
 
@@ -9140,7 +10609,8 @@ CSSLint.addFormatter({
9140
  * Return closing root XML tag.
9141
  * @return {String} to append after all results
9142
  */
9143
- endFormat: function(){
 
9144
  return "</lint>";
9145
  },
9146
 
@@ -9151,7 +10621,8 @@ CSSLint.addFormatter({
9151
  * @param options {Object} (UNUSED for now) specifies special handling of output
9152
  * @return {String} output for results
9153
  */
9154
- formatResults: function(results, filename, options) {
 
9155
  var messages = results.messages,
9156
  output = [];
9157
 
@@ -9171,17 +10642,21 @@ CSSLint.addFormatter({
9171
  if (!str || str.constructor !== String) {
9172
  return "";
9173
  }
9174
- return str.replace(/\"/g, "'").replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
9175
  };
9176
 
9177
  if (messages.length > 0) {
9178
 
9179
  output.push("<file name=\""+filename+"\">");
9180
- CSSLint.Util.forEach(messages, function (message, i) {
9181
  if (message.rollup) {
9182
  output.push("<issue severity=\"" + message.type + "\" reason=\"" + escapeSpecialCharacters(message.message) + "\" evidence=\"" + escapeSpecialCharacters(message.evidence) + "\"/>");
9183
  } else {
9184
- output.push("<issue line=\"" + message.line + "\" char=\"" + message.col + "\" severity=\"" + message.type + "\"" +
 
 
 
 
9185
  " reason=\"" + escapeSpecialCharacters(message.message) + "\" evidence=\"" + escapeSpecialCharacters(message.evidence) + "\"/>");
9186
  }
9187
  });
@@ -9191,9 +10666,9 @@ CSSLint.addFormatter({
9191
  return output.join("");
9192
  }
9193
  });
9194
- /*global CSSLint*/
9195
  CSSLint.addFormatter({
9196
- //format information
9197
  id: "text",
9198
  name: "Plain Text",
9199
 
@@ -9202,6 +10677,7 @@ CSSLint.addFormatter({
9202
  * @return {String} to prepend before all results
9203
  */
9204
  startFormat: function() {
 
9205
  return "";
9206
  },
9207
 
@@ -9210,6 +10686,7 @@ CSSLint.addFormatter({
9210
  * @return {String} to append after all results
9211
  */
9212
  endFormat: function() {
 
9213
  return "";
9214
  },
9215
 
@@ -9221,6 +10698,7 @@ CSSLint.addFormatter({
9221
  * @return {String} output for results
9222
  */
9223
  formatResults: function(results, filename, options) {
 
9224
  var messages = results.messages,
9225
  output = "";
9226
  options = options || {};
@@ -9229,14 +10707,21 @@ CSSLint.addFormatter({
9229
  return options.quiet ? "" : "\n\ncsslint: No errors in " + filename + ".";
9230
  }
9231
 
9232
- output = "\n\ncsslint: There are " + messages.length + " problems in " + filename + ".";
 
 
 
 
 
 
 
9233
  var pos = filename.lastIndexOf("/"),
9234
  shortFilename = filename;
9235
 
9236
- if (pos === -1){
9237
  pos = filename.lastIndexOf("\\");
9238
  }
9239
- if (pos > -1){
9240
  shortFilename = filename.substring(pos+1);
9241
  }
9242
 
@@ -9255,5 +10740,6 @@ CSSLint.addFormatter({
9255
  return output;
9256
  }
9257
  });
 
9258
  return CSSLint;
9259
  })();
1
  /*!
2
+ CSSLint v1.0.3
3
+ Copyright (c) 2016 Nicole Sullivan and Nicholas C. Zakas. All rights reserved.
4
 
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the 'Software'), to deal
7
  in the Software without restriction, including without limitation the rights
8
  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
  copies of the Software, and to permit persons to whom the Software is
12
  The above copyright notice and this permission notice shall be included in
13
  all copies or substantial portions of the Software.
14
 
15
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
  THE SOFTWARE.
22
 
23
  */
24
+
 
25
  var CSSLint = (function(){
26
+ var module = module || {},
27
+ exports = exports || {};
28
+
29
  /*!
30
  Parser-Lib
31
+ Copyright (c) 2009-2016 Nicholas C. Zakas. All rights reserved.
32
 
33
  Permission is hereby granted, free of charge, to any person obtaining a copy
34
  of this software and associated documentation files (the "Software"), to deal
47
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
48
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
49
  THE SOFTWARE.
 
50
  */
51
+ /* Version v1.0.0, Build time: 15-July-2016 12:36:10 */
52
+ var parserlib = (function () {
53
+ var require;
54
+ require=(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
55
+ "use strict";
56
+
57
+ /* exported Colors */
58
+
59
+ var Colors = module.exports = {
60
+ __proto__ :null,
61
+ aliceblue :"#f0f8ff",
62
+ antiquewhite :"#faebd7",
63
+ aqua :"#00ffff",
64
+ aquamarine :"#7fffd4",
65
+ azure :"#f0ffff",
66
+ beige :"#f5f5dc",
67
+ bisque :"#ffe4c4",
68
+ black :"#000000",
69
+ blanchedalmond :"#ffebcd",
70
+ blue :"#0000ff",
71
+ blueviolet :"#8a2be2",
72
+ brown :"#a52a2a",
73
+ burlywood :"#deb887",
74
+ cadetblue :"#5f9ea0",
75
+ chartreuse :"#7fff00",
76
+ chocolate :"#d2691e",
77
+ coral :"#ff7f50",
78
+ cornflowerblue :"#6495ed",
79
+ cornsilk :"#fff8dc",
80
+ crimson :"#dc143c",
81
+ cyan :"#00ffff",
82
+ darkblue :"#00008b",
83
+ darkcyan :"#008b8b",
84
+ darkgoldenrod :"#b8860b",
85
+ darkgray :"#a9a9a9",
86
+ darkgrey :"#a9a9a9",
87
+ darkgreen :"#006400",
88
+ darkkhaki :"#bdb76b",
89
+ darkmagenta :"#8b008b",
90
+ darkolivegreen :"#556b2f",
91
+ darkorange :"#ff8c00",
92
+ darkorchid :"#9932cc",
93
+ darkred :"#8b0000",
94
+ darksalmon :"#e9967a",
95
+ darkseagreen :"#8fbc8f",
96
+ darkslateblue :"#483d8b",
97
+ darkslategray :"#2f4f4f",
98
+ darkslategrey :"#2f4f4f",
99
+ darkturquoise :"#00ced1",
100
+ darkviolet :"#9400d3",
101
+ deeppink :"#ff1493",
102
+ deepskyblue :"#00bfff",
103
+ dimgray :"#696969",
104
+ dimgrey :"#696969",
105
+ dodgerblue :"#1e90ff",
106
+ firebrick :"#b22222",
107
+ floralwhite :"#fffaf0",
108
+ forestgreen :"#228b22",
109
+ fuchsia :"#ff00ff",
110
+ gainsboro :"#dcdcdc",
111
+ ghostwhite :"#f8f8ff",
112
+ gold :"#ffd700",
113
+ goldenrod :"#daa520",
114
+ gray :"#808080",
115
+ grey :"#808080",
116
+ green :"#008000",
117
+ greenyellow :"#adff2f",
118
+ honeydew :"#f0fff0",
119
+ hotpink :"#ff69b4",
120
+ indianred :"#cd5c5c",
121
+ indigo :"#4b0082",
122
+ ivory :"#fffff0",
123
+ khaki :"#f0e68c",
124
+ lavender :"#e6e6fa",
125
+ lavenderblush :"#fff0f5",
126
+ lawngreen :"#7cfc00",
127
+ lemonchiffon :"#fffacd",
128
+ lightblue :"#add8e6",
129
+ lightcoral :"#f08080",
130
+ lightcyan :"#e0ffff",
131
+ lightgoldenrodyellow :"#fafad2",
132
+ lightgray :"#d3d3d3",
133
+ lightgrey :"#d3d3d3",
134
+ lightgreen :"#90ee90",
135
+ lightpink :"#ffb6c1",
136
+ lightsalmon :"#ffa07a",
137
+ lightseagreen :"#20b2aa",
138
+ lightskyblue :"#87cefa",
139
+ lightslategray :"#778899",
140
+ lightslategrey :"#778899",
141
+ lightsteelblue :"#b0c4de",
142
+ lightyellow :"#ffffe0",
143
+ lime :"#00ff00",
144
+ limegreen :"#32cd32",
145
+ linen :"#faf0e6",
146
+ magenta :"#ff00ff",
147
+ maroon :"#800000",
148
+ mediumaquamarine:"#66cdaa",
149
+ mediumblue :"#0000cd",
150
+ mediumorchid :"#ba55d3",
151
+ mediumpurple :"#9370d8",
152
+ mediumseagreen :"#3cb371",
153
+ mediumslateblue :"#7b68ee",
154
+ mediumspringgreen :"#00fa9a",
155
+ mediumturquoise :"#48d1cc",
156
+ mediumvioletred :"#c71585",
157
+ midnightblue :"#191970",
158
+ mintcream :"#f5fffa",
159
+ mistyrose :"#ffe4e1",
160
+ moccasin :"#ffe4b5",
161
+ navajowhite :"#ffdead",
162
+ navy :"#000080",
163
+ oldlace :"#fdf5e6",
164
+ olive :"#808000",
165
+ olivedrab :"#6b8e23",
166
+ orange :"#ffa500",
167
+ orangered :"#ff4500",
168
+ orchid :"#da70d6",
169
+ palegoldenrod :"#eee8aa",
170
+ palegreen :"#98fb98",
171
+ paleturquoise :"#afeeee",
172
+ palevioletred :"#d87093",
173
+ papayawhip :"#ffefd5",
174
+ peachpuff :"#ffdab9",
175
+ peru :"#cd853f",
176
+ pink :"#ffc0cb",
177
+ plum :"#dda0dd",
178
+ powderblue :"#b0e0e6",
179
+ purple :"#800080",
180
+ red :"#ff0000",
181
+ rosybrown :"#bc8f8f",
182
+ royalblue :"#4169e1",
183
+ saddlebrown :"#8b4513",
184
+ salmon :"#fa8072",
185
+ sandybrown :"#f4a460",
186
+ seagreen :"#2e8b57",
187
+ seashell :"#fff5ee",
188
+ sienna :"#a0522d",
189
+ silver :"#c0c0c0",
190
+ skyblue :"#87ceeb",
191
+ slateblue :"#6a5acd",
192
+ slategray :"#708090",
193
+ slategrey :"#708090",
194
+ snow :"#fffafa",
195
+ springgreen :"#00ff7f",
196
+ steelblue :"#4682b4",
197
+ tan :"#d2b48c",
198
+ teal :"#008080",
199
+ thistle :"#d8bfd8",
200
+ tomato :"#ff6347",
201
+ turquoise :"#40e0d0",
202
+ violet :"#ee82ee",
203
+ wheat :"#f5deb3",
204
+ white :"#ffffff",
205
+ whitesmoke :"#f5f5f5",
206
+ yellow :"#ffff00",
207
+ yellowgreen :"#9acd32",
208
+ //'currentColor' color keyword https://www.w3.org/TR/css3-color/#currentcolor
209
+ currentColor :"The value of the 'color' property.",
210
+ //CSS2 system colors https://www.w3.org/TR/css3-color/#css2-system
211
+ activeBorder :"Active window border.",
212
+ activecaption :"Active window caption.",
213
+ appworkspace :"Background color of multiple document interface.",
214
+ background :"Desktop background.",
215
+ buttonface :"The face background color for 3-D elements that appear 3-D due to one layer of surrounding border.",
216
+ buttonhighlight :"The color of the border facing the light source for 3-D elements that appear 3-D due to one layer of surrounding border.",
217
+ buttonshadow :"The color of the border away from the light source for 3-D elements that appear 3-D due to one layer of surrounding border.",
218
+ buttontext :"Text on push buttons.",
219
+ captiontext :"Text in caption, size box, and scrollbar arrow box.",
220
+ graytext :"Grayed (disabled) text. This color is set to #000 if the current display driver does not support a solid gray color.",
221
+ greytext :"Greyed (disabled) text. This color is set to #000 if the current display driver does not support a solid grey color.",
222
+ highlight :"Item(s) selected in a control.",
223
+ highlighttext :"Text of item(s) selected in a control.",
224
+ inactiveborder :"Inactive window border.",
225
+ inactivecaption :"Inactive window caption.",
226
+ inactivecaptiontext :"Color of text in an inactive caption.",
227
+ infobackground :"Background color for tooltip controls.",
228
+ infotext :"Text color for tooltip controls.",
229
+ menu :"Menu background.",
230
+ menutext :"Text in menus.",
231
+ scrollbar :"Scroll bar gray area.",
232
+ threeddarkshadow :"The color of the darker (generally outer) of the two borders away from the light source for 3-D elements that appear 3-D due to two concentric layers of surrounding border.",
233
+ threedface :"The face background color for 3-D elements that appear 3-D due to two concentric layers of surrounding border.",
234
+ threedhighlight :"The color of the lighter (generally outer) of the two borders facing the light source for 3-D elements that appear 3-D due to two concentric layers of surrounding border.",
235
+ threedlightshadow :"The color of the darker (generally inner) of the two borders facing the light source for 3-D elements that appear 3-D due to two concentric layers of surrounding border.",
236
+ threedshadow :"The color of the lighter (generally inner) of the two borders away from the light source for 3-D elements that appear 3-D due to two concentric layers of surrounding border.",
237
+ window :"Window background.",
238
+ windowframe :"Window frame.",
239
+ windowtext :"Text in windows."
240
+ };
241
 
242
+ },{}],2:[function(require,module,exports){
243
+ "use strict";
244
+
245
+ module.exports = Combinator;
246
+
247
+ var SyntaxUnit = require("../util/SyntaxUnit");
248
+
249
+ var Parser = require("./Parser");
250
 
251
  /**
252
+ * Represents a selector combinator (whitespace, +, >).
253
+ * @namespace parserlib.css
254
+ * @class Combinator
255
+ * @extends parserlib.util.SyntaxUnit
256
  * @constructor
257
+ * @param {String} text The text representation of the unit.
258
+ * @param {int} line The line of text on which the unit resides.
259
+ * @param {int} col The column of text on which the unit resides.
260
  */
261
+ function Combinator(text, line, col) {
262
+
263
+ SyntaxUnit.call(this, text, line, col, Parser.COMBINATOR_TYPE);
264
 
265
  /**
266
+ * The type of modifier.
267
+ * @type String
268
+ * @property type
 
269
  */
270
+ this.type = "unknown";
271
+
272
+ //pretty simple
273
+ if (/^\s+$/.test(text)) {
274
+ this.type = "descendant";
275
+ } else if (text === ">") {
276
+ this.type = "child";
277
+ } else if (text === "+") {
278
+ this.type = "adjacent-sibling";
279
+ } else if (text === "~") {
280
+ this.type = "sibling";
281
+ }
282
+
283
  }
284
 
285
+ Combinator.prototype = new SyntaxUnit();
286
+ Combinator.prototype.constructor = Combinator;
287
 
 
 
288
 
289
+ },{"../util/SyntaxUnit":26,"./Parser":6}],3:[function(require,module,exports){
290
+ "use strict";
 
 
 
 
 
 
 
 
 
291
 
292
+ module.exports = Matcher;
 
293
 
294
+ var StringReader = require("../util/StringReader");
295
+ var SyntaxError = require("../util/SyntaxError");
 
 
 
 
 
 
 
 
 
 
 
 
296
 
297
+ /**
298
+ * This class implements a combinator library for matcher functions.
299
+ * The combinators are described at:
300
+ * https://developer.mozilla.org/en-US/docs/Web/CSS/Value_definition_syntax#Component_value_combinators
301
+ */
302
+ function Matcher(matchFunc, toString) {
303
+ this.match = function(expression) {
304
+ // Save/restore marks to ensure that failed matches always restore
305
+ // the original location in the expression.
306
+ var result;
307
+ expression.mark();
308
+ result = matchFunc(expression);
309
+ if (result) {
310
+ expression.drop();
311
+ } else {
312
+ expression.restore();
313
  }
314
+ return result;
315
+ };
316
+ this.toString = typeof toString === "function" ? toString : function() {
317
+ return toString;
318
+ };
319
+ }
320
 
321
+ /** Precedence table of combinators. */
322
+ Matcher.prec = {
323
+ MOD: 5,
324
+ SEQ: 4,
325
+ ANDAND: 3,
326
+ OROR: 2,
327
+ ALT: 1
328
+ };
329
 
330
+ /** Simple recursive-descent grammar to build matchers from strings. */
331
+ Matcher.parse = function(str) {
332
+ var reader, eat, expr, oror, andand, seq, mod, term, result;
333
+ reader = new StringReader(str);
334
+ eat = function(matcher) {
335
+ var result = reader.readMatch(matcher);
336
+ if (result === null) {
337
+ throw new SyntaxError(
338
+ "Expected "+matcher, reader.getLine(), reader.getCol());
339
  }
340
+ return result;
341
+ };
342
+ expr = function() {
343
+ // expr = oror (" | " oror)*
344
+ var m = [ oror() ];
345
+ while (reader.readMatch(" | ") !== null) {
346
+ m.push(oror());
347
+ }
348
+ return m.length === 1 ? m[0] : Matcher.alt.apply(Matcher, m);
349
+ };
350
+ oror = function() {
351
+ // oror = andand ( " || " andand)*
352
+ var m = [ andand() ];
353
+ while (reader.readMatch(" || ") !== null) {
354
+ m.push(andand());
355
+ }
356
+ return m.length === 1 ? m[0] : Matcher.oror.apply(Matcher, m);
357
+ };
358
+ andand = function() {
359
+ // andand = seq ( " && " seq)*
360
+ var m = [ seq() ];
361
+ while (reader.readMatch(" && ") !== null) {
362
+ m.push(seq());
363
+ }
364
+ return m.length === 1 ? m[0] : Matcher.andand.apply(Matcher, m);
365
+ };
366
+ seq = function() {
367
+ // seq = mod ( " " mod)*
368
+ var m = [ mod() ];
369
+ while (reader.readMatch(/^ (?![&|\]])/) !== null) {
370
+ m.push(mod());
371
+ }
372
+ return m.length === 1 ? m[0] : Matcher.seq.apply(Matcher, m);
373
+ };
374
+ mod = function() {
375
+ // mod = term ( "?" | "*" | "+" | "#" | "{<num>,<num>}" )?
376
+ var m = term();
377
+ if (reader.readMatch("?") !== null) {
378
+ return m.question();
379
+ } else if (reader.readMatch("*") !== null) {
380
+ return m.star();
381
+ } else if (reader.readMatch("+") !== null) {
382
+ return m.plus();
383
+ } else if (reader.readMatch("#") !== null) {
384
+ return m.hash();
385
+ } else if (reader.readMatch(/^\{\s*/) !== null) {
386
+ var min = eat(/^\d+/);
387
+ eat(/^\s*,\s*/);
388
+ var max = eat(/^\d+/);
389
+ eat(/^\s*\}/);
390
+ return m.braces(+min, +max);
391
+ }
392
+ return m;
393
+ };
394
+ term = function() {
395
+ // term = <nt> | literal | "[ " expression " ]"
396
+ if (reader.readMatch("[ ") !== null) {
397
+ var m = expr();
398
+ eat(" ]");
399
+ return m;
400
+ }
401
+ return Matcher.fromType(eat(/^[^ ?*+#{]+/));
402
+ };
403
+ result = expr();
404
+ if (!reader.eof()) {
405
+ throw new SyntaxError(
406
+ "Expected end of string", reader.getLine(), reader.getCol());
407
+ }
408
+ return result;
409
+ };
410
+
411
+ /**
412
+ * Convert a string to a matcher (parsing simple alternations),
413
+ * or do nothing if the argument is already a matcher.
414
+ */
415
+ Matcher.cast = function(m) {
416
+ if (m instanceof Matcher) {
417
+ return m;
418
+ }
419
+ return Matcher.parse(m);
420
+ };
421
+
422
+ /**
423
+ * Create a matcher for a single type.
424
+ */
425
+ Matcher.fromType = function(type) {
426
+ // Late require of ValidationTypes to break a dependency cycle.
427
+ var ValidationTypes = require("./ValidationTypes");
428
+ return new Matcher(function(expression) {
429
+ return expression.hasNext() && ValidationTypes.isType(expression, type);
430
+ }, type);
431
+ };
432
+
433
+ /**
434
+ * Create a matcher for one or more juxtaposed words, which all must
435
+ * occur, in the given order.
436
+ */
437
+ Matcher.seq = function() {
438
+ var ms = Array.prototype.slice.call(arguments).map(Matcher.cast);
439
+ if (ms.length === 1) {
440
+ return ms[0];
441
+ }
442
+ return new Matcher(function(expression) {
443
+ var i, result = true;
444
+ for (i = 0; result && i < ms.length; i++) {
445
+ result = ms[i].match(expression);
446
+ }
447
+ return result;
448
+ }, function(prec) {
449
+ var p = Matcher.prec.SEQ;
450
+ var s = ms.map(function(m) {
451
+ return m.toString(p);
452
+ }).join(" ");
453
+ if (prec > p) {
454
+ s = "[ " + s + " ]";
455
+ }
456
+ return s;
457
+ });
458
+ };
459
+
460
+ /**
461
+ * Create a matcher for one or more alternatives, where exactly one
462
+ * must occur.
463
+ */
464
+ Matcher.alt = function() {
465
+ var ms = Array.prototype.slice.call(arguments).map(Matcher.cast);
466
+ if (ms.length === 1) {
467
+ return ms[0];
468
+ }
469
+ return new Matcher(function(expression) {
470
+ var i, result = false;
471
+ for (i = 0; !result && i < ms.length; i++) {
472
+ result = ms[i].match(expression);
473
+ }
474
+ return result;
475
+ }, function(prec) {
476
+ var p = Matcher.prec.ALT;
477
+ var s = ms.map(function(m) {
478
+ return m.toString(p);
479
+ }).join(" | ");
480
+ if (prec > p) {
481
+ s = "[ " + s + " ]";
482
+ }
483
+ return s;
484
+ });
485
+ };
486
+
487
+ /**
488
+ * Create a matcher for two or more options. This implements the
489
+ * double bar (||) and double ampersand (&&) operators, as well as
490
+ * variants of && where some of the alternatives are optional.
491
+ * This will backtrack through even successful matches to try to
492
+ * maximize the number of items matched.
493
+ */
494
+ Matcher.many = function(required) {
495
+ var ms = Array.prototype.slice.call(arguments, 1).reduce(function(acc, v) {
496
+ if (v.expand) {
497
+ // Insert all of the options for the given complex rule as
498
+ // individual options.
499
+ var ValidationTypes = require("./ValidationTypes");
500
+ acc.push.apply(acc, ValidationTypes.complex[v.expand].options);
501
+ } else {
502
+ acc.push(Matcher.cast(v));
503
+ }
504
+ return acc;
505
+ }, []);
506
+
507
+ if (required === true) {
508
+ required = ms.map(function() {
509
+ return true;
510
+ });
511
+ }
512
+
513
+ var result = new Matcher(function(expression) {
514
+ var seen = [], max = 0, pass = 0;
515
+ var success = function(matchCount) {
516
+ if (pass === 0) {
517
+ max = Math.max(matchCount, max);
518
+ return matchCount === ms.length;
519
+ } else {
520
+ return matchCount === max;
521
+ }
522
+ };
523
+ var tryMatch = function(matchCount) {
524
+ for (var i = 0; i < ms.length; i++) {
525
+ if (seen[i]) {
526
+ continue;
527
+ }
528
+ expression.mark();
529
+ if (ms[i].match(expression)) {
530
+ seen[i] = true;
531
+ // Increase matchCount iff this was a required element
532
+ // (or if all the elements are optional)
533
+ if (tryMatch(matchCount + ((required === false || required[i]) ? 1 : 0))) {
534
+ expression.drop();
535
+ return true;
536
+ }
537
+ // Backtrack: try *not* matching using this rule, and
538
+ // let's see if it leads to a better overall match.
539
+ expression.restore();
540
+ seen[i] = false;
541
+ } else {
542
+ expression.drop();
543
  }
544
  }
545
+ return success(matchCount);
546
+ };
547
+ if (!tryMatch(0)) {
548
+ // Couldn't get a complete match, retrace our steps to make the
549
+ // match with the maximum # of required elements.
550
+ pass++;
551
+ tryMatch(0);
552
+ }
553
+
554
+ if (required === false) {
555
+ return max > 0;
556
+ }
557
+ // Use finer-grained specification of which matchers are required.
558
+ for (var i = 0; i < ms.length; i++) {
559
+ if (required[i] && !seen[i]) {
560
+ return false;
561
+ }
562
+ }
563
+ return true;
564
+ }, function(prec) {
565
+ var p = required === false ? Matcher.prec.OROR : Matcher.prec.ANDAND;
566
+ var s = ms.map(function(m, i) {
567
+ if (required !== false && !required[i]) {
568
+ return m.toString(Matcher.prec.MOD) + "?";
569
+ }
570
+ return m.toString(p);
571
+ }).join(required === false ? " || " : " && ");
572
+ if (prec > p) {
573
+ s = "[ " + s + " ]";
574
+ }
575
+ return s;
576
+ });
577
+ result.options = ms;
578
+ return result;
579
+ };
580
+
581
+ /**
582
+ * Create a matcher for two or more options, where all options are
583
+ * mandatory but they may appear in any order.
584
+ */
585
+ Matcher.andand = function() {
586
+ var args = Array.prototype.slice.call(arguments);
587
+ args.unshift(true);
588
+ return Matcher.many.apply(Matcher, args);
589
+ };
590
 
591
+ /**
592
+ * Create a matcher for two or more options, where options are
593
+ * optional and may appear in any order, but at least one must be
594
+ * present.
595
+ */
596
+ Matcher.oror = function() {
597
+ var args = Array.prototype.slice.call(arguments);
598
+ args.unshift(false);
599
+ return Matcher.many.apply(Matcher, args);
600
+ };
601
 
602
+ /** Instance methods on Matchers. */
603
+ Matcher.prototype = {
604
+ constructor: Matcher,
605
+ // These are expected to be overridden in every instance.
606
+ match: function() { throw new Error("unimplemented"); },
607
+ toString: function() { throw new Error("unimplemented"); },
608
+ // This returns a standalone function to do the matching.
609
+ func: function() { return this.match.bind(this); },
610
+ // Basic combinators
611
+ then: function(m) { return Matcher.seq(this, m); },
612
+ or: function(m) { return Matcher.alt(this, m); },
613
+ andand: function(m) { return Matcher.many(true, this, m); },
614
+ oror: function(m) { return Matcher.many(false, this, m); },
615
+ // Component value multipliers
616
+ star: function() { return this.braces(0, Infinity, "*"); },
617
+ plus: function() { return this.braces(1, Infinity, "+"); },
618
+ question: function() { return this.braces(0, 1, "?"); },
619
+ hash: function() {
620
+ return this.braces(1, Infinity, "#", Matcher.cast(","));
621
+ },
622
+ braces: function(min, max, marker, optSep) {
623
+ var m1 = this, m2 = optSep ? optSep.then(this) : this;
624
+ if (!marker) {
625
+ marker = "{" + min + "," + max + "}";
626
  }
627
+ return new Matcher(function(expression) {
628
+ var result = true, i;
629
+ for (i = 0; i < max; i++) {
630
+ if (i > 0 && optSep) {
631
+ result = m2.match(expression);
632
+ } else {
633
+ result = m1.match(expression);
634
+ }
635
+ if (!result) {
636
+ break;
637
+ }
638
+ }
639
+ return i >= min;
640
+ }, function() {
641
+ return m1.toString(Matcher.prec.MOD) + marker;
642
+ });
643
  }
644
  };
645
+
646
+ },{"../util/StringReader":24,"../util/SyntaxError":25,"./ValidationTypes":21}],4:[function(require,module,exports){
647
+ "use strict";
648
+
649
+ module.exports = MediaFeature;
650
+
651
+ var SyntaxUnit = require("../util/SyntaxUnit");
652
+
653
+ var Parser = require("./Parser");
654
+
655
  /**
656
+ * Represents a media feature, such as max-width:500.
657
+ * @namespace parserlib.css
658
+ * @class MediaFeature
659
+ * @extends parserlib.util.SyntaxUnit
660
  * @constructor
661
+ * @param {SyntaxUnit} name The name of the feature.
662
+ * @param {SyntaxUnit} value The value of the feature or null if none.
663
  */
664
+ function MediaFeature(name, value) {
665
+
666
+ SyntaxUnit.call(this, "(" + name + (value !== null ? ":" + value : "") + ")", name.startLine, name.startCol, Parser.MEDIA_FEATURE_TYPE);
667
 
668
  /**
669
+ * The name of the media feature
 
670
  * @type String
671
+ * @property name
672
  */
673
+ this.name = name;
 
674
 
675
  /**
676
+ * The value for the feature or null if there is none.
677
+ * @type SyntaxUnit
678
+ * @property value
 
679
  */
680
+ this.value = value;
681
+ }
682
 
683
+ MediaFeature.prototype = new SyntaxUnit();
684
+ MediaFeature.prototype.constructor = MediaFeature;
685
 
 
 
 
 
 
 
 
686
 
687
+ },{"../util/SyntaxUnit":26,"./Parser":6}],5:[function(require,module,exports){
688
+ "use strict";
 
 
 
 
 
 
689
 
690
+ module.exports = MediaQuery;
691
 
692
+ var SyntaxUnit = require("../util/SyntaxUnit");
 
693
 
694
+ var Parser = require("./Parser");
 
 
695
 
696
+ /**
697
+ * Represents an individual media query.
698
+ * @namespace parserlib.css
699
+ * @class MediaQuery
700
+ * @extends parserlib.util.SyntaxUnit
701
+ * @constructor
702
+ * @param {String} modifier The modifier "not" or "only" (or null).
703
+ * @param {String} mediaType The type of media (i.e., "print").
704
+ * @param {Array} parts Array of selectors parts making up this selector.
705
+ * @param {int} line The line of text on which the unit resides.
706
+ * @param {int} col The column of text on which the unit resides.
707
+ */
708
+ function MediaQuery(modifier, mediaType, features, line, col) {
709
+
710
+ SyntaxUnit.call(this, (modifier ? modifier + " ": "") + (mediaType ? mediaType : "") + (mediaType && features.length > 0 ? " and " : "") + features.join(" and "), line, col, Parser.MEDIA_QUERY_TYPE);
711
 
712
  /**
713
+ * The media modifier ("not" or "only")
714
+ * @type String
715
+ * @property modifier
716
  */
717
+ this.modifier = modifier;
 
 
718
 
719
  /**
720
+ * The mediaType (i.e., "print")
721
+ * @type String
722
+ * @property mediaType
723
  */
724
+ this.mediaType = mediaType;
 
 
 
 
 
 
725
 
726
  /**
727
+ * The parts that make up the selector.
728
+ * @type Array
729
+ * @property features
 
730
  */
731
+ this.features = features;
 
 
732
 
733
+ }
 
734
 
735
+ MediaQuery.prototype = new SyntaxUnit();
736
+ MediaQuery.prototype.constructor = MediaQuery;
 
737
 
 
 
738
 
739
+ },{"../util/SyntaxUnit":26,"./Parser":6}],6:[function(require,module,exports){
740
+ "use strict";
 
 
 
 
 
 
741
 
742
+ module.exports = Parser;
 
743
 
744
+ var EventTarget = require("../util/EventTarget");
745
+ var SyntaxError = require("../util/SyntaxError");
746
+ var SyntaxUnit = require("../util/SyntaxUnit");
 
 
 
 
 
747
 
748
+ var Combinator = require("./Combinator");
749
+ var MediaFeature = require("./MediaFeature");
750
+ var MediaQuery = require("./MediaQuery");
751
+ var PropertyName = require("./PropertyName");
752
+ var PropertyValue = require("./PropertyValue");
753
+ var PropertyValuePart = require("./PropertyValuePart");
754
+ var Selector = require("./Selector");
755
+ var SelectorPart = require("./SelectorPart");
756
+ var SelectorSubPart = require("./SelectorSubPart");
757
+ var TokenStream = require("./TokenStream");
758
+ var Tokens = require("./Tokens");
759
+ var Validation = require("./Validation");
760
 
761
+ /**
762
+ * A CSS3 parser.
763
+ * @namespace parserlib.css
764
+ * @class Parser
765
+ * @constructor
766
+ * @param {Object} options (Optional) Various options for the parser:
767
+ * starHack (true|false) to allow IE6 star hack as valid,
768
+ * underscoreHack (true|false) to interpret leading underscores
769
+ * as IE6-7 targeting for known properties, ieFilters (true|false)
770
+ * to indicate that IE < 8 filters should be accepted and not throw
771
+ * syntax errors.
772
+ */
773
+ function Parser(options) {
774
 
775
+ //inherit event functionality
776
+ EventTarget.call(this);
 
777
 
 
 
 
 
 
 
 
 
 
 
 
 
778
 
779
+ this.options = options || {};
 
 
 
 
 
 
 
780
 
781
+ this._tokenStream = null;
782
+ }
 
783
 
784
+ //Static constants
785
+ Parser.DEFAULT_TYPE = 0;
786
+ Parser.COMBINATOR_TYPE = 1;
787
+ Parser.MEDIA_FEATURE_TYPE = 2;
788
+ Parser.MEDIA_QUERY_TYPE = 3;
789
+ Parser.PROPERTY_NAME_TYPE = 4;
790
+ Parser.PROPERTY_VALUE_TYPE = 5;
791
+ Parser.PROPERTY_VALUE_PART_TYPE = 6;
792
+ Parser.SELECTOR_TYPE = 7;
793
+ Parser.SELECTOR_PART_TYPE = 8;
794
+ Parser.SELECTOR_SUB_PART_TYPE = 9;
795
 
796
+ Parser.prototype = function() {
 
797
 
798
+ var proto = new EventTarget(), //new prototype
799
+ prop,
800
+ additions = {
801
+ __proto__: null,
 
 
 
 
 
 
 
 
 
802
 
803
+ //restore constructor
804
+ constructor: Parser,
805
 
806
+ //instance constants - yuck
807
+ DEFAULT_TYPE : 0,
808
+ COMBINATOR_TYPE : 1,
809
+ MEDIA_FEATURE_TYPE : 2,
810
+ MEDIA_QUERY_TYPE : 3,
811
+ PROPERTY_NAME_TYPE : 4,
812
+ PROPERTY_VALUE_TYPE : 5,
813
+ PROPERTY_VALUE_PART_TYPE : 6,
814
+ SELECTOR_TYPE : 7,
815
+ SELECTOR_PART_TYPE : 8,
816
+ SELECTOR_SUB_PART_TYPE : 9,
817
 
818
+ //-----------------------------------------------------------------
819
+ // Grammar
820
+ //-----------------------------------------------------------------
 
 
 
 
 
 
 
 
821
 
822
+ _stylesheet: function() {
 
823
 
824
+ /*
825
+ * stylesheet
826
+ * : [ CHARSET_SYM S* STRING S* ';' ]?
827
+ * [S|CDO|CDC]* [ import [S|CDO|CDC]* ]*
828
+ * [ namespace [S|CDO|CDC]* ]*
829
+ * [ [ ruleset | media | page | font_face | keyframes_rule | supports_rule ] [S|CDO|CDC]* ]*
830
+ * ;
831
+ */
832
 
833
+ var tokenStream = this._tokenStream,
834
+ count,
835
+ token,
836
+ tt;
837
 
838
+ this.fire("startstylesheet");
839
 
840
+ //try to read character set
841
+ this._charset();
 
 
 
 
 
 
 
 
 
 
 
842
 
843
+ this._skipCruft();
 
844
 
845
+ //try to read imports - may be more than one
846
+ while (tokenStream.peek() === Tokens.IMPORT_SYM) {
847
+ this._import();
848
+ this._skipCruft();
849
+ }
 
 
 
 
 
850
 
851
+ //try to read namespaces - may be more than one
852
+ while (tokenStream.peek() === Tokens.NAMESPACE_SYM) {
853
+ this._namespace();
854
+ this._skipCruft();
855
+ }
856
 
857
+ //get the next token
858
+ tt = tokenStream.peek();
859
 
860
+ //try to read the rest
861
+ while (tt > Tokens.EOF) {
 
 
 
 
 
 
 
862
 
863
+ try {
 
 
864
 
865
+ switch (tt) {
866
+ case Tokens.MEDIA_SYM:
867
+ this._media();
868
+ this._skipCruft();
869
+ break;
870
+ case Tokens.PAGE_SYM:
871
+ this._page();
872
+ this._skipCruft();
873
+ break;
874
+ case Tokens.FONT_FACE_SYM:
875
+ this._font_face();
876
+ this._skipCruft();
877
+ break;
878
+ case Tokens.KEYFRAMES_SYM:
879
+ this._keyframes();
880
+ this._skipCruft();
881
+ break;
882
+ case Tokens.VIEWPORT_SYM:
883
+ this._viewport();
884
+ this._skipCruft();
885
+ break;
886
+ case Tokens.DOCUMENT_SYM:
887
+ this._document();
888
+ this._skipCruft();
889
+ break;
890
+ case Tokens.SUPPORTS_SYM:
891
+ this._supports();
892
+ this._skipCruft();
893
+ break;
894
+ case Tokens.UNKNOWN_SYM: //unknown @ rule
895
+ tokenStream.get();
896
+ if (!this.options.strict) {
897
 
898
+ //fire error event
899
+ this.fire({
900
+ type: "error",
901
+ error: null,
902
+ message: "Unknown @ rule: " + tokenStream.LT(0).value + ".",
903
+ line: tokenStream.LT(0).startLine,
904
+ col: tokenStream.LT(0).startCol
905
+ });
 
 
 
906
 
907
+ //skip braces
908
+ count=0;
909
+ while (tokenStream.advance([Tokens.LBRACE, Tokens.RBRACE]) === Tokens.LBRACE) {
910
+ count++; //keep track of nesting depth
911
+ }
 
912
 
913
+ while (count) {
914
+ tokenStream.advance([Tokens.RBRACE]);
915
+ count--;
916
+ }
 
 
917
 
918
+ } else {
919
+ //not a syntax error, rethrow it
920
+ throw new SyntaxError("Unknown @ rule.", tokenStream.LT(0).startLine, tokenStream.LT(0).startCol);
921
+ }
922
+ break;
923
+ case Tokens.S:
924
+ this._readWhitespace();
925
+ break;
926
+ default:
927
+ if (!this._ruleset()) {
928
 
929
+ //error handling for known issues
930
+ switch (tt) {
931
+ case Tokens.CHARSET_SYM:
932
+ token = tokenStream.LT(1);
933
+ this._charset(false);
934
+ throw new SyntaxError("@charset not allowed here.", token.startLine, token.startCol);
935
+ case Tokens.IMPORT_SYM:
936
+ token = tokenStream.LT(1);
937
+ this._import(false);
938
+ throw new SyntaxError("@import not allowed here.", token.startLine, token.startCol);
939
+ case Tokens.NAMESPACE_SYM:
940
+ token = tokenStream.LT(1);
941
+ this._namespace(false);
942
+ throw new SyntaxError("@namespace not allowed here.", token.startLine, token.startCol);
943
+ default:
944
+ tokenStream.get(); //get the last token
945
+ this._unexpectedToken(tokenStream.token());
946
+ }
947
 
948
+ }
949
+ }
950
+ } catch (ex) {
951
+ if (ex instanceof SyntaxError && !this.options.strict) {
952
+ this.fire({
953
+ type: "error",
954
+ error: ex,
955
+ message: ex.message,
956
+ line: ex.line,
957
+ col: ex.col
958
+ });
959
+ } else {
960
+ throw ex;
961
+ }
962
+ }
963
 
964
+ tt = tokenStream.peek();
965
+ }
966
 
967
+ if (tt !== Tokens.EOF) {
968
+ this._unexpectedToken(tokenStream.token());
969
+ }
 
 
 
970
 
971
+ this.fire("endstylesheet");
972
+ },
 
 
 
 
973
 
974
+ _charset: function(emit) {
975
+ var tokenStream = this._tokenStream,
976
+ charset,
977
+ token,
978
+ line,
979
+ col;
980
 
981
+ if (tokenStream.match(Tokens.CHARSET_SYM)) {
982
+ line = tokenStream.token().startLine;
983
+ col = tokenStream.token().startCol;
 
 
 
 
984
 
985
+ this._readWhitespace();
986
+ tokenStream.mustMatch(Tokens.STRING);
 
 
 
 
 
 
 
 
 
 
987
 
988
+ token = tokenStream.token();
989
+ charset = token.value;
990
 
991
+ this._readWhitespace();
992
+ tokenStream.mustMatch(Tokens.SEMICOLON);
993
 
994
+ if (emit !== false) {
995
+ this.fire({
996
+ type: "charset",
997
+ charset:charset,
998
+ line: line,
999
+ col: col
1000
+ });
1001
+ }
1002
+ }
1003
+ },
1004
 
1005
+ _import: function(emit) {
1006
+ /*
1007
+ * import
1008
+ * : IMPORT_SYM S*
1009
+ * [STRING|URI] S* media_query_list? ';' S*
1010
+ */
 
 
1011
 
1012
+ var tokenStream = this._tokenStream,
1013
+ uri,
1014
+ importToken,
1015
+ mediaList = [];
1016
 
1017
+ //read import symbol
1018
+ tokenStream.mustMatch(Tokens.IMPORT_SYM);
1019
+ importToken = tokenStream.token();
1020
+ this._readWhitespace();
 
 
 
 
 
1021
 
1022
+ tokenStream.mustMatch([Tokens.STRING, Tokens.URI]);
 
 
 
 
 
 
1023
 
1024
+ //grab the URI value
1025
+ uri = tokenStream.token().value.replace(/^(?:url\()?["']?([^"']+?)["']?\)?$/, "$1");
 
 
 
 
 
1026
 
1027
+ this._readWhitespace();
 
 
 
 
 
 
1028
 
1029
+ mediaList = this._media_query_list();
 
 
 
 
 
 
1030
 
1031
+ //must end with a semicolon
1032
+ tokenStream.mustMatch(Tokens.SEMICOLON);
1033
+ this._readWhitespace();
 
 
 
 
1034
 
1035
+ if (emit !== false) {
1036
+ this.fire({
1037
+ type: "import",
1038
+ uri: uri,
1039
+ media: mediaList,
1040
+ line: importToken.startLine,
1041
+ col: importToken.startCol
1042
+ });
1043
+ }
1044
 
1045
+ },
 
 
 
 
 
 
 
 
 
1046
 
1047
+ _namespace: function(emit) {
1048
+ /*
1049
+ * namespace
1050
+ * : NAMESPACE_SYM S* [namespace_prefix S*]? [STRING|URI] S* ';' S*
1051
+ */
1052
 
1053
+ var tokenStream = this._tokenStream,
1054
+ line,
1055
+ col,
1056
+ prefix,
1057
+ uri;
1058
 
1059
+ //read import symbol
1060
+ tokenStream.mustMatch(Tokens.NAMESPACE_SYM);
1061
+ line = tokenStream.token().startLine;
1062
+ col = tokenStream.token().startCol;
1063
+ this._readWhitespace();
 
 
1064
 
1065
+ //it's a namespace prefix - no _namespace_prefix() method because it's just an IDENT
1066
+ if (tokenStream.match(Tokens.IDENT)) {
1067
+ prefix = tokenStream.token().value;
1068
+ this._readWhitespace();
1069
+ }
1070
 
1071
+ tokenStream.mustMatch([Tokens.STRING, Tokens.URI]);
1072
+ /*if (!tokenStream.match(Tokens.STRING)){
1073
+ tokenStream.mustMatch(Tokens.URI);
1074
+ }*/
1075
 
1076
+ //grab the URI value
1077
+ uri = tokenStream.token().value.replace(/(?:url\()?["']([^"']+)["']\)?/, "$1");
1078
 
1079
+ this._readWhitespace();
1080
 
1081
+ //must end with a semicolon
1082
+ tokenStream.mustMatch(Tokens.SEMICOLON);
1083
+ this._readWhitespace();
1084
 
1085
+ if (emit !== false) {
1086
+ this.fire({
1087
+ type: "namespace",
1088
+ prefix: prefix,
1089
+ uri: uri,
1090
+ line: line,
1091
+ col: col
1092
+ });
1093
+ }
1094
 
1095
+ },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1096
 
1097
+ _supports: function(emit) {
1098
+ /*
1099
+ * supports_rule
1100
+ * : SUPPORTS_SYM S* supports_condition S* group_rule_body
1101
+ * ;
1102
+ */
1103
+ var tokenStream = this._tokenStream,
1104
+ line,
1105
+ col;
1106
 
1107
+ if (tokenStream.match(Tokens.SUPPORTS_SYM)) {
1108
+ line = tokenStream.token().startLine;
1109
+ col = tokenStream.token().startCol;
1110
 
1111
+ this._readWhitespace();
1112
+ this._supports_condition();
1113
+ this._readWhitespace();
 
 
1114
 
1115
+ tokenStream.mustMatch(Tokens.LBRACE);
1116
+ this._readWhitespace();
 
 
1117
 
1118
+ if (emit !== false) {
1119
+ this.fire({
1120
+ type: "startsupports",
1121
+ line: line,
1122
+ col: col
1123
+ });
1124
+ }
 
 
 
 
 
1125
 
1126
+ while (true) {
1127
+ if (!this._ruleset()) {
1128
+ break;
1129
+ }
1130
+ }
1131
 
1132
+ tokenStream.mustMatch(Tokens.RBRACE);
1133
+ this._readWhitespace();
 
 
1134
 
1135
+ this.fire({
1136
+ type: "endsupports",
1137
+ line: line,
1138
+ col: col
1139
+ });
1140
+ }
1141
+ },
1142
 
1143
+ _supports_condition: function() {
1144
+ /*
1145
+ * supports_condition
1146
+ * : supports_negation | supports_conjunction | supports_disjunction |
1147
+ * supports_condition_in_parens
1148
+ * ;
1149
+ */
1150
+ var tokenStream = this._tokenStream,
1151
+ ident;
1152
 
1153
+ if (tokenStream.match(Tokens.IDENT)) {
1154
+ ident = tokenStream.token().value.toLowerCase();
 
 
 
 
 
 
 
 
 
 
1155
 
1156
+ if (ident === "not") {
1157
+ tokenStream.mustMatch(Tokens.S);
1158
+ this._supports_condition_in_parens();
1159
+ } else {
1160
+ tokenStream.unget();
1161
+ }
1162
+ } else {
1163
+ this._supports_condition_in_parens();
1164
+ this._readWhitespace();
1165
 
1166
+ while (tokenStream.peek() === Tokens.IDENT) {
1167
+ ident = tokenStream.LT(1).value.toLowerCase();
1168
+ if (ident === "and" || ident === "or") {
1169
+ tokenStream.mustMatch(Tokens.IDENT);
1170
+ this._readWhitespace();
1171
+ this._supports_condition_in_parens();
1172
+ this._readWhitespace();
1173
+ }
1174
+ }
1175
+ }
1176
+ },
1177
 
1178
+ _supports_condition_in_parens: function() {
1179
+ /*
1180
+ * supports_condition_in_parens
1181
+ * : ( '(' S* supports_condition S* ')' ) | supports_declaration_condition |
1182
+ * general_enclosed
1183
+ * ;
1184
+ */
1185
+ var tokenStream = this._tokenStream,
1186
+ ident;
1187
 
1188
+ if (tokenStream.match(Tokens.LPAREN)) {
1189
+ this._readWhitespace();
1190
+ if (tokenStream.match(Tokens.IDENT)) {
1191
+ // look ahead for not keyword, if not given, continue with declaration condition.
1192
+ ident = tokenStream.token().value.toLowerCase();
1193
+ if (ident === "not") {
1194
+ this._readWhitespace();
1195
+ this._supports_condition();
1196
+ this._readWhitespace();
1197
+ tokenStream.mustMatch(Tokens.RPAREN);
1198
+ } else {
1199
+ tokenStream.unget();
1200
+ this._supports_declaration_condition(false);
1201
+ }
1202
+ } else {
1203
+ this._supports_condition();
1204
+ this._readWhitespace();
1205
+ tokenStream.mustMatch(Tokens.RPAREN);
1206
+ }
1207
+ } else {
1208
+ this._supports_declaration_condition();
1209
+ }
1210
+ },
1211
 
1212
+ _supports_declaration_condition: function(requireStartParen) {
1213
+ /*
1214
+ * supports_declaration_condition
1215
+ * : '(' S* declaration ')'
1216
+ * ;
1217
+ */
1218
+ var tokenStream = this._tokenStream;
1219
 
1220
+ if (requireStartParen !== false) {
1221
+ tokenStream.mustMatch(Tokens.LPAREN);
1222
+ }
1223
+ this._readWhitespace();
1224
+ this._declaration();
1225
+ tokenStream.mustMatch(Tokens.RPAREN);
1226
+ },
1227
 
1228
+ _media: function() {
1229
+ /*
1230
+ * media
1231
+ * : MEDIA_SYM S* media_query_list S* '{' S* ruleset* '}' S*
1232
+ * ;
1233
+ */
1234
+ var tokenStream = this._tokenStream,
1235
+ line,
1236
+ col,
1237
+ mediaList;// = [];
1238
 
1239
+ //look for @media
1240
+ tokenStream.mustMatch(Tokens.MEDIA_SYM);
1241
+ line = tokenStream.token().startLine;
1242
+ col = tokenStream.token().startCol;
 
 
 
1243
 
1244
+ this._readWhitespace();
 
1245
 
1246
+ mediaList = this._media_query_list();
 
1247
 
1248
+ tokenStream.mustMatch(Tokens.LBRACE);
1249
+ this._readWhitespace();
1250
 
1251
+ this.fire({
1252
+ type: "startmedia",
1253
+ media: mediaList,
1254
+ line: line,
1255
+ col: col
1256
+ });
1257
 
1258
+ while (true) {
1259
+ if (tokenStream.peek() === Tokens.PAGE_SYM) {
1260
+ this._page();
1261
+ } else if (tokenStream.peek() === Tokens.FONT_FACE_SYM) {
1262
+ this._font_face();
1263
+ } else if (tokenStream.peek() === Tokens.VIEWPORT_SYM) {
1264
+ this._viewport();
1265
+ } else if (tokenStream.peek() === Tokens.DOCUMENT_SYM) {
1266
+ this._document();
1267
+ } else if (tokenStream.peek() === Tokens.SUPPORTS_SYM) {
1268
+ this._supports();
1269
+ } else if (!this._ruleset()) {
1270
+ break;
1271
+ }
1272
+ }
1273
 
1274
+ tokenStream.mustMatch(Tokens.RBRACE);
1275
+ this._readWhitespace();
 
 
1276
 
1277
+ this.fire({
1278
+ type: "endmedia",
1279
+ media: mediaList,
1280
+ line: line,
1281
+ col: col
1282
+ });
1283
+ },
1284
 
 
 
 
1285
 
1286
+ //CSS3 Media Queries
1287
+ _media_query_list: function() {
1288
+ /*
1289
+ * media_query_list
1290
+ * : S* [media_query [ ',' S* media_query ]* ]?
1291
+ * ;
1292
+ */
1293
+ var tokenStream = this._tokenStream,
1294
+ mediaList = [];
 
 
 
 
 
 
1295
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1296
 
1297
+ this._readWhitespace();
 
 
 
 
1298
 
1299
+ if (tokenStream.peek() === Tokens.IDENT || tokenStream.peek() === Tokens.LPAREN) {
1300
+ mediaList.push(this._media_query());
1301
+ }
 
 
 
1302
 
1303
+ while (tokenStream.match(Tokens.COMMA)) {
1304
+ this._readWhitespace();
1305
+ mediaList.push(this._media_query());
1306
+ }
 
1307
 
1308
+ return mediaList;
1309
+ },
 
1310
 
1311
+ /*
1312
+ * Note: "expression" in the grammar maps to the _media_expression
1313
+ * method.
1314
 
1315
+ */
1316
+ _media_query: function() {
1317
+ /*
1318
+ * media_query
1319
+ * : [ONLY | NOT]? S* media_type S* [ AND S* expression ]*
1320
+ * | expression [ AND S* expression ]*
1321
+ * ;
1322
+ */
1323
+ var tokenStream = this._tokenStream,
1324
+ type = null,
1325
+ ident = null,
1326
+ token = null,
1327
+ expressions = [];
1328
 
1329
+ if (tokenStream.match(Tokens.IDENT)) {
1330
+ ident = tokenStream.token().value.toLowerCase();
 
 
 
 
 
 
 
 
 
1331
 
1332
+ //since there's no custom tokens for these, need to manually check
1333
+ if (ident !== "only" && ident !== "not") {
1334
+ tokenStream.unget();
1335
+ ident = null;
1336
+ } else {
1337
+ token = tokenStream.token();
1338
+ }
1339
+ }
1340
 
1341
+ this._readWhitespace();
 
 
1342
 
1343
+ if (tokenStream.peek() === Tokens.IDENT) {
1344
+ type = this._media_type();
1345
+ if (token === null) {
1346
+ token = tokenStream.token();
1347
+ }
1348
+ } else if (tokenStream.peek() === Tokens.LPAREN) {
1349
+ if (token === null) {
1350
+ token = tokenStream.LT(1);
1351
+ }
1352
+ expressions.push(this._media_expression());
1353
+ }
1354
 
1355
+ if (type === null && expressions.length === 0) {
1356
+ return null;
1357
+ } else {
1358
+ this._readWhitespace();
1359
+ while (tokenStream.match(Tokens.IDENT)) {
1360
+ if (tokenStream.token().value.toLowerCase() !== "and") {
1361
+ this._unexpectedToken(tokenStream.token());
1362
+ }
1363
 
1364
+ this._readWhitespace();
1365
+ expressions.push(this._media_expression());
1366
+ }
1367
+ }
 
 
 
 
 
 
 
 
 
 
1368
 
1369
+ return new MediaQuery(ident, type, expressions, token.startLine, token.startCol);
1370
+ },
 
 
 
 
 
 
 
 
1371
 
1372
+ //CSS3 Media Queries
1373
+ _media_type: function() {
1374
+ /*
1375
+ * media_type
1376
+ * : IDENT
1377
+ * ;
1378
+ */
1379
+ return this._media_feature();
1380
+ },
 
 
 
 
1381
 
1382
+ /**
1383
+ * Note: in CSS3 Media Queries, this is called "expression".
1384
+ * Renamed here to avoid conflict with CSS3 Selectors
1385
+ * definition of "expression". Also note that "expr" in the
1386
+ * grammar now maps to "expression" from CSS3 selectors.
1387
+ * @method _media_expression
1388
+ * @private
1389
+ */
1390
+ _media_expression: function() {
1391
+ /*
1392
+ * expression
1393
+ * : '(' S* media_feature S* [ ':' S* expr ]? ')' S*
1394
+ * ;
1395
+ */
1396
+ var tokenStream = this._tokenStream,
1397
+ feature = null,
1398
+ token,
1399
+ expression = null;
1400
 
1401
+ tokenStream.mustMatch(Tokens.LPAREN);
1402
 
1403
+ feature = this._media_feature();
1404
+ this._readWhitespace();
1405
 
1406
+ if (tokenStream.match(Tokens.COLON)) {
1407
+ this._readWhitespace();
1408
+ token = tokenStream.LT(1);
1409
+ expression = this._expression();
1410
+ }
1411
 
1412
+ tokenStream.mustMatch(Tokens.RPAREN);
1413
+ this._readWhitespace();
 
 
 
 
 
 
1414
 
1415
+ return new MediaFeature(feature, expression ? new SyntaxUnit(expression, token.startLine, token.startCol) : null);
1416
+ },
1417
 
1418
+ //CSS3 Media Queries
1419
+ _media_feature: function() {
1420
+ /*
1421
+ * media_feature
1422
+ * : IDENT
1423
+ * ;
1424
+ */
1425
+ var tokenStream = this._tokenStream;
1426
 
1427
+ this._readWhitespace();
 
 
 
 
 
1428
 
1429
+ tokenStream.mustMatch(Tokens.IDENT);
 
1430
 
1431
+ return SyntaxUnit.fromToken(tokenStream.token());
1432
+ },
 
 
 
 
 
1433
 
1434
+ //CSS3 Paged Media
1435
+ _page: function() {
1436
+ /*
1437
+ * page:
1438
+ * PAGE_SYM S* IDENT? pseudo_page? S*
1439
+ * '{' S* [ declaration | margin ]? [ ';' S* [ declaration | margin ]? ]* '}' S*
1440
+ * ;
1441
+ */
1442
+ var tokenStream = this._tokenStream,
1443
+ line,
1444
+ col,
1445
+ identifier = null,
1446
+ pseudoPage = null;
1447
 
1448
+ //look for @page
1449
+ tokenStream.mustMatch(Tokens.PAGE_SYM);
1450
+ line = tokenStream.token().startLine;
1451
+ col = tokenStream.token().startCol;
1452
 
1453
+ this._readWhitespace();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1454
 
1455
+ if (tokenStream.match(Tokens.IDENT)) {
1456
+ identifier = tokenStream.token().value;
1457
 
1458
+ //The value 'auto' may not be used as a page name and MUST be treated as a syntax error.
1459
+ if (identifier.toLowerCase() === "auto") {
1460
+ this._unexpectedToken(tokenStream.token());
1461
+ }
1462
+ }
 
1463
 
1464
+ //see if there's a colon upcoming
1465
+ if (tokenStream.peek() === Tokens.COLON) {
1466
+ pseudoPage = this._pseudo_page();
1467
+ }
 
 
 
 
 
 
1468
 
1469
+ this._readWhitespace();
1470
 
1471
+ this.fire({
1472
+ type: "startpage",
1473
+ id: identifier,
1474
+ pseudo: pseudoPage,
1475
+ line: line,
1476
+ col: col
1477
+ });
1478
 
1479
+ this._readDeclarations(true, true);
1480
 
1481
+ this.fire({
1482
+ type: "endpage",
1483
+ id: identifier,
1484
+ pseudo: pseudoPage,
1485
+ line: line,
1486
+ col: col
1487
+ });
 
 
 
 
1488
 
1489
+ },
1490
 
1491
+ //CSS3 Paged Media
1492
+ _margin: function() {
1493
+ /*
1494
+ * margin :
1495
+ * margin_sym S* '{' declaration [ ';' S* declaration? ]* '}' S*
1496
+ * ;
1497
+ */
1498
+ var tokenStream = this._tokenStream,
1499
+ line,
1500
+ col,
1501
+ marginSym = this._margin_sym();
1502
 
1503
+ if (marginSym) {
1504
+ line = tokenStream.token().startLine;
1505
+ col = tokenStream.token().startCol;
 
 
 
 
1506
 
1507
+ this.fire({
1508
+ type: "startpagemargin",
1509
+ margin: marginSym,
1510
+ line: line,
1511
+ col: col
1512
+ });
1513
 
1514
+ this._readDeclarations(true);
1515
 
1516
+ this.fire({
1517
+ type: "endpagemargin",
1518
+ margin: marginSym,
1519
+ line: line,
1520
+ col: col
1521
+ });
1522
+ return true;
1523
+ } else {
1524
+ return false;
1525
+ }
1526
+ },
 
 
 
1527
 
1528
+ //CSS3 Paged Media
1529
+ _margin_sym: function() {
1530
 
1531
+ /*
1532
+ * margin_sym :
1533
+ * TOPLEFTCORNER_SYM |
1534
+ * TOPLEFT_SYM |
1535
+ * TOPCENTER_SYM |
1536
+ * TOPRIGHT_SYM |
1537
+ * TOPRIGHTCORNER_SYM |
1538
+ * BOTTOMLEFTCORNER_SYM |
1539
+ * BOTTOMLEFT_SYM |
1540
+ * BOTTOMCENTER_SYM |
1541
+ * BOTTOMRIGHT_SYM |
1542
+ * BOTTOMRIGHTCORNER_SYM |
1543
+ * LEFTTOP_SYM |
1544
+ * LEFTMIDDLE_SYM |
1545
+ * LEFTBOTTOM_SYM |
1546
+ * RIGHTTOP_SYM |
1547
+ * RIGHTMIDDLE_SYM |
1548
+ * RIGHTBOTTOM_SYM
1549
+ * ;
1550
+ */
1551
 
1552
+ var tokenStream = this._tokenStream;
1553
+
1554
+ if (tokenStream.match([Tokens.TOPLEFTCORNER_SYM, Tokens.TOPLEFT_SYM,
1555
+ Tokens.TOPCENTER_SYM, Tokens.TOPRIGHT_SYM, Tokens.TOPRIGHTCORNER_SYM,
1556
+ Tokens.BOTTOMLEFTCORNER_SYM, Tokens.BOTTOMLEFT_SYM,
1557
+ Tokens.BOTTOMCENTER_SYM, Tokens.BOTTOMRIGHT_SYM,
1558
+ Tokens.BOTTOMRIGHTCORNER_SYM, Tokens.LEFTTOP_SYM,
1559
+ Tokens.LEFTMIDDLE_SYM, Tokens.LEFTBOTTOM_SYM, Tokens.RIGHTTOP_SYM,
1560
+ Tokens.RIGHTMIDDLE_SYM, Tokens.RIGHTBOTTOM_SYM])) {
1561
+ return SyntaxUnit.fromToken(tokenStream.token());
1562
+ } else {
1563
+ return null;
1564
+ }
1565
+
1566
+ },
1567
+
1568
+ _pseudo_page: function() {
1569
+ /*
1570
+ * pseudo_page
1571
+ * : ':' IDENT
1572
+ * ;
1573
+ */
1574
+
1575
+ var tokenStream = this._tokenStream;
1576
+
1577
+ tokenStream.mustMatch(Tokens.COLON);
1578
+ tokenStream.mustMatch(Tokens.IDENT);
1579
+
1580
+ //TODO: CSS3 Paged Media says only "left", "center", and "right" are allowed
1581
+
1582
+ return tokenStream.token().value;
1583
+ },
1584
+
1585
+ _font_face: function() {
1586
+ /*
1587
+ * font_face
1588
+ * : FONT_FACE_SYM S*
1589
+ * '{' S* declaration [ ';' S* declaration ]* '}' S*
1590
+ * ;
1591
+ */
1592
+ var tokenStream = this._tokenStream,
1593
+ line,
1594
+ col;
1595
+
1596
+ //look for @page
1597
+ tokenStream.mustMatch(Tokens.FONT_FACE_SYM);
1598
+ line = tokenStream.token().startLine;
1599
+ col = tokenStream.token().startCol;
1600
+
1601
+ this._readWhitespace();
1602
+
1603
+ this.fire({
1604
+ type: "startfontface",
1605
+ line: line,
1606
+ col: col
1607
+ });
1608
+
1609
+ this._readDeclarations(true);
1610
+
1611
+ this.fire({
1612
+ type: "endfontface",
1613
+ line: line,
1614
+ col: col
1615
+ });
1616
+ },
1617
+
1618
+ _viewport: function() {
1619
+ /*
1620
+ * viewport
1621
+ * : VIEWPORT_SYM S*
1622
+ * '{' S* declaration? [ ';' S* declaration? ]* '}' S*
1623
+ * ;
1624
+ */
1625
+ var tokenStream = this._tokenStream,
1626
+ line,
1627
+ col;
1628
+
1629
+ tokenStream.mustMatch(Tokens.VIEWPORT_SYM);
1630
+ line = tokenStream.token().startLine;
1631
+ col = tokenStream.token().startCol;
1632
+
1633
+ this._readWhitespace();
1634
+
1635
+ this.fire({
1636
+ type: "startviewport",
1637
+ line: line,
1638
+ col: col
1639
+ });
1640
+
1641
+ this._readDeclarations(true);
1642
+
1643
+ this.fire({
1644
+ type: "endviewport",
1645
+ line: line,
1646
+ col: col
1647
+ });
1648
+
1649
+ },
1650
+
1651
+ _document: function() {
1652
+ /*
1653
+ * document
1654
+ * : DOCUMENT_SYM S*
1655
+ * _document_function [ ',' S* _document_function ]* S*
1656
+ * '{' S* ruleset* '}'
1657
+ * ;
1658
+ */
1659
+
1660
+ var tokenStream = this._tokenStream,
1661
+ token,
1662
+ functions = [],
1663
+ prefix = "";
1664
+
1665
+ tokenStream.mustMatch(Tokens.DOCUMENT_SYM);
1666
+ token = tokenStream.token();
1667
+ if (/^@\-([^\-]+)\-/.test(token.value)) {
1668
+ prefix = RegExp.$1;
1669
+ }
1670
+
1671
+ this._readWhitespace();
1672
+ functions.push(this._document_function());
1673
+
1674
+ while (tokenStream.match(Tokens.COMMA)) {
1675
+ this._readWhitespace();
1676
+ functions.push(this._document_function());
1677
+ }
1678
+
1679
+ tokenStream.mustMatch(Tokens.LBRACE);
1680
+ this._readWhitespace();
1681
+
1682
+ this.fire({
1683
+ type: "startdocument",
1684
+ functions: functions,
1685
+ prefix: prefix,
1686
+ line: token.startLine,
1687
+ col: token.startCol
1688
+ });
1689
+
1690
+ var ok = true;
1691
+ while (ok) {
1692
+ switch (tokenStream.peek()) {
1693
+ case Tokens.PAGE_SYM:
1694
+ this._page();
1695
+ break;
1696
+ case Tokens.FONT_FACE_SYM:
1697
+ this._font_face();
1698
+ break;
1699
+ case Tokens.VIEWPORT_SYM:
1700
+ this._viewport();
1701
+ break;
1702
+ case Tokens.MEDIA_SYM:
1703
+ this._media();
1704
+ break;
1705
+ case Tokens.KEYFRAMES_SYM:
1706
+ this._keyframes();
1707
+ break;
1708
+ case Tokens.DOCUMENT_SYM:
1709
+ this._document();
1710
+ break;
1711
+ default:
1712
+ ok = Boolean(this._ruleset());
1713
+ }
1714
+ }
1715
 
1716
+ tokenStream.mustMatch(Tokens.RBRACE);
1717
+ token = tokenStream.token();
1718
+ this._readWhitespace();
 
 
 
1719
 
1720
+ this.fire({
1721
+ type: "enddocument",
1722
+ functions: functions,
1723
+ prefix: prefix,
1724
+ line: token.startLine,
1725
+ col: token.startCol
1726
+ });
1727
+ },
1728
 
1729
+ _document_function: function() {
1730
+ /*
1731
+ * document_function
1732
+ * : function | URI S*
1733
+ * ;
1734
+ */
1735
 
1736
+ var tokenStream = this._tokenStream,
1737
+ value;
1738
 
1739
+ if (tokenStream.match(Tokens.URI)) {
1740
+ value = tokenStream.token().value;
1741
+ this._readWhitespace();
1742
+ } else {
1743
+ value = this._function();
1744
+ }
1745
 
1746
+ return value;
1747
+ },
 
 
 
 
 
 
 
 
 
 
 
1748
 
1749
+ _operator: function(inFunction) {
 
1750
 
1751
+ /*
1752
+ * operator (outside function)
1753
+ * : '/' S* | ',' S* | /( empty )/
1754
+ * operator (inside function)
1755
+ * : '/' S* | '+' S* | '*' S* | '-' S* /( empty )/
1756
+ * ;
1757
+ */
1758
 
1759
+ var tokenStream = this._tokenStream,
1760
+ token = null;
1761
 
1762
+ if (tokenStream.match([Tokens.SLASH, Tokens.COMMA]) ||
1763
+ (inFunction && tokenStream.match([Tokens.PLUS, Tokens.STAR, Tokens.MINUS]))) {
1764
+ token = tokenStream.token();
1765
+ this._readWhitespace();
1766
+ }
1767
+ return token ? PropertyValuePart.fromToken(token) : null;
1768
 
1769
+ },
 
 
 
 
 
 
 
 
 
 
1770
 
1771
+ _combinator: function() {
1772
 
1773
+ /*
1774
+ * combinator
1775
+ * : PLUS S* | GREATER S* | TILDE S* | S+
1776
+ * ;
1777
+ */
1778
 
1779
+ var tokenStream = this._tokenStream,
1780
+ value = null,
1781
+ token;
1782
 
1783
+ if (tokenStream.match([Tokens.PLUS, Tokens.GREATER, Tokens.TILDE])) {
1784
+ token = tokenStream.token();
1785
+ value = new Combinator(token.value, token.startLine, token.startCol);
1786
+ this._readWhitespace();
1787
+ }
 
 
 
 
 
 
1788
 
1789
+ return value;
1790
+ },
 
1791
 
1792
+ _unary_operator: function() {
1793
 
1794
  /*
1795
+ * unary_operator
1796
+ * : '-' | '+'
 
 
 
1797
  * ;
1798
  */
1799
 
1800
+ var tokenStream = this._tokenStream;
 
 
 
 
1801
 
1802
+ if (tokenStream.match([Tokens.MINUS, Tokens.PLUS])) {
1803
+ return tokenStream.token().value;
1804
+ } else {
1805
+ return null;
1806
+ }
1807
+ },
1808
 
1809
+ _property: function() {
 
1810
 
1811
+ /*
1812
+ * property
1813
+ * : IDENT S*
1814
+ * ;
1815
+ */
1816
 
1817
+ var tokenStream = this._tokenStream,
1818
+ value = null,
1819
+ hack = null,
1820
+ tokenValue,
1821
+ token,
1822
+ line,
1823
+ col;
1824
 
1825
+ //check for star hack - throws error if not allowed
1826
+ if (tokenStream.peek() === Tokens.STAR && this.options.starHack) {
1827
+ tokenStream.get();
1828
+ token = tokenStream.token();
1829
+ hack = token.value;
1830
+ line = token.startLine;
1831
+ col = token.startCol;
1832
  }
1833
 
1834
+ if (tokenStream.match(Tokens.IDENT)) {
1835
+ token = tokenStream.token();
1836
+ tokenValue = token.value;
 
 
1837
 
1838
+ //check for underscore hack - no error if not allowed because it's valid CSS syntax
1839
+ if (tokenValue.charAt(0) === "_" && this.options.underscoreHack) {
1840
+ hack = "_";
1841
+ tokenValue = tokenValue.substring(1);
1842
+ }
1843
 
1844
+ value = new PropertyName(tokenValue, hack, (line||token.startLine), (col||token.startCol));
1845
+ this._readWhitespace();
1846
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1847
 
1848
+ return value;
1849
+ },
 
 
 
 
 
 
1850
 
1851
+ //Augmented with CSS3 Selectors
1852
+ _ruleset: function() {
1853
+ /*
1854
+ * ruleset
1855
+ * : selectors_group
1856
+ * '{' S* declaration? [ ';' S* declaration? ]* '}' S*
1857
+ * ;
1858
+ */
1859
 
1860
+ var tokenStream = this._tokenStream,
1861
+ tt,
1862
+ selectors;
 
1863
 
 
 
 
 
 
 
 
 
 
 
1864
 
1865
+ /*
1866
+ * Error Recovery: If even a single selector fails to parse,
1867
+ * then the entire ruleset should be thrown away.
1868
+ */
1869
+ try {
1870
+ selectors = this._selectors_group();
1871
+ } catch (ex) {
1872
+ if (ex instanceof SyntaxError && !this.options.strict) {
 
 
 
 
 
 
 
 
 
 
1873
 
1874
+ //fire error event
1875
+ this.fire({
1876
+ type: "error",
1877
+ error: ex,
1878
+ message: ex.message,
1879
+ line: ex.line,
1880
+ col: ex.col
1881
+ });
1882
+
1883
+ //skip over everything until closing brace
1884
+ tt = tokenStream.advance([Tokens.RBRACE]);
1885
+ if (tt === Tokens.RBRACE) {
1886
+ //if there's a right brace, the rule is finished so don't do anything
1887
  } else {
1888
+ //otherwise, rethrow the error because it wasn't handled properly
1889
  throw ex;
1890
  }
 
1891
 
1892
+ } else {
1893
+ //not a syntax error, rethrow it
1894
+ throw ex;
1895
+ }
1896
 
1897
+ //trigger parser to continue
1898
+ return true;
1899
  }
1900
 
1901
+ //if it got here, all selectors parsed
1902
+ if (selectors) {
1903
 
1904
+ this.fire({
1905
+ type: "startrule",
1906
+ selectors: selectors,
1907
+ line: selectors[0].line,
1908
+ col: selectors[0].col
1909
+ });
1910
 
1911
+ this._readDeclarations(true);
 
 
1912
 
1913
+ this.fire({
1914
+ type: "endrule",
1915
+ selectors: selectors,
1916
+ line: selectors[0].line,
1917
+ col: selectors[0].col
1918
+ });
1919
 
1920
+ }
 
1921
 
1922
+ return selectors;
 
1923
 
 
 
 
 
 
 
 
 
 
1924
  },
1925
 
1926
+ //CSS3 Selectors
1927
+ _selectors_group: function() {
1928
+
1929
  /*
1930
+ * selectors_group
1931
+ * : selector [ COMMA S* selector ]*
1932
+ * ;
1933
  */
 
1934
  var tokenStream = this._tokenStream,
1935
+ selectors = [],
1936
+ selector;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1937
 
1938
+ selector = this._selector();
1939
+ if (selector !== null) {
 
1940
 
1941
+ selectors.push(selector);
1942
+ while (tokenStream.match(Tokens.COMMA)) {
1943
+ this._readWhitespace();
1944
+ selector = this._selector();
1945
+ if (selector !== null) {
1946
+ selectors.push(selector);
1947
+ } else {
1948
+ this._unexpectedToken(tokenStream.LT(1));
1949
+ }
1950
+ }
1951
  }
1952
 
1953
+ return selectors.length ? selectors : null;
1954
  },
1955
 
1956
+ //CSS3 Selectors
1957
+ _selector: function() {
1958
  /*
1959
+ * selector
1960
+ * : simple_selector_sequence [ combinator simple_selector_sequence ]*
1961
+ * ;
1962
  */
1963
 
1964
  var tokenStream = this._tokenStream,
1965
+ selector = [],
1966
+ nextSelector = null,
1967
+ combinator = null,
1968
+ ws = null;
 
 
 
 
 
 
1969
 
1970
+ //if there's no simple selector, then there's no selector
1971
+ nextSelector = this._simple_selector_sequence();
1972
+ if (nextSelector === null) {
1973
+ return null;
1974
  }
1975
 
1976
+ selector.push(nextSelector);
 
 
 
1977
 
1978
+ do {
 
1979
 
1980
+ //look for a combinator
1981
+ combinator = this._combinator();
1982
 
1983
+ if (combinator !== null) {
1984
+ selector.push(combinator);
1985
+ nextSelector = this._simple_selector_sequence();
1986
 
1987
+ //there must be a next selector
1988
+ if (nextSelector === null) {
1989
+ this._unexpectedToken(tokenStream.LT(1));
1990
+ } else {
 
 
 
 
 
1991
 
1992
+ //nextSelector is an instance of SelectorPart
1993
+ selector.push(nextSelector);
1994
+ }
1995
+ } else {
1996
 
1997
+ //if there's not whitespace, we're done
1998
+ if (this._readWhitespace()) {
 
 
 
 
 
 
 
 
1999
 
2000
+ //add whitespace separator
2001
+ ws = new Combinator(tokenStream.token().value, tokenStream.token().startLine, tokenStream.token().startCol);
 
 
2002
 
2003
+ //combinator is not required
2004
+ combinator = this._combinator();
2005
 
2006
+ //selector is required if there's a combinator
2007
+ nextSelector = this._simple_selector_sequence();
2008
+ if (nextSelector === null) {
2009
+ if (combinator !== null) {
2010
+ this._unexpectedToken(tokenStream.LT(1));
2011
+ }
2012
+ } else {
2013
 
2014
+ if (combinator !== null) {
2015
+ selector.push(combinator);
2016
+ } else {
2017
+ selector.push(ws);
2018
+ }
2019
 
2020
+ selector.push(nextSelector);
2021
+ }
2022
+ } else {
2023
+ break;
2024
+ }
 
2025
 
 
 
 
 
 
 
 
2026
  }
2027
+ } while (true);
 
 
 
2028
 
2029
+ return new Selector(selector, selector[0].line, selector[0].col);
 
 
 
 
 
2030
  },
2031
 
2032
+ //CSS3 Selectors
2033
+ _simple_selector_sequence: function() {
 
2034
  /*
2035
+ * simple_selector_sequence
2036
+ * : [ type_selector | universal ]
2037
+ * [ HASH | class | attrib | pseudo | negation ]*
2038
+ * | [ HASH | class | attrib | pseudo | negation ]+
2039
  * ;
2040
  */
2041
+
2042
  var tokenStream = this._tokenStream,
2043
+
2044
+ //parts of a simple selector
2045
+ elementName = null,
2046
+ modifiers = [],
2047
+
2048
+ //complete selector text
2049
+ selectorText= "",
2050
+
2051
+ //the different parts after the element name to search for
2052
+ components = [
2053
+ //HASH
2054
+ function() {
2055
+ return tokenStream.match(Tokens.HASH) ?
2056
+ new SelectorSubPart(tokenStream.token().value, "id", tokenStream.token().startLine, tokenStream.token().startCol) :
2057
+ null;
2058
+ },
2059
+ this._class,
2060
+ this._attrib,
2061
+ this._pseudo,
2062
+ this._negation
2063
+ ],
2064
+ i = 0,
2065
+ len = components.length,
2066
+ component = null,
2067
+ line,
2068
+ col;
2069
 
2070
 
2071
+ //get starting line and column for the selector
2072
+ line = tokenStream.LT(1).startLine;
2073
+ col = tokenStream.LT(1).startCol;
2074
 
2075
+ elementName = this._type_selector();
2076
+ if (!elementName) {
2077
+ elementName = this._universal();
2078
  }
2079
 
2080
+ if (elementName !== null) {
2081
+ selectorText += elementName;
 
2082
  }
2083
 
2084
+ while (true) {
 
2085
 
2086
+ //whitespace means we're done
2087
+ if (tokenStream.peek() === Tokens.S) {
2088
+ break;
2089
+ }
2090
 
2091
+ //check for each component
2092
+ while (i < len && component === null) {
2093
+ component = components[i++].call(this);
2094
+ }
 
 
 
 
 
 
 
 
 
2095
 
2096
+ if (component === null) {
 
2097
 
2098
+ //we don't have a selector
2099
+ if (selectorText === "") {
2100
+ return null;
2101
+ } else {
2102
+ break;
2103
+ }
2104
  } else {
2105
+ i = 0;
2106
+ modifiers.push(component);
2107
+ selectorText += component.toString();
2108
+ component = null;
2109
  }
2110
  }
2111
 
 
2112
 
2113
+ return selectorText !== "" ?
2114
+ new SelectorPart(elementName, modifiers, selectorText, line, col) :
2115
+ null;
2116
+ },
2117
+
2118
+ //CSS3 Selectors
2119
+ _type_selector: function() {
2120
+ /*
2121
+ * type_selector
2122
+ * : [ namespace_prefix ]? element_name
2123
+ * ;
2124
+ */
2125
+
2126
+ var tokenStream = this._tokenStream,
2127
+ ns = this._namespace_prefix(),
2128
+ elementName = this._element_name();
2129
+
2130
+ if (!elementName) {
2131
+ /*
2132
+ * Need to back out the namespace that was read due to both
2133
+ * type_selector and universal reading namespace_prefix
2134
+ * first. Kind of hacky, but only way I can figure out
2135
+ * right now how to not change the grammar.
2136
+ */
2137
+ if (ns) {
2138
+ tokenStream.unget();
2139
+ if (ns.length > 1) {
2140
+ tokenStream.unget();
2141
+ }
2142
  }
 
 
2143
 
 
2144
  return null;
2145
  } else {
2146
+ if (ns) {
2147
+ elementName.text = ns + elementName.text;
2148
+ elementName.col -= ns.length;
 
 
 
 
 
2149
  }
2150
+ return elementName;
2151
  }
 
 
2152
  },
2153
 
2154
+ //CSS3 Selectors
2155
+ _class: function() {
2156
  /*
2157
+ * class
2158
+ * : '.' IDENT
2159
  * ;
2160
  */
 
 
2161
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2162
  var tokenStream = this._tokenStream,
2163
+ token;
 
 
 
 
 
 
 
2164
 
2165
+ if (tokenStream.match(Tokens.DOT)) {
2166
+ tokenStream.mustMatch(Tokens.IDENT);
2167
+ token = tokenStream.token();
2168
+ return new SelectorSubPart("." + token.value, "class", token.startLine, token.startCol - 1);
2169
+ } else {
2170
+ return null;
2171
  }
2172
 
 
 
 
 
2173
  },
2174
 
2175
+ //CSS3 Selectors
2176
+ _element_name: function() {
2177
  /*
2178
+ * element_name
2179
  * : IDENT
2180
  * ;
2181
  */
 
 
 
 
 
 
2182
 
 
 
 
 
 
 
 
 
2183
  var tokenStream = this._tokenStream,
2184
+ token;
 
 
 
 
 
 
 
 
 
 
 
 
 
2185
 
2186
+ if (tokenStream.match(Tokens.IDENT)) {
2187
+ token = tokenStream.token();
2188
+ return new SelectorSubPart(token.value, "elementName", token.startLine, token.startCol);
 
 
2189
 
2190
+ } else {
2191
+ return null;
 
2192
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2193
  },
2194
 
2195
+ //CSS3 Selectors
2196
+ _namespace_prefix: function() {
2197
  /*
2198
+ * namespace_prefix
2199
+ * : [ IDENT | '*' ]? '|'
2200
+ * ;
2201
  */
2202
  var tokenStream = this._tokenStream,
2203
+ value = "";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2204
 
2205
+ //verify that this is a namespace prefix
2206
+ if (tokenStream.LA(1) === Tokens.PIPE || tokenStream.LA(2) === Tokens.PIPE) {
2207
 
2208
+ if (tokenStream.match([Tokens.IDENT, Tokens.STAR])) {
2209
+ value += tokenStream.token().value;
2210
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2211
 
2212
+ tokenStream.mustMatch(Tokens.PIPE);
2213
+ value += "|";
2214
 
 
 
 
 
 
 
 
 
 
 
 
2215
  }
2216
 
2217
+ return value.length ? value : null;
2218
  },
2219
 
2220
+ //CSS3 Selectors
2221
+ _universal: function() {
2222
  /*
2223
+ * universal
2224
+ * : [ namespace_prefix ]? '*'
2225
  * ;
2226
  */
2227
+ var tokenStream = this._tokenStream,
2228
+ value = "",
2229
+ ns;
2230
 
2231
+ ns = this._namespace_prefix();
2232
+ if (ns) {
2233
+ value += ns;
2234
+ }
2235
 
2236
+ if (tokenStream.match(Tokens.STAR)) {
2237
+ value += "*";
2238
+ }
2239
 
2240
+ return value.length ? value : null;
2241
 
 
2242
  },
2243
 
2244
+ //CSS3 Selectors
2245
+ _attrib: function() {
2246
  /*
2247
+ * attrib
2248
+ * : '[' S* [ namespace_prefix ]? IDENT S*
2249
+ * [ [ PREFIXMATCH |
2250
+ * SUFFIXMATCH |
2251
+ * SUBSTRINGMATCH |
2252
+ * '=' |
2253
+ * INCLUDES |
2254
+ * DASHMATCH ] S* [ IDENT | STRING ] S*
2255
+ * ]? ']'
2256
  * ;
2257
  */
2258
+
2259
  var tokenStream = this._tokenStream,
2260
+ value = null,
2261
+ ns,
2262
+ token;
2263
 
2264
+ if (tokenStream.match(Tokens.LBRACKET)) {
2265
+ token = tokenStream.token();
2266
+ value = token.value;
2267
+ value += this._readWhitespace();
2268
 
2269
+ ns = this._namespace_prefix();
2270
 
2271
+ if (ns) {
2272
+ value += ns;
2273
+ }
 
 
2274
 
2275
+ tokenStream.mustMatch(Tokens.IDENT);
2276
+ value += tokenStream.token().value;
2277
+ value += this._readWhitespace();
2278
 
2279
+ if (tokenStream.match([Tokens.PREFIXMATCH, Tokens.SUFFIXMATCH, Tokens.SUBSTRINGMATCH,
2280
+ Tokens.EQUALS, Tokens.INCLUDES, Tokens.DASHMATCH])) {
2281
+
2282
+ value += tokenStream.token().value;
2283
+ value += this._readWhitespace();
2284
+
2285
+ tokenStream.mustMatch([Tokens.IDENT, Tokens.STRING]);
2286
+ value += tokenStream.token().value;
2287
+ value += this._readWhitespace();
2288
+ }
2289
+
2290
+ tokenStream.mustMatch(Tokens.RBRACKET);
2291
+
2292
+ return new SelectorSubPart(value + "]", "attribute", token.startLine, token.startCol);
2293
+ } else {
2294
+ return null;
2295
+ }
2296
  },
2297
 
2298
+ //CSS3 Selectors
2299
+ _pseudo: function() {
2300
+
2301
  /*
2302
+ * pseudo
2303
+ * : ':' ':'? [ IDENT | functional_pseudo ]
 
2304
  * ;
2305
  */
2306
+
2307
+ var tokenStream = this._tokenStream,
2308
+ pseudo = null,
2309
+ colons = ":",
2310
  line,
2311
  col;
2312
 
2313
+ if (tokenStream.match(Tokens.COLON)) {
 
 
 
 
2314
 
2315
+ if (tokenStream.match(Tokens.COLON)) {
2316
+ colons += ":";
2317
+ }
 
 
2318
 
2319
+ if (tokenStream.match(Tokens.IDENT)) {
2320
+ pseudo = tokenStream.token().value;
2321
+ line = tokenStream.token().startLine;
2322
+ col = tokenStream.token().startCol - colons.length;
2323
+ } else if (tokenStream.peek() === Tokens.FUNCTION) {
2324
+ line = tokenStream.LT(1).startLine;
2325
+ col = tokenStream.LT(1).startCol - colons.length;
2326
+ pseudo = this._functional_pseudo();
2327
+ }
2328
 
2329
+ if (pseudo) {
2330
+ pseudo = new SelectorSubPart(colons + pseudo, "pseudo", line, col);
2331
+ } else {
2332
+ var startLine = tokenStream.LT(1).startLine,
2333
+ startCol = tokenStream.LT(0).startCol;
2334
+ throw new SyntaxError("Expected a `FUNCTION` or `IDENT` after colon at line " + startLine + ", col " + startCol + ".", startLine, startCol);
2335
+ }
2336
+ }
2337
 
2338
+ return pseudo;
2339
  },
2340
 
2341
+ //CSS3 Selectors
2342
+ _functional_pseudo: function() {
2343
  /*
2344
+ * functional_pseudo
2345
+ * : FUNCTION S* expression ')'
2346
+ * ;
2347
+ */
 
 
2348
 
2349
  var tokenStream = this._tokenStream,
2350
+ value = null;
2351
 
2352
+ if (tokenStream.match(Tokens.FUNCTION)) {
2353
+ value = tokenStream.token().value;
2354
+ value += this._readWhitespace();
2355
+ value += this._expression();
2356
+ tokenStream.mustMatch(Tokens.RPAREN);
2357
+ value += ")";
2358
  }
 
2359
 
2360
+ return value;
2361
  },
2362
 
2363
+ //CSS3 Selectors
2364
+ _expression: function() {
2365
  /*
2366
+ * expression
2367
+ * : [ [ PLUS | '-' | DIMENSION | NUMBER | STRING | IDENT ] S* ]+
2368
+ * ;
2369
  */
2370
 
2371
  var tokenStream = this._tokenStream,
2372
+ value = "";
 
2373
 
2374
+ while (tokenStream.match([Tokens.PLUS, Tokens.MINUS, Tokens.DIMENSION,
2375
+ Tokens.NUMBER, Tokens.STRING, Tokens.IDENT, Tokens.LENGTH,
2376
+ Tokens.FREQ, Tokens.ANGLE, Tokens.TIME,
2377
+ Tokens.RESOLUTION, Tokens.SLASH])) {
2378
+
2379
+ value += tokenStream.token().value;
2380
+ value += this._readWhitespace();
2381
  }
2382
 
2383
+ return value.length ? value : null;
 
2384
 
2385
+ },
2386
 
2387
+ //CSS3 Selectors
2388
+ _negation: function() {
2389
  /*
2390
+ * negation
2391
+ * : NOT S* negation_arg S* ')'
2392
+ * ;
2393
  */
2394
 
2395
+ var tokenStream = this._tokenStream,
2396
+ line,
2397
+ col,
2398
+ value = "",
2399
+ arg,
2400
+ subpart = null;
2401
 
2402
+ if (tokenStream.match(Tokens.NOT)) {
2403
+ value = tokenStream.token().value;
2404
+ line = tokenStream.token().startLine;
2405
+ col = tokenStream.token().startCol;
2406
+ value += this._readWhitespace();
2407
+ arg = this._negation_arg();
2408
+ value += arg;
2409
+ value += this._readWhitespace();
2410
+ tokenStream.match(Tokens.RPAREN);
2411
+ value += tokenStream.token().value;
2412
+
2413
+ subpart = new SelectorSubPart(value, "not", line, col);
2414
+ subpart.args.push(arg);
2415
  }
 
2416
 
2417
+ return subpart;
2418
+ },
2419
 
2420
+ //CSS3 Selectors
2421
+ _negation_arg: function() {
2422
  /*
2423
+ * negation_arg
2424
+ * : type_selector | universal | HASH | class | attrib | pseudo
2425
  * ;
2426
  */
2427
 
2428
  var tokenStream = this._tokenStream,
2429
+ args = [
2430
+ this._type_selector,
2431
+ this._universal,
2432
+ function() {
2433
+ return tokenStream.match(Tokens.HASH) ?
2434
+ new SelectorSubPart(tokenStream.token().value, "id", tokenStream.token().startLine, tokenStream.token().startCol) :
2435
+ null;
2436
+ },
2437
+ this._class,
2438
+ this._attrib,
2439
+ this._pseudo
2440
+ ],
2441
+ arg = null,
2442
+ i = 0,
2443
+ len = args.length,
2444
  line,
2445
+ col,
2446
+ part;
2447
 
2448
+ line = tokenStream.LT(1).startLine;
2449
+ col = tokenStream.LT(1).startCol;
 
 
 
 
 
 
2450
 
2451
+ while (i < len && arg === null) {
 
 
2452
 
2453
+ arg = args[i].call(this);
2454
+ i++;
2455
+ }
2456
+
2457
+ //must be a negation arg
2458
+ if (arg === null) {
2459
+ this._unexpectedToken(tokenStream.LT(1));
2460
+ }
2461
 
2462
+ //it's an element name
2463
+ if (arg.type === "elementName") {
2464
+ part = new SelectorPart(arg, [], arg.toString(), line, col);
2465
+ } else {
2466
+ part = new SelectorPart(null, [arg], arg.toString(), line, col);
2467
  }
2468
 
2469
+ return part;
2470
  },
2471
 
2472
+ _declaration: function() {
2473
+
2474
  /*
2475
+ * declaration
2476
+ * : property ':' S* expr prio?
2477
+ * | /( empty )/
2478
  * ;
2479
  */
2480
 
2481
  var tokenStream = this._tokenStream,
2482
+ property = null,
2483
+ expr = null,
2484
+ prio = null,
2485
+ invalid = null,
2486
+ propertyName= "";
2487
 
2488
+ property = this._property();
2489
+ if (property !== null) {
 
 
 
 
 
 
2490
 
2491
+ tokenStream.mustMatch(Tokens.COLON);
2492
+ this._readWhitespace();
 
 
 
 
 
 
2493
 
2494
+ expr = this._expr();
 
 
 
 
 
 
 
2495
 
2496
+ //if there's no parts for the value, it's an error
2497
+ if (!expr || expr.length === 0) {
2498
+ this._unexpectedToken(tokenStream.LT(1));
2499
  }
2500
 
2501
+ prio = this._prio();
 
 
2502
 
2503
+ /*
2504
+ * If hacks should be allowed, then only check the root
2505
+ * property. If hacks should not be allowed, treat
2506
+ * _property or *property as invalid properties.
2507
+ */
2508
+ propertyName = property.toString();
2509
+ if (this.options.starHack && property.hack === "*" ||
2510
+ this.options.underscoreHack && property.hack === "_") {
2511
 
2512
+ propertyName = property.text;
2513
+ }
 
 
 
 
2514
 
2515
+ try {
2516
+ this._validateProperty(propertyName, expr);
2517
+ } catch (ex) {
2518
+ invalid = ex;
2519
+ }
2520
 
2521
  this.fire({
2522
+ type: "property",
2523
+ property: property,
2524
+ value: expr,
2525
+ important: prio,
2526
+ line: property.line,
2527
+ col: property.col,
2528
+ invalid: invalid
2529
  });
2530
 
2531
+ return true;
2532
+ } else {
2533
+ return false;
2534
  }
 
 
 
2535
  },
2536
 
2537
+ _prio: function() {
 
 
2538
  /*
2539
+ * prio
2540
+ * : IMPORTANT_SYM S*
2541
  * ;
2542
  */
 
 
 
 
 
 
2543
 
2544
+ var tokenStream = this._tokenStream,
2545
+ result = tokenStream.match(Tokens.IMPORTANT_SYM);
 
 
 
 
 
 
 
 
 
2546
 
2547
+ this._readWhitespace();
2548
+ return result;
2549
  },
2550
 
2551
+ _expr: function(inFunction) {
 
2552
  /*
2553
+ * expr
2554
+ * : term [ operator term ]*
2555
  * ;
2556
  */
2557
 
2558
+ var values = [],
2559
+ //valueParts = [],
2560
+ value = null,
2561
+ operator = null;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2562
 
2563
+ value = this._term(inFunction);
2564
+ if (value !== null) {
2565
 
2566
+ values.push(value);
 
2567
 
2568
+ do {
2569
+ operator = this._operator(inFunction);
2570
 
2571
+ //if there's an operator, keep building up the value parts
2572
+ if (operator) {
2573
+ values.push(operator);
2574
+ } /*else {
2575
+ //if there's not an operator, you have a full value
2576
+ values.push(new PropertyValue(valueParts, valueParts[0].line, valueParts[0].col));
2577
+ valueParts = [];
2578
+ }*/
2579
 
2580
+ value = this._term(inFunction);
 
 
 
 
2581
 
2582
+ if (value === null) {
 
 
2583
  break;
2584
+ } else {
2585
+ values.push(value);
2586
  }
2587
+ } while (true);
2588
+ }
2589
 
2590
+ //cleanup
2591
+ /*if (valueParts.length) {
2592
+ values.push(new PropertyValue(valueParts, valueParts[0].line, valueParts[0].col));
2593
+ }*/
2594
 
2595
+ return values.length > 0 ? new PropertyValue(values, values[0].line, values[0].col) : null;
2596
  },
2597
 
2598
+ _term: function(inFunction) {
2599
+
2600
  /*
2601
+ * term
2602
+ * : unary_operator?
2603
+ * [ NUMBER S* | PERCENTAGE S* | LENGTH S* | ANGLE S* |
2604
+ * TIME S* | FREQ S* | function | ie_function ]
2605
+ * | STRING S* | IDENT S* | URI S* | UNICODERANGE S* | hexcolor
2606
  * ;
2607
  */
2608
 
2609
  var tokenStream = this._tokenStream,
2610
+ unary = null,
2611
+ value = null,
2612
+ endChar = null,
2613
+ part = null,
2614
+ token,
2615
+ line,
2616
+ col;
2617
 
2618
+ //returns the operator or null
2619
+ unary = this._unary_operator();
2620
+ if (unary !== null) {
2621
+ line = tokenStream.token().startLine;
2622
+ col = tokenStream.token().startCol;
2623
+ }
2624
 
2625
+ //exception for IE filters
2626
+ if (tokenStream.peek() === Tokens.IE_FUNCTION && this.options.ieFilters) {
2627
 
2628
+ value = this._ie_function();
2629
+ if (unary === null) {
2630
+ line = tokenStream.token().startLine;
2631
+ col = tokenStream.token().startCol;
2632
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2633
 
2634
+ //see if it's a simple block
2635
+ } else if (inFunction && tokenStream.match([Tokens.LPAREN, Tokens.LBRACE, Tokens.LBRACKET])) {
2636
 
2637
+ token = tokenStream.token();
2638
+ endChar = token.endChar;
2639
+ value = token.value + this._expr(inFunction).text;
2640
+ if (unary === null) {
2641
+ line = tokenStream.token().startLine;
2642
+ col = tokenStream.token().startCol;
2643
+ }
2644
+ tokenStream.mustMatch(Tokens.type(endChar));
2645
+ value += endChar;
2646
+ this._readWhitespace();
2647
 
2648
+ //see if there's a simple match
2649
+ } else if (tokenStream.match([Tokens.NUMBER, Tokens.PERCENTAGE, Tokens.LENGTH,
2650
+ Tokens.ANGLE, Tokens.TIME,
2651
+ Tokens.FREQ, Tokens.STRING, Tokens.IDENT, Tokens.URI, Tokens.UNICODE_RANGE])) {
2652
 
2653
+ value = tokenStream.token().value;
2654
+ if (unary === null) {
2655
+ line = tokenStream.token().startLine;
2656
+ col = tokenStream.token().startCol;
2657
+ // Correct potentially-inaccurate IDENT parsing in
2658
+ // PropertyValuePart constructor.
2659
+ part = PropertyValuePart.fromToken(tokenStream.token());
2660
+ }
2661
+ this._readWhitespace();
2662
+ } else {
2663
 
2664
+ //see if it's a color
2665
+ token = this._hexcolor();
2666
+ if (token === null) {
2667
 
2668
+ //if there's no unary, get the start of the next token for line/col info
2669
+ if (unary === null) {
2670
+ line = tokenStream.LT(1).startLine;
2671
+ col = tokenStream.LT(1).startCol;
2672
+ }
2673
 
2674
+ //has to be a function
2675
+ if (value === null) {
 
 
2676
 
2677
+ /*
2678
+ * This checks for alpha(opacity=0) style of IE
2679
+ * functions. IE_FUNCTION only presents progid: style.
2680
+ */
2681
+ if (tokenStream.LA(3) === Tokens.EQUALS && this.options.ieFilters) {
2682
+ value = this._ie_function();
2683
+ } else {
2684
+ value = this._function();
2685
+ }
2686
+ }
2687
 
2688
+ /*if (value === null) {
 
2689
  return null;
2690
+ //throw new Error("Expected identifier at line " + tokenStream.token().startLine + ", character " + tokenStream.token().startCol + ".");
2691
+ }*/
2692
+
2693
  } else {
2694
+ value = token.value;
2695
+ if (unary === null) {
2696
+ line = token.startLine;
2697
+ col = token.startCol;
2698
+ }
2699
  }
 
2700
 
2701
+ }
2702
 
2703
+ return part !== null ? part : value !== null ?
2704
+ new PropertyValuePart(unary !== null ? unary + value : value, line, col) :
2705
  null;
2706
+
2707
  },
2708
 
2709
+ _function: function() {
2710
+
2711
  /*
2712
+ * function
2713
+ * : FUNCTION S* expr ')' S*
2714
  * ;
2715
  */
2716
 
2717
  var tokenStream = this._tokenStream,
2718
+ functionText = null,
2719
+ expr = null,
2720
+ lt;
2721
 
2722
+ if (tokenStream.match(Tokens.FUNCTION)) {
2723
+ functionText = tokenStream.token().value;
2724
+ this._readWhitespace();
2725
+ expr = this._expr(true);
2726
+ functionText += expr;
 
 
 
 
 
 
 
 
2727
 
2728
+ //START: Horrible hack in case it's an IE filter
2729
+ if (this.options.ieFilters && tokenStream.peek() === Tokens.EQUALS) {
2730
+ do {
 
 
 
 
 
 
2731
 
2732
+ if (this._readWhitespace()) {
2733
+ functionText += tokenStream.token().value;
2734
+ }
 
 
 
 
2735
 
2736
+ //might be second time in the loop
2737
+ if (tokenStream.LA(0) === Tokens.COMMA) {
2738
+ functionText += tokenStream.token().value;
2739
+ }
2740
 
2741
+ tokenStream.match(Tokens.IDENT);
2742
+ functionText += tokenStream.token().value;
2743
+
2744
+ tokenStream.match(Tokens.EQUALS);
2745
+ functionText += tokenStream.token().value;
2746
+
2747
+ //functionText += this._term();
2748
+ lt = tokenStream.peek();
2749
+ while (lt !== Tokens.COMMA && lt !== Tokens.S && lt !== Tokens.RPAREN) {
2750
+ tokenStream.get();
2751
+ functionText += tokenStream.token().value;
2752
+ lt = tokenStream.peek();
2753
+ }
2754
+ } while (tokenStream.match([Tokens.COMMA, Tokens.S]));
2755
+ }
2756
+
2757
+ //END: Horrible Hack
2758
+
2759
+ tokenStream.match(Tokens.RPAREN);
2760
+ functionText += ")";
2761
+ this._readWhitespace();
2762
  }
2763
 
2764
+ return functionText;
2765
  },
2766
 
2767
+ _ie_function: function() {
2768
+
2769
+ /* (My own extension)
2770
+ * ie_function
2771
+ * : IE_FUNCTION S* IDENT '=' term [S* ','? IDENT '=' term]+ ')' S*
2772
  * ;
2773
  */
2774
 
2775
  var tokenStream = this._tokenStream,
2776
+ functionText = null,
2777
+ lt;
2778
 
2779
+ //IE function can begin like a regular function, too
2780
+ if (tokenStream.match([Tokens.IE_FUNCTION, Tokens.FUNCTION])) {
2781
+ functionText = tokenStream.token().value;
2782
 
2783
+ do {
 
 
 
2784
 
2785
+ if (this._readWhitespace()) {
2786
+ functionText += tokenStream.token().value;
2787
+ }
 
 
 
 
 
 
2788
 
2789
+ //might be second time in the loop
2790
+ if (tokenStream.LA(0) === Tokens.COMMA) {
2791
+ functionText += tokenStream.token().value;
2792
+ }
2793
 
2794
+ tokenStream.match(Tokens.IDENT);
2795
+ functionText += tokenStream.token().value;
 
2796
 
2797
+ tokenStream.match(Tokens.EQUALS);
2798
+ functionText += tokenStream.token().value;
2799
+
2800
+ //functionText += this._term();
2801
+ lt = tokenStream.peek();
2802
+ while (lt !== Tokens.COMMA && lt !== Tokens.S && lt !== Tokens.RPAREN) {
2803
+ tokenStream.get();
2804
+ functionText += tokenStream.token().value;
2805
+ lt = tokenStream.peek();
2806
+ }
2807
+ } while (tokenStream.match([Tokens.COMMA, Tokens.S]));
2808
 
2809
+ tokenStream.match(Tokens.RPAREN);
2810
+ functionText += ")";
2811
+ this._readWhitespace();
2812
  }
2813
 
2814
+ return functionText;
2815
  },
2816
 
2817
+ _hexcolor: function() {
 
2818
  /*
2819
+ * There is a constraint on the color that it must
2820
+ * have either 3 or 6 hex-digits (i.e., [0-9a-fA-F])
2821
+ * after the "#"; e.g., "#000" is OK, but "#abcd" is not.
2822
+ *
2823
+ * hexcolor
2824
+ * : HASH S*
2825
  * ;
2826
  */
2827
+
2828
  var tokenStream = this._tokenStream,
2829
+ token = null,
2830
+ color;
2831
 
2832
+ if (tokenStream.match(Tokens.HASH)) {
 
 
 
2833
 
2834
+ //need to do some validation here
2835
+
2836
+ token = tokenStream.token();
2837
+ color = token.value;
2838
+ if (!/#[a-f0-9]{3,6}/i.test(color)) {
2839
+ throw new SyntaxError("Expected a hex color but found '" + color + "' at line " + token.startLine + ", col " + token.startCol + ".", token.startLine, token.startCol);
2840
+ }
2841
+ this._readWhitespace();
2842
  }
2843
 
2844
+ return token;
2845
+ },
2846
+
2847
+ //-----------------------------------------------------------------
2848
+ // Animations methods
2849
+ //-----------------------------------------------------------------
2850
 
2851
+ _keyframes: function() {
2852
 
 
 
2853
  /*
2854
+ * keyframes:
2855
+ * : KEYFRAMES_SYM S* keyframe_name S* '{' S* keyframe_rule* '}' {
 
 
 
 
 
 
 
2856
  * ;
2857
  */
 
2858
  var tokenStream = this._tokenStream,
2859
+ token,
2860
+ tt,
2861
+ name,
2862
+ prefix = "";
2863
 
2864
+ tokenStream.mustMatch(Tokens.KEYFRAMES_SYM);
2865
+ token = tokenStream.token();
2866
+ if (/^@\-([^\-]+)\-/.test(token.value)) {
2867
+ prefix = RegExp.$1;
2868
+ }
2869
 
2870
+ this._readWhitespace();
2871
+ name = this._keyframe_name();
2872
 
2873
+ this._readWhitespace();
2874
+ tokenStream.mustMatch(Tokens.LBRACE);
 
2875
 
2876
+ this.fire({
2877
+ type: "startkeyframes",
2878
+ name: name,
2879
+ prefix: prefix,
2880
+ line: token.startLine,
2881
+ col: token.startCol
2882
+ });
2883
 
2884
+ this._readWhitespace();
2885
+ tt = tokenStream.peek();
2886
 
2887
+ //check for key
2888
+ while (tt === Tokens.IDENT || tt === Tokens.PERCENTAGE) {
2889
+ this._keyframe_rule();
2890
+ this._readWhitespace();
2891
+ tt = tokenStream.peek();
2892
+ }
2893
 
2894
+ this.fire({
2895
+ type: "endkeyframes",
2896
+ name: name,
2897
+ prefix: prefix,
2898
+ line: token.startLine,
2899
+ col: token.startCol
2900
+ });
2901
 
2902
+ this._readWhitespace();
2903
+ tokenStream.mustMatch(Tokens.RBRACE);
2904
+ this._readWhitespace();
2905
 
 
 
 
 
2906
  },
2907
 
2908
+ _keyframe_name: function() {
 
2909
 
2910
  /*
2911
+ * keyframe_name:
2912
+ * : IDENT
2913
+ * | STRING
2914
  * ;
2915
  */
2916
+ var tokenStream = this._tokenStream;
2917
 
2918
+ tokenStream.mustMatch([Tokens.IDENT, Tokens.STRING]);
2919
+ return SyntaxUnit.fromToken(tokenStream.token());
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2920
  },
2921
 
2922
+ _keyframe_rule: function() {
2923
+
2924
  /*
2925
+ * keyframe_rule:
2926
+ * : key_list S*
2927
+ * '{' S* declaration [ ';' S* declaration ]* '}' S*
2928
  * ;
2929
+ */
2930
+ var keyList = this._key_list();
2931
 
2932
+ this.fire({
2933
+ type: "startkeyframerule",
2934
+ keys: keyList,
2935
+ line: keyList[0].line,
2936
+ col: keyList[0].col
2937
+ });
2938
 
2939
+ this._readDeclarations(true);
2940
+
2941
+ this.fire({
2942
+ type: "endkeyframerule",
2943
+ keys: keyList,
2944
+ line: keyList[0].line,
2945
+ col: keyList[0].col
2946
+ });
2947
 
 
2948
  },
2949
 
2950
+ _key_list: function() {
2951
+
2952
  /*
2953
+ * key_list:
2954
+ * : key [ S* ',' S* key]*
2955
  * ;
2956
  */
 
2957
  var tokenStream = this._tokenStream,
2958
+ keyList = [];
2959
 
2960
+ //must be least one key
2961
+ keyList.push(this._key());
 
 
2962
 
2963
+ this._readWhitespace();
 
 
2964
 
2965
+ while (tokenStream.match(Tokens.COMMA)) {
2966
+ this._readWhitespace();
2967
+ keyList.push(this._key());
2968
+ this._readWhitespace();
2969
+ }
2970
 
2971
+ return keyList;
2972
  },
2973
 
2974
+ _key: function() {
 
2975
  /*
2976
+ * There is a restriction that IDENT can be only "from" or "to".
2977
+ *
2978
+ * key
2979
+ * : PERCENTAGE
2980
+ * | IDENT
2981
  * ;
2982
  */
2983
 
2984
  var tokenStream = this._tokenStream,
2985
+ token;
 
 
 
 
2986
 
2987
+ if (tokenStream.match(Tokens.PERCENTAGE)) {
2988
+ return SyntaxUnit.fromToken(tokenStream.token());
2989
+ } else if (tokenStream.match(Tokens.IDENT)) {
2990
+ token = tokenStream.token();
 
 
 
 
 
 
2991
 
2992
+ if (/from|to/i.test(token.value)) {
2993
+ return SyntaxUnit.fromToken(token);
2994
+ }
2995
+
2996
+ tokenStream.unget();
2997
  }
2998
 
2999
+ //if it gets here, there wasn't a valid token, so time to explode
3000
+ this._unexpectedToken(tokenStream.LT(1));
3001
  },
3002
 
3003
+ //-----------------------------------------------------------------
3004
+ // Helper methods
3005
+ //-----------------------------------------------------------------
3006
+
3007
+ /**
3008
+ * Not part of CSS grammar, but useful for skipping over
3009
+ * combination of white space and HTML-style comments.
3010
+ * @return {void}
3011
+ * @method _skipCruft
3012
+ * @private
3013
+ */
3014
+ _skipCruft: function() {
3015
+ while (this._tokenStream.match([Tokens.S, Tokens.CDO, Tokens.CDC])) {
3016
+ //noop
3017
+ }
3018
+ },
3019
+
3020
+ /**
3021
+ * Not part of CSS grammar, but this pattern occurs frequently
3022
+ * in the official CSS grammar. Split out here to eliminate
3023
+ * duplicate code.
3024
+ * @param {Boolean} checkStart Indicates if the rule should check
3025
+ * for the left brace at the beginning.
3026
+ * @param {Boolean} readMargins Indicates if the rule should check
3027
+ * for margin patterns.
3028
+ * @return {void}
3029
+ * @method _readDeclarations
3030
+ * @private
3031
+ */
3032
+ _readDeclarations: function(checkStart, readMargins) {
3033
  /*
3034
+ * Reads the pattern
3035
+ * S* '{' S* declaration [ ';' S* declaration ]* '}' S*
3036
+ * or
3037
+ * S* '{' S* [ declaration | margin ]? [ ';' S* [ declaration | margin ]? ]* '}' S*
3038
+ * Note that this is how it is described in CSS3 Paged Media, but is actually incorrect.
3039
+ * A semicolon is only necessary following a declaration if there's another declaration
3040
+ * or margin afterwards.
3041
  */
 
3042
  var tokenStream = this._tokenStream,
3043
+ tt;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3044
 
 
 
3045
 
3046
+ this._readWhitespace();
3047
 
3048
+ if (checkStart) {
3049
+ tokenStream.mustMatch(Tokens.LBRACE);
3050
  }
3051
 
3052
+ this._readWhitespace();
 
 
 
3053
 
3054
+ try {
 
 
 
 
 
3055
 
3056
+ while (true) {
3057
+
3058
+ if (tokenStream.match(Tokens.SEMICOLON) || (readMargins && this._margin())) {
3059
+ //noop
3060
+ } else if (this._declaration()) {
3061
+ if (!tokenStream.match(Tokens.SEMICOLON)) {
3062
+ break;
3063
+ }
3064
+ } else {
3065
+ break;
3066
+ }
3067
 
3068
+ //if ((!this._margin() && !this._declaration()) || !tokenStream.match(Tokens.SEMICOLON)){
3069
+ // break;
3070
+ //}
3071
+ this._readWhitespace();
3072
+ }
3073
 
3074
+ tokenStream.mustMatch(Tokens.RBRACE);
3075
+ this._readWhitespace();
 
 
 
 
3076
 
3077
+ } catch (ex) {
3078
+ if (ex instanceof SyntaxError && !this.options.strict) {
3079
+
3080
+ //fire error event
3081
+ this.fire({
3082
+ type: "error",
3083
+ error: ex,
3084
+ message: ex.message,
3085
+ line: ex.line,
3086
+ col: ex.col
3087
+ });
3088
 
3089
+ //see if there's another declaration
3090
+ tt = tokenStream.advance([Tokens.SEMICOLON, Tokens.RBRACE]);
3091
+ if (tt === Tokens.SEMICOLON) {
3092
+ //if there's a semicolon, then there might be another declaration
3093
+ this._readDeclarations(false, readMargins);
3094
+ } else if (tt !== Tokens.RBRACE) {
3095
+ //if there's a right brace, the rule is finished so don't do anything
3096
+ //otherwise, rethrow the error because it wasn't handled properly
3097
+ throw ex;
3098
+ }
3099
 
3100
+ } else {
3101
+ //not a syntax error, rethrow it
3102
+ throw ex;
3103
+ }
3104
+ }
3105
 
3106
+ },
3107
 
3108
+ /**
3109
+ * In some cases, you can end up with two white space tokens in a
3110
+ * row. Instead of making a change in every function that looks for
3111
+ * white space, this function is used to match as much white space
3112
+ * as necessary.
3113
+ * @method _readWhitespace
3114
+ * @return {String} The white space if found, empty string if not.
3115
+ * @private
3116
+ */
3117
+ _readWhitespace: function() {
3118
 
3119
+ var tokenStream = this._tokenStream,
3120
+ ws = "";
3121
 
3122
+ while (tokenStream.match(Tokens.S)) {
3123
+ ws += tokenStream.token().value;
3124
+ }
 
 
 
 
 
3125
 
3126
+ return ws;
3127
+ },
3128
 
 
 
 
 
 
3129
 
3130
+ /**
3131
+ * Throws an error when an unexpected token is found.
3132
+ * @param {Object} token The token that was found.
3133
+ * @method _unexpectedToken
3134
+ * @return {void}
3135
+ * @private
3136
+ */
3137
+ _unexpectedToken: function(token) {
3138
+ throw new SyntaxError("Unexpected token '" + token.value + "' at line " + token.startLine + ", col " + token.startCol + ".", token.startLine, token.startCol);
3139
+ },
3140
 
3141
+ /**
3142
+ * Helper method used for parsing subparts of a style sheet.
3143
+ * @return {void}
3144
+ * @method _verifyEnd
3145
+ * @private
3146
+ */
3147
+ _verifyEnd: function() {
3148
+ if (this._tokenStream.LA(1) !== Tokens.EOF) {
3149
+ this._unexpectedToken(this._tokenStream.LT(1));
3150
  }
3151
  },
3152
 
3153
+ //-----------------------------------------------------------------
3154
+ // Validation methods
3155
+ //-----------------------------------------------------------------
3156
+ _validateProperty: function(property, value) {
3157
+ Validation.validate(property, value);
3158
+ },
3159
 
3160
+ //-----------------------------------------------------------------
3161
+ // Parsing methods
3162
+ //-----------------------------------------------------------------
3163
 
3164
+ parse: function(input) {
3165
+ this._tokenStream = new TokenStream(input, Tokens);
3166
+ this._stylesheet();
3167
  },
3168
 
3169
+ parseStyleSheet: function(input) {
3170
+ //just passthrough
3171
+ return this.parse(input);
3172
+ },
 
 
3173
 
3174
+ parseMediaQuery: function(input) {
3175
+ this._tokenStream = new TokenStream(input, Tokens);
3176
+ var result = this._media_query();
 
 
3177
 
3178
+ //if there's anything more, then it's an invalid selector
3179
+ this._verifyEnd();
3180
 
3181
+ //otherwise return result
3182
+ return result;
3183
+ },
3184
 
3185
+ /**
3186
+ * Parses a property value (everything after the semicolon).
3187
+ * @return {parserlib.css.PropertyValue} The property value.
3188
+ * @throws parserlib.util.SyntaxError If an unexpected token is found.
3189
+ * @method parserPropertyValue
3190
+ */
3191
+ parsePropertyValue: function(input) {
3192
 
3193
+ this._tokenStream = new TokenStream(input, Tokens);
3194
+ this._readWhitespace();
 
 
 
 
 
 
3195
 
3196
+ var result = this._expr();
3197
 
3198
+ //okay to have a trailing white space
3199
+ this._readWhitespace();
 
 
 
 
 
3200
 
3201
+ //if there's anything more, then it's an invalid selector
3202
+ this._verifyEnd();
 
 
3203
 
3204
+ //otherwise return result
3205
+ return result;
3206
  },
3207
 
3208
+ /**
3209
+ * Parses a complete CSS rule, including selectors and
3210
+ * properties.
3211
+ * @param {String} input The text to parser.
3212
+ * @return {Boolean} True if the parse completed successfully, false if not.
3213
+ * @method parseRule
3214
+ */
3215
+ parseRule: function(input) {
3216
+ this._tokenStream = new TokenStream(input, Tokens);
3217
 
3218
+ //skip any leading white space
3219
+ this._readWhitespace();
 
 
 
 
 
 
3220
 
3221
+ var result = this._ruleset();
 
 
 
 
 
3222
 
3223
+ //skip any trailing white space
3224
+ this._readWhitespace();
 
 
 
 
3225
 
3226
+ //if there's anything more, then it's an invalid selector
3227
+ this._verifyEnd();
3228
 
3229
+ //otherwise return result
3230
+ return result;
3231
+ },
 
 
3232
 
3233
+ /**
3234
+ * Parses a single CSS selector (no comma)
3235
+ * @param {String} input The text to parse as a CSS selector.
3236
+ * @return {Selector} An object representing the selector.
3237
+ * @throws parserlib.util.SyntaxError If an unexpected token is found.
3238
+ * @method parseSelector
3239
+ */
3240
+ parseSelector: function(input) {
3241
 
3242
+ this._tokenStream = new TokenStream(input, Tokens);
 
 
 
 
 
 
3243
 
3244
+ //skip any leading white space
3245
+ this._readWhitespace();
 
3246
 
3247
+ var result = this._selector();
 
 
 
 
3248
 
3249
+ //skip any trailing white space
3250
+ this._readWhitespace();
3251
 
3252
+ //if there's anything more, then it's an invalid selector
3253
+ this._verifyEnd();
 
 
 
 
 
 
 
 
3254
 
3255
+ //otherwise return result
3256
+ return result;
3257
+ },
 
3258
 
3259
+ /**
3260
+ * Parses an HTML style attribute: a set of CSS declarations
3261
+ * separated by semicolons.
3262
+ * @param {String} input The text to parse as a style attribute
3263
+ * @return {void}
3264
+ * @method parseStyleAttribute
3265
+ */
3266
+ parseStyleAttribute: function(input) {
3267
+ input += "}"; // for error recovery in _readDeclarations()
3268
+ this._tokenStream = new TokenStream(input, Tokens);
3269
+ this._readDeclarations();
3270
+ }
3271
+ };
3272
 
3273
+ //copy over onto prototype
3274
+ for (prop in additions) {
3275
+ if (Object.prototype.hasOwnProperty.call(additions, prop)) {
3276
+ proto[prop] = additions[prop];
3277
+ }
3278
+ }
3279
 
3280
+ return proto;
3281
+ }();
 
3282
 
 
3283
 
3284
+ /*
3285
+ nth
3286
+ : S* [ ['-'|'+']? INTEGER? {N} [ S* ['-'|'+'] S* INTEGER ]? |
3287
+ ['-'|'+']? INTEGER | {O}{D}{D} | {E}{V}{E}{N} ] S*
3288
+ ;
3289
+ */
3290
 
3291
+ },{"../util/EventTarget":23,"../util/SyntaxError":25,"../util/SyntaxUnit":26,"./Combinator":2,"./MediaFeature":4,"./MediaQuery":5,"./PropertyName":8,"./PropertyValue":9,"./PropertyValuePart":11,"./Selector":13,"./SelectorPart":14,"./SelectorSubPart":15,"./TokenStream":17,"./Tokens":18,"./Validation":19}],7:[function(require,module,exports){
3292
+ "use strict";
 
 
 
3293
 
3294
+ /* exported Properties */
 
 
 
3295
 
3296
+ var Properties = module.exports = {
3297
+ __proto__: null,
 
 
 
3298
 
3299
+ //A
3300
+ "align-items" : "flex-start | flex-end | center | baseline | stretch",
3301
+ "align-content" : "flex-start | flex-end | center | space-between | space-around | stretch",
3302
+ "align-self" : "auto | flex-start | flex-end | center | baseline | stretch",
3303
+ "-webkit-align-items" : "flex-start | flex-end | center | baseline | stretch",
3304
+ "-webkit-align-content" : "flex-start | flex-end | center | space-between | space-around | stretch",
3305
+ "-webkit-align-self" : "auto | flex-start | flex-end | center | baseline | stretch",
3306
+ "alignment-adjust" : "auto | baseline | before-edge | text-before-edge | middle | central | after-edge | text-after-edge | ideographic | alphabetic | hanging | mathematical | <percentage> | <length>",
3307
+ "alignment-baseline" : "auto | baseline | use-script | before-edge | text-before-edge | after-edge | text-after-edge | central | middle | ideographic | alphabetic | hanging | mathematical",
3308
+ "animation" : 1,
3309
+ "animation-delay" : "<time>#",
3310
+ "animation-direction" : "<single-animation-direction>#",
3311
+ "animation-duration" : "<time>#",
3312
+ "animation-fill-mode" : "[ none | forwards | backwards | both ]#",
3313
+ "animation-iteration-count" : "[ <number> | infinite ]#",
3314
+ "animation-name" : "[ none | <single-animation-name> ]#",
3315
+ "animation-play-state" : "[ running | paused ]#",
3316
+ "animation-timing-function" : 1,
3317
 
3318
+ //vendor prefixed
3319
+ "-moz-animation-delay" : "<time>#",
3320
+ "-moz-animation-direction" : "[ normal | alternate ]#",
3321
+ "-moz-animation-duration" : "<time>#",
3322
+ "-moz-animation-iteration-count" : "[ <number> | infinite ]#",
3323
+ "-moz-animation-name" : "[ none | <single-animation-name> ]#",
3324
+ "-moz-animation-play-state" : "[ running | paused ]#",
3325
+
3326
+ "-ms-animation-delay" : "<time>#",
3327
+ "-ms-animation-direction" : "[ normal | alternate ]#",
3328
+ "-ms-animation-duration" : "<time>#",
3329
+ "-ms-animation-iteration-count" : "[ <number> | infinite ]#",
3330
+ "-ms-animation-name" : "[ none | <single-animation-name> ]#",
3331
+ "-ms-animation-play-state" : "[ running | paused ]#",
3332
+
3333
+ "-webkit-animation-delay" : "<time>#",
3334
+ "-webkit-animation-direction" : "[ normal | alternate ]#",
3335
+ "-webkit-animation-duration" : "<time>#",
3336
+ "-webkit-animation-fill-mode" : "[ none | forwards | backwards | both ]#",
3337
+ "-webkit-animation-iteration-count" : "[ <number> | infinite ]#",
3338
+ "-webkit-animation-name" : "[ none | <single-animation-name> ]#",
3339
+ "-webkit-animation-play-state" : "[ running | paused ]#",
3340
+
3341
+ "-o-animation-delay" : "<time>#",
3342
+ "-o-animation-direction" : "[ normal | alternate ]#",
3343
+ "-o-animation-duration" : "<time>#",
3344
+ "-o-animation-iteration-count" : "[ <number> | infinite ]#",
3345
+ "-o-animation-name" : "[ none | <single-animation-name> ]#",
3346
+ "-o-animation-play-state" : "[ running | paused ]#",
3347
+
3348
+ "appearance" : "icon | window | desktop | workspace | document | tooltip | dialog | button | push-button | hyperlink | radio | radio-button | checkbox | menu-item | tab | menu | menubar | pull-down-menu | pop-up-menu | list-menu | radio-group | checkbox-group | outline-tree | range | field | combo-box | signature | password | normal | none",
3349
+ "azimuth" : "<azimuth>",
3350
 
3351
+ //B
3352
+ "backface-visibility" : "visible | hidden",
3353
+ "background" : 1,
3354
+ "background-attachment" : "<attachment>#",
3355
+ "background-clip" : "<box>#",
3356
+ "background-color" : "<color>",
3357
+ "background-image" : "<bg-image>#",
3358
+ "background-origin" : "<box>#",
3359
+ "background-position" : "<bg-position>",
3360
+ "background-repeat" : "<repeat-style>#",
3361
+ "background-size" : "<bg-size>#",
3362
+ "baseline-shift" : "baseline | sub | super | <percentage> | <length>",
3363
+ "behavior" : 1,
3364
+ "binding" : 1,
3365
+ "bleed" : "<length>",
3366
+ "bookmark-label" : "<content> | <attr> | <string>",
3367
+ "bookmark-level" : "none | <integer>",
3368
+ "bookmark-state" : "open | closed",
3369
+ "bookmark-target" : "none | <uri> | <attr>",
3370
+ "border" : "<border-width> || <border-style> || <color>",
3371
+ "border-bottom" : "<border-width> || <border-style> || <color>",
3372
+ "border-bottom-color" : "<color>",
3373
+ "border-bottom-left-radius" : "<x-one-radius>",
3374
+ "border-bottom-right-radius" : "<x-one-radius>",
3375
+ "border-bottom-style" : "<border-style>",
3376
+ "border-bottom-width" : "<border-width>",
3377
+ "border-collapse" : "collapse | separate",
3378
+ "border-color" : "<color>{1,4}",
3379
+ "border-image" : 1,
3380
+ "border-image-outset" : "[ <length> | <number> ]{1,4}",
3381
+ "border-image-repeat" : "[ stretch | repeat | round ]{1,2}",
3382
+ "border-image-slice" : "<border-image-slice>",
3383
+ "border-image-source" : "<image> | none",
3384
+ "border-image-width" : "[ <length> | <percentage> | <number> | auto ]{1,4}",
3385
+ "border-left" : "<border-width> || <border-style> || <color>",
3386
+ "border-left-color" : "<color>",
3387
+ "border-left-style" : "<border-style>",
3388
+ "border-left-width" : "<border-width>",
3389
+ "border-radius" : "<border-radius>",
3390
+ "border-right" : "<border-width> || <border-style> || <color>",
3391
+ "border-right-color" : "<color>",
3392
+ "border-right-style" : "<border-style>",
3393
+ "border-right-width" : "<border-width>",
3394
+ "border-spacing" : "<length>{1,2}",
3395
+ "border-style" : "<border-style>{1,4}",
3396
+ "border-top" : "<border-width> || <border-style> || <color>",
3397
+ "border-top-color" : "<color>",
3398
+ "border-top-left-radius" : "<x-one-radius>",
3399
+ "border-top-right-radius" : "<x-one-radius>",
3400
+ "border-top-style" : "<border-style>",
3401
+ "border-top-width" : "<border-width>",
3402
+ "border-width" : "<border-width>{1,4}",
3403
+ "bottom" : "<margin-width>",
3404
+ "-moz-box-align" : "start | end | center | baseline | stretch",
3405
+ "-moz-box-decoration-break" : "slice | clone",
3406
+ "-moz-box-direction" : "normal | reverse",
3407
+ "-moz-box-flex" : "<number>",
3408
+ "-moz-box-flex-group" : "<integer>",
3409
+ "-moz-box-lines" : "single | multiple",
3410
+ "-moz-box-ordinal-group" : "<integer>",
3411
+ "-moz-box-orient" : "horizontal | vertical | inline-axis | block-axis",
3412
+ "-moz-box-pack" : "start | end | center | justify",
3413
+ "-o-box-decoration-break" : "slice | clone",
3414
+ "-webkit-box-align" : "start | end | center | baseline | stretch",
3415
+ "-webkit-box-decoration-break" : "slice | clone",
3416
+ "-webkit-box-direction" : "normal | reverse",
3417
+ "-webkit-box-flex" : "<number>",
3418
+ "-webkit-box-flex-group" : "<integer>",
3419
+ "-webkit-box-lines" : "single | multiple",
3420
+ "-webkit-box-ordinal-group" : "<integer>",
3421
+ "-webkit-box-orient" : "horizontal | vertical | inline-axis | block-axis",
3422
+ "-webkit-box-pack" : "start | end | center | justify",
3423
+ "box-decoration-break" : "slice | clone",
3424
+ "box-shadow" : "<box-shadow>",
3425
+ "box-sizing" : "content-box | border-box",
3426
+ "break-after" : "auto | always | avoid | left | right | page | column | avoid-page | avoid-column",
3427
+ "break-before" : "auto | always | avoid | left | right | page | column | avoid-page | avoid-column",
3428
+ "break-inside" : "auto | avoid | avoid-page | avoid-column",
3429
 
3430
+ //C
3431
+ "caption-side" : "top | bottom",
3432
+ "clear" : "none | right | left | both",
3433
+ "clip" : "<shape> | auto",
3434
+ "-webkit-clip-path" : "<clip-source> | <clip-path> | none",
3435
+ "clip-path" : "<clip-source> | <clip-path> | none",
3436
+ "clip-rule" : "nonzero | evenodd",
3437
+ "color" : "<color>",
3438
+ "color-interpolation" : "auto | sRGB | linearRGB",
3439
+ "color-interpolation-filters" : "auto | sRGB | linearRGB",
3440
+ "color-profile" : 1,
3441
+ "color-rendering" : "auto | optimizeSpeed | optimizeQuality",
3442
+ "column-count" : "<integer> | auto", //https://www.w3.org/TR/css3-multicol/
3443
+ "column-fill" : "auto | balance",
3444
+ "column-gap" : "<length> | normal",
3445
+ "column-rule" : "<border-width> || <border-style> || <color>",
3446
+ "column-rule-color" : "<color>",
3447
+ "column-rule-style" : "<border-style>",
3448
+ "column-rule-width" : "<border-width>",
3449
+ "column-span" : "none | all",
3450
+ "column-width" : "<length> | auto",
3451
+ "columns" : 1,
3452
+ "content" : 1,
3453
+ "counter-increment" : 1,
3454
+ "counter-reset" : 1,
3455
+ "crop" : "<shape> | auto",
3456
+ "cue" : "cue-after | cue-before",
3457
+ "cue-after" : 1,
3458
+ "cue-before" : 1,
3459
+ "cursor" : 1,
3460
 
3461
+ //D
3462
+ "direction" : "ltr | rtl",
3463
+ "display" : "inline | block | list-item | inline-block | table | inline-table | table-row-group | table-header-group | table-footer-group | table-row | table-column-group | table-column | table-cell | table-caption | grid | inline-grid | run-in | ruby | ruby-base | ruby-text | ruby-base-container | ruby-text-container | contents | none | -moz-box | -moz-inline-block | -moz-inline-box | -moz-inline-grid | -moz-inline-stack | -moz-inline-table | -moz-grid | -moz-grid-group | -moz-grid-line | -moz-groupbox | -moz-deck | -moz-popup | -moz-stack | -moz-marker | -webkit-box | -webkit-inline-box | -ms-flexbox | -ms-inline-flexbox | flex | -webkit-flex | inline-flex | -webkit-inline-flex",
3464
+ "dominant-baseline" : "auto | use-script | no-change | reset-size | ideographic | alphabetic | hanging | mathematical | central | middle | text-after-edge | text-before-edge",
3465
+ "drop-initial-after-adjust" : "central | middle | after-edge | text-after-edge | ideographic | alphabetic | mathematical | <percentage> | <length>",
3466
+ "drop-initial-after-align" : "baseline | use-script | before-edge | text-before-edge | after-edge | text-after-edge | central | middle | ideographic | alphabetic | hanging | mathematical",
3467
+ "drop-initial-before-adjust" : "before-edge | text-before-edge | central | middle | hanging | mathematical | <percentage> | <length>",
3468
+ "drop-initial-before-align" : "caps-height | baseline | use-script | before-edge | text-before-edge | after-edge | text-after-edge | central | middle | ideographic | alphabetic | hanging | mathematical",
3469
+ "drop-initial-size" : "auto | line | <length> | <percentage>",
3470
+ "drop-initial-value" : "<integer>",
3471
 
3472
+ //E
3473
+ "elevation" : "<angle> | below | level | above | higher | lower",
3474
+ "empty-cells" : "show | hide",
3475
+ "enable-background" : 1,
 
 
 
 
 
3476
 
3477
+ //F
3478
+ "fill" : "<paint>",
3479
+ "fill-opacity" : "<opacity-value>",
3480
+ "fill-rule" : "nonzero | evenodd",
3481
+ "filter" : "<filter-function-list> | none",
3482
+ "fit" : "fill | hidden | meet | slice",
3483
+ "fit-position" : 1,
3484
+ "flex" : "<flex>",
3485
+ "flex-basis" : "<width>",
3486
+ "flex-direction" : "row | row-reverse | column | column-reverse",
3487
+ "flex-flow" : "<flex-direction> || <flex-wrap>",
3488
+ "flex-grow" : "<number>",
3489
+ "flex-shrink" : "<number>",
3490
+ "flex-wrap" : "nowrap | wrap | wrap-reverse",
3491
+ "-webkit-flex" : "<flex>",
3492
+ "-webkit-flex-basis" : "<width>",
3493
+ "-webkit-flex-direction" : "row | row-reverse | column | column-reverse",
3494
+ "-webkit-flex-flow" : "<flex-direction> || <flex-wrap>",
3495
+ "-webkit-flex-grow" : "<number>",
3496
+ "-webkit-flex-shrink" : "<number>",
3497
+ "-webkit-flex-wrap" : "nowrap | wrap | wrap-reverse",
3498
+ "-ms-flex" : "<flex>",
3499
+ "-ms-flex-align" : "start | end | center | stretch | baseline",
3500
+ "-ms-flex-direction" : "row | row-reverse | column | column-reverse",
3501
+ "-ms-flex-order" : "<number>",
3502
+ "-ms-flex-pack" : "start | end | center | justify",
3503
+ "-ms-flex-wrap" : "nowrap | wrap | wrap-reverse",
3504
+ "float" : "left | right | none",
3505
+ "float-offset" : 1,
3506
+ "flood-color" : 1,
3507
+ "flood-opacity" : "<opacity-value>",
3508
+ "font" : "<font-shorthand> | caption | icon | menu | message-box | small-caption | status-bar",
3509
+ "font-family" : "<font-family>",
3510
+ "font-feature-settings" : "<feature-tag-value> | normal",
3511
+ "font-kerning" : "auto | normal | none",
3512
+ "font-size" : "<font-size>",
3513
+ "font-size-adjust" : "<number> | none",
3514
+ "font-stretch" : "<font-stretch>",
3515
+ "font-style" : "<font-style>",
3516
+ "font-variant" : "<font-variant> | normal | none",
3517
+ "font-variant-alternates" : "<font-variant-alternates> | normal",
3518
+ "font-variant-caps" : "<font-variant-caps> | normal",
3519
+ "font-variant-east-asian" : "<font-variant-east-asian> | normal",
3520
+ "font-variant-ligatures" : "<font-variant-ligatures> | normal | none",
3521
+ "font-variant-numeric" : "<font-variant-numeric> | normal",
3522
+ "font-variant-position" : "normal | sub | super",
3523
+ "font-weight" : "<font-weight>",
3524
 
3525
+ //G
3526
+ "glyph-orientation-horizontal" : "<glyph-angle>",
3527
+ "glyph-orientation-vertical" : "auto | <glyph-angle>",
3528
+ "grid" : 1,
3529
+ "grid-area" : 1,
3530
+ "grid-auto-columns" : 1,
3531
+ "grid-auto-flow" : 1,
3532
+ "grid-auto-position" : 1,
3533
+ "grid-auto-rows" : 1,
3534
+ "grid-cell-stacking" : "columns | rows | layer",
3535
+ "grid-column" : 1,
3536
+ "grid-columns" : 1,
3537
+ "grid-column-align" : "start | end | center | stretch",
3538
+ "grid-column-sizing" : 1,
3539
+ "grid-column-start" : 1,
3540
+ "grid-column-end" : 1,
3541
+ "grid-column-span" : "<integer>",
3542
+ "grid-flow" : "none | rows | columns",
3543
+ "grid-layer" : "<integer>",
3544
+ "grid-row" : 1,
3545
+ "grid-rows" : 1,
3546
+ "grid-row-align" : "start | end | center | stretch",
3547
+ "grid-row-start" : 1,
3548
+ "grid-row-end" : 1,
3549
+ "grid-row-span" : "<integer>",
3550
+ "grid-row-sizing" : 1,
3551
+ "grid-template" : 1,
3552
+ "grid-template-areas" : 1,
3553
+ "grid-template-columns" : 1,
3554
+ "grid-template-rows" : 1,
3555
 
3556
+ //H
3557
+ "hanging-punctuation" : 1,
3558
+ "height" : "<margin-width> | <content-sizing>",
3559
+ "hyphenate-after" : "<integer> | auto",
3560
+ "hyphenate-before" : "<integer> | auto",
3561
+ "hyphenate-character" : "<string> | auto",
3562
+ "hyphenate-lines" : "no-limit | <integer>",
3563
+ "hyphenate-resource" : 1,
3564
+ "hyphens" : "none | manual | auto",
3565
 
3566
+ //I
3567
+ "icon" : 1,
3568
+ "image-orientation" : "angle | auto",
3569
+ "image-rendering" : "auto | optimizeSpeed | optimizeQuality",
3570
+ "image-resolution" : 1,
3571
+ "ime-mode" : "auto | normal | active | inactive | disabled",
3572
+ "inline-box-align" : "last | <integer>",
3573
 
3574
+ //J
3575
+ "justify-content" : "flex-start | flex-end | center | space-between | space-around",
3576
+ "-webkit-justify-content" : "flex-start | flex-end | center | space-between | space-around",
 
 
3577
 
3578
+ //K
3579
+ "kerning" : "auto | <length>",
 
 
3580
 
3581
+ //L
3582
+ "left" : "<margin-width>",
3583
+ "letter-spacing" : "<length> | normal",
3584
+ "line-height" : "<line-height>",
3585
+ "line-break" : "auto | loose | normal | strict",
3586
+ "line-stacking" : 1,
3587
+ "line-stacking-ruby" : "exclude-ruby | include-ruby",
3588
+ "line-stacking-shift" : "consider-shifts | disregard-shifts",
3589
+ "line-stacking-strategy" : "inline-line-height | block-line-height | max-height | grid-height",
3590
+ "list-style" : 1,
3591
+ "list-style-image" : "<uri> | none",
3592
+ "list-style-position" : "inside | outside",
3593
+ "list-style-type" : "disc | circle | square | decimal | decimal-leading-zero | lower-roman | upper-roman | lower-greek | lower-latin | upper-latin | armenian | georgian | lower-alpha | upper-alpha | none",
3594
 
3595
+ //M
3596
+ "margin" : "<margin-width>{1,4}",
3597
+ "margin-bottom" : "<margin-width>",
3598
+ "margin-left" : "<margin-width>",
3599
+ "margin-right" : "<margin-width>",
3600
+ "margin-top" : "<margin-width>",
3601
+ "mark" : 1,
3602
+ "mark-after" : 1,
3603
+ "mark-before" : 1,
3604
+ "marker" : 1,
3605
+ "marker-end" : 1,
3606
+ "marker-mid" : 1,
3607
+ "marker-start" : 1,
3608
+ "marks" : 1,
3609
+ "marquee-direction" : 1,
3610
+ "marquee-play-count" : 1,
3611
+ "marquee-speed" : 1,
3612
+ "marquee-style" : 1,
3613
+ "mask" : 1,
3614
+ "max-height" : "<length> | <percentage> | <content-sizing> | none",
3615
+ "max-width" : "<length> | <percentage> | <content-sizing> | none",
3616
+ "min-height" : "<length> | <percentage> | <content-sizing> | contain-floats | -moz-contain-floats | -webkit-contain-floats",
3617
+ "min-width" : "<length> | <percentage> | <content-sizing> | contain-floats | -moz-contain-floats | -webkit-contain-floats",
3618
+ "move-to" : 1,
3619
 
3620
+ //N
3621
+ "nav-down" : 1,
3622
+ "nav-index" : 1,
3623
+ "nav-left" : 1,
3624
+ "nav-right" : 1,
3625
+ "nav-up" : 1,
3626
 
3627
+ //O
3628
+ "object-fit" : "fill | contain | cover | none | scale-down",
3629
+ "object-position" : "<position>",
3630
+ "opacity" : "<opacity-value>",
3631
+ "order" : "<integer>",
3632
+ "-webkit-order" : "<integer>",
3633
+ "orphans" : "<integer>",
3634
+ "outline" : 1,
3635
+ "outline-color" : "<color> | invert",
3636
+ "outline-offset" : 1,
3637
+ "outline-style" : "<border-style>",
3638
+ "outline-width" : "<border-width>",
3639
+ "overflow" : "visible | hidden | scroll | auto",
3640
+ "overflow-style" : 1,
3641
+ "overflow-wrap" : "normal | break-word",
3642
+ "overflow-x" : 1,
3643
+ "overflow-y" : 1,
3644
 
3645
+ //P
3646
+ "padding" : "<padding-width>{1,4}",
3647
+ "padding-bottom" : "<padding-width>",
3648
+ "padding-left" : "<padding-width>",
3649
+ "padding-right" : "<padding-width>",
3650
+ "padding-top" : "<padding-width>",
3651
+ "page" : 1,
3652
+ "page-break-after" : "auto | always | avoid | left | right",
3653
+ "page-break-before" : "auto | always | avoid | left | right",
3654
+ "page-break-inside" : "auto | avoid",
3655
+ "page-policy" : 1,
3656
+ "pause" : 1,
3657
+ "pause-after" : 1,
3658
+ "pause-before" : 1,
3659
+ "perspective" : 1,
3660
+ "perspective-origin" : 1,
3661
+ "phonemes" : 1,
3662
+ "pitch" : 1,
3663
+ "pitch-range" : 1,
3664
+ "play-during" : 1,
3665
+ "pointer-events" : "auto | none | visiblePainted | visibleFill | visibleStroke | visible | painted | fill | stroke | all",
3666
+ "position" : "static | relative | absolute | fixed",
3667
+ "presentation-level" : 1,
3668
+ "punctuation-trim" : 1,
3669
 
3670
+ //Q
3671
+ "quotes" : 1,
3672
 
3673
+ //R
3674
+ "rendering-intent" : 1,
3675
+ "resize" : 1,
3676
+ "rest" : 1,
3677
+ "rest-after" : 1,
3678
+ "rest-before" : 1,
3679
+ "richness" : 1,
3680
+ "right" : "<margin-width>",
3681
+ "rotation" : 1,
3682
+ "rotation-point" : 1,
3683
+ "ruby-align" : 1,
3684
+ "ruby-overhang" : 1,
3685
+ "ruby-position" : 1,
3686
+ "ruby-span" : 1,
3687
+
3688
+ //S
3689
+ "shape-rendering" : "auto | optimizeSpeed | crispEdges | geometricPrecision",
3690
+ "size" : 1,
3691
+ "speak" : "normal | none | spell-out",
3692
+ "speak-header" : "once | always",
3693
+ "speak-numeral" : "digits | continuous",
3694
+ "speak-punctuation" : "code | none",
3695
+ "speech-rate" : 1,
3696
+ "src" : 1,
3697
+ "stop-color" : 1,
3698
+ "stop-opacity" : "<opacity-value>",
3699
+ "stress" : 1,
3700
+ "string-set" : 1,
3701
+ "stroke" : "<paint>",
3702
+ "stroke-dasharray" : "none | <dasharray>",
3703
+ "stroke-dashoffset" : "<percentage> | <length>",
3704
+ "stroke-linecap" : "butt | round | square",
3705
+ "stroke-linejoin" : "miter | round | bevel",
3706
+ "stroke-miterlimit" : "<miterlimit>",
3707
+ "stroke-opacity" : "<opacity-value>",
3708
+ "stroke-width" : "<percentage> | <length>",
3709
+
3710
+ "table-layout" : "auto | fixed",
3711
+ "tab-size" : "<integer> | <length>",
3712
+ "target" : 1,
3713
+ "target-name" : 1,
3714
+ "target-new" : 1,
3715
+ "target-position" : 1,
3716
+ "text-align" : "left | right | center | justify | match-parent | start | end",
3717
+ "text-align-last" : 1,
3718
+ "text-anchor" : "start | middle | end",
3719
+ "text-decoration" : "<text-decoration>",
3720
+ "text-emphasis" : 1,
3721
+ "text-height" : 1,
3722
+ "text-indent" : "<length> | <percentage>",
3723
+ "text-justify" : "auto | none | inter-word | inter-ideograph | inter-cluster | distribute | kashida",
3724
+ "text-outline" : 1,
3725
+ "text-overflow" : 1,
3726
+ "text-rendering" : "auto | optimizeSpeed | optimizeLegibility | geometricPrecision",
3727
+ "text-shadow" : 1,
3728
+ "text-transform" : "capitalize | uppercase | lowercase | none",
3729
+ "text-wrap" : "normal | none | avoid",
3730
+ "top" : "<margin-width>",
3731
+ "-ms-touch-action" : "auto | none | pan-x | pan-y | pan-left | pan-right | pan-up | pan-down | manipulation",
3732
+ "touch-action" : "auto | none | pan-x | pan-y | pan-left | pan-right | pan-up | pan-down | manipulation",
3733
+ "transform" : 1,
3734
+ "transform-origin" : 1,
3735
+ "transform-style" : 1,
3736
+ "transition" : 1,
3737
+ "transition-delay" : 1,
3738
+ "transition-duration" : 1,
3739
+ "transition-property" : 1,
3740
+ "transition-timing-function" : 1,
3741
 
3742
+ //U
3743
+ "unicode-bidi" : "normal | embed | isolate | bidi-override | isolate-override | plaintext",
3744
+ "user-modify" : "read-only | read-write | write-only",
3745
+ "user-select" : "none | text | toggle | element | elements | all",
3746
 
3747
+ //V
3748
+ "vertical-align" : "auto | use-script | baseline | sub | super | top | text-top | central | middle | bottom | text-bottom | <percentage> | <length>",
3749
+ "visibility" : "visible | hidden | collapse",
3750
+ "voice-balance" : 1,
3751
+ "voice-duration" : 1,
3752
+ "voice-family" : 1,
3753
+ "voice-pitch" : 1,
3754
+ "voice-pitch-range" : 1,
3755
+ "voice-rate" : 1,
3756
+ "voice-stress" : 1,
3757
+ "voice-volume" : 1,
3758
+ "volume" : 1,
3759
 
3760
+ //W
3761
+ "white-space" : "normal | pre | nowrap | pre-wrap | pre-line | -pre-wrap | -o-pre-wrap | -moz-pre-wrap | -hp-pre-wrap", // https://perishablepress.com/wrapping-content/
3762
+ "white-space-collapse" : 1,
3763
+ "widows" : "<integer>",
3764
+ "width" : "<length> | <percentage> | <content-sizing> | auto",
3765
+ "will-change" : "<will-change>",
3766
+ "word-break" : "normal | keep-all | break-all",
3767
+ "word-spacing" : "<length> | normal",
3768
+ "word-wrap" : "normal | break-word",
3769
+ "writing-mode" : "horizontal-tb | vertical-rl | vertical-lr | lr-tb | rl-tb | tb-rl | bt-rl | tb-lr | bt-lr | lr-bt | rl-bt | lr | rl | tb",
3770
 
3771
+ //Z
3772
+ "z-index" : "<integer> | auto",
3773
+ "zoom" : "<number> | <percentage> | normal"
3774
+ };
3775
 
3776
+ },{}],8:[function(require,module,exports){
3777
+ "use strict";
3778
 
3779
+ module.exports = PropertyName;
3780
 
3781
+ var SyntaxUnit = require("../util/SyntaxUnit");
 
 
 
 
 
 
3782
 
3783
+ var Parser = require("./Parser");
 
3784
 
3785
+ /**
3786
+ * Represents a selector combinator (whitespace, +, >).
3787
+ * @namespace parserlib.css
3788
+ * @class PropertyName
3789
+ * @extends parserlib.util.SyntaxUnit
3790
+ * @constructor
3791
+ * @param {String} text The text representation of the unit.
3792
+ * @param {String} hack The type of IE hack applied ("*", "_", or null).
3793
+ * @param {int} line The line of text on which the unit resides.
3794
+ * @param {int} col The column of text on which the unit resides.
3795
+ */
3796
+ function PropertyName(text, hack, line, col) {
3797
 
3798
+ SyntaxUnit.call(this, text, line, col, Parser.PROPERTY_NAME_TYPE);
3799
 
3800
+ /**
3801
+ * The type of IE hack applied ("*", "_", or null).
3802
+ * @type String
3803
+ * @property hack
3804
+ */
3805
+ this.hack = hack;
 
 
 
 
3806
 
3807
+ }
 
 
 
 
3808
 
3809
+ PropertyName.prototype = new SyntaxUnit();
3810
+ PropertyName.prototype.constructor = PropertyName;
3811
+ PropertyName.prototype.toString = function() {
3812
+ return (this.hack ? this.hack : "") + this.text;
3813
+ };
3814
 
3815
+ },{"../util/SyntaxUnit":26,"./Parser":6}],9:[function(require,module,exports){
3816
+ "use strict";
3817
 
3818
+ module.exports = PropertyValue;
 
 
 
 
 
 
3819
 
3820
+ var SyntaxUnit = require("../util/SyntaxUnit");
 
3821
 
3822
+ var Parser = require("./Parser");
 
 
 
 
 
3823
 
3824
+ /**
3825
+ * Represents a single part of a CSS property value, meaning that it represents
3826
+ * just everything single part between ":" and ";". If there are multiple values
3827
+ * separated by commas, this type represents just one of the values.
3828
+ * @param {String[]} parts An array of value parts making up this value.
3829
+ * @param {int} line The line of text on which the unit resides.
3830
+ * @param {int} col The column of text on which the unit resides.
3831
+ * @namespace parserlib.css
3832
+ * @class PropertyValue
3833
+ * @extends parserlib.util.SyntaxUnit
3834
+ * @constructor
3835
+ */
3836
+ function PropertyValue(parts, line, col) {
3837
 
3838
+ SyntaxUnit.call(this, parts.join(" "), line, col, Parser.PROPERTY_VALUE_TYPE);
 
3839
 
3840
+ /**
3841
+ * The parts that make up the selector.
3842
+ * @type Array
3843
+ * @property parts
3844
+ */
3845
+ this.parts = parts;
3846
 
3847
+ }
3848
 
3849
+ PropertyValue.prototype = new SyntaxUnit();
3850
+ PropertyValue.prototype.constructor = PropertyValue;
 
 
 
 
 
 
3851
 
 
 
 
3852
 
3853
+ },{"../util/SyntaxUnit":26,"./Parser":6}],10:[function(require,module,exports){
3854
+ "use strict";
3855
 
3856
+ module.exports = PropertyValueIterator;
 
 
 
 
 
 
 
 
3857
 
3858
+ /**
3859
+ * A utility class that allows for easy iteration over the various parts of a
3860
+ * property value.
3861
+ * @param {parserlib.css.PropertyValue} value The property value to iterate over.
3862
+ * @namespace parserlib.css
3863
+ * @class PropertyValueIterator
3864
+ * @constructor
3865
+ */
3866
+ function PropertyValueIterator(value) {
3867
 
3868
+ /**
3869
+ * Iterator value
3870
+ * @type int
3871
+ * @property _i
3872
+ * @private
3873
+ */
3874
+ this._i = 0;
3875
 
3876
+ /**
3877
+ * The parts that make up the value.
3878
+ * @type Array
3879
+ * @property _parts
3880
+ * @private
3881
+ */
3882
+ this._parts = value.parts;
3883
 
3884
+ /**
3885
+ * Keeps track of bookmarks along the way.
3886
+ * @type Array
3887
+ * @property _marks
3888
+ * @private
3889
+ */
3890
+ this._marks = [];
3891
 
3892
+ /**
3893
+ * Holds the original property value.
3894
+ * @type parserlib.css.PropertyValue
3895
+ * @property value
3896
+ */
3897
+ this.value = value;
3898
 
3899
+ }
 
 
 
 
 
 
 
 
3900
 
3901
+ /**
3902
+ * Returns the total number of parts in the value.
3903
+ * @return {int} The total number of parts in the value.
3904
+ * @method count
3905
+ */
3906
+ PropertyValueIterator.prototype.count = function() {
3907
+ return this._parts.length;
3908
+ };
3909
 
3910
+ /**
3911
+ * Indicates if the iterator is positioned at the first item.
3912
+ * @return {Boolean} True if positioned at first item, false if not.
3913
+ * @method isFirst
3914
+ */
3915
+ PropertyValueIterator.prototype.isFirst = function() {
3916
+ return this._i === 0;
3917
+ };
3918
 
3919
+ /**
3920
+ * Indicates if there are more parts of the property value.
3921
+ * @return {Boolean} True if there are more parts, false if not.
3922
+ * @method hasNext
3923
+ */
3924
+ PropertyValueIterator.prototype.hasNext = function() {
3925
+ return this._i < this._parts.length;
3926
+ };
3927
 
3928
+ /**
3929
+ * Marks the current spot in the iteration so it can be restored to
3930
+ * later on.
3931
+ * @return {void}
3932
+ * @method mark
3933
+ */
3934
+ PropertyValueIterator.prototype.mark = function() {
3935
+ this._marks.push(this._i);
3936
+ };
3937
 
3938
+ /**
3939
+ * Returns the next part of the property value or null if there is no next
3940
+ * part. Does not move the internal counter forward.
3941
+ * @return {parserlib.css.PropertyValuePart} The next part of the property value or null if there is no next
3942
+ * part.
3943
+ * @method peek
3944
+ */
3945
+ PropertyValueIterator.prototype.peek = function(count) {
3946
+ return this.hasNext() ? this._parts[this._i + (count || 0)] : null;
3947
+ };
3948
 
3949
+ /**
3950
+ * Returns the next part of the property value or null if there is no next
3951
+ * part.
3952
+ * @return {parserlib.css.PropertyValuePart} The next part of the property value or null if there is no next
3953
+ * part.
3954
+ * @method next
3955
+ */
3956
+ PropertyValueIterator.prototype.next = function() {
3957
+ return this.hasNext() ? this._parts[this._i++] : null;
3958
+ };
3959
 
3960
+ /**
3961
+ * Returns the previous part of the property value or null if there is no
3962
+ * previous part.
3963
+ * @return {parserlib.css.PropertyValuePart} The previous part of the
3964
+ * property value or null if there is no previous part.
3965
+ * @method previous
3966
+ */
3967
+ PropertyValueIterator.prototype.previous = function() {
3968
+ return this._i > 0 ? this._parts[--this._i] : null;
3969
+ };
3970
 
3971
+ /**
3972
+ * Restores the last saved bookmark.
3973
+ * @return {void}
3974
+ * @method restore
3975
+ */
3976
+ PropertyValueIterator.prototype.restore = function() {
3977
+ if (this._marks.length) {
3978
+ this._i = this._marks.pop();
3979
+ }
3980
+ };
3981
 
3982
+ /**
3983
+ * Drops the last saved bookmark.
3984
+ * @return {void}
3985
+ * @method drop
3986
+ */
3987
+ PropertyValueIterator.prototype.drop = function() {
3988
+ this._marks.pop();
3989
+ };
3990
 
3991
+ },{}],11:[function(require,module,exports){
3992
+ "use strict";
 
3993
 
3994
+ module.exports = PropertyValuePart;
 
 
3995
 
3996
+ var SyntaxUnit = require("../util/SyntaxUnit");
 
 
 
 
 
 
 
 
 
 
 
3997
 
3998
+ var Colors = require("./Colors");
3999
+ var Parser = require("./Parser");
4000
+ var Tokens = require("./Tokens");
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4001
 
4002
+ /**
4003
+ * Represents a single part of a CSS property value, meaning that it represents
4004
+ * just one part of the data between ":" and ";".
4005
+ * @param {String} text The text representation of the unit.
4006
+ * @param {int} line The line of text on which the unit resides.
4007
+ * @param {int} col The column of text on which the unit resides.
4008
+ * @namespace parserlib.css
4009
+ * @class PropertyValuePart
4010
+ * @extends parserlib.util.SyntaxUnit
4011
+ * @constructor
4012
+ */
4013
+ function PropertyValuePart(text, line, col, optionalHint) {
4014
+ var hint = optionalHint || {};
4015
 
4016
+ SyntaxUnit.call(this, text, line, col, Parser.PROPERTY_VALUE_PART_TYPE);
4017
 
4018
+ /**
4019
+ * Indicates the type of value unit.
4020
+ * @type String
4021
+ * @property type
4022
+ */
4023
+ this.type = "unknown";
4024
 
4025
+ //figure out what type of data it is
4026
 
4027
+ var temp;
4028
 
4029
+ //it is a measurement?
4030
+ if (/^([+\-]?[\d\.]+)([a-z]+)$/i.test(text)) { //dimension
4031
+ this.type = "dimension";
4032
+ this.value = +RegExp.$1;
4033
+ this.units = RegExp.$2;
4034
 
4035
+ //try to narrow down
4036
+ switch (this.units.toLowerCase()) {
 
 
 
 
 
 
 
4037
 
4038
+ case "em":
4039
+ case "rem":
4040
+ case "ex":
4041
+ case "px":
4042
+ case "cm":
4043
+ case "mm":
4044
+ case "in":
4045
+ case "pt":
4046
+ case "pc":
4047
+ case "ch":
4048
+ case "vh":
4049
+ case "vw":
4050
+ case "vmax":
4051
+ case "vmin":
4052
+ this.type = "length";
4053
+ break;
4054
 
4055
+ case "fr":
4056
+ this.type = "grid";
4057
+ break;
4058
 
4059
+ case "deg":
4060
+ case "rad":
4061
+ case "grad":
4062
+ this.type = "angle";
4063
+ break;
4064
 
4065
+ case "ms":
4066
+ case "s":
4067
+ this.type = "time";
4068
+ break;
 
 
 
 
4069
 
4070
+ case "hz":
4071
+ case "khz":
4072
+ this.type = "frequency";
4073
+ break;
 
 
 
 
 
 
4074
 
4075
+ case "dpi":
4076
+ case "dpcm":
4077
+ this.type = "resolution";
4078
+ break;
 
4079
 
4080
+ //default
4081
 
4082
+ }
 
 
 
 
 
 
 
 
 
4083
 
4084
+ } else if (/^([+\-]?[\d\.]+)%$/i.test(text)) { //percentage
4085
+ this.type = "percentage";
4086
+ this.value = +RegExp.$1;
4087
+ } else if (/^([+\-]?\d+)$/i.test(text)) { //integer
4088
+ this.type = "integer";
4089
+ this.value = +RegExp.$1;
4090
+ } else if (/^([+\-]?[\d\.]+)$/i.test(text)) { //number
4091
+ this.type = "number";
4092
+ this.value = +RegExp.$1;
4093
 
4094
+ } else if (/^#([a-f0-9]{3,6})/i.test(text)) { //hexcolor
4095
+ this.type = "color";
4096
+ temp = RegExp.$1;
4097
+ if (temp.length === 3) {
4098
+ this.red = parseInt(temp.charAt(0)+temp.charAt(0), 16);
4099
+ this.green = parseInt(temp.charAt(1)+temp.charAt(1), 16);
4100
+ this.blue = parseInt(temp.charAt(2)+temp.charAt(2), 16);
4101
+ } else {
4102
+ this.red = parseInt(temp.substring(0, 2), 16);
4103
+ this.green = parseInt(temp.substring(2, 4), 16);
4104
+ this.blue = parseInt(temp.substring(4, 6), 16);
4105
+ }
4106
+ } else if (/^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/i.test(text)) { //rgb() color with absolute numbers
4107
+ this.type = "color";
4108
+ this.red = +RegExp.$1;
4109
+ this.green = +RegExp.$2;
4110
+ this.blue = +RegExp.$3;
4111
+ } else if (/^rgb\(\s*(\d+)%\s*,\s*(\d+)%\s*,\s*(\d+)%\s*\)/i.test(text)) { //rgb() color with percentages
4112
+ this.type = "color";
4113
+ this.red = +RegExp.$1 * 255 / 100;
4114
+ this.green = +RegExp.$2 * 255 / 100;
4115
+ this.blue = +RegExp.$3 * 255 / 100;
4116
+ } else if (/^rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*([\d\.]+)\s*\)/i.test(text)) { //rgba() color with absolute numbers
4117
+ this.type = "color";
4118
+ this.red = +RegExp.$1;
4119
+ this.green = +RegExp.$2;
4120
+ this.blue = +RegExp.$3;
4121
+ this.alpha = +RegExp.$4;
4122
+ } else if (/^rgba\(\s*(\d+)%\s*,\s*(\d+)%\s*,\s*(\d+)%\s*,\s*([\d\.]+)\s*\)/i.test(text)) { //rgba() color with percentages
4123
+ this.type = "color";
4124
+ this.red = +RegExp.$1 * 255 / 100;
4125
+ this.green = +RegExp.$2 * 255 / 100;
4126
+ this.blue = +RegExp.$3 * 255 / 100;
4127
+ this.alpha = +RegExp.$4;
4128
+ } else if (/^hsl\(\s*(\d+)\s*,\s*(\d+)%\s*,\s*(\d+)%\s*\)/i.test(text)) { //hsl()
4129
+ this.type = "color";
4130
+ this.hue = +RegExp.$1;
4131
+ this.saturation = +RegExp.$2 / 100;
4132
+ this.lightness = +RegExp.$3 / 100;
4133
+ } else if (/^hsla\(\s*(\d+)\s*,\s*(\d+)%\s*,\s*(\d+)%\s*,\s*([\d\.]+)\s*\)/i.test(text)) { //hsla() color with percentages
4134
+ this.type = "color";
4135
+ this.hue = +RegExp.$1;
4136
+ this.saturation = +RegExp.$2 / 100;
4137
+ this.lightness = +RegExp.$3 / 100;
4138
+ this.alpha = +RegExp.$4;
4139
+ } else if (/^url\(("([^\\"]|\\.)*")\)/i.test(text)) { //URI
4140
+ // generated by TokenStream.readURI, so always double-quoted.
4141
+ this.type = "uri";
4142
+ this.uri = PropertyValuePart.parseString(RegExp.$1);
4143
+ } else if (/^([^\(]+)\(/i.test(text)) {
4144
+ this.type = "function";
4145
+ this.name = RegExp.$1;
4146
+ this.value = text;
4147
+ } else if (/^"([^\n\r\f\\"]|\\\r\n|\\[^\r0-9a-f]|\\[0-9a-f]{1,6}(\r\n|[ \n\r\t\f])?)*"/i.test(text)) { //double-quoted string
4148
+ this.type = "string";
4149
+ this.value = PropertyValuePart.parseString(text);
4150
+ } else if (/^'([^\n\r\f\\']|\\\r\n|\\[^\r0-9a-f]|\\[0-9a-f]{1,6}(\r\n|[ \n\r\t\f])?)*'/i.test(text)) { //single-quoted string
4151
+ this.type = "string";
4152
+ this.value = PropertyValuePart.parseString(text);
4153
+ } else if (Colors[text.toLowerCase()]) { //named color
4154
+ this.type = "color";
4155
+ temp = Colors[text.toLowerCase()].substring(1);
4156
+ this.red = parseInt(temp.substring(0, 2), 16);
4157
+ this.green = parseInt(temp.substring(2, 4), 16);
4158
+ this.blue = parseInt(temp.substring(4, 6), 16);
4159
+ } else if (/^[,\/]$/.test(text)) {
4160
+ this.type = "operator";
4161
+ this.value = text;
4162
+ } else if (/^-?[a-z_\u00A0-\uFFFF][a-z0-9\-_\u00A0-\uFFFF]*$/i.test(text)) {
4163
+ this.type = "identifier";
4164
+ this.value = text;
4165
+ }
4166
+
4167
+ // There can be ambiguity with escape sequences in identifiers, as
4168
+ // well as with "color" parts which are also "identifiers", so record
4169
+ // an explicit hint when the token generating this PropertyValuePart
4170
+ // was an identifier.
4171
+ this.wasIdent = Boolean(hint.ident);
4172
 
4173
+ }
 
4174
 
4175
+ PropertyValuePart.prototype = new SyntaxUnit();
4176
+ PropertyValuePart.prototype.constructor = PropertyValuePart;
4177
 
4178
+ /**
4179
+ * Helper method to parse a CSS string.
4180
+ */
4181
+ PropertyValuePart.parseString = function(str) {
4182
+ str = str.slice(1, -1); // Strip surrounding single/double quotes
4183
+ var replacer = function(match, esc) {
4184
+ if (/^(\n|\r\n|\r|\f)$/.test(esc)) {
4185
+ return "";
4186
+ }
4187
+ var m = /^[0-9a-f]{1,6}/i.exec(esc);
4188
+ if (m) {
4189
+ var codePoint = parseInt(m[0], 16);
4190
+ if (String.fromCodePoint) {
4191
+ return String.fromCodePoint(codePoint);
4192
+ } else {
4193
+ // XXX No support for surrogates on old JavaScript engines.
4194
+ return String.fromCharCode(codePoint);
4195
+ }
4196
+ }
4197
+ return esc;
4198
+ };
4199
+ return str.replace(/\\(\r\n|[^\r0-9a-f]|[0-9a-f]{1,6}(\r\n|[ \n\r\t\f])?)/ig,
4200
+ replacer);
4201
+ };
4202
 
4203
+ /**
4204
+ * Helper method to serialize a CSS string.
4205
+ */
4206
+ PropertyValuePart.serializeString = function(value) {
4207
+ var replacer = function(match, c) {
4208
+ if (c === "\"") {
4209
+ return "\\" + c;
4210
+ }
4211
+ var cp = String.codePointAt ? String.codePointAt(0) :
4212
+ // We only escape non-surrogate chars, so using charCodeAt
4213
+ // is harmless here.
4214
+ String.charCodeAt(0);
4215
+ return "\\" + cp.toString(16) + " ";
4216
+ };
4217
+ return "\"" + value.replace(/["\r\n\f]/g, replacer) + "\"";
4218
+ };
4219
 
4220
+ /**
4221
+ * Create a new syntax unit based solely on the given token.
4222
+ * Convenience method for creating a new syntax unit when
4223
+ * it represents a single token instead of multiple.
4224
+ * @param {Object} token The token object to represent.
4225
+ * @return {parserlib.css.PropertyValuePart} The object representing the token.
4226
+ * @static
4227
+ * @method fromToken
4228
+ */
4229
+ PropertyValuePart.fromToken = function(token) {
4230
+ var part = new PropertyValuePart(token.value, token.startLine, token.startCol, {
4231
+ // Tokens can have escaped characters that would fool the type
4232
+ // identification in the PropertyValuePart constructor, so pass
4233
+ // in a hint if this was an identifier.
4234
+ ident: token.type === Tokens.IDENT
4235
+ });
4236
+ return part;
4237
+ };
4238
 
4239
+ },{"../util/SyntaxUnit":26,"./Colors":1,"./Parser":6,"./Tokens":18}],12:[function(require,module,exports){
4240
+ "use strict";
 
4241
 
4242
+ var Pseudos = module.exports = {
4243
+ __proto__: null,
4244
+ ":first-letter": 1,
4245
+ ":first-line": 1,
4246
+ ":before": 1,
4247
+ ":after": 1
4248
+ };
4249
 
4250
+ Pseudos.ELEMENT = 1;
4251
+ Pseudos.CLASS = 2;
 
 
4252
 
4253
+ Pseudos.isElement = function(pseudo) {
4254
+ return pseudo.indexOf("::") === 0 || Pseudos[pseudo.toLowerCase()] === Pseudos.ELEMENT;
4255
+ };
4256
 
4257
+ },{}],13:[function(require,module,exports){
4258
+ "use strict";
4259
 
4260
+ module.exports = Selector;
 
 
4261
 
4262
+ var SyntaxUnit = require("../util/SyntaxUnit");
 
 
 
 
 
 
4263
 
4264
+ var Parser = require("./Parser");
4265
+ var Specificity = require("./Specificity");
4266
 
4267
+ /**
4268
+ * Represents an entire single selector, including all parts but not
4269
+ * including multiple selectors (those separated by commas).
4270
+ * @namespace parserlib.css
4271
+ * @class Selector
4272
+ * @extends parserlib.util.SyntaxUnit
4273
+ * @constructor
4274
+ * @param {Array} parts Array of selectors parts making up this selector.
4275
+ * @param {int} line The line of text on which the unit resides.
4276
+ * @param {int} col The column of text on which the unit resides.
4277
+ */
4278
+ function Selector(parts, line, col) {
4279
 
4280
+ SyntaxUnit.call(this, parts.join(" "), line, col, Parser.SELECTOR_TYPE);
 
4281
 
4282
+ /**
4283
+ * The parts that make up the selector.
4284
+ * @type Array
4285
+ * @property parts
4286
+ */
4287
+ this.parts = parts;
4288
 
4289
+ /**
4290
+ * The specificity of the selector.
4291
+ * @type parserlib.css.Specificity
4292
+ * @property specificity
4293
+ */
4294
+ this.specificity = Specificity.calculate(this);
4295
 
4296
+ }
 
 
 
 
 
 
 
 
4297
 
4298
+ Selector.prototype = new SyntaxUnit();
4299
+ Selector.prototype.constructor = Selector;
4300
 
 
4301
 
4302
+ },{"../util/SyntaxUnit":26,"./Parser":6,"./Specificity":16}],14:[function(require,module,exports){
4303
+ "use strict";
4304
 
4305
+ module.exports = SelectorPart;
 
4306
 
4307
+ var SyntaxUnit = require("../util/SyntaxUnit");
 
 
4308
 
4309
+ var Parser = require("./Parser");
 
 
 
 
 
 
 
4310
 
4311
+ /**
4312
+ * Represents a single part of a selector string, meaning a single set of
4313
+ * element name and modifiers. This does not include combinators such as
4314
+ * spaces, +, >, etc.
4315
+ * @namespace parserlib.css
4316
+ * @class SelectorPart
4317
+ * @extends parserlib.util.SyntaxUnit
4318
+ * @constructor
4319
+ * @param {String} elementName The element name in the selector or null
4320
+ * if there is no element name.
4321
+ * @param {Array} modifiers Array of individual modifiers for the element.
4322
+ * May be empty if there are none.
4323
+ * @param {String} text The text representation of the unit.
4324
+ * @param {int} line The line of text on which the unit resides.
4325
+ * @param {int} col The column of text on which the unit resides.
4326
+ */
4327
+ function SelectorPart(elementName, modifiers, text, line, col) {
4328
 
4329
+ SyntaxUnit.call(this, text, line, col, Parser.SELECTOR_PART_TYPE);
 
4330
 
4331
+ /**
4332
+ * The tag name of the element to which this part
4333
+ * of the selector affects.
4334
+ * @type String
4335
+ * @property elementName
4336
+ */
4337
+ this.elementName = elementName;
4338
 
4339
+ /**
4340
+ * The parts that come after the element name, such as class names, IDs,
4341
+ * pseudo classes/elements, etc.
4342
+ * @type Array
4343
+ * @property modifiers
4344
+ */
4345
+ this.modifiers = modifiers;
4346
 
4347
+ }
 
4348
 
4349
+ SelectorPart.prototype = new SyntaxUnit();
4350
+ SelectorPart.prototype.constructor = SelectorPart;
 
4351
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4352
 
4353
+ },{"../util/SyntaxUnit":26,"./Parser":6}],15:[function(require,module,exports){
4354
+ "use strict";
 
 
 
 
4355
 
4356
+ module.exports = SelectorSubPart;
 
4357
 
4358
+ var SyntaxUnit = require("../util/SyntaxUnit");
4359
 
4360
+ var Parser = require("./Parser");
 
 
 
 
 
4361
 
4362
+ /**
4363
+ * Represents a selector modifier string, meaning a class name, element name,
4364
+ * element ID, pseudo rule, etc.
4365
+ * @namespace parserlib.css
4366
+ * @class SelectorSubPart
4367
+ * @extends parserlib.util.SyntaxUnit
4368
+ * @constructor
4369
+ * @param {String} text The text representation of the unit.
4370
+ * @param {String} type The type of selector modifier.
4371
+ * @param {int} line The line of text on which the unit resides.
4372
+ * @param {int} col The column of text on which the unit resides.
4373
+ */
4374
+ function SelectorSubPart(text, type, line, col) {
4375
 
4376
+ SyntaxUnit.call(this, text, line, col, Parser.SELECTOR_SUB_PART_TYPE);
 
 
 
 
 
 
 
 
 
 
4377
 
4378
+ /**
4379
+ * The type of modifier.
4380
+ * @type String
4381
+ * @property type
4382
+ */
4383
+ this.type = type;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4384
 
4385
+ /**
4386
+ * Some subparts have arguments, this represents them.
4387
+ * @type Array
4388
+ * @property args
4389
+ */
4390
+ this.args = [];
4391
 
4392
+ }
 
 
 
 
 
 
4393
 
4394
+ SelectorSubPart.prototype = new SyntaxUnit();
4395
+ SelectorSubPart.prototype.constructor = SelectorSubPart;
 
 
 
 
 
 
 
4396
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4397
 
4398
+ },{"../util/SyntaxUnit":26,"./Parser":6}],16:[function(require,module,exports){
4399
+ "use strict";
 
 
4400
 
4401
+ module.exports = Specificity;
 
 
 
 
 
 
4402
 
4403
+ var Pseudos = require("./Pseudos");
4404
+ var SelectorPart = require("./SelectorPart");
4405
 
4406
+ /**
4407
+ * Represents a selector's specificity.
4408
+ * @namespace parserlib.css
4409
+ * @class Specificity
4410
+ * @constructor
4411
+ * @param {int} a Should be 1 for inline styles, zero for stylesheet styles
4412
+ * @param {int} b Number of ID selectors
4413
+ * @param {int} c Number of classes and pseudo classes
4414
+ * @param {int} d Number of element names and pseudo elements
4415
+ */
4416
+ function Specificity(a, b, c, d) {
4417
+ this.a = a;
4418
+ this.b = b;
4419
+ this.c = c;
4420
+ this.d = d;
4421
+ }
4422
 
4423
+ Specificity.prototype = {
4424
+ constructor: Specificity,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4425
 
4426
+ /**
4427
+ * Compare this specificity to another.
4428
+ * @param {Specificity} other The other specificity to compare to.
4429
+ * @return {int} -1 if the other specificity is larger, 1 if smaller, 0 if equal.
4430
+ * @method compare
4431
+ */
4432
+ compare: function(other) {
4433
+ var comps = ["a", "b", "c", "d"],
4434
+ i, len;
4435
 
4436
+ for (i=0, len=comps.length; i < len; i++) {
4437
+ if (this[comps[i]] < other[comps[i]]) {
4438
+ return -1;
4439
+ } else if (this[comps[i]] > other[comps[i]]) {
4440
+ return 1;
 
 
4441
  }
 
4442
  }
4443
 
4444
+ return 0;
 
 
 
 
 
 
 
4445
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4446
 
4447
+ /**
4448
+ * Creates a numeric value for the specificity.
4449
+ * @return {int} The numeric value for the specificity.
4450
+ * @method valueOf
4451
+ */
4452
+ valueOf: function() {
4453
+ return (this.a * 1000) + (this.b * 100) + (this.c * 10) + this.d;
 
4454
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4455
 
4456
+ /**
4457
+ * Returns a string representation for specificity.
4458
+ * @return {String} The string representation of specificity.
4459
+ * @method toString
4460
+ */
4461
+ toString: function() {
4462
+ return this.a + "," + this.b + "," + this.c + "," + this.d;
4463
+ }
 
 
 
 
 
 
4464
 
4465
+ };
 
 
 
 
 
 
 
 
 
 
 
 
 
4466
 
4467
+ /**
4468
+ * Calculates the specificity of the given selector.
4469
+ * @param {parserlib.css.Selector} The selector to calculate specificity for.
4470
+ * @return {parserlib.css.Specificity} The specificity of the selector.
4471
+ * @static
4472
+ * @method calculate
4473
+ */
4474
+ Specificity.calculate = function(selector) {
 
4475
 
4476
+ var i, len,
4477
+ part,
4478
+ b=0, c=0, d=0;
 
 
 
4479
 
4480
+ function updateValues(part) {
 
 
 
 
 
 
 
 
 
 
 
 
4481
 
4482
+ var i, j, len, num,
4483
+ elementName = part.elementName ? part.elementName.text : "",
4484
+ modifier;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4485
 
4486
+ if (elementName && elementName.charAt(elementName.length-1) !== "*") {
4487
+ d++;
4488
+ }
 
 
 
4489
 
4490
+ for (i=0, len=part.modifiers.length; i < len; i++) {
4491
+ modifier = part.modifiers[i];
4492
+ switch (modifier.type) {
4493
+ case "class":
4494
+ case "attribute":
4495
+ c++;
4496
+ break;
 
 
 
 
 
4497
 
4498
+ case "id":
4499
+ b++;
4500
+ break;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4501
 
4502
+ case "pseudo":
4503
+ if (Pseudos.isElement(modifier.text)) {
4504
+ d++;
4505
+ } else {
4506
+ c++;
4507
+ }
4508
+ break;
4509
 
4510
+ case "not":
4511
+ for (j=0, num=modifier.args.length; j < num; j++) {
4512
+ updateValues(modifier.args[j]);
4513
+ }
4514
+ }
4515
+ }
4516
+ }
 
 
 
 
 
 
 
4517
 
4518
+ for (i=0, len=selector.parts.length; i < len; i++) {
4519
+ part = selector.parts[i];
 
 
 
 
 
 
 
 
4520
 
4521
+ if (part instanceof SelectorPart) {
4522
+ updateValues(part);
4523
+ }
4524
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4525
 
4526
+ return new Specificity(0, b, c, d);
4527
+ };
 
 
4528
 
4529
+ },{"./Pseudos":12,"./SelectorPart":14}],17:[function(require,module,exports){
4530
+ "use strict";
 
 
 
 
 
 
 
 
 
 
4531
 
4532
+ module.exports = TokenStream;
 
 
 
 
 
 
 
4533
 
4534
+ var TokenStreamBase = require("../util/TokenStreamBase");
 
 
 
4535
 
4536
+ var PropertyValuePart = require("./PropertyValuePart");
4537
+ var Tokens = require("./Tokens");
 
 
 
 
 
 
 
 
 
 
 
4538
 
4539
+ var h = /^[0-9a-fA-F]$/,
4540
+ nonascii = /^[\u00A0-\uFFFF]$/,
4541
+ nl = /\n|\r\n|\r|\f/,
4542
+ whitespace = /\u0009|\u000a|\u000c|\u000d|\u0020/;
4543
+
4544
+ //-----------------------------------------------------------------------------
4545
+ // Helper functions
4546
+ //-----------------------------------------------------------------------------
4547
 
 
 
 
 
 
 
4548
 
4549
+ function isHexDigit(c) {
4550
+ return c !== null && h.test(c);
4551
  }
4552
 
4553
+ function isDigit(c) {
4554
+ return c !== null && /\d/.test(c);
4555
+ }
 
 
4556
 
4557
+ function isWhitespace(c) {
4558
+ return c !== null && whitespace.test(c);
4559
+ }
 
 
 
 
 
 
 
 
 
 
 
4560
 
4561
+ function isNewLine(c) {
4562
+ return c !== null && nl.test(c);
4563
+ }
4564
 
4565
+ function isNameStart(c) {
4566
+ return c !== null && /[a-z_\u00A0-\uFFFF\\]/i.test(c);
4567
+ }
 
 
 
4568
 
4569
+ function isNameChar(c) {
4570
+ return c !== null && (isNameStart(c) || /[0-9\-\\]/.test(c));
4571
  }
4572
 
4573
+ function isIdentStart(c) {
4574
+ return c !== null && (isNameStart(c) || /\-\\/.test(c));
4575
+ }
4576
+
4577
+ function mix(receiver, supplier) {
4578
+ for (var prop in supplier) {
4579
+ if (Object.prototype.hasOwnProperty.call(supplier, prop)) {
4580
+ receiver[prop] = supplier[prop];
4581
+ }
4582
+ }
4583
+ return receiver;
4584
+ }
4585
+
4586
+ //-----------------------------------------------------------------------------
4587
+ // CSS Token Stream
4588
+ //-----------------------------------------------------------------------------
4589
 
4590
 
 
4591
  /**
4592
+ * A token stream that produces CSS tokens.
4593
+ * @param {String|Reader} input The source of text to tokenize.
 
 
 
4594
  * @constructor
4595
+ * @class TokenStream
4596
+ * @namespace parserlib.css
4597
  */
4598
+ function TokenStream(input) {
4599
+ TokenStreamBase.call(this, input, Tokens);
4600
+ }
4601
 
4602
+ TokenStream.prototype = mix(new TokenStreamBase(), {
 
 
 
 
 
 
4603
 
4604
  /**
4605
+ * Overrides the TokenStreamBase method of the same name
4606
+ * to produce CSS tokens.
4607
+ * @return {Object} A token object representing the next token.
4608
+ * @method _getToken
4609
  * @private
4610
  */
4611
+ _getToken: function() {
4612
 
4613
+ var c,
4614
+ reader = this._reader,
4615
+ token = null,
4616
+ startLine = reader.getLine(),
4617
+ startCol = reader.getCol();
 
 
4618
 
4619
+ c = reader.read();
 
 
 
 
 
4620
 
 
4621
 
4622
+ while (c) {
4623
+ switch (c) {
 
 
 
 
 
 
4624
 
4625
+ /*
4626
+ * Potential tokens:
4627
+ * - COMMENT
4628
+ * - SLASH
4629
+ * - CHAR
4630
+ */
4631
+ case "/":
4632
+
4633
+ if (reader.peek() === "*") {
4634
+ token = this.commentToken(c, startLine, startCol);
4635
+ } else {
4636
+ token = this.charToken(c, startLine, startCol);
4637
+ }
4638
+ break;
4639
+
4640
+ /*
4641
+ * Potential tokens:
4642
+ * - DASHMATCH
4643
+ * - INCLUDES
4644
+ * - PREFIXMATCH
4645
+ * - SUFFIXMATCH
4646
+ * - SUBSTRINGMATCH
4647
+ * - CHAR
4648
+ */
4649
+ case "|":
4650
+ case "~":
4651
+ case "^":
4652
+ case "$":
4653
+ case "*":
4654
+ if (reader.peek() === "=") {
4655
+ token = this.comparisonToken(c, startLine, startCol);
4656
+ } else {
4657
+ token = this.charToken(c, startLine, startCol);
4658
+ }
4659
+ break;
4660
+
4661
+ /*
4662
+ * Potential tokens:
4663
+ * - STRING
4664
+ * - INVALID
4665
+ */
4666
+ case "\"":
4667
+ case "'":
4668
+ token = this.stringToken(c, startLine, startCol);
4669
+ break;
4670
+
4671
+ /*
4672
+ * Potential tokens:
4673
+ * - HASH
4674
+ * - CHAR
4675
+ */
4676
+ case "#":
4677
+ if (isNameChar(reader.peek())) {
4678
+ token = this.hashToken(c, startLine, startCol);
4679
+ } else {
4680
+ token = this.charToken(c, startLine, startCol);
4681
+ }
4682
+ break;
4683
+
4684
+ /*
4685
+ * Potential tokens:
4686
+ * - DOT
4687
+ * - NUMBER
4688
+ * - DIMENSION
4689
+ * - PERCENTAGE
4690
+ */
4691
+ case ".":
4692
+ if (isDigit(reader.peek())) {
4693
+ token = this.numberToken(c, startLine, startCol);
4694
+ } else {
4695
+ token = this.charToken(c, startLine, startCol);
4696
+ }
4697
+ break;
4698
+
4699
+ /*
4700
+ * Potential tokens:
4701
+ * - CDC
4702
+ * - MINUS
4703
+ * - NUMBER
4704
+ * - DIMENSION
4705
+ * - PERCENTAGE
4706
+ */
4707
+ case "-":
4708
+ if (reader.peek() === "-") { //could be closing HTML-style comment
4709
+ token = this.htmlCommentEndToken(c, startLine, startCol);
4710
+ } else if (isNameStart(reader.peek())) {
4711
+ token = this.identOrFunctionToken(c, startLine, startCol);
4712
+ } else {
4713
+ token = this.charToken(c, startLine, startCol);
4714
+ }
4715
+ break;
4716
 
4717
+ /*
4718
+ * Potential tokens:
4719
+ * - IMPORTANT_SYM
4720
+ * - CHAR
4721
+ */
4722
+ case "!":
4723
+ token = this.importantToken(c, startLine, startCol);
4724
+ break;
4725
 
4726
+ /*
4727
+ * Any at-keyword or CHAR
4728
+ */
4729
+ case "@":
4730
+ token = this.atRuleToken(c, startLine, startCol);
4731
+ break;
 
 
 
4732
 
4733
+ /*
4734
+ * Potential tokens:
4735
+ * - NOT
4736
+ * - CHAR
4737
+ */
4738
+ case ":":
4739
+ token = this.notToken(c, startLine, startCol);
4740
+ break;
 
 
4741
 
4742
+ /*
4743
+ * Potential tokens:
4744
+ * - CDO
4745
+ * - CHAR
4746
+ */
4747
+ case "<":
4748
+ token = this.htmlCommentStartToken(c, startLine, startCol);
4749
+ break;
 
 
4750
 
4751
+ /*
4752
+ * Potential tokens:
4753
+ * - IDENT
4754
+ * - CHAR
4755
+ */
4756
+ case "\\":
4757
+ if (/[^\r\n\f]/.test(reader.peek())) {
4758
+ token = this.identOrFunctionToken(this.readEscape(c, true), startLine, startCol);
4759
+ } else {
4760
+ token = this.charToken(c, startLine, startCol);
4761
+ }
4762
+ break;
4763
 
4764
+ /*
4765
+ * Potential tokens:
4766
+ * - UNICODE_RANGE
4767
+ * - URL
4768
+ * - CHAR
4769
+ */
4770
+ case "U":
4771
+ case "u":
4772
+ if (reader.peek() === "+") {
4773
+ token = this.unicodeRangeToken(c, startLine, startCol);
4774
+ break;
4775
+ }
4776
+ /* falls through */
4777
+ default:
4778
 
4779
+ /*
4780
+ * Potential tokens:
4781
+ * - NUMBER
4782
+ * - DIMENSION
4783
+ * - LENGTH
4784
+ * - FREQ
4785
+ * - TIME
4786
+ * - EMS
4787
+ * - EXS
4788
+ * - ANGLE
4789
+ */
4790
+ if (isDigit(c)) {
4791
+ token = this.numberToken(c, startLine, startCol);
4792
+ } else
4793
 
4794
+ /*
4795
+ * Potential tokens:
4796
+ * - S
4797
+ */
4798
+ if (isWhitespace(c)) {
4799
+ token = this.whitespaceToken(c, startLine, startCol);
4800
+ } else
 
 
 
 
 
 
4801
 
4802
+ /*
4803
+ * Potential tokens:
4804
+ * - IDENT
4805
+ */
4806
+ if (isIdentStart(c)) {
4807
+ token = this.identOrFunctionToken(c, startLine, startCol);
4808
+ } else {
4809
+ /*
4810
+ * Potential tokens:
4811
+ * - CHAR
4812
+ * - PLUS
4813
+ */
4814
+ token = this.charToken(c, startLine, startCol);
4815
+ }
4816
 
4817
+ }
 
 
 
 
 
4818
 
4819
+ //make sure this token is wanted
4820
+ //TODO: check channel
4821
+ break;
4822
+ }
4823
 
4824
+ if (!token && c === null) {
4825
+ token = this.createToken(Tokens.EOF, null, startLine, startCol);
4826
+ }
4827
 
4828
+ return token;
4829
+ },
 
 
 
4830
 
4831
+ //-------------------------------------------------------------------------
4832
+ // Methods to create tokens
4833
+ //-------------------------------------------------------------------------
4834
 
4835
+ /**
4836
+ * Produces a token based on available data and the current
4837
+ * reader position information. This method is called by other
4838
+ * private methods to create tokens and is never called directly.
4839
+ * @param {int} tt The token type.
4840
+ * @param {String} value The text value of the token.
4841
+ * @param {int} startLine The beginning line for the character.
4842
+ * @param {int} startCol The beginning column for the character.
4843
+ * @param {Object} options (Optional) Specifies a channel property
4844
+ * to indicate that a different channel should be scanned
4845
+ * and/or a hide property indicating that the token should
4846
+ * be hidden.
4847
+ * @return {Object} A token object.
4848
+ * @method createToken
4849
+ */
4850
+ createToken: function(tt, value, startLine, startCol, options) {
4851
+ var reader = this._reader;
4852
+ options = options || {};
4853
 
4854
+ return {
4855
+ value: value,
4856
+ type: tt,
4857
+ channel: options.channel,
4858
+ endChar: options.endChar,
4859
+ hide: options.hide || false,
4860
+ startLine: startLine,
4861
+ startCol: startCol,
4862
+ endLine: reader.getLine(),
4863
+ endCol: reader.getCol()
4864
+ };
4865
+ },
4866
 
4867
+ //-------------------------------------------------------------------------
4868
+ // Methods to create specific tokens
4869
+ //-------------------------------------------------------------------------
 
4870
 
4871
+ /**
4872
+ * Produces a token for any at-rule. If the at-rule is unknown, then
4873
+ * the token is for a single "@" character.
4874
+ * @param {String} first The first character for the token.
4875
+ * @param {int} startLine The beginning line for the character.
4876
+ * @param {int} startCol The beginning column for the character.
4877
+ * @return {Object} A token object.
4878
+ * @method atRuleToken
4879
+ */
4880
+ atRuleToken: function(first, startLine, startCol) {
4881
+ var rule = first,
4882
+ reader = this._reader,
4883
+ tt = Tokens.CHAR,
4884
+ ident;
4885
 
4886
+ /*
4887
+ * First, mark where we are. There are only four @ rules,
4888
+ * so anything else is really just an invalid token.
4889
+ * Basically, if this doesn't match one of the known @
4890
+ * rules, just return '@' as an unknown token and allow
4891
+ * parsing to continue after that point.
4892
+ */
4893
+ reader.mark();
4894
 
4895
+ //try to find the at-keyword
4896
+ ident = this.readName();
4897
+ rule = first + ident;
4898
+ tt = Tokens.type(rule.toLowerCase());
4899
 
4900
+ //if it's not valid, use the first character only and reset the reader
4901
+ if (tt === Tokens.CHAR || tt === Tokens.UNKNOWN) {
4902
+ if (rule.length > 1) {
4903
+ tt = Tokens.UNKNOWN_SYM;
4904
+ } else {
4905
+ tt = Tokens.CHAR;
4906
+ rule = first;
4907
+ reader.reset();
4908
+ }
4909
  }
4910
 
4911
+ return this.createToken(tt, rule, startLine, startCol);
4912
+ },
 
 
 
 
 
 
 
 
 
 
4913
 
4914
+ /**
4915
+ * Produces a character token based on the given character
4916
+ * and location in the stream. If there's a special (non-standard)
4917
+ * token name, this is used; otherwise CHAR is used.
4918
+ * @param {String} c The character for the token.
4919
+ * @param {int} startLine The beginning line for the character.
4920
+ * @param {int} startCol The beginning column for the character.
4921
+ * @return {Object} A token object.
4922
+ * @method charToken
4923
+ */
4924
+ charToken: function(c, startLine, startCol) {
4925
+ var tt = Tokens.type(c);
4926
+ var opts = {};
4927
+
4928
+ if (tt === -1) {
4929
+ tt = Tokens.CHAR;
4930
  } else {
4931
+ opts.endChar = Tokens[tt].endChar;
 
 
4932
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4933
 
4934
+ return this.createToken(tt, c, startLine, startCol, opts);
4935
+ },
4936
 
4937
+ /**
4938
+ * Produces a character token based on the given character
4939
+ * and location in the stream. If there's a special (non-standard)
4940
+ * token name, this is used; otherwise CHAR is used.
4941
+ * @param {String} first The first character for the token.
4942
+ * @param {int} startLine The beginning line for the character.
4943
+ * @param {int} startCol The beginning column for the character.
4944
+ * @return {Object} A token object.
4945
+ * @method commentToken
4946
+ */
4947
+ commentToken: function(first, startLine, startCol) {
4948
+ var comment = this.readComment(first);
4949
 
4950
+ return this.createToken(Tokens.COMMENT, comment, startLine, startCol);
4951
+ },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4952
 
4953
+ /**
4954
+ * Produces a comparison token based on the given character
4955
+ * and location in the stream. The next character must be
4956
+ * read and is already known to be an equals sign.
4957
+ * @param {String} c The character for the token.
4958
+ * @param {int} startLine The beginning line for the character.
4959
+ * @param {int} startCol The beginning column for the character.
4960
+ * @return {Object} A token object.
4961
+ * @method comparisonToken
4962
+ */
4963
+ comparisonToken: function(c, startLine, startCol) {
4964
+ var reader = this._reader,
4965
+ comparison = c + reader.read(),
4966
+ tt = Tokens.type(comparison) || Tokens.CHAR;
4967
 
4968
+ return this.createToken(tt, comparison, startLine, startCol);
4969
+ },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4970
 
4971
+ /**
4972
+ * Produces a hash token based on the specified information. The
4973
+ * first character provided is the pound sign (#) and then this
4974
+ * method reads a name afterward.
4975
+ * @param {String} first The first character (#) in the hash name.
4976
+ * @param {int} startLine The beginning line for the character.
4977
+ * @param {int} startCol The beginning column for the character.
4978
+ * @return {Object} A token object.
4979
+ * @method hashToken
4980
+ */
4981
+ hashToken: function(first, startLine, startCol) {
4982
+ var name = this.readName(first);
4983
+
4984
+ return this.createToken(Tokens.HASH, name, startLine, startCol);
4985
+ },
4986
 
4987
  /**
4988
+ * Produces a CDO or CHAR token based on the specified information. The
4989
+ * first character is provided and the rest is read by the function to determine
4990
+ * the correct token to create.
4991
+ * @param {String} first The first character in the token.
4992
+ * @param {int} startLine The beginning line for the character.
4993
+ * @param {int} startCol The beginning column for the character.
4994
+ * @return {Object} A token object.
4995
+ * @method htmlCommentStartToken
4996
  */
4997
+ htmlCommentStartToken: function(first, startLine, startCol) {
4998
+ var reader = this._reader,
4999
+ text = first;
5000
+
5001
+ reader.mark();
5002
+ text += reader.readCount(3);
5003
+
5004
+ if (text === "<!--") {
5005
+ return this.createToken(Tokens.CDO, text, startLine, startCol);
5006
+ } else {
5007
+ reader.reset();
5008
+ return this.charToken(first, startLine, startCol);
5009
+ }
5010
+ },
5011
 
5012
  /**
5013
+ * Produces a CDC or CHAR token based on the specified information. The
5014
+ * first character is provided and the rest is read by the function to determine
5015
+ * the correct token to create.
5016
+ * @param {String} first The first character in the token.
5017
+ * @param {int} startLine The beginning line for the character.
5018
+ * @param {int} startCol The beginning column for the character.
5019
+ * @return {Object} A token object.
5020
+ * @method htmlCommentEndToken
5021
  */
5022
+ htmlCommentEndToken: function(first, startLine, startCol) {
5023
+ var reader = this._reader,
5024
+ text = first;
5025
 
5026
+ reader.mark();
5027
+ text += reader.readCount(2);
5028
 
5029
+ if (text === "-->") {
5030
+ return this.createToken(Tokens.CDC, text, startLine, startCol);
5031
+ } else {
5032
+ reader.reset();
5033
+ return this.charToken(first, startLine, startCol);
5034
+ }
5035
+ },
5036
 
5037
+ /**
5038
+ * Produces an IDENT or FUNCTION token based on the specified information. The
5039
+ * first character is provided and the rest is read by the function to determine
5040
+ * the correct token to create.
5041
+ * @param {String} first The first character in the identifier.
5042
+ * @param {int} startLine The beginning line for the character.
5043
+ * @param {int} startCol The beginning column for the character.
5044
+ * @return {Object} A token object.
5045
+ * @method identOrFunctionToken
5046
+ */
5047
+ identOrFunctionToken: function(first, startLine, startCol) {
5048
+ var reader = this._reader,
5049
+ ident = this.readName(first),
5050
+ tt = Tokens.IDENT,
5051
+ uriFns = ["url(", "url-prefix(", "domain("],
5052
+ uri;
5053
 
5054
+ //if there's a left paren immediately after, it's a URI or function
5055
+ if (reader.peek() === "(") {
5056
+ ident += reader.read();
5057
+ if (uriFns.indexOf(ident.toLowerCase()) > -1) {
5058
+ reader.mark();
5059
+ uri = this.readURI(ident);
5060
+ if (uri === null) {
5061
+ //didn't find a valid URL or there's no closing paren
5062
+ reader.reset();
5063
+ tt = Tokens.FUNCTION;
5064
+ } else {
5065
+ tt = Tokens.URI;
5066
+ ident = uri;
5067
+ }
5068
+ } else {
5069
+ tt = Tokens.FUNCTION;
5070
+ }
5071
+ } else if (reader.peek() === ":") { //might be an IE function
5072
+
5073
+ //IE-specific functions always being with progid:
5074
+ if (ident.toLowerCase() === "progid") {
5075
+ ident += reader.readTo("(");
5076
+ tt = Tokens.IE_FUNCTION;
5077
+ }
5078
+ }
5079
+
5080
+ return this.createToken(tt, ident, startLine, startCol);
5081
+ },
5082
+
5083
+ /**
5084
+ * Produces an IMPORTANT_SYM or CHAR token based on the specified information. The
5085
+ * first character is provided and the rest is read by the function to determine
5086
+ * the correct token to create.
5087
+ * @param {String} first The first character in the token.
5088
+ * @param {int} startLine The beginning line for the character.
5089
+ * @param {int} startCol The beginning column for the character.
5090
+ * @return {Object} A token object.
5091
+ * @method importantToken
5092
+ */
5093
+ importantToken: function(first, startLine, startCol) {
5094
+ var reader = this._reader,
5095
+ important = first,
5096
+ tt = Tokens.CHAR,
5097
+ temp,
5098
+ c;
5099
 
5100
+ reader.mark();
5101
+ c = reader.read();
5102
 
5103
+ while (c) {
 
 
 
 
 
 
5104
 
5105
+ //there can be a comment in here
5106
+ if (c === "/") {
 
 
 
 
 
5107
 
5108
+ //if the next character isn't a star, then this isn't a valid !important token
5109
+ if (reader.peek() !== "*") {
5110
+ break;
5111
+ } else {
5112
+ temp = this.readComment(c);
5113
+ if (temp === "") { //broken!
5114
+ break;
5115
+ }
5116
+ }
5117
+ } else if (isWhitespace(c)) {
5118
+ important += c + this.readWhitespace();
5119
+ } else if (/i/i.test(c)) {
5120
+ temp = reader.readCount(8);
5121
+ if (/mportant/i.test(temp)) {
5122
+ important += c + temp;
5123
+ tt = Tokens.IMPORTANT_SYM;
5124
 
5125
+ }
5126
+ break; //we're done
5127
+ } else {
5128
+ break;
5129
+ }
5130
 
5131
+ c = reader.read();
5132
+ }
5133
 
5134
+ if (tt === Tokens.CHAR) {
5135
+ reader.reset();
5136
+ return this.charToken(first, startLine, startCol);
5137
+ } else {
5138
+ return this.createToken(tt, important, startLine, startCol);
5139
+ }
 
 
 
 
 
 
 
 
5140
 
5141
+
5142
+ },
5143
 
5144
  /**
5145
+ * Produces a NOT or CHAR token based on the specified information. The
5146
+ * first character is provided and the rest is read by the function to determine
5147
+ * the correct token to create.
5148
+ * @param {String} first The first character in the token.
5149
+ * @param {int} startLine The beginning line for the character.
5150
+ * @param {int} startCol The beginning column for the character.
5151
+ * @return {Object} A token object.
5152
+ * @method notToken
5153
  */
5154
+ notToken: function(first, startLine, startCol) {
5155
+ var reader = this._reader,
5156
+ text = first;
5157
+
5158
+ reader.mark();
5159
+ text += reader.readCount(4);
5160
+
5161
+ if (text.toLowerCase() === ":not(") {
5162
+ return this.createToken(Tokens.NOT, text, startLine, startCol);
5163
+ } else {
5164
+ reader.reset();
5165
+ return this.charToken(first, startLine, startCol);
5166
+ }
5167
+ },
5168
 
5169
  /**
5170
+ * Produces a number token based on the given character
5171
+ * and location in the stream. This may return a token of
5172
+ * NUMBER, EMS, EXS, LENGTH, ANGLE, TIME, FREQ, DIMENSION,
5173
+ * or PERCENTAGE.
5174
+ * @param {String} first The first character for the token.
5175
+ * @param {int} startLine The beginning line for the character.
5176
+ * @param {int} startCol The beginning column for the character.
5177
+ * @return {Object} A token object.
5178
+ * @method numberToken
5179
  */
5180
+ numberToken: function(first, startLine, startCol) {
5181
+ var reader = this._reader,
5182
+ value = this.readNumber(first),
5183
+ ident,
5184
+ tt = Tokens.NUMBER,
5185
+ c = reader.peek();
5186
 
5187
+ if (isIdentStart(c)) {
5188
+ ident = this.readName(reader.read());
5189
+ value += ident;
5190
 
5191
+ if (/^em$|^ex$|^px$|^gd$|^rem$|^vw$|^vh$|^vmax$|^vmin$|^ch$|^cm$|^mm$|^in$|^pt$|^pc$/i.test(ident)) {
5192
+ tt = Tokens.LENGTH;
5193
+ } else if (/^deg|^rad$|^grad$/i.test(ident)) {
5194
+ tt = Tokens.ANGLE;
5195
+ } else if (/^ms$|^s$/i.test(ident)) {
5196
+ tt = Tokens.TIME;
5197
+ } else if (/^hz$|^khz$/i.test(ident)) {
5198
+ tt = Tokens.FREQ;
5199
+ } else if (/^dpi$|^dpcm$/i.test(ident)) {
5200
+ tt = Tokens.RESOLUTION;
5201
+ } else {
5202
+ tt = Tokens.DIMENSION;
5203
+ }
5204
 
5205
+ } else if (c === "%") {
5206
+ value += reader.read();
5207
+ tt = Tokens.PERCENTAGE;
5208
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
5209
 
5210
+ return this.createToken(tt, value, startLine, startCol);
5211
+ },
5212
 
5213
  /**
5214
+ * Produces a string token based on the given character
5215
+ * and location in the stream. Since strings may be indicated
5216
+ * by single or double quotes, a failure to match starting
5217
+ * and ending quotes results in an INVALID token being generated.
5218
+ * The first character in the string is passed in and then
5219
+ * the rest are read up to and including the final quotation mark.
5220
+ * @param {String} first The first character in the string.
5221
+ * @param {int} startLine The beginning line for the character.
5222
+ * @param {int} startCol The beginning column for the character.
5223
+ * @return {Object} A token object.
5224
+ * @method stringToken
5225
  */
5226
+ stringToken: function(first, startLine, startCol) {
5227
+ var delim = first,
5228
+ string = first,
5229
+ reader = this._reader,
5230
+ tt = Tokens.STRING,
5231
+ c = reader.read(),
5232
+ i;
5233
 
5234
+ while (c) {
5235
+ string += c;
5236
+
5237
+ if (c === "\\") {
5238
+ c = reader.read();
5239
+ if (c === null) {
5240
+ break; // premature EOF after backslash
5241
+ } else if (/[^\r\n\f0-9a-f]/i.test(c)) {
5242
+ // single-character escape
5243
+ string += c;
5244
+ } else {
5245
+ // read up to six hex digits
5246
+ for (i=0; isHexDigit(c) && i<6; i++) {
5247
+ string += c;
5248
+ c = reader.read();
5249
+ }
5250
+ // swallow trailing newline or space
5251
+ if (c === "\r" && reader.peek() === "\n") {
5252
+ string += c;
5253
+ c = reader.read();
5254
+ }
5255
+ if (isWhitespace(c)) {
5256
+ string += c;
5257
+ } else {
5258
+ // This character is null or not part of the escape;
5259
+ // jump back to the top to process it.
5260
+ continue;
5261
+ }
5262
+ }
5263
+ } else if (c === delim) {
5264
+ break; // delimiter found.
5265
+ } else if (isNewLine(reader.peek())) {
5266
+ // newline without an escapement: it's an invalid string
5267
+ tt = Tokens.INVALID;
5268
+ break;
5269
  }
5270
+ c = reader.read();
5271
  }
5272
 
5273
+ //if c is null, that means we're out of input and the string was never closed
5274
+ if (c === null) {
5275
+ tt = Tokens.INVALID;
5276
+ }
5277
 
5278
+ return this.createToken(tt, string, startLine, startCol);
 
 
 
 
 
 
5279
  },
5280
 
5281
+ unicodeRangeToken: function(first, startLine, startCol) {
5282
+ var reader = this._reader,
5283
+ value = first,
5284
+ temp,
5285
+ tt = Tokens.CHAR;
 
 
 
5286
 
5287
+ //then it should be a unicode range
5288
+ if (reader.peek() === "+") {
5289
+ reader.mark();
5290
+ value += reader.read();
5291
+ value += this.readUnicodeRangePart(true);
5292
 
5293
+ //ensure there's an actual unicode range here
5294
+ if (value.length === 2) {
5295
+ reader.reset();
5296
+ } else {
 
 
 
 
5297
 
5298
+ tt = Tokens.UNICODE_RANGE;
 
 
5299
 
5300
+ //if there's a ? in the first part, there can't be a second part
5301
+ if (value.indexOf("?") === -1) {
5302
 
5303
+ if (reader.peek() === "-") {
5304
+ reader.mark();
5305
+ temp = reader.read();
5306
+ temp += this.readUnicodeRangePart(false);
5307
 
5308
+ //if there's not another value, back up and just take the first
5309
+ if (temp.length === 1) {
5310
+ reader.reset();
5311
+ } else {
5312
+ value += temp;
5313
+ }
5314
+ }
5315
+
5316
+ }
5317
+ }
5318
  }
5319
 
5320
+ return this.createToken(tt, value, startLine, startCol);
5321
+ },
 
 
 
 
 
5322
 
5323
+ /**
5324
+ * Produces a S token based on the specified information. Since whitespace
5325
+ * may have multiple characters, this consumes all whitespace characters
5326
+ * into a single token.
5327
+ * @param {String} first The first character in the token.
5328
+ * @param {int} startLine The beginning line for the character.
5329
+ * @param {int} startCol The beginning column for the character.
5330
+ * @return {Object} A token object.
5331
+ * @method whitespaceToken
5332
+ */
5333
+ whitespaceToken: function(first, startLine, startCol) {
5334
+ var value = first + this.readWhitespace();
5335
+ return this.createToken(Tokens.S, value, startLine, startCol);
5336
+ },
5337
 
 
 
 
 
 
 
 
5338
 
5339
+ //-------------------------------------------------------------------------
5340
+ // Methods to read values from the string stream
5341
+ //-------------------------------------------------------------------------
 
 
 
 
5342
 
5343
+ readUnicodeRangePart: function(allowQuestionMark) {
5344
+ var reader = this._reader,
5345
+ part = "",
5346
+ c = reader.peek();
5347
 
5348
+ //first read hex digits
5349
+ while (isHexDigit(c) && part.length < 6) {
5350
+ reader.read();
5351
+ part += c;
5352
+ c = reader.peek();
5353
  }
 
5354
 
5355
+ //then read question marks if allowed
5356
+ if (allowQuestionMark) {
5357
+ while (c === "?" && part.length < 6) {
5358
+ reader.read();
5359
+ part += c;
5360
+ c = reader.peek();
5361
+ }
5362
+ }
5363
 
5364
+ //there can't be any other characters after this point
5365
 
5366
+ return part;
5367
+ },
 
5368
 
5369
+ readWhitespace: function() {
5370
+ var reader = this._reader,
5371
+ whitespace = "",
5372
+ c = reader.peek();
5373
 
5374
+ while (isWhitespace(c)) {
5375
+ reader.read();
5376
+ whitespace += c;
5377
+ c = reader.peek();
5378
+ }
5379
 
5380
+ return whitespace;
5381
+ },
5382
+ readNumber: function(first) {
5383
+ var reader = this._reader,
5384
+ number = first,
5385
+ hasDot = (first === "."),
5386
+ c = reader.peek();
5387
 
 
 
 
5388
 
5389
+ while (c) {
5390
+ if (isDigit(c)) {
5391
+ number += reader.read();
5392
+ } else if (c === ".") {
5393
+ if (hasDot) {
5394
+ break;
5395
+ } else {
5396
+ hasDot = true;
5397
+ number += reader.read();
5398
+ }
5399
+ } else {
5400
+ break;
5401
+ }
5402
 
5403
+ c = reader.peek();
5404
+ }
 
5405
 
5406
+ return number;
5407
+ },
 
5408
 
5409
+ // returns null w/o resetting reader if string is invalid.
5410
+ readString: function() {
5411
+ var token = this.stringToken(this._reader.read(), 0, 0);
5412
+ return token.type === Tokens.INVALID ? null : token.value;
5413
+ },
5414
 
5415
+ // returns null w/o resetting reader if URI is invalid.
5416
+ readURI: function(first) {
5417
+ var reader = this._reader,
5418
+ uri = first,
5419
+ inner = "",
5420
+ c = reader.peek();
5421
 
5422
+ //skip whitespace before
5423
+ while (c && isWhitespace(c)) {
5424
+ reader.read();
5425
+ c = reader.peek();
5426
  }
 
 
 
5427
 
5428
+ //it's a string
5429
+ if (c === "'" || c === "\"") {
5430
+ inner = this.readString();
5431
+ if (inner !== null) {
5432
+ inner = PropertyValuePart.parseString(inner);
5433
+ }
5434
+ } else {
5435
+ inner = this.readUnquotedURL();
5436
+ }
 
 
 
 
 
 
5437
 
5438
+ c = reader.peek();
5439
 
5440
+ //skip whitespace after
5441
+ while (c && isWhitespace(c)) {
5442
+ reader.read();
5443
+ c = reader.peek();
5444
+ }
 
 
 
 
 
5445
 
5446
+ //if there was no inner value or the next character isn't closing paren, it's not a URI
5447
+ if (inner === null || c !== ")") {
5448
+ uri = null;
5449
+ } else {
5450
+ // Ensure argument to URL is always double-quoted
5451
+ // (This simplifies later processing in PropertyValuePart.)
5452
+ uri += PropertyValuePart.serializeString(inner) + reader.read();
5453
+ }
5454
 
5455
+ return uri;
5456
+ },
5457
+ // This method never fails, although it may return an empty string.
5458
+ readUnquotedURL: function(first) {
5459
+ var reader = this._reader,
5460
+ url = first || "",
5461
+ c;
5462
 
5463
+ for (c = reader.peek(); c; c = reader.peek()) {
5464
+ // Note that the grammar at
5465
+ // https://www.w3.org/TR/CSS2/grammar.html#scanner
5466
+ // incorrectly includes the backslash character in the
5467
+ // `url` production, although it is correctly omitted in
5468
+ // the `baduri1` production.
5469
+ if (nonascii.test(c) || /^[\-!#$%&*-\[\]-~]$/.test(c)) {
5470
+ url += c;
5471
+ reader.read();
5472
+ } else if (c === "\\") {
5473
+ if (/^[^\r\n\f]$/.test(reader.peek(2))) {
5474
+ url += this.readEscape(reader.read(), true);
5475
+ } else {
5476
+ break; // bad escape sequence.
5477
+ }
5478
+ } else {
5479
+ break; // bad character
5480
+ }
5481
+ }
5482
 
5483
+ return url;
5484
+ },
5485
 
5486
+ readName: function(first) {
5487
+ var reader = this._reader,
5488
+ ident = first || "",
5489
+ c;
 
 
 
5490
 
5491
+ for (c = reader.peek(); c; c = reader.peek()) {
5492
+ if (c === "\\") {
5493
+ if (/^[^\r\n\f]$/.test(reader.peek(2))) {
5494
+ ident += this.readEscape(reader.read(), true);
5495
+ } else {
5496
+ // Bad escape sequence.
5497
  break;
5498
+ }
5499
+ } else if (isNameChar(c)) {
5500
+ ident += reader.read();
5501
+ } else {
5502
+ break;
5503
+ }
5504
+ }
5505
 
5506
+ return ident;
5507
+ },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5508
 
5509
+ readEscape: function(first, unescape) {
5510
+ var reader = this._reader,
5511
+ cssEscape = first || "",
5512
+ i = 0,
5513
+ c = reader.peek();
 
 
 
 
5514
 
5515
+ if (isHexDigit(c)) {
5516
+ do {
5517
+ cssEscape += reader.read();
5518
+ c = reader.peek();
5519
+ } while (c && isHexDigit(c) && ++i < 6);
5520
+ }
 
 
 
 
 
 
5521
 
5522
+ if (cssEscape.length === 1) {
5523
+ if (/^[^\r\n\f0-9a-f]$/.test(c)) {
5524
+ reader.read();
5525
+ if (unescape) {
5526
+ return c;
5527
+ }
5528
+ } else {
5529
+ // We should never get here (readName won't call readEscape
5530
+ // if the escape sequence is bad).
5531
+ throw new Error("Bad escape sequence.");
5532
+ }
5533
+ } else if (c === "\r") {
5534
+ reader.read();
5535
+ if (reader.peek() === "\n") {
5536
+ c += reader.read();
5537
+ }
5538
+ } else if (/^[ \t\n\f]$/.test(c)) {
5539
+ reader.read();
5540
+ } else {
5541
+ c = "";
5542
+ }
5543
 
5544
+ if (unescape) {
5545
+ var cp = parseInt(cssEscape.slice(first.length), 16);
5546
+ return String.fromCodePoint ? String.fromCodePoint(cp) :
5547
+ String.fromCharCode(cp);
5548
+ }
5549
+ return cssEscape + c;
5550
+ },
5551
+
5552
+ readComment: function(first) {
5553
+ var reader = this._reader,
5554
+ comment = first || "",
5555
+ c = reader.read();
 
 
 
 
 
5556
 
5557
+ if (c === "*") {
5558
+ while (c) {
5559
+ comment += c;
 
 
 
 
 
5560
 
5561
+ //look for end of comment
5562
+ if (comment.length > 2 && c === "*" && reader.peek() === "/") {
5563
+ comment += reader.read();
 
 
5564
  break;
5565
+ }
5566
 
5567
+ c = reader.read();
5568
+ }
 
 
 
 
 
 
5569
 
5570
+ return comment;
5571
+ } else {
5572
+ return "";
5573
+ }
 
 
 
 
5574
 
5575
+ }
5576
+ });
 
 
 
 
 
 
 
 
 
 
 
 
5577
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5578
 
5579
+ },{"../util/TokenStreamBase":27,"./PropertyValuePart":11,"./Tokens":18}],18:[function(require,module,exports){
5580
+ "use strict";
 
 
 
 
 
5581
 
5582
+ var Tokens = module.exports = [
 
 
 
 
 
 
5583
 
5584
+ /*
5585
+ * The following token names are defined in CSS3 Grammar: https://www.w3.org/TR/css3-syntax/#lexical
5586
+ */
 
 
 
 
 
5587
 
5588
+ // HTML-style comments
5589
+ { name: "CDO" },
5590
+ { name: "CDC" },
5591
 
5592
+ // ignorables
5593
+ { name: "S", whitespace: true/*, channel: "ws"*/ },
5594
+ { name: "COMMENT", comment: true, hide: true, channel: "comment" },
5595
 
5596
+ // attribute equality
5597
+ { name: "INCLUDES", text: "~=" },
5598
+ { name: "DASHMATCH", text: "|=" },
5599
+ { name: "PREFIXMATCH", text: "^=" },
5600
+ { name: "SUFFIXMATCH", text: "$=" },
5601
+ { name: "SUBSTRINGMATCH", text: "*=" },
5602
+
5603
+ // identifier types
5604
+ { name: "STRING" },
5605
+ { name: "IDENT" },
5606
+ { name: "HASH" },
5607
+
5608
+ // at-keywords
5609
+ { name: "IMPORT_SYM", text: "@import" },
5610
+ { name: "PAGE_SYM", text: "@page" },
5611
+ { name: "MEDIA_SYM", text: "@media" },
5612
+ { name: "FONT_FACE_SYM", text: "@font-face" },
5613
+ { name: "CHARSET_SYM", text: "@charset" },
5614
+ { name: "NAMESPACE_SYM", text: "@namespace" },
5615
+ { name: "SUPPORTS_SYM", text: "@supports" },
5616
+ { name: "VIEWPORT_SYM", text: ["@viewport", "@-ms-viewport", "@-o-viewport"] },
5617
+ { name: "DOCUMENT_SYM", text: ["@document", "@-moz-document"] },
5618
+ { name: "UNKNOWN_SYM" },
5619
+ //{ name: "ATKEYWORD"},
5620
 
5621
+ // CSS3 animations
5622
+ { name: "KEYFRAMES_SYM", text: [ "@keyframes", "@-webkit-keyframes", "@-moz-keyframes", "@-o-keyframes" ] },
5623
 
5624
+ // important symbol
5625
+ { name: "IMPORTANT_SYM" },
5626
 
5627
+ // measurements
5628
+ { name: "LENGTH" },
5629
+ { name: "ANGLE" },
5630
+ { name: "TIME" },
5631
+ { name: "FREQ" },
5632
+ { name: "DIMENSION" },
5633
+ { name: "PERCENTAGE" },
5634
+ { name: "NUMBER" },
5635
 
5636
+ // functions
5637
+ { name: "URI" },
5638
+ { name: "FUNCTION" },
 
5639
 
5640
+ // Unicode ranges
5641
+ { name: "UNICODE_RANGE" },
 
5642
 
5643
+ /*
5644
+ * The following token names are defined in CSS3 Selectors: https://www.w3.org/TR/css3-selectors/#selector-syntax
5645
+ */
5646
 
5647
+ // invalid string
5648
+ { name: "INVALID" },
 
5649
 
5650
+ // combinators
5651
+ { name: "PLUS", text: "+" },
5652
+ { name: "GREATER", text: ">" },
5653
+ { name: "COMMA", text: "," },
5654
+ { name: "TILDE", text: "~" },
5655
+
5656
+ // modifier
5657
+ { name: "NOT" },
5658
+
5659
+ /*
5660
+ * Defined in CSS3 Paged Media
 
 
 
5661
  */
5662
+ { name: "TOPLEFTCORNER_SYM", text: "@top-left-corner" },
5663
+ { name: "TOPLEFT_SYM", text: "@top-left" },
5664
+ { name: "TOPCENTER_SYM", text: "@top-center" },
5665
+ { name: "TOPRIGHT_SYM", text: "@top-right" },
5666
+ { name: "TOPRIGHTCORNER_SYM", text: "@top-right-corner" },
5667
+ { name: "BOTTOMLEFTCORNER_SYM", text: "@bottom-left-corner" },
5668
+ { name: "BOTTOMLEFT_SYM", text: "@bottom-left" },
5669
+ { name: "BOTTOMCENTER_SYM", text: "@bottom-center" },
5670
+ { name: "BOTTOMRIGHT_SYM", text: "@bottom-right" },
5671
+ { name: "BOTTOMRIGHTCORNER_SYM", text: "@bottom-right-corner" },
5672
+ { name: "LEFTTOP_SYM", text: "@left-top" },
5673
+ { name: "LEFTMIDDLE_SYM", text: "@left-middle" },
5674
+ { name: "LEFTBOTTOM_SYM", text: "@left-bottom" },
5675
+ { name: "RIGHTTOP_SYM", text: "@right-top" },
5676
+ { name: "RIGHTMIDDLE_SYM", text: "@right-middle" },
5677
+ { name: "RIGHTBOTTOM_SYM", text: "@right-bottom" },
5678
 
5679
+ /*
5680
+ * The following token names are defined in CSS3 Media Queries: https://www.w3.org/TR/css3-mediaqueries/#syntax
5681
+ */
5682
+ /*{ name: "MEDIA_ONLY", state: "media"},
5683
+ { name: "MEDIA_NOT", state: "media"},
5684
+ { name: "MEDIA_AND", state: "media"},*/
5685
+ { name: "RESOLUTION", state: "media" },
5686
+
5687
+ /*
5688
+ * The following token names are not defined in any CSS specification but are used by the lexer.
5689
+ */
5690
+
5691
+ // not a real token, but useful for stupid IE filters
5692
+ { name: "IE_FUNCTION" },
5693
+
5694
+ // part of CSS3 grammar but not the Flex code
5695
+ { name: "CHAR" },
5696
+
5697
+ // TODO: Needed?
5698
+ // Not defined as tokens, but might as well be
5699
+ {
5700
+ name: "PIPE",
5701
+ text: "|"
5702
+ },
5703
+ {
5704
+ name: "SLASH",
5705
+ text: "/"
5706
+ },
5707
+ {
5708
+ name: "MINUS",
5709
+ text: "-"
5710
+ },
5711
+ {
5712
+ name: "STAR",
5713
+ text: "*"
5714
  },
5715
 
5716
+ {
5717
+ name: "LBRACE",
5718
+ endChar: "}",
5719
+ text: "{"
5720
+ },
5721
+ {
5722
+ name: "RBRACE",
5723
+ text: "}"
5724
+ },
5725
+ {
5726
+ name: "LBRACKET",
5727
+ endChar: "]",
5728
+ text: "["
5729
+ },
5730
+ {
5731
+ name: "RBRACKET",
5732
+ text: "]"
5733
+ },
5734
+ {
5735
+ name: "EQUALS",
5736
+ text: "="
5737
+ },
5738
+ {
5739
+ name: "COLON",
5740
+ text: ":"
5741
+ },
5742
+ {
5743
+ name: "SEMICOLON",
5744
+ text: ";"
5745
+ },
5746
+ {
5747
+ name: "LPAREN",
5748
+ endChar: ")",
5749
+ text: "("
5750
+ },
5751
+ {
5752
+ name: "RPAREN",
5753
+ text: ")"
5754
+ },
5755
+ {
5756
+ name: "DOT",
5757
+ text: "."
5758
+ }
5759
+ ];
5760
 
5761
+ (function() {
5762
+ var nameMap = [],
5763
+ typeMap = Object.create(null);
 
 
 
 
 
 
 
 
 
 
 
 
 
5764
 
5765
+ Tokens.UNKNOWN = -1;
5766
+ Tokens.unshift({ name:"EOF" });
5767
+ for (var i=0, len = Tokens.length; i < len; i++) {
5768
+ nameMap.push(Tokens[i].name);
5769
+ Tokens[Tokens[i].name] = i;
5770
+ if (Tokens[i].text) {
5771
+ if (Tokens[i].text instanceof Array) {
5772
+ for (var j=0; j < Tokens[i].text.length; j++) {
5773
+ typeMap[Tokens[i].text[j]] = i;
5774
+ }
5775
+ } else {
5776
+ typeMap[Tokens[i].text] = i;
5777
+ }
5778
+ }
5779
+ }
5780
+
5781
+ Tokens.name = function(tt) {
5782
+ return nameMap[tt];
5783
+ };
5784
+
5785
+ Tokens.type = function(c) {
5786
+ return typeMap[c] || -1;
5787
+ };
5788
+ })();
5789
+
5790
+ },{}],19:[function(require,module,exports){
5791
+ "use strict";
5792
+
5793
+ /* exported Validation */
5794
+
5795
+ var Matcher = require("./Matcher");
5796
+ var Properties = require("./Properties");
5797
+ var ValidationTypes = require("./ValidationTypes");
5798
+ var ValidationError = require("./ValidationError");
5799
+ var PropertyValueIterator = require("./PropertyValueIterator");
5800
+
5801
+ var Validation = module.exports = {
5802
+
5803
+ validate: function(property, value) {
5804
+
5805
+ //normalize name
5806
+ var name = property.toString().toLowerCase(),
5807
+ expression = new PropertyValueIterator(value),
5808
+ spec = Properties[name],
5809
+ part;
5810
 
5811
+ if (!spec) {
5812
+ if (name.indexOf("-") !== 0) { //vendor prefixed are ok
5813
+ throw new ValidationError("Unknown property '" + property + "'.", property.line, property.col);
5814
+ }
5815
+ } else if (typeof spec !== "number") {
5816
 
5817
+ // All properties accept some CSS-wide values.
5818
+ // https://drafts.csswg.org/css-values-3/#common-keywords
5819
+ if (ValidationTypes.isAny(expression, "inherit | initial | unset")) {
5820
+ if (expression.hasNext()) {
5821
+ part = expression.next();
5822
+ throw new ValidationError("Expected end of value but found '" + part + "'.", part.line, part.col);
5823
+ }
5824
+ return;
5825
  }
5826
+
5827
+ // Property-specific validation.
5828
+ this.singleProperty(spec, expression);
5829
+
5830
  }
5831
 
 
5832
  },
5833
 
5834
+ singleProperty: function(types, expression) {
 
 
 
 
 
 
 
 
 
 
 
5835
 
5836
+ var result = false,
5837
+ value = expression.value,
5838
+ part;
5839
+
5840
+ result = Matcher.parse(types).match(expression);
5841
+
5842
+ if (!result) {
5843
+ if (expression.hasNext() && !expression.isFirst()) {
5844
+ part = expression.peek();
5845
+ throw new ValidationError("Expected end of value but found '" + part + "'.", part.line, part.col);
5846
+ } else {
5847
+ throw new ValidationError("Expected (" + ValidationTypes.describe(types) + ") but found '" + value + "'.", value.line, value.col);
5848
+ }
5849
+ } else if (expression.hasNext()) {
5850
+ part = expression.next();
5851
+ throw new ValidationError("Expected end of value but found '" + part + "'.", part.line, part.col);
5852
  }
5853
 
5854
+ }
 
5855
 
5856
+ };
 
 
 
 
 
 
 
 
 
 
 
 
5857
 
5858
+ },{"./Matcher":3,"./Properties":7,"./PropertyValueIterator":10,"./ValidationError":20,"./ValidationTypes":21}],20:[function(require,module,exports){
5859
+ "use strict";
5860
 
5861
+ module.exports = ValidationError;
 
 
 
 
 
 
 
 
 
 
 
 
 
5862
 
5863
+ /**
5864
+ * Type to use when a validation error occurs.
5865
+ * @class ValidationError
5866
+ * @namespace parserlib.util
5867
+ * @constructor
5868
+ * @param {String} message The error message.
5869
+ * @param {int} line The line at which the error occurred.
5870
+ * @param {int} col The column at which the error occurred.
5871
+ */
5872
+ function ValidationError(message, line, col) {
5873
 
5874
  /**
5875
+ * The column at which the error occurred.
5876
+ * @type int
5877
+ * @property col
 
 
 
 
 
5878
  */
5879
+ this.col = col;
 
 
5880
 
5881
+ /**
5882
+ * The line at which the error occurred.
5883
+ * @type int
5884
+ * @property line
5885
+ */
5886
+ this.line = line;
5887
 
5888
  /**
5889
+ * The text representation of the unit.
5890
+ * @type String
5891
+ * @property text
 
 
 
 
 
5892
  */
5893
+ this.message = message;
 
 
5894
 
5895
+ }
 
5896
 
5897
+ //inherit from Error
5898
+ ValidationError.prototype = new Error();
5899
+
5900
+ },{}],21:[function(require,module,exports){
5901
+ "use strict";
5902
+
5903
+ var ValidationTypes = module.exports;
5904
+
5905
+ var Matcher = require("./Matcher");
5906
+
5907
+ function copy(to, from) {
5908
+ Object.keys(from).forEach(function(prop) {
5909
+ to[prop] = from[prop];
5910
+ });
5911
+ }
5912
+ copy(ValidationTypes, {
5913
+
5914
+ isLiteral: function (part, literals) {
5915
+ var text = part.text.toString().toLowerCase(),
5916
+ args = literals.split(" | "),
5917
+ i, len, found = false;
5918
+
5919
+ for (i=0, len=args.length; i < len && !found; i++) {
5920
+ if (args[i].charAt(0) === "<") {
5921
+ found = this.simple[args[i]](part);
5922
+ } else if (args[i].slice(-2) === "()") {
5923
+ found = (part.type === "function" &&
5924
+ part.name === args[i].slice(0, -2));
5925
+ } else if (text === args[i].toLowerCase()) {
5926
+ found = true;
5927
+ }
5928
  }
5929
+
5930
+ return found;
5931
  },
5932
 
5933
+ isSimple: function(type) {
5934
+ return Boolean(this.simple[type]);
5935
+ },
 
 
 
 
 
 
 
 
 
 
5936
 
5937
+ isComplex: function(type) {
5938
+ return Boolean(this.complex[type]);
5939
+ },
5940
 
5941
+ describe: function(type) {
5942
+ if (this.complex[type] instanceof Matcher) {
5943
+ return this.complex[type].toString(0);
 
 
5944
  }
5945
+ return type;
5946
  },
5947
 
5948
  /**
5949
+ * Determines if the next part(s) of the given expression
5950
+ * are any of the given types.
 
 
 
 
 
 
5951
  */
5952
+ isAny: function (expression, types) {
5953
+ var args = types.split(" | "),
5954
+ i, len, found = false;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5955
 
5956
+ for (i=0, len=args.length; i < len && !found && expression.hasNext(); i++) {
5957
+ found = this.isType(expression, args[i]);
 
 
 
5958
  }
5959
 
5960
+ return found;
5961
  },
5962
 
5963
  /**
5964
+ * Determines if the next part(s) of the given expression
5965
+ * are one of a group.
 
 
 
 
 
 
5966
  */
5967
+ isAnyOfGroup: function(expression, types) {
5968
+ var args = types.split(" || "),
5969
+ i, len, found = false;
 
 
 
 
 
 
5970
 
5971
+ for (i=0, len=args.length; i < len && !found; i++) {
5972
+ found = this.isType(expression, args[i]);
5973
+ }
5974
 
5975
+ return found ? args[i-1] : false;
5976
+ },
5977
 
5978
+ /**
5979
+ * Determines if the next part(s) of the given expression
5980
+ * are of a given type.
5981
+ */
5982
+ isType: function (expression, type) {
5983
+ var part = expression.peek(),
5984
+ result = false;
 
 
 
 
 
 
 
 
 
5985
 
5986
+ if (type.charAt(0) !== "<") {
5987
+ result = this.isLiteral(part, type);
5988
+ if (result) {
5989
+ expression.next();
5990
+ }
5991
+ } else if (this.simple[type]) {
5992
+ result = this.simple[type](part);
5993
+ if (result) {
5994
+ expression.next();
5995
  }
5996
+ } else if (this.complex[type] instanceof Matcher) {
5997
+ result = this.complex[type].match(expression);
 
 
 
 
 
5998
  } else {
5999
+ result = this.complex[type](expression);
6000
  }
6001
 
6002
+ return result;
6003
  },
6004
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6005
 
6006
+ simple: {
6007
+ __proto__: null,
6008
 
6009
+ "<absolute-size>":
6010
+ "xx-small | x-small | small | medium | large | x-large | xx-large",
 
 
 
 
 
6011
 
6012
+ "<animateable-feature>":
6013
+ "scroll-position | contents | <animateable-feature-name>",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6014
 
6015
+ "<animateable-feature-name>": function(part) {
6016
+ return this["<ident>"](part) &&
6017
+ !/^(unset|initial|inherit|will-change|auto|scroll-position|contents)$/i.test(part);
6018
+ },
6019
 
6020
+ "<angle>": function(part) {
6021
+ return part.type === "angle";
6022
+ },
 
 
 
 
 
 
 
 
 
 
6023
 
6024
+ "<attachment>": "scroll | fixed | local",
 
 
 
6025
 
6026
+ "<attr>": "attr()",
 
6027
 
6028
+ // inset() = inset( <shape-arg>{1,4} [round <border-radius>]? )
6029
+ // circle() = circle( [<shape-radius>]? [at <position>]? )
6030
+ // ellipse() = ellipse( [<shape-radius>{2}]? [at <position>]? )
6031
+ // polygon() = polygon( [<fill-rule>,]? [<shape-arg> <shape-arg>]# )
6032
+ "<basic-shape>": "inset() | circle() | ellipse() | polygon()",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6033
 
6034
+ "<bg-image>": "<image> | <gradient> | none",
 
6035
 
6036
+ "<border-style>":
6037
+ "none | hidden | dotted | dashed | solid | double | groove | " +
6038
+ "ridge | inset | outset",
 
6039
 
6040
+ "<border-width>": "<length> | thin | medium | thick",
 
 
 
 
6041
 
6042
+ "<box>": "padding-box | border-box | content-box",
 
 
 
6043
 
6044
+ "<clip-source>": "<uri>",
 
 
 
6045
 
6046
+ "<color>": function(part) {
6047
+ return part.type === "color" || String(part) === "transparent" || String(part) === "currentColor";
6048
+ },
6049
 
6050
+ // The SVG <color> spec doesn't include "currentColor" or "transparent" as a color.
6051
+ "<color-svg>": function(part) {
6052
+ return part.type === "color";
6053
+ },
 
6054
 
6055
+ "<content>": "content()",
 
 
 
 
6056
 
6057
+ // https://www.w3.org/TR/css3-sizing/#width-height-keywords
6058
+ "<content-sizing>":
6059
+ "fill-available | -moz-available | -webkit-fill-available | " +
6060
+ "max-content | -moz-max-content | -webkit-max-content | " +
6061
+ "min-content | -moz-min-content | -webkit-min-content | " +
6062
+ "fit-content | -moz-fit-content | -webkit-fit-content",
6063
 
6064
+ "<feature-tag-value>": function(part) {
6065
+ return part.type === "function" && /^[A-Z0-9]{4}$/i.test(part);
6066
+ },
6067
 
6068
+ // custom() isn't actually in the spec
6069
+ "<filter-function>":
6070
+ "blur() | brightness() | contrast() | custom() | " +
6071
+ "drop-shadow() | grayscale() | hue-rotate() | invert() | " +
6072
+ "opacity() | saturate() | sepia()",
6073
 
6074
+ "<flex-basis>": "<width>",
 
 
 
6075
 
6076
+ "<flex-direction>": "row | row-reverse | column | column-reverse",
 
 
 
 
 
 
6077
 
6078
+ "<flex-grow>": "<number>",
 
 
6079
 
6080
+ "<flex-shrink>": "<number>",
 
6081
 
6082
+ "<flex-wrap>": "nowrap | wrap | wrap-reverse",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6083
 
6084
+ "<font-size>":
6085
+ "<absolute-size> | <relative-size> | <length> | <percentage>",
6086
 
6087
+ "<font-stretch>":
6088
+ "normal | ultra-condensed | extra-condensed | condensed | " +
6089
+ "semi-condensed | semi-expanded | expanded | extra-expanded | " +
6090
+ "ultra-expanded",
6091
 
6092
+ "<font-style>": "normal | italic | oblique",
6093
 
6094
+ "<font-variant-caps>":
6095
+ "small-caps | all-small-caps | petite-caps | all-petite-caps | " +
6096
+ "unicase | titling-caps",
6097
 
6098
+ "<font-variant-css21>": "normal | small-caps",
 
 
 
6099
 
6100
+ "<font-weight>":
6101
+ "normal | bold | bolder | lighter | " +
6102
+ "100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900",
 
 
 
6103
 
6104
+ "<generic-family>":
6105
+ "serif | sans-serif | cursive | fantasy | monospace",
 
 
 
 
 
 
6106
 
6107
+ "<geometry-box>": "<shape-box> | fill-box | stroke-box | view-box",
6108
 
6109
+ "<glyph-angle>": function(part) {
6110
+ return part.type === "angle" && part.units === "deg";
6111
+ },
6112
 
6113
+ "<gradient>": function(part) {
6114
+ return part.type === "function" && /^(?:\-(?:ms|moz|o|webkit)\-)?(?:repeating\-)?(?:radial\-|linear\-)?gradient/i.test(part);
6115
+ },
 
6116
 
6117
+ "<icccolor>":
6118
+ "cielab() | cielch() | cielchab() | " +
6119
+ "icc-color() | icc-named-color()",
 
 
6120
 
6121
+ //any identifier
6122
+ "<ident>": function(part) {
6123
+ return part.type === "identifier" || part.wasIdent;
6124
+ },
 
 
 
6125
 
6126
+ "<ident-not-generic-family>": function(part) {
6127
+ return this["<ident>"](part) && !this["<generic-family>"](part);
6128
+ },
6129
 
6130
+ "<image>": "<uri>",
6131
+
6132
+ "<integer>": function(part) {
6133
+ return part.type === "integer";
6134
+ },
6135
+
6136
+ "<length>": function(part) {
6137
+ if (part.type === "function" && /^(?:\-(?:ms|moz|o|webkit)\-)?calc/i.test(part)) {
6138
+ return true;
 
6139
  } else {
6140
+ return part.type === "length" || part.type === "number" || part.type === "integer" || String(part) === "0";
6141
  }
6142
+ },
6143
 
6144
+ "<line>": function(part) {
6145
+ return part.type === "integer";
6146
+ },
6147
 
6148
+ "<line-height>": "<number> | <length> | <percentage> | normal",
 
 
 
 
 
 
 
6149
 
6150
+ "<margin-width>": "<length> | <percentage> | auto",
 
 
6151
 
6152
+ "<miterlimit>": function(part) {
6153
+ return this["<number>"](part) && part.value >= 1;
6154
+ },
 
6155
 
6156
+ "<nonnegative-length-or-percentage>": function(part) {
6157
+ return (this["<length>"](part) || this["<percentage>"](part)) &&
6158
+ (String(part) === "0" || part.type === "function" || (part.value) >= 0);
6159
+ },
 
6160
 
6161
+ "<nonnegative-number-or-percentage>": function(part) {
6162
+ return (this["<number>"](part) || this["<percentage>"](part)) &&
6163
+ (String(part) === "0" || part.type === "function" || (part.value) >= 0);
6164
+ },
6165
 
6166
+ "<number>": function(part) {
6167
+ return part.type === "number" || this["<integer>"](part);
6168
+ },
 
6169
 
6170
+ "<opacity-value>": function(part) {
6171
+ return this["<number>"](part) && part.value >= 0 && part.value <= 1;
6172
+ },
 
 
 
 
6173
 
6174
+ "<padding-width>": "<nonnegative-length-or-percentage>",
6175
 
6176
+ "<percentage>": function(part) {
6177
+ return part.type === "percentage" || String(part) === "0";
6178
+ },
 
 
6179
 
6180
+ "<relative-size>": "smaller | larger",
 
 
 
 
 
6181
 
6182
+ "<shape>": "rect() | inset-rect()",
6183
 
6184
+ "<shape-box>": "<box> | margin-box",
6185
+
6186
+ "<single-animation-direction>":
6187
+ "normal | reverse | alternate | alternate-reverse",
6188
+
6189
+ "<single-animation-name>": function(part) {
6190
+ return this["<ident>"](part) &&
6191
+ /^-?[a-z_][-a-z0-9_]+$/i.test(part) &&
6192
+ !/^(none|unset|initial|inherit)$/i.test(part);
6193
+ },
6194
+
6195
+ "<string>": function(part) {
6196
+ return part.type === "string";
6197
+ },
6198
+
6199
+ "<time>": function(part) {
6200
+ return part.type === "time";
6201
+ },
6202
+
6203
+ "<uri>": function(part) {
6204
+ return part.type === "uri";
6205
+ },
6206
+
6207
+ "<width>": "<margin-width>"
6208
+ },
6209
+
6210
+ complex: {
6211
+ __proto__: null,
6212
+
6213
+ "<azimuth>":
6214
+ "<angle>" +
6215
+ " | " +
6216
+ "[ [ left-side | far-left | left | center-left | center | " +
6217
+ "center-right | right | far-right | right-side ] || behind ]" +
6218
+ " | "+
6219
+ "leftwards | rightwards",
6220
+
6221
+ "<bg-position>": "<position>#",
6222
+
6223
+ "<bg-size>":
6224
+ "[ <length> | <percentage> | auto ]{1,2} | cover | contain",
6225
+
6226
+ "<border-image-slice>":
6227
+ // [<number> | <percentage>]{1,4} && fill?
6228
+ // *but* fill can appear between any of the numbers
6229
+ Matcher.many([true /* first element is required */],
6230
+ Matcher.cast("<nonnegative-number-or-percentage>"),
6231
+ Matcher.cast("<nonnegative-number-or-percentage>"),
6232
+ Matcher.cast("<nonnegative-number-or-percentage>"),
6233
+ Matcher.cast("<nonnegative-number-or-percentage>"),
6234
+ "fill"),
6235
+
6236
+ "<border-radius>":
6237
+ "<nonnegative-length-or-percentage>{1,4} " +
6238
+ "[ / <nonnegative-length-or-percentage>{1,4} ]?",
6239
+
6240
+ "<box-shadow>": "none | <shadow>#",
6241
+
6242
+ "<clip-path>": "<basic-shape> || <geometry-box>",
6243
+
6244
+ "<dasharray>":
6245
+ // "list of comma and/or white space separated <length>s and
6246
+ // <percentage>s". There is a non-negative constraint.
6247
+ Matcher.cast("<nonnegative-length-or-percentage>")
6248
+ .braces(1, Infinity, "#", Matcher.cast(",").question()),
6249
+
6250
+ "<family-name>":
6251
+ // <string> | <IDENT>+
6252
+ "<string> | <ident-not-generic-family> <ident>*",
6253
+
6254
+ "<filter-function-list>": "[ <filter-function> | <uri> ]+",
6255
+
6256
+ // https://www.w3.org/TR/2014/WD-css-flexbox-1-20140325/#flex-property
6257
+ "<flex>":
6258
+ "none | [ <flex-grow> <flex-shrink>? || <flex-basis> ]",
6259
+
6260
+ "<font-family>": "[ <generic-family> | <family-name> ]#",
6261
+
6262
+ "<font-shorthand>":
6263
+ "[ <font-style> || <font-variant-css21> || " +
6264
+ "<font-weight> || <font-stretch> ]? <font-size> " +
6265
+ "[ / <line-height> ]? <font-family>",
6266
+
6267
+ "<font-variant-alternates>":
6268
+ // stylistic(<feature-value-name>)
6269
+ "stylistic() || " +
6270
+ "historical-forms || " +
6271
+ // styleset(<feature-value-name> #)
6272
+ "styleset() || " +
6273
+ // character-variant(<feature-value-name> #)
6274
+ "character-variant() || " +
6275
+ // swash(<feature-value-name>)
6276
+ "swash() || " +
6277
+ // ornaments(<feature-value-name>)
6278
+ "ornaments() || " +
6279
+ // annotation(<feature-value-name>)
6280
+ "annotation()",
6281
+
6282
+ "<font-variant-ligatures>":
6283
+ // <common-lig-values>
6284
+ "[ common-ligatures | no-common-ligatures ] || " +
6285
+ // <discretionary-lig-values>
6286
+ "[ discretionary-ligatures | no-discretionary-ligatures ] || " +
6287
+ // <historical-lig-values>
6288
+ "[ historical-ligatures | no-historical-ligatures ] || " +
6289
+ // <contextual-alt-values>
6290
+ "[ contextual | no-contextual ]",
6291
+
6292
+ "<font-variant-numeric>":
6293
+ // <numeric-figure-values>
6294
+ "[ lining-nums | oldstyle-nums ] || " +
6295
+ // <numeric-spacing-values>
6296
+ "[ proportional-nums | tabular-nums ] || " +
6297
+ // <numeric-fraction-values>
6298
+ "[ diagonal-fractions | stacked-fractions ] || " +
6299
+ "ordinal || slashed-zero",
6300
+
6301
+ "<font-variant-east-asian>":
6302
+ // <east-asian-variant-values>
6303
+ "[ jis78 | jis83 | jis90 | jis04 | simplified | traditional ] || " +
6304
+ // <east-asian-width-values>
6305
+ "[ full-width | proportional-width ] || " +
6306
+ "ruby",
6307
+
6308
+ // Note that <color> here is "as defined in the SVG spec", which
6309
+ // is more restrictive that the <color> defined in the CSS spec.
6310
+ // none | currentColor | <color> [<icccolor>]? |
6311
+ // <funciri> [ none | currentColor | <color> [<icccolor>]? ]?
6312
+ "<paint>": "<paint-basic> | <uri> <paint-basic>?",
6313
+
6314
+ // Helper definition for <paint> above.
6315
+ "<paint-basic>": "none | currentColor | <color-svg> <icccolor>?",
6316
+
6317
+ "<position>":
6318
+ // Because our `alt` combinator is ordered, we need to test these
6319
+ // in order from longest possible match to shortest.
6320
+ "[ center | [ left | right ] [ <percentage> | <length> ]? ] && " +
6321
+ "[ center | [ top | bottom ] [ <percentage> | <length> ]? ]" +
6322
+ " | " +
6323
+ "[ left | center | right | <percentage> | <length> ] " +
6324
+ "[ top | center | bottom | <percentage> | <length> ]" +
6325
+ " | " +
6326
+ "[ left | center | right | top | bottom | <percentage> | <length> ]",
6327
+
6328
+ "<repeat-style>":
6329
+ "repeat-x | repeat-y | [ repeat | space | round | no-repeat ]{1,2}",
6330
+
6331
+ "<shadow>":
6332
+ //inset? && [ <length>{2,4} && <color>? ]
6333
+ Matcher.many([true /* length is required */],
6334
+ Matcher.cast("<length>").braces(2, 4), "inset", "<color>"),
6335
+
6336
+ "<text-decoration>":
6337
+ "none | [ underline || overline || line-through || blink ]",
6338
+
6339
+ "<will-change>":
6340
+ "auto | <animateable-feature>#",
6341
+
6342
+ "<x-one-radius>":
6343
+ //[ <length> | <percentage> ] [ <length> | <percentage> ]?
6344
+ "[ <length> | <percentage> ]{1,2}"
6345
+ }
6346
+ });
6347
+
6348
+ Object.keys(ValidationTypes.simple).forEach(function(nt) {
6349
+ var rule = ValidationTypes.simple[nt];
6350
+ if (typeof rule === "string") {
6351
+ ValidationTypes.simple[nt] = function(part) {
6352
+ return ValidationTypes.isLiteral(part, rule);
6353
+ };
6354
+ }
6355
+ });
6356
+
6357
+ Object.keys(ValidationTypes.complex).forEach(function(nt) {
6358
+ var rule = ValidationTypes.complex[nt];
6359
+ if (typeof rule === "string") {
6360
+ ValidationTypes.complex[nt] = Matcher.parse(rule);
6361
+ }
6362
+ });
6363
 
6364
+ // Because this is defined relative to other complex validation types,
6365
+ // we need to define it *after* the rest of the types are initialized.
6366
+ ValidationTypes.complex["<font-variant>"] =
6367
+ Matcher.oror({ expand: "<font-variant-ligatures>" },
6368
+ { expand: "<font-variant-alternates>" },
6369
+ "<font-variant-caps>",
6370
+ { expand: "<font-variant-numeric>" },
6371
+ { expand: "<font-variant-east-asian>" });
6372
+
6373
+ },{"./Matcher":3}],22:[function(require,module,exports){
6374
+ "use strict";
6375
+
6376
+ module.exports = {
6377
+ Colors : require("./Colors"),
6378
+ Combinator : require("./Combinator"),
6379
+ Parser : require("./Parser"),
6380
+ PropertyName : require("./PropertyName"),
6381
+ PropertyValue : require("./PropertyValue"),
6382
+ PropertyValuePart : require("./PropertyValuePart"),
6383
+ Matcher : require("./Matcher"),
6384
+ MediaFeature : require("./MediaFeature"),
6385
+ MediaQuery : require("./MediaQuery"),
6386
+ Selector : require("./Selector"),
6387
+ SelectorPart : require("./SelectorPart"),
6388
+ SelectorSubPart : require("./SelectorSubPart"),
6389
+ Specificity : require("./Specificity"),
6390
+ TokenStream : require("./TokenStream"),
6391
+ Tokens : require("./Tokens"),
6392
+ ValidationError : require("./ValidationError")
6393
+ };
6394
 
6395
+ },{"./Colors":1,"./Combinator":2,"./Matcher":3,"./MediaFeature":4,"./MediaQuery":5,"./Parser":6,"./PropertyName":8,"./PropertyValue":9,"./PropertyValuePart":11,"./Selector":13,"./SelectorPart":14,"./SelectorSubPart":15,"./Specificity":16,"./TokenStream":17,"./Tokens":18,"./ValidationError":20}],23:[function(require,module,exports){
6396
+ "use strict";
 
 
 
 
6397
 
6398
+ module.exports = EventTarget;
 
 
 
 
6399
 
6400
+ /**
6401
+ * A generic base to inherit from for any object
6402
+ * that needs event handling.
6403
+ * @class EventTarget
6404
+ * @constructor
6405
+ */
6406
+ function EventTarget() {
6407
 
6408
+ /**
6409
+ * The array of listeners for various events.
6410
+ * @type Object
6411
+ * @property _listeners
6412
+ * @private
6413
+ */
6414
+ this._listeners = Object.create(null);
6415
+ }
6416
 
6417
+ EventTarget.prototype = {
6418
+
6419
+ //restore constructor
6420
+ constructor: EventTarget,
6421
+
6422
+ /**
6423
+ * Adds a listener for a given event type.
6424
+ * @param {String} type The type of event to add a listener for.
6425
+ * @param {Function} listener The function to call when the event occurs.
6426
+ * @return {void}
6427
+ * @method addListener
6428
+ */
6429
+ addListener: function(type, listener) {
6430
+ if (!this._listeners[type]) {
6431
+ this._listeners[type] = [];
6432
  }
6433
 
6434
+ this._listeners[type].push(listener);
6435
  },
6436
 
6437
+ /**
6438
+ * Fires an event based on the passed-in object.
6439
+ * @param {Object|String} event An object with at least a 'type' attribute
6440
+ * or a string indicating the event name.
6441
+ * @return {void}
6442
+ * @method fire
6443
+ */
6444
+ fire: function(event) {
6445
+ if (typeof event === "string") {
6446
+ event = { type: event };
 
6447
  }
6448
+ if (typeof event.target !== "undefined") {
6449
+ event.target = this;
 
 
 
 
6450
  }
6451
 
6452
+ if (typeof event.type === "undefined") {
6453
+ throw new Error("Event object missing 'type' property.");
6454
+ }
6455
 
6456
+ if (this._listeners[event.type]) {
 
 
 
6457
 
6458
+ //create a copy of the array and use that so listeners can't chane
6459
+ var listeners = this._listeners[event.type].concat();
6460
+ for (var i=0, len=listeners.length; i < len; i++) {
6461
+ listeners[i].call(this, event);
6462
+ }
6463
+ }
6464
+ },
6465
 
6466
+ /**
6467
+ * Removes a listener for a given event type.
6468
+ * @param {String} type The type of event to remove a listener from.
6469
+ * @param {Function} listener The function to remove from the event.
6470
+ * @return {void}
6471
+ * @method removeListener
6472
+ */
6473
+ removeListener: function(type, listener) {
6474
+ if (this._listeners[type]) {
6475
+ var listeners = this._listeners[type];
6476
+ for (var i=0, len=listeners.length; i < len; i++) {
6477
+ if (listeners[i] === listener) {
6478
+ listeners.splice(i, 1);
6479
  break;
6480
  }
 
 
6481
  }
6482
 
 
 
 
 
6483
 
6484
+ }
6485
  }
6486
+ };
6487
 
6488
+ },{}],24:[function(require,module,exports){
6489
+ "use strict";
6490
 
6491
+ module.exports = StringReader;
6492
 
6493
+ /**
6494
+ * Convenient way to read through strings.
6495
+ * @namespace parserlib.util
6496
+ * @class StringReader
6497
+ * @constructor
6498
+ * @param {String} text The text to read.
6499
+ */
6500
+ function StringReader(text) {
6501
+
6502
+ /**
6503
+ * The input text with line endings normalized.
6504
+ * @property _input
6505
+ * @type String
6506
+ * @private
6507
  */
6508
+ this._input = text.replace(/(\r\n?|\n)/g, "\n");
6509
 
 
 
 
6510
 
6511
+ /**
6512
+ * The row for the character to be read next.
6513
+ * @property _line
6514
+ * @type int
6515
+ * @private
6516
+ */
6517
+ this._line = 1;
6518
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6519
 
6520
+ /**
6521
+ * The column for the character to be read next.
6522
+ * @property _col
6523
+ * @type int
6524
+ * @private
6525
+ */
6526
+ this._col = 1;
6527
 
6528
+ /**
6529
+ * The index of the character in the input to be read next.
6530
+ * @property _cursor
6531
+ * @type int
6532
+ * @private
6533
+ */
6534
+ this._cursor = 0;
6535
+ }
6536
 
6537
+ StringReader.prototype = {
 
 
 
 
 
 
 
6538
 
6539
+ // restore constructor
6540
+ constructor: StringReader,
 
6541
 
6542
+ //-------------------------------------------------------------------------
6543
+ // Position info
6544
+ //-------------------------------------------------------------------------
6545
 
6546
+ /**
6547
+ * Returns the column of the character to be read next.
6548
+ * @return {int} The column of the character to be read next.
6549
+ * @method getCol
6550
  */
6551
+ getCol: function() {
6552
+ return this._col;
6553
+ },
6554
 
6555
+ /**
6556
+ * Returns the row of the character to be read next.
6557
+ * @return {int} The row of the character to be read next.
6558
+ * @method getLine
6559
+ */
6560
+ getLine: function() {
6561
+ return this._line;
6562
+ },
6563
 
6564
+ /**
6565
+ * Determines if you're at the end of the input.
6566
+ * @return {Boolean} True if there's no more input, false otherwise.
6567
+ * @method eof
6568
+ */
6569
+ eof: function() {
6570
+ return this._cursor === this._input.length;
6571
+ },
6572
 
6573
+ //-------------------------------------------------------------------------
6574
+ // Basic reading
6575
+ //-------------------------------------------------------------------------
6576
 
6577
+ /**
6578
+ * Reads the next character without advancing the cursor.
6579
+ * @param {int} count How many characters to look ahead (default is 1).
6580
+ * @return {String} The next character or null if there is no next character.
6581
+ * @method peek
6582
  */
6583
+ peek: function(count) {
6584
+ var c = null;
6585
+ count = typeof count === "undefined" ? 1 : count;
 
 
 
 
 
 
 
 
 
 
 
 
 
6586
 
6587
+ // if we're not at the end of the input...
6588
+ if (this._cursor < this._input.length) {
 
 
 
 
 
6589
 
6590
+ // get character and increment cursor and column
6591
+ c = this._input.charAt(this._cursor + count - 1);
6592
+ }
6593
+
6594
+ return c;
6595
+ },
6596
+
6597
+ /**
6598
+ * Reads the next character from the input and adjusts the row and column
6599
+ * accordingly.
6600
+ * @return {String} The next character or null if there is no next character.
6601
+ * @method read
6602
  */
6603
+ read: function() {
6604
+ var c = null;
6605
 
6606
+ // if we're not at the end of the input...
6607
+ if (this._cursor < this._input.length) {
6608
 
6609
+ // if the last character was a newline, increment row count
6610
+ // and reset column count
6611
+ if (this._input.charAt(this._cursor) === "\n") {
6612
+ this._line++;
6613
+ this._col=1;
6614
+ } else {
6615
+ this._col++;
6616
+ }
6617
 
6618
+ // get character and increment cursor and column
6619
+ c = this._input.charAt(this._cursor++);
6620
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6621
 
6622
+ return c;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6623
  },
6624
 
6625
+ //-------------------------------------------------------------------------
6626
+ // Misc
6627
+ //-------------------------------------------------------------------------
6628
+
6629
+ /**
6630
+ * Saves the current location so it can be returned to later.
6631
+ * @method mark
6632
+ * @return {void}
6633
+ */
6634
+ mark: function() {
6635
+ this._bookmark = {
6636
+ cursor: this._cursor,
6637
+ line: this._line,
6638
+ col: this._col
6639
+ };
6640
  },
6641
+
6642
+ reset: function() {
6643
+ if (this._bookmark) {
6644
+ this._cursor = this._bookmark.cursor;
6645
+ this._line = this._bookmark.line;
6646
+ this._col = this._bookmark.col;
6647
+ delete this._bookmark;
6648
+ }
6649
  },
 
 
 
 
 
6650
 
6651
+ //-------------------------------------------------------------------------
6652
+ // Advanced reading
6653
+ //-------------------------------------------------------------------------
6654
 
6655
+ /**
6656
+ * Reads up to and including the given string. Throws an error if that
6657
+ * string is not found.
6658
+ * @param {String} pattern The string to read.
6659
+ * @return {String} The string when it is found.
6660
+ * @throws Error when the string pattern is not found.
6661
+ * @method readTo
6662
+ */
6663
+ readTo: function(pattern) {
6664
 
6665
+ var buffer = "",
6666
+ c;
6667
+
6668
+ /*
6669
+ * First, buffer must be the same length as the pattern.
6670
+ * Then, buffer must end with the pattern or else reach the
6671
+ * end of the input.
6672
+ */
6673
+ while (buffer.length < pattern.length || buffer.lastIndexOf(pattern) !== buffer.length - pattern.length) {
6674
+ c = this.read();
6675
+ if (c) {
6676
+ buffer += c;
6677
  } else {
6678
+ throw new Error("Expected \"" + pattern + "\" at line " + this._line + ", col " + this._col + ".");
6679
  }
6680
  }
 
6681
 
6682
+ return buffer;
 
 
6683
 
6684
+ },
 
 
6685
 
6686
+ /**
6687
+ * Reads characters while each character causes the given
6688
+ * filter function to return true. The function is passed
6689
+ * in each character and either returns true to continue
6690
+ * reading or false to stop.
6691
+ * @param {Function} filter The function to read on each character.
6692
+ * @return {String} The string made up of all characters that passed the
6693
+ * filter check.
6694
+ * @method readWhile
6695
+ */
6696
+ readWhile: function(filter) {
6697
 
6698
+ var buffer = "",
6699
+ c = this.peek();
6700
 
6701
+ while (c !== null && filter(c)) {
6702
+ buffer += this.read();
6703
+ c = this.peek();
6704
+ }
6705
 
6706
+ return buffer;
6707
 
6708
+ },
 
 
6709
 
6710
+ /**
6711
+ * Reads characters that match either text or a regular expression and
6712
+ * returns those characters. If a match is found, the row and column
6713
+ * are adjusted; if no match is found, the reader's state is unchanged.
6714
+ * reading or false to stop.
6715
+ * @param {String|RegExp} matcher If a string, then the literal string
6716
+ * value is searched for. If a regular expression, then any string
6717
+ * matching the pattern is search for.
6718
+ * @return {String} The string made up of all characters that matched or
6719
+ * null if there was no match.
6720
+ * @method readMatch
6721
+ */
6722
+ readMatch: function(matcher) {
6723
 
6724
+ var source = this._input.substring(this._cursor),
6725
+ value = null;
 
 
 
 
 
 
 
 
 
 
 
6726
 
6727
+ // if it's a string, just do a straight match
6728
+ if (typeof matcher === "string") {
6729
+ if (source.slice(0, matcher.length) === matcher) {
6730
+ value = this.readCount(matcher.length);
6731
  }
6732
+ } else if (matcher instanceof RegExp) {
6733
+ if (matcher.test(source)) {
6734
+ value = this.readCount(RegExp.lastMatch.length);
 
 
 
 
 
 
 
 
 
 
 
6735
  }
 
6736
  }
6737
 
6738
+ return value;
6739
  },
6740
 
 
6741
 
6742
+ /**
6743
+ * Reads a given number of characters. If the end of the input is reached,
6744
+ * it reads only the remaining characters and does not throw an error.
6745
+ * @param {int} count The number of characters to read.
6746
+ * @return {String} The string made up the read characters.
6747
+ * @method readCount
6748
+ */
6749
+ readCount: function(count) {
6750
+ var buffer = "";
6751
 
6752
+ while (count--) {
6753
+ buffer += this.read();
 
 
 
 
6754
  }
6755
 
6756
+ return buffer;
6757
+ }
 
 
 
 
 
 
 
 
 
6758
 
6759
+ };
6760
 
6761
+ },{}],25:[function(require,module,exports){
6762
+ "use strict";
6763
 
6764
+ module.exports = SyntaxError;
 
 
 
 
6765
 
6766
+ /**
6767
+ * Type to use when a syntax error occurs.
6768
+ * @class SyntaxError
6769
+ * @namespace parserlib.util
6770
+ * @constructor
6771
+ * @param {String} message The error message.
6772
+ * @param {int} line The line at which the error occurred.
6773
+ * @param {int} col The column at which the error occurred.
6774
+ */
6775
+ function SyntaxError(message, line, col) {
6776
+ Error.call(this);
6777
+ this.name = this.constructor.name;
6778
 
6779
+ /**
6780
+ * The column at which the error occurred.
6781
+ * @type int
6782
+ * @property col
6783
+ */
6784
+ this.col = col;
 
 
 
6785
 
6786
+ /**
6787
+ * The line at which the error occurred.
6788
+ * @type int
6789
+ * @property line
6790
+ */
6791
+ this.line = line;
6792
 
6793
+ /**
6794
+ * The text representation of the unit.
6795
+ * @type String
6796
+ * @property text
6797
+ */
6798
+ this.message = message;
 
 
 
 
 
 
6799
 
6800
+ }
 
 
 
6801
 
6802
+ //inherit from Error
6803
+ SyntaxError.prototype = Object.create(Error.prototype); // jshint ignore:line
6804
+ SyntaxError.prototype.constructor = SyntaxError; // jshint ignore:line
6805
 
6806
+ },{}],26:[function(require,module,exports){
6807
+ "use strict";
6808
 
6809
+ module.exports = SyntaxUnit;
6810
+
6811
+ /**
6812
+ * Base type to represent a single syntactic unit.
6813
+ * @class SyntaxUnit
6814
+ * @namespace parserlib.util
6815
+ * @constructor
6816
+ * @param {String} text The text of the unit.
6817
+ * @param {int} line The line of text on which the unit resides.
6818
+ * @param {int} col The column of text on which the unit resides.
6819
+ */
6820
+ function SyntaxUnit(text, line, col, type) {
6821
+
6822
+
6823
+ /**
6824
+ * The column of text on which the unit resides.
6825
+ * @type int
6826
+ * @property col
6827
+ */
6828
+ this.col = col;
6829
+
6830
+ /**
6831
+ * The line of text on which the unit resides.
6832
+ * @type int
6833
+ * @property line
6834
+ */
6835
+ this.line = line;
6836
+
6837
+ /**
6838
+ * The text representation of the unit.
6839
+ * @type String
6840
+ * @property text
6841
+ */
6842
+ this.text = text;
6843
+
6844
+ /**
6845
+ * The type of syntax unit.
6846
+ * @type int
6847
+ * @property type
6848
+ */
6849
+ this.type = type;
6850
+ }
6851
+
6852
+ /**
6853
+ * Create a new syntax unit based solely on the given token.
6854
+ * Convenience method for creating a new syntax unit when
6855
+ * it represents a single token instead of multiple.
6856
+ * @param {Object} token The token object to represent.
6857
+ * @return {parserlib.util.SyntaxUnit} The object representing the token.
6858
+ * @static
6859
+ * @method fromToken
6860
+ */
6861
+ SyntaxUnit.fromToken = function(token) {
6862
+ return new SyntaxUnit(token.value, token.startLine, token.startCol);
6863
+ };
6864
+
6865
+ SyntaxUnit.prototype = {
6866
 
6867
+ //restore constructor
6868
+ constructor: SyntaxUnit,
6869
+
6870
+ /**
6871
+ * Returns the text representation of the unit.
6872
+ * @return {String} The text representation of the unit.
6873
+ * @method valueOf
6874
+ */
6875
+ valueOf: function() {
6876
+ return this.toString();
6877
+ },
6878
 
6879
+ /**
6880
+ * Returns the text representation of the unit.
6881
+ * @return {String} The text representation of the unit.
6882
+ * @method toString
6883
+ */
6884
+ toString: function() {
6885
+ return this.text;
6886
+ }
6887
 
6888
+ };
 
 
 
 
 
 
 
6889
 
6890
+ },{}],27:[function(require,module,exports){
6891
+ "use strict";
 
 
 
 
 
 
 
 
 
 
6892
 
6893
+ module.exports = TokenStreamBase;
6894
 
6895
+ var StringReader = require("./StringReader");
6896
+ var SyntaxError = require("./SyntaxError");
6897
 
 
6898
  /**
6899
+ * Generic TokenStream providing base functionality.
6900
+ * @class TokenStreamBase
6901
  * @namespace parserlib.util
6902
  * @constructor
6903
+ * @param {String|StringReader} input The text to tokenize or a reader from
6904
+ * which to read the input.
 
6905
  */
6906
+ function TokenStreamBase(input, tokenData) {
6907
 
6908
  /**
6909
+ * The string reader for easy access to the text.
6910
+ * @type StringReader
6911
+ * @property _reader
6912
+ * @private
6913
  */
6914
+ this._reader = new StringReader(input ? input.toString() : "");
6915
 
6916
  /**
6917
+ * Token object for the last consumed token.
6918
+ * @type Token
6919
+ * @property _token
6920
+ * @private
6921
  */
6922
+ this._token = null;
6923
 
6924
  /**
6925
+ * The array of token information.
6926
+ * @type Array
6927
+ * @property _tokenData
6928
+ * @private
6929
  */
6930
+ this._tokenData = tokenData;
6931
+
6932
+ /**
6933
+ * Lookahead token buffer.
6934
+ * @type Array
6935
+ * @property _lt
6936
+ * @private
6937
+ */
6938
+ this._lt = [];
6939
+
6940
+ /**
6941
+ * Lookahead token buffer index.
6942
+ * @type int
6943
+ * @property _ltIndex
6944
+ * @private
6945
+ */
6946
+ this._ltIndex = 0;
6947
 
6948
+ this._ltIndexCache = [];
6949
  }
6950
 
6951
+ /**
6952
+ * Accepts an array of token information and outputs
6953
+ * an array of token data containing key-value mappings
6954
+ * and matching functions that the TokenStream needs.
6955
+ * @param {Array} tokens An array of token descriptors.
6956
+ * @return {Array} An array of processed token data.
6957
+ * @method createTokenData
6958
+ * @static
6959
+ */
6960
+ TokenStreamBase.createTokenData = function(tokens) {
6961
 
6962
+ var nameMap = [],
6963
+ typeMap = Object.create(null),
6964
+ tokenData = tokens.concat([]),
6965
+ i = 0,
6966
+ len = tokenData.length+1;
6967
 
6968
+ tokenData.UNKNOWN = -1;
6969
+ tokenData.unshift({ name:"EOF" });
6970
+
6971
+ for (; i < len; i++) {
6972
+ nameMap.push(tokenData[i].name);
6973
+ tokenData[tokenData[i].name] = i;
6974
+ if (tokenData[i].text) {
6975
+ typeMap[tokenData[i].text] = i;
6976
  }
6977
+ }
6978
 
6979
+ tokenData.name = function(tt) {
6980
+ return nameMap[tt];
6981
+ };
6982
 
6983
+ tokenData.type = function(c) {
6984
+ return typeMap[c];
6985
+ };
6986
 
6987
+ return tokenData;
6988
+ };
 
6989
 
6990
+ TokenStreamBase.prototype = {
 
 
 
 
 
 
6991
 
6992
+ //restore constructor
6993
+ constructor: TokenStreamBase,
 
6994
 
6995
+ //-------------------------------------------------------------------------
6996
+ // Matching methods
6997
+ //-------------------------------------------------------------------------
6998
 
6999
  /**
7000
+ * Determines if the next token matches the given token type.
7001
+ * If so, that token is consumed; if not, the token is placed
7002
+ * back onto the token stream. You can pass in any number of
7003
+ * token types and this will return true if any of the token
7004
+ * types is found.
7005
+ * @param {int|int[]} tokenTypes Either a single token type or an array of
7006
+ * token types that the next token might be. If an array is passed,
7007
+ * it's assumed that the token can be any of these.
7008
+ * @param {variant} channel (Optional) The channel to read from. If not
7009
+ * provided, reads from the default (unnamed) channel.
7010
+ * @return {Boolean} True if the token type matches, false if not.
7011
+ * @method match
7012
  */
7013
+ match: function(tokenTypes, channel) {
 
 
7014
 
7015
+ //always convert to an array, makes things easier
7016
+ if (!(tokenTypes instanceof Array)) {
7017
+ tokenTypes = [tokenTypes];
7018
  }
7019
 
7020
+ var tt = this.get(channel),
7021
+ i = 0,
7022
+ len = tokenTypes.length;
 
 
 
 
 
 
 
7023
 
7024
+ while (i < len) {
7025
+ if (tt === tokenTypes[i++]) {
7026
+ return true;
 
 
 
 
 
 
7027
  }
 
 
7028
  }
7029
 
7030
+ //no match found, put the token back
7031
+ this.unget();
7032
+ return false;
7033
  },
7034
 
7035
+ /**
7036
+ * Determines if the next token matches the given token type.
7037
+ * If so, that token is consumed; if not, an error is thrown.
7038
+ * @param {int|int[]} tokenTypes Either a single token type or an array of
7039
+ * token types that the next token should be. If an array is passed,
7040
+ * it's assumed that the token must be one of these.
7041
+ * @return {void}
7042
+ * @method mustMatch
7043
+ */
7044
+ mustMatch: function(tokenTypes) {
7045
 
7046
+ var token;
7047
 
7048
+ //always convert to an array, makes things easier
7049
+ if (!(tokenTypes instanceof Array)) {
7050
+ tokenTypes = [tokenTypes];
7051
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
7052
 
7053
+ if (!this.match.apply(this, arguments)) {
7054
+ token = this.LT(1);
7055
+ throw new SyntaxError("Expected " + this._tokenData[tokenTypes[0]].name +
7056
+ " at line " + token.startLine + ", col " + token.startCol + ".", token.startLine, token.startCol);
7057
+ }
7058
+ },
7059
 
7060
+ //-------------------------------------------------------------------------
7061
+ // Consuming methods
7062
+ //-------------------------------------------------------------------------
7063
 
7064
+ /**
7065
+ * Keeps reading from the token stream until either one of the specified
7066
+ * token types is found or until the end of the input is reached.
7067
+ * @param {int|int[]} tokenTypes Either a single token type or an array of
7068
+ * token types that the next token should be. If an array is passed,
7069
+ * it's assumed that the token must be one of these.
7070
+ * @param {variant} channel (Optional) The channel to read from. If not
7071
+ * provided, reads from the default (unnamed) channel.
7072
+ * @return {void}
7073
+ * @method advance
7074
+ */
7075
+ advance: function(tokenTypes, channel) {
7076
 
7077
+ while (this.LA(0) !== 0 && !this.match(tokenTypes, channel)) {
7078
+ this.get();
7079
+ }
7080
 
7081
+ return this.LA(0);
7082
+ },
 
 
7083
 
7084
+ /**
7085
+ * Consumes the next token from the token stream.
7086
+ * @return {int} The token type of the token that was just consumed.
7087
+ * @method get
7088
+ */
7089
+ get: function(channel) {
 
7090
 
7091
+ var tokenInfo = this._tokenData,
7092
+ i =0,
7093
+ token,
7094
+ info;
7095
 
7096
+ //check the lookahead buffer first
7097
+ if (this._lt.length && this._ltIndex >= 0 && this._ltIndex < this._lt.length) {
 
7098
 
7099
+ i++;
7100
+ this._token = this._lt[this._ltIndex++];
7101
+ info = tokenInfo[this._token.type];
7102
 
7103
+ //obey channels logic
7104
+ while ((info.channel !== undefined && channel !== info.channel) &&
7105
+ this._ltIndex < this._lt.length) {
7106
+ this._token = this._lt[this._ltIndex++];
7107
+ info = tokenInfo[this._token.type];
7108
+ i++;
7109
+ }
7110
 
7111
+ //here be dragons
7112
+ if ((info.channel === undefined || channel === info.channel) &&
7113
+ this._ltIndex <= this._lt.length) {
7114
+ this._ltIndexCache.push(i);
7115
+ return this._token.type;
7116
+ }
7117
+ }
7118
 
7119
+ //call token retriever method
7120
+ token = this._getToken();
 
7121
 
7122
+ //if it should be hidden, don't save a token
7123
+ if (token.type > -1 && !tokenInfo[token.type].hide) {
 
7124
 
7125
+ //apply token channel
7126
+ token.channel = tokenInfo[token.type].channel;
 
7127
 
7128
+ //save for later
7129
+ this._token = token;
7130
+ this._lt.push(token);
7131
 
7132
+ //save space that will be moved (must be done before array is truncated)
7133
+ this._ltIndexCache.push(this._lt.length - this._ltIndex + i);
 
7134
 
7135
+ //keep the buffer under 5 items
7136
+ if (this._lt.length > 5) {
7137
+ this._lt.shift();
7138
+ }
7139
 
7140
+ //also keep the shift buffer under 5 items
7141
+ if (this._ltIndexCache.length > 5) {
7142
+ this._ltIndexCache.shift();
7143
+ }
7144
 
7145
+ //update lookahead index
7146
+ this._ltIndex = this._lt.length;
7147
+ }
7148
 
7149
+ /*
7150
+ * Skip to the next token if:
7151
+ * 1. The token type is marked as hidden.
7152
+ * 2. The token type has a channel specified and it isn't the current channel.
7153
+ */
7154
+ info = tokenInfo[token.type];
7155
+ if (info &&
7156
+ (info.hide ||
7157
+ (info.channel !== undefined && channel !== info.channel))) {
7158
+ return this.get(channel);
7159
+ } else {
7160
+ //return just the type
7161
+ return token.type;
7162
  }
7163
  },
7164
 
7165
+ /**
7166
+ * Looks ahead a certain number of tokens and returns the token type at
7167
+ * that position. This will throw an error if you lookahead past the
7168
+ * end of input, past the size of the lookahead buffer, or back past
7169
+ * the first token in the lookahead buffer.
7170
+ * @param {int} The index of the token type to retrieve. 0 for the
7171
+ * current token, 1 for the next, -1 for the previous, etc.
7172
+ * @return {int} The token type of the token in the given position.
7173
+ * @method LA
7174
+ */
7175
+ LA: function(index) {
7176
+ var total = index,
7177
+ tt;
7178
+ if (index > 0) {
7179
+ //TODO: Store 5 somewhere
7180
+ if (index > 5) {
7181
+ throw new Error("Too much lookahead.");
7182
+ }
7183
 
7184
+ //get all those tokens
7185
+ while (total) {
7186
+ tt = this.get();
7187
+ total--;
7188
  }
7189
 
7190
+ //unget all those tokens
7191
+ while (total < index) {
7192
+ this.unget();
7193
+ total++;
7194
+ }
7195
+ } else if (index < 0) {
 
 
 
 
 
7196
 
7197
+ if (this._lt[this._ltIndex+index]) {
7198
+ tt = this._lt[this._ltIndex+index].type;
 
 
 
 
 
 
7199
  } else {
7200
+ throw new Error("Too much lookbehind.");
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7201
  }
7202
 
7203
+ } else {
7204
+ tt = this._token.type;
7205
+ }
7206
 
7207
+ return tt;
 
 
 
 
 
 
7208
 
7209
+ },
 
 
 
 
 
7210
 
7211
+ /**
7212
+ * Looks ahead a certain number of tokens and returns the token at
7213
+ * that position. This will throw an error if you lookahead past the
7214
+ * end of input, past the size of the lookahead buffer, or back past
7215
+ * the first token in the lookahead buffer.
7216
+ * @param {int} The index of the token type to retrieve. 0 for the
7217
+ * current token, 1 for the next, -1 for the previous, etc.
7218
+ * @return {Object} The token of the token in the given position.
7219
+ * @method LA
7220
+ */
7221
+ LT: function(index) {
7222
 
7223
+ //lookahead first to prime the token buffer
7224
+ this.LA(index);
 
 
 
7225
 
7226
+ //now find the token, subtract one because _ltIndex is already at the next index
7227
+ return this._lt[this._ltIndex+index-1];
7228
+ },
7229
 
7230
+ /**
7231
+ * Returns the token type for the next token in the stream without
7232
+ * consuming it.
7233
+ * @return {int} The token type of the next token in the stream.
7234
+ * @method peek
7235
+ */
7236
+ peek: function() {
7237
+ return this.LA(1);
7238
+ },
7239
 
7240
+ /**
7241
+ * Returns the actual token object for the last consumed token.
7242
+ * @return {Token} The token object for the last consumed token.
7243
+ * @method token
7244
+ */
7245
+ token: function() {
7246
+ return this._token;
7247
+ },
7248
 
7249
+ /**
7250
+ * Returns the name of the token for the given token type.
7251
+ * @param {int} tokenType The type of token to get the name of.
7252
+ * @return {String} The name of the token or "UNKNOWN_TOKEN" for any
7253
+ * invalid token type.
7254
+ * @method tokenName
7255
+ */
7256
+ tokenName: function(tokenType) {
7257
+ if (tokenType < 0 || tokenType > this._tokenData.length) {
7258
+ return "UNKNOWN_TOKEN";
7259
+ } else {
7260
+ return this._tokenData[tokenType].name;
7261
+ }
7262
+ },
7263
 
7264
+ /**
7265
+ * Returns the token type value for the given token name.
7266
+ * @param {String} tokenName The name of the token whose value should be returned.
7267
+ * @return {int} The token type value for the given token name or -1
7268
+ * for an unknown token.
7269
+ * @method tokenName
7270
+ */
7271
+ tokenType: function(tokenName) {
7272
+ return this._tokenData[tokenName] || -1;
7273
+ },
7274
 
7275
+ /**
7276
+ * Returns the last consumed token to the token stream.
7277
+ * @method unget
7278
+ */
7279
+ unget: function() {
7280
+ //if (this._ltIndex > -1) {
7281
+ if (this._ltIndexCache.length) {
7282
+ this._ltIndex -= this._ltIndexCache.pop();//--;
7283
+ this._token = this._lt[this._ltIndex - 1];
7284
+ } else {
7285
+ throw new Error("Too much lookahead.");
7286
+ }
7287
+ }
7288
 
7289
+ };
7290
 
 
 
 
7291
 
7292
+ },{"./StringReader":24,"./SyntaxError":25}],28:[function(require,module,exports){
7293
+ "use strict";
 
7294
 
7295
+ module.exports = {
7296
+ StringReader : require("./StringReader"),
7297
+ SyntaxError : require("./SyntaxError"),
7298
+ SyntaxUnit : require("./SyntaxUnit"),
7299
+ EventTarget : require("./EventTarget"),
7300
+ TokenStreamBase : require("./TokenStreamBase")
7301
+ };
7302
 
7303
+ },{"./EventTarget":23,"./StringReader":24,"./SyntaxError":25,"./SyntaxUnit":26,"./TokenStreamBase":27}],"parserlib":[function(require,module,exports){
7304
+ "use strict";
7305
 
7306
+ module.exports = {
7307
+ css : require("./css"),
7308
+ util : require("./util")
7309
+ };
7310
 
7311
+ },{"./css":22,"./util":28}]},{},[]);
 
 
7312
 
7313
+ return require('parserlib');
7314
+ })();
7315
+ var clone = (function() {
7316
+ 'use strict';
7317
 
7318
+ /**
7319
+ * Clones (copies) an Object using deep copying.
7320
+ *
7321
+ * This function supports circular references by default, but if you are certain
7322
+ * there are no circular references in your object, you can save some CPU time
7323
+ * by calling clone(obj, false).
7324
+ *
7325
+ * Caution: if `circular` is false and `parent` contains circular references,
7326
+ * your program may enter an infinite loop and crash.
7327
+ *
7328
+ * @param `parent` - the object to be cloned
7329
+ * @param `circular` - set to true if the object to be cloned may contain
7330
+ * circular references. (optional - true by default)
7331
+ * @param `depth` - set to a number if the object is only to be cloned to
7332
+ * a particular depth. (optional - defaults to Infinity)
7333
+ * @param `prototype` - sets the prototype to be used when cloning an object.
7334
+ * (optional - defaults to parent prototype).
7335
+ */
7336
+ function clone(parent, circular, depth, prototype) {
7337
+ var filter;
7338
+ if (typeof circular === 'object') {
7339
+ depth = circular.depth;
7340
+ prototype = circular.prototype;
7341
+ filter = circular.filter;
7342
+ circular = circular.circular
7343
+ }
7344
+ // maintain two arrays for circular references, where corresponding parents
7345
+ // and children have the same index
7346
+ var allParents = [];
7347
+ var allChildren = [];
7348
+
7349
+ var useBuffer = typeof Buffer != 'undefined';
7350
+
7351
+ if (typeof circular == 'undefined')
7352
+ circular = true;
7353
+
7354
+ if (typeof depth == 'undefined')
7355
+ depth = Infinity;
7356
+
7357
+ // recurse this function so we don't reset allParents and allChildren
7358
+ function _clone(parent, depth) {
7359
+ // cloning null always returns null
7360
+ if (parent === null)
7361
+ return null;
7362
+
7363
+ if (depth == 0)
7364
+ return parent;
7365
+
7366
+ var child;
7367
+ var proto;
7368
+ if (typeof parent != 'object') {
7369
+ return parent;
7370
+ }
7371
 
7372
+ if (clone.__isArray(parent)) {
7373
+ child = [];
7374
+ } else if (clone.__isRegExp(parent)) {
7375
+ child = new RegExp(parent.source, __getRegExpFlags(parent));
7376
+ if (parent.lastIndex) child.lastIndex = parent.lastIndex;
7377
+ } else if (clone.__isDate(parent)) {
7378
+ child = new Date(parent.getTime());
7379
+ } else if (useBuffer && Buffer.isBuffer(parent)) {
7380
+ child = new Buffer(parent.length);
7381
+ parent.copy(child);
7382
+ return child;
7383
+ } else {
7384
+ if (typeof prototype == 'undefined') {
7385
+ proto = Object.getPrototypeOf(parent);
7386
+ child = Object.create(proto);
7387
+ }
7388
+ else {
7389
+ child = Object.create(prototype);
7390
+ proto = prototype;
7391
+ }
7392
+ }
7393
 
7394
+ if (circular) {
7395
+ var index = allParents.indexOf(parent);
7396
 
7397
+ if (index != -1) {
7398
+ return allChildren[index];
7399
+ }
7400
+ allParents.push(parent);
7401
+ allChildren.push(child);
7402
+ }
7403
 
7404
+ for (var i in parent) {
7405
+ var attrs;
7406
+ if (proto) {
7407
+ attrs = Object.getOwnPropertyDescriptor(proto, i);
7408
+ }
7409
 
7410
+ if (attrs && attrs.set == null) {
7411
+ continue;
7412
+ }
7413
+ child[i] = _clone(parent[i], depth - 1);
7414
  }
 
7415
 
7416
+ return child;
7417
+ }
7418
+
7419
+ return _clone(parent, depth);
7420
+ }
7421
+
7422
+ /**
7423
+ * Simple flat clone using prototype, accepts only objects, usefull for property
7424
+ * override on FLAT configuration object (no nested props).
7425
+ *
7426
+ * USE WITH CAUTION! This may not behave as you wish if you do not know how this
7427
+ * works.
7428
+ */
7429
+ clone.clonePrototype = function clonePrototype(parent) {
7430
+ if (parent === null)
7431
+ return null;
7432
+
7433
+ var c = function () {};
7434
+ c.prototype = parent;
7435
+ return new c();
7436
+ };
7437
 
7438
+ // private utility functions
7439
 
7440
+ function __objToStr(o) {
7441
+ return Object.prototype.toString.call(o);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7442
  };
7443
+ clone.__objToStr = __objToStr;
7444
 
7445
+ function __isDate(o) {
7446
+ return typeof o === 'object' && __objToStr(o) === '[object Date]';
7447
+ };
7448
+ clone.__isDate = __isDate;
7449
 
7450
+ function __isArray(o) {
7451
+ return typeof o === 'object' && __objToStr(o) === '[object Array]';
7452
+ };
7453
+ clone.__isArray = __isArray;
7454
 
7455
+ function __isRegExp(o) {
7456
+ return typeof o === 'object' && __objToStr(o) === '[object RegExp]';
7457
+ };
7458
+ clone.__isRegExp = __isRegExp;
7459
+
7460
+ function __getRegExpFlags(re) {
7461
+ var flags = '';
7462
+ if (re.global) flags += 'g';
7463
+ if (re.ignoreCase) flags += 'i';
7464
+ if (re.multiline) flags += 'm';
7465
+ return flags;
7466
+ };
7467
+ clone.__getRegExpFlags = __getRegExpFlags;
7468
 
7469
+ return clone;
 
 
 
7470
  })();
7471
 
7472
+ if (typeof module === 'object' && module.exports) {
7473
+ module.exports = clone;
7474
+ }
7475
 
7476
  /**
7477
  * Main CSSLint object.
7479
  * @static
7480
  * @extends parserlib.util.EventTarget
7481
  */
7482
+
7483
+ /* global parserlib, clone, Reporter */
7484
+ /* exported CSSLint */
7485
+
7486
+ var CSSLint = (function() {
7487
+ "use strict";
7488
 
7489
  var rules = [],
7490
  formatters = [],
7491
+ embeddedRuleset = /\/\*\s*csslint([^\*]*)\*\//,
7492
  api = new parserlib.util.EventTarget();
7493
 
7494
+ api.version = "1.0.3";
7495
 
7496
  //-------------------------------------------------------------------------
7497
  // Rule Management
7502
  * @param {Object} rule The rule to add.
7503
  * @method addRule
7504
  */
7505
+ api.addRule = function(rule) {
7506
  rules.push(rule);
7507
  rules[rule.id] = rule;
7508
  };
7511
  * Clears all rule from the engine.
7512
  * @method clearRules
7513
  */
7514
+ api.clearRules = function() {
7515
  rules = [];
7516
  };
7517
 
7520
  * @return An array of rule objects.
7521
  * @method getRules
7522
  */
7523
+ api.getRules = function() {
7524
+ return [].concat(rules).sort(function(a, b) {
7525
  return a.id > b.id ? 1 : 0;
7526
  });
7527
  };
7536
  i = 0,
7537
  len = rules.length;
7538
 
7539
+ while (i < len) {
7540
+ ruleset[rules[i++].id] = 1; // by default, everything is a warning
7541
  }
7542
 
7543
  return ruleset;
7550
  * @return {Object} A ruleset object.
7551
  * @method getEmbeddedRuleset
7552
  */
7553
+ function applyEmbeddedRuleset(text, ruleset) {
7554
  var valueMap,
7555
  embedded = text && text.match(embeddedRuleset),
7556
  rules = embedded && embedded[1];
7566
  "0": 0 // explicit ignore
7567
  };
7568
 
7569
+ rules.toLowerCase().split(",").forEach(function(rule) {
7570
  var pair = rule.split(":"),
7571
  property = pair[0] || "",
7572
  value = pair[1] || "";
7598
  * @return {Object} The formatter or undefined.
7599
  * @method getFormatter
7600
  */
7601
+ api.getFormatter = function(formatId) {
7602
  return formatters[formatId];
7603
  };
7604
 
7615
  var formatter = this.getFormatter(formatId),
7616
  result = null;
7617
 
7618
+ if (formatter) {
7619
  result = formatter.startFormat();
7620
  result += formatter.formatResults(results, filename, options || {});
7621
  result += formatter.endFormat();
7630
  * @return {Boolean} True if the format exists, false if not.
7631
  * @method hasFormat
7632
  */
7633
+ api.hasFormat = function(formatId) {
7634
  return formatters.hasOwnProperty(formatId);
7635
  };
7636
 
7647
  * @return {Object} Results of the verification.
7648
  * @method verify
7649
  */
7650
+ api.verify = function(text, ruleset) {
7651
 
7652
+ var i = 0,
 
7653
  reporter,
7654
  lines,
7655
+ allow = {},
7656
+ ignore = [],
7657
  report,
7658
+ parser = new parserlib.css.Parser({
7659
+ starHack: true,
7660
+ ieFilters: true,
7661
+ underscoreHack: true,
7662
+ strict: false
7663
+ });
7664
 
7665
  // normalize line endings
7666
+ lines = text.replace(/\n\r?/g, "$split$").split("$split$");
7667
 
7668
+ // find 'allow' comments
7669
+ CSSLint.Util.forEach(lines, function (line, lineno) {
7670
+ var allowLine = line && line.match(/\/\*[ \t]*csslint[ \t]+allow:[ \t]*([^\*]*)\*\//i),
7671
+ allowRules = allowLine && allowLine[1],
7672
+ allowRuleset = {};
7673
+
7674
+ if (allowRules) {
7675
+ allowRules.toLowerCase().split(",").forEach(function(allowRule) {
7676
+ allowRuleset[allowRule.trim()] = true;
7677
+ });
7678
+ if (Object.keys(allowRuleset).length > 0) {
7679
+ allow[lineno + 1] = allowRuleset;
7680
+ }
7681
+ }
7682
+ });
7683
+
7684
+ var ignoreStart = null,
7685
+ ignoreEnd = null;
7686
+ CSSLint.Util.forEach(lines, function (line, lineno) {
7687
+ // Keep oldest, "unclosest" ignore:start
7688
+ if (ignoreStart === null && line.match(/\/\*[ \t]*csslint[ \t]+ignore:start[ \t]*\*\//i)) {
7689
+ ignoreStart = lineno;
7690
+ }
7691
+
7692
+ if (line.match(/\/\*[ \t]*csslint[ \t]+ignore:end[ \t]*\*\//i)) {
7693
+ ignoreEnd = lineno;
7694
+ }
7695
+
7696
+ if (ignoreStart !== null && ignoreEnd !== null) {
7697
+ ignore.push([ignoreStart, ignoreEnd]);
7698
+ ignoreStart = ignoreEnd = null;
7699
+ }
7700
+ });
7701
+
7702
+ // Close remaining ignore block, if any
7703
+ if (ignoreStart !== null) {
7704
+ ignore.push([ignoreStart, lines.length]);
7705
+ }
7706
+
7707
+ if (!ruleset) {
7708
  ruleset = this.getRuleset();
7709
  }
7710
 
7711
+ if (embeddedRuleset.test(text)) {
7712
+ // defensively copy so that caller's version does not get modified
7713
+ ruleset = clone(ruleset);
7714
  ruleset = applyEmbeddedRuleset(text, ruleset);
7715
  }
7716
 
7717
+ reporter = new Reporter(lines, ruleset, allow, ignore);
7718
 
7719
+ ruleset.errors = 2; // always report parsing errors as errors
7720
+ for (i in ruleset) {
7721
+ if (ruleset.hasOwnProperty(i) && ruleset[i]) {
7722
+ if (rules[i]) {
7723
  rules[i].init(parser, reporter);
7724
  }
7725
  }
7726
  }
7727
 
7728
 
7729
+ // capture most horrible error type
7730
  try {
7731
  parser.parse(text);
7732
  } catch (ex) {
7736
  report = {
7737
  messages : reporter.messages,
7738
  stats : reporter.stats,
7739
+ ruleset : reporter.ruleset,
7740
+ allow : reporter.allow,
7741
+ ignore : reporter.ignore
7742
  };
7743
 
7744
+ // sort by line numbers, rollups at the bottom
7745
+ report.messages.sort(function (a, b) {
7746
+ if (a.rollup && !b.rollup) {
7747
  return 1;
7748
+ } else if (!a.rollup && b.rollup) {
7749
  return -1;
7750
  } else {
7751
  return a.line - b.line;
7763
 
7764
  })();
7765
 
 
7766
  /**
7767
  * An instance of Report is used to report results of the
7768
  * verification back to the main API.
7771
  * @param {String[]} lines The text lines of the source.
7772
  * @param {Object} ruleset The set of rules to work with, including if
7773
  * they are errors or warnings.
7774
+ * @param {Object} explicitly allowed lines
7775
+ * @param {[][]} ingore list of line ranges to be ignored
7776
  */
7777
+ function Reporter(lines, ruleset, allow, ignore) {
7778
+ "use strict";
7779
 
7780
  /**
7781
  * List of messages being reported.
7806
  * @type Object
7807
  */
7808
  this.ruleset = ruleset;
7809
+
7810
+ /**
7811
+ * Lines with specific rule messages to leave out of the report.
7812
+ * @property allow
7813
+ * @type Object
7814
+ */
7815
+ this.allow = allow;
7816
+ if (!this.allow) {
7817
+ this.allow = {};
7818
+ }
7819
+
7820
+ /**
7821
+ * Linesets not to include in the report.
7822
+ * @property ignore
7823
+ * @type [][]
7824
+ */
7825
+ this.ignore = ignore;
7826
+ if (!this.ignore) {
7827
+ this.ignore = [];
7828
+ }
7829
  }
7830
 
7831
  Reporter.prototype = {
7832
 
7833
+ // restore constructor
7834
  constructor: Reporter,
7835
 
7836
  /**
7841
  * @param {Object} rule The rule this message relates to.
7842
  * @method error
7843
  */
7844
+ error: function(message, line, col, rule) {
7845
+ "use strict";
7846
  this.messages.push({
7847
  type : "error",
7848
  line : line,
7862
  * @method warn
7863
  * @deprecated Use report instead.
7864
  */
7865
+ warn: function(message, line, col, rule) {
7866
+ "use strict";
7867
  this.report(message, line, col, rule);
7868
  },
7869
 
7875
  * @param {Object} rule The rule this message relates to.
7876
  * @method report
7877
  */
7878
+ report: function(message, line, col, rule) {
7879
+ "use strict";
7880
+
7881
+ // Check if rule violation should be allowed
7882
+ if (this.allow.hasOwnProperty(line) && this.allow[line].hasOwnProperty(rule.id)) {
7883
+ return;
7884
+ }
7885
+
7886
+ var ignore = false;
7887
+ CSSLint.Util.forEach(this.ignore, function (range) {
7888
+ if (range[0] <= line && line <= range[1]) {
7889
+ ignore = true;
7890
+ }
7891
+ });
7892
+ if (ignore) {
7893
+ return;
7894
+ }
7895
+
7896
  this.messages.push({
7897
+ type : this.ruleset[rule.id] === 2 ? "error" : "warning",
7898
  line : line,
7899
  col : col,
7900
  message : message,
7911
  * @param {Object} rule The rule this message relates to.
7912
  * @method info
7913
  */
7914
+ info: function(message, line, col, rule) {
7915
+ "use strict";
7916
  this.messages.push({
7917
  type : "info",
7918
  line : line,
7929
  * @param {Object} rule The rule this message relates to.
7930
  * @method rollupError
7931
  */
7932
+ rollupError: function(message, rule) {
7933
+ "use strict";
7934
  this.messages.push({
7935
  type : "error",
7936
  rollup : true,
7945
  * @param {Object} rule The rule this message relates to.
7946
  * @method rollupWarn
7947
  */
7948
+ rollupWarn: function(message, rule) {
7949
+ "use strict";
7950
  this.messages.push({
7951
  type : "warning",
7952
  rollup : true,
7961
  * @param {Variant} value The value of the stat.
7962
  * @method stat
7963
  */
7964
+ stat: function(name, value) {
7965
+ "use strict";
7966
  this.stats[name] = value;
7967
  }
7968
  };
7969
 
7970
+ // expose for testing purposes
7971
  CSSLint._Reporter = Reporter;
7972
 
 
 
7973
  /*
7974
  * Utility functions that make life easier.
7975
  */
7977
  /*
7978
  * Adds all properties from supplier onto receiver,
7979
  * overwriting if the same name already exists on
7980
+ * receiver.
7981
  * @param {Object} The object to receive the properties.
7982
  * @param {Object} The object to provide the properties.
7983
  * @return {Object} The receiver
7984
  */
7985
+ mix: function(receiver, supplier) {
7986
+ "use strict";
7987
  var prop;
7988
 
7989
+ for (prop in supplier) {
7990
+ if (supplier.hasOwnProperty(prop)) {
7991
  receiver[prop] = supplier[prop];
7992
  }
7993
  }
8001
  * @param {Variant} value The value to search for.
8002
  * @return {int} The index of the value if found, -1 if not.
8003
  */
8004
+ indexOf: function(values, value) {
8005
+ "use strict";
8006
+ if (values.indexOf) {
8007
  return values.indexOf(value);
8008
  } else {
8009
+ for (var i=0, len=values.length; i < len; i++) {
8010
+ if (values[i] === value) {
8011
  return i;
8012
  }
8013
  }
8022
  * @return {void}
8023
  */
8024
  forEach: function(values, func) {
8025
+ "use strict";
8026
+ if (values.forEach) {
8027
  return values.forEach(func);
8028
  } else {
8029
+ for (var i=0, len=values.length; i < len; i++) {
8030
  func(values[i], i, values);
8031
  }
8032
  }
8033
  }
8034
  };
8035
+
8036
  /*
8037
  * Rule: Don't use adjoining classes (.foo.bar).
8038
  */
8039
+
8040
  CSSLint.addRule({
8041
 
8042
+ // rule information
8043
  id: "adjoining-classes",
8044
  name: "Disallow adjoining classes",
8045
  desc: "Don't use adjoining classes.",
8046
+ url: "https://github.com/CSSLint/csslint/wiki/Disallow-adjoining-classes",
8047
  browsers: "IE6",
8048
 
8049
+ // initialization
8050
+ init: function(parser, reporter) {
8051
+ "use strict";
8052
  var rule = this;
8053
+ parser.addListener("startrule", function(event) {
8054
  var selectors = event.selectors,
8055
  selector,
8056
  part,
8058
  classCount,
8059
  i, j, k;
8060
 
8061
+ for (i=0; i < selectors.length; i++) {
8062
  selector = selectors[i];
8063
+ for (j=0; j < selector.parts.length; j++) {
8064
  part = selector.parts[j];
8065
+ if (part.type === parser.SELECTOR_PART_TYPE) {
8066
  classCount = 0;
8067
+ for (k=0; k < part.modifiers.length; k++) {
8068
  modifier = part.modifiers[k];
8069
+ if (modifier.type === "class") {
8070
  classCount++;
8071
  }
8072
  if (classCount > 1){
8073
+ reporter.report("Adjoining classes: "+selectors[i].text, part.line, part.col, rule);
8074
  }
8075
  }
8076
  }
8080
  }
8081
 
8082
  });
 
8083
 
8084
  /*
8085
  * Rule: Don't use width or height when using padding or border.
8086
  */
8087
  CSSLint.addRule({
8088
 
8089
+ // rule information
8090
  id: "box-model",
8091
  name: "Beware of broken box size",
8092
  desc: "Don't use width or height when using padding or border.",
8093
+ url: "https://github.com/CSSLint/csslint/wiki/Beware-of-box-model-size",
8094
  browsers: "All",
8095
 
8096
+ // initialization
8097
+ init: function(parser, reporter) {
8098
+ "use strict";
8099
  var rule = this,
8100
  widthProperties = {
8101
  border: 1,
8116
  properties,
8117
  boxSizing = false;
8118
 
8119
+ function startRule() {
8120
  properties = {};
8121
  boxSizing = false;
8122
  }
8123
 
8124
+ function endRule() {
8125
  var prop, value;
8126
 
8127
  if (!boxSizing) {
8128
+ if (properties.height) {
8129
+ for (prop in heightProperties) {
8130
+ if (heightProperties.hasOwnProperty(prop) && properties[prop]) {
8131
  value = properties[prop].value;
8132
+ // special case for padding
8133
+ if (!(prop === "padding" && value.parts.length === 2 && value.parts[0].value === 0)) {
8134
  reporter.report("Using height with " + prop + " can sometimes make elements larger than you expect.", properties[prop].line, properties[prop].col, rule);
8135
  }
8136
  }
8137
  }
8138
  }
8139
 
8140
+ if (properties.width) {
8141
+ for (prop in widthProperties) {
8142
+ if (widthProperties.hasOwnProperty(prop) && properties[prop]) {
8143
  value = properties[prop].value;
8144
 
8145
+ if (!(prop === "padding" && value.parts.length === 2 && value.parts[1].value === 0)) {
8146
  reporter.report("Using width with " + prop + " can sometimes make elements larger than you expect.", properties[prop].line, properties[prop].col, rule);
8147
  }
8148
  }
8156
  parser.addListener("startpage", startRule);
8157
  parser.addListener("startpagemargin", startRule);
8158
  parser.addListener("startkeyframerule", startRule);
8159
+ parser.addListener("startviewport", startRule);
8160
 
8161
+ parser.addListener("property", function(event) {
8162
  var name = event.property.text.toLowerCase();
8163
 
8164
+ if (heightProperties[name] || widthProperties[name]) {
8165
+ if (!/^0\S*$/.test(event.value) && !(name === "border" && event.value.toString() === "none")) {
8166
+ properties[name] = {
8167
+ line: event.property.line,
8168
+ col: event.property.col,
8169
+ value: event.value
8170
+ };
8171
  }
8172
  } else {
8173
+ if (/^(width|height)/i.test(name) && /^(length|percentage)/.test(event.value.parts[0].type)) {
8174
  properties[name] = 1;
8175
+ } else if (name === "box-sizing") {
8176
  boxSizing = true;
8177
  }
8178
  }
8184
  parser.addListener("endpage", endRule);
8185
  parser.addListener("endpagemargin", endRule);
8186
  parser.addListener("endkeyframerule", endRule);
8187
+ parser.addListener("endviewport", endRule);
8188
  }
8189
 
8190
  });
 
8191
 
8192
  /*
8193
  * Rule: box-sizing doesn't work in IE6 and IE7.
8194
  */
8195
+
8196
  CSSLint.addRule({
8197
 
8198
+ // rule information
8199
  id: "box-sizing",
8200
  name: "Disallow use of box-sizing",
8201
  desc: "The box-sizing properties isn't supported in IE6 and IE7.",
8202
+ url: "https://github.com/CSSLint/csslint/wiki/Disallow-box-sizing",
8203
  browsers: "IE6, IE7",
8204
  tags: ["Compatibility"],
8205
 
8206
+ // initialization
8207
+ init: function(parser, reporter) {
8208
+ "use strict";
8209
  var rule = this;
8210
 
8211
+ parser.addListener("property", function(event) {
8212
  var name = event.property.text.toLowerCase();
8213
 
8214
+ if (name === "box-sizing") {
8215
  reporter.report("The box-sizing property isn't supported in IE6 and IE7.", event.line, event.col, rule);
8216
  }
8217
  });
8218
  }
8219
 
8220
  });
8221
+
8222
  /*
8223
  * Rule: Use the bulletproof @font-face syntax to avoid 404's in old IE
8224
  * (http://www.fontspring.com/blog/the-new-bulletproof-font-face-syntax)
8225
  */
8226
+
8227
  CSSLint.addRule({
8228
 
8229
+ // rule information
8230
  id: "bulletproof-font-face",
8231
  name: "Use the bulletproof @font-face syntax",
8232
  desc: "Use the bulletproof @font-face syntax to avoid 404's in old IE (http://www.fontspring.com/blog/the-new-bulletproof-font-face-syntax).",
8233
+ url: "https://github.com/CSSLint/csslint/wiki/Bulletproof-font-face",
8234
  browsers: "All",
8235
 
8236
+ // initialization
8237
+ init: function(parser, reporter) {
8238
+ "use strict";
8239
  var rule = this,
 
8240
  fontFaceRule = false,
8241
+ firstSrc = true,
8242
+ ruleFailed = false,
8243
  line, col;
8244
 
8245
  // Mark the start of a @font-face declaration so we only test properties inside it
8246
+ parser.addListener("startfontface", function() {
8247
  fontFaceRule = true;
8248
  });
8249
 
8250
+ parser.addListener("property", function(event) {
8251
  // If we aren't inside an @font-face declaration then just return
8252
  if (!fontFaceRule) {
8253
  return;
8254
  }
8255
 
8256
  var propertyName = event.property.toString().toLowerCase(),
8257
+ value = event.value.toString();
8258
 
8259
  // Set the line and col numbers for use in the endfontface listener
8260
  line = event.line;
8261
+ col = event.col;
8262
 
8263
  // This is the property that we care about, we can ignore the rest
8264
+ if (propertyName === "src") {
8265
  var regex = /^\s?url\(['"].+\.eot\?.*['"]\)\s*format\(['"]embedded-opentype['"]\).*$/i;
8266
 
8267
  // We need to handle the advanced syntax with two src properties
8277
  });
8278
 
8279
  // Back to normal rules that we don't need to test
8280
+ parser.addListener("endfontface", function() {
8281
  fontFaceRule = false;
8282
 
8283
  if (ruleFailed) {
8286
  });
8287
  }
8288
  });
8289
+
8290
  /*
8291
  * Rule: Include all compatible vendor prefixes to reach a wider
8292
  * range of users.
8293
  */
8294
+
8295
  CSSLint.addRule({
8296
 
8297
+ // rule information
8298
  id: "compatible-vendor-prefixes",
8299
  name: "Require compatible vendor prefixes",
8300
  desc: "Include all compatible vendor prefixes to reach a wider range of users.",
8301
+ url: "https://github.com/CSSLint/csslint/wiki/Require-compatible-vendor-prefixes",
8302
  browsers: "All",
8303
 
8304
+ // initialization
8305
  init: function (parser, reporter) {
8306
+ "use strict";
8307
  var rule = this,
8308
  compatiblePrefixes,
8309
  properties,
8318
 
8319
  // See http://peter.sh/experiments/vendor-prefixed-css-property-overview/ for details
8320
  compatiblePrefixes = {
8321
+ "animation" : "webkit",
8322
+ "animation-delay" : "webkit",
8323
+ "animation-direction" : "webkit",
8324
+ "animation-duration" : "webkit",
8325
+ "animation-fill-mode" : "webkit",
8326
+ "animation-iteration-count" : "webkit",
8327
+ "animation-name" : "webkit",
8328
+ "animation-play-state" : "webkit",
8329
+ "animation-timing-function" : "webkit",
8330
  "appearance" : "webkit moz",
8331
  "border-end" : "webkit moz",
8332
  "border-end-color" : "webkit moz",
8345
  "box-ordinal-group" : "webkit moz ms",
8346
  "box-orient" : "webkit moz ms",
8347
  "box-pack" : "webkit moz ms",
8348
+ "box-sizing" : "",
8349
+ "box-shadow" : "",
8350
  "column-count" : "webkit moz ms",
8351
  "column-gap" : "webkit moz ms",
8352
  "column-rule" : "webkit moz ms",
8364
  "padding-start" : "webkit moz",
8365
  "tab-size" : "moz o",
8366
  "text-size-adjust" : "webkit ms",
8367
+ "transform" : "webkit ms",
8368
+ "transform-origin" : "webkit ms",
8369
+ "transition" : "",
8370
+ "transition-delay" : "",
8371
+ "transition-duration" : "",
8372
+ "transition-property" : "",
8373
+ "transition-timing-function" : "",
8374
  "user-modify" : "webkit moz",
8375
  "user-select" : "webkit moz ms",
8376
  "word-break" : "epub ms",
8381
  for (prop in compatiblePrefixes) {
8382
  if (compatiblePrefixes.hasOwnProperty(prop)) {
8383
  variations = [];
8384
+ prefixed = compatiblePrefixes[prop].split(" ");
8385
  for (i = 0, len = prefixed.length; i < len; i++) {
8386
+ variations.push("-" + prefixed[i] + "-" + prop);
8387
  }
8388
  compatiblePrefixes[prop] = variations;
8389
  arrayPush.apply(applyTo, variations);
8398
  inKeyFrame = event.prefix || true;
8399
  });
8400
 
8401
+ parser.addListener("endkeyframes", function () {
8402
  inKeyFrame = false;
8403
  });
8404
 
8407
  if (CSSLint.Util.indexOf(applyTo, name.text) > -1) {
8408
 
8409
  // e.g., -moz-transform is okay to be alone in @-moz-keyframes
8410
+ if (!inKeyFrame || typeof inKeyFrame !== "string" ||
8411
  name.text.indexOf("-" + inKeyFrame + "-") !== 0) {
8412
  properties.push(name);
8413
  }
8414
  }
8415
  });
8416
 
8417
+ parser.addListener("endrule", function () {
8418
  if (!properties.length) {
8419
  return;
8420
  }
8440
  if (CSSLint.Util.indexOf(variations, name.text) > -1) {
8441
  if (!propertyGroups[prop]) {
8442
  propertyGroups[prop] = {
8443
+ full: variations.slice(0),
8444
+ actual: [],
8445
  actualNodes: []
8446
  };
8447
  }
8464
  for (i = 0, len = full.length; i < len; i++) {
8465
  item = full[i];
8466
  if (CSSLint.Util.indexOf(actual, item) === -1) {
8467
+ propertiesSpecified = (actual.length === 1) ? actual[0] : (actual.length === 2) ? actual.join(" and ") : actual.join(", ");
8468
  reporter.report("The property " + item + " is compatible with " + propertiesSpecified + " and should be included as well.", value.actualNodes[0].line, value.actualNodes[0].col, rule);
8469
  }
8470
  }
8475
  });
8476
  }
8477
  });
8478
+
8479
  /*
8480
  * Rule: Certain properties don't play well with certain display values.
8481
  * - float should not be used with inline-block
8483
  * - vertical-align should not be used with block
8484
  * - margin, float should not be used with table-*
8485
  */
8486
+
8487
  CSSLint.addRule({
8488
 
8489
+ // rule information
8490
  id: "display-property-grouping",
8491
  name: "Require properties appropriate for display",
8492
  desc: "Certain properties shouldn't be used with certain display property values.",
8493
+ url: "https://github.com/CSSLint/csslint/wiki/Require-properties-appropriate-for-display",
8494
  browsers: "All",
8495
 
8496
+ // initialization
8497
+ init: function(parser, reporter) {
8498
+ "use strict";
8499
  var rule = this;
8500
 
8501
  var propertiesToCheck = {
8517
  },
8518
  properties;
8519
 
8520
+ function reportProperty(name, display, msg) {
8521
+ if (properties[name]) {
8522
+ if (typeof propertiesToCheck[name] !== "string" || properties[name].value.toLowerCase() !== propertiesToCheck[name]) {
8523
  reporter.report(msg || name + " can't be used with display: " + display + ".", properties[name].line, properties[name].col, rule);
8524
  }
8525
  }
8526
  }
8527
 
8528
+ function startRule() {
8529
  properties = {};
8530
  }
8531
 
8532
+ function endRule() {
8533
 
8534
  var display = properties.display ? properties.display.value : null;
8535
+ if (display) {
8536
+ switch (display) {
8537
 
8538
  case "inline":
8539
+ // height, width, margin-top, margin-bottom, float should not be used with inline
8540
  reportProperty("height", display);
8541
  reportProperty("width", display);
8542
  reportProperty("margin", display);
8546
  break;
8547
 
8548
  case "block":
8549
+ // vertical-align should not be used with block
8550
  reportProperty("vertical-align", display);
8551
  break;
8552
 
8553
  case "inline-block":
8554
+ // float should not be used with inline-block
8555
  reportProperty("float", display);
8556
  break;
8557
 
8558
  default:
8559
+ // margin, float should not be used with table
8560
+ if (display.indexOf("table-") === 0) {
8561
  reportProperty("margin", display);
8562
  reportProperty("margin-left", display);
8563
  reportProperty("margin-right", display);
8566
  reportProperty("float", display);
8567
  }
8568
 
8569
+ // otherwise do nothing
8570
  }
8571
  }
8572
 
8577
  parser.addListener("startkeyframerule", startRule);
8578
  parser.addListener("startpagemargin", startRule);
8579
  parser.addListener("startpage", startRule);
8580
+ parser.addListener("startviewport", startRule);
8581
 
8582
+ parser.addListener("property", function(event) {
8583
  var name = event.property.text.toLowerCase();
8584
 
8585
+ if (propertiesToCheck[name]) {
8586
+ properties[name] = {
8587
+ value: event.value.text,
8588
+ line: event.property.line,
8589
+ col: event.property.col
8590
+ };
8591
  }
8592
  });
8593
 
8596
  parser.addListener("endkeyframerule", endRule);
8597
  parser.addListener("endpagemargin", endRule);
8598
  parser.addListener("endpage", endRule);
8599
+ parser.addListener("endviewport", endRule);
8600
 
8601
  }
8602
 
8603
  });
8604
+
8605
  /*
8606
  * Rule: Disallow duplicate background-images (using url).
8607
  */
8608
+
8609
  CSSLint.addRule({
8610
 
8611
+ // rule information
8612
  id: "duplicate-background-images",
8613
  name: "Disallow duplicate background images",
8614
  desc: "Every background-image should be unique. Use a common class for e.g. sprites.",
8615
+ url: "https://github.com/CSSLint/csslint/wiki/Disallow-duplicate-background-images",
8616
  browsers: "All",
8617
 
8618
+ // initialization
8619
+ init: function(parser, reporter) {
8620
+ "use strict";
8621
  var rule = this,
8622
  stack = {};
8623
 
8624
+ parser.addListener("property", function(event) {
8625
  var name = event.property.text,
8626
  value = event.value,
8627
  i, len;
8628
 
8629
  if (name.match(/background/i)) {
8630
  for (i=0, len=value.parts.length; i < len; i++) {
8631
+ if (value.parts[i].type === "uri") {
8632
+ if (typeof stack[value.parts[i].uri] === "undefined") {
8633
  stack[value.parts[i].uri] = event;
8634
+ } else {
 
8635
  reporter.report("Background image '" + value.parts[i].uri + "' was used multiple times, first declared at line " + stack[value.parts[i].uri].line + ", col " + stack[value.parts[i].uri].col + ".", event.line, event.col, rule);
8636
  }
8637
  }
8640
  });
8641
  }
8642
  });
8643
+
8644
  /*
8645
  * Rule: Duplicate properties must appear one after the other. If an already-defined
8646
  * property appears somewhere else in the rule, then it's likely an error.
8647
  */
8648
+
8649
  CSSLint.addRule({
8650
 
8651
+ // rule information
8652
  id: "duplicate-properties",
8653
  name: "Disallow duplicate properties",
8654
  desc: "Duplicate properties must appear one after the other.",
8655
+ url: "https://github.com/CSSLint/csslint/wiki/Disallow-duplicate-properties",
8656
  browsers: "All",
8657
 
8658
+ // initialization
8659
+ init: function(parser, reporter) {
8660
+ "use strict";
8661
  var rule = this,
8662
  properties,
8663
  lastProperty;
8664
 
8665
+ function startRule() {
8666
  properties = {};
8667
  }
8668
 
8671
  parser.addListener("startpage", startRule);
8672
  parser.addListener("startpagemargin", startRule);
8673
  parser.addListener("startkeyframerule", startRule);
8674
+ parser.addListener("startviewport", startRule);
8675
 
8676
+ parser.addListener("property", function(event) {
8677
  var property = event.property,
8678
  name = property.text.toLowerCase();
8679
 
8680
+ if (properties[name] && (lastProperty !== name || properties[name] === event.value.text)) {
8681
  reporter.report("Duplicate property '" + event.property + "' found.", event.line, event.col, rule);
8682
  }
8683
 
8690
  }
8691
 
8692
  });
8693
+
8694
  /*
8695
  * Rule: Style rules without any properties defined should be removed.
8696
  */
8697
+
8698
  CSSLint.addRule({
8699
 
8700
+ // rule information
8701
  id: "empty-rules",
8702
  name: "Disallow empty rules",
8703
  desc: "Rules without any properties specified should be removed.",
8704
+ url: "https://github.com/CSSLint/csslint/wiki/Disallow-empty-rules",
8705
  browsers: "All",
8706
 
8707
+ // initialization
8708
+ init: function(parser, reporter) {
8709
+ "use strict";
8710
  var rule = this,
8711
  count = 0;
8712
 
8713
+ parser.addListener("startrule", function() {
8714
  count=0;
8715
  });
8716
 
8717
+ parser.addListener("property", function() {
8718
  count++;
8719
  });
8720
 
8721
+ parser.addListener("endrule", function(event) {
8722
  var selectors = event.selectors;
8723
+ if (count === 0) {
8724
  reporter.report("Rule is empty.", selectors[0].line, selectors[0].col, rule);
8725
  }
8726
  });
8727
  }
8728
 
8729
  });
8730
+
8731
  /*
8732
  * Rule: There should be no syntax errors. (Duh.)
8733
  */
8734
+
8735
  CSSLint.addRule({
8736
 
8737
+ // rule information
8738
  id: "errors",
8739
  name: "Parsing Errors",
8740
  desc: "This rule looks for recoverable syntax errors.",
8741
  browsers: "All",
8742
 
8743
+ // initialization
8744
+ init: function(parser, reporter) {
8745
+ "use strict";
8746
  var rule = this;
8747
 
8748
+ parser.addListener("error", function(event) {
8749
  reporter.error(event.message, event.line, event.col, rule);
8750
  });
8751
 
8753
 
8754
  });
8755
 
 
8756
  CSSLint.addRule({
8757
 
8758
+ // rule information
8759
  id: "fallback-colors",
8760
  name: "Require fallback colors",
8761
  desc: "For older browsers that don't support RGBA, HSL, or HSLA, provide a fallback color.",
8762
+ url: "https://github.com/CSSLint/csslint/wiki/Require-fallback-colors",
8763
  browsers: "IE6,IE7,IE8",
8764
 
8765
+ // initialization
8766
+ init: function(parser, reporter) {
8767
+ "use strict";
8768
  var rule = this,
8769
  lastProperty,
8770
  propertiesToCheck = {
8781
  "border-bottom": 1,
8782
  "border-left": 1,
8783
  "background-color": 1
8784
+ };
 
8785
 
8786
+ function startRule() {
 
8787
  lastProperty = null;
8788
  }
8789
 
8792
  parser.addListener("startpage", startRule);
8793
  parser.addListener("startpagemargin", startRule);
8794
  parser.addListener("startkeyframerule", startRule);
8795
+ parser.addListener("startviewport", startRule);
8796
 
8797
+ parser.addListener("property", function(event) {
8798
  var property = event.property,
8799
  name = property.text.toLowerCase(),
8800
  parts = event.value.parts,
8802
  colorType = "",
8803
  len = parts.length;
8804
 
8805
+ if (propertiesToCheck[name]) {
8806
+ while (i < len) {
8807
+ if (parts[i].type === "color") {
8808
+ if ("alpha" in parts[i] || "hue" in parts[i]) {
8809
 
8810
+ if (/([^\)]+)\(/.test(parts[i])) {
8811
  colorType = RegExp.$1.toUpperCase();
8812
  }
8813
 
8814
+ if (!lastProperty || (lastProperty.property.text.toLowerCase() !== name || lastProperty.colorType !== "compat")) {
8815
  reporter.report("Fallback " + name + " (hex or RGB) should precede " + colorType + " " + name + ".", event.line, event.col, rule);
8816
  }
8817
  } else {
8829
  }
8830
 
8831
  });
8832
+
8833
  /*
8834
  * Rule: You shouldn't use more than 10 floats. If you do, there's probably
8835
  * room for some abstraction.
8836
  */
8837
+
8838
  CSSLint.addRule({
8839
 
8840
+ // rule information
8841
  id: "floats",
8842
  name: "Disallow too many floats",
8843
  desc: "This rule tests if the float property is used too many times",
8844
+ url: "https://github.com/CSSLint/csslint/wiki/Disallow-too-many-floats",
8845
  browsers: "All",
8846
 
8847
+ // initialization
8848
+ init: function(parser, reporter) {
8849
+ "use strict";
8850
  var rule = this;
8851
  var count = 0;
8852
 
8853
+ // count how many times "float" is used
8854
+ parser.addListener("property", function(event) {
8855
+ if (event.property.text.toLowerCase() === "float" &&
8856
+ event.value.text.toLowerCase() !== "none") {
8857
  count++;
8858
  }
8859
  });
8860
 
8861
+ // report the results
8862
+ parser.addListener("endstylesheet", function() {
8863
  reporter.stat("floats", count);
8864
+ if (count >= 10) {
8865
  reporter.rollupWarn("Too many floats (" + count + "), you're probably using them for layout. Consider using a grid system instead.", rule);
8866
  }
8867
  });
8868
  }
8869
 
8870
  });
8871
+
8872
  /*
8873
  * Rule: Avoid too many @font-face declarations in the same stylesheet.
8874
  */
8875
+
8876
  CSSLint.addRule({
8877
 
8878
+ // rule information
8879
  id: "font-faces",
8880
  name: "Don't use too many web fonts",
8881
  desc: "Too many different web fonts in the same stylesheet.",
8882
+ url: "https://github.com/CSSLint/csslint/wiki/Don%27t-use-too-many-web-fonts",
8883
  browsers: "All",
8884
 
8885
+ // initialization
8886
+ init: function(parser, reporter) {
8887
+ "use strict";
8888
  var rule = this,
8889
  count = 0;
8890
 
8891
 
8892
+ parser.addListener("startfontface", function() {
8893
  count++;
8894
  });
8895
 
8896
+ parser.addListener("endstylesheet", function() {
8897
+ if (count > 5) {
8898
  reporter.rollupWarn("Too many @font-face declarations (" + count + ").", rule);
8899
  }
8900
  });
8901
  }
8902
 
8903
  });
8904
+
8905
  /*
8906
  * Rule: You shouldn't need more than 9 font-size declarations.
8907
  */
8908
 
 
8909
  CSSLint.addRule({
8910
 
8911
+ // rule information
8912
  id: "font-sizes",
8913
  name: "Disallow too many font sizes",
8914
  desc: "Checks the number of font-size declarations.",
8915
+ url: "https://github.com/CSSLint/csslint/wiki/Don%27t-use-too-many-font-size-declarations",
8916
  browsers: "All",
8917
 
8918
+ // initialization
8919
+ init: function(parser, reporter) {
8920
+ "use strict";
8921
  var rule = this,
8922
  count = 0;
8923
 
8924
+ // check for use of "font-size"
8925
+ parser.addListener("property", function(event) {
8926
+ if (event.property.toString() === "font-size") {
8927
  count++;
8928
  }
8929
  });
8930
 
8931
+ // report the results
8932
+ parser.addListener("endstylesheet", function() {
8933
  reporter.stat("font-sizes", count);
8934
+ if (count >= 10) {
8935
  reporter.rollupWarn("Too many font-size declarations (" + count + "), abstraction needed.", rule);
8936
  }
8937
  });
8938
  }
8939
 
8940
  });
8941
+
8942
  /*
8943
  * Rule: When using a vendor-prefixed gradient, make sure to use them all.
8944
  */
8945
+
8946
  CSSLint.addRule({
8947
 
8948
+ // rule information
8949
  id: "gradients",
8950
  name: "Require all gradient definitions",
8951
  desc: "When using a vendor-prefixed gradient, make sure to use them all.",
8952
+ url: "https://github.com/CSSLint/csslint/wiki/Require-all-gradient-definitions",
8953
  browsers: "All",
8954
 
8955
+ // initialization
8956
+ init: function(parser, reporter) {
8957
+ "use strict";
8958
  var rule = this,
8959
  gradients;
8960
 
8961
+ parser.addListener("startrule", function() {
8962
  gradients = {
8963
  moz: 0,
8964
  webkit: 0,
8967
  };
8968
  });
8969
 
8970
+ parser.addListener("property", function(event) {
8971
 
8972
+ if (/\-(moz|o|webkit)(?:\-(?:linear|radial))\-gradient/i.test(event.value)) {
8973
  gradients[RegExp.$1] = 1;
8974
+ } else if (/\-webkit\-gradient/i.test(event.value)) {
8975
  gradients.oldWebkit = 1;
8976
  }
8977
 
8978
  });
8979
 
8980
+ parser.addListener("endrule", function(event) {
8981
  var missing = [];
8982
 
8983
+ if (!gradients.moz) {
8984
  missing.push("Firefox 3.6+");
8985
  }
8986
 
8987
+ if (!gradients.webkit) {
8988
  missing.push("Webkit (Safari 5+, Chrome)");
8989
  }
8990
 
8991
+ if (!gradients.oldWebkit) {
8992
  missing.push("Old Webkit (Safari 4+, Chrome)");
8993
  }
8994
 
8995
+ if (!gradients.o) {
8996
  missing.push("Opera 11.1+");
8997
  }
8998
 
8999
+ if (missing.length && missing.length < 4) {
9000
  reporter.report("Missing vendor-prefixed CSS gradients for " + missing.join(", ") + ".", event.selectors[0].line, event.selectors[0].col, rule);
9001
  }
9002
 
9009
  /*
9010
  * Rule: Don't use IDs for selectors.
9011
  */
9012
+
9013
  CSSLint.addRule({
9014
 
9015
+ // rule information
9016
  id: "ids",
9017
  name: "Disallow IDs in selectors",
9018
  desc: "Selectors should not contain IDs.",
9019
+ url: "https://github.com/CSSLint/csslint/wiki/Disallow-IDs-in-selectors",
9020
  browsers: "All",
9021
 
9022
+ // initialization
9023
+ init: function(parser, reporter) {
9024
+ "use strict";
9025
  var rule = this;
9026
+ parser.addListener("startrule", function(event) {
9027
  var selectors = event.selectors,
9028
  selector,
9029
  part,
9031
  idCount,
9032
  i, j, k;
9033
 
9034
+ for (i=0; i < selectors.length; i++) {
9035
  selector = selectors[i];
9036
  idCount = 0;
9037
 
9038
+ for (j=0; j < selector.parts.length; j++) {
9039
  part = selector.parts[j];
9040
+ if (part.type === parser.SELECTOR_PART_TYPE) {
9041
+ for (k=0; k < part.modifiers.length; k++) {
9042
  modifier = part.modifiers[k];
9043
+ if (modifier.type === "id") {
9044
  idCount++;
9045
  }
9046
  }
9047
  }
9048
  }
9049
 
9050
+ if (idCount === 1) {
9051
  reporter.report("Don't use IDs in selectors.", selector.line, selector.col, rule);
9052
+ } else if (idCount > 1) {
9053
  reporter.report(idCount + " IDs in the selector, really?", selector.line, selector.col, rule);
9054
  }
9055
  }
9058
  }
9059
 
9060
  });
9061
+
9062
+ /*
9063
+ * Rule: IE6-9 supports up to 31 stylesheet import.
9064
+ * Reference:
9065
+ * http://blogs.msdn.com/b/ieinternals/archive/2011/05/14/internet-explorer-stylesheet-rule-selector-import-sheet-limit-maximum.aspx
9066
+ */
9067
+
9068
+ CSSLint.addRule({
9069
+
9070
+ // rule information
9071
+ id: "import-ie-limit",
9072
+ name: "@import limit on IE6-IE9",
9073
+ desc: "IE6-9 supports up to 31 @import per stylesheet",
9074
+ browsers: "IE6, IE7, IE8, IE9",
9075
+
9076
+ // initialization
9077
+ init: function(parser, reporter) {
9078
+ "use strict";
9079
+ var rule = this,
9080
+ MAX_IMPORT_COUNT = 31,
9081
+ count = 0;
9082
+
9083
+ function startPage() {
9084
+ count = 0;
9085
+ }
9086
+
9087
+ parser.addListener("startpage", startPage);
9088
+
9089
+ parser.addListener("import", function() {
9090
+ count++;
9091
+ });
9092
+
9093
+ parser.addListener("endstylesheet", function() {
9094
+ if (count > MAX_IMPORT_COUNT) {
9095
+ reporter.rollupError(
9096
+ "Too many @import rules (" + count + "). IE6-9 supports up to 31 import per stylesheet.",
9097
+ rule
9098
+ );
9099
+ }
9100
+ });
9101
+ }
9102
+
9103
+ });
9104
+
9105
  /*
9106
  * Rule: Don't use @import, use <link> instead.
9107
  */
9108
+
9109
  CSSLint.addRule({
9110
 
9111
+ // rule information
9112
  id: "import",
9113
  name: "Disallow @import",
9114
  desc: "Don't use @import, use <link> instead.",
9115
+ url: "https://github.com/CSSLint/csslint/wiki/Disallow-%40import",
9116
  browsers: "All",
9117
 
9118
+ // initialization
9119
+ init: function(parser, reporter) {
9120
+ "use strict";
9121
  var rule = this;
9122
 
9123
+ parser.addListener("import", function(event) {
9124
  reporter.report("@import prevents parallel downloads, use <link> instead.", event.line, event.col, rule);
9125
  });
9126
 
9127
  }
9128
 
9129
  });
9130
+
9131
  /*
9132
  * Rule: Make sure !important is not overused, this could lead to specificity
9133
  * war. Display a warning on !important declarations, an error if it's
9134
  * used more at least 10 times.
9135
  */
9136
+
9137
  CSSLint.addRule({
9138
 
9139
+ // rule information
9140
  id: "important",
9141
  name: "Disallow !important",
9142
  desc: "Be careful when using !important declaration",
9143
+ url: "https://github.com/CSSLint/csslint/wiki/Disallow-%21important",
9144
  browsers: "All",
9145
 
9146
+ // initialization
9147
+ init: function(parser, reporter) {
9148
+ "use strict";
9149
  var rule = this,
9150
  count = 0;
9151
 
9152
+ // warn that important is used and increment the declaration counter
9153
+ parser.addListener("property", function(event) {
9154
+ if (event.important === true) {
9155
  count++;
9156
  reporter.report("Use of !important", event.line, event.col, rule);
9157
  }
9158
  });
9159
 
9160
+ // if there are more than 10, show an error
9161
+ parser.addListener("endstylesheet", function() {
9162
  reporter.stat("important", count);
9163
+ if (count >= 10) {
9164
  reporter.rollupWarn("Too many !important declarations (" + count + "), try to use less than 10 to avoid specificity issues.", rule);
9165
  }
9166
  });
9167
  }
9168
 
9169
  });
9170
+
9171
  /*
9172
  * Rule: Properties should be known (listed in CSS3 specification) or
9173
  * be a vendor-prefixed property.
9174
  */
9175
+
9176
  CSSLint.addRule({
9177
 
9178
+ // rule information
9179
  id: "known-properties",
9180
  name: "Require use of known properties",
9181
  desc: "Properties should be known (listed in CSS3 specification) or be a vendor-prefixed property.",
9182
+ url: "https://github.com/CSSLint/csslint/wiki/Require-use-of-known-properties",
9183
  browsers: "All",
9184
 
9185
+ // initialization
9186
+ init: function(parser, reporter) {
9187
+ "use strict";
9188
  var rule = this;
9189
 
9190
+ parser.addListener("property", function(event) {
 
9191
 
9192
  // the check is handled entirely by the parser-lib (https://github.com/nzakas/parser-lib)
9193
  if (event.invalid) {
9198
  }
9199
 
9200
  });
9201
+
9202
+ /*
9203
+ * Rule: All properties should be in alphabetical order.
9204
+ */
9205
+
9206
+ CSSLint.addRule({
9207
+
9208
+ // rule information
9209
+ id: "order-alphabetical",
9210
+ name: "Alphabetical order",
9211
+ desc: "Assure properties are in alphabetical order",
9212
+ browsers: "All",
9213
+
9214
+ // initialization
9215
+ init: function(parser, reporter) {
9216
+ "use strict";
9217
+ var rule = this,
9218
+ properties;
9219
+
9220
+ var startRule = function () {
9221
+ properties = [];
9222
+ };
9223
+
9224
+ var endRule = function(event) {
9225
+ var currentProperties = properties.join(","),
9226
+ expectedProperties = properties.sort().join(",");
9227
+
9228
+ if (currentProperties !== expectedProperties) {
9229
+ reporter.report("Rule doesn't have all its properties in alphabetical order.", event.line, event.col, rule);
9230
+ }
9231
+ };
9232
+
9233
+ parser.addListener("startrule", startRule);
9234
+ parser.addListener("startfontface", startRule);
9235
+ parser.addListener("startpage", startRule);
9236
+ parser.addListener("startpagemargin", startRule);
9237
+ parser.addListener("startkeyframerule", startRule);
9238
+ parser.addListener("startviewport", startRule);
9239
+
9240
+ parser.addListener("property", function(event) {
9241
+ var name = event.property.text,
9242
+ lowerCasePrefixLessName = name.toLowerCase().replace(/^-.*?-/, "");
9243
+
9244
+ properties.push(lowerCasePrefixLessName);
9245
+ });
9246
+
9247
+ parser.addListener("endrule", endRule);
9248
+ parser.addListener("endfontface", endRule);
9249
+ parser.addListener("endpage", endRule);
9250
+ parser.addListener("endpagemargin", endRule);
9251
+ parser.addListener("endkeyframerule", endRule);
9252
+ parser.addListener("endviewport", endRule);
9253
+ }
9254
+
9255
+ });
9256
+
9257
  /*
9258
  * Rule: outline: none or outline: 0 should only be used in a :focus rule
9259
  * and only if there are other properties in the same rule.
9260
  */
9261
+
9262
  CSSLint.addRule({
9263
 
9264
+ // rule information
9265
  id: "outline-none",
9266
  name: "Disallow outline: none",
9267
  desc: "Use of outline: none or outline: 0 should be limited to :focus rules.",
9268
+ url: "https://github.com/CSSLint/csslint/wiki/Disallow-outline%3Anone",
9269
  browsers: "All",
9270
  tags: ["Accessibility"],
9271
 
9272
+ // initialization
9273
+ init: function(parser, reporter) {
9274
+ "use strict";
9275
  var rule = this,
9276
  lastRule;
9277
 
9278
+ function startRule(event) {
9279
+ if (event.selectors) {
9280
  lastRule = {
9281
  line: event.line,
9282
  col: event.col,
9289
  }
9290
  }
9291
 
9292
+ function endRule() {
9293
+ if (lastRule) {
9294
+ if (lastRule.outline) {
9295
+ if (lastRule.selectors.toString().toLowerCase().indexOf(":focus") === -1) {
9296
  reporter.report("Outlines should only be modified using :focus.", lastRule.line, lastRule.col, rule);
9297
+ } else if (lastRule.propCount === 1) {
9298
  reporter.report("Outlines shouldn't be hidden unless other visual changes are made.", lastRule.line, lastRule.col, rule);
9299
  }
9300
  }
9306
  parser.addListener("startpage", startRule);
9307
  parser.addListener("startpagemargin", startRule);
9308
  parser.addListener("startkeyframerule", startRule);
9309
+ parser.addListener("startviewport", startRule);
9310
 
9311
+ parser.addListener("property", function(event) {
9312
  var name = event.property.text.toLowerCase(),
9313
  value = event.value;
9314
 
9315
+ if (lastRule) {
9316
  lastRule.propCount++;
9317
+ if (name === "outline" && (value.toString() === "none" || value.toString() === "0")) {
9318
  lastRule.outline = true;
9319
  }
9320
  }
9326
  parser.addListener("endpage", endRule);
9327
  parser.addListener("endpagemargin", endRule);
9328
  parser.addListener("endkeyframerule", endRule);
9329
+ parser.addListener("endviewport", endRule);
9330
 
9331
  }
9332
 
9333
  });
9334
+
9335
  /*
9336
  * Rule: Don't use classes or IDs with elements (a.foo or a#foo).
9337
  */
9338
+
9339
  CSSLint.addRule({
9340
 
9341
+ // rule information
9342
  id: "overqualified-elements",
9343
  name: "Disallow overqualified elements",
9344
  desc: "Don't use classes or IDs with elements (a.foo or a#foo).",
9345
+ url: "https://github.com/CSSLint/csslint/wiki/Disallow-overqualified-elements",
9346
  browsers: "All",
9347
 
9348
+ // initialization
9349
+ init: function(parser, reporter) {
9350
+ "use strict";
9351
  var rule = this,
9352
  classes = {};
9353
 
9354
+ parser.addListener("startrule", function(event) {
9355
  var selectors = event.selectors,
9356
  selector,
9357
  part,
9358
  modifier,
9359
  i, j, k;
9360
 
9361
+ for (i=0; i < selectors.length; i++) {
9362
  selector = selectors[i];
9363
 
9364
+ for (j=0; j < selector.parts.length; j++) {
9365
  part = selector.parts[j];
9366
+ if (part.type === parser.SELECTOR_PART_TYPE) {
9367
+ for (k=0; k < part.modifiers.length; k++) {
9368
  modifier = part.modifiers[k];
9369
+ if (part.elementName && modifier.type === "id") {
9370
  reporter.report("Element (" + part + ") is overqualified, just use " + modifier + " without element name.", part.line, part.col, rule);
9371
+ } else if (modifier.type === "class") {
9372
 
9373
+ if (!classes[modifier]) {
9374
  classes[modifier] = [];
9375
  }
9376
+ classes[modifier].push({
9377
+ modifier: modifier,
9378
+ part: part
9379
+ });
9380
  }
9381
  }
9382
  }
9384
  }
9385
  });
9386
 
9387
+ parser.addListener("endstylesheet", function() {
9388
 
9389
  var prop;
9390
+ for (prop in classes) {
9391
+ if (classes.hasOwnProperty(prop)) {
9392
 
9393
+ // one use means that this is overqualified
9394
+ if (classes[prop].length === 1 && classes[prop][0].part.elementName) {
9395
  reporter.report("Element (" + classes[prop][0].part + ") is overqualified, just use " + classes[prop][0].modifier + " without element name.", classes[prop][0].part.line, classes[prop][0].part.col, rule);
9396
  }
9397
  }
9400
  }
9401
 
9402
  });
9403
+
9404
  /*
9405
  * Rule: Headings (h1-h6) should not be qualified (namespaced).
9406
  */
9407
+
9408
  CSSLint.addRule({
9409
 
9410
+ // rule information
9411
  id: "qualified-headings",
9412
  name: "Disallow qualified headings",
9413
  desc: "Headings should not be qualified (namespaced).",
9414
+ url: "https://github.com/CSSLint/csslint/wiki/Disallow-qualified-headings",
9415
  browsers: "All",
9416
 
9417
+ // initialization
9418
+ init: function(parser, reporter) {
9419
+ "use strict";
9420
  var rule = this;
9421
 
9422
+ parser.addListener("startrule", function(event) {
9423
  var selectors = event.selectors,
9424
  selector,
9425
  part,
9426
  i, j;
9427
 
9428
+ for (i=0; i < selectors.length; i++) {
9429
  selector = selectors[i];
9430
 
9431
+ for (j=0; j < selector.parts.length; j++) {
9432
  part = selector.parts[j];
9433
+ if (part.type === parser.SELECTOR_PART_TYPE) {
9434
+ if (part.elementName && /h[1-6]/.test(part.elementName.toString()) && j > 0) {
9435
  reporter.report("Heading (" + part.elementName + ") should not be qualified.", part.line, part.col, rule);
9436
  }
9437
  }
9441
  }
9442
 
9443
  });
9444
+
9445
  /*
9446
  * Rule: Selectors that look like regular expressions are slow and should be avoided.
9447
  */
9448
+
9449
  CSSLint.addRule({
9450
 
9451
+ // rule information
9452
  id: "regex-selectors",
9453
  name: "Disallow selectors that look like regexs",
9454
  desc: "Selectors that look like regular expressions are slow and should be avoided.",
9455
+ url: "https://github.com/CSSLint/csslint/wiki/Disallow-selectors-that-look-like-regular-expressions",
9456
  browsers: "All",
9457
 
9458
+ // initialization
9459
+ init: function(parser, reporter) {
9460
+ "use strict";
9461
  var rule = this;
9462
 
9463
+ parser.addListener("startrule", function(event) {
9464
  var selectors = event.selectors,
9465
  selector,
9466
  part,
9467
  modifier,
9468
  i, j, k;
9469
 
9470
+ for (i=0; i < selectors.length; i++) {
9471
  selector = selectors[i];
9472
+ for (j=0; j < selector.parts.length; j++) {
9473
  part = selector.parts[j];
9474
+ if (part.type === parser.SELECTOR_PART_TYPE) {
9475
+ for (k=0; k < part.modifiers.length; k++) {
9476
  modifier = part.modifiers[k];
9477
+ if (modifier.type === "attribute") {
9478
+ if (/([~\|\^\$\*]=)/.test(modifier)) {
9479
  reporter.report("Attribute selectors with " + RegExp.$1 + " are slow!", modifier.line, modifier.col, rule);
9480
  }
9481
  }
9488
  }
9489
 
9490
  });
9491
+
9492
  /*
9493
  * Rule: Total number of rules should not exceed x.
9494
  */
9495
+
9496
  CSSLint.addRule({
9497
 
9498
+ // rule information
9499
  id: "rules-count",
9500
  name: "Rules Count",
9501
  desc: "Track how many rules there are.",
9502
  browsers: "All",
9503
 
9504
+ // initialization
9505
+ init: function(parser, reporter) {
9506
+ "use strict";
9507
+ var count = 0;
9508
 
9509
+ // count each rule
9510
+ parser.addListener("startrule", function() {
9511
  count++;
9512
  });
9513
 
9514
+ parser.addListener("endstylesheet", function() {
9515
  reporter.stat("rule-count", count);
9516
  });
9517
  }
9518
 
9519
  });
9520
+
9521
  /*
9522
  * Rule: Warn people with approaching the IE 4095 limit
9523
  */
9524
+
9525
  CSSLint.addRule({
9526
 
9527
+ // rule information
9528
  id: "selector-max-approaching",
9529
  name: "Warn when approaching the 4095 selector limit for IE",
9530
  desc: "Will warn when selector count is >= 3800 selectors.",
9531
  browsers: "IE",
9532
 
9533
+ // initialization
9534
  init: function(parser, reporter) {
9535
+ "use strict";
9536
  var rule = this, count = 0;
9537
 
9538
+ parser.addListener("startrule", function(event) {
9539
  count += event.selectors.length;
9540
  });
9541
 
9542
  parser.addListener("endstylesheet", function() {
9543
  if (count >= 3800) {
9544
+ reporter.report("You have " + count + " selectors. Internet Explorer supports a maximum of 4095 selectors per stylesheet. Consider refactoring.", 0, 0, rule);
9545
  }
9546
  });
9547
  }
9551
  /*
9552
  * Rule: Warn people past the IE 4095 limit
9553
  */
9554
+
9555
  CSSLint.addRule({
9556
 
9557
+ // rule information
9558
  id: "selector-max",
9559
  name: "Error when past the 4095 selector limit for IE",
9560
  desc: "Will error when selector count is > 4095.",
9561
  browsers: "IE",
9562
 
9563
+ // initialization
9564
+ init: function(parser, reporter) {
9565
+ "use strict";
9566
  var rule = this, count = 0;
9567
 
9568
+ parser.addListener("startrule", function(event) {
9569
  count += event.selectors.length;
9570
  });
9571
 
9572
  parser.addListener("endstylesheet", function() {
9573
  if (count > 4095) {
9574
+ reporter.report("You have " + count + " selectors. Internet Explorer supports a maximum of 4095 selectors per stylesheet. Consider refactoring.", 0, 0, rule);
9575
  }
9576
  });
9577
  }
9578
 
9579
  });
9580
+
9581
+ /*
9582
+ * Rule: Avoid new-line characters in selectors.
9583
+ */
9584
+
9585
+ CSSLint.addRule({
9586
+
9587
+ // rule information
9588
+ id: "selector-newline",
9589
+ name: "Disallow new-line characters in selectors",
9590
+ desc: "New-line characters in selectors are usually a forgotten comma and not a descendant combinator.",
9591
+ browsers: "All",
9592
+
9593
+ // initialization
9594
+ init: function(parser, reporter) {
9595
+ "use strict";
9596
+ var rule = this;
9597
+
9598
+ function startRule(event) {
9599
+ var i, len, selector, p, n, pLen, part, part2, type, currentLine, nextLine,
9600
+ selectors = event.selectors;
9601
+
9602
+ for (i = 0, len = selectors.length; i < len; i++) {
9603
+ selector = selectors[i];
9604
+ for (p = 0, pLen = selector.parts.length; p < pLen; p++) {
9605
+ for (n = p + 1; n < pLen; n++) {
9606
+ part = selector.parts[p];
9607
+ part2 = selector.parts[n];
9608
+ type = part.type;
9609
+ currentLine = part.line;
9610
+ nextLine = part2.line;
9611
+
9612
+ if (type === "descendant" && nextLine > currentLine) {
9613
+ reporter.report("newline character found in selector (forgot a comma?)", currentLine, selectors[i].parts[0].col, rule);
9614
+ }
9615
+ }
9616
+ }
9617
+
9618
+ }
9619
+ }
9620
+
9621
+ parser.addListener("startrule", startRule);
9622
+
9623
+ }
9624
+ });
9625
+
9626
  /*
9627
  * Rule: Use shorthand properties where possible.
9628
  *
9629
  */
9630
+
9631
  CSSLint.addRule({
9632
 
9633
+ // rule information
9634
  id: "shorthand",
9635
  name: "Require shorthand properties",
9636
  desc: "Use shorthand properties where possible.",
9637
+ url: "https://github.com/CSSLint/csslint/wiki/Require-shorthand-properties",
9638
  browsers: "All",
9639
 
9640
+ // initialization
9641
+ init: function(parser, reporter) {
9642
+ "use strict";
9643
  var rule = this,
9644
  prop, i, len,
9645
  propertiesToCheck = {},
9659
  ]
9660
  };
9661
 
9662
+ // initialize propertiesToCheck
9663
+ for (prop in mapping) {
9664
+ if (mapping.hasOwnProperty(prop)) {
9665
+ for (i=0, len=mapping[prop].length; i < len; i++) {
9666
  propertiesToCheck[mapping[prop][i]] = prop;
9667
  }
9668
  }
9669
  }
9670
 
9671
+ function startRule() {
9672
  properties = {};
9673
  }
9674
 
9675
+ // event handler for end of rules
9676
+ function endRule(event) {
9677
 
9678
  var prop, i, len, total;
9679
 
9680
+ // check which properties this rule has
9681
+ for (prop in mapping) {
9682
+ if (mapping.hasOwnProperty(prop)) {
9683
  total=0;
9684
 
9685
+ for (i=0, len=mapping[prop].length; i < len; i++) {
9686
  total += properties[mapping[prop][i]] ? 1 : 0;
9687
  }
9688
 
9689
+ if (total === mapping[prop].length) {
9690
  reporter.report("The properties " + mapping[prop].join(", ") + " can be replaced by " + prop + ".", event.line, event.col, rule);
9691
  }
9692
  }
9696
  parser.addListener("startrule", startRule);
9697
  parser.addListener("startfontface", startRule);
9698
 
9699
+ // check for use of "font-size"
9700
+ parser.addListener("property", function(event) {
9701
+ var name = event.property.toString().toLowerCase();
 
9702
 
9703
+ if (propertiesToCheck[name]) {
9704
  properties[name] = 1;
9705
  }
9706
  });
9711
  }
9712
 
9713
  });
9714
+
9715
  /*
9716
  * Rule: Don't use properties with a star prefix.
9717
  *
9718
  */
9719
+
9720
  CSSLint.addRule({
9721
 
9722
+ // rule information
9723
  id: "star-property-hack",
9724
  name: "Disallow properties with a star prefix",
9725
  desc: "Checks for the star property hack (targets IE6/7)",
9726
+ url: "https://github.com/CSSLint/csslint/wiki/Disallow-star-hack",
9727
  browsers: "All",
9728
 
9729
+ // initialization
9730
+ init: function(parser, reporter) {
9731
+ "use strict";
9732
  var rule = this;
9733
 
9734
+ // check if property name starts with "*"
9735
+ parser.addListener("property", function(event) {
9736
  var property = event.property;
9737
 
9738
+ if (property.hack === "*") {
9739
  reporter.report("Property with star prefix found.", event.property.line, event.property.col, rule);
9740
  }
9741
  });
9742
  }
9743
  });
9744
+
9745
  /*
9746
  * Rule: Don't use text-indent for image replacement if you need to support rtl.
9747
  *
9748
  */
9749
+
9750
  CSSLint.addRule({
9751
 
9752
+ // rule information
9753
  id: "text-indent",
9754
  name: "Disallow negative text-indent",
9755
  desc: "Checks for text indent less than -99px",
9756
+ url: "https://github.com/CSSLint/csslint/wiki/Disallow-negative-text-indent",
9757
  browsers: "All",
9758
 
9759
+ // initialization
9760
+ init: function(parser, reporter) {
9761
+ "use strict";
9762
  var rule = this,
9763
  textIndent,
9764
  direction;
9765
 
9766
 
9767
+ function startRule() {
9768
  textIndent = false;
9769
  direction = "inherit";
9770
  }
9771
 
9772
+ // event handler for end of rules
9773
+ function endRule() {
9774
+ if (textIndent && direction !== "ltr") {
9775
  reporter.report("Negative text-indent doesn't work well with RTL. If you use text-indent for image replacement explicitly set direction for that item to ltr.", textIndent.line, textIndent.col, rule);
9776
  }
9777
  }
9779
  parser.addListener("startrule", startRule);
9780
  parser.addListener("startfontface", startRule);
9781
 
9782
+ // check for use of "font-size"
9783
+ parser.addListener("property", function(event) {
9784
  var name = event.property.toString().toLowerCase(),
9785
  value = event.value;
9786
 
9787
+ if (name === "text-indent" && value.parts[0].value < -99) {
9788
  textIndent = event.property;
9789
+ } else if (name === "direction" && value.toString() === "ltr") {
9790
  direction = "ltr";
9791
  }
9792
  });
9797
  }
9798
 
9799
  });
9800
+
9801
  /*
9802
  * Rule: Don't use properties with a underscore prefix.
9803
  *
9804
  */
9805
+
9806
  CSSLint.addRule({
9807
 
9808
+ // rule information
9809
  id: "underscore-property-hack",
9810
  name: "Disallow properties with an underscore prefix",
9811
  desc: "Checks for the underscore property hack (targets IE6)",
9812
+ url: "https://github.com/CSSLint/csslint/wiki/Disallow-underscore-hack",
9813
  browsers: "All",
9814
 
9815
+ // initialization
9816
+ init: function(parser, reporter) {
9817
+ "use strict";
9818
  var rule = this;
9819
 
9820
+ // check if property name starts with "_"
9821
+ parser.addListener("property", function(event) {
9822
  var property = event.property;
9823
 
9824
+ if (property.hack === "_") {
9825
  reporter.report("Property with underscore prefix found.", event.property.line, event.property.col, rule);
9826
  }
9827
  });
9828
  }
9829
  });
9830
+
9831
  /*
9832
  * Rule: Headings (h1-h6) should be defined only once.
9833
  */
9834
+
9835
  CSSLint.addRule({
9836
 
9837
+ // rule information
9838
  id: "unique-headings",
9839
  name: "Headings should only be defined once",
9840
  desc: "Headings should be defined only once.",
9841
+ url: "https://github.com/CSSLint/csslint/wiki/Headings-should-only-be-defined-once",
9842
  browsers: "All",
9843
 
9844
+ // initialization
9845
+ init: function(parser, reporter) {
9846
+ "use strict";
9847
  var rule = this;
9848
 
9849
+ var headings = {
9850
+ h1: 0,
9851
+ h2: 0,
9852
+ h3: 0,
9853
+ h4: 0,
9854
+ h5: 0,
9855
+ h6: 0
9856
+ };
9857
 
9858
+ parser.addListener("startrule", function(event) {
9859
  var selectors = event.selectors,
9860
  selector,
9861
  part,
9862
  pseudo,
9863
  i, j;
9864
 
9865
+ for (i=0; i < selectors.length; i++) {
9866
  selector = selectors[i];
9867
  part = selector.parts[selector.parts.length-1];
9868
 
9869
+ if (part.elementName && /(h[1-6])/i.test(part.elementName.toString())) {
9870
 
9871
+ for (j=0; j < part.modifiers.length; j++) {
9872
+ if (part.modifiers[j].type === "pseudo") {
9873
  pseudo = true;
9874
  break;
9875
  }
9876
  }
9877
 
9878
+ if (!pseudo) {
9879
  headings[RegExp.$1]++;
9880
  if (headings[RegExp.$1] > 1) {
9881
  reporter.report("Heading (" + part.elementName + ") has already been defined.", part.line, part.col, rule);
9885
  }
9886
  });
9887
 
9888
+ parser.addListener("endstylesheet", function() {
9889
  var prop,
9890
  messages = [];
9891
 
9892
+ for (prop in headings) {
9893
+ if (headings.hasOwnProperty(prop)) {
9894
+ if (headings[prop] > 1) {
9895
  messages.push(headings[prop] + " " + prop + "s");
9896
  }
9897
  }
9898
  }
9899
 
9900
+ if (messages.length) {
9901
  reporter.rollupWarn("You have " + messages.join(", ") + " defined in this stylesheet.", rule);
9902
  }
9903
  });
9904
  }
9905
 
9906
  });
9907
+
9908
  /*
9909
  * Rule: Don't use universal selector because it's slow.
9910
  */
9911
+
9912
  CSSLint.addRule({
9913
 
9914
+ // rule information
9915
  id: "universal-selector",
9916
  name: "Disallow universal selector",
9917
  desc: "The universal selector (*) is known to be slow.",
9918
+ url: "https://github.com/CSSLint/csslint/wiki/Disallow-universal-selector",
9919
  browsers: "All",
9920
 
9921
+ // initialization
9922
+ init: function(parser, reporter) {
9923
+ "use strict";
9924
  var rule = this;
9925
 
9926
+ parser.addListener("startrule", function(event) {
9927
  var selectors = event.selectors,
9928
  selector,
9929
  part,
9930
+ i;
 
9931
 
9932
+ for (i=0; i < selectors.length; i++) {
9933
  selector = selectors[i];
9934
 
9935
  part = selector.parts[selector.parts.length-1];
9936
+ if (part.elementName === "*") {
9937
  reporter.report(rule.desc, part.line, part.col, rule);
9938
  }
9939
  }
9941
  }
9942
 
9943
  });
9944
+
9945
  /*
9946
  * Rule: Don't use unqualified attribute selectors because they're just like universal selectors.
9947
  */
9948
+
9949
  CSSLint.addRule({
9950
 
9951
+ // rule information
9952
  id: "unqualified-attributes",
9953
  name: "Disallow unqualified attribute selectors",
9954
  desc: "Unqualified attribute selectors are known to be slow.",
9955
+ url: "https://github.com/CSSLint/csslint/wiki/Disallow-unqualified-attribute-selectors",
9956
  browsers: "All",
9957
 
9958
+ // initialization
9959
+ init: function(parser, reporter) {
9960
+ "use strict";
9961
+
9962
  var rule = this;
9963
 
9964
+ parser.addListener("startrule", function(event) {
9965
 
9966
  var selectors = event.selectors,
9967
+ selectorContainsClassOrId = false,
9968
  selector,
9969
  part,
9970
  modifier,
9971
+ i, k;
9972
 
9973
+ for (i=0; i < selectors.length; i++) {
9974
  selector = selectors[i];
9975
 
9976
  part = selector.parts[selector.parts.length-1];
9977
+ if (part.type === parser.SELECTOR_PART_TYPE) {
9978
+ for (k=0; k < part.modifiers.length; k++) {
9979
  modifier = part.modifiers[k];
9980
+
9981
+ if (modifier.type === "class" || modifier.type === "id") {
9982
+ selectorContainsClassOrId = true;
9983
+ break;
9984
+ }
9985
+ }
9986
+
9987
+ if (!selectorContainsClassOrId) {
9988
+ for (k=0; k < part.modifiers.length; k++) {
9989
+ modifier = part.modifiers[k];
9990
+ if (modifier.type === "attribute" && (!part.elementName || part.elementName === "*")) {
9991
+ reporter.report(rule.desc, part.line, part.col, rule);
9992
+ }
9993
  }
9994
  }
9995
  }
9999
  }
10000
 
10001
  });
10002
+
10003
  /*
10004
  * Rule: When using a vendor-prefixed property, make sure to
10005
  * include the standard one.
10006
  */
10007
+
10008
  CSSLint.addRule({
10009
 
10010
+ // rule information
10011
  id: "vendor-prefix",
10012
  name: "Require standard property with vendor prefix",
10013
  desc: "When using a vendor-prefixed property, make sure to include the standard one.",
10014
+ url: "https://github.com/CSSLint/csslint/wiki/Require-standard-property-with-vendor-prefix",
10015
  browsers: "All",
10016
 
10017
+ // initialization
10018
+ init: function(parser, reporter) {
10019
+ "use strict";
10020
  var rule = this,
10021
  properties,
10022
  num,
10066
  "-moz-box-shadow": "box-shadow",
10067
  "-webkit-box-shadow": "box-shadow",
10068
 
10069
+ "-moz-transform": "transform",
10070
+ "-webkit-transform": "transform",
10071
+ "-o-transform": "transform",
10072
+ "-ms-transform": "transform",
10073
 
10074
+ "-moz-transform-origin": "transform-origin",
10075
+ "-webkit-transform-origin": "transform-origin",
10076
+ "-o-transform-origin": "transform-origin",
10077
+ "-ms-transform-origin": "transform-origin",
10078
 
10079
+ "-moz-box-sizing": "box-sizing",
10080
+ "-webkit-box-sizing": "box-sizing"
 
 
 
 
10081
  };
10082
 
10083
+ // event handler for beginning of rules
10084
+ function startRule() {
10085
  properties = {};
10086
+ num = 1;
10087
  }
10088
 
10089
+ // event handler for end of rules
10090
+ function endRule() {
10091
  var prop,
10092
+ i,
10093
+ len,
10094
  needed,
10095
  actual,
10096
  needsStandard = [];
10097
 
10098
+ for (prop in properties) {
10099
+ if (propertiesToCheck[prop]) {
10100
+ needsStandard.push({
10101
+ actual: prop,
10102
+ needed: propertiesToCheck[prop]
10103
+ });
10104
  }
10105
  }
10106
 
10107
+ for (i=0, len=needsStandard.length; i < len; i++) {
10108
  needed = needsStandard[i].needed;
10109
  actual = needsStandard[i].actual;
10110
 
10111
+ if (!properties[needed]) {
10112
  reporter.report("Missing standard property '" + needed + "' to go along with '" + actual + "'.", properties[actual][0].name.line, properties[actual][0].name.col, rule);
10113
  } else {
10114
+ // make sure standard property is last
10115
+ if (properties[needed][0].pos < properties[actual][0].pos) {
10116
  reporter.report("Standard property '" + needed + "' should come after vendor-prefixed property '" + actual + "'.", properties[actual][0].name.line, properties[actual][0].name.col, rule);
10117
  }
10118
  }
10125
  parser.addListener("startpage", startRule);
10126
  parser.addListener("startpagemargin", startRule);
10127
  parser.addListener("startkeyframerule", startRule);
10128
+ parser.addListener("startviewport", startRule);
10129
 
10130
+ parser.addListener("property", function(event) {
10131
  var name = event.property.text.toLowerCase();
10132
 
10133
+ if (!properties[name]) {
10134
  properties[name] = [];
10135
  }
10136
 
10137
+ properties[name].push({
10138
+ name: event.property,
10139
+ value: event.value,
10140
+ pos: num++
10141
+ });
10142
  });
10143
 
10144
  parser.addListener("endrule", endRule);
10146
  parser.addListener("endpage", endRule);
10147
  parser.addListener("endpagemargin", endRule);
10148
  parser.addListener("endkeyframerule", endRule);
10149
+ parser.addListener("endviewport", endRule);
10150
  }
10151
 
10152
  });
10153
+
10154
  /*
10155
  * Rule: You don't need to specify units when a value is 0.
10156
  */
10157
+
10158
  CSSLint.addRule({
10159
 
10160
+ // rule information
10161
  id: "zero-units",
10162
  name: "Disallow units for 0 values",
10163
  desc: "You don't need to specify units when a value is 0.",
10164
+ url: "https://github.com/CSSLint/csslint/wiki/Disallow-units-for-zero-values",
10165
  browsers: "All",
10166
 
10167
+ // initialization
10168
+ init: function(parser, reporter) {
10169
+ "use strict";
10170
  var rule = this;
10171
 
10172
+ // count how many times "float" is used
10173
+ parser.addListener("property", function(event) {
10174
  var parts = event.value.parts,
10175
  i = 0,
10176
  len = parts.length;
10177
 
10178
+ while (i < len) {
10179
+ if ((parts[i].units || parts[i].type === "percentage") && parts[i].value === 0 && parts[i].type !== "time") {
10180
  reporter.report("Values of 0 shouldn't have units specified.", parts[i].line, parts[i].col, rule);
10181
  }
10182
  i++;
10187
  }
10188
 
10189
  });
10190
+
10191
  (function() {
10192
+ "use strict";
10193
 
10194
  /**
10195
  * Replace special characters before write to output.
10208
  return "";
10209
  }
10210
 
10211
+ return str.replace(/["&><]/g, function(match) {
10212
  switch (match) {
10213
  case "\"":
10214
  return "&quot;";
10223
  };
10224
 
10225
  CSSLint.addFormatter({
10226
+ // format information
10227
  id: "checkstyle-xml",
10228
  name: "Checkstyle XML format",
10229
 
10231
  * Return opening root XML tag.
10232
  * @return {String} to prepend before all results
10233
  */
10234
+ startFormat: function() {
10235
  return "<?xml version=\"1.0\" encoding=\"utf-8\"?><checkstyle>";
10236
  },
10237
 
10239
  * Return closing root XML tag.
10240
  * @return {String} to append after all results
10241
  */
10242
+ endFormat: function() {
10243
  return "</checkstyle>";
10244
  },
10245
 
10260
  * @param options {Object} (UNUSED for now) specifies special handling of output
10261
  * @return {String} output for results
10262
  */
10263
+ formatResults: function(results, filename/*, options*/) {
10264
  var messages = results.messages,
10265
  output = [];
10266
 
10272
  * @return rule source as {String}
10273
  */
10274
  var generateSource = function(rule) {
10275
+ if (!rule || !("name" in rule)) {
10276
  return "";
10277
  }
10278
+ return "net.csslint." + rule.name.replace(/\s/g, "");
10279
  };
10280
 
10281
 
 
10282
  if (messages.length > 0) {
10283
  output.push("<file name=\""+filename+"\">");
10284
+ CSSLint.Util.forEach(messages, function (message) {
10285
+ // ignore rollups for now
10286
  if (!message.rollup) {
10287
+ output.push("<error line=\"" + message.line + "\" column=\"" + message.col + "\" severity=\"" + message.type + "\"" +
10288
  " message=\"" + xmlEscape(message.message) + "\" source=\"" + generateSource(message.rule) +"\"/>");
10289
  }
10290
  });
10296
  });
10297
 
10298
  }());
10299
+
10300
  CSSLint.addFormatter({
10301
+ // format information
10302
  id: "compact",
10303
  name: "Compact, 'porcelain' format",
10304
 
10307
  * @return {String} to prepend before all results
10308
  */
10309
  startFormat: function() {
10310
+ "use strict";
10311
  return "";
10312
  },
10313
 
10316
  * @return {String} to append after all results
10317
  */
10318
  endFormat: function() {
10319
+ "use strict";
10320
  return "";
10321
  },
10322
 
10328
  * @return {String} output for results
10329
  */
10330
  formatResults: function(results, filename, options) {
10331
+ "use strict";
10332
  var messages = results.messages,
10333
  output = "";
10334
  options = options || {};
10346
  return options.quiet ? "" : filename + ": Lint Free!";
10347
  }
10348
 
10349
+ CSSLint.Util.forEach(messages, function(message) {
10350
  if (message.rollup) {
10351
+ output += filename + ": " + capitalize(message.type) + " - " + message.message + " (" + message.rule.id + ")\n";
10352
  } else {
10353
+ output += filename + ": line " + message.line +
10354
+ ", col " + message.col + ", " + capitalize(message.type) + " - " + message.message + " (" + message.rule.id + ")\n";
10355
  }
10356
  });
10357
 
10358
  return output;
10359
  }
10360
  });
10361
+
10362
  CSSLint.addFormatter({
10363
+ // format information
10364
  id: "csslint-xml",
10365
  name: "CSSLint XML format",
10366
 
10368
  * Return opening root XML tag.
10369
  * @return {String} to prepend before all results
10370
  */
10371
+ startFormat: function() {
10372
+ "use strict";
10373
  return "<?xml version=\"1.0\" encoding=\"utf-8\"?><csslint>";
10374
  },
10375
 
10377
  * Return closing root XML tag.
10378
  * @return {String} to append after all results
10379
  */
10380
+ endFormat: function() {
10381
+ "use strict";
10382
  return "</csslint>";
10383
  },
10384
 
10389
  * @param options {Object} (UNUSED for now) specifies special handling of output
10390
  * @return {String} output for results
10391
  */
10392
+ formatResults: function(results, filename/*, options*/) {
10393
+ "use strict";
10394
  var messages = results.messages,
10395
  output = [];
10396
 
10410
  if (!str || str.constructor !== String) {
10411
  return "";
10412
  }
10413
+ return str.replace(/"/g, "'").replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
10414
  };
10415
 
10416
  if (messages.length > 0) {
10417
  output.push("<file name=\""+filename+"\">");
10418
+ CSSLint.Util.forEach(messages, function (message) {
10419
  if (message.rollup) {
10420
  output.push("<issue severity=\"" + message.type + "\" reason=\"" + escapeSpecialCharacters(message.message) + "\" evidence=\"" + escapeSpecialCharacters(message.evidence) + "\"/>");
10421
  } else {
10429
  return output.join("");
10430
  }
10431
  });
10432
+
10433
+ /* globals JSON: true */
10434
+
10435
+ CSSLint.addFormatter({
10436
+ // format information
10437
+ id: "json",
10438
+ name: "JSON",
10439
+
10440
+ /**
10441
+ * Return content to be printed before all file results.
10442
+ * @return {String} to prepend before all results
10443
+ */
10444
+ startFormat: function() {
10445
+ "use strict";
10446
+ this.json = [];
10447
+ return "";
10448
+ },
10449
+
10450
+ /**
10451
+ * Return content to be printed after all file results.
10452
+ * @return {String} to append after all results
10453
+ */
10454
+ endFormat: function() {
10455
+ "use strict";
10456
+ var ret = "";
10457
+ if (this.json.length > 0) {
10458
+ if (this.json.length === 1) {
10459
+ ret = JSON.stringify(this.json[0]);
10460
+ } else {
10461
+ ret = JSON.stringify(this.json);
10462
+ }
10463
+ }
10464
+ return ret;
10465
+ },
10466
+
10467
+ /**
10468
+ * Given CSS Lint results for a file, return output for this format.
10469
+ * @param results {Object} with error and warning messages
10470
+ * @param filename {String} relative file path (Unused)
10471
+ * @return {String} output for results
10472
+ */
10473
+ formatResults: function(results, filename, options) {
10474
+ "use strict";
10475
+ if (results.messages.length > 0 || !options.quiet) {
10476
+ this.json.push({
10477
+ filename: filename,
10478
+ messages: results.messages,
10479
+ stats: results.stats
10480
+ });
10481
+ }
10482
+ return "";
10483
+ }
10484
+ });
10485
+
10486
  CSSLint.addFormatter({
10487
+ // format information
10488
  id: "junit-xml",
10489
  name: "JUNIT XML format",
10490
 
10492
  * Return opening root XML tag.
10493
  * @return {String} to prepend before all results
10494
  */
10495
+ startFormat: function() {
10496
+ "use strict";
10497
  return "<?xml version=\"1.0\" encoding=\"utf-8\"?><testsuites>";
10498
  },
10499
 
10502
  * @return {String} to append after all results
10503
  */
10504
  endFormat: function() {
10505
+ "use strict";
10506
  return "</testsuites>";
10507
  },
10508
 
10513
  * @param options {Object} (UNUSED for now) specifies special handling of output
10514
  * @return {String} output for results
10515
  */
10516
+ formatResults: function(results, filename/*, options*/) {
10517
+ "use strict";
10518
 
10519
  var messages = results.messages,
10520
  output = [],
10521
  tests = {
10522
+ "error": 0,
10523
+ "failure": 0
10524
  };
10525
 
10526
  /**
10531
  * @return rule source as {String}
10532
  */
10533
  var generateSource = function(rule) {
10534
+ if (!rule || !("name" in rule)) {
10535
  return "";
10536
  }
10537
+ return "net.csslint." + rule.name.replace(/\s/g, "");
10538
  };
10539
 
10540
  /**
10554
  return "";
10555
  }
10556
 
10557
+ return str.replace(/"/g, "'").replace(/</g, "&lt;").replace(/>/g, "&gt;");
10558
 
10559
  };
10560
 
10561
  if (messages.length > 0) {
10562
 
10563
+ messages.forEach(function (message) {
10564
 
10565
  // since junit has no warning class
10566
  // all issues as errors
10567
+ var type = message.type === "warning" ? "error" : message.type;
10568
 
10569
+ // ignore rollups for now
10570
  if (!message.rollup) {
10571
 
10572
+ // build the test case separately, once joined
10573
  // we'll add it to a custom array filtered by type
10574
  output.push("<testcase time=\"0\" name=\"" + generateSource(message.rule) + "\">");
10575
+ output.push("<" + type + " message=\"" + escapeSpecialCharacters(message.message) + "\"><![CDATA[" + message.line + ":" + message.col + ":" + escapeSpecialCharacters(message.evidence) + "]]></" + type + ">");
10576
  output.push("</testcase>");
10577
 
10578
  tests[type] += 1;
10590
 
10591
  }
10592
  });
10593
+
10594
  CSSLint.addFormatter({
10595
+ // format information
10596
  id: "lint-xml",
10597
  name: "Lint XML format",
10598
 
10600
  * Return opening root XML tag.
10601
  * @return {String} to prepend before all results
10602
  */
10603
+ startFormat: function() {
10604
+ "use strict";
10605
  return "<?xml version=\"1.0\" encoding=\"utf-8\"?><lint>";
10606
  },
10607
 
10609
  * Return closing root XML tag.
10610
  * @return {String} to append after all results
10611
  */
10612
+ endFormat: function() {
10613
+ "use strict";
10614
  return "</lint>";
10615
  },
10616
 
10621
  * @param options {Object} (UNUSED for now) specifies special handling of output
10622
  * @return {String} output for results
10623
  */
10624
+ formatResults: function(results, filename/*, options*/) {
10625
+ "use strict";
10626
  var messages = results.messages,
10627
  output = [];
10628
 
10642
  if (!str || str.constructor !== String) {
10643
  return "";
10644
  }
10645
+ return str.replace(/"/g, "'").replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
10646
  };
10647
 
10648
  if (messages.length > 0) {
10649
 
10650
  output.push("<file name=\""+filename+"\">");
10651
+ CSSLint.Util.forEach(messages, function (message) {
10652
  if (message.rollup) {
10653
  output.push("<issue severity=\"" + message.type + "\" reason=\"" + escapeSpecialCharacters(message.message) + "\" evidence=\"" + escapeSpecialCharacters(message.evidence) + "\"/>");
10654
  } else {
10655
+ var rule = "";
10656
+ if (message.rule && message.rule.id) {
10657
+ rule = "rule=\"" + escapeSpecialCharacters(message.rule.id) + "\" ";
10658
+ }
10659
+ output.push("<issue " + rule + "line=\"" + message.line + "\" char=\"" + message.col + "\" severity=\"" + message.type + "\"" +
10660
  " reason=\"" + escapeSpecialCharacters(message.message) + "\" evidence=\"" + escapeSpecialCharacters(message.evidence) + "\"/>");
10661
  }
10662
  });
10666
  return output.join("");
10667
  }
10668
  });
10669
+
10670
  CSSLint.addFormatter({
10671
+ // format information
10672
  id: "text",
10673
  name: "Plain Text",
10674
 
10677
  * @return {String} to prepend before all results
10678
  */
10679
  startFormat: function() {
10680
+ "use strict";
10681
  return "";
10682
  },
10683
 
10686
  * @return {String} to append after all results
10687
  */
10688
  endFormat: function() {
10689
+ "use strict";
10690
  return "";
10691
  },
10692
 
10698
  * @return {String} output for results
10699
  */
10700
  formatResults: function(results, filename, options) {
10701
+ "use strict";
10702
  var messages = results.messages,
10703
  output = "";
10704
  options = options || {};
10707
  return options.quiet ? "" : "\n\ncsslint: No errors in " + filename + ".";
10708
  }
10709
 
10710
+ output = "\n\ncsslint: There ";
10711
+ if (messages.length === 1) {
10712
+ output += "is 1 problem";
10713
+ } else {
10714
+ output += "are " + messages.length + " problems";
10715
+ }
10716
+ output += " in " + filename + ".";
10717
+
10718
  var pos = filename.lastIndexOf("/"),
10719
  shortFilename = filename;
10720
 
10721
+ if (pos === -1) {
10722
  pos = filename.lastIndexOf("\\");
10723
  }
10724
+ if (pos > -1) {
10725
  shortFilename = filename.substring(pos+1);
10726
  }
10727
 
10740
  return output;
10741
  }
10742
  });
10743
+
10744
  return CSSLint;
10745
  })();
js/csslint.min.js CHANGED
@@ -1,4 +1,4 @@
1
- var exports=exports||{},CSSLint=function(){function Reporter(e,t){this.messages=[],this.stats=[],this.lines=e,this.ruleset=t}var parserlib={};!function(){function e(){this._listeners={}}function t(e){this._input=e.replace(/\n\r?/g,"\n"),this._line=1,this._col=1,this._cursor=0}function r(e,t,r){this.col=r,this.line=t,this.message=e}function n(e,t,r,n){this.col=r,this.line=t,this.text=e,this.type=n}function i(e,r){this._reader=e?new t(e.toString()):null,this._token=null,this._tokenData=r,this._lt=[],this._ltIndex=0,this._ltIndexCache=[]}e.prototype={constructor:e,addListener:function(e,t){this._listeners[e]||(this._listeners[e]=[]),this._listeners[e].push(t)},fire:function(e){if("string"==typeof e&&(e={type:e}),"undefined"!=typeof e.target&&(e.target=this),"undefined"==typeof e.type)throw new Error("Event object missing 'type' property.");if(this._listeners[e.type])for(var t=this._listeners[e.type].concat(),r=0,n=t.length;r<n;r++)t[r].call(this,e)},removeListener:function(e,t){if(this._listeners[e])for(var r=this._listeners[e],n=0,i=r.length;n<i;n++)if(r[n]===t){r.splice(n,1);break}}},t.prototype={constructor:t,getCol:function(){return this._col},getLine:function(){return this._line},eof:function(){return this._cursor==this._input.length},peek:function(e){var t=null;return e="undefined"==typeof e?1:e,this._cursor<this._input.length&&(t=this._input.charAt(this._cursor+e-1)),t},read:function(){var e=null;return this._cursor<this._input.length&&("\n"==this._input.charAt(this._cursor)?(this._line++,this._col=1):this._col++,e=this._input.charAt(this._cursor++)),e},mark:function(){this._bookmark={cursor:this._cursor,line:this._line,col:this._col}},reset:function(){this._bookmark&&(this._cursor=this._bookmark.cursor,this._line=this._bookmark.line,this._col=this._bookmark.col,delete this._bookmark)},readTo:function(e){for(var t,r="";r.length<e.length||r.lastIndexOf(e)!=r.length-e.length;){if(t=this.read(),!t)throw new Error('Expected "'+e+'" at line '+this._line+", col "+this._col+".");r+=t}return r},readWhile:function(e){for(var t="",r=this.read();null!==r&&e(r);)t+=r,r=this.read();return t},readMatch:function(e){var t=this._input.substring(this._cursor),r=null;return"string"==typeof e?0===t.indexOf(e)&&(r=this.readCount(e.length)):e instanceof RegExp&&e.test(t)&&(r=this.readCount(RegExp.lastMatch.length)),r},readCount:function(e){for(var t="";e--;)t+=this.read();return t}},r.prototype=new Error,n.fromToken=function(e){return new n(e.value,e.startLine,e.startCol)},n.prototype={constructor:n,valueOf:function(){return this.toString()},toString:function(){return this.text}},i.createTokenData=function(e){var t=[],r={},n=e.concat([]),i=0,o=n.length+1;for(n.UNKNOWN=-1,n.unshift({name:"EOF"});i<o;i++)t.push(n[i].name),n[n[i].name]=i,n[i].text&&(r[n[i].text]=i);return n.name=function(e){return t[e]},n.type=function(e){return r[e]},n},i.prototype={constructor:i,match:function(e,t){e instanceof Array||(e=[e]);for(var r=this.get(t),n=0,i=e.length;n<i;)if(r==e[n++])return!0;return this.unget(),!1},mustMatch:function(e,t){var n;if(e instanceof Array||(e=[e]),!this.match.apply(this,arguments))throw n=this.LT(1),new r("Expected "+this._tokenData[e[0]].name+" at line "+n.startLine+", col "+n.startCol+".",n.startLine,n.startCol)},advance:function(e,t){for(;0!==this.LA(0)&&!this.match(e,t);)this.get();return this.LA(0)},get:function(e){var t,r,n=this._tokenData,i=(this._reader,0);n.length;if(this._lt.length&&this._ltIndex>=0&&this._ltIndex<this._lt.length){for(i++,this._token=this._lt[this._ltIndex++],r=n[this._token.type];void 0!==r.channel&&e!==r.channel&&this._ltIndex<this._lt.length;)this._token=this._lt[this._ltIndex++],r=n[this._token.type],i++;if((void 0===r.channel||e===r.channel)&&this._ltIndex<=this._lt.length)return this._ltIndexCache.push(i),this._token.type}return t=this._getToken(),t.type>-1&&!n[t.type].hide&&(t.channel=n[t.type].channel,this._token=t,this._lt.push(t),this._ltIndexCache.push(this._lt.length-this._ltIndex+i),this._lt.length>5&&this._lt.shift(),this._ltIndexCache.length>5&&this._ltIndexCache.shift(),this._ltIndex=this._lt.length),r=n[t.type],r&&(r.hide||void 0!==r.channel&&e!==r.channel)?this.get(e):t.type},LA:function(e){var t,r=e;if(e>0){if(e>5)throw new Error("Too much lookahead.");for(;r;)t=this.get(),r--;for(;r<e;)this.unget(),r++}else if(e<0){if(!this._lt[this._ltIndex+e])throw new Error("Too much lookbehind.");t=this._lt[this._ltIndex+e].type}else t=this._token.type;return t},LT:function(e){return this.LA(e),this._lt[this._ltIndex+e-1]},peek:function(){return this.LA(1)},token:function(){return this._token},tokenName:function(e){return e<0||e>this._tokenData.length?"UNKNOWN_TOKEN":this._tokenData[e].name},tokenType:function(e){return this._tokenData[e]||-1},unget:function(){if(!this._ltIndexCache.length)throw new Error("Too much lookahead.");this._ltIndex-=this._ltIndexCache.pop(),this._token=this._lt[this._ltIndex-1]}},parserlib.util={StringReader:t,SyntaxError:r,SyntaxUnit:n,EventTarget:e,TokenStreamBase:i}}(),function(){function Combinator(e,t,r){SyntaxUnit.call(this,e,t,r,Parser.COMBINATOR_TYPE),this.type="unknown",/^\s+$/.test(e)?this.type="descendant":">"==e?this.type="child":"+"==e?this.type="adjacent-sibling":"~"==e&&(this.type="sibling")}function MediaFeature(e,t){SyntaxUnit.call(this,"("+e+(null!==t?":"+t:"")+")",e.startLine,e.startCol,Parser.MEDIA_FEATURE_TYPE),this.name=e,this.value=t}function MediaQuery(e,t,r,n,i){SyntaxUnit.call(this,(e?e+" ":"")+(t?t:"")+(t&&r.length>0?" and ":"")+r.join(" and "),n,i,Parser.MEDIA_QUERY_TYPE),this.modifier=e,this.mediaType=t,this.features=r}function Parser(e){EventTarget.call(this),this.options=e||{},this._tokenStream=null}function PropertyName(e,t,r,n){SyntaxUnit.call(this,e,r,n,Parser.PROPERTY_NAME_TYPE),this.hack=t}function PropertyValue(e,t,r){SyntaxUnit.call(this,e.join(" "),t,r,Parser.PROPERTY_VALUE_TYPE),this.parts=e}function PropertyValueIterator(e){this._i=0,this._parts=e.parts,this._marks=[],this.value=e}function PropertyValuePart(text,line,col){SyntaxUnit.call(this,text,line,col,Parser.PROPERTY_VALUE_PART_TYPE),this.type="unknown";var temp;if(/^([+\-]?[\d\.]+)([a-z]+)$/i.test(text))switch(this.type="dimension",this.value=+RegExp.$1,this.units=RegExp.$2,this.units.toLowerCase()){case"em":case"rem":case"ex":case"px":case"cm":case"mm":case"in":case"pt":case"pc":case"ch":case"vh":case"vw":case"vm":this.type="length";break;case"deg":case"rad":case"grad":this.type="angle";break;case"ms":case"s":this.type="time";break;case"hz":case"khz":this.type="frequency";break;case"dpi":case"dpcm":this.type="resolution"}else/^([+\-]?[\d\.]+)%$/i.test(text)?(this.type="percentage",this.value=+RegExp.$1):/^([+\-]?[\d\.]+)%$/i.test(text)?(this.type="percentage",this.value=+RegExp.$1):/^([+\-]?\d+)$/i.test(text)?(this.type="integer",this.value=+RegExp.$1):/^([+\-]?[\d\.]+)$/i.test(text)?(this.type="number",this.value=+RegExp.$1):/^#([a-f0-9]{3,6})/i.test(text)?(this.type="color",temp=RegExp.$1,3==temp.length?(this.red=parseInt(temp.charAt(0)+temp.charAt(0),16),this.green=parseInt(temp.charAt(1)+temp.charAt(1),16),this.blue=parseInt(temp.charAt(2)+temp.charAt(2),16)):(this.red=parseInt(temp.substring(0,2),16),this.green=parseInt(temp.substring(2,4),16),this.blue=parseInt(temp.substring(4,6),16))):/^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/i.test(text)?(this.type="color",this.red=+RegExp.$1,this.green=+RegExp.$2,this.blue=+RegExp.$3):/^rgb\(\s*(\d+)%\s*,\s*(\d+)%\s*,\s*(\d+)%\s*\)/i.test(text)?(this.type="color",this.red=255*+RegExp.$1/100,this.green=255*+RegExp.$2/100,this.blue=255*+RegExp.$3/100):/^rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*([\d\.]+)\s*\)/i.test(text)?(this.type="color",this.red=+RegExp.$1,this.green=+RegExp.$2,this.blue=+RegExp.$3,this.alpha=+RegExp.$4):/^rgba\(\s*(\d+)%\s*,\s*(\d+)%\s*,\s*(\d+)%\s*,\s*([\d\.]+)\s*\)/i.test(text)?(this.type="color",this.red=255*+RegExp.$1/100,this.green=255*+RegExp.$2/100,this.blue=255*+RegExp.$3/100,this.alpha=+RegExp.$4):/^hsl\(\s*(\d+)\s*,\s*(\d+)%\s*,\s*(\d+)%\s*\)/i.test(text)?(this.type="color",this.hue=+RegExp.$1,this.saturation=+RegExp.$2/100,this.lightness=+RegExp.$3/100):/^hsla\(\s*(\d+)\s*,\s*(\d+)%\s*,\s*(\d+)%\s*,\s*([\d\.]+)\s*\)/i.test(text)?(this.type="color",this.hue=+RegExp.$1,this.saturation=+RegExp.$2/100,this.lightness=+RegExp.$3/100,this.alpha=+RegExp.$4):/^url\(["']?([^\)"']+)["']?\)/i.test(text)?(this.type="uri",this.uri=RegExp.$1):/^([^\(]+)\(/i.test(text)?(this.type="function",this.name=RegExp.$1,this.value=text):/^["'][^"']*["']/.test(text)?(this.type="string",this.value=eval(text)):Colors[text.toLowerCase()]?(this.type="color",temp=Colors[text.toLowerCase()].substring(1),this.red=parseInt(temp.substring(0,2),16),this.green=parseInt(temp.substring(2,4),16),this.blue=parseInt(temp.substring(4,6),16)):/^[\,\/]$/.test(text)?(this.type="operator",this.value=text):/^[a-z\-\u0080-\uFFFF][a-z0-9\-\u0080-\uFFFF]*$/i.test(text)&&(this.type="identifier",this.value=text)}function Selector(e,t,r){SyntaxUnit.call(this,e.join(" "),t,r,Parser.SELECTOR_TYPE),this.parts=e,this.specificity=Specificity.calculate(this)}function SelectorPart(e,t,r,n,i){SyntaxUnit.call(this,r,n,i,Parser.SELECTOR_PART_TYPE),this.elementName=e,this.modifiers=t}function SelectorSubPart(e,t,r,n){SyntaxUnit.call(this,e,r,n,Parser.SELECTOR_SUB_PART_TYPE),this.type=t,this.args=[]}function Specificity(e,t,r,n){this.a=e,this.b=t,this.c=r,this.d=n}function isHexDigit(e){return null!==e&&h.test(e)}function isDigit(e){return null!==e&&/\d/.test(e)}function isWhitespace(e){return null!==e&&/\s/.test(e)}function isNewLine(e){return null!==e&&nl.test(e)}function isNameStart(e){return null!==e&&/[a-z_\u0080-\uFFFF\\]/i.test(e)}function isNameChar(e){return null!==e&&(isNameStart(e)||/[0-9\-\\]/.test(e))}function isIdentStart(e){return null!==e&&(isNameStart(e)||/\-\\/.test(e))}function mix(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r]);return e}function TokenStream(e){TokenStreamBase.call(this,e,Tokens)}function ValidationError(e,t,r){this.col=r,this.line=t,this.message=e}var EventTarget=parserlib.util.EventTarget,TokenStreamBase=parserlib.util.TokenStreamBase,StringReader=parserlib.util.StringReader,SyntaxError=parserlib.util.SyntaxError,SyntaxUnit=parserlib.util.SyntaxUnit,Colors={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgreen:"#90ee90",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370d8",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#d87093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32",activeBorder:"Active window border.",activecaption:"Active window caption.",appworkspace:"Background color of multiple document interface.",background:"Desktop background.",buttonface:"The face background color for 3-D elements that appear 3-D due to one layer of surrounding border.",buttonhighlight:"The color of the border facing the light source for 3-D elements that appear 3-D due to one layer of surrounding border.",buttonshadow:"The color of the border away from the light source for 3-D elements that appear 3-D due to one layer of surrounding border.",buttontext:"Text on push buttons.",captiontext:"Text in caption, size box, and scrollbar arrow box.",graytext:"Grayed (disabled) text. This color is set to #000 if the current display driver does not support a solid gray color.",highlight:"Item(s) selected in a control.",highlighttext:"Text of item(s) selected in a control.",inactiveborder:"Inactive window border.",inactivecaption:"Inactive window caption.",inactivecaptiontext:"Color of text in an inactive caption.",infobackground:"Background color for tooltip controls.",infotext:"Text color for tooltip controls.",menu:"Menu background.",menutext:"Text in menus.",scrollbar:"Scroll bar gray area.",threeddarkshadow:"The color of the darker (generally outer) of the two borders away from the light source for 3-D elements that appear 3-D due to two concentric layers of surrounding border.",threedface:"The face background color for 3-D elements that appear 3-D due to two concentric layers of surrounding border.",threedhighlight:"The color of the lighter (generally outer) of the two borders facing the light source for 3-D elements that appear 3-D due to two concentric layers of surrounding border.",threedlightshadow:"The color of the darker (generally inner) of the two borders facing the light source for 3-D elements that appear 3-D due to two concentric layers of surrounding border.",threedshadow:"The color of the lighter (generally inner) of the two borders away from the light source for 3-D elements that appear 3-D due to two concentric layers of surrounding border.",window:"Window background.",windowframe:"Window frame.",windowtext:"Text in windows."};Combinator.prototype=new SyntaxUnit,Combinator.prototype.constructor=Combinator,MediaFeature.prototype=new SyntaxUnit,MediaFeature.prototype.constructor=MediaFeature,MediaQuery.prototype=new SyntaxUnit,MediaQuery.prototype.constructor=MediaQuery,Parser.DEFAULT_TYPE=0,Parser.COMBINATOR_TYPE=1,Parser.MEDIA_FEATURE_TYPE=2,Parser.MEDIA_QUERY_TYPE=3,Parser.PROPERTY_NAME_TYPE=4,Parser.PROPERTY_VALUE_TYPE=5,Parser.PROPERTY_VALUE_PART_TYPE=6,Parser.SELECTOR_TYPE=7,Parser.SELECTOR_PART_TYPE=8,Parser.SELECTOR_SUB_PART_TYPE=9,Parser.prototype=function(){var e,t=new EventTarget,r={constructor:Parser,DEFAULT_TYPE:0,COMBINATOR_TYPE:1,MEDIA_FEATURE_TYPE:2,MEDIA_QUERY_TYPE:3,PROPERTY_NAME_TYPE:4,PROPERTY_VALUE_TYPE:5,PROPERTY_VALUE_PART_TYPE:6,SELECTOR_TYPE:7,SELECTOR_PART_TYPE:8,SELECTOR_SUB_PART_TYPE:9,_stylesheet:function(){var e,t,r,n=this._tokenStream;for(this.fire("startstylesheet"),this._charset(),this._skipCruft();n.peek()==Tokens.IMPORT_SYM;)this._import(),this._skipCruft();for(;n.peek()==Tokens.NAMESPACE_SYM;)this._namespace(),this._skipCruft();for(r=n.peek();r>Tokens.EOF;){try{switch(r){case Tokens.MEDIA_SYM:this._media(),this._skipCruft();break;case Tokens.PAGE_SYM:this._page(),this._skipCruft();break;case Tokens.FONT_FACE_SYM:this._font_face(),this._skipCruft();break;case Tokens.KEYFRAMES_SYM:this._keyframes(),this._skipCruft();break;case Tokens.VIEWPORT_SYM:this._viewport(),this._skipCruft();break;case Tokens.UNKNOWN_SYM:if(n.get(),this.options.strict)throw new SyntaxError("Unknown @ rule.",n.LT(0).startLine,n.LT(0).startCol);for(this.fire({type:"error",error:null,message:"Unknown @ rule: "+n.LT(0).value+".",line:n.LT(0).startLine,col:n.LT(0).startCol}),e=0;n.advance([Tokens.LBRACE,Tokens.RBRACE])==Tokens.LBRACE;)e++;for(;e;)n.advance([Tokens.RBRACE]),e--;break;case Tokens.S:this._readWhitespace();break;default:if(!this._ruleset())switch(r){case Tokens.CHARSET_SYM:throw t=n.LT(1),this._charset(!1),new SyntaxError("@charset not allowed here.",t.startLine,t.startCol);case Tokens.IMPORT_SYM:throw t=n.LT(1),this._import(!1),new SyntaxError("@import not allowed here.",t.startLine,t.startCol);case Tokens.NAMESPACE_SYM:throw t=n.LT(1),this._namespace(!1),new SyntaxError("@namespace not allowed here.",t.startLine,t.startCol);default:n.get(),this._unexpectedToken(n.token())}}}catch(e){if(!(e instanceof SyntaxError)||this.options.strict)throw e;this.fire({type:"error",error:e,message:e.message,line:e.line,col:e.col})}r=n.peek()}r!=Tokens.EOF&&this._unexpectedToken(n.token()),this.fire("endstylesheet")},_charset:function(e){var t,r,n,i,o=this._tokenStream;o.match(Tokens.CHARSET_SYM)&&(n=o.token().startLine,i=o.token().startCol,this._readWhitespace(),o.mustMatch(Tokens.STRING),r=o.token(),t=r.value,this._readWhitespace(),o.mustMatch(Tokens.SEMICOLON),e!==!1&&this.fire({type:"charset",charset:t,line:n,col:i}))},_import:function(e){var t,r,n=this._tokenStream,i=[];n.mustMatch(Tokens.IMPORT_SYM),r=n.token(),this._readWhitespace(),n.mustMatch([Tokens.STRING,Tokens.URI]),t=n.token().value.replace(/(?:url\()?["']([^"']+)["']\)?/,"$1"),this._readWhitespace(),i=this._media_query_list(),n.mustMatch(Tokens.SEMICOLON),this._readWhitespace(),e!==!1&&this.fire({type:"import",uri:t,media:i,line:r.startLine,col:r.startCol})},_namespace:function(e){var t,r,n,i,o=this._tokenStream;o.mustMatch(Tokens.NAMESPACE_SYM),t=o.token().startLine,r=o.token().startCol,this._readWhitespace(),o.match(Tokens.IDENT)&&(n=o.token().value,this._readWhitespace()),o.mustMatch([Tokens.STRING,Tokens.URI]),i=o.token().value.replace(/(?:url\()?["']([^"']+)["']\)?/,"$1"),this._readWhitespace(),o.mustMatch(Tokens.SEMICOLON),this._readWhitespace(),e!==!1&&this.fire({type:"namespace",prefix:n,uri:i,line:t,col:r})},_media:function(){var e,t,r,n=this._tokenStream;for(n.mustMatch(Tokens.MEDIA_SYM),e=n.token().startLine,t=n.token().startCol,this._readWhitespace(),r=this._media_query_list(),n.mustMatch(Tokens.LBRACE),this._readWhitespace(),this.fire({type:"startmedia",media:r,line:e,col:t});;)if(n.peek()==Tokens.PAGE_SYM)this._page();else if(n.peek()==Tokens.FONT_FACE_SYM)this._font_face();else if(!this._ruleset())break;n.mustMatch(Tokens.RBRACE),this._readWhitespace(),this.fire({type:"endmedia",media:r,line:e,col:t})},_media_query_list:function(){var e=this._tokenStream,t=[];for(this._readWhitespace(),e.peek()!=Tokens.IDENT&&e.peek()!=Tokens.LPAREN||t.push(this._media_query());e.match(Tokens.COMMA);)this._readWhitespace(),t.push(this._media_query());return t},_media_query:function(){var e=this._tokenStream,t=null,r=null,n=null,i=[];if(e.match(Tokens.IDENT)&&(r=e.token().value.toLowerCase(),"only"!=r&&"not"!=r?(e.unget(),r=null):n=e.token()),this._readWhitespace(),e.peek()==Tokens.IDENT?(t=this._media_type(),null===n&&(n=e.token())):e.peek()==Tokens.LPAREN&&(null===n&&(n=e.LT(1)),i.push(this._media_expression())),null===t&&0===i.length)return null;for(this._readWhitespace();e.match(Tokens.IDENT);)"and"!=e.token().value.toLowerCase()&&this._unexpectedToken(e.token()),this._readWhitespace(),i.push(this._media_expression());return new MediaQuery(r,t,i,n.startLine,n.startCol)},_media_type:function(){return this._media_feature()},_media_expression:function(){var e,t=this._tokenStream,r=null,n=null;return t.mustMatch(Tokens.LPAREN),r=this._media_feature(),this._readWhitespace(),t.match(Tokens.COLON)&&(this._readWhitespace(),e=t.LT(1),n=this._expression()),t.mustMatch(Tokens.RPAREN),this._readWhitespace(),new MediaFeature(r,n?new SyntaxUnit(n,e.startLine,e.startCol):null)},_media_feature:function(){var e=this._tokenStream;return e.mustMatch(Tokens.IDENT),SyntaxUnit.fromToken(e.token())},_page:function(){var e,t,r=this._tokenStream,n=null,i=null;r.mustMatch(Tokens.PAGE_SYM),e=r.token().startLine,t=r.token().startCol,this._readWhitespace(),r.match(Tokens.IDENT)&&(n=r.token().value,"auto"===n.toLowerCase()&&this._unexpectedToken(r.token())),r.peek()==Tokens.COLON&&(i=this._pseudo_page()),this._readWhitespace(),this.fire({type:"startpage",id:n,pseudo:i,line:e,col:t}),this._readDeclarations(!0,!0),this.fire({type:"endpage",id:n,pseudo:i,line:e,col:t})},_margin:function(){var e,t,r=this._tokenStream,n=this._margin_sym();return!!n&&(e=r.token().startLine,t=r.token().startCol,this.fire({type:"startpagemargin",margin:n,line:e,col:t}),this._readDeclarations(!0),this.fire({type:"endpagemargin",margin:n,line:e,col:t}),!0)},_margin_sym:function(){var e=this._tokenStream;return e.match([Tokens.TOPLEFTCORNER_SYM,Tokens.TOPLEFT_SYM,Tokens.TOPCENTER_SYM,Tokens.TOPRIGHT_SYM,Tokens.TOPRIGHTCORNER_SYM,Tokens.BOTTOMLEFTCORNER_SYM,Tokens.BOTTOMLEFT_SYM,Tokens.BOTTOMCENTER_SYM,Tokens.BOTTOMRIGHT_SYM,Tokens.BOTTOMRIGHTCORNER_SYM,Tokens.LEFTTOP_SYM,Tokens.LEFTMIDDLE_SYM,Tokens.LEFTBOTTOM_SYM,Tokens.RIGHTTOP_SYM,Tokens.RIGHTMIDDLE_SYM,Tokens.RIGHTBOTTOM_SYM])?SyntaxUnit.fromToken(e.token()):null},_pseudo_page:function(){var e=this._tokenStream;return e.mustMatch(Tokens.COLON),e.mustMatch(Tokens.IDENT),e.token().value},_font_face:function(){var e,t,r=this._tokenStream;r.mustMatch(Tokens.FONT_FACE_SYM),e=r.token().startLine,t=r.token().startCol,this._readWhitespace(),this.fire({type:"startfontface",line:e,col:t}),this._readDeclarations(!0),this.fire({type:"endfontface",line:e,col:t})},_viewport:function(){var e,t,r=this._tokenStream;r.mustMatch(Tokens.VIEWPORT_SYM),e=r.token().startLine,t=r.token().startCol,this._readWhitespace(),this.fire({type:"startviewport",line:e,col:t}),this._readDeclarations(!0),this.fire({type:"endviewport",line:e,col:t})},_operator:function(e){var t=this._tokenStream,r=null;return(t.match([Tokens.SLASH,Tokens.COMMA])||e&&t.match([Tokens.PLUS,Tokens.STAR,Tokens.MINUS]))&&(r=t.token(),this._readWhitespace()),r?PropertyValuePart.fromToken(r):null},_combinator:function(){var e,t=this._tokenStream,r=null;return t.match([Tokens.PLUS,Tokens.GREATER,Tokens.TILDE])&&(e=t.token(),r=new Combinator(e.value,e.startLine,e.startCol),this._readWhitespace()),r},_unary_operator:function(){var e=this._tokenStream;return e.match([Tokens.MINUS,Tokens.PLUS])?e.token().value:null},_property:function(){var e,t,r,n,i=this._tokenStream,o=null,a=null;return i.peek()==Tokens.STAR&&this.options.starHack&&(i.get(),t=i.token(),a=t.value,r=t.startLine,n=t.startCol),i.match(Tokens.IDENT)&&(t=i.token(),e=t.value,"_"==e.charAt(0)&&this.options.underscoreHack&&(a="_",e=e.substring(1)),o=new PropertyName(e,a,r||t.startLine,n||t.startCol),this._readWhitespace()),o},_ruleset:function(){var e,t,r=this._tokenStream;try{t=this._selectors_group()}catch(t){if(!(t instanceof SyntaxError)||this.options.strict)throw t;if(this.fire({type:"error",error:t,message:t.message,line:t.line,col:t.col}),e=r.advance([Tokens.RBRACE]),e!=Tokens.RBRACE)throw t;return!0}return t&&(this.fire({type:"startrule",selectors:t,line:t[0].line,col:t[0].col}),this._readDeclarations(!0),this.fire({type:"endrule",selectors:t,line:t[0].line,col:t[0].col})),t},_selectors_group:function(){var e,t=this._tokenStream,r=[];if(e=this._selector(),null!==e)for(r.push(e);t.match(Tokens.COMMA);)this._readWhitespace(),e=this._selector(),null!==e?r.push(e):this._unexpectedToken(t.LT(1));return r.length?r:null},_selector:function(){var e=this._tokenStream,t=[],r=null,n=null,i=null;if(r=this._simple_selector_sequence(),null===r)return null;for(t.push(r);;)if(n=this._combinator(),null!==n)t.push(n),r=this._simple_selector_sequence(),null===r?this._unexpectedToken(e.LT(1)):t.push(r);else{if(!this._readWhitespace())break;i=new Combinator(e.token().value,e.token().startLine,e.token().startCol),n=this._combinator(),r=this._simple_selector_sequence(),null===r?null!==n&&this._unexpectedToken(e.LT(1)):(null!==n?t.push(n):t.push(i),t.push(r))}return new Selector(t,t[0].line,t[0].col)},_simple_selector_sequence:function(){var e,t,r=this._tokenStream,n=null,i=[],o="",a=[function(){return r.match(Tokens.HASH)?new SelectorSubPart(r.token().value,"id",r.token().startLine,r.token().startCol):null},this._class,this._attrib,this._pseudo,this._negation],s=0,l=a.length,u=null;for(e=r.LT(1).startLine,t=r.LT(1).startCol,n=this._type_selector(),n||(n=this._universal()),null!==n&&(o+=n);;){if(r.peek()===Tokens.S)break;for(;s<l&&null===u;)u=a[s++].call(this);if(null===u){if(""===o)return null;break}s=0,i.push(u),o+=u.toString(),u=null}return""!==o?new SelectorPart(n,i,o,e,t):null},_type_selector:function(){var e=this._tokenStream,t=this._namespace_prefix(),r=this._element_name();return r?(t&&(r.text=t+r.text,r.col-=t.length),r):(t&&(e.unget(),t.length>1&&e.unget()),null)},_class:function(){var e,t=this._tokenStream;return t.match(Tokens.DOT)?(t.mustMatch(Tokens.IDENT),e=t.token(),new SelectorSubPart("."+e.value,"class",e.startLine,e.startCol-1)):null},_element_name:function(){var e,t=this._tokenStream;return t.match(Tokens.IDENT)?(e=t.token(),new SelectorSubPart(e.value,"elementName",e.startLine,e.startCol)):null},_namespace_prefix:function(){var e=this._tokenStream,t="";return e.LA(1)!==Tokens.PIPE&&e.LA(2)!==Tokens.PIPE||(e.match([Tokens.IDENT,Tokens.STAR])&&(t+=e.token().value),e.mustMatch(Tokens.PIPE),t+="|"),t.length?t:null},_universal:function(){var e,t=this._tokenStream,r="";return e=this._namespace_prefix(),e&&(r+=e),t.match(Tokens.STAR)&&(r+="*"),r.length?r:null},_attrib:function(){var e,t,r=this._tokenStream,n=null;return r.match(Tokens.LBRACKET)?(t=r.token(),n=t.value,n+=this._readWhitespace(),e=this._namespace_prefix(),e&&(n+=e),r.mustMatch(Tokens.IDENT),n+=r.token().value,n+=this._readWhitespace(),r.match([Tokens.PREFIXMATCH,Tokens.SUFFIXMATCH,Tokens.SUBSTRINGMATCH,Tokens.EQUALS,Tokens.INCLUDES,Tokens.DASHMATCH])&&(n+=r.token().value,n+=this._readWhitespace(),r.mustMatch([Tokens.IDENT,Tokens.STRING]),n+=r.token().value,n+=this._readWhitespace()),r.mustMatch(Tokens.RBRACKET),new SelectorSubPart(n+"]","attribute",t.startLine,t.startCol)):null},_pseudo:function(){var e,t,r=this._tokenStream,n=null,i=":";return r.match(Tokens.COLON)&&(r.match(Tokens.COLON)&&(i+=":"),r.match(Tokens.IDENT)?(n=r.token().value,e=r.token().startLine,t=r.token().startCol-i.length):r.peek()==Tokens.FUNCTION&&(e=r.LT(1).startLine,t=r.LT(1).startCol-i.length,n=this._functional_pseudo()),n&&(n=new SelectorSubPart(i+n,"pseudo",e,t))),n},_functional_pseudo:function(){var e=this._tokenStream,t=null;return e.match(Tokens.FUNCTION)&&(t=e.token().value,t+=this._readWhitespace(),t+=this._expression(),e.mustMatch(Tokens.RPAREN),t+=")"),t},_expression:function(){for(var e=this._tokenStream,t="";e.match([Tokens.PLUS,Tokens.MINUS,Tokens.DIMENSION,Tokens.NUMBER,Tokens.STRING,Tokens.IDENT,Tokens.LENGTH,Tokens.FREQ,Tokens.ANGLE,Tokens.TIME,Tokens.RESOLUTION,Tokens.SLASH]);)t+=e.token().value,t+=this._readWhitespace();return t.length?t:null},_negation:function(){var e,t,r,n=this._tokenStream,i="",o=null;return n.match(Tokens.NOT)&&(i=n.token().value,e=n.token().startLine,t=n.token().startCol,i+=this._readWhitespace(),r=this._negation_arg(),i+=r,i+=this._readWhitespace(),n.match(Tokens.RPAREN),i+=n.token().value,o=new SelectorSubPart(i,"not",e,t),o.args.push(r)),o},_negation_arg:function(){var e,t,r,n=this._tokenStream,i=[this._type_selector,this._universal,function(){return n.match(Tokens.HASH)?new SelectorSubPart(n.token().value,"id",n.token().startLine,n.token().startCol):null},this._class,this._attrib,this._pseudo],o=null,a=0,s=i.length;for(e=n.LT(1).startLine,t=n.LT(1).startCol;a<s&&null===o;)o=i[a].call(this),a++;return null===o&&this._unexpectedToken(n.LT(1)),r="elementName"==o.type?new SelectorPart(o,[],o.toString(),e,t):new SelectorPart(null,[o],o.toString(),e,t)},_declaration:function(){var e=this._tokenStream,t=null,r=null,n=null,i=null,o="";if(t=this._property(),null!==t){e.mustMatch(Tokens.COLON),this._readWhitespace(),r=this._expr(),r&&0!==r.length||this._unexpectedToken(e.LT(1)),n=this._prio(),o=t.toString(),(this.options.starHack&&"*"==t.hack||this.options.underscoreHack&&"_"==t.hack)&&(o=t.text);try{this._validateProperty(o,r)}catch(e){i=e}return this.fire({type:"property",property:t,value:r,important:n,line:t.line,col:t.col,invalid:i}),!0}return!1},_prio:function(){var e=this._tokenStream,t=e.match(Tokens.IMPORTANT_SYM);return this._readWhitespace(),t},_expr:function(e){var t=(this._tokenStream,[]),r=null,n=null;if(r=this._term(),null!==r)for(t.push(r);;){if(n=this._operator(e),n&&t.push(n),r=this._term(),null===r)break;t.push(r)}return t.length>0?new PropertyValue(t,t[0].line,t[0].col):null},_term:function(){var e,t,r,n=this._tokenStream,i=null,o=null;return i=this._unary_operator(),null!==i&&(t=n.token().startLine,r=n.token().startCol),n.peek()==Tokens.IE_FUNCTION&&this.options.ieFilters?(o=this._ie_function(),null===i&&(t=n.token().startLine,r=n.token().startCol)):n.match([Tokens.NUMBER,Tokens.PERCENTAGE,Tokens.LENGTH,Tokens.ANGLE,Tokens.TIME,Tokens.FREQ,Tokens.STRING,Tokens.IDENT,Tokens.URI,Tokens.UNICODE_RANGE])?(o=n.token().value,null===i&&(t=n.token().startLine,r=n.token().startCol),this._readWhitespace()):(e=this._hexcolor(),null===e?(null===i&&(t=n.LT(1).startLine,r=n.LT(1).startCol),null===o&&(o=n.LA(3)==Tokens.EQUALS&&this.options.ieFilters?this._ie_function():this._function())):(o=e.value,null===i&&(t=e.startLine,r=e.startCol))),null!==o?new PropertyValuePart(null!==i?i+o:o,t,r):null},_function:function(){var e,t=this._tokenStream,r=null,n=null;if(t.match(Tokens.FUNCTION)){if(r=t.token().value,this._readWhitespace(),n=this._expr(!0),r+=n,this.options.ieFilters&&t.peek()==Tokens.EQUALS)do for(this._readWhitespace()&&(r+=t.token().value),t.LA(0)==Tokens.COMMA&&(r+=t.token().value),t.match(Tokens.IDENT),r+=t.token().value,t.match(Tokens.EQUALS),r+=t.token().value,e=t.peek();e!=Tokens.COMMA&&e!=Tokens.S&&e!=Tokens.RPAREN;)t.get(),r+=t.token().value,e=t.peek();while(t.match([Tokens.COMMA,Tokens.S]));t.match(Tokens.RPAREN),r+=")",this._readWhitespace()}return r},_ie_function:function(){var e,t=this._tokenStream,r=null;if(t.match([Tokens.IE_FUNCTION,Tokens.FUNCTION])){r=t.token().value;do for(this._readWhitespace()&&(r+=t.token().value),t.LA(0)==Tokens.COMMA&&(r+=t.token().value),t.match(Tokens.IDENT),r+=t.token().value,t.match(Tokens.EQUALS),r+=t.token().value,e=t.peek();e!=Tokens.COMMA&&e!=Tokens.S&&e!=Tokens.RPAREN;)t.get(),r+=t.token().value,e=t.peek();while(t.match([Tokens.COMMA,Tokens.S]));t.match(Tokens.RPAREN),r+=")",this._readWhitespace()}return r},_hexcolor:function(){var e,t=this._tokenStream,r=null;if(t.match(Tokens.HASH)){if(r=t.token(),e=r.value,!/#[a-f0-9]{3,6}/i.test(e))throw new SyntaxError("Expected a hex color but found '"+e+"' at line "+r.startLine+", col "+r.startCol+".",r.startLine,r.startCol);this._readWhitespace()}return r},_keyframes:function(){var e,t,r,n=this._tokenStream,i="";for(n.mustMatch(Tokens.KEYFRAMES_SYM),e=n.token(),/^@\-([^\-]+)\-/.test(e.value)&&(i=RegExp.$1),this._readWhitespace(),r=this._keyframe_name(),
2
- this._readWhitespace(),n.mustMatch(Tokens.LBRACE),this.fire({type:"startkeyframes",name:r,prefix:i,line:e.startLine,col:e.startCol}),this._readWhitespace(),t=n.peek();t==Tokens.IDENT||t==Tokens.PERCENTAGE;)this._keyframe_rule(),this._readWhitespace(),t=n.peek();this.fire({type:"endkeyframes",name:r,prefix:i,line:e.startLine,col:e.startCol}),this._readWhitespace(),n.mustMatch(Tokens.RBRACE)},_keyframe_name:function(){var e=this._tokenStream;return e.mustMatch([Tokens.IDENT,Tokens.STRING]),SyntaxUnit.fromToken(e.token())},_keyframe_rule:function(){var e=(this._tokenStream,this._key_list());this.fire({type:"startkeyframerule",keys:e,line:e[0].line,col:e[0].col}),this._readDeclarations(!0),this.fire({type:"endkeyframerule",keys:e,line:e[0].line,col:e[0].col})},_key_list:function(){var e=this._tokenStream,t=[];for(t.push(this._key()),this._readWhitespace();e.match(Tokens.COMMA);)this._readWhitespace(),t.push(this._key()),this._readWhitespace();return t},_key:function(){var e,t=this._tokenStream;if(t.match(Tokens.PERCENTAGE))return SyntaxUnit.fromToken(t.token());if(t.match(Tokens.IDENT)){if(e=t.token(),/from|to/i.test(e.value))return SyntaxUnit.fromToken(e);t.unget()}this._unexpectedToken(t.LT(1))},_skipCruft:function(){for(;this._tokenStream.match([Tokens.S,Tokens.CDO,Tokens.CDC]););},_readDeclarations:function(e,t){var r,n=this._tokenStream;this._readWhitespace(),e&&n.mustMatch(Tokens.LBRACE),this._readWhitespace();try{for(;;){if(n.match(Tokens.SEMICOLON)||t&&this._margin());else{if(!this._declaration())break;if(!n.match(Tokens.SEMICOLON))break}this._readWhitespace()}n.mustMatch(Tokens.RBRACE),this._readWhitespace()}catch(e){if(!(e instanceof SyntaxError)||this.options.strict)throw e;if(this.fire({type:"error",error:e,message:e.message,line:e.line,col:e.col}),r=n.advance([Tokens.SEMICOLON,Tokens.RBRACE]),r==Tokens.SEMICOLON)this._readDeclarations(!1,t);else if(r!=Tokens.RBRACE)throw e}},_readWhitespace:function(){for(var e=this._tokenStream,t="";e.match(Tokens.S);)t+=e.token().value;return t},_unexpectedToken:function(e){throw new SyntaxError("Unexpected token '"+e.value+"' at line "+e.startLine+", col "+e.startCol+".",e.startLine,e.startCol)},_verifyEnd:function(){this._tokenStream.LA(1)!=Tokens.EOF&&this._unexpectedToken(this._tokenStream.LT(1))},_validateProperty:function(e,t){Validation.validate(e,t)},parse:function(e){this._tokenStream=new TokenStream(e,Tokens),this._stylesheet()},parseStyleSheet:function(e){return this.parse(e)},parseMediaQuery:function(e){this._tokenStream=new TokenStream(e,Tokens);var t=this._media_query();return this._verifyEnd(),t},parsePropertyValue:function(e){this._tokenStream=new TokenStream(e,Tokens),this._readWhitespace();var t=this._expr();return this._readWhitespace(),this._verifyEnd(),t},parseRule:function(e){this._tokenStream=new TokenStream(e,Tokens),this._readWhitespace();var t=this._ruleset();return this._readWhitespace(),this._verifyEnd(),t},parseSelector:function(e){this._tokenStream=new TokenStream(e,Tokens),this._readWhitespace();var t=this._selector();return this._readWhitespace(),this._verifyEnd(),t},parseStyleAttribute:function(e){e+="}",this._tokenStream=new TokenStream(e,Tokens),this._readDeclarations()}};for(e in r)r.hasOwnProperty(e)&&(t[e]=r[e]);return t}();var Properties={"alignment-adjust":"auto | baseline | before-edge | text-before-edge | middle | central | after-edge | text-after-edge | ideographic | alphabetic | hanging | mathematical | <percentage> | <length>","alignment-baseline":"baseline | use-script | before-edge | text-before-edge | after-edge | text-after-edge | central | middle | ideographic | alphabetic | hanging | mathematical",animation:1,"animation-delay":{multi:"<time>",comma:!0},"animation-direction":{multi:"normal | alternate",comma:!0},"animation-duration":{multi:"<time>",comma:!0},"animation-iteration-count":{multi:"<number> | infinite",comma:!0},"animation-name":{multi:"none | <ident>",comma:!0},"animation-play-state":{multi:"running | paused",comma:!0},"animation-timing-function":1,"-moz-animation-delay":{multi:"<time>",comma:!0},"-moz-animation-direction":{multi:"normal | alternate",comma:!0},"-moz-animation-duration":{multi:"<time>",comma:!0},"-moz-animation-iteration-count":{multi:"<number> | infinite",comma:!0},"-moz-animation-name":{multi:"none | <ident>",comma:!0},"-moz-animation-play-state":{multi:"running | paused",comma:!0},"-ms-animation-delay":{multi:"<time>",comma:!0},"-ms-animation-direction":{multi:"normal | alternate",comma:!0},"-ms-animation-duration":{multi:"<time>",comma:!0},"-ms-animation-iteration-count":{multi:"<number> | infinite",comma:!0},"-ms-animation-name":{multi:"none | <ident>",comma:!0},"-ms-animation-play-state":{multi:"running | paused",comma:!0},"-webkit-animation-delay":{multi:"<time>",comma:!0},"-webkit-animation-direction":{multi:"normal | alternate",comma:!0},"-webkit-animation-duration":{multi:"<time>",comma:!0},"-webkit-animation-iteration-count":{multi:"<number> | infinite",comma:!0},"-webkit-animation-name":{multi:"none | <ident>",comma:!0},"-webkit-animation-play-state":{multi:"running | paused",comma:!0},"-o-animation-delay":{multi:"<time>",comma:!0},"-o-animation-direction":{multi:"normal | alternate",comma:!0},"-o-animation-duration":{multi:"<time>",comma:!0},"-o-animation-iteration-count":{multi:"<number> | infinite",comma:!0},"-o-animation-name":{multi:"none | <ident>",comma:!0},"-o-animation-play-state":{multi:"running | paused",comma:!0},appearance:"icon | window | desktop | workspace | document | tooltip | dialog | button | push-button | hyperlink | radio-button | checkbox | menu-item | tab | menu | menubar | pull-down-menu | pop-up-menu | list-menu | radio-group | checkbox-group | outline-tree | range | field | combo-box | signature | password | normal | none | inherit",azimuth:function(e){var t,r="<angle> | leftwards | rightwards | inherit",n="left-side | far-left | left | center-left | center | center-right | right | far-right | right-side",i=!1,o=!1;if(ValidationTypes.isAny(e,r)||(ValidationTypes.isAny(e,"behind")&&(i=!0,o=!0),ValidationTypes.isAny(e,n)&&(o=!0,i||ValidationTypes.isAny(e,"behind"))),e.hasNext())throw t=e.next(),o?new ValidationError("Expected end of value but found '"+t+"'.",t.line,t.col):new ValidationError("Expected (<'azimuth'>) but found '"+t+"'.",t.line,t.col)},"backface-visibility":"visible | hidden",background:1,"background-attachment":{multi:"<attachment>",comma:!0},"background-clip":{multi:"<box>",comma:!0},"background-color":"<color> | inherit","background-image":{multi:"<bg-image>",comma:!0},"background-origin":{multi:"<box>",comma:!0},"background-position":{multi:"<bg-position>",comma:!0},"background-repeat":{multi:"<repeat-style>"},"background-size":{multi:"<bg-size>",comma:!0},"baseline-shift":"baseline | sub | super | <percentage> | <length>",behavior:1,binding:1,bleed:"<length>","bookmark-label":"<content> | <attr> | <string>","bookmark-level":"none | <integer>","bookmark-state":"open | closed","bookmark-target":"none | <uri> | <attr>",border:"<border-width> || <border-style> || <color>","border-bottom":"<border-width> || <border-style> || <color>","border-bottom-color":"<color> | inherit","border-bottom-left-radius":"<x-one-radius>","border-bottom-right-radius":"<x-one-radius>","border-bottom-style":"<border-style>","border-bottom-width":"<border-width>","border-collapse":"collapse | separate | inherit","border-color":{multi:"<color> | inherit",max:4},"border-image":1,"border-image-outset":{multi:"<length> | <number>",max:4},"border-image-repeat":{multi:"stretch | repeat | round",max:2},"border-image-slice":function(e){var t,r=!1,n="<number> | <percentage>",i=!1,o=0,a=4;for(ValidationTypes.isAny(e,"fill")&&(i=!0,r=!0);e.hasNext()&&o<a&&(r=ValidationTypes.isAny(e,n));)o++;if(i?r=!0:ValidationTypes.isAny(e,"fill"),e.hasNext())throw t=e.next(),r?new ValidationError("Expected end of value but found '"+t+"'.",t.line,t.col):new ValidationError("Expected ([<number> | <percentage>]{1,4} && fill?) but found '"+t+"'.",t.line,t.col)},"border-image-source":"<image> | none","border-image-width":{multi:"<length> | <percentage> | <number> | auto",max:4},"border-left":"<border-width> || <border-style> || <color>","border-left-color":"<color> | inherit","border-left-style":"<border-style>","border-left-width":"<border-width>","border-radius":function(e){for(var t,r=!1,n="<length> | <percentage> | inherit",i=!1,o=0,a=8;e.hasNext()&&o<a;){if(r=ValidationTypes.isAny(e,n),!r){if(!("/"==e.peek()&&o>0)||i)break;i=!0,a=o+5,e.next()}o++}if(e.hasNext())throw t=e.next(),r?new ValidationError("Expected end of value but found '"+t+"'.",t.line,t.col):new ValidationError("Expected (<'border-radius'>) but found '"+t+"'.",t.line,t.col)},"border-right":"<border-width> || <border-style> || <color>","border-right-color":"<color> | inherit","border-right-style":"<border-style>","border-right-width":"<border-width>","border-spacing":{multi:"<length> | inherit",max:2},"border-style":{multi:"<border-style>",max:4},"border-top":"<border-width> || <border-style> || <color>","border-top-color":"<color> | inherit","border-top-left-radius":"<x-one-radius>","border-top-right-radius":"<x-one-radius>","border-top-style":"<border-style>","border-top-width":"<border-width>","border-width":{multi:"<border-width>",max:4},bottom:"<margin-width> | inherit","box-align":"start | end | center | baseline | stretch","box-decoration-break":"slice |clone","box-direction":"normal | reverse | inherit","box-flex":"<number>","box-flex-group":"<integer>","box-lines":"single | multiple","box-ordinal-group":"<integer>","box-orient":"horizontal | vertical | inline-axis | block-axis | inherit","box-pack":"start | end | center | justify","box-shadow":function(e){var t;if(ValidationTypes.isAny(e,"none")){if(e.hasNext())throw t=e.next(),new ValidationError("Expected end of value but found '"+t+"'.",t.line,t.col)}else Validation.multiProperty("<shadow>",e,!0,1/0)},"box-sizing":"content-box | border-box | inherit","break-after":"auto | always | avoid | left | right | page | column | avoid-page | avoid-column","break-before":"auto | always | avoid | left | right | page | column | avoid-page | avoid-column","break-inside":"auto | avoid | avoid-page | avoid-column","caption-side":"top | bottom | inherit",clear:"none | right | left | both | inherit",clip:1,color:"<color> | inherit","color-profile":1,"column-count":"<integer> | auto","column-fill":"auto | balance","column-gap":"<length> | normal","column-rule":"<border-width> || <border-style> || <color>","column-rule-color":"<color>","column-rule-style":"<border-style>","column-rule-width":"<border-width>","column-span":"none | all","column-width":"<length> | auto",columns:1,content:1,"counter-increment":1,"counter-reset":1,crop:"<shape> | auto",cue:"cue-after | cue-before | inherit","cue-after":1,"cue-before":1,cursor:1,direction:"ltr | rtl | inherit",display:"inline | block | list-item | inline-block | table | inline-table | table-row-group | table-header-group | table-footer-group | table-row | table-column-group | table-column | table-cell | table-caption | box | inline-box | grid | inline-grid | none | inherit | -moz-box | -moz-inline-block | -moz-inline-box | -moz-inline-grid | -moz-inline-stack | -moz-inline-table | -moz-grid | -moz-grid-group | -moz-grid-line | -moz-groupbox | -moz-deck | -moz-popup | -moz-stack | -moz-marker | -webkit-box | -webkit-inline-box","dominant-baseline":1,"drop-initial-after-adjust":"central | middle | after-edge | text-after-edge | ideographic | alphabetic | mathematical | <percentage> | <length>","drop-initial-after-align":"baseline | use-script | before-edge | text-before-edge | after-edge | text-after-edge | central | middle | ideographic | alphabetic | hanging | mathematical","drop-initial-before-adjust":"before-edge | text-before-edge | central | middle | hanging | mathematical | <percentage> | <length>","drop-initial-before-align":"caps-height | baseline | use-script | before-edge | text-before-edge | after-edge | text-after-edge | central | middle | ideographic | alphabetic | hanging | mathematical","drop-initial-size":"auto | line | <length> | <percentage>","drop-initial-value":"initial | <integer>",elevation:"<angle> | below | level | above | higher | lower | inherit","empty-cells":"show | hide | inherit",filter:1,fit:"fill | hidden | meet | slice","fit-position":1,float:"left | right | none | inherit","float-offset":1,font:1,"font-family":1,"font-size":"<absolute-size> | <relative-size> | <length> | <percentage> | inherit","font-size-adjust":"<number> | none | inherit","font-stretch":"normal | ultra-condensed | extra-condensed | condensed | semi-condensed | semi-expanded | expanded | extra-expanded | ultra-expanded | inherit","font-style":"normal | italic | oblique | inherit","font-variant":"normal | small-caps | inherit","font-weight":"normal | bold | bolder | lighter | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | inherit","grid-cell-stacking":"columns | rows | layer","grid-column":1,"grid-columns":1,"grid-column-align":"start | end | center | stretch","grid-column-sizing":1,"grid-column-span":"<integer>","grid-flow":"none | rows | columns","grid-layer":"<integer>","grid-row":1,"grid-rows":1,"grid-row-align":"start | end | center | stretch","grid-row-span":"<integer>","grid-row-sizing":1,"hanging-punctuation":1,height:"<margin-width> | inherit","hyphenate-after":"<integer> | auto","hyphenate-before":"<integer> | auto","hyphenate-character":"<string> | auto","hyphenate-lines":"no-limit | <integer>","hyphenate-resource":1,hyphens:"none | manual | auto",icon:1,"image-orientation":"angle | auto","image-rendering":1,"image-resolution":1,"inline-box-align":"initial | last | <integer>",left:"<margin-width> | inherit","letter-spacing":"<length> | normal | inherit","line-height":"<number> | <length> | <percentage> | normal | inherit","line-break":"auto | loose | normal | strict","line-stacking":1,"line-stacking-ruby":"exclude-ruby | include-ruby","line-stacking-shift":"consider-shifts | disregard-shifts","line-stacking-strategy":"inline-line-height | block-line-height | max-height | grid-height","list-style":1,"list-style-image":"<uri> | none | inherit","list-style-position":"inside | outside | inherit","list-style-type":"disc | circle | square | decimal | decimal-leading-zero | lower-roman | upper-roman | lower-greek | lower-latin | upper-latin | armenian | georgian | lower-alpha | upper-alpha | none | inherit",margin:{multi:"<margin-width> | inherit",max:4},"margin-bottom":"<margin-width> | inherit","margin-left":"<margin-width> | inherit","margin-right":"<margin-width> | inherit","margin-top":"<margin-width> | inherit",mark:1,"mark-after":1,"mark-before":1,marks:1,"marquee-direction":1,"marquee-play-count":1,"marquee-speed":1,"marquee-style":1,"max-height":"<length> | <percentage> | none | inherit","max-width":"<length> | <percentage> | none | inherit","min-height":"<length> | <percentage> | inherit","min-width":"<length> | <percentage> | inherit","move-to":1,"nav-down":1,"nav-index":1,"nav-left":1,"nav-right":1,"nav-up":1,opacity:"<number> | inherit",orphans:"<integer> | inherit",outline:1,"outline-color":"<color> | invert | inherit","outline-offset":1,"outline-style":"<border-style> | inherit","outline-width":"<border-width> | inherit",overflow:"visible | hidden | scroll | auto | inherit","overflow-style":1,"overflow-x":1,"overflow-y":1,padding:{multi:"<padding-width> | inherit",max:4},"padding-bottom":"<padding-width> | inherit","padding-left":"<padding-width> | inherit","padding-right":"<padding-width> | inherit","padding-top":"<padding-width> | inherit",page:1,"page-break-after":"auto | always | avoid | left | right | inherit","page-break-before":"auto | always | avoid | left | right | inherit","page-break-inside":"auto | avoid | inherit","page-policy":1,pause:1,"pause-after":1,"pause-before":1,perspective:1,"perspective-origin":1,phonemes:1,pitch:1,"pitch-range":1,"play-during":1,"pointer-events":"auto | none | visiblePainted | visibleFill | visibleStroke | visible | painted | fill | stroke | all | inherit",position:"static | relative | absolute | fixed | inherit","presentation-level":1,"punctuation-trim":1,quotes:1,"rendering-intent":1,resize:1,rest:1,"rest-after":1,"rest-before":1,richness:1,right:"<margin-width> | inherit",rotation:1,"rotation-point":1,"ruby-align":1,"ruby-overhang":1,"ruby-position":1,"ruby-span":1,size:1,speak:"normal | none | spell-out | inherit","speak-header":"once | always | inherit","speak-numeral":"digits | continuous | inherit","speak-punctuation":"code | none | inherit","speech-rate":1,src:1,stress:1,"string-set":1,"table-layout":"auto | fixed | inherit","tab-size":"<integer> | <length>",target:1,"target-name":1,"target-new":1,"target-position":1,"text-align":"left | right | center | justify | inherit","text-align-last":1,"text-decoration":1,"text-emphasis":1,"text-height":1,"text-indent":"<length> | <percentage> | inherit","text-justify":"auto | none | inter-word | inter-ideograph | inter-cluster | distribute | kashida","text-outline":1,"text-overflow":1,"text-rendering":"auto | optimizeSpeed | optimizeLegibility | geometricPrecision | inherit","text-shadow":1,"text-transform":"capitalize | uppercase | lowercase | none | inherit","text-wrap":"normal | none | avoid",top:"<margin-width> | inherit",transform:1,"transform-origin":1,"transform-style":1,transition:1,"transition-delay":1,"transition-duration":1,"transition-property":1,"transition-timing-function":1,"unicode-bidi":"normal | embed | bidi-override | inherit","user-modify":"read-only | read-write | write-only | inherit","user-select":"none | text | toggle | element | elements | all | inherit","vertical-align":"auto | use-script | baseline | sub | super | top | text-top | central | middle | bottom | text-bottom | <percentage> | <length>",visibility:"visible | hidden | collapse | inherit","voice-balance":1,"voice-duration":1,"voice-family":1,"voice-pitch":1,"voice-pitch-range":1,"voice-rate":1,"voice-stress":1,"voice-volume":1,volume:1,"white-space":"normal | pre | nowrap | pre-wrap | pre-line | inherit | -pre-wrap | -o-pre-wrap | -moz-pre-wrap | -hp-pre-wrap","white-space-collapse":1,widows:"<integer> | inherit",width:"<length> | <percentage> | auto | inherit","word-break":"normal | keep-all | break-all","word-spacing":"<length> | normal | inherit","word-wrap":1,"z-index":"<integer> | auto | inherit",zoom:"<number> | <percentage> | normal"};PropertyName.prototype=new SyntaxUnit,PropertyName.prototype.constructor=PropertyName,PropertyName.prototype.toString=function(){return(this.hack?this.hack:"")+this.text},PropertyValue.prototype=new SyntaxUnit,PropertyValue.prototype.constructor=PropertyValue,PropertyValueIterator.prototype.count=function(){return this._parts.length},PropertyValueIterator.prototype.isFirst=function(){return 0===this._i},PropertyValueIterator.prototype.hasNext=function(){return this._i<this._parts.length},PropertyValueIterator.prototype.mark=function(){this._marks.push(this._i)},PropertyValueIterator.prototype.peek=function(e){return this.hasNext()?this._parts[this._i+(e||0)]:null},PropertyValueIterator.prototype.next=function(){return this.hasNext()?this._parts[this._i++]:null},PropertyValueIterator.prototype.previous=function(){return this._i>0?this._parts[--this._i]:null},PropertyValueIterator.prototype.restore=function(){this._marks.length&&(this._i=this._marks.pop())},PropertyValuePart.prototype=new SyntaxUnit,PropertyValuePart.prototype.constructor=PropertyValuePart,PropertyValuePart.fromToken=function(e){return new PropertyValuePart(e.value,e.startLine,e.startCol)};var Pseudos={":first-letter":1,":first-line":1,":before":1,":after":1};Pseudos.ELEMENT=1,Pseudos.CLASS=2,Pseudos.isElement=function(e){return 0===e.indexOf("::")||Pseudos[e.toLowerCase()]==Pseudos.ELEMENT},Selector.prototype=new SyntaxUnit,Selector.prototype.constructor=Selector,SelectorPart.prototype=new SyntaxUnit,SelectorPart.prototype.constructor=SelectorPart,SelectorSubPart.prototype=new SyntaxUnit,SelectorSubPart.prototype.constructor=SelectorSubPart,Specificity.prototype={constructor:Specificity,compare:function(e){var t,r,n=["a","b","c","d"];for(t=0,r=n.length;t<r;t++){if(this[n[t]]<e[n[t]])return-1;if(this[n[t]]>e[n[t]])return 1}return 0},valueOf:function(){return 1e3*this.a+100*this.b+10*this.c+this.d},toString:function(){return this.a+","+this.b+","+this.c+","+this.d}},Specificity.calculate=function(e){function t(e){var r,n,i,l,u,d=e.elementName?e.elementName.text:"";for(d&&"*"!=d.charAt(d.length-1)&&s++,r=0,i=e.modifiers.length;r<i;r++)switch(u=e.modifiers[r],u.type){case"class":case"attribute":a++;break;case"id":o++;break;case"pseudo":Pseudos.isElement(u.text)?s++:a++;break;case"not":for(n=0,l=u.args.length;n<l;n++)t(u.args[n])}}var r,n,i,o=0,a=0,s=0;for(r=0,n=e.parts.length;r<n;r++)i=e.parts[r],i instanceof SelectorPart&&t(i);return new Specificity(0,o,a,s)};var h=/^[0-9a-fA-F]$/,nonascii=/^[\u0080-\uFFFF]$/,nl=/\n|\r\n|\r|\f/;TokenStream.prototype=mix(new TokenStreamBase,{_getToken:function(e){var t,r=this._reader,n=null,i=r.getLine(),o=r.getCol();for(t=r.read();t;){switch(t){case"/":n="*"==r.peek()?this.commentToken(t,i,o):this.charToken(t,i,o);break;case"|":case"~":case"^":case"$":case"*":n="="==r.peek()?this.comparisonToken(t,i,o):this.charToken(t,i,o);break;case'"':case"'":n=this.stringToken(t,i,o);break;case"#":n=isNameChar(r.peek())?this.hashToken(t,i,o):this.charToken(t,i,o);break;case".":n=isDigit(r.peek())?this.numberToken(t,i,o):this.charToken(t,i,o);break;case"-":n="-"==r.peek()?this.htmlCommentEndToken(t,i,o):isNameStart(r.peek())?this.identOrFunctionToken(t,i,o):this.charToken(t,i,o);break;case"!":n=this.importantToken(t,i,o);break;case"@":n=this.atRuleToken(t,i,o);break;case":":n=this.notToken(t,i,o);break;case"<":n=this.htmlCommentStartToken(t,i,o);break;case"U":case"u":if("+"==r.peek()){n=this.unicodeRangeToken(t,i,o);break}default:n=isDigit(t)?this.numberToken(t,i,o):isWhitespace(t)?this.whitespaceToken(t,i,o):isIdentStart(t)?this.identOrFunctionToken(t,i,o):this.charToken(t,i,o)}break}return n||null!==t||(n=this.createToken(Tokens.EOF,null,i,o)),n},createToken:function(e,t,r,n,i){var o=this._reader;return i=i||{},{value:t,type:e,channel:i.channel,hide:i.hide||!1,startLine:r,startCol:n,endLine:o.getLine(),endCol:o.getCol()}},atRuleToken:function(e,t,r){var n,i=e,o=this._reader,a=Tokens.CHAR;return o.mark(),n=this.readName(),i=e+n,a=Tokens.type(i.toLowerCase()),a!=Tokens.CHAR&&a!=Tokens.UNKNOWN||(i.length>1?a=Tokens.UNKNOWN_SYM:(a=Tokens.CHAR,i=e,o.reset())),this.createToken(a,i,t,r)},charToken:function(e,t,r){var n=Tokens.type(e);return n==-1&&(n=Tokens.CHAR),this.createToken(n,e,t,r)},commentToken:function(e,t,r){var n=(this._reader,this.readComment(e));return this.createToken(Tokens.COMMENT,n,t,r)},comparisonToken:function(e,t,r){var n=this._reader,i=e+n.read(),o=Tokens.type(i)||Tokens.CHAR;return this.createToken(o,i,t,r)},hashToken:function(e,t,r){var n=(this._reader,this.readName(e));return this.createToken(Tokens.HASH,n,t,r)},htmlCommentStartToken:function(e,t,r){var n=this._reader,i=e;return n.mark(),i+=n.readCount(3),"<!--"==i?this.createToken(Tokens.CDO,i,t,r):(n.reset(),this.charToken(e,t,r))},htmlCommentEndToken:function(e,t,r){var n=this._reader,i=e;return n.mark(),i+=n.readCount(2),"-->"==i?this.createToken(Tokens.CDC,i,t,r):(n.reset(),this.charToken(e,t,r))},identOrFunctionToken:function(e,t,r){var n=this._reader,i=this.readName(e),o=Tokens.IDENT;return"("==n.peek()?(i+=n.read(),"url("==i.toLowerCase()?(o=Tokens.URI,i=this.readURI(i),"url("==i.toLowerCase()&&(o=Tokens.FUNCTION)):o=Tokens.FUNCTION):":"==n.peek()&&"progid"==i.toLowerCase()&&(i+=n.readTo("("),o=Tokens.IE_FUNCTION),this.createToken(o,i,t,r)},importantToken:function(e,t,r){var n,i,o=this._reader,a=e,s=Tokens.CHAR;for(o.mark(),i=o.read();i;){if("/"==i){if("*"!=o.peek())break;if(n=this.readComment(i),""===n)break}else{if(!isWhitespace(i)){if(/i/i.test(i)){n=o.readCount(8),/mportant/i.test(n)&&(a+=i+n,s=Tokens.IMPORTANT_SYM);break}break}a+=i+this.readWhitespace()}i=o.read()}return s==Tokens.CHAR?(o.reset(),this.charToken(e,t,r)):this.createToken(s,a,t,r)},notToken:function(e,t,r){var n=this._reader,i=e;return n.mark(),i+=n.readCount(4),":not("==i.toLowerCase()?this.createToken(Tokens.NOT,i,t,r):(n.reset(),this.charToken(e,t,r))},numberToken:function(e,t,r){var n,i=this._reader,o=this.readNumber(e),a=Tokens.NUMBER,s=i.peek();return isIdentStart(s)?(n=this.readName(i.read()),o+=n,a=/^em$|^ex$|^px$|^gd$|^rem$|^vw$|^vh$|^vm$|^ch$|^cm$|^mm$|^in$|^pt$|^pc$/i.test(n)?Tokens.LENGTH:/^deg|^rad$|^grad$/i.test(n)?Tokens.ANGLE:/^ms$|^s$/i.test(n)?Tokens.TIME:/^hz$|^khz$/i.test(n)?Tokens.FREQ:/^dpi$|^dpcm$/i.test(n)?Tokens.RESOLUTION:Tokens.DIMENSION):"%"==s&&(o+=i.read(),a=Tokens.PERCENTAGE),this.createToken(a,o,t,r)},stringToken:function(e,t,r){for(var n=e,i=e,o=this._reader,a=e,s=Tokens.STRING,l=o.read();l&&(i+=l,l!=n||"\\"==a);){if(isNewLine(o.peek())&&"\\"!=l){s=Tokens.INVALID;break}a=l,l=o.read()}return null===l&&(s=Tokens.INVALID),this.createToken(s,i,t,r)},unicodeRangeToken:function(e,t,r){var n,i=this._reader,o=e,a=Tokens.CHAR;return"+"==i.peek()&&(i.mark(),o+=i.read(),o+=this.readUnicodeRangePart(!0),2==o.length?i.reset():(a=Tokens.UNICODE_RANGE,o.indexOf("?")==-1&&"-"==i.peek()&&(i.mark(),n=i.read(),n+=this.readUnicodeRangePart(!1),1==n.length?i.reset():o+=n))),this.createToken(a,o,t,r)},whitespaceToken:function(e,t,r){var n=(this._reader,e+this.readWhitespace());return this.createToken(Tokens.S,n,t,r)},readUnicodeRangePart:function(e){for(var t=this._reader,r="",n=t.peek();isHexDigit(n)&&r.length<6;)t.read(),r+=n,n=t.peek();if(e)for(;"?"==n&&r.length<6;)t.read(),r+=n,n=t.peek();return r},readWhitespace:function(){for(var e=this._reader,t="",r=e.peek();isWhitespace(r);)e.read(),t+=r,r=e.peek();return t},readNumber:function(e){for(var t=this._reader,r=e,n="."==e,i=t.peek();i;){if(isDigit(i))r+=t.read();else{if("."!=i)break;if(n)break;n=!0,r+=t.read()}i=t.peek()}return r},readString:function(){for(var e=this._reader,t=e.read(),r=t,n=t,i=e.peek();i&&(i=e.read(),r+=i,i!=t||"\\"==n);){if(isNewLine(e.peek())&&"\\"!=i){r="";break}n=i,i=e.peek()}return null===i&&(r=""),r},readURI:function(e){var t=this._reader,r=e,n="",i=t.peek();for(t.mark();i&&isWhitespace(i);)t.read(),i=t.peek();for(n="'"==i||'"'==i?this.readString():this.readURL(),i=t.peek();i&&isWhitespace(i);)t.read(),i=t.peek();return""===n||")"!=i?(r=e,t.reset()):r+=n+t.read(),r},readURL:function(){for(var e=this._reader,t="",r=e.peek();/^[!#$%&\\*-~]$/.test(r);)t+=e.read(),r=e.peek();return t},readName:function(e){for(var t=this._reader,r=e||"",n=t.peek();;)if("\\"==n)r+=this.readEscape(t.read()),n=t.peek();else{if(!n||!isNameChar(n))break;r+=t.read(),n=t.peek()}return r},readEscape:function(e){var t=this._reader,r=e||"",n=0,i=t.peek();if(isHexDigit(i))do r+=t.read(),i=t.peek();while(i&&isHexDigit(i)&&++n<6);return 3==r.length&&/\s/.test(i)||7==r.length||1==r.length?t.read():i="",r+i},readComment:function(e){var t=this._reader,r=e||"",n=t.read();if("*"==n){for(;n;){if(r+=n,r.length>2&&"*"==n&&"/"==t.peek()){r+=t.read();break}n=t.read()}return r}return""}});var Tokens=[{name:"CDO"},{name:"CDC"},{name:"S",whitespace:!0},{name:"COMMENT",comment:!0,hide:!0,channel:"comment"},{name:"INCLUDES",text:"~="},{name:"DASHMATCH",text:"|="},{name:"PREFIXMATCH",text:"^="},{name:"SUFFIXMATCH",text:"$="},{name:"SUBSTRINGMATCH",text:"*="},{name:"STRING"},{name:"IDENT"},{name:"HASH"},{name:"IMPORT_SYM",text:"@import"},{name:"PAGE_SYM",text:"@page"},{name:"MEDIA_SYM",text:"@media"},{name:"FONT_FACE_SYM",text:"@font-face"},{name:"CHARSET_SYM",text:"@charset"},{name:"NAMESPACE_SYM",text:"@namespace"},{name:"VIEWPORT_SYM",text:"@viewport"},{name:"UNKNOWN_SYM"},{name:"KEYFRAMES_SYM",text:["@keyframes","@-webkit-keyframes","@-moz-keyframes","@-o-keyframes"]},{name:"IMPORTANT_SYM"},{name:"LENGTH"},{name:"ANGLE"},{name:"TIME"},{name:"FREQ"},{name:"DIMENSION"},{name:"PERCENTAGE"},{name:"NUMBER"},{name:"URI"},{name:"FUNCTION"},{name:"UNICODE_RANGE"},{name:"INVALID"},{name:"PLUS",text:"+"},{name:"GREATER",text:">"},{name:"COMMA",text:","},{name:"TILDE",text:"~"},{name:"NOT"},{name:"TOPLEFTCORNER_SYM",text:"@top-left-corner"},{name:"TOPLEFT_SYM",text:"@top-left"},{name:"TOPCENTER_SYM",text:"@top-center"},{name:"TOPRIGHT_SYM",text:"@top-right"},{name:"TOPRIGHTCORNER_SYM",text:"@top-right-corner"},{name:"BOTTOMLEFTCORNER_SYM",text:"@bottom-left-corner"},{name:"BOTTOMLEFT_SYM",text:"@bottom-left"},{name:"BOTTOMCENTER_SYM",text:"@bottom-center"},{name:"BOTTOMRIGHT_SYM",text:"@bottom-right"},{name:"BOTTOMRIGHTCORNER_SYM",text:"@bottom-right-corner"},{name:"LEFTTOP_SYM",text:"@left-top"},{name:"LEFTMIDDLE_SYM",text:"@left-middle"},{name:"LEFTBOTTOM_SYM",text:"@left-bottom"},{name:"RIGHTTOP_SYM",text:"@right-top"},{name:"RIGHTMIDDLE_SYM",text:"@right-middle"},{name:"RIGHTBOTTOM_SYM",text:"@right-bottom"},{name:"RESOLUTION",state:"media"},{name:"IE_FUNCTION"},{name:"CHAR"},{name:"PIPE",text:"|"},{name:"SLASH",text:"/"},{name:"MINUS",text:"-"},{name:"STAR",text:"*"},{name:"LBRACE",text:"{"},{name:"RBRACE",text:"}"},{name:"LBRACKET",text:"["},{name:"RBRACKET",text:"]"},{name:"EQUALS",text:"="},{name:"COLON",text:":"},{name:"SEMICOLON",text:";"},{name:"LPAREN",text:"("},{name:"RPAREN",text:")"},{name:"DOT",text:"."}];!function(){var e=[],t={};Tokens.UNKNOWN=-1,Tokens.unshift({name:"EOF"});for(var r=0,n=Tokens.length;r<n;r++)if(e.push(Tokens[r].name),Tokens[Tokens[r].name]=r,Tokens[r].text)if(Tokens[r].text instanceof Array)for(var i=0;i<Tokens[r].text.length;i++)t[Tokens[r].text[i]]=r;else t[Tokens[r].text]=r;Tokens.name=function(t){return e[t]},Tokens.type=function(e){return t[e]||-1}}();var Validation={validate:function(e,t){var r=e.toString().toLowerCase(),n=(t.parts,new PropertyValueIterator(t)),i=Properties[r];if(i)"number"!=typeof i&&("string"==typeof i?i.indexOf("||")>-1?this.groupProperty(i,n):this.singleProperty(i,n,1):i.multi?this.multiProperty(i.multi,n,i.comma,i.max||1/0):"function"==typeof i&&i(n));else if(0!==r.indexOf("-"))throw new ValidationError("Unknown property '"+e+"'.",e.line,e.col)},singleProperty:function(e,t,r,n){for(var i,o=!1,a=t.value,s=0;t.hasNext()&&s<r&&(o=ValidationTypes.isAny(t,e));)s++;if(!o)throw t.hasNext()&&!t.isFirst()?(i=t.peek(),new ValidationError("Expected end of value but found '"+i+"'.",i.line,i.col)):new ValidationError("Expected ("+e+") but found '"+a+"'.",a.line,a.col);if(t.hasNext())throw i=t.next(),new ValidationError("Expected end of value but found '"+i+"'.",i.line,i.col)},multiProperty:function(e,t,r,n){for(var i,o=!1,a=t.value,s=0;t.hasNext()&&!o&&s<n&&ValidationTypes.isAny(t,e);)if(s++,t.hasNext()){if(r){if(","!=t.peek())break;i=t.next()}}else o=!0;if(!o)throw t.hasNext()&&!t.isFirst()?(i=t.peek(),new ValidationError("Expected end of value but found '"+i+"'.",i.line,i.col)):(i=t.previous(),r&&","==i?new ValidationError("Expected end of value but found '"+i+"'.",i.line,i.col):new ValidationError("Expected ("+e+") but found '"+a+"'.",a.line,a.col));if(t.hasNext())throw i=t.next(),new ValidationError("Expected end of value but found '"+i+"'.",i.line,i.col)},groupProperty:function(e,t,r){for(var n,i,o=!1,a=t.value,s=e.split("||").length,l={count:0},u=!1;t.hasNext()&&!o&&(n=ValidationTypes.isAnyOfGroup(t,e))&&!l[n];)l[n]=1,l.count++,u=!0,l.count!=s&&t.hasNext()||(o=!0);if(!o)throw u&&t.hasNext()?(i=t.peek(),new ValidationError("Expected end of value but found '"+i+"'.",i.line,i.col)):new ValidationError("Expected ("+e+") but found '"+a+"'.",a.line,a.col);if(t.hasNext())throw i=t.next(),new ValidationError("Expected end of value but found '"+i+"'.",i.line,i.col)}};ValidationError.prototype=new Error;var ValidationTypes={isLiteral:function(e,t){var r,n,i=e.text.toString().toLowerCase(),o=t.split(" | "),a=!1;for(r=0,n=o.length;r<n&&!a;r++)i==o[r].toLowerCase()&&(a=!0);return a},isSimple:function(e){return!!this.simple[e]},isComplex:function(e){return!!this.complex[e];
3
- },isAny:function(e,t){var r,n,i=t.split(" | "),o=!1;for(r=0,n=i.length;r<n&&!o&&e.hasNext();r++)o=this.isType(e,i[r]);return o},isAnyOfGroup:function(e,t){var r,n,i=t.split(" || "),o=!1;for(r=0,n=i.length;r<n&&!o;r++)o=this.isType(e,i[r]);return!!o&&i[r-1]},isType:function(e,t){var r=e.peek(),n=!1;return"<"!=t.charAt(0)?(n=this.isLiteral(r,t),n&&e.next()):this.simple[t]?(n=this.simple[t](r),n&&e.next()):n=this.complex[t](e),n},simple:{"<absolute-size>":function(e){return ValidationTypes.isLiteral(e,"xx-small | x-small | small | medium | large | x-large | xx-large")},"<attachment>":function(e){return ValidationTypes.isLiteral(e,"scroll | fixed | local")},"<attr>":function(e){return"function"==e.type&&"attr"==e.name},"<bg-image>":function(e){return this["<image>"](e)||this["<gradient>"](e)||"none"==e},"<gradient>":function(e){return"function"==e.type&&/^(?:\-(?:ms|moz|o|webkit)\-)?(?:repeating\-)?(?:radial\-|linear\-)?gradient/i.test(e)},"<box>":function(e){return ValidationTypes.isLiteral(e,"padding-box | border-box | content-box")},"<content>":function(e){return"function"==e.type&&"content"==e.name},"<relative-size>":function(e){return ValidationTypes.isLiteral(e,"smaller | larger")},"<ident>":function(e){return"identifier"==e.type},"<length>":function(e){return!("function"!=e.type||!/^(?:\-(?:ms|moz|o|webkit)\-)?calc/i.test(e))||("length"==e.type||"number"==e.type||"integer"==e.type||"0"==e)},"<color>":function(e){return"color"==e.type||"transparent"==e},"<number>":function(e){return"number"==e.type||this["<integer>"](e)},"<integer>":function(e){return"integer"==e.type},"<line>":function(e){return"integer"==e.type},"<angle>":function(e){return"angle"==e.type},"<uri>":function(e){return"uri"==e.type},"<image>":function(e){return this["<uri>"](e)},"<percentage>":function(e){return"percentage"==e.type||"0"==e},"<border-width>":function(e){return this["<length>"](e)||ValidationTypes.isLiteral(e,"thin | medium | thick")},"<border-style>":function(e){return ValidationTypes.isLiteral(e,"none | hidden | dotted | dashed | solid | double | groove | ridge | inset | outset")},"<margin-width>":function(e){return this["<length>"](e)||this["<percentage>"](e)||ValidationTypes.isLiteral(e,"auto")},"<padding-width>":function(e){return this["<length>"](e)||this["<percentage>"](e)},"<shape>":function(e){return"function"==e.type&&("rect"==e.name||"inset-rect"==e.name)},"<time>":function(e){return"time"==e.type}},complex:{"<bg-position>":function(e){for(var t=!1,r="<percentage> | <length>",n="left | right",i="top | bottom",o=0;e.peek(o)&&","!=e.peek(o);)o++;return o<3?ValidationTypes.isAny(e,n+" | center | "+r)?(t=!0,ValidationTypes.isAny(e,i+" | center | "+r)):ValidationTypes.isAny(e,i)&&(t=!0,ValidationTypes.isAny(e,n+" | center")):ValidationTypes.isAny(e,n)?ValidationTypes.isAny(e,i)?(t=!0,ValidationTypes.isAny(e,r)):ValidationTypes.isAny(e,r)&&(ValidationTypes.isAny(e,i)?(t=!0,ValidationTypes.isAny(e,r)):ValidationTypes.isAny(e,"center")&&(t=!0)):ValidationTypes.isAny(e,i)?ValidationTypes.isAny(e,n)?(t=!0,ValidationTypes.isAny(e,r)):ValidationTypes.isAny(e,r)&&(ValidationTypes.isAny(e,n)?(t=!0,ValidationTypes.isAny(e,r)):ValidationTypes.isAny(e,"center")&&(t=!0)):ValidationTypes.isAny(e,"center")&&ValidationTypes.isAny(e,n+" | "+i)&&(t=!0,ValidationTypes.isAny(e,r)),t},"<bg-size>":function(e){var t=!1,r="<percentage> | <length> | auto";return ValidationTypes.isAny(e,"cover | contain")?t=!0:ValidationTypes.isAny(e,r)&&(t=!0,ValidationTypes.isAny(e,r)),t},"<repeat-style>":function(e){var t,r=!1,n="repeat | space | round | no-repeat";return e.hasNext()&&(t=e.next(),ValidationTypes.isLiteral(t,"repeat-x | repeat-y")?r=!0:ValidationTypes.isLiteral(t,n)&&(r=!0,e.hasNext()&&ValidationTypes.isLiteral(e.peek(),n)&&e.next())),r},"<shadow>":function(e){var t=!1,r=0,n=!1,i=!1;if(e.hasNext()){for(ValidationTypes.isAny(e,"inset")&&(n=!0),ValidationTypes.isAny(e,"<color>")&&(i=!0);ValidationTypes.isAny(e,"<length>")&&r<4;)r++;e.hasNext()&&(i||ValidationTypes.isAny(e,"<color>"),n||ValidationTypes.isAny(e,"inset")),t=r>=2&&r<=4}return t},"<x-one-radius>":function(e){var t=!1,r="<length> | <percentage> | inherit";return ValidationTypes.isAny(e,r)&&(t=!0,ValidationTypes.isAny(e,r)),t}}};parserlib.css={Colors:Colors,Combinator:Combinator,Parser:Parser,PropertyName:PropertyName,PropertyValue:PropertyValue,PropertyValuePart:PropertyValuePart,MediaFeature:MediaFeature,MediaQuery:MediaQuery,Selector:Selector,SelectorPart:SelectorPart,SelectorSubPart:SelectorSubPart,Specificity:Specificity,TokenStream:TokenStream,Tokens:Tokens,ValidationError:ValidationError}}(),function(){for(var e in parserlib)exports[e]=parserlib[e]}();var CSSLint=function(){function e(e,t){var r,i=e&&e.match(n),o=i&&i[1];return o&&(r={true:2,"":1,false:0,2:2,1:1,0:0},o.toLowerCase().split(",").forEach(function(e){var n=e.split(":"),i=n[0]||"",o=n[1]||"";t[i.trim()]=r[o.trim()]})),t}var t=[],r=[],n=/\/\*csslint([^\*]*)\*\//,i=new parserlib.util.EventTarget;return i.version="0.10.0",i.addRule=function(e){t.push(e),t[e.id]=e},i.clearRules=function(){t=[]},i.getRules=function(){return[].concat(t).sort(function(e,t){return e.id>t.id?1:0})},i.getRuleset=function(){for(var e={},r=0,n=t.length;r<n;)e[t[r++].id]=1;return e},i.addFormatter=function(e){r[e.id]=e},i.getFormatter=function(e){return r[e]},i.format=function(e,t,r,n){var i=this.getFormatter(r),o=null;return i&&(o=i.startFormat(),o+=i.formatResults(e,t,n||{}),o+=i.endFormat()),o},i.hasFormat=function(e){return r.hasOwnProperty(e)},i.verify=function(r,i){var o,a,s,l=0,u=(t.length,new parserlib.css.Parser({starHack:!0,ieFilters:!0,underscoreHack:!0,strict:!1}));a=r.replace(/\n\r?/g,"$split$").split("$split$"),i||(i=this.getRuleset()),n.test(r)&&(i=e(r,i)),o=new Reporter(a,i),i.errors=2;for(l in i)i.hasOwnProperty(l)&&i[l]&&t[l]&&t[l].init(u,o);try{u.parse(r)}catch(e){o.error("Fatal error, cannot continue: "+e.message,e.line,e.col,{})}return s={messages:o.messages,stats:o.stats,ruleset:o.ruleset},s.messages.sort(function(e,t){return e.rollup&&!t.rollup?1:!e.rollup&&t.rollup?-1:e.line-t.line}),s},i}();return Reporter.prototype={constructor:Reporter,error:function(e,t,r,n){this.messages.push({type:"error",line:t,col:r,message:e,evidence:this.lines[t-1],rule:n||{}})},warn:function(e,t,r,n){this.report(e,t,r,n)},report:function(e,t,r,n){this.messages.push({type:2==this.ruleset[n.id]?"error":"warning",line:t,col:r,message:e,evidence:this.lines[t-1],rule:n})},info:function(e,t,r,n){this.messages.push({type:"info",line:t,col:r,message:e,evidence:this.lines[t-1],rule:n})},rollupError:function(e,t){this.messages.push({type:"error",rollup:!0,message:e,rule:t})},rollupWarn:function(e,t){this.messages.push({type:"warning",rollup:!0,message:e,rule:t})},stat:function(e,t){this.stats[e]=t}},CSSLint._Reporter=Reporter,CSSLint.Util={mix:function(e,t){var r;for(r in t)t.hasOwnProperty(r)&&(e[r]=t[r]);return r},indexOf:function(e,t){if(e.indexOf)return e.indexOf(t);for(var r=0,n=e.length;r<n;r++)if(e[r]===t)return r;return-1},forEach:function(e,t){if(e.forEach)return e.forEach(t);for(var r=0,n=e.length;r<n;r++)t(e[r],r,e)}},CSSLint.addRule({id:"adjoining-classes",name:"Disallow adjoining classes",desc:"Don't use adjoining classes.",browsers:"IE6",init:function(e,t){var r=this;e.addListener("startrule",function(n){var i,o,a,s,l,u,d,c=n.selectors;for(l=0;l<c.length;l++)for(i=c[l],u=0;u<i.parts.length;u++)if(o=i.parts[u],o.type==e.SELECTOR_PART_TYPE)for(s=0,d=0;d<o.modifiers.length;d++)a=o.modifiers[d],"class"==a.type&&s++,s>1&&t.report("Don't use adjoining classes.",o.line,o.col,r)})}}),CSSLint.addRule({id:"box-model",name:"Beware of broken box size",desc:"Don't use width or height when using padding or border.",browsers:"All",init:function(e,t){function r(){i={},l=!1}function n(){var e,r;if(!l){if(i.height)for(e in s)s.hasOwnProperty(e)&&i[e]&&(r=i[e].value,"padding"==e&&2===r.parts.length&&0===r.parts[0].value||t.report("Using height with "+e+" can sometimes make elements larger than you expect.",i[e].line,i[e].col,o));if(i.width)for(e in a)a.hasOwnProperty(e)&&i[e]&&(r=i[e].value,"padding"==e&&2===r.parts.length&&0===r.parts[1].value||t.report("Using width with "+e+" can sometimes make elements larger than you expect.",i[e].line,i[e].col,o))}}var i,o=this,a={border:1,"border-left":1,"border-right":1,padding:1,"padding-left":1,"padding-right":1},s={border:1,"border-bottom":1,"border-top":1,padding:1,"padding-bottom":1,"padding-top":1},l=!1;e.addListener("startrule",r),e.addListener("startfontface",r),e.addListener("startpage",r),e.addListener("startpagemargin",r),e.addListener("startkeyframerule",r),e.addListener("property",function(e){var t=e.property.text.toLowerCase();s[t]||a[t]?/^0\S*$/.test(e.value)||"border"==t&&"none"==e.value||(i[t]={line:e.property.line,col:e.property.col,value:e.value}):/^(width|height)/i.test(t)&&/^(length|percentage)/.test(e.value.parts[0].type)?i[t]=1:"box-sizing"==t&&(l=!0)}),e.addListener("endrule",n),e.addListener("endfontface",n),e.addListener("endpage",n),e.addListener("endpagemargin",n),e.addListener("endkeyframerule",n)}}),CSSLint.addRule({id:"box-sizing",name:"Disallow use of box-sizing",desc:"The box-sizing properties isn't supported in IE6 and IE7.",browsers:"IE6, IE7",tags:["Compatibility"],init:function(e,t){var r=this;e.addListener("property",function(e){var n=e.property.text.toLowerCase();"box-sizing"==n&&t.report("The box-sizing property isn't supported in IE6 and IE7.",e.line,e.col,r)})}}),CSSLint.addRule({id:"bulletproof-font-face",name:"Use the bulletproof @font-face syntax",desc:"Use the bulletproof @font-face syntax to avoid 404's in old IE (http://www.fontspring.com/blog/the-new-bulletproof-font-face-syntax).",browsers:"All",init:function(e,t){var r,n,i=this,o=!1,a=!0,s=!1;e.addListener("startfontface",function(e){o=!0}),e.addListener("property",function(e){if(o){var t=e.property.toString().toLowerCase(),i=e.value.toString();if(r=e.line,n=e.col,"src"===t){var l=/^\s?url\(['"].+\.eot\?.*['"]\)\s*format\(['"]embedded-opentype['"]\).*$/i;!i.match(l)&&a?(s=!0,a=!1):i.match(l)&&!a&&(s=!1)}}}),e.addListener("endfontface",function(e){o=!1,s&&t.report("@font-face declaration doesn't follow the fontspring bulletproof syntax.",r,n,i)})}}),CSSLint.addRule({id:"compatible-vendor-prefixes",name:"Require compatible vendor prefixes",desc:"Include all compatible vendor prefixes to reach a wider range of users.",browsers:"All",init:function(e,t){var r,n,i,o,a,s,l,u=this,d=!1,c=Array.prototype.push,h=[];r={animation:"webkit moz","animation-delay":"webkit moz","animation-direction":"webkit moz","animation-duration":"webkit moz","animation-fill-mode":"webkit moz","animation-iteration-count":"webkit moz","animation-name":"webkit moz","animation-play-state":"webkit moz","animation-timing-function":"webkit moz",appearance:"webkit moz","border-end":"webkit moz","border-end-color":"webkit moz","border-end-style":"webkit moz","border-end-width":"webkit moz","border-image":"webkit moz o","border-radius":"webkit","border-start":"webkit moz","border-start-color":"webkit moz","border-start-style":"webkit moz","border-start-width":"webkit moz","box-align":"webkit moz ms","box-direction":"webkit moz ms","box-flex":"webkit moz ms","box-lines":"webkit ms","box-ordinal-group":"webkit moz ms","box-orient":"webkit moz ms","box-pack":"webkit moz ms","box-sizing":"webkit moz","box-shadow":"webkit moz","column-count":"webkit moz ms","column-gap":"webkit moz ms","column-rule":"webkit moz ms","column-rule-color":"webkit moz ms","column-rule-style":"webkit moz ms","column-rule-width":"webkit moz ms","column-width":"webkit moz ms",hyphens:"epub moz","line-break":"webkit ms","margin-end":"webkit moz","margin-start":"webkit moz","marquee-speed":"webkit wap","marquee-style":"webkit wap","padding-end":"webkit moz","padding-start":"webkit moz","tab-size":"moz o","text-size-adjust":"webkit ms",transform:"webkit moz ms o","transform-origin":"webkit moz ms o",transition:"webkit moz o","transition-delay":"webkit moz o","transition-duration":"webkit moz o","transition-property":"webkit moz o","transition-timing-function":"webkit moz o","user-modify":"webkit moz","user-select":"webkit moz ms","word-break":"epub ms","writing-mode":"epub ms"};for(i in r)if(r.hasOwnProperty(i)){for(o=[],a=r[i].split(" "),s=0,l=a.length;s<l;s++)o.push("-"+a[s]+"-"+i);r[i]=o,c.apply(h,o)}e.addListener("startrule",function(){n=[]}),e.addListener("startkeyframes",function(e){d=e.prefix||!0}),e.addListener("endkeyframes",function(e){d=!1}),e.addListener("property",function(e){var t=e.property;CSSLint.Util.indexOf(h,t.text)>-1&&(d&&"string"==typeof d&&0===t.text.indexOf("-"+d+"-")||n.push(t))}),e.addListener("endrule",function(e){if(n.length){var i,o,a,s,l,d,c,h,p,m,f={};for(i=0,o=n.length;i<o;i++){a=n[i];for(s in r)r.hasOwnProperty(s)&&(l=r[s],CSSLint.Util.indexOf(l,a.text)>-1&&(f[s]||(f[s]={full:l.slice(0),actual:[],actualNodes:[]}),CSSLint.Util.indexOf(f[s].actual,a.text)===-1&&(f[s].actual.push(a.text),f[s].actualNodes.push(a))))}for(s in f)if(f.hasOwnProperty(s)&&(d=f[s],c=d.full,h=d.actual,c.length>h.length))for(i=0,o=c.length;i<o;i++)p=c[i],CSSLint.Util.indexOf(h,p)===-1&&(m=1===h.length?h[0]:2==h.length?h.join(" and "):h.join(", "),t.report("The property "+p+" is compatible with "+m+" and should be included as well.",d.actualNodes[0].line,d.actualNodes[0].col,u))}})}}),CSSLint.addRule({id:"display-property-grouping",name:"Require properties appropriate for display",desc:"Certain properties shouldn't be used with certain display property values.",browsers:"All",init:function(e,t){function r(e,r,n){o[e]&&("string"==typeof s[e]&&o[e].value.toLowerCase()==s[e]||t.report(n||e+" can't be used with display: "+r+".",o[e].line,o[e].col,a))}function n(){o={}}function i(){var e=o.display?o.display.value:null;if(e)switch(e){case"inline":r("height",e),r("width",e),r("margin",e),r("margin-top",e),r("margin-bottom",e),r("float",e,"display:inline has no effect on floated elements (but may be used to fix the IE6 double-margin bug).");break;case"block":r("vertical-align",e);break;case"inline-block":r("float",e);break;default:0===e.indexOf("table-")&&(r("margin",e),r("margin-left",e),r("margin-right",e),r("margin-top",e),r("margin-bottom",e),r("float",e))}}var o,a=this,s={display:1,float:"none",height:1,width:1,margin:1,"margin-left":1,"margin-right":1,"margin-bottom":1,"margin-top":1,padding:1,"padding-left":1,"padding-right":1,"padding-bottom":1,"padding-top":1,"vertical-align":1};e.addListener("startrule",n),e.addListener("startfontface",n),e.addListener("startkeyframerule",n),e.addListener("startpagemargin",n),e.addListener("startpage",n),e.addListener("property",function(e){var t=e.property.text.toLowerCase();s[t]&&(o[t]={value:e.value.text,line:e.property.line,col:e.property.col})}),e.addListener("endrule",i),e.addListener("endfontface",i),e.addListener("endkeyframerule",i),e.addListener("endpagemargin",i),e.addListener("endpage",i)}}),CSSLint.addRule({id:"duplicate-background-images",name:"Disallow duplicate background images",desc:"Every background-image should be unique. Use a common class for e.g. sprites.",browsers:"All",init:function(e,t){var r=this,n={};e.addListener("property",function(e){var i,o,a=e.property.text,s=e.value;if(a.match(/background/i))for(i=0,o=s.parts.length;i<o;i++)"uri"==s.parts[i].type&&("undefined"==typeof n[s.parts[i].uri]?n[s.parts[i].uri]=e:t.report("Background image '"+s.parts[i].uri+"' was used multiple times, first declared at line "+n[s.parts[i].uri].line+", col "+n[s.parts[i].uri].col+".",e.line,e.col,r))})}}),CSSLint.addRule({id:"duplicate-properties",name:"Disallow duplicate properties",desc:"Duplicate properties must appear one after the other.",browsers:"All",init:function(e,t){function r(e){n={}}var n,i,o=this;e.addListener("startrule",r),e.addListener("startfontface",r),e.addListener("startpage",r),e.addListener("startpagemargin",r),e.addListener("startkeyframerule",r),e.addListener("property",function(e){var r=e.property,a=r.text.toLowerCase();!n[a]||i==a&&n[a]!=e.value.text||t.report("Duplicate property '"+e.property+"' found.",e.line,e.col,o),n[a]=e.value.text,i=a})}}),CSSLint.addRule({id:"empty-rules",name:"Disallow empty rules",desc:"Rules without any properties specified should be removed.",browsers:"All",init:function(e,t){var r=this,n=0;e.addListener("startrule",function(){n=0}),e.addListener("property",function(){n++}),e.addListener("endrule",function(e){var i=e.selectors;0===n&&t.report("Rule is empty.",i[0].line,i[0].col,r)})}}),CSSLint.addRule({id:"errors",name:"Parsing Errors",desc:"This rule looks for recoverable syntax errors.",browsers:"All",init:function(e,t){var r=this;e.addListener("error",function(e){t.error(e.message,e.line,e.col,r)})}}),CSSLint.addRule({id:"fallback-colors",name:"Require fallback colors",desc:"For older browsers that don't support RGBA, HSL, or HSLA, provide a fallback color.",browsers:"IE6,IE7,IE8",init:function(e,t){function r(e){i={},n=null}var n,i,o=this,a={color:1,background:1,"border-color":1,"border-top-color":1,"border-right-color":1,"border-bottom-color":1,"border-left-color":1,border:1,"border-top":1,"border-right":1,"border-bottom":1,"border-left":1,"background-color":1};e.addListener("startrule",r),e.addListener("startfontface",r),e.addListener("startpage",r),e.addListener("startpagemargin",r),e.addListener("startkeyframerule",r),e.addListener("property",function(e){var r=e.property,i=r.text.toLowerCase(),s=e.value.parts,l=0,u="",d=s.length;if(a[i])for(;l<d;)"color"==s[l].type&&("alpha"in s[l]||"hue"in s[l]?(/([^\)]+)\(/.test(s[l])&&(u=RegExp.$1.toUpperCase()),n&&n.property.text.toLowerCase()==i&&"compat"==n.colorType||t.report("Fallback "+i+" (hex or RGB) should precede "+u+" "+i+".",e.line,e.col,o)):e.colorType="compat"),l++;n=e})}}),CSSLint.addRule({id:"floats",name:"Disallow too many floats",desc:"This rule tests if the float property is used too many times",browsers:"All",init:function(e,t){var r=this,n=0;e.addListener("property",function(e){"float"==e.property.text.toLowerCase()&&"none"!=e.value.text.toLowerCase()&&n++}),e.addListener("endstylesheet",function(){t.stat("floats",n),n>=10&&t.rollupWarn("Too many floats ("+n+"), you're probably using them for layout. Consider using a grid system instead.",r)})}}),CSSLint.addRule({id:"font-faces",name:"Don't use too many web fonts",desc:"Too many different web fonts in the same stylesheet.",browsers:"All",init:function(e,t){var r=this,n=0;e.addListener("startfontface",function(){n++}),e.addListener("endstylesheet",function(){n>5&&t.rollupWarn("Too many @font-face declarations ("+n+").",r)})}}),CSSLint.addRule({id:"font-sizes",name:"Disallow too many font sizes",desc:"Checks the number of font-size declarations.",browsers:"All",init:function(e,t){var r=this,n=0;e.addListener("property",function(e){"font-size"==e.property&&n++}),e.addListener("endstylesheet",function(){t.stat("font-sizes",n),n>=10&&t.rollupWarn("Too many font-size declarations ("+n+"), abstraction needed.",r)})}}),CSSLint.addRule({id:"gradients",name:"Require all gradient definitions",desc:"When using a vendor-prefixed gradient, make sure to use them all.",browsers:"All",init:function(e,t){var r,n=this;e.addListener("startrule",function(){r={moz:0,webkit:0,oldWebkit:0,o:0}}),e.addListener("property",function(e){/\-(moz|o|webkit)(?:\-(?:linear|radial))\-gradient/i.test(e.value)?r[RegExp.$1]=1:/\-webkit\-gradient/i.test(e.value)&&(r.oldWebkit=1)}),e.addListener("endrule",function(e){var i=[];r.moz||i.push("Firefox 3.6+"),r.webkit||i.push("Webkit (Safari 5+, Chrome)"),r.oldWebkit||i.push("Old Webkit (Safari 4+, Chrome)"),r.o||i.push("Opera 11.1+"),i.length&&i.length<4&&t.report("Missing vendor-prefixed CSS gradients for "+i.join(", ")+".",e.selectors[0].line,e.selectors[0].col,n)})}}),CSSLint.addRule({id:"ids",name:"Disallow IDs in selectors",desc:"Selectors should not contain IDs.",browsers:"All",init:function(e,t){var r=this;e.addListener("startrule",function(n){var i,o,a,s,l,u,d,c=n.selectors;for(l=0;l<c.length;l++){for(i=c[l],s=0,u=0;u<i.parts.length;u++)if(o=i.parts[u],o.type==e.SELECTOR_PART_TYPE)for(d=0;d<o.modifiers.length;d++)a=o.modifiers[d],"id"==a.type&&s++;1==s?t.report("Don't use IDs in selectors.",i.line,i.col,r):s>1&&t.report(s+" IDs in the selector, really?",i.line,i.col,r)}})}}),CSSLint.addRule({id:"import",name:"Disallow @import",desc:"Don't use @import, use <link> instead.",browsers:"All",init:function(e,t){var r=this;e.addListener("import",function(e){t.report("@import prevents parallel downloads, use <link> instead.",e.line,e.col,r)})}}),CSSLint.addRule({id:"important",name:"Disallow !important",desc:"Be careful when using !important declaration",browsers:"All",init:function(e,t){var r=this,n=0;e.addListener("property",function(e){e.important===!0&&(n++,t.report("Use of !important",e.line,e.col,r))}),e.addListener("endstylesheet",function(){t.stat("important",n),n>=10&&t.rollupWarn("Too many !important declarations ("+n+"), try to use less than 10 to avoid specificity issues.",r)})}}),CSSLint.addRule({id:"known-properties",name:"Require use of known properties",desc:"Properties should be known (listed in CSS3 specification) or be a vendor-prefixed property.",browsers:"All",init:function(e,t){var r=this;e.addListener("property",function(e){e.property.text.toLowerCase();e.invalid&&t.report(e.invalid.message,e.line,e.col,r)})}}),CSSLint.addRule({id:"outline-none",name:"Disallow outline: none",desc:"Use of outline: none or outline: 0 should be limited to :focus rules.",browsers:"All",tags:["Accessibility"],init:function(e,t){function r(e){i=e.selectors?{line:e.line,col:e.col,selectors:e.selectors,propCount:0,outline:!1}:null}function n(e){i&&i.outline&&(i.selectors.toString().toLowerCase().indexOf(":focus")==-1?t.report("Outlines should only be modified using :focus.",i.line,i.col,o):1==i.propCount&&t.report("Outlines shouldn't be hidden unless other visual changes are made.",i.line,i.col,o))}var i,o=this;e.addListener("startrule",r),e.addListener("startfontface",r),e.addListener("startpage",r),e.addListener("startpagemargin",r),e.addListener("startkeyframerule",r),e.addListener("property",function(e){var t=e.property.text.toLowerCase(),r=e.value;i&&(i.propCount++,"outline"!=t||"none"!=r&&"0"!=r||(i.outline=!0))}),e.addListener("endrule",n),e.addListener("endfontface",n),e.addListener("endpage",n),e.addListener("endpagemargin",n),e.addListener("endkeyframerule",n)}}),CSSLint.addRule({id:"overqualified-elements",name:"Disallow overqualified elements",desc:"Don't use classes or IDs with elements (a.foo or a#foo).",browsers:"All",init:function(e,t){var r=this,n={};e.addListener("startrule",function(i){var o,a,s,l,u,d,c=i.selectors;for(l=0;l<c.length;l++)for(o=c[l],u=0;u<o.parts.length;u++)if(a=o.parts[u],a.type==e.SELECTOR_PART_TYPE)for(d=0;d<a.modifiers.length;d++)s=a.modifiers[d],a.elementName&&"id"==s.type?t.report("Element ("+a+") is overqualified, just use "+s+" without element name.",a.line,a.col,r):"class"==s.type&&(n[s]||(n[s]=[]),n[s].push({modifier:s,part:a}))}),e.addListener("endstylesheet",function(){var e;for(e in n)n.hasOwnProperty(e)&&1==n[e].length&&n[e][0].part.elementName&&t.report("Element ("+n[e][0].part+") is overqualified, just use "+n[e][0].modifier+" without element name.",n[e][0].part.line,n[e][0].part.col,r)})}}),CSSLint.addRule({id:"qualified-headings",name:"Disallow qualified headings",desc:"Headings should not be qualified (namespaced).",browsers:"All",init:function(e,t){var r=this;e.addListener("startrule",function(n){var i,o,a,s,l=n.selectors;for(a=0;a<l.length;a++)for(i=l[a],s=0;s<i.parts.length;s++)o=i.parts[s],o.type==e.SELECTOR_PART_TYPE&&o.elementName&&/h[1-6]/.test(o.elementName.toString())&&s>0&&t.report("Heading ("+o.elementName+") should not be qualified.",o.line,o.col,r)})}}),CSSLint.addRule({id:"regex-selectors",name:"Disallow selectors that look like regexs",desc:"Selectors that look like regular expressions are slow and should be avoided.",browsers:"All",init:function(e,t){var r=this;e.addListener("startrule",function(n){var i,o,a,s,l,u,d=n.selectors;for(s=0;s<d.length;s++)for(i=d[s],l=0;l<i.parts.length;l++)if(o=i.parts[l],o.type==e.SELECTOR_PART_TYPE)for(u=0;u<o.modifiers.length;u++)a=o.modifiers[u],"attribute"==a.type&&/([\~\|\^\$\*]=)/.test(a)&&t.report("Attribute selectors with "+RegExp.$1+" are slow!",a.line,a.col,r)})}}),CSSLint.addRule({id:"rules-count",name:"Rules Count",desc:"Track how many rules there are.",browsers:"All",init:function(e,t){var r=0;e.addListener("startrule",function(){r++}),e.addListener("endstylesheet",function(){t.stat("rule-count",r)})}}),CSSLint.addRule({id:"selector-max-approaching",name:"Warn when approaching the 4095 selector limit for IE",desc:"Will warn when selector count is >= 3800 selectors.",browsers:"IE",init:function(e,t){var r=this,n=0;e.addListener("startrule",function(e){n+=e.selectors.length}),e.addListener("endstylesheet",function(){n>=3800&&t.report("You have "+n+" selectors. Internet Explorer supports a maximum of 4095 selectors per stylesheet. Consider refactoring.",0,0,r)})}}),CSSLint.addRule({id:"selector-max",name:"Error when past the 4095 selector limit for IE",desc:"Will error when selector count is > 4095.",browsers:"IE",init:function(e,t){var r=this,n=0;e.addListener("startrule",function(e){n+=e.selectors.length}),e.addListener("endstylesheet",function(){n>4095&&t.report("You have "+n+" selectors. Internet Explorer supports a maximum of 4095 selectors per stylesheet. Consider refactoring.",0,0,r)})}}),CSSLint.addRule({id:"shorthand",name:"Require shorthand properties",desc:"Use shorthand properties where possible.",browsers:"All",init:function(e,t){function r(e){s={}}function n(e){var r,n,i,o;for(r in d)if(d.hasOwnProperty(r)){for(o=0,n=0,i=d[r].length;n<i;n++)o+=s[d[r][n]]?1:0;o==d[r].length&&t.report("The properties "+d[r].join(", ")+" can be replaced by "+r+".",e.line,e.col,l)}}var i,o,a,s,l=this,u={},d={margin:["margin-top","margin-bottom","margin-left","margin-right"],padding:["padding-top","padding-bottom","padding-left","padding-right"]};for(i in d)if(d.hasOwnProperty(i))for(o=0,a=d[i].length;o<a;o++)u[d[i][o]]=i;e.addListener("startrule",r),e.addListener("startfontface",r),e.addListener("property",function(e){var t=e.property.toString().toLowerCase();e.value.parts[0].value;u[t]&&(s[t]=1)}),e.addListener("endrule",n),e.addListener("endfontface",n)}}),CSSLint.addRule({id:"star-property-hack",name:"Disallow properties with a star prefix",desc:"Checks for the star property hack (targets IE6/7)",browsers:"All",init:function(e,t){var r=this;e.addListener("property",function(e){var n=e.property;"*"==n.hack&&t.report("Property with star prefix found.",e.property.line,e.property.col,r)})}}),CSSLint.addRule({id:"text-indent",name:"Disallow negative text-indent",desc:"Checks for text indent less than -99px",browsers:"All",init:function(e,t){function r(e){i=!1,o="inherit"}function n(e){i&&"ltr"!=o&&t.report("Negative text-indent doesn't work well with RTL. If you use text-indent for image replacement explicitly set direction for that item to ltr.",i.line,i.col,a)}var i,o,a=this;e.addListener("startrule",r),e.addListener("startfontface",r),e.addListener("property",function(e){var t=e.property.toString().toLowerCase(),r=e.value;"text-indent"==t&&r.parts[0].value<-99?i=e.property:"direction"==t&&"ltr"==r&&(o="ltr")}),e.addListener("endrule",n),e.addListener("endfontface",n)}}),CSSLint.addRule({id:"underscore-property-hack",name:"Disallow properties with an underscore prefix",desc:"Checks for the underscore property hack (targets IE6)",browsers:"All",init:function(e,t){var r=this;e.addListener("property",function(e){var n=e.property;"_"==n.hack&&t.report("Property with underscore prefix found.",e.property.line,e.property.col,r)})}}),CSSLint.addRule({id:"unique-headings",name:"Headings should only be defined once",desc:"Headings should be defined only once.",browsers:"All",init:function(e,t){var r=this,n={h1:0,h2:0,h3:0,h4:0,h5:0,h6:0};e.addListener("startrule",function(e){var i,o,a,s,l,u=e.selectors;for(s=0;s<u.length;s++)if(i=u[s],o=i.parts[i.parts.length-1],o.elementName&&/(h[1-6])/i.test(o.elementName.toString())){for(l=0;l<o.modifiers.length;l++)if("pseudo"==o.modifiers[l].type){a=!0;break}a||(n[RegExp.$1]++,n[RegExp.$1]>1&&t.report("Heading ("+o.elementName+") has already been defined.",o.line,o.col,r))}}),e.addListener("endstylesheet",function(e){var i,o=[];for(i in n)n.hasOwnProperty(i)&&n[i]>1&&o.push(n[i]+" "+i+"s");o.length&&t.rollupWarn("You have "+o.join(", ")+" defined in this stylesheet.",r)})}}),CSSLint.addRule({id:"universal-selector",name:"Disallow universal selector",desc:"The universal selector (*) is known to be slow.",browsers:"All",init:function(e,t){var r=this;e.addListener("startrule",function(e){var n,i,o,a=e.selectors;for(o=0;o<a.length;o++)n=a[o],i=n.parts[n.parts.length-1],"*"==i.elementName&&t.report(r.desc,i.line,i.col,r)})}}),CSSLint.addRule({id:"unqualified-attributes",name:"Disallow unqualified attribute selectors",desc:"Unqualified attribute selectors are known to be slow.",browsers:"All",init:function(e,t){var r=this;e.addListener("startrule",function(n){var i,o,a,s,l,u=n.selectors;for(s=0;s<u.length;s++)if(i=u[s],o=i.parts[i.parts.length-1],o.type==e.SELECTOR_PART_TYPE)for(l=0;l<o.modifiers.length;l++)a=o.modifiers[l],"attribute"!=a.type||o.elementName&&"*"!=o.elementName||t.report(r.desc,o.line,o.col,r)})}}),CSSLint.addRule({id:"vendor-prefix",name:"Require standard property with vendor prefix",desc:"When using a vendor-prefixed property, make sure to include the standard one.",browsers:"All",init:function(e,t){function r(){i={},o=1}function n(e){var r,n,o,l,u,d=[];for(r in i)s[r]&&d.push({actual:r,needed:s[r]});for(n=0,o=d.length;n<o;n++)l=d[n].needed,u=d[n].actual,i[l]?i[l][0].pos<i[u][0].pos&&t.report("Standard property '"+l+"' should come after vendor-prefixed property '"+u+"'.",i[u][0].name.line,i[u][0].name.col,a):t.report("Missing standard property '"+l+"' to go along with '"+u+"'.",i[u][0].name.line,i[u][0].name.col,a)}var i,o,a=this,s={"-webkit-border-radius":"border-radius","-webkit-border-top-left-radius":"border-top-left-radius","-webkit-border-top-right-radius":"border-top-right-radius","-webkit-border-bottom-left-radius":"border-bottom-left-radius","-webkit-border-bottom-right-radius":"border-bottom-right-radius","-o-border-radius":"border-radius","-o-border-top-left-radius":"border-top-left-radius","-o-border-top-right-radius":"border-top-right-radius","-o-border-bottom-left-radius":"border-bottom-left-radius","-o-border-bottom-right-radius":"border-bottom-right-radius","-moz-border-radius":"border-radius","-moz-border-radius-topleft":"border-top-left-radius","-moz-border-radius-topright":"border-top-right-radius","-moz-border-radius-bottomleft":"border-bottom-left-radius","-moz-border-radius-bottomright":"border-bottom-right-radius","-moz-column-count":"column-count","-webkit-column-count":"column-count","-moz-column-gap":"column-gap","-webkit-column-gap":"column-gap","-moz-column-rule":"column-rule","-webkit-column-rule":"column-rule","-moz-column-rule-style":"column-rule-style","-webkit-column-rule-style":"column-rule-style","-moz-column-rule-color":"column-rule-color","-webkit-column-rule-color":"column-rule-color","-moz-column-rule-width":"column-rule-width","-webkit-column-rule-width":"column-rule-width","-moz-column-width":"column-width","-webkit-column-width":"column-width","-webkit-column-span":"column-span","-webkit-columns":"columns","-moz-box-shadow":"box-shadow","-webkit-box-shadow":"box-shadow","-moz-transform":"transform","-webkit-transform":"transform","-o-transform":"transform","-ms-transform":"transform","-moz-transform-origin":"transform-origin","-webkit-transform-origin":"transform-origin","-o-transform-origin":"transform-origin","-ms-transform-origin":"transform-origin","-moz-box-sizing":"box-sizing","-webkit-box-sizing":"box-sizing","-moz-user-select":"user-select","-khtml-user-select":"user-select",
4
- "-webkit-user-select":"user-select"};e.addListener("startrule",r),e.addListener("startfontface",r),e.addListener("startpage",r),e.addListener("startpagemargin",r),e.addListener("startkeyframerule",r),e.addListener("property",function(e){var t=e.property.text.toLowerCase();i[t]||(i[t]=[]),i[t].push({name:e.property,value:e.value,pos:o++})}),e.addListener("endrule",n),e.addListener("endfontface",n),e.addListener("endpage",n),e.addListener("endpagemargin",n),e.addListener("endkeyframerule",n)}}),CSSLint.addRule({id:"zero-units",name:"Disallow units for 0 values",desc:"You don't need to specify units when a value is 0.",browsers:"All",init:function(e,t){var r=this;e.addListener("property",function(e){for(var n=e.value.parts,i=0,o=n.length;i<o;)!n[i].units&&"percentage"!=n[i].type||0!==n[i].value||"time"==n[i].type||t.report("Values of 0 shouldn't have units specified.",n[i].line,n[i].col,r),i++})}}),function(){var e=function(e){return e&&e.constructor===String?e.replace(/[\"&><]/g,function(e){switch(e){case'"':return"&quot;";case"&":return"&amp;";case"<":return"&lt;";case">":return"&gt;"}}):""};CSSLint.addFormatter({id:"checkstyle-xml",name:"Checkstyle XML format",startFormat:function(){return'<?xml version="1.0" encoding="utf-8"?><checkstyle>'},endFormat:function(){return"</checkstyle>"},readError:function(t,r){return'<file name="'+e(t)+'"><error line="0" column="0" severty="error" message="'+e(r)+'"></error></file>'},formatResults:function(t,r,n){var i=t.messages,o=[],a=function(e){return e&&"name"in e?"net.csslint."+e.name.replace(/\s/g,""):""};return i.length>0&&(o.push('<file name="'+r+'">'),CSSLint.Util.forEach(i,function(t,r){t.rollup||o.push('<error line="'+t.line+'" column="'+t.col+'" severity="'+t.type+'" message="'+e(t.message)+'" source="'+a(t.rule)+'"/>')}),o.push("</file>")),o.join("")}})}(),CSSLint.addFormatter({id:"compact",name:"Compact, 'porcelain' format",startFormat:function(){return""},endFormat:function(){return""},formatResults:function(e,t,r){var n=e.messages,i="";r=r||{};var o=function(e){return e.charAt(0).toUpperCase()+e.slice(1)};return 0===n.length?r.quiet?"":t+": Lint Free!":(CSSLint.Util.forEach(n,function(e,r){i+=e.rollup?t+": "+o(e.type)+" - "+e.message+"\n":t+": line "+e.line+", col "+e.col+", "+o(e.type)+" - "+e.message+"\n"}),i)}}),CSSLint.addFormatter({id:"csslint-xml",name:"CSSLint XML format",startFormat:function(){return'<?xml version="1.0" encoding="utf-8"?><csslint>'},endFormat:function(){return"</csslint>"},formatResults:function(e,t,r){var n=e.messages,i=[],o=function(e){return e&&e.constructor===String?e.replace(/\"/g,"'").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"):""};return n.length>0&&(i.push('<file name="'+t+'">'),CSSLint.Util.forEach(n,function(e,t){e.rollup?i.push('<issue severity="'+e.type+'" reason="'+o(e.message)+'" evidence="'+o(e.evidence)+'"/>'):i.push('<issue line="'+e.line+'" char="'+e.col+'" severity="'+e.type+'" reason="'+o(e.message)+'" evidence="'+o(e.evidence)+'"/>')}),i.push("</file>")),i.join("")}}),CSSLint.addFormatter({id:"junit-xml",name:"JUNIT XML format",startFormat:function(){return'<?xml version="1.0" encoding="utf-8"?><testsuites>'},endFormat:function(){return"</testsuites>"},formatResults:function(e,t,r){var n=e.messages,i=[],o={error:0,failure:0},a=function(e){return e&&"name"in e?"net.csslint."+e.name.replace(/\s/g,""):""},s=function(e){return e&&e.constructor===String?e.replace(/\"/g,"'").replace(/</g,"&lt;").replace(/>/g,"&gt;"):""};return n.length>0&&(n.forEach(function(e,t){var r="warning"===e.type?"error":e.type;e.rollup||(i.push('<testcase time="0" name="'+a(e.rule)+'">'),i.push("<"+r+' message="'+s(e.message)+'"><![CDATA['+e.line+":"+e.col+":"+s(e.evidence)+"]]></"+r+">"),i.push("</testcase>"),o[r]+=1)}),i.unshift('<testsuite time="0" tests="'+n.length+'" skipped="0" errors="'+o.error+'" failures="'+o.failure+'" package="net.csslint" name="'+t+'">'),i.push("</testsuite>")),i.join("")}}),CSSLint.addFormatter({id:"lint-xml",name:"Lint XML format",startFormat:function(){return'<?xml version="1.0" encoding="utf-8"?><lint>'},endFormat:function(){return"</lint>"},formatResults:function(e,t,r){var n=e.messages,i=[],o=function(e){return e&&e.constructor===String?e.replace(/\"/g,"'").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"):""};return n.length>0&&(i.push('<file name="'+t+'">'),CSSLint.Util.forEach(n,function(e,t){e.rollup?i.push('<issue severity="'+e.type+'" reason="'+o(e.message)+'" evidence="'+o(e.evidence)+'"/>'):i.push('<issue line="'+e.line+'" char="'+e.col+'" severity="'+e.type+'" reason="'+o(e.message)+'" evidence="'+o(e.evidence)+'"/>')}),i.push("</file>")),i.join("")}}),CSSLint.addFormatter({id:"text",name:"Plain Text",startFormat:function(){return""},endFormat:function(){return""},formatResults:function(e,t,r){var n=e.messages,i="";if(r=r||{},0===n.length)return r.quiet?"":"\n\ncsslint: No errors in "+t+".";i="\n\ncsslint: There are "+n.length+" problems in "+t+".";var o=t.lastIndexOf("/"),a=t;return o===-1&&(o=t.lastIndexOf("\\")),o>-1&&(a=t.substring(o+1)),CSSLint.Util.forEach(n,function(e,t){i=i+"\n\n"+a,e.rollup?(i+="\n"+(t+1)+": "+e.type,i+="\n"+e.message):(i+="\n"+(t+1)+": "+e.type+" at line "+e.line+", col "+e.col,i+="\n"+e.message,i+="\n"+e.evidence)}),i}}),CSSLint}();
1
+ var CSSLint=function(){function e(e,t,r,n){"use strict";this.messages=[],this.stats=[],this.lines=e,this.ruleset=t,this.allow=r,this.allow||(this.allow={}),this.ignore=n,this.ignore||(this.ignore=[])}var t=t||{},r=function(){var e;return(e=function t(r,n,i){function o(s,l){if(!n[s]){if(!r[s]){var c="function"==typeof e&&e;if(!l&&c)return c(s,!0);if(a)return a(s,!0);var u=new Error("Cannot find module '"+s+"'");throw u.code="MODULE_NOT_FOUND",u}var d=n[s]={exports:{}};r[s][0].call(d.exports,function(e){var t=r[s][1][e];return o(t?t:e)},d,d.exports,t,r,n,i)}return n[s].exports}for(var a="function"==typeof e&&e,s=0;s<i.length;s++)o(i[s]);return o}({1:[function(e,t,r){"use strict";t.exports={__proto__:null,aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgrey:"#a9a9a9",darkgreen:"#006400",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",grey:"#808080",green:"#008000",greenyellow:"#adff2f",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgrey:"#d3d3d3",lightgreen:"#90ee90",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370d8",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#d87093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32",currentColor:"The value of the 'color' property.",activeBorder:"Active window border.",activecaption:"Active window caption.",appworkspace:"Background color of multiple document interface.",background:"Desktop background.",buttonface:"The face background color for 3-D elements that appear 3-D due to one layer of surrounding border.",buttonhighlight:"The color of the border facing the light source for 3-D elements that appear 3-D due to one layer of surrounding border.",buttonshadow:"The color of the border away from the light source for 3-D elements that appear 3-D due to one layer of surrounding border.",buttontext:"Text on push buttons.",captiontext:"Text in caption, size box, and scrollbar arrow box.",graytext:"Grayed (disabled) text. This color is set to #000 if the current display driver does not support a solid gray color.",greytext:"Greyed (disabled) text. This color is set to #000 if the current display driver does not support a solid grey color.",highlight:"Item(s) selected in a control.",highlighttext:"Text of item(s) selected in a control.",inactiveborder:"Inactive window border.",inactivecaption:"Inactive window caption.",inactivecaptiontext:"Color of text in an inactive caption.",infobackground:"Background color for tooltip controls.",infotext:"Text color for tooltip controls.",menu:"Menu background.",menutext:"Text in menus.",scrollbar:"Scroll bar gray area.",threeddarkshadow:"The color of the darker (generally outer) of the two borders away from the light source for 3-D elements that appear 3-D due to two concentric layers of surrounding border.",threedface:"The face background color for 3-D elements that appear 3-D due to two concentric layers of surrounding border.",threedhighlight:"The color of the lighter (generally outer) of the two borders facing the light source for 3-D elements that appear 3-D due to two concentric layers of surrounding border.",threedlightshadow:"The color of the darker (generally inner) of the two borders facing the light source for 3-D elements that appear 3-D due to two concentric layers of surrounding border.",threedshadow:"The color of the lighter (generally inner) of the two borders away from the light source for 3-D elements that appear 3-D due to two concentric layers of surrounding border.",window:"Window background.",windowframe:"Window frame.",windowtext:"Text in windows."}},{}],2:[function(e,t,r){"use strict";function n(e,t,r){i.call(this,e,t,r,o.COMBINATOR_TYPE),this.type="unknown",/^\s+$/.test(e)?this.type="descendant":">"===e?this.type="child":"+"===e?this.type="adjacent-sibling":"~"===e&&(this.type="sibling")}t.exports=n;var i=e("../util/SyntaxUnit"),o=e("./Parser");n.prototype=new i,n.prototype.constructor=n},{"../util/SyntaxUnit":26,"./Parser":6}],3:[function(e,t,r){"use strict";function n(e,t){this.match=function(t){var r;return t.mark(),r=e(t),r?t.drop():t.restore(),r},this.toString="function"==typeof t?t:function(){return t}}t.exports=n;var i=e("../util/StringReader"),o=e("../util/SyntaxError");n.prec={MOD:5,SEQ:4,ANDAND:3,OROR:2,ALT:1},n.parse=function(e){var t,r,a,s,l,c,u,d,h;if(t=new i(e),r=function(e){var r=t.readMatch(e);if(null===r)throw new o("Expected "+e,t.getLine(),t.getCol());return r},a=function(){for(var e=[s()];null!==t.readMatch(" | ");)e.push(s());return 1===e.length?e[0]:n.alt.apply(n,e)},s=function(){for(var e=[l()];null!==t.readMatch(" || ");)e.push(l());return 1===e.length?e[0]:n.oror.apply(n,e)},l=function(){for(var e=[c()];null!==t.readMatch(" && ");)e.push(c());return 1===e.length?e[0]:n.andand.apply(n,e)},c=function(){for(var e=[u()];null!==t.readMatch(/^ (?![&|\]])/);)e.push(u());return 1===e.length?e[0]:n.seq.apply(n,e)},u=function(){var e=d();if(null!==t.readMatch("?"))return e.question();if(null!==t.readMatch("*"))return e.star();if(null!==t.readMatch("+"))return e.plus();if(null!==t.readMatch("#"))return e.hash();if(null!==t.readMatch(/^\{\s*/)){var n=r(/^\d+/);r(/^\s*,\s*/);var i=r(/^\d+/);return r(/^\s*\}/),e.braces(+n,+i)}return e},d=function(){if(null!==t.readMatch("[ ")){var e=a();return r(" ]"),e}return n.fromType(r(/^[^ ?*+#{]+/))},h=a(),!t.eof())throw new o("Expected end of string",t.getLine(),t.getCol());return h},n.cast=function(e){return e instanceof n?e:n.parse(e)},n.fromType=function(t){var r=e("./ValidationTypes");return new n(function(e){return e.hasNext()&&r.isType(e,t)},t)},n.seq=function(){var e=Array.prototype.slice.call(arguments).map(n.cast);return 1===e.length?e[0]:new n(function(t){var r,n=!0;for(r=0;n&&r<e.length;r++)n=e[r].match(t);return n},function(t){var r=n.prec.SEQ,i=e.map(function(e){return e.toString(r)}).join(" ");return t>r&&(i="[ "+i+" ]"),i})},n.alt=function(){var e=Array.prototype.slice.call(arguments).map(n.cast);return 1===e.length?e[0]:new n(function(t){var r,n=!1;for(r=0;!n&&r<e.length;r++)n=e[r].match(t);return n},function(t){var r=n.prec.ALT,i=e.map(function(e){return e.toString(r)}).join(" | ");return t>r&&(i="[ "+i+" ]"),i})},n.many=function(t){var r=Array.prototype.slice.call(arguments,1).reduce(function(t,r){if(r.expand){var i=e("./ValidationTypes");t.push.apply(t,i.complex[r.expand].options)}else t.push(n.cast(r));return t},[]);t===!0&&(t=r.map(function(){return!0}));var i=new n(function(e){var n=[],i=0,o=0,a=function(e){return 0===o?(i=Math.max(e,i),e===r.length):e===i},s=function(i){for(var o=0;o<r.length;o++)if(!n[o])if(e.mark(),r[o].match(e)){if(n[o]=!0,s(i+(t===!1||t[o]?1:0)))return e.drop(),!0;e.restore(),n[o]=!1}else e.drop();return a(i)};if(s(0)||(o++,s(0)),t===!1)return i>0;for(var l=0;l<r.length;l++)if(t[l]&&!n[l])return!1;return!0},function(e){var i=t===!1?n.prec.OROR:n.prec.ANDAND,o=r.map(function(e,r){return t===!1||t[r]?e.toString(i):e.toString(n.prec.MOD)+"?"}).join(t===!1?" || ":" && ");return e>i&&(o="[ "+o+" ]"),o});return i.options=r,i},n.andand=function(){var e=Array.prototype.slice.call(arguments);return e.unshift(!0),n.many.apply(n,e)},n.oror=function(){var e=Array.prototype.slice.call(arguments);return e.unshift(!1),n.many.apply(n,e)},n.prototype={constructor:n,match:function(){throw new Error("unimplemented")},toString:function(){throw new Error("unimplemented")},func:function(){return this.match.bind(this)},then:function(e){return n.seq(this,e)},or:function(e){return n.alt(this,e)},andand:function(e){return n.many(!0,this,e)},oror:function(e){return n.many(!1,this,e)},star:function(){return this.braces(0,1/0,"*")},plus:function(){return this.braces(1,1/0,"+")},question:function(){return this.braces(0,1,"?")},hash:function(){return this.braces(1,1/0,"#",n.cast(","))},braces:function(e,t,r,i){var o=this,a=i?i.then(this):this;return r||(r="{"+e+","+t+"}"),new n(function(r){var n,s=!0;for(n=0;n<t&&(s=n>0&&i?a.match(r):o.match(r),s);n++);return n>=e},function(){return o.toString(n.prec.MOD)+r})}}},{"../util/StringReader":24,"../util/SyntaxError":25,"./ValidationTypes":21}],4:[function(e,t,r){"use strict";function n(e,t){i.call(this,"("+e+(null!==t?":"+t:"")+")",e.startLine,e.startCol,o.MEDIA_FEATURE_TYPE),this.name=e,this.value=t}t.exports=n;var i=e("../util/SyntaxUnit"),o=e("./Parser");n.prototype=new i,n.prototype.constructor=n},{"../util/SyntaxUnit":26,"./Parser":6}],5:[function(e,t,r){"use strict";function n(e,t,r,n,a){i.call(this,(e?e+" ":"")+(t?t:"")+(t&&r.length>0?" and ":"")+r.join(" and "),n,a,o.MEDIA_QUERY_TYPE),this.modifier=e,this.mediaType=t,this.features=r}t.exports=n;var i=e("../util/SyntaxUnit"),o=e("./Parser");n.prototype=new i,n.prototype.constructor=n},{"../util/SyntaxUnit":26,"./Parser":6}],6:[function(e,t,r){"use strict";function n(e){i.call(this),this.options=e||{},this._tokenStream=null}t.exports=n;var i=e("../util/EventTarget"),o=e("../util/SyntaxError"),a=e("../util/SyntaxUnit"),s=e("./Combinator"),l=e("./MediaFeature"),c=e("./MediaQuery"),u=e("./PropertyName"),d=e("./PropertyValue"),h=e("./PropertyValuePart"),p=e("./Selector"),f=e("./SelectorPart"),m=e("./SelectorSubPart"),g=e("./TokenStream"),b=e("./Tokens"),k=e("./Validation");n.DEFAULT_TYPE=0,n.COMBINATOR_TYPE=1,n.MEDIA_FEATURE_TYPE=2,n.MEDIA_QUERY_TYPE=3,n.PROPERTY_NAME_TYPE=4,n.PROPERTY_VALUE_TYPE=5,n.PROPERTY_VALUE_PART_TYPE=6,n.SELECTOR_TYPE=7,n.SELECTOR_PART_TYPE=8,n.SELECTOR_SUB_PART_TYPE=9,n.prototype=function(){var e,t=new i,r={__proto__:null,constructor:n,DEFAULT_TYPE:0,COMBINATOR_TYPE:1,MEDIA_FEATURE_TYPE:2,MEDIA_QUERY_TYPE:3,PROPERTY_NAME_TYPE:4,PROPERTY_VALUE_TYPE:5,PROPERTY_VALUE_PART_TYPE:6,SELECTOR_TYPE:7,SELECTOR_PART_TYPE:8,SELECTOR_SUB_PART_TYPE:9,_stylesheet:function(){var e,t,r,n=this._tokenStream;for(this.fire("startstylesheet"),this._charset(),this._skipCruft();n.peek()===b.IMPORT_SYM;)this._import(),this._skipCruft();for(;n.peek()===b.NAMESPACE_SYM;)this._namespace(),this._skipCruft();for(r=n.peek();r>b.EOF;){try{switch(r){case b.MEDIA_SYM:this._media(),this._skipCruft();break;case b.PAGE_SYM:this._page(),this._skipCruft();break;case b.FONT_FACE_SYM:this._font_face(),this._skipCruft();break;case b.KEYFRAMES_SYM:this._keyframes(),this._skipCruft();break;case b.VIEWPORT_SYM:this._viewport(),this._skipCruft();break;case b.DOCUMENT_SYM:this._document(),this._skipCruft();break;case b.SUPPORTS_SYM:this._supports(),this._skipCruft();break;case b.UNKNOWN_SYM:if(n.get(),this.options.strict)throw new o("Unknown @ rule.",n.LT(0).startLine,n.LT(0).startCol);for(this.fire({type:"error",error:null,message:"Unknown @ rule: "+n.LT(0).value+".",line:n.LT(0).startLine,col:n.LT(0).startCol}),e=0;n.advance([b.LBRACE,b.RBRACE])===b.LBRACE;)e++;for(;e;)n.advance([b.RBRACE]),e--;break;case b.S:this._readWhitespace();break;default:if(!this._ruleset())switch(r){case b.CHARSET_SYM:throw t=n.LT(1),this._charset(!1),new o("@charset not allowed here.",t.startLine,t.startCol);case b.IMPORT_SYM:throw t=n.LT(1),this._import(!1),new o("@import not allowed here.",t.startLine,t.startCol);case b.NAMESPACE_SYM:throw t=n.LT(1),this._namespace(!1),new o("@namespace not allowed here.",t.startLine,t.startCol);default:n.get(),this._unexpectedToken(n.token())}}}catch(i){if(!(i instanceof o)||this.options.strict)throw i;this.fire({type:"error",error:i,message:i.message,line:i.line,col:i.col})}r=n.peek()}r!==b.EOF&&this._unexpectedToken(n.token()),this.fire("endstylesheet")},_charset:function(e){var t,r,n,i,o=this._tokenStream;o.match(b.CHARSET_SYM)&&(n=o.token().startLine,i=o.token().startCol,this._readWhitespace(),o.mustMatch(b.STRING),r=o.token(),t=r.value,this._readWhitespace(),o.mustMatch(b.SEMICOLON),e!==!1&&this.fire({type:"charset",charset:t,line:n,col:i}))},_import:function(e){var t,r,n=this._tokenStream,i=[];n.mustMatch(b.IMPORT_SYM),r=n.token(),this._readWhitespace(),n.mustMatch([b.STRING,b.URI]),t=n.token().value.replace(/^(?:url\()?["']?([^"']+?)["']?\)?$/,"$1"),this._readWhitespace(),i=this._media_query_list(),n.mustMatch(b.SEMICOLON),this._readWhitespace(),e!==!1&&this.fire({type:"import",uri:t,media:i,line:r.startLine,col:r.startCol})},_namespace:function(e){var t,r,n,i,o=this._tokenStream;o.mustMatch(b.NAMESPACE_SYM),t=o.token().startLine,r=o.token().startCol,this._readWhitespace(),o.match(b.IDENT)&&(n=o.token().value,this._readWhitespace()),o.mustMatch([b.STRING,b.URI]),i=o.token().value.replace(/(?:url\()?["']([^"']+)["']\)?/,"$1"),this._readWhitespace(),o.mustMatch(b.SEMICOLON),this._readWhitespace(),e!==!1&&this.fire({type:"namespace",prefix:n,uri:i,line:t,col:r})},_supports:function(e){var t,r,n=this._tokenStream;if(n.match(b.SUPPORTS_SYM)){for(t=n.token().startLine,r=n.token().startCol,this._readWhitespace(),this._supports_condition(),this._readWhitespace(),n.mustMatch(b.LBRACE),this._readWhitespace(),e!==!1&&this.fire({type:"startsupports",line:t,col:r});;)if(!this._ruleset())break;n.mustMatch(b.RBRACE),this._readWhitespace(),this.fire({type:"endsupports",line:t,col:r})}},_supports_condition:function(){var e,t=this._tokenStream;if(t.match(b.IDENT))e=t.token().value.toLowerCase(),"not"===e?(t.mustMatch(b.S),this._supports_condition_in_parens()):t.unget();else for(this._supports_condition_in_parens(),this._readWhitespace();t.peek()===b.IDENT;)e=t.LT(1).value.toLowerCase(),"and"!==e&&"or"!==e||(t.mustMatch(b.IDENT),this._readWhitespace(),this._supports_condition_in_parens(),this._readWhitespace())},_supports_condition_in_parens:function(){var e,t=this._tokenStream;t.match(b.LPAREN)?(this._readWhitespace(),t.match(b.IDENT)?(e=t.token().value.toLowerCase(),"not"===e?(this._readWhitespace(),this._supports_condition(),this._readWhitespace(),t.mustMatch(b.RPAREN)):(t.unget(),this._supports_declaration_condition(!1))):(this._supports_condition(),this._readWhitespace(),t.mustMatch(b.RPAREN))):this._supports_declaration_condition()},_supports_declaration_condition:function(e){var t=this._tokenStream;e!==!1&&t.mustMatch(b.LPAREN),this._readWhitespace(),this._declaration(),t.mustMatch(b.RPAREN)},_media:function(){var e,t,r,n=this._tokenStream;for(n.mustMatch(b.MEDIA_SYM),e=n.token().startLine,t=n.token().startCol,this._readWhitespace(),r=this._media_query_list(),n.mustMatch(b.LBRACE),this._readWhitespace(),this.fire({type:"startmedia",media:r,line:e,col:t});;)if(n.peek()===b.PAGE_SYM)this._page();else if(n.peek()===b.FONT_FACE_SYM)this._font_face();else if(n.peek()===b.VIEWPORT_SYM)this._viewport();else if(n.peek()===b.DOCUMENT_SYM)this._document();else if(n.peek()===b.SUPPORTS_SYM)this._supports();else if(!this._ruleset())break;n.mustMatch(b.RBRACE),this._readWhitespace(),this.fire({type:"endmedia",media:r,line:e,col:t})},_media_query_list:function(){var e=this._tokenStream,t=[];for(this._readWhitespace(),e.peek()!==b.IDENT&&e.peek()!==b.LPAREN||t.push(this._media_query());e.match(b.COMMA);)this._readWhitespace(),t.push(this._media_query());return t},_media_query:function(){var e=this._tokenStream,t=null,r=null,n=null,i=[];if(e.match(b.IDENT)&&(r=e.token().value.toLowerCase(),"only"!==r&&"not"!==r?(e.unget(),r=null):n=e.token()),this._readWhitespace(),e.peek()===b.IDENT?(t=this._media_type(),null===n&&(n=e.token())):e.peek()===b.LPAREN&&(null===n&&(n=e.LT(1)),i.push(this._media_expression())),null===t&&0===i.length)return null;for(this._readWhitespace();e.match(b.IDENT);)"and"!==e.token().value.toLowerCase()&&this._unexpectedToken(e.token()),this._readWhitespace(),i.push(this._media_expression());return new c(r,t,i,n.startLine,n.startCol)},_media_type:function(){return this._media_feature()},_media_expression:function(){var e,t=this._tokenStream,r=null,n=null;return t.mustMatch(b.LPAREN),r=this._media_feature(),this._readWhitespace(),t.match(b.COLON)&&(this._readWhitespace(),e=t.LT(1),n=this._expression()),t.mustMatch(b.RPAREN),this._readWhitespace(),new l(r,n?new a(n,e.startLine,e.startCol):null)},_media_feature:function(){var e=this._tokenStream;return this._readWhitespace(),e.mustMatch(b.IDENT),a.fromToken(e.token())},_page:function(){var e,t,r=this._tokenStream,n=null,i=null;r.mustMatch(b.PAGE_SYM),e=r.token().startLine,t=r.token().startCol,this._readWhitespace(),r.match(b.IDENT)&&(n=r.token().value,"auto"===n.toLowerCase()&&this._unexpectedToken(r.token())),r.peek()===b.COLON&&(i=this._pseudo_page()),this._readWhitespace(),this.fire({type:"startpage",id:n,pseudo:i,line:e,col:t}),this._readDeclarations(!0,!0),this.fire({type:"endpage",id:n,pseudo:i,line:e,col:t})},_margin:function(){var e,t,r=this._tokenStream,n=this._margin_sym();return!!n&&(e=r.token().startLine,t=r.token().startCol,this.fire({type:"startpagemargin",margin:n,line:e,col:t}),this._readDeclarations(!0),this.fire({type:"endpagemargin",margin:n,line:e,col:t}),!0)},_margin_sym:function(){var e=this._tokenStream;return e.match([b.TOPLEFTCORNER_SYM,b.TOPLEFT_SYM,b.TOPCENTER_SYM,b.TOPRIGHT_SYM,b.TOPRIGHTCORNER_SYM,b.BOTTOMLEFTCORNER_SYM,b.BOTTOMLEFT_SYM,b.BOTTOMCENTER_SYM,b.BOTTOMRIGHT_SYM,b.BOTTOMRIGHTCORNER_SYM,b.LEFTTOP_SYM,b.LEFTMIDDLE_SYM,b.LEFTBOTTOM_SYM,b.RIGHTTOP_SYM,b.RIGHTMIDDLE_SYM,b.RIGHTBOTTOM_SYM])?a.fromToken(e.token()):null},_pseudo_page:function(){var e=this._tokenStream;return e.mustMatch(b.COLON),e.mustMatch(b.IDENT),e.token().value},_font_face:function(){var e,t,r=this._tokenStream;r.mustMatch(b.FONT_FACE_SYM),e=r.token().startLine,t=r.token().startCol,this._readWhitespace(),this.fire({type:"startfontface",line:e,col:t}),this._readDeclarations(!0),this.fire({type:"endfontface",line:e,col:t})},_viewport:function(){var e,t,r=this._tokenStream;r.mustMatch(b.VIEWPORT_SYM),e=r.token().startLine,t=r.token().startCol,this._readWhitespace(),this.fire({type:"startviewport",line:e,col:t}),this._readDeclarations(!0),this.fire({type:"endviewport",line:e,col:t})},_document:function(){var e,t=this._tokenStream,r=[],n="";for(t.mustMatch(b.DOCUMENT_SYM),e=t.token(),/^@\-([^\-]+)\-/.test(e.value)&&(n=RegExp.$1),this._readWhitespace(),r.push(this._document_function());t.match(b.COMMA);)this._readWhitespace(),r.push(this._document_function());t.mustMatch(b.LBRACE),this._readWhitespace(),this.fire({type:"startdocument",functions:r,prefix:n,line:e.startLine,col:e.startCol});for(var i=!0;i;)switch(t.peek()){case b.PAGE_SYM:this._page();break;case b.FONT_FACE_SYM:this._font_face();break;case b.VIEWPORT_SYM:this._viewport();break;case b.MEDIA_SYM:this._media();break;case b.KEYFRAMES_SYM:this._keyframes();break;case b.DOCUMENT_SYM:this._document();break;default:i=Boolean(this._ruleset())}t.mustMatch(b.RBRACE),e=t.token(),this._readWhitespace(),this.fire({type:"enddocument",functions:r,prefix:n,line:e.startLine,col:e.startCol})},_document_function:function(){var e,t=this._tokenStream;return t.match(b.URI)?(e=t.token().value,this._readWhitespace()):e=this._function(),e},_operator:function(e){var t=this._tokenStream,r=null;return(t.match([b.SLASH,b.COMMA])||e&&t.match([b.PLUS,b.STAR,b.MINUS]))&&(r=t.token(),this._readWhitespace()),r?h.fromToken(r):null},_combinator:function(){var e,t=this._tokenStream,r=null;return t.match([b.PLUS,b.GREATER,b.TILDE])&&(e=t.token(),r=new s(e.value,e.startLine,e.startCol),this._readWhitespace()),r},_unary_operator:function(){var e=this._tokenStream;return e.match([b.MINUS,b.PLUS])?e.token().value:null},_property:function(){var e,t,r,n,i=this._tokenStream,o=null,a=null;return i.peek()===b.STAR&&this.options.starHack&&(i.get(),t=i.token(),a=t.value,r=t.startLine,n=t.startCol),i.match(b.IDENT)&&(t=i.token(),e=t.value,"_"===e.charAt(0)&&this.options.underscoreHack&&(a="_",e=e.substring(1)),o=new u(e,a,r||t.startLine,n||t.startCol),this._readWhitespace()),o},_ruleset:function(){var e,t,r=this._tokenStream;try{t=this._selectors_group()}catch(n){if(!(n instanceof o)||this.options.strict)throw n;if(this.fire({type:"error",error:n,message:n.message,line:n.line,col:n.col}),e=r.advance([b.RBRACE]),e!==b.RBRACE)throw n;return!0}return t&&(this.fire({type:"startrule",selectors:t,line:t[0].line,col:t[0].col}),this._readDeclarations(!0),this.fire({type:"endrule",selectors:t,line:t[0].line,col:t[0].col})),t},_selectors_group:function(){var e,t=this._tokenStream,r=[];if(e=this._selector(),null!==e)for(r.push(e);t.match(b.COMMA);)this._readWhitespace(),e=this._selector(),null!==e?r.push(e):this._unexpectedToken(t.LT(1));return r.length?r:null},_selector:function(){var e=this._tokenStream,t=[],r=null,n=null,i=null;if(r=this._simple_selector_sequence(),null===r)return null;for(t.push(r);;)if(n=this._combinator(),null!==n)t.push(n),r=this._simple_selector_sequence(),null===r?this._unexpectedToken(e.LT(1)):t.push(r);else{if(!this._readWhitespace())break;i=new s(e.token().value,e.token().startLine,e.token().startCol),n=this._combinator(),r=this._simple_selector_sequence(),null===r?null!==n&&this._unexpectedToken(e.LT(1)):(null!==n?t.push(n):t.push(i),t.push(r))}return new p(t,t[0].line,t[0].col)},_simple_selector_sequence:function(){var e,t,r=this._tokenStream,n=null,i=[],o="",a=[function(){return r.match(b.HASH)?new m(r.token().value,"id",r.token().startLine,r.token().startCol):null},this._class,this._attrib,this._pseudo,this._negation],s=0,l=a.length,c=null;for(e=r.LT(1).startLine,t=r.LT(1).startCol,n=this._type_selector(),n||(n=this._universal()),null!==n&&(o+=n);;){if(r.peek()===b.S)break;for(;s<l&&null===c;)c=a[s++].call(this);if(null===c){if(""===o)return null;break}s=0,i.push(c),o+=c.toString(),c=null}return""!==o?new f(n,i,o,e,t):null},_type_selector:function(){var e=this._tokenStream,t=this._namespace_prefix(),r=this._element_name();return r?(t&&(r.text=t+r.text,r.col-=t.length),r):(t&&(e.unget(),t.length>1&&e.unget()),null)},_class:function(){var e,t=this._tokenStream;return t.match(b.DOT)?(t.mustMatch(b.IDENT),e=t.token(),new m("."+e.value,"class",e.startLine,e.startCol-1)):null},_element_name:function(){var e,t=this._tokenStream;return t.match(b.IDENT)?(e=t.token(),new m(e.value,"elementName",e.startLine,e.startCol)):null},_namespace_prefix:function(){var e=this._tokenStream,t="";return e.LA(1)!==b.PIPE&&e.LA(2)!==b.PIPE||(e.match([b.IDENT,b.STAR])&&(t+=e.token().value),e.mustMatch(b.PIPE),t+="|"),t.length?t:null},_universal:function(){var e,t=this._tokenStream,r="";return e=this._namespace_prefix(),e&&(r+=e),t.match(b.STAR)&&(r+="*"),r.length?r:null},_attrib:function(){var e,t,r=this._tokenStream,n=null;return r.match(b.LBRACKET)?(t=r.token(),n=t.value,n+=this._readWhitespace(),e=this._namespace_prefix(),e&&(n+=e),r.mustMatch(b.IDENT),n+=r.token().value,n+=this._readWhitespace(),r.match([b.PREFIXMATCH,b.SUFFIXMATCH,b.SUBSTRINGMATCH,b.EQUALS,b.INCLUDES,b.DASHMATCH])&&(n+=r.token().value,n+=this._readWhitespace(),r.mustMatch([b.IDENT,b.STRING]),n+=r.token().value,n+=this._readWhitespace()),r.mustMatch(b.RBRACKET),new m(n+"]","attribute",t.startLine,t.startCol)):null},_pseudo:function(){var e,t,r=this._tokenStream,n=null,i=":";if(r.match(b.COLON)){if(r.match(b.COLON)&&(i+=":"),r.match(b.IDENT)?(n=r.token().value,e=r.token().startLine,t=r.token().startCol-i.length):r.peek()===b.FUNCTION&&(e=r.LT(1).startLine,t=r.LT(1).startCol-i.length,n=this._functional_pseudo()),!n){var a=r.LT(1).startLine,s=r.LT(0).startCol;throw new o("Expected a `FUNCTION` or `IDENT` after colon at line "+a+", col "+s+".",a,s)}n=new m(i+n,"pseudo",e,t)}return n},_functional_pseudo:function(){var e=this._tokenStream,t=null;return e.match(b.FUNCTION)&&(t=e.token().value,t+=this._readWhitespace(),t+=this._expression(),e.mustMatch(b.RPAREN),t+=")"),t},_expression:function(){for(var e=this._tokenStream,t="";e.match([b.PLUS,b.MINUS,b.DIMENSION,b.NUMBER,b.STRING,b.IDENT,b.LENGTH,b.FREQ,b.ANGLE,b.TIME,b.RESOLUTION,b.SLASH]);)t+=e.token().value,t+=this._readWhitespace();return t.length?t:null},_negation:function(){var e,t,r,n=this._tokenStream,i="",o=null;return n.match(b.NOT)&&(i=n.token().value,e=n.token().startLine,t=n.token().startCol,i+=this._readWhitespace(),r=this._negation_arg(),i+=r,i+=this._readWhitespace(),n.match(b.RPAREN),i+=n.token().value,o=new m(i,"not",e,t),o.args.push(r)),o},_negation_arg:function(){var e,t,r,n=this._tokenStream,i=[this._type_selector,this._universal,function(){return n.match(b.HASH)?new m(n.token().value,"id",n.token().startLine,n.token().startCol):null},this._class,this._attrib,this._pseudo],o=null,a=0,s=i.length;for(e=n.LT(1).startLine,t=n.LT(1).startCol;a<s&&null===o;)o=i[a].call(this),a++;return null===o&&this._unexpectedToken(n.LT(1)),r="elementName"===o.type?new f(o,[],o.toString(),e,t):new f(null,[o],o.toString(),e,t)},_declaration:function(){var e=this._tokenStream,t=null,r=null,n=null,i=null,o="";if(t=this._property(),null!==t){e.mustMatch(b.COLON),this._readWhitespace(),r=this._expr(),r&&0!==r.length||this._unexpectedToken(e.LT(1)),n=this._prio(),o=t.toString(),(this.options.starHack&&"*"===t.hack||this.options.underscoreHack&&"_"===t.hack)&&(o=t.text);try{this._validateProperty(o,r)}catch(a){i=a}return this.fire({type:"property",property:t,value:r,important:n,line:t.line,col:t.col,invalid:i}),!0}return!1},_prio:function(){var e=this._tokenStream,t=e.match(b.IMPORTANT_SYM);return this._readWhitespace(),t},_expr:function(e){var t=[],r=null,n=null;if(r=this._term(e),null!==r)for(t.push(r);;){if(n=this._operator(e),n&&t.push(n),r=this._term(e),null===r)break;t.push(r)}return t.length>0?new d(t,t[0].line,t[0].col):null},_term:function(e){var t,r,n,i=this._tokenStream,o=null,a=null,s=null,l=null;return o=this._unary_operator(),null!==o&&(r=i.token().startLine,n=i.token().startCol),i.peek()===b.IE_FUNCTION&&this.options.ieFilters?(a=this._ie_function(),null===o&&(r=i.token().startLine,n=i.token().startCol)):e&&i.match([b.LPAREN,b.LBRACE,b.LBRACKET])?(t=i.token(),s=t.endChar,a=t.value+this._expr(e).text,null===o&&(r=i.token().startLine,n=i.token().startCol),i.mustMatch(b.type(s)),a+=s,this._readWhitespace()):i.match([b.NUMBER,b.PERCENTAGE,b.LENGTH,b.ANGLE,b.TIME,b.FREQ,b.STRING,b.IDENT,b.URI,b.UNICODE_RANGE])?(a=i.token().value,null===o&&(r=i.token().startLine,n=i.token().startCol,l=h.fromToken(i.token())),this._readWhitespace()):(t=this._hexcolor(),null===t?(null===o&&(r=i.LT(1).startLine,n=i.LT(1).startCol),null===a&&(a=i.LA(3)===b.EQUALS&&this.options.ieFilters?this._ie_function():this._function())):(a=t.value,null===o&&(r=t.startLine,n=t.startCol))),null!==l?l:null!==a?new h(null!==o?o+a:a,r,n):null},_function:function(){var e,t=this._tokenStream,r=null,n=null;if(t.match(b.FUNCTION)){if(r=t.token().value,this._readWhitespace(),n=this._expr(!0),r+=n,this.options.ieFilters&&t.peek()===b.EQUALS)do for(this._readWhitespace()&&(r+=t.token().value),t.LA(0)===b.COMMA&&(r+=t.token().value),t.match(b.IDENT),r+=t.token().value,t.match(b.EQUALS),r+=t.token().value,e=t.peek();e!==b.COMMA&&e!==b.S&&e!==b.RPAREN;)t.get(),r+=t.token().value,e=t.peek();while(t.match([b.COMMA,b.S]));t.match(b.RPAREN),r+=")",this._readWhitespace()}return r},_ie_function:function(){var e,t=this._tokenStream,r=null;if(t.match([b.IE_FUNCTION,b.FUNCTION])){r=t.token().value;do for(this._readWhitespace()&&(r+=t.token().value),t.LA(0)===b.COMMA&&(r+=t.token().value),t.match(b.IDENT),r+=t.token().value,t.match(b.EQUALS),r+=t.token().value,e=t.peek();e!==b.COMMA&&e!==b.S&&e!==b.RPAREN;)t.get(),r+=t.token().value,e=t.peek();while(t.match([b.COMMA,b.S]));t.match(b.RPAREN),r+=")",this._readWhitespace()}return r},_hexcolor:function(){var e,t=this._tokenStream,r=null;if(t.match(b.HASH)){if(r=t.token(),e=r.value,!/#[a-f0-9]{3,6}/i.test(e))throw new o("Expected a hex color but found '"+e+"' at line "+r.startLine+", col "+r.startCol+".",r.startLine,r.startCol);this._readWhitespace()}return r},_keyframes:function(){var e,t,r,n=this._tokenStream,i="";for(n.mustMatch(b.KEYFRAMES_SYM),e=n.token(),/^@\-([^\-]+)\-/.test(e.value)&&(i=RegExp.$1),this._readWhitespace(),r=this._keyframe_name(),this._readWhitespace(),n.mustMatch(b.LBRACE),this.fire({type:"startkeyframes",name:r,prefix:i,line:e.startLine,col:e.startCol}),this._readWhitespace(),t=n.peek();t===b.IDENT||t===b.PERCENTAGE;)this._keyframe_rule(),this._readWhitespace(),t=n.peek();this.fire({type:"endkeyframes",name:r,prefix:i,line:e.startLine,col:e.startCol}),this._readWhitespace(),n.mustMatch(b.RBRACE),this._readWhitespace()},_keyframe_name:function(){var e=this._tokenStream;return e.mustMatch([b.IDENT,b.STRING]),a.fromToken(e.token())},_keyframe_rule:function(){var e=this._key_list();this.fire({type:"startkeyframerule",keys:e,line:e[0].line,col:e[0].col}),this._readDeclarations(!0),this.fire({type:"endkeyframerule",keys:e,line:e[0].line,col:e[0].col})},_key_list:function(){var e=this._tokenStream,t=[];for(t.push(this._key()),this._readWhitespace();e.match(b.COMMA);)this._readWhitespace(),t.push(this._key()),this._readWhitespace();return t},_key:function(){var e,t=this._tokenStream;if(t.match(b.PERCENTAGE))return a.fromToken(t.token());if(t.match(b.IDENT)){if(e=t.token(),/from|to/i.test(e.value))return a.fromToken(e);t.unget()}this._unexpectedToken(t.LT(1))},_skipCruft:function(){for(;this._tokenStream.match([b.S,b.CDO,b.CDC]););},_readDeclarations:function(e,t){var r,n=this._tokenStream;this._readWhitespace(),e&&n.mustMatch(b.LBRACE),this._readWhitespace();try{for(;;){if(n.match(b.SEMICOLON)||t&&this._margin());else{if(!this._declaration())break;if(!n.match(b.SEMICOLON))break}this._readWhitespace()}n.mustMatch(b.RBRACE),this._readWhitespace()}catch(i){if(!(i instanceof o)||this.options.strict)throw i;if(this.fire({type:"error",error:i,message:i.message,line:i.line,col:i.col}),r=n.advance([b.SEMICOLON,b.RBRACE]),r===b.SEMICOLON)this._readDeclarations(!1,t);else if(r!==b.RBRACE)throw i}},_readWhitespace:function(){for(var e=this._tokenStream,t="";e.match(b.S);)t+=e.token().value;return t},_unexpectedToken:function(e){
2
+ throw new o("Unexpected token '"+e.value+"' at line "+e.startLine+", col "+e.startCol+".",e.startLine,e.startCol)},_verifyEnd:function(){this._tokenStream.LA(1)!==b.EOF&&this._unexpectedToken(this._tokenStream.LT(1))},_validateProperty:function(e,t){k.validate(e,t)},parse:function(e){this._tokenStream=new g(e,b),this._stylesheet()},parseStyleSheet:function(e){return this.parse(e)},parseMediaQuery:function(e){this._tokenStream=new g(e,b);var t=this._media_query();return this._verifyEnd(),t},parsePropertyValue:function(e){this._tokenStream=new g(e,b),this._readWhitespace();var t=this._expr();return this._readWhitespace(),this._verifyEnd(),t},parseRule:function(e){this._tokenStream=new g(e,b),this._readWhitespace();var t=this._ruleset();return this._readWhitespace(),this._verifyEnd(),t},parseSelector:function(e){this._tokenStream=new g(e,b),this._readWhitespace();var t=this._selector();return this._readWhitespace(),this._verifyEnd(),t},parseStyleAttribute:function(e){e+="}",this._tokenStream=new g(e,b),this._readDeclarations()}};for(e in r)Object.prototype.hasOwnProperty.call(r,e)&&(t[e]=r[e]);return t}()},{"../util/EventTarget":23,"../util/SyntaxError":25,"../util/SyntaxUnit":26,"./Combinator":2,"./MediaFeature":4,"./MediaQuery":5,"./PropertyName":8,"./PropertyValue":9,"./PropertyValuePart":11,"./Selector":13,"./SelectorPart":14,"./SelectorSubPart":15,"./TokenStream":17,"./Tokens":18,"./Validation":19}],7:[function(e,t,r){"use strict";t.exports={__proto__:null,"align-items":"flex-start | flex-end | center | baseline | stretch","align-content":"flex-start | flex-end | center | space-between | space-around | stretch","align-self":"auto | flex-start | flex-end | center | baseline | stretch","-webkit-align-items":"flex-start | flex-end | center | baseline | stretch","-webkit-align-content":"flex-start | flex-end | center | space-between | space-around | stretch","-webkit-align-self":"auto | flex-start | flex-end | center | baseline | stretch","alignment-adjust":"auto | baseline | before-edge | text-before-edge | middle | central | after-edge | text-after-edge | ideographic | alphabetic | hanging | mathematical | <percentage> | <length>","alignment-baseline":"auto | baseline | use-script | before-edge | text-before-edge | after-edge | text-after-edge | central | middle | ideographic | alphabetic | hanging | mathematical",animation:1,"animation-delay":"<time>#","animation-direction":"<single-animation-direction>#","animation-duration":"<time>#","animation-fill-mode":"[ none | forwards | backwards | both ]#","animation-iteration-count":"[ <number> | infinite ]#","animation-name":"[ none | <single-animation-name> ]#","animation-play-state":"[ running | paused ]#","animation-timing-function":1,"-moz-animation-delay":"<time>#","-moz-animation-direction":"[ normal | alternate ]#","-moz-animation-duration":"<time>#","-moz-animation-iteration-count":"[ <number> | infinite ]#","-moz-animation-name":"[ none | <single-animation-name> ]#","-moz-animation-play-state":"[ running | paused ]#","-ms-animation-delay":"<time>#","-ms-animation-direction":"[ normal | alternate ]#","-ms-animation-duration":"<time>#","-ms-animation-iteration-count":"[ <number> | infinite ]#","-ms-animation-name":"[ none | <single-animation-name> ]#","-ms-animation-play-state":"[ running | paused ]#","-webkit-animation-delay":"<time>#","-webkit-animation-direction":"[ normal | alternate ]#","-webkit-animation-duration":"<time>#","-webkit-animation-fill-mode":"[ none | forwards | backwards | both ]#","-webkit-animation-iteration-count":"[ <number> | infinite ]#","-webkit-animation-name":"[ none | <single-animation-name> ]#","-webkit-animation-play-state":"[ running | paused ]#","-o-animation-delay":"<time>#","-o-animation-direction":"[ normal | alternate ]#","-o-animation-duration":"<time>#","-o-animation-iteration-count":"[ <number> | infinite ]#","-o-animation-name":"[ none | <single-animation-name> ]#","-o-animation-play-state":"[ running | paused ]#",appearance:"icon | window | desktop | workspace | document | tooltip | dialog | button | push-button | hyperlink | radio | radio-button | checkbox | menu-item | tab | menu | menubar | pull-down-menu | pop-up-menu | list-menu | radio-group | checkbox-group | outline-tree | range | field | combo-box | signature | password | normal | none",azimuth:"<azimuth>","backface-visibility":"visible | hidden",background:1,"background-attachment":"<attachment>#","background-clip":"<box>#","background-color":"<color>","background-image":"<bg-image>#","background-origin":"<box>#","background-position":"<bg-position>","background-repeat":"<repeat-style>#","background-size":"<bg-size>#","baseline-shift":"baseline | sub | super | <percentage> | <length>",behavior:1,binding:1,bleed:"<length>","bookmark-label":"<content> | <attr> | <string>","bookmark-level":"none | <integer>","bookmark-state":"open | closed","bookmark-target":"none | <uri> | <attr>",border:"<border-width> || <border-style> || <color>","border-bottom":"<border-width> || <border-style> || <color>","border-bottom-color":"<color>","border-bottom-left-radius":"<x-one-radius>","border-bottom-right-radius":"<x-one-radius>","border-bottom-style":"<border-style>","border-bottom-width":"<border-width>","border-collapse":"collapse | separate","border-color":"<color>{1,4}","border-image":1,"border-image-outset":"[ <length> | <number> ]{1,4}","border-image-repeat":"[ stretch | repeat | round ]{1,2}","border-image-slice":"<border-image-slice>","border-image-source":"<image> | none","border-image-width":"[ <length> | <percentage> | <number> | auto ]{1,4}","border-left":"<border-width> || <border-style> || <color>","border-left-color":"<color>","border-left-style":"<border-style>","border-left-width":"<border-width>","border-radius":"<border-radius>","border-right":"<border-width> || <border-style> || <color>","border-right-color":"<color>","border-right-style":"<border-style>","border-right-width":"<border-width>","border-spacing":"<length>{1,2}","border-style":"<border-style>{1,4}","border-top":"<border-width> || <border-style> || <color>","border-top-color":"<color>","border-top-left-radius":"<x-one-radius>","border-top-right-radius":"<x-one-radius>","border-top-style":"<border-style>","border-top-width":"<border-width>","border-width":"<border-width>{1,4}",bottom:"<margin-width>","-moz-box-align":"start | end | center | baseline | stretch","-moz-box-decoration-break":"slice | clone","-moz-box-direction":"normal | reverse","-moz-box-flex":"<number>","-moz-box-flex-group":"<integer>","-moz-box-lines":"single | multiple","-moz-box-ordinal-group":"<integer>","-moz-box-orient":"horizontal | vertical | inline-axis | block-axis","-moz-box-pack":"start | end | center | justify","-o-box-decoration-break":"slice | clone","-webkit-box-align":"start | end | center | baseline | stretch","-webkit-box-decoration-break":"slice | clone","-webkit-box-direction":"normal | reverse","-webkit-box-flex":"<number>","-webkit-box-flex-group":"<integer>","-webkit-box-lines":"single | multiple","-webkit-box-ordinal-group":"<integer>","-webkit-box-orient":"horizontal | vertical | inline-axis | block-axis","-webkit-box-pack":"start | end | center | justify","box-decoration-break":"slice | clone","box-shadow":"<box-shadow>","box-sizing":"content-box | border-box","break-after":"auto | always | avoid | left | right | page | column | avoid-page | avoid-column","break-before":"auto | always | avoid | left | right | page | column | avoid-page | avoid-column","break-inside":"auto | avoid | avoid-page | avoid-column","caption-side":"top | bottom",clear:"none | right | left | both",clip:"<shape> | auto","-webkit-clip-path":"<clip-source> | <clip-path> | none","clip-path":"<clip-source> | <clip-path> | none","clip-rule":"nonzero | evenodd",color:"<color>","color-interpolation":"auto | sRGB | linearRGB","color-interpolation-filters":"auto | sRGB | linearRGB","color-profile":1,"color-rendering":"auto | optimizeSpeed | optimizeQuality","column-count":"<integer> | auto","column-fill":"auto | balance","column-gap":"<length> | normal","column-rule":"<border-width> || <border-style> || <color>","column-rule-color":"<color>","column-rule-style":"<border-style>","column-rule-width":"<border-width>","column-span":"none | all","column-width":"<length> | auto",columns:1,content:1,"counter-increment":1,"counter-reset":1,crop:"<shape> | auto",cue:"cue-after | cue-before","cue-after":1,"cue-before":1,cursor:1,direction:"ltr | rtl",display:"inline | block | list-item | inline-block | table | inline-table | table-row-group | table-header-group | table-footer-group | table-row | table-column-group | table-column | table-cell | table-caption | grid | inline-grid | run-in | ruby | ruby-base | ruby-text | ruby-base-container | ruby-text-container | contents | none | -moz-box | -moz-inline-block | -moz-inline-box | -moz-inline-grid | -moz-inline-stack | -moz-inline-table | -moz-grid | -moz-grid-group | -moz-grid-line | -moz-groupbox | -moz-deck | -moz-popup | -moz-stack | -moz-marker | -webkit-box | -webkit-inline-box | -ms-flexbox | -ms-inline-flexbox | flex | -webkit-flex | inline-flex | -webkit-inline-flex","dominant-baseline":"auto | use-script | no-change | reset-size | ideographic | alphabetic | hanging | mathematical | central | middle | text-after-edge | text-before-edge","drop-initial-after-adjust":"central | middle | after-edge | text-after-edge | ideographic | alphabetic | mathematical | <percentage> | <length>","drop-initial-after-align":"baseline | use-script | before-edge | text-before-edge | after-edge | text-after-edge | central | middle | ideographic | alphabetic | hanging | mathematical","drop-initial-before-adjust":"before-edge | text-before-edge | central | middle | hanging | mathematical | <percentage> | <length>","drop-initial-before-align":"caps-height | baseline | use-script | before-edge | text-before-edge | after-edge | text-after-edge | central | middle | ideographic | alphabetic | hanging | mathematical","drop-initial-size":"auto | line | <length> | <percentage>","drop-initial-value":"<integer>",elevation:"<angle> | below | level | above | higher | lower","empty-cells":"show | hide","enable-background":1,fill:"<paint>","fill-opacity":"<opacity-value>","fill-rule":"nonzero | evenodd",filter:"<filter-function-list> | none",fit:"fill | hidden | meet | slice","fit-position":1,flex:"<flex>","flex-basis":"<width>","flex-direction":"row | row-reverse | column | column-reverse","flex-flow":"<flex-direction> || <flex-wrap>","flex-grow":"<number>","flex-shrink":"<number>","flex-wrap":"nowrap | wrap | wrap-reverse","-webkit-flex":"<flex>","-webkit-flex-basis":"<width>","-webkit-flex-direction":"row | row-reverse | column | column-reverse","-webkit-flex-flow":"<flex-direction> || <flex-wrap>","-webkit-flex-grow":"<number>","-webkit-flex-shrink":"<number>","-webkit-flex-wrap":"nowrap | wrap | wrap-reverse","-ms-flex":"<flex>","-ms-flex-align":"start | end | center | stretch | baseline","-ms-flex-direction":"row | row-reverse | column | column-reverse","-ms-flex-order":"<number>","-ms-flex-pack":"start | end | center | justify","-ms-flex-wrap":"nowrap | wrap | wrap-reverse","float":"left | right | none","float-offset":1,"flood-color":1,"flood-opacity":"<opacity-value>",font:"<font-shorthand> | caption | icon | menu | message-box | small-caption | status-bar","font-family":"<font-family>","font-feature-settings":"<feature-tag-value> | normal","font-kerning":"auto | normal | none","font-size":"<font-size>","font-size-adjust":"<number> | none","font-stretch":"<font-stretch>","font-style":"<font-style>","font-variant":"<font-variant> | normal | none","font-variant-alternates":"<font-variant-alternates> | normal","font-variant-caps":"<font-variant-caps> | normal","font-variant-east-asian":"<font-variant-east-asian> | normal","font-variant-ligatures":"<font-variant-ligatures> | normal | none","font-variant-numeric":"<font-variant-numeric> | normal","font-variant-position":"normal | sub | super","font-weight":"<font-weight>","glyph-orientation-horizontal":"<glyph-angle>","glyph-orientation-vertical":"auto | <glyph-angle>",grid:1,"grid-area":1,"grid-auto-columns":1,"grid-auto-flow":1,"grid-auto-position":1,"grid-auto-rows":1,"grid-cell-stacking":"columns | rows | layer","grid-column":1,"grid-columns":1,"grid-column-align":"start | end | center | stretch","grid-column-sizing":1,"grid-column-start":1,"grid-column-end":1,"grid-column-span":"<integer>","grid-flow":"none | rows | columns","grid-layer":"<integer>","grid-row":1,"grid-rows":1,"grid-row-align":"start | end | center | stretch","grid-row-start":1,"grid-row-end":1,"grid-row-span":"<integer>","grid-row-sizing":1,"grid-template":1,"grid-template-areas":1,"grid-template-columns":1,"grid-template-rows":1,"hanging-punctuation":1,height:"<margin-width> | <content-sizing>","hyphenate-after":"<integer> | auto","hyphenate-before":"<integer> | auto","hyphenate-character":"<string> | auto","hyphenate-lines":"no-limit | <integer>","hyphenate-resource":1,hyphens:"none | manual | auto",icon:1,"image-orientation":"angle | auto","image-rendering":"auto | optimizeSpeed | optimizeQuality","image-resolution":1,"ime-mode":"auto | normal | active | inactive | disabled","inline-box-align":"last | <integer>","justify-content":"flex-start | flex-end | center | space-between | space-around","-webkit-justify-content":"flex-start | flex-end | center | space-between | space-around",kerning:"auto | <length>",left:"<margin-width>","letter-spacing":"<length> | normal","line-height":"<line-height>","line-break":"auto | loose | normal | strict","line-stacking":1,"line-stacking-ruby":"exclude-ruby | include-ruby","line-stacking-shift":"consider-shifts | disregard-shifts","line-stacking-strategy":"inline-line-height | block-line-height | max-height | grid-height","list-style":1,"list-style-image":"<uri> | none","list-style-position":"inside | outside","list-style-type":"disc | circle | square | decimal | decimal-leading-zero | lower-roman | upper-roman | lower-greek | lower-latin | upper-latin | armenian | georgian | lower-alpha | upper-alpha | none",margin:"<margin-width>{1,4}","margin-bottom":"<margin-width>","margin-left":"<margin-width>","margin-right":"<margin-width>","margin-top":"<margin-width>",mark:1,"mark-after":1,"mark-before":1,marker:1,"marker-end":1,"marker-mid":1,"marker-start":1,marks:1,"marquee-direction":1,"marquee-play-count":1,"marquee-speed":1,"marquee-style":1,mask:1,"max-height":"<length> | <percentage> | <content-sizing> | none","max-width":"<length> | <percentage> | <content-sizing> | none","min-height":"<length> | <percentage> | <content-sizing> | contain-floats | -moz-contain-floats | -webkit-contain-floats","min-width":"<length> | <percentage> | <content-sizing> | contain-floats | -moz-contain-floats | -webkit-contain-floats","move-to":1,"nav-down":1,"nav-index":1,"nav-left":1,"nav-right":1,"nav-up":1,"object-fit":"fill | contain | cover | none | scale-down","object-position":"<position>",opacity:"<opacity-value>",order:"<integer>","-webkit-order":"<integer>",orphans:"<integer>",outline:1,"outline-color":"<color> | invert","outline-offset":1,"outline-style":"<border-style>","outline-width":"<border-width>",overflow:"visible | hidden | scroll | auto","overflow-style":1,"overflow-wrap":"normal | break-word","overflow-x":1,"overflow-y":1,padding:"<padding-width>{1,4}","padding-bottom":"<padding-width>","padding-left":"<padding-width>","padding-right":"<padding-width>","padding-top":"<padding-width>",page:1,"page-break-after":"auto | always | avoid | left | right","page-break-before":"auto | always | avoid | left | right","page-break-inside":"auto | avoid","page-policy":1,pause:1,"pause-after":1,"pause-before":1,perspective:1,"perspective-origin":1,phonemes:1,pitch:1,"pitch-range":1,"play-during":1,"pointer-events":"auto | none | visiblePainted | visibleFill | visibleStroke | visible | painted | fill | stroke | all",position:"static | relative | absolute | fixed","presentation-level":1,"punctuation-trim":1,quotes:1,"rendering-intent":1,resize:1,rest:1,"rest-after":1,"rest-before":1,richness:1,right:"<margin-width>",rotation:1,"rotation-point":1,"ruby-align":1,"ruby-overhang":1,"ruby-position":1,"ruby-span":1,"shape-rendering":"auto | optimizeSpeed | crispEdges | geometricPrecision",size:1,speak:"normal | none | spell-out","speak-header":"once | always","speak-numeral":"digits | continuous","speak-punctuation":"code | none","speech-rate":1,src:1,"stop-color":1,"stop-opacity":"<opacity-value>",stress:1,"string-set":1,stroke:"<paint>","stroke-dasharray":"none | <dasharray>","stroke-dashoffset":"<percentage> | <length>","stroke-linecap":"butt | round | square","stroke-linejoin":"miter | round | bevel","stroke-miterlimit":"<miterlimit>","stroke-opacity":"<opacity-value>","stroke-width":"<percentage> | <length>","table-layout":"auto | fixed","tab-size":"<integer> | <length>",target:1,"target-name":1,"target-new":1,"target-position":1,"text-align":"left | right | center | justify | match-parent | start | end","text-align-last":1,"text-anchor":"start | middle | end","text-decoration":"<text-decoration>","text-emphasis":1,"text-height":1,"text-indent":"<length> | <percentage>","text-justify":"auto | none | inter-word | inter-ideograph | inter-cluster | distribute | kashida","text-outline":1,"text-overflow":1,"text-rendering":"auto | optimizeSpeed | optimizeLegibility | geometricPrecision","text-shadow":1,"text-transform":"capitalize | uppercase | lowercase | none","text-wrap":"normal | none | avoid",top:"<margin-width>","-ms-touch-action":"auto | none | pan-x | pan-y | pan-left | pan-right | pan-up | pan-down | manipulation","touch-action":"auto | none | pan-x | pan-y | pan-left | pan-right | pan-up | pan-down | manipulation",transform:1,"transform-origin":1,"transform-style":1,transition:1,"transition-delay":1,"transition-duration":1,"transition-property":1,"transition-timing-function":1,"unicode-bidi":"normal | embed | isolate | bidi-override | isolate-override | plaintext","user-modify":"read-only | read-write | write-only","user-select":"none | text | toggle | element | elements | all","vertical-align":"auto | use-script | baseline | sub | super | top | text-top | central | middle | bottom | text-bottom | <percentage> | <length>",visibility:"visible | hidden | collapse","voice-balance":1,"voice-duration":1,"voice-family":1,"voice-pitch":1,"voice-pitch-range":1,"voice-rate":1,"voice-stress":1,"voice-volume":1,volume:1,"white-space":"normal | pre | nowrap | pre-wrap | pre-line | -pre-wrap | -o-pre-wrap | -moz-pre-wrap | -hp-pre-wrap","white-space-collapse":1,widows:"<integer>",width:"<length> | <percentage> | <content-sizing> | auto","will-change":"<will-change>","word-break":"normal | keep-all | break-all","word-spacing":"<length> | normal","word-wrap":"normal | break-word","writing-mode":"horizontal-tb | vertical-rl | vertical-lr | lr-tb | rl-tb | tb-rl | bt-rl | tb-lr | bt-lr | lr-bt | rl-bt | lr | rl | tb","z-index":"<integer> | auto",zoom:"<number> | <percentage> | normal"}},{}],8:[function(e,t,r){"use strict";function n(e,t,r,n){i.call(this,e,r,n,o.PROPERTY_NAME_TYPE),this.hack=t}t.exports=n;var i=e("../util/SyntaxUnit"),o=e("./Parser");n.prototype=new i,n.prototype.constructor=n,n.prototype.toString=function(){return(this.hack?this.hack:"")+this.text}},{"../util/SyntaxUnit":26,"./Parser":6}],9:[function(e,t,r){"use strict";function n(e,t,r){i.call(this,e.join(" "),t,r,o.PROPERTY_VALUE_TYPE),this.parts=e}t.exports=n;var i=e("../util/SyntaxUnit"),o=e("./Parser");n.prototype=new i,n.prototype.constructor=n},{"../util/SyntaxUnit":26,"./Parser":6}],10:[function(e,t,r){"use strict";function n(e){this._i=0,this._parts=e.parts,this._marks=[],this.value=e}t.exports=n,n.prototype.count=function(){return this._parts.length},n.prototype.isFirst=function(){return 0===this._i},n.prototype.hasNext=function(){return this._i<this._parts.length},n.prototype.mark=function(){this._marks.push(this._i)},n.prototype.peek=function(e){return this.hasNext()?this._parts[this._i+(e||0)]:null},n.prototype.next=function(){return this.hasNext()?this._parts[this._i++]:null},n.prototype.previous=function(){return this._i>0?this._parts[--this._i]:null},n.prototype.restore=function(){this._marks.length&&(this._i=this._marks.pop())},n.prototype.drop=function(){this._marks.pop()}},{}],11:[function(e,t,r){"use strict";function n(e,t,r,s){var l=s||{};i.call(this,e,t,r,a.PROPERTY_VALUE_PART_TYPE),this.type="unknown";var c;if(/^([+\-]?[\d\.]+)([a-z]+)$/i.test(e))switch(this.type="dimension",this.value=+RegExp.$1,this.units=RegExp.$2,this.units.toLowerCase()){case"em":case"rem":case"ex":case"px":case"cm":case"mm":case"in":case"pt":case"pc":case"ch":case"vh":case"vw":case"vmax":case"vmin":this.type="length";break;case"fr":this.type="grid";break;case"deg":case"rad":case"grad":this.type="angle";break;case"ms":case"s":this.type="time";break;case"hz":case"khz":this.type="frequency";break;case"dpi":case"dpcm":this.type="resolution"}else/^([+\-]?[\d\.]+)%$/i.test(e)?(this.type="percentage",this.value=+RegExp.$1):/^([+\-]?\d+)$/i.test(e)?(this.type="integer",this.value=+RegExp.$1):/^([+\-]?[\d\.]+)$/i.test(e)?(this.type="number",this.value=+RegExp.$1):/^#([a-f0-9]{3,6})/i.test(e)?(this.type="color",c=RegExp.$1,3===c.length?(this.red=parseInt(c.charAt(0)+c.charAt(0),16),this.green=parseInt(c.charAt(1)+c.charAt(1),16),this.blue=parseInt(c.charAt(2)+c.charAt(2),16)):(this.red=parseInt(c.substring(0,2),16),this.green=parseInt(c.substring(2,4),16),this.blue=parseInt(c.substring(4,6),16))):/^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/i.test(e)?(this.type="color",this.red=+RegExp.$1,this.green=+RegExp.$2,this.blue=+RegExp.$3):/^rgb\(\s*(\d+)%\s*,\s*(\d+)%\s*,\s*(\d+)%\s*\)/i.test(e)?(this.type="color",this.red=255*+RegExp.$1/100,this.green=255*+RegExp.$2/100,this.blue=255*+RegExp.$3/100):/^rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*([\d\.]+)\s*\)/i.test(e)?(this.type="color",this.red=+RegExp.$1,this.green=+RegExp.$2,this.blue=+RegExp.$3,this.alpha=+RegExp.$4):/^rgba\(\s*(\d+)%\s*,\s*(\d+)%\s*,\s*(\d+)%\s*,\s*([\d\.]+)\s*\)/i.test(e)?(this.type="color",this.red=255*+RegExp.$1/100,this.green=255*+RegExp.$2/100,this.blue=255*+RegExp.$3/100,this.alpha=+RegExp.$4):/^hsl\(\s*(\d+)\s*,\s*(\d+)%\s*,\s*(\d+)%\s*\)/i.test(e)?(this.type="color",this.hue=+RegExp.$1,this.saturation=+RegExp.$2/100,this.lightness=+RegExp.$3/100):/^hsla\(\s*(\d+)\s*,\s*(\d+)%\s*,\s*(\d+)%\s*,\s*([\d\.]+)\s*\)/i.test(e)?(this.type="color",this.hue=+RegExp.$1,this.saturation=+RegExp.$2/100,this.lightness=+RegExp.$3/100,this.alpha=+RegExp.$4):/^url\(("([^\\"]|\\.)*")\)/i.test(e)?(this.type="uri",this.uri=n.parseString(RegExp.$1)):/^([^\(]+)\(/i.test(e)?(this.type="function",this.name=RegExp.$1,this.value=e):/^"([^\n\r\f\\"]|\\\r\n|\\[^\r0-9a-f]|\\[0-9a-f]{1,6}(\r\n|[ \n\r\t\f])?)*"/i.test(e)?(this.type="string",this.value=n.parseString(e)):/^'([^\n\r\f\\']|\\\r\n|\\[^\r0-9a-f]|\\[0-9a-f]{1,6}(\r\n|[ \n\r\t\f])?)*'/i.test(e)?(this.type="string",this.value=n.parseString(e)):o[e.toLowerCase()]?(this.type="color",c=o[e.toLowerCase()].substring(1),this.red=parseInt(c.substring(0,2),16),this.green=parseInt(c.substring(2,4),16),this.blue=parseInt(c.substring(4,6),16)):/^[,\/]$/.test(e)?(this.type="operator",this.value=e):/^-?[a-z_\u00A0-\uFFFF][a-z0-9\-_\u00A0-\uFFFF]*$/i.test(e)&&(this.type="identifier",this.value=e);this.wasIdent=Boolean(l.ident)}t.exports=n;var i=e("../util/SyntaxUnit"),o=e("./Colors"),a=e("./Parser"),s=e("./Tokens");n.prototype=new i,n.prototype.constructor=n,n.parseString=function(e){e=e.slice(1,-1);var t=function(e,t){if(/^(\n|\r\n|\r|\f)$/.test(t))return"";var r=/^[0-9a-f]{1,6}/i.exec(t);if(r){var n=parseInt(r[0],16);return String.fromCodePoint?String.fromCodePoint(n):String.fromCharCode(n)}return t};return e.replace(/\\(\r\n|[^\r0-9a-f]|[0-9a-f]{1,6}(\r\n|[ \n\r\t\f])?)/gi,t)},n.serializeString=function(e){var t=function(e,t){if('"'===t)return"\\"+t;var r=String.codePointAt?String.codePointAt(0):String.charCodeAt(0);return"\\"+r.toString(16)+" "};return'"'+e.replace(/["\r\n\f]/g,t)+'"'},n.fromToken=function(e){var t=new n(e.value,e.startLine,e.startCol,{ident:e.type===s.IDENT});return t}},{"../util/SyntaxUnit":26,"./Colors":1,"./Parser":6,"./Tokens":18}],12:[function(e,t,r){"use strict";var n=t.exports={__proto__:null,":first-letter":1,":first-line":1,":before":1,":after":1};n.ELEMENT=1,n.CLASS=2,n.isElement=function(e){return 0===e.indexOf("::")||n[e.toLowerCase()]===n.ELEMENT}},{}],13:[function(e,t,r){"use strict";function n(e,t,r){i.call(this,e.join(" "),t,r,o.SELECTOR_TYPE),this.parts=e,this.specificity=a.calculate(this)}t.exports=n;var i=e("../util/SyntaxUnit"),o=e("./Parser"),a=e("./Specificity");n.prototype=new i,n.prototype.constructor=n},{"../util/SyntaxUnit":26,"./Parser":6,"./Specificity":16}],14:[function(e,t,r){"use strict";function n(e,t,r,n,a){i.call(this,r,n,a,o.SELECTOR_PART_TYPE),this.elementName=e,this.modifiers=t}t.exports=n;var i=e("../util/SyntaxUnit"),o=e("./Parser");n.prototype=new i,n.prototype.constructor=n},{"../util/SyntaxUnit":26,"./Parser":6}],15:[function(e,t,r){"use strict";function n(e,t,r,n){i.call(this,e,r,n,o.SELECTOR_SUB_PART_TYPE),this.type=t,this.args=[]}t.exports=n;var i=e("../util/SyntaxUnit"),o=e("./Parser");n.prototype=new i,n.prototype.constructor=n},{"../util/SyntaxUnit":26,"./Parser":6}],16:[function(e,t,r){"use strict";function n(e,t,r,n){this.a=e,this.b=t,this.c=r,this.d=n}t.exports=n;var i=e("./Pseudos"),o=e("./SelectorPart");n.prototype={constructor:n,compare:function(e){var t,r,n=["a","b","c","d"];for(t=0,r=n.length;t<r;t++){if(this[n[t]]<e[n[t]])return-1;if(this[n[t]]>e[n[t]])return 1}return 0},valueOf:function(){return 1e3*this.a+100*this.b+10*this.c+this.d},toString:function(){return this.a+","+this.b+","+this.c+","+this.d}},n.calculate=function(e){function t(e){var r,n,o,a,s,d=e.elementName?e.elementName.text:"";for(d&&"*"!==d.charAt(d.length-1)&&u++,r=0,o=e.modifiers.length;r<o;r++)switch(s=e.modifiers[r],s.type){case"class":case"attribute":c++;break;case"id":l++;break;case"pseudo":i.isElement(s.text)?u++:c++;break;case"not":for(n=0,a=s.args.length;n<a;n++)t(s.args[n])}}var r,a,s,l=0,c=0,u=0;for(r=0,a=e.parts.length;r<a;r++)s=e.parts[r],s instanceof o&&t(s);return new n(0,l,c,u)}},{"./Pseudos":12,"./SelectorPart":14}],17:[function(e,t,r){"use strict";function n(e){return null!==e&&m.test(e)}function i(e){return null!==e&&/\d/.test(e)}function o(e){return null!==e&&k.test(e)}function a(e){return null!==e&&b.test(e)}function s(e){return null!==e&&/[a-z_\u00A0-\uFFFF\\]/i.test(e)}function l(e){return null!==e&&(s(e)||/[0-9\-\\]/.test(e))}function c(e){return null!==e&&(s(e)||/\-\\/.test(e))}function u(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e}function d(e){h.call(this,e,f)}t.exports=d;var h=e("../util/TokenStreamBase"),p=e("./PropertyValuePart"),f=e("./Tokens"),m=/^[0-9a-fA-F]$/,g=/^[\u00A0-\uFFFF]$/,b=/\n|\r\n|\r|\f/,k=/\u0009|\u000a|\u000c|\u000d|\u0020/;d.prototype=u(new h,{_getToken:function(){var e,t=this._reader,r=null,n=t.getLine(),a=t.getCol();for(e=t.read();e;){switch(e){case"/":r="*"===t.peek()?this.commentToken(e,n,a):this.charToken(e,n,a);break;case"|":case"~":case"^":case"$":case"*":r="="===t.peek()?this.comparisonToken(e,n,a):this.charToken(e,n,a);break;case'"':case"'":r=this.stringToken(e,n,a);break;case"#":r=l(t.peek())?this.hashToken(e,n,a):this.charToken(e,n,a);break;case".":r=i(t.peek())?this.numberToken(e,n,a):this.charToken(e,n,a);break;case"-":r="-"===t.peek()?this.htmlCommentEndToken(e,n,a):s(t.peek())?this.identOrFunctionToken(e,n,a):this.charToken(e,n,a);break;case"!":r=this.importantToken(e,n,a);break;case"@":r=this.atRuleToken(e,n,a);break;case":":r=this.notToken(e,n,a);break;case"<":r=this.htmlCommentStartToken(e,n,a);break;case"\\":r=/[^\r\n\f]/.test(t.peek())?this.identOrFunctionToken(this.readEscape(e,!0),n,a):this.charToken(e,n,a);break;case"U":case"u":if("+"===t.peek()){r=this.unicodeRangeToken(e,n,a);break}default:r=i(e)?this.numberToken(e,n,a):o(e)?this.whitespaceToken(e,n,a):c(e)?this.identOrFunctionToken(e,n,a):this.charToken(e,n,a)}break}return r||null!==e||(r=this.createToken(f.EOF,null,n,a)),r},createToken:function(e,t,r,n,i){var o=this._reader;return i=i||{},{value:t,type:e,channel:i.channel,endChar:i.endChar,hide:i.hide||!1,startLine:r,startCol:n,endLine:o.getLine(),endCol:o.getCol()}},atRuleToken:function(e,t,r){var n,i=e,o=this._reader,a=f.CHAR;return o.mark(),n=this.readName(),i=e+n,a=f.type(i.toLowerCase()),a!==f.CHAR&&a!==f.UNKNOWN||(i.length>1?a=f.UNKNOWN_SYM:(a=f.CHAR,i=e,o.reset())),this.createToken(a,i,t,r)},charToken:function(e,t,r){var n=f.type(e),i={};return n===-1?n=f.CHAR:i.endChar=f[n].endChar,this.createToken(n,e,t,r,i)},commentToken:function(e,t,r){var n=this.readComment(e);return this.createToken(f.COMMENT,n,t,r)},comparisonToken:function(e,t,r){var n=this._reader,i=e+n.read(),o=f.type(i)||f.CHAR;return this.createToken(o,i,t,r)},hashToken:function(e,t,r){var n=this.readName(e);return this.createToken(f.HASH,n,t,r)},htmlCommentStartToken:function(e,t,r){var n=this._reader,i=e;return n.mark(),i+=n.readCount(3),"<!--"===i?this.createToken(f.CDO,i,t,r):(n.reset(),this.charToken(e,t,r))},htmlCommentEndToken:function(e,t,r){var n=this._reader,i=e;return n.mark(),i+=n.readCount(2),"-->"===i?this.createToken(f.CDC,i,t,r):(n.reset(),this.charToken(e,t,r))},identOrFunctionToken:function(e,t,r){var n,i=this._reader,o=this.readName(e),a=f.IDENT,s=["url(","url-prefix(","domain("];return"("===i.peek()?(o+=i.read(),s.indexOf(o.toLowerCase())>-1?(i.mark(),n=this.readURI(o),null===n?(i.reset(),a=f.FUNCTION):(a=f.URI,o=n)):a=f.FUNCTION):":"===i.peek()&&"progid"===o.toLowerCase()&&(o+=i.readTo("("),a=f.IE_FUNCTION),this.createToken(a,o,t,r)},importantToken:function(e,t,r){var n,i,a=this._reader,s=e,l=f.CHAR;for(a.mark(),i=a.read();i;){if("/"===i){if("*"!==a.peek())break;if(n=this.readComment(i),""===n)break}else{if(!o(i)){if(/i/i.test(i)){n=a.readCount(8),/mportant/i.test(n)&&(s+=i+n,l=f.IMPORTANT_SYM);break}break}s+=i+this.readWhitespace()}i=a.read()}return l===f.CHAR?(a.reset(),this.charToken(e,t,r)):this.createToken(l,s,t,r)},notToken:function(e,t,r){var n=this._reader,i=e;return n.mark(),i+=n.readCount(4),":not("===i.toLowerCase()?this.createToken(f.NOT,i,t,r):(n.reset(),this.charToken(e,t,r))},numberToken:function(e,t,r){var n,i=this._reader,o=this.readNumber(e),a=f.NUMBER,s=i.peek();return c(s)?(n=this.readName(i.read()),o+=n,a=/^em$|^ex$|^px$|^gd$|^rem$|^vw$|^vh$|^vmax$|^vmin$|^ch$|^cm$|^mm$|^in$|^pt$|^pc$/i.test(n)?f.LENGTH:/^deg|^rad$|^grad$/i.test(n)?f.ANGLE:/^ms$|^s$/i.test(n)?f.TIME:/^hz$|^khz$/i.test(n)?f.FREQ:/^dpi$|^dpcm$/i.test(n)?f.RESOLUTION:f.DIMENSION):"%"===s&&(o+=i.read(),a=f.PERCENTAGE),this.createToken(a,o,t,r)},stringToken:function(e,t,r){for(var i,s=e,l=e,c=this._reader,u=f.STRING,d=c.read();d;){if(l+=d,"\\"===d){if(d=c.read(),null===d)break;if(/[^\r\n\f0-9a-f]/i.test(d))l+=d;else{for(i=0;n(d)&&i<6;i++)l+=d,d=c.read();if("\r"===d&&"\n"===c.peek()&&(l+=d,d=c.read()),!o(d))continue;l+=d}}else{if(d===s)break;if(a(c.peek())){u=f.INVALID;break}}d=c.read()}return null===d&&(u=f.INVALID),this.createToken(u,l,t,r)},unicodeRangeToken:function(e,t,r){var n,i=this._reader,o=e,a=f.CHAR;return"+"===i.peek()&&(i.mark(),o+=i.read(),o+=this.readUnicodeRangePart(!0),2===o.length?i.reset():(a=f.UNICODE_RANGE,o.indexOf("?")===-1&&"-"===i.peek()&&(i.mark(),n=i.read(),n+=this.readUnicodeRangePart(!1),1===n.length?i.reset():o+=n))),this.createToken(a,o,t,r)},whitespaceToken:function(e,t,r){var n=e+this.readWhitespace();return this.createToken(f.S,n,t,r)},readUnicodeRangePart:function(e){for(var t=this._reader,r="",i=t.peek();n(i)&&r.length<6;)t.read(),r+=i,i=t.peek();if(e)for(;"?"===i&&r.length<6;)t.read(),r+=i,i=t.peek();return r},readWhitespace:function(){for(var e=this._reader,t="",r=e.peek();o(r);)e.read(),t+=r,r=e.peek();return t},readNumber:function(e){for(var t=this._reader,r=e,n="."===e,o=t.peek();o;){
3
+ if(i(o))r+=t.read();else{if("."!==o)break;if(n)break;n=!0,r+=t.read()}o=t.peek()}return r},readString:function(){var e=this.stringToken(this._reader.read(),0,0);return e.type===f.INVALID?null:e.value},readURI:function(e){for(var t=this._reader,r=e,n="",i=t.peek();i&&o(i);)t.read(),i=t.peek();for("'"===i||'"'===i?(n=this.readString(),null!==n&&(n=p.parseString(n))):n=this.readUnquotedURL(),i=t.peek();i&&o(i);)t.read(),i=t.peek();return null===n||")"!==i?r=null:r+=p.serializeString(n)+t.read(),r},readUnquotedURL:function(e){var t,r=this._reader,n=e||"";for(t=r.peek();t;t=r.peek())if(g.test(t)||/^[\-!#$%&*-\[\]-~]$/.test(t))n+=t,r.read();else{if("\\"!==t)break;if(!/^[^\r\n\f]$/.test(r.peek(2)))break;n+=this.readEscape(r.read(),!0)}return n},readName:function(e){var t,r=this._reader,n=e||"";for(t=r.peek();t;t=r.peek())if("\\"===t){if(!/^[^\r\n\f]$/.test(r.peek(2)))break;n+=this.readEscape(r.read(),!0)}else{if(!l(t))break;n+=r.read()}return n},readEscape:function(e,t){var r=this._reader,i=e||"",o=0,a=r.peek();if(n(a))do i+=r.read(),a=r.peek();while(a&&n(a)&&++o<6);if(1===i.length){if(!/^[^\r\n\f0-9a-f]$/.test(a))throw new Error("Bad escape sequence.");if(r.read(),t)return a}else"\r"===a?(r.read(),"\n"===r.peek()&&(a+=r.read())):/^[ \t\n\f]$/.test(a)?r.read():a="";if(t){var s=parseInt(i.slice(e.length),16);return String.fromCodePoint?String.fromCodePoint(s):String.fromCharCode(s)}return i+a},readComment:function(e){var t=this._reader,r=e||"",n=t.read();if("*"===n){for(;n;){if(r+=n,r.length>2&&"*"===n&&"/"===t.peek()){r+=t.read();break}n=t.read()}return r}return""}})},{"../util/TokenStreamBase":27,"./PropertyValuePart":11,"./Tokens":18}],18:[function(e,t,r){"use strict";var n=t.exports=[{name:"CDO"},{name:"CDC"},{name:"S",whitespace:!0},{name:"COMMENT",comment:!0,hide:!0,channel:"comment"},{name:"INCLUDES",text:"~="},{name:"DASHMATCH",text:"|="},{name:"PREFIXMATCH",text:"^="},{name:"SUFFIXMATCH",text:"$="},{name:"SUBSTRINGMATCH",text:"*="},{name:"STRING"},{name:"IDENT"},{name:"HASH"},{name:"IMPORT_SYM",text:"@import"},{name:"PAGE_SYM",text:"@page"},{name:"MEDIA_SYM",text:"@media"},{name:"FONT_FACE_SYM",text:"@font-face"},{name:"CHARSET_SYM",text:"@charset"},{name:"NAMESPACE_SYM",text:"@namespace"},{name:"SUPPORTS_SYM",text:"@supports"},{name:"VIEWPORT_SYM",text:["@viewport","@-ms-viewport","@-o-viewport"]},{name:"DOCUMENT_SYM",text:["@document","@-moz-document"]},{name:"UNKNOWN_SYM"},{name:"KEYFRAMES_SYM",text:["@keyframes","@-webkit-keyframes","@-moz-keyframes","@-o-keyframes"]},{name:"IMPORTANT_SYM"},{name:"LENGTH"},{name:"ANGLE"},{name:"TIME"},{name:"FREQ"},{name:"DIMENSION"},{name:"PERCENTAGE"},{name:"NUMBER"},{name:"URI"},{name:"FUNCTION"},{name:"UNICODE_RANGE"},{name:"INVALID"},{name:"PLUS",text:"+"},{name:"GREATER",text:">"},{name:"COMMA",text:","},{name:"TILDE",text:"~"},{name:"NOT"},{name:"TOPLEFTCORNER_SYM",text:"@top-left-corner"},{name:"TOPLEFT_SYM",text:"@top-left"},{name:"TOPCENTER_SYM",text:"@top-center"},{name:"TOPRIGHT_SYM",text:"@top-right"},{name:"TOPRIGHTCORNER_SYM",text:"@top-right-corner"},{name:"BOTTOMLEFTCORNER_SYM",text:"@bottom-left-corner"},{name:"BOTTOMLEFT_SYM",text:"@bottom-left"},{name:"BOTTOMCENTER_SYM",text:"@bottom-center"},{name:"BOTTOMRIGHT_SYM",text:"@bottom-right"},{name:"BOTTOMRIGHTCORNER_SYM",text:"@bottom-right-corner"},{name:"LEFTTOP_SYM",text:"@left-top"},{name:"LEFTMIDDLE_SYM",text:"@left-middle"},{name:"LEFTBOTTOM_SYM",text:"@left-bottom"},{name:"RIGHTTOP_SYM",text:"@right-top"},{name:"RIGHTMIDDLE_SYM",text:"@right-middle"},{name:"RIGHTBOTTOM_SYM",text:"@right-bottom"},{name:"RESOLUTION",state:"media"},{name:"IE_FUNCTION"},{name:"CHAR"},{name:"PIPE",text:"|"},{name:"SLASH",text:"/"},{name:"MINUS",text:"-"},{name:"STAR",text:"*"},{name:"LBRACE",endChar:"}",text:"{"},{name:"RBRACE",text:"}"},{name:"LBRACKET",endChar:"]",text:"["},{name:"RBRACKET",text:"]"},{name:"EQUALS",text:"="},{name:"COLON",text:":"},{name:"SEMICOLON",text:";"},{name:"LPAREN",endChar:")",text:"("},{name:"RPAREN",text:")"},{name:"DOT",text:"."}];!function(){var e=[],t=Object.create(null);n.UNKNOWN=-1,n.unshift({name:"EOF"});for(var r=0,i=n.length;r<i;r++)if(e.push(n[r].name),n[n[r].name]=r,n[r].text)if(n[r].text instanceof Array)for(var o=0;o<n[r].text.length;o++)t[n[r].text[o]]=r;else t[n[r].text]=r;n.name=function(t){return e[t]},n.type=function(e){return t[e]||-1}}()},{}],19:[function(e,t,r){"use strict";var n=e("./Matcher"),i=e("./Properties"),o=e("./ValidationTypes"),a=e("./ValidationError"),s=e("./PropertyValueIterator");t.exports={validate:function(e,t){var r,n=e.toString().toLowerCase(),l=new s(t),c=i[n];if(c){if("number"!=typeof c){if(o.isAny(l,"inherit | initial | unset")){if(l.hasNext())throw r=l.next(),new a("Expected end of value but found '"+r+"'.",r.line,r.col);return}this.singleProperty(c,l)}}else if(0!==n.indexOf("-"))throw new a("Unknown property '"+e+"'.",e.line,e.col)},singleProperty:function(e,t){var r,i=!1,s=t.value;if(i=n.parse(e).match(t),!i)throw t.hasNext()&&!t.isFirst()?(r=t.peek(),new a("Expected end of value but found '"+r+"'.",r.line,r.col)):new a("Expected ("+o.describe(e)+") but found '"+s+"'.",s.line,s.col);if(t.hasNext())throw r=t.next(),new a("Expected end of value but found '"+r+"'.",r.line,r.col)}}},{"./Matcher":3,"./Properties":7,"./PropertyValueIterator":10,"./ValidationError":20,"./ValidationTypes":21}],20:[function(e,t,r){"use strict";function n(e,t,r){this.col=r,this.line=t,this.message=e}t.exports=n,n.prototype=new Error},{}],21:[function(e,t,r){"use strict";function n(e,t){Object.keys(t).forEach(function(r){e[r]=t[r]})}var i=t.exports,o=e("./Matcher");n(i,{isLiteral:function(e,t){var r,n,i=e.text.toString().toLowerCase(),o=t.split(" | "),a=!1;for(r=0,n=o.length;r<n&&!a;r++)"<"===o[r].charAt(0)?a=this.simple[o[r]](e):"()"===o[r].slice(-2)?a="function"===e.type&&e.name===o[r].slice(0,-2):i===o[r].toLowerCase()&&(a=!0);return a},isSimple:function(e){return Boolean(this.simple[e])},isComplex:function(e){return Boolean(this.complex[e])},describe:function(e){return this.complex[e]instanceof o?this.complex[e].toString(0):e},isAny:function(e,t){var r,n,i=t.split(" | "),o=!1;for(r=0,n=i.length;r<n&&!o&&e.hasNext();r++)o=this.isType(e,i[r]);return o},isAnyOfGroup:function(e,t){var r,n,i=t.split(" || "),o=!1;for(r=0,n=i.length;r<n&&!o;r++)o=this.isType(e,i[r]);return!!o&&i[r-1]},isType:function(e,t){var r=e.peek(),n=!1;return"<"!==t.charAt(0)?(n=this.isLiteral(r,t),n&&e.next()):this.simple[t]?(n=this.simple[t](r),n&&e.next()):n=this.complex[t]instanceof o?this.complex[t].match(e):this.complex[t](e),n},simple:{__proto__:null,"<absolute-size>":"xx-small | x-small | small | medium | large | x-large | xx-large","<animateable-feature>":"scroll-position | contents | <animateable-feature-name>","<animateable-feature-name>":function(e){return this["<ident>"](e)&&!/^(unset|initial|inherit|will-change|auto|scroll-position|contents)$/i.test(e)},"<angle>":function(e){return"angle"===e.type},"<attachment>":"scroll | fixed | local","<attr>":"attr()","<basic-shape>":"inset() | circle() | ellipse() | polygon()","<bg-image>":"<image> | <gradient> | none","<border-style>":"none | hidden | dotted | dashed | solid | double | groove | ridge | inset | outset","<border-width>":"<length> | thin | medium | thick","<box>":"padding-box | border-box | content-box","<clip-source>":"<uri>","<color>":function(e){return"color"===e.type||"transparent"===String(e)||"currentColor"===String(e)},"<color-svg>":function(e){return"color"===e.type},"<content>":"content()","<content-sizing>":"fill-available | -moz-available | -webkit-fill-available | max-content | -moz-max-content | -webkit-max-content | min-content | -moz-min-content | -webkit-min-content | fit-content | -moz-fit-content | -webkit-fit-content","<feature-tag-value>":function(e){return"function"===e.type&&/^[A-Z0-9]{4}$/i.test(e)},"<filter-function>":"blur() | brightness() | contrast() | custom() | drop-shadow() | grayscale() | hue-rotate() | invert() | opacity() | saturate() | sepia()","<flex-basis>":"<width>","<flex-direction>":"row | row-reverse | column | column-reverse","<flex-grow>":"<number>","<flex-shrink>":"<number>","<flex-wrap>":"nowrap | wrap | wrap-reverse","<font-size>":"<absolute-size> | <relative-size> | <length> | <percentage>","<font-stretch>":"normal | ultra-condensed | extra-condensed | condensed | semi-condensed | semi-expanded | expanded | extra-expanded | ultra-expanded","<font-style>":"normal | italic | oblique","<font-variant-caps>":"small-caps | all-small-caps | petite-caps | all-petite-caps | unicase | titling-caps","<font-variant-css21>":"normal | small-caps","<font-weight>":"normal | bold | bolder | lighter | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900","<generic-family>":"serif | sans-serif | cursive | fantasy | monospace","<geometry-box>":"<shape-box> | fill-box | stroke-box | view-box","<glyph-angle>":function(e){return"angle"===e.type&&"deg"===e.units},"<gradient>":function(e){return"function"===e.type&&/^(?:\-(?:ms|moz|o|webkit)\-)?(?:repeating\-)?(?:radial\-|linear\-)?gradient/i.test(e)},"<icccolor>":"cielab() | cielch() | cielchab() | icc-color() | icc-named-color()","<ident>":function(e){return"identifier"===e.type||e.wasIdent},"<ident-not-generic-family>":function(e){return this["<ident>"](e)&&!this["<generic-family>"](e)},"<image>":"<uri>","<integer>":function(e){return"integer"===e.type},"<length>":function(e){return!("function"!==e.type||!/^(?:\-(?:ms|moz|o|webkit)\-)?calc/i.test(e))||("length"===e.type||"number"===e.type||"integer"===e.type||"0"===String(e))},"<line>":function(e){return"integer"===e.type},"<line-height>":"<number> | <length> | <percentage> | normal","<margin-width>":"<length> | <percentage> | auto","<miterlimit>":function(e){return this["<number>"](e)&&e.value>=1},"<nonnegative-length-or-percentage>":function(e){return(this["<length>"](e)||this["<percentage>"](e))&&("0"===String(e)||"function"===e.type||e.value>=0)},"<nonnegative-number-or-percentage>":function(e){return(this["<number>"](e)||this["<percentage>"](e))&&("0"===String(e)||"function"===e.type||e.value>=0)},"<number>":function(e){return"number"===e.type||this["<integer>"](e)},"<opacity-value>":function(e){return this["<number>"](e)&&e.value>=0&&e.value<=1},"<padding-width>":"<nonnegative-length-or-percentage>","<percentage>":function(e){return"percentage"===e.type||"0"===String(e)},"<relative-size>":"smaller | larger","<shape>":"rect() | inset-rect()","<shape-box>":"<box> | margin-box","<single-animation-direction>":"normal | reverse | alternate | alternate-reverse","<single-animation-name>":function(e){return this["<ident>"](e)&&/^-?[a-z_][-a-z0-9_]+$/i.test(e)&&!/^(none|unset|initial|inherit)$/i.test(e)},"<string>":function(e){return"string"===e.type},"<time>":function(e){return"time"===e.type},"<uri>":function(e){return"uri"===e.type},"<width>":"<margin-width>"},complex:{__proto__:null,"<azimuth>":"<angle> | [ [ left-side | far-left | left | center-left | center | center-right | right | far-right | right-side ] || behind ] | leftwards | rightwards","<bg-position>":"<position>#","<bg-size>":"[ <length> | <percentage> | auto ]{1,2} | cover | contain","<border-image-slice>":o.many([!0],o.cast("<nonnegative-number-or-percentage>"),o.cast("<nonnegative-number-or-percentage>"),o.cast("<nonnegative-number-or-percentage>"),o.cast("<nonnegative-number-or-percentage>"),"fill"),"<border-radius>":"<nonnegative-length-or-percentage>{1,4} [ / <nonnegative-length-or-percentage>{1,4} ]?","<box-shadow>":"none | <shadow>#","<clip-path>":"<basic-shape> || <geometry-box>","<dasharray>":o.cast("<nonnegative-length-or-percentage>").braces(1,1/0,"#",o.cast(",").question()),"<family-name>":"<string> | <ident-not-generic-family> <ident>*","<filter-function-list>":"[ <filter-function> | <uri> ]+","<flex>":"none | [ <flex-grow> <flex-shrink>? || <flex-basis> ]","<font-family>":"[ <generic-family> | <family-name> ]#","<font-shorthand>":"[ <font-style> || <font-variant-css21> || <font-weight> || <font-stretch> ]? <font-size> [ / <line-height> ]? <font-family>","<font-variant-alternates>":"stylistic() || historical-forms || styleset() || character-variant() || swash() || ornaments() || annotation()","<font-variant-ligatures>":"[ common-ligatures | no-common-ligatures ] || [ discretionary-ligatures | no-discretionary-ligatures ] || [ historical-ligatures | no-historical-ligatures ] || [ contextual | no-contextual ]","<font-variant-numeric>":"[ lining-nums | oldstyle-nums ] || [ proportional-nums | tabular-nums ] || [ diagonal-fractions | stacked-fractions ] || ordinal || slashed-zero","<font-variant-east-asian>":"[ jis78 | jis83 | jis90 | jis04 | simplified | traditional ] || [ full-width | proportional-width ] || ruby","<paint>":"<paint-basic> | <uri> <paint-basic>?","<paint-basic>":"none | currentColor | <color-svg> <icccolor>?","<position>":"[ center | [ left | right ] [ <percentage> | <length> ]? ] && [ center | [ top | bottom ] [ <percentage> | <length> ]? ] | [ left | center | right | <percentage> | <length> ] [ top | center | bottom | <percentage> | <length> ] | [ left | center | right | top | bottom | <percentage> | <length> ]","<repeat-style>":"repeat-x | repeat-y | [ repeat | space | round | no-repeat ]{1,2}","<shadow>":o.many([!0],o.cast("<length>").braces(2,4),"inset","<color>"),"<text-decoration>":"none | [ underline || overline || line-through || blink ]","<will-change>":"auto | <animateable-feature>#","<x-one-radius>":"[ <length> | <percentage> ]{1,2}"}}),Object.keys(i.simple).forEach(function(e){var t=i.simple[e];"string"==typeof t&&(i.simple[e]=function(e){return i.isLiteral(e,t)})}),Object.keys(i.complex).forEach(function(e){var t=i.complex[e];"string"==typeof t&&(i.complex[e]=o.parse(t))}),i.complex["<font-variant>"]=o.oror({expand:"<font-variant-ligatures>"},{expand:"<font-variant-alternates>"},"<font-variant-caps>",{expand:"<font-variant-numeric>"},{expand:"<font-variant-east-asian>"})},{"./Matcher":3}],22:[function(e,t,r){"use strict";t.exports={Colors:e("./Colors"),Combinator:e("./Combinator"),Parser:e("./Parser"),PropertyName:e("./PropertyName"),PropertyValue:e("./PropertyValue"),PropertyValuePart:e("./PropertyValuePart"),Matcher:e("./Matcher"),MediaFeature:e("./MediaFeature"),MediaQuery:e("./MediaQuery"),Selector:e("./Selector"),SelectorPart:e("./SelectorPart"),SelectorSubPart:e("./SelectorSubPart"),Specificity:e("./Specificity"),TokenStream:e("./TokenStream"),Tokens:e("./Tokens"),ValidationError:e("./ValidationError")}},{"./Colors":1,"./Combinator":2,"./Matcher":3,"./MediaFeature":4,"./MediaQuery":5,"./Parser":6,"./PropertyName":8,"./PropertyValue":9,"./PropertyValuePart":11,"./Selector":13,"./SelectorPart":14,"./SelectorSubPart":15,"./Specificity":16,"./TokenStream":17,"./Tokens":18,"./ValidationError":20}],23:[function(e,t,r){"use strict";function n(){this._listeners=Object.create(null)}t.exports=n,n.prototype={constructor:n,addListener:function(e,t){this._listeners[e]||(this._listeners[e]=[]),this._listeners[e].push(t)},fire:function(e){if("string"==typeof e&&(e={type:e}),"undefined"!=typeof e.target&&(e.target=this),"undefined"==typeof e.type)throw new Error("Event object missing 'type' property.");if(this._listeners[e.type])for(var t=this._listeners[e.type].concat(),r=0,n=t.length;r<n;r++)t[r].call(this,e)},removeListener:function(e,t){if(this._listeners[e])for(var r=this._listeners[e],n=0,i=r.length;n<i;n++)if(r[n]===t){r.splice(n,1);break}}}},{}],24:[function(e,t,r){"use strict";function n(e){this._input=e.replace(/(\r\n?|\n)/g,"\n"),this._line=1,this._col=1,this._cursor=0}t.exports=n,n.prototype={constructor:n,getCol:function(){return this._col},getLine:function(){return this._line},eof:function(){return this._cursor===this._input.length},peek:function(e){var t=null;return e="undefined"==typeof e?1:e,this._cursor<this._input.length&&(t=this._input.charAt(this._cursor+e-1)),t},read:function(){var e=null;return this._cursor<this._input.length&&("\n"===this._input.charAt(this._cursor)?(this._line++,this._col=1):this._col++,e=this._input.charAt(this._cursor++)),e},mark:function(){this._bookmark={cursor:this._cursor,line:this._line,col:this._col}},reset:function(){this._bookmark&&(this._cursor=this._bookmark.cursor,this._line=this._bookmark.line,this._col=this._bookmark.col,delete this._bookmark)},readTo:function(e){for(var t,r="";r.length<e.length||r.lastIndexOf(e)!==r.length-e.length;){if(t=this.read(),!t)throw new Error('Expected "'+e+'" at line '+this._line+", col "+this._col+".");r+=t}return r},readWhile:function(e){for(var t="",r=this.peek();null!==r&&e(r);)t+=this.read(),r=this.peek();return t},readMatch:function(e){var t=this._input.substring(this._cursor),r=null;return"string"==typeof e?t.slice(0,e.length)===e&&(r=this.readCount(e.length)):e instanceof RegExp&&e.test(t)&&(r=this.readCount(RegExp.lastMatch.length)),r},readCount:function(e){for(var t="";e--;)t+=this.read();return t}}},{}],25:[function(e,t,r){"use strict";function n(e,t,r){Error.call(this),this.name=this.constructor.name,this.col=r,this.line=t,this.message=e}t.exports=n,n.prototype=Object.create(Error.prototype),n.prototype.constructor=n},{}],26:[function(e,t,r){"use strict";function n(e,t,r,n){this.col=r,this.line=t,this.text=e,this.type=n}t.exports=n,n.fromToken=function(e){return new n(e.value,e.startLine,e.startCol)},n.prototype={constructor:n,valueOf:function(){return this.toString()},toString:function(){return this.text}}},{}],27:[function(e,t,r){"use strict";function n(e,t){this._reader=new i(e?e.toString():""),this._token=null,this._tokenData=t,this._lt=[],this._ltIndex=0,this._ltIndexCache=[]}t.exports=n;var i=e("./StringReader"),o=e("./SyntaxError");n.createTokenData=function(e){var t=[],r=Object.create(null),n=e.concat([]),i=0,o=n.length+1;for(n.UNKNOWN=-1,n.unshift({name:"EOF"});i<o;i++)t.push(n[i].name),n[n[i].name]=i,n[i].text&&(r[n[i].text]=i);return n.name=function(e){return t[e]},n.type=function(e){return r[e]},n},n.prototype={constructor:n,match:function(e,t){e instanceof Array||(e=[e]);for(var r=this.get(t),n=0,i=e.length;n<i;)if(r===e[n++])return!0;return this.unget(),!1},mustMatch:function(e){var t;if(e instanceof Array||(e=[e]),!this.match.apply(this,arguments))throw t=this.LT(1),new o("Expected "+this._tokenData[e[0]].name+" at line "+t.startLine+", col "+t.startCol+".",t.startLine,t.startCol)},advance:function(e,t){for(;0!==this.LA(0)&&!this.match(e,t);)this.get();return this.LA(0)},get:function(e){var t,r,n=this._tokenData,i=0;if(this._lt.length&&this._ltIndex>=0&&this._ltIndex<this._lt.length){for(i++,this._token=this._lt[this._ltIndex++],r=n[this._token.type];void 0!==r.channel&&e!==r.channel&&this._ltIndex<this._lt.length;)this._token=this._lt[this._ltIndex++],r=n[this._token.type],i++;if((void 0===r.channel||e===r.channel)&&this._ltIndex<=this._lt.length)return this._ltIndexCache.push(i),this._token.type}return t=this._getToken(),t.type>-1&&!n[t.type].hide&&(t.channel=n[t.type].channel,this._token=t,this._lt.push(t),this._ltIndexCache.push(this._lt.length-this._ltIndex+i),this._lt.length>5&&this._lt.shift(),this._ltIndexCache.length>5&&this._ltIndexCache.shift(),this._ltIndex=this._lt.length),r=n[t.type],r&&(r.hide||void 0!==r.channel&&e!==r.channel)?this.get(e):t.type},LA:function(e){var t,r=e;if(e>0){if(e>5)throw new Error("Too much lookahead.");for(;r;)t=this.get(),r--;for(;r<e;)this.unget(),r++}else if(e<0){if(!this._lt[this._ltIndex+e])throw new Error("Too much lookbehind.");t=this._lt[this._ltIndex+e].type}else t=this._token.type;return t},LT:function(e){return this.LA(e),this._lt[this._ltIndex+e-1]},peek:function(){return this.LA(1)},token:function(){return this._token},tokenName:function(e){return e<0||e>this._tokenData.length?"UNKNOWN_TOKEN":this._tokenData[e].name},tokenType:function(e){return this._tokenData[e]||-1},unget:function(){if(!this._ltIndexCache.length)throw new Error("Too much lookahead.");this._ltIndex-=this._ltIndexCache.pop(),this._token=this._lt[this._ltIndex-1]}}},{"./StringReader":24,"./SyntaxError":25}],28:[function(e,t,r){"use strict";t.exports={StringReader:e("./StringReader"),SyntaxError:e("./SyntaxError"),SyntaxUnit:e("./SyntaxUnit"),EventTarget:e("./EventTarget"),TokenStreamBase:e("./TokenStreamBase")}},{"./EventTarget":23,"./StringReader":24,"./SyntaxError":25,"./SyntaxUnit":26,"./TokenStreamBase":27}],parserlib:[function(e,t,r){"use strict";t.exports={css:e("./css"),util:e("./util")}},{"./css":22,"./util":28}]},{},[]))("parserlib")}(),n=function(){"use strict";function e(t,r,n,i){function a(t,n){if(null===t)return null;if(0==n)return t;var s,d;if("object"!=typeof t)return t;if(e.__isArray(t))s=[];else if(e.__isRegExp(t))s=new RegExp(t.source,o(t)),t.lastIndex&&(s.lastIndex=t.lastIndex);else if(e.__isDate(t))s=new Date(t.getTime());else{if(u&&Buffer.isBuffer(t))return s=new Buffer(t.length),t.copy(s),s;"undefined"==typeof i?(d=Object.getPrototypeOf(t),s=Object.create(d)):(s=Object.create(i),d=i)}if(r){var h=l.indexOf(t);if(h!=-1)return c[h];l.push(t),c.push(s)}for(var p in t){var f;d&&(f=Object.getOwnPropertyDescriptor(d,p)),f&&null==f.set||(s[p]=a(t[p],n-1))}return s}var s;"object"==typeof r&&(n=r.depth,i=r.prototype,s=r.filter,r=r.circular);var l=[],c=[],u="undefined"!=typeof Buffer;return"undefined"==typeof r&&(r=!0),"undefined"==typeof n&&(n=1/0),a(t,n)}function t(e){return Object.prototype.toString.call(e)}function r(e){return"object"==typeof e&&"[object Date]"===t(e)}function n(e){return"object"==typeof e&&"[object Array]"===t(e)}function i(e){return"object"==typeof e&&"[object RegExp]"===t(e)}function o(e){var t="";return e.global&&(t+="g"),e.ignoreCase&&(t+="i"),e.multiline&&(t+="m"),t}return e.clonePrototype=function(e){if(null===e)return null;var t=function(){};return t.prototype=e,new t},e.__objToStr=t,e.__isDate=r,e.__isArray=n,e.__isRegExp=i,e.__getRegExpFlags=o,e}();"object"==typeof t&&t.exports&&(t.exports=n);var i=function(){"use strict";function t(e,t){var r,n=e&&e.match(s),i=n&&n[1];return i&&(r={"true":2,"":1,"false":0,2:2,1:1,0:0},i.toLowerCase().split(",").forEach(function(e){var n=e.split(":"),i=n[0]||"",o=n[1]||"";t[i.trim()]=r[o.trim()]})),t}var o=[],a=[],s=/\/\*\s*csslint([^\*]*)\*\//,l=new r.util.EventTarget;return l.version="1.0.3",l.addRule=function(e){o.push(e),o[e.id]=e},l.clearRules=function(){o=[]},l.getRules=function(){return[].concat(o).sort(function(e,t){return e.id>t.id?1:0})},l.getRuleset=function(){for(var e={},t=0,r=o.length;t<r;)e[o[t++].id]=1;return e},l.addFormatter=function(e){a[e.id]=e},l.getFormatter=function(e){return a[e]},l.format=function(e,t,r,n){var i=this.getFormatter(r),o=null;return i&&(o=i.startFormat(),o+=i.formatResults(e,t,n||{}),o+=i.endFormat()),o},l.hasFormat=function(e){return a.hasOwnProperty(e)},l.verify=function(a,l){var c,u,d,h=0,p={},f=[],m=new r.css.Parser({starHack:!0,ieFilters:!0,underscoreHack:!0,strict:!1});u=a.replace(/\n\r?/g,"$split$").split("$split$"),i.Util.forEach(u,function(e,t){var r=e&&e.match(/\/\*[ \t]*csslint[ \t]+allow:[ \t]*([^\*]*)\*\//i),n=r&&r[1],i={};n&&(n.toLowerCase().split(",").forEach(function(e){i[e.trim()]=!0}),Object.keys(i).length>0&&(p[t+1]=i))});var g=null,b=null;i.Util.forEach(u,function(e,t){null===g&&e.match(/\/\*[ \t]*csslint[ \t]+ignore:start[ \t]*\*\//i)&&(g=t),e.match(/\/\*[ \t]*csslint[ \t]+ignore:end[ \t]*\*\//i)&&(b=t),null!==g&&null!==b&&(f.push([g,b]),g=b=null)}),null!==g&&f.push([g,u.length]),l||(l=this.getRuleset()),s.test(a)&&(l=n(l),l=t(a,l)),c=new e(u,l,p,f),l.errors=2;for(h in l)l.hasOwnProperty(h)&&l[h]&&o[h]&&o[h].init(m,c);try{m.parse(a)}catch(k){c.error("Fatal error, cannot continue: "+k.message,k.line,k.col,{})}return d={messages:c.messages,stats:c.stats,ruleset:c.ruleset,allow:c.allow,ignore:c.ignore},d.messages.sort(function(e,t){return e.rollup&&!t.rollup?1:!e.rollup&&t.rollup?-1:e.line-t.line}),d},l}();return e.prototype={constructor:e,error:function(e,t,r,n){"use strict";this.messages.push({type:"error",line:t,col:r,message:e,evidence:this.lines[t-1],rule:n||{}})},warn:function(e,t,r,n){"use strict";this.report(e,t,r,n)},report:function(e,t,r,n){"use strict";if(!this.allow.hasOwnProperty(t)||!this.allow[t].hasOwnProperty(n.id)){var o=!1;i.Util.forEach(this.ignore,function(e){e[0]<=t&&t<=e[1]&&(o=!0)}),o||this.messages.push({type:2===this.ruleset[n.id]?"error":"warning",line:t,col:r,message:e,evidence:this.lines[t-1],rule:n})}},info:function(e,t,r,n){"use strict";this.messages.push({type:"info",line:t,col:r,message:e,evidence:this.lines[t-1],rule:n})},rollupError:function(e,t){"use strict";this.messages.push({type:"error",rollup:!0,message:e,rule:t})},rollupWarn:function(e,t){"use strict";this.messages.push({type:"warning",rollup:!0,message:e,rule:t})},stat:function(e,t){"use strict";this.stats[e]=t}},i._Reporter=e,i.Util={mix:function(e,t){"use strict";var r;for(r in t)t.hasOwnProperty(r)&&(e[r]=t[r]);return r},indexOf:function(e,t){"use strict";if(e.indexOf)return e.indexOf(t);for(var r=0,n=e.length;r<n;r++)if(e[r]===t)return r;return-1},forEach:function(e,t){"use strict";if(e.forEach)return e.forEach(t);for(var r=0,n=e.length;r<n;r++)t(e[r],r,e)}},i.addRule({id:"adjoining-classes",name:"Disallow adjoining classes",desc:"Don't use adjoining classes.",url:"https://github.com/CSSLint/csslint/wiki/Disallow-adjoining-classes",browsers:"IE6",init:function(e,t){"use strict";var r=this;e.addListener("startrule",function(n){var i,o,a,s,l,c,u,d=n.selectors;for(l=0;l<d.length;l++)for(i=d[l],c=0;c<i.parts.length;c++)if(o=i.parts[c],o.type===e.SELECTOR_PART_TYPE)for(s=0,u=0;u<o.modifiers.length;u++)a=o.modifiers[u],"class"===a.type&&s++,s>1&&t.report("Adjoining classes: "+d[l].text,o.line,o.col,r)})}}),i.addRule({id:"box-model",name:"Beware of broken box size",desc:"Don't use width or height when using padding or border.",url:"https://github.com/CSSLint/csslint/wiki/Beware-of-box-model-size",browsers:"All",init:function(e,t){"use strict";function r(){i={},l=!1}function n(){var e,r;if(!l){if(i.height)for(e in s)s.hasOwnProperty(e)&&i[e]&&(r=i[e].value,"padding"===e&&2===r.parts.length&&0===r.parts[0].value||t.report("Using height with "+e+" can sometimes make elements larger than you expect.",i[e].line,i[e].col,o));if(i.width)for(e in a)a.hasOwnProperty(e)&&i[e]&&(r=i[e].value,"padding"===e&&2===r.parts.length&&0===r.parts[1].value||t.report("Using width with "+e+" can sometimes make elements larger than you expect.",i[e].line,i[e].col,o))}}var i,o=this,a={border:1,"border-left":1,"border-right":1,padding:1,"padding-left":1,"padding-right":1},s={border:1,"border-bottom":1,"border-top":1,padding:1,"padding-bottom":1,"padding-top":1},l=!1;e.addListener("startrule",r),e.addListener("startfontface",r),e.addListener("startpage",r),e.addListener("startpagemargin",r),e.addListener("startkeyframerule",r),e.addListener("startviewport",r),e.addListener("property",function(e){var t=e.property.text.toLowerCase();s[t]||a[t]?/^0\S*$/.test(e.value)||"border"===t&&"none"===e.value.toString()||(i[t]={line:e.property.line,col:e.property.col,value:e.value}):/^(width|height)/i.test(t)&&/^(length|percentage)/.test(e.value.parts[0].type)?i[t]=1:"box-sizing"===t&&(l=!0)}),e.addListener("endrule",n),e.addListener("endfontface",n),e.addListener("endpage",n),e.addListener("endpagemargin",n),e.addListener("endkeyframerule",n),e.addListener("endviewport",n)}}),i.addRule({id:"box-sizing",name:"Disallow use of box-sizing",desc:"The box-sizing properties isn't supported in IE6 and IE7.",url:"https://github.com/CSSLint/csslint/wiki/Disallow-box-sizing",browsers:"IE6, IE7",tags:["Compatibility"],init:function(e,t){"use strict";var r=this;e.addListener("property",function(e){var n=e.property.text.toLowerCase();"box-sizing"===n&&t.report("The box-sizing property isn't supported in IE6 and IE7.",e.line,e.col,r)})}}),i.addRule({id:"bulletproof-font-face",name:"Use the bulletproof @font-face syntax",desc:"Use the bulletproof @font-face syntax to avoid 404's in old IE (http://www.fontspring.com/blog/the-new-bulletproof-font-face-syntax).",url:"https://github.com/CSSLint/csslint/wiki/Bulletproof-font-face",browsers:"All",init:function(e,t){"use strict";var r,n,i=this,o=!1,a=!0,s=!1;e.addListener("startfontface",function(){o=!0}),e.addListener("property",function(e){if(o){var t=e.property.toString().toLowerCase(),i=e.value.toString();if(r=e.line,n=e.col,"src"===t){var l=/^\s?url\(['"].+\.eot\?.*['"]\)\s*format\(['"]embedded-opentype['"]\).*$/i;!i.match(l)&&a?(s=!0,a=!1):i.match(l)&&!a&&(s=!1)}}}),e.addListener("endfontface",function(){o=!1,s&&t.report("@font-face declaration doesn't follow the fontspring bulletproof syntax.",r,n,i)})}}),i.addRule({id:"compatible-vendor-prefixes",name:"Require compatible vendor prefixes",desc:"Include all compatible vendor prefixes to reach a wider range of users.",url:"https://github.com/CSSLint/csslint/wiki/Require-compatible-vendor-prefixes",browsers:"All",init:function(e,t){"use strict";var r,n,o,a,s,l,c,u=this,d=!1,h=Array.prototype.push,p=[];r={animation:"webkit","animation-delay":"webkit","animation-direction":"webkit","animation-duration":"webkit","animation-fill-mode":"webkit","animation-iteration-count":"webkit","animation-name":"webkit","animation-play-state":"webkit","animation-timing-function":"webkit",appearance:"webkit moz","border-end":"webkit moz","border-end-color":"webkit moz","border-end-style":"webkit moz","border-end-width":"webkit moz","border-image":"webkit moz o","border-radius":"webkit","border-start":"webkit moz","border-start-color":"webkit moz","border-start-style":"webkit moz","border-start-width":"webkit moz","box-align":"webkit moz ms","box-direction":"webkit moz ms","box-flex":"webkit moz ms","box-lines":"webkit ms","box-ordinal-group":"webkit moz ms","box-orient":"webkit moz ms","box-pack":"webkit moz ms","box-sizing":"","box-shadow":"","column-count":"webkit moz ms","column-gap":"webkit moz ms","column-rule":"webkit moz ms","column-rule-color":"webkit moz ms","column-rule-style":"webkit moz ms","column-rule-width":"webkit moz ms","column-width":"webkit moz ms",hyphens:"epub moz","line-break":"webkit ms","margin-end":"webkit moz","margin-start":"webkit moz","marquee-speed":"webkit wap","marquee-style":"webkit wap","padding-end":"webkit moz","padding-start":"webkit moz","tab-size":"moz o","text-size-adjust":"webkit ms",transform:"webkit ms","transform-origin":"webkit ms",transition:"","transition-delay":"","transition-duration":"","transition-property":"","transition-timing-function":"","user-modify":"webkit moz","user-select":"webkit moz ms","word-break":"epub ms","writing-mode":"epub ms"};for(o in r)if(r.hasOwnProperty(o)){for(a=[],s=r[o].split(" "),l=0,c=s.length;l<c;l++)a.push("-"+s[l]+"-"+o);r[o]=a,h.apply(p,a)}e.addListener("startrule",function(){n=[]}),e.addListener("startkeyframes",function(e){d=e.prefix||!0}),e.addListener("endkeyframes",function(){d=!1}),e.addListener("property",function(e){var t=e.property;i.Util.indexOf(p,t.text)>-1&&(d&&"string"==typeof d&&0===t.text.indexOf("-"+d+"-")||n.push(t))}),e.addListener("endrule",function(){if(n.length){var e,o,a,s,l,c,d,h,p,f,m={};for(e=0,o=n.length;e<o;e++){a=n[e];for(s in r)r.hasOwnProperty(s)&&(l=r[s],i.Util.indexOf(l,a.text)>-1&&(m[s]||(m[s]={full:l.slice(0),actual:[],actualNodes:[]}),i.Util.indexOf(m[s].actual,a.text)===-1&&(m[s].actual.push(a.text),m[s].actualNodes.push(a))))}for(s in m)if(m.hasOwnProperty(s)&&(c=m[s],d=c.full,h=c.actual,d.length>h.length))for(e=0,o=d.length;e<o;e++)p=d[e],i.Util.indexOf(h,p)===-1&&(f=1===h.length?h[0]:2===h.length?h.join(" and "):h.join(", "),t.report("The property "+p+" is compatible with "+f+" and should be included as well.",c.actualNodes[0].line,c.actualNodes[0].col,u))}})}}),i.addRule({id:"display-property-grouping",name:"Require properties appropriate for display",desc:"Certain properties shouldn't be used with certain display property values.",url:"https://github.com/CSSLint/csslint/wiki/Require-properties-appropriate-for-display",browsers:"All",init:function(e,t){"use strict";function r(e,r,n){o[e]&&("string"==typeof s[e]&&o[e].value.toLowerCase()===s[e]||t.report(n||e+" can't be used with display: "+r+".",o[e].line,o[e].col,a));
4
+ }function n(){o={}}function i(){var e=o.display?o.display.value:null;if(e)switch(e){case"inline":r("height",e),r("width",e),r("margin",e),r("margin-top",e),r("margin-bottom",e),r("float",e,"display:inline has no effect on floated elements (but may be used to fix the IE6 double-margin bug).");break;case"block":r("vertical-align",e);break;case"inline-block":r("float",e);break;default:0===e.indexOf("table-")&&(r("margin",e),r("margin-left",e),r("margin-right",e),r("margin-top",e),r("margin-bottom",e),r("float",e))}}var o,a=this,s={display:1,"float":"none",height:1,width:1,margin:1,"margin-left":1,"margin-right":1,"margin-bottom":1,"margin-top":1,padding:1,"padding-left":1,"padding-right":1,"padding-bottom":1,"padding-top":1,"vertical-align":1};e.addListener("startrule",n),e.addListener("startfontface",n),e.addListener("startkeyframerule",n),e.addListener("startpagemargin",n),e.addListener("startpage",n),e.addListener("startviewport",n),e.addListener("property",function(e){var t=e.property.text.toLowerCase();s[t]&&(o[t]={value:e.value.text,line:e.property.line,col:e.property.col})}),e.addListener("endrule",i),e.addListener("endfontface",i),e.addListener("endkeyframerule",i),e.addListener("endpagemargin",i),e.addListener("endpage",i),e.addListener("endviewport",i)}}),i.addRule({id:"duplicate-background-images",name:"Disallow duplicate background images",desc:"Every background-image should be unique. Use a common class for e.g. sprites.",url:"https://github.com/CSSLint/csslint/wiki/Disallow-duplicate-background-images",browsers:"All",init:function(e,t){"use strict";var r=this,n={};e.addListener("property",function(e){var i,o,a=e.property.text,s=e.value;if(a.match(/background/i))for(i=0,o=s.parts.length;i<o;i++)"uri"===s.parts[i].type&&("undefined"==typeof n[s.parts[i].uri]?n[s.parts[i].uri]=e:t.report("Background image '"+s.parts[i].uri+"' was used multiple times, first declared at line "+n[s.parts[i].uri].line+", col "+n[s.parts[i].uri].col+".",e.line,e.col,r))})}}),i.addRule({id:"duplicate-properties",name:"Disallow duplicate properties",desc:"Duplicate properties must appear one after the other.",url:"https://github.com/CSSLint/csslint/wiki/Disallow-duplicate-properties",browsers:"All",init:function(e,t){"use strict";function r(){n={}}var n,i,o=this;e.addListener("startrule",r),e.addListener("startfontface",r),e.addListener("startpage",r),e.addListener("startpagemargin",r),e.addListener("startkeyframerule",r),e.addListener("startviewport",r),e.addListener("property",function(e){var r=e.property,a=r.text.toLowerCase();!n[a]||i===a&&n[a]!==e.value.text||t.report("Duplicate property '"+e.property+"' found.",e.line,e.col,o),n[a]=e.value.text,i=a})}}),i.addRule({id:"empty-rules",name:"Disallow empty rules",desc:"Rules without any properties specified should be removed.",url:"https://github.com/CSSLint/csslint/wiki/Disallow-empty-rules",browsers:"All",init:function(e,t){"use strict";var r=this,n=0;e.addListener("startrule",function(){n=0}),e.addListener("property",function(){n++}),e.addListener("endrule",function(e){var i=e.selectors;0===n&&t.report("Rule is empty.",i[0].line,i[0].col,r)})}}),i.addRule({id:"errors",name:"Parsing Errors",desc:"This rule looks for recoverable syntax errors.",browsers:"All",init:function(e,t){"use strict";var r=this;e.addListener("error",function(e){t.error(e.message,e.line,e.col,r)})}}),i.addRule({id:"fallback-colors",name:"Require fallback colors",desc:"For older browsers that don't support RGBA, HSL, or HSLA, provide a fallback color.",url:"https://github.com/CSSLint/csslint/wiki/Require-fallback-colors",browsers:"IE6,IE7,IE8",init:function(e,t){"use strict";function r(){n=null}var n,i=this,o={color:1,background:1,"border-color":1,"border-top-color":1,"border-right-color":1,"border-bottom-color":1,"border-left-color":1,border:1,"border-top":1,"border-right":1,"border-bottom":1,"border-left":1,"background-color":1};e.addListener("startrule",r),e.addListener("startfontface",r),e.addListener("startpage",r),e.addListener("startpagemargin",r),e.addListener("startkeyframerule",r),e.addListener("startviewport",r),e.addListener("property",function(e){var r=e.property,a=r.text.toLowerCase(),s=e.value.parts,l=0,c="",u=s.length;if(o[a])for(;l<u;)"color"===s[l].type&&("alpha"in s[l]||"hue"in s[l]?(/([^\)]+)\(/.test(s[l])&&(c=RegExp.$1.toUpperCase()),n&&n.property.text.toLowerCase()===a&&"compat"===n.colorType||t.report("Fallback "+a+" (hex or RGB) should precede "+c+" "+a+".",e.line,e.col,i)):e.colorType="compat"),l++;n=e})}}),i.addRule({id:"floats",name:"Disallow too many floats",desc:"This rule tests if the float property is used too many times",url:"https://github.com/CSSLint/csslint/wiki/Disallow-too-many-floats",browsers:"All",init:function(e,t){"use strict";var r=this,n=0;e.addListener("property",function(e){"float"===e.property.text.toLowerCase()&&"none"!==e.value.text.toLowerCase()&&n++}),e.addListener("endstylesheet",function(){t.stat("floats",n),n>=10&&t.rollupWarn("Too many floats ("+n+"), you're probably using them for layout. Consider using a grid system instead.",r)})}}),i.addRule({id:"font-faces",name:"Don't use too many web fonts",desc:"Too many different web fonts in the same stylesheet.",url:"https://github.com/CSSLint/csslint/wiki/Don%27t-use-too-many-web-fonts",browsers:"All",init:function(e,t){"use strict";var r=this,n=0;e.addListener("startfontface",function(){n++}),e.addListener("endstylesheet",function(){n>5&&t.rollupWarn("Too many @font-face declarations ("+n+").",r)})}}),i.addRule({id:"font-sizes",name:"Disallow too many font sizes",desc:"Checks the number of font-size declarations.",url:"https://github.com/CSSLint/csslint/wiki/Don%27t-use-too-many-font-size-declarations",browsers:"All",init:function(e,t){"use strict";var r=this,n=0;e.addListener("property",function(e){"font-size"===e.property.toString()&&n++}),e.addListener("endstylesheet",function(){t.stat("font-sizes",n),n>=10&&t.rollupWarn("Too many font-size declarations ("+n+"), abstraction needed.",r)})}}),i.addRule({id:"gradients",name:"Require all gradient definitions",desc:"When using a vendor-prefixed gradient, make sure to use them all.",url:"https://github.com/CSSLint/csslint/wiki/Require-all-gradient-definitions",browsers:"All",init:function(e,t){"use strict";var r,n=this;e.addListener("startrule",function(){r={moz:0,webkit:0,oldWebkit:0,o:0}}),e.addListener("property",function(e){/\-(moz|o|webkit)(?:\-(?:linear|radial))\-gradient/i.test(e.value)?r[RegExp.$1]=1:/\-webkit\-gradient/i.test(e.value)&&(r.oldWebkit=1)}),e.addListener("endrule",function(e){var i=[];r.moz||i.push("Firefox 3.6+"),r.webkit||i.push("Webkit (Safari 5+, Chrome)"),r.oldWebkit||i.push("Old Webkit (Safari 4+, Chrome)"),r.o||i.push("Opera 11.1+"),i.length&&i.length<4&&t.report("Missing vendor-prefixed CSS gradients for "+i.join(", ")+".",e.selectors[0].line,e.selectors[0].col,n)})}}),i.addRule({id:"ids",name:"Disallow IDs in selectors",desc:"Selectors should not contain IDs.",url:"https://github.com/CSSLint/csslint/wiki/Disallow-IDs-in-selectors",browsers:"All",init:function(e,t){"use strict";var r=this;e.addListener("startrule",function(n){var i,o,a,s,l,c,u,d=n.selectors;for(l=0;l<d.length;l++){for(i=d[l],s=0,c=0;c<i.parts.length;c++)if(o=i.parts[c],o.type===e.SELECTOR_PART_TYPE)for(u=0;u<o.modifiers.length;u++)a=o.modifiers[u],"id"===a.type&&s++;1===s?t.report("Don't use IDs in selectors.",i.line,i.col,r):s>1&&t.report(s+" IDs in the selector, really?",i.line,i.col,r)}})}}),i.addRule({id:"import-ie-limit",name:"@import limit on IE6-IE9",desc:"IE6-9 supports up to 31 @import per stylesheet",browsers:"IE6, IE7, IE8, IE9",init:function(e,t){"use strict";function r(){o=0}var n=this,i=31,o=0;e.addListener("startpage",r),e.addListener("import",function(){o++}),e.addListener("endstylesheet",function(){o>i&&t.rollupError("Too many @import rules ("+o+"). IE6-9 supports up to 31 import per stylesheet.",n)})}}),i.addRule({id:"import",name:"Disallow @import",desc:"Don't use @import, use <link> instead.",url:"https://github.com/CSSLint/csslint/wiki/Disallow-%40import",browsers:"All",init:function(e,t){"use strict";var r=this;e.addListener("import",function(e){t.report("@import prevents parallel downloads, use <link> instead.",e.line,e.col,r)})}}),i.addRule({id:"important",name:"Disallow !important",desc:"Be careful when using !important declaration",url:"https://github.com/CSSLint/csslint/wiki/Disallow-%21important",browsers:"All",init:function(e,t){"use strict";var r=this,n=0;e.addListener("property",function(e){e.important===!0&&(n++,t.report("Use of !important",e.line,e.col,r))}),e.addListener("endstylesheet",function(){t.stat("important",n),n>=10&&t.rollupWarn("Too many !important declarations ("+n+"), try to use less than 10 to avoid specificity issues.",r)})}}),i.addRule({id:"known-properties",name:"Require use of known properties",desc:"Properties should be known (listed in CSS3 specification) or be a vendor-prefixed property.",url:"https://github.com/CSSLint/csslint/wiki/Require-use-of-known-properties",browsers:"All",init:function(e,t){"use strict";var r=this;e.addListener("property",function(e){e.invalid&&t.report(e.invalid.message,e.line,e.col,r)})}}),i.addRule({id:"order-alphabetical",name:"Alphabetical order",desc:"Assure properties are in alphabetical order",browsers:"All",init:function(e,t){"use strict";var r,n=this,i=function(){r=[]},o=function(e){var i=r.join(","),o=r.sort().join(",");i!==o&&t.report("Rule doesn't have all its properties in alphabetical order.",e.line,e.col,n)};e.addListener("startrule",i),e.addListener("startfontface",i),e.addListener("startpage",i),e.addListener("startpagemargin",i),e.addListener("startkeyframerule",i),e.addListener("startviewport",i),e.addListener("property",function(e){var t=e.property.text,n=t.toLowerCase().replace(/^-.*?-/,"");r.push(n)}),e.addListener("endrule",o),e.addListener("endfontface",o),e.addListener("endpage",o),e.addListener("endpagemargin",o),e.addListener("endkeyframerule",o),e.addListener("endviewport",o)}}),i.addRule({id:"outline-none",name:"Disallow outline: none",desc:"Use of outline: none or outline: 0 should be limited to :focus rules.",url:"https://github.com/CSSLint/csslint/wiki/Disallow-outline%3Anone",browsers:"All",tags:["Accessibility"],init:function(e,t){"use strict";function r(e){i=e.selectors?{line:e.line,col:e.col,selectors:e.selectors,propCount:0,outline:!1}:null}function n(){i&&i.outline&&(i.selectors.toString().toLowerCase().indexOf(":focus")===-1?t.report("Outlines should only be modified using :focus.",i.line,i.col,o):1===i.propCount&&t.report("Outlines shouldn't be hidden unless other visual changes are made.",i.line,i.col,o))}var i,o=this;e.addListener("startrule",r),e.addListener("startfontface",r),e.addListener("startpage",r),e.addListener("startpagemargin",r),e.addListener("startkeyframerule",r),e.addListener("startviewport",r),e.addListener("property",function(e){var t=e.property.text.toLowerCase(),r=e.value;i&&(i.propCount++,"outline"!==t||"none"!==r.toString()&&"0"!==r.toString()||(i.outline=!0))}),e.addListener("endrule",n),e.addListener("endfontface",n),e.addListener("endpage",n),e.addListener("endpagemargin",n),e.addListener("endkeyframerule",n),e.addListener("endviewport",n)}}),i.addRule({id:"overqualified-elements",name:"Disallow overqualified elements",desc:"Don't use classes or IDs with elements (a.foo or a#foo).",url:"https://github.com/CSSLint/csslint/wiki/Disallow-overqualified-elements",browsers:"All",init:function(e,t){"use strict";var r=this,n={};e.addListener("startrule",function(i){var o,a,s,l,c,u,d=i.selectors;for(l=0;l<d.length;l++)for(o=d[l],c=0;c<o.parts.length;c++)if(a=o.parts[c],a.type===e.SELECTOR_PART_TYPE)for(u=0;u<a.modifiers.length;u++)s=a.modifiers[u],a.elementName&&"id"===s.type?t.report("Element ("+a+") is overqualified, just use "+s+" without element name.",a.line,a.col,r):"class"===s.type&&(n[s]||(n[s]=[]),n[s].push({modifier:s,part:a}))}),e.addListener("endstylesheet",function(){var e;for(e in n)n.hasOwnProperty(e)&&1===n[e].length&&n[e][0].part.elementName&&t.report("Element ("+n[e][0].part+") is overqualified, just use "+n[e][0].modifier+" without element name.",n[e][0].part.line,n[e][0].part.col,r)})}}),i.addRule({id:"qualified-headings",name:"Disallow qualified headings",desc:"Headings should not be qualified (namespaced).",url:"https://github.com/CSSLint/csslint/wiki/Disallow-qualified-headings",browsers:"All",init:function(e,t){"use strict";var r=this;e.addListener("startrule",function(n){var i,o,a,s,l=n.selectors;for(a=0;a<l.length;a++)for(i=l[a],s=0;s<i.parts.length;s++)o=i.parts[s],o.type===e.SELECTOR_PART_TYPE&&o.elementName&&/h[1-6]/.test(o.elementName.toString())&&s>0&&t.report("Heading ("+o.elementName+") should not be qualified.",o.line,o.col,r)})}}),i.addRule({id:"regex-selectors",name:"Disallow selectors that look like regexs",desc:"Selectors that look like regular expressions are slow and should be avoided.",url:"https://github.com/CSSLint/csslint/wiki/Disallow-selectors-that-look-like-regular-expressions",browsers:"All",init:function(e,t){"use strict";var r=this;e.addListener("startrule",function(n){var i,o,a,s,l,c,u=n.selectors;for(s=0;s<u.length;s++)for(i=u[s],l=0;l<i.parts.length;l++)if(o=i.parts[l],o.type===e.SELECTOR_PART_TYPE)for(c=0;c<o.modifiers.length;c++)a=o.modifiers[c],"attribute"===a.type&&/([~\|\^\$\*]=)/.test(a)&&t.report("Attribute selectors with "+RegExp.$1+" are slow!",a.line,a.col,r)})}}),i.addRule({id:"rules-count",name:"Rules Count",desc:"Track how many rules there are.",browsers:"All",init:function(e,t){"use strict";var r=0;e.addListener("startrule",function(){r++}),e.addListener("endstylesheet",function(){t.stat("rule-count",r)})}}),i.addRule({id:"selector-max-approaching",name:"Warn when approaching the 4095 selector limit for IE",desc:"Will warn when selector count is >= 3800 selectors.",browsers:"IE",init:function(e,t){"use strict";var r=this,n=0;e.addListener("startrule",function(e){n+=e.selectors.length}),e.addListener("endstylesheet",function(){n>=3800&&t.report("You have "+n+" selectors. Internet Explorer supports a maximum of 4095 selectors per stylesheet. Consider refactoring.",0,0,r)})}}),i.addRule({id:"selector-max",name:"Error when past the 4095 selector limit for IE",desc:"Will error when selector count is > 4095.",browsers:"IE",init:function(e,t){"use strict";var r=this,n=0;e.addListener("startrule",function(e){n+=e.selectors.length}),e.addListener("endstylesheet",function(){n>4095&&t.report("You have "+n+" selectors. Internet Explorer supports a maximum of 4095 selectors per stylesheet. Consider refactoring.",0,0,r)})}}),i.addRule({id:"selector-newline",name:"Disallow new-line characters in selectors",desc:"New-line characters in selectors are usually a forgotten comma and not a descendant combinator.",browsers:"All",init:function(e,t){"use strict";function r(e){var r,i,o,a,s,l,c,u,d,h,p,f=e.selectors;for(r=0,i=f.length;r<i;r++)for(o=f[r],a=0,l=o.parts.length;a<l;a++)for(s=a+1;s<l;s++)c=o.parts[a],u=o.parts[s],d=c.type,h=c.line,p=u.line,"descendant"===d&&p>h&&t.report("newline character found in selector (forgot a comma?)",h,f[r].parts[0].col,n)}var n=this;e.addListener("startrule",r)}}),i.addRule({id:"shorthand",name:"Require shorthand properties",desc:"Use shorthand properties where possible.",url:"https://github.com/CSSLint/csslint/wiki/Require-shorthand-properties",browsers:"All",init:function(e,t){"use strict";function r(){s={}}function n(e){var r,n,i,o;for(r in u)if(u.hasOwnProperty(r)){for(o=0,n=0,i=u[r].length;n<i;n++)o+=s[u[r][n]]?1:0;o===u[r].length&&t.report("The properties "+u[r].join(", ")+" can be replaced by "+r+".",e.line,e.col,l)}}var i,o,a,s,l=this,c={},u={margin:["margin-top","margin-bottom","margin-left","margin-right"],padding:["padding-top","padding-bottom","padding-left","padding-right"]};for(i in u)if(u.hasOwnProperty(i))for(o=0,a=u[i].length;o<a;o++)c[u[i][o]]=i;e.addListener("startrule",r),e.addListener("startfontface",r),e.addListener("property",function(e){var t=e.property.toString().toLowerCase();c[t]&&(s[t]=1)}),e.addListener("endrule",n),e.addListener("endfontface",n)}}),i.addRule({id:"star-property-hack",name:"Disallow properties with a star prefix",desc:"Checks for the star property hack (targets IE6/7)",url:"https://github.com/CSSLint/csslint/wiki/Disallow-star-hack",browsers:"All",init:function(e,t){"use strict";var r=this;e.addListener("property",function(e){var n=e.property;"*"===n.hack&&t.report("Property with star prefix found.",e.property.line,e.property.col,r)})}}),i.addRule({id:"text-indent",name:"Disallow negative text-indent",desc:"Checks for text indent less than -99px",url:"https://github.com/CSSLint/csslint/wiki/Disallow-negative-text-indent",browsers:"All",init:function(e,t){"use strict";function r(){i=!1,o="inherit"}function n(){i&&"ltr"!==o&&t.report("Negative text-indent doesn't work well with RTL. If you use text-indent for image replacement explicitly set direction for that item to ltr.",i.line,i.col,a)}var i,o,a=this;e.addListener("startrule",r),e.addListener("startfontface",r),e.addListener("property",function(e){var t=e.property.toString().toLowerCase(),r=e.value;"text-indent"===t&&r.parts[0].value<-99?i=e.property:"direction"===t&&"ltr"===r.toString()&&(o="ltr")}),e.addListener("endrule",n),e.addListener("endfontface",n)}}),i.addRule({id:"underscore-property-hack",name:"Disallow properties with an underscore prefix",desc:"Checks for the underscore property hack (targets IE6)",url:"https://github.com/CSSLint/csslint/wiki/Disallow-underscore-hack",browsers:"All",init:function(e,t){"use strict";var r=this;e.addListener("property",function(e){var n=e.property;"_"===n.hack&&t.report("Property with underscore prefix found.",e.property.line,e.property.col,r)})}}),i.addRule({id:"unique-headings",name:"Headings should only be defined once",desc:"Headings should be defined only once.",url:"https://github.com/CSSLint/csslint/wiki/Headings-should-only-be-defined-once",browsers:"All",init:function(e,t){"use strict";var r=this,n={h1:0,h2:0,h3:0,h4:0,h5:0,h6:0};e.addListener("startrule",function(e){var i,o,a,s,l,c=e.selectors;for(s=0;s<c.length;s++)if(i=c[s],o=i.parts[i.parts.length-1],o.elementName&&/(h[1-6])/i.test(o.elementName.toString())){for(l=0;l<o.modifiers.length;l++)if("pseudo"===o.modifiers[l].type){a=!0;break}a||(n[RegExp.$1]++,n[RegExp.$1]>1&&t.report("Heading ("+o.elementName+") has already been defined.",o.line,o.col,r))}}),e.addListener("endstylesheet",function(){var e,i=[];for(e in n)n.hasOwnProperty(e)&&n[e]>1&&i.push(n[e]+" "+e+"s");i.length&&t.rollupWarn("You have "+i.join(", ")+" defined in this stylesheet.",r)})}}),i.addRule({id:"universal-selector",name:"Disallow universal selector",desc:"The universal selector (*) is known to be slow.",url:"https://github.com/CSSLint/csslint/wiki/Disallow-universal-selector",browsers:"All",init:function(e,t){"use strict";var r=this;e.addListener("startrule",function(e){var n,i,o,a=e.selectors;for(o=0;o<a.length;o++)n=a[o],i=n.parts[n.parts.length-1],"*"===i.elementName&&t.report(r.desc,i.line,i.col,r)})}}),i.addRule({id:"unqualified-attributes",name:"Disallow unqualified attribute selectors",desc:"Unqualified attribute selectors are known to be slow.",url:"https://github.com/CSSLint/csslint/wiki/Disallow-unqualified-attribute-selectors",browsers:"All",init:function(e,t){"use strict";var r=this;e.addListener("startrule",function(n){var i,o,a,s,l,c=n.selectors,u=!1;for(s=0;s<c.length;s++)if(i=c[s],o=i.parts[i.parts.length-1],o.type===e.SELECTOR_PART_TYPE){for(l=0;l<o.modifiers.length;l++)if(a=o.modifiers[l],"class"===a.type||"id"===a.type){u=!0;break}if(!u)for(l=0;l<o.modifiers.length;l++)a=o.modifiers[l],"attribute"!==a.type||o.elementName&&"*"!==o.elementName||t.report(r.desc,o.line,o.col,r)}})}}),i.addRule({id:"vendor-prefix",name:"Require standard property with vendor prefix",desc:"When using a vendor-prefixed property, make sure to include the standard one.",url:"https://github.com/CSSLint/csslint/wiki/Require-standard-property-with-vendor-prefix",browsers:"All",init:function(e,t){"use strict";function r(){i={},o=1}function n(){var e,r,n,o,l,c=[];for(e in i)s[e]&&c.push({actual:e,needed:s[e]});for(r=0,n=c.length;r<n;r++)o=c[r].needed,l=c[r].actual,i[o]?i[o][0].pos<i[l][0].pos&&t.report("Standard property '"+o+"' should come after vendor-prefixed property '"+l+"'.",i[l][0].name.line,i[l][0].name.col,a):t.report("Missing standard property '"+o+"' to go along with '"+l+"'.",i[l][0].name.line,i[l][0].name.col,a)}var i,o,a=this,s={"-webkit-border-radius":"border-radius","-webkit-border-top-left-radius":"border-top-left-radius","-webkit-border-top-right-radius":"border-top-right-radius","-webkit-border-bottom-left-radius":"border-bottom-left-radius","-webkit-border-bottom-right-radius":"border-bottom-right-radius","-o-border-radius":"border-radius","-o-border-top-left-radius":"border-top-left-radius","-o-border-top-right-radius":"border-top-right-radius","-o-border-bottom-left-radius":"border-bottom-left-radius","-o-border-bottom-right-radius":"border-bottom-right-radius","-moz-border-radius":"border-radius","-moz-border-radius-topleft":"border-top-left-radius","-moz-border-radius-topright":"border-top-right-radius","-moz-border-radius-bottomleft":"border-bottom-left-radius","-moz-border-radius-bottomright":"border-bottom-right-radius","-moz-column-count":"column-count","-webkit-column-count":"column-count","-moz-column-gap":"column-gap","-webkit-column-gap":"column-gap","-moz-column-rule":"column-rule","-webkit-column-rule":"column-rule","-moz-column-rule-style":"column-rule-style","-webkit-column-rule-style":"column-rule-style","-moz-column-rule-color":"column-rule-color","-webkit-column-rule-color":"column-rule-color","-moz-column-rule-width":"column-rule-width","-webkit-column-rule-width":"column-rule-width","-moz-column-width":"column-width","-webkit-column-width":"column-width","-webkit-column-span":"column-span","-webkit-columns":"columns","-moz-box-shadow":"box-shadow","-webkit-box-shadow":"box-shadow","-moz-transform":"transform","-webkit-transform":"transform","-o-transform":"transform","-ms-transform":"transform","-moz-transform-origin":"transform-origin","-webkit-transform-origin":"transform-origin","-o-transform-origin":"transform-origin","-ms-transform-origin":"transform-origin","-moz-box-sizing":"box-sizing","-webkit-box-sizing":"box-sizing"};e.addListener("startrule",r),e.addListener("startfontface",r),e.addListener("startpage",r),e.addListener("startpagemargin",r),e.addListener("startkeyframerule",r),e.addListener("startviewport",r),e.addListener("property",function(e){var t=e.property.text.toLowerCase();i[t]||(i[t]=[]),i[t].push({name:e.property,value:e.value,pos:o++})}),e.addListener("endrule",n),e.addListener("endfontface",n),e.addListener("endpage",n),e.addListener("endpagemargin",n),e.addListener("endkeyframerule",n),e.addListener("endviewport",n)}}),i.addRule({id:"zero-units",name:"Disallow units for 0 values",desc:"You don't need to specify units when a value is 0.",url:"https://github.com/CSSLint/csslint/wiki/Disallow-units-for-zero-values",browsers:"All",init:function(e,t){"use strict";var r=this;e.addListener("property",function(e){for(var n=e.value.parts,i=0,o=n.length;i<o;)!n[i].units&&"percentage"!==n[i].type||0!==n[i].value||"time"===n[i].type||t.report("Values of 0 shouldn't have units specified.",n[i].line,n[i].col,r),i++})}}),function(){"use strict";var e=function(e){return e&&e.constructor===String?e.replace(/["&><]/g,function(e){switch(e){case'"':return"&quot;";case"&":return"&amp;";case"<":return"&lt;";case">":return"&gt;"}}):""};i.addFormatter({id:"checkstyle-xml",name:"Checkstyle XML format",startFormat:function(){return'<?xml version="1.0" encoding="utf-8"?><checkstyle>'},endFormat:function(){return"</checkstyle>"},readError:function(t,r){return'<file name="'+e(t)+'"><error line="0" column="0" severty="error" message="'+e(r)+'"></error></file>'},formatResults:function(t,r){var n=t.messages,o=[],a=function(e){return e&&"name"in e?"net.csslint."+e.name.replace(/\s/g,""):""};return n.length>0&&(o.push('<file name="'+r+'">'),i.Util.forEach(n,function(t){t.rollup||o.push('<error line="'+t.line+'" column="'+t.col+'" severity="'+t.type+'" message="'+e(t.message)+'" source="'+a(t.rule)+'"/>')}),o.push("</file>")),o.join("")}})}(),i.addFormatter({id:"compact",name:"Compact, 'porcelain' format",startFormat:function(){"use strict";return""},endFormat:function(){"use strict";return""},formatResults:function(e,t,r){"use strict";var n=e.messages,o="";r=r||{};var a=function(e){return e.charAt(0).toUpperCase()+e.slice(1)};return 0===n.length?r.quiet?"":t+": Lint Free!":(i.Util.forEach(n,function(e){o+=e.rollup?t+": "+a(e.type)+" - "+e.message+" ("+e.rule.id+")\n":t+": line "+e.line+", col "+e.col+", "+a(e.type)+" - "+e.message+" ("+e.rule.id+")\n"}),o)}}),i.addFormatter({id:"csslint-xml",name:"CSSLint XML format",startFormat:function(){"use strict";return'<?xml version="1.0" encoding="utf-8"?><csslint>'},endFormat:function(){"use strict";return"</csslint>"},formatResults:function(e,t){"use strict";var r=e.messages,n=[],o=function(e){return e&&e.constructor===String?e.replace(/"/g,"'").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"):""};return r.length>0&&(n.push('<file name="'+t+'">'),i.Util.forEach(r,function(e){e.rollup?n.push('<issue severity="'+e.type+'" reason="'+o(e.message)+'" evidence="'+o(e.evidence)+'"/>'):n.push('<issue line="'+e.line+'" char="'+e.col+'" severity="'+e.type+'" reason="'+o(e.message)+'" evidence="'+o(e.evidence)+'"/>')}),n.push("</file>")),n.join("")}}),i.addFormatter({id:"json",name:"JSON",startFormat:function(){"use strict";return this.json=[],""},endFormat:function(){"use strict";var e="";return this.json.length>0&&(e=1===this.json.length?JSON.stringify(this.json[0]):JSON.stringify(this.json)),e},formatResults:function(e,t,r){"use strict";return(e.messages.length>0||!r.quiet)&&this.json.push({filename:t,messages:e.messages,stats:e.stats}),""}}),i.addFormatter({id:"junit-xml",name:"JUNIT XML format",startFormat:function(){"use strict";return'<?xml version="1.0" encoding="utf-8"?><testsuites>'},endFormat:function(){"use strict";return"</testsuites>"},formatResults:function(e,t){"use strict";var r=e.messages,n=[],i={error:0,failure:0},o=function(e){return e&&"name"in e?"net.csslint."+e.name.replace(/\s/g,""):""},a=function(e){return e&&e.constructor===String?e.replace(/"/g,"'").replace(/</g,"&lt;").replace(/>/g,"&gt;"):""};return r.length>0&&(r.forEach(function(e){var t="warning"===e.type?"error":e.type;e.rollup||(n.push('<testcase time="0" name="'+o(e.rule)+'">'),n.push("<"+t+' message="'+a(e.message)+'"><![CDATA['+e.line+":"+e.col+":"+a(e.evidence)+"]]></"+t+">"),n.push("</testcase>"),i[t]+=1)}),n.unshift('<testsuite time="0" tests="'+r.length+'" skipped="0" errors="'+i.error+'" failures="'+i.failure+'" package="net.csslint" name="'+t+'">'),n.push("</testsuite>")),n.join("")}}),i.addFormatter({id:"lint-xml",name:"Lint XML format",startFormat:function(){"use strict";return'<?xml version="1.0" encoding="utf-8"?><lint>'},endFormat:function(){"use strict";return"</lint>"},formatResults:function(e,t){"use strict";var r=e.messages,n=[],o=function(e){return e&&e.constructor===String?e.replace(/"/g,"'").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"):""};return r.length>0&&(n.push('<file name="'+t+'">'),i.Util.forEach(r,function(e){if(e.rollup)n.push('<issue severity="'+e.type+'" reason="'+o(e.message)+'" evidence="'+o(e.evidence)+'"/>');else{var t="";e.rule&&e.rule.id&&(t='rule="'+o(e.rule.id)+'" '),n.push("<issue "+t+'line="'+e.line+'" char="'+e.col+'" severity="'+e.type+'" reason="'+o(e.message)+'" evidence="'+o(e.evidence)+'"/>')}}),n.push("</file>")),n.join("")}}),i.addFormatter({id:"text",name:"Plain Text",startFormat:function(){"use strict";return""},endFormat:function(){"use strict";return""},formatResults:function(e,t,r){"use strict";var n=e.messages,o="";if(r=r||{},0===n.length)return r.quiet?"":"\n\ncsslint: No errors in "+t+".";o="\n\ncsslint: There ",o+=1===n.length?"is 1 problem":"are "+n.length+" problems",o+=" in "+t+".";var a=t.lastIndexOf("/"),s=t;return a===-1&&(a=t.lastIndexOf("\\")),a>-1&&(s=t.substring(a+1)),i.Util.forEach(n,function(e,t){o=o+"\n\n"+s,e.rollup?(o+="\n"+(t+1)+": "+e.type,o+="\n"+e.message):(o+="\n"+(t+1)+": "+e.type+" at line "+e.line+", col "+e.col,o+="\n"+e.message,o+="\n"+e.evidence)}),o}}),i}();
js/editor.js CHANGED
@@ -443,7 +443,7 @@
443
 
444
  this.$( '#preview-iframe' )
445
  .attr( 'src', socssOptions.homeURL )
446
- .load(function () {
447
  var $$ = $(this);
448
 
449
  // Update the current URI with the iframe URI
@@ -984,6 +984,9 @@
984
  for (var j = 0; j < rule.rules.length; j++) {
985
  var mediaRule = '@media ' + rule.media;
986
  var subRule = rule.rules[j];
 
 
 
987
  dropdown.append(
988
  $('<option>')
989
  .html( mediaRule + ': ' + subRule.selectors.join(',') )
443
 
444
  this.$( '#preview-iframe' )
445
  .attr( 'src', socssOptions.homeURL )
446
+ .on( 'load', function () {
447
  var $$ = $(this);
448
 
449
  // Update the current URI with the iframe URI
984
  for (var j = 0; j < rule.rules.length; j++) {
985
  var mediaRule = '@media ' + rule.media;
986
  var subRule = rule.rules[j];
987
+ if(subRule.type != 'rule') {
988
+ continue;
989
+ }
990
  dropdown.append(
991
  $('<option>')
992
  .html( mediaRule + ': ' + subRule.selectors.join(',') )
js/editor.min.js CHANGED
@@ -1 +1 @@
1
- !function(e,t,i){var s={model:{},collection:{},view:{},fn:{}};window.socss=s,s.view.toolbar=Backbone.View.extend({button:t.template('<li><a href="#" class="toolbar-button socss-button"><%= text %></a></li>'),editor:null,initialize:function(t){this.editor=t.editor;var i=this;this.$(".editor-expand").click(function(t){t.preventDefault(),e(this).blur(),i.trigger("click_expand")}),this.$(".editor-visual").click(function(t){t.preventDefault(),e(this).blur(),i.trigger("click_visual")})},addButton:function(t,i){var s=this,r=e(this.button({text:t})).appendTo(this.$(".toolbar-function-buttons .toolbar-buttons")).click(function(t){t.preventDefault(),e(this).blur(),s.trigger("click_"+i)});return r}}),s.view.editor=Backbone.View.extend({codeMirror:null,snippets:null,toolbar:null,visualProperties:null,inspector:null,cssSelectors:[],initialize:function(e){this.setupEditor()},render:function(){var t=this;this.toolbar=new s.view.toolbar({editor:this,el:this.$(".custom-css-toolbar")}),this.toolbar.editor=this,this.toolbar.render(),this.visualProperties=new s.view.properties({editor:this,el:e("#so-custom-css-properties")}),this.visualProperties.render(),this.toolbar.on("click_expand",function(){t.toggleExpand()}),this.toolbar.on("click_visual",function(){t.visualProperties.loadCSS(t.codeMirror.getValue().trim()),t.visualProperties.show()}),this.preview=new s.view.preview({editor:this,el:this.$(".custom-css-preview")}),this.preview.render()},setupEditor:function(){var t=this;this.registerCodeMirrorAutocomplete();for(var s=this.$("textarea.css-editor"),r=s.val(),n=r.match(/\n/gm),o=n?n.length+1:1,a=15-o,l=r,c=0;c<a;c++)l+="\n";s.val(l),this.codeMirror=CodeMirror.fromTextArea(s.get(0),{tabSize:2,lineNumbers:!0,mode:"css",theme:"neat",inputStyle:"contenteditable",gutters:["CodeMirror-lint-markers"],lint:!0}),this.$el.on("submit",function(){r=t.codeMirror.getValue().trim()}),e(window).bind("beforeunload",function(){var e=t.codeMirror.getValue().trim();if(e!==r)return i.loc.leave}),this.$el.find(".custom-css-container").css("overflow","visible"),this.scaleEditor(),e(window).resize(function(){t.scaleEditor()}),this.setupCodeMirrorExtensions()},registerCodeMirrorAutocomplete:function(){var e=this,t={link:1,visited:1,active:1,hover:1,focus:1,"first-letter":1,"first-line":1,"first-child":1,before:1,after:1,lang:1};CodeMirror.registerHelper("hint","css",function(i){function s(e){for(var t in e)c&&0!==t.lastIndexOf(c,0)||d.push(t)}var r=i.getCursor(),n=i.getTokenAt(r),o=CodeMirror.innerMode(i.getMode(),n.state);if("css"===o.mode.name){if("keyword"===n.type&&0==="!important".indexOf(n.string))return{list:["!important"],from:CodeMirror.Pos(r.line,n.start),to:CodeMirror.Pos(r.line,n.end)};var a=n.start,l=r.ch,c=n.string.slice(0,l-a);/[^\w$_-]/.test(c)&&(c="",a=l=r.ch);var p=CodeMirror.resolveMode("text/css"),d=[],h=o.state.state;if("top"===h){for(var u=i.getLine(r.line).trim(),v=e.cssSelectors,f=0;f<v.length;f++)v[f].selector.indexOf(u)!==-1&&d.push(v[f].selector);if(d.length)return{list:d,from:CodeMirror.Pos(r.line,0),to:CodeMirror.Pos(r.line,l)}}else if("pseudo"===h||"variable-3"===n.type?s(t):"block"===h||"maybeprop"===h?s(p.propertyKeywords):"prop"===h||"parens"===h||"at"===h||"params"===h?(s(p.valueKeywords),s(p.colorKeywords)):"media"!==h&&"media_parens"!==h||(s(p.mediaTypes),s(p.mediaFeatures)),d.length)return{list:d,from:CodeMirror.Pos(r.line,a),to:CodeMirror.Pos(r.line,l)}}})},setupCodeMirrorExtensions:function(){var e=this;this.codeMirror.on("cursorActivity",function(t){var i=t.getCursor(),s=t.getTokenAt(i);CodeMirror.innerMode(t.getMode(),s.state);if("qualifier"===s.type||"tag"===s.type||"builtin"===s.type){var r=t.getLine(i.line),n=r.substring(0,s.end);e.preview.highlight(n)}else e.preview.clearHighlight()}),this.codeMirror.on("keyup",function(e,t){(t.keyCode>=65&&t.keyCode<=90||189===t.keyCode&&!t.shiftKey||190===t.keyCode&&!t.shiftKey||51===t.keyCode&&t.shiftKey||189===t.keyCode&&t.shiftKey)&&e.showHint({completeSingle:!1})})},scaleEditor:function(){this.$el.hasClass("expanded")?this.codeMirror.setSize("100%",e(window).outerHeight()-this.$(".custom-css-toolbar").outerHeight()):this.codeMirror.setSize("100%","auto")},isExpanded:function(){return this.$el.hasClass("expanded")},toggleExpand:function(){this.$el.toggleClass("expanded"),this.scaleEditor()},setExpand:function(e){e?this.$el.addClass("expanded"):this.$el.removeClass("expanded"),this.scaleEditor()},setSnippets:function(e){if(!t.isEmpty(e)){var i=this;this.snippets=new s.view.snippets({snippets:e}),this.snippets.editor=this,this.snippets.render(),this.toolbar.addButton("Snippets","snippets"),this.toolbar.on("click_snippets",function(){i.snippets.show()})}},addCode:function(e){var t=this.codeMirror,i="";i=1===t.doc.lineCount()&&0===t.doc.getLine(t.doc.lastLine()).length?"":0===t.doc.getLine(t.doc.lastLine()).length?"\n":"\n\n",t.doc.setCursor(t.doc.lastLine(),t.doc.getLine(t.doc.lastLine()).length),t.doc.replaceSelection(i+e)},addEmptySelector:function(e){this.addCode(e+" {\n \n}")},setInspector:function(e){var t=this;this.inspector=e,this.cssSelectors=e.pageSelectors,e.on("click_selector",function(e){t.visualProperties.isVisible()?t.visualProperties.addSelector(e):t.addEmptySelector(e)}),e.on("click_property",function(e){t.visualProperties.isVisible()||t.codeMirror.replaceSelection(e+";\n ")}),e.on("set_active_element",function(e,i){t.visualProperties.isVisible()&&i.length&&t.visualProperties.addSelector(i[0].selector)})}}),s.view.preview=Backbone.View.extend({template:t.template(e("#template-preview-window").html()),editor:null,originalUri:null,currentUri:null,initialize:function(e){this.editor=e.editor;var t=this;this.editor.codeMirror.on("change",function(e,i){t.updatePreviewCss()})},render:function(){var t=this;this.$el.html(this.template()),this.$("#preview-iframe").attr("src",i.homeURL).load(function(){var i=e(this);t.currentUri=new URI(i.contents().get(0).location.href),t.currentUri.removeQuery("so_css_preview"),t.$("#preview-navigator input").val(t.currentUri.toString()),t.currentUri.addQuery("so_css_preview",1),i.contents().find("a").each(function(){var t=e(this).attr("href");if(void 0===t)return!0;var i=t.indexOf("?")===-1?"?":"&";e(this).attr("href",t+i+"so_css_preview=1")}),t.updatePreviewCss()}).mouseleave(function(){t.clearHighlight()}),this.$("#preview-navigator input").keydown(function(i){var s=e(this);if(13==i.keyCode){i.preventDefault();var r=new URI(s.val());t.originalUri.host()!==r.host()||t.originalUri.protocol()!==r.protocol()?(s.blur(),alert(s.data("invalid-uri")),s.focus()):(r.addQuery("so_css_preview",1),t.$("#preview-iframe").attr("src",r.toString()))}}),this.originalUri=new URI(i.homeURL),this.currentUri=new URI(i.homeURL),this.currentUri.removeQuery("so_css_preview"),this.$("#preview-navigator input").val(this.currentUri.toString()),this.currentUri.addQuery("so_css_preview",1)},updatePreviewCss:function(){var e=this.$("#preview-iframe");if(0!==e.length){var t=e.contents().find("head");0===t.find("style.siteorigin-custom-css").length&&t.append('<style class="siteorigin-custom-css" type="text/css"></style>');var i=t.find("style.siteorigin-custom-css"),s=this.editor.codeMirror.getValue().trim();i.html(s)}},highlight:function(e){try{this.editor.inspector.hl.highlight(e)}catch(e){console.log("No inspector to highlight with")}},clearHighlight:function(){try{this.editor.inspector.hl.clear()}catch(e){console.log("No inspector to highlight with")}}}),s.view.snippets=Backbone.View.extend({template:t.template(e("#template-snippet-browser").html()),snippet:t.template('<li class="snippet"><%- name %></li>'),className:"css-editor-snippet-browser",snippets:null,editor:null,events:{"click .close":"hide","click .buttons .insert-snippet":"insertSnippet"},currentSnippet:null,initialize:function(e){this.snippets=e.snippets},render:function(){var t=this,i=function(i){i.preventDefault();var s=e(this);t.$(".snippets li.snippet").removeClass("active"),e(this).addClass("active"),t.viewSnippet({name:s.html(),description:s.data("description"),css:s.data("css")})};this.$el.html(this.template());for(var s=0;s<this.snippets.length;s++)e(this.snippet({name:this.snippets[s].Name})).data({description:this.snippets[s].Description,css:this.snippets[s].css}).appendTo(this.$("ul.snippets")).click(i);return t.$(".snippets li.snippet").eq(0).click(),this.attach(),this},viewSnippet:function(e){var t=this.$(".main .snippet-view");t.find(".snippet-title").html(e.name),t.find(".snippet-description").html(e.description),t.find(".snippet-code").html(e.css),this.currentSnippet=e},insertSnippet:function(){var e=this.editor.codeMirror,t=this.currentSnippet.css,i="";i=1===e.doc.lineCount()&&0===e.doc.getLine(e.doc.lastLine()).length?"":0===e.doc.getLine(e.doc.lastLine()).length?"\n":"\n\n",e.doc.setCursor(e.doc.lastLine(),e.doc.getLine(e.doc.lastLine()).length),e.doc.replaceSelection(i+t),this.hide()},attach:function(){this.$el.appendTo("body")},show:function(){this.$el.show()},hide:function(){this.$el.hide()}}),s.view.properties=Backbone.View.extend({model:s.model.cssRules,tabTemplate:t.template('<li data-section="<%- id %>"><span class="fa fa-<%- icon %>"></span> <%- title %></li>'),sectionTemplate:t.template('<div class="section" data-section="<%- id %>"><table class="fields-table"><tbody></tbody></table></div>'),controllerTemplate:t.template('<tr><th scope="row"><%- title %></th><td></td></tr>'),propertyControllers:[],editor:null,css:"",parsed:{},activeSelector:"",editorExpandedBefore:!1,events:{"click .close":"hide"},initialize:function(e){this.parser=window.css,this.editor=e.editor},render:function(){var r=this;this.$(".section-tabs").empty(),this.$(".sections").empty(),this.$(".toolbar select").off(),r.propertyControllers=[];var n=i.propertyControllers;for(var o in n){var a=(e(this.tabTemplate({id:o,icon:n[o].icon,title:n[o].title})).appendTo(this.$(".section-tabs")),e(this.sectionTemplate({id:o})).appendTo(this.$(".sections")));if(!t.isEmpty(n[o].controllers))for(var l=0;l<n[o].controllers.length;l++){var c,p=e(r.controllerTemplate({title:n[o].controllers[l].title})).appendTo(a.find("tbody")),d=n[o].controllers[l];c="undefined"==typeof s.view.properties.controllers[d.type]?new s.view.propertyController({el:p.find("td"),propertiesView:r,args:"undefined"==typeof d.args?{}:d.args}):new s.view.properties.controllers[d.type]({el:p.find("td"),propertiesView:r,args:"undefined"==typeof d.args?{}:d.args}),r.propertyControllers.push(c),c.render(),c.initChangeEvents()}}this.$(".section-tabs li").click(function(){var t=e(this),i=r.$('.sections .section[data-section="'+t.data("section")+'"]');r.$(".sections .section").not(i).hide().removeClass("active"),i.show().addClass("active"),r.$(".section-tabs li").not(t).removeClass("active"),t.addClass("active")}).eq(0).click(),this.$(".toolbar select").change(function(){r.setActivateSelector(e(this).find(":selected").data("selector"))})},setRuleValue:function(e,i){if("undefined"!=typeof this.activeSelector&&"undefined"!=typeof this.activeSelector.declarations){for(var s=this.activeSelector.declarations,r=!0,n=!1,o=0;o<s.length;o++)if(s[o].property===e){r=!1;var a=s[o];a.value!==i&&(a.value=i,n=!0),t.isEmpty(a.value)&&s.splice(s.indexOf(a));break}r&&!t.isEmpty(i)&&(s.push({property:e,value:i,type:"declaration"}),n=!0),n&&this.updateMainEditor(!1)}},addImport:function(e){var i=t.filter(this.parsed.stylesheet.rules,function(e){return"import"===e.type}),s=t.any(i,function(t){return t.import===e.import});s||(this.parsed.stylesheet.rules.unshift(e),this.updateMainEditor(!1))},findImport:function(e){return t.find(this.parsed.stylesheet.rules,function(t){return"import"===t.type&&t.import.indexOf(e)>-1})},updateImport:function(e,t){var i=this.findImport(e);i.import!==t.import&&(i.import=t.import,this.updateMainEditor(!1))},removeImport:function(e){var i=t.findIndex(this.parsed.stylesheet.rules,function(t){return"import"===t.type&&t.import.indexOf(e)>-1});i>-1&&this.parsed.stylesheet.rules.splice(i,1)},getRuleValue:function(e){if("undefined"==typeof this.activeSelector||"undefined"==typeof this.activeSelector.declarations)return"";for(var t=this.activeSelector.declarations,i=0;i<t.length;i++)if(t[i].property===e)return t[i].value;return""},updateMainEditor:function(e){this.editor.codeMirror.setValue(this.parser.stringify(this.parsed))},show:function(){this.editorExpandedBefore=this.editor.isExpanded(),this.editor.setExpand(!0),this.$el.show().animate({left:0},"fast")},hide:function(){this.editor.setExpand(this.editorExpandedBefore),this.$el.animate({left:-338},"fast",function(){e(this).hide()}),this.updateMainEditor(!0)},isVisible:function(){return this.$el.is(":visible")},loadCSS:function(i,s){this.css=i,this.parsed=this.parser.parse(i,{silent:!0});for(var r=this.parsed.stylesheet.rules,n=this.$(".toolbar select").empty(),o=0;o<r.length;o++){var a=r[o];if(t.contains(["rule","media"],a.type))if("media"===a.type)for(var l=0;l<a.rules.length;l++){var c="@media "+a.media,p=a.rules[l];n.append(e("<option>").html(c+": "+p.selectors.join(",")).attr("val",c+": "+p.selectors.join(",")).data("selector",p))}else n.append(e("<option>").html(a.selectors.join(",")).attr("val",a.selectors.join(",")).data("selector",a))}"undefined"==typeof s&&(s=n.find("option").eq(0).attr("val")),t.isEmpty(s)||n.val(s).change()},setActivateSelector:function(e){this.activeSelector=e;for(var t=0;t<this.propertyControllers.length;t++)this.propertyControllers[t].refreshFromRule()},addSelector:function(e){var t=this.$(".toolbar select");t.val(e),t.val()===e?t.change():(this.editor.addEmptySelector(e),this.loadCSS(this.editor.codeMirror.getValue().trim(),e)),t.addClass("highlighted"),setTimeout(function(){t.removeClass("highlighted")},2e3)}}),s.view.propertyController=Backbone.View.extend({template:t.template('<input type="text" value="" />'),activeRule:null,args:null,propertiesView:null,initialize:function(e){this.args=e.args,this.propertiesView=e.propertiesView,this.on("set_value",this.updateRule,this),this.on("change",this.updateRule,this)},render:function(){this.$el.append(e(this.template({}))),this.field=this.$("input")},initChangeEvents:function(){var t=this;this.field.on("change keyup",function(){t.trigger("change",e(this).val())})},updateRule:function(){this.propertiesView.setRuleValue(this.args.property,this.getValue())},refreshFromRule:function(){var e=this.propertiesView.getRuleValue(this.args.property);this.setValue(e,{silent:!0})},getValue:function(){return this.field.val()},setValue:function(e,i){i=t.extend({silent:!1},i),this.field.val(e),i.silent||this.trigger("set_value",e)},reset:function(e){e=t.extend({silent:!1},e),this.setValue("",e)}}),s.view.properties.controllers={},s.view.properties.controllers.color=s.view.propertyController.extend({template:t.template('<input type="text" value="" />'),render:function(){this.$el.append(e(this.template({}))),this.field=this.$el.find("input"),this.field.minicolors({})},initChangeEvents:function(){var e=this;this.field.on("change keyup",function(){e.trigger("change",e.field.minicolors("value"))})},getValue:function(){return this.field.minicolors("value").trim()},setValue:function(e,i){i=t.extend({silent:!1},i),this.field.minicolors("value",e),i.silent||this.trigger("set_value",e)}}),s.view.properties.controllers.select=s.view.propertyController.extend({template:t.template("<select></select>"),render:function(){this.$el.append(e(this.template({}))),this.field=this.$el.find("select"),this.field.append(e('<option value=""></option>').html(""));for(var t in this.args.options)this.field.append(e("<option></option>").attr("value",t).html(this.args.options[t]));"undefined"!=typeof this.args.option_icons&&this.setupVisualSelect()},setupVisualSelect:function(){var t=this;this.field.hide();var i=e('<div class="select-tabs"></div>').appendTo(this.$el);e('<div class="select-tab" data-value=""><span class="fa fa-circle-o"></span></div>').appendTo(i);for(var s in this.args.option_icons)e('<div class="select-tab"></div>').appendTo(i).append(e('<span class="fa"></span>').addClass("fa-"+this.args.option_icons[s])).attr("data-value",s);i.find(".select-tab").css("width",100/i.find(">div").length+"%").click(function(){var s=e(this);i.find(".select-tab").removeClass("active"),s.addClass("active"),t.field.val(s.data("value")).change()})},setValue:function(e,i){i=t.extend({silent:!1},i),this.field.val(e),this.$(".select-tabs .select-tab").removeClass("active").filter('[data-value="'+e+'"]').addClass("active"),i.silent||this.trigger("set_value",e)}}),s.view.properties.controllers.image=s.view.propertyController.extend({template:t.template('<input type="text" value="" /> <span class="select socss-button"><span class="fa fa-upload"></span></span>'),render:function(){var t=this;this.media=wp.media({title:i.loc.select_image,library:{type:"image"},button:{text:i.loc.select,close:!1}}),this.$el.append(e(this.template({select:i.loc.select}))),this.field=this.$el.find("input"),this.$(".select").click(function(){t.media.open()}),this.media.on("select",function(){var e=this.state().get("selection").first().attributes,i=t.args.value.replace("{{url}}",e.url);t.field.val(i).change(),t.media.close()},this.media)}}),s.view.properties.controllers.measurement=s.view.propertyController.extend({wrapperClass:"socss-field-measurement",render:function(){this.$el.append(e(this.template({}))),this.field=this.$("input"),this.setupMeasurementField(this.field,{})},setValue:function(e,i){i=t.extend({silent:!1},i),this.field.val(e).trigger("measurement_refresh"),i.silent||this.trigger("set_value",e)},units:["px","%","em","cm","mm","in","pt","pc","ex","ch","rem","vw","vh","vmin","vmax"],parseUnits:function(e){var t=function(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")},i=this.units.map(t),s=new RegExp("([0-9\\.\\-]+)("+i.join("|")+")?","i"),r=s.exec(e);return null===r?{value:"",unit:""}:{value:r[1],unit:void 0===r[2]?"":r[2]}},setupMeasurementField:function(i,s){var r=this,n=i.parent();s=t.extend({defaultUnit:"px"},s),i.hide(),n.addClass(this.wrapperClass).data("unit",s.defaultUnit);for(var o=e('<input type="text" class="socss-field-input"/>').appendTo(n),a=e('<span class="dashicons dashicons-arrow-down"></span>').appendTo(n),l=e('<ul class="dropdown"></ul>').appendTo(n),c=e('<span class="units"></span>').html(s.defaultUnit).appendTo(n),p=0;p<r.units.length;p++){var d=e("<li></li>").html(r.units[p]).data("unit",r.units[p]);r.units[p]===s.defaultUnit&&d.addClass("active"),l.append(d)}var h=function(){var e=r.parseUnits(o.val());""!==e.unit&&e.unit!==n.data("unit")&&(o.val(e.value),u(e.unit)),""===e.value?i.val(""):i.val(e.value+n.data("unit"))},u=function(e){c.html(e),n.data("unit",e),o.trigger("keydown")};a.click(function(){l.toggle()}),l.find("li").click(function(){l.toggle(),u(e(this).data("unit")),h(),i.trigger("change")}),o.on("keyup keydown",function(t){var i=(e(this),"");"keydown"===t.type&&(t.keyCode>=48&&t.keyCode<=57?i=String.fromCharCode(t.keyCode):189===t.keyCode?i="-":190===t.keyCode&&(i="."));var s=e('<span class="socss-hidden-placeholder"></span>').css({"font-size":"14px"}).html(o.val()+i).appendTo("body"),r=s.width();r=Math.min(r,63),s.remove(),c.css("left",r+12)}),o.on("keyup",function(e){h(),i.trigger("change")}),i.on("measurement_refresh",function(){var t=r.parseUnits(i.val());o.val(t.value);var a=""===t.unit?s.defaultUnit:t.unit;n.data("unit",a),c.html(a);var l=e('<span class="socss-hidden-placeholder"></span>').css({"font-size":"14px"}).html(t.value).appendTo("body"),p=l.width();p=Math.min(p,63),l.remove(),c.css("left",p+12)});var v=e('<div class="socss-diw"></div>').appendTo(n),f=e('<div class="dec-button socss-button"><span class="fa fa-minus"></span></div>').appendTo(v),m=e('<div class="inc-button socss-button"><span class="fa fa-plus"></span></div>').appendTo(v);m.click(function(){var e=r.parseUnits(i.val());if(""===e.value)return!0;var t=Math.ceil(1.05*e.value);o.val(t),h(),i.trigger("change").trigger("measurement_refresh")}),f.click(function(){var e=r.parseUnits(i.val());if(""===e.value)return!0;var t=Math.floor(e.value/1.05);o.val(t),h(),i.trigger("change").trigger("measurement_refresh")})}}),s.view.properties.controllers.number=s.view.propertyController.extend({render:function(){this.$el.append(e(this.template({}))),this.field=this.$("input"),this.setupNumberField(this.field,this.args)},setupNumberField:function(i,s){s=t.extend({change:null,default:0,increment:1,decrement:-1,max:null,min:null},s);var r=i.parent();r.addClass("socss-field-number");var n=e('<div class="socss-diw"></div>').appendTo(r),o=e('<div class="dec-button socss-button">-</div>').appendTo(n);e('<div class="inc-button socss-button">+</div>').appendTo(n);return n.find("> div").click(function(t){t.preventDefault();var r=s.default;""!==i.val()&&(r=Number(i.val())),r+=e(this).is(o)?s.decrement:s.increment,r=Math.round(100*r)/100,null!==s.max&&(r=Math.min(s.max,r)),null!==s.min&&(r=Math.max(s.min,r)),i.val(r),i.trigger("change")}),this}}),s.view.properties.controllers.sides=s.view.propertyController.extend({template:t.template(e("#template-sides-field").html().trim()),controllers:[],render:function(){var i=this;this.$el.append(e(this.template({}))),this.field=this.$el.find("input"),i.args.hasAll||(this.$(".select-tab").eq(0).remove(),this.$(".select-tab").css("width","25%")),this.$(".select-tab").each(function(){for(var r=e(this).data("direction"),n=e('<li class="side">').appendTo(i.$(".sides")).hide(),o=0;o<i.args.controllers.length;o++){var a=i.args.controllers[o],l="";l="all"===r?a.args.propertyAll:a.args.property.replace("{dir}",r);var c=t.extend({},a.args,{property:l}),p=new s.view.properties.controllers[a.type]({el:e("<div>").appendTo(n),propertiesView:i.propertiesView,args:c});p.render(),p.initChangeEvents(),i.propertiesView.propertyControllers.push(p)}e(this).on("click",function(){i.$(".select-tab").removeClass("active"),e(this).addClass("active"),i.$(".sides .side").hide(),n.show()})}),this.$(".select-tab").eq(0).click()}})}(jQuery,_,socssOptions),jQuery(function(e){var t=window.socss,i=new t.view.editor({el:e("#so-custom-css-form").get(0)});i.render(),i.setSnippets(socssOptions.snippets),window.socss.mainEditor=i,e("#so-custom-css-getting-started a.hide").click(function(t){t.preventDefault(),e("#so-custom-css-getting-started").slideUp(),e.get(e(this).attr("href"))})});
1
+ !function(e,t,i){var s={model:{},collection:{},view:{},fn:{}};window.socss=s,s.view.toolbar=Backbone.View.extend({button:t.template('<li><a href="#" class="toolbar-button socss-button"><%= text %></a></li>'),editor:null,initialize:function(t){this.editor=t.editor;var i=this;this.$(".editor-expand").click(function(t){t.preventDefault(),e(this).blur(),i.trigger("click_expand")}),this.$(".editor-visual").click(function(t){t.preventDefault(),e(this).blur(),i.trigger("click_visual")})},addButton:function(t,i){var s=this,r=e(this.button({text:t})).appendTo(this.$(".toolbar-function-buttons .toolbar-buttons")).click(function(t){t.preventDefault(),e(this).blur(),s.trigger("click_"+i)});return r}}),s.view.editor=Backbone.View.extend({codeMirror:null,snippets:null,toolbar:null,visualProperties:null,inspector:null,cssSelectors:[],initialize:function(e){this.setupEditor()},render:function(){var t=this;this.toolbar=new s.view.toolbar({editor:this,el:this.$(".custom-css-toolbar")}),this.toolbar.editor=this,this.toolbar.render(),this.visualProperties=new s.view.properties({editor:this,el:e("#so-custom-css-properties")}),this.visualProperties.render(),this.toolbar.on("click_expand",function(){t.toggleExpand()}),this.toolbar.on("click_visual",function(){t.visualProperties.loadCSS(t.codeMirror.getValue().trim()),t.visualProperties.show()}),this.preview=new s.view.preview({editor:this,el:this.$(".custom-css-preview")}),this.preview.render()},setupEditor:function(){var t=this;this.registerCodeMirrorAutocomplete();for(var s=this.$("textarea.css-editor"),r=s.val(),n=r.match(/\n/gm),o=n?n.length+1:1,a=15-o,l=r,c=0;c<a;c++)l+="\n";s.val(l),this.codeMirror=CodeMirror.fromTextArea(s.get(0),{tabSize:2,lineNumbers:!0,mode:"css",theme:"neat",inputStyle:"contenteditable",gutters:["CodeMirror-lint-markers"],lint:!0}),this.$el.on("submit",function(){r=t.codeMirror.getValue().trim()}),e(window).bind("beforeunload",function(){var e=t.codeMirror.getValue().trim();if(e!==r)return i.loc.leave}),this.$el.find(".custom-css-container").css("overflow","visible"),this.scaleEditor(),e(window).resize(function(){t.scaleEditor()}),this.setupCodeMirrorExtensions()},registerCodeMirrorAutocomplete:function(){var e=this,t={link:1,visited:1,active:1,hover:1,focus:1,"first-letter":1,"first-line":1,"first-child":1,before:1,after:1,lang:1};CodeMirror.registerHelper("hint","css",function(i){function s(e){for(var t in e)c&&0!==t.lastIndexOf(c,0)||d.push(t)}var r=i.getCursor(),n=i.getTokenAt(r),o=CodeMirror.innerMode(i.getMode(),n.state);if("css"===o.mode.name){if("keyword"===n.type&&0==="!important".indexOf(n.string))return{list:["!important"],from:CodeMirror.Pos(r.line,n.start),to:CodeMirror.Pos(r.line,n.end)};var a=n.start,l=r.ch,c=n.string.slice(0,l-a);/[^\w$_-]/.test(c)&&(c="",a=l=r.ch);var p=CodeMirror.resolveMode("text/css"),d=[],h=o.state.state;if("top"===h){for(var u=i.getLine(r.line).trim(),v=e.cssSelectors,f=0;f<v.length;f++)v[f].selector.indexOf(u)!==-1&&d.push(v[f].selector);if(d.length)return{list:d,from:CodeMirror.Pos(r.line,0),to:CodeMirror.Pos(r.line,l)}}else if("pseudo"===h||"variable-3"===n.type?s(t):"block"===h||"maybeprop"===h?s(p.propertyKeywords):"prop"===h||"parens"===h||"at"===h||"params"===h?(s(p.valueKeywords),s(p.colorKeywords)):"media"!==h&&"media_parens"!==h||(s(p.mediaTypes),s(p.mediaFeatures)),d.length)return{list:d,from:CodeMirror.Pos(r.line,a),to:CodeMirror.Pos(r.line,l)}}})},setupCodeMirrorExtensions:function(){var e=this;this.codeMirror.on("cursorActivity",function(t){var i=t.getCursor(),s=t.getTokenAt(i);CodeMirror.innerMode(t.getMode(),s.state);if("qualifier"===s.type||"tag"===s.type||"builtin"===s.type){var r=t.getLine(i.line),n=r.substring(0,s.end);e.preview.highlight(n)}else e.preview.clearHighlight()}),this.codeMirror.on("keyup",function(e,t){(t.keyCode>=65&&t.keyCode<=90||189===t.keyCode&&!t.shiftKey||190===t.keyCode&&!t.shiftKey||51===t.keyCode&&t.shiftKey||189===t.keyCode&&t.shiftKey)&&e.showHint({completeSingle:!1})})},scaleEditor:function(){this.$el.hasClass("expanded")?this.codeMirror.setSize("100%",e(window).outerHeight()-this.$(".custom-css-toolbar").outerHeight()):this.codeMirror.setSize("100%","auto")},isExpanded:function(){return this.$el.hasClass("expanded")},toggleExpand:function(){this.$el.toggleClass("expanded"),this.scaleEditor()},setExpand:function(e){e?this.$el.addClass("expanded"):this.$el.removeClass("expanded"),this.scaleEditor()},setSnippets:function(e){if(!t.isEmpty(e)){var i=this;this.snippets=new s.view.snippets({snippets:e}),this.snippets.editor=this,this.snippets.render(),this.toolbar.addButton("Snippets","snippets"),this.toolbar.on("click_snippets",function(){i.snippets.show()})}},addCode:function(e){var t=this.codeMirror,i="";i=1===t.doc.lineCount()&&0===t.doc.getLine(t.doc.lastLine()).length?"":0===t.doc.getLine(t.doc.lastLine()).length?"\n":"\n\n",t.doc.setCursor(t.doc.lastLine(),t.doc.getLine(t.doc.lastLine()).length),t.doc.replaceSelection(i+e)},addEmptySelector:function(e){this.addCode(e+" {\n \n}")},setInspector:function(e){var t=this;this.inspector=e,this.cssSelectors=e.pageSelectors,e.on("click_selector",function(e){t.visualProperties.isVisible()?t.visualProperties.addSelector(e):t.addEmptySelector(e)}),e.on("click_property",function(e){t.visualProperties.isVisible()||t.codeMirror.replaceSelection(e+";\n ")}),e.on("set_active_element",function(e,i){t.visualProperties.isVisible()&&i.length&&t.visualProperties.addSelector(i[0].selector)})}}),s.view.preview=Backbone.View.extend({template:t.template(e("#template-preview-window").html()),editor:null,originalUri:null,currentUri:null,initialize:function(e){this.editor=e.editor;var t=this;this.editor.codeMirror.on("change",function(e,i){t.updatePreviewCss()})},render:function(){var t=this;this.$el.html(this.template()),this.$("#preview-iframe").attr("src",i.homeURL).on("load",function(){var i=e(this);t.currentUri=new URI(i.contents().get(0).location.href),t.currentUri.removeQuery("so_css_preview"),t.$("#preview-navigator input").val(t.currentUri.toString()),t.currentUri.addQuery("so_css_preview",1),i.contents().find("a").each(function(){var t=e(this).attr("href");if(void 0===t)return!0;var i=t.indexOf("?")===-1?"?":"&";e(this).attr("href",t+i+"so_css_preview=1")}),t.updatePreviewCss()}).mouseleave(function(){t.clearHighlight()}),this.$("#preview-navigator input").keydown(function(i){var s=e(this);if(13==i.keyCode){i.preventDefault();var r=new URI(s.val());t.originalUri.host()!==r.host()||t.originalUri.protocol()!==r.protocol()?(s.blur(),alert(s.data("invalid-uri")),s.focus()):(r.addQuery("so_css_preview",1),t.$("#preview-iframe").attr("src",r.toString()))}}),this.originalUri=new URI(i.homeURL),this.currentUri=new URI(i.homeURL),this.currentUri.removeQuery("so_css_preview"),this.$("#preview-navigator input").val(this.currentUri.toString()),this.currentUri.addQuery("so_css_preview",1)},updatePreviewCss:function(){var e=this.$("#preview-iframe");if(0!==e.length){var t=e.contents().find("head");0===t.find("style.siteorigin-custom-css").length&&t.append('<style class="siteorigin-custom-css" type="text/css"></style>');var i=t.find("style.siteorigin-custom-css"),s=this.editor.codeMirror.getValue().trim();i.html(s)}},highlight:function(e){try{this.editor.inspector.hl.highlight(e)}catch(t){console.log("No inspector to highlight with")}},clearHighlight:function(){try{this.editor.inspector.hl.clear()}catch(e){console.log("No inspector to highlight with")}}}),s.view.snippets=Backbone.View.extend({template:t.template(e("#template-snippet-browser").html()),snippet:t.template('<li class="snippet"><%- name %></li>'),className:"css-editor-snippet-browser",snippets:null,editor:null,events:{"click .close":"hide","click .buttons .insert-snippet":"insertSnippet"},currentSnippet:null,initialize:function(e){this.snippets=e.snippets},render:function(){var t=this,i=function(i){i.preventDefault();var s=e(this);t.$(".snippets li.snippet").removeClass("active"),e(this).addClass("active"),t.viewSnippet({name:s.html(),description:s.data("description"),css:s.data("css")})};this.$el.html(this.template());for(var s=0;s<this.snippets.length;s++)e(this.snippet({name:this.snippets[s].Name})).data({description:this.snippets[s].Description,css:this.snippets[s].css}).appendTo(this.$("ul.snippets")).click(i);return t.$(".snippets li.snippet").eq(0).click(),this.attach(),this},viewSnippet:function(e){var t=this.$(".main .snippet-view");t.find(".snippet-title").html(e.name),t.find(".snippet-description").html(e.description),t.find(".snippet-code").html(e.css),this.currentSnippet=e},insertSnippet:function(){var e=this.editor.codeMirror,t=this.currentSnippet.css,i="";i=1===e.doc.lineCount()&&0===e.doc.getLine(e.doc.lastLine()).length?"":0===e.doc.getLine(e.doc.lastLine()).length?"\n":"\n\n",e.doc.setCursor(e.doc.lastLine(),e.doc.getLine(e.doc.lastLine()).length),e.doc.replaceSelection(i+t),this.hide()},attach:function(){this.$el.appendTo("body")},show:function(){this.$el.show()},hide:function(){this.$el.hide()}}),s.view.properties=Backbone.View.extend({model:s.model.cssRules,tabTemplate:t.template('<li data-section="<%- id %>"><span class="fa fa-<%- icon %>"></span> <%- title %></li>'),sectionTemplate:t.template('<div class="section" data-section="<%- id %>"><table class="fields-table"><tbody></tbody></table></div>'),controllerTemplate:t.template('<tr><th scope="row"><%- title %></th><td></td></tr>'),propertyControllers:[],editor:null,css:"",parsed:{},activeSelector:"",editorExpandedBefore:!1,events:{"click .close":"hide"},initialize:function(e){this.parser=window.css,this.editor=e.editor},render:function(){var r=this;this.$(".section-tabs").empty(),this.$(".sections").empty(),this.$(".toolbar select").off(),r.propertyControllers=[];var n=i.propertyControllers;for(var o in n){var a=(e(this.tabTemplate({id:o,icon:n[o].icon,title:n[o].title})).appendTo(this.$(".section-tabs")),e(this.sectionTemplate({id:o})).appendTo(this.$(".sections")));if(!t.isEmpty(n[o].controllers))for(var l=0;l<n[o].controllers.length;l++){var c,p=e(r.controllerTemplate({title:n[o].controllers[l].title})).appendTo(a.find("tbody")),d=n[o].controllers[l];c="undefined"==typeof s.view.properties.controllers[d.type]?new s.view.propertyController({el:p.find("td"),propertiesView:r,args:"undefined"==typeof d.args?{}:d.args}):new s.view.properties.controllers[d.type]({el:p.find("td"),propertiesView:r,args:"undefined"==typeof d.args?{}:d.args}),r.propertyControllers.push(c),c.render(),c.initChangeEvents()}}this.$(".section-tabs li").click(function(){var t=e(this),i=r.$('.sections .section[data-section="'+t.data("section")+'"]');r.$(".sections .section").not(i).hide().removeClass("active"),i.show().addClass("active"),r.$(".section-tabs li").not(t).removeClass("active"),t.addClass("active")}).eq(0).click(),this.$(".toolbar select").change(function(){r.setActivateSelector(e(this).find(":selected").data("selector"))})},setRuleValue:function(e,i){if("undefined"!=typeof this.activeSelector&&"undefined"!=typeof this.activeSelector.declarations){for(var s=this.activeSelector.declarations,r=!0,n=!1,o=0;o<s.length;o++)if(s[o].property===e){r=!1;var a=s[o];a.value!==i&&(a.value=i,n=!0),t.isEmpty(a.value)&&s.splice(s.indexOf(a));break}r&&!t.isEmpty(i)&&(s.push({property:e,value:i,type:"declaration"}),n=!0),n&&this.updateMainEditor(!1)}},addImport:function(e){var i=t.filter(this.parsed.stylesheet.rules,function(e){return"import"===e.type}),s=t.any(i,function(t){return t["import"]===e["import"]});s||(this.parsed.stylesheet.rules.unshift(e),this.updateMainEditor(!1))},findImport:function(e){return t.find(this.parsed.stylesheet.rules,function(t){return"import"===t.type&&t["import"].indexOf(e)>-1})},updateImport:function(e,t){var i=this.findImport(e);i["import"]!==t["import"]&&(i["import"]=t["import"],this.updateMainEditor(!1))},removeImport:function(e){var i=t.findIndex(this.parsed.stylesheet.rules,function(t){return"import"===t.type&&t["import"].indexOf(e)>-1});i>-1&&this.parsed.stylesheet.rules.splice(i,1)},getRuleValue:function(e){if("undefined"==typeof this.activeSelector||"undefined"==typeof this.activeSelector.declarations)return"";for(var t=this.activeSelector.declarations,i=0;i<t.length;i++)if(t[i].property===e)return t[i].value;return""},updateMainEditor:function(e){this.editor.codeMirror.setValue(this.parser.stringify(this.parsed))},show:function(){this.editorExpandedBefore=this.editor.isExpanded(),this.editor.setExpand(!0),this.$el.show().animate({left:0},"fast")},hide:function(){this.editor.setExpand(this.editorExpandedBefore),this.$el.animate({left:-338},"fast",function(){e(this).hide()}),this.updateMainEditor(!0)},isVisible:function(){return this.$el.is(":visible")},loadCSS:function(i,s){this.css=i,this.parsed=this.parser.parse(i,{silent:!0});for(var r=this.parsed.stylesheet.rules,n=this.$(".toolbar select").empty(),o=0;o<r.length;o++){var a=r[o];if(t.contains(["rule","media"],a.type))if("media"===a.type)for(var l=0;l<a.rules.length;l++){var c="@media "+a.media,p=a.rules[l];"rule"==p.type&&n.append(e("<option>").html(c+": "+p.selectors.join(",")).attr("val",c+": "+p.selectors.join(",")).data("selector",p))}else n.append(e("<option>").html(a.selectors.join(",")).attr("val",a.selectors.join(",")).data("selector",a))}"undefined"==typeof s&&(s=n.find("option").eq(0).attr("val")),t.isEmpty(s)||n.val(s).change()},setActivateSelector:function(e){this.activeSelector=e;for(var t=0;t<this.propertyControllers.length;t++)this.propertyControllers[t].refreshFromRule()},addSelector:function(e){var t=this.$(".toolbar select");t.val(e),t.val()===e?t.change():(this.editor.addEmptySelector(e),this.loadCSS(this.editor.codeMirror.getValue().trim(),e)),t.addClass("highlighted"),setTimeout(function(){t.removeClass("highlighted")},2e3)}}),s.view.propertyController=Backbone.View.extend({template:t.template('<input type="text" value="" />'),activeRule:null,args:null,propertiesView:null,initialize:function(e){this.args=e.args,this.propertiesView=e.propertiesView,this.on("set_value",this.updateRule,this),this.on("change",this.updateRule,this)},render:function(){this.$el.append(e(this.template({}))),this.field=this.$("input")},initChangeEvents:function(){var t=this;this.field.on("change keyup",function(){t.trigger("change",e(this).val())})},updateRule:function(){this.propertiesView.setRuleValue(this.args.property,this.getValue())},refreshFromRule:function(){var e=this.propertiesView.getRuleValue(this.args.property);this.setValue(e,{silent:!0})},getValue:function(){return this.field.val()},setValue:function(e,i){i=t.extend({silent:!1},i),this.field.val(e),i.silent||this.trigger("set_value",e)},reset:function(e){e=t.extend({silent:!1},e),this.setValue("",e)}}),s.view.properties.controllers={},s.view.properties.controllers.color=s.view.propertyController.extend({template:t.template('<input type="text" value="" />'),render:function(){this.$el.append(e(this.template({}))),this.field=this.$el.find("input"),this.field.minicolors({})},initChangeEvents:function(){var e=this;this.field.on("change keyup",function(){e.trigger("change",e.field.minicolors("value"))})},getValue:function(){return this.field.minicolors("value").trim()},setValue:function(e,i){i=t.extend({silent:!1},i),this.field.minicolors("value",e),i.silent||this.trigger("set_value",e)}}),s.view.properties.controllers.select=s.view.propertyController.extend({template:t.template("<select></select>"),render:function(){this.$el.append(e(this.template({}))),this.field=this.$el.find("select"),this.field.append(e('<option value=""></option>').html(""));for(var t in this.args.options)this.field.append(e("<option></option>").attr("value",t).html(this.args.options[t]));"undefined"!=typeof this.args.option_icons&&this.setupVisualSelect()},setupVisualSelect:function(){var t=this;this.field.hide();var i=e('<div class="select-tabs"></div>').appendTo(this.$el);e('<div class="select-tab" data-value=""><span class="fa fa-circle-o"></span></div>').appendTo(i);for(var s in this.args.option_icons)e('<div class="select-tab"></div>').appendTo(i).append(e('<span class="fa"></span>').addClass("fa-"+this.args.option_icons[s])).attr("data-value",s);i.find(".select-tab").css("width",100/i.find(">div").length+"%").click(function(){var s=e(this);i.find(".select-tab").removeClass("active"),s.addClass("active"),t.field.val(s.data("value")).change()})},setValue:function(e,i){i=t.extend({silent:!1},i),this.field.val(e),this.$(".select-tabs .select-tab").removeClass("active").filter('[data-value="'+e+'"]').addClass("active"),i.silent||this.trigger("set_value",e)}}),s.view.properties.controllers.image=s.view.propertyController.extend({template:t.template('<input type="text" value="" /> <span class="select socss-button"><span class="fa fa-upload"></span></span>'),render:function(){var t=this;this.media=wp.media({title:i.loc.select_image,library:{type:"image"},button:{text:i.loc.select,close:!1}}),this.$el.append(e(this.template({select:i.loc.select}))),this.field=this.$el.find("input"),this.$(".select").click(function(){t.media.open()}),this.media.on("select",function(){var e=this.state().get("selection").first().attributes,i=t.args.value.replace("{{url}}",e.url);t.field.val(i).change(),t.media.close()},this.media)}}),s.view.properties.controllers.measurement=s.view.propertyController.extend({wrapperClass:"socss-field-measurement",render:function(){this.$el.append(e(this.template({}))),this.field=this.$("input"),this.setupMeasurementField(this.field,{})},setValue:function(e,i){i=t.extend({silent:!1},i),this.field.val(e).trigger("measurement_refresh"),i.silent||this.trigger("set_value",e)},units:["px","%","em","cm","mm","in","pt","pc","ex","ch","rem","vw","vh","vmin","vmax"],parseUnits:function(e){var t=function(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")},i=this.units.map(t),s=new RegExp("([0-9\\.\\-]+)("+i.join("|")+")?","i"),r=s.exec(e);return null===r?{value:"",unit:""}:{value:r[1],unit:void 0===r[2]?"":r[2]}},setupMeasurementField:function(i,s){var r=this,n=i.parent();s=t.extend({defaultUnit:"px"},s),i.hide(),n.addClass(this.wrapperClass).data("unit",s.defaultUnit);for(var o=e('<input type="text" class="socss-field-input"/>').appendTo(n),a=e('<span class="dashicons dashicons-arrow-down"></span>').appendTo(n),l=e('<ul class="dropdown"></ul>').appendTo(n),c=e('<span class="units"></span>').html(s.defaultUnit).appendTo(n),p=0;p<r.units.length;p++){var d=e("<li></li>").html(r.units[p]).data("unit",r.units[p]);r.units[p]===s.defaultUnit&&d.addClass("active"),l.append(d)}var h=function(){var e=r.parseUnits(o.val());""!==e.unit&&e.unit!==n.data("unit")&&(o.val(e.value),u(e.unit)),""===e.value?i.val(""):i.val(e.value+n.data("unit"))},u=function(e){c.html(e),n.data("unit",e),o.trigger("keydown")};a.click(function(){l.toggle()}),l.find("li").click(function(){l.toggle(),u(e(this).data("unit")),h(),i.trigger("change")}),o.on("keyup keydown",function(t){var i=(e(this),"");"keydown"===t.type&&(t.keyCode>=48&&t.keyCode<=57?i=String.fromCharCode(t.keyCode):189===t.keyCode?i="-":190===t.keyCode&&(i="."));var s=e('<span class="socss-hidden-placeholder"></span>').css({"font-size":"14px"}).html(o.val()+i).appendTo("body"),r=s.width();r=Math.min(r,63),s.remove(),c.css("left",r+12)}),o.on("keyup",function(e){h(),i.trigger("change")}),i.on("measurement_refresh",function(){var t=r.parseUnits(i.val());o.val(t.value);var a=""===t.unit?s.defaultUnit:t.unit;n.data("unit",a),c.html(a);var l=e('<span class="socss-hidden-placeholder"></span>').css({"font-size":"14px"}).html(t.value).appendTo("body"),p=l.width();p=Math.min(p,63),l.remove(),c.css("left",p+12)});var v=e('<div class="socss-diw"></div>').appendTo(n),f=e('<div class="dec-button socss-button"><span class="fa fa-minus"></span></div>').appendTo(v),m=e('<div class="inc-button socss-button"><span class="fa fa-plus"></span></div>').appendTo(v);m.click(function(){var e=r.parseUnits(i.val());if(""===e.value)return!0;var t=Math.ceil(1.05*e.value);o.val(t),h(),i.trigger("change").trigger("measurement_refresh")}),f.click(function(){var e=r.parseUnits(i.val());if(""===e.value)return!0;var t=Math.floor(e.value/1.05);o.val(t),h(),i.trigger("change").trigger("measurement_refresh")})}}),s.view.properties.controllers.number=s.view.propertyController.extend({render:function(){this.$el.append(e(this.template({}))),this.field=this.$("input"),this.setupNumberField(this.field,this.args)},setupNumberField:function(i,s){s=t.extend({change:null,"default":0,increment:1,decrement:-1,max:null,min:null},s);var r=i.parent();r.addClass("socss-field-number");var n=e('<div class="socss-diw"></div>').appendTo(r),o=e('<div class="dec-button socss-button">-</div>').appendTo(n);e('<div class="inc-button socss-button">+</div>').appendTo(n);return n.find("> div").click(function(t){t.preventDefault();var r=s["default"];""!==i.val()&&(r=Number(i.val())),r+=e(this).is(o)?s.decrement:s.increment,r=Math.round(100*r)/100,null!==s.max&&(r=Math.min(s.max,r)),null!==s.min&&(r=Math.max(s.min,r)),i.val(r),i.trigger("change")}),this}}),s.view.properties.controllers.sides=s.view.propertyController.extend({template:t.template(e("#template-sides-field").html().trim()),controllers:[],render:function(){var i=this;this.$el.append(e(this.template({}))),this.field=this.$el.find("input"),i.args.hasAll||(this.$(".select-tab").eq(0).remove(),this.$(".select-tab").css("width","25%")),this.$(".select-tab").each(function(){for(var r=e(this).data("direction"),n=e('<li class="side">').appendTo(i.$(".sides")).hide(),o=0;o<i.args.controllers.length;o++){var a=i.args.controllers[o],l="";l="all"===r?a.args.propertyAll:a.args.property.replace("{dir}",r);var c=t.extend({},a.args,{property:l}),p=new s.view.properties.controllers[a.type]({el:e("<div>").appendTo(n),propertiesView:i.propertiesView,args:c});p.render(),p.initChangeEvents(),i.propertiesView.propertyControllers.push(p)}e(this).on("click",function(){i.$(".select-tab").removeClass("active"),e(this).addClass("active"),i.$(".sides .side").hide(),n.show()})}),this.$(".select-tab").eq(0).click()}})}(jQuery,_,socssOptions),jQuery(function(e){var t=window.socss,i=new t.view.editor({el:e("#so-custom-css-form").get(0)});i.render(),i.setSnippets(socssOptions.snippets),window.socss.mainEditor=i,e("#so-custom-css-getting-started a.hide").click(function(t){t.preventDefault(),e("#so-custom-css-getting-started").slideUp(),e.get(e(this).attr("href"))})});
js/inspector.min.js CHANGED
@@ -1 +1 @@
1
- !function(e,t,s){var i={model:{},collection:{},view:{},fn:{}},r=function(e,t){for(var s=[],i=SPECIFICITY.calculate(e),o=0;o<i.length;o++){var c=i[o];if(t)for(var a=0;a<c.parts.length;a++){var n=c.parts[a];s=s.concat(r(n.selector))}else s.push({selector:c.selector.trim(),specificity:parseInt(c.specificity.replace(/,/g,""))})}return s};i.view.inspector=Backbone.View.extend({active:!1,hl:!1,hoverEl:!1,pageSelectors:[],selectorTemplate:t.template('<div class="socss-selector"><%= selector %></div>'),initialize:function(){var t=this;this.hl=new i.view.highlighter,this.hl.initialize(),this.pageSelectors=i.fn.pageSelectors(),e("body").on("mouseover","*",function(s){if(!t.active)return!0;var i=e(this);0===i.closest(".socss-element").length&&(s.stopPropagation(),t.setHoverEl(e(this)))}),e("body *").click(function(s){if(!t.active||t.$el.is(":hover"))return!0;s.preventDefault(),s.stopPropagation();var i=e(this);i.blur(),t.setActiveEl(t.hoverEl)}),this.$(".socss-enable-inspector").click(function(){t.toggleActive()}),this.$el.mouseenter(function(){t.hl.clear()});try{parent.socss.mainEditor.setInspector(this)}catch(e){console.log("No editor to register this inspector with")}},setHoverEl:function(e){this.hoverEl=e,this.hl.highlight(e)},activate:function(){this.active=!0,e("body").addClass("socss-active"),e("body").removeClass("socss-inactive")},deactivate:function(){this.active=!1,e("body").addClass("socss-inactive"),e("body").removeClass("socss-active"),this.hl.clear(),this.$(".socss-hierarchy").empty()},toggleActive:function(){this.active?this.deactivate():this.activate()},setActiveEl:function(s){var r=this,o=this.$(".socss-hierarchy");if(o.empty(),"body"!==s.prop("tagName").toLowerCase()){var c=e(s);do e(this.selectorTemplate({selector:i.fn.elSelector(c)})).prependTo(o).data("el",c),c=c.parent();while("body"!==c.prop("tagName").toLowerCase());e(this.selectorTemplate({selector:"body"})).prependTo(o).data("el",e("body")),this.$(".socss-hierarchy .socss-selector").hover(function(){r.hl.highlight(e(this).data("el"))}).click(function(t){t.preventDefault(),t.stopPropagation(),r.setActiveEl(e(this).data("el"))})}o.scrollLeft(99999);var a=this.pageSelectors.filter(function(e){try{return s.is(e.selector)}catch(e){return!1}}),n=this.$(".socss-selectors-window").empty();t.each(a,function(t){n.append(e(r.selectorTemplate(t)).data(t))}),n.find("> div").mouseenter(function(){r.hl.highlight(e(this).data("selector"))}).click(function(t){t.preventDefault(),t.stopPropagation(),r.trigger("click_selector",e(this).data("selector"))});var l=i.fn.elementAttributes(s);n=this.$(".socss-properties-window").empty(),t.each(l,function(t,s){n.append(e(r.selectorTemplate({selector:"<strong>"+s+"</strong>: "+t})).data("property",s+": "+t))}),n.find("> div").click(function(t){t.preventDefault(),t.stopPropagation(),r.trigger("click_property",e(this).data("property"))});var h=s.closest("a[href]"),p=this.$(".socss-link");h.length?p.show().find("a").html(h.attr("href").replace(/[\?&]*so_css_preview=1/,"")).attr("href",h.attr("href")):p.hide(),this.trigger("set_active_element",s,a)}}),i.view.highlighter=Backbone.View.extend({template:t.template(e("#socss-template-hover").html().trim()),highlighted:[],highlight:function(t){this.clear();var s=this;e(t).each(function(t,i){if(i=e(i),!i.is(":visible"))return!0;var r=e(s.template());r.css({top:i.offset().top,left:i.offset().left,width:i.outerWidth(),height:i.outerHeight()}).appendTo("body");var o,c=i.padding();for(var a in c)parseInt(c[a])>0&&(o=r.find(".socss-guide-padding.socss-guide-"+a).show(),"top"===a||"bottom"===a?o.css("height",c[a]):(o.css("width",c[a]),o.css({width:c[a],top:c.top,bottom:c.bottom})));var n=i.margin();for(var a in n)parseInt(n[a])>0&&(o=r.find(".socss-guide-margin.socss-guide-"+a).show(),"top"===a||"bottom"===a?o.css("height",n[a]):o.css("width",n[a]));s.highlighted.push(r)})},clear:function(){for(;this.highlighted.length;)this.highlighted.pop().remove()}}),i.parsedCss={},i.fn.getParsedCss=function(){if(0===Object.keys(i.parsedCss).length){var t=window.css;e(".socss-theme-styles").each(function(){var s=e(this),r=t.parse(s.html(),{silent:!0});i.parsedCss[s.attr("id")]=r})}return i.parsedCss},i.fn.pageSelectors=function(){var s=[],o=i.fn.getParsedCss();for(var c in o)for(var a=o[c].stylesheet.rules,n=0;n<a.length;n++)if("undefined"!=typeof a[n].selectors)for(var l=0;l<a[n].selectors.length;l++)s=s.concat(r(a[n].selectors[l]));e("body *").each(function(){var t=e(this),o=i.fn.elSelector(t);s=s.concat(r(o))});var h=e("body"),p=i.fn.elSelector(h);return s=s.concat(r(p,!0)),s=t.uniq(s,!1,function(e){return e.selector}),s.sort(function(e,t){return e.specificity>t.specificity?-1:1}),s},i.fn.elementAttributes=function(e){if(!document.styleSheets)return[];var t=[],s=i.fn.getParsedCss(),r=function(e){switch(e){case"charset":case"custom-media":case"document":case"font-face":case"host":case"import":case"keyframes":case"keyframe":case"media":case"namespace":case"page":case"supports":return!0}return!1};for(var o in s)for(var c=s[o].stylesheet.rules,a=0;a<c.length;a++){var n=c[a];if("undefined"!=typeof n.selectors&&!r(n.type))for(var l=0;l<n.selectors.length;l++)for(var h=SPECIFICITY.calculate(n.selectors[l]),p=0;p<h.length;p++)try{if(e.is(h[p].selector))for(var f=n.declarations,p=0;p<f.length;p++)t.push({name:f[p].property,value:f[p].value,specificity:parseInt(h[p].specificity.replace(/,/g,""))})}catch(e){}}t.sort(function(e,t){return e.specificity>t.specificity?1:-1}).reverse();for(var d={},v=0;v<t.length;v++)"undefined"==typeof d[t[v].name]&&(d[t[v].name]=t[v].value);return d},i.fn.elSelector=function(e){var t="";return void 0!==e.attr("id")&&(t+="#"+e.attr("id")),void 0!==e.attr("class")&&(t+="."+e.attr("class").replace(/\s+/g,".")),""===t&&(t=e.prop("tagName").toLowerCase()),t},window.socssInspector=i}(jQuery,_,socssOptions),jQuery(function(e){var t=window.socssInspector,s=new t.view.inspector({el:e("#socss-inspector-interface").get(0)});s.activate(),window.socssInspector.mainInspector=s});
1
+ !function(e,t,s){var i={model:{},collection:{},view:{},fn:{}},r=function(e,t){for(var s=[],i=SPECIFICITY.calculate(e),o=0;o<i.length;o++){var c=i[o];if(t)for(var a=0;a<c.parts.length;a++){var n=c.parts[a];s=s.concat(r(n.selector))}else s.push({selector:c.selector.trim(),specificity:parseInt(c.specificity.replace(/,/g,""))})}return s};i.view.inspector=Backbone.View.extend({active:!1,hl:!1,hoverEl:!1,pageSelectors:[],selectorTemplate:t.template('<div class="socss-selector"><%= selector %></div>'),initialize:function(){var t=this;this.hl=new i.view.highlighter,this.hl.initialize(),this.pageSelectors=i.fn.pageSelectors(),e("body").on("mouseover","*",function(s){if(!t.active)return!0;var i=e(this);0===i.closest(".socss-element").length&&(s.stopPropagation(),t.setHoverEl(e(this)))}),e("body *").click(function(s){if(!t.active||t.$el.is(":hover"))return!0;s.preventDefault(),s.stopPropagation();var i=e(this);i.blur(),t.setActiveEl(t.hoverEl)}),this.$(".socss-enable-inspector").click(function(){t.toggleActive()}),this.$el.mouseenter(function(){t.hl.clear()});try{parent.socss.mainEditor.setInspector(this)}catch(s){console.log("No editor to register this inspector with")}},setHoverEl:function(e){this.hoverEl=e,this.hl.highlight(e)},activate:function(){this.active=!0,e("body").addClass("socss-active"),e("body").removeClass("socss-inactive")},deactivate:function(){this.active=!1,e("body").addClass("socss-inactive"),e("body").removeClass("socss-active"),this.hl.clear(),this.$(".socss-hierarchy").empty()},toggleActive:function(){this.active?this.deactivate():this.activate()},setActiveEl:function(s){var r=this,o=this.$(".socss-hierarchy");if(o.empty(),"body"!==s.prop("tagName").toLowerCase()){var c=e(s);do e(this.selectorTemplate({selector:i.fn.elSelector(c)})).prependTo(o).data("el",c),c=c.parent();while("body"!==c.prop("tagName").toLowerCase());e(this.selectorTemplate({selector:"body"})).prependTo(o).data("el",e("body")),this.$(".socss-hierarchy .socss-selector").hover(function(){r.hl.highlight(e(this).data("el"))}).click(function(t){t.preventDefault(),t.stopPropagation(),r.setActiveEl(e(this).data("el"))})}o.scrollLeft(99999);var a=this.pageSelectors.filter(function(e){try{return s.is(e.selector)}catch(t){return!1}}),n=this.$(".socss-selectors-window").empty();t.each(a,function(t){n.append(e(r.selectorTemplate(t)).data(t))}),n.find("> div").mouseenter(function(){r.hl.highlight(e(this).data("selector"))}).click(function(t){t.preventDefault(),t.stopPropagation(),r.trigger("click_selector",e(this).data("selector"))});var l=i.fn.elementAttributes(s);n=this.$(".socss-properties-window").empty(),t.each(l,function(t,s){n.append(e(r.selectorTemplate({selector:"<strong>"+s+"</strong>: "+t})).data("property",s+": "+t))}),n.find("> div").click(function(t){t.preventDefault(),t.stopPropagation(),r.trigger("click_property",e(this).data("property"))});var h=s.closest("a[href]"),p=this.$(".socss-link");h.length?p.show().find("a").html(h.attr("href").replace(/[\?&]*so_css_preview=1/,"")).attr("href",h.attr("href")):p.hide(),this.trigger("set_active_element",s,a)}}),i.view.highlighter=Backbone.View.extend({template:t.template(e("#socss-template-hover").html().trim()),highlighted:[],highlight:function(t){this.clear();var s=this;e(t).each(function(t,i){if(i=e(i),!i.is(":visible"))return!0;var r=e(s.template());r.css({top:i.offset().top,left:i.offset().left,width:i.outerWidth(),height:i.outerHeight()}).appendTo("body");var o,c=i.padding();for(var a in c)parseInt(c[a])>0&&(o=r.find(".socss-guide-padding.socss-guide-"+a).show(),"top"===a||"bottom"===a?o.css("height",c[a]):(o.css("width",c[a]),o.css({width:c[a],top:c.top,bottom:c.bottom})));var n=i.margin();for(var a in n)parseInt(n[a])>0&&(o=r.find(".socss-guide-margin.socss-guide-"+a).show(),"top"===a||"bottom"===a?o.css("height",n[a]):o.css("width",n[a]));s.highlighted.push(r)})},clear:function(){for(;this.highlighted.length;)this.highlighted.pop().remove()}}),i.parsedCss={},i.fn.getParsedCss=function(){if(0===Object.keys(i.parsedCss).length){var t=window.css;e(".socss-theme-styles").each(function(){var s=e(this),r=t.parse(s.html(),{silent:!0});i.parsedCss[s.attr("id")]=r})}return i.parsedCss},i.fn.pageSelectors=function(){var s=[],o=i.fn.getParsedCss();for(var c in o)for(var a=o[c].stylesheet.rules,n=0;n<a.length;n++)if("undefined"!=typeof a[n].selectors)for(var l=0;l<a[n].selectors.length;l++)s=s.concat(r(a[n].selectors[l]));e("body *").each(function(){var t=e(this),o=i.fn.elSelector(t);s=s.concat(r(o))});var h=e("body"),p=i.fn.elSelector(h);return s=s.concat(r(p,!0)),s=t.uniq(s,!1,function(e){return e.selector}),s.sort(function(e,t){return e.specificity>t.specificity?-1:1}),s},i.fn.elementAttributes=function(e){if(!document.styleSheets)return[];var t=[],s=i.fn.getParsedCss(),r=function(e){switch(e){case"charset":case"custom-media":case"document":case"font-face":case"host":case"import":case"keyframes":case"keyframe":case"media":case"namespace":case"page":case"supports":return!0}return!1};for(var o in s)for(var c=s[o].stylesheet.rules,a=0;a<c.length;a++){var n=c[a];if("undefined"!=typeof n.selectors&&!r(n.type))for(var l=0;l<n.selectors.length;l++)for(var h=SPECIFICITY.calculate(n.selectors[l]),p=0;p<h.length;p++)try{if(e.is(h[p].selector))for(var f=n.declarations,p=0;p<f.length;p++)t.push({name:f[p].property,value:f[p].value,specificity:parseInt(h[p].specificity.replace(/,/g,""))})}catch(d){}}t.sort(function(e,t){return e.specificity>t.specificity?1:-1}).reverse();for(var v={},u=0;u<t.length;u++)"undefined"==typeof v[t[u].name]&&(v[t[u].name]=t[u].value);return v},i.fn.elSelector=function(e){var t="";return void 0!==e.attr("id")&&(t+="#"+e.attr("id")),void 0!==e.attr("class")&&(t+="."+e.attr("class").replace(/\s+/g,".")),""===t&&(t=e.prop("tagName").toLowerCase()),t},window.socssInspector=i}(jQuery,_,socssOptions),jQuery(function(e){var t=window.socssInspector,s=new t.view.inspector({el:e("#socss-inspector-interface").get(0)});s.activate(),window.socssInspector.mainInspector=s});
lib/codemirror/addon/hint/html-hint.min.js CHANGED
@@ -1 +1 @@
1
- !function(l){"object"==typeof exports&&"object"==typeof module?l(require("../../lib/codemirror"),require("./xml-hint")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","./xml-hint"],l):l(CodeMirror)}(function(l){"use strict";function t(l){for(var t in c)c.hasOwnProperty(t)&&(l.attrs[t]=c[t])}function e(t,e){var a={schemaInfo:d};if(e)for(var n in e)a[n]=e[n];return l.hint.xml(t,a)}var a="ab aa af ak sq am ar an hy as av ae ay az bm ba eu be bn bh bi bs br bg my ca ch ce ny zh cv kw co cr hr cs da dv nl dz en eo et ee fo fj fi fr ff gl ka de el gn gu ht ha he hz hi ho hu ia id ie ga ig ik io is it iu ja jv kl kn kr ks kk km ki rw ky kv kg ko ku kj la lb lg li ln lo lt lu lv gv mk mg ms ml mt mi mr mh mn na nv nb nd ne ng nn no ii nr oc oj cu om or os pa pi fa pl ps pt qu rm rn ro ru sa sc sd se sm sg sr gd sn si sk sl so st es su sw ss sv ta te tg th ti bo tk tl tn to tr ts tt tw ty ug uk ur uz ve vi vo wa cy wo fy xh yi yo za zu".split(" "),n=["_blank","_self","_top","_parent"],r=["ascii","utf-8","utf-16","latin1","latin1"],o=["get","post","put","delete"],s=["application/x-www-form-urlencoded","multipart/form-data","text/plain"],u=["all","screen","print","embossed","braille","handheld","print","projection","screen","tty","tv","speech","3d-glasses","resolution [>][<][=] [X]","device-aspect-ratio: X/Y","orientation:portrait","orientation:landscape","device-height: [X]","device-width: [X]"],i={attrs:{}},d={a:{attrs:{href:null,ping:null,type:null,media:u,target:n,hreflang:a}},abbr:i,acronym:i,address:i,applet:i,area:{attrs:{alt:null,coords:null,href:null,target:null,ping:null,media:u,hreflang:a,type:null,shape:["default","rect","circle","poly"]}},article:i,aside:i,audio:{attrs:{src:null,mediagroup:null,crossorigin:["anonymous","use-credentials"],preload:["none","metadata","auto"],autoplay:["","autoplay"],loop:["","loop"],controls:["","controls"]}},b:i,base:{attrs:{href:null,target:n}},basefont:i,bdi:i,bdo:i,big:i,blockquote:{attrs:{cite:null}},body:i,br:i,button:{attrs:{form:null,formaction:null,name:null,value:null,autofocus:["","autofocus"],disabled:["","autofocus"],formenctype:s,formmethod:o,formnovalidate:["","novalidate"],formtarget:n,type:["submit","reset","button"]}},canvas:{attrs:{width:null,height:null}},caption:i,center:i,cite:i,code:i,col:{attrs:{span:null}},colgroup:{attrs:{span:null}},command:{attrs:{type:["command","checkbox","radio"],label:null,icon:null,radiogroup:null,command:null,title:null,disabled:["","disabled"],checked:["","checked"]}},data:{attrs:{value:null}},datagrid:{attrs:{disabled:["","disabled"],multiple:["","multiple"]}},datalist:{attrs:{data:null}},dd:i,del:{attrs:{cite:null,datetime:null}},details:{attrs:{open:["","open"]}},dfn:i,dir:i,div:i,dl:i,dt:i,em:i,embed:{attrs:{src:null,type:null,width:null,height:null}},eventsource:{attrs:{src:null}},fieldset:{attrs:{disabled:["","disabled"],form:null,name:null}},figcaption:i,figure:i,font:i,footer:i,form:{attrs:{action:null,name:null,"accept-charset":r,autocomplete:["on","off"],enctype:s,method:o,novalidate:["","novalidate"],target:n}},frame:i,frameset:i,h1:i,h2:i,h3:i,h4:i,h5:i,h6:i,head:{attrs:{},children:["title","base","link","style","meta","script","noscript","command"]},header:i,hgroup:i,hr:i,html:{attrs:{manifest:null},children:["head","body"]},i:i,iframe:{attrs:{src:null,srcdoc:null,name:null,width:null,height:null,sandbox:["allow-top-navigation","allow-same-origin","allow-forms","allow-scripts"],seamless:["","seamless"]}},img:{attrs:{alt:null,src:null,ismap:null,usemap:null,width:null,height:null,crossorigin:["anonymous","use-credentials"]}},input:{attrs:{alt:null,dirname:null,form:null,formaction:null,height:null,list:null,max:null,maxlength:null,min:null,name:null,pattern:null,placeholder:null,size:null,src:null,step:null,value:null,width:null,accept:["audio/*","video/*","image/*"],autocomplete:["on","off"],autofocus:["","autofocus"],checked:["","checked"],disabled:["","disabled"],formenctype:s,formmethod:o,formnovalidate:["","novalidate"],formtarget:n,multiple:["","multiple"],readonly:["","readonly"],required:["","required"],type:["hidden","text","search","tel","url","email","password","datetime","date","month","week","time","datetime-local","number","range","color","checkbox","radio","file","submit","image","reset","button"]}},ins:{attrs:{cite:null,datetime:null}},kbd:i,keygen:{attrs:{challenge:null,form:null,name:null,autofocus:["","autofocus"],disabled:["","disabled"],keytype:["RSA"]}},label:{attrs:{for:null,form:null}},legend:i,li:{attrs:{value:null}},link:{attrs:{href:null,type:null,hreflang:a,media:u,sizes:["all","16x16","16x16 32x32","16x16 32x32 64x64"]}},map:{attrs:{name:null}},mark:i,menu:{attrs:{label:null,type:["list","context","toolbar"]}},meta:{attrs:{content:null,charset:r,name:["viewport","application-name","author","description","generator","keywords"],"http-equiv":["content-language","content-type","default-style","refresh"]}},meter:{attrs:{value:null,min:null,low:null,high:null,max:null,optimum:null}},nav:i,noframes:i,noscript:i,object:{attrs:{data:null,type:null,name:null,usemap:null,form:null,width:null,height:null,typemustmatch:["","typemustmatch"]}},ol:{attrs:{reversed:["","reversed"],start:null,type:["1","a","A","i","I"]}},optgroup:{attrs:{disabled:["","disabled"],label:null}},option:{attrs:{disabled:["","disabled"],label:null,selected:["","selected"],value:null}},output:{attrs:{for:null,form:null,name:null}},p:i,param:{attrs:{name:null,value:null}},pre:i,progress:{attrs:{value:null,max:null}},q:{attrs:{cite:null}},rp:i,rt:i,ruby:i,s:i,samp:i,script:{attrs:{type:["text/javascript"],src:null,async:["","async"],defer:["","defer"],charset:r}},section:i,select:{attrs:{form:null,name:null,size:null,autofocus:["","autofocus"],disabled:["","disabled"],multiple:["","multiple"]}},small:i,source:{attrs:{src:null,type:null,media:null}},span:i,strike:i,strong:i,style:{attrs:{type:["text/css"],media:u,scoped:null}},sub:i,summary:i,sup:i,table:i,tbody:i,td:{attrs:{colspan:null,rowspan:null,headers:null}},textarea:{attrs:{dirname:null,form:null,maxlength:null,name:null,placeholder:null,rows:null,cols:null,autofocus:["","autofocus"],disabled:["","disabled"],readonly:["","readonly"],required:["","required"],wrap:["soft","hard"]}},tfoot:i,th:{attrs:{colspan:null,rowspan:null,headers:null,scope:["row","col","rowgroup","colgroup"]}},thead:i,time:{attrs:{datetime:null}},title:i,tr:i,track:{attrs:{src:null,label:null,default:null,kind:["subtitles","captions","descriptions","chapters","metadata"],srclang:a}},tt:i,u:i,ul:i,var:i,video:{attrs:{src:null,poster:null,width:null,height:null,crossorigin:["anonymous","use-credentials"],preload:["auto","metadata","none"],autoplay:["","autoplay"],mediagroup:["movie"],muted:["","muted"],controls:["","controls"]}},wbr:i},c={accesskey:["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9"],class:null,contenteditable:["true","false"],contextmenu:null,dir:["ltr","rtl","auto"],draggable:["true","false","auto"],dropzone:["copy","move","link","string:","file:"],hidden:["hidden"],id:null,inert:["inert"],itemid:null,itemprop:null,itemref:null,itemscope:["itemscope"],itemtype:null,lang:["en","es"],spellcheck:["true","false"],style:null,tabindex:["1","2","3","4","5","6","7","8","9"],title:null,translate:["yes","no"],onclick:null,rel:["stylesheet","alternate","author","bookmark","help","license","next","nofollow","noreferrer","prefetch","prev","search","tag"]};t(i);for(var m in d)d.hasOwnProperty(m)&&d[m]!=i&&t(d[m]);l.htmlSchema=d,l.registerHelper("hint","html",e)});
1
+ !function(l){"object"==typeof exports&&"object"==typeof module?l(require("../../lib/codemirror"),require("./xml-hint")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","./xml-hint"],l):l(CodeMirror)}(function(l){"use strict";function t(l){for(var t in c)c.hasOwnProperty(t)&&(l.attrs[t]=c[t])}function e(t,e){var a={schemaInfo:d};if(e)for(var n in e)a[n]=e[n];return l.hint.xml(t,a)}var a="ab aa af ak sq am ar an hy as av ae ay az bm ba eu be bn bh bi bs br bg my ca ch ce ny zh cv kw co cr hr cs da dv nl dz en eo et ee fo fj fi fr ff gl ka de el gn gu ht ha he hz hi ho hu ia id ie ga ig ik io is it iu ja jv kl kn kr ks kk km ki rw ky kv kg ko ku kj la lb lg li ln lo lt lu lv gv mk mg ms ml mt mi mr mh mn na nv nb nd ne ng nn no ii nr oc oj cu om or os pa pi fa pl ps pt qu rm rn ro ru sa sc sd se sm sg sr gd sn si sk sl so st es su sw ss sv ta te tg th ti bo tk tl tn to tr ts tt tw ty ug uk ur uz ve vi vo wa cy wo fy xh yi yo za zu".split(" "),n=["_blank","_self","_top","_parent"],r=["ascii","utf-8","utf-16","latin1","latin1"],o=["get","post","put","delete"],s=["application/x-www-form-urlencoded","multipart/form-data","text/plain"],u=["all","screen","print","embossed","braille","handheld","print","projection","screen","tty","tv","speech","3d-glasses","resolution [>][<][=] [X]","device-aspect-ratio: X/Y","orientation:portrait","orientation:landscape","device-height: [X]","device-width: [X]"],i={attrs:{}},d={a:{attrs:{href:null,ping:null,type:null,media:u,target:n,hreflang:a}},abbr:i,acronym:i,address:i,applet:i,area:{attrs:{alt:null,coords:null,href:null,target:null,ping:null,media:u,hreflang:a,type:null,shape:["default","rect","circle","poly"]}},article:i,aside:i,audio:{attrs:{src:null,mediagroup:null,crossorigin:["anonymous","use-credentials"],preload:["none","metadata","auto"],autoplay:["","autoplay"],loop:["","loop"],controls:["","controls"]}},b:i,base:{attrs:{href:null,target:n}},basefont:i,bdi:i,bdo:i,big:i,blockquote:{attrs:{cite:null}},body:i,br:i,button:{attrs:{form:null,formaction:null,name:null,value:null,autofocus:["","autofocus"],disabled:["","autofocus"],formenctype:s,formmethod:o,formnovalidate:["","novalidate"],formtarget:n,type:["submit","reset","button"]}},canvas:{attrs:{width:null,height:null}},caption:i,center:i,cite:i,code:i,col:{attrs:{span:null}},colgroup:{attrs:{span:null}},command:{attrs:{type:["command","checkbox","radio"],label:null,icon:null,radiogroup:null,command:null,title:null,disabled:["","disabled"],checked:["","checked"]}},data:{attrs:{value:null}},datagrid:{attrs:{disabled:["","disabled"],multiple:["","multiple"]}},datalist:{attrs:{data:null}},dd:i,del:{attrs:{cite:null,datetime:null}},details:{attrs:{open:["","open"]}},dfn:i,dir:i,div:i,dl:i,dt:i,em:i,embed:{attrs:{src:null,type:null,width:null,height:null}},eventsource:{attrs:{src:null}},fieldset:{attrs:{disabled:["","disabled"],form:null,name:null}},figcaption:i,figure:i,font:i,footer:i,form:{attrs:{action:null,name:null,"accept-charset":r,autocomplete:["on","off"],enctype:s,method:o,novalidate:["","novalidate"],target:n}},frame:i,frameset:i,h1:i,h2:i,h3:i,h4:i,h5:i,h6:i,head:{attrs:{},children:["title","base","link","style","meta","script","noscript","command"]},header:i,hgroup:i,hr:i,html:{attrs:{manifest:null},children:["head","body"]},i:i,iframe:{attrs:{src:null,srcdoc:null,name:null,width:null,height:null,sandbox:["allow-top-navigation","allow-same-origin","allow-forms","allow-scripts"],seamless:["","seamless"]}},img:{attrs:{alt:null,src:null,ismap:null,usemap:null,width:null,height:null,crossorigin:["anonymous","use-credentials"]}},input:{attrs:{alt:null,dirname:null,form:null,formaction:null,height:null,list:null,max:null,maxlength:null,min:null,name:null,pattern:null,placeholder:null,size:null,src:null,step:null,value:null,width:null,accept:["audio/*","video/*","image/*"],autocomplete:["on","off"],autofocus:["","autofocus"],checked:["","checked"],disabled:["","disabled"],formenctype:s,formmethod:o,formnovalidate:["","novalidate"],formtarget:n,multiple:["","multiple"],readonly:["","readonly"],required:["","required"],type:["hidden","text","search","tel","url","email","password","datetime","date","month","week","time","datetime-local","number","range","color","checkbox","radio","file","submit","image","reset","button"]}},ins:{attrs:{cite:null,datetime:null}},kbd:i,keygen:{attrs:{challenge:null,form:null,name:null,autofocus:["","autofocus"],disabled:["","disabled"],keytype:["RSA"]}},label:{attrs:{"for":null,form:null}},legend:i,li:{attrs:{value:null}},link:{attrs:{href:null,type:null,hreflang:a,media:u,sizes:["all","16x16","16x16 32x32","16x16 32x32 64x64"]}},map:{attrs:{name:null}},mark:i,menu:{attrs:{label:null,type:["list","context","toolbar"]}},meta:{attrs:{content:null,charset:r,name:["viewport","application-name","author","description","generator","keywords"],"http-equiv":["content-language","content-type","default-style","refresh"]}},meter:{attrs:{value:null,min:null,low:null,high:null,max:null,optimum:null}},nav:i,noframes:i,noscript:i,object:{attrs:{data:null,type:null,name:null,usemap:null,form:null,width:null,height:null,typemustmatch:["","typemustmatch"]}},ol:{attrs:{reversed:["","reversed"],start:null,type:["1","a","A","i","I"]}},optgroup:{attrs:{disabled:["","disabled"],label:null}},option:{attrs:{disabled:["","disabled"],label:null,selected:["","selected"],value:null}},output:{attrs:{"for":null,form:null,name:null}},p:i,param:{attrs:{name:null,value:null}},pre:i,progress:{attrs:{value:null,max:null}},q:{attrs:{cite:null}},rp:i,rt:i,ruby:i,s:i,samp:i,script:{attrs:{type:["text/javascript"],src:null,async:["","async"],defer:["","defer"],charset:r}},section:i,select:{attrs:{form:null,name:null,size:null,autofocus:["","autofocus"],disabled:["","disabled"],multiple:["","multiple"]}},small:i,source:{attrs:{src:null,type:null,media:null}},span:i,strike:i,strong:i,style:{attrs:{type:["text/css"],media:u,scoped:null}},sub:i,summary:i,sup:i,table:i,tbody:i,td:{attrs:{colspan:null,rowspan:null,headers:null}},textarea:{attrs:{dirname:null,form:null,maxlength:null,name:null,placeholder:null,rows:null,cols:null,autofocus:["","autofocus"],disabled:["","disabled"],readonly:["","readonly"],required:["","required"],wrap:["soft","hard"]}},tfoot:i,th:{attrs:{colspan:null,rowspan:null,headers:null,scope:["row","col","rowgroup","colgroup"]}},thead:i,time:{attrs:{datetime:null}},title:i,tr:i,track:{attrs:{src:null,label:null,"default":null,kind:["subtitles","captions","descriptions","chapters","metadata"],srclang:a}},tt:i,u:i,ul:i,"var":i,video:{attrs:{src:null,poster:null,width:null,height:null,crossorigin:["anonymous","use-credentials"],preload:["auto","metadata","none"],autoplay:["","autoplay"],mediagroup:["movie"],muted:["","muted"],controls:["","controls"]}},wbr:i},c={accesskey:["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9"],"class":null,contenteditable:["true","false"],contextmenu:null,dir:["ltr","rtl","auto"],draggable:["true","false","auto"],dropzone:["copy","move","link","string:","file:"],hidden:["hidden"],id:null,inert:["inert"],itemid:null,itemprop:null,itemref:null,itemscope:["itemscope"],itemtype:null,lang:["en","es"],spellcheck:["true","false"],style:null,tabindex:["1","2","3","4","5","6","7","8","9"],title:null,translate:["yes","no"],onclick:null,rel:["stylesheet","alternate","author","bookmark","help","license","next","nofollow","noreferrer","prefetch","prev","search","tag"]};t(i);for(var m in d)d.hasOwnProperty(m)&&d[m]!=i&&t(d[m]);l.htmlSchema=d,l.registerHelper("hint","html",e)});
lib/codemirror/addon/lint/coffeescript-lint.min.js CHANGED
@@ -1 +1 @@
1
- !function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(e){"use strict";e.registerHelper("lint","coffeescript",function(o){var r=[],t=function(o){var t=o.lineNumber;r.push({from:e.Pos(t-1,0),to:e.Pos(t,0),severity:o.level,message:o.message})};try{for(var i=coffeelint.lint(o),n=0;n<i.length;n++)t(i[n])}catch(o){r.push({from:e.Pos(o.location.first_line,0),to:e.Pos(o.location.last_line,o.location.last_column),severity:"error",message:o.message})}return r})});
1
+ !function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(e){"use strict";e.registerHelper("lint","coffeescript",function(o){var r=[],t=function(o){var t=o.lineNumber;r.push({from:e.Pos(t-1,0),to:e.Pos(t,0),severity:o.level,message:o.message})};try{for(var i=coffeelint.lint(o),n=0;n<i.length;n++)t(i[n])}catch(s){r.push({from:e.Pos(s.location.first_line,0),to:e.Pos(s.location.last_line,s.location.last_column),severity:"error",message:s.message})}return r})});
lib/codemirror/addon/lint/json-lint.min.js CHANGED
@@ -1 +1 @@
1
- !function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(e){"use strict";e.registerHelper("lint","json",function(o){var r=[];jsonlint.parseError=function(o,t){var n=t.loc;r.push({from:e.Pos(n.first_line-1,n.first_column),to:e.Pos(n.last_line-1,n.last_column),message:o})};try{jsonlint.parse(o)}catch(e){}return r})});
1
+ !function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(e){"use strict";e.registerHelper("lint","json",function(o){var r=[];jsonlint.parseError=function(o,t){var n=t.loc;r.push({from:e.Pos(n.first_line-1,n.first_column),to:e.Pos(n.last_line-1,n.last_column),message:o})};try{jsonlint.parse(o)}catch(t){}return r})});
lib/codemirror/addon/lint/yaml-lint.min.js CHANGED
@@ -1 +1 @@
1
- !function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(e){"use strict";e.registerHelper("lint","yaml",function(o){var r=[];try{jsyaml.load(o)}catch(o){var i=o.mark;r.push({from:e.Pos(i.line,i.column),to:e.Pos(i.line,i.column),message:o.message})}return r})});
1
+ !function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(e){"use strict";e.registerHelper("lint","yaml",function(o){var r=[];try{jsyaml.load(o)}catch(i){var t=i.mark;r.push({from:e.Pos(t.line,t.column),to:e.Pos(t.line,t.column),message:i.message})}return r})});
lib/codemirror/lib/codemirror.min.js CHANGED
@@ -1,5 +1,5 @@
1
  !function(e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else{if("function"==typeof define&&define.amd)return define([],e);(this||window).CodeMirror=e()}}(function(){"use strict";function e(r,n){if(!(this instanceof e))return new e(r,n);this.options=n=n?zi(n):{},zi(Jo,n,!1),d(n);var i=n.value;"string"==typeof i&&(i=new Sl(i,n.mode,null,n.lineSeparator)),this.doc=i;var o=new e.inputStyles[n.inputStyle](this),l=this.display=new t(r,i,o);l.wrapper.CodeMirror=this,u(this),s(this),n.lineWrapping&&(this.display.wrapper.className+=" CodeMirror-wrap"),n.autofocus&&!Wo&&l.input.focus(),m(this),this.state={keyMaps:[],overlays:[],modeGen:0,overwrite:!1,delayingBlurEvent:!1,focused:!1,suppressEdits:!1,pasteIncoming:!1,cutIncoming:!1,selectingText:!1,draggingText:!1,highlight:new Ai,keySeq:null,specialChars:null};var a=this;bo&&wo<11&&setTimeout(function(){a.display.input.reset(!0)},20),Ut(this),$i(),wt(this),this.curOp.forceUpdate=!0,qn(this,i),n.autofocus&&!Wo||a.hasFocus()?setTimeout(Fi(vr,this),20):mr(this);for(var c in el)el.hasOwnProperty(c)&&el[c](this,n[c],tl);C(this),n.finishInit&&n.finishInit(this);for(var h=0;h<ol.length;++h)ol[h](this);Ct(this),xo&&n.lineWrapping&&"optimizelegibility"==getComputedStyle(l.lineDiv).textRendering&&(l.lineDiv.style.textRendering="auto")}function t(e,t,r){var n=this;this.input=r,n.scrollbarFiller=Ui("div",null,"CodeMirror-scrollbar-filler"),n.scrollbarFiller.setAttribute("cm-not-content","true"),n.gutterFiller=Ui("div",null,"CodeMirror-gutter-filler"),n.gutterFiller.setAttribute("cm-not-content","true"),n.lineDiv=Ui("div",null,"CodeMirror-code"),n.selectionDiv=Ui("div",null,null,"position: relative; z-index: 1"),n.cursorDiv=Ui("div",null,"CodeMirror-cursors"),n.measure=Ui("div",null,"CodeMirror-measure"),n.lineMeasure=Ui("div",null,"CodeMirror-measure"),n.lineSpace=Ui("div",[n.measure,n.lineMeasure,n.selectionDiv,n.cursorDiv,n.lineDiv],null,"position: relative; outline: none"),n.mover=Ui("div",[Ui("div",[n.lineSpace],"CodeMirror-lines")],null,"position: relative"),n.sizer=Ui("div",[n.mover],"CodeMirror-sizer"),n.sizerWidth=null,n.heightForcer=Ui("div",null,null,"position: absolute; height: "+Pl+"px; width: 1px;"),n.gutters=Ui("div",null,"CodeMirror-gutters"),n.lineGutter=null,n.scroller=Ui("div",[n.sizer,n.heightForcer,n.gutters],"CodeMirror-scroll"),n.scroller.setAttribute("tabIndex","-1"),n.wrapper=Ui("div",[n.scrollbarFiller,n.gutterFiller,n.scroller],"CodeMirror"),bo&&wo<8&&(n.gutters.style.zIndex=-1,n.scroller.style.paddingRight=0),xo||vo&&Wo||(n.scroller.draggable=!0),e&&(e.appendChild?e.appendChild(n.wrapper):e(n.wrapper)),n.viewFrom=n.viewTo=t.first,n.reportedViewFrom=n.reportedViewTo=t.first,n.view=[],n.renderedView=null,n.externalMeasured=null,n.viewOffset=0,n.lastWrapHeight=n.lastWrapWidth=0,n.updateLineNumbers=null,n.nativeBarWidth=n.barHeight=n.barWidth=0,n.scrollbarsClipped=!1,n.lineNumWidth=n.lineNumInnerWidth=n.lineNumChars=null,n.alignWidgets=!1,n.cachedCharWidth=n.cachedTextHeight=n.cachedPaddingH=null,n.maxLine=null,n.maxLineLength=0,n.maxLineChanged=!1,n.wheelDX=n.wheelDY=n.wheelStartX=n.wheelStartY=null,n.shift=!1,n.selForContextMenu=null,n.activeTouch=null,r.init(n)}function r(t){t.doc.mode=e.getMode(t.options,t.doc.modeOption),n(t)}function n(e){e.doc.iter(function(e){e.stateAfter&&(e.stateAfter=null),e.styles&&(e.styles=null)}),e.doc.frontier=e.doc.first,Re(e,100),e.state.modeGen++,e.curOp&&Et(e)}function i(e){e.options.lineWrapping?(Zl(e.display.wrapper,"CodeMirror-wrap"),e.display.sizer.style.minWidth="",e.display.sizerWidth=null):(ql(e.display.wrapper,"CodeMirror-wrap"),f(e)),l(e),Et(e),st(e),setTimeout(function(){y(e)},100)}function o(e){var t=yt(e.display),r=e.options.lineWrapping,n=r&&Math.max(5,e.display.scroller.clientWidth/bt(e.display)-3);return function(i){if(Cn(e.doc,i))return 0;var o=0;if(i.widgets)for(var l=0;l<i.widgets.length;l++)i.widgets[l].height&&(o+=i.widgets[l].height);return r?o+(Math.ceil(i.text.length/n)||1)*t:o+t}}function l(e){var t=e.doc,r=o(e);t.iter(function(e){var t=r(e);t!=e.height&&ei(e,t)})}function s(e){e.display.wrapper.className=e.display.wrapper.className.replace(/\s*cm-s-\S+/g,"")+e.options.theme.replace(/(^|\s)\s*/g," cm-s-"),st(e)}function a(e){u(e),Et(e),setTimeout(function(){x(e)},20)}function u(e){var t=e.display.gutters,r=e.options.gutters;Vi(t);for(var n=0;n<r.length;++n){var i=r[n],o=t.appendChild(Ui("div",null,"CodeMirror-gutter "+i));"CodeMirror-linenumbers"==i&&(e.display.lineGutter=o,o.style.width=(e.display.lineNumWidth||1)+"px")}t.style.display=n?"":"none",c(e)}function c(e){var t=e.display.gutters.offsetWidth;e.display.sizer.style.marginLeft=t+"px"}function h(e){if(0==e.height)return 0;for(var t,r=e.text.length,n=e;t=gn(n);){var i=t.find(0,!0);n=i.from.line,r+=i.from.ch-i.to.ch}for(n=e;t=vn(n);){var i=t.find(0,!0);r-=n.text.length-i.from.ch,n=i.to.line,r+=n.text.length-i.to.ch}return r}function f(e){var t=e.display,r=e.doc;t.maxLine=Zn(r,r.first),t.maxLineLength=h(t.maxLine),t.maxLineChanged=!0,r.iter(function(e){var r=h(e);r>t.maxLineLength&&(t.maxLineLength=r,t.maxLine=e)})}function d(e){var t=Hi(e.gutters,"CodeMirror-linenumbers");t==-1&&e.lineNumbers?e.gutters=e.gutters.concat(["CodeMirror-linenumbers"]):t>-1&&!e.lineNumbers&&(e.gutters=e.gutters.slice(0),e.gutters.splice(t,1))}function p(e){var t=e.display,r=t.gutters.offsetWidth,n=Math.round(e.doc.height+Ke(e.display));return{clientHeight:t.scroller.clientHeight,viewHeight:t.wrapper.clientHeight,scrollWidth:t.scroller.scrollWidth,clientWidth:t.scroller.clientWidth,viewWidth:t.wrapper.clientWidth,barLeft:e.options.fixedGutter?r:0,docHeight:n,scrollHeight:n+Xe(e)+t.barHeight,nativeBarWidth:t.nativeBarWidth,gutterWidth:r}}function g(e,t,r){this.cm=r;var n=this.vert=Ui("div",[Ui("div",null,null,"min-width: 1px")],"CodeMirror-vscrollbar"),i=this.horiz=Ui("div",[Ui("div",null,null,"height: 100%; min-height: 1px")],"CodeMirror-hscrollbar");e(n),e(i),Wl(n,"scroll",function(){n.clientHeight&&t(n.scrollTop,"vertical")}),Wl(i,"scroll",function(){i.clientWidth&&t(i.scrollLeft,"horizontal")}),this.checkedZeroWidth=!1,bo&&wo<8&&(this.horiz.style.minHeight=this.vert.style.minWidth="18px")}function v(){}function m(t){t.display.scrollbars&&(t.display.scrollbars.clear(),t.display.scrollbars.addClass&&ql(t.display.wrapper,t.display.scrollbars.addClass)),t.display.scrollbars=new e.scrollbarModel[t.options.scrollbarStyle](function(e){t.display.wrapper.insertBefore(e,t.display.scrollbarFiller),Wl(e,"mousedown",function(){t.state.focused&&setTimeout(function(){t.display.input.focus()},0)}),e.setAttribute("cm-not-content","true")},function(e,r){"horizontal"==r?ir(t,e):nr(t,e)},t),t.display.scrollbars.addClass&&Zl(t.display.wrapper,t.display.scrollbars.addClass)}function y(e,t){t||(t=p(e));var r=e.display.barWidth,n=e.display.barHeight;b(e,t);for(var i=0;i<4&&r!=e.display.barWidth||n!=e.display.barHeight;i++)r!=e.display.barWidth&&e.options.lineWrapping&&O(e),b(e,p(e)),r=e.display.barWidth,n=e.display.barHeight}function b(e,t){var r=e.display,n=r.scrollbars.update(t);r.sizer.style.paddingRight=(r.barWidth=n.right)+"px",r.sizer.style.paddingBottom=(r.barHeight=n.bottom)+"px",n.right&&n.bottom?(r.scrollbarFiller.style.display="block",r.scrollbarFiller.style.height=n.bottom+"px",r.scrollbarFiller.style.width=n.right+"px"):r.scrollbarFiller.style.display="",n.bottom&&e.options.coverGutterNextToScrollbar&&e.options.fixedGutter?(r.gutterFiller.style.display="block",r.gutterFiller.style.height=n.bottom+"px",r.gutterFiller.style.width=t.gutterWidth+"px"):r.gutterFiller.style.display=""}function w(e,t,r){var n=r&&null!=r.top?Math.max(0,r.top):e.scroller.scrollTop;n=Math.floor(n-Ve(e));var i=r&&null!=r.bottom?r.bottom:n+e.wrapper.clientHeight,o=ri(t,n),l=ri(t,i);if(r&&r.ensure){var s=r.ensure.from.line,a=r.ensure.to.line;s<o?(o=s,l=ri(t,ni(Zn(t,s))+e.wrapper.clientHeight)):Math.min(a,t.lastLine())>=l&&(o=ri(t,ni(Zn(t,a))-e.wrapper.clientHeight),l=a)}return{from:o,to:Math.max(l,o+1)}}function x(e){var t=e.display,r=t.view;if(t.alignWidgets||t.gutters.firstChild&&e.options.fixedGutter){for(var n=L(t)-t.scroller.scrollLeft+e.doc.scrollLeft,i=t.gutters.offsetWidth,o=n+"px",l=0;l<r.length;l++)if(!r[l].hidden){e.options.fixedGutter&&r[l].gutter&&(r[l].gutter.style.left=o);var s=r[l].alignable;if(s)for(var a=0;a<s.length;a++)s[a].style.left=o}e.options.fixedGutter&&(t.gutters.style.left=n+i+"px")}}function C(e){if(!e.options.lineNumbers)return!1;var t=e.doc,r=S(e.options,t.first+t.size-1),n=e.display;if(r.length!=n.lineNumChars){var i=n.measure.appendChild(Ui("div",[Ui("div",r)],"CodeMirror-linenumber CodeMirror-gutter-elt")),o=i.firstChild.offsetWidth,l=i.offsetWidth-o;return n.lineGutter.style.width="",n.lineNumInnerWidth=Math.max(o,n.lineGutter.offsetWidth-l)+1,n.lineNumWidth=n.lineNumInnerWidth+l,n.lineNumChars=n.lineNumInnerWidth?r.length:-1,n.lineGutter.style.width=n.lineNumWidth+"px",c(e),!0}return!1}function S(e,t){return String(e.lineNumberFormatter(t+e.firstLineNumber))}function L(e){return e.scroller.getBoundingClientRect().left-e.sizer.getBoundingClientRect().left}function T(e,t,r){var n=e.display;this.viewport=t,this.visible=w(n,e.doc,t),this.editorIsHidden=!n.wrapper.offsetWidth,this.wrapperHeight=n.wrapper.clientHeight,this.wrapperWidth=n.wrapper.clientWidth,this.oldDisplayWidth=Ye(e),this.force=r,this.dims=H(e),this.events=[]}function k(e){var t=e.display;!t.scrollbarsClipped&&t.scroller.offsetWidth&&(t.nativeBarWidth=t.scroller.offsetWidth-t.scroller.clientWidth,t.heightForcer.style.height=Xe(e)+"px",t.sizer.style.marginBottom=-t.nativeBarWidth+"px",t.sizer.style.borderRightWidth=Xe(e)+"px",t.scrollbarsClipped=!0)}function M(e,t){var r=e.display,n=e.doc;if(t.editorIsHidden)return zt(e),!1;if(!t.force&&t.visible.from>=r.viewFrom&&t.visible.to<=r.viewTo&&(null==r.updateLineNumbers||r.updateLineNumbers>=r.viewTo)&&r.renderedView==r.view&&0==Gt(e))return!1;C(e)&&(zt(e),t.dims=H(e));var i=n.first+n.size,o=Math.max(t.visible.from-e.options.viewportMargin,n.first),l=Math.min(i,t.visible.to+e.options.viewportMargin);r.viewFrom<o&&o-r.viewFrom<20&&(o=Math.max(n.first,r.viewFrom)),r.viewTo>l&&r.viewTo-l<20&&(l=Math.min(i,r.viewTo)),Io&&(o=wn(e.doc,o),l=xn(e.doc,l));var s=o!=r.viewFrom||l!=r.viewTo||r.lastWrapHeight!=t.wrapperHeight||r.lastWrapWidth!=t.wrapperWidth;Bt(e,o,l),r.viewOffset=ni(Zn(e.doc,r.viewFrom)),e.display.mover.style.top=r.viewOffset+"px";var a=Gt(e);if(!s&&0==a&&!t.force&&r.renderedView==r.view&&(null==r.updateLineNumbers||r.updateLineNumbers>=r.viewTo))return!1;var u=ji();return a>4&&(r.lineDiv.style.display="none"),P(e,r.updateLineNumbers,t.dims),a>4&&(r.lineDiv.style.display=""),r.renderedView=r.view,u&&ji()!=u&&u.offsetHeight&&u.focus(),Vi(r.cursorDiv),Vi(r.selectionDiv),r.gutters.style.height=r.sizer.style.minHeight=0,s&&(r.lastWrapHeight=t.wrapperHeight,r.lastWrapWidth=t.wrapperWidth,Re(e,400)),r.updateLineNumbers=null,!0}function N(e,t){for(var r=t.viewport,n=!0;(n&&e.options.lineWrapping&&t.oldDisplayWidth!=Ye(e)||(r&&null!=r.top&&(r={top:Math.min(e.doc.height+Ke(e.display)-_e(e),r.top)}),t.visible=w(e.display,e.doc,r),!(t.visible.from>=e.display.viewFrom&&t.visible.to<=e.display.viewTo)))&&M(e,t);n=!1){O(e);var i=p(e);Pe(e),A(e,i),y(e,i)}t.signal(e,"update",e),e.display.viewFrom==e.display.reportedViewFrom&&e.display.viewTo==e.display.reportedViewTo||(t.signal(e,"viewportChange",e,e.display.viewFrom,e.display.viewTo),e.display.reportedViewFrom=e.display.viewFrom,e.display.reportedViewTo=e.display.viewTo)}function W(e,t){var r=new T(e,t);if(M(e,r)){O(e),N(e,r);var n=p(e);Pe(e),A(e,n),y(e,n),r.finish()}}function A(e,t){e.display.sizer.style.minHeight=t.docHeight+"px";var r=t.docHeight+e.display.barHeight;e.display.heightForcer.style.top=r+"px",e.display.gutters.style.height=Math.max(r+Xe(e),t.clientHeight)+"px"}function O(e){for(var t=e.display,r=t.lineDiv.offsetTop,n=0;n<t.view.length;n++){var i,o=t.view[n];if(!o.hidden){if(bo&&wo<8){var l=o.node.offsetTop+o.node.offsetHeight;i=l-r,r=l}else{var s=o.node.getBoundingClientRect();i=s.bottom-s.top}var a=o.line.height-i;if(i<2&&(i=yt(t)),(a>.001||a<-.001)&&(ei(o.line,i),D(o.line),o.rest))for(var u=0;u<o.rest.length;u++)D(o.rest[u])}}}function D(e){if(e.widgets)for(var t=0;t<e.widgets.length;++t)e.widgets[t].height=e.widgets[t].node.parentNode.offsetHeight}function H(e){for(var t=e.display,r={},n={},i=t.gutters.clientLeft,o=t.gutters.firstChild,l=0;o;o=o.nextSibling,++l)r[e.options.gutters[l]]=o.offsetLeft+o.clientLeft+i,n[e.options.gutters[l]]=o.clientWidth;return{fixedPos:L(t),gutterTotalWidth:t.gutters.offsetWidth,gutterLeft:r,gutterWidth:n,wrapperWidth:t.wrapper.clientWidth}}function P(e,t,r){function n(t){var r=t.nextSibling;return xo&&Ao&&e.display.currentWheelTarget==t?t.style.display="none":t.parentNode.removeChild(t),r}for(var i=e.display,o=e.options.lineNumbers,l=i.lineDiv,s=l.firstChild,a=i.view,u=i.viewFrom,c=0;c<a.length;c++){var h=a[c];if(h.hidden);else if(h.node&&h.node.parentNode==l){for(;s!=h.node;)s=n(s);var f=o&&null!=t&&t<=u&&h.lineNumber;h.changes&&(Hi(h.changes,"gutter")>-1&&(f=!1),E(e,h,u,r)),f&&(Vi(h.lineNumber),h.lineNumber.appendChild(document.createTextNode(S(e.options,u)))),s=h.node.nextSibling}else{var d=V(e,h,u,r);l.insertBefore(d,s)}u+=h.size}for(;s;)s=n(s)}function E(e,t,r,n){for(var i=0;i<t.changes.length;i++){var o=t.changes[i];"text"==o?R(e,t):"gutter"==o?G(e,t,r,n):"class"==o?B(t):"widget"==o&&U(e,t,n)}t.changes=null}function I(e){return e.node==e.text&&(e.node=Ui("div",null,null,"position: relative"),e.text.parentNode&&e.text.parentNode.replaceChild(e.node,e.text),e.node.appendChild(e.text),bo&&wo<8&&(e.node.style.zIndex=2)),e.node}function z(e){var t=e.bgClass?e.bgClass+" "+(e.line.bgClass||""):e.line.bgClass;if(t&&(t+=" CodeMirror-linebackground"),e.background)t?e.background.className=t:(e.background.parentNode.removeChild(e.background),e.background=null);else if(t){var r=I(e);e.background=r.insertBefore(Ui("div",null,t),r.firstChild)}}function F(e,t){var r=e.display.externalMeasured;return r&&r.line==t.line?(e.display.externalMeasured=null,t.measure=r.measure,r.built):Fn(e,t)}function R(e,t){var r=t.text.className,n=F(e,t);t.text==t.node&&(t.node=n.pre),t.text.parentNode.replaceChild(n.pre,t.text),t.text=n.pre,n.bgClass!=t.bgClass||n.textClass!=t.textClass?(t.bgClass=n.bgClass,t.textClass=n.textClass,B(t)):r&&(t.text.className=r)}function B(e){z(e),e.line.wrapClass?I(e).className=e.line.wrapClass:e.node!=e.text&&(e.node.className="");var t=e.textClass?e.textClass+" "+(e.line.textClass||""):e.line.textClass;e.text.className=t||""}function G(e,t,r,n){if(t.gutter&&(t.node.removeChild(t.gutter),t.gutter=null),t.gutterBackground&&(t.node.removeChild(t.gutterBackground),t.gutterBackground=null),t.line.gutterClass){var i=I(t);t.gutterBackground=Ui("div",null,"CodeMirror-gutter-background "+t.line.gutterClass,"left: "+(e.options.fixedGutter?n.fixedPos:-n.gutterTotalWidth)+"px; width: "+n.gutterTotalWidth+"px"),i.insertBefore(t.gutterBackground,t.text)}var o=t.line.gutterMarkers;if(e.options.lineNumbers||o){var i=I(t),l=t.gutter=Ui("div",null,"CodeMirror-gutter-wrapper","left: "+(e.options.fixedGutter?n.fixedPos:-n.gutterTotalWidth)+"px");if(e.display.input.setUneditable(l),i.insertBefore(l,t.text),t.line.gutterClass&&(l.className+=" "+t.line.gutterClass),!e.options.lineNumbers||o&&o["CodeMirror-linenumbers"]||(t.lineNumber=l.appendChild(Ui("div",S(e.options,r),"CodeMirror-linenumber CodeMirror-gutter-elt","left: "+n.gutterLeft["CodeMirror-linenumbers"]+"px; width: "+e.display.lineNumInnerWidth+"px"))),o)for(var s=0;s<e.options.gutters.length;++s){var a=e.options.gutters[s],u=o.hasOwnProperty(a)&&o[a];u&&l.appendChild(Ui("div",[u],"CodeMirror-gutter-elt","left: "+n.gutterLeft[a]+"px; width: "+n.gutterWidth[a]+"px"))}}}function U(e,t,r){t.alignable&&(t.alignable=null);for(var n,i=t.node.firstChild;i;i=n){var n=i.nextSibling;"CodeMirror-linewidget"==i.className&&t.node.removeChild(i)}K(e,t,r)}function V(e,t,r,n){var i=F(e,t);return t.text=t.node=i.pre,i.bgClass&&(t.bgClass=i.bgClass),i.textClass&&(t.textClass=i.textClass),B(t),G(e,t,r,n),K(e,t,n),t.node}function K(e,t,r){if(j(e,t.line,t,r,!0),t.rest)for(var n=0;n<t.rest.length;n++)j(e,t.rest[n],t,r,!1)}function j(e,t,r,n,i){if(t.widgets)for(var o=I(r),l=0,s=t.widgets;l<s.length;++l){var a=s[l],u=Ui("div",[a.node],"CodeMirror-linewidget");a.handleMouseEvents||u.setAttribute("cm-ignore-events","true"),X(a,u,r,n),e.display.input.setUneditable(u),i&&a.above?o.insertBefore(u,r.gutter||r.text):o.appendChild(u),Li(a,"redraw")}}function X(e,t,r,n){if(e.noHScroll){(r.alignable||(r.alignable=[])).push(t);var i=n.wrapperWidth;t.style.left=n.fixedPos+"px",e.coverGutter||(i-=n.gutterTotalWidth,t.style.paddingLeft=n.gutterTotalWidth+"px"),t.style.width=i+"px"}e.coverGutter&&(t.style.zIndex=5,t.style.position="relative",e.noHScroll||(t.style.marginLeft=-n.gutterTotalWidth+"px"))}function Y(e){return zo(e.line,e.ch)}function _(e,t){return Fo(e,t)<0?t:e}function $(e,t){return Fo(e,t)<0?e:t}function q(e){e.state.focused||(e.display.input.focus(),vr(e))}function Z(e,t,r,n,i){var o=e.doc;e.display.shift=!1,n||(n=o.sel);var l=e.state.pasteIncoming||"paste"==i,s=o.splitLines(t),a=null;if(l&&n.ranges.length>1)if(Ro&&Ro.join("\n")==t){if(n.ranges.length%Ro.length==0){a=[];for(var u=0;u<Ro.length;u++)a.push(o.splitLines(Ro[u]))}}else s.length==n.ranges.length&&(a=Pi(s,function(e){return[e]}));for(var u=n.ranges.length-1;u>=0;u--){var c=n.ranges[u],h=c.from(),f=c.to();c.empty()&&(r&&r>0?h=zo(h.line,h.ch-r):e.state.overwrite&&!l&&(f=zo(f.line,Math.min(Zn(o,f.line).text.length,f.ch+Di(s).length))));var d=e.curOp.updateInput,p={from:h,to:f,text:a?a[u%a.length]:s,origin:i||(l?"paste":e.state.cutIncoming?"cut":"+input")};Tr(e.doc,p),Li(e,"inputRead",e,p)}t&&!l&&J(e,t),zr(e),e.curOp.updateInput=d,e.curOp.typing=!0,e.state.pasteIncoming=e.state.cutIncoming=!1}function Q(e,t){var r=e.clipboardData&&e.clipboardData.getData("text/plain");if(r)return e.preventDefault(),t.isReadOnly()||t.options.disableInput||Wt(t,function(){Z(t,r,0,null,"paste")}),!0}function J(e,t){if(e.options.electricChars&&e.options.smartIndent)for(var r=e.doc.sel,n=r.ranges.length-1;n>=0;n--){var i=r.ranges[n];if(!(i.head.ch>100||n&&r.ranges[n-1].head.line==i.head.line)){var o=e.getModeAt(i.head),l=!1;if(o.electricChars){for(var s=0;s<o.electricChars.length;s++)if(t.indexOf(o.electricChars.charAt(s))>-1){l=Rr(e,i.head.line,"smart");break}}else o.electricInput&&o.electricInput.test(Zn(e.doc,i.head.line).text.slice(0,i.head.ch))&&(l=Rr(e,i.head.line,"smart"));l&&Li(e,"electricInput",e,i.head.line)}}}function ee(e){for(var t=[],r=[],n=0;n<e.doc.sel.ranges.length;n++){var i=e.doc.sel.ranges[n].head.line,o={anchor:zo(i,0),head:zo(i+1,0)};r.push(o),t.push(e.getRange(o.anchor,o.head))}return{text:t,ranges:r}}function te(e){e.setAttribute("autocorrect","off"),e.setAttribute("autocapitalize","off"),e.setAttribute("spellcheck","false")}function re(e){this.cm=e,this.prevInput="",this.pollingFast=!1,this.polling=new Ai,this.inaccurateSelection=!1,this.hasSelection=!1,this.composing=null}function ne(){var e=Ui("textarea",null,null,"position: absolute; padding: 0; width: 1px; height: 1em; outline: none"),t=Ui("div",[e],null,"overflow: hidden; position: relative; width: 3px; height: 0px;");return xo?e.style.width="1000px":e.setAttribute("wrap","off"),No&&(e.style.border="1px solid black"),te(e),t}function ie(e){this.cm=e,this.lastAnchorNode=this.lastAnchorOffset=this.lastFocusNode=this.lastFocusOffset=null,this.polling=new Ai,this.gracePeriod=!1}function oe(e,t){var r=Je(e,t.line);if(!r||r.hidden)return null;var n=Zn(e.doc,t.line),i=qe(r,n,t.line),o=ii(n),l="left";if(o){var s=uo(o,t.ch);l=s%2?"right":"left"}var a=rt(i.map,t.ch,l);return a.offset="right"==a.collapse?a.end:a.start,a}function le(e,t){return t&&(e.bad=!0),e}function se(e,t,r){var n;if(t==e.display.lineDiv){if(n=e.display.lineDiv.childNodes[r],!n)return le(e.clipPos(zo(e.display.viewTo-1)),!0);t=null,r=0}else for(n=t;;n=n.parentNode){if(!n||n==e.display.lineDiv)return null;if(n.parentNode&&n.parentNode==e.display.lineDiv)break}for(var i=0;i<e.display.view.length;i++){var o=e.display.view[i];if(o.node==n)return ae(o,t,r)}}function ae(e,t,r){function n(t,r,n){for(var i=-1;i<(c?c.length:0);i++)for(var o=i<0?u.map:c[i],l=0;l<o.length;l+=3){var s=o[l+2];if(s==t||s==r){var a=ti(i<0?e.line:e.rest[i]),h=o[l]+n;return(n<0||s!=t)&&(h=o[l+(n?1:0)]),zo(a,h)}}}var i=e.text.firstChild,o=!1;if(!t||!Yl(i,t))return le(zo(ti(e.line),0),!0);if(t==i&&(o=!0,t=i.childNodes[r],r=0,!t)){var l=e.rest?Di(e.rest):e.line;return le(zo(ti(l),l.text.length),o)}var s=3==t.nodeType?t:null,a=t;for(s||1!=t.childNodes.length||3!=t.firstChild.nodeType||(s=t.firstChild,r&&(r=s.nodeValue.length));a.parentNode!=i;)a=a.parentNode;var u=e.measure,c=u.maps,h=n(s,a,r);if(h)return le(h,o);for(var f=a.nextSibling,d=s?s.nodeValue.length-r:0;f;f=f.nextSibling){if(h=n(f,f.firstChild,0))return le(zo(h.line,h.ch-d),o);d+=f.textContent.length}for(var p=a.previousSibling,d=r;p;p=p.previousSibling){if(h=n(p,p.firstChild,-1))return le(zo(h.line,h.ch+d),o);d+=f.textContent.length}}function ue(e,t,r,n,i){function o(e){return function(t){return t.id==e}}function l(t){if(1==t.nodeType){var r=t.getAttribute("cm-text");if(null!=r)return""==r&&(r=t.textContent.replace(/\u200b/g,"")),void(s+=r);var c,h=t.getAttribute("cm-marker");if(h){var f=e.findMarks(zo(n,0),zo(i+1,0),o(+h));return void(f.length&&(c=f[0].find())&&(s+=Qn(e.doc,c.from,c.to).join(u)))}if("false"==t.getAttribute("contenteditable"))return;for(var d=0;d<t.childNodes.length;d++)l(t.childNodes[d]);/^(pre|div|p)$/i.test(t.nodeName)&&(a=!0)}else if(3==t.nodeType){var p=t.nodeValue;if(!p)return;a&&(s+=u,a=!1),s+=p}}for(var s="",a=!1,u=e.doc.lineSeparator();l(t),t!=r;)t=t.nextSibling;return s}function ce(e,t){this.ranges=e,this.primIndex=t}function he(e,t){this.anchor=e,this.head=t}function fe(e,t){var r=e[t];e.sort(function(e,t){return Fo(e.from(),t.from())}),t=Hi(e,r);for(var n=1;n<e.length;n++){var i=e[n],o=e[n-1];if(Fo(o.to(),i.from())>=0){var l=$(o.from(),i.from()),s=_(o.to(),i.to()),a=o.empty()?i.from()==i.head:o.from()==o.head;n<=t&&--t,e.splice(--n,2,new he(a?s:l,a?l:s))}}return new ce(e,t)}function de(e,t){return new ce([new he(e,t||e)],0)}function pe(e,t){return Math.max(e.first,Math.min(t,e.first+e.size-1))}function ge(e,t){if(t.line<e.first)return zo(e.first,0);var r=e.first+e.size-1;return t.line>r?zo(r,Zn(e,r).text.length):ve(t,Zn(e,t.line).text.length)}function ve(e,t){var r=e.ch;return null==r||r>t?zo(e.line,t):r<0?zo(e.line,0):e}function me(e,t){return t>=e.first&&t<e.first+e.size}function ye(e,t){for(var r=[],n=0;n<t.length;n++)r[n]=ge(e,t[n]);return r}function be(e,t,r,n){if(e.cm&&e.cm.display.shift||e.extend){var i=t.anchor;if(n){var o=Fo(r,i)<0;o!=Fo(n,i)<0?(i=r,r=n):o!=Fo(r,n)<0&&(r=n)}return new he(i,r)}return new he(n||r,r)}function we(e,t,r,n){ke(e,new ce([be(e,e.sel.primary(),t,r)],0),n)}function xe(e,t,r){for(var n=[],i=0;i<e.sel.ranges.length;i++)n[i]=be(e,e.sel.ranges[i],t[i],null);var o=fe(n,e.sel.primIndex);ke(e,o,r)}function Ce(e,t,r,n){var i=e.sel.ranges.slice(0);i[t]=r,ke(e,fe(i,e.sel.primIndex),n)}function Se(e,t,r,n){ke(e,de(t,r),n)}function Le(e,t,r){var n={ranges:t.ranges,update:function(t){this.ranges=[];for(var r=0;r<t.length;r++)this.ranges[r]=new he(ge(e,t[r].anchor),ge(e,t[r].head))},origin:r&&r.origin};return Dl(e,"beforeSelectionChange",e,n),e.cm&&Dl(e.cm,"beforeSelectionChange",e.cm,n),n.ranges!=t.ranges?fe(n.ranges,n.ranges.length-1):t}function Te(e,t,r){var n=e.history.done,i=Di(n);i&&i.ranges?(n[n.length-1]=t,Me(e,t,r)):ke(e,t,r)}function ke(e,t,r){Me(e,t,r),hi(e,e.sel,e.cm?e.cm.curOp.id:NaN,r)}function Me(e,t,r){(Ni(e,"beforeSelectionChange")||e.cm&&Ni(e.cm,"beforeSelectionChange"))&&(t=Le(e,t,r));var n=r&&r.bias||(Fo(t.primary().head,e.sel.primary().head)<0?-1:1);Ne(e,Ae(e,t,n,!0)),r&&r.scroll===!1||!e.cm||zr(e.cm)}function Ne(e,t){t.equals(e.sel)||(e.sel=t,e.cm&&(e.cm.curOp.updateInput=e.cm.curOp.selectionChanged=!0,Mi(e.cm)),Li(e,"cursorActivity",e))}function We(e){Ne(e,Ae(e,e.sel,null,!1),Il)}function Ae(e,t,r,n){for(var i,o=0;o<t.ranges.length;o++){var l=t.ranges[o],s=t.ranges.length==e.sel.ranges.length&&e.sel.ranges[o],a=De(e,l.anchor,s&&s.anchor,r,n),u=De(e,l.head,s&&s.head,r,n);(i||a!=l.anchor||u!=l.head)&&(i||(i=t.ranges.slice(0,o)),i[o]=new he(a,u))}return i?fe(i,t.primIndex):t}function Oe(e,t,r,n,i){var o=Zn(e,t.line);if(o.markedSpans)for(var l=0;l<o.markedSpans.length;++l){var s=o.markedSpans[l],a=s.marker;if((null==s.from||(a.inclusiveLeft?s.from<=t.ch:s.from<t.ch))&&(null==s.to||(a.inclusiveRight?s.to>=t.ch:s.to>t.ch))){if(i&&(Dl(a,"beforeCursorEnter"),a.explicitlyCleared)){if(o.markedSpans){--l;continue}break}if(!a.atomic)continue;if(r){var u,c=a.find(n<0?1:-1);if((n<0?a.inclusiveRight:a.inclusiveLeft)&&(c=He(e,c,-n,o)),c&&c.line==t.line&&(u=Fo(c,r))&&(n<0?u<0:u>0))return Oe(e,c,t,n,i)}var h=a.find(n<0?-1:1);return(n<0?a.inclusiveLeft:a.inclusiveRight)&&(h=He(e,h,n,o)),h?Oe(e,h,t,n,i):null}}return t}function De(e,t,r,n,i){var o=n||1,l=Oe(e,t,r,o,i)||!i&&Oe(e,t,r,o,!0)||Oe(e,t,r,-o,i)||!i&&Oe(e,t,r,-o,!0);return l?l:(e.cantEdit=!0,zo(e.first,0))}function He(e,t,r,n){return r<0&&0==t.ch?t.line>e.first?ge(e,zo(t.line-1)):null:r>0&&t.ch==(n||Zn(e,t.line)).text.length?t.line<e.first+e.size-1?zo(t.line+1,0):null:new zo(t.line,t.ch+r)}function Pe(e){e.display.input.showSelection(e.display.input.prepareSelection())}function Ee(e,t){for(var r=e.doc,n={},i=n.cursors=document.createDocumentFragment(),o=n.selection=document.createDocumentFragment(),l=0;l<r.sel.ranges.length;l++)if(t!==!1||l!=r.sel.primIndex){var s=r.sel.ranges[l],a=s.empty();(a||e.options.showCursorWhenSelecting)&&Ie(e,s.head,i),a||ze(e,s,o)}return n}function Ie(e,t,r){var n=dt(e,t,"div",null,null,!e.options.singleCursorHeightPerLine),i=r.appendChild(Ui("div"," ","CodeMirror-cursor"));if(i.style.left=n.left+"px",i.style.top=n.top+"px",i.style.height=Math.max(0,n.bottom-n.top)*e.options.cursorHeight+"px",n.other){var o=r.appendChild(Ui("div"," ","CodeMirror-cursor CodeMirror-secondarycursor"));o.style.display="",o.style.left=n.other.left+"px",o.style.top=n.other.top+"px",o.style.height=.85*(n.other.bottom-n.other.top)+"px"}}function ze(e,t,r){function n(e,t,r,n){t<0&&(t=0),t=Math.round(t),n=Math.round(n),s.appendChild(Ui("div",null,"CodeMirror-selected","position: absolute; left: "+e+"px; top: "+t+"px; width: "+(null==r?c-e:r)+"px; height: "+(n-t)+"px"))}function i(t,r,i){function o(r,n){return ft(e,zo(t,r),"div",h,n)}var s,a,h=Zn(l,t),f=h.text.length;return eo(ii(h),r||0,null==i?f:i,function(e,t,l){var h,d,p,g=o(e,"left");if(e==t)h=g,d=p=g.left;else{if(h=o(t-1,"right"),"rtl"==l){var v=g;g=h,h=v}d=g.left,p=h.right}null==r&&0==e&&(d=u),h.top-g.top>3&&(n(d,g.top,null,g.bottom),d=u,g.bottom<h.top&&n(d,g.bottom,null,h.top)),null==i&&t==f&&(p=c),(!s||g.top<s.top||g.top==s.top&&g.left<s.left)&&(s=g),(!a||h.bottom>a.bottom||h.bottom==a.bottom&&h.right>a.right)&&(a=h),d<u+1&&(d=u),n(d,h.top,p-d,h.bottom)}),{start:s,end:a}}var o=e.display,l=e.doc,s=document.createDocumentFragment(),a=je(e.display),u=a.left,c=Math.max(o.sizerWidth,Ye(e)-o.sizer.offsetLeft)-a.right,h=t.from(),f=t.to();if(h.line==f.line)i(h.line,h.ch,f.ch);else{var d=Zn(l,h.line),p=Zn(l,f.line),g=yn(d)==yn(p),v=i(h.line,h.ch,g?d.text.length+1:null).end,m=i(f.line,g?0:null,f.ch).start;g&&(v.top<m.top-2?(n(v.right,v.top,null,v.bottom),n(u,m.top,m.left,m.bottom)):n(v.right,v.top,m.left-v.right,v.bottom)),v.bottom<m.top&&n(u,v.bottom,null,m.top)}r.appendChild(s)}function Fe(e){if(e.state.focused){var t=e.display;clearInterval(t.blinker);var r=!0;t.cursorDiv.style.visibility="",e.options.cursorBlinkRate>0?t.blinker=setInterval(function(){t.cursorDiv.style.visibility=(r=!r)?"":"hidden"},e.options.cursorBlinkRate):e.options.cursorBlinkRate<0&&(t.cursorDiv.style.visibility="hidden")}}function Re(e,t){e.doc.mode.startState&&e.doc.frontier<e.display.viewTo&&e.state.highlight.set(t,Fi(Be,e))}function Be(e){var t=e.doc;if(t.frontier<t.first&&(t.frontier=t.first),!(t.frontier>=e.display.viewTo)){var r=+new Date+e.options.workTime,n=sl(t.mode,Ue(e,t.frontier)),i=[];t.iter(t.frontier,Math.min(t.first+t.size,e.display.viewTo+500),function(o){if(t.frontier>=e.display.viewFrom){var l=o.styles,s=o.text.length>e.options.maxHighlightLength,a=Pn(e,o,s?sl(t.mode,n):n,!0);o.styles=a.styles;var u=o.styleClasses,c=a.classes;c?o.styleClasses=c:u&&(o.styleClasses=null);for(var h=!l||l.length!=o.styles.length||u!=c&&(!u||!c||u.bgClass!=c.bgClass||u.textClass!=c.textClass),f=0;!h&&f<l.length;++f)h=l[f]!=o.styles[f];h&&i.push(t.frontier),o.stateAfter=s?n:sl(t.mode,n)}else o.text.length<=e.options.maxHighlightLength&&In(e,o.text,n),o.stateAfter=t.frontier%5==0?sl(t.mode,n):null;if(++t.frontier,+new Date>r)return Re(e,e.options.workDelay),!0}),i.length&&Wt(e,function(){for(var t=0;t<i.length;t++)It(e,i[t],"text")})}}function Ge(e,t,r){for(var n,i,o=e.doc,l=r?-1:t-(e.doc.mode.innerMode?1e3:100),s=t;s>l;--s){if(s<=o.first)return o.first;var a=Zn(o,s-1);if(a.stateAfter&&(!r||s<=o.frontier))return s;var u=Rl(a.text,null,e.options.tabSize);(null==i||n>u)&&(i=s-1,n=u)}return i}function Ue(e,t,r){var n=e.doc,i=e.display;if(!n.mode.startState)return!0;var o=Ge(e,t,r),l=o>n.first&&Zn(n,o-1).stateAfter;return l=l?sl(n.mode,l):al(n.mode),n.iter(o,t,function(r){In(e,r.text,l);var s=o==t-1||o%5==0||o>=i.viewFrom&&o<i.viewTo;r.stateAfter=s?sl(n.mode,l):null,++o}),r&&(n.frontier=o),l}function Ve(e){return e.lineSpace.offsetTop}function Ke(e){return e.mover.offsetHeight-e.lineSpace.offsetHeight}function je(e){if(e.cachedPaddingH)return e.cachedPaddingH;var t=Ki(e.measure,Ui("pre","x")),r=window.getComputedStyle?window.getComputedStyle(t):t.currentStyle,n={left:parseInt(r.paddingLeft),right:parseInt(r.paddingRight)};return isNaN(n.left)||isNaN(n.right)||(e.cachedPaddingH=n),n}function Xe(e){return Pl-e.display.nativeBarWidth}function Ye(e){return e.display.scroller.clientWidth-Xe(e)-e.display.barWidth}function _e(e){return e.display.scroller.clientHeight-Xe(e)-e.display.barHeight}function $e(e,t,r){var n=e.options.lineWrapping,i=n&&Ye(e);if(!t.measure.heights||n&&t.measure.width!=i){var o=t.measure.heights=[];if(n){t.measure.width=i;for(var l=t.text.firstChild.getClientRects(),s=0;s<l.length-1;s++){var a=l[s],u=l[s+1];Math.abs(a.bottom-u.bottom)>2&&o.push((a.bottom+u.top)/2-r.top)}}o.push(r.bottom-r.top)}}function qe(e,t,r){if(e.line==t)return{map:e.measure.map,cache:e.measure.cache};for(var n=0;n<e.rest.length;n++)if(e.rest[n]==t)return{map:e.measure.maps[n],cache:e.measure.caches[n]};for(var n=0;n<e.rest.length;n++)if(ti(e.rest[n])>r)return{map:e.measure.maps[n],cache:e.measure.caches[n],before:!0}}function Ze(e,t){t=yn(t);var r=ti(t),n=e.display.externalMeasured=new Ht(e.doc,t,r);n.lineN=r;var i=n.built=Fn(e,n);return n.text=i.pre,Ki(e.display.lineMeasure,i.pre),n}function Qe(e,t,r,n){return tt(e,et(e,t),r,n)}function Je(e,t){if(t>=e.display.viewFrom&&t<e.display.viewTo)return e.display.view[Ft(e,t)];var r=e.display.externalMeasured;return r&&t>=r.lineN&&t<r.lineN+r.size?r:void 0}function et(e,t){var r=ti(t),n=Je(e,r);n&&!n.text?n=null:n&&n.changes&&(E(e,n,r,H(e)),e.curOp.forceUpdate=!0),n||(n=Ze(e,t));var i=qe(n,t,r);return{line:t,view:n,rect:null,map:i.map,cache:i.cache,before:i.before,hasHeights:!1}}function tt(e,t,r,n,i){t.before&&(r=-1);var o,l=r+(n||"");return t.cache.hasOwnProperty(l)?o=t.cache[l]:(t.rect||(t.rect=t.view.text.getBoundingClientRect()),t.hasHeights||($e(e,t.view,t.rect),t.hasHeights=!0),o=nt(e,t,r,n),o.bogus||(t.cache[l]=o)),{left:o.left,right:o.right,top:i?o.rtop:o.top,bottom:i?o.rbottom:o.bottom}}function rt(e,t,r){for(var n,i,o,l,s=0;s<e.length;s+=3){var a=e[s],u=e[s+1];if(t<a?(i=0,o=1,l="left"):t<u?(i=t-a,o=i+1):(s==e.length-3||t==u&&e[s+3]>t)&&(o=u-a,i=o-1,t>=u&&(l="right")),null!=i){if(n=e[s+2],a==u&&r==(n.insertLeft?"left":"right")&&(l=r),"left"==r&&0==i)for(;s&&e[s-2]==e[s-3]&&e[s-1].insertLeft;)n=e[(s-=3)+2],l="left";if("right"==r&&i==u-a)for(;s<e.length-3&&e[s+3]==e[s+4]&&!e[s+5].insertLeft;)n=e[(s+=3)+2],
2
- l="right";break}}return{node:n,start:i,end:o,collapse:l,coverStart:a,coverEnd:u}}function nt(e,t,r,n){var i,o=rt(t.map,r,n),l=o.node,s=o.start,a=o.end,u=o.collapse;if(3==l.nodeType){for(var c=0;c<4;c++){for(;s&&Gi(t.line.text.charAt(o.coverStart+s));)--s;for(;o.coverStart+a<o.coverEnd&&Gi(t.line.text.charAt(o.coverStart+a));)++a;if(bo&&wo<9&&0==s&&a==o.coverEnd-o.coverStart)i=l.parentNode.getBoundingClientRect();else if(bo&&e.options.lineWrapping){var h=Vl(l,s,a).getClientRects();i=h.length?h["right"==n?h.length-1:0]:Vo}else i=Vl(l,s,a).getBoundingClientRect()||Vo;if(i.left||i.right||0==s)break;a=s,s-=1,u="right"}bo&&wo<11&&(i=it(e.display.measure,i))}else{s>0&&(u=n="right");var h;i=e.options.lineWrapping&&(h=l.getClientRects()).length>1?h["right"==n?h.length-1:0]:l.getBoundingClientRect()}if(bo&&wo<9&&!s&&(!i||!i.left&&!i.right)){var f=l.parentNode.getClientRects()[0];i=f?{left:f.left,right:f.left+bt(e.display),top:f.top,bottom:f.bottom}:Vo}for(var d=i.top-t.rect.top,p=i.bottom-t.rect.top,g=(d+p)/2,v=t.view.measure.heights,c=0;c<v.length-1&&!(g<v[c]);c++);var m=c?v[c-1]:0,y=v[c],b={left:("right"==u?i.right:i.left)-t.rect.left,right:("left"==u?i.left:i.right)-t.rect.left,top:m,bottom:y};return i.left||i.right||(b.bogus=!0),e.options.singleCursorHeightPerLine||(b.rtop=d,b.rbottom=p),b}function it(e,t){if(!window.screen||null==screen.logicalXDPI||screen.logicalXDPI==screen.deviceXDPI||!Ji(e))return t;var r=screen.logicalXDPI/screen.deviceXDPI,n=screen.logicalYDPI/screen.deviceYDPI;return{left:t.left*r,right:t.right*r,top:t.top*n,bottom:t.bottom*n}}function ot(e){if(e.measure&&(e.measure.cache={},e.measure.heights=null,e.rest))for(var t=0;t<e.rest.length;t++)e.measure.caches[t]={}}function lt(e){e.display.externalMeasure=null,Vi(e.display.lineMeasure);for(var t=0;t<e.display.view.length;t++)ot(e.display.view[t])}function st(e){lt(e),e.display.cachedCharWidth=e.display.cachedTextHeight=e.display.cachedPaddingH=null,e.options.lineWrapping||(e.display.maxLineChanged=!0),e.display.lineNumChars=null}function at(){return window.pageXOffset||(document.documentElement||document.body).scrollLeft}function ut(){return window.pageYOffset||(document.documentElement||document.body).scrollTop}function ct(e,t,r,n){if(t.widgets)for(var i=0;i<t.widgets.length;++i)if(t.widgets[i].above){var o=Tn(t.widgets[i]);r.top+=o,r.bottom+=o}if("line"==n)return r;n||(n="local");var l=ni(t);if("local"==n?l+=Ve(e.display):l-=e.display.viewOffset,"page"==n||"window"==n){var s=e.display.lineSpace.getBoundingClientRect();l+=s.top+("window"==n?0:ut());var a=s.left+("window"==n?0:at());r.left+=a,r.right+=a}return r.top+=l,r.bottom+=l,r}function ht(e,t,r){if("div"==r)return t;var n=t.left,i=t.top;if("page"==r)n-=at(),i-=ut();else if("local"==r||!r){var o=e.display.sizer.getBoundingClientRect();n+=o.left,i+=o.top}var l=e.display.lineSpace.getBoundingClientRect();return{left:n-l.left,top:i-l.top}}function ft(e,t,r,n,i){return n||(n=Zn(e.doc,t.line)),ct(e,n,Qe(e,n,t.ch,i),r)}function dt(e,t,r,n,i,o){function l(t,l){var s=tt(e,i,t,l?"right":"left",o);return l?s.left=s.right:s.right=s.left,ct(e,n,s,r)}function s(e,t){var r=a[t],n=r.level%2;return e==to(r)&&t&&r.level<a[t-1].level?(r=a[--t],e=ro(r)-(r.level%2?0:1),n=!0):e==ro(r)&&t<a.length-1&&r.level<a[t+1].level&&(r=a[++t],e=to(r)-r.level%2,n=!1),n&&e==r.to&&e>r.from?l(e-1):l(e,n)}n=n||Zn(e.doc,t.line),i||(i=et(e,n));var a=ii(n),u=t.ch;if(!a)return l(u);var c=uo(a,u),h=s(u,c);return null!=os&&(h.other=s(u,os)),h}function pt(e,t){var r=0,t=ge(e.doc,t);e.options.lineWrapping||(r=bt(e.display)*t.ch);var n=Zn(e.doc,t.line),i=ni(n)+Ve(e.display);return{left:r,right:r,top:i,bottom:i+n.height}}function gt(e,t,r,n){var i=zo(e,t);return i.xRel=n,r&&(i.outside=!0),i}function vt(e,t,r){var n=e.doc;if(r+=e.display.viewOffset,r<0)return gt(n.first,0,!0,-1);var i=ri(n,r),o=n.first+n.size-1;if(i>o)return gt(n.first+n.size-1,Zn(n,o).text.length,!0,1);t<0&&(t=0);for(var l=Zn(n,i);;){var s=mt(e,l,i,t,r),a=vn(l),u=a&&a.find(0,!0);if(!a||!(s.ch>u.from.ch||s.ch==u.from.ch&&s.xRel>0))return s;i=ti(l=u.to.line)}}function mt(e,t,r,n,i){function o(n){var i=dt(e,zo(r,n),"line",t,u);return s=!0,l>i.bottom?i.left-a:l<i.top?i.left+a:(s=!1,i.left)}var l=i-ni(t),s=!1,a=2*e.display.wrapper.clientWidth,u=et(e,t),c=ii(t),h=t.text.length,f=no(t),d=io(t),p=o(f),g=s,v=o(d),m=s;if(n>v)return gt(r,d,m,1);for(;;){if(c?d==f||d==ho(t,f,1):d-f<=1){for(var y=n<p||n-p<=v-n?f:d,b=n-(y==f?p:v);Gi(t.text.charAt(y));)++y;var w=gt(r,y,y==f?g:m,b<-1?-1:b>1?1:0);return w}var x=Math.ceil(h/2),C=f+x;if(c){C=f;for(var S=0;S<x;++S)C=ho(t,C,1)}var L=o(C);L>n?(d=C,v=L,(m=s)&&(v+=1e3),h=x):(f=C,p=L,g=s,h-=x)}}function yt(e){if(null!=e.cachedTextHeight)return e.cachedTextHeight;if(null==Bo){Bo=Ui("pre");for(var t=0;t<49;++t)Bo.appendChild(document.createTextNode("x")),Bo.appendChild(Ui("br"));Bo.appendChild(document.createTextNode("x"))}Ki(e.measure,Bo);var r=Bo.offsetHeight/50;return r>3&&(e.cachedTextHeight=r),Vi(e.measure),r||1}function bt(e){if(null!=e.cachedCharWidth)return e.cachedCharWidth;var t=Ui("span","xxxxxxxxxx"),r=Ui("pre",[t]);Ki(e.measure,r);var n=t.getBoundingClientRect(),i=(n.right-n.left)/10;return i>2&&(e.cachedCharWidth=i),i||10}function wt(e){e.curOp={cm:e,viewChanged:!1,startHeight:e.doc.height,forceUpdate:!1,updateInput:null,typing:!1,changeObjs:null,cursorActivityHandlers:null,cursorActivityCalled:0,selectionChanged:!1,updateMaxLine:!1,scrollLeft:null,scrollTop:null,scrollToPos:null,focus:!1,id:++jo},Ko?Ko.ops.push(e.curOp):e.curOp.ownsGroup=Ko={ops:[e.curOp],delayedCallbacks:[]}}function xt(e){var t=e.delayedCallbacks,r=0;do{for(;r<t.length;r++)t[r].call(null);for(var n=0;n<e.ops.length;n++){var i=e.ops[n];if(i.cursorActivityHandlers)for(;i.cursorActivityCalled<i.cursorActivityHandlers.length;)i.cursorActivityHandlers[i.cursorActivityCalled++].call(null,i.cm)}}while(r<t.length)}function Ct(e){var t=e.curOp,r=t.ownsGroup;if(r)try{xt(r)}finally{Ko=null;for(var n=0;n<r.ops.length;n++)r.ops[n].cm.curOp=null;St(r)}}function St(e){for(var t=e.ops,r=0;r<t.length;r++)Lt(t[r]);for(var r=0;r<t.length;r++)Tt(t[r]);for(var r=0;r<t.length;r++)kt(t[r]);for(var r=0;r<t.length;r++)Mt(t[r]);for(var r=0;r<t.length;r++)Nt(t[r])}function Lt(e){var t=e.cm,r=t.display;k(t),e.updateMaxLine&&f(t),e.mustUpdate=e.viewChanged||e.forceUpdate||null!=e.scrollTop||e.scrollToPos&&(e.scrollToPos.from.line<r.viewFrom||e.scrollToPos.to.line>=r.viewTo)||r.maxLineChanged&&t.options.lineWrapping,e.update=e.mustUpdate&&new T(t,e.mustUpdate&&{top:e.scrollTop,ensure:e.scrollToPos},e.forceUpdate)}function Tt(e){e.updatedDisplay=e.mustUpdate&&M(e.cm,e.update)}function kt(e){var t=e.cm,r=t.display;e.updatedDisplay&&O(t),e.barMeasure=p(t),r.maxLineChanged&&!t.options.lineWrapping&&(e.adjustWidthTo=Qe(t,r.maxLine,r.maxLine.text.length).left+3,t.display.sizerWidth=e.adjustWidthTo,e.barMeasure.scrollWidth=Math.max(r.scroller.clientWidth,r.sizer.offsetLeft+e.adjustWidthTo+Xe(t)+t.display.barWidth),e.maxScrollLeft=Math.max(0,r.sizer.offsetLeft+e.adjustWidthTo-Ye(t))),(e.updatedDisplay||e.selectionChanged)&&(e.preparedSelection=r.input.prepareSelection())}function Mt(e){var t=e.cm;null!=e.adjustWidthTo&&(t.display.sizer.style.minWidth=e.adjustWidthTo+"px",e.maxScrollLeft<t.doc.scrollLeft&&ir(t,Math.min(t.display.scroller.scrollLeft,e.maxScrollLeft),!0),t.display.maxLineChanged=!1),e.preparedSelection&&t.display.input.showSelection(e.preparedSelection),e.updatedDisplay&&A(t,e.barMeasure),(e.updatedDisplay||e.startHeight!=t.doc.height)&&y(t,e.barMeasure),e.selectionChanged&&Fe(t),t.state.focused&&e.updateInput&&t.display.input.reset(e.typing),!e.focus||e.focus!=ji()||document.hasFocus&&!document.hasFocus()||q(e.cm)}function Nt(e){var t=e.cm,r=t.display,n=t.doc;if(e.updatedDisplay&&N(t,e.update),null==r.wheelStartX||null==e.scrollTop&&null==e.scrollLeft&&!e.scrollToPos||(r.wheelStartX=r.wheelStartY=null),null==e.scrollTop||r.scroller.scrollTop==e.scrollTop&&!e.forceScroll||(n.scrollTop=Math.max(0,Math.min(r.scroller.scrollHeight-r.scroller.clientHeight,e.scrollTop)),r.scrollbars.setScrollTop(n.scrollTop),r.scroller.scrollTop=n.scrollTop),null==e.scrollLeft||r.scroller.scrollLeft==e.scrollLeft&&!e.forceScroll||(n.scrollLeft=Math.max(0,Math.min(r.scroller.scrollWidth-Ye(t),e.scrollLeft)),r.scrollbars.setScrollLeft(n.scrollLeft),r.scroller.scrollLeft=n.scrollLeft,x(t)),e.scrollToPos){var i=Hr(t,ge(n,e.scrollToPos.from),ge(n,e.scrollToPos.to),e.scrollToPos.margin);e.scrollToPos.isCursor&&t.state.focused&&Dr(t,i)}var o=e.maybeHiddenMarkers,l=e.maybeUnhiddenMarkers;if(o)for(var s=0;s<o.length;++s)o[s].lines.length||Dl(o[s],"hide");if(l)for(var s=0;s<l.length;++s)l[s].lines.length&&Dl(l[s],"unhide");r.wrapper.offsetHeight&&(n.scrollTop=t.display.scroller.scrollTop),e.changeObjs&&Dl(t,"changes",t,e.changeObjs),e.update&&e.update.finish()}function Wt(e,t){if(e.curOp)return t();wt(e);try{return t()}finally{Ct(e)}}function At(e,t){return function(){if(e.curOp)return t.apply(e,arguments);wt(e);try{return t.apply(e,arguments)}finally{Ct(e)}}}function Ot(e){return function(){if(this.curOp)return e.apply(this,arguments);wt(this);try{return e.apply(this,arguments)}finally{Ct(this)}}}function Dt(e){return function(){var t=this.cm;if(!t||t.curOp)return e.apply(this,arguments);wt(t);try{return e.apply(this,arguments)}finally{Ct(t)}}}function Ht(e,t,r){this.line=t,this.rest=bn(t),this.size=this.rest?ti(Di(this.rest))-r+1:1,this.node=this.text=null,this.hidden=Cn(e,t)}function Pt(e,t,r){for(var n,i=[],o=t;o<r;o=n){var l=new Ht(e.doc,Zn(e.doc,o),o);n=o+l.size,i.push(l)}return i}function Et(e,t,r,n){null==t&&(t=e.doc.first),null==r&&(r=e.doc.first+e.doc.size),n||(n=0);var i=e.display;if(n&&r<i.viewTo&&(null==i.updateLineNumbers||i.updateLineNumbers>t)&&(i.updateLineNumbers=t),e.curOp.viewChanged=!0,t>=i.viewTo)Io&&wn(e.doc,t)<i.viewTo&&zt(e);else if(r<=i.viewFrom)Io&&xn(e.doc,r+n)>i.viewFrom?zt(e):(i.viewFrom+=n,i.viewTo+=n);else if(t<=i.viewFrom&&r>=i.viewTo)zt(e);else if(t<=i.viewFrom){var o=Rt(e,r,r+n,1);o?(i.view=i.view.slice(o.index),i.viewFrom=o.lineN,i.viewTo+=n):zt(e)}else if(r>=i.viewTo){var o=Rt(e,t,t,-1);o?(i.view=i.view.slice(0,o.index),i.viewTo=o.lineN):zt(e)}else{var l=Rt(e,t,t,-1),s=Rt(e,r,r+n,1);l&&s?(i.view=i.view.slice(0,l.index).concat(Pt(e,l.lineN,s.lineN)).concat(i.view.slice(s.index)),i.viewTo+=n):zt(e)}var a=i.externalMeasured;a&&(r<a.lineN?a.lineN+=n:t<a.lineN+a.size&&(i.externalMeasured=null))}function It(e,t,r){e.curOp.viewChanged=!0;var n=e.display,i=e.display.externalMeasured;if(i&&t>=i.lineN&&t<i.lineN+i.size&&(n.externalMeasured=null),!(t<n.viewFrom||t>=n.viewTo)){var o=n.view[Ft(e,t)];if(null!=o.node){var l=o.changes||(o.changes=[]);Hi(l,r)==-1&&l.push(r)}}}function zt(e){e.display.viewFrom=e.display.viewTo=e.doc.first,e.display.view=[],e.display.viewOffset=0}function Ft(e,t){if(t>=e.display.viewTo)return null;if(t-=e.display.viewFrom,t<0)return null;for(var r=e.display.view,n=0;n<r.length;n++)if(t-=r[n].size,t<0)return n}function Rt(e,t,r,n){var i,o=Ft(e,t),l=e.display.view;if(!Io||r==e.doc.first+e.doc.size)return{index:o,lineN:r};for(var s=0,a=e.display.viewFrom;s<o;s++)a+=l[s].size;if(a!=t){if(n>0){if(o==l.length-1)return null;i=a+l[o].size-t,o++}else i=a-t;t+=i,r+=i}for(;wn(e.doc,r)!=r;){if(o==(n<0?0:l.length-1))return null;r+=n*l[o-(n<0?1:0)].size,o+=n}return{index:o,lineN:r}}function Bt(e,t,r){var n=e.display,i=n.view;0==i.length||t>=n.viewTo||r<=n.viewFrom?(n.view=Pt(e,t,r),n.viewFrom=t):(n.viewFrom>t?n.view=Pt(e,t,n.viewFrom).concat(n.view):n.viewFrom<t&&(n.view=n.view.slice(Ft(e,t))),n.viewFrom=t,n.viewTo<r?n.view=n.view.concat(Pt(e,n.viewTo,r)):n.viewTo>r&&(n.view=n.view.slice(0,Ft(e,r)))),n.viewTo=r}function Gt(e){for(var t=e.display.view,r=0,n=0;n<t.length;n++){var i=t[n];i.hidden||i.node&&!i.changes||++r}return r}function Ut(e){function t(){i.activeTouch&&(o=setTimeout(function(){i.activeTouch=null},1e3),l=i.activeTouch,l.end=+new Date)}function r(e){if(1!=e.touches.length)return!1;var t=e.touches[0];return t.radiusX<=1&&t.radiusY<=1}function n(e,t){if(null==t.left)return!0;var r=t.left-e.left,n=t.top-e.top;return r*r+n*n>400}var i=e.display;Wl(i.scroller,"mousedown",At(e,Yt)),bo&&wo<11?Wl(i.scroller,"dblclick",At(e,function(t){if(!ki(e,t)){var r=Xt(e,t);if(r&&!Qt(e,t)&&!jt(e.display,t)){kl(t);var n=e.findWordAt(r);we(e.doc,n.anchor,n.head)}}})):Wl(i.scroller,"dblclick",function(t){ki(e,t)||kl(t)}),Po||Wl(i.scroller,"contextmenu",function(t){yr(e,t)});var o,l={end:0};Wl(i.scroller,"touchstart",function(e){if(!r(e)){clearTimeout(o);var t=+new Date;i.activeTouch={start:t,moved:!1,prev:t-l.end<=300?l:null},1==e.touches.length&&(i.activeTouch.left=e.touches[0].pageX,i.activeTouch.top=e.touches[0].pageY)}}),Wl(i.scroller,"touchmove",function(){i.activeTouch&&(i.activeTouch.moved=!0)}),Wl(i.scroller,"touchend",function(r){var o=i.activeTouch;if(o&&!jt(i,r)&&null!=o.left&&!o.moved&&new Date-o.start<300){var l,s=e.coordsChar(i.activeTouch,"page");l=!o.prev||n(o,o.prev)?new he(s,s):!o.prev.prev||n(o,o.prev.prev)?e.findWordAt(s):new he(zo(s.line,0),ge(e.doc,zo(s.line+1,0))),e.setSelection(l.anchor,l.head),e.focus(),kl(r)}t()}),Wl(i.scroller,"touchcancel",t),Wl(i.scroller,"scroll",function(){i.scroller.clientHeight&&(nr(e,i.scroller.scrollTop),ir(e,i.scroller.scrollLeft,!0),Dl(e,"scroll",e))}),Wl(i.scroller,"mousewheel",function(t){or(e,t)}),Wl(i.scroller,"DOMMouseScroll",function(t){or(e,t)}),Wl(i.wrapper,"scroll",function(){i.wrapper.scrollTop=i.wrapper.scrollLeft=0}),i.dragFunctions={enter:function(t){ki(e,t)||Nl(t)},over:function(t){ki(e,t)||(tr(e,t),Nl(t))},start:function(t){er(e,t)},drop:At(e,Jt),leave:function(){rr(e)}};var s=i.input.getField();Wl(s,"keyup",function(t){dr.call(e,t)}),Wl(s,"keydown",At(e,hr)),Wl(s,"keypress",At(e,pr)),Wl(s,"focus",Fi(vr,e)),Wl(s,"blur",Fi(mr,e))}function Vt(t,r,n){var i=n&&n!=e.Init;if(!r!=!i){var o=t.display.dragFunctions,l=r?Wl:Ol;l(t.display.scroller,"dragstart",o.start),l(t.display.scroller,"dragenter",o.enter),l(t.display.scroller,"dragover",o.over),l(t.display.scroller,"dragleave",o.leave),l(t.display.scroller,"drop",o.drop)}}function Kt(e){var t=e.display;t.lastWrapHeight==t.wrapper.clientHeight&&t.lastWrapWidth==t.wrapper.clientWidth||(t.cachedCharWidth=t.cachedTextHeight=t.cachedPaddingH=null,t.scrollbarsClipped=!1,e.setSize())}function jt(e,t){for(var r=xi(t);r!=e.wrapper;r=r.parentNode)if(!r||1==r.nodeType&&"true"==r.getAttribute("cm-ignore-events")||r.parentNode==e.sizer&&r!=e.mover)return!0}function Xt(e,t,r,n){var i=e.display;if(!r&&"true"==xi(t).getAttribute("cm-not-content"))return null;var o,l,s=i.lineSpace.getBoundingClientRect();try{o=t.clientX-s.left,l=t.clientY-s.top}catch(e){return null}var a,u=vt(e,o,l);if(n&&1==u.xRel&&(a=Zn(e.doc,u.line).text).length==u.ch){var c=Rl(a,a.length,e.options.tabSize)-a.length;u=zo(u.line,Math.max(0,Math.round((o-je(e.display).left)/bt(e.display))-c))}return u}function Yt(e){var t=this,r=t.display;if(!(r.activeTouch&&r.input.supportsTouch()||ki(t,e))){if(r.shift=e.shiftKey,jt(r,e))return void(xo||(r.scroller.draggable=!1,setTimeout(function(){r.scroller.draggable=!0},100)));if(!Qt(t,e)){var n=Xt(t,e);switch(window.focus(),Ci(e)){case 1:t.state.selectingText?t.state.selectingText(e):n?_t(t,e,n):xi(e)==r.scroller&&kl(e);break;case 2:xo&&(t.state.lastMiddleDown=+new Date),n&&we(t.doc,n),setTimeout(function(){r.input.focus()},20),kl(e);break;case 3:Po?yr(t,e):gr(t)}}}}function _t(e,t,r){bo?setTimeout(Fi(q,e),0):e.curOp.focus=ji();var n,i=+new Date;Uo&&Uo.time>i-400&&0==Fo(Uo.pos,r)?n="triple":Go&&Go.time>i-400&&0==Fo(Go.pos,r)?(n="double",Uo={time:i,pos:r}):(n="single",Go={time:i,pos:r});var o,l=e.doc.sel,s=Ao?t.metaKey:t.ctrlKey;e.options.dragDrop&&Jl&&!e.isReadOnly()&&"single"==n&&(o=l.contains(r))>-1&&(Fo((o=l.ranges[o]).from(),r)<0||r.xRel>0)&&(Fo(o.to(),r)>0||r.xRel<0)?$t(e,t,r,s):qt(e,t,r,n,s)}function $t(e,t,r,n){var i=e.display,o=+new Date,l=At(e,function(s){xo&&(i.scroller.draggable=!1),e.state.draggingText=!1,Ol(document,"mouseup",l),Ol(i.scroller,"drop",l),Math.abs(t.clientX-s.clientX)+Math.abs(t.clientY-s.clientY)<10&&(kl(s),!n&&+new Date-200<o&&we(e.doc,r),xo||bo&&9==wo?setTimeout(function(){document.body.focus(),i.input.focus()},20):i.input.focus())});xo&&(i.scroller.draggable=!0),e.state.draggingText=l,i.scroller.dragDrop&&i.scroller.dragDrop(),Wl(document,"mouseup",l),Wl(i.scroller,"drop",l)}function qt(e,t,r,n,i){function o(t){if(0!=Fo(v,t))if(v=t,"rect"==n){for(var i=[],o=e.options.tabSize,l=Rl(Zn(u,r.line).text,r.ch,o),s=Rl(Zn(u,t.line).text,t.ch,o),a=Math.min(l,s),d=Math.max(l,s),p=Math.min(r.line,t.line),g=Math.min(e.lastLine(),Math.max(r.line,t.line));p<=g;p++){var m=Zn(u,p).text,y=Bl(m,a,o);a==d?i.push(new he(zo(p,y),zo(p,y))):m.length>y&&i.push(new he(zo(p,y),zo(p,Bl(m,d,o))))}i.length||i.push(new he(r,r)),ke(u,fe(f.ranges.slice(0,h).concat(i),h),{origin:"*mouse",scroll:!1}),e.scrollIntoView(t)}else{var b=c,w=b.anchor,x=t;if("single"!=n){if("double"==n)var C=e.findWordAt(t);else var C=new he(zo(t.line,0),ge(u,zo(t.line+1,0)));Fo(C.anchor,w)>0?(x=C.head,w=$(b.from(),C.anchor)):(x=C.anchor,w=_(b.to(),C.head))}var i=f.ranges.slice(0);i[h]=new he(ge(u,w),x),ke(u,fe(i,h),zl)}}function l(t){var r=++y,i=Xt(e,t,!0,"rect"==n);if(i)if(0!=Fo(i,v)){e.curOp.focus=ji(),o(i);var s=w(a,u);(i.line>=s.to||i.line<s.from)&&setTimeout(At(e,function(){y==r&&l(t)}),150)}else{var c=t.clientY<m.top?-20:t.clientY>m.bottom?20:0;c&&setTimeout(At(e,function(){y==r&&(a.scroller.scrollTop+=c,l(t))}),50)}}function s(t){e.state.selectingText=!1,y=1/0,kl(t),a.input.focus(),Ol(document,"mousemove",b),Ol(document,"mouseup",x),u.history.lastSelOrigin=null}var a=e.display,u=e.doc;kl(t);var c,h,f=u.sel,d=f.ranges;if(i&&!t.shiftKey?(h=u.sel.contains(r),c=h>-1?d[h]:new he(r,r)):(c=u.sel.primary(),h=u.sel.primIndex),t.altKey)n="rect",i||(c=new he(r,r)),r=Xt(e,t,!0,!0),h=-1;else if("double"==n){var p=e.findWordAt(r);c=e.display.shift||u.extend?be(u,c,p.anchor,p.head):p}else if("triple"==n){var g=new he(zo(r.line,0),ge(u,zo(r.line+1,0)));c=e.display.shift||u.extend?be(u,c,g.anchor,g.head):g}else c=be(u,c,r);i?h==-1?(h=d.length,ke(u,fe(d.concat([c]),h),{scroll:!1,origin:"*mouse"})):d.length>1&&d[h].empty()&&"single"==n&&!t.shiftKey?(ke(u,fe(d.slice(0,h).concat(d.slice(h+1)),0),{scroll:!1,origin:"*mouse"}),f=u.sel):Ce(u,h,c,zl):(h=0,ke(u,new ce([c],0),zl),f=u.sel);var v=r,m=a.wrapper.getBoundingClientRect(),y=0,b=At(e,function(e){Ci(e)?l(e):s(e)}),x=At(e,s);e.state.selectingText=x,Wl(document,"mousemove",b),Wl(document,"mouseup",x)}function Zt(e,t,r,n){try{var i=t.clientX,o=t.clientY}catch(e){return!1}if(i>=Math.floor(e.display.gutters.getBoundingClientRect().right))return!1;n&&kl(t);var l=e.display,s=l.lineDiv.getBoundingClientRect();if(o>s.bottom||!Ni(e,r))return wi(t);o-=s.top-l.viewOffset;for(var a=0;a<e.options.gutters.length;++a){var u=l.gutters.childNodes[a];if(u&&u.getBoundingClientRect().right>=i){var c=ri(e.doc,o),h=e.options.gutters[a];return Dl(e,r,e,c,h,t),wi(t)}}}function Qt(e,t){return Zt(e,t,"gutterClick",!0)}function Jt(e){var t=this;if(rr(t),!ki(t,e)&&!jt(t.display,e)){kl(e),bo&&(Xo=+new Date);var r=Xt(t,e,!0),n=e.dataTransfer.files;if(r&&!t.isReadOnly())if(n&&n.length&&window.FileReader&&window.File)for(var i=n.length,o=Array(i),l=0,s=function(e,n){if(!t.options.allowDropFileTypes||Hi(t.options.allowDropFileTypes,e.type)!=-1){var s=new FileReader;s.onload=At(t,function(){var e=s.result;if(/[\x00-\x08\x0e-\x1f]{2}/.test(e)&&(e=""),o[n]=e,++l==i){r=ge(t.doc,r);var a={from:r,to:r,text:t.doc.splitLines(o.join(t.doc.lineSeparator())),origin:"paste"};Tr(t.doc,a),Te(t.doc,de(r,Qo(a)))}}),s.readAsText(e)}},a=0;a<i;++a)s(n[a],a);else{if(t.state.draggingText&&t.doc.sel.contains(r)>-1)return t.state.draggingText(e),void setTimeout(function(){t.display.input.focus()},20);try{var o=e.dataTransfer.getData("Text");if(o){if(t.state.draggingText&&!(Ao?e.altKey:e.ctrlKey))var u=t.listSelections();if(Me(t.doc,de(r,r)),u)for(var a=0;a<u.length;++a)Or(t.doc,"",u[a].anchor,u[a].head,"drag");t.replaceSelection(o,"around","paste"),t.display.input.focus()}}catch(e){}}}}function er(e,t){if(bo&&(!e.state.draggingText||+new Date-Xo<100))return void Nl(t);if(!ki(e,t)&&!jt(e.display,t)&&(t.dataTransfer.setData("Text",e.getSelection()),t.dataTransfer.setDragImage&&!To)){var r=Ui("img",null,null,"position: fixed; left: 0; top: 0;");r.src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",Lo&&(r.width=r.height=1,e.display.wrapper.appendChild(r),r._top=r.offsetTop),t.dataTransfer.setDragImage(r,0,0),Lo&&r.parentNode.removeChild(r)}}function tr(e,t){var r=Xt(e,t);if(r){var n=document.createDocumentFragment();Ie(e,r,n),e.display.dragCursor||(e.display.dragCursor=Ui("div",null,"CodeMirror-cursors CodeMirror-dragcursors"),e.display.lineSpace.insertBefore(e.display.dragCursor,e.display.cursorDiv)),Ki(e.display.dragCursor,n)}}function rr(e){e.display.dragCursor&&(e.display.lineSpace.removeChild(e.display.dragCursor),e.display.dragCursor=null)}function nr(e,t){Math.abs(e.doc.scrollTop-t)<2||(e.doc.scrollTop=t,vo||W(e,{top:t}),e.display.scroller.scrollTop!=t&&(e.display.scroller.scrollTop=t),e.display.scrollbars.setScrollTop(t),vo&&W(e),Re(e,100))}function ir(e,t,r){(r?t==e.doc.scrollLeft:Math.abs(e.doc.scrollLeft-t)<2)||(t=Math.min(t,e.display.scroller.scrollWidth-e.display.scroller.clientWidth),e.doc.scrollLeft=t,x(e),e.display.scroller.scrollLeft!=t&&(e.display.scroller.scrollLeft=t),e.display.scrollbars.setScrollLeft(t))}function or(e,t){var r=$o(t),n=r.x,i=r.y,o=e.display,l=o.scroller,s=l.scrollWidth>l.clientWidth,a=l.scrollHeight>l.clientHeight;if(n&&s||i&&a){if(i&&Ao&&xo)e:for(var u=t.target,c=o.view;u!=l;u=u.parentNode)for(var h=0;h<c.length;h++)if(c[h].node==u){e.display.currentWheelTarget=u;break e}if(n&&!vo&&!Lo&&null!=_o)return i&&a&&nr(e,Math.max(0,Math.min(l.scrollTop+i*_o,l.scrollHeight-l.clientHeight))),ir(e,Math.max(0,Math.min(l.scrollLeft+n*_o,l.scrollWidth-l.clientWidth))),(!i||i&&a)&&kl(t),void(o.wheelStartX=null);if(i&&null!=_o){var f=i*_o,d=e.doc.scrollTop,p=d+o.wrapper.clientHeight;f<0?d=Math.max(0,d+f-50):p=Math.min(e.doc.height,p+f+50),W(e,{top:d,bottom:p})}Yo<20&&(null==o.wheelStartX?(o.wheelStartX=l.scrollLeft,o.wheelStartY=l.scrollTop,o.wheelDX=n,o.wheelDY=i,setTimeout(function(){if(null!=o.wheelStartX){var e=l.scrollLeft-o.wheelStartX,t=l.scrollTop-o.wheelStartY,r=t&&o.wheelDY&&t/o.wheelDY||e&&o.wheelDX&&e/o.wheelDX;o.wheelStartX=o.wheelStartY=null,r&&(_o=(_o*Yo+r)/(Yo+1),++Yo)}},200)):(o.wheelDX+=n,o.wheelDY+=i))}}function lr(e,t,r){if("string"==typeof t&&(t=ul[t],!t))return!1;e.display.input.ensurePolled();var n=e.display.shift,i=!1;try{e.isReadOnly()&&(e.state.suppressEdits=!0),r&&(e.display.shift=!1),i=t(e)!=El}finally{e.display.shift=n,e.state.suppressEdits=!1}return i}function sr(e,t,r){for(var n=0;n<e.state.keyMaps.length;n++){var i=hl(t,e.state.keyMaps[n],r,e);if(i)return i}return e.options.extraKeys&&hl(t,e.options.extraKeys,r,e)||hl(t,e.options.keyMap,r,e)}function ar(e,t,r,n){var i=e.state.keySeq;if(i){if(fl(t))return"handled";qo.set(50,function(){e.state.keySeq==i&&(e.state.keySeq=null,e.display.input.reset())}),t=i+" "+t}var o=sr(e,t,n);return"multi"==o&&(e.state.keySeq=t),"handled"==o&&Li(e,"keyHandled",e,t,r),"handled"!=o&&"multi"!=o||(kl(r),Fe(e)),i&&!o&&/\'$/.test(t)?(kl(r),!0):!!o}function ur(e,t){var r=dl(t,!0);return!!r&&(t.shiftKey&&!e.state.keySeq?ar(e,"Shift-"+r,t,function(t){return lr(e,t,!0)})||ar(e,r,t,function(t){if("string"==typeof t?/^go[A-Z]/.test(t):t.motion)return lr(e,t)}):ar(e,r,t,function(t){return lr(e,t)}))}function cr(e,t,r){return ar(e,"'"+r+"'",t,function(t){return lr(e,t,!0)})}function hr(e){var t=this;if(t.curOp.focus=ji(),!ki(t,e)){bo&&wo<11&&27==e.keyCode&&(e.returnValue=!1);var r=e.keyCode;t.display.shift=16==r||e.shiftKey;var n=ur(t,e);Lo&&(Zo=n?r:null,!n&&88==r&&!rs&&(Ao?e.metaKey:e.ctrlKey)&&t.replaceSelection("",null,"cut")),18!=r||/\bCodeMirror-crosshair\b/.test(t.display.lineDiv.className)||fr(t)}}function fr(e){function t(e){18!=e.keyCode&&e.altKey||(ql(r,"CodeMirror-crosshair"),Ol(document,"keyup",t),Ol(document,"mouseover",t))}var r=e.display.lineDiv;Zl(r,"CodeMirror-crosshair"),Wl(document,"keyup",t),Wl(document,"mouseover",t)}function dr(e){16==e.keyCode&&(this.doc.sel.shift=!1),ki(this,e)}function pr(e){var t=this;if(!(jt(t.display,e)||ki(t,e)||e.ctrlKey&&!e.altKey||Ao&&e.metaKey)){var r=e.keyCode,n=e.charCode;if(Lo&&r==Zo)return Zo=null,void kl(e);if(!Lo||e.which&&!(e.which<10)||!ur(t,e)){var i=String.fromCharCode(null==n?r:n);cr(t,e,i)||t.display.input.onKeyPress(e)}}}function gr(e){e.state.delayingBlurEvent=!0,setTimeout(function(){e.state.delayingBlurEvent&&(e.state.delayingBlurEvent=!1,mr(e))},100)}function vr(e){e.state.delayingBlurEvent&&(e.state.delayingBlurEvent=!1),"nocursor"!=e.options.readOnly&&(e.state.focused||(Dl(e,"focus",e),e.state.focused=!0,Zl(e.display.wrapper,"CodeMirror-focused"),e.curOp||e.display.selForContextMenu==e.doc.sel||(e.display.input.reset(),xo&&setTimeout(function(){e.display.input.reset(!0)},20)),e.display.input.receivedFocus()),Fe(e))}function mr(e){e.state.delayingBlurEvent||(e.state.focused&&(Dl(e,"blur",e),e.state.focused=!1,ql(e.display.wrapper,"CodeMirror-focused")),clearInterval(e.display.blinker),setTimeout(function(){e.state.focused||(e.display.shift=!1)},150))}function yr(e,t){jt(e.display,t)||br(e,t)||ki(e,t,"contextmenu")||e.display.input.onContextMenu(t)}function br(e,t){return!!Ni(e,"gutterContextMenu")&&Zt(e,t,"gutterContextMenu",!1)}function wr(e,t){if(Fo(e,t.from)<0)return e;if(Fo(e,t.to)<=0)return Qo(t);var r=e.line+t.text.length-(t.to.line-t.from.line)-1,n=e.ch;return e.line==t.to.line&&(n+=Qo(t).ch-t.to.ch),zo(r,n)}function xr(e,t){for(var r=[],n=0;n<e.sel.ranges.length;n++){var i=e.sel.ranges[n];r.push(new he(wr(i.anchor,t),wr(i.head,t)))}return fe(r,e.sel.primIndex)}function Cr(e,t,r){return e.line==t.line?zo(r.line,e.ch-t.ch+r.ch):zo(r.line+(e.line-t.line),e.ch)}function Sr(e,t,r){for(var n=[],i=zo(e.first,0),o=i,l=0;l<t.length;l++){var s=t[l],a=Cr(s.from,i,o),u=Cr(Qo(s),i,o);if(i=s.to,o=u,"around"==r){var c=e.sel.ranges[l],h=Fo(c.head,c.anchor)<0;n[l]=new he(h?u:a,h?a:u)}else n[l]=new he(a,a)}return new ce(n,e.sel.primIndex)}function Lr(e,t,r){var n={canceled:!1,from:t.from,to:t.to,text:t.text,origin:t.origin,cancel:function(){this.canceled=!0}};return r&&(n.update=function(t,r,n,i){t&&(this.from=ge(e,t)),r&&(this.to=ge(e,r)),n&&(this.text=n),void 0!==i&&(this.origin=i)}),Dl(e,"beforeChange",e,n),e.cm&&Dl(e.cm,"beforeChange",e.cm,n),n.canceled?null:{from:n.from,to:n.to,text:n.text,origin:n.origin}}function Tr(e,t,r){if(e.cm){if(!e.cm.curOp)return At(e.cm,Tr)(e,t,r);if(e.cm.state.suppressEdits)return}if(!(Ni(e,"beforeChange")||e.cm&&Ni(e.cm,"beforeChange"))||(t=Lr(e,t,!0))){var n=Eo&&!r&&an(e,t.from,t.to);if(n)for(var i=n.length-1;i>=0;--i)kr(e,{from:n[i].from,to:n[i].to,text:i?[""]:t.text});else kr(e,t)}}function kr(e,t){if(1!=t.text.length||""!=t.text[0]||0!=Fo(t.from,t.to)){var r=xr(e,t);ui(e,t,r,e.cm?e.cm.curOp.id:NaN),Wr(e,t,r,on(e,t));var n=[];$n(e,function(e,r){r||Hi(n,e.history)!=-1||(bi(e.history,t),n.push(e.history)),Wr(e,t,null,on(e,t))})}}function Mr(e,t,r){if(!e.cm||!e.cm.state.suppressEdits){for(var n,i=e.history,o=e.sel,l="undo"==t?i.done:i.undone,s="undo"==t?i.undone:i.done,a=0;a<l.length&&(n=l[a],r?!n.ranges||n.equals(e.sel):n.ranges);a++);if(a!=l.length){for(i.lastOrigin=i.lastSelOrigin=null;n=l.pop(),n.ranges;){if(fi(n,s),r&&!n.equals(e.sel))return void ke(e,n,{clearRedo:!1});o=n}var u=[];fi(o,s),s.push({changes:u,generation:i.generation}),i.generation=n.generation||++i.maxGeneration;for(var c=Ni(e,"beforeChange")||e.cm&&Ni(e.cm,"beforeChange"),a=n.changes.length-1;a>=0;--a){var h=n.changes[a];if(h.origin=t,c&&!Lr(e,h,!1))return void(l.length=0);u.push(li(e,h));var f=a?xr(e,h):Di(l);Wr(e,h,f,sn(e,h)),!a&&e.cm&&e.cm.scrollIntoView({from:h.from,to:Qo(h)});var d=[];$n(e,function(e,t){t||Hi(d,e.history)!=-1||(bi(e.history,h),d.push(e.history)),Wr(e,h,null,sn(e,h))})}}}}function Nr(e,t){if(0!=t&&(e.first+=t,e.sel=new ce(Pi(e.sel.ranges,function(e){return new he(zo(e.anchor.line+t,e.anchor.ch),zo(e.head.line+t,e.head.ch))}),e.sel.primIndex),e.cm)){Et(e.cm,e.first,e.first-t,t);for(var r=e.cm.display,n=r.viewFrom;n<r.viewTo;n++)It(e.cm,n,"gutter")}}function Wr(e,t,r,n){if(e.cm&&!e.cm.curOp)return At(e.cm,Wr)(e,t,r,n);if(t.to.line<e.first)return void Nr(e,t.text.length-1-(t.to.line-t.from.line));if(!(t.from.line>e.lastLine())){if(t.from.line<e.first){var i=t.text.length-1-(e.first-t.from.line);Nr(e,i),t={from:zo(e.first,0),to:zo(t.to.line+i,t.to.ch),text:[Di(t.text)],origin:t.origin}}var o=e.lastLine();t.to.line>o&&(t={from:t.from,to:zo(o,Zn(e,o).text.length),text:[t.text[0]],origin:t.origin}),t.removed=Qn(e,t.from,t.to),r||(r=xr(e,t)),e.cm?Ar(e.cm,t,n):Xn(e,t,n),Me(e,r,Il)}}function Ar(e,t,r){var n=e.doc,i=e.display,l=t.from,s=t.to,a=!1,u=l.line;e.options.lineWrapping||(u=ti(yn(Zn(n,l.line))),n.iter(u,s.line+1,function(e){if(e==i.maxLine)return a=!0,!0})),n.sel.contains(t.from,t.to)>-1&&Mi(e),Xn(n,t,r,o(e)),e.options.lineWrapping||(n.iter(u,l.line+t.text.length,function(e){var t=h(e);t>i.maxLineLength&&(i.maxLine=e,i.maxLineLength=t,i.maxLineChanged=!0,a=!1)}),a&&(e.curOp.updateMaxLine=!0)),n.frontier=Math.min(n.frontier,l.line),Re(e,400);var c=t.text.length-(s.line-l.line)-1;t.full?Et(e):l.line!=s.line||1!=t.text.length||jn(e.doc,t)?Et(e,l.line,s.line+1,c):It(e,l.line,"text");var f=Ni(e,"changes"),d=Ni(e,"change");if(d||f){var p={from:l,to:s,text:t.text,removed:t.removed,origin:t.origin};d&&Li(e,"change",e,p),f&&(e.curOp.changeObjs||(e.curOp.changeObjs=[])).push(p)}e.display.selForContextMenu=null}function Or(e,t,r,n,i){if(n||(n=r),Fo(n,r)<0){var o=n;n=r,r=o}"string"==typeof t&&(t=e.splitLines(t)),Tr(e,{from:r,to:n,text:t,origin:i})}function Dr(e,t){if(!ki(e,"scrollCursorIntoView")){var r=e.display,n=r.sizer.getBoundingClientRect(),i=null;if(t.top+n.top<0?i=!0:t.bottom+n.top>(window.innerHeight||document.documentElement.clientHeight)&&(i=!1),null!=i&&!Mo){var o=Ui("div","​",null,"position: absolute; top: "+(t.top-r.viewOffset-Ve(e.display))+"px; height: "+(t.bottom-t.top+Xe(e)+r.barHeight)+"px; left: "+t.left+"px; width: 2px;");e.display.lineSpace.appendChild(o),o.scrollIntoView(i),e.display.lineSpace.removeChild(o)}}}function Hr(e,t,r,n){null==n&&(n=0);for(var i=0;i<5;i++){var o=!1,l=dt(e,t),s=r&&r!=t?dt(e,r):l,a=Er(e,Math.min(l.left,s.left),Math.min(l.top,s.top)-n,Math.max(l.left,s.left),Math.max(l.bottom,s.bottom)+n),u=e.doc.scrollTop,c=e.doc.scrollLeft;if(null!=a.scrollTop&&(nr(e,a.scrollTop),Math.abs(e.doc.scrollTop-u)>1&&(o=!0)),null!=a.scrollLeft&&(ir(e,a.scrollLeft),Math.abs(e.doc.scrollLeft-c)>1&&(o=!0)),!o)break}return l}function Pr(e,t,r,n,i){var o=Er(e,t,r,n,i);null!=o.scrollTop&&nr(e,o.scrollTop),null!=o.scrollLeft&&ir(e,o.scrollLeft)}function Er(e,t,r,n,i){var o=e.display,l=yt(e.display);r<0&&(r=0);var s=e.curOp&&null!=e.curOp.scrollTop?e.curOp.scrollTop:o.scroller.scrollTop,a=_e(e),u={};i-r>a&&(i=r+a);var c=e.doc.height+Ke(o),h=r<l,f=i>c-l;if(r<s)u.scrollTop=h?0:r;else if(i>s+a){var d=Math.min(r,(f?c:i)-a);d!=s&&(u.scrollTop=d)}var p=e.curOp&&null!=e.curOp.scrollLeft?e.curOp.scrollLeft:o.scroller.scrollLeft,g=Ye(e)-(e.options.fixedGutter?o.gutters.offsetWidth:0),v=n-t>g;return v&&(n=t+g),t<10?u.scrollLeft=0:t<p?u.scrollLeft=Math.max(0,t-(v?0:10)):n>g+p-3&&(u.scrollLeft=n+(v?0:10)-g),u}function Ir(e,t,r){null==t&&null==r||Fr(e),null!=t&&(e.curOp.scrollLeft=(null==e.curOp.scrollLeft?e.doc.scrollLeft:e.curOp.scrollLeft)+t),null!=r&&(e.curOp.scrollTop=(null==e.curOp.scrollTop?e.doc.scrollTop:e.curOp.scrollTop)+r)}function zr(e){Fr(e);var t=e.getCursor(),r=t,n=t;e.options.lineWrapping||(r=t.ch?zo(t.line,t.ch-1):t,n=zo(t.line,t.ch+1)),e.curOp.scrollToPos={from:r,to:n,margin:e.options.cursorScrollMargin,isCursor:!0}}function Fr(e){var t=e.curOp.scrollToPos;if(t){e.curOp.scrollToPos=null;var r=pt(e,t.from),n=pt(e,t.to),i=Er(e,Math.min(r.left,n.left),Math.min(r.top,n.top)-t.margin,Math.max(r.right,n.right),Math.max(r.bottom,n.bottom)+t.margin);
3
- e.scrollTo(i.scrollLeft,i.scrollTop)}}function Rr(e,t,r,n){var i,o=e.doc;null==r&&(r="add"),"smart"==r&&(o.mode.indent?i=Ue(e,t):r="prev");var l=e.options.tabSize,s=Zn(o,t),a=Rl(s.text,null,l);s.stateAfter&&(s.stateAfter=null);var u,c=s.text.match(/^\s*/)[0];if(n||/\S/.test(s.text)){if("smart"==r&&(u=o.mode.indent(i,s.text.slice(c.length),s.text),u==El||u>150)){if(!n)return;r="prev"}}else u=0,r="not";"prev"==r?u=t>o.first?Rl(Zn(o,t-1).text,null,l):0:"add"==r?u=a+e.options.indentUnit:"subtract"==r?u=a-e.options.indentUnit:"number"==typeof r&&(u=a+r),u=Math.max(0,u);var h="",f=0;if(e.options.indentWithTabs)for(var d=Math.floor(u/l);d;--d)f+=l,h+="\t";if(f<u&&(h+=Oi(u-f)),h!=c)return Or(o,h,zo(t,0),zo(t,c.length),"+input"),s.stateAfter=null,!0;for(var d=0;d<o.sel.ranges.length;d++){var p=o.sel.ranges[d];if(p.head.line==t&&p.head.ch<c.length){var f=zo(t,c.length);Ce(o,d,new he(f,f));break}}}function Br(e,t,r,n){var i=t,o=t;return"number"==typeof t?o=Zn(e,pe(e,t)):i=ti(t),null==i?null:(n(o,i)&&e.cm&&It(e.cm,i,r),o)}function Gr(e,t){for(var r=e.doc.sel.ranges,n=[],i=0;i<r.length;i++){for(var o=t(r[i]);n.length&&Fo(o.from,Di(n).to)<=0;){var l=n.pop();if(Fo(l.from,o.from)<0){o.from=l.from;break}}n.push(o)}Wt(e,function(){for(var t=n.length-1;t>=0;t--)Or(e.doc,"",n[t].from,n[t].to,"+delete");zr(e)})}function Ur(e,t,r,n,i){function o(){var t=s+r;return t<e.first||t>=e.first+e.size?h=!1:(s=t,c=Zn(e,t))}function l(e){var t=(i?ho:fo)(c,a,r,!0);if(null==t){if(e||!o())return h=!1;a=i?(r<0?io:no)(c):r<0?c.text.length:0}else a=t;return!0}var s=t.line,a=t.ch,u=r,c=Zn(e,s),h=!0;if("char"==n)l();else if("column"==n)l(!0);else if("word"==n||"group"==n)for(var f=null,d="group"==n,p=e.cm&&e.cm.getHelper(t,"wordChars"),g=!0;!(r<0)||l(!g);g=!1){var v=c.text.charAt(a)||"\n",m=Ri(v,p)?"w":d&&"\n"==v?"n":!d||/\s/.test(v)?null:"p";if(!d||g||m||(m="s"),f&&f!=m){r<0&&(r=1,l());break}if(m&&(f=m),r>0&&!l(!g))break}var y=De(e,zo(s,a),t,u,!0);return h||(y.hitSide=!0),y}function Vr(e,t,r,n){var i,o=e.doc,l=t.left;if("page"==n){var s=Math.min(e.display.wrapper.clientHeight,window.innerHeight||document.documentElement.clientHeight);i=t.top+r*(s-(r<0?1.5:.5)*yt(e.display))}else"line"==n&&(i=r>0?t.bottom+3:t.top-3);for(;;){var a=vt(e,l,i);if(!a.outside)break;if(r<0?i<=0:i>=o.height){a.hitSide=!0;break}i+=5*r}return a}function Kr(t,r,n,i){e.defaults[t]=r,n&&(el[t]=i?function(e,t,r){r!=tl&&n(e,t,r)}:n)}function jr(e){for(var t,r,n,i,o=e.split(/-(?!$)/),e=o[o.length-1],l=0;l<o.length-1;l++){var s=o[l];if(/^(cmd|meta|m)$/i.test(s))i=!0;else if(/^a(lt)?$/i.test(s))t=!0;else if(/^(c|ctrl|control)$/i.test(s))r=!0;else{if(!/^s(hift)$/i.test(s))throw new Error("Unrecognized modifier name: "+s);n=!0}}return t&&(e="Alt-"+e),r&&(e="Ctrl-"+e),i&&(e="Cmd-"+e),n&&(e="Shift-"+e),e}function Xr(e){return"string"==typeof e?cl[e]:e}function Yr(e,t,r,n,i){if(n&&n.shared)return _r(e,t,r,n,i);if(e.cm&&!e.cm.curOp)return At(e.cm,Yr)(e,t,r,n,i);var o=new vl(e,i),l=Fo(t,r);if(n&&zi(n,o,!1),l>0||0==l&&o.clearWhenEmpty!==!1)return o;if(o.replacedWith&&(o.collapsed=!0,o.widgetNode=Ui("span",[o.replacedWith],"CodeMirror-widget"),n.handleMouseEvents||o.widgetNode.setAttribute("cm-ignore-events","true"),n.insertLeft&&(o.widgetNode.insertLeft=!0)),o.collapsed){if(mn(e,t.line,t,r,o)||t.line!=r.line&&mn(e,r.line,t,r,o))throw new Error("Inserting collapsed marker partially overlapping an existing one");Io=!0}o.addToHistory&&ui(e,{from:t,to:r,origin:"markText"},e.sel,NaN);var s,a=t.line,u=e.cm;if(e.iter(a,r.line+1,function(e){u&&o.collapsed&&!u.options.lineWrapping&&yn(e)==u.display.maxLine&&(s=!0),o.collapsed&&a!=t.line&&ei(e,0),tn(e,new Qr(o,a==t.line?t.ch:null,a==r.line?r.ch:null)),++a}),o.collapsed&&e.iter(t.line,r.line+1,function(t){Cn(e,t)&&ei(t,0)}),o.clearOnEnter&&Wl(o,"beforeCursorEnter",function(){o.clear()}),o.readOnly&&(Eo=!0,(e.history.done.length||e.history.undone.length)&&e.clearHistory()),o.collapsed&&(o.id=++gl,o.atomic=!0),u){if(s&&(u.curOp.updateMaxLine=!0),o.collapsed)Et(u,t.line,r.line+1);else if(o.className||o.title||o.startStyle||o.endStyle||o.css)for(var c=t.line;c<=r.line;c++)It(u,c,"text");o.atomic&&We(u.doc),Li(u,"markerAdded",u,o)}return o}function _r(e,t,r,n,i){n=zi(n),n.shared=!1;var o=[Yr(e,t,r,n,i)],l=o[0],s=n.widgetNode;return $n(e,function(e){s&&(n.widgetNode=s.cloneNode(!0)),o.push(Yr(e,ge(e,t),ge(e,r),n,i));for(var a=0;a<e.linked.length;++a)if(e.linked[a].isParent)return;l=Di(o)}),new ml(o,l)}function $r(e){return e.findMarks(zo(e.first,0),e.clipPos(zo(e.lastLine())),function(e){return e.parent})}function qr(e,t){for(var r=0;r<t.length;r++){var n=t[r],i=n.find(),o=e.clipPos(i.from),l=e.clipPos(i.to);if(Fo(o,l)){var s=Yr(e,o,l,n.primary,n.primary.type);n.markers.push(s),s.parent=n}}}function Zr(e){for(var t=0;t<e.length;t++){var r=e[t],n=[r.primary.doc];$n(r.primary.doc,function(e){n.push(e)});for(var i=0;i<r.markers.length;i++){var o=r.markers[i];Hi(n,o.doc)==-1&&(o.parent=null,r.markers.splice(i--,1))}}}function Qr(e,t,r){this.marker=e,this.from=t,this.to=r}function Jr(e,t){if(e)for(var r=0;r<e.length;++r){var n=e[r];if(n.marker==t)return n}}function en(e,t){for(var r,n=0;n<e.length;++n)e[n]!=t&&(r||(r=[])).push(e[n]);return r}function tn(e,t){e.markedSpans=e.markedSpans?e.markedSpans.concat([t]):[t],t.marker.attachLine(e)}function rn(e,t,r){if(e)for(var n,i=0;i<e.length;++i){var o=e[i],l=o.marker,s=null==o.from||(l.inclusiveLeft?o.from<=t:o.from<t);if(s||o.from==t&&"bookmark"==l.type&&(!r||!o.marker.insertLeft)){var a=null==o.to||(l.inclusiveRight?o.to>=t:o.to>t);(n||(n=[])).push(new Qr(l,o.from,a?null:o.to))}}return n}function nn(e,t,r){if(e)for(var n,i=0;i<e.length;++i){var o=e[i],l=o.marker,s=null==o.to||(l.inclusiveRight?o.to>=t:o.to>t);if(s||o.from==t&&"bookmark"==l.type&&(!r||o.marker.insertLeft)){var a=null==o.from||(l.inclusiveLeft?o.from<=t:o.from<t);(n||(n=[])).push(new Qr(l,a?null:o.from-t,null==o.to?null:o.to-t))}}return n}function on(e,t){if(t.full)return null;var r=me(e,t.from.line)&&Zn(e,t.from.line).markedSpans,n=me(e,t.to.line)&&Zn(e,t.to.line).markedSpans;if(!r&&!n)return null;var i=t.from.ch,o=t.to.ch,l=0==Fo(t.from,t.to),s=rn(r,i,l),a=nn(n,o,l),u=1==t.text.length,c=Di(t.text).length+(u?i:0);if(s)for(var h=0;h<s.length;++h){var f=s[h];if(null==f.to){var d=Jr(a,f.marker);d?u&&(f.to=null==d.to?null:d.to+c):f.to=i}}if(a)for(var h=0;h<a.length;++h){var f=a[h];if(null!=f.to&&(f.to+=c),null==f.from){var d=Jr(s,f.marker);d||(f.from=c,u&&(s||(s=[])).push(f))}else f.from+=c,u&&(s||(s=[])).push(f)}s&&(s=ln(s)),a&&a!=s&&(a=ln(a));var p=[s];if(!u){var g,v=t.text.length-2;if(v>0&&s)for(var h=0;h<s.length;++h)null==s[h].to&&(g||(g=[])).push(new Qr(s[h].marker,null,null));for(var h=0;h<v;++h)p.push(g);p.push(a)}return p}function ln(e){for(var t=0;t<e.length;++t){var r=e[t];null!=r.from&&r.from==r.to&&r.marker.clearWhenEmpty!==!1&&e.splice(t--,1)}return e.length?e:null}function sn(e,t){var r=gi(e,t),n=on(e,t);if(!r)return n;if(!n)return r;for(var i=0;i<r.length;++i){var o=r[i],l=n[i];if(o&&l)e:for(var s=0;s<l.length;++s){for(var a=l[s],u=0;u<o.length;++u)if(o[u].marker==a.marker)continue e;o.push(a)}else l&&(r[i]=l)}return r}function an(e,t,r){var n=null;if(e.iter(t.line,r.line+1,function(e){if(e.markedSpans)for(var t=0;t<e.markedSpans.length;++t){var r=e.markedSpans[t].marker;!r.readOnly||n&&Hi(n,r)!=-1||(n||(n=[])).push(r)}}),!n)return null;for(var i=[{from:t,to:r}],o=0;o<n.length;++o)for(var l=n[o],s=l.find(0),a=0;a<i.length;++a){var u=i[a];if(!(Fo(u.to,s.from)<0||Fo(u.from,s.to)>0)){var c=[a,1],h=Fo(u.from,s.from),f=Fo(u.to,s.to);(h<0||!l.inclusiveLeft&&!h)&&c.push({from:u.from,to:s.from}),(f>0||!l.inclusiveRight&&!f)&&c.push({from:s.to,to:u.to}),i.splice.apply(i,c),a+=c.length-1}}return i}function un(e){var t=e.markedSpans;if(t){for(var r=0;r<t.length;++r)t[r].marker.detachLine(e);e.markedSpans=null}}function cn(e,t){if(t){for(var r=0;r<t.length;++r)t[r].marker.attachLine(e);e.markedSpans=t}}function hn(e){return e.inclusiveLeft?-1:0}function fn(e){return e.inclusiveRight?1:0}function dn(e,t){var r=e.lines.length-t.lines.length;if(0!=r)return r;var n=e.find(),i=t.find(),o=Fo(n.from,i.from)||hn(e)-hn(t);if(o)return-o;var l=Fo(n.to,i.to)||fn(e)-fn(t);return l?l:t.id-e.id}function pn(e,t){var r,n=Io&&e.markedSpans;if(n)for(var i,o=0;o<n.length;++o)i=n[o],i.marker.collapsed&&null==(t?i.from:i.to)&&(!r||dn(r,i.marker)<0)&&(r=i.marker);return r}function gn(e){return pn(e,!0)}function vn(e){return pn(e,!1)}function mn(e,t,r,n,i){var o=Zn(e,t),l=Io&&o.markedSpans;if(l)for(var s=0;s<l.length;++s){var a=l[s];if(a.marker.collapsed){var u=a.marker.find(0),c=Fo(u.from,r)||hn(a.marker)-hn(i),h=Fo(u.to,n)||fn(a.marker)-fn(i);if(!(c>=0&&h<=0||c<=0&&h>=0)&&(c<=0&&(Fo(u.to,r)>0||a.marker.inclusiveRight&&i.inclusiveLeft)||c>=0&&(Fo(u.from,n)<0||a.marker.inclusiveLeft&&i.inclusiveRight)))return!0}}}function yn(e){for(var t;t=gn(e);)e=t.find(-1,!0).line;return e}function bn(e){for(var t,r;t=vn(e);)e=t.find(1,!0).line,(r||(r=[])).push(e);return r}function wn(e,t){var r=Zn(e,t),n=yn(r);return r==n?t:ti(n)}function xn(e,t){if(t>e.lastLine())return t;var r,n=Zn(e,t);if(!Cn(e,n))return t;for(;r=vn(n);)n=r.find(1,!0).line;return ti(n)+1}function Cn(e,t){var r=Io&&t.markedSpans;if(r)for(var n,i=0;i<r.length;++i)if(n=r[i],n.marker.collapsed){if(null==n.from)return!0;if(!n.marker.widgetNode&&0==n.from&&n.marker.inclusiveLeft&&Sn(e,t,n))return!0}}function Sn(e,t,r){if(null==r.to){var n=r.marker.find(1,!0);return Sn(e,n.line,Jr(n.line.markedSpans,r.marker))}if(r.marker.inclusiveRight&&r.to==t.text.length)return!0;for(var i,o=0;o<t.markedSpans.length;++o)if(i=t.markedSpans[o],i.marker.collapsed&&!i.marker.widgetNode&&i.from==r.to&&(null==i.to||i.to!=r.from)&&(i.marker.inclusiveLeft||r.marker.inclusiveRight)&&Sn(e,t,i))return!0}function Ln(e,t,r){ni(t)<(e.curOp&&e.curOp.scrollTop||e.doc.scrollTop)&&Ir(e,null,r)}function Tn(e){if(null!=e.height)return e.height;var t=e.doc.cm;if(!t)return 0;if(!Yl(document.body,e.node)){var r="position: relative;";e.coverGutter&&(r+="margin-left: -"+t.display.gutters.offsetWidth+"px;"),e.noHScroll&&(r+="width: "+t.display.wrapper.clientWidth+"px;"),Ki(t.display.measure,Ui("div",[e.node],null,r))}return e.height=e.node.parentNode.offsetHeight}function kn(e,t,r,n){var i=new yl(e,r,n),o=e.cm;return o&&i.noHScroll&&(o.display.alignWidgets=!0),Br(e,t,"widget",function(t){var r=t.widgets||(t.widgets=[]);if(null==i.insertAt?r.push(i):r.splice(Math.min(r.length-1,Math.max(0,i.insertAt)),0,i),i.line=t,o&&!Cn(e,t)){var n=ni(t)<e.scrollTop;ei(t,t.height+Tn(i)),n&&Ir(o,null,i.height),o.curOp.forceUpdate=!0}return!0}),i}function Mn(e,t,r,n){e.text=t,e.stateAfter&&(e.stateAfter=null),e.styles&&(e.styles=null),null!=e.order&&(e.order=null),un(e),cn(e,r);var i=n?n(e):1;i!=e.height&&ei(e,i)}function Nn(e){e.parent=null,un(e)}function Wn(e,t){if(e)for(;;){var r=e.match(/(?:^|\s+)line-(background-)?(\S+)/);if(!r)break;e=e.slice(0,r.index)+e.slice(r.index+r[0].length);var n=r[1]?"bgClass":"textClass";null==t[n]?t[n]=r[2]:new RegExp("(?:^|s)"+r[2]+"(?:$|s)").test(t[n])||(t[n]+=" "+r[2])}return e}function An(t,r){if(t.blankLine)return t.blankLine(r);if(t.innerMode){var n=e.innerMode(t,r);return n.mode.blankLine?n.mode.blankLine(n.state):void 0}}function On(t,r,n,i){for(var o=0;o<10;o++){i&&(i[0]=e.innerMode(t,n).mode);var l=t.token(r,n);if(r.pos>r.start)return l}throw new Error("Mode "+t.name+" failed to advance stream.")}function Dn(e,t,r,n){function i(e){return{start:h.start,end:h.pos,string:h.current(),type:o||null,state:e?sl(l.mode,c):c}}var o,l=e.doc,s=l.mode;t=ge(l,t);var a,u=Zn(l,t.line),c=Ue(e,t.line,r),h=new pl(u.text,e.options.tabSize);for(n&&(a=[]);(n||h.pos<t.ch)&&!h.eol();)h.start=h.pos,o=On(s,h,c),n&&a.push(i(!0));return n?a:i()}function Hn(e,t,r,n,i,o,l){var s=r.flattenSpans;null==s&&(s=e.options.flattenSpans);var a,u=0,c=null,h=new pl(t,e.options.tabSize),f=e.options.addModeClass&&[null];for(""==t&&Wn(An(r,n),o);!h.eol();){if(h.pos>e.options.maxHighlightLength?(s=!1,l&&In(e,t,n,h.pos),h.pos=t.length,a=null):a=Wn(On(r,h,n,f),o),f){var d=f[0].name;d&&(a="m-"+(a?d+" "+a:d))}if(!s||c!=a){for(;u<h.start;)u=Math.min(h.start,u+5e4),i(u,c);c=a}h.start=h.pos}for(;u<h.pos;){var p=Math.min(h.pos,u+5e4);i(p,c),u=p}}function Pn(e,t,r,n){var i=[e.state.modeGen],o={};Hn(e,t.text,e.doc.mode,r,function(e,t){i.push(e,t)},o,n);for(var l=0;l<e.state.overlays.length;++l){var s=e.state.overlays[l],a=1,u=0;Hn(e,t.text,s.mode,!0,function(e,t){for(var r=a;u<e;){var n=i[a];n>e&&i.splice(a,1,e,i[a+1],n),a+=2,u=Math.min(e,n)}if(t)if(s.opaque)i.splice(r,a-r,e,"cm-overlay "+t),a=r+2;else for(;r<a;r+=2){var o=i[r+1];i[r+1]=(o?o+" ":"")+"cm-overlay "+t}},o)}return{styles:i,classes:o.bgClass||o.textClass?o:null}}function En(e,t,r){if(!t.styles||t.styles[0]!=e.state.modeGen){var n=Ue(e,ti(t)),i=Pn(e,t,t.text.length>e.options.maxHighlightLength?sl(e.doc.mode,n):n);t.stateAfter=n,t.styles=i.styles,i.classes?t.styleClasses=i.classes:t.styleClasses&&(t.styleClasses=null),r===e.doc.frontier&&e.doc.frontier++}return t.styles}function In(e,t,r,n){var i=e.doc.mode,o=new pl(t,e.options.tabSize);for(o.start=o.pos=n||0,""==t&&An(i,r);!o.eol();)On(i,o,r),o.start=o.pos}function zn(e,t){if(!e||/^\s*$/.test(e))return null;var r=t.addModeClass?xl:wl;return r[e]||(r[e]=e.replace(/\S+/g,"cm-$&"))}function Fn(e,t){var r=Ui("span",null,null,xo?"padding-right: .1px":null),n={pre:Ui("pre",[r],"CodeMirror-line"),content:r,col:0,pos:0,cm:e,splitSpaces:(bo||xo)&&e.getOption("lineWrapping")};t.measure={};for(var i=0;i<=(t.rest?t.rest.length:0);i++){var o,l=i?t.rest[i-1]:t.line;n.pos=0,n.addToken=Bn,Qi(e.display.measure)&&(o=ii(l))&&(n.addToken=Un(n.addToken,o)),n.map=[];var s=t!=e.display.externalMeasured&&ti(l);Kn(l,n,En(e,l,s)),l.styleClasses&&(l.styleClasses.bgClass&&(n.bgClass=Yi(l.styleClasses.bgClass,n.bgClass||"")),l.styleClasses.textClass&&(n.textClass=Yi(l.styleClasses.textClass,n.textClass||""))),0==n.map.length&&n.map.push(0,0,n.content.appendChild(Zi(e.display.measure))),0==i?(t.measure.map=n.map,t.measure.cache={}):((t.measure.maps||(t.measure.maps=[])).push(n.map),(t.measure.caches||(t.measure.caches=[])).push({}))}return xo&&/\bcm-tab\b/.test(n.content.lastChild.className)&&(n.content.className="cm-tab-wrap-hack"),Dl(e,"renderLine",e,t.line,n.pre),n.pre.className&&(n.textClass=Yi(n.pre.className,n.textClass||"")),n}function Rn(e){var t=Ui("span","•","cm-invalidchar");return t.title="\\u"+e.charCodeAt(0).toString(16),t.setAttribute("aria-label",t.title),t}function Bn(e,t,r,n,i,o,l){if(t){var s=e.splitSpaces?t.replace(/ {3,}/g,Gn):t,a=e.cm.state.specialChars,u=!1;if(a.test(t))for(var c=document.createDocumentFragment(),h=0;;){a.lastIndex=h;var f=a.exec(t),d=f?f.index-h:t.length-h;if(d){var p=document.createTextNode(s.slice(h,h+d));bo&&wo<9?c.appendChild(Ui("span",[p])):c.appendChild(p),e.map.push(e.pos,e.pos+d,p),e.col+=d,e.pos+=d}if(!f)break;if(h+=d+1,"\t"==f[0]){var g=e.cm.options.tabSize,v=g-e.col%g,p=c.appendChild(Ui("span",Oi(v),"cm-tab"));p.setAttribute("role","presentation"),p.setAttribute("cm-text","\t"),e.col+=v}else if("\r"==f[0]||"\n"==f[0]){var p=c.appendChild(Ui("span","\r"==f[0]?"␍":"␤","cm-invalidchar"));p.setAttribute("cm-text",f[0]),e.col+=1}else{var p=e.cm.options.specialCharPlaceholder(f[0]);p.setAttribute("cm-text",f[0]),bo&&wo<9?c.appendChild(Ui("span",[p])):c.appendChild(p),e.col+=1}e.map.push(e.pos,e.pos+1,p),e.pos++}else{e.col+=t.length;var c=document.createTextNode(s);e.map.push(e.pos,e.pos+t.length,c),bo&&wo<9&&(u=!0),e.pos+=t.length}if(r||n||i||u||l){var m=r||"";n&&(m+=n),i&&(m+=i);var y=Ui("span",[c],m,l);return o&&(y.title=o),e.content.appendChild(y)}e.content.appendChild(c)}}function Gn(e){for(var t=" ",r=0;r<e.length-2;++r)t+=r%2?" ":" ";return t+=" "}function Un(e,t){return function(r,n,i,o,l,s,a){i=i?i+" cm-force-border":"cm-force-border";for(var u=r.pos,c=u+n.length;;){for(var h=0;h<t.length;h++){var f=t[h];if(f.to>u&&f.from<=u)break}if(f.to>=c)return e(r,n,i,o,l,s,a);e(r,n.slice(0,f.to-u),i,o,null,s,a),o=null,n=n.slice(f.to-u),u=f.to}}}function Vn(e,t,r,n){var i=!n&&r.widgetNode;i&&e.map.push(e.pos,e.pos+t,i),!n&&e.cm.display.input.needsContentAttribute&&(i||(i=e.content.appendChild(document.createElement("span"))),i.setAttribute("cm-marker",r.id)),i&&(e.cm.display.input.setUneditable(i),e.content.appendChild(i)),e.pos+=t}function Kn(e,t,r){var n=e.markedSpans,i=e.text,o=0;if(n)for(var l,s,a,u,c,h,f,d=i.length,p=0,g=1,v="",m=0;;){if(m==p){a=u=c=h=s="",f=null,m=1/0;for(var y,b=[],w=0;w<n.length;++w){var x=n[w],C=x.marker;"bookmark"==C.type&&x.from==p&&C.widgetNode?b.push(C):x.from<=p&&(null==x.to||x.to>p||C.collapsed&&x.to==p&&x.from==p)?(null!=x.to&&x.to!=p&&m>x.to&&(m=x.to,u=""),C.className&&(a+=" "+C.className),C.css&&(s=(s?s+";":"")+C.css),C.startStyle&&x.from==p&&(c+=" "+C.startStyle),C.endStyle&&x.to==m&&(y||(y=[])).push(C.endStyle,x.to),C.title&&!h&&(h=C.title),C.collapsed&&(!f||dn(f.marker,C)<0)&&(f=x)):x.from>p&&m>x.from&&(m=x.from)}if(y)for(var w=0;w<y.length;w+=2)y[w+1]==m&&(u+=" "+y[w]);if(f&&(f.from||0)==p){if(Vn(t,(null==f.to?d+1:f.to)-p,f.marker,null==f.from),null==f.to)return;f.to==p&&(f=!1)}if(!f&&b.length)for(var w=0;w<b.length;++w)Vn(t,0,b[w])}if(p>=d)break;for(var S=Math.min(d,m);;){if(v){var L=p+v.length;if(!f){var T=L>S?v.slice(0,S-p):v;t.addToken(t,T,l?l+a:a,c,p+T.length==m?u:"",h,s)}if(L>=S){v=v.slice(S-p),p=S;break}p=L,c=""}v=i.slice(o,o=r[g++]),l=zn(r[g++],t.cm.options)}}else for(var g=1;g<r.length;g+=2)t.addToken(t,i.slice(o,o=r[g]),zn(r[g+1],t.cm.options))}function jn(e,t){return 0==t.from.ch&&0==t.to.ch&&""==Di(t.text)&&(!e.cm||e.cm.options.wholeLineUpdateBefore)}function Xn(e,t,r,n){function i(e){return r?r[e]:null}function o(e,r,i){Mn(e,r,i,n),Li(e,"change",e,t)}function l(e,t){for(var r=e,o=[];r<t;++r)o.push(new bl(u[r],i(r),n));return o}var s=t.from,a=t.to,u=t.text,c=Zn(e,s.line),h=Zn(e,a.line),f=Di(u),d=i(u.length-1),p=a.line-s.line;if(t.full)e.insert(0,l(0,u.length)),e.remove(u.length,e.size-u.length);else if(jn(e,t)){var g=l(0,u.length-1);o(h,h.text,d),p&&e.remove(s.line,p),g.length&&e.insert(s.line,g)}else if(c==h)if(1==u.length)o(c,c.text.slice(0,s.ch)+f+c.text.slice(a.ch),d);else{var g=l(1,u.length-1);g.push(new bl(f+c.text.slice(a.ch),d,n)),o(c,c.text.slice(0,s.ch)+u[0],i(0)),e.insert(s.line+1,g)}else if(1==u.length)o(c,c.text.slice(0,s.ch)+u[0]+h.text.slice(a.ch),i(0)),e.remove(s.line+1,p);else{o(c,c.text.slice(0,s.ch)+u[0],i(0)),o(h,f+h.text.slice(a.ch),d);var g=l(1,u.length-1);p>1&&e.remove(s.line+1,p-1),e.insert(s.line+1,g)}Li(e,"change",e,t)}function Yn(e){this.lines=e,this.parent=null;for(var t=0,r=0;t<e.length;++t)e[t].parent=this,r+=e[t].height;this.height=r}function _n(e){this.children=e;for(var t=0,r=0,n=0;n<e.length;++n){var i=e[n];t+=i.chunkSize(),r+=i.height,i.parent=this}this.size=t,this.height=r,this.parent=null}function $n(e,t,r){function n(e,i,o){if(e.linked)for(var l=0;l<e.linked.length;++l){var s=e.linked[l];if(s.doc!=i){var a=o&&s.sharedHist;r&&!a||(t(s.doc,a),n(s.doc,e,a))}}}n(e,null,!0)}function qn(e,t){if(t.cm)throw new Error("This document is already in use.");e.doc=t,t.cm=e,l(e),r(e),e.options.lineWrapping||f(e),e.options.mode=t.modeOption,Et(e)}function Zn(e,t){if(t-=e.first,t<0||t>=e.size)throw new Error("There is no line "+(t+e.first)+" in the document.");for(var r=e;!r.lines;)for(var n=0;;++n){var i=r.children[n],o=i.chunkSize();if(t<o){r=i;break}t-=o}return r.lines[t]}function Qn(e,t,r){var n=[],i=t.line;return e.iter(t.line,r.line+1,function(e){var o=e.text;i==r.line&&(o=o.slice(0,r.ch)),i==t.line&&(o=o.slice(t.ch)),n.push(o),++i}),n}function Jn(e,t,r){var n=[];return e.iter(t,r,function(e){n.push(e.text)}),n}function ei(e,t){var r=t-e.height;if(r)for(var n=e;n;n=n.parent)n.height+=r}function ti(e){if(null==e.parent)return null;for(var t=e.parent,r=Hi(t.lines,e),n=t.parent;n;t=n,n=n.parent)for(var i=0;n.children[i]!=t;++i)r+=n.children[i].chunkSize();return r+t.first}function ri(e,t){var r=e.first;e:do{for(var n=0;n<e.children.length;++n){var i=e.children[n],o=i.height;if(t<o){e=i;continue e}t-=o,r+=i.chunkSize()}return r}while(!e.lines);for(var n=0;n<e.lines.length;++n){var l=e.lines[n],s=l.height;if(t<s)break;t-=s}return r+n}function ni(e){e=yn(e);for(var t=0,r=e.parent,n=0;n<r.lines.length;++n){var i=r.lines[n];if(i==e)break;t+=i.height}for(var o=r.parent;o;r=o,o=r.parent)for(var n=0;n<o.children.length;++n){var l=o.children[n];if(l==r)break;t+=l.height}return t}function ii(e){var t=e.order;return null==t&&(t=e.order=ls(e.text)),t}function oi(e){this.done=[],this.undone=[],this.undoDepth=1/0,this.lastModTime=this.lastSelTime=0,this.lastOp=this.lastSelOp=null,this.lastOrigin=this.lastSelOrigin=null,this.generation=this.maxGeneration=e||1}function li(e,t){var r={from:Y(t.from),to:Qo(t),text:Qn(e,t.from,t.to)};return di(e,r,t.from.line,t.to.line+1),$n(e,function(e){di(e,r,t.from.line,t.to.line+1)},!0),r}function si(e){for(;e.length;){var t=Di(e);if(!t.ranges)break;e.pop()}}function ai(e,t){return t?(si(e.done),Di(e.done)):e.done.length&&!Di(e.done).ranges?Di(e.done):e.done.length>1&&!e.done[e.done.length-2].ranges?(e.done.pop(),Di(e.done)):void 0}function ui(e,t,r,n){var i=e.history;i.undone.length=0;var o,l=+new Date;if((i.lastOp==n||i.lastOrigin==t.origin&&t.origin&&("+"==t.origin.charAt(0)&&e.cm&&i.lastModTime>l-e.cm.options.historyEventDelay||"*"==t.origin.charAt(0)))&&(o=ai(i,i.lastOp==n))){var s=Di(o.changes);0==Fo(t.from,t.to)&&0==Fo(t.from,s.to)?s.to=Qo(t):o.changes.push(li(e,t))}else{var a=Di(i.done);for(a&&a.ranges||fi(e.sel,i.done),o={changes:[li(e,t)],generation:i.generation},i.done.push(o);i.done.length>i.undoDepth;)i.done.shift(),i.done[0].ranges||i.done.shift()}i.done.push(r),i.generation=++i.maxGeneration,i.lastModTime=i.lastSelTime=l,i.lastOp=i.lastSelOp=n,i.lastOrigin=i.lastSelOrigin=t.origin,s||Dl(e,"historyAdded")}function ci(e,t,r,n){var i=t.charAt(0);return"*"==i||"+"==i&&r.ranges.length==n.ranges.length&&r.somethingSelected()==n.somethingSelected()&&new Date-e.history.lastSelTime<=(e.cm?e.cm.options.historyEventDelay:500)}function hi(e,t,r,n){var i=e.history,o=n&&n.origin;r==i.lastSelOp||o&&i.lastSelOrigin==o&&(i.lastModTime==i.lastSelTime&&i.lastOrigin==o||ci(e,o,Di(i.done),t))?i.done[i.done.length-1]=t:fi(t,i.done),i.lastSelTime=+new Date,i.lastSelOrigin=o,i.lastSelOp=r,n&&n.clearRedo!==!1&&si(i.undone)}function fi(e,t){var r=Di(t);r&&r.ranges&&r.equals(e)||t.push(e)}function di(e,t,r,n){var i=t["spans_"+e.id],o=0;e.iter(Math.max(e.first,r),Math.min(e.first+e.size,n),function(r){r.markedSpans&&((i||(i=t["spans_"+e.id]={}))[o]=r.markedSpans),++o})}function pi(e){if(!e)return null;for(var t,r=0;r<e.length;++r)e[r].marker.explicitlyCleared?t||(t=e.slice(0,r)):t&&t.push(e[r]);return t?t.length?t:null:e}function gi(e,t){var r=t["spans_"+e.id];if(!r)return null;for(var n=0,i=[];n<t.text.length;++n)i.push(pi(r[n]));return i}function vi(e,t,r){for(var n=0,i=[];n<e.length;++n){var o=e[n];if(o.ranges)i.push(r?ce.prototype.deepCopy.call(o):o);else{var l=o.changes,s=[];i.push({changes:s});for(var a=0;a<l.length;++a){var u,c=l[a];if(s.push({from:c.from,to:c.to,text:c.text}),t)for(var h in c)(u=h.match(/^spans_(\d+)$/))&&Hi(t,Number(u[1]))>-1&&(Di(s)[h]=c[h],delete c[h])}}}return i}function mi(e,t,r,n){r<e.line?e.line+=n:t<e.line&&(e.line=t,e.ch=0)}function yi(e,t,r,n){for(var i=0;i<e.length;++i){var o=e[i],l=!0;if(o.ranges){o.copied||(o=e[i]=o.deepCopy(),o.copied=!0);for(var s=0;s<o.ranges.length;s++)mi(o.ranges[s].anchor,t,r,n),mi(o.ranges[s].head,t,r,n)}else{for(var s=0;s<o.changes.length;++s){var a=o.changes[s];if(r<a.from.line)a.from=zo(a.from.line+n,a.from.ch),a.to=zo(a.to.line+n,a.to.ch);else if(t<=a.to.line){l=!1;break}}l||(e.splice(0,i+1),i=0)}}}function bi(e,t){var
1
  !function(e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else{if("function"==typeof define&&define.amd)return define([],e);(this||window).CodeMirror=e()}}(function(){"use strict";function e(r,n){if(!(this instanceof e))return new e(r,n);this.options=n=n?zi(n):{},zi(Jo,n,!1),d(n);var i=n.value;"string"==typeof i&&(i=new Sl(i,n.mode,null,n.lineSeparator)),this.doc=i;var o=new e.inputStyles[n.inputStyle](this),l=this.display=new t(r,i,o);l.wrapper.CodeMirror=this,u(this),s(this),n.lineWrapping&&(this.display.wrapper.className+=" CodeMirror-wrap"),n.autofocus&&!Wo&&l.input.focus(),m(this),this.state={keyMaps:[],overlays:[],modeGen:0,overwrite:!1,delayingBlurEvent:!1,focused:!1,suppressEdits:!1,pasteIncoming:!1,cutIncoming:!1,selectingText:!1,draggingText:!1,highlight:new Ai,keySeq:null,specialChars:null};var a=this;bo&&wo<11&&setTimeout(function(){a.display.input.reset(!0)},20),Ut(this),$i(),wt(this),this.curOp.forceUpdate=!0,qn(this,i),n.autofocus&&!Wo||a.hasFocus()?setTimeout(Fi(vr,this),20):mr(this);for(var c in el)el.hasOwnProperty(c)&&el[c](this,n[c],tl);C(this),n.finishInit&&n.finishInit(this);for(var h=0;h<ol.length;++h)ol[h](this);Ct(this),xo&&n.lineWrapping&&"optimizelegibility"==getComputedStyle(l.lineDiv).textRendering&&(l.lineDiv.style.textRendering="auto")}function t(e,t,r){var n=this;this.input=r,n.scrollbarFiller=Ui("div",null,"CodeMirror-scrollbar-filler"),n.scrollbarFiller.setAttribute("cm-not-content","true"),n.gutterFiller=Ui("div",null,"CodeMirror-gutter-filler"),n.gutterFiller.setAttribute("cm-not-content","true"),n.lineDiv=Ui("div",null,"CodeMirror-code"),n.selectionDiv=Ui("div",null,null,"position: relative; z-index: 1"),n.cursorDiv=Ui("div",null,"CodeMirror-cursors"),n.measure=Ui("div",null,"CodeMirror-measure"),n.lineMeasure=Ui("div",null,"CodeMirror-measure"),n.lineSpace=Ui("div",[n.measure,n.lineMeasure,n.selectionDiv,n.cursorDiv,n.lineDiv],null,"position: relative; outline: none"),n.mover=Ui("div",[Ui("div",[n.lineSpace],"CodeMirror-lines")],null,"position: relative"),n.sizer=Ui("div",[n.mover],"CodeMirror-sizer"),n.sizerWidth=null,n.heightForcer=Ui("div",null,null,"position: absolute; height: "+Pl+"px; width: 1px;"),n.gutters=Ui("div",null,"CodeMirror-gutters"),n.lineGutter=null,n.scroller=Ui("div",[n.sizer,n.heightForcer,n.gutters],"CodeMirror-scroll"),n.scroller.setAttribute("tabIndex","-1"),n.wrapper=Ui("div",[n.scrollbarFiller,n.gutterFiller,n.scroller],"CodeMirror"),bo&&wo<8&&(n.gutters.style.zIndex=-1,n.scroller.style.paddingRight=0),xo||vo&&Wo||(n.scroller.draggable=!0),e&&(e.appendChild?e.appendChild(n.wrapper):e(n.wrapper)),n.viewFrom=n.viewTo=t.first,n.reportedViewFrom=n.reportedViewTo=t.first,n.view=[],n.renderedView=null,n.externalMeasured=null,n.viewOffset=0,n.lastWrapHeight=n.lastWrapWidth=0,n.updateLineNumbers=null,n.nativeBarWidth=n.barHeight=n.barWidth=0,n.scrollbarsClipped=!1,n.lineNumWidth=n.lineNumInnerWidth=n.lineNumChars=null,n.alignWidgets=!1,n.cachedCharWidth=n.cachedTextHeight=n.cachedPaddingH=null,n.maxLine=null,n.maxLineLength=0,n.maxLineChanged=!1,n.wheelDX=n.wheelDY=n.wheelStartX=n.wheelStartY=null,n.shift=!1,n.selForContextMenu=null,n.activeTouch=null,r.init(n)}function r(t){t.doc.mode=e.getMode(t.options,t.doc.modeOption),n(t)}function n(e){e.doc.iter(function(e){e.stateAfter&&(e.stateAfter=null),e.styles&&(e.styles=null)}),e.doc.frontier=e.doc.first,Re(e,100),e.state.modeGen++,e.curOp&&Et(e)}function i(e){e.options.lineWrapping?(Zl(e.display.wrapper,"CodeMirror-wrap"),e.display.sizer.style.minWidth="",e.display.sizerWidth=null):(ql(e.display.wrapper,"CodeMirror-wrap"),f(e)),l(e),Et(e),st(e),setTimeout(function(){y(e)},100)}function o(e){var t=yt(e.display),r=e.options.lineWrapping,n=r&&Math.max(5,e.display.scroller.clientWidth/bt(e.display)-3);return function(i){if(Cn(e.doc,i))return 0;var o=0;if(i.widgets)for(var l=0;l<i.widgets.length;l++)i.widgets[l].height&&(o+=i.widgets[l].height);return r?o+(Math.ceil(i.text.length/n)||1)*t:o+t}}function l(e){var t=e.doc,r=o(e);t.iter(function(e){var t=r(e);t!=e.height&&ei(e,t)})}function s(e){e.display.wrapper.className=e.display.wrapper.className.replace(/\s*cm-s-\S+/g,"")+e.options.theme.replace(/(^|\s)\s*/g," cm-s-"),st(e)}function a(e){u(e),Et(e),setTimeout(function(){x(e)},20)}function u(e){var t=e.display.gutters,r=e.options.gutters;Vi(t);for(var n=0;n<r.length;++n){var i=r[n],o=t.appendChild(Ui("div",null,"CodeMirror-gutter "+i));"CodeMirror-linenumbers"==i&&(e.display.lineGutter=o,o.style.width=(e.display.lineNumWidth||1)+"px")}t.style.display=n?"":"none",c(e)}function c(e){var t=e.display.gutters.offsetWidth;e.display.sizer.style.marginLeft=t+"px"}function h(e){if(0==e.height)return 0;for(var t,r=e.text.length,n=e;t=gn(n);){var i=t.find(0,!0);n=i.from.line,r+=i.from.ch-i.to.ch}for(n=e;t=vn(n);){var i=t.find(0,!0);r-=n.text.length-i.from.ch,n=i.to.line,r+=n.text.length-i.to.ch}return r}function f(e){var t=e.display,r=e.doc;t.maxLine=Zn(r,r.first),t.maxLineLength=h(t.maxLine),t.maxLineChanged=!0,r.iter(function(e){var r=h(e);r>t.maxLineLength&&(t.maxLineLength=r,t.maxLine=e)})}function d(e){var t=Hi(e.gutters,"CodeMirror-linenumbers");t==-1&&e.lineNumbers?e.gutters=e.gutters.concat(["CodeMirror-linenumbers"]):t>-1&&!e.lineNumbers&&(e.gutters=e.gutters.slice(0),e.gutters.splice(t,1))}function p(e){var t=e.display,r=t.gutters.offsetWidth,n=Math.round(e.doc.height+Ke(e.display));return{clientHeight:t.scroller.clientHeight,viewHeight:t.wrapper.clientHeight,scrollWidth:t.scroller.scrollWidth,clientWidth:t.scroller.clientWidth,viewWidth:t.wrapper.clientWidth,barLeft:e.options.fixedGutter?r:0,docHeight:n,scrollHeight:n+Xe(e)+t.barHeight,nativeBarWidth:t.nativeBarWidth,gutterWidth:r}}function g(e,t,r){this.cm=r;var n=this.vert=Ui("div",[Ui("div",null,null,"min-width: 1px")],"CodeMirror-vscrollbar"),i=this.horiz=Ui("div",[Ui("div",null,null,"height: 100%; min-height: 1px")],"CodeMirror-hscrollbar");e(n),e(i),Wl(n,"scroll",function(){n.clientHeight&&t(n.scrollTop,"vertical")}),Wl(i,"scroll",function(){i.clientWidth&&t(i.scrollLeft,"horizontal")}),this.checkedZeroWidth=!1,bo&&wo<8&&(this.horiz.style.minHeight=this.vert.style.minWidth="18px")}function v(){}function m(t){t.display.scrollbars&&(t.display.scrollbars.clear(),t.display.scrollbars.addClass&&ql(t.display.wrapper,t.display.scrollbars.addClass)),t.display.scrollbars=new e.scrollbarModel[t.options.scrollbarStyle](function(e){t.display.wrapper.insertBefore(e,t.display.scrollbarFiller),Wl(e,"mousedown",function(){t.state.focused&&setTimeout(function(){t.display.input.focus()},0)}),e.setAttribute("cm-not-content","true")},function(e,r){"horizontal"==r?ir(t,e):nr(t,e)},t),t.display.scrollbars.addClass&&Zl(t.display.wrapper,t.display.scrollbars.addClass)}function y(e,t){t||(t=p(e));var r=e.display.barWidth,n=e.display.barHeight;b(e,t);for(var i=0;i<4&&r!=e.display.barWidth||n!=e.display.barHeight;i++)r!=e.display.barWidth&&e.options.lineWrapping&&O(e),b(e,p(e)),r=e.display.barWidth,n=e.display.barHeight}function b(e,t){var r=e.display,n=r.scrollbars.update(t);r.sizer.style.paddingRight=(r.barWidth=n.right)+"px",r.sizer.style.paddingBottom=(r.barHeight=n.bottom)+"px",n.right&&n.bottom?(r.scrollbarFiller.style.display="block",r.scrollbarFiller.style.height=n.bottom+"px",r.scrollbarFiller.style.width=n.right+"px"):r.scrollbarFiller.style.display="",n.bottom&&e.options.coverGutterNextToScrollbar&&e.options.fixedGutter?(r.gutterFiller.style.display="block",r.gutterFiller.style.height=n.bottom+"px",r.gutterFiller.style.width=t.gutterWidth+"px"):r.gutterFiller.style.display=""}function w(e,t,r){var n=r&&null!=r.top?Math.max(0,r.top):e.scroller.scrollTop;n=Math.floor(n-Ve(e));var i=r&&null!=r.bottom?r.bottom:n+e.wrapper.clientHeight,o=ri(t,n),l=ri(t,i);if(r&&r.ensure){var s=r.ensure.from.line,a=r.ensure.to.line;s<o?(o=s,l=ri(t,ni(Zn(t,s))+e.wrapper.clientHeight)):Math.min(a,t.lastLine())>=l&&(o=ri(t,ni(Zn(t,a))-e.wrapper.clientHeight),l=a)}return{from:o,to:Math.max(l,o+1)}}function x(e){var t=e.display,r=t.view;if(t.alignWidgets||t.gutters.firstChild&&e.options.fixedGutter){for(var n=L(t)-t.scroller.scrollLeft+e.doc.scrollLeft,i=t.gutters.offsetWidth,o=n+"px",l=0;l<r.length;l++)if(!r[l].hidden){e.options.fixedGutter&&r[l].gutter&&(r[l].gutter.style.left=o);var s=r[l].alignable;if(s)for(var a=0;a<s.length;a++)s[a].style.left=o}e.options.fixedGutter&&(t.gutters.style.left=n+i+"px")}}function C(e){if(!e.options.lineNumbers)return!1;var t=e.doc,r=S(e.options,t.first+t.size-1),n=e.display;if(r.length!=n.lineNumChars){var i=n.measure.appendChild(Ui("div",[Ui("div",r)],"CodeMirror-linenumber CodeMirror-gutter-elt")),o=i.firstChild.offsetWidth,l=i.offsetWidth-o;return n.lineGutter.style.width="",n.lineNumInnerWidth=Math.max(o,n.lineGutter.offsetWidth-l)+1,n.lineNumWidth=n.lineNumInnerWidth+l,n.lineNumChars=n.lineNumInnerWidth?r.length:-1,n.lineGutter.style.width=n.lineNumWidth+"px",c(e),!0}return!1}function S(e,t){return String(e.lineNumberFormatter(t+e.firstLineNumber))}function L(e){return e.scroller.getBoundingClientRect().left-e.sizer.getBoundingClientRect().left}function T(e,t,r){var n=e.display;this.viewport=t,this.visible=w(n,e.doc,t),this.editorIsHidden=!n.wrapper.offsetWidth,this.wrapperHeight=n.wrapper.clientHeight,this.wrapperWidth=n.wrapper.clientWidth,this.oldDisplayWidth=Ye(e),this.force=r,this.dims=H(e),this.events=[]}function k(e){var t=e.display;!t.scrollbarsClipped&&t.scroller.offsetWidth&&(t.nativeBarWidth=t.scroller.offsetWidth-t.scroller.clientWidth,t.heightForcer.style.height=Xe(e)+"px",t.sizer.style.marginBottom=-t.nativeBarWidth+"px",t.sizer.style.borderRightWidth=Xe(e)+"px",t.scrollbarsClipped=!0)}function M(e,t){var r=e.display,n=e.doc;if(t.editorIsHidden)return zt(e),!1;if(!t.force&&t.visible.from>=r.viewFrom&&t.visible.to<=r.viewTo&&(null==r.updateLineNumbers||r.updateLineNumbers>=r.viewTo)&&r.renderedView==r.view&&0==Gt(e))return!1;C(e)&&(zt(e),t.dims=H(e));var i=n.first+n.size,o=Math.max(t.visible.from-e.options.viewportMargin,n.first),l=Math.min(i,t.visible.to+e.options.viewportMargin);r.viewFrom<o&&o-r.viewFrom<20&&(o=Math.max(n.first,r.viewFrom)),r.viewTo>l&&r.viewTo-l<20&&(l=Math.min(i,r.viewTo)),Io&&(o=wn(e.doc,o),l=xn(e.doc,l));var s=o!=r.viewFrom||l!=r.viewTo||r.lastWrapHeight!=t.wrapperHeight||r.lastWrapWidth!=t.wrapperWidth;Bt(e,o,l),r.viewOffset=ni(Zn(e.doc,r.viewFrom)),e.display.mover.style.top=r.viewOffset+"px";var a=Gt(e);if(!s&&0==a&&!t.force&&r.renderedView==r.view&&(null==r.updateLineNumbers||r.updateLineNumbers>=r.viewTo))return!1;var u=ji();return a>4&&(r.lineDiv.style.display="none"),P(e,r.updateLineNumbers,t.dims),a>4&&(r.lineDiv.style.display=""),r.renderedView=r.view,u&&ji()!=u&&u.offsetHeight&&u.focus(),Vi(r.cursorDiv),Vi(r.selectionDiv),r.gutters.style.height=r.sizer.style.minHeight=0,s&&(r.lastWrapHeight=t.wrapperHeight,r.lastWrapWidth=t.wrapperWidth,Re(e,400)),r.updateLineNumbers=null,!0}function N(e,t){for(var r=t.viewport,n=!0;(n&&e.options.lineWrapping&&t.oldDisplayWidth!=Ye(e)||(r&&null!=r.top&&(r={top:Math.min(e.doc.height+Ke(e.display)-_e(e),r.top)}),t.visible=w(e.display,e.doc,r),!(t.visible.from>=e.display.viewFrom&&t.visible.to<=e.display.viewTo)))&&M(e,t);n=!1){O(e);var i=p(e);Pe(e),A(e,i),y(e,i)}t.signal(e,"update",e),e.display.viewFrom==e.display.reportedViewFrom&&e.display.viewTo==e.display.reportedViewTo||(t.signal(e,"viewportChange",e,e.display.viewFrom,e.display.viewTo),e.display.reportedViewFrom=e.display.viewFrom,e.display.reportedViewTo=e.display.viewTo)}function W(e,t){var r=new T(e,t);if(M(e,r)){O(e),N(e,r);var n=p(e);Pe(e),A(e,n),y(e,n),r.finish()}}function A(e,t){e.display.sizer.style.minHeight=t.docHeight+"px";var r=t.docHeight+e.display.barHeight;e.display.heightForcer.style.top=r+"px",e.display.gutters.style.height=Math.max(r+Xe(e),t.clientHeight)+"px"}function O(e){for(var t=e.display,r=t.lineDiv.offsetTop,n=0;n<t.view.length;n++){var i,o=t.view[n];if(!o.hidden){if(bo&&wo<8){var l=o.node.offsetTop+o.node.offsetHeight;i=l-r,r=l}else{var s=o.node.getBoundingClientRect();i=s.bottom-s.top}var a=o.line.height-i;if(i<2&&(i=yt(t)),(a>.001||a<-.001)&&(ei(o.line,i),D(o.line),o.rest))for(var u=0;u<o.rest.length;u++)D(o.rest[u])}}}function D(e){if(e.widgets)for(var t=0;t<e.widgets.length;++t)e.widgets[t].height=e.widgets[t].node.parentNode.offsetHeight}function H(e){for(var t=e.display,r={},n={},i=t.gutters.clientLeft,o=t.gutters.firstChild,l=0;o;o=o.nextSibling,++l)r[e.options.gutters[l]]=o.offsetLeft+o.clientLeft+i,n[e.options.gutters[l]]=o.clientWidth;return{fixedPos:L(t),gutterTotalWidth:t.gutters.offsetWidth,gutterLeft:r,gutterWidth:n,wrapperWidth:t.wrapper.clientWidth}}function P(e,t,r){function n(t){var r=t.nextSibling;return xo&&Ao&&e.display.currentWheelTarget==t?t.style.display="none":t.parentNode.removeChild(t),r}for(var i=e.display,o=e.options.lineNumbers,l=i.lineDiv,s=l.firstChild,a=i.view,u=i.viewFrom,c=0;c<a.length;c++){var h=a[c];if(h.hidden);else if(h.node&&h.node.parentNode==l){for(;s!=h.node;)s=n(s);var f=o&&null!=t&&t<=u&&h.lineNumber;h.changes&&(Hi(h.changes,"gutter")>-1&&(f=!1),E(e,h,u,r)),f&&(Vi(h.lineNumber),h.lineNumber.appendChild(document.createTextNode(S(e.options,u)))),s=h.node.nextSibling}else{var d=V(e,h,u,r);l.insertBefore(d,s)}u+=h.size}for(;s;)s=n(s)}function E(e,t,r,n){for(var i=0;i<t.changes.length;i++){var o=t.changes[i];"text"==o?R(e,t):"gutter"==o?G(e,t,r,n):"class"==o?B(t):"widget"==o&&U(e,t,n)}t.changes=null}function I(e){return e.node==e.text&&(e.node=Ui("div",null,null,"position: relative"),e.text.parentNode&&e.text.parentNode.replaceChild(e.node,e.text),e.node.appendChild(e.text),bo&&wo<8&&(e.node.style.zIndex=2)),e.node}function z(e){var t=e.bgClass?e.bgClass+" "+(e.line.bgClass||""):e.line.bgClass;if(t&&(t+=" CodeMirror-linebackground"),e.background)t?e.background.className=t:(e.background.parentNode.removeChild(e.background),e.background=null);else if(t){var r=I(e);e.background=r.insertBefore(Ui("div",null,t),r.firstChild)}}function F(e,t){var r=e.display.externalMeasured;return r&&r.line==t.line?(e.display.externalMeasured=null,t.measure=r.measure,r.built):Fn(e,t)}function R(e,t){var r=t.text.className,n=F(e,t);t.text==t.node&&(t.node=n.pre),t.text.parentNode.replaceChild(n.pre,t.text),t.text=n.pre,n.bgClass!=t.bgClass||n.textClass!=t.textClass?(t.bgClass=n.bgClass,t.textClass=n.textClass,B(t)):r&&(t.text.className=r)}function B(e){z(e),e.line.wrapClass?I(e).className=e.line.wrapClass:e.node!=e.text&&(e.node.className="");var t=e.textClass?e.textClass+" "+(e.line.textClass||""):e.line.textClass;e.text.className=t||""}function G(e,t,r,n){if(t.gutter&&(t.node.removeChild(t.gutter),t.gutter=null),t.gutterBackground&&(t.node.removeChild(t.gutterBackground),t.gutterBackground=null),t.line.gutterClass){var i=I(t);t.gutterBackground=Ui("div",null,"CodeMirror-gutter-background "+t.line.gutterClass,"left: "+(e.options.fixedGutter?n.fixedPos:-n.gutterTotalWidth)+"px; width: "+n.gutterTotalWidth+"px"),i.insertBefore(t.gutterBackground,t.text)}var o=t.line.gutterMarkers;if(e.options.lineNumbers||o){var i=I(t),l=t.gutter=Ui("div",null,"CodeMirror-gutter-wrapper","left: "+(e.options.fixedGutter?n.fixedPos:-n.gutterTotalWidth)+"px");if(e.display.input.setUneditable(l),i.insertBefore(l,t.text),t.line.gutterClass&&(l.className+=" "+t.line.gutterClass),!e.options.lineNumbers||o&&o["CodeMirror-linenumbers"]||(t.lineNumber=l.appendChild(Ui("div",S(e.options,r),"CodeMirror-linenumber CodeMirror-gutter-elt","left: "+n.gutterLeft["CodeMirror-linenumbers"]+"px; width: "+e.display.lineNumInnerWidth+"px"))),o)for(var s=0;s<e.options.gutters.length;++s){var a=e.options.gutters[s],u=o.hasOwnProperty(a)&&o[a];u&&l.appendChild(Ui("div",[u],"CodeMirror-gutter-elt","left: "+n.gutterLeft[a]+"px; width: "+n.gutterWidth[a]+"px"))}}}function U(e,t,r){t.alignable&&(t.alignable=null);for(var n,i=t.node.firstChild;i;i=n){var n=i.nextSibling;"CodeMirror-linewidget"==i.className&&t.node.removeChild(i)}K(e,t,r)}function V(e,t,r,n){var i=F(e,t);return t.text=t.node=i.pre,i.bgClass&&(t.bgClass=i.bgClass),i.textClass&&(t.textClass=i.textClass),B(t),G(e,t,r,n),K(e,t,n),t.node}function K(e,t,r){if(j(e,t.line,t,r,!0),t.rest)for(var n=0;n<t.rest.length;n++)j(e,t.rest[n],t,r,!1)}function j(e,t,r,n,i){if(t.widgets)for(var o=I(r),l=0,s=t.widgets;l<s.length;++l){var a=s[l],u=Ui("div",[a.node],"CodeMirror-linewidget");a.handleMouseEvents||u.setAttribute("cm-ignore-events","true"),X(a,u,r,n),e.display.input.setUneditable(u),i&&a.above?o.insertBefore(u,r.gutter||r.text):o.appendChild(u),Li(a,"redraw")}}function X(e,t,r,n){if(e.noHScroll){(r.alignable||(r.alignable=[])).push(t);var i=n.wrapperWidth;t.style.left=n.fixedPos+"px",e.coverGutter||(i-=n.gutterTotalWidth,t.style.paddingLeft=n.gutterTotalWidth+"px"),t.style.width=i+"px"}e.coverGutter&&(t.style.zIndex=5,t.style.position="relative",e.noHScroll||(t.style.marginLeft=-n.gutterTotalWidth+"px"))}function Y(e){return zo(e.line,e.ch)}function _(e,t){return Fo(e,t)<0?t:e}function $(e,t){return Fo(e,t)<0?e:t}function q(e){e.state.focused||(e.display.input.focus(),vr(e))}function Z(e,t,r,n,i){var o=e.doc;e.display.shift=!1,n||(n=o.sel);var l=e.state.pasteIncoming||"paste"==i,s=o.splitLines(t),a=null;if(l&&n.ranges.length>1)if(Ro&&Ro.join("\n")==t){if(n.ranges.length%Ro.length==0){a=[];for(var u=0;u<Ro.length;u++)a.push(o.splitLines(Ro[u]))}}else s.length==n.ranges.length&&(a=Pi(s,function(e){return[e]}));for(var u=n.ranges.length-1;u>=0;u--){var c=n.ranges[u],h=c.from(),f=c.to();c.empty()&&(r&&r>0?h=zo(h.line,h.ch-r):e.state.overwrite&&!l&&(f=zo(f.line,Math.min(Zn(o,f.line).text.length,f.ch+Di(s).length))));var d=e.curOp.updateInput,p={from:h,to:f,text:a?a[u%a.length]:s,origin:i||(l?"paste":e.state.cutIncoming?"cut":"+input")};Tr(e.doc,p),Li(e,"inputRead",e,p)}t&&!l&&J(e,t),zr(e),e.curOp.updateInput=d,e.curOp.typing=!0,e.state.pasteIncoming=e.state.cutIncoming=!1}function Q(e,t){var r=e.clipboardData&&e.clipboardData.getData("text/plain");if(r)return e.preventDefault(),t.isReadOnly()||t.options.disableInput||Wt(t,function(){Z(t,r,0,null,"paste")}),!0}function J(e,t){if(e.options.electricChars&&e.options.smartIndent)for(var r=e.doc.sel,n=r.ranges.length-1;n>=0;n--){var i=r.ranges[n];if(!(i.head.ch>100||n&&r.ranges[n-1].head.line==i.head.line)){var o=e.getModeAt(i.head),l=!1;if(o.electricChars){for(var s=0;s<o.electricChars.length;s++)if(t.indexOf(o.electricChars.charAt(s))>-1){l=Rr(e,i.head.line,"smart");break}}else o.electricInput&&o.electricInput.test(Zn(e.doc,i.head.line).text.slice(0,i.head.ch))&&(l=Rr(e,i.head.line,"smart"));l&&Li(e,"electricInput",e,i.head.line)}}}function ee(e){for(var t=[],r=[],n=0;n<e.doc.sel.ranges.length;n++){var i=e.doc.sel.ranges[n].head.line,o={anchor:zo(i,0),head:zo(i+1,0)};r.push(o),t.push(e.getRange(o.anchor,o.head))}return{text:t,ranges:r}}function te(e){e.setAttribute("autocorrect","off"),e.setAttribute("autocapitalize","off"),e.setAttribute("spellcheck","false")}function re(e){this.cm=e,this.prevInput="",this.pollingFast=!1,this.polling=new Ai,this.inaccurateSelection=!1,this.hasSelection=!1,this.composing=null}function ne(){var e=Ui("textarea",null,null,"position: absolute; padding: 0; width: 1px; height: 1em; outline: none"),t=Ui("div",[e],null,"overflow: hidden; position: relative; width: 3px; height: 0px;");return xo?e.style.width="1000px":e.setAttribute("wrap","off"),No&&(e.style.border="1px solid black"),te(e),t}function ie(e){this.cm=e,this.lastAnchorNode=this.lastAnchorOffset=this.lastFocusNode=this.lastFocusOffset=null,this.polling=new Ai,this.gracePeriod=!1}function oe(e,t){var r=Je(e,t.line);if(!r||r.hidden)return null;var n=Zn(e.doc,t.line),i=qe(r,n,t.line),o=ii(n),l="left";if(o){var s=uo(o,t.ch);l=s%2?"right":"left"}var a=rt(i.map,t.ch,l);return a.offset="right"==a.collapse?a.end:a.start,a}function le(e,t){return t&&(e.bad=!0),e}function se(e,t,r){var n;if(t==e.display.lineDiv){if(n=e.display.lineDiv.childNodes[r],!n)return le(e.clipPos(zo(e.display.viewTo-1)),!0);t=null,r=0}else for(n=t;;n=n.parentNode){if(!n||n==e.display.lineDiv)return null;if(n.parentNode&&n.parentNode==e.display.lineDiv)break}for(var i=0;i<e.display.view.length;i++){var o=e.display.view[i];if(o.node==n)return ae(o,t,r)}}function ae(e,t,r){function n(t,r,n){for(var i=-1;i<(c?c.length:0);i++)for(var o=i<0?u.map:c[i],l=0;l<o.length;l+=3){var s=o[l+2];if(s==t||s==r){var a=ti(i<0?e.line:e.rest[i]),h=o[l]+n;return(n<0||s!=t)&&(h=o[l+(n?1:0)]),zo(a,h)}}}var i=e.text.firstChild,o=!1;if(!t||!Yl(i,t))return le(zo(ti(e.line),0),!0);if(t==i&&(o=!0,t=i.childNodes[r],r=0,!t)){var l=e.rest?Di(e.rest):e.line;return le(zo(ti(l),l.text.length),o)}var s=3==t.nodeType?t:null,a=t;for(s||1!=t.childNodes.length||3!=t.firstChild.nodeType||(s=t.firstChild,r&&(r=s.nodeValue.length));a.parentNode!=i;)a=a.parentNode;var u=e.measure,c=u.maps,h=n(s,a,r);if(h)return le(h,o);for(var f=a.nextSibling,d=s?s.nodeValue.length-r:0;f;f=f.nextSibling){if(h=n(f,f.firstChild,0))return le(zo(h.line,h.ch-d),o);d+=f.textContent.length}for(var p=a.previousSibling,d=r;p;p=p.previousSibling){if(h=n(p,p.firstChild,-1))return le(zo(h.line,h.ch+d),o);d+=f.textContent.length}}function ue(e,t,r,n,i){function o(e){return function(t){return t.id==e}}function l(t){if(1==t.nodeType){var r=t.getAttribute("cm-text");if(null!=r)return""==r&&(r=t.textContent.replace(/\u200b/g,"")),void(s+=r);var c,h=t.getAttribute("cm-marker");if(h){var f=e.findMarks(zo(n,0),zo(i+1,0),o(+h));return void(f.length&&(c=f[0].find())&&(s+=Qn(e.doc,c.from,c.to).join(u)))}if("false"==t.getAttribute("contenteditable"))return;for(var d=0;d<t.childNodes.length;d++)l(t.childNodes[d]);/^(pre|div|p)$/i.test(t.nodeName)&&(a=!0)}else if(3==t.nodeType){var p=t.nodeValue;if(!p)return;a&&(s+=u,a=!1),s+=p}}for(var s="",a=!1,u=e.doc.lineSeparator();l(t),t!=r;)t=t.nextSibling;return s}function ce(e,t){this.ranges=e,this.primIndex=t}function he(e,t){this.anchor=e,this.head=t}function fe(e,t){var r=e[t];e.sort(function(e,t){return Fo(e.from(),t.from())}),t=Hi(e,r);for(var n=1;n<e.length;n++){var i=e[n],o=e[n-1];if(Fo(o.to(),i.from())>=0){var l=$(o.from(),i.from()),s=_(o.to(),i.to()),a=o.empty()?i.from()==i.head:o.from()==o.head;n<=t&&--t,e.splice(--n,2,new he(a?s:l,a?l:s))}}return new ce(e,t)}function de(e,t){return new ce([new he(e,t||e)],0)}function pe(e,t){return Math.max(e.first,Math.min(t,e.first+e.size-1))}function ge(e,t){if(t.line<e.first)return zo(e.first,0);var r=e.first+e.size-1;return t.line>r?zo(r,Zn(e,r).text.length):ve(t,Zn(e,t.line).text.length)}function ve(e,t){var r=e.ch;return null==r||r>t?zo(e.line,t):r<0?zo(e.line,0):e}function me(e,t){return t>=e.first&&t<e.first+e.size}function ye(e,t){for(var r=[],n=0;n<t.length;n++)r[n]=ge(e,t[n]);return r}function be(e,t,r,n){if(e.cm&&e.cm.display.shift||e.extend){var i=t.anchor;if(n){var o=Fo(r,i)<0;o!=Fo(n,i)<0?(i=r,r=n):o!=Fo(r,n)<0&&(r=n)}return new he(i,r)}return new he(n||r,r)}function we(e,t,r,n){ke(e,new ce([be(e,e.sel.primary(),t,r)],0),n)}function xe(e,t,r){for(var n=[],i=0;i<e.sel.ranges.length;i++)n[i]=be(e,e.sel.ranges[i],t[i],null);var o=fe(n,e.sel.primIndex);ke(e,o,r)}function Ce(e,t,r,n){var i=e.sel.ranges.slice(0);i[t]=r,ke(e,fe(i,e.sel.primIndex),n)}function Se(e,t,r,n){ke(e,de(t,r),n)}function Le(e,t,r){var n={ranges:t.ranges,update:function(t){this.ranges=[];for(var r=0;r<t.length;r++)this.ranges[r]=new he(ge(e,t[r].anchor),ge(e,t[r].head))},origin:r&&r.origin};return Dl(e,"beforeSelectionChange",e,n),e.cm&&Dl(e.cm,"beforeSelectionChange",e.cm,n),n.ranges!=t.ranges?fe(n.ranges,n.ranges.length-1):t}function Te(e,t,r){var n=e.history.done,i=Di(n);i&&i.ranges?(n[n.length-1]=t,Me(e,t,r)):ke(e,t,r)}function ke(e,t,r){Me(e,t,r),hi(e,e.sel,e.cm?e.cm.curOp.id:NaN,r)}function Me(e,t,r){(Ni(e,"beforeSelectionChange")||e.cm&&Ni(e.cm,"beforeSelectionChange"))&&(t=Le(e,t,r));var n=r&&r.bias||(Fo(t.primary().head,e.sel.primary().head)<0?-1:1);Ne(e,Ae(e,t,n,!0)),r&&r.scroll===!1||!e.cm||zr(e.cm)}function Ne(e,t){t.equals(e.sel)||(e.sel=t,e.cm&&(e.cm.curOp.updateInput=e.cm.curOp.selectionChanged=!0,Mi(e.cm)),Li(e,"cursorActivity",e))}function We(e){Ne(e,Ae(e,e.sel,null,!1),Il)}function Ae(e,t,r,n){for(var i,o=0;o<t.ranges.length;o++){var l=t.ranges[o],s=t.ranges.length==e.sel.ranges.length&&e.sel.ranges[o],a=De(e,l.anchor,s&&s.anchor,r,n),u=De(e,l.head,s&&s.head,r,n);(i||a!=l.anchor||u!=l.head)&&(i||(i=t.ranges.slice(0,o)),i[o]=new he(a,u))}return i?fe(i,t.primIndex):t}function Oe(e,t,r,n,i){var o=Zn(e,t.line);if(o.markedSpans)for(var l=0;l<o.markedSpans.length;++l){var s=o.markedSpans[l],a=s.marker;if((null==s.from||(a.inclusiveLeft?s.from<=t.ch:s.from<t.ch))&&(null==s.to||(a.inclusiveRight?s.to>=t.ch:s.to>t.ch))){if(i&&(Dl(a,"beforeCursorEnter"),a.explicitlyCleared)){if(o.markedSpans){--l;continue}break}if(!a.atomic)continue;if(r){var u,c=a.find(n<0?1:-1);if((n<0?a.inclusiveRight:a.inclusiveLeft)&&(c=He(e,c,-n,o)),c&&c.line==t.line&&(u=Fo(c,r))&&(n<0?u<0:u>0))return Oe(e,c,t,n,i)}var h=a.find(n<0?-1:1);return(n<0?a.inclusiveLeft:a.inclusiveRight)&&(h=He(e,h,n,o)),h?Oe(e,h,t,n,i):null}}return t}function De(e,t,r,n,i){var o=n||1,l=Oe(e,t,r,o,i)||!i&&Oe(e,t,r,o,!0)||Oe(e,t,r,-o,i)||!i&&Oe(e,t,r,-o,!0);return l?l:(e.cantEdit=!0,zo(e.first,0))}function He(e,t,r,n){return r<0&&0==t.ch?t.line>e.first?ge(e,zo(t.line-1)):null:r>0&&t.ch==(n||Zn(e,t.line)).text.length?t.line<e.first+e.size-1?zo(t.line+1,0):null:new zo(t.line,t.ch+r)}function Pe(e){e.display.input.showSelection(e.display.input.prepareSelection())}function Ee(e,t){for(var r=e.doc,n={},i=n.cursors=document.createDocumentFragment(),o=n.selection=document.createDocumentFragment(),l=0;l<r.sel.ranges.length;l++)if(t!==!1||l!=r.sel.primIndex){var s=r.sel.ranges[l],a=s.empty();(a||e.options.showCursorWhenSelecting)&&Ie(e,s.head,i),a||ze(e,s,o)}return n}function Ie(e,t,r){var n=dt(e,t,"div",null,null,!e.options.singleCursorHeightPerLine),i=r.appendChild(Ui("div"," ","CodeMirror-cursor"));if(i.style.left=n.left+"px",i.style.top=n.top+"px",i.style.height=Math.max(0,n.bottom-n.top)*e.options.cursorHeight+"px",n.other){var o=r.appendChild(Ui("div"," ","CodeMirror-cursor CodeMirror-secondarycursor"));o.style.display="",o.style.left=n.other.left+"px",o.style.top=n.other.top+"px",o.style.height=.85*(n.other.bottom-n.other.top)+"px"}}function ze(e,t,r){function n(e,t,r,n){t<0&&(t=0),t=Math.round(t),n=Math.round(n),s.appendChild(Ui("div",null,"CodeMirror-selected","position: absolute; left: "+e+"px; top: "+t+"px; width: "+(null==r?c-e:r)+"px; height: "+(n-t)+"px"))}function i(t,r,i){function o(r,n){return ft(e,zo(t,r),"div",h,n)}var s,a,h=Zn(l,t),f=h.text.length;return eo(ii(h),r||0,null==i?f:i,function(e,t,l){var h,d,p,g=o(e,"left");if(e==t)h=g,d=p=g.left;else{if(h=o(t-1,"right"),"rtl"==l){var v=g;g=h,h=v}d=g.left,p=h.right}null==r&&0==e&&(d=u),h.top-g.top>3&&(n(d,g.top,null,g.bottom),d=u,g.bottom<h.top&&n(d,g.bottom,null,h.top)),null==i&&t==f&&(p=c),(!s||g.top<s.top||g.top==s.top&&g.left<s.left)&&(s=g),(!a||h.bottom>a.bottom||h.bottom==a.bottom&&h.right>a.right)&&(a=h),d<u+1&&(d=u),n(d,h.top,p-d,h.bottom)}),{start:s,end:a}}var o=e.display,l=e.doc,s=document.createDocumentFragment(),a=je(e.display),u=a.left,c=Math.max(o.sizerWidth,Ye(e)-o.sizer.offsetLeft)-a.right,h=t.from(),f=t.to();if(h.line==f.line)i(h.line,h.ch,f.ch);else{var d=Zn(l,h.line),p=Zn(l,f.line),g=yn(d)==yn(p),v=i(h.line,h.ch,g?d.text.length+1:null).end,m=i(f.line,g?0:null,f.ch).start;g&&(v.top<m.top-2?(n(v.right,v.top,null,v.bottom),n(u,m.top,m.left,m.bottom)):n(v.right,v.top,m.left-v.right,v.bottom)),v.bottom<m.top&&n(u,v.bottom,null,m.top)}r.appendChild(s)}function Fe(e){if(e.state.focused){var t=e.display;clearInterval(t.blinker);var r=!0;t.cursorDiv.style.visibility="",e.options.cursorBlinkRate>0?t.blinker=setInterval(function(){t.cursorDiv.style.visibility=(r=!r)?"":"hidden"},e.options.cursorBlinkRate):e.options.cursorBlinkRate<0&&(t.cursorDiv.style.visibility="hidden")}}function Re(e,t){e.doc.mode.startState&&e.doc.frontier<e.display.viewTo&&e.state.highlight.set(t,Fi(Be,e))}function Be(e){var t=e.doc;if(t.frontier<t.first&&(t.frontier=t.first),!(t.frontier>=e.display.viewTo)){var r=+new Date+e.options.workTime,n=sl(t.mode,Ue(e,t.frontier)),i=[];t.iter(t.frontier,Math.min(t.first+t.size,e.display.viewTo+500),function(o){if(t.frontier>=e.display.viewFrom){var l=o.styles,s=o.text.length>e.options.maxHighlightLength,a=Pn(e,o,s?sl(t.mode,n):n,!0);o.styles=a.styles;var u=o.styleClasses,c=a.classes;c?o.styleClasses=c:u&&(o.styleClasses=null);for(var h=!l||l.length!=o.styles.length||u!=c&&(!u||!c||u.bgClass!=c.bgClass||u.textClass!=c.textClass),f=0;!h&&f<l.length;++f)h=l[f]!=o.styles[f];h&&i.push(t.frontier),o.stateAfter=s?n:sl(t.mode,n)}else o.text.length<=e.options.maxHighlightLength&&In(e,o.text,n),o.stateAfter=t.frontier%5==0?sl(t.mode,n):null;if(++t.frontier,+new Date>r)return Re(e,e.options.workDelay),!0}),i.length&&Wt(e,function(){for(var t=0;t<i.length;t++)It(e,i[t],"text")})}}function Ge(e,t,r){for(var n,i,o=e.doc,l=r?-1:t-(e.doc.mode.innerMode?1e3:100),s=t;s>l;--s){if(s<=o.first)return o.first;var a=Zn(o,s-1);if(a.stateAfter&&(!r||s<=o.frontier))return s;var u=Rl(a.text,null,e.options.tabSize);(null==i||n>u)&&(i=s-1,n=u)}return i}function Ue(e,t,r){var n=e.doc,i=e.display;if(!n.mode.startState)return!0;var o=Ge(e,t,r),l=o>n.first&&Zn(n,o-1).stateAfter;return l=l?sl(n.mode,l):al(n.mode),n.iter(o,t,function(r){In(e,r.text,l);var s=o==t-1||o%5==0||o>=i.viewFrom&&o<i.viewTo;r.stateAfter=s?sl(n.mode,l):null,++o}),r&&(n.frontier=o),l}function Ve(e){return e.lineSpace.offsetTop}function Ke(e){return e.mover.offsetHeight-e.lineSpace.offsetHeight}function je(e){if(e.cachedPaddingH)return e.cachedPaddingH;var t=Ki(e.measure,Ui("pre","x")),r=window.getComputedStyle?window.getComputedStyle(t):t.currentStyle,n={left:parseInt(r.paddingLeft),right:parseInt(r.paddingRight)};return isNaN(n.left)||isNaN(n.right)||(e.cachedPaddingH=n),n}function Xe(e){return Pl-e.display.nativeBarWidth}function Ye(e){return e.display.scroller.clientWidth-Xe(e)-e.display.barWidth}function _e(e){return e.display.scroller.clientHeight-Xe(e)-e.display.barHeight}function $e(e,t,r){var n=e.options.lineWrapping,i=n&&Ye(e);if(!t.measure.heights||n&&t.measure.width!=i){var o=t.measure.heights=[];if(n){t.measure.width=i;for(var l=t.text.firstChild.getClientRects(),s=0;s<l.length-1;s++){var a=l[s],u=l[s+1];Math.abs(a.bottom-u.bottom)>2&&o.push((a.bottom+u.top)/2-r.top)}}o.push(r.bottom-r.top)}}function qe(e,t,r){if(e.line==t)return{map:e.measure.map,cache:e.measure.cache};for(var n=0;n<e.rest.length;n++)if(e.rest[n]==t)return{map:e.measure.maps[n],cache:e.measure.caches[n]};for(var n=0;n<e.rest.length;n++)if(ti(e.rest[n])>r)return{map:e.measure.maps[n],cache:e.measure.caches[n],before:!0}}function Ze(e,t){t=yn(t);var r=ti(t),n=e.display.externalMeasured=new Ht(e.doc,t,r);n.lineN=r;var i=n.built=Fn(e,n);return n.text=i.pre,Ki(e.display.lineMeasure,i.pre),n}function Qe(e,t,r,n){return tt(e,et(e,t),r,n)}function Je(e,t){if(t>=e.display.viewFrom&&t<e.display.viewTo)return e.display.view[Ft(e,t)];var r=e.display.externalMeasured;return r&&t>=r.lineN&&t<r.lineN+r.size?r:void 0}function et(e,t){var r=ti(t),n=Je(e,r);n&&!n.text?n=null:n&&n.changes&&(E(e,n,r,H(e)),e.curOp.forceUpdate=!0),n||(n=Ze(e,t));var i=qe(n,t,r);return{line:t,view:n,rect:null,map:i.map,cache:i.cache,before:i.before,hasHeights:!1}}function tt(e,t,r,n,i){t.before&&(r=-1);var o,l=r+(n||"");return t.cache.hasOwnProperty(l)?o=t.cache[l]:(t.rect||(t.rect=t.view.text.getBoundingClientRect()),t.hasHeights||($e(e,t.view,t.rect),t.hasHeights=!0),o=nt(e,t,r,n),o.bogus||(t.cache[l]=o)),{left:o.left,right:o.right,top:i?o.rtop:o.top,bottom:i?o.rbottom:o.bottom}}function rt(e,t,r){for(var n,i,o,l,s=0;s<e.length;s+=3){var a=e[s],u=e[s+1];if(t<a?(i=0,o=1,l="left"):t<u?(i=t-a,o=i+1):(s==e.length-3||t==u&&e[s+3]>t)&&(o=u-a,i=o-1,t>=u&&(l="right")),null!=i){if(n=e[s+2],a==u&&r==(n.insertLeft?"left":"right")&&(l=r),"left"==r&&0==i)for(;s&&e[s-2]==e[s-3]&&e[s-1].insertLeft;)n=e[(s-=3)+2],l="left";if("right"==r&&i==u-a)for(;s<e.length-3&&e[s+3]==e[s+4]&&!e[s+5].insertLeft;)n=e[(s+=3)+2],