@jupyterlite/pyodide-kernel 0.7.0-rc.0 → 0.7.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,12 +1,12 @@
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(`
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=j.rangeLength(f,y,b);for(let x=0;x<P;x++)yield f+b*x}var j;(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})(j||(j={}));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*T(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=T,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)?j(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],T=w[k];if(!(N===void 0&&T===void 0)&&(N===void 0||T===void 0||!v(N,T)))return!1}return!0}function j(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 j=this._services.get(I);return j?this._plugins.get(j).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 j,A,C,w;this._activated=!1,this._promise=null,this._service=null,this.id=I.id,this.description=(j=I.description)!==null&&j!==void 0?j:"",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,j){let A=[...q.requires,...q.optional],C=k=>{if(k===q.provides)return!0;let N=j.get(k);if(!N)return!1;let T=I.get(N),D=[...T.requires,...T.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,j){let A=new Array,C=D=>{let U=I.get(D),f=[...U.requires,...U.optional];A.push(...f.reduce((y,b)=>{let P=j.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),T=N.findIndex(D=>D===q);return T===-1?[q]:N.slice(0,T+1)}c.findDependents=v;function m(q,I){let j=new Set;for(let A of q.keys())q.get(A).autoStart===!0&&j.add(A);if(I.startPlugins)for(let A of I.startPlugins)j.add(A);if(I.ignorePlugins)for(let A of I.ignorePlugins)j.delete(A);return Array.from(j)}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,j=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&&j(k),I.add(D)}function k(){I.forEach(N),I.clear()}function N(D){e.ArrayExt.removeAllWhere(D,T)}function T(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
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}.
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 T=w,D=0;D<k.length-1;D++){var U=k[D];if(br(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 f=k[k.length-1];br(T,f)||((T===Object.prototype||T===Number.prototype||T===String.prototype)&&(T={}),T===Array.prototype&&(T=[]),T[f]===void 0||t.bools[f]||typeof T[f]=="boolean"?T[f]=N:Array.isArray(T[f])?T[f].push(N):T[f]=[T[f],N])}function c(w,k,N){if(!(N&&t.unknownFn&&!a(w,N)&&t.unknownFn(N)===!1)){var T=!t.strings[w]&&Sr(k)?Number(k):k;h(o,w.split("."),T),(s[w]||[]).forEach(function(D){h(o,D.split("."),T)})}}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 j=d.slice(1,-1).split(""),A=!1,C=0;C<j.length;C++){if(m=d.slice(C+2),m==="-"){c(j[C],m,d);continue}if(/[A-Za-z]/.test(j[C])&&m[0]==="="){c(j[C],m.slice(1),d),A=!0;break}if(/[A-Za-z]/.test(j[C])&&/-?\d+(\.\d*)?(e-?\d+)?$/.test(m)){c(j[C],m,d),A=!0;break}if(j[C+1]&&j[C+1].match(/\W/)){c(j[C],d.slice(C+2),d),A=!0;break}else c(j[C],t.strings[j[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((ju,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((Tu,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 jr=Rr(),Wt=Dr(),wa=/^[\x00-\x20\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]+/,Tr=/[\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(Tr,""),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(Tr,""),!(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),jr(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,jr(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=Ta;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 ja=Z();function Ta(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:ja.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]))),j=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:j,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),j=q.encode(h),A=q.encode(c),C=q.encode(u),w=q.encode(l),k=new Uint8Array(I.length+j.length+A.length+C.length+w.length);k.set(I),k.set(j,I.length),k.set(A,I.length+j.length),k.set(C,I.length+j.length+A.length),k.set(w,I.length+j.length+A.length+C.length);for(let f of[j.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 T=new Uint8Array(8*(1+v)+k.byteLength+N),D=new ArrayBuffer(8),U=new DataView(D);U.setBigUint64(0,BigInt(v),!0),T.set(new Uint8Array(D),0);for(let f=0;f<m.length;f++)U.setBigUint64(0,BigInt(m[f]),!0),T.set(new Uint8Array(D),8*(f+1));T.set(k,m[0]);for(let f=0;f<d.length;f++){let y=d[f];T.set(new Uint8Array(ArrayBuffer.isView(y)?y.buffer:y),m[5+f])}return T.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 j=l[I];c.push(ArrayBuffer.isView(j)?j.buffer:j)}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,j=u(m,d.interval*I);return Math.min(q,j)}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(),jl=Mi(),Tl=te(),Ul="api/kernelspecs";async function Ei(n=gn.ServerConnection.makeSettings()){let e=Tl.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,jl.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 j=!1,A=async w=>{var k,N;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 _t.ServerConnection.NetworkError||((k=T.response)===null||k===void 0?void 0:k.status)===503||((N=T.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=>{j||(j=!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 Ti=R(gt=>{"use strict";Object.defineProperty(gt,"__esModule",{value:!0});gt.KernelManager=void 0;var Vl=He(),qi=ee(),ji=Ae(),Bl=$e(),Wl=_n(),$l=Ss(),Hl=ft(),pt=class extends Bl.BaseManager{constructor(e={}){var t,s,r;super(e),this._commsOverSubshells=ji.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 ji.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(Ti(),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 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.
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 je=ee(),gc=Ae(),mc=Z(),vc=bn(),js=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 je.Signal(this),this._kernelChanged=new je.Signal(this),this._statusChanged=new je.Signal(this),this._connectionStatusChanged=new je.Signal(this),this._pendingInput=new je.Signal(this),this._iopubMessage=new je.Signal(this),this._unhandledMessage=new je.Signal(this),this._anyMessage=new je.Signal(this),this._propertyChanged=new je.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})}je.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=js});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 Ts=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),!Te.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);Te.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 Te.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=Te.injectedProperty.get(e);if(!this._restore||!this.has(e)||r)return;let{connector:i}=this._restore,o=this._restore.name(e),a=Te.nameProperty.get(e),h=o?`${this.namespace}:${o}`:"";if(a&&a!==h&&await i.remove(a),Te.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)),Te.injectedProperty.get(e)||!this._restore)return;let{connector:t}=this._restore,s=Te.nameProperty.get(e);s&&t.remove(s)}};In.RestorablePool=As;var Te;(function(n){n.injectedProperty=new lo.AttachedProperty({name:"injected",create:()=>!1}),n.nameProperty=new lo.AttachedProperty({name:"name",create:()=>""})})(Te||(Te={}))});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 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.
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(),jc="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(j=>j.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(j=>(j.data={composite:{},user:{}},j)))!==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,jc),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 Tc=It();Object.defineProperty(Dn,"isAvailable",{enumerable:!0,get:function(){return Tc.isAvailable}})});var mo=R(jn=>{"use strict";Object.defineProperty(jn,"__esModule",{value:!0});jn.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}};jn.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(Tn=>{"use strict";Object.defineProperty(Tn,"__esModule",{value:!0});Tn.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()}};Tn.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=Ts(),_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(Ts(),$);ce(Fs(),$);ce(Ws(),$);ce(qo(),$);ce(Ys(),$);ce(Zs(),$);ce(Ds(),$)});function jo(n){return"node"in n}var To=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());To();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=>jo(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"),jt=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)&&jt 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,[jt]:0}}Promise.resolve(c).catch(u=>({value:u,[jt]: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"),[jt]: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 Tt=new WeakMap,Ut="FinalizationRegistry"in globalThis&&new FinalizationRegistry(n=>{let e=(Tt.get(n)||0)-1;Tt.set(n,e),e===0&&cr(n)});function aa(n,e){let t=(Tt.get(e)||0)+1;Tt.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
10
  The cause of the error was: ${i.name}
11
11
  ${i.message}
12
12
  Stack trace: