less 1.2.21 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (165) hide show
  1. data/.gitignore +4 -3
  2. data/.gitmodules +6 -0
  3. data/Gemfile +3 -0
  4. data/README.md +39 -46
  5. data/Rakefile +5 -50
  6. data/bin/lessc +1 -100
  7. data/less.gemspec +21 -125
  8. data/lib/less.rb +11 -30
  9. data/{LICENSE → lib/less/js/LICENSE} +1 -1
  10. data/lib/less/js/Makefile +56 -0
  11. data/lib/less/js/README.md +20 -0
  12. data/lib/less/js/benchmark/benchmark.less +3979 -0
  13. data/lib/less/js/benchmark/less-benchmark.js +49 -0
  14. data/lib/less/js/bin/lessc +105 -0
  15. data/lib/less/js/build/ecma-5.js +120 -0
  16. data/lib/less/js/build/header.js +7 -0
  17. data/lib/less/js/build/require.js +7 -0
  18. data/lib/less/js/dist/less-1.0.44.js +2655 -0
  19. data/lib/less/js/dist/less-1.1.0.js +2695 -0
  20. data/lib/less/js/dist/less-1.1.0.min.js +16 -0
  21. data/lib/less/js/dist/less-1.1.1.js +2710 -0
  22. data/lib/less/js/dist/less-1.1.1.min.js +16 -0
  23. data/lib/less/js/dist/less-1.1.2.js +2712 -0
  24. data/lib/less/js/dist/less-1.1.2.min.js +16 -0
  25. data/lib/less/js/dist/less-1.1.3.js +2721 -0
  26. data/lib/less/js/dist/less-1.1.3.min.js +16 -0
  27. data/lib/less/js/lib/less/browser.js +369 -0
  28. data/lib/less/js/lib/less/functions.js +174 -0
  29. data/lib/less/js/lib/less/index.js +137 -0
  30. data/lib/less/js/lib/less/parser.js +1098 -0
  31. data/lib/less/js/lib/less/tree.js +13 -0
  32. data/lib/less/js/lib/less/tree/alpha.js +17 -0
  33. data/lib/less/js/lib/less/tree/anonymous.js +13 -0
  34. data/lib/less/js/lib/less/tree/call.js +45 -0
  35. data/lib/less/js/lib/less/tree/color.js +98 -0
  36. data/lib/less/js/lib/less/tree/comment.js +14 -0
  37. data/lib/less/js/lib/less/tree/dimension.js +34 -0
  38. data/lib/less/js/lib/less/tree/directive.js +33 -0
  39. data/lib/less/js/lib/less/tree/element.js +32 -0
  40. data/lib/less/js/lib/less/tree/expression.js +23 -0
  41. data/lib/less/js/lib/less/tree/import.js +77 -0
  42. data/lib/less/js/lib/less/tree/javascript.js +51 -0
  43. data/lib/less/js/lib/less/tree/keyword.js +9 -0
  44. data/lib/less/js/lib/less/tree/mixin.js +106 -0
  45. data/lib/less/js/lib/less/tree/operation.js +32 -0
  46. data/lib/less/js/lib/less/tree/quoted.js +29 -0
  47. data/lib/less/js/lib/less/tree/rule.js +38 -0
  48. data/lib/less/js/lib/less/tree/ruleset.js +179 -0
  49. data/lib/less/js/lib/less/tree/selector.js +28 -0
  50. data/lib/less/js/lib/less/tree/url.js +25 -0
  51. data/lib/less/js/lib/less/tree/value.js +24 -0
  52. data/lib/less/js/lib/less/tree/variable.js +24 -0
  53. data/lib/less/js/package.json +13 -0
  54. data/lib/less/js/test/css/colors.css +42 -0
  55. data/lib/less/js/test/css/comments.css +52 -0
  56. data/lib/less/js/test/css/css-3.css +42 -0
  57. data/lib/less/js/test/css/css-escapes.css +20 -0
  58. data/lib/less/js/test/css/css.css +82 -0
  59. data/lib/less/js/test/css/functions.css +30 -0
  60. data/{spec → lib/less/js/test}/css/import.css +4 -2
  61. data/lib/less/js/test/css/javascript.css +22 -0
  62. data/lib/less/js/test/css/lazy-eval.css +3 -0
  63. data/lib/less/js/test/css/media.css +21 -0
  64. data/lib/less/js/test/css/mixins-args.css +61 -0
  65. data/lib/less/js/test/css/mixins-closure.css +9 -0
  66. data/lib/less/js/test/css/mixins-nested.css +14 -0
  67. data/lib/less/js/test/css/mixins-pattern.css +49 -0
  68. data/lib/less/js/test/css/mixins.css +50 -0
  69. data/{spec → lib/less/js/test}/css/operations.css +20 -2
  70. data/{spec → lib/less/js/test}/css/parens.css +0 -0
  71. data/lib/less/js/test/css/rulesets.css +29 -0
  72. data/{spec → lib/less/js/test}/css/scope.css +6 -2
  73. data/lib/less/js/test/css/selectors.css +32 -0
  74. data/lib/less/js/test/css/strings.css +38 -0
  75. data/lib/less/js/test/css/variables.css +24 -0
  76. data/lib/less/js/test/css/whitespace.css +36 -0
  77. data/lib/less/js/test/less-test.js +75 -0
  78. data/{spec → lib/less/js/test}/less/colors.less +13 -2
  79. data/{spec → lib/less/js/test}/less/comments.less +19 -2
  80. data/{spec → lib/less/js/test}/less/css-3.less +4 -1
  81. data/lib/less/js/test/less/css-escapes.less +28 -0
  82. data/{spec → lib/less/js/test}/less/css.less +10 -18
  83. data/lib/less/js/test/less/functions.less +35 -0
  84. data/{spec → lib/less/js/test}/less/import.less +1 -1
  85. data/{spec → lib/less/js/test}/less/import/import-test-a.less +0 -0
  86. data/{spec → lib/less/js/test}/less/import/import-test-b.less +0 -0
  87. data/{spec → lib/less/js/test}/less/import/import-test-c.less +0 -0
  88. data/{spec → lib/less/js/test}/less/import/import-test-d.css +0 -0
  89. data/lib/less/js/test/less/javascript.less +27 -0
  90. data/{spec → lib/less/js/test}/less/lazy-eval.less +0 -0
  91. data/lib/less/js/test/less/media.less +25 -0
  92. data/lib/less/js/test/less/mixins-args.less +118 -0
  93. data/lib/less/js/test/less/mixins-closure.less +26 -0
  94. data/lib/less/js/test/less/mixins-nested.less +22 -0
  95. data/lib/less/js/test/less/mixins-pattern.less +96 -0
  96. data/{spec → lib/less/js/test}/less/mixins.less +8 -4
  97. data/{spec → lib/less/js/test}/less/operations.less +19 -0
  98. data/{spec → lib/less/js/test}/less/parens.less +0 -0
  99. data/{spec → lib/less/js/test}/less/rulesets.less +2 -2
  100. data/{spec → lib/less/js/test}/less/scope.less +1 -1
  101. data/{spec → lib/less/js/test}/less/selectors.less +1 -1
  102. data/lib/less/js/test/less/strings.less +49 -0
  103. data/lib/less/js/test/less/variables.less +50 -0
  104. data/{spec → lib/less/js/test}/less/whitespace.less +3 -0
  105. data/lib/less/loader.rb +67 -0
  106. data/lib/less/parser.rb +46 -0
  107. data/lib/less/version.rb +3 -0
  108. data/spec/less/one/one.less +1 -0
  109. data/spec/less/parser_spec.rb +30 -0
  110. data/spec/less/two/two.less +1 -0
  111. data/spec/spec_helper.rb +2 -7
  112. metadata +156 -106
  113. data/CHANGELOG +0 -62
  114. data/VERSION +0 -1
  115. data/lib/less/command.rb +0 -110
  116. data/lib/less/engine.rb +0 -52
  117. data/lib/less/engine/grammar/common.tt +0 -29
  118. data/lib/less/engine/grammar/entity.tt +0 -144
  119. data/lib/less/engine/grammar/less.tt +0 -341
  120. data/lib/less/engine/nodes.rb +0 -9
  121. data/lib/less/engine/nodes/element.rb +0 -281
  122. data/lib/less/engine/nodes/entity.rb +0 -79
  123. data/lib/less/engine/nodes/function.rb +0 -93
  124. data/lib/less/engine/nodes/literal.rb +0 -171
  125. data/lib/less/engine/nodes/property.rb +0 -232
  126. data/lib/less/engine/nodes/ruleset.rb +0 -12
  127. data/lib/less/engine/nodes/selector.rb +0 -44
  128. data/lib/less/ext.rb +0 -60
  129. data/spec/command_spec.rb +0 -102
  130. data/spec/css/accessors.css +0 -18
  131. data/spec/css/big.css +0 -3768
  132. data/spec/css/colors.css +0 -14
  133. data/spec/css/comments.css +0 -9
  134. data/spec/css/css-3.css +0 -21
  135. data/spec/css/css.css +0 -50
  136. data/spec/css/dash-prefix.css +0 -12
  137. data/spec/css/functions.css +0 -6
  138. data/spec/css/import-with-extra-paths.css +0 -8
  139. data/spec/css/import-with-partial-in-extra-path.css +0 -6
  140. data/spec/css/lazy-eval.css +0 -1
  141. data/spec/css/mixins-args.css +0 -32
  142. data/spec/css/mixins.css +0 -28
  143. data/spec/css/rulesets.css +0 -17
  144. data/spec/css/selectors.css +0 -13
  145. data/spec/css/strings.css +0 -12
  146. data/spec/css/variables.css +0 -8
  147. data/spec/css/whitespace.css +0 -7
  148. data/spec/engine_spec.rb +0 -127
  149. data/spec/less/accessors.less +0 -20
  150. data/spec/less/big.less +0 -1264
  151. data/spec/less/dash-prefix.less +0 -21
  152. data/spec/less/exceptions/mixed-units-error.less +0 -3
  153. data/spec/less/exceptions/name-error-1.0.less +0 -3
  154. data/spec/less/exceptions/syntax-error-1.0.less +0 -3
  155. data/spec/less/extra_import_path/extra.less +0 -1
  156. data/spec/less/extra_import_path/import/import-test-a.css +0 -1
  157. data/spec/less/extra_import_path/import/import-test-a.less +0 -4
  158. data/spec/less/functions.less +0 -6
  159. data/spec/less/hidden.less +0 -25
  160. data/spec/less/import-with-extra-paths.less +0 -4
  161. data/spec/less/literal-css.less +0 -11
  162. data/spec/less/mixins-args.less +0 -59
  163. data/spec/less/strings.less +0 -14
  164. data/spec/less/variables.less +0 -29
  165. data/spec/spec.css +0 -50
@@ -0,0 +1,16 @@
1
+ //
2
+ // LESS - Leaner CSS v1.1.1
3
+ // http://lesscss.org
4
+ //
5
+ // Copyright (c) 2009-2011, Alexis Sellier
6
+ // Licensed under the Apache 2.0 License.
7
+ //
8
+ //
9
+ // LESS - Leaner CSS v1.1.1
10
+ // http://lesscss.org
11
+ //
12
+ // Copyright (c) 2009-2011, Alexis Sellier
13
+ // Licensed under the Apache 2.0 License.
14
+ //
15
+ (function(a,b){function v(a,b){var c="less-error-message:"+p(b),e=["<ul>",'<li><label>[-1]</label><pre class="ctx">{0}</pre></li>',"<li><label>[0]</label><pre>{current}</pre></li>",'<li><label>[1]</label><pre class="ctx">{2}</pre></li>',"</ul>"].join("\n"),f=document.createElement("div"),g,h;f.id=c,f.className="less-error-message",h="<h3>"+(a.message||"There is an error in your .less file")+"</h3>"+'<p><a href="'+b+'">'+b+"</a> ",a.extract&&(h+="on line "+a.line+", column "+(a.column+1)+":</p>"+e.replace(/\[(-?\d)\]/g,function(b,c){return parseInt(a.line)+parseInt(c)||""}).replace(/\{(\d)\}/g,function(b,c){return a.extract[parseInt(c)]||""}).replace(/\{current\}/,a.extract[1].slice(0,a.column)+'<span class="error">'+a.extract[1].slice(a.column)+"</span>")),f.innerHTML=h,q([".less-error-message ul, .less-error-message li {","list-style-type: none;","margin-right: 15px;","padding: 4px 0;","margin: 0;","}",".less-error-message label {","font-size: 12px;","margin-right: 15px;","padding: 4px 0;","color: #cc7777;","}",".less-error-message pre {","color: #ee4444;","padding: 4px 0;","margin: 0;","display: inline-block;","}",".less-error-message pre.ctx {","color: #dd4444;","}",".less-error-message h3 {","font-size: 20px;","font-weight: bold;","padding: 15px 0 5px 0;","margin: 0;","}",".less-error-message a {","color: #10a","}",".less-error-message .error {","color: red;","font-weight: bold;","padding-bottom: 2px;","border-bottom: 1px dashed red;","}"].join("\n"),{title:"error-message"}),f.style.cssText=["font-family: Arial, sans-serif","border: 1px solid #e00","background-color: #eee","border-radius: 5px","-webkit-border-radius: 5px","-moz-border-radius: 5px","color: #e00","padding: 15px","margin-bottom: 15px"].join(";"),d.env=="development"&&(g=setInterval(function(){document.body&&(document.getElementById(c)?document.body.replaceChild(f,document.getElementById(c)):document.body.insertBefore(f,document.body.firstChild),clearInterval(g))},10))}function u(a){d.env=="development"&&typeof console!="undefined"&&console.log("less: "+a)}function t(a){return a&&a.parentNode.removeChild(a)}function s(){if(a.XMLHttpRequest)return new XMLHttpRequest;try{return new ActiveXObject("MSXML2.XMLHTTP.3.0")}catch(b){u("browser doesn't support AJAX.");return null}}function r(a,b,c,e){function i(b,c,d){b.status>=200&&b.status<300?c(b.responseText,b.getResponseHeader("Last-Modified")):typeof d=="function"&&d(b.status,a)}var f=s(),h=g?!1:d.async;typeof f.overrideMimeType=="function"&&f.overrideMimeType("text/css"),f.open("GET",a,h),f.setRequestHeader("Accept",b||"text/x-less, text/css; q=0.9, */*; q=0.5"),f.send(null),g?f.status===0?c(f.responseText):e(f.status,a):h?f.onreadystatechange=function(){f.readyState==4&&i(f,c,e)}:i(f,c,e)}function q(a,b,c){var d,e=b.href?b.href.replace(/\?.*$/,""):"",f="less:"+(b.title||p(e));(d=document.getElementById(f))===null&&(d=document.createElement("style"),d.type="text/css",d.media=b.media||"screen",d.id=f,document.getElementsByTagName("head")[0].appendChild(d));if(d.styleSheet)try{d.styleSheet.cssText=a}catch(g){throw new Error("Couldn't reassign styleSheet.cssText.")}else(function(a){d.childNodes.length>0?d.firstChild.nodeValue!==a.nodeValue&&d.replaceChild(a,d.firstChild):d.appendChild(a)})(document.createTextNode(a));c&&h&&(u("saving "+e+" to cache."),h.setItem(e,a),h.setItem(e+":timestamp",c))}function p(a){return a.replace(/^[a-z]+:\/\/?[^\/]+/,"").replace(/^\//,"").replace(/\?.*$/,"").replace(/\.[^\.\/]+$/,"").replace(/[^\.\w-]+/g,"-").replace(/\./g,":")}function o(b,c,e,f){var g=a.location.href.replace(/[#?].*$/,""),i=b.href.replace(/\?.*$/,""),j=h&&h.getItem(i),k=h&&h.getItem(i+":timestamp"),l={css:j,timestamp:k};/^(https?|file):/.test(i)||(i.charAt(0)=="/"?i=a.location.protocol+"//"+a.location.host+i:i=g.slice(0,g.lastIndexOf("/")+1)+i),r(b.href,b.type,function(a,g){if(!e&&l&&g&&(new Date(g)).valueOf()===(new Date(l.timestamp)).valueOf())q(l.css,b),c(null,b,{local:!0,remaining:f});else try{(new d.Parser({optimization:d.optimization,paths:[i.replace(/[\w\.-]+$/,"")],mime:b.type})).parse(a,function(a,d){if(a)return v(a,i);try{c(d,b,{local:!1,lastModified:g,remaining:f}),t(document.getElementById("less-error-message:"+p(i)))}catch(a){v(a,i)}})}catch(h){v(h,i)}},function(a,b){throw new Error("Couldn't load "+b+" ("+a+")")})}function n(a,b){for(var c=0;c<d.sheets.length;c++)o(d.sheets[c],a,b,d.sheets.length-(c+1))}function m(){var a=document.getElementsByTagName("style");for(var b=0;b<a.length;b++)a[b].type.match(k)&&(new d.Parser).parse(a[b].innerHTML||"",function(c,d){a[b].type="text/css",a[b].innerHTML=d.toCSS()})}function c(b){return a.less[b.split("/")[1]]}Array.isArray||(Array.isArray=function(a){return Object.prototype.toString.call(a)==="[object Array]"||a instanceof Array}),Array.prototype.forEach||(Array.prototype.forEach=function(a,b){var c=this.length>>>0;for(var d=0;d<c;d++)d in this&&a.call(b,this[d],d,this)}),Array.prototype.map||(Array.prototype.map=function(a){var b=this.length>>>0,c=Array(b),d=arguments[1];for(var e=0;e<b;e++)e in this&&(c[e]=a.call(d,this[e],e,this));return c}),Array.prototype.filter||(Array.prototype.filter=function(a){var b=[],c=arguments[1];for(var d=0;d<this.length;d++)a.call(c,this[d])&&b.push(this[d]);return b}),Array.prototype.reduce||(Array.prototype.reduce=function(a){var b=this.length>>>0,c=0;if(b===0&&arguments.length===1)throw new TypeError;if(arguments.length>=2)var d=arguments[1];else for(;;){if(c in this){d=this[c++];break}if(++c>=b)throw new TypeError}for(;c<b;c++)c in this&&(d=a.call(null,d,this[c],c,this));return d}),Array.prototype.indexOf||(Array.prototype.indexOf=function(a){var b=this.length,c=arguments[1]||0;if(!b)return-1;if(c>=b)return-1;c<0&&(c+=b);for(;c<b;c++){if(!Object.prototype.hasOwnProperty.call(this,c))continue;if(a===this[c])return c}return-1}),Object.keys||(Object.keys=function(a){var b=[];for(var c in a)Object.prototype.hasOwnProperty.call(a,c)&&b.push(c);return b}),String.prototype.trim||(String.prototype.trim=function(){return String(this).replace(/^\s\s*/,"").replace(/\s\s*$/,"")});var d,e;typeof a=="undefined"?(d=exports,e=c("less/tree")):(typeof a.less=="undefined"&&(a.less={}),d=a.less,e=a.less.tree={}),d.Parser=function(a){function t(a){return typeof a=="string"?b.charAt(c)===a:a.test(j[f])?!0:!1}function s(a){var d,e,g,h,i,m,n,o;if(a instanceof Function)return a.call(l.parsers);if(typeof a=="string")d=b.charAt(c)===a?a:null,g=1,r();else{r();if(d=a.exec(j[f]))g=d[0].length;else return null}if(d){o=c+=g,m=c+j[f].length-g;while(c<m){h=b.charCodeAt(c);if(h!==32&&h!==10&&h!==9)break;c++}j[f]=j[f].slice(g+(c-o)),k=c,j[f].length===0&&f<j.length-1&&f++;return typeof d=="string"?d:d.length===1?d[0]:d}}function r(){c>k&&(j[f]=j[f].slice(c-k),k=c)}function q(){j[f]=g,c=h,k=c}function p(){g=j[f],h=c,k=c}var b,c,f,g,h,i,j,k,l,m=this,n=function(){},o=this.imports={paths:a&&a.paths||[],queue:[],files:{},mime:a&&a.mime,push:function(b,c){var e=this;this.queue.push(b),d.Parser.importer(b,this.paths,function(a){e.queue.splice(e.queue.indexOf(b),1),e.files[b]=a,c(a),e.queue.length===0&&n()},a)}};this.env=a=a||{},this.optimization="optimization"in this.env?this.env.optimization:1,this.env.filename=this.env.filename||null;return l={imports:o,parse:function(d,g){var h,l,m,o,p,q,r=[],t,u=null;c=f=k=i=0,j=[],b=d.replace(/\r\n/g,"\n"),j=function(c){var d=0,e=/[^"'`\{\}\/\(\)]+/g,f=/\/\*(?:[^*]|\*+[^\/*])*\*+\/|\/\/.*/g,g=0,h,i=c[0],j,k;for(var l=0,m,n;l<b.length;l++){e.lastIndex=l,(h=e.exec(b))&&h.index===l&&(l+=h[0].length,i.push(h[0])),m=b.charAt(l),f.lastIndex=l,!k&&!j&&m==="/"&&(n=b.charAt(l+1),(n==="/"||n==="*")&&(h=f.exec(b))&&h.index===l&&(l+=h[0].length,i.push(h[0]),m=b.charAt(l)));if(m==="{"&&!k&&!j)g++,i.push(m);else if(m==="}"&&!k&&!j)g--,i.push(m),c[++d]=i=[];else if(m==="("&&!k&&!j)i.push(m),j=!0;else if(m===")"&&!k&&j)i.push(m),j=!1;else{if(m==='"'||m==="'"||m==="`")k?k=k===m?!1:k:k=m;i.push(m)}}if(g>0)throw{type:"Syntax",message:"Missing closing `}`",filename:a.filename};return c.map(function(a){return a.join("")})}([[]]),h=new e.Ruleset([],s(this.parsers.primary)),h.root=!0,h.toCSS=function(c){var d,f,g;return function(g,h){function n(a){return a?(b.slice(0,a).match(/\n/g)||"").length:null}var i=[];g=g||{},typeof h=="object"&&!Array.isArray(h)&&(h=Object.keys(h).map(function(a){var b=h[a];b instanceof e.Value||(b instanceof e.Expression||(b=new e.Expression([b])),b=new e.Value([b]));return new e.Rule("@"+a,b,!1,0)}),i=[new e.Ruleset(null,h)]);try{var j=c.call(this,{frames:i}).toCSS([],{compress:g.compress||!1})}catch(k){f=b.split("\n"),d=n(k.index);for(var l=k.index,m=-1;l>=0&&b.charAt(l)!=="\n";l--)m++;throw{type:k.type,message:k.message,filename:a.filename,index:k.index,line:typeof d=="number"?d+1:null,callLine:k.call&&n(k.call)+1,callExtract:f[n(k.call)],stack:k.stack,column:m,extract:[f[d-1],f[d],f[d+1]]}}return g.compress?j.replace(/(\s)+/g,"$1"):j}}(h.eval);if(c<b.length-1){c=i,q=b.split("\n"),p=(b.slice(0,c).match(/\n/g)||"").length+1;for(var v=c,w=-1;v>=0&&b.charAt(v)!=="\n";v--)w++;u={name:"ParseError",message:"Syntax Error on line "+p,index:c,filename:a.filename,line:p,column:w,extract:[q[p-2],q[p-1],q[p]]}}this.imports.queue.length>0?n=function(){g(u,h)}:g(u,h)},parsers:{primary:function(){var a,b=[];while((a=s(this.mixin.definition)||s(this.rule)||s(this.ruleset)||s(this.mixin.call)||s(this.comment)||s(this.directive))||s(/^[\s\n]+/))a&&b.push(a);return b},comment:function(){var a;if(b.charAt(c)==="/"){if(b.charAt(c+1)==="/")return new e.Comment(s(/^\/\/.*/),!0);if(a=s(/^\/\*(?:[^*]|\*+[^\/*])*\*+\/\n?/))return new e.Comment(a)}},entities:{quoted:function(){var a,d=c,f;b.charAt(d)==="~"&&(d++,f=!0);if(b.charAt(d)==='"'||b.charAt(d)==="'"){f&&s("~");if(a=s(/^"((?:[^"\\\r\n]|\\.)*)"|'((?:[^'\\\r\n]|\\.)*)'/))return new e.Quoted(a[0],a[1]||a[2],f)}},keyword:function(){var a;if(a=s(/^[A-Za-z-]+/))return new e.Keyword(a)},call:function(){var a,b;if(!!(a=/^([\w-]+|%)\(/.exec(j[f]))){a=a[1].toLowerCase();if(a==="url")return null;c+=a.length;if(a==="alpha")return s(this.alpha);s("("),b=s(this.entities.arguments);if(!s(")"))return;if(a)return new e.Call(a,b)}},arguments:function(){var a=[],b;while(b=s(this.expression)){a.push(b);if(!s(","))break}return a},literal:function(){return s(this.entities.dimension)||s(this.entities.color)||s(this.entities.quoted)},url:function(){var a;if(b.charAt(c)==="u"&&!!s(/^url\(/)){a=s(this.entities.quoted)||s(this.entities.variable)||s(this.entities.dataURI)||s(/^[-\w%@$\/.&=:;#+?~]+/)||"";if(!s(")"))throw new Error("missing closing ) for url()");return new e.URL(a.value||a.data||a instanceof e.Variable?a:new e.Anonymous(a),o.paths)}},dataURI:function(){var a;if(s(/^data:/)){a={},a.mime=s(/^[^\/]+\/[^,;)]+/)||"",a.charset=s(/^;\s*charset=[^,;)]+/)||"",a.base64=s(/^;\s*base64/)||"",a.data=s(/^,\s*[^)]+/);if(a.data)return a}},variable:function(){var a,d=c;if(b.charAt(c)==="@"&&(a=s(/^@@?[\w-]+/)))return new e.Variable(a,d)},color:function(){var a;if(b.charAt(c)==="#"&&(a=s(/^#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})/)))return new e.Color(a[1])},dimension:function(){var a,d=b.charCodeAt(c);if(!(d>57||d<45||d===47))if(a=s(/^(-?\d*\.?\d+)(px|%|em|pc|ex|in|deg|s|ms|pt|cm|mm|rad|grad|turn)?/))return new e.Dimension(a[1],a[2])},javascript:function(){var a,d=c,f;b.charAt(d)==="~"&&(d++,f=!0);if(b.charAt(d)==="`"){f&&s("~");if(a=s(/^`([^`]*)`/))return new e.JavaScript(a[1],c,f)}}},variable:function(){var a;if(b.charAt(c)==="@"&&(a=s(/^(@[\w-]+)\s*:/)))return a[1]},shorthand:function(){var a,b;if(!!t(/^[@\w.%-]+\/[@\w.-]+/)&&(a=s(this.entity))&&s("/")&&(b=s(this.entity)))return new e.Shorthand(a,b)},mixin:{call:function(){var a=[],d,f,g,h=c,i=b.charAt(c);if(i==="."||i==="#"){while(d=s(/^[#.](?:[\w-]|\\(?:[a-fA-F0-9]{1,6} ?|[^a-fA-F0-9]))+/))a.push(new e.Element(f,d)),f=s(">");s("(")&&(g=s(this.entities.arguments))&&s(")");if(a.length>0&&(s(";")||t("}")))return new e.mixin.Call(a,g,h)}},definition:function(){var a,d=[],f,g,h,i;if(!(b.charAt(c)!=="."&&b.charAt(c)!=="#"||t(/^[^{]*(;|})/)))if(f=s(/^([#.](?:[\w-]|\\(?:[a-fA-F0-9]{1,6} ?|[^a-fA-F0-9]))+)\s*\(/)){a=f[1];while(h=s(this.entities.variable)||s(this.entities.literal)||s(this.entities.keyword)){if(h instanceof e.Variable)if(s(":"))if(i=s(this.expression))d.push({name:h.name,value:i});else throw new Error("Expected value");else d.push({name:h.name});else d.push({value:h});if(!s(","))break}if(!s(")"))throw new Error("Expected )");g=s(this.block);if(g)return new e.mixin.Definition(a,d,g)}}},entity:function(){return s(this.entities.literal)||s(this.entities.variable)||s(this.entities.url)||s(this.entities.call)||s(this.entities.keyword)||s(this.entities.javascript)||s(this.comment)},end:function(){return s(";")||t("}")},alpha:function(){var a;if(!!s(/^opacity=/i))if(a=s(/^\d+/)||s(this.entities.variable)){if(!s(")"))throw new Error("missing closing ) for alpha()");return new e.Alpha(a)}},element:function(){var a,b,c;c=s(this.combinator),a=s(/^(?:[.#]?|:*)(?:[\w-]|\\(?:[a-fA-F0-9]{1,6} ?|[^a-fA-F0-9]))+/)||s("*")||s(this.attribute)||s(/^\([^)@]+\)/);if(a)return new e.Element(c,a)},combinator:function(){var a,d=b.charAt(c);if(d===">"||d==="&"||d==="+"||d==="~"){c++;while(b.charAt(c)===" ")c++;return new e.Combinator(d)}if(d===":"&&b.charAt(c+1)===":"){c+=2;while(b.charAt(c)===" ")c++;return new e.Combinator("::")}return b.charAt(c-1)===" "?new e.Combinator(" "):new e.Combinator(null)},selector:function(){var a,d,f=[],g,h;while(d=s(this.element)){g=b.charAt(c),f.push(d);if(g==="{"||g==="}"||g===";"||g===",")break}if(f.length>0)return new e.Selector(f)},tag:function(){return s(/^[a-zA-Z][a-zA-Z-]*[0-9]?/)||s("*")},attribute:function(){var a="",b,c,d;if(!!s("[")){if(b=s(/^[a-zA-Z-]+/)||s(this.entities.quoted))(d=s(/^[|~*$^]?=/))&&(c=s(this.entities.quoted)||s(/^[\w-]+/))?a=[b,d,c.toCSS?c.toCSS():c].join(""):a=b;if(!s("]"))return;if(a)return"["+a+"]"}},block:function(){var a;if(s("{")&&(a=s(this.primary))&&s("}"))return a},ruleset:function(){var a=[],b,d,g;p();if(g=/^([.#: \w-]+)[\s\n]*\{/.exec(j[f]))c+=g[0].length-1,a=[new e.Selector([new e.Element(null,g[1])])];else while(b=s(this.selector)){a.push(b),s(this.comment);if(!s(","))break;s(this.comment)}if(a.length>0&&(d=s(this.block)))return new e.Ruleset(a,d);i=c,q()},rule:function(){var a,d,g=b.charAt(c),k,l;p();if(g!=="."&&g!=="#"&&g!=="&")if(a=s(this.variable)||s(this.property)){a.charAt(0)!="@"&&(l=/^([^@+\/'"*`(;{}-]*);/.exec(j[f]))?(c+=l[0].length-1,d=new e.Anonymous(l[1])):a==="font"?d=s(this.font):d=s(this.value),k=s(this.important);if(d&&s(this.end))return new e.Rule(a,d,k,h);i=c,q()}},"import":function(){var a;if(s(/^@import\s+/)&&(a=s(this.entities.quoted)||s(this.entities.url))&&s(";"))return new e.Import(a,o)},directive:function(){var a,d,f,g;if(b.charAt(c)==="@"){if(d=s(this["import"]))return d;if(a=s(/^@media|@page|@-[-a-z]+/)){g=(s(/^[^{]+/)||"").trim();if(f=s(this.block))return new e.Directive(a+" "+g,f)}else if(a=s(/^@[-a-z]+/))if(a==="@font-face"){if(f=s(this.block))return new e.Directive(a,f)}else if((d=s(this.entity))&&s(";"))return new e.Directive(a,d)}},font:function(){var a=[],b=[],c,d,f,g;while(g=s(this.shorthand)||s(this.entity))b.push(g);a.push(new e.Expression(b));if(s(","))while(g=s(this.expression)){a.push(g);if(!s(","))break}return new e.Value(a)},value:function(){var a,b=[],c;while(a=s(this.expression)){b.push(a);if(!s(","))break}if(b.length>0)return new e.Value(b)},important:function(){if(b.charAt(c)==="!")return s(/^! *important/)},sub:function(){var a;if(s("(")&&(a=s(this.expression))&&s(")"))return a},multiplication:function(){var a,b,c,d;if(a=s(this.operand)){while((c=s("/")||s("*"))&&(b=s(this.operand)))d=new e.Operation(c,[d||a,b]);return d||a}},addition:function(){var a,d,f,g;if(a=s(this.multiplication)){while((f=s(/^[-+]\s+/)||b.charAt(c-1)!=" "&&(s("+")||s("-")))&&(d=s(this.multiplication)))g=new e.Operation(f,[g||a,d]);return g||a}},operand:function(){var a,d=b.charAt(c+1);b.charAt(c)==="-"&&(d==="@"||d==="(")&&(a=s("-"));var f=s(this.sub)||s(this.entities.dimension)||s(this.entities.color)||s(this.entities.variable)||s(this.entities.call);return a?new e.Operation("*",[new e.Dimension(-1),f]):f},expression:function(){var a,b,c=[],d;while(a=s(this.addition)||s(this.entity))c.push(a);if(c.length>0)return new e.Expression(c)},property:function(){var a;if(a=s(/^(\*?-?[-a-z_0-9]+)\s*:/))return a[1]}}}},typeof a!="undefined"&&(d.Parser.importer=function(a,b,c,d){a.charAt(0)!=="/"&&b.length>0&&(a=b[0]+a),o({href:a,title:a,type:d.mime},c,!0)}),function(a){function d(a){return Math.min(1,Math.max(0,a))}function c(b){if(b instanceof a.Dimension)return parseFloat(b.unit=="%"?b.value/100:b.value);if(typeof b=="number")return b;throw{error:"RuntimeError",message:"color functions take numbers as parameters"}}function b(b){return a.functions.hsla(b.h,b.s,b.l,b.a)}a.functions={rgb:function(a,b,c){return this.rgba(a,b,c,1)},rgba:function(b,d,e,f){var g=[b,d,e].map(function(a){return c(a)}),f=c(f);return new a.Color(g,f)},hsl:function(a,b,c){return this.hsla(a,b,c,1)},hsla:function(a,b,d,e){function h(a){a=a<0?a+1:a>1?a-1:a;return a*6<1?g+(f-g)*a*6:a*2<1?f:a*3<2?g+(f-g)*(2/3-a)*6:g}a=c(a)%360/360,b=c(b),d=c(d),e=c(e);var f=d<=.5?d*(b+1):d+b-d*b,g=d*2-f;return this.rgba(h(a+1/3)*255,h(a)*255,h(a-1/3)*255,e)},hue:function(b){return new a.Dimension(Math.round(b.toHSL().h))},saturation:function(b){return new a.Dimension(Math.round(b.toHSL().s*100),"%")},lightness:function(b){return new a.Dimension(Math.round(b.toHSL().l*100),"%")},alpha:function(b){return new a.Dimension(b.toHSL().a)},saturate:function(a,c){var e=a.toHSL();e.s+=c.value/100,e.s=d(e.s);return b(e)},desaturate:function(a,c){var e=a.toHSL();e.s-=c.value/100,e.s=d(e.s);return b(e)},lighten:function(a,c){var e=a.toHSL();e.l+=c.value/100,e.l=d(e.l);return b(e)},darken:function(a,c){var e=a.toHSL();e.l-=c.value/100,e.l=d(e.l);return b(e)},fadein:function(a,c){var e=a.toHSL();e.a+=c.value/100,e.a=d(e.a);return b(e)},fadeout:function(a,c){var e=a.toHSL();e.a-=c.value/100,e.a=d(e.a);return b(e)},spin:function(a,c){var d=a.toHSL(),e=(d.h+c.value)%360;d.h=e<0?360+e:e;return b(d)},mix:function(b,c,d){var e=d.value/100,f=e*2-1,g=b.toHSL().a-c.toHSL().a,h=((f*g==-1?f:(f+g)/(1+f*g))+1)/2,i=1-h,j=[b.rgb[0]*h+c.rgb[0]*i,b.rgb[1]*h+c.rgb[1]*i,b.rgb[2]*h+c.rgb[2]*i],k=b.alpha*e+c.alpha*(1-e);return new a.Color(j,k)},greyscale:function(b){return this.desaturate(b,new a.Dimension(100))},e:function(b){return new a.Anonymous(b instanceof a.JavaScript?b.evaluated:b)},escape:function(b){return new a.Anonymous(encodeURI(b.value).replace(/=/g,"%3D").replace(/:/g,"%3A").replace(/#/g,"%23").replace(/;/g,"%3B").replace(/\(/g,"%28").replace(/\)/g,"%29"))},"%":function(b){var c=Array.prototype.slice.call(arguments,1),d=b.value;for(var e=0;e<c.length;e++)d=d.replace(/%[sda]/i,function(a){var b=a.match(/s/i)?c[e].value:c[e].toCSS();return a.match(/[A-Z]$/)?encodeURIComponent(b):b});d=d.replace(/%%/g,"%");return new a.Quoted('"'+d+'"',d)},round:function(b){if(b instanceof a.Dimension)return new a.Dimension(Math.round(c(b)),b.unit);if(typeof b=="number")return Math.round(b);throw{error:"RuntimeError",message:"math functions take numbers as parameters"}}}}(c("less/tree")),function(a){a.Alpha=function(a){this.value=a},a.Alpha.prototype={toCSS:function(){return"alpha(opacity="+(this.value.toCSS?this.value.toCSS():this.value)+")"},eval:function(){return this}}}(c("less/tree")),function(a){a.Anonymous=function(a){this.value=a.value||a},a.Anonymous.prototype={toCSS:function(){return this.value},eval:function(){return this}}}(c("less/tree")),function(a){a.Call=function(a,b){this.name=a,this.args=b},a.Call.prototype={eval:function(b){var c=this.args.map(function(a){return a.eval(b)});return this.name in a.functions?a.functions[this.name].apply(a.functions,c):new a.Anonymous(this.name+"("+c.map(function(a){return a.toCSS()}).join(", ")+")")},toCSS:function(a){return this.eval(a).toCSS()}}}(c("less/tree")),function(a){a.Color=function(a,b){Array.isArray(a)?this.rgb=a:a.length==6?this.rgb=a.match(/.{2}/g).map(function(a){return parseInt(a,16)}):a.length==8?(this.alpha=parseInt(a.substring(0,2),16)/255,this.rgb=a.substr(2).match(/.{2}/g).map(function(a){return parseInt(a,16)})):this.rgb=a.split("").map(function(a){return parseInt(a+a,16)}),this.alpha=typeof b=="number"?b:1},a.Color.prototype={eval:function(){return this},toCSS:function(){return this.alpha<1?"rgba("+this.rgb.map(function(a){return Math.round(a)}).concat(this.alpha).join(", ")+")":"#"+this.rgb.map(function(a){a=Math.round(a),a=(a>255?255:a<0?0:a).toString(16);return a.length===1?"0"+a:a}).join("")},operate:function(b,c){var d=[];c instanceof a.Color||(c=c.toColor());for(var e=0;e<3;e++)d[e]=a.operate(b,this.rgb[e],c.rgb[e]);return new a.Color(d,this.alpha+c.alpha)},toHSL:function(){var a=this.rgb[0]/255,b=this.rgb[1]/255,c=this.rgb[2]/255,d=this.alpha,e=Math.max(a,b,c),f=Math.min(a,b,c),g,h,i=(e+f)/2,j=e-f;if(e===f)g=h=0;else{h=i>.5?j/(2-e-f):j/(e+f);switch(e){case a:g=(b-c)/j+(b<c?6:0);break;case b:g=(c-a)/j+2;break;case c:g=(a-b)/j+4}g/=6}return{h:g*360,s:h,l:i,a:d}}}}(c("less/tree")),function(a){a.Comment=function(a,b){this.value=a,this.silent=!!b},a.Comment.prototype={toCSS:function(a){return a.compress?"":this.value},eval:function(){return this}}}(c("less/tree")),function(a){a.Dimension=function(a,b){this.value=parseFloat(a),this.unit=b||null},a.Dimension.prototype={eval:function(){return this},toColor:function(){return new a.Color([this.value,this.value,this.value])},toCSS:function(){var a=this.value+this.unit;return a},operate:function(b,c){return new a.Dimension(a.operate(b,this.value,c.value),this.unit||c.unit)}}}(c("less/tree")),function(a){a.Directive=function(b,c){this.name=b,Array.isArray(c)?this.ruleset=new a.Ruleset([],c):this.value=c},a.Directive.prototype={toCSS:function(a,b){if(this.ruleset){this.ruleset.root=!0;return this.name+(b.compress?"{":" {\n ")+this.ruleset.toCSS(a,b).trim().replace(/\n/g,"\n ")+(b.compress?"}":"\n}\n")}return this.name+" "+this.value.toCSS()+";\n"},eval:function(a){a.frames.unshift(this),this.ruleset=this.ruleset&&this.ruleset.eval(a),a.frames.shift();return this},variable:function(b){return a.Ruleset.prototype.variable.call(this.ruleset,b)},find:function(){return a.Ruleset.prototype.find.apply(this.ruleset,arguments)},rulesets:function(){return a.Ruleset.prototype.rulesets.apply(this.ruleset)}}}(c("less/tree")),function(a){a.Element=function(b,c){this.combinator=b instanceof a.Combinator?b:new a.Combinator(b),this.value=c.trim()},a.Element.prototype.toCSS=function(a){return this.combinator.toCSS(a||{})+this.value},a.Combinator=function(a){a===" "?this.value=" ":this.value=a?a.trim():""},a.Combinator.prototype.toCSS=function(a){return{"":""," ":" ","&":"",":":" :","::":"::","+":a.compress?"+":" + ","~":a.compress?"~":" ~ ",">":a.compress?">":" > "}[this.value]}}(c("less/tree")),function(a){a.Expression=function(a){this.value=a},a.Expression.prototype={eval:function(b){return this.value.length>1?new a.Expression(this.value.map(function(a){return a.eval(b)})):this.value.length===1?this.value[0].eval(b):this},toCSS:function(a){return this.value.map(function(b){return b.toCSS(a)}).join(" ")}}}(c("less/tree")),function(a){a.Import=function(b,c){var d=this;this._path=b,b instanceof a.Quoted?this.path=/\.(le?|c)ss$/.test(b.value)?b.value:b.value+".less":this.path=b.value.value||b.value,this.css=/css$/.test(this.path),this.css||c.push(this.path,function(a){if(!a)throw new Error("Error parsing "+d.path);d.root=a})},a.Import.prototype={toCSS:function(){return this.css?"@import "+this._path.toCSS()+";\n":""},eval:function(b){var c;if(this.css)return this;c=new a.Ruleset(null,this.root.rules.slice(0));for(var d=0;d<c.rules.length;d++)c.rules[d]instanceof a.Import&&Array.prototype.splice.apply(c.rules,[d,1].concat(c.rules[d].eval(b)));return c.rules}}}(c("less/tree")),function(a){a.JavaScript=function(a,b,c){this.escaped=c,this.expression=a,this.index=b},a.JavaScript.prototype={eval:function(b){var c,d=this,e={},f=this.expression.replace(/@\{([\w-]+)\}/g,function(c,e){return a.jsify((new a.Variable("@"+e,d.index)).eval(b))});try{f=new Function("return ("+f+")")}catch(g){throw{message:"JavaScript evaluation error: `"+f+"`",index:this.index}}for(var h in b.frames[0].variables())e[h.slice(1)]={value:b.frames[0].variables()[h].value,toJS:function(){return this.value.eval(b).toCSS()}};try{c=f.call(e)}catch(g){throw{message:"JavaScript evaluation error: '"+g.name+": "+g.message+"'",index:this.index}}return typeof c=="string"?new a.Quoted('"'+c+'"',c,this.escaped,this.index):Array.isArray(c)?new a.Anonymous(c.join(", ")):new a.Anonymous(c)}}}(c("less/tree")),function(a){a.Keyword=function(a){this.value=a},a.Keyword.prototype={eval:function(){return this},toCSS:function(){return this.value}}}(c("less/tree")),function(a){a.mixin={},a.mixin.Call=function(b,c,d){this.selector=new a.Selector(b),this.arguments=c,this.index=d},a.mixin.Call.prototype={eval:function(a){var b,c=[],d=!1;for(var e=0;e<a.frames.length;e++)if((b=a.frames[e].find(this.selector)).length>0){for(var f=0;f<b.length;f++)if(b[f].match(this.arguments,a))try{Array.prototype.push.apply(c,b[f].eval(a,this.arguments).rules),d=!0}catch(g){throw{message:g.message,index:g.index,stack:g.stack,call:this.index}}if(d)return c;throw{message:"No matching definition was found for `"+this.selector.toCSS().trim()+"("+this.arguments.map(function(a){return a.toCSS()}).join(", ")+")`",index:this.index}}throw{message:this.selector.toCSS().trim()+" is undefined",index:this.index}}},a.mixin.Definition=function(b,c,d){this.name=b,this.selectors=[new a.Selector([new a.Element(null,b)])],this.params=c,this.arity=c.length,this.rules=d,this._lookups={},this.required=c.reduce(function(a,b){return!b.name||b.name&&!b.value?a+1:a},0),this.parent=a.Ruleset.prototype,this.frames=[]},a.mixin.Definition.prototype={toCSS:function(){return""},variable:function(a){return this.parent.variable.call(this,a)},variables:function(){return this.parent.variables.call(this)},find:function(){return this.parent.find.apply(this,arguments)},rulesets:function(){return this.parent.rulesets.apply(this)},eval:function(b,c){var d=new a.Ruleset(null,[]),e,f=[];for(var g=0,h;g<this.params.length;g++)if(this.params[g].name)if(h=c&&c[g]||this.params[g].value)d.rules.unshift(new a.Rule(this.params[g].name,h.eval(b)));else throw{message:"wrong number of arguments for "+this.name+" ("+c.length+" for "+this.arity+")"};for(var g=0;g<Math.max(this.params.length,c&&c.length);g++)f.push(c[g]||this.params[g].value);d.rules.unshift(new a.Rule("@arguments",(new a.Expression(f)).eval(b)));return(new a.Ruleset(null,this.rules.slice(0))).eval({frames:[this,d].concat(this.frames,b.frames)})},match:function(a,b){var c=a&&a.length||0,d;if(c<this.required)return!1;if(this.required>0&&c>this.params.length)return!1;d=Math.min(c,this.arity);for(var e=0;e<d;e++)if(!this.params[e].name&&a[e].eval(b).toCSS()!=this.params[e].value.eval(b).toCSS())return!1;return!0}}}(c("less/tree")),function(a){a.Operation=function(a,b){this.op=a.trim(),this.operands=b},a.Operation.prototype.eval=function(b){var c=this.operands[0].eval(b),d=this.operands[1].eval(b),e;if(c instanceof a.Dimension&&d instanceof a.Color)if(this.op==="*"||this.op==="+")e=d,d=c,c=e;else throw{name:"OperationError",message:"Can't substract or divide a color from a number"};return c.operate(this.op,d)},a.operate=function(a,b,c){switch(a){case"+":return b+c;case"-":return b-c;case"*":return b*c;case"/":return b/c}}}(c("less/tree")),function(a){a.Quoted=function(a,b,c,d){this.escaped=c,this.value=b||"",this.quote=a.charAt(0),this.index=d},a.Quoted.prototype={toCSS:function(){return this.escaped?this.value:this.quote+this.value+this.quote},eval:function(b){var c=this;this.value=this.value.replace(/`([^`]+)`/g,function(d,e){return(new a.JavaScript(e,c.index,!0)).eval(b).value}).replace(/@\{([\w-]+)\}/g,function(d,e){return(new a.Variable("@"+e,c.index)).eval(b).value});return this}}}(c("less/tree")),function(a){a.Rule=function(b,c,d,e){this.name=b,this.value=c instanceof a.Value?c:new a.Value([c]),this.important=d?" "+d.trim():"",this.index=e,b.charAt(0)==="@"?this.variable=!0:this.variable=!1},a.Rule.prototype.toCSS=function(a){return this.variable?"":this.name+(a.compress?":":": ")+this.value.toCSS(a)+this.important+";"},a.Rule.prototype.eval=function(b){return new a.Rule(this.name,this.value.eval(b),this.important,this.index)},a.Shorthand=function(a,b){this.a=a,this.b=b},a.Shorthand.prototype={toCSS:function(a){return this.a.toCSS(a)+"/"+this.b.toCSS(a)},eval:function(){return this}}}(c("less/tree")),function(a){a.Ruleset=function(a,b){this.selectors=a,this.rules=b,this._lookups={}},a.Ruleset.prototype={eval:function(b){var c=new a.Ruleset(this.selectors,this.rules.slice(0));c.root=this.root,b.frames.unshift(c);if(c.root)for(var d=0;d<c.rules.length;d++)c.rules[d]instanceof a.Import&&Array.prototype.splice.apply(c.rules,[d,1].concat(c.rules[d].eval(b)));for(var d=0;d<c.rules.length;d++)c.rules[d]instanceof a.mixin.Definition&&(c.rules[d].frames=b.frames.slice(0));for(var d=0;d<c.rules.length;d++)c.rules[d]instanceof a.mixin.Call&&Array.prototype.splice.apply(c.rules,[d,1].concat(c.rules[d].eval(b)));for(var d=0,e;d<c.rules.length;d++)e=c.rules[d],e instanceof a.mixin.Definition||(c.rules[d]=e.eval?e.eval(b):e);b.frames.shift();return c},match:function(a){return!a||a.length===0},variables:function(){return this._variables?this._variables:this._variables=this.rules.reduce(function(b,c){c instanceof a.Rule&&c.variable===!0&&(b[c.name]=c);return b},{})},variable:function(a){return this.variables()[a]},rulesets:function(){return this._rulesets?this._rulesets:this._rulesets=this.rules.filter(function(b){return b instanceof a.Ruleset||b instanceof a.mixin.Definition})},find:function(b,c){c=c||this;var d=[],e,f,g=b.toCSS();if(g in this._lookups)return this._lookups[g];this.rulesets().forEach(function(e){if(e!==c)for(var g=0;g<e.selectors.length;g++)if(f=b.match(e.selectors[g])){b.elements.length>1?Array.prototype.push.apply(d,e.find(new a.Selector(b.elements.slice(1)),c)):d.push(e);break}});return this._lookups[g]=d},toCSS:function(b,c){var d=[],e=[],f=[],g=[],h,i;if(!this.root)if(b.length===0)g=this.selectors.map(function(a){return[a]});else for(var j=0;j<this.selectors.length;j++)for(var k=0;k<b.length;k++)g.push(b[k].concat([this.selectors[j]]));for(var l=0;l<this.rules.length;l++)i=this.rules[l],i.rules||i instanceof a.Directive?f.push(i.toCSS(g,c)):i instanceof a.Comment?i.silent||(this.root?f.push(i.toCSS(c)):e.push(i.toCSS(c))):i.toCSS&&!i.variable?e.push(i.toCSS(c)):i.value&&!i.variable&&e.push(i.value.toString());f=f.join(""),this.root?d.push(e.join(c.compress?"":"\n")):e.length>0&&(h=g.map(function(a){return a.map(function(a){return a.toCSS(c)}).join("").trim()}).join(c.compress?",":g.length>3?",\n":", "),d.push(h,(c.compress?"{":" {\n ")+e.join(c.compress?"":"\n ")+(c.compress?"}":"\n}\n"))),d.push(f);return d.join("")+(c.compress?"\n":"")}}}(c("less/tree")),function(a){a.Selector=function(a){this.elements=a,this.elements[0].combinator.value===""&&(this.elements[0].combinator.value=" ")},a.Selector.prototype.match=function(a){return this.elements[0].value===a.elements[0].value?!0:!1},a.Selector.prototype.toCSS=function(a){if(this._css)return this._css;return this._css=this.elements.map(function(b){return typeof b=="string"?" "+b.trim():b.toCSS(a)}).join("")}}(c("less/tree")),function(b){b.URL=function(b,c){b.data?this.attrs=b:(!/^(?:https?:\/|file:\/|data:\/)?\//.test(b.value)&&c.length>0&&typeof a!="undefined"&&(b.value=c[0]+(b.value.charAt(0)==="/"?b.value.slice(1):b.value)),this.value=b,this.paths=c)},b.URL.prototype={toCSS:function(){return"url("+(this.attrs?"data:"+this.attrs.mime+this.attrs.charset+this.attrs.base64+this.attrs.data:this.value.toCSS())+")"},eval:function(a){return this.attrs?this:new b.URL(this.value.eval(a),this.paths)}}}(c("less/tree")),function(a){a.Value=function(a){this.value=a,this.is="value"},a.Value.prototype={eval:function(b){return this.value.length===1?this.value[0].eval(b):new a.Value(this.value.map(function(a){return a.eval(b)}))},toCSS:function(a){return this.value.map(function(b){return b.toCSS(a)}).join(a.compress?",":", ")}}}(c("less/tree")),function(a){a.Variable=function(a,b){this.name=a,this.index=b},a.Variable.prototype={eval:function(b){var c,d,e=this.name;e.indexOf("@@")==0&&(e="@"+(new a.Variable(e.slice(1))).eval(b).value);if(c=a.find(b.frames,function(a){if(d=a.variable(e))return d.value.eval(b)}))return c;throw{message:"variable "+e+" is undefined",index:this.index}}}}(c("less/tree"
16
+ )),c("less/tree").find=function(a,b){for(var c=0,d;c<a.length;c++)if(d=b.call(a,a[c]))return d;return null},c("less/tree").jsify=function(a){return Array.isArray(a.value)&&a.value.length>1?"["+a.value.map(function(a){return a.toCSS(!1)}).join(", ")+"]":a.toCSS(!1)};var g=location.protocol==="file:"||location.protocol==="chrome:"||location.protocol==="chrome-extension:"||location.protocol==="resource:";d.env=d.env||(location.hostname=="127.0.0.1"||location.hostname=="0.0.0.0"||location.hostname=="localhost"||location.port.length>0||g?"development":"production"),d.async=!1,d.poll=d.poll||(g?1e3:1500),d.watch=function(){return this.watchMode=!0},d.unwatch=function(){return this.watchMode=!1},d.env==="development"?(d.optimization=0,/!watch/.test(location.hash)&&d.watch(),d.watchTimer=setInterval(function(){d.watchMode&&n(function(a,b,c){a&&q(a.toCSS(),b,c.lastModified)})},d.poll)):d.optimization=3;var h;try{h=typeof a.localStorage=="undefined"?null:a.localStorage}catch(i){h=null}var j=document.getElementsByTagName("link"),k=/^text\/(x-)?less$/;d.sheets=[];for(var l=0;l<j.length;l++)(j[l].rel==="stylesheet/less"||j[l].rel.match(/stylesheet/)&&j[l].type.match(k))&&d.sheets.push(j[l]);d.refresh=function(a){var b,c;b=c=new Date,n(function(a,d,e){e.local?u("loading "+d.href+" from cache."):(u("parsed "+d.href+" successfully."),q(a.toCSS(),d,e.lastModified)),u("css for "+d.href+" generated in "+(new Date-c)+"ms"),e.remaining===0&&u("css generated in "+(new Date-b)+"ms"),c=new Date},a),m()},d.refreshStyles=m,d.refresh(d.env==="development")})(window)
@@ -0,0 +1,2712 @@
1
+ //
2
+ // LESS - Leaner CSS v1.1.2
3
+ // http://lesscss.org
4
+ //
5
+ // Copyright (c) 2009-2011, Alexis Sellier
6
+ // Licensed under the Apache 2.0 License.
7
+ //
8
+ (function (window, undefined) {
9
+ //
10
+ // Stub out `require` in the browser
11
+ //
12
+ function require(arg) {
13
+ return window.less[arg.split('/')[1]];
14
+ };
15
+
16
+
17
+ // ecma-5.js
18
+ //
19
+ // -- kriskowal Kris Kowal Copyright (C) 2009-2010 MIT License
20
+ // -- tlrobinson Tom Robinson
21
+ // dantman Daniel Friesen
22
+
23
+ //
24
+ // Array
25
+ //
26
+ if (!Array.isArray) {
27
+ Array.isArray = function(obj) {
28
+ return Object.prototype.toString.call(obj) === "[object Array]" ||
29
+ (obj instanceof Array);
30
+ };
31
+ }
32
+ if (!Array.prototype.forEach) {
33
+ Array.prototype.forEach = function(block, thisObject) {
34
+ var len = this.length >>> 0;
35
+ for (var i = 0; i < len; i++) {
36
+ if (i in this) {
37
+ block.call(thisObject, this[i], i, this);
38
+ }
39
+ }
40
+ };
41
+ }
42
+ if (!Array.prototype.map) {
43
+ Array.prototype.map = function(fun /*, thisp*/) {
44
+ var len = this.length >>> 0;
45
+ var res = new Array(len);
46
+ var thisp = arguments[1];
47
+
48
+ for (var i = 0; i < len; i++) {
49
+ if (i in this) {
50
+ res[i] = fun.call(thisp, this[i], i, this);
51
+ }
52
+ }
53
+ return res;
54
+ };
55
+ }
56
+ if (!Array.prototype.filter) {
57
+ Array.prototype.filter = function (block /*, thisp */) {
58
+ var values = [];
59
+ var thisp = arguments[1];
60
+ for (var i = 0; i < this.length; i++) {
61
+ if (block.call(thisp, this[i])) {
62
+ values.push(this[i]);
63
+ }
64
+ }
65
+ return values;
66
+ };
67
+ }
68
+ if (!Array.prototype.reduce) {
69
+ Array.prototype.reduce = function(fun /*, initial*/) {
70
+ var len = this.length >>> 0;
71
+ var i = 0;
72
+
73
+ // no value to return if no initial value and an empty array
74
+ if (len === 0 && arguments.length === 1) throw new TypeError();
75
+
76
+ if (arguments.length >= 2) {
77
+ var rv = arguments[1];
78
+ } else {
79
+ do {
80
+ if (i in this) {
81
+ rv = this[i++];
82
+ break;
83
+ }
84
+ // if array contains no values, no initial value to return
85
+ if (++i >= len) throw new TypeError();
86
+ } while (true);
87
+ }
88
+ for (; i < len; i++) {
89
+ if (i in this) {
90
+ rv = fun.call(null, rv, this[i], i, this);
91
+ }
92
+ }
93
+ return rv;
94
+ };
95
+ }
96
+ if (!Array.prototype.indexOf) {
97
+ Array.prototype.indexOf = function (value /*, fromIndex */ ) {
98
+ var length = this.length;
99
+ var i = arguments[1] || 0;
100
+
101
+ if (!length) return -1;
102
+ if (i >= length) return -1;
103
+ if (i < 0) i += length;
104
+
105
+ for (; i < length; i++) {
106
+ if (!Object.prototype.hasOwnProperty.call(this, i)) { continue }
107
+ if (value === this[i]) return i;
108
+ }
109
+ return -1;
110
+ };
111
+ }
112
+
113
+ //
114
+ // Object
115
+ //
116
+ if (!Object.keys) {
117
+ Object.keys = function (object) {
118
+ var keys = [];
119
+ for (var name in object) {
120
+ if (Object.prototype.hasOwnProperty.call(object, name)) {
121
+ keys.push(name);
122
+ }
123
+ }
124
+ return keys;
125
+ };
126
+ }
127
+
128
+ //
129
+ // String
130
+ //
131
+ if (!String.prototype.trim) {
132
+ String.prototype.trim = function () {
133
+ return String(this).replace(/^\s\s*/, '').replace(/\s\s*$/, '');
134
+ };
135
+ }
136
+ var less, tree;
137
+
138
+ if (typeof(window) === 'undefined') {
139
+ less = exports,
140
+ tree = require('less/tree');
141
+ } else {
142
+ if (typeof(window.less) === 'undefined') { window.less = {} }
143
+ less = window.less,
144
+ tree = window.less.tree = {};
145
+ }
146
+ //
147
+ // less.js - parser
148
+ //
149
+ // A relatively straight-forward predictive parser.
150
+ // There is no tokenization/lexing stage, the input is parsed
151
+ // in one sweep.
152
+ //
153
+ // To make the parser fast enough to run in the browser, several
154
+ // optimization had to be made:
155
+ //
156
+ // - Matching and slicing on a huge input is often cause of slowdowns.
157
+ // The solution is to chunkify the input into smaller strings.
158
+ // The chunks are stored in the `chunks` var,
159
+ // `j` holds the current chunk index, and `current` holds
160
+ // the index of the current chunk in relation to `input`.
161
+ // This gives us an almost 4x speed-up.
162
+ //
163
+ // - In many cases, we don't need to match individual tokens;
164
+ // for example, if a value doesn't hold any variables, operations
165
+ // or dynamic references, the parser can effectively 'skip' it,
166
+ // treating it as a literal.
167
+ // An example would be '1px solid #000' - which evaluates to itself,
168
+ // we don't need to know what the individual components are.
169
+ // The drawback, of course is that you don't get the benefits of
170
+ // syntax-checking on the CSS. This gives us a 50% speed-up in the parser,
171
+ // and a smaller speed-up in the code-gen.
172
+ //
173
+ //
174
+ // Token matching is done with the `$` function, which either takes
175
+ // a terminal string or regexp, or a non-terminal function to call.
176
+ // It also takes care of moving all the indices forwards.
177
+ //
178
+ //
179
+ less.Parser = function Parser(env) {
180
+ var input, // LeSS input string
181
+ i, // current index in `input`
182
+ j, // current chunk
183
+ temp, // temporarily holds a chunk's state, for backtracking
184
+ memo, // temporarily holds `i`, when backtracking
185
+ furthest, // furthest index the parser has gone to
186
+ chunks, // chunkified input
187
+ current, // index of current chunk, in `input`
188
+ parser;
189
+
190
+ var that = this;
191
+
192
+ // This function is called after all files
193
+ // have been imported through `@import`.
194
+ var finish = function () {};
195
+
196
+ var imports = this.imports = {
197
+ paths: env && env.paths || [], // Search paths, when importing
198
+ queue: [], // Files which haven't been imported yet
199
+ files: {}, // Holds the imported parse trees
200
+ mime: env && env.mime, // MIME type of .less files
201
+ push: function (path, callback) {
202
+ var that = this;
203
+ this.queue.push(path);
204
+
205
+ //
206
+ // Import a file asynchronously
207
+ //
208
+ less.Parser.importer(path, this.paths, function (root) {
209
+ that.queue.splice(that.queue.indexOf(path), 1); // Remove the path from the queue
210
+ that.files[path] = root; // Store the root
211
+
212
+ callback(root);
213
+
214
+ if (that.queue.length === 0) { finish() } // Call `finish` if we're done importing
215
+ }, env);
216
+ }
217
+ };
218
+
219
+ function save() { temp = chunks[j], memo = i, current = i }
220
+ function restore() { chunks[j] = temp, i = memo, current = i }
221
+
222
+ function sync() {
223
+ if (i > current) {
224
+ chunks[j] = chunks[j].slice(i - current);
225
+ current = i;
226
+ }
227
+ }
228
+ //
229
+ // Parse from a token, regexp or string, and move forward if match
230
+ //
231
+ function $(tok) {
232
+ var match, args, length, c, index, endIndex, k, mem;
233
+
234
+ //
235
+ // Non-terminal
236
+ //
237
+ if (tok instanceof Function) {
238
+ return tok.call(parser.parsers);
239
+ //
240
+ // Terminal
241
+ //
242
+ // Either match a single character in the input,
243
+ // or match a regexp in the current chunk (chunk[j]).
244
+ //
245
+ } else if (typeof(tok) === 'string') {
246
+ match = input.charAt(i) === tok ? tok : null;
247
+ length = 1;
248
+ sync ();
249
+ } else {
250
+ sync ();
251
+
252
+ if (match = tok.exec(chunks[j])) {
253
+ length = match[0].length;
254
+ } else {
255
+ return null;
256
+ }
257
+ }
258
+
259
+ // The match is confirmed, add the match length to `i`,
260
+ // and consume any extra white-space characters (' ' || '\n')
261
+ // which come after that. The reason for this is that LeSS's
262
+ // grammar is mostly white-space insensitive.
263
+ //
264
+ if (match) {
265
+ mem = i += length;
266
+ endIndex = i + chunks[j].length - length;
267
+
268
+ while (i < endIndex) {
269
+ c = input.charCodeAt(i);
270
+ if (! (c === 32 || c === 10 || c === 9)) { break }
271
+ i++;
272
+ }
273
+ chunks[j] = chunks[j].slice(length + (i - mem));
274
+ current = i;
275
+
276
+ if (chunks[j].length === 0 && j < chunks.length - 1) { j++ }
277
+
278
+ if(typeof(match) === 'string') {
279
+ return match;
280
+ } else {
281
+ return match.length === 1 ? match[0] : match;
282
+ }
283
+ }
284
+ }
285
+
286
+ // Same as $(), but don't change the state of the parser,
287
+ // just return the match.
288
+ function peek(tok) {
289
+ if (typeof(tok) === 'string') {
290
+ return input.charAt(i) === tok;
291
+ } else {
292
+ if (tok.test(chunks[j])) {
293
+ return true;
294
+ } else {
295
+ return false;
296
+ }
297
+ }
298
+ }
299
+
300
+ this.env = env = env || {};
301
+
302
+ // The optimization level dictates the thoroughness of the parser,
303
+ // the lower the number, the less nodes it will create in the tree.
304
+ // This could matter for debugging, or if you want to access
305
+ // the individual nodes in the tree.
306
+ this.optimization = ('optimization' in this.env) ? this.env.optimization : 1;
307
+
308
+ this.env.filename = this.env.filename || null;
309
+
310
+ //
311
+ // The Parser
312
+ //
313
+ return parser = {
314
+
315
+ imports: imports,
316
+ //
317
+ // Parse an input string into an abstract syntax tree,
318
+ // call `callback` when done.
319
+ //
320
+ parse: function (str, callback) {
321
+ var root, start, end, zone, line, lines, buff = [], c, error = null;
322
+
323
+ i = j = current = furthest = 0;
324
+ chunks = [];
325
+ input = str.replace(/\r\n/g, '\n');
326
+
327
+ // Split the input into chunks.
328
+ chunks = (function (chunks) {
329
+ var j = 0,
330
+ skip = /[^"'`\{\}\/\(\)]+/g,
331
+ comment = /\/\*(?:[^*]|\*+[^\/*])*\*+\/|\/\/.*/g,
332
+ level = 0,
333
+ match,
334
+ chunk = chunks[0],
335
+ inParam,
336
+ inString;
337
+
338
+ for (var i = 0, c, cc; i < input.length; i++) {
339
+ skip.lastIndex = i;
340
+ if (match = skip.exec(input)) {
341
+ if (match.index === i) {
342
+ i += match[0].length;
343
+ chunk.push(match[0]);
344
+ }
345
+ }
346
+ c = input.charAt(i);
347
+ comment.lastIndex = i;
348
+
349
+ if (!inString && !inParam && c === '/') {
350
+ cc = input.charAt(i + 1);
351
+ if (cc === '/' || cc === '*') {
352
+ if (match = comment.exec(input)) {
353
+ if (match.index === i) {
354
+ i += match[0].length;
355
+ chunk.push(match[0]);
356
+ c = input.charAt(i);
357
+ }
358
+ }
359
+ }
360
+ }
361
+
362
+ if (c === '{' && !inString && !inParam) { level ++;
363
+ chunk.push(c);
364
+ } else if (c === '}' && !inString && !inParam) { level --;
365
+ chunk.push(c);
366
+ chunks[++j] = chunk = [];
367
+ } else if (c === '(' && !inString && !inParam) {
368
+ chunk.push(c);
369
+ inParam = true;
370
+ } else if (c === ')' && !inString && inParam) {
371
+ chunk.push(c);
372
+ inParam = false;
373
+ } else {
374
+ if (c === '"' || c === "'" || c === '`') {
375
+ if (! inString) {
376
+ inString = c;
377
+ } else {
378
+ inString = inString === c ? false : inString;
379
+ }
380
+ }
381
+ chunk.push(c);
382
+ }
383
+ }
384
+ if (level > 0) {
385
+ throw {
386
+ type: 'Syntax',
387
+ message: "Missing closing `}`",
388
+ filename: env.filename
389
+ };
390
+ }
391
+
392
+ return chunks.map(function (c) { return c.join('') });;
393
+ })([[]]);
394
+
395
+ // Start with the primary rule.
396
+ // The whole syntax tree is held under a Ruleset node,
397
+ // with the `root` property set to true, so no `{}` are
398
+ // output. The callback is called when the input is parsed.
399
+ root = new(tree.Ruleset)([], $(this.parsers.primary));
400
+ root.root = true;
401
+
402
+ root.toCSS = (function (evaluate) {
403
+ var line, lines, column;
404
+
405
+ return function (options, variables) {
406
+ var frames = [];
407
+
408
+ options = options || {};
409
+ //
410
+ // Allows setting variables with a hash, so:
411
+ //
412
+ // `{ color: new(tree.Color)('#f01') }` will become:
413
+ //
414
+ // new(tree.Rule)('@color',
415
+ // new(tree.Value)([
416
+ // new(tree.Expression)([
417
+ // new(tree.Color)('#f01')
418
+ // ])
419
+ // ])
420
+ // )
421
+ //
422
+ if (typeof(variables) === 'object' && !Array.isArray(variables)) {
423
+ variables = Object.keys(variables).map(function (k) {
424
+ var value = variables[k];
425
+
426
+ if (! (value instanceof tree.Value)) {
427
+ if (! (value instanceof tree.Expression)) {
428
+ value = new(tree.Expression)([value]);
429
+ }
430
+ value = new(tree.Value)([value]);
431
+ }
432
+ return new(tree.Rule)('@' + k, value, false, 0);
433
+ });
434
+ frames = [new(tree.Ruleset)(null, variables)];
435
+ }
436
+
437
+ try {
438
+ var css = evaluate.call(this, { frames: frames })
439
+ .toCSS([], { compress: options.compress || false });
440
+ } catch (e) {
441
+ lines = input.split('\n');
442
+ line = getLine(e.index);
443
+
444
+ for (var n = e.index, column = -1;
445
+ n >= 0 && input.charAt(n) !== '\n';
446
+ n--) { column++ }
447
+
448
+ throw {
449
+ type: e.type,
450
+ message: e.message,
451
+ filename: env.filename,
452
+ index: e.index,
453
+ line: typeof(line) === 'number' ? line + 1 : null,
454
+ callLine: e.call && (getLine(e.call) + 1),
455
+ callExtract: lines[getLine(e.call)],
456
+ stack: e.stack,
457
+ column: column,
458
+ extract: [
459
+ lines[line - 1],
460
+ lines[line],
461
+ lines[line + 1]
462
+ ]
463
+ };
464
+ }
465
+ if (options.compress) {
466
+ return css.replace(/(\s)+/g, "$1");
467
+ } else {
468
+ return css;
469
+ }
470
+
471
+ function getLine(index) {
472
+ return index ? (input.slice(0, index).match(/\n/g) || "").length : null;
473
+ }
474
+ };
475
+ })(root.eval);
476
+
477
+ // If `i` is smaller than the `input.length - 1`,
478
+ // it means the parser wasn't able to parse the whole
479
+ // string, so we've got a parsing error.
480
+ //
481
+ // We try to extract a \n delimited string,
482
+ // showing the line where the parse error occured.
483
+ // We split it up into two parts (the part which parsed,
484
+ // and the part which didn't), so we can color them differently.
485
+ if (i < input.length - 1) {
486
+ i = furthest;
487
+ lines = input.split('\n');
488
+ line = (input.slice(0, i).match(/\n/g) || "").length + 1;
489
+
490
+ for (var n = i, column = -1; n >= 0 && input.charAt(n) !== '\n'; n--) { column++ }
491
+
492
+ error = {
493
+ name: "ParseError",
494
+ message: "Syntax Error on line " + line,
495
+ index: i,
496
+ filename: env.filename,
497
+ line: line,
498
+ column: column,
499
+ extract: [
500
+ lines[line - 2],
501
+ lines[line - 1],
502
+ lines[line]
503
+ ]
504
+ };
505
+ }
506
+
507
+ if (this.imports.queue.length > 0) {
508
+ finish = function () { callback(error, root) };
509
+ } else {
510
+ callback(error, root);
511
+ }
512
+ },
513
+
514
+ //
515
+ // Here in, the parsing rules/functions
516
+ //
517
+ // The basic structure of the syntax tree generated is as follows:
518
+ //
519
+ // Ruleset -> Rule -> Value -> Expression -> Entity
520
+ //
521
+ // Here's some LESS code:
522
+ //
523
+ // .class {
524
+ // color: #fff;
525
+ // border: 1px solid #000;
526
+ // width: @w + 4px;
527
+ // > .child {...}
528
+ // }
529
+ //
530
+ // And here's what the parse tree might look like:
531
+ //
532
+ // Ruleset (Selector '.class', [
533
+ // Rule ("color", Value ([Expression [Color #fff]]))
534
+ // Rule ("border", Value ([Expression [Dimension 1px][Keyword "solid"][Color #000]]))
535
+ // Rule ("width", Value ([Expression [Operation "+" [Variable "@w"][Dimension 4px]]]))
536
+ // Ruleset (Selector [Element '>', '.child'], [...])
537
+ // ])
538
+ //
539
+ // In general, most rules will try to parse a token with the `$()` function, and if the return
540
+ // value is truly, will return a new node, of the relevant type. Sometimes, we need to check
541
+ // first, before parsing, that's when we use `peek()`.
542
+ //
543
+ parsers: {
544
+ //
545
+ // The `primary` rule is the *entry* and *exit* point of the parser.
546
+ // The rules here can appear at any level of the parse tree.
547
+ //
548
+ // The recursive nature of the grammar is an interplay between the `block`
549
+ // rule, which represents `{ ... }`, the `ruleset` rule, and this `primary` rule,
550
+ // as represented by this simplified grammar:
551
+ //
552
+ // primary → (ruleset | rule)+
553
+ // ruleset → selector+ block
554
+ // block → '{' primary '}'
555
+ //
556
+ // Only at one point is the primary rule not called from the
557
+ // block rule: at the root level.
558
+ //
559
+ primary: function () {
560
+ var node, root = [];
561
+
562
+ while ((node = $(this.mixin.definition) || $(this.rule) || $(this.ruleset) ||
563
+ $(this.mixin.call) || $(this.comment) || $(this.directive))
564
+ || $(/^[\s\n]+/)) {
565
+ node && root.push(node);
566
+ }
567
+ return root;
568
+ },
569
+
570
+ // We create a Comment node for CSS comments `/* */`,
571
+ // but keep the LeSS comments `//` silent, by just skipping
572
+ // over them.
573
+ comment: function () {
574
+ var comment;
575
+
576
+ if (input.charAt(i) !== '/') return;
577
+
578
+ if (input.charAt(i + 1) === '/') {
579
+ return new(tree.Comment)($(/^\/\/.*/), true);
580
+ } else if (comment = $(/^\/\*(?:[^*]|\*+[^\/*])*\*+\/\n?/)) {
581
+ return new(tree.Comment)(comment);
582
+ }
583
+ },
584
+
585
+ //
586
+ // Entities are tokens which can be found inside an Expression
587
+ //
588
+ entities: {
589
+ //
590
+ // A string, which supports escaping " and '
591
+ //
592
+ // "milky way" 'he\'s the one!'
593
+ //
594
+ quoted: function () {
595
+ var str, j = i, e;
596
+
597
+ if (input.charAt(j) === '~') { j++, e = true } // Escaped strings
598
+ if (input.charAt(j) !== '"' && input.charAt(j) !== "'") return;
599
+
600
+ e && $('~');
601
+
602
+ if (str = $(/^"((?:[^"\\\r\n]|\\.)*)"|'((?:[^'\\\r\n]|\\.)*)'/)) {
603
+ return new(tree.Quoted)(str[0], str[1] || str[2], e);
604
+ }
605
+ },
606
+
607
+ //
608
+ // A catch-all word, such as:
609
+ //
610
+ // black border-collapse
611
+ //
612
+ keyword: function () {
613
+ var k;
614
+ if (k = $(/^[A-Za-z-]+/)) { return new(tree.Keyword)(k) }
615
+ },
616
+
617
+ //
618
+ // A function call
619
+ //
620
+ // rgb(255, 0, 255)
621
+ //
622
+ // We also try to catch IE's `alpha()`, but let the `alpha` parser
623
+ // deal with the details.
624
+ //
625
+ // The arguments are parsed with the `entities.arguments` parser.
626
+ //
627
+ call: function () {
628
+ var name, args;
629
+
630
+ if (! (name = /^([\w-]+|%)\(/.exec(chunks[j]))) return;
631
+
632
+ name = name[1].toLowerCase();
633
+
634
+ if (name === 'url') { return null }
635
+ else { i += name.length }
636
+
637
+ if (name === 'alpha') { return $(this.alpha) }
638
+
639
+ $('('); // Parse the '(' and consume whitespace.
640
+
641
+ args = $(this.entities.arguments);
642
+
643
+ if (! $(')')) return;
644
+
645
+ if (name) { return new(tree.Call)(name, args) }
646
+ },
647
+ arguments: function () {
648
+ var args = [], arg;
649
+
650
+ while (arg = $(this.expression)) {
651
+ args.push(arg);
652
+ if (! $(',')) { break }
653
+ }
654
+ return args;
655
+ },
656
+ literal: function () {
657
+ return $(this.entities.dimension) ||
658
+ $(this.entities.color) ||
659
+ $(this.entities.quoted);
660
+ },
661
+
662
+ //
663
+ // Parse url() tokens
664
+ //
665
+ // We use a specific rule for urls, because they don't really behave like
666
+ // standard function calls. The difference is that the argument doesn't have
667
+ // to be enclosed within a string, so it can't be parsed as an Expression.
668
+ //
669
+ url: function () {
670
+ var value;
671
+
672
+ if (input.charAt(i) !== 'u' || !$(/^url\(/)) return;
673
+ value = $(this.entities.quoted) || $(this.entities.variable) ||
674
+ $(this.entities.dataURI) || $(/^[-\w%@$\/.&=:;#+?~]+/) || "";
675
+ if (! $(')')) throw new(Error)("missing closing ) for url()");
676
+
677
+ return new(tree.URL)((value.value || value.data || value instanceof tree.Variable)
678
+ ? value : new(tree.Anonymous)(value), imports.paths);
679
+ },
680
+
681
+ dataURI: function () {
682
+ var obj;
683
+
684
+ if ($(/^data:/)) {
685
+ obj = {};
686
+ obj.mime = $(/^[^\/]+\/[^,;)]+/) || '';
687
+ obj.charset = $(/^;\s*charset=[^,;)]+/) || '';
688
+ obj.base64 = $(/^;\s*base64/) || '';
689
+ obj.data = $(/^,\s*[^)]+/);
690
+
691
+ if (obj.data) { return obj }
692
+ }
693
+ },
694
+
695
+ //
696
+ // A Variable entity, such as `@fink`, in
697
+ //
698
+ // width: @fink + 2px
699
+ //
700
+ // We use a different parser for variable definitions,
701
+ // see `parsers.variable`.
702
+ //
703
+ variable: function () {
704
+ var name, index = i;
705
+
706
+ if (input.charAt(i) === '@' && (name = $(/^@@?[\w-]+/))) {
707
+ return new(tree.Variable)(name, index);
708
+ }
709
+ },
710
+
711
+ //
712
+ // A Hexadecimal color
713
+ //
714
+ // #4F3C2F
715
+ //
716
+ // `rgb` and `hsl` colors are parsed through the `entities.call` parser.
717
+ //
718
+ color: function () {
719
+ var rgb;
720
+
721
+ if (input.charAt(i) === '#' && (rgb = $(/^#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})/))) {
722
+ return new(tree.Color)(rgb[1]);
723
+ }
724
+ },
725
+
726
+ //
727
+ // A Dimension, that is, a number and a unit
728
+ //
729
+ // 0.5em 95%
730
+ //
731
+ dimension: function () {
732
+ var value, c = input.charCodeAt(i);
733
+ if ((c > 57 || c < 45) || c === 47) return;
734
+
735
+ if (value = $(/^(-?\d*\.?\d+)(px|%|em|pc|ex|in|deg|s|ms|pt|cm|mm|rad|grad|turn)?/)) {
736
+ return new(tree.Dimension)(value[1], value[2]);
737
+ }
738
+ },
739
+
740
+ //
741
+ // JavaScript code to be evaluated
742
+ //
743
+ // `window.location.href`
744
+ //
745
+ javascript: function () {
746
+ var str, j = i, e;
747
+
748
+ if (input.charAt(j) === '~') { j++, e = true } // Escaped strings
749
+ if (input.charAt(j) !== '`') { return }
750
+
751
+ e && $('~');
752
+
753
+ if (str = $(/^`([^`]*)`/)) {
754
+ return new(tree.JavaScript)(str[1], i, e);
755
+ }
756
+ }
757
+ },
758
+
759
+ //
760
+ // The variable part of a variable definition. Used in the `rule` parser
761
+ //
762
+ // @fink:
763
+ //
764
+ variable: function () {
765
+ var name;
766
+
767
+ if (input.charAt(i) === '@' && (name = $(/^(@[\w-]+)\s*:/))) { return name[1] }
768
+ },
769
+
770
+ //
771
+ // A font size/line-height shorthand
772
+ //
773
+ // small/12px
774
+ //
775
+ // We need to peek first, or we'll match on keywords and dimensions
776
+ //
777
+ shorthand: function () {
778
+ var a, b;
779
+
780
+ if (! peek(/^[@\w.%-]+\/[@\w.-]+/)) return;
781
+
782
+ if ((a = $(this.entity)) && $('/') && (b = $(this.entity))) {
783
+ return new(tree.Shorthand)(a, b);
784
+ }
785
+ },
786
+
787
+ //
788
+ // Mixins
789
+ //
790
+ mixin: {
791
+ //
792
+ // A Mixin call, with an optional argument list
793
+ //
794
+ // #mixins > .square(#fff);
795
+ // .rounded(4px, black);
796
+ // .button;
797
+ //
798
+ // The `while` loop is there because mixins can be
799
+ // namespaced, but we only support the child and descendant
800
+ // selector for now.
801
+ //
802
+ call: function () {
803
+ var elements = [], e, c, args, index = i, s = input.charAt(i);
804
+
805
+ if (s !== '.' && s !== '#') { return }
806
+
807
+ while (e = $(/^[#.](?:[\w-]|\\(?:[a-fA-F0-9]{1,6} ?|[^a-fA-F0-9]))+/)) {
808
+ elements.push(new(tree.Element)(c, e));
809
+ c = $('>');
810
+ }
811
+ $('(') && (args = $(this.entities.arguments)) && $(')');
812
+
813
+ if (elements.length > 0 && ($(';') || peek('}'))) {
814
+ return new(tree.mixin.Call)(elements, args, index);
815
+ }
816
+ },
817
+
818
+ //
819
+ // A Mixin definition, with a list of parameters
820
+ //
821
+ // .rounded (@radius: 2px, @color) {
822
+ // ...
823
+ // }
824
+ //
825
+ // Until we have a finer grained state-machine, we have to
826
+ // do a look-ahead, to make sure we don't have a mixin call.
827
+ // See the `rule` function for more information.
828
+ //
829
+ // We start by matching `.rounded (`, and then proceed on to
830
+ // the argument list, which has optional default values.
831
+ // We store the parameters in `params`, with a `value` key,
832
+ // if there is a value, such as in the case of `@radius`.
833
+ //
834
+ // Once we've got our params list, and a closing `)`, we parse
835
+ // the `{...}` block.
836
+ //
837
+ definition: function () {
838
+ var name, params = [], match, ruleset, param, value;
839
+
840
+ if ((input.charAt(i) !== '.' && input.charAt(i) !== '#') ||
841
+ peek(/^[^{]*(;|})/)) return;
842
+
843
+ if (match = $(/^([#.](?:[\w-]|\\(?:[a-fA-F0-9]{1,6} ?|[^a-fA-F0-9]))+)\s*\(/)) {
844
+ name = match[1];
845
+
846
+ while (param = $(this.entities.variable) || $(this.entities.literal)
847
+ || $(this.entities.keyword)) {
848
+ // Variable
849
+ if (param instanceof tree.Variable) {
850
+ if ($(':')) {
851
+ if (value = $(this.expression)) {
852
+ params.push({ name: param.name, value: value });
853
+ } else {
854
+ throw new(Error)("Expected value");
855
+ }
856
+ } else {
857
+ params.push({ name: param.name });
858
+ }
859
+ } else {
860
+ params.push({ value: param });
861
+ }
862
+ if (! $(',')) { break }
863
+ }
864
+ if (! $(')')) throw new(Error)("Expected )");
865
+
866
+ ruleset = $(this.block);
867
+
868
+ if (ruleset) {
869
+ return new(tree.mixin.Definition)(name, params, ruleset);
870
+ }
871
+ }
872
+ }
873
+ },
874
+
875
+ //
876
+ // Entities are the smallest recognized token,
877
+ // and can be found inside a rule's value.
878
+ //
879
+ entity: function () {
880
+ return $(this.entities.literal) || $(this.entities.variable) || $(this.entities.url) ||
881
+ $(this.entities.call) || $(this.entities.keyword) || $(this.entities.javascript) ||
882
+ $(this.comment);
883
+ },
884
+
885
+ //
886
+ // A Rule terminator. Note that we use `peek()` to check for '}',
887
+ // because the `block` rule will be expecting it, but we still need to make sure
888
+ // it's there, if ';' was ommitted.
889
+ //
890
+ end: function () {
891
+ return $(';') || peek('}');
892
+ },
893
+
894
+ //
895
+ // IE's alpha function
896
+ //
897
+ // alpha(opacity=88)
898
+ //
899
+ alpha: function () {
900
+ var value;
901
+
902
+ if (! $(/^opacity=/i)) return;
903
+ if (value = $(/^\d+/) || $(this.entities.variable)) {
904
+ if (! $(')')) throw new(Error)("missing closing ) for alpha()");
905
+ return new(tree.Alpha)(value);
906
+ }
907
+ },
908
+
909
+ //
910
+ // A Selector Element
911
+ //
912
+ // div
913
+ // + h1
914
+ // #socks
915
+ // input[type="text"]
916
+ //
917
+ // Elements are the building blocks for Selectors,
918
+ // they are made out of a `Combinator` (see combinator rule),
919
+ // and an element name, such as a tag a class, or `*`.
920
+ //
921
+ element: function () {
922
+ var e, t, c;
923
+
924
+ c = $(this.combinator);
925
+ e = $(/^(?:[.#]?|:*)(?:[\w-]|\\(?:[a-fA-F0-9]{1,6} ?|[^a-fA-F0-9]))+/) || $('*') || $(this.attribute) || $(/^\([^)@]+\)/);
926
+
927
+ if (e) { return new(tree.Element)(c, e) }
928
+ },
929
+
930
+ //
931
+ // Combinators combine elements together, in a Selector.
932
+ //
933
+ // Because our parser isn't white-space sensitive, special care
934
+ // has to be taken, when parsing the descendant combinator, ` `,
935
+ // as it's an empty space. We have to check the previous character
936
+ // in the input, to see if it's a ` ` character. More info on how
937
+ // we deal with this in *combinator.js*.
938
+ //
939
+ combinator: function () {
940
+ var match, c = input.charAt(i);
941
+
942
+ if (c === '>' || c === '&' || c === '+' || c === '~') {
943
+ i++;
944
+ while (input.charAt(i) === ' ') { i++ }
945
+ return new(tree.Combinator)(c);
946
+ } else if (c === ':' && input.charAt(i + 1) === ':') {
947
+ i += 2;
948
+ while (input.charAt(i) === ' ') { i++ }
949
+ return new(tree.Combinator)('::');
950
+ } else if (input.charAt(i - 1) === ' ') {
951
+ return new(tree.Combinator)(" ");
952
+ } else {
953
+ return new(tree.Combinator)(null);
954
+ }
955
+ },
956
+
957
+ //
958
+ // A CSS Selector
959
+ //
960
+ // .class > div + h1
961
+ // li a:hover
962
+ //
963
+ // Selectors are made out of one or more Elements, see above.
964
+ //
965
+ selector: function () {
966
+ var sel, e, elements = [], c, match;
967
+
968
+ while (e = $(this.element)) {
969
+ c = input.charAt(i);
970
+ elements.push(e)
971
+ if (c === '{' || c === '}' || c === ';' || c === ',') { break }
972
+ }
973
+
974
+ if (elements.length > 0) { return new(tree.Selector)(elements) }
975
+ },
976
+ tag: function () {
977
+ return $(/^[a-zA-Z][a-zA-Z-]*[0-9]?/) || $('*');
978
+ },
979
+ attribute: function () {
980
+ var attr = '', key, val, op;
981
+
982
+ if (! $('[')) return;
983
+
984
+ if (key = $(/^[a-zA-Z-]+/) || $(this.entities.quoted)) {
985
+ if ((op = $(/^[|~*$^]?=/)) &&
986
+ (val = $(this.entities.quoted) || $(/^[\w-]+/))) {
987
+ attr = [key, op, val.toCSS ? val.toCSS() : val].join('');
988
+ } else { attr = key }
989
+ }
990
+
991
+ if (! $(']')) return;
992
+
993
+ if (attr) { return "[" + attr + "]" }
994
+ },
995
+
996
+ //
997
+ // The `block` rule is used by `ruleset` and `mixin.definition`.
998
+ // It's a wrapper around the `primary` rule, with added `{}`.
999
+ //
1000
+ block: function () {
1001
+ var content;
1002
+
1003
+ if ($('{') && (content = $(this.primary)) && $('}')) {
1004
+ return content;
1005
+ }
1006
+ },
1007
+
1008
+ //
1009
+ // div, .class, body > p {...}
1010
+ //
1011
+ ruleset: function () {
1012
+ var selectors = [], s, rules, match;
1013
+ save();
1014
+
1015
+ if (match = /^([.#: \w-]+)[\s\n]*\{/.exec(chunks[j])) {
1016
+ i += match[0].length - 1;
1017
+ selectors = [new(tree.Selector)([new(tree.Element)(null, match[1])])];
1018
+ } else {
1019
+ while (s = $(this.selector)) {
1020
+ selectors.push(s);
1021
+ $(this.comment);
1022
+ if (! $(',')) { break }
1023
+ $(this.comment);
1024
+ }
1025
+ }
1026
+
1027
+ if (selectors.length > 0 && (rules = $(this.block))) {
1028
+ return new(tree.Ruleset)(selectors, rules);
1029
+ } else {
1030
+ // Backtrack
1031
+ furthest = i;
1032
+ restore();
1033
+ }
1034
+ },
1035
+ rule: function () {
1036
+ var name, value, c = input.charAt(i), important, match;
1037
+ save();
1038
+
1039
+ if (c === '.' || c === '#' || c === '&') { return }
1040
+
1041
+ if (name = $(this.variable) || $(this.property)) {
1042
+ if ((name.charAt(0) != '@') && (match = /^([^@+\/'"*`(;{}-]*);/.exec(chunks[j]))) {
1043
+ i += match[0].length - 1;
1044
+ value = new(tree.Anonymous)(match[1]);
1045
+ } else if (name === "font") {
1046
+ value = $(this.font);
1047
+ } else {
1048
+ value = $(this.value);
1049
+ }
1050
+ important = $(this.important);
1051
+
1052
+ if (value && $(this.end)) {
1053
+ return new(tree.Rule)(name, value, important, memo);
1054
+ } else {
1055
+ furthest = i;
1056
+ restore();
1057
+ }
1058
+ }
1059
+ },
1060
+
1061
+ //
1062
+ // An @import directive
1063
+ //
1064
+ // @import "lib";
1065
+ //
1066
+ // Depending on our environemnt, importing is done differently:
1067
+ // In the browser, it's an XHR request, in Node, it would be a
1068
+ // file-system operation. The function used for importing is
1069
+ // stored in `import`, which we pass to the Import constructor.
1070
+ //
1071
+ "import": function () {
1072
+ var path;
1073
+ if ($(/^@import\s+/) &&
1074
+ (path = $(this.entities.quoted) || $(this.entities.url)) &&
1075
+ $(';')) {
1076
+ return new(tree.Import)(path, imports);
1077
+ }
1078
+ },
1079
+
1080
+ //
1081
+ // A CSS Directive
1082
+ //
1083
+ // @charset "utf-8";
1084
+ //
1085
+ directive: function () {
1086
+ var name, value, rules, types;
1087
+
1088
+ if (input.charAt(i) !== '@') return;
1089
+
1090
+ if (value = $(this['import'])) {
1091
+ return value;
1092
+ } else if (name = $(/^@media|@page|@-[-a-z]+/)) {
1093
+ types = ($(/^[^{]+/) || '').trim();
1094
+ if (rules = $(this.block)) {
1095
+ return new(tree.Directive)(name + " " + types, rules);
1096
+ }
1097
+ } else if (name = $(/^@[-a-z]+/)) {
1098
+ if (name === '@font-face') {
1099
+ if (rules = $(this.block)) {
1100
+ return new(tree.Directive)(name, rules);
1101
+ }
1102
+ } else if ((value = $(this.entity)) && $(';')) {
1103
+ return new(tree.Directive)(name, value);
1104
+ }
1105
+ }
1106
+ },
1107
+ font: function () {
1108
+ var value = [], expression = [], weight, shorthand, font, e;
1109
+
1110
+ while (e = $(this.shorthand) || $(this.entity)) {
1111
+ expression.push(e);
1112
+ }
1113
+ value.push(new(tree.Expression)(expression));
1114
+
1115
+ if ($(',')) {
1116
+ while (e = $(this.expression)) {
1117
+ value.push(e);
1118
+ if (! $(',')) { break }
1119
+ }
1120
+ }
1121
+ return new(tree.Value)(value);
1122
+ },
1123
+
1124
+ //
1125
+ // A Value is a comma-delimited list of Expressions
1126
+ //
1127
+ // font-family: Baskerville, Georgia, serif;
1128
+ //
1129
+ // In a Rule, a Value represents everything after the `:`,
1130
+ // and before the `;`.
1131
+ //
1132
+ value: function () {
1133
+ var e, expressions = [], important;
1134
+
1135
+ while (e = $(this.expression)) {
1136
+ expressions.push(e);
1137
+ if (! $(',')) { break }
1138
+ }
1139
+
1140
+ if (expressions.length > 0) {
1141
+ return new(tree.Value)(expressions);
1142
+ }
1143
+ },
1144
+ important: function () {
1145
+ if (input.charAt(i) === '!') {
1146
+ return $(/^! *important/);
1147
+ }
1148
+ },
1149
+ sub: function () {
1150
+ var e;
1151
+
1152
+ if ($('(') && (e = $(this.expression)) && $(')')) {
1153
+ return e;
1154
+ }
1155
+ },
1156
+ multiplication: function () {
1157
+ var m, a, op, operation;
1158
+ if (m = $(this.operand)) {
1159
+ while ((op = ($('/') || $('*'))) && (a = $(this.operand))) {
1160
+ operation = new(tree.Operation)(op, [operation || m, a]);
1161
+ }
1162
+ return operation || m;
1163
+ }
1164
+ },
1165
+ addition: function () {
1166
+ var m, a, op, operation;
1167
+ if (m = $(this.multiplication)) {
1168
+ while ((op = $(/^[-+]\s+/) || (input.charAt(i - 1) != ' ' && ($('+') || $('-')))) &&
1169
+ (a = $(this.multiplication))) {
1170
+ operation = new(tree.Operation)(op, [operation || m, a]);
1171
+ }
1172
+ return operation || m;
1173
+ }
1174
+ },
1175
+
1176
+ //
1177
+ // An operand is anything that can be part of an operation,
1178
+ // such as a Color, or a Variable
1179
+ //
1180
+ operand: function () {
1181
+ var negate, p = input.charAt(i + 1);
1182
+
1183
+ if (input.charAt(i) === '-' && (p === '@' || p === '(')) { negate = $('-') }
1184
+ var o = $(this.sub) || $(this.entities.dimension) ||
1185
+ $(this.entities.color) || $(this.entities.variable) ||
1186
+ $(this.entities.call);
1187
+ return negate ? new(tree.Operation)('*', [new(tree.Dimension)(-1), o])
1188
+ : o;
1189
+ },
1190
+
1191
+ //
1192
+ // Expressions either represent mathematical operations,
1193
+ // or white-space delimited Entities.
1194
+ //
1195
+ // 1px solid black
1196
+ // @var * 2
1197
+ //
1198
+ expression: function () {
1199
+ var e, delim, entities = [], d;
1200
+
1201
+ while (e = $(this.addition) || $(this.entity)) {
1202
+ entities.push(e);
1203
+ }
1204
+ if (entities.length > 0) {
1205
+ return new(tree.Expression)(entities);
1206
+ }
1207
+ },
1208
+ property: function () {
1209
+ var name;
1210
+
1211
+ if (name = $(/^(\*?-?[-a-z_0-9]+)\s*:/)) {
1212
+ return name[1];
1213
+ }
1214
+ }
1215
+ }
1216
+ };
1217
+ };
1218
+
1219
+ if (typeof(window) !== 'undefined') {
1220
+ //
1221
+ // Used by `@import` directives
1222
+ //
1223
+ less.Parser.importer = function (path, paths, callback, env) {
1224
+ if (path.charAt(0) !== '/' && paths.length > 0) {
1225
+ path = paths[0] + path;
1226
+ }
1227
+ // We pass `true` as 3rd argument, to force the reload of the import.
1228
+ // This is so we can get the syntax tree as opposed to just the CSS output,
1229
+ // as we need this to evaluate the current stylesheet.
1230
+ loadStyleSheet({ href: path, title: path, type: env.mime }, callback, true);
1231
+ };
1232
+ }
1233
+
1234
+ (function (tree) {
1235
+
1236
+ tree.functions = {
1237
+ rgb: function (r, g, b) {
1238
+ return this.rgba(r, g, b, 1.0);
1239
+ },
1240
+ rgba: function (r, g, b, a) {
1241
+ var rgb = [r, g, b].map(function (c) { return number(c) }),
1242
+ a = number(a);
1243
+ return new(tree.Color)(rgb, a);
1244
+ },
1245
+ hsl: function (h, s, l) {
1246
+ return this.hsla(h, s, l, 1.0);
1247
+ },
1248
+ hsla: function (h, s, l, a) {
1249
+ h = (number(h) % 360) / 360;
1250
+ s = number(s); l = number(l); a = number(a);
1251
+
1252
+ var m2 = l <= 0.5 ? l * (s + 1) : l + s - l * s;
1253
+ var m1 = l * 2 - m2;
1254
+
1255
+ return this.rgba(hue(h + 1/3) * 255,
1256
+ hue(h) * 255,
1257
+ hue(h - 1/3) * 255,
1258
+ a);
1259
+
1260
+ function hue(h) {
1261
+ h = h < 0 ? h + 1 : (h > 1 ? h - 1 : h);
1262
+ if (h * 6 < 1) return m1 + (m2 - m1) * h * 6;
1263
+ else if (h * 2 < 1) return m2;
1264
+ else if (h * 3 < 2) return m1 + (m2 - m1) * (2/3 - h) * 6;
1265
+ else return m1;
1266
+ }
1267
+ },
1268
+ hue: function (color) {
1269
+ return new(tree.Dimension)(Math.round(color.toHSL().h));
1270
+ },
1271
+ saturation: function (color) {
1272
+ return new(tree.Dimension)(Math.round(color.toHSL().s * 100), '%');
1273
+ },
1274
+ lightness: function (color) {
1275
+ return new(tree.Dimension)(Math.round(color.toHSL().l * 100), '%');
1276
+ },
1277
+ alpha: function (color) {
1278
+ return new(tree.Dimension)(color.toHSL().a);
1279
+ },
1280
+ saturate: function (color, amount) {
1281
+ var hsl = color.toHSL();
1282
+
1283
+ hsl.s += amount.value / 100;
1284
+ hsl.s = clamp(hsl.s);
1285
+ return hsla(hsl);
1286
+ },
1287
+ desaturate: function (color, amount) {
1288
+ var hsl = color.toHSL();
1289
+
1290
+ hsl.s -= amount.value / 100;
1291
+ hsl.s = clamp(hsl.s);
1292
+ return hsla(hsl);
1293
+ },
1294
+ lighten: function (color, amount) {
1295
+ var hsl = color.toHSL();
1296
+
1297
+ hsl.l += amount.value / 100;
1298
+ hsl.l = clamp(hsl.l);
1299
+ return hsla(hsl);
1300
+ },
1301
+ darken: function (color, amount) {
1302
+ var hsl = color.toHSL();
1303
+
1304
+ hsl.l -= amount.value / 100;
1305
+ hsl.l = clamp(hsl.l);
1306
+ return hsla(hsl);
1307
+ },
1308
+ fadein: function (color, amount) {
1309
+ var hsl = color.toHSL();
1310
+
1311
+ hsl.a += amount.value / 100;
1312
+ hsl.a = clamp(hsl.a);
1313
+ return hsla(hsl);
1314
+ },
1315
+ fadeout: function (color, amount) {
1316
+ var hsl = color.toHSL();
1317
+
1318
+ hsl.a -= amount.value / 100;
1319
+ hsl.a = clamp(hsl.a);
1320
+ return hsla(hsl);
1321
+ },
1322
+ spin: function (color, amount) {
1323
+ var hsl = color.toHSL();
1324
+ var hue = (hsl.h + amount.value) % 360;
1325
+
1326
+ hsl.h = hue < 0 ? 360 + hue : hue;
1327
+
1328
+ return hsla(hsl);
1329
+ },
1330
+ //
1331
+ // Copyright (c) 2006-2009 Hampton Catlin, Nathan Weizenbaum, and Chris Eppstein
1332
+ // http://sass-lang.com
1333
+ //
1334
+ mix: function (color1, color2, weight) {
1335
+ var p = weight.value / 100.0;
1336
+ var w = p * 2 - 1;
1337
+ var a = color1.toHSL().a - color2.toHSL().a;
1338
+
1339
+ var w1 = (((w * a == -1) ? w : (w + a) / (1 + w * a)) + 1) / 2.0;
1340
+ var w2 = 1 - w1;
1341
+
1342
+ var rgb = [color1.rgb[0] * w1 + color2.rgb[0] * w2,
1343
+ color1.rgb[1] * w1 + color2.rgb[1] * w2,
1344
+ color1.rgb[2] * w1 + color2.rgb[2] * w2];
1345
+
1346
+ var alpha = color1.alpha * p + color2.alpha * (1 - p);
1347
+
1348
+ return new(tree.Color)(rgb, alpha);
1349
+ },
1350
+ greyscale: function (color) {
1351
+ return this.desaturate(color, new(tree.Dimension)(100));
1352
+ },
1353
+ e: function (str) {
1354
+ return new(tree.Anonymous)(str instanceof tree.JavaScript ? str.evaluated : str);
1355
+ },
1356
+ escape: function (str) {
1357
+ return new(tree.Anonymous)(encodeURI(str.value).replace(/=/g, "%3D").replace(/:/g, "%3A").replace(/#/g, "%23").replace(/;/g, "%3B").replace(/\(/g, "%28").replace(/\)/g, "%29"));
1358
+ },
1359
+ '%': function (quoted /* arg, arg, ...*/) {
1360
+ var args = Array.prototype.slice.call(arguments, 1),
1361
+ str = quoted.value;
1362
+
1363
+ for (var i = 0; i < args.length; i++) {
1364
+ str = str.replace(/%[sda]/i, function(token) {
1365
+ var value = token.match(/s/i) ? args[i].value : args[i].toCSS();
1366
+ return token.match(/[A-Z]$/) ? encodeURIComponent(value) : value;
1367
+ });
1368
+ }
1369
+ str = str.replace(/%%/g, '%');
1370
+ return new(tree.Quoted)('"' + str + '"', str);
1371
+ },
1372
+ round: function (n) {
1373
+ if (n instanceof tree.Dimension) {
1374
+ return new(tree.Dimension)(Math.round(number(n)), n.unit);
1375
+ } else if (typeof(n) === 'number') {
1376
+ return Math.round(n);
1377
+ } else {
1378
+ throw {
1379
+ error: "RuntimeError",
1380
+ message: "math functions take numbers as parameters"
1381
+ };
1382
+ }
1383
+ }
1384
+ };
1385
+
1386
+ function hsla(hsla) {
1387
+ return tree.functions.hsla(hsla.h, hsla.s, hsla.l, hsla.a);
1388
+ }
1389
+
1390
+ function number(n) {
1391
+ if (n instanceof tree.Dimension) {
1392
+ return parseFloat(n.unit == '%' ? n.value / 100 : n.value);
1393
+ } else if (typeof(n) === 'number') {
1394
+ return n;
1395
+ } else {
1396
+ throw {
1397
+ error: "RuntimeError",
1398
+ message: "color functions take numbers as parameters"
1399
+ };
1400
+ }
1401
+ }
1402
+
1403
+ function clamp(val) {
1404
+ return Math.min(1, Math.max(0, val));
1405
+ }
1406
+
1407
+ })(require('less/tree'));
1408
+ (function (tree) {
1409
+
1410
+ tree.Alpha = function (val) {
1411
+ this.value = val;
1412
+ };
1413
+ tree.Alpha.prototype = {
1414
+ toCSS: function () {
1415
+ return "alpha(opacity=" +
1416
+ (this.value.toCSS ? this.value.toCSS() : this.value) + ")";
1417
+ },
1418
+ eval: function () { return this }
1419
+ };
1420
+
1421
+ })(require('less/tree'));
1422
+ (function (tree) {
1423
+
1424
+ tree.Anonymous = function (string) {
1425
+ this.value = string.value || string;
1426
+ };
1427
+ tree.Anonymous.prototype = {
1428
+ toCSS: function () {
1429
+ return this.value;
1430
+ },
1431
+ eval: function () { return this }
1432
+ };
1433
+
1434
+ })(require('less/tree'));
1435
+ (function (tree) {
1436
+
1437
+ //
1438
+ // A function call node.
1439
+ //
1440
+ tree.Call = function (name, args) {
1441
+ this.name = name;
1442
+ this.args = args;
1443
+ };
1444
+ tree.Call.prototype = {
1445
+ //
1446
+ // When evaluating a function call,
1447
+ // we either find the function in `tree.functions` [1],
1448
+ // in which case we call it, passing the evaluated arguments,
1449
+ // or we simply print it out as it appeared originally [2].
1450
+ //
1451
+ // The *functions.js* file contains the built-in functions.
1452
+ //
1453
+ // The reason why we evaluate the arguments, is in the case where
1454
+ // we try to pass a variable to a function, like: `saturate(@color)`.
1455
+ // The function should receive the value, not the variable.
1456
+ //
1457
+ eval: function (env) {
1458
+ var args = this.args.map(function (a) { return a.eval(env) });
1459
+
1460
+ if (this.name in tree.functions) { // 1.
1461
+ return tree.functions[this.name].apply(tree.functions, args);
1462
+ } else { // 2.
1463
+ return new(tree.Anonymous)(this.name +
1464
+ "(" + args.map(function (a) { return a.toCSS() }).join(', ') + ")");
1465
+ }
1466
+ },
1467
+
1468
+ toCSS: function (env) {
1469
+ return this.eval(env).toCSS();
1470
+ }
1471
+ };
1472
+
1473
+ })(require('less/tree'));
1474
+ (function (tree) {
1475
+ //
1476
+ // RGB Colors - #ff0014, #eee
1477
+ //
1478
+ tree.Color = function (rgb, a) {
1479
+ //
1480
+ // The end goal here, is to parse the arguments
1481
+ // into an integer triplet, such as `128, 255, 0`
1482
+ //
1483
+ // This facilitates operations and conversions.
1484
+ //
1485
+ if (Array.isArray(rgb)) {
1486
+ this.rgb = rgb;
1487
+ } else if (rgb.length == 6) {
1488
+ this.rgb = rgb.match(/.{2}/g).map(function (c) {
1489
+ return parseInt(c, 16);
1490
+ });
1491
+ } else if (rgb.length == 8) {
1492
+ this.alpha = parseInt(rgb.substring(0,2), 16) / 255.0;
1493
+ this.rgb = rgb.substr(2).match(/.{2}/g).map(function (c) {
1494
+ return parseInt(c, 16);
1495
+ });
1496
+ } else {
1497
+ this.rgb = rgb.split('').map(function (c) {
1498
+ return parseInt(c + c, 16);
1499
+ });
1500
+ }
1501
+ this.alpha = typeof(a) === 'number' ? a : 1;
1502
+ };
1503
+ tree.Color.prototype = {
1504
+ eval: function () { return this },
1505
+
1506
+ //
1507
+ // If we have some transparency, the only way to represent it
1508
+ // is via `rgba`. Otherwise, we use the hex representation,
1509
+ // which has better compatibility with older browsers.
1510
+ // Values are capped between `0` and `255`, rounded and zero-padded.
1511
+ //
1512
+ toCSS: function () {
1513
+ if (this.alpha < 1.0) {
1514
+ return "rgba(" + this.rgb.map(function (c) {
1515
+ return Math.round(c);
1516
+ }).concat(this.alpha).join(', ') + ")";
1517
+ } else {
1518
+ return '#' + this.rgb.map(function (i) {
1519
+ i = Math.round(i);
1520
+ i = (i > 255 ? 255 : (i < 0 ? 0 : i)).toString(16);
1521
+ return i.length === 1 ? '0' + i : i;
1522
+ }).join('');
1523
+ }
1524
+ },
1525
+
1526
+ //
1527
+ // Operations have to be done per-channel, if not,
1528
+ // channels will spill onto each other. Once we have
1529
+ // our result, in the form of an integer triplet,
1530
+ // we create a new Color node to hold the result.
1531
+ //
1532
+ operate: function (op, other) {
1533
+ var result = [];
1534
+
1535
+ if (! (other instanceof tree.Color)) {
1536
+ other = other.toColor();
1537
+ }
1538
+
1539
+ for (var c = 0; c < 3; c++) {
1540
+ result[c] = tree.operate(op, this.rgb[c], other.rgb[c]);
1541
+ }
1542
+ return new(tree.Color)(result, this.alpha + other.alpha);
1543
+ },
1544
+
1545
+ toHSL: function () {
1546
+ var r = this.rgb[0] / 255,
1547
+ g = this.rgb[1] / 255,
1548
+ b = this.rgb[2] / 255,
1549
+ a = this.alpha;
1550
+
1551
+ var max = Math.max(r, g, b), min = Math.min(r, g, b);
1552
+ var h, s, l = (max + min) / 2, d = max - min;
1553
+
1554
+ if (max === min) {
1555
+ h = s = 0;
1556
+ } else {
1557
+ s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
1558
+
1559
+ switch (max) {
1560
+ case r: h = (g - b) / d + (g < b ? 6 : 0); break;
1561
+ case g: h = (b - r) / d + 2; break;
1562
+ case b: h = (r - g) / d + 4; break;
1563
+ }
1564
+ h /= 6;
1565
+ }
1566
+ return { h: h * 360, s: s, l: l, a: a };
1567
+ }
1568
+ };
1569
+
1570
+
1571
+ })(require('less/tree'));
1572
+ (function (tree) {
1573
+
1574
+ tree.Comment = function (value, silent) {
1575
+ this.value = value;
1576
+ this.silent = !!silent;
1577
+ };
1578
+ tree.Comment.prototype = {
1579
+ toCSS: function (env) {
1580
+ return env.compress ? '' : this.value;
1581
+ },
1582
+ eval: function () { return this }
1583
+ };
1584
+
1585
+ })(require('less/tree'));
1586
+ (function (tree) {
1587
+
1588
+ //
1589
+ // A number with a unit
1590
+ //
1591
+ tree.Dimension = function (value, unit) {
1592
+ this.value = parseFloat(value);
1593
+ this.unit = unit || null;
1594
+ };
1595
+
1596
+ tree.Dimension.prototype = {
1597
+ eval: function () { return this },
1598
+ toColor: function () {
1599
+ return new(tree.Color)([this.value, this.value, this.value]);
1600
+ },
1601
+ toCSS: function () {
1602
+ var css = this.value + this.unit;
1603
+ return css;
1604
+ },
1605
+
1606
+ // In an operation between two Dimensions,
1607
+ // we default to the first Dimension's unit,
1608
+ // so `1px + 2em` will yield `3px`.
1609
+ // In the future, we could implement some unit
1610
+ // conversions such that `100cm + 10mm` would yield
1611
+ // `101cm`.
1612
+ operate: function (op, other) {
1613
+ return new(tree.Dimension)
1614
+ (tree.operate(op, this.value, other.value),
1615
+ this.unit || other.unit);
1616
+ }
1617
+ };
1618
+
1619
+ })(require('less/tree'));
1620
+ (function (tree) {
1621
+
1622
+ tree.Directive = function (name, value) {
1623
+ this.name = name;
1624
+ if (Array.isArray(value)) {
1625
+ this.ruleset = new(tree.Ruleset)([], value);
1626
+ } else {
1627
+ this.value = value;
1628
+ }
1629
+ };
1630
+ tree.Directive.prototype = {
1631
+ toCSS: function (ctx, env) {
1632
+ if (this.ruleset) {
1633
+ this.ruleset.root = true;
1634
+ return this.name + (env.compress ? '{' : ' {\n ') +
1635
+ this.ruleset.toCSS(ctx, env).trim().replace(/\n/g, '\n ') +
1636
+ (env.compress ? '}': '\n}\n');
1637
+ } else {
1638
+ return this.name + ' ' + this.value.toCSS() + ';\n';
1639
+ }
1640
+ },
1641
+ eval: function (env) {
1642
+ env.frames.unshift(this);
1643
+ this.ruleset = this.ruleset && this.ruleset.eval(env);
1644
+ env.frames.shift();
1645
+ return this;
1646
+ },
1647
+ variable: function (name) { return tree.Ruleset.prototype.variable.call(this.ruleset, name) },
1648
+ find: function () { return tree.Ruleset.prototype.find.apply(this.ruleset, arguments) },
1649
+ rulesets: function () { return tree.Ruleset.prototype.rulesets.apply(this.ruleset) }
1650
+ };
1651
+
1652
+ })(require('less/tree'));
1653
+ (function (tree) {
1654
+
1655
+ tree.Element = function (combinator, value) {
1656
+ this.combinator = combinator instanceof tree.Combinator ?
1657
+ combinator : new(tree.Combinator)(combinator);
1658
+ this.value = value.trim();
1659
+ };
1660
+ tree.Element.prototype.toCSS = function (env) {
1661
+ return this.combinator.toCSS(env || {}) + this.value;
1662
+ };
1663
+
1664
+ tree.Combinator = function (value) {
1665
+ if (value === ' ') {
1666
+ this.value = ' ';
1667
+ } else {
1668
+ this.value = value ? value.trim() : "";
1669
+ }
1670
+ };
1671
+ tree.Combinator.prototype.toCSS = function (env) {
1672
+ return {
1673
+ '' : '',
1674
+ ' ' : ' ',
1675
+ '&' : '',
1676
+ ':' : ' :',
1677
+ '::': '::',
1678
+ '+' : env.compress ? '+' : ' + ',
1679
+ '~' : env.compress ? '~' : ' ~ ',
1680
+ '>' : env.compress ? '>' : ' > '
1681
+ }[this.value];
1682
+ };
1683
+
1684
+ })(require('less/tree'));
1685
+ (function (tree) {
1686
+
1687
+ tree.Expression = function (value) { this.value = value };
1688
+ tree.Expression.prototype = {
1689
+ eval: function (env) {
1690
+ if (this.value.length > 1) {
1691
+ return new(tree.Expression)(this.value.map(function (e) {
1692
+ return e.eval(env);
1693
+ }));
1694
+ } else if (this.value.length === 1) {
1695
+ return this.value[0].eval(env);
1696
+ } else {
1697
+ return this;
1698
+ }
1699
+ },
1700
+ toCSS: function (env) {
1701
+ return this.value.map(function (e) {
1702
+ return e.toCSS(env);
1703
+ }).join(' ');
1704
+ }
1705
+ };
1706
+
1707
+ })(require('less/tree'));
1708
+ (function (tree) {
1709
+ //
1710
+ // CSS @import node
1711
+ //
1712
+ // The general strategy here is that we don't want to wait
1713
+ // for the parsing to be completed, before we start importing
1714
+ // the file. That's because in the context of a browser,
1715
+ // most of the time will be spent waiting for the server to respond.
1716
+ //
1717
+ // On creation, we push the import path to our import queue, though
1718
+ // `import,push`, we also pass it a callback, which it'll call once
1719
+ // the file has been fetched, and parsed.
1720
+ //
1721
+ tree.Import = function (path, imports) {
1722
+ var that = this;
1723
+
1724
+ this._path = path;
1725
+
1726
+ // The '.less' extension is optional
1727
+ if (path instanceof tree.Quoted) {
1728
+ this.path = /\.(le?|c)ss$/.test(path.value) ? path.value : path.value + '.less';
1729
+ } else {
1730
+ this.path = path.value.value || path.value;
1731
+ }
1732
+
1733
+ this.css = /css$/.test(this.path);
1734
+
1735
+ // Only pre-compile .less files
1736
+ if (! this.css) {
1737
+ imports.push(this.path, function (root) {
1738
+ if (! root) {
1739
+ throw new(Error)("Error parsing " + that.path);
1740
+ }
1741
+ that.root = root;
1742
+ });
1743
+ }
1744
+ };
1745
+
1746
+ //
1747
+ // The actual import node doesn't return anything, when converted to CSS.
1748
+ // The reason is that it's used at the evaluation stage, so that the rules
1749
+ // it imports can be treated like any other rules.
1750
+ //
1751
+ // In `eval`, we make sure all Import nodes get evaluated, recursively, so
1752
+ // we end up with a flat structure, which can easily be imported in the parent
1753
+ // ruleset.
1754
+ //
1755
+ tree.Import.prototype = {
1756
+ toCSS: function () {
1757
+ if (this.css) {
1758
+ return "@import " + this._path.toCSS() + ';\n';
1759
+ } else {
1760
+ return "";
1761
+ }
1762
+ },
1763
+ eval: function (env) {
1764
+ var ruleset;
1765
+
1766
+ if (this.css) {
1767
+ return this;
1768
+ } else {
1769
+ ruleset = new(tree.Ruleset)(null, this.root.rules.slice(0));
1770
+
1771
+ for (var i = 0; i < ruleset.rules.length; i++) {
1772
+ if (ruleset.rules[i] instanceof tree.Import) {
1773
+ Array.prototype
1774
+ .splice
1775
+ .apply(ruleset.rules,
1776
+ [i, 1].concat(ruleset.rules[i].eval(env)));
1777
+ }
1778
+ }
1779
+ return ruleset.rules;
1780
+ }
1781
+ }
1782
+ };
1783
+
1784
+ })(require('less/tree'));
1785
+ (function (tree) {
1786
+
1787
+ tree.JavaScript = function (string, index, escaped) {
1788
+ this.escaped = escaped;
1789
+ this.expression = string;
1790
+ this.index = index;
1791
+ };
1792
+ tree.JavaScript.prototype = {
1793
+ eval: function (env) {
1794
+ var result,
1795
+ that = this,
1796
+ context = {};
1797
+
1798
+ var expression = this.expression.replace(/@\{([\w-]+)\}/g, function (_, name) {
1799
+ return tree.jsify(new(tree.Variable)('@' + name, that.index).eval(env));
1800
+ });
1801
+
1802
+ try {
1803
+ expression = new(Function)('return (' + expression + ')');
1804
+ } catch (e) {
1805
+ throw { message: "JavaScript evaluation error: `" + expression + "`" ,
1806
+ index: this.index };
1807
+ }
1808
+
1809
+ for (var k in env.frames[0].variables()) {
1810
+ context[k.slice(1)] = {
1811
+ value: env.frames[0].variables()[k].value,
1812
+ toJS: function () {
1813
+ return this.value.eval(env).toCSS();
1814
+ }
1815
+ };
1816
+ }
1817
+
1818
+ try {
1819
+ result = expression.call(context);
1820
+ } catch (e) {
1821
+ throw { message: "JavaScript evaluation error: '" + e.name + ': ' + e.message + "'" ,
1822
+ index: this.index };
1823
+ }
1824
+ if (typeof(result) === 'string') {
1825
+ return new(tree.Quoted)('"' + result + '"', result, this.escaped, this.index);
1826
+ } else if (Array.isArray(result)) {
1827
+ return new(tree.Anonymous)(result.join(', '));
1828
+ } else {
1829
+ return new(tree.Anonymous)(result);
1830
+ }
1831
+ }
1832
+ };
1833
+
1834
+ })(require('less/tree'));
1835
+
1836
+ (function (tree) {
1837
+
1838
+ tree.Keyword = function (value) { this.value = value };
1839
+ tree.Keyword.prototype = {
1840
+ eval: function () { return this },
1841
+ toCSS: function () { return this.value }
1842
+ };
1843
+
1844
+ })(require('less/tree'));
1845
+ (function (tree) {
1846
+
1847
+ tree.mixin = {};
1848
+ tree.mixin.Call = function (elements, args, index) {
1849
+ this.selector = new(tree.Selector)(elements);
1850
+ this.arguments = args;
1851
+ this.index = index;
1852
+ };
1853
+ tree.mixin.Call.prototype = {
1854
+ eval: function (env) {
1855
+ var mixins, args, rules = [], match = false;
1856
+
1857
+ for (var i = 0; i < env.frames.length; i++) {
1858
+ if ((mixins = env.frames[i].find(this.selector)).length > 0) {
1859
+ args = this.arguments && this.arguments.map(function (a) { return a.eval(env) });
1860
+ for (var m = 0; m < mixins.length; m++) {
1861
+ if (mixins[m].match(args, env)) {
1862
+ try {
1863
+ Array.prototype.push.apply(
1864
+ rules, mixins[m].eval(env, this.arguments).rules);
1865
+ match = true;
1866
+ } catch (e) {
1867
+ throw { message: e.message, index: e.index, stack: e.stack, call: this.index };
1868
+ }
1869
+ }
1870
+ }
1871
+ if (match) {
1872
+ return rules;
1873
+ } else {
1874
+ throw { message: 'No matching definition was found for `' +
1875
+ this.selector.toCSS().trim() + '(' +
1876
+ this.arguments.map(function (a) {
1877
+ return a.toCSS();
1878
+ }).join(', ') + ")`",
1879
+ index: this.index };
1880
+ }
1881
+ }
1882
+ }
1883
+ throw { message: this.selector.toCSS().trim() + " is undefined",
1884
+ index: this.index };
1885
+ }
1886
+ };
1887
+
1888
+ tree.mixin.Definition = function (name, params, rules) {
1889
+ this.name = name;
1890
+ this.selectors = [new(tree.Selector)([new(tree.Element)(null, name)])];
1891
+ this.params = params;
1892
+ this.arity = params.length;
1893
+ this.rules = rules;
1894
+ this._lookups = {};
1895
+ this.required = params.reduce(function (count, p) {
1896
+ if (!p.name || (p.name && !p.value)) { return count + 1 }
1897
+ else { return count }
1898
+ }, 0);
1899
+ this.parent = tree.Ruleset.prototype;
1900
+ this.frames = [];
1901
+ };
1902
+ tree.mixin.Definition.prototype = {
1903
+ toCSS: function () { return "" },
1904
+ variable: function (name) { return this.parent.variable.call(this, name) },
1905
+ variables: function () { return this.parent.variables.call(this) },
1906
+ find: function () { return this.parent.find.apply(this, arguments) },
1907
+ rulesets: function () { return this.parent.rulesets.apply(this) },
1908
+
1909
+ eval: function (env, args) {
1910
+ var frame = new(tree.Ruleset)(null, []), context, _arguments = [];
1911
+
1912
+ for (var i = 0, val; i < this.params.length; i++) {
1913
+ if (this.params[i].name) {
1914
+ if (val = (args && args[i]) || this.params[i].value) {
1915
+ frame.rules.unshift(new(tree.Rule)(this.params[i].name, val.eval(env)));
1916
+ } else {
1917
+ throw { message: "wrong number of arguments for " + this.name +
1918
+ ' (' + args.length + ' for ' + this.arity + ')' };
1919
+ }
1920
+ }
1921
+ }
1922
+ for (var i = 0; i < Math.max(this.params.length, args && args.length); i++) {
1923
+ _arguments.push(args[i] || this.params[i].value);
1924
+ }
1925
+ frame.rules.unshift(new(tree.Rule)('@arguments', new(tree.Expression)(_arguments).eval(env)));
1926
+
1927
+ return new(tree.Ruleset)(null, this.rules.slice(0)).eval({
1928
+ frames: [this, frame].concat(this.frames, env.frames)
1929
+ });
1930
+ },
1931
+ match: function (args, env) {
1932
+ var argsLength = (args && args.length) || 0, len;
1933
+
1934
+ if (argsLength < this.required) { return false }
1935
+ if ((this.required > 0) && (argsLength > this.params.length)) { return false }
1936
+
1937
+ len = Math.min(argsLength, this.arity);
1938
+
1939
+ for (var i = 0; i < len; i++) {
1940
+ if (!this.params[i].name) {
1941
+ if (args[i].eval(env).toCSS() != this.params[i].value.eval(env).toCSS()) {
1942
+ return false;
1943
+ }
1944
+ }
1945
+ }
1946
+ return true;
1947
+ }
1948
+ };
1949
+
1950
+ })(require('less/tree'));
1951
+ (function (tree) {
1952
+
1953
+ tree.Operation = function (op, operands) {
1954
+ this.op = op.trim();
1955
+ this.operands = operands;
1956
+ };
1957
+ tree.Operation.prototype.eval = function (env) {
1958
+ var a = this.operands[0].eval(env),
1959
+ b = this.operands[1].eval(env),
1960
+ temp;
1961
+
1962
+ if (a instanceof tree.Dimension && b instanceof tree.Color) {
1963
+ if (this.op === '*' || this.op === '+') {
1964
+ temp = b, b = a, a = temp;
1965
+ } else {
1966
+ throw { name: "OperationError",
1967
+ message: "Can't substract or divide a color from a number" };
1968
+ }
1969
+ }
1970
+ return a.operate(this.op, b);
1971
+ };
1972
+
1973
+ tree.operate = function (op, a, b) {
1974
+ switch (op) {
1975
+ case '+': return a + b;
1976
+ case '-': return a - b;
1977
+ case '*': return a * b;
1978
+ case '/': return a / b;
1979
+ }
1980
+ };
1981
+
1982
+ })(require('less/tree'));
1983
+ (function (tree) {
1984
+
1985
+ tree.Quoted = function (str, content, escaped, i) {
1986
+ this.escaped = escaped;
1987
+ this.value = content || '';
1988
+ this.quote = str.charAt(0);
1989
+ this.index = i;
1990
+ };
1991
+ tree.Quoted.prototype = {
1992
+ toCSS: function () {
1993
+ if (this.escaped) {
1994
+ return this.value;
1995
+ } else {
1996
+ return this.quote + this.value + this.quote;
1997
+ }
1998
+ },
1999
+ eval: function (env) {
2000
+ var that = this;
2001
+ var value = this.value.replace(/`([^`]+)`/g, function (_, exp) {
2002
+ return new(tree.JavaScript)(exp, that.index, true).eval(env).value;
2003
+ }).replace(/@\{([\w-]+)\}/g, function (_, name) {
2004
+ var v = new(tree.Variable)('@' + name, that.index).eval(env);
2005
+ return v.value || v.toCSS();
2006
+ });
2007
+ return new(tree.Quoted)(this.quote + value + this.quote, value, this.escaped, this.index);
2008
+ }
2009
+ };
2010
+
2011
+ })(require('less/tree'));
2012
+ (function (tree) {
2013
+
2014
+ tree.Rule = function (name, value, important, index) {
2015
+ this.name = name;
2016
+ this.value = (value instanceof tree.Value) ? value : new(tree.Value)([value]);
2017
+ this.important = important ? ' ' + important.trim() : '';
2018
+ this.index = index;
2019
+
2020
+ if (name.charAt(0) === '@') {
2021
+ this.variable = true;
2022
+ } else { this.variable = false }
2023
+ };
2024
+ tree.Rule.prototype.toCSS = function (env) {
2025
+ if (this.variable) { return "" }
2026
+ else {
2027
+ return this.name + (env.compress ? ':' : ': ') +
2028
+ this.value.toCSS(env) +
2029
+ this.important + ";";
2030
+ }
2031
+ };
2032
+
2033
+ tree.Rule.prototype.eval = function (context) {
2034
+ return new(tree.Rule)(this.name, this.value.eval(context), this.important, this.index);
2035
+ };
2036
+
2037
+ tree.Shorthand = function (a, b) {
2038
+ this.a = a;
2039
+ this.b = b;
2040
+ };
2041
+
2042
+ tree.Shorthand.prototype = {
2043
+ toCSS: function (env) {
2044
+ return this.a.toCSS(env) + "/" + this.b.toCSS(env);
2045
+ },
2046
+ eval: function () { return this }
2047
+ };
2048
+
2049
+ })(require('less/tree'));
2050
+ (function (tree) {
2051
+
2052
+ tree.Ruleset = function (selectors, rules) {
2053
+ this.selectors = selectors;
2054
+ this.rules = rules;
2055
+ this._lookups = {};
2056
+ };
2057
+ tree.Ruleset.prototype = {
2058
+ eval: function (env) {
2059
+ var ruleset = new(tree.Ruleset)(this.selectors, this.rules.slice(0));
2060
+
2061
+ ruleset.root = this.root;
2062
+
2063
+ // push the current ruleset to the frames stack
2064
+ env.frames.unshift(ruleset);
2065
+
2066
+ // Evaluate imports
2067
+ if (ruleset.root) {
2068
+ for (var i = 0; i < ruleset.rules.length; i++) {
2069
+ if (ruleset.rules[i] instanceof tree.Import) {
2070
+ Array.prototype.splice
2071
+ .apply(ruleset.rules, [i, 1].concat(ruleset.rules[i].eval(env)));
2072
+ }
2073
+ }
2074
+ }
2075
+
2076
+ // Store the frames around mixin definitions,
2077
+ // so they can be evaluated like closures when the time comes.
2078
+ for (var i = 0; i < ruleset.rules.length; i++) {
2079
+ if (ruleset.rules[i] instanceof tree.mixin.Definition) {
2080
+ ruleset.rules[i].frames = env.frames.slice(0);
2081
+ }
2082
+ }
2083
+
2084
+ // Evaluate mixin calls.
2085
+ for (var i = 0; i < ruleset.rules.length; i++) {
2086
+ if (ruleset.rules[i] instanceof tree.mixin.Call) {
2087
+ Array.prototype.splice
2088
+ .apply(ruleset.rules, [i, 1].concat(ruleset.rules[i].eval(env)));
2089
+ }
2090
+ }
2091
+
2092
+ // Evaluate everything else
2093
+ for (var i = 0, rule; i < ruleset.rules.length; i++) {
2094
+ rule = ruleset.rules[i];
2095
+
2096
+ if (! (rule instanceof tree.mixin.Definition)) {
2097
+ ruleset.rules[i] = rule.eval ? rule.eval(env) : rule;
2098
+ }
2099
+ }
2100
+
2101
+ // Pop the stack
2102
+ env.frames.shift();
2103
+
2104
+ return ruleset;
2105
+ },
2106
+ match: function (args) {
2107
+ return !args || args.length === 0;
2108
+ },
2109
+ variables: function () {
2110
+ if (this._variables) { return this._variables }
2111
+ else {
2112
+ return this._variables = this.rules.reduce(function (hash, r) {
2113
+ if (r instanceof tree.Rule && r.variable === true) {
2114
+ hash[r.name] = r;
2115
+ }
2116
+ return hash;
2117
+ }, {});
2118
+ }
2119
+ },
2120
+ variable: function (name) {
2121
+ return this.variables()[name];
2122
+ },
2123
+ rulesets: function () {
2124
+ if (this._rulesets) { return this._rulesets }
2125
+ else {
2126
+ return this._rulesets = this.rules.filter(function (r) {
2127
+ return (r instanceof tree.Ruleset) || (r instanceof tree.mixin.Definition);
2128
+ });
2129
+ }
2130
+ },
2131
+ find: function (selector, self) {
2132
+ self = self || this;
2133
+ var rules = [], rule, match,
2134
+ key = selector.toCSS();
2135
+
2136
+ if (key in this._lookups) { return this._lookups[key] }
2137
+
2138
+ this.rulesets().forEach(function (rule) {
2139
+ if (rule !== self) {
2140
+ for (var j = 0; j < rule.selectors.length; j++) {
2141
+ if (match = selector.match(rule.selectors[j])) {
2142
+ if (selector.elements.length > 1) {
2143
+ Array.prototype.push.apply(rules, rule.find(
2144
+ new(tree.Selector)(selector.elements.slice(1)), self));
2145
+ } else {
2146
+ rules.push(rule);
2147
+ }
2148
+ break;
2149
+ }
2150
+ }
2151
+ }
2152
+ });
2153
+ return this._lookups[key] = rules;
2154
+ },
2155
+ //
2156
+ // Entry point for code generation
2157
+ //
2158
+ // `context` holds an array of arrays.
2159
+ //
2160
+ toCSS: function (context, env) {
2161
+ var css = [], // The CSS output
2162
+ rules = [], // node.Rule instances
2163
+ rulesets = [], // node.Ruleset instances
2164
+ paths = [], // Current selectors
2165
+ selector, // The fully rendered selector
2166
+ rule;
2167
+
2168
+ if (! this.root) {
2169
+ if (context.length === 0) {
2170
+ paths = this.selectors.map(function (s) { return [s] });
2171
+ } else {
2172
+ for (var s = 0; s < this.selectors.length; s++) {
2173
+ for (var c = 0; c < context.length; c++) {
2174
+ paths.push(context[c].concat([this.selectors[s]]));
2175
+ }
2176
+ }
2177
+ }
2178
+ }
2179
+
2180
+ // Compile rules and rulesets
2181
+ for (var i = 0; i < this.rules.length; i++) {
2182
+ rule = this.rules[i];
2183
+
2184
+ if (rule.rules || (rule instanceof tree.Directive)) {
2185
+ rulesets.push(rule.toCSS(paths, env));
2186
+ } else if (rule instanceof tree.Comment) {
2187
+ if (!rule.silent) {
2188
+ if (this.root) {
2189
+ rulesets.push(rule.toCSS(env));
2190
+ } else {
2191
+ rules.push(rule.toCSS(env));
2192
+ }
2193
+ }
2194
+ } else {
2195
+ if (rule.toCSS && !rule.variable) {
2196
+ rules.push(rule.toCSS(env));
2197
+ } else if (rule.value && !rule.variable) {
2198
+ rules.push(rule.value.toString());
2199
+ }
2200
+ }
2201
+ }
2202
+
2203
+ rulesets = rulesets.join('');
2204
+
2205
+ // If this is the root node, we don't render
2206
+ // a selector, or {}.
2207
+ // Otherwise, only output if this ruleset has rules.
2208
+ if (this.root) {
2209
+ css.push(rules.join(env.compress ? '' : '\n'));
2210
+ } else {
2211
+ if (rules.length > 0) {
2212
+ selector = paths.map(function (p) {
2213
+ return p.map(function (s) {
2214
+ return s.toCSS(env);
2215
+ }).join('').trim();
2216
+ }).join(env.compress ? ',' : (paths.length > 3 ? ',\n' : ', '));
2217
+ css.push(selector,
2218
+ (env.compress ? '{' : ' {\n ') +
2219
+ rules.join(env.compress ? '' : '\n ') +
2220
+ (env.compress ? '}' : '\n}\n'));
2221
+ }
2222
+ }
2223
+ css.push(rulesets);
2224
+
2225
+ return css.join('') + (env.compress ? '\n' : '');
2226
+ }
2227
+ };
2228
+ })(require('less/tree'));
2229
+ (function (tree) {
2230
+
2231
+ tree.Selector = function (elements) {
2232
+ this.elements = elements;
2233
+ if (this.elements[0].combinator.value === "") {
2234
+ this.elements[0].combinator.value = ' ';
2235
+ }
2236
+ };
2237
+ tree.Selector.prototype.match = function (other) {
2238
+ if (this.elements[0].value === other.elements[0].value) {
2239
+ return true;
2240
+ } else {
2241
+ return false;
2242
+ }
2243
+ };
2244
+ tree.Selector.prototype.toCSS = function (env) {
2245
+ if (this._css) { return this._css }
2246
+
2247
+ return this._css = this.elements.map(function (e) {
2248
+ if (typeof(e) === 'string') {
2249
+ return ' ' + e.trim();
2250
+ } else {
2251
+ return e.toCSS(env);
2252
+ }
2253
+ }).join('');
2254
+ };
2255
+
2256
+ })(require('less/tree'));
2257
+ (function (tree) {
2258
+
2259
+ tree.URL = function (val, paths) {
2260
+ if (val.data) {
2261
+ this.attrs = val;
2262
+ } else {
2263
+ // Add the base path if the URL is relative and we are in the browser
2264
+ if (!/^(?:https?:\/|file:\/|data:\/)?\//.test(val.value) && paths.length > 0 && typeof(window) !== 'undefined') {
2265
+ val.value = paths[0] + (val.value.charAt(0) === '/' ? val.value.slice(1) : val.value);
2266
+ }
2267
+ this.value = val;
2268
+ this.paths = paths;
2269
+ }
2270
+ };
2271
+ tree.URL.prototype = {
2272
+ toCSS: function () {
2273
+ return "url(" + (this.attrs ? 'data:' + this.attrs.mime + this.attrs.charset + this.attrs.base64 + this.attrs.data
2274
+ : this.value.toCSS()) + ")";
2275
+ },
2276
+ eval: function (ctx) {
2277
+ return this.attrs ? this : new(tree.URL)(this.value.eval(ctx), this.paths);
2278
+ }
2279
+ };
2280
+
2281
+ })(require('less/tree'));
2282
+ (function (tree) {
2283
+
2284
+ tree.Value = function (value) {
2285
+ this.value = value;
2286
+ this.is = 'value';
2287
+ };
2288
+ tree.Value.prototype = {
2289
+ eval: function (env) {
2290
+ if (this.value.length === 1) {
2291
+ return this.value[0].eval(env);
2292
+ } else {
2293
+ return new(tree.Value)(this.value.map(function (v) {
2294
+ return v.eval(env);
2295
+ }));
2296
+ }
2297
+ },
2298
+ toCSS: function (env) {
2299
+ return this.value.map(function (e) {
2300
+ return e.toCSS(env);
2301
+ }).join(env.compress ? ',' : ', ');
2302
+ }
2303
+ };
2304
+
2305
+ })(require('less/tree'));
2306
+ (function (tree) {
2307
+
2308
+ tree.Variable = function (name, index) { this.name = name, this.index = index };
2309
+ tree.Variable.prototype = {
2310
+ eval: function (env) {
2311
+ var variable, v, name = this.name;
2312
+
2313
+ if (name.indexOf('@@') == 0) {
2314
+ name = '@' + new(tree.Variable)(name.slice(1)).eval(env).value;
2315
+ }
2316
+
2317
+ if (variable = tree.find(env.frames, function (frame) {
2318
+ if (v = frame.variable(name)) {
2319
+ return v.value.eval(env);
2320
+ }
2321
+ })) { return variable }
2322
+ else {
2323
+ throw { message: "variable " + name + " is undefined",
2324
+ index: this.index };
2325
+ }
2326
+ }
2327
+ };
2328
+
2329
+ })(require('less/tree'));
2330
+ require('less/tree').find = function (obj, fun) {
2331
+ for (var i = 0, r; i < obj.length; i++) {
2332
+ if (r = fun.call(obj, obj[i])) { return r }
2333
+ }
2334
+ return null;
2335
+ };
2336
+ require('less/tree').jsify = function (obj) {
2337
+ if (Array.isArray(obj.value) && (obj.value.length > 1)) {
2338
+ return '[' + obj.value.map(function (v) { return v.toCSS(false) }).join(', ') + ']';
2339
+ } else {
2340
+ return obj.toCSS(false);
2341
+ }
2342
+ };
2343
+ //
2344
+ // browser.js - client-side engine
2345
+ //
2346
+
2347
+ var isFileProtocol = (location.protocol === 'file:' ||
2348
+ location.protocol === 'chrome:' ||
2349
+ location.protocol === 'chrome-extension:' ||
2350
+ location.protocol === 'resource:');
2351
+
2352
+ less.env = less.env || (location.hostname == '127.0.0.1' ||
2353
+ location.hostname == '0.0.0.0' ||
2354
+ location.hostname == 'localhost' ||
2355
+ location.port.length > 0 ||
2356
+ isFileProtocol ? 'development'
2357
+ : 'production');
2358
+
2359
+ // Load styles asynchronously (default: false)
2360
+ //
2361
+ // This is set to `false` by default, so that the body
2362
+ // doesn't start loading before the stylesheets are parsed.
2363
+ // Setting this to `true` can result in flickering.
2364
+ //
2365
+ less.async = false;
2366
+
2367
+ // Interval between watch polls
2368
+ less.poll = less.poll || (isFileProtocol ? 1000 : 1500);
2369
+
2370
+ //
2371
+ // Watch mode
2372
+ //
2373
+ less.watch = function () { return this.watchMode = true };
2374
+ less.unwatch = function () { return this.watchMode = false };
2375
+
2376
+ if (less.env === 'development') {
2377
+ less.optimization = 0;
2378
+
2379
+ if (/!watch/.test(location.hash)) {
2380
+ less.watch();
2381
+ }
2382
+ less.watchTimer = setInterval(function () {
2383
+ if (less.watchMode) {
2384
+ loadStyleSheets(function (root, sheet, env) {
2385
+ if (root) {
2386
+ createCSS(root.toCSS(), sheet, env.lastModified);
2387
+ }
2388
+ });
2389
+ }
2390
+ }, less.poll);
2391
+ } else {
2392
+ less.optimization = 3;
2393
+ }
2394
+
2395
+ var cache;
2396
+
2397
+ try {
2398
+ cache = (typeof(window.localStorage) === 'undefined') ? null : window.localStorage;
2399
+ } catch (_) {
2400
+ cache = null;
2401
+ }
2402
+
2403
+ //
2404
+ // Get all <link> tags with the 'rel' attribute set to "stylesheet/less"
2405
+ //
2406
+ var links = document.getElementsByTagName('link');
2407
+ var typePattern = /^text\/(x-)?less$/;
2408
+
2409
+ less.sheets = [];
2410
+
2411
+ for (var i = 0; i < links.length; i++) {
2412
+ if (links[i].rel === 'stylesheet/less' || (links[i].rel.match(/stylesheet/) &&
2413
+ (links[i].type.match(typePattern)))) {
2414
+ less.sheets.push(links[i]);
2415
+ }
2416
+ }
2417
+
2418
+
2419
+ less.refresh = function (reload) {
2420
+ var startTime, endTime;
2421
+ startTime = endTime = new(Date);
2422
+
2423
+ loadStyleSheets(function (root, sheet, env) {
2424
+ if (env.local) {
2425
+ log("loading " + sheet.href + " from cache.");
2426
+ } else {
2427
+ log("parsed " + sheet.href + " successfully.");
2428
+ createCSS(root.toCSS(), sheet, env.lastModified);
2429
+ }
2430
+ log("css for " + sheet.href + " generated in " + (new(Date) - endTime) + 'ms');
2431
+ (env.remaining === 0) && log("css generated in " + (new(Date) - startTime) + 'ms');
2432
+ endTime = new(Date);
2433
+ }, reload);
2434
+
2435
+ loadStyles();
2436
+ };
2437
+ less.refreshStyles = loadStyles;
2438
+
2439
+ less.refresh(less.env === 'development');
2440
+
2441
+ function loadStyles() {
2442
+ var styles = document.getElementsByTagName('style');
2443
+ for (var i = 0; i < styles.length; i++) {
2444
+ if (styles[i].type.match(typePattern)) {
2445
+ new(less.Parser)().parse(styles[i].innerHTML || '', function (e, tree) {
2446
+ styles[i].type = 'text/css';
2447
+ styles[i].innerHTML = tree.toCSS();
2448
+ });
2449
+ }
2450
+ }
2451
+ }
2452
+
2453
+ function loadStyleSheets(callback, reload) {
2454
+ for (var i = 0; i < less.sheets.length; i++) {
2455
+ loadStyleSheet(less.sheets[i], callback, reload, less.sheets.length - (i + 1));
2456
+ }
2457
+ }
2458
+
2459
+ function loadStyleSheet(sheet, callback, reload, remaining) {
2460
+ var url = window.location.href.replace(/[#?].*$/, '');
2461
+ var href = sheet.href.replace(/\?.*$/, '');
2462
+ var css = cache && cache.getItem(href);
2463
+ var timestamp = cache && cache.getItem(href + ':timestamp');
2464
+ var styles = { css: css, timestamp: timestamp };
2465
+
2466
+ // Stylesheets in IE don't always return the full path
2467
+ if (! /^(https?|file):/.test(href)) {
2468
+ if (href.charAt(0) == "/") {
2469
+ href = window.location.protocol + "//" + window.location.host + href;
2470
+ } else {
2471
+ href = url.slice(0, url.lastIndexOf('/') + 1) + href;
2472
+ }
2473
+ }
2474
+
2475
+ xhr(sheet.href, sheet.type, function (data, lastModified) {
2476
+ if (!reload && styles && lastModified &&
2477
+ (new(Date)(lastModified).valueOf() ===
2478
+ new(Date)(styles.timestamp).valueOf())) {
2479
+ // Use local copy
2480
+ createCSS(styles.css, sheet);
2481
+ callback(null, sheet, { local: true, remaining: remaining });
2482
+ } else {
2483
+ // Use remote copy (re-parse)
2484
+ try {
2485
+ new(less.Parser)({
2486
+ optimization: less.optimization,
2487
+ paths: [href.replace(/[\w\.-]+$/, '')],
2488
+ mime: sheet.type
2489
+ }).parse(data, function (e, root) {
2490
+ if (e) { return error(e, href) }
2491
+ try {
2492
+ callback(root, sheet, { local: false, lastModified: lastModified, remaining: remaining });
2493
+ removeNode(document.getElementById('less-error-message:' + extractId(href)));
2494
+ } catch (e) {
2495
+ error(e, href);
2496
+ }
2497
+ });
2498
+ } catch (e) {
2499
+ error(e, href);
2500
+ }
2501
+ }
2502
+ }, function (status, url) {
2503
+ throw new(Error)("Couldn't load " + url + " (" + status + ")");
2504
+ });
2505
+ }
2506
+
2507
+ function extractId(href) {
2508
+ return href.replace(/^[a-z]+:\/\/?[^\/]+/, '' ) // Remove protocol & domain
2509
+ .replace(/^\//, '' ) // Remove root /
2510
+ .replace(/\?.*$/, '' ) // Remove query
2511
+ .replace(/\.[^\.\/]+$/, '' ) // Remove file extension
2512
+ .replace(/[^\.\w-]+/g, '-') // Replace illegal characters
2513
+ .replace(/\./g, ':'); // Replace dots with colons(for valid id)
2514
+ }
2515
+
2516
+ function createCSS(styles, sheet, lastModified) {
2517
+ var css;
2518
+
2519
+ // Strip the query-string
2520
+ var href = sheet.href ? sheet.href.replace(/\?.*$/, '') : '';
2521
+
2522
+ // If there is no title set, use the filename, minus the extension
2523
+ var id = 'less:' + (sheet.title || extractId(href));
2524
+
2525
+ // If the stylesheet doesn't exist, create a new node
2526
+ if ((css = document.getElementById(id)) === null) {
2527
+ css = document.createElement('style');
2528
+ css.type = 'text/css';
2529
+ css.media = sheet.media || 'screen';
2530
+ css.id = id;
2531
+ document.getElementsByTagName('head')[0].appendChild(css);
2532
+ }
2533
+
2534
+ if (css.styleSheet) { // IE
2535
+ try {
2536
+ css.styleSheet.cssText = styles;
2537
+ } catch (e) {
2538
+ throw new(Error)("Couldn't reassign styleSheet.cssText.");
2539
+ }
2540
+ } else {
2541
+ (function (node) {
2542
+ if (css.childNodes.length > 0) {
2543
+ if (css.firstChild.nodeValue !== node.nodeValue) {
2544
+ css.replaceChild(node, css.firstChild);
2545
+ }
2546
+ } else {
2547
+ css.appendChild(node);
2548
+ }
2549
+ })(document.createTextNode(styles));
2550
+ }
2551
+
2552
+ // Don't update the local store if the file wasn't modified
2553
+ if (lastModified && cache) {
2554
+ log('saving ' + href + ' to cache.');
2555
+ cache.setItem(href, styles);
2556
+ cache.setItem(href + ':timestamp', lastModified);
2557
+ }
2558
+ }
2559
+
2560
+ function xhr(url, type, callback, errback) {
2561
+ var xhr = getXMLHttpRequest();
2562
+ var async = isFileProtocol ? false : less.async;
2563
+
2564
+ if (typeof(xhr.overrideMimeType) === 'function') {
2565
+ xhr.overrideMimeType('text/css');
2566
+ }
2567
+ xhr.open('GET', url, async);
2568
+ xhr.setRequestHeader('Accept', type || 'text/x-less, text/css; q=0.9, */*; q=0.5');
2569
+ xhr.send(null);
2570
+
2571
+ if (isFileProtocol) {
2572
+ if (xhr.status === 0) {
2573
+ callback(xhr.responseText);
2574
+ } else {
2575
+ errback(xhr.status, url);
2576
+ }
2577
+ } else if (async) {
2578
+ xhr.onreadystatechange = function () {
2579
+ if (xhr.readyState == 4) {
2580
+ handleResponse(xhr, callback, errback);
2581
+ }
2582
+ };
2583
+ } else {
2584
+ handleResponse(xhr, callback, errback);
2585
+ }
2586
+
2587
+ function handleResponse(xhr, callback, errback) {
2588
+ if (xhr.status >= 200 && xhr.status < 300) {
2589
+ callback(xhr.responseText,
2590
+ xhr.getResponseHeader("Last-Modified"));
2591
+ } else if (typeof(errback) === 'function') {
2592
+ errback(xhr.status, url);
2593
+ }
2594
+ }
2595
+ }
2596
+
2597
+ function getXMLHttpRequest() {
2598
+ if (window.XMLHttpRequest) {
2599
+ return new(XMLHttpRequest);
2600
+ } else {
2601
+ try {
2602
+ return new(ActiveXObject)("MSXML2.XMLHTTP.3.0");
2603
+ } catch (e) {
2604
+ log("browser doesn't support AJAX.");
2605
+ return null;
2606
+ }
2607
+ }
2608
+ }
2609
+
2610
+ function removeNode(node) {
2611
+ return node && node.parentNode.removeChild(node);
2612
+ }
2613
+
2614
+ function log(str) {
2615
+ if (less.env == 'development' && typeof(console) !== "undefined") { console.log('less: ' + str) }
2616
+ }
2617
+
2618
+ function error(e, href) {
2619
+ var id = 'less-error-message:' + extractId(href);
2620
+
2621
+ var template = ['<ul>',
2622
+ '<li><label>[-1]</label><pre class="ctx">{0}</pre></li>',
2623
+ '<li><label>[0]</label><pre>{current}</pre></li>',
2624
+ '<li><label>[1]</label><pre class="ctx">{2}</pre></li>',
2625
+ '</ul>'].join('\n');
2626
+
2627
+ var elem = document.createElement('div'), timer, content;
2628
+
2629
+ elem.id = id;
2630
+ elem.className = "less-error-message";
2631
+
2632
+ content = '<h3>' + (e.message || 'There is an error in your .less file') +
2633
+ '</h3>' + '<p><a href="' + href + '">' + href + "</a> ";
2634
+
2635
+ if (e.extract) {
2636
+ content += 'on line ' + e.line + ', column ' + (e.column + 1) + ':</p>' +
2637
+ template.replace(/\[(-?\d)\]/g, function (_, i) {
2638
+ return (parseInt(e.line) + parseInt(i)) || '';
2639
+ }).replace(/\{(\d)\}/g, function (_, i) {
2640
+ return e.extract[parseInt(i)] || '';
2641
+ }).replace(/\{current\}/, e.extract[1].slice(0, e.column) + '<span class="error">' +
2642
+ e.extract[1].slice(e.column) + '</span>');
2643
+ }
2644
+ elem.innerHTML = content;
2645
+
2646
+ // CSS for error messages
2647
+ createCSS([
2648
+ '.less-error-message ul, .less-error-message li {',
2649
+ 'list-style-type: none;',
2650
+ 'margin-right: 15px;',
2651
+ 'padding: 4px 0;',
2652
+ 'margin: 0;',
2653
+ '}',
2654
+ '.less-error-message label {',
2655
+ 'font-size: 12px;',
2656
+ 'margin-right: 15px;',
2657
+ 'padding: 4px 0;',
2658
+ 'color: #cc7777;',
2659
+ '}',
2660
+ '.less-error-message pre {',
2661
+ 'color: #ee4444;',
2662
+ 'padding: 4px 0;',
2663
+ 'margin: 0;',
2664
+ 'display: inline-block;',
2665
+ '}',
2666
+ '.less-error-message pre.ctx {',
2667
+ 'color: #dd4444;',
2668
+ '}',
2669
+ '.less-error-message h3 {',
2670
+ 'font-size: 20px;',
2671
+ 'font-weight: bold;',
2672
+ 'padding: 15px 0 5px 0;',
2673
+ 'margin: 0;',
2674
+ '}',
2675
+ '.less-error-message a {',
2676
+ 'color: #10a',
2677
+ '}',
2678
+ '.less-error-message .error {',
2679
+ 'color: red;',
2680
+ 'font-weight: bold;',
2681
+ 'padding-bottom: 2px;',
2682
+ 'border-bottom: 1px dashed red;',
2683
+ '}'
2684
+ ].join('\n'), { title: 'error-message' });
2685
+
2686
+ elem.style.cssText = [
2687
+ "font-family: Arial, sans-serif",
2688
+ "border: 1px solid #e00",
2689
+ "background-color: #eee",
2690
+ "border-radius: 5px",
2691
+ "-webkit-border-radius: 5px",
2692
+ "-moz-border-radius: 5px",
2693
+ "color: #e00",
2694
+ "padding: 15px",
2695
+ "margin-bottom: 15px"
2696
+ ].join(';');
2697
+
2698
+ if (less.env == 'development') {
2699
+ timer = setInterval(function () {
2700
+ if (document.body) {
2701
+ if (document.getElementById(id)) {
2702
+ document.body.replaceChild(elem, document.getElementById(id));
2703
+ } else {
2704
+ document.body.insertBefore(elem, document.body.firstChild);
2705
+ }
2706
+ clearInterval(timer);
2707
+ }
2708
+ }, 10);
2709
+ }
2710
+ }
2711
+
2712
+ })(window);