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