@sendbird/ai-agent-messenger-react 1.0.0 → 1.1.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.
@@ -0,0 +1,3693 @@
1
+ import * as r from "react";
2
+ import { createContext as ye, useContext as J, useEffect as R, useState as C, useId as un, useRef as D, useCallback as P, useLayoutEffect as ge, lazy as T, Suspense as $e, useMemo as Ie, Component as ur, Fragment as Lt, useReducer as mr, forwardRef as gr, Children as pr } from "react";
3
+ import hr, { SendbirdProduct as fr, DeviceOsPlatform as Rt, SendbirdPlatform as br, ConnectionHandler as dt, SendbirdError as xr, SessionHandler as Er, LogLevel as mn, ConnectionState as vr } from "@sendbird/chat";
4
+ import c, { css as k, ThemeProvider as yr, useTheme as ut, createGlobalStyle as Cr, StyleSheetManager as Tr, keyframes as gn } from "styled-components";
5
+ import { format as pn, isSameMinute as Nt, isSameDay as _r } from "date-fns";
6
+ import { enUS as Sr } from "date-fns/locale/en-US";
7
+ import { AIAgentModule as wr, ConversationStatus as z, ConversationListOrder as kr, ConversationType as Ar } from "@sendbird/chat/aiAgent";
8
+ import { useGroupChannelMessages as Ir, useGroupChannelHandler as hn, useForceUpdate as $r } from "@sendbird/uikit-tools";
9
+ import { GroupChannelModule as Mr } from "@sendbird/chat/groupChannel";
10
+ import { MessageMetaArray as Or, SendingStatus as Lr } from "@sendbird/chat/message";
11
+ import { isSameDay as Rr } from "date-fns/isSameDay";
12
+ import { renderer as Nr, parser as Dr, MessageProvider as Br } from "@sendbird/react-uikit-message-template-view";
13
+ import { createMessageTemplate as Pr } from "@sendbird/uikit-message-template";
14
+ import fn from "dompurify";
15
+ import { createPortal as Fr } from "react-dom";
16
+ import Hr from "@emotion/is-prop-valid";
17
+ const W = (e, t) => {
18
+ const n = ye(null), o = ({ children: a, value: l }) => /* @__PURE__ */ r.createElement(n.Provider, { value: l }, typeof a == "function" ? a(l) : a), i = ({ children: a }) => /* @__PURE__ */ r.createElement(n.Consumer, null, (l) => l ? typeof a == "function" ? a(l) : a : null), s = () => {
19
+ const a = J(n);
20
+ if (!a)
21
+ throw new Error(`use${e}Context must be used within a ${e}Provider`);
22
+ return a;
23
+ };
24
+ return n.displayName = `${e}Context`, o.displayName = `${e}Provider`, i.displayName = `${e}Consumer`, s.displayName = `use${e}Context`, { Context: n, Provider: o, Consumer: i, useContext: s };
25
+ };
26
+ function Ce(e) {
27
+ const t = ye({
28
+ Template: e.template,
29
+ updateTemplate: () => {
30
+ },
31
+ components: e.components,
32
+ updateComponent: () => {
33
+ }
34
+ });
35
+ function n({ children: s }) {
36
+ const [a, l] = C(() => e.template), [d, g] = C(e.components), m = {
37
+ Template: a,
38
+ updateTemplate: (p) => l(() => p),
39
+ components: d,
40
+ updateComponent: (p, h) => g((b) => ({ ...b, [p]: h }))
41
+ };
42
+ return /* @__PURE__ */ r.createElement(t.Provider, { value: m }, s);
43
+ }
44
+ function o({ template: s, children: a }) {
45
+ const { updateTemplate: l } = J(t);
46
+ return R(() => {
47
+ s && l(s);
48
+ }, [s]), /* @__PURE__ */ r.createElement(r.Fragment, null, a);
49
+ }
50
+ function i({ children: s }) {
51
+ return /* @__PURE__ */ r.createElement(n, null, s);
52
+ }
53
+ return i.defaults = e, i.useContext = () => J(t), i.Context = t, i.Template = o, Object.keys(e.components).forEach((s) => {
54
+ i[s] = function({
55
+ component: l
56
+ }) {
57
+ const { updateComponent: d } = J(t);
58
+ return R(() => {
59
+ l && d(s, l);
60
+ }, [l]), null;
61
+ };
62
+ }), i;
63
+ }
64
+ function Ur(...e) {
65
+ return function({ children: n }) {
66
+ return e.reduce((o, i) => /* @__PURE__ */ r.createElement(i, null, o), n);
67
+ };
68
+ }
69
+ function ot() {
70
+ }
71
+ function zr() {
72
+ const e = /iPad|iPhone|iPod/.test(navigator.userAgent), t = /Android/.test(navigator.userAgent);
73
+ return e || t;
74
+ }
75
+ class bn {
76
+ constructor(t) {
77
+ this.logger = t, this.subscribers = {};
78
+ }
79
+ async send(t) {
80
+ const n = Wr(), o = this.subscribers[t.type];
81
+ if (o) {
82
+ this.logger.debug(`messenger.dispatcher: dispatching command: ${t.type}`, t.payload);
83
+ const i = o.map((s) => s(t.payload));
84
+ await Promise.all(i).catch((s) => {
85
+ this.logger.error(`messenger.dispatcher: error in callback for command: ${t.type}`, s);
86
+ });
87
+ }
88
+ return n.resolve(), n.promise;
89
+ }
90
+ subscribe(t, n) {
91
+ this.subscribers[t] || (this.subscribers[t] = []), this.subscribers[t].push(n);
92
+ }
93
+ unsubscribe(t, n) {
94
+ this.subscribers[t] && (this.subscribers[t] = this.subscribers[t].filter((o) => o !== n));
95
+ }
96
+ }
97
+ const Wr = () => {
98
+ let e = ot, t = ot;
99
+ return { promise: new Promise((o, i) => {
100
+ e = o, t = i;
101
+ }), resolve: e, reject: t };
102
+ }, Vr = "1.1.0", ke = "sb-agent", Gr = Vr;
103
+ var xn = /* @__PURE__ */ ((e) => (e[e.VERBOSE = 0] = "VERBOSE", e[e.DEBUG = 1] = "DEBUG", e[e.INFO = 2] = "INFO", e[e.WARN = 3] = "WARN", e[e.ERROR = 4] = "ERROR", e[e.NONE = 5] = "NONE", e))(xn || {});
104
+ class En {
105
+ constructor(t) {
106
+ this.level = t;
107
+ }
108
+ verbose(...t) {
109
+ this.level <= 0 && console.log(`[${ke}/verbose]`, ...t);
110
+ }
111
+ debug(...t) {
112
+ this.level <= 1 && console.log(`[${ke}/debug]`, ...t);
113
+ }
114
+ info(...t) {
115
+ this.level <= 2 && console.log(`[${ke}/info]`, ...t);
116
+ }
117
+ warn(...t) {
118
+ this.level <= 3 && console.warn(`[${ke}/warn]`, ...t);
119
+ }
120
+ error(...t) {
121
+ this.level <= 4 && console.error(`[${ke}/error]`, ...t);
122
+ }
123
+ }
124
+ function Dt(e, t, n) {
125
+ const o = hr.init({
126
+ appId: e,
127
+ modules: [new Mr(), new wr()],
128
+ localCacheEnabled: !0,
129
+ ...n
130
+ });
131
+ return o.addSendbirdExtensions(
132
+ [{ version: Gr, product: fr.AI_AGENT, platform: t.platform }],
133
+ { platform: t.deviceOSPlatform, version: t.deviceOSVersion },
134
+ t.customData
135
+ ) || console.warn("Invalid Sendbird Extensions", t), o;
136
+ }
137
+ const {
138
+ Provider: jr,
139
+ useContext: Ze
140
+ } = W("AIAgent");
141
+ function Kr({
142
+ appId: e,
143
+ aiAgentId: t,
144
+ language: n,
145
+ countryCode: o,
146
+ context: i,
147
+ chatSDK: s,
148
+ chatParams: a,
149
+ dispatcher: l,
150
+ logger: d,
151
+ children: g,
152
+ extensions: m = {
153
+ platform: br.JS,
154
+ deviceOSPlatform: zr() ? Rt.MOBILE_WEB : Rt.WEB
155
+ }
156
+ }) {
157
+ const [p, h] = C(() => {
158
+ const b = d ?? new En(xn.WARN), x = l ?? new bn(b);
159
+ return {
160
+ appId: e,
161
+ aiAgentId: t,
162
+ language: n,
163
+ countryCode: o,
164
+ context: i,
165
+ chatSDK: s ?? Dt(e, m, a),
166
+ logger: b,
167
+ dispatcher: x
168
+ };
169
+ });
170
+ return (n !== p.language || o !== p.countryCode) && h((b) => ({ ...b, language: n, countryCode: o, context: i })), s && s !== p.chatSDK ? h((b) => ({ ...b, aiAgentId: t, chatSDK: s })) : !s && p.chatSDK.appId !== e && h((b) => ({
171
+ ...b,
172
+ aiAgentId: t,
173
+ chatSDK: Dt(e, m, { newInstance: !0, ...a })
174
+ })), R(() => () => {
175
+ p.chatSDK.disconnectWebSocket();
176
+ }, [p.chatSDK]), /* @__PURE__ */ r.createElement(jr, { value: p }, g);
177
+ }
178
+ const Zr = (e, t, n) => Ir(e, t, { ...n, strictStreamingOrder: !0 });
179
+ var it = /* @__PURE__ */ ((e) => (e.ConversationClose = "conv.close", e))(it || {});
180
+ class Yr {
181
+ constructor(t = {}) {
182
+ this.payload = t;
183
+ }
184
+ toJSON() {
185
+ return JSON.stringify({ type: this.type, payload: this.payload });
186
+ }
187
+ }
188
+ class qr extends Yr {
189
+ constructor() {
190
+ super(...arguments), this.type = "conv.close";
191
+ }
192
+ }
193
+ const Jr = {
194
+ CloseConversation: () => new qr()
195
+ }, {
196
+ Provider: Xr
197
+ } = W("AIAgentConversation");
198
+ function Qr({
199
+ children: e,
200
+ channelUrl: t,
201
+ onChannelDeleted: n,
202
+ onMessagesUpdated: o,
203
+ onConversationClosedViaDispatcher: i,
204
+ onBeforeSendMessage: s,
205
+ onAfterSendMessage: a = ot
206
+ }) {
207
+ var v;
208
+ const { chatSDK: l, logger: d, dispatcher: g } = Ze(), { channel: m, channelFetchError: p, fetchChannel: h } = eo(t), b = Zr(l, m, {
209
+ shouldCountNewMessages: () => !1,
210
+ onChannelDeleted: n,
211
+ onMessagesReceived: o,
212
+ onMessagesUpdated: o,
213
+ logger: d
214
+ });
215
+ R(() => {
216
+ const f = async () => {
217
+ d.debug("conversation.dispatcher: try to close conversation", m), m != null && m.conversation && m.conversation.status === z.OPEN && (await m.closeConversation(), i == null || i());
218
+ };
219
+ return g.subscribe(it.ConversationClose, f), () => {
220
+ g.unsubscribe(it.ConversationClose, f);
221
+ };
222
+ }, [g, (v = m == null ? void 0 : m.conversation) == null ? void 0 : v.status, i]);
223
+ const x = {
224
+ conversation: (m == null ? void 0 : m.conversation) ?? void 0,
225
+ channelSource: {
226
+ channel: m,
227
+ error: p,
228
+ refetch: () => h()
229
+ },
230
+ messageSource: {
231
+ messages: b.messages,
232
+ initialized: b.initialized,
233
+ loadPrevious: () => b.loadPrevious(),
234
+ loadNext: () => b.loadNext(),
235
+ sendUserMessage: async (f) => {
236
+ s && (f = await s(f));
237
+ const y = await b.sendUserMessage(f, a);
238
+ return a == null || a(y), y;
239
+ },
240
+ sendFileMessage: async (f) => {
241
+ s && (f = await s(f));
242
+ const y = await b.sendFileMessage(f, a);
243
+ return a == null || a(y), y;
244
+ }
245
+ }
246
+ };
247
+ return /* @__PURE__ */ r.createElement(Xr, { value: x }, e);
248
+ }
249
+ function eo(e) {
250
+ const { chatSDK: t, logger: n } = Ze(), [o, i] = C(void 0), [s, a] = C(void 0);
251
+ async function l() {
252
+ if (n.debug("conversation.fetchChannel: start"), i(void 0), a(void 0), e)
253
+ try {
254
+ n.debug("conversation.fetchChannel: get channel", e);
255
+ const d = await t.groupChannel.getChannel(e);
256
+ i(d);
257
+ const g = new dt({ onReconnectSucceeded: () => d.refresh() });
258
+ t.addConnectionHandler("sba-refresh", g), n.debug("conversation.fetchChannel: fetched channel", d);
259
+ } catch (d) {
260
+ d instanceof xr && a(d), n.error("conversation.fetchChannel: error", d);
261
+ }
262
+ }
263
+ return R(() => {
264
+ l();
265
+ }, [e, t]), {
266
+ channel: o,
267
+ channelFetchError: s,
268
+ fetchChannel: l
269
+ };
270
+ }
271
+ const to = (e, t) => {
272
+ const n = un(), [o, i] = C(!1), [s, a] = C(null), [l, d] = C([]), [g, m] = C(null), p = D(!1), h = P(async () => {
273
+ if (!p.current && e.currentUser) {
274
+ p.current = !0, i(!1), a(null), d([]);
275
+ try {
276
+ const x = e.aiAgent.createConversationListQuery(t), v = await x.next();
277
+ d(v), m(x), a(null);
278
+ } catch (x) {
279
+ m(null), a(x);
280
+ } finally {
281
+ i(!0), p.current = !1;
282
+ }
283
+ }
284
+ }, [e, t.aiAgentId, t.status, t.limit, t.order, t.reverse]), b = P(async () => {
285
+ g && g.next().then((x) => {
286
+ d((v) => [...v, ...x]);
287
+ }).catch(() => {
288
+ });
289
+ }, [g]);
290
+ return R(() => (e.addConnectionHandler(n, new dt({ onConnected: () => h() })), () => e.removeConnectionHandler(n)), [e, n, h]), R(() => {
291
+ h();
292
+ }, [h]), {
293
+ initialized: o,
294
+ error: s,
295
+ conversations: l,
296
+ loadMore: b
297
+ };
298
+ }, {
299
+ Provider: no
300
+ } = W("AIAgentConversationList");
301
+ function ro({ children: e }) {
302
+ const { chatSDK: t, aiAgentId: n } = Ze(), o = to(t, {
303
+ aiAgentId: n,
304
+ status: z.CLOSED,
305
+ order: kr.UPDATED_AT,
306
+ reverse: !0
307
+ }), i = {
308
+ listSource: {
309
+ initialized: o.initialized,
310
+ error: o.error ?? void 0,
311
+ conversations: o.conversations,
312
+ loadMore: () => o.loadMore()
313
+ }
314
+ };
315
+ return /* @__PURE__ */ r.createElement(no, { value: i }, e);
316
+ }
317
+ const st = {
318
+ DEFAULT_BOT_MSG_BG: "#eeeeee",
319
+ WHITE: "#ffffff",
320
+ BLACK: "#000000"
321
+ };
322
+ function vn(e) {
323
+ return e.length === 4 ? `#${[...e.slice(1)].map((t) => t + t).join("")}` : e;
324
+ }
325
+ function oo(e) {
326
+ const t = vn(e);
327
+ return [
328
+ parseInt(t.slice(1, 3), 16),
329
+ // r
330
+ parseInt(t.slice(3, 5), 16),
331
+ // g
332
+ parseInt(t.slice(5, 7), 16)
333
+ // b
334
+ ];
335
+ }
336
+ function io(e) {
337
+ return `#${e.map((t) => t.toString(16).padStart(2, "0")).join("")}`;
338
+ }
339
+ function so(e, t, n) {
340
+ e /= 255, t /= 255, n /= 255;
341
+ const o = Math.max(e, t, n), i = Math.min(e, t, n), s = o - i;
342
+ let a = 0, l = 0;
343
+ const d = (o + i) / 2;
344
+ return o !== i && (l = d > 0.5 ? s / (2 - o - i) : s / (o + i)), o === e ? a = (t - n) / s + (t < n ? 6 : 0) : o === t ? a = (n - e) / s + 2 : o === n && (a = (e - t) / s + 4), a /= 6, [a, l, d];
345
+ }
346
+ function ao(e, t, n) {
347
+ let o, i, s;
348
+ if (t === 0)
349
+ o = i = s = n;
350
+ else {
351
+ const a = function(m, p, h) {
352
+ return h < 0 && (h += 1), h > 1 && (h -= 1), h < 0.16666666666666666 ? m + (p - m) * 6 * h : h < 0.5 ? p : h < 0.6666666666666666 ? m + (p - m) * (0.6666666666666666 - h) * 6 : m;
353
+ }, l = n < 0.5 ? n * (1 + t) : n + t - n * t, d = 2 * n - l;
354
+ o = a(d, l, e + 1 / 3), i = a(d, l, e), s = a(d, l, e - 1 / 3);
355
+ }
356
+ return [Math.round(o * 255), Math.round(i * 255), Math.round(s * 255)];
357
+ }
358
+ function De(e, t, n) {
359
+ const [o, i, s] = oo(e), [a, l, d] = so(o, i, s), g = Math.max(0, Math.min(1, d * t)), m = Math.max(0, Math.min(1, l * n)), [p, h, b] = ao(a, m, g);
360
+ return io([Math.round(p), Math.round(h), Math.round(b)]);
361
+ }
362
+ function lo(e, t = "light") {
363
+ return {
364
+ extraDark: De(e, 0.6, 1.2),
365
+ dark: De(e, 0.85, 1.1),
366
+ main: e,
367
+ light: De(e, t === "dark" ? 1.1 : 1.5, t === "dark" ? 0.95 : 0.9),
368
+ extraLight: De(e, t === "dark" ? 1.2 : 1.75, t === "dark" ? 0.9 : 0.8)
369
+ };
370
+ }
371
+ function at(e) {
372
+ const t = vn(e), n = 149, o = +`0x${t[1]}${t[2]}`, i = +`0x${t[3]}${t[4]}`, s = +`0x${t[5]}${t[6]}`;
373
+ return o * 0.299 + i * 0.587 + s * 0.114 > n ? st.BLACK : st.WHITE;
374
+ }
375
+ function co(e, t, n, o, i) {
376
+ return {
377
+ base: {
378
+ primary: t,
379
+ primaryContrastContent: n,
380
+ background: e.background50,
381
+ headerBackground: e.background50,
382
+ modalContentBackground: e.background50
383
+ },
384
+ metadata: {
385
+ errorContent: e.ondark.textHighEmphasis,
386
+ placeholderText: e.onlight.textLowEmphasis
387
+ },
388
+ messageInput: {
389
+ background: e.background100
390
+ },
391
+ messageIncoming: {
392
+ text: i,
393
+ background: o
394
+ },
395
+ messageOutgoing: {
396
+ text: n,
397
+ background: t
398
+ },
399
+ csat: {
400
+ background: e.background100
401
+ }
402
+ };
403
+ }
404
+ const uo = (e, t, n, o, i) => ({
405
+ base: {
406
+ primary: t,
407
+ primaryContrastContent: n,
408
+ background: e.background600,
409
+ headerBackground: e.background500,
410
+ modalContentBackground: e.background500
411
+ },
412
+ metadata: {
413
+ errorContent: e.ondark.textHighEmphasis,
414
+ placeholderText: e.ondark.textLowEmphasis
415
+ },
416
+ messageInput: {
417
+ background: e.background400
418
+ },
419
+ messageIncoming: {
420
+ text: i,
421
+ background: o
422
+ },
423
+ messageOutgoing: {
424
+ text: n,
425
+ background: t
426
+ },
427
+ csat: {
428
+ background: e.background400
429
+ }
430
+ }), Be = {
431
+ primary: {
432
+ extraDark: "#491389",
433
+ dark: "#6211c8",
434
+ main: "#742ddd",
435
+ light: "#c2a9fa",
436
+ extraLight: "#dbd1ff"
437
+ },
438
+ secondary: {
439
+ extraDark: "#066858",
440
+ dark: "#027d69",
441
+ main: "#259c72",
442
+ light: "#69c085",
443
+ extraLight: "#a8e2ab"
444
+ },
445
+ error: {
446
+ extraDark: "#9d091e",
447
+ dark: "#bf0711",
448
+ main: "#de360b",
449
+ light: "#f66161",
450
+ extraLight: "#fdaaaa"
451
+ },
452
+ information: {
453
+ extraDark: "#241389",
454
+ dark: "#362ca9",
455
+ main: "#4a48cd",
456
+ light: "#a9bbfa",
457
+ extraLight: "#d1dbff"
458
+ },
459
+ background700: "#000000",
460
+ background600: "#161616",
461
+ background500: "#2c2c2c",
462
+ background400: "#393939",
463
+ background300: "#bdbdbd",
464
+ background200: "#e0e0e0",
465
+ background100: "#eeeeee",
466
+ background50: "#ffffff",
467
+ onlight: {
468
+ textHighEmphasis: "rgba(0, 0, 0, 0.88)",
469
+ textMidEmphasis: "rgba(0, 0, 0, 0.5)",
470
+ textLowEmphasis: "rgba(0, 0, 0, 0.38)",
471
+ textDisabled: "rgba(0, 0, 0, 0.12)"
472
+ },
473
+ ondark: {
474
+ textHighEmphasis: "rgba(255, 255, 255, 0.88)",
475
+ textMidEmphasis: "rgba(255, 255, 255, 0.5)",
476
+ textLowEmphasis: "rgba(255, 255, 255, 0.38)",
477
+ textDisabled: "rgba(255, 255, 255, 0.12)"
478
+ },
479
+ overlay: {
480
+ dark: "rgba(0, 0, 0, 0.55)",
481
+ light: "rgba(22, 22, 22, 0.32)"
482
+ }
483
+ }, Qe = {
484
+ h1: { fontSize: 18, fontWeight: 700 },
485
+ h2: { fontSize: 16, fontWeight: 700 },
486
+ subtitle1: { fontSize: 16, fontWeight: 500 },
487
+ subtitle2: { fontSize: 16, fontWeight: 400 },
488
+ body1: { fontSize: 16, fontWeight: 400 },
489
+ body2: { fontSize: 14, fontWeight: 500 },
490
+ body3: { fontSize: 14, fontWeight: 400 },
491
+ button: { fontSize: 14, fontWeight: 700 },
492
+ caption1: { fontSize: 12, fontWeight: 700 },
493
+ caption2: { fontSize: 12, fontWeight: 400 },
494
+ caption3: { fontSize: 11, fontWeight: 700 },
495
+ caption4: { fontSize: 11, fontWeight: 400 }
496
+ };
497
+ function Bt(e) {
498
+ const t = mo(e), { colors: n, aiAgentColorVariables: o } = go(e, t), i = po(e);
499
+ return {
500
+ selectedTheme: e.selectedTheme,
501
+ palette: t,
502
+ colors: n,
503
+ aiAgentColorVariables: o,
504
+ typography: i
505
+ };
506
+ }
507
+ function mo({ selectedTheme: e, palette: t, primary: n }) {
508
+ const o = t != null && t.primary ? t.primary : n ? n === Be.primary.main ? Be.primary : lo(n, e) : Be.primary;
509
+ return {
510
+ ...Be,
511
+ primary: o,
512
+ ...t
513
+ };
514
+ }
515
+ function go({ selectedTheme: e, primaryContrast: t, botMessageBackground: n, botMessageBackgroundContrast: o }, i) {
516
+ const s = i.primary.main, a = t ?? at(s), l = n ?? st.DEFAULT_BOT_MSG_BG, d = o ?? at(l);
517
+ return {
518
+ colors: (e === "light" ? co : uo)(
519
+ i,
520
+ s,
521
+ a,
522
+ l,
523
+ d
524
+ ),
525
+ aiAgentColorVariables: {
526
+ primary_color: s,
527
+ bot_message_bg_color: l,
528
+ primary_contrast_color: a,
529
+ bot_message_bg_contrast_color: d
530
+ }
531
+ };
532
+ }
533
+ function po({ typography: e }) {
534
+ if (!e)
535
+ return Qe;
536
+ const t = { ...Qe };
537
+ return Object.keys(e).forEach((n) => {
538
+ const o = e[n];
539
+ if (o && typeof o == "object") {
540
+ const s = { ...Qe[n] };
541
+ o.fontSize !== void 0 && o.fontSize !== null && (s.fontSize = o.fontSize), o.fontWeight !== void 0 && o.fontWeight !== null && (s.fontWeight = o.fontWeight), o.fontFamily !== void 0 && o.fontFamily !== null && (s.fontFamily = o.fontFamily), t[n] = s;
542
+ }
543
+ }), t;
544
+ }
545
+ const {
546
+ Provider: ho,
547
+ useContext: yn
548
+ } = W("AIAgentTheme");
549
+ function fo({ logger: e, palette: t, typography: n, appearance: o, children: i }) {
550
+ const [s, a] = C(
551
+ () => Bt({
552
+ selectedTheme: (o == null ? void 0 : o.theme) ?? "light",
553
+ palette: t,
554
+ typography: n,
555
+ primary: o == null ? void 0 : o.primaryColor,
556
+ botMessageBackground: o == null ? void 0 : o.botMessageBackgroundColor
557
+ })
558
+ ), l = P(
559
+ (d, g) => {
560
+ const m = (o == null ? void 0 : o.theme) ?? d, p = g == null ? void 0 : g(m), h = {
561
+ primary: o == null ? void 0 : o.primaryColor,
562
+ primaryContrast: void 0,
563
+ botMessageBackground: o == null ? void 0 : o.botMessageBackgroundColor,
564
+ botMessageBackgroundContrast: void 0
565
+ };
566
+ !h.primary && (p != null && p.primaryColor) && (h.primary = p.primaryColor, h.primaryContrast = p.primaryContrastColor), !h.botMessageBackground && (p != null && p.botMessageBackgroundColor) && (h.botMessageBackground = p.botMessageBackgroundColor, h.botMessageBackgroundContrast = p.botMessageBackgroundContrastColor);
567
+ const b = Bt({ selectedTheme: m, palette: t, typography: n, ...h });
568
+ a(b), e == null || e.info("theme.update:", m);
569
+ },
570
+ [o == null ? void 0 : o.theme, o == null ? void 0 : o.primaryColor, o == null ? void 0 : o.botMessageBackgroundColor, t, n, e]
571
+ );
572
+ return R(() => {
573
+ (o != null && o.theme || o != null && o.primaryColor || o != null && o.botMessageBackgroundColor) && l(s.selectedTheme);
574
+ }, [o == null ? void 0 : o.theme, o == null ? void 0 : o.primaryColor, o == null ? void 0 : o.botMessageBackgroundColor]), /* @__PURE__ */ r.createElement(ho, { value: { theme: s, updateTheme: l } }, i);
575
+ }
576
+ const Cn = (e) => {
577
+ try {
578
+ const t = JSON.parse(e);
579
+ return typeof t == "string" ? JSON.stringify(t).slice(1, -1) : e.trim();
580
+ } catch {
581
+ return JSON.stringify(e).slice(1, -1);
582
+ }
583
+ }, Me = (e) => JSON.parse(e), Ye = (e) => JSON.parse(e);
584
+ function bo(e, t) {
585
+ const [n, o] = t.split(",").map((i) => i.trim());
586
+ return e === "dark" && o || n;
587
+ }
588
+ function xo(e) {
589
+ const t = {};
590
+ function n(o, i = "") {
591
+ for (const [s, a] of Object.entries(o)) {
592
+ const l = i ? `${i}.${s}` : s;
593
+ a && typeof a == "object" && !Array.isArray(a) ? n(a, l) : t[l] = a;
594
+ }
595
+ }
596
+ return n(e), t;
597
+ }
598
+ function mt({
599
+ template: e,
600
+ variables: t,
601
+ variableKeyPattern: n,
602
+ variableValueTransformer: o
603
+ }) {
604
+ return Object.entries(t).reduce((i, [s, a]) => {
605
+ if (!o && !["number", "boolean", "string"].includes(typeof a))
606
+ throw new Error("If transformer is not provided, value must be a {string, number, or boolean}");
607
+ const l = o ? o(a) : String(a), d = n(s);
608
+ return i.replace(d, Cn(l));
609
+ }, e);
610
+ }
611
+ async function Eo({
612
+ template: e,
613
+ variables: t,
614
+ variableKeyPattern: n,
615
+ variableValueTransformer: o
616
+ }) {
617
+ return (await Promise.all(
618
+ Object.entries(t).map(async ([s, a]) => {
619
+ const l = await o(a);
620
+ return { regex: n(s), transformedValue: l };
621
+ })
622
+ )).reduce((s, { regex: a, transformedValue: l }) => s.replace(a, Cn(l)), e);
623
+ }
624
+ const vo = (e) => ({
625
+ setTemplate: (t, n) => e.onSetTemplate(t, n),
626
+ getTemplate: (t) => e.onGetTemplate(t),
627
+ setCachedToken: (t) => e.onSetCachedToken(t),
628
+ getCachedToken: () => e.onGetCachedToken(),
629
+ clear: () => e.onClear()
630
+ }), {
631
+ Provider: yo,
632
+ useContext: Tn
633
+ } = W("MessageCacheTemplate");
634
+ function Co({ logger: e, storage: t, children: n }) {
635
+ const o = P(
636
+ (a) => {
637
+ var g, m;
638
+ const l = (m = (g = a.appInfo) == null ? void 0 : g.aiAgentInfo) == null ? void 0 : m.templateListToken;
639
+ if (!l) return !1;
640
+ const d = t.getCachedToken();
641
+ return d ? l !== d : !0;
642
+ },
643
+ [t]
644
+ ), i = P(
645
+ async (a) => {
646
+ try {
647
+ const { templates: l, token: d } = await a.aiAgent.getMessageTemplates({ limit: 20 });
648
+ for (const { template: g } of l) {
649
+ const { key: m } = Me(g);
650
+ t.setTemplate(m, g);
651
+ }
652
+ t.setCachedToken(d);
653
+ } catch (l) {
654
+ e == null || e.error("messageTemplateContext.syncCachedTemplates: error:", l);
655
+ }
656
+ },
657
+ [t, e]
658
+ ), s = P(() => {
659
+ t.clear();
660
+ }, [t]);
661
+ return /* @__PURE__ */ r.createElement(yo, { value: { shouldSyncCachedTemplate: o, syncCachedTemplates: i, clearCachedTemplates: s, storage: t } }, n);
662
+ }
663
+ function To(e) {
664
+ let t = "pending", n = e.then((o) => {
665
+ t = "resolved", n = o;
666
+ }).catch((o) => {
667
+ t = "rejected", n = o;
668
+ });
669
+ return {
670
+ get value() {
671
+ if (t === "resolved")
672
+ return n;
673
+ throw n;
674
+ }
675
+ };
676
+ }
677
+ const {
678
+ Provider: _o,
679
+ useContext: _n
680
+ } = W("MessageTemplateFetching");
681
+ function So({ children: e, internalVariables: t }) {
682
+ const n = D({}), o = D({}), [i, s] = C({}), a = P((g, m) => {
683
+ s((p) => ({
684
+ ...p,
685
+ [g]: { fetching: !1, error: !1, ...p[g], ...m }
686
+ }));
687
+ }, []), l = P(
688
+ async ({
689
+ onRequestTemplate: g,
690
+ onGetCachedTemplate: m,
691
+ templateKey: p,
692
+ suspense: h = !1
693
+ }) => {
694
+ const b = m(p);
695
+ if (b) return b;
696
+ const x = o.current[p];
697
+ if (x) return x;
698
+ h || a(p, { fetching: !0 });
699
+ const v = g(p).catch((f) => {
700
+ throw h || a(p, { error: !0 }), f;
701
+ }).finally(() => {
702
+ h || a(p, { fetching: !1 }), delete o.current[p];
703
+ });
704
+ return o.current[p] = v, v;
705
+ },
706
+ [a]
707
+ ), d = {
708
+ internalVariables: t,
709
+ fetchTemplate: l,
710
+ suspend: (g, m) => {
711
+ if (n.current[g])
712
+ return n.current[g];
713
+ const p = To(m());
714
+ return n.current[g] = p, p;
715
+ },
716
+ getIsFetching: (g) => {
717
+ var m;
718
+ return ((m = i[g]) == null ? void 0 : m.fetching) ?? !1;
719
+ },
720
+ getHasError: (g) => {
721
+ var m;
722
+ return ((m = i[g]) == null ? void 0 : m.error) ?? !1;
723
+ }
724
+ };
725
+ return /* @__PURE__ */ r.createElement(_o, { value: d }, e);
726
+ }
727
+ const qe = {
728
+ VARIABLE: (e) => new RegExp(`\\{${e}\\}`, "g"),
729
+ VIEW_VARIABLE: (e) => new RegExp(`"{@${e}}"`, "g")
730
+ };
731
+ function oe({ uiTemplateString: e, variables: t = {} }) {
732
+ const n = xo(t);
733
+ return mt({
734
+ template: e,
735
+ variables: n,
736
+ variableKeyPattern: (o) => qe.VARIABLE(o)
737
+ });
738
+ }
739
+ function ie({
740
+ theme: e,
741
+ uiTemplateString: t,
742
+ colorVariables: n = {}
743
+ }) {
744
+ return mt({
745
+ template: t,
746
+ variables: n,
747
+ variableKeyPattern: (o) => qe.VARIABLE(o),
748
+ variableValueTransformer: (o) => bo(e, o)
749
+ });
750
+ }
751
+ function wo({
752
+ theme: e,
753
+ uiTemplateString: t,
754
+ viewVariables: n = {},
755
+ aiAgentColorVariables: o,
756
+ internalVariables: i,
757
+ onRequestTemplate: s
758
+ }) {
759
+ const l = Object.values(n).flat().map((g) => g.key);
760
+ return [...new Set(l)].some((g) => !s(g)) ? null : mt({
761
+ template: t,
762
+ variables: n,
763
+ variableKeyPattern: (g) => qe.VIEW_VARIABLE(g),
764
+ variableValueTransformer: (g) => {
765
+ const m = g.map(({ key: p, variables: h }) => {
766
+ const b = s(p), { ui_template: x, color_variables: v } = Me(b);
767
+ let f = JSON.stringify(x);
768
+ return f = oe({
769
+ uiTemplateString: f,
770
+ variables: i
771
+ }), f = ie({
772
+ theme: e,
773
+ uiTemplateString: f,
774
+ colorVariables: v
775
+ }), f = ie({
776
+ theme: e,
777
+ uiTemplateString: f,
778
+ colorVariables: o
779
+ }), f = oe({
780
+ uiTemplateString: f,
781
+ variables: h
782
+ }), Ye(f);
783
+ });
784
+ return JSON.stringify(m);
785
+ }
786
+ });
787
+ }
788
+ async function ko({
789
+ theme: e,
790
+ uiTemplateString: t,
791
+ viewVariables: n = {},
792
+ aiAgentColorVariables: o,
793
+ internalVariables: i,
794
+ onRequestTemplate: s
795
+ }) {
796
+ return Eo({
797
+ template: t,
798
+ variables: n,
799
+ variableKeyPattern: (a) => qe.VIEW_VARIABLE(a),
800
+ variableValueTransformer: async (a) => {
801
+ const l = a.map(async ({ key: g, variables: m }) => {
802
+ const p = await s(g), { ui_template: h, color_variables: b } = Me(p);
803
+ let x = JSON.stringify(h);
804
+ return x = oe({
805
+ uiTemplateString: x,
806
+ variables: i
807
+ }), x = ie({
808
+ theme: e,
809
+ uiTemplateString: x,
810
+ colorVariables: b
811
+ }), x = ie({
812
+ theme: e,
813
+ uiTemplateString: x,
814
+ colorVariables: o
815
+ }), x = oe({
816
+ uiTemplateString: x,
817
+ variables: m
818
+ }), Ye(x);
819
+ }), d = await Promise.all(l);
820
+ return JSON.stringify(d);
821
+ }
822
+ });
823
+ }
824
+ const Ao = ({
825
+ rawTemplate: e,
826
+ aiAgentColorVariables: t,
827
+ internalVariables: n,
828
+ ...o
829
+ }) => {
830
+ const { ui_template: i, color_variables: s } = Me(e);
831
+ let a = JSON.stringify(i);
832
+ if (Object.keys(o.viewVariables ?? {}).length > 0) {
833
+ const d = wo({
834
+ ...o,
835
+ uiTemplateString: a,
836
+ aiAgentColorVariables: t,
837
+ internalVariables: n
838
+ });
839
+ if (d === null) return null;
840
+ a = d;
841
+ }
842
+ return a = oe({ ...o, uiTemplateString: a, variables: n }), a = ie({ ...o, uiTemplateString: a, colorVariables: s }), a = ie({ ...o, uiTemplateString: a, colorVariables: t }), a = oe({ ...o, uiTemplateString: a }), Ye(a);
843
+ }, Io = async ({
844
+ rawTemplate: e,
845
+ aiAgentColorVariables: t,
846
+ internalVariables: n,
847
+ ...o
848
+ }) => {
849
+ const { ui_template: i, color_variables: s } = Me(e);
850
+ let a = JSON.stringify(i);
851
+ return Object.keys(o.viewVariables ?? {}).length > 0 && (a = await ko({
852
+ ...o,
853
+ uiTemplateString: a,
854
+ aiAgentColorVariables: t,
855
+ internalVariables: n
856
+ })), a = oe({ ...o, uiTemplateString: a, variables: n }), a = ie({ ...o, uiTemplateString: a, colorVariables: s }), a = ie({ ...o, uiTemplateString: a, colorVariables: t }), a = oe({ ...o, uiTemplateString: a }), Ye(a);
857
+ }, $o = (e) => {
858
+ const { aiAgentColorVariables: t = {} } = e, { internalVariables: n } = _n();
859
+ return C(() => {
860
+ const o = e.onGetCachedTemplate(e.templateKey);
861
+ return o ? Ao({
862
+ ...e,
863
+ rawTemplate: o,
864
+ aiAgentColorVariables: t,
865
+ internalVariables: n,
866
+ onRequestTemplate: e.onGetCachedTemplate
867
+ }) : null;
868
+ });
869
+ }, Mo = (e) => {
870
+ const [t] = $o(e);
871
+ if (t) return t;
872
+ const { aiAgentColorVariables: n = {} } = e, { internalVariables: o, fetchTemplate: i, suspend: s } = _n();
873
+ return s(e.templateKey, async () => {
874
+ const l = await i({ ...e, suspense: !0 });
875
+ return await Io({
876
+ ...e,
877
+ rawTemplate: l,
878
+ aiAgentColorVariables: n,
879
+ internalVariables: o
880
+ });
881
+ }).value;
882
+ }, Oo = '@import"https://fonts.googleapis.com/css?family=Roboto:400,500,600,700&display=swap";.sb-message-template__border{position:relative}.sb-message-template__border:after{content:"";position:absolute;top:0;bottom:0;left:0;right:0;z-index:1;box-shadow:inset 0 0 0 var(--border-width) var(--border-color);border-radius:var(--border-radius);pointer-events:none}.sb-message-template__action{cursor:pointer}.sb-message-template__parent{font-family:Roboto,serif}.sb-message-template__text{font-family:inherit;font-size:14px;font-weight:400;font-stretch:normal;font-style:normal;letter-spacing:normal;text-align:left}.sb-message-template__text-button{font-family:inherit;background-color:#e0e0e0;text-align:center;padding:10px;border-radius:6px;font-size:14px;font-weight:600;font-stretch:normal;font-style:normal;letter-spacing:normal}.sendbird-theme--light .sb-message-template__text-button{color:#742ddd}.sendbird-theme--dark .sb-message-template__text-button{color:#c2a9fa}.sb-message-template__text-button:hover{opacity:1;box-shadow:#0000001a 0 1px 3px,#0000000f 0 1px 2px}.sb-message-template__text-button,.sb-message-template__image-button{cursor:pointer;border-style:none}.sb-message-template__parent{border-radius:unset;background-color:transparent;overflow:hidden}.sb-message-template__parent *{box-sizing:border-box;line-height:1.3}.sb-message-template__carousel{display:flex;width:100%;box-sizing:border-box;touch-action:pan-y}', Oe = "en", Lo = /* @__PURE__ */ new Set([
883
+ Oe,
884
+ "ko",
885
+ "es",
886
+ "pt",
887
+ "fr",
888
+ "hi",
889
+ "it",
890
+ "de",
891
+ "tr",
892
+ "ja"
893
+ ]), Ro = (e, t, n) => {
894
+ const o = e[t];
895
+ return o ? typeof o == "function" ? o() : Promise.resolve(o) : new Promise((i, s) => {
896
+ (typeof queueMicrotask == "function" ? queueMicrotask : setTimeout)(
897
+ s.bind(
898
+ null,
899
+ new Error(
900
+ "Unknown variable dynamic import: " + t + (t.split("/").length !== n ? ". Note that variables only represent file names one level deep." : "")
901
+ )
902
+ )
903
+ );
904
+ });
905
+ }, No = Sr, Do = {
906
+ // Channel - Common
907
+ CHANNEL_FROZEN: "Channel frozen",
908
+ PLACE_HOLDER__WRONG: "Something went wrong",
909
+ PLACE_HOLDER__NO_MESSAGES: "No messages",
910
+ UNKNOWN__UNKNOWN_MESSAGE_TYPE: "(Unknown message type)",
911
+ // Channel - Header
912
+ HEADER_BUTTON__AGENT_HANDOFF: "Connect with an agent",
913
+ // Message Input
914
+ MESSAGE_INPUT__PLACE_HOLDER: "Ask a question",
915
+ MESSAGE_INPUT__PLACE_HOLDER__WAIT_AI_AGENT_RESPONSE: "Waiting for the agent’s reply…",
916
+ MESSAGE_INPUT__PLACE_HOLDER__DISABLED: "Chat is unavailable in this channel",
917
+ // Common UI
918
+ BUTTON__CANCEL: "Cancel",
919
+ BUTTON__SAVE: "Save",
920
+ BUTTON__OK: "OK",
921
+ NO_NAME: "(No name)",
922
+ RETRY: "Retry",
923
+ // Date format
924
+ DATE_FORMAT__MESSAGE_LIST__DATE_SEPARATOR: "MMMM dd, yyyy",
925
+ DATE_FORMAT__MESSAGE_TIMESTAMP: "p",
926
+ // File Upload
927
+ FILE_UPLOAD_NOTIFICATION__COUNT_LIMIT: "You can't upload more than one image",
928
+ FILE_UPLOAD_NOTIFICATION__SIZE_LIMIT: "The maximum size per file is %d MB.",
929
+ // File Viewer
930
+ FILE_VIEWER__UNSUPPORT: "Unsupported message",
931
+ // CSAT
932
+ CSAT_TITLE_UNSUBMITTED: "Your feedback matters to us",
933
+ CSAT_TITLE_SUBMITTED: "Successfully submitted!",
934
+ CSAT_CRE_TITLE: "Was your issue resolved?",
935
+ CSAT_CRE_SOLVED: "Yes, thank you! 👍",
936
+ CSAT_CRE_NOT_SOLVED: "No, that didn’t help.",
937
+ CSAT_REASON_PLACEHOLDER: "Share your feedback",
938
+ CSAT_RATING_TITLE: "How would you rate your experience?",
939
+ CSAT5_RATING_SCORE_1: "Terrible",
940
+ CSAT5_RATING_SCORE_2: "Bad",
941
+ CSAT5_RATING_SCORE_3: "Okay",
942
+ CSAT5_RATING_SCORE_4: "Good",
943
+ CSAT5_RATING_SCORE_5: "Great",
944
+ CSAT_SUBMIT_LABEL: "Submit",
945
+ CSAT_SUBMISSION_EXPIRED: "We’re sorry, the survey period has ended.",
946
+ POWERED_BY: "Powered by",
947
+ // Conversation list
948
+ CONVERSATION_CLOSED_FOOTER_LABEL: "Your conversation has ended",
949
+ START_NEW_CONVERSATION: "💬 Start a new conversation",
950
+ RETURN_TO_CONVERSATION: "💬 Return to conversation",
951
+ CONVERSATION_LIST__HEADER_TITLE: "Conversation history",
952
+ CONVERSATION_LIST__TOPICS_FALLBACK: "No category",
953
+ CONVERSATION_LIST__NO_CONVERSATIONS: "No conversations yet",
954
+ DATE_FORMAT__CONVERSATION_LIST__LIST_ITEM_TITLE: "MM/dd/yyyy",
955
+ DATE_FORMAT__CONVERSATION_LIST__LIST_ITEM_TITLE_CAPTION: "h:mma"
956
+ }, gt = { language: "en", dateLocale: No, stringSet: Do }, Bo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
957
+ __proto__: null,
958
+ default: gt
959
+ }, Symbol.toStringTag, { value: "Module" })), We = /* @__PURE__ */ new Map([[Oe, gt]]);
960
+ async function Po(e) {
961
+ if (We.has(e))
962
+ return We.get(e);
963
+ const t = Lo.has(e) ? e : Oe;
964
+ try {
965
+ const { default: n } = await Ro(/* @__PURE__ */ Object.assign({ "./languages/de.ts": () => import("./DvjrAXLD.js"), "./languages/en.ts": () => Promise.resolve().then(() => Bo), "./languages/es.ts": () => import("./zI14HLvP.js"), "./languages/fr.ts": () => import("./B9V0T5ZP.js"), "./languages/hi.ts": () => import("./YRQ0vk5Q.js"), "./languages/it.ts": () => import("./BQWJPfGp.js"), "./languages/ja.ts": () => import("./sl-YrKkN.js"), "./languages/ko.ts": () => import("./B8c_rqvH.js"), "./languages/pt.ts": () => import("./BSz49qaD.js"), "./languages/tr.ts": () => import("./D_eZyIAR.js") }), `./languages/${t}.ts`, 3);
966
+ return We.set(e, n), n;
967
+ } catch {
968
+ return gt;
969
+ }
970
+ }
971
+ const {
972
+ Provider: Fo,
973
+ useContext: M
974
+ } = W("Localization");
975
+ function Ho(e) {
976
+ var t;
977
+ return ((t = e.split("-")) == null ? void 0 : t[0]) ?? Oe;
978
+ }
979
+ function Uo({
980
+ language: e = navigator.language,
981
+ logger: t,
982
+ stringSet: n,
983
+ children: o
984
+ }) {
985
+ const [i, s] = C(We.get(Oe));
986
+ return R(() => {
987
+ const a = Ho(e);
988
+ i.language !== a && (t == null || t.debug("localization.useEffect: update language", `${i.language} -> ${a}`), Po(a).then(s));
989
+ }, [e]), /* @__PURE__ */ r.createElement(
990
+ Fo,
991
+ {
992
+ value: {
993
+ language: i.language,
994
+ stringSet: { ...i.stringSet, ...n },
995
+ dateLocale: i.dateLocale,
996
+ format: (a, l, d) => pn(a, l, { locale: i.dateLocale, ...d })
997
+ }
998
+ },
999
+ o
1000
+ );
1001
+ }
1002
+ const Ve = "data-sb-agent-theme", Pt = (e) => (t, ...n) => {
1003
+ let o = "";
1004
+ return t.forEach((i, s) => {
1005
+ o += i + (n[s] ?? "");
1006
+ }), `[${Ve}='${e}'] & { ${o} }`;
1007
+ }, B = {
1008
+ light: Pt("light"),
1009
+ dark: Pt("dark")
1010
+ }, zo = k(({ theme: e }) => {
1011
+ const { palette: t } = e;
1012
+ return `
1013
+ :root,
1014
+ :host {
1015
+ --sendbird-primary-extra-dark: ${t.primary.extraDark};
1016
+ --sendbird-primary-dark: ${t.primary.dark};
1017
+ --sendbird-primary-main: ${t.primary.main};
1018
+ --sendbird-primary-light: ${t.primary.light};
1019
+ --sendbird-primary-extra-light: ${t.primary.extraLight};
1020
+
1021
+ --sendbird-secondary-extra-dark: ${t.secondary.extraDark};
1022
+ --sendbird-secondary-dark: ${t.secondary.dark};
1023
+ --sendbird-secondary-main: ${t.secondary.main};
1024
+ --sendbird-secondary-light: ${t.secondary.light};
1025
+ --sendbird-secondary-extra-light: ${t.secondary.extraLight};
1026
+
1027
+ --sendbird-information-extra-dark: ${t.information.extraDark};
1028
+ --sendbird-information-dark: ${t.information.dark};
1029
+ --sendbird-information-main: ${t.information.main};
1030
+ --sendbird-information-light: ${t.information.light};
1031
+ --sendbird-information-extra-light: ${t.information.extraLight};
1032
+
1033
+ --sendbird-error-extra-dark: ${t.error.extraDark};
1034
+ --sendbird-error-dark: ${t.error.dark};
1035
+ --sendbird-error-main: ${t.error.main};
1036
+ --sendbird-error-light: ${t.error.light};
1037
+ --sendbird-error-extra-light: ${t.error.extraLight};
1038
+
1039
+ --sendbird-background-700: ${t.background700};
1040
+ --sendbird-background-600: ${t.background600};
1041
+ --sendbird-background-500: ${t.background500};
1042
+ --sendbird-background-400: ${t.background400};
1043
+ --sendbird-background-300: ${t.background300};
1044
+ --sendbird-background-200: ${t.background200};
1045
+ --sendbird-background-100: ${t.background100};
1046
+ --sendbird-background-50: ${t.background50};
1047
+
1048
+ --sendbird-onlight-text-high-emphasis: ${t.onlight.textHighEmphasis};
1049
+ --sendbird-onlight-text-mid-emphasis: ${t.onlight.textMidEmphasis};
1050
+ --sendbird-onlight-text-low-emphasis: ${t.onlight.textLowEmphasis};
1051
+ --sendbird-onlight-text-disabled: ${t.onlight.textDisabled};
1052
+
1053
+ --sendbird-ondark-text-high-emphasis: ${t.ondark.textHighEmphasis};
1054
+ --sendbird-ondark-text-mid-emphasis: ${t.ondark.textMidEmphasis};
1055
+ --sendbird-ondark-text-low-emphasis: ${t.ondark.textLowEmphasis};
1056
+ --sendbird-ondark-text-disabled: ${t.ondark.textDisabled};
1057
+
1058
+ --sendbird-overlay-dark: ${t.overlay.dark};
1059
+ --sendbird-overlay-light: ${t.overlay.light};
1060
+ }
1061
+ `;
1062
+ }), Wo = k`[${Ve}='light'] &{--sb-text-high-emphasis:var(--sendbird-onlight-text-high-emphasis);--sb-text-mid-emphasis:var(--sendbird-onlight-text-mid-emphasis);--sb-text-low-emphasis:var(--sendbird-onlight-text-low-emphasis);--sb-text-disabled:var(--sendbird-onlight-text-disabled);--sb-text-high-emphasis-inverse:var(--sendbird-ondark-text-high-emphasis);--sb-text-mid-emphasis-inverse:var(--sendbird-ondark-text-mid-emphasis);--sb-text-low-emphasis-inverse:var(--sendbird-ondark-text-low-emphasis);--sb-text-disabled-inverse:var(--sendbird-ondark-text-disabled);--sb-bg-50-600:var(--sendbird-background-50);--sb-bg-100-500:var(--sendbird-background-100);--sb-bg-200-400:var(--sendbird-background-200);--sb-primary:var(--sendbird-primary-main);--sb-secondary:var(--sendbird-secondary-main);--sb-error:var(--sendbird-error-main);--sb-information:var(--sendbird-information-light);}[${Ve}='dark'] &{--sb-text-high-emphasis:var(--sendbird-ondark-text-high-emphasis);--sb-text-mid-emphasis:var(--sendbird-ondark-text-mid-emphasis);--sb-text-low-emphasis:var(--sendbird-ondark-text-low-emphasis);--sb-text-disabled:var(--sendbird-ondark-text-disabled);--sb-text-high-emphasis-inverse:var(--sendbird-onlight-text-high-emphasis);--sb-text-mid-emphasis-inverse:var(--sendbird-onlight-text-mid-emphasis);--sb-text-low-emphasis-inverse:var(--sendbird-onlight-text-low-emphasis);--sb-text-disabled-inverse:var(--sendbird-onlight-text-disabled);--sb-bg-50-600:var(--sendbird-background-600);--sb-bg-100-500:var(--sendbird-background-500);--sb-bg-200-400:var(--sendbird-background-400);--sb-primary:var(--sendbird-primary-light);--sb-secondary:var(--sendbird-secondary-light);--sb-error:var(--sendbird-error-light);--sb-information:var(--sendbird-information-light);}`, u = {
1063
+ color: {
1064
+ primary: {
1065
+ dark: "var(--sendbird-primary-dark)",
1066
+ main: "var(--sendbird-primary-main)"
1067
+ },
1068
+ error: {
1069
+ extraDark: "var(--sendbird-error-extra-dark)",
1070
+ dark: "var(--sendbird-error-dark)"
1071
+ },
1072
+ information: {
1073
+ main: "var(--sendbird-information-main)",
1074
+ light: "var(--sendbird-information-light)"
1075
+ },
1076
+ background700: "var(--sendbird-background-700)",
1077
+ background500: "var(--sendbird-background-500)",
1078
+ background400: "var(--sendbird-background-400)",
1079
+ background200: "var(--sendbird-background-200)",
1080
+ background100: "var(--sendbird-background-100)",
1081
+ background50: "var(--sendbird-background-50)",
1082
+ ondark: {
1083
+ textMidEmphasis: "var(--sendbird-ondark-text-mid-emphasis)",
1084
+ textLowEmphasis: "var(--sendbird-ondark-text-low-emphasis)",
1085
+ textDisabled: "var(--sendbird-ondark-text-disabled)"
1086
+ },
1087
+ overlay: {
1088
+ dark: "var(--sendbird-overlay-dark)"
1089
+ }
1090
+ },
1091
+ themedColor: {
1092
+ textHighEmphasis: "var(--sb-text-high-emphasis)",
1093
+ textMidEmphasis: "var(--sb-text-mid-emphasis)",
1094
+ textLowEmphasis: "var(--sb-text-low-emphasis)",
1095
+ textDisabled: "var(--sb-text-disabled)",
1096
+ textHighEmphasisInverse: "var(--sb-text-high-emphasis-inverse)",
1097
+ bg_50_600: "var(--sb-bg-50-600)",
1098
+ bg_100_500: "var(--sb-bg-100-500)",
1099
+ bg_200_400: "var(--sb-bg-200-400)",
1100
+ error: "var(--sb-error)"
1101
+ }
1102
+ }, {
1103
+ Provider: Vo,
1104
+ useContext: Go
1105
+ } = W("AIAgentTheme");
1106
+ function jo(e) {
1107
+ const { theme: t, appearance: n, logger: o } = e;
1108
+ return /* @__PURE__ */ r.createElement(
1109
+ fo,
1110
+ {
1111
+ appearance: n,
1112
+ palette: t == null ? void 0 : t.palette,
1113
+ typography: t == null ? void 0 : t.typography,
1114
+ logger: o
1115
+ },
1116
+ /* @__PURE__ */ r.createElement(Ko, { ...e })
1117
+ );
1118
+ }
1119
+ function Ko({ rootElement: e = document.body, children: t }) {
1120
+ const { theme: n, updateTheme: o } = yn();
1121
+ return ge(() => {
1122
+ e.setAttribute(Ve, n.selectedTheme);
1123
+ }, [e, n.selectedTheme]), /* @__PURE__ */ r.createElement(yr, { theme: n }, /* @__PURE__ */ r.createElement(Vo, { value: { theme: n, updateTheme: o } }, t));
1124
+ }
1125
+ function pe(e, t) {
1126
+ const n = e.getRootNode({ composed: t });
1127
+ return n instanceof ShadowRoot || n instanceof Document ? n : document;
1128
+ }
1129
+ const Zo = (e, t) => {
1130
+ R(() => {
1131
+ const n = pe(t) instanceof ShadowRoot, o = pe(t, !0);
1132
+ if (!(n ? t : o).querySelector(`link[href*='${e}']`)) {
1133
+ const s = o.createElement("link");
1134
+ s.rel = "stylesheet", s.href = e, (n ? t : o.head).appendChild(s);
1135
+ }
1136
+ }, [e, t]);
1137
+ }, Yo = (e, t = document.body) => {
1138
+ R(() => {
1139
+ const n = pe(t), i = n instanceof ShadowRoot ? t : n.head;
1140
+ if (!i) return;
1141
+ const s = `sba-${btoa(e).slice(0, 10)}`;
1142
+ let a = i.querySelector(`style#${s}`);
1143
+ a ? a.textContent !== e && (a.textContent = e) : (a = i.ownerDocument.createElement("style"), a.id = s, a.textContent = e, i.appendChild(a));
1144
+ }, [e, t]);
1145
+ }, pt = /iPad|iPhone|iPod/.test(navigator.userAgent), qo = /Android/.test(navigator.userAgent), Le = (e) => pt || qo, Z = "sb-agent", X = {
1146
+ ENTRY: `${Z}-entry`,
1147
+ MODAL_ROOT: `${Z}-modal-root`,
1148
+ WINDOW: `${Z}-window`,
1149
+ LAUNCHER: `${Z}-launcher`
1150
+ }, Pe = 2147483647, he = {
1151
+ MODAL: Pe - 1,
1152
+ // FIXME: need to cover the case where the tooltip is on the top of the modal
1153
+ TOOLTIP: Pe - 2,
1154
+ WINDOW: Pe - 3,
1155
+ LAUNCHER: Pe - 4
1156
+ }, Sn = {
1157
+ SESSION: `@${Z}-session`,
1158
+ USER_DATA: `@${Z}-udata`
1159
+ }, wn = {
1160
+ DEFAULT_PRIMARY: "#742ddd",
1161
+ WHITE: "#ffffff"
1162
+ }, kn = 36, Jo = 100, Xo = 25 * 1024 * 1024, An = ["application/pdf", "image/jpeg", "image/jpg", "image/png"], ht = "noopener noreferrer nofollow", Fe = {}, q = {
1163
+ getItem: (e) => {
1164
+ try {
1165
+ return localStorage.getItem(e);
1166
+ } catch {
1167
+ return Fe[e] ?? null;
1168
+ }
1169
+ },
1170
+ setItem: (e, t) => {
1171
+ try {
1172
+ localStorage.setItem(e, t);
1173
+ } catch {
1174
+ Fe[e] = t;
1175
+ }
1176
+ },
1177
+ deleteItem: (e) => {
1178
+ try {
1179
+ localStorage.removeItem(e);
1180
+ } catch {
1181
+ delete Fe[e];
1182
+ }
1183
+ },
1184
+ getKeys: (e) => {
1185
+ try {
1186
+ const t = [];
1187
+ for (let n = 0; n < localStorage.length; n++) {
1188
+ const o = localStorage.key(n);
1189
+ o && o.startsWith(e) && t.push(o);
1190
+ }
1191
+ return t;
1192
+ } catch {
1193
+ return Object.keys(Fe).filter((t) => t.startsWith(e));
1194
+ }
1195
+ }
1196
+ };
1197
+ function In(e) {
1198
+ const { keyGenerator: t, keyParamsValidator: n } = e;
1199
+ function o(a) {
1200
+ try {
1201
+ n && n(a);
1202
+ const l = t(a), d = q.getItem(l);
1203
+ return d ? JSON.parse(d) : null;
1204
+ } catch {
1205
+ return null;
1206
+ }
1207
+ }
1208
+ function i(a, l) {
1209
+ try {
1210
+ n && n(a);
1211
+ const d = t(a), g = JSON.stringify(l);
1212
+ q.setItem(d, g);
1213
+ } catch {
1214
+ }
1215
+ }
1216
+ function s(a) {
1217
+ try {
1218
+ n && n(a);
1219
+ const l = t(a);
1220
+ q.deleteItem(l);
1221
+ } catch {
1222
+ }
1223
+ }
1224
+ return { get: o, set: i, clear: s };
1225
+ }
1226
+ const et = In({
1227
+ keyGenerator: ({ appId: e, aiAgentId: t, userId: n }) => {
1228
+ const o = Qo(`${e}/${t}/${n}`);
1229
+ return `${Sn.USER_DATA}/${o}`;
1230
+ },
1231
+ keyParamsValidator: ({ appId: e, aiAgentId: t, userId: n }) => {
1232
+ if (!e || !t || !n)
1233
+ throw new Error("Invalid parameters for user data cache");
1234
+ }
1235
+ });
1236
+ function Qo(e) {
1237
+ let t = 0;
1238
+ for (let n = 0; n < e.length; n++)
1239
+ t = (t << 5) - t + e.charCodeAt(n), t |= 0;
1240
+ return t.toString(16);
1241
+ }
1242
+ const tt = In({
1243
+ keyGenerator: ({ appId: e, aiAgentId: t }) => `${Sn.SESSION}/${e}/${t}`
1244
+ }), {
1245
+ Provider: ei,
1246
+ Consumer: $n,
1247
+ useContext: N
1248
+ } = W("Agent");
1249
+ function ti({
1250
+ children: e,
1251
+ state: t,
1252
+ enableCloseConversationButton: n = !1,
1253
+ enableExpandButton: o = !0,
1254
+ enableAutoDisconnectInLauncher: i = !0,
1255
+ ...s
1256
+ }) {
1257
+ const a = Ze(), [l, d] = C(!1), [g, m] = C(!1), p = {
1258
+ opened: (t == null ? void 0 : t.opened) ?? l,
1259
+ setOpened: (t == null ? void 0 : t.setOpened) ?? d,
1260
+ expanded: (t == null ? void 0 : t.expanded) ?? g,
1261
+ setExpanded: (t == null ? void 0 : t.setExpanded) ?? m
1262
+ };
1263
+ return /* @__PURE__ */ r.createElement(
1264
+ ei,
1265
+ {
1266
+ value: {
1267
+ ...s,
1268
+ ...a,
1269
+ state: p,
1270
+ enableCloseConversationButton: n,
1271
+ enableExpandButton: o,
1272
+ enableAutoDisconnectInLauncher: i
1273
+ }
1274
+ },
1275
+ e
1276
+ );
1277
+ }
1278
+ function ni() {
1279
+ const { chatSDK: e, logger: t } = N(), { shouldSyncCachedTemplate: n, syncCachedTemplates: o, clearCachedTemplates: i } = Tn(), s = P(
1280
+ async (l, d) => {
1281
+ t.debug("authManager.authenticate: session:", l.userId), d && e.setSessionHandler(new Er(d)), await e.connect(l.userId, l.authToken), t.debug("authManager.authenticate: user:", e.currentUser), n(e) && await o(e);
1282
+ },
1283
+ [e, t, n, o]
1284
+ ), a = P(async () => {
1285
+ t.debug("authManager.deauthenticate: disconnect"), await e.disconnect(), i();
1286
+ }, [e, t, i]);
1287
+ return {
1288
+ authenticate: s,
1289
+ deauthenticate: a
1290
+ };
1291
+ }
1292
+ const ri = 24 * 60 * 60 * 1e3, {
1293
+ Provider: oi,
1294
+ useContext: F
1295
+ } = W("MessengerSession");
1296
+ function ii({
1297
+ userSessionInfo: e,
1298
+ children: t
1299
+ }) {
1300
+ const { appId: n, aiAgentId: o, chatSDK: i, agentPreviewConfigs: s, state: a, logger: l, language: d, countryCode: g, context: m, handlers: p } = N(), { updateTheme: h } = yn(), { authenticate: b, deauthenticate: x } = ni(), [v, f] = C(
1301
+ void 0
1302
+ ), [y, _] = C(void 0), [w, O] = C(null), [ee, H] = C(null), [le, _e] = C(null), E = s == null ? void 0 : s.forceCreateChannel;
1303
+ function U() {
1304
+ if (e) {
1305
+ l.debug("messengerSession.initialize: manual session info detected");
1306
+ const A = ["userId", "authToken", "sessionHandler"].filter((L) => !(L in e));
1307
+ return A.length > 0 && l.error(
1308
+ `messengerSession.initialize: missing required keys in userSessionInfo: ${A.join(", ")}`
1309
+ ), e;
1310
+ }
1311
+ const I = tt.get({ appId: n, aiAgentId: o });
1312
+ return I ? I.expireAt - ri <= Date.now() ? (l.debug("messengerSession.initialize: auto session expired, clear cache"), tt.clear({ appId: n, aiAgentId: o }), et.clear({ appId: n, aiAgentId: o, userId: I.userId }), null) : (l.debug("messengerSession.initialize: auto session info detected"), I) : null;
1313
+ }
1314
+ const te = P(
1315
+ (I, A) => {
1316
+ et.set({ appId: n, aiAgentId: o, userId: I }, { knownActiveChannelUrl: A });
1317
+ },
1318
+ [n, o]
1319
+ ), G = P(
1320
+ (I) => {
1321
+ const A = et.get({ appId: n, aiAgentId: o, userId: I });
1322
+ return A == null ? void 0 : A.knownActiveChannelUrl;
1323
+ },
1324
+ [n, o]
1325
+ ), Xe = P(async () => {
1326
+ if (w) {
1327
+ l.debug("messengerSession.refreshActiveChannel: try to refresh active channel"), f(void 0);
1328
+ const I = await i.aiAgent.requestMessengerSettings({
1329
+ aiAgentId: o,
1330
+ userId: w.userId,
1331
+ language: d,
1332
+ country: g,
1333
+ context: m,
1334
+ forceCreateChannel: E,
1335
+ knownActiveChannelUrl: G(w.userId)
1336
+ });
1337
+ return te(w.userId, I.active_channel.channel_url), f({ url: I.active_channel.channel_url, status: z.OPEN }), l.info(
1338
+ "messengerSession.refreshActiveChannel: refreshed active channel",
1339
+ I.active_channel.channel_url
1340
+ ), I.active_channel.channel_url;
1341
+ } else
1342
+ throw l.error("messengerSession.refreshActiveChannel: userSession is not ready"), new Error("userSession is not ready");
1343
+ }, [
1344
+ i,
1345
+ n,
1346
+ o,
1347
+ w == null ? void 0 : w.userId,
1348
+ d,
1349
+ g,
1350
+ m,
1351
+ E,
1352
+ G,
1353
+ te
1354
+ ]);
1355
+ return hn(i, {
1356
+ onChannelChanged: (I) => {
1357
+ var A;
1358
+ I.isGroupChannel() && I.url === (v == null ? void 0 : v.url) && (l.info("messengerSession.channelChanged: channel.conversation", I.conversation), f({ url: I.url, status: ((A = I.conversation) == null ? void 0 : A.status) ?? z.OPEN }));
1359
+ },
1360
+ async onUserJoined(I, A) {
1361
+ var j, fe;
1362
+ if (I.conversation && I.conversation.type === Ar.PROACTIVE && A.userId === ((j = i.currentUser) == null ? void 0 : j.userId)) {
1363
+ l.info("messengerSession.onUserJoined: proactive channel joined", I.url);
1364
+ const Se = ((fe = I.conversation) == null ? void 0 : fe.status) ?? z.OPEN;
1365
+ f({ url: I.url, status: Se }), a.setOpened(!0), si({
1366
+ sound: document.hidden || !a.opened
1367
+ });
1368
+ }
1369
+ }
1370
+ }), R(() => {
1371
+ async function I() {
1372
+ l.debug("messengerSession.initialize: start");
1373
+ const A = U(), L = await i.aiAgent.requestMessengerSettings({
1374
+ aiAgentId: o,
1375
+ userId: A == null ? void 0 : A.userId,
1376
+ language: d,
1377
+ country: g,
1378
+ context: m,
1379
+ forceCreateChannel: E,
1380
+ knownActiveChannelUrl: G(A == null ? void 0 : A.userId)
1381
+ });
1382
+ l.debug("messengerSession.initialize: messenger settings response", L);
1383
+ let j = null;
1384
+ if (L.auto_created_user) {
1385
+ const { user_id: K, session_token: ne, expire_at: we } = L.auto_created_user;
1386
+ tt.set({ appId: n, aiAgentId: o }, { userId: K, authToken: ne, expireAt: we }), j = { userId: K, authToken: ne };
1387
+ } else
1388
+ j = {
1389
+ userId: (A == null ? void 0 : A.userId) ?? "",
1390
+ authToken: (A == null ? void 0 : A.authToken) ?? ""
1391
+ };
1392
+ te(j.userId, L.active_channel.channel_url);
1393
+ function fe() {
1394
+ const K = L.appearance.selected_theme;
1395
+ h(K, (we) => {
1396
+ const ce = L.appearance.themes[we];
1397
+ return {
1398
+ primaryColor: ce.primary_color,
1399
+ botMessageBackgroundColor: ce.bot_message_bg_color,
1400
+ primaryContrastColor: ce.primary_contrast_color,
1401
+ botMessageBackgroundContrastColor: ce.bot_message_bg_contrast_color
1402
+ };
1403
+ }), _(void 0), O(j), H({
1404
+ userId: L.bot.bot_userid,
1405
+ profileUrl: L.bot.bot_profile_url,
1406
+ nickname: L.bot.bot_nickname,
1407
+ replyToFile: L.bot.reply_to_file,
1408
+ specialNotice: L.bot.special_notice,
1409
+ specialNoticeEnabled: L.bot.is_special_notice_enabled,
1410
+ showHandoffButton: L.bot.show_handoff_button ?? !0
1411
+ }), _e({
1412
+ type: L.launcher.image_type || "default_icon",
1413
+ imageUrl: L.launcher.image_url
1414
+ }), L.launcher.auto_open && !Le() && setTimeout(() => a.setOpened(!0), 500);
1415
+ }
1416
+ function Se() {
1417
+ f({ url: L.active_channel.channel_url, status: z.OPEN });
1418
+ }
1419
+ try {
1420
+ fe(), await b(j, e == null ? void 0 : e.sessionHandler), Se();
1421
+ } catch (K) {
1422
+ K instanceof Error && (l.error("messengerSession.initialize: failed to connect", K), _(K));
1423
+ }
1424
+ }
1425
+ I().catch((A) => {
1426
+ l.error("messengerSession: failed to initialize", A);
1427
+ });
1428
+ }, [i, n, o, e == null ? void 0 : e.userId, e == null ? void 0 : e.authToken]), R(() => {
1429
+ p != null && p.onRegisterDeauthenticateHandler && (l.debug("messengerSession: registering deauthenticate handler"), p.onRegisterDeauthenticateHandler(x));
1430
+ }, [p == null ? void 0 : p.onRegisterDeauthenticateHandler, x]), !w || !ee || !le ? null : /* @__PURE__ */ r.createElement(
1431
+ oi,
1432
+ {
1433
+ value: {
1434
+ userSession: w,
1435
+ activeChannel: v,
1436
+ refreshActiveChannel: Xe,
1437
+ connectionError: y,
1438
+ aiAgentInfo: { ...ee, ...s == null ? void 0 : s.bot },
1439
+ launcherInfo: { ...le, ...s == null ? void 0 : s.launcher }
1440
+ }
1441
+ },
1442
+ t
1443
+ );
1444
+ }
1445
+ function si({ sound: e }) {
1446
+ const t = "🔔You have received a new message", n = document.title, o = setInterval(() => {
1447
+ document.title = document.title === t ? n : t;
1448
+ }, 750);
1449
+ setTimeout(() => clearInterval(o), 5e3), e && import("./DP0MwObA.js").then((i) => {
1450
+ new Audio(i.default).play();
1451
+ });
1452
+ }
1453
+ const ai = ({ publishSynchronous: e = !1 }) => {
1454
+ const t = /* @__PURE__ */ new Set();
1455
+ return {
1456
+ publish: (n) => {
1457
+ t.forEach((o) => {
1458
+ e ? o(n) : setTimeout(() => o(n), 0);
1459
+ });
1460
+ },
1461
+ subscribe: (n) => (t.add(n), () => t.delete(n))
1462
+ };
1463
+ };
1464
+ function li(e, t = []) {
1465
+ const n = D(null), o = D(0), i = D(0), [s] = C(() => ai({ publishSynchronous: !0 })), [a, l] = C(!0);
1466
+ return ge(() => {
1467
+ o.current = 0, i.current = 0, l(!0), n.current && (n.current.scrollTop = n.current.scrollHeight);
1468
+ }, t), ge(() => s.subscribe(({ type: d, data: g }) => {
1469
+ const { resolve: m, animated: p } = g ?? {};
1470
+ if (!n.current) return m == null ? void 0 : m();
1471
+ if (d === "scrollToBottom" && (n.current.scroll ? n.current.scroll({
1472
+ top: n.current.scrollHeight,
1473
+ behavior: Ft(e, p)
1474
+ }) : n.current.scrollTop = n.current.scrollHeight, i.current = 0, l(!0), m == null || m()), d === "scroll") {
1475
+ const h = g == null ? void 0 : g.top, { scrollTop: b, scrollHeight: x, clientHeight: v } = n.current;
1476
+ n.current.scroll ? n.current.scroll({ top: h, behavior: Ft(e, p) }) : typeof h == "number" && (n.current.scrollTop = h), i.current = Math.max(0, x - b - v), l(i.current === 0), m == null || m();
1477
+ }
1478
+ }), [e]), {
1479
+ scrollRef: n,
1480
+ scrollPubSub: s,
1481
+ isScrollBottomReached: a,
1482
+ setIsScrollBottomReached: l,
1483
+ scrollDistanceFromBottomRef: i,
1484
+ scrollPositionRef: o
1485
+ };
1486
+ }
1487
+ function Ft(e, t) {
1488
+ return typeof t == "boolean" ? t ? "smooth" : "auto" : e;
1489
+ }
1490
+ function ci(e) {
1491
+ return new Promise((t) => {
1492
+ const n = new Image();
1493
+ n.onload = function() {
1494
+ const o = String(n.width), i = String(n.height);
1495
+ URL.revokeObjectURL(n.src), t({ width: o, height: i });
1496
+ }, n.src = URL.createObjectURL(e);
1497
+ });
1498
+ }
1499
+ async function di(e) {
1500
+ if ("file" in e && e.file instanceof File && e.file.type.startsWith("image/")) {
1501
+ const { width: t, height: n } = await ci(e.file);
1502
+ return new Or({
1503
+ key: Mn,
1504
+ value: [t, n]
1505
+ });
1506
+ }
1507
+ }
1508
+ const Mn = "KEY_IMG_ASPECT_RATIO", ui = ({ onScroll: e }) => {
1509
+ const { agentPreviewConfigs: t, handlers: n } = N(), o = D(t == null ? void 0 : t.agentAttributes);
1510
+ return o.current = t == null ? void 0 : t.agentAttributes, {
1511
+ onBeforeSendMessage: async (i) => {
1512
+ const s = await di(i), a = {
1513
+ ...i,
1514
+ metaArrays: s ? [s] : void 0
1515
+ }, l = mi(o.current);
1516
+ return l ? { ...a, data: JSON.stringify(l) } : a;
1517
+ },
1518
+ onAfterSendMessage: (i) => {
1519
+ var s;
1520
+ e(), (s = n == null ? void 0 : n.onMessageSend) == null || s.call(n, i.message);
1521
+ }
1522
+ };
1523
+ }, mi = (e) => {
1524
+ if (!e) return null;
1525
+ const t = {};
1526
+ return e.ai && Object.keys(e.ai).length > 0 && (t.ai_attrs = e.ai), e.safeguard && Object.keys(e.safeguard).length > 0 && (t.safeguard_attrs = e.safeguard), typeof e.use_prompt_cache == "boolean" && (t.use_prompt_cache = e.use_prompt_cache), Object.keys(t).length > 0 ? t : null;
1527
+ }, {
1528
+ Provider: gi,
1529
+ useContext: Y
1530
+ } = W("Conversation"), pi = ({
1531
+ closedChannelUrl: e,
1532
+ onClearClosedChannelUrl: t,
1533
+ onNavigateToConversationList: n,
1534
+ children: o
1535
+ }) => {
1536
+ const { activeChannel: i, refreshActiveChannel: s } = F(), a = li("smooth"), l = () => {
1537
+ setTimeout(() => a.scrollPubSub.publish({ type: "scrollToBottom" }), 25);
1538
+ }, { onBeforeSendMessage: d, onAfterSendMessage: g } = ui({ onScroll: l }), m = P(async () => {
1539
+ await s(), e && (t == null || t());
1540
+ }, [s, e, t]);
1541
+ return /* @__PURE__ */ r.createElement(
1542
+ Qr,
1543
+ {
1544
+ channelUrl: e || (i == null ? void 0 : i.url),
1545
+ onBeforeSendMessage: d,
1546
+ onAfterSendMessage: g,
1547
+ onMessagesUpdated: l,
1548
+ onChannelDeleted: m,
1549
+ onConversationClosedViaDispatcher: m
1550
+ },
1551
+ (p) => /* @__PURE__ */ r.createElement(
1552
+ gi,
1553
+ {
1554
+ value: { ...p, scrollSource: a, goToActiveConversation: m, onNavigateToConversationList: n }
1555
+ },
1556
+ o
1557
+ )
1558
+ );
1559
+ };
1560
+ function Ge() {
1561
+ }
1562
+ async function On(e) {
1563
+ let t = e;
1564
+ t && (!t.startsWith("http://") && !t.startsWith("https://") && (t = "https://" + t), window.open(t, "_blank", "noopener,noreferrer"));
1565
+ }
1566
+ function Ht(e) {
1567
+ try {
1568
+ return JSON.parse(e === "" ? "{}" : e);
1569
+ } catch {
1570
+ return {};
1571
+ }
1572
+ }
1573
+ function Ln(e) {
1574
+ return !e || !e.conversation ? !1 : e.conversation.status === z.CLOSED;
1575
+ }
1576
+ function Rn(e) {
1577
+ return !e || !e.conversation ? !1 : e.conversation.status === z.OPEN;
1578
+ }
1579
+ function hi(e) {
1580
+ var o;
1581
+ const t = (o = e == null ? void 0 : e.conversation) == null ? void 0 : o.handoff, n = !!(t != null && t.timestamp);
1582
+ return Rn(e) && !n;
1583
+ }
1584
+ const ft = ye({
1585
+ onDrop: Ge,
1586
+ subscribe: () => Ge
1587
+ }), lt = ({ children: e }) => {
1588
+ const t = D(/* @__PURE__ */ new Set());
1589
+ return /* @__PURE__ */ r.createElement(
1590
+ ft.Provider,
1591
+ {
1592
+ value: {
1593
+ onDrop: (n) => {
1594
+ var o;
1595
+ if (n.preventDefault(), (o = n.dataTransfer) != null && o.files) {
1596
+ const i = Array.from(n.dataTransfer.files);
1597
+ i.length > 0 && t.current.forEach((s) => s(i));
1598
+ }
1599
+ },
1600
+ subscribe: (n) => (t.current.add(n), () => t.current.delete(n))
1601
+ }
1602
+ },
1603
+ e
1604
+ );
1605
+ }, fi = ({ onDropFiles: e }) => {
1606
+ const { subscribe: t } = J(ft);
1607
+ R(() => t(e), [e]);
1608
+ };
1609
+ lt.Consumer = ({ children: e }) => {
1610
+ const { onDrop: t } = J(ft);
1611
+ return e({ onDrop: t, onDragOver: (i) => i.preventDefault() });
1612
+ };
1613
+ const se = (e) => {
1614
+ const t = e;
1615
+ return typeof t == "number" ? `${t}px` : t;
1616
+ }, bi = /* @__PURE__ */ new Set(["send", "chat", "message", "chevron-right"]), xi = {
1617
+ spinner: T(() => import("./BcUGcaq2.js")),
1618
+ chat: T(() => import("./DcFCGVBm.js")),
1619
+ message: T(() => import("./DsGXnanX.js")),
1620
+ error: T(() => import("./B6fvrWGq.js")),
1621
+ info: T(() => import("./CAIYsKDy.js")),
1622
+ refresh: T(() => import("./B6xd54zt.js")),
1623
+ "chevron-down": T(() => import("./BsimU71m.js")),
1624
+ "chevron-right": T(() => import("./NmJl7zv3.js")),
1625
+ done: T(() => import("./D_q6g3Dd.js")),
1626
+ user: T(() => import("./CvqfQEhO.js")),
1627
+ "file-document": T(() => import("./BAr50pfO.js")),
1628
+ download: T(() => import("./B2CtcWp3.js")),
1629
+ attach: T(() => import("./DY2ULcTX.js")),
1630
+ delete: T(() => import("./DMruRpOm.js")),
1631
+ close: T(() => import("./CuaBI7kd.js")),
1632
+ "close-filled": T(() => import("./CxQFWLnW.js")),
1633
+ send: T(() => import("./DZJyDpNp.js")),
1634
+ menu: T(() => import("./BUYabNz7.js")),
1635
+ expand: T(() => import("./wBtIAuNm.js")),
1636
+ collapse: T(() => import("./C0RFfifL.js")),
1637
+ agent: T(() => import("./Cc7XmLN1.js")),
1638
+ question: T(() => import("./dqwvRBog.js")),
1639
+ actionbook: T(() => import("./CrjNuryZ.js")),
1640
+ function: T(() => import("./CvdSjw1c.js")),
1641
+ "radio-on": T(() => import("./nmdo2Fbj.js")),
1642
+ "radio-off": T(() => import("./BnZcRFmS.js")),
1643
+ confluence: T(() => import("./BOnlh2zd.js")),
1644
+ zendesk: T(() => import("./BAJ6LEKc.js")),
1645
+ salesforce: T(() => import("./CT2kv4lr.js")),
1646
+ sprinklr: T(() => import("./m2INcyV2.js")),
1647
+ website: T(() => import("./BgGVGNdg.js")),
1648
+ snippet: T(() => import("./BFcXPuf5.js")),
1649
+ template: T(() => import("./awO7aBCv.js"))
1650
+ }, $ = ({ type: e, size: t = 24, className: n, color: o }) => {
1651
+ const i = xi[e];
1652
+ return /* @__PURE__ */ r.createElement(
1653
+ vi,
1654
+ {
1655
+ className: n,
1656
+ $rtlFlip: bi.has(e),
1657
+ $size: t,
1658
+ $color: o ?? u.color.primary.main
1659
+ },
1660
+ /* @__PURE__ */ r.createElement($e, { fallback: null }, /* @__PURE__ */ r.createElement(i, null))
1661
+ );
1662
+ }, Ei = k`[dir='rtl'] &{transform:scaleX(-1);}`, vi = c.div`width:${({ $size: e }) => se(e)};height:${({ $size: e }) => se(e)};display:inline-block;&:focus{outline:none;}svg{display:block;}[class*='fill']{fill:${({ $color: e }) => e};}[class*='stroke']{stroke:${({ $color: e }) => e};stroke-width:2px;stroke-linejoin:round;}${({ $rtlFlip: e }) => e && Ei};`, S = ({
1663
+ as: e,
1664
+ variant: t = "body1",
1665
+ color: n,
1666
+ className: o,
1667
+ ...i
1668
+ }) => /* @__PURE__ */ r.createElement(Ci, { as: e, $variant: t, className: o, $color: n, ...i }), Ut = /* @__PURE__ */ new WeakMap(), yi = (e, t) => {
1669
+ let n = Ut.get(t);
1670
+ n || (n = /* @__PURE__ */ new Map(), Ut.set(t, n));
1671
+ const o = n.get(e);
1672
+ if (o) return o;
1673
+ const i = t[e] ?? t.body1, s = k`font-size:${se(i.fontSize)};font-weight:${i.fontWeight};${i.fontFamily ? `font-family: ${i.fontFamily};` : ""}
1674
+ `;
1675
+ return n.set(e, s), s;
1676
+ }, Ci = c.span`font-stretch:normal;font-style:normal;letter-spacing:normal;line-height:100%;${({ $variant: e, theme: t }) => yi(e, t.typography)}color:${({ $color: e }) => e};`, $d = ({ iconSize: e = 64, icon: t, className: n, label: o, children: i }) => /* @__PURE__ */ r.createElement(_i, { className: n }, /* @__PURE__ */ r.createElement($, { type: t, size: e, color: u.themedColor.textLowEmphasis }), /* @__PURE__ */ r.createElement(S, { variant: "body1", color: u.themedColor.textMidEmphasis }, o), i), Ti = c.div`position:relative;display:flex;justify-content:center;align-items:center;width:100%;height:100%;`, _i = c.div`display:flex;flex-direction:column;min-height:104px;align-items:center;gap:20px;text-align:center;`, Si = {
1677
+ loading: T(() => import("./xCNPjZNB.js")),
1678
+ error: T(() => import("./Cfv5QpcS.js")),
1679
+ noChannels: T(() => import("./BdwtEHgL.js")),
1680
+ noMessages: T(() => import("./CXSnn4qx.js"))
1681
+ }, Ee = ({ className: e, type: t = "loading", ...n }) => {
1682
+ const o = Si[t];
1683
+ return /* @__PURE__ */ r.createElement(Ti, { className: e }, /* @__PURE__ */ r.createElement($e, { fallback: null }, /* @__PURE__ */ r.createElement(o, { ...n })));
1684
+ }, Re = 244, Nn = 640, je = 26, Dn = 4, Q = 12, Te = 2, wi = 16, ae = `${Z}-incoming-msg`, ki = `${Z}-marked-text`;
1685
+ function bt(e) {
1686
+ switch (e) {
1687
+ case "top":
1688
+ case "middle":
1689
+ return Te;
1690
+ default:
1691
+ return wi;
1692
+ }
1693
+ }
1694
+ function xt(e, t) {
1695
+ if (t) {
1696
+ const [, n] = t.split("/");
1697
+ if (n)
1698
+ return n.toUpperCase();
1699
+ }
1700
+ if (e && !e.startsWith(".")) {
1701
+ const n = e.split(".").pop();
1702
+ if (n && n !== e)
1703
+ return n.toUpperCase();
1704
+ }
1705
+ return "FILE";
1706
+ }
1707
+ function Bn(e) {
1708
+ return e.messageType === "file" ? e.message.length > 0 && e.file.name !== e.message : e.message.length > 0;
1709
+ }
1710
+ function Et({
1711
+ name: e,
1712
+ type: t = "FILE",
1713
+ iconColor: n,
1714
+ iconBackgroundColor: o,
1715
+ onClick: i
1716
+ }) {
1717
+ const { colors: s } = ut();
1718
+ return /* @__PURE__ */ r.createElement(Ai, { onClick: i, $clickable: !!i }, /* @__PURE__ */ r.createElement($i, { $bgColor: o ?? s.base.primary }, /* @__PURE__ */ r.createElement($, { type: "file-document", size: 24, color: n ?? s.base.primaryContrastContent })), /* @__PURE__ */ r.createElement(Mi, null, /* @__PURE__ */ r.createElement(Oi, { variant: "button", color: u.themedColor.textHighEmphasis }, e), /* @__PURE__ */ r.createElement(S, { color: u.themedColor.textMidEmphasis, variant: "caption3" }, t)));
1719
+ }
1720
+ const Ai = c.div`border-radius:12px;gap:8px;width:${Re}px;height:64px;display:flex;align-items:center;padding:12px;box-sizing:border-box;border:1px solid ${u.themedColor.textDisabled};background-color:${u.themedColor.bg_50_600};${({ $clickable: e }) => e && Ii}`, Ii = k`cursor:pointer;&:hover{background-color:${u.themedColor.bg_100_500};}`, $i = c.div`border-radius:8px;width:40px;height:40px;display:flex;align-items:center;justify-content:center;background-color:${({ $bgColor: e }) => e};`, Mi = c.div`display:flex;flex:1;flex-direction:column;gap:4px;min-width:0;`, Oi = c(S)`text-overflow:ellipsis;white-space:nowrap;overflow:hidden;`;
1721
+ function Li({ file: e, children: t, onClickFile: n }) {
1722
+ return /* @__PURE__ */ r.createElement(Ri, null, /* @__PURE__ */ r.createElement(
1723
+ Et,
1724
+ {
1725
+ name: e.name,
1726
+ type: xt(e.name, e.type),
1727
+ onClick: n && (() => n == null ? void 0 : n(e))
1728
+ }
1729
+ ), t);
1730
+ }
1731
+ const Ri = c.div`display:flex;flex-direction:column;align-items:flex-start;gap:${Te}px;`;
1732
+ function Ni({ file: e, onClickMedia: t, children: n }) {
1733
+ const o = () => e.type.startsWith("image") ? /* @__PURE__ */ r.createElement(Pi, { src: e.url, alt: "image-message" }) : e.type.startsWith("video") ? /* @__PURE__ */ r.createElement(Fi, { controls: !0 }, /* @__PURE__ */ r.createElement("source", { src: e.url }), /* @__PURE__ */ r.createElement("track", { kind: "captions" })) : null;
1734
+ if (o) {
1735
+ const i = {
1736
+ id: `${ae}-media-body`,
1737
+ onClick: () => t == null ? void 0 : t(e)
1738
+ };
1739
+ return /* @__PURE__ */ r.createElement(Di, null, /* @__PURE__ */ r.createElement(Bi, { ...i }, o()), n);
1740
+ }
1741
+ return null;
1742
+ }
1743
+ const Di = c.div`display:flex;flex-direction:column;align-items:flex-start;gap:${Te}px;`, Bi = c.div`width:${Re}px;height:160px;border-radius:12px;overflow:hidden;cursor:pointer;${B.light`
1744
+ background-color: ${u.color.background100};
1745
+ `}
1746
+ ${B.dark`
1747
+ background-color: ${u.color.background400};
1748
+ `}
1749
+ `, Pi = c.img`width:100%;height:100%;object-fit:cover;`, Fi = c.video`width:100%;height:100%;object-fit:cover;`, Hi = "✱";
1750
+ function Pn(e) {
1751
+ const t = new RegExp(`${Hi}+`, "g");
1752
+ return e.replace(t, (n) => `<span id=${ki} aria-label="masked-text">${n}</span>`);
1753
+ }
1754
+ function Ui(e) {
1755
+ const t = /```(\w+)?\n([\s\S]*?)```/g, n = [];
1756
+ let o = 0;
1757
+ return e.replace(t, (i, ...s) => {
1758
+ const [a, l, d] = s;
1759
+ return o < d && n.push({
1760
+ type: "text",
1761
+ value: e.slice(o, d).trim()
1762
+ }), n.push({
1763
+ type: "code",
1764
+ value: l.trim(),
1765
+ language: a ? a.trim() : "plaintext"
1766
+ }), o = d + i.length, i;
1767
+ }), o < e.length && n.push({
1768
+ type: "text",
1769
+ value: e.slice(o).trim()
1770
+ }), n.map((i) => i.type !== "text" ? i : { ...i, value: Pn(i.value) });
1771
+ }
1772
+ const zi = T(async () => ({ default: (await import("./BvhxxGUf.js")).MarkdownText })), Wi = T(async () => ({ default: (await import("./DH2PekOm.js")).CodeBlock }));
1773
+ function zt(e) {
1774
+ var i, s;
1775
+ const t = e.maxBodyWidth ?? Re, n = Ie(() => Ui(e.message), [e.message]), o = {
1776
+ id: `${ae}-text-body`,
1777
+ $maxWidth: t,
1778
+ $color: (i = e.customStyle) == null ? void 0 : i.bubbleContentColor,
1779
+ $bgColor: (s = e.customStyle) == null ? void 0 : s.bubbleBackgroundColor
1780
+ };
1781
+ return n.length === 0 ? e.children ? /* @__PURE__ */ r.createElement(Wt, { ...o }, e.children) : null : /* @__PURE__ */ r.createElement(Wt, { ...o }, n.map((a, l) => a.type === "text" ? /* @__PURE__ */ r.createElement(Vt, { key: l, variant: "body3" }, /* @__PURE__ */ r.createElement($e, { fallback: a.value }, /* @__PURE__ */ r.createElement(zi, null, a.value))) : a.type === "code" ? /* @__PURE__ */ r.createElement($e, { key: l, fallback: /* @__PURE__ */ r.createElement(Vt, { variant: "body3" }, a.value) }, /* @__PURE__ */ r.createElement(Wi, { code: a.value, language: a.language })) : null), e.children);
1782
+ }
1783
+ const Wt = c.div`display:flex;flex-direction:column;border-radius:12px;overflow:hidden;max-width:${({ $maxWidth: e }) => e}px;${({ theme: e, $color: t, $bgColor: n }) => k`
1784
+ color: ${t || e.colors.messageIncoming.text};
1785
+ background-color: ${n || e.colors.messageIncoming.background};
1786
+ `}
1787
+ padding: 12px 0;
1788
+ transition: max-width 0.3s;
1789
+ overflow-wrap: break-word;
1790
+ `, Vt = c(S)`align-items:flex-start;line-height:18px;white-space:pre-wrap;padding:0 12px;`;
1791
+ function Vi(e) {
1792
+ const { stringSet: t } = M(), n = Bn(e) ? /* @__PURE__ */ r.createElement(zt, { ...e }) : null;
1793
+ if (e.messageType === "user")
1794
+ return n;
1795
+ if (e.messageType === "file") {
1796
+ const o = e.file;
1797
+ return o.type.startsWith("image") || o.type.startsWith("video") ? /* @__PURE__ */ r.createElement(Ni, { ...e }, n) : /* @__PURE__ */ r.createElement(Li, { ...e }, n);
1798
+ }
1799
+ return /* @__PURE__ */ r.createElement(zt, { ...e, message: t.UNKNOWN__UNKNOWN_MESSAGE_TYPE });
1800
+ }
1801
+ const vt = (e) => /* @__PURE__ */ r.createElement("svg", { width: 24, height: 24, viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...e }, /* @__PURE__ */ r.createElement("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M12.0008 0.973633C10.6172 0.973633 9.49558 2.09527 9.49558 3.47888C9.49558 4.50705 10.115 5.39055 11.0009 5.77664V7.47887H13.0009V5.77653C13.8868 5.3904 14.5061 4.50696 14.5061 3.47888C14.5061 2.09527 13.3844 0.973633 12.0008 0.973633ZM0.250977 16.5788L0.250977 10.5789H2.25098L2.25098 16.5788H0.250977ZM21.7511 10.5789V16.5788H23.7511V10.5789H21.7511ZM18.251 7.47888H3.25097V18.9789C3.25097 20.3596 4.37026 21.4789 5.75097 21.4789H18.251C19.6317 21.4789 20.751 20.3596 20.751 18.9789V9.97887C20.751 8.59816 19.6317 7.47888 18.251 7.47888ZM9.78434 11.9539V15.2038C9.78434 15.7561 9.33663 16.2038 8.78434 16.2038C8.23206 16.2038 7.78434 15.7561 7.78434 15.2038V11.9539C7.78434 11.4016 8.23206 10.9539 8.78434 10.9539C9.33663 10.9539 9.78434 11.4016 9.78434 11.9539ZM16.2677 11.9539V15.2038C16.2677 15.7561 15.82 16.2038 15.2677 16.2038C14.7154 16.2038 14.2677 15.7561 14.2677 15.2038V11.9539C14.2677 11.4016 14.7154 10.9539 15.2677 10.9539C15.82 10.9539 16.2677 11.4016 16.2677 11.9539Z", fill: "#0D0D0D" }));
1802
+ function yt({ id: e, src: t, size: n = 56, onClick: o, style: i }) {
1803
+ return /* @__PURE__ */ r.createElement(Gi, { id: e, tabIndex: 0, onClick: o, $size: se(n), style: i }, t ? /* @__PURE__ */ r.createElement(ji, { src: t }) : /* @__PURE__ */ r.createElement($, { type: "user", size: n }));
1804
+ }
1805
+ const Gi = c.div`border-radius:50%;display:inline-block;overflow:hidden;position:relative;flex-shrink:0;height:${(e) => e.$size};width:${(e) => e.$size};background-color:${u.themedColor.bg_100_500};&:focus{outline:none;}`, ji = c.img`object-fit:cover;width:100%;height:100%;position:absolute;`;
1806
+ function Ki({ sender: e, isBotMessage: t }) {
1807
+ const n = `${ae}-sender-avatar`;
1808
+ return !e.profileUrl && t ? /* @__PURE__ */ r.createElement(Zi, { id: n }, /* @__PURE__ */ r.createElement(vt, null)) : /* @__PURE__ */ r.createElement(yt, { id: n, size: je, src: e.profileUrl });
1809
+ }
1810
+ const Zi = c.div`flex-shrink:0;width:${je}px;height:${je}px;box-sizing:border-box;padding:6px;border-radius:50%;display:flex;justify-content:center;align-items:center;background-color:${({ theme: e }) => e.colors.base.primary};path{fill:${({ theme: e }) => e.colors.base.primaryContrastContent};}}`;
1811
+ function Yi({ sender: e }) {
1812
+ return /* @__PURE__ */ r.createElement(qi, { id: `${ae}-sender-name`, variant: "caption1", color: u.themedColor.textMidEmphasis }, e.nickname);
1813
+ }
1814
+ const qi = c(S)`text-align:start;width:100%;box-sizing:border-box;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;padding-block:5px;padding-inline:0 7px;`;
1815
+ function Ji({ createdAt: e }) {
1816
+ const { stringSet: t, format: n } = M();
1817
+ return e ? /* @__PURE__ */ r.createElement(S, { id: `${ae}-sent-time`, variant: "caption4", color: u.themedColor.textLowEmphasis }, n(e, t.DATE_FORMAT__MESSAGE_TIMESTAMP)) : null;
1818
+ }
1819
+ function Xi({ customStyle: e }) {
1820
+ return /* @__PURE__ */ r.createElement(Qi, { $bgColor: e == null ? void 0 : e.bubbleBackgroundColor }, [0, 1, 2].map((t) => /* @__PURE__ */ r.createElement(es, { key: t, $color: e == null ? void 0 : e.bubbleContentColor })));
1821
+ }
1822
+ const Qi = c.div`align-items:center;border-radius:12px;display:flex;gap:6px;justify-content:center;padding:16px 12px;background-color:${({ theme: e, $bgColor: t }) => t || e.colors.messageIncoming.background};`, es = c.span`animation:blink 1.4s infinite;animation-fill-mode:both;border-radius:50%;height:8px;width:8px;background:${({ theme: e, $color: t }) => t || e.colors.messageIncoming.text};@keyframes blink{0%{opacity:0.12;transform:scale(1);}21.43%{opacity:0.38;transform:scale(1.2);}42.86%{opacity:0.12;transform:scale(1);}100%{opacity:0.12;transform:scale(1);}}&:nth-child(1){animation-delay:0.4s;}&:nth-child(2){animation-delay:0.6s;}&:nth-child(3){animation-delay:0.8s;}`;
1823
+ function ts({
1824
+ extendedMessagePayload: e,
1825
+ onClickCTA: t = ({ url: n }) => On(n)
1826
+ }) {
1827
+ const n = e == null ? void 0 : e.cta_button;
1828
+ return n ? /* @__PURE__ */ r.createElement(ns, { id: `${ae}-ext-cta-button`, role: "button", onClick: () => t(n) }, /* @__PURE__ */ r.createElement(rs, { variant: "button" }, n.label)) : null;
1829
+ }
1830
+ const ns = c.div`display:flex;align-items:center;justify-content:center;cursor:pointer;border-radius:6px;padding:8px;background-color:${u.color.primary.main};color:${({ theme: e }) => e.colors.base.primaryContrastContent};&:hover{background-color:${u.color.primary.dark};}`, rs = c(S)`overflow:hidden;text-overflow:ellipsis;white-space:nowrap;`;
1831
+ function os(e) {
1832
+ return /* @__PURE__ */ r.createElement(r.Fragment, null);
1833
+ }
1834
+ class is extends ur {
1835
+ constructor(t) {
1836
+ super(t), this.state = {
1837
+ hasError: !1
1838
+ };
1839
+ }
1840
+ static getDerivedStateFromError() {
1841
+ return { hasError: !0 };
1842
+ }
1843
+ render() {
1844
+ return this.state.hasError ? this.props.errorFallback : /* @__PURE__ */ r.createElement($e, { fallback: this.props.loadingFallback }, this.props.children);
1845
+ }
1846
+ }
1847
+ const ss = /* @__PURE__ */ new Set(["default"]), { MessageTemplate: as } = Pr({
1848
+ parser: Dr,
1849
+ renderer: Nr,
1850
+ Container: (e) => /* @__PURE__ */ r.createElement("div", { ...e })
1851
+ });
1852
+ function ls(e) {
1853
+ return /* @__PURE__ */ r.createElement(
1854
+ is,
1855
+ {
1856
+ errorFallback: e.messageTemplateErrorFallback,
1857
+ loadingFallback: e.messageTemplateLoadingFallback
1858
+ },
1859
+ /* @__PURE__ */ r.createElement(cs, { ...e })
1860
+ );
1861
+ }
1862
+ const cs = ({
1863
+ extendedMessagePayload: e,
1864
+ onGetCachedMessageTemplate: t = () => null,
1865
+ onRequestMessageTemplate: n
1866
+ }) => {
1867
+ const o = e == null ? void 0 : e.message_template;
1868
+ if (!ss.has((o == null ? void 0 : o.type) ?? "default")) throw new Error("Unsupported template type");
1869
+ if (!n) throw new Error("onRequestMessageTemplate is required");
1870
+ const { theme: s } = Go(), a = Mo({
1871
+ onRequestTemplate: n,
1872
+ onGetCachedTemplate: t,
1873
+ theme: s.selectedTheme,
1874
+ templateKey: (o == null ? void 0 : o.key) ?? "invalid",
1875
+ variables: o == null ? void 0 : o.variables,
1876
+ viewVariables: o == null ? void 0 : o.view_variables,
1877
+ aiAgentColorVariables: s.aiAgentColorVariables
1878
+ });
1879
+ return /* @__PURE__ */ r.createElement(ds, { id: `${ae}-ext-message-template` }, /* @__PURE__ */ r.createElement(Br, { message: {} }, /* @__PURE__ */ r.createElement(as, { templateItems: a.body.items, templateVersion: a.version })));
1880
+ }, ds = c.div`box-sizing:border-box;overflow:hidden;width:100%;`;
1881
+ function us({
1882
+ extendedMessagePayload: e,
1883
+ onClickSuggestedReply: t,
1884
+ suggestedRepliesDirection: n = "vertical"
1885
+ }) {
1886
+ const [o, i] = C(!1), s = (e == null ? void 0 : e.suggested_replies) ?? [];
1887
+ return s.length === 0 || o ? null : /* @__PURE__ */ r.createElement(ms, { id: `${ae}-ext-suggested-replies`, $type: n }, s.map((a, l) => /* @__PURE__ */ r.createElement(
1888
+ gs,
1889
+ {
1890
+ key: l,
1891
+ $type: n,
1892
+ variant: "body3",
1893
+ onClick: () => {
1894
+ t && (t == null || t({ reply: a }), i(!0));
1895
+ }
1896
+ },
1897
+ a
1898
+ )));
1899
+ }
1900
+ const ms = c.div`margin:16px 0;padding:0 ${Q}px;position:relative;display:flex;gap:8px;${({ $type: e }) => e === "vertical" ? ps : hs};`, gs = c(S)`box-sizing:border-box;padding:8px 12px;display:flex;align-items:center;border-radius:100px;cursor:pointer;word-break:break-word;color:${u.color.primary.main};border:1px solid ${u.color.primary.main};background-color:${u.themedColor.bg_50_600};&:hover{background-color:${u.themedColor.bg_100_500};}${({ $type: e, theme: t }) => k`
1901
+ ${e === "vertical" ? fs : bs};
1902
+ &:active {
1903
+ background-color: ${t.colors.base.primary};
1904
+ color: ${t.colors.base.primaryContrastContent};
1905
+ }
1906
+ `}
1907
+ `, ps = k`flex-direction:column;align-items:flex-end;`, hs = k`flex-direction:row;overflow-x:scroll;-ms-overflow-style:none;scrollbar-width:none;&::-webkit-scrollbar{display:none;}`, fs = k`max-width:calc(100% - 70px);white-space:pre-wrap;`, bs = k`white-space:nowrap;`;
1908
+ function Ct(e) {
1909
+ return e();
1910
+ }
1911
+ const ve = Ce({
1912
+ template: xs,
1913
+ components: {
1914
+ SenderName: Yi,
1915
+ SenderAvatar: Ki,
1916
+ SentTime: Ji,
1917
+ MessageBody: Vi,
1918
+ TypingIndicator: Xi,
1919
+ SuggestedReplies: us,
1920
+ MessageTemplate: ls,
1921
+ CTAButton: ts,
1922
+ MessageLogs: os
1923
+ }
1924
+ });
1925
+ function xs(e) {
1926
+ return /* @__PURE__ */ r.createElement(Fn, { ...e, testerMode: !1 });
1927
+ }
1928
+ function Fn(e) {
1929
+ var p, h, b, x;
1930
+ const { components: t } = ve.useContext(), n = !!e.isTyping, o = e.testerMode, i = !!((p = e.extendedMessagePayload) != null && p.message_template), s = !!((h = e.extendedMessagePayload) != null && h.cta_button), a = !!e.createdAt, l = Ct(() => e.messageType === "user" ? e.message.length > 0 : !0), d = e.groupType === "top" || e.groupType === "single", g = e.groupType === "bottom" || e.groupType === "single", m = o ? 0 : je;
1931
+ return /* @__PURE__ */ r.createElement(Es, { $marginBottom: n ? 0 : bt(e.groupType) }, d && /* @__PURE__ */ r.createElement(vs, null, !o && /* @__PURE__ */ r.createElement(t.SenderAvatar, { ...e }), /* @__PURE__ */ r.createElement(t.SenderName, { ...e })), /* @__PURE__ */ r.createElement(Lt, null, /* @__PURE__ */ r.createElement(nt, { $extraStartPadding: m }, n && /* @__PURE__ */ r.createElement(t.TypingIndicator, { ...e }), /* @__PURE__ */ r.createElement(t.MessageBody, { ...e }, s && /* @__PURE__ */ r.createElement("div", { style: { marginTop: 12, marginInline: 12 } }, /* @__PURE__ */ r.createElement(t.CTAButton, { ...e })))), i && /* @__PURE__ */ r.createElement(Gt, { $startPadding: 0, $endPadding: 0, style: { marginTop: l ? Te : 0 } }, /* @__PURE__ */ r.createElement(
1932
+ t.MessageTemplate,
1933
+ {
1934
+ ...e,
1935
+ messageTemplateErrorFallback: e.messageTemplateErrorFallback ?? /* @__PURE__ */ r.createElement(nt, { $extraStartPadding: m }, /* @__PURE__ */ r.createElement(
1936
+ t.MessageBody,
1937
+ {
1938
+ ...e,
1939
+ messageType: "user",
1940
+ message: ((x = (b = e.extendedMessagePayload) == null ? void 0 : b.message_template) == null ? void 0 : x.fallback_message) ?? "Cannot read this template."
1941
+ }
1942
+ )),
1943
+ messageTemplateLoadingFallback: e.messageTemplateLoadingFallback ?? /* @__PURE__ */ r.createElement(nt, { $extraStartPadding: m }, /* @__PURE__ */ r.createElement(t.TypingIndicator, { ...e }))
1944
+ }
1945
+ ))), g && a && /* @__PURE__ */ r.createElement(ys, { $extraStartPadding: m + 8 }, /* @__PURE__ */ r.createElement(t.SentTime, { ...e })), /* @__PURE__ */ r.createElement(Lt, null, e.suggestedRepliesVisible && /* @__PURE__ */ r.createElement(Gt, null, /* @__PURE__ */ r.createElement(t.SuggestedReplies, { ...e })), /* @__PURE__ */ r.createElement(t.MessageLogs, { ...e })));
1946
+ }
1947
+ const Es = c.div`display:flex;flex-direction:column;align-items:flex-start;margin-bottom:${({ $marginBottom: e }) => `${e}px`};
1948
+ `, Je = c.div`display:flex;align-self:stretch;justify-content:flex-start;${({ $startPadding: e = Q, $endPadding: t = Q, $extraStartPadding: n = 0 }) => `
1949
+ padding-inline: ${e + n}px ${t}px;
1950
+ `}
1951
+ `, vs = c(Je)`display:flex;flex-direction:row;align-items:center;gap:8px;`, nt = c(Je)`display:flex;`, ys = c(Je)`margin-top:${Dn}px;display:flex;align-items:flex-start;justify-content:flex-start;`, Gt = c(Je)`display:flex;flex-direction:column;${({ $startPadding: e = Q, $endPadding: t = Q, $extraStartPadding: n = 0 }) => `
1952
+ padding-inline: ${e + n}px ${t}px;
1953
+ `}
1954
+ `;
1955
+ function Cs({ file: e, children: t, onClickFile: n }) {
1956
+ return /* @__PURE__ */ r.createElement(Ts, null, /* @__PURE__ */ r.createElement(
1957
+ Et,
1958
+ {
1959
+ name: e.name,
1960
+ type: xt(e.name, e.type),
1961
+ onClick: n && (() => n == null ? void 0 : n(e))
1962
+ }
1963
+ ), t);
1964
+ }
1965
+ const Ts = c.div`display:flex;flex-direction:column;align-items:flex-end;gap:${Te}px;`, Hn = ({ className: e, children: t, size: n = 26 }) => /* @__PURE__ */ r.createElement(_s, { className: e, $size: n }, t ?? /* @__PURE__ */ r.createElement($, { type: "spinner", size: n })), _s = c.div`display:flex;align-items:center;justify-content:center;width:${({ $size: e }) => se(e)};height:${({ $size: e }) => se(e)};animation:1s infinite linear;animation-name:rotate;@keyframes rotate{from{transform:rotate(0);}to{transform:rotate(360deg);}}`;
1966
+ function Ss({ file: e, metadata: t, onClickMedia: n, children: o }) {
1967
+ const { aspectRatio: i, localFile: s } = t, [a] = C(() => s instanceof File ? URL.createObjectURL(s) : e.url), [l, d] = C(!1), g = {
1968
+ onClick: () => n == null ? void 0 : n(e),
1969
+ $ratio: i
1970
+ };
1971
+ return /* @__PURE__ */ r.createElement(ws, null, /* @__PURE__ */ r.createElement(ks, { ...g }, !l && /* @__PURE__ */ r.createElement(Hn, { size: 26 }, /* @__PURE__ */ r.createElement($, { type: "spinner", color: "textLowEmphasis", size: 26 })), /* @__PURE__ */ r.createElement(As, { $loaded: l, src: a, alt: "image-message", onLoad: () => d(!0) })), o);
1972
+ }
1973
+ const ws = c.div`display:flex;flex-direction:column;align-items:flex-end;gap:${Te}px;`, ks = c.div`width:${Re}px;border-radius:12px;overflow:hidden;cursor:pointer;height:auto;aspect-ratio:${(e) => e.$ratio};position:relative;display:flex;align-items:center;justify-content:center;${B.light`
1974
+ background-color: ${u.color.background100};
1975
+ `}
1976
+ ${B.dark`
1977
+ background-color: ${u.color.background400};
1978
+ `}
1979
+ `, As = c.img`position:absolute;width:100%;height:100%;inset-block-start:0;inset-inline-start:0;object-fit:cover;opacity:${(e) => e.$loaded ? 1 : 0};transition:opacity 0.5s ease;`;
1980
+ function jt(e) {
1981
+ var n, o;
1982
+ const t = Ie(() => fn.sanitize(Pn(e.message)), [e.message]);
1983
+ return /* @__PURE__ */ r.createElement(
1984
+ Is,
1985
+ {
1986
+ $maxWidth: e.maxBodyWidth ?? Re,
1987
+ $color: (n = e.customStyle) == null ? void 0 : n.bubbleContentColor,
1988
+ $bgColor: (o = e.customStyle) == null ? void 0 : o.bubbleBackgroundColor
1989
+ },
1990
+ /* @__PURE__ */ r.createElement($s, { variant: "body3", dangerouslySetInnerHTML: { __html: t } })
1991
+ );
1992
+ }
1993
+ const Is = c.div`display:flex;flex-direction:column;border-radius:12px;overflow:hidden;max-width:${({ $maxWidth: e }) => e}px;${({ theme: e, $color: t, $bgColor: n }) => k`
1994
+ color: ${t || e.colors.messageOutgoing.text};
1995
+ background-color: ${n || e.colors.messageOutgoing.background};
1996
+ `}
1997
+ padding: 12px 0;
1998
+ transition: max-width 0.3s;
1999
+ overflow-wrap: break-word;
2000
+ `, $s = c(S)`align-items:flex-start;line-height:18px;white-space:pre-wrap;padding:0 12px;`;
2001
+ function Ms(e) {
2002
+ const { stringSet: t } = M(), n = Bn(e) ? /* @__PURE__ */ r.createElement(jt, { ...e }) : null;
2003
+ return e.messageType === "user" ? n : e.messageType === "file" ? e.file.type.startsWith("image") ? /* @__PURE__ */ r.createElement(Ss, { ...e }, n) : /* @__PURE__ */ r.createElement(Cs, { ...e }, n) : /* @__PURE__ */ r.createElement(jt, { ...e, message: t.UNKNOWN__UNKNOWN_MESSAGE_TYPE });
2004
+ }
2005
+ function Os({ sendingStatus: e }) {
2006
+ const t = ut();
2007
+ switch (e) {
2008
+ case "pending":
2009
+ return /* @__PURE__ */ r.createElement(Ls, { size: 16 }, /* @__PURE__ */ r.createElement($, { type: "spinner", color: t.colors.messageOutgoing.background, size: 16 }));
2010
+ case "failed":
2011
+ return /* @__PURE__ */ r.createElement("div", { style: { marginBottom: 2 } }, /* @__PURE__ */ r.createElement($, { type: "error", color: u.themedColor.error, size: 16 }));
2012
+ case "scheduled":
2013
+ case "canceled":
2014
+ return null;
2015
+ default:
2016
+ return /* @__PURE__ */ r.createElement("div", null, /* @__PURE__ */ r.createElement($, { type: "chevron-down" }));
2017
+ }
2018
+ }
2019
+ const Ls = c(Hn)`margin-bottom:2px;width:16px;height:16px;`;
2020
+ function Rs({ createdAt: e }) {
2021
+ const { stringSet: t, format: n } = M();
2022
+ return e ? /* @__PURE__ */ r.createElement(S, { variant: "caption4", color: u.themedColor.textLowEmphasis }, n(e, t.DATE_FORMAT__MESSAGE_TIMESTAMP)) : null;
2023
+ }
2024
+ const Tt = Ce({
2025
+ template: Ns,
2026
+ components: {
2027
+ SendingStatus: Os,
2028
+ SentTime: Rs,
2029
+ MessageBody: Ms
2030
+ }
2031
+ });
2032
+ function Ns(e) {
2033
+ const { components: t } = Tt.useContext(), n = e.sendingStatus === "succeeded", o = e.groupType === "bottom" || e.groupType === "single";
2034
+ return /* @__PURE__ */ r.createElement(Ds, { $marginBottom: bt(e.groupType) }, /* @__PURE__ */ r.createElement(Bs, null, /* @__PURE__ */ r.createElement(t.MessageBody, { ...e })), o && /* @__PURE__ */ r.createElement(Ps, { $extraEndPadding: 8 }, n ? /* @__PURE__ */ r.createElement(t.SentTime, { ...e }) : /* @__PURE__ */ r.createElement(t.SendingStatus, { ...e })));
2035
+ }
2036
+ const Ds = c.div`display:flex;flex:1;flex-direction:column;align-items:flex-end;margin-bottom:${({ $marginBottom: e }) => `${e}px`};
2037
+ `, Un = c.div`display:flex;align-self:stretch;justify-content:flex-end;${({ $startPadding: e = Q, $endPadding: t = Q, $extraEndPadding: n = 0 }) => `padding-inline: ${e}px ${t + n}px;`};
2038
+ `, Bs = c(Un)``, Ps = c(Un)`margin-top:${Dn}px;`;
2039
+ function Fs(e) {
2040
+ return e.messageType !== "admin" ? null : /* @__PURE__ */ r.createElement(Hs, null, /* @__PURE__ */ r.createElement(S, { variant: "caption2", color: u.themedColor.textMidEmphasis }, Us(fn.sanitize(e.message))));
2041
+ }
2042
+ const Hs = c.div`text-align:center;text-wrap:pretty;a{text-decoration:none;color:inherit;}`, Us = (e) => {
2043
+ const t = /\[([^\]]+)\]\((https?:\/\/[^\s]+)\)/g, n = [];
2044
+ let o = 0;
2045
+ return e.replace(t, (i, s, a, l) => (n.push(e.slice(o, l)), n.push(
2046
+ /* @__PURE__ */ r.createElement("a", { key: a, href: a, target: "_blank", rel: ht }, s)
2047
+ ), o = l + i.length, i)), n.push(e.slice(o)), n;
2048
+ }, zs = ({ submitted: e, defaultValue: t, value: n, onChange: o }) => {
2049
+ const { stringSet: i } = M();
2050
+ return R(() => {
2051
+ typeof n > "u" && typeof t == "boolean" && (o == null || o(t));
2052
+ }, [n, t]), /* @__PURE__ */ r.createElement(Ws, null, /* @__PURE__ */ r.createElement(S, { variant: "caption2", color: u.themedColor.textMidEmphasis }, i.CSAT_CRE_TITLE), /* @__PURE__ */ r.createElement("div", null, /* @__PURE__ */ r.createElement(
2053
+ Kt,
2054
+ {
2055
+ checked: n === !0,
2056
+ label: i.CSAT_CRE_SOLVED,
2057
+ disabled: e,
2058
+ onClick: () => o == null ? void 0 : o(!0)
2059
+ }
2060
+ ), /* @__PURE__ */ r.createElement(
2061
+ Kt,
2062
+ {
2063
+ checked: n === !1,
2064
+ label: i.CSAT_CRE_NOT_SOLVED,
2065
+ disabled: e,
2066
+ onClick: () => o == null ? void 0 : o(!1)
2067
+ }
2068
+ )));
2069
+ }, Kt = ({ onClick: e, checked: t, label: n, disabled: o }) => {
2070
+ const i = t ? u.color.primary.main : o ? u.themedColor.textDisabled : u.themedColor.textLowEmphasis, s = t ? u.themedColor.textHighEmphasis : o ? u.themedColor.textLowEmphasis : u.themedColor.textHighEmphasis;
2071
+ return /* @__PURE__ */ r.createElement(Vs, { onClick: e, disabled: o }, /* @__PURE__ */ r.createElement($, { size: 24, type: t ? "radio-on" : "radio-off", color: i }), /* @__PURE__ */ r.createElement(S, { variant: "caption2", color: s }, n));
2072
+ }, Ws = c.div`display:flex;flex-direction:column;gap:8px;`, Vs = c.button`all:unset;display:flex;align-items:center;justify-content:flex-start;gap:2px;span{line-height:initial;}&:enabled{cursor:pointer;}`, Gs = (e) => /* @__PURE__ */ r.createElement("svg", { width: 40, height: 40, viewBox: "0 0 40 40", fill: "none", xmlns: "http://www.w3.org/2000/svg", id: "csat1", ...e }, /* @__PURE__ */ r.createElement("path", { d: "M2.08301 20C2.08301 10.1049 10.1046 2.08334 19.9997 2.08334C29.8948 2.08334 37.9163 10.1049 37.9163 20C37.9163 29.8952 29.8948 37.9167 19.9997 37.9167C10.1046 37.9167 2.08301 29.8952 2.08301 20Z", fill: "#E0E0E0" }), /* @__PURE__ */ r.createElement("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M12.5824 29.3328C13.1344 29.7473 13.918 29.636 14.3326 29.084C15.6269 27.3607 17.6835 26.25 19.9997 26.25C22.316 26.25 24.3727 27.3607 25.6668 29.084C26.0815 29.636 26.865 29.7473 27.4172 29.3328C27.9692 28.9182 28.0805 28.1347 27.6658 27.5825C25.9198 25.2577 23.1357 23.75 19.9997 23.75C16.8638 23.75 14.0797 25.2577 12.3336 27.5825C11.919 28.1347 12.0304 28.9182 12.5824 29.3328Z", fill: "black", fillOpacity: 0.12 }), /* @__PURE__ */ r.createElement("path", { d: "M28.4449 13.7707C29.1324 13.8328 29.64 14.4406 29.578 15.1281C29.516 15.8153 28.909 16.3221 28.2219 16.2608C28.2219 16.2608 28.0282 16.2502 27.9267 16.2487C27.7224 16.2457 27.4382 16.2509 27.1224 16.2833C26.7864 16.3177 26.4644 16.3782 26.1799 16.4662L26.304 16.86C26.7792 18.3675 25.5094 19.5813 24.2057 19.5813C23.504 19.5813 22.8319 19.2617 22.4295 18.6857C22.0025 18.0745 21.9417 17.241 22.4075 16.5344C22.7505 16.0143 23.2444 15.3831 23.8959 14.8657C24.8355 14.1195 26.0435 13.8809 26.867 13.7963C27.3024 13.7517 28.0149 13.7319 28.4449 13.7707Z", fill: "black", fillOpacity: 0.12 }), /* @__PURE__ */ r.createElement("path", { d: "M11.5553 13.7707C10.8677 13.8328 10.3601 14.4406 10.4221 15.1281C10.4842 15.8153 11.0912 16.3221 11.7782 16.2608C11.7782 16.2608 11.972 16.2502 12.0734 16.2487C12.2778 16.2457 12.562 16.2509 12.8778 16.2833C13.2137 16.3177 13.5357 16.3782 13.8203 16.4662L13.6962 16.86C13.2209 18.3675 14.4907 19.5813 15.7944 19.5813C16.4962 19.5813 17.1683 19.2617 17.5707 18.6857C17.9975 18.0745 18.0585 17.241 17.5925 16.5344C17.2497 16.0143 16.7557 15.3831 16.1043 14.8657C15.1646 14.1195 13.9566 13.8809 13.1331 13.7963C12.6978 13.7517 11.9853 13.7319 11.5553 13.7707Z", fill: "black", fillOpacity: 0.12 })), js = (e) => /* @__PURE__ */ r.createElement("svg", { width: 40, height: 40, viewBox: "0 0 40 40", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...e }, /* @__PURE__ */ r.createElement("path", { d: "M2.08337 19.9999C2.08337 10.1048 10.1049 2.08325 20 2.08325C29.8952 2.08325 37.9167 10.1048 37.9167 19.9999C37.9167 29.8951 29.8952 37.9166 20 37.9166C10.1049 37.9166 2.08337 29.8951 2.08337 19.9999Z", fill: "url(#paint0_linear_159_173206)" }), /* @__PURE__ */ r.createElement("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M12.5828 29.3328C13.1348 29.7473 13.9184 29.636 14.3329 29.084C15.6272 27.3607 17.6839 26.25 20 26.25C22.3164 26.25 24.373 27.3607 25.6672 29.084C26.0819 29.636 26.8654 29.7473 27.4175 29.3328C27.9695 28.9182 28.0809 28.1347 27.6662 27.5825C25.9202 25.2577 23.136 23.75 20 23.75C16.8642 23.75 14.0801 25.2577 12.334 27.5825C11.9194 28.1347 12.0308 28.9182 12.5828 29.3328Z", fill: "#141B34" }), /* @__PURE__ */ r.createElement("path", { d: "M28.4454 13.7707C29.1329 13.8328 29.6405 14.4406 29.5785 15.1281C29.5165 15.8153 28.9095 16.3221 28.2224 16.2608C28.2224 16.2608 28.0287 16.2502 27.9272 16.2487C27.7229 16.2457 27.4387 16.2509 27.1229 16.2833C26.7869 16.3177 26.4649 16.3782 26.1804 16.4662L26.3045 16.86C26.7797 18.3675 25.5099 19.5813 24.2062 19.5813C23.5045 19.5813 22.8324 19.2617 22.43 18.6857C22.003 18.0745 21.9422 17.241 22.408 16.5344C22.751 16.0143 23.2449 15.3831 23.8964 14.8657C24.836 14.1195 26.044 13.8809 26.8675 13.7963C27.3029 13.7517 28.0154 13.7319 28.4454 13.7707Z", fill: "#141B34" }), /* @__PURE__ */ r.createElement("path", { d: "M11.5549 13.7707C10.8674 13.8328 10.3597 14.4406 10.4218 15.1281C10.4838 15.8153 11.0908 16.3221 11.7779 16.2608C11.7779 16.2608 11.9716 16.2502 12.073 16.2487C12.2774 16.2457 12.5616 16.2509 12.8774 16.2833C13.2134 16.3177 13.5353 16.3782 13.8199 16.4662L13.6958 16.86C13.2205 18.3675 14.4904 19.5813 15.794 19.5813C16.4958 19.5813 17.168 19.2617 17.5703 18.6857C17.9971 18.0745 18.0581 17.241 17.5921 16.5344C17.2493 16.0143 16.7553 15.3831 16.1039 14.8657C15.1643 14.1195 13.9562 13.8809 13.1327 13.7963C12.6974 13.7517 11.9849 13.7319 11.5549 13.7707Z", fill: "#141B34" }), /* @__PURE__ */ r.createElement("defs", null, /* @__PURE__ */ r.createElement("linearGradient", { id: "paint0_linear_159_173206", x1: 20, y1: 2.08325, x2: 20, y2: 37.9166, gradientUnits: "userSpaceOnUse" }, /* @__PURE__ */ r.createElement("stop", { stopColor: "#FF2D1D" }), /* @__PURE__ */ r.createElement("stop", { offset: 1, stopColor: "#FFA540" })))), Ks = (e) => /* @__PURE__ */ r.createElement("svg", { width: 40, height: 40, viewBox: "0 0 40 40", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...e }, /* @__PURE__ */ r.createElement("path", { d: "M19.9997 36.6667C29.2044 36.6667 36.6663 29.2048 36.6663 20C36.6663 10.7953 29.2044 3.33334 19.9997 3.33334C10.7949 3.33334 3.33301 10.7953 3.33301 20C3.33301 29.2048 10.7949 36.6667 19.9997 36.6667Z", fill: "#E0E0E0" }), /* @__PURE__ */ r.createElement("path", { d: "M15 28.333C16.3927 27.2867 18.124 26.6667 20 26.6667C21.876 26.6667 23.6073 27.2867 25 28.333", stroke: "black", strokeOpacity: 0.12, strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round" }), /* @__PURE__ */ r.createElement("path", { d: "M11.667 13.3511C11.667 13.3511 14.0161 13.139 15.3268 14.18M15.3268 14.18L14.8882 15.5711C14.7153 16.1199 15.1675 16.6667 15.7943 16.6667C16.4531 16.6667 16.8882 16.0723 16.549 15.5579C16.2483 15.102 15.8388 14.5866 15.3268 14.18ZM23.3337 13.3511C23.3337 13.3511 25.6827 13.139 26.9935 14.18M26.9935 14.18L26.555 15.5711C26.382 16.1199 26.8342 16.6667 27.461 16.6667C28.1198 16.6667 28.5548 16.0723 28.2157 15.5579C27.915 15.102 27.5055 14.5866 26.9935 14.18Z", stroke: "black", strokeOpacity: 0.12, strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round" })), Zs = (e) => /* @__PURE__ */ r.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 40, height: 40, viewBox: "0 0 40 40", fill: "none", ...e }, /* @__PURE__ */ r.createElement("path", { d: "M2.083 20C2.083 10.105 10.105 2.083 20 2.083c9.895 0 17.917 8.021 17.917 17.917 0 9.895-8.022 17.917-17.917 17.917C10.105 37.917 2.083 29.895 2.083 20Z", fill: "#FFD46E" }), /* @__PURE__ */ r.createElement("path", { d: "M14.249 27.334C15.851 26.13 17.844 25.417 20 25.417c2.156 0 4.149.714 5.751 1.917.553.415.664 1.199.25 1.751-.415.552-1.199.664-1.751.25-1.183-.889-2.652-1.416-4.25-1.416s-3.067.527-4.25 1.416c-.553.414-1.336.302-1.751-.25-.415-.552-.303-1.336.249-1.751Z", fill: "#141B34" }), /* @__PURE__ */ r.createElement("path", { d: "M23.445 14.596c-.687.062-1.294-.445-1.356-1.132-.062-.687.445-1.295 1.132-1.357.082-.005.342-.02.482-.022.277-.004.662.002 1.097.047.823.085 2.031.323 2.97 1.07.652.518 1.146 1.15 1.489 1.67.466.706.405 1.54-.022 2.15-.402.576-1.074.896-1.775.896-1.304 0-2.573-1.214-2.098-2.722l.125-.394c-.285-.088-.607-.148-.942-.182-.316-.033-.6-.038-.804-.035-.101.002-.242.01-.294.013Z", fill: "#141B34" }), /* @__PURE__ */ r.createElement("path", { d: "M11.779 14.596c-.687.062-1.294-.445-1.356-1.132-.062-.687.445-1.295 1.132-1.357.082-.005.342-.02.482-.022.277-.004.662.002 1.097.047.823.085 2.031.323 2.97 1.07.652.518 1.146 1.15 1.489 1.67.466.706.405 1.54-.022 2.15-.402.576-1.074.896-1.775.896-1.304 0-2.573-1.214-2.098-2.722l.124-.394c-.284-.088-.606-.148-.941-.182-.316-.033-.6-.038-.804-.035-.101.002-.243.01-.294.013Z", fill: "#141B34" })), Ys = (e) => /* @__PURE__ */ r.createElement("svg", { width: 40, height: 40, viewBox: "0 0 40 40", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...e }, /* @__PURE__ */ r.createElement("path", { d: "M19.9997 36.6667C29.2044 36.6667 36.6663 29.2048 36.6663 20C36.6663 10.7953 29.2044 3.33334 19.9997 3.33334C10.7949 3.33334 3.33301 10.7953 3.33301 20C3.33301 29.2048 10.7949 36.6667 19.9997 36.6667Z", fill: "#E0E0E0" }), /* @__PURE__ */ r.createElement("path", { d: "M13.348 15H13.333M26.6663 15H26.6513", stroke: "black", strokeOpacity: 0.12, strokeWidth: 3.33333, strokeLinecap: "round", strokeLinejoin: "round" }), /* @__PURE__ */ r.createElement("path", { d: "M15 26.6667H25", stroke: "black", strokeOpacity: 0.12, strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round" })), qs = (e) => /* @__PURE__ */ r.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 40, height: 40, viewBox: "0 0 40 40", fill: "none", ...e }, /* @__PURE__ */ r.createElement("path", { d: "M2.083 20C2.083 10.105 10.105 2.083 20 2.083c9.895 0 17.917 8.021 17.917 17.917 0 9.895-8.022 17.917-17.917 17.917C10.105 37.917 2.083 29.895 2.083 20Z", fill: "#FFD46E" }), /* @__PURE__ */ r.createElement("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M11.25 15c0-1.151.933-2.083 2.083-2.083h.015c1.151 0 2.084.933 2.084 2.083 0 1.151-.933 2.083-2.084 2.083h-.015c-1.15 0-2.083-.933-2.083-2.083ZM24.568 15c0-1.151.933-2.083 2.084-2.083h.015c1.151 0 2.083.933 2.083 2.083 0 1.151-.932 2.083-2.083 2.083h-.015c-1.151 0-2.084-.933-2.084-2.083Z", fill: "#141B34" }), /* @__PURE__ */ r.createElement("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M13.75 26.667c0-.691.56-1.25 1.25-1.25h10c.69 0 1.25.559 1.25 1.25 0 .691-.56 1.25-1.25 1.25h-10c-.69 0-1.25-.559-1.25-1.25Z", fill: "#141B34" })), Js = (e) => /* @__PURE__ */ r.createElement("svg", { width: 40, height: 40, viewBox: "0 0 40 40", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...e }, /* @__PURE__ */ r.createElement("path", { d: "M19.9997 36.6667C29.2044 36.6667 36.6663 29.2048 36.6663 20C36.6663 10.7953 29.2044 3.33334 19.9997 3.33334C10.7949 3.33334 3.33301 10.7953 3.33301 20C3.33301 29.2048 10.7949 36.6667 19.9997 36.6667Z", fill: "#E0E0E0" }), /* @__PURE__ */ r.createElement("path", { d: "M13.333 25C14.8532 27.024 17.2735 28.3333 19.9997 28.3333C22.7258 28.3333 25.1462 27.024 26.6663 25", stroke: "black", strokeOpacity: 0.12, strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round" }), /* @__PURE__ */ r.createElement("path", { d: "M13.348 15H13.333M26.6663 15H26.6513", stroke: "black", strokeOpacity: 0.12, strokeWidth: 3.33333, strokeLinecap: "round", strokeLinejoin: "round" })), Xs = (e) => /* @__PURE__ */ r.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 40, height: 40, viewBox: "0 0 40 40", fill: "none", ...e }, /* @__PURE__ */ r.createElement("path", { d: "M2.083 20C2.083 10.105 10.105 2.083 20 2.083c9.895 0 17.917 8.021 17.917 17.917 0 9.895-8.022 17.917-17.917 17.917C10.105 37.917 2.083 29.895 2.083 20Z", fill: "#FFD46E" }), /* @__PURE__ */ r.createElement("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M12.583 24.001c.552-.414 1.335-.302 1.75.25 1.294 1.723 3.35 2.834 5.667 2.834s4.373-1.11 5.667-2.834c.415-.552 1.199-.664 1.751-.25.552.415.664 1.199.25 1.751C25.92 28.076 23.136 29.584 20 29.584s-5.92-1.508-7.666-3.832c-.415-.552-.303-1.336.249-1.751Z", fill: "#141B34" }), /* @__PURE__ */ r.createElement("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M11.25 15c0-1.151.933-2.083 2.083-2.083h.015c1.151 0 2.084.933 2.084 2.083 0 1.151-.933 2.083-2.084 2.083h-.015c-1.15 0-2.083-.933-2.083-2.083ZM24.568 15c0-1.151.933-2.083 2.084-2.083h.015c1.151 0 2.083.933 2.083 2.083 0 1.151-.932 2.083-2.083 2.083h-.015c-1.151 0-2.084-.933-2.084-2.083Z", fill: "#141B34" })), Qs = (e) => /* @__PURE__ */ r.createElement("svg", { width: 40, height: 40, viewBox: "0 0 40 40", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...e }, /* @__PURE__ */ r.createElement("path", { d: "M19.9997 36.6663C29.2044 36.6663 36.6663 29.2044 36.6663 19.9997C36.6663 10.7949 29.2044 3.33301 19.9997 3.33301C10.7949 3.33301 3.33301 10.7949 3.33301 19.9997C3.33301 29.2044 10.7949 36.6663 19.9997 36.6663Z", fill: "#E0E0E0" }), /* @__PURE__ */ r.createElement("path", { d: "M19.9997 30C23.16 30 25.8145 27.867 26.56 24.9832C26.9068 23.6413 26.4033 23.3333 25.0765 23.3333H14.9228C13.5959 23.3333 13.0925 23.6413 13.4393 24.9832C14.1848 27.867 16.8393 30 19.9997 30Z", stroke: "black", strokeOpacity: 0.12, strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round" }), /* @__PURE__ */ r.createElement("path", { d: "M11.667 15.8333C11.667 14.4526 12.7863 13.3333 14.167 13.3333C15.5477 13.3333 16.667 14.4526 16.667 15.8333M23.3337 15.8333C23.3337 14.4526 24.453 13.3333 25.8337 13.3333C27.2143 13.3333 28.3337 14.4526 28.3337 15.8333", stroke: "black", strokeOpacity: 0.12, strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round" })), ea = (e) => /* @__PURE__ */ r.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 40, height: 40, viewBox: "0 0 40 40", fill: "none", ...e }, /* @__PURE__ */ r.createElement("path", { d: "M2.083 20C2.083 10.105 10.105 2.083 20 2.083c9.895 0 17.917 8.021 17.917 17.917 0 9.895-8.022 17.917-17.917 17.917C10.105 37.917 2.083 29.895 2.083 20Z", fill: "#FFD46E" }), /* @__PURE__ */ r.createElement("g", { clipPath: "url(#clip0_159_173224)" }, /* @__PURE__ */ r.createElement("g", { clipPath: "url(#clip1_159_173224)" }, /* @__PURE__ */ r.createElement("path", { d: "M20 30.624c3.752 0 6.904-2.532 7.789-5.956.412-1.593-.185-1.959-1.76-1.959H13.973c-1.575 0-2.173.366-1.761 1.959.885 3.424 4.037 5.956 7.788 5.956Z", fill: "#141B34" })), /* @__PURE__ */ r.createElement("mask", { id: "mask0_159_173224", style: {
2073
+ maskType: "alpha"
2074
+ }, maskUnits: "userSpaceOnUse", x: 12, y: 22, width: 16, height: 9 }, /* @__PURE__ */ r.createElement("path", { d: "M20 30.624c3.752 0 6.904-2.532 7.789-5.956.412-1.593-.185-1.959-1.76-1.959H13.973c-1.575 0-2.173.366-1.761 1.959.885 3.424 4.037 5.956 7.788 5.956Z", fill: "#141B34" })), /* @__PURE__ */ r.createElement("g", { mask: "url(#mask0_159_173224)" }, /* @__PURE__ */ r.createElement("path", { d: "M20 32.998c3.278 0 5.936-1.594 5.936-3.561 0-1.968-2.658-3.562-5.936-3.562-3.278 0-5.936 1.594-5.936 3.562 0 1.967 2.658 3.561 5.936 3.561Z", fill: "#FF493B" }))), /* @__PURE__ */ r.createElement("path", { d: "M11.667 15.833c0-1.381 1.12-2.5 2.5-2.5s2.5 1.12 2.5 2.5M23.333 15.833c0-1.381 1.12-2.5 2.5-2.5s2.5 1.12 2.5 2.5", stroke: "#141B34", strokeWidth: 2.5, strokeLinecap: "round", strokeLinejoin: "round" }), /* @__PURE__ */ r.createElement("defs", null, /* @__PURE__ */ r.createElement("clipPath", { id: "clip0_159_173224" }, /* @__PURE__ */ r.createElement("rect", { width: 15.83, height: 7.915, fill: "white", transform: "translate(12.085 22.709)" })), /* @__PURE__ */ r.createElement("clipPath", { id: "clip1_159_173224" }, /* @__PURE__ */ r.createElement("rect", { width: 15.83, height: 7.915, fill: "white", transform: "translate(12.085 22.709)" })))), ta = [
2075
+ {
2076
+ value: 1,
2077
+ Icon: {
2078
+ Active: js,
2079
+ Inactive: Gs
2080
+ },
2081
+ isActive: (e) => e <= 1,
2082
+ getTooltip: (e) => e.CSAT5_RATING_SCORE_1
2083
+ },
2084
+ {
2085
+ value: 2,
2086
+ Icon: {
2087
+ Active: Zs,
2088
+ Inactive: Ks
2089
+ },
2090
+ isActive: (e) => e === 2,
2091
+ getTooltip: (e) => e.CSAT5_RATING_SCORE_2
2092
+ },
2093
+ {
2094
+ value: 3,
2095
+ Icon: {
2096
+ Active: qs,
2097
+ Inactive: Ys
2098
+ },
2099
+ isActive: (e) => e === 3,
2100
+ getTooltip: (e) => e.CSAT5_RATING_SCORE_3
2101
+ },
2102
+ {
2103
+ value: 4,
2104
+ Icon: {
2105
+ Active: Xs,
2106
+ Inactive: Js
2107
+ },
2108
+ isActive: (e) => e === 4,
2109
+ getTooltip: (e) => e.CSAT5_RATING_SCORE_4
2110
+ },
2111
+ {
2112
+ value: 5,
2113
+ Icon: {
2114
+ Active: ea,
2115
+ Inactive: Qs
2116
+ },
2117
+ isActive: (e) => 5 <= e,
2118
+ getTooltip: (e) => e.CSAT5_RATING_SCORE_5
2119
+ }
2120
+ ], na = () => ta, zn = ({ label: e, children: t, position: n = "top", disabled: o }) => {
2121
+ const [i, s] = C(!1);
2122
+ return o ? t : /* @__PURE__ */ r.createElement("div", { style: { position: "relative" }, onMouseEnter: () => s(!0), onMouseLeave: () => s(!1) }, t, /* @__PURE__ */ r.createElement(ia, { $visible: i, $position: n }, /* @__PURE__ */ r.createElement(sa, { variant: "caption1" }, e), /* @__PURE__ */ r.createElement(ra, { $position: n })));
2123
+ }, ra = ({ $position: e }) => /* @__PURE__ */ r.createElement(
2124
+ "svg",
2125
+ {
2126
+ style: { transform: e === "top" ? "rotate(0)" : "rotate(180deg)" },
2127
+ xmlns: "http://www.w3.org/2000/svg",
2128
+ width: "12",
2129
+ height: "6",
2130
+ viewBox: "0 0 12 6",
2131
+ fill: "none"
2132
+ },
2133
+ /* @__PURE__ */ r.createElement("path", { d: "M6 6L0 0h12L6 6Z", fill: u.themedColor.textHighEmphasis })
2134
+ ), oa = {
2135
+ top: k`flex-direction:column;top:0;transform:translate(-50%,-100%);`,
2136
+ bottom: k`flex-direction:column-reverse;bottom:0;transform:translate(-50%,100%);`
2137
+ }, ia = c.div`display:${({ $visible: e }) => e ? "flex" : "none"};align-items:center;position:absolute;left:50%;z-index:${he.TOOLTIP};${({ $position: e }) => oa[e]}`, sa = c(S)`padding:6px 8px;background:${u.themedColor.textHighEmphasis};color:${u.themedColor.textHighEmphasisInverse};border-radius:4px;font-size:12px;white-space:nowrap;`, aa = ({ submitted: e, value: t, onChange: n }) => {
2138
+ const { stringSet: o } = M(), i = na(), s = typeof t == "number";
2139
+ return /* @__PURE__ */ r.createElement(la, null, /* @__PURE__ */ r.createElement(S, { variant: "caption2", color: u.themedColor.textMidEmphasis }, o.CSAT_RATING_TITLE), /* @__PURE__ */ r.createElement(ca, null, i.map((a) => /* @__PURE__ */ r.createElement(zn, { disabled: e, key: a.value, label: a.getTooltip(o) }, /* @__PURE__ */ r.createElement(
2140
+ da,
2141
+ {
2142
+ disabled: e,
2143
+ onClick: () => n(a.value),
2144
+ $inactive: s && !a.isActive(t)
2145
+ },
2146
+ s ? a.isActive(t) ? /* @__PURE__ */ r.createElement(a.Icon.Active, null) : /* @__PURE__ */ r.createElement(a.Icon.Inactive, null) : /* @__PURE__ */ r.createElement(a.Icon.Active, null)
2147
+ )))));
2148
+ }, la = c.div`display:flex;flex-direction:column;gap:8px;`, ca = c.div`display:flex;justify-content:space-between;width:100%;max-width:320px;`, da = c.button`background-color:transparent;border:none;border-radius:4px;padding:0;display:flex;align-items:center;justify-content:center;box-sizing:border-box;&:enabled:hover{cursor:pointer;background-color:${u.color.background200};${B.dark`
2149
+ background-color: ${u.color.background500};
2150
+ `}
2151
+ }
2152
+
2153
+ ${({ $inactive: e, theme: t }) => e && t.selected === "dark" && ua};
2154
+ `, ua = k`[fill]{fill:white;fill-opacity:0.12;}[stroke]{stroke:white;stroke-opacity:0.12;}`, ma = ({ submitted: e, value: t = "", onChange: n }) => {
2155
+ const { stringSet: o } = M();
2156
+ return e && !t ? null : /* @__PURE__ */ r.createElement(
2157
+ ga,
2158
+ {
2159
+ disabled: e,
2160
+ maxLength: 255,
2161
+ value: t,
2162
+ onChange: (i) => n(i.target.value),
2163
+ placeholder: o.CSAT_REASON_PLACEHOLDER
2164
+ }
2165
+ );
2166
+ }, ga = c.input`box-sizing:border-box;width:100%;border-radius:4px;padding:10px 16px;font-size:14px;font-weight:400;font-style:normal;border:unset;&:focus{outline:none;}color:${u.themedColor.textHighEmphasis};&::placeholder{color:${u.themedColor.textLowEmphasis};}background-color:${u.color.background50};${B.dark`
2167
+ background-color: ${u.themedColor.textDisabled};
2168
+ `}
2169
+
2170
+ &:disabled {
2171
+ cursor: not-allowed;
2172
+ color: ${u.themedColor.textLowEmphasis};
2173
+ background-color: ${u.color.background200};
2174
+ ${B.dark`
2175
+ color: ${u.color.ondark.textDisabled};
2176
+ background-color: ${u.themedColor.textDisabled};
2177
+ `}
2178
+ }
2179
+ `, pa = ({ submitted: e }) => {
2180
+ const { stringSet: t } = M();
2181
+ return e ? /* @__PURE__ */ r.createElement(S, { variant: "h2", color: u.themedColor.textHighEmphasis }, t.CSAT_TITLE_SUBMITTED) : /* @__PURE__ */ r.createElement(S, { variant: "h2", color: u.themedColor.textHighEmphasis }, t.CSAT_TITLE_UNSUBMITTED);
2182
+ };
2183
+ var me = /* @__PURE__ */ ((e) => (e.AI_AGENT_CSAT_5 = "AI_AGENT_CSAT_5", e.AI_AGENT_CSAT_5_WITH_CRE = "AI_AGENT_CSAT_5_WITH_CRE", e))(me || {});
2184
+ const ha = (e) => mr((t, n) => ({ ...t, ...n }), e), Zt = ({
2185
+ type: e,
2186
+ renderSubmitButton: t,
2187
+ initialCsat: n,
2188
+ initialCsatReason: o,
2189
+ initialIsResolved: i
2190
+ }) => {
2191
+ const [s, a] = ha({
2192
+ csatType: e,
2193
+ csat: n,
2194
+ csatReason: o,
2195
+ isResolved: i
2196
+ }), l = typeof n == "number" ? "submitted" : e === me.AI_AGENT_CSAT_5 && typeof s.csat == "number" || e === me.AI_AGENT_CSAT_5_WITH_CRE && typeof s.csat == "number" && typeof s.isResolved == "boolean" ? "submittable" : "unsubmittable", d = { state: l, submitted: l === "submitted" };
2197
+ return /* @__PURE__ */ r.createElement(r.Fragment, null, /* @__PURE__ */ r.createElement(fa, null, /* @__PURE__ */ r.createElement(pa, { ...d }), e === me.AI_AGENT_CSAT_5_WITH_CRE && /* @__PURE__ */ r.createElement(
2198
+ zs,
2199
+ {
2200
+ ...d,
2201
+ defaultValue: i,
2202
+ value: s.isResolved,
2203
+ onChange: (g) => a({ isResolved: g })
2204
+ }
2205
+ ), /* @__PURE__ */ r.createElement(aa, { ...d, value: s.csat, onChange: (g) => a({ csat: g }) }), s.csat && /* @__PURE__ */ r.createElement(
2206
+ ma,
2207
+ {
2208
+ ...d,
2209
+ value: s.csatReason,
2210
+ onChange: (g) => a({ csatReason: g })
2211
+ }
2212
+ )), l !== "submitted" && t({ state: l, params: s }));
2213
+ }, fa = c.div`display:flex;flex-direction:column;gap:12px;`, ba = () => {
2214
+ const { stringSet: e } = M();
2215
+ return /* @__PURE__ */ r.createElement(S, { variant: "body2", color: u.themedColor.textMidEmphasis, style: { textAlign: "center" } }, e.CSAT_SUBMISSION_EXPIRED);
2216
+ }, xa = (e) => {
2217
+ if (e.messageType !== "admin.csat")
2218
+ throw new Error("Invalid message type");
2219
+ const t = $r(), { stringSet: n } = M(), { extendedMessagePayload: o, csat: i, csatReason: s, csatExpireAt: a, isResolvedWhenDeterminedByUser: l, onSubmitCSAT: d } = e, { visibility: g, type: m } = (o == null ? void 0 : o.csat) ?? {};
2220
+ if (!g || !m || !me[m]) return null;
2221
+ const p = m === me.AI_AGENT_CSAT_5 || m === me.AI_AGENT_CSAT_5_WITH_CRE ? Zt : () => null, h = (b) => {
2222
+ b.csat && !Yt(a) ? d({
2223
+ csatType: b.csatType,
2224
+ csat: b.csat,
2225
+ csatReason: b.csatReason,
2226
+ isResolved: b.isResolved
2227
+ }) : t();
2228
+ };
2229
+ return /* @__PURE__ */ r.createElement(Ea, null, !i && Yt(a) ? /* @__PURE__ */ r.createElement(ba, null) : /* @__PURE__ */ r.createElement(
2230
+ p,
2231
+ {
2232
+ type: m,
2233
+ initialCsat: i,
2234
+ initialCsatReason: s,
2235
+ initialIsResolved: l,
2236
+ renderSubmitButton: ({ state: b, params: x }) => /* @__PURE__ */ r.createElement(va, { disabled: b !== "submittable", onClick: () => h(x) }, /* @__PURE__ */ r.createElement(S, { variant: "button" }, n.CSAT_SUBMIT_LABEL))
2237
+ }
2238
+ ));
2239
+ }, Ea = c.div`display:flex;flex-direction:column;background-color:${({ theme: e }) => e.colors.csat.background};border-radius:16px;gap:16px;padding:24px;`, va = c.button`all:unset;background-color:${({ theme: e }) => e.colors.base.primary};color:${({ theme: e }) => e.colors.base.primaryContrastContent};border-radius:6px;padding:10px 20px;display:flex;align-items:center;justify-content:center;cursor:pointer;&:hover{background-color:${u.color.primary.dark};}&:disabled{color:${u.color.ondark.textLowEmphasis};background-color:${u.themedColor.textDisabled};cursor:not-allowed;}`;
2240
+ function Yt(e) {
2241
+ return !!e && e < Date.now();
2242
+ }
2243
+ const _t = Ce({
2244
+ template: ya,
2245
+ components: {
2246
+ AdminMessage: Fs,
2247
+ CSATMessage: xa
2248
+ }
2249
+ });
2250
+ function ya(e) {
2251
+ const { components: t } = _t.useContext(), n = Ct(() => e.messageType === "admin" ? /* @__PURE__ */ r.createElement(t.AdminMessage, { ...e }) : e.messageType === "admin.csat" ? /* @__PURE__ */ r.createElement(t.CSATMessage, { ...e }) : null);
2252
+ return /* @__PURE__ */ r.createElement(Ca, { $marginBottom: bt(e.groupType) }, n);
2253
+ }
2254
+ const Ca = c.div`padding-inline:${Q}px;margin-bottom:${({ $marginBottom: e }) => e}px;`, qt = {
2255
+ file: "attach",
2256
+ snippet: "snippet",
2257
+ site: "website",
2258
+ sb_sprinklr: "sprinklr",
2259
+ sb_salesforce: "salesforce",
2260
+ sb_confluence: "confluence",
2261
+ sb_zendesk: "zendesk",
2262
+ sb_desk: "snippet"
2263
+ // TODO: request icon
2264
+ }, Ta = ({
2265
+ actionbook: e,
2266
+ functionCalls: t,
2267
+ groundedness: n,
2268
+ agentMessageTemplates: o,
2269
+ onClickActionbook: i,
2270
+ onClickFunctionCall: s,
2271
+ onClickFunctionCallDetail: a,
2272
+ onClickGroundedness: l,
2273
+ onClickAgentMessageTemplate: d,
2274
+ bottomContent: g,
2275
+ renderCustomGroundednessIcon: m = (h) => h.default,
2276
+ style: p = {}
2277
+ }) => {
2278
+ const {
2279
+ // Note: This component is used with the dashboard, so cssVars should not be used.
2280
+ iconColor: h = "#000000",
2281
+ textColor: b = "#000000",
2282
+ highlightColor: x = wn.DEFAULT_PRIMARY
2283
+ } = p;
2284
+ return /* @__PURE__ */ r.createElement(Jt, null, e && /* @__PURE__ */ r.createElement(Jt, null, /* @__PURE__ */ r.createElement(Ke, null, /* @__PURE__ */ r.createElement(Ue, null, /* @__PURE__ */ r.createElement($, { size: 16, type: "actionbook", color: h })), /* @__PURE__ */ r.createElement(
2285
+ He,
2286
+ {
2287
+ $clickable: !!i,
2288
+ $highlightColor: x,
2289
+ variant: "body2",
2290
+ color: b,
2291
+ onClick: () => i == null ? void 0 : i(e)
2292
+ },
2293
+ e.name
2294
+ ))), t == null ? void 0 : t.map((v) => /* @__PURE__ */ r.createElement(rt, { key: v.key }, /* @__PURE__ */ r.createElement(Ue, null, /* @__PURE__ */ r.createElement($, { size: 16, type: "function", color: h })), /* @__PURE__ */ r.createElement(Ke, null, /* @__PURE__ */ r.createElement(
2295
+ He,
2296
+ {
2297
+ $clickable: !!i,
2298
+ $highlightColor: x,
2299
+ variant: "body2",
2300
+ color: b,
2301
+ onClick: () => s == null ? void 0 : s(v)
2302
+ },
2303
+ v.name
2304
+ ), /* @__PURE__ */ r.createElement(Sa, { role: "button", onClick: () => a == null ? void 0 : a(v) }, /* @__PURE__ */ r.createElement(S, { variant: "body2", color: x }, "View details"), /* @__PURE__ */ r.createElement($, { type: "chevron-right", size: 16, color: x }))))), n == null ? void 0 : n.map((v) => /* @__PURE__ */ r.createElement(rt, { key: v.id }, /* @__PURE__ */ r.createElement(Ue, null, m({
2305
+ default: /* @__PURE__ */ r.createElement($, { size: 16, type: qt[v.source_type] ?? qt.snippet, color: h }),
2306
+ sourceType: v.source_type
2307
+ })), /* @__PURE__ */ r.createElement(
2308
+ He,
2309
+ {
2310
+ $clickable: !!l,
2311
+ $highlightColor: x,
2312
+ variant: "body2",
2313
+ color: b,
2314
+ onClick: () => l == null ? void 0 : l(v)
2315
+ },
2316
+ v.preview_title
2317
+ ))), o == null ? void 0 : o.map((v) => /* @__PURE__ */ r.createElement(rt, { key: v.key }, /* @__PURE__ */ r.createElement(Ue, null, /* @__PURE__ */ r.createElement($, { size: 16, type: "template", color: h })), /* @__PURE__ */ r.createElement(
2318
+ He,
2319
+ {
2320
+ $clickable: !!d,
2321
+ $highlightColor: x,
2322
+ variant: "body2",
2323
+ color: b,
2324
+ onClick: () => d == null ? void 0 : d(v)
2325
+ },
2326
+ v.name
2327
+ ))), g);
2328
+ }, _a = c(S)`font-weight:400;`, He = c(_a)`${({ $clickable: e, $highlightColor: t }) => e && k`
2329
+ cursor: pointer;
2330
+ text-decoration: underline;
2331
+ &:hover {
2332
+ color: ${t};
2333
+ }
2334
+ `}
2335
+ `, Ue = c.div`display:flex;align-items:center;justify-content:center;flex-shrink:0;`, Ke = c.div`display:flex;gap:8px;align-items:center;`, Sa = c(Ke)`cursor:pointer;gap:4px;`, rt = c(Ke)`flex-direction:row;align-items:center;`, Jt = c.div`display:flex;gap:4px;flex-direction:column;align-items:flex-start;`, Wn = ye(
2336
+ null
2337
+ );
2338
+ function wa({
2339
+ isDashboardActionbookTester: e = !1,
2340
+ children: t
2341
+ }) {
2342
+ return /* @__PURE__ */ r.createElement(Wn.Provider, { value: { isDashboardActionbookTester: e } }, e && /* @__PURE__ */ r.createElement(ka, null), t);
2343
+ }
2344
+ const St = () => {
2345
+ const e = J(Wn);
2346
+ if (!e) throw new Error("_UNSAFE_INTERNAL_DashboardActionbookTesterProvider not found");
2347
+ return e;
2348
+ }, ka = () => /* @__PURE__ */ r.createElement(ve.Template, { template: Aa }, /* @__PURE__ */ r.createElement(ve.MessageLogs, { component: Ia })), Aa = (e) => /* @__PURE__ */ r.createElement(Fn, { ...e, testerMode: !0, maxBodyWidth: Nn }), Ia = ({ extendedMessagePayload: e = {} }) => {
2349
+ const { handlers: t } = N(), { manual: n, groundedness: o, function_calls: i, agent_message_templates: s, is_thinking: a } = e;
2350
+ return a || !n && !(o != null && o.length) && !(i != null && i.length) && !(s != null && s.length) ? /* @__PURE__ */ r.createElement(r.Fragment, null) : /* @__PURE__ */ r.createElement($a, null, /* @__PURE__ */ r.createElement(Ma, { width: 4 }), /* @__PURE__ */ r.createElement(
2351
+ Ta,
2352
+ {
2353
+ actionbook: n,
2354
+ functionCalls: i,
2355
+ groundedness: o,
2356
+ agentMessageTemplates: s,
2357
+ onClickFunctionCallDetail: t == null ? void 0 : t.onFunctionCallDetailClick,
2358
+ style: {
2359
+ iconColor: u.themedColor.textHighEmphasis,
2360
+ textColor: u.themedColor.textHighEmphasis,
2361
+ barColor: u.themedColor.textDisabled
2362
+ },
2363
+ bottomContent: /* @__PURE__ */ r.createElement(Oa, { variant: "caption2", color: u.themedColor.textLowEmphasis }, "Only visible in the tester")
2364
+ }
2365
+ ));
2366
+ }, $a = c.div`display:flex;gap:16px;margin:16px ${Q}px 0;align-self:stretch;`, Ma = c.div`width:${({ width: e }) => e}px;background-color:${u.themedColor.textDisabled};border-radius:100px;flex-shrink:0;`, Oa = c(S)`margin-top:5px;`, wt = {
2367
+ isStreaming(e) {
2368
+ const t = Ht(e.data);
2369
+ return typeof t == "object" ? !!t.stream : !1;
2370
+ },
2371
+ isWelcomeMessage(e, t) {
2372
+ var n;
2373
+ if (((n = e.extendedMessagePayload) == null ? void 0 : n.bot_message_type) === "welcome")
2374
+ return !0;
2375
+ if ((e.isUserMessage() || e.isFileMessage()) && e.sender.userId === t) {
2376
+ const o = Ht(e.data);
2377
+ return !(o != null && o.respond_mesg_id) && !(o != null && o.stream);
2378
+ }
2379
+ return !1;
2380
+ }
2381
+ };
2382
+ function La(e) {
2383
+ return "sendingStatus" in e ? e.sendingStatus === "succeeded" ? String(e.messageId) : e.reqId : String(e.messageId);
2384
+ }
2385
+ const Ra = (e, t, n, o = !0) => {
2386
+ if (!o || !e.isUserMessage() && !e.isFileMessage())
2387
+ return "single";
2388
+ const i = () => {
2389
+ if (!t || !t.isUserMessage() && !t.isFileMessage()) return !1;
2390
+ const d = t.sender.userId === e.sender.userId, g = Nt(t.createdAt, e.createdAt);
2391
+ return d && g;
2392
+ }, s = () => {
2393
+ if (!n || !n.isUserMessage() && !n.isFileMessage()) return !1;
2394
+ const d = n.sender.userId === e.sender.userId, g = Nt(n.createdAt, e.createdAt);
2395
+ return d && g;
2396
+ }, a = i(), l = s();
2397
+ return a && l ? "middle" : a ? "bottom" : l ? "top" : "single";
2398
+ };
2399
+ function Na(e, t) {
2400
+ return e.filter((n) => wt.isWelcomeMessage(n, t));
2401
+ }
2402
+ function Vn(e, t) {
2403
+ return Da(e) === t;
2404
+ }
2405
+ function Da(e) {
2406
+ var t;
2407
+ if (e)
2408
+ return e.isUserMessage() || e.isFileMessage() || e.isMultipleFilesMessage() ? e.sender.userId : ((t = e == null ? void 0 : e.sender) == null ? void 0 : t.userId) ?? void 0;
2409
+ }
2410
+ function Ba(e) {
2411
+ return e.isAdminMessage() ? e.message === "The channel's custom_type was updated." : !1;
2412
+ }
2413
+ const Xt = (e) => !!e && "sender" in e, Gn = (e) => e.startsWith("image/"), jn = (e) => e.startsWith("video/"), Qt = (e) => Gn(e) || jn(e), ze = {
2414
+ isAdmin: (e) => e.isAdminMessage(),
2415
+ isCSAT: (e) => {
2416
+ var t;
2417
+ return e.isAdminMessage() && !!((t = e.extendedMessagePayload) != null && t.csat);
2418
+ },
2419
+ isIncoming: (e, t) => Xt(e) && e.sender.userId !== t,
2420
+ isOutgoing: (e, t) => Xt(e) && (e.sender.userId === t || e.sendingStatus === Lr.PENDING)
2421
+ }, Kn = ({ rootElementId: e, visible: t, onClose: n, children: o }) => {
2422
+ if (!t) return null;
2423
+ const { rootElement: i } = N(), s = pe(i), a = pe(i, !0);
2424
+ return Fr(
2425
+ /* @__PURE__ */ r.createElement(Pa, { onClick: n }, /* @__PURE__ */ r.createElement(Fa, { onClick: (l) => l.stopPropagation() }, o)),
2426
+ s.getElementById(e) ?? s.getElementById(X.MODAL_ROOT) ?? a.body
2427
+ );
2428
+ }, Pa = c.div`position:fixed;top:0;left:0;width:100%;height:100%;background:${u.color.overlay.dark};display:flex;justify-content:center;align-items:center;z-index:${he.MODAL};`, Fa = c.div`border-radius:4px;overflow:hidden;box-shadow:0 16px 24px 2px rgba(13,13,13,0.12),0 6px 30px 5px rgba(13,13,13,0.08),0 6px 10px -5px rgba(13,13,13,0.04);z-index:${he.MODAL};`, Ha = c.div`flex-shrink:0;width:${({ $size: e }) => se(e)};height:${({ $size: e }) => se(e)};background-color:${({ theme: e }) => e.colors.base.primary};box-sizing:border-box;padding:6px;border-radius:50%;display:flex;justify-content:center;align-items:center;}`, Ua = c(vt)`path{fill:${({ theme: e }) => e.colors.base.primaryContrastContent};}`;
2429
+ function Zn({ size: e }) {
2430
+ const { aiAgentInfo: t } = F();
2431
+ return t.profileUrl ? /* @__PURE__ */ r.createElement(yt, { size: e, src: t.profileUrl }) : /* @__PURE__ */ r.createElement(Ha, { $size: e }, /* @__PURE__ */ r.createElement(Ua, null));
2432
+ }
2433
+ const za = c.div`width:100%;height:100%;position:fixed;top:0;left:0;outline:none;`, Wa = c.div`height:64px;min-height:64px;box-sizing:border-box;display:flex;justify-content:space-between;border-bottom:1px solid ${u.themedColor.textDisabled};background-color:${u.themedColor.bg_50_600};@media screen and (max-width:768px){position:relative;}`, Va = c.div`box-sizing:border-box;display:flex;flex-direction:row;align-items:center;height:64px;padding:16px 20px;width:calc(100% - 128px);`, Ga = c.div`margin-inline-end:8px;`, ja = c.div`max-width:500px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;display:inline-block;@media screen and (max-width:768px){position:absolute;inset-inline-start:64px;top:10px;display:block;max-width:calc(100vw - 240px);}`, Ka = c.div`display:inline-block;margin-inline-start:8px;padding-top:5px;@media screen and (max-width:768px){position:absolute;inset-inline-start:56px;top:24px;}`, Za = c.div`display:flex;width:160px;justify-content:flex-end;`, Ya = c.div`inset-inline-end:0;display:flex;flex-direction:row;`, ct = c.div`width:64px;padding:21px;box-sizing:border-box;cursor:${(e) => e.disabled ? "not-allowed" : "pointer"};`, qa = c(ct)`border-inline-start:1px solid ${u.themedColor.textDisabled};`, Ja = c.div`width:100%;height:100%;display:flex;align-items:center;justify-content:center;`, Xa = c.video`max-width:100%;max-height:100%;user-select:none;-webkit-user-drag:none;`, Qa = c.img`max-width:90%;max-height:90%;user-select:none;-webkit-user-drag:none;`, el = c.div`max-width:100%;max-height:100%;display:flex;justify-content:center;align-items:center;`, tl = ({ message: e, onClose: t, onDownloadClick: n }) => {
2434
+ const { sender: o, type: i, url: s, name: a = "", threadInfo: l } = e, { profileUrl: d, nickname: g, userId: m } = o, { userSession: p, aiAgentInfo: h } = F();
2435
+ return /* @__PURE__ */ r.createElement(
2436
+ rl,
2437
+ {
2438
+ profileUrl: d,
2439
+ nickname: g,
2440
+ type: i,
2441
+ url: s,
2442
+ name: a,
2443
+ onClose: t,
2444
+ isBotMessage: m === h.userId,
2445
+ isByMe: p.userId === m,
2446
+ disableDelete: l != null && l.replyCount ? l.replyCount > 0 : !1,
2447
+ onDownloadClick: n
2448
+ }
2449
+ );
2450
+ }, nl = ({ profileUrl: e, isBotMessage: t }) => !e && t ? /* @__PURE__ */ r.createElement(Zn, { size: 32 }) : /* @__PURE__ */ r.createElement(yt, { size: 32, src: e }), rl = ({
2451
+ profileUrl: e,
2452
+ isBotMessage: t,
2453
+ nickname: n,
2454
+ name: o,
2455
+ type: i,
2456
+ url: s,
2457
+ isByMe: a,
2458
+ onClose: l,
2459
+ onDelete: d,
2460
+ disableDelete: g,
2461
+ onDownloadClick: m
2462
+ }) => {
2463
+ const { stringSet: p } = M();
2464
+ return /* @__PURE__ */ r.createElement(Kn, { onClose: l, visible: !0, rootElementId: X.MODAL_ROOT }, /* @__PURE__ */ r.createElement(za, null, /* @__PURE__ */ r.createElement(Wa, null, /* @__PURE__ */ r.createElement(Va, null, /* @__PURE__ */ r.createElement(Ga, null, /* @__PURE__ */ r.createElement(nl, { profileUrl: e, isBotMessage: t })), /* @__PURE__ */ r.createElement(ja, null, /* @__PURE__ */ r.createElement(S, { variant: "h2", color: u.themedColor.textHighEmphasis }, o)), /* @__PURE__ */ r.createElement(Ka, null, /* @__PURE__ */ r.createElement(S, { variant: "body1", color: u.color.ondark.textMidEmphasis }, n))), /* @__PURE__ */ r.createElement(Za, null, Qt(i) && /* @__PURE__ */ r.createElement(Ya, null, /* @__PURE__ */ r.createElement(ct, { as: "a", href: s, target: "_blank", rel: ht, onClick: m }, /* @__PURE__ */ r.createElement($, { type: "download", color: u.themedColor.textHighEmphasis, size: 24 })), d && a && /* @__PURE__ */ r.createElement(
2465
+ ct,
2466
+ {
2467
+ disabled: g,
2468
+ onClick: () => {
2469
+ g || d();
2470
+ }
2471
+ },
2472
+ /* @__PURE__ */ r.createElement(
2473
+ $,
2474
+ {
2475
+ type: "delete",
2476
+ color: g ? "gray" : u.themedColor.textHighEmphasis,
2477
+ size: 24
2478
+ }
2479
+ )
2480
+ )), /* @__PURE__ */ r.createElement(qa, { onClick: l }, /* @__PURE__ */ r.createElement($, { type: "close", color: u.themedColor.textHighEmphasis, size: 24 })))), /* @__PURE__ */ r.createElement(Ja, { onClick: (h) => h.currentTarget === h.target && l() }, jn(i) && /* @__PURE__ */ r.createElement(Xa, { controls: !0 }, /* @__PURE__ */ r.createElement("source", { src: s, type: i })), Gn(i) && /* @__PURE__ */ r.createElement(Qa, { src: s, alt: o }), !Qt(i) && /* @__PURE__ */ r.createElement(el, null, /* @__PURE__ */ r.createElement(S, { variant: "h1", color: u.themedColor.textHighEmphasis }, p.FILE_VIEWER__UNSUPPORT)))));
2481
+ }, Yn = ({
2482
+ className: e,
2483
+ locale: t,
2484
+ date: n = Date.now(),
2485
+ formatString: o = "MMMM dd, yyyy",
2486
+ style: i
2487
+ }) => /* @__PURE__ */ r.createElement(ol, { style: i, className: e }, /* @__PURE__ */ r.createElement(S, { variant: "caption4", color: u.themedColor.textMidEmphasis }, pn(n, o, { locale: t }))), ol = c.div`display:flex;justify-content:center;align-items:center;`, il = gr(function(t, n) {
2488
+ const {
2489
+ messages: o,
2490
+ renderMessage: i,
2491
+ messageTopArea: s,
2492
+ messageBottomArea: a,
2493
+ overlayArea: l,
2494
+ onLoadPrev: d,
2495
+ onLoadNext: g,
2496
+ loadThreshold: m = 0.05,
2497
+ onScrollPosition: p = Ge,
2498
+ depsForResetScrollPositionToBottom: h,
2499
+ scrollPositionRef: b,
2500
+ scrollDistanceFromBottomRef: x,
2501
+ stackDirection: v = "top"
2502
+ } = t, f = n && "current" in n ? n : { current: null }, y = D(!1), _ = D(void 0), w = D(0), O = D(0), ee = D(0), H = b ?? O, le = x ?? ee;
2503
+ ge(() => {
2504
+ f.current && (f.current.scrollTop = f.current.scrollHeight);
2505
+ }, h), ge(() => {
2506
+ f.current && (_.current === "top" && (f.current.scrollTop = f.current.scrollHeight - H.current), _.current === "bottom" && (f.current.scrollTop = w.current), _.current = void 0);
2507
+ }, [f.current, o.length]);
2508
+ const _e = async () => {
2509
+ if (!f.current) return;
2510
+ const E = f.current;
2511
+ if (p(sl(E)), H.current = E.scrollHeight - E.scrollTop, le.current = H.current - E.clientHeight, w.current = E.scrollTop, y.current) return;
2512
+ const U = E.clientHeight * Math.min(Math.max(0, m), 1);
2513
+ E.scrollTop <= U ? (y.current = !0, _.current = "top", await d(), y.current = !1) : E.scrollHeight - E.scrollTop - E.clientHeight <= U ? (y.current = !0, _.current = "bottom", await g(), y.current = !1) : _.current = void 0;
2514
+ };
2515
+ return /* @__PURE__ */ r.createElement(al, { id: "infinite-list-container" }, /* @__PURE__ */ r.createElement(ll, { id: "infinite-list-inner", ref: f, onScroll: _e }, v === "bottom" && /* @__PURE__ */ r.createElement("div", { style: { flexGrow: 1 } }), s, o.map((E, U) => i({ message: E, index: U })), a), /* @__PURE__ */ r.createElement(cl, { id: "infinite-list-overlay-container" }, /* @__PURE__ */ r.createElement(dl, { id: "infinite-list-overlay" }, l)));
2516
+ });
2517
+ function sl(e) {
2518
+ return e.scrollTop <= 10 ? "top" : e.scrollHeight - (e.scrollTop + e.clientHeight) <= 10 ? "bottom" : "middle";
2519
+ }
2520
+ const al = c.div`display:flex;position:relative;flex:1;overflow:hidden;`, ll = c.div`display:flex;flex:1;flex-direction:column;overflow-y:auto;scrollbar-color:${u.themedColor.textLowEmphasis}transparent;&::-webkit-scrollbar-thumb:hover{background-color:transparent;}`, cl = c.div`position:absolute;top:0;bottom:0;left:0;right:0;pointer-events:none;`, dl = c.div`pointer-events:auto;`, ul = ({ className: e, onClick: t }) => /* @__PURE__ */ r.createElement(ml, { className: e, onClick: t, tabIndex: 0 }, /* @__PURE__ */ r.createElement($, { size: 24, type: "chevron-down", color: u.color.primary.main })), ml = c.button`all:unset;cursor:pointer;display:flex;align-items:center;justify-content:center;width:40px;height:40px;border-radius:24px;box-shadow:0 2px 8px 0 rgba(0,0,0,0.08),0 4px 6px 0 rgba(0,0,0,0.12);${B.light`
2521
+ background-color: ${u.color.background50};
2522
+ &:hover {
2523
+ background-color: ${u.color.background100};
2524
+ }
2525
+ &:active {
2526
+ background-color: ${u.color.background200};
2527
+ }
2528
+ `}
2529
+ ${B.dark`
2530
+ background-color: ${u.color.background400};
2531
+ &:hover {
2532
+ background-color: ${u.color.background500};
2533
+ }
2534
+ &:active {
2535
+ background-color: ${u.color.background700};
2536
+ }
2537
+ `}
2538
+
2539
+ &:focus {
2540
+ outline: none;
2541
+ }
2542
+ `, qn = () => {
2543
+ const { chatSDK: e } = N(), { channelSource: t } = Y(), [n, o] = C([]);
2544
+ return hn(e, {
2545
+ onTypingStatusUpdated(i) {
2546
+ var s;
2547
+ if (i.url === ((s = t.channel) == null ? void 0 : s.url)) {
2548
+ const a = i.getTypingUsers();
2549
+ o(a);
2550
+ }
2551
+ }
2552
+ }), n;
2553
+ }, gl = () => {
2554
+ const { agentPreviewConfigs: e = {}, aiAgentId: t } = N(), { aiAgentInfo: n } = F(), { stringSet: o, dateLocale: i } = M(), { messageSource: s } = Y(), { Template: a } = ve.useContext(), l = e.welcomeMessages ?? [], d = s.messages, g = Na(d, t), m = d[g.length + 1], p = g[0] ?? m;
2555
+ return {
2556
+ /**
2557
+ * Returns a list of messages filtered according to business requirements.
2558
+ */
2559
+ filteredMessages: d.filter((h) => Ba(h) ? !1 : l.length > 0 ? !wt.isWelcomeMessage(h, t) : !0),
2560
+ /**
2561
+ * Determines whether to display the DateSeparator in the data list by comparing it with the welcome messages from Bot Studio.
2562
+ */
2563
+ shouldShowOriginalDate: (h) => h > 0 || l.length === 0 ? !0 : m && !_r(m.createdAt, (p == null ? void 0 : p.createdAt) ?? 0),
2564
+ /**
2565
+ * Renders the list of welcome messages from Bot Studio.
2566
+ */
2567
+ renderAgentPreviewWelcomeMessages: () => l.length === 0 ? null : /* @__PURE__ */ r.createElement(r.Fragment, null, /* @__PURE__ */ r.createElement(
2568
+ Yn,
2569
+ {
2570
+ style: { margin: "16px 0" },
2571
+ date: p == null ? void 0 : p.createdAt,
2572
+ locale: i,
2573
+ formatString: o.DATE_FORMAT__MESSAGE_LIST__DATE_SEPARATOR
2574
+ }
2575
+ ), l.map((h, b) => {
2576
+ const x = b === l.length - 1, v = g.length !== d.length, f = l.length === 1 ? "single" : b === 0 ? "top" : x || v ? "bottom" : "middle";
2577
+ return /* @__PURE__ */ r.createElement(
2578
+ a,
2579
+ {
2580
+ messageType: "user",
2581
+ message: h.message,
2582
+ sender: n,
2583
+ groupType: f,
2584
+ createdAt: (p == null ? void 0 : p.createdAt) ?? Date.now(),
2585
+ extendedMessagePayload: { suggested_replies: h.suggestedReplies },
2586
+ suggestedRepliesDirection: e.suggestedRepliesDirection,
2587
+ suggestedRepliesVisible: x && !v,
2588
+ isBotMessage: !0,
2589
+ onClickSuggestedReply: async ({ reply: y }) => {
2590
+ s.sendUserMessage({ message: y });
2591
+ }
2592
+ }
2593
+ );
2594
+ }))
2595
+ };
2596
+ }, pl = (e) => c(e).withConfig({ shouldForwardProp: Hr });
2597
+ function hl(e) {
2598
+ var o;
2599
+ const t = "remove_powered_by", n = (o = e == null ? void 0 : e.appInfo) == null ? void 0 : o.applicationAttributes;
2600
+ return Array.isArray(n) && n.includes(t);
2601
+ }
2602
+ const fl = ({ style: e }) => {
2603
+ const { stringSet: t } = M(), { chatSDK: n } = N(), { isDashboardActionbookTester: o } = St();
2604
+ return hl(n) || o ? null : /* @__PURE__ */ r.createElement(bl, { variant: "caption2", style: e }, t.POWERED_BY + " ", /* @__PURE__ */ r.createElement(
2605
+ xl,
2606
+ {
2607
+ variant: "caption2",
2608
+ as: "a",
2609
+ href: "https://sendbird.com?utm_medium=product&utm_source=aiagent&utm_campaign=fy26-glbl-ai-agent-poweredby",
2610
+ "aria-label": "Learn more about Sendbird",
2611
+ rel: ht,
2612
+ target: "_blank"
2613
+ },
2614
+ "Sendbird"
2615
+ ));
2616
+ }, bl = c(S)`color:${u.themedColor.textLowEmphasis};text-align:center;`, xl = pl(S)`
2617
+ color: ${u.themedColor.textLowEmphasis};
2618
+ cursor: pointer;
2619
+ text-decoration: none;
2620
+ `, El = () => {
2621
+ var d;
2622
+ const { stringSet: e } = M(), { activeChannel: t } = F(), { channelSource: n, goToActiveConversation: o, scrollSource: i } = Y(), s = Ln(n.channel), l = t && ((d = n.channel) == null ? void 0 : d.url) === (t == null ? void 0 : t.url) && s;
2623
+ return ge(() => {
2624
+ l && i.scrollPubSub.publish({ type: "scrollToBottom", data: { animated: !0 } });
2625
+ }, [l]), l ? /* @__PURE__ */ r.createElement(vl, null, /* @__PURE__ */ r.createElement(
2626
+ yl,
2627
+ {
2628
+ variant: "button",
2629
+ role: "button",
2630
+ color: u.themedColor.textHighEmphasis,
2631
+ onClick: () => o()
2632
+ },
2633
+ e.START_NEW_CONVERSATION
2634
+ )) : null;
2635
+ }, vl = c.div`display:flex;justify-content:center;margin:16px 0;`, yl = c(S)`border-radius:6px;box-sizing:border-box;padding:10px 20px;border:1px solid ${u.themedColor.textDisabled};cursor:pointer;user-select:none;`, Cl = !0, Tl = () => {
2636
+ const { Template: e } = Tt.useContext(), { Template: t } = ve.useContext(), { Template: n } = _t.useContext(), [o, i] = C(null), { userSession: s, aiAgentInfo: a } = F(), { agentPreviewConfigs: l, chatSDK: d, state: g } = N(), { stringSet: m, dateLocale: p } = M(), { conversation: h, channelSource: b, messageSource: x, scrollSource: v } = Y(), { isDashboardActionbookTester: f } = St(), { filteredMessages: y, shouldShowOriginalDate: _, renderAgentPreviewWelcomeMessages: w } = gl(), { storage: O } = Tn(), ee = qn(), H = Ct(() => {
2637
+ const E = ee[0];
2638
+ return E ? E.userId === a.userId ? a : E : null;
2639
+ });
2640
+ R(() => {
2641
+ H && setTimeout(() => v.scrollPubSub.publish({ type: "scrollToBottom", data: { animated: !0 } }), 25);
2642
+ }, [!!H, v]);
2643
+ const le = (E, U = !1) => {
2644
+ var te;
2645
+ return U ? a : ((te = b.channel) == null ? void 0 : te.members.find((G) => G.userId === E.sender.userId)) ?? E.sender;
2646
+ }, _e = () => {
2647
+ if (!x.initialized)
2648
+ return /* @__PURE__ */ r.createElement(Ee, { type: "loading" });
2649
+ if (x.messages.length === 0) {
2650
+ const E = w();
2651
+ return E ? /* @__PURE__ */ r.createElement("div", { style: { width: "100%" } }, E) : /* @__PURE__ */ r.createElement(Ee, { type: "noMessages", label: m.PLACE_HOLDER__NO_MESSAGES });
2652
+ }
2653
+ return /* @__PURE__ */ r.createElement(
2654
+ il,
2655
+ {
2656
+ ref: v.scrollRef,
2657
+ scrollPositionRef: v.scrollPositionRef,
2658
+ scrollDistanceFromBottomRef: v.scrollDistanceFromBottomRef,
2659
+ onScrollPosition: (E) => v.setIsScrollBottomReached(E === "bottom"),
2660
+ stackDirection: l == null ? void 0 : l.messageStackDirection,
2661
+ messages: y,
2662
+ onLoadPrev: x.loadPrevious,
2663
+ onLoadNext: x.loadNext,
2664
+ depsForResetScrollPositionToBottom: [x.initialized, x.messages.length !== 0],
2665
+ messageTopArea: /* @__PURE__ */ r.createElement(r.Fragment, null, /* @__PURE__ */ r.createElement(fl, { style: { marginTop: 16 } }), w()),
2666
+ messageBottomArea: /* @__PURE__ */ r.createElement(r.Fragment, null, H && /* @__PURE__ */ r.createElement(
2667
+ t,
2668
+ {
2669
+ isTyping: !0,
2670
+ sender: H,
2671
+ messageType: "user",
2672
+ groupType: "single",
2673
+ message: ""
2674
+ }
2675
+ ), /* @__PURE__ */ r.createElement(El, null)),
2676
+ overlayArea: /* @__PURE__ */ r.createElement(r.Fragment, null, !v.isScrollBottomReached && /* @__PURE__ */ r.createElement(Sl, { onClick: () => v.scrollPubSub.publish({ type: "scrollToBottom" }) })),
2677
+ renderMessage: ({ message: E, index: U }) => {
2678
+ const te = La(E), G = y[U - 1], Xe = y[U + 1], I = y[y.length - 1], A = E === I, L = Ra(E, G, Xe, Cl), j = !Rr((G == null ? void 0 : G.createdAt) ?? 0, E.createdAt) && _(U) && !f, fe = () => {
2679
+ E.isFileMessage() && i(E);
2680
+ }, Se = () => {
2681
+ E.isFileMessage() && On(E.url);
2682
+ }, K = j ? /* @__PURE__ */ r.createElement(
2683
+ Yn,
2684
+ {
2685
+ style: { margin: "16px 0" },
2686
+ date: E.createdAt,
2687
+ locale: p,
2688
+ formatString: m.DATE_FORMAT__MESSAGE_LIST__DATE_SEPARATOR
2689
+ }
2690
+ ) : null, ne = {
2691
+ maxBodyWidth: g.expanded ? Nn : void 0,
2692
+ extendedMessagePayload: E.extendedMessagePayload,
2693
+ createdAt: E.createdAt,
2694
+ groupType: L,
2695
+ onClickMedia: fe,
2696
+ onClickFile: Se
2697
+ }, we = (() => {
2698
+ var ce, Mt;
2699
+ if (ze.isAdmin(E))
2700
+ return ze.isCSAT(E) ? h ? /* @__PURE__ */ r.createElement(
2701
+ n,
2702
+ {
2703
+ ...ne,
2704
+ ...h,
2705
+ isResolvedWhenDeterminedByUser: wl(h),
2706
+ messageType: "admin.csat",
2707
+ onSubmitCSAT: ({ csat: re, csatType: de, csatReason: V, isResolved: be }) => {
2708
+ var Ot;
2709
+ re && ((Ot = b.channel) == null || Ot.submitCSAT({ csat: re, csatType: de, csatReason: V, isResolved: be }));
2710
+ }
2711
+ }
2712
+ ) : null : /* @__PURE__ */ r.createElement(n, { ...ne, messageType: "admin", message: E.message });
2713
+ if (ze.isOutgoing(E, s.userId)) {
2714
+ const re = {
2715
+ ...ne,
2716
+ message: E.message,
2717
+ sender: le(E),
2718
+ sendingStatus: E.sendingStatus
2719
+ };
2720
+ if (E.isUserMessage())
2721
+ return /* @__PURE__ */ r.createElement(e, { messageType: "user", ...re });
2722
+ if (E.isFileMessage()) {
2723
+ const [de, V] = ((ce = E.metaArrays.find((be) => be.key === Mn)) == null ? void 0 : ce.value) ?? [];
2724
+ return /* @__PURE__ */ r.createElement(
2725
+ e,
2726
+ {
2727
+ messageType: "file",
2728
+ file: E,
2729
+ metadata: {
2730
+ aspectRatio: de && V ? `${de}/${V}` : "1/1",
2731
+ localFile: (Mt = E.messageParams) == null ? void 0 : Mt.file
2732
+ },
2733
+ ...re
2734
+ }
2735
+ );
2736
+ }
2737
+ }
2738
+ if (ze.isIncoming(E, s.userId)) {
2739
+ const re = E.sender.userId === a.userId, de = {
2740
+ ...ne,
2741
+ sender: le(E, re),
2742
+ message: E.message,
2743
+ suggestedRepliesVisible: A,
2744
+ suggestedRepliesDirection: l == null ? void 0 : l.suggestedRepliesDirection,
2745
+ isBotMessage: re,
2746
+ onClickSuggestedReply: async ({ reply: V }) => {
2747
+ x.sendUserMessage({ message: V });
2748
+ },
2749
+ onRequestMessageTemplate: async (V) => {
2750
+ const { template: be } = await d.aiAgent.getMessageTemplate(V);
2751
+ return O.setTemplate(V, be), be;
2752
+ },
2753
+ onGetCachedMessageTemplate: (V) => O.getTemplate(V)
2754
+ };
2755
+ if (E.isUserMessage())
2756
+ return /* @__PURE__ */ r.createElement(t, { messageType: "user", ...de });
2757
+ if (E.isFileMessage())
2758
+ return /* @__PURE__ */ r.createElement(t, { messageType: "file", file: E, ...de });
2759
+ }
2760
+ })();
2761
+ return /* @__PURE__ */ r.createElement("div", { key: te, id: `${Z}-message-item` }, K, we);
2762
+ }
2763
+ }
2764
+ );
2765
+ };
2766
+ return /* @__PURE__ */ r.createElement(_l, { id: `${Z}-message-list` }, _e(), o && /* @__PURE__ */ r.createElement(tl, { onClose: () => i(null), message: o }));
2767
+ }, _l = c.div`overflow-y:hidden;display:flex;flex:1;position:relative;`, Sl = c(ul)`position:absolute;bottom:20px;inset-inline-end:20px;`;
2768
+ function wl(e) {
2769
+ var t;
2770
+ if (((t = e == null ? void 0 : e.resolution) == null ? void 0 : t.determinedBy) === "user")
2771
+ return e.resolution.isResolved;
2772
+ }
2773
+ const kl = () => {
2774
+ const { stringSet: e } = M(), { connectionError: t } = F(), { channelSource: n } = Y(), o = t || n.error;
2775
+ if (o) {
2776
+ const i = t ? void 0 : { label: e.RETRY, onClick: () => n.refetch() };
2777
+ return /* @__PURE__ */ r.createElement(Ee, { type: "error", label: o.message, action: i });
2778
+ }
2779
+ return n.channel ? /* @__PURE__ */ r.createElement(Tl, null) : /* @__PURE__ */ r.createElement(Ee, { type: "loading" });
2780
+ }, Jn = () => {
2781
+ const { stringSet: e } = M(), { activeChannel: t } = F(), [n] = C(() => (t == null ? void 0 : t.status) === z.OPEN);
2782
+ return n ? e.RETURN_TO_CONVERSATION : e.START_NEW_CONVERSATION;
2783
+ }, Al = () => {
2784
+ const { stringSet: e } = M(), { goToActiveConversation: t } = Y(), n = Jn();
2785
+ return /* @__PURE__ */ r.createElement(Il, null, /* @__PURE__ */ r.createElement(S, { variant: "body1", color: u.themedColor.textMidEmphasis }, e.CONVERSATION_CLOSED_FOOTER_LABEL), /* @__PURE__ */ r.createElement($l, { onClick: t }, /* @__PURE__ */ r.createElement(S, { variant: "button", color: u.themedColor.textHighEmphasis }, n)));
2786
+ }, Il = c.div`display:flex;flex-direction:column;align-items:center;justify-content:center;padding:32px 0;gap:14px;${B.light`
2787
+ background-color: ${u.color.background100};
2788
+ `}
2789
+ ${B.dark`
2790
+ background-color: ${u.color.background500};
2791
+ `}
2792
+ `, $l = c.button`all:unset;padding:10px 20px;border-radius:6px;border:1px solid ${u.themedColor.textDisabled};cursor:pointer;${B.light`
2793
+ background-color: ${u.color.background50};
2794
+ `}
2795
+ ${B.dark`
2796
+ background-color: ${u.color.background700};
2797
+ `}
2798
+ `, Xn = ye(void 0), Ml = ({ children: e }) => {
2799
+ const { stringSet: t } = M(), { aiAgentInfo: n } = F(), [o, i] = C([]), [s, a] = C({
2800
+ visible: !1,
2801
+ title: "",
2802
+ buttonText: t.BUTTON__OK
2803
+ }), l = n == null ? void 0 : n.replyToFile, d = (p) => {
2804
+ if (!l) return;
2805
+ const h = p.filter((b) => An.includes(b.type));
2806
+ if (h.length !== 0) {
2807
+ if (h.some((b) => b.size > Xo)) {
2808
+ a((b) => ({
2809
+ ...b,
2810
+ visible: !0,
2811
+ title: t.FILE_UPLOAD_NOTIFICATION__SIZE_LIMIT.replace("%d", "25")
2812
+ }));
2813
+ return;
2814
+ }
2815
+ if (h.length > 1 || h.length > 0 && o.length > 0) {
2816
+ a((b) => ({
2817
+ ...b,
2818
+ visible: !0,
2819
+ title: t.FILE_UPLOAD_NOTIFICATION__COUNT_LIMIT
2820
+ }));
2821
+ return;
2822
+ }
2823
+ i((b) => [
2824
+ ...b,
2825
+ ...h.map((x) => ({
2826
+ file: x,
2827
+ preview: { url: URL.createObjectURL(x), type: x.type, name: x.name }
2828
+ }))
2829
+ ]);
2830
+ }
2831
+ }, g = (p) => {
2832
+ i((h) => {
2833
+ var x;
2834
+ const b = (x = h[p]) == null ? void 0 : x.preview;
2835
+ return b && URL.revokeObjectURL(b.url), h.filter((v, f) => f !== p);
2836
+ });
2837
+ }, m = () => {
2838
+ i((p) => (p.forEach((h) => URL.revokeObjectURL(h.preview.url)), []));
2839
+ };
2840
+ return /* @__PURE__ */ r.createElement(
2841
+ Xn.Provider,
2842
+ {
2843
+ value: {
2844
+ files: o,
2845
+ addFiles: d,
2846
+ removeFile: g,
2847
+ clearFiles: m,
2848
+ isFileUploadEnabled: l
2849
+ }
2850
+ },
2851
+ e,
2852
+ /* @__PURE__ */ r.createElement(Ol, { ...s, onClose: () => a((p) => ({ ...p, visible: !1, title: "" })) })
2853
+ );
2854
+ }, kt = () => {
2855
+ const e = J(Xn);
2856
+ if (!e)
2857
+ throw new Error("useFileUpload must be used within FileUploadProvider");
2858
+ return e;
2859
+ }, Ol = ({
2860
+ title: e,
2861
+ buttonText: t,
2862
+ visible: n,
2863
+ onClose: o
2864
+ }) => /* @__PURE__ */ r.createElement(Kn, { rootElementId: X.WINDOW, visible: n, onClose: o }, /* @__PURE__ */ r.createElement(Ll, null, /* @__PURE__ */ r.createElement(Nl, null, /* @__PURE__ */ r.createElement(S, { variant: "h1", color: u.themedColor.textHighEmphasis }, e)), /* @__PURE__ */ r.createElement(Rl, null, /* @__PURE__ */ r.createElement(Dl, { onClick: o }, /* @__PURE__ */ r.createElement(S, { variant: "button", color: u.themedColor.textHighEmphasisInverse }, t))))), Ll = c.div`width:100%;height:auto;padding-block:18px 24px;padding-inline:24px;margin:0 auto;border-radius:4px;box-sizing:border-box;background-color:${({ theme: e }) => e.colors.base.modalContentBackground};`, Rl = c.div`display:flex;flex-direction:row;justify-content:flex-end;`, Nl = c.div`margin-bottom:16px;`, Dl = c.button`display:flex;justify-content:center;align-items:center;border-radius:4px;cursor:pointer;background-color:${u.themedColor.error};border:1px solid ${u.themedColor.error};padding:10px 16px;&:hover{background-color:${u.color.error.dark};border-color:${u.color.error.dark};}&:active{background-color:${u.color.error.extraDark};}`;
2865
+ function Bl({ blurred: e, elementRef: t, document: n = window.document }) {
2866
+ const o = D(!1);
2867
+ e && t.current && n.activeElement === t.current && (o.current = !0), ge(() => {
2868
+ var i;
2869
+ !e && o.current && ((i = t.current) == null || i.focus(), o.current = !1);
2870
+ }, [e]);
2871
+ }
2872
+ const Pl = c.div`&::-webkit-scrollbar{display:none;}overflow-x:auto;display:flex;flex-direction:row;gap:10px;padding:8px 16px;background-color:transparent;`, Fl = c.div`display:flex;flex-shrink:0;position:relative;margin-block-start:8px;border-radius:12px;height:64px;img{border-radius:12px;object-fit:cover;width:64px;-webkit-user-drag:none;}`, Hl = c.div`display:flex;align-items:center;justify-content:center;position:absolute;inset-inline-end:-8px;inset-block-start:-8px;cursor:pointer;border-radius:50%;${B.light`
2873
+ background-color: ${u.color.background50};
2874
+ `}
2875
+ ${B.dark`
2876
+ background-color: ${u.color.background500};
2877
+ `}
2878
+ path {
2879
+ fill: ${u.themedColor.textMidEmphasis};
2880
+ }
2881
+
2882
+ &:hover {
2883
+ path {
2884
+ fill: ${u.themedColor.textHighEmphasis};
2885
+ }
2886
+ }
2887
+
2888
+ circle {
2889
+ stroke: ${u.themedColor.bg_50_600};
2890
+ }
2891
+ `, Ul = () => {
2892
+ const e = Le(), [t, n] = C(), { files: o, removeFile: i, isFileUploadEnabled: s } = kt();
2893
+ return !s || o.length === 0 ? null : /* @__PURE__ */ r.createElement(Pl, null, o.map(({ preview: { type: a, name: l, url: d } }, g) => /* @__PURE__ */ r.createElement(Fl, { key: d, onMouseOver: () => n(g), onMouseLeave: () => n(void 0) }, (e || t === g) && /* @__PURE__ */ r.createElement(Hl, { title: "Remove file", onClick: () => i(g) }, /* @__PURE__ */ r.createElement($, { type: "close-filled", color: u.themedColor.textMidEmphasis })), a.startsWith("image/") ? /* @__PURE__ */ r.createElement("img", { alt: "file-image", src: d }) : /* @__PURE__ */ r.createElement(Et, { name: l, type: xt(l, a) }))));
2894
+ }, zl = ({ channel: e, messages: t }) => {
2895
+ const { stringSet: n } = M(), { aiAgentInfo: o } = F(), i = Wl(), s = Vl({
2896
+ lastMessage: t[t.length - 1],
2897
+ aiAgentUserId: o.userId
2898
+ });
2899
+ return !e || !i || Ln(e) ? [!0, n.MESSAGE_INPUT__PLACE_HOLDER__DISABLED] : s ? [!0, n.MESSAGE_INPUT__PLACE_HOLDER__WAIT_AI_AGENT_RESPONSE] : [!1, n.MESSAGE_INPUT__PLACE_HOLDER];
2900
+ }, Wl = () => {
2901
+ const e = un(), { chatSDK: t } = N(), [n, o] = C(!0);
2902
+ return R(() => {
2903
+ const i = new dt({
2904
+ onDisconnected: () => o(!1),
2905
+ onConnected: () => o(!0),
2906
+ onReconnectSucceeded: () => o(!0)
2907
+ });
2908
+ return t.addConnectionHandler(e, i), () => {
2909
+ t.removeConnectionHandler(e);
2910
+ };
2911
+ }, [t]), n;
2912
+ }, Vl = ({
2913
+ lastMessage: e,
2914
+ aiAgentUserId: t
2915
+ }) => {
2916
+ const [n, o] = C(!1), i = qn();
2917
+ return R(() => {
2918
+ if (!e) return;
2919
+ const s = i.some((l) => l.userId === t), a = Vn(e, t) && wt.isStreaming(e);
2920
+ o(!!(a || s));
2921
+ }, [i, e, t]), n;
2922
+ }, Qn = {
2923
+ textArea: k`min-height:40px;height:40px;font-size:16px;line-height:24px;`,
2924
+ attachIcon: k`margin-bottom:4px;`
2925
+ }, er = c.button`all:unset;cursor:pointer;display:flex;align-items:center;justify-content:center;width:32px;height:32px;`, Gl = c(er)`flex-shrink:0;margin-inline-end:12px;margin-bottom:2px;&:disabled{cursor:not-allowed;}&:not(:disabled){&:hover{path{fill:${u.themedColor.textHighEmphasis};}}&:active{border-radius:4px;background-color:${u.themedColor.bg_200_400};}}${pt && Qn.attachIcon};`, jl = c.input`display:none;`, en = c.div`width:100%;position:relative;background-color:${u.themedColor.bg_100_500};border-radius:20px;`, tn = c.div`display:flex;flex-direction:row;align-items:flex-end;position:relative;`, nn = c.textarea`all:unset;display:block;flex:1;min-width:0;padding-top:8px;padding-bottom:8px;padding-inline-start:16px;padding-inline-end:12px;box-sizing:border-box;font-size:14px;line-height:20px;color:${u.themedColor.textHighEmphasis};resize:none;width:100%;height:${kn}px;overflow-wrap:break-word;white-space:pre-wrap;overflow-x:hidden;${pt && Qn.textArea};&::placeholder{color:${u.themedColor.textLowEmphasis};}&:disabled{cursor:not-allowed;&::placeholder{color:${u.themedColor.textDisabled};}}`, rn = c.div`padding:12px 16px;position:relative;display:flex;align-items:center;`, on = ({ disabled: e }) => {
2926
+ const t = D(null), { addFiles: n, clearFiles: o, files: i, isFileUploadEnabled: s } = kt();
2927
+ return !s || i.length > 0 ? null : /* @__PURE__ */ r.createElement(
2928
+ Gl,
2929
+ {
2930
+ disabled: e,
2931
+ onClick: () => {
2932
+ var a;
2933
+ o(), (a = t.current) == null || a.click();
2934
+ }
2935
+ },
2936
+ /* @__PURE__ */ r.createElement(
2937
+ $,
2938
+ {
2939
+ type: "attach",
2940
+ color: e ? u.themedColor.textDisabled : u.themedColor.textMidEmphasis,
2941
+ size: 16
2942
+ }
2943
+ ),
2944
+ /* @__PURE__ */ r.createElement(
2945
+ jl,
2946
+ {
2947
+ type: "file",
2948
+ ref: t,
2949
+ onChange: (a) => {
2950
+ const l = a.currentTarget.files;
2951
+ l && n(Array.from(l)), a.target.value = "";
2952
+ },
2953
+ accept: An.join(",")
2954
+ }
2955
+ )
2956
+ );
2957
+ }, Kl = () => {
2958
+ const e = D(null), [t, n] = C(""), { rootElement: o } = N(), { channelSource: i, messageSource: s } = Y(), [a, l] = zl({
2959
+ channel: i.channel,
2960
+ messages: s.messages
2961
+ }), { files: d, addFiles: g, clearFiles: m } = kt();
2962
+ fi({ onDropFiles: g }), Bl({ blurred: a, elementRef: e, document: pe(o) });
2963
+ const p = t.trim().length > 0, h = d.length > 0, b = !a && (p || h), x = () => {
2964
+ e.current && (e.current.value = "", e.current.style.height = ""), m(), n("");
2965
+ }, v = async () => {
2966
+ const w = t.trim(), O = { message: w };
2967
+ if (!(!w && !d.length)) {
2968
+ if (d.length > 0) {
2969
+ const ee = d[0].file, H = { ...O, file: ee };
2970
+ s.sendFileMessage(H), x();
2971
+ return;
2972
+ }
2973
+ s.sendUserMessage(O), x();
2974
+ }
2975
+ }, f = (w) => {
2976
+ const O = Array.from(w.clipboardData.files);
2977
+ O.length > 0 && (w.preventDefault(), g(O));
2978
+ }, y = (w) => {
2979
+ w.key !== "Enter" || w.nativeEvent.isComposing || w.shiftKey || (w.preventDefault(), v());
2980
+ }, _ = (w) => {
2981
+ if (e.current) {
2982
+ e.current.style.height = "";
2983
+ const O = Math.min(Jo, e.current.scrollHeight);
2984
+ kn < O && (e.current.style.height = `${O}px`);
2985
+ }
2986
+ n(w.target.value);
2987
+ };
2988
+ return a ? /* @__PURE__ */ r.createElement(rn, null, /* @__PURE__ */ r.createElement(en, null, /* @__PURE__ */ r.createElement(tn, null, /* @__PURE__ */ r.createElement(nn, { disabled: !0, placeholder: l }), /* @__PURE__ */ r.createElement(on, { disabled: !0 })))) : /* @__PURE__ */ r.createElement(rn, null, /* @__PURE__ */ r.createElement(en, null, /* @__PURE__ */ r.createElement(Ul, null), /* @__PURE__ */ r.createElement(tn, null, /* @__PURE__ */ r.createElement(
2989
+ nn,
2990
+ {
2991
+ ref: e,
2992
+ role: "textbox",
2993
+ "aria-label": "Text Input",
2994
+ placeholder: l,
2995
+ maxLength: 5e3,
2996
+ onKeyDown: y,
2997
+ onChange: _,
2998
+ onPaste: f
2999
+ }
3000
+ ), /* @__PURE__ */ r.createElement(on, null))), b && /* @__PURE__ */ r.createElement(er, { onClick: () => v() }, /* @__PURE__ */ r.createElement($, { type: "send", color: u.color.primary.main, size: 20 })));
3001
+ }, Zl = c.div`padding:8px 16px;text-align:center;word-break:break-word;white-space:pre-wrap;line-height:1.43;letter-spacing:-0.2px;font-size:14px;font-weight:400;color:${u.themedColor.textLowEmphasis};&& a{font-weight:700;text-decoration:none;${B.light`
3002
+ color: ${u.color.information.light};
3003
+ `};
3004
+ ${B.dark`
3005
+ color: ${u.color.information.main};
3006
+ `};
3007
+ }
3008
+ `, Yl = T(() => import("./BvhxxGUf.js").then((e) => ({ default: e.MarkdownText }))), ql = () => {
3009
+ const { aiAgentInfo: e } = F(), { messageSource: t } = Y(), { userSession: n } = F();
3010
+ return !e.specialNoticeEnabled || !e.specialNotice || !(t.initialized && !t.messages.some((i) => Vn(i, n.userId))) ? null : /* @__PURE__ */ r.createElement(Zl, null, /* @__PURE__ */ r.createElement(Yl, null, e.specialNotice));
3011
+ }, Jl = () => /* @__PURE__ */ r.createElement(Xl, null, /* @__PURE__ */ r.createElement(ql, null), /* @__PURE__ */ r.createElement(Ml, null, /* @__PURE__ */ r.createElement(Kl, null))), Xl = c.div`z-index:0;border:none;width:100%;`, Ql = () => {
3012
+ var s, a, l;
3013
+ const { activeChannel: e } = F(), { channelSource: t } = Y(), n = ((a = (s = t.channel) == null ? void 0 : s.conversation) == null ? void 0 : a.status) === z.CLOSED;
3014
+ return !(((l = t.channel) == null ? void 0 : l.url) === (e == null ? void 0 : e.url)) && n ? /* @__PURE__ */ r.createElement(Al, null) : /* @__PURE__ */ r.createElement(Jl, null);
3015
+ }, ec = () => {
3016
+ var _;
3017
+ const { state: e, logger: t, enableCloseConversationButton: n, enableExpandButton: o, dispatcher: i } = N(), { stringSet: s } = M(), { aiAgentInfo: a, activeChannel: l } = F(), { channelSource: d, onNavigateToConversationList: g } = Y(), m = d.channel, h = Le() ? 24 : 16, b = () => {
3018
+ e.setOpened(!1);
3019
+ }, x = async () => {
3020
+ try {
3021
+ const w = await (m == null ? void 0 : m.markConversationAsHandoff());
3022
+ t.info("conversation.handleAgentHandoff: success", w);
3023
+ } catch (w) {
3024
+ t.error("conversation.handleAgentHandoff: error", w);
3025
+ }
3026
+ }, v = async () => {
3027
+ m && await i.send(Jr.CloseConversation());
3028
+ }, f = l && (m == null ? void 0 : m.url) === l.url, y = a.showHandoffButton && !!((_ = m == null ? void 0 : m.conversation) != null && _.handoff) && f;
3029
+ return /* @__PURE__ */ r.createElement(ic, null, /* @__PURE__ */ r.createElement(sc, null, g && /* @__PURE__ */ r.createElement(Ne, { onClick: () => g() }, /* @__PURE__ */ r.createElement($, { type: "menu", size: 24, color: u.themedColor.textHighEmphasis })), f && /* @__PURE__ */ r.createElement(Zn, { size: 34 }), /* @__PURE__ */ r.createElement(lc, { variant: "h2", color: u.themedColor.textHighEmphasis }, a.nickname || (m == null ? void 0 : m.name))), /* @__PURE__ */ r.createElement(ac, null, y && /* @__PURE__ */ r.createElement(
3030
+ oc,
3031
+ {
3032
+ tooltipLabel: s.HEADER_BUTTON__AGENT_HANDOFF,
3033
+ disabled: !hi(m),
3034
+ size: h,
3035
+ onClick: x
3036
+ }
3037
+ ), n && /* @__PURE__ */ r.createElement(
3038
+ rc,
3039
+ {
3040
+ disabled: !Rn(m),
3041
+ size: h,
3042
+ onClick: v
3043
+ }
3044
+ ), o && /* @__PURE__ */ r.createElement(tc, { size: h }), /* @__PURE__ */ r.createElement(nc, { size: h, onClick: b })));
3045
+ }, tc = ({ size: e, disabled: t }) => {
3046
+ const { state: n } = N();
3047
+ return /* @__PURE__ */ r.createElement(Ne, { "aria-label": "expand", onClick: () => n.setExpanded(!n.expanded), disabled: t }, /* @__PURE__ */ r.createElement($, { type: n.expanded ? "collapse" : "expand", size: e, color: u.themedColor.textHighEmphasis }));
3048
+ }, nc = ({ size: e, disabled: t, onClick: n }) => /* @__PURE__ */ r.createElement(Ne, { "aria-label": "close messenger", onClick: n, disabled: t }, /* @__PURE__ */ r.createElement($, { type: "close", size: e, color: u.themedColor.textHighEmphasis })), rc = ({ size: e, disabled: t, onClick: n }) => /* @__PURE__ */ r.createElement(Ne, { "aria-label": "close conversation", onClick: n, disabled: t }, /* @__PURE__ */ r.createElement(
3049
+ $,
3050
+ {
3051
+ type: "refresh",
3052
+ size: e,
3053
+ color: t ? u.themedColor.textDisabled : u.themedColor.textHighEmphasis
3054
+ }
3055
+ )), oc = ({ size: e, onClick: t, disabled: n, tooltipLabel: o }) => /* @__PURE__ */ r.createElement(zn, { label: o, position: "bottom", disabled: n }, /* @__PURE__ */ r.createElement(Ne, { "aria-label": "agent", onClick: t, disabled: n }, /* @__PURE__ */ r.createElement(
3056
+ $,
3057
+ {
3058
+ type: "agent",
3059
+ size: e,
3060
+ color: n ? u.themedColor.textDisabled : u.themedColor.textHighEmphasis
3061
+ }
3062
+ ))), ic = c.div`height:56px;box-sizing:border-box;display:flex;align-items:center;padding:11px 12px;border-bottom:1px solid ${u.themedColor.textDisabled};background-color:${({ theme: e }) => e.colors.base.headerBackground};`, sc = c.div`display:flex;flex:1;flex-direction:row;align-items:center;gap:6px;overflow:hidden;`, ac = c.div`display:flex;gap:10px;align-items:center;justify-content:center;`, lc = c(S)`text-overflow:ellipsis;overflow:hidden;white-space:nowrap;padding:2px 0;`, Ne = c.button`all:unset;padding:4px;cursor:pointer;display:flex;align-items:center;justify-content:center;&:disabled{cursor:not-allowed;}`, cc = () => {
3063
+ const { isDashboardActionbookTester: e } = St();
3064
+ return e ? null : /* @__PURE__ */ r.createElement(ec, null);
3065
+ }, sn = ({
3066
+ children: e,
3067
+ onNavigateToConversationList: t,
3068
+ closedChannelUrl: n,
3069
+ onClearClosedChannelUrl: o
3070
+ }) => {
3071
+ const { Template: i } = At.useContext();
3072
+ return /* @__PURE__ */ r.createElement(
3073
+ pi,
3074
+ {
3075
+ onNavigateToConversationList: t,
3076
+ closedChannelUrl: n,
3077
+ onClearClosedChannelUrl: o
3078
+ },
3079
+ /* @__PURE__ */ r.createElement(lt, null, /* @__PURE__ */ r.createElement(lt.Consumer, null, (s) => /* @__PURE__ */ r.createElement(r.Fragment, null, /* @__PURE__ */ r.createElement(uc, { ...s }, /* @__PURE__ */ r.createElement(i, null)), e)))
3080
+ );
3081
+ }, At = Ce({
3082
+ template: dc,
3083
+ components: {
3084
+ Header: cc,
3085
+ Body: kl,
3086
+ Footer: Ql
3087
+ }
3088
+ });
3089
+ function dc() {
3090
+ const { components: e } = At.useContext();
3091
+ return /* @__PURE__ */ r.createElement(r.Fragment, null, /* @__PURE__ */ r.createElement(e.Header, null), /* @__PURE__ */ r.createElement(e.Body, null), /* @__PURE__ */ r.createElement(e.Footer, null));
3092
+ }
3093
+ const uc = c.div`height:100%;width:100%;display:flex;flex-direction:column;flex:1;background-color:${({ theme: e }) => e.colors.base.background};`, {
3094
+ Provider: mc,
3095
+ useContext: tr
3096
+ } = W("ConversationList");
3097
+ function gc({
3098
+ onOpenConversationView: e = Ge,
3099
+ children: t
3100
+ }) {
3101
+ return /* @__PURE__ */ r.createElement(ro, null, (n) => /* @__PURE__ */ r.createElement(mc, { value: { ...n, onOpenConversationView: e } }, t));
3102
+ }
3103
+ const nr = Ce({
3104
+ template: pc,
3105
+ // Note: 리스트 변경되면 디자인 변경 가능성이 있어서 일단 컴포넌트는 비워둠
3106
+ components: {}
3107
+ });
3108
+ function pc({
3109
+ title: e = "",
3110
+ lastMessageTimestamp: t = Date.now(),
3111
+ onClick: n
3112
+ }) {
3113
+ const { stringSet: o, format: i } = M();
3114
+ return /* @__PURE__ */ r.createElement(hc, { role: "button", onClick: () => n == null ? void 0 : n() }, /* @__PURE__ */ r.createElement(bc, null, /* @__PURE__ */ r.createElement(xc, null, /* @__PURE__ */ r.createElement(S, { variant: "subtitle1", color: u.themedColor.textHighEmphasis }, i(t, o.DATE_FORMAT__CONVERSATION_LIST__LIST_ITEM_TITLE)), /* @__PURE__ */ r.createElement(S, { variant: "caption2", color: u.themedColor.textLowEmphasis }, i(t, o.DATE_FORMAT__CONVERSATION_LIST__LIST_ITEM_TITLE_CAPTION))), /* @__PURE__ */ r.createElement(S, { variant: "body3", color: u.themedColor.textMidEmphasis }, e || o.CONVERSATION_LIST__TOPICS_FALLBACK)), /* @__PURE__ */ r.createElement($, { type: "chevron-right", size: 16, color: u.themedColor.textHighEmphasis }), /* @__PURE__ */ r.createElement(fc, null));
3115
+ }
3116
+ const hc = c.div`display:flex;flex-direction:row;align-items:center;position:relative;width:100%;padding:14px 16px;box-sizing:border-box;gap:4px;cursor:pointer;`, fc = c.div`position:absolute;bottom:0;height:1px;width:calc(100% - 32px);background-color:${u.themedColor.textDisabled};`, bc = c.div`gap:4px;display:flex;flex-direction:column;flex:1;`, xc = c.div`display:flex;justify-content:flex-start;align-items:center;gap:6px;`, Ec = ({ items: e, renderItem: t, onEndReached: n }) => {
3117
+ const o = (i) => {
3118
+ const s = i.target;
3119
+ s.scrollHeight - s.scrollTop === s.clientHeight && (n == null || n());
3120
+ };
3121
+ return /* @__PURE__ */ r.createElement(vc, { onScroll: (i) => o(i) }, e.map((i, s) => t(i, s)));
3122
+ }, vc = c.div`width:100%;height:100%;display:flex;flex-direction:column;flex:1;overflow:auto;`, yc = () => {
3123
+ const { stringSet: e } = M(), { listSource: t, onOpenConversationView: n } = tr(), { Template: o } = nr.useContext();
3124
+ return t.initialized ? t.conversations.length === 0 ? /* @__PURE__ */ r.createElement(Ee, { type: "noChannels", label: e.CONVERSATION_LIST__NO_CONVERSATIONS }) : /* @__PURE__ */ r.createElement(
3125
+ Ec,
3126
+ {
3127
+ items: t.conversations,
3128
+ renderItem: (i, s) => {
3129
+ var a;
3130
+ return /* @__PURE__ */ r.createElement(
3131
+ o,
3132
+ {
3133
+ key: s,
3134
+ channelUrl: i.channelInfo.url,
3135
+ title: (a = i.topics) == null ? void 0 : a.join(", "),
3136
+ lastMessageTimestamp: i.channelInfo.lastMessageTs,
3137
+ onClick: () => n(i.channelInfo.url, z.CLOSED)
3138
+ }
3139
+ );
3140
+ },
3141
+ onEndReached: () => {
3142
+ t.loadMore();
3143
+ }
3144
+ }
3145
+ ) : /* @__PURE__ */ r.createElement(Ee, { type: "loading" });
3146
+ }, Cc = () => {
3147
+ const { refreshActiveChannel: e } = F(), { onOpenConversationView: t } = tr(), n = Jn();
3148
+ return /* @__PURE__ */ r.createElement(
3149
+ Tc,
3150
+ {
3151
+ role: "button",
3152
+ onClick: async () => {
3153
+ const o = await e();
3154
+ t(o, z.OPEN);
3155
+ }
3156
+ },
3157
+ /* @__PURE__ */ r.createElement(_c, { variant: "h1" }, n)
3158
+ );
3159
+ }, Tc = c.div`background-color:${({ theme: e }) => e.colors.base.primary};display:flex;align-items:center;justify-content:center;padding:16px;cursor:pointer;`, _c = c(S)`color:${({ theme: e }) => e.colors.base.primaryContrastContent};overflow:hidden;text-overflow:ellipsis;white-space:nowrap;`, Sc = () => {
3160
+ const { stringSet: e } = M();
3161
+ return /* @__PURE__ */ r.createElement(wc, null, /* @__PURE__ */ r.createElement(kc, { variant: "h2", color: u.themedColor.textHighEmphasis }, e.CONVERSATION_LIST__HEADER_TITLE), /* @__PURE__ */ r.createElement(Ac, null));
3162
+ }, wc = c.div`display:flex;flex-direction:column;align-items:flex-start;justify-content:center;width:100%;flex-shrink:0;height:56px;position:relative;background-color:${({ theme: e }) => e.colors.base.headerBackground};`, kc = c(S)`padding:0 12px;width:100%;box-sizing:border-box;text-overflow:ellipsis;overflow:hidden;white-space:nowrap;`, Ac = c.div`position:absolute;bottom:0;width:100%;height:1px;background-color:${u.themedColor.textDisabled};`, Ic = ({ children: e, onOpenConversationView: t }) => {
3163
+ const { Template: n } = It.useContext();
3164
+ return /* @__PURE__ */ r.createElement(gc, { onOpenConversationView: t }, /* @__PURE__ */ r.createElement(Mc, null, /* @__PURE__ */ r.createElement(n, null)), e);
3165
+ }, It = Ce({
3166
+ template: $c,
3167
+ components: {
3168
+ Header: Sc,
3169
+ Body: yc,
3170
+ Footer: Cc
3171
+ }
3172
+ });
3173
+ function $c() {
3174
+ const { components: e } = It.useContext();
3175
+ return /* @__PURE__ */ r.createElement(r.Fragment, null, /* @__PURE__ */ r.createElement(e.Header, null), /* @__PURE__ */ r.createElement(e.Body, null), /* @__PURE__ */ r.createElement(e.Footer, null));
3176
+ }
3177
+ const Mc = c.div`height:100%;width:100%;display:flex;flex-direction:column;flex:1;background-color:${({ theme: e }) => e.colors.base.background};`, Oc = k`:where(#${X.ENTRY}) :not(code *){font-family:'Roboto',sans-serif;box-sizing:border-box;}`, Lc = [Oc, zo, Wo], Rc = (e, ...t) => Cr(e, ...Lc, ...t), Nc = Rc``, Dc = Ur(
3178
+ At,
3179
+ ve,
3180
+ Tt,
3181
+ _t,
3182
+ It,
3183
+ nr
3184
+ );
3185
+ function Bc({
3186
+ appearance: e,
3187
+ rootElement: t,
3188
+ logger: n,
3189
+ language: o,
3190
+ stringSet: i,
3191
+ children: s,
3192
+ messageTemplate: a,
3193
+ theme: l
3194
+ }) {
3195
+ return Yo(Oo, t), /* @__PURE__ */ r.createElement(Tr, { target: t }, /* @__PURE__ */ r.createElement(jo, { rootElement: t, logger: n, appearance: e, theme: l }, /* @__PURE__ */ r.createElement(So, { internalVariables: a == null ? void 0 : a.__internalVariables }, /* @__PURE__ */ r.createElement(Uo, { stringSet: i, logger: n, language: o }, /* @__PURE__ */ r.createElement(Dc, null, s, /* @__PURE__ */ r.createElement(Nc, null))))));
3196
+ }
3197
+ const an = {
3198
+ key_payment_plan_container: {
3199
+ color_variables: {},
3200
+ created_at: 1232,
3201
+ updated_at: 4563,
3202
+ key: "key_payment_plan_container",
3203
+ ui_template: {
3204
+ body: {
3205
+ items: [
3206
+ {
3207
+ carouselStyle: { maxChildWidth: 265, spacing: 10 },
3208
+ items: "{@templates}",
3209
+ type: "carouselView",
3210
+ viewStyle: { padding: { top: 0, bottom: 0, left: 50, right: 16 } }
3211
+ }
3212
+ ]
3213
+ },
3214
+ version: 2
3215
+ }
3216
+ },
3217
+ key_payment_plan: {
3218
+ color_variables: {},
3219
+ created_at: 123,
3220
+ updated_at: 456,
3221
+ key: "key_payment_plan",
3222
+ ui_template: {
3223
+ version: 1,
3224
+ body: {
3225
+ items: [
3226
+ {
3227
+ viewStyle: { radius: 16, backgroundColor: "#FFFFFF", borderWidth: "1", borderColor: "#E0E0E0" },
3228
+ width: { type: "fixed", value: "264" },
3229
+ height: { type: "fixed", value: "275" },
3230
+ type: "box",
3231
+ layout: "column",
3232
+ items: [
3233
+ {
3234
+ viewStyle: {
3235
+ padding: { left: 16, right: 16, top: 16, bottom: 16 },
3236
+ backgroundImageUrl: "https://storage-66w.pages.dev/carousel-bg.png"
3237
+ },
3238
+ action: { type: "web", data: "{action_url}" },
3239
+ type: "box",
3240
+ layout: "column",
3241
+ items: [
3242
+ {
3243
+ type: "text",
3244
+ text: "{header_plan}",
3245
+ textStyle: { size: 14, weight: "bold", color: "#FFFFFF" }
3246
+ },
3247
+ { type: "text", text: "{header_desc}", textStyle: { size: 12, color: "#FFFFFF" } }
3248
+ ]
3249
+ },
3250
+ {
3251
+ viewStyle: { padding: { left: 16, right: 16, top: 16, bottom: 16 } },
3252
+ action: { type: "web", data: "{action_url}" },
3253
+ type: "box",
3254
+ layout: "column",
3255
+ items: [
3256
+ { type: "text", text: "{price}", textStyle: { size: 20, weight: "bold" } },
3257
+ {
3258
+ viewStyle: { padding: { left: 0, right: 0, top: 16, bottom: 16 } },
3259
+ type: "box",
3260
+ layout: "column",
3261
+ items: [
3262
+ {
3263
+ viewStyle: { backgroundColor: "#E0E0E0" },
3264
+ width: { type: "flex", value: 0 },
3265
+ height: { type: "fixed", value: "1" },
3266
+ type: "box",
3267
+ layout: "column"
3268
+ }
3269
+ ]
3270
+ },
3271
+ {
3272
+ viewStyle: { margin: { bottom: 8, top: 0, left: 0, right: 0 } },
3273
+ type: "text",
3274
+ text: "{description}",
3275
+ textStyle: { size: 14, weight: "normal", color: "#7F7F7F" }
3276
+ }
3277
+ ]
3278
+ }
3279
+ ]
3280
+ }
3281
+ ]
3282
+ }
3283
+ }
3284
+ },
3285
+ key_content_preview: {
3286
+ color_variables: {},
3287
+ created_at: 1232,
3288
+ updated_at: 4563,
3289
+ key: "key_content_preview",
3290
+ ui_template: {
3291
+ version: 1,
3292
+ body: {
3293
+ items: [
3294
+ {
3295
+ viewStyle: {
3296
+ radius: 16,
3297
+ borderWidth: 1,
3298
+ borderColor: "#1F000000",
3299
+ backgroundColor: "#FFFFFF"
3300
+ },
3301
+ width: {
3302
+ type: "fixed",
3303
+ value: 264
3304
+ },
3305
+ action: { type: "web", data: "{action_url}" },
3306
+ type: "box",
3307
+ layout: "column",
3308
+ items: [
3309
+ {
3310
+ action: { type: "web", data: "{action_url}" },
3311
+ width: {
3312
+ type: "flex",
3313
+ value: 0
3314
+ },
3315
+ height: {
3316
+ type: "fixed",
3317
+ value: 200
3318
+ },
3319
+ type: "image",
3320
+ imageUrl: "{image}",
3321
+ imageStyle: {
3322
+ contentMode: "aspectFill"
3323
+ }
3324
+ },
3325
+ {
3326
+ action: { type: "web", data: "{action_url}" },
3327
+ viewStyle: {
3328
+ padding: {
3329
+ left: 16,
3330
+ right: 16,
3331
+ top: 16,
3332
+ bottom: 16
3333
+ }
3334
+ },
3335
+ type: "box",
3336
+ layout: "column",
3337
+ items: [
3338
+ {
3339
+ viewStyle: {
3340
+ margin: {
3341
+ bottom: 4,
3342
+ top: 0,
3343
+ left: 0,
3344
+ right: 0
3345
+ }
3346
+ },
3347
+ height: {
3348
+ type: "fixed",
3349
+ value: 16
3350
+ },
3351
+ type: "text",
3352
+ text: "{title}",
3353
+ maxTextLines: 1,
3354
+ textStyle: {
3355
+ size: 14,
3356
+ weight: "bold",
3357
+ color: "#000000"
3358
+ }
3359
+ },
3360
+ {
3361
+ height: {
3362
+ type: "fixed",
3363
+ value: 16
3364
+ },
3365
+ type: "text",
3366
+ text: "{release_date}",
3367
+ maxTextLines: 1,
3368
+ textStyle: {
3369
+ size: 14,
3370
+ weight: "normal",
3371
+ color: "#80000000"
3372
+ }
3373
+ }
3374
+ ]
3375
+ }
3376
+ ]
3377
+ }
3378
+ ]
3379
+ }
3380
+ }
3381
+ }
3382
+ };
3383
+ function rr({
3384
+ rootElement: e = document.body,
3385
+ logLevel: t = mn.WARN,
3386
+ language: n = navigator.language,
3387
+ userSessionInfo: o,
3388
+ children: i,
3389
+ ...s
3390
+ }) {
3391
+ var a;
3392
+ return xe.level !== t && (xe.level = t), Zo("https://fonts.googleapis.com/css2?family=Roboto&display=swap", e), /* @__PURE__ */ r.createElement("div", { id: X.ENTRY, style: { width: "fit-content", height: "fit-content" } }, /* @__PURE__ */ r.createElement(Co, { logger: xe, storage: Fc }, /* @__PURE__ */ r.createElement(
3393
+ Bc,
3394
+ {
3395
+ logger: xe,
3396
+ rootElement: e,
3397
+ appearance: (a = s.agentPreviewConfigs) == null ? void 0 : a.appearance,
3398
+ stringSet: s.stringSet,
3399
+ language: n,
3400
+ messageTemplate: s.messageTemplate,
3401
+ theme: s.theme
3402
+ },
3403
+ /* @__PURE__ */ r.createElement(
3404
+ Kr,
3405
+ {
3406
+ appId: s.appId,
3407
+ aiAgentId: s.aiAgentId,
3408
+ language: n,
3409
+ countryCode: s.countryCode,
3410
+ context: s.context,
3411
+ logger: xe,
3412
+ dispatcher: Pc,
3413
+ chatParams: { customApiHost: s.customApiHost, customWebSocketHost: s.customWebSocketHost }
3414
+ },
3415
+ /* @__PURE__ */ r.createElement(ti, { rootElement: e, ...s }, /* @__PURE__ */ r.createElement(ii, { userSessionInfo: o }, /* @__PURE__ */ r.createElement(
3416
+ wa,
3417
+ {
3418
+ isDashboardActionbookTester: s._UNSAFE_INTERNAL_isActionbookTester
3419
+ },
3420
+ i,
3421
+ /* @__PURE__ */ r.createElement("div", { id: X.MODAL_ROOT })
3422
+ )))
3423
+ )
3424
+ )));
3425
+ }
3426
+ const xe = new En(mn.WARN), Pc = new bn(xe), $t = "@sba/message-template", ln = (e) => `${$t}/templates/${e}`, cn = () => `${$t}/token`, Fc = vo({
3427
+ onSetTemplate: (e, t) => {
3428
+ an[e] || q.setItem(ln(e), t);
3429
+ },
3430
+ onGetTemplate: (e) => {
3431
+ const t = an[e];
3432
+ return t ? JSON.stringify(t) : q.getItem(ln(e));
3433
+ },
3434
+ onSetCachedToken(e) {
3435
+ q.setItem(cn(), e);
3436
+ },
3437
+ onGetCachedToken() {
3438
+ return q.getItem(cn());
3439
+ },
3440
+ onClear: () => {
3441
+ q.getKeys($t).forEach(q.deleteItem);
3442
+ }
3443
+ }), or = ({ children: e, isOpened: t }) => {
3444
+ const { dir: n, rootElement: o } = N(), i = pe(o, !0);
3445
+ return R(() => {
3446
+ const s = "sb-agent-block-scroll";
3447
+ return t ? i.body.classList.add(s) : i.body.classList.remove(s), () => {
3448
+ i.body.classList.remove(s);
3449
+ };
3450
+ }, [i, t]), /* @__PURE__ */ r.createElement(Hc, { dir: n, $visible: t }, e);
3451
+ }, Hc = c.div`width:100%;height:100%;position:fixed;top:0;left:0;z-index:${he.WINDOW};visibility:${({ $visible: e }) => e ? "visible" : "hidden"};`;
3452
+ function Uc({
3453
+ className: e,
3454
+ isOpened: t,
3455
+ onClick: n,
3456
+ type: o,
3457
+ imageUrl: i,
3458
+ dir: s,
3459
+ animated: a = !0,
3460
+ backgroundColor: l
3461
+ }) {
3462
+ const d = at(l);
3463
+ return /* @__PURE__ */ r.createElement(
3464
+ Vc,
3465
+ {
3466
+ dir: s,
3467
+ id: X.LAUNCHER,
3468
+ className: e,
3469
+ "aria-label": "Sendbird AIAgent Launcher",
3470
+ onClick: n,
3471
+ $animated: a,
3472
+ $backgroundColor: l
3473
+ },
3474
+ /* @__PURE__ */ r.createElement(Gc, { $isOpened: t, $animated: a, $fillColor: d }, /* @__PURE__ */ r.createElement(dn.Open, { url: i, isDefaultIcon: o === "default_icon" })),
3475
+ /* @__PURE__ */ r.createElement(jc, { $isOpened: t, $animated: a, $fillColor: d }, /* @__PURE__ */ r.createElement(dn.Close, null))
3476
+ );
3477
+ }
3478
+ const zc = k`&:hover{transition:transform 250ms cubic-bezier(0.33,0,0,1);transform:scale(1.1);}&:active{transform:scale(0.8);}`, Wc = k`img{width:100%;height:100%;object-fit:cover;user-select:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;-webkit-user-drag:none;&[data-default-icon='true']{width:32px;height:32px;filter:${({ $fillColor: e }) => e === wn.WHITE ? "grayscale(100%) brightness(2000%)" : "grayscale(100%) invert(100%) saturate(0%) brightness(0%) contrast(1000%)"};}}`, ir = k`svg{width:32px;height:32px;${({ $fillColor: e }) => k`
3479
+ path {
3480
+ fill: ${e};
3481
+ }
3482
+ [class*='fill'] {
3483
+ fill: ${e};
3484
+ }
3485
+ `}
3486
+ }
3487
+ `, Vc = c.button`position:relative;padding:0;width:48px;height:48px;background:${({ $backgroundColor: e }) => e};border-radius:50%;transition:all 0.3s cubic-bezier(0.31,-0.105,0.43,1.4);border:none;display:flex;justify-content:center;align-items:center;box-shadow:0 16px 24px 2px rgba(33,33,33,0.12),0 6px 30px 5px rgba(33,33,33,0.08),0 6px 10px -5px rgba(33,33,33,0.04);${({ $animated: e }) => e && zc}`, sr = c.span`position:absolute;width:100%;height:100%;border-radius:50%;overflow:hidden;transition:transform 0.16s linear,opacity 0.08s linear,scale 0.16s linear;user-select:none;display:flex;justify-content:center;align-items:center;`, Gc = c(sr)`opacity:${({ $isOpened: e }) => e ? 0 : 1};transform:${({ $animated: e, $isOpened: t }) => e && (t ? "rotate(-90deg) scale(0)" : "rotate(0deg)")};${Wc}${ir}`, jc = c(sr)`scale:${({ $isOpened: e }) => e ? 1 : 0};transform:${({ $animated: e, $isOpened: t }) => e && (t ? "rotate(0deg)" : "rotate(-90deg)")};${ir}`, dn = {
3488
+ Open: (e) => e.url ? /* @__PURE__ */ r.createElement("img", { src: e.url, alt: "launcher-img", "data-default-icon": e.isDefaultIcon }) : /* @__PURE__ */ r.createElement(vt, null),
3489
+ Close: () => /* @__PURE__ */ r.createElement($, { size: 32, type: "chevron-down" })
3490
+ };
3491
+ function ar({ className: e }) {
3492
+ const { colors: t } = ut(), { dir: n, state: o } = N(), { launcherInfo: i } = F();
3493
+ return Zc(), /* @__PURE__ */ r.createElement(
3494
+ Uc,
3495
+ {
3496
+ dir: n,
3497
+ className: e,
3498
+ isOpened: o.opened,
3499
+ onClick: () => o.setOpened(!o.opened),
3500
+ type: i.type,
3501
+ imageUrl: i.imageUrl,
3502
+ backgroundColor: t.base.primary
3503
+ }
3504
+ );
3505
+ }
3506
+ const Kc = 1e3 * 60;
3507
+ function Zc() {
3508
+ const { chatSDK: e, state: t, logger: n, enableAutoDisconnectInLauncher: o } = N(), i = D(null);
3509
+ R(() => {
3510
+ if (!o) return;
3511
+ function s() {
3512
+ i.current && (clearTimeout(i.current), i.current = null);
3513
+ }
3514
+ function a() {
3515
+ e.connectionState === vr.CLOSED && (e.reconnect(), n.debug("useSDKInactivityTimeout: reconnected")), s(), n.debug("useSDKInactivityTimeout: clear disconnect schedule");
3516
+ }
3517
+ function l() {
3518
+ s(), i.current = setTimeout(async () => {
3519
+ await e.disconnectWebSocket(), n.debug("useSDKInactivityTimeout: disconnected");
3520
+ }, Kc);
3521
+ }
3522
+ t.opened ? a() : (l(), n.debug("useSDKInactivityTimeout: schedule disconnect"));
3523
+ }, [o, e, t.opened]);
3524
+ }
3525
+ const lr = ye(null);
3526
+ function Yc() {
3527
+ const e = J(lr);
3528
+ if (!e)
3529
+ throw new Error("useNavigator() must be used within <Navigator />");
3530
+ return e;
3531
+ }
3532
+ function cr({ children: e }) {
3533
+ const t = Yc();
3534
+ return typeof e == "function" ? e(t) : /* @__PURE__ */ r.createElement(r.Fragment, null, e);
3535
+ }
3536
+ const qc = gn`0%{transform:translateY(40px);opacity:0;}100%{transform:translateY(0px);opacity:1;}`, Jc = gn`0%{transform:translateY(0px);opacity:1;}100%{transform:translateY(40px);opacity:0;}`, Xc = k`animation-name:${qc};animation-duration:0.3s;animation-fill-mode:forwards;`, Qc = k``, ed = k`animation-name:${Jc};animation-duration:0.3s;animation-fill-mode:forwards;`, td = k`visibility:hidden;`, nd = c.div`position:absolute;top:0;left:0;width:100%;height:100%;${({ $transitionState: e }) => {
3537
+ switch (e) {
3538
+ case "entering":
3539
+ return Xc;
3540
+ case "entered":
3541
+ return Qc;
3542
+ case "exiting":
3543
+ return ed;
3544
+ case "exited":
3545
+ return td;
3546
+ default:
3547
+ return "";
3548
+ }
3549
+ }}${({ $active: e }) => e ? k`
3550
+ z-index: 999;
3551
+ ` : k`z-index:1;pointer-events:none;`}
3552
+ `;
3553
+ function Ae({ initialId: e, children: t }) {
3554
+ const n = P((f, y) => {
3555
+ d((_) => [..._, f]), m((_) => ({ ..._, [f]: !0 })), y != null && y.reset && x((_) => ({
3556
+ ..._,
3557
+ [f]: (_[f] || 0) + 1
3558
+ })), h((_) => ({
3559
+ ..._,
3560
+ [f]: "entering"
3561
+ })), setTimeout(() => {
3562
+ h((_) => ({
3563
+ ..._,
3564
+ [f]: "entered"
3565
+ }));
3566
+ }, 300);
3567
+ }, []), o = P(() => {
3568
+ d((f) => {
3569
+ if (f.length <= 1) return f;
3570
+ const y = f[f.length - 1];
3571
+ return h((_) => ({
3572
+ ..._,
3573
+ [y]: "exiting"
3574
+ })), setTimeout(() => {
3575
+ h((_) => ({
3576
+ ..._,
3577
+ [y]: "exited"
3578
+ })), d((_) => _.slice(0, -1));
3579
+ }, 300), f;
3580
+ });
3581
+ }, []), i = Ie(() => ({
3582
+ navigation: {
3583
+ navigate: n,
3584
+ pop: o
3585
+ }
3586
+ }), [n, o]), s = Ie(() => pr.toArray(t).filter(
3587
+ (f) => f.type === cr
3588
+ ), [t]), a = Ie(() => {
3589
+ const f = {};
3590
+ return s.forEach((y) => {
3591
+ const { id: _, lazy: w, children: O } = y.props;
3592
+ f[_] = { lazy: w, element: typeof O == "function" ? O(i) : O };
3593
+ }), f;
3594
+ }, [s]), [l, d] = C([e]), [g, m] = C(() => {
3595
+ const f = {};
3596
+ return Object.entries(a).forEach(([y, { lazy: _ }]) => {
3597
+ _ === !1 && (f[y] = !0);
3598
+ }), f[e] = !0, f;
3599
+ }), [p, h] = C(() => {
3600
+ const f = {};
3601
+ return Object.keys(a).forEach((y) => {
3602
+ y === e ? f[y] = "entered" : f[y] = "exited";
3603
+ }), f;
3604
+ }), [b, x] = C({}), v = l[l.length - 1];
3605
+ return /* @__PURE__ */ r.createElement(lr.Provider, { value: i }, /* @__PURE__ */ r.createElement(rd, null, Object.keys(a).map((f) => {
3606
+ var O;
3607
+ if (!g[f]) return null;
3608
+ const y = p[f] || "exited", _ = f === v, w = `${f}-${b[f] || 0}`;
3609
+ return /* @__PURE__ */ r.createElement(nd, { key: w, $transitionState: y, $active: _ }, (O = a[f]) == null ? void 0 : O.element);
3610
+ })));
3611
+ }
3612
+ const rd = c.div`position:relative;width:100%;height:100%;`;
3613
+ Ae.Screen = cr;
3614
+ const ue = {
3615
+ activeConv: "active-conv",
3616
+ closedConv: "closed-conv",
3617
+ convList: "conv-list"
3618
+ }, dr = ({ setClosedChannelUrl: e, closedChannelUrl: t }) => /* @__PURE__ */ r.createElement(Ae, { initialId: ue.activeConv }, /* @__PURE__ */ r.createElement(Ae.Screen, { id: ue.activeConv }, ({ navigation: n }) => /* @__PURE__ */ r.createElement(sn, { onNavigateToConversationList: () => n.navigate(ue.convList, { reset: !0 }) })), /* @__PURE__ */ r.createElement(Ae.Screen, { id: ue.closedConv }, ({ navigation: n }) => /* @__PURE__ */ r.createElement(
3619
+ sn,
3620
+ {
3621
+ onNavigateToConversationList: () => n.pop(),
3622
+ closedChannelUrl: t,
3623
+ onClearClosedChannelUrl: () => e(void 0)
3624
+ }
3625
+ )), /* @__PURE__ */ r.createElement(Ae.Screen, { id: ue.convList, lazy: !0 }, ({ navigation: n }) => /* @__PURE__ */ r.createElement(
3626
+ Ic,
3627
+ {
3628
+ onOpenConversationView: (o, i) => {
3629
+ i === "closed" ? (e(o), n.navigate(ue.closedConv, { reset: !0 })) : n.navigate(ue.activeConv);
3630
+ }
3631
+ }
3632
+ )));
3633
+ function od({ isExpanded: e, isOpened: t, children: n, launcher: o }) {
3634
+ const { dir: i } = N();
3635
+ return /* @__PURE__ */ r.createElement(id, null, /* @__PURE__ */ r.createElement(sd, { dir: i, id: X.WINDOW, $isExpanded: e, $isOpened: t }, n), o);
3636
+ }
3637
+ const id = c.div`display:flex;flex-direction:column;gap:8px;align-items:flex-end;`, sd = c.div`background:${({ theme: e }) => e.colors.base.background};display:flex;overscroll-behavior:none;-webkit-overflow-scrolling:auto;height:640px;min-height:80px;width:400px;max-width:80vw;max-height:80vh;box-shadow:0px 16px 24px 2px rgba(33,33,33,0.12),0px 6px 30px 5px rgba(33,33,33,0.08),0px 6px 10px -5px rgba(33,33,33,0.04);border-radius:16px;overflow:hidden;transition:width 200ms ease 0s,height 200ms ease 0s,max-height 200ms ease 0s,transform 150ms cubic-bezier(0,1.2,1,1) 0s,opacity 83ms ease-out 0s;transform:scale(0.15);opacity:0;transform-origin:right bottom;[dir='rtl'] &:not([dir='ltr']),&[dir='rtl']{transform-origin:left bottom;}${({ $isOpened: e }) => e && ld};${({ $isExpanded: e }) => e && ad};`, ad = k`width:743px;height:723px;`, ld = k`z-index:${he.WINDOW};pointer-events:all;transform:scale(1);opacity:1;transition:width 200ms ease 0s,height 200ms ease 0s,max-height 200ms ease 0s,transform 300ms cubic-bezier(0,1.2,1,1) 0s,opacity 83ms ease-out 0s;`, Md = ({ children: e, ...t }) => {
3638
+ const n = Le(), [o, i] = C(), s = n ? or : od;
3639
+ return /* @__PURE__ */ r.createElement(rr, { enableExpandButton: !n, ...t }, /* @__PURE__ */ r.createElement($n, null, ({ state: a }) => /* @__PURE__ */ r.createElement(r.Fragment, null, /* @__PURE__ */ r.createElement(s, { isExpanded: a.expanded, isOpened: a.opened, launcher: /* @__PURE__ */ r.createElement(ar, null) }, /* @__PURE__ */ r.createElement(
3640
+ dr,
3641
+ {
3642
+ closedChannelUrl: o,
3643
+ setClosedChannelUrl: i
3644
+ }
3645
+ )), e)));
3646
+ };
3647
+ function cd(e) {
3648
+ return /* @__PURE__ */ r.createElement(dd, { ...e });
3649
+ }
3650
+ const dd = c(ar)`position:fixed;z-index:${he.LAUNCHER};bottom:24px;inset-inline-end:24px;`;
3651
+ function ud({ isExpanded: e, isOpened: t, children: n }) {
3652
+ const { dir: o } = N();
3653
+ return /* @__PURE__ */ r.createElement(md, { dir: o, id: X.WINDOW, $isExpanded: e, $isOpened: t }, n);
3654
+ }
3655
+ const md = c.div`background:${({ theme: e }) => e.colors.base.background};display:flex;overscroll-behavior:none;-webkit-overflow-scrolling:auto;position:fixed;bottom:84px;inset-inline-end:20px;height:640px;min-height:80px;width:400px;max-width:80vw;max-height:80vh;box-shadow:0px 16px 24px 2px rgba(33,33,33,0.12),0px 6px 30px 5px rgba(33,33,33,0.08),0px 6px 10px -5px rgba(33,33,33,0.04);border-radius:16px;overflow:hidden;transition:width 200ms ease 0s,height 200ms ease 0s,max-height 200ms ease 0s,transform 150ms cubic-bezier(0,1.2,1,1) 0s,opacity 83ms ease-out 0s;transform:scale(0.15);opacity:0;transform-origin:right bottom;[dir='rtl'] &:not([dir='ltr']),&[dir='rtl']{transform-origin:left bottom;}${({ $isOpened: e }) => e && pd};${({ $isExpanded: e }) => e && gd};`, gd = k`width:743px;height:723px;`, pd = k`z-index:${he.WINDOW};pointer-events:all;transform:scale(1);opacity:1;transition:width 200ms ease 0s,height 200ms ease 0s,max-height 200ms ease 0s,transform 300ms cubic-bezier(0,1.2,1,1) 0s,opacity 83ms ease-out 0s;`, Od = ({ children: e, ...t }) => {
3656
+ const n = Le(), [o, i] = C(), s = n ? or : ud;
3657
+ return /* @__PURE__ */ r.createElement(rr, { enableExpandButton: !n, ...t }, /* @__PURE__ */ r.createElement($n, null, ({ state: a }) => /* @__PURE__ */ r.createElement(r.Fragment, null, /* @__PURE__ */ r.createElement(s, { isExpanded: a.expanded, isOpened: a.opened }, /* @__PURE__ */ r.createElement(
3658
+ dr,
3659
+ {
3660
+ closedChannelUrl: o,
3661
+ setClosedChannelUrl: i
3662
+ }
3663
+ )), /* @__PURE__ */ r.createElement(cd, null), e)));
3664
+ };
3665
+ export {
3666
+ ht as A,
3667
+ Jr as C,
3668
+ Md as D,
3669
+ Od as F,
3670
+ $ as I,
3671
+ Hn as L,
3672
+ Ta as M,
3673
+ Tt as O,
3674
+ $d as P,
3675
+ _t as S,
3676
+ S as a,
3677
+ rr as b,
3678
+ u as c,
3679
+ Bc as d,
3680
+ F as e,
3681
+ M as f,
3682
+ Uc as g,
3683
+ ve as h,
3684
+ me as i,
3685
+ nr as j,
3686
+ sn as k,
3687
+ At as l,
3688
+ Pc as m,
3689
+ Ic as n,
3690
+ It as o,
3691
+ xn as p,
3692
+ N as u
3693
+ };