@telia-ace/widget-conversation 1.0.41 → 1.1.1-rc.0

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.
Files changed (58) hide show
  1. package/{dist/components → components}/conversation/ui/styles.d.ts +3 -3
  2. package/conversation-78019545.mjs +1388 -0
  3. package/conversation-905bdeb3.js +569 -0
  4. package/{dist/conversation-controller.d.ts → conversation-controller.d.ts} +2 -2
  5. package/index-1180f4a4.js +1212 -0
  6. package/index-bfc77c45.mjs +11311 -0
  7. package/index.js +1 -0
  8. package/index.mjs +15 -0
  9. package/package.json +19 -41
  10. package/return-button-7560bd06.js +93 -0
  11. package/{dist/return-button-17ecf4af.js → return-button-f3f52295.mjs} +39 -49
  12. package/use-dispatch-7cf7db21.js +1 -0
  13. package/use-dispatch-86019505.mjs +24 -0
  14. package/LICENSE.txt +0 -6
  15. package/README.md +0 -485
  16. package/dist/conversation-5f8374bf.js +0 -1376
  17. package/dist/conversation-5f8374bf.js.map +0 -1
  18. package/dist/conversation-form-adapter.d.ts +0 -7
  19. package/dist/index.js +0 -960
  20. package/dist/index.js.map +0 -1
  21. package/dist/resolve-entity-value.d.ts +0 -10
  22. package/dist/return-button-17ecf4af.js.map +0 -1
  23. /package/{dist/agent.d.ts → agent.d.ts} +0 -0
  24. /package/{dist/components → components}/conversation/conversation.d.ts +0 -0
  25. /package/{dist/components → components}/conversation/plugin.d.ts +0 -0
  26. /package/{dist/components → components}/conversation/ui/content.d.ts +0 -0
  27. /package/{dist/components → components}/conversation/ui/input.d.ts +0 -0
  28. /package/{dist/components → components}/conversation/ui/loader.d.ts +0 -0
  29. /package/{dist/components → components}/conversation/ui/message-list-items/button-list.d.ts +0 -0
  30. /package/{dist/components → components}/conversation/ui/message-list-items/custom.d.ts +0 -0
  31. /package/{dist/components → components}/conversation/ui/message-list-items/html.d.ts +0 -0
  32. /package/{dist/components → components}/conversation/ui/message-list-items/item-list.d.ts +0 -0
  33. /package/{dist/components → components}/conversation/ui/message-list-items/link-list.d.ts +0 -0
  34. /package/{dist/components → components}/conversation/ui/message-list-items/separator.d.ts +0 -0
  35. /package/{dist/components → components}/conversation/ui/message-list-items/text.d.ts +0 -0
  36. /package/{dist/components → components}/conversation/ui/message-list-items/video-request.d.ts +0 -0
  37. /package/{dist/components → components}/conversation/ui/message-types/agent.d.ts +0 -0
  38. /package/{dist/components → components}/conversation/ui/message-types/index.d.ts +0 -0
  39. /package/{dist/components → components}/conversation/ui/message-types/message-list.d.ts +0 -0
  40. /package/{dist/components → components}/conversation/ui/message-types/system.d.ts +0 -0
  41. /package/{dist/components → components}/conversation/ui/message-types/timestamp.d.ts +0 -0
  42. /package/{dist/components → components}/conversation/ui/message-types/user.d.ts +0 -0
  43. /package/{dist/components → components}/conversation/ui/message.d.ts +0 -0
  44. /package/{dist/components → components}/conversation/ui/overlay-outlets.d.ts +0 -0
  45. /package/{dist/components → components}/return-button/plugin.d.ts +0 -0
  46. /package/{dist/components → components}/return-button/return-button.d.ts +0 -0
  47. /package/{dist/conversation-history.d.ts → conversation-history.d.ts} +0 -0
  48. /package/{dist/conversation-platform.d.ts → conversation-platform.d.ts} +0 -0
  49. /package/{dist/conversation-provider.d.ts → conversation-provider.d.ts} +0 -0
  50. /package/{dist/index.d.ts → index.d.ts} +0 -0
  51. /package/{dist/store.d.ts → store.d.ts} +0 -0
  52. /package/{dist/types.d.ts → types.d.ts} +0 -0
  53. /package/{dist/user.d.ts → user.d.ts} +0 -0
  54. /package/{dist/utils → utils}/custom-message.d.ts +0 -0
  55. /package/{dist/utils → utils}/index.d.ts +0 -0
  56. /package/{dist/utils → utils}/map-actions.d.ts +0 -0
  57. /package/{dist/utils → utils}/open-chat-widget.d.ts +0 -0
  58. /package/{dist/utils → utils}/swap-provider.d.ts +0 -0
@@ -0,0 +1,569 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),n=require("./index-1180f4a4.js"),u=require("react");require("react-dom");const L=require("./use-dispatch-7cf7db21.js"),_=(e,t)=>{const r=L.useComponentDescriptor(),o=n.useContainer(),[a,i]=u.useState(void 0),m=n.useIsMounted(),c=e||r.type||"";return u.useEffect(()=>{if(c){let y;return(t||o).getAsync("componentResolver").then(g=>{if(m.current){const d=g.getComponent(c);i(d)}y=g.registerResolver(c,d=>{m.current&&i(d)})}),()=>{y&&y()}}},[m,c,t,o]),a},V=()=>{const[e,t]=u.useState(!1);return u.useEffect(()=>{const r=()=>{t(!1)},o=a=>{a.keyCode===9&&t(!0)};return window.addEventListener("keydown",o),window.addEventListener("click",r),()=>{window.removeEventListener("keydown",o),window.removeEventListener("click",r)}},[]),e},Y=({className:e})=>{const[t,r]=u.useState(""),[o,a]=u.useState(!1),[i,m]=u.useState(0),[c,y]=u.useState(0),g=V(),d=L.useDispatch(),{inputPlaceholder:l="Type your message",inputHidden:f=!1,inputDisabled:$=!1,sendButtonLabel:w="Send message",inputMultiline:x=!0,secondaryAction:p}=n.useProperties(),[P,b]=n.useScroll(!0);u.useEffect(()=>{if(b.current){const{lineHeight:h,maxHeight:S}=getComputedStyle(b.current);if(h&&h.indexOf("px")>-1){const j=h.split("px"),q=parseInt(j[0],10);m(q);const U=S.split("px");y(parseInt(U[0],10))}}},[b.current]);const z=h=>{!h.shiftKey||!x?(h.preventDefault(),t&&t.length>0&&(d("user-submit",{text:t}),r(""),T(""))):t.length<1&&h.preventDefault()},F=h=>{p&&(h.preventDefault(),d("action",{actionKey:p.action,...p}))},W=h=>{if(x&&b.current){const S=b.current.scrollHeight;if(S>i){b.current.style.height="auto";let j=S;h.length<1&&(j=i),b.current.style.height=`${j}px`,j>=c?b.current.style.overflowY="scroll":b.current.style.overflowY="hidden"}}},T=h=>{W(h),r(h),h&&h.length>0&&d("user-typing",{textLength:h.length})};return f?null:s.jsxs(X,{grow:x,className:n.appendClassNames("humany-conversation-input",e),"data-has-focus":o,scrollableCss:P,isTabbing:g,children:[p&&s.jsx(Q,{disabled:$,onClick:F,title:p.label,"aria-label":p.label,children:s.jsx(n.SymbolBadge,{size:24,symbol:{type:"Svg",content:p.icon||"browse"}})}),x?s.jsx(G,{value:t,onChange:T,onEnter:z,disabled:$,"aria-label":l,placeholder:l,onFocusChange:a,type:"textarea",rows:1,ref:b}):s.jsx(J,{value:t,onChange:T,onEnter:z,disabled:$,"aria-label":l,placeholder:l,onFocusChange:a}),s.jsx(K,{disabled:$,onClick:z,title:w,"aria-label":w,children:s.jsx(Z,{size:22,symbol:{type:"Svg",content:"send"},hasContent:!!t&&!!t.length})})]})},G=n.newStyled(n.Input)`
2
+ resize: none;
3
+ flex: 1;
4
+ flex-shrink: 1;
5
+ min-height: 1.2em;
6
+ max-height: 148px;
7
+ line-height: 1.2em;
8
+ height: 1.2em;
9
+ padding: 0;
10
+ margin: ${e=>{var t;return(t=e.theme.sizes)==null?void 0:t.medium}};
11
+ font-size: ${e=>{var t;return(t=e.theme.fonts)==null?void 0:t.normal}};
12
+ border: none;
13
+ transition: height 200ms linear;
14
+ outline: none;
15
+ `,J=n.newStyled(n.Input)`
16
+ flex: 1;
17
+ border: none;
18
+ background-color: transparent;
19
+ font-weight: 300;
20
+ font-size: ${e=>{var t;return(t=e.theme.fonts)==null?void 0:t.normal}};
21
+ line-height: 1.2em;
22
+ outline: none;
23
+ padding: ${e=>{var t;return(t=e.theme.sizes)==null?void 0:t.medium}};
24
+ color: ${e=>{var t;return(t=e.theme.colors)==null?void 0:t.text}};
25
+ &::placeholder {
26
+ color: ${e=>{var t;return(t=e.theme.colors)==null?void 0:t.textLight}};
27
+ font-style: italic;
28
+ }
29
+ `,K=n.newStyled(n.Button)`
30
+ flex: 0 0 50px;
31
+ align-self: stretch;
32
+ background-color: transparent;
33
+ display: flex;
34
+ align-items: center;
35
+ justify-content: center;
36
+ border: none;
37
+ color: #a6a6a6;
38
+ &:focus-visible {
39
+ ${n.borderTabStyle};
40
+ }
41
+ `,Q=n.newStyled(K)`
42
+ border-right: ${e=>e.theme.border};
43
+ margin: ${e=>{var t;return(t=e.theme.sizes)==null?void 0:t.normal}} 0;
44
+ `,X=n.newStyled.div`
45
+ ${e=>e.grow?n.css`
46
+ min-height: 50px;
47
+ max-height: 150px;
48
+ `:n.css`
49
+ height: 50px;
50
+ `}
51
+ flex: 0 0 auto;
52
+ display: flex;
53
+ align-items: center;
54
+ background-color: ${e=>{var t;return(t=e.theme.colors)==null?void 0:t.accent}};
55
+ border-top: ${e=>e.theme.inputBorder};
56
+ ${e=>e["data-has-focus"]&&e.isTabbing&&n.borderTabStyle}
57
+ textarea {
58
+ ${e=>!!e.scrollableCss&&e.scrollableCss}
59
+ }
60
+ `,Z=n.newStyled(({hasContent:e,...t})=>s.jsx(n.SymbolBadge,{...t}))`
61
+ line,
62
+ path {
63
+ stroke: ${e=>{var t;return e.hasContent?(t=e.theme.colors)==null?void 0:t.primary:"#a6a6a6"}};
64
+ fill: ${e=>{var t;return e.hasContent?(t=e.theme.colors)==null?void 0:t.primary:"#a6a6a6"}};
65
+ }
66
+ `,ee=n.newStyled.div`
67
+ width: ${e=>e.avatarSize||"32px"};
68
+ height: ${e=>e.avatarSize||"32px"};
69
+ border-radius: 50%;
70
+ background-color: ${e=>{var t;return(t=e.theme.colors)==null?void 0:t.accent}};
71
+ border: ${e=>e.theme.border};
72
+ grid-area: avatar;
73
+ align-self: flex-end;
74
+ justify-self: center;
75
+ overflow: hidden;
76
+ margin-right: 10px;
77
+ display: flex;
78
+ justify-content: center;
79
+ align-items: center;
80
+ color: ${e=>{var t;return(t=e.theme.colors)==null?void 0:t.text}};
81
+
82
+ > img {
83
+ height: 100%;
84
+ width: 100%;
85
+ object-fit: cover;
86
+ }
87
+
88
+ > svg {
89
+ width: 90%;
90
+ height: 90%;
91
+ padding: 10%;
92
+ color: ${e=>{var t;return(t=e.theme.colors)==null?void 0:t.text}};
93
+
94
+ line,
95
+ path,
96
+ circle,
97
+ fill {
98
+ stroke: ${e=>{var t;return(t=e.theme.colors)==null?void 0:t.text}};
99
+ }
100
+ }
101
+ `,te=n.keyframes`
102
+ 0% {
103
+ opacity: 0;
104
+ }
105
+ 75% {
106
+ opacity: 1;
107
+ }
108
+ 100% {
109
+ opacity: 0;
110
+ }
111
+ `,ne=n.newStyled.div`
112
+ display: flex;
113
+ justify-content: center;
114
+ > div {
115
+ height: 10px;
116
+ width: 10px;
117
+ border-radius: 50%;
118
+ margin: 5px;
119
+ background-color: ${e=>{var t;return(t=e.theme.colors)==null?void 0:t.text}};
120
+ animation: ${te} 1s infinite;
121
+ }
122
+ > div:nth-of-type(2) {
123
+ animation-delay: 100ms;
124
+ }
125
+ > div:nth-of-type(3) {
126
+ animation-delay: 200ms;
127
+ }
128
+ `,N=n.newStyled.div`
129
+ grid-area: content;
130
+ max-width: 100%;
131
+ overflow: hidden;
132
+ `,se=n.newStyled(n.Typography)`
133
+ font-size: ${e=>{var t;return(t=e.theme.fonts)==null?void 0:t.normal}};
134
+ font-weight: normal;
135
+ margin: 0;
136
+ `,B=n.newStyled.div`
137
+ display: flex;
138
+ ${e=>e.left&&"justify-content: start;"};
139
+ ${e=>e.center&&"justify-content: center;"};
140
+ ${e=>e.right&&"justify-content: end;"};
141
+ `,H=n.newStyled.div`
142
+ ${e=>{var t;return e.padded&&`padding: ${(t=e.theme.sizes)==null?void 0:t.medium};`}}
143
+ ${e=>!e.user&&e.stacked&&re(e.stacked,e.theme)}
144
+ ${e=>e.user&&e.stacked&&oe(e.stacked,e.theme)}
145
+
146
+ display: inline-block;
147
+ margin-top: ${e=>{var t;return(t=e.theme.sizes)==null?void 0:t.normal}};
148
+ && > * {
149
+ overflow-wrap: break-word;
150
+ word-wrap: break-word;
151
+ word-break: break-all;
152
+ word-break: break-word;
153
+ hyphens: auto;
154
+ }
155
+ max-width: 100%;
156
+ ${e=>e.fullWidth&&"width: 100%;"}
157
+ `,re=(e,t)=>{var o,a;const r=n.css`
158
+ background-color: ${(o=t.colors)==null?void 0:o.accent};
159
+ color: ${(a=t.colors)==null?void 0:a.text};
160
+ ${t.border&&`border: ${t.border};`};
161
+ `;return t.borderRadius?n.css`
162
+ ${r}
163
+
164
+ border-top-right-radius: ${t.borderRadius};
165
+ border-bottom-right-radius: ${t.borderRadius};
166
+
167
+ ${e==="first"&&`
168
+ border-top-left-radius: ${t.borderRadius};
169
+ `}
170
+
171
+ ${e==="last"&&`
172
+ border-bottom-left-radius: ${t.borderRadius};
173
+ `}
174
+ `:r},oe=(e,t)=>{var o,a;const r=n.css`
175
+ background-color: ${(o=t.colors)==null?void 0:o.primary};
176
+ color: ${(a=t.colors)==null?void 0:a.accent};
177
+ `;return t.borderRadius?n.css`
178
+ ${r}
179
+
180
+ border-top-left-radius: ${t.borderRadius};
181
+ border-bottom-left-radius: ${t.borderRadius};
182
+
183
+ ${e==="first"&&`
184
+ border-top-right-radius: ${t.borderRadius};
185
+ `}
186
+
187
+ ${e==="last"&&`
188
+ border-bottom-right-radius: ${t.borderRadius};
189
+ `}
190
+ `:r},C=n.newStyled.div`
191
+ margin-bottom: ${e=>{var t;return(t=e.theme.sizes)==null?void 0:t.normal}};
192
+ &:last-child {
193
+ margin-bottom: 0;
194
+ }
195
+ `,v=e=>{var t,r;return n.css`
196
+ margin: ${(t=e.theme.sizes)==null?void 0:t.medium} 0;
197
+ padding: 0 ${(r=e.theme.sizes)==null?void 0:r.medium};
198
+ `},ae=n.newStyled(n.Form)`
199
+ & button.humany-form-component-button {
200
+ ${e=>{var t,r,o,a;return((t=e.theme.colors)==null?void 0:t.primary)&&((r=e.theme.colors)==null?void 0:r.accent)&&n.invertedHoverButton({active:!1,primaryColor:(o=e.theme.colors)==null?void 0:o.primary,secondaryColor:(a=e.theme.colors)==null?void 0:a.accent,theme:e.theme})}};
201
+ display: block;
202
+ width: 100%;
203
+ margin-bottom: ${e=>{var t;return(t=e.theme.sizes)==null?void 0:t.normal}};
204
+ }
205
+ & button.humany-form-component-submit {
206
+ width: 100%;
207
+ margin: 0;
208
+ :not(:last-child) {
209
+ margin-bottom: ${e=>{var t;return(t=e.theme.sizes)==null?void 0:t.normal}};
210
+ }
211
+ }
212
+ `,ie=n.newStyled(n.Html)`
213
+ white-space: pre-wrap;
214
+ a {
215
+ color: ${e=>e.theme.colors.link};
216
+ &:focus {
217
+ ${e=>{var t;return((t=e.theme.accessibility)==null?void 0:t.isTabbing)&&n.borderTabStyle}};
218
+ }
219
+ }
220
+ `,le=n.newStyled(n.List)`
221
+ padding: 0;
222
+ list-style: none;
223
+ margin: 0 -${e=>{var t;return(t=e.theme.sizes)==null?void 0:t.normal}};
224
+ > li {
225
+ margin: ${e=>{var t;return(t=e.theme.sizes)==null?void 0:t.normal}};
226
+ }
227
+ `,ce=n.newStyled.button`
228
+ ${e=>n.buttonCss(e)};
229
+ display: block;
230
+ background-color: ${e=>{var t;return(t=e.theme.colors)==null?void 0:t.primary}};
231
+ width: 100%;
232
+ color: #fff;
233
+ &:focus-visible {
234
+ ${n.borderTabStyle}
235
+ background-color: transparent;
236
+ }
237
+ `,A=u.forwardRef(({boxed:e,className:t,agentData:r},o)=>s.jsx(N,{ref:o,children:s.jsx(B,{left:e,center:!e,children:s.jsx(H,{padded:!!e,stacked:e?"first":void 0,children:s.jsxs(ne,{children:[s.jsx("div",{}),s.jsx("div",{}),s.jsx("div",{})]})})})})),de=n.newStyled.p`
238
+ && {
239
+ font-size: ${e=>{var t;return(t=e.theme.fonts)==null?void 0:t.small}};
240
+ font-weight: 300;
241
+ }
242
+ margin: 0;
243
+ line-height: 1.5em;
244
+ grid-area: info;
245
+ color: ${e=>{var t;return(t=e.theme.colors)==null?void 0:t.text}};
246
+ `,E=e=>new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),k=({className:e,name:t,timestamp:r})=>{if(!t&&!r)return null;let o="";return t?r?o=`${t}: ${E(r)}`:o=t:r&&(o=E(r)),s.jsx(de,{children:o})},O=({className:e,children:t,sender:r,timestamp:o})=>{const{avatar:a,name:i}=r,{avatarSize:m}=n.useProperties();return s.jsxs(me,{hasAvatar:!!a,className:n.appendClassNames(e,"humany-conversation-agent-message"),children:[a&&s.jsx(ee,{avatarSize:m,children:typeof a=="string"?s.jsx("img",{src:a}):s.jsx(n.SymbolBadge,{symbol:a})}),t,s.jsx(k,{name:i,timestamp:o})]})},me=n.newStyled.div`
247
+ display: grid;
248
+ margin-right: 10%;
249
+ width: 90%;
250
+ ${e=>e.hasAvatar?n.css`
251
+ grid-template-columns: auto 1fr;
252
+ grid-template-rows: 1fr auto;
253
+ grid-template-areas:
254
+ 'avatar content'
255
+ '. info';
256
+ `:n.css`
257
+ grid-template-columns: 1fr;
258
+ grid-template-rows: 1fr auto;
259
+ grid-template-areas:
260
+ 'content'
261
+ 'info';
262
+ `};
263
+ `,ue=u.forwardRef(({className:e,children:t,timestamp:r,discrete:o,fullWidth:a},i)=>s.jsx(he,{ref:i,className:n.appendClassNames(e,"humany-conversation-system-message"),fullWidth:a,children:o?s.jsxs(ye,{className:"humany-conversation-discrete-message",children:[t,s.jsx(k,{timestamp:r})]}):s.jsxs(s.Fragment,{children:[t,s.jsx(k,{timestamp:r})]})})),he=n.newStyled.div`
264
+ ${e=>e.fullWidth&&"width: 100%"};
265
+ padding: 0 ${e=>{var t;return(t=e.theme.sizes)==null?void 0:t.large}};
266
+ overflow: auto;
267
+ `,ye=n.newStyled.div`
268
+ text-align: center;
269
+ word-wrap: break-word;
270
+ font-size: ${e=>{var t;return(t=e.theme.fonts)==null?void 0:t.normal}};
271
+ color: ${e=>{var t;return(t=e.theme.colors)==null?void 0:t.text}};
272
+ > p {
273
+ margin: 0;
274
+ }
275
+ `,ge=({className:e,children:t,timestamp:r})=>{const{userLabel:o=""}=n.useProperties();return s.jsxs(pe,{className:n.appendClassNames(e,"humany-conversation-user-message"),children:[t,s.jsx(k,{name:o,timestamp:r})]})},pe=n.newStyled.div`
276
+ margin-left: 10%;
277
+ width: 90%;
278
+ display: flex;
279
+ flex-direction: column;
280
+ align-items: flex-end;
281
+ `,R=e=>Array.isArray(e)?e:Object.keys(e).map(t=>({label:e[t],actionKey:t})),be=({header:e,actions:t,dispatch:r})=>s.jsx(fe,{className:"humany-conversation-button-list",header:e,items:R(t),renderItem:o=>s.jsx("li",{children:s.jsxs(xe,{onClick:()=>{r("action",o)},"aria-label":o.label,title:o.label,children:[s.jsx(n.SymbolBadge,{symbol:o.symbol}),o.label]})},o.actionKey)}),fe=n.newStyled(n.ItemList)`
282
+ ${n.itemList}
283
+ > ul {
284
+ display: flex;
285
+ flex-wrap: wrap;
286
+ gap: ${e=>{var t;return(t=e.theme.sizes)==null?void 0:t.normal}};
287
+ > li {
288
+ margin: 0;
289
+ }
290
+ }
291
+ ${v}
292
+ `,xe=n.newStyled(n.Button)`
293
+ ${n.buttonCss};
294
+
295
+ display: block;
296
+ padding: ${e=>{var t;return(t=e.theme.sizes)==null?void 0:t.normal}};
297
+ background-color: ${e=>{var t;return(t=e.theme.colors)==null?void 0:t.primary}};
298
+ width: 100%;
299
+ color: #ffffff;
300
+ overflow: hidden;
301
+ text-overflow: ellipsis;
302
+ &:focus-visible {
303
+ ${n.borderTabStyle}
304
+ background-color: transparent;
305
+ }
306
+
307
+ i,
308
+ svg {
309
+ margin-right: ${e=>{var t;return(t=e.theme.sizes)==null?void 0:t.small}};
310
+ }
311
+ `,ve=({type:e,content:t={}})=>{const r=_(e);return!r||!e?null:s.jsx(u.Suspense,{fallback:null,children:s.jsx(r,{...t})})},$e=({body:e})=>s.jsx(we,{html:e}),we=n.newStyled(n.Html)`
312
+ ${n.genericHtml}
313
+ color: inherit;
314
+ white-space: pre-wrap;
315
+ ${v}
316
+ a {
317
+ color: ${e=>e.theme.colors.link};
318
+ &:focus-visible {
319
+ ${n.borderTabStyle};
320
+ }
321
+ }
322
+ `,je=({header:e,actions:t,dispatch:r})=>s.jsx(Se,{className:"humany-conversation-item-list",header:e,items:R(t),renderItem:o=>{var a;return s.jsx("li",{children:s.jsxs(Ce,{children:[((a=o.symbol)==null?void 0:a.content)&&s.jsx("div",{className:"item-icon",children:s.jsx(n.SymbolBadge,{size:22,symbol:{type:o.symbol.type,content:o.symbol.content}})}),s.jsxs("div",{className:"item-body",children:[s.jsx(n.Button,{onClick:()=>{r("action",o)},"aria-label":o.label,title:o.label,children:o.label}),o.description&&s.jsx("p",{children:o.description})]})]})},o.actionKey)}}),Se=n.newStyled(n.ItemList)`
323
+ ${n.itemList}
324
+
325
+ > .humany-paragraph {
326
+ ${v}
327
+ margin-bottom: 0;
328
+
329
+ h1 {
330
+ margin: 0;
331
+ }
332
+ }
333
+
334
+ ${e=>n.headingElement(e)("h1",n.css`
335
+ white-space: normal;
336
+ `)}
337
+
338
+ > ul {
339
+ display: flex;
340
+ flex-direction: column;
341
+ gap: ${e=>{var t;return(t=e.theme.sizes)==null?void 0:t.normal}};
342
+ > li {
343
+ margin: 0;
344
+ }
345
+ }
346
+
347
+ li {
348
+ border-bottom: ${e=>e.theme.border};
349
+
350
+ &:last-of-type {
351
+ border-bottom: none;
352
+ }
353
+ }
354
+ `,Ce=n.newStyled.div`
355
+ display: flex;
356
+ gap: ${e=>{var t;return(t=e.theme.sizes)==null?void 0:t.medium}};
357
+ ${v}
358
+
359
+ .item-icon {
360
+ }
361
+
362
+ .item-body {
363
+ display: flex;
364
+ flex-direction: column;
365
+ align-items: flex-start;
366
+ gap: ${e=>{var t;return(t=e.theme.sizes)==null?void 0:t.normal}};
367
+
368
+ p {
369
+ margin: 0;
370
+ white-space: normal;
371
+ }
372
+ }
373
+
374
+ button {
375
+ background: transparent;
376
+ border: none;
377
+ font-family: inherit;
378
+ font-size: ${e=>{var t;return(t=e.theme.fonts)==null?void 0:t.normal}};
379
+ cursor: pointer;
380
+ padding: 0;
381
+ margin: 0;
382
+
383
+ &:focus-visible {
384
+ ${n.borderTabStyle}
385
+ span {
386
+ color: ${e=>{var t;return(t=e.theme.colors)==null?void 0:t.primary}};
387
+ text-decoration: underline;
388
+ }
389
+ }
390
+ }
391
+ `,ke=({header:e,actions:t,dispatch:r})=>s.jsx(Le,{className:"humany-conversation-link-list",header:e,items:R(t),renderItem:o=>s.jsx("li",{children:s.jsxs(ze,{help:o.actionKey==="help",onClick:()=>{r("action",o)},"aria-label":o.label,title:o.label,children:[o.label,o.actionKey==="help"&&s.jsx(n.SymbolBadge,{size:14,symbol:{type:"Svg",content:"caret-down"}})]})},o.actionKey)}),Le=n.newStyled(n.ItemList)`
392
+ ${n.itemList}
393
+ ${v}
394
+
395
+ ${e=>n.headingElement(e)("h1",n.css`
396
+ white-space: normal;
397
+ `)}
398
+
399
+ > ul {
400
+ display: flex;
401
+ flex-direction: column;
402
+ gap: ${e=>{var t;return(t=e.theme.sizes)==null?void 0:t.normal}};
403
+ > li {
404
+ margin: 0;
405
+ }
406
+ }
407
+ `,ze=n.newStyled(n.Button)`
408
+ display: block;
409
+ text-align: left;
410
+ font-weight: 300;
411
+ color: ${e=>{var t;return(t=e.theme.colors)==null?void 0:t.primary}};
412
+ max-width: 100%;
413
+ text-overflow: ellipsis;
414
+ overflow: hidden;
415
+
416
+ ${e=>{var t,r;return e.help&&n.css`
417
+ color: ${(t=e.theme.colors)==null?void 0:t.text};
418
+ text-decoration: underline;
419
+
420
+ i,
421
+ svg {
422
+ margin-left: ${(r=e.theme.sizes)==null?void 0:r.small};
423
+ }
424
+ `}}
425
+
426
+ &:focus-visible {
427
+ ${n.borderTabStyle}
428
+ span {
429
+ color: ${e=>{var t;return(t=e.theme.colors)==null?void 0:t.primary}};
430
+ text-decoration: underline;
431
+ }
432
+ }
433
+ `,Te=()=>s.jsx(Ie,{className:"humany-conversation-separator"}),Ie=n.newStyled.div`
434
+ ${e=>e.theme.border&&`border-bottom: ${e.theme.border};`}
435
+ width: 100%;
436
+ `,Me=({text:e})=>s.jsx(Ne,{className:"humany-conversation-text",variant:"span",children:e}),Ne=n.newStyled(n.Typography)`
437
+ ${v}
438
+ `,Be=({header:e="Video call",acceptLabel:t="Accept",declineLabel:r="Decline",dispatch:o})=>{const a=u.useMemo(()=>[{label:t,actionKey:"accept-video-call",symbol:{type:"Svg",content:"video"}},{label:r,actionKey:"decline-video-call",symbol:{type:"Svg",content:"close"}}],[t,r]);return s.jsx(He,{className:"humany-conversation-video-request",header:e,items:a,renderItem:i=>{const m=i.actionKey==="accept-video-call"?"#70c48e":"#da5c85";return s.jsx("li",{children:s.jsx(Re,{onClick:()=>{o("action",i)},"aria-label":i.label,title:i.label,bgColor:m,children:s.jsx(n.SymbolBadge,{symbol:i.symbol,size:25})})},i.actionKey)}})},He=n.newStyled(n.ItemList)`
439
+ ${e=>n.itemList(e)}
440
+ > ul {
441
+ display: flex;
442
+ flex-wrap: wrap;
443
+ gap: ${e=>{var t;return(t=e.theme.sizes)==null?void 0:t.normal}};
444
+ > li {
445
+ margin: 0;
446
+ }
447
+ }
448
+ ${e=>v(e)}
449
+ `,Re=n.newStyled(n.Button)`
450
+ ${n.buttonCss};
451
+
452
+ background-color: ${e=>e.bgColor};
453
+ display: flex;
454
+ justify-content: center;
455
+ align-items: center;
456
+ color: #ffffff;
457
+ width: 46px;
458
+ height: 46px;
459
+ border-radius: 100%;
460
+
461
+ &:focus-visible {
462
+ ${n.borderTabStyle}
463
+ background-color: transparent;
464
+
465
+ i,
466
+ svg {
467
+ color: ${e=>{var t;return(t=e.theme.colors)==null?void 0:t.primary}};
468
+
469
+ path {
470
+ stroke: ${e=>{var t;return(t=e.theme.colors)==null?void 0:t.primary}};
471
+ }
472
+ }
473
+ }
474
+
475
+ i,
476
+ svg {
477
+ color: #fff;
478
+
479
+ path {
480
+ stroke: #fff;
481
+ }
482
+ }
483
+ `,Ae=([e,t])=>({type:e,content:t}),Ee=({items:e,dispatch:t})=>s.jsx(Ke,{className:"humany-message-list",items:e.map(Ae),renderLi:!0,renderItem:r=>{switch(r.type){case n.ConversationMessageListItemType.Text:return s.jsx(Me,{text:r.content});case n.ConversationMessageListItemType.HTML:return s.jsx($e,{...r.content});case n.ConversationMessageListItemType.Separator:return s.jsx(Te,{...r.content});case n.ConversationMessageListItemType.ItemList:return s.jsx(je,{...r.content,dispatch:t});case n.ConversationMessageListItemType.LinkList:return s.jsx(ke,{...r.content,dispatch:t});case n.ConversationMessageListItemType.ButtonList:return s.jsx(be,{...r.content,dispatch:t});case n.ConversationMessageListItemType.VideoRequest:return s.jsx(Be,{...r.content,dispatch:t});default:return s.jsx(ve,{type:r.type,content:r.content})}}}),Ke=n.newStyled(n.List)`
484
+ ${n.list}
485
+
486
+ > li {
487
+ margin: 0;
488
+ }
489
+ `,Oe=u.forwardRef(({className:e,timestamp:t,sender:r,type:o,content:a},i)=>{const m=u.useCallback(d=>{let l="first";return a.length>1&&(l=d===0?"first":d+1===a.length?"last":"middle"),l},[a]),c=()=>s.jsx(s.Fragment,{children:a.map(d=>{const{key:l,body:f,title:$,form:w,actions:x}=d,p=!!f&&!$&&!w&&!x;return s.jsx(ue,{className:e,discrete:p,ref:i,timestamp:t,fullWidth:!!w||!!x,children:p&&f?s.jsx(n.Html,{html:f}):s.jsx(I,{isSystem:!0,content:d})},l)})}),y=()=>s.jsx(O,{sender:r,timestamp:t,className:e,children:s.jsx(N,{className:"humany-message-content-bundle",children:a.map((d,l)=>s.jsx(B,{className:"humany-message-container",left:!0,ref:i,children:s.jsx(I,{content:d,stacked:m(l)})},d.key))})}),g=()=>s.jsx(ge,{timestamp:t,className:e,children:s.jsx(N,{className:"humany-message-content-bundle",children:a.map((d,l)=>s.jsx(B,{className:"humany-message-container",right:!0,ref:i,children:s.jsx(I,{isUser:!0,content:d,stacked:m(l)})},d.key))})});switch(o){case n.ConversationMessageType.System:return c();case n.ConversationMessageType.Agent:return y();case n.ConversationMessageType.User:return g();default:return null}}),I=({content:e,isUser:t,isSystem:r,stacked:o})=>{const a=L.useDispatch(),{title:i,body:m,actions:c,form:y,items:g}=e;return g?s.jsx(H,{className:"humany-message-content",user:!!t,stacked:o,children:s.jsx(Ee,{items:g,dispatch:a})}):s.jsxs(H,{className:"humany-message-content",padded:!r,user:!!t,stacked:o,fullWidth:!!y||!!c,children:[i&&s.jsx(C,{children:s.jsx(se,{variant:"h2",children:i})}),m&&s.jsx(C,{children:s.jsx(ie,{html:m})}),y&&s.jsx(C,{children:s.jsx(ae,{...y,onChange:(l,f)=>{a("form",{data:f,formKey:y.schema.id,actionKey:l})}})}),c&&s.jsx(C,{children:s.jsx(le,{items:Object.keys(c).map(l=>({label:c[l],actionKey:l})),renderItem:l=>s.jsx("li",{children:s.jsx(ce,{onClick:()=>{a("action",l.actionKey)},children:l.label})},l.actionKey)})})]})},D=()=>{const e=u.useCallback(c=>{c&&setTimeout(()=>{c.scrollIntoView({block:"start",behavior:"smooth"})},250)},[]),[t,r]=n.useScroll(!0),{messages:o,loading:a,typingActors:i=[]}=n.useProperties(),m=()=>i&&i.length?i.map((c,y)=>s.jsx(M,{id:`typing_${c.name}`,children:s.jsx(O,{timestamp:Date.now(),sender:c,children:s.jsx(A,{boxed:!0,ref:e})})},`typing_${c.name}`)):null;return s.jsxs(s.Fragment,{children:[s.jsxs(De,{tabIndex:0,scrollableCss:t,ref:r,children:[o&&o.length?o.map((c,y)=>{const{type:g,timestamp:d,sender:l,content:f}=c;return s.jsx(M,{className:"humany-conversation-entry",tabIndex:-1,children:s.jsx(Oe,{...c,ref:e})},`${g}_${l==null?void 0:l.name}_${d}_${f[0].key}`)}):null,m(),a&&s.jsx(M,{children:s.jsx(A,{ref:e})})]}),s.jsx(Y,{})]})},De=n.newStyled.div`
490
+ display: flex;
491
+ flex-direction: column;
492
+ align-items: stretch;
493
+ flex: 0 1 100%;
494
+ padding: 0 ${e=>{var t;return(t=e.theme.sizes)==null?void 0:t.medium}};
495
+ ${e=>!!e.scrollableCss&&e.scrollableCss};
496
+ &:focus-visible {
497
+ ${e=>n.borderTabStyle(e)};
498
+ }
499
+ `,M=n.newStyled.div`
500
+ margin: 0;
501
+ margin-bottom: ${e=>{var t;return(t=e.theme.sizes)==null?void 0:t.medium}};
502
+
503
+ &:first-of-type {
504
+ margin-top: ${e=>{var t;return(t=e.theme.sizes)==null?void 0:t.medium}};
505
+ }
506
+
507
+ &:last-of-type {
508
+ padding-bottom: ${e=>{var t;return(t=e.theme.sizes)==null?void 0:t.medium}};
509
+ }
510
+
511
+ & span,
512
+ p,
513
+ a,
514
+ div {
515
+ font-weight: 300;
516
+ }
517
+
518
+ & b,
519
+ h1 {
520
+ font-weight: normal;
521
+ }
522
+ ${e=>n.headingElement(e)("h1",n.css`
523
+ font-weight: normal;
524
+ `)}
525
+ `,Pe=({dispatch:e})=>{const t=u.useRef(null);return u.useEffect(()=>{t.current&&t.current.parentNode&&e("overlay-mounted",t.current)},[t]),s.jsx(n.WidgetOverlayOutlet,{portalId:"humany-conversation-overlay-portal",className:"humany-conversation-overlay-outlet",ref:t})},Fe=({dispatch:e,header:t,buttonLabel:r})=>s.jsxs(We,{portalId:"humany-conversation-portal",className:"humany-conversation-outlet",children:[s.jsxs(qe,{className:"humany-conversation-outlet-head",children:[s.jsx(_e,{className:"humany-conversation-outlet-head-button","aria-label":r,title:r,onClick:()=>e("hide-overlay-conversation"),children:s.jsx(n.SymbolBadge,{symbol:{type:"Svg",content:"caret-down"},size:20})}),t&&s.jsx(Ue,{className:"humany-conversation-outlet-header",variant:"h1",children:t})]}),s.jsx(D,{})]}),We=n.newStyled(n.WidgetOverlayOutlet)`
526
+ z-index: 11;
527
+ top: auto;
528
+ height: 65%;
529
+ background-color: #ffffff;
530
+ display: flex;
531
+ flex-direction: column;
532
+ border-top-right-radius: ${e=>{var t;return(t=e.theme.sizes)==null?void 0:t.large}};
533
+ border-top-left-radius: ${e=>{var t;return(t=e.theme.sizes)==null?void 0:t.large}};
534
+ `,qe=n.newStyled.div`
535
+ display: flex;
536
+ flex-direction: column;
537
+ justify-content: center;
538
+ align-items: center;
539
+ gap: ${e=>{var t;return(t=e.theme.sizes)==null?void 0:t.normal}};
540
+ padding: ${e=>{var t;return(t=e.theme.sizes)==null?void 0:t.normal}};
541
+ ${e=>e.theme.border&&`border-bottom: ${e.theme.border};`}
542
+ `,Ue=n.newStyled(n.Typography)`
543
+ font-size: ${e=>{var t;return(t=e.theme.fonts)==null?void 0:t.medium}};
544
+ color: ${e=>{var t;return(t=e.theme.colors)==null?void 0:t.text}};
545
+ margin: 0;
546
+ `,_e=n.newStyled(n.Button)`
547
+ display: flex;
548
+ align-items: center;
549
+ justify-content: center;
550
+ padding: ${e=>{var t;return(t=e.theme.sizes)==null?void 0:t.small}} ${e=>{var t;return(t=e.theme.sizes)==null?void 0:t.medium}};
551
+ ${e=>e.theme.borderRadius&&`border-radius: ${e.theme.borderRadius};`}
552
+
553
+ &:focus-visible {
554
+ ${n.borderTabStyle};
555
+ }
556
+
557
+ svg line {
558
+ stroke: ${e=>{var t;return(t=e.theme.colors)==null?void 0:t.text}};
559
+ }
560
+ `,Ve=({className:e,...t})=>{const{overlay:r,overlayConversationHeader:o,overlayConversationCloseLabel:a,conversationControllerId:i}=n.useProperties(),m=L.useDispatch();return s.jsxs(n.ConversationContext.Provider,{value:i?{id:i}:null,children:[s.jsx(Ye,{...t,className:n.appendClassNames(e,"humany-conversation-component"),children:s.jsx(D,{})}),r&&s.jsxs(s.Fragment,{children:[s.jsx(Pe,{dispatch:m}),r.conversation&&s.jsx(Fe,{dispatch:m,header:o,buttonLabel:a})]})]})},Ye=n.newStyled.div`
561
+ position: absolute;
562
+ right: 0;
563
+ left: 0;
564
+ bottom: 0;
565
+ top: 0;
566
+ overflow: hidden;
567
+ display: flex;
568
+ flex-direction: column;
569
+ `;exports.default=Ve;
@@ -42,8 +42,8 @@ export type ConversationMessage = {
42
42
  };
43
43
  export type EntryWriter = (content: ConversationMessageUpdateSettings | null) => void;
44
44
  export declare const getNormalizedMessageSettings: (settings: string | ConversationMessageSettings | ConverstationMessageItem<any> | ConverstationMessageItem<any>[], options?: {
45
- key?: string | undefined;
46
- } | undefined) => NormalizedMessageSettings;
45
+ key?: string;
46
+ }) => NormalizedMessageSettings;
47
47
  /**
48
48
  * Manages the stream of messages inside a `ConversationComponent` and provides external read-write
49
49
  * access to it as well as exposing emitted actions.