@telia-ace/widget-conversation-flamingo 1.1.38-rc.1 → 1.1.38-rc.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -2705,6 +2705,7 @@ class tt extends ls {
2705
2705
  const e = this.application.texts, i = e.getOrFallback("conversation.mute", "Mute"), n = e.getOrFallback("conversation.unmute", "Unmute"), r = !!this.application.branding().other.disableSound, a = t.addOption({
2706
2706
  label: r ? n : i,
2707
2707
  icon: r ? de.svg : ce.svg,
2708
+ closeOnClick: !1,
2708
2709
  onClick: () => {
2709
2710
  !!this.application.branding().other.disableSound ? (this.application.unmute(), a.updateLabel(i), a.updateIcon(de.svg)) : (this.application.mute(), a.updateLabel(n), a.updateIcon(ce.svg));
2710
2711
  }
@@ -580,7 +580,7 @@
580
580
  padding: 0;
581
581
  word-break: break-word;
582
582
  }
583
- `];as([$({attribute:!1})],$t.prototype,"message",2);$t=as([V("message-type-html")],$t);class fn{constructor(t){this._message=null,this._host=t,t.addController(this)}hostConnected(){}set message(t){this._message=t,this._host.requestUpdate()}get message(){return this._message}hasMessage(){return!!this.message}}var gn=Object.defineProperty,$n=Object.getOwnPropertyDescriptor,At=(s,t,e,i)=>{for(var n=i>1?void 0:i?$n(t,e):t,o=s.length-1,r;o>=0;o--)(r=s[o])&&(n=(i?r(t,e,n):r(n))||n);return i&&n&&gn(t,e,n),n};const mn=s=>{s.scrollTo?s.scrollTo({top:s.scrollHeight,behavior:"smooth"}):s.scrollTop=s.scrollHeight},ls=is(m);class R extends ls{constructor(){super(...arguments),this.toast=new fn(this),this.message="",this.platform=null,this.session=null,this.disabled=!1,this.conversationContentRef=pt(),this.formRef=pt(),this.chatScrollHeight=0}async connectedCallback(){super.connectedCallback();const t=await this.application.container.get("conversation");this.platform=t||null,this.platform&&(this.platform.activeSessionId?this.session=this.platform.sessions.get(this.platform.activeSessionId)||null:this.session=this.platform.createSession(this)||null),this._addHeaderOptions()}async _onSendMessage(t){var i;if(t.preventDefault(),this.message.length<=0){(i=this.formRef.value)==null||i.classList.add("shake"),setTimeout(()=>{var n;(n=this.formRef.value)==null||n.classList.remove("shake")},500);return}const e=new CustomEvent("user-submit",{detail:{text:this.message}});this.dispatchEvent(e),this.message=""}_addHeaderOptions(){const t=this.application.getComponent("widget-header");if(!t)return;const e=this.application.texts,i=e.getOrFallback("conversation.mute","Mute"),n=e.getOrFallback("conversation.unmute","Unmute"),r=!!this.application.branding().other.disableSound,a=t.addOption({label:r?n:i,icon:r?de.svg:ce.svg,onClick:()=>{!!this.application.branding().other.disableSound?(this.application.unmute(),a.updateLabel(i),a.updateIcon(de.svg)):(this.application.mute(),a.updateLabel(n),a.updateIcon(ce.svg))}})}_inputHandler(t){this.message=t.target.value}_actionHandler(t){}onSessionUpdated(){const t=this.conversationContentRef.value;t&&setTimeout(()=>{const e=t.scrollHeight;e>this.chatScrollHeight&&(mn(t),this.chatScrollHeight=e)},1e3)}disableInput(){this.disabled=!0}enableInput(){this.disabled=!1}setToastMessage(t){this.toast.message=t}render(){const t=this.application.texts;return f` <div
583
+ `];as([$({attribute:!1})],$t.prototype,"message",2);$t=as([V("message-type-html")],$t);class fn{constructor(t){this._message=null,this._host=t,t.addController(this)}hostConnected(){}set message(t){this._message=t,this._host.requestUpdate()}get message(){return this._message}hasMessage(){return!!this.message}}var gn=Object.defineProperty,$n=Object.getOwnPropertyDescriptor,At=(s,t,e,i)=>{for(var n=i>1?void 0:i?$n(t,e):t,o=s.length-1,r;o>=0;o--)(r=s[o])&&(n=(i?r(t,e,n):r(n))||n);return i&&n&&gn(t,e,n),n};const mn=s=>{s.scrollTo?s.scrollTo({top:s.scrollHeight,behavior:"smooth"}):s.scrollTop=s.scrollHeight},ls=is(m);class R extends ls{constructor(){super(...arguments),this.toast=new fn(this),this.message="",this.platform=null,this.session=null,this.disabled=!1,this.conversationContentRef=pt(),this.formRef=pt(),this.chatScrollHeight=0}async connectedCallback(){super.connectedCallback();const t=await this.application.container.get("conversation");this.platform=t||null,this.platform&&(this.platform.activeSessionId?this.session=this.platform.sessions.get(this.platform.activeSessionId)||null:this.session=this.platform.createSession(this)||null),this._addHeaderOptions()}async _onSendMessage(t){var i;if(t.preventDefault(),this.message.length<=0){(i=this.formRef.value)==null||i.classList.add("shake"),setTimeout(()=>{var n;(n=this.formRef.value)==null||n.classList.remove("shake")},500);return}const e=new CustomEvent("user-submit",{detail:{text:this.message}});this.dispatchEvent(e),this.message=""}_addHeaderOptions(){const t=this.application.getComponent("widget-header");if(!t)return;const e=this.application.texts,i=e.getOrFallback("conversation.mute","Mute"),n=e.getOrFallback("conversation.unmute","Unmute"),r=!!this.application.branding().other.disableSound,a=t.addOption({label:r?n:i,icon:r?de.svg:ce.svg,closeOnClick:!1,onClick:()=>{!!this.application.branding().other.disableSound?(this.application.unmute(),a.updateLabel(i),a.updateIcon(de.svg)):(this.application.mute(),a.updateLabel(n),a.updateIcon(ce.svg))}})}_inputHandler(t){this.message=t.target.value}_actionHandler(t){}onSessionUpdated(){const t=this.conversationContentRef.value;t&&setTimeout(()=>{const e=t.scrollHeight;e>this.chatScrollHeight&&(mn(t),this.chatScrollHeight=e)},1e3)}disableInput(){this.disabled=!0}enableInput(){this.disabled=!1}setToastMessage(t){this.toast.message=t}render(){const t=this.application.texts;return f` <div
584
584
  @action=${this._actionHandler}
585
585
  class=${Xt({conversation:!0,disabled:this.disabled,"conversation--has-toast":this.toast.hasMessage(),"conversation--input-has-text":this.message.length>0})}
586
586
  >
package/index.js CHANGED
@@ -1,3 +1,3 @@
1
1
  "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});let T;const wt=new Uint8Array(16);function St(){if(!T&&(T=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!T))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return T(wt)}const d=[];for(let e=0;e<256;++e)d.push((e+256).toString(16).slice(1));function gt(e,r=0){return d[e[r+0]]+d[e[r+1]]+d[e[r+2]]+d[e[r+3]]+"-"+d[e[r+4]]+d[e[r+5]]+"-"+d[e[r+6]]+d[e[r+7]]+"-"+d[e[r+8]]+d[e[r+9]]+"-"+d[e[r+10]]+d[e[r+11]]+d[e[r+12]]+d[e[r+13]]+d[e[r+14]]+d[e[r+15]]}const xt=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),G={randomUUID:xt};function Et(e,r,t){if(G.randomUUID&&!r&&!e)return G.randomUUID();e=e||{};const n=e.random||(e.rng||St)();if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,r){t=t||0;for(let i=0;i<16;++i)r[t+i]=n[i];return r}return gt(n)}var M=function(e,r){return M=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])},M(e,r)};function x(e,r){if(typeof r!="function"&&r!==null)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");M(e,r);function t(){this.constructor=e}e.prototype=r===null?Object.create(r):(t.prototype=r.prototype,new t)}function _t(e,r,t,n){function i(o){return o instanceof t?o:new t(function(s){s(o)})}return new(t||(t=Promise))(function(o,s){function u(l){try{c(n.next(l))}catch(v){s(v)}}function a(l){try{c(n.throw(l))}catch(v){s(v)}}function c(l){l.done?o(l.value):i(l.value).then(u,a)}c((n=n.apply(e,r||[])).next())})}function W(e,r){var t={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},n,i,o,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(l){return a([c,l])}}function a(c){if(n)throw new TypeError("Generator is already executing.");for(;s&&(s=0,c[0]&&(t=0)),t;)try{if(n=1,i&&(o=c[0]&2?i.return:c[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,c[1])).done)return o;switch(i=0,o&&(c=[c[0]&2,o.value]),c[0]){case 0:case 1:o=c;break;case 4:return t.label++,{value:c[1],done:!1};case 5:t.label++,i=c[1],c=[0];continue;case 7:c=t.ops.pop(),t.trys.pop();continue;default:if(o=t.trys,!(o=o.length>0&&o[o.length-1])&&(c[0]===6||c[0]===2)){t=0;continue}if(c[0]===3&&(!o||c[1]>o[0]&&c[1]<o[3])){t.label=c[1];break}if(c[0]===6&&t.label<o[1]){t.label=o[1],o=c;break}if(o&&t.label<o[2]){t.label=o[2],t.ops.push(c);break}o[2]&&t.ops.pop(),t.trys.pop();continue}c=r.call(e,t)}catch(l){c=[6,l],i=0}finally{n=o=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}function g(e){var r=typeof Symbol=="function"&&Symbol.iterator,t=r&&e[r],n=0;if(t)return t.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(r?"Object is not iterable.":"Symbol.iterator is not defined.")}function C(e,r){var t=typeof Symbol=="function"&&e[Symbol.iterator];if(!t)return e;var n=t.call(e),i,o=[],s;try{for(;(r===void 0||r-- >0)&&!(i=n.next()).done;)o.push(i.value)}catch(u){s={error:u}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(s)throw s.error}}return o}function k(e,r,t){if(t||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 e.concat(o||Array.prototype.slice.call(r))}function S(e){return this instanceof S?(this.v=e,this):new S(e)}function Pt(e,r,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=t.apply(e,r||[]),i,o=[];return i={},s("next"),s("throw"),s("return"),i[Symbol.asyncIterator]=function(){return this},i;function s(f){n[f]&&(i[f]=function(y){return new Promise(function(_,p){o.push([f,y,_,p])>1||u(f,y)})})}function u(f,y){try{a(n[f](y))}catch(_){v(o[0][3],_)}}function a(f){f.value instanceof S?Promise.resolve(f.value.v).then(c,l):v(o[0][2],f)}function c(f){u("next",f)}function l(f){u("throw",f)}function v(f,y){f(y),o.shift(),o.length&&u(o[0][0],o[0][1])}}function It(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=e[Symbol.asyncIterator],t;return r?r.call(e):(e=typeof g=="function"?g(e):e[Symbol.iterator](),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(o){t[o]=e[o]&&function(s){return new Promise(function(u,a){s=e[o](s),i(u,a,s.done,s.value)})}}function i(o,s,u,a){Promise.resolve(a).then(function(c){o({value:c,done:u})},s)}}function h(e){return typeof e=="function"}function X(e){var r=function(n){Error.call(n),n.stack=new Error().stack},t=e(r);return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}var F=X(function(e){return function(t){e(this),this.message=t?t.length+` errors occurred during unsubscription:
2
2
  `+t.map(function(n,i){return i+1+") "+n.toString()}).join(`
3
- `):"",this.name="UnsubscriptionError",this.errors=t}});function D(e,r){if(e){var t=e.indexOf(r);0<=t&&e.splice(t,1)}}var j=function(){function e(r){this.initialTeardown=r,this.closed=!1,this._parentage=null,this._finalizers=null}return e.prototype.unsubscribe=function(){var r,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){r={error:p}}finally{try{a&&!a.done&&(t=u.return)&&t.call(u)}finally{if(r)throw r.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)}},e.prototype.add=function(r){var t;if(r&&r!==this)if(this.closed)z(r);else{if(r instanceof e){if(r.closed||r._hasParent(this))return;r._addParent(this)}(this._finalizers=(t=this._finalizers)!==null&&t!==void 0?t:[]).push(r)}},e.prototype._hasParent=function(r){var t=this._parentage;return t===r||Array.isArray(t)&&t.includes(r)},e.prototype._addParent=function(r){var t=this._parentage;this._parentage=Array.isArray(t)?(t.push(r),t):t?[t,r]:r},e.prototype._removeParent=function(r){var t=this._parentage;t===r?this._parentage=null:Array.isArray(t)&&D(t,r)},e.prototype.remove=function(r){var t=this._finalizers;t&&D(t,r),r instanceof e&&r._removeParent(this)},e.EMPTY=function(){var r=new e;return r.closed=!0,r}(),e}(),Z=j.EMPTY;function N(e){return e instanceof j||e&&"closed"in e&&h(e.remove)&&h(e.add)&&h(e.unsubscribe)}function z(e){h(e)?e():e.unsubscribe()}var tt={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},Y={setTimeout:function(e,r){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([e,r],C(t))):setTimeout.apply(void 0,k([e,r],C(t)))},clearTimeout:function(e){var r=Y.delegate;return((r==null?void 0:r.clearTimeout)||clearTimeout)(e)},delegate:void 0};function et(e){Y.setTimeout(function(){throw e})}function V(){}function $(e){e()}var B=function(e){x(r,e);function r(t){var n=e.call(this)||this;return n.isStopped=!1,t?(n.destination=t,N(t)&&t.add(n)):n.destination=At,n}return r.create=function(t,n,i){return new q(t,n,i)},r.prototype.next=function(t){this.isStopped||this._next(t)},r.prototype.error=function(t){this.isStopped||(this.isStopped=!0,this._error(t))},r.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},r.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this),this.destination=null)},r.prototype._next=function(t){this.destination.next(t)},r.prototype._error=function(t){try{this.destination.error(t)}finally{this.unsubscribe()}},r.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},r}(j),Ot=Function.prototype.bind;function L(e,r){return Ot.call(e,r)}var Ut=function(){function e(r){this.partialObserver=r}return e.prototype.next=function(r){var t=this.partialObserver;if(t.next)try{t.next(r)}catch(n){A(n)}},e.prototype.error=function(r){var t=this.partialObserver;if(t.error)try{t.error(r)}catch(n){A(n)}else A(r)},e.prototype.complete=function(){var r=this.partialObserver;if(r.complete)try{r.complete()}catch(t){A(t)}},e}(),q=function(e){x(r,e);function r(t,n,i){var o=e.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 r}(B);function A(e){et(e)}function Tt(e){throw e}var At={closed:!0,next:V,error:Tt,complete:V},H=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function $t(e){return e}function Ct(e){return e.length===0?$t:e.length===1?e[0]:function(t){return e.reduce(function(n,i){return i(n)},t)}}var b=function(){function e(r){r&&(this._subscribe=r)}return e.prototype.lift=function(r){var t=new e;return t.source=this,t.operator=r,t},e.prototype.subscribe=function(r,t,n){var i=this,o=jt(r)?r:new q(r,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},e.prototype._trySubscribe=function(r){try{return this._subscribe(r)}catch(t){r.error(t)}},e.prototype.forEach=function(r,t){var n=this;return t=K(t),new t(function(i,o){var s=new q({next:function(u){try{r(u)}catch(a){o(a),s.unsubscribe()}},error:o,complete:i});n.subscribe(s)})},e.prototype._subscribe=function(r){var t;return(t=this.source)===null||t===void 0?void 0:t.subscribe(r)},e.prototype[H]=function(){return this},e.prototype.pipe=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return Ct(r)(this)},e.prototype.toPromise=function(r){var t=this;return r=K(r),new r(function(n,i){var o;t.subscribe(function(s){return o=s},function(s){return i(s)},function(){return n(o)})})},e.create=function(r){return new e(r)},e}();function K(e){var r;return(r=e??tt.Promise)!==null&&r!==void 0?r:Promise}function kt(e){return e&&h(e.next)&&h(e.error)&&h(e.complete)}function jt(e){return e&&e instanceof B||kt(e)&&N(e)}function Rt(e){return h(e==null?void 0:e.lift)}function I(e){return function(r){if(Rt(r))return r.lift(function(t){try{return e(t,this)}catch(n){this.error(n)}});throw new TypeError("Unable to lift unknown Observable type")}}function P(e,r,t,n,i){return new Ft(e,r,t,n,i)}var Ft=function(e){x(r,e);function r(t,n,i,o,s,u){var a=e.call(this,t)||this;return a.onFinalize=s,a.shouldUnsubscribe=u,a._next=n?function(c){try{n(c)}catch(l){t.error(l)}}:e.prototype._next,a._error=o?function(c){try{o(c)}catch(l){t.error(l)}finally{this.unsubscribe()}}:e.prototype._error,a._complete=i?function(){try{i()}catch(c){t.error(c)}finally{this.unsubscribe()}}:e.prototype._complete,a}return r.prototype.unsubscribe=function(){var t;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var n=this.closed;e.prototype.unsubscribe.call(this),!n&&((t=this.onFinalize)===null||t===void 0||t.call(this))}},r}(B),Lt=X(function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),m=function(e){x(r,e);function r(){var t=e.call(this)||this;return t.closed=!1,t.currentObservers=null,t.observers=[],t.isStopped=!1,t.hasError=!1,t.thrownError=null,t}return r.prototype.lift=function(t){var n=new J(this,this);return n.operator=t,n},r.prototype._throwIfClosed=function(){if(this.closed)throw new Lt},r.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}}}})},r.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)}})},r.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()}})},r.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(r.prototype,"observed",{get:function(){var t;return((t=this.observers)===null||t===void 0?void 0:t.length)>0},enumerable:!1,configurable:!0}),r.prototype._trySubscribe=function(t){return this._throwIfClosed(),e.prototype._trySubscribe.call(this,t)},r.prototype._subscribe=function(t){return this._throwIfClosed(),this._checkFinalizedStatuses(t),this._innerSubscribe(t)},r.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)}))},r.prototype._checkFinalizedStatuses=function(t){var n=this,i=n.hasError,o=n.thrownError,s=n.isStopped;i?t.error(o):s&&t.complete()},r.prototype.asObservable=function(){var t=new b;return t.source=this,t},r.create=function(t,n){return new J(t,n)},r}(b),J=function(e){x(r,e);function r(t,n){var i=e.call(this)||this;return i.destination=t,i.source=n,i}return r.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)},r.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)},r.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)},r.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},r}(m),rt=function(e){x(r,e);function r(t){var n=e.call(this)||this;return n._value=t,n}return Object.defineProperty(r.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),r.prototype._subscribe=function(t){var n=e.prototype._subscribe.call(this,t);return!n.closed&&t.next(this._value),n},r.prototype.getValue=function(){var t=this,n=t.hasError,i=t.thrownError,o=t._value;if(n)throw i;return this._throwIfClosed(),o},r.prototype.next=function(t){e.prototype.next.call(this,this._value=t)},r}(m),Mt=new b(function(e){return e.complete()});function Dt(e){return e&&h(e.schedule)}function Yt(e){return e[e.length-1]}function Vt(e){return Dt(Yt(e))?e.pop():void 0}var nt=function(e){return e&&typeof e.length=="number"&&typeof e!="function"};function it(e){return h(e==null?void 0:e.then)}function ot(e){return h(e[H])}function st(e){return Symbol.asyncIterator&&h(e==null?void 0:e[Symbol.asyncIterator])}function ut(e){return new TypeError("You provided "+(e!==null&&typeof e=="object"?"an invalid object":"'"+e+"'")+" 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(e){return h(e==null?void 0:e[ct])}function lt(e){return Pt(this,arguments,function(){var t,n,i,o;return W(this,function(s){switch(s.label){case 0:t=e.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(e){return h(e==null?void 0:e.getReader)}function O(e){if(e instanceof b)return e;if(e!=null){if(ot(e))return Bt(e);if(nt(e))return Ht(e);if(it(e))return Gt(e);if(st(e))return ht(e);if(at(e))return zt(e);if(ft(e))return Kt(e)}throw ut(e)}function Bt(e){return new b(function(r){var t=e[H]();if(h(t.subscribe))return t.subscribe(r);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function Ht(e){return new b(function(r){for(var t=0;t<e.length&&!r.closed;t++)r.next(e[t]);r.complete()})}function Gt(e){return new b(function(r){e.then(function(t){r.closed||(r.next(t),r.complete())},function(t){return r.error(t)}).then(null,et)})}function zt(e){return new b(function(r){var t,n;try{for(var i=g(e),o=i.next();!o.done;o=i.next()){var s=o.value;if(r.next(s),r.closed)return}}catch(u){t={error:u}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}r.complete()})}function ht(e){return new b(function(r){Jt(e,r).catch(function(t){return r.error(t)})})}function Kt(e){return ht(lt(e))}function Jt(e,r){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(e),a.label=1;case 1:return[4,t.next()];case 2:if(n=a.sent(),!!n.done)return[3,4];if(s=n.value,r.next(s),r.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 r.complete(),[2]}})})}function w(e,r,t,n,i){n===void 0&&(n=0),i===void 0&&(i=!1);var o=r.schedule(function(){t(),i?e.add(this.schedule(null,n)):this.unsubscribe()},n);if(e.add(o),!i)return o}function dt(e,r){return r===void 0&&(r=0),I(function(t,n){t.subscribe(P(n,function(i){return w(n,e,function(){return n.next(i)},r)},function(){return w(n,e,function(){return n.complete()},r)},function(i){return w(n,e,function(){return n.error(i)},r)}))})}function pt(e,r){return r===void 0&&(r=0),I(function(t,n){n.add(e.schedule(function(){return t.subscribe(n)},r))})}function Qt(e,r){return O(e).pipe(pt(r),dt(r))}function Wt(e,r){return O(e).pipe(pt(r),dt(r))}function Xt(e,r){return new b(function(t){var n=0;return r.schedule(function(){n===e.length?t.complete():(t.next(e[n++]),t.closed||this.schedule())})})}function Zt(e,r){return new b(function(t){var n;return w(t,r,function(){n=e[ct](),w(t,r,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(e,r){if(!e)throw new Error("Iterable cannot be null");return new b(function(t){w(t,r,function(){var n=e[Symbol.asyncIterator]();w(t,r,function(){n.next().then(function(i){i.done?t.complete():t.next(i.value)})},0,!0)})})}function Nt(e,r){return vt(lt(e),r)}function te(e,r){if(e!=null){if(ot(e))return Qt(e,r);if(nt(e))return Xt(e,r);if(it(e))return Wt(e,r);if(st(e))return vt(e,r);if(at(e))return Zt(e,r);if(ft(e))return Nt(e,r)}throw ut(e)}function ee(e,r){return r?te(e,r):O(e)}function re(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];var t=Vt(e);return ee(e,t)}function Q(e){return e<=0?function(){return Mt}:I(function(r,t){var n=0;r.subscribe(P(t,function(i){++n<=e&&(t.next(i),e<=n&&t.complete())}))})}function ne(e,r){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(e(a,l)).subscribe(i=P(n,function(v){return n.next(r?r(a,v,l,c++):v)},function(){i=null,u()}))},function(){s=!0,u()}))})}function ie(e){return I(function(r,t){O(e).subscribe(P(t,function(){return t.complete()},V)),!t.closed&&r.subscribe(t)})}class yt{constructor(r,t,n){this.id=r,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(r){this.addEntryRemoveHandler(r),this.entries$.pipe(Q(1)).subscribe(t=>{this.entries$.next([...t,r])})}entries(){return this.entries$.asObservable()}setProvider(r){this.provider=r,this.provider.actions().pipe(ie(this.kill$)).subscribe(t=>{this.write(t)}),this.provider.connect()}handover(r){const t=this.platform.registeredProviders.get(r);if(t){this.provider&&this.queue.unshift(this.provider),this.kill$.next();const n=t(this);this.setProvider(n)}}addEntryRemoveHandler(r){r.remove$.pipe(ne(()=>this.entries$),Q(1)).subscribe(t=>{this.entries$.next(t.filter(n=>n!==r))})}completeProvider(){const[r]=this.queue;r&&this.setProvider(r)}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(r){let t=await r.get("conversation");return t||(t=new R,await r.register("conversation",t),t)}registerProvider(r,t){this.registeredProviders.set(r,t)}createSession(r){const t=new yt(Et(),r,this),n=this.getProviderByConfiguration(r);if(n){const i=n(t);t.setProvider(i)}return this.sessions.set(t.id,t),this.activeSessionId=t.id,t}getProviderByConfiguration(r){const[t]=r.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 e=>{e.registerComponent("conversation",Promise.resolve().then(()=>require("./conversation-e8aa867e.js"))),await R.getInstance(e.container)};var E=(e=>(e.User="user",e.Agent="agent",e.System="system",e))(E||{});class U{constructor(r,t,n){this.type=r,this.sender=t,this.messages=n,this.didUpdate=new m,this.actions$=new m,this.remove$=new m,this.timestamp=Date.now()}update(r){this.messages=[{items:r}],this.didUpdate.next(this)}remove(){this.remove$.next()}}class bt{constructor(r){this.name=r,this.print$=new m}print(r){const t=new U(E.Agent,{name:this.name},[{items:[["html",{content:r}]]}]);return this.print$.next(t),t}subscribe(){return this.print$.asObservable()}}class mt{constructor(r){this.name=r,this.print$=new m}print(r){const t=new U(E.User,{name:this.name},[{items:[["html",{content:r}]]}]);return this.print$.next(t),t}subscribe(){return this.print$.asObservable()}}class se{constructor(){this.print$=new m,this.name="system"}print(r){const t=new U(E.System,{name:this.name},[{items:[["html",{content:r}]]}]);return this.print$.next(t),t}subscribe(){return this.print$.asObservable()}}class ue{constructor(r,t){this.name=r,this.session=t,this.print$=new m,this.typingState$=new rt(!1),this.system=this.createSystem()}connect(){}onUserSubmit(r){this.print(E.User,r.text)}print(r,t){const n=new U(r,{name:""},[{items:[["html",{content:t}]]}]);return this.printEntry(n)}printEntry(r){return this.print$.next(r),r}createAgent(r){const t=new bt(r);return t.subscribe().subscribe(n=>{this.playNotification(),this.printEntry(n)}),t}createUser(r){const t=new mt(r);return t.subscribe().subscribe(n=>{this.printEntry(n)}),t}createSystem(){const r=new se;return r.subscribe().subscribe(t=>{this.printEntry(t)}),r}setTypingState(r){this.typingState$.next(r)}setToastMessage(r){this.session.component.setToastMessage(r)}isTyping(){return this.typingState$.asObservable()}actions(){return this.print$.asObservable()}complete(){this.session.completeProvider()}playNotification(){const r="https://publicpoc.blob.core.windows.net/widget-assets/notification.mp3";this.session.component.application.branding().other.disableSound||new Audio(r).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;
3
+ `):"",this.name="UnsubscriptionError",this.errors=t}});function D(e,r){if(e){var t=e.indexOf(r);0<=t&&e.splice(t,1)}}var j=function(){function e(r){this.initialTeardown=r,this.closed=!1,this._parentage=null,this._finalizers=null}return e.prototype.unsubscribe=function(){var r,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){r={error:p}}finally{try{a&&!a.done&&(t=u.return)&&t.call(u)}finally{if(r)throw r.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)}},e.prototype.add=function(r){var t;if(r&&r!==this)if(this.closed)z(r);else{if(r instanceof e){if(r.closed||r._hasParent(this))return;r._addParent(this)}(this._finalizers=(t=this._finalizers)!==null&&t!==void 0?t:[]).push(r)}},e.prototype._hasParent=function(r){var t=this._parentage;return t===r||Array.isArray(t)&&t.includes(r)},e.prototype._addParent=function(r){var t=this._parentage;this._parentage=Array.isArray(t)?(t.push(r),t):t?[t,r]:r},e.prototype._removeParent=function(r){var t=this._parentage;t===r?this._parentage=null:Array.isArray(t)&&D(t,r)},e.prototype.remove=function(r){var t=this._finalizers;t&&D(t,r),r instanceof e&&r._removeParent(this)},e.EMPTY=function(){var r=new e;return r.closed=!0,r}(),e}(),Z=j.EMPTY;function N(e){return e instanceof j||e&&"closed"in e&&h(e.remove)&&h(e.add)&&h(e.unsubscribe)}function z(e){h(e)?e():e.unsubscribe()}var tt={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},Y={setTimeout:function(e,r){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([e,r],C(t))):setTimeout.apply(void 0,k([e,r],C(t)))},clearTimeout:function(e){var r=Y.delegate;return((r==null?void 0:r.clearTimeout)||clearTimeout)(e)},delegate:void 0};function et(e){Y.setTimeout(function(){throw e})}function V(){}function $(e){e()}var B=function(e){x(r,e);function r(t){var n=e.call(this)||this;return n.isStopped=!1,t?(n.destination=t,N(t)&&t.add(n)):n.destination=At,n}return r.create=function(t,n,i){return new q(t,n,i)},r.prototype.next=function(t){this.isStopped||this._next(t)},r.prototype.error=function(t){this.isStopped||(this.isStopped=!0,this._error(t))},r.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},r.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this),this.destination=null)},r.prototype._next=function(t){this.destination.next(t)},r.prototype._error=function(t){try{this.destination.error(t)}finally{this.unsubscribe()}},r.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},r}(j),Ot=Function.prototype.bind;function L(e,r){return Ot.call(e,r)}var Ut=function(){function e(r){this.partialObserver=r}return e.prototype.next=function(r){var t=this.partialObserver;if(t.next)try{t.next(r)}catch(n){A(n)}},e.prototype.error=function(r){var t=this.partialObserver;if(t.error)try{t.error(r)}catch(n){A(n)}else A(r)},e.prototype.complete=function(){var r=this.partialObserver;if(r.complete)try{r.complete()}catch(t){A(t)}},e}(),q=function(e){x(r,e);function r(t,n,i){var o=e.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 r}(B);function A(e){et(e)}function Tt(e){throw e}var At={closed:!0,next:V,error:Tt,complete:V},H=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function $t(e){return e}function Ct(e){return e.length===0?$t:e.length===1?e[0]:function(t){return e.reduce(function(n,i){return i(n)},t)}}var b=function(){function e(r){r&&(this._subscribe=r)}return e.prototype.lift=function(r){var t=new e;return t.source=this,t.operator=r,t},e.prototype.subscribe=function(r,t,n){var i=this,o=jt(r)?r:new q(r,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},e.prototype._trySubscribe=function(r){try{return this._subscribe(r)}catch(t){r.error(t)}},e.prototype.forEach=function(r,t){var n=this;return t=K(t),new t(function(i,o){var s=new q({next:function(u){try{r(u)}catch(a){o(a),s.unsubscribe()}},error:o,complete:i});n.subscribe(s)})},e.prototype._subscribe=function(r){var t;return(t=this.source)===null||t===void 0?void 0:t.subscribe(r)},e.prototype[H]=function(){return this},e.prototype.pipe=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return Ct(r)(this)},e.prototype.toPromise=function(r){var t=this;return r=K(r),new r(function(n,i){var o;t.subscribe(function(s){return o=s},function(s){return i(s)},function(){return n(o)})})},e.create=function(r){return new e(r)},e}();function K(e){var r;return(r=e??tt.Promise)!==null&&r!==void 0?r:Promise}function kt(e){return e&&h(e.next)&&h(e.error)&&h(e.complete)}function jt(e){return e&&e instanceof B||kt(e)&&N(e)}function Rt(e){return h(e==null?void 0:e.lift)}function I(e){return function(r){if(Rt(r))return r.lift(function(t){try{return e(t,this)}catch(n){this.error(n)}});throw new TypeError("Unable to lift unknown Observable type")}}function P(e,r,t,n,i){return new Ft(e,r,t,n,i)}var Ft=function(e){x(r,e);function r(t,n,i,o,s,u){var a=e.call(this,t)||this;return a.onFinalize=s,a.shouldUnsubscribe=u,a._next=n?function(c){try{n(c)}catch(l){t.error(l)}}:e.prototype._next,a._error=o?function(c){try{o(c)}catch(l){t.error(l)}finally{this.unsubscribe()}}:e.prototype._error,a._complete=i?function(){try{i()}catch(c){t.error(c)}finally{this.unsubscribe()}}:e.prototype._complete,a}return r.prototype.unsubscribe=function(){var t;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var n=this.closed;e.prototype.unsubscribe.call(this),!n&&((t=this.onFinalize)===null||t===void 0||t.call(this))}},r}(B),Lt=X(function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),m=function(e){x(r,e);function r(){var t=e.call(this)||this;return t.closed=!1,t.currentObservers=null,t.observers=[],t.isStopped=!1,t.hasError=!1,t.thrownError=null,t}return r.prototype.lift=function(t){var n=new J(this,this);return n.operator=t,n},r.prototype._throwIfClosed=function(){if(this.closed)throw new Lt},r.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}}}})},r.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)}})},r.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()}})},r.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(r.prototype,"observed",{get:function(){var t;return((t=this.observers)===null||t===void 0?void 0:t.length)>0},enumerable:!1,configurable:!0}),r.prototype._trySubscribe=function(t){return this._throwIfClosed(),e.prototype._trySubscribe.call(this,t)},r.prototype._subscribe=function(t){return this._throwIfClosed(),this._checkFinalizedStatuses(t),this._innerSubscribe(t)},r.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)}))},r.prototype._checkFinalizedStatuses=function(t){var n=this,i=n.hasError,o=n.thrownError,s=n.isStopped;i?t.error(o):s&&t.complete()},r.prototype.asObservable=function(){var t=new b;return t.source=this,t},r.create=function(t,n){return new J(t,n)},r}(b),J=function(e){x(r,e);function r(t,n){var i=e.call(this)||this;return i.destination=t,i.source=n,i}return r.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)},r.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)},r.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)},r.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},r}(m),rt=function(e){x(r,e);function r(t){var n=e.call(this)||this;return n._value=t,n}return Object.defineProperty(r.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),r.prototype._subscribe=function(t){var n=e.prototype._subscribe.call(this,t);return!n.closed&&t.next(this._value),n},r.prototype.getValue=function(){var t=this,n=t.hasError,i=t.thrownError,o=t._value;if(n)throw i;return this._throwIfClosed(),o},r.prototype.next=function(t){e.prototype.next.call(this,this._value=t)},r}(m),Mt=new b(function(e){return e.complete()});function Dt(e){return e&&h(e.schedule)}function Yt(e){return e[e.length-1]}function Vt(e){return Dt(Yt(e))?e.pop():void 0}var nt=function(e){return e&&typeof e.length=="number"&&typeof e!="function"};function it(e){return h(e==null?void 0:e.then)}function ot(e){return h(e[H])}function st(e){return Symbol.asyncIterator&&h(e==null?void 0:e[Symbol.asyncIterator])}function ut(e){return new TypeError("You provided "+(e!==null&&typeof e=="object"?"an invalid object":"'"+e+"'")+" 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(e){return h(e==null?void 0:e[ct])}function lt(e){return Pt(this,arguments,function(){var t,n,i,o;return W(this,function(s){switch(s.label){case 0:t=e.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(e){return h(e==null?void 0:e.getReader)}function O(e){if(e instanceof b)return e;if(e!=null){if(ot(e))return Bt(e);if(nt(e))return Ht(e);if(it(e))return Gt(e);if(st(e))return ht(e);if(at(e))return zt(e);if(ft(e))return Kt(e)}throw ut(e)}function Bt(e){return new b(function(r){var t=e[H]();if(h(t.subscribe))return t.subscribe(r);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function Ht(e){return new b(function(r){for(var t=0;t<e.length&&!r.closed;t++)r.next(e[t]);r.complete()})}function Gt(e){return new b(function(r){e.then(function(t){r.closed||(r.next(t),r.complete())},function(t){return r.error(t)}).then(null,et)})}function zt(e){return new b(function(r){var t,n;try{for(var i=g(e),o=i.next();!o.done;o=i.next()){var s=o.value;if(r.next(s),r.closed)return}}catch(u){t={error:u}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}r.complete()})}function ht(e){return new b(function(r){Jt(e,r).catch(function(t){return r.error(t)})})}function Kt(e){return ht(lt(e))}function Jt(e,r){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(e),a.label=1;case 1:return[4,t.next()];case 2:if(n=a.sent(),!!n.done)return[3,4];if(s=n.value,r.next(s),r.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 r.complete(),[2]}})})}function w(e,r,t,n,i){n===void 0&&(n=0),i===void 0&&(i=!1);var o=r.schedule(function(){t(),i?e.add(this.schedule(null,n)):this.unsubscribe()},n);if(e.add(o),!i)return o}function dt(e,r){return r===void 0&&(r=0),I(function(t,n){t.subscribe(P(n,function(i){return w(n,e,function(){return n.next(i)},r)},function(){return w(n,e,function(){return n.complete()},r)},function(i){return w(n,e,function(){return n.error(i)},r)}))})}function pt(e,r){return r===void 0&&(r=0),I(function(t,n){n.add(e.schedule(function(){return t.subscribe(n)},r))})}function Qt(e,r){return O(e).pipe(pt(r),dt(r))}function Wt(e,r){return O(e).pipe(pt(r),dt(r))}function Xt(e,r){return new b(function(t){var n=0;return r.schedule(function(){n===e.length?t.complete():(t.next(e[n++]),t.closed||this.schedule())})})}function Zt(e,r){return new b(function(t){var n;return w(t,r,function(){n=e[ct](),w(t,r,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(e,r){if(!e)throw new Error("Iterable cannot be null");return new b(function(t){w(t,r,function(){var n=e[Symbol.asyncIterator]();w(t,r,function(){n.next().then(function(i){i.done?t.complete():t.next(i.value)})},0,!0)})})}function Nt(e,r){return vt(lt(e),r)}function te(e,r){if(e!=null){if(ot(e))return Qt(e,r);if(nt(e))return Xt(e,r);if(it(e))return Wt(e,r);if(st(e))return vt(e,r);if(at(e))return Zt(e,r);if(ft(e))return Nt(e,r)}throw ut(e)}function ee(e,r){return r?te(e,r):O(e)}function re(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];var t=Vt(e);return ee(e,t)}function Q(e){return e<=0?function(){return Mt}:I(function(r,t){var n=0;r.subscribe(P(t,function(i){++n<=e&&(t.next(i),e<=n&&t.complete())}))})}function ne(e,r){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(e(a,l)).subscribe(i=P(n,function(v){return n.next(r?r(a,v,l,c++):v)},function(){i=null,u()}))},function(){s=!0,u()}))})}function ie(e){return I(function(r,t){O(e).subscribe(P(t,function(){return t.complete()},V)),!t.closed&&r.subscribe(t)})}class yt{constructor(r,t,n){this.id=r,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(r){this.addEntryRemoveHandler(r),this.entries$.pipe(Q(1)).subscribe(t=>{this.entries$.next([...t,r])})}entries(){return this.entries$.asObservable()}setProvider(r){this.provider=r,this.provider.actions().pipe(ie(this.kill$)).subscribe(t=>{this.write(t)}),this.provider.connect()}handover(r){const t=this.platform.registeredProviders.get(r);if(t){this.provider&&this.queue.unshift(this.provider),this.kill$.next();const n=t(this);this.setProvider(n)}}addEntryRemoveHandler(r){r.remove$.pipe(ne(()=>this.entries$),Q(1)).subscribe(t=>{this.entries$.next(t.filter(n=>n!==r))})}completeProvider(){const[r]=this.queue;r&&this.setProvider(r)}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(r){let t=await r.get("conversation");return t||(t=new R,await r.register("conversation",t),t)}registerProvider(r,t){this.registeredProviders.set(r,t)}createSession(r){const t=new yt(Et(),r,this),n=this.getProviderByConfiguration(r);if(n){const i=n(t);t.setProvider(i)}return this.sessions.set(t.id,t),this.activeSessionId=t.id,t}getProviderByConfiguration(r){const[t]=r.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 e=>{e.registerComponent("conversation",Promise.resolve().then(()=>require("./conversation-ee9f472e.js"))),await R.getInstance(e.container)};var E=(e=>(e.User="user",e.Agent="agent",e.System="system",e))(E||{});class U{constructor(r,t,n){this.type=r,this.sender=t,this.messages=n,this.didUpdate=new m,this.actions$=new m,this.remove$=new m,this.timestamp=Date.now()}update(r){this.messages=[{items:r}],this.didUpdate.next(this)}remove(){this.remove$.next()}}class bt{constructor(r){this.name=r,this.print$=new m}print(r){const t=new U(E.Agent,{name:this.name},[{items:[["html",{content:r}]]}]);return this.print$.next(t),t}subscribe(){return this.print$.asObservable()}}class mt{constructor(r){this.name=r,this.print$=new m}print(r){const t=new U(E.User,{name:this.name},[{items:[["html",{content:r}]]}]);return this.print$.next(t),t}subscribe(){return this.print$.asObservable()}}class se{constructor(){this.print$=new m,this.name="system"}print(r){const t=new U(E.System,{name:this.name},[{items:[["html",{content:r}]]}]);return this.print$.next(t),t}subscribe(){return this.print$.asObservable()}}class ue{constructor(r,t){this.name=r,this.session=t,this.print$=new m,this.typingState$=new rt(!1),this.system=this.createSystem()}connect(){}onUserSubmit(r){this.print(E.User,r.text)}print(r,t){const n=new U(r,{name:""},[{items:[["html",{content:t}]]}]);return this.printEntry(n)}printEntry(r){return this.print$.next(r),r}createAgent(r){const t=new bt(r);return t.subscribe().subscribe(n=>{this.playNotification(),this.printEntry(n)}),t}createUser(r){const t=new mt(r);return t.subscribe().subscribe(n=>{this.printEntry(n)}),t}createSystem(){const r=new se;return r.subscribe().subscribe(t=>{this.printEntry(t)}),r}setTypingState(r){this.typingState$.next(r)}setToastMessage(r){this.session.component.setToastMessage(r)}isTyping(){return this.typingState$.asObservable()}actions(){return this.print$.asObservable()}complete(){this.session.completeProvider()}playNotification(){const r="https://publicpoc.blob.core.windows.net/widget-assets/notification.mp3";this.session.component.application.branding().other.disableSound||new Audio(r).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;
package/index.mjs CHANGED
@@ -1151,7 +1151,7 @@ class H {
1151
1151
  }
1152
1152
  }
1153
1153
  const se = async (e) => {
1154
- e.registerComponent("conversation", import("./conversation-29bea177.mjs")), await H.getInstance(e.container);
1154
+ e.registerComponent("conversation", import("./conversation-b17a1b13.mjs")), await H.getInstance(e.container);
1155
1155
  };
1156
1156
  var O = /* @__PURE__ */ ((e) => (e.User = "user", e.Agent = "agent", e.System = "system", e))(O || {});
1157
1157
  class C {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@telia-ace/widget-conversation-flamingo",
3
- "version": "1.1.38-rc.1",
3
+ "version": "1.1.38-rc.2",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org"
6
6
  },
@@ -9,7 +9,7 @@
9
9
  "@lit-labs/motion": "^1.0.4",
10
10
  "@teliads/icons": "^8.4.0",
11
11
  "@teliads/components": "^22.1.1",
12
- "@telia-ace/widget-core-flamingo": "1.1.38-rc.1",
12
+ "@telia-ace/widget-core-flamingo": "1.1.38-rc.2",
13
13
  "uuid": "^9.0.1",
14
14
  "lit-html": "^3.0.2",
15
15
  "rxjs": "^7.8.1"