@asgard-js/core 0.0.4 → 0.0.6
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 +67 -0
- package/dist/constants/enum.d.ts +23 -0
- package/dist/constants/enum.d.ts.map +1 -0
- package/dist/index.cjs +4 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +974 -881
- 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 +13 -0
- package/dist/lib/client.d.ts.map +1 -0
- package/dist/lib/conversation.d.ts +21 -0
- package/dist/lib/conversation.d.ts.map +1 -0
- package/dist/lib/create-sse-observable.d.ts +12 -0
- package/dist/lib/create-sse-observable.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 +26 -0
- package/dist/types/client.d.ts.map +1 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/sse-response.d.ts +109 -0
- package/dist/types/sse-response.d.ts.map +1 -0
- package/package.json +1 -1
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type { Subscription } from 'rxjs';
|
|
2
|
+
export type * from './types';
|
|
3
|
+
export * from './constants/enum';
|
|
4
|
+
export { default as AsgardServiceClient } from './lib/client';
|
|
5
|
+
export { default as Channel } from './lib/channel';
|
|
6
|
+
export { default as Conversation } from './lib/conversation';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +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,WAAW,CAAC;AAE/B,cAAc,oBAAoB,CAAC;AAEnC,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAEhE,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAErD,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,sBAAsB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
(function(
|
|
2
|
-
`+e.map(function(
|
|
3
|
-
`):"",this.name="UnsubscriptionError",this.errors=e}});function N(t,n){if(t){var e=t.indexOf(n);0<=e&&t.splice(e,1)}}var j=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,u;if(!this.closed){this.closed=!0;var o=this._parentage;if(o)if(this._parentage=null,Array.isArray(o))try{for(var s=D(o),c=s.next();!c.done;c=s.next()){var a=c.value;a.remove(this)}}catch(d){n={error:d}}finally{try{c&&!c.done&&(e=s.return)&&e.call(s)}finally{if(n)throw n.error}}else o.remove(this);var l=this.initialTeardown;if(v(l))try{l()}catch(d){u=d instanceof H?d.errors:[d]}var h=this._finalizers;if(h){this._finalizers=null;try{for(var m=D(h),f=m.next();!f.done;f=m.next()){var y=f.value;try{re(y)}catch(d){u=u??[],d instanceof H?u=U(U([],L(u)),L(d.errors)):u.push(d)}}}catch(d){r={error:d}}finally{try{f&&!f.done&&(i=m.return)&&i.call(m)}finally{if(r)throw r.error}}}if(u)throw new H(u)}},t.prototype.add=function(n){var e;if(n&&n!==this)if(this.closed)re(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)&&N(e,n)},t.prototype.remove=function(n){var e=this._finalizers;e&&N(e,n),n instanceof t&&n._removeParent(this)},t.EMPTY=function(){var n=new t;return n.closed=!0,n}(),t}(),te=j.EMPTY;function ne(t){return t instanceof j||t&&"closed"in t&&v(t.remove)&&v(t.add)&&v(t.unsubscribe)}function re(t){v(t)?t():t.unsubscribe()}var Ne={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},ie={setTimeout:function(t,n){for(var e=[],r=2;r<arguments.length;r++)e[r-2]=arguments[r];return setTimeout.apply(void 0,U([t,n],L(e)))},clearTimeout:function(t){var n=ie.delegate;return((n==null?void 0:n.clearTimeout)||clearTimeout)(t)},delegate:void 0};function ue(t){ie.setTimeout(function(){throw t})}function V(){}function R(t){t()}var q=function(t){I(n,t);function n(e){var r=t.call(this)||this;return r.isStopped=!1,e?(r.destination=e,ne(e)&&e.add(r)):r.destination=Ge,r}return n.create=function(e,r,i){return new B(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}(j),Re=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)}},t.prototype.error=function(n){var e=this.partialObserver;if(e.error)try{e.error(n)}catch(r){$(r)}else $(n)},t.prototype.complete=function(){var n=this.partialObserver;if(n.complete)try{n.complete()}catch(e){$(e)}},t}(),B=function(t){I(n,t);function n(e,r,i){var u=t.call(this)||this,o;return v(e)||!e?o={next:e??void 0,error:r??void 0,complete:i??void 0}:o=e,u.destination=new Re(o),u}return n}(q);function $(t){ue(t)}function $e(t){throw t}var Ge={closed:!0,next:V,error:$e,complete:V},Y=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function oe(t){return t}function Fe(t){return t.length===0?oe: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,u=He(n)?n:new B(n,e,r);return R(function(){var o=i,s=o.operator,c=o.source;u.add(s?s.call(u,c):c?i._subscribe(u):i._trySubscribe(u))}),u},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=se(e),new e(function(i,u){var o=new B({next:function(s){try{n(s)}catch(c){u(c),o.unsubscribe()}},error:u,complete:i});r.subscribe(o)})},t.prototype._subscribe=function(n){var e;return(e=this.source)===null||e===void 0?void 0:e.subscribe(n)},t.prototype[Y]=function(){return this},t.prototype.pipe=function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];return Fe(n)(this)},t.prototype.toPromise=function(n){var e=this;return n=se(n),new n(function(r,i){var u;e.subscribe(function(o){return u=o},function(o){return i(o)},function(){return r(u)})})},t.create=function(n){return new t(n)},t}();function se(t){var n;return(n=t??Ne.Promise)!==null&&n!==void 0?n:Promise}function Ke(t){return t&&v(t.next)&&v(t.error)&&v(t.complete)}function He(t){return t&&t instanceof q||Ke(t)&&ne(t)}function Ve(t){return v(t==null?void 0:t.lift)}function C(t){return function(n){if(Ve(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 A(t,n,e,r,i){return new qe(t,n,e,r,i)}var qe=function(t){I(n,t);function n(e,r,i,u,o,s){var c=t.call(this,e)||this;return c.onFinalize=o,c.shouldUnsubscribe=s,c._next=r?function(a){try{r(a)}catch(l){e.error(l)}}:t.prototype._next,c._error=u?function(a){try{u(a)}catch(l){e.error(l)}finally{this.unsubscribe()}}:t.prototype._error,c._complete=i?function(){try{i()}catch(a){e.error(a)}finally{this.unsubscribe()}}:t.prototype._complete,c}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}(q),Be=ee(function(t){return function(){t(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),W=function(t){I(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 ae(this,this);return r.operator=e,r},n.prototype._throwIfClosed=function(){if(this.closed)throw new Be},n.prototype.next=function(e){var r=this;R(function(){var i,u;if(r._throwIfClosed(),!r.isStopped){r.currentObservers||(r.currentObservers=Array.from(r.observers));try{for(var o=D(r.currentObservers),s=o.next();!s.done;s=o.next()){var c=s.value;c.next(e)}}catch(a){i={error:a}}finally{try{s&&!s.done&&(u=o.return)&&u.call(o)}finally{if(i)throw i.error}}}})},n.prototype.error=function(e){var r=this;R(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;R(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,u=i.hasError,o=i.isStopped,s=i.observers;return u||o?te:(this.currentObservers=null,s.push(e),new j(function(){r.currentObservers=null,N(s,e)}))},n.prototype._checkFinalizedStatuses=function(e){var r=this,i=r.hasError,u=r.thrownError,o=r.isStopped;i?e.error(u):o&&e.complete()},n.prototype.asObservable=function(){var e=new w;return e.source=this,e},n.create=function(e,r){return new ae(e,r)},n}(w),ae=function(t){I(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:te},n}(W),ce=function(t){I(n,t);function n(e){var r=t.call(this)||this;return r._value=e,r}return Object.defineProperty(n.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),n.prototype._subscribe=function(e){var r=t.prototype._subscribe.call(this,e);return!r.closed&&e.next(this._value),r},n.prototype.getValue=function(){var e=this,r=e.hasError,i=e.thrownError,u=e._value;if(r)throw i;return this._throwIfClosed(),u},n.prototype.next=function(e){t.prototype.next.call(this,this._value=e)},n}(W),Ye={now:function(){return Date.now()},delegate:void 0},We=function(t){I(n,t);function n(e,r){return t.call(this)||this}return n.prototype.schedule=function(e,r){return this},n}(j),fe={setInterval:function(t,n){for(var e=[],r=2;r<arguments.length;r++)e[r-2]=arguments[r];return setInterval.apply(void 0,U([t,n],L(e)))},clearInterval:function(t){return clearInterval(t)},delegate:void 0},Xe=function(t){I(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 u=this.id,o=this.scheduler;return u!=null&&(this.id=this.recycleAsyncId(o,u,r)),this.pending=!0,this.delay=r,this.id=(i=this.id)!==null&&i!==void 0?i:this.requestAsyncId(o,this.id,r),this},n.prototype.requestAsyncId=function(e,r,i){return i===void 0&&(i=0),fe.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&&fe.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,u;try{this.work(e)}catch(o){i=!0,u=o||new Error("Scheduled action threw falsy error")}if(i)return this.unsubscribe(),u},n.prototype.unsubscribe=function(){if(!this.closed){var e=this,r=e.id,i=e.scheduler,u=i.actions;this.work=this.state=this.scheduler=null,this.pending=!1,N(u,this),r!=null&&(this.id=this.recycleAsyncId(i,r,null)),this.delay=null,t.prototype.unsubscribe.call(this)}},n}(We),le=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=Ye.now,t}(),ze=function(t){I(n,t);function n(e,r){r===void 0&&(r=le.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}(le),de=new ze(Xe),Je=de,Qe=new w(function(t){return t.complete()});function he(t){return t&&v(t.schedule)}function Ze(t){return t[t.length-1]}function et(t){return he(Ze(t))?t.pop():void 0}var ye=function(t){return t&&typeof t.length=="number"&&typeof t!="function"};function ve(t){return v(t==null?void 0:t.then)}function pe(t){return v(t[Y])}function be(t){return Symbol.asyncIterator&&v(t==null?void 0:t[Symbol.asyncIterator])}function me(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 tt(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var ge=tt();function we(t){return v(t==null?void 0:t[ge])}function Se(t){return Le(this,arguments,function(){var e,r,i,u;return Z(this,function(o){switch(o.label){case 0:e=t.getReader(),o.label=1;case 1:o.trys.push([1,,9,10]),o.label=2;case 2:return[4,k(e.read())];case 3:return r=o.sent(),i=r.value,u=r.done,u?[4,k(void 0)]:[3,5];case 4:return[2,o.sent()];case 5:return[4,k(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 Ee(t){return v(t==null?void 0:t.getReader)}function _(t){if(t instanceof w)return t;if(t!=null){if(pe(t))return nt(t);if(ye(t))return rt(t);if(ve(t))return it(t);if(be(t))return Ie(t);if(we(t))return ut(t);if(Ee(t))return ot(t)}throw me(t)}function nt(t){return new w(function(n){var e=t[Y]();if(v(e.subscribe))return e.subscribe(n);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function rt(t){return new w(function(n){for(var e=0;e<t.length&&!n.closed;e++)n.next(t[e]);n.complete()})}function it(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,ue)})}function ut(t){return new w(function(n){var e,r;try{for(var i=D(t),u=i.next();!u.done;u=i.next()){var o=u.value;if(n.next(o),n.closed)return}}catch(s){e={error:s}}finally{try{u&&!u.done&&(r=i.return)&&r.call(i)}finally{if(e)throw e.error}}n.complete()})}function Ie(t){return new w(function(n){st(t,n).catch(function(e){return n.error(e)})})}function ot(t){return Ie(Se(t))}function st(t,n){var e,r,i,u;return je(this,void 0,void 0,function(){var o,s;return Z(this,function(c){switch(c.label){case 0:c.trys.push([0,5,6,11]),e=Ue(t),c.label=1;case 1:return[4,e.next()];case 2:if(r=c.sent(),!!r.done)return[3,4];if(o=r.value,n.next(o),n.closed)return[2];c.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return s=c.sent(),i={error:s},[3,11];case 6:return c.trys.push([6,,9,10]),r&&!r.done&&(u=e.return)?[4,u.call(e)]:[3,8];case 7:c.sent(),c.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 P(t,n,e,r,i){r===void 0&&(r=0),i===void 0&&(i=!1);var u=n.schedule(function(){e(),i?t.add(this.schedule(null,r)):this.unsubscribe()},r);if(t.add(u),!i)return u}function xe(t,n){return n===void 0&&(n=0),C(function(e,r){e.subscribe(A(r,function(i){return P(r,t,function(){return r.next(i)},n)},function(){return P(r,t,function(){return r.complete()},n)},function(i){return P(r,t,function(){return r.error(i)},n)}))})}function Oe(t,n){return n===void 0&&(n=0),C(function(e,r){r.add(t.schedule(function(){return e.subscribe(r)},n))})}function at(t,n){return _(t).pipe(Oe(n),xe(n))}function ct(t,n){return _(t).pipe(Oe(n),xe(n))}function ft(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 lt(t,n){return new w(function(e){var r;return P(e,n,function(){r=t[ge](),P(e,n,function(){var i,u,o;try{i=r.next(),u=i.value,o=i.done}catch(s){e.error(s);return}o?e.complete():e.next(u)},0,!0)}),function(){return v(r==null?void 0:r.return)&&r.return()}})}function Ae(t,n){if(!t)throw new Error("Iterable cannot be null");return new w(function(e){P(e,n,function(){var r=t[Symbol.asyncIterator]();P(e,n,function(){r.next().then(function(i){i.done?e.complete():e.next(i.value)})},0,!0)})})}function dt(t,n){return Ae(Se(t),n)}function ht(t,n){if(t!=null){if(pe(t))return at(t,n);if(ye(t))return ft(t,n);if(ve(t))return ct(t,n);if(be(t))return Ae(t,n);if(we(t))return lt(t,n);if(Ee(t))return dt(t,n)}throw me(t)}function yt(t,n){return n?ht(t,n):_(t)}function vt(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var e=et(t);return yt(t,e)}function pt(t){return t instanceof Date&&!isNaN(t)}function _e(t,n){return C(function(e,r){var i=0;e.subscribe(A(r,function(u){r.next(t.call(n,u,i++))}))})}function bt(t,n,e,r,i,u,o,s){var c=[],a=0,l=0,h=!1,m=function(){h&&!c.length&&!a&&n.complete()},f=function(d){return a<r?y(d):c.push(d)},y=function(d){a++;var E=!1;_(e(d,l++)).subscribe(A(n,function(O){n.next(O)},function(){E=!0},void 0,function(){if(E)try{a--;for(var O=function(){var M=c.shift();o||y(M)};c.length&&a<r;)O();m()}catch(M){n.error(M)}}))};return t.subscribe(A(n,f,function(){h=!0,m()})),function(){}}function G(t,n,e){return e===void 0&&(e=1/0),v(n)?G(function(r,i){return _e(function(u,o){return n(r,u,i,o)})(_(t(r,i)))},e):(typeof n=="number"&&(e=n),C(function(r,i){return bt(r,i,t,e)}))}function Te(t,n,e){t===void 0&&(t=0),e===void 0&&(e=Je);var r=-1;return n!=null&&(he(n)?e=n:r=n),new w(function(i){var u=pt(t)?+t-e.now():t;u<0&&(u=0);var o=0;return e.schedule(function(){i.closed||(i.next(o++),0<=r?this.schedule(void 0,r):i.complete())},u)})}function mt(t,n){return v(n)?G(t,n,1):G(t,1)}function gt(t){return t<=0?function(){return Qe}:C(function(n,e){var r=0;n.subscribe(A(e,function(i){++r<=t&&(e.next(i),t<=r&&e.complete())}))})}function wt(t){return _e(function(){return t})}function St(t,n){return G(function(e,r){return _(t(e,r)).pipe(gt(1),wt(e))})}function Et(t,n){n===void 0&&(n=de);var e=Te(t,n);return St(function(){return e})}function Ce(t){var n;n={count:t};var e=n.count,r=e===void 0?1/0:e,i=n.delay,u=n.resetOnSuccess,o=u===void 0?!1:u;return r<=0?oe:C(function(s,c){var a=0,l,h=function(){var m=!1;l=s.subscribe(A(c,function(f){o&&(a=0),c.next(f)},void 0,function(f){if(a++<r){var y=function(){l?(l.unsubscribe(),l=null,h()):m=!0};if(i!=null){var d=typeof i=="number"?Te(i):_(i(f,a)),E=A(c,function(){E.unsubscribe(),y()},function(){c.complete()});d.subscribe(E)}else y()}else c.error(f)})),m&&(l.unsubscribe(),l=null,h())};h()})}function Pe(t){return C(function(n,e){_(t).subscribe(A(e,function(){return e.complete()},V)),!e.closed&&n.subscribe(e)})}async function It(t,n){const e=t.getReader();let r;for(;!(r=await e.read()).done;)n(r.value)}function xt(t){let n,e,r,i=!1;return function(o){n===void 0?(n=o,e=0,r=-1):n=At(n,o);const s=n.length;let c=0;for(;e<s;){i&&(n[e]===10&&(c=++e),i=!1);let a=-1;for(;e<s&&a===-1;++e)switch(n[e]){case 58:r===-1&&(r=e-c);break;case 13:i=!0;case 10:a=e;break}if(a===-1)break;t(n.subarray(c,a),r),c=e,r=-1}c===s?n=void 0:c!==0&&(n=n.subarray(c),e-=c)}}function Ot(t,n,e){let r=Me();const i=new TextDecoder;return function(o,s){if(o.length===0)e==null||e(r),r=Me();else if(s>0){const c=i.decode(o.subarray(0,s)),a=s+(o[s+1]===32?2:1),l=i.decode(o.subarray(a));switch(c){case"data":r.data=r.data?r.data+`
|
|
4
|
-
`+
|
|
1
|
+
(function(b,g){typeof exports=="object"&&typeof module<"u"?g(exports):typeof define=="function"&&define.amd?define(["exports"],g):(b=typeof globalThis<"u"?globalThis:b||self,g(b["@asgard-js/core"]={}))})(this,function(b){"use strict";var Jt=Object.defineProperty;var Xt=(b,g,m)=>g in b?Jt(b,g,{enumerable:!0,configurable:!0,writable:!0,value:m}):b[g]=m;var S=(b,g,m)=>Xt(b,typeof g!="symbol"?g+"":g,m);var g=(t=>(t.RESET_CHANNEL="RESET_CHANNEL",t.NONE="NONE",t))(g||{}),m=(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.ERROR="asgard.run.error",t))(m||{}),re=(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))(re||{}),K=function(t,r){return K=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])},K(t,r)};function I(t,r){if(typeof r!="function"&&r!==null)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");K(t,r);function e(){this.constructor=t}t.prototype=r===null?Object.create(r):(e.prototype=r.prototype,new e)}function De(t,r,e,n){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{a(n.next(f))}catch(d){s(d)}}function u(f){try{a(n.throw(f))}catch(d){s(d)}}function a(f){f.done?o(f.value):i(f.value).then(c,u)}a((n=n.apply(t,r||[])).next())})}function ne(t,r){var e={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},n,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(a){return function(f){return u([a,f])}}function u(a){if(n)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(e=0)),e;)try{if(n=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=r.call(t,e)}catch(f){a=[6,f],i=0}finally{n=o=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}}function M(t){var r=typeof Symbol=="function"&&Symbol.iterator,e=r&&t[r],n=0;if(e)return e.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(r?"Object is not iterable.":"Symbol.iterator is not defined.")}function j(t,r){var e=typeof Symbol=="function"&&t[Symbol.iterator];if(!e)return t;var n=e.call(t),i,o=[],s;try{for(;(r===void 0||r-- >0)&&!(i=n.next()).done;)o.push(i.value)}catch(c){s={error:c}}finally{try{i&&!i.done&&(e=n.return)&&e.call(n)}finally{if(s)throw s.error}}return o}function R(t,r,e){if(e||arguments.length===2)for(var n=0,i=r.length,o;n<i;n++)(o||!(n in r))&&(o||(o=Array.prototype.slice.call(r,0,n)),o[n]=r[n]);return t.concat(o||Array.prototype.slice.call(r))}function k(t){return this instanceof k?(this.v=t,this):new k(t)}function Le(t,r,e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=e.apply(t,r||[]),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,d)}}function c(l,v){n[l]&&(i[l]=function(h){return new Promise(function(E,A){o.push([l,h,E,A])>1||u(l,h)})},v&&(i[l]=v(i[l])))}function u(l,v){try{a(n[l](v))}catch(h){p(o[0][3],h)}}function a(l){l.value instanceof k?Promise.resolve(l.value.v).then(f,d):p(o[0][2],l)}function f(l){u("next",l)}function d(l){u("throw",l)}function p(l,v){l(v),o.shift(),o.length&&u(o[0][0],o[0][1])}}function Ue(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=t[Symbol.asyncIterator],e;return r?r.call(t):(t=typeof M=="function"?M(t):t[Symbol.iterator](),e={},n("next"),n("throw"),n("return"),e[Symbol.asyncIterator]=function(){return this},e);function n(o){e[o]=t[o]&&function(s){return new Promise(function(c,u){s=t[o](s),i(c,u,s.done,s.value)})}}function i(o,s,c,u){Promise.resolve(u).then(function(a){o({value:a,done:c})},s)}}typeof SuppressedError=="function"&&SuppressedError;function y(t){return typeof t=="function"}function ie(t){var r=function(n){Error.call(n),n.stack=new Error().stack},e=t(r);return e.prototype=Object.create(Error.prototype),e.prototype.constructor=e,e}var H=ie(function(t){return function(e){t(this),this.message=e?e.length+` errors occurred during unsubscription:
|
|
2
|
+
`+e.map(function(n,i){return i+1+") "+n.toString()}).join(`
|
|
3
|
+
`):"",this.name="UnsubscriptionError",this.errors=e}});function L(t,r){if(t){var e=t.indexOf(r);0<=e&&t.splice(e,1)}}var D=function(){function t(r){this.initialTeardown=r,this.closed=!1,this._parentage=null,this._finalizers=null}return t.prototype.unsubscribe=function(){var r,e,n,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=M(s),u=c.next();!u.done;u=c.next()){var a=u.value;a.remove(this)}}catch(h){r={error:h}}finally{try{u&&!u.done&&(e=c.return)&&e.call(c)}finally{if(r)throw r.error}}else s.remove(this);var f=this.initialTeardown;if(y(f))try{f()}catch(h){o=h instanceof H?h.errors:[h]}var d=this._finalizers;if(d){this._finalizers=null;try{for(var p=M(d),l=p.next();!l.done;l=p.next()){var v=l.value;try{ae(v)}catch(h){o=o??[],h instanceof H?o=R(R([],j(o)),j(h.errors)):o.push(h)}}}catch(h){n={error:h}}finally{try{l&&!l.done&&(i=p.return)&&i.call(p)}finally{if(n)throw n.error}}}if(o)throw new H(o)}},t.prototype.add=function(r){var e;if(r&&r!==this)if(this.closed)ae(r);else{if(r instanceof t){if(r.closed||r._hasParent(this))return;r._addParent(this)}(this._finalizers=(e=this._finalizers)!==null&&e!==void 0?e:[]).push(r)}},t.prototype._hasParent=function(r){var e=this._parentage;return e===r||Array.isArray(e)&&e.includes(r)},t.prototype._addParent=function(r){var e=this._parentage;this._parentage=Array.isArray(e)?(e.push(r),e):e?[e,r]:r},t.prototype._removeParent=function(r){var e=this._parentage;e===r?this._parentage=null:Array.isArray(e)&&L(e,r)},t.prototype.remove=function(r){var e=this._finalizers;e&&L(e,r),r instanceof t&&r._removeParent(this)},t.EMPTY=function(){var r=new t;return r.closed=!0,r}(),t}(),oe=D.EMPTY;function se(t){return t instanceof D||t&&"closed"in t&&y(t.remove)&&y(t.add)&&y(t.unsubscribe)}function ae(t){y(t)?t():t.unsubscribe()}var $e={Promise:void 0},Ne={setTimeout:function(t,r){for(var e=[],n=2;n<arguments.length;n++)e[n-2]=arguments[n];return setTimeout.apply(void 0,R([t,r],j(e)))},clearTimeout:function(t){return clearTimeout(t)},delegate:void 0};function ue(t){Ne.setTimeout(function(){throw t})}function q(){}function U(t){t()}var B=function(t){I(r,t);function r(e){var n=t.call(this)||this;return n.isStopped=!1,e?(n.destination=e,se(e)&&e.add(n)):n.destination=Ve,n}return r.create=function(e,n,i){return new Y(e,n,i)},r.prototype.next=function(e){this.isStopped||this._next(e)},r.prototype.error=function(e){this.isStopped||(this.isStopped=!0,this._error(e))},r.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},r.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,t.prototype.unsubscribe.call(this),this.destination=null)},r.prototype._next=function(e){this.destination.next(e)},r.prototype._error=function(e){try{this.destination.error(e)}finally{this.unsubscribe()}},r.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},r}(D),Ge=function(){function t(r){this.partialObserver=r}return t.prototype.next=function(r){var e=this.partialObserver;if(e.next)try{e.next(r)}catch(n){$(n)}},t.prototype.error=function(r){var e=this.partialObserver;if(e.error)try{e.error(r)}catch(n){$(n)}else $(r)},t.prototype.complete=function(){var r=this.partialObserver;if(r.complete)try{r.complete()}catch(e){$(e)}},t}(),Y=function(t){I(r,t);function r(e,n,i){var o=t.call(this)||this,s;return y(e)||!e?s={next:e??void 0,error:n??void 0,complete:i??void 0}:s=e,o.destination=new Ge(s),o}return r}(B);function $(t){ue(t)}function Fe(t){throw t}var Ve={closed:!0,next:q,error:Fe,complete:q},W=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function N(t){return t}function Ke(t){return t.length===0?N:t.length===1?t[0]:function(e){return t.reduce(function(n,i){return i(n)},e)}}var w=function(){function t(r){r&&(this._subscribe=r)}return t.prototype.lift=function(r){var e=new t;return e.source=this,e.operator=r,e},t.prototype.subscribe=function(r,e,n){var i=this,o=qe(r)?r:new Y(r,e,n);return U(function(){var s=i,c=s.operator,u=s.source;o.add(c?c.call(o,u):u?i._subscribe(o):i._trySubscribe(o))}),o},t.prototype._trySubscribe=function(r){try{return this._subscribe(r)}catch(e){r.error(e)}},t.prototype.forEach=function(r,e){var n=this;return e=ce(e),new e(function(i,o){var s=new Y({next:function(c){try{r(c)}catch(u){o(u),s.unsubscribe()}},error:o,complete:i});n.subscribe(s)})},t.prototype._subscribe=function(r){var e;return(e=this.source)===null||e===void 0?void 0:e.subscribe(r)},t.prototype[W]=function(){return this},t.prototype.pipe=function(){for(var r=[],e=0;e<arguments.length;e++)r[e]=arguments[e];return Ke(r)(this)},t.prototype.toPromise=function(r){var e=this;return r=ce(r),new r(function(n,i){var o;e.subscribe(function(s){return o=s},function(s){return i(s)},function(){return n(o)})})},t.create=function(r){return new t(r)},t}();function ce(t){var r;return(r=t??$e.Promise)!==null&&r!==void 0?r:Promise}function He(t){return t&&y(t.next)&&y(t.error)&&y(t.complete)}function qe(t){return t&&t instanceof B||He(t)&&se(t)}function Be(t){return y(t==null?void 0:t.lift)}function C(t){return function(r){if(Be(r))return r.lift(function(e){try{return t(e,this)}catch(n){this.error(n)}});throw new TypeError("Unable to lift unknown Observable type")}}function O(t,r,e,n,i){return new Ye(t,r,e,n,i)}var Ye=function(t){I(r,t);function r(e,n,i,o,s,c){var u=t.call(this,e)||this;return u.onFinalize=s,u.shouldUnsubscribe=c,u._next=n?function(a){try{n(a)}catch(f){e.error(f)}}:t.prototype._next,u._error=o?function(a){try{o(a)}catch(f){e.error(f)}finally{this.unsubscribe()}}:t.prototype._error,u._complete=i?function(){try{i()}catch(a){e.error(a)}finally{this.unsubscribe()}}:t.prototype._complete,u}return r.prototype.unsubscribe=function(){var e;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var n=this.closed;t.prototype.unsubscribe.call(this),!n&&((e=this.onFinalize)===null||e===void 0||e.call(this))}},r}(B),We=ie(function(t){return function(){t(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),J=function(t){I(r,t);function r(){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 r.prototype.lift=function(e){var n=new le(this,this);return n.operator=e,n},r.prototype._throwIfClosed=function(){if(this.closed)throw new We},r.prototype.next=function(e){var n=this;U(function(){var i,o;if(n._throwIfClosed(),!n.isStopped){n.currentObservers||(n.currentObservers=Array.from(n.observers));try{for(var s=M(n.currentObservers),c=s.next();!c.done;c=s.next()){var u=c.value;u.next(e)}}catch(a){i={error:a}}finally{try{c&&!c.done&&(o=s.return)&&o.call(s)}finally{if(i)throw i.error}}}})},r.prototype.error=function(e){var n=this;U(function(){if(n._throwIfClosed(),!n.isStopped){n.hasError=n.isStopped=!0,n.thrownError=e;for(var i=n.observers;i.length;)i.shift().error(e)}})},r.prototype.complete=function(){var e=this;U(function(){if(e._throwIfClosed(),!e.isStopped){e.isStopped=!0;for(var n=e.observers;n.length;)n.shift().complete()}})},r.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(r.prototype,"observed",{get:function(){var e;return((e=this.observers)===null||e===void 0?void 0:e.length)>0},enumerable:!1,configurable:!0}),r.prototype._trySubscribe=function(e){return this._throwIfClosed(),t.prototype._trySubscribe.call(this,e)},r.prototype._subscribe=function(e){return this._throwIfClosed(),this._checkFinalizedStatuses(e),this._innerSubscribe(e)},r.prototype._innerSubscribe=function(e){var n=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(){n.currentObservers=null,L(c,e)}))},r.prototype._checkFinalizedStatuses=function(e){var n=this,i=n.hasError,o=n.thrownError,s=n.isStopped;i?e.error(o):s&&e.complete()},r.prototype.asObservable=function(){var e=new w;return e.source=this,e},r.create=function(e,n){return new le(e,n)},r}(w),le=function(t){I(r,t);function r(e,n){var i=t.call(this)||this;return i.destination=e,i.source=n,i}return r.prototype.next=function(e){var n,i;(i=(n=this.destination)===null||n===void 0?void 0:n.next)===null||i===void 0||i.call(n,e)},r.prototype.error=function(e){var n,i;(i=(n=this.destination)===null||n===void 0?void 0:n.error)===null||i===void 0||i.call(n,e)},r.prototype.complete=function(){var e,n;(n=(e=this.destination)===null||e===void 0?void 0:e.complete)===null||n===void 0||n.call(e)},r.prototype._subscribe=function(e){var n,i;return(i=(n=this.source)===null||n===void 0?void 0:n.subscribe(e))!==null&&i!==void 0?i:oe},r}(J),fe=function(t){I(r,t);function r(e){var n=t.call(this)||this;return n._value=e,n}return Object.defineProperty(r.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),r.prototype._subscribe=function(e){var n=t.prototype._subscribe.call(this,e);return!n.closed&&e.next(this._value),n},r.prototype.getValue=function(){var e=this,n=e.hasError,i=e.thrownError,o=e._value;if(n)throw i;return this._throwIfClosed(),o},r.prototype.next=function(e){t.prototype.next.call(this,this._value=e)},r}(J),Je={now:function(){return Date.now()}},Xe=function(t){I(r,t);function r(e,n){return t.call(this)||this}return r.prototype.schedule=function(e,n){return this},r}(D),he={setInterval:function(t,r){for(var e=[],n=2;n<arguments.length;n++)e[n-2]=arguments[n];return setInterval.apply(void 0,R([t,r],j(e)))},clearInterval:function(t){return clearInterval(t)},delegate:void 0},ze=function(t){I(r,t);function r(e,n){var i=t.call(this,e,n)||this;return i.scheduler=e,i.work=n,i.pending=!1,i}return r.prototype.schedule=function(e,n){var i;if(n===void 0&&(n=0),this.closed)return this;this.state=e;var o=this.id,s=this.scheduler;return o!=null&&(this.id=this.recycleAsyncId(s,o,n)),this.pending=!0,this.delay=n,this.id=(i=this.id)!==null&&i!==void 0?i:this.requestAsyncId(s,this.id,n),this},r.prototype.requestAsyncId=function(e,n,i){return i===void 0&&(i=0),he.setInterval(e.flush.bind(e,this),i)},r.prototype.recycleAsyncId=function(e,n,i){if(i===void 0&&(i=0),i!=null&&this.delay===i&&this.pending===!1)return n;n!=null&&he.clearInterval(n)},r.prototype.execute=function(e,n){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var i=this._execute(e,n);if(i)return i;this.pending===!1&&this.id!=null&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},r.prototype._execute=function(e,n){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},r.prototype.unsubscribe=function(){if(!this.closed){var e=this,n=e.id,i=e.scheduler,o=i.actions;this.work=this.state=this.scheduler=null,this.pending=!1,L(o,this),n!=null&&(this.id=this.recycleAsyncId(i,n,null)),this.delay=null,t.prototype.unsubscribe.call(this)}},r}(Xe),de=function(){function t(r,e){e===void 0&&(e=t.now),this.schedulerActionCtor=r,this.now=e}return t.prototype.schedule=function(r,e,n){return e===void 0&&(e=0),new this.schedulerActionCtor(this,r).schedule(n,e)},t.now=Je.now,t}(),Qe=function(t){I(r,t);function r(e,n){n===void 0&&(n=de.now);var i=t.call(this,e,n)||this;return i.actions=[],i._active=!1,i}return r.prototype.flush=function(e){var n=this.actions;if(this._active){n.push(e);return}var i;this._active=!0;do if(i=e.execute(e.state,e.delay))break;while(e=n.shift());if(this._active=!1,i){for(;e=n.shift();)e.unsubscribe();throw i}},r}(de),ve=new Qe(ze),Ze=ve,et=new w(function(t){return t.complete()});function ye(t){return t&&y(t.schedule)}function pe(t){return t[t.length-1]}function tt(t){return y(pe(t))?t.pop():void 0}function be(t){return ye(pe(t))?t.pop():void 0}var me=function(t){return t&&typeof t.length=="number"&&typeof t!="function"};function ge(t){return y(t==null?void 0:t.then)}function we(t){return y(t[W])}function Se(t){return Symbol.asyncIterator&&y(t==null?void 0:t[Symbol.asyncIterator])}function Ee(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 rt(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var Ie=rt();function Oe(t){return y(t==null?void 0:t[Ie])}function Ae(t){return Le(this,arguments,function(){var e,n,i,o;return ne(this,function(s){switch(s.label){case 0:e=t.getReader(),s.label=1;case 1:s.trys.push([1,,9,10]),s.label=2;case 2:return[4,k(e.read())];case 3:return n=s.sent(),i=n.value,o=n.done,o?[4,k(void 0)]:[3,5];case 4:return[2,s.sent()];case 5:return[4,k(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(t){return y(t==null?void 0:t.getReader)}function x(t){if(t instanceof w)return t;if(t!=null){if(we(t))return nt(t);if(me(t))return it(t);if(ge(t))return ot(t);if(Se(t))return _e(t);if(Oe(t))return st(t);if(xe(t))return at(t)}throw Ee(t)}function nt(t){return new w(function(r){var e=t[W]();if(y(e.subscribe))return e.subscribe(r);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function it(t){return new w(function(r){for(var e=0;e<t.length&&!r.closed;e++)r.next(t[e]);r.complete()})}function ot(t){return new w(function(r){t.then(function(e){r.closed||(r.next(e),r.complete())},function(e){return r.error(e)}).then(null,ue)})}function st(t){return new w(function(r){var e,n;try{for(var i=M(t),o=i.next();!o.done;o=i.next()){var s=o.value;if(r.next(s),r.closed)return}}catch(c){e={error:c}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(e)throw e.error}}r.complete()})}function _e(t){return new w(function(r){ut(t,r).catch(function(e){return r.error(e)})})}function at(t){return _e(Ae(t))}function ut(t,r){var e,n,i,o;return De(this,void 0,void 0,function(){var s,c;return ne(this,function(u){switch(u.label){case 0:u.trys.push([0,5,6,11]),e=Ue(t),u.label=1;case 1:return[4,e.next()];case 2:if(n=u.sent(),!!n.done)return[3,4];if(s=n.value,r.next(s),r.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]),n&&!n.done&&(o=e.return)?[4,o.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 r.complete(),[2]}})})}function _(t,r,e,n,i){n===void 0&&(n=0),i===void 0&&(i=!1);var o=r.schedule(function(){e(),i?t.add(this.schedule(null,n)):this.unsubscribe()},n);if(t.add(o),!i)return o}function Te(t,r){return r===void 0&&(r=0),C(function(e,n){e.subscribe(O(n,function(i){return _(n,t,function(){return n.next(i)},r)},function(){return _(n,t,function(){return n.complete()},r)},function(i){return _(n,t,function(){return n.error(i)},r)}))})}function Ce(t,r){return r===void 0&&(r=0),C(function(e,n){n.add(t.schedule(function(){return e.subscribe(n)},r))})}function ct(t,r){return x(t).pipe(Ce(r),Te(r))}function lt(t,r){return x(t).pipe(Ce(r),Te(r))}function ft(t,r){return new w(function(e){var n=0;return r.schedule(function(){n===t.length?e.complete():(e.next(t[n++]),e.closed||this.schedule())})})}function ht(t,r){return new w(function(e){var n;return _(e,r,function(){n=t[Ie](),_(e,r,function(){var i,o,s;try{i=n.next(),o=i.value,s=i.done}catch(c){e.error(c);return}s?e.complete():e.next(o)},0,!0)}),function(){return y(n==null?void 0:n.return)&&n.return()}})}function Pe(t,r){if(!t)throw new Error("Iterable cannot be null");return new w(function(e){_(e,r,function(){var n=t[Symbol.asyncIterator]();_(e,r,function(){n.next().then(function(i){i.done?e.complete():e.next(i.value)})},0,!0)})})}function dt(t,r){return Pe(Ae(t),r)}function vt(t,r){if(t!=null){if(we(t))return ct(t,r);if(me(t))return ft(t,r);if(ge(t))return lt(t,r);if(Se(t))return Pe(t,r);if(Oe(t))return ht(t,r);if(xe(t))return dt(t,r)}throw Ee(t)}function X(t,r){return r?vt(t,r):x(t)}function yt(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];var e=be(t);return X(t,e)}function pt(t){return t instanceof Date&&!isNaN(t)}function G(t,r){return C(function(e,n){var i=0;e.subscribe(O(n,function(o){n.next(t.call(r,o,i++))}))})}var bt=Array.isArray;function mt(t,r){return bt(r)?t.apply(void 0,R([],j(r))):t(r)}function gt(t){return G(function(r){return mt(t,r)})}var wt=Array.isArray,St=Object.getPrototypeOf,Et=Object.prototype,It=Object.keys;function Ot(t){if(t.length===1){var r=t[0];if(wt(r))return{args:r,keys:null};if(At(r)){var e=It(r);return{args:e.map(function(n){return r[n]}),keys:e}}}return{args:t,keys:null}}function At(t){return t&&typeof t=="object"&&St(t)===Et}function xt(t,r){return t.reduce(function(e,n,i){return e[n]=r[i],e},{})}function _t(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];var e=be(t),n=tt(t),i=Ot(t),o=i.args,s=i.keys;if(o.length===0)return X([],e);var c=new w(Tt(o,e,s?function(u){return xt(s,u)}:N));return n?c.pipe(gt(n)):c}function Tt(t,r,e){return e===void 0&&(e=N),function(n){Me(r,function(){for(var i=t.length,o=new Array(i),s=i,c=i,u=function(f){Me(r,function(){var d=X(t[f],r),p=!1;d.subscribe(O(n,function(l){o[f]=l,p||(p=!0,c--),c||n.next(e(o.slice()))},function(){--s||n.complete()}))},n)},a=0;a<i;a++)u(a)},n)}}function Me(t,r,e){t?_(e,t,r):r()}function Ct(t,r,e,n,i,o,s,c){var u=[],a=0,f=0,d=!1,p=function(){d&&!u.length&&!a&&r.complete()},l=function(h){return a<n?v(h):u.push(h)},v=function(h){a++;var E=!1;x(e(h,f++)).subscribe(O(r,function(A){r.next(A)},function(){E=!0},void 0,function(){if(E)try{a--;for(var A=function(){var P=u.shift();s||v(P)};u.length&&a<n;)A();p()}catch(P){r.error(P)}}))};return t.subscribe(O(r,l,function(){d=!0,p()})),function(){}}function F(t,r,e){return e===void 0&&(e=1/0),y(r)?F(function(n,i){return G(function(o,s){return r(n,o,i,s)})(x(t(n,i)))},e):(typeof r=="number"&&(e=r),C(function(n,i){return Ct(n,i,t,e)}))}function ke(t,r,e){t===void 0&&(t=0),e===void 0&&(e=Ze);var n=-1;return r!=null&&(ye(r)?e=r:n=r),new w(function(i){var o=pt(t)?+t-e.now():t;o<0&&(o=0);var s=0;return e.schedule(function(){i.closed||(i.next(s++),0<=n?this.schedule(void 0,n):i.complete())},o)})}function Pt(t,r){return y(r)?F(t,r,1):F(t,1)}function Mt(t){return t<=0?function(){return et}:C(function(r,e){var n=0;r.subscribe(O(e,function(i){++n<=t&&(e.next(i),t<=n&&e.complete())}))})}function kt(t){return G(function(){return t})}function jt(t,r){return F(function(e,n){return x(t(e,n)).pipe(Mt(1),kt(e))})}function Rt(t,r){r===void 0&&(r=ve);var e=ke(t,r);return jt(function(){return e})}function Dt(t){var r;r={count:t};var e=r.count,n=e===void 0?1/0:e,i=r.delay,o=r.resetOnSuccess,s=o===void 0?!1:o;return n<=0?N:C(function(c,u){var a=0,f,d=function(){var p=!1;f=c.subscribe(O(u,function(l){s&&(a=0),u.next(l)},void 0,function(l){if(a++<n){var v=function(){f?(f.unsubscribe(),f=null,d()):p=!0};if(i!=null){var h=typeof i=="number"?ke(i):x(i(l,a)),E=O(u,function(){E.unsubscribe(),v()},function(){u.complete()});h.subscribe(E)}else v()}else u.error(l)})),p&&(f.unsubscribe(),f=null,d())};d()})}function Lt(t){return C(function(r,e){x(t).subscribe(O(e,function(){return e.complete()},q)),!e.closed&&r.subscribe(e)})}async function Ut(t,r){const e=t.getReader();let n;for(;!(n=await e.read()).done;)r(n.value)}function $t(t){let r,e,n,i=!1;return function(s){r===void 0?(r=s,e=0,n=-1):r=Gt(r,s);const c=r.length;let u=0;for(;e<c;){i&&(r[e]===10&&(u=++e),i=!1);let a=-1;for(;e<c&&a===-1;++e)switch(r[e]){case 58:n===-1&&(n=e-u);break;case 13:i=!0;case 10:a=e;break}if(a===-1)break;t(r.subarray(u,a),n),u=e,n=-1}u===c?r=void 0:u!==0&&(r=r.subarray(u),e-=u)}}function Nt(t,r,e){let n=je();const i=new TextDecoder;return function(s,c){if(s.length===0)e==null||e(n),n=je();else if(c>0){const u=i.decode(s.subarray(0,c)),a=c+(s[c+1]===32?2:1),f=i.decode(s.subarray(a));switch(u){case"data":n.data=n.data?n.data+`
|
|
4
|
+
`+f:f;break;case"event":n.event=f;break;case"id":t(n.id=f);break;case"retry":const d=parseInt(f,10);isNaN(d)||r(n.retry=d);break}}}}function Gt(t,r){const e=new Uint8Array(t.length+r.length);return e.set(t),e.set(r,t.length),e}function je(){return{data:"",event:"",id:"",retry:void 0}}var Ft=function(t,r){var e={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&r.indexOf(n)<0&&(e[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);i<n.length;i++)r.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(e[n[i]]=t[n[i]]);return e};const z="text/event-stream",Vt=1e3,Re="last-event-id";function Kt(t,r){var{signal:e,headers:n,onopen:i,onmessage:o,onclose:s,onerror:c,openWhenHidden:u,fetch:a}=r,f=Ft(r,["signal","headers","onopen","onmessage","onclose","onerror","openWhenHidden","fetch"]);return new Promise((d,p)=>{const l=Object.assign({},n);l.accept||(l.accept=z);let v;function h(){v.abort(),document.hidden||ee()}u||document.addEventListener("visibilitychange",h);let E=Vt,A=0;function P(){document.removeEventListener("visibilitychange",h),window.clearTimeout(A),v.abort()}e==null||e.addEventListener("abort",()=>{P(),d()});const Yt=a??window.fetch,Wt=i??Ht;async function ee(){var te;v=new AbortController;try{const V=await Yt(t,Object.assign(Object.assign({},f),{headers:l,signal:v.signal}));await Wt(V),await Ut(V.body,$t(Nt(T=>{T?l[Re]=T:delete l[Re]},T=>{E=T},o))),s==null||s(),P(),d()}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){P(),p(T)}}}ee()})}function Ht(t){const r=t.headers.get("content-type");if(!(r!=null&&r.startsWith(z)))throw new Error(`Expected content-type to be ${z}, Actual: ${r}`)}function qt(t){const{endpoint:r,apiKey:e,payload:n}=t;return new w(i=>{const o=new AbortController;return Kt(r,{method:"POST",headers:{"X-API-KEY":e,"Content-Type":"application/json"},body:n?JSON.stringify(n):void 0,signal:o.signal,onopen:async s=>{s.ok||(i.error(s),o.abort())},onmessage:s=>{i.next(JSON.parse(s.data))},onclose:()=>{i.complete()},onerror:s=>{throw i.error(s),o.abort(),s}}),()=>{o.abort()}})}class Bt{constructor(r){S(this,"apiKey");S(this,"endpoint");S(this,"destroy$",new J);S(this,"onExecutionError");S(this,"transformSsePayload");if(!r.apiKey)throw new Error("apiKey must be required");if(!r.endpoint)throw new Error("endpoint must be required");this.apiKey=r.apiKey,this.endpoint=r.endpoint,this.onExecutionError=r.onExecutionError,this.transformSsePayload=r.transformSsePayload}fetchSse(r,e){var n,i;(n=e==null?void 0:e.onSseStart)==null||n.call(e),qt({apiKey:this.apiKey,endpoint:this.endpoint,payload:((i=this.transformSsePayload)==null?void 0:i.call(this,r))??r}).pipe(Pt(o=>yt(o).pipe(Rt((e==null?void 0:e.delayTime)??50))),Lt(this.destroy$),Dt(3)).subscribe({next:o=>{var s,c;switch((s=e==null?void 0:e.onSseMessage)==null||s.call(e,o),o.eventType){case m.ERROR:(c=this.onExecutionError)==null||c.call(this,o.fact.runError);break}},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 Q{constructor(r){S(this,"client");S(this,"customChannelId");S(this,"customMessageId");S(this,"isConnecting$");S(this,"conversation$");S(this,"statesObserver");S(this,"statesSubscription");if(!r.client)throw new Error("client must be required");if(!r.customChannelId)throw new Error("customChannelId must be required");this.client=r.client,this.customChannelId=r.customChannelId,this.customMessageId=r.customMessageId,this.isConnecting$=new fe(!1),this.conversation$=new fe(r.conversation),this.statesObserver=r.statesObserver}static async reset(r,e){const n=new Q(r);try{return n.subscribe(),await n.resetChannel(e),n}catch(i){throw n.close(),i}}subscribe(){this.statesSubscription=_t([this.isConnecting$,this.conversation$]).pipe(G(([r,e])=>({isConnecting:r,conversation:e}))).subscribe(this.statesObserver)}fetchSse(r,e){return new Promise((n,i)=>{this.isConnecting$.next(!0),this.client.fetchSse(r,{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),n()}})})}resetChannel(r){return this.fetchSse({action:g.RESET_CHANNEL,customChannelId:this.customChannelId,customMessageId:this.customMessageId,text:""},r)}sendMessage(r,e){const n=r.text.trim(),i=r.customMessageId??crypto.randomUUID();return this.conversation$.next(this.conversation$.value.pushMessage({type:"user",messageId:i,text:n,time:new Date})),this.fetchSse({action:g.NONE,customChannelId:this.customChannelId,customMessageId:i,text:n},e)}close(){var r;this.isConnecting$.complete(),this.conversation$.complete(),(r=this.statesSubscription)==null||r.unsubscribe()}}class Z{constructor({messages:r,showDebugMessage:e}){S(this,"showDebugMessage",!1);S(this,"messages",null);this.messages=r,this.showDebugMessage=e??!1}create(r){return new Z({messages:r,showDebugMessage:this.showDebugMessage})}pushMessage(r){const e=new Map(this.messages);return e.set(r.messageId,r),this.create(e)}onMessage(r){switch(r.eventType){case m.MESSAGE_START:return this.onMessageStart(r);case m.MESSAGE_DELTA:return this.onMessageDelta(r);case m.MESSAGE_COMPLETE:return this.onMessageComplete(r);case m.ERROR:return this.onMessageError(r);default:return this}}onMessageStart(r){const e=r.fact.messageStart.message,n=new Map(this.messages);return e.isDebug&&!this.showDebugMessage||n!=null&&n.has(e.messageId)?this.create(n):(n.set(e.messageId,{type:"bot",eventType:m.MESSAGE_START,isTyping:!0,typingText:"",messageId:e.messageId,message:e,time:new Date}),this.create(n))}onMessageDelta(r){const e=r.fact.messageDelta.message,n=new Map(this.messages),i=n.get(e.messageId);if((i==null?void 0:i.type)!=="bot")return this;if(e.isDebug&&!this.showDebugMessage||(i==null?void 0:i.eventType)===m.MESSAGE_COMPLETE)return this.create(n);const o=`${(i==null?void 0:i.typingText)??""}${e.text}`;return n.set(e.messageId,{type:"bot",eventType:m.MESSAGE_DELTA,isTyping:!0,typingText:o,messageId:e.messageId,message:e,time:new Date}),this.create(n)}onMessageComplete(r){const e=r.fact.messageComplete.message,n=new Map(this.messages);return e.isDebug&&!this.showDebugMessage?this.create(n):(n.set(e.messageId,{type:"bot",eventType:m.MESSAGE_COMPLETE,isTyping:!1,typingText:null,messageId:e.messageId,message:e,time:new Date}),this.create(n))}onMessageError(r){const e=crypto.randomUUID(),n=r.fact.runError.error,i=new Map(this.messages);return i.set(e,{type:"error",eventType:m.ERROR,messageId:e,error:n,time:new Date}),this.create(i)}}b.AsgardServiceClient=Bt,b.Channel=Q,b.Conversation=Z,b.EventType=m,b.FetchSseAction=g,b.MessageTemplateType=re,Object.defineProperty(b,Symbol.toStringTag,{value:"Module"})});
|
|
5
5
|
//# sourceMappingURL=index.js.map
|