@telia-ace/widget-conversation-flamingo 1.1.45-rc.3 → 1.1.45-rc.5
Sign up to get free protection for your applications and to get access to all the features.
- package/{conversation-ebf57871.js → conversation-4cae227d.js} +35 -35
- package/{conversation-ed602fb6.mjs → conversation-f7ad8459.mjs} +197 -197
- package/conversation.d.ts +2 -1
- package/index-20604d5c.js +3 -0
- package/index-913a371e.mjs +1199 -0
- package/index.js +1 -3
- package/index.mjs +9 -1308
- package/models/conversation-provider.d.ts +4 -1
- package/models/conversation-session-state.d.ts +2 -3
- package/package.json +2 -2
package/index.js
CHANGED
@@ -1,3 +1 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});
|
2
|
-
`+t.map(function(n,i){return i+1+") "+n.toString()}).join(`
|
3
|
-
`):"",this.name="UnsubscriptionError",this.errors=t}});function D(r,e){if(r){var t=r.indexOf(e);0<=t&&r.splice(t,1)}}var j=function(){function r(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}return r.prototype.unsubscribe=function(){var e,t,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 u=g(s),a=u.next();!a.done;a=u.next()){var c=a.value;c.remove(this)}}catch(p){e={error:p}}finally{try{a&&!a.done&&(t=u.return)&&t.call(u)}finally{if(e)throw e.error}}else s.remove(this);var l=this.initialTeardown;if(h(l))try{l()}catch(p){o=p instanceof F?p.errors:[p]}var v=this._finalizers;if(v){this._finalizers=null;try{for(var f=g(v),y=f.next();!y.done;y=f.next()){var _=y.value;try{z(_)}catch(p){o=o??[],p instanceof F?o=k(k([],C(o)),C(p.errors)):o.push(p)}}}catch(p){n={error:p}}finally{try{y&&!y.done&&(i=f.return)&&i.call(f)}finally{if(n)throw n.error}}}if(o)throw new F(o)}},r.prototype.add=function(e){var t;if(e&&e!==this)if(this.closed)z(e);else{if(e instanceof r){if(e.closed||e._hasParent(this))return;e._addParent(this)}(this._finalizers=(t=this._finalizers)!==null&&t!==void 0?t:[]).push(e)}},r.prototype._hasParent=function(e){var t=this._parentage;return t===e||Array.isArray(t)&&t.includes(e)},r.prototype._addParent=function(e){var t=this._parentage;this._parentage=Array.isArray(t)?(t.push(e),t):t?[t,e]:e},r.prototype._removeParent=function(e){var t=this._parentage;t===e?this._parentage=null:Array.isArray(t)&&D(t,e)},r.prototype.remove=function(e){var t=this._finalizers;t&&D(t,e),e instanceof r&&e._removeParent(this)},r.EMPTY=function(){var e=new r;return e.closed=!0,e}(),r}(),Z=j.EMPTY;function N(r){return r instanceof j||r&&"closed"in r&&h(r.remove)&&h(r.add)&&h(r.unsubscribe)}function z(r){h(r)?r():r.unsubscribe()}var tt={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},Y={setTimeout:function(r,e){for(var t=[],n=2;n<arguments.length;n++)t[n-2]=arguments[n];var i=Y.delegate;return i!=null&&i.setTimeout?i.setTimeout.apply(i,k([r,e],C(t))):setTimeout.apply(void 0,k([r,e],C(t)))},clearTimeout:function(r){var e=Y.delegate;return((e==null?void 0:e.clearTimeout)||clearTimeout)(r)},delegate:void 0};function et(r){Y.setTimeout(function(){throw r})}function V(){}function $(r){r()}var B=function(r){x(e,r);function e(t){var n=r.call(this)||this;return n.isStopped=!1,t?(n.destination=t,N(t)&&t.add(n)):n.destination=At,n}return e.create=function(t,n,i){return new q(t,n,i)},e.prototype.next=function(t){this.isStopped||this._next(t)},e.prototype.error=function(t){this.isStopped||(this.isStopped=!0,this._error(t))},e.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},e.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,r.prototype.unsubscribe.call(this),this.destination=null)},e.prototype._next=function(t){this.destination.next(t)},e.prototype._error=function(t){try{this.destination.error(t)}finally{this.unsubscribe()}},e.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},e}(j),Ot=Function.prototype.bind;function L(r,e){return Ot.call(r,e)}var Ut=function(){function r(e){this.partialObserver=e}return r.prototype.next=function(e){var t=this.partialObserver;if(t.next)try{t.next(e)}catch(n){A(n)}},r.prototype.error=function(e){var t=this.partialObserver;if(t.error)try{t.error(e)}catch(n){A(n)}else A(e)},r.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(t){A(t)}},r}(),q=function(r){x(e,r);function e(t,n,i){var o=r.call(this)||this,s;if(h(t)||!t)s={next:t??void 0,error:n??void 0,complete:i??void 0};else{var u;o&&tt.useDeprecatedNextContext?(u=Object.create(t),u.unsubscribe=function(){return o.unsubscribe()},s={next:t.next&&L(t.next,u),error:t.error&&L(t.error,u),complete:t.complete&&L(t.complete,u)}):s=t}return o.destination=new Ut(s),o}return e}(B);function A(r){et(r)}function Tt(r){throw r}var At={closed:!0,next:V,error:Tt,complete:V},H=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function $t(r){return r}function Ct(r){return r.length===0?$t:r.length===1?r[0]:function(t){return r.reduce(function(n,i){return i(n)},t)}}var b=function(){function r(e){e&&(this._subscribe=e)}return r.prototype.lift=function(e){var t=new r;return t.source=this,t.operator=e,t},r.prototype.subscribe=function(e,t,n){var i=this,o=jt(e)?e:new q(e,t,n);return $(function(){var s=i,u=s.operator,a=s.source;o.add(u?u.call(o,a):a?i._subscribe(o):i._trySubscribe(o))}),o},r.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(t){e.error(t)}},r.prototype.forEach=function(e,t){var n=this;return t=K(t),new t(function(i,o){var s=new q({next:function(u){try{e(u)}catch(a){o(a),s.unsubscribe()}},error:o,complete:i});n.subscribe(s)})},r.prototype._subscribe=function(e){var t;return(t=this.source)===null||t===void 0?void 0:t.subscribe(e)},r.prototype[H]=function(){return this},r.prototype.pipe=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Ct(e)(this)},r.prototype.toPromise=function(e){var t=this;return e=K(e),new e(function(n,i){var o;t.subscribe(function(s){return o=s},function(s){return i(s)},function(){return n(o)})})},r.create=function(e){return new r(e)},r}();function K(r){var e;return(e=r??tt.Promise)!==null&&e!==void 0?e:Promise}function kt(r){return r&&h(r.next)&&h(r.error)&&h(r.complete)}function jt(r){return r&&r instanceof B||kt(r)&&N(r)}function Rt(r){return h(r==null?void 0:r.lift)}function I(r){return function(e){if(Rt(e))return e.lift(function(t){try{return r(t,this)}catch(n){this.error(n)}});throw new TypeError("Unable to lift unknown Observable type")}}function P(r,e,t,n,i){return new Ft(r,e,t,n,i)}var Ft=function(r){x(e,r);function e(t,n,i,o,s,u){var a=r.call(this,t)||this;return a.onFinalize=s,a.shouldUnsubscribe=u,a._next=n?function(c){try{n(c)}catch(l){t.error(l)}}:r.prototype._next,a._error=o?function(c){try{o(c)}catch(l){t.error(l)}finally{this.unsubscribe()}}:r.prototype._error,a._complete=i?function(){try{i()}catch(c){t.error(c)}finally{this.unsubscribe()}}:r.prototype._complete,a}return e.prototype.unsubscribe=function(){var t;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var n=this.closed;r.prototype.unsubscribe.call(this),!n&&((t=this.onFinalize)===null||t===void 0||t.call(this))}},e}(B),Lt=X(function(r){return function(){r(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),m=function(r){x(e,r);function e(){var t=r.call(this)||this;return t.closed=!1,t.currentObservers=null,t.observers=[],t.isStopped=!1,t.hasError=!1,t.thrownError=null,t}return e.prototype.lift=function(t){var n=new J(this,this);return n.operator=t,n},e.prototype._throwIfClosed=function(){if(this.closed)throw new Lt},e.prototype.next=function(t){var n=this;$(function(){var i,o;if(n._throwIfClosed(),!n.isStopped){n.currentObservers||(n.currentObservers=Array.from(n.observers));try{for(var s=g(n.currentObservers),u=s.next();!u.done;u=s.next()){var a=u.value;a.next(t)}}catch(c){i={error:c}}finally{try{u&&!u.done&&(o=s.return)&&o.call(s)}finally{if(i)throw i.error}}}})},e.prototype.error=function(t){var n=this;$(function(){if(n._throwIfClosed(),!n.isStopped){n.hasError=n.isStopped=!0,n.thrownError=t;for(var i=n.observers;i.length;)i.shift().error(t)}})},e.prototype.complete=function(){var t=this;$(function(){if(t._throwIfClosed(),!t.isStopped){t.isStopped=!0;for(var n=t.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 t;return((t=this.observers)===null||t===void 0?void 0:t.length)>0},enumerable:!1,configurable:!0}),e.prototype._trySubscribe=function(t){return this._throwIfClosed(),r.prototype._trySubscribe.call(this,t)},e.prototype._subscribe=function(t){return this._throwIfClosed(),this._checkFinalizedStatuses(t),this._innerSubscribe(t)},e.prototype._innerSubscribe=function(t){var n=this,i=this,o=i.hasError,s=i.isStopped,u=i.observers;return o||s?Z:(this.currentObservers=null,u.push(t),new j(function(){n.currentObservers=null,D(u,t)}))},e.prototype._checkFinalizedStatuses=function(t){var n=this,i=n.hasError,o=n.thrownError,s=n.isStopped;i?t.error(o):s&&t.complete()},e.prototype.asObservable=function(){var t=new b;return t.source=this,t},e.create=function(t,n){return new J(t,n)},e}(b),J=function(r){x(e,r);function e(t,n){var i=r.call(this)||this;return i.destination=t,i.source=n,i}return e.prototype.next=function(t){var n,i;(i=(n=this.destination)===null||n===void 0?void 0:n.next)===null||i===void 0||i.call(n,t)},e.prototype.error=function(t){var n,i;(i=(n=this.destination)===null||n===void 0?void 0:n.error)===null||i===void 0||i.call(n,t)},e.prototype.complete=function(){var t,n;(n=(t=this.destination)===null||t===void 0?void 0:t.complete)===null||n===void 0||n.call(t)},e.prototype._subscribe=function(t){var n,i;return(i=(n=this.source)===null||n===void 0?void 0:n.subscribe(t))!==null&&i!==void 0?i:Z},e}(m),rt=function(r){x(e,r);function e(t){var n=r.call(this)||this;return n._value=t,n}return Object.defineProperty(e.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),e.prototype._subscribe=function(t){var n=r.prototype._subscribe.call(this,t);return!n.closed&&t.next(this._value),n},e.prototype.getValue=function(){var t=this,n=t.hasError,i=t.thrownError,o=t._value;if(n)throw i;return this._throwIfClosed(),o},e.prototype.next=function(t){r.prototype.next.call(this,this._value=t)},e}(m),Mt=new b(function(r){return r.complete()});function Dt(r){return r&&h(r.schedule)}function Yt(r){return r[r.length-1]}function Vt(r){return Dt(Yt(r))?r.pop():void 0}var nt=function(r){return r&&typeof r.length=="number"&&typeof r!="function"};function it(r){return h(r==null?void 0:r.then)}function ot(r){return h(r[H])}function st(r){return Symbol.asyncIterator&&h(r==null?void 0:r[Symbol.asyncIterator])}function ut(r){return new TypeError("You provided "+(r!==null&&typeof r=="object"?"an invalid object":"'"+r+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}function qt(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var ct=qt();function at(r){return h(r==null?void 0:r[ct])}function lt(r){return Pt(this,arguments,function(){var t,n,i,o;return W(this,function(s){switch(s.label){case 0:t=r.getReader(),s.label=1;case 1:s.trys.push([1,,9,10]),s.label=2;case 2:return[4,S(t.read())];case 3:return n=s.sent(),i=n.value,o=n.done,o?[4,S(void 0)]:[3,5];case 4:return[2,s.sent()];case 5:return[4,S(i)];case 6:return[4,s.sent()];case 7:return s.sent(),[3,2];case 8:return[3,10];case 9:return t.releaseLock(),[7];case 10:return[2]}})})}function ft(r){return h(r==null?void 0:r.getReader)}function O(r){if(r instanceof b)return r;if(r!=null){if(ot(r))return Bt(r);if(nt(r))return Ht(r);if(it(r))return Gt(r);if(st(r))return ht(r);if(at(r))return zt(r);if(ft(r))return Kt(r)}throw ut(r)}function Bt(r){return new b(function(e){var t=r[H]();if(h(t.subscribe))return t.subscribe(e);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function Ht(r){return new b(function(e){for(var t=0;t<r.length&&!e.closed;t++)e.next(r[t]);e.complete()})}function Gt(r){return new b(function(e){r.then(function(t){e.closed||(e.next(t),e.complete())},function(t){return e.error(t)}).then(null,et)})}function zt(r){return new b(function(e){var t,n;try{for(var i=g(r),o=i.next();!o.done;o=i.next()){var s=o.value;if(e.next(s),e.closed)return}}catch(u){t={error:u}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}e.complete()})}function ht(r){return new b(function(e){Jt(r,e).catch(function(t){return e.error(t)})})}function Kt(r){return ht(lt(r))}function Jt(r,e){var t,n,i,o;return _t(this,void 0,void 0,function(){var s,u;return W(this,function(a){switch(a.label){case 0:a.trys.push([0,5,6,11]),t=It(r),a.label=1;case 1:return[4,t.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(),i={error:u},[3,11];case 6:return a.trys.push([6,,9,10]),n&&!n.done&&(o=t.return)?[4,o.call(t)]:[3,8];case 7:a.sent(),a.label=8;case 8:return[3,10];case 9:if(i)throw i.error;return[7];case 10:return[7];case 11:return e.complete(),[2]}})})}function w(r,e,t,n,i){n===void 0&&(n=0),i===void 0&&(i=!1);var o=e.schedule(function(){t(),i?r.add(this.schedule(null,n)):this.unsubscribe()},n);if(r.add(o),!i)return o}function dt(r,e){return e===void 0&&(e=0),I(function(t,n){t.subscribe(P(n,function(i){return w(n,r,function(){return n.next(i)},e)},function(){return w(n,r,function(){return n.complete()},e)},function(i){return w(n,r,function(){return n.error(i)},e)}))})}function pt(r,e){return e===void 0&&(e=0),I(function(t,n){n.add(r.schedule(function(){return t.subscribe(n)},e))})}function Qt(r,e){return O(r).pipe(pt(e),dt(e))}function Wt(r,e){return O(r).pipe(pt(e),dt(e))}function Xt(r,e){return new b(function(t){var n=0;return e.schedule(function(){n===r.length?t.complete():(t.next(r[n++]),t.closed||this.schedule())})})}function Zt(r,e){return new b(function(t){var n;return w(t,e,function(){n=r[ct](),w(t,e,function(){var i,o,s;try{i=n.next(),o=i.value,s=i.done}catch(u){t.error(u);return}s?t.complete():t.next(o)},0,!0)}),function(){return h(n==null?void 0:n.return)&&n.return()}})}function vt(r,e){if(!r)throw new Error("Iterable cannot be null");return new b(function(t){w(t,e,function(){var n=r[Symbol.asyncIterator]();w(t,e,function(){n.next().then(function(i){i.done?t.complete():t.next(i.value)})},0,!0)})})}function Nt(r,e){return vt(lt(r),e)}function te(r,e){if(r!=null){if(ot(r))return Qt(r,e);if(nt(r))return Xt(r,e);if(it(r))return Wt(r,e);if(st(r))return vt(r,e);if(at(r))return Zt(r,e);if(ft(r))return Nt(r,e)}throw ut(r)}function ee(r,e){return e?te(r,e):O(r)}function re(){for(var r=[],e=0;e<arguments.length;e++)r[e]=arguments[e];var t=Vt(r);return ee(r,t)}function Q(r){return r<=0?function(){return Mt}:I(function(e,t){var n=0;e.subscribe(P(t,function(i){++n<=r&&(t.next(i),r<=n&&t.complete())}))})}function ne(r,e){return I(function(t,n){var i=null,o=0,s=!1,u=function(){return s&&!i&&n.complete()};t.subscribe(P(n,function(a){i==null||i.unsubscribe();var c=0,l=o++;O(r(a,l)).subscribe(i=P(n,function(v){return n.next(e?e(a,v,l,c++):v)},function(){i=null,u()}))},function(){s=!0,u()}))})}function ie(r){return I(function(e,t){O(r).subscribe(P(t,function(){return t.complete()},V)),!t.closed&&e.subscribe(t)})}class yt{constructor(e,t,n){this.id=e,this.component=t,this.platform=n,this.entries$=new rt([]),this.kill$=new m,this.queue=[],t.addEventListener("user-submit",i=>{if(!this.provider){console.warn("No provider activated, unable to print message to conversation.");return}this.provider.onUserSubmit(i.detail)})}write(e){this.addEntryRemoveHandler(e),this.entries$.pipe(Q(1)).subscribe(t=>{this.entries$.next([...t,e])})}entries(){return this.entries$.asObservable()}setProvider(e,t={}){this.provider=e,this.provider.actions().pipe(ie(this.kill$)).subscribe(n=>{this.write(n)}),this.provider.connect(t)}handover(e,t={}){var i;(i=this.provider)==null||i.setTypingState(!1);const n=this.platform.registeredProviders.get(e);if(n){this.provider&&this.queue.unshift(this.provider),this.kill$.next();const o=n(this);this.setProvider(o,t)}}addEntryRemoveHandler(e){e.remove$.pipe(ne(()=>this.entries$),Q(1)).subscribe(t=>{this.entries$.next(t.filter(n=>n!==e))})}completeProvider(){const[e]=this.queue;e&&this.setProvider(e)}isTyping(){return this.provider?this.provider.isTyping():re(!1)}}class R{constructor(){this.sessions=new Map,this.registeredProviders=new Map,this.activeSessionId=null}static async getInstance(e){let t=await e.get("conversation");return t||(t=new R,await e.register("conversation",t),t)}registerProvider(e,t){this.registeredProviders.set(e,t)}createSession(e){const t=new yt(Et(),e,this),n=this.getProviderByConfiguration(e);if(n){const i=n(t);t.setProvider(i)}return this.sessions.set(t.id,t),this.activeSessionId=t.id,t}getProviderByConfiguration(e){const[t]=e.properties.providers||[];if(!t){console.warn("No providers registered. You most likely forgot to add a provider to the conversation component properties.");return}return this.registeredProviders.get(t)}}const oe=async r=>{r.registerComponent("conversation",Promise.resolve().then(()=>require("./conversation-ebf57871.js"))),await R.getInstance(r.container)};var E=(r=>(r.User="user",r.Agent="agent",r.System="system",r))(E||{});class U{constructor(e,t,n){this.type=e,this.sender=t,this.messages=n,this.status="delivered",this.didUpdate=new m,this.actions$=new m,this.remove$=new m,this.timestamp=Date.now()}update(e){this.messages=[{items:e}],this.didUpdate.next(this)}setStatus(e){this.status=e,this.didUpdate.next(this)}remove(){this.remove$.next()}}class bt{constructor(e){this.name=e,this.print$=new m}print(e){const t=new U(E.Agent,{name:this.name},[{items:[["html",{content:e}]]}]);return this.print$.next(t),t}subscribe(){return this.print$.asObservable()}}class mt{constructor(e){this.name=e,this.print$=new m}print(e){const t=new U(E.User,{name:this.name},[{items:[["html",{content:e}]]}]);return this.print$.next(t),t}subscribe(){return this.print$.asObservable()}}class se{constructor(){this.print$=new m,this.name="system"}print(e){const t=new U(E.System,{name:this.name},[{items:[["html",{content:e}]]}]);return this.print$.next(t),t}subscribe(){return this.print$.asObservable()}}class ue{constructor(e,t){this.name=e,this.session=t,this.print$=new m,this.typingState$=new rt(!1),this.system=this.createSystem()}connect(e={}){}onUserSubmit(e){this.print(E.User,e.text)}print(e,t){const n=new U(e,{name:""},[{items:[["html",{content:t}]]}]);return this.printEntry(n)}printEntry(e){return this.print$.next(e),e}createAgent(e){const t=new bt(e);return t.subscribe().subscribe(n=>{this.playNotification(),this.printEntry(n)}),t}createUser(e){const t=new mt(e);return t.subscribe().subscribe(n=>{this.printEntry(n)}),t}createSystem(){const e=new se;return e.subscribe().subscribe(t=>{this.printEntry(t)}),e}setTypingState(e){this.typingState$.next(e)}setToastMessage(e){this.session.component.setToastMessage(e)}isTyping(){return this.typingState$.asObservable()}actions(){return this.print$.asObservable()}complete(){this.session.completeProvider()}playNotification(){const e="https://publicpoc.blob.core.windows.net/widget-assets/notification.mp3";this.session.component.application.branding().other.disableSound||new Audio(e).play()}}exports.Agent=bt;exports.ConversationComponent=oe;exports.ConversationEntry=U;exports.ConversationMessageType=E;exports.ConversationPlatform=R;exports.ConversationProvider=ue;exports.ConversationSessionState=yt;exports.User=mt;
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-20604d5c.js");exports.Agent=e.Agent;exports.ConversationComponent=e.ConversationComponent;exports.ConversationEntry=e.ConversationEntry;exports.ConversationMessageType=e.ConversationMessageType;exports.ConversationPlatform=e.ConversationPlatform;exports.ConversationProvider=e.ConversationProvider;exports.ConversationSessionState=e.ConversationSessionState;exports.User=e.User;
|