"use strict";(self.webpackChunktelemetry_router=self.webpackChunktelemetry_router||[]).push([[763],{763:(o,e,t)=>{t.r(e),t.d(e,{ITelemetryRouter:()=>a,default:()=>d});var n=t(930),s=t(519),i=t(380);async function r(o="",e={}){const t=i.ServerConnection.makeSettings(),n=s.URLExt.join(t.baseUrl,"telemetry-router",o);let r;try{r=await i.ServerConnection.makeRequest(n,e,t)}catch(o){throw new i.ServerConnection.NetworkError(o)}let l=await r.text();if(l.length>0)try{l=JSON.parse(l)}catch(o){console.log("Not a JSON response body.",r)}if(!r.ok)throw new i.ServerConnection.ResponseError(r,l.message||l);return l}const l="telemetry-router:plugin",a=new n.Token(l);class c{async loadNotebookPanel(o){this.notebookPanel=o}async publishEvent(o,e){var t,n,s,i,l,a,c;if(!this.notebookPanel)throw Error("router needs to load notebookPanel first.");this.sessionID&&this.sessionID===(null===(n=null===(t=this.notebookPanel)||void 0===t?void 0:t.sessionContext.session)||void 0===n?void 0:n.id)||(this.sessionID=null===(i=null===(s=this.notebookPanel)||void 0===s?void 0:s.sessionContext.session)||void 0===i?void 0:i.id);const d={eventDetail:o,notebookState:{sessionID:this.sessionID,notebookPath:null===(l=this.notebookPanel)||void 0===l?void 0:l.context.path,notebookContent:e?null===(c=null===(a=this.notebookPanel)||void 0===a?void 0:a.model)||void 0===c?void 0:c.toJSON():null}},u=await r("export",{method:"POST",body:JSON.stringify(d)});console.log(u)}}const d={id:l,provides:a,autoStart:!0,activate:async function(o){const e=await r("version");return console.log(`${l}: ${e}`),new c}}}}]);