@telia-ace/widget-conversation 1.1.2-rc.2 → 1.1.2-rc.4

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.
@@ -0,0 +1,595 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),i=require("@emotion/styled"),n=require("@telia-ace/widget-ui"),C=require("@telia-ace/widget-utilities"),f=require("@emotion/react"),h=require("react"),Q=require("@telia-ace/widget-forms"),$=require("./index.js");require("@telia-ace/widget-core");require("@telia-ace/widget-services");require("@telia-ace/widget-plugins");const X=({className:t})=>{const[e,r]=h.useState(""),[o,a]=h.useState(!1),[l,d]=h.useState(0),[m,u]=h.useState(0),b=n.useIsTabbing(),p=n.useDispatch(),{inputPlaceholder:c="Type your message",inputHidden:g=!1,inputDisabled:j=!1,sendButtonLabel:L="Send message",inputMultiline:S=!0,secondaryAction:x}=n.useProperties(),[z,v]=n.useScroll(!0);h.useEffect(()=>{if(v.current){const{lineHeight:y,maxHeight:T}=getComputedStyle(v.current);if(y&&y.indexOf("px")>-1){const k=y.split("px"),G=parseInt(k[0],10);d(G);const J=T.split("px");u(parseInt(J[0],10))}}},[v.current]);const M=y=>{!y.shiftKey||!S?(y.preventDefault(),e&&e.length>0&&(p("user-submit",{text:e}),r(""),B(""))):e.length<1&&y.preventDefault()},_=y=>{x&&(y.preventDefault(),p("action",{actionKey:x.action,...x}))},Y=y=>{if(S&&v.current){const T=v.current.scrollHeight;if(T>l){v.current.style.height="auto";let k=T;y.length<1&&(k=l),v.current.style.height=`${k}px`,k>=m?v.current.style.overflowY="scroll":v.current.style.overflowY="hidden"}}},B=y=>{Y(y),r(y),y&&y.length>0&&p("user-typing",{textLength:y.length})};return g?null:s.jsxs(se,{grow:S,className:C.appendClassNames("humany-conversation-input",t),"data-has-focus":o,scrollableCss:z,isTabbing:b,children:[x&&s.jsx(te,{disabled:j,onClick:_,title:x.label,"aria-label":x.label,children:s.jsx(n.SymbolBadge,{size:24,symbol:{type:"Svg",content:x.icon||"browse"}})}),S?s.jsx(Z,{value:e,onChange:B,onEnter:M,disabled:j,"aria-label":c,placeholder:c,onFocusChange:a,type:"textarea",rows:1,ref:v}):s.jsx(ee,{value:e,onChange:B,onEnter:M,disabled:j,"aria-label":c,placeholder:c,onFocusChange:a}),s.jsx(F,{disabled:!1,onClick:M,title:L,"aria-label":L,children:s.jsx(ne,{size:22,symbol:{type:"Svg",content:"send"},hasContent:!!e&&!!e.length})})]})},Z=i(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: ${t=>{var e;return(e=t.theme.sizes)==null?void 0:e.medium}};
11
+ font-size: ${t=>{var e;return(e=t.theme.fonts)==null?void 0:e.normal}};
12
+ border: none;
13
+ transition: height 200ms linear;
14
+ outline: none;
15
+ `,ee=i(n.Input)`
16
+ flex: 1;
17
+ border: none;
18
+ background-color: transparent;
19
+ font-weight: 300;
20
+ font-size: ${t=>{var e;return(e=t.theme.fonts)==null?void 0:e.normal}};
21
+ line-height: 1.2em;
22
+ outline: none;
23
+ padding: ${t=>{var e;return(e=t.theme.sizes)==null?void 0:e.medium}};
24
+ color: ${t=>{var e;return(e=t.theme.colors)==null?void 0:e.text}};
25
+ &::placeholder {
26
+ color: ${t=>{var e;return(e=t.theme.colors)==null?void 0:e.textLight}};
27
+ font-style: italic;
28
+ }
29
+ `,F=i(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
+ `,te=i(F)`
42
+ border-right: ${t=>t.theme.border};
43
+ margin: ${t=>{var e;return(e=t.theme.sizes)==null?void 0:e.normal}} 0;
44
+ `,se=i.div`
45
+ ${t=>t.grow?f.css`
46
+ min-height: 50px;
47
+ max-height: 150px;
48
+ `:f.css`
49
+ height: 50px;
50
+ `}
51
+ flex: 0 0 auto;
52
+ display: flex;
53
+ align-items: center;
54
+ background-color: ${t=>{var e;return(e=t.theme.colors)==null?void 0:e.accent}};
55
+ border-top: ${t=>t.theme.inputBorder};
56
+ ${t=>t["data-has-focus"]&&t.isTabbing&&n.borderTabStyle}
57
+ textarea {
58
+ ${t=>!!t.scrollableCss&&t.scrollableCss}
59
+ }
60
+ `,ne=i(({hasContent:t,...e})=>s.jsx(n.SymbolBadge,{...e}))`
61
+ line,
62
+ path {
63
+ stroke: ${t=>{var e;return t.hasContent?(e=t.theme.colors)==null?void 0:e.primary:"#a6a6a6"}};
64
+ fill: ${t=>{var e;return t.hasContent?(e=t.theme.colors)==null?void 0:e.primary:"#a6a6a6"}};
65
+ }
66
+ `,re=i.div`
67
+ width: ${t=>t.avatarSize||"32px"};
68
+ height: ${t=>t.avatarSize||"32px"};
69
+ border-radius: 50%;
70
+ background-color: ${t=>{var e;return(e=t.theme.colors)==null?void 0:e.accent}};
71
+ border: ${t=>t.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: ${t=>{var e;return(e=t.theme.colors)==null?void 0:e.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: ${t=>{var e;return(e=t.theme.colors)==null?void 0:e.text}};
93
+
94
+ line,
95
+ path,
96
+ circle,
97
+ fill {
98
+ stroke: ${t=>{var e;return(e=t.theme.colors)==null?void 0:e.text}};
99
+ }
100
+ }
101
+ `,oe=f.keyframes`
102
+ 0% {
103
+ opacity: 0;
104
+ }
105
+ 75% {
106
+ opacity: 1;
107
+ }
108
+ 100% {
109
+ opacity: 0;
110
+ }
111
+ `,ae=i.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: ${t=>{var e;return(e=t.theme.colors)==null?void 0:e.text}};
120
+ animation: ${oe} 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
+ `,R=i.div`
129
+ grid-area: content;
130
+ max-width: 100%;
131
+ overflow: hidden;
132
+ `,ie=i(n.Typography)`
133
+ font-size: ${t=>{var e;return(e=t.theme.fonts)==null?void 0:e.normal}};
134
+ font-weight: normal;
135
+ margin: 0;
136
+ `,O=i.div`
137
+ display: flex;
138
+ ${t=>t.left&&"justify-content: start;"};
139
+ ${t=>t.center&&"justify-content: center;"};
140
+ ${t=>t.right&&"justify-content: end;"};
141
+ `,K=i.div`
142
+ ${t=>{var e;return t.padded&&`padding: ${(e=t.theme.sizes)==null?void 0:e.medium};`}}
143
+ ${t=>!t.user&&t.stacked&&le(t.stacked,t.theme)}
144
+ ${t=>t.user&&t.stacked&&ce(t.stacked,t.theme)}
145
+
146
+ display: inline-block;
147
+ margin-top: ${t=>{var e;return(e=t.theme.sizes)==null?void 0:e.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
+ ${t=>t.fullWidth&&"width: 100%;"}
157
+ `,le=(t,e)=>{var o,a;const r=f.css`
158
+ background-color: ${(o=e.colors)==null?void 0:o.accent};
159
+ color: ${(a=e.colors)==null?void 0:a.text};
160
+ ${e.border&&`border: ${e.border};`};
161
+ `;return e.borderRadius?f.css`
162
+ ${r}
163
+
164
+ border-top-right-radius: ${e.borderRadius};
165
+ border-bottom-right-radius: ${e.borderRadius};
166
+
167
+ ${t==="first"&&`
168
+ border-top-left-radius: ${e.borderRadius};
169
+ `}
170
+
171
+ ${t==="last"&&`
172
+ border-bottom-left-radius: ${e.borderRadius};
173
+ `}
174
+ `:r},ce=(t,e)=>{var o,a;const r=f.css`
175
+ background-color: ${(o=e.colors)==null?void 0:o.primary};
176
+ color: ${(a=e.colors)==null?void 0:a.accent};
177
+ `;return e.borderRadius?f.css`
178
+ ${r}
179
+
180
+ border-top-left-radius: ${e.borderRadius};
181
+ border-bottom-left-radius: ${e.borderRadius};
182
+
183
+ ${t==="first"&&`
184
+ border-top-right-radius: ${e.borderRadius};
185
+ `}
186
+
187
+ ${t==="last"&&`
188
+ border-bottom-right-radius: ${e.borderRadius};
189
+ `}
190
+ `:r},I=i.div`
191
+ margin-bottom: ${t=>{var e;return(e=t.theme.sizes)==null?void 0:e.normal}};
192
+ &:last-child {
193
+ margin-bottom: 0;
194
+ }
195
+ `,w=t=>{var e,r;return f.css`
196
+ margin: ${(e=t.theme.sizes)==null?void 0:e.medium} 0;
197
+ padding: 0 ${(r=t.theme.sizes)==null?void 0:r.medium};
198
+ `},de=i(Q.FormComponent)`
199
+ & button.humany-form-component-button {
200
+ ${t=>{var e,r,o,a;return((e=t.theme.colors)==null?void 0:e.primary)&&((r=t.theme.colors)==null?void 0:r.accent)&&n.invertedHoverButton({active:!1,primaryColor:(o=t.theme.colors)==null?void 0:o.primary,secondaryColor:(a=t.theme.colors)==null?void 0:a.accent,theme:t.theme})}};
201
+ display: block;
202
+ width: 100%;
203
+ margin-bottom: ${t=>{var e;return(e=t.theme.sizes)==null?void 0:e.normal}};
204
+ }
205
+ & button.humany-form-component-submit {
206
+ width: 100%;
207
+ margin: 0;
208
+ :not(:last-child) {
209
+ margin-bottom: ${t=>{var e;return(e=t.theme.sizes)==null?void 0:e.normal}};
210
+ }
211
+ }
212
+ `,me=i(n.Html)`
213
+ white-space: pre-wrap;
214
+ a {
215
+ color: ${t=>t.theme.colors.link};
216
+ &:focus {
217
+ ${t=>{var e;return((e=t.theme.accessibility)==null?void 0:e.isTabbing)&&n.borderTabStyle}};
218
+ }
219
+ }
220
+ `,ue=i(n.List)`
221
+ padding: 0;
222
+ list-style: none;
223
+ margin: 0 -${t=>{var e;return(e=t.theme.sizes)==null?void 0:e.normal}};
224
+ > li {
225
+ margin: ${t=>{var e;return(e=t.theme.sizes)==null?void 0:e.normal}};
226
+ }
227
+ `,he=i.button`
228
+ ${t=>n.buttonCss(t)};
229
+ display: block;
230
+ background-color: ${t=>{var e;return(e=t.theme.colors)==null?void 0:e.primary}};
231
+ width: 100%;
232
+ color: #fff;
233
+ &:focus-visible {
234
+ ${n.borderTabStyle}
235
+ background-color: transparent;
236
+ }
237
+ `,D=h.forwardRef(({boxed:t,className:e,agentData:r},o)=>s.jsx(R,{ref:o,children:s.jsx(O,{left:t,center:!t,children:s.jsx(K,{padded:!!t,stacked:t?"first":void 0,children:s.jsxs(ae,{children:[s.jsx("div",{}),s.jsx("div",{}),s.jsx("div",{})]})})})})),W=h.createContext(null),ge=i.p`
238
+ && {
239
+ font-size: ${t=>{var e;return(e=t.theme.fonts)==null?void 0:e.small}};
240
+ font-weight: 300;
241
+ }
242
+ margin: 0;
243
+ line-height: 1.5em;
244
+ grid-area: info;
245
+ color: ${t=>{var e;return(e=t.theme.colors)==null?void 0:e.text}};
246
+ `,P=(t,e)=>new Date(t).toLocaleTimeString(e||[],{hour:"2-digit",minute:"2-digit"}),N=({className:t,name:e,timestamp:r})=>{const o=h.useContext(W);if(!e&&!r)return null;let a="";return e?r?a=`${e}: ${P(r,o)}`:a=e:r&&(a=P(r,o)),s.jsx(ge,{children:a})},U=({className:t,children:e,sender:r,timestamp:o})=>{const{avatar:a,name:l}=r,{avatarSize:d}=n.useProperties();return s.jsxs(ye,{hasAvatar:!!a,className:C.appendClassNames(t,"humany-conversation-agent-message"),children:[a&&s.jsx(re,{avatarSize:d,children:typeof a=="string"?s.jsx("img",{src:a}):s.jsx(n.SymbolBadge,{symbol:a})}),e,s.jsx(N,{name:l,timestamp:o})]})},ye=i.div`
247
+ display: grid;
248
+ margin-right: 10%;
249
+ width: 90%;
250
+ ${t=>t.hasAvatar?f.css`
251
+ grid-template-columns: auto 1fr;
252
+ grid-template-rows: 1fr auto;
253
+ grid-template-areas:
254
+ 'avatar content'
255
+ '. info';
256
+ `:f.css`
257
+ grid-template-columns: 1fr;
258
+ grid-template-rows: 1fr auto;
259
+ grid-template-areas:
260
+ 'content'
261
+ 'info';
262
+ `};
263
+ `,fe=h.forwardRef(({className:t,children:e,timestamp:r,discrete:o,fullWidth:a},l)=>s.jsx(be,{ref:l,className:C.appendClassNames(t,"humany-conversation-system-message"),fullWidth:a,children:o?s.jsxs(pe,{className:"humany-conversation-discrete-message",children:[e,s.jsx(N,{timestamp:r})]}):s.jsxs(s.Fragment,{children:[e,s.jsx(N,{timestamp:r})]})})),be=i.div`
264
+ ${t=>t.fullWidth&&"width: 100%"};
265
+ padding: 0 ${t=>{var e;return(e=t.theme.sizes)==null?void 0:e.large}};
266
+ overflow: auto;
267
+ `,pe=i.div`
268
+ text-align: center;
269
+ word-wrap: break-word;
270
+ font-size: ${t=>{var e;return(e=t.theme.fonts)==null?void 0:e.normal}};
271
+ color: ${t=>{var e;return(e=t.theme.colors)==null?void 0:e.text}};
272
+ > p {
273
+ margin: 0;
274
+ }
275
+ `,xe=({className:t,children:e,timestamp:r})=>{const{userLabel:o=""}=n.useProperties();return s.jsxs(ve,{className:C.appendClassNames(t,"humany-conversation-user-message"),children:[e,s.jsx(N,{name:o,timestamp:r})]})},ve=i.div`
276
+ margin-left: 10%;
277
+ width: 90%;
278
+ display: flex;
279
+ flex-direction: column;
280
+ align-items: flex-end;
281
+ `,q=t=>Array.isArray(t)?t:Object.keys(t).map(e=>({label:t[e],actionKey:e})),$e=({header:t,actions:e,dispatch:r})=>s.jsx(je,{className:"humany-conversation-button-list",header:t,items:q(e),renderItem:o=>{var l;const a=!!((l=o==null?void 0:o.data)!=null&&l.href);return s.jsx("li",{children:a?s.jsxs(Se,{onClick:()=>{r("action",o)},href:o.data.href,target:o.data.target,"aria-label":o.label,title:o.label,children:[s.jsx(n.SymbolBadge,{symbol:o.symbol}),o.label]}):s.jsxs(we,{onClick:()=>{r("action",o)},"aria-label":o.label,title:o.label,children:[s.jsx(n.SymbolBadge,{symbol:o.symbol}),o.label]})},o.actionKey)}}),je=i(n.ItemList)`
282
+ ${n.itemList}
283
+ > ul {
284
+ display: flex;
285
+ flex-wrap: wrap;
286
+ gap: ${t=>{var e;return(e=t.theme.sizes)==null?void 0:e.normal}};
287
+ > li {
288
+ margin: 0;
289
+ }
290
+ }
291
+ ${w}
292
+ `,Se=i(n.Link)`
293
+ ${n.buttonCss};
294
+
295
+ display: block;
296
+ padding: ${t=>{var e;return(e=t.theme.sizes)==null?void 0:e.normal}};
297
+ background-color: ${t=>{var e;return(e=t.theme.colors)==null?void 0:e.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: ${t=>{var e;return(e=t.theme.sizes)==null?void 0:e.small}};
310
+ }
311
+ `,we=i(n.Button)`
312
+ ${n.buttonCss};
313
+
314
+ display: block;
315
+ padding: ${t=>{var e;return(e=t.theme.sizes)==null?void 0:e.normal}};
316
+ background-color: ${t=>{var e;return(e=t.theme.colors)==null?void 0:e.primary}};
317
+ width: 100%;
318
+ color: #ffffff;
319
+ overflow: hidden;
320
+ text-overflow: ellipsis;
321
+ &:focus-visible {
322
+ ${n.borderTabStyle}
323
+ background-color: transparent;
324
+ }
325
+
326
+ i,
327
+ svg {
328
+ margin-right: ${t=>{var e;return(e=t.theme.sizes)==null?void 0:e.small}};
329
+ }
330
+ `,Ce=({type:t,content:e={}})=>{const r=n.useComponent(t);return!r||!t?null:s.jsx(h.Suspense,{fallback:null,children:s.jsx(r,{...e})})},ke=({body:t})=>s.jsx(Le,{html:t}),Le=i(n.Html)`
331
+ ${n.genericHtml}
332
+ color: inherit;
333
+ white-space: pre-wrap;
334
+ ${w}
335
+ a {
336
+ color: ${t=>t.theme.colors.link};
337
+ &:focus-visible {
338
+ ${n.borderTabStyle};
339
+ }
340
+ }
341
+ `,ze=({header:t,actions:e,dispatch:r})=>s.jsx(Te,{className:"humany-conversation-item-list",header:t,items:q(e),renderItem:o=>{var a;return s.jsx("li",{children:s.jsxs(Ie,{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)}}),Te=i(n.ItemList)`
342
+ ${n.itemList}
343
+
344
+ > .humany-paragraph {
345
+ ${w}
346
+ margin-bottom: 0;
347
+
348
+ h1 {
349
+ margin: 0;
350
+ }
351
+ }
352
+
353
+ ${t=>n.headingElement(t)("h1",f.css`
354
+ white-space: normal;
355
+ `)}
356
+
357
+ > ul {
358
+ display: flex;
359
+ flex-direction: column;
360
+ gap: ${t=>{var e;return(e=t.theme.sizes)==null?void 0:e.normal}};
361
+ > li {
362
+ margin: 0;
363
+ }
364
+ }
365
+
366
+ li {
367
+ border-bottom: ${t=>t.theme.border};
368
+
369
+ &:last-of-type {
370
+ border-bottom: none;
371
+ }
372
+ }
373
+ `,Ie=i.div`
374
+ display: flex;
375
+ gap: ${t=>{var e;return(e=t.theme.sizes)==null?void 0:e.medium}};
376
+ ${w}
377
+
378
+ .item-icon {
379
+ }
380
+
381
+ .item-body {
382
+ display: flex;
383
+ flex-direction: column;
384
+ align-items: flex-start;
385
+ gap: ${t=>{var e;return(e=t.theme.sizes)==null?void 0:e.normal}};
386
+
387
+ p {
388
+ margin: 0;
389
+ white-space: normal;
390
+ }
391
+ }
392
+
393
+ button {
394
+ background: transparent;
395
+ border: none;
396
+ font-family: inherit;
397
+ font-size: ${t=>{var e;return(e=t.theme.fonts)==null?void 0:e.normal}};
398
+ cursor: pointer;
399
+ padding: 0;
400
+ margin: 0;
401
+
402
+ &:focus-visible {
403
+ ${n.borderTabStyle}
404
+ span {
405
+ color: ${t=>{var e;return(e=t.theme.colors)==null?void 0:e.primary}};
406
+ text-decoration: underline;
407
+ }
408
+ }
409
+ }
410
+ `,Ne=({header:t,actions:e,dispatch:r})=>{const o=n.usePrevious(e),a=h.useRef(),l=n.useIsTabbing();return h.useEffect(()=>{if(o&&Array.isArray(e)&&Array.isArray(o)&&o.length<e.length&&a.current){const d=a.current.querySelectorAll(".humany-conversation-link-list > ul > li"),m=d[o.length];if(d.length===e.length&&o.length){const u=d[o.length-1];if(u){const b=u.querySelector(".humany-button");b&&b.focus()}}else m&&new MutationObserver((b,p)=>{b.forEach(c=>{if(c.addedNodes){const g=Array.from(c.addedNodes).find(j=>j.tagName==="BUTTON");g&&C.htmlParentContains(a.current,document.activeElement)&&(l&&g.focus(),p.disconnect())}})}).observe(m,{attributes:!1,characterData:!1,childList:!0,subtree:!0,attributeOldValue:!1,characterDataOldValue:!1})}}),s.jsx(Me,{ref:a,className:"humany-conversation-link-list",header:t,items:q(e),renderItem:d=>s.jsx("li",{children:s.jsxs(Be,{help:d.actionKey==="help",onClick:()=>{r("action",d)},"aria-label":d.label,title:d.label,children:[d.label,d.actionKey==="help"&&s.jsx(n.SymbolBadge,{size:14,symbol:{type:"Svg",content:"caret-down"}})]})},d.actionKey)})},Me=i(n.ItemList)`
411
+ ${n.itemList}
412
+ ${w}
413
+
414
+ ${t=>n.headingElement(t)("h1",f.css`
415
+ white-space: normal;
416
+ `)}
417
+
418
+ > ul {
419
+ display: flex;
420
+ flex-direction: column;
421
+ gap: ${t=>{var e;return(e=t.theme.sizes)==null?void 0:e.normal}};
422
+ > li {
423
+ margin: 0;
424
+ }
425
+ }
426
+ `,Be=i(n.Button)`
427
+ display: block;
428
+ text-align: left;
429
+ font-weight: 300;
430
+ color: ${t=>{var e;return(e=t.theme.colors)==null?void 0:e.primary}};
431
+ max-width: 100%;
432
+ text-overflow: ellipsis;
433
+ overflow: hidden;
434
+
435
+ ${t=>{var e,r;return t.help&&f.css`
436
+ color: ${(e=t.theme.colors)==null?void 0:e.text};
437
+ text-decoration: underline;
438
+
439
+ i,
440
+ svg {
441
+ margin-left: ${(r=t.theme.sizes)==null?void 0:r.small};
442
+ }
443
+ `}}
444
+
445
+ &:focus-visible {
446
+ ${n.borderTabStyle}
447
+ span {
448
+ color: ${t=>{var e;return(e=t.theme.colors)==null?void 0:e.primary}};
449
+ text-decoration: underline;
450
+ }
451
+ }
452
+ `,He=()=>s.jsx(Ae,{className:"humany-conversation-separator"}),Ae=i.div`
453
+ ${t=>t.theme.border&&`border-bottom: ${t.theme.border};`}
454
+ width: 100%;
455
+ `,Re=({text:t})=>s.jsx(Oe,{className:"humany-conversation-text",variant:"span",children:t}),Oe=i(n.Typography)`
456
+ ${w}
457
+ `,Ke=({header:t="Video call",acceptLabel:e="Accept",declineLabel:r="Decline",dispatch:o})=>{const a=h.useMemo(()=>[{label:e,actionKey:"accept-video-call",symbol:{type:"Svg",content:"video"}},{label:r,actionKey:"decline-video-call",symbol:{type:"Svg",content:"close"}}],[e,r]);return s.jsx(qe,{className:"humany-conversation-video-request",header:t,items:a,renderItem:l=>{const d=l.actionKey==="accept-video-call"?"#70c48e":"#da5c85";return s.jsx("li",{children:s.jsx(De,{onClick:()=>{o("action",l)},"aria-label":l.label,title:l.label,bgColor:d,children:s.jsx(n.SymbolBadge,{symbol:l.symbol,size:25})})},l.actionKey)}})},qe=i(n.ItemList)`
458
+ ${t=>n.itemList(t)}
459
+ > ul {
460
+ display: flex;
461
+ flex-wrap: wrap;
462
+ gap: ${t=>{var e;return(e=t.theme.sizes)==null?void 0:e.normal}};
463
+ > li {
464
+ margin: 0;
465
+ }
466
+ }
467
+ ${t=>w(t)}
468
+ `,De=i(n.Button)`
469
+ ${n.buttonCss};
470
+
471
+ background-color: ${t=>t.bgColor};
472
+ display: flex;
473
+ justify-content: center;
474
+ align-items: center;
475
+ color: #ffffff;
476
+ width: 46px;
477
+ height: 46px;
478
+ border-radius: 100%;
479
+
480
+ &:focus-visible {
481
+ ${n.borderTabStyle}
482
+ background-color: transparent;
483
+
484
+ i,
485
+ svg {
486
+ color: ${t=>{var e;return(e=t.theme.colors)==null?void 0:e.primary}};
487
+
488
+ path {
489
+ stroke: ${t=>{var e;return(e=t.theme.colors)==null?void 0:e.primary}};
490
+ }
491
+ }
492
+ }
493
+
494
+ i,
495
+ svg {
496
+ color: #fff;
497
+
498
+ path {
499
+ stroke: #fff;
500
+ }
501
+ }
502
+ `,Pe=([t,e])=>({type:t,content:e}),Ee=({items:t,dispatch:e})=>s.jsx(Fe,{role:"none",className:"humany-message-list",items:t.map(Pe),renderLi:!0,renderItem:r=>{switch(r.type){case $.ConversationMessageListItemType.Text:return s.jsx(Re,{text:r.content});case $.ConversationMessageListItemType.HTML:return s.jsx(ke,{...r.content});case $.ConversationMessageListItemType.Separator:return s.jsx(He,{...r.content});case $.ConversationMessageListItemType.ItemList:return s.jsx(ze,{...r.content,dispatch:e});case $.ConversationMessageListItemType.LinkList:return s.jsx(Ne,{...r.content,dispatch:e});case $.ConversationMessageListItemType.ButtonList:return s.jsx($e,{...r.content,dispatch:e});case $.ConversationMessageListItemType.VideoRequest:return s.jsx(Ke,{...r.content,dispatch:e});default:return s.jsx(Ce,{type:r.type,content:r.content})}}}),Fe=i(n.List)`
503
+ ${n.list}
504
+
505
+ > li {
506
+ margin: 0;
507
+ }
508
+ `,We=h.forwardRef(({className:t,timestamp:e,sender:r,type:o,content:a},l)=>{const d=h.useCallback(c=>{let g="first";return a.length>1&&(g=c===0?"first":c+1===a.length?"last":"middle"),g},[a]),{userLabel:m=""}=n.useProperties(),u=()=>s.jsx(s.Fragment,{children:a.map(c=>{const{key:g,body:j,title:L,form:S,actions:x}=c,z=!!j&&!L&&!S&&!x;return s.jsx(fe,{className:t,discrete:z,ref:l,timestamp:e,fullWidth:!!S||!!x,children:z&&j?s.jsx(n.Html,{html:j}):s.jsx(H,{isSystem:!0,content:c})},g)})}),b=()=>s.jsxs(s.Fragment,{children:[s.jsxs(E,{className:"humany-sr-only",children:[r==null?void 0:r.name,":"]}),s.jsx(U,{sender:r,timestamp:e,className:t,children:s.jsx(R,{className:"humany-message-content-bundle",children:a.map((c,g)=>s.jsx(O,{className:"humany-message-container",left:!0,ref:l,children:s.jsx(H,{content:c,stacked:d(g)})},c.key))})})]}),p=()=>s.jsxs(s.Fragment,{children:[s.jsxs(E,{className:"humany-sr-only",children:[m,":"]}),s.jsx(xe,{timestamp:e,className:t,children:s.jsx(R,{className:"humany-message-content-bundle",children:a.map((c,g)=>s.jsx(O,{className:"humany-message-container",right:!0,ref:l,children:s.jsx(H,{isUser:!0,content:c,stacked:d(g)})},c.key))})})]});switch(o){case $.ConversationMessageType.System:return u();case $.ConversationMessageType.Agent:return b();case $.ConversationMessageType.User:return p();default:return null}}),H=({content:t,isUser:e,isSystem:r,stacked:o})=>{const a=n.useDispatch(),{title:l,body:d,actions:m,form:u,items:b}=t;return b?s.jsx(K,{className:"humany-message-content",user:!!e,stacked:o,children:s.jsx(Ee,{items:b,dispatch:a})}):s.jsxs(K,{className:"humany-message-content",padded:!r,user:!!e,stacked:o,fullWidth:!!u||!!m,children:[l&&s.jsx(I,{children:s.jsx(ie,{variant:"h2",children:l})}),d&&s.jsx(I,{children:s.jsx(me,{html:d})}),u&&s.jsx(I,{children:s.jsx(de,{...u,onChange:(c,g)=>{a("form",{data:g,formKey:u.schema.id,actionKey:c})}})}),m&&s.jsx(I,{children:s.jsx(ue,{items:Object.keys(m).map(c=>({label:m[c],actionKey:c})),renderItem:c=>s.jsx("li",{children:s.jsx(he,{onClick:()=>{a("action",c.actionKey)},children:c.label})},c.actionKey)})})]})},E=i.div`
509
+ position: absolute;
510
+ left: -10000px;
511
+ top: auto;
512
+ width: 1px;
513
+ height: 1px;
514
+ overflow: hidden;
515
+ `,V=()=>{const t=h.useCallback(m=>{m&&setTimeout(()=>{m.scrollIntoView({block:"start",behavior:"smooth"})},250)},[]),[e,r]=n.useScroll(!0),{messages:o,loading:a,typingActors:l=[]}=n.useProperties(),d=()=>l&&l.length?l.map((m,u)=>s.jsx(A,{id:`typing_${m.name}`,children:s.jsx(U,{timestamp:Date.now(),sender:m,children:s.jsx(D,{boxed:!0,ref:t})})},`typing_${m.name}`)):null;return s.jsxs(s.Fragment,{children:[s.jsxs(Ue,{tabIndex:0,scrollableCss:e,ref:r,children:[o&&o.length?o.map((m,u)=>{const{type:b,timestamp:p,sender:c,content:g}=m;return s.jsx(A,{className:"humany-conversation-entry",tabIndex:-1,children:s.jsx(We,{...m,ref:t})},`${b}_${c==null?void 0:c.name}_${p}_${g[0].key}`)}):null,d(),a&&s.jsx(A,{children:s.jsx(D,{ref:t})})]}),s.jsx(X,{})]})},Ue=i.div`
516
+ display: flex;
517
+ flex-direction: column;
518
+ align-items: stretch;
519
+ flex: 0 1 100%;
520
+ padding: 0 ${t=>{var e;return(e=t.theme.sizes)==null?void 0:e.medium}};
521
+ ${t=>!!t.scrollableCss&&t.scrollableCss};
522
+ &:focus-visible {
523
+ ${t=>n.borderTabStyle(t)};
524
+ }
525
+ `,A=i.div`
526
+ margin: 0;
527
+ margin-bottom: ${t=>{var e;return(e=t.theme.sizes)==null?void 0:e.medium}};
528
+
529
+ &:first-of-type {
530
+ margin-top: ${t=>{var e;return(e=t.theme.sizes)==null?void 0:e.medium}};
531
+ }
532
+
533
+ &:last-of-type {
534
+ padding-bottom: ${t=>{var e;return(e=t.theme.sizes)==null?void 0:e.medium}};
535
+ }
536
+
537
+ & span,
538
+ p,
539
+ a,
540
+ div {
541
+ font-weight: 300;
542
+ }
543
+
544
+ & b,
545
+ h1 {
546
+ font-weight: normal;
547
+ }
548
+ ${t=>n.headingElement(t)("h1",f.css`
549
+ font-weight: normal;
550
+ `)}
551
+ `,Ve=({dispatch:t})=>{const e=h.useRef(null);return h.useEffect(()=>{e.current&&e.current.parentNode&&t("overlay-mounted",e.current)},[e]),s.jsx(n.WidgetOverlayOutlet,{portalId:"humany-conversation-overlay-portal",className:"humany-conversation-overlay-outlet",ref:e})},_e=({dispatch:t,header:e,buttonLabel:r})=>s.jsxs(Ye,{portalId:"humany-conversation-portal",className:"humany-conversation-outlet",children:[s.jsxs(Ge,{className:"humany-conversation-outlet-head",children:[s.jsx(Qe,{className:"humany-conversation-outlet-head-button","aria-label":r,title:r,onClick:()=>t("hide-overlay-conversation"),children:s.jsx(n.SymbolBadge,{symbol:{type:"Svg",content:"caret-down"},size:20})}),e&&s.jsx(Je,{className:"humany-conversation-outlet-header",variant:"h1",children:e})]}),s.jsx(V,{})]}),Ye=i(n.WidgetOverlayOutlet)`
552
+ z-index: 11;
553
+ top: auto;
554
+ height: 65%;
555
+ background-color: #ffffff;
556
+ display: flex;
557
+ flex-direction: column;
558
+ border-top-right-radius: ${t=>{var e;return(e=t.theme.sizes)==null?void 0:e.large}};
559
+ border-top-left-radius: ${t=>{var e;return(e=t.theme.sizes)==null?void 0:e.large}};
560
+ `,Ge=i.div`
561
+ display: flex;
562
+ flex-direction: column;
563
+ justify-content: center;
564
+ align-items: center;
565
+ gap: ${t=>{var e;return(e=t.theme.sizes)==null?void 0:e.normal}};
566
+ padding: ${t=>{var e;return(e=t.theme.sizes)==null?void 0:e.normal}};
567
+ ${t=>t.theme.border&&`border-bottom: ${t.theme.border};`}
568
+ `,Je=i(n.Typography)`
569
+ font-size: ${t=>{var e;return(e=t.theme.fonts)==null?void 0:e.medium}};
570
+ color: ${t=>{var e;return(e=t.theme.colors)==null?void 0:e.text}};
571
+ margin: 0;
572
+ `,Qe=i(n.Button)`
573
+ display: flex;
574
+ align-items: center;
575
+ justify-content: center;
576
+ padding: ${t=>{var e;return(e=t.theme.sizes)==null?void 0:e.small}} ${t=>{var e;return(e=t.theme.sizes)==null?void 0:e.medium}};
577
+ ${t=>t.theme.borderRadius&&`border-radius: ${t.theme.borderRadius};`}
578
+
579
+ &:focus-visible {
580
+ ${n.borderTabStyle};
581
+ }
582
+
583
+ svg line {
584
+ stroke: ${t=>{var e;return(e=t.theme.colors)==null?void 0:e.text}};
585
+ }
586
+ `,Xe=({className:t,...e})=>{const{overlay:r,overlayConversationHeader:o,overlayConversationCloseLabel:a,conversationControllerId:l}=n.useProperties(),d=n.useDispatch(),u=n.useContainer().get("$settings");return s.jsx(n.ConversationContext.Provider,{value:l?{id:l}:null,children:s.jsxs(W.Provider,{value:u==null?void 0:u.language,children:[s.jsx(Ze,{"aria-live":"assertive",...e,className:C.appendClassNames(t,"humany-conversation-component"),children:s.jsx(V,{})}),r&&s.jsxs(s.Fragment,{children:[s.jsx(Ve,{dispatch:d}),r.conversation&&s.jsx(_e,{dispatch:d,header:o,buttonLabel:a})]})]})})},Ze=i.div`
587
+ position: absolute;
588
+ right: 0;
589
+ left: 0;
590
+ bottom: 0;
591
+ top: 0;
592
+ overflow: hidden;
593
+ display: flex;
594
+ flex-direction: column;
595
+ `;exports.default=Xe;