!function(e){function t(t){for(var n,a,l=t[0],u=t[1],c=t[2],d=0,f=[];d<l.length;d++)a=l[d],Object.prototype.hasOwnProperty.call(o,a)&&o[a]&&f.push(o[a][0]),o[a]=0;for(n in u)Object.prototype.hasOwnProperty.call(u,n)&&(e[n]=u[n]);for(s&&s(t);f.length;)f.shift()();return i.push.apply(i,c||[]),r()}function r(){for(var e,t=0;t<i.length;t++){for(var r=i[t],n=!0,l=1;l<r.length;l++){var u=r[l];0!==o[u]&&(n=!1)}n&&(i.splice(t--,1),e=a(a.s=r[0]))}return e}var n={},o={17:0},i=[];function a(t){if(n[t])return n[t].exports;var r=n[t]={i:t,l:!1,exports:{}};return e[t].call(r.exports,r,r.exports,a),r.l=!0,r.exports}a.m=e,a.c=n,a.d=function(e,t,r){a.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},a.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},a.t=function(e,t){if(1&t&&(e=a(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(a.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)a.d(r,n,function(t){return e[t]}.bind(null,n));return r},a.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return a.d(t,"a",t),t},a.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},a.p="/dist/";var l=window.webpackJsonp=window.webpackJsonp||[],u=l.push.bind(l);l.push=t,l=l.slice();for(var c=0;c<l.length;c++)t(l[c]);var s=u;i.push([117,0]),r()}({117:function(e,t,r){"use strict";const{promisify:n}=r(14),o=r(3),i=r(7);r(184);const a=r(5),l=r(4),u=r(11),c=r(1),{Dialog:s}=u,{Key:d,config:f}=CloudCmd;let p,m,y;CloudCmd.TerminalRun=t;const C=i(),h=async()=>{const{prefix:e}=CloudCmd,t=CloudCmd.prefix+"/gritty"+"/gritty.js",r=e+"/dist/terminal.css",[n]=await o(l.parallel,[t,r]);if(n){const e=n.target.src.replace(window.location.href,"");return s.alert(`file ${e} could not be loaded`)}p=!0};function w(){CloudCmd.View.hide()}function g(e){e.emit("auth",f("username"),f("password")),e.on("reject",()=>{s.alert("Wrong credentials!")})}e.exports.init=async()=>{f("terminal")&&(c.show.load("top"),await CloudCmd.View(),await h())},e.exports.show=n((e={},t)=>{if(!p)return t(null,-1);f("terminal")&&(!function(e){const{cwd:t=u.getCurrentDirPath(),command:r,autoClose:n,closeMessage:o="Press any key to close Terminal..."}=e,i={cwd:t,env:{ACTIVE_DIR:u.getCurrentDirPath,PASSIVE_DIR:u.getNotCurrentDirPath,CURRENT_NAME:u.getCurrentName,CURRENT_PATH:u.getCurrentPath},prefix:CloudCmd.prefixSocket+"/gritty",socketPath:CloudCmd.prefix,fontFamily:"Droid Sans Mono",command:r,autoRestart:!1};let l=!1;const{socket:c,terminal:s}=gritty(document.body,i);y=c,m=s,m.onKey(({domEvent:e})=>{const{keyCode:t,shiftKey:r}=e;l&&w(),r&&t===d.ESC&&w()}),y.on("exit",e=>{if(C(e),n)return w();s.write("\n"+o),l=!0}),y.on("connect",a.with(g,c))}(e),CloudCmd.View.show(m.element,{afterShow:()=>{m.focus()},afterClose:()=>{t(null,C())}}))}),e.exports.hide=w}});
//# sourceMappingURL=terminal-run.js.map