"use strict";(self.webpackChunk_JUPYTERLAB_CORE_OUTPUT=self.webpackChunk_JUPYTERLAB_CORE_OUTPUT||[]).push([[9638,8771],{68771:(e,t,s)=>{s.r(t),s.d(t,{ILauncher:()=>n,Launcher:()=>p,LauncherModel:()=>u});const n=new(s(74547).Token)("@jupyterlab/launcher:ILauncher");var a,c=s(2484),r=s(7144),i=s(25167),o=s(81734),l=s(18108),d=s(2383),h=s(28877),m=s(72245);class u extends i.VDomModel{constructor(){super(...arguments),this._items=[]}add(e){const t=a.createItem(e);return this._items.push(t),this.stateChanged.emit(void 0),new l.DisposableDelegate((()=>{o.ArrayExt.removeFirstOf(this._items,t),this.stateChanged.emit(void 0)}))}items(){return new o.ArrayIterator(this._items)}}class p extends i.VDomRenderer{constructor(e){super(e.model),this._pending=!1,this._cwd="",this._cwd=e.cwd,this.translator=e.translator||r.nullTranslator,this._trans=this.translator.load("jupyterlab"),this._callback=e.callback,this._commands=e.commands,this.addClass("jp-Launcher")}get cwd(){return this._cwd}set cwd(e){this._cwd=e,this.update()}get pending(){return this._pending}set pending(e){this._pending=e}render(){if(!this.model)return null;const e=[this._trans.__("Notebook"),this._trans.__("Console"),this._trans.__("Other")],t=[this._trans.__("Notebook"),this._trans.__("Console")],s=Object.create(null);(0,o.each)(this.model.items(),((e,t)=>{const n=e.category||this._trans.__("Other");n in s||(s[n]=[]),s[n].push(e)}));for(const e in s)s[e]=s[e].sort(((e,t)=>a.sortCmp(e,t,this._cwd,this._commands)));const n=[];let r;const l=[];(0,o.each)(e,((e,t)=>{l.push(e)}));for(const t in s)-1===e.indexOf(t)&&l.push(t);return l.forEach((e=>{if(!s[e])return;const l=s[e][0],d=Object.assign(Object.assign({},l.args),{cwd:this.cwd}),u=t.indexOf(e)>-1,p=this._commands.iconClass(l.command,d),_=this._commands.icon(l.command,d),g=_===p?void 0:_;e in s&&(r=m.createElement("div",{className:"jp-Launcher-section",key:e},m.createElement("div",{className:"jp-Launcher-sectionHeader"},m.createElement(i.LabIcon.resolveReact,{icon:g,iconClass:(0,i.classes)(p,"jp-Icon-cover"),stylesheet:"launcherSection"}),m.createElement("h2",{className:"jp-Launcher-sectionTitle"},e)),m.createElement("div",{className:"jp-Launcher-cardContainer"},(0,o.toArray)((0,o.map)(s[e],(e=>function(e,t,s,n,r,o){const l=t.command,d=Object.assign(Object.assign({},t.args),{cwd:s.cwd}),u=n.caption(l,d),p=n.label(l,d),_=e?p:u||p,g=()=>{!0!==s.pending&&(s.pending=!0,n.execute(l,Object.assign(Object.assign({},t.args),{cwd:s.cwd})).then((e=>{s.pending=!1,e instanceof h.Widget&&(o(e),s.dispose())})).catch((e=>{s.pending=!1,(0,c.showErrorMessage)(r._p("Error","Launcher Error"),e)})))},b=n.iconClass(l,d),j=n.icon(l,d),E=j===b?void 0:j;return m.createElement("div",{className:"jp-LauncherCard",title:_,onClick:g,onKeyPress:e=>{"Enter"===e.key&&g()},tabIndex:0,"data-category":t.category||r.__("Other"),key:a.keyProperty.get(t)},m.createElement("div",{className:"jp-LauncherCard-icon"},e?t.kernelIconUrl?m.createElement("img",{src:t.kernelIconUrl,className:"jp-Launcher-kernelIcon"}):m.createElement("div",{className:"jp-LauncherCard-noKernelIcon"},p[0].toUpperCase()):m.createElement(i.LabIcon.resolveReact,{icon:E,iconClass:(0,i.classes)(b,"jp-Icon-cover"),stylesheet:"launcherCard"})),m.createElement("div",{className:"jp-LauncherCard-label",title:_},m.createElement("p",null,p)))}(u,e,this,this._commands,this._trans,this._callback)))))),n.push(r))})),m.createElement("div",{className:"jp-Launcher-body"},m.createElement("div",{className:"jp-Launcher-content"},m.createElement("div",{className:"jp-Launcher-cwd"},m.createElement("h3",null,this.cwd)),n))}}!function(e){let t=0;e.keyProperty=new d.AttachedProperty({name:"key",create:()=>t++}),e.createItem=function(e){return Object.assign(Object.assign({},e),{category:e.category||"",rank:void 0!==e.rank?e.rank:1/0})},e.sortCmp=function(e,t,s,n){const a=e.rank,c=t.rank;if(a!==c&&void 0!==a&&void 0!==c)return a<c?-1:1;const r=n.label(e.command,Object.assign(Object.assign({},e.args),{cwd:s})),i=n.label(t.command,Object.assign(Object.assign({},t.args),{cwd:s}));return r.localeCompare(i)}}(a||(a={}))}}]);