@jupyterlite/pyodide-kernel 0.7.0-beta.0 → 0.7.0-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,25 +1,24 @@
1
- var Eo=Object.create;var ti=Object.defineProperty;var Io=Object.getOwnPropertyDescriptor;var Oo=Object.getOwnPropertyNames;var Ro=Object.getPrototypeOf,jo=Object.prototype.hasOwnProperty;var tt=(i,e)=>()=>(i&&(e=i(i=0)),e);var P=(i,e)=>()=>(e||i((e={exports:{}}).exports,e),e.exports),Do=(i,e)=>{for(var t in e)ti(i,t,{get:e[t],enumerable:!0})},To=(i,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Oo(e))!jo.call(i,s)&&s!==t&&ti(i,s,{get:()=>e[s],enumerable:!(n=Io(e,s))||n.enumerable});return i};var Ie=(i,e,t)=>(t=i!=null?Eo(Ro(i)):{},To(e||!i||!i.__esModule?ti(t,"default",{value:i,enumerable:!0}):t,i));var si=P((Wt,Is)=>{(function(i,e){typeof Wt=="object"&&typeof Is!="undefined"?e(Wt):typeof define=="function"&&define.amd?define(["exports"],e):(i=typeof globalThis!="undefined"?globalThis:i||self,e(i.lumino_algorithm={}))})(Wt,function(i){"use strict";i.ArrayExt=void 0,function(h){function y(b,k,m=0,f=-1){let g=b.length;if(g===0)return-1;m<0?m=Math.max(0,m+g):m=Math.min(m,g-1),f<0?f=Math.max(0,f+g):f=Math.min(f,g-1);let E;f<m?E=f+1+(g-m):E=f-m+1;for(let R=0;R<E;++R){let K=(m+R)%g;if(b[K]===k)return K}return-1}h.firstIndexOf=y;function S(b,k,m=-1,f=0){let g=b.length;if(g===0)return-1;m<0?m=Math.max(0,m+g):m=Math.min(m,g-1),f<0?f=Math.max(0,f+g):f=Math.min(f,g-1);let E;m<f?E=m+1+(g-f):E=m-f+1;for(let R=0;R<E;++R){let K=(m-R+g)%g;if(b[K]===k)return K}return-1}h.lastIndexOf=S;function C(b,k,m=0,f=-1){let g=b.length;if(g===0)return-1;m<0?m=Math.max(0,m+g):m=Math.min(m,g-1),f<0?f=Math.max(0,f+g):f=Math.min(f,g-1);let E;f<m?E=f+1+(g-m):E=f-m+1;for(let R=0;R<E;++R){let K=(m+R)%g;if(k(b[K],K))return K}return-1}h.findFirstIndex=C;function N(b,k,m=-1,f=0){let g=b.length;if(g===0)return-1;m<0?m=Math.max(0,m+g):m=Math.min(m,g-1),f<0?f=Math.max(0,f+g):f=Math.min(f,g-1);let E;m<f?E=m+1+(g-f):E=m-f+1;for(let R=0;R<E;++R){let K=(m-R+g)%g;if(k(b[K],K))return K}return-1}h.findLastIndex=N;function G(b,k,m=0,f=-1){let g=C(b,k,m,f);return g!==-1?b[g]:void 0}h.findFirstValue=G;function z(b,k,m=-1,f=0){let g=N(b,k,m,f);return g!==-1?b[g]:void 0}h.findLastValue=z;function F(b,k,m,f=0,g=-1){let E=b.length;if(E===0)return 0;f<0?f=Math.max(0,f+E):f=Math.min(f,E-1),g<0?g=Math.max(0,g+E):g=Math.min(g,E-1);let R=f,K=g-f+1;for(;K>0;){let be=K>>1,ht=R+be;m(b[ht],k)<0?(R=ht+1,K-=be+1):K=be}return R}h.lowerBound=F;function X(b,k,m,f=0,g=-1){let E=b.length;if(E===0)return 0;f<0?f=Math.max(0,f+E):f=Math.min(f,E-1),g<0?g=Math.max(0,g+E):g=Math.min(g,E-1);let R=f,K=g-f+1;for(;K>0;){let be=K>>1,ht=R+be;m(b[ht],k)>0?K=be:(R=ht+1,K-=be+1)}return R}h.upperBound=X;function $(b,k,m){if(b===k)return!0;if(b.length!==k.length)return!1;for(let f=0,g=b.length;f<g;++f)if(m?!m(b[f],k[f]):b[f]!==k[f])return!1;return!0}h.shallowEqual=$;function ee(b,k={}){let{start:m,stop:f,step:g}=k;if(g===void 0&&(g=1),g===0)throw new Error("Slice `step` cannot be zero.");let E=b.length;m===void 0?m=g<0?E-1:0:m<0?m=Math.max(m+E,g<0?-1:0):m>=E&&(m=g<0?E-1:E),f===void 0?f=g<0?-1:E:f<0?f=Math.max(f+E,g<0?-1:0):f>=E&&(f=g<0?E-1:E);let R;g<0&&f>=m||g>0&&m>=f?R=0:g<0?R=Math.floor((f-m+1)/g+1):R=Math.floor((f-m-1)/g+1);let K=[];for(let be=0;be<R;++be)K[be]=b[m+be*g];return K}h.slice=ee;function Y(b,k,m){let f=b.length;if(f<=1||(k<0?k=Math.max(0,k+f):k=Math.min(k,f-1),m<0?m=Math.max(0,m+f):m=Math.min(m,f-1),k===m))return;let g=b[k],E=k<m?1:-1;for(let R=k;R!==m;R+=E)b[R]=b[R+E];b[m]=g}h.move=Y;function ce(b,k=0,m=-1){let f=b.length;if(!(f<=1))for(k<0?k=Math.max(0,k+f):k=Math.min(k,f-1),m<0?m=Math.max(0,m+f):m=Math.min(m,f-1);k<m;){let g=b[k],E=b[m];b[k++]=E,b[m--]=g}}h.reverse=ce;function ke(b,k,m=0,f=-1){let g=b.length;if(g<=1||(m<0?m=Math.max(0,m+g):m=Math.min(m,g-1),f<0?f=Math.max(0,f+g):f=Math.min(f,g-1),m>=f))return;let E=f-m+1;if(k>0?k=k%E:k<0&&(k=(k%E+E)%E),k===0)return;let R=m+k;ce(b,m,R-1),ce(b,R,f),ce(b,m,f)}h.rotate=ke;function Ee(b,k,m=0,f=-1){let g=b.length;if(g===0)return;m<0?m=Math.max(0,m+g):m=Math.min(m,g-1),f<0?f=Math.max(0,f+g):f=Math.min(f,g-1);let E;f<m?E=f+1+(g-m):E=f-m+1;for(let R=0;R<E;++R)b[(m+R)%g]=k}h.fill=Ee;function bo(b,k,m){let f=b.length;k<0?k=Math.max(0,k+f):k=Math.min(k,f);for(let g=f;g>k;--g)b[g]=b[g-1];b[k]=m}h.insert=bo;function pt(b,k){let m=b.length;if(k<0&&(k+=m),k<0||k>=m)return;let f=b[k];for(let g=k+1;g<m;++g)b[g-1]=b[g];return b.length=m-1,f}h.removeAt=pt;function So(b,k,m=0,f=-1){let g=y(b,k,m,f);return g!==-1&&pt(b,g),g}h.removeFirstOf=So;function xo(b,k,m=-1,f=0){let g=S(b,k,m,f);return g!==-1&&pt(b,g),g}h.removeLastOf=xo;function Co(b,k,m=0,f=-1){let g=b.length;if(g===0)return 0;m<0?m=Math.max(0,m+g):m=Math.min(m,g-1),f<0?f=Math.max(0,f+g):f=Math.min(f,g-1);let E=0;for(let R=0;R<g;++R)m<=f&&R>=m&&R<=f&&b[R]===k||f<m&&(R<=f||R>=m)&&b[R]===k?E++:E>0&&(b[R-E]=b[R]);return E>0&&(b.length=g-E),E}h.removeAllOf=Co;function ko(b,k,m=0,f=-1){let g,E=C(b,k,m,f);return E!==-1&&(g=pt(b,E)),{index:E,value:g}}h.removeFirstWhere=ko;function Po(b,k,m=-1,f=0){let g,E=N(b,k,m,f);return E!==-1&&(g=pt(b,E)),{index:E,value:g}}h.removeLastWhere=Po;function Mo(b,k,m=0,f=-1){let g=b.length;if(g===0)return 0;m<0?m=Math.max(0,m+g):m=Math.min(m,g-1),f<0?f=Math.max(0,f+g):f=Math.min(f,g-1);let E=0;for(let R=0;R<g;++R)m<=f&&R>=m&&R<=f&&k(b[R],R)||f<m&&(R<=f||R>=m)&&k(b[R],R)?E++:E>0&&(b[R-E]=b[R]);return E>0&&(b.length=g-E),E}h.removeAllWhere=Mo}(i.ArrayExt||(i.ArrayExt={}));function*e(...h){for(let y of h)yield*y}function*t(){}function*n(h,y=0){for(let S of h)yield[y++,S]}function*s(h,y){let S=0;for(let C of h)y(C,S++)&&(yield C)}function r(h,y){let S=0;for(let C of h)if(y(C,S++))return C}function a(h,y){let S=0;for(let C of h)if(y(C,S++))return S-1;return-1}function o(h,y){let S;for(let C of h){if(S===void 0){S=C;continue}y(C,S)<0&&(S=C)}return S}function u(h,y){let S;for(let C of h){if(S===void 0){S=C;continue}y(C,S)>0&&(S=C)}return S}function c(h,y){let S=!0,C,N;for(let G of h)S?(C=G,N=G,S=!1):y(G,C)<0?C=G:y(G,N)>0&&(N=G);return S?void 0:[C,N]}function d(h){return Array.from(h)}function l(h){let y={};for(let[S,C]of h)y[S]=C;return y}function p(h,y){let S=0;for(let C of h)if(y(C,S++)===!1)return}function v(h,y){let S=0;for(let C of h)if(y(C,S++)===!1)return!1;return!0}function _(h,y){let S=0;for(let C of h)if(y(C,S++))return!0;return!1}function*I(h,y){let S=0;for(let C of h)yield y(C,S++)}function*M(h,y,S){y===void 0?(y=h,h=0,S=1):S===void 0&&(S=1);let C=j.rangeLength(h,y,S);for(let N=0;N<C;N++)yield h+S*N}var j;(function(h){function y(S,C,N){return N===0?1/0:S>C&&N>0||S<C&&N<0?0:Math.ceil((C-S)/N)}h.rangeLength=y})(j||(j={}));function q(h,y,S){let C=h[Symbol.iterator](),N=0,G=C.next();if(G.done&&S===void 0)throw new TypeError("Reduce of empty iterable with no initial value.");if(G.done)return S;let z=C.next();if(z.done&&S===void 0)return G.value;if(z.done)return y(S,G.value,N++);let F;S===void 0?F=y(G.value,z.value,N++):F=y(y(S,G.value,N++),z.value,N++);let X;for(;!(X=C.next()).done;)F=y(F,X.value,N++);return F}function*x(h,y){for(;0<y--;)yield h}function*w(h){yield h}function*O(h){if(typeof h.retro=="function")yield*h.retro();else for(let y=h.length-1;y>-1;y--)yield h[y]}function A(h){let y=[],S=new Set,C=new Map;for(let z of h)N(z);for(let[z]of C)G(z);return y;function N(z){let[F,X]=z,$=C.get(X);$?$.push(F):C.set(X,[F])}function G(z){if(S.has(z))return;S.add(z);let F=C.get(z);if(F)for(let X of F)G(X);y.push(z)}}function*T(h,y){let S=0;for(let C of h)S++%y===0&&(yield C)}i.StringExt=void 0,function(h){function y(z,F,X=0){let $=new Array(F.length);for(let ee=0,Y=X,ce=F.length;ee<ce;++ee,++Y){if(Y=z.indexOf(F[ee],Y),Y===-1)return null;$[ee]=Y}return $}h.findIndices=y;function S(z,F,X=0){let $=y(z,F,X);if(!$)return null;let ee=0;for(let Y=0,ce=$.length;Y<ce;++Y){let ke=$[Y]-X;ee+=ke*ke}return{score:ee,indices:$}}h.matchSumOfSquares=S;function C(z,F,X=0){let $=y(z,F,X);if(!$)return null;let ee=0,Y=X-1;for(let ce=0,ke=$.length;ce<ke;++ce){let Ee=$[ce];ee+=Ee-Y-1,Y=Ee}return{score:ee,indices:$}}h.matchSumOfDeltas=C;function N(z,F,X){let $=[],ee=0,Y=0,ce=F.length;for(;ee<ce;){let ke=F[ee],Ee=F[ee];for(;++ee<ce&&F[ee]===Ee+1;)Ee++;Y<ke&&$.push(z.slice(Y,ke)),ke<Ee+1&&$.push(X(z.slice(ke,Ee+1))),Y=Ee+1}return Y<z.length&&$.push(z.slice(Y)),$}h.highlight=N;function G(z,F){return z<F?-1:z>F?1:0}h.cmp=G}(i.StringExt||(i.StringExt={}));function*D(h,y){if(y<1)return;let S=h[Symbol.iterator](),C;for(;0<y--&&!(C=S.next()).done;)yield C.value}function*U(...h){let y=h.map(C=>C[Symbol.iterator]()),S=y.map(C=>C.next());for(;v(S,C=>!C.done);S=y.map(C=>C.next()))yield S.map(C=>C.value)}i.chain=e,i.each=p,i.empty=t,i.enumerate=n,i.every=v,i.filter=s,i.find=r,i.findIndex=a,i.map=I,i.max=u,i.min=o,i.minmax=c,i.once=w,i.range=M,i.reduce=q,i.repeat=x,i.retro=O,i.some=_,i.stride=T,i.take=D,i.toArray=d,i.toObject=l,i.topologicSort=A,i.zip=U})});var te=P((Jt,Os)=>{(function(i,e){typeof Jt=="object"&&typeof Os!="undefined"?e(Jt,si()):typeof define=="function"&&define.amd?define(["exports","@lumino/algorithm"],e):(i=typeof globalThis!="undefined"?globalThis:i||self,e(i.lumino_coreutils={},i.lumino_algorithm))})(Jt,function(i,e){"use strict";i.JSONExt=void 0,function(c){c.emptyObject=Object.freeze({}),c.emptyArray=Object.freeze([]);function d(x){return x===null||typeof x=="boolean"||typeof x=="number"||typeof x=="string"}c.isPrimitive=d;function l(x){return Array.isArray(x)}c.isArray=l;function p(x){return!d(x)&&!l(x)}c.isObject=p;function v(x,w){if(x===w)return!0;if(d(x)||d(w))return!1;let O=l(x),A=l(w);return O!==A?!1:O&&A?I(x,w):M(x,w)}c.deepEqual=v;function _(x){return d(x)?x:l(x)?j(x):q(x)}c.deepCopy=_;function I(x,w){if(x===w)return!0;if(x.length!==w.length)return!1;for(let O=0,A=x.length;O<A;++O)if(!v(x[O],w[O]))return!1;return!0}function M(x,w){if(x===w)return!0;for(let O in x)if(x[O]!==void 0&&!(O in w))return!1;for(let O in w)if(w[O]!==void 0&&!(O in x))return!1;for(let O in x){let A=x[O],T=w[O];if(!(A===void 0&&T===void 0)&&(A===void 0||T===void 0||!v(A,T)))return!1}return!0}function j(x){let w=new Array(x.length);for(let O=0,A=x.length;O<A;++O)w[O]=_(x[O]);return w}function q(x){let w={};for(let O in x){let A=x[O];A!==void 0&&(w[O]=_(A))}return w}}(i.JSONExt||(i.JSONExt={}));class t{constructor(){this._types=[],this._values=[]}types(){return this._types.slice()}hasData(d){return this._types.indexOf(d)!==-1}getData(d){let l=this._types.indexOf(d);return l!==-1?this._values[l]:void 0}setData(d,l){this.clearData(d),this._types.push(d),this._values.push(l)}clearData(d){let l=this._types.indexOf(d);l!==-1&&(this._types.splice(l,1),this._values.splice(l,1))}clear(){this._types.length=0,this._values.length=0}}class n{constructor(d={}){this._application=null,this._validatePlugin=()=>!0,this._plugins=new Map,this._services=new Map,d.validatePlugin&&(console.info("Plugins may be rejected by the custom validation plugin method."),this._validatePlugin=d.validatePlugin)}get application(){return this._application}set application(d){if(this._application!==null)throw Error("PluginRegistry.application is already set. It cannot be overridden.");this._application=d}get deferredPlugins(){return Array.from(this._plugins).filter(([d,l])=>l.autoStart==="defer").map(([d,l])=>d)}getPluginDescription(d){var l,p;return(p=(l=this._plugins.get(d))===null||l===void 0?void 0:l.description)!==null&&p!==void 0?p:""}hasPlugin(d){return this._plugins.has(d)}isPluginActivated(d){var l,p;return(p=(l=this._plugins.get(d))===null||l===void 0?void 0:l.activated)!==null&&p!==void 0?p:!1}listPlugins(){return Array.from(this._plugins.keys())}registerPlugin(d){if(this._plugins.has(d.id))throw new TypeError(`Plugin '${d.id}' is already registered.`);if(!this._validatePlugin(d))throw new Error(`Plugin '${d.id}' is not valid.`);let l=s.createPluginData(d);s.ensureNoCycle(l,this._plugins,this._services),l.provides&&this._services.set(l.provides,l.id),this._plugins.set(l.id,l)}registerPlugins(d){for(let l of d)this.registerPlugin(l)}deregisterPlugin(d,l){let p=this._plugins.get(d);if(p){if(p.activated&&!l)throw new Error(`Plugin '${d}' is still active.`);this._plugins.delete(d)}}async activatePlugin(d){let l=this._plugins.get(d);if(!l)throw new ReferenceError(`Plugin '${d}' is not registered.`);if(l.activated)return;if(l.promise)return l.promise;let p=l.requires.map(_=>this.resolveRequiredService(_)),v=l.optional.map(_=>this.resolveOptionalService(_));return l.promise=Promise.all([...p,...v]).then(_=>l.activate.apply(void 0,[this.application,..._])).then(_=>{l.service=_,l.activated=!0,l.promise=null}).catch(_=>{throw l.promise=null,_}),l.promise}async activatePlugins(d,l={}){switch(d){case"defer":{let p=this.deferredPlugins.filter(v=>this._plugins.get(v).autoStart).map(v=>this.activatePlugin(v));await Promise.all(p);break}case"startUp":{let v=s.collectStartupPlugins(this._plugins,l).map(async _=>{try{return await this.activatePlugin(_)}catch(I){console.error(`Plugin '${_}' failed to activate.`,I)}});await Promise.all(v);break}}}async deactivatePlugin(d){let l=this._plugins.get(d);if(!l)throw new ReferenceError(`Plugin '${d}' is not registered.`);if(!l.activated)return[];if(!l.deactivate)throw new TypeError(`Plugin '${d}'#deactivate() method missing`);let p=s.findDependents(d,this._plugins,this._services),v=p.map(_=>this._plugins.get(_));for(let _ of v)if(!_.deactivate)throw new TypeError(`Plugin ${_.id}#deactivate() method missing (depends on ${d})`);for(let _ of v){let I=[..._.requires,..._.optional].map(M=>{let j=this._services.get(M);return j?this._plugins.get(j).service:null});await _.deactivate(this.application,...I),_.service=null,_.activated=!1}return p.pop(),p}async resolveRequiredService(d){let l=this._services.get(d);if(!l)throw new TypeError(`No provider for: ${d.name}.`);let p=this._plugins.get(l);return p.activated||await this.activatePlugin(l),p.service}async resolveOptionalService(d){let l=this._services.get(d);if(!l)return null;let p=this._plugins.get(l);if(!p.activated)try{await this.activatePlugin(l)}catch(v){return console.error(v),null}return p.service}}var s;(function(c){class d{constructor(M){var j,q,x,w;this._activated=!1,this._promise=null,this._service=null,this.id=M.id,this.description=(j=M.description)!==null&&j!==void 0?j:"",this.activate=M.activate,this.deactivate=(q=M.deactivate)!==null&&q!==void 0?q:null,this.provides=(x=M.provides)!==null&&x!==void 0?x:null,this.autoStart=(w=M.autoStart)!==null&&w!==void 0?w:!1,this.requires=M.requires?M.requires.slice():[],this.optional=M.optional?M.optional.slice():[]}get activated(){return this._activated}set activated(M){this._activated=M}get service(){return this._service}set service(M){this._service=M}get promise(){return this._promise}set promise(M){this._promise=M}}function l(I){return new d(I)}c.createPluginData=l;function p(I,M,j){let q=[...I.requires,...I.optional],x=O=>{if(O===I.provides)return!0;let A=j.get(O);if(!A)return!1;let T=M.get(A),D=[...T.requires,...T.optional];return D.length===0?!1:(w.push(A),D.some(x)?!0:(w.pop(),!1))};if(!I.provides||q.length===0)return;let w=[I.id];if(q.some(x))throw new ReferenceError(`Cycle detected: ${w.join(" -> ")}.`)}c.ensureNoCycle=p;function v(I,M,j){let q=new Array,x=D=>{let U=M.get(D),h=[...U.requires,...U.optional];q.push(...h.reduce((y,S)=>{let C=j.get(S);return C&&y.push([D,C]),y},[]))};for(let D of M.keys())x(D);let w=q.filter(D=>D[1]===I),O=0;for(;w.length>O;){let D=w.length,U=new Set(w.map(h=>h[0]));for(let h of U)q.filter(y=>y[1]===h).forEach(y=>{w.includes(y)||w.push(y)});O=D}let A=e.topologicSort(w),T=A.findIndex(D=>D===I);return T===-1?[I]:A.slice(0,T+1)}c.findDependents=v;function _(I,M){let j=new Set;for(let q of I.keys())I.get(q).autoStart===!0&&j.add(q);if(M.startPlugins)for(let q of M.startPlugins)j.add(q);if(M.ignorePlugins)for(let q of M.ignorePlugins)j.delete(q);return Array.from(j)}c.collectStartupPlugins=_})(s||(s={}));class r{constructor(){this.promise=new Promise((d,l)=>{this._resolve=d,this._reject=l})}resolve(d){let l=this._resolve;l(d)}reject(d){let l=this._reject;l(d)}}class a{constructor(d,l){this.name=d,this.description=l!=null?l:"",this._tokenStructuralPropertyT=null}}function o(c){let d=0;for(let l=0,p=c.length;l<p;++l)l%4===0&&(d=Math.random()*4294967295>>>0),c[l]=d&255,d>>>=8}i.Random=void 0,function(c){c.getRandomValues=(()=>{let d=typeof window!="undefined"&&(window.crypto||window.msCrypto)||null;return d&&typeof d.getRandomValues=="function"?function(p){return d.getRandomValues(p)}:o})()}(i.Random||(i.Random={}));function u(c){let d=new Uint8Array(16),l=new Array(256);for(let p=0;p<16;++p)l[p]="0"+p.toString(16);for(let p=16;p<256;++p)l[p]=p.toString(16);return function(){return c(d),d[6]=64|d[6]&15,d[8]=128|d[8]&63,l[d[0]]+l[d[1]]+l[d[2]]+l[d[3]]+"-"+l[d[4]]+l[d[5]]+"-"+l[d[6]]+l[d[7]]+"-"+l[d[8]]+l[d[9]]+"-"+l[d[10]]+l[d[11]]+l[d[12]]+l[d[13]]+l[d[14]]+l[d[15]]}}i.UUID=void 0,function(c){c.uuid4=u(i.Random.getRandomValues)}(i.UUID||(i.UUID={})),i.MimeData=t,i.PluginRegistry=n,i.PromiseDelegate=r,i.Token=a})});var Z=P((Ht,Rs)=>{(function(i,e){typeof Ht=="object"&&typeof Rs!="undefined"?e(Ht,si(),te()):typeof define=="function"&&define.amd?define(["exports","@lumino/algorithm","@lumino/coreutils"],e):(i=typeof globalThis!="undefined"?globalThis:i||self,e(i.lumino_signaling={},i.lumino_algorithm,i.lumino_coreutils))})(Ht,function(i,e,t){"use strict";class n{constructor(o){this.sender=o}connect(o,u){return r.connect(this,o,u)}disconnect(o,u){return r.disconnect(this,o,u)}emit(o){r.emit(this,o)}}(function(a){function o(_,I){r.disconnectBetween(_,I)}a.disconnectBetween=o;function u(_){r.disconnectSender(_)}a.disconnectSender=u;function c(_){r.disconnectReceiver(_)}a.disconnectReceiver=c;function d(_){r.disconnectAll(_)}a.disconnectAll=d;function l(_){r.disconnectAll(_)}a.clearData=l;function p(){return r.exceptionHandler}a.getExceptionHandler=p;function v(_){let I=r.exceptionHandler;return r.exceptionHandler=_,I}a.setExceptionHandler=v})(n||(n={}));class s extends n{constructor(){super(...arguments),this._pending=new t.PromiseDelegate}async*[Symbol.asyncIterator](){let o=this._pending;for(;;)try{let{args:u,next:c}=await o.promise;o=c,yield u}catch{return}}emit(o){let u=this._pending,c=this._pending=new t.PromiseDelegate;u.resolve({args:o,next:c}),super.emit(o)}stop(){this._pending.promise.catch(()=>{}),this._pending.reject("stop"),this._pending=new t.PromiseDelegate}}var r;(function(a){a.exceptionHandler=D=>{console.error(D)};function o(D,U,h){h=h||void 0;let y=_.get(D.sender);if(y||(y=[],_.set(D.sender,y)),q(y,D,U,h))return!1;let S=h||U,C=I.get(S);C||(C=[],I.set(S,C));let N={signal:D,slot:U,thisArg:h};return y.push(N),C.push(N),!0}a.connect=o;function u(D,U,h){h=h||void 0;let y=_.get(D.sender);if(!y||y.length===0)return!1;let S=q(y,D,U,h);if(!S)return!1;let C=h||U,N=I.get(C);return S.signal=null,w(y),w(N),!0}a.disconnect=u;function c(D,U){let h=_.get(D);if(!h||h.length===0)return;let y=I.get(U);if(!(!y||y.length===0)){for(let S of y)S.signal&&S.signal.sender===D&&(S.signal=null);w(h),w(y)}}a.disconnectBetween=c;function d(D){let U=_.get(D);if(!(!U||U.length===0)){for(let h of U){if(!h.signal)continue;let y=h.thisArg||h.slot;h.signal=null,w(I.get(y))}w(U)}}a.disconnectSender=d;function l(D){let U=I.get(D);if(!(!U||U.length===0)){for(let h of U){if(!h.signal)continue;let y=h.signal.sender;h.signal=null,w(_.get(y))}w(U)}}a.disconnectReceiver=l;function p(D){d(D),l(D)}a.disconnectAll=p;function v(D,U){let h=_.get(D.sender);if(!(!h||h.length===0))for(let y=0,S=h.length;y<S;++y){let C=h[y];C.signal===D&&x(C,U)}}a.emit=v;let _=new WeakMap,I=new WeakMap,M=new Set,j=typeof requestAnimationFrame=="function"?requestAnimationFrame:setImmediate;function q(D,U,h,y){return e.find(D,S=>S.signal===U&&S.slot===h&&S.thisArg===y)}function x(D,U){let{signal:h,slot:y,thisArg:S}=D;try{y.call(S,h.sender,U)}catch(C){a.exceptionHandler(C)}}function w(D){M.size===0&&j(O),M.add(D)}function O(){M.forEach(A),M.clear()}function A(D){e.ArrayExt.removeAllWhere(D,T)}function T(D){return D.signal===null}})(r||(r={})),i.Signal=n,i.Stream=s})});var Ds=P(Gt=>{"use strict";Object.defineProperty(Gt,"__esModule",{value:!0});Gt.ActivityMonitor=void 0;var js=Z(),ri=class{constructor(e){this._timer=-1,this._timeout=-1,this._isDisposed=!1,this._activityStopped=new js.Signal(this),e.signal.connect(this._onSignalFired,this),this._timeout=e.timeout||1e3}get activityStopped(){return this._activityStopped}get timeout(){return this._timeout}set timeout(e){this._timeout=e}get isDisposed(){return this._isDisposed}dispose(){this._isDisposed||(this._isDisposed=!0,js.Signal.clearData(this))}_onSignalFired(e,t){clearTimeout(this._timer),this._sender=e,this._args=t,this._timer=setTimeout(()=>{this._activityStopped.emit({sender:this._sender,args:this._args})},this._timeout)}};Gt.ActivityMonitor=ri});var qs=P(Ts=>{"use strict";Object.defineProperty(Ts,"__esModule",{value:!0})});var Us=P(Yt=>{"use strict";Object.defineProperty(Yt,"__esModule",{value:!0});Yt.LruCache=void 0;var Ho=128,ai=class{constructor(e={}){this._map=new Map,this._maxSize=(e==null?void 0:e.maxSize)||Ho}get size(){return this._map.size}clear(){this._map.clear()}get(e){let t=this._map.get(e)||null;return t!=null&&(this._map.delete(e),this._map.set(e,t)),t}set(e,t){this._map.size>=this._maxSize&&this._map.delete(this._map.keys().next().value),this._map.set(e,t)}};Yt.LruCache=ai});var Ns=P(Xt=>{"use strict";Object.defineProperty(Xt,"__esModule",{value:!0});Xt.MarkdownCodeBlocks=void 0;var As;(function(i){i.CODE_BLOCK_MARKER="```";let e=[".markdown",".mdown",".mkdn",".md",".mkd",".mdwn",".mdtxt",".mdtext",".text",".txt",".Rmd"];class t{constructor(a){this.startLine=a,this.code="",this.endLine=-1}}i.MarkdownCodeBlock=t;function n(r){return e.indexOf(r)>-1}i.isMarkdown=n;function s(r){if(!r||r==="")return[];let a=r.split(`
2
- `),o=[],u=null;for(let c=0;c<a.length;c++){let d=a[c],l=d.indexOf(i.CODE_BLOCK_MARKER)===0,p=u!=null;if(!(!l&&!p))if(p)u&&(l?(u.endLine=c-1,o.push(u),u=null):u.code+=d+`
3
- `);else{u=new t(c);let v=d.indexOf(i.CODE_BLOCK_MARKER),_=d.lastIndexOf(i.CODE_BLOCK_MARKER);v!==_&&(u.code=d.substring(v+i.CODE_BLOCK_MARKER.length,_),u.endLine=c,o.push(u),u=null)}}return o}i.findMarkdownCodeBlocks=s})(As||(Xt.MarkdownCodeBlocks=As={}))});var Ks=P((cu,Fs)=>{"use strict";function Go(i,e){var t=i;e.slice(0,-1).forEach(function(s){t=t[s]||{}});var n=e[e.length-1];return n in t}function Ls(i){return typeof i=="number"||/^0x[0-9a-f]+$/i.test(i)?!0:/^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(i)}function zs(i,e){return e==="constructor"&&typeof i[e]=="function"||e==="__proto__"}Fs.exports=function(i,e){e||(e={});var t={bools:{},strings:{},unknownFn:null};typeof e.unknown=="function"&&(t.unknownFn=e.unknown),typeof e.boolean=="boolean"&&e.boolean?t.allBools=!0:[].concat(e.boolean).filter(Boolean).forEach(function(w){t.bools[w]=!0});var n={};function s(w){return n[w].some(function(O){return t.bools[O]})}Object.keys(e.alias||{}).forEach(function(w){n[w]=[].concat(e.alias[w]),n[w].forEach(function(O){n[O]=[w].concat(n[w].filter(function(A){return O!==A}))})}),[].concat(e.string).filter(Boolean).forEach(function(w){t.strings[w]=!0,n[w]&&[].concat(n[w]).forEach(function(O){t.strings[O]=!0})});var r=e.default||{},a={_:[]};function o(w,O){return t.allBools&&/^--[^=]+$/.test(O)||t.strings[w]||t.bools[w]||n[w]}function u(w,O,A){for(var T=w,D=0;D<O.length-1;D++){var U=O[D];if(zs(T,U))return;T[U]===void 0&&(T[U]={}),(T[U]===Object.prototype||T[U]===Number.prototype||T[U]===String.prototype)&&(T[U]={}),T[U]===Array.prototype&&(T[U]=[]),T=T[U]}var h=O[O.length-1];zs(T,h)||((T===Object.prototype||T===Number.prototype||T===String.prototype)&&(T={}),T===Array.prototype&&(T=[]),T[h]===void 0||t.bools[h]||typeof T[h]=="boolean"?T[h]=A:Array.isArray(T[h])?T[h].push(A):T[h]=[T[h],A])}function c(w,O,A){if(!(A&&t.unknownFn&&!o(w,A)&&t.unknownFn(A)===!1)){var T=!t.strings[w]&&Ls(O)?Number(O):O;u(a,w.split("."),T),(n[w]||[]).forEach(function(D){u(a,D.split("."),T)})}}Object.keys(t.bools).forEach(function(w){c(w,r[w]===void 0?!1:r[w])});var d=[];i.indexOf("--")!==-1&&(d=i.slice(i.indexOf("--")+1),i=i.slice(0,i.indexOf("--")));for(var l=0;l<i.length;l++){var p=i[l],v,_;if(/^--.+=/.test(p)){var I=p.match(/^--([^=]+)=([\s\S]*)$/);v=I[1];var M=I[2];t.bools[v]&&(M=M!=="false"),c(v,M,p)}else if(/^--no-.+/.test(p))v=p.match(/^--no-(.+)/)[1],c(v,!1,p);else if(/^--.+/.test(p))v=p.match(/^--(.+)/)[1],_=i[l+1],_!==void 0&&!/^(-|--)[^-]/.test(_)&&!t.bools[v]&&!t.allBools&&(!n[v]||!s(v))?(c(v,_,p),l+=1):/^(true|false)$/.test(_)?(c(v,_==="true",p),l+=1):c(v,t.strings[v]?"":!0,p);else if(/^-[^-]+/.test(p)){for(var j=p.slice(1,-1).split(""),q=!1,x=0;x<j.length;x++){if(_=p.slice(x+2),_==="-"){c(j[x],_,p);continue}if(/[A-Za-z]/.test(j[x])&&_[0]==="="){c(j[x],_.slice(1),p),q=!0;break}if(/[A-Za-z]/.test(j[x])&&/-?\d+(\.\d*)?(e-?\d+)?$/.test(_)){c(j[x],_,p),q=!0;break}if(j[x+1]&&j[x+1].match(/\W/)){c(j[x],p.slice(x+2),p),q=!0;break}else c(j[x],t.strings[j[x]]?"":!0,p)}v=p.slice(-1)[0],!q&&v!=="-"&&(i[l+1]&&!/^(-|--)[^-]/.test(i[l+1])&&!t.bools[v]&&(!n[v]||!s(v))?(c(v,i[l+1],p),l+=1):i[l+1]&&/^(true|false)$/.test(i[l+1])?(c(v,i[l+1]==="true",p),l+=1):c(v,t.strings[v]?"":!0,p))}else if((!t.unknownFn||t.unknownFn(p)!==!1)&&a._.push(t.strings._||!Ls(p)?p:Number(p)),e.stopEarly){a._.push.apply(a._,i.slice(l+1));break}}return Object.keys(r).forEach(function(w){Go(a,w.split("."))||(u(a,w.split("."),r[w]),(n[w]||[]).forEach(function(O){u(a,O.split("."),r[w])}))}),e["--"]?a["--"]=d.slice():d.forEach(function(w){a._.push(w)}),a}});var Zt=P((du,$s)=>{"use strict";function Oe(i){if(typeof i!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(i))}function Bs(i,e){for(var t="",n=0,s=-1,r=0,a,o=0;o<=i.length;++o){if(o<i.length)a=i.charCodeAt(o);else{if(a===47)break;a=47}if(a===47){if(!(s===o-1||r===1))if(s!==o-1&&r===2){if(t.length<2||n!==2||t.charCodeAt(t.length-1)!==46||t.charCodeAt(t.length-2)!==46){if(t.length>2){var u=t.lastIndexOf("/");if(u!==t.length-1){u===-1?(t="",n=0):(t=t.slice(0,u),n=t.length-1-t.lastIndexOf("/")),s=o,r=0;continue}}else if(t.length===2||t.length===1){t="",n=0,s=o,r=0;continue}}e&&(t.length>0?t+="/..":t="..",n=2)}else t.length>0?t+="/"+i.slice(s+1,o):t=i.slice(s+1,o),n=o-s-1;s=o,r=0}else a===46&&r!==-1?++r:r=-1}return t}function Yo(i,e){var t=e.dir||e.root,n=e.base||(e.name||"")+(e.ext||"");return t?t===e.root?t+n:t+i+n:n}var it={resolve:function(){for(var e="",t=!1,n,s=arguments.length-1;s>=-1&&!t;s--){var r;s>=0?r=arguments[s]:(n===void 0&&(n=process.cwd()),r=n),Oe(r),r.length!==0&&(e=r+"/"+e,t=r.charCodeAt(0)===47)}return e=Bs(e,!t),t?e.length>0?"/"+e:"/":e.length>0?e:"."},normalize:function(e){if(Oe(e),e.length===0)return".";var t=e.charCodeAt(0)===47,n=e.charCodeAt(e.length-1)===47;return e=Bs(e,!t),e.length===0&&!t&&(e="."),e.length>0&&n&&(e+="/"),t?"/"+e:e},isAbsolute:function(e){return Oe(e),e.length>0&&e.charCodeAt(0)===47},join:function(){if(arguments.length===0)return".";for(var e,t=0;t<arguments.length;++t){var n=arguments[t];Oe(n),n.length>0&&(e===void 0?e=n:e+="/"+n)}return e===void 0?".":it.normalize(e)},relative:function(e,t){if(Oe(e),Oe(t),e===t||(e=it.resolve(e),t=it.resolve(t),e===t))return"";for(var n=1;n<e.length&&e.charCodeAt(n)===47;++n);for(var s=e.length,r=s-n,a=1;a<t.length&&t.charCodeAt(a)===47;++a);for(var o=t.length,u=o-a,c=r<u?r:u,d=-1,l=0;l<=c;++l){if(l===c){if(u>c){if(t.charCodeAt(a+l)===47)return t.slice(a+l+1);if(l===0)return t.slice(a+l)}else r>c&&(e.charCodeAt(n+l)===47?d=l:l===0&&(d=0));break}var p=e.charCodeAt(n+l),v=t.charCodeAt(a+l);if(p!==v)break;p===47&&(d=l)}var _="";for(l=n+d+1;l<=s;++l)(l===s||e.charCodeAt(l)===47)&&(_.length===0?_+="..":_+="/..");return _.length>0?_+t.slice(a+d):(a+=d,t.charCodeAt(a)===47&&++a,t.slice(a))},_makeLong:function(e){return e},dirname:function(e){if(Oe(e),e.length===0)return".";for(var t=e.charCodeAt(0),n=t===47,s=-1,r=!0,a=e.length-1;a>=1;--a)if(t=e.charCodeAt(a),t===47){if(!r){s=a;break}}else r=!1;return s===-1?n?"/":".":n&&s===1?"//":e.slice(0,s)},basename:function(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');Oe(e);var n=0,s=-1,r=!0,a;if(t!==void 0&&t.length>0&&t.length<=e.length){if(t.length===e.length&&t===e)return"";var o=t.length-1,u=-1;for(a=e.length-1;a>=0;--a){var c=e.charCodeAt(a);if(c===47){if(!r){n=a+1;break}}else u===-1&&(r=!1,u=a+1),o>=0&&(c===t.charCodeAt(o)?--o===-1&&(s=a):(o=-1,s=u))}return n===s?s=u:s===-1&&(s=e.length),e.slice(n,s)}else{for(a=e.length-1;a>=0;--a)if(e.charCodeAt(a)===47){if(!r){n=a+1;break}}else s===-1&&(r=!1,s=a+1);return s===-1?"":e.slice(n,s)}},extname:function(e){Oe(e);for(var t=-1,n=0,s=-1,r=!0,a=0,o=e.length-1;o>=0;--o){var u=e.charCodeAt(o);if(u===47){if(!r){n=o+1;break}continue}s===-1&&(r=!1,s=o+1),u===46?t===-1?t=o:a!==1&&(a=1):t!==-1&&(a=-1)}return t===-1||s===-1||a===0||a===1&&t===s-1&&t===n+1?"":e.slice(t,s)},format:function(e){if(e===null||typeof e!="object")throw new TypeError('The "pathObject" argument must be of type Object. Received type '+typeof e);return Yo("/",e)},parse:function(e){Oe(e);var t={root:"",dir:"",base:"",ext:"",name:""};if(e.length===0)return t;var n=e.charCodeAt(0),s=n===47,r;s?(t.root="/",r=1):r=0;for(var a=-1,o=0,u=-1,c=!0,d=e.length-1,l=0;d>=r;--d){if(n=e.charCodeAt(d),n===47){if(!c){o=d+1;break}continue}u===-1&&(c=!1,u=d+1),n===46?a===-1?a=d:l!==1&&(l=1):a!==-1&&(l=-1)}return a===-1||u===-1||l===0||l===1&&a===u-1&&a===o+1?u!==-1&&(o===0&&s?t.base=t.name=e.slice(1,u):t.base=t.name=e.slice(o,u)):(o===0&&s?(t.name=e.slice(1,a),t.base=e.slice(1,u)):(t.name=e.slice(o,a),t.base=e.slice(o,u)),t.ext=e.slice(a,u)),o>0?t.dir=e.slice(0,o-1):s&&(t.dir="/"),t},sep:"/",delimiter:":",win32:null,posix:null};it.posix=it;$s.exports=it});var Ws=P((uu,Vs)=>{"use strict";Vs.exports=function(e,t){if(t=t.split(":")[0],e=+e,!e)return!1;switch(t){case"http":case"ws":return e!==80;case"https":case"wss":return e!==443;case"ftp":return e!==21;case"gopher":return e!==70;case"file":return!1}return e!==0}});var Gs=P(oi=>{"use strict";var Xo=Object.prototype.hasOwnProperty,Zo;function Js(i){try{return decodeURIComponent(i.replace(/\+/g," "))}catch{return null}}function Hs(i){try{return encodeURIComponent(i)}catch{return null}}function Qo(i){for(var e=/([^=?#&]+)=?([^&]*)/g,t={},n;n=e.exec(i);){var s=Js(n[1]),r=Js(n[2]);s===null||r===null||s in t||(t[s]=r)}return t}function el(i,e){e=e||"";var t=[],n,s;typeof e!="string"&&(e="?");for(s in i)if(Xo.call(i,s)){if(n=i[s],!n&&(n===null||n===Zo||isNaN(n))&&(n=""),s=Hs(s),n=Hs(n),s===null||n===null)continue;t.push(s+"="+n)}return t.length?e+t.join("&"):""}oi.stringify=el;oi.parse=Qo});var ir=P((hu,nr)=>{"use strict";var Xs=Ws(),Qt=Gs(),tl=/^[\x00-\x20\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]+/,Zs=/[\n\r\t]/g,nl=/^[A-Za-z][A-Za-z0-9+-.]*:\/\//,Qs=/:\d+$/,il=/^([a-z][a-z0-9.+-]*:)?(\/\/)?([\\/]+)?([\S\s]*)/i,sl=/^[a-zA-Z]:/;function ci(i){return(i||"").toString().replace(tl,"")}var li=[["#","hash"],["?","query"],function(e,t){return Re(t.protocol)?e.replace(/\\/g,"/"):e},["/","pathname"],["@","auth",1],[NaN,"host",void 0,1,1],[/:(\d*)$/,"port",void 0,1],[NaN,"hostname",void 0,1,1]],Ys={hash:1,query:1};function er(i){var e;typeof window!="undefined"?e=window:typeof global!="undefined"?e=global:typeof self!="undefined"?e=self:e={};var t=e.location||{};i=i||t;var n={},s=typeof i,r;if(i.protocol==="blob:")n=new je(unescape(i.pathname),{});else if(s==="string"){n=new je(i,{});for(r in Ys)delete n[r]}else if(s==="object"){for(r in i)r in Ys||(n[r]=i[r]);n.slashes===void 0&&(n.slashes=nl.test(i.href))}return n}function Re(i){return i==="file:"||i==="ftp:"||i==="http:"||i==="https:"||i==="ws:"||i==="wss:"}function tr(i,e){i=ci(i),i=i.replace(Zs,""),e=e||{};var t=il.exec(i),n=t[1]?t[1].toLowerCase():"",s=!!t[2],r=!!t[3],a=0,o;return s?r?(o=t[2]+t[3]+t[4],a=t[2].length+t[3].length):(o=t[2]+t[4],a=t[2].length):r?(o=t[3]+t[4],a=t[3].length):o=t[4],n==="file:"?a>=2&&(o=o.slice(2)):Re(n)?o=t[4]:n?s&&(o=o.slice(2)):a>=2&&Re(e.protocol)&&(o=t[4]),{protocol:n,slashes:s||Re(n),slashesCount:a,rest:o}}function rl(i,e){if(i==="")return e;for(var t=(e||"/").split("/").slice(0,-1).concat(i.split("/")),n=t.length,s=t[n-1],r=!1,a=0;n--;)t[n]==="."?t.splice(n,1):t[n]===".."?(t.splice(n,1),a++):a&&(n===0&&(r=!0),t.splice(n,1),a--);return r&&t.unshift(""),(s==="."||s==="..")&&t.push(""),t.join("/")}function je(i,e,t){if(i=ci(i),i=i.replace(Zs,""),!(this instanceof je))return new je(i,e,t);var n,s,r,a,o,u,c=li.slice(),d=typeof e,l=this,p=0;for(d!=="object"&&d!=="string"&&(t=e,e=null),t&&typeof t!="function"&&(t=Qt.parse),e=er(e),s=tr(i||"",e),n=!s.protocol&&!s.slashes,l.slashes=s.slashes||n&&e.slashes,l.protocol=s.protocol||e.protocol||"",i=s.rest,(s.protocol==="file:"&&(s.slashesCount!==2||sl.test(i))||!s.slashes&&(s.protocol||s.slashesCount<2||!Re(l.protocol)))&&(c[3]=[/(.*)/,"pathname"]);p<c.length;p++){if(a=c[p],typeof a=="function"){i=a(i,l);continue}r=a[0],u=a[1],r!==r?l[u]=i:typeof r=="string"?(o=r==="@"?i.lastIndexOf(r):i.indexOf(r),~o&&(typeof a[2]=="number"?(l[u]=i.slice(0,o),i=i.slice(o+a[2])):(l[u]=i.slice(o),i=i.slice(0,o)))):(o=r.exec(i))&&(l[u]=o[1],i=i.slice(0,o.index)),l[u]=l[u]||n&&a[3]&&e[u]||"",a[4]&&(l[u]=l[u].toLowerCase())}t&&(l.query=t(l.query)),n&&e.slashes&&l.pathname.charAt(0)!=="/"&&(l.pathname!==""||e.pathname!=="")&&(l.pathname=rl(l.pathname,e.pathname)),l.pathname.charAt(0)!=="/"&&Re(l.protocol)&&(l.pathname="/"+l.pathname),Xs(l.port,l.protocol)||(l.host=l.hostname,l.port=""),l.username=l.password="",l.auth&&(o=l.auth.indexOf(":"),~o?(l.username=l.auth.slice(0,o),l.username=encodeURIComponent(decodeURIComponent(l.username)),l.password=l.auth.slice(o+1),l.password=encodeURIComponent(decodeURIComponent(l.password))):l.username=encodeURIComponent(decodeURIComponent(l.auth)),l.auth=l.password?l.username+":"+l.password:l.username),l.origin=l.protocol!=="file:"&&Re(l.protocol)&&l.host?l.protocol+"//"+l.host:"null",l.href=l.toString()}function al(i,e,t){var n=this;switch(i){case"query":typeof e=="string"&&e.length&&(e=(t||Qt.parse)(e)),n[i]=e;break;case"port":n[i]=e,Xs(e,n.protocol)?e&&(n.host=n.hostname+":"+e):(n.host=n.hostname,n[i]="");break;case"hostname":n[i]=e,n.port&&(e+=":"+n.port),n.host=e;break;case"host":n[i]=e,Qs.test(e)?(e=e.split(":"),n.port=e.pop(),n.hostname=e.join(":")):(n.hostname=e,n.port="");break;case"protocol":n.protocol=e.toLowerCase(),n.slashes=!t;break;case"pathname":case"hash":if(e){var s=i==="pathname"?"/":"#";n[i]=e.charAt(0)!==s?s+e:e}else n[i]=e;break;case"username":case"password":n[i]=encodeURIComponent(e);break;case"auth":var r=e.indexOf(":");~r?(n.username=e.slice(0,r),n.username=encodeURIComponent(decodeURIComponent(n.username)),n.password=e.slice(r+1),n.password=encodeURIComponent(decodeURIComponent(n.password))):n.username=encodeURIComponent(decodeURIComponent(e))}for(var a=0;a<li.length;a++){var o=li[a];o[4]&&(n[o[1]]=n[o[1]].toLowerCase())}return n.auth=n.password?n.username+":"+n.password:n.username,n.origin=n.protocol!=="file:"&&Re(n.protocol)&&n.host?n.protocol+"//"+n.host:"null",n.href=n.toString(),n}function ol(i){(!i||typeof i!="function")&&(i=Qt.stringify);var e,t=this,n=t.host,s=t.protocol;s&&s.charAt(s.length-1)!==":"&&(s+=":");var r=s+(t.protocol&&t.slashes||Re(t.protocol)?"//":"");return t.username?(r+=t.username,t.password&&(r+=":"+t.password),r+="@"):t.password?(r+=":"+t.password,r+="@"):t.protocol!=="file:"&&Re(t.protocol)&&!n&&t.pathname!=="/"&&(r+="@"),(n[n.length-1]===":"||Qs.test(t.hostname)&&!t.port)&&(n+=":"),r+=n+t.pathname,e=typeof t.query=="object"?i(t.query):t.query,e&&(r+=e.charAt(0)!=="?"?"?"+e:e),t.hash&&(r+=t.hash),r}je.prototype={set:al,toString:ol};je.extractProtocol=tr;je.location=er;je.trimLeft=ci;je.qs=Qt;nr.exports=je});var di=P(st=>{"use strict";var ll=st&&st.__importDefault||function(i){return i&&i.__esModule?i:{default:i}};Object.defineProperty(st,"__esModule",{value:!0});st.URLExt=void 0;var cl=Zt(),en=ll(ir()),sr;(function(i){function e(c){if(typeof document!="undefined"&&document){let d=document.createElement("a");return d.href=c,d}return(0,en.default)(c)}i.parse=e;function t(c){return(0,en.default)(c).hostname}i.getHostName=t;function n(c){return c&&e(c).toString()}i.normalize=n;function s(...c){let d=(0,en.default)(c[0],{}),l=d.protocol===""&&d.slashes;l&&(d=(0,en.default)(c[0],"https:"+c[0]));let p=`${l?"":d.protocol}${d.slashes?"//":""}${d.auth}${d.auth?"@":""}${d.host}`,v=cl.posix.join(`${p&&d.pathname[0]!=="/"?"/":""}${d.pathname}`,...c.slice(1));return`${p}${v==="."?"":v}`}i.join=s;function r(c){return s(...c.split("/").map(encodeURIComponent))}i.encodeParts=r;function a(c){let d=Object.keys(c).filter(l=>l.length>0);return d.length?"?"+d.map(l=>{let p=encodeURIComponent(String(c[l]));return l+(p?"="+p:"")}).join("&"):""}i.objectToQueryString=a;function o(c){return c.replace(/^\?/,"").split("&").reduce((d,l)=>{let[p,v]=l.split("=");return p.length>0&&(d[p]=decodeURIComponent(v||"")),d},{})}i.queryStringToObject=o;function u(c,d=!1){let{protocol:l}=e(c);return(!l||c.toLowerCase().indexOf(l)!==0)&&(d?c.indexOf("//")!==0:c.indexOf("/")!==0)}i.isLocal=u})(sr||(st.URLExt=sr={}))});var rr=P((exports,module)=>{"use strict";var __importDefault=exports&&exports.__importDefault||function(i){return i&&i.__esModule?i:{default:i}};Object.defineProperty(exports,"__esModule",{value:!0});exports.PageConfig=void 0;var coreutils_1=te(),minimist_1=__importDefault(Ks()),url_1=di(),PageConfig;(function(PageConfig){function getOption(name){if(configData)return configData[name]||getBodyData(name);configData=Object.create(null);let found=!1;if(typeof document!="undefined"&&document){let i=document.getElementById("jupyter-config-data");i&&(configData=JSON.parse(i.textContent||""),found=!0)}if(!found&&typeof process!="undefined"&&process.argv)try{let cli=(0,minimist_1.default)(process.argv.slice(2)),path=Zt(),fullPath="";"jupyter-config-data"in cli?fullPath=path.resolve(cli["jupyter-config-data"]):"JUPYTER_CONFIG_DATA"in process.env&&(fullPath=path.resolve(process.env.JUPYTER_CONFIG_DATA)),fullPath&&(configData=eval("require")(fullPath))}catch(i){console.error(i)}if(!coreutils_1.JSONExt.isObject(configData))configData=Object.create(null);else for(let i in configData)typeof configData[i]!="string"&&(configData[i]=JSON.stringify(configData[i]));return configData[name]||getBodyData(name)}PageConfig.getOption=getOption;function setOption(i,e){let t=getOption(i);return configData[i]=e,t}PageConfig.setOption=setOption;function getBaseUrl(){return url_1.URLExt.normalize(getOption("baseUrl")||"/")}PageConfig.getBaseUrl=getBaseUrl;function getTreeUrl(){return url_1.URLExt.join(getBaseUrl(),getOption("treeUrl"))}PageConfig.getTreeUrl=getTreeUrl;function getShareUrl(){return url_1.URLExt.normalize(getOption("shareUrl")||getBaseUrl())}PageConfig.getShareUrl=getShareUrl;function getTreeShareUrl(){return url_1.URLExt.normalize(url_1.URLExt.join(getShareUrl(),getOption("treeUrl")))}PageConfig.getTreeShareUrl=getTreeShareUrl;function getUrl(i){var e,t,n,s;let r=i.toShare?getShareUrl():getBaseUrl(),a=(e=i.mode)!==null&&e!==void 0?e:getOption("mode"),o=(t=i.workspace)!==null&&t!==void 0?t:getOption("workspace"),u=a==="single-document"?"doc":"lab";r=url_1.URLExt.join(r,u),o!==PageConfig.defaultWorkspace&&(r=url_1.URLExt.join(r,"workspaces",encodeURIComponent((n=getOption("workspace"))!==null&&n!==void 0?n:PageConfig.defaultWorkspace)));let c=(s=i.treePath)!==null&&s!==void 0?s:getOption("treePath");return c&&(r=url_1.URLExt.join(r,"tree",url_1.URLExt.encodeParts(c))),r}PageConfig.getUrl=getUrl,PageConfig.defaultWorkspace="default";function getWsUrl(i){let e=getOption("wsUrl");if(!e){if(i=i?url_1.URLExt.normalize(i):getBaseUrl(),i.indexOf("http")!==0)return"";e="ws"+i.slice(4)}return url_1.URLExt.normalize(e)}PageConfig.getWsUrl=getWsUrl;function getNBConvertURL({path:i,format:e,download:t}){let n=url_1.URLExt.encodeParts(i),s=url_1.URLExt.join(getBaseUrl(),"nbconvert",e,n);return t?s+"?download=true":s}PageConfig.getNBConvertURL=getNBConvertURL;function getToken(){return getOption("token")||getBodyData("jupyterApiToken")}PageConfig.getToken=getToken;function getNotebookVersion(){let i=getOption("notebookVersion");return i===""?[0,0,0]:JSON.parse(i)}PageConfig.getNotebookVersion=getNotebookVersion;let configData=null;function getBodyData(i){if(typeof document=="undefined"||!document.body)return"";let e=document.body.dataset[i];return typeof e=="undefined"?"":decodeURIComponent(e)}let Extension;(function(i){function e(s){try{let r=getOption(s);if(r)return JSON.parse(r)}catch(r){console.warn(`Unable to parse ${s}.`,r)}return[]}i.deferred=e("deferredExtensions"),i.disabled=e("disabledExtensions");function t(s){let r=s.indexOf(":"),a="";return r!==-1&&(a=s.slice(0,r)),i.deferred.some(o=>o===s||a&&o===a)}i.isDeferred=t;function n(s){let r=s.indexOf(":"),a="";return r!==-1&&(a=s.slice(0,r)),i.disabled.some(o=>o===s||a&&o===a)}i.isDisabled=n})(Extension=PageConfig.Extension||(PageConfig.Extension={}))})(PageConfig||(exports.PageConfig=PageConfig={}))});var or=P(tn=>{"use strict";Object.defineProperty(tn,"__esModule",{value:!0});tn.PathExt=void 0;var Be=Zt(),ar;(function(i){function e(...l){let p=Be.posix.join(...l);return p==="."?"":d(p)}i.join=e;function t(...l){let p=Be.posix.join(...l);return p==="."?"":p}i.joinWithLeadingSlash=t;function n(l,p){return Be.posix.basename(l,p)}i.basename=n;function s(l){let p=d(Be.posix.dirname(l));return p==="."?"":p}i.dirname=s;function r(l){return Be.posix.extname(l)}i.extname=r;function a(l){return l===""?"":d(Be.posix.normalize(l))}i.normalize=a;function o(...l){return d(Be.posix.resolve(...l))}i.resolve=o;function u(l,p){return d(Be.posix.relative(l,p))}i.relative=u;function c(l){return l.length>0&&l.indexOf(".")!==0&&(l=`.${l}`),l}i.normalizeExtension=c;function d(l){return l.indexOf("/")===0&&(l=l.slice(1)),l}i.removeSlash=d})(ar||(tn.PathExt=ar={}))});var lr=P(ui=>{"use strict";Object.defineProperty(ui,"__esModule",{value:!0});ui.signalToPromise=ul;var dl=te();function ul(i,e){let t=new dl.PromiseDelegate;function n(){i.disconnect(s)}function s(r,a){n(),t.resolve([r,a])}return i.connect(s),(e!=null?e:0)>0&&setTimeout(()=>{n(),t.reject(`Signal not emitted within ${e} ms.`)},e),t.promise}});var dr=P(nn=>{"use strict";Object.defineProperty(nn,"__esModule",{value:!0});nn.Text=void 0;var cr;(function(i){let e=2>1;function t(a,o){if(e)return a;let u=a;for(let c=0;c+1<o.length&&c<a;c++){let d=o.charCodeAt(c);if(d>=55296&&d<=56319){let l=o.charCodeAt(c+1);l>=56320&&l<=57343&&(u--,c++)}}return u}i.jsIndexToCharIndex=t;function n(a,o){if(e)return a;let u=a;for(let c=0;c+1<o.length&&c<u;c++){let d=o.charCodeAt(c);if(d>=55296&&d<=56319){let l=o.charCodeAt(c+1);l>=56320&&l<=57343&&(u++,c++)}}return u}i.charIndexToJsIndex=n;function s(a,o=!1){return a.replace(/^(\w)|[\s-_:]+(\w)/g,function(u,c,d){return d?d.toUpperCase():o?c.toUpperCase():c.toLowerCase()})}i.camelCase=s;function r(a){return(a||"").toLowerCase().split(" ").map(o=>o.charAt(0).toUpperCase()+o.slice(1)).join(" ")}i.titleCase=r})(cr||(nn.Text=cr={}))});var pr=P(sn=>{"use strict";Object.defineProperty(sn,"__esModule",{value:!0});sn.Time=void 0;var pl=[{name:"years",milliseconds:365*24*60*60*1e3},{name:"months",milliseconds:30*24*60*60*1e3},{name:"days",milliseconds:24*60*60*1e3},{name:"hours",milliseconds:60*60*1e3},{name:"minutes",milliseconds:60*1e3},{name:"seconds",milliseconds:1e3}],ur;(function(i){function e(n,s="long"){let r=document.documentElement.lang||"en",a=new Intl.RelativeTimeFormat(r,{numeric:"auto",style:s}),o=new Date(n).getTime()-Date.now();for(let u of pl){let c=Math.ceil(o/u.milliseconds);if(c!==0)return a.format(c,u.name)}return a.format(0,"seconds")}i.formatHuman=e;function t(n){let s=document.documentElement.lang||"en";return new Intl.DateTimeFormat(s,{dateStyle:"short",timeStyle:"short"}).format(new Date(n))}i.format=t})(ur||(sn.Time=ur={}))});var J=P(oe=>{"use strict";var hl=oe&&oe.__createBinding||(Object.create?function(i,e,t,n){n===void 0&&(n=t);var s=Object.getOwnPropertyDescriptor(e,t);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(i,n,s)}:function(i,e,t,n){n===void 0&&(n=t),i[n]=e[t]}),De=oe&&oe.__exportStar||function(i,e){for(var t in i)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&hl(e,i,t)};Object.defineProperty(oe,"__esModule",{value:!0});De(Ds(),oe);De(qs(),oe);De(Us(),oe);De(Ns(),oe);De(rr(),oe);De(or(),oe);De(lr(),oe);De(dr(),oe);De(pr(),oe);De(di(),oe)});var rt=P(B=>{"use strict";Object.defineProperty(B,"__esModule",{value:!0});B.supportedKernelWebSocketProtocols=void 0;B.createMessage=ml;B.isStreamMsg=gl;B.isDisplayDataMsg=_l;B.isUpdateDisplayDataMsg=vl;B.isExecuteInputMsg=yl;B.isExecuteResultMsg=wl;B.isErrorMsg=bl;B.isStatusMsg=Sl;B.isClearOutputMsg=xl;B.isDebugEventMsg=Cl;B.isCommOpenMsg=kl;B.isCommCloseMsg=Pl;B.isCommMsgMsg=Ml;B.isInfoRequestMsg=El;B.isExecuteReplyMsg=Il;B.isDebugRequestMsg=Ol;B.isDebugReplyMsg=Rl;B.isInputRequestMsg=jl;B.isInputReplyMsg=Dl;var fl=te();function ml(i){var e,t,n,s,r,a;return{buffers:(e=i.buffers)!==null&&e!==void 0?e:[],channel:i.channel,content:i.content,header:{date:new Date().toISOString(),msg_id:(t=i.msgId)!==null&&t!==void 0?t:fl.UUID.uuid4(),msg_type:i.msgType,session:i.session,username:(n=i.username)!==null&&n!==void 0?n:"",subshell_id:(s=i.subshellId)!==null&&s!==void 0?s:null,version:"5.2"},metadata:(r=i.metadata)!==null&&r!==void 0?r:{},parent_header:(a=i.parentHeader)!==null&&a!==void 0?a:{}}}function gl(i){return i.header.msg_type==="stream"}function _l(i){return i.header.msg_type==="display_data"}function vl(i){return i.header.msg_type==="update_display_data"}function yl(i){return i.header.msg_type==="execute_input"}function wl(i){return i.header.msg_type==="execute_result"}function bl(i){return i.header.msg_type==="error"}function Sl(i){return i.header.msg_type==="status"}function xl(i){return i.header.msg_type==="clear_output"}function Cl(i){return i.header.msg_type==="debug_event"}function kl(i){return i.header.msg_type==="comm_open"}function Pl(i){return i.header.msg_type==="comm_close"}function Ml(i){return i.header.msg_type==="comm_msg"}function El(i){return i.header.msg_type==="kernel_info_request"}function Il(i){return i.header.msg_type==="execute_reply"}function Ol(i){return i.header.msg_type==="debug_request"}function Rl(i){return i.header.msg_type==="debug_reply"}function jl(i){return i.header.msg_type==="input_request"}function Dl(i){return i.header.msg_type==="input_reply"}var hr;(function(i){i.v1KernelWebsocketJupyterOrg="v1.kernel.websocket.jupyter.org"})(hr||(B.supportedKernelWebSocketProtocols=hr={}))});var mr=P(Te=>{"use strict";var Tl=Te&&Te.__createBinding||(Object.create?function(i,e,t,n){n===void 0&&(n=t);var s=Object.getOwnPropertyDescriptor(e,t);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(i,n,s)}:function(i,e,t,n){n===void 0&&(n=t),i[n]=e[t]}),ql=Te&&Te.__setModuleDefault||(Object.create?function(i,e){Object.defineProperty(i,"default",{enumerable:!0,value:e})}:function(i,e){i.default=e}),Ul=Te&&Te.__importStar||function(i){if(i&&i.__esModule)return i;var e={};if(i!=null)for(var t in i)t!=="default"&&Object.prototype.hasOwnProperty.call(i,t)&&Tl(e,i,t);return ql(e,i),e};Object.defineProperty(Te,"__esModule",{value:!0});Te.serialize=Al;Te.deserialize=Nl;var fr=Ul(rt());function Al(i,e=""){switch(e){case fr.supportedKernelWebSocketProtocols.v1KernelWebsocketJupyterOrg:return at.serializeV1KernelWebsocketJupyterOrg(i);default:return at.serializeDefault(i)}}function Nl(i,e=""){switch(e){case fr.supportedKernelWebSocketProtocols.v1KernelWebsocketJupyterOrg:return at.deserializeV1KernelWebsocketJupyterOrg(i);default:return at.deserializeDefault(i)}}var at;(function(i){function e(o){let u,c=new DataView(o),d=Number(c.getBigUint64(0,!0)),l=[];for(let x=0;x<d;x++)l.push(Number(c.getBigUint64(8*(x+1),!0)));let p=new TextDecoder("utf8"),v=p.decode(o.slice(l[0],l[1])),_=JSON.parse(p.decode(o.slice(l[1],l[2]))),I=JSON.parse(p.decode(o.slice(l[2],l[3]))),M=JSON.parse(p.decode(o.slice(l[3],l[4]))),j=JSON.parse(p.decode(o.slice(l[4],l[5]))),q=[];for(let x=5;x<l.length-1;x++)q.push(new DataView(o.slice(l[x],l[x+1])));return u={channel:v,header:_,parent_header:I,metadata:M,content:j,buffers:q},u}i.deserializeV1KernelWebsocketJupyterOrg=e;function t(o){let u=JSON.stringify(o.header),c=o.parent_header==null?"{}":JSON.stringify(o.parent_header),d=JSON.stringify(o.metadata),l=JSON.stringify(o.content),p=o.buffers!==void 0?o.buffers:[],v=5+p.length+1,_=[];_.push(8*(1+v)),_.push(o.channel.length+_[_.length-1]);let I=new TextEncoder,M=I.encode(o.channel),j=I.encode(u),q=I.encode(c),x=I.encode(d),w=I.encode(l),O=new Uint8Array(M.length+j.length+q.length+x.length+w.length);O.set(M),O.set(j,M.length),O.set(q,M.length+j.length),O.set(x,M.length+j.length+q.length),O.set(w,M.length+j.length+q.length+x.length);for(let h of[j.length,q.length,x.length,w.length])_.push(h+_[_.length-1]);let A=0;for(let h of p){let y=h.byteLength;_.push(y+_[_.length-1]),A+=y}let T=new Uint8Array(8*(1+v)+O.byteLength+A),D=new ArrayBuffer(8),U=new DataView(D);U.setBigUint64(0,BigInt(v),!0),T.set(new Uint8Array(D),0);for(let h=0;h<_.length;h++)U.setBigUint64(0,BigInt(_[h]),!0),T.set(new Uint8Array(D),8*(h+1));T.set(O,_[0]);for(let h=0;h<p.length;h++){let y=p[h];T.set(new Uint8Array(ArrayBuffer.isView(y)?y.buffer:y),_[5+h])}return T.buffer}i.serializeV1KernelWebsocketJupyterOrg=t;function n(o){let u;return typeof o=="string"?u=JSON.parse(o):u=r(o),u}i.deserializeDefault=n;function s(o){var u;let c;return!((u=o.buffers)===null||u===void 0)&&u.length?c=a(o):c=JSON.stringify(o),c}i.serializeDefault=s;function r(o){let u=new DataView(o),c=u.getUint32(0),d=[];if(c<2)throw new Error("Invalid incoming Kernel Message");for(let v=1;v<=c;v++)d.push(u.getUint32(v*4));let l=new Uint8Array(o.slice(d[0],d[1])),p=JSON.parse(new TextDecoder("utf8").decode(l));p.buffers=[];for(let v=1;v<c;v++){let _=d[v],I=d[v+1]||o.byteLength;p.buffers.push(new DataView(o.slice(_,I)))}return p}function a(o){let u=[],c=[],d=new TextEncoder,l=[];o.buffers!==void 0&&(l=o.buffers,delete o.buffers);let p=d.encode(JSON.stringify(o));c.push(p.buffer);for(let M=0;M<l.length;M++){let j=l[M];c.push(ArrayBuffer.isView(j)?j.buffer:j)}let v=c.length;u.push(4*(v+1));for(let M=0;M+1<c.length;M++)u.push(u[u.length-1]+c[M].byteLength);let _=new Uint8Array(u[u.length-1]+c[c.length-1].byteLength),I=new DataView(_.buffer);I.setUint32(0,v);for(let M=0;M<u.length;M++)I.setUint32(4*(M+1),u[M]);for(let M=0;M<c.length;M++)_.set(new Uint8Array(c[M]),u[M]);return _.buffer}})(at||(at={}))});var gr=P(pi=>{"use strict";Object.defineProperty(pi,"__esModule",{value:!0});pi.default=WebSocket});var de=P(an=>{"use strict";Object.defineProperty(an,"__esModule",{value:!0});an.ServerConnection=void 0;var $e=J(),_r=mr(),hi;typeof window=="undefined"?hi=gr():hi=WebSocket;var fi;(function(i){function e(r){return rn.makeSettings(r)}i.makeSettings=e;function t(r,a,o){return rn.handleRequest(r,a,o)}i.makeRequest=t;class n extends Error{static async create(a){try{let o=await a.json(),{message:u,traceback:c}=o;return c&&console.error(c),new n(a,u!=null?u:n._defaultMessage(a),c!=null?c:"")}catch(o){return console.debug(o),new n(a)}}constructor(a,o=n._defaultMessage(a),u=""){super(o),this.response=a,this.traceback=u}static _defaultMessage(a){return`Invalid response: ${a.status} ${a.statusText}`}}i.ResponseError=n;class s extends TypeError{constructor(a){super(a.message),this.stack=a.stack}}i.NetworkError=s})(fi||(an.ServerConnection=fi={}));var rn;(function(i){function e(s={}){var r;let a=$e.PageConfig.getBaseUrl(),o=$e.PageConfig.getWsUrl(),u=$e.URLExt.normalize(s.baseUrl)||a,c=s.wsUrl;!c&&u===a&&(c=o),!c&&u.indexOf("http")===0&&(c="ws"+u.slice(4)),c=c!=null?c:o;let d=$e.PageConfig.getOption("appendToken").toLowerCase(),l;return d===""?l=typeof window=="undefined"||typeof process!="undefined"&&((r=process==null?void 0:process.env)===null||r===void 0?void 0:r.JEST_WORKER_ID)!==void 0||$e.URLExt.getHostName(a)!==$e.URLExt.getHostName(c):l=d==="true",{init:{cache:"no-store",credentials:"same-origin"},fetch,Headers,Request,WebSocket:hi,token:$e.PageConfig.getToken(),appUrl:$e.PageConfig.getOption("appUrl"),appendToken:l,serializer:{serialize:_r.serialize,deserialize:_r.deserialize},...s,baseUrl:u,wsUrl:c}}i.makeSettings=e;function t(s,r,a){var o;if(s.indexOf(a.baseUrl)!==0)throw new Error("Can only be used for notebook server requests");((o=r.cache)!==null&&o!==void 0?o:a.init.cache)==="no-store"&&(s+=(/\?/.test(s)?"&":"?")+new Date().getTime());let c=new a.Request(s,{...a.init,...r}),d=!1;if(a.token&&(d=!0,c.headers.append("Authorization",`token ${a.token}`)),typeof document!="undefined"){let l=n("_xsrf");l!==void 0&&(d=!0,c.headers.append("X-XSRFToken",l))}return!c.headers.has("Content-Type")&&d&&c.headers.set("Content-Type","application/json"),a.fetch.call(null,c).catch(l=>{throw new fi.NetworkError(l)})}i.handleRequest=t;function n(s){let r="";try{r=document.cookie}catch{return}let a=r.match("\\b"+s+"=([^;]*)\\b");return a==null?void 0:a[1]}})(rn||(rn={}))});var Xe=P(on=>{"use strict";Object.defineProperty(on,"__esModule",{value:!0});on.BaseManager=void 0;var vr=Z(),Ll=de(),mi=class{constructor(e){var t;this._isDisposed=!1,this._disposed=new vr.Signal(this),this.serverSettings=(t=e.serverSettings)!==null&&t!==void 0?t:Ll.ServerConnection.makeSettings()}get disposed(){return this._disposed}get isDisposed(){return this._isDisposed}get isActive(){return!0}dispose(){this.isDisposed||(this._isDisposed=!0,this._disposed.emit(void 0),vr.Signal.clearData(this))}};on.BaseManager=mi});var wr=P(Ve=>{"use strict";Object.defineProperty(Ve,"__esModule",{value:!0});Ve.ConfigWithDefaults=Ve.ConfigSection=Ve.ConfigSectionManager=void 0;var zl=J(),ot=qe(),Fl="api/config",gi=class{constructor(e){var t;this.serverSettings=(t=e.serverSettings)!==null&&t!==void 0?t:ot.ServerConnection.makeSettings()}async create(e){let t=new ln({...e,serverSettings:this.serverSettings});return await t.load(),t}};Ve.ConfigSectionManager=gi;var yr;(function(i){async function e(s){if(!t){let a=new ln(s);return await a.load(),a}return await t.create(s)}i.create=e;let t;function n(s){if(t)throw new Error("ConfigSectionManager already set. If you would like to create a config section, use the `IConfigSectionManager` token in a plugin.");t=s}i._setConfigSectionManager=n})(yr||(Ve.ConfigSection=yr={}));var ln=class{constructor(e){var t;this.serverSettings=(t=e.serverSettings)!==null&&t!==void 0?t:ot.ServerConnection.makeSettings(),this._name=e.name}get data(){return this._data}async load(){let e=await ot.ServerConnection.makeRequest(this._url,{},this.serverSettings);if(e.status!==200)throw await ot.ServerConnection.ResponseError.create(e);this._data=await e.json()}async update(e){this._data={...this._data,...e};let t={method:"PATCH",body:JSON.stringify(e)},n=await ot.ServerConnection.makeRequest(this._url,t,this.serverSettings);if(n.status!==200)throw await ot.ServerConnection.ResponseError.create(n);return this._data=await n.json(),this._data}get _url(){return zl.URLExt.join(this.serverSettings.baseUrl,Fl,encodeURIComponent(this._name))}},_i=class{constructor(e){var t,n;this._className="",this._section=e.section,this._defaults=(t=e.defaults)!==null&&t!==void 0?t:{},this._className=(n=e.className)!==null&&n!==void 0?n:""}get(e){let t=this._classData();return e in t?t[e]:this._defaults[e]}set(e,t){let n={};if(n[e]=t,this._className){let s={};return s[this._className]=n,this._section.update(s)}else return this._section.update(n)}_classData(){let e=this._section.data;return this._className&&this._className in e?e[this._className]:e}};Ve.ConfigWithDefaults=_i});var br=P(cn=>{"use strict";Object.defineProperty(cn,"__esModule",{value:!0});cn.ConnectionStatus=void 0;var vi=class{constructor(){this.isConnected=!0}};cn.ConnectionStatus=vi});var un=P((dn,Sr)=>{(function(i,e){typeof dn=="object"&&typeof Sr!="undefined"?e(dn,Z()):typeof define=="function"&&define.amd?define(["exports","@lumino/signaling"],e):(i=typeof globalThis!="undefined"?globalThis:i||self,e(i.lumino_disposable={},i.lumino_signaling))})(dn,function(i,e){"use strict";class t{constructor(o){this._fn=o}get isDisposed(){return!this._fn}dispose(){if(!this._fn)return;let o=this._fn;this._fn=null,o()}}class n extends t{constructor(){super(...arguments),this._disposed=new e.Signal(this)}get disposed(){return this._disposed}dispose(){this.isDisposed||(super.dispose(),this._disposed.emit(void 0),e.Signal.clearData(this))}}class s{constructor(){this._isDisposed=!1,this._items=new Set}get isDisposed(){return this._isDisposed}dispose(){this._isDisposed||(this._isDisposed=!0,this._items.forEach(o=>{o.dispose()}),this._items.clear())}contains(o){return this._items.has(o)}add(o){this._items.add(o)}remove(o){this._items.delete(o)}clear(){this._items.clear()}}(function(a){function o(u){let c=new a;for(let d of u)c.add(d);return c}a.from=o})(s||(s={}));class r extends s{constructor(){super(...arguments),this._disposed=new e.Signal(this)}get disposed(){return this._disposed}dispose(){this.isDisposed||(super.dispose(),this._disposed.emit(void 0),e.Signal.clearData(this))}}(function(a){function o(u){let c=new a;for(let d of u)c.add(d);return c}a.from=o})(r||(r={})),i.DisposableDelegate=t,i.DisposableSet=s,i.ObservableDisposableDelegate=n,i.ObservableDisposableSet=r})});var ft=P(yi=>{"use strict";Object.defineProperty(yi,"__esModule",{value:!0});yi.validateProperty=Kl;function Kl(i,e,t,n=[]){if(!i.hasOwnProperty(e))throw Error(`Missing property '${e}'`);let s=i[e];if(t!==void 0){let r=!0;switch(t){case"array":r=Array.isArray(s);break;case"object":r=typeof s!="undefined";break;default:r=typeof s===t}if(!r)throw new Error(`Property '${e}' is not of type '${t}'`);if(n.length>0){let a=!0;switch(t){case"string":case"number":case"boolean":a=n.includes(s);break;default:a=n.findIndex(o=>o===s)>=0;break}if(!a)throw new Error(`Property '${e}' is not one of the valid values ${JSON.stringify(n)}`)}}}});var xr=P(pn=>{"use strict";Object.defineProperty(pn,"__esModule",{value:!0});pn.validateContentsModel=Bl;pn.validateCheckpointModel=$l;var Ue=ft();function Bl(i){(0,Ue.validateProperty)(i,"name","string"),(0,Ue.validateProperty)(i,"path","string"),(0,Ue.validateProperty)(i,"type","string"),(0,Ue.validateProperty)(i,"created","string"),(0,Ue.validateProperty)(i,"last_modified","string"),(0,Ue.validateProperty)(i,"mimetype","object"),(0,Ue.validateProperty)(i,"content","object"),(0,Ue.validateProperty)(i,"format","object")}function $l(i){(0,Ue.validateProperty)(i,"id","string"),(0,Ue.validateProperty)(i,"last_modified","string")}});var Si=P(ne=>{"use strict";var Vl=ne&&ne.__createBinding||(Object.create?function(i,e,t,n){n===void 0&&(n=t);var s=Object.getOwnPropertyDescriptor(e,t);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(i,n,s)}:function(i,e,t,n){n===void 0&&(n=t),i[n]=e[t]}),Wl=ne&&ne.__setModuleDefault||(Object.create?function(i,e){Object.defineProperty(i,"default",{enumerable:!0,value:e})}:function(i,e){i.default=e}),Jl=ne&&ne.__importStar||function(i){if(i&&i.__esModule)return i;var e={};if(i!=null)for(var t in i)t!=="default"&&Object.prototype.hasOwnProperty.call(i,t)&&Vl(e,i,t);return Wl(e,i),e};Object.defineProperty(ne,"__esModule",{value:!0});ne.RestContentProvider=ne.ContentProviderRegistry=ne.Drive=ne.ContentsManager=ne.Contents=void 0;var ue=J(),Hl=un(),mt=Z(),V=qe(),Ke=Jl(xr()),Gl="api/contents",Yl="files",Cr;(function(i){function e(n){Ke.validateContentsModel(n)}i.validateContentsModel=e;function t(n){Ke.validateCheckpointModel(n)}i.validateCheckpointModel=t})(Cr||(ne.Contents=Cr={}));var wi=class{constructor(e={}){var t,n;this._isDisposed=!1,this._additionalDrives=new Map,this._fileChanged=new mt.Signal(this);let s=this.serverSettings=(t=e.serverSettings)!==null&&t!==void 0?t:V.ServerConnection.makeSettings();this._defaultDrive=(n=e.defaultDrive)!==null&&n!==void 0?n:new hn({serverSettings:s}),this._defaultDrive.fileChanged.connect(this._onFileChanged,this)}get defaultDrive(){return this._defaultDrive}get fileChanged(){return this._fileChanged}get isDisposed(){return this._isDisposed}dispose(){this.isDisposed||(this._isDisposed=!0,mt.Signal.clearData(this))}addDrive(e){this._additionalDrives.set(e.name,e),e.fileChanged.connect(this._onFileChanged,this)}getSharedModelFactory(e,t){var n,s;let[r]=this._driveForPath(e),a=(n=r.contentProviderRegistry)===null||n===void 0?void 0:n.getProvider(t==null?void 0:t.contentProviderId);return a!=null&&a.sharedModelFactory?a.sharedModelFactory:(s=r.sharedModelFactory)!==null&&s!==void 0?s:null}localPath(e){let t=e.split("/"),n=t[0].split(":");return n.length===1||!this._additionalDrives.has(n[0])?ue.PathExt.removeSlash(e):ue.PathExt.join(n.slice(1).join(":"),...t.slice(1))}normalize(e){let t=e.split(":");return t.length===1?ue.PathExt.normalize(e):`${t[0]}:${ue.PathExt.normalize(t.slice(1).join(":"))}`}resolvePath(e,t){let n=this.driveName(e),s=this.localPath(e),r=ue.PathExt.resolve("/",s,t);return n?`${n}:${r}`:r}driveName(e){let n=e.split("/")[0].split(":");return n.length===1?"":this._additionalDrives.has(n[0])?n[0]:""}get(e,t){let[n,s]=this._driveForPath(e);return n.get(s,t).then(r=>{let a=[];if(r.type==="directory"&&r.content){for(let o of r.content)a.push({...o,path:this._toGlobalPath(n,o.path)});return{...r,path:this._toGlobalPath(n,s),content:a,serverPath:r.path}}else return{...r,path:this._toGlobalPath(n,s),serverPath:r.path}})}getDownloadUrl(e){let[t,n]=this._driveForPath(e);return t.getDownloadUrl(n)}newUntitled(e={}){if(e.path){let t=this.normalize(e.path),[n,s]=this._driveForPath(t);return n.newUntitled({...e,path:s}).then(r=>({...r,path:ue.PathExt.join(t,r.name),serverPath:r.path}))}else return this._defaultDrive.newUntitled(e)}delete(e){let[t,n]=this._driveForPath(e);return t.delete(n)}rename(e,t){let[n,s]=this._driveForPath(e),[r,a]=this._driveForPath(t);if(n!==r)throw Error("ContentsManager: renaming files must occur within a Drive");return n.rename(s,a).then(o=>({...o,path:this._toGlobalPath(n,a),serverPath:o.path}))}save(e,t={}){let n=this.normalize(e),[s,r]=this._driveForPath(e);return s.save(r,{...t,path:r}).then(a=>({...a,path:n,serverPath:a.path}))}copy(e,t){let[n,s]=this._driveForPath(e),[r,a]=this._driveForPath(t);if(n===r)return n.copy(s,a).then(o=>({...o,path:this._toGlobalPath(n,o.path),serverPath:o.path}));throw Error("Copying files between drives is not currently implemented")}createCheckpoint(e){let[t,n]=this._driveForPath(e);return t.createCheckpoint(n)}listCheckpoints(e){let[t,n]=this._driveForPath(e);return t.listCheckpoints(n)}restoreCheckpoint(e,t){let[n,s]=this._driveForPath(e);return n.restoreCheckpoint(s,t)}deleteCheckpoint(e,t){let[n,s]=this._driveForPath(e);return n.deleteCheckpoint(s,t)}_toGlobalPath(e,t){return e===this._defaultDrive?ue.PathExt.removeSlash(t):`${e.name}:${ue.PathExt.removeSlash(t)}`}_driveForPath(e){let t=this.driveName(e),n=this.localPath(e);return t?[this._additionalDrives.get(t),n]:[this._defaultDrive,n]}_onFileChanged(e,t){var n,s;if(e===this._defaultDrive)this._fileChanged.emit(t);else{let r=null,a=null;!((n=t.newValue)===null||n===void 0)&&n.path&&(r={...t.newValue,path:this._toGlobalPath(e,t.newValue.path)}),!((s=t.oldValue)===null||s===void 0)&&s.path&&(a={...t.oldValue,path:this._toGlobalPath(e,t.oldValue.path)}),this._fileChanged.emit({type:t.type,newValue:r,oldValue:a})}}};ne.ContentsManager=wi;var hn=class{constructor(e={}){var t,n,s;this._isDisposed=!1,this._fileChanged=new mt.Signal(this),this.name=(t=e.name)!==null&&t!==void 0?t:"Default",this._apiEndpoint=(n=e.apiEndpoint)!==null&&n!==void 0?n:Gl,this.serverSettings=(s=e.serverSettings)!==null&&s!==void 0?s:V.ServerConnection.makeSettings();let r=new mn({apiEndpoint:this._apiEndpoint,serverSettings:this.serverSettings});this.contentProviderRegistry=new fn({defaultProvider:r}),this.contentProviderRegistry.fileChanged.connect((a,o)=>{this._fileChanged.emit(o)})}get fileChanged(){return this._fileChanged}get isDisposed(){return this._isDisposed}dispose(){this.isDisposed||(this._isDisposed=!0,mt.Signal.clearData(this))}async get(e,t){return this.contentProviderRegistry.getProvider(t==null?void 0:t.contentProviderId).get(e,t)}getDownloadUrl(e){let t=this.serverSettings.baseUrl,n=ue.URLExt.join(t,Yl,ue.URLExt.encodeParts(e)),s="";try{s=document.cookie}catch{}let r=s.match("\\b_xsrf=([^;]*)\\b");if(r){let a=new URL(n);a.searchParams.append("_xsrf",r[1]),n=a.toString()}return Promise.resolve(n)}async newUntitled(e={}){var t;let n="{}";e&&(e.ext&&(e.ext=bi.normalizeExtension(e.ext)),n=JSON.stringify(e));let s=this.serverSettings,r=this._getUrl((t=e.path)!==null&&t!==void 0?t:""),a={method:"POST",body:n},o=await V.ServerConnection.makeRequest(r,a,s);if(o.status!==201)throw await V.ServerConnection.ResponseError.create(o);let u=await o.json();return Ke.validateContentsModel(u),this._fileChanged.emit({type:"new",oldValue:null,newValue:u}),u}async delete(e){let t=this._getUrl(e),n=this.serverSettings,s={method:"DELETE"},r=await V.ServerConnection.makeRequest(t,s,n);if(r.status!==204)throw await V.ServerConnection.ResponseError.create(r);this._fileChanged.emit({type:"delete",oldValue:{path:e},newValue:null})}async rename(e,t){let n=this.serverSettings,s=this._getUrl(e),r={method:"PATCH",body:JSON.stringify({path:t})},a=await V.ServerConnection.makeRequest(s,r,n);if(a.status!==200)throw await V.ServerConnection.ResponseError.create(a);let o=await a.json();return Ke.validateContentsModel(o),this._fileChanged.emit({type:"rename",oldValue:{path:e},newValue:o}),o}async save(e,t={}){let s=await this.contentProviderRegistry.getProvider(t==null?void 0:t.contentProviderId).save(e,t);return this._fileChanged.emit({type:"save",oldValue:null,newValue:s}),s}async copy(e,t){let n=this.serverSettings,s=this._getUrl(t),r={method:"POST",body:JSON.stringify({copy_from:e})},a=await V.ServerConnection.makeRequest(s,r,n);if(a.status!==201)throw await V.ServerConnection.ResponseError.create(a);let o=await a.json();return Ke.validateContentsModel(o),this._fileChanged.emit({type:"new",oldValue:null,newValue:o}),o}async createCheckpoint(e){let t=this._getUrl(e,"checkpoints"),n={method:"POST"},s=await V.ServerConnection.makeRequest(t,n,this.serverSettings);if(s.status!==201)throw await V.ServerConnection.ResponseError.create(s);let r=await s.json();return Ke.validateCheckpointModel(r),r}async listCheckpoints(e){let t=this._getUrl(e,"checkpoints"),n=await V.ServerConnection.makeRequest(t,{},this.serverSettings);if(n.status!==200)throw await V.ServerConnection.ResponseError.create(n);let s=await n.json();if(!Array.isArray(s))throw new Error("Invalid Checkpoint list");for(let r=0;r<s.length;r++)Ke.validateCheckpointModel(s[r]);return s}async restoreCheckpoint(e,t){let n=this._getUrl(e,"checkpoints",t),s={method:"POST"},r=await V.ServerConnection.makeRequest(n,s,this.serverSettings);if(r.status!==204)throw await V.ServerConnection.ResponseError.create(r)}async deleteCheckpoint(e,t){let n=this._getUrl(e,"checkpoints",t),s={method:"DELETE"},r=await V.ServerConnection.makeRequest(n,s,this.serverSettings);if(r.status!==204)throw await V.ServerConnection.ResponseError.create(r)}_getUrl(...e){let t=e.map(s=>ue.URLExt.encodeParts(s)),n=this.serverSettings.baseUrl;return ue.URLExt.join(n,this._apiEndpoint,...t)}};ne.Drive=hn;var bi;(function(i){function e(t){return t.length>0&&t.indexOf(".")!==0&&(t=`.${t}`),t}i.normalizeExtension=e})(bi||(bi={}));var fn=class{constructor(e){this._providers=new Map,this._fileChanged=new mt.Signal(this),this.register("default",e.defaultProvider),this._defaultProvider=e.defaultProvider}register(e,t){if(this._providers.has(e))throw Error(`Provider with ${e} identifier was already registered on this drive`);this._providers.set(e,t);let n=(s,r)=>{this._fileChanged.emit(r)};return t.fileChanged&&t.fileChanged.connect(n),new Hl.DisposableDelegate(()=>{t.fileChanged&&t.fileChanged.disconnect(n),this._providers.has(e)&&this._providers.delete(e)})}getProvider(e){if(!e)return this._defaultProvider;let t=this._providers.get(e);if(!t)throw Error(`Provider ${e} is not registered`);return t}get fileChanged(){return this._fileChanged}};ne.ContentProviderRegistry=fn;var mn=class{constructor(e){this._options=e}async get(e,t){let n=this._getUrl(e);if(t){t.type==="notebook"&&delete t.format;let o=t.content?"1":"0",u=t.hash?"1":"0",c={...t,content:o,hash:u};n+=ue.URLExt.objectToQueryString(c)}let s=this._options.serverSettings,r=await V.ServerConnection.makeRequest(n,{},s);if(r.status!==200)throw await V.ServerConnection.ResponseError.create(r);let a=await r.json();return Ke.validateContentsModel(a),a}async save(e,t={}){let n=this._options.serverSettings,s=this._getUrl(e),a={method:"PUT",body:new File([JSON.stringify(t)],"data.json",{type:"application/json"})},o=await V.ServerConnection.makeRequest(s,a,n);if(o.status!==200&&o.status!==201)throw await V.ServerConnection.ResponseError.create(o);let u=await o.json();return Ke.validateContentsModel(u),u}_getUrl(...e){let t=e.map(s=>ue.URLExt.encodeParts(s)),n=this._options.serverSettings.baseUrl;return ue.URLExt.join(n,this._options.apiEndpoint,...t)}};ne.RestContentProvider=mn});var Ze=P((gn,kr)=>{(function(i,e){typeof gn=="object"&&typeof kr!="undefined"?e(gn,te(),Z()):typeof define=="function"&&define.amd?define(["exports","@lumino/coreutils","@lumino/signaling"],e):(i=typeof globalThis!="undefined"?globalThis:i||self,e(i.lumino_polling={},i.lumino_coreutils,i.lumino_signaling))})(gn,function(i,e,t){"use strict";class n{constructor(c){var d;this._disposed=new t.Signal(this),this._lingered=0,this._tick=new e.PromiseDelegate,this._ticked=new t.Signal(this),this._factory=c.factory,this._linger=(d=c.linger)!==null&&d!==void 0?d:s.DEFAULT_LINGER,this._standby=c.standby||s.DEFAULT_STANDBY,this._state={...s.DEFAULT_STATE,timestamp:new Date().getTime()};let l=c.frequency||{},p=Math.max(l.interval||0,l.max||0,s.DEFAULT_FREQUENCY.max);this.frequency={...s.DEFAULT_FREQUENCY,...l,max:p},this.name=c.name||s.DEFAULT_NAME,(!("auto"in c)||c.auto)&&setTimeout(()=>this.start())}get disposed(){return this._disposed}get frequency(){return this._frequency}set frequency(c){if(this.isDisposed||e.JSONExt.deepEqual(c,this.frequency||{}))return;let{backoff:d,interval:l,max:p}=c;if(l=Math.round(l),p=Math.round(p),typeof d=="number"&&d<1)throw new Error("Poll backoff growth factor must be at least 1");if((l<0||l>p)&&l!==n.NEVER)throw new Error("Poll interval must be between 0 and max");if(p>n.MAX_INTERVAL&&p!==n.NEVER)throw new Error(`Max interval must be less than ${n.MAX_INTERVAL}`);this._frequency={backoff:d,interval:l,max:p}}get isDisposed(){return this.state.phase==="disposed"}get standby(){return this._standby}set standby(c){this.isDisposed||this.standby===c||(this._standby=c)}get state(){return this._state}get tick(){return this._tick.promise}get ticked(){return this._ticked}async*[Symbol.asyncIterator](){for(;!this.isDisposed;)yield this.state,await this.tick.catch(()=>{})}dispose(){this.isDisposed||(this._state={...s.DISPOSED_STATE,timestamp:new Date().getTime()},this._tick.promise.catch(c=>{}),this._tick.reject(new Error(`Poll (${this.name}) is disposed.`)),this._disposed.emit(void 0),t.Signal.clearData(this))}refresh(){return this.schedule({cancel:({phase:c})=>c==="refreshed",interval:n.IMMEDIATE,phase:"refreshed"})}async schedule(c={}){if(this.isDisposed||c.cancel&&c.cancel(this.state))return;let d=this._tick,l=new e.PromiseDelegate,p={interval:this.frequency.interval,payload:null,phase:"standby",timestamp:new Date().getTime(),...c};if(this._state=p,this._tick=l,clearTimeout(this._timeout),this._ticked.emit(this.state),d.resolve(this),await d.promise,p.interval===n.NEVER){this._timeout=void 0;return}let v=()=>{this.isDisposed||this.tick!==l.promise||this._execute()};this._timeout=setTimeout(v,p.interval)}start(){return this.schedule({cancel:({phase:c})=>c!=="constructed"&&c!=="standby"&&c!=="stopped",interval:n.IMMEDIATE,phase:"started"})}stop(){return this.schedule({cancel:({phase:c})=>c==="stopped",interval:n.NEVER,phase:"stopped"})}get hidden(){return s.hidden}_execute(){let c=typeof this.standby=="function"?this.standby():this.standby;if(c==="never"?c=!1:c==="when-hidden"&&(this.hidden?c=++this._lingered>this._linger:(this._lingered=0,c=!1)),c){this.schedule();return}let d=this.tick;this._factory(this.state).then(l=>{this.isDisposed||this.tick!==d||this.schedule({payload:l,phase:this.state.phase==="rejected"?"reconnected":"resolved"})}).catch(l=>{this.isDisposed||this.tick!==d||this.schedule({interval:s.sleep(this.frequency,this.state),payload:l,phase:"rejected"})})}}(function(u){u.IMMEDIATE=0,u.MAX_INTERVAL=2147483647,u.NEVER=1/0})(n||(n={}));var s;(function(u){u.DEFAULT_BACKOFF=3,u.DEFAULT_FREQUENCY={backoff:!0,interval:1e3,max:30*1e3},u.DEFAULT_LINGER=1,u.DEFAULT_NAME="unknown",u.DEFAULT_STANDBY="when-hidden",u.DEFAULT_STATE={interval:n.NEVER,payload:null,phase:"constructed",timestamp:new Date(0).getTime()},u.DISPOSED_STATE={interval:n.NEVER,payload:null,phase:"disposed",timestamp:new Date(0).getTime()};function c(l,p){let{backoff:v,interval:_,max:I}=l;if(_===n.NEVER)return _;let M=v===!0?u.DEFAULT_BACKOFF:v===!1?1:v,j=d(_,p.interval*M);return Math.min(I,j)}u.sleep=c,u.hidden=typeof document=="undefined"?!1:(document.addEventListener("visibilitychange",()=>{u.hidden=document.visibilityState==="hidden"}),document.addEventListener("pagehide",()=>{u.hidden=document.visibilityState==="hidden"}),document.visibilityState==="hidden");function d(l,p){return l=Math.ceil(l),p=Math.floor(p),Math.floor(Math.random()*(p-l+1))+l}})(s||(s={}));class r{constructor(c,d=500){this.args=void 0,this.payload=null,this.limit=d,this.poll=new n({auto:!1,factory:async()=>{let{args:l}=this;return this.args=void 0,c(...l)},frequency:{backoff:!1,interval:n.NEVER,max:n.NEVER},standby:"never"}),this.payload=new e.PromiseDelegate,this.poll.ticked.connect((l,p)=>{let{payload:v}=this;if(p.phase==="resolved"){this.payload=new e.PromiseDelegate,v.resolve(p.payload);return}if(p.phase==="rejected"||p.phase==="stopped"){this.payload=new e.PromiseDelegate,v.promise.catch(_=>{}),v.reject(p.payload);return}},this)}get isDisposed(){return this.payload===null}dispose(){this.isDisposed||(this.args=void 0,this.payload=null,this.poll.dispose())}async stop(){return this.poll.stop()}}class a extends r{invoke(...c){return this.args=c,this.poll.schedule({interval:this.limit,phase:"invoked"}),this.payload.promise}}class o extends r{constructor(c,d){super(c,typeof d=="number"?d:d&&d.limit),this._trailing=!1,typeof d!="number"&&d&&d.edge==="trailing"&&(this._trailing=!0),this._interval=this._trailing?this.limit:n.IMMEDIATE}invoke(...c){let d=this.poll.state.phase!=="invoked";return(d||this._trailing)&&(this.args=c),d&&this.poll.schedule({interval:this._interval,phase:"invoked"}),this.payload.promise}}i.Debouncer=a,i.Poll=n,i.RateLimiter=r,i.Throttler=o})});var Ci=P(_n=>{"use strict";Object.defineProperty(_n,"__esModule",{value:!0});_n.EventManager=void 0;var Pr=J(),Xl=Ze(),Mr=Z(),Er=de(),Ir="api/events",xi=class{constructor(e={}){var t,n;this._socket=null,this.serverSettings=(t=e.serverSettings)!==null&&t!==void 0?t:Er.ServerConnection.makeSettings(),this._poll=new Xl.Poll({factory:()=>this._subscribe(),standby:(n=e.standby)!==null&&n!==void 0?n:"when-hidden"}),this._stream=new Mr.Stream(this),this._poll.start()}get isDisposed(){return this._poll.isDisposed}get stream(){return this._stream}dispose(){if(this.isDisposed)return;this._poll.dispose();let e=this._socket;e&&(this._socket=null,e.onopen=()=>{},e.onerror=()=>{},e.onmessage=()=>{},e.onclose=()=>{},e.close()),Mr.Signal.clearData(this),this._stream.stop()}async emit(e){let{serverSettings:t}=this,{baseUrl:n}=t,{makeRequest:s,ResponseError:r}=Er.ServerConnection,a=Pr.URLExt.join(n,Ir),o={body:JSON.stringify(e),method:"POST"},u=await s(a,o,t);if(u.status!==204)throw new r(u)}_subscribe(){return new Promise((e,t)=>{if(this.isDisposed)return;let{appendToken:n,token:s,WebSocket:r,wsUrl:a}=this.serverSettings,o=Pr.URLExt.join(a,Ir,"subscribe");n&&s!==""&&(o+=`?token=${encodeURIComponent(s)}`);let u=this._socket=new r(o),c=this._stream;u.onclose=()=>t(new Error("EventManager socket closed")),u.onmessage=d=>d.data&&c.emit(JSON.parse(d.data))})}};_n.EventManager=xi});var ki=P(Se=>{"use strict";var Zl=Se&&Se.__createBinding||(Object.create?function(i,e,t,n){n===void 0&&(n=t);var s=Object.getOwnPropertyDescriptor(e,t);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(i,n,s)}:function(i,e,t,n){n===void 0&&(n=t),i[n]=e[t]}),Ql=Se&&Se.__setModuleDefault||(Object.create?function(i,e){Object.defineProperty(i,"default",{enumerable:!0,value:e})}:function(i,e){i.default=e}),ec=Se&&Se.__importStar||function(i){if(i&&i.__esModule)return i;var e={};if(i!=null)for(var t in i)t!=="default"&&Object.prototype.hasOwnProperty.call(i,t)&&Zl(e,i,t);return Ql(e,i),e};Object.defineProperty(Se,"__esModule",{value:!0});Se.CommHandler=Se.CommsOverSubshells=void 0;var tc=te(),nc=un(),vn=ec(rt()),lt;(function(i){i.Disabled="disabled",i.PerComm="perComm",i.PerCommTarget="perCommTarget"})(lt||(Se.CommsOverSubshells=lt={}));var yn=class i extends nc.DisposableDelegate{constructor(e,t,n,s,r){super(s),this._subshellStarted=new tc.PromiseDelegate,this._subshellId=null,this._target="",this._id="",this._id=t,this._target=e,this._kernel=n,this._kernel.statusChanged.connect(()=>{this._kernel.status==="restarting"&&this._cleanSubshells()}),this.commsOverSubshells=r!=null?r:lt.PerCommTarget}get commId(){return this._id}get targetName(){return this._target}get subshellId(){return this._subshellId}get subshellStarted(){return this._subshellStarted.promise}get commsOverSubshells(){return this._commsOverSubshells}set commsOverSubshells(e){this._commsOverSubshells=e,this._commsOverSubshells===lt.Disabled?this._maybeCloseSubshell():this._maybeStartSubshell()}get onClose(){return this._onClose}set onClose(e){this._onClose=e}get onMsg(){return this._onMsg}set onMsg(e){this._onMsg=e}open(e,t,n=[]){if(this.isDisposed||this._kernel.isDisposed)throw new Error("Cannot open");let s=vn.createMessage({msgType:"comm_open",channel:"shell",username:this._kernel.username,session:this._kernel.clientId,subshellId:this._subshellId||this._kernel.subshellId,content:{comm_id:this._id,target_name:this._target,data:e!=null?e:{}},metadata:t,buffers:n});return this._kernel.sendShellMessage(s,!1,!0)}send(e,t,n=[],s=!0){if(this.isDisposed||this._kernel.isDisposed)throw new Error("Cannot send");let r=vn.createMessage({msgType:"comm_msg",channel:"shell",username:this._kernel.username,session:this._kernel.clientId,subshellId:this._subshellId||this._kernel.subshellId,content:{comm_id:this._id,data:e},metadata:t,buffers:n});return this._kernel.sendShellMessage(r,!1,s)}close(e,t,n=[]){if(this.isDisposed||this._kernel.isDisposed)throw new Error("Cannot close");let s=vn.createMessage({msgType:"comm_close",channel:"shell",username:this._kernel.username,session:this._kernel.clientId,subshellId:this._subshellId||this._kernel.subshellId,content:{comm_id:this._id,data:e!=null?e:{}},metadata:t,buffers:n}),r=this._kernel.sendShellMessage(s,!1,!0),a=this._onClose;if(a){let o=vn.createMessage({msgType:"comm_close",channel:"iopub",username:this._kernel.username,session:this._kernel.clientId,subshellId:this._subshellId||this._kernel.subshellId,content:{comm_id:this._id,data:e!=null?e:{}},metadata:t,buffers:n});a(o)}return this.dispose(),r}dispose(){this._maybeCloseSubshell(),super.dispose()}_cleanSubshells(){let e=this._kernel.id;i._commTargetSubShellsId.hasOwnProperty(e)&&delete i._commTargetSubShellsId[e]}async _maybeStartSubshell(){if(await this._kernel.info,!this._kernel.supportsSubshells)return;if(this._commsOverSubshells===lt.PerComm){let n=await this._kernel.requestCreateSubshell({}).done;this._subshellId=n.content.subshell_id,this._subshellStarted.resolve();return}let e=this._kernel.id;i._commTargetSubShellsId.hasOwnProperty(e)||(i._commTargetSubShellsId[e]={});let t=i._commTargetSubShellsId[e];t[this._target]?(this._subshellId=await t[this._target],this._subshellStarted.resolve()):(t[this._target]=this._kernel.requestCreateSubshell({}).done.then(n=>(this._subshellId=n.content.subshell_id,this._subshellId)),await t[this._target],this._subshellStarted.resolve())}_maybeCloseSubshell(){if(this._commsOverSubshells!==lt.PerComm){this._subshellId=null;return}this._subshellId&&this._kernel.status!=="dead"&&this._kernel.requestDeleteSubshell({subshell_id:this._subshellId},!0),this._subshellId=null}};Se.CommHandler=yn;yn._commTargetSubShellsId={}});var Rr=P(Or=>{"use strict";Object.defineProperty(Or,"__esModule",{value:!0})});var wn=P(gt=>{"use strict";Object.defineProperty(gt,"__esModule",{value:!0});gt.validateMessage=rc;gt.validateModel=Dr;gt.validateModels=oc;var Qe=ft(),jr=["username","version","session","msg_id","msg_type"],ic={stream:{name:"string",text:"string"},display_data:{data:"object",metadata:"object"},execute_input:{code:"string",execution_count:"number"},execute_result:{execution_count:"number",data:"object",metadata:"object"},error:{ename:"string",evalue:"string",traceback:"object"},status:{execution_state:["string",["starting","idle","busy","restarting","dead"]]},clear_output:{wait:"boolean"},comm_open:{comm_id:"string",target_name:"string",data:"object"},comm_msg:{comm_id:"string",data:"object"},comm_close:{comm_id:"string"},shutdown_reply:{restart:"boolean"}};function sc(i){for(let e=0;e<jr.length;e++)(0,Qe.validateProperty)(i,jr[e],"string")}function rc(i){(0,Qe.validateProperty)(i,"metadata","object"),(0,Qe.validateProperty)(i,"content","object"),(0,Qe.validateProperty)(i,"channel","string"),sc(i.header),i.channel==="iopub"&&ac(i)}function ac(i){if(i.channel==="iopub"){let e=ic[i.header.msg_type];if(e===void 0)return;let t=Object.keys(e),n=i.content;for(let s=0;s<t.length;s++){let r=e[t[s]];Array.isArray(r)||(r=[r]),(0,Qe.validateProperty)(n,t[s],...r)}}}function Dr(i){(0,Qe.validateProperty)(i,"name","string"),(0,Qe.validateProperty)(i,"id","string")}function oc(i){if(!Array.isArray(i))throw new Error("Invalid kernel list");i.forEach(e=>Dr(e))}});var Sn=P(ie=>{"use strict";Object.defineProperty(ie,"__esModule",{value:!0});ie.KernelAPIClient=ie.KERNEL_SERVICE_URL=void 0;ie.listRunning=Tr;ie.startNew=qr;ie.restartKernel=Ur;ie.interruptKernel=Ar;ie.shutdownKernel=Nr;ie.getKernelModel=Lr;var Q=de(),ct=J(),bn=wn();ie.KERNEL_SERVICE_URL="api/kernels";async function Tr(i=Q.ServerConnection.makeSettings()){let e=ct.URLExt.join(i.baseUrl,ie.KERNEL_SERVICE_URL),t=await Q.ServerConnection.makeRequest(e,{},i);if(t.status!==200)throw await Q.ServerConnection.ResponseError.create(t);let n=await t.json();return(0,bn.validateModels)(n),n}async function qr(i={},e=Q.ServerConnection.makeSettings()){let t=ct.URLExt.join(e.baseUrl,ie.KERNEL_SERVICE_URL),n={method:"POST",body:JSON.stringify(i)},s=await Q.ServerConnection.makeRequest(t,n,e);if(s.status!==201)throw await Q.ServerConnection.ResponseError.create(s);let r=await s.json();return(0,bn.validateModel)(r),r}async function Ur(i,e=Q.ServerConnection.makeSettings()){let t=ct.URLExt.join(e.baseUrl,ie.KERNEL_SERVICE_URL,encodeURIComponent(i),"restart"),n={method:"POST"},s=await Q.ServerConnection.makeRequest(t,n,e);if(s.status!==200)throw await Q.ServerConnection.ResponseError.create(s);let r=await s.json();(0,bn.validateModel)(r)}async function Ar(i,e=Q.ServerConnection.makeSettings()){let t=ct.URLExt.join(e.baseUrl,ie.KERNEL_SERVICE_URL,encodeURIComponent(i),"interrupt"),n={method:"POST"},s=await Q.ServerConnection.makeRequest(t,n,e);if(s.status!==204)throw await Q.ServerConnection.ResponseError.create(s)}async function Nr(i,e=Q.ServerConnection.makeSettings()){let t=ct.URLExt.join(e.baseUrl,ie.KERNEL_SERVICE_URL,encodeURIComponent(i)),n={method:"DELETE"},s=await Q.ServerConnection.makeRequest(t,n,e);if(s.status===404){let r=`The kernel "${i}" does not exist on the server`;console.warn(r)}else if(s.status!==204)throw await Q.ServerConnection.ResponseError.create(s)}async function Lr(i,e=Q.ServerConnection.makeSettings()){let t=ct.URLExt.join(e.baseUrl,ie.KERNEL_SERVICE_URL,encodeURIComponent(i)),n=await Q.ServerConnection.makeRequest(t,{},e);if(n.status===404)return;if(n.status!==200)throw await Q.ServerConnection.ResponseError.create(n);let s=await n.json();return(0,bn.validateModel)(s),s}var Pi=class{constructor(e={}){var t;this.serverSettings=(t=e.serverSettings)!==null&&t!==void 0?t:Q.ServerConnection.makeSettings()}async listRunning(){return Tr(this.serverSettings)}async getModel(e){return Lr(e,this.serverSettings)}async startNew(e={}){return qr(e,this.serverSettings)}async restart(e){return Ur(e,this.serverSettings)}async interrupt(e){return Ar(e,this.serverSettings)}async shutdown(e){return Nr(e,this.serverSettings)}};ie.KernelAPIClient=Pi});var Fr=P(ve=>{"use strict";var lc=ve&&ve.__createBinding||(Object.create?function(i,e,t,n){n===void 0&&(n=t);var s=Object.getOwnPropertyDescriptor(e,t);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(i,n,s)}:function(i,e,t,n){n===void 0&&(n=t),i[n]=e[t]}),cc=ve&&ve.__setModuleDefault||(Object.create?function(i,e){Object.defineProperty(i,"default",{enumerable:!0,value:e})}:function(i,e){i.default=e}),dc=ve&&ve.__importStar||function(i){if(i&&i.__esModule)return i;var e={};if(i!=null)for(var t in i)t!=="default"&&Object.prototype.hasOwnProperty.call(i,t)&&lc(e,i,t);return cc(e,i),e};Object.defineProperty(ve,"__esModule",{value:!0});ve.KernelShellFutureHandler=ve.KernelControlFutureHandler=ve.KernelFutureHandler=void 0;var zr=te(),uc=un(),pc=dc(rt()),_t=class extends uc.DisposableDelegate{constructor(e,t,n,s,r){super(e),this._status=0,this._stdin=se.noOp,this._iopub=se.noOp,this._reply=se.noOp,this._done=new zr.PromiseDelegate,this._hooks=new se.HookList,this._disposeOnDone=!0,this._msg=t,n||this._setFlag(se.KernelFutureFlag.GotReply),this._disposeOnDone=s,this._kernel=r}get msg(){return this._msg}get done(){return this._done.promise}get onReply(){return this._reply}set onReply(e){this._reply=e}get onIOPub(){return this._iopub}set onIOPub(e){this._iopub=e}get onStdin(){return this._stdin}set onStdin(e){this._stdin=e}registerMessageHook(e){if(this.isDisposed)throw new Error("Kernel future is disposed");this._hooks.add(e)}removeMessageHook(e){this.isDisposed||this._hooks.remove(e)}sendInputReply(e,t){this._kernel.sendInputReply(e,t)}dispose(){this._stdin=se.noOp,this._iopub=se.noOp,this._reply=se.noOp,this._hooks=null,this._testFlag(se.KernelFutureFlag.IsDone)||(this._done.promise.catch(()=>{}),this._done.reject(new Error(`Canceled future for ${this.msg.header.msg_type} message before replies were done`))),super.dispose()}async handleMsg(e){switch(e.channel){case"control":case"shell":e.channel===this.msg.channel&&e.parent_header.msg_id===this.msg.header.msg_id&&await this._handleReply(e);break;case"stdin":await this._handleStdin(e);break;case"iopub":await this._handleIOPub(e);break;default:break}}async _handleReply(e){let t=this._reply;t&&await t(e),this._replyMsg=e,this._setFlag(se.KernelFutureFlag.GotReply),this._testFlag(se.KernelFutureFlag.GotIdle)&&this._handleDone()}async _handleStdin(e){this._kernel.hasPendingInput=!0;let t=this._stdin;t&&await t(e)}async _handleIOPub(e){let t=await this._hooks.process(e),n=this._iopub;t&&n&&await n(e),pc.isStatusMsg(e)&&e.content.execution_state==="idle"&&(this._setFlag(se.KernelFutureFlag.GotIdle),this._testFlag(se.KernelFutureFlag.GotReply)&&this._handleDone())}_handleDone(){this._testFlag(se.KernelFutureFlag.IsDone)||(this._setFlag(se.KernelFutureFlag.IsDone),this._done.resolve(this._replyMsg),this._disposeOnDone&&this.dispose())}_testFlag(e){return(this._status&e)!==0}_setFlag(e){this._status|=e}};ve.KernelFutureHandler=_t;var Mi=class extends _t{};ve.KernelControlFutureHandler=Mi;var Ei=class extends _t{};ve.KernelShellFutureHandler=Ei;var se;(function(i){i.noOp=()=>{};let e=typeof requestAnimationFrame=="function"?requestAnimationFrame:setImmediate;class t{constructor(){this._hooks=[]}add(r){this.remove(r),this._hooks.push(r)}remove(r){let a=this._hooks.indexOf(r);a>=0&&(this._hooks[a]=null,this._scheduleCompact())}async process(r){await this._processing;let a=new zr.PromiseDelegate;this._processing=a.promise;let o;for(let u=this._hooks.length-1;u>=0;u--){let c=this._hooks[u];if(c!==null){try{o=await c(r)}catch(d){o=!0,console.error(d)}if(o===!1)return a.resolve(void 0),!1}}return a.resolve(void 0),!0}_scheduleCompact(){this._compactScheduled||(this._compactScheduled=!0,e(()=>{this._processing=this._processing.then(()=>{this._compactScheduled=!1,this._compact()})}))}_compact(){let r=0;for(let a=0,o=this._hooks.length;a<o;a++){let u=this._hooks[a];this._hooks[a]===null?r++:this._hooks[a-r]=u}this._hooks.length-=r}}i.HookList=t;let n;(function(s){s[s.GotReply=1]="GotReply",s[s.GotIdle=2]="GotIdle",s[s.IsDone=4]="IsDone",s[s.DisposeOnDone=8]="DisposeOnDone"})(n=i.KernelFutureFlag||(i.KernelFutureFlag={}))})(se||(se={}))});var Br=P(xn=>{"use strict";Object.defineProperty(xn,"__esModule",{value:!0});xn.validateSpecModel=Kr;xn.validateSpecModels=hc;var et=ft();function Kr(i){let e=i.spec;if(!e)throw new Error("Invalid kernel spec");(0,et.validateProperty)(i,"name","string"),(0,et.validateProperty)(i,"resources","object"),(0,et.validateProperty)(e,"language","string"),(0,et.validateProperty)(e,"display_name","string"),(0,et.validateProperty)(e,"argv","array");let t=null;e.hasOwnProperty("metadata")&&((0,et.validateProperty)(e,"metadata","object"),t=e.metadata);let n=null;return e.hasOwnProperty("env")&&((0,et.validateProperty)(e,"env","object"),n=e.env),{name:i.name,resources:i.resources,language:e.language,display_name:e.display_name,argv:e.argv,metadata:t,env:n}}function hc(i){if(!i.hasOwnProperty("kernelspecs"))throw new Error("No kernelspecs found");let e=Object.keys(i.kernelspecs),t=Object.create(null),n=i.default;for(let s=0;s<e.length;s++){let r=i.kernelspecs[e[s]];try{t[e[s]]=Kr(r)}catch{console.warn(`Removing errant kernel spec: ${e[s]}`)}}if(e=Object.keys(t),!e.length)throw new Error("No valid kernelspecs found");return(!n||typeof n!="string"||!(n in t))&&(n=e[0],console.warn(`Default kernel not found, using '${e[0]}'`)),{default:n,kernelspecs:t}}});var yt=P(vt=>{"use strict";Object.defineProperty(vt,"__esModule",{value:!0});vt.KernelSpecAPIClient=void 0;vt.getSpecs=$r;var Cn=de(),fc=Br(),mc=J(),gc="api/kernelspecs";async function $r(i=Cn.ServerConnection.makeSettings()){let e=mc.URLExt.join(i.baseUrl,gc),t=await Cn.ServerConnection.makeRequest(e,{},i);if(t.status!==200)throw await Cn.ServerConnection.ResponseError.create(t);let n=await t.json();return(0,fc.validateSpecModels)(n)}var Ii=class{constructor(e={}){var t;this.serverSettings=(t=e.serverSettings)!==null&&t!==void 0?t:Cn.ServerConnection.makeSettings()}async get(){return $r(this.serverSettings)}};vt.KernelSpecAPIClient=Ii});var Ri=P(Ae=>{"use strict";var _c=Ae&&Ae.__createBinding||(Object.create?function(i,e,t,n){n===void 0&&(n=t);var s=Object.getOwnPropertyDescriptor(e,t);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(i,n,s)}:function(i,e,t,n){n===void 0&&(n=t),i[n]=e[t]}),vc=Ae&&Ae.__setModuleDefault||(Object.create?function(i,e){Object.defineProperty(i,"default",{enumerable:!0,value:e})}:function(i,e){i.default=e}),Gr=Ae&&Ae.__importStar||function(i){if(i&&i.__esModule)return i;var e={};if(i!=null)for(var t in i)t!=="default"&&Object.prototype.hasOwnProperty.call(i,t)&&_c(e,i,t);return vc(e,i),e};Object.defineProperty(Ae,"__esModule",{value:!0});Ae.KernelConnection=void 0;var Vr=J(),We=te(),Je=Z(),wt=qe(),Wr=ki(),re=Gr(rt()),Jr=Fr(),yc=Gr(wn()),Hr=Sn(),wc=yt(),bc=3e3,dt="_RESTARTING_",Sc="",Oi=class i{constructor(e){var t,n,s,r,a,o,u,c;this._createSocket=(d=!0)=>{this._errorIfDisposed(),this._clearSocket(),this._updateConnectionStatus("connecting");let l=this.serverSettings,p=Vr.URLExt.join(l.wsUrl,Hr.KERNEL_SERVICE_URL,encodeURIComponent(this._id)),v=p.replace(/^((?:\w+:)?\/\/)(?:[^@\/]+@)/,"$1");console.debug(`Starting WebSocket: ${v}`);let _=Vr.URLExt.join(p,"channels?session_id="+encodeURIComponent(this._clientId)),I=l.token;l.appendToken&&I!==""&&(_=_+`&token=${encodeURIComponent(I)}`);let M=d?this._supportedProtocols:[];this._ws=new l.WebSocket(_,M),this._ws.binaryType="arraybuffer";let j=!1,q=async w=>{var O,A;if(!this._isDisposed){this._reason="",this._model=void 0;try{let T=await this._kernelAPIClient.getModel(this._id);this._model=T,(T==null?void 0:T.execution_state)==="dead"?this._updateStatus("dead"):this._onWSClose(w)}catch(T){if(T instanceof wt.ServerConnection.NetworkError||((O=T.response)===null||O===void 0?void 0:O.status)===503||((A=T.response)===null||A===void 0?void 0:A.status)===424){let D=xe.getRandomIntInclusive(10,30)*1e3;setTimeout(q,D,w)}else this._reason="Kernel died unexpectedly",this._updateStatus("dead")}}},x=async w=>{j||(j=!0,await q(w))};this._ws.onmessage=this._onWSMessage,this._ws.onopen=this._onWSOpen,this._ws.onclose=x,this._ws.onerror=x},this._onWSOpen=d=>{if(this._ws.protocol!==""&&!this._supportedProtocols.includes(this._ws.protocol))throw console.log("Server selected unknown kernel wire protocol:",this._ws.protocol),this._updateStatus("dead"),new Error(`Unknown kernel wire protocol: ${this._ws.protocol}`);this._selectedProtocol=this._ws.protocol,this._ws.onclose=this._onWSClose,this._ws.onerror=this._onWSClose,this._updateConnectionStatus("connected")},this._onWSMessage=d=>{let l;try{l=this.serverSettings.serializer.deserialize(d.data,this._ws.protocol),yc.validateMessage(l)}catch(p){throw p.message=`Kernel message validation error: ${p.message}`,p}this._kernelSession=l.header.session,this._msgChain=this._msgChain.then(()=>this._handleMessage(l)).catch(p=>{p.message.startsWith("Canceled future for ")&&console.error(p)}),this._anyMessage.emit({msg:l,direction:"recv"})},this._onWSClose=d=>{this.isDisposed||this._reconnect()},this._id="",this._name="",this._status="unknown",this._connectionStatus="connecting",this._kernelSession="",this._isDisposed=!1,this._ws=null,this._username="",this._reconnectLimit=7,this._reconnectAttempt=0,this._reconnectTimeout=null,this._supportedProtocols=Object.values(re.supportedKernelWebSocketProtocols),this._selectedProtocol="",this._commsOverSubshells=wt.CommsOverSubshells.PerCommTarget,this._futures=new Map,this._comms=new Map,this._targetRegistry=Object.create(null),this._info=new We.PromiseDelegate,this._pendingMessages=[],this._statusChanged=new Je.Signal(this),this._connectionStatusChanged=new Je.Signal(this),this._disposed=new Je.Signal(this),this._iopubMessage=new Je.Signal(this),this._anyMessage=new Je.Signal(this),this._pendingInput=new Je.Signal(this),this._unhandledMessage=new Je.Signal(this),this._displayIdToParentIds=new Map,this._msgIdToDisplayIds=new Map,this._msgChain=Promise.resolve(),this._hasPendingInput=!1,this._reason="",this._noOp=()=>{},this._supportsSubshells=!1,this._name=e.model.name,this._id=e.model.id,this.serverSettings=(t=e.serverSettings)!==null&&t!==void 0?t:wt.ServerConnection.makeSettings(),this._kernelAPIClient=(n=e.kernelAPIClient)!==null&&n!==void 0?n:new Hr.KernelAPIClient({serverSettings:this.serverSettings}),this._kernelSpecAPIClient=(s=e.kernelSpecAPIClient)!==null&&s!==void 0?s:new wc.KernelSpecAPIClient({serverSettings:this.serverSettings}),this._clientId=(r=e.clientId)!==null&&r!==void 0?r:We.UUID.uuid4(),this._username=(a=e.username)!==null&&a!==void 0?a:"",this.handleComms=(o=e.handleComms)!==null&&o!==void 0?o:!0,this._commsOverSubshells=(u=e.commsOverSubshells)!==null&&u!==void 0?u:wt.CommsOverSubshells.PerCommTarget,this._subshellId=(c=e.subshellId)!==null&&c!==void 0?c:null,this._createSocket()}get disposed(){return this._disposed}get commsOverSubshells(){return this._commsOverSubshells}set commsOverSubshells(e){this._commsOverSubshells=e;for(let[t,n]of this._comms)n.commsOverSubshells=e}get statusChanged(){return this._statusChanged}get connectionStatusChanged(){return this._connectionStatusChanged}get iopubMessage(){return this._iopubMessage}get unhandledMessage(){return this._unhandledMessage}get model(){return this._model||{id:this.id,name:this.name,reason:this._reason}}get anyMessage(){return this._anyMessage}get pendingInput(){return this._pendingInput}get id(){return this._id}get name(){return this._name}get username(){return this._username}get clientId(){return this._clientId}get subshellId(){return this._subshellId}set subshellId(e){this._subshellId=e}get status(){return this._status}get connectionStatus(){return this._connectionStatus}get isDisposed(){return this._isDisposed}get info(){return this._info.promise}get spec(){return this._specPromise?this._specPromise:(this._specPromise=this._kernelSpecAPIClient.get().then(e=>e.kernelspecs[this._name]),this._specPromise)}get supportsSubshells(){return this._supportsSubshells}clone(e={}){return new i({model:this.model,username:this.username,serverSettings:this.serverSettings,handleComms:!1,kernelAPIClient:this._kernelAPIClient,commsOverSubshells:wt.CommsOverSubshells.Disabled,...e})}dispose(){if(this.isDisposed)return;let e=()=>{this._isDisposed=!0,this._disposed.emit(),this._updateConnectionStatus("disconnected"),this._clearKernelState(),this._pendingMessages=[],this._clearSocket(),Je.Signal.clearData(this)};if(this._subshellId!==null){let t=this.requestDeleteSubshell({subshell_id:this._subshellId},!0);t.onReply=n=>{e()}}else e()}sendShellMessage(e,t=!1,n=!0){return this._sendKernelShellControl(Jr.KernelShellFutureHandler,e,t,n)}sendControlMessage(e,t=!1,n=!0){return this._sendKernelShellControl(Jr.KernelControlFutureHandler,e,t,n)}_sendKernelShellControl(e,t,n=!1,s=!0){this._sendMessage(t),this._anyMessage.emit({msg:t,direction:"send"});let r=new e(()=>{let a=t.header.msg_id;this._futures.delete(a);let o=this._msgIdToDisplayIds.get(a);o&&(o.forEach(u=>{let c=this._displayIdToParentIds.get(u);if(c){let d=c.indexOf(a);if(d===-1)return;c.length===1?this._displayIdToParentIds.delete(u):(c.splice(d,1),this._displayIdToParentIds.set(u,c))}}),this._msgIdToDisplayIds.delete(a))},t,n,s,this);return this._futures.set(t.header.msg_id,r),r}_sendMessage(e,t=!0){if(this.status==="dead")throw new Error("Kernel is dead");if((this._kernelSession===Sc||this._kernelSession===dt)&&re.isInfoRequestMsg(e))if(this.connectionStatus==="connected"){this._ws.send(this.serverSettings.serializer.serialize(e,this._ws.protocol));return}else throw new Error("Could not send message: status is not connected");if(t&&this._pendingMessages.length>0){this._pendingMessages.push(e);return}if(this.connectionStatus==="connected"&&this._kernelSession!==dt)this._ws.send(this.serverSettings.serializer.serialize(e,this._ws.protocol));else if(t)this._pendingMessages.push(e);else throw new Error("Could not send message")}async interrupt(){if(this.hasPendingInput=!1,this.status==="dead")throw new Error("Kernel is dead");return this._kernelAPIClient.interrupt(this.id)}async restart(){if(this.status==="dead")throw new Error("Kernel is dead");this._updateStatus("restarting"),this._clearKernelState(),this._kernelSession=dt,await this._kernelAPIClient.restart(this.id),await this.reconnect(),this.hasPendingInput=!1}reconnect(){this._errorIfDisposed();let e=new We.PromiseDelegate,t=(n,s)=>{s==="connected"?(e.resolve(),this.connectionStatusChanged.disconnect(t,this)):s==="disconnected"&&(e.reject(new Error("Kernel connection disconnected")),this.connectionStatusChanged.disconnect(t,this))};return this.connectionStatusChanged.connect(t,this),this._reconnectAttempt=0,this._reconnect(),e.promise}async shutdown(){this.status!=="dead"&&await this._kernelAPIClient.shutdown(this.id),this.handleShutdown()}handleShutdown(){this._updateStatus("dead"),this.dispose()}async requestKernelInfo(){let e=re.createMessage({msgType:"kernel_info_request",channel:"shell",username:this._username,session:this._clientId,subshellId:this._subshellId,content:{}}),t;try{t=await xe.handleShellMessage(this,e)}catch(s){if(this.isDisposed)return;throw s}if(this._errorIfDisposed(),!t)return;if(t.content.status===void 0&&(t.content.status="ok"),t.content.status!=="ok")return this._info.reject("Kernel info reply errored"),t;this._info.resolve(t.content),this._kernelSession=t.header.session;let n=t.content.supported_features;return this._supportsSubshells=n!==void 0&&n.includes("kernel subshells"),t}requestComplete(e){let t=re.createMessage({msgType:"complete_request",channel:"shell",username:this._username,session:this._clientId,subshellId:this._subshellId,content:e});return xe.handleShellMessage(this,t)}requestInspect(e){let t=re.createMessage({msgType:"inspect_request",channel:"shell",username:this._username,session:this._clientId,subshellId:this._subshellId,content:e});return xe.handleShellMessage(this,t)}requestHistory(e){let t=re.createMessage({msgType:"history_request",channel:"shell",username:this._username,session:this._clientId,subshellId:this._subshellId,content:e});return xe.handleShellMessage(this,t)}requestExecute(e,t=!0,n){let s={silent:!1,store_history:!0,user_expressions:{},allow_stdin:!0,stop_on_error:!1},r=re.createMessage({msgType:"execute_request",channel:"shell",username:this._username,session:this._clientId,subshellId:this._subshellId,content:{...s,...e},metadata:n});return this.sendShellMessage(r,!0,t)}requestDebug(e,t=!0){let n=re.createMessage({msgType:"debug_request",channel:"control",username:this._username,session:this._clientId,content:e});return this.sendControlMessage(n,!0,t)}requestCreateSubshell(e,t=!0){if(!this.supportsSubshells)throw new Error("Kernel subshells are not supported");let n=re.createMessage({msgType:"create_subshell_request",channel:"control",username:this._username,session:this._clientId,content:e});return this.sendControlMessage(n,!0,t)}requestDeleteSubshell(e,t=!0){if(!this.supportsSubshells)throw new Error("Kernel subshells are not supported");let n=re.createMessage({msgType:"delete_subshell_request",channel:"control",username:this._username,session:this._clientId,content:e});return this.sendControlMessage(n,!0,t)}requestListSubshell(e,t=!0){if(!this.supportsSubshells)throw new Error("Kernel subshells are not supported");let n=re.createMessage({msgType:"list_subshell_request",channel:"control",username:this._username,session:this._clientId,content:e});return this.sendControlMessage(n,!0,t)}requestIsComplete(e){let t=re.createMessage({msgType:"is_complete_request",channel:"shell",username:this._username,session:this._clientId,subshellId:this._subshellId,content:e});return xe.handleShellMessage(this,t)}requestCommInfo(e){let t=re.createMessage({msgType:"comm_info_request",channel:"shell",username:this._username,session:this._clientId,subshellId:this._subshellId,content:e});return xe.handleShellMessage(this,t)}sendInputReply(e,t){let n=re.createMessage({msgType:"input_reply",channel:"stdin",username:this._username,session:this._clientId,content:e});n.parent_header=t,this._sendMessage(n),this._anyMessage.emit({msg:n,direction:"send"}),this.hasPendingInput=!1}createComm(e,t=We.UUID.uuid4()){if(!this.handleComms)throw new Error("Comms are disabled on this kernel connection");if(this._comms.has(t))throw new Error("Comm is already created");let n=new Wr.CommHandler(e,t,this,()=>{this._unregisterComm(t)},this._commsOverSubshells);return this._comms.set(t,n),n}hasComm(e){return this._comms.has(e)}registerCommTarget(e,t){this.handleComms&&(this._targetRegistry[e]=t)}removeCommTarget(e,t){this.handleComms&&!this.isDisposed&&this._targetRegistry[e]===t&&delete this._targetRegistry[e]}registerMessageHook(e,t){var n;let s=(n=this._futures)===null||n===void 0?void 0:n.get(e);s&&s.registerMessageHook(t)}removeMessageHook(e,t){var n;let s=(n=this._futures)===null||n===void 0?void 0:n.get(e);s&&s.removeMessageHook(t)}removeInputGuard(){this.hasPendingInput=!1}async _handleDisplayId(e,t){var n,s;let r=t.parent_header.msg_id,a=this._displayIdToParentIds.get(e);if(a){let u={header:We.JSONExt.deepCopy(t.header),parent_header:We.JSONExt.deepCopy(t.parent_header),metadata:We.JSONExt.deepCopy(t.metadata),content:We.JSONExt.deepCopy(t.content),channel:t.channel,buffers:t.buffers?t.buffers.slice():[]};u.header.msg_type="update_display_data",await Promise.all(a.map(async c=>{let d=this._futures&&this._futures.get(c);d&&await d.handleMsg(u)}))}if(t.header.msg_type==="update_display_data")return!0;a=(n=this._displayIdToParentIds.get(e))!==null&&n!==void 0?n:[],a.indexOf(r)===-1&&a.push(r),this._displayIdToParentIds.set(e,a);let o=(s=this._msgIdToDisplayIds.get(r))!==null&&s!==void 0?s:[];return o.indexOf(r)===-1&&o.push(r),this._msgIdToDisplayIds.set(r,o),!1}_clearSocket(){this._ws!==null&&(this._ws.onopen=this._noOp,this._ws.onclose=this._noOp,this._ws.onerror=this._noOp,this._ws.onmessage=this._noOp,this._ws.close(),this._ws=null)}_updateStatus(e){this._status===e||this._status==="dead"||(this._status=e,xe.logKernelStatus(this),this._statusChanged.emit(e),e==="dead"&&this.dispose())}_sendPending(){for(;this.connectionStatus==="connected"&&this._kernelSession!==dt&&this._pendingMessages.length>0;)this._sendMessage(this._pendingMessages[0],!1),this._pendingMessages.shift()}_clearKernelState(){this._kernelSession="",this._pendingMessages=[],this._futures.forEach(e=>{e.dispose()}),this._comms.forEach(e=>{e.dispose()}),this._msgChain=Promise.resolve(),this._futures=new Map,this._comms=new Map,this._displayIdToParentIds.clear(),this._msgIdToDisplayIds.clear()}_assertCurrentMessage(e){if(this._errorIfDisposed(),e.header.session!==this._kernelSession)throw new Error(`Canceling handling of old message: ${e.header.msg_type}`)}async _handleCommOpen(e){this._assertCurrentMessage(e);let t=e.content,n=new Wr.CommHandler(t.target_name,t.comm_id,this,()=>{this._unregisterComm(t.comm_id)},this.commsOverSubshells);this._comms.set(t.comm_id,n);try{await(await xe.loadObject(t.target_name,t.target_module,this._targetRegistry))(n,e)}catch(s){throw n.close(),console.error("Exception opening new comm"),s}}async _handleCommClose(e){this._assertCurrentMessage(e);let t=e.content,n=this._comms.get(t.comm_id);if(!n){console.error("Comm not found for comm id "+t.comm_id);return}this._unregisterComm(n.commId);let s=n.onClose;s&&await s(e),n.dispose()}async _handleCommMsg(e){this._assertCurrentMessage(e);let t=e.content,n=this._comms.get(t.comm_id);if(!n)return;let s=n.onMsg;s&&await s(e)}_unregisterComm(e){this._comms.delete(e)}_updateConnectionStatus(e){if(this._connectionStatus!==e){if(this._connectionStatus=e,e!=="connecting"&&(this._reconnectAttempt=0,clearTimeout(this._reconnectTimeout)),this.status!=="dead")if(e==="connected"){let t=this._kernelSession===dt,n=this.requestKernelInfo(),s=!1,r=()=>{s||(s=!0,t&&this._kernelSession===dt&&(this._kernelSession=""),clearTimeout(a),this._pendingMessages.length>0&&this._sendPending())};n.then(r);let a=setTimeout(r,bc)}else this._updateStatus("unknown");this._connectionStatusChanged.emit(e)}}async _handleMessage(e){var t,n;let s=!1;if(e.parent_header&&e.channel==="iopub"&&(re.isDisplayDataMsg(e)||re.isUpdateDisplayDataMsg(e)||re.isExecuteResultMsg(e))){let a=((t=e.content.transient)!==null&&t!==void 0?t:{}).display_id;a&&(s=await this._handleDisplayId(a,e),this._assertCurrentMessage(e))}if(!s&&e.parent_header){let r=e.parent_header,a=(n=this._futures)===null||n===void 0?void 0:n.get(r.msg_id);if(a)await a.handleMsg(e),this._assertCurrentMessage(e);else{let o=r.session===this.clientId;e.channel!=="iopub"&&o&&this._unhandledMessage.emit(e)}}if(e.channel==="iopub"){switch(e.header.msg_type){case"status":{let r=e.content.execution_state;r==="restarting"&&Promise.resolve().then(async()=>{this._updateStatus("autorestarting"),this._clearKernelState(),await this.reconnect()}),this._updateStatus(r);break}case"comm_open":this.handleComms&&await this._handleCommOpen(e);break;case"comm_msg":this.handleComms&&await this._handleCommMsg(e);break;case"comm_close":this.handleComms&&await this._handleCommClose(e);break;default:break}this.isDisposed||(this._assertCurrentMessage(e),this._iopubMessage.emit(e))}}_reconnect(){if(this._errorIfDisposed(),clearTimeout(this._reconnectTimeout),this._reconnectAttempt<this._reconnectLimit){this._updateConnectionStatus("connecting");let e=xe.getRandomIntInclusive(0,1e3*(Math.pow(2,this._reconnectAttempt)-1));console.warn(`Connection lost, reconnecting in ${Math.floor(e/1e3)} seconds.`);let t=this._selectedProtocol!=="";this._reconnectTimeout=setTimeout(this._createSocket,e,t),this._reconnectAttempt+=1}else this._updateConnectionStatus("disconnected");this._clearSocket()}_errorIfDisposed(){if(this.isDisposed)throw new Error("Kernel connection is disposed")}get hasPendingInput(){return this._hasPendingInput}set hasPendingInput(e){this._hasPendingInput=e,this._pendingInput.emit(e)}};Ae.KernelConnection=Oi;var xe;(function(i){function e(r){switch(r.status){case"idle":case"busy":case"unknown":return;default:console.debug(`Kernel: ${r.status} (${r.id})`);break}}i.logKernelStatus=e;async function t(r,a){return r.sendShellMessage(a,!0).done}i.handleShellMessage=t;function n(r,a,o){return new Promise((u,c)=>{if(a){if(typeof requirejs=="undefined")throw new Error("requirejs not found");requirejs([a],d=>{if(d[r]===void 0){let l=`Object '${r}' not found in module '${a}'`;c(new Error(l))}else u(d[r])},c)}else o!=null&&o[r]?u(o[r]):c(new Error(`Object '${r}' not found in registry`))})}i.loadObject=n;function s(r,a){return r=Math.ceil(r),a=Math.floor(a),Math.floor(Math.random()*(a-r+1))+r}i.getRandomIntInclusive=s})(xe||(xe={}))});var Zr=P(St=>{"use strict";Object.defineProperty(St,"__esModule",{value:!0});St.KernelManager=void 0;var xc=Ze(),Yr=Z(),Xr=qe(),Cc=Xe(),kc=Sn(),Pc=Ri(),Mc=yt(),bt=class extends Cc.BaseManager{constructor(e={}){var t,n,s;super(e),this._commsOverSubshells=Xr.CommsOverSubshells.PerCommTarget,this._isReady=!1,this._kernelConnections=new Set,this._models=new Map,this._runningChanged=new Yr.Signal(this),this._connectionFailure=new Yr.Signal(this),this._kernelAPIClient=(t=e.kernelAPIClient)!==null&&t!==void 0?t:new kc.KernelAPIClient({serverSettings:this.serverSettings}),this._kernelSpecAPIClient=(n=e.kernelSpecAPIClient)!==null&&n!==void 0?n:new Mc.KernelSpecAPIClient({serverSettings:this.serverSettings}),this._pollModels=new xc.Poll({auto:!1,factory:()=>this.requestRunning(),frequency:{interval:10*1e3,backoff:!0,max:300*1e3},name:"@jupyterlab/services:KernelManager#models",standby:(s=e.standby)!==null&&s!==void 0?s:"when-hidden"}),this._ready=(async()=>{await this._pollModels.start(),await this._pollModels.tick,this._isReady=!0})()}get isReady(){return this._isReady}get ready(){return this._ready}get runningChanged(){return this._runningChanged}get connectionFailure(){return this._connectionFailure}dispose(){this.isDisposed||(this._models.clear(),this._kernelConnections.forEach(e=>e.dispose()),this._pollModels.dispose(),super.dispose())}connectTo(e){var t;let{id:n}=e.model,s=(t=e.handleComms)!==null&&t!==void 0?t:!0;if(e.handleComms===void 0){for(let a of this._kernelConnections)if(a.id===n&&a.handleComms){s=!1;break}}e.commsOverSubshells=this._commsOverSubshells;let r=new Pc.KernelConnection({handleComms:s,...e,serverSettings:this.serverSettings,kernelAPIClient:this._kernelAPIClient,kernelSpecAPIClient:this._kernelSpecAPIClient});return this._onStarted(r),this._models.has(n)||this.refreshRunning().catch(()=>{}),r}running(){return this._models.values()}get runningCount(){return this._models.size}get commsOverSubshells(){return this._commsOverSubshells}set commsOverSubshells(e){this._commsOverSubshells=e;for(let t of this._kernelConnections)t.commsOverSubshells=e}async refreshRunning(){await this._pollModels.refresh(),await this._pollModels.tick}async startNew(e={},t={}){let n=await this._kernelAPIClient.startNew(e);return this.connectTo({...t,model:n})}async shutdown(e){await this._kernelAPIClient.shutdown(e),await this.refreshRunning()}async shutdownAll(){await this.refreshRunning(),await Promise.all([...this._models.keys()].map(e=>this._kernelAPIClient.shutdown(e))),await this.refreshRunning()}async findById(e){return this._models.has(e)?this._models.get(e):(await this.refreshRunning(),this._models.get(e))}async requestRunning(){var e,t;let n;try{n=await this._kernelAPIClient.listRunning()}catch(s){throw(s instanceof Xr.ServerConnection.NetworkError||((e=s.response)===null||e===void 0?void 0:e.status)===503||((t=s.response)===null||t===void 0?void 0:t.status)===424)&&this._connectionFailure.emit(s),s}this.isDisposed||this._models.size===n.length&&n.every(s=>{let r=this._models.get(s.id);return r?r.connections===s.connections&&r.execution_state===s.execution_state&&r.last_activity===s.last_activity&&r.name===s.name&&r.reason===s.reason&&r.traceback===s.traceback:!1})||(this._models=new Map(n.map(s=>[s.id,s])),this._kernelConnections.forEach(s=>{this._models.has(s.id)||s.handleShutdown()}),this._runningChanged.emit(n))}_onStarted(e){this._kernelConnections.add(e),e.statusChanged.connect(this._onStatusChanged,this),e.disposed.connect(this._onDisposed,this)}_onDisposed(e){this._kernelConnections.delete(e),this.refreshRunning().catch(()=>{})}_onStatusChanged(e,t){t==="dead"&&this.refreshRunning().catch(()=>{})}};St.KernelManager=bt;(function(i){class e extends i{constructor(){super(...arguments),this._readyPromise=new Promise(()=>{})}get isActive(){return!1}get parentReady(){return super.ready}async startNew(n={},s={}){return Promise.reject(new Error("Not implemented in no-op Kernel Manager"))}connectTo(n){throw new Error("Not implemented in no-op Kernel Manager")}async shutdown(n){return Promise.reject(new Error("Not implemented in no-op Kernel Manager"))}get ready(){return this.parentReady.then(()=>this._readyPromise)}async requestRunning(){return Promise.resolve()}}i.NoopManager=e})(bt||(St.KernelManager=bt={}))});var Di=P(H=>{"use strict";var Qr=H&&H.__createBinding||(Object.create?function(i,e,t,n){n===void 0&&(n=t);var s=Object.getOwnPropertyDescriptor(e,t);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(i,n,s)}:function(i,e,t,n){n===void 0&&(n=t),i[n]=e[t]}),Ec=H&&H.__setModuleDefault||(Object.create?function(i,e){Object.defineProperty(i,"default",{enumerable:!0,value:e})}:function(i,e){i.default=e}),ji=H&&H.__importStar||function(i){if(i&&i.__esModule)return i;var e={};if(i!=null)for(var t in i)t!=="default"&&Object.prototype.hasOwnProperty.call(i,t)&&Qr(e,i,t);return Ec(e,i),e},Ic=H&&H.__exportStar||function(i,e){for(var t in i)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&Qr(e,i,t)};Object.defineProperty(H,"__esModule",{value:!0});H.CommsOverSubshells=H.KernelConnection=H.KernelAPI=H.KernelMessage=H.Kernel=void 0;var Oc=ki();Object.defineProperty(H,"CommsOverSubshells",{enumerable:!0,get:function(){return Oc.CommsOverSubshells}});var Rc=ji(Rr());H.Kernel=Rc;var jc=ji(rt());H.KernelMessage=jc;var Dc=ji(Sn());H.KernelAPI=Dc;var Tc=Ri();Object.defineProperty(H,"KernelConnection",{enumerable:!0,get:function(){return Tc.KernelConnection}});Ic(Zr(),H)});var ta=P(ea=>{"use strict";Object.defineProperty(ea,"__esModule",{value:!0})});var ia=P(kn=>{"use strict";Object.defineProperty(kn,"__esModule",{value:!0});kn.KernelSpecManager=void 0;var qc=te(),Uc=Ze(),na=Z(),Ac=Xe(),Nc=yt(),Ti=class extends Ac.BaseManager{constructor(e={}){var t,n;super(e),this._isReady=!1,this._connectionFailure=new na.Signal(this),this._specs=null,this._specsChanged=new na.Signal(this),this._kernelSpecAPIClient=(t=e.kernelSpecAPIClient)!==null&&t!==void 0?t:new Nc.KernelSpecAPIClient({serverSettings:this.serverSettings}),this._ready=Promise.all([this.requestSpecs()]).then(s=>{}).catch(s=>{}).then(()=>{this.isDisposed||(this._isReady=!0)}),this._pollSpecs=new Uc.Poll({auto:!1,factory:()=>this.requestSpecs(),frequency:{interval:61*1e3,backoff:!0,max:300*1e3},name:"@jupyterlab/services:KernelSpecManager#specs",standby:(n=e.standby)!==null&&n!==void 0?n:"when-hidden"}),this.ready.then(()=>{this._pollSpecs.start()})}get isReady(){return this._isReady}get ready(){return this._ready}get specs(){return this._specs}get specsChanged(){return this._specsChanged}get connectionFailure(){return this._connectionFailure}dispose(){this._pollSpecs.dispose(),super.dispose()}async refreshSpecs(){await this._pollSpecs.refresh(),await this._pollSpecs.tick}async requestSpecs(){let e=await this._kernelSpecAPIClient.get();this.isDisposed||qc.JSONExt.deepEqual(e,this._specs)||(this._specs=e,this._specsChanged.emit(e))}};kn.KernelSpecManager=Ti});var qi=P(pe=>{"use strict";var sa=pe&&pe.__createBinding||(Object.create?function(i,e,t,n){n===void 0&&(n=t);var s=Object.getOwnPropertyDescriptor(e,t);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(i,n,s)}:function(i,e,t,n){n===void 0&&(n=t),i[n]=e[t]}),Lc=pe&&pe.__setModuleDefault||(Object.create?function(i,e){Object.defineProperty(i,"default",{enumerable:!0,value:e})}:function(i,e){i.default=e}),ra=pe&&pe.__importStar||function(i){if(i&&i.__esModule)return i;var e={};if(i!=null)for(var t in i)t!=="default"&&Object.prototype.hasOwnProperty.call(i,t)&&sa(e,i,t);return Lc(e,i),e},zc=pe&&pe.__exportStar||function(i,e){for(var t in i)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&sa(e,i,t)};Object.defineProperty(pe,"__esModule",{value:!0});pe.KernelSpecAPI=pe.KernelSpec=void 0;var Fc=ra(ta());pe.KernelSpec=Fc;var Kc=ra(yt());pe.KernelSpecAPI=Kc;zc(ia(),pe)});var aa=P(Pn=>{"use strict";Object.defineProperty(Pn,"__esModule",{value:!0});Pn.BuildManager=void 0;var Ui=J(),He=de(),Bc="api/build",Ai=class{constructor(e={}){var t;this.serverSettings=(t=e.serverSettings)!==null&&t!==void 0?t:He.ServerConnection.makeSettings()}get isAvailable(){return Ui.PageConfig.getOption("buildAvailable").toLowerCase()==="true"}get shouldCheck(){return Ui.PageConfig.getOption("buildCheck").toLowerCase()==="true"}getStatus(){let{_url:e,serverSettings:t}=this;return He.ServerConnection.makeRequest(e,{},t).then(s=>{if(s.status!==200)throw new He.ServerConnection.ResponseError(s);return s.json()}).then(s=>{if(typeof s.status!="string")throw new Error("Invalid data");if(typeof s.message!="string")throw new Error("Invalid data");return s})}build(){let{_url:e,serverSettings:t}=this,n={method:"POST"};return He.ServerConnection.makeRequest(e,n,t).then(r=>{if(r.status===400)throw new He.ServerConnection.ResponseError(r,"Build aborted");if(r.status!==200){let a=`Build failed with ${r.status}.
1
+ var Ho=Object.create;var Bn=Object.defineProperty;var Jo=Object.getOwnPropertyDescriptor;var Go=Object.getOwnPropertyNames;var Xo=Object.getPrototypeOf,Yo=Object.prototype.hasOwnProperty;var sr=(n,e)=>()=>(n&&(e=n(n=0)),e);var R=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),Qo=(n,e)=>{for(var t in e)Bn(n,t,{get:e[t],enumerable:!0})},Zo=(n,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Go(e))!Yo.call(n,r)&&r!==t&&Bn(n,r,{get:()=>e[r],enumerable:!(s=Jo(e,r))||s.enumerable});return n};var Wn=(n,e,t)=>(t=n!=null?Ho(Xo(n)):{},Zo(e||!n||!n.__esModule?Bn(t,"default",{value:n,enumerable:!0}):t,n));var Jn=R((Lt,hr)=>{(function(n,e){typeof Lt=="object"&&typeof hr!="undefined"?e(Lt):typeof define=="function"&&define.amd?define(["exports"],e):(n=typeof globalThis!="undefined"?globalThis:n||self,e(n.lumino_algorithm={}))})(Lt,function(n){"use strict";n.ArrayExt=void 0,function(f){function y(S,M,p=0,_=-1){let g=S.length;if(g===0)return-1;p<0?p=Math.max(0,p+g):p=Math.min(p,g-1),_<0?_=Math.max(0,_+g):_=Math.min(_,g-1);let E;_<p?E=_+1+(g-p):E=_-p+1;for(let O=0;O<E;++O){let z=(p+O)%g;if(S[z]===M)return z}return-1}f.firstIndexOf=y;function b(S,M,p=-1,_=0){let g=S.length;if(g===0)return-1;p<0?p=Math.max(0,p+g):p=Math.min(p,g-1),_<0?_=Math.max(0,_+g):_=Math.min(_,g-1);let E;p<_?E=p+1+(g-_):E=p-_+1;for(let O=0;O<E;++O){let z=(p-O+g)%g;if(S[z]===M)return z}return-1}f.lastIndexOf=b;function P(S,M,p=0,_=-1){let g=S.length;if(g===0)return-1;p<0?p=Math.max(0,p+g):p=Math.min(p,g-1),_<0?_=Math.max(0,_+g):_=Math.min(_,g-1);let E;_<p?E=_+1+(g-p):E=_-p+1;for(let O=0;O<E;++O){let z=(p+O)%g;if(M(S[z],z))return z}return-1}f.findFirstIndex=P;function x(S,M,p=-1,_=0){let g=S.length;if(g===0)return-1;p<0?p=Math.max(0,p+g):p=Math.min(p,g-1),_<0?_=Math.max(0,_+g):_=Math.min(_,g-1);let E;p<_?E=p+1+(g-_):E=p-_+1;for(let O=0;O<E;++O){let z=(p-O+g)%g;if(M(S[z],z))return z}return-1}f.findLastIndex=x;function J(S,M,p=0,_=-1){let g=P(S,M,p,_);return g!==-1?S[g]:void 0}f.findFirstValue=J;function F(S,M,p=-1,_=0){let g=x(S,M,p,_);return g!==-1?S[g]:void 0}f.findLastValue=F;function K(S,M,p,_=0,g=-1){let E=S.length;if(E===0)return 0;_<0?_=Math.max(0,_+E):_=Math.min(_,E-1),g<0?g=Math.max(0,g+E):g=Math.min(g,E-1);let O=_,z=g-_+1;for(;z>0;){let we=z>>1,at=O+we;p(S[at],M)<0?(O=at+1,z-=we+1):z=we}return O}f.lowerBound=K;function X(S,M,p,_=0,g=-1){let E=S.length;if(E===0)return 0;_<0?_=Math.max(0,_+E):_=Math.min(_,E-1),g<0?g=Math.max(0,g+E):g=Math.min(g,E-1);let O=_,z=g-_+1;for(;z>0;){let we=z>>1,at=O+we;p(S[at],M)>0?z=we:(O=at+1,z-=we+1)}return O}f.upperBound=X;function B(S,M,p){if(S===M)return!0;if(S.length!==M.length)return!1;for(let _=0,g=S.length;_<g;++_)if(p?!p(S[_],M[_]):S[_]!==M[_])return!1;return!0}f.shallowEqual=B;function Q(S,M={}){let{start:p,stop:_,step:g}=M;if(g===void 0&&(g=1),g===0)throw new Error("Slice `step` cannot be zero.");let E=S.length;p===void 0?p=g<0?E-1:0:p<0?p=Math.max(p+E,g<0?-1:0):p>=E&&(p=g<0?E-1:E),_===void 0?_=g<0?-1:E:_<0?_=Math.max(_+E,g<0?-1:0):_>=E&&(_=g<0?E-1:E);let O;g<0&&_>=p||g>0&&p>=_?O=0:g<0?O=Math.floor((_-p+1)/g+1):O=Math.floor((_-p-1)/g+1);let z=[];for(let we=0;we<O;++we)z[we]=S[p+we*g];return z}f.slice=Q;function G(S,M,p){let _=S.length;if(_<=1||(M<0?M=Math.max(0,M+_):M=Math.min(M,_-1),p<0?p=Math.max(0,p+_):p=Math.min(p,_-1),M===p))return;let g=S[M],E=M<p?1:-1;for(let O=M;O!==p;O+=E)S[O]=S[O+E];S[p]=g}f.move=G;function ue(S,M=0,p=-1){let _=S.length;if(!(_<=1))for(M<0?M=Math.max(0,M+_):M=Math.min(M,_-1),p<0?p=Math.max(0,p+_):p=Math.min(p,_-1);M<p;){let g=S[M],E=S[p];S[M++]=E,S[p--]=g}}f.reverse=ue;function Ce(S,M,p=0,_=-1){let g=S.length;if(g<=1||(p<0?p=Math.max(0,p+g):p=Math.min(p,g-1),_<0?_=Math.max(0,_+g):_=Math.min(_,g-1),p>=_))return;let E=_-p+1;if(M>0?M=M%E:M<0&&(M=(M%E+E)%E),M===0)return;let O=p+M;ue(S,p,O-1),ue(S,O,_),ue(S,p,_)}f.rotate=Ce;function Me(S,M,p=0,_=-1){let g=S.length;if(g===0)return;p<0?p=Math.max(0,p+g):p=Math.min(p,g-1),_<0?_=Math.max(0,_+g):_=Math.min(_,g-1);let E;_<p?E=_+1+(g-p):E=_-p+1;for(let O=0;O<E;++O)S[(p+O)%g]=M}f.fill=Me;function Fo(S,M,p){let _=S.length;M<0?M=Math.max(0,M+_):M=Math.min(M,_);for(let g=_;g>M;--g)S[g]=S[g-1];S[M]=p}f.insert=Fo;function ot(S,M){let p=S.length;if(M<0&&(M+=p),M<0||M>=p)return;let _=S[M];for(let g=M+1;g<p;++g)S[g-1]=S[g];return S.length=p-1,_}f.removeAt=ot;function Ko(S,M,p=0,_=-1){let g=y(S,M,p,_);return g!==-1&&ot(S,g),g}f.removeFirstOf=Ko;function zo(S,M,p=-1,_=0){let g=b(S,M,p,_);return g!==-1&&ot(S,g),g}f.removeLastOf=zo;function Vo(S,M,p=0,_=-1){let g=S.length;if(g===0)return 0;p<0?p=Math.max(0,p+g):p=Math.min(p,g-1),_<0?_=Math.max(0,_+g):_=Math.min(_,g-1);let E=0;for(let O=0;O<g;++O)p<=_&&O>=p&&O<=_&&S[O]===M||_<p&&(O<=_||O>=p)&&S[O]===M?E++:E>0&&(S[O-E]=S[O]);return E>0&&(S.length=g-E),E}f.removeAllOf=Vo;function Bo(S,M,p=0,_=-1){let g,E=P(S,M,p,_);return E!==-1&&(g=ot(S,E)),{index:E,value:g}}f.removeFirstWhere=Bo;function Wo(S,M,p=-1,_=0){let g,E=x(S,M,p,_);return E!==-1&&(g=ot(S,E)),{index:E,value:g}}f.removeLastWhere=Wo;function $o(S,M,p=0,_=-1){let g=S.length;if(g===0)return 0;p<0?p=Math.max(0,p+g):p=Math.min(p,g-1),_<0?_=Math.max(0,_+g):_=Math.min(_,g-1);let E=0;for(let O=0;O<g;++O)p<=_&&O>=p&&O<=_&&M(S[O],O)||_<p&&(O<=_||O>=p)&&M(S[O],O)?E++:E>0&&(S[O-E]=S[O]);return E>0&&(S.length=g-E),E}f.removeAllWhere=$o}(n.ArrayExt||(n.ArrayExt={}));function*e(...f){for(let y of f)yield*y}function*t(){}function*s(f,y=0){for(let b of f)yield[y++,b]}function*r(f,y){let b=0;for(let P of f)y(P,b++)&&(yield P)}function i(f,y){let b=0;for(let P of f)if(y(P,b++))return P}function o(f,y){let b=0;for(let P of f)if(y(P,b++))return b-1;return-1}function a(f,y){let b;for(let P of f){if(b===void 0){b=P;continue}y(P,b)<0&&(b=P)}return b}function h(f,y){let b;for(let P of f){if(b===void 0){b=P;continue}y(P,b)>0&&(b=P)}return b}function c(f,y){let b=!0,P,x;for(let J of f)b?(P=J,x=J,b=!1):y(J,P)<0?P=J:y(J,x)>0&&(x=J);return b?void 0:[P,x]}function u(f){return Array.from(f)}function l(f){let y={};for(let[b,P]of f)y[b]=P;return y}function d(f,y){let b=0;for(let P of f)if(y(P,b++)===!1)return}function v(f,y){let b=0;for(let P of f)if(y(P,b++)===!1)return!1;return!0}function m(f,y){let b=0;for(let P of f)if(y(P,b++))return!0;return!1}function*q(f,y){let b=0;for(let P of f)yield y(P,b++)}function*I(f,y,b){y===void 0?(y=f,f=0,b=1):b===void 0&&(b=1);let P=T.rangeLength(f,y,b);for(let x=0;x<P;x++)yield f+b*x}var T;(function(f){function y(b,P,x){return x===0?1/0:b>P&&x>0||b<P&&x<0?0:Math.ceil((P-b)/x)}f.rangeLength=y})(T||(T={}));function A(f,y,b){let P=f[Symbol.iterator](),x=0,J=P.next();if(J.done&&b===void 0)throw new TypeError("Reduce of empty iterable with no initial value.");if(J.done)return b;let F=P.next();if(F.done&&b===void 0)return J.value;if(F.done)return y(b,J.value,x++);let K;b===void 0?K=y(J.value,F.value,x++):K=y(y(b,J.value,x++),F.value,x++);let X;for(;!(X=P.next()).done;)K=y(K,X.value,x++);return K}function*C(f,y){for(;0<y--;)yield f}function*w(f){yield f}function*k(f){if(typeof f.retro=="function")yield*f.retro();else for(let y=f.length-1;y>-1;y--)yield f[y]}function N(f){let y=[],b=new Set,P=new Map;for(let F of f)x(F);for(let[F]of P)J(F);return y;function x(F){let[K,X]=F,B=P.get(X);B?B.push(K):P.set(X,[K])}function J(F){if(b.has(F))return;b.add(F);let K=P.get(F);if(K)for(let X of K)J(X);y.push(F)}}function*j(f,y){let b=0;for(let P of f)b++%y===0&&(yield P)}n.StringExt=void 0,function(f){function y(F,K,X=0){let B=new Array(K.length);for(let Q=0,G=X,ue=K.length;Q<ue;++Q,++G){if(G=F.indexOf(K[Q],G),G===-1)return null;B[Q]=G}return B}f.findIndices=y;function b(F,K,X=0){let B=y(F,K,X);if(!B)return null;let Q=0;for(let G=0,ue=B.length;G<ue;++G){let Ce=B[G]-X;Q+=Ce*Ce}return{score:Q,indices:B}}f.matchSumOfSquares=b;function P(F,K,X=0){let B=y(F,K,X);if(!B)return null;let Q=0,G=X-1;for(let ue=0,Ce=B.length;ue<Ce;++ue){let Me=B[ue];Q+=Me-G-1,G=Me}return{score:Q,indices:B}}f.matchSumOfDeltas=P;function x(F,K,X){let B=[],Q=0,G=0,ue=K.length;for(;Q<ue;){let Ce=K[Q],Me=K[Q];for(;++Q<ue&&K[Q]===Me+1;)Me++;G<Ce&&B.push(F.slice(G,Ce)),Ce<Me+1&&B.push(X(F.slice(Ce,Me+1))),G=Me+1}return G<F.length&&B.push(F.slice(G)),B}f.highlight=x;function J(F,K){return F<K?-1:F>K?1:0}f.cmp=J}(n.StringExt||(n.StringExt={}));function*D(f,y){if(y<1)return;let b=f[Symbol.iterator](),P;for(;0<y--&&!(P=b.next()).done;)yield P.value}function*U(...f){let y=f.map(P=>P[Symbol.iterator]()),b=y.map(P=>P.next());for(;v(b,P=>!P.done);b=y.map(P=>P.next()))yield b.map(P=>P.value)}n.chain=e,n.each=d,n.empty=t,n.enumerate=s,n.every=v,n.filter=r,n.find=i,n.findIndex=o,n.map=q,n.max=h,n.min=a,n.minmax=c,n.once=w,n.range=I,n.reduce=A,n.repeat=C,n.retro=k,n.some=m,n.stride=j,n.take=D,n.toArray=u,n.toObject=l,n.topologicSort=N,n.zip=U})});var Z=R((xt,dr)=>{(function(n,e){typeof xt=="object"&&typeof dr!="undefined"?e(xt,Jn()):typeof define=="function"&&define.amd?define(["exports","@lumino/algorithm"],e):(n=typeof globalThis!="undefined"?globalThis:n||self,e(n.lumino_coreutils={},n.lumino_algorithm))})(xt,function(n,e){"use strict";n.JSONExt=void 0,function(c){c.emptyObject=Object.freeze({}),c.emptyArray=Object.freeze([]);function u(C){return C===null||typeof C=="boolean"||typeof C=="number"||typeof C=="string"}c.isPrimitive=u;function l(C){return Array.isArray(C)}c.isArray=l;function d(C){return!u(C)&&!l(C)}c.isObject=d;function v(C,w){if(C===w)return!0;if(u(C)||u(w))return!1;let k=l(C),N=l(w);return k!==N?!1:k&&N?q(C,w):I(C,w)}c.deepEqual=v;function m(C){return u(C)?C:l(C)?T(C):A(C)}c.deepCopy=m;function q(C,w){if(C===w)return!0;if(C.length!==w.length)return!1;for(let k=0,N=C.length;k<N;++k)if(!v(C[k],w[k]))return!1;return!0}function I(C,w){if(C===w)return!0;for(let k in C)if(C[k]!==void 0&&!(k in w))return!1;for(let k in w)if(w[k]!==void 0&&!(k in C))return!1;for(let k in C){let N=C[k],j=w[k];if(!(N===void 0&&j===void 0)&&(N===void 0||j===void 0||!v(N,j)))return!1}return!0}function T(C){let w=new Array(C.length);for(let k=0,N=C.length;k<N;++k)w[k]=m(C[k]);return w}function A(C){let w={};for(let k in C){let N=C[k];N!==void 0&&(w[k]=m(N))}return w}}(n.JSONExt||(n.JSONExt={}));class t{constructor(){this._types=[],this._values=[]}types(){return this._types.slice()}hasData(u){return this._types.indexOf(u)!==-1}getData(u){let l=this._types.indexOf(u);return l!==-1?this._values[l]:void 0}setData(u,l){this.clearData(u),this._types.push(u),this._values.push(l)}clearData(u){let l=this._types.indexOf(u);l!==-1&&(this._types.splice(l,1),this._values.splice(l,1))}clear(){this._types.length=0,this._values.length=0}}class s{constructor(u={}){this._application=null,this._validatePlugin=()=>!0,this._plugins=new Map,this._services=new Map,u.validatePlugin&&(console.info("Plugins may be rejected by the custom validation plugin method."),this._validatePlugin=u.validatePlugin)}get application(){return this._application}set application(u){if(this._application!==null)throw Error("PluginRegistry.application is already set. It cannot be overridden.");this._application=u}get deferredPlugins(){return Array.from(this._plugins).filter(([u,l])=>l.autoStart==="defer").map(([u,l])=>u)}getPluginDescription(u){var l,d;return(d=(l=this._plugins.get(u))===null||l===void 0?void 0:l.description)!==null&&d!==void 0?d:""}hasPlugin(u){return this._plugins.has(u)}isPluginActivated(u){var l,d;return(d=(l=this._plugins.get(u))===null||l===void 0?void 0:l.activated)!==null&&d!==void 0?d:!1}listPlugins(){return Array.from(this._plugins.keys())}registerPlugin(u){if(this._plugins.has(u.id))throw new TypeError(`Plugin '${u.id}' is already registered.`);if(!this._validatePlugin(u))throw new Error(`Plugin '${u.id}' is not valid.`);let l=r.createPluginData(u);r.ensureNoCycle(l,this._plugins,this._services),l.provides&&this._services.set(l.provides,l.id),this._plugins.set(l.id,l)}registerPlugins(u){for(let l of u)this.registerPlugin(l)}deregisterPlugin(u,l){let d=this._plugins.get(u);if(d){if(d.activated&&!l)throw new Error(`Plugin '${u}' is still active.`);this._plugins.delete(u)}}async activatePlugin(u){let l=this._plugins.get(u);if(!l)throw new ReferenceError(`Plugin '${u}' is not registered.`);if(l.activated)return;if(l.promise)return l.promise;let d=l.requires.map(m=>this.resolveRequiredService(m)),v=l.optional.map(m=>this.resolveOptionalService(m));return l.promise=Promise.all([...d,...v]).then(m=>l.activate.apply(void 0,[this.application,...m])).then(m=>{l.service=m,l.activated=!0,l.promise=null}).catch(m=>{throw l.promise=null,m}),l.promise}async activatePlugins(u,l={}){switch(u){case"defer":{let d=this.deferredPlugins.filter(v=>this._plugins.get(v).autoStart).map(v=>this.activatePlugin(v));await Promise.all(d);break}case"startUp":{let v=r.collectStartupPlugins(this._plugins,l).map(async m=>{try{return await this.activatePlugin(m)}catch(q){console.error(`Plugin '${m}' failed to activate.`,q)}});await Promise.all(v);break}}}async deactivatePlugin(u){let l=this._plugins.get(u);if(!l)throw new ReferenceError(`Plugin '${u}' is not registered.`);if(!l.activated)return[];if(!l.deactivate)throw new TypeError(`Plugin '${u}'#deactivate() method missing`);let d=r.findDependents(u,this._plugins,this._services),v=d.map(m=>this._plugins.get(m));for(let m of v)if(!m.deactivate)throw new TypeError(`Plugin ${m.id}#deactivate() method missing (depends on ${u})`);for(let m of v){let q=[...m.requires,...m.optional].map(I=>{let T=this._services.get(I);return T?this._plugins.get(T).service:null});await m.deactivate(this.application,...q),m.service=null,m.activated=!1}return d.pop(),d}async resolveRequiredService(u){let l=this._services.get(u);if(!l)throw new TypeError(`No provider for: ${u.name}.`);let d=this._plugins.get(l);return d.activated||await this.activatePlugin(l),d.service}async resolveOptionalService(u){let l=this._services.get(u);if(!l)return null;let d=this._plugins.get(l);if(!d.activated)try{await this.activatePlugin(l)}catch(v){return console.error(v),null}return d.service}}var r;(function(c){class u{constructor(I){var T,A,C,w;this._activated=!1,this._promise=null,this._service=null,this.id=I.id,this.description=(T=I.description)!==null&&T!==void 0?T:"",this.activate=I.activate,this.deactivate=(A=I.deactivate)!==null&&A!==void 0?A:null,this.provides=(C=I.provides)!==null&&C!==void 0?C:null,this.autoStart=(w=I.autoStart)!==null&&w!==void 0?w:!1,this.requires=I.requires?I.requires.slice():[],this.optional=I.optional?I.optional.slice():[]}get activated(){return this._activated}set activated(I){this._activated=I}get service(){return this._service}set service(I){this._service=I}get promise(){return this._promise}set promise(I){this._promise=I}}function l(q){return new u(q)}c.createPluginData=l;function d(q,I,T){let A=[...q.requires,...q.optional],C=k=>{if(k===q.provides)return!0;let N=T.get(k);if(!N)return!1;let j=I.get(N),D=[...j.requires,...j.optional];return D.length===0?!1:(w.push(N),D.some(C)?!0:(w.pop(),!1))};if(!q.provides||A.length===0)return;let w=[q.id];if(A.some(C))throw new ReferenceError(`Cycle detected: ${w.join(" -> ")}.`)}c.ensureNoCycle=d;function v(q,I,T){let A=new Array,C=D=>{let U=I.get(D),f=[...U.requires,...U.optional];A.push(...f.reduce((y,b)=>{let P=T.get(b);return P&&y.push([D,P]),y},[]))};for(let D of I.keys())C(D);let w=A.filter(D=>D[1]===q),k=0;for(;w.length>k;){let D=w.length,U=new Set(w.map(f=>f[0]));for(let f of U)A.filter(y=>y[1]===f).forEach(y=>{w.includes(y)||w.push(y)});k=D}let N=e.topologicSort(w),j=N.findIndex(D=>D===q);return j===-1?[q]:N.slice(0,j+1)}c.findDependents=v;function m(q,I){let T=new Set;for(let A of q.keys())q.get(A).autoStart===!0&&T.add(A);if(I.startPlugins)for(let A of I.startPlugins)T.add(A);if(I.ignorePlugins)for(let A of I.ignorePlugins)T.delete(A);return Array.from(T)}c.collectStartupPlugins=m})(r||(r={}));class i{constructor(){this.promise=new Promise((u,l)=>{this._resolve=u,this._reject=l})}resolve(u){let l=this._resolve;l(u)}reject(u){let l=this._reject;l(u)}}class o{constructor(u,l){this.name=u,this.description=l!=null?l:"",this._tokenStructuralPropertyT=null}}function a(c){let u=0;for(let l=0,d=c.length;l<d;++l)l%4===0&&(u=Math.random()*4294967295>>>0),c[l]=u&255,u>>>=8}n.Random=void 0,function(c){c.getRandomValues=(()=>{let u=typeof window!="undefined"&&(window.crypto||window.msCrypto)||null;return u&&typeof u.getRandomValues=="function"?function(d){return u.getRandomValues(d)}:a})()}(n.Random||(n.Random={}));function h(c){let u=new Uint8Array(16),l=new Array(256);for(let d=0;d<16;++d)l[d]="0"+d.toString(16);for(let d=16;d<256;++d)l[d]=d.toString(16);return function(){return c(u),u[6]=64|u[6]&15,u[8]=128|u[8]&63,l[u[0]]+l[u[1]]+l[u[2]]+l[u[3]]+"-"+l[u[4]]+l[u[5]]+"-"+l[u[6]]+l[u[7]]+"-"+l[u[8]]+l[u[9]]+"-"+l[u[10]]+l[u[11]]+l[u[12]]+l[u[13]]+l[u[14]]+l[u[15]]}}n.UUID=void 0,function(c){c.uuid4=h(n.Random.getRandomValues)}(n.UUID||(n.UUID={})),n.MimeData=t,n.PluginRegistry=s,n.PromiseDelegate=i,n.Token=o})});var ee=R((Ft,fr)=>{(function(n,e){typeof Ft=="object"&&typeof fr!="undefined"?e(Ft,Jn(),Z()):typeof define=="function"&&define.amd?define(["exports","@lumino/algorithm","@lumino/coreutils"],e):(n=typeof globalThis!="undefined"?globalThis:n||self,e(n.lumino_signaling={},n.lumino_algorithm,n.lumino_coreutils))})(Ft,function(n,e,t){"use strict";class s{constructor(a){this.sender=a}connect(a,h){return i.connect(this,a,h)}disconnect(a,h){return i.disconnect(this,a,h)}emit(a){i.emit(this,a)}}(function(o){function a(m,q){i.disconnectBetween(m,q)}o.disconnectBetween=a;function h(m){i.disconnectSender(m)}o.disconnectSender=h;function c(m){i.disconnectReceiver(m)}o.disconnectReceiver=c;function u(m){i.disconnectAll(m)}o.disconnectAll=u;function l(m){i.disconnectAll(m)}o.clearData=l;function d(){return i.exceptionHandler}o.getExceptionHandler=d;function v(m){let q=i.exceptionHandler;return i.exceptionHandler=m,q}o.setExceptionHandler=v})(s||(s={}));class r extends s{constructor(){super(...arguments),this._pending=new t.PromiseDelegate}async*[Symbol.asyncIterator](){let a=this._pending;for(;;)try{let{args:h,next:c}=await a.promise;a=c,yield h}catch{return}}emit(a){let h=this._pending,c=this._pending=new t.PromiseDelegate;h.resolve({args:a,next:c}),super.emit(a)}stop(){this._pending.promise.catch(()=>{}),this._pending.reject("stop"),this._pending=new t.PromiseDelegate}}var i;(function(o){o.exceptionHandler=D=>{console.error(D)};function a(D,U,f){f=f||void 0;let y=m.get(D.sender);if(y||(y=[],m.set(D.sender,y)),A(y,D,U,f))return!1;let b=f||U,P=q.get(b);P||(P=[],q.set(b,P));let x={signal:D,slot:U,thisArg:f};return y.push(x),P.push(x),!0}o.connect=a;function h(D,U,f){f=f||void 0;let y=m.get(D.sender);if(!y||y.length===0)return!1;let b=A(y,D,U,f);if(!b)return!1;let P=f||U,x=q.get(P);return b.signal=null,w(y),w(x),!0}o.disconnect=h;function c(D,U){let f=m.get(D);if(!f||f.length===0)return;let y=q.get(U);if(!(!y||y.length===0)){for(let b of y)b.signal&&b.signal.sender===D&&(b.signal=null);w(f),w(y)}}o.disconnectBetween=c;function u(D){let U=m.get(D);if(!(!U||U.length===0)){for(let f of U){if(!f.signal)continue;let y=f.thisArg||f.slot;f.signal=null,w(q.get(y))}w(U)}}o.disconnectSender=u;function l(D){let U=q.get(D);if(!(!U||U.length===0)){for(let f of U){if(!f.signal)continue;let y=f.signal.sender;f.signal=null,w(m.get(y))}w(U)}}o.disconnectReceiver=l;function d(D){u(D),l(D)}o.disconnectAll=d;function v(D,U){let f=m.get(D.sender);if(!(!f||f.length===0))for(let y=0,b=f.length;y<b;++y){let P=f[y];P.signal===D&&C(P,U)}}o.emit=v;let m=new WeakMap,q=new WeakMap,I=new Set,T=typeof requestAnimationFrame=="function"?requestAnimationFrame:setImmediate;function A(D,U,f,y){return e.find(D,b=>b.signal===U&&b.slot===f&&b.thisArg===y)}function C(D,U){let{signal:f,slot:y,thisArg:b}=D;try{y.call(b,f.sender,U)}catch(P){o.exceptionHandler(P)}}function w(D){I.size===0&&T(k),I.add(D)}function k(){I.forEach(N),I.clear()}function N(D){e.ArrayExt.removeAllWhere(D,j)}function j(D){return D.signal===null}})(i||(i={})),n.Signal=s,n.Stream=r})});var pr=R(Kt=>{"use strict";Object.defineProperty(Kt,"__esModule",{value:!0});Kt.ActivityMonitor=void 0;var _r=ee(),Gn=class{constructor(e){this._timer=-1,this._timeout=-1,this._isDisposed=!1,this._activityStopped=new _r.Signal(this),e.signal.connect(this._onSignalFired,this),this._timeout=e.timeout||1e3}get activityStopped(){return this._activityStopped}get timeout(){return this._timeout}set timeout(e){this._timeout=e}get isDisposed(){return this._isDisposed}dispose(){this._isDisposed||(this._isDisposed=!0,_r.Signal.clearData(this))}_onSignalFired(e,t){clearTimeout(this._timer),this._sender=e,this._args=t,this._timer=setTimeout(()=>{this._activityStopped.emit({sender:this._sender,args:this._args})},this._timeout)}};Kt.ActivityMonitor=Gn});var mr=R(gr=>{"use strict";Object.defineProperty(gr,"__esModule",{value:!0})});var vr=R(zt=>{"use strict";Object.defineProperty(zt,"__esModule",{value:!0});zt.LruCache=void 0;var fa=128,Xn=class{constructor(e={}){this._map=new Map,this._maxSize=(e==null?void 0:e.maxSize)||fa}get size(){return this._map.size}clear(){this._map.clear()}get(e){let t=this._map.get(e)||null;return t!=null&&(this._map.delete(e),this._map.set(e,t)),t}set(e,t){this._map.size>=this._maxSize&&this._map.delete(this._map.keys().next().value),this._map.set(e,t)}};zt.LruCache=Xn});var wr=R(Vt=>{"use strict";Object.defineProperty(Vt,"__esModule",{value:!0});Vt.MarkdownCodeBlocks=void 0;var yr;(function(n){n.CODE_BLOCK_MARKER="```";let e=[".markdown",".mdown",".mkdn",".md",".mkd",".mdwn",".mdtxt",".mdtext",".text",".txt",".Rmd"];class t{constructor(o){this.startLine=o,this.code="",this.endLine=-1}}n.MarkdownCodeBlock=t;function s(i){return e.indexOf(i)>-1}n.isMarkdown=s;function r(i){if(!i||i==="")return[];let o=i.split(`
2
+ `),a=[],h=null;for(let c=0;c<o.length;c++){let u=o[c],l=u.indexOf(n.CODE_BLOCK_MARKER)===0,d=h!=null;if(!(!l&&!d))if(d)h&&(l?(h.endLine=c-1,a.push(h),h=null):h.code+=u+`
3
+ `);else{h=new t(c);let v=u.indexOf(n.CODE_BLOCK_MARKER),m=u.lastIndexOf(n.CODE_BLOCK_MARKER);v!==m&&(h.code=u.substring(v+n.CODE_BLOCK_MARKER.length,m),h.endLine=c,a.push(h),h=null)}}return a}n.findMarkdownCodeBlocks=r})(yr||(Vt.MarkdownCodeBlocks=yr={}))});var Pr=R((qu,Cr)=>{"use strict";function _a(n,e){var t=n;e.slice(0,-1).forEach(function(r){t=t[r]||{}});var s=e[e.length-1];return s in t}function Sr(n){return typeof n=="number"||/^0x[0-9a-f]+$/i.test(n)?!0:/^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(n)}function br(n,e){return e==="constructor"&&typeof n[e]=="function"||e==="__proto__"}Cr.exports=function(n,e){e||(e={});var t={bools:{},strings:{},unknownFn:null};typeof e.unknown=="function"&&(t.unknownFn=e.unknown),typeof e.boolean=="boolean"&&e.boolean?t.allBools=!0:[].concat(e.boolean).filter(Boolean).forEach(function(w){t.bools[w]=!0});var s={};function r(w){return s[w].some(function(k){return t.bools[k]})}Object.keys(e.alias||{}).forEach(function(w){s[w]=[].concat(e.alias[w]),s[w].forEach(function(k){s[k]=[w].concat(s[w].filter(function(N){return k!==N}))})}),[].concat(e.string).filter(Boolean).forEach(function(w){t.strings[w]=!0,s[w]&&[].concat(s[w]).forEach(function(k){t.strings[k]=!0})});var i=e.default||{},o={_:[]};function a(w,k){return t.allBools&&/^--[^=]+$/.test(k)||t.strings[w]||t.bools[w]||s[w]}function h(w,k,N){for(var j=w,D=0;D<k.length-1;D++){var U=k[D];if(br(j,U))return;j[U]===void 0&&(j[U]={}),(j[U]===Object.prototype||j[U]===Number.prototype||j[U]===String.prototype)&&(j[U]={}),j[U]===Array.prototype&&(j[U]=[]),j=j[U]}var f=k[k.length-1];br(j,f)||((j===Object.prototype||j===Number.prototype||j===String.prototype)&&(j={}),j===Array.prototype&&(j=[]),j[f]===void 0||t.bools[f]||typeof j[f]=="boolean"?j[f]=N:Array.isArray(j[f])?j[f].push(N):j[f]=[j[f],N])}function c(w,k,N){if(!(N&&t.unknownFn&&!a(w,N)&&t.unknownFn(N)===!1)){var j=!t.strings[w]&&Sr(k)?Number(k):k;h(o,w.split("."),j),(s[w]||[]).forEach(function(D){h(o,D.split("."),j)})}}Object.keys(t.bools).forEach(function(w){c(w,i[w]===void 0?!1:i[w])});var u=[];n.indexOf("--")!==-1&&(u=n.slice(n.indexOf("--")+1),n=n.slice(0,n.indexOf("--")));for(var l=0;l<n.length;l++){var d=n[l],v,m;if(/^--.+=/.test(d)){var q=d.match(/^--([^=]+)=([\s\S]*)$/);v=q[1];var I=q[2];t.bools[v]&&(I=I!=="false"),c(v,I,d)}else if(/^--no-.+/.test(d))v=d.match(/^--no-(.+)/)[1],c(v,!1,d);else if(/^--.+/.test(d))v=d.match(/^--(.+)/)[1],m=n[l+1],m!==void 0&&!/^(-|--)[^-]/.test(m)&&!t.bools[v]&&!t.allBools&&(!s[v]||!r(v))?(c(v,m,d),l+=1):/^(true|false)$/.test(m)?(c(v,m==="true",d),l+=1):c(v,t.strings[v]?"":!0,d);else if(/^-[^-]+/.test(d)){for(var T=d.slice(1,-1).split(""),A=!1,C=0;C<T.length;C++){if(m=d.slice(C+2),m==="-"){c(T[C],m,d);continue}if(/[A-Za-z]/.test(T[C])&&m[0]==="="){c(T[C],m.slice(1),d),A=!0;break}if(/[A-Za-z]/.test(T[C])&&/-?\d+(\.\d*)?(e-?\d+)?$/.test(m)){c(T[C],m,d),A=!0;break}if(T[C+1]&&T[C+1].match(/\W/)){c(T[C],d.slice(C+2),d),A=!0;break}else c(T[C],t.strings[T[C]]?"":!0,d)}v=d.slice(-1)[0],!A&&v!=="-"&&(n[l+1]&&!/^(-|--)[^-]/.test(n[l+1])&&!t.bools[v]&&(!s[v]||!r(v))?(c(v,n[l+1],d),l+=1):n[l+1]&&/^(true|false)$/.test(n[l+1])?(c(v,n[l+1]==="true",d),l+=1):c(v,t.strings[v]?"":!0,d))}else if((!t.unknownFn||t.unknownFn(d)!==!1)&&o._.push(t.strings._||!Sr(d)?d:Number(d)),e.stopEarly){o._.push.apply(o._,n.slice(l+1));break}}return Object.keys(i).forEach(function(w){_a(o,w.split("."))||(h(o,w.split("."),i[w]),(s[w]||[]).forEach(function(k){h(o,k.split("."),i[w])}))}),e["--"]?o["--"]=u.slice():u.forEach(function(w){o._.push(w)}),o}});var Bt=R((Tu,Er)=>{"use strict";function Ee(n){if(typeof n!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(n))}function Mr(n,e){for(var t="",s=0,r=-1,i=0,o,a=0;a<=n.length;++a){if(a<n.length)o=n.charCodeAt(a);else{if(o===47)break;o=47}if(o===47){if(!(r===a-1||i===1))if(r!==a-1&&i===2){if(t.length<2||s!==2||t.charCodeAt(t.length-1)!==46||t.charCodeAt(t.length-2)!==46){if(t.length>2){var h=t.lastIndexOf("/");if(h!==t.length-1){h===-1?(t="",s=0):(t=t.slice(0,h),s=t.length-1-t.lastIndexOf("/")),r=a,i=0;continue}}else if(t.length===2||t.length===1){t="",s=0,r=a,i=0;continue}}e&&(t.length>0?t+="/..":t="..",s=2)}else t.length>0?t+="/"+n.slice(r+1,a):t=n.slice(r+1,a),s=a-r-1;r=a,i=0}else o===46&&i!==-1?++i:i=-1}return t}function pa(n,e){var t=e.dir||e.root,s=e.base||(e.name||"")+(e.ext||"");return t?t===e.root?t+s:t+n+s:s}var Ye={resolve:function(){for(var e="",t=!1,s,r=arguments.length-1;r>=-1&&!t;r--){var i;r>=0?i=arguments[r]:(s===void 0&&(s=process.cwd()),i=s),Ee(i),i.length!==0&&(e=i+"/"+e,t=i.charCodeAt(0)===47)}return e=Mr(e,!t),t?e.length>0?"/"+e:"/":e.length>0?e:"."},normalize:function(e){if(Ee(e),e.length===0)return".";var t=e.charCodeAt(0)===47,s=e.charCodeAt(e.length-1)===47;return e=Mr(e,!t),e.length===0&&!t&&(e="."),e.length>0&&s&&(e+="/"),t?"/"+e:e},isAbsolute:function(e){return Ee(e),e.length>0&&e.charCodeAt(0)===47},join:function(){if(arguments.length===0)return".";for(var e,t=0;t<arguments.length;++t){var s=arguments[t];Ee(s),s.length>0&&(e===void 0?e=s:e+="/"+s)}return e===void 0?".":Ye.normalize(e)},relative:function(e,t){if(Ee(e),Ee(t),e===t||(e=Ye.resolve(e),t=Ye.resolve(t),e===t))return"";for(var s=1;s<e.length&&e.charCodeAt(s)===47;++s);for(var r=e.length,i=r-s,o=1;o<t.length&&t.charCodeAt(o)===47;++o);for(var a=t.length,h=a-o,c=i<h?i:h,u=-1,l=0;l<=c;++l){if(l===c){if(h>c){if(t.charCodeAt(o+l)===47)return t.slice(o+l+1);if(l===0)return t.slice(o+l)}else i>c&&(e.charCodeAt(s+l)===47?u=l:l===0&&(u=0));break}var d=e.charCodeAt(s+l),v=t.charCodeAt(o+l);if(d!==v)break;d===47&&(u=l)}var m="";for(l=s+u+1;l<=r;++l)(l===r||e.charCodeAt(l)===47)&&(m.length===0?m+="..":m+="/..");return m.length>0?m+t.slice(o+u):(o+=u,t.charCodeAt(o)===47&&++o,t.slice(o))},_makeLong:function(e){return e},dirname:function(e){if(Ee(e),e.length===0)return".";for(var t=e.charCodeAt(0),s=t===47,r=-1,i=!0,o=e.length-1;o>=1;--o)if(t=e.charCodeAt(o),t===47){if(!i){r=o;break}}else i=!1;return r===-1?s?"/":".":s&&r===1?"//":e.slice(0,r)},basename:function(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');Ee(e);var s=0,r=-1,i=!0,o;if(t!==void 0&&t.length>0&&t.length<=e.length){if(t.length===e.length&&t===e)return"";var a=t.length-1,h=-1;for(o=e.length-1;o>=0;--o){var c=e.charCodeAt(o);if(c===47){if(!i){s=o+1;break}}else h===-1&&(i=!1,h=o+1),a>=0&&(c===t.charCodeAt(a)?--a===-1&&(r=o):(a=-1,r=h))}return s===r?r=h:r===-1&&(r=e.length),e.slice(s,r)}else{for(o=e.length-1;o>=0;--o)if(e.charCodeAt(o)===47){if(!i){s=o+1;break}}else r===-1&&(i=!1,r=o+1);return r===-1?"":e.slice(s,r)}},extname:function(e){Ee(e);for(var t=-1,s=0,r=-1,i=!0,o=0,a=e.length-1;a>=0;--a){var h=e.charCodeAt(a);if(h===47){if(!i){s=a+1;break}continue}r===-1&&(i=!1,r=a+1),h===46?t===-1?t=a:o!==1&&(o=1):t!==-1&&(o=-1)}return t===-1||r===-1||o===0||o===1&&t===r-1&&t===s+1?"":e.slice(t,r)},format:function(e){if(e===null||typeof e!="object")throw new TypeError('The "pathObject" argument must be of type Object. Received type '+typeof e);return pa("/",e)},parse:function(e){Ee(e);var t={root:"",dir:"",base:"",ext:"",name:""};if(e.length===0)return t;var s=e.charCodeAt(0),r=s===47,i;r?(t.root="/",i=1):i=0;for(var o=-1,a=0,h=-1,c=!0,u=e.length-1,l=0;u>=i;--u){if(s=e.charCodeAt(u),s===47){if(!c){a=u+1;break}continue}h===-1&&(c=!1,h=u+1),s===46?o===-1?o=u:l!==1&&(l=1):o!==-1&&(l=-1)}return o===-1||h===-1||l===0||l===1&&o===h-1&&o===a+1?h!==-1&&(a===0&&r?t.base=t.name=e.slice(1,h):t.base=t.name=e.slice(a,h)):(a===0&&r?(t.name=e.slice(1,o),t.base=e.slice(1,h)):(t.name=e.slice(a,o),t.base=e.slice(a,h)),t.ext=e.slice(o,h)),a>0?t.dir=e.slice(0,a-1):r&&(t.dir="/"),t},sep:"/",delimiter:":",win32:null,posix:null};Ye.posix=Ye;Er.exports=Ye});var Rr=R((ju,Ir)=>{"use strict";Ir.exports=function(e,t){if(t=t.split(":")[0],e=+e,!e)return!1;switch(t){case"http":case"ws":return e!==80;case"https":case"wss":return e!==443;case"ftp":return e!==21;case"gopher":return e!==70;case"file":return!1}return e!==0}});var Dr=R(Yn=>{"use strict";var ga=Object.prototype.hasOwnProperty,ma;function kr(n){try{return decodeURIComponent(n.replace(/\+/g," "))}catch{return null}}function Or(n){try{return encodeURIComponent(n)}catch{return null}}function va(n){for(var e=/([^=?#&]+)=?([^&]*)/g,t={},s;s=e.exec(n);){var r=kr(s[1]),i=kr(s[2]);r===null||i===null||r in t||(t[r]=i)}return t}function ya(n,e){e=e||"";var t=[],s,r;typeof e!="string"&&(e="?");for(r in n)if(ga.call(n,r)){if(s=n[r],!s&&(s===null||s===ma||isNaN(s))&&(s=""),r=Or(r),s=Or(s),r===null||s===null)continue;t.push(r+"="+s)}return t.length?e+t.join("&"):""}Yn.stringify=ya;Yn.parse=va});var xr=R((Au,Lr)=>{"use strict";var Tr=Rr(),Wt=Dr(),wa=/^[\x00-\x20\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]+/,jr=/[\n\r\t]/g,Sa=/^[A-Za-z][A-Za-z0-9+-.]*:\/\//,Ur=/:\d+$/,ba=/^([a-z][a-z0-9.+-]*:)?(\/\/)?([\\/]+)?([\S\s]*)/i,Ca=/^[a-zA-Z]:/;function Zn(n){return(n||"").toString().replace(wa,"")}var Qn=[["#","hash"],["?","query"],function(e,t){return Ie(t.protocol)?e.replace(/\\/g,"/"):e},["/","pathname"],["@","auth",1],[NaN,"host",void 0,1,1],[/:(\d*)$/,"port",void 0,1],[NaN,"hostname",void 0,1,1]],qr={hash:1,query:1};function Ar(n){var e;typeof window!="undefined"?e=window:typeof global!="undefined"?e=global:typeof self!="undefined"?e=self:e={};var t=e.location||{};n=n||t;var s={},r=typeof n,i;if(n.protocol==="blob:")s=new Re(unescape(n.pathname),{});else if(r==="string"){s=new Re(n,{});for(i in qr)delete s[i]}else if(r==="object"){for(i in n)i in qr||(s[i]=n[i]);s.slashes===void 0&&(s.slashes=Sa.test(n.href))}return s}function Ie(n){return n==="file:"||n==="ftp:"||n==="http:"||n==="https:"||n==="ws:"||n==="wss:"}function Nr(n,e){n=Zn(n),n=n.replace(jr,""),e=e||{};var t=ba.exec(n),s=t[1]?t[1].toLowerCase():"",r=!!t[2],i=!!t[3],o=0,a;return r?i?(a=t[2]+t[3]+t[4],o=t[2].length+t[3].length):(a=t[2]+t[4],o=t[2].length):i?(a=t[3]+t[4],o=t[3].length):a=t[4],s==="file:"?o>=2&&(a=a.slice(2)):Ie(s)?a=t[4]:s?r&&(a=a.slice(2)):o>=2&&Ie(e.protocol)&&(a=t[4]),{protocol:s,slashes:r||Ie(s),slashesCount:o,rest:a}}function Pa(n,e){if(n==="")return e;for(var t=(e||"/").split("/").slice(0,-1).concat(n.split("/")),s=t.length,r=t[s-1],i=!1,o=0;s--;)t[s]==="."?t.splice(s,1):t[s]===".."?(t.splice(s,1),o++):o&&(s===0&&(i=!0),t.splice(s,1),o--);return i&&t.unshift(""),(r==="."||r==="..")&&t.push(""),t.join("/")}function Re(n,e,t){if(n=Zn(n),n=n.replace(jr,""),!(this instanceof Re))return new Re(n,e,t);var s,r,i,o,a,h,c=Qn.slice(),u=typeof e,l=this,d=0;for(u!=="object"&&u!=="string"&&(t=e,e=null),t&&typeof t!="function"&&(t=Wt.parse),e=Ar(e),r=Nr(n||"",e),s=!r.protocol&&!r.slashes,l.slashes=r.slashes||s&&e.slashes,l.protocol=r.protocol||e.protocol||"",n=r.rest,(r.protocol==="file:"&&(r.slashesCount!==2||Ca.test(n))||!r.slashes&&(r.protocol||r.slashesCount<2||!Ie(l.protocol)))&&(c[3]=[/(.*)/,"pathname"]);d<c.length;d++){if(o=c[d],typeof o=="function"){n=o(n,l);continue}i=o[0],h=o[1],i!==i?l[h]=n:typeof i=="string"?(a=i==="@"?n.lastIndexOf(i):n.indexOf(i),~a&&(typeof o[2]=="number"?(l[h]=n.slice(0,a),n=n.slice(a+o[2])):(l[h]=n.slice(a),n=n.slice(0,a)))):(a=i.exec(n))&&(l[h]=a[1],n=n.slice(0,a.index)),l[h]=l[h]||s&&o[3]&&e[h]||"",o[4]&&(l[h]=l[h].toLowerCase())}t&&(l.query=t(l.query)),s&&e.slashes&&l.pathname.charAt(0)!=="/"&&(l.pathname!==""||e.pathname!=="")&&(l.pathname=Pa(l.pathname,e.pathname)),l.pathname.charAt(0)!=="/"&&Ie(l.protocol)&&(l.pathname="/"+l.pathname),Tr(l.port,l.protocol)||(l.host=l.hostname,l.port=""),l.username=l.password="",l.auth&&(a=l.auth.indexOf(":"),~a?(l.username=l.auth.slice(0,a),l.username=encodeURIComponent(decodeURIComponent(l.username)),l.password=l.auth.slice(a+1),l.password=encodeURIComponent(decodeURIComponent(l.password))):l.username=encodeURIComponent(decodeURIComponent(l.auth)),l.auth=l.password?l.username+":"+l.password:l.username),l.origin=l.protocol!=="file:"&&Ie(l.protocol)&&l.host?l.protocol+"//"+l.host:"null",l.href=l.toString()}function Ma(n,e,t){var s=this;switch(n){case"query":typeof e=="string"&&e.length&&(e=(t||Wt.parse)(e)),s[n]=e;break;case"port":s[n]=e,Tr(e,s.protocol)?e&&(s.host=s.hostname+":"+e):(s.host=s.hostname,s[n]="");break;case"hostname":s[n]=e,s.port&&(e+=":"+s.port),s.host=e;break;case"host":s[n]=e,Ur.test(e)?(e=e.split(":"),s.port=e.pop(),s.hostname=e.join(":")):(s.hostname=e,s.port="");break;case"protocol":s.protocol=e.toLowerCase(),s.slashes=!t;break;case"pathname":case"hash":if(e){var r=n==="pathname"?"/":"#";s[n]=e.charAt(0)!==r?r+e:e}else s[n]=e;break;case"username":case"password":s[n]=encodeURIComponent(e);break;case"auth":var i=e.indexOf(":");~i?(s.username=e.slice(0,i),s.username=encodeURIComponent(decodeURIComponent(s.username)),s.password=e.slice(i+1),s.password=encodeURIComponent(decodeURIComponent(s.password))):s.username=encodeURIComponent(decodeURIComponent(e))}for(var o=0;o<Qn.length;o++){var a=Qn[o];a[4]&&(s[a[1]]=s[a[1]].toLowerCase())}return s.auth=s.password?s.username+":"+s.password:s.username,s.origin=s.protocol!=="file:"&&Ie(s.protocol)&&s.host?s.protocol+"//"+s.host:"null",s.href=s.toString(),s}function Ea(n){(!n||typeof n!="function")&&(n=Wt.stringify);var e,t=this,s=t.host,r=t.protocol;r&&r.charAt(r.length-1)!==":"&&(r+=":");var i=r+(t.protocol&&t.slashes||Ie(t.protocol)?"//":"");return t.username?(i+=t.username,t.password&&(i+=":"+t.password),i+="@"):t.password?(i+=":"+t.password,i+="@"):t.protocol!=="file:"&&Ie(t.protocol)&&!s&&t.pathname!=="/"&&(i+="@"),(s[s.length-1]===":"||Ur.test(t.hostname)&&!t.port)&&(s+=":"),i+=s+t.pathname,e=typeof t.query=="object"?n(t.query):t.query,e&&(i+=e.charAt(0)!=="?"?"?"+e:e),t.hash&&(i+=t.hash),i}Re.prototype={set:Ma,toString:Ea};Re.extractProtocol=Nr;Re.location=Ar;Re.trimLeft=Zn;Re.qs=Wt;Lr.exports=Re});var es=R(Qe=>{"use strict";var Ia=Qe&&Qe.__importDefault||function(n){return n&&n.__esModule?n:{default:n}};Object.defineProperty(Qe,"__esModule",{value:!0});Qe.URLExt=void 0;var Ra=Bt(),$t=Ia(xr()),Fr;(function(n){function e(c){if(typeof document!="undefined"&&document){let u=document.createElement("a");return u.href=c,u}return(0,$t.default)(c)}n.parse=e;function t(c){return(0,$t.default)(c).hostname}n.getHostName=t;function s(c){return c&&e(c).toString()}n.normalize=s;function r(...c){let u=(0,$t.default)(c[0],{}),l=u.protocol===""&&u.slashes;l&&(u=(0,$t.default)(c[0],"https:"+c[0]));let d=`${l?"":u.protocol}${u.slashes?"//":""}${u.auth}${u.auth?"@":""}${u.host}`,v=Ra.posix.join(`${d&&u.pathname[0]!=="/"?"/":""}${u.pathname}`,...c.slice(1));return`${d}${v==="."?"":v}`}n.join=r;function i(c){return r(...c.split("/").map(encodeURIComponent))}n.encodeParts=i;function o(c){let u=Object.keys(c).filter(l=>l.length>0);return u.length?"?"+u.map(l=>{let d=encodeURIComponent(String(c[l]));return l+(d?"="+d:"")}).join("&"):""}n.objectToQueryString=o;function a(c){return c.replace(/^\?/,"").split("&").reduce((u,l)=>{let[d,v]=l.split("=");return d.length>0&&(u[d]=decodeURIComponent(v||"")),u},{})}n.queryStringToObject=a;function h(c,u=!1){let{protocol:l}=e(c);return(!l||c.toLowerCase().indexOf(l)!==0)&&(u?c.indexOf("//")!==0:c.indexOf("/")!==0)}n.isLocal=h})(Fr||(Qe.URLExt=Fr={}))});var Kr=R((exports,module)=>{"use strict";var __importDefault=exports&&exports.__importDefault||function(n){return n&&n.__esModule?n:{default:n}};Object.defineProperty(exports,"__esModule",{value:!0});exports.PageConfig=void 0;var coreutils_1=Z(),minimist_1=__importDefault(Pr()),url_1=es(),PageConfig;(function(PageConfig){function getOption(name){if(configData)return configData[name]||getBodyData(name);configData=Object.create(null);let found=!1;if(typeof document!="undefined"&&document){let n=document.getElementById("jupyter-config-data");n&&(configData=JSON.parse(n.textContent||""),found=!0)}if(!found&&typeof process!="undefined"&&process.argv)try{let cli=(0,minimist_1.default)(process.argv.slice(2)),path=Bt(),fullPath="";"jupyter-config-data"in cli?fullPath=path.resolve(cli["jupyter-config-data"]):"JUPYTER_CONFIG_DATA"in process.env&&(fullPath=path.resolve(process.env.JUPYTER_CONFIG_DATA)),fullPath&&(configData=eval("require")(fullPath))}catch(n){console.error(n)}if(!coreutils_1.JSONExt.isObject(configData))configData=Object.create(null);else for(let n in configData)typeof configData[n]!="string"&&(configData[n]=JSON.stringify(configData[n]));return configData[name]||getBodyData(name)}PageConfig.getOption=getOption;function setOption(n,e){let t=getOption(n);return configData[n]=e,t}PageConfig.setOption=setOption;function getBaseUrl(){return url_1.URLExt.normalize(getOption("baseUrl")||"/")}PageConfig.getBaseUrl=getBaseUrl;function getTreeUrl(){return url_1.URLExt.join(getBaseUrl(),getOption("treeUrl"))}PageConfig.getTreeUrl=getTreeUrl;function getShareUrl(){return url_1.URLExt.normalize(getOption("shareUrl")||getBaseUrl())}PageConfig.getShareUrl=getShareUrl;function getTreeShareUrl(){return url_1.URLExt.normalize(url_1.URLExt.join(getShareUrl(),getOption("treeUrl")))}PageConfig.getTreeShareUrl=getTreeShareUrl;function getUrl(n){var e,t,s,r;let i=n.toShare?getShareUrl():getBaseUrl(),o=(e=n.mode)!==null&&e!==void 0?e:getOption("mode"),a=(t=n.workspace)!==null&&t!==void 0?t:getOption("workspace"),h=o==="single-document"?"doc":"lab";i=url_1.URLExt.join(i,h),a!==PageConfig.defaultWorkspace&&(i=url_1.URLExt.join(i,"workspaces",encodeURIComponent((s=getOption("workspace"))!==null&&s!==void 0?s:PageConfig.defaultWorkspace)));let c=(r=n.treePath)!==null&&r!==void 0?r:getOption("treePath");return c&&(i=url_1.URLExt.join(i,"tree",url_1.URLExt.encodeParts(c))),i}PageConfig.getUrl=getUrl,PageConfig.defaultWorkspace="default";function getWsUrl(n){let e=getOption("wsUrl");if(!e){if(n=n?url_1.URLExt.normalize(n):getBaseUrl(),n.indexOf("http")!==0)return"";e="ws"+n.slice(4)}return url_1.URLExt.normalize(e)}PageConfig.getWsUrl=getWsUrl;function getNBConvertURL({path:n,format:e,download:t}){let s=url_1.URLExt.encodeParts(n),r=url_1.URLExt.join(getBaseUrl(),"nbconvert",e,s);return t?r+"?download=true":r}PageConfig.getNBConvertURL=getNBConvertURL;function getToken(){return getOption("token")||getBodyData("jupyterApiToken")}PageConfig.getToken=getToken;function getNotebookVersion(){let n=getOption("notebookVersion");return n===""?[0,0,0]:JSON.parse(n)}PageConfig.getNotebookVersion=getNotebookVersion;let configData=null;function getBodyData(n){if(typeof document=="undefined"||!document.body)return"";let e=document.body.dataset[n];return typeof e=="undefined"?"":decodeURIComponent(e)}let Extension;(function(n){function e(r){try{let i=getOption(r);if(i)return JSON.parse(i)}catch(i){console.warn(`Unable to parse ${r}.`,i)}return[]}n.deferred=e("deferredExtensions"),n.disabled=e("disabledExtensions");function t(r){let i=r.indexOf(":"),o="";return i!==-1&&(o=r.slice(0,i)),n.deferred.some(a=>a===r||o&&a===o)}n.isDeferred=t;function s(r){let i=r.indexOf(":"),o="";return i!==-1&&(o=r.slice(0,i)),n.disabled.some(a=>a===r||o&&a===o)}n.isDisabled=s})(Extension=PageConfig.Extension||(PageConfig.Extension={}))})(PageConfig||(exports.PageConfig=PageConfig={}))});var Vr=R(Ht=>{"use strict";Object.defineProperty(Ht,"__esModule",{value:!0});Ht.PathExt=void 0;var Le=Bt(),zr;(function(n){function e(...l){let d=Le.posix.join(...l);return d==="."?"":u(d)}n.join=e;function t(...l){let d=Le.posix.join(...l);return d==="."?"":d}n.joinWithLeadingSlash=t;function s(l,d){return Le.posix.basename(l,d)}n.basename=s;function r(l){let d=u(Le.posix.dirname(l));return d==="."?"":d}n.dirname=r;function i(l){return Le.posix.extname(l)}n.extname=i;function o(l){return l===""?"":u(Le.posix.normalize(l))}n.normalize=o;function a(...l){return u(Le.posix.resolve(...l))}n.resolve=a;function h(l,d){return u(Le.posix.relative(l,d))}n.relative=h;function c(l){return l.length>0&&l.indexOf(".")!==0&&(l=`.${l}`),l}n.normalizeExtension=c;function u(l){return l.indexOf("/")===0&&(l=l.slice(1)),l}n.removeSlash=u})(zr||(Ht.PathExt=zr={}))});var Br=R(ts=>{"use strict";Object.defineProperty(ts,"__esModule",{value:!0});ts.signalToPromise=Oa;var ka=Z();function Oa(n,e){let t=new ka.PromiseDelegate;function s(){n.disconnect(r)}function r(i,o){s(),t.resolve([i,o])}return n.connect(r),(e!=null?e:0)>0&&setTimeout(()=>{s(),t.reject(`Signal not emitted within ${e} ms.`)},e),t.promise}});var $r=R(Jt=>{"use strict";Object.defineProperty(Jt,"__esModule",{value:!0});Jt.Text=void 0;var Wr;(function(n){let e=2>1;function t(o,a){if(e)return o;let h=o;for(let c=0;c+1<a.length&&c<o;c++){let u=a.charCodeAt(c);if(u>=55296&&u<=56319){let l=a.charCodeAt(c+1);l>=56320&&l<=57343&&(h--,c++)}}return h}n.jsIndexToCharIndex=t;function s(o,a){if(e)return o;let h=o;for(let c=0;c+1<a.length&&c<h;c++){let u=a.charCodeAt(c);if(u>=55296&&u<=56319){let l=a.charCodeAt(c+1);l>=56320&&l<=57343&&(h++,c++)}}return h}n.charIndexToJsIndex=s;function r(o,a=!1){return o.replace(/^(\w)|[\s-_:]+(\w)/g,function(h,c,u){return u?u.toUpperCase():a?c.toUpperCase():c.toLowerCase()})}n.camelCase=r;function i(o){return(o||"").toLowerCase().split(" ").map(a=>a.charAt(0).toUpperCase()+a.slice(1)).join(" ")}n.titleCase=i})(Wr||(Jt.Text=Wr={}))});var Jr=R(Gt=>{"use strict";Object.defineProperty(Gt,"__esModule",{value:!0});Gt.Time=void 0;var Da=[{name:"years",milliseconds:365*24*60*60*1e3},{name:"months",milliseconds:30*24*60*60*1e3},{name:"days",milliseconds:24*60*60*1e3},{name:"hours",milliseconds:60*60*1e3},{name:"minutes",milliseconds:60*1e3},{name:"seconds",milliseconds:1e3}],Hr;(function(n){function e(s,r="long"){let i=document.documentElement.lang||"en",o=new Intl.RelativeTimeFormat(i,{numeric:"auto",style:r}),a=new Date(s).getTime()-Date.now();for(let h of Da){let c=Math.ceil(a/h.milliseconds);if(c!==0)return o.format(c,h.name)}return o.format(0,"seconds")}n.formatHuman=e;function t(s){let r=document.documentElement.lang||"en";return new Intl.DateTimeFormat(r,{dateStyle:"short",timeStyle:"short"}).format(new Date(s))}n.format=t})(Hr||(Gt.Time=Hr={}))});var te=R(ae=>{"use strict";var qa=ae&&ae.__createBinding||(Object.create?function(n,e,t,s){s===void 0&&(s=t);var r=Object.getOwnPropertyDescriptor(e,t);(!r||("get"in r?!e.__esModule:r.writable||r.configurable))&&(r={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(n,s,r)}:function(n,e,t,s){s===void 0&&(s=t),n[s]=e[t]}),ke=ae&&ae.__exportStar||function(n,e){for(var t in n)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&qa(e,n,t)};Object.defineProperty(ae,"__esModule",{value:!0});ke(pr(),ae);ke(mr(),ae);ke(vr(),ae);ke(wr(),ae);ke(Kr(),ae);ke(Vr(),ae);ke(Br(),ae);ke($r(),ae);ke(Jr(),ae);ke(es(),ae)});var Ze=R(V=>{"use strict";Object.defineProperty(V,"__esModule",{value:!0});V.supportedKernelWebSocketProtocols=void 0;V.createMessage=ja;V.isStreamMsg=Ua;V.isDisplayDataMsg=Aa;V.isUpdateDisplayDataMsg=Na;V.isExecuteInputMsg=La;V.isExecuteResultMsg=xa;V.isErrorMsg=Fa;V.isStatusMsg=Ka;V.isClearOutputMsg=za;V.isDebugEventMsg=Va;V.isCommOpenMsg=Ba;V.isCommCloseMsg=Wa;V.isCommMsgMsg=$a;V.isInfoRequestMsg=Ha;V.isExecuteReplyMsg=Ja;V.isDebugRequestMsg=Ga;V.isDebugReplyMsg=Xa;V.isInputRequestMsg=Ya;V.isInputReplyMsg=Qa;var Ta=Z();function ja(n){var e,t,s,r,i,o;return{buffers:(e=n.buffers)!==null&&e!==void 0?e:[],channel:n.channel,content:n.content,header:{date:new Date().toISOString(),msg_id:(t=n.msgId)!==null&&t!==void 0?t:Ta.UUID.uuid4(),msg_type:n.msgType,session:n.session,username:(s=n.username)!==null&&s!==void 0?s:"",subshell_id:(r=n.subshellId)!==null&&r!==void 0?r:null,version:"5.2"},metadata:(i=n.metadata)!==null&&i!==void 0?i:{},parent_header:(o=n.parentHeader)!==null&&o!==void 0?o:{}}}function Ua(n){return n.header.msg_type==="stream"}function Aa(n){return n.header.msg_type==="display_data"}function Na(n){return n.header.msg_type==="update_display_data"}function La(n){return n.header.msg_type==="execute_input"}function xa(n){return n.header.msg_type==="execute_result"}function Fa(n){return n.header.msg_type==="error"}function Ka(n){return n.header.msg_type==="status"}function za(n){return n.header.msg_type==="clear_output"}function Va(n){return n.header.msg_type==="debug_event"}function Ba(n){return n.header.msg_type==="comm_open"}function Wa(n){return n.header.msg_type==="comm_close"}function $a(n){return n.header.msg_type==="comm_msg"}function Ha(n){return n.header.msg_type==="kernel_info_request"}function Ja(n){return n.header.msg_type==="execute_reply"}function Ga(n){return n.header.msg_type==="debug_request"}function Xa(n){return n.header.msg_type==="debug_reply"}function Ya(n){return n.header.msg_type==="input_request"}function Qa(n){return n.header.msg_type==="input_reply"}var Gr;(function(n){n.v1KernelWebsocketJupyterOrg="v1.kernel.websocket.jupyter.org"})(Gr||(V.supportedKernelWebSocketProtocols=Gr={}))});var Yr=R(Oe=>{"use strict";var Za=Oe&&Oe.__createBinding||(Object.create?function(n,e,t,s){s===void 0&&(s=t);var r=Object.getOwnPropertyDescriptor(e,t);(!r||("get"in r?!e.__esModule:r.writable||r.configurable))&&(r={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(n,s,r)}:function(n,e,t,s){s===void 0&&(s=t),n[s]=e[t]}),el=Oe&&Oe.__setModuleDefault||(Object.create?function(n,e){Object.defineProperty(n,"default",{enumerable:!0,value:e})}:function(n,e){n.default=e}),tl=Oe&&Oe.__importStar||function(n){if(n&&n.__esModule)return n;var e={};if(n!=null)for(var t in n)t!=="default"&&Object.prototype.hasOwnProperty.call(n,t)&&Za(e,n,t);return el(e,n),e};Object.defineProperty(Oe,"__esModule",{value:!0});Oe.serialize=nl;Oe.deserialize=sl;var Xr=tl(Ze());function nl(n,e=""){switch(e){case Xr.supportedKernelWebSocketProtocols.v1KernelWebsocketJupyterOrg:return et.serializeV1KernelWebsocketJupyterOrg(n);default:return et.serializeDefault(n)}}function sl(n,e=""){switch(e){case Xr.supportedKernelWebSocketProtocols.v1KernelWebsocketJupyterOrg:return et.deserializeV1KernelWebsocketJupyterOrg(n);default:return et.deserializeDefault(n)}}var et;(function(n){function e(a){let h,c=new DataView(a),u=Number(c.getBigUint64(0,!0)),l=[];for(let C=0;C<u;C++)l.push(Number(c.getBigUint64(8*(C+1),!0)));let d=new TextDecoder("utf8"),v=d.decode(a.slice(l[0],l[1])),m=JSON.parse(d.decode(a.slice(l[1],l[2]))),q=JSON.parse(d.decode(a.slice(l[2],l[3]))),I=JSON.parse(d.decode(a.slice(l[3],l[4]))),T=JSON.parse(d.decode(a.slice(l[4],l[5]))),A=[];for(let C=5;C<l.length-1;C++)A.push(new DataView(a.slice(l[C],l[C+1])));return h={channel:v,header:m,parent_header:q,metadata:I,content:T,buffers:A},h}n.deserializeV1KernelWebsocketJupyterOrg=e;function t(a){let h=JSON.stringify(a.header),c=a.parent_header==null?"{}":JSON.stringify(a.parent_header),u=JSON.stringify(a.metadata),l=JSON.stringify(a.content),d=a.buffers!==void 0?a.buffers:[],v=5+d.length+1,m=[];m.push(8*(1+v)),m.push(a.channel.length+m[m.length-1]);let q=new TextEncoder,I=q.encode(a.channel),T=q.encode(h),A=q.encode(c),C=q.encode(u),w=q.encode(l),k=new Uint8Array(I.length+T.length+A.length+C.length+w.length);k.set(I),k.set(T,I.length),k.set(A,I.length+T.length),k.set(C,I.length+T.length+A.length),k.set(w,I.length+T.length+A.length+C.length);for(let f of[T.length,A.length,C.length,w.length])m.push(f+m[m.length-1]);let N=0;for(let f of d){let y=f.byteLength;m.push(y+m[m.length-1]),N+=y}let j=new Uint8Array(8*(1+v)+k.byteLength+N),D=new ArrayBuffer(8),U=new DataView(D);U.setBigUint64(0,BigInt(v),!0),j.set(new Uint8Array(D),0);for(let f=0;f<m.length;f++)U.setBigUint64(0,BigInt(m[f]),!0),j.set(new Uint8Array(D),8*(f+1));j.set(k,m[0]);for(let f=0;f<d.length;f++){let y=d[f];j.set(new Uint8Array(ArrayBuffer.isView(y)?y.buffer:y),m[5+f])}return j.buffer}n.serializeV1KernelWebsocketJupyterOrg=t;function s(a){let h;return typeof a=="string"?h=JSON.parse(a):h=i(a),h}n.deserializeDefault=s;function r(a){var h;let c;return!((h=a.buffers)===null||h===void 0)&&h.length?c=o(a):c=JSON.stringify(a),c}n.serializeDefault=r;function i(a){let h=new DataView(a),c=h.getUint32(0),u=[];if(c<2)throw new Error("Invalid incoming Kernel Message");for(let v=1;v<=c;v++)u.push(h.getUint32(v*4));let l=new Uint8Array(a.slice(u[0],u[1])),d=JSON.parse(new TextDecoder("utf8").decode(l));d.buffers=[];for(let v=1;v<c;v++){let m=u[v],q=u[v+1]||a.byteLength;d.buffers.push(new DataView(a.slice(m,q)))}return d}function o(a){let h=[],c=[],u=new TextEncoder,l=[];a.buffers!==void 0&&(l=a.buffers,delete a.buffers);let d=u.encode(JSON.stringify(a));c.push(d.buffer);for(let I=0;I<l.length;I++){let T=l[I];c.push(ArrayBuffer.isView(T)?T.buffer:T)}let v=c.length;h.push(4*(v+1));for(let I=0;I+1<c.length;I++)h.push(h[h.length-1]+c[I].byteLength);let m=new Uint8Array(h[h.length-1]+c[c.length-1].byteLength),q=new DataView(m.buffer);q.setUint32(0,v);for(let I=0;I<h.length;I++)q.setUint32(4*(I+1),h[I]);for(let I=0;I<c.length;I++)m.set(new Uint8Array(c[I]),h[I]);return m.buffer}})(et||(et={}))});var Qr=R(ns=>{"use strict";Object.defineProperty(ns,"__esModule",{value:!0});ns.default=WebSocket});var he=R(Yt=>{"use strict";Object.defineProperty(Yt,"__esModule",{value:!0});Yt.ServerConnection=void 0;var xe=te(),Zr=Yr(),ss;typeof window=="undefined"?ss=Qr():ss=WebSocket;var rs;(function(n){function e(i){return Xt.makeSettings(i)}n.makeSettings=e;function t(i,o,a){return Xt.handleRequest(i,o,a)}n.makeRequest=t;class s extends Error{static async create(o){try{let a=await o.json(),{message:h,traceback:c}=a;return c&&console.error(c),new s(o,h!=null?h:s._defaultMessage(o),c!=null?c:"")}catch(a){return console.debug(a),new s(o)}}constructor(o,a=s._defaultMessage(o),h=""){super(a),this.response=o,this.traceback=h}static _defaultMessage(o){return`Invalid response: ${o.status} ${o.statusText}`}}n.ResponseError=s;class r extends TypeError{constructor(o){super(o.message),this.stack=o.stack}}n.NetworkError=r})(rs||(Yt.ServerConnection=rs={}));var Xt;(function(n){function e(r={}){var i;let o=xe.PageConfig.getBaseUrl(),a=xe.PageConfig.getWsUrl(),h=xe.URLExt.normalize(r.baseUrl)||o,c=r.wsUrl;!c&&h===o&&(c=a),!c&&h.indexOf("http")===0&&(c="ws"+h.slice(4)),c=c!=null?c:a;let u=xe.PageConfig.getOption("appendToken").toLowerCase(),l;return u===""?l=typeof window=="undefined"||typeof process!="undefined"&&((i=process==null?void 0:process.env)===null||i===void 0?void 0:i.JEST_WORKER_ID)!==void 0||xe.URLExt.getHostName(o)!==xe.URLExt.getHostName(c):l=u==="true",{init:{cache:"no-store",credentials:"same-origin"},fetch,Headers,Request,WebSocket:ss,token:xe.PageConfig.getToken(),appUrl:xe.PageConfig.getOption("appUrl"),appendToken:l,serializer:{serialize:Zr.serialize,deserialize:Zr.deserialize},...r,baseUrl:h,wsUrl:c}}n.makeSettings=e;function t(r,i,o){var a;if(r.indexOf(o.baseUrl)!==0)throw new Error("Can only be used for notebook server requests");((a=i.cache)!==null&&a!==void 0?a:o.init.cache)==="no-store"&&(r+=(/\?/.test(r)?"&":"?")+new Date().getTime());let c=new o.Request(r,{...o.init,...i}),u=!1;if(o.token&&(u=!0,c.headers.append("Authorization",`token ${o.token}`)),typeof document!="undefined"){let l=s("_xsrf");l!==void 0&&(u=!0,c.headers.append("X-XSRFToken",l))}return!c.headers.has("Content-Type")&&u&&c.headers.set("Content-Type","application/json"),o.fetch.call(null,c).catch(l=>{throw new rs.NetworkError(l)})}n.handleRequest=t;function s(r){let i="";try{i=document.cookie}catch{return}let o=i.match("\\b"+r+"=([^;]*)\\b");return o==null?void 0:o[1]}})(Xt||(Xt={}))});var $e=R(Qt=>{"use strict";Object.defineProperty(Qt,"__esModule",{value:!0});Qt.BaseManager=void 0;var ei=ee(),rl=he(),is=class{constructor(e){var t;this._isDisposed=!1,this._disposed=new ei.Signal(this),this.serverSettings=(t=e.serverSettings)!==null&&t!==void 0?t:rl.ServerConnection.makeSettings()}get disposed(){return this._disposed}get isDisposed(){return this._isDisposed}get isActive(){return!0}dispose(){this.isDisposed||(this._isDisposed=!0,this._disposed.emit(void 0),ei.Signal.clearData(this))}};Qt.BaseManager=is});var ni=R(Fe=>{"use strict";Object.defineProperty(Fe,"__esModule",{value:!0});Fe.ConfigWithDefaults=Fe.ConfigSection=Fe.ConfigSectionManager=void 0;var il=te(),tt=Ae(),ol="api/config",os=class{constructor(e){var t;this.serverSettings=(t=e.serverSettings)!==null&&t!==void 0?t:tt.ServerConnection.makeSettings()}async create(e){let t=new Zt({...e,serverSettings:this.serverSettings});return await t.load(),t}};Fe.ConfigSectionManager=os;var ti;(function(n){async function e(r){if(!t){let o=new Zt(r);return await o.load(),o}return await t.create(r)}n.create=e;let t;function s(r){if(t)throw new Error("ConfigSectionManager already set. If you would like to create a config section, use the `IConfigSectionManager` token in a plugin.");t=r}n._setConfigSectionManager=s})(ti||(Fe.ConfigSection=ti={}));var Zt=class{constructor(e){var t;this.serverSettings=(t=e.serverSettings)!==null&&t!==void 0?t:tt.ServerConnection.makeSettings(),this._name=e.name}get data(){return this._data}async load(){let e=await tt.ServerConnection.makeRequest(this._url,{},this.serverSettings);if(e.status!==200)throw await tt.ServerConnection.ResponseError.create(e);this._data=await e.json()}async update(e){this._data={...this._data,...e};let t={method:"PATCH",body:JSON.stringify(e)},s=await tt.ServerConnection.makeRequest(this._url,t,this.serverSettings);if(s.status!==200)throw await tt.ServerConnection.ResponseError.create(s);return this._data=await s.json(),this._data}get _url(){return il.URLExt.join(this.serverSettings.baseUrl,ol,encodeURIComponent(this._name))}},as=class{constructor(e){var t,s;this._className="",this._section=e.section,this._defaults=(t=e.defaults)!==null&&t!==void 0?t:{},this._className=(s=e.className)!==null&&s!==void 0?s:""}get(e){let t=this._classData();return e in t?t[e]:this._defaults[e]}set(e,t){let s={};if(s[e]=t,this._className){let r={};return r[this._className]=s,this._section.update(r)}else return this._section.update(s)}_classData(){let e=this._section.data;return this._className&&this._className in e?e[this._className]:e}};Fe.ConfigWithDefaults=as});var si=R(en=>{"use strict";Object.defineProperty(en,"__esModule",{value:!0});en.ConnectionStatus=void 0;var ls=class{constructor(){this.isConnected=!0}};en.ConnectionStatus=ls});var nn=R((tn,ri)=>{(function(n,e){typeof tn=="object"&&typeof ri!="undefined"?e(tn,ee()):typeof define=="function"&&define.amd?define(["exports","@lumino/signaling"],e):(n=typeof globalThis!="undefined"?globalThis:n||self,e(n.lumino_disposable={},n.lumino_signaling))})(tn,function(n,e){"use strict";class t{constructor(a){this._fn=a}get isDisposed(){return!this._fn}dispose(){if(!this._fn)return;let a=this._fn;this._fn=null,a()}}class s extends t{constructor(){super(...arguments),this._disposed=new e.Signal(this)}get disposed(){return this._disposed}dispose(){this.isDisposed||(super.dispose(),this._disposed.emit(void 0),e.Signal.clearData(this))}}class r{constructor(){this._isDisposed=!1,this._items=new Set}get isDisposed(){return this._isDisposed}dispose(){this._isDisposed||(this._isDisposed=!0,this._items.forEach(a=>{a.dispose()}),this._items.clear())}contains(a){return this._items.has(a)}add(a){this._items.add(a)}remove(a){this._items.delete(a)}clear(){this._items.clear()}}(function(o){function a(h){let c=new o;for(let u of h)c.add(u);return c}o.from=a})(r||(r={}));class i extends r{constructor(){super(...arguments),this._disposed=new e.Signal(this)}get disposed(){return this._disposed}dispose(){this.isDisposed||(super.dispose(),this._disposed.emit(void 0),e.Signal.clearData(this))}}(function(o){function a(h){let c=new o;for(let u of h)c.add(u);return c}o.from=a})(i||(i={})),n.DisposableDelegate=t,n.DisposableSet=r,n.ObservableDisposableDelegate=s,n.ObservableDisposableSet=i})});var lt=R(cs=>{"use strict";Object.defineProperty(cs,"__esModule",{value:!0});cs.validateProperty=al;function al(n,e,t,s=[]){if(!n.hasOwnProperty(e))throw Error(`Missing property '${e}'`);let r=n[e];if(t!==void 0){let i=!0;switch(t){case"array":i=Array.isArray(r);break;case"object":i=typeof r!="undefined";break;default:i=typeof r===t}if(!i)throw new Error(`Property '${e}' is not of type '${t}'`);if(s.length>0){let o=!0;switch(t){case"string":case"number":case"boolean":o=s.includes(r);break;default:o=s.findIndex(a=>a===r)>=0;break}if(!o)throw new Error(`Property '${e}' is not one of the valid values ${JSON.stringify(s)}`)}}}});var ii=R(sn=>{"use strict";Object.defineProperty(sn,"__esModule",{value:!0});sn.validateContentsModel=ll;sn.validateCheckpointModel=cl;var De=lt();function ll(n){(0,De.validateProperty)(n,"name","string"),(0,De.validateProperty)(n,"path","string"),(0,De.validateProperty)(n,"type","string"),(0,De.validateProperty)(n,"created","string"),(0,De.validateProperty)(n,"last_modified","string"),(0,De.validateProperty)(n,"mimetype","object"),(0,De.validateProperty)(n,"content","object"),(0,De.validateProperty)(n,"format","object")}function cl(n){(0,De.validateProperty)(n,"id","string"),(0,De.validateProperty)(n,"last_modified","string")}});var ds=R(ne=>{"use strict";var ul=ne&&ne.__createBinding||(Object.create?function(n,e,t,s){s===void 0&&(s=t);var r=Object.getOwnPropertyDescriptor(e,t);(!r||("get"in r?!e.__esModule:r.writable||r.configurable))&&(r={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(n,s,r)}:function(n,e,t,s){s===void 0&&(s=t),n[s]=e[t]}),hl=ne&&ne.__setModuleDefault||(Object.create?function(n,e){Object.defineProperty(n,"default",{enumerable:!0,value:e})}:function(n,e){n.default=e}),dl=ne&&ne.__importStar||function(n){if(n&&n.__esModule)return n;var e={};if(n!=null)for(var t in n)t!=="default"&&Object.prototype.hasOwnProperty.call(n,t)&&ul(e,n,t);return hl(e,n),e};Object.defineProperty(ne,"__esModule",{value:!0});ne.RestContentProvider=ne.ContentProviderRegistry=ne.Drive=ne.ContentsManager=ne.Contents=void 0;var de=te(),fl=nn(),ct=ee(),W=Ae(),Ne=dl(ii()),_l="api/contents",pl="files",oi;(function(n){function e(s){Ne.validateContentsModel(s)}n.validateContentsModel=e;function t(s){Ne.validateCheckpointModel(s)}n.validateCheckpointModel=t})(oi||(ne.Contents=oi={}));var us=class{constructor(e={}){var t,s;this._isDisposed=!1,this._additionalDrives=new Map,this._fileChanged=new ct.Signal(this);let r=this.serverSettings=(t=e.serverSettings)!==null&&t!==void 0?t:W.ServerConnection.makeSettings();this._defaultDrive=(s=e.defaultDrive)!==null&&s!==void 0?s:new rn({serverSettings:r}),this._defaultDrive.fileChanged.connect(this._onFileChanged,this)}get defaultDrive(){return this._defaultDrive}get fileChanged(){return this._fileChanged}get isDisposed(){return this._isDisposed}dispose(){this.isDisposed||(this._isDisposed=!0,ct.Signal.clearData(this))}addDrive(e){this._additionalDrives.set(e.name,e),e.fileChanged.connect(this._onFileChanged,this)}getSharedModelFactory(e,t){var s,r;let[i]=this._driveForPath(e),o=(s=i.contentProviderRegistry)===null||s===void 0?void 0:s.getProvider(t==null?void 0:t.contentProviderId);return o!=null&&o.sharedModelFactory?o.sharedModelFactory:(r=i.sharedModelFactory)!==null&&r!==void 0?r:null}localPath(e){let t=e.split("/"),s=t[0].split(":");return s.length===1||!this._additionalDrives.has(s[0])?de.PathExt.removeSlash(e):de.PathExt.join(s.slice(1).join(":"),...t.slice(1))}normalize(e){let t=e.split(":");return t.length===1?de.PathExt.normalize(e):`${t[0]}:${de.PathExt.normalize(t.slice(1).join(":"))}`}resolvePath(e,t){let s=this.driveName(e),r=this.localPath(e),i=de.PathExt.resolve("/",r,t);return s?`${s}:${i}`:i}driveName(e){let s=e.split("/")[0].split(":");return s.length===1?"":this._additionalDrives.has(s[0])?s[0]:""}get(e,t){let[s,r]=this._driveForPath(e);return s.get(r,t).then(i=>{let o=[];if(i.type==="directory"&&i.content){for(let a of i.content)o.push({...a,path:this._toGlobalPath(s,a.path)});return{...i,path:this._toGlobalPath(s,r),content:o,serverPath:i.path}}else return{...i,path:this._toGlobalPath(s,r),serverPath:i.path}})}getDownloadUrl(e){let[t,s]=this._driveForPath(e);return t.getDownloadUrl(s)}newUntitled(e={}){if(e.path){let t=this.normalize(e.path),[s,r]=this._driveForPath(t);return s.newUntitled({...e,path:r}).then(i=>({...i,path:de.PathExt.join(t,i.name),serverPath:i.path}))}else return this._defaultDrive.newUntitled(e)}delete(e){let[t,s]=this._driveForPath(e);return t.delete(s)}rename(e,t){let[s,r]=this._driveForPath(e),[i,o]=this._driveForPath(t);if(s!==i)throw Error("ContentsManager: renaming files must occur within a Drive");return s.rename(r,o).then(a=>({...a,path:this._toGlobalPath(s,o),serverPath:a.path}))}save(e,t={}){let s=this.normalize(e),[r,i]=this._driveForPath(e);return r.save(i,{...t,path:i}).then(o=>({...o,path:s,serverPath:o.path}))}copy(e,t){let[s,r]=this._driveForPath(e),[i,o]=this._driveForPath(t);if(s===i)return s.copy(r,o).then(a=>({...a,path:this._toGlobalPath(s,a.path),serverPath:a.path}));throw Error("Copying files between drives is not currently implemented")}createCheckpoint(e){let[t,s]=this._driveForPath(e);return t.createCheckpoint(s)}listCheckpoints(e){let[t,s]=this._driveForPath(e);return t.listCheckpoints(s)}restoreCheckpoint(e,t){let[s,r]=this._driveForPath(e);return s.restoreCheckpoint(r,t)}deleteCheckpoint(e,t){let[s,r]=this._driveForPath(e);return s.deleteCheckpoint(r,t)}_toGlobalPath(e,t){return e===this._defaultDrive?de.PathExt.removeSlash(t):`${e.name}:${de.PathExt.removeSlash(t)}`}_driveForPath(e){let t=this.driveName(e),s=this.localPath(e);return t?[this._additionalDrives.get(t),s]:[this._defaultDrive,s]}_onFileChanged(e,t){var s,r;if(e===this._defaultDrive)this._fileChanged.emit(t);else{let i=null,o=null;!((s=t.newValue)===null||s===void 0)&&s.path&&(i={...t.newValue,path:this._toGlobalPath(e,t.newValue.path)}),!((r=t.oldValue)===null||r===void 0)&&r.path&&(o={...t.oldValue,path:this._toGlobalPath(e,t.oldValue.path)}),this._fileChanged.emit({type:t.type,newValue:i,oldValue:o})}}};ne.ContentsManager=us;var rn=class{constructor(e={}){var t,s,r,i;this._isDisposed=!1,this._fileChanged=new ct.Signal(this),this.name=(t=e.name)!==null&&t!==void 0?t:"Default",this._apiEndpoint=(s=e.apiEndpoint)!==null&&s!==void 0?s:_l,this.serverSettings=(r=e.serverSettings)!==null&&r!==void 0?r:W.ServerConnection.makeSettings();let o=(i=e.defaultContentProvider)!==null&&i!==void 0?i:new an({apiEndpoint:this._apiEndpoint,serverSettings:this.serverSettings});this.contentProviderRegistry=new on({defaultProvider:o}),this.contentProviderRegistry.fileChanged.connect((a,h)=>{this._fileChanged.emit(h)})}get fileChanged(){return this._fileChanged}get isDisposed(){return this._isDisposed}dispose(){this.isDisposed||(this._isDisposed=!0,ct.Signal.clearData(this))}async get(e,t){return this.contentProviderRegistry.getProvider(t==null?void 0:t.contentProviderId).get(e,t)}getDownloadUrl(e){let t=this.serverSettings.baseUrl,s=de.URLExt.join(t,pl,de.URLExt.encodeParts(e)),r="";try{r=document.cookie}catch{}let i=r.match("\\b_xsrf=([^;]*)\\b");if(i){let o=new URL(s);o.searchParams.append("_xsrf",i[1]),s=o.toString()}return Promise.resolve(s)}async newUntitled(e={}){var t;let s="{}";e&&(e.ext&&(e.ext=hs.normalizeExtension(e.ext)),s=JSON.stringify(e));let r=this.serverSettings,i=this._getUrl((t=e.path)!==null&&t!==void 0?t:""),o={method:"POST",body:s},a=await W.ServerConnection.makeRequest(i,o,r);if(a.status!==201)throw await W.ServerConnection.ResponseError.create(a);let h=await a.json();return Ne.validateContentsModel(h),this._fileChanged.emit({type:"new",oldValue:null,newValue:h}),h}async delete(e){let t=this._getUrl(e),s=this.serverSettings,r={method:"DELETE"},i=await W.ServerConnection.makeRequest(t,r,s);if(i.status!==204)throw await W.ServerConnection.ResponseError.create(i);this._fileChanged.emit({type:"delete",oldValue:{path:e},newValue:null})}async rename(e,t){let s=this.serverSettings,r=this._getUrl(e),i={method:"PATCH",body:JSON.stringify({path:t})},o=await W.ServerConnection.makeRequest(r,i,s);if(o.status!==200)throw await W.ServerConnection.ResponseError.create(o);let a=await o.json();return Ne.validateContentsModel(a),this._fileChanged.emit({type:"rename",oldValue:{path:e},newValue:a}),a}async save(e,t={}){let r=await this.contentProviderRegistry.getProvider(t==null?void 0:t.contentProviderId).save(e,t);return this._fileChanged.emit({type:"save",oldValue:null,newValue:r}),r}async copy(e,t){let s=this.serverSettings,r=this._getUrl(t),i={method:"POST",body:JSON.stringify({copy_from:e})},o=await W.ServerConnection.makeRequest(r,i,s);if(o.status!==201)throw await W.ServerConnection.ResponseError.create(o);let a=await o.json();return Ne.validateContentsModel(a),this._fileChanged.emit({type:"new",oldValue:null,newValue:a}),a}async createCheckpoint(e){let t=this._getUrl(e,"checkpoints"),s={method:"POST"},r=await W.ServerConnection.makeRequest(t,s,this.serverSettings);if(r.status!==201)throw await W.ServerConnection.ResponseError.create(r);let i=await r.json();return Ne.validateCheckpointModel(i),i}async listCheckpoints(e){let t=this._getUrl(e,"checkpoints"),s=await W.ServerConnection.makeRequest(t,{},this.serverSettings);if(s.status!==200)throw await W.ServerConnection.ResponseError.create(s);let r=await s.json();if(!Array.isArray(r))throw new Error("Invalid Checkpoint list");for(let i=0;i<r.length;i++)Ne.validateCheckpointModel(r[i]);return r}async restoreCheckpoint(e,t){let s=this._getUrl(e,"checkpoints",t),r={method:"POST"},i=await W.ServerConnection.makeRequest(s,r,this.serverSettings);if(i.status!==204)throw await W.ServerConnection.ResponseError.create(i)}async deleteCheckpoint(e,t){let s=this._getUrl(e,"checkpoints",t),r={method:"DELETE"},i=await W.ServerConnection.makeRequest(s,r,this.serverSettings);if(i.status!==204)throw await W.ServerConnection.ResponseError.create(i)}_getUrl(...e){let t=e.map(r=>de.URLExt.encodeParts(r)),s=this.serverSettings.baseUrl;return de.URLExt.join(s,this._apiEndpoint,...t)}};ne.Drive=rn;var hs;(function(n){function e(t){return t.length>0&&t.indexOf(".")!==0&&(t=`.${t}`),t}n.normalizeExtension=e})(hs||(hs={}));var on=class{constructor(e){this._providers=new Map,this._fileChanged=new ct.Signal(this),this.register("default",e.defaultProvider),this._defaultProvider=e.defaultProvider}register(e,t){if(this._providers.has(e))throw Error(`Provider with ${e} identifier was already registered on this drive`);this._providers.set(e,t);let s=(r,i)=>{this._fileChanged.emit(i)};return t.fileChanged&&t.fileChanged.connect(s),new fl.DisposableDelegate(()=>{t.fileChanged&&t.fileChanged.disconnect(s),this._providers.has(e)&&this._providers.delete(e)})}getProvider(e){if(!e)return this._defaultProvider;let t=this._providers.get(e);if(!t)throw Error(`Provider ${e} is not registered`);return t}get fileChanged(){return this._fileChanged}};ne.ContentProviderRegistry=on;var an=class{constructor(e){this._options=e}async get(e,t){let s=this._getUrl(e);if(t){t.type==="notebook"&&delete t.format;let a=t.content?"1":"0",h=t.hash?"1":"0",c={...t,content:a,hash:h};s+=de.URLExt.objectToQueryString(c)}let r=this._options.serverSettings,i=await W.ServerConnection.makeRequest(s,{},r);if(i.status!==200)throw await W.ServerConnection.ResponseError.create(i);let o=await i.json();return Ne.validateContentsModel(o),o}async save(e,t={}){let s=this._options.serverSettings,r=this._getUrl(e),o={method:"PUT",body:new File([JSON.stringify(t)],"data.json",{type:"application/json"})},a=await W.ServerConnection.makeRequest(r,o,s);if(a.status!==200&&a.status!==201)throw await W.ServerConnection.ResponseError.create(a);let h=await a.json();return Ne.validateContentsModel(h),h}_getUrl(...e){let t=e.map(r=>de.URLExt.encodeParts(r)),s=this._options.serverSettings.baseUrl;return de.URLExt.join(s,this._options.apiEndpoint,...t)}};ne.RestContentProvider=an});var He=R((ln,ai)=>{(function(n,e){typeof ln=="object"&&typeof ai!="undefined"?e(ln,Z(),ee()):typeof define=="function"&&define.amd?define(["exports","@lumino/coreutils","@lumino/signaling"],e):(n=typeof globalThis!="undefined"?globalThis:n||self,e(n.lumino_polling={},n.lumino_coreutils,n.lumino_signaling))})(ln,function(n,e,t){"use strict";class s{constructor(c){var u;this._disposed=new t.Signal(this),this._lingered=0,this._tick=new e.PromiseDelegate,this._ticked=new t.Signal(this),this._factory=c.factory,this._linger=(u=c.linger)!==null&&u!==void 0?u:r.DEFAULT_LINGER,this._standby=c.standby||r.DEFAULT_STANDBY,this._state={...r.DEFAULT_STATE,timestamp:new Date().getTime()};let l=c.frequency||{},d=Math.max(l.interval||0,l.max||0,r.DEFAULT_FREQUENCY.max);this.frequency={...r.DEFAULT_FREQUENCY,...l,max:d},this.name=c.name||r.DEFAULT_NAME,(!("auto"in c)||c.auto)&&setTimeout(()=>this.start())}get disposed(){return this._disposed}get frequency(){return this._frequency}set frequency(c){if(this.isDisposed||e.JSONExt.deepEqual(c,this.frequency||{}))return;let{backoff:u,interval:l,max:d}=c;if(l=Math.round(l),d=Math.round(d),typeof u=="number"&&u<1)throw new Error("Poll backoff growth factor must be at least 1");if((l<0||l>d)&&l!==s.NEVER)throw new Error("Poll interval must be between 0 and max");if(d>s.MAX_INTERVAL&&d!==s.NEVER)throw new Error(`Max interval must be less than ${s.MAX_INTERVAL}`);this._frequency={backoff:u,interval:l,max:d}}get isDisposed(){return this.state.phase==="disposed"}get standby(){return this._standby}set standby(c){this.isDisposed||this.standby===c||(this._standby=c)}get state(){return this._state}get tick(){return this._tick.promise}get ticked(){return this._ticked}async*[Symbol.asyncIterator](){for(;!this.isDisposed;)yield this.state,await this.tick.catch(()=>{})}dispose(){this.isDisposed||(this._state={...r.DISPOSED_STATE,timestamp:new Date().getTime()},this._tick.promise.catch(c=>{}),this._tick.reject(new Error(`Poll (${this.name}) is disposed.`)),this._disposed.emit(void 0),t.Signal.clearData(this))}refresh(){return this.schedule({cancel:({phase:c})=>c==="refreshed",interval:s.IMMEDIATE,phase:"refreshed"})}async schedule(c={}){if(this.isDisposed||c.cancel&&c.cancel(this.state))return;let u=this._tick,l=new e.PromiseDelegate,d={interval:this.frequency.interval,payload:null,phase:"standby",timestamp:new Date().getTime(),...c};if(this._state=d,this._tick=l,clearTimeout(this._timeout),this._ticked.emit(this.state),u.resolve(this),await u.promise,d.interval===s.NEVER){this._timeout=void 0;return}let v=()=>{this.isDisposed||this.tick!==l.promise||this._execute()};this._timeout=setTimeout(v,d.interval)}start(){return this.schedule({cancel:({phase:c})=>c!=="constructed"&&c!=="standby"&&c!=="stopped",interval:s.IMMEDIATE,phase:"started"})}stop(){return this.schedule({cancel:({phase:c})=>c==="stopped",interval:s.NEVER,phase:"stopped"})}get hidden(){return r.hidden}_execute(){let c=typeof this.standby=="function"?this.standby():this.standby;if(c==="never"?c=!1:c==="when-hidden"&&(this.hidden?c=++this._lingered>this._linger:(this._lingered=0,c=!1)),c){this.schedule();return}let u=this.tick;this._factory(this.state).then(l=>{this.isDisposed||this.tick!==u||this.schedule({payload:l,phase:this.state.phase==="rejected"?"reconnected":"resolved"})}).catch(l=>{this.isDisposed||this.tick!==u||this.schedule({interval:r.sleep(this.frequency,this.state),payload:l,phase:"rejected"})})}}(function(h){h.IMMEDIATE=0,h.MAX_INTERVAL=2147483647,h.NEVER=1/0})(s||(s={}));var r;(function(h){h.DEFAULT_BACKOFF=3,h.DEFAULT_FREQUENCY={backoff:!0,interval:1e3,max:30*1e3},h.DEFAULT_LINGER=1,h.DEFAULT_NAME="unknown",h.DEFAULT_STANDBY="when-hidden",h.DEFAULT_STATE={interval:s.NEVER,payload:null,phase:"constructed",timestamp:new Date(0).getTime()},h.DISPOSED_STATE={interval:s.NEVER,payload:null,phase:"disposed",timestamp:new Date(0).getTime()};function c(l,d){let{backoff:v,interval:m,max:q}=l;if(m===s.NEVER)return m;let I=v===!0?h.DEFAULT_BACKOFF:v===!1?1:v,T=u(m,d.interval*I);return Math.min(q,T)}h.sleep=c,h.hidden=typeof document=="undefined"?!1:(document.addEventListener("visibilitychange",()=>{h.hidden=document.visibilityState==="hidden"}),document.addEventListener("pagehide",()=>{h.hidden=document.visibilityState==="hidden"}),document.visibilityState==="hidden");function u(l,d){return l=Math.ceil(l),d=Math.floor(d),Math.floor(Math.random()*(d-l+1))+l}})(r||(r={}));class i{constructor(c,u=500){this.args=void 0,this.payload=null,this.limit=u,this.poll=new s({auto:!1,factory:async()=>{let{args:l}=this;return this.args=void 0,c(...l)},frequency:{backoff:!1,interval:s.NEVER,max:s.NEVER},standby:"never"}),this.payload=new e.PromiseDelegate,this.poll.ticked.connect((l,d)=>{let{payload:v}=this;if(d.phase==="resolved"){this.payload=new e.PromiseDelegate,v.resolve(d.payload);return}if(d.phase==="rejected"||d.phase==="stopped"){this.payload=new e.PromiseDelegate,v.promise.catch(m=>{}),v.reject(d.payload);return}},this)}get isDisposed(){return this.payload===null}dispose(){this.isDisposed||(this.args=void 0,this.payload=null,this.poll.dispose())}async stop(){return this.poll.stop()}}class o extends i{invoke(...c){return this.args=c,this.poll.schedule({interval:this.limit,phase:"invoked"}),this.payload.promise}}class a extends i{constructor(c,u){super(c,typeof u=="number"?u:u&&u.limit),this._trailing=!1,typeof u!="number"&&u&&u.edge==="trailing"&&(this._trailing=!0),this._interval=this._trailing?this.limit:s.IMMEDIATE}invoke(...c){let u=this.poll.state.phase!=="invoked";return(u||this._trailing)&&(this.args=c),u&&this.poll.schedule({interval:this._interval,phase:"invoked"}),this.payload.promise}}n.Debouncer=o,n.Poll=s,n.RateLimiter=i,n.Throttler=a})});var _s=R(cn=>{"use strict";Object.defineProperty(cn,"__esModule",{value:!0});cn.EventManager=void 0;var li=te(),gl=He(),ci=ee(),ui=he(),hi="api/events",fs=class{constructor(e={}){var t,s;this._socket=null,this.serverSettings=(t=e.serverSettings)!==null&&t!==void 0?t:ui.ServerConnection.makeSettings(),this._poll=new gl.Poll({factory:()=>this._subscribe(),standby:(s=e.standby)!==null&&s!==void 0?s:"when-hidden"}),this._stream=new ci.Stream(this),this._poll.start()}get isDisposed(){return this._poll.isDisposed}get stream(){return this._stream}dispose(){if(this.isDisposed)return;this._poll.dispose();let e=this._socket;e&&(this._socket=null,e.onopen=()=>{},e.onerror=()=>{},e.onmessage=()=>{},e.onclose=()=>{},e.close()),ci.Signal.clearData(this),this._stream.stop()}async emit(e){let{serverSettings:t}=this,{baseUrl:s}=t,{makeRequest:r,ResponseError:i}=ui.ServerConnection,o=li.URLExt.join(s,hi),a={body:JSON.stringify(e),method:"POST"},h=await r(o,a,t);if(h.status!==204)throw new i(h)}_subscribe(){return new Promise((e,t)=>{if(this.isDisposed)return;let{appendToken:s,token:r,WebSocket:i,wsUrl:o}=this.serverSettings,a=li.URLExt.join(o,hi,"subscribe");s&&r!==""&&(a+=`?token=${encodeURIComponent(r)}`);let h=this._socket=new i(a),c=this._stream;h.onclose=()=>t(new Error("EventManager socket closed")),h.onmessage=u=>u.data&&c.emit(JSON.parse(u.data))})}};cn.EventManager=fs});var ps=R(Se=>{"use strict";var ml=Se&&Se.__createBinding||(Object.create?function(n,e,t,s){s===void 0&&(s=t);var r=Object.getOwnPropertyDescriptor(e,t);(!r||("get"in r?!e.__esModule:r.writable||r.configurable))&&(r={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(n,s,r)}:function(n,e,t,s){s===void 0&&(s=t),n[s]=e[t]}),vl=Se&&Se.__setModuleDefault||(Object.create?function(n,e){Object.defineProperty(n,"default",{enumerable:!0,value:e})}:function(n,e){n.default=e}),yl=Se&&Se.__importStar||function(n){if(n&&n.__esModule)return n;var e={};if(n!=null)for(var t in n)t!=="default"&&Object.prototype.hasOwnProperty.call(n,t)&&ml(e,n,t);return vl(e,n),e};Object.defineProperty(Se,"__esModule",{value:!0});Se.CommHandler=Se.CommsOverSubshells=void 0;var wl=Z(),Sl=nn(),un=yl(Ze()),nt;(function(n){n.Disabled="disabled",n.PerComm="perComm",n.PerCommTarget="perCommTarget"})(nt||(Se.CommsOverSubshells=nt={}));var hn=class n extends Sl.DisposableDelegate{constructor(e,t,s,r,i){super(r),this._subshellStarted=new wl.PromiseDelegate,this._subshellId=null,this._target="",this._id="",this._id=t,this._target=e,this._kernel=s,this._kernel.statusChanged.connect(()=>{this._kernel.status==="restarting"&&this._cleanSubshells()}),this.commsOverSubshells=i!=null?i:nt.PerCommTarget}get commId(){return this._id}get targetName(){return this._target}get subshellId(){return this._subshellId}get subshellStarted(){return this._subshellStarted.promise}get commsOverSubshells(){return this._commsOverSubshells}set commsOverSubshells(e){this._commsOverSubshells=e,this._commsOverSubshells===nt.Disabled?this._maybeCloseSubshell():this._maybeStartSubshell()}get onClose(){return this._onClose}set onClose(e){this._onClose=e}get onMsg(){return this._onMsg}set onMsg(e){this._onMsg=e}open(e,t,s=[]){if(this.isDisposed||this._kernel.isDisposed)throw new Error("Cannot open");let r=un.createMessage({msgType:"comm_open",channel:"shell",username:this._kernel.username,session:this._kernel.clientId,subshellId:this._subshellId||this._kernel.subshellId,content:{comm_id:this._id,target_name:this._target,data:e!=null?e:{}},metadata:t,buffers:s});return this._kernel.sendShellMessage(r,!1,!0)}send(e,t,s=[],r=!0){if(this.isDisposed||this._kernel.isDisposed)throw new Error("Cannot send");let i=un.createMessage({msgType:"comm_msg",channel:"shell",username:this._kernel.username,session:this._kernel.clientId,subshellId:this._subshellId||this._kernel.subshellId,content:{comm_id:this._id,data:e},metadata:t,buffers:s});return this._kernel.sendShellMessage(i,!1,r)}close(e,t,s=[]){if(this.isDisposed||this._kernel.isDisposed)throw new Error("Cannot close");let r=un.createMessage({msgType:"comm_close",channel:"shell",username:this._kernel.username,session:this._kernel.clientId,subshellId:this._subshellId||this._kernel.subshellId,content:{comm_id:this._id,data:e!=null?e:{}},metadata:t,buffers:s}),i=this._kernel.sendShellMessage(r,!1,!0),o=this._onClose;if(o){let a=un.createMessage({msgType:"comm_close",channel:"iopub",username:this._kernel.username,session:this._kernel.clientId,subshellId:this._subshellId||this._kernel.subshellId,content:{comm_id:this._id,data:e!=null?e:{}},metadata:t,buffers:s});o(a)}return this.dispose(),i}dispose(){this._maybeCloseSubshell(),super.dispose()}_cleanSubshells(){let e=this._kernel.id;n._commTargetSubShellsId.hasOwnProperty(e)&&delete n._commTargetSubShellsId[e]}async _maybeStartSubshell(){if(await this._kernel.info,!this._kernel.supportsSubshells)return;if(this._commsOverSubshells===nt.PerComm){let s=await this._kernel.requestCreateSubshell({}).done;this._subshellId=s.content.subshell_id,this._subshellStarted.resolve();return}let e=this._kernel.id;n._commTargetSubShellsId.hasOwnProperty(e)||(n._commTargetSubShellsId[e]={});let t=n._commTargetSubShellsId[e];t[this._target]?(this._subshellId=await t[this._target],this._subshellStarted.resolve()):(t[this._target]=this._kernel.requestCreateSubshell({}).done.then(s=>(this._subshellId=s.content.subshell_id,this._subshellId)),await t[this._target],this._subshellStarted.resolve())}_maybeCloseSubshell(){if(this._commsOverSubshells!==nt.PerComm){this._subshellId=null;return}this._subshellId&&this._kernel.status!=="dead"&&this._kernel.requestDeleteSubshell({subshell_id:this._subshellId},!0),this._subshellId=null}};Se.CommHandler=hn;hn._commTargetSubShellsId={}});var fi=R(di=>{"use strict";Object.defineProperty(di,"__esModule",{value:!0})});var dn=R(ut=>{"use strict";Object.defineProperty(ut,"__esModule",{value:!0});ut.validateMessage=Pl;ut.validateModel=pi;ut.validateModels=El;var Je=lt(),_i=["username","version","session","msg_id","msg_type"],bl={stream:{name:"string",text:"string"},display_data:{data:"object",metadata:"object"},execute_input:{code:"string",execution_count:"number"},execute_result:{execution_count:"number",data:"object",metadata:"object"},error:{ename:"string",evalue:"string",traceback:"object"},status:{execution_state:["string",["starting","idle","busy","restarting","dead"]]},clear_output:{wait:"boolean"},comm_open:{comm_id:"string",target_name:"string",data:"object"},comm_msg:{comm_id:"string",data:"object"},comm_close:{comm_id:"string"},shutdown_reply:{restart:"boolean"}};function Cl(n){for(let e=0;e<_i.length;e++)(0,Je.validateProperty)(n,_i[e],"string")}function Pl(n){(0,Je.validateProperty)(n,"metadata","object"),(0,Je.validateProperty)(n,"content","object"),(0,Je.validateProperty)(n,"channel","string"),Cl(n.header),n.channel==="iopub"&&Ml(n)}function Ml(n){if(n.channel==="iopub"){let e=bl[n.header.msg_type];if(e===void 0)return;let t=Object.keys(e),s=n.content;for(let r=0;r<t.length;r++){let i=e[t[r]];Array.isArray(i)||(i=[i]),(0,Je.validateProperty)(s,t[r],...i)}}}function pi(n){(0,Je.validateProperty)(n,"name","string"),(0,Je.validateProperty)(n,"id","string")}function El(n){if(!Array.isArray(n))throw new Error("Invalid kernel list");n.forEach(e=>pi(e))}});var _n=R(se=>{"use strict";Object.defineProperty(se,"__esModule",{value:!0});se.KernelAPIClient=se.KERNEL_SERVICE_URL=void 0;se.listRunning=gi;se.startNew=mi;se.restartKernel=vi;se.interruptKernel=yi;se.shutdownKernel=wi;se.getKernelModel=Si;var Y=he(),st=te(),fn=dn();se.KERNEL_SERVICE_URL="api/kernels";async function gi(n=Y.ServerConnection.makeSettings()){let e=st.URLExt.join(n.baseUrl,se.KERNEL_SERVICE_URL),t=await Y.ServerConnection.makeRequest(e,{},n);if(t.status!==200)throw await Y.ServerConnection.ResponseError.create(t);let s=await t.json();return(0,fn.validateModels)(s),s}async function mi(n={},e=Y.ServerConnection.makeSettings()){let t=st.URLExt.join(e.baseUrl,se.KERNEL_SERVICE_URL),s={method:"POST",body:JSON.stringify(n)},r=await Y.ServerConnection.makeRequest(t,s,e);if(r.status!==201)throw await Y.ServerConnection.ResponseError.create(r);let i=await r.json();return(0,fn.validateModel)(i),i}async function vi(n,e=Y.ServerConnection.makeSettings()){let t=st.URLExt.join(e.baseUrl,se.KERNEL_SERVICE_URL,encodeURIComponent(n),"restart"),s={method:"POST"},r=await Y.ServerConnection.makeRequest(t,s,e);if(r.status!==200)throw await Y.ServerConnection.ResponseError.create(r);let i=await r.json();(0,fn.validateModel)(i)}async function yi(n,e=Y.ServerConnection.makeSettings()){let t=st.URLExt.join(e.baseUrl,se.KERNEL_SERVICE_URL,encodeURIComponent(n),"interrupt"),s={method:"POST"},r=await Y.ServerConnection.makeRequest(t,s,e);if(r.status!==204)throw await Y.ServerConnection.ResponseError.create(r)}async function wi(n,e=Y.ServerConnection.makeSettings()){let t=st.URLExt.join(e.baseUrl,se.KERNEL_SERVICE_URL,encodeURIComponent(n)),s={method:"DELETE"},r=await Y.ServerConnection.makeRequest(t,s,e);if(r.status===404){let i=`The kernel "${n}" does not exist on the server`;console.warn(i)}else if(r.status!==204)throw await Y.ServerConnection.ResponseError.create(r)}async function Si(n,e=Y.ServerConnection.makeSettings()){let t=st.URLExt.join(e.baseUrl,se.KERNEL_SERVICE_URL,encodeURIComponent(n)),s=await Y.ServerConnection.makeRequest(t,{},e);if(s.status===404)return;if(s.status!==200)throw await Y.ServerConnection.ResponseError.create(s);let r=await s.json();return(0,fn.validateModel)(r),r}var gs=class{constructor(e={}){var t;this.serverSettings=(t=e.serverSettings)!==null&&t!==void 0?t:Y.ServerConnection.makeSettings()}async listRunning(){return gi(this.serverSettings)}async getModel(e){return Si(e,this.serverSettings)}async startNew(e={}){return mi(e,this.serverSettings)}async restart(e){return vi(e,this.serverSettings)}async interrupt(e){return yi(e,this.serverSettings)}async shutdown(e){return wi(e,this.serverSettings)}};se.KernelAPIClient=gs});var Ci=R(ve=>{"use strict";var Il=ve&&ve.__createBinding||(Object.create?function(n,e,t,s){s===void 0&&(s=t);var r=Object.getOwnPropertyDescriptor(e,t);(!r||("get"in r?!e.__esModule:r.writable||r.configurable))&&(r={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(n,s,r)}:function(n,e,t,s){s===void 0&&(s=t),n[s]=e[t]}),Rl=ve&&ve.__setModuleDefault||(Object.create?function(n,e){Object.defineProperty(n,"default",{enumerable:!0,value:e})}:function(n,e){n.default=e}),kl=ve&&ve.__importStar||function(n){if(n&&n.__esModule)return n;var e={};if(n!=null)for(var t in n)t!=="default"&&Object.prototype.hasOwnProperty.call(n,t)&&Il(e,n,t);return Rl(e,n),e};Object.defineProperty(ve,"__esModule",{value:!0});ve.KernelShellFutureHandler=ve.KernelControlFutureHandler=ve.KernelFutureHandler=void 0;var bi=Z(),Ol=nn(),Dl=kl(Ze()),ht=class extends Ol.DisposableDelegate{constructor(e,t,s,r,i){super(e),this._status=0,this._stdin=re.noOp,this._iopub=re.noOp,this._reply=re.noOp,this._done=new bi.PromiseDelegate,this._hooks=new re.HookList,this._disposeOnDone=!0,this._msg=t,s||this._setFlag(re.KernelFutureFlag.GotReply),this._disposeOnDone=r,this._kernel=i}get msg(){return this._msg}get done(){return this._done.promise}get onReply(){return this._reply}set onReply(e){this._reply=e}get onIOPub(){return this._iopub}set onIOPub(e){this._iopub=e}get onStdin(){return this._stdin}set onStdin(e){this._stdin=e}registerMessageHook(e){if(this.isDisposed)throw new Error("Kernel future is disposed");this._hooks.add(e)}removeMessageHook(e){this.isDisposed||this._hooks.remove(e)}sendInputReply(e,t){this._kernel.sendInputReply(e,t)}dispose(){this._stdin=re.noOp,this._iopub=re.noOp,this._reply=re.noOp,this._hooks=null,this._testFlag(re.KernelFutureFlag.IsDone)||(this._done.promise.catch(()=>{}),this._done.reject(new Error(`Canceled future for ${this.msg.header.msg_type} message before replies were done`))),super.dispose()}async handleMsg(e){switch(e.channel){case"control":case"shell":e.channel===this.msg.channel&&e.parent_header.msg_id===this.msg.header.msg_id&&await this._handleReply(e);break;case"stdin":await this._handleStdin(e);break;case"iopub":await this._handleIOPub(e);break;default:break}}async _handleReply(e){let t=this._reply;t&&await t(e),this._replyMsg=e,this._setFlag(re.KernelFutureFlag.GotReply),this._testFlag(re.KernelFutureFlag.GotIdle)&&this._handleDone()}async _handleStdin(e){this._kernel.hasPendingInput=!0;let t=this._stdin;t&&await t(e)}async _handleIOPub(e){let t=await this._hooks.process(e),s=this._iopub;t&&s&&await s(e),Dl.isStatusMsg(e)&&e.content.execution_state==="idle"&&(this._setFlag(re.KernelFutureFlag.GotIdle),this._testFlag(re.KernelFutureFlag.GotReply)&&this._handleDone())}_handleDone(){this._testFlag(re.KernelFutureFlag.IsDone)||(this._setFlag(re.KernelFutureFlag.IsDone),this._done.resolve(this._replyMsg),this._disposeOnDone&&this.dispose())}_testFlag(e){return(this._status&e)!==0}_setFlag(e){this._status|=e}};ve.KernelFutureHandler=ht;var ms=class extends ht{};ve.KernelControlFutureHandler=ms;var vs=class extends ht{};ve.KernelShellFutureHandler=vs;var re;(function(n){n.noOp=()=>{};let e=typeof requestAnimationFrame=="function"?requestAnimationFrame:setImmediate;class t{constructor(){this._hooks=[]}add(i){this.remove(i),this._hooks.push(i)}remove(i){let o=this._hooks.indexOf(i);o>=0&&(this._hooks[o]=null,this._scheduleCompact())}async process(i){await this._processing;let o=new bi.PromiseDelegate;this._processing=o.promise;let a;for(let h=this._hooks.length-1;h>=0;h--){let c=this._hooks[h];if(c!==null){try{a=await c(i)}catch(u){a=!0,console.error(u)}if(a===!1)return o.resolve(void 0),!1}}return o.resolve(void 0),!0}_scheduleCompact(){this._compactScheduled||(this._compactScheduled=!0,e(()=>{this._processing=this._processing.then(()=>{this._compactScheduled=!1,this._compact()})}))}_compact(){let i=0;for(let o=0,a=this._hooks.length;o<a;o++){let h=this._hooks[o];this._hooks[o]===null?i++:this._hooks[o-i]=h}this._hooks.length-=i}}n.HookList=t;let s;(function(r){r[r.GotReply=1]="GotReply",r[r.GotIdle=2]="GotIdle",r[r.IsDone=4]="IsDone",r[r.DisposeOnDone=8]="DisposeOnDone"})(s=n.KernelFutureFlag||(n.KernelFutureFlag={}))})(re||(re={}))});var Mi=R(pn=>{"use strict";Object.defineProperty(pn,"__esModule",{value:!0});pn.validateSpecModel=Pi;pn.validateSpecModels=ql;var Ge=lt();function Pi(n){let e=n.spec;if(!e)throw new Error("Invalid kernel spec");(0,Ge.validateProperty)(n,"name","string"),(0,Ge.validateProperty)(n,"resources","object"),(0,Ge.validateProperty)(e,"language","string"),(0,Ge.validateProperty)(e,"display_name","string"),(0,Ge.validateProperty)(e,"argv","array");let t=null;e.hasOwnProperty("metadata")&&((0,Ge.validateProperty)(e,"metadata","object"),t=e.metadata);let s=null;return e.hasOwnProperty("env")&&((0,Ge.validateProperty)(e,"env","object"),s=e.env),{name:n.name,resources:n.resources,language:e.language,display_name:e.display_name,argv:e.argv,metadata:t,env:s}}function ql(n){if(!n.hasOwnProperty("kernelspecs"))throw new Error("No kernelspecs found");let e=Object.keys(n.kernelspecs),t=Object.create(null),s=n.default;for(let r=0;r<e.length;r++){let i=n.kernelspecs[e[r]];try{t[e[r]]=Pi(i)}catch{console.warn(`Removing errant kernel spec: ${e[r]}`)}}if(e=Object.keys(t),!e.length)throw new Error("No valid kernelspecs found");return(!s||typeof s!="string"||!(s in t))&&(s=e[0],console.warn(`Default kernel not found, using '${e[0]}'`)),{default:s,kernelspecs:t}}});var ft=R(dt=>{"use strict";Object.defineProperty(dt,"__esModule",{value:!0});dt.KernelSpecAPIClient=void 0;dt.getSpecs=Ei;var gn=he(),Tl=Mi(),jl=te(),Ul="api/kernelspecs";async function Ei(n=gn.ServerConnection.makeSettings()){let e=jl.URLExt.join(n.baseUrl,Ul),t=await gn.ServerConnection.makeRequest(e,{},n);if(t.status!==200)throw await gn.ServerConnection.ResponseError.create(t);let s=await t.json();return(0,Tl.validateSpecModels)(s)}var ys=class{constructor(e={}){var t;this.serverSettings=(t=e.serverSettings)!==null&&t!==void 0?t:gn.ServerConnection.makeSettings()}async get(){return Ei(this.serverSettings)}};dt.KernelSpecAPIClient=ys});var Ss=R(qe=>{"use strict";var Al=qe&&qe.__createBinding||(Object.create?function(n,e,t,s){s===void 0&&(s=t);var r=Object.getOwnPropertyDescriptor(e,t);(!r||("get"in r?!e.__esModule:r.writable||r.configurable))&&(r={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(n,s,r)}:function(n,e,t,s){s===void 0&&(s=t),n[s]=e[t]}),Nl=qe&&qe.__setModuleDefault||(Object.create?function(n,e){Object.defineProperty(n,"default",{enumerable:!0,value:e})}:function(n,e){n.default=e}),Di=qe&&qe.__importStar||function(n){if(n&&n.__esModule)return n;var e={};if(n!=null)for(var t in n)t!=="default"&&Object.prototype.hasOwnProperty.call(n,t)&&Al(e,n,t);return Nl(e,n),e};Object.defineProperty(qe,"__esModule",{value:!0});qe.KernelConnection=void 0;var Ii=te(),Ke=Z(),ze=ee(),_t=Ae(),Ri=ps(),ie=Di(Ze()),ki=Ci(),Ll=Di(dn()),Oi=_n(),xl=ft(),Fl=te(),Kl=3e3,rt="_RESTARTING_",zl="",ws=class n{constructor(e){var t,s,r,i,o,a,h,c;this._createSocket=(u=!0)=>{this._errorIfDisposed(),this._clearSocket(),this._updateConnectionStatus("connecting");let l=this.serverSettings,d=Ii.URLExt.join(l.wsUrl,Oi.KERNEL_SERVICE_URL,encodeURIComponent(this._id)),v=d.replace(/^((?:\w+:)?\/\/)(?:[^@\/]+@)/,"$1");console.debug(`Starting WebSocket: ${v}`);let m=Ii.URLExt.join(d,"channels?session_id="+encodeURIComponent(this._clientId)),q=l.token;l.appendToken&&q!==""&&(m=m+`&token=${encodeURIComponent(q)}`);let I=u?this._supportedProtocols:[];this._ws=new l.WebSocket(m,I),this._ws.binaryType="arraybuffer";let T=!1,A=async w=>{var k,N;if(!this._isDisposed){this._reason="",this._model=void 0;try{let j=await this._kernelAPIClient.getModel(this._id);this._model=j,(j==null?void 0:j.execution_state)==="dead"?this._updateStatus("dead"):this._onWSClose(w)}catch(j){if(j instanceof _t.ServerConnection.NetworkError||((k=j.response)===null||k===void 0?void 0:k.status)===503||((N=j.response)===null||N===void 0?void 0:N.status)===424){let D=be.getRandomIntInclusive(10,30)*1e3;setTimeout(A,D,w)}else this._reason="Kernel died unexpectedly",this._updateStatus("dead")}}},C=async w=>{T||(T=!0,await A(w))};this._ws.onmessage=this._onWSMessage,this._ws.onopen=this._onWSOpen,this._ws.onclose=C,this._ws.onerror=C},this._onWSOpen=u=>{if(this._ws.protocol!==""&&!this._supportedProtocols.includes(this._ws.protocol))throw console.log("Server selected unknown kernel wire protocol:",this._ws.protocol),this._updateStatus("dead"),new Error(`Unknown kernel wire protocol: ${this._ws.protocol}`);this._selectedProtocol=this._ws.protocol,this._ws.onclose=this._onWSClose,this._ws.onerror=this._onWSClose,this._updateConnectionStatus("connected")},this._onWSMessage=u=>{let l;try{l=this.serverSettings.serializer.deserialize(u.data,this._ws.protocol),Ll.validateMessage(l)}catch(d){throw d.message=`Kernel message validation error: ${d.message}`,d}this._kernelSession=l.header.session,this._msgChain=this._msgChain.then(()=>this._handleMessage(l)).catch(d=>{d.message.startsWith("Canceled future for ")&&console.error(d)}),this._anyMessage.emit({msg:l,direction:"recv"})},this._onWSClose=u=>{this.isDisposed||this._reconnect()},this._id="",this._name="",this._status="unknown",this._connectionStatus="connecting",this._kernelSession="",this._isDisposed=!1,this._ws=null,this._username="",this._reconnectLimit=7,this._reconnectAttempt=0,this._reconnectTimeout=null,this._supportedProtocols=Object.values(ie.supportedKernelWebSocketProtocols),this._selectedProtocol="",this._commsOverSubshells=_t.CommsOverSubshells.PerCommTarget,this._futures=new Map,this._comms=new Map,this._targetRegistry=Object.create(null),this._info=new Ke.PromiseDelegate,this._pendingMessages=[],this._statusChanged=new ze.Signal(this),this._connectionStatusChanged=new ze.Signal(this),this._disposed=new ze.Signal(this),this._iopubMessage=new ze.Signal(this),this._anyMessage=new ze.Signal(this),this._pendingInput=new ze.Signal(this),this._unhandledMessage=new ze.Signal(this),this._displayIdToParentIds=new Map,this._msgIdToDisplayIds=new Map,this._msgChain=Promise.resolve(),this._hasPendingInput=!1,this._reason="",this._noOp=()=>{},this._supportsSubshells=!1,this._name=e.model.name,this._id=e.model.id,this.serverSettings=(t=e.serverSettings)!==null&&t!==void 0?t:_t.ServerConnection.makeSettings(),this._kernelAPIClient=(s=e.kernelAPIClient)!==null&&s!==void 0?s:new Oi.KernelAPIClient({serverSettings:this.serverSettings}),this._kernelSpecAPIClient=(r=e.kernelSpecAPIClient)!==null&&r!==void 0?r:new xl.KernelSpecAPIClient({serverSettings:this.serverSettings}),this._clientId=(i=e.clientId)!==null&&i!==void 0?i:Ke.UUID.uuid4(),this._username=(o=e.username)!==null&&o!==void 0?o:"",this.handleComms=(a=e.handleComms)!==null&&a!==void 0?a:!0,this._commsOverSubshells=(h=e.commsOverSubshells)!==null&&h!==void 0?h:_t.CommsOverSubshells.PerCommTarget,this._subshellId=(c=e.subshellId)!==null&&c!==void 0?c:null,this._createSocket()}get disposed(){return this._disposed}get commsOverSubshells(){return this._commsOverSubshells}set commsOverSubshells(e){this._commsOverSubshells=e;for(let[t,s]of this._comms)s.commsOverSubshells=e}get statusChanged(){return this._statusChanged}get connectionStatusChanged(){return this._connectionStatusChanged}get iopubMessage(){return this._iopubMessage}get unhandledMessage(){return this._unhandledMessage}get model(){return this._model||{id:this.id,name:this.name,reason:this._reason}}get anyMessage(){return this._anyMessage}get pendingInput(){return this._pendingInput}get id(){return this._id}get name(){return this._name}get username(){return this._username}get clientId(){return this._clientId}get subshellId(){return this._subshellId}set subshellId(e){this._subshellId=e}get status(){return this._status}get connectionStatus(){return this._connectionStatus}get isDisposed(){return this._isDisposed}get info(){return this._info.promise}get spec(){return this._specPromise?this._specPromise:(this._specPromise=this._kernelSpecAPIClient.get().then(e=>e.kernelspecs[this._name]),this._specPromise)}get supportsSubshells(){return this._supportsSubshells}clone(e={}){return new n({model:this.model,username:this.username,serverSettings:this.serverSettings,handleComms:!1,kernelAPIClient:this._kernelAPIClient,commsOverSubshells:_t.CommsOverSubshells.Disabled,...e})}dispose(){if(this.isDisposed)return;let e=()=>{this._isDisposed=!0,this._disposed.emit(),this._updateConnectionStatus("disconnected"),this._clearKernelState(),this._pendingMessages=[],this._clearSocket(),ze.Signal.clearData(this)};if(this._subshellId!==null){let t=this.requestDeleteSubshell({subshell_id:this._subshellId},!0);t.onReply=s=>{e()}}else e()}sendShellMessage(e,t=!1,s=!0){return this._sendKernelShellControl(ki.KernelShellFutureHandler,e,t,s)}sendControlMessage(e,t=!1,s=!0){return this._sendKernelShellControl(ki.KernelControlFutureHandler,e,t,s)}_sendKernelShellControl(e,t,s=!1,r=!0){this._sendMessage(t),this._anyMessage.emit({msg:t,direction:"send"});let i=new e(()=>{let o=t.header.msg_id;this._futures.delete(o);let a=this._msgIdToDisplayIds.get(o);a&&(a.forEach(h=>{let c=this._displayIdToParentIds.get(h);if(c){let u=c.indexOf(o);if(u===-1)return;c.length===1?this._displayIdToParentIds.delete(h):(c.splice(u,1),this._displayIdToParentIds.set(h,c))}}),this._msgIdToDisplayIds.delete(o))},t,s,r,this);return this._futures.set(t.header.msg_id,i),i}_sendMessage(e,t=!0){if(this.status==="dead")throw new Error("Kernel is dead");if((this._kernelSession===zl||this._kernelSession===rt)&&ie.isInfoRequestMsg(e))if(this.connectionStatus==="connected"){this._ws.send(this.serverSettings.serializer.serialize(e,this._ws.protocol));return}else throw new Error("Could not send message: status is not connected");if(t&&this._pendingMessages.length>0){this._pendingMessages.push(e);return}if(this.connectionStatus==="connected"&&this._kernelSession!==rt)this._ws.send(this.serverSettings.serializer.serialize(e,this._ws.protocol));else if(t)this._pendingMessages.push(e);else throw new Error("Could not send message")}async interrupt(){if(this.hasPendingInput=!1,this.status==="dead")throw new Error("Kernel is dead");return this._kernelAPIClient.interrupt(this.id)}async restart(){if(this.status==="dead")throw new Error("Kernel is dead");this._updateStatus("restarting"),this._clearKernelState(),this._kernelSession=rt,await this._kernelAPIClient.restart(this.id),await this.reconnect(),this.hasPendingInput=!1}reconnect(){this._errorIfDisposed();let e=new Ke.PromiseDelegate,t=(s,r)=>{r==="connected"?(e.resolve(),this.connectionStatusChanged.disconnect(t,this)):r==="disconnected"&&(e.reject(new Error("Kernel connection disconnected")),this.connectionStatusChanged.disconnect(t,this))};return this.connectionStatusChanged.connect(t,this),this._reconnectAttempt=0,this._reconnect(),e.promise}async shutdown(){this.status!=="dead"&&await this._kernelAPIClient.shutdown(this.id),this.handleShutdown()}handleShutdown(){this._updateStatus("dead"),this.dispose()}async requestKernelInfo(){let e=ie.createMessage({msgType:"kernel_info_request",channel:"shell",username:this._username,session:this._clientId,subshellId:this._subshellId,content:{}}),t;try{t=await be.handleShellMessage(this,e)}catch(r){if(this.isDisposed)return;throw r}if(this._errorIfDisposed(),!t)return;if(t.content.status===void 0&&(t.content.status="ok"),t.content.status!=="ok")return this._info.reject("Kernel info reply errored"),t;this._info.resolve(t.content),this._kernelSession=t.header.session;let s=t.content.supported_features;return this._supportsSubshells=s!==void 0&&s.includes("kernel subshells"),t}requestComplete(e){let t=ie.createMessage({msgType:"complete_request",channel:"shell",username:this._username,session:this._clientId,subshellId:this._subshellId,content:e});return be.handleShellMessage(this,t)}requestInspect(e){let t=ie.createMessage({msgType:"inspect_request",channel:"shell",username:this._username,session:this._clientId,subshellId:this._subshellId,content:e});return be.handleShellMessage(this,t)}requestHistory(e){let t=ie.createMessage({msgType:"history_request",channel:"shell",username:this._username,session:this._clientId,subshellId:this._subshellId,content:e});return be.handleShellMessage(this,t)}requestExecute(e,t=!0,s){let r={silent:!1,store_history:!0,user_expressions:{},allow_stdin:!0,stop_on_error:!1},i=ie.createMessage({msgType:"execute_request",channel:"shell",username:this._username,session:this._clientId,subshellId:this._subshellId,content:{...r,...e},metadata:s});return this.sendShellMessage(i,!0,t)}requestDebug(e,t=!0){let s=ie.createMessage({msgType:"debug_request",channel:"control",username:this._username,session:this._clientId,content:e});return this.sendControlMessage(s,!0,t)}requestCreateSubshell(e,t=!0){if(!this.supportsSubshells)throw new Error("Kernel subshells are not supported");let s=ie.createMessage({msgType:"create_subshell_request",channel:"control",username:this._username,session:this._clientId,content:e});return this.sendControlMessage(s,!0,t)}requestDeleteSubshell(e,t=!0){if(!this.supportsSubshells)throw new Error("Kernel subshells are not supported");let s=ie.createMessage({msgType:"delete_subshell_request",channel:"control",username:this._username,session:this._clientId,content:e});return this.sendControlMessage(s,!0,t)}requestListSubshell(e,t=!0){if(!this.supportsSubshells)throw new Error("Kernel subshells are not supported");let s=ie.createMessage({msgType:"list_subshell_request",channel:"control",username:this._username,session:this._clientId,content:e});return this.sendControlMessage(s,!0,t)}requestIsComplete(e){let t=ie.createMessage({msgType:"is_complete_request",channel:"shell",username:this._username,session:this._clientId,subshellId:this._subshellId,content:e});return be.handleShellMessage(this,t)}requestCommInfo(e){let t=ie.createMessage({msgType:"comm_info_request",channel:"shell",username:this._username,session:this._clientId,subshellId:this._subshellId,content:e});return be.handleShellMessage(this,t)}sendInputReply(e,t){let s=ie.createMessage({msgType:"input_reply",channel:"stdin",username:this._username,session:this._clientId,content:e});s.parent_header=t,this._sendMessage(s),this._anyMessage.emit({msg:s,direction:"send"}),this.hasPendingInput=!1}createComm(e,t=Ke.UUID.uuid4()){if(!this.handleComms)throw new Error("Comms are disabled on this kernel connection");if(this._comms.has(t))throw new Error("Comm is already created");let s=new Ri.CommHandler(e,t,this,()=>{this._unregisterComm(t)},this._commsOverSubshells);return this._comms.set(t,s),s}hasComm(e){return this._comms.has(e)}registerCommTarget(e,t){this.handleComms&&(this._targetRegistry[e]=t)}removeCommTarget(e,t){this.handleComms&&!this.isDisposed&&this._targetRegistry[e]===t&&delete this._targetRegistry[e]}registerMessageHook(e,t){var s;let r=(s=this._futures)===null||s===void 0?void 0:s.get(e);r&&r.registerMessageHook(t)}removeMessageHook(e,t){var s;let r=(s=this._futures)===null||s===void 0?void 0:s.get(e);r&&r.removeMessageHook(t)}removeInputGuard(){this.hasPendingInput=!1}async _handleDisplayId(e,t){var s,r;let i=t.parent_header.msg_id,o=this._displayIdToParentIds.get(e);if(o){let h={header:Ke.JSONExt.deepCopy(t.header),parent_header:Ke.JSONExt.deepCopy(t.parent_header),metadata:Ke.JSONExt.deepCopy(t.metadata),content:Ke.JSONExt.deepCopy(t.content),channel:t.channel,buffers:t.buffers?t.buffers.slice():[]};h.header.msg_type="update_display_data",await Promise.all(o.map(async c=>{let u=this._futures&&this._futures.get(c);u&&await u.handleMsg(h)}))}if(t.header.msg_type==="update_display_data")return!0;o=(s=this._displayIdToParentIds.get(e))!==null&&s!==void 0?s:[],o.indexOf(i)===-1&&o.push(i),this._displayIdToParentIds.set(e,o);let a=(r=this._msgIdToDisplayIds.get(i))!==null&&r!==void 0?r:[];return a.indexOf(i)===-1&&a.push(i),this._msgIdToDisplayIds.set(i,a),!1}_clearSocket(){this._ws!==null&&(this._ws.onopen=this._noOp,this._ws.onclose=this._noOp,this._ws.onerror=this._noOp,this._ws.onmessage=this._noOp,this._ws.close(),this._ws=null)}_updateStatus(e){this._status===e||this._status==="dead"||(this._status=e,be.logKernelStatus(this),this._statusChanged.emit(e),e==="dead"&&this.dispose())}_sendPending(){for(;this.connectionStatus==="connected"&&this._kernelSession!==rt&&this._pendingMessages.length>0;)this._sendMessage(this._pendingMessages[0],!1),this._pendingMessages.shift()}_clearKernelState(){this._kernelSession="",this._pendingMessages=[],this._futures.forEach(e=>{e.dispose()}),this._comms.forEach(e=>{e.dispose()}),this._msgChain=Promise.resolve(),this._futures=new Map,this._comms=new Map,this._displayIdToParentIds.clear(),this._msgIdToDisplayIds.clear()}_assertCurrentMessage(e){if(this._errorIfDisposed(),e.header.session!==this._kernelSession)throw new Error(`Canceling handling of old message: ${e.header.msg_type}`)}async _handleCommOpen(e){this._assertCurrentMessage(e);let t=e.content,s=new Ri.CommHandler(t.target_name,t.comm_id,this,()=>{this._unregisterComm(t.comm_id)},this.commsOverSubshells);this._comms.set(t.comm_id,s);try{await(await be.loadObject(t.target_name,t.target_module,this._targetRegistry))(s,e)}catch(r){throw s.close(),console.error("Exception opening new comm"),r}}async _handleCommClose(e){this._assertCurrentMessage(e);let t=e.content,s=this._comms.get(t.comm_id);if(!s){console.error("Comm not found for comm id "+t.comm_id);return}this._unregisterComm(s.commId);let r=s.onClose;r&&await r(e),s.dispose()}async _handleCommMsg(e){this._assertCurrentMessage(e);let t=e.content,s=this._comms.get(t.comm_id);if(!s)return;let r=s.onMsg;r&&await r(e)}_unregisterComm(e){this._comms.delete(e)}_updateConnectionStatus(e){if(this._connectionStatus!==e){if(this._connectionStatus=e,e!=="connecting"&&(this._reconnectAttempt=0,clearTimeout(this._reconnectTimeout)),this.status!=="dead")if(e==="connected"){let t=this._kernelSession===rt,s=this.requestKernelInfo(),r=!1,i=()=>{r||(r=!0,t&&this._kernelSession===rt&&(this._kernelSession=""),clearTimeout(o),this._pendingMessages.length>0&&this._sendPending())};s.then(i);let o=setTimeout(i,Kl)}else this._updateStatus("unknown");this._connectionStatusChanged.emit(e)}}async _handleMessage(e){var t,s;let r=!1;if(e.parent_header&&e.channel==="iopub"&&(ie.isDisplayDataMsg(e)||ie.isUpdateDisplayDataMsg(e)||ie.isExecuteResultMsg(e))){let o=((t=e.content.transient)!==null&&t!==void 0?t:{}).display_id;o&&(r=await this._handleDisplayId(o,e),this._assertCurrentMessage(e))}if(!r&&e.parent_header){let i=e.parent_header,o=(s=this._futures)===null||s===void 0?void 0:s.get(i.msg_id);if(o)await o.handleMsg(e),this._assertCurrentMessage(e);else{let a=i.session===this.clientId;e.channel!=="iopub"&&a&&this._unhandledMessage.emit(e)}}if(e.channel==="iopub"){switch(e.header.msg_type){case"status":{let i=Fl.PageConfig.getOption("untracked_message_types");if(JSON.parse(i||"[]").includes(e.parent_header.msg_type))break;let a=e.content.execution_state;a==="restarting"&&Promise.resolve().then(async()=>{this._updateStatus("autorestarting"),this._clearKernelState(),await this.reconnect()}),this._updateStatus(a);break}case"comm_open":this.handleComms&&await this._handleCommOpen(e);break;case"comm_msg":this.handleComms&&await this._handleCommMsg(e);break;case"comm_close":this.handleComms&&await this._handleCommClose(e);break;default:break}this.isDisposed||(this._assertCurrentMessage(e),this._iopubMessage.emit(e))}}_reconnect(){if(this._errorIfDisposed(),clearTimeout(this._reconnectTimeout),this._reconnectAttempt<this._reconnectLimit){this._updateConnectionStatus("connecting");let e=be.getRandomIntInclusive(0,1e3*(Math.pow(2,this._reconnectAttempt)-1));console.warn(`Connection lost, reconnecting in ${Math.floor(e/1e3)} seconds.`);let t=this._selectedProtocol!=="";this._reconnectTimeout=setTimeout(this._createSocket,e,t),this._reconnectAttempt+=1}else this._updateConnectionStatus("disconnected");this._clearSocket()}_errorIfDisposed(){if(this.isDisposed)throw new Error("Kernel connection is disposed")}get hasPendingInput(){return this._hasPendingInput}set hasPendingInput(e){this._hasPendingInput=e,this._pendingInput.emit(e)}};qe.KernelConnection=ws;var be;(function(n){function e(i){switch(i.status){case"idle":case"busy":case"unknown":return;default:console.debug(`Kernel: ${i.status} (${i.id})`);break}}n.logKernelStatus=e;async function t(i,o){return i.sendShellMessage(o,!0).done}n.handleShellMessage=t;function s(i,o,a){return new Promise((h,c)=>{if(o){if(typeof requirejs=="undefined")throw new Error("requirejs not found");requirejs([o],u=>{if(u[i]===void 0){let l=`Object '${i}' not found in module '${o}'`;c(new Error(l))}else h(u[i])},c)}else a!=null&&a[i]?h(a[i]):c(new Error(`Object '${i}' not found in registry`))})}n.loadObject=s;function r(i,o){return i=Math.ceil(i),o=Math.floor(o),Math.floor(Math.random()*(o-i+1))+i}n.getRandomIntInclusive=r})(be||(be={}))});var ji=R(gt=>{"use strict";Object.defineProperty(gt,"__esModule",{value:!0});gt.KernelManager=void 0;var Vl=He(),qi=ee(),Ti=Ae(),Bl=$e(),Wl=_n(),$l=Ss(),Hl=ft(),pt=class extends Bl.BaseManager{constructor(e={}){var t,s,r;super(e),this._commsOverSubshells=Ti.CommsOverSubshells.PerCommTarget,this._isReady=!1,this._kernelConnections=new Set,this._models=new Map,this._runningChanged=new qi.Signal(this),this._connectionFailure=new qi.Signal(this),this._kernelAPIClient=(t=e.kernelAPIClient)!==null&&t!==void 0?t:new Wl.KernelAPIClient({serverSettings:this.serverSettings}),this._kernelSpecAPIClient=(s=e.kernelSpecAPIClient)!==null&&s!==void 0?s:new Hl.KernelSpecAPIClient({serverSettings:this.serverSettings}),this._pollModels=new Vl.Poll({auto:!1,factory:()=>this.requestRunning(),frequency:{interval:10*1e3,backoff:!0,max:300*1e3},name:"@jupyterlab/services:KernelManager#models",standby:(r=e.standby)!==null&&r!==void 0?r:"when-hidden"}),this._ready=(async()=>{await this._pollModels.start(),await this._pollModels.tick,this._isReady=!0})()}get isReady(){return this._isReady}get ready(){return this._ready}get runningChanged(){return this._runningChanged}get connectionFailure(){return this._connectionFailure}dispose(){this.isDisposed||(this._models.clear(),this._kernelConnections.forEach(e=>e.dispose()),this._pollModels.dispose(),super.dispose())}connectTo(e){var t;let{id:s}=e.model,r=(t=e.handleComms)!==null&&t!==void 0?t:!0;if(e.handleComms===void 0){for(let o of this._kernelConnections)if(o.id===s&&o.handleComms){r=!1;break}}e.commsOverSubshells=this._commsOverSubshells;let i=new $l.KernelConnection({handleComms:r,...e,serverSettings:this.serverSettings,kernelAPIClient:this._kernelAPIClient,kernelSpecAPIClient:this._kernelSpecAPIClient});return this._onStarted(i),this._models.has(s)||this.refreshRunning().catch(()=>{}),i}running(){return this._models.values()}get runningCount(){return this._models.size}get commsOverSubshells(){return this._commsOverSubshells}set commsOverSubshells(e){this._commsOverSubshells=e;for(let t of this._kernelConnections)t.commsOverSubshells=e}async refreshRunning(){await this._pollModels.refresh(),await this._pollModels.tick}async startNew(e={},t={}){let s=await this._kernelAPIClient.startNew(e);return this.connectTo({...t,model:s})}async shutdown(e){await this._kernelAPIClient.shutdown(e),await this.refreshRunning()}async shutdownAll(){await this.refreshRunning(),await Promise.all([...this._models.keys()].map(e=>this._kernelAPIClient.shutdown(e))),await this.refreshRunning()}async findById(e){return this._models.has(e)?this._models.get(e):(await this.refreshRunning(),this._models.get(e))}async requestRunning(){var e,t;let s;try{s=await this._kernelAPIClient.listRunning()}catch(r){throw(r instanceof Ti.ServerConnection.NetworkError||((e=r.response)===null||e===void 0?void 0:e.status)===503||((t=r.response)===null||t===void 0?void 0:t.status)===424)&&this._connectionFailure.emit(r),r}this.isDisposed||this._models.size===s.length&&s.every(r=>{let i=this._models.get(r.id);return i?i.connections===r.connections&&i.execution_state===r.execution_state&&i.last_activity===r.last_activity&&i.name===r.name&&i.reason===r.reason&&i.traceback===r.traceback:!1})||(this._models=new Map(s.map(r=>[r.id,r])),this._kernelConnections.forEach(r=>{this._models.has(r.id)||r.handleShutdown()}),this._runningChanged.emit(s))}_onStarted(e){this._kernelConnections.add(e),e.statusChanged.connect(this._onStatusChanged,this),e.disposed.connect(this._onDisposed,this)}_onDisposed(e){this._kernelConnections.delete(e),this.refreshRunning().catch(()=>{})}_onStatusChanged(e,t){t==="dead"&&this.refreshRunning().catch(()=>{})}};gt.KernelManager=pt;(function(n){class e extends n{constructor(){super(...arguments),this._readyPromise=new Promise(()=>{})}get isActive(){return!1}get parentReady(){return super.ready}async startNew(s={},r={}){return Promise.reject(new Error("Not implemented in no-op Kernel Manager"))}connectTo(s){throw new Error("Not implemented in no-op Kernel Manager")}async shutdown(s){return Promise.reject(new Error("Not implemented in no-op Kernel Manager"))}get ready(){return this.parentReady.then(()=>this._readyPromise)}async requestRunning(){return Promise.resolve()}}n.NoopManager=e})(pt||(gt.KernelManager=pt={}))});var Cs=R(H=>{"use strict";var Ui=H&&H.__createBinding||(Object.create?function(n,e,t,s){s===void 0&&(s=t);var r=Object.getOwnPropertyDescriptor(e,t);(!r||("get"in r?!e.__esModule:r.writable||r.configurable))&&(r={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(n,s,r)}:function(n,e,t,s){s===void 0&&(s=t),n[s]=e[t]}),Jl=H&&H.__setModuleDefault||(Object.create?function(n,e){Object.defineProperty(n,"default",{enumerable:!0,value:e})}:function(n,e){n.default=e}),bs=H&&H.__importStar||function(n){if(n&&n.__esModule)return n;var e={};if(n!=null)for(var t in n)t!=="default"&&Object.prototype.hasOwnProperty.call(n,t)&&Ui(e,n,t);return Jl(e,n),e},Gl=H&&H.__exportStar||function(n,e){for(var t in n)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&Ui(e,n,t)};Object.defineProperty(H,"__esModule",{value:!0});H.CommsOverSubshells=H.KernelConnection=H.KernelAPI=H.KernelMessage=H.Kernel=void 0;var Xl=ps();Object.defineProperty(H,"CommsOverSubshells",{enumerable:!0,get:function(){return Xl.CommsOverSubshells}});var Yl=bs(fi());H.Kernel=Yl;var Ql=bs(Ze());H.KernelMessage=Ql;var Zl=bs(_n());H.KernelAPI=Zl;var ec=Ss();Object.defineProperty(H,"KernelConnection",{enumerable:!0,get:function(){return ec.KernelConnection}});Gl(ji(),H)});var Ni=R(Ai=>{"use strict";Object.defineProperty(Ai,"__esModule",{value:!0})});var xi=R(mn=>{"use strict";Object.defineProperty(mn,"__esModule",{value:!0});mn.KernelSpecManager=void 0;var tc=Z(),nc=He(),Li=ee(),sc=$e(),rc=ft(),Ps=class extends sc.BaseManager{constructor(e={}){var t,s;super(e),this._isReady=!1,this._connectionFailure=new Li.Signal(this),this._specs=null,this._specsChanged=new Li.Signal(this),this._kernelSpecAPIClient=(t=e.kernelSpecAPIClient)!==null&&t!==void 0?t:new rc.KernelSpecAPIClient({serverSettings:this.serverSettings}),this._ready=Promise.all([this.requestSpecs()]).then(r=>{}).catch(r=>{}).then(()=>{this.isDisposed||(this._isReady=!0)}),this._pollSpecs=new nc.Poll({auto:!1,factory:()=>this.requestSpecs(),frequency:{interval:61*1e3,backoff:!0,max:300*1e3},name:"@jupyterlab/services:KernelSpecManager#specs",standby:(s=e.standby)!==null&&s!==void 0?s:"when-hidden"}),this.ready.then(()=>{this._pollSpecs.start()})}get isReady(){return this._isReady}get ready(){return this._ready}get specs(){return this._specs}get specsChanged(){return this._specsChanged}get connectionFailure(){return this._connectionFailure}dispose(){this._pollSpecs.dispose(),super.dispose()}async refreshSpecs(){await this._pollSpecs.refresh(),await this._pollSpecs.tick}async requestSpecs(){let e=await this._kernelSpecAPIClient.get();this.isDisposed||tc.JSONExt.deepEqual(e,this._specs)||(this._specs=e,this._specsChanged.emit(e))}};mn.KernelSpecManager=Ps});var Ms=R(fe=>{"use strict";var Fi=fe&&fe.__createBinding||(Object.create?function(n,e,t,s){s===void 0&&(s=t);var r=Object.getOwnPropertyDescriptor(e,t);(!r||("get"in r?!e.__esModule:r.writable||r.configurable))&&(r={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(n,s,r)}:function(n,e,t,s){s===void 0&&(s=t),n[s]=e[t]}),ic=fe&&fe.__setModuleDefault||(Object.create?function(n,e){Object.defineProperty(n,"default",{enumerable:!0,value:e})}:function(n,e){n.default=e}),Ki=fe&&fe.__importStar||function(n){if(n&&n.__esModule)return n;var e={};if(n!=null)for(var t in n)t!=="default"&&Object.prototype.hasOwnProperty.call(n,t)&&Fi(e,n,t);return ic(e,n),e},oc=fe&&fe.__exportStar||function(n,e){for(var t in n)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&Fi(e,n,t)};Object.defineProperty(fe,"__esModule",{value:!0});fe.KernelSpecAPI=fe.KernelSpec=void 0;var ac=Ki(Ni());fe.KernelSpec=ac;var lc=Ki(ft());fe.KernelSpecAPI=lc;oc(xi(),fe)});var zi=R(vn=>{"use strict";Object.defineProperty(vn,"__esModule",{value:!0});vn.BuildManager=void 0;var Es=te(),Ve=he(),cc="api/build",Is=class{constructor(e={}){var t;this.serverSettings=(t=e.serverSettings)!==null&&t!==void 0?t:Ve.ServerConnection.makeSettings()}get isAvailable(){return Es.PageConfig.getOption("buildAvailable").toLowerCase()==="true"}get shouldCheck(){return Es.PageConfig.getOption("buildCheck").toLowerCase()==="true"}getStatus(){let{_url:e,serverSettings:t}=this;return Ve.ServerConnection.makeRequest(e,{},t).then(r=>{if(r.status!==200)throw new Ve.ServerConnection.ResponseError(r);return r.json()}).then(r=>{if(typeof r.status!="string")throw new Error("Invalid data");if(typeof r.message!="string")throw new Error("Invalid data");return r})}build(){let{_url:e,serverSettings:t}=this,s={method:"POST"};return Ve.ServerConnection.makeRequest(e,s,t).then(i=>{if(i.status===400)throw new Ve.ServerConnection.ResponseError(i,"Build aborted");if(i.status!==200){let o=`Build failed with ${i.status}.
4
4
 
5
5
  If you are experiencing the build failure after installing an extension (or trying to include previously installed extension after updating JupyterLab) please check the extension repository for new installation instructions as many extensions migrated to the prebuilt extensions system which no longer requires rebuilding JupyterLab (but uses a different installation procedure, typically involving a package manager such as 'pip' or 'conda').
6
6
 
7
- If you specifically intended to install a source extension, please run 'jupyter lab build' on the server for full output.`;throw new He.ServerConnection.ResponseError(r,a)}})}cancel(){let{_url:e,serverSettings:t}=this,n={method:"DELETE"};return He.ServerConnection.makeRequest(e,n,t).then(r=>{if(r.status!==204)throw new He.ServerConnection.ResponseError(r)})}get _url(){let{baseUrl:e,appUrl:t}=this.serverSettings;return Ui.URLExt.join(e,t,Bc)}};Pn.BuildManager=Ai});var Fi=P(Mn=>{"use strict";Object.defineProperty(Mn,"__esModule",{value:!0});Mn.NbConvertManager=void 0;var Ni=J(),Li=de(),$c=te(),Vc="api/nbconvert",Wc="nbconvert",zi=class{constructor(e={}){var t;this._exportFormats=null,this.serverSettings=(t=e.serverSettings)!==null&&t!==void 0?t:Li.ServerConnection.makeSettings()}async fetchExportFormats(){this._requestingFormats=new $c.PromiseDelegate,this._exportFormats=null;let e=this.serverSettings.baseUrl,t=Ni.URLExt.join(e,Vc),{serverSettings:n}=this,s=await Li.ServerConnection.makeRequest(t,{},n);if(s.status!==200)throw await Li.ServerConnection.ResponseError.create(s);let r=await s.json(),a={};return Object.keys(r).forEach(function(u){let c=r[u].output_mimetype;a[u]={output_mimetype:c}}),this._exportFormats=a,this._requestingFormats.resolve(a),a}async getExportFormats(e=!0){return this._requestingFormats?this._requestingFormats.promise:e||!this._exportFormats?await this.fetchExportFormats():this._exportFormats}async exportAs(e){let{format:t,path:n}=e,{download:s=!1}=e.exporterOptions||{},r=this.serverSettings.baseUrl,a=Ni.URLExt.encodeParts(n),o=Ni.URLExt.join(r,Wc,t,a);s&&(o+="?download=true"),window==null||window.open(o,"_blank","noopener")}};Mn.NbConvertManager=zi});var la=P(oa=>{"use strict";Object.defineProperty(oa,"__esModule",{value:!0})});var da=P(Ct=>{"use strict";Object.defineProperty(Ct,"__esModule",{value:!0});Ct.validateModel=ca;Ct.updateLegacySessionModel=Hc;Ct.validateModels=Gc;var Jc=wn(),xt=ft();function ca(i){(0,xt.validateProperty)(i,"id","string"),(0,xt.validateProperty)(i,"type","string"),(0,xt.validateProperty)(i,"name","string"),(0,xt.validateProperty)(i,"path","string"),(0,xt.validateProperty)(i,"kernel","object"),(0,Jc.validateModel)(i.kernel)}function Hc(i){i.path===void 0&&i.notebook!==void 0&&(i.path=i.notebook.path,i.type="notebook",i.name="")}function Gc(i){if(!Array.isArray(i))throw new Error("Invalid session list");i.forEach(e=>ca(e))}});var On=P(he=>{"use strict";Object.defineProperty(he,"__esModule",{value:!0});he.SessionAPIClient=he.SESSION_SERVICE_URL=void 0;he.listRunning=ua;he.getSessionUrl=In;he.shutdownSession=pa;he.getSessionModel=ha;he.startSession=fa;he.updateSession=ma;var ae=de(),En=J(),Ge=da();he.SESSION_SERVICE_URL="api/sessions";async function ua(i=ae.ServerConnection.makeSettings()){let e=En.URLExt.join(i.baseUrl,he.SESSION_SERVICE_URL),t=await ae.ServerConnection.makeRequest(e,{},i);if(t.status!==200)throw await ae.ServerConnection.ResponseError.create(t);let n=await t.json();if(!Array.isArray(n))throw new Error("Invalid Session list");return n.forEach(s=>{(0,Ge.updateLegacySessionModel)(s),(0,Ge.validateModel)(s)}),n}function In(i,e){let t=En.URLExt.join(i,he.SESSION_SERVICE_URL),n=En.URLExt.join(t,e);if(!n.startsWith(t))throw new Error("Can only be used for services requests");return n}async function pa(i,e=ae.ServerConnection.makeSettings()){var t;let n=In(e.baseUrl,i),s={method:"DELETE"},r=await ae.ServerConnection.makeRequest(n,s,e);if(r.status===404){let o=(t=(await r.json()).message)!==null&&t!==void 0?t:`The session "${i}"" does not exist on the server`;console.warn(o)}else{if(r.status===410)throw new ae.ServerConnection.ResponseError(r,"The kernel was deleted but the session was not");if(r.status!==204)throw await ae.ServerConnection.ResponseError.create(r)}}async function ha(i,e=ae.ServerConnection.makeSettings()){let t=In(e.baseUrl,i),n=await ae.ServerConnection.makeRequest(t,{},e);if(n.status!==200)throw await ae.ServerConnection.ResponseError.create(n);let s=await n.json();return(0,Ge.updateLegacySessionModel)(s),(0,Ge.validateModel)(s),s}async function fa(i,e=ae.ServerConnection.makeSettings()){let t=En.URLExt.join(e.baseUrl,he.SESSION_SERVICE_URL),n={method:"POST",body:JSON.stringify(i)},s=await ae.ServerConnection.makeRequest(t,n,e);if(s.status!==201)throw await ae.ServerConnection.ResponseError.create(s);let r=await s.json();return(0,Ge.updateLegacySessionModel)(r),(0,Ge.validateModel)(r),r}async function ma(i,e=ae.ServerConnection.makeSettings()){let t=In(e.baseUrl,i.id),n={method:"PATCH",body:JSON.stringify(i)},s=await ae.ServerConnection.makeRequest(t,n,e);if(s.status!==200)throw await ae.ServerConnection.ResponseError.create(s);let r=await s.json();return(0,Ge.updateLegacySessionModel)(r),(0,Ge.validateModel)(r),r}var Ki=class{constructor(e){var t;this.serverSettings=(t=e.serverSettings)!==null&&t!==void 0?t:ae.ServerConnection.makeSettings()}async listRunning(){return ua(this.serverSettings)}async getModel(e){return ha(e,this.serverSettings)}async startNew(e){return fa(e,this.serverSettings)}async shutdown(e){return pa(e,this.serverSettings)}async update(e){return ma(e,this.serverSettings)}};he.SessionAPIClient=Ki});var ga=P(Rn=>{"use strict";Object.defineProperty(Rn,"__esModule",{value:!0});Rn.SessionConnection=void 0;var Ne=Z(),Yc=qe(),Xc=te(),Zc=On(),Bi=class{constructor(e){var t,n,s,r,a;this._id="",this._path="",this._name="",this._type="",this._kernel=null,this._isDisposed=!1,this._disposed=new Ne.Signal(this),this._kernelChanged=new Ne.Signal(this),this._statusChanged=new Ne.Signal(this),this._connectionStatusChanged=new Ne.Signal(this),this._pendingInput=new Ne.Signal(this),this._iopubMessage=new Ne.Signal(this),this._unhandledMessage=new Ne.Signal(this),this._anyMessage=new Ne.Signal(this),this._propertyChanged=new Ne.Signal(this),this._id=e.model.id,this._name=e.model.name,this._path=e.model.path,this._type=e.model.type,this._username=(t=e.username)!==null&&t!==void 0?t:"",this._clientId=(n=e.clientId)!==null&&n!==void 0?n:Xc.UUID.uuid4(),this._connectToKernel=e.connectToKernel,this._kernelConnectionOptions=(s=e.kernelConnectionOptions)!==null&&s!==void 0?s:{},this.serverSettings=(r=e.serverSettings)!==null&&r!==void 0?r:Yc.ServerConnection.makeSettings(),this._sessionAPIClient=(a=e.sessionAPIClient)!==null&&a!==void 0?a:new Zc.SessionAPIClient({serverSettings:this.serverSettings}),this.setupKernel(e.model.kernel)}get disposed(){return this._disposed}get kernelChanged(){return this._kernelChanged}get statusChanged(){return this._statusChanged}get connectionStatusChanged(){return this._connectionStatusChanged}get pendingInput(){return this._pendingInput}get iopubMessage(){return this._iopubMessage}get unhandledMessage(){return this._unhandledMessage}get anyMessage(){return this._anyMessage}get propertyChanged(){return this._propertyChanged}get id(){return this._id}get kernel(){return this._kernel}get path(){return this._path}get type(){return this._type}get name(){return this._name}get model(){return{id:this.id,kernel:this.kernel&&{id:this.kernel.id,name:this.kernel.name},path:this._path,type:this._type,name:this._name}}get isDisposed(){return this._isDisposed}update(e){let t=this.model;if(this._path=e.path,this._name=e.name,this._type=e.type,this._kernel===null&&e.kernel!==null||this._kernel!==null&&e.kernel===null||this._kernel!==null&&e.kernel!==null&&this._kernel.id!==e.kernel.id){this._kernel!==null&&this._kernel.dispose();let n=this._kernel||null;this.setupKernel(e.kernel);let s=this._kernel||null;this._kernelChanged.emit({name:"kernel",oldValue:n,newValue:s})}this._handleModelChange(t)}dispose(){if(!this.isDisposed){if(this._isDisposed=!0,this._disposed.emit(),this._kernel){this._kernel.dispose();let e=this._kernel;this._kernel=null;let t=this._kernel;this._kernelChanged.emit({name:"kernel",oldValue:e,newValue:t})}Ne.Signal.clearData(this)}}async setPath(e){if(this.isDisposed)throw new Error("Session is disposed");await this._patch({path:e})}async setName(e){if(this.isDisposed)throw new Error("Session is disposed");await this._patch({name:e})}async setType(e){if(this.isDisposed)throw new Error("Session is disposed");await this._patch({type:e})}async changeKernel(e){if(this.isDisposed)throw new Error("Session is disposed");return await this._patch({kernel:e}),this.kernel}async shutdown(){if(this.isDisposed)throw new Error("Session is disposed");await this._sessionAPIClient.shutdown(this.id),this.dispose()}setupKernel(e){if(e===null){this._kernel=null;return}let t=this._connectToKernel({...this._kernelConnectionOptions,model:e,username:this._username,clientId:this._clientId,serverSettings:this.serverSettings});this._kernel=t,t.statusChanged.connect(this.onKernelStatus,this),t.connectionStatusChanged.connect(this.onKernelConnectionStatus,this),t.pendingInput.connect(this.onPendingInput,this),t.unhandledMessage.connect(this.onUnhandledMessage,this),t.iopubMessage.connect(this.onIOPubMessage,this),t.anyMessage.connect(this.onAnyMessage,this)}onKernelStatus(e,t){this._statusChanged.emit(t)}onKernelConnectionStatus(e,t){this._connectionStatusChanged.emit(t)}onPendingInput(e,t){this._pendingInput.emit(t)}onIOPubMessage(e,t){this._iopubMessage.emit(t)}onUnhandledMessage(e,t){this._unhandledMessage.emit(t)}onAnyMessage(e,t){this._anyMessage.emit(t)}async _patch(e){let t=await this._sessionAPIClient.update({...e,id:this._id});return this.update(t),t}_handleModelChange(e){e.name!==this._name&&this._propertyChanged.emit("name"),e.type!==this._type&&this._propertyChanged.emit("type"),e.path!==this._path&&this._propertyChanged.emit("path")}};Rn.SessionConnection=Bi});var va=P(Pt=>{"use strict";Object.defineProperty(Pt,"__esModule",{value:!0});Pt.SessionManager=void 0;var Qc=Ze(),_a=Z(),ed=de(),td=Xe(),nd=ga(),id=On(),kt=class extends td.BaseManager{constructor(e){var t,n;super(e),this._isReady=!1,this._sessionConnections=new Set,this._models=new Map,this._runningChanged=new _a.Signal(this),this._connectionFailure=new _a.Signal(this),this._connectToKernel=s=>this._kernelManager.connectTo(s),this._kernelManager=e.kernelManager,this._sessionAPIClient=(t=e.sessionAPIClient)!==null&&t!==void 0?t:new id.SessionAPIClient({serverSettings:e.serverSettings}),this._pollModels=new Qc.Poll({auto:!1,factory:()=>this.requestRunning(),frequency:{interval:10*1e3,backoff:!0,max:300*1e3},name:"@jupyterlab/services:SessionManager#models",standby:(n=e.standby)!==null&&n!==void 0?n:"when-hidden"}),this._ready=(async()=>{await this._pollModels.start(),await this._pollModels.tick,this._kernelManager.isActive&&await this._kernelManager.ready,this._isReady=!0})()}get isReady(){return this._isReady}get ready(){return this._ready}get runningChanged(){return this._runningChanged}get connectionFailure(){return this._connectionFailure}dispose(){this.isDisposed||(this._models.clear(),this._sessionConnections.forEach(e=>e.dispose()),this._pollModels.dispose(),super.dispose())}connectTo(e){let t=new nd.SessionConnection({...e,connectToKernel:this._connectToKernel,serverSettings:this.serverSettings,sessionAPIClient:this._sessionAPIClient});return this._onStarted(t),this._models.has(e.model.id)||this.refreshRunning().catch(()=>{}),t}running(){return this._models.values()}async refreshRunning(){await this._pollModels.refresh(),await this._pollModels.tick}async startNew(e,t={}){let n=await this._sessionAPIClient.startNew(e);return await this.refreshRunning(),this.connectTo({...t,model:n})}async shutdown(e){await this._sessionAPIClient.shutdown(e),await this.refreshRunning()}async shutdownAll(){await this.refreshRunning(),await Promise.all([...this._models.keys()].map(e=>this._sessionAPIClient.shutdown(e))),await this.refreshRunning()}async stopIfNeeded(e){try{let n=(await this._sessionAPIClient.listRunning()).filter(s=>s.path===e);if(n.length===1){let s=n[0].id;await this.shutdown(s)}}catch{}}async findById(e){return this._models.has(e)?this._models.get(e):(await this.refreshRunning(),this._models.get(e))}async findByPath(e){for(let t of this._models.values())if(t.path===e)return t;await this.refreshRunning();for(let t of this._models.values())if(t.path===e)return t}async requestRunning(){var e,t;let n;try{n=await this._sessionAPIClient.listRunning()}catch(s){throw(s instanceof ed.ServerConnection.NetworkError||((e=s.response)===null||e===void 0?void 0:e.status)===503||((t=s.response)===null||t===void 0?void 0:t.status)===424)&&this._connectionFailure.emit(s),s}this.isDisposed||this._models.size===n.length&&n.every(s=>{var r,a,o,u;let c=this._models.get(s.id);return c?((r=c.kernel)===null||r===void 0?void 0:r.id)===((a=s.kernel)===null||a===void 0?void 0:a.id)&&((o=c.kernel)===null||o===void 0?void 0:o.name)===((u=s.kernel)===null||u===void 0?void 0:u.name)&&c.name===s.name&&c.path===s.path&&c.type===s.type:!1})||(this._models=new Map(n.map(s=>[s.id,s])),this._sessionConnections.forEach(s=>{this._models.has(s.id)?s.update(this._models.get(s.id)):s.dispose()}),this._runningChanged.emit(n))}_onStarted(e){this._sessionConnections.add(e),e.disposed.connect(this._onDisposed,this),e.propertyChanged.connect(this._onChanged,this),e.kernelChanged.connect(this._onChanged,this)}_onDisposed(e){this._sessionConnections.delete(e),this.refreshRunning().catch(()=>{})}_onChanged(){this.refreshRunning().catch(()=>{})}};Pt.SessionManager=kt;(function(i){class e extends i{constructor(){super(...arguments),this._readyPromise=new Promise(()=>{})}get isActive(){return!1}get parentReady(){return super.ready}async startNew(n,s={}){return Promise.reject(new Error("Not implemented in no-op Session Manager"))}connectTo(n){throw Error("Not implemented in no-op Session Manager")}get ready(){return this.parentReady.then(()=>this._readyPromise)}async shutdown(n){return Promise.reject(new Error("Not implemented in no-op Session Manager"))}async requestRunning(){return Promise.resolve()}}i.NoopManager=e})(kt||(Pt.SessionManager=kt={}))});var $i=P(fe=>{"use strict";var ya=fe&&fe.__createBinding||(Object.create?function(i,e,t,n){n===void 0&&(n=t);var s=Object.getOwnPropertyDescriptor(e,t);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(i,n,s)}:function(i,e,t,n){n===void 0&&(n=t),i[n]=e[t]}),sd=fe&&fe.__setModuleDefault||(Object.create?function(i,e){Object.defineProperty(i,"default",{enumerable:!0,value:e})}:function(i,e){i.default=e}),wa=fe&&fe.__importStar||function(i){if(i&&i.__esModule)return i;var e={};if(i!=null)for(var t in i)t!=="default"&&Object.prototype.hasOwnProperty.call(i,t)&&ya(e,i,t);return sd(e,i),e},rd=fe&&fe.__exportStar||function(i,e){for(var t in i)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&ya(e,i,t)};Object.defineProperty(fe,"__esModule",{value:!0});fe.SessionAPI=fe.Session=void 0;var ad=wa(la());fe.Session=ad;var od=wa(On());fe.SessionAPI=od;rd(va(),fe)});var ba=P(jn=>{"use strict";Object.defineProperty(jn,"__esModule",{value:!0});jn.DataConnector=void 0;var Vi=class{async list(e){throw new Error("DataConnector#list method has not been implemented.")}async remove(e){throw new Error("DataConnector#remove method has not been implemented.")}async save(e,t){throw new Error("DataConnector#save method has not been implemented.")}};jn.DataConnector=Vi});var xa=P(Sa=>{"use strict";Object.defineProperty(Sa,"__esModule",{value:!0})});var ka=P((Dn,Ca)=>{(function(i,e){typeof Dn=="object"&&typeof Ca!="undefined"?e(Dn):typeof define=="function"&&define.amd?define(["exports"],e):(i=typeof globalThis!="undefined"?globalThis:i||self,e(i.lumino_properties={}))})(Dn,function(i){"use strict";class e{constructor(s){this._pid=t.nextPID(),this.name=s.name,this._create=s.create,this._coerce=s.coerce||null,this._compare=s.compare||null,this._changed=s.changed||null}get(s){let r,a=t.ensureMap(s);return this._pid in a?r=a[this._pid]:r=a[this._pid]=this._createValue(s),r}set(s,r){let a,o=t.ensureMap(s);this._pid in o?a=o[this._pid]:a=o[this._pid]=this._createValue(s);let u=this._coerceValue(s,r);this._maybeNotify(s,a,o[this._pid]=u)}coerce(s){let r,a=t.ensureMap(s);this._pid in a?r=a[this._pid]:r=a[this._pid]=this._createValue(s);let o=this._coerceValue(s,r);this._maybeNotify(s,r,a[this._pid]=o)}_createValue(s){let r=this._create;return r(s)}_coerceValue(s,r){let a=this._coerce;return a?a(s,r):r}_compareValue(s,r){let a=this._compare;return a?a(s,r):s===r}_maybeNotify(s,r,a){let o=this._changed;o&&!this._compareValue(r,a)&&o(s,r,a)}}(function(n){function s(r){t.ownerData.delete(r)}n.clearData=s})(e||(e={}));var t;(function(n){n.ownerData=new WeakMap,n.nextPID=(()=>{let r=0;return()=>`pid-${`${Math.random()}`.slice(2)}-${r++}`})();function s(r){let a=n.ownerData.get(r);return a||(a=Object.create(null),n.ownerData.set(r,a),a)}n.ensureMap=s})(t||(t={})),i.AttachedProperty=e})});var Ma=P(qn=>{"use strict";Object.defineProperty(qn,"__esModule",{value:!0});qn.RestorablePool=void 0;var ld=te(),Pa=ka(),Tn=Z(),Wi=class{constructor(e){this._added=new Tn.Signal(this),this._current=null,this._currentChanged=new Tn.Signal(this),this._hasRestored=!1,this._isDisposed=!1,this._objects=new Set,this._restore=null,this._restored=new ld.PromiseDelegate,this._updated=new Tn.Signal(this),this.namespace=e.namespace}get added(){return this._added}get current(){return this._current}set current(e){this._current!==e&&e!==null&&this._objects.has(e)&&(this._current=e,this._currentChanged.emit(this._current))}get currentChanged(){return this._currentChanged}get isDisposed(){return this._isDisposed}get restored(){return this._restored.promise}get size(){return this._objects.size}get updated(){return this._updated}async add(e){var t,n;if(e.isDisposed){let s="A disposed object cannot be added.";throw console.warn(s,e),new Error(s)}if(this._objects.has(e)){let s="This object already exists in the pool.";throw console.warn(s,e),new Error(s)}if(this._objects.add(e),e.disposed.connect(this._onInstanceDisposed,this),!Le.injectedProperty.get(e)){if(this._restore){let{connector:s}=this._restore,r=this._restore.name(e);if(r){let a=`${this.namespace}:${r}`,o=(n=(t=this._restore).args)===null||n===void 0?void 0:n.call(t,e);Le.nameProperty.set(e,a),await s.save(a,{data:o})}}this._added.emit(e)}}dispose(){this.isDisposed||(this._current=null,this._isDisposed=!0,this._objects.clear(),Tn.Signal.clearData(this))}find(e){let t=this._objects.values();for(let n of t)if(e(n))return n}forEach(e){this._objects.forEach(e)}filter(e){let t=[];return this.forEach(n=>{e(n)&&t.push(n)}),t}inject(e){return Le.injectedProperty.set(e,!0),this.add(e)}has(e){return this._objects.has(e)}async restore(e){if(this._hasRestored)throw new Error("This pool has already been restored.");this._hasRestored=!0;let{command:t,connector:n,registry:s,when:r}=e,a=this.namespace,o=r?[n.list(a)].concat(r):[n.list(a)];this._restore=e;let[u]=await Promise.all(o),c=await Promise.all(u.ids.map(async(d,l)=>{let p=u.values[l],v=p&&p.data;return v===void 0?n.remove(d):s.execute(t,v).catch(()=>n.remove(d))}));return this._restored.resolve(),c}async save(e){var t,n;let s=Le.injectedProperty.get(e);if(!this._restore||!this.has(e)||s)return;let{connector:r}=this._restore,a=this._restore.name(e),o=Le.nameProperty.get(e),u=a?`${this.namespace}:${a}`:"";if(o&&o!==u&&await r.remove(o),Le.nameProperty.set(e,u),u){let c=(n=(t=this._restore).args)===null||n===void 0?void 0:n.call(t,e);await r.save(u,{data:c})}o!==u&&this._updated.emit(e)}_onInstanceDisposed(e){if(this._objects.delete(e),e===this._current&&(this._current=null,this._currentChanged.emit(this._current)),Le.injectedProperty.get(e)||!this._restore)return;let{connector:t}=this._restore,n=Le.nameProperty.get(e);n&&t.remove(n)}};qn.RestorablePool=Wi;var Le;(function(i){i.injectedProperty=new Pa.AttachedProperty({name:"injected",create:()=>!1}),i.nameProperty=new Pa.AttachedProperty({name:"name",create:()=>""})})(Le||(Le={}))});var Ea=P(Et=>{"use strict";Object.defineProperty(Et,"__esModule",{value:!0});Et.StateDB=void 0;var cd=Z(),Mt=class i{constructor(e={}){this._changed=new cd.Signal(this);let{connector:t,transform:n}=e;this._connector=t||new i.Connector,n?this._ready=n.then(s=>{let{contents:r,type:a}=s;switch(a){case"cancel":return;case"clear":return this._clear();case"merge":return this._merge(r||{});case"overwrite":return this._overwrite(r||{});default:return}}):this._ready=Promise.resolve(void 0)}get changed(){return this._changed}async clear(){await this._ready,await this._clear()}async fetch(e){return await this._ready,this._fetch(e)}async list(e){return await this._ready,this._list(e)}async remove(e){await this._ready,await this._remove(e),this._changed.emit({id:e,type:"remove"})}async save(e,t){await this._ready,await this._save(e,t),this._changed.emit({id:e,type:"save"})}async toJSON(){await this._ready;let{ids:e,values:t}=await this._list();return t.reduce((n,s,r)=>(n[e[r]]=s,n),{})}async _clear(){await Promise.all((await this._list()).ids.map(e=>this._remove(e)))}async _fetch(e){let t=await this._connector.fetch(e);if(t)return JSON.parse(t).v}async _list(e=""){let{ids:t,values:n}=await this._connector.list(e);return{ids:t,values:n.map(s=>JSON.parse(s).v)}}async _merge(e){await Promise.all(Object.keys(e).map(t=>e[t]&&this._save(t,e[t])))}async _overwrite(e){await this._clear(),await this._merge(e)}async _remove(e){return this._connector.remove(e)}async _save(e,t){return this._connector.save(e,JSON.stringify({v:t}))}};Et.StateDB=Mt;(function(i){class e{constructor(){this._storage={}}async fetch(n){return this._storage[n]}async list(n=""){return Object.keys(this._storage).reduce((s,r)=>((n===""||n===r.split(":")[0])&&(s.ids.push(r),s.values.push(this._storage[r])),s),{ids:[],values:[]})}async remove(n){delete this._storage[n]}async save(n,s){this._storage[n]=s}}i.Connector=e})(Mt||(Et.StateDB=Mt={}))});var Ia=P(Un=>{"use strict";Object.defineProperty(Un,"__esModule",{value:!0});Un.IStateDB=void 0;var dd=te();Un.IStateDB=new dd.Token("@jupyterlab/coreutils:IStateDB",`A service for the JupyterLab state database.
7
+ If you specifically intended to install a source extension, please run 'jupyter lab build' on the server for full output.`;throw new Ve.ServerConnection.ResponseError(i,o)}})}cancel(){let{_url:e,serverSettings:t}=this,s={method:"DELETE"};return Ve.ServerConnection.makeRequest(e,s,t).then(i=>{if(i.status!==204)throw new Ve.ServerConnection.ResponseError(i)})}get _url(){let{baseUrl:e,appUrl:t}=this.serverSettings;return Es.URLExt.join(e,t,cc)}};vn.BuildManager=Is});var Ds=R(yn=>{"use strict";Object.defineProperty(yn,"__esModule",{value:!0});yn.NbConvertManager=void 0;var Rs=te(),ks=he(),uc=Z(),hc="api/nbconvert",dc="nbconvert",Os=class{constructor(e={}){var t;this._exportFormats=null,this.serverSettings=(t=e.serverSettings)!==null&&t!==void 0?t:ks.ServerConnection.makeSettings()}async fetchExportFormats(){this._requestingFormats=new uc.PromiseDelegate,this._exportFormats=null;let e=this.serverSettings.baseUrl,t=Rs.URLExt.join(e,hc),{serverSettings:s}=this,r=await ks.ServerConnection.makeRequest(t,{},s);if(r.status!==200)throw await ks.ServerConnection.ResponseError.create(r);let i=await r.json(),o={};return Object.keys(i).forEach(function(h){let c=i[h].output_mimetype;o[h]={output_mimetype:c}}),this._exportFormats=o,this._requestingFormats.resolve(o),o}async getExportFormats(e=!0){return this._requestingFormats?this._requestingFormats.promise:e||!this._exportFormats?await this.fetchExportFormats():this._exportFormats}async exportAs(e){let{format:t,path:s}=e,{download:r=!1}=e.exporterOptions||{},i=this.serverSettings.baseUrl,o=Rs.URLExt.encodeParts(s),a=Rs.URLExt.join(i,dc,t,o);r&&(a+="?download=true"),window==null||window.open(a,"_blank","noopener")}};yn.NbConvertManager=Os});var Bi=R(Vi=>{"use strict";Object.defineProperty(Vi,"__esModule",{value:!0})});var $i=R(vt=>{"use strict";Object.defineProperty(vt,"__esModule",{value:!0});vt.validateModel=Wi;vt.updateLegacySessionModel=_c;vt.validateModels=pc;var fc=dn(),mt=lt();function Wi(n){(0,mt.validateProperty)(n,"id","string"),(0,mt.validateProperty)(n,"type","string"),(0,mt.validateProperty)(n,"name","string"),(0,mt.validateProperty)(n,"path","string"),(0,mt.validateProperty)(n,"kernel","object"),(0,fc.validateModel)(n.kernel)}function _c(n){n.path===void 0&&n.notebook!==void 0&&(n.path=n.notebook.path,n.type="notebook",n.name="")}function pc(n){if(!Array.isArray(n))throw new Error("Invalid session list");n.forEach(e=>Wi(e))}});var bn=R(_e=>{"use strict";Object.defineProperty(_e,"__esModule",{value:!0});_e.SessionAPIClient=_e.SESSION_SERVICE_URL=void 0;_e.listRunning=Hi;_e.getSessionUrl=Sn;_e.shutdownSession=Ji;_e.getSessionModel=Gi;_e.startSession=Xi;_e.updateSession=Yi;var oe=he(),wn=te(),Be=$i();_e.SESSION_SERVICE_URL="api/sessions";async function Hi(n=oe.ServerConnection.makeSettings()){let e=wn.URLExt.join(n.baseUrl,_e.SESSION_SERVICE_URL),t=await oe.ServerConnection.makeRequest(e,{},n);if(t.status!==200)throw await oe.ServerConnection.ResponseError.create(t);let s=await t.json();if(!Array.isArray(s))throw new Error("Invalid Session list");return s.forEach(r=>{(0,Be.updateLegacySessionModel)(r),(0,Be.validateModel)(r)}),s}function Sn(n,e){let t=wn.URLExt.join(n,_e.SESSION_SERVICE_URL),s=wn.URLExt.join(t,e);if(!s.startsWith(t))throw new Error("Can only be used for services requests");return s}async function Ji(n,e=oe.ServerConnection.makeSettings()){var t;let s=Sn(e.baseUrl,n),r={method:"DELETE"},i=await oe.ServerConnection.makeRequest(s,r,e);if(i.status===404){let a=(t=(await i.json()).message)!==null&&t!==void 0?t:`The session "${n}"" does not exist on the server`;console.warn(a)}else{if(i.status===410)throw new oe.ServerConnection.ResponseError(i,"The kernel was deleted but the session was not");if(i.status!==204)throw await oe.ServerConnection.ResponseError.create(i)}}async function Gi(n,e=oe.ServerConnection.makeSettings()){let t=Sn(e.baseUrl,n),s=await oe.ServerConnection.makeRequest(t,{},e);if(s.status!==200)throw await oe.ServerConnection.ResponseError.create(s);let r=await s.json();return(0,Be.updateLegacySessionModel)(r),(0,Be.validateModel)(r),r}async function Xi(n,e=oe.ServerConnection.makeSettings()){let t=wn.URLExt.join(e.baseUrl,_e.SESSION_SERVICE_URL),s={method:"POST",body:JSON.stringify(n)},r=await oe.ServerConnection.makeRequest(t,s,e);if(r.status!==201)throw await oe.ServerConnection.ResponseError.create(r);let i=await r.json();return(0,Be.updateLegacySessionModel)(i),(0,Be.validateModel)(i),i}async function Yi(n,e=oe.ServerConnection.makeSettings()){let t=Sn(e.baseUrl,n.id),s={method:"PATCH",body:JSON.stringify(n)},r=await oe.ServerConnection.makeRequest(t,s,e);if(r.status!==200)throw await oe.ServerConnection.ResponseError.create(r);let i=await r.json();return(0,Be.updateLegacySessionModel)(i),(0,Be.validateModel)(i),i}var qs=class{constructor(e){var t;this.serverSettings=(t=e.serverSettings)!==null&&t!==void 0?t:oe.ServerConnection.makeSettings()}async listRunning(){return Hi(this.serverSettings)}async getModel(e){return Gi(e,this.serverSettings)}async startNew(e){return Xi(e,this.serverSettings)}async shutdown(e){return Ji(e,this.serverSettings)}async update(e){return Yi(e,this.serverSettings)}};_e.SessionAPIClient=qs});var Qi=R(Cn=>{"use strict";Object.defineProperty(Cn,"__esModule",{value:!0});Cn.SessionConnection=void 0;var Te=ee(),gc=Ae(),mc=Z(),vc=bn(),Ts=class{constructor(e){var t,s,r,i,o;this._id="",this._path="",this._name="",this._type="",this._kernel=null,this._isDisposed=!1,this._disposed=new Te.Signal(this),this._kernelChanged=new Te.Signal(this),this._statusChanged=new Te.Signal(this),this._connectionStatusChanged=new Te.Signal(this),this._pendingInput=new Te.Signal(this),this._iopubMessage=new Te.Signal(this),this._unhandledMessage=new Te.Signal(this),this._anyMessage=new Te.Signal(this),this._propertyChanged=new Te.Signal(this),this._id=e.model.id,this._name=e.model.name,this._path=e.model.path,this._type=e.model.type,this._username=(t=e.username)!==null&&t!==void 0?t:"",this._clientId=(s=e.clientId)!==null&&s!==void 0?s:mc.UUID.uuid4(),this._connectToKernel=e.connectToKernel,this._kernelConnectionOptions=(r=e.kernelConnectionOptions)!==null&&r!==void 0?r:{},this.serverSettings=(i=e.serverSettings)!==null&&i!==void 0?i:gc.ServerConnection.makeSettings(),this._sessionAPIClient=(o=e.sessionAPIClient)!==null&&o!==void 0?o:new vc.SessionAPIClient({serverSettings:this.serverSettings}),this.setupKernel(e.model.kernel)}get disposed(){return this._disposed}get kernelChanged(){return this._kernelChanged}get statusChanged(){return this._statusChanged}get connectionStatusChanged(){return this._connectionStatusChanged}get pendingInput(){return this._pendingInput}get iopubMessage(){return this._iopubMessage}get unhandledMessage(){return this._unhandledMessage}get anyMessage(){return this._anyMessage}get propertyChanged(){return this._propertyChanged}get id(){return this._id}get kernel(){return this._kernel}get path(){return this._path}get type(){return this._type}get name(){return this._name}get model(){return{id:this.id,kernel:this.kernel&&{id:this.kernel.id,name:this.kernel.name},path:this._path,type:this._type,name:this._name}}get isDisposed(){return this._isDisposed}update(e){let t=this.model;if(this._path=e.path,this._name=e.name,this._type=e.type,this._kernel===null&&e.kernel!==null||this._kernel!==null&&e.kernel===null||this._kernel!==null&&e.kernel!==null&&this._kernel.id!==e.kernel.id){this._kernel!==null&&this._kernel.dispose();let s=this._kernel||null;this.setupKernel(e.kernel);let r=this._kernel||null;this._kernelChanged.emit({name:"kernel",oldValue:s,newValue:r})}this._handleModelChange(t)}dispose(){if(!this.isDisposed){if(this._isDisposed=!0,this._disposed.emit(),this._kernel){this._kernel.dispose();let e=this._kernel;this._kernel=null;let t=this._kernel;this._kernelChanged.emit({name:"kernel",oldValue:e,newValue:t})}Te.Signal.clearData(this)}}async setPath(e){if(this.isDisposed)throw new Error("Session is disposed");await this._patch({path:e})}async setName(e){if(this.isDisposed)throw new Error("Session is disposed");await this._patch({name:e})}async setType(e){if(this.isDisposed)throw new Error("Session is disposed");await this._patch({type:e})}async changeKernel(e){if(this.isDisposed)throw new Error("Session is disposed");return await this._patch({kernel:e}),this.kernel}async shutdown(){if(this.isDisposed)throw new Error("Session is disposed");await this._sessionAPIClient.shutdown(this.id),this.dispose()}setupKernel(e){if(e===null){this._kernel=null;return}let t=this._connectToKernel({...this._kernelConnectionOptions,model:e,username:this._username,clientId:this._clientId,serverSettings:this.serverSettings});this._kernel=t,t.statusChanged.connect(this.onKernelStatus,this),t.connectionStatusChanged.connect(this.onKernelConnectionStatus,this),t.pendingInput.connect(this.onPendingInput,this),t.unhandledMessage.connect(this.onUnhandledMessage,this),t.iopubMessage.connect(this.onIOPubMessage,this),t.anyMessage.connect(this.onAnyMessage,this)}onKernelStatus(e,t){this._statusChanged.emit(t)}onKernelConnectionStatus(e,t){this._connectionStatusChanged.emit(t)}onPendingInput(e,t){this._pendingInput.emit(t)}onIOPubMessage(e,t){this._iopubMessage.emit(t)}onUnhandledMessage(e,t){this._unhandledMessage.emit(t)}onAnyMessage(e,t){this._anyMessage.emit(t)}async _patch(e){let t=await this._sessionAPIClient.update({...e,id:this._id});return this.update(t),t}_handleModelChange(e){e.name!==this._name&&this._propertyChanged.emit("name"),e.type!==this._type&&this._propertyChanged.emit("type"),e.path!==this._path&&this._propertyChanged.emit("path")}};Cn.SessionConnection=Ts});var eo=R(wt=>{"use strict";Object.defineProperty(wt,"__esModule",{value:!0});wt.SessionManager=void 0;var yc=He(),Zi=ee(),wc=he(),Sc=$e(),bc=Qi(),Cc=bn(),yt=class extends Sc.BaseManager{constructor(e){var t,s;super(e),this._isReady=!1,this._sessionConnections=new Set,this._models=new Map,this._runningChanged=new Zi.Signal(this),this._connectionFailure=new Zi.Signal(this),this._connectToKernel=r=>this._kernelManager.connectTo(r),this._kernelManager=e.kernelManager,this._sessionAPIClient=(t=e.sessionAPIClient)!==null&&t!==void 0?t:new Cc.SessionAPIClient({serverSettings:e.serverSettings}),this._pollModels=new yc.Poll({auto:!1,factory:()=>this.requestRunning(),frequency:{interval:10*1e3,backoff:!0,max:300*1e3},name:"@jupyterlab/services:SessionManager#models",standby:(s=e.standby)!==null&&s!==void 0?s:"when-hidden"}),this._ready=(async()=>{await this._pollModels.start(),await this._pollModels.tick,this._kernelManager.isActive&&await this._kernelManager.ready,this._isReady=!0})()}get isReady(){return this._isReady}get ready(){return this._ready}get runningChanged(){return this._runningChanged}get connectionFailure(){return this._connectionFailure}dispose(){this.isDisposed||(this._models.clear(),this._sessionConnections.forEach(e=>e.dispose()),this._pollModels.dispose(),super.dispose())}connectTo(e){let t=new bc.SessionConnection({...e,connectToKernel:this._connectToKernel,serverSettings:this.serverSettings,sessionAPIClient:this._sessionAPIClient});return this._onStarted(t),this._models.has(e.model.id)||this.refreshRunning().catch(()=>{}),t}running(){return this._models.values()}async refreshRunning(){await this._pollModels.refresh(),await this._pollModels.tick}async startNew(e,t={}){let s=await this._sessionAPIClient.startNew(e);return await this.refreshRunning(),this.connectTo({...t,model:s})}async shutdown(e){await this._sessionAPIClient.shutdown(e),await this.refreshRunning()}async shutdownAll(){await this.refreshRunning(),await Promise.all([...this._models.keys()].map(e=>this._sessionAPIClient.shutdown(e))),await this.refreshRunning()}async stopIfNeeded(e){try{let s=(await this._sessionAPIClient.listRunning()).filter(r=>r.path===e);if(s.length===1){let r=s[0].id;await this.shutdown(r)}}catch{}}async findById(e){return this._models.has(e)?this._models.get(e):(await this.refreshRunning(),this._models.get(e))}async findByPath(e){for(let t of this._models.values())if(t.path===e)return t;await this.refreshRunning();for(let t of this._models.values())if(t.path===e)return t}async requestRunning(){var e,t;let s;try{s=await this._sessionAPIClient.listRunning()}catch(r){throw(r instanceof wc.ServerConnection.NetworkError||((e=r.response)===null||e===void 0?void 0:e.status)===503||((t=r.response)===null||t===void 0?void 0:t.status)===424)&&this._connectionFailure.emit(r),r}this.isDisposed||this._models.size===s.length&&s.every(r=>{var i,o,a,h;let c=this._models.get(r.id);return c?((i=c.kernel)===null||i===void 0?void 0:i.id)===((o=r.kernel)===null||o===void 0?void 0:o.id)&&((a=c.kernel)===null||a===void 0?void 0:a.name)===((h=r.kernel)===null||h===void 0?void 0:h.name)&&c.name===r.name&&c.path===r.path&&c.type===r.type:!1})||(this._models=new Map(s.map(r=>[r.id,r])),this._sessionConnections.forEach(r=>{this._models.has(r.id)?r.update(this._models.get(r.id)):r.dispose()}),this._runningChanged.emit(s))}_onStarted(e){this._sessionConnections.add(e),e.disposed.connect(this._onDisposed,this),e.propertyChanged.connect(this._onChanged,this),e.kernelChanged.connect(this._onChanged,this)}_onDisposed(e){this._sessionConnections.delete(e),this.refreshRunning().catch(()=>{})}_onChanged(){this.refreshRunning().catch(()=>{})}};wt.SessionManager=yt;(function(n){class e extends n{constructor(){super(...arguments),this._readyPromise=new Promise(()=>{})}get isActive(){return!1}get parentReady(){return super.ready}async startNew(s,r={}){return Promise.reject(new Error("Not implemented in no-op Session Manager"))}connectTo(s){throw Error("Not implemented in no-op Session Manager")}get ready(){return this.parentReady.then(()=>this._readyPromise)}async shutdown(s){return Promise.reject(new Error("Not implemented in no-op Session Manager"))}async requestRunning(){return Promise.resolve()}}n.NoopManager=e})(yt||(wt.SessionManager=yt={}))});var js=R(pe=>{"use strict";var to=pe&&pe.__createBinding||(Object.create?function(n,e,t,s){s===void 0&&(s=t);var r=Object.getOwnPropertyDescriptor(e,t);(!r||("get"in r?!e.__esModule:r.writable||r.configurable))&&(r={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(n,s,r)}:function(n,e,t,s){s===void 0&&(s=t),n[s]=e[t]}),Pc=pe&&pe.__setModuleDefault||(Object.create?function(n,e){Object.defineProperty(n,"default",{enumerable:!0,value:e})}:function(n,e){n.default=e}),no=pe&&pe.__importStar||function(n){if(n&&n.__esModule)return n;var e={};if(n!=null)for(var t in n)t!=="default"&&Object.prototype.hasOwnProperty.call(n,t)&&to(e,n,t);return Pc(e,n),e},Mc=pe&&pe.__exportStar||function(n,e){for(var t in n)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&to(e,n,t)};Object.defineProperty(pe,"__esModule",{value:!0});pe.SessionAPI=pe.Session=void 0;var Ec=no(Bi());pe.Session=Ec;var Ic=no(bn());pe.SessionAPI=Ic;Mc(eo(),pe)});var so=R(Pn=>{"use strict";Object.defineProperty(Pn,"__esModule",{value:!0});Pn.DataConnector=void 0;var Us=class{async list(e){throw new Error("DataConnector#list method has not been implemented.")}async remove(e){throw new Error("DataConnector#remove method has not been implemented.")}async save(e,t){throw new Error("DataConnector#save method has not been implemented.")}};Pn.DataConnector=Us});var io=R(ro=>{"use strict";Object.defineProperty(ro,"__esModule",{value:!0})});var ao=R((Mn,oo)=>{(function(n,e){typeof Mn=="object"&&typeof oo!="undefined"?e(Mn):typeof define=="function"&&define.amd?define(["exports"],e):(n=typeof globalThis!="undefined"?globalThis:n||self,e(n.lumino_properties={}))})(Mn,function(n){"use strict";class e{constructor(r){this._pid=t.nextPID(),this.name=r.name,this._create=r.create,this._coerce=r.coerce||null,this._compare=r.compare||null,this._changed=r.changed||null}get(r){let i,o=t.ensureMap(r);return this._pid in o?i=o[this._pid]:i=o[this._pid]=this._createValue(r),i}set(r,i){let o,a=t.ensureMap(r);this._pid in a?o=a[this._pid]:o=a[this._pid]=this._createValue(r);let h=this._coerceValue(r,i);this._maybeNotify(r,o,a[this._pid]=h)}coerce(r){let i,o=t.ensureMap(r);this._pid in o?i=o[this._pid]:i=o[this._pid]=this._createValue(r);let a=this._coerceValue(r,i);this._maybeNotify(r,i,o[this._pid]=a)}_createValue(r){let i=this._create;return i(r)}_coerceValue(r,i){let o=this._coerce;return o?o(r,i):i}_compareValue(r,i){let o=this._compare;return o?o(r,i):r===i}_maybeNotify(r,i,o){let a=this._changed;a&&!this._compareValue(i,o)&&a(r,i,o)}}(function(s){function r(i){t.ownerData.delete(i)}s.clearData=r})(e||(e={}));var t;(function(s){s.ownerData=new WeakMap,s.nextPID=(()=>{let i=0;return()=>`pid-${`${Math.random()}`.slice(2)}-${i++}`})();function r(i){let o=s.ownerData.get(i);return o||(o=Object.create(null),s.ownerData.set(i,o),o)}s.ensureMap=r})(t||(t={})),n.AttachedProperty=e})});var co=R(In=>{"use strict";Object.defineProperty(In,"__esModule",{value:!0});In.RestorablePool=void 0;var Rc=Z(),lo=ao(),En=ee(),As=class{constructor(e){this._added=new En.Signal(this),this._current=null,this._currentChanged=new En.Signal(this),this._hasRestored=!1,this._isDisposed=!1,this._objects=new Set,this._restore=null,this._restored=new Rc.PromiseDelegate,this._updated=new En.Signal(this),this.namespace=e.namespace}get added(){return this._added}get current(){return this._current}set current(e){this._current!==e&&e!==null&&this._objects.has(e)&&(this._current=e,this._currentChanged.emit(this._current))}get currentChanged(){return this._currentChanged}get isDisposed(){return this._isDisposed}get restored(){return this._restored.promise}get size(){return this._objects.size}get updated(){return this._updated}async add(e){var t,s;if(e.isDisposed){let r="A disposed object cannot be added.";throw console.warn(r,e),new Error(r)}if(this._objects.has(e)){let r="This object already exists in the pool.";throw console.warn(r,e),new Error(r)}if(this._objects.add(e),e.disposed.connect(this._onInstanceDisposed,this),!je.injectedProperty.get(e)){if(this._restore){let{connector:r}=this._restore,i=this._restore.name(e);if(i){let o=`${this.namespace}:${i}`,a=(s=(t=this._restore).args)===null||s===void 0?void 0:s.call(t,e);je.nameProperty.set(e,o),await r.save(o,{data:a})}}this._added.emit(e)}}dispose(){this.isDisposed||(this._current=null,this._isDisposed=!0,this._objects.clear(),En.Signal.clearData(this))}find(e){let t=this._objects.values();for(let s of t)if(e(s))return s}forEach(e){this._objects.forEach(e)}filter(e){let t=[];return this.forEach(s=>{e(s)&&t.push(s)}),t}inject(e){return je.injectedProperty.set(e,!0),this.add(e)}has(e){return this._objects.has(e)}async restore(e){if(this._hasRestored)throw new Error("This pool has already been restored.");this._hasRestored=!0;let{command:t,connector:s,registry:r,when:i}=e,o=this.namespace,a=i?[s.list(o)].concat(i):[s.list(o)];this._restore=e;let[h]=await Promise.all(a),c=await Promise.all(h.ids.map(async(u,l)=>{let d=h.values[l],v=d&&d.data;return v===void 0?s.remove(u):r.execute(t,v).catch(()=>s.remove(u))}));return this._restored.resolve(),c}async save(e){var t,s;let r=je.injectedProperty.get(e);if(!this._restore||!this.has(e)||r)return;let{connector:i}=this._restore,o=this._restore.name(e),a=je.nameProperty.get(e),h=o?`${this.namespace}:${o}`:"";if(a&&a!==h&&await i.remove(a),je.nameProperty.set(e,h),h){let c=(s=(t=this._restore).args)===null||s===void 0?void 0:s.call(t,e);await i.save(h,{data:c})}a!==h&&this._updated.emit(e)}_onInstanceDisposed(e){if(this._objects.delete(e),e===this._current&&(this._current=null,this._currentChanged.emit(this._current)),je.injectedProperty.get(e)||!this._restore)return;let{connector:t}=this._restore,s=je.nameProperty.get(e);s&&t.remove(s)}};In.RestorablePool=As;var je;(function(n){n.injectedProperty=new lo.AttachedProperty({name:"injected",create:()=>!1}),n.nameProperty=new lo.AttachedProperty({name:"name",create:()=>""})})(je||(je={}))});var uo=R(bt=>{"use strict";Object.defineProperty(bt,"__esModule",{value:!0});bt.StateDB=void 0;var kc=ee(),St=class n{constructor(e={}){this._changed=new kc.Signal(this);let{connector:t,transform:s}=e;this._connector=t||new n.Connector,s?this._ready=s.then(r=>{let{contents:i,type:o}=r;switch(o){case"cancel":return;case"clear":return this._clear();case"merge":return this._merge(i||{});case"overwrite":return this._overwrite(i||{});default:return}}):this._ready=Promise.resolve(void 0)}get changed(){return this._changed}async clear(){await this._ready,await this._clear()}async fetch(e){return await this._ready,this._fetch(e)}async list(e){return await this._ready,this._list(e)}async remove(e){await this._ready,await this._remove(e),this._changed.emit({id:e,type:"remove"})}async save(e,t){await this._ready,await this._save(e,t),this._changed.emit({id:e,type:"save"})}async toJSON(){await this._ready;let{ids:e,values:t}=await this._list();return t.reduce((s,r,i)=>(s[e[i]]=r,s),{})}async _clear(){await Promise.all((await this._list()).ids.map(e=>this._remove(e)))}async _fetch(e){let t=await this._connector.fetch(e);if(t)return JSON.parse(t).v}async _list(e=""){let{ids:t,values:s}=await this._connector.list(e);return{ids:t,values:s.map(r=>JSON.parse(r).v)}}async _merge(e){await Promise.all(Object.keys(e).map(t=>e[t]&&this._save(t,e[t])))}async _overwrite(e){await this._clear(),await this._merge(e)}async _remove(e){return this._connector.remove(e)}async _save(e,t){return this._connector.save(e,JSON.stringify({v:t}))}};bt.StateDB=St;(function(n){class e{constructor(){this._storage={}}async fetch(s){return this._storage[s]}async list(s=""){return Object.keys(this._storage).reduce((r,i)=>((s===""||s===i.split(":")[0])&&(r.ids.push(i),r.values.push(this._storage[i])),r),{ids:[],values:[]})}async remove(s){delete this._storage[s]}async save(s,r){this._storage[s]=r}}n.Connector=e})(St||(bt.StateDB=St={}))});var ho=R(Rn=>{"use strict";Object.defineProperty(Rn,"__esModule",{value:!0});Rn.IStateDB=void 0;var Oc=Z();Rn.IStateDB=new Oc.Token("@jupyterlab/coreutils:IStateDB",`A service for the JupyterLab state database.
8
8
  Use this if you want to store data that will persist across page loads.
9
- See "state database" for more information.`)});var Ji=P(Pe=>{"use strict";var ud=Pe&&Pe.__createBinding||(Object.create?function(i,e,t,n){n===void 0&&(n=t);var s=Object.getOwnPropertyDescriptor(e,t);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(i,n,s)}:function(i,e,t,n){n===void 0&&(n=t),i[n]=e[t]}),It=Pe&&Pe.__exportStar||function(i,e){for(var t in i)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&ud(e,i,t)};Object.defineProperty(Pe,"__esModule",{value:!0});It(ba(),Pe);It(xa(),Pe);It(Ma(),Pe);It(Ea(),Pe);It(Ia(),Pe)});var Yi=P(Nn=>{"use strict";Object.defineProperty(Nn,"__esModule",{value:!0});Nn.SettingManager=void 0;var Hi=J(),pd=Ji(),An=de(),hd="api/settings",Gi=class extends pd.DataConnector{constructor(e={}){var t;super(),this.serverSettings=(t=e.serverSettings)!==null&&t!==void 0?t:An.ServerConnection.makeSettings()}async fetch(e){if(!e)throw new Error("Plugin `id` parameter is required for settings fetch.");let{serverSettings:t}=this,{baseUrl:n,appUrl:s}=t,{makeRequest:r,ResponseError:a}=An.ServerConnection,o=n+s,u=Ot.url(o,e),c=await r(u,{},t);if(c.status!==200)throw await a.create(c);return c.json()}async list(e){var t,n,s,r;let{serverSettings:a}=this,{baseUrl:o,appUrl:u}=a,{makeRequest:c,ResponseError:d}=An.ServerConnection,l=o+u,p=Ot.url(l,"",e==="ids"),v=await c(p,{},a);if(v.status!==200)throw new d(v);let _=await v.json(),I=(n=(t=_==null?void 0:_.settings)===null||t===void 0?void 0:t.map(j=>j.id))!==null&&n!==void 0?n:[],M=[];return e||(M=(r=(s=_==null?void 0:_.settings)===null||s===void 0?void 0:s.map(j=>(j.data={composite:{},user:{}},j)))!==null&&r!==void 0?r:[]),{ids:I,values:M}}async save(e,t){let{serverSettings:n}=this,{baseUrl:s,appUrl:r}=n,{makeRequest:a,ResponseError:o}=An.ServerConnection,u=s+r,c=Ot.url(u,e),d={body:JSON.stringify({raw:t}),method:"PUT"},l=await a(c,d,n);if(l.status!==204)throw new o(l)}};Nn.SettingManager=Gi;var Ot;(function(i){function e(t,n,s){let r=s?Hi.URLExt.objectToQueryString({ids_only:!0}):"",a=Hi.URLExt.join(t,hd),o=Hi.URLExt.join(a,n);if(!o.startsWith(a))throw new Error("Can only be used for workspaces requests");return`${o}${r}`}i.url=e})(Ot||(Ot={}))});var Dt=P(ye=>{"use strict";Object.defineProperty(ye,"__esModule",{value:!0});ye.TerminalAPIClient=ye.TERMINAL_SERVICE_URL=void 0;ye.isAvailable=Zi;ye.startNew=Oa;ye.listRunning=Ra;ye.shutdownTerminal=ja;var Rt=J(),ze=de();ye.TERMINAL_SERVICE_URL="api/terminals";function Zi(){return String(Rt.PageConfig.getOption("terminalsAvailable")).toLowerCase()==="true"}async function Oa(i=ze.ServerConnection.makeSettings(),e,t){jt.errorIfNotAvailable();let n=Rt.URLExt.join(i.baseUrl,ye.TERMINAL_SERVICE_URL),s={method:"POST",body:JSON.stringify({name:e,cwd:t})},r=await ze.ServerConnection.makeRequest(n,s,i);if(r.status!==200)throw await ze.ServerConnection.ResponseError.create(r);return await r.json()}async function Ra(i=ze.ServerConnection.makeSettings()){jt.errorIfNotAvailable();let e=Rt.URLExt.join(i.baseUrl,ye.TERMINAL_SERVICE_URL),t=await ze.ServerConnection.makeRequest(e,{},i);if(t.status!==200)throw await ze.ServerConnection.ResponseError.create(t);let n=await t.json();if(!Array.isArray(n))throw new Error("Invalid terminal list");return n}async function ja(i,e=ze.ServerConnection.makeSettings()){var t;jt.errorIfNotAvailable();let n=Rt.URLExt.join(e.baseUrl,ye.TERMINAL_SERVICE_URL),s=Rt.URLExt.join(n,i);if(!s.startsWith(n))throw new Error("Can only be used for terminal requests");let r={method:"DELETE"},a=await ze.ServerConnection.makeRequest(s,r,e);if(a.status===404){let u=(t=(await a.json()).message)!==null&&t!==void 0?t:`The terminal session "${i}"" does not exist on the server`;console.warn(u)}else if(a.status!==204)throw await ze.ServerConnection.ResponseError.create(a)}var Xi=class{constructor(e={}){var t;this.serverSettings=(t=e.serverSettings)!==null&&t!==void 0?t:ze.ServerConnection.makeSettings()}get isAvailable(){return Zi()}async startNew(e={}){let{name:t,cwd:n}=e;return Oa(this.serverSettings,t,n)}async listRunning(){return Ra(this.serverSettings)}async shutdown(e){return ja(e,this.serverSettings)}};ye.TerminalAPIClient=Xi;var jt;(function(i){function e(){if(!Zi())throw new Error("Terminals Unavailable")}i.errorIfNotAvailable=e})(jt||(jt={}))});var Da=P(Ln=>{"use strict";Object.defineProperty(Ln,"__esModule",{value:!0});Ln.isAvailable=void 0;var fd=Dt();Object.defineProperty(Ln,"isAvailable",{enumerable:!0,get:function(){return fd.isAvailable}})});var Ta=P(Fn=>{"use strict";Object.defineProperty(Fn,"__esModule",{value:!0});Fn.TerminalConnection=void 0;var md=J(),gd=te(),zn=Z(),_d=qe(),vd=Dt(),Qi=class i{constructor(e){var t,n;this._createSocket=()=>{this._errorIfDisposed(),this._clearSocket(),this._updateConnectionStatus("connecting");let s=this._name,r=this.serverSettings,a=md.URLExt.join(r.wsUrl,"terminals","websocket",encodeURIComponent(s)),o=r.token;r.appendToken&&o!==""&&(a=a+`?token=${encodeURIComponent(o)}`),this._ws=new r.WebSocket(a),this._ws.onmessage=this._onWSMessage,this._ws.onclose=this._onWSClose,this._ws.onerror=this._onWSClose},this._onWSMessage=s=>{if(this._isDisposed)return;let r=JSON.parse(s.data);if(r[0]==="disconnect"&&this.dispose(),this._connectionStatus==="connecting"){r[0]==="setup"&&this._updateConnectionStatus("connected");return}this._messageReceived.emit({type:r[0],content:r.slice(1)})},this._onWSClose=s=>{console.warn(`Terminal websocket closed: ${s.code}`),this.isDisposed||this._reconnect()},this._connectionStatus="connecting",this._connectionStatusChanged=new zn.Signal(this),this._isDisposed=!1,this._disposed=new zn.Signal(this),this._messageReceived=new zn.Signal(this),this._reconnectTimeout=null,this._ws=null,this._noOp=()=>{},this._reconnectLimit=7,this._reconnectAttempt=0,this._pendingMessages=[],this._name=e.model.name,this.serverSettings=(t=e.serverSettings)!==null&&t!==void 0?t:_d.ServerConnection.makeSettings(),this._terminalAPIClient=(n=e.terminalAPIClient)!==null&&n!==void 0?n:new vd.TerminalAPIClient({serverSettings:this.serverSettings}),this._createSocket()}get disposed(){return this._disposed}get messageReceived(){return this._messageReceived}get name(){return this._name}get model(){return{name:this._name}}get isDisposed(){return this._isDisposed}dispose(){this._isDisposed||(this._isDisposed=!0,this._disposed.emit(),this._updateConnectionStatus("disconnected"),this._clearSocket(),zn.Signal.clearData(this))}send(e){this._sendMessage(e)}_sendMessage(e,t=!0){if(!(this._isDisposed||!e.content))if(this.connectionStatus==="connected"&&this._ws){let n=[e.type,...e.content];this._ws.send(JSON.stringify(n))}else if(t)this._pendingMessages.push(e);else throw new Error(`Could not send message: ${JSON.stringify(e)}`)}_sendPending(){for(;this.connectionStatus==="connected"&&this._pendingMessages.length>0;)this._sendMessage(this._pendingMessages[0],!1),this._pendingMessages.shift()}reconnect(){this._errorIfDisposed();let e=new gd.PromiseDelegate,t=(n,s)=>{s==="connected"?(e.resolve(),this.connectionStatusChanged.disconnect(t,this)):s==="disconnected"&&(e.reject(new Error("Terminal connection disconnected")),this.connectionStatusChanged.disconnect(t,this))};return this.connectionStatusChanged.connect(t,this),this._reconnectAttempt=0,this._reconnect(),e.promise}_reconnect(){if(this._errorIfDisposed(),clearTimeout(this._reconnectTimeout),this._reconnectAttempt<this._reconnectLimit){this._updateConnectionStatus("connecting");let e=es.getRandomIntInclusive(0,1e3*(Math.pow(2,this._reconnectAttempt)-1));console.error(`Connection lost, reconnecting in ${Math.floor(e/1e3)} seconds.`),this._reconnectTimeout=setTimeout(this._createSocket,e),this._reconnectAttempt+=1}else this._updateConnectionStatus("disconnected");this._clearSocket()}_clearSocket(){this._ws!==null&&(this._ws.onopen=this._noOp,this._ws.onclose=this._noOp,this._ws.onerror=this._noOp,this._ws.onmessage=this._noOp,this._ws.close(),this._ws=null)}async shutdown(){await this._terminalAPIClient.shutdown(this.name),this.dispose()}clone(){return new i({model:this.model,serverSettings:this.serverSettings,terminalAPIClient:this._terminalAPIClient})}_updateConnectionStatus(e){this._connectionStatus!==e&&(this._connectionStatus=e,e!=="connecting"&&(this._reconnectAttempt=0,clearTimeout(this._reconnectTimeout)),e==="connected"&&this._sendPending(),this._connectionStatusChanged.emit(e))}_errorIfDisposed(){if(this.isDisposed)throw new Error("Terminal connection is disposed")}get connectionStatusChanged(){return this._connectionStatusChanged}get connectionStatus(){return this._connectionStatus}};Fn.TerminalConnection=Qi;var es;(function(i){function e(t,n){return t=Math.ceil(t),n=Math.floor(n),Math.floor(Math.random()*(n-t+1))+t}i.getRandomIntInclusive=e})(es||(es={}))});var Ua=P(qt=>{"use strict";Object.defineProperty(qt,"__esModule",{value:!0});qt.TerminalManager=void 0;var yd=Ze(),qa=Z(),wd=qe(),bd=Xe(),Sd=Dt(),xd=Ta(),Tt=class extends bd.BaseManager{constructor(e={}){var t,n;if(super(e),this._isReady=!1,this._names=[],this._terminalConnections=new Set,this._runningChanged=new qa.Signal(this),this._connectionFailure=new qa.Signal(this),this._terminalAPIClient=(t=e.terminalAPIClient)!==null&&t!==void 0?t:new Sd.TerminalAPIClient({serverSettings:this.serverSettings}),!this.isAvailable()){this._ready=Promise.reject("Terminals unavailable"),this._ready.catch(r=>{});return}let s=this._pollModels=new yd.Poll({auto:!1,factory:()=>this.requestRunning(),frequency:{interval:10*1e3,backoff:!0,max:300*1e3},name:"@jupyterlab/services:TerminalManager#models",standby:(n=e.standby)!==null&&n!==void 0?n:"when-hidden"});this._ready=(async()=>{await s.start(),await s.tick,this._isReady=!0})()}get isReady(){return this._isReady}get ready(){return this._ready}get runningChanged(){return this._runningChanged}get connectionFailure(){return this._connectionFailure}dispose(){var e;this.isDisposed||(this._names.length=0,this._terminalConnections.forEach(t=>t.dispose()),(e=this._pollModels)===null||e===void 0||e.dispose(),super.dispose())}isAvailable(){return this._terminalAPIClient.isAvailable}connectTo(e){let t=new xd.TerminalConnection({...e,serverSettings:this.serverSettings,terminalAPIClient:this._terminalAPIClient});return this._onStarted(t),this._names.includes(e.model.name)||this.refreshRunning().catch(()=>{}),t}running(){return this._models[Symbol.iterator]()}async refreshRunning(){this._pollModels&&(await this._pollModels.refresh(),await this._pollModels.tick)}async startNew(e={}){let{name:t,cwd:n}=e,s=await this._terminalAPIClient.startNew({name:t,cwd:n});return await this.refreshRunning(),this.connectTo({model:s})}async shutdown(e){await this._terminalAPIClient.shutdown(e),await this.refreshRunning()}async shutdownAll(){await this.refreshRunning(),await Promise.all(this._names.map(e=>this._terminalAPIClient.shutdown(e))),await this.refreshRunning()}async requestRunning(){var e,t;let n;try{n=await this._terminalAPIClient.listRunning()}catch(r){throw(r instanceof wd.ServerConnection.NetworkError||((e=r.response)===null||e===void 0?void 0:e.status)===503||((t=r.response)===null||t===void 0?void 0:t.status)===424)&&this._connectionFailure.emit(r),r}if(this.isDisposed)return;let s=n.map(({name:r})=>r).sort();s!==this._names&&(this._names=s,this._terminalConnections.forEach(r=>{s.includes(r.name)||r.dispose()}),this._runningChanged.emit(this._models))}_onStarted(e){this._terminalConnections.add(e),e.disposed.connect(this._onDisposed,this)}_onDisposed(e){this._terminalConnections.delete(e),this.refreshRunning().catch(()=>{})}get _models(){return this._names.map(e=>({name:e}))}};qt.TerminalManager=Tt;(function(i){class e extends i{constructor(){super(...arguments),this._readyPromise=new Promise(()=>{})}get isActive(){return!1}get parentReady(){return super.ready}get ready(){return this.parentReady.then(()=>this._readyPromise)}async startNew(n){return Promise.reject(new Error("Not implemented in no-op Terminal Manager"))}connectTo(n){throw Error("Not implemented in no-op Terminal Manager")}async shutdown(n){return Promise.reject(new Error("Not implemented in no-op Terminal Manager"))}async requestRunning(){return Promise.resolve()}}i.NoopManager=e})(Tt||(qt.TerminalManager=Tt={}))});var ts=P(me=>{"use strict";var Aa=me&&me.__createBinding||(Object.create?function(i,e,t,n){n===void 0&&(n=t);var s=Object.getOwnPropertyDescriptor(e,t);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(i,n,s)}:function(i,e,t,n){n===void 0&&(n=t),i[n]=e[t]}),Cd=me&&me.__setModuleDefault||(Object.create?function(i,e){Object.defineProperty(i,"default",{enumerable:!0,value:e})}:function(i,e){i.default=e}),Na=me&&me.__importStar||function(i){if(i&&i.__esModule)return i;var e={};if(i!=null)for(var t in i)t!=="default"&&Object.prototype.hasOwnProperty.call(i,t)&&Aa(e,i,t);return Cd(e,i),e},kd=me&&me.__exportStar||function(i,e){for(var t in i)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&Aa(e,i,t)};Object.defineProperty(me,"__esModule",{value:!0});me.TerminalAPI=me.Terminal=void 0;var Pd=Na(Da());me.Terminal=Pd;var Md=Na(Dt());me.TerminalAPI=Md;kd(Ua(),me)});var za=P(La=>{"use strict";Object.defineProperty(La,"__esModule",{value:!0})});var is=P(Kn=>{"use strict";Object.defineProperty(Kn,"__esModule",{value:!0});Kn.UserAPIClient=void 0;var Fa=de(),Ed=J(),Id="api/me",ns=class{constructor(e={}){var t;this.serverSettings=(t=e.serverSettings)!==null&&t!==void 0?t:Fa.ServerConnection.makeSettings()}async get(){let{baseUrl:e}=this.serverSettings,{makeRequest:t,ResponseError:n}=Fa.ServerConnection,s=Ed.URLExt.join(e,Id),r=await t(s,{},this.serverSettings);if(r.status!==200)throw await n.create(r);return await r.json()}};Kn.UserAPIClient=ns});var Ba=P(Bn=>{"use strict";Object.defineProperty(Bn,"__esModule",{value:!0});Bn.UserManager=void 0;var Od=te(),Rd=Ze(),Ka=Z(),jd=Xe(),Dd=is(),ss="@jupyterlab/services:UserManager#user",rs=class extends jd.BaseManager{constructor(e={}){var t,n;super(e),this._isReady=!1,this._userChanged=new Ka.Signal(this),this._connectionFailure=new Ka.Signal(this),this._userApiClient=(t=e.userApiClient)!==null&&t!==void 0?t:new Dd.UserAPIClient({serverSettings:this.serverSettings}),this._ready=this.requestUser().then(()=>{this.isDisposed||(this._isReady=!0)}).catch(s=>new Promise(()=>{})),this._pollUser=new Rd.Poll({auto:!1,factory:()=>this.requestUser(),frequency:{interval:61*1e3,backoff:!0,max:300*1e3},name:ss,standby:(n=e.standby)!==null&&n!==void 0?n:"when-hidden"}),this.ready.then(()=>{this._pollUser.start()})}get isReady(){return this._isReady}get ready(){return this._ready}get identity(){return this._identity}get permissions(){return this._permissions}get userChanged(){return this._userChanged}get connectionFailure(){return this._connectionFailure}dispose(){this._pollUser.dispose(),super.dispose()}async refreshUser(){await this._pollUser.refresh(),await this._pollUser.tick}async requestUser(){if(this.isDisposed)return;let e={identity:this._identity,permissions:this._permissions},t=await this._userApiClient.get(),n=t.identity,{localStorage:s}=window,r=s.getItem(ss);if(r&&(!n.initials||!n.color)){let a=JSON.parse(r);n.initials=n.initials||a.initials||n.name.substring(0,1),n.color=n.color||a.color||as.getRandomColor()}Od.JSONExt.deepEqual(t,e)||(this._identity=n,this._permissions=t.permissions,s.setItem(ss,JSON.stringify(n)),this._userChanged.emit(t))}};Bn.UserManager=rs;var as;(function(i){let e=["var(--jp-collaborator-color1)","var(--jp-collaborator-color2)","var(--jp-collaborator-color3)","var(--jp-collaborator-color4)","var(--jp-collaborator-color5)","var(--jp-collaborator-color6)","var(--jp-collaborator-color7)"];i.getRandomColor=()=>e[Math.floor(Math.random()*e.length)]})(as||(as={}))});var os=P(ge=>{"use strict";var $a=ge&&ge.__createBinding||(Object.create?function(i,e,t,n){n===void 0&&(n=t);var s=Object.getOwnPropertyDescriptor(e,t);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(i,n,s)}:function(i,e,t,n){n===void 0&&(n=t),i[n]=e[t]}),Td=ge&&ge.__setModuleDefault||(Object.create?function(i,e){Object.defineProperty(i,"default",{enumerable:!0,value:e})}:function(i,e){i.default=e}),Va=ge&&ge.__importStar||function(i){if(i&&i.__esModule)return i;var e={};if(i!=null)for(var t in i)t!=="default"&&Object.prototype.hasOwnProperty.call(i,t)&&$a(e,i,t);return Td(e,i),e},qd=ge&&ge.__exportStar||function(i,e){for(var t in i)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&$a(e,i,t)};Object.defineProperty(ge,"__esModule",{value:!0});ge.UserAPI=ge.User=void 0;var Ud=Va(za());ge.User=Ud;var Ad=Va(is());ge.UserAPI=Ad;qd(Ba(),ge)});var cs=P($n=>{"use strict";Object.defineProperty($n,"__esModule",{value:!0});$n.WorkspaceManager=void 0;var Wa=J(),Nd=Ji(),Ut=de(),Ld="api/workspaces",ls=class extends Nd.DataConnector{constructor(e={}){var t;super(),this.serverSettings=(t=e.serverSettings)!==null&&t!==void 0?t:Ut.ServerConnection.makeSettings()}async fetch(e){let{serverSettings:t}=this,{baseUrl:n,appUrl:s}=t,{makeRequest:r,ResponseError:a}=Ut.ServerConnection,o=n+s,u=ut.url(o,e),c=await r(u,{},t);if(c.status!==200)throw await a.create(c);return c.json()}async list(){let{serverSettings:e}=this,{baseUrl:t,appUrl:n}=e,{makeRequest:s,ResponseError:r}=Ut.ServerConnection,a=t+n,o=ut.url(a,""),u=await s(o,{},e);if(u.status!==200)throw await r.create(u);return(await u.json()).workspaces}async remove(e){let{serverSettings:t}=this,{baseUrl:n,appUrl:s}=t,{makeRequest:r,ResponseError:a}=Ut.ServerConnection,o=n+s,u=ut.url(o,e),d=await r(u,{method:"DELETE"},t);if(d.status!==204)throw await a.create(d)}async save(e,t){let{serverSettings:n}=this,{baseUrl:s,appUrl:r}=n,{makeRequest:a,ResponseError:o}=Ut.ServerConnection,u=s+r,c=ut.url(u,e),d={body:JSON.stringify(t),method:"PUT"},l=await a(c,d,n);if(l.status!==204)throw await o.create(l)}};$n.WorkspaceManager=ls;var ut;(function(i){function e(t,n){let s=Wa.URLExt.join(t,Ld),r=Wa.URLExt.join(s,n);if(!r.startsWith(s))throw new Error("Can only be used for workspaces requests");return r}i.url=e})(ut||(ut={}))});var Ha=P(Vn=>{"use strict";Object.defineProperty(Vn,"__esModule",{value:!0});Vn.ServiceManager=void 0;var Ja=Z(),zd=aa(),Fd=Si(),Kd=Ci(),Bd=Di(),$d=qi(),Vd=Fi(),Wd=de(),Jd=$i(),Hd=Yi(),Gd=ts(),Yd=os(),Xd=cs(),ds=class{constructor(e={}){var t,n;this._isDisposed=!1,this._connectionFailure=new Ja.Signal(this),this._isReady=!1;let s=e.defaultDrive,r=(t=e.serverSettings)!==null&&t!==void 0?t:Wd.ServerConnection.makeSettings(),a=(n=e.standby)!==null&&n!==void 0?n:"when-hidden",o={defaultDrive:s,serverSettings:r,standby:a};this.serverSettings=r,this.contents=e.contents||new Fd.ContentsManager(o),this.events=e.events||new Kd.EventManager(o),this.kernels=e.kernels||new Bd.KernelManager(o),this.sessions=e.sessions||new Jd.SessionManager({...o,kernelManager:this.kernels}),this.settings=e.settings||new Hd.SettingManager(o),this.terminals=e.terminals||new Gd.TerminalManager(o),this.builder=e.builder||new zd.BuildManager(o),this.workspaces=e.workspaces||new Xd.WorkspaceManager(o),this.nbconvert=e.nbconvert||new Vd.NbConvertManager(o),this.kernelspecs=e.kernelspecs||new $d.KernelSpecManager(o),this.user=e.user||new Yd.UserManager(o),this.kernelspecs.connectionFailure.connect(this._onConnectionFailure,this),this.sessions.connectionFailure.connect(this._onConnectionFailure,this),this.terminals.connectionFailure.connect(this._onConnectionFailure,this);let u=[this.sessions.ready,this.kernelspecs.ready];this.terminals.isAvailable()&&u.push(this.terminals.ready),this._readyPromise=Promise.all(u).then(()=>{this._isReady=!0})}get connectionFailure(){return this._connectionFailure}get isDisposed(){return this._isDisposed}dispose(){this.isDisposed||(this._isDisposed=!0,Ja.Signal.clearData(this),this.contents.dispose(),this.events.dispose(),this.sessions.dispose(),this.terminals.dispose())}get isReady(){return this._isReady}get ready(){return this._readyPromise}_onConnectionFailure(e,t){this._connectionFailure.emit(t)}};Vn.ServiceManager=ds});var Ga=P(L=>{"use strict";Object.defineProperty(L,"__esModule",{value:!0});L.IWorkspaceManager=L.IUserManager=L.ITerminalManager=L.IServiceManager=L.ISettingManager=L.ISessionManager=L.IServerSettings=L.INbConvertManager=L.IKernelSpecManager=L.IKernelManager=L.IEventManager=L.IDefaultDrive=L.IContentsManager=L.IConfigSectionManager=L.IConnectionStatus=void 0;var _e=te();L.IConnectionStatus=new _e.Token("@jupyterlab/application:IConnectionStatus","A service providing the application connection status.");L.IConfigSectionManager=new _e.Token("@jupyterlab/services:IConfigSectionManager","A service providing the config section manager.");L.IContentsManager=new _e.Token("@jupyterlab/services:IContentsManager","The contents manager token.");L.IDefaultDrive=new _e.Token("@jupyterlab/services:IDefaultDrive","The default drive for the contents manager.");L.IEventManager=new _e.Token("@jupyterlab/services:IEventManager","The event manager token.");L.IKernelManager=new _e.Token("@jupyterlab/services:IKernelManager","The kernel manager token.");L.IKernelSpecManager=new _e.Token("@jupyterlab/services:IKernelSpecManager","The kernel spec manager token.");L.INbConvertManager=new _e.Token("@jupyterlab/services:INbConvertManager","The nbconvert manager token.");L.IServerSettings=new _e.Token("@jupyterlab/services:IServerSettings","The server settings for the application.");L.ISessionManager=new _e.Token("@jupyterlab/services:ISessionManager","The session manager token.");L.ISettingManager=new _e.Token("@jupyterlab/services:ISettingManager","The setting manager token.");L.IServiceManager=new _e.Token("@jupyterlab/services:IServiceManager","The service manager for the application.");L.ITerminalManager=new _e.Token("@jupyterlab/services:ITerminalManager","The terminal manager token.");L.IUserManager=new _e.Token("@jupyterlab/services:IUserManager","The user manager token.");L.IWorkspaceManager=new _e.Token("@jupyterlab/services:IWorkspaceManager","The workspace manager token.")});var qe=P(W=>{"use strict";var Zd=W&&W.__createBinding||(Object.create?function(i,e,t,n){n===void 0&&(n=t);var s=Object.getOwnPropertyDescriptor(e,t);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(i,n,s)}:function(i,e,t,n){n===void 0&&(n=t),i[n]=e[t]}),le=W&&W.__exportStar||function(i,e){for(var t in i)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&Zd(e,i,t)};Object.defineProperty(W,"__esModule",{value:!0});le(Xe(),W);le(wr(),W);le(br(),W);le(Si(),W);le(Ci(),W);le(Di(),W);le(qi(),W);le(Ha(),W);le(de(),W);le($i(),W);le(Yi(),W);le(ts(),W);le(Ga(),W);le(os(),W);le(cs(),W);le(Fi(),W)});var Xa=P((vp,Ya)=>{"use strict";function Wn(){this._types=Object.create(null),this._extensions=Object.create(null);for(let i=0;i<arguments.length;i++)this.define(arguments[i]);this.define=this.define.bind(this),this.getType=this.getType.bind(this),this.getExtension=this.getExtension.bind(this)}Wn.prototype.define=function(i,e){for(let t in i){let n=i[t].map(function(s){return s.toLowerCase()});t=t.toLowerCase();for(let s=0;s<n.length;s++){let r=n[s];if(r[0]!=="*"){if(!e&&r in this._types)throw new Error('Attempt to change mapping for "'+r+'" extension from "'+this._types[r]+'" to "'+t+'". Pass `force=true` to allow this, otherwise remove "'+r+'" from the list of extensions for "'+t+'".');this._types[r]=t}}if(e||!this._extensions[t]){let s=n[0];this._extensions[t]=s[0]!=="*"?s:s.substr(1)}}};Wn.prototype.getType=function(i){i=String(i);let e=i.replace(/^.*[/\\]/,"").toLowerCase(),t=e.replace(/^.*\./,"").toLowerCase(),n=e.length<i.length;return(t.length<e.length-1||!n)&&this._types[t]||null};Wn.prototype.getExtension=function(i){return i=/^\s*([^;\s]*)/.test(i)&&RegExp.$1,i&&this._extensions[i.toLowerCase()]||null};Ya.exports=Wn});var Qa=P((yp,Za)=>{Za.exports={"application/andrew-inset":["ez"],"application/applixware":["aw"],"application/atom+xml":["atom"],"application/atomcat+xml":["atomcat"],"application/atomdeleted+xml":["atomdeleted"],"application/atomsvc+xml":["atomsvc"],"application/atsc-dwd+xml":["dwd"],"application/atsc-held+xml":["held"],"application/atsc-rsat+xml":["rsat"],"application/bdoc":["bdoc"],"application/calendar+xml":["xcs"],"application/ccxml+xml":["ccxml"],"application/cdfx+xml":["cdfx"],"application/cdmi-capability":["cdmia"],"application/cdmi-container":["cdmic"],"application/cdmi-domain":["cdmid"],"application/cdmi-object":["cdmio"],"application/cdmi-queue":["cdmiq"],"application/cu-seeme":["cu"],"application/dash+xml":["mpd"],"application/davmount+xml":["davmount"],"application/docbook+xml":["dbk"],"application/dssc+der":["dssc"],"application/dssc+xml":["xdssc"],"application/ecmascript":["es","ecma"],"application/emma+xml":["emma"],"application/emotionml+xml":["emotionml"],"application/epub+zip":["epub"],"application/exi":["exi"],"application/express":["exp"],"application/fdt+xml":["fdt"],"application/font-tdpfr":["pfr"],"application/geo+json":["geojson"],"application/gml+xml":["gml"],"application/gpx+xml":["gpx"],"application/gxf":["gxf"],"application/gzip":["gz"],"application/hjson":["hjson"],"application/hyperstudio":["stk"],"application/inkml+xml":["ink","inkml"],"application/ipfix":["ipfix"],"application/its+xml":["its"],"application/java-archive":["jar","war","ear"],"application/java-serialized-object":["ser"],"application/java-vm":["class"],"application/javascript":["js","mjs"],"application/json":["json","map"],"application/json5":["json5"],"application/jsonml+json":["jsonml"],"application/ld+json":["jsonld"],"application/lgr+xml":["lgr"],"application/lost+xml":["lostxml"],"application/mac-binhex40":["hqx"],"application/mac-compactpro":["cpt"],"application/mads+xml":["mads"],"application/manifest+json":["webmanifest"],"application/marc":["mrc"],"application/marcxml+xml":["mrcx"],"application/mathematica":["ma","nb","mb"],"application/mathml+xml":["mathml"],"application/mbox":["mbox"],"application/mediaservercontrol+xml":["mscml"],"application/metalink+xml":["metalink"],"application/metalink4+xml":["meta4"],"application/mets+xml":["mets"],"application/mmt-aei+xml":["maei"],"application/mmt-usd+xml":["musd"],"application/mods+xml":["mods"],"application/mp21":["m21","mp21"],"application/mp4":["mp4s","m4p"],"application/msword":["doc","dot"],"application/mxf":["mxf"],"application/n-quads":["nq"],"application/n-triples":["nt"],"application/node":["cjs"],"application/octet-stream":["bin","dms","lrf","mar","so","dist","distz","pkg","bpk","dump","elc","deploy","exe","dll","deb","dmg","iso","img","msi","msp","msm","buffer"],"application/oda":["oda"],"application/oebps-package+xml":["opf"],"application/ogg":["ogx"],"application/omdoc+xml":["omdoc"],"application/onenote":["onetoc","onetoc2","onetmp","onepkg"],"application/oxps":["oxps"],"application/p2p-overlay+xml":["relo"],"application/patch-ops-error+xml":["xer"],"application/pdf":["pdf"],"application/pgp-encrypted":["pgp"],"application/pgp-signature":["asc","sig"],"application/pics-rules":["prf"],"application/pkcs10":["p10"],"application/pkcs7-mime":["p7m","p7c"],"application/pkcs7-signature":["p7s"],"application/pkcs8":["p8"],"application/pkix-attr-cert":["ac"],"application/pkix-cert":["cer"],"application/pkix-crl":["crl"],"application/pkix-pkipath":["pkipath"],"application/pkixcmp":["pki"],"application/pls+xml":["pls"],"application/postscript":["ai","eps","ps"],"application/provenance+xml":["provx"],"application/pskc+xml":["pskcxml"],"application/raml+yaml":["raml"],"application/rdf+xml":["rdf","owl"],"application/reginfo+xml":["rif"],"application/relax-ng-compact-syntax":["rnc"],"application/resource-lists+xml":["rl"],"application/resource-lists-diff+xml":["rld"],"application/rls-services+xml":["rs"],"application/route-apd+xml":["rapd"],"application/route-s-tsid+xml":["sls"],"application/route-usd+xml":["rusd"],"application/rpki-ghostbusters":["gbr"],"application/rpki-manifest":["mft"],"application/rpki-roa":["roa"],"application/rsd+xml":["rsd"],"application/rss+xml":["rss"],"application/rtf":["rtf"],"application/sbml+xml":["sbml"],"application/scvp-cv-request":["scq"],"application/scvp-cv-response":["scs"],"application/scvp-vp-request":["spq"],"application/scvp-vp-response":["spp"],"application/sdp":["sdp"],"application/senml+xml":["senmlx"],"application/sensml+xml":["sensmlx"],"application/set-payment-initiation":["setpay"],"application/set-registration-initiation":["setreg"],"application/shf+xml":["shf"],"application/sieve":["siv","sieve"],"application/smil+xml":["smi","smil"],"application/sparql-query":["rq"],"application/sparql-results+xml":["srx"],"application/srgs":["gram"],"application/srgs+xml":["grxml"],"application/sru+xml":["sru"],"application/ssdl+xml":["ssdl"],"application/ssml+xml":["ssml"],"application/swid+xml":["swidtag"],"application/tei+xml":["tei","teicorpus"],"application/thraud+xml":["tfi"],"application/timestamped-data":["tsd"],"application/toml":["toml"],"application/trig":["trig"],"application/ttml+xml":["ttml"],"application/ubjson":["ubj"],"application/urc-ressheet+xml":["rsheet"],"application/urc-targetdesc+xml":["td"],"application/voicexml+xml":["vxml"],"application/wasm":["wasm"],"application/widget":["wgt"],"application/winhlp":["hlp"],"application/wsdl+xml":["wsdl"],"application/wspolicy+xml":["wspolicy"],"application/xaml+xml":["xaml"],"application/xcap-att+xml":["xav"],"application/xcap-caps+xml":["xca"],"application/xcap-diff+xml":["xdf"],"application/xcap-el+xml":["xel"],"application/xcap-ns+xml":["xns"],"application/xenc+xml":["xenc"],"application/xhtml+xml":["xhtml","xht"],"application/xliff+xml":["xlf"],"application/xml":["xml","xsl","xsd","rng"],"application/xml-dtd":["dtd"],"application/xop+xml":["xop"],"application/xproc+xml":["xpl"],"application/xslt+xml":["*xsl","xslt"],"application/xspf+xml":["xspf"],"application/xv+xml":["mxml","xhvml","xvml","xvm"],"application/yang":["yang"],"application/yin+xml":["yin"],"application/zip":["zip"],"audio/3gpp":["*3gpp"],"audio/adpcm":["adp"],"audio/amr":["amr"],"audio/basic":["au","snd"],"audio/midi":["mid","midi","kar","rmi"],"audio/mobile-xmf":["mxmf"],"audio/mp3":["*mp3"],"audio/mp4":["m4a","mp4a"],"audio/mpeg":["mpga","mp2","mp2a","mp3","m2a","m3a"],"audio/ogg":["oga","ogg","spx","opus"],"audio/s3m":["s3m"],"audio/silk":["sil"],"audio/wav":["wav"],"audio/wave":["*wav"],"audio/webm":["weba"],"audio/xm":["xm"],"font/collection":["ttc"],"font/otf":["otf"],"font/ttf":["ttf"],"font/woff":["woff"],"font/woff2":["woff2"],"image/aces":["exr"],"image/apng":["apng"],"image/avif":["avif"],"image/bmp":["bmp"],"image/cgm":["cgm"],"image/dicom-rle":["drle"],"image/emf":["emf"],"image/fits":["fits"],"image/g3fax":["g3"],"image/gif":["gif"],"image/heic":["heic"],"image/heic-sequence":["heics"],"image/heif":["heif"],"image/heif-sequence":["heifs"],"image/hej2k":["hej2"],"image/hsj2":["hsj2"],"image/ief":["ief"],"image/jls":["jls"],"image/jp2":["jp2","jpg2"],"image/jpeg":["jpeg","jpg","jpe"],"image/jph":["jph"],"image/jphc":["jhc"],"image/jpm":["jpm"],"image/jpx":["jpx","jpf"],"image/jxr":["jxr"],"image/jxra":["jxra"],"image/jxrs":["jxrs"],"image/jxs":["jxs"],"image/jxsc":["jxsc"],"image/jxsi":["jxsi"],"image/jxss":["jxss"],"image/ktx":["ktx"],"image/ktx2":["ktx2"],"image/png":["png"],"image/sgi":["sgi"],"image/svg+xml":["svg","svgz"],"image/t38":["t38"],"image/tiff":["tif","tiff"],"image/tiff-fx":["tfx"],"image/webp":["webp"],"image/wmf":["wmf"],"message/disposition-notification":["disposition-notification"],"message/global":["u8msg"],"message/global-delivery-status":["u8dsn"],"message/global-disposition-notification":["u8mdn"],"message/global-headers":["u8hdr"],"message/rfc822":["eml","mime"],"model/3mf":["3mf"],"model/gltf+json":["gltf"],"model/gltf-binary":["glb"],"model/iges":["igs","iges"],"model/mesh":["msh","mesh","silo"],"model/mtl":["mtl"],"model/obj":["obj"],"model/step+xml":["stpx"],"model/step+zip":["stpz"],"model/step-xml+zip":["stpxz"],"model/stl":["stl"],"model/vrml":["wrl","vrml"],"model/x3d+binary":["*x3db","x3dbz"],"model/x3d+fastinfoset":["x3db"],"model/x3d+vrml":["*x3dv","x3dvz"],"model/x3d+xml":["x3d","x3dz"],"model/x3d-vrml":["x3dv"],"text/cache-manifest":["appcache","manifest"],"text/calendar":["ics","ifb"],"text/coffeescript":["coffee","litcoffee"],"text/css":["css"],"text/csv":["csv"],"text/html":["html","htm","shtml"],"text/jade":["jade"],"text/jsx":["jsx"],"text/less":["less"],"text/markdown":["markdown","md"],"text/mathml":["mml"],"text/mdx":["mdx"],"text/n3":["n3"],"text/plain":["txt","text","conf","def","list","log","in","ini"],"text/richtext":["rtx"],"text/rtf":["*rtf"],"text/sgml":["sgml","sgm"],"text/shex":["shex"],"text/slim":["slim","slm"],"text/spdx":["spdx"],"text/stylus":["stylus","styl"],"text/tab-separated-values":["tsv"],"text/troff":["t","tr","roff","man","me","ms"],"text/turtle":["ttl"],"text/uri-list":["uri","uris","urls"],"text/vcard":["vcard"],"text/vtt":["vtt"],"text/xml":["*xml"],"text/yaml":["yaml","yml"],"video/3gpp":["3gp","3gpp"],"video/3gpp2":["3g2"],"video/h261":["h261"],"video/h263":["h263"],"video/h264":["h264"],"video/iso.segment":["m4s"],"video/jpeg":["jpgv"],"video/jpm":["*jpm","jpgm"],"video/mj2":["mj2","mjp2"],"video/mp2t":["ts"],"video/mp4":["mp4","mp4v","mpg4"],"video/mpeg":["mpeg","mpg","mpe","m1v","m2v"],"video/ogg":["ogv"],"video/quicktime":["qt","mov"],"video/webm":["webm"]}});var to=P((wp,eo)=>{eo.exports={"application/prs.cww":["cww"],"application/vnd.1000minds.decision-model+xml":["1km"],"application/vnd.3gpp.pic-bw-large":["plb"],"application/vnd.3gpp.pic-bw-small":["psb"],"application/vnd.3gpp.pic-bw-var":["pvb"],"application/vnd.3gpp2.tcap":["tcap"],"application/vnd.3m.post-it-notes":["pwn"],"application/vnd.accpac.simply.aso":["aso"],"application/vnd.accpac.simply.imp":["imp"],"application/vnd.acucobol":["acu"],"application/vnd.acucorp":["atc","acutc"],"application/vnd.adobe.air-application-installer-package+zip":["air"],"application/vnd.adobe.formscentral.fcdt":["fcdt"],"application/vnd.adobe.fxp":["fxp","fxpl"],"application/vnd.adobe.xdp+xml":["xdp"],"application/vnd.adobe.xfdf":["xfdf"],"application/vnd.ahead.space":["ahead"],"application/vnd.airzip.filesecure.azf":["azf"],"application/vnd.airzip.filesecure.azs":["azs"],"application/vnd.amazon.ebook":["azw"],"application/vnd.americandynamics.acc":["acc"],"application/vnd.amiga.ami":["ami"],"application/vnd.android.package-archive":["apk"],"application/vnd.anser-web-certificate-issue-initiation":["cii"],"application/vnd.anser-web-funds-transfer-initiation":["fti"],"application/vnd.antix.game-component":["atx"],"application/vnd.apple.installer+xml":["mpkg"],"application/vnd.apple.keynote":["key"],"application/vnd.apple.mpegurl":["m3u8"],"application/vnd.apple.numbers":["numbers"],"application/vnd.apple.pages":["pages"],"application/vnd.apple.pkpass":["pkpass"],"application/vnd.aristanetworks.swi":["swi"],"application/vnd.astraea-software.iota":["iota"],"application/vnd.audiograph":["aep"],"application/vnd.balsamiq.bmml+xml":["bmml"],"application/vnd.blueice.multipass":["mpm"],"application/vnd.bmi":["bmi"],"application/vnd.businessobjects":["rep"],"application/vnd.chemdraw+xml":["cdxml"],"application/vnd.chipnuts.karaoke-mmd":["mmd"],"application/vnd.cinderella":["cdy"],"application/vnd.citationstyles.style+xml":["csl"],"application/vnd.claymore":["cla"],"application/vnd.cloanto.rp9":["rp9"],"application/vnd.clonk.c4group":["c4g","c4d","c4f","c4p","c4u"],"application/vnd.cluetrust.cartomobile-config":["c11amc"],"application/vnd.cluetrust.cartomobile-config-pkg":["c11amz"],"application/vnd.commonspace":["csp"],"application/vnd.contact.cmsg":["cdbcmsg"],"application/vnd.cosmocaller":["cmc"],"application/vnd.crick.clicker":["clkx"],"application/vnd.crick.clicker.keyboard":["clkk"],"application/vnd.crick.clicker.palette":["clkp"],"application/vnd.crick.clicker.template":["clkt"],"application/vnd.crick.clicker.wordbank":["clkw"],"application/vnd.criticaltools.wbs+xml":["wbs"],"application/vnd.ctc-posml":["pml"],"application/vnd.cups-ppd":["ppd"],"application/vnd.curl.car":["car"],"application/vnd.curl.pcurl":["pcurl"],"application/vnd.dart":["dart"],"application/vnd.data-vision.rdz":["rdz"],"application/vnd.dbf":["dbf"],"application/vnd.dece.data":["uvf","uvvf","uvd","uvvd"],"application/vnd.dece.ttml+xml":["uvt","uvvt"],"application/vnd.dece.unspecified":["uvx","uvvx"],"application/vnd.dece.zip":["uvz","uvvz"],"application/vnd.denovo.fcselayout-link":["fe_launch"],"application/vnd.dna":["dna"],"application/vnd.dolby.mlp":["mlp"],"application/vnd.dpgraph":["dpg"],"application/vnd.dreamfactory":["dfac"],"application/vnd.ds-keypoint":["kpxx"],"application/vnd.dvb.ait":["ait"],"application/vnd.dvb.service":["svc"],"application/vnd.dynageo":["geo"],"application/vnd.ecowin.chart":["mag"],"application/vnd.enliven":["nml"],"application/vnd.epson.esf":["esf"],"application/vnd.epson.msf":["msf"],"application/vnd.epson.quickanime":["qam"],"application/vnd.epson.salt":["slt"],"application/vnd.epson.ssf":["ssf"],"application/vnd.eszigno3+xml":["es3","et3"],"application/vnd.ezpix-album":["ez2"],"application/vnd.ezpix-package":["ez3"],"application/vnd.fdf":["fdf"],"application/vnd.fdsn.mseed":["mseed"],"application/vnd.fdsn.seed":["seed","dataless"],"application/vnd.flographit":["gph"],"application/vnd.fluxtime.clip":["ftc"],"application/vnd.framemaker":["fm","frame","maker","book"],"application/vnd.frogans.fnc":["fnc"],"application/vnd.frogans.ltf":["ltf"],"application/vnd.fsc.weblaunch":["fsc"],"application/vnd.fujitsu.oasys":["oas"],"application/vnd.fujitsu.oasys2":["oa2"],"application/vnd.fujitsu.oasys3":["oa3"],"application/vnd.fujitsu.oasysgp":["fg5"],"application/vnd.fujitsu.oasysprs":["bh2"],"application/vnd.fujixerox.ddd":["ddd"],"application/vnd.fujixerox.docuworks":["xdw"],"application/vnd.fujixerox.docuworks.binder":["xbd"],"application/vnd.fuzzysheet":["fzs"],"application/vnd.genomatix.tuxedo":["txd"],"application/vnd.geogebra.file":["ggb"],"application/vnd.geogebra.tool":["ggt"],"application/vnd.geometry-explorer":["gex","gre"],"application/vnd.geonext":["gxt"],"application/vnd.geoplan":["g2w"],"application/vnd.geospace":["g3w"],"application/vnd.gmx":["gmx"],"application/vnd.google-apps.document":["gdoc"],"application/vnd.google-apps.presentation":["gslides"],"application/vnd.google-apps.spreadsheet":["gsheet"],"application/vnd.google-earth.kml+xml":["kml"],"application/vnd.google-earth.kmz":["kmz"],"application/vnd.grafeq":["gqf","gqs"],"application/vnd.groove-account":["gac"],"application/vnd.groove-help":["ghf"],"application/vnd.groove-identity-message":["gim"],"application/vnd.groove-injector":["grv"],"application/vnd.groove-tool-message":["gtm"],"application/vnd.groove-tool-template":["tpl"],"application/vnd.groove-vcard":["vcg"],"application/vnd.hal+xml":["hal"],"application/vnd.handheld-entertainment+xml":["zmm"],"application/vnd.hbci":["hbci"],"application/vnd.hhe.lesson-player":["les"],"application/vnd.hp-hpgl":["hpgl"],"application/vnd.hp-hpid":["hpid"],"application/vnd.hp-hps":["hps"],"application/vnd.hp-jlyt":["jlt"],"application/vnd.hp-pcl":["pcl"],"application/vnd.hp-pclxl":["pclxl"],"application/vnd.hydrostatix.sof-data":["sfd-hdstx"],"application/vnd.ibm.minipay":["mpy"],"application/vnd.ibm.modcap":["afp","listafp","list3820"],"application/vnd.ibm.rights-management":["irm"],"application/vnd.ibm.secure-container":["sc"],"application/vnd.iccprofile":["icc","icm"],"application/vnd.igloader":["igl"],"application/vnd.immervision-ivp":["ivp"],"application/vnd.immervision-ivu":["ivu"],"application/vnd.insors.igm":["igm"],"application/vnd.intercon.formnet":["xpw","xpx"],"application/vnd.intergeo":["i2g"],"application/vnd.intu.qbo":["qbo"],"application/vnd.intu.qfx":["qfx"],"application/vnd.ipunplugged.rcprofile":["rcprofile"],"application/vnd.irepository.package+xml":["irp"],"application/vnd.is-xpr":["xpr"],"application/vnd.isac.fcs":["fcs"],"application/vnd.jam":["jam"],"application/vnd.jcp.javame.midlet-rms":["rms"],"application/vnd.jisp":["jisp"],"application/vnd.joost.joda-archive":["joda"],"application/vnd.kahootz":["ktz","ktr"],"application/vnd.kde.karbon":["karbon"],"application/vnd.kde.kchart":["chrt"],"application/vnd.kde.kformula":["kfo"],"application/vnd.kde.kivio":["flw"],"application/vnd.kde.kontour":["kon"],"application/vnd.kde.kpresenter":["kpr","kpt"],"application/vnd.kde.kspread":["ksp"],"application/vnd.kde.kword":["kwd","kwt"],"application/vnd.kenameaapp":["htke"],"application/vnd.kidspiration":["kia"],"application/vnd.kinar":["kne","knp"],"application/vnd.koan":["skp","skd","skt","skm"],"application/vnd.kodak-descriptor":["sse"],"application/vnd.las.las+xml":["lasxml"],"application/vnd.llamagraphics.life-balance.desktop":["lbd"],"application/vnd.llamagraphics.life-balance.exchange+xml":["lbe"],"application/vnd.lotus-1-2-3":["123"],"application/vnd.lotus-approach":["apr"],"application/vnd.lotus-freelance":["pre"],"application/vnd.lotus-notes":["nsf"],"application/vnd.lotus-organizer":["org"],"application/vnd.lotus-screencam":["scm"],"application/vnd.lotus-wordpro":["lwp"],"application/vnd.macports.portpkg":["portpkg"],"application/vnd.mapbox-vector-tile":["mvt"],"application/vnd.mcd":["mcd"],"application/vnd.medcalcdata":["mc1"],"application/vnd.mediastation.cdkey":["cdkey"],"application/vnd.mfer":["mwf"],"application/vnd.mfmp":["mfm"],"application/vnd.micrografx.flo":["flo"],"application/vnd.micrografx.igx":["igx"],"application/vnd.mif":["mif"],"application/vnd.mobius.daf":["daf"],"application/vnd.mobius.dis":["dis"],"application/vnd.mobius.mbk":["mbk"],"application/vnd.mobius.mqy":["mqy"],"application/vnd.mobius.msl":["msl"],"application/vnd.mobius.plc":["plc"],"application/vnd.mobius.txf":["txf"],"application/vnd.mophun.application":["mpn"],"application/vnd.mophun.certificate":["mpc"],"application/vnd.mozilla.xul+xml":["xul"],"application/vnd.ms-artgalry":["cil"],"application/vnd.ms-cab-compressed":["cab"],"application/vnd.ms-excel":["xls","xlm","xla","xlc","xlt","xlw"],"application/vnd.ms-excel.addin.macroenabled.12":["xlam"],"application/vnd.ms-excel.sheet.binary.macroenabled.12":["xlsb"],"application/vnd.ms-excel.sheet.macroenabled.12":["xlsm"],"application/vnd.ms-excel.template.macroenabled.12":["xltm"],"application/vnd.ms-fontobject":["eot"],"application/vnd.ms-htmlhelp":["chm"],"application/vnd.ms-ims":["ims"],"application/vnd.ms-lrm":["lrm"],"application/vnd.ms-officetheme":["thmx"],"application/vnd.ms-outlook":["msg"],"application/vnd.ms-pki.seccat":["cat"],"application/vnd.ms-pki.stl":["*stl"],"application/vnd.ms-powerpoint":["ppt","pps","pot"],"application/vnd.ms-powerpoint.addin.macroenabled.12":["ppam"],"application/vnd.ms-powerpoint.presentation.macroenabled.12":["pptm"],"application/vnd.ms-powerpoint.slide.macroenabled.12":["sldm"],"application/vnd.ms-powerpoint.slideshow.macroenabled.12":["ppsm"],"application/vnd.ms-powerpoint.template.macroenabled.12":["potm"],"application/vnd.ms-project":["mpp","mpt"],"application/vnd.ms-word.document.macroenabled.12":["docm"],"application/vnd.ms-word.template.macroenabled.12":["dotm"],"application/vnd.ms-works":["wps","wks","wcm","wdb"],"application/vnd.ms-wpl":["wpl"],"application/vnd.ms-xpsdocument":["xps"],"application/vnd.mseq":["mseq"],"application/vnd.musician":["mus"],"application/vnd.muvee.style":["msty"],"application/vnd.mynfc":["taglet"],"application/vnd.neurolanguage.nlu":["nlu"],"application/vnd.nitf":["ntf","nitf"],"application/vnd.noblenet-directory":["nnd"],"application/vnd.noblenet-sealer":["nns"],"application/vnd.noblenet-web":["nnw"],"application/vnd.nokia.n-gage.ac+xml":["*ac"],"application/vnd.nokia.n-gage.data":["ngdat"],"application/vnd.nokia.n-gage.symbian.install":["n-gage"],"application/vnd.nokia.radio-preset":["rpst"],"application/vnd.nokia.radio-presets":["rpss"],"application/vnd.novadigm.edm":["edm"],"application/vnd.novadigm.edx":["edx"],"application/vnd.novadigm.ext":["ext"],"application/vnd.oasis.opendocument.chart":["odc"],"application/vnd.oasis.opendocument.chart-template":["otc"],"application/vnd.oasis.opendocument.database":["odb"],"application/vnd.oasis.opendocument.formula":["odf"],"application/vnd.oasis.opendocument.formula-template":["odft"],"application/vnd.oasis.opendocument.graphics":["odg"],"application/vnd.oasis.opendocument.graphics-template":["otg"],"application/vnd.oasis.opendocument.image":["odi"],"application/vnd.oasis.opendocument.image-template":["oti"],"application/vnd.oasis.opendocument.presentation":["odp"],"application/vnd.oasis.opendocument.presentation-template":["otp"],"application/vnd.oasis.opendocument.spreadsheet":["ods"],"application/vnd.oasis.opendocument.spreadsheet-template":["ots"],"application/vnd.oasis.opendocument.text":["odt"],"application/vnd.oasis.opendocument.text-master":["odm"],"application/vnd.oasis.opendocument.text-template":["ott"],"application/vnd.oasis.opendocument.text-web":["oth"],"application/vnd.olpc-sugar":["xo"],"application/vnd.oma.dd2+xml":["dd2"],"application/vnd.openblox.game+xml":["obgx"],"application/vnd.openofficeorg.extension":["oxt"],"application/vnd.openstreetmap.data+xml":["osm"],"application/vnd.openxmlformats-officedocument.presentationml.presentation":["pptx"],"application/vnd.openxmlformats-officedocument.presentationml.slide":["sldx"],"application/vnd.openxmlformats-officedocument.presentationml.slideshow":["ppsx"],"application/vnd.openxmlformats-officedocument.presentationml.template":["potx"],"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":["xlsx"],"application/vnd.openxmlformats-officedocument.spreadsheetml.template":["xltx"],"application/vnd.openxmlformats-officedocument.wordprocessingml.document":["docx"],"application/vnd.openxmlformats-officedocument.wordprocessingml.template":["dotx"],"application/vnd.osgeo.mapguide.package":["mgp"],"application/vnd.osgi.dp":["dp"],"application/vnd.osgi.subsystem":["esa"],"application/vnd.palm":["pdb","pqa","oprc"],"application/vnd.pawaafile":["paw"],"application/vnd.pg.format":["str"],"application/vnd.pg.osasli":["ei6"],"application/vnd.picsel":["efif"],"application/vnd.pmi.widget":["wg"],"application/vnd.pocketlearn":["plf"],"application/vnd.powerbuilder6":["pbd"],"application/vnd.previewsystems.box":["box"],"application/vnd.proteus.magazine":["mgz"],"application/vnd.publishare-delta-tree":["qps"],"application/vnd.pvi.ptid1":["ptid"],"application/vnd.quark.quarkxpress":["qxd","qxt","qwd","qwt","qxl","qxb"],"application/vnd.rar":["rar"],"application/vnd.realvnc.bed":["bed"],"application/vnd.recordare.musicxml":["mxl"],"application/vnd.recordare.musicxml+xml":["musicxml"],"application/vnd.rig.cryptonote":["cryptonote"],"application/vnd.rim.cod":["cod"],"application/vnd.rn-realmedia":["rm"],"application/vnd.rn-realmedia-vbr":["rmvb"],"application/vnd.route66.link66+xml":["link66"],"application/vnd.sailingtracker.track":["st"],"application/vnd.seemail":["see"],"application/vnd.sema":["sema"],"application/vnd.semd":["semd"],"application/vnd.semf":["semf"],"application/vnd.shana.informed.formdata":["ifm"],"application/vnd.shana.informed.formtemplate":["itp"],"application/vnd.shana.informed.interchange":["iif"],"application/vnd.shana.informed.package":["ipk"],"application/vnd.simtech-mindmapper":["twd","twds"],"application/vnd.smaf":["mmf"],"application/vnd.smart.teacher":["teacher"],"application/vnd.software602.filler.form+xml":["fo"],"application/vnd.solent.sdkm+xml":["sdkm","sdkd"],"application/vnd.spotfire.dxp":["dxp"],"application/vnd.spotfire.sfs":["sfs"],"application/vnd.stardivision.calc":["sdc"],"application/vnd.stardivision.draw":["sda"],"application/vnd.stardivision.impress":["sdd"],"application/vnd.stardivision.math":["smf"],"application/vnd.stardivision.writer":["sdw","vor"],"application/vnd.stardivision.writer-global":["sgl"],"application/vnd.stepmania.package":["smzip"],"application/vnd.stepmania.stepchart":["sm"],"application/vnd.sun.wadl+xml":["wadl"],"application/vnd.sun.xml.calc":["sxc"],"application/vnd.sun.xml.calc.template":["stc"],"application/vnd.sun.xml.draw":["sxd"],"application/vnd.sun.xml.draw.template":["std"],"application/vnd.sun.xml.impress":["sxi"],"application/vnd.sun.xml.impress.template":["sti"],"application/vnd.sun.xml.math":["sxm"],"application/vnd.sun.xml.writer":["sxw"],"application/vnd.sun.xml.writer.global":["sxg"],"application/vnd.sun.xml.writer.template":["stw"],"application/vnd.sus-calendar":["sus","susp"],"application/vnd.svd":["svd"],"application/vnd.symbian.install":["sis","sisx"],"application/vnd.syncml+xml":["xsm"],"application/vnd.syncml.dm+wbxml":["bdm"],"application/vnd.syncml.dm+xml":["xdm"],"application/vnd.syncml.dmddf+xml":["ddf"],"application/vnd.tao.intent-module-archive":["tao"],"application/vnd.tcpdump.pcap":["pcap","cap","dmp"],"application/vnd.tmobile-livetv":["tmo"],"application/vnd.trid.tpt":["tpt"],"application/vnd.triscape.mxs":["mxs"],"application/vnd.trueapp":["tra"],"application/vnd.ufdl":["ufd","ufdl"],"application/vnd.uiq.theme":["utz"],"application/vnd.umajin":["umj"],"application/vnd.unity":["unityweb"],"application/vnd.uoml+xml":["uoml"],"application/vnd.vcx":["vcx"],"application/vnd.visio":["vsd","vst","vss","vsw"],"application/vnd.visionary":["vis"],"application/vnd.vsf":["vsf"],"application/vnd.wap.wbxml":["wbxml"],"application/vnd.wap.wmlc":["wmlc"],"application/vnd.wap.wmlscriptc":["wmlsc"],"application/vnd.webturbo":["wtb"],"application/vnd.wolfram.player":["nbp"],"application/vnd.wordperfect":["wpd"],"application/vnd.wqd":["wqd"],"application/vnd.wt.stf":["stf"],"application/vnd.xara":["xar"],"application/vnd.xfdl":["xfdl"],"application/vnd.yamaha.hv-dic":["hvd"],"application/vnd.yamaha.hv-script":["hvs"],"application/vnd.yamaha.hv-voice":["hvp"],"application/vnd.yamaha.openscoreformat":["osf"],"application/vnd.yamaha.openscoreformat.osfpvg+xml":["osfpvg"],"application/vnd.yamaha.smaf-audio":["saf"],"application/vnd.yamaha.smaf-phrase":["spf"],"application/vnd.yellowriver-custom-menu":["cmp"],"application/vnd.zul":["zir","zirz"],"application/vnd.zzazz.deck+xml":["zaz"],"application/x-7z-compressed":["7z"],"application/x-abiword":["abw"],"application/x-ace-compressed":["ace"],"application/x-apple-diskimage":["*dmg"],"application/x-arj":["arj"],"application/x-authorware-bin":["aab","x32","u32","vox"],"application/x-authorware-map":["aam"],"application/x-authorware-seg":["aas"],"application/x-bcpio":["bcpio"],"application/x-bdoc":["*bdoc"],"application/x-bittorrent":["torrent"],"application/x-blorb":["blb","blorb"],"application/x-bzip":["bz"],"application/x-bzip2":["bz2","boz"],"application/x-cbr":["cbr","cba","cbt","cbz","cb7"],"application/x-cdlink":["vcd"],"application/x-cfs-compressed":["cfs"],"application/x-chat":["chat"],"application/x-chess-pgn":["pgn"],"application/x-chrome-extension":["crx"],"application/x-cocoa":["cco"],"application/x-conference":["nsc"],"application/x-cpio":["cpio"],"application/x-csh":["csh"],"application/x-debian-package":["*deb","udeb"],"application/x-dgc-compressed":["dgc"],"application/x-director":["dir","dcr","dxr","cst","cct","cxt","w3d","fgd","swa"],"application/x-doom":["wad"],"application/x-dtbncx+xml":["ncx"],"application/x-dtbook+xml":["dtb"],"application/x-dtbresource+xml":["res"],"application/x-dvi":["dvi"],"application/x-envoy":["evy"],"application/x-eva":["eva"],"application/x-font-bdf":["bdf"],"application/x-font-ghostscript":["gsf"],"application/x-font-linux-psf":["psf"],"application/x-font-pcf":["pcf"],"application/x-font-snf":["snf"],"application/x-font-type1":["pfa","pfb","pfm","afm"],"application/x-freearc":["arc"],"application/x-futuresplash":["spl"],"application/x-gca-compressed":["gca"],"application/x-glulx":["ulx"],"application/x-gnumeric":["gnumeric"],"application/x-gramps-xml":["gramps"],"application/x-gtar":["gtar"],"application/x-hdf":["hdf"],"application/x-httpd-php":["php"],"application/x-install-instructions":["install"],"application/x-iso9660-image":["*iso"],"application/x-iwork-keynote-sffkey":["*key"],"application/x-iwork-numbers-sffnumbers":["*numbers"],"application/x-iwork-pages-sffpages":["*pages"],"application/x-java-archive-diff":["jardiff"],"application/x-java-jnlp-file":["jnlp"],"application/x-keepass2":["kdbx"],"application/x-latex":["latex"],"application/x-lua-bytecode":["luac"],"application/x-lzh-compressed":["lzh","lha"],"application/x-makeself":["run"],"application/x-mie":["mie"],"application/x-mobipocket-ebook":["prc","mobi"],"application/x-ms-application":["application"],"application/x-ms-shortcut":["lnk"],"application/x-ms-wmd":["wmd"],"application/x-ms-wmz":["wmz"],"application/x-ms-xbap":["xbap"],"application/x-msaccess":["mdb"],"application/x-msbinder":["obd"],"application/x-mscardfile":["crd"],"application/x-msclip":["clp"],"application/x-msdos-program":["*exe"],"application/x-msdownload":["*exe","*dll","com","bat","*msi"],"application/x-msmediaview":["mvb","m13","m14"],"application/x-msmetafile":["*wmf","*wmz","*emf","emz"],"application/x-msmoney":["mny"],"application/x-mspublisher":["pub"],"application/x-msschedule":["scd"],"application/x-msterminal":["trm"],"application/x-mswrite":["wri"],"application/x-netcdf":["nc","cdf"],"application/x-ns-proxy-autoconfig":["pac"],"application/x-nzb":["nzb"],"application/x-perl":["pl","pm"],"application/x-pilot":["*prc","*pdb"],"application/x-pkcs12":["p12","pfx"],"application/x-pkcs7-certificates":["p7b","spc"],"application/x-pkcs7-certreqresp":["p7r"],"application/x-rar-compressed":["*rar"],"application/x-redhat-package-manager":["rpm"],"application/x-research-info-systems":["ris"],"application/x-sea":["sea"],"application/x-sh":["sh"],"application/x-shar":["shar"],"application/x-shockwave-flash":["swf"],"application/x-silverlight-app":["xap"],"application/x-sql":["sql"],"application/x-stuffit":["sit"],"application/x-stuffitx":["sitx"],"application/x-subrip":["srt"],"application/x-sv4cpio":["sv4cpio"],"application/x-sv4crc":["sv4crc"],"application/x-t3vm-image":["t3"],"application/x-tads":["gam"],"application/x-tar":["tar"],"application/x-tcl":["tcl","tk"],"application/x-tex":["tex"],"application/x-tex-tfm":["tfm"],"application/x-texinfo":["texinfo","texi"],"application/x-tgif":["*obj"],"application/x-ustar":["ustar"],"application/x-virtualbox-hdd":["hdd"],"application/x-virtualbox-ova":["ova"],"application/x-virtualbox-ovf":["ovf"],"application/x-virtualbox-vbox":["vbox"],"application/x-virtualbox-vbox-extpack":["vbox-extpack"],"application/x-virtualbox-vdi":["vdi"],"application/x-virtualbox-vhd":["vhd"],"application/x-virtualbox-vmdk":["vmdk"],"application/x-wais-source":["src"],"application/x-web-app-manifest+json":["webapp"],"application/x-x509-ca-cert":["der","crt","pem"],"application/x-xfig":["fig"],"application/x-xliff+xml":["*xlf"],"application/x-xpinstall":["xpi"],"application/x-xz":["xz"],"application/x-zmachine":["z1","z2","z3","z4","z5","z6","z7","z8"],"audio/vnd.dece.audio":["uva","uvva"],"audio/vnd.digital-winds":["eol"],"audio/vnd.dra":["dra"],"audio/vnd.dts":["dts"],"audio/vnd.dts.hd":["dtshd"],"audio/vnd.lucent.voice":["lvp"],"audio/vnd.ms-playready.media.pya":["pya"],"audio/vnd.nuera.ecelp4800":["ecelp4800"],"audio/vnd.nuera.ecelp7470":["ecelp7470"],"audio/vnd.nuera.ecelp9600":["ecelp9600"],"audio/vnd.rip":["rip"],"audio/x-aac":["aac"],"audio/x-aiff":["aif","aiff","aifc"],"audio/x-caf":["caf"],"audio/x-flac":["flac"],"audio/x-m4a":["*m4a"],"audio/x-matroska":["mka"],"audio/x-mpegurl":["m3u"],"audio/x-ms-wax":["wax"],"audio/x-ms-wma":["wma"],"audio/x-pn-realaudio":["ram","ra"],"audio/x-pn-realaudio-plugin":["rmp"],"audio/x-realaudio":["*ra"],"audio/x-wav":["*wav"],"chemical/x-cdx":["cdx"],"chemical/x-cif":["cif"],"chemical/x-cmdf":["cmdf"],"chemical/x-cml":["cml"],"chemical/x-csml":["csml"],"chemical/x-xyz":["xyz"],"image/prs.btif":["btif"],"image/prs.pti":["pti"],"image/vnd.adobe.photoshop":["psd"],"image/vnd.airzip.accelerator.azv":["azv"],"image/vnd.dece.graphic":["uvi","uvvi","uvg","uvvg"],"image/vnd.djvu":["djvu","djv"],"image/vnd.dvb.subtitle":["*sub"],"image/vnd.dwg":["dwg"],"image/vnd.dxf":["dxf"],"image/vnd.fastbidsheet":["fbs"],"image/vnd.fpx":["fpx"],"image/vnd.fst":["fst"],"image/vnd.fujixerox.edmics-mmr":["mmr"],"image/vnd.fujixerox.edmics-rlc":["rlc"],"image/vnd.microsoft.icon":["ico"],"image/vnd.ms-dds":["dds"],"image/vnd.ms-modi":["mdi"],"image/vnd.ms-photo":["wdp"],"image/vnd.net-fpx":["npx"],"image/vnd.pco.b16":["b16"],"image/vnd.tencent.tap":["tap"],"image/vnd.valve.source.texture":["vtf"],"image/vnd.wap.wbmp":["wbmp"],"image/vnd.xiff":["xif"],"image/vnd.zbrush.pcx":["pcx"],"image/x-3ds":["3ds"],"image/x-cmu-raster":["ras"],"image/x-cmx":["cmx"],"image/x-freehand":["fh","fhc","fh4","fh5","fh7"],"image/x-icon":["*ico"],"image/x-jng":["jng"],"image/x-mrsid-image":["sid"],"image/x-ms-bmp":["*bmp"],"image/x-pcx":["*pcx"],"image/x-pict":["pic","pct"],"image/x-portable-anymap":["pnm"],"image/x-portable-bitmap":["pbm"],"image/x-portable-graymap":["pgm"],"image/x-portable-pixmap":["ppm"],"image/x-rgb":["rgb"],"image/x-tga":["tga"],"image/x-xbitmap":["xbm"],"image/x-xpixmap":["xpm"],"image/x-xwindowdump":["xwd"],"message/vnd.wfa.wsc":["wsc"],"model/vnd.collada+xml":["dae"],"model/vnd.dwf":["dwf"],"model/vnd.gdl":["gdl"],"model/vnd.gtw":["gtw"],"model/vnd.mts":["mts"],"model/vnd.opengex":["ogex"],"model/vnd.parasolid.transmit.binary":["x_b"],"model/vnd.parasolid.transmit.text":["x_t"],"model/vnd.sap.vds":["vds"],"model/vnd.usdz+zip":["usdz"],"model/vnd.valve.source.compiled-map":["bsp"],"model/vnd.vtu":["vtu"],"text/prs.lines.tag":["dsc"],"text/vnd.curl":["curl"],"text/vnd.curl.dcurl":["dcurl"],"text/vnd.curl.mcurl":["mcurl"],"text/vnd.curl.scurl":["scurl"],"text/vnd.dvb.subtitle":["sub"],"text/vnd.fly":["fly"],"text/vnd.fmi.flexstor":["flx"],"text/vnd.graphviz":["gv"],"text/vnd.in3d.3dml":["3dml"],"text/vnd.in3d.spot":["spot"],"text/vnd.sun.j2me.app-descriptor":["jad"],"text/vnd.wap.wml":["wml"],"text/vnd.wap.wmlscript":["wmls"],"text/x-asm":["s","asm"],"text/x-c":["c","cc","cxx","cpp","h","hh","dic"],"text/x-component":["htc"],"text/x-fortran":["f","for","f77","f90"],"text/x-handlebars-template":["hbs"],"text/x-java-source":["java"],"text/x-lua":["lua"],"text/x-markdown":["mkd"],"text/x-nfo":["nfo"],"text/x-opml":["opml"],"text/x-org":["*org"],"text/x-pascal":["p","pas"],"text/x-processing":["pde"],"text/x-sass":["sass"],"text/x-scss":["scss"],"text/x-setext":["etx"],"text/x-sfv":["sfv"],"text/x-suse-ymp":["ymp"],"text/x-uuencode":["uu"],"text/x-vcalendar":["vcs"],"text/x-vcard":["vcf"],"video/vnd.dece.hd":["uvh","uvvh"],"video/vnd.dece.mobile":["uvm","uvvm"],"video/vnd.dece.pd":["uvp","uvvp"],"video/vnd.dece.sd":["uvs","uvvs"],"video/vnd.dece.video":["uvv","uvvv"],"video/vnd.dvb.file":["dvb"],"video/vnd.fvt":["fvt"],"video/vnd.mpegurl":["mxu","m4u"],"video/vnd.ms-playready.media.pyv":["pyv"],"video/vnd.uvvu.mp4":["uvu","uvvu"],"video/vnd.vivo":["viv"],"video/x-f4v":["f4v"],"video/x-fli":["fli"],"video/x-flv":["flv"],"video/x-m4v":["m4v"],"video/x-matroska":["mkv","mk3d","mks"],"video/x-mng":["mng"],"video/x-ms-asf":["asf","asx"],"video/x-ms-vob":["vob"],"video/x-ms-wm":["wm"],"video/x-ms-wmv":["wmv"],"video/x-ms-wmx":["wmx"],"video/x-ms-wvx":["wvx"],"video/x-msvideo":["avi"],"video/x-sgi-movie":["movie"],"video/x-smv":["smv"],"x-conference/x-cooltalk":["ice"]}});var io=P((bp,no)=>{"use strict";var Qd=Xa();no.exports=new Qd(Qa(),to())});var so,ro,we,Fe,us=tt(()=>{so=Ie(J()),ro=Ie(io());(function(i){i.JSON="application/json",i.PLAIN_TEXT="text/plain",i.OCTET_STREAM="octet/stream"})(we||(we={}));(function(i){let e=JSON.parse(so.PageConfig.getOption("fileTypes")||"{}");function t(s,r=null){s=s.toLowerCase();for(let a of Object.values(e))for(let o of a.extensions||[])if(o===s&&a.mimeTypes&&a.mimeTypes.length)return a.mimeTypes[0];return ro.default.getType(s)||r||we.OCTET_STREAM}i.getType=t;function n(s,r){s=s.toLowerCase();for(let a of Object.values(e))if(a.fileFormat===r){for(let o of a.extensions||[])if(o===s)return!0}return!1}i.hasFormat=n})(Fe||(Fe={}))});var Me,lo,Ce,co,hs,ao,uo,oo,At,ps,fs,Jn,po=tt(()=>{Me=Ie(J()),lo=Ie(qe()),Ce=Ie(J()),co=Ie(te()),hs=Ie(Z());us();ao="JupyterLite Storage",uo="BrowserStorage",oo=5,At=new TextEncoder,ps=new TextDecoder("utf-8"),fs=class{constructor(e){var t;this.reduceBytesToString=(n,s)=>n+String.fromCharCode(s),this._serverContents=new Map,this._isDisposed=!1,this._fileChanged=new hs.Signal(this),this._storageName=ao,this._storageDrivers=null,this._localforage=e.localforage,this._storageName=e.storageName||ao,this._storageDrivers=e.storageDrivers||null,this._serverSettings=(t=e.serverSettings)!==null&&t!==void 0?t:lo.ServerConnection.makeSettings(),this._ready=new co.PromiseDelegate,this.initialize().catch(console.warn)}dispose(){this.isDisposed||(this._isDisposed=!0,hs.Signal.clearData(this))}get isDisposed(){return this._isDisposed}get name(){return uo}get serverSettings(){return this._serverSettings}get fileChanged(){return this._fileChanged}async getDownloadUrl(e){e=decodeURIComponent(e.replace(/^\//,""));let n=await(await this.storage).getItem(e);if(n&&n.content!==null){let a;if(n.format==="base64"){let o=atob(n.content),u=new Uint8Array(o.length);for(let c=0;c<o.length;c++)u[c]=o.charCodeAt(c);a=new Blob([u],{type:n.mimetype})}else if(n.format==="json"){let o=JSON.stringify(n.content);a=new Blob([o],{type:n.mimetype})}else a=new Blob([n.content],{type:n.mimetype});return URL.createObjectURL(a)}let s=this.serverSettings.baseUrl;return Me.URLExt.join(s,"files",Me.URLExt.encodeParts(e))}async initialize(){await this.initStorage(),this._ready.resolve(void 0)}async initStorage(){this._storage=this.createDefaultStorage(),this._counters=this.createDefaultCounters(),this._checkpoints=this.createDefaultCheckpoints()}get ready(){return this._ready.promise}get storage(){return this.ready.then(()=>this._storage)}get counters(){return this.ready.then(()=>this._counters)}get checkpoints(){return this.ready.then(()=>this._checkpoints)}get defaultStorageOptions(){let e=this._storageDrivers&&this._storageDrivers.length?this._storageDrivers:null;return{version:1,name:this._storageName,...e?{driver:e}:{}}}createDefaultStorage(){return this._localforage.createInstance({description:"Offline Storage for Notebooks and Files",storeName:"files",...this.defaultStorageOptions})}createDefaultCounters(){return this._localforage.createInstance({description:"Store the current file suffix counters",storeName:"counters",...this.defaultStorageOptions})}createDefaultCheckpoints(){return this._localforage.createInstance({description:"Offline Storage for Checkpoints",storeName:"checkpoints",...this.defaultStorageOptions})}async clearStorage(){await Promise.all([(await this.storage).clear(),(await this.counters).clear(),(await this.checkpoints).clear()])}async newUntitled(e){var t,n,s;let r=(t=e==null?void 0:e.path)!==null&&t!==void 0?t:"",a=(n=e==null?void 0:e.type)!==null&&n!==void 0?n:"notebook",o=new Date().toISOString(),u=Ce.PathExt.dirname(r),c=Ce.PathExt.basename(r),d=Ce.PathExt.extname(r),l=await this.get(u).catch(()=>null),p="";r&&!d&&l?(u=`${r}/`,p=""):u&&c?(u=`${u}/`,p=c):(u="",p=r);let v;switch(a){case"directory":{p=`Untitled Folder${await this._incrementCounter("directory")||""}`,v={name:p,path:`${u}${p}`,last_modified:o,created:o,format:"json",mimetype:"",content:null,size:0,writable:!0,type:"directory"};break}case"notebook":{let I=await this._incrementCounter("notebook");p=p||`Untitled${I||""}.ipynb`,v={name:p,path:`${u}${p}`,last_modified:o,created:o,format:"json",mimetype:we.JSON,content:Jn.EMPTY_NB,size:At.encode(JSON.stringify(Jn.EMPTY_NB)).length,writable:!0,type:"notebook"};break}default:{let I=(s=e==null?void 0:e.ext)!==null&&s!==void 0?s:".txt";I.startsWith(".")||(I=`.${I}`);let M=await this._incrementCounter("file"),j=Fe.getType(I)||we.OCTET_STREAM,q;Fe.hasFormat(I,"text")||j.indexOf("text")!==-1?q="text":I.indexOf("json")!==-1||I.indexOf("ipynb")!==-1?q="json":q="base64",p=p||`untitled${M||""}${I}`,v={name:p,path:`${u}${p}`,last_modified:o,created:o,format:q,mimetype:j,content:"",size:0,writable:!0,type:"file"};break}}let _=v.path;return await(await this.storage).setItem(_,v),this._fileChanged.emit({type:"new",oldValue:null,newValue:v}),v}async copy(e,t){let n=Ce.PathExt.basename(e);for(t=t===""?"":`${Ce.PathExt.removeSlash(t)}/`;await this.get(`${t}${n}`,{content:!0}).then(()=>!0).catch(()=>!1);){let a=Ce.PathExt.extname(n);n=`${n.replace(a,"")} (copy)${a}`}let s=`${t}${n}`,r=await this.get(e,{content:!0}).catch(()=>null);if(!r)throw Error(`Could not find file with path ${e}`);return r={...r,name:n,path:s},await(await this.storage).setItem(s,r),this._fileChanged.emit({type:"new",oldValue:null,newValue:r}),r}async get(e,t){if(e=decodeURIComponent(e.replace(/^\//,"")),e===""){let o=await this._getFolder(e);if(o===null)throw Error(`Could not find file with path ${e}`);return o}let n=await this.storage,s=await n.getItem(e),r=await this._getServerContents(e,t),a=s||r;if(!a)throw Error(`Could not find content with path ${e}`);if(!(t!=null&&t.content))return{size:0,...a,content:null};if(a.type==="directory"){let o=new Map;await n.iterate((d,l)=>{l===`${e}/${d.name}`&&o.set(d.name,d)});let u=r?r.content:Array.from((await this._getServerDirectory(e)).values());for(let d of u)o.has(d.name)||o.set(d.name,d);let c=[...o.values()];return{name:Ce.PathExt.basename(e),path:e,last_modified:a.last_modified,created:a.created,format:"json",mimetype:we.JSON,content:c,size:0,writable:!0,type:"directory"}}return a}async rename(e,t){let n=decodeURIComponent(e),s=await this.get(n,{content:!0}).catch(()=>null);if(!s)throw Error(`Could not find file with path ${n}`);let r=new Date().toISOString(),a=Ce.PathExt.basename(t),o={...s,name:a,path:t,last_modified:r},u=await this.storage;if(await u.setItem(t,o),await u.removeItem(n),await(await this.checkpoints).removeItem(n),s.type==="directory"){let c;for(c of s.content)await this.rename(Me.URLExt.join(e,c.name),Me.URLExt.join(t,c.name))}return this._fileChanged.emit({type:"rename",oldValue:{path:e},newValue:o}),o}async save(e,t={}){var n;e=decodeURIComponent(e);let s=Ce.PathExt.extname((n=t.name)!==null&&n!==void 0?n:""),r=t.chunk,a=r?r>1||r===-1:!1,o=await this.get(e,{content:a}).catch(()=>null);if(o||(o=await this.newUntitled({path:e,ext:s,type:"file"})),!o)throw Error(`Could not find file with path ${e}`);let u=o.content,c=new Date().toISOString();if(o={...o,...t,last_modified:c},t.content&&t.format==="base64"){let d=r?r===-1:!0,l=this._handleUploadChunk(t.content,u,a);if(s===".ipynb"){let p=d?JSON.parse(ps.decode(this._binaryStringToBytes(l))):l;o={...o,content:p,format:"json",type:"notebook",size:l.length}}else if(Fe.hasFormat(s,"json")){let p=d?JSON.parse(ps.decode(this._binaryStringToBytes(l))):l;o={...o,content:p,format:"json",type:"file",size:l.length}}else if(Fe.hasFormat(s,"text")){let p=d?ps.decode(this._binaryStringToBytes(l)):l;o={...o,content:p,format:"text",type:"file",size:l.length}}else{let p=d?btoa(l):l;o={...o,content:p,format:"base64",type:"file",size:l.length}}}if(o.content)switch(t.format){case"json":{o={...o,size:At.encode(JSON.stringify(o.content)).length};break}case"text":{o={...o,size:At.encode(o.content).length};break}case"base64":break;default:{o={...o,size:0};break}}else o={...o,size:0};return await(await this.storage).setItem(e,o),this._fileChanged.emit({type:"save",oldValue:null,newValue:o}),o}async delete(e){e=decodeURIComponent(e);let t=`${e}/`,n=(await(await this.storage).keys()).filter(s=>s===e||s.startsWith(t));await Promise.all(n.map(this.forgetPath,this)),this._fileChanged.emit({type:"delete",oldValue:{path:e},newValue:null})}async forgetPath(e){await Promise.all([(await this.storage).removeItem(e),(await this.checkpoints).removeItem(e)])}async createCheckpoint(e){var t;let n=await this.checkpoints;e=decodeURIComponent(e);let s=await this.get(e,{content:!0}).catch(()=>null);if(!s)throw Error(`Could not find file with path ${e}`);let r=((t=await n.getItem(e))!==null&&t!==void 0?t:[]).filter(Boolean);return r.push(s),r.length>oo&&r.splice(0,r.length-oo),await n.setItem(e,r),{id:`${r.length-1}`,last_modified:s.last_modified}}async listCheckpoints(e){return(await(await this.checkpoints).getItem(e)||[]).filter(Boolean).map(this.normalizeCheckpoint,this)}normalizeCheckpoint(e,t){return{id:t.toString(),last_modified:e.last_modified}}async restoreCheckpoint(e,t){e=decodeURIComponent(e);let n=await(await this.checkpoints).getItem(e)||[],s=parseInt(t),r=n[s];await(await this.storage).setItem(e,r)}async deleteCheckpoint(e,t){e=decodeURIComponent(e);let n=await(await this.checkpoints).getItem(e)||[],s=parseInt(t);n.splice(s,1),await(await this.checkpoints).setItem(e,n)}_handleUploadChunk(e,t,n){let s=atob(e);return n?t+s:s}_binaryStringToBytes(e){let t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n);return t}async _getFolder(e){let t=new Map;await(await this.storage).iterate((s,r)=>{r.includes("/")||t.set(s.path,s)});for(let s of(await this._getServerDirectory(e)).values())t.has(s.path)||t.set(s.path,s);return e&&t.size===0?null:{name:"",path:e,last_modified:new Date(0).toISOString(),created:new Date(0).toISOString(),format:"json",mimetype:we.JSON,content:Array.from(t.values()),size:0,writable:!0,type:"directory"}}async _getServerContents(e,t){let n=Ce.PathExt.basename(e),r=(await this._getServerDirectory(Me.URLExt.join(e,".."))).get(n);if(!r)return null;if(r=r||{name:n,path:e,last_modified:new Date(0).toISOString(),created:new Date(0).toISOString(),format:"text",mimetype:we.PLAIN_TEXT,type:"file",writable:!0,size:0,content:""},t!=null&&t.content)if(r.type==="directory"){let a=await this._getServerDirectory(e);r={...r,content:Array.from(a.values())}}else{let a=Me.URLExt.join(Me.PageConfig.getBaseUrl(),"files",e),o=await fetch(a);if(!o.ok)return null;let u=r.mimetype||o.headers.get("Content-Type"),c=Ce.PathExt.extname(n);if(r.type==="notebook"||Fe.hasFormat(c,"json")||(u==null?void 0:u.indexOf("json"))!==-1||e.match(/\.(ipynb|[^/]*json[^/]*)$/)){let d=await o.text();r={...r,content:JSON.parse(d),format:"json",mimetype:r.mimetype||we.JSON,size:At.encode(d).length}}else if(Fe.hasFormat(c,"text")||u.indexOf("text")!==-1){let d=await o.text();r={...r,content:d,format:"text",mimetype:u||we.PLAIN_TEXT,size:At.encode(d).length}}else{let d=await o.arrayBuffer(),l=new Uint8Array(d);r={...r,content:btoa(l.reduce(this.reduceBytesToString,"")),format:"base64",mimetype:u||we.OCTET_STREAM,size:l.length}}}return r}async _getServerDirectory(e){let t=this._serverContents.get(e)||new Map;if(!this._serverContents.has(e)){let n=Me.URLExt.join(Me.PageConfig.getBaseUrl(),"api/contents",e,"all.json");try{let s=await fetch(n),r=JSON.parse(await s.text());for(let a of r.content)t.set(a.name,a)}catch(s){console.warn(`don't worry, about ${s}... nothing's broken. If there had been a
10
- file at ${n}, you might see some more files.`)}this._serverContents.set(e,t)}return t}async _incrementCounter(e){var t;let n=await this.counters,r=((t=await n.getItem(e))!==null&&t!==void 0?t:-1)+1;return await n.setItem(e,r),r}};(function(i){i.EMPTY_NB={metadata:{orig_nbformat:4},nbformat_minor:5,nbformat:4,cells:[]}})(Jn||(Jn={}))});function ms(i){return"node"in i}var Nt,ho,fo,mo,gs=tt(()=>{Nt=16895,ho=33206,fo=1,mo=2});var go,Qn,eu,tu,Hn,Gn,Yn,Xn,Zn,Lt,_s=tt(()=>{gs();go=":",Qn=4096,eu=new TextEncoder,tu=new TextDecoder("utf-8"),Hn={0:!1,1:!0,2:!0,64:!0,65:!0,66:!0,129:!0,193:!0,514:!0,577:!0,578:!0,705:!0,706:!0,1024:!0,1025:!0,1026:!0,1089:!0,1090:!0,1153:!0,1154:!0,1217:!0,1218:!0,4096:!0,4098:!0},Gn=class{constructor(e){this.fs=e}open(e){var t;let n=this.fs.realPath(e.node);if(this.fs.FS.isFile(e.node.mode))try{let s=this.fs.API.get(n);e.file=s}catch{let r=(t=e.flags)!==null&&t!==void 0?t:e.shared.flags,a=typeof r=="string"?parseInt(r,10):r;a&=8191;let o=!0;if(a in Hn&&(o=Hn[a]),o){e.node=this.fs.node_ops.mknod(e.node.parent,e.node.name,e.node.mode,0);let u=this.fs.API.get(n);e.file=u}else throw new this.fs.FS.ErrnoError(this.fs.ERRNO_CODES.ENOENT)}}close(e){var t;if(!this.fs.FS.isFile(e.node.mode)||!e.file)return;let n=this.fs.realPath(e.node),s=(t=e.flags)!==null&&t!==void 0?t:e.shared.flags,r=typeof s=="string"?parseInt(s,10):s;r&=8191;let a=!0;r in Hn&&(a=Hn[r]),a&&this.fs.API.put(n,e.file),e.file=void 0}read(e,t,n,s,r){if(s<=0||e.file===void 0||r>=(e.file.data.length||0))return 0;let a=Math.min(e.file.data.length-r,s);return t.set(e.file.data.subarray(r,r+a),n),a}write(e,t,n,s,r){var a;if(s<=0||e.file===void 0)return 0;if(e.node.timestamp=Date.now(),r+s>(((a=e.file)===null||a===void 0?void 0:a.data.length)||0)){let o=e.file.data?e.file.data:new Uint8Array;e.file.data=new Uint8Array(r+s),e.file.data.set(o)}return e.file.data.set(t.subarray(n,n+s),r),s}llseek(e,t,n){var s;let r=t;if(n===1)r+=(s=e.position)!==null&&s!==void 0?s:e.shared.position;else if(n===2&&this.fs.FS.isFile(e.node.mode))if(e.file!==void 0)r+=e.file.data.length;else throw new this.fs.FS.ErrnoError(this.fs.ERRNO_CODES.EPERM);if(r<0)throw new this.fs.FS.ErrnoError(this.fs.ERRNO_CODES.EINVAL);return r}},Yn=class{constructor(e){this.node=t=>ms(t)?t.node:t,this.getattr=t=>{let n=this.node(t);return{...this.fs.API.getattr(this.fs.realPath(n)),mode:n.mode,ino:n.id}},this.setattr=(t,n)=>{let s=this.node(t);for(let[r,a]of Object.entries(n))switch(r){case"mode":s.mode=a;break;case"timestamp":s.timestamp=a;break;case"size":{let o=a,u=this.fs.realPath(s);if(this.fs.FS.isFile(s.mode)&&o>=0){let c;try{c=this.fs.API.get(u)}catch{break}let d=c.data?c.data:new Uint8Array;o!==d.length&&(o<d.length?c.data=c.data.slice(0,o):(c.data=new Uint8Array(o),c.data.set(d)),this.fs.API.put(u,c))}else console.warn("setattr size of",o,"on",s,"not yet implemented");break}case"ctime":case"dontFollow":break;default:console.warn("setattr",r,"of",a,"on",s,"not yet implemented");break}},this.lookup=(t,n)=>{let s=this.node(t),r=this.fs.PATH.join2(this.fs.realPath(s),n),a=this.fs.API.lookup(r);if(!a.ok)throw new this.fs.FS.ErrnoError(this.fs.ERRNO_CODES.ENOENT);return this.fs.createNode(s,n,a.mode,0)},this.mknod=(t,n,s,r)=>{let a=this.node(t),o=this.fs.PATH.join2(this.fs.realPath(a),n);return this.fs.API.mknod(o,s),this.fs.createNode(a,n,s,r)},this.rename=(t,n,s)=>{let r=this.node(t),a=this.node(n);this.fs.API.rename(r.parent?this.fs.PATH.join2(this.fs.realPath(r.parent),r.name):r.name,this.fs.PATH.join2(this.fs.realPath(a),s)),r.name=s,r.parent=a},this.unlink=(t,n)=>this.fs.API.rmdir(this.fs.PATH.join2(this.fs.realPath(this.node(t)),n)),this.rmdir=(t,n)=>this.fs.API.rmdir(this.fs.PATH.join2(this.fs.realPath(this.node(t)),n)),this.readdir=t=>this.fs.API.readdir(this.fs.realPath(this.node(t))),this.symlink=(t,n,s)=>{throw new this.fs.FS.ErrnoError(this.fs.ERRNO_CODES.EPERM)},this.readlink=t=>{throw new this.fs.FS.ErrnoError(this.fs.ERRNO_CODES.EINVAL)},this.fs=e}},Xn=class{constructor(e){this._driveName=e.driveName,this._mountpoint=e.mountpoint,this.FS=e.FS,this.ERRNO_CODES=e.ERRNO_CODES}lookup(e){return this.request({method:"lookup",path:this.normalizePath(e)})}getmode(e){return this.request({method:"getmode",path:this.normalizePath(e)})}mknod(e,t){return this.request({method:"mknod",path:this.normalizePath(e),data:{mode:t}})}rename(e,t){return this.request({method:"rename",path:this.normalizePath(e),data:{newPath:this.normalizePath(t)}})}readdir(e){let t=this.request({method:"readdir",path:this.normalizePath(e)});return t.push("."),t.push(".."),t}rmdir(e){return this.request({method:"rmdir",path:this.normalizePath(e)})}get(e){let t=this.request({method:"get",path:this.normalizePath(e)});if(!t)throw new this.FS.ErrnoError(this.ERRNO_CODES.ENOENT);let n=t.content,s=t.format;switch(s){case"json":case"text":return{data:eu.encode(n),format:s};case"base64":{let r=atob(n),a=r.length,o=new Uint8Array(a);for(let u=0;u<a;u++)o[u]=r.charCodeAt(u);return{data:o,format:s}}default:throw new this.FS.ErrnoError(this.ERRNO_CODES.ENOENT)}}put(e,t){switch(t.format){case"json":case"text":return this.request({method:"put",path:this.normalizePath(e),data:{format:t.format,data:tu.decode(t.data)}});case"base64":{let n="";for(let s=0;s<t.data.byteLength;s++)n+=String.fromCharCode(t.data[s]);return this.request({method:"put",path:this.normalizePath(e),data:{format:t.format,data:btoa(n)}})}}}getattr(e){let t=this.request({method:"getattr",path:this.normalizePath(e)});return t.atime&&(t.atime=new Date(t.atime)),t.mtime&&(t.mtime=new Date(t.mtime)),t.ctime&&(t.ctime=new Date(t.ctime)),t.size=t.size||0,t}normalizePath(e){return e.startsWith(this._mountpoint)&&(e=e.slice(this._mountpoint.length)),this._driveName&&(e=`${this._driveName}${go}${e}`),e}},Zn=class extends Xn{constructor(e){super(e),this._baseUrl=e.baseUrl,this._browsingContextId=e.browsingContextId||""}request(e){let t=new XMLHttpRequest;t.open("POST",encodeURI(this.endpoint),!1);let n={data:e,browsingContextId:this._browsingContextId};try{t.send(JSON.stringify(n))}catch(s){console.error(s)}if(t.status>=400)throw new this.FS.ErrnoError(this.ERRNO_CODES.EINVAL);return JSON.parse(t.responseText)}get endpoint(){return`${this._baseUrl}api/drive`}},Lt=class{constructor(e){this.FS=e.FS,this.PATH=e.PATH,this.ERRNO_CODES=e.ERRNO_CODES,this.API=this.createAPI(e),this.driveName=e.driveName,this.node_ops=new Yn(this),this.stream_ops=new Gn(this)}createAPI(e){if(!e.browsingContextId||!e.baseUrl)throw new Error("Cannot create service-worker API without current browsingContextId");return new Zn(e)}mount(e){return this.createNode(null,e.mountpoint,16895,0)}createNode(e,t,n,s){let r=this.FS;if(!r.isDir(n)&&!r.isFile(n))throw new r.ErrnoError(this.ERRNO_CODES.EINVAL);let a=r.createNode(e,t,n,s);return a.node_ops=this.node_ops,a.stream_ops=this.stream_ops,a}getMode(e){return this.API.getmode(e)}realPath(e){let t=[],n=e;for(t.push(n.name);n.parent!==n;)n=n.parent,t.push(n.name);return t.reverse(),this.PATH.join.apply(null,t)}}});var vs,ys,_o=tt(()=>{vs=Ie(J());_s();ys=class{constructor(e){this.contentsManager=e.contentsManager}async processDriveRequest(e){switch(e.method){case"readdir":return this.readdir(e);case"rmdir":return this.rmdir(e);case"rename":return this.rename(e);case"getmode":return this.getmode(e);case"lookup":return this.lookup(e);case"mknod":return this.mknod(e);case"getattr":return this.getattr(e);case"get":return this.get(e);case"put":return this.put(e)}throw`Drive request ${e.method} does not exist.`}async readdir(e){let t=await this.contentsManager.get(e.path,{content:!0}),n=[];return t.type==="directory"&&t.content&&(n=t.content.map(s=>s.name)),n}async rmdir(e){return await this.contentsManager.delete(e.path),null}async rename(e){return await this.contentsManager.rename(e.path,e.data.newPath),null}async getmode(e){let t=await this.contentsManager.get(e.path),n;return t.type==="directory"?n=16895:n=33206,n}async lookup(e){let t;try{t={ok:!0,mode:(await this.contentsManager.get(e.path)).type==="directory"?16895:33206}}catch{t={ok:!1}}return t}async mknod(e){let t=await this.contentsManager.newUntitled({path:vs.PathExt.dirname(e.path),type:e.data.mode===16895?"directory":"file",ext:vs.PathExt.extname(e.path)});return await this.contentsManager.rename(t.path,e.path),null}async getattr(e){let t=await this.contentsManager.get(e.path),n=new Date(0).toISOString();return{dev:1,nlink:1,uid:0,gid:0,rdev:0,size:t.size||0,blksize:Qn,blocks:Math.ceil(t.size||0/Qn),atime:t.last_modified||n,mtime:t.last_modified||n,ctime:t.created||n,timestamp:0}}async get(e){let t;try{t=await this.contentsManager.get(e.path,{content:!0})}catch{return null}let n=null;return t.type!=="directory"&&(n={content:t.format==="json"?JSON.stringify(t.content):t.content,format:t.format}),n}async put(e){return await this.contentsManager.save(e.path,{content:e.data.format==="json"&&e.data.data?JSON.parse(e.data.data):e.data.data,type:"file",format:e.data.format}),null}}});var vo={};Do(vo,{BLOCK_SIZE:()=>Qn,BrowserStorageDrive:()=>fs,ContentsAPI:()=>Xn,DIR_MODE:()=>Nt,DRIVE_NAME:()=>uo,DRIVE_SEPARATOR:()=>go,DriveContentsProcessor:()=>ys,DriveFS:()=>Lt,DriveFSEmscriptenNodeOps:()=>Yn,DriveFSEmscriptenStreamOps:()=>Gn,FILE:()=>Fe,FILE_MODE:()=>ho,MIME:()=>we,SEEK_CUR:()=>fo,SEEK_END:()=>mo,ServiceWorkerContentsAPI:()=>Zn,instanceOfStream:()=>ms});var ws=tt(()=>{po();_s();us();gs();_o()});var xs=Symbol("Comlink.proxy"),qo=Symbol("Comlink.endpoint"),Uo=Symbol("Comlink.releaseProxy"),ni=Symbol("Comlink.finalizer"),Ft=Symbol("Comlink.thrown"),Cs=i=>typeof i=="object"&&i!==null||typeof i=="function",Ao={canHandle:i=>Cs(i)&&i[xs],serialize(i){let{port1:e,port2:t}=new MessageChannel;return Vt(i,e),[t,[t]]},deserialize(i){return i.start(),Fo(i)}},No={canHandle:i=>Cs(i)&&Ft in i,serialize({value:i}){let e;return i instanceof Error?e={isError:!0,value:{message:i.message,name:i.name,stack:i.stack}}:e={isError:!1,value:i},[e,[]]},deserialize(i){throw i.isError?Object.assign(new Error(i.value.message),i.value):i.value}},ks=new Map([["proxy",Ao],["throw",No]]);function Lo(i,e){for(let t of i)if(e===t||t==="*"||t instanceof RegExp&&t.test(e))return!0;return!1}function Vt(i,e=globalThis,t=["*"]){e.addEventListener("message",function n(s){if(!s||!s.data)return;if(!Lo(t,s.origin)){console.warn(`Invalid origin '${s.origin}' for comlink proxy`);return}let{id:r,type:a,path:o}=Object.assign({path:[]},s.data),u=(s.data.argumentList||[]).map(Ye),c;try{let d=o.slice(0,-1).reduce((p,v)=>p[v],i),l=o.reduce((p,v)=>p[v],i);switch(a){case"GET":c=l;break;case"SET":d[o.slice(-1)[0]]=Ye(s.data.value),c=!0;break;case"APPLY":c=l.apply(d,u);break;case"CONSTRUCT":{let p=new l(...u);c=Wo(p)}break;case"ENDPOINT":{let{port1:p,port2:v}=new MessageChannel;Vt(i,v),c=Vo(p,[p])}break;case"RELEASE":c=void 0;break;default:return}}catch(d){c={value:d,[Ft]:0}}Promise.resolve(c).catch(d=>({value:d,[Ft]:0})).then(d=>{let[l,p]=$t(d);e.postMessage(Object.assign(Object.assign({},l),{id:r}),p),a==="RELEASE"&&(e.removeEventListener("message",n),Ps(e),ni in i&&typeof i[ni]=="function"&&i[ni]())}).catch(d=>{let[l,p]=$t({value:new TypeError("Unserializable return value"),[Ft]:0});e.postMessage(Object.assign(Object.assign({},l),{id:r}),p)})}),e.start&&e.start()}function zo(i){return i.constructor.name==="MessagePort"}function Ps(i){zo(i)&&i.close()}function Fo(i,e){let t=new Map;return i.addEventListener("message",function(s){let{data:r}=s;if(!r||!r.id)return;let a=t.get(r.id);if(a)try{a(r)}finally{t.delete(r.id)}}),ii(i,t,[],e)}function zt(i){if(i)throw new Error("Proxy has been released and is not useable")}function Ms(i){return nt(i,new Map,{type:"RELEASE"}).then(()=>{Ps(i)})}var Kt=new WeakMap,Bt="FinalizationRegistry"in globalThis&&new FinalizationRegistry(i=>{let e=(Kt.get(i)||0)-1;Kt.set(i,e),e===0&&Ms(i)});function Ko(i,e){let t=(Kt.get(e)||0)+1;Kt.set(e,t),Bt&&Bt.register(i,e,i)}function Bo(i){Bt&&Bt.unregister(i)}function ii(i,e,t=[],n=function(){}){let s=!1,r=new Proxy(n,{get(a,o){if(zt(s),o===Uo)return()=>{Bo(r),Ms(i),e.clear(),s=!0};if(o==="then"){if(t.length===0)return{then:()=>r};let u=nt(i,e,{type:"GET",path:t.map(c=>c.toString())}).then(Ye);return u.then.bind(u)}return ii(i,e,[...t,o])},set(a,o,u){zt(s);let[c,d]=$t(u);return nt(i,e,{type:"SET",path:[...t,o].map(l=>l.toString()),value:c},d).then(Ye)},apply(a,o,u){zt(s);let c=t[t.length-1];if(c===qo)return nt(i,e,{type:"ENDPOINT"}).then(Ye);if(c==="bind")return ii(i,e,t.slice(0,-1));let[d,l]=Ss(u);return nt(i,e,{type:"APPLY",path:t.map(p=>p.toString()),argumentList:d},l).then(Ye)},construct(a,o){zt(s);let[u,c]=Ss(o);return nt(i,e,{type:"CONSTRUCT",path:t.map(d=>d.toString()),argumentList:u},c).then(Ye)}});return Ko(r,i),r}function $o(i){return Array.prototype.concat.apply([],i)}function Ss(i){let e=i.map($t);return[e.map(t=>t[0]),$o(e.map(t=>t[1]))]}var Es=new WeakMap;function Vo(i,e){return Es.set(i,e),i}function Wo(i){return Object.assign(i,{[xs]:!0})}function $t(i){for(let[e,t]of ks)if(t.canHandle(i)){let[n,s]=t.serialize(i);return[{type:"HANDLER",name:e,value:n},s]}return[{type:"RAW",value:i},Es.get(i)||[]]}function Ye(i){switch(i.type){case"HANDLER":return ks.get(i.name).deserialize(i.value);case"RAW":return i.value}}function nt(i,e,t,n){return new Promise(s=>{let r=Jo();e.set(r,s),i.start&&i.start(),i.postMessage(Object.assign({id:r},t),n)})}function Jo(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}var yo=Ie(J()),wo=Ie(qe());ws();var ei=class{constructor(){this._options=null;this._initializer=null;this._pyodide=null;this._localPath="";this._driveName="";this._driveFS=null;this._sendWorkerMessage=()=>{};this._logMessage=()=>{};this._initialized=new Promise((e,t)=>{this._initializer={resolve:e,reject:t}})}async initialize(e){var t;if(this._options=e,e.location.includes(":")){let n=e.location.split(":");this._driveName=n[0],this._localPath=n[1]}else this._driveName="",this._localPath=e.location;await this.initRuntime(e),await this.initFilesystem(e),await this.initPackageManager(e),await this.initKernel(e),await this.initGlobals(e),(t=this._initializer)==null||t.resolve()}async initRuntime(e){let{pyodideUrl:t,indexUrl:n}=e,s;t.endsWith(".mjs")?s=(await import(t)).loadPyodide:(importScripts(t),s=self.loadPyodide),this._pyodide=await s({indexURL:n,stdout:r=>{console.log(r),this._logMessage({type:"text",level:"info",data:r})},stderr:r=>{console.error(r),this._logMessage({type:"text",level:"critical",data:r})},...e.loadPyodideOptions}),this._pyodide._api.on_fatal=async r=>{let a="";r.name==="Exit"?a="Pyodide has exited and can no longer be used.":a=`Pyodide has suffered a fatal error. Please report this to the Pyodide maintainers.
11
- The cause of the error was: ${r.name}
12
- ${r.message}
9
+ See "state database" for more information.`)});var Ns=R(Pe=>{"use strict";var Dc=Pe&&Pe.__createBinding||(Object.create?function(n,e,t,s){s===void 0&&(s=t);var r=Object.getOwnPropertyDescriptor(e,t);(!r||("get"in r?!e.__esModule:r.writable||r.configurable))&&(r={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(n,s,r)}:function(n,e,t,s){s===void 0&&(s=t),n[s]=e[t]}),Ct=Pe&&Pe.__exportStar||function(n,e){for(var t in n)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&Dc(e,n,t)};Object.defineProperty(Pe,"__esModule",{value:!0});Ct(so(),Pe);Ct(io(),Pe);Ct(co(),Pe);Ct(uo(),Pe);Ct(ho(),Pe)});var Fs=R(On=>{"use strict";Object.defineProperty(On,"__esModule",{value:!0});On.SettingManager=void 0;var Ls=te(),qc=Ns(),kn=he(),Tc="api/settings",xs=class extends qc.DataConnector{constructor(e={}){var t;super(),this.serverSettings=(t=e.serverSettings)!==null&&t!==void 0?t:kn.ServerConnection.makeSettings()}async fetch(e){if(!e)throw new Error("Plugin `id` parameter is required for settings fetch.");let{serverSettings:t}=this,{baseUrl:s,appUrl:r}=t,{makeRequest:i,ResponseError:o}=kn.ServerConnection,a=s+r,h=Pt.url(a,e),c=await i(h,{},t);if(c.status!==200)throw await o.create(c);return c.json()}async list(e){var t,s,r,i;let{serverSettings:o}=this,{baseUrl:a,appUrl:h}=o,{makeRequest:c,ResponseError:u}=kn.ServerConnection,l=a+h,d=Pt.url(l,"",e==="ids"),v=await c(d,{},o);if(v.status!==200)throw new u(v);let m=await v.json(),q=(s=(t=m==null?void 0:m.settings)===null||t===void 0?void 0:t.map(T=>T.id))!==null&&s!==void 0?s:[],I=[];return e||(I=(i=(r=m==null?void 0:m.settings)===null||r===void 0?void 0:r.map(T=>(T.data={composite:{},user:{}},T)))!==null&&i!==void 0?i:[]),{ids:q,values:I}}async save(e,t){let{serverSettings:s}=this,{baseUrl:r,appUrl:i}=s,{makeRequest:o,ResponseError:a}=kn.ServerConnection,h=r+i,c=Pt.url(h,e),u={body:JSON.stringify({raw:t}),method:"PUT"},l=await o(c,u,s);if(l.status!==204)throw new a(l)}};On.SettingManager=xs;var Pt;(function(n){function e(t,s,r){let i=r?Ls.URLExt.objectToQueryString({ids_only:!0}):"",o=Ls.URLExt.join(t,Tc),a=Ls.URLExt.join(o,s);if(!a.startsWith(o))throw new Error("Can only be used for workspaces requests");return`${a}${i}`}n.url=e})(Pt||(Pt={}))});var It=R(ye=>{"use strict";Object.defineProperty(ye,"__esModule",{value:!0});ye.TerminalAPIClient=ye.TERMINAL_SERVICE_URL=void 0;ye.isAvailable=zs;ye.startNew=fo;ye.listRunning=_o;ye.shutdownTerminal=po;var Mt=te(),Ue=he();ye.TERMINAL_SERVICE_URL="api/terminals";function zs(){return String(Mt.PageConfig.getOption("terminalsAvailable")).toLowerCase()==="true"}async function fo(n=Ue.ServerConnection.makeSettings(),e,t){Et.errorIfNotAvailable();let s=Mt.URLExt.join(n.baseUrl,ye.TERMINAL_SERVICE_URL),r={method:"POST",body:JSON.stringify({name:e,cwd:t})},i=await Ue.ServerConnection.makeRequest(s,r,n);if(i.status!==200)throw await Ue.ServerConnection.ResponseError.create(i);return await i.json()}async function _o(n=Ue.ServerConnection.makeSettings()){Et.errorIfNotAvailable();let e=Mt.URLExt.join(n.baseUrl,ye.TERMINAL_SERVICE_URL),t=await Ue.ServerConnection.makeRequest(e,{},n);if(t.status!==200)throw await Ue.ServerConnection.ResponseError.create(t);let s=await t.json();if(!Array.isArray(s))throw new Error("Invalid terminal list");return s}async function po(n,e=Ue.ServerConnection.makeSettings()){var t;Et.errorIfNotAvailable();let s=Mt.URLExt.join(e.baseUrl,ye.TERMINAL_SERVICE_URL),r=Mt.URLExt.join(s,n);if(!r.startsWith(s))throw new Error("Can only be used for terminal requests");let i={method:"DELETE"},o=await Ue.ServerConnection.makeRequest(r,i,e);if(o.status===404){let h=(t=(await o.json()).message)!==null&&t!==void 0?t:`The terminal session "${n}"" does not exist on the server`;console.warn(h)}else if(o.status!==204)throw await Ue.ServerConnection.ResponseError.create(o)}var Ks=class{constructor(e={}){var t;this.serverSettings=(t=e.serverSettings)!==null&&t!==void 0?t:Ue.ServerConnection.makeSettings()}get isAvailable(){return zs()}async startNew(e={}){let{name:t,cwd:s}=e;return fo(this.serverSettings,t,s)}async listRunning(){return _o(this.serverSettings)}async shutdown(e){return po(e,this.serverSettings)}};ye.TerminalAPIClient=Ks;var Et;(function(n){function e(){if(!zs())throw new Error("Terminals Unavailable")}n.errorIfNotAvailable=e})(Et||(Et={}))});var go=R(Dn=>{"use strict";Object.defineProperty(Dn,"__esModule",{value:!0});Dn.isAvailable=void 0;var jc=It();Object.defineProperty(Dn,"isAvailable",{enumerable:!0,get:function(){return jc.isAvailable}})});var mo=R(Tn=>{"use strict";Object.defineProperty(Tn,"__esModule",{value:!0});Tn.TerminalConnection=void 0;var Uc=te(),Ac=Z(),qn=ee(),Nc=Ae(),Lc=It(),Vs=class n{constructor(e){var t,s;this._createSocket=()=>{this._errorIfDisposed(),this._clearSocket(),this._updateConnectionStatus("connecting");let r=this._name,i=this.serverSettings,o=Uc.URLExt.join(i.wsUrl,"terminals","websocket",encodeURIComponent(r)),a=i.token;i.appendToken&&a!==""&&(o=o+`?token=${encodeURIComponent(a)}`),this._ws=new i.WebSocket(o),this._ws.onmessage=this._onWSMessage,this._ws.onclose=this._onWSClose,this._ws.onerror=this._onWSClose},this._onWSMessage=r=>{if(this._isDisposed)return;let i=JSON.parse(r.data);if(i[0]==="disconnect"&&this.dispose(),this._connectionStatus==="connecting"){i[0]==="setup"&&this._updateConnectionStatus("connected");return}this._messageReceived.emit({type:i[0],content:i.slice(1)})},this._onWSClose=r=>{console.warn(`Terminal websocket closed: ${r.code}`),this.isDisposed||this._reconnect()},this._connectionStatus="connecting",this._connectionStatusChanged=new qn.Signal(this),this._isDisposed=!1,this._disposed=new qn.Signal(this),this._messageReceived=new qn.Signal(this),this._reconnectTimeout=null,this._ws=null,this._noOp=()=>{},this._reconnectLimit=7,this._reconnectAttempt=0,this._pendingMessages=[],this._name=e.model.name,this.serverSettings=(t=e.serverSettings)!==null&&t!==void 0?t:Nc.ServerConnection.makeSettings(),this._terminalAPIClient=(s=e.terminalAPIClient)!==null&&s!==void 0?s:new Lc.TerminalAPIClient({serverSettings:this.serverSettings}),this._createSocket()}get disposed(){return this._disposed}get messageReceived(){return this._messageReceived}get name(){return this._name}get model(){return{name:this._name}}get isDisposed(){return this._isDisposed}dispose(){this._isDisposed||(this._isDisposed=!0,this._disposed.emit(),this._updateConnectionStatus("disconnected"),this._clearSocket(),qn.Signal.clearData(this))}send(e){this._sendMessage(e)}_sendMessage(e,t=!0){if(!(this._isDisposed||!e.content))if(this.connectionStatus==="connected"&&this._ws){let s=[e.type,...e.content];this._ws.send(JSON.stringify(s))}else if(t)this._pendingMessages.push(e);else throw new Error(`Could not send message: ${JSON.stringify(e)}`)}_sendPending(){for(;this.connectionStatus==="connected"&&this._pendingMessages.length>0;)this._sendMessage(this._pendingMessages[0],!1),this._pendingMessages.shift()}reconnect(){this._errorIfDisposed();let e=new Ac.PromiseDelegate,t=(s,r)=>{r==="connected"?(e.resolve(),this.connectionStatusChanged.disconnect(t,this)):r==="disconnected"&&(e.reject(new Error("Terminal connection disconnected")),this.connectionStatusChanged.disconnect(t,this))};return this.connectionStatusChanged.connect(t,this),this._reconnectAttempt=0,this._reconnect(),e.promise}_reconnect(){if(this._errorIfDisposed(),clearTimeout(this._reconnectTimeout),this._reconnectAttempt<this._reconnectLimit){this._updateConnectionStatus("connecting");let e=Bs.getRandomIntInclusive(0,1e3*(Math.pow(2,this._reconnectAttempt)-1));console.error(`Connection lost, reconnecting in ${Math.floor(e/1e3)} seconds.`),this._reconnectTimeout=setTimeout(this._createSocket,e),this._reconnectAttempt+=1}else this._updateConnectionStatus("disconnected");this._clearSocket()}_clearSocket(){this._ws!==null&&(this._ws.onopen=this._noOp,this._ws.onclose=this._noOp,this._ws.onerror=this._noOp,this._ws.onmessage=this._noOp,this._ws.close(),this._ws=null)}async shutdown(){await this._terminalAPIClient.shutdown(this.name),this.dispose()}clone(){return new n({model:this.model,serverSettings:this.serverSettings,terminalAPIClient:this._terminalAPIClient})}_updateConnectionStatus(e){this._connectionStatus!==e&&(this._connectionStatus=e,e!=="connecting"&&(this._reconnectAttempt=0,clearTimeout(this._reconnectTimeout)),e==="connected"&&this._sendPending(),this._connectionStatusChanged.emit(e))}_errorIfDisposed(){if(this.isDisposed)throw new Error("Terminal connection is disposed")}get connectionStatusChanged(){return this._connectionStatusChanged}get connectionStatus(){return this._connectionStatus}};Tn.TerminalConnection=Vs;var Bs;(function(n){function e(t,s){return t=Math.ceil(t),s=Math.floor(s),Math.floor(Math.random()*(s-t+1))+t}n.getRandomIntInclusive=e})(Bs||(Bs={}))});var yo=R(kt=>{"use strict";Object.defineProperty(kt,"__esModule",{value:!0});kt.TerminalManager=void 0;var xc=He(),vo=ee(),Fc=Ae(),Kc=$e(),zc=It(),Vc=mo(),Rt=class extends Kc.BaseManager{constructor(e={}){var t,s;if(super(e),this._isReady=!1,this._names=[],this._terminalConnections=new Set,this._runningChanged=new vo.Signal(this),this._connectionFailure=new vo.Signal(this),this._terminalAPIClient=(t=e.terminalAPIClient)!==null&&t!==void 0?t:new zc.TerminalAPIClient({serverSettings:this.serverSettings}),!this.isAvailable()){this._ready=Promise.reject("Terminals unavailable"),this._ready.catch(i=>{});return}let r=this._pollModels=new xc.Poll({auto:!1,factory:()=>this.requestRunning(),frequency:{interval:10*1e3,backoff:!0,max:300*1e3},name:"@jupyterlab/services:TerminalManager#models",standby:(s=e.standby)!==null&&s!==void 0?s:"when-hidden"});this._ready=(async()=>{await r.start(),await r.tick,this._isReady=!0})()}get isReady(){return this._isReady}get ready(){return this._ready}get runningChanged(){return this._runningChanged}get connectionFailure(){return this._connectionFailure}dispose(){var e;this.isDisposed||(this._names.length=0,this._terminalConnections.forEach(t=>t.dispose()),(e=this._pollModels)===null||e===void 0||e.dispose(),super.dispose())}isAvailable(){return this._terminalAPIClient.isAvailable}connectTo(e){let t=new Vc.TerminalConnection({...e,serverSettings:this.serverSettings,terminalAPIClient:this._terminalAPIClient});return this._onStarted(t),this._names.includes(e.model.name)||this.refreshRunning().catch(()=>{}),t}running(){return this._models[Symbol.iterator]()}async refreshRunning(){this._pollModels&&(await this._pollModels.refresh(),await this._pollModels.tick)}async startNew(e={}){let{name:t,cwd:s}=e,r=await this._terminalAPIClient.startNew({name:t,cwd:s});return await this.refreshRunning(),this.connectTo({model:r})}async shutdown(e){await this._terminalAPIClient.shutdown(e),await this.refreshRunning()}async shutdownAll(){await this.refreshRunning(),await Promise.all(this._names.map(e=>this._terminalAPIClient.shutdown(e))),await this.refreshRunning()}async requestRunning(){var e,t;let s;try{s=await this._terminalAPIClient.listRunning()}catch(i){throw(i instanceof Fc.ServerConnection.NetworkError||((e=i.response)===null||e===void 0?void 0:e.status)===503||((t=i.response)===null||t===void 0?void 0:t.status)===424)&&this._connectionFailure.emit(i),i}if(this.isDisposed)return;let r=s.map(({name:i})=>i).sort();r!==this._names&&(this._names=r,this._terminalConnections.forEach(i=>{r.includes(i.name)||i.dispose()}),this._runningChanged.emit(this._models))}_onStarted(e){this._terminalConnections.add(e),e.disposed.connect(this._onDisposed,this)}_onDisposed(e){this._terminalConnections.delete(e),this.refreshRunning().catch(()=>{})}get _models(){return this._names.map(e=>({name:e}))}};kt.TerminalManager=Rt;(function(n){class e extends n{constructor(){super(...arguments),this._readyPromise=new Promise(()=>{})}get isActive(){return!1}get parentReady(){return super.ready}get ready(){return this.parentReady.then(()=>this._readyPromise)}async startNew(s){return Promise.reject(new Error("Not implemented in no-op Terminal Manager"))}connectTo(s){throw Error("Not implemented in no-op Terminal Manager")}async shutdown(s){return Promise.reject(new Error("Not implemented in no-op Terminal Manager"))}async requestRunning(){return Promise.resolve()}}n.NoopManager=e})(Rt||(kt.TerminalManager=Rt={}))});var Ws=R(ge=>{"use strict";var wo=ge&&ge.__createBinding||(Object.create?function(n,e,t,s){s===void 0&&(s=t);var r=Object.getOwnPropertyDescriptor(e,t);(!r||("get"in r?!e.__esModule:r.writable||r.configurable))&&(r={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(n,s,r)}:function(n,e,t,s){s===void 0&&(s=t),n[s]=e[t]}),Bc=ge&&ge.__setModuleDefault||(Object.create?function(n,e){Object.defineProperty(n,"default",{enumerable:!0,value:e})}:function(n,e){n.default=e}),So=ge&&ge.__importStar||function(n){if(n&&n.__esModule)return n;var e={};if(n!=null)for(var t in n)t!=="default"&&Object.prototype.hasOwnProperty.call(n,t)&&wo(e,n,t);return Bc(e,n),e},Wc=ge&&ge.__exportStar||function(n,e){for(var t in n)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&wo(e,n,t)};Object.defineProperty(ge,"__esModule",{value:!0});ge.TerminalAPI=ge.Terminal=void 0;var $c=So(go());ge.Terminal=$c;var Hc=So(It());ge.TerminalAPI=Hc;Wc(yo(),ge)});var Co=R(bo=>{"use strict";Object.defineProperty(bo,"__esModule",{value:!0})});var Hs=R(jn=>{"use strict";Object.defineProperty(jn,"__esModule",{value:!0});jn.UserAPIClient=void 0;var Po=he(),Jc=te(),Gc="api/me",$s=class{constructor(e={}){var t;this.serverSettings=(t=e.serverSettings)!==null&&t!==void 0?t:Po.ServerConnection.makeSettings()}async get(){let{baseUrl:e}=this.serverSettings,{makeRequest:t,ResponseError:s}=Po.ServerConnection,r=Jc.URLExt.join(e,Gc),i=await t(r,{},this.serverSettings);if(i.status!==200)throw await s.create(i);return await i.json()}};jn.UserAPIClient=$s});var Eo=R(Un=>{"use strict";Object.defineProperty(Un,"__esModule",{value:!0});Un.UserManager=void 0;var Xc=Z(),Yc=He(),Mo=ee(),Qc=$e(),Zc=Hs(),Js="@jupyterlab/services:UserManager#user",Gs=class extends Qc.BaseManager{constructor(e={}){var t,s;super(e),this._isReady=!1,this._userChanged=new Mo.Signal(this),this._connectionFailure=new Mo.Signal(this),this._userApiClient=(t=e.userApiClient)!==null&&t!==void 0?t:new Zc.UserAPIClient({serverSettings:this.serverSettings}),this._ready=this.requestUser().then(()=>{this.isDisposed||(this._isReady=!0)}).catch(r=>new Promise(()=>{})),this._pollUser=new Yc.Poll({auto:!1,factory:()=>this.requestUser(),frequency:{interval:61*1e3,backoff:!0,max:300*1e3},name:Js,standby:(s=e.standby)!==null&&s!==void 0?s:"when-hidden"}),this.ready.then(()=>{this._pollUser.start()})}get isReady(){return this._isReady}get ready(){return this._ready}get identity(){return this._identity}get permissions(){return this._permissions}get userChanged(){return this._userChanged}get connectionFailure(){return this._connectionFailure}dispose(){this._pollUser.dispose(),super.dispose()}async refreshUser(){await this._pollUser.refresh(),await this._pollUser.tick}async requestUser(){if(this.isDisposed)return;let e={identity:this._identity,permissions:this._permissions},t=await this._userApiClient.get(),s=t.identity,{localStorage:r}=window,i=r.getItem(Js);if(i&&(!s.initials||!s.color)){let o=JSON.parse(i);s.initials=s.initials||o.initials||s.name.substring(0,1),s.color=s.color||o.color||Xs.getRandomColor()}Xc.JSONExt.deepEqual(t,e)||(this._identity=s,this._permissions=t.permissions,r.setItem(Js,JSON.stringify(s)),this._userChanged.emit(t))}};Un.UserManager=Gs;var Xs;(function(n){let e=["var(--jp-collaborator-color1)","var(--jp-collaborator-color2)","var(--jp-collaborator-color3)","var(--jp-collaborator-color4)","var(--jp-collaborator-color5)","var(--jp-collaborator-color6)","var(--jp-collaborator-color7)"];n.getRandomColor=()=>e[Math.floor(Math.random()*e.length)]})(Xs||(Xs={}))});var Ys=R(me=>{"use strict";var Io=me&&me.__createBinding||(Object.create?function(n,e,t,s){s===void 0&&(s=t);var r=Object.getOwnPropertyDescriptor(e,t);(!r||("get"in r?!e.__esModule:r.writable||r.configurable))&&(r={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(n,s,r)}:function(n,e,t,s){s===void 0&&(s=t),n[s]=e[t]}),eu=me&&me.__setModuleDefault||(Object.create?function(n,e){Object.defineProperty(n,"default",{enumerable:!0,value:e})}:function(n,e){n.default=e}),Ro=me&&me.__importStar||function(n){if(n&&n.__esModule)return n;var e={};if(n!=null)for(var t in n)t!=="default"&&Object.prototype.hasOwnProperty.call(n,t)&&Io(e,n,t);return eu(e,n),e},tu=me&&me.__exportStar||function(n,e){for(var t in n)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&Io(e,n,t)};Object.defineProperty(me,"__esModule",{value:!0});me.UserAPI=me.User=void 0;var nu=Ro(Co());me.User=nu;var su=Ro(Hs());me.UserAPI=su;tu(Eo(),me)});var Zs=R(An=>{"use strict";Object.defineProperty(An,"__esModule",{value:!0});An.WorkspaceManager=void 0;var ko=te(),ru=Ns(),Ot=he(),iu="api/workspaces",Qs=class extends ru.DataConnector{constructor(e={}){var t;super(),this.serverSettings=(t=e.serverSettings)!==null&&t!==void 0?t:Ot.ServerConnection.makeSettings()}async fetch(e){let{serverSettings:t}=this,{baseUrl:s,appUrl:r}=t,{makeRequest:i,ResponseError:o}=Ot.ServerConnection,a=s+r,h=it.url(a,e),c=await i(h,{},t);if(c.status!==200)throw await o.create(c);return c.json()}async list(){let{serverSettings:e}=this,{baseUrl:t,appUrl:s}=e,{makeRequest:r,ResponseError:i}=Ot.ServerConnection,o=t+s,a=it.url(o,""),h=await r(a,{},e);if(h.status!==200)throw await i.create(h);return(await h.json()).workspaces}async remove(e){let{serverSettings:t}=this,{baseUrl:s,appUrl:r}=t,{makeRequest:i,ResponseError:o}=Ot.ServerConnection,a=s+r,h=it.url(a,e),u=await i(h,{method:"DELETE"},t);if(u.status!==204)throw await o.create(u)}async save(e,t){let{serverSettings:s}=this,{baseUrl:r,appUrl:i}=s,{makeRequest:o,ResponseError:a}=Ot.ServerConnection,h=r+i,c=it.url(h,e),u={body:JSON.stringify(t),method:"PUT"},l=await o(c,u,s);if(l.status!==204)throw await a.create(l)}};An.WorkspaceManager=Qs;var it;(function(n){function e(t,s){let r=ko.URLExt.join(t,iu),i=ko.URLExt.join(r,s);if(!i.startsWith(r))throw new Error("Can only be used for workspaces requests");return i}n.url=e})(it||(it={}))});var Do=R(Nn=>{"use strict";Object.defineProperty(Nn,"__esModule",{value:!0});Nn.ServiceManager=void 0;var Oo=ee(),ou=zi(),au=ds(),lu=_s(),cu=Cs(),uu=Ms(),hu=Ds(),du=he(),fu=js(),_u=Fs(),pu=Ws(),gu=Ys(),mu=Zs(),er=class{constructor(e={}){var t,s;this._isDisposed=!1,this._connectionFailure=new Oo.Signal(this),this._isReady=!1;let r=e.defaultDrive,i=(t=e.serverSettings)!==null&&t!==void 0?t:du.ServerConnection.makeSettings(),o=(s=e.standby)!==null&&s!==void 0?s:"when-hidden",a={defaultDrive:r,serverSettings:i,standby:o};this.serverSettings=i,this.contents=e.contents||new au.ContentsManager(a),this.events=e.events||new lu.EventManager(a),this.kernels=e.kernels||new cu.KernelManager(a),this.sessions=e.sessions||new fu.SessionManager({...a,kernelManager:this.kernels}),this.settings=e.settings||new _u.SettingManager(a),this.terminals=e.terminals||new pu.TerminalManager(a),this.builder=e.builder||new ou.BuildManager(a),this.workspaces=e.workspaces||new mu.WorkspaceManager(a),this.nbconvert=e.nbconvert||new hu.NbConvertManager(a),this.kernelspecs=e.kernelspecs||new uu.KernelSpecManager(a),this.user=e.user||new gu.UserManager(a),this.kernelspecs.connectionFailure.connect(this._onConnectionFailure,this),this.sessions.connectionFailure.connect(this._onConnectionFailure,this),this.terminals.connectionFailure.connect(this._onConnectionFailure,this);let h=[this.sessions.ready,this.kernelspecs.ready];this.terminals.isAvailable()&&h.push(this.terminals.ready),this._readyPromise=Promise.all(h).then(()=>{this._isReady=!0})}get connectionFailure(){return this._connectionFailure}get isDisposed(){return this._isDisposed}dispose(){this.isDisposed||(this._isDisposed=!0,Oo.Signal.clearData(this),this.contents.dispose(),this.events.dispose(),this.sessions.dispose(),this.terminals.dispose())}get isReady(){return this._isReady}get ready(){return this._readyPromise}_onConnectionFailure(e,t){this._connectionFailure.emit(t)}};Nn.ServiceManager=er});var qo=R(L=>{"use strict";Object.defineProperty(L,"__esModule",{value:!0});L.IWorkspaceManager=L.IUserManager=L.ITerminalManager=L.IServiceManager=L.ISettingManager=L.ISessionManager=L.IServerSettings=L.INbConvertManager=L.IKernelSpecManager=L.IKernelManager=L.IEventManager=L.IDefaultDrive=L.IDefaultContentProvider=L.IContentsManager=L.IConfigSectionManager=L.IConnectionStatus=void 0;var le=Z();L.IConnectionStatus=new le.Token("@jupyterlab/application:IConnectionStatus","A service providing the application connection status.");L.IConfigSectionManager=new le.Token("@jupyterlab/services:IConfigSectionManager","A service providing the config section manager.");L.IContentsManager=new le.Token("@jupyterlab/services:IContentsManager","The contents manager token.");L.IDefaultContentProvider=new le.Token("@jupyterlab/services:IDefaultContentProvider","The default content provider for the contents manager.");L.IDefaultDrive=new le.Token("@jupyterlab/services:IDefaultDrive","The default drive for the contents manager.");L.IEventManager=new le.Token("@jupyterlab/services:IEventManager","The event manager token.");L.IKernelManager=new le.Token("@jupyterlab/services:IKernelManager","The kernel manager token.");L.IKernelSpecManager=new le.Token("@jupyterlab/services:IKernelSpecManager","The kernel spec manager token.");L.INbConvertManager=new le.Token("@jupyterlab/services:INbConvertManager","The nbconvert manager token.");L.IServerSettings=new le.Token("@jupyterlab/services:IServerSettings","The server settings for the application.");L.ISessionManager=new le.Token("@jupyterlab/services:ISessionManager","The session manager token.");L.ISettingManager=new le.Token("@jupyterlab/services:ISettingManager","The setting manager token.");L.IServiceManager=new le.Token("@jupyterlab/services:IServiceManager","The service manager for the application.");L.ITerminalManager=new le.Token("@jupyterlab/services:ITerminalManager","The terminal manager token.");L.IUserManager=new le.Token("@jupyterlab/services:IUserManager","The user manager token.");L.IWorkspaceManager=new le.Token("@jupyterlab/services:IWorkspaceManager","The workspace manager token.")});var Ae=R($=>{"use strict";var vu=$&&$.__createBinding||(Object.create?function(n,e,t,s){s===void 0&&(s=t);var r=Object.getOwnPropertyDescriptor(e,t);(!r||("get"in r?!e.__esModule:r.writable||r.configurable))&&(r={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(n,s,r)}:function(n,e,t,s){s===void 0&&(s=t),n[s]=e[t]}),ce=$&&$.__exportStar||function(n,e){for(var t in n)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&vu(e,n,t)};Object.defineProperty($,"__esModule",{value:!0});ce($e(),$);ce(ni(),$);ce(si(),$);ce(ds(),$);ce(_s(),$);ce(Cs(),$);ce(Ms(),$);ce(Do(),$);ce(he(),$);ce(js(),$);ce(Fs(),$);ce(Ws(),$);ce(qo(),$);ce(Ys(),$);ce(Zs(),$);ce(Ds(),$)});function To(n){return"node"in n}var jo=sr(()=>{});var No={};Qo(No,{BLOCK_SIZE:()=>bu,ContentsAPI:()=>Kn,DRIVE_SEPARATOR:()=>Ao,DriveFS:()=>Dt,DriveFSEmscriptenNodeOps:()=>Fn,DriveFSEmscriptenStreamOps:()=>xn,ServiceWorkerContentsAPI:()=>zn});var Uo,Ao,bu,Cu,Pu,Ln,xn,Fn,Kn,zn,Dt,tr=sr(()=>{Uo=Wn(Z());jo();Ao=":",bu=4096,Cu=new TextEncoder,Pu=new TextDecoder("utf-8"),Ln={0:!1,1:!0,2:!0,64:!0,65:!0,66:!0,129:!0,193:!0,514:!0,577:!0,578:!0,705:!0,706:!0,1024:!0,1025:!0,1026:!0,1089:!0,1090:!0,1153:!0,1154:!0,1217:!0,1218:!0,4096:!0,4098:!0},xn=class{constructor(e){this.fs=e}open(e){var t;let s=this.fs.realPath(e.node);if(this.fs.FS.isFile(e.node.mode))try{let r=this.fs.API.get(s);e.file=r}catch{let i=(t=e.flags)!==null&&t!==void 0?t:e.shared.flags,o=typeof i=="string"?parseInt(i,10):i;o&=8191;let a=!0;if(o in Ln&&(a=Ln[o]),a){e.node=this.fs.node_ops.mknod(e.node.parent,e.node.name,e.node.mode,0);let h=this.fs.API.get(s);e.file=h}else throw new this.fs.FS.ErrnoError(this.fs.ERRNO_CODES.ENOENT)}}close(e){var t;if(!this.fs.FS.isFile(e.node.mode)||!e.file)return;let s=this.fs.realPath(e.node),r=(t=e.flags)!==null&&t!==void 0?t:e.shared.flags,i=typeof r=="string"?parseInt(r,10):r;i&=8191;let o=!0;i in Ln&&(o=Ln[i]),o&&this.fs.API.put(s,e.file),e.file=void 0}read(e,t,s,r,i){if(r<=0||e.file===void 0||i>=(e.file.data.length||0))return 0;let o=Math.min(e.file.data.length-i,r);return t.set(e.file.data.subarray(i,i+o),s),o}write(e,t,s,r,i){var o;if(r<=0||e.file===void 0)return 0;let a=Date.now();if(e.node.timestamp=a,e.node.atime=a,e.node.mtime=a,e.node.ctime=a,i+r>(((o=e.file)===null||o===void 0?void 0:o.data.length)||0)){let h=e.file.data?e.file.data:new Uint8Array;e.file.data=new Uint8Array(i+r),e.file.data.set(h)}return e.file.data.set(t.subarray(s,s+r),i),r}llseek(e,t,s){var r;let i=t;if(s===1)i+=(r=e.position)!==null&&r!==void 0?r:e.shared.position;else if(s===2&&this.fs.FS.isFile(e.node.mode))if(e.file!==void 0)i+=e.file.data.length;else throw new this.fs.FS.ErrnoError(this.fs.ERRNO_CODES.EPERM);if(i<0)throw new this.fs.FS.ErrnoError(this.fs.ERRNO_CODES.EINVAL);return i}},Fn=class{constructor(e){this.node=t=>To(t)?t.node:t,this.getattr=t=>{let s=this.node(t);return{...this.fs.API.getattr(this.fs.realPath(s)),mode:s.mode,ino:s.id}},this.setattr=(t,s)=>{let r=this.node(t);for(let[i,o]of Object.entries(s))switch(i){case"mode":r.mode=o;break;case"timestamp":r.timestamp=o;break;case"atime":r.atime=o;break;case"mtime":r.mtime=o;break;case"ctime":r.ctime=o;break;case"size":{let a=o,h=this.fs.realPath(r);if(this.fs.FS.isFile(r.mode)&&a>=0){let c;try{c=this.fs.API.get(h)}catch{break}let u=c.data?c.data:new Uint8Array;a!==u.length&&(a<u.length?c.data=c.data.slice(0,a):(c.data=new Uint8Array(a),c.data.set(u)),this.fs.API.put(h,c))}else console.warn("setattr size of",a,"on",r,"not yet implemented");break}case"dontFollow":break;default:console.warn("setattr",i,"of",o,"on",r,"not yet implemented");break}},this.lookup=(t,s)=>{let r=this.node(t),i=this.fs.PATH.join2(this.fs.realPath(r),s),o=this.fs.API.lookup(i);if(!o.ok)throw new this.fs.FS.ErrnoError(this.fs.ERRNO_CODES.ENOENT);return this.fs.createNode(r,s,o.mode,0)},this.mknod=(t,s,r,i)=>{let o=this.node(t),a=this.fs.PATH.join2(this.fs.realPath(o),s);return this.fs.API.mknod(a,r),this.fs.createNode(o,s,r,i)},this.rename=(t,s,r)=>{let i=this.node(t),o=this.node(s);this.fs.API.rename(i.parent?this.fs.PATH.join2(this.fs.realPath(i.parent),i.name):i.name,this.fs.PATH.join2(this.fs.realPath(o),r)),i.name=r,i.parent=o},this.unlink=(t,s)=>this.fs.API.rmdir(this.fs.PATH.join2(this.fs.realPath(this.node(t)),s)),this.rmdir=(t,s)=>this.fs.API.rmdir(this.fs.PATH.join2(this.fs.realPath(this.node(t)),s)),this.readdir=t=>this.fs.API.readdir(this.fs.realPath(this.node(t))),this.symlink=(t,s,r)=>{throw new this.fs.FS.ErrnoError(this.fs.ERRNO_CODES.EPERM)},this.readlink=t=>{throw new this.fs.FS.ErrnoError(this.fs.ERRNO_CODES.EINVAL)},this.fs=e}},Kn=class{constructor(e){this._driveName=e.driveName,this._mountpoint=e.mountpoint,this.FS=e.FS,this.ERRNO_CODES=e.ERRNO_CODES}lookup(e){return this.request({method:"lookup",path:this.normalizePath(e)})}getmode(e){return this.request({method:"getmode",path:this.normalizePath(e)})}mknod(e,t){return this.request({method:"mknod",path:this.normalizePath(e),data:{mode:t}})}rename(e,t){return this.request({method:"rename",path:this.normalizePath(e),data:{newPath:this.normalizePath(t)}})}readdir(e){let t=this.request({method:"readdir",path:this.normalizePath(e)});return t.push("."),t.push(".."),t}rmdir(e){return this.request({method:"rmdir",path:this.normalizePath(e)})}get(e){let t=this.request({method:"get",path:this.normalizePath(e)});if(!t)throw new this.FS.ErrnoError(this.ERRNO_CODES.ENOENT);let s=t.content,r=t.format;switch(r){case"json":case"text":return{data:Cu.encode(s),format:r};case"base64":{let i=atob(s),o=i.length,a=new Uint8Array(o);for(let h=0;h<o;h++)a[h]=i.charCodeAt(h);return{data:a,format:r}}default:throw new this.FS.ErrnoError(this.ERRNO_CODES.ENOENT)}}put(e,t){switch(t.format){case"json":case"text":return this.request({method:"put",path:this.normalizePath(e),data:{format:t.format,data:Pu.decode(t.data)}});case"base64":{let s="";for(let r=0;r<t.data.byteLength;r++)s+=String.fromCharCode(t.data[r]);return this.request({method:"put",path:this.normalizePath(e),data:{format:t.format,data:btoa(s)}})}}}getattr(e){let t=this.request({method:"getattr",path:this.normalizePath(e)}),s=new Date(0);return t.atime=t.atime?new Date(t.atime):s,t.mtime=t.mtime?new Date(t.mtime):s,t.ctime=t.ctime?new Date(t.ctime):s,t.size=t.size||0,t}normalizePath(e){return e.startsWith(this._mountpoint)&&(e=e.slice(this._mountpoint.length)),this._driveName&&(e=`${this._driveName}${Ao}${e}`),e}},zn=class extends Kn{constructor(e){super(e),this._baseUrl=e.baseUrl,this._browsingContextId=e.browsingContextId||""}request(e){let t=new XMLHttpRequest;t.open("POST",encodeURI(this.endpoint),!1);let s=Uo.UUID.uuid4(),r={data:{...e,requestId:s},browsingContextId:this._browsingContextId,requestId:s};try{t.send(JSON.stringify(r))}catch(i){console.error(i)}if(t.status>=400)throw new this.FS.ErrnoError(this.ERRNO_CODES.EINVAL);return JSON.parse(t.responseText)}get endpoint(){return`${this._baseUrl}api/drive`}},Dt=class{constructor(e){this.FS=e.FS,this.PATH=e.PATH,this.ERRNO_CODES=e.ERRNO_CODES,this.API=this.createAPI(e),this.driveName=e.driveName,this.node_ops=new Fn(this),this.stream_ops=new xn(this)}createAPI(e){if(!e.browsingContextId||!e.baseUrl)throw new Error("Cannot create service-worker API without current browsingContextId");return new zn(e)}mount(e){return this.createNode(null,e.mountpoint,16895,0)}createNode(e,t,s,r){let i=this.FS;if(!i.isDir(s)&&!i.isFile(s))throw new i.ErrnoError(this.ERRNO_CODES.EINVAL);let o=i.createNode(e,t,s,r);return o.node_ops=this.node_ops,o.stream_ops=this.stream_ops,o}getMode(e){return this.API.getmode(e)}realPath(e){let t=[],s=e;for(t.push(s.name);s.parent!==s;)s=s.parent,t.push(s.name);return t.reverse(),this.PATH.join.apply(null,t)}}});var ir=Symbol("Comlink.proxy"),ea=Symbol("Comlink.endpoint"),ta=Symbol("Comlink.releaseProxy"),$n=Symbol("Comlink.finalizer"),Tt=Symbol("Comlink.thrown"),or=n=>typeof n=="object"&&n!==null||typeof n=="function",na={canHandle:n=>or(n)&&n[ir],serialize(n){let{port1:e,port2:t}=new MessageChannel;return Nt(n,e),[t,[t]]},deserialize(n){return n.start(),oa(n)}},sa={canHandle:n=>or(n)&&Tt in n,serialize({value:n}){let e;return n instanceof Error?e={isError:!0,value:{message:n.message,name:n.name,stack:n.stack}}:e={isError:!1,value:n},[e,[]]},deserialize(n){throw n.isError?Object.assign(new Error(n.value.message),n.value):n.value}},ar=new Map([["proxy",na],["throw",sa]]);function ra(n,e){for(let t of n)if(e===t||t==="*"||t instanceof RegExp&&t.test(e))return!0;return!1}function Nt(n,e=globalThis,t=["*"]){e.addEventListener("message",function s(r){if(!r||!r.data)return;if(!ra(t,r.origin)){console.warn(`Invalid origin '${r.origin}' for comlink proxy`);return}let{id:i,type:o,path:a}=Object.assign({path:[]},r.data),h=(r.data.argumentList||[]).map(We),c;try{let u=a.slice(0,-1).reduce((d,v)=>d[v],n),l=a.reduce((d,v)=>d[v],n);switch(o){case"GET":c=l;break;case"SET":u[a.slice(-1)[0]]=We(r.data.value),c=!0;break;case"APPLY":c=l.apply(u,h);break;case"CONSTRUCT":{let d=new l(...h);c=ha(d)}break;case"ENDPOINT":{let{port1:d,port2:v}=new MessageChannel;Nt(n,v),c=ua(d,[d])}break;case"RELEASE":c=void 0;break;default:return}}catch(u){c={value:u,[Tt]:0}}Promise.resolve(c).catch(u=>({value:u,[Tt]:0})).then(u=>{let[l,d]=At(u);e.postMessage(Object.assign(Object.assign({},l),{id:i}),d),o==="RELEASE"&&(e.removeEventListener("message",s),lr(e),$n in n&&typeof n[$n]=="function"&&n[$n]())}).catch(u=>{let[l,d]=At({value:new TypeError("Unserializable return value"),[Tt]:0});e.postMessage(Object.assign(Object.assign({},l),{id:i}),d)})}),e.start&&e.start()}function ia(n){return n.constructor.name==="MessagePort"}function lr(n){ia(n)&&n.close()}function oa(n,e){let t=new Map;return n.addEventListener("message",function(r){let{data:i}=r;if(!i||!i.id)return;let o=t.get(i.id);if(o)try{o(i)}finally{t.delete(i.id)}}),Hn(n,t,[],e)}function qt(n){if(n)throw new Error("Proxy has been released and is not useable")}function cr(n){return Xe(n,new Map,{type:"RELEASE"}).then(()=>{lr(n)})}var jt=new WeakMap,Ut="FinalizationRegistry"in globalThis&&new FinalizationRegistry(n=>{let e=(jt.get(n)||0)-1;jt.set(n,e),e===0&&cr(n)});function aa(n,e){let t=(jt.get(e)||0)+1;jt.set(e,t),Ut&&Ut.register(n,e,n)}function la(n){Ut&&Ut.unregister(n)}function Hn(n,e,t=[],s=function(){}){let r=!1,i=new Proxy(s,{get(o,a){if(qt(r),a===ta)return()=>{la(i),cr(n),e.clear(),r=!0};if(a==="then"){if(t.length===0)return{then:()=>i};let h=Xe(n,e,{type:"GET",path:t.map(c=>c.toString())}).then(We);return h.then.bind(h)}return Hn(n,e,[...t,a])},set(o,a,h){qt(r);let[c,u]=At(h);return Xe(n,e,{type:"SET",path:[...t,a].map(l=>l.toString()),value:c},u).then(We)},apply(o,a,h){qt(r);let c=t[t.length-1];if(c===ea)return Xe(n,e,{type:"ENDPOINT"}).then(We);if(c==="bind")return Hn(n,e,t.slice(0,-1));let[u,l]=rr(h);return Xe(n,e,{type:"APPLY",path:t.map(d=>d.toString()),argumentList:u},l).then(We)},construct(o,a){qt(r);let[h,c]=rr(a);return Xe(n,e,{type:"CONSTRUCT",path:t.map(u=>u.toString()),argumentList:h},c).then(We)}});return aa(i,n),i}function ca(n){return Array.prototype.concat.apply([],n)}function rr(n){let e=n.map(At);return[e.map(t=>t[0]),ca(e.map(t=>t[1]))]}var ur=new WeakMap;function ua(n,e){return ur.set(n,e),n}function ha(n){return Object.assign(n,{[ir]:!0})}function At(n){for(let[e,t]of ar)if(t.canHandle(n)){let[s,r]=t.serialize(n);return[{type:"HANDLER",name:e,value:s},r]}return[{type:"RAW",value:n},ur.get(n)||[]]}function We(n){switch(n.type){case"HANDLER":return ar.get(n.name).deserialize(n.value);case"RAW":return n.value}}function Xe(n,e,t,s){return new Promise(r=>{let i=da();e.set(i,r),n.start&&n.start(),n.postMessage(Object.assign({id:i},t),s)})}function da(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}var Lo=Wn(te()),xo=Wn(Ae());tr();var Vn=class{constructor(){this._options=null;this._initializer=null;this._pyodide=null;this._localPath="";this._driveName="";this._driveFS=null;this._sendWorkerMessage=()=>{};this._logMessage=()=>{};this._initialized=new Promise((e,t)=>{this._initializer={resolve:e,reject:t}})}async initialize(e){var t;if(this._options=e,e.location.includes(":")){let s=e.location.split(":");this._driveName=s[0],this._localPath=s[1]}else this._driveName="",this._localPath=e.location;await this.initRuntime(e),await this.initFilesystem(e),await this.initPackageManager(e),await this.initKernel(e),await this.initGlobals(e),(t=this._initializer)==null||t.resolve()}async initRuntime(e){let{pyodideUrl:t,indexUrl:s}=e,r;t.endsWith(".mjs")?r=(await import(t)).loadPyodide:(importScripts(t),r=self.loadPyodide),this._pyodide=await r({indexURL:s,stdout:i=>{console.log(i),this._logMessage({type:"text",level:"info",data:i})},stderr:i=>{console.error(i),this._logMessage({type:"text",level:"critical",data:i})},...e.loadPyodideOptions}),this._pyodide._api.on_fatal=async i=>{let o="";i.name==="Exit"?o="Pyodide has exited and can no longer be used.":o=`Pyodide has suffered a fatal error. Please report this to the Pyodide maintainers.
10
+ The cause of the error was: ${i.name}
11
+ ${i.message}
13
12
  Stack trace:
14
- ${r.stack}`,this._logMessage({type:"text",level:"critical",data:a})}}async initPackageManager(e){if(!this._options)throw new Error("Uninitialized");let{pipliteWheelUrl:t,disablePyPIFallback:n,pipliteUrls:s,loadPyodideOptions:r}=this._options,a=(r||{}).packages||[];a.includes("micropip")||await this._pyodide.loadPackage(["micropip"]),a.includes("piplite")||await this._pyodide.runPythonAsync(`
13
+ ${i.stack}`,this._logMessage({type:"text",level:"critical",data:o})}}async initPackageManager(e){if(!this._options)throw new Error("Uninitialized");let{pipliteWheelUrl:t,disablePyPIFallback:s,pipliteUrls:r,loadPyodideOptions:i}=this._options,o=(i||{}).packages||[];o.includes("micropip")||await this._pyodide.loadPackage(["micropip"]),o.includes("piplite")||await this._pyodide.runPythonAsync(`
15
14
  import micropip
16
15
  await micropip.install('${t}', keep_going=True)
17
16
  `),await this._pyodide.runPythonAsync(`
18
17
  import piplite.piplite
19
- piplite.piplite._PIPLITE_DISABLE_PYPI = ${n?"True":"False"}
20
- piplite.piplite._PIPLITE_URLS = ${JSON.stringify(s)}
21
- `)}async initKernel(e){let t=(e.loadPyodideOptions||{}).packages||[],n=["sqlite3","ipykernel","comm","pyodide_kernel","jedi","ipython"],s=[];for(let r of n)t.includes(r)||s.push(`await piplite.install('${r}', keep_going=True)`);s.push("import pyodide_kernel"),e.mountDrive&&this._localPath&&s.push("import os",`os.chdir("${this._localPath}")`),await this._pyodide.runPythonAsync(s.join(`
22
- `))}async initGlobals(e){let{globals:t}=this._pyodide;this._kernel=t.get("pyodide_kernel").kernel_instance.copy(),this._stdout_stream=t.get("pyodide_kernel").stdout_stream.copy(),this._stderr_stream=t.get("pyodide_kernel").stderr_stream.copy(),this._interpreter=this._kernel.interpreter.copy(),this._interpreter.send_comm=this.sendComm.bind(this)}async initFilesystem(e){if(e.mountDrive){let t="/drive",{FS:n,PATH:s,ERRNO_CODES:r}=this._pyodide,{baseUrl:a}=e,{DriveFS:o}=await Promise.resolve().then(()=>(ws(),vo)),u=new o({FS:n,PATH:s,ERRNO_CODES:r,baseUrl:a,driveName:this._driveName,mountpoint:t,browsingContextId:this._browsingContextId});n.mkdirTree(t),n.mount(u,{},t),n.chdir(t),this._driveFS=u}}mapToObject(e){let t=e instanceof Array?[]:{},n=e instanceof Map?e.entries():Object.entries(e);for(let[s,r]of n)t[s]=r instanceof Map||r instanceof Array?this.mapToObject(r):r;return t}formatResult(e){if(!(e instanceof this._pyodide.ffi.PyProxy))return e;let t=e.toJs();return this.mapToObject(t)}registerWorkerMessageCallback(e){this._sendWorkerMessage=e}registerLogMessageCallback(e){this._logMessage=e}async setup(e){await this._initialized,this._kernel._parent_header=this._pyodide.toPy(e)}async execute(e,t){await this.setup(t);let n=(l,p,v)=>{let _={execution_count:l,data:this.formatResult(p),metadata:this.formatResult(v)};this._sendWorkerMessage({parentHeader:this.formatResult(this._kernel._parent_header).header,bundle:_,type:"execute_result"})},s=(l,p,v)=>{let _={ename:l,evalue:p,traceback:v};this._sendWorkerMessage({parentHeader:this.formatResult(this._kernel._parent_header).header,bundle:_,type:"execute_error"})},r=l=>{let p={wait:this.formatResult(l)};this._sendWorkerMessage({parentHeader:this.formatResult(this._kernel._parent_header).header,bundle:p,type:"clear_output"})},a=(l,p,v)=>{let _={data:this.formatResult(l),metadata:this.formatResult(p),transient:this.formatResult(v)};this._sendWorkerMessage({parentHeader:this.formatResult(this._kernel._parent_header).header,bundle:_,type:"display_data"})},o=(l,p,v)=>{let _={data:this.formatResult(l),metadata:this.formatResult(p),transient:this.formatResult(v)};this._sendWorkerMessage({parentHeader:this.formatResult(this._kernel._parent_header).header,bundle:_,type:"update_display_data"})},u=(l,p)=>{let v={name:this.formatResult(l),text:this.formatResult(p)};this._sendWorkerMessage({parentHeader:this.formatResult(this._kernel._parent_header).header,bundle:v,type:"stream"})};this._stdout_stream.publish_stream_callback=u,this._stderr_stream.publish_stream_callback=u,this._interpreter.display_pub.clear_output_callback=r,this._interpreter.display_pub.display_data_callback=a,this._interpreter.display_pub.update_display_data_callback=o,this._interpreter.displayhook.publish_execution_result=n,this._interpreter.input=this.input.bind(this),this._interpreter.getpass=this.getpass.bind(this);let c=await this._kernel.run(e.code),d=this.formatResult(c);return d.status==="error"&&s(d.ename,d.evalue,d.traceback),d}async complete(e,t){await this.setup(t);let n=this._kernel.complete(e.code,e.cursor_pos);return this.formatResult(n)}async inspect(e,t){await this.setup(t);let n=this._kernel.inspect(e.code,e.cursor_pos,e.detail_level);return this.formatResult(n)}async isComplete(e,t){await this.setup(t);let n=this._kernel.is_complete(e.code);return this.formatResult(n)}async commInfo(e,t){await this.setup(t);let n=this._kernel.comm_info(e.target_name);return{comms:this.formatResult(n),status:"ok"}}async commOpen(e,t){await this.setup(t);let n=this._kernel.comm_manager.comm_open(this._pyodide.toPy(null),this._pyodide.toPy(null),this._pyodide.toPy(e));return this.formatResult(n)}async commMsg(e,t){await this.setup(t);let n=this._kernel.comm_manager.comm_msg(this._pyodide.toPy(null),this._pyodide.toPy(null),this._pyodide.toPy(e));return this.formatResult(n)}async commClose(e,t){await this.setup(t);let n=this._kernel.comm_manager.comm_close(this._pyodide.toPy(null),this._pyodide.toPy(null),this._pyodide.toPy(e));return this.formatResult(n)}async inputReply(e,t){}getpass(e){return e=typeof e=="undefined"?"":e,this.sendInputRequest(e,!0)}input(e){return e=typeof e=="undefined"?"":e,this.sendInputRequest(e,!1)}async sendComm(e,t,n,s,r){this._sendWorkerMessage({type:e,content:this.formatResult(t),metadata:this.formatResult(n),ident:this.formatResult(s),buffers:this.formatResult(r),parentHeader:this.formatResult(this._kernel._parent_header).header})}};var bs=class extends ei{constructor(){super(),this._sendWorkerMessage=e=>{postMessage({_kernelMessage:e})},this._logMessage=e=>{postMessage({_logMessage:e})}}async initFilesystem(e){if(e.mountDrive){let t="/drive",{FS:n,PATH:s,ERRNO_CODES:r}=this._pyodide,{baseUrl:a,browsingContextId:o}=e,u=new Lt({FS:n,PATH:s,ERRNO_CODES:r,baseUrl:a,driveName:this._driveName,mountpoint:t,browsingContextId:o});n.mkdirTree(t),n.mount(u,{},t),n.chdir(t),this._driveFS=u}}sendInputRequest(e,t){var r,a;let n=this.formatResult(this._kernel._parent_header).header,s=wo.KernelMessage.createMessage({channel:"stdin",msgType:"input_request",session:(r=n==null?void 0:n.session)!=null?r:"",parentHeader:n,content:{prompt:e,password:t}});try{if(!this._options)throw new Error("Kernel options not set");let{baseUrl:o,browsingContextId:u}=this._options;if(!u)throw new Error("Kernel browsingContextId not set");let c=new XMLHttpRequest,d=yo.URLExt.join(o,"/api/stdin/kernel");c.open("POST",d,!1);let l=JSON.stringify({browsingContextId:u,data:s});c.send(l);let p=JSON.parse(c.response);if("error"in p)throw new Error(p.error);return(a=p.content)==null?void 0:a.value}catch(o){console.warn(`Failed to request stdin via service worker: ${o}`);return}}},nu=new bs;Vt(nu);export{bs as PyodideComlinkKernel};
18
+ piplite.piplite._PIPLITE_DISABLE_PYPI = ${s?"True":"False"}
19
+ piplite.piplite._PIPLITE_URLS = ${JSON.stringify(r)}
20
+ `)}async initKernel(e){let t=(e.loadPyodideOptions||{}).packages||[],s=["sqlite3","ipykernel","comm","pyodide_kernel","jedi","ipython"],r=[];for(let i of s)t.includes(i)||r.push(`await piplite.install('${i}', keep_going=True)`);r.push("import pyodide_kernel"),e.mountDrive&&this._localPath&&r.push("import os",`os.chdir("${this._localPath}")`),await this._pyodide.runPythonAsync(r.join(`
21
+ `))}async initGlobals(e){let{globals:t}=this._pyodide;this._kernel=t.get("pyodide_kernel").kernel_instance.copy(),this._stdout_stream=t.get("pyodide_kernel").stdout_stream.copy(),this._stderr_stream=t.get("pyodide_kernel").stderr_stream.copy(),this._interpreter=this._kernel.interpreter.copy(),this._interpreter.send_comm=this.sendComm.bind(this)}async initFilesystem(e){if(e.mountDrive){let t="/drive",{FS:s,PATH:r,ERRNO_CODES:i}=this._pyodide,{baseUrl:o}=e,{DriveFS:a}=await Promise.resolve().then(()=>(tr(),No)),h=new a({FS:s,PATH:r,ERRNO_CODES:i,baseUrl:o,driveName:this._driveName,mountpoint:t,browsingContextId:this._browsingContextId});s.mkdirTree(t),s.mount(h,{},t),s.chdir(t),this._driveFS=h}}mapToObject(e){let t=e instanceof Array?[]:{},s=e instanceof Map?e.entries():Object.entries(e);for(let[r,i]of s)t[r]=i instanceof Map||i instanceof Array?this.mapToObject(i):i;return t}formatResult(e){if(!(e instanceof this._pyodide.ffi.PyProxy))return e;let t=e.toJs();return this.mapToObject(t)}registerWorkerMessageCallback(e){this._sendWorkerMessage=e}registerLogMessageCallback(e){this._logMessage=e}async setup(e){await this._initialized,this._kernel._parent_header=this._pyodide.toPy(e)}async execute(e,t){await this.setup(t);let s=(l,d,v)=>{let m={execution_count:l,data:this.formatResult(d),metadata:this.formatResult(v)};this._sendWorkerMessage({parentHeader:this.formatResult(this._kernel._parent_header).header,bundle:m,type:"execute_result"})},r=(l,d,v)=>{let m={ename:l,evalue:d,traceback:v};this._sendWorkerMessage({parentHeader:this.formatResult(this._kernel._parent_header).header,bundle:m,type:"execute_error"})},i=l=>{let d={wait:this.formatResult(l)};this._sendWorkerMessage({parentHeader:this.formatResult(this._kernel._parent_header).header,bundle:d,type:"clear_output"})},o=(l,d,v)=>{let m={data:this.formatResult(l),metadata:this.formatResult(d),transient:this.formatResult(v)};this._sendWorkerMessage({parentHeader:this.formatResult(this._kernel._parent_header).header,bundle:m,type:"display_data"})},a=(l,d,v)=>{let m={data:this.formatResult(l),metadata:this.formatResult(d),transient:this.formatResult(v)};this._sendWorkerMessage({parentHeader:this.formatResult(this._kernel._parent_header).header,bundle:m,type:"update_display_data"})},h=(l,d)=>{let v={name:this.formatResult(l),text:this.formatResult(d)};this._sendWorkerMessage({parentHeader:this.formatResult(this._kernel._parent_header).header,bundle:v,type:"stream"})};this._stdout_stream.publish_stream_callback=h,this._stderr_stream.publish_stream_callback=h,this._interpreter.display_pub.clear_output_callback=i,this._interpreter.display_pub.display_data_callback=o,this._interpreter.display_pub.update_display_data_callback=a,this._interpreter.displayhook.publish_execution_result=s,this._interpreter.input=this.input.bind(this),this._interpreter.getpass=this.getpass.bind(this);let c=await this._kernel.run(e.code),u=this.formatResult(c);return u.status==="error"&&r(u.ename,u.evalue,u.traceback),u}async complete(e,t){await this.setup(t);let s=this._kernel.complete(e.code,e.cursor_pos);return this.formatResult(s)}async inspect(e,t){await this.setup(t);let s=this._kernel.inspect(e.code,e.cursor_pos,e.detail_level);return this.formatResult(s)}async isComplete(e,t){await this.setup(t);let s=this._kernel.is_complete(e.code);return this.formatResult(s)}async commInfo(e,t){await this.setup(t);let s=this._kernel.comm_info(e.target_name);return{comms:this.formatResult(s),status:"ok"}}async commOpen(e,t){await this.setup(t);let s=this._kernel.comm_manager.comm_open(this._pyodide.toPy(null),this._pyodide.toPy(null),this._pyodide.toPy(e));return this.formatResult(s)}async commMsg(e,t){await this.setup(t);let s=this._kernel.comm_manager.comm_msg(this._pyodide.toPy(null),this._pyodide.toPy(null),this._pyodide.toPy(e));return this.formatResult(s)}async commClose(e,t){await this.setup(t);let s=this._kernel.comm_manager.comm_close(this._pyodide.toPy(null),this._pyodide.toPy(null),this._pyodide.toPy(e));return this.formatResult(s)}async inputReply(e,t){}getpass(e){return e=typeof e=="undefined"?"":e,this.sendInputRequest(e,!0)}input(e){return e=typeof e=="undefined"?"":e,this.sendInputRequest(e,!1)}async sendComm(e,t,s,r,i){this._sendWorkerMessage({type:e,content:this.formatResult(t),metadata:this.formatResult(s),ident:this.formatResult(r),buffers:this.formatResult(i),parentHeader:this.formatResult(this._kernel._parent_header).header})}};var nr=class extends Vn{constructor(){super(),this._sendWorkerMessage=e=>{postMessage({_kernelMessage:e})},this._logMessage=e=>{postMessage({_logMessage:e})}}async initFilesystem(e){if(e.mountDrive){let t="/drive",{FS:s,PATH:r,ERRNO_CODES:i}=this._pyodide,{baseUrl:o,browsingContextId:a}=e,h=new Dt({FS:s,PATH:r,ERRNO_CODES:i,baseUrl:o,driveName:this._driveName,mountpoint:t,browsingContextId:a});s.mkdirTree(t),s.mount(h,{},t),s.chdir(t),this._driveFS=h}}sendInputRequest(e,t){var i,o;let s=this.formatResult(this._kernel._parent_header).header,r=xo.KernelMessage.createMessage({channel:"stdin",msgType:"input_request",session:(i=s==null?void 0:s.session)!=null?i:"",parentHeader:s,content:{prompt:e,password:t}});try{if(!this._options)throw new Error("Kernel options not set");let{baseUrl:a,browsingContextId:h}=this._options;if(!h)throw new Error("Kernel browsingContextId not set");let c=new XMLHttpRequest,u=Lo.URLExt.join(a,"/api/stdin/kernel");c.open("POST",u,!1);let l=JSON.stringify({browsingContextId:h,data:r});c.send(l);let d=JSON.parse(c.response);if("error"in d)throw new Error(d.error);return(o=d.content)==null?void 0:o.value}catch(a){console.warn(`Failed to request stdin via service worker: ${a}`);return}}},Mu=new nr;Nt(Mu);export{nr as PyodideComlinkKernel};
23
22
  /*! Bundled license information:
24
23
 
25
24
  comlink/dist/esm/comlink.mjs: