"use strict";(self.webpackChunk_JUPYTERLAB_CORE_OUTPUT=self.webpackChunk_JUPYTERLAB_CORE_OUTPUT||[]).push([[1337,1809],{1809:(n,e,t)=>{t.r(e),t.d(e,{IRunningSessionManagers:()=>u,RunningSessionManagers:()=>c,RunningSessions:()=>p});var s=t(46693),a=t(86072),o=t(75291),i=t(39787),l=t(97897),r=t(6691),d=t(72245);const u=new i.Token("@jupyterlab/running:IRunningSessionManagers");class c{constructor(){this._added=new r.Signal(this),this._managers=[]}get added(){return this._added}add(n){return this._managers.push(n),this._added.emit(n),new l.DisposableDelegate((()=>{const e=this._managers.indexOf(n);e>-1&&this._managers.splice(e,1)}))}items(){return this._managers}}function h(n){var e;const{runningItem:t}=n,s=t.icon(),i=null===(e=t.detail)||void 0===e?void 0:e.call(t),l=(n.translator||a.nullTranslator).load("jupyterlab"),r=n.shutdownLabel||l.__("Shut Down"),u=n.shutdownItemIcon||o.closeIcon;return d.createElement("li",{className:"jp-RunningSessions-item"},d.createElement(s.react,{tag:"span",stylesheet:"runningItem"}),d.createElement("span",{className:"jp-RunningSessions-itemLabel",title:t.labelTitle?t.labelTitle():"",onClick:()=>t.open()},t.label()),i&&d.createElement("span",{className:"jp-RunningSessions-itemDetail"},i),d.createElement(o.ToolbarButtonComponent,{className:"jp-RunningSessions-itemShutdown",icon:u,onClick:()=>t.shutdown(),tooltip:r}))}function m(n){return d.createElement("ul",{className:"jp-RunningSessions-sectionList"},n.runningItems.map(((e,t)=>d.createElement(h,{key:t,runningItem:e,shutdownLabel:n.shutdownLabel,shutdownItemIcon:n.shutdownItemIcon,translator:n.translator}))))}class g extends o.PanelWithToolbar{constructor(n){super(),this._manager=n.manager;const e=(n.translator||a.nullTranslator).load("jupyterlab"),t=n.manager.shutdownAllLabel||e.__("Shut Down All"),i=`${t}?`,l=n.manager.shutdownAllConfirmationText||`${t} ${n.manager.name}`;this.addClass("jp-RunningSessions-section"),this.title.label=n.manager.name;const r=n.manager.running().length>0;this._button=new o.ToolbarButton({label:t,className:`jp-RunningSessions-shutdownAll jp-mod-styled ${!r&&"jp-mod-disabled"}`,enabled:r,onClick:function(){(0,s.showDialog)({title:i,body:l,buttons:[s.Dialog.cancelButton(),s.Dialog.warnButton({label:t})]}).then((e=>{e.button.accept&&n.manager.shutdownAll()}))}}),this._manager.runningChanged.connect(this._updateButton,this),this.toolbar.addItem("shutdown-all",this._button),this.addWidget(o.ReactWidget.create(d.createElement(o.UseSignal,{signal:n.manager.runningChanged},(()=>d.createElement("div",{className:"jp-RunningSessions-sectionContainer"},d.createElement(m,{runningItems:n.manager.running(),shutdownLabel:n.manager.shutdownLabel,shutdownAllLabel:t,shutdownItemIcon:n.manager.shutdownItemIcon,translator:n.translator}))))))}dispose(){this.isDisposed||(this._manager.runningChanged.disconnect(this._updateButton,this),super.dispose())}_updateButton(){var n,e;this._button.enabled=this._manager.running().length>0,this._button.enabled?null===(n=this._button.node.querySelector("button"))||void 0===n||n.classList.remove("jp-mod-disabled"):null===(e=this._button.node.querySelector("button"))||void 0===e||e.classList.add("jp-mod-disabled")}}class p extends o.SidePanel{constructor(n,e){super(),this.managers=n,this.translator=null!=e?e:a.nullTranslator;const t=this.translator.load("jupyterlab");this.addClass("jp-RunningSessions"),this.toolbar.addItem("refresh",new o.ToolbarButton({tooltip:t.__("Refresh List"),icon:o.refreshIcon,onClick:()=>n.items().forEach((n=>n.refreshRunning()))})),n.items().forEach((e=>this.addSection(n,e))),n.added.connect(this.addSection,this)}dispose(){this.isDisposed||(this.managers.added.disconnect(this.addSection,this),super.dispose())}addSection(n,e){this.addWidget(new g({manager:e,translator:this.translator}))}}}}]);