"use strict";(self.webpackChunk_jupyterhub_jupyter_server_proxy=self.webpackChunk_jupyterhub_jupyter_server_proxy||[]).push([[465],{465:(e,t,r)=>{r.r(t),r.d(t,{default:()=>g});var o=r(445),n=r(119),a=r(65),s=r(853),i=r(534),l=r(856);const c="server-proxy",d=Object.freeze(["allow-same-origin","allow-scripts","allow-popups","allow-forms","allow-downloads","allow-modals"]),u=Object.freeze({type:"object",properties:{id:{type:"string"},title:{type:"string"},url:{type:"string",format:"uri"},newBrowserTab:{type:"boolean"}}});var p;!function(e){e.open=`${c}:open`}(p||(p={}));const w=a.PageConfig.getBaseUrl(),f=a.PageConfig.getOption("notebookPage"),y="tree"===f,b=!!f;function m(e){const{new_browser_tab:t,launcher_entry:r,name:o}=e,n=t&&!b?" [↗]":"";return{url:`${w}${r.path_info}`,title:`${r.title}${n}`,newBrowserTab:t,id:`${c}:${o}`}}const g={id:"@jupyterhub/jupyter-server-proxy:add-launcher-entries",autoStart:!0,requires:[],optional:[i.ILauncher,o.ILayoutRestorer,n.IToolbarWidgetRegistry,s.IDefaultFileBrowser],activate:async function(e,t,r,o,s){if(b&&!y)return;const i=l.ServerConnection.makeSettings(),f=a.URLExt.join(w,`${c}/servers-info`),g=await l.ServerConnection.makeRequest(f,{},i);if(!g.ok)return console.warn("Could not fetch metadata about registered servers. Make sure jupyter-server-proxy is installed."),void console.warn(g);const v=await g.json(),_=new n.WidgetTracker({namespace:c});r&&r.restore(_,{command:p.open,args:e=>({url:e.content.url,title:e.content.title.label,newBrowserTab:!1,id:e.content.id}),name:e=>e.content.id});const{commands:h,shell:j}=e;if(h.addCommand(p.open,{label:e=>e.title,describedBy:async()=>({args:u}),execute:e=>{const{id:t,title:r,url:o,newBrowserTab:a}=e;if(a)return void window.open(o,"_blank");let s=_.find((e=>e.content.id===t));return s||(s=function(e,t,r){const o=new n.IFrame({sandbox:d});o.title.label=r,o.title.closable=!0,o.url=t,o.addClass("jp-ServerProxy"),o.id=e;const a=new n.MainAreaWidget({content:o});return a.addClass("jp-ServerProxy"),a}(t,o,r)),_.has(s)||_.add(s),s.isAttached?j.activateById(s.id):j.add(s),s}}),t)for(let e of v.server_processes){const{launcher_entry:r}=e;r.enabled&&t.add({command:p.open,args:m(e),category:"Notebook",kernelIconUrl:r.icon_url||void 0})}if(y&&o&&s){const{toolbar:e}=s,t=(e.layout||{}).widgets;if(t&&t.length)for(const e of t)if(e&&e.menus){const t=e.menus[0];t.addItem({type:"separator"});for(const e of v.server_processes){let r={...m(e),newBrowserTab:!0};t.addItem({command:p.open,args:r})}}}}}}}]);