@telia-ace/widget-conversation-flamingo 1.1.18-rc.4 → 1.1.18
Sign up to get free protection for your applications and to get access to all the features.
- package/{conversation-3926f29b.mjs → conversation-82eb83b8.mjs} +2 -2
- package/{conversation-9bbc787d.js → conversation-9745531a.js} +2 -2
- package/conversation-platform.d.ts +1 -1
- package/{index-d5d01cbe.js → index-823bc9d0.js} +1 -1
- package/index-b34f590f.js +3 -0
- package/{index-306e28c8.mjs → index-cc2f0d24.mjs} +2 -2
- package/index-e9da2f7d.mjs +1241 -0
- package/index.d.ts +1 -0
- package/index.js +1 -1
- package/index.mjs +6 -5
- package/models/conversation-provider.d.ts +4 -1
- package/models/conversation-session-state.d.ts +7 -1
- package/package.json +2 -2
- package/index-41339d4e.mjs +0 -1218
- package/index-70996338.js +0 -3
package/index-70996338.js
DELETED
@@ -1,3 +0,0 @@
|
|
1
|
-
"use strict";let I;const bt=new Uint8Array(16);function mt(){if(!I&&(I=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!I))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return I(bt)}const p=[];for(let t=0;t<256;++t)p.push((t+256).toString(16).slice(1));function wt(t,e=0){return p[t[e+0]]+p[t[e+1]]+p[t[e+2]]+p[t[e+3]]+"-"+p[t[e+4]]+p[t[e+5]]+"-"+p[t[e+6]]+p[t[e+7]]+"-"+p[t[e+8]]+p[t[e+9]]+"-"+p[t[e+10]]+p[t[e+11]]+p[t[e+12]]+p[t[e+13]]+p[t[e+14]]+p[t[e+15]]}const St=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),G={randomUUID:St};function gt(t,e,r){if(G.randomUUID&&!e&&!t)return G.randomUUID();t=t||{};const n=t.random||(t.rng||mt)();if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,e){r=r||0;for(let o=0;o<16;++o)e[r+o]=n[o];return e}return wt(n)}var R=function(t,e){return R=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,n){r.__proto__=n}||function(r,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(r[o]=n[o])},R(t,e)};function g(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");R(t,e);function r(){this.constructor=t}t.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}function Et(t,e,r,n){function o(i){return i instanceof r?i:new r(function(s){s(i)})}return new(r||(r=Promise))(function(i,s){function u(f){try{c(n.next(f))}catch(b){s(b)}}function a(f){try{c(n.throw(f))}catch(b){s(b)}}function c(f){f.done?i(f.value):o(f.value).then(u,a)}c((n=n.apply(t,e||[])).next())})}function J(t,e){var r={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},n,o,i,s;return s={next:u(0),throw:u(1),return:u(2)},typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function u(c){return function(f){return a([c,f])}}function a(c){if(n)throw new TypeError("Generator is already executing.");for(;s&&(s=0,c[0]&&(r=0)),r;)try{if(n=1,o&&(i=c[0]&2?o.return:c[0]?o.throw||((i=o.return)&&i.call(o),0):o.next)&&!(i=i.call(o,c[1])).done)return i;switch(o=0,i&&(c=[c[0]&2,i.value]),c[0]){case 0:case 1:i=c;break;case 4:return r.label++,{value:c[1],done:!1};case 5:r.label++,o=c[1],c=[0];continue;case 7:c=r.ops.pop(),r.trys.pop();continue;default:if(i=r.trys,!(i=i.length>0&&i[i.length-1])&&(c[0]===6||c[0]===2)){r=0;continue}if(c[0]===3&&(!i||c[1]>i[0]&&c[1]<i[3])){r.label=c[1];break}if(c[0]===6&&r.label<i[1]){r.label=i[1],i=c;break}if(i&&r.label<i[2]){r.label=i[2],r.ops.push(c);break}i[2]&&r.ops.pop(),r.trys.pop();continue}c=e.call(t,r)}catch(f){c=[6,f],o=0}finally{n=i=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}function S(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.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(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function U(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),o,i=[],s;try{for(;(e===void 0||e-- >0)&&!(o=n.next()).done;)i.push(o.value)}catch(u){s={error:u}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(s)throw s.error}}return i}function A(t,e,r){if(r||arguments.length===2)for(var n=0,o=e.length,i;n<o;n++)(i||!(n in e))&&(i||(i=Array.prototype.slice.call(e,0,n)),i[n]=e[n]);return t.concat(i||Array.prototype.slice.call(e))}function w(t){return this instanceof w?(this.v=t,this):new w(t)}function xt(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=r.apply(t,e||[]),o,i=[];return o={},s("next"),s("throw"),s("return"),o[Symbol.asyncIterator]=function(){return this},o;function s(l){n[l]&&(o[l]=function(v){return new Promise(function(x,d){i.push([l,v,x,d])>1||u(l,v)})})}function u(l,v){try{a(n[l](v))}catch(x){b(i[0][3],x)}}function a(l){l.value instanceof w?Promise.resolve(l.value.v).then(c,f):b(i[0][2],l)}function c(l){u("next",l)}function f(l){u("throw",l)}function b(l,v){l(v),i.shift(),i.length&&u(i[0][0],i[0][1])}}function _t(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=t[Symbol.asyncIterator],r;return e?e.call(t):(t=typeof S=="function"?S(t):t[Symbol.iterator](),r={},n("next"),n("throw"),n("return"),r[Symbol.asyncIterator]=function(){return this},r);function n(i){r[i]=t[i]&&function(s){return new Promise(function(u,a){s=t[i](s),o(u,a,s.done,s.value)})}}function o(i,s,u,a){Promise.resolve(a).then(function(c){i({value:c,done:u})},s)}}function h(t){return typeof t=="function"}function Q(t){var e=function(n){Error.call(n),n.stack=new Error().stack},r=t(e);return r.prototype=Object.create(Error.prototype),r.prototype.constructor=r,r}var k=Q(function(t){return function(r){t(this),this.message=r?r.length+` errors occurred during unsubscription:
|
2
|
-
`+r.map(function(n,o){return o+1+") "+n.toString()}).join(`
|
3
|
-
`):"",this.name="UnsubscriptionError",this.errors=r}});function F(t,e){if(t){var r=t.indexOf(e);0<=r&&t.splice(r,1)}}var T=function(){function t(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}return t.prototype.unsubscribe=function(){var e,r,n,o,i;if(!this.closed){this.closed=!0;var s=this._parentage;if(s)if(this._parentage=null,Array.isArray(s))try{for(var u=S(s),a=u.next();!a.done;a=u.next()){var c=a.value;c.remove(this)}}catch(d){e={error:d}}finally{try{a&&!a.done&&(r=u.return)&&r.call(u)}finally{if(e)throw e.error}}else s.remove(this);var f=this.initialTeardown;if(h(f))try{f()}catch(d){i=d instanceof k?d.errors:[d]}var b=this._finalizers;if(b){this._finalizers=null;try{for(var l=S(b),v=l.next();!v.done;v=l.next()){var x=v.value;try{H(x)}catch(d){i=i??[],d instanceof k?i=A(A([],U(i)),U(d.errors)):i.push(d)}}}catch(d){n={error:d}}finally{try{v&&!v.done&&(o=l.return)&&o.call(l)}finally{if(n)throw n.error}}}if(i)throw new k(i)}},t.prototype.add=function(e){var r;if(e&&e!==this)if(this.closed)H(e);else{if(e instanceof t){if(e.closed||e._hasParent(this))return;e._addParent(this)}(this._finalizers=(r=this._finalizers)!==null&&r!==void 0?r:[]).push(e)}},t.prototype._hasParent=function(e){var r=this._parentage;return r===e||Array.isArray(r)&&r.includes(e)},t.prototype._addParent=function(e){var r=this._parentage;this._parentage=Array.isArray(r)?(r.push(e),r):r?[r,e]:e},t.prototype._removeParent=function(e){var r=this._parentage;r===e?this._parentage=null:Array.isArray(r)&&F(r,e)},t.prototype.remove=function(e){var r=this._finalizers;r&&F(r,e),e instanceof t&&e._removeParent(this)},t.EMPTY=function(){var e=new t;return e.closed=!0,e}(),t}(),W=T.EMPTY;function X(t){return t instanceof T||t&&"closed"in t&&h(t.remove)&&h(t.add)&&h(t.unsubscribe)}function H(t){h(t)?t():t.unsubscribe()}var Z={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},L={setTimeout:function(t,e){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];var o=L.delegate;return o!=null&&o.setTimeout?o.setTimeout.apply(o,A([t,e],U(r))):setTimeout.apply(void 0,A([t,e],U(r)))},clearTimeout:function(t){var e=L.delegate;return((e==null?void 0:e.clearTimeout)||clearTimeout)(t)},delegate:void 0};function N(t){L.setTimeout(function(){throw t})}function q(){}function O(t){t()}var V=function(t){g(e,t);function e(r){var n=t.call(this)||this;return n.isStopped=!1,r?(n.destination=r,X(r)&&r.add(n)):n.destination=Ut,n}return e.create=function(r,n,o){return new D(r,n,o)},e.prototype.next=function(r){this.isStopped||this._next(r)},e.prototype.error=function(r){this.isStopped||(this.isStopped=!0,this._error(r))},e.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},e.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,t.prototype.unsubscribe.call(this),this.destination=null)},e.prototype._next=function(r){this.destination.next(r)},e.prototype._error=function(r){try{this.destination.error(r)}finally{this.unsubscribe()}},e.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},e}(T),It=Function.prototype.bind;function $(t,e){return It.call(t,e)}var Pt=function(){function t(e){this.partialObserver=e}return t.prototype.next=function(e){var r=this.partialObserver;if(r.next)try{r.next(e)}catch(n){P(n)}},t.prototype.error=function(e){var r=this.partialObserver;if(r.error)try{r.error(e)}catch(n){P(n)}else P(e)},t.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(r){P(r)}},t}(),D=function(t){g(e,t);function e(r,n,o){var i=t.call(this)||this,s;if(h(r)||!r)s={next:r??void 0,error:n??void 0,complete:o??void 0};else{var u;i&&Z.useDeprecatedNextContext?(u=Object.create(r),u.unsubscribe=function(){return i.unsubscribe()},s={next:r.next&&$(r.next,u),error:r.error&&$(r.error,u),complete:r.complete&&$(r.complete,u)}):s=r}return i.destination=new Pt(s),i}return e}(V);function P(t){N(t)}function Ot(t){throw t}var Ut={closed:!0,next:q,error:Ot,complete:q},Y=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function At(t){return t}function Tt(t){return t.length===0?At:t.length===1?t[0]:function(r){return t.reduce(function(n,o){return o(n)},r)}}var y=function(){function t(e){e&&(this._subscribe=e)}return t.prototype.lift=function(e){var r=new t;return r.source=this,r.operator=e,r},t.prototype.subscribe=function(e,r,n){var o=this,i=jt(e)?e:new D(e,r,n);return O(function(){var s=o,u=s.operator,a=s.source;i.add(u?u.call(i,a):a?o._subscribe(i):o._trySubscribe(i))}),i},t.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(r){e.error(r)}},t.prototype.forEach=function(e,r){var n=this;return r=z(r),new r(function(o,i){var s=new D({next:function(u){try{e(u)}catch(a){i(a),s.unsubscribe()}},error:i,complete:o});n.subscribe(s)})},t.prototype._subscribe=function(e){var r;return(r=this.source)===null||r===void 0?void 0:r.subscribe(e)},t.prototype[Y]=function(){return this},t.prototype.pipe=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return Tt(e)(this)},t.prototype.toPromise=function(e){var r=this;return e=z(e),new e(function(n,o){var i;r.subscribe(function(s){return i=s},function(s){return o(s)},function(){return n(i)})})},t.create=function(e){return new t(e)},t}();function z(t){var e;return(e=t??Z.Promise)!==null&&e!==void 0?e:Promise}function Ct(t){return t&&h(t.next)&&h(t.error)&&h(t.complete)}function jt(t){return t&&t instanceof V||Ct(t)&&X(t)}function kt(t){return h(t==null?void 0:t.lift)}function B(t){return function(e){if(kt(e))return e.lift(function(r){try{return t(r,this)}catch(n){this.error(n)}});throw new TypeError("Unable to lift unknown Observable type")}}function tt(t,e,r,n,o){return new $t(t,e,r,n,o)}var $t=function(t){g(e,t);function e(r,n,o,i,s,u){var a=t.call(this,r)||this;return a.onFinalize=s,a.shouldUnsubscribe=u,a._next=n?function(c){try{n(c)}catch(f){r.error(f)}}:t.prototype._next,a._error=i?function(c){try{i(c)}catch(f){r.error(f)}finally{this.unsubscribe()}}:t.prototype._error,a._complete=o?function(){try{o()}catch(c){r.error(c)}finally{this.unsubscribe()}}:t.prototype._complete,a}return e.prototype.unsubscribe=function(){var r;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var n=this.closed;t.prototype.unsubscribe.call(this),!n&&((r=this.onFinalize)===null||r===void 0||r.call(this))}},e}(V),Rt=Q(function(t){return function(){t(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),E=function(t){g(e,t);function e(){var r=t.call(this)||this;return r.closed=!1,r.currentObservers=null,r.observers=[],r.isStopped=!1,r.hasError=!1,r.thrownError=null,r}return e.prototype.lift=function(r){var n=new K(this,this);return n.operator=r,n},e.prototype._throwIfClosed=function(){if(this.closed)throw new Rt},e.prototype.next=function(r){var n=this;O(function(){var o,i;if(n._throwIfClosed(),!n.isStopped){n.currentObservers||(n.currentObservers=Array.from(n.observers));try{for(var s=S(n.currentObservers),u=s.next();!u.done;u=s.next()){var a=u.value;a.next(r)}}catch(c){o={error:c}}finally{try{u&&!u.done&&(i=s.return)&&i.call(s)}finally{if(o)throw o.error}}}})},e.prototype.error=function(r){var n=this;O(function(){if(n._throwIfClosed(),!n.isStopped){n.hasError=n.isStopped=!0,n.thrownError=r;for(var o=n.observers;o.length;)o.shift().error(r)}})},e.prototype.complete=function(){var r=this;O(function(){if(r._throwIfClosed(),!r.isStopped){r.isStopped=!0;for(var n=r.observers;n.length;)n.shift().complete()}})},e.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(e.prototype,"observed",{get:function(){var r;return((r=this.observers)===null||r===void 0?void 0:r.length)>0},enumerable:!1,configurable:!0}),e.prototype._trySubscribe=function(r){return this._throwIfClosed(),t.prototype._trySubscribe.call(this,r)},e.prototype._subscribe=function(r){return this._throwIfClosed(),this._checkFinalizedStatuses(r),this._innerSubscribe(r)},e.prototype._innerSubscribe=function(r){var n=this,o=this,i=o.hasError,s=o.isStopped,u=o.observers;return i||s?W:(this.currentObservers=null,u.push(r),new T(function(){n.currentObservers=null,F(u,r)}))},e.prototype._checkFinalizedStatuses=function(r){var n=this,o=n.hasError,i=n.thrownError,s=n.isStopped;o?r.error(i):s&&r.complete()},e.prototype.asObservable=function(){var r=new y;return r.source=this,r},e.create=function(r,n){return new K(r,n)},e}(y),K=function(t){g(e,t);function e(r,n){var o=t.call(this)||this;return o.destination=r,o.source=n,o}return e.prototype.next=function(r){var n,o;(o=(n=this.destination)===null||n===void 0?void 0:n.next)===null||o===void 0||o.call(n,r)},e.prototype.error=function(r){var n,o;(o=(n=this.destination)===null||n===void 0?void 0:n.error)===null||o===void 0||o.call(n,r)},e.prototype.complete=function(){var r,n;(n=(r=this.destination)===null||r===void 0?void 0:r.complete)===null||n===void 0||n.call(r)},e.prototype._subscribe=function(r){var n,o;return(o=(n=this.source)===null||n===void 0?void 0:n.subscribe(r))!==null&&o!==void 0?o:W},e}(E),rt=function(t){g(e,t);function e(r){var n=t.call(this)||this;return n._value=r,n}return Object.defineProperty(e.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),e.prototype._subscribe=function(r){var n=t.prototype._subscribe.call(this,r);return!n.closed&&r.next(this._value),n},e.prototype.getValue=function(){var r=this,n=r.hasError,o=r.thrownError,i=r._value;if(n)throw o;return this._throwIfClosed(),i},e.prototype.next=function(r){t.prototype.next.call(this,this._value=r)},e}(E),Ft=new y(function(t){return t.complete()});function Lt(t){return t&&h(t.schedule)}function Dt(t){return t[t.length-1]}function Vt(t){return Lt(Dt(t))?t.pop():void 0}var et=function(t){return t&&typeof t.length=="number"&&typeof t!="function"};function nt(t){return h(t==null?void 0:t.then)}function ot(t){return h(t[Y])}function it(t){return Symbol.asyncIterator&&h(t==null?void 0:t[Symbol.asyncIterator])}function st(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 Yt(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var ut=Yt();function ct(t){return h(t==null?void 0:t[ut])}function at(t){return xt(this,arguments,function(){var r,n,o,i;return J(this,function(s){switch(s.label){case 0:r=t.getReader(),s.label=1;case 1:s.trys.push([1,,9,10]),s.label=2;case 2:return[4,w(r.read())];case 3:return n=s.sent(),o=n.value,i=n.done,i?[4,w(void 0)]:[3,5];case 4:return[2,s.sent()];case 5:return[4,w(o)];case 6:return[4,s.sent()];case 7:return s.sent(),[3,2];case 8:return[3,10];case 9:return r.releaseLock(),[7];case 10:return[2]}})})}function lt(t){return h(t==null?void 0:t.getReader)}function M(t){if(t instanceof y)return t;if(t!=null){if(ot(t))return Bt(t);if(et(t))return Mt(t);if(nt(t))return Gt(t);if(it(t))return ft(t);if(ct(t))return Ht(t);if(lt(t))return qt(t)}throw st(t)}function Bt(t){return new y(function(e){var r=t[Y]();if(h(r.subscribe))return r.subscribe(e);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function Mt(t){return new y(function(e){for(var r=0;r<t.length&&!e.closed;r++)e.next(t[r]);e.complete()})}function Gt(t){return new y(function(e){t.then(function(r){e.closed||(e.next(r),e.complete())},function(r){return e.error(r)}).then(null,N)})}function Ht(t){return new y(function(e){var r,n;try{for(var o=S(t),i=o.next();!i.done;i=o.next()){var s=i.value;if(e.next(s),e.closed)return}}catch(u){r={error:u}}finally{try{i&&!i.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}e.complete()})}function ft(t){return new y(function(e){zt(t,e).catch(function(r){return e.error(r)})})}function qt(t){return ft(at(t))}function zt(t,e){var r,n,o,i;return Et(this,void 0,void 0,function(){var s,u;return J(this,function(a){switch(a.label){case 0:a.trys.push([0,5,6,11]),r=_t(t),a.label=1;case 1:return[4,r.next()];case 2:if(n=a.sent(),!!n.done)return[3,4];if(s=n.value,e.next(s),e.closed)return[2];a.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return u=a.sent(),o={error:u},[3,11];case 6:return a.trys.push([6,,9,10]),n&&!n.done&&(i=r.return)?[4,i.call(r)]:[3,8];case 7:a.sent(),a.label=8;case 8:return[3,10];case 9:if(o)throw o.error;return[7];case 10:return[7];case 11:return e.complete(),[2]}})})}function m(t,e,r,n,o){n===void 0&&(n=0),o===void 0&&(o=!1);var i=e.schedule(function(){r(),o?t.add(this.schedule(null,n)):this.unsubscribe()},n);if(t.add(i),!o)return i}function ht(t,e){return e===void 0&&(e=0),B(function(r,n){r.subscribe(tt(n,function(o){return m(n,t,function(){return n.next(o)},e)},function(){return m(n,t,function(){return n.complete()},e)},function(o){return m(n,t,function(){return n.error(o)},e)}))})}function pt(t,e){return e===void 0&&(e=0),B(function(r,n){n.add(t.schedule(function(){return r.subscribe(n)},e))})}function Kt(t,e){return M(t).pipe(pt(e),ht(e))}function Jt(t,e){return M(t).pipe(pt(e),ht(e))}function Qt(t,e){return new y(function(r){var n=0;return e.schedule(function(){n===t.length?r.complete():(r.next(t[n++]),r.closed||this.schedule())})})}function Wt(t,e){return new y(function(r){var n;return m(r,e,function(){n=t[ut](),m(r,e,function(){var o,i,s;try{o=n.next(),i=o.value,s=o.done}catch(u){r.error(u);return}s?r.complete():r.next(i)},0,!0)}),function(){return h(n==null?void 0:n.return)&&n.return()}})}function dt(t,e){if(!t)throw new Error("Iterable cannot be null");return new y(function(r){m(r,e,function(){var n=t[Symbol.asyncIterator]();m(r,e,function(){n.next().then(function(o){o.done?r.complete():r.next(o.value)})},0,!0)})})}function Xt(t,e){return dt(at(t),e)}function Zt(t,e){if(t!=null){if(ot(t))return Kt(t,e);if(et(t))return Qt(t,e);if(nt(t))return Jt(t,e);if(it(t))return dt(t,e);if(ct(t))return Wt(t,e);if(lt(t))return Xt(t,e)}throw st(t)}function Nt(t,e){return e?Zt(t,e):M(t)}function tr(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=Vt(t);return Nt(t,r)}function rr(t){return t<=0?function(){return Ft}:B(function(e,r){var n=0;e.subscribe(tt(r,function(o){++n<=t&&(r.next(o),t<=n&&r.complete())}))})}class er{constructor(e,r){this.id=e,this.entries$=new rt([]),r.addEventListener("user-submit",n=>{if(!this.provider){console.warn("No provider activated, unable to print message to conversation.");return}this.provider.onUserSubmit(n.detail)})}write(e){this.entries$.pipe(rr(1)).subscribe(r=>{this.entries$.next([...r,e])})}entries(){return this.entries$.asObservable()}setProvider(e){this.provider=e,this.provider.actions().subscribe(r=>{this.write(r)})}isTyping(){return this.provider?this.provider.isTyping():tr(!1)}}class C{constructor(){this.sessions=new Map,this.registeredProviders=new Map,this.activeSessionId=null}static async getInstance(e){let r=await e.get("conversation");return r||(r=new C,await e.register("conversation",r),r)}registerProvider(e,r){this.registeredProviders.set(e,r)}createSession(e){const r=new er(gt(),e),n=this.getProviderByConfiguration(e);if(n){const o=n();r.setProvider(o)}return this.sessions.set(r.id,r),this.activeSessionId=r.id,r}getProviderByConfiguration(e){const[r]=e.properties.providers||[];if(!r){console.warn("No providers registered. You most likely forgot to add a provider to the conversation component properties.");return}return this.registeredProviders.get(r)}}const nr=async t=>{t.registerComponent("conversation",Promise.resolve().then(()=>require("./conversation-9bbc787d.js")).then(e=>e.conversation)),await C.getInstance(t.container)};var _=(t=>(t.User="user",t.Agent="agent",t.System="system",t))(_||{});class j{constructor(e,r,n){this.type=e,this.sender=r,this.messages=n,this.didUpdate=new E,this.timestamp=Date.now()}update(e){this.messages=[{items:e}],this.didUpdate.next(this)}}class vt{constructor(e){this.name=e,this.print$=new E}print(e){const r=new j(_.Agent,{name:this.name},[{items:[["html",{content:e}]]}]);return this.print$.next(r),r}subscribe(){return this.print$.asObservable()}}class yt{constructor(e){this.name=e,this.print$=new E}print(e){const r=new j(_.User,{name:this.name},[{items:[["html",{content:e}]]}]);return this.print$.next(r),r}subscribe(){return this.print$.asObservable()}}class or{constructor(e){this.name=e,this.print$=new E,this.typingState$=new rt(!1)}onUserSubmit(e){this.print(_.User,e.text)}print(e,r){const n=new j(e,{name:""},[{items:[["html",{content:r}]]}]);return this.printEntry(n)}printEntry(e){return this.print$.next(e),e}createAgent(e){const r=new vt(e);return r.subscribe().subscribe(n=>{this.printEntry(n)}),r}createUser(e){const r=new yt(e);return r.subscribe().subscribe(n=>{this.printEntry(n)}),r}setTypingState(e){this.typingState$.next(e)}isTyping(){return this.typingState$.asObservable()}actions(){return this.print$.asObservable()}}exports.Agent=vt;exports.ConversationComponent=nr;exports.ConversationEntry=j;exports.ConversationMessageType=_;exports.ConversationPlatform=C;exports.ConversationProvider=or;exports.User=yt;
|