@telia-ace/widget-conversation 1.3.59-rc.1 → 1.3.59-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/agent.d.ts +1 -2
- package/components/conversation/conversation.d.ts +0 -1
- package/components/conversation/plugin.d.ts +0 -1
- package/components/conversation/ui/content.d.ts +0 -1
- package/components/conversation/ui/input.d.ts +0 -1
- package/components/conversation/ui/language-context.d.ts +0 -1
- package/components/conversation/ui/loader.d.ts +0 -1
- package/components/conversation/ui/message-list-items/button-list.d.ts +1 -2
- package/components/conversation/ui/message-list-items/custom.d.ts +0 -1
- package/components/conversation/ui/message-list-items/html.d.ts +0 -1
- package/components/conversation/ui/message-list-items/item-list.d.ts +1 -2
- package/components/conversation/ui/message-list-items/link-list.d.ts +1 -2
- package/components/conversation/ui/message-list-items/separator.d.ts +0 -1
- package/components/conversation/ui/message-list-items/text.d.ts +0 -1
- package/components/conversation/ui/message-list-items/video-request.d.ts +1 -2
- package/components/conversation/ui/message-types/agent.d.ts +0 -1
- package/components/conversation/ui/message-types/message-list.d.ts +1 -2
- package/components/conversation/ui/message-types/system.d.ts +0 -1
- package/components/conversation/ui/message-types/timestamp.d.ts +0 -1
- package/components/conversation/ui/message-types/user.d.ts +0 -1
- package/components/conversation/ui/message.d.ts +0 -1
- package/components/conversation/ui/overlay-outlets.d.ts +1 -2
- package/components/conversation/ui/skip-link.d.ts +0 -1
- package/components/conversation/ui/styles.d.ts +3 -8
- package/components/return-button/plugin.d.ts +1 -2
- package/components/return-button/return-button.d.ts +0 -1
- package/{conversation-CZEwSpw2.js → conversation-Bl_75lU9.js} +1 -1
- package/{conversation-BJP1_oQk.mjs → conversation-DzOpPoC3.mjs} +2 -2
- package/conversation-controller.d.ts +0 -1
- package/conversation-form-adapter.d.ts +7 -0
- package/conversation-history.d.ts +0 -1
- package/conversation-platform.d.ts +2 -3
- package/conversation-provider.d.ts +0 -1
- package/index.d.ts +0 -1
- package/index.js +3 -3
- package/index.mjs +111 -98
- package/package.json +8 -8
- package/resolve-entity-value.d.ts +10 -0
- package/store.d.ts +0 -1
- package/types.d.ts +2 -3
- package/user.d.ts +0 -1
- package/utils/custom-message.d.ts +1 -2
- package/utils/open-chat-widget.d.ts +0 -1
- package/utils/swap-provider.d.ts +0 -1
package/agent.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { Symbol } from '
|
|
1
|
+
import { Symbol } from '@telia-ace/widget-ui';
|
|
2
2
|
import { ConversationEntry } from './conversation-controller';
|
|
3
3
|
import { ConversationProvider } from './conversation-provider';
|
|
4
4
|
import { ConversationMessageSettings, ConverstationMessageItem } from './types';
|
|
5
|
-
|
|
6
5
|
export type AgentSettings = {
|
|
7
6
|
id?: string;
|
|
8
7
|
name?: string;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Container } from '@webprovisions/platform';
|
|
2
2
|
import { ConversationMessage, ConversationMessageType } from '../../conversation-controller';
|
|
3
3
|
import { ConversationMessageContent, ConversationMessageSender } from '../../types';
|
|
4
|
-
|
|
5
4
|
export type BundledConversationMessage = {
|
|
6
5
|
timestamp: number;
|
|
7
6
|
content: [BundledMessageContent];
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { DispatchAction } from '
|
|
1
|
+
import { DispatchAction } from '@telia-ace/widget-ui';
|
|
2
2
|
import { FC } from 'react';
|
|
3
3
|
import { ButtonListProperties } from '../../../../types';
|
|
4
|
-
|
|
5
4
|
type Props = {
|
|
6
5
|
dispatch: DispatchAction;
|
|
7
6
|
} & ButtonListProperties;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { DispatchAction } from '
|
|
1
|
+
import { DispatchAction } from '@telia-ace/widget-ui';
|
|
2
2
|
import { FC } from 'react';
|
|
3
3
|
import { LinkListProperties } from '../../../../types';
|
|
4
|
-
|
|
5
4
|
type Props = {
|
|
6
5
|
dispatch: DispatchAction;
|
|
7
6
|
} & LinkListProperties;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { DispatchAction } from '
|
|
1
|
+
import { DispatchAction } from '@telia-ace/widget-ui';
|
|
2
2
|
import { FC } from 'react';
|
|
3
3
|
import { LinkListProperties } from '../../../../types';
|
|
4
|
-
|
|
5
4
|
type Props = {
|
|
6
5
|
dispatch: DispatchAction;
|
|
7
6
|
} & LinkListProperties;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { DispatchAction } from '
|
|
1
|
+
import { DispatchAction } from '@telia-ace/widget-ui';
|
|
2
2
|
import { FC } from 'react';
|
|
3
3
|
import { VideoRequestProperties } from '../../../../types';
|
|
4
|
-
|
|
5
4
|
type Props = {
|
|
6
5
|
dispatch: DispatchAction;
|
|
7
6
|
} & VideoRequestProperties;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
|
-
import { DispatchAction } from '
|
|
2
|
+
import { DispatchAction } from '@telia-ace/widget-ui';
|
|
3
3
|
import { ConverstationMessageItem } from '../../../../types';
|
|
4
|
-
|
|
5
4
|
type Props = {
|
|
6
5
|
items: ConverstationMessageItem<any>[];
|
|
7
6
|
dispatch: DispatchAction;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
2
|
import { BundledConversationMessage } from '../plugin';
|
|
3
|
-
|
|
4
3
|
export declare const ConversationMessage: React.ForwardRefExoticComponent<{
|
|
5
4
|
className?: string;
|
|
6
5
|
} & BundledConversationMessage & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Theme } from '@emotion/react';
|
|
2
|
-
|
|
3
2
|
export declare const Avatar: import('@emotion/styled').StyledComponent<any, import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
4
3
|
export declare const LoaderAnimation: import('@emotion/react').Keyframes;
|
|
5
4
|
export declare const Loader: import('@emotion/styled').StyledComponent<{
|
|
@@ -10,7 +9,7 @@ export declare const ContentBundle: import('@emotion/styled').StyledComponent<{
|
|
|
10
9
|
theme?: Theme;
|
|
11
10
|
as?: React.ElementType;
|
|
12
11
|
}, import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
13
|
-
export declare const MessageTitle: import('@emotion/styled').StyledComponent<import('
|
|
12
|
+
export declare const MessageTitle: import('@emotion/styled').StyledComponent<import('@telia-ace/widget-ui').TypographyProps & {
|
|
14
13
|
theme?: Theme;
|
|
15
14
|
}, {}, {}>;
|
|
16
15
|
export declare const MessageContainer: import('@emotion/styled').StyledComponent<{
|
|
@@ -39,7 +38,7 @@ export declare const messageContentPadding: (p: {
|
|
|
39
38
|
theme: Theme;
|
|
40
39
|
}) => import('@emotion/react').SerializedStyles;
|
|
41
40
|
export declare const StyledForm: import('@emotion/styled').StyledComponent<{
|
|
42
|
-
data?: import('
|
|
41
|
+
data?: import('@telia-ace/widget-forms').FormData | null;
|
|
43
42
|
className?: string;
|
|
44
43
|
onChange?: Function;
|
|
45
44
|
autoFocus?: boolean;
|
|
@@ -49,11 +48,7 @@ export declare const StyledForm: import('@emotion/styled').StyledComponent<{
|
|
|
49
48
|
theme?: Theme;
|
|
50
49
|
}, {}, {}>;
|
|
51
50
|
export declare const StyledHtml: import('@emotion/styled').StyledComponent<any, {}, {}>;
|
|
52
|
-
export declare const StyledActionList: import('@emotion/styled').StyledComponent<Omit<
|
|
53
|
-
renderItem: import('../../../../../ui/src/index.ts').ItemRenderer;
|
|
54
|
-
items: any[];
|
|
55
|
-
renderLi?: boolean;
|
|
56
|
-
}>, "ref"> & import('react').RefAttributes<HTMLUListElement> & {
|
|
51
|
+
export declare const StyledActionList: import('@emotion/styled').StyledComponent<Omit<import('@telia-ace/widget-ui').ListProps, "ref"> & import('react').RefAttributes<HTMLUListElement> & {
|
|
57
52
|
theme?: Theme;
|
|
58
53
|
}, {}, {}>;
|
|
59
54
|
export declare const StyledActionButton: import('@emotion/styled').StyledComponent<{
|
|
@@ -506,7 +506,7 @@
|
|
|
506
506
|
stroke: #fff;
|
|
507
507
|
}
|
|
508
508
|
}
|
|
509
|
-
`,M=([t,e])=>({type:t,content:e}),Pe=({items:t,dispatch:e})=>{const o=t.map(M).filter(r=>r.type.includes("ace-knowledge")).map(r=>"humany-"+r.type.toString());return
|
|
509
|
+
`,M=([t,e])=>({type:t,content:e}),Pe=({items:t,dispatch:e})=>{const o=t.map(M).filter(r=>r.type.includes("ace-knowledge")).map(r=>"humany-"+r.type.toString());return t.map(M).filter(r=>{const u=r==null?void 0:r.content,m=u==null?void 0:u.actions;return!!(m!=null&&m.filter(d=>d.actionKey==="contact").length)}).length&&o.push("humany-secondary-action-list"),t.map(M).filter(r=>{var m;const u=r==null?void 0:r.content;return!!((m=u==null?void 0:u.tags)!=null&&m.includes("category"))}).length&&o.push("humany-category-list"),s.jsx(qe,{role:"none",className:w.appendClassNames("humany-message-list",o.join(" ")),items:t.map(M),renderLi:!0,renderItem:r=>{switch(r.type){case S.ConversationMessageListItemType.Text:return s.jsx(He,{text:r.content});case S.ConversationMessageListItemType.HTML:return s.jsx(Ce,{...r.content});case S.ConversationMessageListItemType.Separator:return s.jsx(Ae,{...r.content});case S.ConversationMessageListItemType.ItemList:return s.jsx(ze,{...r.content,dispatch:e});case S.ConversationMessageListItemType.LinkList:return s.jsx(Me,{...r.content,dispatch:e});case S.ConversationMessageListItemType.ButtonList:return s.jsx($e,{...r.content,dispatch:e});case S.ConversationMessageListItemType.VideoRequest:return s.jsx(Re,{...r.content,dispatch:e});default:return s.jsx(ke,{type:r.type,content:r.content})}}})},qe=l(n.List)`
|
|
510
510
|
${n.list}
|
|
511
511
|
|
|
512
512
|
> li {
|
|
@@ -1101,10 +1101,10 @@ const Oe = ({ className: t }) => {
|
|
|
1101
1101
|
}
|
|
1102
1102
|
`, E = ([t, e]) => ({ type: t, content: e }), wt = ({ items: t, dispatch: e }) => {
|
|
1103
1103
|
const r = t.map(E).filter((o) => o.type.includes("ace-knowledge")).map((o) => "humany-" + o.type.toString());
|
|
1104
|
-
return
|
|
1104
|
+
return t.map(E).filter((o) => {
|
|
1105
1105
|
const d = o == null ? void 0 : o.content, m = d == null ? void 0 : d.actions;
|
|
1106
1106
|
return !!(m != null && m.filter((c) => c.actionKey === "contact").length);
|
|
1107
|
-
}).length && r.push("humany-secondary-action-list"),
|
|
1107
|
+
}).length && r.push("humany-secondary-action-list"), t.map(E).filter((o) => {
|
|
1108
1108
|
var m;
|
|
1109
1109
|
const d = o == null ? void 0 : o.content;
|
|
1110
1110
|
return !!((m = d == null ? void 0 : d.tags) != null && m.includes("category"));
|
|
@@ -3,7 +3,6 @@ import { AgentSettings } from './agent';
|
|
|
3
3
|
import { ConversationProvider } from './conversation-provider';
|
|
4
4
|
import { ConversationMessageContent, ConversationMessageSender, ConversationMessageSettings, ConversationMessageUpdateSettings, ConverstationMessageItem, NormalizedMessageSettings } from './types';
|
|
5
5
|
import { User } from './user';
|
|
6
|
-
|
|
7
6
|
export type ValidateHandler = (formValues: {
|
|
8
7
|
[key: string]: any;
|
|
9
8
|
}) => Promise<any>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ConversationPlatform } from '.';
|
|
2
|
+
export declare class ConversationFormAdapter {
|
|
3
|
+
private platform;
|
|
4
|
+
constructor(platform: ConversationPlatform);
|
|
5
|
+
submit: (invoke: any, cancel: any) => (contactMethod: any) => Promise<any>;
|
|
6
|
+
updateContactMethod: (contactMethod: any, errors?: any) => void;
|
|
7
|
+
}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { ComponentNodeController, ComponentPlatform } from '
|
|
2
|
-
import { RouteData } from '
|
|
1
|
+
import { ComponentNodeController, ComponentPlatform } from '@telia-ace/widget-core';
|
|
2
|
+
import { RouteData } from '@telia-ace/widget-routing';
|
|
3
3
|
import { Container, EventManager, EventSubscriptionCancellation } from '@webprovisions/platform';
|
|
4
4
|
import { ConversationController } from './conversation-controller';
|
|
5
5
|
import { ConversationProvider } from './conversation-provider';
|
|
6
|
-
|
|
7
6
|
export type ConversationHandler = (conversation: ConversationProvider, component: ComponentNodeController) => void | (() => void);
|
|
8
7
|
export type UnregisterControllerDelegate = () => void;
|
|
9
8
|
export type ConversationProviderRegistration = {
|
|
@@ -2,7 +2,6 @@ import { Container, EventListener, EventSubscriptionCancellation } from '@webpro
|
|
|
2
2
|
import { Agent, AgentSettings } from './agent';
|
|
3
3
|
import { CancelLoaderDelegate, ConversationController, ConversationEntry, ConversationMessageType, ConversationOptions } from './conversation-controller';
|
|
4
4
|
import { ConversationMessageContent, ConversationMessageSender, ConversationMessageSettings } from './types';
|
|
5
|
-
|
|
6
5
|
export declare class ConversationProvider {
|
|
7
6
|
name: string;
|
|
8
7
|
private container;
|
package/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { ConversationEndedBehavior, ConversationPlatform, UnregisterControllerDelegate } from './conversation-platform';
|
|
2
|
-
|
|
3
2
|
export { ConversationComponent } from './components/conversation/plugin';
|
|
4
3
|
export { ConversationReturnButtonComponent } from './components/return-button/plugin';
|
|
5
4
|
export { ConversationController, ConversationEntry, ConversationMessageType, } from './conversation-controller';
|
package/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";var _=Object.defineProperty;var q=(o,e,t)=>e in o?_(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t;var
|
|
2
|
-
`):void 0,source:this.createMessageSource(t),alias:this.createAlias(t,s),timestamp:r}}createMessageSource(e){return e}createAlias(e,t){return e===y.System?"system":(t==null?void 0:t.name)||"Me"}handleContactMethod(e){if(!this.cache.has(e))return;const t=this.cache.get(e);let s="";return s=this.appendText(s,`${t.clientName}:`),s=this.appendText(s,t.title),t.description&&(s=this.appendText(s,t.title)),s}getDetails(e,t=!0){if(!e)return"";const{header:s,title:r,label:n,description:a,text:i,html:
|
|
3
|
-
${t}`:e.length?`${e} ${t}`:t}dispose(){this.subscriptions.forEach(e=>{e()})}}class P{constructor(e,t){h(this,"id");h(this,"name");h(this,"avatar");h(this,"print",(e,t,s=null)=>{var i,c,d;const r={name:this.name,avatar:this.avatar,id:this.id},n=k(e,t);s=s??n.timestamp;const a=(c=(i=this.provider)==null?void 0:i.controller)==null?void 0:c.container.get("$widget");return(d=a==null?void 0:a.events)==null||d.dispatch("tracking:conversation-message",{sender:"agent"}),this.provider.createEntry(n.key,n.content,y.Agent,r,s)});h(this,"typing",()=>this.provider.setTypingState({name:this.name,avatar:this.avatar}));this.provider=e,this.id=t.id||E.uuid(),this.name=t.name,this.avatar=t.avatar}update(e){var r;const{name:t,avatar:s}=e;s===null?this.avatar=void 0:s&&(this.avatar=s),t===null?this.name=void 0:t&&(this.name=t),(r=this.provider.controller)==null||r.events.dispatch("conversation:agent-updated",{agent:this})}}class A{constructor(e,t,s){h(this,"subscriptions",[]);h(this,"options");h(this,"user");this.name=e,this.container=t,this.controller=s,this.user=s==null?void 0:s.user,this.options={silent:!1}}static create(e,t,s){return new A(e,t,s)}createAgent(e={}){var t;if(this.controller){const s=this.controller.getAgentById(e.id),r=s?new P(this,{...s,...e}):new P(this,e);return s||(t=this.controller)==null||t.events.dispatch("conversation:agent-created",{agent:r}),r}}print(e){var t;return(t=this.controller)==null?void 0:t.print(e)}setTypingState(e,t){var s;return(s=this.controller)==null?void 0:s.setTypingState(e,t)}loading(){return this.controller?this.controller.loader():()=>()=>{}}createEntry(e,t,s,r,n){var a;return(a=this.controller)==null?void 0:a.createEntry(e,t,s,r,n)}dispose(){var e;process.env.NODE_ENV!=="production"&&console.log(`conversation-provider: dispose (${this.name})`),(e=this.controller)==null||e.disposeProvider(this),this.controller=null,this.subscriptions.forEach(t=>t())}isRehydrated(){var e;return((e=this.controller)==null?void 0:e.isRehydrated())||Promise.resolve(!1)}getHistory(){var e;return((e=this.controller)==null?void 0:e.getHistory())||[]}complete(){var e;(e=this.controller)==null||e.onCompleteProvider()}setOptions(e={silent:!1}){this.options=e}onUnreadMessage(e){var t;if(this.controller){const s=(t=this.controller)==null?void 0:t.onUnreadMessage(e);return this.subscriptions.push(s),()=>{s()}}}onMounted(e){var t;if(this.controller){const s=(t=this.controller)==null?void 0:t.events.subscribe("conversation:component-mount-changed",e);return this.subscriptions.push(s),e({},this.controller.getComponentMountedState()),()=>{s()}}}}const D=o=>`conversation-${o}`;class K{constructor(){h(this,"_locking",Promise.resolve());h(this,"_locks",0)}isLocked(){return this._locks>0}lock(){this._locks+=1;let e;const t=new Promise(r=>e=()=>{this._locks-=1,r()}),s=this._locking.then(()=>e);return this._locking=this._locking.then(()=>t),s}}function Q(o){let e=0;if(o.length===0)return e.toString();for(let t=0;t<o.length;t++){const s=o.charCodeAt(t);e=(e<<5)-e+s,e=e&e}return e.toString()}class j{constructor(e,t,s){h(this,"sessionStorageKey");h(this,"locker",new K);h(this,"initialStoredAgents",[]);this.container=e,this.conversation=t,this.enabled=s,this.sessionStorageKey=D(t.id),t.onStarted(async()=>{if(t.messages.length>0)return;const{agents:r}=await this.read(),n=[];r&&r.forEach(i=>{const c=t.providerIndex(i.providerName),d=c>-1?t.registeredProviders[c]:t.createProvider(i.providerName),u=new P(d,{name:i.name,avatar:i.avatar,id:i.id});n.push(u)});const{messages:a}=await this.read();a.filter(i=>(i==null?void 0:i.content)!=null).filter(i=>!i.chat||!t.providers.includes("ace.chat")).forEach(i=>{switch(i.type){case"agent":{const c=n.find(d=>{var u;return d.id===((u=i.sender)==null?void 0:u.id)});c&&c.print(i.content.items||i.content,{key:i.key},i.timestamp);return}case"user":{t.user.print(i.content.items||i.content,{key:i.key},i.timestamp);return}case"system":default:t.print(i.content.items||i.content,i.timestamp)}})}),t.onMessageCreated(async(r,n)=>{this.write(n.message,"messages")}),t.events.subscribe("conversation:agent-created",async(r,n)=>{const a={id:n.agent.id,name:n.agent.name,avatar:n.agent.avatar,providerName:n.agent.provider.name};await this.write(a,"agents")}),t.events.subscribe("conversation:agent-updated",async(r,n)=>{const{agents:a}=await this.read();await this.write([...a.map(i=>i.id===n.agent.id?{...i,name:n.agent.name,avatar:n.agent.avatar}:i)],"agents","update")})}setInitialData(e){this.initialStoredAgents=e.agents}async isRehydrated(){const{messages:e}=await this.read();return e.length>0}getStoredAgent(e){if(this.enabled)return this.initialStoredAgents.find(t=>t.id===e)}async write(e,t,s="add"){if(!this.enabled)return;const r=await this.locker.lock();return p.createStorageWriter(this.container,this.sessionStorageKey,p.StorageCategory.Necessary).then(async n=>{if(s==="add"){const a=await this.read();if(t==="messages"&&(e.chat=this.conversation.providers.includes("ace.chat"),e.hash=Q(JSON.stringify(e.content)+e.timestamp)),t==="messages"&&a.messages.findIndex(c=>c.key===e.key||c.hash===e.hash)>-1){r();return}const i={...a};return t==="messages"?i.messages=[...i.messages,e]:t==="agents"&&(i.agents=[...i.agents,e]),n({...a,...i}).then(()=>{r()})}if(s==="update"&&t==="agents"){const a=await this.read();return n({...a,agents:e}).then(()=>{r()})}return n(e).then(()=>{r()})})}async read(){return p.readStorage(this.container,this.sessionStorageKey).then(e=>e||{messages:[],agents:[]})}}class F{constructor(e){h(this,"print",(e,t,s=null)=>{var a,i;const r=k(e,t);return s=s??r.timestamp,(i=((a=this.controller)==null?void 0:a.container.get("$widget")).events)==null||i.dispatch("tracking:conversation-message",{sender:"user"}),this.controller.createEntry(r.key,r.content,y.User,void 0,s)});this.controller=e}}const x=async(o,e,t)=>{const s=await o.getAsync("conversation"),r=await o.getAsync("components"),n=s.controllers.find(a=>a.conversation.id===e);if(n){const a=[...n.conversation.providers];a.forEach(c=>{n.conversation.setProviderOptions(c,{silent:!0})}),n.conversation.queueProviders(a),n.conversation.setProviders([t]);const i=r.components().ofType("conversation");r.write({key:"setConversationProvider",attributes:{properties:{providers:[t]}},target:i,provider:"localStorage"})}};class ${constructor(e){this.writer=e}update(e){const t=this.getNormalizedSettings(e);this.writer(t)}remove(){this.writer(null)}getNormalizedSettings(e){return typeof e=="string"?{body:e}:e.length>-1&&typeof e=="object"?{items:e}:e}}var y=(o=>(o.User="user",o.Agent="agent",o.System="system",o))(y||{});const k=(o,e)=>{let t,s=(e==null?void 0:e.key)||E.uuid(),r=Date.now();if(Array.isArray(o)&&o.length>-1)typeof o[0]=="string"?t={items:[o]}:t={items:o};else if(typeof o=="string")t={body:o};else if(o=o||{},o.type)t={...o};else{if(t={body:o.body,actions:o.actions,title:o.title},o.key&&(s=o.key),o.timestamp&&(r=o.timestamp),typeof o.form=="function"){const n=L.FormBuilder.create(s);o.form(n);const a=n.get();t.form=a}o.timestamp===null&&(r=null)}return{content:t,key:s,timestamp:r}},W=(o,e)=>{if(!e)return;const t=JSON.stringify(e),s=o.findIndex(r=>t===JSON.stringify(r));if(s>-1)return o.splice(s,1)};class H{constructor(e,t,s){h(this,"formHandlers",{});h(this,"user",new F(this));h(this,"events");h(this,"providers",[]);h(this,"active",!1);h(this,"queuedProviders",[]);h(this,"registeredProviders",[]);h(this,"loaders",0);h(this,"componentMounted",!1);h(this,"store");h(this,"messages",[]);h(this,"typingActors",[]);h(this,"conversationHistory");h(this,"print",(e,t=null)=>{const s=k(e);t=t??s.timestamp;const r=this.container.get("$widget");return r==null||r.events.dispatch("tracking:conversation-message",{sender:"system"}),this.createEntry(s.key,s.content,"system",void 0,t)});this.container=e,this.id=t;const r=e.get("$widget");this.events=r.events.createChild(this),this.store=new j(e,this,s.rehydrate),this.conversationHistory=new U(this)}setInitialStorage(e){this.store.setInitialData(e)}setProviders(e){const t=[],s=[];this.providers.reduce((r,n)=>(e.indexOf(n)===-1&&r.push(n),r),[]).forEach(r=>{const n=this.providers.indexOf(r);n>-1&&(t.push(r),this.providers.splice(n,1))}),e.forEach(r=>{this.providers.indexOf(r)===-1&&(s.push(r),this.providers.push(r))}),(s.length||t.length)&&this.events.dispatch("conversation:providers-changed",{added:s,removed:t})}createProvider(e){const t=this.providerIndex(e);if(t>-1)return this.registeredProviders[t];const s=A.create(e,this.container,this);return this.registeredProviders.push(s),s}providerIndex(e){return this.registeredProviders.findIndex(t=>t.name===e)}getAgentById(e){if(e)return this.store.getStoredAgent(e)}dispose(){this.conversationHistory.dispose(),this.registeredProviders.forEach(e=>e.dispose()),this.messages=[],this.events.dispatch("conversation:controller-disposed",this),this.active=!1}onDispose(e){return this.events.subscribe("conversation:controller-disposed",e)}onStarted(e){return this.events.subscribe("conversation:started",e)}onMessageCreated(e){return this.events.subscribe("conversation:message-created",e)}isRehydrated(){return this.store.isRehydrated()}disposeProvider(e){const t=this.providerIndex(e.name);t>-1&&this.registeredProviders.splice(t,1),this.events.dispatch("conversation:providers-changed",{removed:[e.name]}),this.registeredProviders.length||this.dispose()}onProvidersChange(e){return this.events.subscribe("conversation:providers-changed",e)}setComponentMountedState(e){this.componentMounted!==e&&(this.componentMounted=e,e&&(this.events.dispatch("conversation:unread-message",!1),this.events.dispatch("conversation:started",!0),this.active=!0),this.events.dispatch("conversation:component-mount-changed",e))}setProviderOptions(e,t){const s=this.providerIndex(e);s>-1&&this.registeredProviders[s].setOptions(t)}changeProvider(e){this.registeredProviders.find(s=>s.name===e)&&x(this.container,this.id,e)}queueProviders(e){this.queuedProviders=e}onCompleteProvider(){const e=this.queuedProviders.pop();e&&x(this.container,this.id,e)}getComponentMountedState(){return this.componentMounted}onUnreadMessage(e){return this.events.subscribe("conversation:unread-message",e)}createEntry(e,t,s,r,n){const a={key:e,content:t,type:s,sender:r||null,timestamp:n||n===null?n:Date.now()};this.messages.push(a),a.type==="agent"&&W(this.typingActors,r);const i=new $(c=>{if(c!==null){const{timestamp:d=void 0,...u}=c;a.content=u,d&&(a.timestamp=d)}else{const d=this.messages.indexOf(a);a.content=null,d>-1&&this.messages.splice(d,1)}this.events.dispatch("conversation:message-updated",{message:a}),this.update()});return this.events.dispatch("conversation:message-created",{message:a}),this.update(),this.componentMounted||this.events.dispatch("conversation:unread-message",!0),i}update(){this.events.dispatch("conversation:updated",{messages:this.messages,loading:this.loaders>0,typingActors:this.typingActors})}getMessageStream(){return{messages:this.messages,loading:this.loaders>0,typingActors:this.typingActors}}setTypingState(e,t){return this.typingActors.indexOf(e)===-1&&(this.typingActors.push(e),this.update()),()=>{W(this.typingActors,e),this.update()}}loader(){this.loaders=this.loaders+1;let e=!1;return this.loaders===1&&this.update(),()=>{e||(e=!0,this.loaders=this.loaders-1,this.loaders===0&&this.update())}}submitForm(e,t){this.formHandlers[e]={...this.formHandlers[e],submit:t}}validateForm(e,t){this.formHandlers[e]={...this.formHandlers[e],validate:t}}getHistory(){return this.conversationHistory.getConversationLogs()}}const J=(o,e)=>{const t=o.split("_contact");return e.widgets.get(t[0])},I=o=>{const e=o.get("$widget"),{name:t,implementation:s}=o.get("$widget"),r=t.indexOf("_contact")>-1?J(t,s):e,{data:n}=o.get("$settings"),{trigger:a}=r.container.get("$settings"),i=`${t.replace("_contact-method","").replace("_contact","")}_contact-method`,c=s.widgets.get(i);return c&&!a?{chatWidget:c,mainWidget:r,data:n}:{mainWidget:r,data:n}},G=o=>{const{chatWidget:e}=I(o);return!!e},R=(o,e,t)=>{const{mainWidget:s,data:r,chatWidget:n}=I(o);return n?n.state==="activated"?n.invoke("open").then(()=>{n.container.getAsync("conversation").then(a=>{a.navigateToConversationIfActive(e.id).then(()=>M.closeAllModals(o))})}):n.activate().then(()=>{const{trigger:a}=n.container.get("$settings");return a.action="hide",n.invoke("setSettings",()=>({data:r,trigger:a,activate:!0})).then(()=>n.container.getAsync("components").then(i=>{const c=i.components().ofType("contact-method");i.write({key:"setContactMethodId",attributes:{properties:{id:e.id,guideId:e.guideId}},target:c,provider:"localStorage"});const d=i.components().ofType("conversation");i.write({key:"setConversationProvider",attributes:{properties:{providers:[e.clientName]}},target:d,provider:"localStorage"})}))}).then(()=>n.invoke("attach",{key:"contact-method",triggerDOMElement:t,withRenderState:"open"})).then(()=>(p.createStorageWriter(n.container,"activeStickyWidget",p.StorageCategory.Necessary,{medium:p.StorageMedium.Local,scope:p.StorageScope.Implementation}).then(a=>a(n.name)),n.container.getAsync("conversation").then(a=>{a.setConversationEndedBehavior(S.Deactivate)}).then(()=>M.closeAllModals(o)).then(()=>!1))):(s.container.getAsync("conversation").then(a=>a.navigateToConversationIfActive(e.id).then(()=>a.setConversationEndedBehavior(S.Navigate))),!n)},V=(o,e,t="conversation")=>{const{mainWidget:s,chatWidget:r}=I(o);return r?r.container.getAsync("router").then(n=>{n.navigate(t,{id:e.id})}):s.container.getAsync("conversation").then(n=>{var a;(a=n.setConversationEndedBehavior(S.Navigate))==null||a.then(()=>{s.container.getAsync("router").then(i=>{s.container.getAsync("components").then(c=>{const d=c.components().ofType("conversation");c.write({key:"setConversationProvider",attributes:{properties:{providers:[e.clientName]}},target:d,provider:"localStorage"})}).then(()=>{i.navigate(t,{id:e.id})})})})})},b="conversations";var S=(o=>(o.Deactivate="deactivate",o.Navigate="navigate",o.None="none",o))(S||{});class w{constructor(e,t){h(this,"events");h(this,"controllers",[]);h(this,"providers",[]);h(this,"disposeProviders",{});h(this,"subscriptions",[]);h(this,"storageWriter",null);h(this,"router",null);h(this,"buttonQuery",null);h(this,"sessionInfo",null);this.container=e,this.components=t;const s=e.get("$widget");this.events=s.events.createChild(this)}initialize(){p.createStorageWriter(this.container,b,p.StorageCategory.Necessary,{medium:p.StorageMedium.Local}).then(e=>this.storageWriter=e),p.readStorage(this.container,b,p.StorageMedium.Local).then(e=>{this.buttonQuery=this.components.components().ofType("conversation-return-button"),e&&(this.sessionInfo=e,e.id&&e.route&&this.writeToComponents({active:!0,alert:{show:!1}}))}),this.container.getAsync("router").then(e=>this.router=e),this.events.subscribe("conversation:ended",(e,t)=>{var s,r,n;switch((s=this.sessionInfo)==null?void 0:s.conversationEndedBehavior){case"deactivate":this.container.get("$widget").deactivate();break;case"navigate":const i=(r=this.router)==null?void 0:r.getInitialRoute();i&&((n=this.router)==null||n.navigate(i.name));break}this.writeToComponents({active:!1}),this.sessionInfo=null,this.storageWriter&&this.storageWriter()})}addSubscription(e){this.subscriptions.push(e)}static getInstance(e,t="conversation"){return E.lock(e)(()=>e.getAsync(t).then(s=>{let r=s;return r||N.ComponentPlatform.getInstance(e).then(n=>(r=new w(e,n),r.initialize(),e.registerAsync(t,()=>r),r))}))}navigateToConversationIfActive(e){return p.readStorage(this.container,b,p.StorageMedium.Local).then(t=>{var s;if(t&&t.id===e&&t.route){const{name:r,params:n}=t.route;(s=this.router)==null||s.navigate(r,n)}})}setConversationEndedBehavior(e){return p.readStorage(this.container,b,p.StorageMedium.Local).then(t=>{let s=t;return s?s.conversationEndedBehavior=e:s={conversationEndedBehavior:e},this.sessionInfo=s,this.storageWriter&&this.storageWriter(this.sessionInfo)||Promise.resolve()})}async createController(e,t){const s=D(e),{agents:r}=await p.readStorage(this.container,s)||{agents:[]},n=this.controllers.findIndex(i=>i.conversation.id===e);let a;return n>-1?a=this.controllers[n].conversation:a=new H(this.container,e,t),a.setInitialStorage({agents:r||[]}),a}registerProvider(e,t){const s={name:e,handler:t};this.providers.push(s),this.controllers.filter(r=>r.conversation.providers.indexOf(e)>-1).forEach(r=>{this.invokeHandler(s,r)})}registerController(e,t){const s=this.controllers.findIndex(n=>n.conversation.id===e.id);let r;if(s<0){r={conversation:e,component:t},this.controllers.push(r);const n=a=>{a&&this.providers.filter(i=>a.indexOf(i.name)>-1).forEach(i=>{this.invokeHandler(i,r)})};return this.subscriptions.push(e.onDispose((a,i)=>{const c=this.controllers.findIndex(d=>d.conversation===i);c>-1&&this.controllers.splice(c,1),this.components.components().ofType("conversation-return-button").select().writeProperties({active:!1}),this.events.dispatch("conversation:ended",{},{bubbles:!0})})),this.subscriptions.push(e.onProvidersChange((a,i)=>{const{added:c,removed:d=[]}=i;d.forEach(u=>{(this.disposeProviders[u]||[]).forEach(l=>{l()})}),n(c)})),this.subscriptions.push(e.onStarted((a,i)=>{var d,u;const c={id:e.id,route:(d=this.router)==null?void 0:d.getRouteData(),conversationEndedBehavior:(u=this.sessionInfo)==null?void 0:u.conversationEndedBehavior};this.sessionInfo=c,this.storageWriter&&this.storageWriter(c),this.writeToComponents({active:i})})),this.subscriptions.push(e.onUnreadMessage((a,i)=>{this.events.dispatch("conversation:unread-message",i),this.writeToComponents({alert:{show:i}})})),n(e.providers),!0}return r=this.controllers[s],!1}writeToComponents(e,t="conversationReturnButtonState"){this.buttonQuery&&this.components.write({key:"conversationReturnButtonState",attributes:{properties:e},target:this.buttonQuery,provider:"localStorage"})}invokeHandler(e,t){const s=e.handler(t.conversation.createProvider(e.name),t.component);s&&(this.disposeProviders[e.name]||(this.disposeProviders[e.name]=[]),this.disposeProviders[e.name].push(s))}getComponentRoute(){return p.readStorage(this.container,b,p.StorageMedium.Local).then(e=>e==null?void 0:e.route)}dispose(){Object.keys(this.disposeProviders).forEach(e=>{this.disposeProviders[e].forEach(t=>{t()})}),this.subscriptions.forEach(e=>{e()}),this.controllers=[],this.providers=[]}static async handleContactMethodClick(e,t,s,r){if(G(t)){e.preventDefault();let n=document.getElementById("humany-dynamic-anchor");n||(n=document.createElement("a"),n.setAttribute("href","#"),n.id="humany-dynamic-anchor",document.body.appendChild(n)),R(t,s,n)}R(t,s)}static async handleContactMethodSubmit(e,t){var s,r;return(r=(s=t==null?void 0:t.body.form.meta)==null?void 0:s.conversation)!=null&&r.id?x(e,t.body.form.meta.conversation.id,t.clientName):V(e,t)}}const Y=(o,e)=>o.reduce((t,s,r)=>{var a,i;const n={...s,content:[{...s.content,key:s.key}]};if(t.length>0&&s.type!==y.System){const c=t[t.length-1];if(Math.abs(c.timestamp-s.timestamp)<e&&((a=c.sender)==null?void 0:a.name)===((i=s.sender)==null?void 0:i.name)&&c.type===s.type)return c.timestamp=s.timestamp,c.content.push({...s.content,key:s.key}),t}return t.push(n),t},[]),X=o=>Promise.all([w.getInstance(o),o.getAsync("router")]).then(([e,t])=>O.createReactComponent(o,"conversation",Promise.resolve().then(()=>require("./conversation-CZEwSpw2.js")),async s=>{const{rehydrate:r=!1}=s.properties(),a=t.getRouteData().params.id||s.node.name||"component",i=await e.createController(a,{rehydrate:r}),c=e.registerController(i,s),d=180*1e3,u=v=>{const{providers:g=[]}=v;if(g){const f=Array.isArray(g)?g:[g];return i.setProviders(f),f}};u(s.properties(u)),i.setComponentMountedState(!0);const l=v=>{const{loading:g,typingActors:f,messages:C}=v;s.writeProperties({loading:g,typingActors:f,messages:Y(C,d)})};l(i.getMessageStream()),c&&(s.writeProperties({conversationControllerId:i.id}),s.actions.create("user-submit",(v,g)=>{if(g){const{preventDefault:f,validationPromise:C}=g;if(f){C&&C().then(T=>{T&&i.user.print(T)});return}}i.user.print(v.text)}),s.actions.create("user-typing",(v,g)=>{}),s.actions.create("form",(v,g)=>{}),s.actions.create("action",(v,g)=>{}),s.actions.create("overlay-mounted",(v,g)=>{}),s.actions.create("show-overlay",(v,g)=>{s.writeProperties({overlay:{conversation:!1,secondary:!1}})}),s.actions.create("hide-overlay",(v,g)=>{s.writeProperties({overlay:null})}),s.actions.create("show-overlay-conversation",(v,g)=>{s.writeProperties({overlay:{conversation:!0,secondary:!1}})}),s.actions.create("hide-overlay-conversation",(v,g)=>{s.writeProperties({overlay:{conversation:!1,secondary:!1}})}));const m=i.events.subscribe("conversation:updated",(v,g)=>{l(g)});return()=>{i.setComponentMountedState(!1),m(),i.active||l({messages:[],typingActors:[],loading:!1})}},{reuseController:!0})),Z=o=>Promise.all([N.ComponentPlatform.getInstance(o),w.getInstance(o),o.getAsync("router")]).then(([e,t,s])=>O.createReactComponent(o,"conversation-return-button",Promise.resolve().then(()=>require("./return-button-CZfCkYSE.js")),r=>{r.actions.create("toggle",(n={})=>{var a;(a=t.getComponentRoute())==null||a.then(i=>{i&&s.navigate(i.name,i.params)})})}));var B=(o=>(o.LinkList="link-list",o.Separator="separator",o.ButtonList="button-list",o.ItemList="item-list",o.Text="text",o.HTML="html",o.VideoRequest="video-request",o))(B||{});const ee=(o,e,t)=>o.getAsync("componentResolver").then(async s=>{(await w.getInstance(o)).addSubscription(s.registerComponent(e,z.lazy(()=>t)))});exports.Agent=P;exports.ConversationComponent=X;exports.ConversationController=H;exports.ConversationEndedBehavior=S;exports.ConversationEntry=$;exports.ConversationMessageListItemType=B;exports.ConversationMessageType=y;exports.ConversationPlatform=w;exports.ConversationProvider=A;exports.ConversationReturnButtonComponent=Z;exports.registerCustomMessageComponent=ee;
|
|
1
|
+
"use strict";var _=Object.defineProperty;var q=(o,e,t)=>e in o?_(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t;var c=(o,e,t)=>q(o,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const N=require("@telia-ace/widget-core"),p=require("@telia-ace/widget-services"),E=require("@telia-ace/widget-utilities"),L=require("@telia-ace/widget-forms"),M=require("@telia-ace/widget-plugins"),O=require("@telia-ace/widget-ui"),z=require("react");class U{constructor(e){c(this,"controller");c(this,"cache",new Map);c(this,"subscriptions",[]);this.controller=e;const{events:t}=e.container.get("$widget"),s=t.subscribe("data-client:fetched",(r,n)=>{n.type==="contact-method"&&this.cache.set(n.response.id,n.response)});this.subscriptions.push(s)}getConversationLogs(){return this.controller.messages.reduce((t,s)=>{const r=k(s),{key:n,content:a,type:i,sender:d,timestamp:h}=r.content,u=this.parseEntry(a,i,d,h);return u&&t.push(u),t},[])}parseEntry(e,t,s,r){const n=h=>{let u=[],l=[],m;if(Array.isArray(h)){const[g,f]=h;m=f}else m=h;return this.createMessageContent(m).length&&(l=[...l,this.createMessageContent(m)]),u=[...u,...this.createMessageOptions(m)],{messagesAsList:l,options:u}};let a=[],i=[];if(Array.isArray(e.items)){const{items:h}=e;h.forEach(u=>{const l=n(u);a=[...a,...l.options],i=[...i,...l.messagesAsList]})}else{const h=n(e);a=[...a,...h.options],i=[...i,...h.messagesAsList]}return{options:a,message:i.length?i.join(`
|
|
2
|
+
`):void 0,source:this.createMessageSource(t),alias:this.createAlias(t,s),timestamp:r}}createMessageSource(e){return e}createAlias(e,t){return e===y.System?"system":(t==null?void 0:t.name)||"Me"}handleContactMethod(e){if(!this.cache.has(e))return;const t=this.cache.get(e);let s="";return s=this.appendText(s,`${t.clientName}:`),s=this.appendText(s,t.title),t.description&&(s=this.appendText(s,t.title)),s}getDetails(e,t=!0){if(!e)return"";const{header:s,title:r,label:n,description:a,text:i,html:d,body:h,contactMethodId:u}=e;let l="";if(u){const m=this.handleContactMethod(u.toString());m&&(l=this.appendText(l,m,t))}return s&&(l=this.appendText(l,s,t)),r&&(l=this.appendText(l,r,t)),a&&(l=this.appendText(l,a,t)),i&&(l=this.appendText(l,i,t)),n&&(l=this.appendText(l,n,t)),d&&(l=this.appendText(l,d,t)),h&&typeof h=="string"&&(l=this.appendText(l,h,t)),l}createMessageContent(e){let t="";return t=this.getDetails(e),t}createMessageOptions(e){let t=[],s=[];return Array.isArray(e==null?void 0:e.actions)?s=e.actions:typeof(e==null?void 0:e.actions)=="object"&&(s=Object.entries(e.actions).map(([r,n])=>({actionKey:r,label:n}))),s.length&&(t=s.map(r=>this.getDetails(r,!1))),t}appendText(e,t,s=!0){return s&&e.length?`${e}
|
|
3
|
+
${t}`:e.length?`${e} ${t}`:t}dispose(){this.subscriptions.forEach(e=>{e()})}}class P{constructor(e,t){c(this,"provider");c(this,"id");c(this,"name");c(this,"avatar");c(this,"print",(e,t,s=null)=>{var i,d,h;const r={name:this.name,avatar:this.avatar,id:this.id},n=k(e,t);s=s??n.timestamp;const a=(d=(i=this.provider)==null?void 0:i.controller)==null?void 0:d.container.get("$widget");return(h=a==null?void 0:a.events)==null||h.dispatch("tracking:conversation-message",{sender:"agent"}),this.provider.createEntry(n.key,n.content,y.Agent,r,s)});c(this,"typing",()=>this.provider.setTypingState({name:this.name,avatar:this.avatar}));this.provider=e,this.id=t.id||E.uuid(),this.name=t.name,this.avatar=t.avatar}update(e){var r;const{name:t,avatar:s}=e;s===null?this.avatar=void 0:s&&(this.avatar=s),t===null?this.name=void 0:t&&(this.name=t),(r=this.provider.controller)==null||r.events.dispatch("conversation:agent-updated",{agent:this})}}class A{constructor(e,t,s){c(this,"name");c(this,"container");c(this,"controller");c(this,"subscriptions",[]);c(this,"options");c(this,"user");this.name=e,this.container=t,this.controller=s,this.user=s==null?void 0:s.user,this.options={silent:!1}}static create(e,t,s){return new A(e,t,s)}createAgent(e={}){var t;if(this.controller){const s=this.controller.getAgentById(e.id),r=s?new P(this,{...s,...e}):new P(this,e);return s||(t=this.controller)==null||t.events.dispatch("conversation:agent-created",{agent:r}),r}}print(e){var t;return(t=this.controller)==null?void 0:t.print(e)}setTypingState(e,t){var s;return(s=this.controller)==null?void 0:s.setTypingState(e,t)}loading(){return this.controller?this.controller.loader():()=>()=>{}}createEntry(e,t,s,r,n){var a;return(a=this.controller)==null?void 0:a.createEntry(e,t,s,r,n)}dispose(){var e;process.env.NODE_ENV!=="production"&&console.log(`conversation-provider: dispose (${this.name})`),(e=this.controller)==null||e.disposeProvider(this),this.controller=null,this.subscriptions.forEach(t=>t())}isRehydrated(){var e;return((e=this.controller)==null?void 0:e.isRehydrated())||Promise.resolve(!1)}getHistory(){var e;return((e=this.controller)==null?void 0:e.getHistory())||[]}complete(){var e;(e=this.controller)==null||e.onCompleteProvider()}setOptions(e={silent:!1}){this.options=e}onUnreadMessage(e){var t;if(this.controller){const s=(t=this.controller)==null?void 0:t.onUnreadMessage(e);return this.subscriptions.push(s),()=>{s()}}}onMounted(e){var t;if(this.controller){const s=(t=this.controller)==null?void 0:t.events.subscribe("conversation:component-mount-changed",e);return this.subscriptions.push(s),e({},this.controller.getComponentMountedState()),()=>{s()}}}}const D=o=>`conversation-${o}`;class K{constructor(){c(this,"_locking",Promise.resolve());c(this,"_locks",0)}isLocked(){return this._locks>0}lock(){this._locks+=1;let e;const t=new Promise(r=>e=()=>{this._locks-=1,r()}),s=this._locking.then(()=>e);return this._locking=this._locking.then(()=>t),s}}function Q(o){let e=0;if(o.length===0)return e.toString();for(let t=0;t<o.length;t++){const s=o.charCodeAt(t);e=(e<<5)-e+s,e=e&e}return e.toString()}class j{constructor(e,t,s){c(this,"container");c(this,"conversation");c(this,"enabled");c(this,"sessionStorageKey");c(this,"locker",new K);c(this,"initialStoredAgents",[]);this.container=e,this.conversation=t,this.enabled=s,this.sessionStorageKey=D(t.id),t.onStarted(async()=>{if(t.messages.length>0)return;const{agents:r}=await this.read(),n=[];r&&r.forEach(i=>{const d=t.providerIndex(i.providerName),h=d>-1?t.registeredProviders[d]:t.createProvider(i.providerName),u=new P(h,{name:i.name,avatar:i.avatar,id:i.id});n.push(u)});const{messages:a}=await this.read();a.filter(i=>(i==null?void 0:i.content)!=null).filter(i=>!i.chat||!t.providers.includes("ace.chat")).forEach(i=>{switch(i.type){case"agent":{const d=n.find(h=>{var u;return h.id===((u=i.sender)==null?void 0:u.id)});d&&d.print(i.content.items||i.content,{key:i.key},i.timestamp);return}case"user":{t.user.print(i.content.items||i.content,{key:i.key},i.timestamp);return}default:t.print(i.content.items||i.content,i.timestamp)}})}),t.onMessageCreated(async(r,n)=>{this.write(n.message,"messages")}),t.events.subscribe("conversation:agent-created",async(r,n)=>{const a={id:n.agent.id,name:n.agent.name,avatar:n.agent.avatar,providerName:n.agent.provider.name};await this.write(a,"agents")}),t.events.subscribe("conversation:agent-updated",async(r,n)=>{const{agents:a}=await this.read();await this.write([...a.map(i=>i.id===n.agent.id?{...i,name:n.agent.name,avatar:n.agent.avatar}:i)],"agents","update")})}setInitialData(e){this.initialStoredAgents=e.agents}async isRehydrated(){const{messages:e}=await this.read();return e.length>0}getStoredAgent(e){if(this.enabled)return this.initialStoredAgents.find(t=>t.id===e)}async write(e,t,s="add"){if(!this.enabled)return;const r=await this.locker.lock();return p.createStorageWriter(this.container,this.sessionStorageKey,p.StorageCategory.Necessary).then(async n=>{if(s==="add"){const a=await this.read();if(t==="messages"&&(e.chat=this.conversation.providers.includes("ace.chat"),e.hash=Q(JSON.stringify(e.content)+e.timestamp)),t==="messages"&&a.messages.findIndex(d=>d.key===e.key||d.hash===e.hash)>-1){r();return}const i={...a};return t==="messages"?i.messages=[...i.messages,e]:t==="agents"&&(i.agents=[...i.agents,e]),n({...a,...i}).then(()=>{r()})}if(s==="update"&&t==="agents"){const a=await this.read();return n({...a,agents:e}).then(()=>{r()})}return n(e).then(()=>{r()})})}async read(){return p.readStorage(this.container,this.sessionStorageKey).then(e=>e||{messages:[],agents:[]})}}class F{constructor(e){c(this,"controller");c(this,"print",(e,t,s=null)=>{var a,i;const r=k(e,t);return s=s??r.timestamp,(i=((a=this.controller)==null?void 0:a.container.get("$widget")).events)==null||i.dispatch("tracking:conversation-message",{sender:"user"}),this.controller.createEntry(r.key,r.content,y.User,void 0,s)});this.controller=e}}const x=async(o,e,t)=>{const s=await o.getAsync("conversation"),r=await o.getAsync("components"),n=s.controllers.find(a=>a.conversation.id===e);if(n){const a=[...n.conversation.providers];a.forEach(d=>{n.conversation.setProviderOptions(d,{silent:!0})}),n.conversation.queueProviders(a),n.conversation.setProviders([t]);const i=r.components().ofType("conversation");r.write({key:"setConversationProvider",attributes:{properties:{providers:[t]}},target:i,provider:"localStorage"})}};class ${constructor(e){c(this,"writer");this.writer=e}update(e){const t=this.getNormalizedSettings(e);this.writer(t)}remove(){this.writer(null)}getNormalizedSettings(e){return typeof e=="string"?{body:e}:e.length>-1&&typeof e=="object"?{items:e}:e}}var y=(o=>(o.User="user",o.Agent="agent",o.System="system",o))(y||{});const k=(o,e)=>{let t,s=(e==null?void 0:e.key)||E.uuid(),r=Date.now();if(Array.isArray(o)&&o.length>-1)typeof o[0]=="string"?t={items:[o]}:t={items:o};else if(typeof o=="string")t={body:o};else if(o=o||{},o.type)t={...o};else{if(t={body:o.body,actions:o.actions,title:o.title},o.key&&(s=o.key),o.timestamp&&(r=o.timestamp),typeof o.form=="function"){const n=L.FormBuilder.create(s);o.form(n);const a=n.get();t.form=a}o.timestamp===null&&(r=null)}return{content:t,key:s,timestamp:r}},W=(o,e)=>{if(!e)return;const t=JSON.stringify(e),s=o.findIndex(r=>t===JSON.stringify(r));if(s>-1)return o.splice(s,1)};class H{constructor(e,t,s){c(this,"container");c(this,"id");c(this,"formHandlers",{});c(this,"user",new F(this));c(this,"events");c(this,"providers",[]);c(this,"active",!1);c(this,"queuedProviders",[]);c(this,"registeredProviders",[]);c(this,"loaders",0);c(this,"componentMounted",!1);c(this,"store");c(this,"messages",[]);c(this,"typingActors",[]);c(this,"conversationHistory");c(this,"print",(e,t=null)=>{const s=k(e);t=t??s.timestamp;const r=this.container.get("$widget");return r==null||r.events.dispatch("tracking:conversation-message",{sender:"system"}),this.createEntry(s.key,s.content,"system",void 0,t)});this.container=e,this.id=t;const r=e.get("$widget");this.events=r.events.createChild(this),this.store=new j(e,this,s.rehydrate),this.conversationHistory=new U(this)}setInitialStorage(e){this.store.setInitialData(e)}setProviders(e){const t=[],s=[];this.providers.reduce((r,n)=>(e.indexOf(n)===-1&&r.push(n),r),[]).forEach(r=>{const n=this.providers.indexOf(r);n>-1&&(t.push(r),this.providers.splice(n,1))}),e.forEach(r=>{this.providers.indexOf(r)===-1&&(s.push(r),this.providers.push(r))}),(s.length||t.length)&&this.events.dispatch("conversation:providers-changed",{added:s,removed:t})}createProvider(e){const t=this.providerIndex(e);if(t>-1)return this.registeredProviders[t];const s=A.create(e,this.container,this);return this.registeredProviders.push(s),s}providerIndex(e){return this.registeredProviders.findIndex(t=>t.name===e)}getAgentById(e){if(e)return this.store.getStoredAgent(e)}dispose(){this.conversationHistory.dispose(),this.registeredProviders.forEach(e=>e.dispose()),this.messages=[],this.events.dispatch("conversation:controller-disposed",this),this.active=!1}onDispose(e){return this.events.subscribe("conversation:controller-disposed",e)}onStarted(e){return this.events.subscribe("conversation:started",e)}onMessageCreated(e){return this.events.subscribe("conversation:message-created",e)}isRehydrated(){return this.store.isRehydrated()}disposeProvider(e){const t=this.providerIndex(e.name);t>-1&&this.registeredProviders.splice(t,1),this.events.dispatch("conversation:providers-changed",{removed:[e.name]}),this.registeredProviders.length||this.dispose()}onProvidersChange(e){return this.events.subscribe("conversation:providers-changed",e)}setComponentMountedState(e){this.componentMounted!==e&&(this.componentMounted=e,e&&(this.events.dispatch("conversation:unread-message",!1),this.events.dispatch("conversation:started",!0),this.active=!0),this.events.dispatch("conversation:component-mount-changed",e))}setProviderOptions(e,t){const s=this.providerIndex(e);s>-1&&this.registeredProviders[s].setOptions(t)}changeProvider(e){this.registeredProviders.find(s=>s.name===e)&&x(this.container,this.id,e)}queueProviders(e){this.queuedProviders=e}onCompleteProvider(){const e=this.queuedProviders.pop();e&&x(this.container,this.id,e)}getComponentMountedState(){return this.componentMounted}onUnreadMessage(e){return this.events.subscribe("conversation:unread-message",e)}createEntry(e,t,s,r,n){const a={key:e,content:t,type:s,sender:r||null,timestamp:n||n===null?n:Date.now()};this.messages.push(a),a.type==="agent"&&W(this.typingActors,r);const i=new $(d=>{if(d!==null){const{timestamp:h=void 0,...u}=d;a.content=u,h&&(a.timestamp=h)}else{const h=this.messages.indexOf(a);a.content=null,h>-1&&this.messages.splice(h,1)}this.events.dispatch("conversation:message-updated",{message:a}),this.update()});return this.events.dispatch("conversation:message-created",{message:a}),this.update(),this.componentMounted||this.events.dispatch("conversation:unread-message",!0),i}update(){this.events.dispatch("conversation:updated",{messages:this.messages,loading:this.loaders>0,typingActors:this.typingActors})}getMessageStream(){return{messages:this.messages,loading:this.loaders>0,typingActors:this.typingActors}}setTypingState(e,t){return this.typingActors.indexOf(e)===-1&&(this.typingActors.push(e),this.update()),()=>{W(this.typingActors,e),this.update()}}loader(){this.loaders=this.loaders+1;let e=!1;return this.loaders===1&&this.update(),()=>{e||(e=!0,this.loaders=this.loaders-1,this.loaders===0&&this.update())}}submitForm(e,t){this.formHandlers[e]={...this.formHandlers[e],submit:t}}validateForm(e,t){this.formHandlers[e]={...this.formHandlers[e],validate:t}}getHistory(){return this.conversationHistory.getConversationLogs()}}const J=(o,e)=>{const t=o.split("_contact");return e.widgets.get(t[0])},I=o=>{const e=o.get("$widget"),{name:t,implementation:s}=o.get("$widget"),r=t.indexOf("_contact")>-1?J(t,s):e,{data:n}=o.get("$settings"),{trigger:a}=r.container.get("$settings"),i=`${t.replace("_contact-method","").replace("_contact","")}_contact-method`,d=s.widgets.get(i);return d&&!a?{chatWidget:d,mainWidget:r,data:n}:{mainWidget:r,data:n}},G=o=>{const{chatWidget:e}=I(o);return!!e},R=(o,e,t)=>{const{mainWidget:s,data:r,chatWidget:n}=I(o);return n?n.state==="activated"?n.invoke("open").then(()=>{n.container.getAsync("conversation").then(a=>{a.navigateToConversationIfActive(e.id).then(()=>M.closeAllModals(o))})}):n.activate().then(()=>{const{trigger:a}=n.container.get("$settings");return a.action="hide",n.invoke("setSettings",()=>({data:r,trigger:a,activate:!0})).then(()=>n.container.getAsync("components").then(i=>{const d=i.components().ofType("contact-method");i.write({key:"setContactMethodId",attributes:{properties:{id:e.id,guideId:e.guideId}},target:d,provider:"localStorage"});const h=i.components().ofType("conversation");i.write({key:"setConversationProvider",attributes:{properties:{providers:[e.clientName]}},target:h,provider:"localStorage"})}))}).then(()=>n.invoke("attach",{key:"contact-method",triggerDOMElement:t,withRenderState:"open"})).then(()=>(p.createStorageWriter(n.container,"activeStickyWidget",p.StorageCategory.Necessary,{medium:p.StorageMedium.Local,scope:p.StorageScope.Implementation}).then(a=>a(n.name)),n.container.getAsync("conversation").then(a=>{a.setConversationEndedBehavior(S.Deactivate)}).then(()=>M.closeAllModals(o)).then(()=>!1))):(s.container.getAsync("conversation").then(a=>a.navigateToConversationIfActive(e.id).then(()=>a.setConversationEndedBehavior(S.Navigate))),!n)},V=(o,e,t="conversation")=>{const{mainWidget:s,chatWidget:r}=I(o);return r?r.container.getAsync("router").then(n=>{n.navigate(t,{id:e.id})}):s.container.getAsync("conversation").then(n=>{var a;(a=n.setConversationEndedBehavior(S.Navigate))==null||a.then(()=>{s.container.getAsync("router").then(i=>{s.container.getAsync("components").then(d=>{const h=d.components().ofType("conversation");d.write({key:"setConversationProvider",attributes:{properties:{providers:[e.clientName]}},target:h,provider:"localStorage"})}).then(()=>{i.navigate(t,{id:e.id})})})})})},b="conversations";var S=(o=>(o.Deactivate="deactivate",o.Navigate="navigate",o.None="none",o))(S||{});class w{constructor(e,t){c(this,"container");c(this,"components");c(this,"events");c(this,"controllers",[]);c(this,"providers",[]);c(this,"disposeProviders",{});c(this,"subscriptions",[]);c(this,"storageWriter",null);c(this,"router",null);c(this,"buttonQuery",null);c(this,"sessionInfo",null);this.container=e,this.components=t;const s=e.get("$widget");this.events=s.events.createChild(this)}initialize(){p.createStorageWriter(this.container,b,p.StorageCategory.Necessary,{medium:p.StorageMedium.Local}).then(e=>this.storageWriter=e),p.readStorage(this.container,b,p.StorageMedium.Local).then(e=>{this.buttonQuery=this.components.components().ofType("conversation-return-button"),e&&(this.sessionInfo=e,e.id&&e.route&&this.writeToComponents({active:!0,alert:{show:!1}}))}),this.container.getAsync("router").then(e=>this.router=e),this.events.subscribe("conversation:ended",(e,t)=>{var s,r,n;switch((s=this.sessionInfo)==null?void 0:s.conversationEndedBehavior){case"deactivate":this.container.get("$widget").deactivate();break;case"navigate":const i=(r=this.router)==null?void 0:r.getInitialRoute();i&&((n=this.router)==null||n.navigate(i.name));break}this.writeToComponents({active:!1}),this.sessionInfo=null,this.storageWriter&&this.storageWriter()})}addSubscription(e){this.subscriptions.push(e)}static getInstance(e,t="conversation"){return E.lock(e)(()=>e.getAsync(t).then(s=>{let r=s;return r||N.ComponentPlatform.getInstance(e).then(n=>(r=new w(e,n),r.initialize(),e.registerAsync(t,()=>r),r))}))}navigateToConversationIfActive(e){return p.readStorage(this.container,b,p.StorageMedium.Local).then(t=>{var s;if(t&&t.id===e&&t.route){const{name:r,params:n}=t.route;(s=this.router)==null||s.navigate(r,n)}})}setConversationEndedBehavior(e){return p.readStorage(this.container,b,p.StorageMedium.Local).then(t=>{let s=t;return s?s.conversationEndedBehavior=e:s={conversationEndedBehavior:e},this.sessionInfo=s,this.storageWriter&&this.storageWriter(this.sessionInfo)||Promise.resolve()})}async createController(e,t){const s=D(e),{agents:r}=await p.readStorage(this.container,s)||{agents:[]},n=this.controllers.findIndex(i=>i.conversation.id===e);let a;return n>-1?a=this.controllers[n].conversation:a=new H(this.container,e,t),a.setInitialStorage({agents:r||[]}),a}registerProvider(e,t){const s={name:e,handler:t};this.providers.push(s),this.controllers.filter(r=>r.conversation.providers.indexOf(e)>-1).forEach(r=>{this.invokeHandler(s,r)})}registerController(e,t){const s=this.controllers.findIndex(n=>n.conversation.id===e.id);let r;if(s<0){r={conversation:e,component:t},this.controllers.push(r);const n=a=>{a&&this.providers.filter(i=>a.indexOf(i.name)>-1).forEach(i=>{this.invokeHandler(i,r)})};return this.subscriptions.push(e.onDispose((a,i)=>{const d=this.controllers.findIndex(h=>h.conversation===i);d>-1&&this.controllers.splice(d,1),this.components.components().ofType("conversation-return-button").select().writeProperties({active:!1}),this.events.dispatch("conversation:ended",{},{bubbles:!0})})),this.subscriptions.push(e.onProvidersChange((a,i)=>{const{added:d,removed:h=[]}=i;h.forEach(u=>{(this.disposeProviders[u]||[]).forEach(l=>{l()})}),n(d)})),this.subscriptions.push(e.onStarted((a,i)=>{var h,u;const d={id:e.id,route:(h=this.router)==null?void 0:h.getRouteData(),conversationEndedBehavior:(u=this.sessionInfo)==null?void 0:u.conversationEndedBehavior};this.sessionInfo=d,this.storageWriter&&this.storageWriter(d),this.writeToComponents({active:i})})),this.subscriptions.push(e.onUnreadMessage((a,i)=>{this.events.dispatch("conversation:unread-message",i),this.writeToComponents({alert:{show:i}})})),n(e.providers),!0}return r=this.controllers[s],!1}writeToComponents(e,t="conversationReturnButtonState"){this.buttonQuery&&this.components.write({key:"conversationReturnButtonState",attributes:{properties:e},target:this.buttonQuery,provider:"localStorage"})}invokeHandler(e,t){const s=e.handler(t.conversation.createProvider(e.name),t.component);s&&(this.disposeProviders[e.name]||(this.disposeProviders[e.name]=[]),this.disposeProviders[e.name].push(s))}getComponentRoute(){return p.readStorage(this.container,b,p.StorageMedium.Local).then(e=>e==null?void 0:e.route)}dispose(){Object.keys(this.disposeProviders).forEach(e=>{this.disposeProviders[e].forEach(t=>{t()})}),this.subscriptions.forEach(e=>{e()}),this.controllers=[],this.providers=[]}static async handleContactMethodClick(e,t,s,r){if(G(t)){e.preventDefault();let n=document.getElementById("humany-dynamic-anchor");n||(n=document.createElement("a"),n.setAttribute("href","#"),n.id="humany-dynamic-anchor",document.body.appendChild(n)),R(t,s,n)}R(t,s)}static async handleContactMethodSubmit(e,t){var s,r;return(r=(s=t==null?void 0:t.body.form.meta)==null?void 0:s.conversation)!=null&&r.id?x(e,t.body.form.meta.conversation.id,t.clientName):V(e,t)}}const Y=(o,e)=>o.reduce((t,s,r)=>{var a,i;const n={...s,content:[{...s.content,key:s.key}]};if(t.length>0&&s.type!==y.System){const d=t[t.length-1];if(Math.abs(d.timestamp-s.timestamp)<e&&((a=d.sender)==null?void 0:a.name)===((i=s.sender)==null?void 0:i.name)&&d.type===s.type)return d.timestamp=s.timestamp,d.content.push({...s.content,key:s.key}),t}return t.push(n),t},[]),X=o=>Promise.all([w.getInstance(o),o.getAsync("router")]).then(([e,t])=>O.createReactComponent(o,"conversation",Promise.resolve().then(()=>require("./conversation-Bl_75lU9.js")),async s=>{const{rehydrate:r=!1}=s.properties(),a=t.getRouteData().params.id||s.node.name||"component",i=await e.createController(a,{rehydrate:r}),d=e.registerController(i,s),h=180*1e3,u=v=>{const{providers:g=[]}=v;if(g){const f=Array.isArray(g)?g:[g];return i.setProviders(f),f}};u(s.properties(u)),i.setComponentMountedState(!0);const l=v=>{const{loading:g,typingActors:f,messages:C}=v;s.writeProperties({loading:g,typingActors:f,messages:Y(C,h)})};l(i.getMessageStream()),d&&(s.writeProperties({conversationControllerId:i.id}),s.actions.create("user-submit",(v,g)=>{if(g){const{preventDefault:f,validationPromise:C}=g;if(f){C&&C().then(T=>{T&&i.user.print(T)});return}}i.user.print(v.text)}),s.actions.create("user-typing",(v,g)=>{}),s.actions.create("form",(v,g)=>{}),s.actions.create("action",(v,g)=>{}),s.actions.create("overlay-mounted",(v,g)=>{}),s.actions.create("show-overlay",(v,g)=>{s.writeProperties({overlay:{conversation:!1,secondary:!1}})}),s.actions.create("hide-overlay",(v,g)=>{s.writeProperties({overlay:null})}),s.actions.create("show-overlay-conversation",(v,g)=>{s.writeProperties({overlay:{conversation:!0,secondary:!1}})}),s.actions.create("hide-overlay-conversation",(v,g)=>{s.writeProperties({overlay:{conversation:!1,secondary:!1}})}));const m=i.events.subscribe("conversation:updated",(v,g)=>{l(g)});return()=>{i.setComponentMountedState(!1),m(),i.active||l({messages:[],typingActors:[],loading:!1})}},{reuseController:!0})),Z=o=>Promise.all([N.ComponentPlatform.getInstance(o),w.getInstance(o),o.getAsync("router")]).then(([e,t,s])=>O.createReactComponent(o,"conversation-return-button",Promise.resolve().then(()=>require("./return-button-CZfCkYSE.js")),r=>{r.actions.create("toggle",(n={})=>{var a;(a=t.getComponentRoute())==null||a.then(i=>{i&&s.navigate(i.name,i.params)})})}));var B=(o=>(o.LinkList="link-list",o.Separator="separator",o.ButtonList="button-list",o.ItemList="item-list",o.Text="text",o.HTML="html",o.VideoRequest="video-request",o))(B||{});const ee=(o,e,t)=>o.getAsync("componentResolver").then(async s=>{(await w.getInstance(o)).addSubscription(s.registerComponent(e,z.lazy(()=>t)))});exports.Agent=P;exports.ConversationComponent=X;exports.ConversationController=H;exports.ConversationEndedBehavior=S;exports.ConversationEntry=$;exports.ConversationMessageListItemType=B;exports.ConversationMessageType=y;exports.ConversationPlatform=w;exports.ConversationProvider=A;exports.ConversationReturnButtonComponent=Z;exports.registerCustomMessageComponent=ee;
|
package/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
var B = Object.defineProperty;
|
|
2
2
|
var L = (o, e, t) => e in o ? B(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
|
|
3
|
-
var
|
|
3
|
+
var c = (o, e, t) => L(o, typeof e != "symbol" ? e + "" : e, t);
|
|
4
4
|
import { ComponentPlatform as R } from "@telia-ace/widget-core";
|
|
5
5
|
import { createStorageWriter as E, StorageCategory as I, readStorage as f, StorageScope as z, StorageMedium as y } from "@telia-ace/widget-services";
|
|
6
6
|
import { uuid as $, lock as K } from "@telia-ace/widget-utilities";
|
|
@@ -10,8 +10,9 @@ import { createReactComponent as H } from "@telia-ace/widget-ui";
|
|
|
10
10
|
import { lazy as U } from "react";
|
|
11
11
|
class q {
|
|
12
12
|
constructor(e) {
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
c(this, "controller");
|
|
14
|
+
c(this, "cache", /* @__PURE__ */ new Map());
|
|
15
|
+
c(this, "subscriptions", []);
|
|
15
16
|
this.controller = e;
|
|
16
17
|
const { events: t } = e.container.get("$widget"), s = t.subscribe("data-client:fetched", (r, n) => {
|
|
17
18
|
n.type === "contact-method" && this.cache.set(n.response.id, n.response);
|
|
@@ -21,20 +22,20 @@ class q {
|
|
|
21
22
|
getConversationLogs() {
|
|
22
23
|
return this.controller.messages.reduce(
|
|
23
24
|
(t, s) => {
|
|
24
|
-
const r = C(s), { key: n, content: a, type: i, sender:
|
|
25
|
+
const r = C(s), { key: n, content: a, type: i, sender: h, timestamp: d } = r.content, u = this.parseEntry(a, i, h, d);
|
|
25
26
|
return u && t.push(u), t;
|
|
26
27
|
},
|
|
27
28
|
[]
|
|
28
29
|
);
|
|
29
30
|
}
|
|
30
31
|
parseEntry(e, t, s, r) {
|
|
31
|
-
const n = (
|
|
32
|
+
const n = (d) => {
|
|
32
33
|
let u = [], l = [], v;
|
|
33
|
-
if (Array.isArray(
|
|
34
|
-
const [p, m] =
|
|
34
|
+
if (Array.isArray(d)) {
|
|
35
|
+
const [p, m] = d;
|
|
35
36
|
v = m;
|
|
36
37
|
} else
|
|
37
|
-
v =
|
|
38
|
+
v = d;
|
|
38
39
|
return this.createMessageContent(v).length && (l = [
|
|
39
40
|
...l,
|
|
40
41
|
this.createMessageContent(v)
|
|
@@ -45,14 +46,14 @@ class q {
|
|
|
45
46
|
};
|
|
46
47
|
let a = [], i = [];
|
|
47
48
|
if (Array.isArray(e.items)) {
|
|
48
|
-
const { items:
|
|
49
|
-
|
|
49
|
+
const { items: d } = e;
|
|
50
|
+
d.forEach((u) => {
|
|
50
51
|
const l = n(u);
|
|
51
52
|
a = [...a, ...l.options], i = [...i, ...l.messagesAsList];
|
|
52
53
|
});
|
|
53
54
|
} else {
|
|
54
|
-
const
|
|
55
|
-
a = [...a, ...
|
|
55
|
+
const d = n(e);
|
|
56
|
+
a = [...a, ...d.options], i = [...i, ...d.messagesAsList];
|
|
56
57
|
}
|
|
57
58
|
return {
|
|
58
59
|
options: a,
|
|
@@ -85,8 +86,8 @@ class q {
|
|
|
85
86
|
label: n,
|
|
86
87
|
description: a,
|
|
87
88
|
text: i,
|
|
88
|
-
html:
|
|
89
|
-
body:
|
|
89
|
+
html: h,
|
|
90
|
+
body: d,
|
|
90
91
|
contactMethodId: u
|
|
91
92
|
} = e;
|
|
92
93
|
let l = "";
|
|
@@ -94,7 +95,7 @@ class q {
|
|
|
94
95
|
const v = this.handleContactMethod(u.toString());
|
|
95
96
|
v && (l = this.appendText(l, v, t));
|
|
96
97
|
}
|
|
97
|
-
return s && (l = this.appendText(l, s, t)), r && (l = this.appendText(l, r, t)), a && (l = this.appendText(l, a, t)), i && (l = this.appendText(l, i, t)), n && (l = this.appendText(l, n, t)),
|
|
98
|
+
return s && (l = this.appendText(l, s, t)), r && (l = this.appendText(l, r, t)), a && (l = this.appendText(l, a, t)), i && (l = this.appendText(l, i, t)), n && (l = this.appendText(l, n, t)), h && (l = this.appendText(l, h, t)), d && typeof d == "string" && (l = this.appendText(l, d, t)), l;
|
|
98
99
|
}
|
|
99
100
|
createMessageContent(e) {
|
|
100
101
|
let t = "";
|
|
@@ -119,21 +120,22 @@ ${t}` : e.length ? `${e} ${t}` : t;
|
|
|
119
120
|
}
|
|
120
121
|
class k {
|
|
121
122
|
constructor(e, t) {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
123
|
+
c(this, "provider");
|
|
124
|
+
c(this, "id");
|
|
125
|
+
c(this, "name");
|
|
126
|
+
c(this, "avatar");
|
|
127
|
+
c(this, "print", (e, t, s = null) => {
|
|
128
|
+
var i, h, d;
|
|
127
129
|
const r = {
|
|
128
130
|
name: this.name,
|
|
129
131
|
avatar: this.avatar,
|
|
130
132
|
id: this.id
|
|
131
133
|
}, n = C(e, t);
|
|
132
134
|
s = s ?? n.timestamp;
|
|
133
|
-
const a = (
|
|
135
|
+
const a = (h = (i = this.provider) == null ? void 0 : i.controller) == null ? void 0 : h.container.get(
|
|
134
136
|
"$widget"
|
|
135
137
|
);
|
|
136
|
-
return (
|
|
138
|
+
return (d = a == null ? void 0 : a.events) == null || d.dispatch("tracking:conversation-message", {
|
|
137
139
|
sender: "agent"
|
|
138
140
|
}), this.provider.createEntry(
|
|
139
141
|
n.key,
|
|
@@ -143,7 +145,7 @@ class k {
|
|
|
143
145
|
s
|
|
144
146
|
);
|
|
145
147
|
});
|
|
146
|
-
|
|
148
|
+
c(this, "typing", () => this.provider.setTypingState({
|
|
147
149
|
name: this.name,
|
|
148
150
|
avatar: this.avatar
|
|
149
151
|
}));
|
|
@@ -159,9 +161,12 @@ class k {
|
|
|
159
161
|
}
|
|
160
162
|
class T {
|
|
161
163
|
constructor(e, t, s) {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
164
|
+
c(this, "name");
|
|
165
|
+
c(this, "container");
|
|
166
|
+
c(this, "controller");
|
|
167
|
+
c(this, "subscriptions", []);
|
|
168
|
+
c(this, "options");
|
|
169
|
+
c(this, "user");
|
|
165
170
|
this.name = e, this.container = t, this.controller = s, this.user = s == null ? void 0 : s.user, this.options = {
|
|
166
171
|
silent: !1
|
|
167
172
|
};
|
|
@@ -238,8 +243,8 @@ class T {
|
|
|
238
243
|
const _ = (o) => `conversation-${o}`;
|
|
239
244
|
class j {
|
|
240
245
|
constructor() {
|
|
241
|
-
|
|
242
|
-
|
|
246
|
+
c(this, "_locking", Promise.resolve());
|
|
247
|
+
c(this, "_locks", 0);
|
|
243
248
|
}
|
|
244
249
|
isLocked() {
|
|
245
250
|
return this._locks > 0;
|
|
@@ -267,15 +272,18 @@ function F(o) {
|
|
|
267
272
|
}
|
|
268
273
|
class J {
|
|
269
274
|
constructor(e, t, s) {
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
275
|
+
c(this, "container");
|
|
276
|
+
c(this, "conversation");
|
|
277
|
+
c(this, "enabled");
|
|
278
|
+
c(this, "sessionStorageKey");
|
|
279
|
+
c(this, "locker", new j());
|
|
280
|
+
c(this, "initialStoredAgents", []);
|
|
273
281
|
this.container = e, this.conversation = t, this.enabled = s, this.sessionStorageKey = _(t.id), t.onStarted(async () => {
|
|
274
282
|
if (t.messages.length > 0)
|
|
275
283
|
return;
|
|
276
284
|
const { agents: r } = await this.read(), n = [];
|
|
277
285
|
r && r.forEach((i) => {
|
|
278
|
-
const
|
|
286
|
+
const h = t.providerIndex(i.providerName), d = h > -1 ? t.registeredProviders[h] : t.createProvider(i.providerName), u = new k(d, {
|
|
279
287
|
name: i.name,
|
|
280
288
|
avatar: i.avatar,
|
|
281
289
|
id: i.id
|
|
@@ -288,11 +296,11 @@ class J {
|
|
|
288
296
|
).forEach((i) => {
|
|
289
297
|
switch (i.type) {
|
|
290
298
|
case "agent": {
|
|
291
|
-
const
|
|
299
|
+
const h = n.find((d) => {
|
|
292
300
|
var u;
|
|
293
|
-
return
|
|
301
|
+
return d.id === ((u = i.sender) == null ? void 0 : u.id);
|
|
294
302
|
});
|
|
295
|
-
|
|
303
|
+
h && h.print(
|
|
296
304
|
i.content.items || i.content,
|
|
297
305
|
{
|
|
298
306
|
key: i.key
|
|
@@ -311,7 +319,6 @@ class J {
|
|
|
311
319
|
);
|
|
312
320
|
return;
|
|
313
321
|
}
|
|
314
|
-
case "system":
|
|
315
322
|
default:
|
|
316
323
|
t.print(
|
|
317
324
|
i.content.items || i.content,
|
|
@@ -373,7 +380,7 @@ class J {
|
|
|
373
380
|
if (s === "add") {
|
|
374
381
|
const a = await this.read();
|
|
375
382
|
if (t === "messages" && (e.chat = this.conversation.providers.includes("ace.chat"), e.hash = F(JSON.stringify(e.content) + e.timestamp)), t === "messages" && a.messages.findIndex(
|
|
376
|
-
(
|
|
383
|
+
(h) => h.key === e.key || h.hash === e.hash
|
|
377
384
|
) > -1) {
|
|
378
385
|
r();
|
|
379
386
|
return;
|
|
@@ -411,7 +418,8 @@ class J {
|
|
|
411
418
|
}
|
|
412
419
|
class G {
|
|
413
420
|
constructor(e) {
|
|
414
|
-
|
|
421
|
+
c(this, "controller");
|
|
422
|
+
c(this, "print", (e, t, s = null) => {
|
|
415
423
|
var a, i;
|
|
416
424
|
const r = C(e, t);
|
|
417
425
|
return s = s ?? r.timestamp, (i = ((a = this.controller) == null ? void 0 : a.container.get("$widget")).events) == null || i.dispatch("tracking:conversation-message", {
|
|
@@ -433,8 +441,8 @@ const x = async (o, e, t) => {
|
|
|
433
441
|
), r = await o.getAsync("components"), n = s.controllers.find((a) => a.conversation.id === e);
|
|
434
442
|
if (n) {
|
|
435
443
|
const a = [...n.conversation.providers];
|
|
436
|
-
a.forEach((
|
|
437
|
-
n.conversation.setProviderOptions(
|
|
444
|
+
a.forEach((h) => {
|
|
445
|
+
n.conversation.setProviderOptions(h, { silent: !0 });
|
|
438
446
|
}), n.conversation.queueProviders(a), n.conversation.setProviders([t]);
|
|
439
447
|
const i = r.components().ofType("conversation");
|
|
440
448
|
r.write({
|
|
@@ -449,6 +457,7 @@ const x = async (o, e, t) => {
|
|
|
449
457
|
};
|
|
450
458
|
class V {
|
|
451
459
|
constructor(e) {
|
|
460
|
+
c(this, "writer");
|
|
452
461
|
this.writer = e;
|
|
453
462
|
}
|
|
454
463
|
update(e) {
|
|
@@ -496,23 +505,25 @@ const C = (o, e) => {
|
|
|
496
505
|
};
|
|
497
506
|
class Y {
|
|
498
507
|
constructor(e, t, s) {
|
|
499
|
-
|
|
508
|
+
c(this, "container");
|
|
509
|
+
c(this, "id");
|
|
510
|
+
c(this, "formHandlers", {});
|
|
500
511
|
/**
|
|
501
512
|
* Represents the current end user.
|
|
502
513
|
*/
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
514
|
+
c(this, "user", new G(this));
|
|
515
|
+
c(this, "events");
|
|
516
|
+
c(this, "providers", []);
|
|
517
|
+
c(this, "active", !1);
|
|
518
|
+
c(this, "queuedProviders", []);
|
|
519
|
+
c(this, "registeredProviders", []);
|
|
520
|
+
c(this, "loaders", 0);
|
|
521
|
+
c(this, "componentMounted", !1);
|
|
522
|
+
c(this, "store");
|
|
523
|
+
c(this, "messages", []);
|
|
524
|
+
c(this, "typingActors", []);
|
|
525
|
+
c(this, "conversationHistory");
|
|
526
|
+
c(this, "print", (e, t = null) => {
|
|
516
527
|
const s = C(e);
|
|
517
528
|
t = t ?? s.timestamp;
|
|
518
529
|
const r = this.container.get("$widget");
|
|
@@ -617,13 +628,13 @@ class Y {
|
|
|
617
628
|
timestamp: n || n === null ? n : Date.now()
|
|
618
629
|
};
|
|
619
630
|
this.messages.push(a), a.type === "agent" && M(this.typingActors, r);
|
|
620
|
-
const i = new V((
|
|
621
|
-
if (
|
|
622
|
-
const { timestamp:
|
|
623
|
-
a.content = u,
|
|
631
|
+
const i = new V((h) => {
|
|
632
|
+
if (h !== null) {
|
|
633
|
+
const { timestamp: d = void 0, ...u } = h;
|
|
634
|
+
a.content = u, d && (a.timestamp = d);
|
|
624
635
|
} else {
|
|
625
|
-
const
|
|
626
|
-
a.content = null,
|
|
636
|
+
const d = this.messages.indexOf(a);
|
|
637
|
+
a.content = null, d > -1 && this.messages.splice(d, 1);
|
|
627
638
|
}
|
|
628
639
|
this.events.dispatch("conversation:message-updated", { message: a }), this.update();
|
|
629
640
|
});
|
|
@@ -672,8 +683,8 @@ const X = (o, e) => {
|
|
|
672
683
|
const t = o.split("_contact");
|
|
673
684
|
return e.widgets.get(t[0]);
|
|
674
685
|
}, N = (o) => {
|
|
675
|
-
const e = o.get("$widget"), { name: t, implementation: s } = o.get("$widget"), r = t.indexOf("_contact") > -1 ? X(t, s) : e, { data: n } = o.get("$settings"), { trigger: a } = r.container.get("$settings"), i = `${t.replace("_contact-method", "").replace("_contact", "")}_contact-method`,
|
|
676
|
-
return
|
|
686
|
+
const e = o.get("$widget"), { name: t, implementation: s } = o.get("$widget"), r = t.indexOf("_contact") > -1 ? X(t, s) : e, { data: n } = o.get("$settings"), { trigger: a } = r.container.get("$settings"), i = `${t.replace("_contact-method", "").replace("_contact", "")}_contact-method`, h = s.widgets.get(i);
|
|
687
|
+
return h && !a ? { chatWidget: h, mainWidget: r, data: n } : { mainWidget: r, data: n };
|
|
677
688
|
}, Z = (o) => {
|
|
678
689
|
const { chatWidget: e } = N(o);
|
|
679
690
|
return !!e;
|
|
@@ -690,7 +701,7 @@ const X = (o, e) => {
|
|
|
690
701
|
trigger: a,
|
|
691
702
|
activate: !0
|
|
692
703
|
})).then(() => n.container.getAsync("components").then((i) => {
|
|
693
|
-
const
|
|
704
|
+
const h = i.components().ofType("contact-method");
|
|
694
705
|
i.write({
|
|
695
706
|
key: "setContactMethodId",
|
|
696
707
|
attributes: {
|
|
@@ -699,16 +710,16 @@ const X = (o, e) => {
|
|
|
699
710
|
guideId: e.guideId
|
|
700
711
|
}
|
|
701
712
|
},
|
|
702
|
-
target:
|
|
713
|
+
target: h,
|
|
703
714
|
provider: "localStorage"
|
|
704
715
|
});
|
|
705
|
-
const
|
|
716
|
+
const d = i.components().ofType("conversation");
|
|
706
717
|
i.write({
|
|
707
718
|
key: "setConversationProvider",
|
|
708
719
|
attributes: {
|
|
709
720
|
properties: { providers: [e.clientName] }
|
|
710
721
|
},
|
|
711
|
-
target:
|
|
722
|
+
target: d,
|
|
712
723
|
provider: "localStorage"
|
|
713
724
|
});
|
|
714
725
|
}));
|
|
@@ -741,14 +752,14 @@ const X = (o, e) => {
|
|
|
741
752
|
var a;
|
|
742
753
|
(a = n.setConversationEndedBehavior(S.Navigate)) == null || a.then(() => {
|
|
743
754
|
s.container.getAsync("router").then((i) => {
|
|
744
|
-
s.container.getAsync("components").then((
|
|
745
|
-
const
|
|
746
|
-
|
|
755
|
+
s.container.getAsync("components").then((h) => {
|
|
756
|
+
const d = h.components().ofType("conversation");
|
|
757
|
+
h.write({
|
|
747
758
|
key: "setConversationProvider",
|
|
748
759
|
attributes: {
|
|
749
760
|
properties: { providers: [e.clientName] }
|
|
750
761
|
},
|
|
751
|
-
target:
|
|
762
|
+
target: d,
|
|
752
763
|
provider: "localStorage"
|
|
753
764
|
});
|
|
754
765
|
}).then(() => {
|
|
@@ -761,15 +772,17 @@ const X = (o, e) => {
|
|
|
761
772
|
var S = /* @__PURE__ */ ((o) => (o.Deactivate = "deactivate", o.Navigate = "navigate", o.None = "none", o))(S || {});
|
|
762
773
|
class A {
|
|
763
774
|
constructor(e, t) {
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
775
|
+
c(this, "container");
|
|
776
|
+
c(this, "components");
|
|
777
|
+
c(this, "events");
|
|
778
|
+
c(this, "controllers", []);
|
|
779
|
+
c(this, "providers", []);
|
|
780
|
+
c(this, "disposeProviders", {});
|
|
781
|
+
c(this, "subscriptions", []);
|
|
782
|
+
c(this, "storageWriter", null);
|
|
783
|
+
c(this, "router", null);
|
|
784
|
+
c(this, "buttonQuery", null);
|
|
785
|
+
c(this, "sessionInfo", null);
|
|
773
786
|
this.container = e, this.components = t;
|
|
774
787
|
const s = e.get("$widget");
|
|
775
788
|
this.events = s.events.createChild(this);
|
|
@@ -864,34 +877,34 @@ class A {
|
|
|
864
877
|
};
|
|
865
878
|
return this.subscriptions.push(
|
|
866
879
|
e.onDispose((a, i) => {
|
|
867
|
-
const
|
|
868
|
-
(
|
|
880
|
+
const h = this.controllers.findIndex(
|
|
881
|
+
(d) => d.conversation === i
|
|
869
882
|
);
|
|
870
|
-
|
|
883
|
+
h > -1 && this.controllers.splice(h, 1), this.components.components().ofType("conversation-return-button").select().writeProperties({ active: !1 }), this.events.dispatch("conversation:ended", {}, { bubbles: !0 });
|
|
871
884
|
})
|
|
872
885
|
), this.subscriptions.push(
|
|
873
886
|
e.onProvidersChange((a, i) => {
|
|
874
887
|
const {
|
|
875
|
-
added:
|
|
876
|
-
removed:
|
|
888
|
+
added: h,
|
|
889
|
+
removed: d = []
|
|
877
890
|
} = i;
|
|
878
|
-
|
|
891
|
+
d.forEach((u) => {
|
|
879
892
|
(this.disposeProviders[u] || []).forEach(
|
|
880
893
|
(l) => {
|
|
881
894
|
l();
|
|
882
895
|
}
|
|
883
896
|
);
|
|
884
|
-
}), n(
|
|
897
|
+
}), n(h);
|
|
885
898
|
})
|
|
886
899
|
), this.subscriptions.push(
|
|
887
900
|
e.onStarted((a, i) => {
|
|
888
|
-
var
|
|
889
|
-
const
|
|
901
|
+
var d, u;
|
|
902
|
+
const h = {
|
|
890
903
|
id: e.id,
|
|
891
|
-
route: (
|
|
904
|
+
route: (d = this.router) == null ? void 0 : d.getRouteData(),
|
|
892
905
|
conversationEndedBehavior: (u = this.sessionInfo) == null ? void 0 : u.conversationEndedBehavior
|
|
893
906
|
};
|
|
894
|
-
this.sessionInfo =
|
|
907
|
+
this.sessionInfo = h, this.storageWriter && this.storageWriter(h), this.writeToComponents({ active: i });
|
|
895
908
|
})
|
|
896
909
|
), this.subscriptions.push(
|
|
897
910
|
e.onUnreadMessage((a, i) => {
|
|
@@ -956,9 +969,9 @@ const te = (o, e) => o.reduce((t, s, r) => {
|
|
|
956
969
|
content: [{ ...s.content, key: s.key }]
|
|
957
970
|
};
|
|
958
971
|
if (t.length > 0 && s.type !== w.System) {
|
|
959
|
-
const
|
|
960
|
-
if (Math.abs(
|
|
961
|
-
return
|
|
972
|
+
const h = t[t.length - 1];
|
|
973
|
+
if (Math.abs(h.timestamp - s.timestamp) < e && ((a = h.sender) == null ? void 0 : a.name) === ((i = s.sender) == null ? void 0 : i.name) && h.type === s.type)
|
|
974
|
+
return h.timestamp = s.timestamp, h.content.push({ ...s.content, key: s.key }), t;
|
|
962
975
|
}
|
|
963
976
|
return t.push(n), t;
|
|
964
977
|
}, []), le = (o) => Promise.all([
|
|
@@ -967,14 +980,14 @@ const te = (o, e) => o.reduce((t, s, r) => {
|
|
|
967
980
|
]).then(([e, t]) => H(
|
|
968
981
|
o,
|
|
969
982
|
"conversation",
|
|
970
|
-
import("./conversation-
|
|
983
|
+
import("./conversation-DzOpPoC3.mjs"),
|
|
971
984
|
async (s) => {
|
|
972
985
|
const { rehydrate: r = !1 } = s.properties(), a = t.getRouteData().params.id || s.node.name || "component", i = await e.createController(a, {
|
|
973
986
|
rehydrate: r
|
|
974
|
-
}),
|
|
987
|
+
}), h = e.registerController(
|
|
975
988
|
i,
|
|
976
989
|
s
|
|
977
|
-
),
|
|
990
|
+
), d = 180 * 1e3, u = (g) => {
|
|
978
991
|
const { providers: p = [] } = g;
|
|
979
992
|
if (p) {
|
|
980
993
|
const m = Array.isArray(p) ? p : [p];
|
|
@@ -989,10 +1002,10 @@ const te = (o, e) => o.reduce((t, s, r) => {
|
|
|
989
1002
|
s.writeProperties({
|
|
990
1003
|
loading: p,
|
|
991
1004
|
typingActors: m,
|
|
992
|
-
messages: te(P,
|
|
1005
|
+
messages: te(P, d)
|
|
993
1006
|
});
|
|
994
1007
|
};
|
|
995
|
-
l(i.getMessageStream()),
|
|
1008
|
+
l(i.getMessageStream()), h && (s.writeProperties({
|
|
996
1009
|
conversationControllerId: i.id
|
|
997
1010
|
}), s.actions.create("user-submit", (g, p) => {
|
|
998
1011
|
if (p) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@telia-ace/widget-conversation",
|
|
3
|
-
"version": "1.3.59-rc.
|
|
3
|
+
"version": "1.3.59-rc.2",
|
|
4
4
|
"main": "./index.js",
|
|
5
5
|
"types": "./index.d.ts",
|
|
6
6
|
"exports": {
|
|
@@ -10,13 +10,13 @@
|
|
|
10
10
|
}
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@telia-ace/widget-core": "^1.3.59-rc.
|
|
14
|
-
"@telia-ace/widget-forms": "^1.3.59-rc.
|
|
15
|
-
"@telia-ace/widget-plugins": "^1.3.59-rc.
|
|
16
|
-
"@telia-ace/widget-routing": "^1.3.59-rc.
|
|
17
|
-
"@telia-ace/widget-services": "^1.3.59-rc.
|
|
18
|
-
"@telia-ace/widget-ui": "^1.3.59-rc.
|
|
19
|
-
"@telia-ace/widget-utilities": "^1.3.59-rc.
|
|
13
|
+
"@telia-ace/widget-core": "^1.3.59-rc.2",
|
|
14
|
+
"@telia-ace/widget-forms": "^1.3.59-rc.2",
|
|
15
|
+
"@telia-ace/widget-plugins": "^1.3.59-rc.2",
|
|
16
|
+
"@telia-ace/widget-routing": "^1.3.59-rc.2",
|
|
17
|
+
"@telia-ace/widget-services": "^1.3.59-rc.2",
|
|
18
|
+
"@telia-ace/widget-ui": "^1.3.59-rc.2",
|
|
19
|
+
"@telia-ace/widget-utilities": "^1.3.59-rc.2",
|
|
20
20
|
"@webprovisions/platform": "^1.1.4"
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { EventSubscriptionCancellation, Widget } from '@webprovisions/platform';
|
|
2
|
+
export type EntityValueResolver = (value: any) => void;
|
|
3
|
+
export type ResolveEntityValueHandler = (resolve: EntityValueResolver, originalValue: any) => any | Promise<any>;
|
|
4
|
+
/**
|
|
5
|
+
* Registers a handler to resolve entity values initiated by the backend service.
|
|
6
|
+
* @param widget Widget to resolve the entity value for.
|
|
7
|
+
* @param name Name of entity to resolve.
|
|
8
|
+
* @param handler Handler for resolving value.
|
|
9
|
+
*/
|
|
10
|
+
export declare const resolveEntityValue: (widget: Widget, name: string, handler: ResolveEntityValueHandler) => EventSubscriptionCancellation;
|
package/store.d.ts
CHANGED
package/types.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { Form, FormBuilder } from '
|
|
2
|
-
import { Symbol } from '
|
|
3
|
-
|
|
1
|
+
import { Form, FormBuilder } from '@telia-ace/widget-forms';
|
|
2
|
+
import { Symbol } from '@telia-ace/widget-ui';
|
|
4
3
|
export type ConversationMessageSettings = {
|
|
5
4
|
key?: string;
|
|
6
5
|
timestamp?: number;
|
package/user.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { ReactComponent } from '
|
|
1
|
+
import { ReactComponent } from '@telia-ace/widget-core';
|
|
2
2
|
import { Container } from '@webprovisions/platform';
|
|
3
|
-
|
|
4
3
|
export declare const registerCustomMessageComponent: (container: Container, type: string, component: ReactComponent) => Promise<void>;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Container } from '@webprovisions/platform';
|
|
2
|
-
|
|
3
2
|
export declare const shouldPreventDefault: (container: Container) => boolean;
|
|
4
3
|
export declare const openChatWidget: (container: Container, contactMethod: any, triggerDOMTarget?: HTMLElement) => boolean | Promise<void> | Promise<boolean>;
|
|
5
4
|
export declare const navigateToConversation: (container: Container, contactMethod: any, routeName?: string) => any;
|