UNPKG

tabby-quick-cmds

Version:
3 lines 49.3 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("tabby-core"),require("tabby-settings"),require("tabby-terminal"));else if("function"==typeof define&&define.amd)define(["@angular/core","@angular/common","@angular/forms","@ng-bootstrap/ng-bootstrap","tabby-core","tabby-settings","tabby-terminal"],t);else{var o="object"==typeof exports?t(require("@angular/core"),require("@angular/common"),require("@angular/forms"),require("@ng-bootstrap/ng-bootstrap"),require("tabby-core"),require("tabby-settings"),require("tabby-terminal")):t(e["@angular/core"],e["@angular/common"],e["@angular/forms"],e["@ng-bootstrap/ng-bootstrap"],e["tabby-core"],e["tabby-settings"],e["tabby-terminal"]);for(var n in o)("object"==typeof exports?exports:e)[n]=o[n]}}(global,(e,t,o,n,s,i,r)=>(()=>{var a={490(e,t,o){var n=o(715);e.exports=(n.default||n).apply(n,[])},430(e,t,o){var n=o(731);e.exports=(n.default||n).apply(n,[])},951(e,t,o){var n=o(480);e.exports=(n.default||n).apply(n,[])},585(e,t,o){var n=o(716);e.exports=(n.default||n).apply(n,[])},286(e,t,o){var n=o(819);e.exports=(n.default||n).apply(n,[])},805(e,t,o){"use strict";o.r(t),o.d(t,{default:()=>a});var n=o(354),s=o.n(n),i=o(314),r=o.n(i)()(s());r.push([e.id,":host .input-group{display:flex !important;width:100% !important;margin-bottom:1rem}:host .input-group .form-control{flex:1 1 auto !important;width:1% !important}:host .input-group .btn{flex:0 0 auto !important}:host .list-group{max-height:60vh;overflow-y:auto}","",{version:3,sources:["webpack://./src/components/quickCmdsModal.component.scss"],names:[],mappings:"AACE,mBACE,uBAAA,CACA,qBAAA,CACA,kBAAA,CAEA,iCACE,wBAAA,CACA,mBAAA,CAGF,wBACE,wBAAA,CAIJ,kBACE,eAAA,CACA,eAAA",sourcesContent:[":host {\r\n .input-group {\r\n display: flex !important;\r\n width: 100% !important;\r\n margin-bottom: 1rem;\r\n\r\n .form-control {\r\n flex: 1 1 auto !important;\r\n width: 1% !important;\r\n }\r\n\r\n .btn {\r\n flex: 0 0 auto !important;\r\n }\r\n }\r\n\r\n .list-group {\r\n max-height: 60vh;\r\n overflow-y: auto;\r\n }\r\n}"],sourceRoot:""}]);const a=r},244(e,t,o){"use strict";o.r(t),o.d(t,{default:()=>a});var n=o(354),s=o.n(n),i=o(314),r=o.n(i)()(s());r.push([e.id,".list-group-item{position:relative;padding-right:100px}.command-buttons{position:absolute;top:50%;right:10px;transform:translateY(-50%);display:flex;gap:5px}.ssh-profile-list{max-height:220px;overflow:auto}","",{version:3,sources:["webpack://./src/components/quickCmdsSettingsTab.component.scss"],names:[],mappings:"AAAA,iBACI,iBAAA,CACA,mBAAA,CAGJ,iBACI,iBAAA,CACA,OAAA,CACA,UAAA,CACA,0BAAA,CACA,YAAA,CACA,OAAA,CAGJ,kBACI,gBAAA,CACA,aAAA",sourcesContent:[".list-group-item {\r\n position: relative;\r\n padding-right: 100px; /* Add padding to prevent text from overlapping with buttons */\r\n}\r\n\r\n.command-buttons {\n position: absolute;\r\n top: 50%;\r\n right: 10px;\r\n transform: translateY(-50%);\r\n display: flex;\r\n gap: 5px; /* Add some space between the buttons */\n}\n\n.ssh-profile-list {\n max-height: 220px;\n overflow: auto;\n}\n"],sourceRoot:""}]);const a=r},314(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 a=0;a<this.length;a++){var l=this[a][0];null!=l&&(r[l]=!0)}for(var c=0;c<e.length;c++){var d=[].concat(e[c]);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}},354(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," */");return[t].concat([i]).join("\n")}return[t].join("\n")}},715(e,t,o){o(766),e.exports=function(e){var t="",o=e||{};return function(e){t+='<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 class="form-text text-muted">{{ specialCommandsInfo }}</div></div><div class="form-group"><label>Group</label><input class="form-control" type="text" list="groupList" placeholder="Select or type a group name" [(ngModel)]="command.group" (focus)="onGroupFocus()" (blur)="onGroupBlur()"><datalist id="groupList"><option [value]="">Ungrouped</option><option *ngFor="let group of allGroups" [value]="group">{{ group }}</option></datalist></div><div class="form-group"><label>Shortcut</label><div class="input-group"><input class="form-control" type="text" placeholder="Click to capture shortcut" [(ngModel)]="command.shortcut" (click)="startCaptureShortcut($event)" (focus)="startCaptureShortcut($event)" [disabled]="isCapturingShortcut"><div class="input-group-append"><button class="btn btn-outline-secondary" type="button" (click)="startCaptureShortcut($event)" [class.btn-outline-primary]="isCapturingShortcut">',t+=e?"Capturing...":"Capture",t+='</button></div></div></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 class="form-line"><div class="header"><div class="title">Limit to SSH profiles</div><div class="description">Only show this command in selected SSH terminal tabs</div></div><toggle [(ngModel)]="sshEnabled" (ngModelChange)="onSshToggle()"></toggle></div><div class="form-group" *ngIf="sshEnabled"><label>SSH profiles</label><input class="form-control mb-2" type="text" placeholder="Search SSH profiles" [(ngModel)]="sshProfileQuery"><div class="list-group ssh-profile-list"><label class="list-group-item d-flex align-items-center" *ngFor="let profile of filteredProfiles"><input class="form-check-input me-2" type="checkbox" [checked]="isProfileSelected(profile.id)" (change)="toggleProfile(profile.id)"><span class="mr-auto">{{ profile.name }}</span><small class="text-muted">{{ profile.description }}</small></label><div class="list-group-item text-muted" *ngIf="!filteredProfiles.length">No matching SSH profiles</div></div></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>'}.call(this,"isCapturingShortcut"in o?o.isCapturingShortcut:"undefined"!=typeof isCapturingShortcut?isCapturingShortcut:void 0),t}},731(e,t,o){o(766),e.exports=function(e){return""+'<div class="modal-header"><h4 class="modal-title">Enter Parameters</h4></div><div class="modal-body"><div class="form-group" *ngFor="let param of parameters; let i = index"><label>{{ param.name }}</label><input class="form-control" type="text" [(ngModel)]="param.value" (keydown.enter)="save()" [autofocus]="i === 0"></div></div><div class="modal-footer"><button class="btn btn-outline-primary" (click)="save()">OK</button><button class="btn btn-outline-danger" (click)="cancel()">Cancel</button></div>'}},480(e,t,o){o(766),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>'}},716(e,t,o){o(766),e.exports=function(e){return""+'<div class="modal-body"><div class="input-group"><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()"><button class="btn btn-primary" (click)="addCommand()" title="Add a new command">Add</button></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"><span>{{cmd.text}}</span><span class="ml-1" *ngIf="cmd.appendCR" title="Appends CR">↵</span></div></div></div></ng-container></ng-container></div></div>'}},819(e,t,o){o(766),e.exports=function(e){return""+'<h3>Quick Commands</h3><div class="form-group"><button class="btn btn-sm btn-outline-primary mb-2" (click)="createCommand()"><i class="fa fa-fw fa-globe"></i><span class="ml-2">Add command</span></button><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><div class="command-buttons"><button class="btn btn-sm btn-outline-info" (click)="editGroup(group); $event.stopPropagation()"><i class="fa fa-pencil"></i></button><button class="btn btn-sm btn-outline-danger" (click)="deleteGroup(group); $event.stopPropagation()"><i class="fa fa-trash-can"></i></button></div></div><ng-container *ngIf="!groupCollapsed[group.name]"><div class="list-group-item pl-5 d-flex align-items-start" *ngFor="let cmd of group.cmds"> <div class="mr-auto"><div>{{cmd.name}}</div><div class="text-muted"><span>{{cmd.text}}</span><span class="ml-1" *ngIf="cmd.appendCR" title="Appends CR">↵</span><span class="badge bg-secondary ml-2" *ngIf="cmd.profileIds?.length">SSH</span></div></div><div class="command-buttons"><button class="btn btn-outline-info" (click)="editCommand(cmd)"><i class="fa fa-pencil"></i></button><button class="btn btn-outline-danger" (click)="deleteCommand(cmd)"><i class="fa fa-trash-can"></i></button></div></div></ng-container></ng-container></div>'}},766(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),a=0;a<e.length;a++)(o=s(e[a]))&&(r&&t[a]&&(o=l(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=l(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 a=t[r]||[];t[r]=(Array.isArray(a)?a:[a]).concat(o[r]||[])}else if("style"===r){a=(a=i(t[r]))&&";"!==a[a.length-1]?a+";":a;var l=i(o[r]);l=l&&";"!==l[l.length-1]?l+";":l,t[r]=a+l}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 a in e)if(n.call(e,a)){var l=e[a];if("class"===a){o=r(a,l=s(l),!1,t)+o;continue}"style"===a&&(l=i(l)),o+=r(a,l,!1,t)}return o};var a=/["&<>]/;function l(e){var t=""+e,o=a.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=l,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,a,l,c;try{i=i||o(896).readFileSync(n,{encoding:"utf8"}),r=3,a=i.split("\n"),l=Math.max(s-r,0),c=Math.min(a.length,s+r)}catch(o){return t.message+=" - could not read from "+n+" ("+o.message+")",void e(t,null,s)}r=a.slice(l,c).map(function(e,t){var o=t+l+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}},234(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>'},401(e,t,o){var n=o(805);n&&n.__esModule&&(n=n.default),e.exports="string"==typeof n?n:n.toString()},576(e,t,o){var n=o(244);n&&n.__esModule&&(n=n.default),e.exports="string"==typeof n?n:n.toString()},983(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 a=e.length-1;a>=0;a--)(s=e[a])&&(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{l(n.next(e))}catch(e){i(e)}}function a(e){try{l(n.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof o?t:new o(function(e){e(t)})).then(r,a)}l((n=n.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.ButtonProvider=void 0;const r=o(860),a=o(765),l=o(650),c=o(895),d=o(349),p=o(724);let u=class extends l.ToolbarButtonProvider{constructor(e,t,o,n){super(),this.ngbModal=e,this.hotkeys=t,this.config=o,this.app=n,this.usageCount={},this.hotkeys.matchedHotkey.subscribe(e=>i(this,void 0,void 0,function*(){"qc"===e?this.activate():this.executeCommandByShortcut(e)})),document.addEventListener("keydown",this.handleDocumentKeyDown.bind(this),!0)}handleDocumentKeyDown(e){if(e.repeat)return;let t="";const o=[];(e.ctrlKey||e.metaKey)&&o.push("Ctrl"),e.altKey&&o.push("Alt"),e.shiftKey&&o.push("Shift"),o.sort(),o.length>0&&(t=o.join("+")+"+");const n=e.key;if(n&&!["Control","Alt","Shift","Meta"].includes(n)){let o=n;o=1===n.length?n.toUpperCase():n.charAt(0).toUpperCase()+n.slice(1),t+=o;const s=this.config.store.qc.cmds,i=(0,p.getRuntimeSSHContext)(this.app.activeTab),r=this.getGroupScopes();s.find(e=>e.shortcut===t&&(0,p.commandVisibleForContext)(e,r,i))&&(e.preventDefault(),e.stopPropagation(),this.executeCommandByShortcut(t))}}executeCommandByShortcut(e){return i(this,void 0,void 0,function*(){const t=this.config.store.qc.cmds,o=(0,p.getRuntimeSSHContext)(this.app.activeTab),n=this.getGroupScopes(),s=t.find(t=>t.shortcut===e&&(0,p.commandVisibleForContext)(t,n,o));s&&(this.usageCount[s.text]=(this.usageCount[s.text]||0)+1,localStorage.setItem("qcUsageCount",JSON.stringify(this.usageCount)),yield this._send(this.app.activeTab,s))})}_send(e,t){return i(this,void 0,void 0,function*(){if(e instanceof l.SplitTabComponent)this._send(e.getFocusedTab(),t);else if((0,p.commandVisibleForContext)(t,this.getGroupScopes(),(0,p.getRuntimeSSHContext)(e))&&e instanceof d.BaseTerminalTabComponent){let o=e,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)/),a=[];for(let e of r)if(""!==e){if(e.startsWith("\\s")){if(!t.appendCR)continue;e=e.replace("\\s","");let o=parseInt(e);yield this.sleep(o);continue}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)):a.push(e)}if(a.length>0){let e;e=o.title.includes("powershell")?a.join(" ; "):a.join(" "+i+s+n),yield o.sendInput(e)}}})}sleep(e){return new Promise(t=>setTimeout(t,e))}activate(){this.ngbModal.open(c.QuickCmdsModalComponent)}provide(){return[{icon:o(234),weight:5,title:"Quick commands",touchBarNSImage:"NSTouchBarComposeTemplate",click:()=>i(this,void 0,void 0,function*(){this.activate()})}]}getGroupScopes(){var e;return(null!==(e=this.config.store.qc.groups)&&void 0!==e?e:[]).map(e=>{var t;return{name:e.name,cmds:[],profileIds:null!==(t=e.profileIds)&&void 0!==t?t:[]}})}};u=n([(0,r.Injectable)(),s("design:paramtypes",[a.NgbModal,l.HotkeysService,l.ConfigService,l.AppService])],u),t.ButtonProvider=u},114(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 a=e.length-1;a>=0;a--)(s=e[a])&&(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(860),r=o(765),a=o(724);let l=class{constructor(e){this.modalInstance=e,this.allGroups=[],this.profiles=[],this.command=void 0,this.isCapturingShortcut=!1,this.sshProfileQuery="",this.specialCommandsInfo="Special commands:<br> \\x<xx> for control characters, \\s<ms> for delays, ${parameterName} for parameters.",this.sshEnabled=!1,this._groupSavedValue=""}ngOnInit(){var e,t,o;this.sshEnabled=(null!==(o=null===(t=null===(e=this.command)||void 0===e?void 0:e.profileIds)||void 0===t?void 0:t.length)&&void 0!==o?o:0)>0}onGroupFocus(){this._groupSavedValue=this.command.group||"",this.command.group=""}onGroupBlur(){this.command.group||(this.command.group=this._groupSavedValue)}onKeyDown(e){if(this.isCapturingShortcut){if(e.preventDefault(),e.stopPropagation(),"Escape"===e.key)return void(this.isCapturingShortcut=!1);if("Delete"===e.key||"Backspace"===e.key)return this.command.shortcut="",void(this.isCapturingShortcut=!1);let t="";const o=[];(e.ctrlKey||e.metaKey)&&o.push("Ctrl"),e.altKey&&o.push("Alt"),e.shiftKey&&o.push("Shift"),o.sort(),o.length>0&&(t=o.join("+")+"+");const n=e.key;if(n&&!["Control","Alt","Shift","Meta"].includes(n)){let e=n;e=1===n.length?n.toUpperCase():n.charAt(0).toUpperCase()+n.slice(1),t+=e,this.command.shortcut=t,this.isCapturingShortcut=!1}}}startCaptureShortcut(e){e.preventDefault(),this.isCapturingShortcut=!0}get filteredProfiles(){return this.profiles.filter(e=>(0,a.profileMatchesQuery)(e,this.sshProfileQuery))}isProfileSelected(e){var t;return(null!==(t=this.command.profileIds)&&void 0!==t?t:[]).includes(e)}toggleProfile(e){var t;const o=new Set(null!==(t=this.command.profileIds)&&void 0!==t?t:[]);o.has(e)?o.delete(e):o.add(e),this.command.profileIds=Array.from(o)}onSshToggle(){this.sshEnabled||(this.command.profileIds=[])}save(){var e;this.sshEnabled||(this.command.profileIds=[]),this.command.profileIds=null!==(e=this.command.profileIds)&&void 0!==e?e:[],this.modalInstance.close(this.command)}cancel(){this.modalInstance.dismiss()}};n([(0,i.HostListener)("document:keydown",["$event"]),s("design:type",Function),s("design:paramtypes",[KeyboardEvent]),s("design:returntype",void 0)],l.prototype,"onKeyDown",null),l=n([(0,i.Component)({template:o(490),styles:["\n .ssh-profile-list {\n max-height: 220px;\n overflow: auto;\n }\n "]}),s("design:paramtypes",[r.NgbActiveModal])],l),t.EditCommandModalComponent=l},532(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 a=e.length-1;a>=0;a--)(s=e[a])&&(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.EditGroupModalComponent=void 0;const i=o(860),r=o(765),a=o(724);let l=class{constructor(e){this.modalInstance=e,this.profiles=[],this.sshProfileQuery=""}get filteredProfiles(){return this.profiles.filter(e=>(0,a.profileMatchesQuery)(e,this.sshProfileQuery))}isSelected(e){var t;return(null!==(t=this.group.profileIds)&&void 0!==t?t:[]).includes(e)}toggleProfile(e){var t;const o=new Set(null!==(t=this.group.profileIds)&&void 0!==t?t:[]);o.has(e)?o.delete(e):o.add(e),this.group.profileIds=Array.from(o)}save(){this.modalInstance.close(this.group)}cancel(){this.modalInstance.dismiss()}};n([(0,i.Input)(),s("design:type",Object)],l.prototype,"group",void 0),n([(0,i.Input)(),s("design:type",Array)],l.prototype,"profiles",void 0),l=n([(0,i.Component)({template:'\n <div class="modal-body">\n <div class="form-group">\n <label>Name</label>\n <input class="form-control" type="text" autofocus [(ngModel)]="group.name">\n </div>\n <div class="form-group mt-3">\n <label>SSH profiles</label>\n <div class="form-text text-muted mb-2">Leave empty to show this group in every terminal tab.</div>\n <input class="form-control mb-2" type="text" placeholder="Search SSH profiles" [(ngModel)]="sshProfileQuery">\n <div class="list-group ssh-profile-list">\n <label class="list-group-item d-flex align-items-center" *ngFor="let profile of filteredProfiles">\n <input class="form-check-input me-2" type="checkbox" [checked]="isSelected(profile.id)" (change)="toggleProfile(profile.id)">\n <span class="me-auto">{{ profile.name }}</span>\n <small class="text-muted">{{ profile.description }}</small>\n </label>\n <div class="list-group-item text-muted" *ngIf="!filteredProfiles.length">No matching SSH profiles</div>\n </div>\n </div>\n </div>\n <div class="modal-footer">\n <button class="btn btn-outline-primary" (click)="save()">Save</button>\n <button class="btn btn-outline-danger" (click)="cancel()">Cancel</button>\n </div>\n ',styles:["\n .ssh-profile-list {\n max-height: 220px;\n overflow: auto;\n }\n "]}),s("design:paramtypes",[r.NgbActiveModal])],l),t.EditGroupModalComponent=l},842(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 a=e.length-1;a>=0;a--)(s=e[a])&&(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.ParameterPromptModalComponent=void 0;const i=o(860),r=o(765);let a=class{constructor(e){this.modalInstance=e,this.parameters=[]}save(){const e={};for(const t of this.parameters)e[t.name]=t.value;this.modalInstance.close(e)}cancel(){this.modalInstance.dismiss()}};n([(0,i.Input)(),s("design:type",Array)],a.prototype,"parameters",void 0),a=n([(0,i.Component)({template:o(430)}),s("design:paramtypes",[r.NgbActiveModal])],a),t.ParameterPromptModalComponent=a},867(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 a=e.length-1;a>=0;a--)(s=e[a])&&(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(860),r=o(765);let a=class{constructor(e){this.modalInstance=e,this.frequencyMap={}}ngOnInit(){try{const e=localStorage.getItem("quickCmdFrequency");e&&(this.frequencyMap=JSON.parse(e))}catch(e){}this.input.nativeElement.focus()}ok(){this.value&&(this.frequencyMap[this.value]=(this.frequencyMap[this.value]||0)+1,localStorage.setItem("quickCmdFrequency",JSON.stringify(this.frequencyMap))),this.modalInstance.close(this.value)}cancel(){this.modalInstance.close("")}getSortedHistory(){return Object.entries(this.frequencyMap).sort((e,t)=>t[1]-e[1]).map(([e])=>e)}};n([(0,i.Input)(),s("design:type",String)],a.prototype,"value",void 0),n([(0,i.Input)(),s("design:type",Boolean)],a.prototype,"password",void 0),n([(0,i.ViewChild)("input"),s("design:type",i.ElementRef)],a.prototype,"input",void 0),a=n([(0,i.Component)({template:o(951)}),s("design:paramtypes",[r.NgbActiveModal])],a),t.PromptModalComponent=a},895(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 a=e.length-1;a>=0;a--)(s=e[a])&&(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{l(n.next(e))}catch(e){i(e)}}function a(e){try{l(n.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof o?t:new o(function(e){e(t)})).then(r,a)}l((n=n.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.QuickCmdsModalComponent=void 0;const r=o(860),a=o(765),l=o(765),c=o(650),d=o(114),p=o(349),u=o(842),m=o(724);let f=class{constructor(e,t,o,n,s){this.modalInstance=e,this.ngbModal=t,this.config=o,this.app=n,this.profilesService=s,this.profiles=[],this.groupCollapsed={},this.expandedGroups={},this.flattenedItems=[],this.selectedGroupIndex=0,this.selectedCmdIndex=-1,this.usageCount={}}ngOnInit(){var e;try{const e=localStorage.getItem("qcUsageCount");e&&(this.usageCount=JSON.parse(e))}catch(e){}this.cmds=this.config.store.qc.cmds,this.config.store.qc.groups=null!==(e=this.config.store.qc.groups)&&void 0!==e?e:[],this.appendCR=!0,this.refresh(),this.updateFlattenedItems(),this.loadProfiles()}loadProfiles(){return i(this,void 0,void 0,function*(){const e=yield this.profilesService.getProfiles();this.profiles=e.filter(e=>"ssh"===e.type&&!!e.id).map(e=>({id:e.id,name:e.name,description:this.describeProfile(e)})).sort((e,t)=>e.name.localeCompare(t.name))})}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*(){const o=t.text.match(/\$\{(.*?)\}/g);if(o){const n=this.ngbModal.open(u.ParameterPromptModalComponent);n.componentInstance.parameters=o.map(e=>({name:e.substring(2,e.length-1),value:""})),n.result.then(o=>{let n=t.text;for(const e in o)n=n.replace(`\${${e}}`,o[e]);const s=Object.assign(Object.assign({},t),{text:n});this.executeSend(e,s)})}else this.executeSend(e,t)})}executeSend(e,t){return i(this,void 0,void 0,function*(){if(e instanceof c.SplitTabComponent)this._send(e.getFocusedTab(),t);else if((0,m.commandVisibleForContext)(t,this.getGroupScopes(),(0,m.getRuntimeSSHContext)(e))&&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)/),a=[];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);continue}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)):a.push(e)}if(a.length>0){let e;e=o.title.includes("powershell")?a.join(" ; "):a.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 c.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){this.usageCount[e.text]=(this.usageCount[e.text]||0)+1,localStorage.setItem("qcUsageCount",JSON.stringify(this.usageCount)),t.ctrlKey?this._sendAll(e):this._send(this.app.activeTab,e),this.close()}addCommand(){const e={name:"",text:this.quickCmd||"",appendCR:!0,profileIds:[]};this.edit(e)}edit(e){const t=this.ngbModal.open(d.EditCommandModalComponent);t.componentInstance.allGroups=Array.from(new Set(this.cmds.map(e=>e.group||""))),t.componentInstance.profiles=this.profiles;const o=!this.cmds.includes(e);t.componentInstance.command=Object.assign(Object.assign({},e),{group:e.group||""}),t.result.then(t=>{o?this.cmds.push(t):Object.assign(e,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())).filter(e=>(0,m.commandVisibleForContext)(e,this.getGroupScopes(),(0,m.getRuntimeSSHContext)(this.app.activeTab)));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:[],profileIds:this.getGroupProfileIds(t.group)},this.childGroups.push(e)),e.cmds.push(t)}for(const e of this.childGroups)e.cmds.sort((e,t)=>(this.usageCount[t.text]||0)-(this.usageCount[e.text]||0));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())).filter(e=>(0,m.commandVisibleForContext)(e,this.getGroupScopes(),(0,m.getRuntimeSSHContext)(this.app.activeTab))),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();return void(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)}))}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()]}getGroupScopes(){var e;return(null!==(e=this.config.store.qc.groups)&&void 0!==e?e:[]).map(e=>{var t;return{name:e.name,cmds:[],profileIds:null!==(t=e.profileIds)&&void 0!==t?t:[]}})}getGroupProfileIds(e){var t,o,n;return null!==(n=null===(o=(null!==(t=this.config.store.qc.groups)&&void 0!==t?t:[]).find(t=>t.name===e))||void 0===o?void 0:o.profileIds)&&void 0!==n?n:[]}describeProfile(e){var t,o,n;const s=null===(t=e.options)||void 0===t?void 0:t.host,i=null===(o=e.options)||void 0===o?void 0:o.user,r=null===(n=e.options)||void 0===n?void 0:n.port;return s?`${i?`${i}@`:""}${s}${r?`:${r}`:""}`:e.id}};f=n([(0,r.Component)({template:o(585),styles:[o(401)],host:{"(keydown)":"handleKeyDown($event)"}}),s("design:paramtypes",[a.NgbActiveModal,l.NgbModal,c.ConfigService,c.AppService,c.ProfilesService])],f),t.QuickCmdsModalComponent=f},986(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 a=e.length-1;a>=0;a--)(s=e[a])&&(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{l(n.next(e))}catch(e){i(e)}}function a(e){try{l(n.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof o?t:new o(function(e){e(t)})).then(r,a)}l((n=n.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.QuickCmdsSettingsTabComponent=void 0;const r=o(860),a=o(765),l=o(650),c=o(114),d=o(532);let p=class{constructor(e,t,o){var n;this.config=e,this.ngbModal=t,this.profilesService=o,this.groupCollapsed={},this.profiles=[],this.commands=this.config.store.qc.cmds,this.config.store.qc.groups=null!==(n=this.config.store.qc.groups)&&void 0!==n?n:[],this.refresh(),this.loadProfiles()}loadProfiles(){return i(this,void 0,void 0,function*(){const e=yield this.profilesService.getProfiles();this.profiles=e.filter(e=>"ssh"===e.type&&!!e.id).map(e=>({id:e.id,name:e.name,description:this.describeProfile(e)})).sort((e,t)=>e.name.localeCompare(t.name))})}createCommand(){let e=this.ngbModal.open(c.EditCommandModalComponent);e.componentInstance.command={name:"",text:"",appendCR:!0,profileIds:[]},e.componentInstance.allGroups=Array.from(new Set(this.commands.map(e=>e.group||""))).filter(e=>e),e.componentInstance.profiles=this.profiles,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(c.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.componentInstance.profiles=this.profiles,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){var t;const o=this.ngbModal.open(d.EditGroupModalComponent);o.componentInstance.group={name:e.name,cmds:e.cmds,profileIds:null!==(t=e.profileIds)&&void 0!==t?t:[]},o.componentInstance.profiles=this.profiles,o.result.then(t=>{var o;if(!(null==t?void 0:t.name))return;const n=e.name;for(let e of this.commands.filter(e=>e.group===n))e.group=t.name;this.upsertGroupScope(t.name,null!==(o=t.profileIds)&&void 0!==o?o:[]),n!==t.name&&this.removeGroupScope(n),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.removeGroupScope(e.name),this.config.save(),this.refresh()}}cancelFilter(){this.quickCmd="",this.refresh()}refresh(){var e;this.childGroups=[];let t=this.commands;this.quickCmd&&(t=t.filter(e=>(e.name+e.group+e.text).toLowerCase().includes(this.quickCmd)));for(let o of t){o.group=o.group||null;let t=this.childGroups.find(e=>e.name===o.group);t||(t={name:o.group,cmds:[],profileIds:null!==(e=this.getGroupScope(o.group).profileIds)&&void 0!==e?e:[]},this.childGroups.push(t)),t.cmds.push(o)}}getGroupScope(e){var t,o;return null!==(o=(null!==(t=this.config.store.qc.groups)&&void 0!==t?t:[]).find(t=>t.name===e))&&void 0!==o?o:{name:e,profileIds:[]}}upsertGroupScope(e,t){var o;const n=null!==(o=this.config.store.qc.groups)&&void 0!==o?o:[],s=n.find(t=>t.name===e);s?s.profileIds=t:n.push({name:e,profileIds:t}),this.config.store.qc.groups=n.filter(e=>{var t;return e.name||(null!==(t=e.profileIds)&&void 0!==t?t:[]).length})}removeGroupScope(e){var t;this.config.store.qc.groups=(null!==(t=this.config.store.qc.groups)&&void 0!==t?t:[]).filter(t=>t.name!==e)}describeProfile(e){var t,o,n;const s=null===(t=e.options)||void 0===t?void 0:t.host,i=null===(o=e.options)||void 0===o?void 0:o.user,r=null===(n=e.options)||void 0===n?void 0:n.port;return s?`${i?`${i}@`:""}${s}${r?`:${r}`:""}`:e.id}};p=n([(0,r.Component)({template:o(286),styles:[o(576)]}),s("design:paramtypes",[l.ConfigService,a.NgbModal,l.ProfilesService])],p),t.QuickCmdsSettingsTabComponent=p},28(e,t,o){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.QuickCmdsConfigProvider=void 0;const n=o(650);class s extends n.ConfigProvider{constructor(){super(...arguments),this.defaults={qc:{cmds:[],groups:[]},hotkeys:{qc:["Alt-Q"]}},this.platformDefaults={}}}t.QuickCmdsConfigProvider=s},156(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 a=e.length-1;a>=0;a--)(s=e[a])&&(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(860),i=o(358),r=o(182),a=o(765),l=o(650),c=o(650),d=o(700),p=o(114),u=o(895),m=o(986),f=o(867),h=o(842),g=o(532),v=o(983),y=o(28),b=o(451);let C=class{};C=n([(0,s.NgModule)({imports:[a.NgbModule,i.CommonModule,r.FormsModule,c.default],providers:[{provide:l.ToolbarButtonProvider,useClass:v.ButtonProvider,multi:!0},{provide:l.ConfigProvider,useClass:y.QuickCmdsConfigProvider,multi:!0},{provide:d.SettingsTabProvider,useClass:b.QuickCmdsSettingsTabProvider,multi:!0}],declarations:[f.PromptModalComponent,p.EditCommandModalComponent,u.QuickCmdsModalComponent,m.QuickCmdsSettingsTabComponent,h.ParameterPromptModalComponent,g.EditGroupModalComponent],entryComponents:[f.PromptModalComponent,p.EditCommandModalComponent,u.QuickCmdsModalComponent,m.QuickCmdsSettingsTabComponent,h.ParameterPromptModalComponent,g.EditGroupModalComponent]})],C),t.default=C},451(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 a=e.length-1;a>=0;a--)(s=e[a])&&(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(860),i=o(700),r=o(986);let a=class extends i.SettingsTabProvider{constructor(){super(...arguments),this.id="qc",this.title="Quick Commands"}getComponentType(){return r.QuickCmdsSettingsTabComponent}};a=n([(0,s.Injectable)()],a),t.QuickCmdsSettingsTabProvider=a},724(e,t,o){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.profileMatchesQuery=t.profileLabel=t.commandVisibleForContext=t.scopedToCurrentProfile=t.getRuntimeSSHContext=t.getFocusedTab=void 0;const n=o(650);function s(e){return e?e instanceof n.SplitTabComponent?e.getFocusedTab():e:null}function i(e,t){const o=(null!=e?e:[]).filter(Boolean);return!o.length||t.isSSH&&!!t.profileId&&o.includes(t.profileId)}t.getFocusedTab=s,t.getRuntimeSSHContext=function(e){var t,o,n,i,r,a,l,c,d;const p=s(e),u=null!==(r=null!==(n=null!==(t=null==p?void 0:p.profile)&&void 0!==t?t:null===(o=null==p?void 0:p.sshSession)||void 0===o?void 0:o.profile)&&void 0!==n?n:null===(i=null==p?void 0:p.session)||void 0===i?void 0:i.profile)&&void 0!==r?r:null;return{profileId:"string"==typeof(null==u?void 0:u.id)?u.id:null,isSSH:"ssh"===(null==u?void 0:u.type)||!!(null===(a=null==u?void 0:u.options)||void 0===a?void 0:a.host)&&!!(null===(l=null==u?void 0:u.options)||void 0===l?void 0:l.user)||String(null!==(d=null===(c=null==p?void 0:p.constructor)||void 0===c?void 0:c.name)&&void 0!==d?d:"").includes("SSH")}},t.scopedToCurrentProfile=i,t.commandVisibleForContext=function(e,t,o){const n=t.find(t=>t.name===(e.group||""));return i(null==n?void 0:n.profileIds,o)&&i(e.profileIds,o)},t.profileLabel=function(e){return e.description?`${e.name} (${e.description})`:e.name},t.profileMatchesQuery=function(e,t){const o=t.trim().toLowerCase();return!o||[e.id,e.name,e.description].some(e=>(null!=e?e:"").toLowerCase().includes(o))}},896(e){"use strict";e.exports=require("fs")},358(e){"use strict";e.exports=t},860(t){"use strict";t.exports=e},182(e){"use strict";e.exports=o},765(e){"use strict";e.exports=n},650(e){"use strict";e.exports=s},700(e){"use strict";e.exports=i},349(e){"use strict";e.exports=r}},l={};function c(e){var t=l[e];if(void 0!==t)return t.exports;var o=l[e]={id:e,exports:{}};if(!(e in a)){delete l[e];var n=new Error("Cannot find module '"+e+"'");throw n.code="MODULE_NOT_FOUND",n}return a[e].call(o.exports,o,o.exports,c),o.exports}return c.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return c.d(t,{a:t}),t},c.d=(e,t)=>{for(var o in t)c.o(t,o)&&!c.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},c.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),c.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},c(156)})()); //# sourceMappingURL=index.js.map