"use strict";(self.webpackChunkpresentpy_jupyter=self.webpackChunkpresentpy_jupyter||[]).push([[509],{509:(e,t,o)=>{o.r(t),o.d(t,{default:()=>s});var n=o(765),r=o(31),i=o(465);const a={id:"presentpy_jupyter:plugin",description:"A JupyterLab extension.",autoStart:!0,optional:[n.ISettingRegistry,r.INotebookTracker],activate:(e,t,o)=>{console.log("JupyterLab extension presentpy_jupyter is activated!"),t&&t.load(a.id).then((e=>{console.log("presentpy_jupyter settings loaded:",e.composite)})).catch((e=>{console.error("Failed to load settings for presentpy_jupyter.",e)}));const{commands:n}=e,r="presentpy_jupyter:convert";n.addCommand(r,{label:"ODP",caption:"Export to ODP",execute:async e=>{var n;const r=await(null==t?void 0:t.load(a.id)),s=null===(n=o.currentWidget)||void 0===n?void 0:n.sessionContext.path;if("init"!==e.origin){const e=i.ServerConnection.makeSettings(),t=`${e.baseUrl}presentpy-jupyter/download`;try{const o=(null==r?void 0:r.get("theme").composite)||"default",n=(null==r?void 0:r.get("keep_odp").composite)||!1;console.log(`Converting ${s} to ODP with theme ${o} and keep_odp ${n}`);const a=await i.ServerConnection.makeRequest(t,{method:"POST",body:JSON.stringify({path:s,theme:o,keep_odp:n})},e);if(200!==a.status){const e=await a.json();throw new Error(e.message||"Unknown error")}const p=(null==s?void 0:s.split("/").pop())||"notebook.ipynb",c=await a.blob(),d=URL.createObjectURL(c),l=document.createElement("a");l.href=d,l.download=`${p.split(".")[0]}.odp`,document.body.appendChild(l),l.click(),document.body.removeChild(l),URL.revokeObjectURL(d)}catch(e){console.error("Failed to download notebook:",e)}}}}),n.execute(r,{origin:"init"}).catch((e=>{console.error(`An error occurred during the execution of jlab-examples:command.\n${e}`)}))}},s=a}}]);