"use strict";(self.webpackChunklauncher_links=self.webpackChunklauncher_links||[]).push([[509],{509:(e,n,o)=>{o.r(n),o.d(n,{default:()=>i});var c=o(560),t=o(775),s=o(694);function a(e){return e?e.charAt(0).toUpperCase()+e.slice(1):""}const l={id:"launcher-links:plugin",description:"Add arbitrary launcher icons based on settings.",autoStart:!0,optional:[c.ISettingRegistry],requires:[t.ILauncher],activate:(e,n,o)=>{console.log("JupyterLab extension launcher-links is activated!");let c=[],t=[];const i=["Notebook","Console","Other"],r=o=>{c.forEach((e=>e.dispose())),c=[],t.forEach((e=>e.dispose())),t=[];const r=o.get("launchers").composite||[];console.log("Updating launchers with:",r);const d=new Set;r.forEach((o=>{const r=a(o.category)||"Other";if(!i.includes(r)&&!d.has(r)){d.add(r);const o=`${l.id}:sentinel-${r.toLowerCase()}`,a=e.commands.addCommand(o,{label:r,caption:`sentinel-item:${r}`,icon:s.LabIcon.resolve({icon:"ui-components:folder"}),execute:()=>{}});c.push(a);const i=n.add({command:o,category:r,rank:-1/0});t.push(i)}}));const u=new Map;r.forEach((o=>{var i;const r=`${l.id}:${o.id}`,d=o.icon||"ui-components:launch";let h;try{if(!d.trim().startsWith("<svg")&&d.includes(":"))h=s.LabIcon.resolve({icon:d});else{const e=`${l.id}-icon:${o.id}`,n=function(e,n){const o=`${n}-cls-`;return(e=e.replace(/\.cls-(\d+)\s*{([^}]+)}/g,`.${o}$1{$2}`)).replace(/class="cls-(\d+)"/g,`class="${o}$1"`)}(d,o.id);h=new s.LabIcon({name:e,svgstr:n})}}catch(e){console.warn(`Could not resolve or create icon for ${r}. Icon string: '${d.substring(0,70)}...'. Using default. Error:`,e),h=s.LabIcon.resolve({icon:"ui-components:launch"})}if(h)try{const s=e.commands.addCommand(r,{label:o.label,caption:`Open ${o.label}`,icon:h,execute:()=>{window.open(o.url,"_blank")}});c.push(s);const l=a(o.category)||"Other",d=null!==(i=u.get(l))&&void 0!==i?i:0;u.set(l,d+1);const p=1e3+d,g=n.add({command:r,category:l,rank:p});t.push(g)}catch(e){console.error(`Failed to add launcher item '${o.label}':`,e)}else console.error(`Failed to obtain any icon instance for ${r}. Skipping item.`)}))};o?o.load(l.id).then((e=>{console.log("launcher-links settings loaded:",e.composite),r(e),e.changed.connect(r)})).catch((e=>{console.error("Failed to load settings for launcher-links.",e)})):console.warn("ISettingRegistry not available. Cannot load custom launchers.")}},i=l}}]);