define("settings",[],function(){var e=codebox.require("core/settings");return e.add({namespace:"project",title:"Project",defaults:{openrundialog:!0},fields:{openrundialog:{label:"Open Run Dialog",type:"checkbox",help:"Open new window when running application."}}})}),define("ports",[],function(){var e=codebox.require("hr/utils"),t=codebox.require("core/operations"),n=codebox.require("core/box"),r=codebox.require("utils/dialogs"),i=codebox.require("utils/alerts"),s=codebox.require("models/command"),o=s.register("project.ports",{category:"Project",title:"Running Ports",type:"menu",offline:!1,search:!1}),u=function(){return n.procHttp().then(function(t){return o.menu.reset(e.map(t,function(e){return{title:e.port,flags:e.reachable?"":"disabled",action:function(){e.reachable?window.open(e.url):r.alert("Your server is not accessible ","Your server is not accessible externally because it is bound to 'localhost', please bind it to '0.0.0.0' instead")}}})),t})};return{command:o,update:u}}),define("autorun",["settings","ports"],function(e,t){var n=codebox.require("hr/utils"),r=codebox.require("core/commands/toolbar"),i=codebox.require("core/operations"),s=codebox.require("core/box"),o=codebox.require("utils/dialogs"),u=codebox.require("utils/alerts"),a=codebox.require("models/command"),f=undefined,l={run:"fa-play",build:"fa-cog fa-spin",clean:"fa-eraser"},c=r.register("project.run",{category:"Project",title:"Run",icons:{"default":"play"},offline:!1,position:1,shortcuts:["alt+r"]},function(r){r=n.defaults(r||{},{ignoreErrors:!1});if(f!==undefined){f!=null&&f.terminal.closeTab();return}return h(null),s.run({type:r.type}).then(function(r){var s=i.start("project.run."+r.shellId,null,{title:r.name+" running on port "+r.port,icons:{"default":l[r.type]||"play"},action:function(){window.open(r.url),t.update().then(function(e){var t=n.find(e,function(e){return e.port==r.port});t||s.destroy()})}});r.terminal.on("tab:close",function(){s.destroy(),h(undefined)}),h(r),t.update(),e.user.get("openrundialog",!0)&&o.confirm("Application is now running on port "+r.port,"Open <b>"+n.escape(r.url)+"</b> in a new window? (This dialog can be disabled in the settings).").progress(function(e){e.once("close",function(e,t){e&&window.open(r.url)})})},function(e){h(undefined),r.ignoreErrors||o.alert("Error running this project","An error occurred when trying to run this project: "+(e.message||e))})}),h=function(e){var t=f;f=e,f!=null?c.set({title:"Stop",icons:{"default":"stop"}}):c.set({title:"Run",icons:{"default":"play"}});if(t&&t.type=="run"&&f===undefined)return c.run({type:"stop",ignoreErrors:!0})};return h(undefined),{command:c}}),define("runner",["autorun"],function(e){var t=codebox.require("hr/utils"),n=codebox.require("core/operations"),r=codebox.require("core/box"),i=codebox.require("utils/dialogs"),s=codebox.require("utils/alerts"),o=codebox.require("models/command"),u=o.register("project.run.action",{category:"Project",title:"Perform Action",type:"menu",offline:!1,search:!1}),a=function(){return r.runner().then(function(n){return u.menu.reset(t.map(n,function(t){return{title:t.name,action:function(){e.command.run({id:t.id})}}})),ports})};return{command:u,update:a}}),define("samples",[],function(){var e=codebox.require("hr/utils"),t=codebox.require("utils/dialogs"),n=codebox.require("core/box"),r=codebox.require("core/backends/rpc"),i=codebox.require("models/command"),s=i.register("project.samples",{category:"Project",title:"Use Sample Project",type:"menu",offline:!1,search:!1}),o=function(){return r.execute("project/supported").then(function(n){return s.menu.reset(e.chain(n).map(function(e){return e.sample?{title:e.name,action:function(){t.confirm("Replace workspace contents with "+e.name+" sample?","WARNING: Using a sample will erase the current contents of your workspace. Use only if your workspace is empty or if you want to wipe it").then(function(){return r.execute("project/useSample",{sample:e.id})})}}:null}).compact().value()),n})};return{command:s,update:o}}),define("client",["runner","ports","autorun","samples"],function(e,t,n,r){var i=codebox.require("hr/utils"),s=codebox.require("core/operations"),o=codebox.require("core/app"),u=codebox.require("core/box"),a=codebox.require("core/commands/menu"),f=codebox.require("utils/dialogs"),l=codebox.require("utils/alerts");a.getById("file").menuSection([r.command]),a.register("project",{title:"Project",offline:!1}).menuSection([n.command,e.command]).menuSection([{id:"project.build",category:"Project",title:"Build",offline:!1,action:function(){return n.command.run({type:"build"})},shortcuts:["mod+b"]},{id:"project.clean",category:"Project",title:"Clean",offline:!1,action:function(){return n.command.run({type:"clean"})},shortcuts:["mod+shift+k"]}]).menuSection([{id:"project.ports.refresh",category:"Project",title:"Refresh Ports",offline:!1,action:t.update},t.command]),u.on("box:project:define",function(){e.update()}),e.update(),t.update(),r.update()});