"use strict";var Hn=Object.defineProperty;var Ya=Object.getOwnPropertyDescriptor;var Xa=Object.getOwnPropertyNames;var Za=Object.prototype.hasOwnProperty;var Qa=(n,e)=>()=>(n&&(e=n(n=0)),e);var R=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),ec=(n,e)=>{for(var t in e)Hn(n,t,{get:e[t],enumerable:!0})},tc=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Xa(e))!Za.call(n,i)&&i!==t&&Hn(n,i,{get:()=>e[i],enumerable:!(r=Ya(e,i))||r.enumerable});return n};var nc=n=>tc(Hn({},"__esModule",{value:!0}),n);var et=R((Yt,ji)=>{(function(n,e){typeof Yt=="object"&&typeof ji<"u"?e(Yt):typeof define=="function"&&define.amd?define(["exports"],e):(n=typeof globalThis<"u"?globalThis:n||self,e(n.lumino_algorithm={}))})(Yt,function(n){"use strict";n.ArrayExt=void 0,function(h){function _(S,E,p,f){p===void 0&&(p=0),f===void 0&&(f=-1);var m=S.length;if(m===0)return-1;p<0?p=Math.max(0,p+m):p=Math.min(p,m-1),f<0?f=Math.max(0,f+m):f=Math.min(f,m-1);var D;f
0;){var Se=V>>1,bt=T+Se;p(S[bt],E)<0?(T=bt+1,V-=Se+1):V=Se}return T}h.lowerBound=B;function W(S,E,p,f,m){f===void 0&&(f=0),m===void 0&&(m=-1);var D=S.length;if(D===0)return 0;f<0?f=Math.max(0,f+D):f=Math.min(f,D-1),m<0?m=Math.max(0,m+D):m=Math.min(m,D-1);for(var T=f,V=m-f+1;V>0;){var Se=V>>1,bt=T+Se;p(S[bt],E)>0?V=Se:(T=bt+1,V-=Se+1)}return T}h.upperBound=W;function $(S,E,p){if(S===E)return!0;if(S.length!==E.length)return!1;for(var f=0,m=S.length;f=D&&(p=m<0?D-1:D),f===void 0?f=m<0?-1:D:f<0?f=Math.max(f+D,m<0?-1:0):f>=D&&(f=m<0?D-1:D);var T;m<0&&f>=p||m>0&&p>=f?T=0:m<0?T=Math.floor((f-p+1)/m+1):T=Math.floor((f-p-1)/m+1);for(var V=[],Se=0;Se=f))){var D=f-p+1;if(E>0?E=E%D:E<0&&(E=(E%D+D)%D),E!==0){var T=p+E;ae(S,p,T-1),ae(S,T,f),ae(S,p,f)}}}h.rotate=Ce;function xe(S,E,p,f){p===void 0&&(p=0),f===void 0&&(f=-1);var m=S.length;if(m!==0){p<0?p=Math.max(0,p+m):p=Math.min(p,m-1),f<0?f=Math.max(0,f+m):f=Math.min(f,m-1);var D;fE;--m)S[m]=S[m-1];S[E]=p}h.insert=Va;function St(S,E){var p=S.length;if(E<0&&(E+=p),!(E<0||E>=p)){for(var f=S[E],m=E+1;m
=p&&T<=f&&S[T]===E||f
=p)&&S[T]===E?D++:D>0&&(S[T-D]=S[T]);return D>0&&(S.length=m-D),D}h.removeAllOf=Ga;function Ha(S,E,p,f){p===void 0&&(p=0),f===void 0&&(f=-1);var m,D=I(S,E,p,f);return D!==-1&&(m=St(S,D)),{index:D,value:m}}h.removeFirstWhere=Ha;function za(S,E,p,f){p===void 0&&(p=-1),f===void 0&&(f=0);var m,D=U(S,E,p,f);return D!==-1&&(m=St(S,D)),{index:D,value:m}}h.removeLastWhere=za;function Ja(S,E,p,f){p===void 0&&(p=0),f===void 0&&(f=-1);var m=S.length;if(m===0)return 0;p<0?p=Math.max(0,p+m):p=Math.min(p,m-1),f<0?f=Math.max(0,f+m):f=Math.min(f,m-1);for(var D=0,T=0;T=p&&T<=f&&E(S[T],T)||f=p)&&E(S[T],T)?D++:D>0&&(S[T-D]=S[T]);return D>0&&(S.length=m-D),D}h.removeAllWhere=Ja}(n.ArrayExt||(n.ArrayExt={}));function e(h){var _;return typeof h.iter=="function"?_=h.iter():_=new d(h),_}function t(h){return new g(h)}function r(h){return new y(h)}function i(h){return new v(h)}function s(h){return new b(h)}function o(h,_){for(var C=0,I=e(h),U;(U=I.next())!==void 0;)if(_(U,C++)===!1)return}function a(h,_){for(var C=0,I=e(h),U;(U=I.next())!==void 0;)if(!_(U,C++))return!1;return!0}function c(h,_){for(var C=0,I=e(h),U;(U=I.next())!==void 0;)if(_(U,C++))return!0;return!1}function u(h){for(var _=0,C=[],I=e(h),U;(U=I.next())!==void 0;)C[_++]=U;return C}function l(h){for(var _=e(h),C,I={};(C=_.next())!==void 0;)I[C[0]]=C[1];return I}var d=function(){function h(_){this._index=0,this._source=_}return h.prototype.iter=function(){return this},h.prototype.clone=function(){var _=new h(this._source);return _._index=this._index,_},h.prototype.next=function(){if(!(this._index>=this._source.length))return this._source[this._index++]},h}(),g=function(){function h(_,C){C===void 0&&(C=Object.keys(_)),this._index=0,this._source=_,this._keys=C}return h.prototype.iter=function(){return this},h.prototype.clone=function(){var _=new h(this._source,this._keys);return _._index=this._index,_},h.prototype.next=function(){if(!(this._index>=this._keys.length)){var _=this._keys[this._index++];return _ in this._source?_:this.next()}},h}(),y=function(){function h(_,C){C===void 0&&(C=Object.keys(_)),this._index=0,this._source=_,this._keys=C}return h.prototype.iter=function(){return this},h.prototype.clone=function(){var _=new h(this._source,this._keys);return _._index=this._index,_},h.prototype.next=function(){if(!(this._index>=this._keys.length)){var _=this._keys[this._index++];return _ in this._source?this._source[_]:this.next()}},h}(),v=function(){function h(_,C){C===void 0&&(C=Object.keys(_)),this._index=0,this._source=_,this._keys=C}return h.prototype.iter=function(){return this},h.prototype.clone=function(){var _=new h(this._source,this._keys);return _._index=this._index,_},h.prototype.next=function(){if(!(this._index>=this._keys.length)){var _=this._keys[this._index++];return _ in this._source?[_,this._source[_]]:this.next()}},h}(),b=function(){function h(_){this._fn=_}return h.prototype.iter=function(){return this},h.prototype.clone=function(){throw new Error("An `FnIterator` cannot be cloned.")},h.prototype.next=function(){return this._fn.call(void 0)},h}();function x(){for(var h=[],_=0;_0&&(U=I);return U}}function dt(h,_){var C=e(h),I=C.next();if(I!==void 0){for(var U=I,ee=I;(I=C.next())!==void 0;)_(I,U)<0?U=I:_(I,ee)>0&&(ee=I);return[U,ee]}}function Ta(h,_){return new Di(e(h),_)}var Di=function(){function h(_,C){this._index=0,this._source=_,this._fn=C}return h.prototype.iter=function(){return this},h.prototype.clone=function(){var _=new h(this._source.clone(),this._fn);return _._index=this._index,_},h.prototype.next=function(){var _=this._source.next();if(_!==void 0)return this._fn.call(void 0,_,this._index++)},h}();function ja(h,_,C){return _===void 0?new Jt(0,h,1):C===void 0?new Jt(h,_,1):new Jt(h,_,C)}var Jt=function(){function h(_,C,I){this._index=0,this._start=_,this._stop=C,this._step=I,this._length=$n.rangeLength(_,C,I)}return h.prototype.iter=function(){return this},h.prototype.clone=function(){var _=new h(this._start,this._stop,this._step);return _._index=this._index,_},h.prototype.next=function(){if(!(this._index>=this._length))return this._start+this._step*this._index++},h}(),$n;(function(h){function _(C,I,U){return U===0?1/0:C>I&&U>0||C=this._source.length))return this._source[this._index--]},h}();function Aa(h){var _=[],C=new Set,I=new Map;return o(h,U),I.forEach(function(K,B){ee(B)}),_;function U(K){var B=K[0],W=K[1],$=I.get(W);$?$.push(B):I.set(W,[B])}function ee(K){if(!C.has(K)){C.add(K);var B=I.get(K);B&&B.forEach(ee),_.push(K)}}}function Ba(h,_){return new Ii(e(h),_)}var Ii=function(){function h(_,C){this._source=_,this._step=C}return h.prototype.iter=function(){return this},h.prototype.clone=function(){return new h(this._source.clone(),this._step)},h.prototype.next=function(){for(var _=this._source.next(),C=this._step-1;C>0;--C)this._source.next();return _},h}();n.StringExt=void 0,function(h){function _(K,B,W){W===void 0&&(W=0);for(var $=new Array(B.length),Z=0,J=W,ae=B.length;ZB?1:0}h.cmp=ee}(n.StringExt||(n.StringExt={}));function Fa(h,_){return new ki(e(h),_)}var ki=function(){function h(_,C){this._source=_,this._count=C}return h.prototype.iter=function(){return this},h.prototype.clone=function(){return new h(this._source.clone(),this._count)},h.prototype.next=function(){if(!(this._count<=0)){var _=this._source.next();if(_!==void 0)return this._count--,_}},h}();function Ka(){for(var h=[],_=0;_{(function(n,e){typeof Xt=="object"&&typeof qi<"u"?e(Xt):typeof define=="function"&&define.amd?define(["exports"],e):(n=typeof globalThis<"u"?globalThis:n||self,e(n.lumino_properties={}))})(Xt,function(n){"use strict";n.AttachedProperty=function(){function t(r){this._pid=e.nextPID(),this.name=r.name,this._create=r.create,this._coerce=r.coerce||null,this._compare=r.compare||null,this._changed=r.changed||null}return t.prototype.get=function(r){var i,s=e.ensureMap(r);return this._pid in s?i=s[this._pid]:i=s[this._pid]=this._createValue(r),i},t.prototype.set=function(r,i){var s,o=e.ensureMap(r);this._pid in o?s=o[this._pid]:s=o[this._pid]=this._createValue(r);var a=this._coerceValue(r,i);this._maybeNotify(r,s,o[this._pid]=a)},t.prototype.coerce=function(r){var i,s=e.ensureMap(r);this._pid in s?i=s[this._pid]:i=s[this._pid]=this._createValue(r);var o=this._coerceValue(r,i);this._maybeNotify(r,i,s[this._pid]=o)},t.prototype._createValue=function(r){var i=this._create;return i(r)},t.prototype._coerceValue=function(r,i){var s=this._coerce;return s?s(r,i):i},t.prototype._compareValue=function(r,i){var s=this._compare;return s?s(r,i):r===i},t.prototype._maybeNotify=function(r,i,s){var o=this._changed;o&&!this._compareValue(i,s)&&o(r,i,s)},t}(),function(t){function r(i){e.ownerData.delete(i)}t.clearData=r}(n.AttachedProperty||(n.AttachedProperty={}));var e;(function(t){t.ownerData=new WeakMap,t.nextPID=function(){var i=0;return function(){var s=Math.random(),o=(""+s).slice(2);return"pid-"+o+"-"+i++}}();function r(i){var s=t.ownerData.get(i);return s||(s=Object.create(null),t.ownerData.set(i,s),s)}t.ensureMap=r})(e||(e={})),Object.defineProperty(n,"__esModule",{value:!0})})});var ie=R((Zt,Ui)=>{(function(n,e){typeof Zt=="object"&&typeof Ui<"u"?e(Zt,et(),zn()):typeof define=="function"&&define.amd?define(["exports","@lumino/algorithm","@lumino/properties"],e):(n=typeof globalThis<"u"?globalThis:n||self,e(n.lumino_signaling={},n.lumino_algorithm,n.lumino_properties))})(Zt,function(n,e,t){"use strict";n.Signal=function(){function i(s){this._blockedCount=0,this.sender=s}return i.prototype.block=function(s){this._blockedCount++;try{s()}finally{this._blockedCount--}},i.prototype.connect=function(s,o){return r.connect(this,s,o)},i.prototype.disconnect=function(s,o){return r.disconnect(this,s,o)},i.prototype.emit=function(s){this._blockedCount||r.emit(this,s)},i}(),function(i){function s(y,v){var b=r.blockedProperty;b.set(y,b.get(y)+1);try{v()}finally{b.set(y,b.get(y)-1)}}i.blockAll=s;function o(y,v){r.disconnectBetween(y,v)}i.disconnectBetween=o;function a(y){r.disconnectSender(y)}i.disconnectSender=a;function c(y){r.disconnectReceiver(y)}i.disconnectReceiver=c;function u(y){r.disconnectAll(y)}i.disconnectAll=u;function l(y){r.disconnectAll(y)}i.clearData=l;function d(){return r.exceptionHandler}i.getExceptionHandler=d;function g(y){var v=r.exceptionHandler;return r.exceptionHandler=y,v}i.setExceptionHandler=g}(n.Signal||(n.Signal={}));var r;(function(i){i.exceptionHandler=function(j){console.error(j)};function s(j,w,q){q=q||void 0;var N=g.get(j.sender);if(N||(N=[],g.set(j.sender,N)),x(N,j,w,q))return!1;var F=q||w,me=y.get(F);me||(me=[],y.set(F,me));var dt={signal:j,slot:w,thisArg:q};return N.push(dt),me.push(dt),!0}i.connect=s;function o(j,w,q){q=q||void 0;var N=g.get(j.sender);if(!N||N.length===0)return!1;var F=x(N,j,w,q);if(!F)return!1;var me=q||w,dt=y.get(me);return F.signal=null,P(N),P(dt),!0}i.disconnect=o;function a(j,w){var q=g.get(j);if(!(!q||q.length===0)){var N=y.get(w);!N||N.length===0||(e.each(N,function(F){F.signal&&F.signal.sender===j&&(F.signal=null)}),P(q),P(N))}}i.disconnectBetween=a;function c(j){var w=g.get(j);!w||w.length===0||(e.each(w,function(q){if(q.signal){var N=q.thisArg||q.slot;q.signal=null,P(y.get(N))}}),P(w))}i.disconnectSender=c;function u(j){var w=y.get(j);!w||w.length===0||(e.each(w,function(q){if(q.signal){var N=q.signal.sender;q.signal=null,P(g.get(N))}}),P(w))}i.disconnectReceiver=u;function l(j){c(j),u(j)}i.disconnectAll=l;function d(j,w){if(!(i.blockedProperty.get(j.sender)>0)){var q=g.get(j.sender);if(!(!q||q.length===0))for(var N=0,F=q.length;N{"use strict";Object.defineProperty(Qt,"__esModule",{value:!0});Qt.ActivityMonitor=void 0;var Ni=ie(),Jn=class{constructor(e){this._timer=-1,this._timeout=-1,this._isDisposed=!1,this._activityStopped=new Ni.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,Ni.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)}};Qt.ActivityMonitor=Jn});var Bi=R(Ai=>{"use strict";Object.defineProperty(Ai,"__esModule",{value:!0})});var Fi=R(Ct=>{"use strict";Object.defineProperty(Ct,"__esModule",{value:!0});Ct.MarkdownCodeBlocks=void 0;var rc;(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 r(s){return e.indexOf(s)>-1}n.isMarkdown=r;function i(s){if(!s||s==="")return[];let o=s.split(`
`),a=[],c=null;for(let u=0;u{"use strict";Object.defineProperty(ce,"__esModule",{value:!0});ce.JSONExt=void 0;(function(n){n.emptyObject=Object.freeze({}),n.emptyArray=Object.freeze([]);function e(l){return l===null||typeof l=="boolean"||typeof l=="number"||typeof l=="string"}n.isPrimitive=e;function t(l){return Array.isArray(l)}n.isArray=t;function r(l){return!e(l)&&!t(l)}n.isObject=r;function i(l,d){if(l===d)return!0;if(e(l)||e(d))return!1;var g=t(l),y=t(d);return g!==y?!1:g&&y?o(l,d):a(l,d)}n.deepEqual=i;function s(l){return e(l)?l:t(l)?c(l):u(l)}n.deepCopy=s;function o(l,d){if(l===d)return!0;if(l.length!==d.length)return!1;for(var g=0,y=l.length;g>>0),n[t]=e&255,e>>>=8}ce.Random=void 0;(function(n){n.getRandomValues=function(){var e=typeof require<"u"&&require("crypto")||null;return e&&typeof e.randomFillSync=="function"?function(r){return e.randomFillSync(r)}:e&&typeof e.randomBytes=="function"?function(r){for(var i=e.randomBytes(r.length),s=0,o=i.length;s{"use strict";function uc(n,e){var t=n;e.slice(0,-1).forEach(function(i){t=t[i]||{}});var r=e[e.length-1];return r in t}function Ki(n){return typeof n=="number"||/^0x[0-9a-f]+$/i.test(n)?!0:/^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(n)}function Vi(n,e){return e==="constructor"&&typeof n[e]=="function"||e==="__proto__"}Wi.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(k){t.bools[k]=!0});var r={};function i(k){return r[k].some(function(L){return t.bools[L]})}Object.keys(e.alias||{}).forEach(function(k){r[k]=[].concat(e.alias[k]),r[k].forEach(function(L){r[L]=[k].concat(r[k].filter(function(j){return L!==j}))})}),[].concat(e.string).filter(Boolean).forEach(function(k){t.strings[k]=!0,r[k]&&[].concat(r[k]).forEach(function(L){t.strings[L]=!0})});var s=e.default||{},o={_:[]};function a(k,L){return t.allBools&&/^--[^=]+$/.test(L)||t.strings[k]||t.bools[k]||r[k]}function c(k,L,j){for(var w=k,q=0;q{"use strict";Gi.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 Yi=R(Yn=>{"use strict";var lc=Object.prototype.hasOwnProperty,hc;function zi(n){try{return decodeURIComponent(n.replace(/\+/g," "))}catch{return null}}function Ji(n){try{return encodeURIComponent(n)}catch{return null}}function dc(n){for(var e=/([^=?#&]+)=?([^&]*)/g,t={},r;r=e.exec(n);){var i=zi(r[1]),s=zi(r[2]);i===null||s===null||i in t||(t[i]=s)}return t}function fc(n,e){e=e||"";var t=[],r,i;typeof e!="string"&&(e="?");for(i in n)if(lc.call(n,i)){if(r=n[i],!r&&(r===null||r===hc||isNaN(r))&&(r=""),i=Ji(i),r=Ji(r),i===null||r===null)continue;t.push(i+"="+r)}return t.length?e+t.join("&"):""}Yn.stringify=fc;Yn.parse=dc});var is=R((Ud,rs)=>{"use strict";var Zi=Hi(),en=Yi(),_c=/^[\x00-\x20\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]+/,Qi=/[\n\r\t]/g,pc=/^[A-Za-z][A-Za-z0-9+-.]*:\/\//,es=/:\d+$/,gc=/^([a-z][a-z0-9.+-]*:)?(\/\/)?([\\/]+)?([\S\s]*)/i,mc=/^[a-zA-Z]:/;function Zn(n){return(n||"").toString().replace(_c,"")}var Xn=[["#","hash"],["?","query"],function(e,t){return De(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]],Xi={hash:1,query:1};function ts(n){var e;typeof window<"u"?e=window:typeof global<"u"?e=global:typeof self<"u"?e=self:e={};var t=e.location||{};n=n||t;var r={},i=typeof n,s;if(n.protocol==="blob:")r=new Pe(unescape(n.pathname),{});else if(i==="string"){r=new Pe(n,{});for(s in Xi)delete r[s]}else if(i==="object"){for(s in n)s in Xi||(r[s]=n[s]);r.slashes===void 0&&(r.slashes=pc.test(n.href))}return r}function De(n){return n==="file:"||n==="ftp:"||n==="http:"||n==="https:"||n==="ws:"||n==="wss:"}function ns(n,e){n=Zn(n),n=n.replace(Qi,""),e=e||{};var t=gc.exec(n),r=t[1]?t[1].toLowerCase():"",i=!!t[2],s=!!t[3],o=0,a;return i?s?(a=t[2]+t[3]+t[4],o=t[2].length+t[3].length):(a=t[2]+t[4],o=t[2].length):s?(a=t[3]+t[4],o=t[3].length):a=t[4],r==="file:"?o>=2&&(a=a.slice(2)):De(r)?a=t[4]:r?i&&(a=a.slice(2)):o>=2&&De(e.protocol)&&(a=t[4]),{protocol:r,slashes:i||De(r),slashesCount:o,rest:a}}function vc(n,e){if(n==="")return e;for(var t=(e||"/").split("/").slice(0,-1).concat(n.split("/")),r=t.length,i=t[r-1],s=!1,o=0;r--;)t[r]==="."?t.splice(r,1):t[r]===".."?(t.splice(r,1),o++):o&&(r===0&&(s=!0),t.splice(r,1),o--);return s&&t.unshift(""),(i==="."||i==="..")&&t.push(""),t.join("/")}function Pe(n,e,t){if(n=Zn(n),n=n.replace(Qi,""),!(this instanceof Pe))return new Pe(n,e,t);var r,i,s,o,a,c,u=Xn.slice(),l=typeof e,d=this,g=0;for(l!=="object"&&l!=="string"&&(t=e,e=null),t&&typeof t!="function"&&(t=en.parse),e=ts(e),i=ns(n||"",e),r=!i.protocol&&!i.slashes,d.slashes=i.slashes||r&&e.slashes,d.protocol=i.protocol||e.protocol||"",n=i.rest,(i.protocol==="file:"&&(i.slashesCount!==2||mc.test(n))||!i.slashes&&(i.protocol||i.slashesCount<2||!De(d.protocol)))&&(u[3]=[/(.*)/,"pathname"]);g{"use strict";var Sc=tt&&tt.__importDefault||function(n){return n&&n.__esModule?n:{default:n}};Object.defineProperty(tt,"__esModule",{value:!0});tt.URLExt=void 0;var bc=require("path"),Qn=Sc(is()),Cc;(function(n){function e(u){if(typeof document<"u"&&document){let l=document.createElement("a");return l.href=u,l}return Qn.default(u)}n.parse=e;function t(u){return Qn.default(u).hostname}n.getHostName=t;function r(u){return u&&e(u).toString()}n.normalize=r;function i(...u){let l=Qn.default(u[0],{}),d=`${l.protocol}${l.slashes?"//":""}${l.auth}${l.auth?"@":""}${l.host}`,g=bc.posix.join(`${d&&l.pathname[0]!=="/"?"/":""}${l.pathname}`,...u.slice(1));return`${d}${g==="."?"":g}`}n.join=i;function s(u){return i(...u.split("/").map(encodeURIComponent))}n.encodeParts=s;function o(u){let l=Object.keys(u).filter(d=>d.length>0);return l.length?"?"+l.map(d=>{let g=encodeURIComponent(String(u[d]));return d+(g?"="+g:"")}).join("&"):""}n.objectToQueryString=o;function a(u){return u.replace(/^\?/,"").split("&").reduce((l,d)=>{let[g,y]=d.split("=");return g.length>0&&(l[g]=decodeURIComponent(y||"")),l},{})}n.queryStringToObject=a;function c(u){let{protocol:l}=e(u);return(!l||u.toLowerCase().indexOf(l)!==0)&&u.indexOf("/")!==0}n.isLocal=c})(Cc=tt.URLExt||(tt.URLExt={}))});var ss=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=Ee(),minimist_1=__importDefault($i()),url_1=er(),PageConfig;(function(PageConfig){function getOption(name){if(configData)return configData[name]||getBodyData(name);configData=Object.create(null);let found=!1;if(typeof document<"u"&&document){let n=document.getElementById("jupyter-config-data");n&&(configData=JSON.parse(n.textContent||""),found=!0)}if(!found&&typeof process<"u"&&process.argv)try{let cli=minimist_1.default(process.argv.slice(2)),path=require("path"),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,r;let i=getOption("baseUrl")||"/",s=(e=n.mode)!==null&&e!==void 0?e:getOption("mode"),o=(t=n.workspace)!==null&&t!==void 0?t:getOption("workspace"),a=s==="multiple-document"?"lab":"doc";i=url_1.URLExt.join(i,a),o!==PageConfig.defaultWorkspace&&(i=url_1.URLExt.join(i,"workspaces",encodeURIComponent(getOption("workspace"))));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 r=url_1.URLExt.encodeParts(n),i=url_1.URLExt.join(getBaseUrl(),"nbconvert",e,r);return t?i+"?download=true":i}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>"u"||!document.body)return"";let e=document.body.dataset[n];return typeof e>"u"?"":decodeURIComponent(e)}let Extension;(function(n){function e(i){try{let s=getOption(i);if(s)return JSON.parse(s)}catch(s){console.warn(`Unable to parse ${i}.`,s)}return[]}n.deferred=e("deferredExtensions"),n.disabled=e("disabledExtensions");function t(i){let s=i.indexOf(":"),o="";return s!==-1&&(o=i.slice(0,s)),n.deferred.some(a=>a===i||o&&a===o)}n.isDeferred=t;function r(i){let s=i.indexOf(":"),o="";return s!==-1&&(o=i.slice(0,s)),n.disabled.some(a=>a===i||o&&a===o)}n.isDisabled=r})(Extension=PageConfig.Extension||(PageConfig.Extension={}))})(PageConfig=exports.PageConfig||(exports.PageConfig={}))});var os=R(Et=>{"use strict";Object.defineProperty(Et,"__esModule",{value:!0});Et.PathExt=void 0;var nt=require("path"),Ec;(function(n){function e(...l){let d=nt.posix.join(...l);return d==="."?"":u(d)}n.join=e;function t(l,d){return nt.posix.basename(l,d)}n.basename=t;function r(l){let d=u(nt.posix.dirname(l));return d==="."?"":d}n.dirname=r;function i(l){return nt.posix.extname(l)}n.extname=i;function s(l){return l===""?"":u(nt.posix.normalize(l))}n.normalize=s;function o(...l){return u(nt.posix.resolve(...l))}n.resolve=o;function a(l,d){return u(nt.posix.relative(l,d))}n.relative=a;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})(Ec=Et.PathExt||(Et.PathExt={}))});var as=R(Ot=>{"use strict";Object.defineProperty(Ot,"__esModule",{value:!0});Ot.Text=void 0;var Oc;(function(n){let e=2>1;function t(o,a){if(e)return o;let c=o;for(let u=0;u+1=55296&&l<=56319){let d=a.charCodeAt(u+1);d>=56320&&d<=57343&&(c--,u++)}}return c}n.jsIndexToCharIndex=t;function r(o,a){if(e)return o;let c=o;for(let u=0;u+1=55296&&l<=56319){let d=a.charCodeAt(u+1);d>=56320&&d<=57343&&(c++,u++)}}return c}n.charIndexToJsIndex=r;function i(o,a=!1){return o.replace(/^(\w)|[\s-_:]+(\w)/g,function(c,u,l){return l?l.toUpperCase():a?u.toUpperCase():u.toLowerCase()})}n.camelCase=i;function s(o){return(o||"").toLowerCase().split(" ").map(a=>a.charAt(0).toUpperCase()+a.slice(1)).join(" ")}n.titleCase=s})(Oc=Ot.Text||(Ot.Text={}))});var cs={};ec(cs,{default:()=>Mc});function Mc(n){return{formatNow:()=>{try{return n.toLocaleString()}catch{return`${n}`}},format:()=>{try{return n.toLocaleTimeString()}catch{return`${n}`}}}}var us=Qa(()=>{"use strict"});var ls=R(rt=>{"use strict";var Rc=rt&&rt.__importDefault||function(n){return n&&n.__esModule?n:{default:n}};Object.defineProperty(rt,"__esModule",{value:!0});rt.Time=void 0;var tr=Rc((us(),nc(cs))),xc;(function(n){function e(r){tr.default.locale(document.documentElement.lang);let i=tr.default(r).fromNow();return i=i==="a few seconds ago"?"seconds ago":i,i}n.formatHuman=e;function t(r,i="YYYY-MM-DD HH:mm"){return tr.default(r).format(i)}n.format=t})(xc=rt.Time||(rt.Time={}))});var pe=R(_e=>{"use strict";var Dc=_e&&_e.__createBinding||(Object.create?function(n,e,t,r){r===void 0&&(r=t),Object.defineProperty(n,r,{enumerable:!0,get:function(){return e[t]}})}:function(n,e,t,r){r===void 0&&(r=t),n[r]=e[t]}),$e=_e&&_e.__exportStar||function(n,e){for(var t in n)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&Dc(e,n,t)};Object.defineProperty(_e,"__esModule",{value:!0});$e(Li(),_e);$e(Bi(),_e);$e(Fi(),_e);$e(ss(),_e);$e(os(),_e);$e(as(),_e);$e(ls(),_e);$e(er(),_e)});var hs=R(it=>{"use strict";Object.defineProperty(it,"__esModule",{value:!0});it.ConfigWithDefaults=it.ConfigSection=void 0;var Pc=pe(),Mt=Ge(),Ic="api/config",kc;(function(n){function e(t){let r=new nr(t);return r.load().then(()=>r)}n.create=e})(kc=it.ConfigSection||(it.ConfigSection={}));var nr=class{constructor(e){var t;this._url="unknown";let r=this.serverSettings=(t=e.serverSettings)!==null&&t!==void 0?t:Mt.ServerConnection.makeSettings();this._url=Pc.URLExt.join(r.baseUrl,Ic,encodeURIComponent(e.name))}get data(){return this._data}async load(){let e=await Mt.ServerConnection.makeRequest(this._url,{},this.serverSettings);if(e.status!==200)throw await Mt.ServerConnection.ResponseError.create(e);this._data=await e.json()}async update(e){this._data=Object.assign(Object.assign({},this._data),e);let t={method:"PATCH",body:JSON.stringify(e)},r=await Mt.ServerConnection.makeRequest(this._url,t,this.serverSettings);if(r.status!==200)throw await Mt.ServerConnection.ResponseError.create(r);return this._data=await r.json(),this._data}},rr=class{constructor(e){var t,r;this._className="",this._section=e.section,this._defaults=(t=e.defaults)!==null&&t!==void 0?t:{},this._className=(r=e.className)!==null&&r!==void 0?r:""}get(e){let t=this._classData();return e in t?t[e]:this._defaults[e]}set(e,t){let r={};if(r[e]=t,this._className){let i={};return i[this._className]=r,this._section.update(i)}else return this._section.update(r)}_classData(){let e=this._section.data;return this._className&&this._className in e?e[this._className]:e}};it.ConfigWithDefaults=rr});var Rt=R(tn=>{"use strict";Object.defineProperty(tn,"__esModule",{value:!0});tn.validateProperty=void 0;function Tc(n,e,t,r=[]){if(!n.hasOwnProperty(e))throw Error(`Missing property '${e}'`);let i=n[e];if(t!==void 0){let s=!0;switch(t){case"array":s=Array.isArray(i);break;case"object":s=typeof i<"u";break;default:s=typeof i===t}if(!s)throw new Error(`Property '${e}' is not of type '${t}'`);if(r.length>0){let o=!0;switch(t){case"string":case"number":case"boolean":o=r.includes(i);break;default:o=r.findIndex(a=>a===i)>=0;break}if(!o)throw new Error(`Property '${e}' is not one of the valid values ${JSON.stringify(r)}`)}}}tn.validateProperty=Tc});var ds=R(ft=>{"use strict";Object.defineProperty(ft,"__esModule",{value:!0});ft.validateCheckpointModel=ft.validateContentsModel=void 0;var Ie=Rt();function jc(n){Ie.validateProperty(n,"name","string"),Ie.validateProperty(n,"path","string"),Ie.validateProperty(n,"type","string"),Ie.validateProperty(n,"created","string"),Ie.validateProperty(n,"last_modified","string"),Ie.validateProperty(n,"mimetype","object"),Ie.validateProperty(n,"content","object"),Ie.validateProperty(n,"format","object")}ft.validateContentsModel=jc;function qc(n){Ie.validateProperty(n,"id","string"),Ie.validateProperty(n,"last_modified","string")}ft.validateCheckpointModel=qc});var or=R(ue=>{"use strict";var Uc=ue&&ue.__createBinding||(Object.create?function(n,e,t,r){r===void 0&&(r=t),Object.defineProperty(n,r,{enumerable:!0,get:function(){return e[t]}})}:function(n,e,t,r){r===void 0&&(r=t),n[r]=e[t]}),Nc=ue&&ue.__setModuleDefault||(Object.create?function(n,e){Object.defineProperty(n,"default",{enumerable:!0,value:e})}:function(n,e){n.default=e}),Lc=ue&&ue.__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)&&Uc(e,n,t);return Nc(e,n),e};Object.defineProperty(ue,"__esModule",{value:!0});ue.Drive=ue.ContentsManager=ue.Contents=void 0;var ve=pe(),Ac=et(),nn=ie(),G=Ge(),Le=Lc(ds()),Bc="api/contents",Fc="files",Kc;(function(n){function e(r){Le.validateContentsModel(r)}n.validateContentsModel=e;function t(r){Le.validateCheckpointModel(r)}n.validateCheckpointModel=t})(Kc=ue.Contents||(ue.Contents={}));var ir=class{constructor(e={}){var t,r;this._isDisposed=!1,this._additionalDrives=new Map,this._fileChanged=new nn.Signal(this);let i=this.serverSettings=(t=e.serverSettings)!==null&&t!==void 0?t:G.ServerConnection.makeSettings();this._defaultDrive=(r=e.defaultDrive)!==null&&r!==void 0?r:new rn({serverSettings:i}),this._defaultDrive.fileChanged.connect(this._onFileChanged,this)}get fileChanged(){return this._fileChanged}get isDisposed(){return this._isDisposed}dispose(){this.isDisposed||(this._isDisposed=!0,nn.Signal.clearData(this))}addDrive(e){this._additionalDrives.set(e.name,e),e.fileChanged.connect(this._onFileChanged,this)}getModelDBFactory(e){var t;let[r]=this._driveForPath(e);return(t=r?.modelDBFactory)!==null&&t!==void 0?t:null}localPath(e){let t=e.split("/"),r=t[0].split(":");return r.length===1||!this._additionalDrives.has(r[0])?ve.PathExt.removeSlash(e):ve.PathExt.join(r.slice(1).join(":"),...t.slice(1))}normalize(e){let t=e.split(":");return t.length===1?ve.PathExt.normalize(e):`${t[0]}:${ve.PathExt.normalize(t.slice(1).join(":"))}`}resolvePath(e,t){let r=this.driveName(e),i=this.localPath(e),s=ve.PathExt.resolve("/",i,t);return r?`${r}:${s}`:s}driveName(e){let r=e.split("/")[0].split(":");return r.length===1?"":this._additionalDrives.has(r[0])?r[0]:""}get(e,t){let[r,i]=this._driveForPath(e);return r.get(i,t).then(s=>{let o=[];return s.type==="directory"&&s.content?(Ac.each(s.content,a=>{o.push(Object.assign(Object.assign({},a),{path:this._toGlobalPath(r,a.path)}))}),Object.assign(Object.assign({},s),{path:this._toGlobalPath(r,i),content:o})):Object.assign(Object.assign({},s),{path:this._toGlobalPath(r,i)})})}getDownloadUrl(e){let[t,r]=this._driveForPath(e);return t.getDownloadUrl(r)}newUntitled(e={}){if(e.path){let t=this.normalize(e.path),[r,i]=this._driveForPath(t);return r.newUntitled(Object.assign(Object.assign({},e),{path:i})).then(s=>Object.assign(Object.assign({},s),{path:ve.PathExt.join(t,s.name)}))}else return this._defaultDrive.newUntitled(e)}delete(e){let[t,r]=this._driveForPath(e);return t.delete(r)}rename(e,t){let[r,i]=this._driveForPath(e),[s,o]=this._driveForPath(t);if(r!==s)throw Error("ContentsManager: renaming files must occur within a Drive");return r.rename(i,o).then(a=>Object.assign(Object.assign({},a),{path:this._toGlobalPath(r,o)}))}save(e,t={}){let r=this.normalize(e),[i,s]=this._driveForPath(e);return i.save(s,Object.assign(Object.assign({},t),{path:s})).then(o=>Object.assign(Object.assign({},o),{path:r}))}copy(e,t){let[r,i]=this._driveForPath(e),[s,o]=this._driveForPath(t);if(r===s)return r.copy(i,o).then(a=>Object.assign(Object.assign({},a),{path:this._toGlobalPath(r,a.path)}));throw Error("Copying files between drives is not currently implemented")}createCheckpoint(e){let[t,r]=this._driveForPath(e);return t.createCheckpoint(r)}listCheckpoints(e){let[t,r]=this._driveForPath(e);return t.listCheckpoints(r)}restoreCheckpoint(e,t){let[r,i]=this._driveForPath(e);return r.restoreCheckpoint(i,t)}deleteCheckpoint(e,t){let[r,i]=this._driveForPath(e);return r.deleteCheckpoint(i,t)}_toGlobalPath(e,t){return e===this._defaultDrive?ve.PathExt.removeSlash(t):`${e.name}:${ve.PathExt.removeSlash(t)}`}_driveForPath(e){let t=this.driveName(e),r=this.localPath(e);return t?[this._additionalDrives.get(t),r]:[this._defaultDrive,r]}_onFileChanged(e,t){var r,i;if(e===this._defaultDrive)this._fileChanged.emit(t);else{let s=null,o=null;!((r=t.newValue)===null||r===void 0)&&r.path&&(s=Object.assign(Object.assign({},t.newValue),{path:this._toGlobalPath(e,t.newValue.path)})),!((i=t.oldValue)===null||i===void 0)&&i.path&&(o=Object.assign(Object.assign({},t.oldValue),{path:this._toGlobalPath(e,t.oldValue.path)})),this._fileChanged.emit({type:t.type,newValue:s,oldValue:o})}}};ue.ContentsManager=ir;var rn=class{constructor(e={}){var t,r,i;this._isDisposed=!1,this._fileChanged=new nn.Signal(this),this.name=(t=e.name)!==null&&t!==void 0?t:"Default",this._apiEndpoint=(r=e.apiEndpoint)!==null&&r!==void 0?r:Bc,this.serverSettings=(i=e.serverSettings)!==null&&i!==void 0?i:G.ServerConnection.makeSettings()}get fileChanged(){return this._fileChanged}get isDisposed(){return this._isDisposed}dispose(){this.isDisposed||(this._isDisposed=!0,nn.Signal.clearData(this))}async get(e,t){let r=this._getUrl(e);if(t){t.type==="notebook"&&delete t.format;let a=t.content?"1":"0",c=Object.assign(Object.assign({},t),{content:a});r+=ve.URLExt.objectToQueryString(c)}let i=this.serverSettings,s=await G.ServerConnection.makeRequest(r,{},i);if(s.status!==200)throw await G.ServerConnection.ResponseError.create(s);let o=await s.json();return Le.validateContentsModel(o),o}getDownloadUrl(e){let t=this.serverSettings.baseUrl,r=ve.URLExt.join(t,Fc,ve.URLExt.encodeParts(e)),i=document.cookie.match("\\b_xsrf=([^;]*)\\b");if(i){let s=new URL(r);s.searchParams.append("_xsrf",i[1]),r=s.toString()}return Promise.resolve(r)}async newUntitled(e={}){var t;let r="{}";e&&(e.ext&&(e.ext=sr.normalizeExtension(e.ext)),r=JSON.stringify(e));let i=this.serverSettings,s=this._getUrl((t=e.path)!==null&&t!==void 0?t:""),o={method:"POST",body:r},a=await G.ServerConnection.makeRequest(s,o,i);if(a.status!==201)throw await G.ServerConnection.ResponseError.create(a);let c=await a.json();return Le.validateContentsModel(c),this._fileChanged.emit({type:"new",oldValue:null,newValue:c}),c}async delete(e){let t=this._getUrl(e),r=this.serverSettings,i={method:"DELETE"},s=await G.ServerConnection.makeRequest(t,i,r);if(s.status!==204)throw await G.ServerConnection.ResponseError.create(s);this._fileChanged.emit({type:"delete",oldValue:{path:e},newValue:null})}async rename(e,t){let r=this.serverSettings,i=this._getUrl(e),s={method:"PATCH",body:JSON.stringify({path:t})},o=await G.ServerConnection.makeRequest(i,s,r);if(o.status!==200)throw await G.ServerConnection.ResponseError.create(o);let a=await o.json();return Le.validateContentsModel(a),this._fileChanged.emit({type:"rename",oldValue:{path:e},newValue:a}),a}async save(e,t={}){let r=this.serverSettings,i=this._getUrl(e),s={method:"PUT",body:JSON.stringify(t)},o=await G.ServerConnection.makeRequest(i,s,r);if(o.status!==200&&o.status!==201)throw await G.ServerConnection.ResponseError.create(o);let a=await o.json();return Le.validateContentsModel(a),this._fileChanged.emit({type:"save",oldValue:null,newValue:a}),a}async copy(e,t){let r=this.serverSettings,i=this._getUrl(t),s={method:"POST",body:JSON.stringify({copy_from:e})},o=await G.ServerConnection.makeRequest(i,s,r);if(o.status!==201)throw await G.ServerConnection.ResponseError.create(o);let a=await o.json();return Le.validateContentsModel(a),this._fileChanged.emit({type:"new",oldValue:null,newValue:a}),a}async createCheckpoint(e){let t=this._getUrl(e,"checkpoints"),r={method:"POST"},i=await G.ServerConnection.makeRequest(t,r,this.serverSettings);if(i.status!==201)throw await G.ServerConnection.ResponseError.create(i);let s=await i.json();return Le.validateCheckpointModel(s),s}async listCheckpoints(e){let t=this._getUrl(e,"checkpoints"),r=await G.ServerConnection.makeRequest(t,{},this.serverSettings);if(r.status!==200)throw await G.ServerConnection.ResponseError.create(r);let i=await r.json();if(!Array.isArray(i))throw new Error("Invalid Checkpoint list");for(let s=0;sve.URLExt.encodeParts(i)),r=this.serverSettings.baseUrl;return ve.URLExt.join(r,this._apiEndpoint,...t)}};ue.Drive=rn;var sr;(function(n){function e(t){return t.length>0&&t.indexOf(".")!==0&&(t=`.${t}`),t}n.normalizeExtension=e})(sr||(sr={}))});var _s=R(fs=>{"use strict";Object.defineProperty(fs,"__esModule",{value:!0})});var xt=R(A=>{"use strict";Object.defineProperty(A,"__esModule",{value:!0});A.isInputReplyMsg=A.isInputRequestMsg=A.isDebugReplyMsg=A.isDebugRequestMsg=A.isExecuteReplyMsg=A.isInfoRequestMsg=A.isCommMsgMsg=A.isCommCloseMsg=A.isCommOpenMsg=A.isDebugEventMsg=A.isClearOutputMsg=A.isStatusMsg=A.isErrorMsg=A.isExecuteResultMsg=A.isExecuteInputMsg=A.isUpdateDisplayDataMsg=A.isDisplayDataMsg=A.isStreamMsg=A.createMessage=void 0;var Vc=Ee();function Wc(n){var e,t,r,i,s;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:Vc.UUID.uuid4(),msg_type:n.msgType,session:n.session,username:(r=n.username)!==null&&r!==void 0?r:"",version:"5.2"},metadata:(i=n.metadata)!==null&&i!==void 0?i:{},parent_header:(s=n.parentHeader)!==null&&s!==void 0?s:{}}}A.createMessage=Wc;function $c(n){return n.header.msg_type==="stream"}A.isStreamMsg=$c;function Gc(n){return n.header.msg_type==="display_data"}A.isDisplayDataMsg=Gc;function Hc(n){return n.header.msg_type==="update_display_data"}A.isUpdateDisplayDataMsg=Hc;function zc(n){return n.header.msg_type==="execute_input"}A.isExecuteInputMsg=zc;function Jc(n){return n.header.msg_type==="execute_result"}A.isExecuteResultMsg=Jc;function Yc(n){return n.header.msg_type==="error"}A.isErrorMsg=Yc;function Xc(n){return n.header.msg_type==="status"}A.isStatusMsg=Xc;function Zc(n){return n.header.msg_type==="clear_output"}A.isClearOutputMsg=Zc;function Qc(n){return n.header.msg_type==="debug_event"}A.isDebugEventMsg=Qc;function eu(n){return n.header.msg_type==="comm_open"}A.isCommOpenMsg=eu;function tu(n){return n.header.msg_type==="comm_close"}A.isCommCloseMsg=tu;function nu(n){return n.header.msg_type==="comm_msg"}A.isCommMsgMsg=nu;function ru(n){return n.header.msg_type==="kernel_info_request"}A.isInfoRequestMsg=ru;function iu(n){return n.header.msg_type==="execute_reply"}A.isExecuteReplyMsg=iu;function su(n){return n.header.msg_type==="debug_request"}A.isDebugRequestMsg=su;function ou(n){return n.header.msg_type==="debug_reply"}A.isDebugReplyMsg=ou;function au(n){return n.header.msg_type==="input_request"}A.isInputRequestMsg=au;function cu(n){return n.header.msg_type==="input_reply"}A.isInputReplyMsg=cu});var st=R((zd,ps)=>{"use strict";ps.exports={BINARY_TYPES:["nodebuffer","arraybuffer","fragments"],GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),EMPTY_BUFFER:Buffer.alloc(0),NOOP:()=>{}}});var Is=R((Jd,Ps)=>{var ys=require("fs"),Ae=require("path"),ws=require("os"),Ss=typeof __webpack_require__=="function"?__non_webpack_require__:require,uu=process.config&&process.config.variables||{},lu=!!process.env.PREBUILDS_ONLY,gs=process.versions.modules,ar=fu()?"electron":du()?"node-webkit":"node",cr=process.env.npm_config_arch||ws.arch(),ur=process.env.npm_config_platform||ws.platform(),bs=process.env.LIBC||(_u(ur)?"musl":"glibc"),lr=process.env.ARM_VERSION||(cr==="arm64"?"8":uu.arm_version)||"",Cs=(process.versions.uv||"").split(".")[0];Ps.exports=ke;function ke(n){return Ss(ke.resolve(n))}ke.resolve=ke.path=function(n){n=Ae.resolve(n||".");try{var e=Ss(Ae.join(n,"package.json")).name.toUpperCase().replace(/-/g,"_");process.env[e+"_PREBUILD"]&&(n=process.env[e+"_PREBUILD"])}catch{}if(!lu){var t=ms(Ae.join(n,"build/Release"),vs);if(t)return t;var r=ms(Ae.join(n,"build/Debug"),vs);if(r)return r}var i=a(n);if(i)return i;var s=a(Ae.dirname(process.execPath));if(s)return s;var o=["platform="+ur,"arch="+cr,"runtime="+ar,"abi="+gs,"uv="+Cs,lr?"armv="+lr:"","libc="+bs,"node="+process.versions.node,process.versions.electron?"electron="+process.versions.electron:"",typeof __webpack_require__=="function"?"webpack=true":""].filter(Boolean).join(" ");throw new Error("No native build was found for "+o+`
loaded from: `+n+`
`);function a(c){var u=hr(Ae.join(c,"prebuilds")).map(Es),l=u.filter(Os(ur,cr)).sort(Ms)[0];if(l){var d=Ae.join(c,"prebuilds",l.name),g=hr(d).map(Rs),y=g.filter(xs(ar,gs)),v=y.sort(Ds(ar))[0];if(v)return Ae.join(d,v.file)}}};function hr(n){try{return ys.readdirSync(n)}catch{return[]}}function ms(n,e){var t=hr(n).filter(e);return t[0]&&Ae.join(n,t[0])}function vs(n){return/\.node$/.test(n)}function Es(n){var e=n.split("-");if(e.length===2){var t=e[0],r=e[1].split("+");if(t&&r.length&&r.every(Boolean))return{name:n,platform:t,architectures:r}}}function Os(n,e){return function(t){return t==null||t.platform!==n?!1:t.architectures.includes(e)}}function Ms(n,e){return n.architectures.length-e.architectures.length}function Rs(n){var e=n.split("."),t=e.pop(),r={file:n,specificity:0};if(t==="node"){for(var i=0;it.specificity?-1:1:0}}function du(){return!!(process.versions&&process.versions.nw)}function fu(){return process.versions&&process.versions.electron||process.env.ELECTRON_RUN_AS_NODE?!0:typeof window<"u"&&window.process&&window.process.type==="renderer"}function _u(n){return n==="linux"&&ys.existsSync("/etc/alpine-release")}ke.parseTags=Rs;ke.matchTags=xs;ke.compareTags=Ds;ke.parseTuple=Es;ke.matchTuple=Os;ke.compareTuples=Ms});var fr=R((Yd,dr)=>{typeof process.addon=="function"?dr.exports=process.addon.bind(process):dr.exports=Is()});var Ts=R((Xd,ks)=>{"use strict";var pu=(n,e,t,r,i)=>{for(var s=0;s{let t=n.length;for(var r=0;r{"use strict";try{_r.exports=fr()(__dirname)}catch{_r.exports=Ts()}});var Dt=R((Qd,pr)=>{"use strict";var{EMPTY_BUFFER:mu}=st();function qs(n,e){if(n.length===0)return mu;if(n.length===1)return n[0];let t=Buffer.allocUnsafe(e),r=0;for(let i=0;i{"use strict";var As=Symbol("kDone"),gr=Symbol("kRun"),mr=class{constructor(e){this[As]=()=>{this.pending--,this[gr]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[gr]()}[gr](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[As])}}};Bs.exports=mr});var kt=R((tf,$s)=>{"use strict";var Pt=require("zlib"),Ks=Dt(),vu=Fs(),{kStatusCode:Vs,NOOP:yu}=st(),wu=Buffer.from([0,0,255,255]),cn=Symbol("permessage-deflate"),Be=Symbol("total-length"),It=Symbol("callback"),He=Symbol("buffers"),an=Symbol("error"),on,vr=class{constructor(e,t,r){if(this._maxPayload=r|0,this._options=e||{},this._threshold=this._options.threshold!==void 0?this._options.threshold:1024,this._isServer=!!t,this._deflate=null,this._inflate=null,this.params=null,!on){let i=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;on=new vu(i)}}static get extensionName(){return"permessage-deflate"}offer(){let e={};return this._options.serverNoContextTakeover&&(e.server_no_context_takeover=!0),this._options.clientNoContextTakeover&&(e.client_no_context_takeover=!0),this._options.serverMaxWindowBits&&(e.server_max_window_bits=this._options.serverMaxWindowBits),this._options.clientMaxWindowBits?e.client_max_window_bits=this._options.clientMaxWindowBits:this._options.clientMaxWindowBits==null&&(e.client_max_window_bits=!0),e}accept(e){return e=this.normalizeParams(e),this.params=this._isServer?this.acceptAsServer(e):this.acceptAsClient(e),this.params}cleanup(){if(this._inflate&&(this._inflate.close(),this._inflate=null),this._deflate){let e=this._deflate[It];this._deflate.close(),this._deflate=null,e&&e(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(e){let t=this._options,r=e.find(i=>!(t.serverNoContextTakeover===!1&&i.server_no_context_takeover||i.server_max_window_bits&&(t.serverMaxWindowBits===!1||typeof t.serverMaxWindowBits=="number"&&t.serverMaxWindowBits>i.server_max_window_bits)||typeof t.clientMaxWindowBits=="number"&&!i.client_max_window_bits));if(!r)throw new Error("None of the extension offers can be accepted");return t.serverNoContextTakeover&&(r.server_no_context_takeover=!0),t.clientNoContextTakeover&&(r.client_no_context_takeover=!0),typeof t.serverMaxWindowBits=="number"&&(r.server_max_window_bits=t.serverMaxWindowBits),typeof t.clientMaxWindowBits=="number"?r.client_max_window_bits=t.clientMaxWindowBits:(r.client_max_window_bits===!0||t.clientMaxWindowBits===!1)&&delete r.client_max_window_bits,r}acceptAsClient(e){let t=e[0];if(this._options.clientNoContextTakeover===!1&&t.client_no_context_takeover)throw new Error('Unexpected parameter "client_no_context_takeover"');if(!t.client_max_window_bits)typeof this._options.clientMaxWindowBits=="number"&&(t.client_max_window_bits=this._options.clientMaxWindowBits);else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits=="number"&&t.client_max_window_bits>this._options.clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"');return t}normalizeParams(e){return e.forEach(t=>{Object.keys(t).forEach(r=>{let i=t[r];if(i.length>1)throw new Error(`Parameter "${r}" must have only a single value`);if(i=i[0],r==="client_max_window_bits"){if(i!==!0){let s=+i;if(!Number.isInteger(s)||s<8||s>15)throw new TypeError(`Invalid value for parameter "${r}": ${i}`);i=s}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${r}": ${i}`)}else if(r==="server_max_window_bits"){let s=+i;if(!Number.isInteger(s)||s<8||s>15)throw new TypeError(`Invalid value for parameter "${r}": ${i}`);i=s}else if(r==="client_no_context_takeover"||r==="server_no_context_takeover"){if(i!==!0)throw new TypeError(`Invalid value for parameter "${r}": ${i}`)}else throw new Error(`Unknown parameter "${r}"`);t[r]=i})}),e}decompress(e,t,r){on.add(i=>{this._decompress(e,t,(s,o)=>{i(),r(s,o)})})}compress(e,t,r){on.add(i=>{this._compress(e,t,(s,o)=>{i(),r(s,o)})})}_decompress(e,t,r){let i=this._isServer?"client":"server";if(!this._inflate){let s=`${i}_max_window_bits`,o=typeof this.params[s]!="number"?Pt.Z_DEFAULT_WINDOWBITS:this.params[s];this._inflate=Pt.createInflateRaw({...this._options.zlibInflateOptions,windowBits:o}),this._inflate[cn]=this,this._inflate[Be]=0,this._inflate[He]=[],this._inflate.on("error",bu),this._inflate.on("data",Ws)}this._inflate[It]=r,this._inflate.write(e),t&&this._inflate.write(wu),this._inflate.flush(()=>{let s=this._inflate[an];if(s){this._inflate.close(),this._inflate=null,r(s);return}let o=Ks.concat(this._inflate[He],this._inflate[Be]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[Be]=0,this._inflate[He]=[],t&&this.params[`${i}_no_context_takeover`]&&this._inflate.reset()),r(null,o)})}_compress(e,t,r){let i=this._isServer?"server":"client";if(!this._deflate){let s=`${i}_max_window_bits`,o=typeof this.params[s]!="number"?Pt.Z_DEFAULT_WINDOWBITS:this.params[s];this._deflate=Pt.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:o}),this._deflate[Be]=0,this._deflate[He]=[],this._deflate.on("error",yu),this._deflate.on("data",Su)}this._deflate[It]=r,this._deflate.write(e),this._deflate.flush(Pt.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let s=Ks.concat(this._deflate[He],this._deflate[Be]);t&&(s=s.slice(0,s.length-4)),this._deflate[It]=null,this._deflate[Be]=0,this._deflate[He]=[],t&&this.params[`${i}_no_context_takeover`]&&this._deflate.reset(),r(null,s)})}};$s.exports=vr;function Su(n){this[He].push(n),this[Be]+=n.length}function Ws(n){if(this[Be]+=n.length,this[cn]._maxPayload<1||this[Be]<=this[cn]._maxPayload){this[He].push(n);return}this[an]=new RangeError("Max payload size exceeded"),this[an].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[an][Vs]=1009,this.removeListener("data",Ws),this.reset()}function bu(n){this[cn]._inflate=null,n[Vs]=1007,this[It](n)}});var Hs=R((nf,Gs)=>{"use strict";function Cu(n){let e=n.length,t=0;for(;t=e||(n[t+1]&192)!==128||(n[t+2]&192)!==128||n[t]===224&&(n[t+1]&224)===128||n[t]===237&&(n[t+1]&224)===160)return!1;t+=3}else if((n[t]&248)===240){if(t+3>=e||(n[t+1]&192)!==128||(n[t+2]&192)!==128||(n[t+3]&192)!==128||n[t]===240&&(n[t+1]&240)===128||n[t]===244&&n[t+1]>143||n[t]>244)return!1;t+=4}else return!1;return!0}Gs.exports=Cu});var zs=R((rf,yr)=>{"use strict";try{yr.exports=fr()(__dirname)}catch{yr.exports=Hs()}});var Sr=R((sf,wr)=>{"use strict";function Js(n){return n>=1e3&&n<=1014&&n!==1004&&n!==1005&&n!==1006||n>=3e3&&n<=4999}function Ys(n){let e=n.length,t=0;for(;t=e||(n[t+1]&192)!==128||(n[t+2]&192)!==128||n[t]===224&&(n[t+1]&224)===128||n[t]===237&&(n[t+1]&224)===160)return!1;t+=3}else if((n[t]&248)===240){if(t+3>=e||(n[t+1]&192)!==128||(n[t+2]&192)!==128||(n[t+3]&192)!==128||n[t]===240&&(n[t+1]&240)===128||n[t]===244&&n[t+1]>143||n[t]>244)return!1;t+=4}else return!1;return!0}try{let n=zs();typeof n=="object"&&(n=n.Validation.isValidUTF8),wr.exports={isValidStatusCode:Js,isValidUTF8(e){return e.length<150?Ys(e):n(e)}}}catch{wr.exports={isValidStatusCode:Js,isValidUTF8:Ys}}});var Or=R((of,no)=>{"use strict";var{Writable:Eu}=require("stream"),Xs=kt(),{BINARY_TYPES:Ou,EMPTY_BUFFER:Mu,kStatusCode:Ru,kWebSocket:xu}=st(),{concat:br,toArrayBuffer:Du,unmask:Pu}=Dt(),{isValidStatusCode:Iu,isValidUTF8:Zs}=Sr(),Tt=0,Qs=1,eo=2,to=3,Cr=4,ku=5,Er=class extends Eu{constructor(e,t,r,i){super(),this._binaryType=e||Ou[0],this[xu]=void 0,this._extensions=t||{},this._isServer=!!r,this._maxPayload=i|0,this._bufferedBytes=0,this._buffers=[],this._compressed=!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=0,this._messageLength=0,this._fragments=[],this._state=Tt,this._loop=!1}_write(e,t,r){if(this._opcode===8&&this._state==Tt)return r();this._bufferedBytes+=e.length,this._buffers.push(e),this.startLoop(r)}consume(e){if(this._bufferedBytes-=e,e===this._buffers[0].length)return this._buffers.shift();if(e=r.length?t.set(this._buffers.shift(),i):(t.set(new Uint8Array(r.buffer,r.byteOffset,e),i),this._buffers[0]=r.slice(e)),e-=r.length}while(e>0);return t}startLoop(e){let t;this._loop=!0;do switch(this._state){case Tt:t=this.getInfo();break;case Qs:t=this.getPayloadLength16();break;case eo:t=this.getPayloadLength64();break;case to:this.getMask();break;case Cr:t=this.getData(e);break;default:this._loop=!1;return}while(this._loop);e(t)}getInfo(){if(this._bufferedBytes<2){this._loop=!1;return}let e=this.consume(2);if(e[0]&48)return this._loop=!1,Y(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");let t=(e[0]&64)===64;if(t&&!this._extensions[Xs.extensionName])return this._loop=!1,Y(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");if(this._fin=(e[0]&128)===128,this._opcode=e[0]&15,this._payloadLength=e[1]&127,this._opcode===0){if(t)return this._loop=!1,Y(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");if(!this._fragmented)return this._loop=!1,Y(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented)return this._loop=!1,Y(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");this._compressed=t}else if(this._opcode>7&&this._opcode<11){if(!this._fin)return this._loop=!1,Y(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");if(t)return this._loop=!1,Y(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");if(this._payloadLength>125)return this._loop=!1,Y(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH")}else return this._loop=!1,Y(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(e[1]&128)===128,this._isServer){if(!this._masked)return this._loop=!1,Y(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK")}else if(this._masked)return this._loop=!1,Y(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");if(this._payloadLength===126)this._state=Qs;else if(this._payloadLength===127)this._state=eo;else return this.haveLength()}getPayloadLength16(){if(this._bufferedBytes<2){this._loop=!1;return}return this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength()}getPayloadLength64(){if(this._bufferedBytes<8){this._loop=!1;return}let e=this.consume(8),t=e.readUInt32BE(0);return t>Math.pow(2,53-32)-1?(this._loop=!1,Y(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH")):(this._payloadLength=t*Math.pow(2,32)+e.readUInt32BE(4),this.haveLength())}haveLength(){if(this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0))return this._loop=!1,Y(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");this._masked?this._state=to:this._state=Cr}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=Cr}getData(e){let t=Mu;if(this._payloadLength){if(this._bufferedBytes7)return this.controlMessage(t);if(this._compressed){this._state=ku,this.decompress(t,e);return}return t.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(t)),this.dataMessage()}decompress(e,t){this._extensions[Xs.extensionName].decompress(e,this._fin,(i,s)=>{if(i)return t(i);if(s.length){if(this._messageLength+=s.length,this._messageLength>this._maxPayload&&this._maxPayload>0)return t(Y(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH"));this._fragments.push(s)}let o=this.dataMessage();if(o)return t(o);this.startLoop(t)})}dataMessage(){if(this._fin){let e=this._messageLength,t=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let r;this._binaryType==="nodebuffer"?r=br(t,e):this._binaryType==="arraybuffer"?r=Du(br(t,e)):r=t,this.emit("message",r)}else{let r=br(t,e);if(!Zs(r))return this._loop=!1,Y(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");this.emit("message",r.toString())}}this._state=Tt}controlMessage(e){if(this._opcode===8)if(this._loop=!1,e.length===0)this.emit("conclude",1005,""),this.end();else{if(e.length===1)return Y(RangeError,"invalid payload length 1",!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");{let t=e.readUInt16BE(0);if(!Iu(t))return Y(RangeError,`invalid status code ${t}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");let r=e.slice(2);if(!Zs(r))return Y(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");this.emit("conclude",t,r.toString()),this.end()}}else this._opcode===9?this.emit("ping",e):this.emit("pong",e);this._state=Tt}};no.exports=Er;function Y(n,e,t,r,i){let s=new n(t?`Invalid WebSocket frame: ${e}`:e);return Error.captureStackTrace(s,Y),s.code=i,s[Ru]=r,s}});var Rr=R((uf,so)=>{"use strict";var af=require("net"),cf=require("tls"),{randomFillSync:Tu}=require("crypto"),ro=kt(),{EMPTY_BUFFER:ju}=st(),{isValidStatusCode:qu}=Sr(),{mask:io,toBuffer:Fe}=Dt(),ot=Buffer.alloc(4),Mr=class n{constructor(e,t){this._extensions=t||{},this._socket=e,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._deflating=!1,this._queue=[]}static frame(e,t){let r=t.mask&&t.readOnly,i=t.mask?6:2,s=e.length;e.length>=65536?(i+=8,s=127):e.length>125&&(i+=2,s=126);let o=Buffer.allocUnsafe(r?e.length+i:i);return o[0]=t.fin?t.opcode|128:t.opcode,t.rsv1&&(o[0]|=64),o[1]=s,s===126?o.writeUInt16BE(e.length,2):s===127&&(o.writeUInt32BE(0,2),o.writeUInt32BE(e.length,6)),t.mask?(Tu(ot,0,4),o[1]|=128,o[i-4]=ot[0],o[i-3]=ot[1],o[i-2]=ot[2],o[i-1]=ot[3],r?(io(e,ot,o,i,e.length),[o]):(io(e,ot,e,0,e.length),[o,e])):[o,e]}close(e,t,r,i){let s;if(e===void 0)s=ju;else{if(typeof e!="number"||!qu(e))throw new TypeError("First argument must be a valid error code number");if(t===void 0||t==="")s=Buffer.allocUnsafe(2),s.writeUInt16BE(e,0);else{let o=Buffer.byteLength(t);if(o>123)throw new RangeError("The message must not be greater than 123 bytes");s=Buffer.allocUnsafe(2+o),s.writeUInt16BE(e,0),s.write(t,2)}}this._deflating?this.enqueue([this.doClose,s,r,i]):this.doClose(s,r,i)}doClose(e,t,r){this.sendFrame(n.frame(e,{fin:!0,rsv1:!1,opcode:8,mask:t,readOnly:!1}),r)}ping(e,t,r){let i=Fe(e);if(i.length>125)throw new RangeError("The data size must not be greater than 125 bytes");this._deflating?this.enqueue([this.doPing,i,t,Fe.readOnly,r]):this.doPing(i,t,Fe.readOnly,r)}doPing(e,t,r,i){this.sendFrame(n.frame(e,{fin:!0,rsv1:!1,opcode:9,mask:t,readOnly:r}),i)}pong(e,t,r){let i=Fe(e);if(i.length>125)throw new RangeError("The data size must not be greater than 125 bytes");this._deflating?this.enqueue([this.doPong,i,t,Fe.readOnly,r]):this.doPong(i,t,Fe.readOnly,r)}doPong(e,t,r,i){this.sendFrame(n.frame(e,{fin:!0,rsv1:!1,opcode:10,mask:t,readOnly:r}),i)}send(e,t,r){let i=Fe(e),s=this._extensions[ro.extensionName],o=t.binary?2:1,a=t.compress;if(this._firstFragment?(this._firstFragment=!1,a&&s&&(a=i.length>=s._threshold),this._compress=a):(a=!1,o=0),t.fin&&(this._firstFragment=!0),s){let c={fin:t.fin,rsv1:a,opcode:o,mask:t.mask,readOnly:Fe.readOnly};this._deflating?this.enqueue([this.dispatch,i,this._compress,c,r]):this.dispatch(i,this._compress,c,r)}else this.sendFrame(n.frame(i,{fin:t.fin,rsv1:!1,opcode:o,mask:t.mask,readOnly:Fe.readOnly}),r)}dispatch(e,t,r,i){if(!t){this.sendFrame(n.frame(e,r),i);return}let s=this._extensions[ro.extensionName];this._bufferedBytes+=e.length,this._deflating=!0,s.compress(e,r.fin,(o,a)=>{if(this._socket.destroyed){let c=new Error("The socket was closed while data was being compressed");typeof i=="function"&&i(c);for(let u=0;u{"use strict";var _t=class{constructor(e,t){this.target=t,this.type=e}},xr=class extends _t{constructor(e,t){super("message",t),this.data=e}},Dr=class extends _t{constructor(e,t,r){super("close",r),this.wasClean=r._closeFrameReceived&&r._closeFrameSent,this.reason=t,this.code=e}},Pr=class extends _t{constructor(e){super("open",e)}},Ir=class extends _t{constructor(e,t){super("error",t),this.message=e.message,this.error=e}},Uu={addEventListener(n,e,t){if(typeof e!="function")return;function r(c){e.call(this,new xr(c,this))}function i(c,u){e.call(this,new Dr(c,u,this))}function s(c){e.call(this,new Ir(c,this))}function o(){e.call(this,new Pr(this))}let a=t&&t.once?"once":"on";n==="message"?(r._listener=e,this[a](n,r)):n==="close"?(i._listener=e,this[a](n,i)):n==="error"?(s._listener=e,this[a](n,s)):n==="open"?(o._listener=e,this[a](n,o)):this[a](n,e)},removeEventListener(n,e){let t=this.listeners(n);for(let r=0;r{"use strict";var jt=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0];function Te(n,e,t){n[e]===void 0?n[e]=[t]:n[e].push(t)}function Nu(n){let e=Object.create(null);if(n===void 0||n==="")return e;let t=Object.create(null),r=!1,i=!1,s=!1,o,a,c=-1,u=-1,l=0;for(;l{let t=n[e];return Array.isArray(t)||(t=[t]),t.map(r=>[e].concat(Object.keys(r).map(i=>{let s=r[i];return Array.isArray(s)||(s=[s]),s.map(o=>o===!0?i:`${i}=${o}`).join("; ")})).join("; ")).join(", ")}).join(", ")}co.exports={format:Lu,parse:Nu}});var Lr=R((ff,yo)=>{"use strict";var Au=require("events"),Bu=require("https"),Fu=require("http"),ho=require("net"),Ku=require("tls"),{randomBytes:Vu,createHash:Wu}=require("crypto"),{Readable:df}=require("stream"),{URL:Tr}=require("url"),ze=kt(),$u=Or(),Gu=Rr(),{BINARY_TYPES:uo,EMPTY_BUFFER:jr,GUID:Hu,kStatusCode:zu,kWebSocket:se,NOOP:fo}=st(),{addEventListener:Ju,removeEventListener:Yu}=ao(),{format:Xu,parse:Zu}=kr(),{toBuffer:Qu}=Dt(),Ke=["CONNECTING","OPEN","CLOSING","CLOSED"],qr=[8,13],el=30*1e3,z=class n extends Au{constructor(e,t,r){super(),this._binaryType=uo[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage="",this._closeTimer=null,this._extensions={},this._protocol="",this._readyState=n.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,e!==null?(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,Array.isArray(t)?t=t.join(", "):typeof t=="object"&&t!==null&&(r=t,t=void 0),_o(this,e,t,r)):this._isServer=!0}get binaryType(){return this._binaryType}set binaryType(e){uo.includes(e)&&(this._binaryType=e,this._receiver&&(this._receiver._binaryType=e))}get bufferedAmount(){return this._socket?this._socket._writableState.length+this._sender._bufferedBytes:this._bufferedAmount}get extensions(){return Object.keys(this._extensions).join()}get onclose(){}set onclose(e){}get onerror(){}set onerror(e){}get onopen(){}set onopen(e){}get onmessage(){}set onmessage(e){}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(e,t,r){let i=new $u(this.binaryType,this._extensions,this._isServer,r);this._sender=new Gu(e,this._extensions),this._receiver=i,this._socket=e,i[se]=this,e[se]=this,i.on("conclude",rl),i.on("drain",il),i.on("error",sl),i.on("message",ol),i.on("ping",al),i.on("pong",cl),e.setTimeout(0),e.setNoDelay(),t.length>0&&e.unshift(t),e.on("close",go),e.on("data",un),e.on("end",mo),e.on("error",vo),this._readyState=n.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=n.CLOSED,this.emit("close",this._closeCode,this._closeMessage);return}this._extensions[ze.extensionName]&&this._extensions[ze.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=n.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(e,t){if(this.readyState!==n.CLOSED){if(this.readyState===n.CONNECTING){let r="WebSocket was closed before the connection was established";return be(this,this._req,r)}if(this.readyState===n.CLOSING){this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();return}this._readyState=n.CLOSING,this._sender.close(e,t,!this._isServer,r=>{r||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),this._closeTimer=setTimeout(this._socket.destroy.bind(this._socket),el)}}ping(e,t,r){if(this.readyState===n.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(r=e,e=t=void 0):typeof t=="function"&&(r=t,t=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==n.OPEN){Nr(this,e,r);return}t===void 0&&(t=!this._isServer),this._sender.ping(e||jr,t,r)}pong(e,t,r){if(this.readyState===n.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(r=e,e=t=void 0):typeof t=="function"&&(r=t,t=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==n.OPEN){Nr(this,e,r);return}t===void 0&&(t=!this._isServer),this._sender.pong(e||jr,t,r)}send(e,t,r){if(this.readyState===n.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof t=="function"&&(r=t,t={}),typeof e=="number"&&(e=e.toString()),this.readyState!==n.OPEN){Nr(this,e,r);return}let i={binary:typeof e!="string",mask:!this._isServer,compress:!0,fin:!0,...t};this._extensions[ze.extensionName]||(i.compress=!1),this._sender.send(e||jr,i,r)}terminate(){if(this.readyState!==n.CLOSED){if(this.readyState===n.CONNECTING){let e="WebSocket was closed before the connection was established";return be(this,this._req,e)}this._socket&&(this._readyState=n.CLOSING,this._socket.destroy())}}};Object.defineProperty(z,"CONNECTING",{enumerable:!0,value:Ke.indexOf("CONNECTING")});Object.defineProperty(z.prototype,"CONNECTING",{enumerable:!0,value:Ke.indexOf("CONNECTING")});Object.defineProperty(z,"OPEN",{enumerable:!0,value:Ke.indexOf("OPEN")});Object.defineProperty(z.prototype,"OPEN",{enumerable:!0,value:Ke.indexOf("OPEN")});Object.defineProperty(z,"CLOSING",{enumerable:!0,value:Ke.indexOf("CLOSING")});Object.defineProperty(z.prototype,"CLOSING",{enumerable:!0,value:Ke.indexOf("CLOSING")});Object.defineProperty(z,"CLOSED",{enumerable:!0,value:Ke.indexOf("CLOSED")});Object.defineProperty(z.prototype,"CLOSED",{enumerable:!0,value:Ke.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","protocol","readyState","url"].forEach(n=>{Object.defineProperty(z.prototype,n,{enumerable:!0})});["open","error","close","message"].forEach(n=>{Object.defineProperty(z.prototype,`on${n}`,{enumerable:!0,get(){let e=this.listeners(n);for(let t=0;t{be(n,g,"Opening handshake has timed out")}),g.on("error",y=>{g===null||g.aborted||(g=n._req=null,Ur(n,y))}),g.on("response",y=>{let v=y.headers.location,b=y.statusCode;if(v&&i.followRedirects&&b>=300&&b<400){if(++n._redirects>i.maxRedirects){be(n,g,"Maximum redirects exceeded");return}g.abort();let x;try{x=new Tr(v,e)}catch(O){Ur(n,O);return}_o(n,x,t,r)}else n.emit("unexpected-response",g,y)||be(n,g,`Unexpected server response: ${y.statusCode}`)}),g.on("upgrade",(y,v,b)=>{if(n.emit("upgrade",y),n.readyState!==z.CONNECTING)return;g=n._req=null;let x=Wu("sha1").update(u+Hu).digest("base64");if(y.headers["sec-websocket-accept"]!==x){be(n,v,"Invalid Sec-WebSocket-Accept header");return}let O=y.headers["sec-websocket-protocol"],P=(t||"").split(/, */),M;if(!t&&O?M="Server sent a subprotocol but none was requested":t&&!O?M="Server sent no subprotocol":O&&!P.includes(O)&&(M="Server sent an invalid subprotocol"),M){be(n,v,M);return}O&&(n._protocol=O);let k=y.headers["sec-websocket-extensions"];if(k!==void 0){if(!d){be(n,v,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let L;try{L=Zu(k)}catch{be(n,v,"Invalid Sec-WebSocket-Extensions header");return}let j=Object.keys(L);if(j.length){if(j.length!==1||j[0]!==ze.extensionName){be(n,v,"Server indicated an extension that was not requested");return}try{d.accept(L[ze.extensionName])}catch{be(n,v,"Invalid Sec-WebSocket-Extensions header");return}n._extensions[ze.extensionName]=d}}n.setSocket(v,b,i.maxPayload)})}function Ur(n,e){n._readyState=z.CLOSING,n.emit("error",e),n.emitClose()}function tl(n){return n.path=n.socketPath,ho.connect(n)}function nl(n){return n.path=void 0,!n.servername&&n.servername!==""&&(n.servername=ho.isIP(n.host)?"":n.host),Ku.connect(n)}function be(n,e,t){n._readyState=z.CLOSING;let r=new Error(t);Error.captureStackTrace(r,be),e.setHeader?(e.abort(),e.socket&&!e.socket.destroyed&&e.socket.destroy(),e.once("abort",n.emitClose.bind(n)),n.emit("error",r)):(e.destroy(r),e.once("error",n.emit.bind(n,"error")),e.once("close",n.emitClose.bind(n)))}function Nr(n,e,t){if(e){let r=Qu(e).length;n._socket?n._sender._bufferedBytes+=r:n._bufferedAmount+=r}if(t){let r=new Error(`WebSocket is not open: readyState ${n.readyState} (${Ke[n.readyState]})`);t(r)}}function rl(n,e){let t=this[se];t._closeFrameReceived=!0,t._closeMessage=e,t._closeCode=n,t._socket[se]!==void 0&&(t._socket.removeListener("data",un),process.nextTick(po,t._socket),n===1005?t.close():t.close(n,e))}function il(){this[se]._socket.resume()}function sl(n){let e=this[se];e._socket[se]!==void 0&&(e._socket.removeListener("data",un),process.nextTick(po,e._socket),e.close(n[zu])),e.emit("error",n)}function lo(){this[se].emitClose()}function ol(n){this[se].emit("message",n)}function al(n){let e=this[se];e.pong(n,!e._isServer,fo),e.emit("ping",n)}function cl(n){this[se].emit("pong",n)}function po(n){n.resume()}function go(){let n=this[se];this.removeListener("close",go),this.removeListener("data",un),this.removeListener("end",mo),n._readyState=z.CLOSING;let e;!this._readableState.endEmitted&&!n._closeFrameReceived&&!n._receiver._writableState.errorEmitted&&(e=n._socket.read())!==null&&n._receiver.write(e),n._receiver.end(),this[se]=void 0,clearTimeout(n._closeTimer),n._receiver._writableState.finished||n._receiver._writableState.errorEmitted?n.emitClose():(n._receiver.on("error",lo),n._receiver.on("finish",lo))}function un(n){this[se]._receiver.write(n)||this.pause()}function mo(){let n=this[se];n._readyState=z.CLOSING,n._receiver.end(),this.end()}function vo(){let n=this[se];this.removeListener("error",vo),this.on("error",fo),n&&(n._readyState=z.CLOSING,this.destroy())}});var Co=R((_f,bo)=>{"use strict";var{Duplex:ul}=require("stream");function wo(n){n.emit("close")}function ll(){!this.destroyed&&this._writableState.finished&&this.destroy()}function So(n){this.removeListener("error",So),this.destroy(),this.listenerCount("error")===0&&this.emit("error",n)}function hl(n,e){let t=!0,r=!0;function i(){t&&n._socket.resume()}n.readyState===n.CONNECTING?n.once("open",function(){n._receiver.removeAllListeners("drain"),n._receiver.on("drain",i)}):(n._receiver.removeAllListeners("drain"),n._receiver.on("drain",i));let s=new ul({...e,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return n.on("message",function(a){s.push(a)||(t=!1,n._socket.pause())}),n.once("error",function(a){s.destroyed||(r=!1,s.destroy(a))}),n.once("close",function(){s.destroyed||s.push(null)}),s._destroy=function(o,a){if(n.readyState===n.CLOSED){a(o),process.nextTick(wo,s);return}let c=!1;n.once("error",function(l){c=!0,a(l)}),n.once("close",function(){c||a(o),process.nextTick(wo,s)}),r&&n.terminate()},s._final=function(o){if(n.readyState===n.CONNECTING){n.once("open",function(){s._final(o)});return}n._socket!==null&&(n._socket._writableState.finished?(o(),s._readableState.endEmitted&&s.destroy()):(n._socket.once("finish",function(){o()}),n.close()))},s._read=function(){(n.readyState===n.OPEN||n.readyState===n.CLOSING)&&!t&&(t=!0,n._receiver._writableState.needDrain||n._socket.resume())},s._write=function(o,a,c){if(n.readyState===n.CONNECTING){n.once("open",function(){s._write(o,a,c)});return}n.send(o,c)},s.on("end",ll),s.on("error",So),s}bo.exports=hl});var xo=R((vf,Ro)=>{"use strict";var dl=require("events"),ln=require("http"),pf=require("https"),gf=require("net"),mf=require("tls"),{createHash:fl}=require("crypto"),at=kt(),_l=Lr(),{format:pl,parse:gl}=kr(),{GUID:ml,kWebSocket:vl}=st(),yl=/^[+/0-9A-Za-z]{22}==$/,Eo=0,Oo=1,Mo=2,Br=class extends dl{constructor(e,t){if(super(),e={maxPayload:100*1024*1024,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,...e},e.port==null&&!e.server&&!e.noServer||e.port!=null&&(e.server||e.noServer)||e.server&&e.noServer)throw new TypeError('One and only one of the "port", "server", or "noServer" options must be specified');if(e.port!=null?(this._server=ln.createServer((r,i)=>{let s=ln.STATUS_CODES[426];i.writeHead(426,{"Content-Length":s.length,"Content-Type":"text/plain"}),i.end(s)}),this._server.listen(e.port,e.host,e.backlog,t)):e.server&&(this._server=e.server),this._server){let r=this.emit.bind(this,"connection");this._removeListeners=wl(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(i,s,o)=>{this.handleUpgrade(i,s,o,r)}})}e.perMessageDeflate===!0&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set),this.options=e,this._state=Eo}address(){if(this.options.noServer)throw new Error('The server is operating in "noServer" mode');return this._server?this._server.address():null}close(e){if(e&&this.once("close",e),this._state===Mo){process.nextTick(Ar,this);return}if(this._state===Oo)return;if(this._state=Oo,this.clients)for(let r of this.clients)r.terminate();let t=this._server;if(t&&(this._removeListeners(),this._removeListeners=this._server=null,this.options.port!=null)){t.close(Ar.bind(void 0,this));return}process.nextTick(Ar,this)}shouldHandle(e){if(this.options.path){let t=e.url.indexOf("?");if((t!==-1?e.url.slice(0,t):e.url)!==this.options.path)return!1}return!0}handleUpgrade(e,t,r,i){t.on("error",Fr);let s=e.headers["sec-websocket-key"]!==void 0?e.headers["sec-websocket-key"].trim():!1,o=+e.headers["sec-websocket-version"],a={};if(e.method!=="GET"||e.headers.upgrade.toLowerCase()!=="websocket"||!s||!yl.test(s)||o!==8&&o!==13||!this.shouldHandle(e))return qt(t,400);if(this.options.perMessageDeflate){let c=new at(this.options.perMessageDeflate,!0,this.options.maxPayload);try{let u=gl(e.headers["sec-websocket-extensions"]);u[at.extensionName]&&(c.accept(u[at.extensionName]),a[at.extensionName]=c)}catch{return qt(t,400)}}if(this.options.verifyClient){let c={origin:e.headers[`${o===8?"sec-websocket-origin":"origin"}`],secure:!!(e.socket.authorized||e.socket.encrypted),req:e};if(this.options.verifyClient.length===2){this.options.verifyClient(c,(u,l,d,g)=>{if(!u)return qt(t,l||401,d,g);this.completeUpgrade(s,a,e,t,r,i)});return}if(!this.options.verifyClient(c))return qt(t,401)}this.completeUpgrade(s,a,e,t,r,i)}completeUpgrade(e,t,r,i,s,o){if(!i.readable||!i.writable)return i.destroy();if(i[vl])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>Eo)return qt(i,503);let c=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${fl("sha1").update(e+ml).digest("base64")}`],u=new _l(null),l=r.headers["sec-websocket-protocol"];if(l&&(l=l.split(",").map(Sl),this.options.handleProtocols?l=this.options.handleProtocols(l,r):l=l[0],l&&(c.push(`Sec-WebSocket-Protocol: ${l}`),u._protocol=l)),t[at.extensionName]){let d=t[at.extensionName].params,g=pl({[at.extensionName]:[d]});c.push(`Sec-WebSocket-Extensions: ${g}`),u._extensions=t}this.emit("headers",c,r),i.write(c.concat(`\r
`).join(`\r
`)),i.removeListener("error",Fr),u.setSocket(i,s,this.options.maxPayload),this.clients&&(this.clients.add(u),u.on("close",()=>this.clients.delete(u))),o(u,r)}};Ro.exports=Br;function wl(n,e){for(let t of Object.keys(e))n.on(t,e[t]);return function(){for(let r of Object.keys(e))n.removeListener(r,e[r])}}function Ar(n){n._state=Mo,n.emit("close")}function Fr(){this.destroy()}function qt(n,e,t,r){n.writable&&(t=t||ln.STATUS_CODES[e],r={Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(t),...r},n.write(`HTTP/1.1 ${e} ${ln.STATUS_CODES[e]}\r
`+Object.keys(r).map(i=>`${i}: ${r[i]}`).join(`\r
`)+`\r
\r
`+t)),n.removeListener("error",Fr),n.destroy()}function Sl(n){return n.trim()}});var Po=R((yf,Do)=>{"use strict";var Ut=Lr();Ut.createWebSocketStream=Co();Ut.Server=xo();Ut.Receiver=Or();Ut.Sender=Rr();Do.exports=Ut});var ye=R(Nt=>{"use strict";var Kr,Vr,Wr;Object.defineProperty(Nt,"__esModule",{value:!0});Nt.ServerConnection=void 0;var ct=pe(),$r,Gr,Hr,zr;if(typeof window>"u"){let n=require("node-fetch");$r=(Kr=global.fetch)!==null&&Kr!==void 0?Kr:n,Hr=(Vr=global.Request)!==null&&Vr!==void 0?Vr:n.Request,Gr=(Wr=global.Headers)!==null&&Wr!==void 0?Wr:n.Headers,zr=Po()}else $r=fetch,Hr=Request,Gr=Headers,zr=WebSocket;var Io;(function(n){function e(s){return hn.makeSettings(s)}n.makeSettings=e;function t(s,o,a){return hn.handleRequest(s,o,a)}n.makeRequest=t;class r extends Error{constructor(o,a=`Invalid response: ${o.status} ${o.statusText}`,c=""){super(a),this.response=o,this.traceback=c}static async create(o){try{let a=await o.json();return a.traceback&&console.error(a.traceback),a.message?new r(o,a.message):new r(o)}catch(a){return console.debug(a),new r(o)}}}n.ResponseError=r;class i extends TypeError{constructor(o){super(o.message),this.stack=o.stack}}n.NetworkError=i})(Io=Nt.ServerConnection||(Nt.ServerConnection={}));var hn;(function(n){function e(i={}){let s=ct.PageConfig.getBaseUrl(),o=ct.PageConfig.getWsUrl(),a=ct.URLExt.normalize(i.baseUrl)||s,c=i.wsUrl;return!c&&a===s&&(c=o),!c&&a.indexOf("http")===0&&(c="ws"+a.slice(4)),c=c??o,Object.assign(Object.assign({init:{cache:"no-store",credentials:"same-origin"},fetch:$r,Headers:Gr,Request:Hr,WebSocket:zr,token:ct.PageConfig.getToken(),appUrl:ct.PageConfig.getOption("appUrl"),appendToken:typeof window>"u"||process.env.JEST_WORKER_ID!==void 0||ct.URLExt.getHostName(s)!==ct.URLExt.getHostName(c)},i),{baseUrl:a,wsUrl:c})}n.makeSettings=e;function t(i,s,o){var a;if(i.indexOf(o.baseUrl)!==0)throw new Error("Can only be used for notebook server requests");((a=s.cache)!==null&&a!==void 0?a:o.init.cache)==="no-store"&&(i+=(/\?/.test(i)?"&":"?")+new Date().getTime());let u=new o.Request(i,Object.assign(Object.assign({},o.init),s)),l=!1;if(o.token&&(l=!0,u.headers.append("Authorization",`token ${o.token}`)),typeof document<"u"&&document?.cookie){let d=r("_xsrf");d!==void 0&&(l=!0,u.headers.append("X-XSRFToken",d))}return!u.headers.has("Content-Type")&&l&&u.headers.set("Content-Type","application/json"),o.fetch.call(null,u).catch(d=>{throw new Io.NetworkError(d)})}n.handleRequest=t;function r(i){let s=document.cookie.match("\\b"+i+"=([^;]*)\\b");return s?.[1]}})(hn||(hn={}))});var dn=R(Je=>{"use strict";Object.defineProperty(Je,"__esModule",{value:!0});Je.validateModels=Je.validateModel=Je.validateMessage=void 0;var ut=Rt(),ko=["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;eTo(e))}Je.validateModels=Ml});var _n=R(H=>{"use strict";Object.defineProperty(H,"__esModule",{value:!0});H.getKernelModel=H.shutdownKernel=H.interruptKernel=H.restartKernel=H.startNew=H.listRunning=H.KERNEL_SERVICE_URL=void 0;var Q=ye(),pt=pe(),fn=dn();H.KERNEL_SERVICE_URL="api/kernels";async function Rl(n=Q.ServerConnection.makeSettings()){let e=pt.URLExt.join(n.baseUrl,H.KERNEL_SERVICE_URL),t=await Q.ServerConnection.makeRequest(e,{},n);if(t.status!==200)throw await Q.ServerConnection.ResponseError.create(t);let r=await t.json();return fn.validateModels(r),r}H.listRunning=Rl;async function xl(n={},e=Q.ServerConnection.makeSettings()){let t=pt.URLExt.join(e.baseUrl,H.KERNEL_SERVICE_URL),r={method:"POST",body:JSON.stringify(n)},i=await Q.ServerConnection.makeRequest(t,r,e);if(i.status!==201)throw await Q.ServerConnection.ResponseError.create(i);let s=await i.json();return fn.validateModel(s),s}H.startNew=xl;async function Dl(n,e=Q.ServerConnection.makeSettings()){let t=pt.URLExt.join(e.baseUrl,H.KERNEL_SERVICE_URL,encodeURIComponent(n),"restart"),r={method:"POST"},i=await Q.ServerConnection.makeRequest(t,r,e);if(i.status!==200)throw await Q.ServerConnection.ResponseError.create(i);let s=await i.json();fn.validateModel(s)}H.restartKernel=Dl;async function Pl(n,e=Q.ServerConnection.makeSettings()){let t=pt.URLExt.join(e.baseUrl,H.KERNEL_SERVICE_URL,encodeURIComponent(n),"interrupt"),r={method:"POST"},i=await Q.ServerConnection.makeRequest(t,r,e);if(i.status!==204)throw await Q.ServerConnection.ResponseError.create(i)}H.interruptKernel=Pl;async function Il(n,e=Q.ServerConnection.makeSettings()){let t=pt.URLExt.join(e.baseUrl,H.KERNEL_SERVICE_URL,encodeURIComponent(n)),r={method:"DELETE"},i=await Q.ServerConnection.makeRequest(t,r,e);if(i.status===404){let s=`The kernel "${n}" does not exist on the server`;console.warn(s)}else if(i.status!==204)throw await Q.ServerConnection.ResponseError.create(i)}H.shutdownKernel=Il;async function kl(n,e=Q.ServerConnection.makeSettings()){let t=pt.URLExt.join(e.baseUrl,H.KERNEL_SERVICE_URL,encodeURIComponent(n)),r=await Q.ServerConnection.makeRequest(t,{},e);if(r.status===404)return;if(r.status!==200)throw await Q.ServerConnection.ResponseError.create(r);let i=await r.json();return fn.validateModel(i),i}H.getKernelModel=kl});var Lt=R((pn,jo)=>{(function(n,e){typeof pn=="object"&&typeof jo<"u"?e(pn,Ee(),ie()):typeof define=="function"&&define.amd?define(["exports","@lumino/coreutils","@lumino/signaling"],e):(n=typeof globalThis<"u"?globalThis:n||self,e(n.lumino_polling={},n.lumino_coreutils,n.lumino_signaling))})(pn,function(n,e,t){"use strict";var r=function(v,b){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(x,O){x.__proto__=O}||function(x,O){for(var P in O)Object.prototype.hasOwnProperty.call(O,P)&&(x[P]=O[P])},r(v,b)};function i(v,b){if(typeof b!="function"&&b!==null)throw new TypeError("Class extends value "+String(b)+" is not a constructor or null");r(v,b);function x(){this.constructor=v}v.prototype=b===null?Object.create(b):(x.prototype=b.prototype,new x)}var s=function(){return s=Object.assign||function(b){for(var x,O=1,P=arguments.length;O0&&M[M.length-1])&&(w[0]===6||w[0]===2)){x=0;continue}if(w[0]===3&&(!M||w[1]>M[0]&&w[1]P)&&O!==v.NEVER)throw new Error("Poll interval must be between 0 and max");if(P>v.MAX_INTERVAL&&P!==v.NEVER)throw new Error("Max interval must be less than "+v.MAX_INTERVAL);this._frequency={backoff:x,interval:O,max:P}}},enumerable:!0,configurable:!0}),Object.defineProperty(v.prototype,"isDisposed",{get:function(){return this.state.phase==="disposed"},enumerable:!0,configurable:!0}),Object.defineProperty(v.prototype,"standby",{get:function(){return this._standby},set:function(b){this.isDisposed||this.standby===b||(this._standby=b)},enumerable:!0,configurable:!0}),Object.defineProperty(v.prototype,"state",{get:function(){return this._state},enumerable:!0,configurable:!0}),Object.defineProperty(v.prototype,"tick",{get:function(){return this._tick.promise},enumerable:!0,configurable:!0}),Object.defineProperty(v.prototype,"ticked",{get:function(){return this._ticked},enumerable:!0,configurable:!0}),v.prototype.dispose=function(){this.isDisposed||(this._state=s(s({},l.DISPOSED_STATE),{timestamp:new Date().getTime()}),this._tick.promise.catch(function(b){}),this._tick.reject(new Error("Poll ("+this.name+") is disposed.")),this._disposed.emit(void 0),t.Signal.clearData(this))},v.prototype.refresh=function(){return this.schedule({cancel:function(b){var x=b.phase;return x==="refreshed"},interval:v.IMMEDIATE,phase:"refreshed"})},v.prototype.schedule=function(b){return b===void 0&&(b={}),o(this,void 0,void 0,function(){var x,O,P,M,k,L=this;return a(this,function(j){switch(j.label){case 0:return this.isDisposed?[2]:b.cancel&&b.cancel(this.state)?[2]:(x=this.state,O=this._tick,P=new e.PromiseDelegate,M=s({interval:this.frequency.interval,payload:null,phase:"standby",timestamp:new Date().getTime()},b),this._state=M,this._tick=P,x.interval===v.IMMEDIATE?u(this._timeout):clearTimeout(this._timeout),this._ticked.emit(this.state),O.resolve(this),[4,O.promise]);case 1:return j.sent(),k=function(){L.isDisposed||L.tick!==P.promise||L._execute()},this._timeout=M.interval===v.IMMEDIATE?c(k):M.interval===v.NEVER?-1:setTimeout(k,M.interval),[2]}})})},v.prototype.start=function(){return this.schedule({cancel:function(b){var x=b.phase;return x!=="constructed"&&x!=="standby"&&x!=="stopped"},interval:v.IMMEDIATE,phase:"started"})},v.prototype.stop=function(){return this.schedule({cancel:function(b){var x=b.phase;return x==="stopped"},interval:v.NEVER,phase:"stopped"})},v.prototype._execute=function(){var b=this,x=typeof this.standby=="function"?this.standby():this.standby;if(x=x==="never"?!1:x==="when-hidden"?!!(typeof document<"u"&&document&&document.hidden):x,x){this.schedule();return}var O=this.tick;this._factory(this.state).then(function(P){b.isDisposed||b.tick!==O||b.schedule({payload:P,phase:b.state.phase==="rejected"?"reconnected":"resolved"})}).catch(function(P){b.isDisposed||b.tick!==O||b.schedule({interval:l.sleep(b.frequency,b.state),payload:P,phase:"rejected"})})},v}(),function(v){v.IMMEDIATE=0,v.MAX_INTERVAL=2147483647,v.NEVER=1/0}(n.Poll||(n.Poll={}));var l;(function(v){v.DEFAULT_BACKOFF=3,v.DEFAULT_FREQUENCY={backoff:!0,interval:1e3,max:30*1e3},v.DEFAULT_NAME="unknown",v.DEFAULT_STANDBY="when-hidden",v.DEFAULT_STATE={interval:n.Poll.NEVER,payload:null,phase:"constructed",timestamp:new Date(0).getTime()},v.DISPOSED_STATE={interval:n.Poll.NEVER,payload:null,phase:"disposed",timestamp:new Date(0).getTime()};function b(O,P){return O=Math.ceil(O),P=Math.floor(P),Math.floor(Math.random()*(P-O+1))+O}function x(O,P){var M=O.backoff,k=O.interval,L=O.max;if(k===n.Poll.NEVER)return k;var j=M===!0?v.DEFAULT_BACKOFF:M===!1?1:M,w=b(k,P.interval*j);return Math.min(L,w)}v.sleep=x})(l||(l={}));var d=function(){function v(b,x){var O=this;x===void 0&&(x=500),this.payload=null,this.limit=x,this.poll=new n.Poll({auto:!1,factory:function(){return o(O,void 0,void 0,function(){return a(this,function(P){switch(P.label){case 0:return[4,b()];case 1:return[2,P.sent()]}})})},frequency:{backoff:!1,interval:n.Poll.NEVER,max:n.Poll.NEVER},standby:"never"}),this.payload=new e.PromiseDelegate,this.poll.ticked.connect(function(P,M){var k=O.payload;if(M.phase==="resolved"){O.payload=new e.PromiseDelegate,k.resolve(M.payload);return}if(M.phase==="rejected"||M.phase==="stopped"){O.payload=new e.PromiseDelegate,k.promise.catch(function(L){}),k.reject(M.payload);return}},this)}return Object.defineProperty(v.prototype,"isDisposed",{get:function(){return this.payload===null},enumerable:!0,configurable:!0}),v.prototype.dispose=function(){this.isDisposed||(this.payload=null,this.poll.dispose())},v.prototype.stop=function(){return o(this,void 0,void 0,function(){return a(this,function(b){return[2,this.poll.stop()]})})},v}(),g=function(v){i(b,v);function b(){return v!==null&&v.apply(this,arguments)||this}return b.prototype.invoke=function(){return this.poll.schedule({interval:this.limit,phase:"invoked"}),this.payload.promise},b}(d),y=function(v){i(b,v);function b(x,O){var P=v.call(this,x,typeof O=="number"?O:O&&O.limit)||this,M="leading";return typeof O!="number"&&(O=O||{},M="edge"in O?O.edge:M),P._interval=M==="trailing"?P.limit:n.Poll.IMMEDIATE,P}return b.prototype.invoke=function(){return this.poll.state.phase!=="invoked"&&this.poll.schedule({interval:this._interval,phase:"invoked"}),this.payload.promise},b}(d);n.Debouncer=g,n.RateLimiter=d,n.Throttler=y,Object.defineProperty(n,"__esModule",{value:!0})})});var At=R(gn=>{"use strict";Object.defineProperty(gn,"__esModule",{value:!0});gn.BaseManager=void 0;var qo=ie(),Tl=ye(),Jr=class{constructor(e){var t;this._isDisposed=!1,this._disposed=new qo.Signal(this),this.serverSettings=(t=e.serverSettings)!==null&&t!==void 0?t:Tl.ServerConnection.makeSettings()}get disposed(){return this._disposed}get isDisposed(){return this._isDisposed}dispose(){this.isDisposed||(this._disposed.emit(void 0),qo.Signal.clearData(this))}};gn.BaseManager=Jr});var Yr=R((mn,Uo)=>{(function(n,e){typeof mn=="object"&&typeof Uo<"u"?e(mn,et(),ie()):typeof define=="function"&&define.amd?define(["exports","@lumino/algorithm","@lumino/signaling"],e):(n=typeof globalThis<"u"?globalThis:n||self,e(n.lumino_disposable={},n.lumino_algorithm,n.lumino_signaling))})(mn,function(n,e,t){"use strict";var r=function(a,c){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(u,l){u.__proto__=l}||function(u,l){for(var d in l)Object.prototype.hasOwnProperty.call(l,d)&&(u[d]=l[d])},r(a,c)};function i(a,c){if(typeof c!="function"&&c!==null)throw new TypeError("Class extends value "+String(c)+" is not a constructor or null");r(a,c);function u(){this.constructor=a}a.prototype=c===null?Object.create(c):(u.prototype=c.prototype,new u)}var s=function(){function a(c){this._fn=c}return Object.defineProperty(a.prototype,"isDisposed",{get:function(){return!this._fn},enumerable:!0,configurable:!0}),a.prototype.dispose=function(){if(this._fn){var c=this._fn;this._fn=null,c()}},a}(),o=function(a){i(c,a);function c(){var u=a!==null&&a.apply(this,arguments)||this;return u._disposed=new t.Signal(u),u}return Object.defineProperty(c.prototype,"disposed",{get:function(){return this._disposed},enumerable:!0,configurable:!0}),c.prototype.dispose=function(){this.isDisposed||(a.prototype.dispose.call(this),this._disposed.emit(void 0),t.Signal.clearData(this))},c}(s);n.DisposableSet=function(){function a(){this._isDisposed=!1,this._items=new Set}return Object.defineProperty(a.prototype,"isDisposed",{get:function(){return this._isDisposed},enumerable:!0,configurable:!0}),a.prototype.dispose=function(){this._isDisposed||(this._isDisposed=!0,this._items.forEach(function(c){c.dispose()}),this._items.clear())},a.prototype.contains=function(c){return this._items.has(c)},a.prototype.add=function(c){this._items.add(c)},a.prototype.remove=function(c){this._items.delete(c)},a.prototype.clear=function(){this._items.clear()},a}(),function(a){function c(u){var l=new a;return e.each(u,function(d){l.add(d)}),l}a.from=c}(n.DisposableSet||(n.DisposableSet={})),n.ObservableDisposableSet=function(a){i(c,a);function c(){var u=a!==null&&a.apply(this,arguments)||this;return u._disposed=new t.Signal(u),u}return Object.defineProperty(c.prototype,"disposed",{get:function(){return this._disposed},enumerable:!0,configurable:!0}),c.prototype.dispose=function(){this.isDisposed||(a.prototype.dispose.call(this),this._disposed.emit(void 0),t.Signal.clearData(this))},c}(n.DisposableSet),function(a){function c(u){var l=new a;return e.each(u,function(d){l.add(d)}),l}a.from=c}(n.ObservableDisposableSet||(n.ObservableDisposableSet={})),n.DisposableDelegate=s,n.ObservableDisposableDelegate=o,Object.defineProperty(n,"__esModule",{value:!0})})});var No=R(je=>{"use strict";var jl=je&&je.__createBinding||(Object.create?function(n,e,t,r){r===void 0&&(r=t),Object.defineProperty(n,r,{enumerable:!0,get:function(){return e[t]}})}:function(n,e,t,r){r===void 0&&(r=t),n[r]=e[t]}),ql=je&&je.__setModuleDefault||(Object.create?function(n,e){Object.defineProperty(n,"default",{enumerable:!0,value:e})}:function(n,e){n.default=e}),Ul=je&&je.__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)&&jl(e,n,t);return ql(e,n),e};Object.defineProperty(je,"__esModule",{value:!0});je.CommHandler=void 0;var Nl=Yr(),vn=Ul(xt()),Xr=class extends Nl.DisposableDelegate{constructor(e,t,r,i){super(i),this._target="",this._id="",this._id=t,this._target=e,this._kernel=r}get commId(){return this._id}get targetName(){return this._target}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,r=[]){if(this.isDisposed||this._kernel.isDisposed)throw new Error("Cannot open");let i=vn.createMessage({msgType:"comm_open",channel:"shell",username:this._kernel.username,session:this._kernel.clientId,content:{comm_id:this._id,target_name:this._target,data:e??{}},metadata:t,buffers:r});return this._kernel.sendShellMessage(i,!1,!0)}send(e,t,r=[],i=!0){if(this.isDisposed||this._kernel.isDisposed)throw new Error("Cannot send");let s=vn.createMessage({msgType:"comm_msg",channel:"shell",username:this._kernel.username,session:this._kernel.clientId,content:{comm_id:this._id,data:e},metadata:t,buffers:r});return this._kernel.sendShellMessage(s,!1,i)}close(e,t,r=[]){if(this.isDisposed||this._kernel.isDisposed)throw new Error("Cannot close");let i=vn.createMessage({msgType:"comm_close",channel:"shell",username:this._kernel.username,session:this._kernel.clientId,content:{comm_id:this._id,data:e??{}},metadata:t,buffers:r}),s=this._kernel.sendShellMessage(i,!1,!0),o=this._onClose;if(o){let a=vn.createMessage({msgType:"comm_close",channel:"iopub",username:this._kernel.username,session:this._kernel.clientId,content:{comm_id:this._id,data:e??{}},metadata:t,buffers:r});o(a)}return this.dispose(),s}};je.CommHandler=Xr});var Ao=R(ge=>{"use strict";var Ll=ge&&ge.__createBinding||(Object.create?function(n,e,t,r){r===void 0&&(r=t),Object.defineProperty(n,r,{enumerable:!0,get:function(){return e[t]}})}:function(n,e,t,r){r===void 0&&(r=t),n[r]=e[t]}),Al=ge&&ge.__setModuleDefault||(Object.create?function(n,e){Object.defineProperty(n,"default",{enumerable:!0,value:e})}:function(n,e){n.default=e}),Bl=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)&&Ll(e,n,t);return Al(e,n),e};Object.defineProperty(ge,"__esModule",{value:!0});ge.KernelShellFutureHandler=ge.KernelControlFutureHandler=ge.KernelFutureHandler=void 0;var Lo=Ee(),Fl=Yr(),Kl=Bl(xt()),Bt=class extends Fl.DisposableDelegate{constructor(e,t,r,i,s){super(e),this._status=0,this._stdin=te.noOp,this._iopub=te.noOp,this._reply=te.noOp,this._done=new Lo.PromiseDelegate,this._hooks=new te.HookList,this._disposeOnDone=!0,this._msg=t,r||this._setFlag(te.KernelFutureFlag.GotReply),this._disposeOnDone=i,this._kernel=s}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){this._kernel.sendInputReply(e)}dispose(){this._stdin=te.noOp,this._iopub=te.noOp,this._reply=te.noOp,this._hooks=null,this._testFlag(te.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(te.KernelFutureFlag.GotReply),this._testFlag(te.KernelFutureFlag.GotIdle)&&this._handleDone()}async _handleStdin(e){let t=this._stdin;t&&await t(e)}async _handleIOPub(e){let t=await this._hooks.process(e),r=this._iopub;t&&r&&await r(e),Kl.isStatusMsg(e)&&e.content.execution_state==="idle"&&(this._setFlag(te.KernelFutureFlag.GotIdle),this._testFlag(te.KernelFutureFlag.GotReply)&&this._handleDone())}_handleDone(){this._testFlag(te.KernelFutureFlag.IsDone)||(this._setFlag(te.KernelFutureFlag.IsDone),this._done.resolve(this._replyMsg),this._disposeOnDone&&this.dispose())}_testFlag(e){return(this._status&e)!==0}_setFlag(e){this._status|=e}};ge.KernelFutureHandler=Bt;var Zr=class extends Bt{};ge.KernelControlFutureHandler=Zr;var Qr=class extends Bt{};ge.KernelShellFutureHandler=Qr;var te;(function(n){n.noOp=()=>{};let e=(()=>typeof requestAnimationFrame=="function"?requestAnimationFrame:setImmediate)();class t{constructor(){this._hooks=[]}add(s){this.remove(s),this._hooks.push(s)}remove(s){let o=this._hooks.indexOf(s);o>=0&&(this._hooks[o]=null,this._scheduleCompact())}async process(s){await this._processing;let o=new Lo.PromiseDelegate;this._processing=o.promise;let a;for(let c=this._hooks.length-1;c>=0;c--){let u=this._hooks[c];if(u!==null){try{a=await u(s)}catch(l){a=!0,console.error(l)}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 s=0;for(let o=0,a=this._hooks.length;o{"use strict";Object.defineProperty(gt,"__esModule",{value:!0});gt.serialize=gt.deserialize=void 0;function Vl(n){let e;return typeof n=="string"?e=JSON.parse(n):e=$l(n),e}gt.deserialize=Vl;function Wl(n){var e;let t;return!((e=n.buffers)===null||e===void 0)&&e.length?t=Gl(n):t=JSON.stringify(n),t}gt.serialize=Wl;function $l(n){let e=new DataView(n),t=e.getUint32(0),r=[];if(t<2)throw new Error("Invalid incoming Kernel Message");for(let o=1;o<=t;o++)r.push(e.getUint32(o*4));let i=new Uint8Array(n.slice(r[0],r[1])),s=JSON.parse(new TextDecoder("utf8").decode(i));s.buffers=[];for(let o=1;o{"use strict";Object.defineProperty(Fo,"__esModule",{value:!0})});var Wo=R(mt=>{"use strict";Object.defineProperty(mt,"__esModule",{value:!0});mt.validateSpecModels=mt.validateSpecModel=void 0;var lt=Rt();function Vo(n){let e=n.spec;if(!e)throw new Error("Invalid kernel spec");lt.validateProperty(n,"name","string"),lt.validateProperty(n,"resources","object"),lt.validateProperty(e,"language","string"),lt.validateProperty(e,"display_name","string"),lt.validateProperty(e,"argv","array");let t=null;e.hasOwnProperty("metadata")&&(lt.validateProperty(e,"metadata","object"),t=e.metadata);let r=null;return e.hasOwnProperty("env")&&(lt.validateProperty(e,"env","object"),r=e.env),{name:n.name,resources:n.resources,language:e.language,display_name:e.display_name,argv:e.argv,metadata:t,env:r}}mt.validateSpecModel=Vo;function Hl(n){if(!n.hasOwnProperty("kernelspecs"))throw new Error("No kernelspecs found");let e=Object.keys(n.kernelspecs),t=Object.create(null),r=n.default;for(let i=0;i{"use strict";Object.defineProperty(yn,"__esModule",{value:!0});yn.getSpecs=void 0;var ei=ye(),zl=Wo(),Jl=pe(),Yl="api/kernelspecs";async function Xl(n=ei.ServerConnection.makeSettings()){let e=Jl.URLExt.join(n.baseUrl,Yl),t=await ei.ServerConnection.makeRequest(e,{},n);if(t.status!==200)throw await ei.ServerConnection.ResponseError.create(t);let r=await t.json();return zl.validateSpecModels(r)}yn.getSpecs=Xl});var Go=R(qe=>{"use strict";var Zl=qe&&qe.__createBinding||(Object.create?function(n,e,t,r){r===void 0&&(r=t),Object.defineProperty(n,r,{enumerable:!0,get:function(){return e[t]}})}:function(n,e,t,r){r===void 0&&(r=t),n[r]=e[t]}),Ql=qe&&qe.__setModuleDefault||(Object.create?function(n,e){Object.defineProperty(n,"default",{enumerable:!0,value:e})}:function(n,e){n.default=e}),eh=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)&&Zl(e,n,t);return Ql(e,n),e};Object.defineProperty(qe,"__esModule",{value:!0});qe.KernelSpecManager=void 0;var th=Ee(),nh=Lt(),$o=ie(),rh=eh(ti()),ih=At(),ni=class extends ih.BaseManager{constructor(e={}){var t;super(e),this._isReady=!1,this._connectionFailure=new $o.Signal(this),this._specs=null,this._specsChanged=new $o.Signal(this),this._ready=Promise.all([this.requestSpecs()]).then(r=>{}).catch(r=>{}).then(()=>{this.isDisposed||(this._isReady=!0)}),this._pollSpecs=new nh.Poll({auto:!1,factory:()=>this.requestSpecs(),frequency:{interval:61*1e3,backoff:!0,max:300*1e3},name:"@jupyterlab/services:KernelSpecManager#specs",standby:(t=e.standby)!==null&&t!==void 0?t:"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 rh.getSpecs(this.serverSettings);this.isDisposed||th.JSONExt.deepEqual(e,this._specs)||(this._specs=e,this._specsChanged.emit(e))}};qe.KernelSpecManager=ni});var wn=R(le=>{"use strict";var Ho=le&&le.__createBinding||(Object.create?function(n,e,t,r){r===void 0&&(r=t),Object.defineProperty(n,r,{enumerable:!0,get:function(){return e[t]}})}:function(n,e,t,r){r===void 0&&(r=t),n[r]=e[t]}),sh=le&&le.__setModuleDefault||(Object.create?function(n,e){Object.defineProperty(n,"default",{enumerable:!0,value:e})}:function(n,e){n.default=e}),zo=le&&le.__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)&&Ho(e,n,t);return sh(e,n),e},oh=le&&le.__exportStar||function(n,e){for(var t in n)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&Ho(e,n,t)};Object.defineProperty(le,"__esModule",{value:!0});le.KernelSpecAPI=le.KernelSpec=void 0;var ah=zo(Ko());le.KernelSpec=ah;var ch=zo(ti());le.KernelSpecAPI=ch;oh(Go(),le)});var Zo=R(Ue=>{"use strict";var uh=Ue&&Ue.__createBinding||(Object.create?function(n,e,t,r){r===void 0&&(r=t),Object.defineProperty(n,r,{enumerable:!0,get:function(){return e[t]}})}:function(n,e,t,r){r===void 0&&(r=t),n[r]=e[t]}),lh=Ue&&Ue.__setModuleDefault||(Object.create?function(n,e){Object.defineProperty(n,"default",{enumerable:!0,value:e})}:function(n,e){n.default=e}),bn=Ue&&Ue.__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)&&uh(e,n,t);return lh(e,n),e};Object.defineProperty(Ue,"__esModule",{value:!0});Ue.KernelConnection=void 0;var Jo=pe(),Ye=Ee(),ht=ie(),hh=Ge(),Yo=No(),we=bn(xt()),Xo=Ao(),ri=bn(Bo()),dh=bn(dn()),fh=wn(),Sn=bn(_n()),_h=3e3,vt="_RESTARTING_",ph="",ii=class n{constructor(e){var t,r,i,s;this._createSocket=()=>{this._errorIfDisposed(),this._clearSocket(),this._updateConnectionStatus("connecting");let o=this.serverSettings,a=Jo.URLExt.join(o.wsUrl,Sn.KERNEL_SERVICE_URL,encodeURIComponent(this._id)),c=a.replace(/^((?:\w+:)?\/\/)(?:[^@\/]+@)/,"$1"),u=Jo.URLExt.join(a,"channels?session_id="+encodeURIComponent(this._clientId)),l=o.token;o.appendToken&&l!==""&&(u=u+`&token=${encodeURIComponent(l)}`),this._ws=new o.WebSocket(u),this._ws.binaryType="arraybuffer",this._ws.onmessage=this._onWSMessage,this._ws.onopen=this._onWSOpen,this._ws.onclose=this._onWSClose,this._ws.onerror=this._onWSClose},this._onWSOpen=o=>{this._updateConnectionStatus("connected")},this._onWSMessage=o=>{let a;try{a=ri.deserialize(o.data),dh.validateMessage(a)}catch(c){throw c.message=`Kernel message validation error: ${c.message}`,c}this._kernelSession=a.header.session,this._msgChain=this._msgChain.then(()=>this._handleMessage(a)).catch(c=>{c.message.startsWith("Canceled future for ")&&console.error(c)}),this._anyMessage.emit({msg:a,direction:"recv"})},this._onWSClose=o=>{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._futures=new Map,this._comms=new Map,this._targetRegistry=Object.create(null),this._info=new Ye.PromiseDelegate,this._pendingMessages=[],this._statusChanged=new ht.Signal(this),this._connectionStatusChanged=new ht.Signal(this),this._disposed=new ht.Signal(this),this._iopubMessage=new ht.Signal(this),this._anyMessage=new ht.Signal(this),this._unhandledMessage=new ht.Signal(this),this._displayIdToParentIds=new Map,this._msgIdToDisplayIds=new Map,this._msgChain=Promise.resolve(),this._noOp=()=>{},this._name=e.model.name,this._id=e.model.id,this.serverSettings=(t=e.serverSettings)!==null&&t!==void 0?t:hh.ServerConnection.makeSettings(),this._clientId=(r=e.clientId)!==null&&r!==void 0?r:Ye.UUID.uuid4(),this._username=(i=e.username)!==null&&i!==void 0?i:"",this.handleComms=(s=e.handleComms)!==null&&s!==void 0?s:!0,this._createSocket()}get disposed(){return this._disposed}get statusChanged(){return this._statusChanged}get connectionStatusChanged(){return this._connectionStatusChanged}get iopubMessage(){return this._iopubMessage}get unhandledMessage(){return this._unhandledMessage}get model(){return{id:this.id,name:this.name}}get anyMessage(){return this._anyMessage}get id(){return this._id}get name(){return this._name}get username(){return this._username}get clientId(){return this._clientId}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=fh.KernelSpecAPI.getSpecs(this.serverSettings).then(e=>e.kernelspecs[this._name]),this._specPromise)}clone(e={}){return new n(Object.assign({model:this.model,username:this.username,serverSettings:this.serverSettings,handleComms:!1},e))}dispose(){this.isDisposed||(this._isDisposed=!0,this._disposed.emit(),this._updateConnectionStatus("disconnected"),this._clearKernelState(),this._pendingMessages=[],this._clearSocket(),ht.Signal.clearData(this))}sendShellMessage(e,t=!1,r=!0){return this._sendKernelShellControl(Xo.KernelShellFutureHandler,e,t,r)}sendControlMessage(e,t=!1,r=!0){return this._sendKernelShellControl(Xo.KernelControlFutureHandler,e,t,r)}_sendKernelShellControl(e,t,r=!1,i=!0){this._sendMessage(t),this._anyMessage.emit({msg:t,direction:"send"});let s=new e(()=>{let o=t.header.msg_id;this._futures.delete(o);let a=this._msgIdToDisplayIds.get(o);a&&(a.forEach(c=>{let u=this._displayIdToParentIds.get(c);if(u){let l=u.indexOf(o);if(l===-1)return;u.length===1?this._displayIdToParentIds.delete(c):(u.splice(l,1),this._displayIdToParentIds.set(c,u))}}),this._msgIdToDisplayIds.delete(o))},t,r,i,this);return this._futures.set(t.header.msg_id,s),s}_sendMessage(e,t=!0){if(this.status==="dead")throw new Error("Kernel is dead");if((this._kernelSession===ph||this._kernelSession===vt)&&we.isInfoRequestMsg(e))if(this.connectionStatus==="connected"){this._ws.send(ri.serialize(e));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!==vt)this._ws.send(ri.serialize(e));else if(t)this._pendingMessages.push(e);else throw new Error("Could not send message")}async interrupt(){if(this.status==="dead")throw new Error("Kernel is dead");return Sn.interruptKernel(this.id,this.serverSettings)}async restart(){if(this.status==="dead")throw new Error("Kernel is dead");this._updateStatus("restarting"),this._clearKernelState(),this._kernelSession=vt,await Sn.restartKernel(this.id,this.serverSettings),await this.reconnect()}reconnect(){this._errorIfDisposed();let e=new Ye.PromiseDelegate,t=(r,i)=>{i==="connected"?(e.resolve(),this.connectionStatusChanged.disconnect(t,this)):i==="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 Sn.shutdownKernel(this.id,this.serverSettings),this.handleShutdown()}handleShutdown(){this._updateStatus("dead"),this.dispose()}async requestKernelInfo(){let e=we.createMessage({msgType:"kernel_info_request",channel:"shell",username:this._username,session:this._clientId,content:{}}),t;try{t=await Oe.handleShellMessage(this,e)}catch(r){if(this.isDisposed)return;throw r}if(this._errorIfDisposed(),!!t)return t.content.status===void 0&&(t.content.status="ok"),t.content.status!=="ok"?(this._info.reject("Kernel info reply errored"),t):(this._info.resolve(t.content),this._kernelSession=t.header.session,t)}requestComplete(e){let t=we.createMessage({msgType:"complete_request",channel:"shell",username:this._username,session:this._clientId,content:e});return Oe.handleShellMessage(this,t)}requestInspect(e){let t=we.createMessage({msgType:"inspect_request",channel:"shell",username:this._username,session:this._clientId,content:e});return Oe.handleShellMessage(this,t)}requestHistory(e){let t=we.createMessage({msgType:"history_request",channel:"shell",username:this._username,session:this._clientId,content:e});return Oe.handleShellMessage(this,t)}requestExecute(e,t=!0,r){let i={silent:!1,store_history:!0,user_expressions:{},allow_stdin:!0,stop_on_error:!1},s=we.createMessage({msgType:"execute_request",channel:"shell",username:this._username,session:this._clientId,content:Object.assign(Object.assign({},i),e),metadata:r});return this.sendShellMessage(s,!0,t)}requestDebug(e,t=!0){let r=we.createMessage({msgType:"debug_request",channel:"control",username:this._username,session:this._clientId,content:e});return this.sendControlMessage(r,!0,t)}requestIsComplete(e){let t=we.createMessage({msgType:"is_complete_request",channel:"shell",username:this._username,session:this._clientId,content:e});return Oe.handleShellMessage(this,t)}requestCommInfo(e){let t=we.createMessage({msgType:"comm_info_request",channel:"shell",username:this._username,session:this._clientId,content:e});return Oe.handleShellMessage(this,t)}sendInputReply(e){let t=we.createMessage({msgType:"input_reply",channel:"stdin",username:this._username,session:this._clientId,content:e});this._sendMessage(t),this._anyMessage.emit({msg:t,direction:"send"})}createComm(e,t=Ye.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 r=new Yo.CommHandler(e,t,this,()=>{this._unregisterComm(t)});return this._comms.set(t,r),r}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 r;let i=(r=this._futures)===null||r===void 0?void 0:r.get(e);i&&i.registerMessageHook(t)}removeMessageHook(e,t){var r;let i=(r=this._futures)===null||r===void 0?void 0:r.get(e);i&&i.removeMessageHook(t)}async _handleDisplayId(e,t){var r,i;let s=t.parent_header.msg_id,o=this._displayIdToParentIds.get(e);if(o){let c={header:Ye.JSONExt.deepCopy(t.header),parent_header:Ye.JSONExt.deepCopy(t.parent_header),metadata:Ye.JSONExt.deepCopy(t.metadata),content:Ye.JSONExt.deepCopy(t.content),channel:t.channel,buffers:t.buffers?t.buffers.slice():[]};c.header.msg_type="update_display_data",await Promise.all(o.map(async u=>{let l=this._futures&&this._futures.get(u);l&&await l.handleMsg(c)}))}if(t.header.msg_type==="update_display_data")return!0;o=(r=this._displayIdToParentIds.get(e))!==null&&r!==void 0?r:[],o.indexOf(s)===-1&&o.push(s),this._displayIdToParentIds.set(e,o);let a=(i=this._msgIdToDisplayIds.get(s))!==null&&i!==void 0?i:[];return a.indexOf(s)===-1&&a.push(s),this._msgIdToDisplayIds.set(s,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,Oe.logKernelStatus(this),this._statusChanged.emit(e),e==="dead"&&this.dispose())}_sendPending(){for(;this.connectionStatus==="connected"&&this._kernelSession!==vt&&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,r=new Yo.CommHandler(t.target_name,t.comm_id,this,()=>{this._unregisterComm(t.comm_id)});this._comms.set(t.comm_id,r);try{await(await Oe.loadObject(t.target_name,t.target_module,this._targetRegistry))(r,e)}catch(i){throw r.close(),console.error("Exception opening new comm"),i}}async _handleCommClose(e){this._assertCurrentMessage(e);let t=e.content,r=this._comms.get(t.comm_id);if(!r){console.error("Comm not found for comm id "+t.comm_id);return}this._unregisterComm(r.commId);let i=r.onClose;i&&await i(e),r.dispose()}async _handleCommMsg(e){this._assertCurrentMessage(e);let t=e.content,r=this._comms.get(t.comm_id);if(!r)return;let i=r.onMsg;i&&await i(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===vt,r=this.requestKernelInfo(),i=!1,s=()=>{i||(i=!0,t&&this._kernelSession===vt&&(this._kernelSession=""),clearTimeout(o),this._pendingMessages.length>0&&this._sendPending())};r.then(s);let o=setTimeout(s,_h)}else this._updateStatus("unknown");this._connectionStatusChanged.emit(e)}}async _handleMessage(e){var t,r;let i=!1;if(e.parent_header&&e.channel==="iopub"&&(we.isDisplayDataMsg(e)||we.isUpdateDisplayDataMsg(e)||we.isExecuteResultMsg(e))){let o=((t=e.content.transient)!==null&&t!==void 0?t:{}).display_id;o&&(i=await this._handleDisplayId(o,e),this._assertCurrentMessage(e))}if(!i&&e.parent_header){let s=e.parent_header,o=(r=this._futures)===null||r===void 0?void 0:r.get(s.msg_id);if(o)await o.handleMsg(e),this._assertCurrentMessage(e);else{let a=s.session===this.clientId;e.channel!=="iopub"&&a&&this._unhandledMessage.emit(e)}}if(e.channel==="iopub"){switch(e.header.msg_type){case"status":{let s=e.content.execution_state;s==="restarting"&&Promise.resolve().then(async()=>{this._updateStatus("autorestarting"),this._clearKernelState(),await this.reconnect()}),this._updateStatus(s);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{if(o){if(typeof requirejs>"u")throw new Error("requirejs not found");requirejs([o],l=>{if(l[s]===void 0){let d=`Object '${s}' not found in module '${o}'`;u(new Error(d))}else c(l[s])},u)}else a?.[s]?c(a[s]):u(new Error(`Object '${s}' not found in registry`))})}n.loadObject=r;function i(s,o){return s=Math.ceil(s),o=Math.floor(o),Math.floor(Math.random()*(o-s+1))+s}n.getRandomIntInclusive=i})(Oe||(Oe={}))});var ta=R(En=>{"use strict";Object.defineProperty(En,"__esModule",{value:!0});En.KernelManager=void 0;var Qo=et(),gh=Lt(),ea=ie(),mh=Ge(),vh=At(),Cn=_n(),yh=Zo(),si=class extends vh.BaseManager{constructor(e={}){var t;super(e),this._isReady=!1,this._kernelConnections=new Set,this._models=new Map,this._runningChanged=new ea.Signal(this),this._connectionFailure=new ea.Signal(this),this._pollModels=new gh.Poll({auto:!1,factory:()=>this.requestRunning(),frequency:{interval:10*1e3,backoff:!0,max:300*1e3},name:"@jupyterlab/services:KernelManager#models",standby:(t=e.standby)!==null&&t!==void 0?t:"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:r}=e.model,i=(t=e.handleComms)!==null&&t!==void 0?t:!0;if(e.handleComms===void 0){for(let o of this._kernelConnections)if(o.id===r&&o.handleComms){i=!1;break}}let s=new yh.KernelConnection(Object.assign(Object.assign({handleComms:i},e),{serverSettings:this.serverSettings}));return this._onStarted(s),this._models.has(r)||this.refreshRunning().catch(()=>{}),s}running(){return Qo.iter([...this._models.values()])}async refreshRunning(){await this._pollModels.refresh(),await this._pollModels.tick}async startNew(e={},t={}){let r=await Cn.startNew(e,this.serverSettings);return this.connectTo(Object.assign(Object.assign({},t),{model:r}))}async shutdown(e){await Cn.shutdownKernel(e,this.serverSettings),await this.refreshRunning()}async shutdownAll(){await this.refreshRunning(),await Promise.all([...this._models.keys()].map(e=>Cn.shutdownKernel(e,this.serverSettings))),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 r;try{r=await Cn.listRunning(this.serverSettings)}catch(i){throw(i instanceof mh.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}this.isDisposed||this._models.size===r.length&&Qo.every(r,i=>{let s=this._models.get(i.id);return s?s.name===i.name:!1})||(this._models=new Map(r.map(i=>[i.id,i])),this._kernelConnections.forEach(i=>{this._models.has(i.id)||i.handleShutdown()}),this._runningChanged.emit(r))}_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(()=>{})}};En.KernelManager=si});var ai=R(ne=>{"use strict";var na=ne&&ne.__createBinding||(Object.create?function(n,e,t,r){r===void 0&&(r=t),Object.defineProperty(n,r,{enumerable:!0,get:function(){return e[t]}})}:function(n,e,t,r){r===void 0&&(r=t),n[r]=e[t]}),wh=ne&&ne.__setModuleDefault||(Object.create?function(n,e){Object.defineProperty(n,"default",{enumerable:!0,value:e})}:function(n,e){n.default=e}),oi=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)&&na(e,n,t);return wh(e,n),e},Sh=ne&&ne.__exportStar||function(n,e){for(var t in n)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&na(e,n,t)};Object.defineProperty(ne,"__esModule",{value:!0});ne.KernelAPI=ne.KernelMessage=ne.Kernel=void 0;var bh=oi(_s());ne.Kernel=bh;var Ch=oi(xt());ne.KernelMessage=Ch;var Eh=oi(_n());ne.KernelAPI=Eh;Sh(ta(),ne)});var ra=R(On=>{"use strict";Object.defineProperty(On,"__esModule",{value:!0});On.BuildManager=void 0;var ci=pe(),Xe=ye(),Oh="api/build",ui=class{constructor(e={}){var t;this._url="",this.serverSettings=(t=e.serverSettings)!==null&&t!==void 0?t:Xe.ServerConnection.makeSettings();let{baseUrl:r,appUrl:i}=this.serverSettings;this._url=ci.URLExt.join(r,i,Oh)}get isAvailable(){return ci.PageConfig.getOption("buildAvailable").toLowerCase()==="true"}get shouldCheck(){return ci.PageConfig.getOption("buildCheck").toLowerCase()==="true"}getStatus(){let{_url:e,serverSettings:t}=this;return Xe.ServerConnection.makeRequest(e,{},t).then(i=>{if(i.status!==200)throw new Xe.ServerConnection.ResponseError(i);return i.json()}).then(i=>{if(typeof i.status!="string")throw new Error("Invalid data");if(typeof i.message!="string")throw new Error("Invalid data");return i})}build(){let{_url:e,serverSettings:t}=this,r={method:"POST"};return Xe.ServerConnection.makeRequest(e,r,t).then(s=>{if(s.status===400)throw new Xe.ServerConnection.ResponseError(s,"Build aborted");if(s.status!==200){let o=`Build failed with ${s.status}, please run 'jupyter lab build' on the server for full output`;throw new Xe.ServerConnection.ResponseError(s,o)}})}cancel(){let{_url:e,serverSettings:t}=this,r={method:"DELETE"};return Xe.ServerConnection.makeRequest(e,r,t).then(s=>{if(s.status!==204)throw new Xe.ServerConnection.ResponseError(s)})}};On.BuildManager=ui});var di=R(Mn=>{"use strict";Object.defineProperty(Mn,"__esModule",{value:!0});Mn.NbConvertManager=void 0;var Mh=pe(),li=ye(),Rh="api/nbconvert",hi=class{constructor(e={}){var t;this.serverSettings=(t=e.serverSettings)!==null&&t!==void 0?t:li.ServerConnection.makeSettings()}async getExportFormats(){let e=this.serverSettings.baseUrl,t=Mh.URLExt.join(e,Rh),{serverSettings:r}=this,i=await li.ServerConnection.makeRequest(t,{},r);if(i.status!==200)throw await li.ServerConnection.ResponseError.create(i);let s=await i.json(),o={};return Object.keys(s).forEach(function(c){let u=s[c].output_mimetype;o[c]={output_mimetype:u}}),o}};Mn.NbConvertManager=hi});var sa=R(ia=>{"use strict";Object.defineProperty(ia,"__esModule",{value:!0})});var aa=R(Ze=>{"use strict";Object.defineProperty(Ze,"__esModule",{value:!0});Ze.validateModels=Ze.updateLegacySessionModel=Ze.validateModel=void 0;var xh=dn(),Ft=Rt();function oa(n){Ft.validateProperty(n,"id","string"),Ft.validateProperty(n,"type","string"),Ft.validateProperty(n,"name","string"),Ft.validateProperty(n,"path","string"),Ft.validateProperty(n,"kernel","object"),xh.validateModel(n.kernel)}Ze.validateModel=oa;function Dh(n){n.path===void 0&&n.notebook!==void 0&&(n.path=n.notebook.path,n.type="notebook",n.name="")}Ze.updateLegacySessionModel=Dh;function Ph(n){if(!Array.isArray(n))throw new Error("Invalid session list");n.forEach(e=>oa(e))}Ze.validateModels=Ph});var xn=R(X=>{"use strict";Object.defineProperty(X,"__esModule",{value:!0});X.updateSession=X.startSession=X.getSessionModel=X.shutdownSession=X.getSessionUrl=X.listRunning=X.SESSION_SERVICE_URL=void 0;var oe=ye(),fi=pe(),Qe=aa();X.SESSION_SERVICE_URL="api/sessions";async function Ih(n=oe.ServerConnection.makeSettings()){let e=fi.URLExt.join(n.baseUrl,X.SESSION_SERVICE_URL),t=await oe.ServerConnection.makeRequest(e,{},n);if(t.status!==200)throw await oe.ServerConnection.ResponseError.create(t);let r=await t.json();if(!Array.isArray(r))throw new Error("Invalid Session list");return r.forEach(i=>{Qe.updateLegacySessionModel(i),Qe.validateModel(i)}),r}X.listRunning=Ih;function Rn(n,e){return fi.URLExt.join(n,X.SESSION_SERVICE_URL,e)}X.getSessionUrl=Rn;async function kh(n,e=oe.ServerConnection.makeSettings()){var t;let r=Rn(e.baseUrl,n),i={method:"DELETE"},s=await oe.ServerConnection.makeRequest(r,i,e);if(s.status===404){let a=(t=(await s.json()).message)!==null&&t!==void 0?t:`The session "${n}"" does not exist on the server`;console.warn(a)}else{if(s.status===410)throw new oe.ServerConnection.ResponseError(s,"The kernel was deleted but the session was not");if(s.status!==204)throw await oe.ServerConnection.ResponseError.create(s)}}X.shutdownSession=kh;async function Th(n,e=oe.ServerConnection.makeSettings()){let t=Rn(e.baseUrl,n),r=await oe.ServerConnection.makeRequest(t,{},e);if(r.status!==200)throw await oe.ServerConnection.ResponseError.create(r);let i=await r.json();return Qe.updateLegacySessionModel(i),Qe.validateModel(i),i}X.getSessionModel=Th;async function jh(n,e=oe.ServerConnection.makeSettings()){let t=fi.URLExt.join(e.baseUrl,X.SESSION_SERVICE_URL),r={method:"POST",body:JSON.stringify(n)},i=await oe.ServerConnection.makeRequest(t,r,e);if(i.status!==201)throw await oe.ServerConnection.ResponseError.create(i);let s=await i.json();return Qe.updateLegacySessionModel(s),Qe.validateModel(s),s}X.startSession=jh;async function qh(n,e=oe.ServerConnection.makeSettings()){let t=Rn(e.baseUrl,n.id),r={method:"PATCH",body:JSON.stringify(n)},i=await oe.ServerConnection.makeRequest(t,r,e);if(i.status!==200)throw await oe.ServerConnection.ResponseError.create(i);let s=await i.json();return Qe.updateLegacySessionModel(s),Qe.validateModel(s),s}X.updateSession=qh});var ua=R(Dn=>{"use strict";Object.defineProperty(Dn,"__esModule",{value:!0});Dn.SessionConnection=void 0;var Ve=ie(),Uh=Ge(),ca=xn(),Nh=Ee(),_i=class{constructor(e){var t,r,i,s;this._id="",this._path="",this._name="",this._type="",this._kernel=null,this._isDisposed=!1,this._disposed=new Ve.Signal(this),this._kernelChanged=new Ve.Signal(this),this._statusChanged=new Ve.Signal(this),this._connectionStatusChanged=new Ve.Signal(this),this._iopubMessage=new Ve.Signal(this),this._unhandledMessage=new Ve.Signal(this),this._anyMessage=new Ve.Signal(this),this._propertyChanged=new Ve.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=(r=e.clientId)!==null&&r!==void 0?r:Nh.UUID.uuid4(),this._connectToKernel=e.connectToKernel,this._kernelConnectionOptions=(i=e.kernelConnectionOptions)!==null&&i!==void 0?i:{},this.serverSettings=(s=e.serverSettings)!==null&&s!==void 0?s:Uh.ServerConnection.makeSettings(),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 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 r=this._kernel||null;this.setupKernel(e.kernel);let i=this._kernel||null;this._kernelChanged.emit({name:"kernel",oldValue:r,newValue:i})}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})}Ve.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 ca.shutdownSession(this.id,this.serverSettings),this.dispose()}setupKernel(e){if(e===null){this._kernel=null;return}let t=this._connectToKernel(Object.assign(Object.assign({},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.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)}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 ca.updateSession(Object.assign(Object.assign({},e),{id:this._id}),this.serverSettings);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")}};Dn.SessionConnection=_i});var da=R(Pn=>{"use strict";Object.defineProperty(Pn,"__esModule",{value:!0});Pn.SessionManager=void 0;var la=et(),Lh=Lt(),ha=ie(),Ah=ye(),Bh=At(),Fh=ua(),Kt=xn(),pi=class extends Bh.BaseManager{constructor(e){var t;super(e),this._isReady=!1,this._sessionConnections=new Set,this._models=new Map,this._runningChanged=new ha.Signal(this),this._connectionFailure=new ha.Signal(this),this._connectToKernel=r=>this._kernelManager.connectTo(r),this._kernelManager=e.kernelManager,this._pollModels=new Lh.Poll({auto:!1,factory:()=>this.requestRunning(),frequency:{interval:10*1e3,backoff:!0,max:300*1e3},name:"@jupyterlab/services:SessionManager#models",standby:(t=e.standby)!==null&&t!==void 0?t:"when-hidden"}),this._ready=(async()=>{await this._pollModels.start(),await this._pollModels.tick,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 Fh.SessionConnection(Object.assign(Object.assign({},e),{connectToKernel:this._connectToKernel,serverSettings:this.serverSettings}));return this._onStarted(t),this._models.has(e.model.id)||this.refreshRunning().catch(()=>{}),t}running(){return la.iter([...this._models.values()])}async refreshRunning(){await this._pollModels.refresh(),await this._pollModels.tick}async startNew(e,t={}){let r=await Kt.startSession(e,this.serverSettings);return await this.refreshRunning(),this.connectTo(Object.assign(Object.assign({},t),{model:r}))}async shutdown(e){await Kt.shutdownSession(e,this.serverSettings),await this.refreshRunning()}async shutdownAll(){await this.refreshRunning(),await Promise.all([...this._models.keys()].map(e=>Kt.shutdownSession(e,this.serverSettings))),await this.refreshRunning()}async stopIfNeeded(e){try{let r=(await Kt.listRunning(this.serverSettings)).filter(i=>i.path===e);if(r.length===1){let i=r[0].id;await this.shutdown(i)}}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 r;try{r=await Kt.listRunning(this.serverSettings)}catch(i){throw(i instanceof Ah.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}this.isDisposed||this._models.size===r.length&&la.every(r,i=>{var s,o,a,c;let u=this._models.get(i.id);return u?((s=u.kernel)===null||s===void 0?void 0:s.id)===((o=i.kernel)===null||o===void 0?void 0:o.id)&&((a=u.kernel)===null||a===void 0?void 0:a.name)===((c=i.kernel)===null||c===void 0?void 0:c.name)&&u.name===i.name&&u.path===i.path&&u.type===i.type:!1})||(this._models=new Map(r.map(i=>[i.id,i])),this._sessionConnections.forEach(i=>{this._models.has(i.id)?i.update(this._models.get(i.id)):i.dispose()}),this._runningChanged.emit(r))}_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(()=>{})}};Pn.SessionManager=pi});var gi=R(he=>{"use strict";var fa=he&&he.__createBinding||(Object.create?function(n,e,t,r){r===void 0&&(r=t),Object.defineProperty(n,r,{enumerable:!0,get:function(){return e[t]}})}:function(n,e,t,r){r===void 0&&(r=t),n[r]=e[t]}),Kh=he&&he.__setModuleDefault||(Object.create?function(n,e){Object.defineProperty(n,"default",{enumerable:!0,value:e})}:function(n,e){n.default=e}),_a=he&&he.__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)&&fa(e,n,t);return Kh(e,n),e},Vh=he&&he.__exportStar||function(n,e){for(var t in n)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&fa(e,n,t)};Object.defineProperty(he,"__esModule",{value:!0});he.SessionAPI=he.Session=void 0;var Wh=_a(sa());he.Session=Wh;var $h=_a(xn());he.SessionAPI=$h;Vh(da(),he)});var pa=R(In=>{"use strict";Object.defineProperty(In,"__esModule",{value:!0});In.DataConnector=void 0;var mi=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.")}};In.DataConnector=mi});var ma=R(ga=>{"use strict";Object.defineProperty(ga,"__esModule",{value:!0})});var ya=R(Tn=>{"use strict";Object.defineProperty(Tn,"__esModule",{value:!0});Tn.RestorablePool=void 0;var Gh=Ee(),va=zn(),kn=ie(),vi=class{constructor(e){this._added=new kn.Signal(this),this._current=null,this._currentChanged=new kn.Signal(this),this._hasRestored=!1,this._isDisposed=!1,this._objects=new Set,this._restore=null,this._restored=new Gh.PromiseDelegate,this._updated=new kn.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,r;if(e.isDisposed){let i="A disposed object cannot be added.";throw console.warn(i,e),new Error(i)}if(this._objects.has(e)){let i="This object already exists in the pool.";throw console.warn(i,e),new Error(i)}if(this._objects.add(e),e.disposed.connect(this._onInstanceDisposed,this),!Ne.injectedProperty.get(e)){if(this._restore){let{connector:i}=this._restore,s=this._restore.name(e);if(s){let o=`${this.namespace}:${s}`,a=(r=(t=this._restore).args)===null||r===void 0?void 0:r.call(t,e);Ne.nameProperty.set(e,o),await i.save(o,{data:a})}}this._added.emit(e)}}dispose(){this.isDisposed||(this._current=null,this._isDisposed=!0,this._objects.clear(),kn.Signal.clearData(this))}find(e){let t=this._objects.values();for(let r of t)if(e(r))return r}forEach(e){this._objects.forEach(e)}filter(e){let t=[];return this.forEach(r=>{e(r)&&t.push(r)}),t}inject(e){return Ne.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:r,registry:i,when:s}=e,o=this.namespace,a=s?[r.list(o)].concat(s):[r.list(o)];this._restore=e;let[c]=await Promise.all(a),u=await Promise.all(c.ids.map(async(l,d)=>{let g=c.values[d],y=g&&g.data;return y===void 0?r.remove(l):i.execute(t,y).catch(()=>r.remove(l))}));return this._restored.resolve(),u}async save(e){var t,r;let i=Ne.injectedProperty.get(e);if(!this._restore||!this.has(e)||i)return;let{connector:s}=this._restore,o=this._restore.name(e),a=Ne.nameProperty.get(e),c=o?`${this.namespace}:${o}`:"";if(a&&a!==c&&await s.remove(a),Ne.nameProperty.set(e,c),c){let u=(r=(t=this._restore).args)===null||r===void 0?void 0:r.call(t,e);await s.save(c,{data:u})}a!==c&&this._updated.emit(e)}_onInstanceDisposed(e){if(this._objects.delete(e),e===this._current&&(this._current=null,this._currentChanged.emit(this._current)),Ne.injectedProperty.get(e)||!this._restore)return;let{connector:t}=this._restore,r=Ne.nameProperty.get(e);r&&t.remove(r)}};Tn.RestorablePool=vi;var Ne;(function(n){n.injectedProperty=new va.AttachedProperty({name:"injected",create:()=>!1}),n.nameProperty=new va.AttachedProperty({name:"name",create:()=>""})})(Ne||(Ne={}))});var wa=R(yt=>{"use strict";Object.defineProperty(yt,"__esModule",{value:!0});yt.StateDB=void 0;var Hh=ie(),jn=class n{constructor(e={}){this._changed=new Hh.Signal(this);let{connector:t,transform:r}=e;this._connector=t||new n.Connector,r?this._ready=r.then(i=>{let{contents:s,type:o}=i;switch(o){case"cancel":return;case"clear":return this._clear();case"merge":return this._merge(s||{});case"overwrite":return this._overwrite(s||{});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((r,i,s)=>(r[e[s]]=i,r),{})}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:r}=await this._connector.list(e);return{ids:t,values:r.map(i=>JSON.parse(i).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}))}};yt.StateDB=jn;(function(n){class e{constructor(){this._storage={}}async fetch(r){return this._storage[r]}async list(r=""){return Object.keys(this._storage).reduce((i,s)=>((r===""||r===s.split(":")[0])&&(i.ids.push(s),i.values.push(this._storage[s])),i),{ids:[],values:[]})}async remove(r){delete this._storage[r]}async save(r,i){this._storage[r]=i}}n.Connector=e})(jn=yt.StateDB||(yt.StateDB={}))});var Sa=R(qn=>{"use strict";Object.defineProperty(qn,"__esModule",{value:!0});qn.IStateDB=void 0;var zh=Ee();qn.IStateDB=new zh.Token("@jupyterlab/coreutils:IStateDB")});var yi=R(Me=>{"use strict";var Jh=Me&&Me.__createBinding||(Object.create?function(n,e,t,r){r===void 0&&(r=t),Object.defineProperty(n,r,{enumerable:!0,get:function(){return e[t]}})}:function(n,e,t,r){r===void 0&&(r=t),n[r]=e[t]}),Vt=Me&&Me.__exportStar||function(n,e){for(var t in n)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&Jh(e,n,t)};Object.defineProperty(Me,"__esModule",{value:!0});Vt(pa(),Me);Vt(ma(),Me);Vt(ya(),Me);Vt(wa(),Me);Vt(Sa(),Me)});var Si=R(Nn=>{"use strict";Object.defineProperty(Nn,"__esModule",{value:!0});Nn.SettingManager=void 0;var Yh=pe(),Xh=yi(),Un=ye(),Zh="api/settings",wi=class extends Xh.DataConnector{constructor(e={}){var t;super(),this.serverSettings=(t=e.serverSettings)!==null&&t!==void 0?t:Un.ServerConnection.makeSettings()}async fetch(e){if(!e)throw new Error("Plugin `id` parameter is required for settings fetch.");let{serverSettings:t}=this,{baseUrl:r,appUrl:i}=t,{makeRequest:s,ResponseError:o}=Un.ServerConnection,a=r+i,c=Wt.url(a,e),u=await s(c,{},t);if(u.status!==200)throw await o.create(u);return u.json()}async list(){var e,t;let{serverSettings:r}=this,{baseUrl:i,appUrl:s}=r,{makeRequest:o,ResponseError:a}=Un.ServerConnection,c=i+s,u=Wt.url(c,""),l=await o(u,{},r);if(l.status!==200)throw new a(l);let d=await l.json(),g=(t=(e=d?.settings)===null||e===void 0?void 0:e.map(v=>(v.data={composite:{},user:{}},v)))!==null&&t!==void 0?t:[];return{ids:g.map(v=>v.id),values:g}}async save(e,t){let{serverSettings:r}=this,{baseUrl:i,appUrl:s}=r,{makeRequest:o,ResponseError:a}=Un.ServerConnection,c=i+s,u=Wt.url(c,e),l={body:JSON.stringify({raw:t}),method:"PUT"},d=await o(u,l,r);if(d.status!==204)throw new a(d)}};Nn.SettingManager=wi;var Wt;(function(n){function e(t,r){return Yh.URLExt.join(t,Zh,r)}n.url=e})(Wt||(Wt={}))});var Gt=R(de=>{"use strict";Object.defineProperty(de,"__esModule",{value:!0});de.shutdownTerminal=de.listRunning=de.startNew=de.isAvailable=de.TERMINAL_SERVICE_URL=void 0;var Ln=pe(),We=ye();de.TERMINAL_SERVICE_URL="api/terminals";function ba(){return String(Ln.PageConfig.getOption("terminalsAvailable")).toLowerCase()==="true"}de.isAvailable=ba;async function Qh(n=We.ServerConnection.makeSettings()){$t.errorIfNotAvailable();let e=Ln.URLExt.join(n.baseUrl,de.TERMINAL_SERVICE_URL),t={method:"POST"},r=await We.ServerConnection.makeRequest(e,t,n);if(r.status!==200)throw await We.ServerConnection.ResponseError.create(r);return await r.json()}de.startNew=Qh;async function ed(n=We.ServerConnection.makeSettings()){$t.errorIfNotAvailable();let e=Ln.URLExt.join(n.baseUrl,de.TERMINAL_SERVICE_URL),t=await We.ServerConnection.makeRequest(e,{},n);if(t.status!==200)throw await We.ServerConnection.ResponseError.create(t);let r=await t.json();if(!Array.isArray(r))throw new Error("Invalid terminal list");return r}de.listRunning=ed;async function td(n,e=We.ServerConnection.makeSettings()){var t;$t.errorIfNotAvailable();let r=Ln.URLExt.join(e.baseUrl,de.TERMINAL_SERVICE_URL,n),i={method:"DELETE"},s=await We.ServerConnection.makeRequest(r,i,e);if(s.status===404){let a=(t=(await s.json()).message)!==null&&t!==void 0?t:`The terminal session "${n}"" does not exist on the server`;console.warn(a)}else if(s.status!==204)throw await We.ServerConnection.ResponseError.create(s)}de.shutdownTerminal=td;var $t;(function(n){function e(){if(!ba())throw new Error("Terminals Unavailable")}n.errorIfNotAvailable=e})($t||($t={}))});var Ca=R(An=>{"use strict";Object.defineProperty(An,"__esModule",{value:!0});An.isAvailable=void 0;var nd=Gt();Object.defineProperty(An,"isAvailable",{enumerable:!0,get:function(){return nd.isAvailable}})});var Ma=R(Fn=>{"use strict";Object.defineProperty(Fn,"__esModule",{value:!0});Fn.TerminalConnection=void 0;var Ea=pe(),rd=Ee(),Bn=ie(),id=Ge(),Oa=Gt(),bi=class n{constructor(e){var t;this._createSocket=()=>{this._errorIfDisposed(),this._clearSocket(),this._updateConnectionStatus("connecting");let r=this._name,i=this.serverSettings,s=Ea.URLExt.join(i.wsUrl,"terminals","websocket",encodeURIComponent(r)),o=i.token;i.appendToken&&o!==""&&(s=s+`?token=${encodeURIComponent(o)}`),this._ws=new i.WebSocket(s),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 Bn.Signal(this),this._isDisposed=!1,this._disposed=new Bn.Signal(this),this._messageReceived=new Bn.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:id.ServerConnection.makeSettings(),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(),Bn.Signal.clearData(this))}send(e){this._sendMessage(e)}_sendMessage(e,t=!0){if(!(this._isDisposed||!e.content))if(this.connectionStatus==="connected"&&this._ws){let r=[e.type,...e.content];this._ws.send(JSON.stringify(r))}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 rd.PromiseDelegate,t=(r,i)=>{i==="connected"?(e.resolve(),this.connectionStatusChanged.disconnect(t,this)):i==="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{"use strict";Object.defineProperty(Kn,"__esModule",{value:!0});Kn.TerminalManager=void 0;var sd=et(),od=Lt(),Ra=ie(),ad=Ge(),cd=At(),Ht=Gt(),ud=Ma(),Ei=class extends cd.BaseManager{constructor(e={}){var t;if(super(e),this._isReady=!1,this._names=[],this._terminalConnections=new Set,this._runningChanged=new Ra.Signal(this),this._connectionFailure=new Ra.Signal(this),!this.isAvailable()){this._ready=Promise.reject("Terminals unavailable"),this._ready.catch(r=>{});return}this._pollModels=new od.Poll({auto:!1,factory:()=>this.requestRunning(),frequency:{interval:10*1e3,backoff:!0,max:300*1e3},name:"@jupyterlab/services:TerminalManager#models",standby:(t=e.standby)!==null&&t!==void 0?t:"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._names.length=0,this._terminalConnections.forEach(e=>e.dispose()),this._pollModels.dispose(),super.dispose())}isAvailable(){return Ht.isAvailable()}connectTo(e){let t=new ud.TerminalConnection(Object.assign(Object.assign({},e),{serverSettings:this.serverSettings}));return this._onStarted(t),this._names.includes(e.model.name)||this.refreshRunning().catch(()=>{}),t}running(){return sd.iter(this._models)}async refreshRunning(){await this._pollModels.refresh(),await this._pollModels.tick}async startNew(){let e=await Ht.startNew(this.serverSettings);return await this.refreshRunning(),this.connectTo({model:e})}async shutdown(e){await Ht.shutdownTerminal(e,this.serverSettings),await this.refreshRunning()}async shutdownAll(){await this.refreshRunning(),await Promise.all(this._names.map(e=>Ht.shutdownTerminal(e,this.serverSettings))),await this.refreshRunning()}async requestRunning(){var e,t;let r;try{r=await Ht.listRunning(this.serverSettings)}catch(s){throw(s instanceof ad.ServerConnection.NetworkError||((e=s.response)===null||e===void 0?void 0:e.status)===503||((t=s.response)===null||t===void 0?void 0:t.status)===424)&&this._connectionFailure.emit(s),s}if(this.isDisposed)return;let i=r.map(({name:s})=>s).sort();i!==this._names&&(this._names=i,this._terminalConnections.forEach(s=>{i.includes(s.name)||s.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}))}};Kn.TerminalManager=Ei});var Oi=R(fe=>{"use strict";var Da=fe&&fe.__createBinding||(Object.create?function(n,e,t,r){r===void 0&&(r=t),Object.defineProperty(n,r,{enumerable:!0,get:function(){return e[t]}})}:function(n,e,t,r){r===void 0&&(r=t),n[r]=e[t]}),ld=fe&&fe.__setModuleDefault||(Object.create?function(n,e){Object.defineProperty(n,"default",{enumerable:!0,value:e})}:function(n,e){n.default=e}),Pa=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)&&Da(e,n,t);return ld(e,n),e},hd=fe&&fe.__exportStar||function(n,e){for(var t in n)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&Da(e,n,t)};Object.defineProperty(fe,"__esModule",{value:!0});fe.TerminalAPI=fe.Terminal=void 0;var dd=Pa(Ca());fe.Terminal=dd;var fd=Pa(Gt());fe.TerminalAPI=fd;hd(xa(),fe)});var Ri=R(Vn=>{"use strict";Object.defineProperty(Vn,"__esModule",{value:!0});Vn.WorkspaceManager=void 0;var _d=pe(),pd=yi(),zt=ye(),gd="api/workspaces",Mi=class extends pd.DataConnector{constructor(e={}){var t;super(),this.serverSettings=(t=e.serverSettings)!==null&&t!==void 0?t:zt.ServerConnection.makeSettings()}async fetch(e){let{serverSettings:t}=this,{baseUrl:r,appUrl:i}=t,{makeRequest:s,ResponseError:o}=zt.ServerConnection,a=r+i,c=wt.url(a,e),u=await s(c,{},t);if(u.status!==200)throw await o.create(u);return u.json()}async list(){let{serverSettings:e}=this,{baseUrl:t,appUrl:r}=e,{makeRequest:i,ResponseError:s}=zt.ServerConnection,o=t+r,a=wt.url(o,""),c=await i(a,{},e);if(c.status!==200)throw await s.create(c);return(await c.json()).workspaces}async remove(e){let{serverSettings:t}=this,{baseUrl:r,appUrl:i}=t,{makeRequest:s,ResponseError:o}=zt.ServerConnection,a=r+i,c=wt.url(a,e),l=await s(c,{method:"DELETE"},t);if(l.status!==204)throw await o.create(l)}async save(e,t){let{serverSettings:r}=this,{baseUrl:i,appUrl:s}=r,{makeRequest:o,ResponseError:a}=zt.ServerConnection,c=i+s,u=wt.url(c,e),l={body:JSON.stringify(t),method:"PUT"},d=await o(u,l,r);if(d.status!==204)throw await a.create(d)}};Vn.WorkspaceManager=Mi;var wt;(function(n){function e(t,r){return _d.URLExt.join(t,gd,r)}n.url=e})(wt||(wt={}))});var ka=R(Wn=>{"use strict";Object.defineProperty(Wn,"__esModule",{value:!0});Wn.ServiceManager=void 0;var Ia=ie(),md=ra(),vd=di(),yd=or(),wd=wn(),Sd=gi(),bd=Si(),Cd=Oi(),Ed=ye(),Od=Ri(),Md=ai(),xi=class{constructor(e={}){var t,r;this._isDisposed=!1,this._connectionFailure=new Ia.Signal(this),this._isReady=!1;let i=e.defaultDrive,s=(t=e.serverSettings)!==null&&t!==void 0?t:Ed.ServerConnection.makeSettings(),o=(r=e.standby)!==null&&r!==void 0?r:"when-hidden",a={defaultDrive:i,serverSettings:s,standby:o},c=new Md.KernelManager(a);this.serverSettings=s,this.contents=new yd.ContentsManager(a),this.sessions=new Sd.SessionManager(Object.assign(Object.assign({},a),{kernelManager:c})),this.settings=new bd.SettingManager(a),this.terminals=new Cd.TerminalManager(a),this.builder=new md.BuildManager(a),this.workspaces=new Od.WorkspaceManager(a),this.nbconvert=new vd.NbConvertManager(a),this.kernelspecs=new wd.KernelSpecManager(a),this.kernelspecs.connectionFailure.connect(this._onConnectionFailure,this),this.sessions.connectionFailure.connect(this._onConnectionFailure,this),this.terminals.connectionFailure.connect(this._onConnectionFailure,this);let u=[this.sessions.ready,this.kernelspecs.ready];this.terminals.isAvailable()&&u.push(this.terminals.ready),this._readyPromise=Promise.all(u).then(()=>{this._isReady=!0})}get connectionFailure(){return this._connectionFailure}get isDisposed(){return this._isDisposed}dispose(){this.isDisposed||(this._isDisposed=!0,Ia.Signal.clearData(this),this.contents.dispose(),this.sessions.dispose(),this.terminals.dispose())}get isReady(){return this._isReady}get ready(){return this._readyPromise}_onConnectionFailure(e,t){this._connectionFailure.emit(t)}};Wn.ServiceManager=xi});var Ge=R(re=>{var Rd=re&&re.__createBinding||(Object.create?function(n,e,t,r){r===void 0&&(r=t),Object.defineProperty(n,r,{enumerable:!0,get:function(){return e[t]}})}:function(n,e,t,r){r===void 0&&(r=t),n[r]=e[t]}),Re=re&&re.__exportStar||function(n,e){for(var t in n)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&Rd(e,n,t)};Object.defineProperty(re,"__esModule",{value:!0});Re(hs(),re);Re(or(),re);Re(ai(),re);Re(wn(),re);Re(ka(),re);Re(ye(),re);Re(gi(),re);Re(Si(),re);Re(Oi(),re);Re(Ri(),re);Re(di(),re)});module.exports=Ge();
/*! Bundled license information:
@lumino/polling/dist/index.js:
(*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** *)
@lumino/disposable/dist/index.js:
(*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** *)
*/