//>>built
require({cache:{"dojo/node":function(){define(["./has"],function(c){var a;if(require.nodeRequire)a=require.nodeRequire("path");else throw Error("node plugin failed to load because it cannot find the original Node.js require");return{load:function(a,b,n){if(!b.nodeRequire)throw Error("Cannot find native require function");b=b.nodeRequire;var f=define,l;define=void 0;try{l=b(a)}finally{define=f}n(l)},normalize:function(h,b){if("."===h.charAt(0)){var n=require.toUrl(b(".")).replace("/",a.sep),f=h.split("/");
f.unshift(n);h=a.join.apply(a,f)}return h}}})},"main/config":function(){define(["dojo/_base/declare","dojo/_base/config"],function(c,a){return new (c([],{__dirname:a.__dirname,constructor:function(a){c.safeMixin(this,a)}}))(a.nodeMirrorConfig)})},"main/remoteCaller":function(){define(["dojo/_base/declare","main/config","dojo/Deferred","dojo/json"],function(c,a,h,b){return new (c([],{classes:{},call:function(a,f){for(var l={declaredClass:a,fName:f,args:[]},e=2;e<arguments.length;)l.args.push(arguments[e]),
++e;var g=new h;require(["dojo/request/xhr"],function(a){a("/apicall",{data:b.stringify(l),method:"PUT",handleAs:"json",headers:{"Content-Type":"application/json"}}).then(function(a){g.resolve(a)},function(a){g.reject(a)})});return g},add:function(a){this.classes[a.declaredClass]=a},serverCall:function(a){var f=[];a.args&&(f=a.args);var b=this.classes[a.declaredClass];return b[a.fName].apply(b,f)}}))({})})},"main/treeItems":function(){define("dojo/_base/declare main/_RemoteCall dojo/Deferred main/config dojo/_base/array sol/fileName sol/promise dojo/_base/lang main/nameTranslator".split(" "),
function(c,a,h,b,n,f,l,e,g){var m;b.isServer&&require(["server/files"],function(a){m=a});var p;return p=new (c("treeItems",[a],{remoteFunctions:{getRootDef:!0,getChildrenDef:!0,getItemDef:!0},getRootDef:function(){return p.getItemDef("")},getItemDef:function(a){var k=new h,d={id:a,name:""===a?f.single(b.__dirname):f.single(a)};m.dirsDef(g.fileName(a)).then(function(a){d.hasChildren=!!a;k.resolve(d)});return k},getChildrenDef:function(a){var k=new h;m.dirsDef(b.__dirname+a).then(function(a){if(a){var b=
[];l.allDone(n.map(a,function(a){return p.getItemDef(g.reduceName(a)).then(e.hitch(b,"push"))})).then(function(){k.resolve(b)},function(){})}else k.resolve()});return k}}))})},"main/_RemoteCall":function(){define(["dojo/_base/declare","main/config","main/remoteCaller","dojo/_base/lang"],function(c,a,h,b){return c("_RemoteCall",[],{constructor:function(n){h.add(this);if(!a.isServer)for(var f in this.remoteFunctions)this.remoteFunctions[f]&&"function"==typeof this[f]&&(n={},n[f]=b.hitch(h,"call",this.declaredClass,
f),c.safeMixin(this,n))},remoteFunctions:{}})})},"sol/fileName":function(){define(["dojo/_base/declare","dojo/_base/array","dojo/_base/lang"],function(c,a,h,b){return new (c("File",[],{single:function(a){a=a.split("/");return a[a.length-1]}}))})},"sol/promise":function(){define(["dojo/_base/declare","dojo/Deferred","dojo/_base/array","dojo/promise/all","dojo/_base/lang"],function(c,a,h,b,n){return new (c("SolPromise",[],{_isPromise:function(a){return a&&"function"===typeof a.then},_parseParameter:function(a){var b,
e;a instanceof Array?e=a:a&&"object"===typeof a&&(b=a);if(b){e=[];for(var g in b)Object.hasOwnProperty.call(b,g)&&this._isPromise(b[g])&&e.push(b[g])}if(e)return e},allDone:function(b){ar=this._parseParameter(b);if(!ar||!ar.length)return(new a).resolve(b);var c=new a,e=ar.length,g=function(){0===--e&&c.resolve(b)};h.forEach(ar,function(a,b){a.then(g,g)});return c.promise}}))})},"dojo/promise/all":function(){define(["../_base/array","../Deferred","../when"],function(c,a,h){var b=c.some;return function(c){var f,
l;c instanceof Array?l=c:c&&"object"===typeof c&&(f=c);var e,g=[];if(f){l=[];for(var m in f)Object.hasOwnProperty.call(f,m)&&(g.push(m),l.push(f[m]));e={}}else l&&(e=[]);if(!l||!l.length)return(new a).resolve(e);var p=new a;p.promise.always(function(){e=g=null});var q=l.length;b(l,function(a,d){f||g.push(d);h(a,function(a){p.isFulfilled()||(e[g[d]]=a,0===--q&&p.resolve(e))},p.reject);return p.isFulfilled()});return p.promise}})},"main/nameTranslator":function(){define(["dojo/_base/declare","main/config"],
function(c,a){var h=0;a.isServer&&(h=a.__dirname.length);return new (c("NameTranslator",[],{reduceName:function(a){return a.substr(h)},fileName:function(b){return a.__dirname+b}}))})},"server/files":function(){define("dojo/_base/declare dojo/Deferred dojo/_base/config dojo/node!fs dojo/_base/array dojo/promise/all dojo/_base/lang sol/promise dojo/node!mime-magic dojo/node!mime".split(" "),function(c,a,h,b,n,f,l,e,g,m){var p={".pl":"application/promiseLand",".pegjs":"application/peg.js"},q;return q=
new (c("File",[],{remoteFunctions:{},dirsDef:function(k){var d=new a;b.stat(k,function(a,c){a||!c.isDirectory()?d.resolve():b.readdir(k,function(a,b){if(a)d.resolve();else{var c=[];e.allDone(n.map(b,function(a){filename=k+"/"+a;return q.isDirDef(filename).then(function(a){c.push(a)})})).then(function(){d.resolve(c)})}})});return d.promise},childrenDef:function(k){var d=new a;q.isDirDef(k).then(function(){b.readdir(k,function(a,b){a?d.resolve():d.resolve(n.map(b,function(a){return k+"/"+a}))})},function(){d.resolve()});
return d.promise},isDirDef:function(k){var d=new a;b.stat(k,function(a,b){b.isDirectory()&&d.resolve(k);d.reject(k)});return d.promise},contentTypeDef:function(k){var d=new a;g(k,function(a,c){a?d.reject(a):b.stat(k,function(a,b){try{if(a)d.reject(a);else{var g=0===b.size;"inode/x-empty"==c&&(g=!0);if("text/plain"==c||g){for(var e in p)if(k.substr(k.length-e.length)==e){c=p[e];d.resolve(c);return}c=m.lookup(k)}d.resolve(c)}}catch(f){}})});return d.promise},readTextDef:function(c){var d=new a;b.readFile(c,
{encoding:"utf8"},function(a,b){d.resolve(b)});return d.promise},createFileDef:function(c){var d=new a;b.open(c,"a",void 0,function(a,c){a?d.reject(a):c?b.close(c,function(){d.resolve()}):d.resolve()});return d.promise},createDirDef:function(c){var d=new a;b.mkdir(c,void 0,function(a){a?d.reject(a):d.resolve(c)});return d.promise},writeTextDef:function(c,d){var g=new a;b.writeFile(c,d,{encoding:"utf8"},function(a,b){g.resolve()});return g.promise}}))})},"main/contentIO":function(){define("dojo/_base/declare main/_RemoteCall dojo/Deferred main/config dojo/_base/array sol/fileName sol/promise dojo/_base/lang main/nameTranslator".split(" "),
function(c,a,h,b,n,f,l,e,g){var m;b.isServer&&require(["server/files"],function(a){m=a});return new (c("ContentIO",[a],{remoteFunctions:{getContentDef:!0,saveTextDef:!0,createFileDef:!0},getContentDef:function(a){var b=new h,c=g.fileName(a),d={};m.contentTypeDef(c).then(function(e){d.id=a;d.contentType=e;if("inode/directory"==e)m.childrenDef(c).then(function(a){d.children=[];l.allDone(n.map(a,function(a){var b={id:g.reduceName(a)};d.children.push(b);return m.contentTypeDef(a).then(function(a){b.contentType=
a})})).then(function(){b.resolve(d)})});else{var f;(f=(f=(f=(f=(f="text/"==e.substr(0,5))||"application/javascript"==e||"application/peg.js"==e)||"application/css"==e)||"application/json"==e)||"inode/x-empty"==e)?(d.isText=!0,m.readTextDef(c).then(function(a){d.text=a;b.resolve(d)})):"application/promiseLand"==e&&(d.isText=!0,m.readTextDef(c).then(function(a){d.text=a;b.resolve(d)}))}});return b},saveTextDef:function(a,b){var c=g.fileName(a);return m.writeTextDef(c,b)},createFileDef:function(a,b,
c){var d=new h,f=a+"/"+b;if(!b||!b.length)d.reject();else return a=g.fileName(f),c?m.createDirDef(a).then(e.hitch(this,function(){this.getContentDef(f).then(function(a){d.resolve(a)})}),function(){d.reject()}):m.createFileDef(a).then(e.hitch(this,function(){this.getContentDef(f).then(function(a){d.resolve(a)})}),function(){d.reject()}),d.promise}}))})},"main/nodeControl":function(){define("dojo/_base/declare main/_RemoteCall dojo/Deferred main/config dojo/_base/array sol/promise dojo/_base/lang".split(" "),
function(c,a,h,b,n,f,l){return new (c("NodeControl",[a],{remoteFunctions:{restartDef:!0},restartDef:function(){var a=new h;setTimeout(function(){b.restartableObj&&b.restartableObj.isRestartable&&b.restartableObj.restart()},10);a.resolve({});return a.promise}}))})}}});
define("server/server","dojo/node!express main/config dojo/node!mime-magic dojo/node!pty.js dojo/node!socket.io dojo/node!http".split(" "),function(c,a,h,b,n,f,l){a.isServer=!0;require(["main/remoteCaller","main/treeItems","main/contentIO","main/nodeControl"],function(e,g,h){g=c();h=f.createServer(g);g.use(c.bodyParser());g.put("/apicall",function(a,b){e.serverCall(a.body).then(function(a){b.send(a)})});g.use(c["static"](a["static"]));g.get("/",function(a,b){b.send("Hello World")});h.listen(a.port);
g=n.listen(h);h=b.spawn("bash",[],{name:"xterm-color",cols:80,rows:30,cwd:process.env.HOME,env:process.env});g.sockets.on("connection",function(a){a.on("create",function(a,b,c){c(null,{id:1})});a.on("data",function(a,b){})});h.on("close",function(){})})});
//@ sourceMappingURL=server.js.map