@telia-ace/widget-conversation 1.3.41-rc.0 → 1.3.41-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.
@@ -10,7 +10,7 @@ export type Props = {
10
10
  declare const SystemMessage: React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLDivElement>>;
11
11
  export declare const StyledSystemMessage: import('@emotion/styled').StyledComponent<any, React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
12
12
  export declare const Discrete: import('@emotion/styled').StyledComponent<{
13
- theme?: import('@emotion/react').Theme | undefined;
14
- as?: React.ElementType<any> | undefined;
13
+ theme?: import('@emotion/react').Theme;
14
+ as?: React.ElementType;
15
15
  }, React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
16
16
  export default SystemMessage;
@@ -2,5 +2,5 @@ import { default as React } from 'react';
2
2
  import { BundledConversationMessage } from '../plugin';
3
3
 
4
4
  export declare const ConversationMessage: React.ForwardRefExoticComponent<{
5
- className?: string | undefined;
5
+ className?: string;
6
6
  } & BundledConversationMessage & React.RefAttributes<HTMLDivElement>>;
@@ -3,60 +3,60 @@ import { Theme } from '@emotion/react';
3
3
  export declare const Avatar: import('@emotion/styled').StyledComponent<any, import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
4
4
  export declare const LoaderAnimation: import('@emotion/react').Keyframes;
5
5
  export declare const Loader: import('@emotion/styled').StyledComponent<{
6
- theme?: Theme | undefined;
7
- as?: import('react').ElementType<any> | undefined;
6
+ theme?: Theme;
7
+ as?: React.ElementType;
8
8
  }, import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
9
9
  export declare const ContentBundle: import('@emotion/styled').StyledComponent<{
10
- theme?: Theme | undefined;
11
- as?: import('react').ElementType<any> | undefined;
10
+ theme?: Theme;
11
+ as?: React.ElementType;
12
12
  }, import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
13
13
  export declare const MessageTitle: import('@emotion/styled').StyledComponent<import('../../../../../ui/src/index.ts').TypographyProps & {
14
- theme?: Theme | undefined;
14
+ theme?: Theme;
15
15
  }, {}, {}>;
16
16
  export declare const MessageContainer: import('@emotion/styled').StyledComponent<{
17
- theme?: Theme | undefined;
18
- as?: import('react').ElementType<any> | undefined;
17
+ theme?: Theme;
18
+ as?: React.ElementType;
19
19
  } & {
20
- left?: boolean | undefined;
21
- center?: boolean | undefined;
22
- right?: boolean | undefined;
20
+ left?: boolean;
21
+ center?: boolean;
22
+ right?: boolean;
23
23
  }, import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
24
24
  export type Stacked = 'first' | 'last' | 'middle';
25
25
  export declare const MessageContent: import('@emotion/styled').StyledComponent<{
26
- theme?: Theme | undefined;
27
- as?: import('react').ElementType<any> | undefined;
26
+ theme?: Theme;
27
+ as?: React.ElementType;
28
28
  } & {
29
- user?: boolean | undefined;
30
- fullWidth?: boolean | undefined;
31
- stacked?: Stacked | undefined;
32
- padded?: boolean | undefined;
29
+ user?: boolean;
30
+ fullWidth?: boolean;
31
+ stacked?: Stacked;
32
+ padded?: boolean;
33
33
  }, import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
34
34
  export declare const MessageContentPart: import('@emotion/styled').StyledComponent<{
35
- theme?: Theme | undefined;
36
- as?: import('react').ElementType<any> | undefined;
35
+ theme?: Theme;
36
+ as?: React.ElementType;
37
37
  }, import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
38
38
  export declare const messageContentPadding: (p: {
39
39
  theme: Theme;
40
40
  }) => import('@emotion/react').SerializedStyles;
41
41
  export declare const StyledForm: import('@emotion/styled').StyledComponent<{
42
- data?: import('../../../../../forms/src/index.ts').FormData | null | undefined;
43
- className?: string | undefined;
44
- onChange?: Function | undefined;
45
- autoFocus?: boolean | undefined;
42
+ data?: import('../../../../../forms/src/index.ts').FormData | null;
43
+ className?: string;
44
+ onChange?: Function;
45
+ autoFocus?: boolean;
46
46
  schema: import('libs/forms/src/form').FormSchema;
47
47
  layout: import('libs/forms/src/form').FormLayout;
48
48
  } & {
49
- theme?: Theme | undefined;
49
+ theme?: Theme;
50
50
  }, {}, {}>;
51
51
  export declare const StyledHtml: import('@emotion/styled').StyledComponent<any, {}, {}>;
52
52
  export declare const StyledActionList: import('@emotion/styled').StyledComponent<Omit<Merge<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLUListElement>, HTMLUListElement>, {
53
53
  renderItem: import('../../../../../ui/src/index.ts').ItemRenderer;
54
54
  items: any[];
55
- renderLi?: boolean | undefined;
55
+ renderLi?: boolean;
56
56
  }>, "ref"> & import('react').RefAttributes<HTMLUListElement> & {
57
- theme?: Theme | undefined;
57
+ theme?: Theme;
58
58
  }, {}, {}>;
59
59
  export declare const StyledActionButton: import('@emotion/styled').StyledComponent<{
60
- theme?: Theme | undefined;
61
- as?: import('react').ElementType<any> | undefined;
60
+ theme?: Theme;
61
+ as?: React.ElementType;
62
62
  }, import('react').DetailedHTMLProps<import('react').ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, {}>;
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),l=require("@emotion/styled"),n=require("@telia-ace/widget-ui"),w=require("@telia-ace/widget-utilities"),v=require("@emotion/react"),g=require("react"),J=require("@telia-ace/widget-forms"),S=require("./index.js");require("@telia-ace/widget-core");require("@telia-ace/widget-services");require("@telia-ace/widget-plugins");const Q=({className:t})=>{const[e,o]=g.useState(""),[a,i]=g.useState(0),[r,u]=g.useState(0),m=n.useIsTabbing(),d=n.useDispatch(),{inputPlaceholder:f="Type your message",inputHidden:$=!1,inputDisabled:c=!1,sendButtonLabel:h="Send message",inputMultiline:b=!0,secondaryAction:x}=n.useProperties(),[j,p]=n.useScroll(!0),T=n.useContainer();g.useEffect(()=>{if(p.current){const{lineHeight:y,maxHeight:C}=getComputedStyle(p.current);if(y&&y.indexOf("px")>-1){const z=y.split("px"),X=parseInt(z[0],10);i(X);const G=C.split("px");u(parseInt(G[0],10))}}},[p.current]);const I=y=>{!y.shiftKey||!b?(y.preventDefault(),e&&e.length>0&&(d("user-submit",{text:e}),o(""),B(""))):e.length<1&&y.preventDefault()},_=y=>{if(!x)return;y.preventDefault(),d("action",{actionKey:x.action,...x});const{events:C}=T.get("$widget");C.dispatch("tracking:secondary-clicked",{})},Y=y=>{if(b&&p.current){const C=p.current.scrollHeight;if(C>a){p.current.style.height="auto";let z=C;y.length<1&&(z=a),p.current.style.height=`${z}px`,z>=r?p.current.style.overflowY="scroll":p.current.style.overflowY="hidden"}}},B=y=>{Y(y),o(y),y&&y.length>0&&d("user-typing",{textLength:y.length})};return $?null:s.jsxs(se,{grow:b,className:w.appendClassNames("humany-conversation-input",t),scrollableCss:j,isTabbing:m,children:[x&&s.jsx(te,{className:"humany-secondary-button",disabled:c,onClick:_,title:x.label,"aria-label":x.label,children:s.jsx(n.SymbolBadge,{size:24,symbol:{type:"Svg",content:x.icon||"browse"}})}),b?s.jsx(Z,{value:e,onChange:B,onEnter:I,disabled:c,"aria-label":f,placeholder:f,type:"textarea",rows:1,ref:p}):s.jsx(ee,{value:e,onChange:B,onEnter:I,disabled:c,"aria-label":f,placeholder:f}),s.jsx(F,{className:"humany-send-button",disabled:!1,onClick:I,title:h,"aria-label":h,children:s.jsx(ne,{size:22,symbol:{type:"Svg",content:"send"},hasContent:!!e&&!!e.length})})]})},Z=l(n.Input)`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),l=require("@emotion/styled"),n=require("@telia-ace/widget-ui"),w=require("@telia-ace/widget-utilities"),v=require("@emotion/react"),g=require("react"),J=require("@telia-ace/widget-forms"),S=require("./index.js"),Q=({className:t})=>{const[e,o]=g.useState(""),[a,i]=g.useState(0),[r,u]=g.useState(0),m=n.useIsTabbing(),d=n.useDispatch(),{inputPlaceholder:f="Type your message",inputHidden:$=!1,inputDisabled:c=!1,sendButtonLabel:h="Send message",inputMultiline:b=!0,secondaryAction:x}=n.useProperties(),[j,p]=n.useScroll(!0),T=n.useContainer();g.useEffect(()=>{if(p.current){const{lineHeight:y,maxHeight:C}=getComputedStyle(p.current);if(y&&y.indexOf("px")>-1){const z=y.split("px"),X=parseInt(z[0],10);i(X);const G=C.split("px");u(parseInt(G[0],10))}}},[p.current]);const I=y=>{!y.shiftKey||!b?(y.preventDefault(),e&&e.length>0&&(d("user-submit",{text:e}),o(""),B(""))):e.length<1&&y.preventDefault()},_=y=>{if(!x)return;y.preventDefault(),d("action",{actionKey:x.action,...x});const{events:C}=T.get("$widget");C.dispatch("tracking:secondary-clicked",{})},Y=y=>{if(b&&p.current){const C=p.current.scrollHeight;if(C>a){p.current.style.height="auto";let z=C;y.length<1&&(z=a),p.current.style.height=`${z}px`,z>=r?p.current.style.overflowY="scroll":p.current.style.overflowY="hidden"}}},B=y=>{Y(y),o(y),y&&y.length>0&&d("user-typing",{textLength:y.length})};return $?null:s.jsxs(se,{grow:b,className:w.appendClassNames("humany-conversation-input",t),scrollableCss:j,isTabbing:m,children:[x&&s.jsx(te,{className:"humany-secondary-button",disabled:c,onClick:_,title:x.label,"aria-label":x.label,children:s.jsx(n.SymbolBadge,{size:24,symbol:{type:"Svg",content:x.icon||"browse"}})}),b?s.jsx(Z,{value:e,onChange:B,onEnter:I,disabled:c,"aria-label":f,placeholder:f,type:"textarea",rows:1,ref:p}):s.jsx(ee,{value:e,onChange:B,onEnter:I,disabled:c,"aria-label":f,placeholder:f}),s.jsx(F,{className:"humany-send-button",disabled:!1,onClick:I,title:h,"aria-label":h,children:s.jsx(ne,{size:22,symbol:{type:"Svg",content:"send"},hasContent:!!e&&!!e.length})})]})},Z=l(n.Input)`
2
2
  resize: none;
3
3
  flex: 1;
4
4
  flex-shrink: 1;
@@ -247,7 +247,7 @@
247
247
  line-height: 1.5em;
248
248
  grid-area: info;
249
249
  color: ${t=>{var e;return(e=t.theme.colors)==null?void 0:e.text}};
250
- `,q=(t,e)=>new Date(t).toLocaleTimeString(e||[],{hour:"numeric",minute:"2-digit"}),L=({className:t,name:e,timestamp:o,ariaHidden:a=!1})=>{const i=g.useContext(W);if(!e&&!o)return null;let r="";return e?o?r=`${e}: ${q(o,i)}`:r=e:o&&(r=q(o,i)),s.jsx(ge,{"aria-hidden":a,children:r})},U=({className:t,children:e,sender:o,timestamp:a})=>{const{avatar:i,name:r}=o,{avatarSize:u,avatarLabel:m="Avatar"}=n.useProperties();return s.jsxs(ye,{hasAvatar:!!i,className:w.appendClassNames(t,"humany-conversation-agent-message"),children:[i&&s.jsx(re,{className:"humany-agent-avatar",avatarSize:u,children:typeof i=="string"?s.jsx("img",{src:i,alt:m}):s.jsx(n.SymbolBadge,{symbol:i})}),e,s.jsx(L,{name:r,timestamp:a,ariaHidden:!0})]})},ye=l.div`
250
+ `,P=(t,e)=>new Date(t).toLocaleTimeString(e||[],{hour:"numeric",minute:"2-digit"}),L=({className:t,name:e,timestamp:o,ariaHidden:a=!1})=>{const i=g.useContext(W);if(!e&&!o)return null;let r="";return e?o?r=`${e}: ${P(o,i)}`:r=e:o&&(r=P(o,i)),s.jsx(ge,{"aria-hidden":a,children:r})},U=({className:t,children:e,sender:o,timestamp:a})=>{const{avatar:i,name:r}=o,{avatarSize:u,avatarLabel:m="Avatar"}=n.useProperties();return s.jsxs(ye,{hasAvatar:!!i,className:w.appendClassNames(t,"humany-conversation-agent-message"),children:[i&&s.jsx(re,{className:"humany-agent-avatar",avatarSize:u,children:typeof i=="string"?s.jsx("img",{src:i,alt:m}):s.jsx(n.SymbolBadge,{symbol:i})}),e,s.jsx(L,{name:r,timestamp:a,ariaHidden:!0})]})},ye=l.div`
251
251
  display: grid;
252
252
  margin-right: 10%;
253
253
  width: 90%;
@@ -506,13 +506,13 @@
506
506
  stroke: #fff;
507
507
  }
508
508
  }
509
- `,M=([t,e])=>({type:t,content:e}),qe=({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(Pe,{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})}}})},Pe=l(n.List)`
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 {
513
513
  margin: 0;
514
514
  }
515
- `,Fe=g.forwardRef(({className:t,timestamp:e,sender:o,type:a,content:i},r)=>{const u=g.useCallback(c=>{let h="first";return i.length>1&&(h=c===0?"first":c+1===i.length?"last":"middle"),h},[i]),{userLabel:m=""}=n.useProperties(),d=()=>s.jsx(s.Fragment,{children:i.map(c=>{const{key:h,body:b,title:x,form:j,actions:p}=c,T=!!b&&!x&&!j&&!p;return s.jsx(fe,{className:t,discrete:T,ref:r,timestamp:e,fullWidth:!!j||!!p,children:T&&b?s.jsx(n.Html,{html:b}):s.jsx(A,{isSystem:!0,content:c})},h)})}),f=()=>s.jsxs(s.Fragment,{children:[s.jsx(P,{className:"humany-sr-only",children:s.jsx(L,{name:o==null?void 0:o.name,timestamp:e})}),s.jsx(U,{sender:o,timestamp:e,className:t,children:s.jsx(H,{className:"humany-message-content-bundle",children:i.map((c,h)=>s.jsx(E,{className:"humany-message-container",left:!0,ref:r,children:s.jsx(A,{content:c,stacked:u(h)})},c.key))})})]}),$=()=>s.jsxs(s.Fragment,{children:[s.jsx(P,{className:"humany-sr-only",children:s.jsx(L,{name:m,timestamp:e})}),s.jsx(xe,{timestamp:e,className:t,children:s.jsx(H,{className:"humany-message-content-bundle",children:i.map((c,h)=>s.jsx(E,{className:"humany-message-container",right:!0,ref:r,children:s.jsx(A,{isUser:!0,content:c,stacked:u(h)})},c.key))})})]});switch(a){case S.ConversationMessageType.System:return d();case S.ConversationMessageType.Agent:return f();case S.ConversationMessageType.User:return $();default:return null}}),A=({content:t,isUser:e,isSystem:o,stacked:a})=>{const i=n.useDispatch(),{title:r,body:u,actions:m,form:d,items:f}=t;return f?s.jsx(R,{className:"humany-message-content",user:!!e,stacked:a,children:s.jsx(qe,{items:f,dispatch:i})}):s.jsxs(R,{className:"humany-message-content",padded:!o,user:!!e,stacked:a,fullWidth:!!d||!!m,children:[r&&s.jsx(N,{children:s.jsx(ie,{variant:"h2",children:r})}),u&&s.jsx(N,{children:s.jsx(ue,{html:u})}),d&&s.jsx(N,{children:s.jsx(de,{...d,onChange:(c,h)=>{i("form",{data:h,formKey:d.schema.id,actionKey:c})}})}),m&&s.jsx(N,{children:s.jsx(me,{items:Object.keys(m).map(c=>({label:m[c],actionKey:c})),renderItem:c=>s.jsx("li",{children:s.jsx(he,{onClick:()=>{i("action",c.actionKey)},children:c.label})},c.actionKey)})})]})},P=l.div`
515
+ `,Fe=g.forwardRef(({className:t,timestamp:e,sender:o,type:a,content:i},r)=>{const u=g.useCallback(c=>{let h="first";return i.length>1&&(h=c===0?"first":c+1===i.length?"last":"middle"),h},[i]),{userLabel:m=""}=n.useProperties(),d=()=>s.jsx(s.Fragment,{children:i.map(c=>{const{key:h,body:b,title:x,form:j,actions:p}=c,T=!!b&&!x&&!j&&!p;return s.jsx(fe,{className:t,discrete:T,ref:r,timestamp:e,fullWidth:!!j||!!p,children:T&&b?s.jsx(n.Html,{html:b}):s.jsx(A,{isSystem:!0,content:c})},h)})}),f=()=>s.jsxs(s.Fragment,{children:[s.jsx(q,{className:"humany-sr-only",children:s.jsx(L,{name:o==null?void 0:o.name,timestamp:e})}),s.jsx(U,{sender:o,timestamp:e,className:t,children:s.jsx(H,{className:"humany-message-content-bundle",children:i.map((c,h)=>s.jsx(E,{className:"humany-message-container",left:!0,ref:r,children:s.jsx(A,{content:c,stacked:u(h)})},c.key))})})]}),$=()=>s.jsxs(s.Fragment,{children:[s.jsx(q,{className:"humany-sr-only",children:s.jsx(L,{name:m,timestamp:e})}),s.jsx(xe,{timestamp:e,className:t,children:s.jsx(H,{className:"humany-message-content-bundle",children:i.map((c,h)=>s.jsx(E,{className:"humany-message-container",right:!0,ref:r,children:s.jsx(A,{isUser:!0,content:c,stacked:u(h)})},c.key))})})]});switch(a){case S.ConversationMessageType.System:return d();case S.ConversationMessageType.Agent:return f();case S.ConversationMessageType.User:return $();default:return null}}),A=({content:t,isUser:e,isSystem:o,stacked:a})=>{const i=n.useDispatch(),{title:r,body:u,actions:m,form:d,items:f}=t;return f?s.jsx(R,{className:"humany-message-content",user:!!e,stacked:a,children:s.jsx(Pe,{items:f,dispatch:i})}):s.jsxs(R,{className:"humany-message-content",padded:!o,user:!!e,stacked:a,fullWidth:!!d||!!m,children:[r&&s.jsx(N,{children:s.jsx(ie,{variant:"h2",children:r})}),u&&s.jsx(N,{children:s.jsx(ue,{html:u})}),d&&s.jsx(N,{children:s.jsx(de,{...d,onChange:(c,h)=>{i("form",{data:h,formKey:d.schema.id,actionKey:c})}})}),m&&s.jsx(N,{children:s.jsx(me,{items:Object.keys(m).map(c=>({label:m[c],actionKey:c})),renderItem:c=>s.jsx("li",{children:s.jsx(he,{onClick:()=>{i("action",c.actionKey)},children:c.label})},c.actionKey)})})]})},q=l.div`
516
516
  position: absolute !important;
517
517
  height: 1px;
518
518
  width: 1px;
@@ -1,23 +1,20 @@
1
- import { jsx as n, jsxs as h, Fragment as N } from "react/jsx-runtime";
1
+ import { jsxs as h, jsx as n, Fragment as N } from "react/jsx-runtime";
2
2
  import i from "@emotion/styled";
3
- import { Input as se, borderTabStyle as p, Button as A, SymbolBadge as w, useIsTabbing as ae, useDispatch as G, useProperties as C, useScroll as ie, useContainer as I, Typography as J, invertedHoverButton as xe, Html as Q, List as le, buttonCss as R, ItemList as K, itemList as D, Link as ke, useComponent as we, genericHtml as Se, headingElement as Z, usePrevious as Ce, list as Le, WidgetOverlayOutlet as ce, ConversationContext as ze } from "@telia-ace/widget-ui";
3
+ import { useIsTabbing as se, useDispatch as G, useProperties as C, useScroll as ae, useContainer as A, SymbolBadge as w, borderTabStyle as p, Input as ie, Button as I, Typography as J, Html as Q, invertedHoverButton as xe, List as le, buttonCss as R, itemList as K, ItemList as D, Link as ke, useComponent as we, genericHtml as Se, headingElement as Z, usePrevious as Ce, list as Le, WidgetOverlayOutlet as ce, ConversationContext as ze } from "@telia-ace/widget-ui";
4
4
  import { appendClassNames as H, htmlParentContains as Ne } from "@telia-ace/widget-utilities";
5
5
  import { css as v, keyframes as Me } from "@emotion/react";
6
6
  import de, { useState as q, useEffect as j, forwardRef as ee, useContext as Ae, Suspense as Ie, useRef as me, useMemo as He, useCallback as ue } from "react";
7
7
  import { FormComponent as Te } from "@telia-ace/widget-forms";
8
8
  import { ConversationMessageListItemType as S, ConversationMessageType as U } from "./index.mjs";
9
- import "@telia-ace/widget-core";
10
- import "@telia-ace/widget-services";
11
- import "@telia-ace/widget-plugins";
12
9
  const Oe = ({ className: t }) => {
13
- const [e, r] = q(""), [s, a] = q(0), [o, d] = q(0), m = ae(), c = G(), {
10
+ const [e, r] = q(""), [s, a] = q(0), [o, d] = q(0), m = se(), c = G(), {
14
11
  inputPlaceholder: f = "Type your message",
15
12
  inputHidden: x = !1,
16
13
  inputDisabled: l = !1,
17
14
  sendButtonLabel: u = "Send message",
18
15
  inputMultiline: b = !0,
19
16
  secondaryAction: $
20
- } = C(), [k, y] = ie(!0), O = I();
17
+ } = C(), [k, y] = ae(!0), O = A();
21
18
  j(() => {
22
19
  if (y.current) {
23
20
  const { lineHeight: g, maxHeight: z } = getComputedStyle(y.current);
@@ -122,7 +119,7 @@ const Oe = ({ className: t }) => {
122
119
  ]
123
120
  }
124
121
  );
125
- }, Be = i(se)`
122
+ }, Be = i(ie)`
126
123
  resize: none;
127
124
  flex: 1;
128
125
  flex-shrink: 1;
@@ -146,7 +143,7 @@ const Oe = ({ className: t }) => {
146
143
  ${p};
147
144
  outline-offset: 12px;
148
145
  }
149
- `, Ee = i(se)`
146
+ `, Ee = i(ie)`
150
147
  flex: 1;
151
148
  border: none;
152
149
  background-color: transparent;
@@ -172,7 +169,7 @@ const Oe = ({ className: t }) => {
172
169
  }};
173
170
  font-style: italic;
174
171
  }
175
- `, he = i(A)`
172
+ `, he = i(I)`
176
173
  flex: 0 0 50px;
177
174
  align-self: stretch;
178
175
  background-color: transparent;
@@ -624,7 +621,7 @@ const Oe = ({ className: t }) => {
624
621
  label: t[e],
625
622
  actionKey: e
626
623
  })), ot = ({ header: t, actions: e, dispatch: r }) => {
627
- const s = I(), { events: a } = s.get("$widget");
624
+ const s = A(), { events: a } = s.get("$widget");
628
625
  return /* @__PURE__ */ n(
629
626
  rt,
630
627
  {
@@ -663,8 +660,8 @@ const Oe = ({ className: t }) => {
663
660
  }
664
661
  }
665
662
  );
666
- }, rt = i(K)`
667
- ${D}
663
+ }, rt = i(D)`
664
+ ${K}
668
665
  > ul {
669
666
  display: flex;
670
667
  flex-wrap: wrap;
@@ -705,7 +702,7 @@ const Oe = ({ className: t }) => {
705
702
  return (e = t.theme.sizes) == null ? void 0 : e.small;
706
703
  }};
707
704
  }
708
- `, at = i(A)`
705
+ `, at = i(I)`
709
706
  ${R};
710
707
 
711
708
  display: block;
@@ -771,7 +768,7 @@ const Oe = ({ className: t }) => {
771
768
  ) }),
772
769
  /* @__PURE__ */ h("div", { className: "item-body", children: [
773
770
  /* @__PURE__ */ n(
774
- A,
771
+ I,
775
772
  {
776
773
  onClick: () => {
777
774
  r("action", s);
@@ -786,8 +783,8 @@ const Oe = ({ className: t }) => {
786
783
  ] }) }, s.actionKey);
787
784
  }
788
785
  }
789
- ), mt = i(K)`
790
- ${D}
786
+ ), mt = i(D)`
787
+ ${K}
791
788
 
792
789
  > .humany-paragraph {
793
790
  ${L}
@@ -874,7 +871,7 @@ const Oe = ({ className: t }) => {
874
871
  }
875
872
  }
876
873
  `, ht = ({ header: t, actions: e, dispatch: r }) => {
877
- const s = Ce(e), a = me(), o = ae(), d = I(), { events: m } = d.get("$widget");
874
+ const s = Ce(e), a = me(), o = se(), d = A(), { events: m } = d.get("$widget");
878
875
  return j(() => {
879
876
  if (s && Array.isArray(e) && Array.isArray(s) && s.length < e.length && a.current) {
880
877
  const c = a.current.querySelectorAll(
@@ -888,24 +885,23 @@ const Oe = ({ className: t }) => {
888
885
  );
889
886
  l && l.focus();
890
887
  }
891
- } else
892
- f && new MutationObserver((l, u) => {
893
- l.forEach((b) => {
894
- if (b.addedNodes) {
895
- const $ = Array.from(
896
- b.addedNodes
897
- ).find((k) => k.tagName === "BUTTON");
898
- $ && Ne(a.current, document.activeElement) && (o && $.focus(), u.disconnect());
899
- }
900
- });
901
- }).observe(f, {
902
- attributes: !1,
903
- characterData: !1,
904
- childList: !0,
905
- subtree: !0,
906
- attributeOldValue: !1,
907
- characterDataOldValue: !1
888
+ } else f && new MutationObserver((l, u) => {
889
+ l.forEach((b) => {
890
+ if (b.addedNodes) {
891
+ const $ = Array.from(
892
+ b.addedNodes
893
+ ).find((k) => k.tagName === "BUTTON");
894
+ $ && Ne(a.current, document.activeElement) && (o && $.focus(), u.disconnect());
895
+ }
908
896
  });
897
+ }).observe(f, {
898
+ attributes: !1,
899
+ characterData: !1,
900
+ childList: !0,
901
+ subtree: !0,
902
+ attributeOldValue: !1,
903
+ characterDataOldValue: !1
904
+ });
909
905
  }
910
906
  }), /* @__PURE__ */ n(
911
907
  gt,
@@ -940,8 +936,8 @@ const Oe = ({ className: t }) => {
940
936
  ) }, c.actionKey)
941
937
  }
942
938
  );
943
- }, gt = i(K)`
944
- ${D}
939
+ }, gt = i(D)`
940
+ ${K}
945
941
  ${L}
946
942
 
947
943
  ${(t) => Z(t)(
@@ -962,7 +958,7 @@ const Oe = ({ className: t }) => {
962
958
  margin: 0;
963
959
  }
964
960
  }
965
- `, ft = i(A)`
961
+ `, ft = i(I)`
966
962
  display: block;
967
963
  text-align: left;
968
964
  font-weight: 300;
@@ -1049,8 +1045,8 @@ const Oe = ({ className: t }) => {
1049
1045
  }
1050
1046
  }
1051
1047
  );
1052
- }, xt = i(K)`
1053
- ${(t) => D(t)}
1048
+ }, xt = i(D)`
1049
+ ${(t) => K(t)}
1054
1050
  > ul {
1055
1051
  display: flex;
1056
1052
  flex-wrap: wrap;
@@ -1063,7 +1059,7 @@ const Oe = ({ className: t }) => {
1063
1059
  }
1064
1060
  }
1065
1061
  ${(t) => L(t)}
1066
- `, kt = i(A)`
1062
+ `, kt = i(I)`
1067
1063
  ${R};
1068
1064
 
1069
1065
  background-color: ${(t) => t.bgColor};
@@ -1105,10 +1101,10 @@ const Oe = ({ className: t }) => {
1105
1101
  }
1106
1102
  `, E = ([t, e]) => ({ type: t, content: e }), wt = ({ items: t, dispatch: e }) => {
1107
1103
  const r = t.map(E).filter((o) => o.type.includes("ace-knowledge")).map((o) => "humany-" + o.type.toString());
1108
- return !!t.map(E).filter((o) => {
1104
+ return t.map(E).filter((o) => {
1109
1105
  const d = o == null ? void 0 : o.content, m = d == null ? void 0 : d.actions;
1110
1106
  return !!(m != null && m.filter((c) => c.actionKey === "contact").length);
1111
- }).length && r.push("humany-secondary-action-list"), !!t.map(E).filter((o) => {
1107
+ }).length && r.push("humany-secondary-action-list"), t.map(E).filter((o) => {
1112
1108
  var m;
1113
1109
  const d = o == null ? void 0 : o.content;
1114
1110
  return !!((m = d == null ? void 0 : d.tags) != null && m.includes("category"));
@@ -1296,7 +1292,7 @@ const Oe = ({ className: t }) => {
1296
1292
  left: -10000000px;
1297
1293
  top: auto;
1298
1294
  `, Lt = () => {
1299
- const { skipToLatestMessageLabel: t = "Skip to latest message" } = C(), e = I(), r = () => {
1295
+ const { skipToLatestMessageLabel: t = "Skip to latest message" } = C(), e = A(), r = () => {
1300
1296
  const s = e.get("widgetDOMElement");
1301
1297
  if (s) {
1302
1298
  const a = s.querySelectorAll(
@@ -1337,14 +1333,14 @@ const Oe = ({ className: t }) => {
1337
1333
  ${p};
1338
1334
  }
1339
1335
  `, ye = () => {
1340
- const t = I(), e = ue((l) => {
1336
+ const t = A(), e = ue((l) => {
1341
1337
  l && setTimeout(() => {
1342
1338
  l.scrollIntoView({
1343
1339
  block: "start",
1344
1340
  behavior: "smooth"
1345
1341
  });
1346
1342
  }, 250);
1347
- }, []), [r, s] = ie(!0), {
1343
+ }, []), [r, s] = ae(!0), {
1348
1344
  messages: a,
1349
1345
  loading: o,
1350
1346
  typingActors: d = [],
@@ -1543,7 +1539,7 @@ const Oe = ({ className: t }) => {
1543
1539
  return (e = t.theme.colors) == null ? void 0 : e.text;
1544
1540
  }};
1545
1541
  margin: 0;
1546
- `, Ot = i(A)`
1542
+ `, Ot = i(I)`
1547
1543
  display: flex;
1548
1544
  align-items: center;
1549
1545
  justify-content: center;
@@ -1566,13 +1562,13 @@ const Oe = ({ className: t }) => {
1566
1562
  return (e = t.theme.colors) == null ? void 0 : e.text;
1567
1563
  }};
1568
1564
  }
1569
- `, Ft = ({ className: t, ...e }) => {
1565
+ `, Ut = ({ className: t, ...e }) => {
1570
1566
  const {
1571
1567
  overlay: r,
1572
1568
  overlayConversationHeader: s,
1573
1569
  overlayConversationCloseLabel: a,
1574
1570
  conversationControllerId: o
1575
- } = C(), d = G(), c = I().get("$settings");
1571
+ } = C(), d = G(), c = A().get("$settings");
1576
1572
  return /* @__PURE__ */ n(
1577
1573
  ze.Provider,
1578
1574
  {
@@ -1615,5 +1611,5 @@ const Oe = ({ className: t }) => {
1615
1611
  flex-direction: column;
1616
1612
  `;
1617
1613
  export {
1618
- Ft as default
1614
+ Ut as default
1619
1615
  };
@@ -80,7 +80,7 @@ export declare class ConversationController {
80
80
  getAgentById(id?: string): {
81
81
  id: string;
82
82
  name: string;
83
- avatar?: string | undefined;
83
+ avatar?: string;
84
84
  providerName: string;
85
85
  } | undefined;
86
86
  dispose(): void;
@@ -113,8 +113,8 @@ export declare class ConversationController {
113
113
  submitForm(key: string, handler: SubmitHandler): void;
114
114
  validateForm(key: string, handler: ValidateHandler): void;
115
115
  getHistory(): {
116
- message?: string | undefined;
117
- options?: string[] | undefined;
116
+ message?: string;
117
+ options?: string[];
118
118
  alias: string;
119
119
  source: string;
120
120
  timestamp: number | null;
@@ -20,8 +20,8 @@ export declare class ConversationProvider {
20
20
  dispose(): void;
21
21
  isRehydrated(): Promise<boolean>;
22
22
  getHistory(): {
23
- message?: string | undefined;
24
- options?: string[] | undefined;
23
+ message?: string;
24
+ options?: string[];
25
25
  alias: string;
26
26
  source: string;
27
27
  timestamp: number | null;
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 h=(o,e,t)=>(q(o,typeof e!="symbol"?e+"":e,t),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){h(this,"cache",new Map);h(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:c,timestamp:d}=r.content,u=this.parseEntry(a,i,c,d);return u&&t.push(u),t},[])}parseEntry(e,t,s,r){const n=d=>{let u=[],l=[],m;if(Array.isArray(d)){const[g,f]=d;m=f}else m=d;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:d}=e;d.forEach(u=>{const l=n(u);a=[...a,...l.options],i=[...i,...l.messagesAsList]})}else{const d=n(e);a=[...a,...d.options],i=[...i,...d.messagesAsList]}return{options:a,message:i.length?i.join(`
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 h=(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){h(this,"cache",new Map);h(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:c,timestamp:d}=r.content,u=this.parseEntry(a,i,c,d);return u&&t.push(u),t},[])}parseEntry(e,t,s,r){const n=d=>{let u=[],l=[],m;if(Array.isArray(d)){const[g,f]=d;m=f}else m=d;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:d}=e;d.forEach(u=>{const l=n(u);a=[...a,...l.options],i=[...i,...l.messagesAsList]})}else{const d=n(e);a=[...a,...d.options],i=[...i,...d.messagesAsList]}return{options:a,message:i.length?i.join(`
2
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:c,body:d,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)),c&&(l=this.appendText(l,c,t)),d&&typeof d=="string"&&(l=this.appendText(l,d,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){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((!e&&e!==0||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-92e4cb62.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=3*60*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-f1f43984.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;
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}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-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}),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;
package/index.mjs CHANGED
@@ -1,8 +1,8 @@
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 d = (o, e, t) => (L(o, typeof e != "symbol" ? e + "" : e, t), t);
3
+ var d = (o, e, t) => L(o, typeof e != "symbol" ? e + "" : e, t);
4
4
  import { ComponentPlatform as R } from "@telia-ace/widget-core";
5
- import { createStorageWriter as E, StorageCategory as I, readStorage as f, StorageMedium as y, StorageScope as z } from "@telia-ace/widget-services";
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";
7
7
  import { FormBuilder as Q } from "@telia-ace/widget-forms";
8
8
  import { closeAllModals as D } from "@telia-ace/widget-plugins";
@@ -311,7 +311,6 @@ class J {
311
311
  );
312
312
  return;
313
313
  }
314
- case "system":
315
314
  default:
316
315
  t.print(
317
316
  i.content.items || i.content,
@@ -957,7 +956,7 @@ const te = (o, e) => o.reduce((t, s, r) => {
957
956
  };
958
957
  if (t.length > 0 && s.type !== w.System) {
959
958
  const c = t[t.length - 1];
960
- if ((!e && e !== 0 || 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)
959
+ 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)
961
960
  return c.timestamp = s.timestamp, c.content.push({ ...s.content, key: s.key }), t;
962
961
  }
963
962
  return t.push(n), t;
@@ -967,14 +966,14 @@ const te = (o, e) => o.reduce((t, s, r) => {
967
966
  ]).then(([e, t]) => H(
968
967
  o,
969
968
  "conversation",
970
- import("./conversation-3787f6ba.mjs"),
969
+ import("./conversation-DzOpPoC3.mjs"),
971
970
  async (s) => {
972
971
  const { rehydrate: r = !1 } = s.properties(), a = t.getRouteData().params.id || s.node.name || "component", i = await e.createController(a, {
973
972
  rehydrate: r
974
973
  }), c = e.registerController(
975
974
  i,
976
975
  s
977
- ), h = 3 * 60 * 1e3, u = (g) => {
976
+ ), h = 180 * 1e3, u = (g) => {
978
977
  const { providers: p = [] } = g;
979
978
  if (p) {
980
979
  const m = Array.isArray(p) ? p : [p];
@@ -1051,7 +1050,7 @@ const te = (o, e) => o.reduce((t, s, r) => {
1051
1050
  ([e, t, s]) => H(
1052
1051
  o,
1053
1052
  "conversation-return-button",
1054
- import("./return-button-3e542ab7.mjs"),
1053
+ import("./return-button-DZ4pJday.mjs"),
1055
1054
  (r) => {
1056
1055
  r.actions.create("toggle", (n = {}) => {
1057
1056
  var a;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@telia-ace/widget-conversation",
3
- "version": "1.3.41-rc.0",
3
+ "version": "1.3.41-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.41-rc.0",
14
- "@telia-ace/widget-forms": "^1.3.41-rc.0",
15
- "@telia-ace/widget-plugins": "^1.3.41-rc.0",
16
- "@telia-ace/widget-routing": "^1.3.41-rc.0",
17
- "@telia-ace/widget-services": "^1.3.41-rc.0",
18
- "@telia-ace/widget-ui": "^1.3.41-rc.0",
19
- "@telia-ace/widget-utilities": "^1.3.41-rc.0",
13
+ "@telia-ace/widget-core": "^1.3.41-rc.2",
14
+ "@telia-ace/widget-forms": "^1.3.41-rc.2",
15
+ "@telia-ace/widget-plugins": "^1.3.41-rc.2",
16
+ "@telia-ace/widget-routing": "^1.3.41-rc.2",
17
+ "@telia-ace/widget-services": "^1.3.41-rc.2",
18
+ "@telia-ace/widget-ui": "^1.3.41-rc.2",
19
+ "@telia-ace/widget-utilities": "^1.3.41-rc.2",
20
20
  "@webprovisions/platform": "^1.1.4"
21
21
  },
22
22
  "peerDependencies": {
@@ -1,7 +1,7 @@
1
1
  import { jsxs as h, jsx as a } from "react/jsx-runtime";
2
- import { keyframes as s, css as l } from "@emotion/react";
2
+ import { css as l, keyframes as s } from "@emotion/react";
3
3
  import n from "@emotion/styled";
4
- import { useProperties as u, useDispatch as b, SymbolBadge as p, Button as y, borderTabStyle as $ } from "@telia-ace/widget-ui";
4
+ import { useProperties as u, useDispatch as b, SymbolBadge as p, borderTabStyle as y, Button as $ } from "@telia-ace/widget-ui";
5
5
  const I = ({ className: e, ...t }) => {
6
6
  const {
7
7
  label: o,
@@ -113,7 +113,7 @@ const I = ({ className: e, ...t }) => {
113
113
  background-size: 200% 200%;
114
114
  animation: ${x} 1.5s ease infinite;
115
115
  `;
116
- }, j = n(y)`
116
+ }, j = n($)`
117
117
  overflow: hidden;
118
118
  padding: ${(e) => {
119
119
  var t;
@@ -138,7 +138,7 @@ const I = ({ className: e, ...t }) => {
138
138
  }
139
139
 
140
140
  &:focus-visible {
141
- ${(e) => $(e)}
141
+ ${(e) => y(e)}
142
142
  background: ${(e) => {
143
143
  var t;
144
144
  return (t = e.theme.colors) == null ? void 0 : t.text;