"use strict";(self.webpackChunkgennaker_tools=self.webpackChunkgennaker_tools||[]).push([[28],{28:(e,t,o)=>{o.r(t),o.d(t,{default:()=>k,reloadPlugin:()=>p,settingsChangedPlugin:()=>y,snippetsPlugin:()=>r,statelessRunPlugin:()=>d});var n=o(880),a=o(505);const s={properties:{snippets:{type:"array",title:"Codemirror snippets",description:"Snippets of the form accepted by Codemirrors snippetCompletion",items:{type:"object",properties:{type:{type:"string",enum:["class","constant","enum","function","interface","keyword","method","namespace","property","text","type","variable"]},body:{type:"string"},label:{type:"string"}},required:["type","body","label"]}}},additionalProperties:!1,type:"object"},r={id:"gennaker-tools:snippets",description:"A JupyterLab extension.",autoStart:!0,requires:[n.IEditorExtensionRegistry],optional:[],activate:(e,t)=>{console.log("JupyterLab plugin gennaker-tools:snippets is activated!"),t.addExtension(Object.freeze({name:"gennaker-tools:snippets",factory:()=>n.EditorExtensionRegistry.createConfigurableExtension(e=>(0,a.autocompletion)({override:[(0,a.completeFromList)(e.snippets.map(e=>{const{body:t,...o}=e;return(0,a.snippetCompletion)(t,o)}))]})),default:{snippets:[]},schema:s}))}};var l,i=o(511),c=o(979);!function(e){e.restartRunStateless="gennaker-tools:restart-run-stateless",e.resetJupyterLab="gennaker-tools:reset-jupyterlab"}(l||(l={}));const p={id:"gennaker-tools:reload",description:"A JupyterLab extension.",autoStart:!0,requires:[i.ICommandPalette],optional:[c.ITranslator],activate:(e,t,o)=>{console.log("JupyterLab plugin gennaker-tools:reload is activated!");const{commands:n}=e,a=(null!=o?o:c.nullTranslator).load("jupyterlab");n.addCommand(l.resetJupyterLab,{label:"Reset JupyterLab",caption:"Reset JupyterLab",isEnabled:()=>!0,execute:e=>{"init"!==e.origin&&window.location.reload()}});const s=a.__("Reset");t.addItem({command:l.resetJupyterLab,category:s,args:{origin:"from palette"}})}};var u=o(22);const d={id:"gennaker-tools:stateless-run",description:"A JupyterLab extension.",autoStart:!0,requires:[i.ICommandPalette,u.INotebookTracker],optional:[c.ITranslator],activate:(e,t,o,n)=>{const a=(null!=n?n:c.nullTranslator).load("jupyterlab"),{commands:s,shell:r}=e;console.log("JupyterLab plugin gennaker-tools:stateless-run is activated!"),s.addCommand(l.restartRunStateless,{label:"Restart Kernel, Clear Outputs, and Run All Above Selected Cell",caption:"Clear all outputs, restart kernel, and run all cells above the selected cell",isEnabled:()=>null!==o.currentWidget&&o.currentWidget===r.currentWidget,execute:async e=>{const t=e.origin;console.log(`${l.restartRunStateless} has been called from... ${t}.`),"init"!==t&&await s.execute("apputils:run-all-enabled",{commands:["notebook:clear-all-cell-outputs","notebook:restart-and-run-to-selected"]})}});const i=a.__("Notebook Operations");t.addItem({command:l.restartRunStateless,category:i,args:{origin:"from palette"}})}};var g=o(520),b=o(519);const m="settings-changed",y={id:"gennaker-tools:settings-changed",description:"A JupyterLab extension.",autoStart:!0,requires:[],activate:e=>{console.log("JupyterLab plugin gennaker-tools:settings-changed is activated!");const{commands:t}=e,o=function(e){const t=null!=e?e:b.ServerConnection.makeSettings(),o=g.URLExt.join(t.baseUrl.replace(/^http/,"ws"),"gennaker-tools",m),n=new WebSocket(o);return n.onopen=()=>{console.log(`WebSocket connected to ${m}`),n.send(JSON.stringify({message:"Client connected"}))},n.onmessage=e=>{const t=JSON.parse(e.data);console.log(`Data received from ${m}:`,t)},n.onerror=e=>{console.error(`WebSocket error on ${m}:`,e)},n.onclose=()=>{console.log(`WebSocket disconnected from ${m}`)},n}(e.serviceManager.serverSettings);console.log({ws:o}),o.onmessage=e=>{const o=JSON.parse(e.data);"toml"===o.file_type&&(0,i.showDialog)({title:"Settings file change changed",body:`A change was detected to ${o.file_path}. This might require a reload of JupyterLab. Reloading will lose any unsaved changes on your page.`,buttons:[i.Dialog.cancelButton({label:"Ignore"}),i.Dialog.okButton({label:"Reload"})],defaultButton:0}).catch(e=>console.log(e)).then(async e=>{console.log({result:e}),(null==e?void 0:e.button.accept)&&await t.execute(l.resetJupyterLab)})}}},k=[d,p,r,y]}}]);