From a61018ed1a0e533aaab7aa698a2e89c754f67d5d Mon Sep 17 00:00:00 2001 From: Mikhail Korepanov Date: Tue, 28 Apr 2015 13:40:00 +0300 Subject: [PATCH] Update "stylus.min.js" with 0.51.1 --- try/stylus.min.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/try/stylus.min.js b/try/stylus.min.js index 0b7b92f..7e5335a 100644 --- a/try/stylus.min.js +++ b/try/stylus.min.js @@ -1,6 +1,6 @@ if(Function.prototype.name===undefined&&Object.defineProperty!==undefined){Object.defineProperty(Function.prototype,"name",{get:function(){var regex=/function\s([^(]{1,})\(/,match=regex.exec(this.toString());return match&&match.length>1?match[1].trim():""}})}if(String.prototype.trimRight===undefined){String.prototype.trimRight=function(){return String(this).replace(/\s+$/,"")}}var stylus=function(){function require(p){var path=require.resolve(p),mod=require.modules[path];if(!mod)throw new Error('failed to require "'+p+'"');if(!mod.exports){mod.exports={};mod.call(mod.exports,mod,mod.exports,require.relative(path))}return mod.exports}var bifs="called-from = ()\n\nvendors = moz webkit o ms official\n\n// stringify the given arg\n\n-string(arg)\n type(arg) + ' ' + arg\n\n// require a color\n\nrequire-color(color)\n unless color is a 'color'\n error('RGB or HSL value expected, got a ' + -string(color))\n\n// require a unit\n\nrequire-unit(n)\n unless n is a 'unit'\n error('unit expected, got a ' + -string(n))\n\n// require a string\n\nrequire-string(str)\n unless str is a 'string' or str is a 'ident'\n error('string expected, got a ' + -string(str))\n\n// Math functions\n\nabs(n) { math(n, 'abs') }\nmin(a, b) { a < b ? a : b }\nmax(a, b) { a > b ? a : b }\n\n// Trigonometrics\nPI = -math-prop('PI')\n\nradians-to-degrees(angle)\n angle * (180 / PI)\n\ndegrees-to-radians(angle)\n unit(angle * (PI / 180),'')\n\nsin(n)\n n = degrees-to-radians(n) if unit(n) == 'deg'\n round(math(n, 'sin'), 9)\n\ncos(n)\n n = degrees-to-radians(n) if unit(n) == 'deg'\n round(math(n, 'cos'), 9)\n\n// Rounding Math functions\n\nceil(n, precision = 0)\n multiplier = 10 ** precision\n math(n * multiplier, 'ceil') / multiplier\n\nfloor(n, precision = 0)\n multiplier = 10 ** precision\n math(n * multiplier, 'floor') / multiplier\n\nround(n, precision = 0)\n multiplier = 10 ** precision\n math(n * multiplier, 'round') / multiplier\n\n// return the sum of the given numbers\n\nsum(nums)\n sum = 0\n sum += n for n in nums\n\n// return the average of the given numbers\n\navg(nums)\n sum(nums) / length(nums)\n\n// return a unitless number, or pass through\n\nremove-unit(n)\n if typeof(n) is 'unit'\n unit(n, '')\n else\n n\n\n// convert a percent to a decimal, or pass through\n\npercent-to-decimal(n)\n if unit(n) is '%'\n remove-unit(n) / 100\n else\n n\n\n// check if n is an odd number\n\nodd(n)\n 1 == n % 2\n\n// check if n is an even number\n\neven(n)\n 0 == n % 2\n\n// check if color is light\n\nlight(color)\n lightness(color) >= 50%\n\n// check if color is dark\n\ndark(color)\n lightness(color) < 50%\n\n// desaturate color by amount\n\ndesaturate(color, amount)\n adjust(color, 'saturation', - amount)\n\n// saturate color by amount\n\nsaturate(color = '', amount = 100%)\n if color is a 'color'\n adjust(color, 'saturation', amount)\n else\n unquote( 'saturate(' + color + ')' )\n\n// darken by the given amount\n\ndarken(color, amount)\n adjust(color, 'lightness', - amount)\n\n// lighten by the given amount\n\nlighten(color, amount)\n adjust(color, 'lightness', amount)\n\n// decrease opacity by amount\n\nfade-out(color, amount)\n color - rgba(black, percent-to-decimal(amount))\n\n// increase opacity by amount\n\nfade-in(color, amount)\n color + rgba(black, percent-to-decimal(amount))\n\n// spin hue by a given amount\n\nspin(color, amount)\n color + unit(amount, deg)\n\n// mix two colors by a given amount\n\nmix(color1, color2, weight = 50%)\n unless weight in 0..100\n error('Weight must be between 0% and 100%')\n\n if length(color1) == 2\n weight = color1[0]\n color1 = color1[1]\n\n else if length(color2) == 2\n weight = 100 - color2[0]\n color2 = color2[1]\n\n require-color(color1)\n require-color(color2)\n\n p = unit(weight / 100, '')\n w = p * 2 - 1\n\n a = alpha(color1) - alpha(color2)\n\n w1 = (((w * a == -1) ? w : (w + a) / (1 + w * a)) + 1) / 2\n w2 = 1 - w1\n\n channels = (red(color1) red(color2)) (green(color1) green(color2)) (blue(color1) blue(color2))\n rgb = ()\n\n for pair in channels\n push(rgb, floor(pair[0] * w1 + pair[1] * w2))\n\n a1 = alpha(color1) * p\n a2 = alpha(color2) * (1 - p)\n alpha = a1 + a2\n\n rgba(rgb[0], rgb[1], rgb[2], alpha)\n\n// invert colors, leave alpha intact\n\ninvert(color = '')\n if color is a 'color'\n rgba(#fff - color, alpha(color))\n else\n unquote( 'invert(' + color + ')' )\n\n// give complement of the given color\n\ncomplement( color )\n spin( color, 180 )\n\n// give grayscale of the given color\n\ngrayscale( color = '' )\n if color is a 'color'\n desaturate( color, 100% )\n else\n unquote( 'grayscale(' + color + ')' )\n\n// mix the given color with white\n\ntint( color, percent )\n mix( white, color, percent )\n\n// mix the given color with black\n\nshade( color, percent )\n mix( black, color, percent )\n\n// return the last value in the given expr\n\nlast(expr)\n expr[length(expr) - 1]\n\n// return keys in the given pairs or object\n\nkeys(pairs)\n ret = ()\n if type(pairs) == 'object'\n for key in pairs\n push(ret, key)\n else\n for pair in pairs\n push(ret, pair[0]);\n ret\n\n// return values in the given pairs or object\n\nvalues(pairs)\n ret = ()\n if type(pairs) == 'object'\n for key, val in pairs\n push(ret, val)\n else\n for pair in pairs\n push(ret, pair[1]);\n ret\n\n// join values with the given delimiter\n\njoin(delim, vals...)\n buf = ''\n vals = vals[0] if length(vals) == 1\n for val, i in vals\n buf += i ? delim + val : val\n\n// add a CSS rule to the containing block\n\n// - This definition allows add-property to be used as a mixin\n// - It has the same effect as interpolation but allows users\n// to opt for a functional style\n\nadd-property-function = add-property\nadd-property(name, expr)\n if mixin\n {name} expr\n else\n add-property-function(name, expr)\n\nprefix-classes(prefix)\n -prefix-classes(prefix, block)\n\n// Caching mixin, use inside your functions to enable caching by extending.\n\n$stylus_mixin_cache = {}\ncache()\n $key = (current-media() or 'no-media') + '__' + called-from[0] + '__' + arguments\n if $key in $stylus_mixin_cache\n @extend {'$cache_placeholder_for_' + $stylus_mixin_cache[$key]}\n else if 'cache' in called-from\n {block}\n else\n $id = length($stylus_mixin_cache)\n\n &,\n /$cache_placeholder_for_{$id}\n $stylus_mixin_cache[$key] = $id\n {block}\n";require.modules={};require.resolve=function(path){var orig=path,reg=path+".js",index=path+"/index.js";return require.modules[reg]&®||require.modules[index]&&index||orig};require.register=function(path,fn){require.modules[path]=fn};require.relative=function(parent){return function(p){if("."!=p[0])return require(p);var path=parent.split("/"),segs=p.split("/");path.pop();for(var i=0;i=0;i--){var last=parts[i];if(last=="."){parts.splice(i,1)}else if(last===".."){parts.splice(i,1);up++}else if(up){parts.splice(i,1);up--}}if(allowAboveRoot){for(;up--;up){parts.unshift("..")}}return parts}var splitPathRe=/^([\s\S]+\/(?!$)|\/)?((?:[\s\S]+?)?(\.[^.]*)?)$/;exports.normalize=function(path){var isAbsolute=path.charAt(0)==="/",trailingSlash=path.slice(-1)==="/";path=normalizeArray(path.split("/").filter(function(p){return!!p}),!isAbsolute).join("/");if(!path&&!isAbsolute){path="."}if(path&&trailingSlash){path+="/"}return(isAbsolute?"/":"")+path};exports.join=function(){var paths=Array.prototype.slice.call(arguments,0);return exports.normalize(paths.filter(function(p,index){return p&&typeof p==="string"}).join("/"))};exports.relative=function(from,to){from=exports.resolve(from).substr(1);to=exports.resolve(to).substr(1);function trim(arr){var start=0;for(;start=0;end--){if(arr[end]!=="")break}if(start>end)return[];return arr.slice(start,end-start+1)}var fromParts=trim(from.split("/"));var toParts=trim(to.split("/"));var length=Math.min(fromParts.length,toParts.length);var samePartsLength=length;for(var i=0;ichannel?channel/12.92:Math.pow((channel+.055)/1.055,2.4)}return new nodes.Unit(.2126*processChannel(color.r)+.7152*processChannel(color.g)+.0722*processChannel(color.b))};exports.contrast=function contrast(top,bottom){if("rgba"!=top.nodeName&&"hsla"!=top.nodeName){return new nodes.Literal("contrast("+(top.isNull?"":top.toString())+")")}var result=new nodes.Object;top=top.rgba;bottom=bottom||new nodes.RGBA(255,255,255,1);utils.assertColor(bottom);bottom=bottom.rgba;function contrast(top,bottom){if(1>top.a){top=exports.blend(top,bottom)}var l1=exports.luminosity(bottom).val+.05,l2=exports.luminosity(top).val+.05,ratio=l1/l2;if(l2>l1){ratio=1/ratio}return Math.round(ratio*10)/10}if(1<=bottom.a){var resultRatio=new nodes.Unit(contrast(top,bottom));result.set("ratio",resultRatio);result.set("error",new nodes.Unit(0));result.set("min",resultRatio);result.set("max",resultRatio)}else{var onBlack=contrast(top,exports.blend(bottom,new nodes.RGBA(0,0,0,1))),onWhite=contrast(top,exports.blend(bottom,new nodes.RGBA(255,255,255,1))),max=Math.max(onBlack,onWhite);function processChannel(topChannel,bottomChannel){return Math.min(Math.max(0,(topChannel-bottomChannel*bottom.a)/(1-bottom.a)),255)}var closest=new nodes.RGBA(processChannel(top.r,bottom.r),processChannel(top.g,bottom.g),processChannel(top.b,bottom.b),1);var min=contrast(top,exports.blend(bottom,closest));result.set("ratio",new nodes.Unit(Math.round((min+max)*50)/100));result.set("error",new nodes.Unit(Math.round((max-min)*50)/100));result.set("min",new nodes.Unit(min));result.set("max",new nodes.Unit(max))}return result};exports.transparentify=function transparentify(top,bottom,alpha){utils.assertColor(top);top=top.rgba;bottom=bottom||new nodes.RGBA(255,255,255,1);if(!alpha&&bottom&&!bottom.rgba){alpha=bottom;bottom=new nodes.RGBA(255,255,255,1)}utils.assertColor(bottom);bottom=bottom.rgba;var bestAlpha=["r","g","b"].map(function(channel){return(top[channel]-bottom[channel])/((00?(100-hsl[prop])*val/100:hsl[prop]*(val/100)}hsl[prop]+=val;return hsl.rgba};(exports.clone=function clone(expr){utils.assertPresent(expr,"expr");return expr.clone()}).raw=true;(exports["add-property"]=function addProperty(name,expr){utils.assertType(name,"expression","name");name=utils.unwrap(name).first;utils.assertString(name,"name");utils.assertType(expr,"expression","expr");var prop=new nodes.Property([name],expr);var block=this.closestBlock;var len=block.nodes.length,head=block.nodes.slice(0,block.index),tail=block.nodes.slice(block.index++,len);head.push(prop);block.nodes=head.concat(tail);return prop}).raw=true;(exports.merge=exports.extend=function merge(dest){utils.assertPresent(dest,"dest");dest=utils.unwrap(dest).first;utils.assertType(dest,"object","dest");var last=utils.unwrap(arguments[arguments.length-1]).first,deep=true===last.val;for(var i=1,len=arguments.length-deep;i=this.length||255!=buf[offset])break;if(192==buf[offset+1]||194==buf[offset+1]){height=buf[offset+5]<<8|buf[offset+6];width=buf[offset+7]<<8|buf[offset+8]}else{offset+=2;blockSize=buf[offset]<<8|buf[offset+1]}}break;case"png":buf=new Buffer(8);fs.readSync(this.fd,buf,0,8,16);width=uint32(buf);height=uint32(buf.slice(4,8));break;case"gif":buf=new Buffer(4);fs.readSync(this.fd,buf,0,4,6);width=uint16(buf);height=uint16(buf.slice(2,4));break;case"svg":offset=Math.min(this.length,1024);buf=new Buffer(offset);fs.readSync(this.fd,buf,0,offset,0);buf=buf.toString("utf8");parser=sax.parser(true);parser.onopentag=function(node){if("svg"==node.name&&node.attributes.width&&node.attributes.height){width=parseInt(node.attributes.width,10);height=parseInt(node.attributes.height,10)}};parser.write(buf).close();break}if("number"!=typeof width)throw new Error('failed to find width of "'+this.path+'"');if("number"!=typeof height)throw new Error('failed to find height of "'+this.path+'"');return[width,height]}});require.register("functions/url.js",function(module,exports,require){var Compiler=require("../visitor/compiler"),events=require("../renderer").events,nodes=require("../nodes"),extname=require("../path").extname,utils=require("../utils");var defaultMimes={".gif":"image/gif",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".svg":"image/svg+xml",".webp":"image/webp",".ttf":"application/x-font-ttf",".eot":"application/vnd.ms-fontobject",".woff":"application/font-woff",".woff2":"application/font-woff2"};module.exports=function(options){options=options||{};var _paths=options.paths||[];var sizeLimit=null!=options.limit?options.limit:3e4;var mimes=options.mimes||defaultMimes;function fn(url){var compiler=new Compiler(url);compiler.isURL=true;url=url.nodes.map(function(node){return compiler.visit(node)}).join("");url=parse(url);var ext=extname(url.pathname),mime=mimes[ext],hash=url.hash||"",literal=new nodes.Literal('url("'+url.href+'")'),paths=_paths.concat(this.paths),buf;if(!mime)return literal;if(url.protocol)return literal;var found=utils.lookup(url.pathname,paths);if(!found){events.emit("file not found","File "+literal+" could not be found, literal url retained!");return literal}buf=fs.readFileSync(found);if(false!==sizeLimit&&buf.length>sizeLimit)return literal;return new nodes.Literal('url("data:'+mime+";base64,"+buf.toString("base64")+hash+'")')}fn.raw=true;return fn};module.exports.mimes=defaultMimes});require.register("lexer.js",function(module,exports,require){var Token=require("./token"),nodes=require("./nodes"),errors=require("./errors"),units=require("./units");exports=module.exports=Lexer;var alias={and:"&&",or:"||",is:"==",isnt:"!=","is not":"!=",":=":"?="};units=units.join("|");var unit=new RegExp("^(-)?(\\d+\\.\\d+|\\d+|\\.\\d+)("+units+")?[ \\t]*");function Lexer(str,options){options=options||{};this.stash=[];this.indentStack=[];this.indentRe=null;this.lineno=1;this.column=1;function comment(str,val,offset,s){var inComment=s.lastIndexOf("/*",offset)>s.lastIndexOf("*/",offset),commentIdx=s.lastIndexOf("//",offset),i=s.lastIndexOf("\n",offset),double=0,single=0;if(~commentIdx&&commentIdx>i){while(i!=offset){if("'"==s[i])single?single--:single++;if('"'==s[i])double?double--:double++;if("/"==s[i]&&"/"==s[i+1]){inComment=!single&&!double;break}++i}}return inComment?str:val+"\r"}if(""==str.charAt(0))str=str.slice(1);this.str=str.replace(/\s+$/,"\n").replace(/\r\n?/g,"\n").replace(/\\ *\n/g,"\r").replace(/([,(:](?!\/\/[^ ])) *(?:\/\/[^\n]*)?\n\s*/g,comment).replace(/\s*\n[ \t]*([,)])/g,comment)}Lexer.prototype={inspect:function(){var tok,tmp=this.str,buf=[];while("eos"!=(tok=this.next()).type){buf.push(tok.inspect())}this.str=tmp;return buf.concat(tok.inspect()).join("\n")},lookahead:function(n){var fetch=n-this.stash.length;while(fetch-->0)this.stash.push(this.advance());return this.stash[--n]},skip:function(len){var chunk=len[0];len=chunk?chunk.length:len;this.str=this.str.substr(len);if(chunk){this.move(chunk)}else{this.column+=len}},move:function(str){var lines=str.match(/\n/g),idx=str.lastIndexOf("\n");if(lines)this.lineno+=lines.length;this.column=~idx?str.length-idx:this.column+str.length},next:function(){var tok=this.stashed()||this.advance();this.prev=tok;return tok},isPartOfSelector:function(){var tok=this.stash[this.stash.length-1]||this.prev;switch(tok&&tok.type){case"color":return 2==tok.val.raw.length;case".":case"[":return true}return false},advance:function(){var column=this.column,line=this.lineno,tok=this.eos()||this.nil()||this.sep()||this.keyword()||this.urlchars()||this.comment()||this.newline()||this.escaped()||this.important()||this.literal()||this.fun()||this.anonFunc()||this.atrule()||this.brace()||this.paren()||this.color()||this.string()||this.unit()||this.namedop()||this.boolean()||this.unicode()||this.ident()||this.op()||this.eol()||this.space()||this.selector();tok.lineno=line;tok.column=column;return tok},peek:function(){return this.lookahead(1)},stashed:function(){return this.stash.shift()},eos:function(){if(this.str.length)return;if(this.indentStack.length){this.indentStack.shift();return new Token("outdent")}else{return new Token("eos")}},urlchars:function(){var captures;if(!this.isURL)return;if(captures=/^[\/:@.;?&=*!,<>#%0-9]+/.exec(this.str)){this.skip(captures);return new Token("literal",new nodes.Literal(captures[0]))}},sep:function(){var captures;if(captures=/^;[ \t]*/.exec(this.str)){this.skip(captures);return new Token(";")}},eol:function(){if("\r"==this.str[0]){++this.lineno;this.skip(1);return this.advance()}},space:function(){var captures;if(captures=/^([ \t]+)/.exec(this.str)){this.skip(captures);return new Token("space")}},escaped:function(){var captures;if(captures=/^\\(.)[ \t]*/.exec(this.str)){var c=captures[1];this.skip(captures);return new Token("ident",new nodes.Literal(c))}},literal:function(){var captures;if(captures=/^@css[ \t]*\{/.exec(this.str)){this.skip(captures);var c,braces=1,css="",node;while(c=this.str[0]){this.str=this.str.substr(1);switch(c){case"{":++braces;break;case"}":--braces;break;case"\n":++this.lineno;break}css+=c;if(!braces)break}css=css.replace(/\s*}$/,"");node=new nodes.Literal(css);node.css=true;return new Token("literal",node)}},important:function(){var captures;if(captures=/^!important[ \t]*/.exec(this.str)){this.skip(captures);return new Token("ident",new nodes.Literal("!important"))}},brace:function(){var captures;if(captures=/^([{}])/.exec(this.str)){this.skip(1);var brace=captures[1];return new Token(brace,brace)}},paren:function(){var captures;if(captures=/^([()])([ \t]*)/.exec(this.str)){var paren=captures[1];this.skip(captures);if(")"==paren)this.isURL=false;var tok=new Token(paren,paren);tok.space=captures[2];return tok}},nil:function(){var captures,tok;if(captures=/^(null)\b[ \t]*/.exec(this.str)){this.skip(captures);if(this.isPartOfSelector()){tok=new Token("ident",new nodes.Ident(captures[0]))}else{tok=new Token("null",nodes.nil)}return tok}},keyword:function(){var captures,tok;if(captures=/^(return|if|else|unless|for|in)\b[ \t]*/.exec(this.str)){var keyword=captures[1];this.skip(captures);if(this.isPartOfSelector()){tok=new Token("ident",new nodes.Ident(captures[0]))}else{tok=new Token(keyword,keyword)}return tok}},namedop:function(){var captures,tok;if(captures=/^(not|and|or|is a|is defined|isnt|is not|is)(?!-)\b([ \t]*)/.exec(this.str)){var op=captures[1];this.skip(captures);if(this.isPartOfSelector()){tok=new Token("ident",new nodes.Ident(captures[0]))}else{op=alias[op]||op;tok=new Token(op,op)}tok.space=captures[2];return tok}},op:function(){var captures;if(captures=/^([.]{1,3}|&&|\|\||[!<>=?:]=|\*\*|[-+*\/%]=?|[,=?:!~<>&\[\]])([ \t]*)/.exec(this.str)){var op=captures[1];this.skip(captures);op=alias[op]||op;var tok=new Token(op,op);tok.space=captures[2];this.isURL=false;return tok}},anonFunc:function(){var tok;if("@"==this.str[0]&&"("==this.str[1]){this.skip(2);tok=new Token("function",new nodes.Ident("anonymous"));tok.anonymous=true;return tok}},atrule:function(){var captures;if(captures=/^@(?:-(\w+)-)?([a-zA-Z0-9-_]+)[ \t]*/.exec(this.str)){this.skip(captures);var vendor=captures[1],type=captures[2],tok;switch(type){case"require":case"import":case"charset":case"namespace":case"media":case"scope":case"supports":return new Token(type);case"document":return new Token("-moz-document");case"block":return new Token("atblock");case"extend":case"extends":return new Token("extend");case"keyframes":return new Token(type,vendor);default:return new Token("atrule",vendor?"-"+vendor+"-"+type:type)}}},comment:function(){if("/"==this.str[0]&&"/"==this.str[1]){var end=this.str.indexOf("\n");if(-1==end)end=this.str.length;this.skip(end);return this.advance()}if("/"==this.str[0]&&"*"==this.str[1]){var end=this.str.indexOf("*/");if(-1==end)end=this.str.length;var str=this.str.substr(0,end+2),lines=str.split("\n").length-1,suppress=true,inline=false;this.lineno+=lines;this.skip(end+2);if("!"==str[2]){str=str.replace("*!","*");suppress=false}if(this.prev&&";"==this.prev.type)inline=true;return new Token("comment",new nodes.Comment(str,suppress,inline))}},"boolean":function(){var captures;if(captures=/^(true|false)\b([ \t]*)/.exec(this.str)){var val=nodes.Boolean("true"==captures[1]);this.skip(captures);var tok=new Token("boolean",val);tok.space=captures[2];return tok}},unicode:function(){var captures;if(captures=/^u\+[0-9a-f?]{1,6}(?:-[0-9a-f]{1,6})?/i.exec(this.str)){this.skip(captures);return new Token("literal",new nodes.Literal(captures[0]))}},fun:function(){var captures;if(captures=/^(-*[_a-zA-Z$][-\w\d$]*)\(([ \t]*)/.exec(this.str)){var name=captures[1];this.skip(captures);this.isURL="url"==name;var tok=new Token("function",new nodes.Ident(name));tok.space=captures[2];return tok}},ident:function(){var captures;if(captures=/^-*[_a-zA-Z$][-\w\d$]*/.exec(this.str)){this.skip(captures);return new Token("ident",new nodes.Ident(captures[0]))}},newline:function(){var captures,re;if(this.indentRe){captures=this.indentRe.exec(this.str)}else{re=/^\n([\t]*)[ \t]*/;captures=re.exec(this.str);if(captures&&!captures[1].length){re=/^\n([ \t]*)/;captures=re.exec(this.str)}if(captures&&captures[1].length)this.indentRe=re}if(captures){var tok,indents=captures[1].length;this.skip(captures);if(this.str[0]===" "||this.str[0]===" "){throw new errors.SyntaxError("Invalid indentation. You can use tabs or spaces to indent, but not both.")}if("\n"==this.str[0])return this.advance();if(this.indentStack.length&&indentsindents){this.stash.push(new Token("outdent"));this.indentStack.shift()}tok=this.stash.pop()}else if(indents&&indents!=this.indentStack[0]){this.indentStack.unshift(indents);tok=new Token("indent")}else{tok=new Token("newline")}return tok}},unit:function(){var captures;if(captures=unit.exec(this.str)){this.skip(captures);var n=parseFloat(captures[2]);if("-"==captures[1])n=-n;var node=new nodes.Unit(n,captures[3]);node.raw=captures[0];return new Token("unit",node)}},string:function(){var captures;if(captures=/^("[^"]*"|'[^']*')[ \t]*/.exec(this.str)){var str=captures[1],quote=captures[0][0];this.skip(captures);str=str.slice(1,-1).replace(/\\n/g,"\n");return new Token("string",new nodes.String(str,quote))}},color:function(){return this.rrggbbaa()||this.rrggbb()||this.rgba()||this.rgb()||this.nn()||this.n()},n:function(){var captures;if(captures=/^#([a-fA-F0-9]{1})[ \t]*/.exec(this.str)){this.skip(captures);var n=parseInt(captures[1]+captures[1],16),color=new nodes.RGBA(n,n,n,1);color.raw=captures[0];return new Token("color",color)}},nn:function(){var captures;if(captures=/^#([a-fA-F0-9]{2})[ \t]*/.exec(this.str)){this.skip(captures);var n=parseInt(captures[1],16),color=new nodes.RGBA(n,n,n,1);color.raw=captures[0];return new Token("color",color)}},rgb:function(){var captures;if(captures=/^#([a-fA-F0-9]{3})[ \t]*/.exec(this.str)){this.skip(captures);var rgb=captures[1],r=parseInt(rgb[0]+rgb[0],16),g=parseInt(rgb[1]+rgb[1],16),b=parseInt(rgb[2]+rgb[2],16),color=new nodes.RGBA(r,g,b,1);color.raw=captures[0];return new Token("color",color)}},rgba:function(){var captures;if(captures=/^#([a-fA-F0-9]{4})[ \t]*/.exec(this.str)){this.skip(captures);var rgb=captures[1],r=parseInt(rgb[0]+rgb[0],16),g=parseInt(rgb[1]+rgb[1],16),b=parseInt(rgb[2]+rgb[2],16),a=parseInt(rgb[3]+rgb[3],16),color=new nodes.RGBA(r,g,b,a/255);color.raw=captures[0];return new Token("color",color)}},rrggbb:function(){var captures;if(captures=/^#([a-fA-F0-9]{6})[ \t]*/.exec(this.str)){this.skip(captures);var rgb=captures[1],r=parseInt(rgb.substr(0,2),16),g=parseInt(rgb.substr(2,2),16),b=parseInt(rgb.substr(4,2),16),color=new nodes.RGBA(r,g,b,1);color.raw=captures[0];return new Token("color",color)}},rrggbbaa:function(){var captures;if(captures=/^#([a-fA-F0-9]{8})[ \t]*/.exec(this.str)){this.skip(captures);var rgb=captures[1],r=parseInt(rgb.substr(0,2),16),g=parseInt(rgb.substr(2,2),16),b=parseInt(rgb.substr(4,2),16),a=parseInt(rgb.substr(6,2),16),color=new nodes.RGBA(r,g,b,a/255);color.raw=captures[0];return new Token("color",color)}},selector:function(){var captures;if(captures=/^.*?(?=\/\/(?![^\[]*\])|[,\n{])/.exec(this.str)){var selector=captures[0];this.skip(captures);return new Token("selector",selector)}}}});require.register("nodes/arguments.js",function(module,exports,require){var Node=require("./node"),nodes=require("../nodes"),utils=require("../utils");var Arguments=module.exports=function Arguments(){nodes.Expression.call(this);this.map={}};Arguments.prototype.__proto__=nodes.Expression.prototype;Arguments.fromExpression=function(expr){var args=new Arguments,len=expr.nodes.length;args.lineno=expr.lineno;args.column=expr.column;args.isList=expr.isList;for(var i=0;ilen)self.nodes[i]=nodes.nil;self.nodes[n]=val}else if(unit.string){node=self.nodes[0];if(node&&"object"==node.nodeName)node.set(unit.string,val.clone())}});return val;case"[]":var expr=new nodes.Expression,vals=utils.unwrap(this).nodes,range=utils.unwrap(right).nodes,node;range.forEach(function(unit){if("unit"==unit.nodeName){node=vals[unit.val<0?vals.length+unit.val:unit.val]}else if("object"==vals[0].nodeName){node=vals[0].get(unit.string)}if(node)expr.push(node)});return expr.isEmpty?nodes.nil:utils.unwrap(expr);case"||":return this.toBoolean().isTrue?this:right;case"in":return Node.prototype.operate.call(this,op,right);case"!=":return this.operate("==",right,val).negate();case"==":var len=this.nodes.length,right=right.toExpression(),a,b;if(len!=right.nodes.length)return nodes.no;for(var i=0;i1)return nodes.yes;return this.first.toBoolean()};Expression.prototype.toString=function(){return"("+this.nodes.map(function(node){return node.toString()}).join(this.isList?", ":" ")+")"};Expression.prototype.toJSON=function(){return{__type:"Expression",isList:this.isList,preserve:this.preserve,lineno:this.lineno,column:this.column,filename:this.filename,nodes:this.nodes}}});require.register("nodes/function.js",function(module,exports,require){var Node=require("./node");var Function=module.exports=function Function(name,params,body){Node.call(this);this.name=name;this.params=params;this.block=body;if("function"==typeof params)this.fn=params};Function.prototype.__defineGetter__("arity",function(){return this.params.length});Function.prototype.__proto__=Node.prototype;Function.prototype.__defineGetter__("hash",function(){return"function "+this.name});Function.prototype.clone=function(parent){if(this.fn){var clone=new Function(this.name,this.fn)}else{var clone=new Function(this.name);clone.params=this.params.clone(parent,clone);clone.block=this.block.clone(parent,clone)}clone.lineno=this.lineno;clone.column=this.column;clone.filename=this.filename;return clone};Function.prototype.toString=function(){if(this.fn){return this.name+"("+this.fn.toString().match(/^function *\w*\((.*?)\)/).slice(1).join(", ")+")"}else{return this.name+"("+this.params.nodes.join(", ")+")"}};Function.prototype.toJSON=function(){var json={__type:"Function",name:this.name,lineno:this.lineno,column:this.column,filename:this.filename};if(this.fn){json.fn=this.fn}else{json.params=this.params;json.block=this.block}return json}});require.register("nodes/group.js",function(module,exports,require){var Node=require("./node");var Group=module.exports=function Group(){Node.call(this);this.nodes=[];this.extends=[]};Group.prototype.__proto__=Node.prototype;Group.prototype.push=function(selector){this.nodes.push(selector)};Group.prototype.__defineGetter__("block",function(){return this.nodes[0].block});Group.prototype.__defineSetter__("block",function(block){for(var i=0,len=this.nodes.length;i=":case"<":case">":case"is a":case"||":case"&&":return this.rgba.operate(op,right);default:return this.rgba.operate(op,right).hsla}};exports.fromRGBA=function(rgba){var r=rgba.r/255,g=rgba.g/255,b=rgba.b/255,a=rgba.a;var min=Math.min(r,g,b),max=Math.max(r,g,b),l=(max+min)/2,d=max-min,h,s;switch(max){case min:h=0;break;case r:h=60*(g-b)/d;break;case g:h=60*(b-r)/d+120;break;case b:h=60*(r-g)/d+240;break}if(max==min){s=0}else if(l<.5){s=d/(2*l)}else{s=d/(2-2*l)}h%=360;s*=100;l*=100;return new HSLA(h,s,l,a)};HSLA.prototype.adjustLightness=function(percent){this.l=clampPercentage(this.l+this.l*(percent/100));return this};HSLA.prototype.adjustHue=function(deg){this.h=clampDegrees(this.h+deg);return this};function clampDegrees(n){n=n%360;return n>=0?n:360+n}function clampPercentage(n){return Math.max(0,Math.min(n,100))}function clampAlpha(n){return Math.max(0,Math.min(n,1))}});require.register("nodes/ident.js",function(module,exports,require){var Node=require("./node"),nodes=require("./index");var Ident=module.exports=function Ident(name,val,mixin){Node.call(this);this.name=name;this.string=name;this.val=val||nodes.nil;this.mixin=!!mixin};Ident.prototype.__defineGetter__("isEmpty",function(){return undefined==this.val});Ident.prototype.__defineGetter__("hash",function(){return this.name});Ident.prototype.__proto__=Node.prototype;Ident.prototype.clone=function(parent){var clone=new Ident(this.name);clone.val=this.val.clone(parent,clone);clone.mixin=this.mixin;clone.lineno=this.lineno;clone.column=this.column;clone.filename=this.filename;clone.property=this.property;clone.rest=this.rest;return clone};Ident.prototype.toJSON=function(){return{__type:"Ident",name:this.name,val:this.val,mixin:this.mixin,property:this.property,rest:this.rest,lineno:this.lineno,column:this.column,filename:this.filename}};Ident.prototype.toString=function(){return this.name};Ident.prototype.coerce=function(other){switch(other.nodeName){case"ident":case"string":case"literal":return new Ident(other.string);case"unit":return new Ident(other.toString());default:return Node.prototype.coerce.call(this,other)}};Ident.prototype.operate=function(op,right){var val=right.first;switch(op){case"-":if("unit"==val.nodeName){var expr=new nodes.Expression;val=val.clone();val.val=-val.val;expr.push(this);expr.push(val);return expr}case"+":return new nodes.Ident(this.string+this.coerce(val).string)}return Node.prototype.operate.call(this,op,right)}});require.register("nodes/if.js",function(module,exports,require){var Node=require("./node");var If=module.exports=function If(cond,negate){Node.call(this);this.cond=cond;this.elses=[];if(negate&&negate.nodeName){this.block=negate}else{this.negate=negate}};If.prototype.__proto__=Node.prototype;If.prototype.clone=function(parent){var clone=new If;clone.cond=this.cond.clone(parent,clone);clone.block=this.block.clone(parent,clone);clone.elses=this.elses.map(function(node){return node.clone(parent,clone) -});clone.negate=this.negate;clone.postfix=this.postfix;clone.lineno=this.lineno;clone.column=this.column;clone.filename=this.filename;return clone};If.prototype.toJSON=function(){return{__type:"If",cond:this.cond,block:this.block,elses:this.elses,negate:this.negate,postfix:this.postfix,lineno:this.lineno,column:this.column,filename:this.filename}}});require.register("nodes/import.js",function(module,exports,require){var Node=require("./node");var Import=module.exports=function Import(expr,once){Node.call(this);this.path=expr;this.once=once||false};Import.prototype.__proto__=Node.prototype;Import.prototype.clone=function(parent){var clone=new Import;clone.path=this.path.nodeName?this.path.clone(parent,clone):this.path;clone.once=this.once;clone.mtime=this.mtime;clone.lineno=this.lineno;clone.column=this.column;clone.filename=this.filename;return clone};Import.prototype.toJSON=function(){return{__type:"Import",path:this.path,once:this.once,mtime:this.mtime,lineno:this.lineno,column:this.column,filename:this.filename}}});require.register("nodes/extend.js",function(module,exports,require){var Node=require("./node");var Extend=module.exports=function Extend(selectors){Node.call(this);this.selectors=selectors};Extend.prototype.__proto__=Node.prototype;Extend.prototype.clone=function(){return new Extend(this.selectors)};Extend.prototype.toString=function(){return"@extend "+this.selectors.join(", ")};Extend.prototype.toJSON=function(){return{__type:"Extend",selectors:this.selectors,lineno:this.lineno,column:this.column,filename:this.filename}}});require.register("nodes/index.js",function(module,exports,require){exports.Node=require("./node");exports.Root=require("./root");exports.Null=require("./null");exports.Each=require("./each");exports.If=require("./if");exports.Call=require("./call");exports.UnaryOp=require("./unaryop");exports.BinOp=require("./binop");exports.Ternary=require("./ternary");exports.Block=require("./block");exports.Unit=require("./unit");exports.String=require("./string");exports.HSLA=require("./hsla");exports.RGBA=require("./rgba");exports.Ident=require("./ident");exports.Group=require("./group");exports.Literal=require("./literal");exports.Boolean=require("./boolean");exports.Return=require("./return");exports.Media=require("./media");exports.QueryList=require("./query-list");exports.Query=require("./query");exports.Feature=require("./feature");exports.Params=require("./params");exports.Comment=require("./comment");exports.Keyframes=require("./keyframes");exports.Member=require("./member");exports.Charset=require("./charset");exports.Namespace=require("./namespace");exports.Import=require("./import");exports.Extend=require("./extend");exports.Object=require("./object");exports.Function=require("./function");exports.Property=require("./property");exports.Selector=require("./selector");exports.Expression=require("./expression");exports.Arguments=require("./arguments");exports.Atblock=require("./atblock");exports.Atrule=require("./atrule");exports.Supports=require("./supports");exports.yes=new exports.Boolean(true);exports.no=new exports.Boolean(false);exports.nil=new exports.Null});require.register("nodes/keyframes.js",function(module,exports,require){var Atrule=require("./atrule");var Keyframes=module.exports=function Keyframes(segs,prefix){Atrule.call(this,"keyframes");this.segments=segs;this.prefix=prefix||"official"};Keyframes.prototype.__proto__=Atrule.prototype;Keyframes.prototype.clone=function(parent){var clone=new Keyframes;clone.lineno=this.lineno;clone.column=this.column;clone.filename=this.filename;clone.segments=this.segments.map(function(node){return node.clone(parent,clone)});clone.prefix=this.prefix;clone.block=this.block.clone(parent,clone);return clone};Keyframes.prototype.toJSON=function(){return{__type:"Keyframes",segments:this.segments,prefix:this.prefix,block:this.block,lineno:this.lineno,column:this.column,filename:this.filename}};Keyframes.prototype.toString=function(){return"@keyframes "+this.segments.join("")}});require.register("nodes/literal.js",function(module,exports,require){var Node=require("./node"),nodes=require("./index");var Literal=module.exports=function Literal(str){Node.call(this);this.val=str;this.string=str;this.prefixed=false};Literal.prototype.__proto__=Node.prototype;Literal.prototype.__defineGetter__("hash",function(){return this.val});Literal.prototype.toString=function(){return this.val};Literal.prototype.coerce=function(other){switch(other.nodeName){case"ident":case"string":case"literal":return new Literal(other.string);default:return Node.prototype.coerce.call(this,other)}};Literal.prototype.operate=function(op,right){var val=right.first;switch(op){case"+":return new nodes.Literal(this.string+this.coerce(val).string);default:return Node.prototype.operate.call(this,op,right)}};Literal.prototype.toJSON=function(){return{__type:"Literal",val:this.val,string:this.string,prefixed:this.prefixed,lineno:this.lineno,column:this.column,filename:this.filename}}});require.register("nodes/media.js",function(module,exports,require){var Atrule=require("./atrule");var Media=module.exports=function Media(val){Atrule.call(this,"media");this.val=val};Media.prototype.__proto__=Atrule.prototype;Media.prototype.clone=function(parent){var clone=new Media;clone.val=this.val.clone(parent,clone);clone.block=this.block.clone(parent,clone);clone.lineno=this.lineno;clone.column=this.column;clone.filename=this.filename;return clone};Media.prototype.toJSON=function(){return{__type:"Media",val:this.val,block:this.block,lineno:this.lineno,column:this.column,filename:this.filename}};Media.prototype.toString=function(){return"@media "+this.val}});require.register("nodes/query-list.js",function(module,exports,require){var Node=require("./node");var QueryList=module.exports=function QueryList(){Node.call(this);this.nodes=[]};QueryList.prototype.__proto__=Node.prototype;QueryList.prototype.clone=function(parent){var clone=new QueryList;clone.lineno=this.lineno;clone.column=this.column;clone.filename=this.filename;for(var i=0;i=":return nodes.Boolean(this.hash>=right.hash);case"<=":return nodes.Boolean(this.hash<=right.hash);case">":return nodes.Boolean(this.hash>right.hash);case"<":return nodes.Boolean(this.hash1)--h;if(h*6<1)return m1+(m2-m1)*h*6;if(h*2<1)return m2;if(h*3<2)return m1+(m2-m1)*(2/3-h)*6;return m1}return new RGBA(r,g,b,a)};function clamp(n){return Math.max(0,Math.min(n.toFixed(0),255))}function clampAlpha(n){return Math.max(0,Math.min(n,1))}});require.register("nodes/root.js",function(module,exports,require){var Node=require("./node");var Root=module.exports=function Root(){this.nodes=[]};Root.prototype.__proto__=Node.prototype;Root.prototype.push=function(node){this.nodes.push(node)};Root.prototype.unshift=function(node){this.nodes.unshift(node)};Root.prototype.clone=function(){var clone=new Root;clone.lineno=this.lineno;clone.column=this.column;clone.filename=this.filename;this.nodes.forEach(function(node){clone.push(node.clone(clone,clone))});return clone};Root.prototype.toString=function(){return"[Root]"};Root.prototype.toJSON=function(){return{__type:"Root",nodes:this.nodes,lineno:this.lineno,column:this.column,filename:this.filename}}});require.register("nodes/selector.js",function(module,exports,require){var Block=require("./block"),Node=require("./node");var Selector=module.exports=function Selector(segs){Node.call(this);this.inherits=true;this.segments=segs;this.optional=false};Selector.prototype.__proto__=Node.prototype;Selector.prototype.toString=function(){return this.segments.join("")+(this.optional?" !optional":"")};Selector.prototype.__defineGetter__("isPlaceholder",function(){return this.val&&~this.val.substr(0,2).indexOf("$")});Selector.prototype.clone=function(parent){var clone=new Selector;clone.lineno=this.lineno;clone.column=this.column;clone.filename=this.filename;clone.inherits=this.inherits;clone.val=this.val;clone.segments=this.segments.map(function(node){return node.clone(parent,clone)});clone.optional=this.optional;return clone};Selector.prototype.toJSON=function(){return{__type:"Selector",inherits:this.inherits,segments:this.segments,optional:this.optional,val:this.val,lineno:this.lineno,column:this.column,filename:this.filename}}});require.register("nodes/string.js",function(module,exports,require){var Node=require("./node"),sprintf=require("../functions").s,utils=require("../utils"),nodes=require("./index");var String=module.exports=function String(val,quote){Node.call(this);this.val=val;this.string=val;this.prefixed=false;if(typeof quote!=="string"){this.quote="'"}else{this.quote=quote}};String.prototype.__proto__=Node.prototype;String.prototype.toString=function(){return this.quote+this.val+this.quote};String.prototype.clone=function(){var clone=new String(this.val,this.quote);clone.lineno=this.lineno;clone.column=this.column;clone.filename=this.filename;return clone};String.prototype.toJSON=function(){return{__type:"String",val:this.val,quote:this.quote,lineno:this.lineno,column:this.column,filename:this.filename}};String.prototype.toBoolean=function(){return nodes.Boolean(this.val.length)};String.prototype.coerce=function(other){switch(other.nodeName){case"string":return other;case"expression":return new String(other.nodes.map(function(node){return this.coerce(node).val},this).join(" "));default:return new String(other.toString())}};String.prototype.operate=function(op,right){switch(op){case"%":var expr=new nodes.Expression;expr.push(this);var args="expression"==right.nodeName?utils.unwrap(right).nodes:[right];return sprintf.apply(null,[expr].concat(args));case"+":var expr=new nodes.Expression;expr.push(new String(this.val+this.coerce(right).val));return expr;default:return Node.prototype.operate.call(this,op,right)}}});require.register("nodes/ternary.js",function(module,exports,require){var Node=require("./node");var Ternary=module.exports=function Ternary(cond,trueExpr,falseExpr){Node.call(this);this.cond=cond;this.trueExpr=trueExpr;this.falseExpr=falseExpr};Ternary.prototype.__proto__=Node.prototype;Ternary.prototype.clone=function(parent){var clone=new Ternary;clone.cond=this.cond.clone(parent,clone);clone.trueExpr=this.trueExpr.clone(parent,clone);clone.falseExpr=this.falseExpr.clone(parent,clone);clone.lineno=this.lineno;clone.column=this.column;clone.filename=this.filename;return clone};Ternary.prototype.toJSON=function(){return{__type:"Ternary",cond:this.cond,trueExpr:this.trueExpr,falseExpr:this.falseExpr,lineno:this.lineno,column:this.column,filename:this.filename}}});require.register("nodes/unaryop.js",function(module,exports,require){var Node=require("./node");var UnaryOp=module.exports=function UnaryOp(op,expr){Node.call(this);this.op=op;this.expr=expr};UnaryOp.prototype.__proto__=Node.prototype;UnaryOp.prototype.clone=function(parent){var clone=new UnaryOp(this.op);clone.expr=this.expr.clone(parent,clone);clone.lineno=this.lineno;clone.column=this.column;clone.filename=this.filename;return clone};UnaryOp.prototype.toJSON=function(){return{__type:"UnaryOp",op:this.op,expr:this.expr,lineno:this.lineno,column:this.column,filename:this.filename}}});require.register("nodes/unit.js",function(module,exports,require){var Node=require("./node"),nodes=require("./index");var FACTOR_TABLE={mm:{val:1,label:"mm"},cm:{val:10,label:"mm"},"in":{val:25.4,label:"mm"},pt:{val:25.4/72,label:"mm"},ms:{val:1,label:"ms"},s:{val:1e3,label:"ms"},Hz:{val:1,label:"Hz"},kHz:{val:1e3,label:"Hz"}};var Unit=module.exports=function Unit(val,type){Node.call(this);this.val=val;this.type=type};Unit.prototype.__proto__=Node.prototype;Unit.prototype.toBoolean=function(){return nodes.Boolean(this.type?true:this.val)};Unit.prototype.toString=function(){return this.val+(this.type||"")};Unit.prototype.clone=function(){var clone=new Unit(this.val,this.type);clone.lineno=this.lineno;clone.column=this.column;clone.filename=this.filename;return clone};Unit.prototype.toJSON=function(){return{__type:"Unit",val:this.val,type:this.type,lineno:this.lineno,column:this.column,filename:this.filename}};Unit.prototype.operate=function(op,right){var type=this.type||right.first.type;if("rgba"==right.nodeName||"hsla"==right.nodeName){return right.operate(op,this)}if(this.shouldCoerce(op)){right=right.first;if("%"!=this.type&&("-"==op||"+"==op)&&"%"==right.type){right=new Unit(this.val*(right.val/100),"%")}else{right=this.coerce(right)}switch(op){case"-":return new Unit(this.val-right.val,type);case"+":type=type||right.type=="%"&&right.type;return new Unit(this.val+right.val,type);case"/":return new Unit(this.val/right.val,type);case"*":return new Unit(this.val*right.val,type);case"%":return new Unit(this.val%right.val,type);case"**":return new Unit(Math.pow(this.val,right.val),type);case"..":case"...":var start=this.val,end=right.val,expr=new nodes.Expression,inclusive=".."==op;if(start=end:--start>end)}return expr}}return Node.prototype.operate.call(this,op,right)};Unit.prototype.coerce=function(other){if("unit"==other.nodeName){var a=this,b=other,factorA=FACTOR_TABLE[a.type],factorB=FACTOR_TABLE[b.type];if(factorA&&factorB&&factorA.label==factorB.label){var bVal=b.val*(factorB.val/factorA.val);return new nodes.Unit(bVal,a.type)}else{return new nodes.Unit(b.val,a.type)}}else if("string"==other.nodeName){if("%"==other.val)return new nodes.Unit(0,"%");var val=parseFloat(other.val);if(isNaN(val))Node.prototype.coerce.call(this,other);return new nodes.Unit(val)}else{return Node.prototype.coerce.call(this,other)}}});require.register("nodes/object.js",function(module,exports,require){var Node=require("./node"),nodes=require("./index"),nativeObj={}.constructor;var Object=module.exports=function Object(){Node.call(this);this.vals={}};Object.prototype.__proto__=Node.prototype;Object.prototype.set=function(key,val){this.vals[key]=val;return this};Object.prototype.__defineGetter__("length",function(){return nativeObj.keys(this.vals).length});Object.prototype.get=function(key){return this.vals[key]||nodes.nil};Object.prototype.has=function(key){return key in this.vals};Object.prototype.operate=function(op,right){switch(op){case".":case"[]":return this.get(right.hash);case"==":var vals=this.vals,a,b;if("object"!=right.nodeName||this.length!=right.length)return nodes.no;for(var key in vals){a=vals[key];b=right.vals[key];if(a.operate(op,b).isFalse)return nodes.no}return nodes.yes;case"!=":return this.operate("==",right).negate();default:return Node.prototype.operate.call(this,op,right)}};Object.prototype.toBoolean=function(){return nodes.Boolean(this.length)};Object.prototype.toBlock=function(){var str="{",key,val;for(key in this.vals){val=this.get(key);if("object"==val.first.nodeName){str+=key+" "+this.toBlock.call(val.first)}else{switch(key){case"@charset":str+=key+" "+val.first.toString()+";";break;default:str+=key+":"+val.toString().replace(/ , /g,"\\,")+";"}}}str+="}";return str};Object.prototype.clone=function(parent){var clone=new Object;clone.lineno=this.lineno;clone.column=this.column;clone.filename=this.filename;for(var key in this.vals){clone.vals[key]=this.vals[key].clone(parent,clone)}return clone};Object.prototype.toJSON=function(){return{__type:"Object",vals:this.vals,lineno:this.lineno,column:this.column,filename:this.filename}};Object.prototype.toString=function(){var obj={};for(var prop in this.vals){obj[prop]=this.vals[prop].toString()}return JSON.stringify(obj)}});require.register("nodes/supports.js",function(module,exports,require){var Atrule=require("./atrule");var Supports=module.exports=function Supports(condition){Atrule.call(this,"supports");this.condition=condition};Supports.prototype.__proto__=Atrule.prototype;Supports.prototype.clone=function(parent){var clone=new Supports;clone.condition=this.condition.clone(parent,clone);clone.block=this.block.clone(parent,clone);clone.lineno=this.lineno;clone.column=this.column;clone.filename=this.filename;return clone};Supports.prototype.toJSON=function(){return{__type:"Supports",condition:this.condition,block:this.block,lineno:this.lineno,column:this.column,filename:this.filename}};Supports.prototype.toString=function(){return"@supports "+this.condition}});require.register("nodes/member.js",function(module,exports,require){var Node=require("./node");var Member=module.exports=function Member(left,right){Node.call(this);this.left=left;this.right=right};Member.prototype.__proto__=Node.prototype;Member.prototype.clone=function(parent){var clone=new Member;clone.left=this.left.clone(parent,clone);clone.right=this.right.clone(parent,clone);if(this.val)clone.val=this.val.clone(parent,clone);clone.lineno=this.lineno;clone.column=this.column;clone.filename=this.filename;return clone};Member.prototype.toJSON=function(){var json={__type:"Member",left:this.left,right:this.right,lineno:this.lineno,column:this.column,filename:this.filename};if(this.val)json.val=this.val;return json};Member.prototype.toString=function(){return this.left.toString()+"."+this.right.toString()}});require.register("nodes/atblock.js",function(module,exports,require){var Node=require("./node");var Atblock=module.exports=function Atblock(){Node.call(this)};Atblock.prototype.__defineGetter__("nodes",function(){return this.block.nodes});Atblock.prototype.__proto__=Node.prototype;Atblock.prototype.clone=function(parent){var clone=new Atblock;clone.block=this.block.clone(parent,clone);clone.lineno=this.lineno;clone.column=this.column;clone.filename=this.filename;return clone};Atblock.prototype.toString=function(){return"@block"};Atblock.prototype.toJSON=function(){return{__type:"Atblock",block:this.block,lineno:this.lineno,column:this.column,fileno:this.fileno}}});require.register("nodes/atrule.js",function(module,exports,require){var Node=require("./node");var Atrule=module.exports=function Atrule(type){Node.call(this);this.type=type};Atrule.prototype.__proto__=Node.prototype;Atrule.prototype.__defineGetter__("hasOnlyProperties",function(){if(!this.block)return false;var nodes=this.block.nodes;for(var i=0,len=nodes.length;i","=",":","&","~","{","}",".","/"];var pseudoSelectors=["matches","not","dir","lang","any-link","link","visited","local-link","target","scope","hover","active","focus","drop","current","past","future","enabled","disabled","read-only","read-write","placeholder-shown","checked","indeterminate","valid","invalid","in-range","out-of-range","required","optional","user-error","root","empty","blank","nth-child","nth-last-child","first-child","last-child","only-child","nth-of-type","nth-last-of-type","first-of-type","last-of-type","only-of-type","nth-match","nth-last-match","nth-column","nth-last-column","first-line","first-letter","before","after","selection"];var Parser=module.exports=function Parser(str,options){var self=this; -options=options||{};this.lexer=new Lexer(str,options);this.prefix=options.prefix||"";this.root=options.root||new nodes.Root;this.state=["root"];this.stash=[];this.parens=0;this.css=0;this.state.pop=function(){self.prevState=[].pop.call(this)}};Parser.prototype={constructor:Parser,currentState:function(){return this.state[this.state.length-1]},previousState:function(){return this.state[this.state.length-2]},parse:function(){var block=this.parent=this.root;while("eos"!=this.peek().type){this.skipWhitespace();if("eos"==this.peek().type)break;var stmt=this.statement();this.accept(";");if(!stmt)this.error("unexpected token {peek}, not allowed at the root level");block.push(stmt)}return block},error:function(msg){var type=this.peek().type,val=undefined==this.peek().val?"":" "+this.peek().toString();if(val.trim()==type.trim())val="";throw new errors.ParseError(msg.replace("{peek}",'"'+type+val+'"'))},accept:function(type){if(type==this.peek().type){return this.next()}},expect:function(type){if(type!=this.peek().type){this.error('expected "'+type+'", got {peek}')}return this.next()},next:function(){var tok=this.stash.length?this.stash.pop():this.lexer.next(),line=tok.lineno,column=tok.column||1;if(tok.val&&tok.val.nodeName){tok.val.lineno=line;tok.val.column=column}nodes.lineno=line;nodes.column=column;return tok},peek:function(){return this.lexer.peek()},lookahead:function(n){return this.lexer.lookahead(n)},isSelectorToken:function(n){var la=this.lookahead(n).type;switch(la){case"for":return this.bracketed;case"[":this.bracketed=true;return true;case"]":this.bracketed=false;return true;default:return~selectorTokens.indexOf(la)}},isPseudoSelector:function(n){var val=this.lookahead(n).val;return val&&~pseudoSelectors.indexOf(val.name)},lineContains:function(type){var i=1,la;while(la=this.lookahead(i++)){if(~["indent","outdent","newline","eos"].indexOf(la.type))return;if(type==la.type)return true}},selectorToken:function(){if(this.isSelectorToken(1)){if("{"==this.peek().type){if(!this.lineContains("}"))return;var i=0,la;while(la=this.lookahead(++i)){if("}"==la.type){if(i==2||i==3&&this.lookahead(i-1).type=="space")return;break}if(":"==la.type)return}}return this.next()}},skip:function(tokens){while(~tokens.indexOf(this.peek().type))this.next()},skipWhitespace:function(){this.skip(["space","indent","outdent","newline"])},skipNewlines:function(){while("newline"==this.peek().type)this.next()},skipSpaces:function(){while("space"==this.peek().type)this.next()},skipSpacesAndComments:function(){while("space"==this.peek().type||"comment"==this.peek().type)this.next()},looksLikeFunctionDefinition:function(i){return"indent"==this.lookahead(i).type||"{"==this.lookahead(i).type},looksLikeSelector:function(fromProperty){var i=1,brace;if(fromProperty&&":"==this.lookahead(i+1).type&&(this.lookahead(i+1).space||"indent"==this.lookahead(i+2).type))return false;while("ident"==this.lookahead(i).type&&"newline"==this.lookahead(i+1).type)i+=2;while(this.isSelectorToken(i)||","==this.lookahead(i).type){if("selector"==this.lookahead(i).type)return true;if("&"==this.lookahead(i+1).type)return true;if("."==this.lookahead(i).type&&"ident"==this.lookahead(i+1).type)return true;if("*"==this.lookahead(i).type&&"newline"==this.lookahead(i+1).type)return true;if(":"==this.lookahead(i).type&&":"==this.lookahead(i+1).type)return true;if(this.looksLikeAttributeSelector(i))return true;if(("="==this.lookahead(i).type||"function"==this.lookahead(i).type)&&"{"==this.lookahead(i+1).type)return false;if(":"==this.lookahead(i).type&&!this.isPseudoSelector(i+1)&&this.lineContains("."))return false;if("{"==this.lookahead(i).type)brace=true;else if("}"==this.lookahead(i).type)brace=false;if(brace&&":"==this.lookahead(i).type)return true;if("space"==this.lookahead(i).type&&"{"==this.lookahead(i+1).type)return true;if(":"==this.lookahead(i++).type&&!this.lookahead(i-1).space&&this.isPseudoSelector(i))return true;if(","==this.lookahead(i).type&&"newline"==this.lookahead(i+1).type)return true}if(","==this.lookahead(i).type&&"newline"==this.lookahead(i+1).type)return true;if("{"==this.lookahead(i).type&&"newline"==this.lookahead(i+1).type)return true;if(this.css){if(";"==this.lookahead(i).type||"}"==this.lookahead(i-1).type)return false}while(!~["indent","outdent","newline","for","if",";","}","eos"].indexOf(this.lookahead(i).type))++i;if("indent"==this.lookahead(i).type)return true},looksLikeAttributeSelector:function(n){var type=this.lookahead(n).type;if("="==type&&this.bracketed)return true;return("ident"==type||"string"==type)&&"]"==this.lookahead(n+1).type&&("newline"==this.lookahead(n+2).type||this.isSelectorToken(n+2))&&!this.lineContains(":")&&!this.lineContains("=")},looksLikeKeyframe:function(){var i=2,type;switch(this.lookahead(i).type){case"{":case"indent":case",":return true;case"newline":while("unit"==this.lookahead(++i).type||"newline"==this.lookahead(i).type);type=this.lookahead(i).type;return"indent"==type||"{"==type}},stateAllowsSelector:function(){switch(this.currentState()){case"root":case"atblock":case"selector":case"conditional":case"function":case"atrule":case"for":return true}},assignAtblock:function(expr){try{expr.push(this.atblock(expr))}catch(err){this.error("invalid right-hand side operand in assignment, got {peek}")}},statement:function(){var stmt=this.stmt(),state=this.prevState,block,op;if(this.allowPostfix){this.allowPostfix=false;state="expression"}switch(state){case"assignment":case"expression":case"function arguments":while(op=this.accept("if")||this.accept("unless")||this.accept("for")){switch(op.type){case"if":case"unless":stmt=new nodes.If(this.expression(),stmt);stmt.postfix=true;stmt.negate="unless"==op.type;this.accept(";");break;case"for":var key,val=this.id().name;if(this.accept(","))key=this.id().name;this.expect("in");var each=new nodes.Each(val,key,this.expression());block=new nodes.Block(this.parent,each);block.push(stmt);each.block=block;stmt=each}}}return stmt},stmt:function(){var type=this.peek().type;switch(type){case"keyframes":return this.keyframes();case"-moz-document":return this.mozdocument();case"comment":case"selector":case"extend":case"literal":case"charset":case"namespace":case"require":case"extend":case"media":case"atrule":case"ident":case"scope":case"supports":case"unless":return this[type]();case"function":return this.fun();case"import":return this.atimport();case"if":return this.ifstmt();case"for":return this.forin();case"return":return this.ret();case"{":return this.property();default:if(this.stateAllowsSelector()){switch(type){case"color":case"~":case">":case"<":case":":case"&":case"[":case".":case"/":return this.selector();case"+":return"function"==this.lookahead(2).type?this.functionCall():this.selector();case"*":return this.property();case"unit":if(this.looksLikeKeyframe())return this.selector();case"-":if("{"==this.lookahead(2).type)return this.property()}}var expr=this.expression();if(expr.isEmpty)this.error("unexpected {peek}");return expr}},block:function(node,scope){var delim,stmt,next,block=this.parent=new nodes.Block(this.parent,node);if(false===scope)block.scope=false;this.accept("newline");if(this.accept("{")){this.css++;delim="}";this.skipWhitespace()}else{delim="outdent";this.expect("indent")}while(delim!=this.peek().type){if(this.css){if(this.accept("newline")||this.accept("indent"))continue;stmt=this.statement();this.accept(";");this.skipWhitespace()}else{if(this.accept("newline"))continue;next=this.lookahead(2).type;if("indent"==this.peek().type&&("outdent"==next||"comment"==next)){this.accept("indent");continue}stmt=this.statement();this.accept(";")}if(!stmt)this.error("unexpected token {peek} in block");block.push(stmt)}if(this.css){this.skipWhitespace();this.expect("}");this.skipSpaces();this.css--}else{this.expect("outdent")}this.parent=block.parent;return block},comment:function(){var node=this.next().val;this.skipSpaces();return node},forin:function(){this.expect("for");var key,val=this.id().name;if(this.accept(","))key=this.id().name;this.expect("in");this.state.push("for");this.cond=true;var each=new nodes.Each(val,key,this.expression());this.cond=false;each.block=this.block(each,false);this.state.pop();return each},ret:function(){this.expect("return");var expr=this.expression();return expr.isEmpty?new nodes.Return:new nodes.Return(expr)},unless:function(){this.expect("unless");this.state.push("conditional");this.cond=true;var node=new nodes.If(this.expression(),true);this.cond=false;node.block=this.block(node,false);this.state.pop();return node},ifstmt:function(){this.expect("if");this.state.push("conditional");this.cond=true;var node=new nodes.If(this.expression()),cond,block;this.cond=false;node.block=this.block(node,false);this.skip(["newline","comment"]);while(this.accept("else")){if(this.accept("if")){this.cond=true;cond=this.expression();this.cond=false;block=this.block(node,false);node.elses.push(new nodes.If(cond,block))}else{node.elses.push(this.block(node,false));break}this.skip(["newline","comment"])}this.state.pop();return node},atblock:function(node){if(!node)this.expect("atblock");node=new nodes.Atblock;this.state.push("atblock");node.block=this.block(node,false);this.state.pop();return node},atrule:function(){var type=this.expect("atrule").val,node=new nodes.Atrule(type),tok;this.skipSpacesAndComments();node.segments=this.selectorParts();this.skipSpacesAndComments();tok=this.peek().type;if("indent"==tok||"{"==tok){this.state.push("atrule");node.block=this.block(node);this.state.pop()}return node},scope:function(){this.expect("scope");var selector=this.selectorParts().map(function(selector){return selector.val}).join("");this.selectorScope=selector.trim();return nodes.nil},supports:function(){this.expect("supports");var node=new nodes.Supports(this.supportsCondition());this.state.push("atrule");node.block=this.block(node);this.state.pop();return node},supportsCondition:function(){var node=this.supportsNegation()||this.supportsOp();if(!node){this.cond=true;node=this.expression();this.cond=false}return node},supportsNegation:function(){if(this.accept("not")){var node=new nodes.Expression;node.push(new nodes.Literal("not"));node.push(this.supportsFeature());return node}},supportsOp:function(){var feature=this.supportsFeature(),op,expr;if(feature){expr=new nodes.Expression;expr.push(feature);while(op=this.accept("&&")||this.accept("||")){expr.push(new nodes.Literal("&&"==op.val?"and":"or"));expr.push(this.supportsFeature())}return expr}},supportsFeature:function(){this.skipSpacesAndComments();if("("==this.peek().type){var la=this.lookahead(2).type;if("ident"==la||"{"==la){return this.feature()}else{this.expect("(");var node=new nodes.Expression;node.push(new nodes.Literal("("));node.push(this.supportsCondition());this.expect(")");node.push(new nodes.Literal(")"));this.skipSpacesAndComments();return node}}},extend:function(){var tok=this.expect("extend"),selectors=[],sel,node,arr;do{arr=this.selectorParts();if(!arr.length)continue;sel=new nodes.Selector(arr);selectors.push(sel);if("!"!==this.peek().type)continue;tok=this.lookahead(2);if("ident"!==tok.type||"optional"!==tok.val.name)continue;this.skip(["!","ident"]);sel.optional=true}while(this.accept(","));node=new nodes.Extend(selectors);node.lineno=tok.lineno;node.column=tok.column;return node},media:function(){this.expect("media");this.state.push("atrule");var media=new nodes.Media(this.queries());media.block=this.block(media);this.state.pop();return media},queries:function(){var queries=new nodes.QueryList,skip=["comment","newline","space"];do{this.skip(skip);queries.push(this.query());this.skip(skip)}while(this.accept(","));return queries},query:function(){var query=new nodes.Query,expr,pred,id;if("ident"==this.peek().type&&("."==this.lookahead(2).type||"["==this.lookahead(2).type)){this.cond=true;expr=this.expression();this.cond=false;query.push(new nodes.Feature(expr.nodes));return query}if(pred=this.accept("ident")||this.accept("not")){pred=new nodes.Literal(pred.val.string||pred.val);this.skipSpacesAndComments();if(id=this.accept("ident")){query.type=id.val;query.predicate=pred}else{query.type=pred}this.skipSpacesAndComments();if(!this.accept("&&"))return query}do{query.push(this.feature())}while(this.accept("&&"));return query},feature:function(){this.skipSpacesAndComments();this.expect("(");this.skipSpacesAndComments();var node=new nodes.Feature(this.interpolate());this.skipSpacesAndComments();this.accept(":");this.skipSpacesAndComments();this.inProperty=true;node.expr=this.expression();this.inProperty=false;this.skipSpacesAndComments();this.expect(")");this.skipSpacesAndComments();return node},mozdocument:function(){this.expect("-moz-document");var mozdocument=new nodes.Atrule("-moz-document"),calls=[];do{this.skipSpacesAndComments();calls.push(this.functionCall());this.skipSpacesAndComments()}while(this.accept(","));mozdocument.segments=[new nodes.Literal(calls.join(", "))];this.state.push("atrule");mozdocument.block=this.block(mozdocument,false);this.state.pop();return mozdocument},atimport:function(){this.expect("import");this.allowPostfix=true;return new nodes.Import(this.expression(),false)},require:function(){this.expect("require");this.allowPostfix=true;return new nodes.Import(this.expression(),true)},charset:function(){this.expect("charset");var str=this.expect("string").val;this.allowPostfix=true;return new nodes.Charset(str)},namespace:function(){var str,prefix;this.expect("namespace");this.skipSpacesAndComments();if(prefix=this.accept("ident")){prefix=prefix.val}this.skipSpacesAndComments();str=this.accept("string")||this.url();this.allowPostfix=true;return new nodes.Namespace(str,prefix)},keyframes:function(){var tok=this.expect("keyframes"),keyframes;this.skipSpacesAndComments();keyframes=new nodes.Keyframes(this.interpolate(),tok.val);this.skipSpacesAndComments();this.state.push("atrule");keyframes.block=this.block(keyframes);this.state.pop();return keyframes},literal:function(){return this.expect("literal").val},id:function(){var tok=this.expect("ident");this.accept("space");return tok.val},ident:function(){var i=2,la=this.lookahead(i).type;while("space"==la)la=this.lookahead(++i).type;switch(la){case"=":case"?=":case"-=":case"+=":case"*=":case"/=":case"%=":return this.assignment();case".":if("space"==this.lookahead(i-1).type)return this.selector();if(this._ident==this.peek())return this.id();while("="!=this.lookahead(++i).type&&!~["[",",","newline","indent","eos"].indexOf(this.lookahead(i).type));if("="==this.lookahead(i).type){this._ident=this.peek();return this.expression()}else if(this.looksLikeSelector()&&this.stateAllowsSelector()){return this.selector()}case"[":if(this._ident==this.peek())return this.id();while("]"!=this.lookahead(i++).type&&"selector"!=this.lookahead(i).type&&"eos"!=this.lookahead(i).type);if("="==this.lookahead(i).type){this._ident=this.peek();return this.expression()}else if(this.looksLikeSelector()&&this.stateAllowsSelector()){return this.selector()}case"-":case"+":case"/":case"*":case"%":case"**":case"&&":case"||":case">":case"<":case">=":case"<=":case"!=":case"==":case"?":case"in":case"is a":case"is defined":if(this._ident==this.peek()){return this.id()}else{this._ident=this.peek();switch(this.currentState()){case"for":case"selector":return this.property();case"root":case"atblock":case"atrule":return"["==la?this.subscript():this.selector();case"function":case"conditional":return this.looksLikeSelector()?this.selector():this.expression();default:return this.operand?this.id():this.expression()}}default:switch(this.currentState()){case"root":return this.selector();case"for":case"selector":case"function":case"conditional":case"atblock":case"atrule":return this.property();default:var id=this.id();if("interpolation"==this.previousState())id.mixin=true;return id}}},interpolate:function(){var node,segs=[],star;star=this.accept("*");if(star)segs.push(new nodes.Literal("*"));while(true){if(this.accept("{")){this.state.push("interpolation");segs.push(this.expression());this.expect("}");this.state.pop()}else if(node=this.accept("-")){segs.push(new nodes.Literal("-"))}else if(node=this.accept("ident")){segs.push(node.val)}else{break}}if(!segs.length)this.expect("ident");return segs},property:function(){if(this.looksLikeSelector(true))return this.selector();var ident=this.interpolate(),prop=new nodes.Property(ident),ret=prop;this.accept("space");if(this.accept(":"))this.accept("space");this.state.push("property");this.inProperty=true;prop.expr=this.list();if(prop.expr.isEmpty)ret=ident[0];this.inProperty=false;this.allowPostfix=true;this.state.pop();this.accept(";");return ret},selector:function(){var arr,group=new nodes.Group,scope=this.selectorScope,isRoot="root"==this.currentState(),selector;do{this.accept("newline");arr=this.selectorParts();if(isRoot&&scope)arr.unshift(new nodes.Literal(scope+" "));if(arr.length){selector=new nodes.Selector(arr);selector.lineno=arr[0].lineno;selector.column=arr[0].column;group.push(selector)}}while(this.accept(",")||this.accept("newline"));this.state.push("selector");group.block=this.block(group);this.state.pop();return group},selectorParts:function(){var tok,arr=[];while(tok=this.selectorToken()){switch(tok.type){case"{":this.skipSpaces();var expr=this.expression();this.skipSpaces();this.expect("}");arr.push(expr);break;case this.prefix&&".":var literal=new nodes.Literal(tok.val+this.prefix);literal.prefixed=true;arr.push(literal);break;case"comment":break;case"color":case"unit":arr.push(new nodes.Literal(tok.val.raw));break;case"space":arr.push(new nodes.Literal(" "));break;case"function":arr.push(new nodes.Literal(tok.val.name+"("));break;case"ident":arr.push(new nodes.Literal(tok.val.name||tok.val.string));break;default:arr.push(new nodes.Literal(tok.val));if(tok.space)arr.push(new nodes.Literal(" "))}}return arr},assignment:function(){var op,node,name=this.id().name;if(op=this.accept("=")||this.accept("?=")||this.accept("+=")||this.accept("-=")||this.accept("*=")||this.accept("/=")||this.accept("%=")){this.state.push("assignment");var expr=this.list();if(expr.isEmpty)this.assignAtblock(expr);node=new nodes.Ident(name,expr);this.state.pop();switch(op.type){case"?=":var defined=new nodes.BinOp("is defined",node),lookup=new nodes.Ident(name);node=new nodes.Ternary(defined,lookup,node);break;case"+=":case"-=":case"*=":case"/=":case"%=":node.val=new nodes.BinOp(op.type[0],new nodes.Ident(name),expr);break}}return node},fun:function(){var parens=1,i=2,tok;out:while(tok=this.lookahead(i++)){switch(tok.type){case"function":case"(":++parens;break;case")":if(!--parens)break out;break;case"eos":this.error('failed to find closing paren ")"')}}switch(this.currentState()){case"expression":return this.functionCall();default:return this.looksLikeFunctionDefinition(i)?this.functionDefinition():this.expression()}},url:function(){this.expect("function");this.state.push("function arguments");var args=this.args();this.expect(")");this.state.pop();return new nodes.Call("url",args)},functionCall:function(){var withBlock=this.accept("+");if("url"==this.peek().val.name)return this.url();var name=this.expect("function").val.name;this.state.push("function arguments");this.parens++;var args=this.args();this.expect(")");this.parens--;this.state.pop();var call=new nodes.Call(name,args);if(withBlock){this.state.push("function");call.block=this.block(call);this.state.pop()}return call},functionDefinition:function(){var name=this.expect("function").val.name;this.state.push("function params");this.skipWhitespace();var params=this.params();this.skipWhitespace();this.expect(")");this.state.pop();this.state.push("function");var fn=new nodes.Function(name,params);fn.block=this.block(fn);this.state.pop();return new nodes.Ident(name,fn)},params:function(){var tok,node,params=new nodes.Params;while(tok=this.accept("ident")){this.accept("space");params.push(node=tok.val);if(this.accept("...")){node.rest=true}else if(this.accept("=")){node.val=this.expression()}this.skipWhitespace();this.accept(",");this.skipWhitespace()}return params},args:function(){var args=new nodes.Arguments,keyword;do{if("ident"==this.peek().type&&":"==this.lookahead(2).type){keyword=this.next().val.string;this.expect(":");args.map[keyword]=this.expression()}else{args.push(this.expression())}}while(this.accept(","));return args},list:function(){var node=this.expression();while(this.accept(",")){if(node.isList){list.push(this.expression())}else{var list=new nodes.Expression(true);list.push(node);list.push(this.expression());node=list}}return node},expression:function(){var node,expr=new nodes.Expression;this.state.push("expression");while(node=this.negation()){if(!node)this.error("unexpected token {peek} in expression");expr.push(node)}this.state.pop();if(expr.nodes.length){expr.lineno=expr.nodes[0].lineno;expr.column=expr.nodes[0].column}return expr},negation:function(){if(this.accept("not")){return new nodes.UnaryOp("!",this.negation())}return this.ternary()},ternary:function(){var node=this.logical();if(this.accept("?")){var trueExpr=this.expression();this.expect(":");var falseExpr=this.expression();node=new nodes.Ternary(node,trueExpr,falseExpr)}return node},logical:function(){var op,node=this.typecheck();while(op=this.accept("&&")||this.accept("||")){node=new nodes.BinOp(op.type,node,this.typecheck())}return node},typecheck:function(){var op,node=this.equality();while(op=this.accept("is a")){this.operand=true;if(!node)this.error('illegal unary "'+op+'", missing left-hand operand');node=new nodes.BinOp(op.type,node,this.equality());this.operand=false}return node},equality:function(){var op,node=this.inop();while(op=this.accept("==")||this.accept("!=")){this.operand=true;if(!node)this.error('illegal unary "'+op+'", missing left-hand operand');node=new nodes.BinOp(op.type,node,this.inop());this.operand=false}return node},inop:function(){var node=this.relational();while(this.accept("in")){this.operand=true;if(!node)this.error('illegal unary "in", missing left-hand operand');node=new nodes.BinOp("in",node,this.relational());this.operand=false}return node},relational:function(){var op,node=this.range();while(op=this.accept(">=")||this.accept("<=")||this.accept("<")||this.accept(">")){this.operand=true;if(!node)this.error('illegal unary "'+op+'", missing left-hand operand');node=new nodes.BinOp(op.type,node,this.range());this.operand=false}return node},range:function(){var op,node=this.additive();if(op=this.accept("...")||this.accept("..")){this.operand=true;if(!node)this.error('illegal unary "'+op+'", missing left-hand operand');node=new nodes.BinOp(op.val,node,this.additive());this.operand=false}return node},additive:function(){var op,node=this.multiplicative();while(op=this.accept("+")||this.accept("-")){this.operand=true;node=new nodes.BinOp(op.type,node,this.multiplicative());this.operand=false}return node},multiplicative:function(){var op,node=this.defined();while(op=this.accept("**")||this.accept("*")||this.accept("/")||this.accept("%")){this.operand=true;if("/"==op&&this.inProperty&&!this.parens){this.stash.push(new Token("literal",new nodes.Literal("/")));this.operand=false;return node}else{if(!node)this.error('illegal unary "'+op+'", missing left-hand operand');node=new nodes.BinOp(op.type,node,this.defined());this.operand=false}}return node},defined:function(){var node=this.unary();if(this.accept("is defined")){if(!node)this.error('illegal unary "is defined", missing left-hand operand');node=new nodes.BinOp("is defined",node)}return node},unary:function(){var op,node;if(op=this.accept("!")||this.accept("~")||this.accept("+")||this.accept("-")){this.operand=true;node=this.unary();if(!node)this.error('illegal unary "'+op+'"');node=new nodes.UnaryOp(op.type,node);this.operand=false;return node}return this.subscript()},subscript:function(){var node=this.member(),id;while(this.accept("[")){node=new nodes.BinOp("[]",node,this.expression());this.expect("]")}if(this.accept("=")){node.op+="=";node.val=this.list();if(node.val.isEmpty)this.assignAtblock(node.val)}return node},member:function(){var node=this.primary();if(node){while(this.accept(".")){var id=new nodes.Ident(this.expect("ident").val.string);node=new nodes.Member(node,id)}this.skipSpaces();if(this.accept("=")){node.val=this.list();if(node.val.isEmpty)this.assignAtblock(node.val)}}return node},object:function(){var obj=new nodes.Object,id,val,comma;this.expect("{");this.skipWhitespace();while(!this.accept("}")){if(this.accept("comment")||this.accept("newline"))continue;if(!comma)this.accept(",");id=this.accept("ident")||this.accept("string");if(!id)this.error('expected "ident" or "string", got {peek}');id=id.val.hash;this.skipSpacesAndComments();this.expect(":");val=this.expression();obj.set(id,val);comma=this.accept(",");this.skipWhitespace()}return obj},primary:function(){var tok;this.skipSpacesAndComments();if(this.accept("(")){++this.parens;var expr=this.expression(),paren=this.expect(")");--this.parens;if(this.accept("%"))expr.push(new nodes.Ident("%"));tok=this.peek();if(!paren.space&&"ident"==tok.type&&~units.indexOf(tok.val.string)){expr.push(new nodes.Ident(tok.val.string));this.next()}return expr}tok=this.peek();switch(tok.type){case"null":case"unit":case"color":case"string":case"literal":case"boolean":return this.next().val;case!this.cond&&"{":return this.object();case"atblock":return this.atblock();case"atrule":var id=new nodes.Ident(this.next().val);id.property=true;return id;case"ident":return this.ident();case"function":return tok.anonymous?this.functionDefinition():this.functionCall()}}}});require.register("renderer.js",function(module,exports,require){var Parser=require("./parser"),Evaluator=require("./visitor/evaluator"),Normalizer=require("./visitor/normalizer"),utils=require("./utils"),nodes=require("./nodes"),join=require("./path").join;module.exports=Renderer;function Renderer(str,options){options=options||{};options.globals=options.globals||{};options.functions=options.functions||{};options.use=options.use||[];options.use=Array.isArray(options.use)?options.use:[options.use];options.imports=[];options.paths=options.paths||[];options.filename=options.filename||"stylus";options.Evaluator=options.Evaluator||Evaluator;this.options=options;this.str=str}Renderer.prototype.render=function(fn){var parser=this.parser=new Parser(this.str,this.options);for(var i=0,len=this.options.use.length;i-1){return n.toString().replace("0.",".")+type}}return(float?parseFloat(n.toFixed(15)):n).toString()+type};Compiler.prototype.visitGroup=function(group){var stack=this.keyframe?[]:this.stack,comma=this.compress?",":",\n";stack.push(group.nodes);if(group.block.hasProperties){var selectors=utils.compileSelectors.call(this,stack),len=selectors.length;if(len){if(this.keyframe)comma=this.compress?",":", ";for(var i=0;i200){throw new RangeError("Maximum stylus call stack size exceeded")}if("expression"==fn.nodeName)fn=fn.first;this.ret++;var args=this.visit(call.args);for(var key in args.map){args.map[key]=this.visit(args.map[key].clone())}this.ret--;if(fn.fn){ret=this.invokeBuiltin(fn.fn,args)}else if("function"==fn.nodeName){if(call.block)call.block=this.visit(call.block);ret=this.invokeFunction(fn,args,call.block)}this.calling.pop();this.ignoreColors=false;return ret};Evaluator.prototype.visitIdent=function(ident){var prop;if(ident.property){if(prop=this.lookupProperty(ident.name)){return this.visit(prop.expr.clone())}return nodes.nil}else if(ident.val.isNull){var val=this.lookup(ident.name);if(val&&ident.mixin)this.mixinNode(val);return val?this.visit(val):ident}else{this.ret++;ident.val=this.visit(ident.val);this.ret--;this.currentScope.add(ident);return ident.val}};Evaluator.prototype.visitBinOp=function(binop){if("is defined"==binop.op)return this.isDefined(binop.left);this.ret++;var op=binop.op,left=this.visit(binop.left),right="||"==op||"&&"==op?binop.right:this.visit(binop.right);var val=binop.val?this.visit(binop.val):null;this.ret--;try{return this.visit(left.operate(op,right,val))}catch(err){if("CoercionError"==err.name){switch(op){case"==":return nodes.no;case"!=":return nodes.yes}}throw err}};Evaluator.prototype.visitUnaryOp=function(unary){var op=unary.op,node=this.visit(unary.expr);if("!"!=op){node=node.first.clone();utils.assertType(node,"unit")}switch(op){case"-":node.val=-node.val;break;case"+":node.val=+node.val;break;case"~":node.val=~node.val;break;case"!":return node.toBoolean().negate()}return node};Evaluator.prototype.visitTernary=function(ternary){var ok=this.visit(ternary.cond).toBoolean();return ok.isTrue?this.visit(ternary.trueExpr):this.visit(ternary.falseExpr)};Evaluator.prototype.visitExpression=function(expr){for(var i=0,len=expr.nodes.length;i1){for(var i=0;i0&&!~part.indexOf("&")){part="/"+part}s=new nodes.Selector([new nodes.Literal(part)]);s.val=part;s.block=group.block;group.nodes[i++]=s}});stack.push(group.nodes);var selectors=utils.compileSelectors(stack,true);selectors.forEach(function(selector){map[selector]=map[selector]||[];map[selector].push(group)});this.extend(group,selectors);stack.pop();return group};Normalizer.prototype.visitFunction=function(){return nodes.nil};Normalizer.prototype.visitMedia=function(media){var medias=[],group=this.closestGroup(media.block),parent;function mergeQueries(block){block.nodes.forEach(function(node,i){switch(node.nodeName){case"media":node.val=media.val.merge(node.val);medias.push(node);block.nodes[i]=nodes.nil;break;case"block":mergeQueries(node);break;default:if(node.block&&node.block.nodes)mergeQueries(node.block)}})}mergeQueries(media.block);this.bubble(media);if(medias.length){medias.forEach(function(node){if(group){group.block.push(node)}else{this.root.nodes.splice(++this.rootIndex,0,node)}node=this.visit(node);parent=node.block.parent;if(node.bubbled&&(!group||"group"==parent.node.nodeName)){node.group.block=node.block.nodes[0].block;node.block.nodes[0]=node.group}},this)}return media};Normalizer.prototype.visitSupports=function(node){this.bubble(node);return node};Normalizer.prototype.visitAtrule=function(node){if(node.block)node.block=this.visit(node.block);return node};Normalizer.prototype.visitKeyframes=function(node){var frames=node.block.nodes.filter(function(frame){return frame.block&&frame.block.hasProperties});node.frames=frames.length;return node};Normalizer.prototype.visitImport=function(node){this.imports.push(node);return this.hoist?nodes.nil:node};Normalizer.prototype.visitCharset=function(node){this.charset=node;return this.hoist?nodes.nil:node};Normalizer.prototype.extend=function(group,selectors){var map=this.map,self=this,parent=this.closestGroup(group.block);group.extends.forEach(function(extend){var groups=map[extend.selector];if(!groups){if(extend.optional)return;var err=new Error('Failed to @extend "'+extend.selector+'"');err.lineno=extend.lineno;err.column=extend.column;throw err}selectors.forEach(function(selector){var node=new nodes.Selector;node.val=selector;node.inherits=false;groups.forEach(function(group){if(!parent||parent!=group)self.extend(group,selectors);group.push(node)})})});group.block=this.visit(group.block)}});return require("stylus")}(); \ No newline at end of file +utils.assertType(stop,"unit","stop");if(step){utils.assertType(step,"unit","step");if(0==step.val){throw new Error('ArgumentError: "step" argument must not be zero')}}else{step=new nodes.Unit(1)}var list=new nodes.Expression;for(var i=start.val;i<=stop.val;i+=step.val){list.push(new nodes.Unit(i,start.type))}return list};function parseUnit(str){var units=require("./../units").join("|"),m=str.match(new RegExp("^(-)?(\\d+\\.\\d+|\\d+|\\.\\d+)("+units+")?")),n;if(!m)return;n=parseFloat(m[2]);if("-"==m[1])n=-n;return new nodes.Unit(n,m[3])}function parseColor(str){if(str.substr(0,1)==="#"){var shorthand=str.length===4,m=str.match(shorthand?/\w/g:/\w{2}/g);if(!m)return;m=m.map(function(s){return parseInt(shorthand?s+s:s,16)});return new nodes.RGBA(m[0],m[1],m[2],1)}else if(str.substr(0,3)==="rgb"){var m=str.match(/([0-9]*\.?[0-9]+)/g);if(!m)return;m=m.map(function(s){return parseFloat(s,10)});return new nodes.RGBA(m[0],m[1],m[2],m[3]||1)}else{var rgb=colors[str];if(!rgb)return;return new nodes.RGBA(rgb[0],rgb[1],rgb[2],1)}}function parseString(str){return parseUnit(str)||parseColor(str)||new nodes.Literal(str)}function parseObject(obj){obj=obj.vals;for(var key in obj){var nodes=obj[key].nodes[0].nodes;if(nodes&&nodes.length){obj[key]=[];for(var i=0,len=nodes.length;i=this.length||255!=buf[offset])break;if(192==buf[offset+1]||194==buf[offset+1]){height=buf[offset+5]<<8|buf[offset+6];width=buf[offset+7]<<8|buf[offset+8]}else{offset+=2;blockSize=buf[offset]<<8|buf[offset+1]}}break;case"png":buf=new Buffer(8);fs.readSync(this.fd,buf,0,8,16);width=uint32(buf);height=uint32(buf.slice(4,8));break;case"gif":buf=new Buffer(4);fs.readSync(this.fd,buf,0,4,6);width=uint16(buf);height=uint16(buf.slice(2,4));break;case"svg":offset=Math.min(this.length,1024);buf=new Buffer(offset);fs.readSync(this.fd,buf,0,offset,0);buf=buf.toString("utf8");parser=sax.parser(true);parser.onopentag=function(node){if("svg"==node.name&&node.attributes.width&&node.attributes.height){width=parseInt(node.attributes.width,10);height=parseInt(node.attributes.height,10)}};parser.write(buf).close();break}if("number"!=typeof width)throw new Error('failed to find width of "'+this.path+'"');if("number"!=typeof height)throw new Error('failed to find height of "'+this.path+'"');return[width,height]}});require.register("functions/url.js",function(module,exports,require){var Compiler=require("../visitor/compiler"),events=require("../renderer").events,nodes=require("../nodes"),extname=require("../path").extname,utils=require("../utils");var defaultMimes={".gif":"image/gif",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".svg":"image/svg+xml",".webp":"image/webp",".ttf":"application/x-font-ttf",".eot":"application/vnd.ms-fontobject",".woff":"application/font-woff",".woff2":"application/font-woff2"};module.exports=function(options){options=options||{};var _paths=options.paths||[];var sizeLimit=null!=options.limit?options.limit:3e4;var mimes=options.mimes||defaultMimes;function fn(url){var compiler=new Compiler(url);compiler.isURL=true;url=url.nodes.map(function(node){return compiler.visit(node)}).join("");url=parse(url);var ext=extname(url.pathname),mime=mimes[ext],hash=url.hash||"",literal=new nodes.Literal('url("'+url.href+'")'),paths=_paths.concat(this.paths),buf;if(!mime)return literal;if(url.protocol)return literal;var found=utils.lookup(url.pathname,paths);if(!found){events.emit("file not found","File "+literal+" could not be found, literal url retained!");return literal}buf=fs.readFileSync(found);if(false!==sizeLimit&&buf.length>sizeLimit)return literal;return new nodes.Literal('url("data:'+mime+";base64,"+buf.toString("base64")+hash+'")')}fn.raw=true;return fn};module.exports.mimes=defaultMimes});require.register("lexer.js",function(module,exports,require){var Token=require("./token"),nodes=require("./nodes"),errors=require("./errors"),units=require("./units");exports=module.exports=Lexer;var alias={and:"&&",or:"||",is:"==",isnt:"!=","is not":"!=",":=":"?="};units=units.join("|");var unit=new RegExp("^(-)?(\\d+\\.\\d+|\\d+|\\.\\d+)("+units+")?[ \\t]*");function Lexer(str,options){options=options||{};this.stash=[];this.indentStack=[];this.indentRe=null;this.lineno=1;this.column=1;function comment(str,val,offset,s){var inComment=s.lastIndexOf("/*",offset)>s.lastIndexOf("*/",offset),commentIdx=s.lastIndexOf("//",offset),i=s.lastIndexOf("\n",offset),double=0,single=0;if(~commentIdx&&commentIdx>i){while(i!=offset){if("'"==s[i])single?single--:single++;if('"'==s[i])double?double--:double++;if("/"==s[i]&&"/"==s[i+1]){inComment=!single&&!double;break}++i}}return inComment?str:val+"\r"}if(""==str.charAt(0))str=str.slice(1);this.str=str.replace(/\s+$/,"\n").replace(/\r\n?/g,"\n").replace(/\\ *\n/g,"\r").replace(/([,(:](?!\/\/[^ ])) *(?:\/\/[^\n]*)?\n\s*/g,comment).replace(/\s*\n[ \t]*([,)])/g,comment)}Lexer.prototype={inspect:function(){var tok,tmp=this.str,buf=[];while("eos"!=(tok=this.next()).type){buf.push(tok.inspect())}this.str=tmp;return buf.concat(tok.inspect()).join("\n")},lookahead:function(n){var fetch=n-this.stash.length;while(fetch-->0)this.stash.push(this.advance());return this.stash[--n]},skip:function(len){var chunk=len[0];len=chunk?chunk.length:len;this.str=this.str.substr(len);if(chunk){this.move(chunk)}else{this.column+=len}},move:function(str){var lines=str.match(/\n/g),idx=str.lastIndexOf("\n");if(lines)this.lineno+=lines.length;this.column=~idx?str.length-idx:this.column+str.length},next:function(){var tok=this.stashed()||this.advance();this.prev=tok;return tok},isPartOfSelector:function(){var tok=this.stash[this.stash.length-1]||this.prev;switch(tok&&tok.type){case"color":return 2==tok.val.raw.length;case".":case"[":return true}return false},advance:function(){var column=this.column,line=this.lineno,tok=this.eos()||this.nil()||this.sep()||this.keyword()||this.urlchars()||this.comment()||this.newline()||this.escaped()||this.important()||this.literal()||this.fun()||this.anonFunc()||this.atrule()||this.brace()||this.paren()||this.color()||this.string()||this.unit()||this.namedop()||this.boolean()||this.unicode()||this.ident()||this.op()||this.eol()||this.space()||this.selector();tok.lineno=line;tok.column=column;return tok},peek:function(){return this.lookahead(1)},stashed:function(){return this.stash.shift()},eos:function(){if(this.str.length)return;if(this.indentStack.length){this.indentStack.shift();return new Token("outdent")}else{return new Token("eos")}},urlchars:function(){var captures;if(!this.isURL)return;if(captures=/^[\/:@.;?&=*!,<>#%0-9]+/.exec(this.str)){this.skip(captures);return new Token("literal",new nodes.Literal(captures[0]))}},sep:function(){var captures;if(captures=/^;[ \t]*/.exec(this.str)){this.skip(captures);return new Token(";")}},eol:function(){if("\r"==this.str[0]){++this.lineno;this.skip(1);return this.advance()}},space:function(){var captures;if(captures=/^([ \t]+)/.exec(this.str)){this.skip(captures);return new Token("space")}},escaped:function(){var captures;if(captures=/^\\(.)[ \t]*/.exec(this.str)){var c=captures[1];this.skip(captures);return new Token("ident",new nodes.Literal(c))}},literal:function(){var captures;if(captures=/^@css[ \t]*\{/.exec(this.str)){this.skip(captures);var c,braces=1,css="",node;while(c=this.str[0]){this.str=this.str.substr(1);switch(c){case"{":++braces;break;case"}":--braces;break;case"\n":++this.lineno;break}css+=c;if(!braces)break}css=css.replace(/\s*}$/,"");node=new nodes.Literal(css);node.css=true;return new Token("literal",node)}},important:function(){var captures;if(captures=/^!important[ \t]*/.exec(this.str)){this.skip(captures);return new Token("ident",new nodes.Literal("!important"))}},brace:function(){var captures;if(captures=/^([{}])/.exec(this.str)){this.skip(1);var brace=captures[1];return new Token(brace,brace)}},paren:function(){var captures;if(captures=/^([()])([ \t]*)/.exec(this.str)){var paren=captures[1];this.skip(captures);if(")"==paren)this.isURL=false;var tok=new Token(paren,paren);tok.space=captures[2];return tok}},nil:function(){var captures,tok;if(captures=/^(null)\b[ \t]*/.exec(this.str)){this.skip(captures);if(this.isPartOfSelector()){tok=new Token("ident",new nodes.Ident(captures[0]))}else{tok=new Token("null",nodes.nil)}return tok}},keyword:function(){var captures,tok;if(captures=/^(return|if|else|unless|for|in)\b[ \t]*/.exec(this.str)){var keyword=captures[1];this.skip(captures);if(this.isPartOfSelector()){tok=new Token("ident",new nodes.Ident(captures[0]))}else{tok=new Token(keyword,keyword)}return tok}},namedop:function(){var captures,tok;if(captures=/^(not|and|or|is a|is defined|isnt|is not|is)(?!-)\b([ \t]*)/.exec(this.str)){var op=captures[1];this.skip(captures);if(this.isPartOfSelector()){tok=new Token("ident",new nodes.Ident(captures[0]))}else{op=alias[op]||op;tok=new Token(op,op)}tok.space=captures[2];return tok}},op:function(){var captures;if(captures=/^([.]{1,3}|&&|\|\||[!<>=?:]=|\*\*|[-+*\/%]=?|[,=?:!~<>&\[\]])([ \t]*)/.exec(this.str)){var op=captures[1];this.skip(captures);op=alias[op]||op;var tok=new Token(op,op);tok.space=captures[2];this.isURL=false;return tok}},anonFunc:function(){var tok;if("@"==this.str[0]&&"("==this.str[1]){this.skip(2);tok=new Token("function",new nodes.Ident("anonymous"));tok.anonymous=true;return tok}},atrule:function(){var captures;if(captures=/^@(?:-(\w+)-)?([a-zA-Z0-9-_]+)[ \t]*/.exec(this.str)){this.skip(captures);var vendor=captures[1],type=captures[2],tok;switch(type){case"require":case"import":case"charset":case"namespace":case"media":case"scope":case"supports":return new Token(type);case"document":return new Token("-moz-document");case"block":return new Token("atblock");case"extend":case"extends":return new Token("extend");case"keyframes":return new Token(type,vendor);default:return new Token("atrule",vendor?"-"+vendor+"-"+type:type)}}},comment:function(){if("/"==this.str[0]&&"/"==this.str[1]){var end=this.str.indexOf("\n");if(-1==end)end=this.str.length;this.skip(end);return this.advance()}if("/"==this.str[0]&&"*"==this.str[1]){var end=this.str.indexOf("*/");if(-1==end)end=this.str.length;var str=this.str.substr(0,end+2),lines=str.split("\n").length-1,suppress=true,inline=false;this.lineno+=lines;this.skip(end+2);if("!"==str[2]){str=str.replace("*!","*");suppress=false}if(this.prev&&";"==this.prev.type)inline=true;return new Token("comment",new nodes.Comment(str,suppress,inline))}},"boolean":function(){var captures;if(captures=/^(true|false)\b([ \t]*)/.exec(this.str)){var val=nodes.Boolean("true"==captures[1]);this.skip(captures);var tok=new Token("boolean",val);tok.space=captures[2];return tok}},unicode:function(){var captures;if(captures=/^u\+[0-9a-f?]{1,6}(?:-[0-9a-f]{1,6})?/i.exec(this.str)){this.skip(captures);return new Token("literal",new nodes.Literal(captures[0]))}},fun:function(){var captures;if(captures=/^(-*[_a-zA-Z$][-\w\d$]*)\(([ \t]*)/.exec(this.str)){var name=captures[1];this.skip(captures);this.isURL="url"==name;var tok=new Token("function",new nodes.Ident(name));tok.space=captures[2];return tok}},ident:function(){var captures;if(captures=/^-*[_a-zA-Z$][-\w\d$]*/.exec(this.str)){this.skip(captures);return new Token("ident",new nodes.Ident(captures[0]))}},newline:function(){var captures,re;if(this.indentRe){captures=this.indentRe.exec(this.str)}else{re=/^\n([\t]*)[ \t]*/;captures=re.exec(this.str);if(captures&&!captures[1].length){re=/^\n([ \t]*)/;captures=re.exec(this.str)}if(captures&&captures[1].length)this.indentRe=re}if(captures){var tok,indents=captures[1].length;this.skip(captures);if(this.str[0]===" "||this.str[0]===" "){throw new errors.SyntaxError("Invalid indentation. You can use tabs or spaces to indent, but not both.")}if("\n"==this.str[0])return this.advance();if(this.indentStack.length&&indentsindents){this.stash.push(new Token("outdent"));this.indentStack.shift()}tok=this.stash.pop()}else if(indents&&indents!=this.indentStack[0]){this.indentStack.unshift(indents);tok=new Token("indent")}else{tok=new Token("newline")}return tok}},unit:function(){var captures;if(captures=unit.exec(this.str)){this.skip(captures);var n=parseFloat(captures[2]);if("-"==captures[1])n=-n;var node=new nodes.Unit(n,captures[3]);node.raw=captures[0];return new Token("unit",node)}},string:function(){var captures;if(captures=/^("[^"]*"|'[^']*')[ \t]*/.exec(this.str)){var str=captures[1],quote=captures[0][0];this.skip(captures);str=str.slice(1,-1).replace(/\\n/g,"\n");return new Token("string",new nodes.String(str,quote))}},color:function(){return this.rrggbbaa()||this.rrggbb()||this.rgba()||this.rgb()||this.nn()||this.n()},n:function(){var captures;if(captures=/^#([a-fA-F0-9]{1})[ \t]*/.exec(this.str)){this.skip(captures);var n=parseInt(captures[1]+captures[1],16),color=new nodes.RGBA(n,n,n,1);color.raw=captures[0];return new Token("color",color)}},nn:function(){var captures;if(captures=/^#([a-fA-F0-9]{2})[ \t]*/.exec(this.str)){this.skip(captures);var n=parseInt(captures[1],16),color=new nodes.RGBA(n,n,n,1);color.raw=captures[0];return new Token("color",color)}},rgb:function(){var captures;if(captures=/^#([a-fA-F0-9]{3})[ \t]*/.exec(this.str)){this.skip(captures);var rgb=captures[1],r=parseInt(rgb[0]+rgb[0],16),g=parseInt(rgb[1]+rgb[1],16),b=parseInt(rgb[2]+rgb[2],16),color=new nodes.RGBA(r,g,b,1);color.raw=captures[0];return new Token("color",color)}},rgba:function(){var captures;if(captures=/^#([a-fA-F0-9]{4})[ \t]*/.exec(this.str)){this.skip(captures);var rgb=captures[1],r=parseInt(rgb[0]+rgb[0],16),g=parseInt(rgb[1]+rgb[1],16),b=parseInt(rgb[2]+rgb[2],16),a=parseInt(rgb[3]+rgb[3],16),color=new nodes.RGBA(r,g,b,a/255);color.raw=captures[0];return new Token("color",color)}},rrggbb:function(){var captures;if(captures=/^#([a-fA-F0-9]{6})[ \t]*/.exec(this.str)){this.skip(captures);var rgb=captures[1],r=parseInt(rgb.substr(0,2),16),g=parseInt(rgb.substr(2,2),16),b=parseInt(rgb.substr(4,2),16),color=new nodes.RGBA(r,g,b,1);color.raw=captures[0];return new Token("color",color)}},rrggbbaa:function(){var captures;if(captures=/^#([a-fA-F0-9]{8})[ \t]*/.exec(this.str)){this.skip(captures);var rgb=captures[1],r=parseInt(rgb.substr(0,2),16),g=parseInt(rgb.substr(2,2),16),b=parseInt(rgb.substr(4,2),16),a=parseInt(rgb.substr(6,2),16),color=new nodes.RGBA(r,g,b,a/255);color.raw=captures[0];return new Token("color",color)}},selector:function(){var captures;if(captures=/^.*?(?=\/\/(?![^\[]*\])|[,\n{])/.exec(this.str)){var selector=captures[0];this.skip(captures);return new Token("selector",selector)}}}});require.register("nodes/arguments.js",function(module,exports,require){var Node=require("./node"),nodes=require("../nodes"),utils=require("../utils");var Arguments=module.exports=function Arguments(){nodes.Expression.call(this);this.map={}};Arguments.prototype.__proto__=nodes.Expression.prototype;Arguments.fromExpression=function(expr){var args=new Arguments,len=expr.nodes.length;args.lineno=expr.lineno;args.column=expr.column;args.isList=expr.isList;for(var i=0;ilen)self.nodes[i]=nodes.nil;self.nodes[n]=val}else if(unit.string){node=self.nodes[0];if(node&&"object"==node.nodeName)node.set(unit.string,val.clone())}});return val;case"[]":var expr=new nodes.Expression,vals=utils.unwrap(this).nodes,range=utils.unwrap(right).nodes,node;range.forEach(function(unit){if("unit"==unit.nodeName){node=vals[unit.val<0?vals.length+unit.val:unit.val]}else if("object"==vals[0].nodeName){node=vals[0].get(unit.string)}if(node)expr.push(node)});return expr.isEmpty?nodes.nil:utils.unwrap(expr);case"||":return this.toBoolean().isTrue?this:right;case"in":return Node.prototype.operate.call(this,op,right);case"!=":return this.operate("==",right,val).negate();case"==":var len=this.nodes.length,right=right.toExpression(),a,b;if(len!=right.nodes.length)return nodes.no;for(var i=0;i1)return nodes.yes;return this.first.toBoolean()};Expression.prototype.toString=function(){return"("+this.nodes.map(function(node){return node.toString()}).join(this.isList?", ":" ")+")"};Expression.prototype.toJSON=function(){return{__type:"Expression",isList:this.isList,preserve:this.preserve,lineno:this.lineno,column:this.column,filename:this.filename,nodes:this.nodes}}});require.register("nodes/function.js",function(module,exports,require){var Node=require("./node");var Function=module.exports=function Function(name,params,body){Node.call(this);this.name=name;this.params=params;this.block=body;if("function"==typeof params)this.fn=params};Function.prototype.__defineGetter__("arity",function(){return this.params.length});Function.prototype.__proto__=Node.prototype;Function.prototype.__defineGetter__("hash",function(){return"function "+this.name});Function.prototype.clone=function(parent){if(this.fn){var clone=new Function(this.name,this.fn)}else{var clone=new Function(this.name);clone.params=this.params.clone(parent,clone);clone.block=this.block.clone(parent,clone)}clone.lineno=this.lineno;clone.column=this.column;clone.filename=this.filename;return clone};Function.prototype.toString=function(){if(this.fn){return this.name+"("+this.fn.toString().match(/^function *\w*\((.*?)\)/).slice(1).join(", ")+")"}else{return this.name+"("+this.params.nodes.join(", ")+")"}};Function.prototype.toJSON=function(){var json={__type:"Function",name:this.name,lineno:this.lineno,column:this.column,filename:this.filename};if(this.fn){json.fn=this.fn}else{json.params=this.params;json.block=this.block}return json}});require.register("nodes/group.js",function(module,exports,require){var Node=require("./node");var Group=module.exports=function Group(){Node.call(this);this.nodes=[];this.extends=[]};Group.prototype.__proto__=Node.prototype;Group.prototype.push=function(selector){this.nodes.push(selector)};Group.prototype.__defineGetter__("block",function(){return this.nodes[0].block});Group.prototype.__defineSetter__("block",function(block){for(var i=0,len=this.nodes.length;i=":case"<":case">":case"is a":case"||":case"&&":return this.rgba.operate(op,right);default:return this.rgba.operate(op,right).hsla}};exports.fromRGBA=function(rgba){var r=rgba.r/255,g=rgba.g/255,b=rgba.b/255,a=rgba.a;var min=Math.min(r,g,b),max=Math.max(r,g,b),l=(max+min)/2,d=max-min,h,s;switch(max){case min:h=0;break;case r:h=60*(g-b)/d;break;case g:h=60*(b-r)/d+120;break;case b:h=60*(r-g)/d+240;break}if(max==min){s=0}else if(l<.5){s=d/(2*l)}else{s=d/(2-2*l)}h%=360;s*=100;l*=100;return new HSLA(h,s,l,a)};HSLA.prototype.adjustLightness=function(percent){this.l=clampPercentage(this.l+this.l*(percent/100));return this};HSLA.prototype.adjustHue=function(deg){this.h=clampDegrees(this.h+deg);return this};function clampDegrees(n){n=n%360;return n>=0?n:360+n}function clampPercentage(n){return Math.max(0,Math.min(n,100))}function clampAlpha(n){return Math.max(0,Math.min(n,1))}});require.register("nodes/ident.js",function(module,exports,require){var Node=require("./node"),nodes=require("./index");var Ident=module.exports=function Ident(name,val,mixin){Node.call(this);this.name=name;this.string=name;this.val=val||nodes.nil;this.mixin=!!mixin};Ident.prototype.__defineGetter__("isEmpty",function(){return undefined==this.val});Ident.prototype.__defineGetter__("hash",function(){return this.name});Ident.prototype.__proto__=Node.prototype;Ident.prototype.clone=function(parent){var clone=new Ident(this.name);clone.val=this.val.clone(parent,clone);clone.mixin=this.mixin;clone.lineno=this.lineno;clone.column=this.column;clone.filename=this.filename;clone.property=this.property;clone.rest=this.rest;return clone};Ident.prototype.toJSON=function(){return{__type:"Ident",name:this.name,val:this.val,mixin:this.mixin,property:this.property,rest:this.rest,lineno:this.lineno,column:this.column,filename:this.filename}};Ident.prototype.toString=function(){return this.name};Ident.prototype.coerce=function(other){switch(other.nodeName){case"ident":case"string":case"literal":return new Ident(other.string);case"unit":return new Ident(other.toString());default:return Node.prototype.coerce.call(this,other)}};Ident.prototype.operate=function(op,right){var val=right.first;switch(op){case"-":if("unit"==val.nodeName){var expr=new nodes.Expression;val=val.clone();val.val=-val.val;expr.push(this);expr.push(val);return expr}case"+":return new nodes.Ident(this.string+this.coerce(val).string)}return Node.prototype.operate.call(this,op,right)}});require.register("nodes/if.js",function(module,exports,require){var Node=require("./node");var If=module.exports=function If(cond,negate){Node.call(this);this.cond=cond;this.elses=[];if(negate&&negate.nodeName){this.block=negate}else{this.negate=negate}};If.prototype.__proto__=Node.prototype;If.prototype.clone=function(parent){var clone=new If;clone.cond=this.cond.clone(parent,clone);clone.block=this.block.clone(parent,clone); +clone.elses=this.elses.map(function(node){return node.clone(parent,clone)});clone.negate=this.negate;clone.postfix=this.postfix;clone.lineno=this.lineno;clone.column=this.column;clone.filename=this.filename;return clone};If.prototype.toJSON=function(){return{__type:"If",cond:this.cond,block:this.block,elses:this.elses,negate:this.negate,postfix:this.postfix,lineno:this.lineno,column:this.column,filename:this.filename}}});require.register("nodes/import.js",function(module,exports,require){var Node=require("./node");var Import=module.exports=function Import(expr,once){Node.call(this);this.path=expr;this.once=once||false};Import.prototype.__proto__=Node.prototype;Import.prototype.clone=function(parent){var clone=new Import;clone.path=this.path.nodeName?this.path.clone(parent,clone):this.path;clone.once=this.once;clone.mtime=this.mtime;clone.lineno=this.lineno;clone.column=this.column;clone.filename=this.filename;return clone};Import.prototype.toJSON=function(){return{__type:"Import",path:this.path,once:this.once,mtime:this.mtime,lineno:this.lineno,column:this.column,filename:this.filename}}});require.register("nodes/extend.js",function(module,exports,require){var Node=require("./node");var Extend=module.exports=function Extend(selectors){Node.call(this);this.selectors=selectors};Extend.prototype.__proto__=Node.prototype;Extend.prototype.clone=function(){return new Extend(this.selectors)};Extend.prototype.toString=function(){return"@extend "+this.selectors.join(", ")};Extend.prototype.toJSON=function(){return{__type:"Extend",selectors:this.selectors,lineno:this.lineno,column:this.column,filename:this.filename}}});require.register("nodes/index.js",function(module,exports,require){exports.Node=require("./node");exports.Root=require("./root");exports.Null=require("./null");exports.Each=require("./each");exports.If=require("./if");exports.Call=require("./call");exports.UnaryOp=require("./unaryop");exports.BinOp=require("./binop");exports.Ternary=require("./ternary");exports.Block=require("./block");exports.Unit=require("./unit");exports.String=require("./string");exports.HSLA=require("./hsla");exports.RGBA=require("./rgba");exports.Ident=require("./ident");exports.Group=require("./group");exports.Literal=require("./literal");exports.Boolean=require("./boolean");exports.Return=require("./return");exports.Media=require("./media");exports.QueryList=require("./query-list");exports.Query=require("./query");exports.Feature=require("./feature");exports.Params=require("./params");exports.Comment=require("./comment");exports.Keyframes=require("./keyframes");exports.Member=require("./member");exports.Charset=require("./charset");exports.Namespace=require("./namespace");exports.Import=require("./import");exports.Extend=require("./extend");exports.Object=require("./object");exports.Function=require("./function");exports.Property=require("./property");exports.Selector=require("./selector");exports.Expression=require("./expression");exports.Arguments=require("./arguments");exports.Atblock=require("./atblock");exports.Atrule=require("./atrule");exports.Supports=require("./supports");exports.yes=new exports.Boolean(true);exports.no=new exports.Boolean(false);exports.nil=new exports.Null});require.register("nodes/keyframes.js",function(module,exports,require){var Atrule=require("./atrule");var Keyframes=module.exports=function Keyframes(segs,prefix){Atrule.call(this,"keyframes");this.segments=segs;this.prefix=prefix||"official"};Keyframes.prototype.__proto__=Atrule.prototype;Keyframes.prototype.clone=function(parent){var clone=new Keyframes;clone.lineno=this.lineno;clone.column=this.column;clone.filename=this.filename;clone.segments=this.segments.map(function(node){return node.clone(parent,clone)});clone.prefix=this.prefix;clone.block=this.block.clone(parent,clone);return clone};Keyframes.prototype.toJSON=function(){return{__type:"Keyframes",segments:this.segments,prefix:this.prefix,block:this.block,lineno:this.lineno,column:this.column,filename:this.filename}};Keyframes.prototype.toString=function(){return"@keyframes "+this.segments.join("")}});require.register("nodes/literal.js",function(module,exports,require){var Node=require("./node"),nodes=require("./index");var Literal=module.exports=function Literal(str){Node.call(this);this.val=str;this.string=str;this.prefixed=false};Literal.prototype.__proto__=Node.prototype;Literal.prototype.__defineGetter__("hash",function(){return this.val});Literal.prototype.toString=function(){return this.val};Literal.prototype.coerce=function(other){switch(other.nodeName){case"ident":case"string":case"literal":return new Literal(other.string);default:return Node.prototype.coerce.call(this,other)}};Literal.prototype.operate=function(op,right){var val=right.first;switch(op){case"+":return new nodes.Literal(this.string+this.coerce(val).string);default:return Node.prototype.operate.call(this,op,right)}};Literal.prototype.toJSON=function(){return{__type:"Literal",val:this.val,string:this.string,prefixed:this.prefixed,lineno:this.lineno,column:this.column,filename:this.filename}}});require.register("nodes/media.js",function(module,exports,require){var Atrule=require("./atrule");var Media=module.exports=function Media(val){Atrule.call(this,"media");this.val=val};Media.prototype.__proto__=Atrule.prototype;Media.prototype.clone=function(parent){var clone=new Media;clone.val=this.val.clone(parent,clone);clone.block=this.block.clone(parent,clone);clone.lineno=this.lineno;clone.column=this.column;clone.filename=this.filename;return clone};Media.prototype.toJSON=function(){return{__type:"Media",val:this.val,block:this.block,lineno:this.lineno,column:this.column,filename:this.filename}};Media.prototype.toString=function(){return"@media "+this.val}});require.register("nodes/query-list.js",function(module,exports,require){var Node=require("./node");var QueryList=module.exports=function QueryList(){Node.call(this);this.nodes=[]};QueryList.prototype.__proto__=Node.prototype;QueryList.prototype.clone=function(parent){var clone=new QueryList;clone.lineno=this.lineno;clone.column=this.column;clone.filename=this.filename;for(var i=0;i=":return nodes.Boolean(this.hash>=right.hash);case"<=":return nodes.Boolean(this.hash<=right.hash);case">":return nodes.Boolean(this.hash>right.hash);case"<":return nodes.Boolean(this.hash1)--h;if(h*6<1)return m1+(m2-m1)*h*6;if(h*2<1)return m2;if(h*3<2)return m1+(m2-m1)*(2/3-h)*6;return m1}return new RGBA(r,g,b,a)};function clamp(n){return Math.max(0,Math.min(n.toFixed(0),255))}function clampAlpha(n){return Math.max(0,Math.min(n,1))}});require.register("nodes/root.js",function(module,exports,require){var Node=require("./node");var Root=module.exports=function Root(){this.nodes=[]};Root.prototype.__proto__=Node.prototype;Root.prototype.push=function(node){this.nodes.push(node)};Root.prototype.unshift=function(node){this.nodes.unshift(node)};Root.prototype.clone=function(){var clone=new Root;clone.lineno=this.lineno;clone.column=this.column;clone.filename=this.filename;this.nodes.forEach(function(node){clone.push(node.clone(clone,clone))});return clone};Root.prototype.toString=function(){return"[Root]"};Root.prototype.toJSON=function(){return{__type:"Root",nodes:this.nodes,lineno:this.lineno,column:this.column,filename:this.filename}}});require.register("nodes/selector.js",function(module,exports,require){var Block=require("./block"),Node=require("./node");var Selector=module.exports=function Selector(segs){Node.call(this);this.inherits=true;this.segments=segs;this.optional=false};Selector.prototype.__proto__=Node.prototype;Selector.prototype.toString=function(){return this.segments.join("")+(this.optional?" !optional":"")};Selector.prototype.__defineGetter__("isPlaceholder",function(){return this.val&&~this.val.substr(0,2).indexOf("$")});Selector.prototype.clone=function(parent){var clone=new Selector;clone.lineno=this.lineno;clone.column=this.column;clone.filename=this.filename;clone.inherits=this.inherits;clone.val=this.val;clone.segments=this.segments.map(function(node){return node.clone(parent,clone)});clone.optional=this.optional;return clone};Selector.prototype.toJSON=function(){return{__type:"Selector",inherits:this.inherits,segments:this.segments,optional:this.optional,val:this.val,lineno:this.lineno,column:this.column,filename:this.filename}}});require.register("nodes/string.js",function(module,exports,require){var Node=require("./node"),sprintf=require("../functions").s,utils=require("../utils"),nodes=require("./index");var String=module.exports=function String(val,quote){Node.call(this);this.val=val;this.string=val;this.prefixed=false;if(typeof quote!=="string"){this.quote="'"}else{this.quote=quote}};String.prototype.__proto__=Node.prototype;String.prototype.toString=function(){return this.quote+this.val+this.quote};String.prototype.clone=function(){var clone=new String(this.val,this.quote);clone.lineno=this.lineno;clone.column=this.column;clone.filename=this.filename;return clone};String.prototype.toJSON=function(){return{__type:"String",val:this.val,quote:this.quote,lineno:this.lineno,column:this.column,filename:this.filename}};String.prototype.toBoolean=function(){return nodes.Boolean(this.val.length)};String.prototype.coerce=function(other){switch(other.nodeName){case"string":return other;case"expression":return new String(other.nodes.map(function(node){return this.coerce(node).val},this).join(" "));default:return new String(other.toString())}};String.prototype.operate=function(op,right){switch(op){case"%":var expr=new nodes.Expression;expr.push(this);var args="expression"==right.nodeName?utils.unwrap(right).nodes:[right];return sprintf.apply(null,[expr].concat(args));case"+":var expr=new nodes.Expression;expr.push(new String(this.val+this.coerce(right).val));return expr;default:return Node.prototype.operate.call(this,op,right)}}});require.register("nodes/ternary.js",function(module,exports,require){var Node=require("./node");var Ternary=module.exports=function Ternary(cond,trueExpr,falseExpr){Node.call(this);this.cond=cond;this.trueExpr=trueExpr;this.falseExpr=falseExpr};Ternary.prototype.__proto__=Node.prototype;Ternary.prototype.clone=function(parent){var clone=new Ternary;clone.cond=this.cond.clone(parent,clone);clone.trueExpr=this.trueExpr.clone(parent,clone);clone.falseExpr=this.falseExpr.clone(parent,clone);clone.lineno=this.lineno;clone.column=this.column;clone.filename=this.filename;return clone};Ternary.prototype.toJSON=function(){return{__type:"Ternary",cond:this.cond,trueExpr:this.trueExpr,falseExpr:this.falseExpr,lineno:this.lineno,column:this.column,filename:this.filename}}});require.register("nodes/unaryop.js",function(module,exports,require){var Node=require("./node");var UnaryOp=module.exports=function UnaryOp(op,expr){Node.call(this);this.op=op;this.expr=expr};UnaryOp.prototype.__proto__=Node.prototype;UnaryOp.prototype.clone=function(parent){var clone=new UnaryOp(this.op);clone.expr=this.expr.clone(parent,clone);clone.lineno=this.lineno;clone.column=this.column;clone.filename=this.filename;return clone};UnaryOp.prototype.toJSON=function(){return{__type:"UnaryOp",op:this.op,expr:this.expr,lineno:this.lineno,column:this.column,filename:this.filename}}});require.register("nodes/unit.js",function(module,exports,require){var Node=require("./node"),nodes=require("./index");var FACTOR_TABLE={mm:{val:1,label:"mm"},cm:{val:10,label:"mm"},"in":{val:25.4,label:"mm"},pt:{val:25.4/72,label:"mm"},ms:{val:1,label:"ms"},s:{val:1e3,label:"ms"},Hz:{val:1,label:"Hz"},kHz:{val:1e3,label:"Hz"}};var Unit=module.exports=function Unit(val,type){Node.call(this);this.val=val;this.type=type};Unit.prototype.__proto__=Node.prototype;Unit.prototype.toBoolean=function(){return nodes.Boolean(this.type?true:this.val)};Unit.prototype.toString=function(){return this.val+(this.type||"")};Unit.prototype.clone=function(){var clone=new Unit(this.val,this.type);clone.lineno=this.lineno;clone.column=this.column;clone.filename=this.filename;return clone};Unit.prototype.toJSON=function(){return{__type:"Unit",val:this.val,type:this.type,lineno:this.lineno,column:this.column,filename:this.filename}};Unit.prototype.operate=function(op,right){var type=this.type||right.first.type;if("rgba"==right.nodeName||"hsla"==right.nodeName){return right.operate(op,this)}if(this.shouldCoerce(op)){right=right.first;if("%"!=this.type&&("-"==op||"+"==op)&&"%"==right.type){right=new Unit(this.val*(right.val/100),"%")}else{right=this.coerce(right)}switch(op){case"-":return new Unit(this.val-right.val,type);case"+":type=type||right.type=="%"&&right.type;return new Unit(this.val+right.val,type);case"/":return new Unit(this.val/right.val,type);case"*":return new Unit(this.val*right.val,type);case"%":return new Unit(this.val%right.val,type);case"**":return new Unit(Math.pow(this.val,right.val),type);case"..":case"...":var start=this.val,end=right.val,expr=new nodes.Expression,inclusive=".."==op;if(start=end:--start>end)}return expr}}return Node.prototype.operate.call(this,op,right)};Unit.prototype.coerce=function(other){if("unit"==other.nodeName){var a=this,b=other,factorA=FACTOR_TABLE[a.type],factorB=FACTOR_TABLE[b.type];if(factorA&&factorB&&factorA.label==factorB.label){var bVal=b.val*(factorB.val/factorA.val);return new nodes.Unit(bVal,a.type)}else{return new nodes.Unit(b.val,a.type)}}else if("string"==other.nodeName){if("%"==other.val)return new nodes.Unit(0,"%");var val=parseFloat(other.val);if(isNaN(val))Node.prototype.coerce.call(this,other);return new nodes.Unit(val)}else{return Node.prototype.coerce.call(this,other)}}});require.register("nodes/object.js",function(module,exports,require){var Node=require("./node"),nodes=require("./index"),nativeObj={}.constructor;var Object=module.exports=function Object(){Node.call(this);this.vals={}};Object.prototype.__proto__=Node.prototype;Object.prototype.set=function(key,val){this.vals[key]=val;return this};Object.prototype.__defineGetter__("length",function(){return nativeObj.keys(this.vals).length});Object.prototype.get=function(key){return this.vals[key]||nodes.nil};Object.prototype.has=function(key){return key in this.vals};Object.prototype.operate=function(op,right){switch(op){case".":case"[]":return this.get(right.hash);case"==":var vals=this.vals,a,b;if("object"!=right.nodeName||this.length!=right.length)return nodes.no;for(var key in vals){a=vals[key];b=right.vals[key];if(a.operate(op,b).isFalse)return nodes.no}return nodes.yes;case"!=":return this.operate("==",right).negate();default:return Node.prototype.operate.call(this,op,right)}};Object.prototype.toBoolean=function(){return nodes.Boolean(this.length)};Object.prototype.toBlock=function(){var str="{",key,val;for(key in this.vals){val=this.get(key);if("object"==val.first.nodeName){str+=key+" "+this.toBlock.call(val.first)}else{switch(key){case"@charset":str+=key+" "+val.first.toString()+";";break;default:str+=key+":"+val.toString().replace(/ , /g,"\\,")+";"}}}str+="}";return str};Object.prototype.clone=function(parent){var clone=new Object;clone.lineno=this.lineno;clone.column=this.column;clone.filename=this.filename;for(var key in this.vals){clone.vals[key]=this.vals[key].clone(parent,clone)}return clone};Object.prototype.toJSON=function(){return{__type:"Object",vals:this.vals,lineno:this.lineno,column:this.column,filename:this.filename}};Object.prototype.toString=function(){var obj={};for(var prop in this.vals){obj[prop]=this.vals[prop].toString()}return JSON.stringify(obj)}});require.register("nodes/supports.js",function(module,exports,require){var Atrule=require("./atrule");var Supports=module.exports=function Supports(condition){Atrule.call(this,"supports");this.condition=condition};Supports.prototype.__proto__=Atrule.prototype;Supports.prototype.clone=function(parent){var clone=new Supports;clone.condition=this.condition.clone(parent,clone);clone.block=this.block.clone(parent,clone);clone.lineno=this.lineno;clone.column=this.column;clone.filename=this.filename;return clone};Supports.prototype.toJSON=function(){return{__type:"Supports",condition:this.condition,block:this.block,lineno:this.lineno,column:this.column,filename:this.filename}};Supports.prototype.toString=function(){return"@supports "+this.condition}});require.register("nodes/member.js",function(module,exports,require){var Node=require("./node");var Member=module.exports=function Member(left,right){Node.call(this);this.left=left;this.right=right};Member.prototype.__proto__=Node.prototype;Member.prototype.clone=function(parent){var clone=new Member;clone.left=this.left.clone(parent,clone);clone.right=this.right.clone(parent,clone);if(this.val)clone.val=this.val.clone(parent,clone);clone.lineno=this.lineno;clone.column=this.column;clone.filename=this.filename;return clone};Member.prototype.toJSON=function(){var json={__type:"Member",left:this.left,right:this.right,lineno:this.lineno,column:this.column,filename:this.filename};if(this.val)json.val=this.val;return json};Member.prototype.toString=function(){return this.left.toString()+"."+this.right.toString()}});require.register("nodes/atblock.js",function(module,exports,require){var Node=require("./node");var Atblock=module.exports=function Atblock(){Node.call(this)};Atblock.prototype.__defineGetter__("nodes",function(){return this.block.nodes});Atblock.prototype.__proto__=Node.prototype;Atblock.prototype.clone=function(parent){var clone=new Atblock;clone.block=this.block.clone(parent,clone);clone.lineno=this.lineno;clone.column=this.column;clone.filename=this.filename;return clone};Atblock.prototype.toString=function(){return"@block"};Atblock.prototype.toJSON=function(){return{__type:"Atblock",block:this.block,lineno:this.lineno,column:this.column,fileno:this.fileno}}});require.register("nodes/atrule.js",function(module,exports,require){var Node=require("./node");var Atrule=module.exports=function Atrule(type){Node.call(this);this.type=type};Atrule.prototype.__proto__=Node.prototype;Atrule.prototype.__defineGetter__("hasOnlyProperties",function(){if(!this.block)return false;var nodes=this.block.nodes;for(var i=0,len=nodes.length;i","=",":","&","~","{","}",".","/"];var pseudoSelectors=["matches","not","dir","lang","any-link","link","visited","local-link","target","scope","hover","active","focus","drop","current","past","future","enabled","disabled","read-only","read-write","placeholder-shown","checked","indeterminate","valid","invalid","in-range","out-of-range","required","optional","user-error","root","empty","blank","nth-child","nth-last-child","first-child","last-child","only-child","nth-of-type","nth-last-of-type","first-of-type","last-of-type","only-of-type","nth-match","nth-last-match","nth-column","nth-last-column","first-line","first-letter","before","after","selection"]; +var Parser=module.exports=function Parser(str,options){var self=this;options=options||{};this.lexer=new Lexer(str,options);this.prefix=options.prefix||"";this.root=options.root||new nodes.Root;this.state=["root"];this.stash=[];this.parens=0;this.css=0;this.state.pop=function(){self.prevState=[].pop.call(this)}};Parser.prototype={constructor:Parser,currentState:function(){return this.state[this.state.length-1]},previousState:function(){return this.state[this.state.length-2]},parse:function(){var block=this.parent=this.root;while("eos"!=this.peek().type){this.skipWhitespace();if("eos"==this.peek().type)break;var stmt=this.statement();this.accept(";");if(!stmt)this.error("unexpected token {peek}, not allowed at the root level");block.push(stmt)}return block},error:function(msg){var type=this.peek().type,val=undefined==this.peek().val?"":" "+this.peek().toString();if(val.trim()==type.trim())val="";throw new errors.ParseError(msg.replace("{peek}",'"'+type+val+'"'))},accept:function(type){if(type==this.peek().type){return this.next()}},expect:function(type){if(type!=this.peek().type){this.error('expected "'+type+'", got {peek}')}return this.next()},next:function(){var tok=this.stash.length?this.stash.pop():this.lexer.next(),line=tok.lineno,column=tok.column||1;if(tok.val&&tok.val.nodeName){tok.val.lineno=line;tok.val.column=column}nodes.lineno=line;nodes.column=column;return tok},peek:function(){return this.lexer.peek()},lookahead:function(n){return this.lexer.lookahead(n)},isSelectorToken:function(n){var la=this.lookahead(n).type;switch(la){case"for":return this.bracketed;case"[":this.bracketed=true;return true;case"]":this.bracketed=false;return true;default:return~selectorTokens.indexOf(la)}},isPseudoSelector:function(n){var val=this.lookahead(n).val;return val&&~pseudoSelectors.indexOf(val.name)},lineContains:function(type){var i=1,la;while(la=this.lookahead(i++)){if(~["indent","outdent","newline","eos"].indexOf(la.type))return;if(type==la.type)return true}},selectorToken:function(){if(this.isSelectorToken(1)){if("{"==this.peek().type){if(!this.lineContains("}"))return;var i=0,la;while(la=this.lookahead(++i)){if("}"==la.type){if(i==2||i==3&&this.lookahead(i-1).type=="space")return;break}if(":"==la.type)return}}return this.next()}},skip:function(tokens){while(~tokens.indexOf(this.peek().type))this.next()},skipWhitespace:function(){this.skip(["space","indent","outdent","newline"])},skipNewlines:function(){while("newline"==this.peek().type)this.next()},skipSpaces:function(){while("space"==this.peek().type)this.next()},skipSpacesAndComments:function(){while("space"==this.peek().type||"comment"==this.peek().type)this.next()},looksLikeFunctionDefinition:function(i){return"indent"==this.lookahead(i).type||"{"==this.lookahead(i).type},looksLikeSelector:function(fromProperty){var i=1,brace;if(fromProperty&&":"==this.lookahead(i+1).type&&(this.lookahead(i+1).space||"indent"==this.lookahead(i+2).type))return false;while("ident"==this.lookahead(i).type&&"newline"==this.lookahead(i+1).type)i+=2;while(this.isSelectorToken(i)||","==this.lookahead(i).type){if("selector"==this.lookahead(i).type)return true;if("&"==this.lookahead(i+1).type)return true;if("."==this.lookahead(i).type&&"ident"==this.lookahead(i+1).type)return true;if("*"==this.lookahead(i).type&&"newline"==this.lookahead(i+1).type)return true;if(":"==this.lookahead(i).type&&":"==this.lookahead(i+1).type)return true;if(this.looksLikeAttributeSelector(i))return true;if(("="==this.lookahead(i).type||"function"==this.lookahead(i).type)&&"{"==this.lookahead(i+1).type)return false;if(":"==this.lookahead(i).type&&!this.isPseudoSelector(i+1)&&this.lineContains("."))return false;if("{"==this.lookahead(i).type)brace=true;else if("}"==this.lookahead(i).type)brace=false;if(brace&&":"==this.lookahead(i).type)return true;if("space"==this.lookahead(i).type&&"{"==this.lookahead(i+1).type)return true;if(":"==this.lookahead(i++).type&&!this.lookahead(i-1).space&&this.isPseudoSelector(i))return true;if(","==this.lookahead(i).type&&"newline"==this.lookahead(i+1).type)return true}if(","==this.lookahead(i).type&&"newline"==this.lookahead(i+1).type)return true;if("{"==this.lookahead(i).type&&"newline"==this.lookahead(i+1).type)return true;if(this.css){if(";"==this.lookahead(i).type||"}"==this.lookahead(i-1).type)return false}while(!~["indent","outdent","newline","for","if",";","}","eos"].indexOf(this.lookahead(i).type))++i;if("indent"==this.lookahead(i).type)return true},looksLikeAttributeSelector:function(n){var type=this.lookahead(n).type;if("="==type&&this.bracketed)return true;return("ident"==type||"string"==type)&&"]"==this.lookahead(n+1).type&&("newline"==this.lookahead(n+2).type||this.isSelectorToken(n+2))&&!this.lineContains(":")&&!this.lineContains("=")},looksLikeKeyframe:function(){var i=2,type;switch(this.lookahead(i).type){case"{":case"indent":case",":return true;case"newline":while("unit"==this.lookahead(++i).type||"newline"==this.lookahead(i).type);type=this.lookahead(i).type;return"indent"==type||"{"==type}},stateAllowsSelector:function(){switch(this.currentState()){case"root":case"atblock":case"selector":case"conditional":case"function":case"atrule":case"for":return true}},assignAtblock:function(expr){try{expr.push(this.atblock(expr))}catch(err){this.error("invalid right-hand side operand in assignment, got {peek}")}},statement:function(){var stmt=this.stmt(),state=this.prevState,block,op;if(this.allowPostfix){this.allowPostfix=false;state="expression"}switch(state){case"assignment":case"expression":case"function arguments":while(op=this.accept("if")||this.accept("unless")||this.accept("for")){switch(op.type){case"if":case"unless":stmt=new nodes.If(this.expression(),stmt);stmt.postfix=true;stmt.negate="unless"==op.type;this.accept(";");break;case"for":var key,val=this.id().name;if(this.accept(","))key=this.id().name;this.expect("in");var each=new nodes.Each(val,key,this.expression());block=new nodes.Block(this.parent,each);block.push(stmt);each.block=block;stmt=each}}}return stmt},stmt:function(){var type=this.peek().type;switch(type){case"keyframes":return this.keyframes();case"-moz-document":return this.mozdocument();case"comment":case"selector":case"extend":case"literal":case"charset":case"namespace":case"require":case"extend":case"media":case"atrule":case"ident":case"scope":case"supports":case"unless":return this[type]();case"function":return this.fun();case"import":return this.atimport();case"if":return this.ifstmt();case"for":return this.forin();case"return":return this.ret();case"{":return this.property();default:if(this.stateAllowsSelector()){switch(type){case"color":case"~":case">":case"<":case":":case"&":case"[":case".":case"/":return this.selector();case"+":return"function"==this.lookahead(2).type?this.functionCall():this.selector();case"*":return this.property();case"unit":if(this.looksLikeKeyframe())return this.selector();case"-":if("{"==this.lookahead(2).type)return this.property()}}var expr=this.expression();if(expr.isEmpty)this.error("unexpected {peek}");return expr}},block:function(node,scope){var delim,stmt,next,block=this.parent=new nodes.Block(this.parent,node);if(false===scope)block.scope=false;this.accept("newline");if(this.accept("{")){this.css++;delim="}";this.skipWhitespace()}else{delim="outdent";this.expect("indent")}while(delim!=this.peek().type){if(this.css){if(this.accept("newline")||this.accept("indent"))continue;stmt=this.statement();this.accept(";");this.skipWhitespace()}else{if(this.accept("newline"))continue;next=this.lookahead(2).type;if("indent"==this.peek().type&&("outdent"==next||"comment"==next)){this.accept("indent");continue}stmt=this.statement();this.accept(";")}if(!stmt)this.error("unexpected token {peek} in block");block.push(stmt)}if(this.css){this.skipWhitespace();this.expect("}");this.skipSpaces();this.css--}else{this.expect("outdent")}this.parent=block.parent;return block},comment:function(){var node=this.next().val;this.skipSpaces();return node},forin:function(){this.expect("for");var key,val=this.id().name;if(this.accept(","))key=this.id().name;this.expect("in");this.state.push("for");this.cond=true;var each=new nodes.Each(val,key,this.expression());this.cond=false;each.block=this.block(each,false);this.state.pop();return each},ret:function(){this.expect("return");var expr=this.expression();return expr.isEmpty?new nodes.Return:new nodes.Return(expr)},unless:function(){this.expect("unless");this.state.push("conditional");this.cond=true;var node=new nodes.If(this.expression(),true);this.cond=false;node.block=this.block(node,false);this.state.pop();return node},ifstmt:function(){this.expect("if");this.state.push("conditional");this.cond=true;var node=new nodes.If(this.expression()),cond,block;this.cond=false;node.block=this.block(node,false);this.skip(["newline","comment"]);while(this.accept("else")){if(this.accept("if")){this.cond=true;cond=this.expression();this.cond=false;block=this.block(node,false);node.elses.push(new nodes.If(cond,block))}else{node.elses.push(this.block(node,false));break}this.skip(["newline","comment"])}this.state.pop();return node},atblock:function(node){if(!node)this.expect("atblock");node=new nodes.Atblock;this.state.push("atblock");node.block=this.block(node,false);this.state.pop();return node},atrule:function(){var type=this.expect("atrule").val,node=new nodes.Atrule(type),tok;this.skipSpacesAndComments();node.segments=this.selectorParts();this.skipSpacesAndComments();tok=this.peek().type;if("indent"==tok||"{"==tok){this.state.push("atrule");node.block=this.block(node);this.state.pop()}return node},scope:function(){this.expect("scope");var selector=this.selectorParts().map(function(selector){return selector.val}).join("");this.selectorScope=selector.trim();return nodes.nil},supports:function(){this.expect("supports");var node=new nodes.Supports(this.supportsCondition());this.state.push("atrule");node.block=this.block(node);this.state.pop();return node},supportsCondition:function(){var node=this.supportsNegation()||this.supportsOp();if(!node){this.cond=true;node=this.expression();this.cond=false}return node},supportsNegation:function(){if(this.accept("not")){var node=new nodes.Expression;node.push(new nodes.Literal("not"));node.push(this.supportsFeature());return node}},supportsOp:function(){var feature=this.supportsFeature(),op,expr;if(feature){expr=new nodes.Expression;expr.push(feature);while(op=this.accept("&&")||this.accept("||")){expr.push(new nodes.Literal("&&"==op.val?"and":"or"));expr.push(this.supportsFeature())}return expr}},supportsFeature:function(){this.skipSpacesAndComments();if("("==this.peek().type){var la=this.lookahead(2).type;if("ident"==la||"{"==la){return this.feature()}else{this.expect("(");var node=new nodes.Expression;node.push(new nodes.Literal("("));node.push(this.supportsCondition());this.expect(")");node.push(new nodes.Literal(")"));this.skipSpacesAndComments();return node}}},extend:function(){var tok=this.expect("extend"),selectors=[],sel,node,arr;do{arr=this.selectorParts();if(!arr.length)continue;sel=new nodes.Selector(arr);selectors.push(sel);if("!"!==this.peek().type)continue;tok=this.lookahead(2);if("ident"!==tok.type||"optional"!==tok.val.name)continue;this.skip(["!","ident"]);sel.optional=true}while(this.accept(","));node=new nodes.Extend(selectors);node.lineno=tok.lineno;node.column=tok.column;return node},media:function(){this.expect("media");this.state.push("atrule");var media=new nodes.Media(this.queries());media.block=this.block(media);this.state.pop();return media},queries:function(){var queries=new nodes.QueryList,skip=["comment","newline","space"];do{this.skip(skip);queries.push(this.query());this.skip(skip)}while(this.accept(","));return queries},query:function(){var query=new nodes.Query,expr,pred,id;if("ident"==this.peek().type&&("."==this.lookahead(2).type||"["==this.lookahead(2).type)){this.cond=true;expr=this.expression();this.cond=false;query.push(new nodes.Feature(expr.nodes));return query}if(pred=this.accept("ident")||this.accept("not")){pred=new nodes.Literal(pred.val.string||pred.val);this.skipSpacesAndComments();if(id=this.accept("ident")){query.type=id.val;query.predicate=pred}else{query.type=pred}this.skipSpacesAndComments();if(!this.accept("&&"))return query}do{query.push(this.feature())}while(this.accept("&&"));return query},feature:function(){this.skipSpacesAndComments();this.expect("(");this.skipSpacesAndComments();var node=new nodes.Feature(this.interpolate());this.skipSpacesAndComments();this.accept(":");this.skipSpacesAndComments();this.inProperty=true;node.expr=this.expression();this.inProperty=false;this.skipSpacesAndComments();this.expect(")");this.skipSpacesAndComments();return node},mozdocument:function(){this.expect("-moz-document");var mozdocument=new nodes.Atrule("-moz-document"),calls=[];do{this.skipSpacesAndComments();calls.push(this.functionCall());this.skipSpacesAndComments()}while(this.accept(","));mozdocument.segments=[new nodes.Literal(calls.join(", "))];this.state.push("atrule");mozdocument.block=this.block(mozdocument,false);this.state.pop();return mozdocument},atimport:function(){this.expect("import");this.allowPostfix=true;return new nodes.Import(this.expression(),false)},require:function(){this.expect("require");this.allowPostfix=true;return new nodes.Import(this.expression(),true)},charset:function(){this.expect("charset");var str=this.expect("string").val;this.allowPostfix=true;return new nodes.Charset(str)},namespace:function(){var str,prefix;this.expect("namespace");this.skipSpacesAndComments();if(prefix=this.accept("ident")){prefix=prefix.val}this.skipSpacesAndComments();str=this.accept("string")||this.url();this.allowPostfix=true;return new nodes.Namespace(str,prefix)},keyframes:function(){var tok=this.expect("keyframes"),keyframes;this.skipSpacesAndComments();keyframes=new nodes.Keyframes(this.interpolate(),tok.val);this.skipSpacesAndComments();this.state.push("atrule");keyframes.block=this.block(keyframes);this.state.pop();return keyframes},literal:function(){return this.expect("literal").val},id:function(){var tok=this.expect("ident");this.accept("space");return tok.val},ident:function(){var i=2,la=this.lookahead(i).type;while("space"==la)la=this.lookahead(++i).type;switch(la){case"=":case"?=":case"-=":case"+=":case"*=":case"/=":case"%=":return this.assignment();case".":if("space"==this.lookahead(i-1).type)return this.selector();if(this._ident==this.peek())return this.id();while("="!=this.lookahead(++i).type&&!~["[",",","newline","indent","eos"].indexOf(this.lookahead(i).type));if("="==this.lookahead(i).type){this._ident=this.peek();return this.expression()}else if(this.looksLikeSelector()&&this.stateAllowsSelector()){return this.selector()}case"[":if(this._ident==this.peek())return this.id();while("]"!=this.lookahead(i++).type&&"selector"!=this.lookahead(i).type&&"eos"!=this.lookahead(i).type);if("="==this.lookahead(i).type){this._ident=this.peek();return this.expression()}else if(this.looksLikeSelector()&&this.stateAllowsSelector()){return this.selector()}case"-":case"+":case"/":case"*":case"%":case"**":case"&&":case"||":case">":case"<":case">=":case"<=":case"!=":case"==":case"?":case"in":case"is a":case"is defined":if(this._ident==this.peek()){return this.id()}else{this._ident=this.peek();switch(this.currentState()){case"for":case"selector":return this.property();case"root":case"atblock":case"atrule":return"["==la?this.subscript():this.selector();case"function":case"conditional":return this.looksLikeSelector()?this.selector():this.expression();default:return this.operand?this.id():this.expression()}}default:switch(this.currentState()){case"root":return this.selector();case"for":case"selector":case"function":case"conditional":case"atblock":case"atrule":return this.property();default:var id=this.id();if("interpolation"==this.previousState())id.mixin=true;return id}}},interpolate:function(){var node,segs=[],star;star=this.accept("*");if(star)segs.push(new nodes.Literal("*"));while(true){if(this.accept("{")){this.state.push("interpolation");segs.push(this.expression());this.expect("}");this.state.pop()}else if(node=this.accept("-")){segs.push(new nodes.Literal("-"))}else if(node=this.accept("ident")){segs.push(node.val)}else{break}}if(!segs.length)this.expect("ident");return segs},property:function(){if(this.looksLikeSelector(true))return this.selector();var ident=this.interpolate(),prop=new nodes.Property(ident),ret=prop;this.accept("space");if(this.accept(":"))this.accept("space");this.state.push("property");this.inProperty=true;prop.expr=this.list();if(prop.expr.isEmpty)ret=ident[0];this.inProperty=false;this.allowPostfix=true;this.state.pop();this.accept(";");return ret},selector:function(){var arr,group=new nodes.Group,scope=this.selectorScope,isRoot="root"==this.currentState(),selector;do{this.accept("newline");arr=this.selectorParts();if(isRoot&&scope)arr.unshift(new nodes.Literal(scope+" "));if(arr.length){selector=new nodes.Selector(arr);selector.lineno=arr[0].lineno;selector.column=arr[0].column;group.push(selector)}}while(this.accept(",")||this.accept("newline"));this.state.push("selector");group.block=this.block(group);this.state.pop();return group},selectorParts:function(){var tok,arr=[];while(tok=this.selectorToken()){switch(tok.type){case"{":this.skipSpaces();var expr=this.expression();this.skipSpaces();this.expect("}");arr.push(expr);break;case this.prefix&&".":var literal=new nodes.Literal(tok.val+this.prefix);literal.prefixed=true;arr.push(literal);break;case"comment":break;case"color":case"unit":arr.push(new nodes.Literal(tok.val.raw));break;case"space":arr.push(new nodes.Literal(" "));break;case"function":arr.push(new nodes.Literal(tok.val.name+"("));break;case"ident":arr.push(new nodes.Literal(tok.val.name||tok.val.string));break;default:arr.push(new nodes.Literal(tok.val));if(tok.space)arr.push(new nodes.Literal(" "))}}return arr},assignment:function(){var op,node,name=this.id().name;if(op=this.accept("=")||this.accept("?=")||this.accept("+=")||this.accept("-=")||this.accept("*=")||this.accept("/=")||this.accept("%=")){this.state.push("assignment");var expr=this.list();if(expr.isEmpty)this.assignAtblock(expr);node=new nodes.Ident(name,expr);this.state.pop();switch(op.type){case"?=":var defined=new nodes.BinOp("is defined",node),lookup=new nodes.Ident(name);node=new nodes.Ternary(defined,lookup,node);break;case"+=":case"-=":case"*=":case"/=":case"%=":node.val=new nodes.BinOp(op.type[0],new nodes.Ident(name),expr);break}}return node},fun:function(){var parens=1,i=2,tok;out:while(tok=this.lookahead(i++)){switch(tok.type){case"function":case"(":++parens;break;case")":if(!--parens)break out;break;case"eos":this.error('failed to find closing paren ")"')}}switch(this.currentState()){case"expression":return this.functionCall();default:return this.looksLikeFunctionDefinition(i)?this.functionDefinition():this.expression()}},url:function(){this.expect("function");this.state.push("function arguments");var args=this.args();this.expect(")");this.state.pop();return new nodes.Call("url",args)},functionCall:function(){var withBlock=this.accept("+");if("url"==this.peek().val.name)return this.url();var name=this.expect("function").val.name;this.state.push("function arguments");this.parens++;var args=this.args();this.expect(")");this.parens--;this.state.pop();var call=new nodes.Call(name,args);if(withBlock){this.state.push("function");call.block=this.block(call);this.state.pop()}return call},functionDefinition:function(){var name=this.expect("function").val.name;this.state.push("function params");this.skipWhitespace();var params=this.params();this.skipWhitespace();this.expect(")");this.state.pop();this.state.push("function");var fn=new nodes.Function(name,params);fn.block=this.block(fn);this.state.pop();return new nodes.Ident(name,fn)},params:function(){var tok,node,params=new nodes.Params;while(tok=this.accept("ident")){this.accept("space");params.push(node=tok.val);if(this.accept("...")){node.rest=true}else if(this.accept("=")){node.val=this.expression()}this.skipWhitespace();this.accept(",");this.skipWhitespace()}return params},args:function(){var args=new nodes.Arguments,keyword;do{if("ident"==this.peek().type&&":"==this.lookahead(2).type){keyword=this.next().val.string;this.expect(":");args.map[keyword]=this.expression()}else{args.push(this.expression())}}while(this.accept(","));return args},list:function(){var node=this.expression();while(this.accept(",")){if(node.isList){list.push(this.expression())}else{var list=new nodes.Expression(true);list.push(node);list.push(this.expression());node=list}}return node},expression:function(){var node,expr=new nodes.Expression;this.state.push("expression");while(node=this.negation()){if(!node)this.error("unexpected token {peek} in expression");expr.push(node)}this.state.pop();if(expr.nodes.length){expr.lineno=expr.nodes[0].lineno;expr.column=expr.nodes[0].column}return expr},negation:function(){if(this.accept("not")){return new nodes.UnaryOp("!",this.negation())}return this.ternary()},ternary:function(){var node=this.logical();if(this.accept("?")){var trueExpr=this.expression();this.expect(":");var falseExpr=this.expression();node=new nodes.Ternary(node,trueExpr,falseExpr)}return node},logical:function(){var op,node=this.typecheck();while(op=this.accept("&&")||this.accept("||")){node=new nodes.BinOp(op.type,node,this.typecheck())}return node},typecheck:function(){var op,node=this.equality();while(op=this.accept("is a")){this.operand=true;if(!node)this.error('illegal unary "'+op+'", missing left-hand operand');node=new nodes.BinOp(op.type,node,this.equality());this.operand=false}return node},equality:function(){var op,node=this.inop();while(op=this.accept("==")||this.accept("!=")){this.operand=true;if(!node)this.error('illegal unary "'+op+'", missing left-hand operand');node=new nodes.BinOp(op.type,node,this.inop());this.operand=false}return node},inop:function(){var node=this.relational();while(this.accept("in")){this.operand=true;if(!node)this.error('illegal unary "in", missing left-hand operand');node=new nodes.BinOp("in",node,this.relational());this.operand=false}return node},relational:function(){var op,node=this.range();while(op=this.accept(">=")||this.accept("<=")||this.accept("<")||this.accept(">")){this.operand=true;if(!node)this.error('illegal unary "'+op+'", missing left-hand operand');node=new nodes.BinOp(op.type,node,this.range());this.operand=false}return node},range:function(){var op,node=this.additive();if(op=this.accept("...")||this.accept("..")){this.operand=true;if(!node)this.error('illegal unary "'+op+'", missing left-hand operand');node=new nodes.BinOp(op.val,node,this.additive());this.operand=false}return node},additive:function(){var op,node=this.multiplicative();while(op=this.accept("+")||this.accept("-")){this.operand=true;node=new nodes.BinOp(op.type,node,this.multiplicative());this.operand=false}return node},multiplicative:function(){var op,node=this.defined();while(op=this.accept("**")||this.accept("*")||this.accept("/")||this.accept("%")){this.operand=true;if("/"==op&&this.inProperty&&!this.parens){this.stash.push(new Token("literal",new nodes.Literal("/")));this.operand=false;return node}else{if(!node)this.error('illegal unary "'+op+'", missing left-hand operand');node=new nodes.BinOp(op.type,node,this.defined());this.operand=false}}return node},defined:function(){var node=this.unary();if(this.accept("is defined")){if(!node)this.error('illegal unary "is defined", missing left-hand operand');node=new nodes.BinOp("is defined",node)}return node},unary:function(){var op,node;if(op=this.accept("!")||this.accept("~")||this.accept("+")||this.accept("-")){this.operand=true;node=this.unary();if(!node)this.error('illegal unary "'+op+'"');node=new nodes.UnaryOp(op.type,node);this.operand=false;return node}return this.subscript()},subscript:function(){var node=this.member(),id;while(this.accept("[")){node=new nodes.BinOp("[]",node,this.expression());this.expect("]")}if(this.accept("=")){node.op+="=";node.val=this.list();if(node.val.isEmpty)this.assignAtblock(node.val)}return node},member:function(){var node=this.primary();if(node){while(this.accept(".")){var id=new nodes.Ident(this.expect("ident").val.string);node=new nodes.Member(node,id)}this.skipSpaces();if(this.accept("=")){node.val=this.list();if(node.val.isEmpty)this.assignAtblock(node.val)}}return node},object:function(){var obj=new nodes.Object,id,val,comma;this.expect("{");this.skipWhitespace();while(!this.accept("}")){if(this.accept("comment")||this.accept("newline"))continue;if(!comma)this.accept(",");id=this.accept("ident")||this.accept("string");if(!id)this.error('expected "ident" or "string", got {peek}');id=id.val.hash;this.skipSpacesAndComments();this.expect(":");val=this.expression();obj.set(id,val);comma=this.accept(",");this.skipWhitespace()}return obj},primary:function(){var tok;this.skipSpacesAndComments();if(this.accept("(")){++this.parens;var expr=this.expression(),paren=this.expect(")");--this.parens;if(this.accept("%"))expr.push(new nodes.Ident("%"));tok=this.peek();if(!paren.space&&"ident"==tok.type&&~units.indexOf(tok.val.string)){expr.push(new nodes.Ident(tok.val.string));this.next()}return expr}tok=this.peek();switch(tok.type){case"null":case"unit":case"color":case"string":case"literal":case"boolean":return this.next().val;case!this.cond&&"{":return this.object();case"atblock":return this.atblock();case"atrule":var id=new nodes.Ident(this.next().val);id.property=true;return id;case"ident":return this.ident();case"function":return tok.anonymous?this.functionDefinition():this.functionCall()}}}});require.register("renderer.js",function(module,exports,require){var Parser=require("./parser"),Evaluator=require("./visitor/evaluator"),Normalizer=require("./visitor/normalizer"),utils=require("./utils"),nodes=require("./nodes"),join=require("./path").join;module.exports=Renderer;function Renderer(str,options){options=options||{};options.globals=options.globals||{};options.functions=options.functions||{};options.use=options.use||[];options.use=Array.isArray(options.use)?options.use:[options.use];options.imports=[];options.paths=options.paths||[];options.filename=options.filename||"stylus";options.Evaluator=options.Evaluator||Evaluator;this.options=options;this.str=str}Renderer.prototype.render=function(fn){var parser=this.parser=new Parser(this.str,this.options);for(var i=0,len=this.options.use.length;i-1){return n.toString().replace("0.",".")+type}}return(float?parseFloat(n.toFixed(15)):n).toString()+type};Compiler.prototype.visitGroup=function(group){var stack=this.keyframe?[]:this.stack,comma=this.compress?",":",\n";stack.push(group.nodes);if(group.block.hasProperties){var selectors=utils.compileSelectors.call(this,stack),len=selectors.length;if(len){if(this.keyframe)comma=this.compress?",":", ";for(var i=0;i200){throw new RangeError("Maximum stylus call stack size exceeded")}if("expression"==fn.nodeName)fn=fn.first;this.ret++;var args=this.visit(call.args);for(var key in args.map){args.map[key]=this.visit(args.map[key].clone())}this.ret--;if(fn.fn){ret=this.invokeBuiltin(fn.fn,args)}else if("function"==fn.nodeName){if(call.block)call.block=this.visit(call.block);ret=this.invokeFunction(fn,args,call.block)}this.calling.pop();this.ignoreColors=false;return ret};Evaluator.prototype.visitIdent=function(ident){var prop;if(ident.property){if(prop=this.lookupProperty(ident.name)){return this.visit(prop.expr.clone())}return nodes.nil}else if(ident.val.isNull){var val=this.lookup(ident.name);if(val&&ident.mixin)this.mixinNode(val);return val?this.visit(val):ident}else{this.ret++;ident.val=this.visit(ident.val);this.ret--;this.currentScope.add(ident);return ident.val}};Evaluator.prototype.visitBinOp=function(binop){if("is defined"==binop.op)return this.isDefined(binop.left);this.ret++;var op=binop.op,left=this.visit(binop.left),right="||"==op||"&&"==op?binop.right:this.visit(binop.right);var val=binop.val?this.visit(binop.val):null;this.ret--;try{return this.visit(left.operate(op,right,val))}catch(err){if("CoercionError"==err.name){switch(op){case"==":return nodes.no;case"!=":return nodes.yes}}throw err}};Evaluator.prototype.visitUnaryOp=function(unary){var op=unary.op,node=this.visit(unary.expr);if("!"!=op){node=node.first.clone();utils.assertType(node,"unit")}switch(op){case"-":node.val=-node.val;break;case"+":node.val=+node.val;break;case"~":node.val=~node.val;break;case"!":return node.toBoolean().negate()}return node};Evaluator.prototype.visitTernary=function(ternary){var ok=this.visit(ternary.cond).toBoolean();return ok.isTrue?this.visit(ternary.trueExpr):this.visit(ternary.falseExpr)};Evaluator.prototype.visitExpression=function(expr){for(var i=0,len=expr.nodes.length;i1){for(var i=0;i0&&!~part.indexOf("&")){part="/"+part}s=new nodes.Selector([new nodes.Literal(part)]);s.val=part;s.block=group.block;group.nodes[i++]=s}});stack.push(group.nodes);var selectors=utils.compileSelectors(stack,true);selectors.forEach(function(selector){map[selector]=map[selector]||[];map[selector].push(group)});this.extend(group,selectors);stack.pop();return group};Normalizer.prototype.visitFunction=function(){return nodes.nil};Normalizer.prototype.visitMedia=function(media){var medias=[],group=this.closestGroup(media.block),parent;function mergeQueries(block){block.nodes.forEach(function(node,i){switch(node.nodeName){case"media":node.val=media.val.merge(node.val);medias.push(node);block.nodes[i]=nodes.nil;break;case"block":mergeQueries(node);break;default:if(node.block&&node.block.nodes)mergeQueries(node.block)}})}mergeQueries(media.block);this.bubble(media);if(medias.length){medias.forEach(function(node){if(group){group.block.push(node)}else{this.root.nodes.splice(++this.rootIndex,0,node)}node=this.visit(node);parent=node.block.parent;if(node.bubbled&&(!group||"group"==parent.node.nodeName)){node.group.block=node.block.nodes[0].block;node.block.nodes[0]=node.group}},this)}return media};Normalizer.prototype.visitSupports=function(node){this.bubble(node);return node};Normalizer.prototype.visitAtrule=function(node){if(node.block)node.block=this.visit(node.block);return node};Normalizer.prototype.visitKeyframes=function(node){var frames=node.block.nodes.filter(function(frame){return frame.block&&frame.block.hasProperties});node.frames=frames.length;return node};Normalizer.prototype.visitImport=function(node){this.imports.push(node);return this.hoist?nodes.nil:node};Normalizer.prototype.visitCharset=function(node){this.charset=node;return this.hoist?nodes.nil:node};Normalizer.prototype.extend=function(group,selectors){var map=this.map,self=this,parent=this.closestGroup(group.block);group.extends.forEach(function(extend){var groups=map[extend.selector];if(!groups){if(extend.optional)return;var err=new Error('Failed to @extend "'+extend.selector+'"');err.lineno=extend.lineno;err.column=extend.column;throw err}selectors.forEach(function(selector){var node=new nodes.Selector;node.val=selector;node.inherits=false;groups.forEach(function(group){if(!parent||parent!=group)self.extend(group,selectors);group.push(node)})})});group.block=this.visit(group.block)}});return require("stylus")}();