"use strict";(self.webpackChunkdatabrix_hub_extension=self.webpackChunkdatabrix_hub_extension||[]).push([[509],{509:(t,e,o)=>{o.r(e),o.d(e,{CommandIDs:()=>n,default:()=>u});var n,a=o(974),r=o(607),s=o(74),i=o(605);!function(t){t.controlPanel="hub:control-panel",t.logout="hub:logout",t.restart="hub:restart"}(n||(n={}));const u=[{activate:function(t,e,o,a){const r=o.load("jupyterlab"),i=e.urls.hubHost||"",u=e.urls.hubPrefix||"",l=e.urls.base;if(console.log("JupyterLab extension databrix_hub_extension is activated!"),!u)return;console.debug("hub-extension: Found configuration ",{hubHost:i,hubPrefix:u});const c=s.URLExt.join(u,"spawn");let d;try{const t=s.PageConfig.getBaseUrl(),e=new URL(t).pathname.split("/").filter((t=>t.length>0)),o=e.indexOf("user");d=-1!==o&&o+1<e.length?e[o+1]:""}catch(t){console.error("Invalid URL:",t),d=""}const b=s.URLExt.join(c,d);let h=i+b;console.log("restarturl: ",h);const{commands:p}=t;if(p.addCommand(n.restart,{label:r.__("Restart Server"),caption:r.__("Request that the Hub restart this server"),execute:()=>{window.open(h,"_blank")}}),p.addCommand(n.controlPanel,{label:r.__("Hub Control Panel"),caption:r.__("Open the Hub control panel in a new browser tab"),execute:()=>{window.open(i+s.URLExt.join(u,"home"),"_blank")}}),p.addCommand(n.logout,{label:r.__("Log Out"),caption:r.__("Log out of the Hub"),execute:()=>{window.location.href=i+s.URLExt.join(l,"logout")}}),a){const t=r.__("Hub");a.addItem({category:t,command:n.controlPanel}),a.addItem({category:t,command:n.logout})}},id:"@jupyterlab/hub-extension:plugin",description:"Registers commands related to the hub server",requires:[a.JupyterFrontEnd.IPaths,i.ITranslator],optional:[r.ICommandPalette],autoStart:!0},{activate:()=>{},id:"@jupyterlab/hub-extension:menu",description:"Adds hub related commands to the menu.",autoStart:!0},{id:"@jupyterlab/hub-extension:connectionlost",description:"Provides a service to be notified when the connection to the hub server is lost.",requires:[a.JupyterFrontEnd.IPaths,i.ITranslator],optional:[a.JupyterLab.IInfo],activate:(t,e,o,s)=>{const i=o.load("jupyterlab"),u=e.urls.hubPrefix||"",l=e.urls.base;if(!u)return a.ConnectionLost;let c=!1;return async(e,o)=>{if(c)return;c=!0,s&&(s.isConnected=!1);const a=await(0,r.showDialog)({title:i.__("Server unavailable or unreachable"),body:i.__("Your server at %1 is not running.\nWould you like to restart it?",l),buttons:[r.Dialog.okButton({label:i.__("Restart")}),r.Dialog.cancelButton({label:i.__("Dismiss")})]});s&&(s.isConnected=!0),c=!1,a.button.accept&&await t.commands.execute(n.restart)}},autoStart:!0,provides:a.IConnectionLost}]}}]);