UNPKG

tabby-quick-cmds

Version:
3 lines 31 kB
/*! For license information please see index.js.LICENSE.txt */ !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("@angular/core"),require("@angular/common"),require("@angular/forms"),require("@ng-bootstrap/ng-bootstrap"),require("terminus-core"),require("terminus-settings"),require("terminus-terminal"));else if("function"==typeof define&&define.amd)define(["@angular/core","@angular/common","@angular/forms","@ng-bootstrap/ng-bootstrap","terminus-core","terminus-settings","terminus-terminal"],t);else{var o="object"==typeof exports?t(require("@angular/core"),require("@angular/common"),require("@angular/forms"),require("@ng-bootstrap/ng-bootstrap"),require("terminus-core"),require("terminus-settings"),require("terminus-terminal")):t(e["@angular/core"],e["@angular/common"],e["@angular/forms"],e["@ng-bootstrap/ng-bootstrap"],e["terminus-core"],e["terminus-settings"],e["terminus-terminal"]);for(var n in o)("object"==typeof exports?exports:e)[n]=o[n]}}(global,((e,t,o,n,s,i,r)=>(()=>{var c={27:(e,t,o)=>{var n=o(817);e.exports=(n.default||n).apply(n,[])},721:(e,t,o)=>{var n=o(29);e.exports=(n.default||n).apply(n,[])},230:(e,t,o)=>{var n=o(172);e.exports=(n.default||n).apply(n,[])},774:(e,t,o)=>{var n=o(772);e.exports=(n.default||n).apply(n,[])},972:(e,t,o)=>{"use strict";o.r(t),o.d(t,{default:()=>c});var n=o(537),s=o.n(n),i=o(645),r=o.n(i)()(s());r.push([e.id,".list-group.connections-list{display:block;max-height:70vh;overflow-y:auto}.list-group.connections-list .list-group-item.active{background-color:#007bff !important;border-color:#007bff !important;color:#fff !important}.list-group.connections-list .list-group-item.active .text-muted{color:hsla(0,0%,100%,.8) !important}.quickCmd{flex:2 !important}.quickCmdContainer{display:flex !important}","",{version:3,sources:["webpack://./src/components/quickCmdsModal.component.scss"],names:[],mappings:"AAAA,6BACI,aAAA,CACA,eAAA,CACA,eAAA,CAGI,qDACI,mCAAA,CACA,+BAAA,CACA,qBAAA,CACA,iEACI,mCAAA,CAMhB,UACI,iBAAA,CAGJ,mBACI,uBAAA",sourcesContent:[".list-group.connections-list {\n display: block;\n max-height: 70vh;\n overflow-y: auto;\n\n .list-group-item {\n &.active {\n background-color: #007bff !important;\n border-color: #007bff !important;\n color: white !important;\n .text-muted {\n color: rgba(255, 255, 255, 0.8) !important;\n }\n }\n }\n}\n\n.quickCmd {\n flex: 2 !important\n}\n\n.quickCmdContainer {\n display: flex !important\n}\n"],sourceRoot:""}]);const c=r},645:e=>{"use strict";e.exports=function(e){var t=[];return t.toString=function(){return this.map((function(t){var o="",n=void 0!==t[5];return t[4]&&(o+="@supports (".concat(t[4],") {")),t[2]&&(o+="@media ".concat(t[2]," {")),n&&(o+="@layer".concat(t[5].length>0?" ".concat(t[5]):""," {")),o+=e(t),n&&(o+="}"),t[2]&&(o+="}"),t[4]&&(o+="}"),o})).join("")},t.i=function(e,o,n,s,i){"string"==typeof e&&(e=[[null,e,void 0]]);var r={};if(n)for(var c=0;c<this.length;c++){var a=this[c][0];null!=a&&(r[a]=!0)}for(var l=0;l<e.length;l++){var d=[].concat(e[l]);n&&r[d[0]]||(void 0!==i&&(void 0===d[5]||(d[1]="@layer".concat(d[5].length>0?" ".concat(d[5]):""," {").concat(d[1],"}")),d[5]=i),o&&(d[2]?(d[1]="@media ".concat(d[2]," {").concat(d[1],"}"),d[2]=o):d[2]=o),s&&(d[4]?(d[1]="@supports (".concat(d[4],") {").concat(d[1],"}"),d[4]=s):d[4]="".concat(s)),t.push(d))}},t}},537:e=>{"use strict";e.exports=function(e){var t=e[1],o=e[3];if(!o)return t;if("function"==typeof btoa){var n=btoa(unescape(encodeURIComponent(JSON.stringify(o)))),s="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(n),i="/*# ".concat(s," */"),r=o.sources.map((function(e){return"/*# sourceURL=".concat(o.sourceRoot||"").concat(e," */")}));return[t].concat(r).concat([i]).join("\n")}return[t].join("\n")}},817:(e,t,o)=>{o(55),e.exports=function(e){return""+'<div class="modal-body"><div class="form-group"><label>Name</label><input class="form-control" type="text" placeholder="Name" autofocus [(ngModel)]="command.name"></div><div class="form-group"><label>Text</label><textarea class="form-control" rows="6" style="white-space: pre-line" placeholder="Text to be sent" [(ngModel)]="command.text"></textarea></div><div class="form-group"><label>Group</label><select class="form-control" [(ngModel)]="command.group"><option [value]="">Ungrouped</option><option *ngFor="let group of allGroups" [value]="group">{{ group }}</option></select></div><div class="form-line"><div class="header"><div class="title">Append \'\\n\'</div><div class="description">Automatically append a \'\\n\' char to the end</div></div><toggle [(ngModel)]="command.appendCR"></toggle></div></div><div class="modal-footer"><button class="btn btn-outline-primary" (click)="save()">Save</button><button class="btn btn-outline-danger" (click)="cancel()">Cancel</button></div>'}},29:(e,t,o)=>{o(55),e.exports=function(e){return""+'<div class="modal-body"><input class="form-control" [type]="password ? &quot;password&quot; : &quot;text&quot;" autofocus [(ngModel)]="value" #input [placeholder]="prompt" (keyup.enter)="ok()" (keyup.esc)="cancel()"></div>'}},172:(e,t,o)=>{o(55),e.exports=function(e){return""+'<div class="modal-body"><div class="quickCmdContainer"><input class="form-control quickCmd" type="text" [(ngModel)]="quickCmd" autofocus placeholder="Ctrl + Enter send to all" (ngModelChange)="refresh()" (keyup.enter)="quickSend()" (keyup.control.enter)="quickSendAll()"><toggle class="ml-1" title="Automatically append a \'\\n\' char to the end" [(ngModel)]="appendCR"></toggle></div><div class="list-group mt-3 connections-list"><ng-container *ngFor="let group of childGroups"> <div class="list-group-item list-group-item-action d-flex align-items-center" (click)="clickGroup(group, $event)" title="Shift + Click send all to active tab\nCtrl + Shift + Click send all to all tabs" [class.active]="childGroups.indexOf(group) === selectedGroupIndex &amp;&amp; selectedCmdIndex === -1"><div class="fa fa-fw fa-chevron-right" *ngIf="groupCollapsed[group.name]"></div><div class="fa fa-fw fa-chevron-down" *ngIf="!groupCollapsed[group.name]"></div><div class="ml-2">{{group.name || "Ungrouped"}}</div></div><ng-container *ngIf="!groupCollapsed[group.name]"><div class="list-group-item list-group-item-action pl-5 d-flex align-items-center" *ngFor="let cmd of group.cmds" (click)="send(cmd, $event)" (contextmenu)="copyCommand(cmd, $event)" title="Ctrl + Click send to all\nRight Click to copy command" [class.active]="childGroups.indexOf(group) === selectedGroupIndex &amp;&amp; group.cmds.indexOf(cmd) === selectedCmdIndex"><div class="mr-auto"><div>{{cmd.name}}</div><div class="text-muted">{{cmd.text}}{{cmd.appendCR ? "\\\\n" : ""}}</div></div></div></ng-container></ng-container></div></div>'}},772:(e,t,o)=>{o(55),e.exports=function(e){return""+'<h3>Quick Commands</h3><div class="form-group"><button class="btn btn-outline-primary" (click)="createCommand()"><div class="fa fa-fw fa-globe"></div><span class="ml-2">Add command</span></button></div><div class="form-group"><input class="form-control quickCmd" type="text" [(ngModel)]="quickCmd" autofocus placeholder="enter to filter" (ngModelChange)="refresh()" (keyup.esc)="cancelFilter()"></div><div class="list-group mt-3 mb-3"><ng-container *ngFor="let group of childGroups"> <div class="list-group-item list-group-item-action d-flex align-items-center" (click)="groupCollapsed[group.name] = !groupCollapsed[group.name]"><div class="fa fa-fw fa-chevron-right" *ngIf="groupCollapsed[group.name]"></div><div class="fa fa-fw fa-chevron-down" *ngIf="!groupCollapsed[group.name]"></div><span class="ml-3 mr-auto">{{group.name || "Ungrouped"}}</span><button class="btn btn-outline-info ml-2" (click)="editGroup(group)"><i class="fa fa-pencil"></i></button><button class="btn btn-outline-danger ml-1" (click)="deleteGroup(group)"><i class="fa fa-trash-can"> </i></button></div><ng-container *ngIf="!groupCollapsed[group.name]"><div class="list-group-item pl-5 d-flex align-items-center" *ngFor="let cmd of group.cmds"> <div class="mr-auto"><div>{{cmd.name}}</div><div class="text-muted">{{cmd.text}} {{cmd.appendCR ? "\\\\n" : ""}}</div></div><button class="btn btn-outline-info ml-2" (click)="editCommand(cmd)"><i class="fa fa-pencil"></i></button><button class="btn btn-outline-danger ml-1" (click)="deleteCommand(cmd)"><i class="fa fa-trash-can"> </i></button></div></ng-container></ng-container></div>'}},55:(e,t,o)=>{"use strict";var n=Object.prototype.hasOwnProperty;function s(e,t){return Array.isArray(e)?function(e,t){for(var o,n="",i="",r=Array.isArray(t),c=0;c<e.length;c++)(o=s(e[c]))&&(r&&t[c]&&(o=a(o)),n=n+i+o,i=" ");return n}(e,t):e&&"object"==typeof e?function(e){var t="",o="";for(var s in e)s&&e[s]&&n.call(e,s)&&(t=t+o+s,o=" ");return t}(e):e||""}function i(e){if(!e)return"";if("object"==typeof e){var t="";for(var o in e)n.call(e,o)&&(t=t+o+":"+e[o]+";");return t}return e+""}function r(e,t,o,n){if(!1===t||null==t||!t&&("class"===e||"style"===e))return"";if(!0===t)return" "+(n?e:e+'="'+e+'"');var s=typeof t;return"object"!==s&&"function"!==s||"function"!=typeof t.toJSON||(t=t.toJSON()),"string"==typeof t||(t=JSON.stringify(t),o||-1===t.indexOf('"'))?(o&&(t=a(t))," "+e+'="'+t+'"'):" "+e+"='"+t.replace(/'/g,"&#39;")+"'"}t.merge=function e(t,o){if(1===arguments.length){for(var n=t[0],s=1;s<t.length;s++)n=e(n,t[s]);return n}for(var r in o)if("class"===r){var c=t[r]||[];t[r]=(Array.isArray(c)?c:[c]).concat(o[r]||[])}else if("style"===r){c=(c=i(t[r]))&&";"!==c[c.length-1]?c+";":c;var a=i(o[r]);a=a&&";"!==a[a.length-1]?a+";":a,t[r]=c+a}else t[r]=o[r];return t},t.classes=s,t.style=i,t.attr=r,t.attrs=function(e,t){var o="";for(var c in e)if(n.call(e,c)){var a=e[c];if("class"===c){o=r(c,a=s(a),!1,t)+o;continue}"style"===c&&(a=i(a)),o+=r(c,a,!1,t)}return o};var c=/["&<>]/;function a(e){var t=""+e,o=c.exec(t);if(!o)return e;var n,s,i,r="";for(n=o.index,s=0;n<t.length;n++){switch(t.charCodeAt(n)){case 34:i="&quot;";break;case 38:i="&amp;";break;case 60:i="&lt;";break;case 62:i="&gt;";break;default:continue}s!==n&&(r+=t.substring(s,n)),s=n+1,r+=i}return s!==n?r+t.substring(s,n):r}t.escape=a,t.rethrow=function e(t,n,s,i){if(!(t instanceof Error))throw t;if(!("undefined"==typeof window&&n||i))throw t.message+=" on line "+s,t;var r,c,a,l;try{i=i||o(147).readFileSync(n,{encoding:"utf8"}),r=3,c=i.split("\n"),a=Math.max(s-r,0),l=Math.min(c.length,s+r)}catch(o){return t.message+=" - could not read from "+n+" ("+o.message+")",void e(t,null,s)}r=c.slice(a,l).map((function(e,t){var o=t+a+1;return(o==s?" > ":" ")+o+"| "+e})).join("\n"),t.path=n;try{t.message=(n||"Pug")+":"+s+"\n"+r+"\n\n"+t.message}catch(e){}throw t}},812:e=>{e.exports='<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 1000 1000" enable-background="new 0 0 1000 1000" xml:space="preserve"><metadata> Svg Vector Icons : http://www.onlinewebfonts.com/icon </metadata><g><path d="M286.1,422.2h-79.4c-16.2,0-29.4-13.2-29.4-29.4v-54.4c0-16.2,13.2-29.4,29.4-29.4h79.4c16.2,0,29.4,13.2,29.4,29.4v54.4C315.5,409,302.3,422.2,286.1,422.2z"></path><path d="M455.2,422.2h-79.4c-16.2,0-29.4-13.2-29.4-29.4v-54.4c0-16.2,13.2-29.4,29.4-29.4h79.4c16.2,0,29.4,13.2,29.4,29.4v54.4C484.6,409,471.3,422.2,455.2,422.2z"></path><path d="M624.2,422.2h-79.4c-16.2,0-29.4-13.2-29.4-29.4v-54.4c0-16.2,13.2-29.4,29.4-29.4h79.4c16.2,0,29.4,13.2,29.4,29.4v54.4C653.6,409,640.4,422.2,624.2,422.2z"></path><path d="M793.2,422.2h-79.4c-16.2,0-29.4-13.2-29.4-29.4v-54.4c0-16.2,13.2-29.4,29.4-29.4h79.4c16.2,0,29.4,13.2,29.4,29.4v54.4C822.6,409,809.4,422.2,793.2,422.2z"></path><path d="M305,573.6h-79.4c-16.2,0-29.4-13.2-29.4-29.4v-54.4c0-16.2,13.2-29.4,29.4-29.4H305c16.2,0,29.4,13.2,29.4,29.4v54.4C334.4,560.4,321.2,573.6,305,573.6z"></path><path d="M461.5,573.6h-79.4c-16.2,0-29.4-13.2-29.4-29.4v-54.4c0-16.2,13.2-29.4,29.4-29.4h79.4c16.2,0,29.4,13.2,29.4,29.4v54.4C490.9,560.4,477.6,573.6,461.5,573.6z"></path><path d="M617.9,573.6h-79.4c-16.2,0-29.4-13.2-29.4-29.4v-54.4c0-16.2,13.2-29.4,29.4-29.4h79.4c16.2,0,29.4,13.2,29.4,29.4v54.4C647.3,560.4,634.1,573.6,617.9,573.6z"></path><path d="M774.4,573.6H695c-16.2,0-29.4-13.2-29.4-29.4v-54.4c0-16.2,13.2-29.4,29.4-29.4h79.4c16.2,0,29.4,13.2,29.4,29.4v54.4C803.8,560.4,790.6,573.6,774.4,573.6z"></path><path d="M741.1,732.1H258.9c-16.2,0-29.4-13.2-29.4-29.4v-35.3c0-16.2,13.2-29.4,29.4-29.4h482.2c16.2,0,29.4,13.2,29.4,29.4v35.3C770.5,718.9,757.3,732.1,741.1,732.1z"></path><path d="M500,39.4c62.2,0,122.5,12.2,179.3,36.2c54.8,23.2,104.1,56.4,146.4,98.7s75.5,91.6,98.7,146.4c24,56.8,36.2,117.1,36.2,179.3c0,62.2-12.2,122.5-36.2,179.3c-23.2,54.8-56.4,104.1-98.7,146.4s-91.6,75.5-146.4,98.7c-56.8,24-117.1,36.2-179.3,36.2c-62.2,0-122.5-12.2-179.3-36.2c-54.8-23.2-104.1-56.4-146.4-98.7s-75.5-91.6-98.7-146.4c-24-56.8-36.2-117.1-36.2-179.3c0-62.2,12.2-122.5,36.2-179.3c23.2-54.8,56.4-104.1,98.7-146.4s91.6-75.5,146.4-98.7C377.5,51.6,437.8,39.4,500,39.4 M500,10C229.4,10,10,229.4,10,500s219.4,490,490,490c270.6,0,490-219.4,490-490S770.6,10,500,10L500,10z"></path></g></svg>'},835:(e,t,o)=>{var n=o(972);n&&n.__esModule&&(n=n.default),e.exports="string"==typeof n?n:n.toString()},619:function(e,t,o){"use strict";var n=this&&this.__decorate||function(e,t,o,n){var s,i=arguments.length,r=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,o):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(e,t,o,n);else for(var c=e.length-1;c>=0;c--)(s=e[c])&&(r=(i<3?s(r):i>3?s(t,o,r):s(t,o))||r);return i>3&&r&&Object.defineProperty(t,o,r),r},s=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},i=this&&this.__awaiter||function(e,t,o,n){return new(o||(o=Promise))((function(s,i){function r(e){try{a(n.next(e))}catch(e){i(e)}}function c(e){try{a(n.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?s(e.value):(t=e.value,t instanceof o?t:new o((function(e){e(t)}))).then(r,c)}a((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.ButtonProvider=void 0;const r=o(900),c=o(571),a=o(243),l=o(589);let d=class extends a.ToolbarButtonProvider{constructor(e,t){super(),this.ngbModal=e,t.matchedHotkey.subscribe((e=>i(this,void 0,void 0,(function*(){"qc"===e&&this.activate()}))))}activate(){this.ngbModal.open(l.QuickCmdsModalComponent)}provide(){return[{icon:o(812),weight:5,title:"Quick commands",touchBarNSImage:"NSTouchBarComposeTemplate",click:()=>i(this,void 0,void 0,(function*(){this.activate()}))}]}};d=n([(0,r.Injectable)(),s("design:paramtypes",[c.NgbModal,a.HotkeysService])],d),t.ButtonProvider=d},704:function(e,t,o){"use strict";var n=this&&this.__decorate||function(e,t,o,n){var s,i=arguments.length,r=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,o):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(e,t,o,n);else for(var c=e.length-1;c>=0;c--)(s=e[c])&&(r=(i<3?s(r):i>3?s(t,o,r):s(t,o))||r);return i>3&&r&&Object.defineProperty(t,o,r),r},s=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};Object.defineProperty(t,"__esModule",{value:!0}),t.EditCommandModalComponent=void 0;const i=o(900),r=o(571);let c=class{constructor(e){this.modalInstance=e,this.allGroups=[]}save(){this.modalInstance.close(this.command)}cancel(){this.modalInstance.dismiss()}};c=n([(0,i.Component)({template:o(27)}),s("design:paramtypes",[r.NgbActiveModal])],c),t.EditCommandModalComponent=c},491:function(e,t,o){"use strict";var n=this&&this.__decorate||function(e,t,o,n){var s,i=arguments.length,r=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,o):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(e,t,o,n);else for(var c=e.length-1;c>=0;c--)(s=e[c])&&(r=(i<3?s(r):i>3?s(t,o,r):s(t,o))||r);return i>3&&r&&Object.defineProperty(t,o,r),r},s=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};Object.defineProperty(t,"__esModule",{value:!0}),t.PromptModalComponent=void 0;const i=o(900),r=o(571);let c=class{constructor(e){this.modalInstance=e}ngOnInit(){this.input.nativeElement.focus()}ok(){this.modalInstance.close(this.value)}cancel(){this.modalInstance.close("")}};n([(0,i.Input)(),s("design:type",String)],c.prototype,"value",void 0),n([(0,i.Input)(),s("design:type",Boolean)],c.prototype,"password",void 0),n([(0,i.ViewChild)("input"),s("design:type",i.ElementRef)],c.prototype,"input",void 0),c=n([(0,i.Component)({template:o(721)}),s("design:paramtypes",[r.NgbActiveModal])],c),t.PromptModalComponent=c},589:function(e,t,o){"use strict";var n=this&&this.__decorate||function(e,t,o,n){var s,i=arguments.length,r=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,o):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(e,t,o,n);else for(var c=e.length-1;c>=0;c--)(s=e[c])&&(r=(i<3?s(r):i>3?s(t,o,r):s(t,o))||r);return i>3&&r&&Object.defineProperty(t,o,r),r},s=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},i=this&&this.__awaiter||function(e,t,o,n){return new(o||(o=Promise))((function(s,i){function r(e){try{a(n.next(e))}catch(e){i(e)}}function c(e){try{a(n.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?s(e.value):(t=e.value,t instanceof o?t:new o((function(e){e(t)}))).then(r,c)}a((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.QuickCmdsModalComponent=void 0;const r=o(900),c=o(571),a=o(571),l=o(243),d=o(704),p=o(501);let u=class{constructor(e,t,o,n){this.modalInstance=e,this.ngbModal=t,this.config=o,this.app=n,this.groupCollapsed={},this.expandedGroups={},this.flattenedItems=[],this.selectedGroupIndex=0,this.selectedCmdIndex=-1}ngOnInit(){this.cmds=this.config.store.qc.cmds,this.appendCR=!0,this.refresh(),this.updateFlattenedItems()}quickSend(){const e=this.getSelectedItem();if(e&&"cmd"===e.type)this.send(e.cmd,new MouseEvent("click"));else{let e={name:"",text:this.quickCmd,appendCR:!0};this._send(this.app.activeTab,e)}this.close()}quickSendAll(){const e=this.getSelectedItem();if(e&&"cmd"===e.type)this.send(e.cmd,new MouseEvent("click",{ctrlKey:!0}));else{let e={name:"",text:this.quickCmd,appendCR:!0};this._sendAll(e)}this.close()}sleep(e){return new Promise((t=>setTimeout(t,e)))}_send(e,t){return i(this,void 0,void 0,(function*(){if(e instanceof l.SplitTabComponent&&this._send(e.getFocusedTab(),t),e instanceof p.BaseTerminalTabComponent){let o=e;console.log("Current title:",o.title);let n="\n",s="\\",i="&&";o.title.includes("cmd.exe")?(n="\r\n",s="^",i="&"):o.title.includes("powershell")&&(n="\r\n",s="`",i=";");let r=t.text.split(/(?:\r\n|\r|\n)/),c=[];for(let e of r)if(console.log("Sending "+e),""!==e)if(e.startsWith("\\s")){if(console.log("Processing sleep command"),!t.appendCR)continue;e=e.replace("\\s","");let o=parseInt(e);yield this.sleep(o),console.log("sleep time: "+o)}else e.startsWith("\\x")&&(e=e.replace(/\\x([0-9a-f]{2})/gi,(function(e,t){return String.fromCharCode(parseInt(t,16))}))),t.appendCR?(yield o.sendInput(e),yield this.sleep(50),yield o.sendInput(n)):c.push(e);if(c.length>0){let e;e=o.title.includes("powershell")?c.join(" ; "):c.join(" "+i+s+n),console.log("New command text:",e),yield o.sendInput(e)}}}))}_sendAll(e){for(let t of this.app.tabs)if(t instanceof l.SplitTabComponent)for(let o of t.getAllTabs())this._send(o,e);else this._send(t,e)}close(){this.modalInstance.close(),this.app.activeTab.emitFocused()}send(e,t){t.ctrlKey?this._sendAll(e):this._send(this.app.activeTab,e),this.close()}edit(e){const t=this.ngbModal.open(d.EditCommandModalComponent);t.componentInstance.allGroups=Array.from(new Set(this.cmds.map((e=>e.group||"")))),t.componentInstance.command=e?Object.assign(Object.assign({},e),{group:e.group||""}):{name:"",text:"",appendCR:!0},t.result.then((t=>{e?Object.assign(e,t):this.cmds.push(t),this.config.save(),this.refresh()}),(()=>null))}clickGroup(e,t){if(t.shiftKey)if(t.ctrlKey)for(let t of e.cmds)this._sendAll(t);else for(let t of e.cmds)this._send(this.app.activeTab,t);else this.groupCollapsed[e.name]=!this.groupCollapsed[e.name],this.updateFlattenedItems(),this.groupCollapsed[e.name]&&this.selectedGroupIndex===this.childGroups.indexOf(e)&&(this.selectedCmdIndex=-1),this.selectedGroupIndex=this.childGroups.indexOf(e)}refresh(){this.childGroups=[],this.flattenedItems=[];let e=this.cmds.filter((e=>!this.quickCmd||(e.name+e.group+e.text).toLowerCase().includes(this.quickCmd.toLowerCase())));for(let t of e){t.group=t.group||"";let e=this.childGroups.find((e=>e.name===t.group));e||(e={name:t.group,cmds:[]},this.childGroups.push(e)),e.cmds.push(t)}if(this.quickCmd)for(const e of this.childGroups)this.groupCollapsed[e.name]=!1;else{for(const e of this.childGroups)this.groupCollapsed[e.name]=!0;this.childGroups.length>0&&(this.groupCollapsed[this.childGroups[0].name]=!1)}this.updateFlattenedItems(),this.selectedGroupIndex=0,this.selectedCmdIndex=-1,this.quickCmd&&e.length>0&&(this.selectedCmdIndex=0)}updateFlattenedItems(){if(this.flattenedItems=[],this.quickCmd){const e=this.cmds.filter((e=>(e.name+(e.group||"")+e.text).toLowerCase().includes(this.quickCmd.toLowerCase()))),t=new Set;e.forEach((e=>t.add(e.group||"")));for(const o of this.childGroups)if(t.has(o.name)){this.flattenedItems.push({type:"group",group:o});for(const t of o.cmds)e.includes(t)&&this.flattenedItems.push({type:"cmd",cmd:t})}}else for(let e of this.childGroups)if(this.flattenedItems.push({type:"group",group:e}),!this.groupCollapsed[e.name])for(let t of e.cmds)this.flattenedItems.push({type:"cmd",cmd:t})}copyCommand(e,t){t.preventDefault(),navigator.clipboard.writeText(e.text).then((()=>{console.log("Command text copied to clipboard"),this.showCopySuccessMessage()})).catch((e=>{console.error("Failed to copy text: ",e)}))}showCopySuccessMessage(){const e=document.createElement("div");e.textContent="Copied successfully",e.style.cssText="position: fixed; top: 20px; left: 50%; transform: translateX(-50%); background-color: rgba(0, 0, 0, 0.8); color: white; padding: 8px 16px; border-radius: 4px; z-index: 9999;",document.body.appendChild(e),setTimeout((()=>{e.style.opacity="0",e.style.transition="opacity 0.3s",setTimeout((()=>document.body.removeChild(e)),300)}),1500)}handleKeyDown(e){if(console.log("KeyDown event:",{key:e.key,type:e.type,target:e.target,activeElement:document.activeElement}),e.ctrlKey&&"c"===e.key){e.preventDefault();const t=this.getSelectedItem();t&&"cmd"===t.type&&navigator.clipboard.writeText(t.cmd.text).then((()=>{console.log("Command text copied to clipboard")})).catch((e=>{console.error("Failed to copy text: ",e)}))}else if("ArrowUp"===e.key||"ArrowDown"===e.key){e.preventDefault();const t="ArrowUp"===e.key?-1:1,o=(e,t)=>{let o=e+t;for(;o>=0&&o<this.flattenedItems.length;){const e=this.flattenedItems[o];if("group"===e.type)return o;if("cmd"===e.type){const t=this.childGroups.find((t=>t.cmds.includes(e.cmd)));if(t&&!this.groupCollapsed[t.name])return o}o+=t}return-1},n=o(this.getSelectedIndex(),t);if(n>=0){const e=this.flattenedItems[n];if("group"===e.type)this.selectedGroupIndex=this.childGroups.indexOf(e.group),this.selectedCmdIndex=-1;else{const t=this.childGroups.find((t=>t.cmds.includes(e.cmd)));this.selectedGroupIndex=this.childGroups.indexOf(t),this.selectedCmdIndex=t.cmds.indexOf(e.cmd)}requestAnimationFrame((()=>{const e=document.querySelector(".list-group-item.active");e&&e.scrollIntoView({behavior:"smooth",block:"nearest"})}))}}else if("Escape"===e.key){const e=document.querySelector(".quickCmd");e&&(console.log("Focusing search input on Escape"),e.focus(),this.selectedGroupIndex=0,this.selectedCmdIndex=-1,this.quickCmd="",this.refresh())}else if(" "===e.key){const t=document.querySelector(".quickCmd"),o=document.activeElement===t;if(!this.quickCmd||!o){e.preventDefault();const t=this.getSelectedItem();t&&"group"===t.type&&(this.groupCollapsed[t.group.name]=!this.groupCollapsed[t.group.name],this.updateFlattenedItems(),this.selectedCmdIndex=-1)}}else if("ArrowLeft"===e.key||"ArrowRight"===e.key){const t=this.getSelectedItem();t&&"group"===t.type&&(e.preventDefault(),"ArrowLeft"===e.key?this.groupCollapsed[t.group.name]=!0:"ArrowRight"===e.key&&(this.groupCollapsed[t.group.name]=!1),this.updateFlattenedItems())}else if("Enter"===e.key){e.preventDefault();const t=this.getSelectedItem();t&&"cmd"===t.type&&this.send(t.cmd,new MouseEvent("click"))}}getSelectedIndex(){for(let e=0;e<this.flattenedItems.length;e++){const t=this.flattenedItems[e];if("group"===t.type){if(this.childGroups.indexOf(t.group)===this.selectedGroupIndex&&-1===this.selectedCmdIndex)return e}else{const o=this.childGroups.find((e=>e.cmds.includes(t.cmd)));if(o&&this.childGroups.indexOf(o)===this.selectedGroupIndex&&o.cmds.indexOf(t.cmd)===this.selectedCmdIndex)return e}}return-1}getSelectedItem(){return this.flattenedItems[this.getSelectedIndex()]}};u=n([(0,r.Component)({template:o(230),styles:[o(835)],host:{"(keydown)":"handleKeyDown($event)"}}),s("design:paramtypes",[c.NgbActiveModal,a.NgbModal,l.ConfigService,l.AppService])],u),t.QuickCmdsModalComponent=u},864:function(e,t,o){"use strict";var n=this&&this.__decorate||function(e,t,o,n){var s,i=arguments.length,r=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,o):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(e,t,o,n);else for(var c=e.length-1;c>=0;c--)(s=e[c])&&(r=(i<3?s(r):i>3?s(t,o,r):s(t,o))||r);return i>3&&r&&Object.defineProperty(t,o,r),r},s=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};Object.defineProperty(t,"__esModule",{value:!0}),t.QuickCmdsSettingsTabComponent=void 0;const i=o(900),r=o(571),c=o(243),a=o(704),l=o(491);let d=class{constructor(e,t){this.config=e,this.ngbModal=t,this.groupCollapsed={},this.commands=this.config.store.qc.cmds,this.refresh()}createCommand(){let e=this.ngbModal.open(a.EditCommandModalComponent);e.componentInstance.command={name:"",text:"",appendCR:!0},e.componentInstance.allGroups=Array.from(new Set(this.commands.map((e=>e.group||"")))).filter((e=>e)),e.result.then((e=>{this.commands.push(e),this.config.store.qc.cmds=this.commands,this.config.save(),this.refresh()}))}editCommand(e){let t=this.ngbModal.open(a.EditCommandModalComponent);t.componentInstance.command=Object.assign(Object.assign({},e),{group:e.group||"Ungrouped"}),t.componentInstance.allGroups=Array.from(new Set(this.commands.map((e=>e.group||"")))).filter((e=>e)),t.result.then((t=>{"Ungrouped"===t.group&&(t.group=null),Object.assign(e,t),this.config.save(),this.refresh()}))}deleteCommand(e){confirm(`Delete "${e.name}"?`)&&(this.commands=this.commands.filter((t=>t!==e)),this.config.store.qc.cmds=this.commands,this.config.save(),this.refresh())}editGroup(e){let t=this.ngbModal.open(l.PromptModalComponent);t.componentInstance.prompt="New group name",t.componentInstance.value=e.name,t.result.then((t=>{if(t){for(let o of this.commands.filter((t=>t.group===e.name)))o.group=t;this.config.save(),this.refresh()}}))}deleteGroup(e){if(confirm(`Delete "${e}"?`)){for(let t of this.commands.filter((t=>t.group===e.name)))t.group=null;this.config.save(),this.refresh()}}cancelFilter(){this.quickCmd="",this.refresh()}refresh(){this.childGroups=[];let e=this.commands;this.quickCmd&&(e=e.filter((e=>(e.name+e.group+e.text).toLowerCase().includes(this.quickCmd))));for(let t of e){t.group=t.group||null;let e=this.childGroups.find((e=>e.name===t.group));e||(e={name:t.group,cmds:[]},this.childGroups.push(e)),e.cmds.push(t)}}};d=n([(0,i.Component)({template:o(774)}),s("design:paramtypes",[c.ConfigService,r.NgbModal])],d),t.QuickCmdsSettingsTabComponent=d},913:(e,t,o)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.QuickCmdsConfigProvider=void 0;const n=o(243);class s extends n.ConfigProvider{constructor(){super(...arguments),this.defaults={qc:{cmds:[]},hotkeys:{qc:["Alt-Q"]}},this.platformDefaults={}}}t.QuickCmdsConfigProvider=s},607:function(e,t,o){"use strict";var n=this&&this.__decorate||function(e,t,o,n){var s,i=arguments.length,r=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,o):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(e,t,o,n);else for(var c=e.length-1;c>=0;c--)(s=e[c])&&(r=(i<3?s(r):i>3?s(t,o,r):s(t,o))||r);return i>3&&r&&Object.defineProperty(t,o,r),r};Object.defineProperty(t,"__esModule",{value:!0});const s=o(900),i=o(848),r=o(161),c=o(571),a=o(243),l=o(243),d=o(266),p=o(704),u=o(589),m=o(864),f=o(491),h=o(619),g=o(913),v=o(310);let C=class{};C=n([(0,s.NgModule)({imports:[c.NgbModule,i.CommonModule,r.FormsModule,l.default],providers:[{provide:a.ToolbarButtonProvider,useClass:h.ButtonProvider,multi:!0},{provide:a.ConfigProvider,useClass:g.QuickCmdsConfigProvider,multi:!0},{provide:d.SettingsTabProvider,useClass:v.QuickCmdsSettingsTabProvider,multi:!0}],entryComponents:[f.PromptModalComponent,p.EditCommandModalComponent,u.QuickCmdsModalComponent,m.QuickCmdsSettingsTabComponent],declarations:[f.PromptModalComponent,p.EditCommandModalComponent,u.QuickCmdsModalComponent,m.QuickCmdsSettingsTabComponent]})],C),t.default=C},310:function(e,t,o){"use strict";var n=this&&this.__decorate||function(e,t,o,n){var s,i=arguments.length,r=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,o):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(e,t,o,n);else for(var c=e.length-1;c>=0;c--)(s=e[c])&&(r=(i<3?s(r):i>3?s(t,o,r):s(t,o))||r);return i>3&&r&&Object.defineProperty(t,o,r),r};Object.defineProperty(t,"__esModule",{value:!0}),t.QuickCmdsSettingsTabProvider=void 0;const s=o(900),i=o(266),r=o(864);let c=class extends i.SettingsTabProvider{constructor(){super(...arguments),this.id="qc",this.title="Quick Commands"}getComponentType(){return r.QuickCmdsSettingsTabComponent}};c=n([(0,s.Injectable)()],c),t.QuickCmdsSettingsTabProvider=c},147:e=>{"use strict";e.exports=require("fs")},848:e=>{"use strict";e.exports=t},900:t=>{"use strict";t.exports=e},161:e=>{"use strict";e.exports=o},571:e=>{"use strict";e.exports=n},243:e=>{"use strict";e.exports=s},266:e=>{"use strict";e.exports=i},501:e=>{"use strict";e.exports=r}},a={};function l(e){var t=a[e];if(void 0!==t)return t.exports;var o=a[e]={id:e,exports:{}};return c[e].call(o.exports,o,o.exports,l),o.exports}return l.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return l.d(t,{a:t}),t},l.d=(e,t)=>{for(var o in t)l.o(t,o)&&!l.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},l.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),l.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},l(607)})())); //# sourceMappingURL=index.js.map