define(function(){var e=function(e){return e.join("\n")},t=function(t,n){var r=[];return r.push("/* Source: "+t+" */"),r.push(n),e(r)},n=function(){};n.prototype.name=function(e){if(!e)return this.el.id||!1;this.el.id=e},n.prototype.clean=function(){var e;while(this.el.firstChild)e=this.el.firstChild,this.el.removeChild(e)},n.prototype.getElement=function(){return this.el};var r=function(){var e;this.el=document.createElement("style"),e=document.getElementsByTagName("head")[0],e.appendChild(this.el)};r.prototype=new n,r.prototype.render=function(e,t){var n,r;while(t.length>0)n=t.length-1,r=e[t[n]],r.previous&&this.el.removeChild(r.previous.node),this.el.appendChild(r.node),t.splice(n,1)};var i=function(){this.el=document.createStyleSheet()};i.prototype=new n,i.prototype.render=function(t,n){var r=[],i;for(i in t)r.push(t[i].source);r=e(r),this.clean(),this.el.cssText=r};var s=function(e){this.setRenderer(e),this.stylesheets={},this.changed=[]};s.prototype.setRenderer=function(e){document.createStyleSheet?this.renderer=new i:this.renderer=new r,this.renderer.name(e)},s.prototype.register=function(e,n){var r=!1;return n=t(e,n),this.changed.push(e),this.stylesheets[e]&&(r=this.stylesheets[e]),this.stylesheets[e]={source:n,node:document.createTextNode(n)},this.stylesheets[e].previous=r,this.render(),this},s.prototype.name=function(e){return this.renderer.name(e)},s.prototype.clean=function(){this.renderer.clean()},s.prototype.render=function(){return this.renderer.render(this.stylesheets,this.changed),this},s.prototype.getRenderer=function(){return this.renderer};var o,u,a=["Msxml2.XMLHTTP","Microsoft.XMLHTTP","Msxml2.XMLHTTP.4.0"],f=function(){throw new Error("Environment unsupported.")},l={};return typeof process!="undefined"&&process.versions&&!!process.versions.node?(o=require.nodeRequire("fs"),f=function(e,t){t(o.readFileSync(e,"utf8"))}):typeof window!="undefined"&&window.navigator&&window.document||typeof importScripts!="undefined"?(u=function(){var e,t,n;if(typeof XMLHttpRequest!="undefined")return new XMLHttpRequest;for(t=0;t<3;t++){n=a[t];try{e=new ActiveXObject(n)}catch(r){}if(e){a=[n];break}}if(!e)throw new Error("getXhr(): XMLHttpRequest not available");return e},f=function(e,t){var n=u();n.open("GET",e,!0),n.onreadystatechange=function(e){n.readyState===4&&t(n.responseText)},n.send(null)}):typeof Packages!="undefined"&&(f=function(e,t){var n="utf-8",r=new java.io.File(e),i=java.lang.System.getProperty("line.separator"),s=new java.io.BufferedReader(new java.io.InputStreamReader(new java.io.FileInputStream(r),n)),o,u,a="";try{o=new java.lang.StringBuffer,u=s.readLine(),u&&u.length()&&u.charAt(0)===65279&&(u=u.substring(1)),o.append(u);while((u=s.readLine())!==null)o.append(i),o.append(u);a=String(o.toString())}finally{s.close()}t(a)}),{load:function(e,t,n,r){var i=t.toUrl(e);f(i,function(e){var t=new s(i);t.register(i,e),n(t)})}}});