@asgard-js/core 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- export declare enum FetchSSEAction {
1
+ export declare enum FetchSseAction {
2
2
  RESET_CHANNEL = "RESET_CHANNEL",
3
3
  NONE = "NONE"
4
4
  }
package/dist/index.cjs CHANGED
@@ -1,5 +1,5 @@
1
- "use strict";var Ye=Object.defineProperty;var Be=(t,n,e)=>n in t?Ye(t,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[n]=e;var E=(t,n,e)=>Be(t,typeof n!="symbol"?n+"":n,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var I=(t=>(t.RESET_CHANNEL="RESET_CHANNEL",t.NONE="NONE",t))(I||{}),le=(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))(le||{}),de=(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))(de||{});function Ke(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var J={exports:{}},T=typeof Reflect=="object"?Reflect:null,Z=T&&typeof T.apply=="function"?T.apply:function(n,e,r){return Function.prototype.apply.call(n,e,r)},U;T&&typeof T.ownKeys=="function"?U=T.ownKeys:Object.getOwnPropertySymbols?U=function(n){return Object.getOwnPropertyNames(n).concat(Object.getOwnPropertySymbols(n))}:U=function(n){return Object.getOwnPropertyNames(n)};function ze(t){console&&console.warn&&console.warn(t)}var he=Number.isNaN||function(n){return n!==n};function d(){d.init.call(this)}J.exports=d;J.exports.once=Ze;d.EventEmitter=d;d.prototype._events=void 0;d.prototype._eventsCount=0;d.prototype._maxListeners=void 0;var ee=10;function G(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 ee},set:function(t){if(typeof t!="number"||t<0||he(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");ee=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||he(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 ve(t){return t._maxListeners===void 0?d.defaultMaxListeners:t._maxListeners}d.prototype.getMaxListeners=function(){return ve(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")Z(f,this,e);else for(var a=f.length,l=we(f,a),r=0;r<a;++r)Z(l[r],this,e);return!0};function pe(t,n,e,r){var i,o,u;if(G(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=ve(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,ze(s)}return t}d.prototype.addListener=function(n,e){return pe(this,n,e,!1)};d.prototype.on=d.prototype.addListener;d.prototype.prependListener=function(n,e){return pe(this,n,e,!0)};function Je(){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 ye(t,n,e){var r={fired:!1,wrapFn:void 0,target:t,type:n,listener:e},i=Je.bind(r);return i.listener=e,r.wrapFn=i,i}d.prototype.once=function(n,e){return G(e),this.on(n,ye(this,n,e)),this};d.prototype.prependOnceListener=function(n,e){return G(e),this.prependListener(n,ye(this,n,e)),this};d.prototype.removeListener=function(n,e){var r,i,o,u,s;if(G(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():Xe(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 be(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?Qe(i):we(i,i.length)}d.prototype.listeners=function(n){return be(this,n,!0)};d.prototype.rawListeners=function(n){return be(this,n,!1)};d.listenerCount=function(t,n){return typeof t.listenerCount=="function"?t.listenerCount(n):me.call(t,n)};d.prototype.listenerCount=me;function me(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 we(t,n){for(var e=new Array(n),r=0;r<n;++r)e[r]=t[r];return e}function Xe(t,n){for(;n+1<t.length;n++)t[n]=t[n+1];t.pop()}function Qe(t){for(var n=new Array(t.length),e=0;e<n.length;++e)n[e]=t[e].listener||t[e];return n}function Ze(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))}ge(t,n,o,{once:!0}),n!=="error"&&et(t,i,{once:!0})})}function et(t,n,e){typeof t.on=="function"&&ge(t,"error",n,e)}function ge(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 tt=J.exports;const nt=Ke(tt);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 rt(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(y){u(y)}}function f(l){try{a(r.throw(l))}catch(y){u(y)}}function a(l){l.done?o(l.value):i(l.value).then(s,f)}a((r=r.apply(t,n||[])).next())})}function Ee(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 P(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 k(t){return this instanceof k?(this.v=t,this):new k(t)}function it(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,y)}}function s(c,p){r[c]&&(i[c]=function(h){return new Promise(function(O,w){o.push([c,h,O,w])>1||f(c,h)})},p&&(i[c]=p(i[c])))}function f(c,p){try{a(r[c](p))}catch(h){m(o[0][3],h)}}function a(c){c.value instanceof k?Promise.resolve(c.value.v).then(l,y):m(o[0][2],c)}function l(c){f("next",c)}function y(c){f("throw",c)}function m(c,p){c(p),o.shift(),o.length&&f(o[0][0],o[0][1])}}function ot(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 P=="function"?P(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)}}function v(t){return typeof t=="function"}function Se(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 V=Se(function(t){return function(e){t(this),this.message=e?e.length+` errors occurred during unsubscription:
1
+ "use strict";var Le=Object.defineProperty;var je=(n,t,e)=>t in n?Le(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var _=(n,t,e)=>je(n,typeof t!="symbol"?t+"":t,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var N=(n=>(n.RESET_CHANNEL="RESET_CHANNEL",n.NONE="NONE",n))(N||{}),m=(n=>(n.INIT="asgard.run.init",n.MESSAGE_START="asgard.message.start",n.MESSAGE_DELTA="asgard.message.delta",n.MESSAGE_COMPLETE="asgard.message.complete",n.DONE="asgard.run.done",n))(m||{}),oe=(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))(oe||{}),V=function(n,t){return V=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])},V(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");V(n,t);function e(){this.constructor=n}n.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}function Ne(n,t,e,r){function i(s){return s instanceof e?s:new e(function(o){o(s)})}return new(e||(e=Promise))(function(s,o){function c(l){try{a(r.next(l))}catch(h){o(h)}}function u(l){try{a(r.throw(l))}catch(h){o(h)}}function a(l){l.done?s(l.value):i(l.value).then(c,u)}a((r=r.apply(n,t||[])).next())})}function ue(n,t){var e={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},r,i,s,o=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return o.next=c(0),o.throw=c(1),o.return=c(2),typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function c(a){return function(l){return u([a,l])}}function u(a){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(e=0)),e;)try{if(r=1,i&&(s=a[0]&2?i.return:a[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,a[1])).done)return s;switch(i=0,s&&(a=[a[0]&2,s.value]),a[0]){case 0:case 1:s=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(s=e.trys,!(s=s.length>0&&s[s.length-1])&&(a[0]===6||a[0]===2)){e=0;continue}if(a[0]===3&&(!s||a[1]>s[0]&&a[1]<s[3])){e.label=a[1];break}if(a[0]===6&&e.label<s[1]){e.label=s[1],s=a;break}if(s&&e.label<s[2]){e.label=s[2],e.ops.push(a);break}s[2]&&e.ops.pop(),e.trys.pop();continue}a=t.call(n,e)}catch(l){a=[6,l],i=0}finally{r=s=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}}function P(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 R(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var r=e.call(n),i,s=[],o;try{for(;(t===void 0||t-- >0)&&!(i=r.next()).done;)s.push(i.value)}catch(c){o={error:c}}finally{try{i&&!i.done&&(e=r.return)&&e.call(r)}finally{if(o)throw o.error}}return s}function U(n,t,e){if(e||arguments.length===2)for(var r=0,i=t.length,s;r<i;r++)(s||!(r in t))&&(s||(s=Array.prototype.slice.call(t,0,r)),s[r]=t[r]);return n.concat(s||Array.prototype.slice.call(t))}function C(n){return this instanceof C?(this.v=n,this):new C(n)}function Re(n,t,e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=e.apply(n,t||[]),i,s=[];return i=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),c("next"),c("throw"),c("return",o),i[Symbol.asyncIterator]=function(){return this},i;function o(f){return function(y){return Promise.resolve(y).then(f,h)}}function c(f,y){r[f]&&(i[f]=function(d){return new Promise(function(w,S){s.push([f,d,w,S])>1||u(f,d)})},y&&(i[f]=y(i[f])))}function u(f,y){try{a(r[f](y))}catch(d){p(s[0][3],d)}}function a(f){f.value instanceof C?Promise.resolve(f.value.v).then(l,h):p(s[0][2],f)}function l(f){u("next",f)}function h(f){u("throw",f)}function p(f,y){f(y),s.shift(),s.length&&u(s[0][0],s[0][1])}}function Ue(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 P=="function"?P(n):n[Symbol.iterator](),e={},r("next"),r("throw"),r("return"),e[Symbol.asyncIterator]=function(){return this},e);function r(s){e[s]=n[s]&&function(o){return new Promise(function(c,u){o=n[s](o),i(c,u,o.done,o.value)})}}function i(s,o,c,u){Promise.resolve(u).then(function(a){s({value:a,done:c})},o)}}function v(n){return typeof n=="function"}function ae(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 $=ae(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 N=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=P(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 V?h.errors:[h]}var y=this._finalizers;if(y){this._finalizers=null;try{for(var m=P(y),c=m.next();!c.done;c=m.next()){var p=c.value;try{te(p)}catch(h){o=o??[],h instanceof V?o=D(D([],$(o)),$(h.errors)):o.push(h)}}}catch(h){r={error:h}}finally{try{c&&!c.done&&(i=m.return)&&i.call(m)}finally{if(r)throw r.error}}}if(o)throw new V(o)}},t.prototype.add=function(n){var e;if(n&&n!==this)if(this.closed)te(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}(),Oe=N.EMPTY;function _e(t){return t instanceof N||t&&"closed"in t&&v(t.remove)&&v(t.add)&&v(t.unsubscribe)}function te(t){v(t)?t():t.unsubscribe()}var ut={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},xe={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=xe.delegate;return((n==null?void 0:n.clearTimeout)||clearTimeout)(t)},delegate:void 0};function Le(t){xe.setTimeout(function(){throw t})}function B(){}function M(t){t()}var X=function(t){S(n,t);function n(e){var r=t.call(this)||this;return r.isStopped=!1,e?(r.destination=e,_e(e)&&e.add(r)):r.destination=ft,r}return n.create=function(e,r,i){return new K(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}(N),st=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){R(r)}},t.prototype.error=function(n){var e=this.partialObserver;if(e.error)try{e.error(n)}catch(r){R(r)}else R(n)},t.prototype.complete=function(){var n=this.partialObserver;if(n.complete)try{n.complete()}catch(e){R(e)}},t}(),K=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 st(u),o}return n}(X);function R(t){Le(t)}function at(t){throw t}var ft={closed:!0,next:B,error:at,complete:B},Q=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function ct(t){return t}function lt(t){return t.length===0?ct:t.length===1?t[0]:function(e){return t.reduce(function(r,i){return i(r)},e)}}var b=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=ht(n)?n:new K(n,e,r);return M(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=ne(e),new e(function(i,o){var u=new K({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[Q]=function(){return this},t.prototype.pipe=function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];return lt(n)(this)},t.prototype.toPromise=function(n){var e=this;return n=ne(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 ne(t){var n;return(n=t??ut.Promise)!==null&&n!==void 0?n:Promise}function dt(t){return t&&v(t.next)&&v(t.error)&&v(t.complete)}function ht(t){return t&&t instanceof X||dt(t)&&_e(t)}function vt(t){return v(t==null?void 0:t.lift)}function L(t){return function(n){if(vt(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 C(t,n,e,r,i){return new pt(t,n,e,r,i)}var pt=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}(X),yt=Se(function(t){return function(){t(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),Ae=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 re(this,this);return r.operator=e,r},n.prototype._throwIfClosed=function(){if(this.closed)throw new yt},n.prototype.next=function(e){var r=this;M(function(){var i,o;if(r._throwIfClosed(),!r.isStopped){r.currentObservers||(r.currentObservers=Array.from(r.observers));try{for(var u=P(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;M(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;M(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?Oe:(this.currentObservers=null,s.push(e),new N(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 b;return e.source=this,e},n.create=function(e,r){return new re(e,r)},n}(b),re=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:Oe},n}(Ae),bt={now:function(){return Date.now()},delegate:void 0},mt=function(t){S(n,t);function n(e,r){return t.call(this)||this}return n.prototype.schedule=function(e,r){return this},n}(N),ie={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},wt=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),ie.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&&ie.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}(mt),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=bt.now,t}(),gt=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),Ie=new gt(wt),Et=Ie,St=new b(function(t){return t.complete()});function Te(t){return t&&v(t.schedule)}function Ot(t){return t[t.length-1]}function _t(t){return Te(Ot(t))?t.pop():void 0}var ke=function(t){return t&&typeof t.length=="number"&&typeof t!="function"};function Pe(t){return v(t==null?void 0:t.then)}function Ce(t){return v(t[Q])}function Ne(t){return Symbol.asyncIterator&&v(t==null?void 0:t[Symbol.asyncIterator])}function je(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 xt(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var Re=xt();function Ue(t){return v(t==null?void 0:t[Re])}function Me(t){return it(this,arguments,function(){var e,r,i,o;return Ee(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,k(e.read())];case 3:return r=u.sent(),i=r.value,o=r.done,o?[4,k(void 0)]:[3,5];case 4:return[2,u.sent()];case 5:return[4,k(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 $e(t){return v(t==null?void 0:t.getReader)}function A(t){if(t instanceof b)return t;if(t!=null){if(Ce(t))return Lt(t);if(ke(t))return At(t);if(Pe(t))return It(t);if(Ne(t))return De(t);if(Ue(t))return Tt(t);if($e(t))return kt(t)}throw je(t)}function Lt(t){return new b(function(n){var e=t[Q]();if(v(e.subscribe))return e.subscribe(n);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function At(t){return new b(function(n){for(var e=0;e<t.length&&!n.closed;e++)n.next(t[e]);n.complete()})}function It(t){return new b(function(n){t.then(function(e){n.closed||(n.next(e),n.complete())},function(e){return n.error(e)}).then(null,Le)})}function Tt(t){return new b(function(n){var e,r;try{for(var i=P(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 De(t){return new b(function(n){Pt(t,n).catch(function(e){return n.error(e)})})}function kt(t){return De(Me(t))}function Pt(t,n){var e,r,i,o;return rt(this,void 0,void 0,function(){var u,s;return Ee(this,function(f){switch(f.label){case 0:f.trys.push([0,5,6,11]),e=ot(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 x(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 Fe(t,n){return n===void 0&&(n=0),L(function(e,r){e.subscribe(C(r,function(i){return x(r,t,function(){return r.next(i)},n)},function(){return x(r,t,function(){return r.complete()},n)},function(i){return x(r,t,function(){return r.error(i)},n)}))})}function He(t,n){return n===void 0&&(n=0),L(function(e,r){r.add(t.schedule(function(){return e.subscribe(r)},n))})}function Ct(t,n){return A(t).pipe(He(n),Fe(n))}function Nt(t,n){return A(t).pipe(He(n),Fe(n))}function jt(t,n){return new b(function(e){var r=0;return n.schedule(function(){r===t.length?e.complete():(e.next(t[r++]),e.closed||this.schedule())})})}function Rt(t,n){return new b(function(e){var r;return x(e,n,function(){r=t[Re](),x(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 Ge(t,n){if(!t)throw new Error("Iterable cannot be null");return new b(function(e){x(e,n,function(){var r=t[Symbol.asyncIterator]();x(e,n,function(){r.next().then(function(i){i.done?e.complete():e.next(i.value)})},0,!0)})})}function Ut(t,n){return Ge(Me(t),n)}function Mt(t,n){if(t!=null){if(Ce(t))return Ct(t,n);if(ke(t))return jt(t,n);if(Pe(t))return Nt(t,n);if(Ne(t))return Ge(t,n);if(Ue(t))return Rt(t,n);if($e(t))return Ut(t,n)}throw je(t)}function $t(t,n){return n?Mt(t,n):A(t)}function Dt(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var e=_t(t);return $t(t,e)}function Ft(t){return t instanceof Date&&!isNaN(t)}function We(t,n){return L(function(e,r){var i=0;e.subscribe(C(r,function(o){r.next(t.call(n,o,i++))}))})}function Ht(t,n,e,r,i,o,u,s){var f=[],a=0,l=0,y=!1,m=function(){y&&!f.length&&!a&&n.complete()},c=function(h){return a<r?p(h):f.push(h)},p=function(h){a++;var O=!1;A(e(h,l++)).subscribe(C(n,function(w){n.next(w)},function(){O=!0},void 0,function(){if(O)try{a--;for(var w=function(){var _=f.shift();u||p(_)};f.length&&a<r;)w();m()}catch(_){n.error(_)}}))};return t.subscribe(C(n,c,function(){y=!0,m()})),function(){}}function H(t,n,e){return e===void 0&&(e=1/0),v(n)?H(function(r,i){return We(function(o,u){return n(r,o,i,u)})(A(t(r,i)))},e):(typeof n=="number"&&(e=n),L(function(r,i){return Ht(r,i,t,e)}))}function Gt(t,n,e){t===void 0&&(t=0),e===void 0&&(e=Et);var r=-1;return n!=null&&(Te(n)?e=n:r=n),new b(function(i){var o=Ft(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 Wt(t,n){return v(n)?H(t,n,1):H(t,1)}function qt(t){return t<=0?function(){return St}:L(function(n,e){var r=0;n.subscribe(C(e,function(i){++r<=t&&(e.next(i),t<=r&&e.complete())}))})}function Vt(t){return We(function(){return t})}function Yt(t,n){return H(function(e,r){return A(t(e,r)).pipe(qt(1),Vt(e))})}function Bt(t,n){n===void 0&&(n=Ie);var e=Gt(t,n);return Yt(function(){return e})}function ue(t){return L(function(n,e){try{n.subscribe(e)}finally{e.add(t)}})}function se(t){return L(function(n,e){A(t).subscribe(C(e,function(){return e.complete()},B)),!e.closed&&n.subscribe(e)})}async function Kt(t,n){const e=t.getReader();let r;for(;!(r=await e.read()).done;)n(r.value)}function zt(t){let n,e,r,i=!1;return function(u){n===void 0?(n=u,e=0,r=-1):n=Xt(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 Jt(t,n,e){let r=ae();const i=new TextDecoder;return function(u,s){if(u.length===0)e==null||e(r),r=ae();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
- `+l:l;break;case"event":r.event=l;break;case"id":t(r.id=l);break;case"retry":const y=parseInt(l,10);isNaN(y)||n(r.retry=y);break}}}}function Xt(t,n){const e=new Uint8Array(t.length+n.length);return e.set(t),e.set(n,t.length),e}function ae(){return{data:"",event:"",id:"",retry:void 0}}var Qt=function(t,n){var e={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&n.indexOf(r)<0&&(e[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(t);i<r.length;i++)n.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(t,r[i])&&(e[r[i]]=t[r[i]]);return e};const z="text/event-stream",Zt=1e3,fe="last-event-id";function en(t,n){var{signal:e,headers:r,onopen:i,onmessage:o,onclose:u,onerror:s,openWhenHidden:f,fetch:a}=n,l=Qt(n,["signal","headers","onopen","onmessage","onclose","onerror","openWhenHidden","fetch"]);return new Promise((y,m)=>{const c=Object.assign({},r);c.accept||(c.accept=z);let p;function h(){p.abort(),document.hidden||W()}f||document.addEventListener("visibilitychange",h);let O=Zt,w=0;function _(){document.removeEventListener("visibilitychange",h),window.clearTimeout(w),p.abort()}e==null||e.addEventListener("abort",()=>{_(),y()});const qe=a??window.fetch,Ve=i??tn;async function W(){var q;p=new AbortController;try{const j=await qe(t,Object.assign(Object.assign({},l),{headers:c,signal:p.signal}));await Ve(j),await Kt(j.body,zt(Jt(g=>{g?c[fe]=g:delete c[fe]},g=>{O=g},o))),u==null||u(),_(),y()}catch(j){if(!p.signal.aborted)try{const g=(q=s==null?void 0:s(j))!==null&&q!==void 0?q:O;window.clearTimeout(w),w=window.setTimeout(W,g)}catch(g){_(),m(g)}}}W()})}function tn(t){const n=t.headers.get("content-type");if(!(n!=null&&n.startsWith(z)))throw new Error(`Expected content-type to be ${z}, Actual: ${n}`)}function ce(t){const{endpoint:n,webhookToken:e,payload:r}=t;return new b(i=>{const o=new AbortController;return en(n,{method:"POST",headers:{"X-Asgard-Webhook-Token":e,"Content-Type":"application/json"},body:r?JSON.stringify(r):void 0,signal:o.signal,onopen:async u=>{u.ok||(i.error(u),o.abort())},onmessage:u=>{i.next(u)},onclose:()=>{i.complete()},onerror:u=>{i.error(u),o.abort()}}),()=>{o.abort()}})}class nn{constructor(n){E(this,"baseUrl");E(this,"namespace");E(this,"botProviderName");E(this,"endpoint");E(this,"webhookToken");E(this,"eventEmitter");E(this,"destroy$",new Ae);if(!n.baseUrl)throw new Error("baseUrl must be required");if(!n.namespace)throw new Error("namespace must be required");if(!n.botProviderName)throw new Error("botProviderName must be required");if(!n.webhookToken)throw new Error("webhookToken must be required");this.baseUrl=n.baseUrl,this.namespace=n.namespace,this.botProviderName=n.botProviderName,this.webhookToken=n.webhookToken,this.endpoint=`${this.baseUrl}/generic/ns/${this.namespace}/bot-provider/${this.botProviderName}/message/sse`,this.eventEmitter=new nt}on(n,e,r){const i=`${n}:${e}`;this.eventEmitter.listeners(i).length>0&&this.eventEmitter.removeAllListeners(i),this.eventEmitter.on(i,r)}setChannel(n,e){var r;return(r=e==null?void 0:e.onStart)==null||r.call(e),ce({endpoint:this.endpoint,webhookToken:this.webhookToken,payload:Object.assign({action:I.RESET_CHANNEL},n)}).pipe(se(this.destroy$),ue(()=>{var i;return(i=e==null?void 0:e.onCompleted)==null?void 0:i.call(e)})).subscribe({next:i=>{this.eventEmitter.emit(`${I.RESET_CHANNEL}:${i.event}`,JSON.parse(i.data))}})}sendMessage(n,e){var r;return(r=e==null?void 0:e.onStart)==null||r.call(e),ce({endpoint:this.endpoint,webhookToken:this.webhookToken,payload:Object.assign({action:I.NONE},n)}).pipe(Wt(i=>Dt(i).pipe(Bt((e==null?void 0:e.delayTime)??50))),se(this.destroy$),ue(()=>{var i;return(i=e==null?void 0:e.onCompleted)==null?void 0:i.call(e)})).subscribe({next:i=>{this.eventEmitter.emit(`${I.NONE}:${i.event}`,JSON.parse(i.data))}})}close(){this.destroy$.next(),this.destroy$.complete()}}exports.AsgardServiceClient=nn;exports.EventType=le;exports.FetchSSEAction=I;exports.MessageTemplateType=de;
3
+ `):"",this.name="UnsubscriptionError",this.errors=e}});function G(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,s;if(!this.closed){this.closed=!0;var o=this._parentage;if(o)if(this._parentage=null,Array.isArray(o))try{for(var c=P(o),u=c.next();!u.done;u=c.next()){var a=u.value;a.remove(this)}}catch(d){t={error:d}}finally{try{u&&!u.done&&(e=c.return)&&e.call(c)}finally{if(t)throw t.error}}else o.remove(this);var l=this.initialTeardown;if(v(l))try{l()}catch(d){s=d instanceof $?d.errors:[d]}var h=this._finalizers;if(h){this._finalizers=null;try{for(var p=P(h),f=p.next();!f.done;f=p.next()){var y=f.value;try{z(y)}catch(d){s=s??[],d instanceof $?s=U(U([],R(s)),R(d.errors)):s.push(d)}}}catch(d){r={error:d}}finally{try{f&&!f.done&&(i=p.return)&&i.call(p)}finally{if(r)throw r.error}}}if(s)throw new $(s)}},n.prototype.add=function(t){var e;if(t&&t!==this)if(this.closed)z(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)&&G(e,t)},n.prototype.remove=function(t){var e=this._finalizers;e&&G(e,t),t instanceof n&&t._removeParent(this)},n.EMPTY=function(){var t=new n;return t.closed=!0,t}(),n}(),ce=D.EMPTY;function fe(n){return n instanceof D||n&&"closed"in n&&v(n.remove)&&v(n.add)&&v(n.unsubscribe)}function z(n){v(n)?n():n.unsubscribe()}var Ge={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},le={setTimeout:function(n,t){for(var e=[],r=2;r<arguments.length;r++)e[r-2]=arguments[r];return setTimeout.apply(void 0,U([n,t],R(e)))},clearTimeout:function(n){var t=le.delegate;return((t==null?void 0:t.clearTimeout)||clearTimeout)(n)},delegate:void 0};function de(n){le.setTimeout(function(){throw n})}function Y(){}function j(n){n()}var W=function(n){O(t,n);function t(e){var r=n.call(this)||this;return r.isStopped=!1,e?(r.destination=e,fe(e)&&e.add(r)):r.destination=He,r}return t.create=function(e,r,i){return new q(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),Fe=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){L(r)}},n.prototype.error=function(t){var e=this.partialObserver;if(e.error)try{e.error(t)}catch(r){L(r)}else L(t)},n.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(e){L(e)}},n}(),q=function(n){O(t,n);function t(e,r,i){var s=n.call(this)||this,o;return v(e)||!e?o={next:e??void 0,error:r??void 0,complete:i??void 0}:o=e,s.destination=new Fe(o),s}return t}(W);function L(n){de(n)}function Ke(n){throw n}var He={closed:!0,next:Y,error:Ke,complete:Y},X=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function he(n){return n}function $e(n){return n.length===0?he:n.length===1?n[0]:function(e){return n.reduce(function(r,i){return i(r)},e)}}var b=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,s=Ye(t)?t:new q(t,e,r);return j(function(){var o=i,c=o.operator,u=o.source;s.add(c?c.call(s,u):u?i._subscribe(s):i._trySubscribe(s))}),s},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=J(e),new e(function(i,s){var o=new q({next:function(c){try{t(c)}catch(u){s(u),o.unsubscribe()}},error:s,complete:i});r.subscribe(o)})},n.prototype._subscribe=function(t){var e;return(e=this.source)===null||e===void 0?void 0:e.subscribe(t)},n.prototype[X]=function(){return this},n.prototype.pipe=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return $e(t)(this)},n.prototype.toPromise=function(t){var e=this;return t=J(t),new t(function(r,i){var s;e.subscribe(function(o){return s=o},function(o){return i(o)},function(){return r(s)})})},n.create=function(t){return new n(t)},n}();function J(n){var t;return(t=n??Ge.Promise)!==null&&t!==void 0?t:Promise}function Ve(n){return n&&v(n.next)&&v(n.error)&&v(n.complete)}function Ye(n){return n&&n instanceof W||Ve(n)&&fe(n)}function qe(n){return v(n==null?void 0:n.lift)}function M(n){return function(t){if(qe(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 Be(n,t,e,r,i)}var Be=function(n){O(t,n);function t(e,r,i,s,o,c){var u=n.call(this,e)||this;return u.onFinalize=o,u.shouldUnsubscribe=c,u._next=r?function(a){try{r(a)}catch(l){e.error(l)}}:n.prototype._next,u._error=s?function(a){try{s(a)}catch(l){e.error(l)}finally{this.unsubscribe()}}:n.prototype._error,u._complete=i?function(){try{i()}catch(a){e.error(a)}finally{this.unsubscribe()}}:n.prototype._complete,u}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}(W),We=ae(function(n){return function(){n(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),ye=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 Q(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;j(function(){var i,s;if(r._throwIfClosed(),!r.isStopped){r.currentObservers||(r.currentObservers=Array.from(r.observers));try{for(var o=P(r.currentObservers),c=o.next();!c.done;c=o.next()){var u=c.value;u.next(e)}}catch(a){i={error:a}}finally{try{c&&!c.done&&(s=o.return)&&s.call(o)}finally{if(i)throw i.error}}}})},t.prototype.error=function(e){var r=this;j(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;j(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,s=i.hasError,o=i.isStopped,c=i.observers;return s||o?ce:(this.currentObservers=null,c.push(e),new D(function(){r.currentObservers=null,G(c,e)}))},t.prototype._checkFinalizedStatuses=function(e){var r=this,i=r.hasError,s=r.thrownError,o=r.isStopped;i?e.error(s):o&&e.complete()},t.prototype.asObservable=function(){var e=new b;return e.source=this,e},t.create=function(e,r){return new Q(e,r)},t}(b),Q=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:ce},t}(ye),Xe={now:function(){return Date.now()},delegate:void 0},ze=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),Z={setInterval:function(n,t){for(var e=[],r=2;r<arguments.length;r++)e[r-2]=arguments[r];return setInterval.apply(void 0,U([n,t],R(e)))},clearInterval:function(n){return clearInterval(n)},delegate:void 0},Je=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 s=this.id,o=this.scheduler;return s!=null&&(this.id=this.recycleAsyncId(o,s,r)),this.pending=!0,this.delay=r,this.id=(i=this.id)!==null&&i!==void 0?i:this.requestAsyncId(o,this.id,r),this},t.prototype.requestAsyncId=function(e,r,i){return i===void 0&&(i=0),Z.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&&Z.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,s;try{this.work(e)}catch(o){i=!0,s=o||new Error("Scheduled action threw falsy error")}if(i)return this.unsubscribe(),s},t.prototype.unsubscribe=function(){if(!this.closed){var e=this,r=e.id,i=e.scheduler,s=i.actions;this.work=this.state=this.scheduler=null,this.pending=!1,G(s,this),r!=null&&(this.id=this.recycleAsyncId(i,r,null)),this.delay=null,n.prototype.unsubscribe.call(this)}},t}(ze),ee=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=Xe.now,n}(),Qe=function(n){O(t,n);function t(e,r){r===void 0&&(r=ee.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}(ee),ve=new Qe(Je),Ze=ve,en=new b(function(n){return n.complete()});function pe(n){return n&&v(n.schedule)}function nn(n){return n[n.length-1]}function tn(n){return pe(nn(n))?n.pop():void 0}var be=function(n){return n&&typeof n.length=="number"&&typeof n!="function"};function me(n){return v(n==null?void 0:n.then)}function ge(n){return v(n[X])}function we(n){return Symbol.asyncIterator&&v(n==null?void 0:n[Symbol.asyncIterator])}function Se(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 rn(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var Ee=rn();function Ie(n){return v(n==null?void 0:n[Ee])}function Oe(n){return Re(this,arguments,function(){var e,r,i,s;return ue(this,function(o){switch(o.label){case 0:e=n.getReader(),o.label=1;case 1:o.trys.push([1,,9,10]),o.label=2;case 2:return[4,C(e.read())];case 3:return r=o.sent(),i=r.value,s=r.done,s?[4,C(void 0)]:[3,5];case 4:return[2,o.sent()];case 5:return[4,C(i)];case 6:return[4,o.sent()];case 7:return o.sent(),[3,2];case 8:return[3,10];case 9:return e.releaseLock(),[7];case 10:return[2]}})})}function Ae(n){return v(n==null?void 0:n.getReader)}function A(n){if(n instanceof b)return n;if(n!=null){if(ge(n))return sn(n);if(be(n))return on(n);if(me(n))return un(n);if(we(n))return xe(n);if(Ie(n))return an(n);if(Ae(n))return cn(n)}throw Se(n)}function sn(n){return new b(function(t){var e=n[X]();if(v(e.subscribe))return e.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function on(n){return new b(function(t){for(var e=0;e<n.length&&!t.closed;e++)t.next(n[e]);t.complete()})}function un(n){return new b(function(t){n.then(function(e){t.closed||(t.next(e),t.complete())},function(e){return t.error(e)}).then(null,de)})}function an(n){return new b(function(t){var e,r;try{for(var i=P(n),s=i.next();!s.done;s=i.next()){var o=s.value;if(t.next(o),t.closed)return}}catch(c){e={error:c}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(e)throw e.error}}t.complete()})}function xe(n){return new b(function(t){fn(n,t).catch(function(e){return t.error(e)})})}function cn(n){return xe(Oe(n))}function fn(n,t){var e,r,i,s;return Ne(this,void 0,void 0,function(){var o,c;return ue(this,function(u){switch(u.label){case 0:u.trys.push([0,5,6,11]),e=Ue(n),u.label=1;case 1:return[4,e.next()];case 2:if(r=u.sent(),!!r.done)return[3,4];if(o=r.value,t.next(o),t.closed)return[2];u.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return c=u.sent(),i={error:c},[3,11];case 6:return u.trys.push([6,,9,10]),r&&!r.done&&(s=e.return)?[4,s.call(e)]:[3,8];case 7:u.sent(),u.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 T(n,t,e,r,i){r===void 0&&(r=0),i===void 0&&(i=!1);var s=t.schedule(function(){e(),i?n.add(this.schedule(null,r)):this.unsubscribe()},r);if(n.add(s),!i)return s}function _e(n,t){return t===void 0&&(t=0),M(function(e,r){e.subscribe(I(r,function(i){return T(r,n,function(){return r.next(i)},t)},function(){return T(r,n,function(){return r.complete()},t)},function(i){return T(r,n,function(){return r.error(i)},t)}))})}function Te(n,t){return t===void 0&&(t=0),M(function(e,r){r.add(n.schedule(function(){return e.subscribe(r)},t))})}function ln(n,t){return A(n).pipe(Te(t),_e(t))}function dn(n,t){return A(n).pipe(Te(t),_e(t))}function hn(n,t){return new b(function(e){var r=0;return t.schedule(function(){r===n.length?e.complete():(e.next(n[r++]),e.closed||this.schedule())})})}function yn(n,t){return new b(function(e){var r;return T(e,t,function(){r=n[Ee](),T(e,t,function(){var i,s,o;try{i=r.next(),s=i.value,o=i.done}catch(c){e.error(c);return}o?e.complete():e.next(s)},0,!0)}),function(){return v(r==null?void 0:r.return)&&r.return()}})}function Me(n,t){if(!n)throw new Error("Iterable cannot be null");return new b(function(e){T(e,t,function(){var r=n[Symbol.asyncIterator]();T(e,t,function(){r.next().then(function(i){i.done?e.complete():e.next(i.value)})},0,!0)})})}function vn(n,t){return Me(Oe(n),t)}function pn(n,t){if(n!=null){if(ge(n))return ln(n,t);if(be(n))return hn(n,t);if(me(n))return dn(n,t);if(we(n))return Me(n,t);if(Ie(n))return yn(n,t);if(Ae(n))return vn(n,t)}throw Se(n)}function bn(n,t){return t?pn(n,t):A(n)}function mn(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];var e=tn(n);return bn(n,e)}function gn(n){return n instanceof Date&&!isNaN(n)}function Ce(n,t){return M(function(e,r){var i=0;e.subscribe(I(r,function(s){r.next(n.call(t,s,i++))}))})}function wn(n,t,e,r,i,s,o,c){var u=[],a=0,l=0,h=!1,p=function(){h&&!u.length&&!a&&t.complete()},f=function(d){return a<r?y(d):u.push(d)},y=function(d){a++;var w=!1;A(e(d,l++)).subscribe(I(t,function(S){t.next(S)},function(){w=!0},void 0,function(){if(w)try{a--;for(var S=function(){var x=u.shift();o||y(x)};u.length&&a<r;)S();p()}catch(x){t.error(x)}}))};return n.subscribe(I(t,f,function(){h=!0,p()})),function(){}}function F(n,t,e){return e===void 0&&(e=1/0),v(t)?F(function(r,i){return Ce(function(s,o){return t(r,s,i,o)})(A(n(r,i)))},e):(typeof t=="number"&&(e=t),M(function(r,i){return wn(r,i,n,e)}))}function Pe(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 b(function(i){var s=gn(n)?+n-e.now():n;s<0&&(s=0);var o=0;return e.schedule(function(){i.closed||(i.next(o++),0<=r?this.schedule(void 0,r):i.complete())},s)})}function Sn(n,t){return v(t)?F(n,t,1):F(n,1)}function En(n){return n<=0?function(){return en}:M(function(t,e){var r=0;t.subscribe(I(e,function(i){++r<=n&&(e.next(i),n<=r&&e.complete())}))})}function In(n){return Ce(function(){return n})}function On(n,t){return F(function(e,r){return A(n(e,r)).pipe(En(1),In(e))})}function An(n,t){t===void 0&&(t=ve);var e=Pe(n,t);return On(function(){return e})}function ne(n){var t;t={count:n};var e=t.count,r=e===void 0?1/0:e,i=t.delay,s=t.resetOnSuccess,o=s===void 0?!1:s;return r<=0?he:M(function(c,u){var a=0,l,h=function(){var p=!1;l=c.subscribe(I(u,function(f){o&&(a=0),u.next(f)},void 0,function(f){if(a++<r){var y=function(){l?(l.unsubscribe(),l=null,h()):p=!0};if(i!=null){var d=typeof i=="number"?Pe(i):A(i(f,a)),w=I(u,function(){w.unsubscribe(),y()},function(){u.complete()});d.subscribe(w)}else y()}else u.error(f)})),p&&(l.unsubscribe(),l=null,h())};h()})}function te(n){return M(function(t,e){A(n).subscribe(I(e,function(){return e.complete()},Y)),!e.closed&&t.subscribe(e)})}async function xn(n,t){const e=n.getReader();let r;for(;!(r=await e.read()).done;)t(r.value)}function _n(n){let t,e,r,i=!1;return function(o){t===void 0?(t=o,e=0,r=-1):t=Mn(t,o);const c=t.length;let u=0;for(;e<c;){i&&(t[e]===10&&(u=++e),i=!1);let a=-1;for(;e<c&&a===-1;++e)switch(t[e]){case 58:r===-1&&(r=e-u);break;case 13:i=!0;case 10:a=e;break}if(a===-1)break;n(t.subarray(u,a),r),u=e,r=-1}u===c?t=void 0:u!==0&&(t=t.subarray(u),e-=u)}}function Tn(n,t,e){let r=re();const i=new TextDecoder;return function(o,c){if(o.length===0)e==null||e(r),r=re();else if(c>0){const u=i.decode(o.subarray(0,c)),a=c+(o[c+1]===32?2:1),l=i.decode(o.subarray(a));switch(u){case"data":r.data=r.data?r.data+`
4
+ `+l:l;break;case"event":r.event=l;break;case"id":n(r.id=l);break;case"retry":const h=parseInt(l,10);isNaN(h)||t(r.retry=h);break}}}}function Mn(n,t){const e=new Uint8Array(n.length+t.length);return e.set(n),e.set(t,n.length),e}function re(){return{data:"",event:"",id:"",retry:void 0}}var Cn=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 B="text/event-stream",Pn=1e3,ie="last-event-id";function Dn(n,t){var{signal:e,headers:r,onopen:i,onmessage:s,onclose:o,onerror:c,openWhenHidden:u,fetch:a}=t,l=Cn(t,["signal","headers","onopen","onmessage","onclose","onerror","openWhenHidden","fetch"]);return new Promise((h,p)=>{const f=Object.assign({},r);f.accept||(f.accept=B);let y;function d(){y.abort(),document.hidden||K()}u||document.addEventListener("visibilitychange",d);let w=Pn,S=0;function x(){document.removeEventListener("visibilitychange",d),window.clearTimeout(S),y.abort()}e==null||e.addEventListener("abort",()=>{x(),h()});const De=a??window.fetch,ke=i??kn;async function K(){var H;y=new AbortController;try{const k=await De(n,Object.assign(Object.assign({},l),{headers:f,signal:y.signal}));await ke(k),await xn(k.body,_n(Tn(E=>{E?f[ie]=E:delete f[ie]},E=>{w=E},s))),o==null||o(),x(),h()}catch(k){if(!y.signal.aborted)try{const E=(H=c==null?void 0:c(k))!==null&&H!==void 0?H:w;window.clearTimeout(S),S=window.setTimeout(K,E)}catch(E){x(),p(E)}}}K()})}function kn(n){const t=n.headers.get("content-type");if(!(t!=null&&t.startsWith(B)))throw new Error(`Expected content-type to be ${B}, Actual: ${t}`)}function se(n){const{endpoint:t,apiKey:e,payload:r}=n;return new b(i=>{const s=new AbortController;return Dn(t,{method:"POST",headers:{"X-API-KEY":e,"Content-Type":"application/json"},body:r?JSON.stringify(r):void 0,signal:s.signal,onopen:async o=>{o.ok||(i.error(o),s.abort())},onmessage:o=>{i.next(JSON.parse(o.data))},onclose:()=>{i.complete()},onerror:o=>{throw i.error(o),s.abort(),o}}),()=>{s.abort()}})}class Ln{constructor(t){_(this,"isConnecting",!1);_(this,"apiKey");_(this,"endpoint");_(this,"destroy$",new ye);if(!t.apiKey)throw new Error("apiKey must be required");if(!t.endpoint)throw new Error("botProviderName must be required");this.apiKey=t.apiKey,this.endpoint=t.endpoint}setChannel(t,e){var r;(r=e==null?void 0:e.onSseStart)==null||r.call(e),this.isConnecting=!0,se({apiKey:this.apiKey,endpoint:this.endpoint,payload:{action:N.RESET_CHANNEL,customChannelId:t.customChannelId,customMessageId:t==null?void 0:t.customMessageId,text:""}}).pipe(te(this.destroy$),ne(3)).subscribe({next:i=>{var s;(s=e==null?void 0:e.onSseMessage)==null||s.call(e,i)},error:i=>{var s;(s=e==null?void 0:e.onSseError)==null||s.call(e,i),this.isConnecting=!1},complete:()=>{var i;(i=e==null?void 0:e.onSseCompleted)==null||i.call(e),this.isConnecting=!1}})}sendMessage(t,e){var r;this.isConnecting=!0,(r=e==null?void 0:e.onSseStart)==null||r.call(e),se({apiKey:this.apiKey,endpoint:this.endpoint,payload:{action:N.NONE,customChannelId:t.customChannelId,customMessageId:t==null?void 0:t.customMessageId,text:t.text}}).pipe(Sn(i=>mn(i).pipe(An((e==null?void 0:e.delayTime)??50))),te(this.destroy$),ne(3)).subscribe({next:i=>{var s;(s=e==null?void 0:e.onSseMessage)==null||s.call(e,i)},error:i=>{var s;(s=e==null?void 0:e.onSseError)==null||s.call(e,i),this.isConnecting=!1},complete:()=>{var i;(i=e==null?void 0:e.onSseCompleted)==null||i.call(e),this.isConnecting=!1}})}close(){this.isConnecting=!1,this.destroy$.next(),this.destroy$.complete()}}class g{constructor({messages:t,typingMessages:e}){_(this,"messages");_(this,"typingMessages",null);this.messages=t,this.typingMessages=e}resetConversation(){return new g({messages:null,typingMessages:null})}pushMessage(t,e){const r=new Map(t.messages);return r.set(e.messageId,e),new g({messages:r,typingMessages:t.typingMessages})}onMessage(t,e,r){const i=(r==null?void 0:r.showDebugMessage)??!1;switch(e.eventType){case m.MESSAGE_START:return t.onMessageStart(t,e,{showDebugMessage:i});case m.MESSAGE_DELTA:return t.onMessageDelta(t,e,{showDebugMessage:i});case m.MESSAGE_COMPLETE:return t.onMessageComplete(t,e,{showDebugMessage:i});case m.DONE:return t.onMessageDone(t);default:return t}}onMessageStart(t,e,r){const i=e.fact.messageStart.message,s=new Map(t.typingMessages);return i.isDebug&&!r.showDebugMessage||s!=null&&s.has(i.messageId)?new g({messages:t.messages,typingMessages:s}):(s.set(i.messageId,{type:"bot",eventType:m.MESSAGE_START,isTyping:!0,typingText:"",messageId:i.messageId,message:i,time:new Date}),new g({messages:t.messages,typingMessages:s}))}onMessageDelta(t,e,r){const i=e.fact.messageDelta.message,s=new Map(t.messages),o=new Map(t.typingMessages),c=o.get(i.messageId);if(i.isDebug&&!r.showDebugMessage||s.has(i.messageId)||(c==null?void 0:c.eventType)===m.MESSAGE_COMPLETE)return new g({messages:t.messages,typingMessages:o});const u=`${(c==null?void 0:c.typingText)??""}${i.text}`;return o.set(i.messageId,{type:"bot",eventType:m.MESSAGE_DELTA,isTyping:!0,typingText:u,messageId:i.messageId,message:i,time:new Date}),new g({messages:t.messages,typingMessages:o})}onMessageComplete(t,e,r){const i=e.fact.messageComplete.message,s=new Map(t.messages),o=new Map(t.typingMessages);return i.isDebug&&!r.showDebugMessage?new g({messages:s,typingMessages:o}):(s.set(i.messageId,{type:"bot",eventType:m.MESSAGE_COMPLETE,isTyping:!1,typingText:null,messageId:i.messageId,message:i,time:new Date}),o.delete(i.messageId),new g({messages:s,typingMessages:o}))}onMessageDone(t){const e=new Map(t.messages),r=new Map(t.typingMessages);return r.forEach((i,s)=>{i.eventType===m.MESSAGE_COMPLETE&&(e.set(i.messageId,i),r.delete(s))}),new g({messages:t.messages,typingMessages:r})}}exports.AsgardServiceClient=Ln;exports.Conversation=g;exports.EventType=m;exports.FetchSseAction=N;exports.MessageTemplateType=oe;
5
5
  //# sourceMappingURL=index.cjs.map