@telia-ace/widget-conversation-flamingo 1.1.72-rc.0 → 1.1.72-rc.2
Sign up to get free protection for your applications and to get access to all the features.
- package/index.js +23 -8
- package/index.mjs +31 -12
- package/models/agent.d.ts +1 -1
- package/package.json +2 -2
package/index.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";var Ai=Object.defineProperty;var Ei=(s,e,t)=>e in s?Ai(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var x=(s,e,t)=>(Ei(s,typeof e!="symbol"?e+"":e,t),t),Ti=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)};var $t=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t)};var De=(s,e,t)=>(Ti(s,e,"access private method"),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Li=async s=>{s.registerComponent("conversation",Promise.resolve().then(()=>Rl))};class Zt{constructor(){this.registeredProviders=new Map}static async getInstance(e){let t=await e.get("conversation");return t||(t=new Zt,await e.register("conversation",t),t)}registerProvider(e,t){this.registeredProviders.set(e,t)}}var Lt=function(s,e){return Lt=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])},Lt(s,e)};function be(s,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");Lt(s,e);function t(){this.constructor=s}s.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}function Oi(s,e,t,n){function i(r){return r instanceof t?r:new t(function(o){o(r)})}return new(t||(t=Promise))(function(r,o){function a(h){try{c(n.next(h))}catch(u){o(u)}}function l(h){try{c(n.throw(h))}catch(u){o(u)}}function c(h){h.done?r(h.value):i(h.value).then(a,l)}c((n=n.apply(s,e||[])).next())})}function fs(s,e){var t={label:0,sent:function(){if(r[0]&1)throw r[1];return r[1]},trys:[],ops:[]},n,i,r,o;return o={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(c){return function(h){return l([c,h])}}function l(c){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,c[0]&&(t=0)),t;)try{if(n=1,i&&(r=c[0]&2?i.return:c[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,c[1])).done)return r;switch(i=0,r&&(c=[c[0]&2,r.value]),c[0]){case 0:case 1:r=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(r=t.trys,!(r=r.length>0&&r[r.length-1])&&(c[0]===6||c[0]===2)){t=0;continue}if(c[0]===3&&(!r||c[1]>r[0]&&c[1]<r[3])){t.label=c[1];break}if(c[0]===6&&t.label<r[1]){t.label=r[1],r=c;break}if(r&&t.label<r[2]){t.label=r[2],t.ops.push(c);break}r[2]&&t.ops.pop(),t.trys.pop();continue}c=e.call(s,t)}catch(h){c=[6,h],i=0}finally{n=r=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}function ge(s){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&s[e],n=0;if(t)return t.call(s);if(s&&typeof s.length=="number")return{next:function(){return s&&n>=s.length&&(s=void 0),{value:s&&s[n++],done:!s}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function Y(s,e){var t=typeof Symbol=="function"&&s[Symbol.iterator];if(!t)return s;var n=t.call(s),i,r=[],o;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)r.push(i.value)}catch(a){o={error:a}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(o)throw o.error}}return r}function ne(s,e,t){if(t||arguments.length===2)for(var n=0,i=e.length,r;n<i;n++)(r||!(n in e))&&(r||(r=Array.prototype.slice.call(e,0,n)),r[n]=e[n]);return s.concat(r||Array.prototype.slice.call(e))}function ue(s){return this instanceof ue?(this.v=s,this):new ue(s)}function Pi(s,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=t.apply(s,e||[]),i,r=[];return i={},o("next"),o("throw"),o("return"),i[Symbol.asyncIterator]=function(){return this},i;function o(p){n[p]&&(i[p]=function(d){return new Promise(function(b,f){r.push([p,d,b,f])>1||a(p,d)})})}function a(p,d){try{l(n[p](d))}catch(b){u(r[0][3],b)}}function l(p){p.value instanceof ue?Promise.resolve(p.value.v).then(c,h):u(r[0][2],p)}function c(p){a("next",p)}function h(p){a("throw",p)}function u(p,d){p(d),r.shift(),r.length&&a(r[0][0],r[0][1])}}function Ri(s){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=s[Symbol.asyncIterator],t;return e?e.call(s):(s=typeof ge=="function"?ge(s):s[Symbol.iterator](),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(r){t[r]=s[r]&&function(o){return new Promise(function(a,l){o=s[r](o),i(a,l,o.done,o.value)})}}function i(r,o,a,l){Promise.resolve(l).then(function(c){r({value:c,done:a})},o)}}function $(s){return typeof s=="function"}function gs(s){var e=function(n){Error.call(n),n.stack=new Error().stack},t=s(e);return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}var xt=gs(function(s){return function(t){s(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 Ot(s,e){if(s){var t=s.indexOf(e);0<=t&&s.splice(t,1)}}var lt=function(){function s(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}return s.prototype.unsubscribe=function(){var e,t,n,i,r;if(!this.closed){this.closed=!0;var o=this._parentage;if(o)if(this._parentage=null,Array.isArray(o))try{for(var a=ge(o),l=a.next();!l.done;l=a.next()){var c=l.value;c.remove(this)}}catch(f){e={error:f}}finally{try{l&&!l.done&&(t=a.return)&&t.call(a)}finally{if(e)throw e.error}}else o.remove(this);var h=this.initialTeardown;if($(h))try{h()}catch(f){r=f instanceof xt?f.errors:[f]}var u=this._finalizers;if(u){this._finalizers=null;try{for(var p=ge(u),d=p.next();!d.done;d=p.next()){var b=d.value;try{_n(b)}catch(f){r=r??[],f instanceof xt?r=ne(ne([],Y(r)),Y(f.errors)):r.push(f)}}}catch(f){n={error:f}}finally{try{d&&!d.done&&(i=p.return)&&i.call(p)}finally{if(n)throw n.error}}}if(r)throw new xt(r)}},s.prototype.add=function(e){var t;if(e&&e!==this)if(this.closed)_n(e);else{if(e instanceof s){if(e.closed||e._hasParent(this))return;e._addParent(this)}(this._finalizers=(t=this._finalizers)!==null&&t!==void 0?t:[]).push(e)}},s.prototype._hasParent=function(e){var t=this._parentage;return t===e||Array.isArray(t)&&t.includes(e)},s.prototype._addParent=function(e){var t=this._parentage;this._parentage=Array.isArray(t)?(t.push(e),t):t?[t,e]:e},s.prototype._removeParent=function(e){var t=this._parentage;t===e?this._parentage=null:Array.isArray(t)&&Ot(t,e)},s.prototype.remove=function(e){var t=this._finalizers;t&&Ot(t,e),e instanceof s&&e._removeParent(this)},s.EMPTY=function(){var e=new s;return e.closed=!0,e}(),s}(),ms=lt.EMPTY;function vs(s){return s instanceof lt||s&&"closed"in s&&$(s.remove)&&$(s.add)&&$(s.unsubscribe)}function _n(s){$(s)?s():s.unsubscribe()}var bs={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},Pt={setTimeout:function(s,e){for(var t=[],n=2;n<arguments.length;n++)t[n-2]=arguments[n];var i=Pt.delegate;return i!=null&&i.setTimeout?i.setTimeout.apply(i,ne([s,e],Y(t))):setTimeout.apply(void 0,ne([s,e],Y(t)))},clearTimeout:function(s){var e=Pt.delegate;return((e==null?void 0:e.clearTimeout)||clearTimeout)(s)},delegate:void 0};function ys(s){Pt.setTimeout(function(){throw s})}function Qe(){}function We(s){s()}var Wt=function(s){be(e,s);function e(t){var n=s.call(this)||this;return n.isStopped=!1,t?(n.destination=t,vs(t)&&t.add(n)):n.destination=Ui,n}return e.create=function(t,n,i){return new Rt(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,s.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}(lt),Ii=Function.prototype.bind;function wt(s,e){return Ii.call(s,e)}var Mi=function(){function s(e){this.partialObserver=e}return s.prototype.next=function(e){var t=this.partialObserver;if(t.next)try{t.next(e)}catch(n){Be(n)}},s.prototype.error=function(e){var t=this.partialObserver;if(t.error)try{t.error(e)}catch(n){Be(n)}else Be(e)},s.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(t){Be(t)}},s}(),Rt=function(s){be(e,s);function e(t,n,i){var r=s.call(this)||this,o;if($(t)||!t)o={next:t??void 0,error:n??void 0,complete:i??void 0};else{var a;r&&bs.useDeprecatedNextContext?(a=Object.create(t),a.unsubscribe=function(){return r.unsubscribe()},o={next:t.next&&wt(t.next,a),error:t.error&&wt(t.error,a),complete:t.complete&&wt(t.complete,a)}):o=t}return r.destination=new Mi(o),r}return e}(Wt);function Be(s){ys(s)}function zi(s){throw s}var Ui={closed:!0,next:Qe,error:zi,complete:Qe},Yt=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function Oe(s){return s}function ji(s){return s.length===0?Oe:s.length===1?s[0]:function(t){return s.reduce(function(n,i){return i(n)},t)}}var A=function(){function s(e){e&&(this._subscribe=e)}return s.prototype.lift=function(e){var t=new s;return t.source=this,t.operator=e,t},s.prototype.subscribe=function(e,t,n){var i=this,r=Di(e)?e:new Rt(e,t,n);return We(function(){var o=i,a=o.operator,l=o.source;r.add(a?a.call(r,l):l?i._subscribe(r):i._trySubscribe(r))}),r},s.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(t){e.error(t)}},s.prototype.forEach=function(e,t){var n=this;return t=Sn(t),new t(function(i,r){var o=new Rt({next:function(a){try{e(a)}catch(l){r(l),o.unsubscribe()}},error:r,complete:i});n.subscribe(o)})},s.prototype._subscribe=function(e){var t;return(t=this.source)===null||t===void 0?void 0:t.subscribe(e)},s.prototype[Yt]=function(){return this},s.prototype.pipe=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return ji(e)(this)},s.prototype.toPromise=function(e){var t=this;return e=Sn(e),new e(function(n,i){var r;t.subscribe(function(o){return r=o},function(o){return i(o)},function(){return n(r)})})},s.create=function(e){return new s(e)},s}();function Sn(s){var e;return(e=s??bs.Promise)!==null&&e!==void 0?e:Promise}function Hi(s){return s&&$(s.next)&&$(s.error)&&$(s.complete)}function Di(s){return s&&s instanceof Wt||Hi(s)&&vs(s)}function Bi(s){return $(s==null?void 0:s.lift)}function K(s){return function(e){if(Bi(e))return e.lift(function(t){try{return s(t,this)}catch(n){this.error(n)}});throw new TypeError("Unable to lift unknown Observable type")}}function R(s,e,t,n,i){return new Ni(s,e,t,n,i)}var Ni=function(s){be(e,s);function e(t,n,i,r,o,a){var l=s.call(this,t)||this;return l.onFinalize=o,l.shouldUnsubscribe=a,l._next=n?function(c){try{n(c)}catch(h){t.error(h)}}:s.prototype._next,l._error=r?function(c){try{r(c)}catch(h){t.error(h)}finally{this.unsubscribe()}}:s.prototype._error,l._complete=i?function(){try{i()}catch(c){t.error(c)}finally{this.unsubscribe()}}:s.prototype._complete,l}return e.prototype.unsubscribe=function(){var t;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var n=this.closed;s.prototype.unsubscribe.call(this),!n&&((t=this.onFinalize)===null||t===void 0||t.call(this))}},e}(Wt),Fi=gs(function(s){return function(){s(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),_=function(s){be(e,s);function e(){var t=s.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 Cn(this,this);return n.operator=t,n},e.prototype._throwIfClosed=function(){if(this.closed)throw new Fi},e.prototype.next=function(t){var n=this;We(function(){var i,r;if(n._throwIfClosed(),!n.isStopped){n.currentObservers||(n.currentObservers=Array.from(n.observers));try{for(var o=ge(n.currentObservers),a=o.next();!a.done;a=o.next()){var l=a.value;l.next(t)}}catch(c){i={error:c}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}}})},e.prototype.error=function(t){var n=this;We(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;We(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(),s.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,r=i.hasError,o=i.isStopped,a=i.observers;return r||o?ms:(this.currentObservers=null,a.push(t),new lt(function(){n.currentObservers=null,Ot(a,t)}))},e.prototype._checkFinalizedStatuses=function(t){var n=this,i=n.hasError,r=n.thrownError,o=n.isStopped;i?t.error(r):o&&t.complete()},e.prototype.asObservable=function(){var t=new A;return t.source=this,t},e.create=function(t,n){return new Cn(t,n)},e}(A),Cn=function(s){be(e,s);function e(t,n){var i=s.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:ms},e}(_),U=function(s){be(e,s);function e(t){var n=s.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=s.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,r=t._value;if(n)throw i;return this._throwIfClosed(),r},e.prototype.next=function(t){s.prototype.next.call(this,this._value=t)},e}(_),Pe=new A(function(s){return s.complete()});function qi(s){return s&&$(s.schedule)}function Qt(s){return s[s.length-1]}function $s(s){return $(Qt(s))?s.pop():void 0}function Kt(s){return qi(Qt(s))?s.pop():void 0}function Zi(s,e){return typeof Qt(s)=="number"?s.pop():e}var Gt=function(s){return s&&typeof s.length=="number"&&typeof s!="function"};function xs(s){return $(s==null?void 0:s.then)}function ws(s){return $(s[Yt])}function ks(s){return Symbol.asyncIterator&&$(s==null?void 0:s[Symbol.asyncIterator])}function _s(s){return new TypeError("You provided "+(s!==null&&typeof s=="object"?"an invalid object":"'"+s+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}function Wi(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var Ss=Wi();function Cs(s){return $(s==null?void 0:s[Ss])}function As(s){return Pi(this,arguments,function(){var t,n,i,r;return fs(this,function(o){switch(o.label){case 0:t=s.getReader(),o.label=1;case 1:o.trys.push([1,,9,10]),o.label=2;case 2:return[4,ue(t.read())];case 3:return n=o.sent(),i=n.value,r=n.done,r?[4,ue(void 0)]:[3,5];case 4:return[2,o.sent()];case 5:return[4,ue(i)];case 6:return[4,o.sent()];case 7:return o.sent(),[3,2];case 8:return[3,10];case 9:return t.releaseLock(),[7];case 10:return[2]}})})}function Es(s){return $(s==null?void 0:s.getReader)}function B(s){if(s instanceof A)return s;if(s!=null){if(ws(s))return Yi(s);if(Gt(s))return Qi(s);if(xs(s))return Ki(s);if(ks(s))return Ts(s);if(Cs(s))return Gi(s);if(Es(s))return Xi(s)}throw _s(s)}function Yi(s){return new A(function(e){var t=s[Yt]();if($(t.subscribe))return t.subscribe(e);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function Qi(s){return new A(function(e){for(var t=0;t<s.length&&!e.closed;t++)e.next(s[t]);e.complete()})}function Ki(s){return new A(function(e){s.then(function(t){e.closed||(e.next(t),e.complete())},function(t){return e.error(t)}).then(null,ys)})}function Gi(s){return new A(function(e){var t,n;try{for(var i=ge(s),r=i.next();!r.done;r=i.next()){var o=r.value;if(e.next(o),e.closed)return}}catch(a){t={error:a}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}e.complete()})}function Ts(s){return new A(function(e){Vi(s,e).catch(function(t){return e.error(t)})})}function Xi(s){return Ts(As(s))}function Vi(s,e){var t,n,i,r;return Oi(this,void 0,void 0,function(){var o,a;return fs(this,function(l){switch(l.label){case 0:l.trys.push([0,5,6,11]),t=Ri(s),l.label=1;case 1:return[4,t.next()];case 2:if(n=l.sent(),!!n.done)return[3,4];if(o=n.value,e.next(o),e.closed)return[2];l.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return a=l.sent(),i={error:a},[3,11];case 6:return l.trys.push([6,,9,10]),n&&!n.done&&(r=t.return)?[4,r.call(t)]:[3,8];case 7:l.sent(),l.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 F(s,e,t,n,i){n===void 0&&(n=0),i===void 0&&(i=!1);var r=e.schedule(function(){t(),i?s.add(this.schedule(null,n)):this.unsubscribe()},n);if(s.add(r),!i)return r}function Ls(s,e){return e===void 0&&(e=0),K(function(t,n){t.subscribe(R(n,function(i){return F(n,s,function(){return n.next(i)},e)},function(){return F(n,s,function(){return n.complete()},e)},function(i){return F(n,s,function(){return n.error(i)},e)}))})}function Os(s,e){return e===void 0&&(e=0),K(function(t,n){n.add(s.schedule(function(){return t.subscribe(n)},e))})}function Ji(s,e){return B(s).pipe(Os(e),Ls(e))}function er(s,e){return B(s).pipe(Os(e),Ls(e))}function tr(s,e){return new A(function(t){var n=0;return e.schedule(function(){n===s.length?t.complete():(t.next(s[n++]),t.closed||this.schedule())})})}function nr(s,e){return new A(function(t){var n;return F(t,e,function(){n=s[Ss](),F(t,e,function(){var i,r,o;try{i=n.next(),r=i.value,o=i.done}catch(a){t.error(a);return}o?t.complete():t.next(r)},0,!0)}),function(){return $(n==null?void 0:n.return)&&n.return()}})}function Ps(s,e){if(!s)throw new Error("Iterable cannot be null");return new A(function(t){F(t,e,function(){var n=s[Symbol.asyncIterator]();F(t,e,function(){n.next().then(function(i){i.done?t.complete():t.next(i.value)})},0,!0)})})}function sr(s,e){return Ps(As(s),e)}function ir(s,e){if(s!=null){if(ws(s))return Ji(s,e);if(Gt(s))return tr(s,e);if(xs(s))return er(s,e);if(ks(s))return Ps(s,e);if(Cs(s))return nr(s,e);if(Es(s))return sr(s,e)}throw _s(s)}function ct(s,e){return e?ir(s,e):B(s)}function It(){for(var s=[],e=0;e<arguments.length;e++)s[e]=arguments[e];var t=Kt(s);return ct(s,t)}function Ke(s,e){return K(function(t,n){var i=0;t.subscribe(R(n,function(r){n.next(s.call(e,r,i++))}))})}var rr=Array.isArray;function or(s,e){return rr(e)?s.apply(void 0,ne([],Y(e))):s(e)}function Rs(s){return Ke(function(e){return or(s,e)})}var ar=Array.isArray,lr=Object.getPrototypeOf,cr=Object.prototype,hr=Object.keys;function ur(s){if(s.length===1){var e=s[0];if(ar(e))return{args:e,keys:null};if(pr(e)){var t=hr(e);return{args:t.map(function(n){return e[n]}),keys:t}}}return{args:s,keys:null}}function pr(s){return s&&typeof s=="object"&&lr(s)===cr}function dr(s,e){return s.reduce(function(t,n,i){return t[n]=e[i],t},{})}function fr(){for(var s=[],e=0;e<arguments.length;e++)s[e]=arguments[e];var t=Kt(s),n=$s(s),i=ur(s),r=i.args,o=i.keys;if(r.length===0)return ct([],t);var a=new A(gr(r,t,o?function(l){return dr(o,l)}:Oe));return n?a.pipe(Rs(n)):a}function gr(s,e,t){return t===void 0&&(t=Oe),function(n){An(e,function(){for(var i=s.length,r=new Array(i),o=i,a=i,l=function(h){An(e,function(){var u=ct(s[h],e),p=!1;u.subscribe(R(n,function(d){r[h]=d,p||(p=!0,a--),a||n.next(t(r.slice()))},function(){--o||n.complete()}))},n)},c=0;c<i;c++)l(c)},n)}}function An(s,e,t){s?F(t,s,e):e()}function mr(s,e,t,n,i,r,o,a){var l=[],c=0,h=0,u=!1,p=function(){u&&!l.length&&!c&&e.complete()},d=function(f){return c<n?b(f):l.push(f)},b=function(f){r&&e.next(f),c++;var I=!1;B(t(f,h++)).subscribe(R(e,function(N){i==null||i(N),r?d(N):e.next(N)},function(){I=!0},void 0,function(){if(I)try{c--;for(var N=function(){var V=l.shift();o?F(e,o,function(){return b(V)}):b(V)};l.length&&c<n;)N();p()}catch(V){e.error(V)}}))};return s.subscribe(R(e,d,function(){u=!0,p()})),function(){a==null||a()}}function Xt(s,e,t){return t===void 0&&(t=1/0),$(e)?Xt(function(n,i){return Ke(function(r,o){return e(n,r,i,o)})(B(s(n,i)))},t):(typeof e=="number"&&(t=e),K(function(n,i){return mr(n,i,s,t)}))}function vr(s){return s===void 0&&(s=1/0),Xt(Oe,s)}var br=["addListener","removeListener"],yr=["addEventListener","removeEventListener"],$r=["on","off"];function Ge(s,e,t,n){if($(t)&&(n=t,t=void 0),n)return Ge(s,e,t).pipe(Rs(n));var i=Y(kr(s)?yr.map(function(a){return function(l){return s[a](e,l,t)}}):xr(s)?br.map(En(s,e)):wr(s)?$r.map(En(s,e)):[],2),r=i[0],o=i[1];if(!r&&Gt(s))return Xt(function(a){return Ge(a,e,t)})(B(s));if(!r)throw new TypeError("Invalid event target");return new A(function(a){var l=function(){for(var c=[],h=0;h<arguments.length;h++)c[h]=arguments[h];return a.next(1<c.length?c:c[0])};return r(l),function(){return o(l)}})}function En(s,e){return function(t){return function(n){return s[t](e,n)}}}function xr(s){return $(s.addListener)&&$(s.removeListener)}function wr(s){return $(s.on)&&$(s.off)}function kr(s){return $(s.addEventListener)&&$(s.removeEventListener)}function _r(){for(var s=[],e=0;e<arguments.length;e++)s[e]=arguments[e];var t=Kt(s),n=Zi(s,1/0),i=s;return i.length?i.length===1?B(i[0]):vr(n)(ct(i,t)):Pe}function Mt(s){return s<=0?function(){return Pe}:K(function(e,t){var n=0;e.subscribe(R(t,function(i){++n<=s&&(t.next(i),s<=n&&t.complete())}))})}function pe(s,e){return K(function(t,n){var i=null,r=0,o=!1,a=function(){return o&&!i&&n.complete()};t.subscribe(R(n,function(l){i==null||i.unsubscribe();var c=0,h=r++;B(s(l,h)).subscribe(i=R(n,function(u){return n.next(e?e(l,u,h,c++):u)},function(){i=null,a()}))},function(){o=!0,a()}))})}function zt(s){return K(function(e,t){B(s).subscribe(R(t,function(){return t.complete()},Qe)),!t.closed&&e.subscribe(t)})}function Ut(){for(var s=[],e=0;e<arguments.length;e++)s[e]=arguments[e];var t=$s(s);return K(function(n,i){for(var r=s.length,o=new Array(r),a=s.map(function(){return!1}),l=!1,c=function(u){B(s[u]).subscribe(R(i,function(p){o[u]=p,!l&&!a[u]&&(a[u]=!0,(l=a.every(Oe))&&(a=null))},Qe))},h=0;h<r;h++)c(h);n.subscribe(R(i,function(u){if(l){var p=ne([u],Y(o));i.next(t?t.apply(void 0,ne([],Y(p))):p)}}))})}var q=(s=>(s.User="user",s.Agent="agent",s.System="system",s))(q||{});const Is=()=>crypto.randomUUID();class Re{constructor(e,t,n){this.type=e,this.sender=t,this.messages=n,this.status="delivered",this.didUpdate=new _,this.actions$=new _,this.remove$=new _,this.timestamp=Date.now(),this.id=Is()}update(e){this.messages=[{items:e}],this.didUpdate.next(this)}setStatus(e){this.status=e,this.didUpdate.next(this)}remove(){this.remove$.next()}}class Ms{constructor(e){this.name=e,this.print$=new _}print(e,t="html"){const n=new Re(q.Agent,{name:this.name},[{items:[[t,{content:e}]]}]);return this.print$.next(n),n}subscribe(){return this.print$.asObservable()}}class zs{constructor(e){this.name=e,this.print$=new _}print(e){const t=new Re(q.User,{name:this.name},[{items:[["html",{content:e}]]}]);return this.print$.next(t),t}subscribe(){return this.print$.asObservable()}}class Sr{constructor(){this.print$=new _,this.name="system"}print(e){const t=new Re(q.System,{name:this.name},[{items:[["html",{content:e}]]}]);return this.print$.next(t),t}subscribe(){return this.print$.asObservable()}}class Cr{constructor(e,t){this.name=e,this.component=t,this.print$=new _,this.typingState$=new U(!1),this.complete$=new _,this.system=this.createSystem(),this.rehydrate$=new _,this.saveToCurrentSession$=new _,this.showChatOverlay$=new U(!1),this.onComplete=()=>this.complete$.asObservable()}connect(e={}){this.complete$.pipe(Mt(1)).subscribe(()=>{this.disconnected()})}disconnected(){}onUserSubmit(e){this.print(q.User,e.text)}print(e,t){const n=new Re(e,{name:""},[{items:[["html",{content:t}]]}]);return this.printEntry(n)}printEntry(e){return this.print$.next(e),e}createAgent(e){const t=new Ms(e);return t.subscribe().subscribe(n=>{this.playNotification(),this.printEntry(n)}),t}createUser(e){const t=new zs(e);return t.subscribe().subscribe(n=>{this.printEntry(n)}),t}createSystem(){const e=new Sr;return e.subscribe().subscribe(t=>{this.printEntry(t)}),e}setTypingState(e){this.typingState$.next(e)}setToastMessage(e){this.component.setToastMessage(e)}isTyping(){return this.typingState$.asObservable()}actions(){return this.print$.asObservable()}playNotification(){const e="https://publicpoc.blob.core.windows.net/widget-assets/notification.mp3";this.component.application.storage.get("muteAudioNotifications")||new Audio(e).play().catch(n=>{})}complete(){this.complete$.next()}save(e){this.saveToCurrentSession$.next(e)}async rehydrate(e){}}/**
|
3
|
+
`):"",this.name="UnsubscriptionError",this.errors=t}});function Ot(s,e){if(s){var t=s.indexOf(e);0<=t&&s.splice(t,1)}}var lt=function(){function s(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}return s.prototype.unsubscribe=function(){var e,t,n,i,r;if(!this.closed){this.closed=!0;var o=this._parentage;if(o)if(this._parentage=null,Array.isArray(o))try{for(var a=ge(o),l=a.next();!l.done;l=a.next()){var c=l.value;c.remove(this)}}catch(f){e={error:f}}finally{try{l&&!l.done&&(t=a.return)&&t.call(a)}finally{if(e)throw e.error}}else o.remove(this);var h=this.initialTeardown;if($(h))try{h()}catch(f){r=f instanceof xt?f.errors:[f]}var u=this._finalizers;if(u){this._finalizers=null;try{for(var p=ge(u),d=p.next();!d.done;d=p.next()){var b=d.value;try{_n(b)}catch(f){r=r??[],f instanceof xt?r=ne(ne([],Y(r)),Y(f.errors)):r.push(f)}}}catch(f){n={error:f}}finally{try{d&&!d.done&&(i=p.return)&&i.call(p)}finally{if(n)throw n.error}}}if(r)throw new xt(r)}},s.prototype.add=function(e){var t;if(e&&e!==this)if(this.closed)_n(e);else{if(e instanceof s){if(e.closed||e._hasParent(this))return;e._addParent(this)}(this._finalizers=(t=this._finalizers)!==null&&t!==void 0?t:[]).push(e)}},s.prototype._hasParent=function(e){var t=this._parentage;return t===e||Array.isArray(t)&&t.includes(e)},s.prototype._addParent=function(e){var t=this._parentage;this._parentage=Array.isArray(t)?(t.push(e),t):t?[t,e]:e},s.prototype._removeParent=function(e){var t=this._parentage;t===e?this._parentage=null:Array.isArray(t)&&Ot(t,e)},s.prototype.remove=function(e){var t=this._finalizers;t&&Ot(t,e),e instanceof s&&e._removeParent(this)},s.EMPTY=function(){var e=new s;return e.closed=!0,e}(),s}(),ms=lt.EMPTY;function vs(s){return s instanceof lt||s&&"closed"in s&&$(s.remove)&&$(s.add)&&$(s.unsubscribe)}function _n(s){$(s)?s():s.unsubscribe()}var bs={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},Pt={setTimeout:function(s,e){for(var t=[],n=2;n<arguments.length;n++)t[n-2]=arguments[n];var i=Pt.delegate;return i!=null&&i.setTimeout?i.setTimeout.apply(i,ne([s,e],Y(t))):setTimeout.apply(void 0,ne([s,e],Y(t)))},clearTimeout:function(s){var e=Pt.delegate;return((e==null?void 0:e.clearTimeout)||clearTimeout)(s)},delegate:void 0};function ys(s){Pt.setTimeout(function(){throw s})}function Qe(){}function We(s){s()}var Wt=function(s){be(e,s);function e(t){var n=s.call(this)||this;return n.isStopped=!1,t?(n.destination=t,vs(t)&&t.add(n)):n.destination=Ui,n}return e.create=function(t,n,i){return new Rt(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,s.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}(lt),Ii=Function.prototype.bind;function wt(s,e){return Ii.call(s,e)}var Mi=function(){function s(e){this.partialObserver=e}return s.prototype.next=function(e){var t=this.partialObserver;if(t.next)try{t.next(e)}catch(n){Be(n)}},s.prototype.error=function(e){var t=this.partialObserver;if(t.error)try{t.error(e)}catch(n){Be(n)}else Be(e)},s.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(t){Be(t)}},s}(),Rt=function(s){be(e,s);function e(t,n,i){var r=s.call(this)||this,o;if($(t)||!t)o={next:t??void 0,error:n??void 0,complete:i??void 0};else{var a;r&&bs.useDeprecatedNextContext?(a=Object.create(t),a.unsubscribe=function(){return r.unsubscribe()},o={next:t.next&&wt(t.next,a),error:t.error&&wt(t.error,a),complete:t.complete&&wt(t.complete,a)}):o=t}return r.destination=new Mi(o),r}return e}(Wt);function Be(s){ys(s)}function zi(s){throw s}var Ui={closed:!0,next:Qe,error:zi,complete:Qe},Yt=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function Oe(s){return s}function ji(s){return s.length===0?Oe:s.length===1?s[0]:function(t){return s.reduce(function(n,i){return i(n)},t)}}var A=function(){function s(e){e&&(this._subscribe=e)}return s.prototype.lift=function(e){var t=new s;return t.source=this,t.operator=e,t},s.prototype.subscribe=function(e,t,n){var i=this,r=Di(e)?e:new Rt(e,t,n);return We(function(){var o=i,a=o.operator,l=o.source;r.add(a?a.call(r,l):l?i._subscribe(r):i._trySubscribe(r))}),r},s.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(t){e.error(t)}},s.prototype.forEach=function(e,t){var n=this;return t=Sn(t),new t(function(i,r){var o=new Rt({next:function(a){try{e(a)}catch(l){r(l),o.unsubscribe()}},error:r,complete:i});n.subscribe(o)})},s.prototype._subscribe=function(e){var t;return(t=this.source)===null||t===void 0?void 0:t.subscribe(e)},s.prototype[Yt]=function(){return this},s.prototype.pipe=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return ji(e)(this)},s.prototype.toPromise=function(e){var t=this;return e=Sn(e),new e(function(n,i){var r;t.subscribe(function(o){return r=o},function(o){return i(o)},function(){return n(r)})})},s.create=function(e){return new s(e)},s}();function Sn(s){var e;return(e=s??bs.Promise)!==null&&e!==void 0?e:Promise}function Hi(s){return s&&$(s.next)&&$(s.error)&&$(s.complete)}function Di(s){return s&&s instanceof Wt||Hi(s)&&vs(s)}function Bi(s){return $(s==null?void 0:s.lift)}function K(s){return function(e){if(Bi(e))return e.lift(function(t){try{return s(t,this)}catch(n){this.error(n)}});throw new TypeError("Unable to lift unknown Observable type")}}function R(s,e,t,n,i){return new Ni(s,e,t,n,i)}var Ni=function(s){be(e,s);function e(t,n,i,r,o,a){var l=s.call(this,t)||this;return l.onFinalize=o,l.shouldUnsubscribe=a,l._next=n?function(c){try{n(c)}catch(h){t.error(h)}}:s.prototype._next,l._error=r?function(c){try{r(c)}catch(h){t.error(h)}finally{this.unsubscribe()}}:s.prototype._error,l._complete=i?function(){try{i()}catch(c){t.error(c)}finally{this.unsubscribe()}}:s.prototype._complete,l}return e.prototype.unsubscribe=function(){var t;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var n=this.closed;s.prototype.unsubscribe.call(this),!n&&((t=this.onFinalize)===null||t===void 0||t.call(this))}},e}(Wt),Fi=gs(function(s){return function(){s(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),_=function(s){be(e,s);function e(){var t=s.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 Cn(this,this);return n.operator=t,n},e.prototype._throwIfClosed=function(){if(this.closed)throw new Fi},e.prototype.next=function(t){var n=this;We(function(){var i,r;if(n._throwIfClosed(),!n.isStopped){n.currentObservers||(n.currentObservers=Array.from(n.observers));try{for(var o=ge(n.currentObservers),a=o.next();!a.done;a=o.next()){var l=a.value;l.next(t)}}catch(c){i={error:c}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}}})},e.prototype.error=function(t){var n=this;We(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;We(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(),s.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,r=i.hasError,o=i.isStopped,a=i.observers;return r||o?ms:(this.currentObservers=null,a.push(t),new lt(function(){n.currentObservers=null,Ot(a,t)}))},e.prototype._checkFinalizedStatuses=function(t){var n=this,i=n.hasError,r=n.thrownError,o=n.isStopped;i?t.error(r):o&&t.complete()},e.prototype.asObservable=function(){var t=new A;return t.source=this,t},e.create=function(t,n){return new Cn(t,n)},e}(A),Cn=function(s){be(e,s);function e(t,n){var i=s.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:ms},e}(_),U=function(s){be(e,s);function e(t){var n=s.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=s.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,r=t._value;if(n)throw i;return this._throwIfClosed(),r},e.prototype.next=function(t){s.prototype.next.call(this,this._value=t)},e}(_),Pe=new A(function(s){return s.complete()});function qi(s){return s&&$(s.schedule)}function Qt(s){return s[s.length-1]}function $s(s){return $(Qt(s))?s.pop():void 0}function Kt(s){return qi(Qt(s))?s.pop():void 0}function Zi(s,e){return typeof Qt(s)=="number"?s.pop():e}var Gt=function(s){return s&&typeof s.length=="number"&&typeof s!="function"};function xs(s){return $(s==null?void 0:s.then)}function ws(s){return $(s[Yt])}function ks(s){return Symbol.asyncIterator&&$(s==null?void 0:s[Symbol.asyncIterator])}function _s(s){return new TypeError("You provided "+(s!==null&&typeof s=="object"?"an invalid object":"'"+s+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}function Wi(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var Ss=Wi();function Cs(s){return $(s==null?void 0:s[Ss])}function As(s){return Pi(this,arguments,function(){var t,n,i,r;return fs(this,function(o){switch(o.label){case 0:t=s.getReader(),o.label=1;case 1:o.trys.push([1,,9,10]),o.label=2;case 2:return[4,ue(t.read())];case 3:return n=o.sent(),i=n.value,r=n.done,r?[4,ue(void 0)]:[3,5];case 4:return[2,o.sent()];case 5:return[4,ue(i)];case 6:return[4,o.sent()];case 7:return o.sent(),[3,2];case 8:return[3,10];case 9:return t.releaseLock(),[7];case 10:return[2]}})})}function Es(s){return $(s==null?void 0:s.getReader)}function B(s){if(s instanceof A)return s;if(s!=null){if(ws(s))return Yi(s);if(Gt(s))return Qi(s);if(xs(s))return Ki(s);if(ks(s))return Ts(s);if(Cs(s))return Gi(s);if(Es(s))return Xi(s)}throw _s(s)}function Yi(s){return new A(function(e){var t=s[Yt]();if($(t.subscribe))return t.subscribe(e);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function Qi(s){return new A(function(e){for(var t=0;t<s.length&&!e.closed;t++)e.next(s[t]);e.complete()})}function Ki(s){return new A(function(e){s.then(function(t){e.closed||(e.next(t),e.complete())},function(t){return e.error(t)}).then(null,ys)})}function Gi(s){return new A(function(e){var t,n;try{for(var i=ge(s),r=i.next();!r.done;r=i.next()){var o=r.value;if(e.next(o),e.closed)return}}catch(a){t={error:a}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}e.complete()})}function Ts(s){return new A(function(e){Vi(s,e).catch(function(t){return e.error(t)})})}function Xi(s){return Ts(As(s))}function Vi(s,e){var t,n,i,r;return Oi(this,void 0,void 0,function(){var o,a;return fs(this,function(l){switch(l.label){case 0:l.trys.push([0,5,6,11]),t=Ri(s),l.label=1;case 1:return[4,t.next()];case 2:if(n=l.sent(),!!n.done)return[3,4];if(o=n.value,e.next(o),e.closed)return[2];l.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return a=l.sent(),i={error:a},[3,11];case 6:return l.trys.push([6,,9,10]),n&&!n.done&&(r=t.return)?[4,r.call(t)]:[3,8];case 7:l.sent(),l.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 F(s,e,t,n,i){n===void 0&&(n=0),i===void 0&&(i=!1);var r=e.schedule(function(){t(),i?s.add(this.schedule(null,n)):this.unsubscribe()},n);if(s.add(r),!i)return r}function Ls(s,e){return e===void 0&&(e=0),K(function(t,n){t.subscribe(R(n,function(i){return F(n,s,function(){return n.next(i)},e)},function(){return F(n,s,function(){return n.complete()},e)},function(i){return F(n,s,function(){return n.error(i)},e)}))})}function Os(s,e){return e===void 0&&(e=0),K(function(t,n){n.add(s.schedule(function(){return t.subscribe(n)},e))})}function Ji(s,e){return B(s).pipe(Os(e),Ls(e))}function er(s,e){return B(s).pipe(Os(e),Ls(e))}function tr(s,e){return new A(function(t){var n=0;return e.schedule(function(){n===s.length?t.complete():(t.next(s[n++]),t.closed||this.schedule())})})}function nr(s,e){return new A(function(t){var n;return F(t,e,function(){n=s[Ss](),F(t,e,function(){var i,r,o;try{i=n.next(),r=i.value,o=i.done}catch(a){t.error(a);return}o?t.complete():t.next(r)},0,!0)}),function(){return $(n==null?void 0:n.return)&&n.return()}})}function Ps(s,e){if(!s)throw new Error("Iterable cannot be null");return new A(function(t){F(t,e,function(){var n=s[Symbol.asyncIterator]();F(t,e,function(){n.next().then(function(i){i.done?t.complete():t.next(i.value)})},0,!0)})})}function sr(s,e){return Ps(As(s),e)}function ir(s,e){if(s!=null){if(ws(s))return Ji(s,e);if(Gt(s))return tr(s,e);if(xs(s))return er(s,e);if(ks(s))return Ps(s,e);if(Cs(s))return nr(s,e);if(Es(s))return sr(s,e)}throw _s(s)}function ct(s,e){return e?ir(s,e):B(s)}function It(){for(var s=[],e=0;e<arguments.length;e++)s[e]=arguments[e];var t=Kt(s);return ct(s,t)}function Ke(s,e){return K(function(t,n){var i=0;t.subscribe(R(n,function(r){n.next(s.call(e,r,i++))}))})}var rr=Array.isArray;function or(s,e){return rr(e)?s.apply(void 0,ne([],Y(e))):s(e)}function Rs(s){return Ke(function(e){return or(s,e)})}var ar=Array.isArray,lr=Object.getPrototypeOf,cr=Object.prototype,hr=Object.keys;function ur(s){if(s.length===1){var e=s[0];if(ar(e))return{args:e,keys:null};if(pr(e)){var t=hr(e);return{args:t.map(function(n){return e[n]}),keys:t}}}return{args:s,keys:null}}function pr(s){return s&&typeof s=="object"&&lr(s)===cr}function dr(s,e){return s.reduce(function(t,n,i){return t[n]=e[i],t},{})}function fr(){for(var s=[],e=0;e<arguments.length;e++)s[e]=arguments[e];var t=Kt(s),n=$s(s),i=ur(s),r=i.args,o=i.keys;if(r.length===0)return ct([],t);var a=new A(gr(r,t,o?function(l){return dr(o,l)}:Oe));return n?a.pipe(Rs(n)):a}function gr(s,e,t){return t===void 0&&(t=Oe),function(n){An(e,function(){for(var i=s.length,r=new Array(i),o=i,a=i,l=function(h){An(e,function(){var u=ct(s[h],e),p=!1;u.subscribe(R(n,function(d){r[h]=d,p||(p=!0,a--),a||n.next(t(r.slice()))},function(){--o||n.complete()}))},n)},c=0;c<i;c++)l(c)},n)}}function An(s,e,t){s?F(t,s,e):e()}function mr(s,e,t,n,i,r,o,a){var l=[],c=0,h=0,u=!1,p=function(){u&&!l.length&&!c&&e.complete()},d=function(f){return c<n?b(f):l.push(f)},b=function(f){r&&e.next(f),c++;var I=!1;B(t(f,h++)).subscribe(R(e,function(N){i==null||i(N),r?d(N):e.next(N)},function(){I=!0},void 0,function(){if(I)try{c--;for(var N=function(){var V=l.shift();o?F(e,o,function(){return b(V)}):b(V)};l.length&&c<n;)N();p()}catch(V){e.error(V)}}))};return s.subscribe(R(e,d,function(){u=!0,p()})),function(){a==null||a()}}function Xt(s,e,t){return t===void 0&&(t=1/0),$(e)?Xt(function(n,i){return Ke(function(r,o){return e(n,r,i,o)})(B(s(n,i)))},t):(typeof e=="number"&&(t=e),K(function(n,i){return mr(n,i,s,t)}))}function vr(s){return s===void 0&&(s=1/0),Xt(Oe,s)}var br=["addListener","removeListener"],yr=["addEventListener","removeEventListener"],$r=["on","off"];function Ge(s,e,t,n){if($(t)&&(n=t,t=void 0),n)return Ge(s,e,t).pipe(Rs(n));var i=Y(kr(s)?yr.map(function(a){return function(l){return s[a](e,l,t)}}):xr(s)?br.map(En(s,e)):wr(s)?$r.map(En(s,e)):[],2),r=i[0],o=i[1];if(!r&&Gt(s))return Xt(function(a){return Ge(a,e,t)})(B(s));if(!r)throw new TypeError("Invalid event target");return new A(function(a){var l=function(){for(var c=[],h=0;h<arguments.length;h++)c[h]=arguments[h];return a.next(1<c.length?c:c[0])};return r(l),function(){return o(l)}})}function En(s,e){return function(t){return function(n){return s[t](e,n)}}}function xr(s){return $(s.addListener)&&$(s.removeListener)}function wr(s){return $(s.on)&&$(s.off)}function kr(s){return $(s.addEventListener)&&$(s.removeEventListener)}function _r(){for(var s=[],e=0;e<arguments.length;e++)s[e]=arguments[e];var t=Kt(s),n=Zi(s,1/0),i=s;return i.length?i.length===1?B(i[0]):vr(n)(ct(i,t)):Pe}function Mt(s){return s<=0?function(){return Pe}:K(function(e,t){var n=0;e.subscribe(R(t,function(i){++n<=s&&(t.next(i),s<=n&&t.complete())}))})}function pe(s,e){return K(function(t,n){var i=null,r=0,o=!1,a=function(){return o&&!i&&n.complete()};t.subscribe(R(n,function(l){i==null||i.unsubscribe();var c=0,h=r++;B(s(l,h)).subscribe(i=R(n,function(u){return n.next(e?e(l,u,h,c++):u)},function(){i=null,a()}))},function(){o=!0,a()}))})}function zt(s){return K(function(e,t){B(s).subscribe(R(t,function(){return t.complete()},Qe)),!t.closed&&e.subscribe(t)})}function Ut(){for(var s=[],e=0;e<arguments.length;e++)s[e]=arguments[e];var t=$s(s);return K(function(n,i){for(var r=s.length,o=new Array(r),a=s.map(function(){return!1}),l=!1,c=function(u){B(s[u]).subscribe(R(i,function(p){o[u]=p,!l&&!a[u]&&(a[u]=!0,(l=a.every(Oe))&&(a=null))},Qe))},h=0;h<r;h++)c(h);n.subscribe(R(i,function(u){if(l){var p=ne([u],Y(o));i.next(t?t.apply(void 0,ne([],Y(p))):p)}}))})}var q=(s=>(s.User="user",s.Agent="agent",s.System="system",s))(q||{});const Is=()=>crypto.randomUUID();class Re{constructor(e,t,n){this.type=e,this.sender=t,this.messages=n,this.status="delivered",this.didUpdate=new _,this.actions$=new _,this.remove$=new _,this.timestamp=Date.now(),this.id=Is()}update(e){this.messages=[{items:e}],this.didUpdate.next(this)}setStatus(e){this.status=e,this.didUpdate.next(this)}remove(){this.remove$.next()}}class Ms{constructor(e){this.name=e,this.print$=new _}print(e,t="html",n=this.name){const i=new Re(q.Agent,{name:n},[{items:[[t,{content:e}]]}]);return this.print$.next(i),i}subscribe(){return this.print$.asObservable()}}class zs{constructor(e){this.name=e,this.print$=new _}print(e){const t=new Re(q.User,{name:this.name},[{items:[["html",{content:e}]]}]);return this.print$.next(t),t}subscribe(){return this.print$.asObservable()}}class Sr{constructor(){this.print$=new _,this.name="system"}print(e){const t=new Re(q.System,{name:this.name},[{items:[["html",{content:e}]]}]);return this.print$.next(t),t}subscribe(){return this.print$.asObservable()}}class Cr{constructor(e,t){this.name=e,this.component=t,this.print$=new _,this.typingState$=new U(!1),this.complete$=new _,this.system=this.createSystem(),this.rehydrate$=new _,this.saveToCurrentSession$=new _,this.showChatOverlay$=new U(!1),this.onComplete=()=>this.complete$.asObservable()}connect(e={}){this.complete$.pipe(Mt(1)).subscribe(()=>{this.disconnected()})}disconnected(){}onUserSubmit(e){this.print(q.User,e.text)}print(e,t){const n=new Re(e,{name:""},[{items:[["html",{content:t}]]}]);return this.printEntry(n)}printEntry(e){return this.print$.next(e),e}createAgent(e){const t=new Ms(e);return t.subscribe().subscribe(n=>{this.playNotification(),this.printEntry(n)}),t}createUser(e){const t=new zs(e);return t.subscribe().subscribe(n=>{this.printEntry(n)}),t}createSystem(){const e=new Sr;return e.subscribe().subscribe(t=>{this.printEntry(t)}),e}setTypingState(e){this.typingState$.next(e)}setToastMessage(e){this.component.setToastMessage(e)}isTyping(){return this.typingState$.asObservable()}actions(){return this.print$.asObservable()}playNotification(){const e="https://publicpoc.blob.core.windows.net/widget-assets/notification.mp3";this.component.application.storage.get("muteAudioNotifications")||new Audio(e).play().catch(n=>{})}complete(){this.complete$.next()}save(e){this.saveToCurrentSession$.next(e)}async rehydrate(e){}}/**
|
4
4
|
* @license
|
5
5
|
* Copyright 2019 Google LLC
|
6
6
|
* SPDX-License-Identifier: BSD-3-Clause
|
@@ -264,8 +264,8 @@
|
|
264
264
|
* @license
|
265
265
|
* Copyright 2017 Google LLC
|
266
266
|
* SPDX-License-Identifier: BSD-3-Clause
|
267
|
-
*/function wa({context:s}){return(e,t)=>{const n=new WeakMap;if(typeof t=="object")return t.addInitializer(function(){n.set(this,new os(this,{context:s}))}),{get(){return e.get.call(this)},set(i){var r;return(r=n.get(this))==null||r.setValue(i),e.set.call(this,i)},init(i){var r;return(r=n.get(this))==null||r.setValue(i),i}};{e.constructor.addInitializer(o=>{n.set(o,new os(o,{context:s}))});const i=Object.getOwnPropertyDescriptor(e,t);let r;if(i===void 0){const o=new WeakMap;r={get:function(){return o.get(this)},set:function(a){n.get(this).setValue(a),o.set(this,a)},configurable:!0,enumerable:!0}}else{const o=i.set;r={...i,set:function(a){n.get(this).setValue(a),o==null||o.call(this,a)}}}return void Object.defineProperty(e,t,r)}}}var ka=Object.defineProperty,_a=Object.getOwnPropertyDescriptor,Sa=(s,e,t,n)=>{for(var i=n>1?void 0:n?_a(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(i=(n?o(e,t,i):o(i))||i);return n&&i&&ka(e,t,i),i};const Ca="application";class cn extends k{constructor(){super(...arguments),this.nodes=[],this.wrapperRef=M()}addChild(e){e.parent=this,this.nodes.push(e)}applyBranding(){if(!this.wrapperRef.value)return;const e=this.application.settings;e!=null&&e.branding&&li(e.branding,this.wrapperRef.value)}applyStyles(){if(!this.wrapperRef.value)return;const e=this.application.styles(),t=this.wrapperRef.value;Object.entries(e).forEach(([n,i])=>{t.style.setProperty(`--${n}`,i)})}firstUpdated(e){this.applyBranding(),this.applyStyles()}render(){return this.application.renderStrategy===ln.Trigger&&(this.renderRoot.host.classList.add("floating"),this.application.anchor==="BottomLeft"?this.renderRoot.host.classList.add("bottom-left"):this.application.anchor==="BottomRight"&&this.renderRoot.host.classList.add("bottom-right")),m`<div class="widget-container" ${z(this.wrapperRef)}>
|
268
|
-
${ba(this.nodes,
|
267
|
+
*/function wa({context:s}){return(e,t)=>{const n=new WeakMap;if(typeof t=="object")return t.addInitializer(function(){n.set(this,new os(this,{context:s}))}),{get(){return e.get.call(this)},set(i){var r;return(r=n.get(this))==null||r.setValue(i),e.set.call(this,i)},init(i){var r;return(r=n.get(this))==null||r.setValue(i),i}};{e.constructor.addInitializer(o=>{n.set(o,new os(o,{context:s}))});const i=Object.getOwnPropertyDescriptor(e,t);let r;if(i===void 0){const o=new WeakMap;r={get:function(){return o.get(this)},set:function(a){n.get(this).setValue(a),o.set(this,a)},configurable:!0,enumerable:!0}}else{const o=i.set;r={...i,set:function(a){n.get(this).setValue(a),o==null||o.call(this,a)}}}return void Object.defineProperty(e,t,r)}}}var ka=Object.defineProperty,_a=Object.getOwnPropertyDescriptor,Sa=(s,e,t,n)=>{for(var i=n>1?void 0:n?_a(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(i=(n?o(e,t,i):o(i))||i);return n&&i&&ka(e,t,i),i};const Ca="application";class cn extends k{constructor(){super(...arguments),this.nodes=[],this.wrapperRef=M()}addChild(e){e.parent=this,this.nodes.push(e)}applyBranding(){if(!this.wrapperRef.value)return;const e=this.application.settings;e!=null&&e.branding&&li(e.branding,this.wrapperRef.value)}applyStyles(){if(!this.wrapperRef.value)return;const e=this.application.styles(),t=this.wrapperRef.value;Object.entries(e).forEach(([n,i])=>{t.style.setProperty(`--${n}`,i)})}firstUpdated(e){this.applyBranding(),this.applyStyles()}render(){var n,i;const e=this.application.settings.components.conversation;return((i=(n=e==null?void 0:e.properties)==null?void 0:n.chat)==null?void 0:i.isThirdPartyWidget)?this.renderRoot.host.classList.add("third-party"):this.application.renderStrategy===ln.Trigger&&(this.renderRoot.host.classList.add("floating"),this.application.anchor==="BottomLeft"?this.renderRoot.host.classList.add("bottom-left"):this.application.anchor==="BottomRight"&&this.renderRoot.host.classList.add("bottom-right")),m`<div class="widget-container" ${z(this.wrapperRef)}>
|
268
|
+
${ba(this.nodes,r=>r)}
|
269
269
|
</div>`}}cn.styles=E`
|
270
270
|
:host {
|
271
271
|
--font-family: TeliaSans, Helvetica, Arial, Lucida Grande, sans-serif;
|
@@ -313,6 +313,10 @@
|
|
313
313
|
inset: 0 0 95px 0;
|
314
314
|
height: 100%;
|
315
315
|
}
|
316
|
+
:host(.third-party) {
|
317
|
+
inset: 0 0 95px 0;
|
318
|
+
height: 100vh;
|
319
|
+
}
|
316
320
|
}
|
317
321
|
@media screen and (min-width: 801px) {
|
318
322
|
:host(.floating) {
|
@@ -321,6 +325,14 @@
|
|
321
325
|
width: 400px;
|
322
326
|
height: 700px;
|
323
327
|
}
|
328
|
+
:host(.third-party) {
|
329
|
+
max-width: 1000px;
|
330
|
+
height: 100vh;
|
331
|
+
position: relative;
|
332
|
+
left: 50%;
|
333
|
+
transform: translateX(-50%);
|
334
|
+
margin: -10px 0;
|
335
|
+
}
|
324
336
|
:host(.floating.bottom-right) {
|
325
337
|
inset: auto 20px 95px auto;
|
326
338
|
}
|
@@ -346,6 +358,8 @@
|
|
346
358
|
background-color: var(--primary-background);
|
347
359
|
padding: var(--spacing-sm);
|
348
360
|
border: var(--widget-border, none);
|
361
|
+
border-left: 1px solid #00000054;
|
362
|
+
border-right: 1px solid #00000054;
|
349
363
|
}
|
350
364
|
@keyframes slideDown {
|
351
365
|
from {
|
@@ -782,7 +796,7 @@ Please report this to https://github.com/markedjs/marked.`,e){const i="<p>An err
|
|
782
796
|
width: 80%;
|
783
797
|
max-width: 700px;
|
784
798
|
}
|
785
|
-
`];Ll([w({attribute:!0})],xn.prototype,"imageUrl",2);var Ol=Object.defineProperty,Pl=Object.getOwnPropertyDescriptor,X=(s,e,t,n)=>{for(var i=n>1?void 0:n?Pl(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(i=(n?o(e,t,i):o(i))||i);return n&&i&&Ol(e,t,i),i};customElements.get("conversation-entry")||customElements.define("conversation-entry",un);customElements.get("ace-conversation-feed")||customElements.define("ace-conversation-feed",mt);customElements.get("conversation-group")||customElements.define("conversation-group",pn);customElements.get("ace-typing-state")||customElements.define("ace-typing-state",di);customElements.get("message-type-html")||customElements.define("message-type-html",dn);customElements.get("message-type-markdown")||customElements.define("message-type-markdown",bt);customElements.get("ace-lightbox")||customElements.define("ace-lightbox",xn);const Ci=ci(k);class O extends Ci{constructor(){super(...arguments),this.message="",this.disabledInput=!1,this.disabledSubmit=!1,this.chatOverlayActive=!1,this.textAreaLength=0,this.conversationContentRef=M(),this.conversationFeedRef=M(),this.formRef=M(),this.inputRef=M(),this.scrollRef=M(),this.counterRef=M(),this.chatScrollHeight=0,this.chatCurrentScrollPosition=0,this.toast=new Ta(this),this.messageMaxLength=1e3,this.messageMaxLengthLabel="Maximum character limit reached",this.skipToLatestMessageLabel="Skip to latest message",this.platform=null,this.entries=[],this.typing=!1,this.conversationState$=new U("waiting"),this.stateMachine=new Oa(this.conversationState$,this),this.provider$=this.stateMachine.session().pipe(pe(e=>e?e==null?void 0:e.provider$:It(null))),this.userTyping$=new _}async connectedCallback(){super.connectedCallback(),this.messageMaxLength=this.properties.messageMaxLength??this.messageMaxLength,this.messageMaxLengthLabel=this.properties.messageMaxLengthLabel??this.messageMaxLengthLabel,this.skipToLatestMessageLabel=this.properties.skipToLatestMessageLabel??this.skipToLatestMessageLabel;const e=await this.application.container.get("conversation");this.platform=e||null;const t=this.application.trigger;t&&t.widgetActive$.pipe(zt(t.componentIsDestroyed$)).subscribe(n=>{const i=this.conversationContentRef.value;i&&(n?i.scrollTop=this.chatCurrentScrollPosition:this.chatCurrentScrollPosition=i.scrollTop)}),this.stateSubscription=fr([this.stateMachine.entries(),this.stateMachine.isTyping()]).subscribe(([n,i])=>{this.entries=n,this.typing=i}),this.userSubmitSubscription=Ge(this,"user-submit").pipe(Ut(this.provider$)).subscribe(([n,i])=>{i&&i.onUserSubmit(n.detail)}),this._addHeaderOptions(),this.provider$.pipe(Ut(this.provider$)).subscribe(([n,i])=>{i&&i.showChatOverlay$.pipe().subscribe(r=>{this.chatOverlayActive=r})})}disconnectedCallback(){var e,t;super.disconnectedCallback(),(e=this.userSubmitSubscription)==null||e.unsubscribe(),(t=this.stateSubscription)==null||t.unsubscribe()}_actionHandler(e){}isTypingState(){var t,n;const e=(n=(t=this.conversationFeedRef.value)==null?void 0:t.shadowRoot)==null?void 0:n.querySelector(".conversation-feed");if(e){const i=e.lastElementChild;if(i&&i.tagName.toLowerCase()==="ace-typing-state")return!0}return!1}isAtBottom(){const e=this.conversationContentRef.value;return e?e.scrollHeight-e.scrollTop-e.clientHeight<1:!1}scrollToBottom(){var e,t;(!this.isTypingState()||this.isAtBottom())&&(setTimeout(()=>{var n;return(n=this.scrollRef.value)==null?void 0:n.scrollIntoView({behavior:"smooth"})},300),this.chatScrollHeight=(e=this.scrollRef.value)==null?void 0:e.scrollHeight,this.chatCurrentScrollPosition=(t=this.scrollRef.value)==null?void 0:t.scrollTop)}onSessionUpdated(){this.scrollToBottom()}disableInput(){this.disabledInput=!0}enableInput(){this.disabledInput=!1}disableSubmit(){this.disabledSubmit=!0}enableSubmit(){this.disabledSubmit=!1}clearMessages(){var i,r;const e=(i=this.shadowRoot)==null?void 0:i.querySelector("ace-conversation-feed"),t=(r=e==null?void 0:e.shadowRoot)==null?void 0:r.querySelector(".conversation-feed"),n=t==null?void 0:t.querySelectorAll(".conversation-entry");n==null||n.forEach(o=>o.remove())}setToastMessage(e){this.toast.message=e}async _onSendMessage(e){var n,i;if(e.preventDefault(),this.message.length<=0||this.message.length>this.messageMaxLength){(n=this.formRef.value)==null||n.classList.add("shake"),setTimeout(()=>{var r;(r=this.formRef.value)==null||r.classList.remove("shake")},500);return}this.message=this.message.slice(0,this.messageMaxLength);const t=new CustomEvent("user-submit",{detail:{text:this.message}});this.dispatchEvent(t),this.message="",this.textAreaLength=0,(i=this.counterRef.value)==null||i.classList.remove("max-char-count-reached"),this.inputRef.value.style.height=this.style.getPropertyValue("--textarea-default-height")}_addHeaderOptions(){const e=this.application.getComponent("widget-header");if(!e)return;const t=this.application.texts,n=t.getOrFallback("conversation.mute","Mute"),i=t.getOrFallback("conversation.unmute","Unmute"),r=!!this.application.storage.get("muteAudioNotifications"),o=e.addOption({label:r?i:n,icon:r?Hn.svg:Dn.svg,closeOnClick:!1,datatestid:"options-mute-button",onClick:()=>{!!this.application.storage.get("muteAudioNotifications")?(this.application.unmute(),o.updateLabel(n),o.updateIcon(Dn.svg)):(this.application.mute(),o.updateLabel(i),o.updateIcon(Hn.svg))}})}_inputHandler(e){var t,n;this.message=e.target.value,e.target.style.height=this.style.getPropertyValue("--textarea-default-height"),e.target.style.height=e.target.scrollHeight+"px",this.textAreaLength=e.target.value.length,e.target.value.length>this.messageMaxLength?(t=this.counterRef.value)==null||t.classList.add("max-char-count-reached"):(n=this.counterRef.value)==null||n.classList.remove("max-char-count-reached")}_keyDownHandler(e){this.userTyping$.next(e.key),e.key==="Enter"&&!e.shiftKey&&!this.disabledSubmit&&(this._onSendMessage(e),e.preventDefault())}skipToLatestMessage(){var n,i;const e=(n=this.conversationFeedRef)==null?void 0:n.value,t=(i=e==null?void 0:e.shadowRoot)==null?void 0:i.querySelectorAll(".conversation-entry");t.length&&Array.from(t).pop().focus()}handover(e,t){this.enableInput(),this.setToastMessage(null);const n=new CustomEvent("handover",{detail:{providerKey:e,providerOptions:t}});return this.dispatchEvent(n),n.detail.complete||Pe}render(){var
|
799
|
+
`];Ll([w({attribute:!0})],xn.prototype,"imageUrl",2);var Ol=Object.defineProperty,Pl=Object.getOwnPropertyDescriptor,X=(s,e,t,n)=>{for(var i=n>1?void 0:n?Pl(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(i=(n?o(e,t,i):o(i))||i);return n&&i&&Ol(e,t,i),i};customElements.get("conversation-entry")||customElements.define("conversation-entry",un);customElements.get("ace-conversation-feed")||customElements.define("ace-conversation-feed",mt);customElements.get("conversation-group")||customElements.define("conversation-group",pn);customElements.get("ace-typing-state")||customElements.define("ace-typing-state",di);customElements.get("message-type-html")||customElements.define("message-type-html",dn);customElements.get("message-type-markdown")||customElements.define("message-type-markdown",bt);customElements.get("ace-lightbox")||customElements.define("ace-lightbox",xn);const Ci=ci(k);class O extends Ci{constructor(){super(...arguments),this.message="",this.disabledInput=!1,this.disabledSubmit=!1,this.chatOverlayActive=!1,this.textAreaLength=0,this.conversationContentRef=M(),this.conversationFeedRef=M(),this.formRef=M(),this.inputRef=M(),this.scrollRef=M(),this.counterRef=M(),this.chatScrollHeight=0,this.chatCurrentScrollPosition=0,this.toast=new Ta(this),this.messageMaxLength=1e3,this.messageMaxLengthLabel="Maximum character limit reached",this.skipToLatestMessageLabel="Skip to latest message",this.platform=null,this.entries=[],this.typing=!1,this.conversationState$=new U("waiting"),this.stateMachine=new Oa(this.conversationState$,this),this.provider$=this.stateMachine.session().pipe(pe(e=>e?e==null?void 0:e.provider$:It(null))),this.userTyping$=new _}async connectedCallback(){super.connectedCallback(),this.messageMaxLength=this.properties.messageMaxLength??this.messageMaxLength,this.messageMaxLengthLabel=this.properties.messageMaxLengthLabel??this.messageMaxLengthLabel,this.skipToLatestMessageLabel=this.properties.skipToLatestMessageLabel??this.skipToLatestMessageLabel;const e=await this.application.container.get("conversation");this.platform=e||null;const t=this.application.trigger;t&&t.widgetActive$.pipe(zt(t.componentIsDestroyed$)).subscribe(n=>{const i=this.conversationContentRef.value;i&&(n?i.scrollTop=this.chatCurrentScrollPosition:this.chatCurrentScrollPosition=i.scrollTop)}),this.stateSubscription=fr([this.stateMachine.entries(),this.stateMachine.isTyping()]).subscribe(([n,i])=>{this.entries=n,this.typing=i}),this.userSubmitSubscription=Ge(this,"user-submit").pipe(Ut(this.provider$)).subscribe(([n,i])=>{i&&i.onUserSubmit(n.detail)}),this._addHeaderOptions(),this.provider$.pipe(Ut(this.provider$)).subscribe(([n,i])=>{i&&i.showChatOverlay$.pipe().subscribe(r=>{this.chatOverlayActive=r})})}disconnectedCallback(){var e,t;super.disconnectedCallback(),(e=this.userSubmitSubscription)==null||e.unsubscribe(),(t=this.stateSubscription)==null||t.unsubscribe()}_actionHandler(e){}isTypingState(){var t,n;const e=(n=(t=this.conversationFeedRef.value)==null?void 0:t.shadowRoot)==null?void 0:n.querySelector(".conversation-feed");if(e){const i=e.lastElementChild;if(i&&i.tagName.toLowerCase()==="ace-typing-state")return!0}return!1}isAtBottom(){const e=this.conversationContentRef.value;return e?e.scrollHeight-e.scrollTop-e.clientHeight<1:!1}scrollToBottom(){var e,t;(!this.isTypingState()||this.isAtBottom())&&(setTimeout(()=>{var n;return(n=this.scrollRef.value)==null?void 0:n.scrollIntoView({behavior:"smooth"})},300),this.chatScrollHeight=(e=this.scrollRef.value)==null?void 0:e.scrollHeight,this.chatCurrentScrollPosition=(t=this.scrollRef.value)==null?void 0:t.scrollTop)}onSessionUpdated(){this.scrollToBottom()}disableInput(){this.disabledInput=!0}enableInput(){this.disabledInput=!1}disableSubmit(){this.disabledSubmit=!0}enableSubmit(){this.disabledSubmit=!1}clearMessages(){var i,r;const e=(i=this.shadowRoot)==null?void 0:i.querySelector("ace-conversation-feed"),t=(r=e==null?void 0:e.shadowRoot)==null?void 0:r.querySelector(".conversation-feed"),n=t==null?void 0:t.querySelectorAll(".conversation-entry");n==null||n.forEach(o=>o.remove())}setToastMessage(e){this.toast.message=e}async _onSendMessage(e){var n,i;if(e.preventDefault(),this.message.length<=0||this.message.length>this.messageMaxLength){(n=this.formRef.value)==null||n.classList.add("shake"),setTimeout(()=>{var r;(r=this.formRef.value)==null||r.classList.remove("shake")},500);return}this.message=this.message.slice(0,this.messageMaxLength);const t=new CustomEvent("user-submit",{detail:{text:this.message}});this.dispatchEvent(t),this.message="",this.textAreaLength=0,(i=this.counterRef.value)==null||i.classList.remove("max-char-count-reached"),this.inputRef.value.style.height=this.style.getPropertyValue("--textarea-default-height")}_addHeaderOptions(){const e=this.application.getComponent("widget-header");if(!e)return;const t=this.application.texts,n=t.getOrFallback("conversation.mute","Mute"),i=t.getOrFallback("conversation.unmute","Unmute"),r=!!this.application.storage.get("muteAudioNotifications"),o=e.addOption({label:r?i:n,icon:r?Hn.svg:Dn.svg,closeOnClick:!1,datatestid:"options-mute-button",onClick:()=>{!!this.application.storage.get("muteAudioNotifications")?(this.application.unmute(),o.updateLabel(n),o.updateIcon(Dn.svg)):(this.application.mute(),o.updateLabel(i),o.updateIcon(Hn.svg))}})}_inputHandler(e){var t,n;this.message=e.target.value,e.target.style.height=this.style.getPropertyValue("--textarea-default-height"),e.target.style.height=e.target.scrollHeight+"px",this.textAreaLength=e.target.value.length,e.target.value.length>this.messageMaxLength?(t=this.counterRef.value)==null||t.classList.add("max-char-count-reached"):(n=this.counterRef.value)==null||n.classList.remove("max-char-count-reached")}_keyDownHandler(e){this.userTyping$.next(e.key),e.key==="Enter"&&!e.shiftKey&&!this.disabledSubmit&&(this._onSendMessage(e),e.preventDefault())}skipToLatestMessage(){var n,i;const e=(n=this.conversationFeedRef)==null?void 0:n.value,t=(i=e==null?void 0:e.shadowRoot)==null?void 0:i.querySelectorAll(".conversation-entry");t.length&&Array.from(t).pop().focus()}handover(e,t){this.enableInput(),this.setToastMessage(null);const n=new CustomEvent("handover",{detail:{providerKey:e,providerOptions:t}});return this.dispatchEvent(n),n.detail.complete||Pe}render(){var i,r,o;const e=this.application.texts;this.conversationState$.value==="waiting"&&((i=this.application)!=null&&i.storage)&&this.platform&&(this.stateMachine.setStorage(this.application.storage),this.conversationState$.next("init"));const t=this.application.settings.components.conversation;return((o=(r=t==null?void 0:t.properties)==null?void 0:r.chat)==null?void 0:o.isThirdPartyWidget)&&(this.renderRoot.host.style.width="100%"),m` <div
|
786
800
|
@action=${this._actionHandler}
|
787
801
|
class=${ve({conversation:!0,disabled:this.disabledInput,"conversation--has-toast":this.toast.hasMessage(),"conversation--input-has-valid-text":this.message.length>0&&this.message.length<=this.messageMaxLength&&!this.disabledSubmit,"overlay-mode":this.chatOverlayActive})}
|
788
802
|
>
|
@@ -864,11 +878,12 @@ Please report this to https://github.com/markedjs/marked.`,e){const i="<p>An err
|
|
864
878
|
--textarea-default-height: 1.5rem;
|
865
879
|
--send-icon-opacity: 0.4;
|
866
880
|
--send-icon-color: var(--text-color);
|
867
|
-
--conversation-bg: var(--conversation-bg-color, #
|
881
|
+
--conversation-bg: var(--conversation-bg-color, #fff);
|
868
882
|
--agent-bg-color: var(
|
869
883
|
--conversation-agent-bg-color,
|
870
884
|
var(--secondary-background)
|
871
885
|
);
|
886
|
+
--conversation-border-color: var(--border-color-weak, #00000029);
|
872
887
|
--agent-text-color: var(
|
873
888
|
--conversation-agent-text-color,
|
874
889
|
var(--text-on-secondary-background)
|
@@ -882,8 +897,8 @@ Please report this to https://github.com/markedjs/marked.`,e){const i="<p>An err
|
|
882
897
|
var(--text-on-primary-background)
|
883
898
|
);
|
884
899
|
|
885
|
-
--content-border: var(--conversation-content-border,
|
886
|
-
--input-border: var(--conversation-input-border,
|
900
|
+
--content-border: var(--conversation-content-border, #00000054);
|
901
|
+
--input-border: var(--conversation-input-border, 1px solid #00000054);
|
887
902
|
--input-text-color: var(--conversation-input-text-color, inherit);
|
888
903
|
--conversation-input-bg: var(--conversation-input-bg-color, #fff);
|
889
904
|
|
@@ -984,7 +999,7 @@ Please report this to https://github.com/markedjs/marked.`,e){const i="<p>An err
|
|
984
999
|
overflow-y: auto;
|
985
1000
|
overflow-x: hidden;
|
986
1001
|
border-radius: var(--border-radius-sm);
|
987
|
-
border: var(--content-border);
|
1002
|
+
border: 1px solid var(--content-border);
|
988
1003
|
position: relative;
|
989
1004
|
}
|
990
1005
|
.conversation-bottom {
|
package/index.mjs
CHANGED
@@ -1301,17 +1301,17 @@ class wr {
|
|
1301
1301
|
constructor(e) {
|
1302
1302
|
this.name = e, this.print$ = new _();
|
1303
1303
|
}
|
1304
|
-
print(e, t = "html") {
|
1305
|
-
const
|
1304
|
+
print(e, t = "html", n = this.name) {
|
1305
|
+
const i = new ct(
|
1306
1306
|
Z.Agent,
|
1307
|
-
{ name:
|
1307
|
+
{ name: n },
|
1308
1308
|
[
|
1309
1309
|
{
|
1310
1310
|
items: [[t, { content: e }]]
|
1311
1311
|
}
|
1312
1312
|
]
|
1313
1313
|
);
|
1314
|
-
return this.print$.next(
|
1314
|
+
return this.print$.next(i), i;
|
1315
1315
|
}
|
1316
1316
|
subscribe() {
|
1317
1317
|
return this.print$.asObservable();
|
@@ -3609,8 +3609,10 @@ class ln extends k {
|
|
3609
3609
|
this.applyBranding(), this.applyStyles();
|
3610
3610
|
}
|
3611
3611
|
render() {
|
3612
|
-
|
3613
|
-
|
3612
|
+
var n, i;
|
3613
|
+
const e = this.application.settings.components.conversation;
|
3614
|
+
return ((i = (n = e == null ? void 0 : e.properties) == null ? void 0 : n.chat) == null ? void 0 : i.isThirdPartyWidget) ? this.renderRoot.host.classList.add("third-party") : this.application.renderStrategy === an.Trigger && (this.renderRoot.host.classList.add("floating"), this.application.anchor === "BottomLeft" ? this.renderRoot.host.classList.add("bottom-left") : this.application.anchor === "BottomRight" && this.renderRoot.host.classList.add("bottom-right")), m`<div class="widget-container" ${z(this.wrapperRef)}>
|
3615
|
+
${ma(this.nodes, (r) => r)}
|
3614
3616
|
</div>`;
|
3615
3617
|
}
|
3616
3618
|
}
|
@@ -3661,6 +3663,10 @@ ln.styles = E`
|
|
3661
3663
|
inset: 0 0 95px 0;
|
3662
3664
|
height: 100%;
|
3663
3665
|
}
|
3666
|
+
:host(.third-party) {
|
3667
|
+
inset: 0 0 95px 0;
|
3668
|
+
height: 100vh;
|
3669
|
+
}
|
3664
3670
|
}
|
3665
3671
|
@media screen and (min-width: 801px) {
|
3666
3672
|
:host(.floating) {
|
@@ -3669,6 +3675,14 @@ ln.styles = E`
|
|
3669
3675
|
width: 400px;
|
3670
3676
|
height: 700px;
|
3671
3677
|
}
|
3678
|
+
:host(.third-party) {
|
3679
|
+
max-width: 1000px;
|
3680
|
+
height: 100vh;
|
3681
|
+
position: relative;
|
3682
|
+
left: 50%;
|
3683
|
+
transform: translateX(-50%);
|
3684
|
+
margin: -10px 0;
|
3685
|
+
}
|
3672
3686
|
:host(.floating.bottom-right) {
|
3673
3687
|
inset: auto 20px 95px auto;
|
3674
3688
|
}
|
@@ -3694,6 +3708,8 @@ ln.styles = E`
|
|
3694
3708
|
background-color: var(--primary-background);
|
3695
3709
|
padding: var(--spacing-sm);
|
3696
3710
|
border: var(--widget-border, none);
|
3711
|
+
border-left: 1px solid #00000054;
|
3712
|
+
border-right: 1px solid #00000054;
|
3697
3713
|
}
|
3698
3714
|
@keyframes slideDown {
|
3699
3715
|
from {
|
@@ -6276,9 +6292,11 @@ class R extends _i {
|
|
6276
6292
|
return this.dispatchEvent(n), n.detail.complete || Pe;
|
6277
6293
|
}
|
6278
6294
|
render() {
|
6279
|
-
var
|
6295
|
+
var i, r, o;
|
6280
6296
|
const e = this.application.texts;
|
6281
|
-
|
6297
|
+
this.conversationState$.value === "waiting" && ((i = this.application) != null && i.storage) && this.platform && (this.stateMachine.setStorage(this.application.storage), this.conversationState$.next("init"));
|
6298
|
+
const t = this.application.settings.components.conversation;
|
6299
|
+
return ((o = (r = t == null ? void 0 : t.properties) == null ? void 0 : r.chat) == null ? void 0 : o.isThirdPartyWidget) && (this.renderRoot.host.style.width = "100%"), m` <div
|
6282
6300
|
@action=${this._actionHandler}
|
6283
6301
|
class=${ve({
|
6284
6302
|
conversation: !0,
|
@@ -6377,11 +6395,12 @@ R.styles = [
|
|
6377
6395
|
--textarea-default-height: 1.5rem;
|
6378
6396
|
--send-icon-opacity: 0.4;
|
6379
6397
|
--send-icon-color: var(--text-color);
|
6380
|
-
--conversation-bg: var(--conversation-bg-color, #
|
6398
|
+
--conversation-bg: var(--conversation-bg-color, #fff);
|
6381
6399
|
--agent-bg-color: var(
|
6382
6400
|
--conversation-agent-bg-color,
|
6383
6401
|
var(--secondary-background)
|
6384
6402
|
);
|
6403
|
+
--conversation-border-color: var(--border-color-weak, #00000029);
|
6385
6404
|
--agent-text-color: var(
|
6386
6405
|
--conversation-agent-text-color,
|
6387
6406
|
var(--text-on-secondary-background)
|
@@ -6395,8 +6414,8 @@ R.styles = [
|
|
6395
6414
|
var(--text-on-primary-background)
|
6396
6415
|
);
|
6397
6416
|
|
6398
|
-
--content-border: var(--conversation-content-border,
|
6399
|
-
--input-border: var(--conversation-input-border,
|
6417
|
+
--content-border: var(--conversation-content-border, #00000054);
|
6418
|
+
--input-border: var(--conversation-input-border, 1px solid #00000054);
|
6400
6419
|
--input-text-color: var(--conversation-input-text-color, inherit);
|
6401
6420
|
--conversation-input-bg: var(--conversation-input-bg-color, #fff);
|
6402
6421
|
|
@@ -6497,7 +6516,7 @@ R.styles = [
|
|
6497
6516
|
overflow-y: auto;
|
6498
6517
|
overflow-x: hidden;
|
6499
6518
|
border-radius: var(--border-radius-sm);
|
6500
|
-
border: var(--content-border);
|
6519
|
+
border: 1px solid var(--content-border);
|
6501
6520
|
position: relative;
|
6502
6521
|
}
|
6503
6522
|
.conversation-bottom {
|
package/models/agent.d.ts
CHANGED
@@ -3,6 +3,6 @@ export declare class Agent {
|
|
3
3
|
name: string;
|
4
4
|
private print$;
|
5
5
|
constructor(name: string);
|
6
|
-
print(text: string, type?: string): ConversationEntry;
|
6
|
+
print(text: string, type?: string, alias?: string): ConversationEntry;
|
7
7
|
subscribe(): import("rxjs").Observable<ConversationEntry>;
|
8
8
|
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@telia-ace/widget-conversation-flamingo",
|
3
|
-
"version": "1.1.72-rc.
|
3
|
+
"version": "1.1.72-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.72-rc.
|
12
|
+
"@telia-ace/widget-core-flamingo": "1.1.72-rc.2",
|
13
13
|
"lit-html": "^3.0.2",
|
14
14
|
"rxjs": "^7.8.1",
|
15
15
|
"marked": "^12.0.2"
|