@telia-ace/widget-conversation 1.0.24 → 1.0.25

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 (45) hide show
  1. package/README.md +110 -210
  2. package/dist/conversation.3981560b.js +1100 -0
  3. package/dist/conversation.3981560b.js.map +1 -0
  4. package/dist/index.d.ts +1 -2
  5. package/dist/index.js +164 -182
  6. package/dist/index.js.map +1 -1
  7. package/dist/{return-button.facf6a45.js → return-button.8773c0de.js} +1 -1
  8. package/dist/return-button.8773c0de.js.map +1 -0
  9. package/dist/types.d.ts +41 -34
  10. package/dist/{components/conversation/plugin.d.ts → ui/conversation/conversation-component.d.ts} +2 -13
  11. package/dist/ui/conversation/conversation-content.d.ts +11 -0
  12. package/dist/{components/conversation/ui/input.d.ts → ui/conversation/conversation-input.d.ts} +0 -0
  13. package/dist/ui/conversation/conversation-loader.d.ts +8 -0
  14. package/dist/ui/conversation/conversation-message.d.ts +7 -0
  15. package/dist/ui/conversation/conversation-styles.d.ts +11 -0
  16. package/dist/{components → ui}/conversation/conversation.d.ts +0 -0
  17. package/dist/ui/conversation/index.d.ts +2 -0
  18. package/dist/{components/conversation/ui → ui/conversation}/message-types/agent.d.ts +1 -1
  19. package/dist/ui/conversation/message-types/custom.d.ts +9 -0
  20. package/dist/{components/conversation/ui → ui/conversation}/message-types/index.d.ts +1 -0
  21. package/dist/{components/conversation/ui → ui/conversation}/message-types/system.d.ts +0 -0
  22. package/dist/{components/conversation/ui → ui/conversation}/message-types/timestamp.d.ts +0 -0
  23. package/dist/{components/conversation/ui → ui/conversation}/message-types/user.d.ts +0 -0
  24. package/dist/ui/index.d.ts +2 -0
  25. package/dist/ui/return-button/index.d.ts +2 -0
  26. package/dist/{components/return-button/plugin.d.ts → ui/return-button/return-button-component.d.ts} +2 -1
  27. package/dist/{components → ui}/return-button/return-button.d.ts +0 -0
  28. package/package.json +8 -8
  29. package/dist/components/conversation/ui/content.d.ts +0 -2
  30. package/dist/components/conversation/ui/loader.d.ts +0 -8
  31. package/dist/components/conversation/ui/message-list-items/button-list.d.ts +0 -8
  32. package/dist/components/conversation/ui/message-list-items/custom.d.ts +0 -9
  33. package/dist/components/conversation/ui/message-list-items/html.d.ts +0 -5
  34. package/dist/components/conversation/ui/message-list-items/link-list.d.ts +0 -8
  35. package/dist/components/conversation/ui/message-list-items/separator.d.ts +0 -2
  36. package/dist/components/conversation/ui/message-list-items/text.d.ts +0 -6
  37. package/dist/components/conversation/ui/message-list-items/video-request.d.ts +0 -8
  38. package/dist/components/conversation/ui/message-types/message-list.d.ts +0 -9
  39. package/dist/components/conversation/ui/message.d.ts +0 -7
  40. package/dist/components/conversation/ui/overlay-outlets.d.ts +0 -13
  41. package/dist/components/conversation/ui/styles.d.ts +0 -27
  42. package/dist/conversation.edf14596.js +0 -1191
  43. package/dist/conversation.edf14596.js.map +0 -1
  44. package/dist/return-button.facf6a45.js.map +0 -1
  45. package/dist/utils/map-actions.d.ts +0 -1
@@ -1,1191 +0,0 @@
1
- var Ee = Object.defineProperty, xe = Object.defineProperties;
2
- var ke = Object.getOwnPropertyDescriptors;
3
- var I = Object.getOwnPropertySymbols;
4
- var Q = Object.prototype.hasOwnProperty, X = Object.prototype.propertyIsEnumerable;
5
- var J = (t, e, r) => e in t ? Ee(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r, g = (t, e) => {
6
- for (var r in e || (e = {}))
7
- Q.call(e, r) && J(t, r, e[r]);
8
- if (I)
9
- for (var r of I(e))
10
- X.call(e, r) && J(t, r, e[r]);
11
- return t;
12
- }, z = (t, e) => xe(t, ke(e));
13
- var Z = (t, e) => {
14
- var r = {};
15
- for (var o in t)
16
- Q.call(t, o) && e.indexOf(o) < 0 && (r[o] = t[o]);
17
- if (t != null && I)
18
- for (var o of I(t))
19
- e.indexOf(o) < 0 && X.call(t, o) && (r[o] = t[o]);
20
- return r;
21
- };
22
- import { Input as ne, Button as S, borderTabStyle as v, SymbolBadge as k, useDispatch as W, useProperties as L, useScroll as re, Typography as P, invertedHoverButton as we, List as oe, buttonCss as V, Html as Ce, genericHtml as ze, ItemList as _, itemList as q, useComponent as Se, list as Le, headingElement as Te, WidgetOverlayOutlet as ae } from "@telia-ace/widget-ui";
23
- import { appendClassNames as T, uuid as le } from "@telia-ace/widget-utilities";
24
- import n, { useState as A, useEffect as Y, forwardRef as Me, Suspense as He, useMemo as se, useCallback as ie, useRef as ce } from "react";
25
- import a, { css as d, keyframes as Ie } from "styled-components";
26
- import { FormComponent as Ae } from "@telia-ace/widget-forms";
27
- import { ConversationMessageListItemType as w, ConversationMessageType as O } from "./index.js";
28
- import "@telia-ace/widget-core";
29
- import "@telia-ace/widget-services";
30
- import "@telia-ace/widget-plugins";
31
- const Re = ({ className: t }) => {
32
- const [e, r] = A(""), [o, l] = A(!1), [i, u] = A(0), [f, E] = A(0), s = W(), {
33
- inputPlaceholder: c = "Type your message",
34
- inputHidden: p = !1,
35
- inputDisabled: x = !1,
36
- sendButtonLabel: b = "Send message",
37
- inputMultiline: $ = !0,
38
- secondaryAction: h
39
- } = L(), [ye, y] = re(!0);
40
- Y(() => {
41
- if (y.current) {
42
- const { lineHeight: m, maxHeight: H } = getComputedStyle(y.current);
43
- if (m && m.indexOf("px") > -1) {
44
- const C = m.split("px"), $e = parseInt(C[0], 10);
45
- u($e);
46
- const ve = H.split("px");
47
- E(parseInt(ve[0], 10));
48
- }
49
- }
50
- }, [y.current]);
51
- const K = (m) => {
52
- !m.shiftKey || !$ ? (m.preventDefault(), e && e.length > 0 && (s("user-submit", { text: e }), r(""), N(""))) : e.length < 1 && m.preventDefault();
53
- }, pe = (m) => {
54
- !h || (m.preventDefault(), s("action", g({
55
- actionKey: h.action
56
- }, h)));
57
- }, be = (m) => {
58
- if ($ && y.current) {
59
- const H = y.current.scrollHeight;
60
- if (H > i) {
61
- y.current.style.height = "auto";
62
- let C = H;
63
- m.length < 1 && (C = i), y.current.style.height = `${C}px`, C >= f ? y.current.style.overflowY = "scroll" : y.current.style.overflowY = "hidden";
64
- }
65
- }
66
- }, N = (m) => {
67
- be(m), r(m), m && m.length > 0 && s("user-typing", { textLength: m.length });
68
- };
69
- return p ? null : /* @__PURE__ */ n.createElement(Ne, {
70
- grow: $,
71
- className: T("humany-conversation-input", t),
72
- "data-has-focus": o,
73
- scrollableCss: ye
74
- }, h && /* @__PURE__ */ n.createElement(Ke, {
75
- disabled: x,
76
- onClick: pe,
77
- title: h.label,
78
- "aria-label": h.label
79
- }, /* @__PURE__ */ n.createElement(k, {
80
- size: 24,
81
- symbol: { type: "Svg", content: h.icon || "browse" }
82
- })), $ ? /* @__PURE__ */ n.createElement(me, {
83
- value: e,
84
- onChange: N,
85
- onEnter: K,
86
- disabled: x,
87
- "aria-label": c,
88
- placeholder: c,
89
- onFocusChange: l,
90
- type: "textarea",
91
- rows: 1,
92
- ref: y
93
- }) : /* @__PURE__ */ n.createElement(Be, {
94
- value: e,
95
- onChange: N,
96
- onEnter: K,
97
- disabled: x,
98
- "aria-label": c,
99
- placeholder: c,
100
- onFocusChange: l
101
- }), /* @__PURE__ */ n.createElement(de, {
102
- disabled: x,
103
- onClick: K,
104
- title: b,
105
- "aria-label": b
106
- }, /* @__PURE__ */ n.createElement(Oe, {
107
- size: 22,
108
- symbol: { type: "Svg", content: "send" },
109
- hasContent: e && e.length
110
- })));
111
- }, me = a(ne)`
112
- resize: none;
113
- flex: 1;
114
- flex-shrink: 1;
115
- min-height: 1.2em;
116
- max-height: 148px;
117
- line-height: 1.2em;
118
- height: 1.2em;
119
- padding: 0;
120
- margin: calc(${(t) => {
121
- var e;
122
- return (e = t.theme.sizes) == null ? void 0 : e.small;
123
- }} * 2);
124
- font-size: ${(t) => {
125
- var e;
126
- return (e = t.theme.fonts) == null ? void 0 : e.normal;
127
- }};
128
- border: none;
129
- transition: height 200ms linear;
130
- outline: none;
131
- `, Be = a(ne)`
132
- flex: 1;
133
- border: none;
134
- background-color: transparent;
135
- font-weight: 300;
136
- font-size: ${(t) => {
137
- var e;
138
- return (e = t.theme.fonts) == null ? void 0 : e.normal;
139
- }};
140
- line-height: 1.2em;
141
- outline: none;
142
- padding-left: ${(t) => {
143
- var e;
144
- return (e = t.theme.sizes) == null ? void 0 : e.large;
145
- }};
146
- color: ${(t) => {
147
- var e;
148
- return (e = t.theme.colors) == null ? void 0 : e.text;
149
- }};
150
- &::placeholder {
151
- color: ${(t) => {
152
- var e;
153
- return (e = t.theme.colors) == null ? void 0 : e.textLight;
154
- }};
155
- font-style: italic;
156
- }
157
- `, de = a(S)`
158
- flex: 0 0 50px;
159
- align-self: stretch;
160
- background-color: transparent;
161
- display: flex;
162
- align-items: center;
163
- justify-content: center;
164
- border: none;
165
- color: #a6a6a6;
166
- &:focus {
167
- ${(t) => {
168
- var e;
169
- return ((e = t.theme.accessibility) == null ? void 0 : e.isTabbing) && v;
170
- }};
171
- }
172
- `, Ke = a(de)`
173
- border-right: ${(t) => t.theme.border};
174
- margin: ${(t) => {
175
- var e;
176
- return (e = t.theme.sizes) == null ? void 0 : e.normal;
177
- }} 0;
178
- `, Ne = a.div`
179
- ${(t) => t.grow ? d`
180
- min-height: 50px;
181
- max-height: 150px;
182
- ` : d`
183
- height: 50px;
184
- `}
185
- flex: 0 0 auto;
186
- display: flex;
187
- align-items: center;
188
- background-color: ${(t) => {
189
- var e;
190
- return (e = t.theme.colors) == null ? void 0 : e.accent;
191
- }};
192
- border-top: ${(t) => t.theme.inputBorder};
193
- ${(t) => t["data-has-focus"] && d`
194
- ${(e) => {
195
- var r;
196
- return ((r = e.theme.accessibility) == null ? void 0 : r.isTabbing) && v;
197
- }};
198
- `}
199
- ${me} {
200
- ${(t) => !!t.scrollableCss && t.scrollableCss}
201
- }
202
- `, Oe = a((r) => {
203
- var o = r, { hasContent: t } = o, e = Z(o, ["hasContent"]);
204
- return /* @__PURE__ */ n.createElement(k, g({}, e));
205
- })`
206
- line,
207
- path {
208
- stroke: ${(t) => {
209
- var e;
210
- return t.hasContent ? (e = t.theme.colors) == null ? void 0 : e.primary : "#a6a6a6";
211
- }};
212
- fill: ${(t) => {
213
- var e;
214
- return t.hasContent ? (e = t.theme.colors) == null ? void 0 : e.primary : "#a6a6a6";
215
- }};
216
- }
217
- `, je = a.div`
218
- width: ${(t) => t.avatarSize || "32px"};
219
- height: ${(t) => t.avatarSize || "32px"};
220
- border-radius: 50%;
221
- background-color: ${(t) => {
222
- var e;
223
- return (e = t.theme.colors) == null ? void 0 : e.accent;
224
- }};
225
- border: ${(t) => t.theme.border};
226
- grid-area: avatar;
227
- align-self: flex-end;
228
- justify-self: center;
229
- overflow: hidden;
230
- margin-right: ${(t) => {
231
- var e;
232
- return (e = t.theme.sizes) == null ? void 0 : e.normal;
233
- }};
234
- display: flex;
235
- justify-content: center;
236
- align-items: center;
237
- color: ${(t) => {
238
- var e;
239
- return (e = t.theme.colors) == null ? void 0 : e.text;
240
- }};
241
-
242
- > img {
243
- height: 100%;
244
- width: 100%;
245
- object-fit: cover;
246
- }
247
-
248
- > svg {
249
- width: 90%;
250
- height: 90%;
251
- padding: 10%;
252
- color: ${(t) => {
253
- var e;
254
- return (e = t.theme.colors) == null ? void 0 : e.text;
255
- }};
256
-
257
- line,
258
- path,
259
- circle,
260
- fill {
261
- stroke: ${(t) => {
262
- var e;
263
- return (e = t.theme.colors) == null ? void 0 : e.text;
264
- }};
265
- }
266
- }
267
- `, Fe = Ie`
268
- 0% {
269
- opacity: 0;
270
- }
271
- 75% {
272
- opacity: 1;
273
- }
274
- 100% {
275
- opacity: 0;
276
- }
277
- `, De = a.div`
278
- display: flex;
279
- justify-content: center;
280
- padding: 0 0 ${(t) => {
281
- var e;
282
- return (e = t.theme.sizes) == null ? void 0 : e.normal;
283
- }};
284
- > div {
285
- height: 10px;
286
- width: 10px;
287
- border-radius: 50%;
288
- margin: 5px;
289
- background-color: ${(t) => {
290
- var e;
291
- return (e = t.theme.colors) == null ? void 0 : e.text;
292
- }};
293
- animation: ${Fe} 1s infinite;
294
- }
295
- > div:nth-child(2) {
296
- animation-delay: 100ms;
297
- }
298
- > div:nth-child(3) {
299
- animation-delay: 200ms;
300
- }
301
- `, D = a.div`
302
- grid-area: content;
303
- max-width: 100%;
304
- overflow: hidden;
305
- `, Ue = a(P)`
306
- font-size: ${(t) => {
307
- var e;
308
- return (e = t.theme.fonts) == null ? void 0 : e.normal;
309
- }};
310
- font-weight: normal;
311
- margin: 0;
312
- `, U = a.div`
313
- display: flex;
314
- justify-content: ${(t) => t.user ? "end" : "start"};
315
- `, ue = a.div`
316
- ${(t) => !t.user && t.stacked && We(t.stacked, t.theme)}
317
- ${(t) => t.user && t.stacked && Pe(t.stacked, t.theme)}
318
-
319
- display: inline-block;
320
- margin-top: ${(t) => {
321
- var e;
322
- return (e = t.theme.sizes) == null ? void 0 : e.normal;
323
- }};
324
- && > * {
325
- overflow-wrap: break-word;
326
- word-wrap: break-word;
327
- word-break: break-all;
328
- word-break: break-word;
329
- hyphens: auto;
330
- }
331
- max-width: 100%;
332
- ${(t) => t.fullWidth && "width: 100%;"}
333
- `, We = (t, e) => {
334
- var o, l;
335
- const r = d`
336
- background-color: ${(o = e.colors) == null ? void 0 : o.accent};
337
- color: ${(l = e.colors) == null ? void 0 : l.text};
338
- ${e.border && `border: ${e.border};`};
339
- `;
340
- return e.borderRadius ? d`
341
- ${r}
342
-
343
- border-top-right-radius: ${e.borderRadius};
344
- border-bottom-right-radius: ${e.borderRadius};
345
-
346
- ${t === "first" && `
347
- border-top-left-radius: ${e.borderRadius};
348
- `}
349
-
350
- ${t === "last" && `
351
- border-bottom-left-radius: ${e.borderRadius};
352
- `}
353
- ` : r;
354
- }, Pe = (t, e) => {
355
- var o, l;
356
- const r = d`
357
- background-color: ${(o = e.colors) == null ? void 0 : o.primary};
358
- color: ${(l = e.colors) == null ? void 0 : l.accent};
359
- `;
360
- return e.borderRadius ? d`
361
- ${r}
362
-
363
- border-top-left-radius: ${e.borderRadius};
364
- border-bottom-left-radius: ${e.borderRadius};
365
-
366
- ${t === "first" && `
367
- border-top-right-radius: ${e.borderRadius};
368
- `}
369
-
370
- ${t === "last" && `
371
- border-bottom-right-radius: ${e.borderRadius};
372
- `}
373
- ` : r;
374
- }, R = a.div`
375
- margin-bottom: ${(t) => {
376
- var e;
377
- return (e = t.theme.sizes) == null ? void 0 : e.normal;
378
- }};
379
- &:last-child {
380
- margin-bottom: 0;
381
- }
382
- `, M = d`
383
- margin: ${(t) => {
384
- var e;
385
- return (e = t.theme.sizes) == null ? void 0 : e.normal;
386
- }} 0;
387
- padding: 0 ${(t) => {
388
- var e;
389
- return (e = t.theme.sizes) == null ? void 0 : e.normal;
390
- }};
391
- `, Ve = a(Ae)`
392
- margin: ${(t) => {
393
- var e;
394
- return (e = t.theme.sizes) == null ? void 0 : e.medium;
395
- }} 0;
396
- padding: 0 ${(t) => {
397
- var e;
398
- return (e = t.theme.sizes) == null ? void 0 : e.medium;
399
- }};
400
- & button.humany-form-component-button {
401
- ${(t) => {
402
- var e, r;
403
- return we({
404
- active: !1,
405
- primaryColor: (e = t.theme.colors) == null ? void 0 : e.primary,
406
- secondaryColor: (r = t.theme.colors) == null ? void 0 : r.accent
407
- });
408
- }};
409
- display: block;
410
- width: 100%;
411
- margin-bottom: ${(t) => {
412
- var e;
413
- return (e = t.theme.sizes) == null ? void 0 : e.normal;
414
- }};
415
- }
416
- & button.humany-form-component-submit {
417
- width: 100%;
418
- margin: 0;
419
- :not(:last-child) {
420
- margin-bottom: ${(t) => {
421
- var e;
422
- return (e = t.theme.sizes) == null ? void 0 : e.normal;
423
- }};
424
- }
425
- }
426
- `, _e = a(oe)`
427
- padding: 0;
428
- list-style: none;
429
- button {
430
- font-size: inherit;
431
- }
432
- margin: ${(t) => {
433
- var e;
434
- return (e = t.theme.sizes) == null ? void 0 : e.medium;
435
- }} 0;
436
- padding: 0 ${(t) => {
437
- var e;
438
- return (e = t.theme.sizes) == null ? void 0 : e.medium;
439
- }};
440
- display: flex;
441
- gap: ${(t) => {
442
- var e;
443
- return (e = t.theme.sizes) == null ? void 0 : e.normal;
444
- }};
445
- `, qe = a.button`
446
- ${V};
447
- display: block;
448
- background-color: ${(t) => {
449
- var e;
450
- return (e = t.theme.colors) == null ? void 0 : e.primary;
451
- }};
452
- width: 100%;
453
- color: #fff;
454
- margin: ${(t) => {
455
- var e;
456
- return (e = t.theme.sizes) == null ? void 0 : e.medium;
457
- }} 0;
458
- padding: 0 ${(t) => {
459
- var e;
460
- return (e = t.theme.sizes) == null ? void 0 : e.medium;
461
- }};
462
- font-family: Lato;
463
- font-size: ${(t) => {
464
- var e;
465
- return (e = t.theme.fonts) == null ? void 0 : e.huge;
466
- }};
467
- font-weight: 300;
468
- &:focus {
469
- ${(t) => {
470
- var e;
471
- return ((e = t.theme.accessibility) == null ? void 0 : e.isTabbing) && d`
472
- ${v}
473
- background-color: transparent;
474
- `;
475
- }}
476
- }
477
- `, ee = Me(({ className: t, agentData: e }, r) => /* @__PURE__ */ n.createElement(D, {
478
- ref: r
479
- }, /* @__PURE__ */ n.createElement(U, null, /* @__PURE__ */ n.createElement(ue, null, /* @__PURE__ */ n.createElement(De, null, /* @__PURE__ */ n.createElement("div", null), /* @__PURE__ */ n.createElement("div", null), /* @__PURE__ */ n.createElement("div", null)))))), G = ({ body: t }) => /* @__PURE__ */ n.createElement(Ye, {
480
- html: t
481
- }), Ye = a(Ce)`
482
- ${ze}
483
- color: inherit;
484
- white-space: pre-wrap;
485
- ${M}
486
- a {
487
- color: ${(t) => t.theme.colors.link};
488
- &:focus {
489
- ${(t) => {
490
- var e;
491
- return ((e = t.theme.accessibility) == null ? void 0 : e.isTabbing) && v;
492
- }};
493
- }
494
- }
495
- `, Ge = a.p`
496
- && {
497
- font-size: ${(t) => {
498
- var e;
499
- return (e = t.theme.fonts) == null ? void 0 : e.small;
500
- }};
501
- font-weight: 300;
502
- }
503
- padding-top: ${(t) => {
504
- var e;
505
- return (e = t.theme.sizes) == null ? void 0 : e.small;
506
- }};
507
- margin: 0;
508
- line-height: 1.5em;
509
- grid-area: info;
510
- color: ${(t) => {
511
- var e;
512
- return (e = t.theme.colors) == null ? void 0 : e.text;
513
- }};
514
- `, te = (t) => new Date(t).toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" }), B = ({ className: t, name: e, timestamp: r }) => {
515
- if (!e && !r)
516
- return null;
517
- let o = "";
518
- return e ? r ? o = `${e}: ${te(r)}` : o = e : r && (o = te(r)), /* @__PURE__ */ n.createElement(Ge, null, o);
519
- }, he = ({ className: t, children: e, sender: r, timestamp: o }) => {
520
- const { avatar: l, name: i } = r, { avatarSize: u } = L();
521
- return /* @__PURE__ */ n.createElement(Je, {
522
- hasAvatar: !!l,
523
- className: T(t, "humany-conversation-agent-message")
524
- }, l && /* @__PURE__ */ n.createElement(je, {
525
- avatarSize: u
526
- }, typeof l == "string" ? /* @__PURE__ */ n.createElement("img", {
527
- src: l
528
- }) : /* @__PURE__ */ n.createElement(k, {
529
- symbol: l
530
- })), e, /* @__PURE__ */ n.createElement(B, {
531
- name: i,
532
- timestamp: o
533
- }));
534
- }, Je = a.div`
535
- display: grid;
536
- margin-right: 10%;
537
- width: 90%;
538
- ${(t) => t.hasAvatar ? d`
539
- grid-template-columns: auto 1fr;
540
- grid-template-rows: 1fr auto;
541
- grid-template-areas:
542
- 'avatar content'
543
- '. info';
544
- ` : d`
545
- grid-template-columns: 1fr;
546
- grid-template-rows: 1fr auto;
547
- grid-template-areas:
548
- 'content'
549
- 'info';
550
- `};
551
- `, Qe = ({
552
- className: t,
553
- children: e,
554
- timestamp: r,
555
- discrete: o,
556
- fullWidth: l
557
- }) => /* @__PURE__ */ n.createElement(Xe, {
558
- className: T(t, "humany-conversation-system-message"),
559
- fullWidth: l
560
- }, o ? /* @__PURE__ */ n.createElement(Ze, {
561
- className: "humany-conversation-discrete-message"
562
- }, e, /* @__PURE__ */ n.createElement(B, {
563
- timestamp: r
564
- })) : /* @__PURE__ */ n.createElement(n.Fragment, null, e, /* @__PURE__ */ n.createElement(B, {
565
- timestamp: r
566
- }))), Xe = a.div`
567
- ${(t) => t.fullWidth && "width: 100%"};
568
- padding: 0 ${(t) => {
569
- var e;
570
- return (e = t.theme.sizes) == null ? void 0 : e.large;
571
- }};
572
- overflow: auto;
573
- `, Ze = a.div`
574
- text-align: center;
575
- word-wrap: break-word;
576
- font-size: ${(t) => {
577
- var e;
578
- return (e = t.theme.fonts) == null ? void 0 : e.normal;
579
- }};
580
- color: ${(t) => {
581
- var e;
582
- return (e = t.theme.colors) == null ? void 0 : e.text;
583
- }};
584
- > p {
585
- margin: 0;
586
- }
587
- `, et = ({ className: t, children: e, timestamp: r }) => {
588
- const { userLabel: o = "" } = L();
589
- return /* @__PURE__ */ n.createElement(tt, {
590
- className: T(t, "humany-conversation-user-message")
591
- }, e, /* @__PURE__ */ n.createElement(B, {
592
- name: o,
593
- timestamp: r
594
- }));
595
- }, tt = a.div`
596
- margin-left: 10%;
597
- width: 90%;
598
- display: flex;
599
- flex-direction: column;
600
- align-items: flex-end;
601
- `, ge = (t) => Array.isArray(t) ? t : Object.keys(t).map((e) => ({
602
- label: t[e],
603
- actionKey: e
604
- })), nt = ({ header: t, actions: e, dispatch: r }) => /* @__PURE__ */ n.createElement(rt, {
605
- header: t,
606
- items: ge(e),
607
- renderItem: (o) => /* @__PURE__ */ n.createElement("li", {
608
- key: o.actionKey
609
- }, /* @__PURE__ */ n.createElement(ot, {
610
- onClick: () => {
611
- r("action", o);
612
- },
613
- "aria-label": o.label,
614
- title: o.label
615
- }, /* @__PURE__ */ n.createElement(k, {
616
- symbol: o.symbol
617
- }), o.label))
618
- }), rt = a(_)`
619
- ${q}
620
- > ul {
621
- display: flex;
622
- flex-wrap: wrap;
623
- gap: ${(t) => {
624
- var e;
625
- return (e = t.theme.sizes) == null ? void 0 : e.normal;
626
- }};
627
- > li {
628
- margin: 0;
629
- }
630
- }
631
- ${M}
632
- `, ot = a(S)`
633
- ${V};
634
-
635
- display: block;
636
- padding: ${(t) => {
637
- var e;
638
- return (e = t.theme.sizes) == null ? void 0 : e.normal;
639
- }};
640
- background-color: ${(t) => {
641
- var e;
642
- return (e = t.theme.colors) == null ? void 0 : e.primary;
643
- }};
644
- width: 100%;
645
- color: #ffffff;
646
- &:focus {
647
- ${(t) => {
648
- var e;
649
- return ((e = t.theme.accessibility) == null ? void 0 : e.isTabbing) && d`
650
- ${v}
651
- background-color: transparent;
652
- `;
653
- }}
654
- }
655
-
656
- i,
657
- svg {
658
- margin-right: ${(t) => {
659
- var e;
660
- return (e = t.theme.sizes) == null ? void 0 : e.small;
661
- }};
662
- }
663
- `, at = ({ type: t, content: e = {} }) => {
664
- const r = Se(t);
665
- return !r || !t ? null : /* @__PURE__ */ n.createElement(He, {
666
- fallback: null
667
- }, /* @__PURE__ */ n.createElement(r, g({}, e)));
668
- }, lt = ({ header: t, actions: e, dispatch: r }) => /* @__PURE__ */ n.createElement(st, {
669
- header: t,
670
- items: ge(e),
671
- renderItem: (o) => /* @__PURE__ */ n.createElement("li", {
672
- key: o.actionKey
673
- }, /* @__PURE__ */ n.createElement(it, {
674
- help: o.actionKey === "help",
675
- onClick: () => {
676
- r("action", o);
677
- },
678
- "aria-label": o.label,
679
- title: o.label
680
- }, o.label, o.actionKey === "help" && /* @__PURE__ */ n.createElement(k, {
681
- size: 14,
682
- symbol: {
683
- type: "Svg",
684
- content: "caret-down"
685
- }
686
- })))
687
- }), st = a(_)`
688
- ${q}
689
- ${M}
690
- > ul {
691
- display: flex;
692
- flex-direction: column;
693
- gap: ${(t) => {
694
- var e;
695
- return (e = t.theme.sizes) == null ? void 0 : e.normal;
696
- }};
697
- > li {
698
- margin: 0;
699
- }
700
- }
701
- `, it = a(S)`
702
- display: block;
703
- text-align: left;
704
- font-weight: 300;
705
- color: ${(t) => {
706
- var e;
707
- return (e = t.theme.colors) == null ? void 0 : e.primary;
708
- }};
709
- max-width: 100%;
710
- text-overflow: ellipsis;
711
- overflow: hidden;
712
-
713
- ${(t) => {
714
- var e, r;
715
- return t.help && d`
716
- color: ${(e = t.theme.colors) == null ? void 0 : e.text};
717
- text-decoration: underline;
718
-
719
- i,
720
- svg {
721
- margin-left: ${(r = t.theme.sizes) == null ? void 0 : r.small};
722
- }
723
- `;
724
- }}
725
-
726
- &:focus {
727
- ${(t) => {
728
- var e, r;
729
- return ((e = t.theme.accessibility) == null ? void 0 : e.isTabbing) && d`
730
- ${v}
731
- span {
732
- color: ${(r = t.theme.colors) == null ? void 0 : r.primary};
733
- text-decoration: underline;
734
- }
735
- `;
736
- }};
737
- }
738
- `, ct = () => /* @__PURE__ */ n.createElement(mt, null), mt = a.div`
739
- ${(t) => t.theme.border && `border-bottom: ${t.theme.border};`}
740
- width: 100%;
741
- `, dt = ({ text: t }) => /* @__PURE__ */ n.createElement(ut, {
742
- variant: "span"
743
- }, t), ut = a(P)`
744
- ${M}
745
- `, ht = ({
746
- header: t = "Video call",
747
- acceptLabel: e = "Accept",
748
- declineLabel: r = "Decline",
749
- dispatch: o
750
- }) => {
751
- const l = se(() => [
752
- {
753
- label: e,
754
- actionKey: "accept-video-call",
755
- symbol: {
756
- type: "Svg",
757
- content: "video"
758
- }
759
- },
760
- {
761
- label: r,
762
- actionKey: "decline-video-call",
763
- symbol: {
764
- type: "Svg",
765
- content: "close"
766
- }
767
- }
768
- ], [e, r]);
769
- return /* @__PURE__ */ n.createElement(gt, {
770
- header: t,
771
- items: l,
772
- renderItem: (i) => {
773
- const u = i.actionKey === "accept-video-call" ? "#70c48e" : "#da5c85";
774
- return /* @__PURE__ */ n.createElement("li", {
775
- key: i.actionKey
776
- }, /* @__PURE__ */ n.createElement(ft, {
777
- onClick: () => {
778
- o("action", i);
779
- },
780
- "aria-label": i.label,
781
- title: i.label,
782
- bgColor: u
783
- }, /* @__PURE__ */ n.createElement(k, {
784
- symbol: i.symbol,
785
- size: 25
786
- })));
787
- }
788
- });
789
- }, gt = a(_)`
790
- ${q}
791
- > ul {
792
- display: flex;
793
- flex-wrap: wrap;
794
- gap: ${(t) => {
795
- var e;
796
- return (e = t.theme.sizes) == null ? void 0 : e.normal;
797
- }};
798
- > li {
799
- margin: 0;
800
- }
801
- }
802
- ${M}
803
- `, ft = a(S)`
804
- ${V};
805
-
806
- background-color: ${(t) => t.bgColor};
807
- display: flex;
808
- justify-content: center;
809
- align-items: center;
810
- color: #ffffff;
811
- width: 46px;
812
- height: 46px;
813
- border-radius: 100%;
814
-
815
- &:focus {
816
- ${(t) => {
817
- var e;
818
- return ((e = t.theme.accessibility) == null ? void 0 : e.isTabbing) && d`
819
- ${v}
820
- background-color: transparent;
821
-
822
- i,
823
- svg {
824
- color: ${(r) => {
825
- var o;
826
- return (o = r.theme.colors) == null ? void 0 : o.primary;
827
- }};
828
-
829
- path {
830
- stroke: ${(r) => {
831
- var o;
832
- return (o = r.theme.colors) == null ? void 0 : o.primary;
833
- }};
834
- }
835
- }
836
- `;
837
- }}
838
- }
839
-
840
- i,
841
- svg {
842
- color: #fff;
843
-
844
- path {
845
- stroke: #fff;
846
- }
847
- }
848
- `, yt = ([t, e]) => ({ type: t, content: e, id: le() }), pt = ({ items: t, dispatch: e }) => /* @__PURE__ */ n.createElement(bt, {
849
- items: t.map(yt),
850
- renderLi: !0,
851
- renderItem: (r) => {
852
- switch (r.type) {
853
- case w.Text:
854
- return /* @__PURE__ */ n.createElement(dt, {
855
- text: r.content
856
- });
857
- case w.HTML:
858
- return /* @__PURE__ */ n.createElement(G, g({}, r.content));
859
- case w.Separator:
860
- return /* @__PURE__ */ n.createElement(ct, g({}, r.content));
861
- case w.LinkList:
862
- return /* @__PURE__ */ n.createElement(lt, z(g({}, r.content), {
863
- dispatch: e
864
- }));
865
- case w.ButtonList:
866
- return /* @__PURE__ */ n.createElement(nt, z(g({}, r.content), {
867
- dispatch: e
868
- }));
869
- case w.VideoRequest:
870
- return /* @__PURE__ */ n.createElement(ht, z(g({}, r.content), {
871
- dispatch: e
872
- }));
873
- default:
874
- return /* @__PURE__ */ n.createElement(at, {
875
- type: r.type,
876
- content: r.content
877
- });
878
- }
879
- }
880
- }), bt = a(oe)`
881
- ${Le}
882
-
883
- > li {
884
- margin: 0;
885
- }
886
- `, $t = ({
887
- className: t,
888
- timestamp: e,
889
- sender: r,
890
- type: o,
891
- content: l
892
- }) => {
893
- const i = ie((s) => {
894
- let c = "first";
895
- return l.length > 1 && (c = s === 0 ? "first" : s + 1 === l.length ? "last" : "middle"), c;
896
- }, [l]), u = () => /* @__PURE__ */ n.createElement(n.Fragment, null, l.map((s) => {
897
- const { key: c, body: p, title: x, form: b, actions: $ } = s, h = !!p && !x && !b && !$;
898
- return /* @__PURE__ */ n.createElement(Qe, {
899
- className: t,
900
- key: c,
901
- discrete: h,
902
- timestamp: e,
903
- fullWidth: !!b || !!$
904
- }, h && p ? /* @__PURE__ */ n.createElement(G, {
905
- body: p
906
- }) : /* @__PURE__ */ n.createElement(j, {
907
- content: s,
908
- isUser: !1
909
- }));
910
- })), f = () => /* @__PURE__ */ n.createElement(he, {
911
- sender: r,
912
- timestamp: e,
913
- className: t
914
- }, /* @__PURE__ */ n.createElement(D, null, l.map((s, c) => /* @__PURE__ */ n.createElement(U, {
915
- key: s.key
916
- }, /* @__PURE__ */ n.createElement(j, {
917
- content: s,
918
- isUser: !1,
919
- stacked: i(c)
920
- }))))), E = () => /* @__PURE__ */ n.createElement(et, {
921
- timestamp: e,
922
- className: t
923
- }, /* @__PURE__ */ n.createElement(D, null, l.map((s, c) => /* @__PURE__ */ n.createElement(U, {
924
- user: !0,
925
- key: s.key
926
- }, /* @__PURE__ */ n.createElement(j, {
927
- content: s,
928
- isUser: !0,
929
- stacked: i(c)
930
- })))));
931
- switch (o) {
932
- case O.System:
933
- return u();
934
- case O.Agent:
935
- return f();
936
- case O.User:
937
- return E();
938
- default:
939
- return null;
940
- }
941
- }, j = ({ content: t, isUser: e, stacked: r }) => {
942
- const o = W(), { title: l, body: i, actions: u, form: f, items: E } = t;
943
- return /* @__PURE__ */ n.createElement(ue, {
944
- user: e,
945
- stacked: r,
946
- fullWidth: !!f || !!u
947
- }, l && /* @__PURE__ */ n.createElement(R, null, /* @__PURE__ */ n.createElement(Ue, {
948
- variant: "h2"
949
- }, l)), i && /* @__PURE__ */ n.createElement(R, null, /* @__PURE__ */ n.createElement(G, {
950
- body: i
951
- })), f && /* @__PURE__ */ n.createElement(R, null, /* @__PURE__ */ n.createElement(Ve, z(g({}, f), {
952
- onChange: (s, c) => {
953
- o("form", {
954
- data: c,
955
- formKey: f.schema.id,
956
- actionKey: s
957
- });
958
- }
959
- }))), u && /* @__PURE__ */ n.createElement(R, null, /* @__PURE__ */ n.createElement(_e, {
960
- items: Object.keys(u).map((s) => ({ label: u[s], actionKey: s })),
961
- renderItem: (s) => /* @__PURE__ */ n.createElement("li", {
962
- key: s.actionKey
963
- }, /* @__PURE__ */ n.createElement(qe, {
964
- onClick: () => {
965
- o("action", s.actionKey);
966
- }
967
- }, s.label))
968
- })), E && /* @__PURE__ */ n.createElement(pt, {
969
- key: le(),
970
- items: E,
971
- dispatch: o
972
- }));
973
- }, fe = () => {
974
- const t = ce(null), [e, r] = re(!0), {
975
- messages: o,
976
- loading: l,
977
- typingActors: i = []
978
- } = L(), u = ie(() => {
979
- t.current && t.current.scrollIntoView({
980
- block: "start",
981
- behavior: "smooth"
982
- });
983
- }, [t]);
984
- Y(() => {
985
- const s = setTimeout(u, 250);
986
- return () => clearTimeout(s);
987
- }, [o, i]);
988
- const f = se(() => !!i.length || l, [i, l]), E = () => i && i.length ? i.map((s, c) => {
989
- const p = c === i.length - 1;
990
- return /* @__PURE__ */ n.createElement(F, {
991
- id: `typing_${s.name}`,
992
- ref: l ? null : p ? t : null,
993
- key: `typing_${s.name}`
994
- }, /* @__PURE__ */ n.createElement(he, {
995
- timestamp: Date.now(),
996
- sender: s
997
- }, /* @__PURE__ */ n.createElement(ee, null)));
998
- }) : null;
999
- return /* @__PURE__ */ n.createElement(n.Fragment, null, /* @__PURE__ */ n.createElement(vt, {
1000
- tabIndex: 0,
1001
- scrollableCss: e,
1002
- ref: r
1003
- }, o && o.length ? o.map((s, c) => {
1004
- const { type: p, timestamp: x, sender: b, content: $ } = s, h = c === o.length - 1;
1005
- return /* @__PURE__ */ n.createElement(F, {
1006
- className: "humany-conversation-entry",
1007
- tabIndex: -1,
1008
- key: `${p}_${b == null ? void 0 : b.name}_${x}_${$[0].key}`,
1009
- ref: f ? null : h ? t : null
1010
- }, /* @__PURE__ */ n.createElement($t, g({}, s)));
1011
- }) : null, E(), l && /* @__PURE__ */ n.createElement(F, null, /* @__PURE__ */ n.createElement(ee, {
1012
- ref: t
1013
- }))), /* @__PURE__ */ n.createElement(Re, null));
1014
- }, vt = a.div`
1015
- display: flex;
1016
- flex-direction: column;
1017
- align-items: stretch;
1018
- flex: 0 1 100%;
1019
- padding: 0 ${(t) => {
1020
- var e;
1021
- return (e = t.theme.sizes) == null ? void 0 : e.normal;
1022
- }};
1023
- ${(t) => !!t.scrollableCss && t.scrollableCss};
1024
- &:focus {
1025
- ${(t) => {
1026
- var e;
1027
- return ((e = t.theme.accessibility) == null ? void 0 : e.isTabbing) && v;
1028
- }};
1029
- }
1030
- `, F = a.div`
1031
- margin: 0;
1032
- margin-bottom: ${(t) => {
1033
- var e;
1034
- return (e = t.theme.sizes) == null ? void 0 : e.medium;
1035
- }};
1036
-
1037
- &:first-of-type {
1038
- margin-top: ${(t) => {
1039
- var e;
1040
- return (e = t.theme.sizes) == null ? void 0 : e.medium;
1041
- }};
1042
- }
1043
-
1044
- &:last-of-type {
1045
- padding-bottom: ${(t) => {
1046
- var e;
1047
- return (e = t.theme.sizes) == null ? void 0 : e.medium;
1048
- }};
1049
- }
1050
-
1051
- & span,
1052
- p,
1053
- a,
1054
- div {
1055
- font-weight: 300;
1056
- }
1057
-
1058
- & b,
1059
- h1 {
1060
- font-weight: normal;
1061
- }
1062
-
1063
- ${Te("h1", d`
1064
- font-weight: normal;
1065
- `)}
1066
- `, Et = ({ dispatch: t }) => {
1067
- const e = ce(null);
1068
- return Y(() => {
1069
- e.current && e.current.parentNode && t("overlay-mounted", e.current);
1070
- }, [e]), /* @__PURE__ */ n.createElement(ae, {
1071
- portalId: "humany-conversation-overlay-portal",
1072
- className: "humany-conversation-overlay-outlet",
1073
- ref: e
1074
- });
1075
- }, xt = ({
1076
- dispatch: t,
1077
- header: e,
1078
- buttonLabel: r
1079
- }) => /* @__PURE__ */ n.createElement(kt, {
1080
- portalId: "humany-conversation-portal",
1081
- className: "humany-conversation-outlet"
1082
- }, /* @__PURE__ */ n.createElement(wt, {
1083
- className: "humany-conversation-outlet-head"
1084
- }, /* @__PURE__ */ n.createElement(zt, {
1085
- className: "humany-conversation-outlet-head-button",
1086
- "aria-label": r,
1087
- title: r,
1088
- onClick: () => t("hide-overlay-conversation")
1089
- }, /* @__PURE__ */ n.createElement(k, {
1090
- symbol: {
1091
- type: "Svg",
1092
- content: "caret-down"
1093
- },
1094
- size: 20
1095
- })), e && /* @__PURE__ */ n.createElement(Ct, {
1096
- className: "humany-conversation-outlet-header",
1097
- variant: "h1"
1098
- }, e)), /* @__PURE__ */ n.createElement(fe, null)), kt = a(ae)`
1099
- z-index: 11;
1100
- top: auto;
1101
- height: 65%;
1102
- background-color: #ffffff;
1103
- display: flex;
1104
- flex-direction: column;
1105
- border-top-right-radius: ${(t) => {
1106
- var e;
1107
- return (e = t.theme.sizes) == null ? void 0 : e.large;
1108
- }};
1109
- border-top-left-radius: ${(t) => {
1110
- var e;
1111
- return (e = t.theme.sizes) == null ? void 0 : e.large;
1112
- }};
1113
- `, wt = a.div`
1114
- display: flex;
1115
- flex-direction: column;
1116
- justify-content: center;
1117
- align-items: center;
1118
- gap: ${(t) => {
1119
- var e;
1120
- return (e = t.theme.sizes) == null ? void 0 : e.normal;
1121
- }};
1122
- padding: ${(t) => {
1123
- var e;
1124
- return (e = t.theme.sizes) == null ? void 0 : e.normal;
1125
- }};
1126
- ${(t) => t.theme.border && `border-bottom: ${t.theme.border};`}
1127
- `, Ct = a(P)`
1128
- font-size: ${(t) => {
1129
- var e;
1130
- return (e = t.theme.fonts) == null ? void 0 : e.medium;
1131
- }};
1132
- color: ${(t) => {
1133
- var e;
1134
- return (e = t.theme.colors) == null ? void 0 : e.text;
1135
- }};
1136
- margin: 0;
1137
- `, zt = a(S)`
1138
- display: flex;
1139
- align-items: center;
1140
- justify-content: center;
1141
- padding: ${(t) => {
1142
- var e;
1143
- return (e = t.theme.sizes) == null ? void 0 : e.small;
1144
- }} ${(t) => {
1145
- var e;
1146
- return (e = t.theme.sizes) == null ? void 0 : e.medium;
1147
- }};
1148
- ${(t) => t.theme.borderRadius && `border-radius: ${t.theme.borderRadius};`}
1149
-
1150
- &:focus {
1151
- ${(t) => {
1152
- var e;
1153
- return ((e = t.theme.accessibility) == null ? void 0 : e.isTabbing) && v;
1154
- }};
1155
- }
1156
-
1157
- svg line {
1158
- stroke: ${(t) => {
1159
- var e;
1160
- return (e = t.theme.colors) == null ? void 0 : e.text;
1161
- }};
1162
- }
1163
- `, Ot = ({ className: t }) => {
1164
- const {
1165
- overlay: e,
1166
- overlayConversationHeader: r,
1167
- overlayConversationCloseLabel: o
1168
- } = L(), l = W();
1169
- return /* @__PURE__ */ n.createElement(n.Fragment, null, /* @__PURE__ */ n.createElement(St, {
1170
- className: T(t, "humany-conversation-component")
1171
- }, /* @__PURE__ */ n.createElement(fe, null)), e && /* @__PURE__ */ n.createElement(n.Fragment, null, /* @__PURE__ */ n.createElement(Et, {
1172
- dispatch: l
1173
- }), e.conversation && /* @__PURE__ */ n.createElement(xt, {
1174
- dispatch: l,
1175
- header: r,
1176
- buttonLabel: o
1177
- })));
1178
- }, St = a.div`
1179
- position: absolute;
1180
- right: 0;
1181
- left: 0;
1182
- bottom: 0;
1183
- top: 0;
1184
- overflow: hidden;
1185
- display: flex;
1186
- flex-direction: column;
1187
- `;
1188
- export {
1189
- Ot as default
1190
- };
1191
- //# sourceMappingURL=conversation.edf14596.js.map