@telia-ace/widget-conversation-flamingo 1.1.76-rc.5 → 1.1.76-rc.51
Sign up to get free protection for your applications and to get access to all the features.
- package/conversation-utilities.d.ts +1 -1
- package/conversation.d.ts +2 -0
- package/index.js +25 -20
- package/index.mjs +162 -136
- package/package.json +2 -2
- package/widget-manifest.json +14 -0
package/conversation.d.ts
CHANGED
@@ -11,6 +11,7 @@ export declare class Conversation extends WidgetElement {
|
|
11
11
|
disabledSubmit: boolean;
|
12
12
|
chatOverlayActive: boolean;
|
13
13
|
textAreaLength: number;
|
14
|
+
private isMuted;
|
14
15
|
conversationContentRef: Ref<HTMLDivElement>;
|
15
16
|
conversationFeedRef: Ref<HTMLDivElement>;
|
16
17
|
formRef: Ref<HTMLFormElement>;
|
@@ -54,6 +55,7 @@ export declare class Conversation extends WidgetElement {
|
|
54
55
|
_keyDownHandler(e: KeyboardEvent): void;
|
55
56
|
skipToLatestMessage(): void;
|
56
57
|
handover(providerKey: string, providerOptions: Record<string, any>): Observable<void>;
|
58
|
+
firstUpdated(): void;
|
57
59
|
render(): import("lit-html").TemplateResult<1>;
|
58
60
|
}
|
59
61
|
export default Conversation;
|
package/index.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
"use strict";var
|
1
|
+
"use strict";var Ti=Object.defineProperty;var Li=(s,e,t)=>e in s?Ti(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var x=(s,e,t)=>(Li(s,typeof e!="symbol"?e+"":e,t),t),Oi=(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 Be=(s,e,t)=>(Oi(s,e,"access private method"),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Pi=async s=>{s.registerComponent("conversation",Promise.resolve().then(()=>jl))};class Wt{constructor(){this.registeredProviders=new Map}static async getInstance(e){let t=await e.get("conversation");return t||(t=new Wt,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 ye(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 Ri(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 gs(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 me(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 Q(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 se(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 pe(s){return this instanceof pe?(this.v=s,this):new pe(s)}function Ii(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 pe?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 Mi(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 me=="function"?me(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 ms(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=ms(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=me(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=me(u),d=p.next();!d.done;d=p.next()){var b=d.value;try{Sn(b)}catch(f){r=r??[],f instanceof xt?r=se(se([],Q(r)),Q(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)Sn(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}(),vs=lt.EMPTY;function bs(s){return s instanceof lt||s&&"closed"in s&&$(s.remove)&&$(s.add)&&$(s.unsubscribe)}function Sn(s){$(s)?s():s.unsubscribe()}var ys={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,se([s,e],Q(t))):setTimeout.apply(void 0,se([s,e],Q(t)))},clearTimeout:function(s){var e=Pt.delegate;return((e==null?void 0:e.clearTimeout)||clearTimeout)(s)},delegate:void 0};function $s(s){Pt.setTimeout(function(){throw s})}function Qe(){}function We(s){s()}var Yt=function(s){ye(e,s);function e(t){var n=s.call(this)||this;return n.isStopped=!1,t?(n.destination=t,bs(t)&&t.add(n)):n.destination=Hi,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),Ui=Function.prototype.bind;function wt(s,e){return Ui.call(s,e)}var ji=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){Ne(n)}},s.prototype.error=function(e){var t=this.partialObserver;if(t.error)try{t.error(e)}catch(n){Ne(n)}else Ne(e)},s.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(t){Ne(t)}},s}(),Rt=function(s){ye(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&&ys.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 ji(o),r}return e}(Yt);function Ne(s){$s(s)}function Di(s){throw s}var Hi={closed:!0,next:Qe,error:Di,complete:Qe},Qt=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function Pe(s){return s}function Bi(s){return s.length===0?Pe: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=Fi(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=Cn(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[Qt]=function(){return this},s.prototype.pipe=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Bi(e)(this)},s.prototype.toPromise=function(e){var t=this;return e=Cn(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 Cn(s){var e;return(e=s??ys.Promise)!==null&&e!==void 0?e:Promise}function Ni(s){return s&&$(s.next)&&$(s.error)&&$(s.complete)}function Fi(s){return s&&s instanceof Yt||Ni(s)&&bs(s)}function qi(s){return $(s==null?void 0:s.lift)}function K(s){return function(e){if(qi(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 Zi(s,e,t,n,i)}var Zi=function(s){ye(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}(Yt),Wi=ms(function(s){return function(){s(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),_=function(s){ye(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 An(this,this);return n.operator=t,n},e.prototype._throwIfClosed=function(){if(this.closed)throw new Wi},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=me(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?vs:(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 An(t,n)},e}(A),An=function(s){ye(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:vs},e}(_),U=function(s){ye(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}(_),Re=new A(function(s){return s.complete()});function Yi(s){return s&&$(s.schedule)}function Gt(s){return s[s.length-1]}function xs(s){return $(Gt(s))?s.pop():void 0}function Kt(s){return Yi(Gt(s))?s.pop():void 0}function Qi(s,e){return typeof Gt(s)=="number"?s.pop():e}var Xt=function(s){return s&&typeof s.length=="number"&&typeof s!="function"};function ws(s){return $(s==null?void 0:s.then)}function ks(s){return $(s[Qt])}function _s(s){return Symbol.asyncIterator&&$(s==null?void 0:s[Symbol.asyncIterator])}function Ss(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 Gi(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var Cs=Gi();function As(s){return $(s==null?void 0:s[Cs])}function Es(s){return Mi(this,arguments,function(){var t,n,i,r;return gs(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,pe(t.read())];case 3:return n=o.sent(),i=n.value,r=n.done,r?[4,pe(void 0)]:[3,5];case 4:return[2,o.sent()];case 5:return[4,pe(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 Ts(s){return $(s==null?void 0:s.getReader)}function B(s){if(s instanceof A)return s;if(s!=null){if(ks(s))return Ki(s);if(Xt(s))return Xi(s);if(ws(s))return Vi(s);if(_s(s))return Ls(s);if(As(s))return Ji(s);if(Ts(s))return er(s)}throw Ss(s)}function Ki(s){return new A(function(e){var t=s[Qt]();if($(t.subscribe))return t.subscribe(e);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function Xi(s){return new A(function(e){for(var t=0;t<s.length&&!e.closed;t++)e.next(s[t]);e.complete()})}function Vi(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,$s)})}function Ji(s){return new A(function(e){var t,n;try{for(var i=me(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 Ls(s){return new A(function(e){tr(s,e).catch(function(t){return e.error(t)})})}function er(s){return Ls(Es(s))}function tr(s,e){var t,n,i,r;return Ii(this,void 0,void 0,function(){var o,a;return gs(this,function(l){switch(l.label){case 0:l.trys.push([0,5,6,11]),t=zi(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 q(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 Os(s,e){return e===void 0&&(e=0),K(function(t,n){t.subscribe(R(n,function(i){return q(n,s,function(){return n.next(i)},e)},function(){return q(n,s,function(){return n.complete()},e)},function(i){return q(n,s,function(){return n.error(i)},e)}))})}function Ps(s,e){return e===void 0&&(e=0),K(function(t,n){n.add(s.schedule(function(){return t.subscribe(n)},e))})}function nr(s,e){return B(s).pipe(Ps(e),Os(e))}function sr(s,e){return B(s).pipe(Ps(e),Os(e))}function ir(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 rr(s,e){return new A(function(t){var n;return q(t,e,function(){n=s[Cs](),q(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 Rs(s,e){if(!s)throw new Error("Iterable cannot be null");return new A(function(t){q(t,e,function(){var n=s[Symbol.asyncIterator]();q(t,e,function(){n.next().then(function(i){i.done?t.complete():t.next(i.value)})},0,!0)})})}function or(s,e){return Rs(Es(s),e)}function ar(s,e){if(s!=null){if(ks(s))return nr(s,e);if(Xt(s))return ir(s,e);if(ws(s))return sr(s,e);if(_s(s))return Rs(s,e);if(As(s))return rr(s,e);if(Ts(s))return or(s,e)}throw Ss(s)}function ct(s,e){return e?ar(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 Ge(s,e){return K(function(t,n){var i=0;t.subscribe(R(n,function(r){n.next(s.call(e,r,i++))}))})}var lr=Array.isArray;function cr(s,e){return lr(e)?s.apply(void 0,se([],Q(e))):s(e)}function Is(s){return Ge(function(e){return cr(s,e)})}var hr=Array.isArray,ur=Object.getPrototypeOf,pr=Object.prototype,dr=Object.keys;function fr(s){if(s.length===1){var e=s[0];if(hr(e))return{args:e,keys:null};if(gr(e)){var t=dr(e);return{args:t.map(function(n){return e[n]}),keys:t}}}return{args:s,keys:null}}function gr(s){return s&&typeof s=="object"&&ur(s)===pr}function mr(s,e){return s.reduce(function(t,n,i){return t[n]=e[i],t},{})}function vr(){for(var s=[],e=0;e<arguments.length;e++)s[e]=arguments[e];var t=Kt(s),n=xs(s),i=fr(s),r=i.args,o=i.keys;if(r.length===0)return ct([],t);var a=new A(br(r,t,o?function(l){return mr(o,l)}:Pe));return n?a.pipe(Is(n)):a}function br(s,e,t){return t===void 0&&(t=Pe),function(n){En(e,function(){for(var i=s.length,r=new Array(i),o=i,a=i,l=function(h){En(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 En(s,e,t){s?q(t,s,e):e()}function yr(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 J=l.shift();o?q(e,o,function(){return b(J)}):b(J)};l.length&&c<n;)N();p()}catch(J){e.error(J)}}))};return s.subscribe(R(e,d,function(){u=!0,p()})),function(){a==null||a()}}function Vt(s,e,t){return t===void 0&&(t=1/0),$(e)?Vt(function(n,i){return Ge(function(r,o){return e(n,r,i,o)})(B(s(n,i)))},t):(typeof e=="number"&&(t=e),K(function(n,i){return yr(n,i,s,t)}))}function $r(s){return s===void 0&&(s=1/0),Vt(Pe,s)}var xr=["addListener","removeListener"],wr=["addEventListener","removeEventListener"],kr=["on","off"];function Ke(s,e,t,n){if($(t)&&(n=t,t=void 0),n)return Ke(s,e,t).pipe(Is(n));var i=Q(Cr(s)?wr.map(function(a){return function(l){return s[a](e,l,t)}}):_r(s)?xr.map(Tn(s,e)):Sr(s)?kr.map(Tn(s,e)):[],2),r=i[0],o=i[1];if(!r&&Xt(s))return Vt(function(a){return Ke(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 Tn(s,e){return function(t){return function(n){return s[t](e,n)}}}function _r(s){return $(s.addListener)&&$(s.removeListener)}function Sr(s){return $(s.on)&&$(s.off)}function Cr(s){return $(s.addEventListener)&&$(s.removeEventListener)}function Ar(){for(var s=[],e=0;e<arguments.length;e++)s[e]=arguments[e];var t=Kt(s),n=Qi(s,1/0),i=s;return i.length?i.length===1?B(i[0]):$r(n)(ct(i,t)):Re}function Mt(s){return s<=0?function(){return Re}:K(function(e,t){var n=0;e.subscribe(R(t,function(i){++n<=s&&(t.next(i),s<=n&&t.complete())}))})}function de(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=xs(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(Pe))&&(a=null))},Qe))},h=0;h<r;h++)c(h);n.subscribe(R(i,function(u){if(l){var p=se([u],Q(o));i.next(t?t.apply(void 0,se([],Q(p))):p)}}))})}var Z=(s=>(s.User="user",s.Agent="agent",s.System="system",s))(Z||{});const Ms=()=>crypto.randomUUID();function Er(s){let e=s;const t=/https?:\/\/[^\s<]+/gi,n=/<a [^>]*href="([^"]*)"[^>]*>[^<]*<\/a>/g,i=s.match(t)||[],r=[];let o;for(;(o=n.exec(s))!==null;)r.push(o[1]);return i.filter(l=>!r.includes(l)).forEach(l=>{const c=l.endsWith(".")?l.slice(0,-1):l,h=new RegExp(`(?<!<a[^>]*>)${c.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}(?![^<]*</a>)`,"gi");e=e.replace(h,`<a title='${c}' target='_blank' href='${c}'>${c}</a>`)}),e}function zs(s){if(s.includes("aceChatGuideTitle"))return Tr(s);const e=/<a [^>]*>https?:\/\/[^<]*<\/a>/gim;return s.replace(e,t=>{const n=Us(t);if(!n)return t;const i=50;if(n.length>i){const r=/^(https?:\/\/[^/]+)(\/.*)?$/i,o=n.match(r);if(!o)return t;const a=o[1],c=(o[2]||"/").split("?")[0],h=c.split("/").pop(),u=i-a.length;let p=c;h&&h.length<u&&c.length>u?p=c.substring(0,u-h.length-4)+".../"+h:p=c.substring(0,u-3)+"...";const d=`${a}${p}`;return jt(t,d)}return jt(t,n)})}function Us(s){const e=s.match(/href=["']([^'"]*)["']/);if(e&&e.length>1){let t=e[1];return t.endsWith(".")&&(t=t.slice(0,-1)),t}return null}function jt(s,e){return s.replace(/>[^<]*<\/a>/,`>${e}</a>`)}function Tr(s){const e=/<a [^>]*aceChatGuideTitle[^>]*>[^<]*<\/a>/gm;return s.replace(e,t=>{const n=Us(t);if(!n)return t;const i=n.split("?").pop(),o=new URLSearchParams(i).get("aceChatGuideTitle");return o?jt(t,o):t})}class Ie{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=Ms()}update(e){this.messages=[{items:e}],this.didUpdate.next(this)}setStatus(e){this.status=e,this.didUpdate.next(this)}remove(){this.remove$.next()}}class js{constructor(e){this.name=e,this.print$=new _}print(e,t="html",n=this.name){const i=new Ie(Z.Agent,{name:n},[{items:[[t,{content:e}]]}]);return this.print$.next(i),i}subscribe(){return this.print$.asObservable()}}class Ds{constructor(e){this.name=e,this.print$=new _}print(e){const t=new Ie(Z.User,{name:this.name},[{items:[["html",{content:e}]]}]);return this.print$.next(t),t}subscribe(){return this.print$.asObservable()}}class Lr{constructor(){this.print$=new _,this.name="system"}print(e){const t=new Ie(Z.System,{name:this.name},[{items:[["html",{content:e}]]}]);return this.print$.next(t),t}subscribe(){return this.print$.asObservable()}}class Or{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(Z.User,e.text)}print(e,t){const n=new Ie(e,{name:""},[{items:[["html",{content:t}]]}]);return this.printEntry(n)}printEntry(e){return this.print$.next(e),e}createAgent(e){const t=new js(e);return t.subscribe().subscribe(n=>{this.playNotification(),this.printEntry(n)}),t}createUser(e){const t=new Ds(e);return t.subscribe().subscribe(n=>{this.printEntry(n)}),t}createSystem(){const e=new Lr;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=me(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=me(u),d=p.next();!d.done;d=p.next()){var b=d.value;try{Sn(b)}catch(f){r=r??[],f instanceof xt?r=se(se([],Q(r)),Q(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)Sn(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}(),vs=lt.EMPTY;function bs(s){return s instanceof lt||s&&"closed"in s&&$(s.remove)&&$(s.add)&&$(s.unsubscribe)}function Sn(s){$(s)?s():s.unsubscribe()}var ys={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,se([s,e],Q(t))):setTimeout.apply(void 0,se([s,e],Q(t)))},clearTimeout:function(s){var e=Pt.delegate;return((e==null?void 0:e.clearTimeout)||clearTimeout)(s)},delegate:void 0};function $s(s){Pt.setTimeout(function(){throw s})}function Qe(){}function We(s){s()}var Yt=function(s){ye(e,s);function e(t){var n=s.call(this)||this;return n.isStopped=!1,t?(n.destination=t,bs(t)&&t.add(n)):n.destination=Di,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),zi=Function.prototype.bind;function wt(s,e){return zi.call(s,e)}var Ui=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){Ne(n)}},s.prototype.error=function(e){var t=this.partialObserver;if(t.error)try{t.error(e)}catch(n){Ne(n)}else Ne(e)},s.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(t){Ne(t)}},s}(),Rt=function(s){ye(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&&ys.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 Ui(o),r}return e}(Yt);function Ne(s){$s(s)}function ji(s){throw s}var Di={closed:!0,next:Qe,error:ji,complete:Qe},Qt=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function Pe(s){return s}function Hi(s){return s.length===0?Pe: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=Ni(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=Cn(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[Qt]=function(){return this},s.prototype.pipe=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Hi(e)(this)},s.prototype.toPromise=function(e){var t=this;return e=Cn(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 Cn(s){var e;return(e=s??ys.Promise)!==null&&e!==void 0?e:Promise}function Bi(s){return s&&$(s.next)&&$(s.error)&&$(s.complete)}function Ni(s){return s&&s instanceof Yt||Bi(s)&&bs(s)}function Fi(s){return $(s==null?void 0:s.lift)}function K(s){return function(e){if(Fi(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 qi(s,e,t,n,i)}var qi=function(s){ye(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}(Yt),Zi=ms(function(s){return function(){s(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),_=function(s){ye(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 An(this,this);return n.operator=t,n},e.prototype._throwIfClosed=function(){if(this.closed)throw new Zi},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=me(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?vs:(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 An(t,n)},e}(A),An=function(s){ye(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:vs},e}(_),U=function(s){ye(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}(_),Re=new A(function(s){return s.complete()});function Wi(s){return s&&$(s.schedule)}function Gt(s){return s[s.length-1]}function xs(s){return $(Gt(s))?s.pop():void 0}function Kt(s){return Wi(Gt(s))?s.pop():void 0}function Yi(s,e){return typeof Gt(s)=="number"?s.pop():e}var Xt=function(s){return s&&typeof s.length=="number"&&typeof s!="function"};function ws(s){return $(s==null?void 0:s.then)}function ks(s){return $(s[Qt])}function _s(s){return Symbol.asyncIterator&&$(s==null?void 0:s[Symbol.asyncIterator])}function Ss(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 Qi(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var Cs=Qi();function As(s){return $(s==null?void 0:s[Cs])}function Es(s){return Ii(this,arguments,function(){var t,n,i,r;return gs(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,pe(t.read())];case 3:return n=o.sent(),i=n.value,r=n.done,r?[4,pe(void 0)]:[3,5];case 4:return[2,o.sent()];case 5:return[4,pe(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 Ts(s){return $(s==null?void 0:s.getReader)}function B(s){if(s instanceof A)return s;if(s!=null){if(ks(s))return Gi(s);if(Xt(s))return Ki(s);if(ws(s))return Xi(s);if(_s(s))return Ls(s);if(As(s))return Vi(s);if(Ts(s))return Ji(s)}throw Ss(s)}function Gi(s){return new A(function(e){var t=s[Qt]();if($(t.subscribe))return t.subscribe(e);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function Ki(s){return new A(function(e){for(var t=0;t<s.length&&!e.closed;t++)e.next(s[t]);e.complete()})}function Xi(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,$s)})}function Vi(s){return new A(function(e){var t,n;try{for(var i=me(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 Ls(s){return new A(function(e){er(s,e).catch(function(t){return e.error(t)})})}function Ji(s){return Ls(Es(s))}function er(s,e){var t,n,i,r;return Ri(this,void 0,void 0,function(){var o,a;return gs(this,function(l){switch(l.label){case 0:l.trys.push([0,5,6,11]),t=Mi(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 q(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 Os(s,e){return e===void 0&&(e=0),K(function(t,n){t.subscribe(R(n,function(i){return q(n,s,function(){return n.next(i)},e)},function(){return q(n,s,function(){return n.complete()},e)},function(i){return q(n,s,function(){return n.error(i)},e)}))})}function Ps(s,e){return e===void 0&&(e=0),K(function(t,n){n.add(s.schedule(function(){return t.subscribe(n)},e))})}function tr(s,e){return B(s).pipe(Ps(e),Os(e))}function nr(s,e){return B(s).pipe(Ps(e),Os(e))}function sr(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 ir(s,e){return new A(function(t){var n;return q(t,e,function(){n=s[Cs](),q(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 Rs(s,e){if(!s)throw new Error("Iterable cannot be null");return new A(function(t){q(t,e,function(){var n=s[Symbol.asyncIterator]();q(t,e,function(){n.next().then(function(i){i.done?t.complete():t.next(i.value)})},0,!0)})})}function rr(s,e){return Rs(Es(s),e)}function or(s,e){if(s!=null){if(ks(s))return tr(s,e);if(Xt(s))return sr(s,e);if(ws(s))return nr(s,e);if(_s(s))return Rs(s,e);if(As(s))return ir(s,e);if(Ts(s))return rr(s,e)}throw Ss(s)}function ct(s,e){return e?or(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 Ge(s,e){return K(function(t,n){var i=0;t.subscribe(R(n,function(r){n.next(s.call(e,r,i++))}))})}var ar=Array.isArray;function lr(s,e){return ar(e)?s.apply(void 0,se([],Q(e))):s(e)}function Is(s){return Ge(function(e){return lr(s,e)})}var cr=Array.isArray,hr=Object.getPrototypeOf,ur=Object.prototype,pr=Object.keys;function dr(s){if(s.length===1){var e=s[0];if(cr(e))return{args:e,keys:null};if(fr(e)){var t=pr(e);return{args:t.map(function(n){return e[n]}),keys:t}}}return{args:s,keys:null}}function fr(s){return s&&typeof s=="object"&&hr(s)===ur}function gr(s,e){return s.reduce(function(t,n,i){return t[n]=e[i],t},{})}function mr(){for(var s=[],e=0;e<arguments.length;e++)s[e]=arguments[e];var t=Kt(s),n=xs(s),i=dr(s),r=i.args,o=i.keys;if(r.length===0)return ct([],t);var a=new A(vr(r,t,o?function(l){return gr(o,l)}:Pe));return n?a.pipe(Is(n)):a}function vr(s,e,t){return t===void 0&&(t=Pe),function(n){En(e,function(){for(var i=s.length,r=new Array(i),o=i,a=i,l=function(h){En(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 En(s,e,t){s?q(t,s,e):e()}function br(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 J=l.shift();o?q(e,o,function(){return b(J)}):b(J)};l.length&&c<n;)N();p()}catch(J){e.error(J)}}))};return s.subscribe(R(e,d,function(){u=!0,p()})),function(){a==null||a()}}function Vt(s,e,t){return t===void 0&&(t=1/0),$(e)?Vt(function(n,i){return Ge(function(r,o){return e(n,r,i,o)})(B(s(n,i)))},t):(typeof e=="number"&&(t=e),K(function(n,i){return br(n,i,s,t)}))}function yr(s){return s===void 0&&(s=1/0),Vt(Pe,s)}var $r=["addListener","removeListener"],xr=["addEventListener","removeEventListener"],wr=["on","off"];function Ke(s,e,t,n){if($(t)&&(n=t,t=void 0),n)return Ke(s,e,t).pipe(Is(n));var i=Q(Sr(s)?xr.map(function(a){return function(l){return s[a](e,l,t)}}):kr(s)?$r.map(Tn(s,e)):_r(s)?wr.map(Tn(s,e)):[],2),r=i[0],o=i[1];if(!r&&Xt(s))return Vt(function(a){return Ke(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 Tn(s,e){return function(t){return function(n){return s[t](e,n)}}}function kr(s){return $(s.addListener)&&$(s.removeListener)}function _r(s){return $(s.on)&&$(s.off)}function Sr(s){return $(s.addEventListener)&&$(s.removeEventListener)}function Cr(){for(var s=[],e=0;e<arguments.length;e++)s[e]=arguments[e];var t=Kt(s),n=Yi(s,1/0),i=s;return i.length?i.length===1?B(i[0]):yr(n)(ct(i,t)):Re}function Mt(s){return s<=0?function(){return Re}:K(function(e,t){var n=0;e.subscribe(R(t,function(i){++n<=s&&(t.next(i),s<=n&&t.complete())}))})}function de(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=xs(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(Pe))&&(a=null))},Qe))},h=0;h<r;h++)c(h);n.subscribe(R(i,function(u){if(l){var p=se([u],Q(o));i.next(t?t.apply(void 0,se([],Q(p))):p)}}))})}var Z=(s=>(s.User="user",s.Agent="agent",s.System="system",s))(Z||{});const Ar=()=>"10000000-1000-4000-8000-100000000000".replace(/[018]/g,s=>(+s^crypto.getRandomValues(new Uint8Array(1))[0]&15>>+s/4).toString(16)),Ms=()=>typeof crypto.randomUUID=="function"?crypto.randomUUID():Ar();function Er(s){let e=s;const t=/https?:\/\/[^\s<]+/gi,n=/<a [^>]*href="([^"]*)"[^>]*>[^<]*<\/a>/g,i=s.match(t)||[],r=[];let o;for(;(o=n.exec(s))!==null;)r.push(o[1]);return i.filter(l=>!r.includes(l)).forEach(l=>{const c=l.endsWith(".")?l.slice(0,-1):l,h=new RegExp(`(?<!<a[^>]*>)${c.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}(?![^<]*</a>)`,"gi");e=e.replace(h,`<a title='${c}' target='_blank' href='${c}'>${c}</a>`)}),e}function zs(s){if(s.includes("aceChatGuideTitle"))return Tr(s);const e=/<a [^>]*>https?:\/\/[^<]*<\/a>/gim;return s.replace(e,t=>{const n=Us(t);if(!n)return t;const i=50;if(n.length>i){const r=/^(https?:\/\/[^/]+)(\/.*)?$/i,o=n.match(r);if(!o)return t;const a=o[1],c=(o[2]||"/").split("?")[0],h=c.split("/").pop(),u=i-a.length;let p=c;h&&h.length<u&&c.length>u?p=c.substring(0,u-h.length-4)+".../"+h:p=c.substring(0,u-3)+"...";const d=`${a}${p}`;return jt(t,d)}return jt(t,n)})}function Us(s){const e=s.match(/href=["']([^'"]*)["']/);if(e&&e.length>1){let t=e[1];return t.endsWith(".")&&(t=t.slice(0,-1)),t}return null}function jt(s,e){return s.replace(/>[^<]*<\/a>/,`>${e}</a>`)}function Tr(s){const e=/<a [^>]*aceChatGuideTitle[^>]*>[^<]*<\/a>/gm;return s.replace(e,t=>{const n=Us(t);if(!n)return t;const i=n.split("?").pop(),o=new URLSearchParams(i).get("aceChatGuideTitle");return o?jt(t,o):t})}class Ie{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=Ms()}update(e){this.messages=[{items:e}],this.didUpdate.next(this)}setStatus(e){this.status=e,this.didUpdate.next(this)}remove(){this.remove$.next()}}class js{constructor(e){this.name=e,this.print$=new _}print(e,t="html",n=this.name){const i=new Ie(Z.Agent,{name:n},[{items:[[t,{content:e}]]}]);return this.print$.next(i),i}subscribe(){return this.print$.asObservable()}}class Ds{constructor(e){this.name=e,this.print$=new _}print(e){const t=new Ie(Z.User,{name:this.name},[{items:[["html",{content:e}]]}]);return this.print$.next(t),t}subscribe(){return this.print$.asObservable()}}class Lr{constructor(){this.print$=new _,this.name="system"}print(e){const t=new Ie(Z.System,{name:this.name},[{items:[["html",{content:e}]]}]);return this.print$.next(t),t}subscribe(){return this.print$.asObservable()}}class Or{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(Z.User,e.text)}print(e,t){const n=new Ie(e,{name:""},[{items:[["html",{content:t}]]}]);return this.printEntry(n)}printEntry(e){return this.print$.next(e),e}createAgent(e){const t=new js(e);return t.subscribe().subscribe(n=>{this.playNotification(),this.printEntry(n)}),t}createUser(e){const t=new Ds(e);return t.subscribe().subscribe(n=>{this.printEntry(n)}),t}createSystem(){const e=new Lr;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=!document.hidden&&this.component.application.storage.get("open"),t="https://publicpoc.blob.core.windows.net/widget-assets/notification.mp3";!this.component.application.storage.get("muteAudioNotifications")&&!e&&new Audio(t).play().catch(i=>{})}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
|
@@ -62,7 +62,7 @@
|
|
62
62
|
bottom: 20px;
|
63
63
|
left: 20px;
|
64
64
|
}
|
65
|
-
`];pa([w({attribute:!0})],ln.prototype,"anchor",2);const da=new WeakMap;let es=0;const Et=new Map,ts=new WeakSet,ns=()=>new Promise(s=>requestAnimationFrame(s)),fa=[{transform:"translateX(100%) scale(0)",opacity:0}],ga=[{opacity:0}],ss=[{opacity:0},{opacity:1}],is=(s,e)=>{const t=s-e;return t===0?void 0:t},rs=(s,e)=>{const t=s/e;return t===1?void 0:t},Tt={left:(s,e)=>{const t=is(s,e);return{value:t,transform:t==null||isNaN(t)?void 0:`translateX(${t}px)`}},top:(s,e)=>{const t=is(s,e);return{value:t,transform:t==null||isNaN(t)?void 0:`translateY(${t}px)`}},width:(s,e)=>{let t;e===0&&(e=1,t={width:"1px"});const n=rs(s,e);return{value:n,overrideFrom:t,transform:n==null||isNaN(n)?void 0:`scaleX(${n})`}},height:(s,e)=>{let t;e===0&&(e=1,t={height:"1px"});const n=rs(s,e);return{value:n,overrideFrom:t,transform:n==null||isNaN(n)?void 0:`scaleY(${n})`}}},ma={duration:333,easing:"ease-in-out"},va=["left","top","width","height","opacity","color","background"],os=new WeakMap;class ba extends hi{constructor(e){if(super(e),this.t=!1,this.i=null,this.o=null,this.h=!0,this.shouldLog=!1,e.type===ft.CHILD)throw Error("The `animate` directive must be used in attribute position.");this.createFinished()}createFinished(){var e;(e=this.resolveFinished)==null||e.call(this),this.finished=new Promise(t=>{this.l=t})}async resolveFinished(){var e;(e=this.l)==null||e.call(this),this.l=void 0}render(e){return g}getController(){return da.get(this.u)}isDisabled(){var e;return this.options.disabled||((e=this.getController())==null?void 0:e.disabled)}update(e,[t]){var i;const n=this.u===void 0;return n&&(this.u=(i=e.options)==null?void 0:i.host,this.u.addController(this),this.u.updateComplete.then(r=>this.t=!0),this.element=e.element,os.set(this.element,this)),this.optionsOrCallback=t,(n||typeof t!="function")&&this.p(t),this.render(t)}p(e){e=e??{};const t=this.getController();t!==void 0&&((e={...t.defaultOptions,...e}).keyframeOptions={...t.defaultOptions.keyframeOptions,...e.keyframeOptions}),e.properties??(e.properties=va),this.options=e}m(){const e={},t=this.element.getBoundingClientRect(),n=getComputedStyle(this.element);return this.options.properties.forEach(i=>{const r=t[i]??(Tt[i]?void 0:n[i]),o=Number(r);e[i]=isNaN(o)?r+"":o}),e}v(){let e,t=!0;return this.options.guard&&(e=this.options.guard(),t=((n,i)=>{if(Array.isArray(n)){if(Array.isArray(i)&&i.length===n.length&&n.every((r,o)=>r===i[o]))return!1}else if(i===n)return!1;return!0})(e,this._)),this.h=this.t&&!this.isDisabled()&&!this.isAnimating()&&t&&this.element.isConnected,this.h&&(this._=Array.isArray(e)?Array.from(e):e),this.h}hostUpdate(){typeof this.optionsOrCallback=="function"&&this.p(this.optionsOrCallback()),this.v()&&(this.A=this.m(),this.i=this.i??this.element.parentNode,this.o=this.element.nextSibling)}async hostUpdated(){if(!this.h||!this.element.isConnected||this.options.skipInitial&&!this.isHostRendered)return;let e;this.prepare(),await ns;const t=this.O(),n=this.j(this.options.keyframeOptions,t),i=this.m();if(this.A!==void 0){const{from:r,to:o}=this.N(this.A,i,t);this.log("measured",[this.A,i,r,o]),e=this.calculateKeyframes(r,o)}else{const r=Et.get(this.options.inId);if(r){Et.delete(this.options.inId);const{from:o,to:a}=this.N(r,i,t);e=this.calculateKeyframes(o,a),e=this.options.in?[{...this.options.in[0],...e[0]},...this.options.in.slice(1),e[1]]:e,es++,e.forEach(l=>l.zIndex=es)}else this.options.in&&(e=[...this.options.in,{}])}this.animate(e,n)}resetStyles(){this.P!==void 0&&(this.element.setAttribute("style",this.P??""),this.P=void 0)}commitStyles(){var e,t;this.P=this.element.getAttribute("style"),(e=this.webAnimation)==null||e.commitStyles(),(t=this.webAnimation)==null||t.cancel()}reconnected(){}async disconnected(){var t;if(!this.h||(this.options.id!==void 0&&Et.set(this.options.id,this.A),this.options.out===void 0))return;if(this.prepare(),await ns(),(t=this.i)==null?void 0:t.isConnected){const n=this.o&&this.o.parentNode===this.i?this.o:null;if(this.i.insertBefore(this.element,n),this.options.stabilizeOut){const i=this.m();this.log("stabilizing out");const r=this.A.left-i.left,o=this.A.top-i.top;getComputedStyle(this.element).position!=="static"||r===0&&o===0||(this.element.style.position="relative"),r!==0&&(this.element.style.left=r+"px"),o!==0&&(this.element.style.top=o+"px")}}const e=this.j(this.options.keyframeOptions);await this.animate(this.options.out,e),this.element.remove()}prepare(){this.createFinished()}start(){var e,t;(t=(e=this.options).onStart)==null||t.call(e,this)}didFinish(e){var t,n;e&&((n=(t=this.options).onComplete)==null||n.call(t,this)),this.A=void 0,this.animatingProperties=void 0,this.frames=void 0,this.resolveFinished()}O(){const e=[];for(let t=this.element.parentNode;t;t=t==null?void 0:t.parentNode){const n=os.get(t);n&&!n.isDisabled()&&n&&e.push(n)}return e}get isHostRendered(){const e=ts.has(this.u);return e||this.u.updateComplete.then(()=>{ts.add(this.u)}),e}j(e,t=this.O()){const n={...ma};return t.forEach(i=>Object.assign(n,i.options.keyframeOptions)),Object.assign(n,e),n}N(e,t,n){e={...e},t={...t};const i=n.map(a=>a.animatingProperties).filter(a=>a!==void 0);let r=1,o=1;return i.length>0&&(i.forEach(a=>{a.width&&(r/=a.width),a.height&&(o/=a.height)}),e.left!==void 0&&t.left!==void 0&&(e.left=r*e.left,t.left=r*t.left),e.top!==void 0&&t.top!==void 0&&(e.top=o*e.top,t.top=o*t.top)),{from:e,to:t}}calculateKeyframes(e,t,n=!1){const i={},r={};let o=!1;const a={};for(const l in t){const c=e[l],h=t[l];if(l in Tt){const u=Tt[l];if(c===void 0||h===void 0)continue;const p=u(c,h);p.transform!==void 0&&(a[l]=p.value,o=!0,i.transform=`${i.transform??""} ${p.transform}`,p.overrideFrom!==void 0&&Object.assign(i,p.overrideFrom))}else c!==h&&c!==void 0&&h!==void 0&&(o=!0,i[l]=c,r[l]=h)}return i.transformOrigin=r.transformOrigin=n?"center center":"top left",this.animatingProperties=a,o?[i,r]:void 0}async animate(e,t=this.options.keyframeOptions){this.start(),this.frames=e;let n=!1;if(!this.isAnimating()&&!this.isDisabled()&&(this.options.onFrames&&(this.frames=e=this.options.onFrames(this),this.log("modified frames",e)),e!==void 0)){this.log("animate",[e,t]),n=!0,this.webAnimation=this.element.animate(e,t);const i=this.getController();i==null||i.add(this);try{await this.webAnimation.finished}catch{}i==null||i.remove(this)}return this.didFinish(n),n}isAnimating(){var e,t;return((e=this.webAnimation)==null?void 0:e.playState)==="running"||((t=this.webAnimation)==null?void 0:t.pending)}log(e,t){this.shouldLog&&!this.isDisabled()&&console.log(e,this.options.id,t)}}const Nt=gt(ba),F=(s,e,t)=>{s&&t.style.setProperty(e,s)},ui=(s,e)=>{var t,n,i,r,o,a,l,c,h;F((t=s.colors)==null?void 0:t.primaryBackground,"--primary-background",e),F((n=s.colors)==null?void 0:n.textOnPrimaryBackground,"--text-on-primary-background",e),F((i=s.colors)==null?void 0:i.secondaryBackground,"--secondary-background",e),F((r=s.colors)==null?void 0:r.textOnSecondaryBackground,"--text-on-secondary-background",e),F((o=s.colors)==null?void 0:o.interactiveDestructiveBackground,"--destructive-color",e),F((a=s.colors)==null?void 0:a.interactiveTextOnDestructiveBackground,"--text-on-destructive-color",e),F((l=s.colors)==null?void 0:l.interactivePrimaryBackground,"--interactive-primary-background",e),F((c=s.colors)==null?void 0:c.interactiveTextOnPrimaryBackground,"--interactive-text-on-primary-background",e),F((h=s.colors)==null?void 0:h.focusColor,"--focus-color",e)};var ya=Object.defineProperty,$a=Object.getOwnPropertyDescriptor,Ue=(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&&ya(e,t,i),i};class X extends k{constructor(){super(...arguments),this.active=!1,this.triggerVisible=!0,this.loaded=!1,this.containerRef=M(),this.widgetActive$=new U(!1),this.componentIsDestroyed$=new _}async connectedCallback(){super.connectedCallback(),this.icon=await this._renderSymbol(),this.loaded=!0,this._applyBranding()}disconnectedCallback(){super.disconnectedCallback(),this.componentIsDestroyed$.next(),this.componentIsDestroyed$.complete()}toggleActive(){var e;if(!((e=this.application)!=null&&e.root)){console.warn("Could not activate widget. No root element assigned to widget.");return}this.active=!this.active,this.active?(this.application.appendToDOM(),this.widgetActive$.next(!0),this.hideTrigger()):(this.application.hide(),this.widgetActive$.next(!1),this.showTrigger())}_applyBranding(){var e;(e=this.application)!=null&&e.settings&&ui(this.application.settings.branding,this)}async _renderSymbol(){var a,l,c;const e=(a=this.application)==null?void 0:a.branding(),t=(l=e==null?void 0:e.graphics)==null?void 0:l.trigger;if(t)return m` <img src=${t} class="trigger-icon" alt="" /> `;const n=(c=this.application)==null?void 0:c.triggerIcon;if(!n)return g;const i=async h=>no,{type:r,content:o}=n;switch(r){case"Telia":{const h=await i();return h?m`<telia-icon
|
65
|
+
`];pa([w({attribute:!0})],ln.prototype,"anchor",2);const da=new WeakMap;let es=0;const Et=new Map,ts=new WeakSet,ns=()=>new Promise(s=>requestAnimationFrame(s)),fa=[{transform:"translateX(100%) scale(0)",opacity:0}],ga=[{opacity:0}],ss=[{opacity:0},{opacity:1}],is=(s,e)=>{const t=s-e;return t===0?void 0:t},rs=(s,e)=>{const t=s/e;return t===1?void 0:t},Tt={left:(s,e)=>{const t=is(s,e);return{value:t,transform:t==null||isNaN(t)?void 0:`translateX(${t}px)`}},top:(s,e)=>{const t=is(s,e);return{value:t,transform:t==null||isNaN(t)?void 0:`translateY(${t}px)`}},width:(s,e)=>{let t;e===0&&(e=1,t={width:"1px"});const n=rs(s,e);return{value:n,overrideFrom:t,transform:n==null||isNaN(n)?void 0:`scaleX(${n})`}},height:(s,e)=>{let t;e===0&&(e=1,t={height:"1px"});const n=rs(s,e);return{value:n,overrideFrom:t,transform:n==null||isNaN(n)?void 0:`scaleY(${n})`}}},ma={duration:333,easing:"ease-in-out"},va=["left","top","width","height","opacity","color","background"],os=new WeakMap;class ba extends hi{constructor(e){if(super(e),this.t=!1,this.i=null,this.o=null,this.h=!0,this.shouldLog=!1,e.type===ft.CHILD)throw Error("The `animate` directive must be used in attribute position.");this.createFinished()}createFinished(){var e;(e=this.resolveFinished)==null||e.call(this),this.finished=new Promise(t=>{this.l=t})}async resolveFinished(){var e;(e=this.l)==null||e.call(this),this.l=void 0}render(e){return g}getController(){return da.get(this.u)}isDisabled(){var e;return this.options.disabled||((e=this.getController())==null?void 0:e.disabled)}update(e,[t]){var i;const n=this.u===void 0;return n&&(this.u=(i=e.options)==null?void 0:i.host,this.u.addController(this),this.u.updateComplete.then(r=>this.t=!0),this.element=e.element,os.set(this.element,this)),this.optionsOrCallback=t,(n||typeof t!="function")&&this.p(t),this.render(t)}p(e){e=e??{};const t=this.getController();t!==void 0&&((e={...t.defaultOptions,...e}).keyframeOptions={...t.defaultOptions.keyframeOptions,...e.keyframeOptions}),e.properties??(e.properties=va),this.options=e}m(){const e={},t=this.element.getBoundingClientRect(),n=getComputedStyle(this.element);return this.options.properties.forEach(i=>{const r=t[i]??(Tt[i]?void 0:n[i]),o=Number(r);e[i]=isNaN(o)?r+"":o}),e}v(){let e,t=!0;return this.options.guard&&(e=this.options.guard(),t=((n,i)=>{if(Array.isArray(n)){if(Array.isArray(i)&&i.length===n.length&&n.every((r,o)=>r===i[o]))return!1}else if(i===n)return!1;return!0})(e,this._)),this.h=this.t&&!this.isDisabled()&&!this.isAnimating()&&t&&this.element.isConnected,this.h&&(this._=Array.isArray(e)?Array.from(e):e),this.h}hostUpdate(){typeof this.optionsOrCallback=="function"&&this.p(this.optionsOrCallback()),this.v()&&(this.A=this.m(),this.i=this.i??this.element.parentNode,this.o=this.element.nextSibling)}async hostUpdated(){if(!this.h||!this.element.isConnected||this.options.skipInitial&&!this.isHostRendered)return;let e;this.prepare(),await ns;const t=this.O(),n=this.j(this.options.keyframeOptions,t),i=this.m();if(this.A!==void 0){const{from:r,to:o}=this.N(this.A,i,t);this.log("measured",[this.A,i,r,o]),e=this.calculateKeyframes(r,o)}else{const r=Et.get(this.options.inId);if(r){Et.delete(this.options.inId);const{from:o,to:a}=this.N(r,i,t);e=this.calculateKeyframes(o,a),e=this.options.in?[{...this.options.in[0],...e[0]},...this.options.in.slice(1),e[1]]:e,es++,e.forEach(l=>l.zIndex=es)}else this.options.in&&(e=[...this.options.in,{}])}this.animate(e,n)}resetStyles(){this.P!==void 0&&(this.element.setAttribute("style",this.P??""),this.P=void 0)}commitStyles(){var e,t;this.P=this.element.getAttribute("style"),(e=this.webAnimation)==null||e.commitStyles(),(t=this.webAnimation)==null||t.cancel()}reconnected(){}async disconnected(){var t;if(!this.h||(this.options.id!==void 0&&Et.set(this.options.id,this.A),this.options.out===void 0))return;if(this.prepare(),await ns(),(t=this.i)==null?void 0:t.isConnected){const n=this.o&&this.o.parentNode===this.i?this.o:null;if(this.i.insertBefore(this.element,n),this.options.stabilizeOut){const i=this.m();this.log("stabilizing out");const r=this.A.left-i.left,o=this.A.top-i.top;getComputedStyle(this.element).position!=="static"||r===0&&o===0||(this.element.style.position="relative"),r!==0&&(this.element.style.left=r+"px"),o!==0&&(this.element.style.top=o+"px")}}const e=this.j(this.options.keyframeOptions);await this.animate(this.options.out,e),this.element.remove()}prepare(){this.createFinished()}start(){var e,t;(t=(e=this.options).onStart)==null||t.call(e,this)}didFinish(e){var t,n;e&&((n=(t=this.options).onComplete)==null||n.call(t,this)),this.A=void 0,this.animatingProperties=void 0,this.frames=void 0,this.resolveFinished()}O(){const e=[];for(let t=this.element.parentNode;t;t=t==null?void 0:t.parentNode){const n=os.get(t);n&&!n.isDisabled()&&n&&e.push(n)}return e}get isHostRendered(){const e=ts.has(this.u);return e||this.u.updateComplete.then(()=>{ts.add(this.u)}),e}j(e,t=this.O()){const n={...ma};return t.forEach(i=>Object.assign(n,i.options.keyframeOptions)),Object.assign(n,e),n}N(e,t,n){e={...e},t={...t};const i=n.map(a=>a.animatingProperties).filter(a=>a!==void 0);let r=1,o=1;return i.length>0&&(i.forEach(a=>{a.width&&(r/=a.width),a.height&&(o/=a.height)}),e.left!==void 0&&t.left!==void 0&&(e.left=r*e.left,t.left=r*t.left),e.top!==void 0&&t.top!==void 0&&(e.top=o*e.top,t.top=o*t.top)),{from:e,to:t}}calculateKeyframes(e,t,n=!1){const i={},r={};let o=!1;const a={};for(const l in t){const c=e[l],h=t[l];if(l in Tt){const u=Tt[l];if(c===void 0||h===void 0)continue;const p=u(c,h);p.transform!==void 0&&(a[l]=p.value,o=!0,i.transform=`${i.transform??""} ${p.transform}`,p.overrideFrom!==void 0&&Object.assign(i,p.overrideFrom))}else c!==h&&c!==void 0&&h!==void 0&&(o=!0,i[l]=c,r[l]=h)}return i.transformOrigin=r.transformOrigin=n?"center center":"top left",this.animatingProperties=a,o?[i,r]:void 0}async animate(e,t=this.options.keyframeOptions){this.start(),this.frames=e;let n=!1;if(!this.isAnimating()&&!this.isDisabled()&&(this.options.onFrames&&(this.frames=e=this.options.onFrames(this),this.log("modified frames",e)),e!==void 0)){this.log("animate",[e,t]),n=!0,this.webAnimation=this.element.animate(e,t);const i=this.getController();i==null||i.add(this);try{await this.webAnimation.finished}catch{}i==null||i.remove(this)}return this.didFinish(n),n}isAnimating(){var e,t;return((e=this.webAnimation)==null?void 0:e.playState)==="running"||((t=this.webAnimation)==null?void 0:t.pending)}log(e,t){this.shouldLog&&!this.isDisabled()&&console.log(e,this.options.id,t)}}const Nt=gt(ba),F=(s,e,t)=>{s&&t.style.setProperty(e,s)},ui=(s,e)=>{var t,n,i,r,o,a,l,c,h;F((t=s.colors)==null?void 0:t.primaryBackground,"--primary-background",e),F((n=s.colors)==null?void 0:n.textOnPrimaryBackground,"--text-on-primary-background",e),F((i=s.colors)==null?void 0:i.secondaryBackground,"--secondary-background",e),F((r=s.colors)==null?void 0:r.textOnSecondaryBackground,"--text-on-secondary-background",e),F((o=s.colors)==null?void 0:o.interactiveDestructiveBackground,"--destructive-color",e),F((a=s.colors)==null?void 0:a.interactiveTextOnDestructiveBackground,"--text-on-destructive-color",e),F((l=s.colors)==null?void 0:l.interactivePrimaryBackground,"--interactive-primary-background",e),F((c=s.colors)==null?void 0:c.interactiveTextOnPrimaryBackground,"--interactive-text-on-primary-background",e),F((h=s.colors)==null?void 0:h.focusColor,"--focus-color",e)};var ya=Object.defineProperty,$a=Object.getOwnPropertyDescriptor,Ue=(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&&ya(e,t,i),i};class X extends k{constructor(){super(...arguments),this.active=!1,this.triggerVisible=!0,this.loaded=!1,this.containerRef=M(),this.widgetActive$=new U(!1),this.componentIsDestroyed$=new _}async connectedCallback(){super.connectedCallback(),this.icon=await this._renderSymbol(),this.loaded=!0,this._applyBranding()}disconnectedCallback(){super.disconnectedCallback(),this.componentIsDestroyed$.next(),this.componentIsDestroyed$.complete()}toggleActive(){var e;if(!((e=this.application)!=null&&e.root)){console.warn("Could not activate widget. No root element assigned to widget.");return}this.active=!this.active,this.active?(this.application.appendToDOM(),this.notify("widget-set-active",{widgetId:this.application.id,active:!0}),this.widgetActive$.next(!0),this.hideTrigger()):(this.application.hide(),this.notify("widget-set-active",{widgetId:this.application.id,active:!1}),this.widgetActive$.next(!1),this.showTrigger())}notify(e,t={}){window!=null&&window.parent&&window.parent.postMessage({type:e,data:t},"*")}_applyBranding(){var e;(e=this.application)!=null&&e.settings&&ui(this.application.settings.branding,this)}async _renderSymbol(){var a,l,c;const e=(a=this.application)==null?void 0:a.branding(),t=(l=e==null?void 0:e.graphics)==null?void 0:l.trigger;if(t)return m` <img src=${t} class="trigger-icon" alt="" /> `;const n=(c=this.application)==null?void 0:c.triggerIcon;if(!n)return g;const i=async h=>no,{type:r,content:o}=n;switch(r){case"Telia":{const h=await i();return h?m`<telia-icon
|
66
66
|
class="trigger-icon"
|
67
67
|
svg=${h.svg}
|
68
68
|
size="lg"
|
@@ -284,7 +284,7 @@
|
|
284
284
|
* @license
|
285
285
|
* Copyright 2017 Google LLC
|
286
286
|
* SPDX-License-Identifier: BSD-3-Clause
|
287
|
-
*/function Aa({context:s}){return(e,t)=>{const n=new WeakMap;if(typeof t=="object")return t.addInitializer(function(){n.set(this,new as(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 as(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 Ea=Object.defineProperty,Ta=Object.getOwnPropertyDescriptor,La=(s,e,t,n)=>{for(var i=n>1?void 0:n?Ta(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&&Ea(e,t,i),i};const Oa="application";class hn 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&&ui(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===cn.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)}>
|
287
|
+
*/function Aa({context:s}){return(e,t)=>{const n=new WeakMap;if(typeof t=="object")return t.addInitializer(function(){n.set(this,new as(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 as(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 Ea=Object.defineProperty,Ta=Object.getOwnPropertyDescriptor,La=(s,e,t,n)=>{for(var i=n>1?void 0:n?Ta(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&&Ea(e,t,i),i};const Oa="application";class hn 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&&ui(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===cn.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")),window.self!==window.top&&this.renderRoot.host.classList.add("embedded"),m`<div class="widget-container" ${z(this.wrapperRef)}>
|
288
288
|
${ka(this.nodes,r=>r)}
|
289
289
|
</div>`}}hn.styles=E`
|
290
290
|
:host {
|
@@ -421,11 +421,11 @@
|
|
421
421
|
animation: slideDown 0.3s linear;
|
422
422
|
pointer-events: none;
|
423
423
|
}
|
424
|
-
`;La([w({attribute:!1}),Aa({context:Oa})],hn.prototype,"application",2);var
|
424
|
+
`;La([w({attribute:!1}),Aa({context:Oa})],hn.prototype,"application",2);var Pa=Object.defineProperty,Ra=Object.getOwnPropertyDescriptor,un=(s,e,t,n)=>{for(var i=n>1?void 0:n?Ra(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&&Pa(e,t,i),i};class je extends k{constructor(){super(),this.status="deactivated",this.addEventListener("environment-created",this.onEnvironmentCreated)}async connectedCallback(){super.connectedCallback(),await this.getGlobalEnvironment()}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("environment-created",this.onEnvironmentCreated)}async onEnvironmentCreated(e){this.widget=e.detail.widget,await this.activate(),this.requestUpdate()}async activate(){this.widget&&(await this.widget.activate(),this.status="activated")}async getGlobalEnvironment(){const e=globalThis.widgets;e&&(this.widget=e.applications.find(t=>t.name===this.name),await this.activate())}render(){if(!this.widget||this.status!=="activated")return g;if(this.widget.renderStrategy===cn.Trigger){const e=new X;return e.application=this.widget,e}return this.widget.render()}}je.styles=[E`
|
425
425
|
:host {
|
426
426
|
display: block;
|
427
427
|
}
|
428
|
-
`];un([w({attribute:!0})],je.prototype,"name",2);un([C()],je.prototype,"widget",2);un([C()],je.prototype,"status",2);customElements.get("ace-trigger-slot")||customElements.define("ace-trigger-slot",ln);customElements.get("ace-trigger")||customElements.define("ace-trigger",X);customElements.get("ace-unresolved-component")||customElements.define("ace-unresolved-component",di);customElements.get("ace-wrapper")||customElements.define("ace-wrapper",hn);customElements.get("ace-widget")||customElements.define("ace-widget",je);class Ia{constructor(e){this._message=null,this._host=e,e.addController(this)}hostConnected(){}set message(e){this._message=e,this._host.requestUpdate()}get message(){return this._message}hasMessage(){return!!this.message}}class ls{constructor(e,t,n,i,r){this.id=e,this.providerKey=t,this.providerOptions=n,this.component=r,this.provider$=new U(null),this.entries$=new U([]),this.removeEntryAction$=new _,this.kill$=new _,this.isTyping$=new U(!1),this.data$=new U({}),this.complete$=this.provider$.pipe(de(l=>l?l.onComplete():Re));const o=this._getProviderFactory(t);if(!o)throw new Error(`No provider with key "${t}" was found.`);this.data$.next(i);const a=o(this.component);this.provider$.next(a),a.actions().pipe(zt(this.kill$)).subscribe(l=>{this.write(l)}),a.isTyping().pipe(zt(this.kill$)).subscribe(l=>{this.isTyping$.next(l)})}start(){const e=this.provider$.value;if(!e)throw new Error("No provider bound to session.");e.saveToCurrentSession$.subscribe(t=>{this.data$.next(t)}),e.connect(this.providerOptions)}entries(){return this.entries$.asObservable()}rehydrate(){var e;(e=this.provider$.value)==null||e.rehydrate(this.data$.value)}toStore(){return{id:this.id,providerKey:this.providerKey,providerOptions:this.providerOptions,data:this.data$.value}}write(e){this._addEntryRemoveHandler(e),this.entries$.pipe(Mt(1)).subscribe(t=>{this.entries$.next([...t,e])})}_addEntryRemoveHandler(e){e.remove$.pipe(de(()=>this.entries$),Mt(1)).subscribe(t=>{this.removeEntryAction$.next(e),this.entries$.next(t.filter(n=>n!==e))})}_getProviderFactory(e){return this.component.platform.registeredProviders.get(e)}}class Ma{constructor(e){this.component=e,this.currentSession$=new U(null),this.sessions=[],this.storage=null,Ke(e,"handover").subscribe(t=>{const n=this._createNewSession(t.detail.providerKey,t.detail.providerOptions);this._setSession(n),t.detail.complete=n.complete$,n.start()})}loadFromStorage(){const e=this._getStoredSessions();this.sessions=e.sessions,this.sessions.forEach(t=>{this._setSession(t),t.rehydrate()}),this.save(e)}startSession(){const e=this._getStoredSessions();let t=null;if(e.sessions.length)t=e.sessions[e.sessions.length-1];else{const n=this._getInitialProviderKey(),i={};t=this._createNewSession(n,i)}this._setSession(t),t.start()}setStorageService(e){this.storage=e}currentSession(){return this.currentSession$.asObservable()}_getStoredSessions(){if(!this.storage)throw new Error("Could not locate StorageService in SessionService.");if(this.sessions.length)return{sessions:this.sessions};const e=this.storage.get("conversation");return e?{sessions:e.sessions.map(t=>new ls(t.id,t.providerKey,t.providerOptions,t.data,this.component))}:{sessions:[]}}_setSession(e){this.currentSession$.next(e),e.data$.subscribe(()=>{this._saveSession(e)})}_saveSession(e){let t=this._getStoredSessions();const n=t.sessions.findIndex(i=>i.id===e.id);n>-1?t={sessions:[...t.sessions.slice(0,n),e,...t.sessions.slice(n+1)]}:t.sessions.push(e),this.save(t)}save(e){if(!this.storage)throw new Error("Could not locate StorageService in SessionService.");const t={sessions:e.sessions.map(n=>n.toStore())};this.storage.set("conversation",t
|
428
|
+
`];un([w({attribute:!0})],je.prototype,"name",2);un([C()],je.prototype,"widget",2);un([C()],je.prototype,"status",2);customElements.get("ace-trigger-slot")||customElements.define("ace-trigger-slot",ln);customElements.get("ace-trigger")||customElements.define("ace-trigger",X);customElements.get("ace-unresolved-component")||customElements.define("ace-unresolved-component",di);customElements.get("ace-wrapper")||customElements.define("ace-wrapper",hn);customElements.get("ace-widget")||customElements.define("ace-widget",je);class Ia{constructor(e){this._message=null,this._host=e,e.addController(this)}hostConnected(){}set message(e){this._message=e,this._host.requestUpdate()}get message(){return this._message}hasMessage(){return!!this.message}}class ls{constructor(e,t,n,i,r){this.id=e,this.providerKey=t,this.providerOptions=n,this.component=r,this.provider$=new U(null),this.entries$=new U([]),this.removeEntryAction$=new _,this.kill$=new _,this.isTyping$=new U(!1),this.data$=new U({}),this.complete$=this.provider$.pipe(de(l=>l?l.onComplete():Re));const o=this._getProviderFactory(t);if(!o)throw new Error(`No provider with key "${t}" was found.`);this.data$.next(i);const a=o(this.component);this.provider$.next(a),a.actions().pipe(zt(this.kill$)).subscribe(l=>{this.write(l)}),a.isTyping().pipe(zt(this.kill$)).subscribe(l=>{this.isTyping$.next(l)})}start(){const e=this.provider$.value;if(!e)throw new Error("No provider bound to session.");e.saveToCurrentSession$.subscribe(t=>{this.data$.next(t)}),e.connect(this.providerOptions)}entries(){return this.entries$.asObservable()}rehydrate(){var e;(e=this.provider$.value)==null||e.rehydrate(this.data$.value)}toStore(){return{id:this.id,providerKey:this.providerKey,providerOptions:this.providerOptions,data:this.data$.value}}write(e){this._addEntryRemoveHandler(e),this.entries$.pipe(Mt(1)).subscribe(t=>{this.entries$.next([...t,e])})}_addEntryRemoveHandler(e){e.remove$.pipe(de(()=>this.entries$),Mt(1)).subscribe(t=>{this.removeEntryAction$.next(e),this.entries$.next(t.filter(n=>n!==e))})}_getProviderFactory(e){return this.component.platform.registeredProviders.get(e)}}class Ma{constructor(e){this.component=e,this.currentSession$=new U(null),this.sessions=[],this.storage=null,Ke(e,"handover").subscribe(t=>{const n=this._createNewSession(t.detail.providerKey,t.detail.providerOptions);this._setSession(n),t.detail.complete=n.complete$,n.start()})}loadFromStorage(){const e=this._getStoredSessions();this.sessions=e.sessions,this.sessions.forEach(t=>{this._setSession(t),t.rehydrate()}),this.save(e)}startSession(){const e=this._getStoredSessions();let t=null;if(e.sessions.length)t=e.sessions[e.sessions.length-1];else{const n=this._getInitialProviderKey(),i={};t=this._createNewSession(n,i)}this._setSession(t),t.start()}setStorageService(e){this.storage=e}currentSession(){return this.currentSession$.asObservable()}_getStoredSessions(){if(!this.storage)throw new Error("Could not locate StorageService in SessionService.");if(this.sessions.length)return{sessions:this.sessions};const e=this.storage.get("conversation");return e?{sessions:e.sessions.map(t=>new ls(t.id,t.providerKey,t.providerOptions,t.data,this.component))}:{sessions:[]}}_setSession(e){this.currentSession$.next(e),e.data$.subscribe(()=>{this._saveSession(e)})}_saveSession(e){let t=this._getStoredSessions();const n=t.sessions.findIndex(i=>i.id===e.id);n>-1?t={sessions:[...t.sessions.slice(0,n),e,...t.sessions.slice(n+1)]}:t.sessions.push(e),this.save(t)}save(e){if(!this.storage)throw new Error("Could not locate StorageService in SessionService.");const t={sessions:e.sessions.map(n=>n.toStore())};this.storage.set("conversation",t)}_createNewSession(e,t={}){const n=this._getStoredSessions(),i=new ls(Ms(),e,t,{},this.component);return n.sessions.push(i),this.save(n),i}_getInitialProviderKey(){var e;if(!((e=this.component.properties.providers)!=null&&e.length))throw new Error("No providers registered on conversation component.");return this.component.properties.providers[0]}}class za{constructor(e,t){this.state$=e,this.component=t,this.entries$=new U([]),this.session=()=>this.session$,this.isTyping=()=>this.isTyping$,this.entries=()=>this.entries$.asObservable(),this.sessionService=new Ma(this.component),this.session$=this.sessionService.currentSession(),this.isTyping$=this.session$.pipe(de(n=>n?n.provider$.pipe(de(i=>i?i.isTyping():It(!1))):It(!1))),e.subscribe(n=>{switch(n){case"init":this.initialize();break;case"rehydrating":this.rehydrate();break;case"connected":this.connected();break}})}setStorage(e){var t;(t=this.sessionService)==null||t.setStorageService(e)}initialize(){this.state$.next("rehydrating")}rehydrate(){this.session$.pipe(de(e=>{if(!e)return Re;const t=e.removeEntryAction$.pipe(Ut(this.entries$)).pipe(Ge(([i,r])=>r.filter(o=>o.id!==i.id))),n=e.entries().pipe(Ge(i=>{const r=this.entries$.value,o=i.filter(a=>r.findIndex(l=>l.id===a.id)===-1);return[...r,...o]}));return Cr(t,n)})).subscribe(e=>{this.entries$.next(e)}),this.sessionService.loadFromStorage(),this.state$.next("connected")}connected(){var e;(e=this.sessionService)==null||e.startSession()}}var Ua=Object.defineProperty,ja=Object.getOwnPropertyDescriptor,Da=(s,e,t,n)=>{for(var i=n>1?void 0:n?ja(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&&Ua(e,t,i),i};class pn extends k{connectedCallback(){var e;super.connectedCallback(),(e=this.entry.didUpdate)==null||e.subscribe(()=>{this.requestUpdate()})}_getTimestamp(e){return new Date(e).toLocaleTimeString([],{hour:"numeric",minute:"2-digit",hourCycle:"h23"})}_renderTimestamp(e,t){if(!e&&!t)return g;let n="";return e?t?n=`${e}: ${this._getTimestamp(t)}`:n=e:t&&(n=this._getTimestamp(t)),m`<p class="conversation-timestamp">${n}</p>`}_renderDeliveryStatus(e){return e==="delivered"?m`<telia-icon
|
429
429
|
svg=${Vr.svg}
|
430
430
|
size="sm"
|
431
431
|
></telia-icon>`:e==="failed"?m`<telia-icon
|
@@ -484,7 +484,7 @@
|
|
484
484
|
</div>`;default:return g}}}pn.styles=[E`
|
485
485
|
:host {
|
486
486
|
box-sizing: border-box;
|
487
|
-
display:
|
487
|
+
display: inline;
|
488
488
|
}
|
489
489
|
* {
|
490
490
|
box-sizing: border-box;
|
@@ -514,8 +514,13 @@
|
|
514
514
|
align-items: center;
|
515
515
|
}
|
516
516
|
|
517
|
+
.conversation-system-message .message-container {
|
518
|
+
width: 100%;
|
519
|
+
}
|
517
520
|
.conversation-system-message .message-content {
|
518
521
|
padding: 0;
|
522
|
+
width: 100%;
|
523
|
+
text-align: center;
|
519
524
|
}
|
520
525
|
|
521
526
|
.conversation-system-message span {
|
@@ -596,7 +601,7 @@
|
|
596
601
|
.entry-content {
|
597
602
|
grid-area: content;
|
598
603
|
}
|
599
|
-
`];Da([w({attribute:!1})],pn.prototype,"entry",2);var Ha=Object.defineProperty,Ba=Object.getOwnPropertyDescriptor,
|
604
|
+
`];Da([w({attribute:!1})],pn.prototype,"entry",2);var Ha=Object.defineProperty,Ba=Object.getOwnPropertyDescriptor,fi=(s,e,t,n)=>{for(var i=n>1?void 0:n?Ba(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&&Ha(e,t,i),i};class mt extends k{constructor(){super(...arguments),this.entries=[],this.loading=!0}updated(e){const t=new CustomEvent("updated",{});this.dispatchEvent(t)}render(){return m`<div class="conversation-feed">
|
600
605
|
${this.entries.map(e=>m`<div class="conversation-entry" tabindex="-1">
|
601
606
|
<conversation-entry
|
602
607
|
.entry=${e}
|
@@ -623,7 +628,7 @@
|
|
623
628
|
.conversation-entry:focus {
|
624
629
|
outline-color: var(--focus-color);
|
625
630
|
}
|
626
|
-
`];
|
631
|
+
`];fi([w({attribute:!1})],mt.prototype,"entries",2);fi([w({type:Boolean})],mt.prototype,"loading",2);/**
|
627
632
|
* @license
|
628
633
|
* Copyright 2021 Google LLC
|
629
634
|
* SPDX-License-Identifier: BSD-3-Clause
|
@@ -646,11 +651,11 @@
|
|
646
651
|
flex-direction: column;
|
647
652
|
gap: var(--spacing-md);
|
648
653
|
}
|
649
|
-
`];Za([w({attribute:!1})],dn.prototype,"group",2);class
|
654
|
+
`];Za([w({attribute:!1})],dn.prototype,"group",2);class gi extends k{render(){return m`<div class="container">
|
650
655
|
<div class="dot"></div>
|
651
656
|
<div class="dot"></div>
|
652
657
|
<div class="dot"></div>
|
653
|
-
</div>`}}
|
658
|
+
</div>`}}gi.styles=[E`
|
654
659
|
:host {
|
655
660
|
display: block;
|
656
661
|
}
|
@@ -724,7 +729,7 @@
|
|
724
729
|
height: auto;
|
725
730
|
object-fit: contain;
|
726
731
|
}
|
727
|
-
`];Ga([w({attribute:!1})],fn.prototype,"message",2);function gn(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}let ae=gn();function
|
732
|
+
`];Ga([w({attribute:!1})],fn.prototype,"message",2);function gn(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}let ae=gn();function mi(s){ae=s}const vi=/[&<>"']/,Ka=new RegExp(vi.source,"g"),bi=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,Xa=new RegExp(bi.source,"g"),Va={"&":"&","<":"<",">":">",'"':""","'":"'"},cs=s=>Va[s];function L(s,e){if(e){if(vi.test(s))return s.replace(Ka,cs)}else if(bi.test(s))return s.replace(Xa,cs);return s}const Ja=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function el(s){return s.replace(Ja,(e,t)=>(t=t.toLowerCase(),t==="colon"?":":t.charAt(0)==="#"?t.charAt(1)==="x"?String.fromCharCode(parseInt(t.substring(2),16)):String.fromCharCode(+t.substring(1)):""))}const tl=/(^|[^\[])\^/g;function y(s,e){let t=typeof s=="string"?s:s.source;e=e||"";const n={replace:(i,r)=>{let o=typeof r=="string"?r:r.source;return o=o.replace(tl,"$1"),t=t.replace(i,o),n},getRegex:()=>new RegExp(t,e)};return n}function hs(s){try{s=encodeURI(s).replace(/%25/g,"%")}catch{return null}return s}const Se={exec:()=>null};function us(s,e){const t=s.replace(/\|/g,(r,o,a)=>{let l=!1,c=o;for(;--c>=0&&a[c]==="\\";)l=!l;return l?"|":" |"}),n=t.split(/ \|/);let i=0;if(n[0].trim()||n.shift(),n.length>0&&!n[n.length-1].trim()&&n.pop(),e)if(n.length>e)n.splice(e);else for(;n.length<e;)n.push("");for(;i<n.length;i++)n[i]=n[i].trim().replace(/\\\|/g,"|");return n}function qe(s,e,t){const n=s.length;if(n===0)return"";let i=0;for(;i<n;){const r=s.charAt(n-i-1);if(r===e&&!t)i++;else if(r!==e&&t)i++;else break}return s.slice(0,n-i)}function nl(s,e){if(s.indexOf(e[1])===-1)return-1;let t=0;for(let n=0;n<s.length;n++)if(s[n]==="\\")n++;else if(s[n]===e[0])t++;else if(s[n]===e[1]&&(t--,t<0))return n;return-1}function ps(s,e,t,n){const i=e.href,r=e.title?L(e.title):null,o=s[1].replace(/\\([\[\]])/g,"$1");if(s[0].charAt(0)!=="!"){n.state.inLink=!0;const a={type:"link",raw:t,href:i,title:r,text:o,tokens:n.inlineTokens(o)};return n.state.inLink=!1,a}return{type:"image",raw:t,href:i,title:r,text:L(o)}}function sl(s,e){const t=s.match(/^(\s+)(?:```)/);if(t===null)return e;const n=t[1];return e.split(`
|
728
733
|
`).map(i=>{const r=i.match(/^\s+/);if(r===null)return i;const[o]=r;return o.length>=n.length?i.slice(n.length):i}).join(`
|
729
734
|
`)}class it{constructor(e){x(this,"options");x(this,"rules");x(this,"lexer");this.options=e||ae}space(e){const t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(e){const t=this.rules.block.code.exec(e);if(t){const n=t[0].replace(/^ {1,4}/gm,"");return{type:"code",raw:t[0],codeBlockStyle:"indented",text:this.options.pedantic?n:qe(n,`
|
730
735
|
`)}}}fences(e){const t=this.rules.block.fences.exec(e);if(t){const n=t[0],i=sl(n,t[3]||"");return{type:"code",raw:n,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:i}}}heading(e){const t=this.rules.block.heading.exec(e);if(t){let n=t[2].trim();if(/#$/.test(n)){const i=qe(n,"#");(this.options.pedantic||!i||/ $/.test(i))&&(n=i.trim())}return{type:"heading",raw:t[0],depth:t[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(e){const t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:t[0]}}blockquote(e){const t=this.rules.block.blockquote.exec(e);if(t){let n=t[0].replace(/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,`
|
@@ -738,8 +743,8 @@
|
|
738
743
|
`+p}!b&&!p.trim()&&(b=!0),a+=yt+`
|
739
744
|
`,e=e.substring(yt.length+1),u=p.slice(d)}}r.loose||(c?r.loose=!0:/\n *\n *$/.test(a)&&(c=!0));let f=null,I;this.options.gfm&&(f=/^\[[ xX]\] /.exec(l),f&&(I=f[0]!=="[ ] ",l=l.replace(/^\[[ xX]\] +/,""))),r.items.push({type:"list_item",raw:a,task:!!f,checked:I,loose:!1,text:l,tokens:[]}),r.raw+=a}r.items[r.items.length-1].raw=a.trimEnd(),r.items[r.items.length-1].text=l.trimEnd(),r.raw=r.raw.trimEnd();for(let h=0;h<r.items.length;h++)if(this.lexer.state.top=!1,r.items[h].tokens=this.lexer.blockTokens(r.items[h].text,[]),!r.loose){const u=r.items[h].tokens.filter(d=>d.type==="space"),p=u.length>0&&u.some(d=>/\n.*\n/.test(d.raw));r.loose=p}if(r.loose)for(let h=0;h<r.items.length;h++)r.items[h].loose=!0;return r}}html(e){const t=this.rules.block.html.exec(e);if(t)return{type:"html",block:!0,raw:t[0],pre:t[1]==="pre"||t[1]==="script"||t[1]==="style",text:t[0]}}def(e){const t=this.rules.block.def.exec(e);if(t){const n=t[1].toLowerCase().replace(/\s+/g," "),i=t[2]?t[2].replace(/^<(.*)>$/,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",r=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:n,raw:t[0],href:i,title:r}}}table(e){const t=this.rules.block.table.exec(e);if(!t||!/[:|]/.test(t[2]))return;const n=us(t[1]),i=t[2].replace(/^\||\| *$/g,"").split("|"),r=t[3]&&t[3].trim()?t[3].replace(/\n[ \t]*$/,"").split(`
|
740
745
|
`):[],o={type:"table",raw:t[0],header:[],align:[],rows:[]};if(n.length===i.length){for(const a of i)/^ *-+: *$/.test(a)?o.align.push("right"):/^ *:-+: *$/.test(a)?o.align.push("center"):/^ *:-+ *$/.test(a)?o.align.push("left"):o.align.push(null);for(const a of n)o.header.push({text:a,tokens:this.lexer.inline(a)});for(const a of r)o.rows.push(us(a,o.header.length).map(l=>({text:l,tokens:this.lexer.inline(l)})));return o}}lheading(e){const t=this.rules.block.lheading.exec(e);if(t)return{type:"heading",raw:t[0],depth:t[2].charAt(0)==="="?1:2,text:t[1],tokens:this.lexer.inline(t[1])}}paragraph(e){const t=this.rules.block.paragraph.exec(e);if(t){const n=t[1].charAt(t[1].length-1)===`
|
741
|
-
`?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:n,tokens:this.lexer.inline(n)}}}text(e){const t=this.rules.block.text.exec(e);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){const t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:L(t[1])}}tag(e){const t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&/^<a /i.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&/^<\/a>/i.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&/^<(pre|code|kbd|script)(\s|>)/i.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){const t=this.rules.inline.link.exec(e);if(t){const n=t[2].trim();if(!this.options.pedantic&&/^</.test(n)){if(!/>$/.test(n))return;const o=qe(n.slice(0,-1),"\\");if((n.length-o.length)%2===0)return}else{const o=nl(t[2],"()");if(o>-1){const l=(t[0].indexOf("!")===0?5:4)+t[1].length+o;t[2]=t[2].substring(0,o),t[0]=t[0].substring(0,l).trim(),t[3]=""}}let i=t[2],r="";if(this.options.pedantic){const o=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(i);o&&(i=o[1],r=o[3])}else r=t[3]?t[3].slice(1,-1):"";return i=i.trim(),/^</.test(i)&&(this.options.pedantic&&!/>$/.test(n)?i=i.slice(1):i=i.slice(1,-1)),ps(t,{href:i&&i.replace(this.rules.inline.anyPunctuation,"$1"),title:r&&r.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){const i=(n[2]||n[1]).replace(/\s+/g," "),r=t[i.toLowerCase()];if(!r){const o=n[0].charAt(0);return{type:"text",raw:o,text:o}}return ps(n,r,n[0],this.lexer)}}emStrong(e,t,n=""){let i=this.rules.inline.emStrongLDelim.exec(e);if(!i||i[3]&&n.match(/[\p{L}\p{N}]/u))return;if(!(i[1]||i[2]||"")||!n||this.rules.inline.punctuation.exec(n)){const o=[...i[0]].length-1;let a,l,c=o,h=0;const u=i[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(u.lastIndex=0,t=t.slice(-1*e.length+o);(i=u.exec(t))!=null;){if(a=i[1]||i[2]||i[3]||i[4]||i[5]||i[6],!a)continue;if(l=[...a].length,i[3]||i[4]){c+=l;continue}else if((i[5]||i[6])&&o%3&&!((o+l)%3)){h+=l;continue}if(c-=l,c>0)continue;l=Math.min(l,l+c+h);const p=[...i[0]][0].length,d=e.slice(0,o+i.index+p+l);if(Math.min(o,l)%2){const f=d.slice(1,-1);return{type:"em",raw:d,text:f,tokens:this.lexer.inlineTokens(f)}}const b=d.slice(2,-2);return{type:"strong",raw:d,text:b,tokens:this.lexer.inlineTokens(b)}}}}codespan(e){const t=this.rules.inline.code.exec(e);if(t){let n=t[2].replace(/\n/g," ");const i=/[^ ]/.test(n),r=/^ /.test(n)&&/ $/.test(n);return i&&r&&(n=n.substring(1,n.length-1)),n=L(n,!0),{type:"codespan",raw:t[0],text:n}}}br(e){const t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e){const t=this.rules.inline.del.exec(e);if(t)return{type:"del",raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}autolink(e){const t=this.rules.inline.autolink.exec(e);if(t){let n,i;return t[2]==="@"?(n=L(t[1]),i="mailto:"+n):(n=L(t[1]),i=n),{type:"link",raw:t[0],text:n,href:i,tokens:[{type:"text",raw:n,text:n}]}}}url(e){var n;let t;if(t=this.rules.inline.url.exec(e)){let i,r;if(t[2]==="@")i=L(t[0]),r="mailto:"+i;else{let o;do o=t[0],t[0]=((n=this.rules.inline._backpedal.exec(t[0]))==null?void 0:n[0])??"";while(o!==t[0]);i=L(t[0]),t[1]==="www."?r="http://"+t[0]:r=t[0]}return{type:"link",raw:t[0],text:i,href:r,tokens:[{type:"text",raw:i,text:i}]}}}inlineText(e){const t=this.rules.inline.text.exec(e);if(t){let n;return this.lexer.state.inRawBlock?n=t[0]:n=L(t[0]),{type:"text",raw:t[0],text:n}}}}const il=/^(?: *(?:\n|$))+/,rl=/^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/,ol=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,De=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,al=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)
|
742
|
-
]`).replace("lheading"
|
746
|
+
`?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:n,tokens:this.lexer.inline(n)}}}text(e){const t=this.rules.block.text.exec(e);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){const t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:L(t[1])}}tag(e){const t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&/^<a /i.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&/^<\/a>/i.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&/^<(pre|code|kbd|script)(\s|>)/i.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){const t=this.rules.inline.link.exec(e);if(t){const n=t[2].trim();if(!this.options.pedantic&&/^</.test(n)){if(!/>$/.test(n))return;const o=qe(n.slice(0,-1),"\\");if((n.length-o.length)%2===0)return}else{const o=nl(t[2],"()");if(o>-1){const l=(t[0].indexOf("!")===0?5:4)+t[1].length+o;t[2]=t[2].substring(0,o),t[0]=t[0].substring(0,l).trim(),t[3]=""}}let i=t[2],r="";if(this.options.pedantic){const o=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(i);o&&(i=o[1],r=o[3])}else r=t[3]?t[3].slice(1,-1):"";return i=i.trim(),/^</.test(i)&&(this.options.pedantic&&!/>$/.test(n)?i=i.slice(1):i=i.slice(1,-1)),ps(t,{href:i&&i.replace(this.rules.inline.anyPunctuation,"$1"),title:r&&r.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){const i=(n[2]||n[1]).replace(/\s+/g," "),r=t[i.toLowerCase()];if(!r){const o=n[0].charAt(0);return{type:"text",raw:o,text:o}}return ps(n,r,n[0],this.lexer)}}emStrong(e,t,n=""){let i=this.rules.inline.emStrongLDelim.exec(e);if(!i||i[3]&&n.match(/[\p{L}\p{N}]/u))return;if(!(i[1]||i[2]||"")||!n||this.rules.inline.punctuation.exec(n)){const o=[...i[0]].length-1;let a,l,c=o,h=0;const u=i[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(u.lastIndex=0,t=t.slice(-1*e.length+o);(i=u.exec(t))!=null;){if(a=i[1]||i[2]||i[3]||i[4]||i[5]||i[6],!a)continue;if(l=[...a].length,i[3]||i[4]){c+=l;continue}else if((i[5]||i[6])&&o%3&&!((o+l)%3)){h+=l;continue}if(c-=l,c>0)continue;l=Math.min(l,l+c+h);const p=[...i[0]][0].length,d=e.slice(0,o+i.index+p+l);if(Math.min(o,l)%2){const f=d.slice(1,-1);return{type:"em",raw:d,text:f,tokens:this.lexer.inlineTokens(f)}}const b=d.slice(2,-2);return{type:"strong",raw:d,text:b,tokens:this.lexer.inlineTokens(b)}}}}codespan(e){const t=this.rules.inline.code.exec(e);if(t){let n=t[2].replace(/\n/g," ");const i=/[^ ]/.test(n),r=/^ /.test(n)&&/ $/.test(n);return i&&r&&(n=n.substring(1,n.length-1)),n=L(n,!0),{type:"codespan",raw:t[0],text:n}}}br(e){const t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e){const t=this.rules.inline.del.exec(e);if(t)return{type:"del",raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}autolink(e){const t=this.rules.inline.autolink.exec(e);if(t){let n,i;return t[2]==="@"?(n=L(t[1]),i="mailto:"+n):(n=L(t[1]),i=n),{type:"link",raw:t[0],text:n,href:i,tokens:[{type:"text",raw:n,text:n}]}}}url(e){var n;let t;if(t=this.rules.inline.url.exec(e)){let i,r;if(t[2]==="@")i=L(t[0]),r="mailto:"+i;else{let o;do o=t[0],t[0]=((n=this.rules.inline._backpedal.exec(t[0]))==null?void 0:n[0])??"";while(o!==t[0]);i=L(t[0]),t[1]==="www."?r="http://"+t[0]:r=t[0]}return{type:"link",raw:t[0],text:i,href:r,tokens:[{type:"text",raw:i,text:i}]}}}inlineText(e){const t=this.rules.inline.text.exec(e);if(t){let n;return this.lexer.state.inRawBlock?n=t[0]:n=L(t[0]),{type:"text",raw:t[0],text:n}}}}const il=/^(?: *(?:\n|$))+/,rl=/^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/,ol=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,De=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,al=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,yi=/(?:[*+-]|\d{1,9}[.)])/,$i=y(/^(?!bull |blockCode|fences|blockquote|heading|html)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html))+?)\n {0,3}(=+|-+) *(?:\n+|$)/).replace(/bull/g,yi).replace(/blockCode/g,/ {4}/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).getRegex(),mn=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,ll=/^[^\n]+/,vn=/(?!\s*\])(?:\\.|[^\[\]\\])+/,cl=y(/^ {0,3}\[(label)\]: *(?:\n *)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/).replace("label",vn).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),hl=y(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,yi).getRegex(),vt="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",bn=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,ul=y("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n *)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$))","i").replace("comment",bn).replace("tag",vt).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),xi=y(mn).replace("hr",De).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",vt).getRegex(),pl=y(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",xi).getRegex(),yn={blockquote:pl,code:rl,def:cl,fences:ol,heading:al,hr:De,html:ul,lheading:$i,list:hl,newline:il,paragraph:xi,table:Se,text:ll},ds=y("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",De).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code"," {4}[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",vt).getRegex(),dl={...yn,table:ds,paragraph:y(mn).replace("hr",De).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",ds).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",vt).getRegex()},fl={...yn,html:y(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",bn).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:Se,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:y(mn).replace("hr",De).replace("heading",` *#{1,6} *[^
|
747
|
+
]`).replace("lheading",$i).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},wi=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,gl=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,ki=/^( {2,}|\\)\n(?!\s*$)/,ml=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,He="\\p{P}\\p{S}",vl=y(/^((?![*_])[\spunctuation])/,"u").replace(/punctuation/g,He).getRegex(),bl=/\[[^[\]]*?\]\([^\(\)]*?\)|`[^`]*?`|<[^<>]*?>/g,yl=y(/^(?:\*+(?:((?!\*)[punct])|[^\s*]))|^_+(?:((?!_)[punct])|([^\s_]))/,"u").replace(/punct/g,He).getRegex(),$l=y("^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)[punct](\\*+)(?=[\\s]|$)|[^punct\\s](\\*+)(?!\\*)(?=[punct\\s]|$)|(?!\\*)[punct\\s](\\*+)(?=[^punct\\s])|[\\s](\\*+)(?!\\*)(?=[punct])|(?!\\*)[punct](\\*+)(?!\\*)(?=[punct])|[^punct\\s](\\*+)(?=[^punct\\s])","gu").replace(/punct/g,He).getRegex(),xl=y("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)[punct](_+)(?=[\\s]|$)|[^punct\\s](_+)(?!_)(?=[punct\\s]|$)|(?!_)[punct\\s](_+)(?=[^punct\\s])|[\\s](_+)(?!_)(?=[punct])|(?!_)[punct](_+)(?!_)(?=[punct])","gu").replace(/punct/g,He).getRegex(),wl=y(/\\([punct])/,"gu").replace(/punct/g,He).getRegex(),kl=y(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),_l=y(bn).replace("(?:-->|$)","-->").getRegex(),Sl=y("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",_l).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),rt=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,Cl=y(/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/).replace("label",rt).replace("href",/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),_i=y(/^!?\[(label)\]\[(ref)\]/).replace("label",rt).replace("ref",vn).getRegex(),Si=y(/^!?\[(ref)\](?:\[\])?/).replace("ref",vn).getRegex(),Al=y("reflink|nolink(?!\\()","g").replace("reflink",_i).replace("nolink",Si).getRegex(),$n={_backpedal:Se,anyPunctuation:wl,autolink:kl,blockSkip:bl,br:ki,code:gl,del:Se,emStrongLDelim:yl,emStrongRDelimAst:$l,emStrongRDelimUnd:xl,escape:wi,link:Cl,nolink:Si,punctuation:vl,reflink:_i,reflinkSearch:Al,tag:Sl,text:ml,url:Se},El={...$n,link:y(/^!?\[(label)\]\((.*?)\)/).replace("label",rt).getRegex(),reflink:y(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",rt).getRegex()},qt={...$n,escape:y(wi).replace("])","~|])").getRegex(),url:y(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,"i").replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/},Tl={...qt,br:y(ki).replace("{2,}","*").getRegex(),text:y(qt.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Ze={normal:yn,gfm:dl,pedantic:fl},xe={normal:$n,gfm:qt,breaks:Tl,pedantic:El};class j{constructor(e){x(this,"tokens");x(this,"options");x(this,"state");x(this,"tokenizer");x(this,"inlineQueue");this.tokens=[],this.tokens.links=Object.create(null),this.options=e||ae,this.options.tokenizer=this.options.tokenizer||new it,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};const t={block:Ze.normal,inline:xe.normal};this.options.pedantic?(t.block=Ze.pedantic,t.inline=xe.pedantic):this.options.gfm&&(t.block=Ze.gfm,this.options.breaks?t.inline=xe.breaks:t.inline=xe.gfm),this.tokenizer.rules=t}static get rules(){return{block:Ze,inline:xe}}static lex(e,t){return new j(t).lex(e)}static lexInline(e,t){return new j(t).inlineTokens(e)}lex(e){e=e.replace(/\r\n|\r/g,`
|
743
748
|
`),this.blockTokens(e,this.tokens);for(let t=0;t<this.inlineQueue.length;t++){const n=this.inlineQueue[t];this.inlineTokens(n.src,n.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[]){this.options.pedantic?e=e.replace(/\t/g," ").replace(/^ +$/gm,""):e=e.replace(/^( *)(\t+)/gm,(a,l,c)=>l+" ".repeat(c.length));let n,i,r,o;for(;e;)if(!(this.options.extensions&&this.options.extensions.block&&this.options.extensions.block.some(a=>(n=a.call({lexer:this},e,t))?(e=e.substring(n.raw.length),t.push(n),!0):!1))){if(n=this.tokenizer.space(e)){e=e.substring(n.raw.length),n.raw.length===1&&t.length>0?t[t.length-1].raw+=`
|
744
749
|
`:t.push(n);continue}if(n=this.tokenizer.code(e)){e=e.substring(n.raw.length),i=t[t.length-1],i&&(i.type==="paragraph"||i.type==="text")?(i.raw+=`
|
745
750
|
`+n.raw,i.text+=`
|
@@ -768,8 +773,8 @@ ${e}</blockquote>
|
|
768
773
|
${e}</tr>
|
769
774
|
`}tablecell(e,t){const n=t.header?"th":"td";return(t.align?`<${n} align="${t.align}">`:`<${n}>`)+e+`</${n}>
|
770
775
|
`}strong(e){return`<strong>${e}</strong>`}em(e){return`<em>${e}</em>`}codespan(e){return`<code>${e}</code>`}br(){return"<br>"}del(e){return`<del>${e}</del>`}link(e,t,n){const i=hs(e);if(i===null)return n;e=i;let r='<a href="'+e+'"';return t&&(r+=' title="'+t+'"'),r+=">"+n+"</a>",r}image(e,t,n){const i=hs(e);if(i===null)return n;e=i;let r=`<img src="${e}" alt="${n}"`;return t&&(r+=` title="${t}"`),r+=">",r}text(e){return e}}class xn{strong(e){return e}em(e){return e}codespan(e){return e}del(e){return e}html(e){return e}text(e){return e}link(e,t,n){return""+n}image(e,t,n){return""+n}br(){return""}}class D{constructor(e){x(this,"options");x(this,"renderer");x(this,"textRenderer");this.options=e||ae,this.options.renderer=this.options.renderer||new ot,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new xn}static parse(e,t){return new D(t).parse(e)}static parseInline(e,t){return new D(t).parseInline(e)}parse(e,t=!0){let n="";for(let i=0;i<e.length;i++){const r=e[i];if(this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[r.type]){const o=r,a=this.options.extensions.renderers[o.type].call({parser:this},o);if(a!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(o.type)){n+=a||"";continue}}switch(r.type){case"space":continue;case"hr":{n+=this.renderer.hr();continue}case"heading":{const o=r;n+=this.renderer.heading(this.parseInline(o.tokens),o.depth,el(this.parseInline(o.tokens,this.textRenderer)));continue}case"code":{const o=r;n+=this.renderer.code(o.text,o.lang,!!o.escaped);continue}case"table":{const o=r;let a="",l="";for(let h=0;h<o.header.length;h++)l+=this.renderer.tablecell(this.parseInline(o.header[h].tokens),{header:!0,align:o.align[h]});a+=this.renderer.tablerow(l);let c="";for(let h=0;h<o.rows.length;h++){const u=o.rows[h];l="";for(let p=0;p<u.length;p++)l+=this.renderer.tablecell(this.parseInline(u[p].tokens),{header:!1,align:o.align[p]});c+=this.renderer.tablerow(l)}n+=this.renderer.table(a,c);continue}case"blockquote":{const o=r,a=this.parse(o.tokens);n+=this.renderer.blockquote(a);continue}case"list":{const o=r,a=o.ordered,l=o.start,c=o.loose;let h="";for(let u=0;u<o.items.length;u++){const p=o.items[u],d=p.checked,b=p.task;let f="";if(p.task){const I=this.renderer.checkbox(!!d);c?p.tokens.length>0&&p.tokens[0].type==="paragraph"?(p.tokens[0].text=I+" "+p.tokens[0].text,p.tokens[0].tokens&&p.tokens[0].tokens.length>0&&p.tokens[0].tokens[0].type==="text"&&(p.tokens[0].tokens[0].text=I+" "+p.tokens[0].tokens[0].text)):p.tokens.unshift({type:"text",text:I+" "}):f+=I+" "}f+=this.parse(p.tokens,c),h+=this.renderer.listitem(f,b,!!d)}n+=this.renderer.list(h,a,l);continue}case"html":{const o=r;n+=this.renderer.html(o.text,o.block);continue}case"paragraph":{const o=r;n+=this.renderer.paragraph(this.parseInline(o.tokens));continue}case"text":{let o=r,a=o.tokens?this.parseInline(o.tokens):o.text;for(;i+1<e.length&&e[i+1].type==="text";)o=e[++i],a+=`
|
771
|
-
`+(o.tokens?this.parseInline(o.tokens):o.text);n+=t?this.renderer.paragraph(a):a;continue}default:{const o='Token with "'+r.type+'" type was not found.';if(this.options.silent)return console.error(o),"";throw new Error(o)}}}return n}parseInline(e,t){t=t||this.renderer;let n="";for(let i=0;i<e.length;i++){const r=e[i];if(this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[r.type]){const o=this.options.extensions.renderers[r.type].call({parser:this},r);if(o!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(r.type)){n+=o||"";continue}}switch(r.type){case"escape":{const o=r;n+=t.text(o.text);break}case"html":{const o=r;n+=t.html(o.text);break}case"link":{const o=r;n+=t.link(o.href,o.title,this.parseInline(o.tokens,t));break}case"image":{const o=r;n+=t.image(o.href,o.title,o.text);break}case"strong":{const o=r;n+=t.strong(this.parseInline(o.tokens,t));break}case"em":{const o=r;n+=t.em(this.parseInline(o.tokens,t));break}case"codespan":{const o=r;n+=t.codespan(o.text);break}case"br":{n+=t.br();break}case"del":{const o=r;n+=t.del(this.parseInline(o.tokens,t));break}case"text":{const o=r;n+=t.text(o.text);break}default:{const o='Token with "'+r.type+'" type was not found.';if(this.options.silent)return console.error(o),"";throw new Error(o)}}}return n}}class Ce{constructor(e){x(this,"options");this.options=e||ae}preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}}x(Ce,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens"]));var Oe,Zt,at,
|
772
|
-
Please report this to https://github.com/markedjs/marked.`,e){const i="<p>An error occurred:</p><pre>"+L(n.message+"",!0)+"</pre>";return t?Promise.resolve(i):i}if(t)return Promise.reject(n);throw n}};const oe=new Ll;function v(s,e){return oe.parse(s,e)}v.options=v.setOptions=function(s){return oe.setOptions(s),v.defaults=oe.defaults,
|
776
|
+
`+(o.tokens?this.parseInline(o.tokens):o.text);n+=t?this.renderer.paragraph(a):a;continue}default:{const o='Token with "'+r.type+'" type was not found.';if(this.options.silent)return console.error(o),"";throw new Error(o)}}}return n}parseInline(e,t){t=t||this.renderer;let n="";for(let i=0;i<e.length;i++){const r=e[i];if(this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[r.type]){const o=this.options.extensions.renderers[r.type].call({parser:this},r);if(o!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(r.type)){n+=o||"";continue}}switch(r.type){case"escape":{const o=r;n+=t.text(o.text);break}case"html":{const o=r;n+=t.html(o.text);break}case"link":{const o=r;n+=t.link(o.href,o.title,this.parseInline(o.tokens,t));break}case"image":{const o=r;n+=t.image(o.href,o.title,o.text);break}case"strong":{const o=r;n+=t.strong(this.parseInline(o.tokens,t));break}case"em":{const o=r;n+=t.em(this.parseInline(o.tokens,t));break}case"codespan":{const o=r;n+=t.codespan(o.text);break}case"br":{n+=t.br();break}case"del":{const o=r;n+=t.del(this.parseInline(o.tokens,t));break}case"text":{const o=r;n+=t.text(o.text);break}default:{const o='Token with "'+r.type+'" type was not found.';if(this.options.silent)return console.error(o),"";throw new Error(o)}}}return n}}class Ce{constructor(e){x(this,"options");this.options=e||ae}preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}}x(Ce,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens"]));var Oe,Zt,at,Ci;class Ll{constructor(...e){$t(this,Oe);$t(this,at);x(this,"defaults",gn());x(this,"options",this.setOptions);x(this,"parse",Be(this,Oe,Zt).call(this,j.lex,D.parse));x(this,"parseInline",Be(this,Oe,Zt).call(this,j.lexInline,D.parseInline));x(this,"Parser",D);x(this,"Renderer",ot);x(this,"TextRenderer",xn);x(this,"Lexer",j);x(this,"Tokenizer",it);x(this,"Hooks",Ce);this.use(...e)}walkTokens(e,t){var i,r;let n=[];for(const o of e)switch(n=n.concat(t.call(this,o)),o.type){case"table":{const a=o;for(const l of a.header)n=n.concat(this.walkTokens(l.tokens,t));for(const l of a.rows)for(const c of l)n=n.concat(this.walkTokens(c.tokens,t));break}case"list":{const a=o;n=n.concat(this.walkTokens(a.items,t));break}default:{const a=o;(r=(i=this.defaults.extensions)==null?void 0:i.childTokens)!=null&&r[a.type]?this.defaults.extensions.childTokens[a.type].forEach(l=>{const c=a[l].flat(1/0);n=n.concat(this.walkTokens(c,t))}):a.tokens&&(n=n.concat(this.walkTokens(a.tokens,t)))}}return n}use(...e){const t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(n=>{const i={...n};if(i.async=this.defaults.async||i.async||!1,n.extensions&&(n.extensions.forEach(r=>{if(!r.name)throw new Error("extension name required");if("renderer"in r){const o=t.renderers[r.name];o?t.renderers[r.name]=function(...a){let l=r.renderer.apply(this,a);return l===!1&&(l=o.apply(this,a)),l}:t.renderers[r.name]=r.renderer}if("tokenizer"in r){if(!r.level||r.level!=="block"&&r.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");const o=t[r.level];o?o.unshift(r.tokenizer):t[r.level]=[r.tokenizer],r.start&&(r.level==="block"?t.startBlock?t.startBlock.push(r.start):t.startBlock=[r.start]:r.level==="inline"&&(t.startInline?t.startInline.push(r.start):t.startInline=[r.start]))}"childTokens"in r&&r.childTokens&&(t.childTokens[r.name]=r.childTokens)}),i.extensions=t),n.renderer){const r=this.defaults.renderer||new ot(this.defaults);for(const o in n.renderer){if(!(o in r))throw new Error(`renderer '${o}' does not exist`);if(o==="options")continue;const a=o,l=n.renderer[a],c=r[a];r[a]=(...h)=>{let u=l.apply(r,h);return u===!1&&(u=c.apply(r,h)),u||""}}i.renderer=r}if(n.tokenizer){const r=this.defaults.tokenizer||new it(this.defaults);for(const o in n.tokenizer){if(!(o in r))throw new Error(`tokenizer '${o}' does not exist`);if(["options","rules","lexer"].includes(o))continue;const a=o,l=n.tokenizer[a],c=r[a];r[a]=(...h)=>{let u=l.apply(r,h);return u===!1&&(u=c.apply(r,h)),u}}i.tokenizer=r}if(n.hooks){const r=this.defaults.hooks||new Ce;for(const o in n.hooks){if(!(o in r))throw new Error(`hook '${o}' does not exist`);if(o==="options")continue;const a=o,l=n.hooks[a],c=r[a];Ce.passThroughHooks.has(o)?r[a]=h=>{if(this.defaults.async)return Promise.resolve(l.call(r,h)).then(p=>c.call(r,p));const u=l.call(r,h);return c.call(r,u)}:r[a]=(...h)=>{let u=l.apply(r,h);return u===!1&&(u=c.apply(r,h)),u}}i.hooks=r}if(n.walkTokens){const r=this.defaults.walkTokens,o=n.walkTokens;i.walkTokens=function(a){let l=[];return l.push(o.call(this,a)),r&&(l=l.concat(r.call(this,a))),l}}this.defaults={...this.defaults,...i}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return j.lex(e,t??this.defaults)}parser(e,t){return D.parse(e,t??this.defaults)}}Oe=new WeakSet,Zt=function(e,t){return(n,i)=>{const r={...i},o={...this.defaults,...r};this.defaults.async===!0&&r.async===!1&&(o.silent||console.warn("marked(): The async option was set to true by an extension. The async: false option sent to parse will be ignored."),o.async=!0);const a=Be(this,at,Ci).call(this,!!o.silent,!!o.async);if(typeof n>"u"||n===null)return a(new Error("marked(): input parameter is undefined or null"));if(typeof n!="string")return a(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(n)+", string expected"));if(o.hooks&&(o.hooks.options=o),o.async)return Promise.resolve(o.hooks?o.hooks.preprocess(n):n).then(l=>e(l,o)).then(l=>o.hooks?o.hooks.processAllTokens(l):l).then(l=>o.walkTokens?Promise.all(this.walkTokens(l,o.walkTokens)).then(()=>l):l).then(l=>t(l,o)).then(l=>o.hooks?o.hooks.postprocess(l):l).catch(a);try{o.hooks&&(n=o.hooks.preprocess(n));let l=e(n,o);o.hooks&&(l=o.hooks.processAllTokens(l)),o.walkTokens&&this.walkTokens(l,o.walkTokens);let c=t(l,o);return o.hooks&&(c=o.hooks.postprocess(c)),c}catch(l){return a(l)}}},at=new WeakSet,Ci=function(e,t){return n=>{if(n.message+=`
|
777
|
+
Please report this to https://github.com/markedjs/marked.`,e){const i="<p>An error occurred:</p><pre>"+L(n.message+"",!0)+"</pre>";return t?Promise.resolve(i):i}if(t)return Promise.reject(n);throw n}};const oe=new Ll;function v(s,e){return oe.parse(s,e)}v.options=v.setOptions=function(s){return oe.setOptions(s),v.defaults=oe.defaults,mi(v.defaults),v};v.getDefaults=gn;v.defaults=ae;v.use=function(...s){return oe.use(...s),v.defaults=oe.defaults,mi(v.defaults),v};v.walkTokens=function(s,e){return oe.walkTokens(s,e)};v.parseInline=oe.parseInline;v.Parser=D;v.parser=D.parse;v.Renderer=ot;v.TextRenderer=xn;v.Lexer=j;v.lexer=j.lex;v.Tokenizer=it;v.Hooks=Ce;v.parse=v;v.options;v.setOptions;v.use;v.walkTokens;v.parseInline;D.parse;j.lex;var Ol=Object.defineProperty,Pl=Object.getOwnPropertyDescriptor,Ai=(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};v.use({renderer:{link(s,e,t){return e||(e=t),`<a target="_blank" href="${s}" title="${e}">${t}</a>`}}});class bt extends k{constructor(){super(...arguments),this.showLightbox=!1,this.imageUrl="",this.altText="",this.scrollRef=M(),this.contentRef=M(),this.autoScroll=!0,this.buffer="",this.pointer=0,this.imageRegexp=new RegExp(/!\[[^[]*\([^)]*\)/gm),this.includesImage=e=>this.imageRegexp.test(e)}handleAutoscroll(){this.addEventListener("wheel",()=>{this.autoScroll=!1},{passive:!0}),this.addEventListener("click",()=>{this.autoScroll=!1})}handleLightboxClose(){this.addEventListener("action",e=>{e.detail.key==="close-lightbox"&&(this.showLightbox=!1)})}handleLightboxOpen(){this.contentRef.value.addEventListener("click",e=>{e.target.tagName==="IMG"&&(this.showLightbox=!0,this.imageUrl=e.target.src,this.altText=e.target.alt)})}getLastChunk(){const e=this.message.content.length-this.pointer;return e===0?"":(this.pointer=this.message.content.length,this.message.content.slice(-e))}async firstUpdated(){this.handleAutoscroll(),this.handleLightboxOpen(),this.handleLightboxClose()}updated(){var i,r;const e=this.getLastChunk();if(!e)return;this.buffer+=e;const t=v.parse(this.buffer),n=(i=this.contentRef.value)==null?void 0:i.querySelector("div:last-of-type");if(this.includesImage(this.buffer))(r=this.contentRef.value)==null||r.appendChild(document.createElement("div")),this.buffer="";else if(this.buffer.includes("!["))return;n.innerHTML=zs(t),this.applyCodeStyles(n),this.autoScroll&&this.scrollRef.value.scrollIntoView()}applyCodeStyles(e){if(!e)return;e.querySelectorAll("code").forEach(n=>{n.style.whiteSpace="pre-wrap"})}render(){return m`
|
773
778
|
<div class="message-type-markdown" ${z(this.contentRef)}>
|
774
779
|
<div></div>
|
775
780
|
</div>
|
@@ -816,7 +821,7 @@ Please report this to https://github.com/markedjs/marked.`,e){const i="<p>An err
|
|
816
821
|
height: auto;
|
817
822
|
object-fit: contain;
|
818
823
|
}
|
819
|
-
`];
|
824
|
+
`];Ai([w({attribute:!1})],bt.prototype,"message",2);Ai([C()],bt.prototype,"showLightbox",2);var Rl=Object.defineProperty,Il=Object.getOwnPropertyDescriptor,Ml=(s,e,t,n)=>{for(var i=n>1?void 0:n?Il(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&&Rl(e,t,i),i};class wn extends k{constructor(){super(...arguments),this.escapeListener=e=>{e.key==="Escape"&&this.closeLightbox()}}firstUpdated(){document.addEventListener("keydown",this.escapeListener)}disconnectedCallback(){document.removeEventListener("keydown",this.escapeListener)}closeLightbox(){const e=new CustomEvent("action",{composed:!0,detail:{key:"close-lightbox"}});this.dispatchEvent(e)}handleKeyDown(e){if(e.key==="Tab"){const t=this.shadowRoot.querySelectorAll("button");if(t.length){const n=t[0],i=t[t.length-1];e.shiftKey?e.target===n&&(i.focus(),e.preventDefault()):e.target===i&&(n.focus(),e.preventDefault())}}}render(){return m`<div
|
820
825
|
class="lightbox"
|
821
826
|
tabindex="-1"
|
822
827
|
@keydown=${this.handleKeyDown}
|
@@ -863,7 +868,7 @@ Please report this to https://github.com/markedjs/marked.`,e){const i="<p>An err
|
|
863
868
|
width: 80%;
|
864
869
|
max-width: 700px;
|
865
870
|
}
|
866
|
-
`];Ml([w({attribute:!0})],wn.prototype,"imageUrl",2);var zl=Object.defineProperty,Ul=Object.getOwnPropertyDescriptor,V=(s,e,t,n)=>{for(var i=n>1?void 0:n?Ul(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&&zl(e,t,i),i};customElements.get("conversation-entry")||customElements.define("conversation-entry",pn);customElements.get("ace-conversation-feed")||customElements.define("ace-conversation-feed",mt);customElements.get("conversation-group")||customElements.define("conversation-group",dn);customElements.get("ace-typing-state")||customElements.define("ace-typing-state",
|
871
|
+
`];Ml([w({attribute:!0})],wn.prototype,"imageUrl",2);var zl=Object.defineProperty,Ul=Object.getOwnPropertyDescriptor,V=(s,e,t,n)=>{for(var i=n>1?void 0:n?Ul(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&&zl(e,t,i),i};customElements.get("conversation-entry")||customElements.define("conversation-entry",pn);customElements.get("ace-conversation-feed")||customElements.define("ace-conversation-feed",mt);customElements.get("conversation-group")||customElements.define("conversation-group",dn);customElements.get("ace-typing-state")||customElements.define("ace-typing-state",gi);customElements.get("message-type-html")||customElements.define("message-type-html",fn);customElements.get("message-type-markdown")||customElements.define("message-type-markdown",bt);customElements.get("ace-lightbox")||customElements.define("ace-lightbox",wn);const Ei=pi(k);class O extends Ei{constructor(){super(...arguments),this.message="",this.disabledInput=!1,this.disabledSubmit=!1,this.chatOverlayActive=!1,this.textAreaLength=0,this.isMuted=!1,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 Ia(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 za(this.conversationState$,this),this.provider$=this.stateMachine.session().pipe(de(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=mr([this.stateMachine.entries(),this.stateMachine.isTyping()]).subscribe(([n,i])=>{this.entries=n,this.typing=i}),this.userSubmitSubscription=Ke(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,this.message=""}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=e.addOption({label:this.isMuted?i:n,icon:this.isMuted?Hn.svg:Bn.svg,closeOnClick:!1,datatestid:"options-mute-button",onClick:()=>{this.isMuted?(this.isMuted=!1,this.application.unmute(),r.updateLabel(n),r.updateIcon(Bn.svg)):(this.isMuted=!0,this.application.mute(),r.updateLabel(i),r.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||Re}firstUpdated(){this.isMuted=this.application.storage.get("muteAudioNotifications")??!1}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
|
867
872
|
@action=${this._actionHandler}
|
868
873
|
class=${be({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})}
|
869
874
|
>
|
@@ -938,7 +943,7 @@ Please report this to https://github.com/markedjs/marked.`,e){const i="<p>An err
|
|
938
943
|
>
|
939
944
|
${this.skipToLatestMessageLabel}
|
940
945
|
</button>
|
941
|
-
</div>`}}O.styles=[
|
946
|
+
</div>`}}O.styles=[Ei.styles||[],E`
|
942
947
|
:host {
|
943
948
|
font-family: var(--font-family);
|
944
949
|
/* --send-icon-color: var(--gray-dark-color, #a6a6a6); */
|
@@ -1220,4 +1225,4 @@ Please report this to https://github.com/markedjs/marked.`,e){const i="<p>An err
|
|
1220
1225
|
clip: rect(0, 0, 0, 0);
|
1221
1226
|
border: 0;
|
1222
1227
|
}
|
1223
|
-
`];V([C()],O.prototype,"message",2);V([C()],O.prototype,"disabledInput",2);V([C()],O.prototype,"disabledSubmit",2);V([C()],O.prototype,"chatOverlayActive",2);V([C()],O.prototype,"textAreaLength",2);V([C()],O.prototype,"platform",2);V([C()],O.prototype,"entries",2);V([C()],O.prototype,"typing",2);const jl=Object.freeze(Object.defineProperty({__proto__:null,Conversation:O,default:O},Symbol.toStringTag,{value:"Module"}));exports.Agent=js;exports.Conversation=O;exports.ConversationComponent=
|
1228
|
+
`];V([C()],O.prototype,"message",2);V([C()],O.prototype,"disabledInput",2);V([C()],O.prototype,"disabledSubmit",2);V([C()],O.prototype,"chatOverlayActive",2);V([C()],O.prototype,"textAreaLength",2);V([C()],O.prototype,"platform",2);V([C()],O.prototype,"entries",2);V([C()],O.prototype,"typing",2);const jl=Object.freeze(Object.defineProperty({__proto__:null,Conversation:O,default:O},Symbol.toStringTag,{value:"Module"}));exports.Agent=js;exports.Conversation=O;exports.ConversationComponent=Pi;exports.ConversationEntry=Ie;exports.ConversationMessageType=Z;exports.ConversationPlatform=Wt;exports.ConversationProvider=Or;exports.User=Ds;exports.findPlainTextLinks=Er;exports.truncateLongLinks=zs;
|