@asgard-js/core 0.0.1 → 0.0.3-8.canary-1
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.
- package/README.md +329 -6
- package/dist/constants/enum.d.ts +12 -3
- package/dist/constants/enum.d.ts.map +1 -1
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1119 -1010
- package/dist/index.mjs.map +1 -1
- package/dist/lib/channel.d.ts +19 -0
- package/dist/lib/channel.d.ts.map +1 -0
- package/dist/lib/client.d.ts +11 -13
- package/dist/lib/client.d.ts.map +1 -1
- package/dist/lib/conversation.d.ts +18 -0
- package/dist/lib/conversation.d.ts.map +1 -0
- package/dist/lib/create-sse-observable.d.ts +7 -6
- package/dist/lib/create-sse-observable.d.ts.map +1 -1
- package/dist/lib/event-emitter.d.ts +8 -0
- package/dist/lib/event-emitter.d.ts.map +1 -0
- package/dist/types/channel.d.ts +42 -0
- package/dist/types/channel.d.ts.map +1 -0
- package/dist/types/client.d.ts +62 -16
- package/dist/types/client.d.ts.map +1 -1
- package/dist/types/event-emitter.d.ts +5 -0
- package/dist/types/event-emitter.d.ts.map +1 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/sse-response.d.ts +60 -11
- package/dist/types/sse-response.d.ts.map +1 -1
- package/eslint.config.cjs +22 -0
- package/package.json +13 -1
- package/src/constants/enum.ts +32 -0
- package/src/index.ts +11 -0
- package/src/lib/channel.ts +153 -0
- package/src/lib/client.spec.ts +150 -0
- package/src/lib/client.ts +141 -0
- package/src/lib/conversation.ts +120 -0
- package/src/lib/create-sse-observable.ts +77 -0
- package/src/lib/event-emitter.ts +30 -0
- package/src/types/channel.ts +50 -0
- package/src/types/client.ts +89 -0
- package/src/types/event-emitter.ts +8 -0
- package/src/types/index.ts +4 -0
- package/src/types/sse-response.ts +176 -0
- package/tsconfig.json +13 -0
- package/tsconfig.lib.json +28 -0
- package/tsconfig.spec.json +33 -0
- package/vite.config.ts +80 -0
package/dist/index.d.ts
CHANGED
|
@@ -2,4 +2,6 @@ export type { Subscription } from 'rxjs';
|
|
|
2
2
|
export type * from './types';
|
|
3
3
|
export * from './constants/enum';
|
|
4
4
|
export { default as AsgardServiceClient } from './lib/client';
|
|
5
|
+
export { default as Channel } from './lib/channel';
|
|
6
|
+
export { default as Conversation } from './lib/conversation';
|
|
5
7
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AAEzC,mBAAmB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AAEzC,mBAAmB,SAAS,CAAC;AAE7B,cAAc,kBAAkB,CAAC;AAEjC,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAE9D,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,eAAe,CAAC;AAEnD,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,oBAAoB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
(function(m,y){typeof exports=="object"&&typeof module<"u"?y(exports):typeof define=="function"&&define.amd?define(["exports"],y):(m=typeof globalThis<"u"?globalThis:m||self,y(m["@asgard-js/core"]={}))})(this,function(m){"use strict";var nn=Object.defineProperty;var rn=(m,y,x)=>y in m?nn(m,y,{enumerable:!0,configurable:!0,writable:!0,value:x}):m[y]=x;var _=(m,y,x)=>rn(m,typeof y!="symbol"?y+"":y,x);var y=(t=>(t.RESET_CHANNEL="RESET_CHANNEL",t.NONE="NONE",t))(y||{}),x=(t=>(t.INIT="asgard.run.init",t.MESSAGE_START="asgard.message.start",t.MESSAGE_DELTA="asgard.message.delta",t.MESSAGE_COMPLETE="asgard.message.complete",t.DONE="asgard.run.done",t))(x||{}),te=(t=>(t.TEXT="TEXT",t.HINT="HINT",t.BUTTON="BUTTON",t.IMAGE="IMAGE",t.VIDEO="VIDEO",t.AUDIO="AUDIO",t.LOCATION="LOCATION",t.CAROUSEL="CAROUSEL",t))(te||{});function Ve(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var V={exports:{}},P=typeof Reflect=="object"?Reflect:null,ne=P&&typeof P.apply=="function"?P.apply:function(n,e,r){return Function.prototype.apply.call(n,e,r)},U;P&&typeof P.ownKeys=="function"?U=P.ownKeys:Object.getOwnPropertySymbols?U=function(n){return Object.getOwnPropertyNames(n).concat(Object.getOwnPropertySymbols(n))}:U=function(n){return Object.getOwnPropertyNames(n)};function Ye(t){console&&console.warn&&console.warn(t)}var re=Number.isNaN||function(n){return n!==n};function d(){d.init.call(this)}V.exports=d,V.exports.once=Je,d.EventEmitter=d,d.prototype._events=void 0,d.prototype._eventsCount=0,d.prototype._maxListeners=void 0;var ie=10;function M(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(d,"defaultMaxListeners",{enumerable:!0,get:function(){return ie},set:function(t){if(typeof t!="number"||t<0||re(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");ie=t}}),d.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},d.prototype.setMaxListeners=function(n){if(typeof n!="number"||n<0||re(n))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+n+".");return this._maxListeners=n,this};function oe(t){return t._maxListeners===void 0?d.defaultMaxListeners:t._maxListeners}d.prototype.getMaxListeners=function(){return oe(this)},d.prototype.emit=function(n){for(var e=[],r=1;r<arguments.length;r++)e.push(arguments[r]);var i=n==="error",o=this._events;if(o!==void 0)i=i&&o.error===void 0;else if(!i)return!1;if(i){var u;if(e.length>0&&(u=e[0]),u instanceof Error)throw u;var s=new Error("Unhandled error."+(u?" ("+u.message+")":""));throw s.context=u,s}var f=o[n];if(f===void 0)return!1;if(typeof f=="function")ne(f,this,e);else for(var a=f.length,l=ce(f,a),r=0;r<a;++r)ne(l[r],this,e);return!0};function ue(t,n,e,r){var i,o,u;if(M(e),o=t._events,o===void 0?(o=t._events=Object.create(null),t._eventsCount=0):(o.newListener!==void 0&&(t.emit("newListener",n,e.listener?e.listener:e),o=t._events),u=o[n]),u===void 0)u=o[n]=e,++t._eventsCount;else if(typeof u=="function"?u=o[n]=r?[e,u]:[u,e]:r?u.unshift(e):u.push(e),i=oe(t),i>0&&u.length>i&&!u.warned){u.warned=!0;var s=new Error("Possible EventEmitter memory leak detected. "+u.length+" "+String(n)+" listeners added. Use emitter.setMaxListeners() to increase limit");s.name="MaxListenersExceededWarning",s.emitter=t,s.type=n,s.count=u.length,Ye(s)}return t}d.prototype.addListener=function(n,e){return ue(this,n,e,!1)},d.prototype.on=d.prototype.addListener,d.prototype.prependListener=function(n,e){return ue(this,n,e,!0)};function Be(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function se(t,n,e){var r={fired:!1,wrapFn:void 0,target:t,type:n,listener:e},i=Be.bind(r);return i.listener=e,r.wrapFn=i,i}d.prototype.once=function(n,e){return M(e),this.on(n,se(this,n,e)),this},d.prototype.prependOnceListener=function(n,e){return M(e),this.prependListener(n,se(this,n,e)),this},d.prototype.removeListener=function(n,e){var r,i,o,u,s;if(M(e),i=this._events,i===void 0)return this;if(r=i[n],r===void 0)return this;if(r===e||r.listener===e)--this._eventsCount===0?this._events=Object.create(null):(delete i[n],i.removeListener&&this.emit("removeListener",n,r.listener||e));else if(typeof r!="function"){for(o=-1,u=r.length-1;u>=0;u--)if(r[u]===e||r[u].listener===e){s=r[u].listener,o=u;break}if(o<0)return this;o===0?r.shift():Ke(r,o),r.length===1&&(i[n]=r[0]),i.removeListener!==void 0&&this.emit("removeListener",n,s||e)}return this},d.prototype.off=d.prototype.removeListener,d.prototype.removeAllListeners=function(n){var e,r,i;if(r=this._events,r===void 0)return this;if(r.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):r[n]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete r[n]),this;if(arguments.length===0){var o=Object.keys(r),u;for(i=0;i<o.length;++i)u=o[i],u!=="removeListener"&&this.removeAllListeners(u);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(e=r[n],typeof e=="function")this.removeListener(n,e);else if(e!==void 0)for(i=e.length-1;i>=0;i--)this.removeListener(n,e[i]);return this};function ae(t,n,e){var r=t._events;if(r===void 0)return[];var i=r[n];return i===void 0?[]:typeof i=="function"?e?[i.listener||i]:[i]:e?ze(i):ce(i,i.length)}d.prototype.listeners=function(n){return ae(this,n,!0)},d.prototype.rawListeners=function(n){return ae(this,n,!1)},d.listenerCount=function(t,n){return typeof t.listenerCount=="function"?t.listenerCount(n):fe.call(t,n)},d.prototype.listenerCount=fe;function fe(t){var n=this._events;if(n!==void 0){var e=n[t];if(typeof e=="function")return 1;if(e!==void 0)return e.length}return 0}d.prototype.eventNames=function(){return this._eventsCount>0?U(this._events):[]};function ce(t,n){for(var e=new Array(n),r=0;r<n;++r)e[r]=t[r];return e}function Ke(t,n){for(;n+1<t.length;n++)t[n]=t[n+1];t.pop()}function ze(t){for(var n=new Array(t.length),e=0;e<n.length;++e)n[e]=t[e].listener||t[e];return n}function Je(t,n){return new Promise(function(e,r){function i(u){t.removeListener(n,o),r(u)}function o(){typeof t.removeListener=="function"&&t.removeListener("error",i),e([].slice.call(arguments))}le(t,n,o,{once:!0}),n!=="error"&&Xe(t,i,{once:!0})})}function Xe(t,n,e){typeof t.on=="function"&&le(t,"error",n,e)}function le(t,n,e,r){if(typeof t.on=="function")r.once?t.once(n,e):t.on(n,e);else if(typeof t.addEventListener=="function")t.addEventListener(n,function i(o){r.once&&t.removeEventListener(n,i),e(o)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t)}var Qe=V.exports;const Ze=Ve(Qe);var Y=function(t,n){return Y=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])},Y(t,n)};function S(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");Y(t,n);function e(){this.constructor=t}t.prototype=n===null?Object.create(n):(e.prototype=n.prototype,new e)}function et(t,n,e,r){function i(o){return o instanceof e?o:new e(function(u){u(o)})}return new(e||(e=Promise))(function(o,u){function s(l){try{a(r.next(l))}catch(b){u(b)}}function f(l){try{a(r.throw(l))}catch(b){u(b)}}function a(l){l.done?o(l.value):i(l.value).then(s,f)}a((r=r.apply(t,n||[])).next())})}function de(t,n){var e={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,i,o,u=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return u.next=s(0),u.throw=s(1),u.return=s(2),typeof Symbol=="function"&&(u[Symbol.iterator]=function(){return this}),u;function s(a){return function(l){return f([a,l])}}function f(a){if(r)throw new TypeError("Generator is already executing.");for(;u&&(u=0,a[0]&&(e=0)),e;)try{if(r=1,i&&(o=a[0]&2?i.return:a[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,a[1])).done)return o;switch(i=0,o&&(a=[a[0]&2,o.value]),a[0]){case 0:case 1:o=a;break;case 4:return e.label++,{value:a[1],done:!1};case 5:e.label++,i=a[1],a=[0];continue;case 7:a=e.ops.pop(),e.trys.pop();continue;default:if(o=e.trys,!(o=o.length>0&&o[o.length-1])&&(a[0]===6||a[0]===2)){e=0;continue}if(a[0]===3&&(!o||a[1]>o[0]&&a[1]<o[3])){e.label=a[1];break}if(a[0]===6&&e.label<o[1]){e.label=o[1],o=a;break}if(o&&e.label<o[2]){e.label=o[2],e.ops.push(a);break}o[2]&&e.ops.pop(),e.trys.pop();continue}a=n.call(t,e)}catch(l){a=[6,l],i=0}finally{r=o=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}}function C(t){var n=typeof Symbol=="function"&&Symbol.iterator,e=n&&t[n],r=0;if(e)return e.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(n?"Object is not iterable.":"Symbol.iterator is not defined.")}function $(t,n){var e=typeof Symbol=="function"&&t[Symbol.iterator];if(!e)return t;var r=e.call(t),i,o=[],u;try{for(;(n===void 0||n-- >0)&&!(i=r.next()).done;)o.push(i.value)}catch(s){u={error:s}}finally{try{i&&!i.done&&(e=r.return)&&e.call(r)}finally{if(u)throw u.error}}return o}function D(t,n,e){if(e||arguments.length===2)for(var r=0,i=n.length,o;r<i;r++)(o||!(r in n))&&(o||(o=Array.prototype.slice.call(n,0,r)),o[r]=n[r]);return t.concat(o||Array.prototype.slice.call(n))}function N(t){return this instanceof N?(this.v=t,this):new N(t)}function tt(t,n,e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=e.apply(t,n||[]),i,o=[];return i=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),s("next"),s("throw"),s("return",u),i[Symbol.asyncIterator]=function(){return this},i;function u(c){return function(p){return Promise.resolve(p).then(c,b)}}function s(c,p){r[c]&&(i[c]=function(h){return new Promise(function(T,E){o.push([c,h,T,E])>1||f(c,h)})},p&&(i[c]=p(i[c])))}function f(c,p){try{a(r[c](p))}catch(h){g(o[0][3],h)}}function a(c){c.value instanceof N?Promise.resolve(c.value.v).then(l,b):g(o[0][2],c)}function l(c){f("next",c)}function b(c){f("throw",c)}function g(c,p){c(p),o.shift(),o.length&&f(o[0][0],o[0][1])}}function nt(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=t[Symbol.asyncIterator],e;return n?n.call(t):(t=typeof C=="function"?C(t):t[Symbol.iterator](),e={},r("next"),r("throw"),r("return"),e[Symbol.asyncIterator]=function(){return this},e);function r(o){e[o]=t[o]&&function(u){return new Promise(function(s,f){u=t[o](u),i(s,f,u.done,u.value)})}}function i(o,u,s,f){Promise.resolve(f).then(function(a){o({value:a,done:s})},u)}}typeof SuppressedError=="function"&&SuppressedError;function v(t){return typeof t=="function"}function he(t){var n=function(r){Error.call(r),r.stack=new Error().stack},e=t(n);return e.prototype=Object.create(Error.prototype),e.prototype.constructor=e,e}var B=he(function(t){return function(e){t(this),this.message=e?e.length+` errors occurred during unsubscription:
|
|
1
|
+
(function(m,g){typeof exports=="object"&&typeof module<"u"?g(exports):typeof define=="function"&&define.amd?define(["exports"],g):(m=typeof globalThis<"u"?globalThis:m||self,g(m["@asgard-js/core"]={}))})(this,function(m){"use strict";var Xt=Object.defineProperty;var zt=(m,g,d)=>g in m?Xt(m,g,{enumerable:!0,configurable:!0,writable:!0,value:d}):m[g]=d;var S=(m,g,d)=>zt(m,typeof g!="symbol"?g+"":g,d);var g=(n=>(n.RESET_CHANNEL="RESET_CHANNEL",n.NONE="NONE",n))(g||{}),d=(n=>(n.INIT="asgard.run.init",n.PROCESS="asgard.process",n.PROCESS_START="asgard.process.start",n.PROCESS_COMPLETE="asgard.process.complete",n.MESSAGE="asgard.message",n.MESSAGE_START="asgard.message.start",n.MESSAGE_DELTA="asgard.message.delta",n.MESSAGE_COMPLETE="asgard.message.complete",n.TOOL_CALL="asgard.tool_call",n.TOOL_CALL_START="asgard.tool_call.start",n.TOOL_CALL_COMPLETE="asgard.tool_call.complete",n.DONE="asgard.run.done",n.ERROR="asgard.run.error",n))(d||{}),ne=(n=>(n.TEXT="TEXT",n.HINT="HINT",n.BUTTON="BUTTON",n.IMAGE="IMAGE",n.VIDEO="VIDEO",n.AUDIO="AUDIO",n.LOCATION="LOCATION",n.CAROUSEL="CAROUSEL",n.CHART="CHART",n))(ne||{}),B=function(n,t){return B=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])},B(n,t)};function O(n,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");B(n,t);function e(){this.constructor=n}n.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}function De(n,t,e,r){function i(o){return o instanceof e?o:new e(function(s){s(o)})}return new(e||(e=Promise))(function(o,s){function c(f){try{u(r.next(f))}catch(y){s(y)}}function a(f){try{u(r.throw(f))}catch(y){s(y)}}function u(f){f.done?o(f.value):i(f.value).then(c,a)}u((r=r.apply(n,t||[])).next())})}function re(n,t){var e={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,i,o,s=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return s.next=c(0),s.throw=c(1),s.return=c(2),typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function c(u){return function(f){return a([u,f])}}function a(u){if(r)throw new TypeError("Generator is already executing.");for(;s&&(s=0,u[0]&&(e=0)),e;)try{if(r=1,i&&(o=u[0]&2?i.return:u[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,u[1])).done)return o;switch(i=0,o&&(u=[u[0]&2,o.value]),u[0]){case 0:case 1:o=u;break;case 4:return e.label++,{value:u[1],done:!1};case 5:e.label++,i=u[1],u=[0];continue;case 7:u=e.ops.pop(),e.trys.pop();continue;default:if(o=e.trys,!(o=o.length>0&&o[o.length-1])&&(u[0]===6||u[0]===2)){e=0;continue}if(u[0]===3&&(!o||u[1]>o[0]&&u[1]<o[3])){e.label=u[1];break}if(u[0]===6&&e.label<o[1]){e.label=o[1],o=u;break}if(o&&e.label<o[2]){e.label=o[2],e.ops.push(u);break}o[2]&&e.ops.pop(),e.trys.pop();continue}u=t.call(n,e)}catch(f){u=[6,f],i=0}finally{r=o=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}function L(n){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&n[t],r=0;if(e)return e.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&r>=n.length&&(n=void 0),{value:n&&n[r++],done:!n}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function k(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var r=e.call(n),i,o=[],s;try{for(;(t===void 0||t-- >0)&&!(i=r.next()).done;)o.push(i.value)}catch(c){s={error:c}}finally{try{i&&!i.done&&(e=r.return)&&e.call(r)}finally{if(s)throw s.error}}return o}function j(n,t,e){if(e||arguments.length===2)for(var r=0,i=t.length,o;r<i;r++)(o||!(r in t))&&(o||(o=Array.prototype.slice.call(t,0,r)),o[r]=t[r]);return n.concat(o||Array.prototype.slice.call(t))}function R(n){return this instanceof R?(this.v=n,this):new R(n)}function Ue(n,t,e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=e.apply(n,t||[]),i,o=[];return i=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),c("next"),c("throw"),c("return",s),i[Symbol.asyncIterator]=function(){return this},i;function s(l){return function(v){return Promise.resolve(v).then(l,y)}}function c(l,v){r[l]&&(i[l]=function(h){return new Promise(function(E,A){o.push([l,h,E,A])>1||a(l,h)})},v&&(i[l]=v(i[l])))}function a(l,v){try{u(r[l](v))}catch(h){b(o[0][3],h)}}function u(l){l.value instanceof R?Promise.resolve(l.value.v).then(f,y):b(o[0][2],l)}function f(l){a("next",l)}function y(l){a("throw",l)}function b(l,v){l(v),o.shift(),o.length&&a(o[0][0],o[0][1])}}function Ne(n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=n[Symbol.asyncIterator],e;return t?t.call(n):(n=typeof L=="function"?L(n):n[Symbol.iterator](),e={},r("next"),r("throw"),r("return"),e[Symbol.asyncIterator]=function(){return this},e);function r(o){e[o]=n[o]&&function(s){return new Promise(function(c,a){s=n[o](s),i(c,a,s.done,s.value)})}}function i(o,s,c,a){Promise.resolve(a).then(function(u){o({value:u,done:c})},s)}}typeof SuppressedError=="function"&&SuppressedError;function p(n){return typeof n=="function"}function ie(n){var t=function(r){Error.call(r),r.stack=new Error().stack},e=n(t);return e.prototype=Object.create(Error.prototype),e.prototype.constructor=e,e}var K=ie(function(n){return function(e){n(this),this.message=e?e.length+` errors occurred during unsubscription:
|
|
2
2
|
`+e.map(function(r,i){return i+1+") "+r.toString()}).join(`
|
|
3
|
-
`):"",this.name="UnsubscriptionError",this.errors=e}});function F(t,n){if(t){var e=t.indexOf(n);0<=e&&t.splice(e,1)}}var R=function(){function t(n){this.initialTeardown=n,this.closed=!1,this._parentage=null,this._finalizers=null}return t.prototype.unsubscribe=function(){var n,e,r,i,o;if(!this.closed){this.closed=!0;var u=this._parentage;if(u)if(this._parentage=null,Array.isArray(u))try{for(var s=C(u),f=s.next();!f.done;f=s.next()){var a=f.value;a.remove(this)}}catch(h){n={error:h}}finally{try{f&&!f.done&&(e=s.return)&&e.call(s)}finally{if(n)throw n.error}}else u.remove(this);var l=this.initialTeardown;if(v(l))try{l()}catch(h){o=h instanceof B?h.errors:[h]}var b=this._finalizers;if(b){this._finalizers=null;try{for(var g=C(b),c=g.next();!c.done;c=g.next()){var p=c.value;try{ye(p)}catch(h){o=o??[],h instanceof B?o=D(D([],$(o)),$(h.errors)):o.push(h)}}}catch(h){r={error:h}}finally{try{c&&!c.done&&(i=g.return)&&i.call(g)}finally{if(r)throw r.error}}}if(o)throw new B(o)}},t.prototype.add=function(n){var e;if(n&&n!==this)if(this.closed)ye(n);else{if(n instanceof t){if(n.closed||n._hasParent(this))return;n._addParent(this)}(this._finalizers=(e=this._finalizers)!==null&&e!==void 0?e:[]).push(n)}},t.prototype._hasParent=function(n){var e=this._parentage;return e===n||Array.isArray(e)&&e.includes(n)},t.prototype._addParent=function(n){var e=this._parentage;this._parentage=Array.isArray(e)?(e.push(n),e):e?[e,n]:n},t.prototype._removeParent=function(n){var e=this._parentage;e===n?this._parentage=null:Array.isArray(e)&&F(e,n)},t.prototype.remove=function(n){var e=this._finalizers;e&&F(e,n),n instanceof t&&n._removeParent(this)},t.EMPTY=function(){var n=new t;return n.closed=!0,n}(),t}(),ve=R.EMPTY;function pe(t){return t instanceof R||t&&"closed"in t&&v(t.remove)&&v(t.add)&&v(t.unsubscribe)}function ye(t){v(t)?t():t.unsubscribe()}var rt={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},be={setTimeout:function(t,n){for(var e=[],r=2;r<arguments.length;r++)e[r-2]=arguments[r];return setTimeout.apply(void 0,D([t,n],$(e)))},clearTimeout:function(t){var n=be.delegate;return((n==null?void 0:n.clearTimeout)||clearTimeout)(t)},delegate:void 0};function me(t){be.setTimeout(function(){throw t})}function K(){}function H(t){t()}var z=function(t){S(n,t);function n(e){var r=t.call(this)||this;return r.isStopped=!1,e?(r.destination=e,pe(e)&&e.add(r)):r.destination=ut,r}return n.create=function(e,r,i){return new J(e,r,i)},n.prototype.next=function(e){this.isStopped||this._next(e)},n.prototype.error=function(e){this.isStopped||(this.isStopped=!0,this._error(e))},n.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},n.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,t.prototype.unsubscribe.call(this),this.destination=null)},n.prototype._next=function(e){this.destination.next(e)},n.prototype._error=function(e){try{this.destination.error(e)}finally{this.unsubscribe()}},n.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},n}(R),it=function(){function t(n){this.partialObserver=n}return t.prototype.next=function(n){var e=this.partialObserver;if(e.next)try{e.next(n)}catch(r){G(r)}},t.prototype.error=function(n){var e=this.partialObserver;if(e.error)try{e.error(n)}catch(r){G(r)}else G(n)},t.prototype.complete=function(){var n=this.partialObserver;if(n.complete)try{n.complete()}catch(e){G(e)}},t}(),J=function(t){S(n,t);function n(e,r,i){var o=t.call(this)||this,u;return v(e)||!e?u={next:e??void 0,error:r??void 0,complete:i??void 0}:u=e,o.destination=new it(u),o}return n}(z);function G(t){me(t)}function ot(t){throw t}var ut={closed:!0,next:K,error:ot,complete:K},X=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function st(t){return t}function at(t){return t.length===0?st:t.length===1?t[0]:function(e){return t.reduce(function(r,i){return i(r)},e)}}var w=function(){function t(n){n&&(this._subscribe=n)}return t.prototype.lift=function(n){var e=new t;return e.source=this,e.operator=n,e},t.prototype.subscribe=function(n,e,r){var i=this,o=ct(n)?n:new J(n,e,r);return H(function(){var u=i,s=u.operator,f=u.source;o.add(s?s.call(o,f):f?i._subscribe(o):i._trySubscribe(o))}),o},t.prototype._trySubscribe=function(n){try{return this._subscribe(n)}catch(e){n.error(e)}},t.prototype.forEach=function(n,e){var r=this;return e=we(e),new e(function(i,o){var u=new J({next:function(s){try{n(s)}catch(f){o(f),u.unsubscribe()}},error:o,complete:i});r.subscribe(u)})},t.prototype._subscribe=function(n){var e;return(e=this.source)===null||e===void 0?void 0:e.subscribe(n)},t.prototype[X]=function(){return this},t.prototype.pipe=function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];return at(n)(this)},t.prototype.toPromise=function(n){var e=this;return n=we(n),new n(function(r,i){var o;e.subscribe(function(u){return o=u},function(u){return i(u)},function(){return r(o)})})},t.create=function(n){return new t(n)},t}();function we(t){var n;return(n=t??rt.Promise)!==null&&n!==void 0?n:Promise}function ft(t){return t&&v(t.next)&&v(t.error)&&v(t.complete)}function ct(t){return t&&t instanceof z||ft(t)&&pe(t)}function lt(t){return v(t==null?void 0:t.lift)}function L(t){return function(n){if(lt(n))return n.lift(function(e){try{return t(e,this)}catch(r){this.error(r)}});throw new TypeError("Unable to lift unknown Observable type")}}function j(t,n,e,r,i){return new dt(t,n,e,r,i)}var dt=function(t){S(n,t);function n(e,r,i,o,u,s){var f=t.call(this,e)||this;return f.onFinalize=u,f.shouldUnsubscribe=s,f._next=r?function(a){try{r(a)}catch(l){e.error(l)}}:t.prototype._next,f._error=o?function(a){try{o(a)}catch(l){e.error(l)}finally{this.unsubscribe()}}:t.prototype._error,f._complete=i?function(){try{i()}catch(a){e.error(a)}finally{this.unsubscribe()}}:t.prototype._complete,f}return n.prototype.unsubscribe=function(){var e;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var r=this.closed;t.prototype.unsubscribe.call(this),!r&&((e=this.onFinalize)===null||e===void 0||e.call(this))}},n}(z),ht=he(function(t){return function(){t(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),ge=function(t){S(n,t);function n(){var e=t.call(this)||this;return e.closed=!1,e.currentObservers=null,e.observers=[],e.isStopped=!1,e.hasError=!1,e.thrownError=null,e}return n.prototype.lift=function(e){var r=new Ee(this,this);return r.operator=e,r},n.prototype._throwIfClosed=function(){if(this.closed)throw new ht},n.prototype.next=function(e){var r=this;H(function(){var i,o;if(r._throwIfClosed(),!r.isStopped){r.currentObservers||(r.currentObservers=Array.from(r.observers));try{for(var u=C(r.currentObservers),s=u.next();!s.done;s=u.next()){var f=s.value;f.next(e)}}catch(a){i={error:a}}finally{try{s&&!s.done&&(o=u.return)&&o.call(u)}finally{if(i)throw i.error}}}})},n.prototype.error=function(e){var r=this;H(function(){if(r._throwIfClosed(),!r.isStopped){r.hasError=r.isStopped=!0,r.thrownError=e;for(var i=r.observers;i.length;)i.shift().error(e)}})},n.prototype.complete=function(){var e=this;H(function(){if(e._throwIfClosed(),!e.isStopped){e.isStopped=!0;for(var r=e.observers;r.length;)r.shift().complete()}})},n.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(n.prototype,"observed",{get:function(){var e;return((e=this.observers)===null||e===void 0?void 0:e.length)>0},enumerable:!1,configurable:!0}),n.prototype._trySubscribe=function(e){return this._throwIfClosed(),t.prototype._trySubscribe.call(this,e)},n.prototype._subscribe=function(e){return this._throwIfClosed(),this._checkFinalizedStatuses(e),this._innerSubscribe(e)},n.prototype._innerSubscribe=function(e){var r=this,i=this,o=i.hasError,u=i.isStopped,s=i.observers;return o||u?ve:(this.currentObservers=null,s.push(e),new R(function(){r.currentObservers=null,F(s,e)}))},n.prototype._checkFinalizedStatuses=function(e){var r=this,i=r.hasError,o=r.thrownError,u=r.isStopped;i?e.error(o):u&&e.complete()},n.prototype.asObservable=function(){var e=new w;return e.source=this,e},n.create=function(e,r){return new Ee(e,r)},n}(w),Ee=function(t){S(n,t);function n(e,r){var i=t.call(this)||this;return i.destination=e,i.source=r,i}return n.prototype.next=function(e){var r,i;(i=(r=this.destination)===null||r===void 0?void 0:r.next)===null||i===void 0||i.call(r,e)},n.prototype.error=function(e){var r,i;(i=(r=this.destination)===null||r===void 0?void 0:r.error)===null||i===void 0||i.call(r,e)},n.prototype.complete=function(){var e,r;(r=(e=this.destination)===null||e===void 0?void 0:e.complete)===null||r===void 0||r.call(e)},n.prototype._subscribe=function(e){var r,i;return(i=(r=this.source)===null||r===void 0?void 0:r.subscribe(e))!==null&&i!==void 0?i:ve},n}(ge),vt={now:function(){return Date.now()},delegate:void 0},pt=function(t){S(n,t);function n(e,r){return t.call(this)||this}return n.prototype.schedule=function(e,r){return this},n}(R),Se={setInterval:function(t,n){for(var e=[],r=2;r<arguments.length;r++)e[r-2]=arguments[r];return setInterval.apply(void 0,D([t,n],$(e)))},clearInterval:function(t){return clearInterval(t)},delegate:void 0},yt=function(t){S(n,t);function n(e,r){var i=t.call(this,e,r)||this;return i.scheduler=e,i.work=r,i.pending=!1,i}return n.prototype.schedule=function(e,r){var i;if(r===void 0&&(r=0),this.closed)return this;this.state=e;var o=this.id,u=this.scheduler;return o!=null&&(this.id=this.recycleAsyncId(u,o,r)),this.pending=!0,this.delay=r,this.id=(i=this.id)!==null&&i!==void 0?i:this.requestAsyncId(u,this.id,r),this},n.prototype.requestAsyncId=function(e,r,i){return i===void 0&&(i=0),Se.setInterval(e.flush.bind(e,this),i)},n.prototype.recycleAsyncId=function(e,r,i){if(i===void 0&&(i=0),i!=null&&this.delay===i&&this.pending===!1)return r;r!=null&&Se.clearInterval(r)},n.prototype.execute=function(e,r){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var i=this._execute(e,r);if(i)return i;this.pending===!1&&this.id!=null&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},n.prototype._execute=function(e,r){var i=!1,o;try{this.work(e)}catch(u){i=!0,o=u||new Error("Scheduled action threw falsy error")}if(i)return this.unsubscribe(),o},n.prototype.unsubscribe=function(){if(!this.closed){var e=this,r=e.id,i=e.scheduler,o=i.actions;this.work=this.state=this.scheduler=null,this.pending=!1,F(o,this),r!=null&&(this.id=this.recycleAsyncId(i,r,null)),this.delay=null,t.prototype.unsubscribe.call(this)}},n}(pt),Oe=function(){function t(n,e){e===void 0&&(e=t.now),this.schedulerActionCtor=n,this.now=e}return t.prototype.schedule=function(n,e,r){return e===void 0&&(e=0),new this.schedulerActionCtor(this,n).schedule(r,e)},t.now=vt.now,t}(),bt=function(t){S(n,t);function n(e,r){r===void 0&&(r=Oe.now);var i=t.call(this,e,r)||this;return i.actions=[],i._active=!1,i}return n.prototype.flush=function(e){var r=this.actions;if(this._active){r.push(e);return}var i;this._active=!0;do if(i=e.execute(e.state,e.delay))break;while(e=r.shift());if(this._active=!1,i){for(;e=r.shift();)e.unsubscribe();throw i}},n}(Oe),_e=new bt(yt),mt=_e,wt=new w(function(t){return t.complete()});function xe(t){return t&&v(t.schedule)}function gt(t){return t[t.length-1]}function Et(t){return xe(gt(t))?t.pop():void 0}var Le=function(t){return t&&typeof t.length=="number"&&typeof t!="function"};function Ae(t){return v(t==null?void 0:t.then)}function Ie(t){return v(t[X])}function Te(t){return Symbol.asyncIterator&&v(t==null?void 0:t[Symbol.asyncIterator])}function ke(t){return new TypeError("You provided "+(t!==null&&typeof t=="object"?"an invalid object":"'"+t+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}function St(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var Pe=St();function Ce(t){return v(t==null?void 0:t[Pe])}function Ne(t){return tt(this,arguments,function(){var e,r,i,o;return de(this,function(u){switch(u.label){case 0:e=t.getReader(),u.label=1;case 1:u.trys.push([1,,9,10]),u.label=2;case 2:return[4,N(e.read())];case 3:return r=u.sent(),i=r.value,o=r.done,o?[4,N(void 0)]:[3,5];case 4:return[2,u.sent()];case 5:return[4,N(i)];case 6:return[4,u.sent()];case 7:return u.sent(),[3,2];case 8:return[3,10];case 9:return e.releaseLock(),[7];case 10:return[2]}})})}function je(t){return v(t==null?void 0:t.getReader)}function A(t){if(t instanceof w)return t;if(t!=null){if(Ie(t))return Ot(t);if(Le(t))return _t(t);if(Ae(t))return xt(t);if(Te(t))return Re(t);if(Ce(t))return Lt(t);if(je(t))return At(t)}throw ke(t)}function Ot(t){return new w(function(n){var e=t[X]();if(v(e.subscribe))return e.subscribe(n);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function _t(t){return new w(function(n){for(var e=0;e<t.length&&!n.closed;e++)n.next(t[e]);n.complete()})}function xt(t){return new w(function(n){t.then(function(e){n.closed||(n.next(e),n.complete())},function(e){return n.error(e)}).then(null,me)})}function Lt(t){return new w(function(n){var e,r;try{for(var i=C(t),o=i.next();!o.done;o=i.next()){var u=o.value;if(n.next(u),n.closed)return}}catch(s){e={error:s}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(e)throw e.error}}n.complete()})}function Re(t){return new w(function(n){It(t,n).catch(function(e){return n.error(e)})})}function At(t){return Re(Ne(t))}function It(t,n){var e,r,i,o;return et(this,void 0,void 0,function(){var u,s;return de(this,function(f){switch(f.label){case 0:f.trys.push([0,5,6,11]),e=nt(t),f.label=1;case 1:return[4,e.next()];case 2:if(r=f.sent(),!!r.done)return[3,4];if(u=r.value,n.next(u),n.closed)return[2];f.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return s=f.sent(),i={error:s},[3,11];case 6:return f.trys.push([6,,9,10]),r&&!r.done&&(o=e.return)?[4,o.call(e)]:[3,8];case 7:f.sent(),f.label=8;case 8:return[3,10];case 9:if(i)throw i.error;return[7];case 10:return[7];case 11:return n.complete(),[2]}})})}function I(t,n,e,r,i){r===void 0&&(r=0),i===void 0&&(i=!1);var o=n.schedule(function(){e(),i?t.add(this.schedule(null,r)):this.unsubscribe()},r);if(t.add(o),!i)return o}function Ue(t,n){return n===void 0&&(n=0),L(function(e,r){e.subscribe(j(r,function(i){return I(r,t,function(){return r.next(i)},n)},function(){return I(r,t,function(){return r.complete()},n)},function(i){return I(r,t,function(){return r.error(i)},n)}))})}function Me(t,n){return n===void 0&&(n=0),L(function(e,r){r.add(t.schedule(function(){return e.subscribe(r)},n))})}function Tt(t,n){return A(t).pipe(Me(n),Ue(n))}function kt(t,n){return A(t).pipe(Me(n),Ue(n))}function Pt(t,n){return new w(function(e){var r=0;return n.schedule(function(){r===t.length?e.complete():(e.next(t[r++]),e.closed||this.schedule())})})}function Ct(t,n){return new w(function(e){var r;return I(e,n,function(){r=t[Pe](),I(e,n,function(){var i,o,u;try{i=r.next(),o=i.value,u=i.done}catch(s){e.error(s);return}u?e.complete():e.next(o)},0,!0)}),function(){return v(r==null?void 0:r.return)&&r.return()}})}function $e(t,n){if(!t)throw new Error("Iterable cannot be null");return new w(function(e){I(e,n,function(){var r=t[Symbol.asyncIterator]();I(e,n,function(){r.next().then(function(i){i.done?e.complete():e.next(i.value)})},0,!0)})})}function Nt(t,n){return $e(Ne(t),n)}function jt(t,n){if(t!=null){if(Ie(t))return Tt(t,n);if(Le(t))return Pt(t,n);if(Ae(t))return kt(t,n);if(Te(t))return $e(t,n);if(Ce(t))return Ct(t,n);if(je(t))return Nt(t,n)}throw ke(t)}function Rt(t,n){return n?jt(t,n):A(t)}function Ut(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var e=Et(t);return Rt(t,e)}function Mt(t){return t instanceof Date&&!isNaN(t)}function De(t,n){return L(function(e,r){var i=0;e.subscribe(j(r,function(o){r.next(t.call(n,o,i++))}))})}function $t(t,n,e,r,i,o,u,s){var f=[],a=0,l=0,b=!1,g=function(){b&&!f.length&&!a&&n.complete()},c=function(h){return a<r?p(h):f.push(h)},p=function(h){a++;var T=!1;A(e(h,l++)).subscribe(j(n,function(E){n.next(E)},function(){T=!0},void 0,function(){if(T)try{a--;for(var E=function(){var k=f.shift();u||p(k)};f.length&&a<r;)E();g()}catch(k){n.error(k)}}))};return t.subscribe(j(n,c,function(){b=!0,g()})),function(){}}function W(t,n,e){return e===void 0&&(e=1/0),v(n)?W(function(r,i){return De(function(o,u){return n(r,o,i,u)})(A(t(r,i)))},e):(typeof n=="number"&&(e=n),L(function(r,i){return $t(r,i,t,e)}))}function Dt(t,n,e){t===void 0&&(t=0),e===void 0&&(e=mt);var r=-1;return n!=null&&(xe(n)?e=n:r=n),new w(function(i){var o=Mt(t)?+t-e.now():t;o<0&&(o=0);var u=0;return e.schedule(function(){i.closed||(i.next(u++),0<=r?this.schedule(void 0,r):i.complete())},o)})}function Ft(t,n){return v(n)?W(t,n,1):W(t,1)}function Ht(t){return t<=0?function(){return wt}:L(function(n,e){var r=0;n.subscribe(j(e,function(i){++r<=t&&(e.next(i),t<=r&&e.complete())}))})}function Gt(t){return De(function(){return t})}function Wt(t,n){return W(function(e,r){return A(t(e,r)).pipe(Ht(1),Gt(e))})}function qt(t,n){n===void 0&&(n=_e);var e=Dt(t,n);return Wt(function(){return e})}function Fe(t){return L(function(n,e){try{n.subscribe(e)}finally{e.add(t)}})}function He(t){return L(function(n,e){A(t).subscribe(j(e,function(){return e.complete()},K)),!e.closed&&n.subscribe(e)})}async function Vt(t,n){const e=t.getReader();let r;for(;!(r=await e.read()).done;)n(r.value)}function Yt(t){let n,e,r,i=!1;return function(u){n===void 0?(n=u,e=0,r=-1):n=Kt(n,u);const s=n.length;let f=0;for(;e<s;){i&&(n[e]===10&&(f=++e),i=!1);let a=-1;for(;e<s&&a===-1;++e)switch(n[e]){case 58:r===-1&&(r=e-f);break;case 13:i=!0;case 10:a=e;break}if(a===-1)break;t(n.subarray(f,a),r),f=e,r=-1}f===s?n=void 0:f!==0&&(n=n.subarray(f),e-=f)}}function Bt(t,n,e){let r=Ge();const i=new TextDecoder;return function(u,s){if(u.length===0)e==null||e(r),r=Ge();else if(s>0){const f=i.decode(u.subarray(0,s)),a=s+(u[s+1]===32?2:1),l=i.decode(u.subarray(a));switch(f){case"data":r.data=r.data?r.data+`
|
|
4
|
-
`+
|
|
3
|
+
`):"",this.name="UnsubscriptionError",this.errors=e}});function U(n,t){if(n){var e=n.indexOf(t);0<=e&&n.splice(e,1)}}var D=function(){function n(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}return n.prototype.unsubscribe=function(){var t,e,r,i,o;if(!this.closed){this.closed=!0;var s=this._parentage;if(s)if(this._parentage=null,Array.isArray(s))try{for(var c=L(s),a=c.next();!a.done;a=c.next()){var u=a.value;u.remove(this)}}catch(h){t={error:h}}finally{try{a&&!a.done&&(e=c.return)&&e.call(c)}finally{if(t)throw t.error}}else s.remove(this);var f=this.initialTeardown;if(p(f))try{f()}catch(h){o=h instanceof K?h.errors:[h]}var y=this._finalizers;if(y){this._finalizers=null;try{for(var b=L(y),l=b.next();!l.done;l=b.next()){var v=l.value;try{ue(v)}catch(h){o=o??[],h instanceof K?o=j(j([],k(o)),k(h.errors)):o.push(h)}}}catch(h){r={error:h}}finally{try{l&&!l.done&&(i=b.return)&&i.call(b)}finally{if(r)throw r.error}}}if(o)throw new K(o)}},n.prototype.add=function(t){var e;if(t&&t!==this)if(this.closed)ue(t);else{if(t instanceof n){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=(e=this._finalizers)!==null&&e!==void 0?e:[]).push(t)}},n.prototype._hasParent=function(t){var e=this._parentage;return e===t||Array.isArray(e)&&e.includes(t)},n.prototype._addParent=function(t){var e=this._parentage;this._parentage=Array.isArray(e)?(e.push(t),e):e?[e,t]:t},n.prototype._removeParent=function(t){var e=this._parentage;e===t?this._parentage=null:Array.isArray(e)&&U(e,t)},n.prototype.remove=function(t){var e=this._finalizers;e&&U(e,t),t instanceof n&&t._removeParent(this)},n.EMPTY=function(){var t=new n;return t.closed=!0,t}(),n}(),oe=D.EMPTY;function se(n){return n instanceof D||n&&"closed"in n&&p(n.remove)&&p(n.add)&&p(n.unsubscribe)}function ue(n){p(n)?n():n.unsubscribe()}var $e={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},ae={setTimeout:function(n,t){for(var e=[],r=2;r<arguments.length;r++)e[r-2]=arguments[r];return setTimeout.apply(void 0,j([n,t],k(e)))},clearTimeout:function(n){var t=ae.delegate;return((t==null?void 0:t.clearTimeout)||clearTimeout)(n)},delegate:void 0};function ce(n){ae.setTimeout(function(){throw n})}function Y(){}function N(n){n()}var q=function(n){O(t,n);function t(e){var r=n.call(this)||this;return r.isStopped=!1,e?(r.destination=e,se(e)&&e.add(r)):r.destination=He,r}return t.create=function(e,r,i){return new W(e,r,i)},t.prototype.next=function(e){this.isStopped||this._next(e)},t.prototype.error=function(e){this.isStopped||(this.isStopped=!0,this._error(e))},t.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,n.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(e){this.destination.next(e)},t.prototype._error=function(e){try{this.destination.error(e)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t}(D),Ge=function(){function n(t){this.partialObserver=t}return n.prototype.next=function(t){var e=this.partialObserver;if(e.next)try{e.next(t)}catch(r){$(r)}},n.prototype.error=function(t){var e=this.partialObserver;if(e.error)try{e.error(t)}catch(r){$(r)}else $(t)},n.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(e){$(e)}},n}(),W=function(n){O(t,n);function t(e,r,i){var o=n.call(this)||this,s;return p(e)||!e?s={next:e??void 0,error:r??void 0,complete:i??void 0}:s=e,o.destination=new Ge(s),o}return t}(q);function $(n){ce(n)}function Fe(n){throw n}var He={closed:!0,next:Y,error:Fe,complete:Y},J=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function G(n){return n}function Ve(n){return n.length===0?G:n.length===1?n[0]:function(e){return n.reduce(function(r,i){return i(r)},e)}}var w=function(){function n(t){t&&(this._subscribe=t)}return n.prototype.lift=function(t){var e=new n;return e.source=this,e.operator=t,e},n.prototype.subscribe=function(t,e,r){var i=this,o=Ke(t)?t:new W(t,e,r);return N(function(){var s=i,c=s.operator,a=s.source;o.add(c?c.call(o,a):a?i._subscribe(o):i._trySubscribe(o))}),o},n.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(e){t.error(e)}},n.prototype.forEach=function(t,e){var r=this;return e=fe(e),new e(function(i,o){var s=new W({next:function(c){try{t(c)}catch(a){o(a),s.unsubscribe()}},error:o,complete:i});r.subscribe(s)})},n.prototype._subscribe=function(t){var e;return(e=this.source)===null||e===void 0?void 0:e.subscribe(t)},n.prototype[J]=function(){return this},n.prototype.pipe=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return Ve(t)(this)},n.prototype.toPromise=function(t){var e=this;return t=fe(t),new t(function(r,i){var o;e.subscribe(function(s){return o=s},function(s){return i(s)},function(){return r(o)})})},n.create=function(t){return new n(t)},n}();function fe(n){var t;return(t=n??$e.Promise)!==null&&t!==void 0?t:Promise}function Be(n){return n&&p(n.next)&&p(n.error)&&p(n.complete)}function Ke(n){return n&&n instanceof q||Be(n)&&se(n)}function Ye(n){return p(n==null?void 0:n.lift)}function C(n){return function(t){if(Ye(t))return t.lift(function(e){try{return n(e,this)}catch(r){this.error(r)}});throw new TypeError("Unable to lift unknown Observable type")}}function I(n,t,e,r,i){return new qe(n,t,e,r,i)}var qe=function(n){O(t,n);function t(e,r,i,o,s,c){var a=n.call(this,e)||this;return a.onFinalize=s,a.shouldUnsubscribe=c,a._next=r?function(u){try{r(u)}catch(f){e.error(f)}}:n.prototype._next,a._error=o?function(u){try{o(u)}catch(f){e.error(f)}finally{this.unsubscribe()}}:n.prototype._error,a._complete=i?function(){try{i()}catch(u){e.error(u)}finally{this.unsubscribe()}}:n.prototype._complete,a}return t.prototype.unsubscribe=function(){var e;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var r=this.closed;n.prototype.unsubscribe.call(this),!r&&((e=this.onFinalize)===null||e===void 0||e.call(this))}},t}(q),We=ie(function(n){return function(){n(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),X=function(n){O(t,n);function t(){var e=n.call(this)||this;return e.closed=!1,e.currentObservers=null,e.observers=[],e.isStopped=!1,e.hasError=!1,e.thrownError=null,e}return t.prototype.lift=function(e){var r=new le(this,this);return r.operator=e,r},t.prototype._throwIfClosed=function(){if(this.closed)throw new We},t.prototype.next=function(e){var r=this;N(function(){var i,o;if(r._throwIfClosed(),!r.isStopped){r.currentObservers||(r.currentObservers=Array.from(r.observers));try{for(var s=L(r.currentObservers),c=s.next();!c.done;c=s.next()){var a=c.value;a.next(e)}}catch(u){i={error:u}}finally{try{c&&!c.done&&(o=s.return)&&o.call(s)}finally{if(i)throw i.error}}}})},t.prototype.error=function(e){var r=this;N(function(){if(r._throwIfClosed(),!r.isStopped){r.hasError=r.isStopped=!0,r.thrownError=e;for(var i=r.observers;i.length;)i.shift().error(e)}})},t.prototype.complete=function(){var e=this;N(function(){if(e._throwIfClosed(),!e.isStopped){e.isStopped=!0;for(var r=e.observers;r.length;)r.shift().complete()}})},t.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(t.prototype,"observed",{get:function(){var e;return((e=this.observers)===null||e===void 0?void 0:e.length)>0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(e){return this._throwIfClosed(),n.prototype._trySubscribe.call(this,e)},t.prototype._subscribe=function(e){return this._throwIfClosed(),this._checkFinalizedStatuses(e),this._innerSubscribe(e)},t.prototype._innerSubscribe=function(e){var r=this,i=this,o=i.hasError,s=i.isStopped,c=i.observers;return o||s?oe:(this.currentObservers=null,c.push(e),new D(function(){r.currentObservers=null,U(c,e)}))},t.prototype._checkFinalizedStatuses=function(e){var r=this,i=r.hasError,o=r.thrownError,s=r.isStopped;i?e.error(o):s&&e.complete()},t.prototype.asObservable=function(){var e=new w;return e.source=this,e},t.create=function(e,r){return new le(e,r)},t}(w),le=function(n){O(t,n);function t(e,r){var i=n.call(this)||this;return i.destination=e,i.source=r,i}return t.prototype.next=function(e){var r,i;(i=(r=this.destination)===null||r===void 0?void 0:r.next)===null||i===void 0||i.call(r,e)},t.prototype.error=function(e){var r,i;(i=(r=this.destination)===null||r===void 0?void 0:r.error)===null||i===void 0||i.call(r,e)},t.prototype.complete=function(){var e,r;(r=(e=this.destination)===null||e===void 0?void 0:e.complete)===null||r===void 0||r.call(e)},t.prototype._subscribe=function(e){var r,i;return(i=(r=this.source)===null||r===void 0?void 0:r.subscribe(e))!==null&&i!==void 0?i:oe},t}(X),de=function(n){O(t,n);function t(e){var r=n.call(this)||this;return r._value=e,r}return Object.defineProperty(t.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),t.prototype._subscribe=function(e){var r=n.prototype._subscribe.call(this,e);return!r.closed&&e.next(this._value),r},t.prototype.getValue=function(){var e=this,r=e.hasError,i=e.thrownError,o=e._value;if(r)throw i;return this._throwIfClosed(),o},t.prototype.next=function(e){n.prototype.next.call(this,this._value=e)},t}(X),Je={now:function(){return Date.now()},delegate:void 0},Xe=function(n){O(t,n);function t(e,r){return n.call(this)||this}return t.prototype.schedule=function(e,r){return this},t}(D),he={setInterval:function(n,t){for(var e=[],r=2;r<arguments.length;r++)e[r-2]=arguments[r];return setInterval.apply(void 0,j([n,t],k(e)))},clearInterval:function(n){return clearInterval(n)},delegate:void 0},ze=function(n){O(t,n);function t(e,r){var i=n.call(this,e,r)||this;return i.scheduler=e,i.work=r,i.pending=!1,i}return t.prototype.schedule=function(e,r){var i;if(r===void 0&&(r=0),this.closed)return this;this.state=e;var o=this.id,s=this.scheduler;return o!=null&&(this.id=this.recycleAsyncId(s,o,r)),this.pending=!0,this.delay=r,this.id=(i=this.id)!==null&&i!==void 0?i:this.requestAsyncId(s,this.id,r),this},t.prototype.requestAsyncId=function(e,r,i){return i===void 0&&(i=0),he.setInterval(e.flush.bind(e,this),i)},t.prototype.recycleAsyncId=function(e,r,i){if(i===void 0&&(i=0),i!=null&&this.delay===i&&this.pending===!1)return r;r!=null&&he.clearInterval(r)},t.prototype.execute=function(e,r){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var i=this._execute(e,r);if(i)return i;this.pending===!1&&this.id!=null&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},t.prototype._execute=function(e,r){var i=!1,o;try{this.work(e)}catch(s){i=!0,o=s||new Error("Scheduled action threw falsy error")}if(i)return this.unsubscribe(),o},t.prototype.unsubscribe=function(){if(!this.closed){var e=this,r=e.id,i=e.scheduler,o=i.actions;this.work=this.state=this.scheduler=null,this.pending=!1,U(o,this),r!=null&&(this.id=this.recycleAsyncId(i,r,null)),this.delay=null,n.prototype.unsubscribe.call(this)}},t}(Xe),ye=function(){function n(t,e){e===void 0&&(e=n.now),this.schedulerActionCtor=t,this.now=e}return n.prototype.schedule=function(t,e,r){return e===void 0&&(e=0),new this.schedulerActionCtor(this,t).schedule(r,e)},n.now=Je.now,n}(),Qe=function(n){O(t,n);function t(e,r){r===void 0&&(r=ye.now);var i=n.call(this,e,r)||this;return i.actions=[],i._active=!1,i}return t.prototype.flush=function(e){var r=this.actions;if(this._active){r.push(e);return}var i;this._active=!0;do if(i=e.execute(e.state,e.delay))break;while(e=r.shift());if(this._active=!1,i){for(;e=r.shift();)e.unsubscribe();throw i}},t}(ye),ve=new Qe(ze),Ze=ve,et=new w(function(n){return n.complete()});function pe(n){return n&&p(n.schedule)}function be(n){return n[n.length-1]}function tt(n){return p(be(n))?n.pop():void 0}function me(n){return pe(be(n))?n.pop():void 0}var ge=function(n){return n&&typeof n.length=="number"&&typeof n!="function"};function Se(n){return p(n==null?void 0:n.then)}function we(n){return p(n[J])}function Ee(n){return Symbol.asyncIterator&&p(n==null?void 0:n[Symbol.asyncIterator])}function Oe(n){return new TypeError("You provided "+(n!==null&&typeof n=="object"?"an invalid object":"'"+n+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}function nt(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var Ie=nt();function Ae(n){return p(n==null?void 0:n[Ie])}function _e(n){return Ue(this,arguments,function(){var e,r,i,o;return re(this,function(s){switch(s.label){case 0:e=n.getReader(),s.label=1;case 1:s.trys.push([1,,9,10]),s.label=2;case 2:return[4,R(e.read())];case 3:return r=s.sent(),i=r.value,o=r.done,o?[4,R(void 0)]:[3,5];case 4:return[2,s.sent()];case 5:return[4,R(i)];case 6:return[4,s.sent()];case 7:return s.sent(),[3,2];case 8:return[3,10];case 9:return e.releaseLock(),[7];case 10:return[2]}})})}function xe(n){return p(n==null?void 0:n.getReader)}function _(n){if(n instanceof w)return n;if(n!=null){if(we(n))return rt(n);if(ge(n))return it(n);if(Se(n))return ot(n);if(Ee(n))return Te(n);if(Ae(n))return st(n);if(xe(n))return ut(n)}throw Oe(n)}function rt(n){return new w(function(t){var e=n[J]();if(p(e.subscribe))return e.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function it(n){return new w(function(t){for(var e=0;e<n.length&&!t.closed;e++)t.next(n[e]);t.complete()})}function ot(n){return new w(function(t){n.then(function(e){t.closed||(t.next(e),t.complete())},function(e){return t.error(e)}).then(null,ce)})}function st(n){return new w(function(t){var e,r;try{for(var i=L(n),o=i.next();!o.done;o=i.next()){var s=o.value;if(t.next(s),t.closed)return}}catch(c){e={error:c}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(e)throw e.error}}t.complete()})}function Te(n){return new w(function(t){at(n,t).catch(function(e){return t.error(e)})})}function ut(n){return Te(_e(n))}function at(n,t){var e,r,i,o;return De(this,void 0,void 0,function(){var s,c;return re(this,function(a){switch(a.label){case 0:a.trys.push([0,5,6,11]),e=Ne(n),a.label=1;case 1:return[4,e.next()];case 2:if(r=a.sent(),!!r.done)return[3,4];if(s=r.value,t.next(s),t.closed)return[2];a.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return c=a.sent(),i={error:c},[3,11];case 6:return a.trys.push([6,,9,10]),r&&!r.done&&(o=e.return)?[4,o.call(e)]:[3,8];case 7:a.sent(),a.label=8;case 8:return[3,10];case 9:if(i)throw i.error;return[7];case 10:return[7];case 11:return t.complete(),[2]}})})}function x(n,t,e,r,i){r===void 0&&(r=0),i===void 0&&(i=!1);var o=t.schedule(function(){e(),i?n.add(this.schedule(null,r)):this.unsubscribe()},r);if(n.add(o),!i)return o}function Ce(n,t){return t===void 0&&(t=0),C(function(e,r){e.subscribe(I(r,function(i){return x(r,n,function(){return r.next(i)},t)},function(){return x(r,n,function(){return r.complete()},t)},function(i){return x(r,n,function(){return r.error(i)},t)}))})}function Pe(n,t){return t===void 0&&(t=0),C(function(e,r){r.add(n.schedule(function(){return e.subscribe(r)},t))})}function ct(n,t){return _(n).pipe(Pe(t),Ce(t))}function ft(n,t){return _(n).pipe(Pe(t),Ce(t))}function lt(n,t){return new w(function(e){var r=0;return t.schedule(function(){r===n.length?e.complete():(e.next(n[r++]),e.closed||this.schedule())})})}function dt(n,t){return new w(function(e){var r;return x(e,t,function(){r=n[Ie](),x(e,t,function(){var i,o,s;try{i=r.next(),o=i.value,s=i.done}catch(c){e.error(c);return}s?e.complete():e.next(o)},0,!0)}),function(){return p(r==null?void 0:r.return)&&r.return()}})}function Me(n,t){if(!n)throw new Error("Iterable cannot be null");return new w(function(e){x(e,t,function(){var r=n[Symbol.asyncIterator]();x(e,t,function(){r.next().then(function(i){i.done?e.complete():e.next(i.value)})},0,!0)})})}function ht(n,t){return Me(_e(n),t)}function yt(n,t){if(n!=null){if(we(n))return ct(n,t);if(ge(n))return lt(n,t);if(Se(n))return ft(n,t);if(Ee(n))return Me(n,t);if(Ae(n))return dt(n,t);if(xe(n))return ht(n,t)}throw Oe(n)}function z(n,t){return t?yt(n,t):_(n)}function vt(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];var e=me(n);return z(n,e)}function pt(n){return n instanceof Date&&!isNaN(n)}function F(n,t){return C(function(e,r){var i=0;e.subscribe(I(r,function(o){r.next(n.call(t,o,i++))}))})}var bt=Array.isArray;function mt(n,t){return bt(t)?n.apply(void 0,j([],k(t))):n(t)}function gt(n){return F(function(t){return mt(n,t)})}var St=Array.isArray,wt=Object.getPrototypeOf,Et=Object.prototype,Ot=Object.keys;function It(n){if(n.length===1){var t=n[0];if(St(t))return{args:t,keys:null};if(At(t)){var e=Ot(t);return{args:e.map(function(r){return t[r]}),keys:e}}}return{args:n,keys:null}}function At(n){return n&&typeof n=="object"&&wt(n)===Et}function _t(n,t){return n.reduce(function(e,r,i){return e[r]=t[i],e},{})}function xt(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];var e=me(n),r=tt(n),i=It(n),o=i.args,s=i.keys;if(o.length===0)return z([],e);var c=new w(Tt(o,e,s?function(a){return _t(s,a)}:G));return r?c.pipe(gt(r)):c}function Tt(n,t,e){return e===void 0&&(e=G),function(r){Le(t,function(){for(var i=n.length,o=new Array(i),s=i,c=i,a=function(f){Le(t,function(){var y=z(n[f],t),b=!1;y.subscribe(I(r,function(l){o[f]=l,b||(b=!0,c--),c||r.next(e(o.slice()))},function(){--s||r.complete()}))},r)},u=0;u<i;u++)a(u)},r)}}function Le(n,t,e){n?x(e,n,t):t()}function Ct(n,t,e,r,i,o,s,c){var a=[],u=0,f=0,y=!1,b=function(){y&&!a.length&&!u&&t.complete()},l=function(h){return u<r?v(h):a.push(h)},v=function(h){u++;var E=!1;_(e(h,f++)).subscribe(I(t,function(A){t.next(A)},function(){E=!0},void 0,function(){if(E)try{u--;for(var A=function(){var M=a.shift();s||v(M)};a.length&&u<r;)A();b()}catch(M){t.error(M)}}))};return n.subscribe(I(t,l,function(){y=!0,b()})),function(){}}function H(n,t,e){return e===void 0&&(e=1/0),p(t)?H(function(r,i){return F(function(o,s){return t(r,o,i,s)})(_(n(r,i)))},e):(typeof t=="number"&&(e=t),C(function(r,i){return Ct(r,i,n,e)}))}function Re(n,t,e){n===void 0&&(n=0),e===void 0&&(e=Ze);var r=-1;return t!=null&&(pe(t)?e=t:r=t),new w(function(i){var o=pt(n)?+n-e.now():n;o<0&&(o=0);var s=0;return e.schedule(function(){i.closed||(i.next(s++),0<=r?this.schedule(void 0,r):i.complete())},o)})}function Pt(n,t){return p(t)?H(n,t,1):H(n,1)}function Mt(n){return n<=0?function(){return et}:C(function(t,e){var r=0;t.subscribe(I(e,function(i){++r<=n&&(e.next(i),n<=r&&e.complete())}))})}function Lt(n){return F(function(){return n})}function Rt(n,t){return H(function(e,r){return _(n(e,r)).pipe(Mt(1),Lt(e))})}function kt(n,t){t===void 0&&(t=ve);var e=Re(n,t);return Rt(function(){return e})}function jt(n){var t;t={count:n};var e=t.count,r=e===void 0?1/0:e,i=t.delay,o=t.resetOnSuccess,s=o===void 0?!1:o;return r<=0?G:C(function(c,a){var u=0,f,y=function(){var b=!1;f=c.subscribe(I(a,function(l){s&&(u=0),a.next(l)},void 0,function(l){if(u++<r){var v=function(){f?(f.unsubscribe(),f=null,y()):b=!0};if(i!=null){var h=typeof i=="number"?Re(i):_(i(l,u)),E=I(a,function(){E.unsubscribe(),v()},function(){a.complete()});h.subscribe(E)}else v()}else a.error(l)})),b&&(f.unsubscribe(),f=null,y())};y()})}function Dt(n){return C(function(t,e){_(n).subscribe(I(e,function(){return e.complete()},Y)),!e.closed&&t.subscribe(e)})}async function Ut(n,t){const e=n.getReader();let r;for(;!(r=await e.read()).done;)t(r.value)}function Nt(n){let t,e,r,i=!1;return function(s){t===void 0?(t=s,e=0,r=-1):t=Gt(t,s);const c=t.length;let a=0;for(;e<c;){i&&(t[e]===10&&(a=++e),i=!1);let u=-1;for(;e<c&&u===-1;++e)switch(t[e]){case 58:r===-1&&(r=e-a);break;case 13:i=!0;case 10:u=e;break}if(u===-1)break;n(t.subarray(a,u),r),a=e,r=-1}a===c?t=void 0:a!==0&&(t=t.subarray(a),e-=a)}}function $t(n,t,e){let r=ke();const i=new TextDecoder;return function(s,c){if(s.length===0)e==null||e(r),r=ke();else if(c>0){const a=i.decode(s.subarray(0,c)),u=c+(s[c+1]===32?2:1),f=i.decode(s.subarray(u));switch(a){case"data":r.data=r.data?r.data+`
|
|
4
|
+
`+f:f;break;case"event":r.event=f;break;case"id":n(r.id=f);break;case"retry":const y=parseInt(f,10);isNaN(y)||t(r.retry=y);break}}}}function Gt(n,t){const e=new Uint8Array(n.length+t.length);return e.set(n),e.set(t,n.length),e}function ke(){return{data:"",event:"",id:"",retry:void 0}}var Ft=function(n,t){var e={};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&t.indexOf(r)<0&&(e[r]=n[r]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(n);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(n,r[i])&&(e[r[i]]=n[r[i]]);return e};const Q="text/event-stream",Ht=1e3,je="last-event-id";function Vt(n,t){var{signal:e,headers:r,onopen:i,onmessage:o,onclose:s,onerror:c,openWhenHidden:a,fetch:u}=t,f=Ft(t,["signal","headers","onopen","onmessage","onclose","onerror","openWhenHidden","fetch"]);return new Promise((y,b)=>{const l=Object.assign({},r);l.accept||(l.accept=Q);let v;function h(){v.abort(),document.hidden||ee()}a||document.addEventListener("visibilitychange",h);let E=Ht,A=0;function M(){document.removeEventListener("visibilitychange",h),window.clearTimeout(A),v.abort()}e==null||e.addEventListener("abort",()=>{M(),y()});const Wt=u??window.fetch,Jt=i??Bt;async function ee(){var te;v=new AbortController;try{const V=await Wt(n,Object.assign(Object.assign({},f),{headers:l,signal:v.signal}));await Jt(V),await Ut(V.body,Nt($t(T=>{T?l[je]=T:delete l[je]},T=>{E=T},o))),s==null||s(),M(),y()}catch(V){if(!v.signal.aborted)try{const T=(te=c==null?void 0:c(V))!==null&&te!==void 0?te:E;window.clearTimeout(A),A=window.setTimeout(ee,T)}catch(T){M(),b(T)}}}ee()})}function Bt(n){const t=n.headers.get("content-type");if(!(t!=null&&t.startsWith(Q)))throw new Error(`Expected content-type to be ${Q}, Actual: ${t}`)}function Kt(n){const{endpoint:t,apiKey:e,payload:r,debugMode:i}=n;return new w(o=>{const s=new AbortController,c={"Content-Type":"application/json"};e&&(c["X-API-KEY"]=e);const a=new URLSearchParams;i&&a.set("is_debug","true");const u=new URL(t);return a.toString()&&(u.search=a.toString()),Vt(u.toString(),{method:"POST",headers:c,body:r?JSON.stringify(r):void 0,signal:s.signal,openWhenHidden:!0,onopen:async f=>{f.ok||(o.error(f),s.abort())},onmessage:f=>{o.next(JSON.parse(f.data))},onclose:()=>{o.complete()},onerror:f=>{throw o.error(f),s.abort(),f}}),()=>{s.abort()}})}class Yt{constructor(){S(this,"listeners",{})}on(t,e){this.listeners=Object.assign({},this.listeners,{[t]:(this.listeners[t]??[]).concat(e)})}off(t,e){this.listeners[t]&&(this.listeners=Object.assign({},this.listeners,{[t]:(this.listeners[t]??[]).filter(r=>r!==e)}))}remove(t){delete this.listeners[t]}emit(t,...e){this.listeners[t]&&this.listeners[t].forEach(r=>r(...e))}}class qt{constructor(t){S(this,"apiKey");S(this,"endpoint");S(this,"debugMode");S(this,"destroy$",new X);S(this,"sseEmitter",new Yt);S(this,"transformSsePayload");if(!t.endpoint&&!t.botProviderEndpoint)throw new Error("Either endpoint or botProviderEndpoint must be provided");if(this.apiKey=t.apiKey,this.debugMode=t.debugMode,this.transformSsePayload=t.transformSsePayload,!t.endpoint&&t.botProviderEndpoint){const e=t.botProviderEndpoint.replace(/\/+$/,"");this.endpoint=`${e}/message/sse`}else t.endpoint&&(this.endpoint=t.endpoint,this.debugMode&&console.warn('[AsgardServiceClient] The "endpoint" option is deprecated and will be removed in the next major version. Please use "botProviderEndpoint" instead. The SSE endpoint will be automatically derived as "${botProviderEndpoint}/message/sse".'))}on(t,e){this.sseEmitter.remove(t),this.sseEmitter.on(t,e)}handleEvent(t){switch(t.eventType){case d.INIT:this.sseEmitter.emit(d.INIT,t);break;case d.PROCESS_START:case d.PROCESS_COMPLETE:this.sseEmitter.emit(d.PROCESS,t);break;case d.MESSAGE_START:case d.MESSAGE_DELTA:case d.MESSAGE_COMPLETE:this.sseEmitter.emit(d.MESSAGE,t);break;case d.TOOL_CALL_START:case d.TOOL_CALL_COMPLETE:this.sseEmitter.emit(d.TOOL_CALL,t);break;case d.DONE:this.sseEmitter.emit(d.DONE,t);break;case d.ERROR:this.sseEmitter.emit(d.ERROR,t);break}}fetchSse(t,e){var r,i;(r=e==null?void 0:e.onSseStart)==null||r.call(e),Kt({apiKey:this.apiKey,endpoint:this.endpoint,debugMode:this.debugMode,payload:((i=this.transformSsePayload)==null?void 0:i.call(this,t))??t}).pipe(Pt(o=>vt(o).pipe(kt((e==null?void 0:e.delayTime)??50))),Dt(this.destroy$),jt(3)).subscribe({next:o=>{var s;(s=e==null?void 0:e.onSseMessage)==null||s.call(e,o),this.handleEvent(o)},error:o=>{var s;(s=e==null?void 0:e.onSseError)==null||s.call(e,o)},complete:()=>{var o;(o=e==null?void 0:e.onSseCompleted)==null||o.call(e)}})}close(){this.destroy$.next(),this.destroy$.complete()}}class Z{constructor(t){S(this,"client");S(this,"customChannelId");S(this,"customMessageId");S(this,"isConnecting$");S(this,"conversation$");S(this,"statesObserver");S(this,"statesSubscription");if(!t.client)throw new Error("client must be required");if(!t.customChannelId)throw new Error("customChannelId must be required");this.client=t.client,this.customChannelId=t.customChannelId,this.customMessageId=t.customMessageId,this.isConnecting$=new de(!1),this.conversation$=new de(t.conversation),this.statesObserver=t.statesObserver}static async reset(t,e,r){const i=new Z(t);try{return i.subscribe(),await i.resetChannel(e,r),i}catch(o){throw i.close(),o}}subscribe(){this.statesSubscription=xt([this.isConnecting$,this.conversation$]).pipe(F(([t,e])=>({isConnecting:t,conversation:e}))).subscribe(this.statesObserver)}fetchSse(t,e){return new Promise((r,i)=>{this.isConnecting$.next(!0),this.client.fetchSse(t,{onSseStart:e==null?void 0:e.onSseStart,onSseMessage:o=>{var s;(s=e==null?void 0:e.onSseMessage)==null||s.call(e,o),this.conversation$.next(this.conversation$.value.onMessage(o))},onSseError:o=>{var s;(s=e==null?void 0:e.onSseError)==null||s.call(e,o),this.isConnecting$.next(!1),i(o)},onSseCompleted:()=>{var o;(o=e==null?void 0:e.onSseCompleted)==null||o.call(e),this.isConnecting$.next(!1),r()}})})}resetChannel(t,e){return this.fetchSse({action:g.RESET_CHANNEL,customChannelId:this.customChannelId,customMessageId:this.customMessageId,text:(t==null?void 0:t.text)||"",payload:t==null?void 0:t.payload},e)}sendMessage(t,e){const r=t.text.trim(),i=t.customMessageId??crypto.randomUUID();return this.conversation$.next(this.conversation$.value.pushMessage({type:"user",messageId:i,text:r,time:new Date})),this.fetchSse({action:g.NONE,customChannelId:this.customChannelId,customMessageId:i,payload:t==null?void 0:t.payload,text:r},e)}close(){var t;this.isConnecting$.complete(),this.conversation$.complete(),(t=this.statesSubscription)==null||t.unsubscribe()}}class P{constructor({messages:t}){S(this,"messages",null);this.messages=t}pushMessage(t){const e=new Map(this.messages);return e.set(t.messageId,t),new P({messages:e})}onMessage(t){switch(t.eventType){case d.MESSAGE_START:return this.onMessageStart(t);case d.MESSAGE_DELTA:return this.onMessageDelta(t);case d.MESSAGE_COMPLETE:return this.onMessageComplete(t);case d.ERROR:return this.onMessageError(t);default:return this}}onMessageStart(t){const e=t.fact.messageStart.message,r=new Map(this.messages);return r.set(e.messageId,{type:"bot",eventType:d.MESSAGE_START,isTyping:!0,typingText:"",messageId:e.messageId,message:e,time:new Date}),new P({messages:r})}onMessageDelta(t){const e=t.fact.messageDelta.message,r=new Map(this.messages),i=r.get(e.messageId);if((i==null?void 0:i.type)!=="bot")return this;const o=`${(i==null?void 0:i.typingText)??""}${e.text}`;return r.set(e.messageId,{type:"bot",eventType:d.MESSAGE_DELTA,isTyping:!0,typingText:o,messageId:e.messageId,message:e,time:new Date}),new P({messages:r})}onMessageComplete(t){const e=t.fact.messageComplete.message,r=new Map(this.messages);return r.set(e.messageId,{type:"bot",eventType:d.MESSAGE_COMPLETE,isTyping:!1,typingText:null,messageId:e.messageId,message:e,time:new Date}),new P({messages:r})}onMessageError(t){const e=crypto.randomUUID(),r=t.fact.runError.error,i=new Map(this.messages);return i.set(e,{type:"error",eventType:d.ERROR,messageId:e,error:r,time:new Date}),new P({messages:i})}}m.AsgardServiceClient=qt,m.Channel=Z,m.Conversation=P,m.EventType=d,m.FetchSseAction=g,m.MessageTemplateType=ne,Object.defineProperty(m,Symbol.toStringTag,{value:"Module"})});
|
|
5
5
|
//# sourceMappingURL=index.js.map
|