@runmedev/react-console 3.14.4 → 3.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14,8 +14,8 @@ interface ConsoleRunner {
14
14
  reconnect: boolean;
15
15
  authorization: Authorization;
16
16
  }
17
- declare function Console({ blockID, runID, sequence, commands, runner, settings: settingsProp, onStdout, onStderr, onExitCode, onPid, onMimeType, }: {
18
- blockID: string;
17
+ declare function Console({ cellID, runID, sequence, commands, runner, settings: settingsProp, onStdout, onStderr, onExitCode, onPid, onMimeType, }: {
18
+ cellID: string;
19
19
  runID: string;
20
20
  sequence: number;
21
21
  commands: string[];
@@ -1 +1 @@
1
- {"version":3,"file":"Console.d.ts","sourceRoot":"","sources":["../../src/components/Console.tsx"],"names":[],"mappings":"AAcA,OAAO,qBAAqB,CAAA;AAG5B,OAAO,+BAA+B,CAAA;AACtC,OAAgB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAEnD,UAAU,eAAe;IACvB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,WAAW,CAAC,EAAE,OAAO,CAAA;CACtB;AAED,UAAU,aAAa;IACrB,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,EAAE,OAAO,CAAA;IAClB,aAAa,EAAE,aAAa,CAAA;CAC7B;AAED,iBAAS,OAAO,CAAC,EACf,OAAO,EACP,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,MAAM,EACN,QAAQ,EAAE,YAAiB,EAC3B,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,KAAK,EACL,UAAU,GACX,EAAE;IACD,OAAO,EAAE,MAAM,CAAA;IACf,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,EAAE,MAAM,EAAE,CAAA;IAClB,MAAM,EAAE,aAAa,CAAA;IACrB,QAAQ,CAAC,EAAE,eAAe,CAAA;IAC1B,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,IAAI,CAAA;IACrC,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,IAAI,CAAA;IACrC,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;IACnC,KAAK,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAA;IAC7B,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAA;CACxC,2CA0SA;AAaD,eAAe,OAAO,CAAA"}
1
+ {"version":3,"file":"Console.d.ts","sourceRoot":"","sources":["../../src/components/Console.tsx"],"names":[],"mappings":"AAcA,OAAO,qBAAqB,CAAA;AAG5B,OAAO,+BAA+B,CAAA;AACtC,OAAgB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAEnD,UAAU,eAAe;IACvB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,WAAW,CAAC,EAAE,OAAO,CAAA;CACtB;AAED,UAAU,aAAa;IACrB,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,EAAE,OAAO,CAAA;IAClB,aAAa,EAAE,aAAa,CAAA;CAC7B;AAED,iBAAS,OAAO,CAAC,EACf,MAAM,EACN,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,MAAM,EACN,QAAQ,EAAE,YAAiB,EAC3B,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,KAAK,EACL,UAAU,GACX,EAAE;IACD,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,EAAE,MAAM,EAAE,CAAA;IAClB,MAAM,EAAE,aAAa,CAAA;IACrB,QAAQ,CAAC,EAAE,eAAe,CAAA;IAC1B,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,IAAI,CAAA;IACrC,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,IAAI,CAAA;IACrC,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;IACnC,KAAK,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAA;IAC7B,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAA;CACxC,2CA0SA;AAaD,eAAe,OAAO,CAAA"}
@@ -6539,4 +6539,4 @@ Open Dashboard to configure it`)},O=function(){var W;const ie=(0,U.getContext)()
6539
6539
  !*** ./src/client/index.ts ***!
6540
6540
  \*****************************/Object.defineProperty(g,"__esModule",{value:!0}),g.ClientMessages=g.setContext=g.activate=void 0;const e=mt("./src/constants.ts");Object.defineProperty(g,"ClientMessages",{enumerable:!0,get:function(){return e.ClientMessages}});const t=mt("./src/client/utils.ts");Object.defineProperty(g,"setContext",{enumerable:!0,get:function(){return t.setContext}}),mt("./src/client/components/index.ts");const d=m=>((0,t.setContext)(m),{renderOutputItem(v,o){var n,s,r;const i=v.json();switch(i.type){case e.OutputType.vercel:if(i.output.error){a(i.output.error);break}const c=document.createElement(e.RENDERERS.VercelOutput);c.setAttribute("content",JSON.stringify(i.output)),o.appendChild(c);break;case e.OutputType.daggerCall:if(!((n=i.output)!=null&&n.cellId))return;const f=document.createElement(e.RENDERERS.DaggerCli);f.setAttribute("cellId",i.output.cellId);const h={...i.output,cli:{status:"active"}};f.setAttribute("state",JSON.stringify(h)),o.appendChild(f);break;case e.OutputType.deno:if((s=i.output)!=null&&s.error){a(i.output.error);break}const l=i.output||{},u=document.createElement(e.RENDERERS.DenoOutput);u.setAttribute("state",JSON.stringify(l)),o.appendChild(u);break;case e.OutputType.outputItems:const p=decodeURIComponent(escape(window.atob(i.output.content))),_=document.createElement(e.RENDERERS.ShellOutput);_.innerHTML=p,o.appendChild(_);const b=document.createElement(e.RENDERERS.ShellOutputItems);b.setAttribute("id",i.output.id),b.setAttribute("content",p),o.appendChild(b);break;case e.OutputType.annotations:const y=document.createElement(e.RENDERERS.EditAnnotations);y.setAttribute("annotations",JSON.stringify(i.output.annotations??[])),y.setAttribute("validationErrors",JSON.stringify(i.output.validationErrors??[])),y.setAttribute("settings",JSON.stringify(i.output.settings)),o.appendChild(y);break;case e.OutputType.terminal:const C=document.createElement(e.RENDERERS.TerminalView);C.setAttribute("id",i.output["runme.dev/id"]),C.setAttribute("fontFamily",i.output.fontFamily),typeof i.output.fontSize=="number"&&C.setAttribute("fontSize",i.output.fontSize.toString()),i.output.cursorStyle&&C.setAttribute("cursorStyle",i.output.cursorStyle),typeof i.output.cursorBlink=="boolean"&&C.setAttribute("cursorBlink",i.output.cursorBlink?"true":"false"),typeof i.output.cursorWidth=="number"&&C.setAttribute("cursorWidth",i.output.cursorWidth.toString()),typeof i.output.smoothScrollDuration=="number"&&C.setAttribute("smoothScrollDuration",i.output.smoothScrollDuration.toString()),typeof i.output.scrollback=="number"&&C.setAttribute("scrollback",i.output.scrollback.toString()),i.output.initialRows!==void 0&&C.setAttribute("initialRows",i.output.initialRows.toString()),i.output.content!==void 0&&C.setAttribute("initialContent",i.output.content),i.output.isAutoSaveEnabled&&C.setAttribute("isAutoSaveEnabled",i.output.isAutoSaveEnabled.toString()),i.output.isPlatformAuthEnabled&&C.setAttribute("isPlatformAuthEnabled",i.output.isPlatformAuthEnabled.toString()),i.output.isDaggerOutput&&C.setAttribute("isDaggerOutput",i.output.isDaggerOutput.toString()),o.appendChild(C);break;case e.OutputType.error:a(i.output);break;case e.OutputType.github:const S=document.createElement(e.RENDERERS.GitHubWorkflowViewer);(r=i.output)!=null&&r.content&&S.setAttribute("state",JSON.stringify(i.output)),o.appendChild(S);break;case e.OutputType.gcp:const E=document.createElement(e.RENDERERS.GCPView);i.output&&E.setAttribute("state",JSON.stringify(i.output)),o.appendChild(E);break;case e.OutputType.aws:const j=document.createElement(e.RENDERERS.AWSView);i.output&&j.setAttribute("state",JSON.stringify(i.output)),o.appendChild(j);break;default:o.innerHTML="No renderer found!"}function a(c){o.innerHTML=`⚠️ ${c}`}},disposeOutputItem(){}});g.activate=d})();const fs=Ss.ClientMessages;Ss.__esModule;Ss.activate;const xa=Ss.setContext,Xr=$s("ChVnb29nbGUvcnBjL2NvZGUucHJvdG8SCmdvb2dsZS5ycGMqtwIKBENvZGUSBgoCT0sQABINCglDQU5DRUxMRUQQARILCgdVTktOT1dOEAISFAoQSU5WQUxJRF9BUkdVTUVOVBADEhUKEURFQURMSU5FX0VYQ0VFREVEEAQSDQoJTk9UX0ZPVU5EEAUSEgoOQUxSRUFEWV9FWElTVFMQBhIVChFQRVJNSVNTSU9OX0RFTklFRBAHEhMKD1VOQVVUSEVOVElDQVRFRBAQEhYKElJFU09VUkNFX0VYSEFVU1RFRBAIEhcKE0ZBSUxFRF9QUkVDT05ESVRJT04QCRILCgdBQk9SVEVEEAoSEAoMT1VUX09GX1JBTkdFEAsSEQoNVU5JTVBMRU1FTlRFRBAMEgwKCElOVEVSTkFMEA0SDwoLVU5BVkFJTEFCTEUQDhINCglEQVRBX0xPU1MQD0JYCg5jb20uZ29vZ2xlLnJwY0IJQ29kZVByb3RvUAFaM2dvb2dsZS5nb2xhbmcub3JnL2dlbnByb3RvL2dvb2dsZWFwaXMvcnBjL2NvZGU7Y29kZaICA1JQQ2IGcHJvdG8z"),Aa=Sn(Xr,0),Pa=jn(Aa),Yr=$s("CiBydW5tZS9zdHJlYW0vdjEvd2Vic29ja2V0cy5wcm90bxIPcnVubWUuc3RyZWFtLnYxIkIKD1dlYnNvY2tldFN0YXR1cxIeCgRjb2RlGAEgASgOMhAuZ29vZ2xlLnJwYy5Db2RlEg8KB21lc3NhZ2UYAiABKAkiGQoEUGluZxIRCgl0aW1lc3RhbXAYASABKAMiGQoEUG9uZxIRCgl0aW1lc3RhbXAYASABKAMiugEKEFdlYnNvY2tldFJlcXVlc3QSOgoPZXhlY3V0ZV9yZXF1ZXN0GAEgASgLMh8ucnVubWUucnVubmVyLnYyLkV4ZWN1dGVSZXF1ZXN0SAASIwoEcGluZxhkIAEoCzIVLnJ1bm1lLnN0cmVhbS52MS5QaW5nEhYKDWF1dGhvcml6YXRpb24YyAEgASgJEhEKCGtub3duX2lkGNIBIAEoCRIPCgZydW5faWQY3AEgASgJQgkKB3BheWxvYWQi2AEKEVdlYnNvY2tldFJlc3BvbnNlEjwKEGV4ZWN1dGVfcmVzcG9uc2UYASABKAsyIC5ydW5tZS5ydW5uZXIudjIuRXhlY3V0ZVJlc3BvbnNlSAASIwoEcG9uZxhkIAEoCzIVLnJ1bm1lLnN0cmVhbS52MS5Qb25nEjEKBnN0YXR1cxjIASABKAsyIC5ydW5tZS5zdHJlYW0udjEuV2Vic29ja2V0U3RhdHVzEhEKCGtub3duX2lkGNIBIAEoCRIPCgZydW5faWQY3AEgASgJQgkKB3BheWxvYWRCSFpGZ2l0aHViLmNvbS9ydW5tZWRldi9ydW5tZS92My9hcGkvZ2VuL3Byb3RvL2dvL3J1bm1lL3N0cmVhbS92MTtzdHJlYW12MWIGcHJvdG8z",[Xr,Us]),ln=Es(Yr,3),Ra=Es(Yr,4);var cn=function(g,e){return cn=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,d){t.__proto__=d}||function(t,d){for(var m in d)Object.prototype.hasOwnProperty.call(d,m)&&(t[m]=d[m])},cn(g,e)};function bt(g,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");cn(g,e);function t(){this.constructor=g}g.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}function Da(g,e,t,d){function m(v){return v instanceof t?v:new t(function(o){o(v)})}return new(t||(t=Promise))(function(v,o){function i(s){try{n(d.next(s))}catch(r){o(r)}}function a(s){try{n(d.throw(s))}catch(r){o(r)}}function n(s){s.done?v(s.value):m(s.value).then(i,a)}n((d=d.apply(g,e||[])).next())})}function Jr(g,e){var t={label:0,sent:function(){if(v[0]&1)throw v[1];return v[1]},trys:[],ops:[]},d,m,v,o=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return o.next=i(0),o.throw=i(1),o.return=i(2),typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function i(n){return function(s){return a([n,s])}}function a(n){if(d)throw new TypeError("Generator is already executing.");for(;o&&(o=0,n[0]&&(t=0)),t;)try{if(d=1,m&&(v=n[0]&2?m.return:n[0]?m.throw||((v=m.return)&&v.call(m),0):m.next)&&!(v=v.call(m,n[1])).done)return v;switch(m=0,v&&(n=[n[0]&2,v.value]),n[0]){case 0:case 1:v=n;break;case 4:return t.label++,{value:n[1],done:!1};case 5:t.label++,m=n[1],n=[0];continue;case 7:n=t.ops.pop(),t.trys.pop();continue;default:if(v=t.trys,!(v=v.length>0&&v[v.length-1])&&(n[0]===6||n[0]===2)){t=0;continue}if(n[0]===3&&(!v||n[1]>v[0]&&n[1]<v[3])){t.label=n[1];break}if(n[0]===6&&t.label<v[1]){t.label=v[1],v=n;break}if(v&&t.label<v[2]){t.label=v[2],t.ops.push(n);break}v[2]&&t.ops.pop(),t.trys.pop();continue}n=e.call(g,t)}catch(s){n=[6,s],m=0}finally{d=v=0}if(n[0]&5)throw n[1];return{value:n[0]?n[1]:void 0,done:!0}}}function ns(g){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&g[e],d=0;if(t)return t.call(g);if(g&&typeof g.length=="number")return{next:function(){return g&&d>=g.length&&(g=void 0),{value:g&&g[d++],done:!g}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function pt(g,e){var t=typeof Symbol=="function"&&g[Symbol.iterator];if(!t)return g;var d=t.call(g),m,v=[],o;try{for(;(e===void 0||e-- >0)&&!(m=d.next()).done;)v.push(m.value)}catch(i){o={error:i}}finally{try{m&&!m.done&&(t=d.return)&&t.call(d)}finally{if(o)throw o.error}}return v}function _t(g,e,t){if(t||arguments.length===2)for(var d=0,m=e.length,v;d<m;d++)(v||!(d in e))&&(v||(v=Array.prototype.slice.call(e,0,d)),v[d]=e[d]);return g.concat(v||Array.prototype.slice.call(e))}function Qt(g){return this instanceof Qt?(this.v=g,this):new Qt(g)}function Ma(g,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var d=t.apply(g,e||[]),m,v=[];return m=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),i("next"),i("throw"),i("return",o),m[Symbol.asyncIterator]=function(){return this},m;function o(f){return function(h){return Promise.resolve(h).then(f,r)}}function i(f,h){d[f]&&(m[f]=function(l){return new Promise(function(u,p){v.push([f,l,u,p])>1||a(f,l)})},h&&(m[f]=h(m[f])))}function a(f,h){try{n(d[f](h))}catch(l){c(v[0][3],l)}}function n(f){f.value instanceof Qt?Promise.resolve(f.value.v).then(s,r):c(v[0][2],f)}function s(f){a("next",f)}function r(f){a("throw",f)}function c(f,h){f(h),v.shift(),v.length&&a(v[0][0],v[0][1])}}function La(g){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=g[Symbol.asyncIterator],t;return e?e.call(g):(g=typeof ns=="function"?ns(g):g[Symbol.iterator](),t={},d("next"),d("throw"),d("return"),t[Symbol.asyncIterator]=function(){return this},t);function d(v){t[v]=g[v]&&function(o){return new Promise(function(i,a){o=g[v](o),m(i,a,o.done,o.value)})}}function m(v,o,i,a){Promise.resolve(a).then(function(n){v({value:n,done:i})},o)}}function Ne(g){return typeof g=="function"}function Qr(g){var e=function(d){Error.call(d),d.stack=new Error().stack},t=g(e);return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}var qs=Qr(function(g){return function(t){g(this),this.message=t?t.length+` errors occurred during unsubscription:
6541
6541
  `+t.map(function(d,m){return m+1+") "+d.toString()}).join(`
6542
- `):"",this.name="UnsubscriptionError",this.errors=t}});function ks(g,e){if(g){var t=g.indexOf(e);0<=t&&g.splice(t,1)}}var js=function(){function g(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}return g.prototype.unsubscribe=function(){var e,t,d,m,v;if(!this.closed){this.closed=!0;var o=this._parentage;if(o)if(this._parentage=null,Array.isArray(o))try{for(var i=ns(o),a=i.next();!a.done;a=i.next()){var n=a.value;n.remove(this)}}catch(l){e={error:l}}finally{try{a&&!a.done&&(t=i.return)&&t.call(i)}finally{if(e)throw e.error}}else o.remove(this);var s=this.initialTeardown;if(Ne(s))try{s()}catch(l){v=l instanceof qs?l.errors:[l]}var r=this._finalizers;if(r){this._finalizers=null;try{for(var c=ns(r),f=c.next();!f.done;f=c.next()){var h=f.value;try{dr(h)}catch(l){v=v??[],l instanceof qs?v=_t(_t([],pt(v)),pt(l.errors)):v.push(l)}}}catch(l){d={error:l}}finally{try{f&&!f.done&&(m=c.return)&&m.call(c)}finally{if(d)throw d.error}}}if(v)throw new qs(v)}},g.prototype.add=function(e){var t;if(e&&e!==this)if(this.closed)dr(e);else{if(e instanceof g){if(e.closed||e._hasParent(this))return;e._addParent(this)}(this._finalizers=(t=this._finalizers)!==null&&t!==void 0?t:[]).push(e)}},g.prototype._hasParent=function(e){var t=this._parentage;return t===e||Array.isArray(t)&&t.includes(e)},g.prototype._addParent=function(e){var t=this._parentage;this._parentage=Array.isArray(t)?(t.push(e),t):t?[t,e]:e},g.prototype._removeParent=function(e){var t=this._parentage;t===e?this._parentage=null:Array.isArray(t)&&ks(t,e)},g.prototype.remove=function(e){var t=this._finalizers;t&&ks(t,e),e instanceof g&&e._removeParent(this)},g.EMPTY=function(){var e=new g;return e.closed=!0,e}(),g}(),qr=js.EMPTY;function ei(g){return g instanceof js||g&&"closed"in g&&Ne(g.remove)&&Ne(g.add)&&Ne(g.unsubscribe)}function dr(g){Ne(g)?g():g.unsubscribe()}var ka={Promise:void 0},Ba={setTimeout:function(g,e){for(var t=[],d=2;d<arguments.length;d++)t[d-2]=arguments[d];return setTimeout.apply(void 0,_t([g,e],pt(t)))},clearTimeout:function(g){return clearTimeout(g)},delegate:void 0};function ti(g){Ba.setTimeout(function(){throw g})}function bs(){}function Rs(g){g()}var On=function(g){bt(e,g);function e(t){var d=g.call(this)||this;return d.isStopped=!1,t?(d.destination=t,ei(t)&&t.add(d)):d.destination=Ua,d}return e.create=function(t,d,m){return new ys(t,d,m)},e.prototype.next=function(t){this.isStopped||this._next(t)},e.prototype.error=function(t){this.isStopped||(this.isStopped=!0,this._error(t))},e.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},e.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,g.prototype.unsubscribe.call(this),this.destination=null)},e.prototype._next=function(t){this.destination.next(t)},e.prototype._error=function(t){try{this.destination.error(t)}finally{this.unsubscribe()}},e.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},e}(js),Na=function(){function g(e){this.partialObserver=e}return g.prototype.next=function(e){var t=this.partialObserver;if(t.next)try{t.next(e)}catch(d){Is(d)}},g.prototype.error=function(e){var t=this.partialObserver;if(t.error)try{t.error(e)}catch(d){Is(d)}else Is(e)},g.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(t){Is(t)}},g}(),ys=function(g){bt(e,g);function e(t,d,m){var v=g.call(this)||this,o;return Ne(t)||!t?o={next:t??void 0,error:d??void 0,complete:m??void 0}:o=t,v.destination=new Na(o),v}return e}(On);function Is(g){ti(g)}function $a(g){throw g}var Ua={closed:!0,next:bs,error:$a,complete:bs},In=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function Fs(g){return g}function Fa(g){return g.length===0?Fs:g.length===1?g[0]:function(t){return g.reduce(function(d,m){return m(d)},t)}}var Ge=function(){function g(e){e&&(this._subscribe=e)}return g.prototype.lift=function(e){var t=new g;return t.source=this,t.operator=e,t},g.prototype.subscribe=function(e,t,d){var m=this,v=Wa(e)?e:new ys(e,t,d);return Rs(function(){var o=m,i=o.operator,a=o.source;v.add(i?i.call(v,a):a?m._subscribe(v):m._trySubscribe(v))}),v},g.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(t){e.error(t)}},g.prototype.forEach=function(e,t){var d=this;return t=ur(t),new t(function(m,v){var o=new ys({next:function(i){try{e(i)}catch(a){v(a),o.unsubscribe()}},error:v,complete:m});d.subscribe(o)})},g.prototype._subscribe=function(e){var t;return(t=this.source)===null||t===void 0?void 0:t.subscribe(e)},g.prototype[In]=function(){return this},g.prototype.pipe=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Fa(e)(this)},g.prototype.toPromise=function(e){var t=this;return e=ur(e),new e(function(d,m){var v;t.subscribe(function(o){return v=o},function(o){return m(o)},function(){return d(v)})})},g.create=function(e){return new g(e)},g}();function ur(g){var e;return(e=g??ka.Promise)!==null&&e!==void 0?e:Promise}function Va(g){return g&&Ne(g.next)&&Ne(g.error)&&Ne(g.complete)}function Wa(g){return g&&g instanceof On||Va(g)&&ei(g)}function Ha(g){return Ne(g==null?void 0:g.lift)}function et(g){return function(e){if(Ha(e))return e.lift(function(t){try{return g(t,this)}catch(d){this.error(d)}});throw new TypeError("Unable to lift unknown Observable type")}}function Ke(g,e,t,d,m){return new Ka(g,e,t,d,m)}var Ka=function(g){bt(e,g);function e(t,d,m,v,o,i){var a=g.call(this,t)||this;return a.onFinalize=o,a.shouldUnsubscribe=i,a._next=d?function(n){try{d(n)}catch(s){t.error(s)}}:g.prototype._next,a._error=v?function(n){try{v(n)}catch(s){t.error(s)}finally{this.unsubscribe()}}:g.prototype._error,a._complete=m?function(){try{m()}catch(n){t.error(n)}finally{this.unsubscribe()}}:g.prototype._complete,a}return e.prototype.unsubscribe=function(){var t;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var d=this.closed;g.prototype.unsubscribe.call(this),!d&&((t=this.onFinalize)===null||t===void 0||t.call(this))}},e}(On),za=Qr(function(g){return function(){g(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),ot=function(g){bt(e,g);function e(){var t=g.call(this)||this;return t.closed=!1,t.currentObservers=null,t.observers=[],t.isStopped=!1,t.hasError=!1,t.thrownError=null,t}return e.prototype.lift=function(t){var d=new hr(this,this);return d.operator=t,d},e.prototype._throwIfClosed=function(){if(this.closed)throw new za},e.prototype.next=function(t){var d=this;Rs(function(){var m,v;if(d._throwIfClosed(),!d.isStopped){d.currentObservers||(d.currentObservers=Array.from(d.observers));try{for(var o=ns(d.currentObservers),i=o.next();!i.done;i=o.next()){var a=i.value;a.next(t)}}catch(n){m={error:n}}finally{try{i&&!i.done&&(v=o.return)&&v.call(o)}finally{if(m)throw m.error}}}})},e.prototype.error=function(t){var d=this;Rs(function(){if(d._throwIfClosed(),!d.isStopped){d.hasError=d.isStopped=!0,d.thrownError=t;for(var m=d.observers;m.length;)m.shift().error(t)}})},e.prototype.complete=function(){var t=this;Rs(function(){if(t._throwIfClosed(),!t.isStopped){t.isStopped=!0;for(var d=t.observers;d.length;)d.shift().complete()}})},e.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(e.prototype,"observed",{get:function(){var t;return((t=this.observers)===null||t===void 0?void 0:t.length)>0},enumerable:!1,configurable:!0}),e.prototype._trySubscribe=function(t){return this._throwIfClosed(),g.prototype._trySubscribe.call(this,t)},e.prototype._subscribe=function(t){return this._throwIfClosed(),this._checkFinalizedStatuses(t),this._innerSubscribe(t)},e.prototype._innerSubscribe=function(t){var d=this,m=this,v=m.hasError,o=m.isStopped,i=m.observers;return v||o?qr:(this.currentObservers=null,i.push(t),new js(function(){d.currentObservers=null,ks(i,t)}))},e.prototype._checkFinalizedStatuses=function(t){var d=this,m=d.hasError,v=d.thrownError,o=d.isStopped;m?t.error(v):o&&t.complete()},e.prototype.asObservable=function(){var t=new Ge;return t.source=this,t},e.create=function(t,d){return new hr(t,d)},e}(Ge),hr=function(g){bt(e,g);function e(t,d){var m=g.call(this)||this;return m.destination=t,m.source=d,m}return e.prototype.next=function(t){var d,m;(m=(d=this.destination)===null||d===void 0?void 0:d.next)===null||m===void 0||m.call(d,t)},e.prototype.error=function(t){var d,m;(m=(d=this.destination)===null||d===void 0?void 0:d.error)===null||m===void 0||m.call(d,t)},e.prototype.complete=function(){var t,d;(d=(t=this.destination)===null||t===void 0?void 0:t.complete)===null||d===void 0||d.call(t)},e.prototype._subscribe=function(t){var d,m;return(m=(d=this.source)===null||d===void 0?void 0:d.subscribe(t))!==null&&m!==void 0?m:qr},e}(ot),Ga={now:function(){return Date.now()}},Za=function(g){bt(e,g);function e(t,d){return g.call(this)||this}return e.prototype.schedule=function(t,d){return this},e}(js),fr={setInterval:function(g,e){for(var t=[],d=2;d<arguments.length;d++)t[d-2]=arguments[d];return setInterval.apply(void 0,_t([g,e],pt(t)))},clearInterval:function(g){return clearInterval(g)},delegate:void 0},Xa=function(g){bt(e,g);function e(t,d){var m=g.call(this,t,d)||this;return m.scheduler=t,m.work=d,m.pending=!1,m}return e.prototype.schedule=function(t,d){var m;if(d===void 0&&(d=0),this.closed)return this;this.state=t;var v=this.id,o=this.scheduler;return v!=null&&(this.id=this.recycleAsyncId(o,v,d)),this.pending=!0,this.delay=d,this.id=(m=this.id)!==null&&m!==void 0?m:this.requestAsyncId(o,this.id,d),this},e.prototype.requestAsyncId=function(t,d,m){return m===void 0&&(m=0),fr.setInterval(t.flush.bind(t,this),m)},e.prototype.recycleAsyncId=function(t,d,m){if(m===void 0&&(m=0),m!=null&&this.delay===m&&this.pending===!1)return d;d!=null&&fr.clearInterval(d)},e.prototype.execute=function(t,d){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var m=this._execute(t,d);if(m)return m;this.pending===!1&&this.id!=null&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},e.prototype._execute=function(t,d){var m=!1,v;try{this.work(t)}catch(o){m=!0,v=o||new Error("Scheduled action threw falsy error")}if(m)return this.unsubscribe(),v},e.prototype.unsubscribe=function(){if(!this.closed){var t=this,d=t.id,m=t.scheduler,v=m.actions;this.work=this.state=this.scheduler=null,this.pending=!1,ks(v,this),d!=null&&(this.id=this.recycleAsyncId(m,d,null)),this.delay=null,g.prototype.unsubscribe.call(this)}},e}(Za),mr=function(){function g(e,t){t===void 0&&(t=g.now),this.schedulerActionCtor=e,this.now=t}return g.prototype.schedule=function(e,t,d){return t===void 0&&(t=0),new this.schedulerActionCtor(this,e).schedule(d,t)},g.now=Ga.now,g}(),Ya=function(g){bt(e,g);function e(t,d){d===void 0&&(d=mr.now);var m=g.call(this,t,d)||this;return m.actions=[],m._active=!1,m}return e.prototype.flush=function(t){var d=this.actions;if(this._active){d.push(t);return}var m;this._active=!0;do if(m=t.execute(t.state,t.delay))break;while(t=d.shift());if(this._active=!1,m){for(;t=d.shift();)t.unsubscribe();throw m}},e}(mr),Vs=new Ya(Xa),Ja=Vs,si=new Ge(function(g){return g.complete()});function ni(g){return g&&Ne(g.schedule)}function Tn(g){return g[g.length-1]}function Qa(g){return Ne(Tn(g))?g.pop():void 0}function ri(g){return ni(Tn(g))?g.pop():void 0}function qa(g,e){return typeof Tn(g)=="number"?g.pop():e}var xn=function(g){return g&&typeof g.length=="number"&&typeof g!="function"};function ii(g){return Ne(g==null?void 0:g.then)}function oi(g){return Ne(g[In])}function ai(g){return Symbol.asyncIterator&&Ne(g==null?void 0:g[Symbol.asyncIterator])}function li(g){return new TypeError("You provided "+(g!==null&&typeof g=="object"?"an invalid object":"'"+g+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}function el(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var ci=el();function di(g){return Ne(g==null?void 0:g[ci])}function ui(g){return Ma(this,arguments,function(){var t,d,m,v;return Jr(this,function(o){switch(o.label){case 0:t=g.getReader(),o.label=1;case 1:o.trys.push([1,,9,10]),o.label=2;case 2:return[4,Qt(t.read())];case 3:return d=o.sent(),m=d.value,v=d.done,v?[4,Qt(void 0)]:[3,5];case 4:return[2,o.sent()];case 5:return[4,Qt(m)];case 6:return[4,o.sent()];case 7:return o.sent(),[3,2];case 8:return[3,10];case 9:return t.releaseLock(),[7];case 10:return[2]}})})}function hi(g){return Ne(g==null?void 0:g.getReader)}function Ye(g){if(g instanceof Ge)return g;if(g!=null){if(oi(g))return tl(g);if(xn(g))return sl(g);if(ii(g))return nl(g);if(ai(g))return fi(g);if(di(g))return rl(g);if(hi(g))return il(g)}throw li(g)}function tl(g){return new Ge(function(e){var t=g[In]();if(Ne(t.subscribe))return t.subscribe(e);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function sl(g){return new Ge(function(e){for(var t=0;t<g.length&&!e.closed;t++)e.next(g[t]);e.complete()})}function nl(g){return new Ge(function(e){g.then(function(t){e.closed||(e.next(t),e.complete())},function(t){return e.error(t)}).then(null,ti)})}function rl(g){return new Ge(function(e){var t,d;try{for(var m=ns(g),v=m.next();!v.done;v=m.next()){var o=v.value;if(e.next(o),e.closed)return}}catch(i){t={error:i}}finally{try{v&&!v.done&&(d=m.return)&&d.call(m)}finally{if(t)throw t.error}}e.complete()})}function fi(g){return new Ge(function(e){ol(g,e).catch(function(t){return e.error(t)})})}function il(g){return fi(ui(g))}function ol(g,e){var t,d,m,v;return Da(this,void 0,void 0,function(){var o,i;return Jr(this,function(a){switch(a.label){case 0:a.trys.push([0,5,6,11]),t=La(g),a.label=1;case 1:return[4,t.next()];case 2:if(d=a.sent(),!!d.done)return[3,4];if(o=d.value,e.next(o),e.closed)return[2];a.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return i=a.sent(),m={error:i},[3,11];case 6:return a.trys.push([6,,9,10]),d&&!d.done&&(v=t.return)?[4,v.call(t)]:[3,8];case 7:a.sent(),a.label=8;case 8:return[3,10];case 9:if(m)throw m.error;return[7];case 10:return[7];case 11:return e.complete(),[2]}})})}function Gt(g,e,t,d,m){d===void 0&&(d=0),m===void 0&&(m=!1);var v=e.schedule(function(){t(),m?g.add(this.schedule(null,d)):this.unsubscribe()},d);if(g.add(v),!m)return v}function mi(g,e){return e===void 0&&(e=0),et(function(t,d){t.subscribe(Ke(d,function(m){return Gt(d,g,function(){return d.next(m)},e)},function(){return Gt(d,g,function(){return d.complete()},e)},function(m){return Gt(d,g,function(){return d.error(m)},e)}))})}function pi(g,e){return e===void 0&&(e=0),et(function(t,d){d.add(g.schedule(function(){return t.subscribe(d)},e))})}function al(g,e){return Ye(g).pipe(pi(e),mi(e))}function ll(g,e){return Ye(g).pipe(pi(e),mi(e))}function cl(g,e){return new Ge(function(t){var d=0;return e.schedule(function(){d===g.length?t.complete():(t.next(g[d++]),t.closed||this.schedule())})})}function dl(g,e){return new Ge(function(t){var d;return Gt(t,e,function(){d=g[ci](),Gt(t,e,function(){var m,v,o;try{m=d.next(),v=m.value,o=m.done}catch(i){t.error(i);return}o?t.complete():t.next(v)},0,!0)}),function(){return Ne(d==null?void 0:d.return)&&d.return()}})}function vi(g,e){if(!g)throw new Error("Iterable cannot be null");return new Ge(function(t){Gt(t,e,function(){var d=g[Symbol.asyncIterator]();Gt(t,e,function(){d.next().then(function(m){m.done?t.complete():t.next(m.value)})},0,!0)})})}function ul(g,e){return vi(ui(g),e)}function hl(g,e){if(g!=null){if(oi(g))return al(g,e);if(xn(g))return cl(g,e);if(ii(g))return ll(g,e);if(ai(g))return vi(g,e);if(di(g))return dl(g,e);if(hi(g))return ul(g,e)}throw li(g)}function gi(g,e){return e?hl(g,e):Ye(g)}function fl(){for(var g=[],e=0;e<arguments.length;e++)g[e]=arguments[e];var t=ri(g);return gi(g,t)}function ml(g){return g instanceof Date&&!isNaN(g)}function nt(g,e){return et(function(t,d){var m=0;t.subscribe(Ke(d,function(v){d.next(g.call(e,v,m++))}))})}var pl=Array.isArray;function vl(g,e){return pl(e)?g.apply(void 0,_t([],pt(e))):g(e)}function gl(g){return nt(function(e){return vl(g,e)})}function _l(g,e,t,d,m,v,o,i){var a=[],n=0,s=0,r=!1,c=function(){r&&!a.length&&!n&&e.complete()},f=function(l){return n<d?h(l):a.push(l)},h=function(l){n++;var u=!1;Ye(t(l,s++)).subscribe(Ke(e,function(p){e.next(p)},function(){u=!0},void 0,function(){if(u)try{n--;for(var p=function(){var _=a.shift();o||h(_)};a.length&&n<d;)p();c()}catch(_){e.error(_)}}))};return g.subscribe(Ke(e,f,function(){r=!0,c()})),function(){}}function Cs(g,e,t){return t===void 0&&(t=1/0),Ne(e)?Cs(function(d,m){return nt(function(v,o){return e(d,v,m,o)})(Ye(g(d,m)))},t):(typeof e=="number"&&(t=e),et(function(d,m){return _l(d,m,g,t)}))}function bl(g){return g===void 0&&(g=1/0),Cs(Fs,g)}function yl(g){return new Ge(function(e){Ye(g()).subscribe(e)})}var Cl={connector:function(){return new ot},resetOnDisconnect:!0};function Kt(g,e){e===void 0&&(e=Cl);var t=null,d=e.connector,m=e.resetOnDisconnect,v=m===void 0?!0:m,o=d(),i=new Ge(function(a){return o.subscribe(a)});return i.connect=function(){return(!t||t.closed)&&(t=yl(function(){return g}).subscribe(o),v&&t.add(function(){return o=d()})),t},i}var El=["addListener","removeListener"],Sl=["addEventListener","removeEventListener"],jl=["on","off"];function dn(g,e,t,d){if(Ne(t)&&(d=t,t=void 0),d)return dn(g,e,t).pipe(gl(d));var m=pt(Il(g)?Sl.map(function(i){return function(a){return g[i](e,a,t)}}):wl(g)?El.map(pr(g,e)):Ol(g)?jl.map(pr(g,e)):[],2),v=m[0],o=m[1];if(!v&&xn(g))return Cs(function(i){return dn(i,e,t)})(Ye(g));if(!v)throw new TypeError("Invalid event target");return new Ge(function(i){var a=function(){for(var n=[],s=0;s<arguments.length;s++)n[s]=arguments[s];return i.next(1<n.length?n:n[0])};return v(a),function(){return o(a)}})}function pr(g,e){return function(t){return function(d){return g[t](e,d)}}}function wl(g){return Ne(g.addListener)&&Ne(g.removeListener)}function Ol(g){return Ne(g.on)&&Ne(g.off)}function Il(g){return Ne(g.addEventListener)&&Ne(g.removeEventListener)}function ms(g,e,t){g===void 0&&(g=0),t===void 0&&(t=Ja);var d=-1;return e!=null&&(ni(e)?t=e:d=e),new Ge(function(m){var v=ml(g)?+g-t.now():g;v<0&&(v=0);var o=0;return t.schedule(function(){m.closed||(m.next(o++),0<=d?this.schedule(void 0,d):m.complete())},v)})}function Tl(g,e){return e===void 0&&(e=Vs),ms(g,g,e)}function xl(){for(var g=[],e=0;e<arguments.length;e++)g[e]=arguments[e];var t=ri(g),d=qa(g,1/0),m=g;return m.length?m.length===1?Ye(m[0]):bl(d)(gi(m,t)):si}var Al=Array.isArray;function Pl(g){return g.length===1&&Al(g[0])?g[0]:g}function gt(g,e){return et(function(t,d){var m=0;t.subscribe(Ke(d,function(v){return g.call(e,v,m++)&&d.next(v)}))})}function Rl(){for(var g=[],e=0;e<arguments.length;e++)g[e]=arguments[e];return g=Pl(g),g.length===1?Ye(g[0]):new Ge(Dl(g))}function Dl(g){return function(e){for(var t=[],d=function(v){t.push(Ye(g[v]).subscribe(Ke(e,function(o){if(t){for(var i=0;i<t.length;i++)i!==v&&t[i].unsubscribe();t=null}e.next(o)})))},m=0;t&&!e.closed&&m<g.length;m++)d(m)}}function Ml(g){return et(function(e,t){var d=null,m=null,v=function(){m==null||m.unsubscribe();var o=d;d=[],o&&t.next(o),Ye(g()).subscribe(m=Ke(t,v,bs))};v(),e.subscribe(Ke(t,function(o){return d==null?void 0:d.push(o)},function(){d&&t.next(d),t.complete()},void 0,function(){return d=m=null}))})}function _i(g){return et(function(e,t){var d=null,m=!1,v;d=e.subscribe(Ke(t,void 0,void 0,function(o){v=Ye(g(o,_i(g)(e))),d?(d.unsubscribe(),d=null,v.subscribe(t)):m=!0})),m&&(d.unsubscribe(),d=null,v.subscribe(t))})}function Ll(g,e,t,d,m){return function(v,o){var i=t,a=e,n=0;v.subscribe(Ke(o,function(s){var r=n++;a=i?g(a,s,r):(i=!0,s),o.next(a)},m))}}function vr(g){return g<=0?function(){return si}:et(function(e,t){var d=0;e.subscribe(Ke(t,function(m){++d<=g&&(t.next(m),g<=d&&t.complete())}))})}function kl(g){return et(function(e,t){try{e.subscribe(t)}finally{t.add(g)}})}function Bl(g,e){return et(Ll(g,e,arguments.length>=2,!0))}function Nl(g){g===void 0&&(g={});var e=g.connector,t=e===void 0?function(){return new ot}:e,d=g.resetOnError,m=d===void 0?!0:d,v=g.resetOnComplete,o=v===void 0?!0:v,i=g.resetOnRefCountZero,a=i===void 0?!0:i;return function(n){var s,r,c,f=0,h=!1,l=!1,u=function(){r==null||r.unsubscribe(),r=void 0},p=function(){u(),s=c=void 0,h=l=!1},_=function(){var b=s;p(),b==null||b.unsubscribe()};return et(function(b,y){f++,!l&&!h&&u();var C=c=c??t();y.add(function(){f--,f===0&&!l&&!h&&(r=en(_,a))}),C.subscribe(y),!s&&f>0&&(s=new ys({next:function(S){return C.next(S)},error:function(S){l=!0,u(),r=en(p,m,S),C.error(S)},complete:function(){h=!0,u(),r=en(p,o),C.complete()}}),Ye(b).subscribe(s))})(n)}}function en(g,e){for(var t=[],d=2;d<arguments.length;d++)t[d-2]=arguments[d];if(e===!0){g();return}if(e!==!1){var m=new ys({next:function(){m.unsubscribe(),g()}});return Ye(e.apply(void 0,_t([],pt(t)))).subscribe(m)}}function $l(g){return et(function(e,t){var d=!1,m=Ke(t,function(){m==null||m.unsubscribe(),d=!0},bs);Ye(g).subscribe(m),e.subscribe(Ke(t,function(v){return d&&t.next(v)}))})}function gr(g,e){return et(function(t,d){var m=null,v=0,o=!1,i=function(){return o&&!m&&d.complete()};t.subscribe(Ke(d,function(a){m==null||m.unsubscribe();var n=0,s=v++;Ye(g(a,s)).subscribe(m=Ke(d,function(r){return d.next(e?e(a,r,s,n++):r)},function(){m=null,i()}))},function(){o=!0,i()}))})}function Ts(g,e){return e===void 0&&(e=!1),et(function(t,d){var m=0;t.subscribe(Ke(d,function(v){var o=g(v,m++);(o||e)&&d.next(v),!o&&d.complete()}))})}function _r(g,e,t){var d=Ne(g)||e||t?{next:g,error:e,complete:t}:g;return d?et(function(m,v){var o;(o=d.subscribe)===null||o===void 0||o.call(d);var i=!0;m.subscribe(Ke(v,function(a){var n;(n=d.next)===null||n===void 0||n.call(d,a),v.next(a)},function(){var a;i=!1,(a=d.complete)===null||a===void 0||a.call(d),v.complete()},function(a){var n;i=!1,(n=d.error)===null||n===void 0||n.call(d,a),v.error(a)},function(){var a,n;i&&((a=d.unsubscribe)===null||a===void 0||a.call(d)),(n=d.finalize)===null||n===void 0||n.call(d)}))}):Fs}function Ul(g,e){return et(function(t,d){var m=e??{},v=m.leading,o=v===void 0?!0:v,i=m.trailing,a=i===void 0?!1:i,n=!1,s=null,r=null,c=!1,f=function(){r==null||r.unsubscribe(),r=null,a&&(u(),c&&d.complete())},h=function(){r=null,c&&d.complete()},l=function(p){return r=Ye(g(p)).subscribe(Ke(d,f,h))},u=function(){if(n){n=!1;var p=s;s=null,d.next(p),!c&&l(p)}};t.subscribe(Ke(d,function(p){n=!0,s=p,!(r&&!r.closed)&&(o?u():l(p))},function(){c=!0,!(a&&n&&r&&!r.closed)&&d.complete()}))})}function br(g,e,t){e===void 0&&(e=Vs);var d=ms(g,e);return Ul(function(){return d},t)}function tn(){for(var g=[],e=0;e<arguments.length;e++)g[e]=arguments[e];var t=Qa(g);return et(function(d,m){for(var v=g.length,o=new Array(v),i=g.map(function(){return!1}),a=!1,n=function(r){Ye(g[r]).subscribe(Ke(m,function(c){o[r]=c,!a&&!i[r]&&(i[r]=!0,(a=i.every(Fs))&&(i=null))},bs))},s=0;s<v;s++)n(s);d.subscribe(Ke(m,function(r){if(a){var c=_t([r],pt(o));m.next(t?t.apply(void 0,_t([],pt(c))):c)}}))})}const bi="0123456789ABCDEFGHJKMNPQRSTVWXYZ",Bs=32,Fl=16,yi=10,yr=0xffffffffffff;var zt;(function(g){g.Base32IncorrectEncoding="B32_ENC_INVALID",g.DecodeTimeInvalidCharacter="DEC_TIME_CHAR",g.DecodeTimeValueMalformed="DEC_TIME_MALFORMED",g.EncodeTimeNegative="ENC_TIME_NEG",g.EncodeTimeSizeExceeded="ENC_TIME_SIZE_EXCEED",g.EncodeTimeValueMalformed="ENC_TIME_MALFORMED",g.PRNGDetectFailure="PRNG_DETECT",g.ULIDInvalid="ULID_INVALID",g.Unexpected="UNEXPECTED",g.UUIDInvalid="UUID_INVALID"})(zt||(zt={}));class us extends Error{constructor(e,t){super(`${t} (${e})`),this.name="ULIDError",this.code=e}}function Vl(g){const e=Math.floor(g()*Bs)%Bs;return bi.charAt(e)}function Wl(g){const e=Hl(),t=e&&(e.crypto||e.msCrypto)||null;if(typeof(t==null?void 0:t.getRandomValues)=="function")return()=>{const d=new Uint8Array(1);return t.getRandomValues(d),d[0]/255};if(typeof(t==null?void 0:t.randomBytes)=="function")return()=>t.randomBytes(1).readUInt8()/255;throw new us(zt.PRNGDetectFailure,"Failed to find a reliable PRNG")}function Hl(){return Gl()?self:typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:null}function Kl(g,e){let t="";for(;g>0;g--)t=Vl(e)+t;return t}function zl(g,e=yi){if(isNaN(g))throw new us(zt.EncodeTimeValueMalformed,`Time must be a number: ${g}`);if(g>yr)throw new us(zt.EncodeTimeSizeExceeded,`Cannot encode a time larger than ${yr}: ${g}`);if(g<0)throw new us(zt.EncodeTimeNegative,`Time must be positive: ${g}`);if(Number.isInteger(g)===!1)throw new us(zt.EncodeTimeValueMalformed,`Time must be an integer: ${g}`);let t,d="";for(let m=e;m>0;m--)t=g%Bs,d=bi.charAt(t)+d,g=(g-t)/Bs;return d}function Gl(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}function Zl(g,e){const t=Wl(),d=Date.now();return zl(d,yi)+Kl(Fl,t)}const Qe=[];for(let g=0;g<256;++g)Qe.push((g+256).toString(16).slice(1));function Xl(g,e=0){return(Qe[g[e+0]]+Qe[g[e+1]]+Qe[g[e+2]]+Qe[g[e+3]]+"-"+Qe[g[e+4]]+Qe[g[e+5]]+"-"+Qe[g[e+6]]+Qe[g[e+7]]+"-"+Qe[g[e+8]]+Qe[g[e+9]]+"-"+Qe[g[e+10]]+Qe[g[e+11]]+Qe[g[e+12]]+Qe[g[e+13]]+Qe[g[e+14]]+Qe[g[e+15]]).toLowerCase()}let sn;const Yl=new Uint8Array(16);function Jl(){if(!sn){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");sn=crypto.getRandomValues.bind(crypto)}return sn(Yl)}const Ql=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),Cr={randomUUID:Ql};function ql(g,e,t){var m;if(Cr.randomUUID&&!g)return Cr.randomUUID();g=g||{};const d=g.random??((m=g.rng)==null?void 0:m.call(g))??Jl();if(d.length<16)throw new Error("Random bytes length must be >= 16");return d[6]=d[6]&15|64,d[8]=d[8]&63|128,Xl(d)}const ec=5e3,tc=1e3,xs=4e3,Er=1e3;var Ci=(g=>(g.CONTINUOUS="CONTINUOUS",g.INITIAL="INITIAL",g))(Ci||{});class Ei{constructor({knownID:e,runID:t,sequence:d,options:m}){Ue(this,"callback");Ue(this,"queue",new ot);Ue(this,"subscriptions",[]);Ue(this,"reconnect",new ot);Ue(this,"client",new Ge);Ue(this,"_latencies",new ot);Ue(this,"_latenciesConnectable",Kt(this._latencies.asObservable().pipe(Bl((e,t)=>{if(t.latency<0){const d=e.get(t.streamID);d&&e.set(t.streamID,{...d,readyState:t.readyState})}else e.set(t.streamID,t);return e},new Map))));Ue(this,"_errors",new ot);Ue(this,"_errorsConnectable",Kt(this._errors.asObservable()));Ue(this,"_stdout",new ot);Ue(this,"_stderr",new ot);Ue(this,"_exitCode",new ot);Ue(this,"_pid",new ot);Ue(this,"_mimeType",new ot);Ue(this,"_stdoutConnectable",Kt(this._stdout.asObservable()));Ue(this,"_stderrConnectable",Kt(this._stderr.asObservable()));Ue(this,"_exitCodeConnectable",Kt(this._exitCode.asObservable()));Ue(this,"_pidConnectable",Kt(this._pid.asObservable()));Ue(this,"_mimeTypeConnectable",Kt(this._mimeType.asObservable()));Ue(this,"knownID");Ue(this,"runID");Ue(this,"sequence");Ue(this,"runnerEndpoint");Ue(this,"authorization");Ue(this,"autoReconnect");this.knownID=e,this.runID=t,this.sequence=d,this.runnerEndpoint=m.runnerEndpoint,this.authorization=m.authorization,this.autoReconnect=m.autoReconnect,this._latenciesConnectable.connect(),this._errorsConnectable.connect(),this._stdoutConnectable.connect(),this._stderrConnectable.connect(),this._exitCodeConnectable.connect(),this._pidConnectable.connect(),this._mimeTypeConnectable.connect(),this.client=this.reconnect.pipe(br(Er,Vs,{leading:!0,trailing:!0}),gr(v=>this.useSocketClient(v.streamID).pipe(gr(o=>this.useHeartbeat(o,v))))).pipe(Nl()),this.subscriptions.push(this.monitor()),this.subscriptions.push(this.process())}get latencies(){return this._latenciesConnectable}get errors(){return this._errorsConnectable}get stdout(){return this._stdoutConnectable}get stderr(){return this._stderrConnectable}get exitCode(){return this._exitCodeConnectable}get pid(){return this._pidConnectable}get mimeType(){return this._mimeTypeConnectable}monitor(){return Tl(tc).pipe(gt(()=>this.autoReconnect),tn(this.reconnect),gt(([,t])=>t.heartbeat==="CONTINUOUS"),tn(this.latencies),nt(([,t])=>Array.from(t.values()).filter(d=>d.readyState===WebSocket.OPEN&&d.latency>=xs)),gt(t=>t.length>0),br(Er)).subscribe({next:t=>{console.log(new Date,"Triggering reconnect",t),this.connect()},complete:()=>{console.log("Monitor complete")},error:t=>{console.error("Error in monitor",t)}})}process(){const e=this.client.pipe(gt(o=>(o==null?void 0:o.readyState)===WebSocket.OPEN),vr(1)),t=this.queue.pipe(Ml(()=>e),gt(o=>o.length>0),nt(o=>o.sort((i,a)=>{const n=s=>{var r;return!!((r=s.payload.value)!=null&&r.config)};return n(a)?1:n(i)?-1:0}))),d=this.queue.pipe($l(e));return xl(t.pipe(Cs(o=>o)),d).pipe(tn(this.client),Ts(([,o])=>o.readyState===WebSocket.OPEN),nt(([o,i])=>jr({req:o,authorization:this.authorization,socket:i,knownID:this.knownID,runID:this.runID}))).subscribe({error:o=>{this._errors.next(o)}})}useSocketClient(e){return new Ge(t=>{const d=new URL(this.runnerEndpoint);d.searchParams.set("id",e),d.searchParams.set("runID",this.runID);const m=new WebSocket(d.toString()),v=n=>{if(console.log(new Date,`WebSocket transport ${e} closed`,n),n.code===1005){t.complete();return}if(this.autoReconnect){this.connect();return}},o=n=>{console.log(new Date,`WebSocket transport ${e} error`,n),this.autoReconnect||t.error(n)},i=n=>{var f,h;if(typeof n.data!="string"){console.warn("Unexpected WebSocket message type:",typeof n.data);return}let s;try{s=Sr(n.data),console.log("Received WebsocketResponse:",s)}catch(l){console.error("Failed to parse WebsocketResponse:",l)}const r=s.status;if(r&&r.code!==Pa.OK){t.error(r);return}if(s.pong)return;const c=s.payload.value;if(c.stdoutData&&c.stdoutData.length>0&&((f=this.callback)==null||f.call(this,{type:fs.terminalStdout,output:{"runme.dev/id":this.knownID,data:c.stdoutData}}),this._stdout.next(c.stdoutData)),c.stderrData&&c.stderrData.length>0&&((h=this.callback)==null||h.call(this,{type:fs.terminalStderr,output:{"runme.dev/id":this.knownID,data:c.stderrData}}),this._stderr.next(c.stderrData)),c.exitCode!==void 0&&(this._exitCode.next(c.exitCode),t.complete()),c.pid!==void 0&&this._pid.next(c.pid),c.mimeType){const u=c.mimeType.split(";")[0];this._mimeType.next(u)}},a=()=>{console.log(new Date,`✅ Connected WebSocket for block ${this.knownID} (#${this.sequence}) with runID ${this.runID}`),t.next(m)};return m.addEventListener("close",v),m.addEventListener("error",o),m.addEventListener("message",i),m.addEventListener("open",a),()=>{console.log(new Date,`☑️ Cleanly disconnected WebSocket for block ${this.knownID} (#${this.sequence}) with runID ${this.runID}`),m.removeEventListener("close",v),m.removeEventListener("error",o),m.removeEventListener("message",i),m.removeEventListener("open",a),m.close()}})}setCallback(e){this.callback=e}sendExecuteRequest(e){this.queue.next(ht.create(ln,{payload:{value:e,case:"executeRequest"}}))}useHeartbeat(e,{streamID:t,heartbeat:d}){return new Ge(m=>{const v=dn(e,"message").pipe(Ts(()=>e.readyState===WebSocket.OPEN),nt(s=>Sr(s.data)),nt(s=>s.pong),gt(s=>s!==void 0),nt(s=>({receivedAt:BigInt(Date.now()),pong:s}))),a=(d==="INITIAL"?ms(0):ms(0,ec)).pipe(Ts(()=>e.readyState===WebSocket.OPEN),nt(()=>{const s={timestamp:BigInt(Date.now())};return ht.create(ln,{ping:s})}),_r(s=>{jr({req:s,authorization:this.authorization,socket:e})}),nt(s=>s.ping)).pipe(gt(s=>(s==null?void 0:s.timestamp)!==void 0),Cs(s=>Rl(v.pipe(gt(r=>r.pong.timestamp===s.timestamp),vr(1),nt(r=>{const c=s.timestamp,f=r.receivedAt;return Number(f-c)})),ms(xs).pipe(nt(()=>{throw new Error(`Pong not received within ${xs}ms for stream ${t}`)}))).pipe(_i(r=>(this._latencies.next({streamID:t,latency:xs,readyState:e.readyState,updatedAt:BigInt(Date.now())}),console.log(new Date,"Ping deadline exceeded",r.message),fl(null))))),kl(()=>{this._latencies.next({streamID:t,latency:-1,readyState:e.readyState,updatedAt:BigInt(Date.now())})}),_r(s=>{s!==null&&this._latencies.next({streamID:t,latency:s,readyState:e.readyState,updatedAt:BigInt(Date.now())})})),n=[];return n.push(a.subscribe({error:s=>{console.error("Unexpected error sending heartbeat",s)}})),m.next(e),()=>{n.forEach(s=>s.unsubscribe())}})}connect(e="CONTINUOUS"){const t=sc(),d=this.latencies.pipe(nt(m=>{const v=m.get(t);return v===void 0?null:v}),Ts(m=>(m==null?void 0:m.readyState)===WebSocket.OPEN));return this.reconnect.next({streamID:t,heartbeat:e}),d}close(){this.reconnect.complete(),this.queue.complete(),this._latencies.complete(),this.subscriptions.forEach(e=>e.unsubscribe())}}function Sr(g){const e=JSON.parse(g);return ht.fromJson(Ra,e)}function jr({req:g,authorization:e,socket:t,knownID:d,runID:m}){d&&(g.knownId=d),m&&(g.runId=m);const{bearerToken:v}=e;v&&g&&(g.authorization=`Bearer ${v}`),t.send(JSON.stringify(ht.toJson(ln,g)))}function sc(){return ql().replace(/-/g,"")}function nc(){return`run_${Zl()}`}function rc({blockID:g,runID:e,sequence:t,commands:d,runner:m,settings:v={},onStdout:o,onStderr:i,onExitCode:a,onPid:n,onMimeType:s}){var S;const{rows:r=20,className:c,fontSize:f=12,fontFamily:h="monospace",takeFocus:l=!0,scrollToFit:u=!0}=v,p=ct.useMemo(()=>{if(!(!g||!e||!m.endpoint))return console.log("Creating stream",g,e,m.endpoint),new Ei({knownID:g,runID:e,sequence:t,options:{runnerEndpoint:m.endpoint,authorization:m.authorization,autoReconnect:m.reconnect}})},[g,e,t,m]);ct.useEffect(()=>{const E=p==null?void 0:p.connect().subscribe(j=>console.log(`Heartbeat latency for streamID ${j==null?void 0:j.streamID} (${(j==null?void 0:j.readyState)===1?"open":"closed"}): ${j==null?void 0:j.latency}ms`));return()=>{E==null||E.unsubscribe(),p==null||p.close()}},[p]);let _=ht.create(lr,{rows:34,cols:100,x:0,y:0});const b=ct.useMemo(()=>ht.create(Qs,{sessionStrategy:Ia.MOST_RECENT,storeStdoutInEnv:!0,config:{languageId:"sh",background:!1,fileExtension:"",env:[`RUNME_ID=${g}`,"RUNME_RUNNER=v2","TERM=xterm-256color"],source:{case:"commands",value:{items:d}},interactive:!0,mode:wa.INLINE,runId:e,knownId:g},winsize:_}),[g,d,_]),y=ct.useMemo(()=>{var E;return{output:{"runme.dev/id":(E=b.config)==null?void 0:E.knownId,fontFamily:h||"monospace",fontSize:f||12,cursorStyle:"block",cursorBlink:!0,cursorWidth:1,takeFocus:l,scrollToFit:u,smoothScrollDuration:0,scrollback:4e3,initialRows:r,content:"",isAutoSaveEnabled:!1,isPlatformAuthEnabled:!1}}},[h,f,l,r,(S=b.config)==null?void 0:S.knownId,u]),C=new TextEncoder;return xa({postMessage:E=>{if(E.type===fs.terminalOpen||E.type===fs.terminalResize){const j=Number(E.output.terminalDimensions.columns),O=Number(E.output.terminalDimensions.rows);if(Number.isFinite(j)&&Number.isFinite(O)){if(_.cols===j&&_.rows===O)return;_=ht.create(lr,{cols:j,rows:O,x:0,y:0});const I=ht.create(Qs,{winsize:_});p==null||p.sendExecuteRequest(I)}}if(E.type===fs.terminalStdin){const j=C.encode(E.output.input),O=ht.create(Qs,{inputData:j});p==null||p.sendExecuteRequest(O)}},onDidReceiveMessage:E=>{p==null||p.setCallback(E)}}),ct.useEffect(()=>{const E=p==null?void 0:p.stdout.subscribe(j=>{o==null||o(j)});return()=>E==null?void 0:E.unsubscribe()},[p,o]),ct.useEffect(()=>{const E=p==null?void 0:p.stderr.subscribe(j=>{i==null||i(j)});return()=>E==null?void 0:E.unsubscribe()},[p,i]),ct.useEffect(()=>{const E=p==null?void 0:p.exitCode.subscribe(j=>{a==null||a(j),p==null||p.close()});return()=>E==null?void 0:E.unsubscribe()},[p,a]),ct.useEffect(()=>{const E=p==null?void 0:p.pid.subscribe(j=>{n==null||n(j)});return()=>E==null?void 0:E.unsubscribe()},[p,n]),ct.useEffect(()=>{const E=p==null?void 0:p.mimeType.subscribe(j=>{s==null||s(j)});return()=>E==null?void 0:E.unsubscribe()},[p,s]),ct.useEffect(()=>{!p||!b||(console.log("useEffect invoked - Commands changed:",JSON.stringify(b.config.source.value)),p==null||p.sendExecuteRequest(b))},[b,p]),no.jsx("div",{className:c,ref:E=>{if(!E||E.hasChildNodes())return;const j=document.createElement("terminal-view");j.setAttribute("buttons","false"),j.setAttribute("id",y.output["runme.dev/id"]),j.setAttribute("fontFamily",y.output.fontFamily),typeof y.output.fontSize=="number"&&j.setAttribute("fontSize",y.output.fontSize.toString()),y.output.cursorStyle&&j.setAttribute("cursorStyle",y.output.cursorStyle),typeof y.output.cursorBlink=="boolean"&&j.setAttribute("cursorBlink",y.output.cursorBlink?"true":"false"),typeof y.output.cursorWidth=="number"&&j.setAttribute("cursorWidth",y.output.cursorWidth.toString()),typeof y.output.takeFocus=="boolean"&&j.setAttribute("takeFocus",y.output.takeFocus?"true":"false"),typeof y.output.smoothScrollDuration=="number"&&j.setAttribute("smoothScrollDuration",y.output.smoothScrollDuration.toString()),typeof y.output.scrollback=="number"&&j.setAttribute("scrollback",y.output.scrollback.toString()),y.output.initialRows!==void 0&&j.setAttribute("initialRows",y.output.initialRows.toString()),y.output.content!==void 0&&j.setAttribute("initialContent",y.output.content),y.output.isAutoSaveEnabled&&j.setAttribute("isAutoSaveEnabled",y.output.isAutoSaveEnabled.toString()),y.output.isPlatformAuthEnabled&&j.setAttribute("isPlatformAuthEnabled",y.output.isPlatformAuthEnabled.toString()),E.appendChild(j);const O=document.createElement("div");O.setAttribute("className","h-1"),E.appendChild(O),setTimeout(()=>{u&&!ic(O)&&O.scrollIntoView({behavior:"smooth"})},0)}})}function ic(g){const e=g.getBoundingClientRect();return e.top>=0&&e.left>=0&&e.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&e.right<=(window.innerWidth||document.documentElement.clientWidth)}exports.Console=rc;exports.Heartbeat=Ci;exports.Streams=Ei;exports.genRunID=nc;
6542
+ `):"",this.name="UnsubscriptionError",this.errors=t}});function ks(g,e){if(g){var t=g.indexOf(e);0<=t&&g.splice(t,1)}}var js=function(){function g(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}return g.prototype.unsubscribe=function(){var e,t,d,m,v;if(!this.closed){this.closed=!0;var o=this._parentage;if(o)if(this._parentage=null,Array.isArray(o))try{for(var i=ns(o),a=i.next();!a.done;a=i.next()){var n=a.value;n.remove(this)}}catch(l){e={error:l}}finally{try{a&&!a.done&&(t=i.return)&&t.call(i)}finally{if(e)throw e.error}}else o.remove(this);var s=this.initialTeardown;if(Ne(s))try{s()}catch(l){v=l instanceof qs?l.errors:[l]}var r=this._finalizers;if(r){this._finalizers=null;try{for(var c=ns(r),f=c.next();!f.done;f=c.next()){var h=f.value;try{dr(h)}catch(l){v=v??[],l instanceof qs?v=_t(_t([],pt(v)),pt(l.errors)):v.push(l)}}}catch(l){d={error:l}}finally{try{f&&!f.done&&(m=c.return)&&m.call(c)}finally{if(d)throw d.error}}}if(v)throw new qs(v)}},g.prototype.add=function(e){var t;if(e&&e!==this)if(this.closed)dr(e);else{if(e instanceof g){if(e.closed||e._hasParent(this))return;e._addParent(this)}(this._finalizers=(t=this._finalizers)!==null&&t!==void 0?t:[]).push(e)}},g.prototype._hasParent=function(e){var t=this._parentage;return t===e||Array.isArray(t)&&t.includes(e)},g.prototype._addParent=function(e){var t=this._parentage;this._parentage=Array.isArray(t)?(t.push(e),t):t?[t,e]:e},g.prototype._removeParent=function(e){var t=this._parentage;t===e?this._parentage=null:Array.isArray(t)&&ks(t,e)},g.prototype.remove=function(e){var t=this._finalizers;t&&ks(t,e),e instanceof g&&e._removeParent(this)},g.EMPTY=function(){var e=new g;return e.closed=!0,e}(),g}(),qr=js.EMPTY;function ei(g){return g instanceof js||g&&"closed"in g&&Ne(g.remove)&&Ne(g.add)&&Ne(g.unsubscribe)}function dr(g){Ne(g)?g():g.unsubscribe()}var ka={Promise:void 0},Ba={setTimeout:function(g,e){for(var t=[],d=2;d<arguments.length;d++)t[d-2]=arguments[d];return setTimeout.apply(void 0,_t([g,e],pt(t)))},clearTimeout:function(g){return clearTimeout(g)},delegate:void 0};function ti(g){Ba.setTimeout(function(){throw g})}function bs(){}function Rs(g){g()}var On=function(g){bt(e,g);function e(t){var d=g.call(this)||this;return d.isStopped=!1,t?(d.destination=t,ei(t)&&t.add(d)):d.destination=Ua,d}return e.create=function(t,d,m){return new ys(t,d,m)},e.prototype.next=function(t){this.isStopped||this._next(t)},e.prototype.error=function(t){this.isStopped||(this.isStopped=!0,this._error(t))},e.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},e.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,g.prototype.unsubscribe.call(this),this.destination=null)},e.prototype._next=function(t){this.destination.next(t)},e.prototype._error=function(t){try{this.destination.error(t)}finally{this.unsubscribe()}},e.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},e}(js),Na=function(){function g(e){this.partialObserver=e}return g.prototype.next=function(e){var t=this.partialObserver;if(t.next)try{t.next(e)}catch(d){Is(d)}},g.prototype.error=function(e){var t=this.partialObserver;if(t.error)try{t.error(e)}catch(d){Is(d)}else Is(e)},g.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(t){Is(t)}},g}(),ys=function(g){bt(e,g);function e(t,d,m){var v=g.call(this)||this,o;return Ne(t)||!t?o={next:t??void 0,error:d??void 0,complete:m??void 0}:o=t,v.destination=new Na(o),v}return e}(On);function Is(g){ti(g)}function $a(g){throw g}var Ua={closed:!0,next:bs,error:$a,complete:bs},In=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function Fs(g){return g}function Fa(g){return g.length===0?Fs:g.length===1?g[0]:function(t){return g.reduce(function(d,m){return m(d)},t)}}var Ge=function(){function g(e){e&&(this._subscribe=e)}return g.prototype.lift=function(e){var t=new g;return t.source=this,t.operator=e,t},g.prototype.subscribe=function(e,t,d){var m=this,v=Wa(e)?e:new ys(e,t,d);return Rs(function(){var o=m,i=o.operator,a=o.source;v.add(i?i.call(v,a):a?m._subscribe(v):m._trySubscribe(v))}),v},g.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(t){e.error(t)}},g.prototype.forEach=function(e,t){var d=this;return t=ur(t),new t(function(m,v){var o=new ys({next:function(i){try{e(i)}catch(a){v(a),o.unsubscribe()}},error:v,complete:m});d.subscribe(o)})},g.prototype._subscribe=function(e){var t;return(t=this.source)===null||t===void 0?void 0:t.subscribe(e)},g.prototype[In]=function(){return this},g.prototype.pipe=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Fa(e)(this)},g.prototype.toPromise=function(e){var t=this;return e=ur(e),new e(function(d,m){var v;t.subscribe(function(o){return v=o},function(o){return m(o)},function(){return d(v)})})},g.create=function(e){return new g(e)},g}();function ur(g){var e;return(e=g??ka.Promise)!==null&&e!==void 0?e:Promise}function Va(g){return g&&Ne(g.next)&&Ne(g.error)&&Ne(g.complete)}function Wa(g){return g&&g instanceof On||Va(g)&&ei(g)}function Ha(g){return Ne(g==null?void 0:g.lift)}function et(g){return function(e){if(Ha(e))return e.lift(function(t){try{return g(t,this)}catch(d){this.error(d)}});throw new TypeError("Unable to lift unknown Observable type")}}function Ke(g,e,t,d,m){return new Ka(g,e,t,d,m)}var Ka=function(g){bt(e,g);function e(t,d,m,v,o,i){var a=g.call(this,t)||this;return a.onFinalize=o,a.shouldUnsubscribe=i,a._next=d?function(n){try{d(n)}catch(s){t.error(s)}}:g.prototype._next,a._error=v?function(n){try{v(n)}catch(s){t.error(s)}finally{this.unsubscribe()}}:g.prototype._error,a._complete=m?function(){try{m()}catch(n){t.error(n)}finally{this.unsubscribe()}}:g.prototype._complete,a}return e.prototype.unsubscribe=function(){var t;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var d=this.closed;g.prototype.unsubscribe.call(this),!d&&((t=this.onFinalize)===null||t===void 0||t.call(this))}},e}(On),za=Qr(function(g){return function(){g(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),ot=function(g){bt(e,g);function e(){var t=g.call(this)||this;return t.closed=!1,t.currentObservers=null,t.observers=[],t.isStopped=!1,t.hasError=!1,t.thrownError=null,t}return e.prototype.lift=function(t){var d=new hr(this,this);return d.operator=t,d},e.prototype._throwIfClosed=function(){if(this.closed)throw new za},e.prototype.next=function(t){var d=this;Rs(function(){var m,v;if(d._throwIfClosed(),!d.isStopped){d.currentObservers||(d.currentObservers=Array.from(d.observers));try{for(var o=ns(d.currentObservers),i=o.next();!i.done;i=o.next()){var a=i.value;a.next(t)}}catch(n){m={error:n}}finally{try{i&&!i.done&&(v=o.return)&&v.call(o)}finally{if(m)throw m.error}}}})},e.prototype.error=function(t){var d=this;Rs(function(){if(d._throwIfClosed(),!d.isStopped){d.hasError=d.isStopped=!0,d.thrownError=t;for(var m=d.observers;m.length;)m.shift().error(t)}})},e.prototype.complete=function(){var t=this;Rs(function(){if(t._throwIfClosed(),!t.isStopped){t.isStopped=!0;for(var d=t.observers;d.length;)d.shift().complete()}})},e.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(e.prototype,"observed",{get:function(){var t;return((t=this.observers)===null||t===void 0?void 0:t.length)>0},enumerable:!1,configurable:!0}),e.prototype._trySubscribe=function(t){return this._throwIfClosed(),g.prototype._trySubscribe.call(this,t)},e.prototype._subscribe=function(t){return this._throwIfClosed(),this._checkFinalizedStatuses(t),this._innerSubscribe(t)},e.prototype._innerSubscribe=function(t){var d=this,m=this,v=m.hasError,o=m.isStopped,i=m.observers;return v||o?qr:(this.currentObservers=null,i.push(t),new js(function(){d.currentObservers=null,ks(i,t)}))},e.prototype._checkFinalizedStatuses=function(t){var d=this,m=d.hasError,v=d.thrownError,o=d.isStopped;m?t.error(v):o&&t.complete()},e.prototype.asObservable=function(){var t=new Ge;return t.source=this,t},e.create=function(t,d){return new hr(t,d)},e}(Ge),hr=function(g){bt(e,g);function e(t,d){var m=g.call(this)||this;return m.destination=t,m.source=d,m}return e.prototype.next=function(t){var d,m;(m=(d=this.destination)===null||d===void 0?void 0:d.next)===null||m===void 0||m.call(d,t)},e.prototype.error=function(t){var d,m;(m=(d=this.destination)===null||d===void 0?void 0:d.error)===null||m===void 0||m.call(d,t)},e.prototype.complete=function(){var t,d;(d=(t=this.destination)===null||t===void 0?void 0:t.complete)===null||d===void 0||d.call(t)},e.prototype._subscribe=function(t){var d,m;return(m=(d=this.source)===null||d===void 0?void 0:d.subscribe(t))!==null&&m!==void 0?m:qr},e}(ot),Ga={now:function(){return Date.now()}},Za=function(g){bt(e,g);function e(t,d){return g.call(this)||this}return e.prototype.schedule=function(t,d){return this},e}(js),fr={setInterval:function(g,e){for(var t=[],d=2;d<arguments.length;d++)t[d-2]=arguments[d];return setInterval.apply(void 0,_t([g,e],pt(t)))},clearInterval:function(g){return clearInterval(g)},delegate:void 0},Xa=function(g){bt(e,g);function e(t,d){var m=g.call(this,t,d)||this;return m.scheduler=t,m.work=d,m.pending=!1,m}return e.prototype.schedule=function(t,d){var m;if(d===void 0&&(d=0),this.closed)return this;this.state=t;var v=this.id,o=this.scheduler;return v!=null&&(this.id=this.recycleAsyncId(o,v,d)),this.pending=!0,this.delay=d,this.id=(m=this.id)!==null&&m!==void 0?m:this.requestAsyncId(o,this.id,d),this},e.prototype.requestAsyncId=function(t,d,m){return m===void 0&&(m=0),fr.setInterval(t.flush.bind(t,this),m)},e.prototype.recycleAsyncId=function(t,d,m){if(m===void 0&&(m=0),m!=null&&this.delay===m&&this.pending===!1)return d;d!=null&&fr.clearInterval(d)},e.prototype.execute=function(t,d){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var m=this._execute(t,d);if(m)return m;this.pending===!1&&this.id!=null&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},e.prototype._execute=function(t,d){var m=!1,v;try{this.work(t)}catch(o){m=!0,v=o||new Error("Scheduled action threw falsy error")}if(m)return this.unsubscribe(),v},e.prototype.unsubscribe=function(){if(!this.closed){var t=this,d=t.id,m=t.scheduler,v=m.actions;this.work=this.state=this.scheduler=null,this.pending=!1,ks(v,this),d!=null&&(this.id=this.recycleAsyncId(m,d,null)),this.delay=null,g.prototype.unsubscribe.call(this)}},e}(Za),mr=function(){function g(e,t){t===void 0&&(t=g.now),this.schedulerActionCtor=e,this.now=t}return g.prototype.schedule=function(e,t,d){return t===void 0&&(t=0),new this.schedulerActionCtor(this,e).schedule(d,t)},g.now=Ga.now,g}(),Ya=function(g){bt(e,g);function e(t,d){d===void 0&&(d=mr.now);var m=g.call(this,t,d)||this;return m.actions=[],m._active=!1,m}return e.prototype.flush=function(t){var d=this.actions;if(this._active){d.push(t);return}var m;this._active=!0;do if(m=t.execute(t.state,t.delay))break;while(t=d.shift());if(this._active=!1,m){for(;t=d.shift();)t.unsubscribe();throw m}},e}(mr),Vs=new Ya(Xa),Ja=Vs,si=new Ge(function(g){return g.complete()});function ni(g){return g&&Ne(g.schedule)}function Tn(g){return g[g.length-1]}function Qa(g){return Ne(Tn(g))?g.pop():void 0}function ri(g){return ni(Tn(g))?g.pop():void 0}function qa(g,e){return typeof Tn(g)=="number"?g.pop():e}var xn=function(g){return g&&typeof g.length=="number"&&typeof g!="function"};function ii(g){return Ne(g==null?void 0:g.then)}function oi(g){return Ne(g[In])}function ai(g){return Symbol.asyncIterator&&Ne(g==null?void 0:g[Symbol.asyncIterator])}function li(g){return new TypeError("You provided "+(g!==null&&typeof g=="object"?"an invalid object":"'"+g+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}function el(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var ci=el();function di(g){return Ne(g==null?void 0:g[ci])}function ui(g){return Ma(this,arguments,function(){var t,d,m,v;return Jr(this,function(o){switch(o.label){case 0:t=g.getReader(),o.label=1;case 1:o.trys.push([1,,9,10]),o.label=2;case 2:return[4,Qt(t.read())];case 3:return d=o.sent(),m=d.value,v=d.done,v?[4,Qt(void 0)]:[3,5];case 4:return[2,o.sent()];case 5:return[4,Qt(m)];case 6:return[4,o.sent()];case 7:return o.sent(),[3,2];case 8:return[3,10];case 9:return t.releaseLock(),[7];case 10:return[2]}})})}function hi(g){return Ne(g==null?void 0:g.getReader)}function Ye(g){if(g instanceof Ge)return g;if(g!=null){if(oi(g))return tl(g);if(xn(g))return sl(g);if(ii(g))return nl(g);if(ai(g))return fi(g);if(di(g))return rl(g);if(hi(g))return il(g)}throw li(g)}function tl(g){return new Ge(function(e){var t=g[In]();if(Ne(t.subscribe))return t.subscribe(e);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function sl(g){return new Ge(function(e){for(var t=0;t<g.length&&!e.closed;t++)e.next(g[t]);e.complete()})}function nl(g){return new Ge(function(e){g.then(function(t){e.closed||(e.next(t),e.complete())},function(t){return e.error(t)}).then(null,ti)})}function rl(g){return new Ge(function(e){var t,d;try{for(var m=ns(g),v=m.next();!v.done;v=m.next()){var o=v.value;if(e.next(o),e.closed)return}}catch(i){t={error:i}}finally{try{v&&!v.done&&(d=m.return)&&d.call(m)}finally{if(t)throw t.error}}e.complete()})}function fi(g){return new Ge(function(e){ol(g,e).catch(function(t){return e.error(t)})})}function il(g){return fi(ui(g))}function ol(g,e){var t,d,m,v;return Da(this,void 0,void 0,function(){var o,i;return Jr(this,function(a){switch(a.label){case 0:a.trys.push([0,5,6,11]),t=La(g),a.label=1;case 1:return[4,t.next()];case 2:if(d=a.sent(),!!d.done)return[3,4];if(o=d.value,e.next(o),e.closed)return[2];a.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return i=a.sent(),m={error:i},[3,11];case 6:return a.trys.push([6,,9,10]),d&&!d.done&&(v=t.return)?[4,v.call(t)]:[3,8];case 7:a.sent(),a.label=8;case 8:return[3,10];case 9:if(m)throw m.error;return[7];case 10:return[7];case 11:return e.complete(),[2]}})})}function Gt(g,e,t,d,m){d===void 0&&(d=0),m===void 0&&(m=!1);var v=e.schedule(function(){t(),m?g.add(this.schedule(null,d)):this.unsubscribe()},d);if(g.add(v),!m)return v}function mi(g,e){return e===void 0&&(e=0),et(function(t,d){t.subscribe(Ke(d,function(m){return Gt(d,g,function(){return d.next(m)},e)},function(){return Gt(d,g,function(){return d.complete()},e)},function(m){return Gt(d,g,function(){return d.error(m)},e)}))})}function pi(g,e){return e===void 0&&(e=0),et(function(t,d){d.add(g.schedule(function(){return t.subscribe(d)},e))})}function al(g,e){return Ye(g).pipe(pi(e),mi(e))}function ll(g,e){return Ye(g).pipe(pi(e),mi(e))}function cl(g,e){return new Ge(function(t){var d=0;return e.schedule(function(){d===g.length?t.complete():(t.next(g[d++]),t.closed||this.schedule())})})}function dl(g,e){return new Ge(function(t){var d;return Gt(t,e,function(){d=g[ci](),Gt(t,e,function(){var m,v,o;try{m=d.next(),v=m.value,o=m.done}catch(i){t.error(i);return}o?t.complete():t.next(v)},0,!0)}),function(){return Ne(d==null?void 0:d.return)&&d.return()}})}function vi(g,e){if(!g)throw new Error("Iterable cannot be null");return new Ge(function(t){Gt(t,e,function(){var d=g[Symbol.asyncIterator]();Gt(t,e,function(){d.next().then(function(m){m.done?t.complete():t.next(m.value)})},0,!0)})})}function ul(g,e){return vi(ui(g),e)}function hl(g,e){if(g!=null){if(oi(g))return al(g,e);if(xn(g))return cl(g,e);if(ii(g))return ll(g,e);if(ai(g))return vi(g,e);if(di(g))return dl(g,e);if(hi(g))return ul(g,e)}throw li(g)}function gi(g,e){return e?hl(g,e):Ye(g)}function fl(){for(var g=[],e=0;e<arguments.length;e++)g[e]=arguments[e];var t=ri(g);return gi(g,t)}function ml(g){return g instanceof Date&&!isNaN(g)}function nt(g,e){return et(function(t,d){var m=0;t.subscribe(Ke(d,function(v){d.next(g.call(e,v,m++))}))})}var pl=Array.isArray;function vl(g,e){return pl(e)?g.apply(void 0,_t([],pt(e))):g(e)}function gl(g){return nt(function(e){return vl(g,e)})}function _l(g,e,t,d,m,v,o,i){var a=[],n=0,s=0,r=!1,c=function(){r&&!a.length&&!n&&e.complete()},f=function(l){return n<d?h(l):a.push(l)},h=function(l){n++;var u=!1;Ye(t(l,s++)).subscribe(Ke(e,function(p){e.next(p)},function(){u=!0},void 0,function(){if(u)try{n--;for(var p=function(){var _=a.shift();o||h(_)};a.length&&n<d;)p();c()}catch(_){e.error(_)}}))};return g.subscribe(Ke(e,f,function(){r=!0,c()})),function(){}}function Cs(g,e,t){return t===void 0&&(t=1/0),Ne(e)?Cs(function(d,m){return nt(function(v,o){return e(d,v,m,o)})(Ye(g(d,m)))},t):(typeof e=="number"&&(t=e),et(function(d,m){return _l(d,m,g,t)}))}function bl(g){return g===void 0&&(g=1/0),Cs(Fs,g)}function yl(g){return new Ge(function(e){Ye(g()).subscribe(e)})}var Cl={connector:function(){return new ot},resetOnDisconnect:!0};function Kt(g,e){e===void 0&&(e=Cl);var t=null,d=e.connector,m=e.resetOnDisconnect,v=m===void 0?!0:m,o=d(),i=new Ge(function(a){return o.subscribe(a)});return i.connect=function(){return(!t||t.closed)&&(t=yl(function(){return g}).subscribe(o),v&&t.add(function(){return o=d()})),t},i}var El=["addListener","removeListener"],Sl=["addEventListener","removeEventListener"],jl=["on","off"];function dn(g,e,t,d){if(Ne(t)&&(d=t,t=void 0),d)return dn(g,e,t).pipe(gl(d));var m=pt(Il(g)?Sl.map(function(i){return function(a){return g[i](e,a,t)}}):wl(g)?El.map(pr(g,e)):Ol(g)?jl.map(pr(g,e)):[],2),v=m[0],o=m[1];if(!v&&xn(g))return Cs(function(i){return dn(i,e,t)})(Ye(g));if(!v)throw new TypeError("Invalid event target");return new Ge(function(i){var a=function(){for(var n=[],s=0;s<arguments.length;s++)n[s]=arguments[s];return i.next(1<n.length?n:n[0])};return v(a),function(){return o(a)}})}function pr(g,e){return function(t){return function(d){return g[t](e,d)}}}function wl(g){return Ne(g.addListener)&&Ne(g.removeListener)}function Ol(g){return Ne(g.on)&&Ne(g.off)}function Il(g){return Ne(g.addEventListener)&&Ne(g.removeEventListener)}function ms(g,e,t){g===void 0&&(g=0),t===void 0&&(t=Ja);var d=-1;return e!=null&&(ni(e)?t=e:d=e),new Ge(function(m){var v=ml(g)?+g-t.now():g;v<0&&(v=0);var o=0;return t.schedule(function(){m.closed||(m.next(o++),0<=d?this.schedule(void 0,d):m.complete())},v)})}function Tl(g,e){return e===void 0&&(e=Vs),ms(g,g,e)}function xl(){for(var g=[],e=0;e<arguments.length;e++)g[e]=arguments[e];var t=ri(g),d=qa(g,1/0),m=g;return m.length?m.length===1?Ye(m[0]):bl(d)(gi(m,t)):si}var Al=Array.isArray;function Pl(g){return g.length===1&&Al(g[0])?g[0]:g}function gt(g,e){return et(function(t,d){var m=0;t.subscribe(Ke(d,function(v){return g.call(e,v,m++)&&d.next(v)}))})}function Rl(){for(var g=[],e=0;e<arguments.length;e++)g[e]=arguments[e];return g=Pl(g),g.length===1?Ye(g[0]):new Ge(Dl(g))}function Dl(g){return function(e){for(var t=[],d=function(v){t.push(Ye(g[v]).subscribe(Ke(e,function(o){if(t){for(var i=0;i<t.length;i++)i!==v&&t[i].unsubscribe();t=null}e.next(o)})))},m=0;t&&!e.closed&&m<g.length;m++)d(m)}}function Ml(g){return et(function(e,t){var d=null,m=null,v=function(){m==null||m.unsubscribe();var o=d;d=[],o&&t.next(o),Ye(g()).subscribe(m=Ke(t,v,bs))};v(),e.subscribe(Ke(t,function(o){return d==null?void 0:d.push(o)},function(){d&&t.next(d),t.complete()},void 0,function(){return d=m=null}))})}function _i(g){return et(function(e,t){var d=null,m=!1,v;d=e.subscribe(Ke(t,void 0,void 0,function(o){v=Ye(g(o,_i(g)(e))),d?(d.unsubscribe(),d=null,v.subscribe(t)):m=!0})),m&&(d.unsubscribe(),d=null,v.subscribe(t))})}function Ll(g,e,t,d,m){return function(v,o){var i=t,a=e,n=0;v.subscribe(Ke(o,function(s){var r=n++;a=i?g(a,s,r):(i=!0,s),o.next(a)},m))}}function vr(g){return g<=0?function(){return si}:et(function(e,t){var d=0;e.subscribe(Ke(t,function(m){++d<=g&&(t.next(m),g<=d&&t.complete())}))})}function kl(g){return et(function(e,t){try{e.subscribe(t)}finally{t.add(g)}})}function Bl(g,e){return et(Ll(g,e,arguments.length>=2,!0))}function Nl(g){g===void 0&&(g={});var e=g.connector,t=e===void 0?function(){return new ot}:e,d=g.resetOnError,m=d===void 0?!0:d,v=g.resetOnComplete,o=v===void 0?!0:v,i=g.resetOnRefCountZero,a=i===void 0?!0:i;return function(n){var s,r,c,f=0,h=!1,l=!1,u=function(){r==null||r.unsubscribe(),r=void 0},p=function(){u(),s=c=void 0,h=l=!1},_=function(){var b=s;p(),b==null||b.unsubscribe()};return et(function(b,y){f++,!l&&!h&&u();var C=c=c??t();y.add(function(){f--,f===0&&!l&&!h&&(r=en(_,a))}),C.subscribe(y),!s&&f>0&&(s=new ys({next:function(S){return C.next(S)},error:function(S){l=!0,u(),r=en(p,m,S),C.error(S)},complete:function(){h=!0,u(),r=en(p,o),C.complete()}}),Ye(b).subscribe(s))})(n)}}function en(g,e){for(var t=[],d=2;d<arguments.length;d++)t[d-2]=arguments[d];if(e===!0){g();return}if(e!==!1){var m=new ys({next:function(){m.unsubscribe(),g()}});return Ye(e.apply(void 0,_t([],pt(t)))).subscribe(m)}}function $l(g){return et(function(e,t){var d=!1,m=Ke(t,function(){m==null||m.unsubscribe(),d=!0},bs);Ye(g).subscribe(m),e.subscribe(Ke(t,function(v){return d&&t.next(v)}))})}function gr(g,e){return et(function(t,d){var m=null,v=0,o=!1,i=function(){return o&&!m&&d.complete()};t.subscribe(Ke(d,function(a){m==null||m.unsubscribe();var n=0,s=v++;Ye(g(a,s)).subscribe(m=Ke(d,function(r){return d.next(e?e(a,r,s,n++):r)},function(){m=null,i()}))},function(){o=!0,i()}))})}function Ts(g,e){return e===void 0&&(e=!1),et(function(t,d){var m=0;t.subscribe(Ke(d,function(v){var o=g(v,m++);(o||e)&&d.next(v),!o&&d.complete()}))})}function _r(g,e,t){var d=Ne(g)||e||t?{next:g,error:e,complete:t}:g;return d?et(function(m,v){var o;(o=d.subscribe)===null||o===void 0||o.call(d);var i=!0;m.subscribe(Ke(v,function(a){var n;(n=d.next)===null||n===void 0||n.call(d,a),v.next(a)},function(){var a;i=!1,(a=d.complete)===null||a===void 0||a.call(d),v.complete()},function(a){var n;i=!1,(n=d.error)===null||n===void 0||n.call(d,a),v.error(a)},function(){var a,n;i&&((a=d.unsubscribe)===null||a===void 0||a.call(d)),(n=d.finalize)===null||n===void 0||n.call(d)}))}):Fs}function Ul(g,e){return et(function(t,d){var m=e??{},v=m.leading,o=v===void 0?!0:v,i=m.trailing,a=i===void 0?!1:i,n=!1,s=null,r=null,c=!1,f=function(){r==null||r.unsubscribe(),r=null,a&&(u(),c&&d.complete())},h=function(){r=null,c&&d.complete()},l=function(p){return r=Ye(g(p)).subscribe(Ke(d,f,h))},u=function(){if(n){n=!1;var p=s;s=null,d.next(p),!c&&l(p)}};t.subscribe(Ke(d,function(p){n=!0,s=p,!(r&&!r.closed)&&(o?u():l(p))},function(){c=!0,!(a&&n&&r&&!r.closed)&&d.complete()}))})}function br(g,e,t){e===void 0&&(e=Vs);var d=ms(g,e);return Ul(function(){return d},t)}function tn(){for(var g=[],e=0;e<arguments.length;e++)g[e]=arguments[e];var t=Qa(g);return et(function(d,m){for(var v=g.length,o=new Array(v),i=g.map(function(){return!1}),a=!1,n=function(r){Ye(g[r]).subscribe(Ke(m,function(c){o[r]=c,!a&&!i[r]&&(i[r]=!0,(a=i.every(Fs))&&(i=null))},bs))},s=0;s<v;s++)n(s);d.subscribe(Ke(m,function(r){if(a){var c=_t([r],pt(o));m.next(t?t.apply(void 0,_t([],pt(c))):c)}}))})}const bi="0123456789ABCDEFGHJKMNPQRSTVWXYZ",Bs=32,Fl=16,yi=10,yr=0xffffffffffff;var zt;(function(g){g.Base32IncorrectEncoding="B32_ENC_INVALID",g.DecodeTimeInvalidCharacter="DEC_TIME_CHAR",g.DecodeTimeValueMalformed="DEC_TIME_MALFORMED",g.EncodeTimeNegative="ENC_TIME_NEG",g.EncodeTimeSizeExceeded="ENC_TIME_SIZE_EXCEED",g.EncodeTimeValueMalformed="ENC_TIME_MALFORMED",g.PRNGDetectFailure="PRNG_DETECT",g.ULIDInvalid="ULID_INVALID",g.Unexpected="UNEXPECTED",g.UUIDInvalid="UUID_INVALID"})(zt||(zt={}));class us extends Error{constructor(e,t){super(`${t} (${e})`),this.name="ULIDError",this.code=e}}function Vl(g){const e=Math.floor(g()*Bs)%Bs;return bi.charAt(e)}function Wl(g){const e=Hl(),t=e&&(e.crypto||e.msCrypto)||null;if(typeof(t==null?void 0:t.getRandomValues)=="function")return()=>{const d=new Uint8Array(1);return t.getRandomValues(d),d[0]/255};if(typeof(t==null?void 0:t.randomBytes)=="function")return()=>t.randomBytes(1).readUInt8()/255;throw new us(zt.PRNGDetectFailure,"Failed to find a reliable PRNG")}function Hl(){return Gl()?self:typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:null}function Kl(g,e){let t="";for(;g>0;g--)t=Vl(e)+t;return t}function zl(g,e=yi){if(isNaN(g))throw new us(zt.EncodeTimeValueMalformed,`Time must be a number: ${g}`);if(g>yr)throw new us(zt.EncodeTimeSizeExceeded,`Cannot encode a time larger than ${yr}: ${g}`);if(g<0)throw new us(zt.EncodeTimeNegative,`Time must be positive: ${g}`);if(Number.isInteger(g)===!1)throw new us(zt.EncodeTimeValueMalformed,`Time must be an integer: ${g}`);let t,d="";for(let m=e;m>0;m--)t=g%Bs,d=bi.charAt(t)+d,g=(g-t)/Bs;return d}function Gl(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}function Zl(g,e){const t=Wl(),d=Date.now();return zl(d,yi)+Kl(Fl,t)}const Qe=[];for(let g=0;g<256;++g)Qe.push((g+256).toString(16).slice(1));function Xl(g,e=0){return(Qe[g[e+0]]+Qe[g[e+1]]+Qe[g[e+2]]+Qe[g[e+3]]+"-"+Qe[g[e+4]]+Qe[g[e+5]]+"-"+Qe[g[e+6]]+Qe[g[e+7]]+"-"+Qe[g[e+8]]+Qe[g[e+9]]+"-"+Qe[g[e+10]]+Qe[g[e+11]]+Qe[g[e+12]]+Qe[g[e+13]]+Qe[g[e+14]]+Qe[g[e+15]]).toLowerCase()}let sn;const Yl=new Uint8Array(16);function Jl(){if(!sn){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");sn=crypto.getRandomValues.bind(crypto)}return sn(Yl)}const Ql=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),Cr={randomUUID:Ql};function ql(g,e,t){var m;if(Cr.randomUUID&&!g)return Cr.randomUUID();g=g||{};const d=g.random??((m=g.rng)==null?void 0:m.call(g))??Jl();if(d.length<16)throw new Error("Random bytes length must be >= 16");return d[6]=d[6]&15|64,d[8]=d[8]&63|128,Xl(d)}const ec=5e3,tc=1e3,xs=4e3,Er=1e3;var Ci=(g=>(g.CONTINUOUS="CONTINUOUS",g.INITIAL="INITIAL",g))(Ci||{});class Ei{constructor({knownID:e,runID:t,sequence:d,options:m}){Ue(this,"callback");Ue(this,"queue",new ot);Ue(this,"subscriptions",[]);Ue(this,"reconnect",new ot);Ue(this,"client",new Ge);Ue(this,"_latencies",new ot);Ue(this,"_latenciesConnectable",Kt(this._latencies.asObservable().pipe(Bl((e,t)=>{if(t.latency<0){const d=e.get(t.streamID);d&&e.set(t.streamID,{...d,readyState:t.readyState})}else e.set(t.streamID,t);return e},new Map))));Ue(this,"_errors",new ot);Ue(this,"_errorsConnectable",Kt(this._errors.asObservable()));Ue(this,"_stdout",new ot);Ue(this,"_stderr",new ot);Ue(this,"_exitCode",new ot);Ue(this,"_pid",new ot);Ue(this,"_mimeType",new ot);Ue(this,"_stdoutConnectable",Kt(this._stdout.asObservable()));Ue(this,"_stderrConnectable",Kt(this._stderr.asObservable()));Ue(this,"_exitCodeConnectable",Kt(this._exitCode.asObservable()));Ue(this,"_pidConnectable",Kt(this._pid.asObservable()));Ue(this,"_mimeTypeConnectable",Kt(this._mimeType.asObservable()));Ue(this,"knownID");Ue(this,"runID");Ue(this,"sequence");Ue(this,"runnerEndpoint");Ue(this,"authorization");Ue(this,"autoReconnect");this.knownID=e,this.runID=t,this.sequence=d,this.runnerEndpoint=m.runnerEndpoint,this.authorization=m.authorization,this.autoReconnect=m.autoReconnect,this._latenciesConnectable.connect(),this._errorsConnectable.connect(),this._stdoutConnectable.connect(),this._stderrConnectable.connect(),this._exitCodeConnectable.connect(),this._pidConnectable.connect(),this._mimeTypeConnectable.connect(),this.client=this.reconnect.pipe(br(Er,Vs,{leading:!0,trailing:!0}),gr(v=>this.useSocketClient(v.streamID).pipe(gr(o=>this.useHeartbeat(o,v))))).pipe(Nl()),this.subscriptions.push(this.monitor()),this.subscriptions.push(this.process())}get latencies(){return this._latenciesConnectable}get errors(){return this._errorsConnectable}get stdout(){return this._stdoutConnectable}get stderr(){return this._stderrConnectable}get exitCode(){return this._exitCodeConnectable}get pid(){return this._pidConnectable}get mimeType(){return this._mimeTypeConnectable}monitor(){return Tl(tc).pipe(gt(()=>this.autoReconnect),tn(this.reconnect),gt(([,t])=>t.heartbeat==="CONTINUOUS"),tn(this.latencies),nt(([,t])=>Array.from(t.values()).filter(d=>d.readyState===WebSocket.OPEN&&d.latency>=xs)),gt(t=>t.length>0),br(Er)).subscribe({next:t=>{console.log(new Date,"Triggering reconnect",t),this.connect()},complete:()=>{console.log("Monitor complete")},error:t=>{console.error("Error in monitor",t)}})}process(){const e=this.client.pipe(gt(o=>(o==null?void 0:o.readyState)===WebSocket.OPEN),vr(1)),t=this.queue.pipe(Ml(()=>e),gt(o=>o.length>0),nt(o=>o.sort((i,a)=>{const n=s=>{var r;return!!((r=s.payload.value)!=null&&r.config)};return n(a)?1:n(i)?-1:0}))),d=this.queue.pipe($l(e));return xl(t.pipe(Cs(o=>o)),d).pipe(tn(this.client),Ts(([,o])=>o.readyState===WebSocket.OPEN),nt(([o,i])=>jr({req:o,authorization:this.authorization,socket:i,knownID:this.knownID,runID:this.runID}))).subscribe({error:o=>{this._errors.next(o)}})}useSocketClient(e){return new Ge(t=>{const d=new URL(this.runnerEndpoint);d.searchParams.set("id",e),d.searchParams.set("runID",this.runID);const m=new WebSocket(d.toString()),v=n=>{if(console.log(new Date,`WebSocket transport ${e} closed`,n),n.code===1005){t.complete();return}if(this.autoReconnect){this.connect();return}},o=n=>{console.log(new Date,`WebSocket transport ${e} error`,n),this.autoReconnect||t.error(n)},i=n=>{var f,h;if(typeof n.data!="string"){console.warn("Unexpected WebSocket message type:",typeof n.data);return}let s;try{s=Sr(n.data),console.log("Received WebsocketResponse:",s)}catch(l){console.error("Failed to parse WebsocketResponse:",l)}const r=s.status;if(r&&r.code!==Pa.OK){t.error(r);return}if(s.pong)return;const c=s.payload.value;if(c.stdoutData&&c.stdoutData.length>0&&((f=this.callback)==null||f.call(this,{type:fs.terminalStdout,output:{"runme.dev/id":this.knownID,data:c.stdoutData}}),this._stdout.next(c.stdoutData)),c.stderrData&&c.stderrData.length>0&&((h=this.callback)==null||h.call(this,{type:fs.terminalStderr,output:{"runme.dev/id":this.knownID,data:c.stderrData}}),this._stderr.next(c.stderrData)),c.exitCode!==void 0&&(this._exitCode.next(c.exitCode),t.complete()),c.pid!==void 0&&this._pid.next(c.pid),c.mimeType){const u=c.mimeType.split(";")[0];this._mimeType.next(u)}},a=()=>{console.log(new Date,`✅ Connected WebSocket for cell ${this.knownID} (#${this.sequence}) with runID ${this.runID}`),t.next(m)};return m.addEventListener("close",v),m.addEventListener("error",o),m.addEventListener("message",i),m.addEventListener("open",a),()=>{console.log(new Date,`☑️ Cleanly disconnected WebSocket for cell ${this.knownID} (#${this.sequence}) with runID ${this.runID}`),m.removeEventListener("close",v),m.removeEventListener("error",o),m.removeEventListener("message",i),m.removeEventListener("open",a),m.close()}})}setCallback(e){this.callback=e}sendExecuteRequest(e){this.queue.next(ht.create(ln,{payload:{value:e,case:"executeRequest"}}))}useHeartbeat(e,{streamID:t,heartbeat:d}){return new Ge(m=>{const v=dn(e,"message").pipe(Ts(()=>e.readyState===WebSocket.OPEN),nt(s=>Sr(s.data)),nt(s=>s.pong),gt(s=>s!==void 0),nt(s=>({receivedAt:BigInt(Date.now()),pong:s}))),a=(d==="INITIAL"?ms(0):ms(0,ec)).pipe(Ts(()=>e.readyState===WebSocket.OPEN),nt(()=>{const s={timestamp:BigInt(Date.now())};return ht.create(ln,{ping:s})}),_r(s=>{jr({req:s,authorization:this.authorization,socket:e})}),nt(s=>s.ping)).pipe(gt(s=>(s==null?void 0:s.timestamp)!==void 0),Cs(s=>Rl(v.pipe(gt(r=>r.pong.timestamp===s.timestamp),vr(1),nt(r=>{const c=s.timestamp,f=r.receivedAt;return Number(f-c)})),ms(xs).pipe(nt(()=>{throw new Error(`Pong not received within ${xs}ms for stream ${t}`)}))).pipe(_i(r=>(this._latencies.next({streamID:t,latency:xs,readyState:e.readyState,updatedAt:BigInt(Date.now())}),console.log(new Date,"Ping deadline exceeded",r.message),fl(null))))),kl(()=>{this._latencies.next({streamID:t,latency:-1,readyState:e.readyState,updatedAt:BigInt(Date.now())})}),_r(s=>{s!==null&&this._latencies.next({streamID:t,latency:s,readyState:e.readyState,updatedAt:BigInt(Date.now())})})),n=[];return n.push(a.subscribe({error:s=>{console.error("Unexpected error sending heartbeat",s)}})),m.next(e),()=>{n.forEach(s=>s.unsubscribe())}})}connect(e="CONTINUOUS"){const t=sc(),d=this.latencies.pipe(nt(m=>{const v=m.get(t);return v===void 0?null:v}),Ts(m=>(m==null?void 0:m.readyState)===WebSocket.OPEN));return this.reconnect.next({streamID:t,heartbeat:e}),d}close(){this.reconnect.complete(),this.queue.complete(),this._latencies.complete(),this.subscriptions.forEach(e=>e.unsubscribe())}}function Sr(g){const e=JSON.parse(g);return ht.fromJson(Ra,e)}function jr({req:g,authorization:e,socket:t,knownID:d,runID:m}){d&&(g.knownId=d),m&&(g.runId=m);const{bearerToken:v}=e;v&&g&&(g.authorization=`Bearer ${v}`),t.send(JSON.stringify(ht.toJson(ln,g)))}function sc(){return ql().replace(/-/g,"")}function nc(){return`run_${Zl()}`}function rc({cellID:g,runID:e,sequence:t,commands:d,runner:m,settings:v={},onStdout:o,onStderr:i,onExitCode:a,onPid:n,onMimeType:s}){var S;const{rows:r=20,className:c,fontSize:f=12,fontFamily:h="monospace",takeFocus:l=!0,scrollToFit:u=!0}=v,p=ct.useMemo(()=>{if(!(!g||!e||!m.endpoint))return console.log("Creating stream",g,e,m.endpoint),new Ei({knownID:g,runID:e,sequence:t,options:{runnerEndpoint:m.endpoint,authorization:m.authorization,autoReconnect:m.reconnect}})},[g,e,t,m]);ct.useEffect(()=>{const E=p==null?void 0:p.connect().subscribe(j=>console.log(`Heartbeat latency for streamID ${j==null?void 0:j.streamID} (${(j==null?void 0:j.readyState)===1?"open":"closed"}): ${j==null?void 0:j.latency}ms`));return()=>{E==null||E.unsubscribe(),p==null||p.close()}},[p]);let _=ht.create(lr,{rows:34,cols:100,x:0,y:0});const b=ct.useMemo(()=>ht.create(Qs,{sessionStrategy:Ia.MOST_RECENT,storeStdoutInEnv:!0,config:{languageId:"sh",background:!1,fileExtension:"",env:[`RUNME_ID=${g}`,"RUNME_RUNNER=v2","TERM=xterm-256color"],source:{case:"commands",value:{items:d}},interactive:!0,mode:wa.INLINE,runId:e,knownId:g},winsize:_}),[g,e,d,_]),y=ct.useMemo(()=>{var E;return{output:{"runme.dev/id":(E=b.config)==null?void 0:E.knownId,fontFamily:h||"monospace",fontSize:f||12,cursorStyle:"block",cursorBlink:!0,cursorWidth:1,takeFocus:l,scrollToFit:u,smoothScrollDuration:0,scrollback:4e3,initialRows:r,content:"",isAutoSaveEnabled:!1,isPlatformAuthEnabled:!1}}},[h,f,l,r,(S=b.config)==null?void 0:S.knownId,u]),C=new TextEncoder;return xa({postMessage:E=>{if(E.type===fs.terminalOpen||E.type===fs.terminalResize){const j=Number(E.output.terminalDimensions.columns),O=Number(E.output.terminalDimensions.rows);if(Number.isFinite(j)&&Number.isFinite(O)){if(_.cols===j&&_.rows===O)return;_=ht.create(lr,{cols:j,rows:O,x:0,y:0});const I=ht.create(Qs,{winsize:_});p==null||p.sendExecuteRequest(I)}}if(E.type===fs.terminalStdin){const j=C.encode(E.output.input),O=ht.create(Qs,{inputData:j});p==null||p.sendExecuteRequest(O)}},onDidReceiveMessage:E=>{p==null||p.setCallback(E)}}),ct.useEffect(()=>{const E=p==null?void 0:p.stdout.subscribe(j=>{o==null||o(j)});return()=>E==null?void 0:E.unsubscribe()},[p,o]),ct.useEffect(()=>{const E=p==null?void 0:p.stderr.subscribe(j=>{i==null||i(j)});return()=>E==null?void 0:E.unsubscribe()},[p,i]),ct.useEffect(()=>{const E=p==null?void 0:p.exitCode.subscribe(j=>{a==null||a(j),p==null||p.close()});return()=>E==null?void 0:E.unsubscribe()},[p,a]),ct.useEffect(()=>{const E=p==null?void 0:p.pid.subscribe(j=>{n==null||n(j)});return()=>E==null?void 0:E.unsubscribe()},[p,n]),ct.useEffect(()=>{const E=p==null?void 0:p.mimeType.subscribe(j=>{s==null||s(j)});return()=>E==null?void 0:E.unsubscribe()},[p,s]),ct.useEffect(()=>{!p||!b||(console.log("useEffect invoked - Commands changed:",JSON.stringify(b.config.source.value)),p==null||p.sendExecuteRequest(b))},[b,p]),no.jsx("div",{className:c,ref:E=>{if(!E||E.hasChildNodes())return;const j=document.createElement("terminal-view");j.setAttribute("buttons","false"),j.setAttribute("id",y.output["runme.dev/id"]),j.setAttribute("fontFamily",y.output.fontFamily),typeof y.output.fontSize=="number"&&j.setAttribute("fontSize",y.output.fontSize.toString()),y.output.cursorStyle&&j.setAttribute("cursorStyle",y.output.cursorStyle),typeof y.output.cursorBlink=="boolean"&&j.setAttribute("cursorBlink",y.output.cursorBlink?"true":"false"),typeof y.output.cursorWidth=="number"&&j.setAttribute("cursorWidth",y.output.cursorWidth.toString()),typeof y.output.takeFocus=="boolean"&&j.setAttribute("takeFocus",y.output.takeFocus?"true":"false"),typeof y.output.smoothScrollDuration=="number"&&j.setAttribute("smoothScrollDuration",y.output.smoothScrollDuration.toString()),typeof y.output.scrollback=="number"&&j.setAttribute("scrollback",y.output.scrollback.toString()),y.output.initialRows!==void 0&&j.setAttribute("initialRows",y.output.initialRows.toString()),y.output.content!==void 0&&j.setAttribute("initialContent",y.output.content),y.output.isAutoSaveEnabled&&j.setAttribute("isAutoSaveEnabled",y.output.isAutoSaveEnabled.toString()),y.output.isPlatformAuthEnabled&&j.setAttribute("isPlatformAuthEnabled",y.output.isPlatformAuthEnabled.toString()),E.appendChild(j);const O=document.createElement("div");O.setAttribute("className","h-1"),E.appendChild(O),setTimeout(()=>{u&&!ic(O)&&O.scrollIntoView({behavior:"smooth"})},0)}})}function ic(g){const e=g.getBoundingClientRect();return e.top>=0&&e.left>=0&&e.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&e.right<=(window.innerWidth||document.documentElement.clientWidth)}exports.Console=rc;exports.Heartbeat=Ci;exports.Streams=Ei;exports.genRunID=nc;
@@ -61299,7 +61299,7 @@ class rc {
61299
61299
  Ue(this, "_exitCodeConnectable", Ht(this._exitCode.asObservable()));
61300
61300
  Ue(this, "_pidConnectable", Ht(this._pid.asObservable()));
61301
61301
  Ue(this, "_mimeTypeConnectable", Ht(this._mimeType.asObservable()));
61302
- // Identifiers for the block/console associated with this stream
61302
+ // Identifiers for the cell/console associated with this stream
61303
61303
  Ue(this, "knownID");
61304
61304
  Ue(this, "runID");
61305
61305
  Ue(this, "sequence");
@@ -61468,13 +61468,13 @@ class rc {
61468
61468
  }, a = () => {
61469
61469
  console.log(
61470
61470
  /* @__PURE__ */ new Date(),
61471
- `✅ Connected WebSocket for block ${this.knownID} (#${this.sequence}) with runID ${this.runID}`
61471
+ `✅ Connected WebSocket for cell ${this.knownID} (#${this.sequence}) with runID ${this.runID}`
61472
61472
  ), t.next(m);
61473
61473
  };
61474
61474
  return m.addEventListener("close", v), m.addEventListener("error", o), m.addEventListener("message", i), m.addEventListener("open", a), () => {
61475
61475
  console.log(
61476
61476
  /* @__PURE__ */ new Date(),
61477
- `☑️ Cleanly disconnected WebSocket for block ${this.knownID} (#${this.sequence}) with runID ${this.runID}`
61477
+ `☑️ Cleanly disconnected WebSocket for cell ${this.knownID} (#${this.sequence}) with runID ${this.runID}`
61478
61478
  ), m.removeEventListener("close", v), m.removeEventListener("error", o), m.removeEventListener("message", i), m.removeEventListener("open", a), m.close();
61479
61479
  };
61480
61480
  });
@@ -61620,7 +61620,7 @@ function rd() {
61620
61620
  return `run_${Xl()}`;
61621
61621
  }
61622
61622
  function id({
61623
- blockID: g,
61623
+ cellID: g,
61624
61624
  runID: e,
61625
61625
  sequence: t,
61626
61626
  commands: d,
@@ -61688,10 +61688,10 @@ function id({
61688
61688
  mode: Oa.INLINE,
61689
61689
  runId: e,
61690
61690
  knownId: g
61691
- // knownName: "the-block-name",
61691
+ // knownName: "the-cell-name",
61692
61692
  },
61693
61693
  winsize: _
61694
- }), [g, d, _]), y = Gs(
61694
+ }), [g, e, d, _]), y = Gs(
61695
61695
  () => {
61696
61696
  var E;
61697
61697
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@runmedev/react-console",
3
- "version": "3.14.4",
3
+ "version": "3.15.0",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "private": false,