"use strict";(self.webpackChunkjupyterlab_open_in_terminal_extension=self.webpackChunkjupyterlab_open_in_terminal_extension||[]).push([[509],{509(e,t,n){n.r(t),n.d(t,{default:()=>s});var a=n(110),r=n(285),o=n(391);const i="filebrowser:open-in-terminal",s={id:"jupyterlab_open_in_terminal_extension:plugin",description:"JupyterLab extension that adds context menu item to the file browser to open folder in terminal",autoStart:!0,requires:[a.IDefaultFileBrowser],activate:(e,t)=>{console.log("JupyterLab extension jupyterlab_open_in_terminal_extension is activated!");const{commands:n,serviceManager:a}=e;n.addCommand(i,{label:"Open in Terminal",caption:"Open a terminal at this directory",icon:o.terminalIcon,isVisible:()=>{const e=t.selectedItems().next();return!(e.done||!e.value)&&"directory"===e.value.type},execute:async()=>{const e=t.selectedItems().next();if(e.done||!e.value)return void await(0,r.showErrorMessage)("No Selection","No folder selected in file browser.");const o=e.value;if("directory"!==o.type)return void await(0,r.showErrorMessage)("Not a Directory","Please select a directory to open in terminal.");const i=o.path;try{const e=await a.terminals.startNew({cwd:i});await n.execute("terminal:create-new",{name:e.name})||await n.execute("terminal:open",{name:e.name}),console.log(`Opened terminal "${e.name}" at path: ${i}`)}catch(e){console.error("Failed to open terminal:",e),await(0,r.showErrorMessage)("Terminal Error",`Failed to open terminal at: ${i}\nError: ${e}`)}}}),e.contextMenu.addItem({command:i,selector:'.jp-DirListing-item[data-isdir="true"]',rank:3}),console.log(`Command registered: ${i}`)}}}}]);