less 2.3.3 → 2.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (185) hide show
  1. checksums.yaml +4 -4
  2. data/Changelog.md +5 -0
  3. data/less.gemspec +1 -1
  4. data/lib/less/js/.gitattributes +9 -0
  5. data/lib/less/js/.gitignore +1 -0
  6. data/lib/less/js/.npmignore +1 -1
  7. data/lib/less/js/CHANGELOG.md +68 -0
  8. data/lib/less/js/CONTRIBUTING.md +33 -34
  9. data/lib/less/js/Makefile +24 -9
  10. data/lib/less/js/README.md +2 -2
  11. data/lib/less/js/bin/lessc +102 -25
  12. data/lib/less/js/build/amd.js +1 -1
  13. data/lib/less/js/build/header.js +9 -7
  14. data/lib/less/js/dist/less-1.3.3.js +2 -2
  15. data/lib/less/js/dist/less-1.3.3.min.js +2 -2
  16. data/lib/less/js/dist/less-1.4.0-beta.js +5830 -0
  17. data/lib/less/js/dist/less-1.4.0-beta.min.js +11 -0
  18. data/lib/less/js/dist/less-1.4.0.js +5830 -0
  19. data/lib/less/js/dist/less-1.4.0.min.js +11 -0
  20. data/lib/less/js/dist/less-1.4.1.js +5837 -0
  21. data/lib/less/js/dist/less-1.4.1.min.js +11 -0
  22. data/lib/less/js/dist/less-1.4.2.js +5837 -0
  23. data/lib/less/js/dist/less-1.4.2.min.js +11 -0
  24. data/lib/less/js/dist/less-rhino-1.4.0.js +4273 -0
  25. data/lib/less/js/lib/less/browser.js +131 -101
  26. data/lib/less/js/lib/less/env.js +105 -0
  27. data/lib/less/js/lib/less/extend-visitor.js +391 -0
  28. data/lib/less/js/lib/less/functions.js +174 -19
  29. data/lib/less/js/lib/less/import-visitor.js +107 -0
  30. data/lib/less/js/lib/less/index.js +70 -63
  31. data/lib/less/js/lib/less/join-selector-visitor.js +37 -0
  32. data/lib/less/js/lib/less/lessc_helper.js +13 -4
  33. data/lib/less/js/lib/less/parser.js +353 -264
  34. data/lib/less/js/lib/less/rhino.js +5 -2
  35. data/lib/less/js/lib/less/tree.js +1 -1
  36. data/lib/less/js/lib/less/tree/alpha.js +7 -3
  37. data/lib/less/js/lib/less/tree/anonymous.js +1 -0
  38. data/lib/less/js/lib/less/tree/assignment.js +4 -0
  39. data/lib/less/js/lib/less/tree/call.js +14 -8
  40. data/lib/less/js/lib/less/tree/color.js +50 -5
  41. data/lib/less/js/lib/less/tree/comment.js +1 -0
  42. data/lib/less/js/lib/less/tree/condition.js +35 -28
  43. data/lib/less/js/lib/less/tree/dimension.js +270 -16
  44. data/lib/less/js/lib/less/tree/directive.js +7 -2
  45. data/lib/less/js/lib/less/tree/element.js +57 -21
  46. data/lib/less/js/lib/less/tree/expression.js +29 -4
  47. data/lib/less/js/lib/less/tree/extend.js +43 -0
  48. data/lib/less/js/lib/less/tree/import.js +49 -28
  49. data/lib/less/js/lib/less/tree/javascript.js +1 -0
  50. data/lib/less/js/lib/less/tree/keyword.js +3 -2
  51. data/lib/less/js/lib/less/tree/media.js +20 -4
  52. data/lib/less/js/lib/less/tree/mixin.js +38 -18
  53. data/lib/less/js/lib/less/tree/negative.js +22 -0
  54. data/lib/less/js/lib/less/tree/operation.js +32 -17
  55. data/lib/less/js/lib/less/tree/paren.js +5 -1
  56. data/lib/less/js/lib/less/tree/quoted.js +5 -3
  57. data/lib/less/js/lib/less/tree/rule.js +44 -31
  58. data/lib/less/js/lib/less/tree/ruleset.js +50 -23
  59. data/lib/less/js/lib/less/tree/selector.js +49 -39
  60. data/lib/less/js/lib/less/tree/unicode-descriptor.js +1 -0
  61. data/lib/less/js/lib/less/tree/url.js +9 -5
  62. data/lib/less/js/lib/less/tree/value.js +4 -1
  63. data/lib/less/js/lib/less/tree/variable.js +4 -3
  64. data/lib/less/js/lib/less/visitor.js +54 -0
  65. data/lib/less/js/package.json +69 -19
  66. data/lib/less/js/test/browser-test-prepare.js +23 -6
  67. data/lib/less/js/test/browser/common.js +55 -3
  68. data/lib/less/js/test/browser/css/urls.css +13 -0
  69. data/lib/less/js/test/browser/less/relative-urls/urls.less +1 -1
  70. data/lib/less/js/test/browser/less/urls.less +16 -0
  71. data/lib/less/js/test/browser/phantom-runner.js +7 -5
  72. data/lib/less/js/test/browser/runner-browser.js +5 -1
  73. data/lib/less/js/test/browser/runner-errors.js +5 -0
  74. data/lib/less/js/test/browser/runner-legacy.js +6 -0
  75. data/lib/less/js/test/browser/runner-production.js +7 -0
  76. data/lib/less/js/test/browser/template.htm +6 -6
  77. data/lib/less/js/test/css/comments.css +1 -0
  78. data/lib/less/js/test/css/compression/compression.css +2 -0
  79. data/lib/less/js/test/css/css-3.css +4 -0
  80. data/lib/less/js/test/css/css.css +9 -3
  81. data/lib/less/js/test/css/extend-chaining.css +72 -0
  82. data/lib/less/js/test/css/extend-clearfix.css +19 -0
  83. data/lib/less/js/test/css/extend-exact.css +37 -0
  84. data/lib/less/js/test/css/extend-media.css +24 -0
  85. data/lib/less/js/test/css/extend-nest.css +57 -0
  86. data/lib/less/js/test/css/extend-selector.css +72 -0
  87. data/lib/less/js/test/css/extend.css +76 -0
  88. data/lib/less/js/test/css/functions.css +28 -0
  89. data/lib/less/js/test/css/import-interpolation.css +6 -0
  90. data/lib/less/js/test/css/import.css +18 -1
  91. data/lib/less/js/test/css/legacy/legacy.css +7 -0
  92. data/lib/less/js/test/css/media.css +9 -1
  93. data/lib/less/js/test/css/mixins-args.css +18 -0
  94. data/lib/less/js/test/css/mixins-guards.css +5 -0
  95. data/lib/less/js/test/css/parens.css +18 -5
  96. data/lib/less/js/test/css/selectors.css +14 -6
  97. data/lib/less/js/test/css/urls.css +17 -0
  98. data/lib/less/js/test/css/variables.css +22 -3
  99. data/lib/less/js/test/data/data-uri-fail.png +0 -0
  100. data/lib/less/js/test/data/image.jpg +0 -0
  101. data/lib/less/js/test/data/page.html +1 -0
  102. data/lib/less/js/test/less-test.js +41 -9
  103. data/lib/less/js/test/less/colors.less +4 -4
  104. data/lib/less/js/test/less/comments.less +2 -2
  105. data/lib/less/js/test/less/compression/compression.less +16 -0
  106. data/lib/less/js/test/less/css-3.less +5 -1
  107. data/lib/less/js/test/less/css.less +9 -3
  108. data/lib/less/js/test/less/errors/add-mixed-units.less +3 -0
  109. data/lib/less/js/test/less/errors/add-mixed-units.txt +2 -0
  110. data/lib/less/js/test/less/errors/add-mixed-units2.less +3 -0
  111. data/lib/less/js/test/less/errors/add-mixed-units2.txt +2 -0
  112. data/lib/less/js/test/less/errors/bad-variable-declaration1.txt +1 -1
  113. data/lib/less/js/test/less/errors/color-operation-error.less +3 -0
  114. data/lib/less/js/test/less/errors/color-operation-error.txt +2 -0
  115. data/lib/less/js/test/less/errors/comment-in-selector.txt +1 -1
  116. data/lib/less/js/test/less/errors/divide-mixed-units.less +3 -0
  117. data/lib/less/js/test/less/errors/divide-mixed-units.txt +4 -0
  118. data/lib/less/js/test/less/errors/extend-no-selector.less +3 -0
  119. data/lib/less/js/test/less/errors/extend-no-selector.txt +3 -0
  120. data/lib/less/js/test/less/errors/extend-not-at-end.less +3 -0
  121. data/lib/less/js/test/less/errors/extend-not-at-end.txt +3 -0
  122. data/lib/less/js/test/less/errors/import-missing.less +5 -0
  123. data/lib/less/js/test/less/errors/import-missing.txt +3 -3
  124. data/lib/less/js/test/less/errors/import-no-semi.txt +1 -1
  125. data/lib/less/js/test/less/errors/import-subfolder1.txt +1 -1
  126. data/lib/less/js/test/less/errors/import-subfolder2.txt +1 -1
  127. data/lib/less/js/test/less/errors/javascript-error.txt +1 -1
  128. data/lib/less/js/test/less/errors/mixed-mixin-definition-args-1.txt +1 -1
  129. data/lib/less/js/test/less/errors/mixed-mixin-definition-args-2.txt +1 -1
  130. data/lib/less/js/test/less/errors/mixin-not-defined.txt +1 -1
  131. data/lib/less/js/test/less/errors/mixin-not-matched.txt +1 -1
  132. data/lib/less/js/test/less/errors/mixin-not-matched2.txt +1 -1
  133. data/lib/less/js/test/less/errors/multiply-mixed-units.less +7 -0
  134. data/lib/less/js/test/less/errors/multiply-mixed-units.txt +4 -0
  135. data/lib/less/js/test/less/errors/parens-error-1.less +3 -0
  136. data/lib/less/js/test/less/errors/parens-error-1.txt +4 -0
  137. data/lib/less/js/test/less/errors/parens-error-2.less +3 -0
  138. data/lib/less/js/test/less/errors/parens-error-2.txt +4 -0
  139. data/lib/less/js/test/less/errors/parens-error-3.less +3 -0
  140. data/lib/less/js/test/less/errors/parens-error-3.txt +4 -0
  141. data/lib/less/js/test/less/errors/parse-error-curly-bracket.txt +1 -1
  142. data/lib/less/js/test/less/errors/parse-error-missing-bracket.txt +2 -1
  143. data/lib/less/js/test/less/errors/parse-error-with-import.txt +1 -1
  144. data/lib/less/js/test/less/errors/property-ie5-hack.txt +1 -1
  145. data/lib/less/js/test/less/errors/property-in-root.less +4 -0
  146. data/lib/less/js/test/less/errors/property-in-root.txt +4 -0
  147. data/lib/less/js/test/less/errors/property-in-root2.less +1 -0
  148. data/lib/less/js/test/less/errors/property-in-root2.txt +4 -0
  149. data/lib/less/js/test/less/errors/property-in-root3.less +4 -0
  150. data/lib/less/js/test/less/errors/property-in-root3.txt +3 -0
  151. data/lib/less/js/test/less/errors/recursive-variable.txt +1 -1
  152. data/lib/less/js/test/less/extend-chaining.less +79 -0
  153. data/lib/less/js/test/less/extend-clearfix.less +19 -0
  154. data/lib/less/js/test/less/extend-exact.less +46 -0
  155. data/lib/less/js/test/less/extend-media.less +24 -0
  156. data/lib/less/js/test/less/extend-nest.less +65 -0
  157. data/lib/less/js/test/less/extend-selector.less +84 -0
  158. data/lib/less/js/test/less/extend.less +81 -0
  159. data/lib/less/js/test/less/functions.less +37 -6
  160. data/lib/less/js/test/less/import-interpolation.less +8 -0
  161. data/lib/less/js/test/less/import-once.less +4 -4
  162. data/lib/less/js/test/less/import.less +11 -2
  163. data/lib/less/js/test/less/import/deeper/import-once-test-a.less +1 -1
  164. data/lib/less/js/test/less/import/import-interpolation.less +1 -0
  165. data/lib/less/js/test/less/import/import-interpolation2.less +5 -0
  166. data/lib/less/js/test/less/javascript.less +1 -1
  167. data/lib/less/js/test/less/legacy/legacy.less +7 -0
  168. data/lib/less/js/test/less/media.less +14 -3
  169. data/lib/less/js/test/less/mixins-args.less +43 -5
  170. data/lib/less/js/test/less/mixins-guards.less +13 -0
  171. data/lib/less/js/test/less/mixins-named-args.less +5 -5
  172. data/lib/less/js/test/less/mixins-nested.less +2 -2
  173. data/lib/less/js/test/less/mixins-pattern.less +1 -1
  174. data/lib/less/js/test/less/mixins.less +1 -1
  175. data/lib/less/js/test/less/operations.less +27 -27
  176. data/lib/less/js/test/less/parens.less +20 -5
  177. data/lib/less/js/test/less/selectors.less +14 -7
  178. data/lib/less/js/test/less/urls.less +24 -0
  179. data/lib/less/js/test/less/variables.less +42 -12
  180. data/lib/less/loader.rb +33 -0
  181. data/lib/less/version.rb +1 -1
  182. data/spec/less/parser_spec.rb +5 -5
  183. metadata +76 -6
  184. data/lib/less/js/build/ecma-5.js +0 -120
  185. data/lib/less/js/lib/less/tree/ratio.js +0 -13
@@ -0,0 +1,11 @@
1
+ /*
2
+ * LESS - Leaner CSS v1.4.2
3
+ * http://lesscss.org
4
+ *
5
+ * Copyright (c) 2009-2013, Alexis Sellier
6
+ * Licensed under the Apache 2.0 License.
7
+ *
8
+ * @licence
9
+ */(function(e,t){function n(t){return e.less[t.split("/")[1]]}function f(){r.env==="development"?(r.optimization=0,r.watchTimer=setInterval(function(){r.watchMode&&g(function(e,t,n,i,s){e?k(e,i.href):t&&S(t.toCSS(r),i,s.lastModified)})},r.poll)):r.optimization=3}function m(){var e=document.getElementsByTagName("style");for(var t=0;t<e.length;t++)if(e[t].type.match(p)){var n=new r.tree.parseEnv(r);n.filename=document.location.href.replace(/#.*$/,""),(new r.Parser(n)).parse(e[t].innerHTML||"",function(n,i){if(n)return k(n,"inline");var s=i.toCSS(r),o=e[t];o.type="text/css",o.styleSheet?o.styleSheet.cssText=s:o.innerHTML=s})}}function g(e,t){for(var n=0;n<r.sheets.length;n++)w(r.sheets[n],e,t,r.sheets.length-(n+1))}function y(e,t){var n=b(e),r=b(t),i,s,o,u,a="";if(n.hostPart!==r.hostPart)return"";s=Math.max(r.directories.length,n.directories.length);for(i=0;i<s;i++)if(r.directories[i]!==n.directories[i])break;u=r.directories.slice(i),o=n.directories.slice(i);for(i=0;i<u.length-1;i++)a+="../";for(i=0;i<o.length-1;i++)a+=o[i]+"/";return a}function b(e,t){var n=/^((?:[a-z-]+:)?\/+?(?:[^\/\?#]*\/)|([\/\\]))?((?:[^\/\\\?#]*[\/\\])*)([^\/\\\?#]*)([#\?].*)?$/i,r=e.match(n),i={},s=[],o,u;if(!r)throw new Error("Could not parse sheet href - '"+e+"'");if(!r[1]||r[2]){u=t.match(n);if(!u)throw new Error("Could not parse page url - '"+t+"'");r[1]=r[1]||u[1]||"",r[2]||(r[3]=u[3]+r[3])}if(r[3]){s=r[3].replace(/\\/g,"/").split("/");for(o=0;o<s.length;o++)s[o]==="."&&(s.splice(o,1),o-=1);for(o=0;o<s.length;o++)s[o]===".."&&o>0&&(s.splice(o-1,2),o-=2)}return i.hostPart=r[1],i.directories=s,i.path=r[1]+s.join("/"),i.fileUrl=i.path+(r[4]||""),i.url=i.fileUrl+(r[5]||""),i}function w(t,n,i,s){var o=b(t.href,e.location.href),u=o.url,a=l&&l.getItem(u),f=l&&l.getItem(u+":timestamp"),c={css:a,timestamp:f},h,p={relativeUrls:r.relativeUrls,currentDirectory:o.path,filename:u};t instanceof r.tree.parseEnv?(h=new r.tree.parseEnv(t),p.entryPath=h.currentFileInfo.entryPath,p.rootpath=h.currentFileInfo.rootpath,p.rootFilename=h.currentFileInfo.rootFilename):(h=new r.tree.parseEnv(r),h.mime=t.type,p.entryPath=o.path,p.rootpath=r.rootpath||o.path,p.rootFilename=u),h.relativeUrls&&(r.rootpath?p.rootpath=b(r.rootpath+y(o.path,p.entryPath)).path:p.rootpath=o.path),x(u,t.type,function(e,a){v+=e.replace(/@import .+?;/ig,"");if(!i&&c&&a&&(new Date(a)).valueOf()===(new Date(c.timestamp)).valueOf())S(c.css,t),n(null,null,e,t,{local:!0,remaining:s},u);else try{h.contents[u]=e,h.paths=[o.path],h.currentFileInfo=p,(new r.Parser(h)).parse(e,function(r,i){if(r)return n(r,null,null,t);try{n(r,i,e,t,{local:!1,lastModified:a,remaining:s},u),h.currentFileInfo.rootFilename===u&&N(document.getElementById("less-error-message:"+E(u)))}catch(r){n(r,null,null,t)}})}catch(f){n(f,null,null,t)}},function(e,r){n({type:"File",message:"'"+r+"' wasn't found ("+e+")"},null,null,t)})}function E(e){return e.replace(/^[a-z-]+:\/+?[^\/]+/,"").replace(/^\//,"").replace(/\.[a-zA-Z]+$/,"").replace(/[^\.\w-]+/g,"-").replace(/\./g,":")}function S(e,t,n){var r=t.href||"",i="less:"+(t.title||E(r)),s=document.getElementById(i),o=!1,u=document.createElement("style");u.setAttribute("type","text/css"),t.media&&u.setAttribute("media",t.media),u.id=i;if(u.styleSheet)try{u.styleSheet.cssText=e}catch(a){throw new Error("Couldn't reassign styleSheet.cssText.")}else u.appendChild(document.createTextNode(e)),o=s!==null&&s.childNodes.length>0&&u.childNodes.length>0&&s.firstChild.nodeValue===u.firstChild.nodeValue;var f=document.getElementsByTagName("head")[0];if(s==null||o===!1){var c=t&&t.nextSibling||null;(c||document.getElementsByTagName("head")[0]).parentNode.insertBefore(u,c)}s&&o===!1&&f.removeChild(s);if(n&&l){C("saving "+r+" to cache.");try{l.setItem(r,e),l.setItem(r+":timestamp",n)}catch(a){C("failed to save")}}}function x(e,t,n,i){function a(t,n,r){t.status>=200&&t.status<300?n(t.responseText,t.getResponseHeader("Last-Modified")):typeof r=="function"&&r(t.status,e)}var s=T(),u=o?r.fileAsync:r.async;typeof s.overrideMimeType=="function"&&s.overrideMimeType("text/css"),s.open("GET",e,u),s.setRequestHeader("Accept",t||"text/x-less, text/css; q=0.9, */*; q=0.5"),s.send(null),o&&!r.fileAsync?s.status===0||s.status>=200&&s.status<300?n(s.responseText):i(s.status,e):u?s.onreadystatechange=function(){s.readyState==4&&a(s,n,i)}:a(s,n,i)}function T(){if(e.XMLHttpRequest)return new XMLHttpRequest;try{return new ActiveXObject("MSXML2.XMLHTTP.3.0")}catch(t){return C("browser doesn't support AJAX."),null}}function N(e){return e&&e.parentNode.removeChild(e)}function C(e){r.env=="development"&&typeof console!="undefined"&&console.log("less: "+e)}function k(e,n){var i="less-error-message:"+E(n||""),s='<li><label>{line}</label><pre class="{class}">{content}</pre></li>',o=document.createElement("div"),u,a,f=[],l=e.filename||n,c=l.match(/([^\/]+(\?.*)?)$/)[1];o.id=i,o.className="less-error-message",a="<h3>"+(e.type||"Syntax")+"Error: "+(e.message||"There is an error in your .less file")+"</h3>"+'<p>in <a href="'+l+'">'+c+"</a> ";var h=function(e,n,r){e.extract[n]!=t&&f.push(s.replace(/\{line\}/,(parseInt(e.line)||0)+(n-1)).replace(/\{class\}/,r).replace(/\{content\}/,e.extract[n]))};e.extract?(h(e,0,""),h(e,1,"line"),h(e,2,""),a+="on line "+e.line+", column "+(e.column+1)+":</p>"+"<ul>"+f.join("")+"</ul>"):e.stack&&(a+="<br/>"+e.stack.split("\n").slice(1).join("<br/>")),o.innerHTML=a,S([".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: #dd6666;","padding: 4px 0;","margin: 0;","display: inline-block;","}",".less-error-message pre.line {","color: #ff0000;","}",".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"}),o.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(";"),r.env=="development"&&(u=setInterval(function(){document.body&&(document.getElementById(i)?document.body.replaceChild(o,document.getElementById(i)):document.body.insertBefore(o,document.body.firstChild),clearInterval(u))},10))}var r,i,s;typeof environment=="object"&&{}.toString.call(environment)==="[object Environment]"?(typeof e=="undefined"?r={}:r=e.less={},i=r.tree={},r.mode="rhino"):typeof e=="undefined"?(r=exports,i=n("./tree"),r.mode="node"):(typeof e.less=="undefined"&&(e.less={}),r=e.less,i=e.less.tree={},r.mode="browser"),r.Parser=function(t){function m(){a=c[u],f=o,h=o}function g(){c[u]=a,o=f,h=o}function y(){o>h&&(c[u]=c[u].slice(o-h),h=o)}function b(e){var t=e.charCodeAt(0);return t===32||t===10||t===9}function w(e){var t,n,r,i,a;if(e instanceof Function)return e.call(p.parsers);if(typeof e=="string")t=s.charAt(o)===e?e:null,r=1,y();else{y();if(!(t=e.exec(c[u])))return null;r=t[0].length}if(t)return E(r),typeof t=="string"?t:t.length===1?t[0]:t}function E(e){var t=o,n=u,r=o+c[u].length,i=o+=e;while(o<r){if(!b(s.charAt(o)))break;o++}return c[u]=c[u].slice(e+(o-i)),h=o,c[u].length===0&&u<c.length-1&&u++,t!==o||n!==u}function S(e,t){var n=w(e);if(!!n)return n;x(t||(typeof e=="string"?"expected '"+e+"' got '"+s.charAt(o)+"'":"unexpected token"))}function x(e,t){var n=new Error(e);throw n.index=o,n.type=t||"Syntax",n}function T(e){return typeof e=="string"?s.charAt(o)===e:e.test(c[u])?!0:!1}function N(e,t){return e.filename&&t.currentFileInfo.filename&&e.filename!==t.currentFileInfo.filename?p.imports.contents[e.filename]:s}function C(e,t){for(var n=e,r=-1;n>=0&&t.charAt(n)!=="\n";n--)r++;return{line:typeof e=="number"?(t.slice(0,e).match(/\n/g)||"").length:null,column:r}}function k(e,t,i){var s=i.currentFileInfo.filename;return r.mode!=="browser"&&r.mode!=="rhino"&&(s=n("path").resolve(s)),{lineNumber:C(e,t).line+1,fileName:s}}function L(e,t){var n=N(e,t),r=C(e.index,n),i=r.line,s=r.column,o=n.split("\n");this.type=e.type||"Syntax",this.message=e.message,this.filename=e.filename||t.currentFileInfo.filename,this.index=e.index,this.line=typeof i=="number"?i+1:null,this.callLine=e.call&&C(e.call,n).line+1,this.callExtract=o[C(e.call,n).line],this.stack=e.stack,this.column=s,this.extract=[o[i-1],o[i],o[i+1]]}var s,o,u,a,f,l,c,h,p,d=this;t instanceof i.parseEnv||(t=new i.parseEnv(t));var v=this.imports={paths:t.paths||[],queue:[],files:t.files,contents:t.contents,mime:t.mime,error:null,push:function(e,n,i){var s=this;this.queue.push(e),r.Parser.importer(e,n,function(t,n,r){s.queue.splice(s.queue.indexOf(e),1);var o=r in s.files;s.files[r]=n,t&&!s.error&&(s.error=t),i(t,n,o)},t)}};return L.prototype=new Error,L.prototype.constructor=L,this.env=t=t||{},this.optimization="optimization"in this.env?this.env.optimization:1,p={imports:v,parse:function(e,a){var f,d,v,m,g,y,b=[],E,S=null;o=u=h=l=0,s=e.replace(/\r\n/g,"\n"),s=s.replace(/^\uFEFF/,""),c=function(e){var n=0,r=/(?:@\{[\w-]+\}|[^"'`\{\}\/\(\)\\])+/g,i=/\/\*(?:[^*]|\*+[^\/*])*\*+\/|\/\/.*/g,o=/"((?:[^"\\\r\n]|\\.)*)"|'((?:[^'\\\r\n]|\\.)*)'|`((?:[^`]|\\.)*)`/g,u=0,a,f=e[0],l;for(var c=0,h,p;c<s.length;){r.lastIndex=c,(a=r.exec(s))&&a.index===c&&(c+=a[0].length,f.push(a[0])),h=s.charAt(c),i.lastIndex=o.lastIndex=c;if(a=o.exec(s))if(a.index===c){c+=a[0].length,f.push(a[0]);continue}if(!l&&h==="/"){p=s.charAt(c+1);if(p==="/"||p==="*")if(a=i.exec(s))if(a.index===c){c+=a[0].length,f.push(a[0]);continue}}switch(h){case"{":if(!l){u++,f.push(h);break};case"}":if(!l){u--,f.push(h),e[++n]=f=[];break};case"(":if(!l){l=!0,f.push(h);break};case")":if(l){l=!1,f.push(h);break};default:f.push(h)}c++}return u!=0&&(S=new L({index:c-1,type:"Parse",message:u>0?"missing closing `}`":"missing opening `{`",filename:t.currentFileInfo.filename},t)),e.map(function(e){return e.join("")})}([[]]);if(S)return a(new L(S,t));try{f=new i.Ruleset([],w(this.parsers.primary)),f.root=!0,f.firstRoot=!0}catch(x){return a(new L(x,t))}f.toCSS=function(e){var s,o,u;return function(s,o){s=s||{};var u,a=new i.evalEnv(s);typeof o=="object"&&!Array.isArray(o)&&(o=Object.keys(o).map(function(e){var t=o[e];return t instanceof i.Value||(t instanceof i.Expression||(t=new i.Expression([t])),t=new i.Value([t])),new i.Rule("@"+e,t,!1,0)}),a.frames=[new i.Ruleset(null,o)]);try{var f=e.call(this,a);(new i.joinSelectorVisitor).run(f),(new i.processExtendsVisitor).run(f);var l=f.toCSS({compress:Boolean(s.compress),dumpLineNumbers:t.dumpLineNumbers,strictUnits:Boolean(s.strictUnits)})}catch(c){throw new L(c,t)}return s.yuicompress&&r.mode==="node"?n("ycssmin").cssmin(l,s.maxLineLen):s.compress?l.replace(/(\s)+/g,"$1"):l}}(f.eval);if(o<s.length-1){o=l,y=s.split("\n"),g=(s.slice(0,o).match(/\n/g)||"").length+1;for(var T=o,N=-1;T>=0&&s.charAt(T)!=="\n";T--)N++;S={type:"Parse",message:"Unrecognised input",index:o,filename:t.currentFileInfo.filename,line:g,column:N,extract:[y[g-2],y[g-1],y[g]]}}var C=function(e){e=S||e||p.imports.error,e?(e instanceof L||(e=new L(e,t)),a(e)):a(null,f)};t.processImports!==!1?(new i.importVisitor(this.imports,C)).run(f):C()},parsers:{primary:function(){var e,t=[];while((e=w(this.extendRule)||w(this.mixin.definition)||w(this.rule)||w(this.ruleset)||w(this.mixin.call)||w(this.comment)||w(this.directive))||w(/^[\s\n]+/)||w(/^;+/))e&&t.push(e);return t},comment:function(){var e;if(s.charAt(o)!=="/")return;if(s.charAt(o+1)==="/")return new i.Comment(w(/^\/\/.*/),!0);if(e=w(/^\/\*(?:[^*]|\*+[^\/*])*\*+\/\n?/))return new i.Comment(e)},entities:{quoted:function(){var e,n=o,r,u=o;s.charAt(n)==="~"&&(n++,r=!0);if(s.charAt(n)!=='"'&&s.charAt(n)!=="'")return;r&&w("~");if(e=w(/^"((?:[^"\\\r\n]|\\.)*)"|'((?:[^'\\\r\n]|\\.)*)'/))return new i.Quoted(e[0],e[1]||e[2],r,u,t.currentFileInfo)},keyword:function(){var e;if(e=w(/^[_A-Za-z-][_A-Za-z0-9-]*/))return i.colors.hasOwnProperty(e)?new i.Color(i.colors[e].slice(1)):new i.Keyword(e)},call:function(){var e,n,r,s,a=o;if(!(e=/^([\w-]+|%|progid:[\w\.]+)\(/.exec(c[u])))return;e=e[1],n=e.toLowerCase();if(n==="url")return null;o+=e.length;if(n==="alpha"){s=w(this.alpha);if(typeof s!="undefined")return s}w("("),r=w(this.entities.arguments);if(!w(")"))return;if(e)return new i.Call(e,r,a,t.currentFileInfo)},arguments:function(){var e=[],t;while(t=w(this.entities.assignment)||w(this.expression)){e.push(t);if(!w(","))break}return e},literal:function(){return w(this.entities.dimension)||w(this.entities.color)||w(this.entities.quoted)||w(this.entities.unicodeDescriptor)},assignment:function(){var e,t;if((e=w(/^\w+(?=\s?=)/i))&&w("=")&&(t=w(this.entity)))return new i.Assignment(e,t)},url:function(){var e;if(s.charAt(o)!=="u"||!w(/^url\(/))return;return e=w(this.entities.quoted)||w(this.entities.variable)||w(/^(?:(?:\\[\(\)'"])|[^\(\)'"])+/)||"",S(")"),new i.URL(e.value!=null||e instanceof i.Variable?e:new i.Anonymous(e),t.currentFileInfo)},variable:function(){var e,n=o;if(s.charAt(o)==="@"&&(e=w(/^@@?[\w-]+/)))return new i.Variable(e,n,t.currentFileInfo)},variableCurly:function(){var e,n,r=o;if(s.charAt(o)==="@"&&(n=w(/^@\{([\w-]+)\}/)))return new i.Variable("@"+n[1],r,t.currentFileInfo)},color:function(){var e;if(s.charAt(o)==="#"&&(e=w(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})/)))return new i.Color(e[1])},dimension:function(){var e,t=s.charCodeAt(o);if(t>57||t<43||t===47||t==44)return;if(e=w(/^([+-]?\d*\.?\d+)(%|[a-z]+)?/))return new i.Dimension(e[1],e[2])},unicodeDescriptor:function(){var e;if(e=w(/^U\+[0-9a-fA-F?]+(\-[0-9a-fA-F?]+)?/))return new i.UnicodeDescriptor(e[0])},javascript:function(){var e,t=o,n;s.charAt(t)==="~"&&(t++,n=!0);if(s.charAt(t)!=="`")return;n&&w("~");if(e=w(/^`([^`]*)`/))return new i.JavaScript(e[1],o,n)}},variable:function(){var e;if(s.charAt(o)==="@"&&(e=w(/^(@[\w-]+)\s*:/)))return e[1]},extend:function(e){var t,n,r=o,s,u=[];if(!w(e?/^&:extend\(/:/^:extend\(/))return;do{s=null,t=[];for(;;){s=w(/^(all)(?=\s*(\)|,))/);if(s)break;n=w(this.element);if(!n)break;t.push(n)}s=s&&s[1],u.push(new i.Extend(new i.Selector(t),s,r))}while(w(","));return S(/^\)/),e&&S(/^;/),u},extendRule:function(){return this.extend(!0)},mixin:{call:function(){var e=[],n,r,u,a,f,l=o,c=s.charAt(o),h=!1;if(c!=="."&&c!=="#")return;m();while(n=w(/^[#.](?:[\w-]|\\(?:[A-Fa-f0-9]{1,6} ?|[^A-Fa-f0-9]))+/))e.push(new i.Element(r,n,o)),r=w(">");w("(")&&(u=this.mixin.args.call(this,!0).args,S(")")),u=u||[],w(this.important)&&(h=!0);if(e.length>0&&(w(";")||T("}")))return new i.mixin.Call(e,u,l,t.currentFileInfo,h);g()},args:function(e){var t=[],n=[],r,u=[],a,f,l,c,h,p={args:null,variadic:!1};for(;;){if(e)h=w(this.expression);else{w(this.comment);if(s.charAt(o)==="."&&w(/^\.{3}/)){p.variadic=!0,w(";")&&!r&&(r=!0),(r?n:u).push({variadic:!0});break}h=w(this.entities.variable)||w(this.entities.literal)||w(this.entities.keyword)}if(!h)break;l=null,h.throwAwayComments&&h.throwAwayComments(),c=h;var d=null;if(e){if(h.value.length==1)var d=h.value[0]}else d=h;if(d&&d instanceof i.Variable)if(w(":"))t.length>0&&(r&&x("Cannot mix ; and , as delimiter types"),a=!0),c=S(this.expression),l=f=d.name;else{if(!e&&w(/^\.{3}/)){p.variadic=!0,w(";")&&!r&&(r=!0),(r?n:u).push({name:h.name,variadic:!0});break}e||(f=l=d.name,c=null)}c&&t.push(c),u.push({name:l,value:c});if(w(","))continue;if(w(";")||r)a&&x("Cannot mix ; and , as delimiter types"),r=!0,t.length>1&&(c=new i.Value(t)),n.push({name:f,value:c}),f=null,t=[],a=!1}return p.args=r?n:u,p},definition:function(){var e,t=[],n,r,u,a,f,c=!1;if(s.charAt(o)!=="."&&s.charAt(o)!=="#"||T(/^[^{]*\}/))return;m();if(n=w(/^([#.](?:[\w-]|\\(?:[A-Fa-f0-9]{1,6} ?|[^A-Fa-f0-9]))+)\s*\(/)){e=n[1];var h=this.mixin.args.call(this,!1);t=h.args,c=h.variadic,w(")")||(l=o,g()),w(this.comment),w(/^when/)&&(f=S(this.conditions,"expected condition")),r=w(this.block);if(r)return new i.mixin.Definition(e,t,r,f,c);g()}}},entity:function(){return w(this.entities.literal)||w(this.entities.variable)||w(this.entities.url)||w(this.entities.call)||w(this.entities.keyword)||w(this.entities.javascript)||w(this.comment)},end:function(){return w(";")||T("}")},alpha:function(){var e;if(!w(/^\(opacity=/i))return;if(e=w(/^\d+/)||w(this.entities.variable))return S(")"),new i.Alpha(e)},element:function(){var e,t,n,r;n=w(this.combinator),e=w(/^(?:\d+\.\d+|\d+)%/)||w(/^(?:[.#]?|:*)(?:[\w-]|[^\x00-\x9f]|\\(?:[A-Fa-f0-9]{1,6} ?|[^A-Fa-f0-9]))+/)||w("*")||w("&")||w(this.attribute)||w(/^\([^()@]+\)/)||w(/^[\.#](?=@)/)||w(this.entities.variableCurly),e||w("(")&&(r=w(this.selector))&&w(")")&&(e=new i.Paren(r));if(e)return new i.Element(n,e,o)},combinator:function(){var e=s.charAt(o);if(e===">"||e==="+"||e==="~"||e==="|"){o++;while(s.charAt(o).match(/\s/))o++;return new i.Combinator(e)}return s.charAt(o-1).match(/\s/)?new i.Combinator(" "):new i.Combinator(null)},selector:function(){var e,t,n=[],r,u,a=[];while((u=w(this.extend))||(t=w(this.element))){u?a.push.apply(a,u):(a.length&&x("Extend can only be used at the end of selector"),r=s.charAt(o),n.push(t),t=null);if(r==="{"||r==="}"||r===";"||r===","||r===")")break}if(n.length>0)return new i.Selector(n,a);a.length&&x("Extend must be used to extend a selector, it cannot be used on its own")},attribute:function(){var e="",t,n,r;if(!w("["))return;(t=w(this.entities.variableCurly))||(t=S(/^(?:[_A-Za-z0-9-\*]*\|)?(?:[_A-Za-z0-9-]|\\.)+/));if(r=w(/^[|~*$^]?=/))n=w(this.entities.quoted)||w(/^[\w-]+/)||w(this.entities.variableCurly);return S("]"),new i.Attribute(t,r,n)},block:function(){var e;if(w("{")&&(e=w(this.primary))&&w("}"))return e},ruleset:function(){var e=[],n,r,u;m(),t.dumpLineNumbers&&(u=k(o,s,t));while(n=w(this.selector)){e.push(n),w(this.comment);if(!w(","))break;w(this.comment)}if(e.length>0&&(r=w(this.block))){var a=new i.Ruleset(e,r,t.strictImports);return t.dumpLineNumbers&&(a.debugInfo=u),a}l=o,g()},rule:function(e){var n,r,u=s.charAt(o),a;m();if(u==="."||u==="#"||u==="&")return;if(n=w(this.variable)||w(this.property)){r=!e&&(t.compress||n.charAt(0)==="@")?w(this.value)||w(this.anonymousValue):w(this.anonymousValue)||w(this.value),a=w(this.important);if(r&&w(this.end))return new i.Rule(n,r,a,f,t.currentFileInfo);l=o,g();if(r&&!e)return this.rule(!0)}},anonymousValue:function(){var e;if(e=/^([^@+\/'"*`(;{}-]*);/.exec(c[u]))return o+=e[0].length-1,new i.Anonymous(e[1])},"import":function(){var e,n,r=o;m();var s=w(/^@import?\s+/),u=(s?w(this.importOptions):null)||{};if(s&&(e=w(this.entities.quoted)||w(this.entities.url))){n=w(this.mediaFeatures);if(w(";"))return n=n&&new i.Value(n),new i.Import(e,n,u,r,t.currentFileInfo)}g()},importOptions:function(){var e,t={},n,r;if(!w("("))return null;do if(e=w(this.importOption)){n=e,r=!0;switch(n){case"css":n="less",r=!1;break;case"once":n="multiple",r=!1}t[n]=r;if(!w(","))break}while(e);return S(")"),t},importOption:function(){var e=w(/^(less|css|multiple|once)/);if(e)return e[1]},mediaFeature:function(){var e,n,r=[];do if(e=w(this.entities.keyword))r.push(e);else if(w("(")){n=w(this.property),e=w(this.value);if(!w(")"))return null;if(n&&e)r.push(new i.Paren(new i.Rule(n,e,null,o,t.currentFileInfo,!0)));else{if(!e)return null;r.push(new i.Paren(e))}}while(e);if(r.length>0)return new i.Expression(r)},mediaFeatures:function(){var e,t=[];do if(e=w(this.mediaFeature)){t.push(e);if(!w(","))break}else if(e=w(this.entities.variable)){t.push(e);if(!w(","))break}while(e);return t.length>0?t:null},media:function(){var e,n,r,u;t.dumpLineNumbers&&(u=k(o,s,t));if(w(/^@media/)){e=w(this.mediaFeatures);if(n=w(this.block))return r=new i.Media(n,e),t.dumpLineNumbers&&(r.debugInfo=u),r}},directive:function(){var e,n,r,u,a,f,l,c,h,p;if(s.charAt(o)!=="@")return;if(n=w(this["import"])||w(this.media))return n;m(),e=w(/^@[a-z-]+/);if(!e)return;l=e,e.charAt(1)=="-"&&e.indexOf("-",2)>0&&(l="@"+e.slice(e.indexOf("-",2)+1));switch(l){case"@font-face":c=!0;break;case"@viewport":case"@top-left":case"@top-left-corner":case"@top-center":case"@top-right":case"@top-right-corner":case"@bottom-left":case"@bottom-left-corner":case"@bottom-center":case"@bottom-right":case"@bottom-right-corner":case"@left-top":case"@left-middle":case"@left-bottom":case"@right-top":case"@right-middle":case"@right-bottom":c=!0;break;case"@page":case"@document":case"@supports":case"@keyframes":c=!0,h=!0;break;case"@namespace":p=!0}h&&(e+=" "+(w(/^[^{]+/)||"").trim());if(c){if(r=w(this.block))return new i.Directive(e,r)}else if((n=p?w(this.expression):w(this.entity))&&w(";")){var d=new i.Directive(e,n);return t.dumpLineNumbers&&(d.debugInfo=k(o,s,t)),d}g()},value:function(){var e,t=[],n;while(e=w(this.expression)){t.push(e);if(!w(","))break}if(t.length>0)return new i.Value(t)},important:function(){if(s.charAt(o)==="!")return w(/^! *important/)},sub:function(){var e,t;if(w("("))if(e=w(this.addition))return t=new i.Expression([e]),S(")"),t.parens=!0,t},multiplication:function(){var e,t,n,r,u,a=[];if(e=w(this.operand)){u=b(s.charAt(o-1));while(!T(/^\/[*\/]/)&&(n=w("/")||w("*"))){if(!(t=w(this.operand)))break;e.parensInOp=!0,t.parensInOp=!0,r=new i.Operation(n,[r||e,t],u),u=b(s.charAt(o-1))}return r||e}},addition:function(){var e,t,n,r,u;if(e=w(this.multiplication)){u=b(s.charAt(o-1));while((n=w(/^[-+]\s+/)||!u&&(w("+")||w("-")))&&(t=w(this.multiplication)))e.parensInOp=!0,t.parensInOp=!0,r=new i.Operation(n,[r||e,t],u),u=b(s.charAt(o-1));return r||e}},conditions:function(){var e,t,n=o,r;if(e=w(this.condition)){while(w(",")&&(t=w(this.condition)))r=new i.Condition("or",r||e,t,n);return r||e}},condition:function(){var e,t,n,r,s=o,u=!1;w(/^not/)&&(u=!0),S("(");if(e=w(this.addition)||w(this.entities.keyword)||w(this.entities.quoted))return(r=w(/^(?:>=|=<|[<=>])/))?(t=w(this.addition)||w(this.entities.keyword)||w(this.entities.quoted))?n=new i.Condition(r,e,t,s,u):x("expected expression"):n=new i.Condition("=",e,new i.Keyword("true"),s,u),S(")"),w(/^and/)?new i.Condition("and",n,w(this.condition)):n},operand:function(){var e,t=s.charAt(o+1);s.charAt(o)==="-"&&(t==="@"||t==="(")&&(e=w("-"));var n=w(this.sub)||w(this.entities.dimension)||w(this.entities.color)||w(this.entities.variable)||w(this.entities.call);return e&&(n.parensInOp=!0,n=new i.Negative(n)),n},expression:function(){var e,t,n=[],r;while(e=w(this.addition)||w(this.entity))n.push(e),!T(/^\/[\/*]/)&&(t=w("/"))&&n.push(new i.Anonymous(t));if(n.length>0)return new i.Expression(n)},property:function(){var e;if(e=w(/^(\*?-?[_a-zA-Z0-9-]+)\s*:/))return e[1]}}}};if(r.mode==="browser"||r.mode==="rhino")r.Parser.importer=function(e,t,n,r){!/^([a-z-]+:)?\//.test(e)&&t.currentDirectory&&(e=t.currentDirectory+e);var i=r.toSheet(e);i.processImports=!1,i.currentFileInfo=t,w(i,function(e,t,r,i,s,o){n.call(null,e,t,o)},!0)};(function(r){function u(e){return r.functions.hsla(e.h,e.s,e.l,e.a)}function a(e,t){return e instanceof r.Dimension&&e.unit.is("%")?parseFloat(e.value*t/100):f(e)}function f(e){if(e instanceof r.Dimension)return parseFloat(e.unit.is("%")?e.value/100:e.value);if(typeof e=="number")return e;throw{error:"RuntimeError",message:"color functions take numbers as parameters"}}function l(e){return Math.min(1,Math.max(0,e))}r.functions={rgb:function(e,t,n){return this.rgba(e,t,n,1)},rgba:function(e,t,n,i){var s=[e,t,n].map(function(e){return a(e,256)});return i=f(i),new r.Color(s,i)},hsl:function(e,t,n){return this.hsla(e,t,n,1)},hsla:function(e,t,n,r){function o(e){return e=e<0?e+1:e>1?e-1:e,e*6<1?s+(i-s)*e*6:e*2<1?i:e*3<2?s+(i-s)*(2/3-e)*6:s}e=f(e)%360/360,t=l(f(t)),n=l(f(n)),r=l(f(r));var i=n<=.5?n*(t+1):n+t-n*t,s=n*2-i;return this.rgba(o(e+1/3)*255,o(e)*255,o(e-1/3)*255,r)},hsv:function(e,t,n){return this.hsva(e,t,n,1)},hsva:function(e,t,n,r){e=f(e)%360/360*360,t=f(t),n=f(n),r=f(r);var i,s;i=Math.floor(e/60%6),s=e/60-i;var o=[n,n*(1-t),n*(1-s*t),n*(1-(1-s)*t)],u=[[0,3,1],[2,0,1],[1,0,3],[1,2,0],[3,1,0],[0,1,2]];return this.rgba(o[u[i][0]]*255,o[u[i][1]]*255,o[u[i][2]]*255,r)},hue:function(e){return new r.Dimension(Math.round(e.toHSL().h))},saturation:function(e){return new r.Dimension(Math.round(e.toHSL().s*100),"%")},lightness:function(e){return new r.Dimension(Math.round(e.toHSL().l*100),"%")},hsvhue:function(e){return new r.Dimension(Math.round(e.toHSV().h))},hsvsaturation:function(e){return new r.Dimension(Math.round(e.toHSV().s*100),"%")},hsvvalue:function(e){return new r.Dimension(Math.round(e.toHSV().v*100),"%")},red:function(e){return new r.Dimension(e.rgb[0])},green:function(e){return new r.Dimension(e.rgb[1])},blue:function(e){return new r.Dimension(e.rgb[2])},alpha:function(e){return new r.Dimension(e.toHSL().a)},luma:function(e){return new r.Dimension(Math.round(e.luma()*e.alpha*100),"%")},saturate:function(e,t){var n=e.toHSL();return n.s+=t.value/100,n.s=l(n.s),u(n)},desaturate:function(e,t){var n=e.toHSL();return n.s-=t.value/100,n.s=l(n.s),u(n)},lighten:function(e,t){var n=e.toHSL();return n.l+=t.value/100,n.l=l(n.l),u(n)},darken:function(e,t){var n=e.toHSL();return n.l-=t.value/100,n.l=l(n.l),u(n)},fadein:function(e,t){var n=e.toHSL();return n.a+=t.value/100,n.a=l(n.a),u(n)},fadeout:function(e,t){var n=e.toHSL();return n.a-=t.value/100,n.a=l(n.a),u(n)},fade:function(e,t){var n=e.toHSL();return n.a=t.value/100,n.a=l(n.a),u(n)},spin:function(e,t){var n=e.toHSL(),r=(n.h+t.value)%360;return n.h=r<0?360+r:r,u(n)},mix:function(e,t,n){n||(n=new r.Dimension(50));var i=n.value/100,s=i*2-1,o=e.toHSL().a-t.toHSL().a,u=((s*o==-1?s:(s+o)/(1+s*o))+1)/2,a=1-u,f=[e.rgb[0]*u+t.rgb[0]*a,e.rgb[1]*u+t.rgb[1]*a,e.rgb[2]*u+t.rgb[2]*a],l=e.alpha*i+t.alpha*(1-i);return new r.Color(f,l)},greyscale:function(e){return this.desaturate(e,new r.Dimension(100))},contrast:function(e,t,n,r){if(!e.rgb)return null;typeof n=="undefined"&&(n=this.rgba(255,255,255,1)),typeof t=="undefined"&&(t=this.rgba(0,0,0,1));if(t.luma()>n.luma()){var i=n;n=t,t=i}return typeof r=="undefined"?r=.43:r=f(r),e.luma()*e.alpha<r?n:t},e:function(e){return new r.Anonymous(e instanceof r.JavaScript?e.evaluated:e)},escape:function(e){return new r.Anonymous(encodeURI(e.value).replace(/=/g,"%3D").replace(/:/g,"%3A").replace(/#/g,"%23").replace(/;/g,"%3B").replace(/\(/g,"%28").replace(/\)/g,"%29"))},"%":function(e){var t=Array.prototype.slice.call(arguments,1),n=e.value;for(var i=0;i<t.length;i++)n=n.replace(/%[sda]/i,function(e){var n=e.match(/s/i)?t[i].value:t[i].toCSS();return e.match(/[A-Z]$/)?encodeURIComponent(n):n});return n=n.replace(/%%/g,"%"),new r.Quoted('"'+n+'"',n)},unit:function(e,t){return new r.Dimension(e.value,t?t.toCSS():"")},convert:function(e,t){return e.convertTo(t.value)},round:function(e,t){var n=typeof t=="undefined"?0:t.value;return this._math(function(e){return e.toFixed(n)},null,e)},pi:function(){return new r.Dimension(Math.PI)},mod:function(e,t){return new r.Dimension(e.value%t.value,e.unit)},pow:function(e,t){if(typeof e=="number"&&typeof t=="number")e=new r.Dimension(e),t=new r.Dimension(t);else if(!(e instanceof r.Dimension)||!(t instanceof r.Dimension))throw{type:"Argument",message:"arguments must be numbers"};return new r.Dimension(Math.pow(e.value,t.value),e.unit)},_math:function(e,t,n){if(n instanceof r.Dimension)return new r.Dimension(e(parseFloat(n.value)),t==null?n.unit:t);if(typeof n=="number")return e(n);throw{type:"Argument",message:"argument must be a number"}},argb:function(e){return new r.Anonymous(e.toARGB())},percentage:function(e){return new r.Dimension(e.value*100,"%")},color:function(e){if(e instanceof r.Quoted)return new r.Color(e.value.slice(1));throw{type:"Argument",message:"argument must be a string"}},iscolor:function(e){return this._isa(e,r.Color)},isnumber:function(e){return this._isa(e,r.Dimension)},isstring:function(e){return this._isa(e,r.Quoted)},iskeyword:function(e){return this._isa(e,r.Keyword)},isurl:function(e){return this._isa(e,r.URL)},ispixel:function(e){return this.isunit(e,"px")},ispercentage:function(e){return this.isunit(e,"%")},isem:function(e){return this.isunit(e,"em")},isunit:function(e,t){return e instanceof r.Dimension&&e.unit.is(t.value||t)?r.True:r.False},_isa:function(e,t){return e instanceof t?r.True:r.False},multiply:function(e,t){var n=e.rgb[0]*t.rgb[0]/255,r=e.rgb[1]*t.rgb[1]/255,i=e.rgb[2]*t.rgb[2]/255;return this.rgb(n,r,i)},screen:function(e,t){var n=255-(255-e.rgb[0])*(255-t.rgb[0])/255,r=255-(255-e.rgb[1])*(255-t.rgb[1])/255,i=255-(255-e.rgb[2])*(255-t.rgb[2])/255;return this.rgb(n,r,i)},overlay:function(e,t){var n=e.rgb[0]<128?2*e.rgb[0]*t.rgb[0]/255:255-2*(255-e.rgb[0])*(255-t.rgb[0])/255,r=e.rgb[1]<128?2*e.rgb[1]*t.rgb[1]/255:255-2*(255-e.rgb[1])*(255-t.rgb[1])/255,i=e.rgb[2]<128?2*e.rgb[2]*t.rgb[2]/255:255-2*(255-e.rgb[2])*(255-t.rgb[2])/255;return this.rgb(n,r,i)},softlight:function(e,t){var n=t.rgb[0]*e.rgb[0]/255,r=n+e.rgb[0]*(255-(255-e.rgb[0])*(255-t.rgb[0])/255-n)/255;n=t.rgb[1]*e.rgb[1]/255;var i=n+e.rgb[1]*(255-(255-e.rgb[1])*(255-t.rgb[1])/255-n)/255;n=t.rgb[2]*e.rgb[2]/255;var s=n+e.rgb[2]*(255-(255-e.rgb[2])*(255-t.rgb[2])/255-n)/255;return this.rgb(r,i,s)},hardlight:function(e,t){var n=t.rgb[0]<128?2*t.rgb[0]*e.rgb[0]/255:255-2*(255-t.rgb[0])*(255-e.rgb[0])/255,r=t.rgb[1]<128?2*t.rgb[1]*e.rgb[1]/255:255-2*(255-t.rgb[1])*(255-e.rgb[1])/255,i=t.rgb[2]<128?2*t.rgb[2]*e.rgb[2]/255:255-2*(255-t.rgb[2])*(255-e.rgb[2])/255;return this.rgb(n,r,i)},difference:function(e,t){var n=Math.abs(e.rgb[0]-t.rgb[0]),r=Math.abs(e.rgb[1]-t.rgb[1]),i=Math.abs(e.rgb[2]-t.rgb[2]);return this.rgb(n,r,i)},exclusion:function(e,t){var n=e.rgb[0]+t.rgb[0]*(255-e.rgb[0]-e.rgb[0])/255,r=e.rgb[1]+t.rgb[1]*(255-e.rgb[1]-e.rgb[1])/255,i=e.rgb[2]+t.rgb[2]*(255-e.rgb[2]-e.rgb[2])/255;return this.rgb(n,r,i)},average:function(e,t){var n=(e.rgb[0]+t.rgb[0])/2,r=(e.rgb[1]+t.rgb[1])/2,i=(e.rgb[2]+t.rgb[2])/2;return this.rgb(n,r,i)},negation:function(e,t){var n=255-Math.abs(255-t.rgb[0]-e.rgb[0]),r=255-Math.abs(255-t.rgb[1]-e.rgb[1]),i=255-Math.abs(255-t.rgb[2]-e.rgb[2]);return this.rgb(n,r,i)},tint:function(e,t){return this.mix(this.rgb(255,255,255),e,t)},shade:function(e,t){return this.mix(this.rgb(0,0,0),e,t)},extract:function(e,t){return t=t.value-1,e.value[t]},"data-uri":function(t,i){if(typeof e!="undefined")return(new r.URL(i||t,this.currentFileInfo)).eval(this.env);var s=t.value,o=i&&i.value,u=n("fs"),a=n("path"),f=!1;arguments.length<2&&(o=s),this.env.isPathRelative(o)&&(this.currentFileInfo.relativeUrls?o=a.join(this.currentFileInfo.currentDirectory,o):o=a.join(this.currentFileInfo.entryPath,o));if(arguments.length<2){var l;try{l=n("mime")}catch(c){l=r._mime}s=l.lookup(o);var h=l.charsets.lookup(s);f=["US-ASCII","UTF-8"].indexOf(h)<0,f&&(s+=";base64")}else f=/;base64$/.test(s);var p=u.readFileSync(o),d=32,v=parseInt(p.length/1024,10);if(v>=d){if(this.env.ieCompat!==!1)return this.env.silent||console.warn("Skipped data-uri embedding of %s because its size (%dKB) exceeds IE8-safe %dKB!",o,v,d),(new r.URL(i||t,this.currentFileInfo)).eval(this.env);this.env.silent||console.warn("WARNING: Embedding %s (%dKB) exceeds IE8's data-uri size limit of %dKB!",o,v,d)}p=f?p.toString("base64"):encodeURIComponent(p);var m="'data:"+s+","+p+"'";return new r.URL(new r.Anonymous(m))}},r._mime={_types:{".htm":"text/html",".html":"text/html",".gif":"image/gif",".jpg":"image/jpeg",".jpeg":"image/jpeg",".png":"image/png"},lookup:function(e){var i=n("path").extname(e),s=r._mime._types[i];if(s===t)throw new Error('Optional dependency "mime" is required for '+i);return s},charsets:{lookup:function(e){return e&&/^text\//.test(e)?"UTF-8":""}}};var i=[{name:"ceil"},{name:"floor"},{name:"sqrt"},{name:"abs"},{name:"tan",unit:""},{name:"sin",unit:""},{name:"cos",unit:""},{name:"atan",unit:"rad"},{name:"asin",unit:"rad"},{name:"acos",unit:"rad"}],s=function(e,t){return function(n){return t!=null&&(n=n.unify()),this._math(Math[e],t,n)}};for(var o=0;o<i.length;o++)r.functions[i[o].name]=s(i[o].name,i[o].unit);r.functionCall=function(e,t){this.env=e,this.currentFileInfo=t},r.functionCall.prototype=r.functions})(n("./tree")),function(e){e.colors={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgrey:"#a9a9a9",darkgreen:"#006400",darkkhaki:"#bdb76b",darkmagenta
10
+ :"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",grey:"#808080",green:"#008000",greenyellow:"#adff2f",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgrey:"#d3d3d3",lightgreen:"#90ee90",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370d8",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#d87093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"}}(n("./tree")),function(e){e.Alpha=function(e){this.value=e},e.Alpha.prototype={type:"Alpha",accept:function(e){this.value=e.visit(this.value)},eval:function(e){return this.value.eval&&(this.value=this.value.eval(e)),this},toCSS:function(){return"alpha(opacity="+(this.value.toCSS?this.value.toCSS():this.value)+")"}}}(n("../tree")),function(e){e.Anonymous=function(e){this.value=e.value||e},e.Anonymous.prototype={type:"Anonymous",toCSS:function(){return this.value},eval:function(){return this},compare:function(e){if(!e.toCSS)return-1;var t=this.toCSS(),n=e.toCSS();return t===n?0:t<n?-1:1}}}(n("../tree")),function(e){e.Assignment=function(e,t){this.key=e,this.value=t},e.Assignment.prototype={type:"Assignment",accept:function(e){this.value=e.visit(this.value)},toCSS:function(){return this.key+"="+(this.value.toCSS?this.value.toCSS():this.value)},eval:function(t){return this.value.eval?new e.Assignment(this.key,this.value.eval(t)):this}}}(n("../tree")),function(e){e.Call=function(e,t,n,r){this.name=e,this.args=t,this.index=n,this.currentFileInfo=r},e.Call.prototype={type:"Call",accept:function(e){this.args=e.visit(this.args)},eval:function(t){var n=this.args.map(function(e){return e.eval(t)}),r=this.name.toLowerCase(),i,s;if(r in e.functions)try{s=new e.functionCall(t,this.currentFileInfo),i=s[r].apply(s,n);if(i!=null)return i}catch(o){throw{type:o.type||"Runtime",message:"error evaluating function `"+this.name+"`"+(o.message?": "+o.message:""),index:this.index,filename:this.currentFileInfo.filename}}return new e.Anonymous(this.name+"("+n.map(function(e){return e.toCSS(t)}).join(", ")+")")},toCSS:function(e){return this.eval(e).toCSS()}}}(n("../tree")),function(e){e.Color=function(e,t){Array.isArray(e)?this.rgb=e:e.length==6?this.rgb=e.match(/.{2}/g).map(function(e){return parseInt(e,16)}):this.rgb=e.split("").map(function(e){return parseInt(e+e,16)}),this.alpha=typeof t=="number"?t:1},e.Color.prototype={type:"Color",eval:function(){return this},luma:function(){return.2126*this.rgb[0]/255+.7152*this.rgb[1]/255+.0722*this.rgb[2]/255},toCSS:function(e,t){var n=e&&e.compress&&!t;if(this.alpha<1)return"rgba("+this.rgb.map(function(e){return Math.round(e)}).concat(this.alpha).join(","+(n?"":" "))+")";var r=this.rgb.map(function(e){return e=Math.round(e),e=(e>255?255:e<0?0:e).toString(16),e.length===1?"0"+e:e}).join("");return n&&(r=r.split(""),r[0]==r[1]&&r[2]==r[3]&&r[4]==r[5]?r=r[0]+r[2]+r[4]:r=r.join("")),"#"+r},operate:function(t,n,r){var i=[];r instanceof e.Color||(r=r.toColor());for(var s=0;s<3;s++)i[s]=e.operate(t,n,this.rgb[s],r.rgb[s]);return new e.Color(i,this.alpha+r.alpha)},toHSL:function(){var e=this.rgb[0]/255,t=this.rgb[1]/255,n=this.rgb[2]/255,r=this.alpha,i=Math.max(e,t,n),s=Math.min(e,t,n),o,u,a=(i+s)/2,f=i-s;if(i===s)o=u=0;else{u=a>.5?f/(2-i-s):f/(i+s);switch(i){case e:o=(t-n)/f+(t<n?6:0);break;case t:o=(n-e)/f+2;break;case n:o=(e-t)/f+4}o/=6}return{h:o*360,s:u,l:a,a:r}},toHSV:function(){var e=this.rgb[0]/255,t=this.rgb[1]/255,n=this.rgb[2]/255,r=this.alpha,i=Math.max(e,t,n),s=Math.min(e,t,n),o,u,a=i,f=i-s;i===0?u=0:u=f/i;if(i===s)o=0;else{switch(i){case e:o=(t-n)/f+(t<n?6:0);break;case t:o=(n-e)/f+2;break;case n:o=(e-t)/f+4}o/=6}return{h:o*360,s:u,v:a,a:r}},toARGB:function(){var e=[Math.round(this.alpha*255)].concat(this.rgb);return"#"+e.map(function(e){return e=Math.round(e),e=(e>255?255:e<0?0:e).toString(16),e.length===1?"0"+e:e}).join("")},compare:function(e){return e.rgb?e.rgb[0]===this.rgb[0]&&e.rgb[1]===this.rgb[1]&&e.rgb[2]===this.rgb[2]&&e.alpha===this.alpha?0:-1:-1}}}(n("../tree")),function(e){e.Comment=function(e,t){this.value=e,this.silent=!!t},e.Comment.prototype={type:"Comment",toCSS:function(e){return e.compress?"":this.value},eval:function(){return this}}}(n("../tree")),function(e){e.Condition=function(e,t,n,r,i){this.op=e.trim(),this.lvalue=t,this.rvalue=n,this.index=r,this.negate=i},e.Condition.prototype={type:"Condition",accept:function(e){this.lvalue=e.visit(this.lvalue),this.rvalue=e.visit(this.rvalue)},eval:function(e){var t=this.lvalue.eval(e),n=this.rvalue.eval(e),r=this.index,i,i=function(e){switch(e){case"and":return t&&n;case"or":return t||n;default:if(t.compare)i=t.compare(n);else{if(!n.compare)throw{type:"Type",message:"Unable to perform comparison",index:r};i=n.compare(t)}switch(i){case-1:return e==="<"||e==="=<";case 0:return e==="="||e===">="||e==="=<";case 1:return e===">"||e===">="}}}(this.op);return this.negate?!i:i}}}(n("../tree")),function(e){e.Dimension=function(n,r){this.value=parseFloat(n),this.unit=r&&r instanceof e.Unit?r:new e.Unit(r?[r]:t)},e.Dimension.prototype={type:"Dimension",accept:function(e){this.unit=e.visit(this.unit)},eval:function(e){return this},toColor:function(){return new e.Color([this.value,this.value,this.value])},toCSS:function(e){if(e&&e.strictUnits&&!this.unit.isSingular())throw new Error("Multiple units in dimension. Correct the units or use the unit function. Bad unit: "+this.unit.toString());var t=this.value,n=String(t);t!==0&&t<1e-6&&t>-0.000001&&(n=t.toFixed(20).replace(/0+$/,""));if(e&&e.compress){if(t===0&&!this.unit.isAngle())return n;t>0&&t<1&&(n=n.substr(1))}return n+this.unit.toCSS(e)},operate:function(t,n,r){var i=e.operate(t,n,this.value,r.value),s=this.unit.clone();if(n==="+"||n==="-"){if(s.numerator.length===0&&s.denominator.length===0)s.numerator=r.unit.numerator.slice(0),s.denominator=r.unit.denominator.slice(0);else if(r.unit.numerator.length!=0||s.denominator.length!=0){r=r.convertTo(this.unit.usedUnits());if(t.strictUnits&&r.unit.toString()!==s.toString())throw new Error("Incompatible units. Change the units or use the unit function. Bad units: '"+s.toString()+"' and '"+r.unit.toString()+"'.");i=e.operate(t,n,this.value,r.value)}}else n==="*"?(s.numerator=s.numerator.concat(r.unit.numerator).sort(),s.denominator=s.denominator.concat(r.unit.denominator).sort(),s.cancel()):n==="/"&&(s.numerator=s.numerator.concat(r.unit.denominator).sort(),s.denominator=s.denominator.concat(r.unit.numerator).sort(),s.cancel());return new e.Dimension(i,s)},compare:function(t){if(t instanceof e.Dimension){var n=this.unify(),r=t.unify(),i=n.value,s=r.value;return s>i?-1:s<i?1:!r.unit.isEmpty()&&n.unit.compare(r.unit)!==0?-1:0}return-1},unify:function(){return this.convertTo({length:"m",duration:"s",angle:"rad"})},convertTo:function(t){var n=this.value,r=this.unit.clone(),i,s,o,u,a,f={};if(typeof t=="string"){for(i in e.UnitConversions)e.UnitConversions[i].hasOwnProperty(t)&&(f={},f[i]=t);t=f}for(s in t)t.hasOwnProperty(s)&&(a=t[s],o=e.UnitConversions[s],r.map(function(e,t){return o.hasOwnProperty(e)?(t?n/=o[e]/o[a]:n*=o[e]/o[a],a):e}));return r.cancel(),new e.Dimension(n,r)}},e.UnitConversions={length:{m:1,cm:.01,mm:.001,"in":.0254,pt:.0254/72,pc:.0254/72*12},duration:{s:1,ms:.001},angle:{rad:1/(2*Math.PI),deg:1/360,grad:.0025,turn:1}},e.Unit=function(e,t,n){this.numerator=e?e.slice(0).sort():[],this.denominator=t?t.slice(0).sort():[],this.backupUnit=n},e.Unit.prototype={type:"Unit",clone:function(){return new e.Unit(this.numerator.slice(0),this.denominator.slice(0),this.backupUnit)},toCSS:function(e){return this.numerator.length>=1?this.numerator[0]:this.denominator.length>=1?this.denominator[0]:(!e||!e.strictUnits)&&this.backupUnit?this.backupUnit:""},toString:function(){var e,t=this.numerator.join("*");for(e=0;e<this.denominator.length;e++)t+="/"+this.denominator[e];return t},compare:function(e){return this.is(e.toString())?0:-1},is:function(e){return this.toString()===e},isAngle:function(){return e.UnitConversions.angle.hasOwnProperty(this.toCSS())},isEmpty:function(){return this.numerator.length==0&&this.denominator.length==0},isSingular:function(){return this.numerator.length<=1&&this.denominator.length==0},map:function(e){var t;for(t=0;t<this.numerator.length;t++)this.numerator[t]=e(this.numerator[t],!1);for(t=0;t<this.denominator.length;t++)this.denominator[t]=e(this.denominator[t],!0)},usedUnits:function(){var t,n,r={};for(n in e.UnitConversions)e.UnitConversions.hasOwnProperty(n)&&(t=e.UnitConversions[n],this.map(function(e){return t.hasOwnProperty(e)&&!r[n]&&(r[n]=e),e}));return r},cancel:function(){var e={},t,n,r;for(n=0;n<this.numerator.length;n++)t=this.numerator[n],r||(r=t),e[t]=(e[t]||0)+1;for(n=0;n<this.denominator.length;n++)t=this.denominator[n],r||(r=t),e[t]=(e[t]||0)-1;this.numerator=[],this.denominator=[];for(t in e)if(e.hasOwnProperty(t)){var i=e[t];if(i>0)for(n=0;n<i;n++)this.numerator.push(t);else if(i<0)for(n=0;n<-i;n++)this.denominator.push(t)}this.numerator.length===0&&this.denominator.length===0&&r&&(this.backupUnit=r),this.numerator.sort(),this.denominator.sort()}}}(n("../tree")),function(e){e.Directive=function(t,n){this.name=t,Array.isArray(n)?(this.ruleset=new e.Ruleset([],n),this.ruleset.allowImports=!0):this.value=n},e.Directive.prototype={type:"Directive",accept:function(e){this.ruleset=e.visit(this.ruleset),this.value=e.visit(this.value)},toCSS:function(e){return this.ruleset?(this.ruleset.root=!0,this.name+(e.compress?"{":" {\n ")+this.ruleset.toCSS(e).trim().replace(/\n/g,"\n ")+(e.compress?"}":"\n}\n")):this.name+" "+this.value.toCSS()+";\n"},eval:function(t){var n=this;return this.ruleset&&(t.frames.unshift(this),n=new e.Directive(this.name),n.ruleset=this.ruleset.eval(t),t.frames.shift()),n},variable:function(t){return e.Ruleset.prototype.variable.call(this.ruleset,t)},find:function(){return e.Ruleset.prototype.find.apply(this.ruleset,arguments)},rulesets:function(){return e.Ruleset.prototype.rulesets.apply(this.ruleset)}}}(n("../tree")),function(e){e.Element=function(t,n,r){this.combinator=t instanceof e.Combinator?t:new e.Combinator(t),typeof n=="string"?this.value=n.trim():n?this.value=n:this.value="",this.index=r},e.Element.prototype={type:"Element",accept:function(e){this.combinator=e.visit(this.combinator),this.value=e.visit(this.value)},eval:function(t){return new e.Element(this.combinator,this.value.eval?this.value.eval(t):this.value,this.index)},toCSS:function(e){var t=this.value.toCSS?this.value.toCSS(e):this.value;return t==""&&this.combinator.value.charAt(0)=="&"?"":this.combinator.toCSS(e||{})+t}},e.Attribute=function(e,t,n){this.key=e,this.op=t,this.value=n},e.Attribute.prototype={type:"Attribute",accept:function(e){this.value=e.visit(this.value)},eval:function(t){return new e.Attribute(this.key.eval?this.key.eval(t):this.key,this.op,this.value&&this.value.eval?this.value.eval(t):this.value)},toCSS:function(e){var t=this.key.toCSS?this.key.toCSS(e):this.key;return this.op&&(t+=this.op,t+=this.value.toCSS?this.value.toCSS(e):this.value),"["+t+"]"}},e.Combinator=function(e){e===" "?this.value=" ":this.value=e?e.trim():""},e.Combinator.prototype={type:"Combinator",toCSS:function(e){return{"":""," ":" ",":":" :","+":e.compress?"+":" + ","~":e.compress?"~":" ~ ",">":e.compress?">":" > ","|":e.compress?"|":" | "}[this.value]}}}(n("../tree")),function(e){e.Expression=function(e){this.value=e},e.Expression.prototype={type:"Expression",accept:function(e){this.value=e.visit(this.value)},eval:function(t){var n,r=this.parens&&!this.parensInOp,i=!1;return r&&t.inParenthesis(),this.value.length>1?n=new e.Expression(this.value.map(function(e){return e.eval(t)})):this.value.length===1?(this.value[0].parens&&!this.value[0].parensInOp&&(i=!0),n=this.value[0].eval(t)):n=this,r&&t.outOfParenthesis(),this.parens&&this.parensInOp&&!t.isMathOn()&&!i&&(n=new e.Paren(n)),n},toCSS:function(e){return this.value.map(function(t){return t.toCSS?t.toCSS(e):""}).join(" ")},throwAwayComments:function(){this.value=this.value.filter(function(t){return!(t instanceof e.Comment)})}}}(n("../tree")),function(e){e.Extend=function(t,n,r){this.selector=t,this.option=n,this.index=r;switch(n){case"all":this.allowBefore=!0,this.allowAfter=!0;break;default:this.allowBefore=!1,this.allowAfter=!1}},e.Extend.prototype={type:"Extend",accept:function(e){this.selector=e.visit(this.selector)},eval:function(t){return new e.Extend(this.selector.eval(t),this.option,this.index)},clone:function(t){return new e.Extend(this.selector,this.option,this.index)},findSelfSelectors:function(e){var t=[],n;for(n=0;n<e.length;n++)t=t.concat(e[n].elements);this.selfSelectors=[{elements:t}]}}}(n("../tree")),function(e){e.Import=function(e,n,r,i,s){var o=this;this.options=r,this.index=i,this.path=e,this.features=n,this.currentFileInfo=s;if(this.options.less!==t)this.css=!this.options.less;else{var u=this.getPath();u&&/css([\?;].*)?$/.test(u)&&(this.css=!0)}},e.Import.prototype={type:"Import",accept:function(e){this.features=e.visit(this.features),this.path=e.visit(this.path),this.root=e.visit(this.root)},toCSS:function(e){var t=this.features?" "+this.features.toCSS(e):"";return this.css?"@import "+this.path.toCSS()+t+";\n":""},getPath:function(){if(this.path instanceof e.Quoted){var n=this.path.value;return this.css!==t||/(\.[a-z]*$)|([\?;].*)$/.test(n)?n:n+".less"}return this.path instanceof e.URL?this.path.value.value:null},evalForImport:function(t){return new e.Import(this.path.eval(t),this.features,this.options,this.index,this.currentFileInfo)},evalPath:function(t){var n=this.path.eval(t),r=this.currentFileInfo&&this.currentFileInfo.rootpath;if(r&&!(n instanceof e.URL)){var i=n.value;i&&t.isPathRelative(i)&&(n.value=r+i)}return n},eval:function(t){var n,r=this.features&&this.features.eval(t);if(this.skip)return[];if(this.css){var i=new e.Import(this.evalPath(t),r,this.options,this.index);if(!i.css&&this.error)throw this.error;return i}return n=new e.Ruleset([],this.root.rules.slice(0)),n.evalImports(t),this.features?new e.Media(n.rules,this.features.value):n.rules}}}(n("../tree")),function(e){e.JavaScript=function(e,t,n){this.escaped=n,this.expression=e,this.index=t},e.JavaScript.prototype={type:"JavaScript",eval:function(t){var n,r=this,i={},s=this.expression.replace(/@\{([\w-]+)\}/g,function(n,i){return e.jsify((new e.Variable("@"+i,r.index)).eval(t))});try{s=new Function("return ("+s+")")}catch(o){throw{message:"JavaScript evaluation error: `"+s+"`",index:this.index}}for(var u in t.frames[0].variables())i[u.slice(1)]={value:t.frames[0].variables()[u].value,toJS:function(){return this.value.eval(t).toCSS()}};try{n=s.call(i)}catch(o){throw{message:"JavaScript evaluation error: '"+o.name+": "+o.message+"'",index:this.index}}return typeof n=="string"?new e.Quoted('"'+n+'"',n,this.escaped,this.index):Array.isArray(n)?new e.Anonymous(n.join(", ")):new e.Anonymous(n)}}}(n("../tree")),function(e){e.Keyword=function(e){this.value=e},e.Keyword.prototype={type:"Keyword",eval:function(){return this},toCSS:function(){return this.value},compare:function(t){return t instanceof e.Keyword?t.value===this.value?0:1:-1}},e.True=new e.Keyword("true"),e.False=new e.Keyword("false")}(n("../tree")),function(e){e.Media=function(t,n){var r=this.emptySelectors();this.features=new e.Value(n),this.ruleset=new e.Ruleset(r,t),this.ruleset.allowImports=!0},e.Media.prototype={type:"Media",accept:function(e){this.features=e.visit(this.features),this.ruleset=e.visit(this.ruleset)},toCSS:function(e){var t=this.features.toCSS(e);return"@media "+t+(e.compress?"{":" {\n ")+this.ruleset.toCSS(e).trim().replace(/\n/g,"\n ")+(e.compress?"}":"\n}\n")},eval:function(t){t.mediaBlocks||(t.mediaBlocks=[],t.mediaPath=[]);var n=new e.Media([],[]);this.debugInfo&&(this.ruleset.debugInfo=this.debugInfo,n.debugInfo=this.debugInfo);var r=!1;t.strictMath||(r=!0,t.strictMath=!0);try{n.features=this.features.eval(t)}finally{r&&(t.strictMath=!1)}return t.mediaPath.push(n),t.mediaBlocks.push(n),t.frames.unshift(this.ruleset),n.ruleset=this.ruleset.eval(t),t.frames.shift(),t.mediaPath.pop(),t.mediaPath.length===0?n.evalTop(t):n.evalNested(t)},variable:function(t){return e.Ruleset.prototype.variable.call(this.ruleset,t)},find:function(){return e.Ruleset.prototype.find.apply(this.ruleset,arguments)},rulesets:function(){return e.Ruleset.prototype.rulesets.apply(this.ruleset)},emptySelectors:function(){var t=new e.Element("","&",0);return[new e.Selector([t])]},evalTop:function(t){var n=this;if(t.mediaBlocks.length>1){var r=this.emptySelectors();n=new e.Ruleset(r,t.mediaBlocks),n.multiMedia=!0}return delete t.mediaBlocks,delete t.mediaPath,n},evalNested:function(t){var n,r,i=t.mediaPath.concat([this]);for(n=0;n<i.length;n++)r=i[n].features instanceof e.Value?i[n].features.value:i[n].features,i[n]=Array.isArray(r)?r:[r];return this.features=new e.Value(this.permute(i).map(function(t){t=t.map(function(t){return t.toCSS?t:new e.Anonymous(t)});for(n=t.length-1;n>0;n--)t.splice(n,0,new e.Anonymous("and"));return new e.Expression(t)})),new e.Ruleset([],[])},permute:function(e){if(e.length===0)return[];if(e.length===1)return e[0];var t=[],n=this.permute(e.slice(1));for(var r=0;r<n.length;r++)for(var i=0;i<e[0].length;i++)t.push([e[0][i]].concat(n[r]));return t},bubbleSelectors:function(t){this.ruleset=new e.Ruleset(t.slice(0),[this.ruleset])}}}(n("../tree")),function(e){e.mixin={},e.mixin.Call=function(t,n,r,i,s){this.selector=new e.Selector(t),this.arguments=n,this.index=r,this.currentFileInfo=i,this.important=s},e.mixin.Call.prototype={type:"MixinCall",accept:function(e){this.selector=e.visit(this.selector),this.arguments=e.visit(this.arguments)},eval:function(t){var n,r,i,s=[],o=!1,u,a,f,l,c;i=this.arguments&&this.arguments.map(function(e){return{name:e.name,value:e.value.eval(t)}});for(u=0;u<t.frames.length;u++)if((n=t.frames[u].find(this.selector)).length>0){c=!0;for(a=0;a<n.length;a++){r=n[a],l=!1;for(f=0;f<t.frames.length;f++)if(!(r instanceof e.mixin.Definition)&&r===(t.frames[f].originalRuleset||t.frames[f])){l=!0;break}if(l)continue;if(r.matchArgs(i,t)){if(!r.matchCondition||r.matchCondition(i,t))try{Array.prototype.push.apply(s,r.eval(t,i,this.important).rules)}catch(h){throw{message:h.message,index:this.index,filename:this.currentFileInfo.filename,stack:h.stack}}o=!0}}if(o)return s}throw c?{type:"Runtime",message:"No matching definition was found for `"+this.selector.toCSS().trim()+"("+(i?i.map(function(e){var t="";return e.name&&(t+=e.name+":"),e.value.toCSS?t+=e.value.toCSS():t+="???",t}).join(", "):"")+")`",index:this.index,filename:this.currentFileInfo.filename}:{type:"Name",message:this.selector.toCSS().trim()+" is undefined",index:this.index,filename:this.currentFileInfo.filename}}},e.mixin.Definition=function(t,n,r,i,s){this.name=t,this.selectors=[new e.Selector([new e.Element(null,t)])],this.params=n,this.condition=i,this.variadic=s,this.arity=n.length,this.rules=r,this._lookups={},this.required=n.reduce(function(e,t){return!t.name||t.name&&!t.value?e+1:e},0),this.parent=e.Ruleset.prototype,this.frames=[]},e.mixin.Definition.prototype={type:"MixinDefinition",accept:function(e){this.params=e.visit(this.params),this.rules=e.visit(this.rules),this.condition=e.visit(this.condition)},toCSS:function(){return""},variable:function(e){return this.parent.variable.call(this,e)},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)},evalParams:function(t,n,r,i){var s=new e.Ruleset(null,[]),o,u,a=this.params.slice(0),f,l,c,h,p,d;n=new e.evalEnv(n,[s].concat(n.frames));if(r){r=r.slice(0);for(f=0;f<r.length;f++){u=r[f];if(h=u&&u.name){p=!1;for(l=0;l<a.length;l++)if(!i[l]&&h===a[l].name){i[l]=u.value.eval(t),s.rules.unshift(new e.Rule(h,u.value.eval(t))),p=!0;break}if(p){r.splice(f,1),f--;continue}throw{type:"Runtime",message:"Named argument for "+this.name+" "+r[f].name+" not found"}}}}d=0;for(f=0;f<a.length;f++){if(i[f])continue;u=r&&r[d];if(h=a[f].name)if(a[f].variadic&&r){o=[];for(l=d;l<r.length;l++)o.push(r[l].value.eval(t));s.rules.unshift(new e.Rule(h,(new e.Expression(o)).eval(t)))}else{c=u&&u.value;if(c)c=c.eval(t);else{if(!a[f].value)throw{type:"Runtime",message:"wrong number of arguments for "+this.name+" ("+r.length+" for "+this.arity+")"};c=a[f].value.eval(n),s.resetCache()}s.rules.unshift(new e.Rule(h,c)),i[f]=c}if(a[f].variadic&&r)for(l=d;l<r.length;l++)i[l]=r[l].value.eval(t);d++}return s},eval:function(t,n,r){var i=[],s=this.frames.concat(t.frames),o=this.evalParams(t,new e.evalEnv(t,s),n,i),u,a,f,l;return o.rules.unshift(new e.Rule("@arguments",(new e.Expression(i)).eval(t))),a=r?this.parent.makeImportant.apply(this).rules:this.rules.slice(0),l=(new e.Ruleset(null,a)).eval(new e.evalEnv(t,[this,o].concat(s))),l.originalRuleset=this,l},matchCondition:function(t,n){return this.condition&&!this.condition.eval(new e.evalEnv(n,[this.evalParams(n,new e.evalEnv(n,this.frames.concat(n.frames)),t,[])].concat(n.frames)))?!1:!0},matchArgs:function(e,t){var n=e&&e.length||0,r,i;if(!this.variadic){if(n<this.required)return!1;if(n>this.params.length)return!1;if(this.required>0&&n>this.params.length)return!1}r=Math.min(n,this.arity);for(var s=0;s<r;s++)if(!this.params[s].name&&!this.params[s].variadic&&e[s].value.eval(t).toCSS()!=this.params[s].value.eval(t).toCSS())return!1;return!0}}}(n("../tree")),function(e){e.Negative=function(e){this.value=e},e.Negative.prototype={type:"Negative",accept:function(e){this.value=e.visit(this.value)},toCSS:function(e){return"-"+this.value.toCSS(e)},eval:function(t){return t.isMathOn()?(new e.Operation("*",[new e.Dimension(-1),this.value])).eval(t):new e.Negative(this.value.eval(t))}}}(n("../tree")),function(e){e.Operation=function(e,t,n){this.op=e.trim(),this.operands=t,this.isSpaced=n},e.Operation.prototype={type:"Operation",accept:function(e){this.operands=e.visit(this.operands)},eval:function(t){var n=this.operands[0].eval(t),r=this.operands[1].eval(t),i;if(t.isMathOn()){if(n instanceof e.Dimension&&r instanceof e.Color){if(this.op!=="*"&&this.op!=="+")throw{type:"Operation",message:"Can't substract or divide a color from a number"};i=r,r=n,n=i}if(!n.operate)throw{type:"Operation",message:"Operation on an invalid type"};return n.operate(t,this.op,r)}return new e.Operation(this.op,[n,r],this.isSpaced)},toCSS:function(e){var t=this.isSpaced?" ":"";return this.operands[0].toCSS()+t+this.op+t+this.operands[1].toCSS()}},e.operate=function(e,t,n,r){switch(t){case"+":return n+r;case"-":return n-r;case"*":return n*r;case"/":return n/r}}}(n("../tree")),function(e){e.Paren=function(e){this.value=e},e.Paren.prototype={type:"Paren",accept:function(e){this.value=e.visit(this.value)},toCSS:function(e){return"("+this.value.toCSS(e).trim()+")"},eval:function(t){return new e.Paren(this.value.eval(t))}}}(n("../tree")),function(e){e.Quoted=function(e,t,n,r,i){this.escaped=n,this.value=t||"",this.quote=e.charAt(0),this.index=r,this.currentFileInfo=i},e.Quoted.prototype={type:"Quoted",toCSS:function(){return this.escaped?this.value:this.quote+this.value+this.quote},eval:function(t){var n=this,r=this.value.replace(/`([^`]+)`/g,function(r,i){return(new e.JavaScript(i,n.index,!0)).eval(t).value}).replace(/@\{([\w-]+)\}/g,function(r,i){var s=(new e.Variable("@"+i,n.index,n.currentFileInfo)).eval(t,!0);return s instanceof e.Quoted?s.value:s.toCSS()});return new e.Quoted(this.quote+r+this.quote,r,this.escaped,this.index)},compare:function(e){if(!e.toCSS)return-1;var t=this.toCSS(),n=e.toCSS();return t===n?0:t<n?-1:1}}}(n("../tree")),function(e){e.Rule=function(t,n,r,i,s,o){this.name=t,this.value=n instanceof e.Value?n:new e.Value([n]),this.important=r?" "+r.trim():"",this.index=i,this.currentFileInfo=s,this.inline=o||!1,t.charAt(0)==="@"?this.variable=!0:this.variable=!1},e.Rule.prototype={type:"Rule",accept:function(e){this.value=e.visit(this.value)},toCSS:function(e){if(this.variable)return"";try{return this.name+(e.compress?":":": ")+this.value.toCSS(e)+this.important+(this.inline?"":";")}catch(t){throw t.index=this.index,t.filename=this.currentFileInfo.filename,t}},eval:function(t){var n=!1;this.name==="font"&&!t.strictMath&&(n=!0,t.strictMath=!0);try{return new e.Rule(this.name,this.value.eval(t),this.important,this.index,this.currentFileInfo,this.inline)}finally{n&&(t.strictMath=!1)}},makeImportant:function(){return new e.Rule(this.name,this.value,"!important",this.index,this.currentFileInfo,this.inline)}}}(n("../tree")),function(e){e.Ruleset=function(e,t,n){this.selectors=e,this.rules=t,this._lookups={},this.strictImports=n},e.Ruleset.prototype={type:"Ruleset",accept:function(e){this.selectors=e.visit(this.selectors),this.rules=e.visit(this.rules)},eval:function(t){var n=this.selectors&&this.selectors.map(function(e){return e.eval(t)}),r=new e.Ruleset(n,this.rules.slice(0),this.strictImports),i;r.originalRuleset=this,r.root=this.root,r.firstRoot=this.firstRoot,r.allowImports=this.allowImports,this.debugInfo&&(r.debugInfo=this.debugInfo),t.frames.unshift(r),t.selectors||(t.selectors=[]),t.selectors.unshift(this.selectors),(r.root||r.allowImports||!r.strictImports)&&r.evalImports(t);for(var s=0;s<r.rules.length;s++)r.rules[s]instanceof e.mixin.Definition&&(r.rules[s].frames=t.frames.slice(0));var o=t.mediaBlocks&&t.mediaBlocks.length||0;for(var s=0;s<r.rules.length;s++)r.rules[s]instanceof e.mixin.Call&&(i=r.rules[s].eval(t).filter(function(t){return t instanceof e.Rule&&t.variable?!r.variable(t.name):!0}),r.rules.splice.apply(r.rules,[s,1].concat(i)),s+=i.length-1,r.resetCache());for(var s=0,u;s<r.rules.length;s++)u=r.rules[s],u instanceof e.mixin.Definition||(r.rules[s]=u.eval?u.eval(t):u);t.frames.shift(),t.selectors.shift();if(t.mediaBlocks)for(var s=o;s<t.mediaBlocks.length;s++)t.mediaBlocks[s].bubbleSelectors(n);return r},evalImports:function(t){var n,r;for(n=0;n<this.rules.length;n++)this.rules[n]instanceof e.Import&&(r=this.rules[n].eval(t),typeof r.length=="number"?(this.rules.splice.apply(this.rules,[n,1].concat(r)),n+=r.length-1):this.rules.splice(n,1,r),this.resetCache())},makeImportant:function(){return new e.Ruleset(this.selectors,this.rules.map(function(e){return e.makeImportant?e.makeImportant():e}),this.strictImports)},matchArgs:function(e){return!e||e.length===0},resetCache:function(){this._rulesets=null,this._variables=null,this._lookups={}},variables:function(){return this._variables?this._variables:this._variables=this.rules.reduce(function(t,n){return n instanceof e.Rule&&n.variable===!0&&(t[n.name]=n),t},{})},variable:function(e){return this.variables()[e]},rulesets:function(){return this.rules.filter(function(t){return t instanceof e.Ruleset||t instanceof e.mixin.Definition})},find:function(t,n){n=n||this;var r=[],i,s,o=t.toCSS();return o in this._lookups?this._lookups[o]:(this.rulesets().forEach(function(i){if(i!==n)for(var o=0;o<i.selectors.length;o++)if(s=t.match(i.selectors[o])){t.elements.length>i.selectors[o].elements.length?Array.prototype.push.apply(r,i.find(new e.Selector(t.elements.slice(1)),n)):r.push(i);break}}),this._lookups[o]=r)},toCSS:function(t){var n=[],r=[],i=[],s=[],o,u,a;for(var f=0;f<this.rules.length;f++){a=this.rules[f];if(a.rules||a instanceof e.Media)s.push(a.toCSS(t));else if(a instanceof e.Directive){var l=a.toCSS(t);if(a.name==="@charset"){if(t.charset){a.debugInfo&&(s.push(e.debugInfo(t,a)),s.push((new e.Comment("/* "+l.replace(/\n/g,"")+" */\n")).toCSS(t)));continue}t.charset=!0}s.push(l)}else if(a instanceof e.Comment)a.silent||(this.root?s.push(a.toCSS(t)):r.push(a.toCSS(t)));else if(a.toCSS&&!a.variable){if(this.firstRoot&&a instanceof e.Rule)throw{message:"properties must be inside selector blocks, they cannot be in the root.",index:a.index,filename:a.currentFileInfo?a.currentFileInfo.filename:null};r.push(a.toCSS(t))}else a.value&&!a.variable&&r.push(a.value.toString())}t.compress&&r.length&&(a=r[r.length-1],a.charAt(a.length-1)===";"&&(r[r.length-1]=a.substring(0,a.length-1))),s=s.join("");if(this.root)n.push(r.join(t.compress?"":"\n"));else if(r.length>0){u=e.debugInfo(t,this),o=this.paths.map(function(e){return e.map(function(e){return e.toCSS(t)}).join("").trim()}).join(t.compress?",":",\n");for(var f=r.length-1;f>=0;f--)(r[f].slice(0,2)==="/*"||i.indexOf(r[f])===-1)&&i.unshift(r[f]);r=i,n.push(u+o+(t.compress?"{":" {\n ")+r.join(t.compress?"":"\n ")+(t.compress?"}":"\n}\n"))}return n.push(s),n.join("")+(t.compress?"\n":"")},joinSelectors:function(e,t,n){for(var r=0;r<n.length;r++)this.joinSelector(e,t,n[r])},joinSelector:function(t,n,r){var i,s,o,u,a,f,l,c,h,p,d,v,m,g,y;for(i=0;i<r.elements.length;i++)f=r.elements[i],f.value==="&"&&(u=!0);if(!u){if(n.length>0)for(i=0;i<n.length;i++)t.push(n[i].concat(r));else t.push([r]);return}g=[],a=[[]];for(i=0;i<r.elements.length;i++){f=r.elements[i];if(f.value!=="&")g.push(f);else{y=[],g.length>0&&this.mergeElementsOnToSelectors(g,a);for(s=0;s<a.length;s++){l=a[s];if(n.length==0)l.length>0&&(l[0].elements=l[0].elements.slice(0),l[0].elements.push(new e.Element(f.combinator,"",0))),y.push(l);else for(o=0;o<n.length;o++)c=n[o],h=[],p=[],v=!0,l.length>0?(h=l.slice(0),m=h.pop(),d=new e.Selector(m.elements.slice(0),r.extendList),v=!1):d=new e.Selector([],r.extendList),c.length>1&&(p=p.concat(c.slice(1))),c.length>0&&(v=!1,d.elements.push(new e.Element(f.combinator,c[0].elements[0].value,0)),d.elements=d.elements.concat(c[0].elements.slice(1))),v||h.push(d),h=h.concat(p),y.push(h)}a=y,g=[]}}g.length>0&&this.mergeElementsOnToSelectors(g,a);for(i=0;i<a.length;i++)a[i].length>0&&t.push(a[i])},mergeElementsOnToSelectors:function(t,n){var r,i,s;if(n.length==0){n.push([new e.Selector(t)]);return}for(r=0;r<n.length;r++)i=n[r],i.length>0?i[i.length-1]=new e.Selector(i[i.length-1].elements.concat(t),i[i.length-1].extendList):i.push(new e.Selector(t))}}}(n("../tree")),function(e){e.Selector=function(e,t){this.elements=e,this.extendList=t||[]},e.Selector.prototype={type:"Selector",accept:function(e){this.elements=e.visit(this.elements),this.extendList=e.visit(this.extendList)},match:function(e){var t=this.elements,n=t.length,r,i,s,o;r=e.elements.slice(e.elements.length&&e.elements[0].value==="&"?1:0),i=r.length,s=Math.min(n,i);if(i===0||n<i)return!1;for(o=0;o<s;o++)if(t[o].value!==r[o].value)return!1;return!0},eval:function(t){return new e.Selector(this.elements.map(function(e){return e.eval(t)}),this.extendList.map(function(e){return e.eval(t)}))},toCSS:function(e){return this._css?this._css:(this.elements[0].combinator.value===""?this._css=" ":this._css="",this._css+=this.elements.map(function(t){return typeof t=="string"?" "+t.trim():t.toCSS(e)}).join(""),this._css)}}}(n("../tree")),function(e){e.UnicodeDescriptor=function(e){this.value=e},e.UnicodeDescriptor.prototype={type:"UnicodeDescriptor",toCSS:function(e){return this.value},eval:function(){return this}}}(n
11
+ ("../tree")),function(e){e.URL=function(e,t){this.value=e,this.currentFileInfo=t},e.URL.prototype={type:"Url",accept:function(e){this.value=e.visit(this.value)},toCSS:function(){return"url("+this.value.toCSS()+")"},eval:function(t){var n=this.value.eval(t),r;return r=this.currentFileInfo&&this.currentFileInfo.rootpath,r&&typeof n.value=="string"&&t.isPathRelative(n.value)&&(n.quote||(r=r.replace(/[\(\)'"\s]/g,function(e){return"\\"+e})),n.value=r+n.value),new e.URL(n,null)}}}(n("../tree")),function(e){e.Value=function(e){this.value=e},e.Value.prototype={type:"Value",accept:function(e){this.value=e.visit(this.value)},eval:function(t){return this.value.length===1?this.value[0].eval(t):new e.Value(this.value.map(function(e){return e.eval(t)}))},toCSS:function(e){return this.value.map(function(t){return t.toCSS(e)}).join(e.compress?",":", ")}}}(n("../tree")),function(e){e.Variable=function(e,t,n){this.name=e,this.index=t,this.currentFileInfo=n},e.Variable.prototype={type:"Variable",eval:function(t){var n,r,i=this.name;i.indexOf("@@")==0&&(i="@"+(new e.Variable(i.slice(1))).eval(t).value);if(this.evaluating)throw{type:"Name",message:"Recursive variable definition for "+i,filename:this.currentFileInfo.file,index:this.index};this.evaluating=!0;if(n=e.find(t.frames,function(e){if(r=e.variable(i))return r.value.eval(t)}))return this.evaluating=!1,n;throw{type:"Name",message:"variable "+i+" is undefined",filename:this.currentFileInfo.filename,index:this.index}}}}(n("../tree")),function(e){e.debugInfo=function(t,n){var r="";if(t.dumpLineNumbers&&!t.compress)switch(t.dumpLineNumbers){case"comments":r=e.debugInfo.asComment(n);break;case"mediaquery":r=e.debugInfo.asMediaQuery(n);break;case"all":r=e.debugInfo.asComment(n)+e.debugInfo.asMediaQuery(n)}return r},e.debugInfo.asComment=function(e){return"/* line "+e.debugInfo.lineNumber+", "+e.debugInfo.fileName+" */\n"},e.debugInfo.asMediaQuery=function(e){return"@media -sass-debug-info{filename{font-family:"+("file://"+e.debugInfo.fileName).replace(/([.:/\\])/g,function(e){return e=="\\"&&(e="/"),"\\"+e})+"}line{font-family:\\00003"+e.debugInfo.lineNumber+"}}\n"},e.find=function(e,t){for(var n=0,r;n<e.length;n++)if(r=t.call(e,e[n]))return r;return null},e.jsify=function(e){return Array.isArray(e.value)&&e.value.length>1?"["+e.value.map(function(e){return e.toCSS(!1)}).join(", ")+"]":e.toCSS(!1)}}(n("./tree")),function(e){var t=["paths","optimization","files","contents","relativeUrls","strictImports","dumpLineNumbers","compress","processImports","syncImport","mime","currentFileInfo"];e.parseEnv=function(e){r(e,this,t),this.contents||(this.contents={}),this.files||(this.files={});if(!this.currentFileInfo){var n=e&&e.filename||"input",i=n.replace(/[^\/\\]*$/,"");e&&(e.filename=null),this.currentFileInfo={filename:n,relativeUrls:this.relativeUrls,rootpath:e&&e.rootpath||"",currentDirectory:i,entryPath:i,rootFilename:n}}},e.parseEnv.prototype.toSheet=function(t){var n=new e.parseEnv(this);return n.href=t,n.type=this.mime,n};var n=["silent","verbose","compress","yuicompress","ieCompat","strictMath","strictUnits"];e.evalEnv=function(e,t){r(e,this,n),this.frames=t||[]},e.evalEnv.prototype.inParenthesis=function(){this.parensStack||(this.parensStack=[]),this.parensStack.push(!0)},e.evalEnv.prototype.outOfParenthesis=function(){this.parensStack.pop()},e.evalEnv.prototype.isMathOn=function(){return this.strictMath?this.parensStack&&this.parensStack.length:!0},e.evalEnv.prototype.isPathRelative=function(e){return!/^(?:[a-z-]+:|\/)/.test(e)};var r=function(e,t,n){if(!e)return;for(var r=0;r<n.length;r++)e.hasOwnProperty(n[r])&&(t[n[r]]=e[n[r]])}}(n("./tree")),function(e){e.visitor=function(e){this._implementation=e},e.visitor.prototype={visit:function(e){if(e instanceof Array)return this.visitArray(e);if(!e||!e.type)return e;var t="visit"+e.type,n=this._implementation[t],r,i;return n&&(r={visitDeeper:!0},i=n.call(this._implementation,e,r),this._implementation.isReplacing&&(e=i)),(!r||r.visitDeeper)&&e&&e.accept&&e.accept(this),t+="Out",this._implementation[t]&&this._implementation[t](e),e},visitArray:function(e){var t,n=[];for(t=0;t<e.length;t++){var r=this.visit(e[t]);r instanceof Array?n=n.concat(r):n.push(r)}return this._implementation.isReplacing?n:e}}}(n("./tree")),function(e){e.importVisitor=function(t,n,r){this._visitor=new e.visitor(this),this._importer=t,this._finish=n,this.env=r||new e.evalEnv,this.importCount=0},e.importVisitor.prototype={isReplacing:!0,run:function(e){var t;try{this._visitor.visit(e)}catch(n){t=n}this.isFinished=!0,this.importCount===0&&this._finish(t)},visitImport:function(t,n){var r=this,i;if(!t.css){try{i=t.evalForImport(this.env)}catch(s){s.filename||(s.index=t.index,s.filename=t.currentFileInfo.filename),t.css=!0,t.error=s}if(i&&!i.css){t=i,this.importCount++;var o=new e.evalEnv(this.env,this.env.frames.slice(0));this._importer.push(t.getPath(),t.currentFileInfo,function(n,i,s){n&&!n.filename&&(n.index=t.index,n.filename=t.currentFileInfo.filename),s&&!t.options.multiple&&(t.skip=s);var u=function(e){r.importCount--,r.importCount===0&&r.isFinished&&r._finish(e)};i?(t.root=i,(new e.importVisitor(r._importer,u,o)).run(i)):u()})}}return n.visitDeeper=!1,t},visitRule:function(e,t){return t.visitDeeper=!1,e},visitDirective:function(e,t){return this.env.frames.unshift(e),e},visitDirectiveOut:function(e){this.env.frames.shift()},visitMixinDefinition:function(e,t){return this.env.frames.unshift(e),e},visitMixinDefinitionOut:function(e){this.env.frames.shift()},visitRuleset:function(e,t){return this.env.frames.unshift(e),e},visitRulesetOut:function(e){this.env.frames.shift()},visitMedia:function(e,t){return this.env.frames.unshift(e.ruleset),e},visitMediaOut:function(e){this.env.frames.shift()}}}(n("./tree")),function(e){e.joinSelectorVisitor=function(){this.contexts=[[]],this._visitor=new e.visitor(this)},e.joinSelectorVisitor.prototype={run:function(e){return this._visitor.visit(e)},visitRule:function(e,t){t.visitDeeper=!1},visitMixinDefinition:function(e,t){t.visitDeeper=!1},visitRuleset:function(e,t){var n=this.contexts[this.contexts.length-1],r=[];this.contexts.push(r),e.root||(e.joinSelectors(r,n,e.selectors),e.paths=r)},visitRulesetOut:function(e){this.contexts.length=this.contexts.length-1},visitMedia:function(e,t){var n=this.contexts[this.contexts.length-1];e.ruleset.root=n.length===0||n[0].multiMedia}}}(n("./tree")),function(e){e.extendFinderVisitor=function(){this._visitor=new e.visitor(this),this.contexts=[],this.allExtendsStack=[[]]},e.extendFinderVisitor.prototype={run:function(e){return e=this._visitor.visit(e),e.allExtends=this.allExtendsStack[0],e},visitRule:function(e,t){t.visitDeeper=!1},visitMixinDefinition:function(e,t){t.visitDeeper=!1},visitRuleset:function(t,n){if(t.root)return;var r,i,s,o=[],u;for(r=0;r<t.rules.length;r++)t.rules[r]instanceof e.Extend&&o.push(t.rules[r]);for(r=0;r<t.paths.length;r++){var a=t.paths[r],f=a[a.length-1];u=f.extendList.slice(0).concat(o).map(function(e){return e.clone()});for(i=0;i<u.length;i++)this.foundExtends=!0,s=u[i],s.findSelfSelectors(a),s.ruleset=t,i===0&&(s.firstExtendOnThisSelectorPath=!0),this.allExtendsStack[this.allExtendsStack.length-1].push(s)}this.contexts.push(t.selectors)},visitRulesetOut:function(e){e.root||(this.contexts.length=this.contexts.length-1)},visitMedia:function(e,t){e.allExtends=[],this.allExtendsStack.push(e.allExtends)},visitMediaOut:function(e){this.allExtendsStack.length=this.allExtendsStack.length-1},visitDirective:function(e,t){e.allExtends=[],this.allExtendsStack.push(e.allExtends)},visitDirectiveOut:function(e){this.allExtendsStack.length=this.allExtendsStack.length-1}},e.processExtendsVisitor=function(){this._visitor=new e.visitor(this)},e.processExtendsVisitor.prototype={run:function(t){var n=new e.extendFinderVisitor;return n.run(t),n.foundExtends?(t.allExtends=t.allExtends.concat(this.doExtendChaining(t.allExtends,t.allExtends)),this.allExtendsStack=[t.allExtends],this._visitor.visit(t)):t},doExtendChaining:function(t,n,r){var i,s,o,u=[],a,f=this,l,c,h,p;r=r||0;for(i=0;i<t.length;i++)for(s=0;s<n.length;s++){c=t[i],h=n[s];if(this.inInheritanceChain(h,c))continue;l=[h.selfSelectors[0]],o=f.findMatch(c,l),o.length&&c.selfSelectors.forEach(function(t){a=f.extendSelector(o,l,t),p=new e.Extend(h.selector,h.option,0),p.selfSelectors=a,a[a.length-1].extendList=[p],u.push(p),p.ruleset=h.ruleset,p.parents=[h,c],h.firstExtendOnThisSelectorPath&&(p.firstExtendOnThisSelectorPath=!0,h.ruleset.paths.push(a))})}if(u.length){this.extendChainCount++;if(r>100){var d="{unable to calculate}",v="{unable to calculate}";try{d=u[0].selfSelectors[0].toCSS(),v=u[0].selector.toCSS()}catch(m){}throw{message:"extend circular reference detected. One of the circular extends is currently:"+d+":extend("+v+")"}}return u.concat(f.doExtendChaining(u,n,r+1))}return u},inInheritanceChain:function(e,t){if(e===t)return!0;if(t.parents){if(this.inInheritanceChain(e,t.parents[0]))return!0;if(this.inInheritanceChain(e,t.parents[1]))return!0}return!1},visitRule:function(e,t){t.visitDeeper=!1},visitMixinDefinition:function(e,t){t.visitDeeper=!1},visitSelector:function(e,t){t.visitDeeper=!1},visitRuleset:function(e,t){if(e.root)return;var n,r,i,s=this.allExtendsStack[this.allExtendsStack.length-1],o=[],u=this,a;for(i=0;i<s.length;i++)for(r=0;r<e.paths.length;r++){a=e.paths[r];if(a[a.length-1].extendList.length)continue;n=this.findMatch(s[i],a),n.length&&s[i].selfSelectors.forEach(function(e){o.push(u.extendSelector(n,a,e))})}e.paths=e.paths.concat(o)},findMatch:function(e,t){var n,r,i,s,o,u,a=this,f=e.selector.elements,l=[],c,h=[];for(n=0;n<t.length;n++){r=t[n];for(i=0;i<r.elements.length;i++){s=r.elements[i],(e.allowBefore||n==0&&i==0)&&l.push({pathIndex:n,index:i,matched:0,initialCombinator:s.combinator});for(u=0;u<l.length;u++)c=l[u],o=s.combinator.value,o==""&&i===0&&(o=" "),!a.isElementValuesEqual(f[c.matched].value,s.value)||c.matched>0&&f[c.matched].combinator.value!==o?c=null:c.matched++,c&&(c.finished=c.matched===f.length,c.finished&&!e.allowAfter&&(i+1<r.elements.length||n+1<t.length)&&(c=null)),c?c.finished&&(c.length=f.length,c.endPathIndex=n,c.endPathElementIndex=i+1,l.length=0,h.push(c)):(l.splice(u,1),u--)}}return h},isElementValuesEqual:function(t,n){if(typeof t=="string"||typeof n=="string")return t===n;if(t instanceof e.Attribute)return t.op!==n.op||t.key!==n.key?!1:!t.value||!n.value?t.value||n.value?!1:!0:(t=t.value.value||t.value,n=n.value.value||n.value,t===n);return!1},extendSelector:function(t,n,r){var i=0,s=0,o=[],u,a,f,l;for(u=0;u<t.length;u++)l=t[u],a=n[l.pathIndex],f=new e.Element(l.initialCombinator,r.elements[0].value,r.elements[0].index),l.pathIndex>i&&s>0&&(o[o.length-1].elements=o[o.length-1].elements.concat(n[i].elements.slice(s)),s=0,i++),o=o.concat(n.slice(i,l.pathIndex)),o.push(new e.Selector(a.elements.slice(s,l.index).concat([f]).concat(r.elements.slice(1)))),i=l.endPathIndex,s=l.endPathElementIndex,s>=a.elements.length&&(s=0,i++);return i<n.length&&s>0&&(o[o.length-1].elements=o[o.length-1].elements.concat(n[i].elements.slice(s)),s=0,i++),o=o.concat(n.slice(i,n.length)),o},visitRulesetOut:function(e){},visitMedia:function(e,t){var n=e.allExtends.concat(this.allExtendsStack[this.allExtendsStack.length-1]);n=n.concat(this.doExtendChaining(n,e.allExtends)),this.allExtendsStack.push(n)},visitMediaOut:function(e){this.allExtendsStack.length=this.allExtendsStack.length-1},visitDirective:function(e,t){var n=e.allExtends.concat(this.allExtendsStack[this.allExtendsStack.length-1]);n=n.concat(this.doExtendChaining(n,e.allExtends)),this.allExtendsStack.push(n)},visitDirectiveOut:function(e){this.allExtendsStack.length=this.allExtendsStack.length-1}}}(n("./tree"));var o=/^(file|chrome(-extension)?|resource|qrc|app):/.test(location.protocol);r.env=r.env||(location.hostname=="127.0.0.1"||location.hostname=="0.0.0.0"||location.hostname=="localhost"||location.port.length>0||o?"development":"production"),r.async=r.async||!1,r.fileAsync=r.fileAsync||!1,r.poll=r.poll||(o?1e3:1500);if(r.functions)for(var u in r.functions)r.tree.functions[u]=r.functions[u];var a=/!dumpLineNumbers:(comments|mediaquery|all)/.exec(location.hash);a&&(r.dumpLineNumbers=a[1]),r.watch=function(){return r.watchMode||(r.env="development",f()),this.watchMode=!0},r.unwatch=function(){return clearInterval(r.watchTimer),this.watchMode=!1},/!watch/.test(location.hash)&&r.watch();var l=null;if(r.env!="development")try{l=typeof e.localStorage=="undefined"?null:e.localStorage}catch(c){}var h=document.getElementsByTagName("link"),p=/^text\/(x-)?less$/;r.sheets=[];for(var d=0;d<h.length;d++)(h[d].rel==="stylesheet/less"||h[d].rel.match(/stylesheet/)&&h[d].type.match(p))&&r.sheets.push(h[d]);var v="";r.modifyVars=function(e){var t=v;for(var n in e)t+=(n.slice(0,1)==="@"?"":"@")+n+": "+(e[n].slice(-1)===";"?e[n]:e[n]+";");(new r.Parser(new r.tree.parseEnv(r))).parse(t,function(e,t){e?k(e,"session_cache"):S(t.toCSS(r),r.sheets[r.sheets.length-1])})},r.refresh=function(e){var t,n;t=n=new Date,g(function(e,i,s,o,u){if(e)return k(e,o.href);u.local?C("loading "+o.href+" from cache."):(C("parsed "+o.href+" successfully."),S(i.toCSS(r),o,u.lastModified)),C("css for "+o.href+" generated in "+(new Date-n)+"ms"),u.remaining===0&&C("css generated in "+(new Date-t)+"ms"),n=new Date},e),m()},r.refreshStyles=m,r.refresh(r.env==="development"),typeof define=="function"&&define.amd&&define(function(){return r})})(window);
@@ -0,0 +1,4273 @@
1
+ //
2
+ // Stub out `require` in rhino
3
+ //
4
+ function require(arg) {
5
+ return less[arg.split('/')[1]];
6
+ };
7
+
8
+
9
+ // ecma-5.js
10
+ //
11
+ // -- kriskowal Kris Kowal Copyright (C) 2009-2010 MIT License
12
+ // -- tlrobinson Tom Robinson
13
+ // dantman Daniel Friesen
14
+
15
+ //
16
+ // Array
17
+ //
18
+ if (!Array.isArray) {
19
+ Array.isArray = function(obj) {
20
+ return Object.prototype.toString.call(obj) === "[object Array]" ||
21
+ (obj instanceof Array);
22
+ };
23
+ }
24
+ if (!Array.prototype.forEach) {
25
+ Array.prototype.forEach = function(block, thisObject) {
26
+ var len = this.length >>> 0;
27
+ for (var i = 0; i < len; i++) {
28
+ if (i in this) {
29
+ block.call(thisObject, this[i], i, this);
30
+ }
31
+ }
32
+ };
33
+ }
34
+ if (!Array.prototype.map) {
35
+ Array.prototype.map = function(fun /*, thisp*/) {
36
+ var len = this.length >>> 0;
37
+ var res = new Array(len);
38
+ var thisp = arguments[1];
39
+
40
+ for (var i = 0; i < len; i++) {
41
+ if (i in this) {
42
+ res[i] = fun.call(thisp, this[i], i, this);
43
+ }
44
+ }
45
+ return res;
46
+ };
47
+ }
48
+ if (!Array.prototype.filter) {
49
+ Array.prototype.filter = function (block /*, thisp */) {
50
+ var values = [];
51
+ var thisp = arguments[1];
52
+ for (var i = 0; i < this.length; i++) {
53
+ if (block.call(thisp, this[i])) {
54
+ values.push(this[i]);
55
+ }
56
+ }
57
+ return values;
58
+ };
59
+ }
60
+ if (!Array.prototype.reduce) {
61
+ Array.prototype.reduce = function(fun /*, initial*/) {
62
+ var len = this.length >>> 0;
63
+ var i = 0;
64
+
65
+ // no value to return if no initial value and an empty array
66
+ if (len === 0 && arguments.length === 1) throw new TypeError();
67
+
68
+ if (arguments.length >= 2) {
69
+ var rv = arguments[1];
70
+ } else {
71
+ do {
72
+ if (i in this) {
73
+ rv = this[i++];
74
+ break;
75
+ }
76
+ // if array contains no values, no initial value to return
77
+ if (++i >= len) throw new TypeError();
78
+ } while (true);
79
+ }
80
+ for (; i < len; i++) {
81
+ if (i in this) {
82
+ rv = fun.call(null, rv, this[i], i, this);
83
+ }
84
+ }
85
+ return rv;
86
+ };
87
+ }
88
+ if (!Array.prototype.indexOf) {
89
+ Array.prototype.indexOf = function (value /*, fromIndex */ ) {
90
+ var length = this.length;
91
+ var i = arguments[1] || 0;
92
+
93
+ if (!length) return -1;
94
+ if (i >= length) return -1;
95
+ if (i < 0) i += length;
96
+
97
+ for (; i < length; i++) {
98
+ if (!Object.prototype.hasOwnProperty.call(this, i)) { continue }
99
+ if (value === this[i]) return i;
100
+ }
101
+ return -1;
102
+ };
103
+ }
104
+
105
+ //
106
+ // Object
107
+ //
108
+ if (!Object.keys) {
109
+ Object.keys = function (object) {
110
+ var keys = [];
111
+ for (var name in object) {
112
+ if (Object.prototype.hasOwnProperty.call(object, name)) {
113
+ keys.push(name);
114
+ }
115
+ }
116
+ return keys;
117
+ };
118
+ }
119
+
120
+ //
121
+ // String
122
+ //
123
+ if (!String.prototype.trim) {
124
+ String.prototype.trim = function () {
125
+ return String(this).replace(/^\s\s*/, '').replace(/\s\s*$/, '');
126
+ };
127
+ }
128
+ var less, tree, charset;
129
+
130
+ if (typeof environment === "object" && ({}).toString.call(environment) === "[object Environment]") {
131
+ // Rhino
132
+ // Details on how to detect Rhino: https://github.com/ringo/ringojs/issues/88
133
+ if (typeof(window) === 'undefined') { less = {} }
134
+ else { less = window.less = {} }
135
+ tree = less.tree = {};
136
+ less.mode = 'rhino';
137
+ } else if (typeof(window) === 'undefined') {
138
+ // Node.js
139
+ less = exports,
140
+ tree = require('./tree');
141
+ less.mode = 'node';
142
+ } else {
143
+ // Browser
144
+ if (typeof(window.less) === 'undefined') { window.less = {} }
145
+ less = window.less,
146
+ tree = window.less.tree = {};
147
+ less.mode = 'browser';
148
+ }
149
+ //
150
+ // less.js - parser
151
+ //
152
+ // A relatively straight-forward predictive parser.
153
+ // There is no tokenization/lexing stage, the input is parsed
154
+ // in one sweep.
155
+ //
156
+ // To make the parser fast enough to run in the browser, several
157
+ // optimization had to be made:
158
+ //
159
+ // - Matching and slicing on a huge input is often cause of slowdowns.
160
+ // The solution is to chunkify the input into smaller strings.
161
+ // The chunks are stored in the `chunks` var,
162
+ // `j` holds the current chunk index, and `current` holds
163
+ // the index of the current chunk in relation to `input`.
164
+ // This gives us an almost 4x speed-up.
165
+ //
166
+ // - In many cases, we don't need to match individual tokens;
167
+ // for example, if a value doesn't hold any variables, operations
168
+ // or dynamic references, the parser can effectively 'skip' it,
169
+ // treating it as a literal.
170
+ // An example would be '1px solid #000' - which evaluates to itself,
171
+ // we don't need to know what the individual components are.
172
+ // The drawback, of course is that you don't get the benefits of
173
+ // syntax-checking on the CSS. This gives us a 50% speed-up in the parser,
174
+ // and a smaller speed-up in the code-gen.
175
+ //
176
+ //
177
+ // Token matching is done with the `$` function, which either takes
178
+ // a terminal string or regexp, or a non-terminal function to call.
179
+ // It also takes care of moving all the indices forwards.
180
+ //
181
+ //
182
+ less.Parser = function Parser(env) {
183
+ var input, // LeSS input string
184
+ i, // current index in `input`
185
+ j, // current chunk
186
+ temp, // temporarily holds a chunk's state, for backtracking
187
+ memo, // temporarily holds `i`, when backtracking
188
+ furthest, // furthest index the parser has gone to
189
+ chunks, // chunkified input
190
+ current, // index of current chunk, in `input`
191
+ parser;
192
+
193
+ var that = this;
194
+
195
+ // Top parser on an import tree must be sure there is one "env"
196
+ // which will then be passed arround by reference.
197
+ var env = env || { };
198
+ // env.contents and files must be passed arround with top env
199
+ if (!env.contents) { env.contents = {}; }
200
+ env.rootpath = env.rootpath || ''; // env.rootpath must be initialized to '' if not provided
201
+ if (!env.files) { env.files = {}; }
202
+
203
+ // This function is called after all files
204
+ // have been imported through `@import`.
205
+ var finish = function () {};
206
+
207
+ var imports = this.imports = {
208
+ paths: env.paths || [], // Search paths, when importing
209
+ queue: [], // Files which haven't been imported yet
210
+ files: env.files, // Holds the imported parse trees
211
+ contents: env.contents, // Holds the imported file contents
212
+ mime: env.mime, // MIME type of .less files
213
+ error: null, // Error in parsing/evaluating an import
214
+ push: function (path, callback) {
215
+ var that = this;
216
+ this.queue.push(path);
217
+
218
+ //
219
+ // Import a file asynchronously
220
+ //
221
+ less.Parser.importer(path, this.paths, function (e, root, fullPath) {
222
+ that.queue.splice(that.queue.indexOf(path), 1); // Remove the path from the queue
223
+
224
+ var imported = fullPath in that.files;
225
+
226
+ that.files[fullPath] = root; // Store the root
227
+
228
+ if (e && !that.error) { that.error = e }
229
+
230
+ callback(e, root, imported);
231
+
232
+ if (that.queue.length === 0) { finish(that.error) } // Call `finish` if we're done importing
233
+ }, env);
234
+ }
235
+ };
236
+
237
+ function save() { temp = chunks[j], memo = i, current = i }
238
+ function restore() { chunks[j] = temp, i = memo, current = i }
239
+
240
+ function sync() {
241
+ if (i > current) {
242
+ chunks[j] = chunks[j].slice(i - current);
243
+ current = i;
244
+ }
245
+ }
246
+ function isWhitespace(c) {
247
+ // Could change to \s?
248
+ var code = c.charCodeAt(0);
249
+ return code === 32 || code === 10 || code === 9;
250
+ }
251
+ //
252
+ // Parse from a token, regexp or string, and move forward if match
253
+ //
254
+ function $(tok) {
255
+ var match, args, length, index, k;
256
+
257
+ //
258
+ // Non-terminal
259
+ //
260
+ if (tok instanceof Function) {
261
+ return tok.call(parser.parsers);
262
+ //
263
+ // Terminal
264
+ //
265
+ // Either match a single character in the input,
266
+ // or match a regexp in the current chunk (chunk[j]).
267
+ //
268
+ } else if (typeof(tok) === 'string') {
269
+ match = input.charAt(i) === tok ? tok : null;
270
+ length = 1;
271
+ sync ();
272
+ } else {
273
+ sync ();
274
+
275
+ if (match = tok.exec(chunks[j])) {
276
+ length = match[0].length;
277
+ } else {
278
+ return null;
279
+ }
280
+ }
281
+
282
+ // The match is confirmed, add the match length to `i`,
283
+ // and consume any extra white-space characters (' ' || '\n')
284
+ // which come after that. The reason for this is that LeSS's
285
+ // grammar is mostly white-space insensitive.
286
+ //
287
+ if (match) {
288
+ skipWhitespace(length);
289
+
290
+ if(typeof(match) === 'string') {
291
+ return match;
292
+ } else {
293
+ return match.length === 1 ? match[0] : match;
294
+ }
295
+ }
296
+ }
297
+
298
+ function skipWhitespace(length) {
299
+ var oldi = i, oldj = j,
300
+ endIndex = i + chunks[j].length,
301
+ mem = i += length;
302
+
303
+ while (i < endIndex) {
304
+ if (! isWhitespace(input.charAt(i))) { break }
305
+ i++;
306
+ }
307
+ chunks[j] = chunks[j].slice(length + (i - mem));
308
+ current = i;
309
+
310
+ if (chunks[j].length === 0 && j < chunks.length - 1) { j++ }
311
+
312
+ return oldi !== i || oldj !== j;
313
+ }
314
+
315
+ function expect(arg, msg) {
316
+ var result = $(arg);
317
+ if (! result) {
318
+ error(msg || (typeof(arg) === 'string' ? "expected '" + arg + "' got '" + input.charAt(i) + "'"
319
+ : "unexpected token"));
320
+ } else {
321
+ return result;
322
+ }
323
+ }
324
+
325
+ function error(msg, type) {
326
+ var e = new Error(msg);
327
+ e.index = i;
328
+ e.type = type || 'Syntax';
329
+ throw e;
330
+ }
331
+
332
+ // Same as $(), but don't change the state of the parser,
333
+ // just return the match.
334
+ function peek(tok) {
335
+ if (typeof(tok) === 'string') {
336
+ return input.charAt(i) === tok;
337
+ } else {
338
+ if (tok.test(chunks[j])) {
339
+ return true;
340
+ } else {
341
+ return false;
342
+ }
343
+ }
344
+ }
345
+
346
+ function getInput(e, env) {
347
+ if (e.filename && env.filename && (e.filename !== env.filename)) {
348
+ return parser.imports.contents[e.filename];
349
+ } else {
350
+ return input;
351
+ }
352
+ }
353
+
354
+ function getLocation(index, input) {
355
+ for (var n = index, column = -1;
356
+ n >= 0 && input.charAt(n) !== '\n';
357
+ n--) { column++ }
358
+
359
+ return { line: typeof(index) === 'number' ? (input.slice(0, index).match(/\n/g) || "").length : null,
360
+ column: column };
361
+ }
362
+
363
+ function getFileName(e) {
364
+ if(less.mode === 'browser' || less.mode === 'rhino')
365
+ return e.filename;
366
+ else
367
+ return require('path').resolve(e.filename);
368
+ }
369
+
370
+ function getDebugInfo(index, inputStream, e) {
371
+ return {
372
+ lineNumber: getLocation(index, inputStream).line + 1,
373
+ fileName: getFileName(e)
374
+ };
375
+ }
376
+
377
+ function LessError(e, env) {
378
+ var input = getInput(e, env),
379
+ loc = getLocation(e.index, input),
380
+ line = loc.line,
381
+ col = loc.column,
382
+ lines = input.split('\n');
383
+
384
+ this.type = e.type || 'Syntax';
385
+ this.message = e.message;
386
+ this.filename = e.filename || env.filename;
387
+ this.index = e.index;
388
+ this.line = typeof(line) === 'number' ? line + 1 : null;
389
+ this.callLine = e.call && (getLocation(e.call, input).line + 1);
390
+ this.callExtract = lines[getLocation(e.call, input).line];
391
+ this.stack = e.stack;
392
+ this.column = col;
393
+ this.extract = [
394
+ lines[line - 1],
395
+ lines[line],
396
+ lines[line + 1]
397
+ ];
398
+ }
399
+
400
+ this.env = env = env || {};
401
+
402
+ // The optimization level dictates the thoroughness of the parser,
403
+ // the lower the number, the less nodes it will create in the tree.
404
+ // This could matter for debugging, or if you want to access
405
+ // the individual nodes in the tree.
406
+ this.optimization = ('optimization' in this.env) ? this.env.optimization : 1;
407
+
408
+ this.env.filename = this.env.filename || null;
409
+
410
+ //
411
+ // The Parser
412
+ //
413
+ return parser = {
414
+
415
+ imports: imports,
416
+ //
417
+ // Parse an input string into an abstract syntax tree,
418
+ // call `callback` when done.
419
+ //
420
+ parse: function (str, callback) {
421
+ var root, start, end, zone, line, lines, buff = [], c, error = null;
422
+
423
+ i = j = current = furthest = 0;
424
+ input = str.replace(/\r\n/g, '\n');
425
+
426
+ // Remove potential UTF Byte Order Mark
427
+ input = input.replace(/^\uFEFF/, '');
428
+
429
+ // Split the input into chunks.
430
+ chunks = (function (chunks) {
431
+ var j = 0,
432
+ skip = /(?:@\{[\w-]+\}|[^"'`\{\}\/\(\)\\])+/g,
433
+ comment = /\/\*(?:[^*]|\*+[^\/*])*\*+\/|\/\/.*/g,
434
+ string = /"((?:[^"\\\r\n]|\\.)*)"|'((?:[^'\\\r\n]|\\.)*)'|`((?:[^`]|\\.)*)`/g,
435
+ level = 0,
436
+ match,
437
+ chunk = chunks[0],
438
+ inParam;
439
+
440
+ for (var i = 0, c, cc; i < input.length;) {
441
+ skip.lastIndex = i;
442
+ if (match = skip.exec(input)) {
443
+ if (match.index === i) {
444
+ i += match[0].length;
445
+ chunk.push(match[0]);
446
+ }
447
+ }
448
+ c = input.charAt(i);
449
+ comment.lastIndex = string.lastIndex = i;
450
+
451
+ if (match = string.exec(input)) {
452
+ if (match.index === i) {
453
+ i += match[0].length;
454
+ chunk.push(match[0]);
455
+ continue;
456
+ }
457
+ }
458
+
459
+ if (!inParam && c === '/') {
460
+ cc = input.charAt(i + 1);
461
+ if (cc === '/' || cc === '*') {
462
+ if (match = comment.exec(input)) {
463
+ if (match.index === i) {
464
+ i += match[0].length;
465
+ chunk.push(match[0]);
466
+ continue;
467
+ }
468
+ }
469
+ }
470
+ }
471
+
472
+ switch (c) {
473
+ case '{': if (! inParam) { level ++; chunk.push(c); break }
474
+ case '}': if (! inParam) { level --; chunk.push(c); chunks[++j] = chunk = []; break }
475
+ case '(': if (! inParam) { inParam = true; chunk.push(c); break }
476
+ case ')': if ( inParam) { inParam = false; chunk.push(c); break }
477
+ default: chunk.push(c);
478
+ }
479
+
480
+ i++;
481
+ }
482
+ if (level != 0) {
483
+ error = new(LessError)({
484
+ index: i-1,
485
+ type: 'Parse',
486
+ message: (level > 0) ? "missing closing `}`" : "missing opening `{`",
487
+ filename: env.filename
488
+ }, env);
489
+ }
490
+
491
+ return chunks.map(function (c) { return c.join('') });;
492
+ })([[]]);
493
+
494
+ if (error) {
495
+ return callback(error, env);
496
+ }
497
+
498
+ // Start with the primary rule.
499
+ // The whole syntax tree is held under a Ruleset node,
500
+ // with the `root` property set to true, so no `{}` are
501
+ // output. The callback is called when the input is parsed.
502
+ try {
503
+ root = new(tree.Ruleset)([], $(this.parsers.primary));
504
+ root.root = true;
505
+ } catch (e) {
506
+ return callback(new(LessError)(e, env));
507
+ }
508
+
509
+ root.toCSS = (function (evaluate) {
510
+ var line, lines, column;
511
+
512
+ return function (options, variables) {
513
+ var frames = [], importError;
514
+
515
+ options = options || {};
516
+ //
517
+ // Allows setting variables with a hash, so:
518
+ //
519
+ // `{ color: new(tree.Color)('#f01') }` will become:
520
+ //
521
+ // new(tree.Rule)('@color',
522
+ // new(tree.Value)([
523
+ // new(tree.Expression)([
524
+ // new(tree.Color)('#f01')
525
+ // ])
526
+ // ])
527
+ // )
528
+ //
529
+ if (typeof(variables) === 'object' && !Array.isArray(variables)) {
530
+ variables = Object.keys(variables).map(function (k) {
531
+ var value = variables[k];
532
+
533
+ if (! (value instanceof tree.Value)) {
534
+ if (! (value instanceof tree.Expression)) {
535
+ value = new(tree.Expression)([value]);
536
+ }
537
+ value = new(tree.Value)([value]);
538
+ }
539
+ return new(tree.Rule)('@' + k, value, false, 0);
540
+ });
541
+ frames = [new(tree.Ruleset)(null, variables)];
542
+ }
543
+
544
+ try {
545
+ var css = evaluate.call(this, { frames: frames })
546
+ .toCSS([], { compress: options.compress || false, dumpLineNumbers: env.dumpLineNumbers });
547
+ } catch (e) {
548
+ throw new(LessError)(e, env);
549
+ }
550
+
551
+ if ((importError = parser.imports.error)) { // Check if there was an error during importing
552
+ if (importError instanceof LessError) throw importError;
553
+ else throw new(LessError)(importError, env);
554
+ }
555
+
556
+ if (options.yuicompress && less.mode === 'node') {
557
+ return require('ycssmin').cssmin(css);
558
+ } else if (options.compress) {
559
+ return css.replace(/(\s)+/g, "$1");
560
+ } else {
561
+ return css;
562
+ }
563
+ };
564
+ })(root.eval);
565
+
566
+ // If `i` is smaller than the `input.length - 1`,
567
+ // it means the parser wasn't able to parse the whole
568
+ // string, so we've got a parsing error.
569
+ //
570
+ // We try to extract a \n delimited string,
571
+ // showing the line where the parse error occured.
572
+ // We split it up into two parts (the part which parsed,
573
+ // and the part which didn't), so we can color them differently.
574
+ if (i < input.length - 1) {
575
+ i = furthest;
576
+ lines = input.split('\n');
577
+ line = (input.slice(0, i).match(/\n/g) || "").length + 1;
578
+
579
+ for (var n = i, column = -1; n >= 0 && input.charAt(n) !== '\n'; n--) { column++ }
580
+
581
+ error = {
582
+ type: "Parse",
583
+ message: "Syntax Error on line " + line,
584
+ index: i,
585
+ filename: env.filename,
586
+ line: line,
587
+ column: column,
588
+ extract: [
589
+ lines[line - 2],
590
+ lines[line - 1],
591
+ lines[line]
592
+ ]
593
+ };
594
+ }
595
+
596
+ if (this.imports.queue.length > 0) {
597
+ finish = function (e) {
598
+ e = error || e;
599
+ if (e) callback(e);
600
+ else callback(null, root);
601
+ };
602
+ } else {
603
+ callback(error, root);
604
+ }
605
+ },
606
+
607
+ //
608
+ // Here in, the parsing rules/functions
609
+ //
610
+ // The basic structure of the syntax tree generated is as follows:
611
+ //
612
+ // Ruleset -> Rule -> Value -> Expression -> Entity
613
+ //
614
+ // Here's some LESS code:
615
+ //
616
+ // .class {
617
+ // color: #fff;
618
+ // border: 1px solid #000;
619
+ // width: @w + 4px;
620
+ // > .child {...}
621
+ // }
622
+ //
623
+ // And here's what the parse tree might look like:
624
+ //
625
+ // Ruleset (Selector '.class', [
626
+ // Rule ("color", Value ([Expression [Color #fff]]))
627
+ // Rule ("border", Value ([Expression [Dimension 1px][Keyword "solid"][Color #000]]))
628
+ // Rule ("width", Value ([Expression [Operation "+" [Variable "@w"][Dimension 4px]]]))
629
+ // Ruleset (Selector [Element '>', '.child'], [...])
630
+ // ])
631
+ //
632
+ // In general, most rules will try to parse a token with the `$()` function, and if the return
633
+ // value is truly, will return a new node, of the relevant type. Sometimes, we need to check
634
+ // first, before parsing, that's when we use `peek()`.
635
+ //
636
+ parsers: {
637
+ //
638
+ // The `primary` rule is the *entry* and *exit* point of the parser.
639
+ // The rules here can appear at any level of the parse tree.
640
+ //
641
+ // The recursive nature of the grammar is an interplay between the `block`
642
+ // rule, which represents `{ ... }`, the `ruleset` rule, and this `primary` rule,
643
+ // as represented by this simplified grammar:
644
+ //
645
+ // primary → (ruleset | rule)+
646
+ // ruleset → selector+ block
647
+ // block → '{' primary '}'
648
+ //
649
+ // Only at one point is the primary rule not called from the
650
+ // block rule: at the root level.
651
+ //
652
+ primary: function () {
653
+ var node, root = [];
654
+
655
+ while ((node = $(this.extendRule) || $(this.mixin.definition) || $(this.rule) || $(this.ruleset) ||
656
+ $(this.mixin.call) || $(this.comment) || $(this.directive))
657
+ || $(/^[\s\n]+/) || $(/^;+/)) {
658
+ node && root.push(node);
659
+ }
660
+ return root;
661
+ },
662
+
663
+ // We create a Comment node for CSS comments `/* */`,
664
+ // but keep the LeSS comments `//` silent, by just skipping
665
+ // over them.
666
+ comment: function () {
667
+ var comment;
668
+
669
+ if (input.charAt(i) !== '/') return;
670
+
671
+ if (input.charAt(i + 1) === '/') {
672
+ return new(tree.Comment)($(/^\/\/.*/), true);
673
+ } else if (comment = $(/^\/\*(?:[^*]|\*+[^\/*])*\*+\/\n?/)) {
674
+ return new(tree.Comment)(comment);
675
+ }
676
+ },
677
+
678
+ //
679
+ // Entities are tokens which can be found inside an Expression
680
+ //
681
+ entities: {
682
+ //
683
+ // A string, which supports escaping " and '
684
+ //
685
+ // "milky way" 'he\'s the one!'
686
+ //
687
+ quoted: function () {
688
+ var str, j = i, e;
689
+
690
+ if (input.charAt(j) === '~') { j++, e = true } // Escaped strings
691
+ if (input.charAt(j) !== '"' && input.charAt(j) !== "'") return;
692
+
693
+ e && $('~');
694
+
695
+ if (str = $(/^"((?:[^"\\\r\n]|\\.)*)"|'((?:[^'\\\r\n]|\\.)*)'/)) {
696
+ return new(tree.Quoted)(str[0], str[1] || str[2], e);
697
+ }
698
+ },
699
+
700
+ //
701
+ // A catch-all word, such as:
702
+ //
703
+ // black border-collapse
704
+ //
705
+ keyword: function () {
706
+ var k;
707
+
708
+ if (k = $(/^[_A-Za-z-][_A-Za-z0-9-]*/)) {
709
+ if (tree.colors.hasOwnProperty(k)) {
710
+ // detect named color
711
+ return new(tree.Color)(tree.colors[k].slice(1));
712
+ } else {
713
+ return new(tree.Keyword)(k);
714
+ }
715
+ }
716
+ },
717
+
718
+ //
719
+ // A function call
720
+ //
721
+ // rgb(255, 0, 255)
722
+ //
723
+ // We also try to catch IE's `alpha()`, but let the `alpha` parser
724
+ // deal with the details.
725
+ //
726
+ // The arguments are parsed with the `entities.arguments` parser.
727
+ //
728
+ call: function () {
729
+ var name, nameLC, args, alpha_ret, index = i;
730
+
731
+ if (! (name = /^([\w-]+|%|progid:[\w\.]+)\(/.exec(chunks[j]))) return;
732
+
733
+ name = name[1];
734
+ nameLC = name.toLowerCase();
735
+
736
+ if (nameLC === 'url') { return null }
737
+ else { i += name.length }
738
+
739
+ if (nameLC === 'alpha') {
740
+ alpha_ret = $(this.alpha);
741
+ if(typeof alpha_ret !== 'undefined') {
742
+ return alpha_ret;
743
+ }
744
+ }
745
+
746
+ $('('); // Parse the '(' and consume whitespace.
747
+
748
+ args = $(this.entities.arguments);
749
+
750
+ if (! $(')')) return;
751
+
752
+ if (name) { return new(tree.Call)(name, args, index, env.filename) }
753
+ },
754
+ arguments: function () {
755
+ var args = [], arg;
756
+
757
+ while (arg = $(this.entities.assignment) || $(this.expression)) {
758
+ args.push(arg);
759
+ if (! $(',')) { break }
760
+ }
761
+ return args;
762
+ },
763
+ literal: function () {
764
+ return $(this.entities.ratio) ||
765
+ $(this.entities.dimension) ||
766
+ $(this.entities.color) ||
767
+ $(this.entities.quoted) ||
768
+ $(this.entities.unicodeDescriptor);
769
+ },
770
+
771
+ // Assignments are argument entities for calls.
772
+ // They are present in ie filter properties as shown below.
773
+ //
774
+ // filter: progid:DXImageTransform.Microsoft.Alpha( *opacity=50* )
775
+ //
776
+
777
+ assignment: function () {
778
+ var key, value;
779
+ if ((key = $(/^\w+(?=\s?=)/i)) && $('=') && (value = $(this.entity))) {
780
+ return new(tree.Assignment)(key, value);
781
+ }
782
+ },
783
+
784
+ //
785
+ // Parse url() tokens
786
+ //
787
+ // We use a specific rule for urls, because they don't really behave like
788
+ // standard function calls. The difference is that the argument doesn't have
789
+ // to be enclosed within a string, so it can't be parsed as an Expression.
790
+ //
791
+ url: function () {
792
+ var value;
793
+
794
+ if (input.charAt(i) !== 'u' || !$(/^url\(/)) return;
795
+ value = $(this.entities.quoted) || $(this.entities.variable) ||
796
+ $(/^(?:(?:\\[\(\)'"])|[^\(\)'"])+/) || "";
797
+
798
+ expect(')');
799
+
800
+ return new(tree.URL)((value.value != null || value instanceof tree.Variable)
801
+ ? value : new(tree.Anonymous)(value), env.rootpath);
802
+ },
803
+
804
+ //
805
+ // A Variable entity, such as `@fink`, in
806
+ //
807
+ // width: @fink + 2px
808
+ //
809
+ // We use a different parser for variable definitions,
810
+ // see `parsers.variable`.
811
+ //
812
+ variable: function () {
813
+ var name, index = i;
814
+
815
+ if (input.charAt(i) === '@' && (name = $(/^@@?[\w-]+/))) {
816
+ return new(tree.Variable)(name, index, env.filename);
817
+ }
818
+ },
819
+
820
+ // A variable entity useing the protective {} e.g. @{var}
821
+ variableCurly: function () {
822
+ var name, curly, index = i;
823
+
824
+ if (input.charAt(i) === '@' && (curly = $(/^@\{([\w-]+)\}/))) {
825
+ return new(tree.Variable)("@" + curly[1], index, env.filename);
826
+ }
827
+ },
828
+
829
+ //
830
+ // A Hexadecimal color
831
+ //
832
+ // #4F3C2F
833
+ //
834
+ // `rgb` and `hsl` colors are parsed through the `entities.call` parser.
835
+ //
836
+ color: function () {
837
+ var rgb;
838
+
839
+ if (input.charAt(i) === '#' && (rgb = $(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})/))) {
840
+ return new(tree.Color)(rgb[1]);
841
+ }
842
+ },
843
+
844
+ //
845
+ // A Dimension, that is, a number and a unit
846
+ //
847
+ // 0.5em 95%
848
+ //
849
+ dimension: function () {
850
+ var value, c = input.charCodeAt(i);
851
+ //Is the first char of the dimension 0-9, '.', '+' or '-'
852
+ if ((c > 57 || c < 43) || c === 47 || c == 44) return;
853
+
854
+ if (value = $(/^([+-]?\d*\.?\d+)(%|[a-z]+)?/)) {
855
+ return new(tree.Dimension)(value[1], value[2]);
856
+ }
857
+ },
858
+
859
+ //
860
+ // A Ratio
861
+ //
862
+ // 16/9
863
+ //
864
+ ratio: function () {
865
+ var value, c = input.charCodeAt(i);
866
+ if (c > 57 || c < 48) return;
867
+
868
+ if (value = $(/^(\d+\/\d+)/)) {
869
+ return new(tree.Ratio)(value[1]);
870
+ }
871
+ },
872
+
873
+ //
874
+ // A unicode descriptor, as is used in unicode-range
875
+ //
876
+ // U+0?? or U+00A1-00A9
877
+ //
878
+ unicodeDescriptor: function () {
879
+ var ud;
880
+
881
+ if (ud = $(/^U\+[0-9a-fA-F?]+(\-[0-9a-fA-F?]+)?/)) {
882
+ return new(tree.UnicodeDescriptor)(ud[0]);
883
+ }
884
+ },
885
+
886
+ //
887
+ // JavaScript code to be evaluated
888
+ //
889
+ // `window.location.href`
890
+ //
891
+ javascript: function () {
892
+ var str, j = i, e;
893
+
894
+ if (input.charAt(j) === '~') { j++, e = true } // Escaped strings
895
+ if (input.charAt(j) !== '`') { return }
896
+
897
+ e && $('~');
898
+
899
+ if (str = $(/^`([^`]*)`/)) {
900
+ return new(tree.JavaScript)(str[1], i, e);
901
+ }
902
+ }
903
+ },
904
+
905
+ //
906
+ // The variable part of a variable definition. Used in the `rule` parser
907
+ //
908
+ // @fink:
909
+ //
910
+ variable: function () {
911
+ var name;
912
+
913
+ if (input.charAt(i) === '@' && (name = $(/^(@[\w-]+)\s*:/))) { return name[1] }
914
+ },
915
+
916
+ //
917
+ // A font size/line-height shorthand
918
+ //
919
+ // small/12px
920
+ //
921
+ // We need to peek first, or we'll match on keywords and dimensions
922
+ //
923
+ shorthand: function () {
924
+ var a, b;
925
+
926
+ if (! peek(/^[@\w.%-]+\/[@\w.-]+/)) return;
927
+
928
+ save();
929
+
930
+ if ((a = $(this.entity)) && $('/') && (b = $(this.entity))) {
931
+ return new(tree.Shorthand)(a, b);
932
+ }
933
+
934
+ restore();
935
+ },
936
+
937
+ //
938
+ // extend syntax - used to extend selectors
939
+ //
940
+ extend: function(isRule) {
941
+ var elements = [], e, args, index = i;
942
+
943
+ if (!$(isRule ? /^&:extend\(/ : /^:extend\(/)) { return; }
944
+
945
+ while (e = $(/^[#.](?:[\w-]|\\(?:[a-fA-F0-9]{1,6} ?|[^a-fA-F0-9]))+/)) {
946
+ elements.push(new(tree.Element)(null, e, i));
947
+ }
948
+
949
+ expect(/^\)/);
950
+
951
+ if (isRule) {
952
+ expect(/^;/);
953
+ }
954
+
955
+ return new(tree.Extend)(elements, index);
956
+ },
957
+
958
+ //
959
+ // extendRule - used in a rule to extend all the parent selectors
960
+ //
961
+ extendRule: function() {
962
+ return this.extend(true);
963
+ },
964
+
965
+ //
966
+ // Mixins
967
+ //
968
+ mixin: {
969
+ //
970
+ // A Mixin call, with an optional argument list
971
+ //
972
+ // #mixins > .square(#fff);
973
+ // .rounded(4px, black);
974
+ // .button;
975
+ //
976
+ // The `while` loop is there because mixins can be
977
+ // namespaced, but we only support the child and descendant
978
+ // selector for now.
979
+ //
980
+ call: function () {
981
+ var elements = [], e, c, argsSemiColon = [], argsComma = [], args, delim, arg, nameLoop, expressions, isSemiColonSeperated, expressionContainsNamed, index = i, s = input.charAt(i), name, value, important = false;
982
+
983
+ if (s !== '.' && s !== '#') { return }
984
+
985
+ save(); // stop us absorbing part of an invalid selector
986
+
987
+ while (e = $(/^[#.](?:[\w-]|\\(?:[A-Fa-f0-9]{1,6} ?|[^A-Fa-f0-9]))+/)) {
988
+ elements.push(new(tree.Element)(c, e, i));
989
+ c = $('>');
990
+ }
991
+ if ($('(')) {
992
+ expressions = [];
993
+ while (arg = $(this.expression)) {
994
+ nameLoop = null;
995
+ value = arg;
996
+
997
+ // Variable
998
+ if (arg.value.length == 1) {
999
+ var val = arg.value[0];
1000
+ if (val instanceof tree.Variable) {
1001
+ if ($(':')) {
1002
+ if (expressions.length > 0) {
1003
+ if (isSemiColonSeperated) {
1004
+ error("Cannot mix ; and , as delimiter types");
1005
+ }
1006
+ expressionContainsNamed = true;
1007
+ }
1008
+ value = expect(this.expression);
1009
+ nameLoop = (name = val.name);
1010
+ }
1011
+ }
1012
+ }
1013
+
1014
+ expressions.push(value);
1015
+
1016
+ argsComma.push({ name: nameLoop, value: value });
1017
+
1018
+ if ($(',')) {
1019
+ continue;
1020
+ }
1021
+
1022
+ if ($(';') || isSemiColonSeperated) {
1023
+
1024
+ if (expressionContainsNamed) {
1025
+ error("Cannot mix ; and , as delimiter types");
1026
+ }
1027
+
1028
+ isSemiColonSeperated = true;
1029
+
1030
+ if (expressions.length > 1) {
1031
+ value = new(tree.Value)(expressions);
1032
+ }
1033
+ argsSemiColon.push({ name: name, value: value });
1034
+
1035
+ name = null;
1036
+ expressions = [];
1037
+ expressionContainsNamed = false;
1038
+ }
1039
+ }
1040
+
1041
+ expect(')');
1042
+ }
1043
+
1044
+ args = isSemiColonSeperated ? argsSemiColon : argsComma;
1045
+
1046
+ if ($(this.important)) {
1047
+ important = true;
1048
+ }
1049
+
1050
+ if (elements.length > 0 && ($(';') || peek('}'))) {
1051
+ return new(tree.mixin.Call)(elements, args, index, env.filename, important);
1052
+ }
1053
+
1054
+ restore();
1055
+ },
1056
+
1057
+ //
1058
+ // A Mixin definition, with a list of parameters
1059
+ //
1060
+ // .rounded (@radius: 2px, @color) {
1061
+ // ...
1062
+ // }
1063
+ //
1064
+ // Until we have a finer grained state-machine, we have to
1065
+ // do a look-ahead, to make sure we don't have a mixin call.
1066
+ // See the `rule` function for more information.
1067
+ //
1068
+ // We start by matching `.rounded (`, and then proceed on to
1069
+ // the argument list, which has optional default values.
1070
+ // We store the parameters in `params`, with a `value` key,
1071
+ // if there is a value, such as in the case of `@radius`.
1072
+ //
1073
+ // Once we've got our params list, and a closing `)`, we parse
1074
+ // the `{...}` block.
1075
+ //
1076
+ definition: function () {
1077
+ var name, params = [], match, ruleset, param, value, cond, variadic = false;
1078
+ if ((input.charAt(i) !== '.' && input.charAt(i) !== '#') ||
1079
+ peek(/^[^{]*\}/)) return;
1080
+
1081
+ save();
1082
+
1083
+ if (match = $(/^([#.](?:[\w-]|\\(?:[A-Fa-f0-9]{1,6} ?|[^A-Fa-f0-9]))+)\s*\(/)) {
1084
+ name = match[1];
1085
+
1086
+ do {
1087
+ $(this.comment);
1088
+ if (input.charAt(i) === '.' && $(/^\.{3}/)) {
1089
+ variadic = true;
1090
+ params.push({ variadic: true });
1091
+ break;
1092
+ } else if (param = $(this.entities.variable) || $(this.entities.literal)
1093
+ || $(this.entities.keyword)) {
1094
+ // Variable
1095
+ if (param instanceof tree.Variable) {
1096
+ if ($(':')) {
1097
+ value = expect(this.expression, 'expected expression');
1098
+ params.push({ name: param.name, value: value });
1099
+ } else if ($(/^\.{3}/)) {
1100
+ params.push({ name: param.name, variadic: true });
1101
+ variadic = true;
1102
+ break;
1103
+ } else {
1104
+ params.push({ name: param.name });
1105
+ }
1106
+ } else {
1107
+ params.push({ value: param });
1108
+ }
1109
+ } else {
1110
+ break;
1111
+ }
1112
+ } while ($(',') || $(';'))
1113
+
1114
+ // .mixincall("@{a}");
1115
+ // looks a bit like a mixin definition.. so we have to be nice and restore
1116
+ if (!$(')')) {
1117
+ furthest = i;
1118
+ restore();
1119
+ }
1120
+
1121
+ $(this.comment);
1122
+
1123
+ if ($(/^when/)) { // Guard
1124
+ cond = expect(this.conditions, 'expected condition');
1125
+ }
1126
+
1127
+ ruleset = $(this.block);
1128
+
1129
+ if (ruleset) {
1130
+ return new(tree.mixin.Definition)(name, params, ruleset, cond, variadic);
1131
+ } else {
1132
+ restore();
1133
+ }
1134
+ }
1135
+ }
1136
+ },
1137
+
1138
+ //
1139
+ // Entities are the smallest recognized token,
1140
+ // and can be found inside a rule's value.
1141
+ //
1142
+ entity: function () {
1143
+ return $(this.entities.literal) || $(this.entities.variable) || $(this.entities.url) ||
1144
+ $(this.entities.call) || $(this.entities.keyword) ||$(this.entities.javascript) ||
1145
+ $(this.comment);
1146
+ },
1147
+
1148
+ //
1149
+ // A Rule terminator. Note that we use `peek()` to check for '}',
1150
+ // because the `block` rule will be expecting it, but we still need to make sure
1151
+ // it's there, if ';' was ommitted.
1152
+ //
1153
+ end: function () {
1154
+ return $(';') || peek('}');
1155
+ },
1156
+
1157
+ //
1158
+ // IE's alpha function
1159
+ //
1160
+ // alpha(opacity=88)
1161
+ //
1162
+ alpha: function () {
1163
+ var value;
1164
+
1165
+ if (! $(/^\(opacity=/i)) return;
1166
+ if (value = $(/^\d+/) || $(this.entities.variable)) {
1167
+ expect(')');
1168
+ return new(tree.Alpha)(value);
1169
+ }
1170
+ },
1171
+
1172
+ //
1173
+ // A Selector Element
1174
+ //
1175
+ // div
1176
+ // + h1
1177
+ // #socks
1178
+ // input[type="text"]
1179
+ //
1180
+ // Elements are the building blocks for Selectors,
1181
+ // they are made out of a `Combinator` (see combinator rule),
1182
+ // and an element name, such as a tag a class, or `*`.
1183
+ //
1184
+ element: function () {
1185
+ var e, t, c, v;
1186
+
1187
+ c = $(this.combinator);
1188
+
1189
+ e = $(/^(?:\d+\.\d+|\d+)%/) || $(/^(?:[.#]?|:*)(?:[\w-]|[^\x00-\x9f]|\\(?:[A-Fa-f0-9]{1,6} ?|[^A-Fa-f0-9]))+/) ||
1190
+ $('*') || $('&') || $(this.attribute) || $(/^\([^()@]+\)/) || $(/^[\.#](?=@)/) || $(this.entities.variableCurly);
1191
+
1192
+ if (! e) {
1193
+ if ($('(')) {
1194
+ if ((v = (//$(this.entities.variableCurly) ||
1195
+ $(this.selector))) &&
1196
+ $(')')) {
1197
+ e = new(tree.Paren)(v);
1198
+ }
1199
+ }
1200
+ }
1201
+
1202
+ if (e) { return new(tree.Element)(c, e, i) }
1203
+ },
1204
+
1205
+ //
1206
+ // Combinators combine elements together, in a Selector.
1207
+ //
1208
+ // Because our parser isn't white-space sensitive, special care
1209
+ // has to be taken, when parsing the descendant combinator, ` `,
1210
+ // as it's an empty space. We have to check the previous character
1211
+ // in the input, to see if it's a ` ` character. More info on how
1212
+ // we deal with this in *combinator.js*.
1213
+ //
1214
+ combinator: function () {
1215
+ var match, c = input.charAt(i);
1216
+
1217
+ if (c === '>' || c === '+' || c === '~' || c === '|') {
1218
+ i++;
1219
+ while (input.charAt(i).match(/\s/)) { i++ }
1220
+ return new(tree.Combinator)(c);
1221
+ } else if (input.charAt(i - 1).match(/\s/)) {
1222
+ return new(tree.Combinator)(" ");
1223
+ } else {
1224
+ return new(tree.Combinator)(null);
1225
+ }
1226
+ },
1227
+
1228
+ //
1229
+ // A CSS Selector
1230
+ //
1231
+ // .class > div + h1
1232
+ // li a:hover
1233
+ //
1234
+ // Selectors are made out of one or more Elements, see above.
1235
+ //
1236
+ selector: function () {
1237
+ var sel, e, elements = [], c, match, extend;
1238
+
1239
+ while ((extend = $(this.extend)) || (e = $(this.element))) {
1240
+ if (!e) {
1241
+ break;
1242
+ }
1243
+ c = input.charAt(i);
1244
+ elements.push(e)
1245
+ e = null;
1246
+ if (c === '{' || c === '}' || c === ';' || c === ',' || c === ')') { break }
1247
+ }
1248
+
1249
+ if (elements.length > 0) { return new(tree.Selector)(elements, extend) }
1250
+ if (extend) { error("Extend must be used to extend a selector"); }
1251
+ },
1252
+ attribute: function () {
1253
+ var attr = '', key, val, op;
1254
+
1255
+ if (! $('[')) return;
1256
+
1257
+ if (key = $(/^(?:[_A-Za-z0-9-]|\\.)+/) || $(this.entities.quoted)) {
1258
+ if ((op = $(/^[|~*$^]?=/)) &&
1259
+ (val = $(this.entities.quoted) || $(/^[\w-]+/))) {
1260
+ attr = [key, op, val.toCSS ? val.toCSS() : val].join('');
1261
+ } else { attr = key }
1262
+ }
1263
+
1264
+ if (! $(']')) return;
1265
+
1266
+ if (attr) { return "[" + attr + "]" }
1267
+ },
1268
+
1269
+ //
1270
+ // The `block` rule is used by `ruleset` and `mixin.definition`.
1271
+ // It's a wrapper around the `primary` rule, with added `{}`.
1272
+ //
1273
+ block: function () {
1274
+ var content;
1275
+ if ($('{') && (content = $(this.primary)) && $('}')) {
1276
+ return content;
1277
+ }
1278
+ },
1279
+
1280
+ //
1281
+ // div, .class, body > p {...}
1282
+ //
1283
+ ruleset: function () {
1284
+ var selectors = [], s, rules, match, debugInfo;
1285
+
1286
+ save();
1287
+
1288
+ if (env.dumpLineNumbers)
1289
+ debugInfo = getDebugInfo(i, input, env);
1290
+
1291
+ while (s = $(this.selector)) {
1292
+ selectors.push(s);
1293
+ $(this.comment);
1294
+ if (! $(',')) { break }
1295
+ $(this.comment);
1296
+ }
1297
+
1298
+ if (selectors.length > 0 && (rules = $(this.block))) {
1299
+ var ruleset = new(tree.Ruleset)(selectors, rules, env.strictImports);
1300
+ if (env.dumpLineNumbers)
1301
+ ruleset.debugInfo = debugInfo;
1302
+ return ruleset;
1303
+ } else {
1304
+ // Backtrack
1305
+ furthest = i;
1306
+ restore();
1307
+ }
1308
+ },
1309
+ rule: function () {
1310
+ var name, value, c = input.charAt(i), important, match;
1311
+ save();
1312
+
1313
+ if (c === '.' || c === '#' || c === '&') { return }
1314
+
1315
+ if (name = $(this.variable) || $(this.property)) {
1316
+ if ((name.charAt(0) != '@') && (match = /^([^@+\/'"*`(;{}-]*);/.exec(chunks[j]))) {
1317
+ i += match[0].length - 1;
1318
+ value = new(tree.Anonymous)(match[1]);
1319
+ } else if (name === "font") {
1320
+ value = $(this.font);
1321
+ } else {
1322
+ value = $(this.value);
1323
+ }
1324
+ important = $(this.important);
1325
+
1326
+ if (value && $(this.end)) {
1327
+ return new(tree.Rule)(name, value, important, memo);
1328
+ } else {
1329
+ furthest = i;
1330
+ restore();
1331
+ }
1332
+ }
1333
+ },
1334
+
1335
+ //
1336
+ // An @import directive
1337
+ //
1338
+ // @import "lib";
1339
+ //
1340
+ // Depending on our environemnt, importing is done differently:
1341
+ // In the browser, it's an XHR request, in Node, it would be a
1342
+ // file-system operation. The function used for importing is
1343
+ // stored in `import`, which we pass to the Import constructor.
1344
+ //
1345
+ "import": function () {
1346
+ var path, features, index = i;
1347
+
1348
+ save();
1349
+
1350
+ var dir = $(/^@import(?:-(once|multiple))?\s+/);
1351
+
1352
+ if (dir && (path = $(this.entities.quoted) || $(this.entities.url))) {
1353
+ features = $(this.mediaFeatures);
1354
+ if ($(';')) {
1355
+ var importOnce = dir[1] !== 'multiple';
1356
+ return new(tree.Import)(path, imports, features, importOnce, index, env.rootpath);
1357
+ }
1358
+ }
1359
+
1360
+ restore();
1361
+ },
1362
+
1363
+ mediaFeature: function () {
1364
+ var e, p, nodes = [];
1365
+
1366
+ do {
1367
+ if (e = $(this.entities.keyword)) {
1368
+ nodes.push(e);
1369
+ } else if ($('(')) {
1370
+ p = $(this.property);
1371
+ e = $(this.entity);
1372
+ if ($(')')) {
1373
+ if (p && e) {
1374
+ nodes.push(new(tree.Paren)(new(tree.Rule)(p, e, null, i, true)));
1375
+ } else if (e) {
1376
+ nodes.push(new(tree.Paren)(e));
1377
+ } else {
1378
+ return null;
1379
+ }
1380
+ } else { return null }
1381
+ }
1382
+ } while (e);
1383
+
1384
+ if (nodes.length > 0) {
1385
+ return new(tree.Expression)(nodes);
1386
+ }
1387
+ },
1388
+
1389
+ mediaFeatures: function () {
1390
+ var e, features = [];
1391
+
1392
+ do {
1393
+ if (e = $(this.mediaFeature)) {
1394
+ features.push(e);
1395
+ if (! $(',')) { break }
1396
+ } else if (e = $(this.entities.variable)) {
1397
+ features.push(e);
1398
+ if (! $(',')) { break }
1399
+ }
1400
+ } while (e);
1401
+
1402
+ return features.length > 0 ? features : null;
1403
+ },
1404
+
1405
+ media: function () {
1406
+ var features, rules, media, debugInfo;
1407
+
1408
+ if (env.dumpLineNumbers)
1409
+ debugInfo = getDebugInfo(i, input, env);
1410
+
1411
+ if ($(/^@media/)) {
1412
+ features = $(this.mediaFeatures);
1413
+
1414
+ if (rules = $(this.block)) {
1415
+ media = new(tree.Media)(rules, features);
1416
+ if(env.dumpLineNumbers)
1417
+ media.debugInfo = debugInfo;
1418
+ return media;
1419
+ }
1420
+ }
1421
+ },
1422
+
1423
+ //
1424
+ // A CSS Directive
1425
+ //
1426
+ // @charset "utf-8";
1427
+ //
1428
+ directive: function () {
1429
+ var name, value, rules, identifier, e, nodes, nonVendorSpecificName,
1430
+ hasBlock, hasIdentifier, hasExpression;
1431
+
1432
+ if (input.charAt(i) !== '@') return;
1433
+
1434
+ if (value = $(this['import']) || $(this.media)) {
1435
+ return value;
1436
+ }
1437
+
1438
+ save();
1439
+
1440
+ name = $(/^@[a-z-]+/);
1441
+
1442
+ if (!name) return;
1443
+
1444
+ nonVendorSpecificName = name;
1445
+ if (name.charAt(1) == '-' && name.indexOf('-', 2) > 0) {
1446
+ nonVendorSpecificName = "@" + name.slice(name.indexOf('-', 2) + 1);
1447
+ }
1448
+
1449
+ switch(nonVendorSpecificName) {
1450
+ case "@font-face":
1451
+ hasBlock = true;
1452
+ break;
1453
+ case "@viewport":
1454
+ case "@top-left":
1455
+ case "@top-left-corner":
1456
+ case "@top-center":
1457
+ case "@top-right":
1458
+ case "@top-right-corner":
1459
+ case "@bottom-left":
1460
+ case "@bottom-left-corner":
1461
+ case "@bottom-center":
1462
+ case "@bottom-right":
1463
+ case "@bottom-right-corner":
1464
+ case "@left-top":
1465
+ case "@left-middle":
1466
+ case "@left-bottom":
1467
+ case "@right-top":
1468
+ case "@right-middle":
1469
+ case "@right-bottom":
1470
+ hasBlock = true;
1471
+ break;
1472
+ case "@page":
1473
+ case "@document":
1474
+ case "@supports":
1475
+ case "@keyframes":
1476
+ hasBlock = true;
1477
+ hasIdentifier = true;
1478
+ break;
1479
+ case "@namespace":
1480
+ hasExpression = true;
1481
+ break;
1482
+ }
1483
+
1484
+ if (hasIdentifier) {
1485
+ name += " " + ($(/^[^{]+/) || '').trim();
1486
+ }
1487
+
1488
+ if (hasBlock)
1489
+ {
1490
+ if (rules = $(this.block)) {
1491
+ return new(tree.Directive)(name, rules);
1492
+ }
1493
+ } else {
1494
+ if ((value = hasExpression ? $(this.expression) : $(this.entity)) && $(';')) {
1495
+ var directive = new(tree.Directive)(name, value);
1496
+ if (env.dumpLineNumbers) {
1497
+ directive.debugInfo = getDebugInfo(i, input, env);
1498
+ }
1499
+ return directive;
1500
+ }
1501
+ }
1502
+
1503
+ restore();
1504
+ },
1505
+ font: function () {
1506
+ var value = [], expression = [], weight, shorthand, font, e;
1507
+
1508
+ while (e = $(this.shorthand) || $(this.entity)) {
1509
+ expression.push(e);
1510
+ }
1511
+ value.push(new(tree.Expression)(expression));
1512
+
1513
+ if ($(',')) {
1514
+ while (e = $(this.expression)) {
1515
+ value.push(e);
1516
+ if (! $(',')) { break }
1517
+ }
1518
+ }
1519
+ return new(tree.Value)(value);
1520
+ },
1521
+
1522
+ //
1523
+ // A Value is a comma-delimited list of Expressions
1524
+ //
1525
+ // font-family: Baskerville, Georgia, serif;
1526
+ //
1527
+ // In a Rule, a Value represents everything after the `:`,
1528
+ // and before the `;`.
1529
+ //
1530
+ value: function () {
1531
+ var e, expressions = [], important;
1532
+
1533
+ while (e = $(this.expression)) {
1534
+ expressions.push(e);
1535
+ if (! $(',')) { break }
1536
+ }
1537
+
1538
+ if (expressions.length > 0) {
1539
+ return new(tree.Value)(expressions);
1540
+ }
1541
+ },
1542
+ important: function () {
1543
+ if (input.charAt(i) === '!') {
1544
+ return $(/^! *important/);
1545
+ }
1546
+ },
1547
+ sub: function () {
1548
+ var e;
1549
+
1550
+ if ($('(') && (e = $(this.expression)) && $(')')) {
1551
+ return e;
1552
+ }
1553
+ },
1554
+ multiplication: function () {
1555
+ var m, a, op, operation;
1556
+ if (m = $(this.operand)) {
1557
+ while (!peek(/^\/[*\/]/) && (op = ($('/') || $('*'))) && (a = $(this.operand))) {
1558
+ operation = new(tree.Operation)(op, [operation || m, a]);
1559
+ }
1560
+ return operation || m;
1561
+ }
1562
+ },
1563
+ addition: function () {
1564
+ var m, a, op, operation;
1565
+ if (m = $(this.multiplication)) {
1566
+ while ((op = $(/^[-+]\s+/) || (!isWhitespace(input.charAt(i - 1)) && ($('+') || $('-')))) &&
1567
+ (a = $(this.multiplication))) {
1568
+ operation = new(tree.Operation)(op, [operation || m, a]);
1569
+ }
1570
+ return operation || m;
1571
+ }
1572
+ },
1573
+ conditions: function () {
1574
+ var a, b, index = i, condition;
1575
+
1576
+ if (a = $(this.condition)) {
1577
+ while ($(',') && (b = $(this.condition))) {
1578
+ condition = new(tree.Condition)('or', condition || a, b, index);
1579
+ }
1580
+ return condition || a;
1581
+ }
1582
+ },
1583
+ condition: function () {
1584
+ var a, b, c, op, index = i, negate = false;
1585
+
1586
+ if ($(/^not/)) { negate = true }
1587
+ expect('(');
1588
+ if (a = $(this.addition) || $(this.entities.keyword) || $(this.entities.quoted)) {
1589
+ if (op = $(/^(?:>=|=<|[<=>])/)) {
1590
+ if (b = $(this.addition) || $(this.entities.keyword) || $(this.entities.quoted)) {
1591
+ c = new(tree.Condition)(op, a, b, index, negate);
1592
+ } else {
1593
+ error('expected expression');
1594
+ }
1595
+ } else {
1596
+ c = new(tree.Condition)('=', a, new(tree.Keyword)('true'), index, negate);
1597
+ }
1598
+ expect(')');
1599
+ return $(/^and/) ? new(tree.Condition)('and', c, $(this.condition)) : c;
1600
+ }
1601
+ },
1602
+
1603
+ //
1604
+ // An operand is anything that can be part of an operation,
1605
+ // such as a Color, or a Variable
1606
+ //
1607
+ operand: function () {
1608
+ var negate, p = input.charAt(i + 1);
1609
+
1610
+ if (input.charAt(i) === '-' && (p === '@' || p === '(')) { negate = $('-') }
1611
+ var o = $(this.sub) || $(this.entities.dimension) ||
1612
+ $(this.entities.color) || $(this.entities.variable) ||
1613
+ $(this.entities.call);
1614
+ return negate ? new(tree.Operation)('*', [new(tree.Dimension)(-1), o])
1615
+ : o;
1616
+ },
1617
+
1618
+ //
1619
+ // Expressions either represent mathematical operations,
1620
+ // or white-space delimited Entities.
1621
+ //
1622
+ // 1px solid black
1623
+ // @var * 2
1624
+ //
1625
+ expression: function () {
1626
+ var e, delim, entities = [], d;
1627
+
1628
+ while (e = $(this.addition) || $(this.entity)) {
1629
+ entities.push(e);
1630
+ }
1631
+ if (entities.length > 0) {
1632
+ return new(tree.Expression)(entities);
1633
+ }
1634
+ },
1635
+ property: function () {
1636
+ var name;
1637
+
1638
+ if (name = $(/^(\*?-?[_a-z0-9-]+)\s*:/)) {
1639
+ return name[1];
1640
+ }
1641
+ }
1642
+ }
1643
+ };
1644
+ };
1645
+
1646
+ if (less.mode === 'browser' || less.mode === 'rhino') {
1647
+ //
1648
+ // Used by `@import` directives
1649
+ //
1650
+ less.Parser.importer = function (path, paths, callback, env) {
1651
+ if (!/^([a-z-]+:)?\//.test(path) && paths.length > 0) {
1652
+ path = paths[0] + path;
1653
+ }
1654
+ // We pass `true` as 3rd argument, to force the reload of the import.
1655
+ // This is so we can get the syntax tree as opposed to just the CSS output,
1656
+ // as we need this to evaluate the current stylesheet.
1657
+ loadStyleSheet({
1658
+ href: path,
1659
+ title: path,
1660
+ type: env.mime,
1661
+ contents: env.contents,
1662
+ files: env.files,
1663
+ rootpath: env.rootpath,
1664
+ entryPath: env.entryPath,
1665
+ relativeUrls: env.relativeUrls },
1666
+ function (e, root, data, sheet, _, path) {
1667
+ if (e && typeof(env.errback) === "function") {
1668
+ env.errback.call(null, path, paths, callback, env);
1669
+ } else {
1670
+ callback.call(null, e, root, path);
1671
+ }
1672
+ }, true);
1673
+ };
1674
+ }
1675
+
1676
+ (function (tree) {
1677
+
1678
+ tree.functions = {
1679
+ rgb: function (r, g, b) {
1680
+ return this.rgba(r, g, b, 1.0);
1681
+ },
1682
+ rgba: function (r, g, b, a) {
1683
+ var rgb = [r, g, b].map(function (c) { return scaled(c, 256); });
1684
+ a = number(a);
1685
+ return new(tree.Color)(rgb, a);
1686
+ },
1687
+ hsl: function (h, s, l) {
1688
+ return this.hsla(h, s, l, 1.0);
1689
+ },
1690
+ hsla: function (h, s, l, a) {
1691
+ h = (number(h) % 360) / 360;
1692
+ s = number(s); l = number(l); a = number(a);
1693
+
1694
+ var m2 = l <= 0.5 ? l * (s + 1) : l + s - l * s;
1695
+ var m1 = l * 2 - m2;
1696
+
1697
+ return this.rgba(hue(h + 1/3) * 255,
1698
+ hue(h) * 255,
1699
+ hue(h - 1/3) * 255,
1700
+ a);
1701
+
1702
+ function hue(h) {
1703
+ h = h < 0 ? h + 1 : (h > 1 ? h - 1 : h);
1704
+ if (h * 6 < 1) return m1 + (m2 - m1) * h * 6;
1705
+ else if (h * 2 < 1) return m2;
1706
+ else if (h * 3 < 2) return m1 + (m2 - m1) * (2/3 - h) * 6;
1707
+ else return m1;
1708
+ }
1709
+ },
1710
+
1711
+ hsv: function(h, s, v) {
1712
+ return this.hsva(h, s, v, 1.0);
1713
+ },
1714
+
1715
+ hsva: function(h, s, v, a) {
1716
+ h = ((number(h) % 360) / 360) * 360;
1717
+ s = number(s); v = number(v); a = number(a);
1718
+
1719
+ var i, f;
1720
+ i = Math.floor((h / 60) % 6);
1721
+ f = (h / 60) - i;
1722
+
1723
+ var vs = [v,
1724
+ v * (1 - s),
1725
+ v * (1 - f * s),
1726
+ v * (1 - (1 - f) * s)];
1727
+ var perm = [[0, 3, 1],
1728
+ [2, 0, 1],
1729
+ [1, 0, 3],
1730
+ [1, 2, 0],
1731
+ [3, 1, 0],
1732
+ [0, 1, 2]];
1733
+
1734
+ return this.rgba(vs[perm[i][0]] * 255,
1735
+ vs[perm[i][1]] * 255,
1736
+ vs[perm[i][2]] * 255,
1737
+ a);
1738
+ },
1739
+
1740
+ hue: function (color) {
1741
+ return new(tree.Dimension)(Math.round(color.toHSL().h));
1742
+ },
1743
+ saturation: function (color) {
1744
+ return new(tree.Dimension)(Math.round(color.toHSL().s * 100), '%');
1745
+ },
1746
+ lightness: function (color) {
1747
+ return new(tree.Dimension)(Math.round(color.toHSL().l * 100), '%');
1748
+ },
1749
+ red: function (color) {
1750
+ return new(tree.Dimension)(color.rgb[0]);
1751
+ },
1752
+ green: function (color) {
1753
+ return new(tree.Dimension)(color.rgb[1]);
1754
+ },
1755
+ blue: function (color) {
1756
+ return new(tree.Dimension)(color.rgb[2]);
1757
+ },
1758
+ alpha: function (color) {
1759
+ return new(tree.Dimension)(color.toHSL().a);
1760
+ },
1761
+ luma: function (color) {
1762
+ return new(tree.Dimension)(Math.round((0.2126 * (color.rgb[0]/255) +
1763
+ 0.7152 * (color.rgb[1]/255) +
1764
+ 0.0722 * (color.rgb[2]/255)) *
1765
+ color.alpha * 100), '%');
1766
+ },
1767
+ saturate: function (color, amount) {
1768
+ var hsl = color.toHSL();
1769
+
1770
+ hsl.s += amount.value / 100;
1771
+ hsl.s = clamp(hsl.s);
1772
+ return hsla(hsl);
1773
+ },
1774
+ desaturate: function (color, amount) {
1775
+ var hsl = color.toHSL();
1776
+
1777
+ hsl.s -= amount.value / 100;
1778
+ hsl.s = clamp(hsl.s);
1779
+ return hsla(hsl);
1780
+ },
1781
+ lighten: function (color, amount) {
1782
+ var hsl = color.toHSL();
1783
+
1784
+ hsl.l += amount.value / 100;
1785
+ hsl.l = clamp(hsl.l);
1786
+ return hsla(hsl);
1787
+ },
1788
+ darken: function (color, amount) {
1789
+ var hsl = color.toHSL();
1790
+
1791
+ hsl.l -= amount.value / 100;
1792
+ hsl.l = clamp(hsl.l);
1793
+ return hsla(hsl);
1794
+ },
1795
+ fadein: function (color, amount) {
1796
+ var hsl = color.toHSL();
1797
+
1798
+ hsl.a += amount.value / 100;
1799
+ hsl.a = clamp(hsl.a);
1800
+ return hsla(hsl);
1801
+ },
1802
+ fadeout: function (color, amount) {
1803
+ var hsl = color.toHSL();
1804
+
1805
+ hsl.a -= amount.value / 100;
1806
+ hsl.a = clamp(hsl.a);
1807
+ return hsla(hsl);
1808
+ },
1809
+ fade: function (color, amount) {
1810
+ var hsl = color.toHSL();
1811
+
1812
+ hsl.a = amount.value / 100;
1813
+ hsl.a = clamp(hsl.a);
1814
+ return hsla(hsl);
1815
+ },
1816
+ spin: function (color, amount) {
1817
+ var hsl = color.toHSL();
1818
+ var hue = (hsl.h + amount.value) % 360;
1819
+
1820
+ hsl.h = hue < 0 ? 360 + hue : hue;
1821
+
1822
+ return hsla(hsl);
1823
+ },
1824
+ //
1825
+ // Copyright (c) 2006-2009 Hampton Catlin, Nathan Weizenbaum, and Chris Eppstein
1826
+ // http://sass-lang.com
1827
+ //
1828
+ mix: function (color1, color2, weight) {
1829
+ if (!weight) {
1830
+ weight = new(tree.Dimension)(50);
1831
+ }
1832
+ var p = weight.value / 100.0;
1833
+ var w = p * 2 - 1;
1834
+ var a = color1.toHSL().a - color2.toHSL().a;
1835
+
1836
+ var w1 = (((w * a == -1) ? w : (w + a) / (1 + w * a)) + 1) / 2.0;
1837
+ var w2 = 1 - w1;
1838
+
1839
+ var rgb = [color1.rgb[0] * w1 + color2.rgb[0] * w2,
1840
+ color1.rgb[1] * w1 + color2.rgb[1] * w2,
1841
+ color1.rgb[2] * w1 + color2.rgb[2] * w2];
1842
+
1843
+ var alpha = color1.alpha * p + color2.alpha * (1 - p);
1844
+
1845
+ return new(tree.Color)(rgb, alpha);
1846
+ },
1847
+ greyscale: function (color) {
1848
+ return this.desaturate(color, new(tree.Dimension)(100));
1849
+ },
1850
+ contrast: function (color, dark, light, threshold) {
1851
+ // filter: contrast(3.2);
1852
+ // should be kept as is, so check for color
1853
+ if (!color.rgb) {
1854
+ return null;
1855
+ }
1856
+ if (typeof light === 'undefined') {
1857
+ light = this.rgba(255, 255, 255, 1.0);
1858
+ }
1859
+ if (typeof dark === 'undefined') {
1860
+ dark = this.rgba(0, 0, 0, 1.0);
1861
+ }
1862
+ if (typeof threshold === 'undefined') {
1863
+ threshold = 0.43;
1864
+ } else {
1865
+ threshold = threshold.value;
1866
+ }
1867
+ if (((0.2126 * (color.rgb[0]/255) + 0.7152 * (color.rgb[1]/255) + 0.0722 * (color.rgb[2]/255)) * color.alpha) < threshold) {
1868
+ return light;
1869
+ } else {
1870
+ return dark;
1871
+ }
1872
+ },
1873
+ e: function (str) {
1874
+ return new(tree.Anonymous)(str instanceof tree.JavaScript ? str.evaluated : str);
1875
+ },
1876
+ escape: function (str) {
1877
+ 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"));
1878
+ },
1879
+ '%': function (quoted /* arg, arg, ...*/) {
1880
+ var args = Array.prototype.slice.call(arguments, 1),
1881
+ str = quoted.value;
1882
+
1883
+ for (var i = 0; i < args.length; i++) {
1884
+ str = str.replace(/%[sda]/i, function(token) {
1885
+ var value = token.match(/s/i) ? args[i].value : args[i].toCSS();
1886
+ return token.match(/[A-Z]$/) ? encodeURIComponent(value) : value;
1887
+ });
1888
+ }
1889
+ str = str.replace(/%%/g, '%');
1890
+ return new(tree.Quoted)('"' + str + '"', str);
1891
+ },
1892
+ unit: function (val, unit) {
1893
+ return new(tree.Dimension)(val.value, unit ? unit.toCSS() : "");
1894
+ },
1895
+ round: function (n, f) {
1896
+ var fraction = typeof(f) === "undefined" ? 0 : f.value;
1897
+ return this._math(function(num) { return num.toFixed(fraction); }, n);
1898
+ },
1899
+ ceil: function (n) {
1900
+ return this._math(Math.ceil, n);
1901
+ },
1902
+ floor: function (n) {
1903
+ return this._math(Math.floor, n);
1904
+ },
1905
+ _math: function (fn, n) {
1906
+ if (n instanceof tree.Dimension) {
1907
+ return new(tree.Dimension)(fn(parseFloat(n.value)), n.unit);
1908
+ } else if (typeof(n) === 'number') {
1909
+ return fn(n);
1910
+ } else {
1911
+ throw { type: "Argument", message: "argument must be a number" };
1912
+ }
1913
+ },
1914
+ argb: function (color) {
1915
+ return new(tree.Anonymous)(color.toARGB());
1916
+
1917
+ },
1918
+ percentage: function (n) {
1919
+ return new(tree.Dimension)(n.value * 100, '%');
1920
+ },
1921
+ color: function (n) {
1922
+ if (n instanceof tree.Quoted) {
1923
+ return new(tree.Color)(n.value.slice(1));
1924
+ } else {
1925
+ throw { type: "Argument", message: "argument must be a string" };
1926
+ }
1927
+ },
1928
+ iscolor: function (n) {
1929
+ return this._isa(n, tree.Color);
1930
+ },
1931
+ isnumber: function (n) {
1932
+ return this._isa(n, tree.Dimension);
1933
+ },
1934
+ isstring: function (n) {
1935
+ return this._isa(n, tree.Quoted);
1936
+ },
1937
+ iskeyword: function (n) {
1938
+ return this._isa(n, tree.Keyword);
1939
+ },
1940
+ isurl: function (n) {
1941
+ return this._isa(n, tree.URL);
1942
+ },
1943
+ ispixel: function (n) {
1944
+ return (n instanceof tree.Dimension) && n.unit.is('px') ? tree.True : tree.False;
1945
+ },
1946
+ ispercentage: function (n) {
1947
+ return (n instanceof tree.Dimension) && n.unit.is('%') ? tree.True : tree.False;
1948
+ },
1949
+ isem: function (n) {
1950
+ return (n instanceof tree.Dimension) && n.unit.is('em') ? tree.True : tree.False;
1951
+ },
1952
+ _isa: function (n, Type) {
1953
+ return (n instanceof Type) ? tree.True : tree.False;
1954
+ },
1955
+
1956
+ /* Blending modes */
1957
+
1958
+ multiply: function(color1, color2) {
1959
+ var r = color1.rgb[0] * color2.rgb[0] / 255;
1960
+ var g = color1.rgb[1] * color2.rgb[1] / 255;
1961
+ var b = color1.rgb[2] * color2.rgb[2] / 255;
1962
+ return this.rgb(r, g, b);
1963
+ },
1964
+ screen: function(color1, color2) {
1965
+ var r = 255 - (255 - color1.rgb[0]) * (255 - color2.rgb[0]) / 255;
1966
+ var g = 255 - (255 - color1.rgb[1]) * (255 - color2.rgb[1]) / 255;
1967
+ var b = 255 - (255 - color1.rgb[2]) * (255 - color2.rgb[2]) / 255;
1968
+ return this.rgb(r, g, b);
1969
+ },
1970
+ overlay: function(color1, color2) {
1971
+ var r = color1.rgb[0] < 128 ? 2 * color1.rgb[0] * color2.rgb[0] / 255 : 255 - 2 * (255 - color1.rgb[0]) * (255 - color2.rgb[0]) / 255;
1972
+ var g = color1.rgb[1] < 128 ? 2 * color1.rgb[1] * color2.rgb[1] / 255 : 255 - 2 * (255 - color1.rgb[1]) * (255 - color2.rgb[1]) / 255;
1973
+ var b = color1.rgb[2] < 128 ? 2 * color1.rgb[2] * color2.rgb[2] / 255 : 255 - 2 * (255 - color1.rgb[2]) * (255 - color2.rgb[2]) / 255;
1974
+ return this.rgb(r, g, b);
1975
+ },
1976
+ softlight: function(color1, color2) {
1977
+ var t = color2.rgb[0] * color1.rgb[0] / 255;
1978
+ var r = t + color1.rgb[0] * (255 - (255 - color1.rgb[0]) * (255 - color2.rgb[0]) / 255 - t) / 255;
1979
+ t = color2.rgb[1] * color1.rgb[1] / 255;
1980
+ var g = t + color1.rgb[1] * (255 - (255 - color1.rgb[1]) * (255 - color2.rgb[1]) / 255 - t) / 255;
1981
+ t = color2.rgb[2] * color1.rgb[2] / 255;
1982
+ var b = t + color1.rgb[2] * (255 - (255 - color1.rgb[2]) * (255 - color2.rgb[2]) / 255 - t) / 255;
1983
+ return this.rgb(r, g, b);
1984
+ },
1985
+ hardlight: function(color1, color2) {
1986
+ var r = color2.rgb[0] < 128 ? 2 * color2.rgb[0] * color1.rgb[0] / 255 : 255 - 2 * (255 - color2.rgb[0]) * (255 - color1.rgb[0]) / 255;
1987
+ var g = color2.rgb[1] < 128 ? 2 * color2.rgb[1] * color1.rgb[1] / 255 : 255 - 2 * (255 - color2.rgb[1]) * (255 - color1.rgb[1]) / 255;
1988
+ var b = color2.rgb[2] < 128 ? 2 * color2.rgb[2] * color1.rgb[2] / 255 : 255 - 2 * (255 - color2.rgb[2]) * (255 - color1.rgb[2]) / 255;
1989
+ return this.rgb(r, g, b);
1990
+ },
1991
+ difference: function(color1, color2) {
1992
+ var r = Math.abs(color1.rgb[0] - color2.rgb[0]);
1993
+ var g = Math.abs(color1.rgb[1] - color2.rgb[1]);
1994
+ var b = Math.abs(color1.rgb[2] - color2.rgb[2]);
1995
+ return this.rgb(r, g, b);
1996
+ },
1997
+ exclusion: function(color1, color2) {
1998
+ var r = color1.rgb[0] + color2.rgb[0] * (255 - color1.rgb[0] - color1.rgb[0]) / 255;
1999
+ var g = color1.rgb[1] + color2.rgb[1] * (255 - color1.rgb[1] - color1.rgb[1]) / 255;
2000
+ var b = color1.rgb[2] + color2.rgb[2] * (255 - color1.rgb[2] - color1.rgb[2]) / 255;
2001
+ return this.rgb(r, g, b);
2002
+ },
2003
+ average: function(color1, color2) {
2004
+ var r = (color1.rgb[0] + color2.rgb[0]) / 2;
2005
+ var g = (color1.rgb[1] + color2.rgb[1]) / 2;
2006
+ var b = (color1.rgb[2] + color2.rgb[2]) / 2;
2007
+ return this.rgb(r, g, b);
2008
+ },
2009
+ negation: function(color1, color2) {
2010
+ var r = 255 - Math.abs(255 - color2.rgb[0] - color1.rgb[0]);
2011
+ var g = 255 - Math.abs(255 - color2.rgb[1] - color1.rgb[1]);
2012
+ var b = 255 - Math.abs(255 - color2.rgb[2] - color1.rgb[2]);
2013
+ return this.rgb(r, g, b);
2014
+ },
2015
+ tint: function(color, amount) {
2016
+ return this.mix(this.rgb(255,255,255), color, amount);
2017
+ },
2018
+ shade: function(color, amount) {
2019
+ return this.mix(this.rgb(0, 0, 0), color, amount);
2020
+ }
2021
+ };
2022
+
2023
+ function hsla(color) {
2024
+ return tree.functions.hsla(color.h, color.s, color.l, color.a);
2025
+ }
2026
+
2027
+ function scaled(n, size) {
2028
+ if (n instanceof tree.Dimension && n.unit.is('%')) {
2029
+ return parseFloat(n.value * size / 100);
2030
+ } else {
2031
+ return number(n);
2032
+ }
2033
+ }
2034
+
2035
+ function number(n) {
2036
+ if (n instanceof tree.Dimension) {
2037
+ return parseFloat(n.unit.is('%') ? n.value / 100 : n.value);
2038
+ } else if (typeof(n) === 'number') {
2039
+ return n;
2040
+ } else {
2041
+ throw {
2042
+ error: "RuntimeError",
2043
+ message: "color functions take numbers as parameters"
2044
+ };
2045
+ }
2046
+ }
2047
+
2048
+ function clamp(val) {
2049
+ return Math.min(1, Math.max(0, val));
2050
+ }
2051
+
2052
+ })(require('./tree'));
2053
+ (function (tree) {
2054
+ tree.colors = {
2055
+ 'aliceblue':'#f0f8ff',
2056
+ 'antiquewhite':'#faebd7',
2057
+ 'aqua':'#00ffff',
2058
+ 'aquamarine':'#7fffd4',
2059
+ 'azure':'#f0ffff',
2060
+ 'beige':'#f5f5dc',
2061
+ 'bisque':'#ffe4c4',
2062
+ 'black':'#000000',
2063
+ 'blanchedalmond':'#ffebcd',
2064
+ 'blue':'#0000ff',
2065
+ 'blueviolet':'#8a2be2',
2066
+ 'brown':'#a52a2a',
2067
+ 'burlywood':'#deb887',
2068
+ 'cadetblue':'#5f9ea0',
2069
+ 'chartreuse':'#7fff00',
2070
+ 'chocolate':'#d2691e',
2071
+ 'coral':'#ff7f50',
2072
+ 'cornflowerblue':'#6495ed',
2073
+ 'cornsilk':'#fff8dc',
2074
+ 'crimson':'#dc143c',
2075
+ 'cyan':'#00ffff',
2076
+ 'darkblue':'#00008b',
2077
+ 'darkcyan':'#008b8b',
2078
+ 'darkgoldenrod':'#b8860b',
2079
+ 'darkgray':'#a9a9a9',
2080
+ 'darkgrey':'#a9a9a9',
2081
+ 'darkgreen':'#006400',
2082
+ 'darkkhaki':'#bdb76b',
2083
+ 'darkmagenta':'#8b008b',
2084
+ 'darkolivegreen':'#556b2f',
2085
+ 'darkorange':'#ff8c00',
2086
+ 'darkorchid':'#9932cc',
2087
+ 'darkred':'#8b0000',
2088
+ 'darksalmon':'#e9967a',
2089
+ 'darkseagreen':'#8fbc8f',
2090
+ 'darkslateblue':'#483d8b',
2091
+ 'darkslategray':'#2f4f4f',
2092
+ 'darkslategrey':'#2f4f4f',
2093
+ 'darkturquoise':'#00ced1',
2094
+ 'darkviolet':'#9400d3',
2095
+ 'deeppink':'#ff1493',
2096
+ 'deepskyblue':'#00bfff',
2097
+ 'dimgray':'#696969',
2098
+ 'dimgrey':'#696969',
2099
+ 'dodgerblue':'#1e90ff',
2100
+ 'firebrick':'#b22222',
2101
+ 'floralwhite':'#fffaf0',
2102
+ 'forestgreen':'#228b22',
2103
+ 'fuchsia':'#ff00ff',
2104
+ 'gainsboro':'#dcdcdc',
2105
+ 'ghostwhite':'#f8f8ff',
2106
+ 'gold':'#ffd700',
2107
+ 'goldenrod':'#daa520',
2108
+ 'gray':'#808080',
2109
+ 'grey':'#808080',
2110
+ 'green':'#008000',
2111
+ 'greenyellow':'#adff2f',
2112
+ 'honeydew':'#f0fff0',
2113
+ 'hotpink':'#ff69b4',
2114
+ 'indianred':'#cd5c5c',
2115
+ 'indigo':'#4b0082',
2116
+ 'ivory':'#fffff0',
2117
+ 'khaki':'#f0e68c',
2118
+ 'lavender':'#e6e6fa',
2119
+ 'lavenderblush':'#fff0f5',
2120
+ 'lawngreen':'#7cfc00',
2121
+ 'lemonchiffon':'#fffacd',
2122
+ 'lightblue':'#add8e6',
2123
+ 'lightcoral':'#f08080',
2124
+ 'lightcyan':'#e0ffff',
2125
+ 'lightgoldenrodyellow':'#fafad2',
2126
+ 'lightgray':'#d3d3d3',
2127
+ 'lightgrey':'#d3d3d3',
2128
+ 'lightgreen':'#90ee90',
2129
+ 'lightpink':'#ffb6c1',
2130
+ 'lightsalmon':'#ffa07a',
2131
+ 'lightseagreen':'#20b2aa',
2132
+ 'lightskyblue':'#87cefa',
2133
+ 'lightslategray':'#778899',
2134
+ 'lightslategrey':'#778899',
2135
+ 'lightsteelblue':'#b0c4de',
2136
+ 'lightyellow':'#ffffe0',
2137
+ 'lime':'#00ff00',
2138
+ 'limegreen':'#32cd32',
2139
+ 'linen':'#faf0e6',
2140
+ 'magenta':'#ff00ff',
2141
+ 'maroon':'#800000',
2142
+ 'mediumaquamarine':'#66cdaa',
2143
+ 'mediumblue':'#0000cd',
2144
+ 'mediumorchid':'#ba55d3',
2145
+ 'mediumpurple':'#9370d8',
2146
+ 'mediumseagreen':'#3cb371',
2147
+ 'mediumslateblue':'#7b68ee',
2148
+ 'mediumspringgreen':'#00fa9a',
2149
+ 'mediumturquoise':'#48d1cc',
2150
+ 'mediumvioletred':'#c71585',
2151
+ 'midnightblue':'#191970',
2152
+ 'mintcream':'#f5fffa',
2153
+ 'mistyrose':'#ffe4e1',
2154
+ 'moccasin':'#ffe4b5',
2155
+ 'navajowhite':'#ffdead',
2156
+ 'navy':'#000080',
2157
+ 'oldlace':'#fdf5e6',
2158
+ 'olive':'#808000',
2159
+ 'olivedrab':'#6b8e23',
2160
+ 'orange':'#ffa500',
2161
+ 'orangered':'#ff4500',
2162
+ 'orchid':'#da70d6',
2163
+ 'palegoldenrod':'#eee8aa',
2164
+ 'palegreen':'#98fb98',
2165
+ 'paleturquoise':'#afeeee',
2166
+ 'palevioletred':'#d87093',
2167
+ 'papayawhip':'#ffefd5',
2168
+ 'peachpuff':'#ffdab9',
2169
+ 'peru':'#cd853f',
2170
+ 'pink':'#ffc0cb',
2171
+ 'plum':'#dda0dd',
2172
+ 'powderblue':'#b0e0e6',
2173
+ 'purple':'#800080',
2174
+ 'red':'#ff0000',
2175
+ 'rosybrown':'#bc8f8f',
2176
+ 'royalblue':'#4169e1',
2177
+ 'saddlebrown':'#8b4513',
2178
+ 'salmon':'#fa8072',
2179
+ 'sandybrown':'#f4a460',
2180
+ 'seagreen':'#2e8b57',
2181
+ 'seashell':'#fff5ee',
2182
+ 'sienna':'#a0522d',
2183
+ 'silver':'#c0c0c0',
2184
+ 'skyblue':'#87ceeb',
2185
+ 'slateblue':'#6a5acd',
2186
+ 'slategray':'#708090',
2187
+ 'slategrey':'#708090',
2188
+ 'snow':'#fffafa',
2189
+ 'springgreen':'#00ff7f',
2190
+ 'steelblue':'#4682b4',
2191
+ 'tan':'#d2b48c',
2192
+ 'teal':'#008080',
2193
+ 'thistle':'#d8bfd8',
2194
+ 'tomato':'#ff6347',
2195
+ // 'transparent':'rgba(0,0,0,0)',
2196
+ 'turquoise':'#40e0d0',
2197
+ 'violet':'#ee82ee',
2198
+ 'wheat':'#f5deb3',
2199
+ 'white':'#ffffff',
2200
+ 'whitesmoke':'#f5f5f5',
2201
+ 'yellow':'#ffff00',
2202
+ 'yellowgreen':'#9acd32'
2203
+ };
2204
+ })(require('./tree'));
2205
+ (function (tree) {
2206
+
2207
+ tree.Alpha = function (val) {
2208
+ this.value = val;
2209
+ };
2210
+ tree.Alpha.prototype = {
2211
+ toCSS: function () {
2212
+ return "alpha(opacity=" +
2213
+ (this.value.toCSS ? this.value.toCSS() : this.value) + ")";
2214
+ },
2215
+ eval: function (env) {
2216
+ if (this.value.eval) { this.value = this.value.eval(env) }
2217
+ return this;
2218
+ }
2219
+ };
2220
+
2221
+ })(require('../tree'));
2222
+ (function (tree) {
2223
+
2224
+ tree.Anonymous = function (string) {
2225
+ this.value = string.value || string;
2226
+ };
2227
+ tree.Anonymous.prototype = {
2228
+ toCSS: function () {
2229
+ return this.value;
2230
+ },
2231
+ eval: function () { return this },
2232
+ compare: function (x) {
2233
+ if (!x.toCSS) {
2234
+ return -1;
2235
+ }
2236
+
2237
+ var left = this.toCSS(),
2238
+ right = x.toCSS();
2239
+
2240
+ if (left === right) {
2241
+ return 0;
2242
+ }
2243
+
2244
+ return left < right ? -1 : 1;
2245
+ }
2246
+ };
2247
+
2248
+ })(require('../tree'));
2249
+ (function (tree) {
2250
+
2251
+ tree.Assignment = function (key, val) {
2252
+ this.key = key;
2253
+ this.value = val;
2254
+ };
2255
+ tree.Assignment.prototype = {
2256
+ toCSS: function () {
2257
+ return this.key + '=' + (this.value.toCSS ? this.value.toCSS() : this.value);
2258
+ },
2259
+ eval: function (env) {
2260
+ if (this.value.eval) {
2261
+ return new(tree.Assignment)(this.key, this.value.eval(env));
2262
+ }
2263
+ return this;
2264
+ }
2265
+ };
2266
+
2267
+ })(require('../tree'));(function (tree) {
2268
+
2269
+ //
2270
+ // A function call node.
2271
+ //
2272
+ tree.Call = function (name, args, index, filename) {
2273
+ this.name = name;
2274
+ this.args = args;
2275
+ this.index = index;
2276
+ this.filename = filename;
2277
+ };
2278
+ tree.Call.prototype = {
2279
+ //
2280
+ // When evaluating a function call,
2281
+ // we either find the function in `tree.functions` [1],
2282
+ // in which case we call it, passing the evaluated arguments,
2283
+ // if this returns null or we cannot find the function, we
2284
+ // simply print it out as it appeared originally [2].
2285
+ //
2286
+ // The *functions.js* file contains the built-in functions.
2287
+ //
2288
+ // The reason why we evaluate the arguments, is in the case where
2289
+ // we try to pass a variable to a function, like: `saturate(@color)`.
2290
+ // The function should receive the value, not the variable.
2291
+ //
2292
+ eval: function (env) {
2293
+ var args = this.args.map(function (a) { return a.eval(env) }),
2294
+ result;
2295
+
2296
+ if (this.name in tree.functions) { // 1.
2297
+ try {
2298
+ result = tree.functions[this.name].apply(tree.functions, args);
2299
+ if (result != null) {
2300
+ return result;
2301
+ }
2302
+ } catch (e) {
2303
+ throw { type: e.type || "Runtime",
2304
+ message: "error evaluating function `" + this.name + "`" +
2305
+ (e.message ? ': ' + e.message : ''),
2306
+ index: this.index, filename: this.filename };
2307
+ }
2308
+ }
2309
+
2310
+ // 2.
2311
+ return new(tree.Anonymous)(this.name +
2312
+ "(" + args.map(function (a) { return a.toCSS(env) }).join(', ') + ")");
2313
+ },
2314
+
2315
+ toCSS: function (env) {
2316
+ return this.eval(env).toCSS();
2317
+ }
2318
+ };
2319
+
2320
+ })(require('../tree'));
2321
+ (function (tree) {
2322
+ //
2323
+ // RGB Colors - #ff0014, #eee
2324
+ //
2325
+ tree.Color = function (rgb, a) {
2326
+ //
2327
+ // The end goal here, is to parse the arguments
2328
+ // into an integer triplet, such as `128, 255, 0`
2329
+ //
2330
+ // This facilitates operations and conversions.
2331
+ //
2332
+ if (Array.isArray(rgb)) {
2333
+ this.rgb = rgb;
2334
+ } else if (rgb.length == 6) {
2335
+ this.rgb = rgb.match(/.{2}/g).map(function (c) {
2336
+ return parseInt(c, 16);
2337
+ });
2338
+ } else {
2339
+ this.rgb = rgb.split('').map(function (c) {
2340
+ return parseInt(c + c, 16);
2341
+ });
2342
+ }
2343
+ this.alpha = typeof(a) === 'number' ? a : 1;
2344
+ };
2345
+ tree.Color.prototype = {
2346
+ eval: function () { return this },
2347
+
2348
+ //
2349
+ // If we have some transparency, the only way to represent it
2350
+ // is via `rgba`. Otherwise, we use the hex representation,
2351
+ // which has better compatibility with older browsers.
2352
+ // Values are capped between `0` and `255`, rounded and zero-padded.
2353
+ //
2354
+ toCSS: function () {
2355
+ if (this.alpha < 1.0) {
2356
+ return "rgba(" + this.rgb.map(function (c) {
2357
+ return Math.round(c);
2358
+ }).concat(this.alpha).join(', ') + ")";
2359
+ } else {
2360
+ return '#' + this.rgb.map(function (i) {
2361
+ i = Math.round(i);
2362
+ i = (i > 255 ? 255 : (i < 0 ? 0 : i)).toString(16);
2363
+ return i.length === 1 ? '0' + i : i;
2364
+ }).join('');
2365
+ }
2366
+ },
2367
+
2368
+ //
2369
+ // Operations have to be done per-channel, if not,
2370
+ // channels will spill onto each other. Once we have
2371
+ // our result, in the form of an integer triplet,
2372
+ // we create a new Color node to hold the result.
2373
+ //
2374
+ operate: function (op, other) {
2375
+ var result = [];
2376
+
2377
+ if (! (other instanceof tree.Color)) {
2378
+ other = other.toColor();
2379
+ }
2380
+
2381
+ for (var c = 0; c < 3; c++) {
2382
+ result[c] = tree.operate(op, this.rgb[c], other.rgb[c]);
2383
+ }
2384
+ return new(tree.Color)(result, this.alpha + other.alpha);
2385
+ },
2386
+
2387
+ toHSL: function () {
2388
+ var r = this.rgb[0] / 255,
2389
+ g = this.rgb[1] / 255,
2390
+ b = this.rgb[2] / 255,
2391
+ a = this.alpha;
2392
+
2393
+ var max = Math.max(r, g, b), min = Math.min(r, g, b);
2394
+ var h, s, l = (max + min) / 2, d = max - min;
2395
+
2396
+ if (max === min) {
2397
+ h = s = 0;
2398
+ } else {
2399
+ s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
2400
+
2401
+ switch (max) {
2402
+ case r: h = (g - b) / d + (g < b ? 6 : 0); break;
2403
+ case g: h = (b - r) / d + 2; break;
2404
+ case b: h = (r - g) / d + 4; break;
2405
+ }
2406
+ h /= 6;
2407
+ }
2408
+ return { h: h * 360, s: s, l: l, a: a };
2409
+ },
2410
+ toARGB: function () {
2411
+ var argb = [Math.round(this.alpha * 255)].concat(this.rgb);
2412
+ return '#' + argb.map(function (i) {
2413
+ i = Math.round(i);
2414
+ i = (i > 255 ? 255 : (i < 0 ? 0 : i)).toString(16);
2415
+ return i.length === 1 ? '0' + i : i;
2416
+ }).join('');
2417
+ },
2418
+ compare: function (x) {
2419
+ if (!x.rgb) {
2420
+ return -1;
2421
+ }
2422
+
2423
+ return (x.rgb[0] === this.rgb[0] &&
2424
+ x.rgb[1] === this.rgb[1] &&
2425
+ x.rgb[2] === this.rgb[2] &&
2426
+ x.alpha === this.alpha) ? 0 : -1;
2427
+ }
2428
+ };
2429
+
2430
+
2431
+ })(require('../tree'));
2432
+ (function (tree) {
2433
+
2434
+ tree.Comment = function (value, silent) {
2435
+ this.value = value;
2436
+ this.silent = !!silent;
2437
+ };
2438
+ tree.Comment.prototype = {
2439
+ toCSS: function (env) {
2440
+ return env.compress ? '' : this.value;
2441
+ },
2442
+ eval: function () { return this }
2443
+ };
2444
+
2445
+ })(require('../tree'));
2446
+ (function (tree) {
2447
+
2448
+ tree.Condition = function (op, l, r, i, negate) {
2449
+ this.op = op.trim();
2450
+ this.lvalue = l;
2451
+ this.rvalue = r;
2452
+ this.index = i;
2453
+ this.negate = negate;
2454
+ };
2455
+ tree.Condition.prototype.eval = function (env) {
2456
+ var a = this.lvalue.eval(env),
2457
+ b = this.rvalue.eval(env);
2458
+
2459
+ var i = this.index, result;
2460
+
2461
+ var result = (function (op) {
2462
+ switch (op) {
2463
+ case 'and':
2464
+ return a && b;
2465
+ case 'or':
2466
+ return a || b;
2467
+ default:
2468
+ if (a.compare) {
2469
+ result = a.compare(b);
2470
+ } else if (b.compare) {
2471
+ result = b.compare(a);
2472
+ } else {
2473
+ throw { type: "Type",
2474
+ message: "Unable to perform comparison",
2475
+ index: i };
2476
+ }
2477
+ switch (result) {
2478
+ case -1: return op === '<' || op === '=<';
2479
+ case 0: return op === '=' || op === '>=' || op === '=<';
2480
+ case 1: return op === '>' || op === '>=';
2481
+ }
2482
+ }
2483
+ })(this.op);
2484
+ return this.negate ? !result : result;
2485
+ };
2486
+
2487
+ })(require('../tree'));
2488
+ (function (tree) {
2489
+
2490
+ //
2491
+ // A number with a unit
2492
+ //
2493
+ tree.Dimension = function (value, unit) {
2494
+ this.value = parseFloat(value);
2495
+ this.unit = (unit && unit instanceof tree.Unit) ? unit :
2496
+ new(tree.Unit)(unit ? [unit] : undefined);
2497
+ };
2498
+
2499
+ tree.Dimension.prototype = {
2500
+ eval: function () { return this },
2501
+ toColor: function () {
2502
+ return new(tree.Color)([this.value, this.value, this.value]);
2503
+ },
2504
+ toCSS: function () {
2505
+ return this.unit.isEmpty() ? this.value :
2506
+ (String(this.value) + this.unit.toCSS());
2507
+ },
2508
+
2509
+ // In an operation between two Dimensions,
2510
+ // we default to the first Dimension's unit,
2511
+ // so `1px + 2` will yield `3px`.
2512
+ operate: function (op, other) {
2513
+ var value = tree.operate(op, this.value, other.value),
2514
+ unit = this.unit.clone();
2515
+
2516
+ if (op === '+' || op === '-') {
2517
+ if (unit.numerator.length === 0 && unit.denominator.length === 0) {
2518
+ unit.numerator = other.unit.numerator.slice(0);
2519
+ unit.denominator = other.unit.denominator.slice(0);
2520
+ } else if (other.unit.numerator.length == 0 && unit.denominator.length == 0) {
2521
+ // do nothing
2522
+ } else {
2523
+ other = other.convertTo(this.unit.usedUnits());
2524
+
2525
+ if(other.unit.toCSS() !== unit.toCSS()) {
2526
+ throw new Error("Incompatible units: '" + unit.toCSS() +
2527
+ "' and '" + other.unit.toCSS() + "'.");
2528
+ }
2529
+
2530
+ value = tree.operate(op, this.value, other.value);
2531
+ }
2532
+ } else if (op === '*') {
2533
+ unit.numerator = unit.numerator.concat(other.unit.numerator).sort();
2534
+ unit.denominator = unit.denominator.concat(other.unit.denominator).sort();
2535
+ unit.cancel();
2536
+ } else if (op === '/') {
2537
+ unit.numerator = unit.numerator.concat(other.unit.denominator).sort();
2538
+ unit.denominator = unit.denominator.concat(other.unit.numerator).sort();
2539
+ unit.cancel();
2540
+ }
2541
+ return new(tree.Dimension)(value, unit);
2542
+ },
2543
+
2544
+ compare: function (other) {
2545
+ if (other instanceof tree.Dimension) {
2546
+ var a = this.unify(), b = other.unify(),
2547
+ aValue = a.value, bValue = b.value;
2548
+
2549
+ if (bValue > aValue) {
2550
+ return -1;
2551
+ } else if (bValue < aValue) {
2552
+ return 1;
2553
+ } else {
2554
+ if (!b.unit.isEmpty() && a.unit.compare(b) !== 0) {
2555
+ return -1;
2556
+ }
2557
+ return 0;
2558
+ }
2559
+ } else {
2560
+ return -1;
2561
+ }
2562
+ },
2563
+
2564
+ unify: function () {
2565
+ return this.convertTo({ length: 'm', duration: 's' });
2566
+ },
2567
+
2568
+ convertTo: function (conversions) {
2569
+ var value = this.value, unit = this.unit.clone(),
2570
+ i, groupName, group, conversion, targetUnit;
2571
+
2572
+ for (groupName in conversions) {
2573
+ if (conversions.hasOwnProperty(groupName)) {
2574
+ targetUnit = conversions[groupName];
2575
+ group = tree.UnitConversions[groupName];
2576
+
2577
+ unit.map(function (atomicUnit, denominator) {
2578
+ if (group.hasOwnProperty(atomicUnit)) {
2579
+ if (denominator) {
2580
+ value = value / (group[atomicUnit] / group[targetUnit]);
2581
+ } else {
2582
+ value = value * (group[atomicUnit] / group[targetUnit]);
2583
+ }
2584
+
2585
+ return targetUnit;
2586
+ }
2587
+
2588
+ return atomicUnit;
2589
+ });
2590
+ }
2591
+ }
2592
+
2593
+ unit.cancel();
2594
+
2595
+ return new(tree.Dimension)(value, unit);
2596
+ }
2597
+ };
2598
+
2599
+ // http://www.w3.org/TR/css3-values/#absolute-lengths
2600
+ tree.UnitConversions = {
2601
+ length: {
2602
+ 'm': 1,
2603
+ 'cm': 0.01,
2604
+ 'mm': 0.001,
2605
+ 'in': 0.0254,
2606
+ 'pt': 0.0254 / 72,
2607
+ 'pc': 0.0254 / 72 * 12
2608
+ },
2609
+ duration: {
2610
+ 's': 1,
2611
+ 'ms': 0.001
2612
+ }
2613
+ };
2614
+
2615
+ tree.Unit = function (numerator, denominator) {
2616
+ this.numerator = numerator ? numerator.slice(0).sort() : [];
2617
+ this.denominator = denominator ? denominator.slice(0).sort() : [];
2618
+ };
2619
+
2620
+ tree.Unit.prototype = {
2621
+ clone: function () {
2622
+ return new tree.Unit(this.numerator.slice(0), this.denominator.slice(0));
2623
+ },
2624
+
2625
+ toCSS: function () {
2626
+ var i, css = this.numerator.join("*");
2627
+ for (i = 0; i < this.denominator.length; i++) {
2628
+ css += "/" + this.denominator[i];
2629
+ }
2630
+ return css;
2631
+ },
2632
+
2633
+ compare: function (other) {
2634
+ return this.is(other.toCSS()) ? 0 : -1;
2635
+ },
2636
+
2637
+ is: function (unitString) {
2638
+ return this.toCSS() === unitString;
2639
+ },
2640
+
2641
+ isEmpty: function () {
2642
+ return this.numerator.length == 0 && this.denominator.length == 0;
2643
+ },
2644
+
2645
+ map: function(callback) {
2646
+ var i;
2647
+
2648
+ for (i = 0; i < this.numerator.length; i++) {
2649
+ this.numerator[i] = callback(this.numerator[i], false);
2650
+ }
2651
+
2652
+ for (i = 0; i < this.denominator.length; i++) {
2653
+ this.denominator[i] = callback(this.denominator[i], true);
2654
+ }
2655
+ },
2656
+
2657
+ usedUnits: function() {
2658
+ var group, groupName, result = {};
2659
+
2660
+ for (groupName in tree.UnitConversions) {
2661
+ if (tree.UnitConversions.hasOwnProperty(groupName)) {
2662
+ group = tree.UnitConversions[groupName];
2663
+
2664
+ this.map(function (atomicUnit) {
2665
+ if (group.hasOwnProperty(atomicUnit) && !result[groupName]) {
2666
+ result[groupName] = atomicUnit;
2667
+ }
2668
+
2669
+ return atomicUnit;
2670
+ });
2671
+ }
2672
+ }
2673
+
2674
+ return result;
2675
+ },
2676
+
2677
+ cancel: function () {
2678
+ var counter = {}, atomicUnit, i;
2679
+
2680
+ for (i = 0; i < this.numerator.length; i++) {
2681
+ atomicUnit = this.numerator[i];
2682
+ counter[atomicUnit] = (counter[atomicUnit] || 0) + 1;
2683
+ }
2684
+
2685
+ for (i = 0; i < this.denominator.length; i++) {
2686
+ atomicUnit = this.denominator[i];
2687
+ counter[atomicUnit] = (counter[atomicUnit] || 0) - 1;
2688
+ }
2689
+
2690
+ this.numerator = [];
2691
+ this.denominator = [];
2692
+
2693
+ for (atomicUnit in counter) {
2694
+ if (counter.hasOwnProperty(atomicUnit)) {
2695
+ var count = counter[atomicUnit];
2696
+
2697
+ if (count > 0) {
2698
+ for (i = 0; i < count; i++) {
2699
+ this.numerator.push(atomicUnit);
2700
+ }
2701
+ } else if (count < 0) {
2702
+ for (i = 0; i < -count; i++) {
2703
+ this.denominator.push(atomicUnit);
2704
+ }
2705
+ }
2706
+ }
2707
+ }
2708
+
2709
+ this.numerator.sort();
2710
+ this.denominator.sort();
2711
+ }
2712
+ };
2713
+
2714
+ })(require('../tree'));
2715
+ (function (tree) {
2716
+
2717
+ tree.Directive = function (name, value) {
2718
+ this.name = name;
2719
+
2720
+ if (Array.isArray(value)) {
2721
+ this.ruleset = new(tree.Ruleset)([], value);
2722
+ this.ruleset.allowImports = true;
2723
+ } else {
2724
+ this.value = value;
2725
+ }
2726
+ };
2727
+ tree.Directive.prototype = {
2728
+ toCSS: function (ctx, env) {
2729
+ if (this.ruleset) {
2730
+ this.ruleset.root = true;
2731
+ return this.name + (env.compress ? '{' : ' {\n ') +
2732
+ this.ruleset.toCSS(ctx, env).trim().replace(/\n/g, '\n ') +
2733
+ (env.compress ? '}': '\n}\n');
2734
+ } else {
2735
+ return this.name + ' ' + this.value.toCSS() + ';\n';
2736
+ }
2737
+ },
2738
+ eval: function (env) {
2739
+ var evaldDirective = this;
2740
+ if (this.ruleset) {
2741
+ env.frames.unshift(this);
2742
+ evaldDirective = new(tree.Directive)(this.name);
2743
+ evaldDirective.ruleset = this.ruleset.eval(env);
2744
+ env.frames.shift();
2745
+ }
2746
+ return evaldDirective;
2747
+ },
2748
+ variable: function (name) { return tree.Ruleset.prototype.variable.call(this.ruleset, name) },
2749
+ find: function () { return tree.Ruleset.prototype.find.apply(this.ruleset, arguments) },
2750
+ rulesets: function () { return tree.Ruleset.prototype.rulesets.apply(this.ruleset) }
2751
+ };
2752
+
2753
+ })(require('../tree'));
2754
+ (function (tree) {
2755
+
2756
+ tree.Element = function (combinator, value, index) {
2757
+ this.combinator = combinator instanceof tree.Combinator ?
2758
+ combinator : new(tree.Combinator)(combinator);
2759
+
2760
+ if (typeof(value) === 'string') {
2761
+ this.value = value.trim();
2762
+ } else if (value) {
2763
+ this.value = value;
2764
+ } else {
2765
+ this.value = "";
2766
+ }
2767
+ this.index = index;
2768
+ };
2769
+ tree.Element.prototype.eval = function (env) {
2770
+ return new(tree.Element)(this.combinator,
2771
+ this.value.eval ? this.value.eval(env) : this.value,
2772
+ this.index);
2773
+ };
2774
+ tree.Element.prototype.toCSS = function (env) {
2775
+ var value = (this.value.toCSS ? this.value.toCSS(env) : this.value);
2776
+ if (value == '' && this.combinator.value.charAt(0) == '&') {
2777
+ return '';
2778
+ } else {
2779
+ return this.combinator.toCSS(env || {}) + value;
2780
+ }
2781
+ };
2782
+
2783
+ tree.Combinator = function (value) {
2784
+ if (value === ' ') {
2785
+ this.value = ' ';
2786
+ } else {
2787
+ this.value = value ? value.trim() : "";
2788
+ }
2789
+ };
2790
+ tree.Combinator.prototype.toCSS = function (env) {
2791
+ return {
2792
+ '' : '',
2793
+ ' ' : ' ',
2794
+ ':' : ' :',
2795
+ '+' : env.compress ? '+' : ' + ',
2796
+ '~' : env.compress ? '~' : ' ~ ',
2797
+ '>' : env.compress ? '>' : ' > ',
2798
+ '|' : env.compress ? '|' : ' | '
2799
+ }[this.value];
2800
+ };
2801
+
2802
+ })(require('../tree'));
2803
+ (function (tree) {
2804
+
2805
+ tree.Expression = function (value) { this.value = value };
2806
+ tree.Expression.prototype = {
2807
+ eval: function (env) {
2808
+ if (this.value.length > 1) {
2809
+ return new(tree.Expression)(this.value.map(function (e) {
2810
+ return e.eval(env);
2811
+ }));
2812
+ } else if (this.value.length === 1) {
2813
+ return this.value[0].eval(env);
2814
+ } else {
2815
+ return this;
2816
+ }
2817
+ },
2818
+ toCSS: function (env) {
2819
+ return this.value.map(function (e) {
2820
+ return e.toCSS ? e.toCSS(env) : '';
2821
+ }).join(' ');
2822
+ }
2823
+ };
2824
+
2825
+ })(require('../tree'));
2826
+ (function (tree) {
2827
+
2828
+ tree.Extend = function Extend(elements, index) {
2829
+ this.selector = new(tree.Selector)(elements);
2830
+ this.index = index;
2831
+ };
2832
+
2833
+ tree.Extend.prototype.eval = function Extend_eval(env, selectors) {
2834
+ var selfSelectors = findSelfSelectors(selectors || env.selectors),
2835
+ targetValue = this.selector.elements[0].value;
2836
+
2837
+ env.frames.forEach(function(frame) {
2838
+ frame.rulesets().forEach(function(rule) {
2839
+ rule.selectors.forEach(function(selector) {
2840
+ selector.elements.forEach(function(element, idx) {
2841
+ if (element.value === targetValue) {
2842
+ selfSelectors.forEach(function(_selector) {
2843
+ _selector.elements[0] = new tree.Element(
2844
+ element.combinator,
2845
+ _selector.elements[0].value,
2846
+ _selector.elements[0].index
2847
+ );
2848
+ rule.selectors.push(new tree.Selector(
2849
+ selector.elements
2850
+ .slice(0, idx)
2851
+ .concat(_selector.elements)
2852
+ .concat(selector.elements.slice(idx + 1))
2853
+ ));
2854
+ });
2855
+ }
2856
+ });
2857
+ });
2858
+ });
2859
+ });
2860
+ return this;
2861
+ };
2862
+
2863
+ function findSelfSelectors(selectors) {
2864
+ var ret = [];
2865
+
2866
+ (function loop(elem, i) {
2867
+ if (selectors[i] && selectors[i].length) {
2868
+ selectors[i].forEach(function(s) {
2869
+ loop(s.elements.concat(elem), i + 1);
2870
+ });
2871
+ }
2872
+ else {
2873
+ ret.push({ elements: elem });
2874
+ }
2875
+ })([], 0);
2876
+
2877
+ return ret;
2878
+ }
2879
+
2880
+
2881
+ })(require('../tree'));
2882
+ (function (tree) {
2883
+ //
2884
+ // CSS @import node
2885
+ //
2886
+ // The general strategy here is that we don't want to wait
2887
+ // for the parsing to be completed, before we start importing
2888
+ // the file. That's because in the context of a browser,
2889
+ // most of the time will be spent waiting for the server to respond.
2890
+ //
2891
+ // On creation, we push the import path to our import queue, though
2892
+ // `import,push`, we also pass it a callback, which it'll call once
2893
+ // the file has been fetched, and parsed.
2894
+ //
2895
+ tree.Import = function (path, imports, features, once, index, rootpath) {
2896
+ var that = this;
2897
+
2898
+ this.once = once;
2899
+ this.index = index;
2900
+ this._path = path;
2901
+ this.features = features && new(tree.Value)(features);
2902
+ this.rootpath = rootpath;
2903
+
2904
+ // The '.less' extension is optional
2905
+ if (path instanceof tree.Quoted) {
2906
+ this.path = /(\.[a-z]*$)|([\?;].*)$/.test(path.value) ? path.value : path.value + '.less';
2907
+ } else {
2908
+ this.path = path.value.value || path.value;
2909
+ }
2910
+
2911
+ this.css = /css([\?;].*)?$/.test(this.path);
2912
+
2913
+ // Only pre-compile .less files
2914
+ if (! this.css) {
2915
+ imports.push(this.path, function (e, root, imported) {
2916
+ if (e) { e.index = index }
2917
+ if (imported && that.once) that.skip = imported;
2918
+ that.root = root || new(tree.Ruleset)([], []);
2919
+ });
2920
+ }
2921
+ };
2922
+
2923
+ //
2924
+ // The actual import node doesn't return anything, when converted to CSS.
2925
+ // The reason is that it's used at the evaluation stage, so that the rules
2926
+ // it imports can be treated like any other rules.
2927
+ //
2928
+ // In `eval`, we make sure all Import nodes get evaluated, recursively, so
2929
+ // we end up with a flat structure, which can easily be imported in the parent
2930
+ // ruleset.
2931
+ //
2932
+ tree.Import.prototype = {
2933
+ toCSS: function (env) {
2934
+ var features = this.features ? ' ' + this.features.toCSS(env) : '';
2935
+
2936
+ if (this.css) {
2937
+ // Add the base path if the import is relative
2938
+ if (typeof this._path.value === "string" && !/^(?:[a-z-]+:|\/)/.test(this._path.value)) {
2939
+ this._path.value = this.rootpath + this._path.value;
2940
+ }
2941
+ return "@import " + this._path.toCSS() + features + ';\n';
2942
+ } else {
2943
+ return "";
2944
+ }
2945
+ },
2946
+ eval: function (env) {
2947
+ var ruleset, features = this.features && this.features.eval(env);
2948
+
2949
+ if (this.skip) return [];
2950
+
2951
+ if (this.css) {
2952
+ return this;
2953
+ } else {
2954
+ ruleset = new(tree.Ruleset)([], this.root.rules.slice(0));
2955
+
2956
+ ruleset.evalImports(env);
2957
+
2958
+ return this.features ? new(tree.Media)(ruleset.rules, this.features.value) : ruleset.rules;
2959
+ }
2960
+ }
2961
+ };
2962
+
2963
+ })(require('../tree'));
2964
+ (function (tree) {
2965
+
2966
+ tree.JavaScript = function (string, index, escaped) {
2967
+ this.escaped = escaped;
2968
+ this.expression = string;
2969
+ this.index = index;
2970
+ };
2971
+ tree.JavaScript.prototype = {
2972
+ eval: function (env) {
2973
+ var result,
2974
+ that = this,
2975
+ context = {};
2976
+
2977
+ var expression = this.expression.replace(/@\{([\w-]+)\}/g, function (_, name) {
2978
+ return tree.jsify(new(tree.Variable)('@' + name, that.index).eval(env));
2979
+ });
2980
+
2981
+ try {
2982
+ expression = new(Function)('return (' + expression + ')');
2983
+ } catch (e) {
2984
+ throw { message: "JavaScript evaluation error: `" + expression + "`" ,
2985
+ index: this.index };
2986
+ }
2987
+
2988
+ for (var k in env.frames[0].variables()) {
2989
+ context[k.slice(1)] = {
2990
+ value: env.frames[0].variables()[k].value,
2991
+ toJS: function () {
2992
+ return this.value.eval(env).toCSS();
2993
+ }
2994
+ };
2995
+ }
2996
+
2997
+ try {
2998
+ result = expression.call(context);
2999
+ } catch (e) {
3000
+ throw { message: "JavaScript evaluation error: '" + e.name + ': ' + e.message + "'" ,
3001
+ index: this.index };
3002
+ }
3003
+ if (typeof(result) === 'string') {
3004
+ return new(tree.Quoted)('"' + result + '"', result, this.escaped, this.index);
3005
+ } else if (Array.isArray(result)) {
3006
+ return new(tree.Anonymous)(result.join(', '));
3007
+ } else {
3008
+ return new(tree.Anonymous)(result);
3009
+ }
3010
+ }
3011
+ };
3012
+
3013
+ })(require('../tree'));
3014
+
3015
+ (function (tree) {
3016
+
3017
+ tree.Keyword = function (value) { this.value = value };
3018
+ tree.Keyword.prototype = {
3019
+ eval: function () { return this },
3020
+ toCSS: function () { return this.value },
3021
+ compare: function (other) {
3022
+ if (other instanceof tree.Keyword) {
3023
+ return other.value === this.value ? 0 : 1;
3024
+ } else {
3025
+ return -1;
3026
+ }
3027
+ }
3028
+ };
3029
+
3030
+ tree.True = new(tree.Keyword)('true');
3031
+ tree.False = new(tree.Keyword)('false');
3032
+
3033
+ })(require('../tree'));
3034
+ (function (tree) {
3035
+
3036
+ tree.Media = function (value, features) {
3037
+ var selectors = this.emptySelectors();
3038
+
3039
+ this.features = new(tree.Value)(features);
3040
+ this.ruleset = new(tree.Ruleset)(selectors, value);
3041
+ this.ruleset.allowImports = true;
3042
+ };
3043
+ tree.Media.prototype = {
3044
+ toCSS: function (ctx, env) {
3045
+ var features = this.features.toCSS(env);
3046
+
3047
+ this.ruleset.root = (ctx.length === 0 || ctx[0].multiMedia);
3048
+ return '@media ' + features + (env.compress ? '{' : ' {\n ') +
3049
+ this.ruleset.toCSS(ctx, env).trim().replace(/\n/g, '\n ') +
3050
+ (env.compress ? '}': '\n}\n');
3051
+ },
3052
+ eval: function (env) {
3053
+ if (!env.mediaBlocks) {
3054
+ env.mediaBlocks = [];
3055
+ env.mediaPath = [];
3056
+ }
3057
+
3058
+ var media = new(tree.Media)([], []);
3059
+ if(this.debugInfo) {
3060
+ this.ruleset.debugInfo = this.debugInfo;
3061
+ media.debugInfo = this.debugInfo;
3062
+ }
3063
+ media.features = this.features.eval(env);
3064
+
3065
+ env.mediaPath.push(media);
3066
+ env.mediaBlocks.push(media);
3067
+
3068
+ env.frames.unshift(this.ruleset);
3069
+ media.ruleset = this.ruleset.eval(env);
3070
+ env.frames.shift();
3071
+
3072
+ env.mediaPath.pop();
3073
+
3074
+ return env.mediaPath.length === 0 ? media.evalTop(env) :
3075
+ media.evalNested(env)
3076
+ },
3077
+ variable: function (name) { return tree.Ruleset.prototype.variable.call(this.ruleset, name) },
3078
+ find: function () { return tree.Ruleset.prototype.find.apply(this.ruleset, arguments) },
3079
+ rulesets: function () { return tree.Ruleset.prototype.rulesets.apply(this.ruleset) },
3080
+ emptySelectors: function() {
3081
+ var el = new(tree.Element)('', '&', 0);
3082
+ return [new(tree.Selector)([el])];
3083
+ },
3084
+
3085
+ evalTop: function (env) {
3086
+ var result = this;
3087
+
3088
+ // Render all dependent Media blocks.
3089
+ if (env.mediaBlocks.length > 1) {
3090
+ var selectors = this.emptySelectors();
3091
+ result = new(tree.Ruleset)(selectors, env.mediaBlocks);
3092
+ result.multiMedia = true;
3093
+ }
3094
+
3095
+ delete env.mediaBlocks;
3096
+ delete env.mediaPath;
3097
+
3098
+ return result;
3099
+ },
3100
+ evalNested: function (env) {
3101
+ var i, value,
3102
+ path = env.mediaPath.concat([this]);
3103
+
3104
+ // Extract the media-query conditions separated with `,` (OR).
3105
+ for (i = 0; i < path.length; i++) {
3106
+ value = path[i].features instanceof tree.Value ?
3107
+ path[i].features.value : path[i].features;
3108
+ path[i] = Array.isArray(value) ? value : [value];
3109
+ }
3110
+
3111
+ // Trace all permutations to generate the resulting media-query.
3112
+ //
3113
+ // (a, b and c) with nested (d, e) ->
3114
+ // a and d
3115
+ // a and e
3116
+ // b and c and d
3117
+ // b and c and e
3118
+ this.features = new(tree.Value)(this.permute(path).map(function (path) {
3119
+ path = path.map(function (fragment) {
3120
+ return fragment.toCSS ? fragment : new(tree.Anonymous)(fragment);
3121
+ });
3122
+
3123
+ for(i = path.length - 1; i > 0; i--) {
3124
+ path.splice(i, 0, new(tree.Anonymous)("and"));
3125
+ }
3126
+
3127
+ return new(tree.Expression)(path);
3128
+ }));
3129
+
3130
+ // Fake a tree-node that doesn't output anything.
3131
+ return new(tree.Ruleset)([], []);
3132
+ },
3133
+ permute: function (arr) {
3134
+ if (arr.length === 0) {
3135
+ return [];
3136
+ } else if (arr.length === 1) {
3137
+ return arr[0];
3138
+ } else {
3139
+ var result = [];
3140
+ var rest = this.permute(arr.slice(1));
3141
+ for (var i = 0; i < rest.length; i++) {
3142
+ for (var j = 0; j < arr[0].length; j++) {
3143
+ result.push([arr[0][j]].concat(rest[i]));
3144
+ }
3145
+ }
3146
+ return result;
3147
+ }
3148
+ },
3149
+ bubbleSelectors: function (selectors) {
3150
+ this.ruleset = new(tree.Ruleset)(selectors.slice(0), [this.ruleset]);
3151
+ }
3152
+ };
3153
+
3154
+ })(require('../tree'));
3155
+ (function (tree) {
3156
+
3157
+ tree.mixin = {};
3158
+ tree.mixin.Call = function (elements, args, index, filename, important) {
3159
+ this.selector = new(tree.Selector)(elements);
3160
+ this.arguments = args;
3161
+ this.index = index;
3162
+ this.filename = filename;
3163
+ this.important = important;
3164
+ };
3165
+ tree.mixin.Call.prototype = {
3166
+ eval: function (env) {
3167
+ var mixins, mixin, args, rules = [], match = false, i, m, f, isRecursive, isOneFound;
3168
+
3169
+ args = this.arguments && this.arguments.map(function (a) {
3170
+ return { name: a.name, value: a.value.eval(env) };
3171
+ });
3172
+
3173
+ for (i = 0; i < env.frames.length; i++) {
3174
+ if ((mixins = env.frames[i].find(this.selector)).length > 0) {
3175
+ isOneFound = true;
3176
+ for (m = 0; m < mixins.length; m++) {
3177
+ mixin = mixins[m];
3178
+ isRecursive = false;
3179
+ for(f = 0; f < env.frames.length; f++) {
3180
+ if ((!(mixin instanceof tree.mixin.Definition)) && mixin === (env.frames[f].originalRuleset || env.frames[f])) {
3181
+ isRecursive = true;
3182
+ break;
3183
+ }
3184
+ }
3185
+ if (isRecursive) {
3186
+ continue;
3187
+ }
3188
+ if (mixin.matchArgs(args, env)) {
3189
+ if (!mixin.matchCondition || mixin.matchCondition(args, env)) {
3190
+ try {
3191
+ Array.prototype.push.apply(
3192
+ rules, mixin.eval(env, args, this.important).rules);
3193
+ } catch (e) {
3194
+ throw { message: e.message, index: this.index, filename: this.filename, stack: e.stack };
3195
+ }
3196
+ }
3197
+ match = true;
3198
+ }
3199
+ }
3200
+ if (match) {
3201
+ return rules;
3202
+ }
3203
+ }
3204
+ }
3205
+ if (isOneFound) {
3206
+ throw { type: 'Runtime',
3207
+ message: 'No matching definition was found for `' +
3208
+ this.selector.toCSS().trim() + '(' +
3209
+ (args ? args.map(function (a) {
3210
+ var argValue = "";
3211
+ if (a.name) {
3212
+ argValue += a.name + ":";
3213
+ }
3214
+ if (a.value.toCSS) {
3215
+ argValue += a.value.toCSS();
3216
+ } else {
3217
+ argValue += "???";
3218
+ }
3219
+ return argValue;
3220
+ }).join(', ') : "") + ")`",
3221
+ index: this.index, filename: this.filename };
3222
+ } else {
3223
+ throw { type: 'Name',
3224
+ message: this.selector.toCSS().trim() + " is undefined",
3225
+ index: this.index, filename: this.filename };
3226
+ }
3227
+ }
3228
+ };
3229
+
3230
+ tree.mixin.Definition = function (name, params, rules, condition, variadic) {
3231
+ this.name = name;
3232
+ this.selectors = [new(tree.Selector)([new(tree.Element)(null, name)])];
3233
+ this.params = params;
3234
+ this.condition = condition;
3235
+ this.variadic = variadic;
3236
+ this.arity = params.length;
3237
+ this.rules = rules;
3238
+ this._lookups = {};
3239
+ this.required = params.reduce(function (count, p) {
3240
+ if (!p.name || (p.name && !p.value)) { return count + 1 }
3241
+ else { return count }
3242
+ }, 0);
3243
+ this.parent = tree.Ruleset.prototype;
3244
+ this.frames = [];
3245
+ };
3246
+ tree.mixin.Definition.prototype = {
3247
+ toCSS: function () { return "" },
3248
+ variable: function (name) { return this.parent.variable.call(this, name) },
3249
+ variables: function () { return this.parent.variables.call(this) },
3250
+ find: function () { return this.parent.find.apply(this, arguments) },
3251
+ rulesets: function () { return this.parent.rulesets.apply(this) },
3252
+
3253
+ evalParams: function (env, mixinEnv, args, evaldArguments) {
3254
+ var frame = new(tree.Ruleset)(null, []), varargs, arg, params = this.params.slice(0), i, j, val, name, isNamedFound, argIndex;
3255
+
3256
+ if (args) {
3257
+ args = args.slice(0);
3258
+
3259
+ for(i = 0; i < args.length; i++) {
3260
+ arg = args[i];
3261
+ if (name = (arg && arg.name)) {
3262
+ isNamedFound = false;
3263
+ for(j = 0; j < params.length; j++) {
3264
+ if (!evaldArguments[j] && name === params[j].name) {
3265
+ evaldArguments[j] = arg.value.eval(env);
3266
+ frame.rules.unshift(new(tree.Rule)(name, arg.value.eval(env)));
3267
+ isNamedFound = true;
3268
+ break;
3269
+ }
3270
+ }
3271
+ if (isNamedFound) {
3272
+ args.splice(i, 1);
3273
+ i--;
3274
+ continue;
3275
+ } else {
3276
+ throw { type: 'Runtime', message: "Named argument for " + this.name +
3277
+ ' ' + args[i].name + ' not found' };
3278
+ }
3279
+ }
3280
+ }
3281
+ }
3282
+ argIndex = 0;
3283
+ for (i = 0; i < params.length; i++) {
3284
+ if (evaldArguments[i]) continue;
3285
+
3286
+ arg = args && args[argIndex];
3287
+
3288
+ if (name = params[i].name) {
3289
+ if (params[i].variadic && args) {
3290
+ varargs = [];
3291
+ for (j = argIndex; j < args.length; j++) {
3292
+ varargs.push(args[j].value.eval(env));
3293
+ }
3294
+ frame.rules.unshift(new(tree.Rule)(name, new(tree.Expression)(varargs).eval(env)));
3295
+ } else {
3296
+ val = arg && arg.value;
3297
+ if (val) {
3298
+ val = val.eval(env);
3299
+ } else if (params[i].value) {
3300
+ val = params[i].value.eval(mixinEnv);
3301
+ } else {
3302
+ throw { type: 'Runtime', message: "wrong number of arguments for " + this.name +
3303
+ ' (' + args.length + ' for ' + this.arity + ')' };
3304
+ }
3305
+
3306
+ frame.rules.unshift(new(tree.Rule)(name, val));
3307
+ evaldArguments[i] = val;
3308
+ }
3309
+ }
3310
+
3311
+ if (params[i].variadic && args) {
3312
+ for (j = argIndex; j < args.length; j++) {
3313
+ evaldArguments[j] = args[j].value.eval(env);
3314
+ }
3315
+ }
3316
+ argIndex++;
3317
+ }
3318
+
3319
+ return frame;
3320
+ },
3321
+ eval: function (env, args, important) {
3322
+ var _arguments = [],
3323
+ mixinFrames = this.frames.concat(env.frames),
3324
+ frame = this.evalParams(env, {frames: mixinFrames}, args, _arguments),
3325
+ context, rules, start, ruleset;
3326
+
3327
+ frame.rules.unshift(new(tree.Rule)('@arguments', new(tree.Expression)(_arguments).eval(env)));
3328
+
3329
+ rules = important ?
3330
+ this.parent.makeImportant.apply(this).rules : this.rules.slice(0);
3331
+
3332
+ ruleset = new(tree.Ruleset)(null, rules).eval({
3333
+ frames: [this, frame].concat(mixinFrames)
3334
+ });
3335
+ ruleset.originalRuleset = this;
3336
+ return ruleset;
3337
+ },
3338
+ matchCondition: function (args, env) {
3339
+ if (this.condition && !this.condition.eval({
3340
+ frames: [this.evalParams(env, {frames: this.frames.concat(env.frames)}, args, [])].concat(env.frames)
3341
+ })) { return false }
3342
+ return true;
3343
+ },
3344
+ matchArgs: function (args, env) {
3345
+ var argsLength = (args && args.length) || 0, len, frame;
3346
+
3347
+ if (! this.variadic) {
3348
+ if (argsLength < this.required) { return false }
3349
+ if (argsLength > this.params.length) { return false }
3350
+ if ((this.required > 0) && (argsLength > this.params.length)) { return false }
3351
+ }
3352
+
3353
+ len = Math.min(argsLength, this.arity);
3354
+
3355
+ for (var i = 0; i < len; i++) {
3356
+ if (!this.params[i].name && !this.params[i].variadic) {
3357
+ if (args[i].value.eval(env).toCSS() != this.params[i].value.eval(env).toCSS()) {
3358
+ return false;
3359
+ }
3360
+ }
3361
+ }
3362
+ return true;
3363
+ }
3364
+ };
3365
+
3366
+ })(require('../tree'));
3367
+ (function (tree) {
3368
+
3369
+ tree.Operation = function (op, operands) {
3370
+ this.op = op.trim();
3371
+ this.operands = operands;
3372
+ };
3373
+ tree.Operation.prototype.eval = function (env) {
3374
+ var a = this.operands[0].eval(env),
3375
+ b = this.operands[1].eval(env),
3376
+ temp;
3377
+
3378
+ if (a instanceof tree.Dimension && b instanceof tree.Color) {
3379
+ if (this.op === '*' || this.op === '+') {
3380
+ temp = b, b = a, a = temp;
3381
+ } else {
3382
+ throw { name: "OperationError",
3383
+ message: "Can't substract or divide a color from a number" };
3384
+ }
3385
+ }
3386
+ if (!a.operate) {
3387
+ throw { name: "OperationError",
3388
+ message: "Operation on an invalid type" };
3389
+ }
3390
+
3391
+ return a.operate(this.op, b);
3392
+ };
3393
+
3394
+ tree.operate = function (op, a, b) {
3395
+ switch (op) {
3396
+ case '+': return a + b;
3397
+ case '-': return a - b;
3398
+ case '*': return a * b;
3399
+ case '/': return a / b;
3400
+ }
3401
+ };
3402
+
3403
+ })(require('../tree'));
3404
+
3405
+ (function (tree) {
3406
+
3407
+ tree.Paren = function (node) {
3408
+ this.value = node;
3409
+ };
3410
+ tree.Paren.prototype = {
3411
+ toCSS: function (env) {
3412
+ return '(' + this.value.toCSS(env).trim() + ')';
3413
+ },
3414
+ eval: function (env) {
3415
+ return new(tree.Paren)(this.value.eval(env));
3416
+ }
3417
+ };
3418
+
3419
+ })(require('../tree'));
3420
+ (function (tree) {
3421
+
3422
+ tree.Quoted = function (str, content, escaped, i) {
3423
+ this.escaped = escaped;
3424
+ this.value = content || '';
3425
+ this.quote = str.charAt(0);
3426
+ this.index = i;
3427
+ };
3428
+ tree.Quoted.prototype = {
3429
+ toCSS: function () {
3430
+ if (this.escaped) {
3431
+ return this.value;
3432
+ } else {
3433
+ return this.quote + this.value + this.quote;
3434
+ }
3435
+ },
3436
+ eval: function (env) {
3437
+ var that = this;
3438
+ var value = this.value.replace(/`([^`]+)`/g, function (_, exp) {
3439
+ return new(tree.JavaScript)(exp, that.index, true).eval(env).value;
3440
+ }).replace(/@\{([\w-]+)\}/g, function (_, name) {
3441
+ var v = new(tree.Variable)('@' + name, that.index).eval(env);
3442
+ return (v instanceof tree.Quoted) ? v.value : v.toCSS();
3443
+ });
3444
+ return new(tree.Quoted)(this.quote + value + this.quote, value, this.escaped, this.index);
3445
+ },
3446
+ compare: function (x) {
3447
+ if (!x.toCSS) {
3448
+ return -1;
3449
+ }
3450
+
3451
+ var left = this.toCSS(),
3452
+ right = x.toCSS();
3453
+
3454
+ if (left === right) {
3455
+ return 0;
3456
+ }
3457
+
3458
+ return left < right ? -1 : 1;
3459
+ }
3460
+ };
3461
+
3462
+ })(require('../tree'));
3463
+ (function (tree) {
3464
+
3465
+ tree.Ratio = function (value) {
3466
+ this.value = value;
3467
+ };
3468
+ tree.Ratio.prototype = {
3469
+ toCSS: function (env) {
3470
+ return this.value;
3471
+ },
3472
+ eval: function () { return this }
3473
+ };
3474
+
3475
+ })(require('../tree'));
3476
+ (function (tree) {
3477
+
3478
+ tree.Rule = function (name, value, important, index, inline) {
3479
+ this.name = name;
3480
+ this.value = (value instanceof tree.Value) ? value : new(tree.Value)([value]);
3481
+ this.important = important ? ' ' + important.trim() : '';
3482
+ this.index = index;
3483
+ this.inline = inline || false;
3484
+
3485
+ if (name.charAt(0) === '@') {
3486
+ this.variable = true;
3487
+ } else { this.variable = false }
3488
+ };
3489
+ tree.Rule.prototype.toCSS = function (env) {
3490
+ if (this.variable) { return "" }
3491
+ else {
3492
+ return this.name + (env.compress ? ':' : ': ') +
3493
+ this.value.toCSS(env) +
3494
+ this.important + (this.inline ? "" : ";");
3495
+ }
3496
+ };
3497
+
3498
+ tree.Rule.prototype.eval = function (context) {
3499
+ return new(tree.Rule)(this.name,
3500
+ this.value.eval(context),
3501
+ this.important,
3502
+ this.index, this.inline);
3503
+ };
3504
+
3505
+ tree.Rule.prototype.makeImportant = function () {
3506
+ return new(tree.Rule)(this.name,
3507
+ this.value,
3508
+ "!important",
3509
+ this.index, this.inline);
3510
+ };
3511
+
3512
+ tree.Shorthand = function (a, b) {
3513
+ this.a = a;
3514
+ this.b = b;
3515
+ };
3516
+
3517
+ tree.Shorthand.prototype = {
3518
+ toCSS: function (env) {
3519
+ return this.a.toCSS(env) + "/" + this.b.toCSS(env);
3520
+ },
3521
+ eval: function () { return this }
3522
+ };
3523
+
3524
+ })(require('../tree'));
3525
+ (function (tree) {
3526
+
3527
+ tree.Ruleset = function (selectors, rules, strictImports) {
3528
+ this.selectors = selectors;
3529
+ this.rules = rules;
3530
+ this._lookups = {};
3531
+ this.strictImports = strictImports;
3532
+ };
3533
+ tree.Ruleset.prototype = {
3534
+ eval: function (env) {
3535
+ var selectors = this.selectors && this.selectors.map(function (s) { return s.eval(env) });
3536
+ var ruleset = new(tree.Ruleset)(selectors, this.rules.slice(0), this.strictImports);
3537
+ var rules;
3538
+
3539
+ ruleset.originalRuleset = this;
3540
+ ruleset.root = this.root;
3541
+ ruleset.allowImports = this.allowImports;
3542
+
3543
+ if(this.debugInfo) {
3544
+ ruleset.debugInfo = this.debugInfo;
3545
+ }
3546
+
3547
+ // push the current ruleset to the frames stack
3548
+ env.frames.unshift(ruleset);
3549
+
3550
+ // currrent selectors
3551
+ if (!env.selectors) {
3552
+ env.selectors = [];
3553
+ }
3554
+ env.selectors.unshift(this.selectors);
3555
+
3556
+ // Evaluate imports
3557
+ if (ruleset.root || ruleset.allowImports || !ruleset.strictImports) {
3558
+ ruleset.evalImports(env);
3559
+ }
3560
+
3561
+ // Store the frames around mixin definitions,
3562
+ // so they can be evaluated like closures when the time comes.
3563
+ for (var i = 0; i < ruleset.rules.length; i++) {
3564
+ if (ruleset.rules[i] instanceof tree.mixin.Definition) {
3565
+ ruleset.rules[i].frames = env.frames.slice(0);
3566
+ }
3567
+ }
3568
+
3569
+ var mediaBlockCount = (env.mediaBlocks && env.mediaBlocks.length) || 0;
3570
+
3571
+ // Evaluate mixin calls.
3572
+ for (var i = 0; i < ruleset.rules.length; i++) {
3573
+ if (ruleset.rules[i] instanceof tree.mixin.Call) {
3574
+ rules = ruleset.rules[i].eval(env);
3575
+ ruleset.rules.splice.apply(ruleset.rules, [i, 1].concat(rules));
3576
+ i += rules.length-1;
3577
+ ruleset.resetCache();
3578
+ }
3579
+ }
3580
+
3581
+ if (this.selectors) {
3582
+ for (var i = 0; i < this.selectors.length; i++) {
3583
+ if (this.selectors[i].extend) {
3584
+ this.selectors[i].extend.eval(env, [[this.selectors[i]]].concat(env.selectors.slice(1)));
3585
+ }
3586
+ }
3587
+ }
3588
+
3589
+ // Evaluate everything else
3590
+ for (var i = 0, rule; i < ruleset.rules.length; i++) {
3591
+ rule = ruleset.rules[i];
3592
+
3593
+ if (! (rule instanceof tree.mixin.Definition)) {
3594
+ ruleset.rules[i] = rule.eval ? rule.eval(env) : rule;
3595
+ }
3596
+ }
3597
+
3598
+ // Pop the stack
3599
+ env.frames.shift();
3600
+ env.selectors.shift();
3601
+
3602
+ if (env.mediaBlocks) {
3603
+ for(var i = mediaBlockCount; i < env.mediaBlocks.length; i++) {
3604
+ env.mediaBlocks[i].bubbleSelectors(selectors);
3605
+ }
3606
+ }
3607
+
3608
+ return ruleset;
3609
+ },
3610
+ evalImports: function(env) {
3611
+ var i, rules;
3612
+ for (i = 0; i < this.rules.length; i++) {
3613
+ if (this.rules[i] instanceof tree.Import) {
3614
+ rules = this.rules[i].eval(env);
3615
+ if (typeof rules.length === "number") {
3616
+ this.rules.splice.apply(this.rules, [i, 1].concat(rules));
3617
+ i+= rules.length-1;
3618
+ } else {
3619
+ this.rules.splice(i, 1, rules);
3620
+ }
3621
+ this.resetCache();
3622
+ }
3623
+ }
3624
+ },
3625
+ makeImportant: function() {
3626
+ return new tree.Ruleset(this.selectors, this.rules.map(function (r) {
3627
+ if (r.makeImportant) {
3628
+ return r.makeImportant();
3629
+ } else {
3630
+ return r;
3631
+ }
3632
+ }), this.strictImports);
3633
+ },
3634
+ matchArgs: function (args) {
3635
+ return !args || args.length === 0;
3636
+ },
3637
+ resetCache: function () {
3638
+ this._rulesets = null;
3639
+ this._variables = null;
3640
+ this._lookups = {};
3641
+ },
3642
+ variables: function () {
3643
+ if (this._variables) { return this._variables }
3644
+ else {
3645
+ return this._variables = this.rules.reduce(function (hash, r) {
3646
+ if (r instanceof tree.Rule && r.variable === true) {
3647
+ hash[r.name] = r;
3648
+ }
3649
+ return hash;
3650
+ }, {});
3651
+ }
3652
+ },
3653
+ variable: function (name) {
3654
+ return this.variables()[name];
3655
+ },
3656
+ rulesets: function () {
3657
+ return this.rules.filter(function (r) {
3658
+ return (r instanceof tree.Ruleset) || (r instanceof tree.mixin.Definition);
3659
+ });
3660
+ },
3661
+ find: function (selector, self) {
3662
+ self = self || this;
3663
+ var rules = [], rule, match,
3664
+ key = selector.toCSS();
3665
+
3666
+ if (key in this._lookups) { return this._lookups[key] }
3667
+
3668
+ this.rulesets().forEach(function (rule) {
3669
+ if (rule !== self) {
3670
+ for (var j = 0; j < rule.selectors.length; j++) {
3671
+ if (match = selector.match(rule.selectors[j])) {
3672
+ if (selector.elements.length > rule.selectors[j].elements.length) {
3673
+ Array.prototype.push.apply(rules, rule.find(
3674
+ new(tree.Selector)(selector.elements.slice(1)), self));
3675
+ } else {
3676
+ rules.push(rule);
3677
+ }
3678
+ break;
3679
+ }
3680
+ }
3681
+ }
3682
+ });
3683
+ return this._lookups[key] = rules;
3684
+ },
3685
+ //
3686
+ // Entry point for code generation
3687
+ //
3688
+ // `context` holds an array of arrays.
3689
+ //
3690
+ toCSS: function (context, env) {
3691
+ var css = [], // The CSS output
3692
+ rules = [], // node.Rule instances
3693
+ _rules = [], //
3694
+ rulesets = [], // node.Ruleset instances
3695
+ paths = [], // Current selectors
3696
+ selector, // The fully rendered selector
3697
+ debugInfo, // Line number debugging
3698
+ rule;
3699
+
3700
+ if (! this.root) {
3701
+ this.joinSelectors(paths, context, this.selectors);
3702
+ }
3703
+
3704
+ // Compile rules and rulesets
3705
+ for (var i = 0; i < this.rules.length; i++) {
3706
+ rule = this.rules[i];
3707
+
3708
+ if (rule.rules || (rule instanceof tree.Media)) {
3709
+ rulesets.push(rule.toCSS(paths, env));
3710
+ } else if (rule instanceof tree.Directive) {
3711
+ var cssValue = rule.toCSS(paths, env);
3712
+ // Output only the first @charset definition as such - convert the others
3713
+ // to comments in case debug is enabled
3714
+ if (rule.name === "@charset") {
3715
+ // Only output the debug info together with subsequent @charset definitions
3716
+ // a comment (or @media statement) before the actual @charset directive would
3717
+ // be considered illegal css as it has to be on the first line
3718
+ if (env.charset) {
3719
+ if (rule.debugInfo) {
3720
+ rulesets.push(tree.debugInfo(env, rule));
3721
+ rulesets.push(new tree.Comment("/* "+cssValue.replace(/\n/g, "")+" */\n").toCSS(env));
3722
+ }
3723
+ continue;
3724
+ }
3725
+ env.charset = true;
3726
+ }
3727
+ rulesets.push(cssValue);
3728
+ } else if (rule instanceof tree.Comment) {
3729
+ if (!rule.silent) {
3730
+ if (this.root) {
3731
+ rulesets.push(rule.toCSS(env));
3732
+ } else {
3733
+ rules.push(rule.toCSS(env));
3734
+ }
3735
+ }
3736
+ } else {
3737
+ if (rule.toCSS && !rule.variable) {
3738
+ rules.push(rule.toCSS(env));
3739
+ } else if (rule.value && !rule.variable) {
3740
+ rules.push(rule.value.toString());
3741
+ }
3742
+ }
3743
+ }
3744
+
3745
+ rulesets = rulesets.join('');
3746
+
3747
+ // If this is the root node, we don't render
3748
+ // a selector, or {}.
3749
+ // Otherwise, only output if this ruleset has rules.
3750
+ if (this.root) {
3751
+ css.push(rules.join(env.compress ? '' : '\n'));
3752
+ } else {
3753
+ if (rules.length > 0) {
3754
+ debugInfo = tree.debugInfo(env, this);
3755
+ selector = paths.map(function (p) {
3756
+ return p.map(function (s) {
3757
+ return s.toCSS(env);
3758
+ }).join('').trim();
3759
+ }).join(env.compress ? ',' : ',\n');
3760
+
3761
+ // Remove duplicates
3762
+ for (var i = rules.length - 1; i >= 0; i--) {
3763
+ if (_rules.indexOf(rules[i]) === -1) {
3764
+ _rules.unshift(rules[i]);
3765
+ }
3766
+ }
3767
+ rules = _rules;
3768
+
3769
+ css.push(debugInfo + selector +
3770
+ (env.compress ? '{' : ' {\n ') +
3771
+ rules.join(env.compress ? '' : '\n ') +
3772
+ (env.compress ? '}' : '\n}\n'));
3773
+ }
3774
+ }
3775
+ css.push(rulesets);
3776
+
3777
+ return css.join('') + (env.compress ? '\n' : '');
3778
+ },
3779
+
3780
+ joinSelectors: function (paths, context, selectors) {
3781
+ for (var s = 0; s < selectors.length; s++) {
3782
+ this.joinSelector(paths, context, selectors[s]);
3783
+ }
3784
+ },
3785
+
3786
+ joinSelector: function (paths, context, selector) {
3787
+
3788
+ var i, j, k,
3789
+ hasParentSelector, newSelectors, el, sel, parentSel,
3790
+ newSelectorPath, afterParentJoin, newJoinedSelector,
3791
+ newJoinedSelectorEmpty, lastSelector, currentElements,
3792
+ selectorsMultiplied;
3793
+
3794
+ for (i = 0; i < selector.elements.length; i++) {
3795
+ el = selector.elements[i];
3796
+ if (el.value === '&') {
3797
+ hasParentSelector = true;
3798
+ }
3799
+ }
3800
+
3801
+ if (!hasParentSelector) {
3802
+ if (context.length > 0) {
3803
+ for(i = 0; i < context.length; i++) {
3804
+ paths.push(context[i].concat(selector));
3805
+ }
3806
+ }
3807
+ else {
3808
+ paths.push([selector]);
3809
+ }
3810
+ return;
3811
+ }
3812
+
3813
+ // The paths are [[Selector]]
3814
+ // The first list is a list of comma seperated selectors
3815
+ // The inner list is a list of inheritance seperated selectors
3816
+ // e.g.
3817
+ // .a, .b {
3818
+ // .c {
3819
+ // }
3820
+ // }
3821
+ // == [[.a] [.c]] [[.b] [.c]]
3822
+ //
3823
+
3824
+ // the elements from the current selector so far
3825
+ currentElements = [];
3826
+ // the current list of new selectors to add to the path.
3827
+ // We will build it up. We initiate it with one empty selector as we "multiply" the new selectors
3828
+ // by the parents
3829
+ newSelectors = [[]];
3830
+
3831
+ for (i = 0; i < selector.elements.length; i++) {
3832
+ el = selector.elements[i];
3833
+ // non parent reference elements just get added
3834
+ if (el.value !== "&") {
3835
+ currentElements.push(el);
3836
+ } else {
3837
+ // the new list of selectors to add
3838
+ selectorsMultiplied = [];
3839
+
3840
+ // merge the current list of non parent selector elements
3841
+ // on to the current list of selectors to add
3842
+ if (currentElements.length > 0) {
3843
+ this.mergeElementsOnToSelectors(currentElements, newSelectors);
3844
+ }
3845
+
3846
+ // loop through our current selectors
3847
+ for(j = 0; j < newSelectors.length; j++) {
3848
+ sel = newSelectors[j];
3849
+ // if we don't have any parent paths, the & might be in a mixin so that it can be used
3850
+ // whether there are parents or not
3851
+ if (context.length == 0) {
3852
+ // the combinator used on el should now be applied to the next element instead so that
3853
+ // it is not lost
3854
+ if (sel.length > 0) {
3855
+ sel[0].elements = sel[0].elements.slice(0);
3856
+ sel[0].elements.push(new(tree.Element)(el.combinator, '', 0)); //new Element(el.Combinator, ""));
3857
+ }
3858
+ selectorsMultiplied.push(sel);
3859
+ }
3860
+ else {
3861
+ // and the parent selectors
3862
+ for(k = 0; k < context.length; k++) {
3863
+ parentSel = context[k];
3864
+ // We need to put the current selectors
3865
+ // then join the last selector's elements on to the parents selectors
3866
+
3867
+ // our new selector path
3868
+ newSelectorPath = [];
3869
+ // selectors from the parent after the join
3870
+ afterParentJoin = [];
3871
+ newJoinedSelectorEmpty = true;
3872
+
3873
+ //construct the joined selector - if & is the first thing this will be empty,
3874
+ // if not newJoinedSelector will be the last set of elements in the selector
3875
+ if (sel.length > 0) {
3876
+ newSelectorPath = sel.slice(0);
3877
+ lastSelector = newSelectorPath.pop();
3878
+ newJoinedSelector = new(tree.Selector)(lastSelector.elements.slice(0));
3879
+ newJoinedSelectorEmpty = false;
3880
+ }
3881
+ else {
3882
+ newJoinedSelector = new(tree.Selector)([]);
3883
+ }
3884
+
3885
+ //put together the parent selectors after the join
3886
+ if (parentSel.length > 1) {
3887
+ afterParentJoin = afterParentJoin.concat(parentSel.slice(1));
3888
+ }
3889
+
3890
+ if (parentSel.length > 0) {
3891
+ newJoinedSelectorEmpty = false;
3892
+
3893
+ // join the elements so far with the first part of the parent
3894
+ newJoinedSelector.elements.push(new(tree.Element)(el.combinator, parentSel[0].elements[0].value, 0));
3895
+ newJoinedSelector.elements = newJoinedSelector.elements.concat(parentSel[0].elements.slice(1));
3896
+ }
3897
+
3898
+ if (!newJoinedSelectorEmpty) {
3899
+ // now add the joined selector
3900
+ newSelectorPath.push(newJoinedSelector);
3901
+ }
3902
+
3903
+ // and the rest of the parent
3904
+ newSelectorPath = newSelectorPath.concat(afterParentJoin);
3905
+
3906
+ // add that to our new set of selectors
3907
+ selectorsMultiplied.push(newSelectorPath);
3908
+ }
3909
+ }
3910
+ }
3911
+
3912
+ // our new selectors has been multiplied, so reset the state
3913
+ newSelectors = selectorsMultiplied;
3914
+ currentElements = [];
3915
+ }
3916
+ }
3917
+
3918
+ // if we have any elements left over (e.g. .a& .b == .b)
3919
+ // add them on to all the current selectors
3920
+ if (currentElements.length > 0) {
3921
+ this.mergeElementsOnToSelectors(currentElements, newSelectors);
3922
+ }
3923
+
3924
+ for(i = 0; i < newSelectors.length; i++) {
3925
+ paths.push(newSelectors[i]);
3926
+ }
3927
+ },
3928
+
3929
+ mergeElementsOnToSelectors: function(elements, selectors) {
3930
+ var i, sel;
3931
+
3932
+ if (selectors.length == 0) {
3933
+ selectors.push([ new(tree.Selector)(elements) ]);
3934
+ return;
3935
+ }
3936
+
3937
+ for(i = 0; i < selectors.length; i++) {
3938
+ sel = selectors[i];
3939
+
3940
+ // if the previous thing in sel is a parent this needs to join on to it
3941
+ if (sel.length > 0) {
3942
+ sel[sel.length - 1] = new(tree.Selector)(sel[sel.length - 1].elements.concat(elements));
3943
+ }
3944
+ else {
3945
+ sel.push(new(tree.Selector)(elements));
3946
+ }
3947
+ }
3948
+ }
3949
+ };
3950
+ })(require('../tree'));
3951
+ (function (tree) {
3952
+
3953
+ tree.Selector = function (elements, extend) {
3954
+ this.elements = elements;
3955
+ this.extend = extend;
3956
+ };
3957
+ tree.Selector.prototype.match = function (other) {
3958
+ var elements = this.elements,
3959
+ len = elements.length,
3960
+ oelements, olen, max, i;
3961
+
3962
+ oelements = other.elements.slice(
3963
+ (other.elements.length && other.elements[0].value === "&") ? 1 : 0);
3964
+ olen = oelements.length;
3965
+ max = Math.min(len, olen)
3966
+
3967
+ if (olen === 0 || len < olen) {
3968
+ return false;
3969
+ } else {
3970
+ for (i = 0; i < max; i++) {
3971
+ if (elements[i].value !== oelements[i].value) {
3972
+ return false;
3973
+ }
3974
+ }
3975
+ }
3976
+ return true;
3977
+ };
3978
+ tree.Selector.prototype.eval = function (env) {
3979
+ return new(tree.Selector)(this.elements.map(function (e) {
3980
+ return e.eval(env);
3981
+ }), this.extend);
3982
+ };
3983
+ tree.Selector.prototype.toCSS = function (env) {
3984
+ if (this._css) { return this._css }
3985
+
3986
+ if (this.elements[0].combinator.value === "") {
3987
+ this._css = ' ';
3988
+ } else {
3989
+ this._css = '';
3990
+ }
3991
+
3992
+ this._css += this.elements.map(function (e) {
3993
+ if (typeof(e) === 'string') {
3994
+ return ' ' + e.trim();
3995
+ } else {
3996
+ return e.toCSS(env);
3997
+ }
3998
+ }).join('');
3999
+
4000
+ return this._css;
4001
+ };
4002
+
4003
+ })(require('../tree'));
4004
+ (function (tree) {
4005
+
4006
+ tree.UnicodeDescriptor = function (value) {
4007
+ this.value = value;
4008
+ };
4009
+ tree.UnicodeDescriptor.prototype = {
4010
+ toCSS: function (env) {
4011
+ return this.value;
4012
+ },
4013
+ eval: function () { return this }
4014
+ };
4015
+
4016
+ })(require('../tree'));
4017
+ (function (tree) {
4018
+
4019
+ tree.URL = function (val, rootpath) {
4020
+ this.value = val;
4021
+ this.rootpath = rootpath;
4022
+ };
4023
+ tree.URL.prototype = {
4024
+ toCSS: function () {
4025
+ return "url(" + this.value.toCSS() + ")";
4026
+ },
4027
+ eval: function (ctx) {
4028
+ var val = this.value.eval(ctx), rootpath;
4029
+
4030
+ // Add the base path if the URL is relative
4031
+ if (typeof val.value === "string" && !/^(?:[a-z-]+:|\/)/.test(val.value)) {
4032
+ rootpath = this.rootpath;
4033
+ if (!val.quote) {
4034
+ rootpath = rootpath.replace(/[\(\)'"\s]/g, function(match) { return "\\"+match; });
4035
+ }
4036
+ val.value = rootpath + val.value;
4037
+ }
4038
+
4039
+ return new(tree.URL)(val, this.rootpath);
4040
+ }
4041
+ };
4042
+
4043
+ })(require('../tree'));
4044
+ (function (tree) {
4045
+
4046
+ tree.Value = function (value) {
4047
+ this.value = value;
4048
+ this.is = 'value';
4049
+ };
4050
+ tree.Value.prototype = {
4051
+ eval: function (env) {
4052
+ if (this.value.length === 1) {
4053
+ return this.value[0].eval(env);
4054
+ } else {
4055
+ return new(tree.Value)(this.value.map(function (v) {
4056
+ return v.eval(env);
4057
+ }));
4058
+ }
4059
+ },
4060
+ toCSS: function (env) {
4061
+ return this.value.map(function (e) {
4062
+ return e.toCSS(env);
4063
+ }).join(env.compress ? ',' : ', ');
4064
+ }
4065
+ };
4066
+
4067
+ })(require('../tree'));
4068
+ (function (tree) {
4069
+
4070
+ tree.Variable = function (name, index, file) { this.name = name, this.index = index, this.file = file };
4071
+ tree.Variable.prototype = {
4072
+ eval: function (env) {
4073
+ var variable, v, name = this.name;
4074
+
4075
+ if (name.indexOf('@@') == 0) {
4076
+ name = '@' + new(tree.Variable)(name.slice(1)).eval(env).value;
4077
+ }
4078
+
4079
+ if (this.evaluating) {
4080
+ throw { type: 'Name',
4081
+ message: "Recursive variable definition for " + name,
4082
+ filename: this.file,
4083
+ index: this.index };
4084
+ }
4085
+
4086
+ this.evaluating = true;
4087
+
4088
+ if (variable = tree.find(env.frames, function (frame) {
4089
+ if (v = frame.variable(name)) {
4090
+ return v.value.eval(env);
4091
+ }
4092
+ })) {
4093
+ this.evaluating = false;
4094
+ return variable;
4095
+ }
4096
+ else {
4097
+ throw { type: 'Name',
4098
+ message: "variable " + name + " is undefined",
4099
+ filename: this.file,
4100
+ index: this.index };
4101
+ }
4102
+ }
4103
+ };
4104
+
4105
+ })(require('../tree'));
4106
+ (function (tree) {
4107
+
4108
+ tree.debugInfo = function(env, ctx) {
4109
+ var result="";
4110
+ if (env.dumpLineNumbers && !env.compress) {
4111
+ switch(env.dumpLineNumbers) {
4112
+ case 'comments':
4113
+ result = tree.debugInfo.asComment(ctx);
4114
+ break;
4115
+ case 'mediaquery':
4116
+ result = tree.debugInfo.asMediaQuery(ctx);
4117
+ break;
4118
+ case 'all':
4119
+ result = tree.debugInfo.asComment(ctx)+tree.debugInfo.asMediaQuery(ctx);
4120
+ break;
4121
+ }
4122
+ }
4123
+ return result;
4124
+ };
4125
+
4126
+ tree.debugInfo.asComment = function(ctx) {
4127
+ return '/* line ' + ctx.debugInfo.lineNumber + ', ' + ctx.debugInfo.fileName + ' */\n';
4128
+ };
4129
+
4130
+ tree.debugInfo.asMediaQuery = function(ctx) {
4131
+ return '@media -sass-debug-info{filename{font-family:' +
4132
+ ('file://' + ctx.debugInfo.fileName).replace(/[\/:.]/g, '\\$&') +
4133
+ '}line{font-family:\\00003' + ctx.debugInfo.lineNumber + '}}\n';
4134
+ };
4135
+
4136
+ tree.find = function (obj, fun) {
4137
+ for (var i = 0, r; i < obj.length; i++) {
4138
+ if (r = fun.call(obj, obj[i])) { return r }
4139
+ }
4140
+ return null;
4141
+ };
4142
+ tree.jsify = function (obj) {
4143
+ if (Array.isArray(obj.value) && (obj.value.length > 1)) {
4144
+ return '[' + obj.value.map(function (v) { return v.toCSS(false) }).join(', ') + ']';
4145
+ } else {
4146
+ return obj.toCSS(false);
4147
+ }
4148
+ };
4149
+
4150
+ })(require('./tree'));
4151
+ var name;
4152
+
4153
+ function loadStyleSheet(sheet, callback, reload, remaining) {
4154
+ var endOfPath = Math.max(name.lastIndexOf('/'), name.lastIndexOf('\\')),
4155
+ sheetName = name.slice(0, endOfPath + 1) + sheet.href,
4156
+ contents = sheet.contents || {},
4157
+ input = readFile(sheetName);
4158
+
4159
+ contents[sheetName] = input;
4160
+
4161
+ var parser = new less.Parser({
4162
+ paths: [sheet.href.replace(/[\w\.-]+$/, '')],
4163
+ contents: contents
4164
+ });
4165
+ parser.parse(input, function (e, root) {
4166
+ if (e) {
4167
+ return error(e, sheetName);
4168
+ }
4169
+ try {
4170
+ callback(e, root, input, sheet, { local: false, lastModified: 0, remaining: remaining }, sheetName);
4171
+ } catch(e) {
4172
+ error(e, sheetName);
4173
+ }
4174
+ });
4175
+ }
4176
+
4177
+ function writeFile(filename, content) {
4178
+ var fstream = new java.io.FileWriter(filename);
4179
+ var out = new java.io.BufferedWriter(fstream);
4180
+ out.write(content);
4181
+ out.close();
4182
+ }
4183
+
4184
+ // Command line integration via Rhino
4185
+ (function (args) {
4186
+ var output,
4187
+ compress = false,
4188
+ i;
4189
+
4190
+ for(i = 0; i < args.length; i++) {
4191
+ switch(args[i]) {
4192
+ case "-x":
4193
+ compress = true;
4194
+ break;
4195
+ default:
4196
+ if (!name) {
4197
+ name = args[i];
4198
+ } else if (!output) {
4199
+ output = args[i];
4200
+ } else {
4201
+ print("unrecognised parameters");
4202
+ print("input_file [output_file] [-x]");
4203
+ }
4204
+ }
4205
+ }
4206
+
4207
+ if (!name) {
4208
+ print('No files present in the fileset; Check your pattern match in build.xml');
4209
+ quit(1);
4210
+ }
4211
+ path = name.split("/");path.pop();path=path.join("/")
4212
+
4213
+ var input = readFile(name);
4214
+
4215
+ if (!input) {
4216
+ print('lesscss: couldn\'t open file ' + name);
4217
+ quit(1);
4218
+ }
4219
+
4220
+ var result;
4221
+ try {
4222
+ var parser = new less.Parser();
4223
+ parser.parse(input, function (e, root) {
4224
+ if (e) {
4225
+ error(e, name);
4226
+ quit(1);
4227
+ } else {
4228
+ result = root.toCSS({compress: compress || false});
4229
+ if (output) {
4230
+ writeFile(output, result);
4231
+ print("Written to " + output);
4232
+ } else {
4233
+ print(result);
4234
+ }
4235
+ quit(0);
4236
+ }
4237
+ });
4238
+ }
4239
+ catch(e) {
4240
+ error(e, name);
4241
+ quit(1);
4242
+ }
4243
+ print("done");
4244
+ }(arguments));
4245
+
4246
+ function error(e, filename) {
4247
+
4248
+ var content = "Error : " + filename + "\n";
4249
+
4250
+ filename = e.filename || filename;
4251
+
4252
+ if (e.message) {
4253
+ content += e.message + "\n";
4254
+ }
4255
+
4256
+ var errorline = function (e, i, classname) {
4257
+ if (e.extract[i]) {
4258
+ content +=
4259
+ String(parseInt(e.line) + (i - 1)) +
4260
+ ":" + e.extract[i] + "\n";
4261
+ }
4262
+ };
4263
+
4264
+ if (e.stack) {
4265
+ content += e.stack;
4266
+ } else if (e.extract) {
4267
+ content += 'on line ' + e.line + ', column ' + (e.column + 1) + ':\n';
4268
+ errorline(e, 0);
4269
+ errorline(e, 1);
4270
+ errorline(e, 2);
4271
+ }
4272
+ print(content);
4273
+ }