@sendbird/ai-agent-messenger-react 1.3.2 → 1.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/dist/cjs/BHzdI_Qt.cjs +1 -0
  2. package/dist/cjs/{Qn-Vab7D.cjs → BJI8cfvF.cjs} +1 -1
  3. package/dist/cjs/BJrc6-lv.cjs +1 -0
  4. package/dist/cjs/Bb0Nr21w.cjs +1 -0
  5. package/dist/cjs/{D0K6vsP-.cjs → C29jU3T2.cjs} +1 -1
  6. package/dist/cjs/C6S9YvOe.cjs +1 -0
  7. package/dist/cjs/{udFozCQd.cjs → CEraeJ-K.cjs} +1 -1
  8. package/dist/cjs/COgkkyBM.cjs +1 -0
  9. package/dist/cjs/CzB3EwDs.cjs +1 -0
  10. package/dist/cjs/D6zoiaPq.cjs +1 -0
  11. package/dist/cjs/DM-WWpci.cjs +1 -0
  12. package/dist/cjs/{CuE-R-Ab.cjs → DPkjGd1h.cjs} +1 -1
  13. package/dist/cjs/Df_7d5l_.cjs +1 -0
  14. package/dist/cjs/KtTuzALW.cjs +1 -0
  15. package/dist/cjs/P_ra76fq.cjs +1 -0
  16. package/dist/cjs/QbzBXqp7.cjs +1 -0
  17. package/dist/cjs/{D7p9IHLh.cjs → Rny4qIUJ.cjs} +1 -1
  18. package/dist/cjs/nZrhe9jg.cjs +297 -0
  19. package/dist/es/{DYR8UT_l.js → B-Bit2rH.js} +21 -5
  20. package/dist/es/{BKSUGIyL.js → B7zUx3wi.js} +21 -5
  21. package/dist/es/{kE3eGJ-O.js → B9RZQBFg.js} +1 -1
  22. package/dist/es/{D0QwWNMF.js → BDu5g5oT.js} +21 -5
  23. package/dist/es/{B1s75De5.js → BOQBJafG.js} +21 -5
  24. package/dist/es/{CA1gVgSD.js → BgVN3jH0.js} +21 -5
  25. package/dist/es/BkNaytIU.js +4809 -0
  26. package/dist/es/CBd3y0FA.js +5 -0
  27. package/dist/es/{EylKxx4d.js → CGGa6Wi6.js} +21 -5
  28. package/dist/es/{DhUBPQ6o.js → C_zdaLEd.js} +1 -1
  29. package/dist/es/{DcqbdvlW.js → DGEcXOnE.js} +21 -5
  30. package/dist/es/{jtdZ66dz.js → DJ2cswO9.js} +1 -1
  31. package/dist/es/{D5uRw0Em.js → DK3lW85j.js} +1 -1
  32. package/dist/es/{CVCUjr3Q.js → L8ixNvKX.js} +1 -1
  33. package/dist/es/Y-x39_PW.js +5 -0
  34. package/dist/es/{Dxrtj2R8.js → fgcpgo5V.js} +21 -5
  35. package/dist/es/oD5rM94o.js +5 -0
  36. package/dist/es/{BAebVbLs.js → qC-GIbc4.js} +20 -4
  37. package/dist/index.cjs +1 -1
  38. package/dist/index.d.ts +200 -13
  39. package/dist/index.js +1 -1
  40. package/package.json +7 -7
  41. package/dist/cjs/6xTfJrmg.cjs +0 -1
  42. package/dist/cjs/B4mujFdj.cjs +0 -1
  43. package/dist/cjs/BIDOBNC3.cjs +0 -1
  44. package/dist/cjs/BlshmoPb.cjs +0 -207
  45. package/dist/cjs/BzMiZszH.cjs +0 -1
  46. package/dist/cjs/D5dT1ruo.cjs +0 -1
  47. package/dist/cjs/DdQV23MS.cjs +0 -1
  48. package/dist/cjs/VJMogId3.cjs +0 -1
  49. package/dist/cjs/eFpF2Osy.cjs +0 -1
  50. package/dist/cjs/kTWMrzTz.cjs +0 -1
  51. package/dist/es/DcGmTG3A.js +0 -4104
@@ -0,0 +1,4809 @@
1
+ import * as r from "react";
2
+ import { createContext as _e, useContext as se, useEffect as L, useState as T, useCallback as D, useMemo as ee, forwardRef as Se, useImperativeHandle as Or, useId as _t, useRef as F, useLayoutEffect as pe, Suspense as Oe, lazy as A, Fragment as wn, Component as Lr, useReducer as Rr, Children as Dr } from "react";
3
+ import Nr, { SendbirdChatOptions as Fr, SendbirdProduct as Br, DeviceOsPlatform as qt, SendbirdPlatform as Pr, SessionHandler as Ur, ConnectionHandler as Qe, SendbirdError as Hr, LogLevel as An, ConnectionState as Vr } from "@sendbird/chat";
4
+ import m, { css as _, ThemeProvider as zr, useTheme as St, createGlobalStyle as Wr, StyleSheetManager as Gr, keyframes as kn } from "styled-components";
5
+ import { format as In, isSameMinute as Zt, isSameDay as jr } from "date-fns";
6
+ import { enUS as Kr } from "date-fns/locale/en-US";
7
+ import { AIAgentModule as qr, ConversationStatus as z, ConversationType as Zr } from "@sendbird/chat/aiAgent";
8
+ import { useGroupChannelMessages as Yr, useGroupChannelHandler as et, useForceUpdate as Jr } from "@sendbird/uikit-tools";
9
+ import { GroupChannelModule as Xr, GroupChannelListOrder as $n, GroupChannelHandler as Qr } from "@sendbird/chat/groupChannel";
10
+ import { createPortal as eo } from "react-dom";
11
+ import { renderer as to, parser as no, MessageProvider as ro } from "@sendbird/react-uikit-message-template-view";
12
+ import { createMessageTemplate as oo } from "@sendbird/uikit-message-template";
13
+ import Mn from "dompurify";
14
+ import { SendingStatus as mt, MessageMetaArray as so } from "@sendbird/chat/message";
15
+ import { isSameDay as io } from "date-fns/isSameDay";
16
+ import ao from "@emotion/is-prop-valid";
17
+ const W = (e, t) => {
18
+ const n = _e(null), o = ({ children: a, value: l }) => /* @__PURE__ */ r.createElement(n.Provider, { value: l }, typeof a == "function" ? a(l) : a), s = ({ children: a }) => /* @__PURE__ */ r.createElement(n.Consumer, null, (l) => l ? typeof a == "function" ? a(l) : a : null), i = () => {
19
+ const a = se(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`, s.displayName = `${e}Consumer`, i.displayName = `use${e}Context`, { Context: n, Provider: o, Consumer: s, useContext: i };
25
+ };
26
+ function Te(e) {
27
+ const t = _e({
28
+ Template: e.template,
29
+ updateTemplate: () => {
30
+ },
31
+ components: e.components,
32
+ updateComponent: () => {
33
+ }
34
+ });
35
+ function n({ children: i }) {
36
+ const [a, l] = T(() => e.template), [c, u] = T(e.components), h = {
37
+ Template: a,
38
+ updateTemplate: (g) => l(() => g),
39
+ components: c,
40
+ updateComponent: (g, x) => u((y) => ({ ...y, [g]: x }))
41
+ };
42
+ return /* @__PURE__ */ r.createElement(t.Provider, { value: h }, i);
43
+ }
44
+ function o({ template: i, children: a }) {
45
+ const { updateTemplate: l } = se(t);
46
+ return L(() => {
47
+ i && l(i);
48
+ }, [i]), /* @__PURE__ */ r.createElement(r.Fragment, null, a);
49
+ }
50
+ function s({ children: i }) {
51
+ return /* @__PURE__ */ r.createElement(n, null, i);
52
+ }
53
+ return s.defaults = e, s.useContext = () => se(t), s.Context = t, s.Template = o, Object.keys(e.components).forEach((i) => {
54
+ s[i] = function({
55
+ component: l
56
+ }) {
57
+ const { updateComponent: c } = se(t);
58
+ return L(() => {
59
+ l && c(i, l);
60
+ }, [l]), null;
61
+ };
62
+ }), s;
63
+ }
64
+ function lo(...e) {
65
+ return function({ children: n }) {
66
+ return e.reduce((o, s) => /* @__PURE__ */ r.createElement(s, null, o), n);
67
+ };
68
+ }
69
+ function ht() {
70
+ }
71
+ function co() {
72
+ const e = /iPad|iPhone|iPod/.test(navigator.userAgent), t = /Android/.test(navigator.userAgent);
73
+ return e || t;
74
+ }
75
+ function uo(e) {
76
+ let t = 0;
77
+ for (let n = 0; n < e.length; n++)
78
+ t = (t << 5) - t + e.charCodeAt(n), t |= 0;
79
+ return t.toString(16);
80
+ }
81
+ const gt = (e) => {
82
+ try {
83
+ return JSON.parse(e === "" ? "{}" : e);
84
+ } catch {
85
+ return {};
86
+ }
87
+ }, we = {
88
+ isStreaming(e) {
89
+ const t = gt(e.data);
90
+ return typeof t == "object" && !!t.stream;
91
+ },
92
+ isWelcomeMessage(e, t) {
93
+ var n;
94
+ if (((n = e.extendedMessagePayload) == null ? void 0 : n.bot_message_type) === "welcome")
95
+ return !0;
96
+ if ((e.isUserMessage() || e.isFileMessage()) && e.sender.userId === t) {
97
+ const o = gt(e.data);
98
+ return !(o != null && o.respond_mesg_id) && !(o != null && o.stream);
99
+ }
100
+ return !1;
101
+ },
102
+ isGeneratedMessage(e) {
103
+ var t;
104
+ return ((t = e.extendedMessagePayload) == null ? void 0 : t.bot_message_type) === "generated";
105
+ },
106
+ checkExtendedFieldPresence(e) {
107
+ const t = e.extendedMessagePayload || {}, n = (a) => a.some((l) => typeof t[l] < "u"), o = n(it.ui), s = n(it.trail), i = n(it.marking);
108
+ return { ui: o, trail: s, marking: i };
109
+ },
110
+ shouldScrollToBottom(e, t, n = !1) {
111
+ if ((e.isUserMessage() || e.isFileMessage() || e.isMultipleFilesMessage()) && e.sender.userId === t) {
112
+ if (this.isGeneratedMessage(e) && this.isStreaming(e))
113
+ return !0;
114
+ const { ui: i, trail: a, marking: l } = this.checkExtendedFieldPresence(e);
115
+ return i ? !(!n && l) : !!(n && (a || l));
116
+ }
117
+ return !0;
118
+ }
119
+ }, it = {
120
+ ui: ["suggested_replies", "cta_button", "message_template", "csat"],
121
+ trail: ["groundedness", "manual", "function_calls"],
122
+ marking: ["is_hallucination", "is_moderated", "flagged_types"]
123
+ }, mo = "1.4.0", ve = "sb-agent", ho = mo, at = `@${ve}`, Yt = ({ appId: e, aiAgentId: t, storage: n }) => {
124
+ const o = {
125
+ templateBase: `${at}-template`,
126
+ template: (s) => `${o.templateBase}/templates/${s}`,
127
+ templateToken: () => `${o.templateBase}-template/message-template/tokens`,
128
+ messengerSession: (s) => {
129
+ const i = uo(`${e}/${t}/${s}`);
130
+ return `${at}-udata/${i}`;
131
+ },
132
+ anonUserSession: () => `${at}-session/${e}/${t}`
133
+ };
134
+ return {
135
+ template: {
136
+ set: (s, i) => n.set(o.template(s), i),
137
+ get: (s) => n.get(o.template(s)),
138
+ setCachedToken: (s) => n.set(o.templateToken(), s),
139
+ getCachedToken: () => n.get(o.templateToken()),
140
+ clear: () => {
141
+ n.getKeys(o.templateBase).forEach(n.delete);
142
+ }
143
+ },
144
+ messenger: {
145
+ getSettings: (s) => {
146
+ try {
147
+ const i = n.get(o.messengerSession(s));
148
+ return i ? JSON.parse(i) : null;
149
+ } catch {
150
+ return null;
151
+ }
152
+ },
153
+ setSettings: (s, i) => {
154
+ try {
155
+ const a = JSON.stringify(i);
156
+ n.set(o.messengerSession(s), a);
157
+ } catch {
158
+ return;
159
+ }
160
+ },
161
+ getAnonUser: () => {
162
+ try {
163
+ const s = n.get(o.anonUserSession());
164
+ return s ? JSON.parse(s) : null;
165
+ } catch {
166
+ return null;
167
+ }
168
+ },
169
+ setAnonUser: (s) => {
170
+ try {
171
+ const i = JSON.stringify(s);
172
+ n.set(o.anonUserSession(), i);
173
+ } catch {
174
+ return;
175
+ }
176
+ },
177
+ clear: (s) => {
178
+ try {
179
+ n.delete(o.messengerSession(s)), n.delete(o.anonUserSession());
180
+ } catch {
181
+ return;
182
+ }
183
+ }
184
+ }
185
+ };
186
+ };
187
+ class On {
188
+ constructor(t) {
189
+ this.logger = t, this.subscribers = {};
190
+ }
191
+ async send(t) {
192
+ const n = go(), o = this.subscribers[t.type];
193
+ if (o) {
194
+ this.logger.debug(`messenger.dispatcher: dispatching command: ${t.type}`, t.payload);
195
+ const s = o.map((i) => i(t.payload));
196
+ await Promise.all(s).catch((i) => {
197
+ this.logger.error(`messenger.dispatcher: error in callback for command: ${t.type}`, i);
198
+ });
199
+ }
200
+ return n.resolve(), n.promise;
201
+ }
202
+ subscribe(t, n) {
203
+ this.subscribers[t] || (this.subscribers[t] = []), this.subscribers[t].push(n);
204
+ }
205
+ unsubscribe(t, n) {
206
+ this.subscribers[t] && (this.subscribers[t] = this.subscribers[t].filter((o) => o !== n));
207
+ }
208
+ }
209
+ const go = () => {
210
+ let e = ht, t = ht;
211
+ return { promise: new Promise((o, s) => {
212
+ e = o, t = s;
213
+ }), resolve: e, reject: t };
214
+ };
215
+ var Ln = /* @__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))(Ln || {});
216
+ class Rn {
217
+ constructor(t) {
218
+ this.level = t;
219
+ }
220
+ verbose(...t) {
221
+ this.level <= 0 && console.log(`[${ve}/verbose]`, ...t);
222
+ }
223
+ debug(...t) {
224
+ this.level <= 1 && console.log(`[${ve}/debug]`, ...t);
225
+ }
226
+ info(...t) {
227
+ this.level <= 2 && console.log(`[${ve}/info]`, ...t);
228
+ }
229
+ warn(...t) {
230
+ this.level <= 3 && console.warn(`[${ve}/warn]`, ...t);
231
+ }
232
+ error(...t) {
233
+ this.level <= 4 && console.error(`[${ve}/error]`, ...t);
234
+ }
235
+ }
236
+ function Jt(e, t, n) {
237
+ const o = Nr.init({
238
+ appId: e,
239
+ modules: [new Xr(), new qr()],
240
+ localCacheEnabled: !0,
241
+ options: new Fr({ typingIndicatorInvalidateTime: 3e4 }),
242
+ ...n
243
+ });
244
+ return o.addSendbirdExtensions(
245
+ [{ version: ho, product: Br.AI_AGENT, platform: t.platform }],
246
+ { platform: t.deviceOSPlatform, version: t.deviceOSVersion },
247
+ t.customData
248
+ ) || console.warn("Invalid Sendbird Extensions", t), o;
249
+ }
250
+ function po(e) {
251
+ const t = (n) => {
252
+ throw new Error(`Please initialize chat sdk with ${n}`);
253
+ };
254
+ typeof e.groupChannel != "object" && t("GroupChannelModule"), typeof e.aiAgent != "object" && t("AIAgentModule");
255
+ }
256
+ const {
257
+ Provider: fo,
258
+ useContext: Y
259
+ } = W("AIAgent");
260
+ function bo({
261
+ appId: e,
262
+ aiAgentId: t,
263
+ keyValueStorage: n,
264
+ language: o,
265
+ countryCode: s,
266
+ context: i,
267
+ queryParams: a,
268
+ chatSDK: l,
269
+ chatParams: c,
270
+ children: u,
271
+ logger: h,
272
+ dispatcher: g,
273
+ extensions: x = {
274
+ platform: Pr.JS,
275
+ deviceOSPlatform: co() ? qt.MOBILE_WEB : qt.WEB
276
+ }
277
+ }) {
278
+ const [y, E] = T(() => {
279
+ const b = h ?? new Rn(Ln.WARN), p = g ?? new On(b);
280
+ return {
281
+ appId: e,
282
+ aiAgentId: t,
283
+ language: o,
284
+ countryCode: s,
285
+ context: i,
286
+ queryParams: a,
287
+ keyValueStorage: n,
288
+ logger: b,
289
+ dispatcher: p,
290
+ chatSDK: l ?? Jt(e, x, c),
291
+ cache: Yt({ appId: e, aiAgentId: t, storage: n })
292
+ };
293
+ });
294
+ return L(() => {
295
+ E((b) => {
296
+ let p = b.logger, f = b.dispatcher, v = b.chatSDK;
297
+ return h && h !== b.logger && (p = h), g && g !== b.dispatcher && (f = g), l && l !== b.chatSDK ? v = l : !l && b.chatSDK.appId !== e && (v = Jt(e, x, { newInstance: !0, ...c })), {
298
+ ...b,
299
+ appId: e,
300
+ aiAgentId: t,
301
+ keyValueStorage: n,
302
+ language: o,
303
+ countryCode: s,
304
+ context: i,
305
+ queryParams: a,
306
+ logger: p,
307
+ dispatcher: f,
308
+ chatSDK: v,
309
+ cache: Yt({ appId: e, aiAgentId: t, storage: n })
310
+ };
311
+ });
312
+ }, [e, t, o, s, i, h, g, l]), L(() => () => {
313
+ y.chatSDK.disconnectWebSocket();
314
+ }, [y.chatSDK]), po(y.chatSDK), /* @__PURE__ */ r.createElement(fo, { value: y }, u);
315
+ }
316
+ const xo = (e, t, n) => Yr(e, t, { ...n, strictStreamingOrder: !0 });
317
+ var pt = /* @__PURE__ */ ((e) => (e.ConversationClose = "conv.close", e))(pt || {});
318
+ class Eo {
319
+ constructor(t = {}) {
320
+ this.payload = t;
321
+ }
322
+ toJSON() {
323
+ return JSON.stringify({ type: this.type, payload: this.payload });
324
+ }
325
+ }
326
+ const vo = {
327
+ CloseConversation: (e) => new yo(e)
328
+ };
329
+ class yo extends Eo {
330
+ constructor() {
331
+ super(...arguments), this.type = "conv.close";
332
+ }
333
+ }
334
+ const ft = {
335
+ DEFAULT_BOT_MSG_BG: "#eeeeee",
336
+ WHITE: "#ffffff",
337
+ BLACK: "#000000"
338
+ };
339
+ function Dn(e) {
340
+ return e.length === 4 ? `#${[...e.slice(1)].map((t) => t + t).join("")}` : e;
341
+ }
342
+ function Co(e) {
343
+ const t = Dn(e);
344
+ return [
345
+ parseInt(t.slice(1, 3), 16),
346
+ // r
347
+ parseInt(t.slice(3, 5), 16),
348
+ // g
349
+ parseInt(t.slice(5, 7), 16)
350
+ // b
351
+ ];
352
+ }
353
+ function _o(e) {
354
+ return `#${e.map((t) => t.toString(16).padStart(2, "0")).join("")}`;
355
+ }
356
+ function So(e, t, n) {
357
+ e /= 255, t /= 255, n /= 255;
358
+ const o = Math.max(e, t, n), s = Math.min(e, t, n), i = o - s;
359
+ let a = 0, l = 0;
360
+ const c = (o + s) / 2;
361
+ return o !== s && (l = c > 0.5 ? i / (2 - o - s) : i / (o + s)), o === e ? a = (t - n) / i + (t < n ? 6 : 0) : o === t ? a = (n - e) / i + 2 : o === n && (a = (e - t) / i + 4), a /= 6, [a, l, c];
362
+ }
363
+ function To(e, t, n) {
364
+ let o, s, i;
365
+ if (t === 0)
366
+ o = s = i = n;
367
+ else {
368
+ const a = function(h, g, x) {
369
+ return x < 0 && (x += 1), x > 1 && (x -= 1), x < 0.16666666666666666 ? h + (g - h) * 6 * x : x < 0.5 ? g : x < 0.6666666666666666 ? h + (g - h) * (0.6666666666666666 - x) * 6 : h;
370
+ }, l = n < 0.5 ? n * (1 + t) : n + t - n * t, c = 2 * n - l;
371
+ o = a(c, l, e + 1 / 3), s = a(c, l, e), i = a(c, l, e - 1 / 3);
372
+ }
373
+ return [Math.round(o * 255), Math.round(s * 255), Math.round(i * 255)];
374
+ }
375
+ function Ue(e, t, n) {
376
+ const [o, s, i] = Co(e), [a, l, c] = So(o, s, i), u = Math.max(0, Math.min(1, c * t)), h = Math.max(0, Math.min(1, l * n)), [g, x, y] = To(a, h, u);
377
+ return _o([Math.round(g), Math.round(x), Math.round(y)]);
378
+ }
379
+ function wo(e, t = "light") {
380
+ return {
381
+ extraDark: Ue(e, 0.6, 1.2),
382
+ dark: Ue(e, 0.85, 1.1),
383
+ main: e,
384
+ light: Ue(e, t === "dark" ? 1.1 : 1.5, t === "dark" ? 0.95 : 0.9),
385
+ extraLight: Ue(e, t === "dark" ? 1.2 : 1.75, t === "dark" ? 0.9 : 0.8)
386
+ };
387
+ }
388
+ function bt(e) {
389
+ const t = Dn(e), n = 149, o = +`0x${t[1]}${t[2]}`, s = +`0x${t[3]}${t[4]}`, i = +`0x${t[5]}${t[6]}`;
390
+ return o * 0.299 + s * 0.587 + i * 0.114 > n ? ft.BLACK : ft.WHITE;
391
+ }
392
+ function Ao(e, t, n, o, s) {
393
+ return {
394
+ base: {
395
+ primary: t,
396
+ primaryContrastContent: n,
397
+ background: e.background50,
398
+ headerBackground: e.background50,
399
+ modalContentBackground: e.background50
400
+ },
401
+ metadata: {
402
+ errorContent: e.ondark.textHighEmphasis,
403
+ placeholderText: e.onlight.textLowEmphasis
404
+ },
405
+ messageInput: {
406
+ background: e.background100
407
+ },
408
+ messageIncoming: {
409
+ text: s,
410
+ background: o
411
+ },
412
+ messageOutgoing: {
413
+ text: n,
414
+ background: t
415
+ },
416
+ csat: {
417
+ background: e.background100
418
+ }
419
+ };
420
+ }
421
+ const ko = (e, t, n, o, s) => ({
422
+ base: {
423
+ primary: t,
424
+ primaryContrastContent: n,
425
+ background: e.background600,
426
+ headerBackground: e.background500,
427
+ modalContentBackground: e.background500
428
+ },
429
+ metadata: {
430
+ errorContent: e.ondark.textHighEmphasis,
431
+ placeholderText: e.ondark.textLowEmphasis
432
+ },
433
+ messageInput: {
434
+ background: e.background400
435
+ },
436
+ messageIncoming: {
437
+ text: s,
438
+ background: o
439
+ },
440
+ messageOutgoing: {
441
+ text: n,
442
+ background: t
443
+ },
444
+ csat: {
445
+ background: e.background400
446
+ }
447
+ }), He = {
448
+ primary: {
449
+ extraDark: "#491389",
450
+ dark: "#6211c8",
451
+ main: "#742ddd",
452
+ light: "#c2a9fa",
453
+ extraLight: "#dbd1ff"
454
+ },
455
+ secondary: {
456
+ extraDark: "#066858",
457
+ dark: "#027d69",
458
+ main: "#259c72",
459
+ light: "#69c085",
460
+ extraLight: "#a8e2ab"
461
+ },
462
+ error: {
463
+ extraDark: "#9d091e",
464
+ dark: "#bf0711",
465
+ main: "#de360b",
466
+ light: "#f66161",
467
+ extraLight: "#fdaaaa"
468
+ },
469
+ information: {
470
+ extraDark: "#241389",
471
+ dark: "#362ca9",
472
+ main: "#4a48cd",
473
+ light: "#a9bbfa",
474
+ extraLight: "#d1dbff"
475
+ },
476
+ background700: "#000000",
477
+ background600: "#161616",
478
+ background500: "#2c2c2c",
479
+ background400: "#393939",
480
+ background300: "#bdbdbd",
481
+ background200: "#e0e0e0",
482
+ background100: "#eeeeee",
483
+ background50: "#ffffff",
484
+ onlight: {
485
+ textHighEmphasis: "rgba(0, 0, 0, 0.88)",
486
+ textMidEmphasis: "rgba(0, 0, 0, 0.5)",
487
+ textLowEmphasis: "rgba(0, 0, 0, 0.38)",
488
+ textDisabled: "rgba(0, 0, 0, 0.12)"
489
+ },
490
+ ondark: {
491
+ textHighEmphasis: "rgba(255, 255, 255, 0.88)",
492
+ textMidEmphasis: "rgba(255, 255, 255, 0.5)",
493
+ textLowEmphasis: "rgba(255, 255, 255, 0.38)",
494
+ textDisabled: "rgba(255, 255, 255, 0.12)"
495
+ },
496
+ overlay: {
497
+ dark: "rgba(0, 0, 0, 0.55)",
498
+ light: "rgba(22, 22, 22, 0.32)"
499
+ }
500
+ }, lt = {
501
+ h1: { fontSize: 18, fontWeight: 700 },
502
+ h2: { fontSize: 16, fontWeight: 700 },
503
+ subtitle1: { fontSize: 16, fontWeight: 500 },
504
+ subtitle2: { fontSize: 16, fontWeight: 400 },
505
+ body1: { fontSize: 16, fontWeight: 400 },
506
+ body2: { fontSize: 14, fontWeight: 500 },
507
+ body3: { fontSize: 14, fontWeight: 400 },
508
+ button: { fontSize: 14, fontWeight: 700 },
509
+ caption1: { fontSize: 12, fontWeight: 700 },
510
+ caption2: { fontSize: 12, fontWeight: 400 },
511
+ caption3: { fontSize: 11, fontWeight: 700 },
512
+ caption4: { fontSize: 11, fontWeight: 400 }
513
+ };
514
+ function Xt(e) {
515
+ const t = Io(e), { colors: n, aiAgentColorVariables: o } = $o(e, t), s = Oo(e);
516
+ return {
517
+ selectedTheme: e.selectedTheme,
518
+ palette: t,
519
+ colors: n,
520
+ aiAgentColorVariables: o,
521
+ typography: s
522
+ };
523
+ }
524
+ function Io({ selectedTheme: e, palette: t, primary: n }) {
525
+ const o = t != null && t.primary ? t.primary : n ? n === He.primary.main ? He.primary : wo(n, e) : He.primary;
526
+ return {
527
+ ...He,
528
+ primary: o,
529
+ ...t
530
+ };
531
+ }
532
+ function $o({ selectedTheme: e, primaryContrast: t, botMessageBackground: n, botMessageBackgroundContrast: o }, s) {
533
+ const i = s.primary.main, a = t ?? bt(i), l = n ?? ft.DEFAULT_BOT_MSG_BG, c = o ?? bt(l);
534
+ return {
535
+ colors: (e === "light" ? Ao : ko)(
536
+ s,
537
+ i,
538
+ a,
539
+ l,
540
+ c
541
+ ),
542
+ aiAgentColorVariables: {
543
+ primary_color: i,
544
+ bot_message_bg_color: l,
545
+ primary_contrast_color: a,
546
+ bot_message_bg_contrast_color: c
547
+ }
548
+ };
549
+ }
550
+ function Mo(e, t, n) {
551
+ const o = { ...e };
552
+ return n.forEach((s) => {
553
+ const i = t[s];
554
+ i != null && (o[s] = i);
555
+ }), o;
556
+ }
557
+ function Oo({ typography: e }) {
558
+ if (!e)
559
+ return lt;
560
+ const t = { ...lt };
561
+ return Object.keys(e).forEach((n) => {
562
+ const o = e[n];
563
+ if (o && typeof o == "object") {
564
+ const s = lt[n], i = ["fontSize", "fontWeight", "fontFamily", "lineHeight"];
565
+ t[n] = Mo(s, o, i);
566
+ }
567
+ }), t;
568
+ }
569
+ const {
570
+ Provider: Lo,
571
+ useContext: Tt
572
+ } = W("AIAgentTheme");
573
+ function Ro({ logger: e, palette: t, typography: n, appearance: o, children: s }) {
574
+ const [i, a] = T(
575
+ () => Xt({
576
+ selectedTheme: (o == null ? void 0 : o.theme) ?? "light",
577
+ palette: t,
578
+ typography: n,
579
+ primary: o == null ? void 0 : o.primaryColor,
580
+ botMessageBackground: o == null ? void 0 : o.botMessageBackgroundColor
581
+ })
582
+ ), l = D(
583
+ (c, u) => {
584
+ const h = (o == null ? void 0 : o.theme) ?? c, g = u == null ? void 0 : u(h), x = {
585
+ primary: o == null ? void 0 : o.primaryColor,
586
+ primaryContrast: void 0,
587
+ botMessageBackground: o == null ? void 0 : o.botMessageBackgroundColor,
588
+ botMessageBackgroundContrast: void 0
589
+ };
590
+ !x.primary && (g != null && g.primaryColor) && (x.primary = g.primaryColor, x.primaryContrast = g.primaryContrastColor), !x.botMessageBackground && (g != null && g.botMessageBackgroundColor) && (x.botMessageBackground = g.botMessageBackgroundColor, x.botMessageBackgroundContrast = g.botMessageBackgroundContrastColor);
591
+ const y = Xt({ selectedTheme: h, palette: t, typography: n, ...x });
592
+ a(y), e == null || e.info("theme.update:", h);
593
+ },
594
+ [o == null ? void 0 : o.theme, o == null ? void 0 : o.primaryColor, o == null ? void 0 : o.botMessageBackgroundColor, t, n, e]
595
+ );
596
+ return L(() => {
597
+ (o != null && o.theme || o != null && o.primaryColor || o != null && o.botMessageBackgroundColor) && l(i.selectedTheme);
598
+ }, [o == null ? void 0 : o.theme, o == null ? void 0 : o.primaryColor, o == null ? void 0 : o.botMessageBackgroundColor]), /* @__PURE__ */ r.createElement(Lo, { value: { theme: i, updateTheme: l } }, s);
599
+ }
600
+ function Nn() {
601
+ const { chatSDK: e, logger: t } = Y();
602
+ return D(
603
+ async (n) => {
604
+ if (n.userId === "") {
605
+ const o = new Error("userId cannot be empty string for messenger settings request");
606
+ throw t.error("requestMessengerSettings: invalid userId", o), o;
607
+ }
608
+ return await e.aiAgent.requestMessengerSettings(n);
609
+ },
610
+ [e, t]
611
+ );
612
+ }
613
+ function Do() {
614
+ const { chatSDK: e, logger: t } = Y(), n = D(
615
+ async (s, i, a) => {
616
+ if (t.debug("useChatConnection.connect: start, session", s.userId), i) {
617
+ const l = new Ur({
618
+ ...i,
619
+ onSessionTokenRequired: No(i.onSessionTokenRequired, a)
620
+ });
621
+ e.setSessionHandler(l);
622
+ }
623
+ await e.connect(s.userId, s.authToken), t.debug("useChatConnection.connect: end, currentUser", e.currentUser);
624
+ },
625
+ [e, t]
626
+ ), o = D(async () => {
627
+ t.debug("useChatConnection.disconnect: start"), await e.disconnect(), t.debug("useChatConnection.disconnect: end");
628
+ }, [e, t]);
629
+ return { connect: n, disconnect: o };
630
+ }
631
+ function No(e, t) {
632
+ if (e)
633
+ return async (n, o) => {
634
+ new Promise((s, i) => e == null ? void 0 : e(s, i)).then((s) => {
635
+ s && (t == null || t(s)), n(s);
636
+ }).catch((s) => {
637
+ o(s);
638
+ });
639
+ };
640
+ }
641
+ class Fo {
642
+ constructor({ userId: t, authToken: n, sessionHandler: o }) {
643
+ this.userId = t, this.authToken = n, this.sessionHandler = o;
644
+ }
645
+ }
646
+ class Qt {
647
+ }
648
+ const Bo = 24 * 60 * 60 * 1e3, Po = (e) => {
649
+ const { logger: t, cache: n } = Y(), o = () => {
650
+ const i = n.messenger.getAnonUser();
651
+ return i ? i.expireAt - Bo <= Date.now() ? (t.debug("useUserSessionCandidate.getAnonymousSessionInfo: auto session expired, clear cache"), n.messenger.clear(i.userId), null) : (t.debug("useUserSessionCandidate.getAnonymousSessionInfo: auto session info detected"), i) : null;
652
+ }, s = () => {
653
+ if (!e || e instanceof Qt)
654
+ throw new Error("userSessionInfo must be an instance of ManualSessionInfo");
655
+ if (typeof e.userId != "string")
656
+ throw new Error("userSessionInfo.userId must be a string");
657
+ const i = ["userId", "authToken", "sessionHandler"].filter((a) => !(a in e));
658
+ return i.length > 0 && t.error(
659
+ `useUserSessionCandidate.getManualSessionInfo: missing required keys in userSessionInfo: ${i.join(", ")}`
660
+ ), t.debug("useUserSessionCandidate.getManualSessionInfo: manual session info detected"), e;
661
+ };
662
+ return ee(() => e instanceof Fo ? { type: "manual", userSessionCandidate: s() } : e instanceof Qt ? { type: "anonymous", userSessionCandidate: o() } : e && typeof e == "object" ? (t.warn("Please use ManualSessionInfo instead of the old userSessionInfo format."), { type: "manual", userSessionCandidate: s() }) : e === void 0 ? (t.warn("Please use AnonymousSessionInfo instead of undefined userSessionInfo."), { type: "anonymous", userSessionCandidate: o() }) : { type: "anonymous", userSessionCandidate: null }, [
663
+ t,
664
+ e == null ? void 0 : e.userId,
665
+ e == null ? void 0 : e.authToken,
666
+ e == null ? void 0 : e.sessionHandler,
667
+ n.messenger.getAnonUser,
668
+ n.messenger.clear
669
+ ]);
670
+ };
671
+ function Uo({
672
+ userSessionInfo: e,
673
+ onPreAuth: t,
674
+ onPostAuth: n,
675
+ onErrorAuth: o,
676
+ onAuthTokenRefreshed: s,
677
+ onPostDeauth: i,
678
+ forceCreateChannel: a
679
+ }) {
680
+ const { aiAgentId: l, language: c, context: u, countryCode: h, logger: g, cache: x } = Y(), { connect: y, disconnect: E } = Do(), { type: b, userSessionCandidate: p } = Po(e), f = Nn(), v = D(async () => {
681
+ var J;
682
+ g.debug("useAuthentication.authenticate: start");
683
+ const M = (p == null ? void 0 : p.userId) && ((J = x.messenger.getSettings(p.userId)) == null ? void 0 : J.knownActiveChannelUrl), P = await f({
684
+ aiAgentId: l,
685
+ userId: p == null ? void 0 : p.userId,
686
+ language: c,
687
+ country: h,
688
+ context: u,
689
+ forceCreateChannel: a,
690
+ knownActiveChannelUrl: M
691
+ });
692
+ g.debug("useAuthentication.authenticate: messenger settings response", P);
693
+ let $ = null;
694
+ if (P.auto_created_user)
695
+ if (b === "manual")
696
+ g.warn("Received auto created user info but current session is manual. Ignoring auto created user info."), $ = { userId: p.userId, authToken: p.authToken };
697
+ else {
698
+ const { user_id: G, session_token: C, expire_at: U } = P.auto_created_user;
699
+ x.messenger.setAnonUser({ userId: G, authToken: C, expireAt: U }), $ = { userId: G, authToken: C };
700
+ }
701
+ else
702
+ $ = {
703
+ userId: (p == null ? void 0 : p.userId) ?? "",
704
+ authToken: (p == null ? void 0 : p.authToken) ?? ""
705
+ };
706
+ x.messenger.setSettings($.userId, {
707
+ knownActiveChannelUrl: P.active_channel.channel_url
708
+ });
709
+ try {
710
+ await t(P, $), await y($, p == null ? void 0 : p.sessionHandler, s), await n(P, $);
711
+ } catch (G) {
712
+ G instanceof Error && (o(G), g.error("useAuthentication.authenticate: failed to connect", G));
713
+ }
714
+ return P;
715
+ }, [
716
+ f,
717
+ y,
718
+ b,
719
+ p == null ? void 0 : p.userId,
720
+ p == null ? void 0 : p.sessionHandler,
721
+ p == null ? void 0 : p.authToken,
722
+ x.messenger.setAnonUser,
723
+ x.messenger.getSettings,
724
+ x.messenger.setSettings,
725
+ t,
726
+ n,
727
+ o,
728
+ s
729
+ ]), S = D(async () => {
730
+ g.debug("useAuthentication.deauthenticate: start"), await E(), i(), g.debug("useAuthentication.deauthenticate: completed");
731
+ }, [E, g, i]);
732
+ return {
733
+ authenticate: v,
734
+ deauthenticate: S,
735
+ userSessionCandidate: p
736
+ };
737
+ }
738
+ const Fn = (e) => {
739
+ try {
740
+ const t = JSON.parse(e);
741
+ return typeof t == "string" ? JSON.stringify(t).slice(1, -1) : e.trim();
742
+ } catch {
743
+ return JSON.stringify(e).slice(1, -1);
744
+ }
745
+ }, Re = (e) => JSON.parse(e), tt = (e) => JSON.parse(e);
746
+ function Ho(e, t) {
747
+ const [n, o] = t.split(",").map((s) => s.trim());
748
+ return e === "dark" && o || n;
749
+ }
750
+ function Vo(e) {
751
+ const t = {};
752
+ function n(o, s = "") {
753
+ for (const [i, a] of Object.entries(o)) {
754
+ const l = s ? `${s}.${i}` : i;
755
+ a && typeof a == "object" && !Array.isArray(a) ? n(a, l) : t[l] = a;
756
+ }
757
+ }
758
+ return n(e), t;
759
+ }
760
+ function wt({
761
+ template: e,
762
+ variables: t,
763
+ variableKeyPattern: n,
764
+ variableValueTransformer: o
765
+ }) {
766
+ return Object.entries(t).reduce((s, [i, a]) => {
767
+ if (!o && !["number", "boolean", "string"].includes(typeof a))
768
+ throw new Error(`If transformer is not provided, value(${i}:${a}) must be a {string, number, or boolean}`);
769
+ const l = o ? o(a) : String(a), c = n(i);
770
+ return s.replace(c, Fn(l));
771
+ }, e);
772
+ }
773
+ async function zo({
774
+ template: e,
775
+ variables: t,
776
+ variableKeyPattern: n,
777
+ variableValueTransformer: o
778
+ }) {
779
+ return (await Promise.all(
780
+ Object.entries(t).map(async ([i, a]) => {
781
+ const l = await o(a);
782
+ return { regex: n(i), transformedValue: l };
783
+ })
784
+ )).reduce((i, { regex: a, transformedValue: l }) => i.replace(a, Fn(l)), e);
785
+ }
786
+ const Wo = () => {
787
+ const { chatSDK: e, logger: t, cache: n } = Y(), o = D(() => {
788
+ var l, c;
789
+ const i = (c = (l = e.appInfo) == null ? void 0 : l.aiAgentInfo) == null ? void 0 : c.templateListToken;
790
+ if (!i) return !1;
791
+ const a = n.template.getCachedToken();
792
+ return a ? i !== a : !0;
793
+ }, [e, n.template.getCachedToken]), s = D(async () => {
794
+ try {
795
+ const { templates: i, token: a } = await e.aiAgent.getMessageTemplates({ limit: 20 });
796
+ for (const { template: l } of i) {
797
+ const { key: c } = Re(l);
798
+ n.template.set(c, l);
799
+ }
800
+ n.template.setCachedToken(a);
801
+ } catch (i) {
802
+ t == null || t.error("messageTemplateContext.syncCachedTemplates: error:", i);
803
+ }
804
+ }, [e, t, n.template.set, n.template.setCachedToken]);
805
+ return {
806
+ shouldSyncCachedTemplate: o,
807
+ syncCachedTemplates: s
808
+ };
809
+ };
810
+ var qe = /* @__PURE__ */ ((e) => (e.OFF = "off", e.ALWAYS = "always", e.HANDED_OFF_ONLY = "handed_off_only", e))(qe || {});
811
+ const Go = {
812
+ off: "off",
813
+ always: "always",
814
+ handed_off_only: "handed_off_only"
815
+ /* HANDED_OFF_ONLY */
816
+ }, {
817
+ Provider: jo,
818
+ useContext: Ko
819
+ } = W("AIAgentMessengerSession"), qo = Se(
820
+ function({ userSessionInfo: e, forceCreateChannel: t, children: n }, o) {
821
+ const { appId: s, aiAgentId: i, chatSDK: a, language: l, countryCode: c, context: u, cache: h, logger: g } = Y(), { updateTheme: x } = Tt(), [y, E] = T(void 0), [b, p] = T(
822
+ void 0
823
+ ), [f, v] = T(null), [S, M] = T(null), [P, $] = T(null), [J, G] = T(
824
+ "handed_off_only"
825
+ /* HANDED_OFF_ONLY */
826
+ ), { shouldSyncCachedTemplate: C, syncCachedTemplates: U } = Wo(), te = Nn(), { authenticate: X, deauthenticate: Ie } = Uo({
827
+ userSessionInfo: e,
828
+ forceCreateChannel: t,
829
+ onPreAuth: D((k, N) => {
830
+ const q = k.appearance.selected_theme;
831
+ x(q, (ne) => {
832
+ const Ee = k.appearance.themes[ne];
833
+ return {
834
+ primaryColor: Ee.primary_color,
835
+ botMessageBackgroundColor: Ee.bot_message_bg_color,
836
+ primaryContrastColor: Ee.primary_contrast_color,
837
+ botMessageBackgroundContrastColor: Ee.bot_message_bg_contrast_color
838
+ };
839
+ }), E(void 0), v(N), M({
840
+ userId: k.bot.bot_userid,
841
+ profileUrl: k.bot.bot_profile_url,
842
+ nickname: k.bot.bot_nickname,
843
+ replyToFile: k.bot.reply_to_file,
844
+ specialNotice: k.bot.special_notice,
845
+ specialNoticeEnabled: k.bot.is_special_notice_enabled,
846
+ showHandoffButton: k.bot.show_handoff_button ?? !0
847
+ }), $({
848
+ type: k.launcher.image_type || "default_icon",
849
+ imageUrl: k.launcher.image_url
850
+ }), G(
851
+ Go[k.active_channel.attachment_mode] ?? "handed_off_only"
852
+ /* HANDED_OFF_ONLY */
853
+ );
854
+ }, []),
855
+ onPostAuth: D(
856
+ async (k) => {
857
+ C() && await U(), p({ url: k.active_channel.channel_url, status: z.OPEN });
858
+ },
859
+ [C, U]
860
+ ),
861
+ onErrorAuth: D((k) => {
862
+ E(k);
863
+ }, []),
864
+ onAuthTokenRefreshed: D((k) => {
865
+ v((N) => N ? { ...N, authToken: k } : null);
866
+ }, []),
867
+ onPostDeauth: D(() => {
868
+ h.template.clear(), f != null && f.userId && h.messenger.clear(f.userId), p(void 0), v(null), M(null), $(null);
869
+ }, [h.template.clear, f])
870
+ }), ot = D(async () => {
871
+ var k;
872
+ if (f) {
873
+ g.debug("agentMessengerSession.refreshActiveChannel: try to refresh active channel"), p(void 0);
874
+ const N = await te({
875
+ aiAgentId: i,
876
+ userId: f.userId,
877
+ language: l,
878
+ country: c,
879
+ context: u,
880
+ forceCreateChannel: t,
881
+ knownActiveChannelUrl: (k = h.messenger.getSettings(f.userId)) == null ? void 0 : k.knownActiveChannelUrl
882
+ });
883
+ return h.messenger.setSettings(f.userId, {
884
+ knownActiveChannelUrl: N.active_channel.channel_url
885
+ }), p({ url: N.active_channel.channel_url, status: z.OPEN }), g.info(
886
+ "agentMessengerSession.refreshActiveChannel: refreshed active channel",
887
+ N.active_channel.channel_url
888
+ ), N.active_channel.channel_url;
889
+ } else
890
+ throw g.error("agentMessengerSession.refreshActiveChannel: userSession is not ready"), new Error("userSession is not ready");
891
+ }, [
892
+ te,
893
+ s,
894
+ i,
895
+ f == null ? void 0 : f.userId,
896
+ l,
897
+ c,
898
+ u,
899
+ t,
900
+ h.messenger.getSettings,
901
+ h.messenger.setSettings
902
+ ]), st = D(
903
+ async (k) => {
904
+ if (!(f != null && f.userId))
905
+ throw new Error("Current user is not authenticated. Please authenticate first.");
906
+ const q = (await te({
907
+ ...k,
908
+ userId: f.userId,
909
+ knownActiveChannelUrl: void 0
910
+ })).active_channel.channel_url;
911
+ return h.messenger.setSettings(f.userId, { knownActiveChannelUrl: q }), q;
912
+ },
913
+ [f == null ? void 0 : f.userId, te]
914
+ );
915
+ return et(a, {
916
+ onChannelChanged: (k) => {
917
+ var N;
918
+ k.isGroupChannel() && k.url === (b == null ? void 0 : b.url) && (g.info("agentMessengerSession.channelChanged: channel.conversation", k.conversation), p({ url: k.url, status: ((N = k.conversation) == null ? void 0 : N.status) ?? z.OPEN }));
919
+ }
920
+ }), Or(o, () => {
921
+ const k = async () => {
922
+ if (!b) throw new Error("No active conversation. Please start a conversation first.");
923
+ return await a.groupChannel.getChannel(b.url);
924
+ };
925
+ return {
926
+ activeChannel: b,
927
+ chatSDK: a,
928
+ authenticate: X,
929
+ deauthenticate: Ie,
930
+ updateContext: async (N) => {
931
+ const ne = await (await k()).updateContext(i, N);
932
+ return { ...ne, context: ne.context ?? {} };
933
+ },
934
+ patchContext: async (N) => {
935
+ const ne = await (await k()).patchContext(i, N);
936
+ return { ...ne, context: ne.context ?? {} };
937
+ },
938
+ getContextObject: async () => {
939
+ const q = await (await k()).getContextObject(i);
940
+ return { ...q, context: q.context ?? {} };
941
+ }
942
+ };
943
+ }, [X, Ie, b, a, i, g]), /* @__PURE__ */ r.createElement(
944
+ jo,
945
+ {
946
+ value: {
947
+ userSessionInfo: e,
948
+ userSession: f,
949
+ activeChannel: b,
950
+ setActiveChannel: p,
951
+ refreshActiveChannel: ot,
952
+ createConversation: st,
953
+ connectionError: y,
954
+ aiAgentInfo: S,
955
+ launcherInfo: P,
956
+ authenticate: X,
957
+ deauthenticate: Ie,
958
+ attachmentMode: J
959
+ }
960
+ },
961
+ n
962
+ );
963
+ }
964
+ ), {
965
+ Provider: Zo
966
+ } = W("AIAgentConversation");
967
+ function Yo({
968
+ children: e,
969
+ channelUrl: t,
970
+ onChannelDeleted: n,
971
+ onMessagesReceived: o,
972
+ onMessagesUpdated: s,
973
+ onConversationClosedViaDispatcher: i,
974
+ onBeforeSendMessage: a,
975
+ onAfterSendMessage: l = ht
976
+ }) {
977
+ var p;
978
+ const { chatSDK: c, logger: u, dispatcher: h } = Y(), { channel: g, channelFetchError: x, fetchChannel: y } = Jo(t), E = xo(c, g, {
979
+ shouldCountNewMessages: () => !1,
980
+ onChannelDeleted: n,
981
+ onMessagesReceived: (f) => o == null ? void 0 : o(f),
982
+ onMessagesUpdated: (f) => s == null ? void 0 : s(f),
983
+ logger: u
984
+ });
985
+ L(() => {
986
+ const f = async (v) => {
987
+ const S = typeof (v == null ? void 0 : v.channelUrl) == "string";
988
+ g && S && v.channelUrl !== g.url || (u.debug("conversation.dispatcher: try to close conversation", g), g != null && g.conversation && g.conversation.status === z.OPEN && (await g.closeConversation(), i == null || i()));
989
+ };
990
+ return h.subscribe(pt.ConversationClose, f), () => {
991
+ h.unsubscribe(pt.ConversationClose, f);
992
+ };
993
+ }, [h, (p = g == null ? void 0 : g.conversation) == null ? void 0 : p.status, i]);
994
+ const b = {
995
+ conversation: (g == null ? void 0 : g.conversation) ?? void 0,
996
+ channelSource: {
997
+ channel: g,
998
+ error: x,
999
+ refetch: () => y()
1000
+ },
1001
+ messageSource: {
1002
+ messages: E.messages,
1003
+ initialized: E.initialized,
1004
+ loadPrevious: () => E.loadPrevious(),
1005
+ loadNext: () => E.loadNext(),
1006
+ sendUserMessage: async (f) => {
1007
+ var S;
1008
+ if (((S = g == null ? void 0 : g.conversation) == null ? void 0 : S.status) === z.CLOSED)
1009
+ throw new Error("Conversation is closed");
1010
+ a && (f = await a(f));
1011
+ const v = await E.sendUserMessage(f, l);
1012
+ return l == null || l(v), v;
1013
+ },
1014
+ sendFileMessage: async (f) => {
1015
+ var S;
1016
+ if (((S = g == null ? void 0 : g.conversation) == null ? void 0 : S.status) === z.CLOSED)
1017
+ throw new Error("Conversation is closed");
1018
+ a && (f = await a(f));
1019
+ const v = await E.sendFileMessage(f, l);
1020
+ return l == null || l(v), v;
1021
+ }
1022
+ }
1023
+ };
1024
+ return /* @__PURE__ */ r.createElement(Zo, { value: b }, e);
1025
+ }
1026
+ function Jo(e) {
1027
+ const { chatSDK: t, logger: n } = Y(), [o, s] = T(void 0), [i, a] = T(void 0);
1028
+ async function l() {
1029
+ if (n.debug("conversation.fetchChannel: start"), s(void 0), a(void 0), e)
1030
+ try {
1031
+ n.debug("conversation.fetchChannel: get channel", e);
1032
+ const c = await t.groupChannel.getChannel(e);
1033
+ s(c), n.debug("conversation.fetchChannel: fetched channel", c);
1034
+ } catch (c) {
1035
+ c instanceof Hr && a(c), n.error("conversation.fetchChannel: error", c);
1036
+ }
1037
+ }
1038
+ return Xo(o), L(() => {
1039
+ l();
1040
+ }, [t, e]), {
1041
+ channel: o,
1042
+ channelFetchError: i,
1043
+ fetchChannel: l
1044
+ };
1045
+ }
1046
+ function Xo(e) {
1047
+ const { chatSDK: t } = Y(), { activeChannel: n, setActiveChannel: o } = Ko(), s = _t();
1048
+ L(() => {
1049
+ if (!e || !n) return;
1050
+ const i = new Qe({
1051
+ onReconnectSucceeded: async () => {
1052
+ var l;
1053
+ const a = await e.refresh();
1054
+ a.url === n.url && o({
1055
+ url: a.url,
1056
+ status: ((l = a.conversation) == null ? void 0 : l.status) ?? z.OPEN
1057
+ });
1058
+ }
1059
+ });
1060
+ return t.addConnectionHandler(s, i), () => {
1061
+ t.removeConnectionHandler(s);
1062
+ };
1063
+ }, [t, e, n]);
1064
+ }
1065
+ class Qo {
1066
+ /**
1067
+ * Creates a new ConversationListCollection instance.
1068
+ * @param sdk - The Sendbird Chat SDK instance
1069
+ * @param params - Configuration parameters for the collection
1070
+ */
1071
+ constructor(t, { filter: n, limit: o = 20 }) {
1072
+ var s, i, a, l, c;
1073
+ this._isDisposed = !1, this._handlerId = `handler-id-${Date.now()}`, this._order = $n.LATEST_LAST_MESSAGE, this.filter = n, this._sdk = t, this._pinnedChannels = [], this._channels = [], this._limit = o, this._query = this._sdk.aiAgent.createMyGroupChannelListQuery({
1074
+ aiAgentChannelFilter: (s = this.filter) == null ? void 0 : s.aiAgentChannelFilter,
1075
+ aiAgentConversationStatusFilter: (i = this.filter) == null ? void 0 : i.aiAgentConversationStatusFilter,
1076
+ aiAgentIds: (a = this.filter) == null ? void 0 : a.aiAgentIds,
1077
+ deskChannelFilter: (l = this.filter) == null ? void 0 : l.deskChannelFilter,
1078
+ pinnedChannelUrls: (c = this.filter) == null ? void 0 : c.pinnedChannelUrls,
1079
+ limit: this._limit
1080
+ }), this._token = "", this._timestamp = Number.MAX_SAFE_INTEGER, this._isSyncing = !1, this._channelHandler = new Qr({
1081
+ onChannelChanged: (u) => {
1082
+ u.isGroupChannel() && (this._query.belongsTo(u) ? this._addChannelsToView([u], !1) : this._removeChannelsFromView([u.url]));
1083
+ },
1084
+ onChannelDeleted: (u) => {
1085
+ this._removeChannelsFromView([u]);
1086
+ }
1087
+ }), this._connectionHandler = new Qe({
1088
+ onReconnectSucceeded: () => {
1089
+ this._isDefaultChangelogSyncTimestampUpdated && this._syncChannelChangelogs();
1090
+ }
1091
+ }), this._sdk.addConnectionHandler(this._handlerId, this._connectionHandler), this._sdk.groupChannel.addGroupChannelHandler(this._handlerId, this._channelHandler);
1092
+ }
1093
+ /**
1094
+ * Checks if the default changelog sync timestamp has been updated.
1095
+ */
1096
+ get _isDefaultChangelogSyncTimestampUpdated() {
1097
+ return this._timestamp !== Number.MAX_SAFE_INTEGER;
1098
+ }
1099
+ /**
1100
+ * Sets the default changelog sync timestamp based on the first non-pinned channel.
1101
+ * @param channels - Array of channels to analyze
1102
+ */
1103
+ _setDefaultChangelogsSyncTimestamp(t) {
1104
+ var i, a;
1105
+ const n = new Set(((i = this.filter) == null ? void 0 : i.pinnedChannelUrls) ?? []), o = t.find((l) => !n.has(l.url));
1106
+ let s;
1107
+ o ? s = ((a = o.lastMessage) == null ? void 0 : a.createdAt) ?? o.createdAt : s = this._query.lastResponseAt, this._timestamp > s && (this._timestamp = s);
1108
+ }
1109
+ /**
1110
+ * Synchronizes channel changelogs to keep the collection up-to-date.
1111
+ * @returns Promise that resolves to an empty array
1112
+ */
1113
+ async _syncChannelChangelogs() {
1114
+ if (this._isDisposed) return [];
1115
+ if (this._isSyncing) return [];
1116
+ try {
1117
+ this._isSyncing = !0;
1118
+ let t;
1119
+ for (this._token ? t = await this._sdk.aiAgent.getMyGroupChannelChangeLogsByToken(this._token, this.filter) : t = await this._sdk.aiAgent.getMyGroupChannelChangeLogsByTimestamp(this._timestamp, this.filter), this._token = t.token, this._addChannelsToView(t.updatedChannels), this._removeChannelsFromView(t.deletedChannelUrls); t.hasMore && t.token; )
1120
+ t = await this._sdk.aiAgent.getMyGroupChannelChangeLogsByToken(this._token, this.filter), this._token = t.token, this._addChannelsToView(t.updatedChannels), this._removeChannelsFromView(t.deletedChannelUrls);
1121
+ } catch {
1122
+ } finally {
1123
+ this._isSyncing = !1;
1124
+ }
1125
+ return [];
1126
+ }
1127
+ /**
1128
+ * Upserts pinned channels maintaining the order specified in pinnedChannelUrls.
1129
+ * @param channels - Pinned channels to upsert
1130
+ * @returns Object containing added, updated channels and unmatched URLs
1131
+ */
1132
+ _upsertPinnedChannelsToArray(t) {
1133
+ var l;
1134
+ const n = ((l = this.filter) == null ? void 0 : l.pinnedChannelUrls) ?? [], o = new Map(n.map((c, u) => [c, u])), s = [], i = [], a = [];
1135
+ for (const c of t) {
1136
+ if (!this._query.belongsTo(c)) {
1137
+ a.push(c.url);
1138
+ continue;
1139
+ }
1140
+ const u = o.get(c.url);
1141
+ if (u === void 0) continue;
1142
+ const h = xt(this._pinnedChannels, c);
1143
+ h >= 0 ? (this._pinnedChannels.splice(h, 1), i.push(c)) : s.push(c);
1144
+ const x = this._pinnedChannels.findIndex((E) => (o.get(E.url) ?? 1 / 0) > u), y = x === -1 ? this._pinnedChannels.length : x;
1145
+ this._pinnedChannels.splice(y, 0, c);
1146
+ }
1147
+ return { addedChannels: s, updatedChannels: i, unmatchedChannelUrls: a };
1148
+ }
1149
+ /**
1150
+ * Upserts regular (non-pinned) channels with time-based sorting.
1151
+ * @param channels - Regular channels to upsert
1152
+ * @param forceAppend - Whether to force append channels at the end regardless of hasMore status
1153
+ * @returns Object containing added, updated channels and unmatched URLs
1154
+ */
1155
+ _upsertRegularChannelsToArray(t, n = !1) {
1156
+ const o = [], s = [], i = [];
1157
+ for (const a of t) {
1158
+ if (!this._query.belongsTo(a)) {
1159
+ o.push(a.url);
1160
+ continue;
1161
+ }
1162
+ const l = xt(this._channels, a), c = l < 0;
1163
+ !c && this._channels.splice(l, 1);
1164
+ const h = es(this._channels, a, this._order).place, g = h === this._channels.length;
1165
+ c ? g ? (n || !this.hasMore) && (this._channels.push(a), s.push(a)) : (this._channels.splice(h, 0, a), s.push(a)) : (this._channels.splice(h, 0, a), i.push(a));
1166
+ }
1167
+ return { addedChannels: s, updatedChannels: i, unmatchedChannelUrls: o };
1168
+ }
1169
+ /**
1170
+ * Adds or updates channels in the collection, separating pinned and non-pinned channels.
1171
+ * @param channels - Channels to add or update
1172
+ * @param forceAppend - Whether to force append channels at the end
1173
+ */
1174
+ _addChannelsToView(t, n = !1) {
1175
+ var g, x, y, E, b;
1176
+ const o = new Set(((g = this.filter) == null ? void 0 : g.pinnedChannelUrls) ?? []), s = [], i = [];
1177
+ for (const p of t)
1178
+ o.has(p.url) ? s.push(p) : i.push(p);
1179
+ const a = this._upsertPinnedChannelsToArray(s), l = this._upsertRegularChannelsToArray(i, n), c = a.addedChannels.concat(l.addedChannels), u = a.updatedChannels.concat(l.updatedChannels), h = a.unmatchedChannelUrls.concat(l.unmatchedChannelUrls);
1180
+ c.length > 0 && ((y = (x = this._collectionEventHandler) == null ? void 0 : x.onChannelsAdded) == null || y.call(x, {}, c)), u.length > 0 && ((b = (E = this._collectionEventHandler) == null ? void 0 : E.onChannelsUpdated) == null || b.call(E, {}, u)), h.length > 0 && this._removeChannelsFromView(h);
1181
+ }
1182
+ /**
1183
+ * Removes channels from the collection by their URLs.
1184
+ * @param channelUrls - Array of channel URLs to remove
1185
+ */
1186
+ _removeChannelsFromView(t) {
1187
+ var s, i, a;
1188
+ const n = new Set(((s = this.filter) == null ? void 0 : s.pinnedChannelUrls) ?? []), o = [];
1189
+ for (const l of t)
1190
+ if (n.has(l)) {
1191
+ const c = this._pinnedChannels.findIndex((u) => u.url === l);
1192
+ c >= 0 && (o.push(l), this._pinnedChannels.splice(c, 1));
1193
+ } else {
1194
+ const c = this._channels.findIndex((u) => u.url === l);
1195
+ c >= 0 && (o.push(l), this._channels.splice(c, 1));
1196
+ }
1197
+ o.length > 0 && ((a = (i = this._collectionEventHandler) == null ? void 0 : i.onChannelsDeleted) == null || a.call(i, {}, o));
1198
+ }
1199
+ /**
1200
+ * Gets all channels in the collection.
1201
+ * Pinned channels are always returned first, followed by non-pinned channels.
1202
+ * @returns Array of GroupChannel objects
1203
+ */
1204
+ get channels() {
1205
+ return this._isDisposed ? [] : [...this._pinnedChannels, ...this._channels];
1206
+ }
1207
+ /**
1208
+ * Indicates whether the collection has more channels to load.
1209
+ * @returns True if more channels can be loaded, false otherwise
1210
+ */
1211
+ get hasMore() {
1212
+ return this._isDisposed ? !1 : this._query.hasNext;
1213
+ }
1214
+ /**
1215
+ * Loads the next batch of channels from the server.
1216
+ * @returns Promise that resolves to an array of newly loaded channels
1217
+ */
1218
+ async loadMore() {
1219
+ if (this._isDisposed) return [];
1220
+ if (this.hasMore) {
1221
+ const t = await this._query.next();
1222
+ return this._setDefaultChangelogsSyncTimestamp(t), this._addChannelsToView(t, !0), t;
1223
+ }
1224
+ return [];
1225
+ }
1226
+ /**
1227
+ * Sets the event handler for collection updates.
1228
+ * @param handler - Event handler for channel collection changes
1229
+ */
1230
+ setConversationListCollectionHandler(t) {
1231
+ this._collectionEventHandler = t;
1232
+ }
1233
+ /**
1234
+ * Disposes the collection and cleans up all resources.
1235
+ * Stops all event handlers and clears all channels.
1236
+ */
1237
+ dispose() {
1238
+ this._isDisposed || (this._isDisposed = !0, this._collectionEventHandler = void 0, this._sdk.removeConnectionHandler(this._handlerId), this._sdk.groupChannel.removeGroupChannelHandler(this._handlerId), this._pinnedChannels.length = 0, this._channels.length = 0);
1239
+ }
1240
+ }
1241
+ const xt = (e, t) => e.findIndex((n) => n.isIdentical(t)), es = (e, t, n) => {
1242
+ if (e.length > 0) {
1243
+ const o = xt(e, t);
1244
+ let s = 0, i = e.length - 1, a = Math.floor((s + i) / 2);
1245
+ for (; s < i; ) {
1246
+ const c = en(e[a], t, n);
1247
+ if (c > 0)
1248
+ i = a, a = Math.floor((s + i) / 2);
1249
+ else if (c < 0)
1250
+ s = a + 1, a = Math.floor((s + i) / 2);
1251
+ else
1252
+ return { place: a, oldPosition: o };
1253
+ }
1254
+ return { place: en(e[a], t, n) >= 0 ? a : a + 1, oldPosition: o };
1255
+ }
1256
+ return { place: e.length, oldPosition: -1 };
1257
+ }, en = (e, t, n) => {
1258
+ switch (n) {
1259
+ case $n.LATEST_LAST_MESSAGE:
1260
+ if (e.lastMessage && t.lastMessage) {
1261
+ const o = t.lastMessage.createdAt - e.lastMessage.createdAt;
1262
+ return o === 0 ? t.createdAt - e.createdAt : o;
1263
+ } else return e.lastMessage ? -1 : t.lastMessage ? 1 : t.createdAt - e.createdAt;
1264
+ default:
1265
+ return 0;
1266
+ }
1267
+ };
1268
+ function ts(e, t) {
1269
+ var E, b, p, f, v, S, M, P;
1270
+ const n = _t(), [o, s] = T(!1), [i, a] = T(null), [l, c] = T([]), [u, h] = T(null), g = F(!1), x = D(async () => {
1271
+ if (!g.current && e.currentUser) {
1272
+ g.current = !0, s(!1), a(null), c([]);
1273
+ try {
1274
+ u == null || u.dispose();
1275
+ const $ = new Qo(e, t);
1276
+ $.setConversationListCollectionHandler({
1277
+ onChannelsAdded: () => {
1278
+ c($.channels);
1279
+ },
1280
+ onChannelsUpdated: () => {
1281
+ c($.channels);
1282
+ },
1283
+ onChannelsDeleted: () => {
1284
+ c($.channels);
1285
+ }
1286
+ }), await $.loadMore(), h($), a(null);
1287
+ } catch ($) {
1288
+ h(null), a($);
1289
+ } finally {
1290
+ s(!0), g.current = !1;
1291
+ }
1292
+ }
1293
+ }, [
1294
+ e,
1295
+ (E = t.filter) == null ? void 0 : E.aiAgentChannelFilter,
1296
+ (p = (b = t.filter) == null ? void 0 : b.aiAgentConversationStatusFilter) == null ? void 0 : p.join(),
1297
+ (v = (f = t.filter) == null ? void 0 : f.aiAgentIds) == null ? void 0 : v.join(),
1298
+ (S = t.filter) == null ? void 0 : S.deskChannelFilter,
1299
+ (P = (M = t.filter) == null ? void 0 : M.pinnedChannelUrls) == null ? void 0 : P.join(),
1300
+ t.limit
1301
+ ]), y = D(async () => {
1302
+ if (u)
1303
+ try {
1304
+ await u.loadMore();
1305
+ } catch ($) {
1306
+ a($);
1307
+ }
1308
+ }, [u]);
1309
+ return L(() => (e.addConnectionHandler(n, new Qe({ onConnected: () => x() })), () => e.removeConnectionHandler(n)), [e, n, x]), L(() => {
1310
+ x();
1311
+ }, [x]), L(() => () => {
1312
+ g.current = !1, u == null || u.dispose();
1313
+ }, [u]), {
1314
+ initialized: o,
1315
+ error: i,
1316
+ channels: l,
1317
+ loadMore: y
1318
+ };
1319
+ }
1320
+ const {
1321
+ Provider: ns
1322
+ } = W("AIAgentConversationList");
1323
+ function rs({
1324
+ conversationListLimit: e,
1325
+ conversationListFilter: t,
1326
+ children: n
1327
+ }) {
1328
+ var g, x;
1329
+ const { chatSDK: o, aiAgentId: s, queryParams: i } = Y(), a = { aiAgentIds: [s], aiAgentConversationStatusFilter: [z.CLOSED] }, l = e ?? ((g = i == null ? void 0 : i.conversationListParams) == null ? void 0 : g.limit), c = {
1330
+ ...a,
1331
+ ...(x = i == null ? void 0 : i.conversationListParams) == null ? void 0 : x.filter,
1332
+ ...t
1333
+ }, u = ts(o, { limit: l, filter: c }), h = {
1334
+ listSource: {
1335
+ initialized: u.initialized,
1336
+ error: u.error ?? void 0,
1337
+ channels: u.channels,
1338
+ loadMore: () => u.loadMore()
1339
+ }
1340
+ };
1341
+ return /* @__PURE__ */ r.createElement(ns, { value: h }, n);
1342
+ }
1343
+ function os(e) {
1344
+ let t = "pending", n = e.then((o) => {
1345
+ t = "resolved", n = o;
1346
+ }).catch((o) => {
1347
+ t = "rejected", n = o;
1348
+ });
1349
+ return {
1350
+ get value() {
1351
+ if (t === "resolved")
1352
+ return n;
1353
+ throw n;
1354
+ }
1355
+ };
1356
+ }
1357
+ const {
1358
+ Provider: ss,
1359
+ useContext: Bn
1360
+ } = W("MessageTemplateFetching");
1361
+ function is({ children: e, internalVariables: t }) {
1362
+ const n = F({}), o = F({}), [s, i] = T({}), a = D((u, h) => {
1363
+ i((g) => ({
1364
+ ...g,
1365
+ [u]: { fetching: !1, error: !1, ...g[u], ...h }
1366
+ }));
1367
+ }, []), l = D(
1368
+ async ({
1369
+ onRequestTemplate: u,
1370
+ onGetCachedTemplate: h,
1371
+ templateKey: g,
1372
+ suspense: x = !1
1373
+ }) => {
1374
+ const y = h(g);
1375
+ if (y) return y;
1376
+ const E = o.current[g];
1377
+ if (E) return E;
1378
+ x || a(g, { fetching: !0 });
1379
+ const b = u(g).catch((p) => {
1380
+ throw x || a(g, { error: !0 }), p;
1381
+ }).finally(() => {
1382
+ x || a(g, { fetching: !1 }), delete o.current[g];
1383
+ });
1384
+ return o.current[g] = b, b;
1385
+ },
1386
+ [a]
1387
+ ), c = {
1388
+ internalVariables: t,
1389
+ fetchTemplate: l,
1390
+ suspend: (u, h) => {
1391
+ if (n.current[u])
1392
+ return n.current[u];
1393
+ const g = os(h());
1394
+ return n.current[u] = g, g;
1395
+ },
1396
+ getIsFetching: (u) => {
1397
+ var h;
1398
+ return ((h = s[u]) == null ? void 0 : h.fetching) ?? !1;
1399
+ },
1400
+ getHasError: (u) => {
1401
+ var h;
1402
+ return ((h = s[u]) == null ? void 0 : h.error) ?? !1;
1403
+ }
1404
+ };
1405
+ return /* @__PURE__ */ r.createElement(ss, { value: c }, e);
1406
+ }
1407
+ const nt = {
1408
+ VARIABLE: (e) => new RegExp(`\\{${e}\\}`, "g"),
1409
+ VIEW_VARIABLE: (e) => new RegExp(`"{@${e}}"`, "g")
1410
+ };
1411
+ function de({ uiTemplateString: e, variables: t = {} }) {
1412
+ const n = Vo(t);
1413
+ return wt({
1414
+ template: e,
1415
+ variables: n,
1416
+ variableKeyPattern: (o) => nt.VARIABLE(o)
1417
+ });
1418
+ }
1419
+ function ue({
1420
+ theme: e,
1421
+ uiTemplateString: t,
1422
+ colorVariables: n = {}
1423
+ }) {
1424
+ return wt({
1425
+ template: t,
1426
+ variables: n,
1427
+ variableKeyPattern: (o) => nt.VARIABLE(o),
1428
+ variableValueTransformer: (o) => Ho(e, o)
1429
+ });
1430
+ }
1431
+ function as({
1432
+ theme: e,
1433
+ uiTemplateString: t,
1434
+ viewVariables: n = {},
1435
+ aiAgentColorVariables: o,
1436
+ internalVariables: s,
1437
+ onRequestTemplate: i
1438
+ }) {
1439
+ const l = Object.values(n).flat().map((u) => u.key);
1440
+ return [...new Set(l)].some((u) => !i(u)) ? null : wt({
1441
+ template: t,
1442
+ variables: n,
1443
+ variableKeyPattern: (u) => nt.VIEW_VARIABLE(u),
1444
+ variableValueTransformer: (u) => {
1445
+ const h = u.map(({ key: g, variables: x }) => {
1446
+ const y = i(g), { ui_template: E, color_variables: b } = Re(y);
1447
+ let p = JSON.stringify(E);
1448
+ return p = de({
1449
+ uiTemplateString: p,
1450
+ variables: s
1451
+ }), p = ue({
1452
+ theme: e,
1453
+ uiTemplateString: p,
1454
+ colorVariables: b
1455
+ }), p = ue({
1456
+ theme: e,
1457
+ uiTemplateString: p,
1458
+ colorVariables: o
1459
+ }), p = de({
1460
+ uiTemplateString: p,
1461
+ variables: x
1462
+ }), tt(p);
1463
+ });
1464
+ return JSON.stringify(h);
1465
+ }
1466
+ });
1467
+ }
1468
+ async function ls({
1469
+ theme: e,
1470
+ uiTemplateString: t,
1471
+ viewVariables: n = {},
1472
+ aiAgentColorVariables: o,
1473
+ internalVariables: s,
1474
+ onRequestTemplate: i
1475
+ }) {
1476
+ return zo({
1477
+ template: t,
1478
+ variables: n,
1479
+ variableKeyPattern: (a) => nt.VIEW_VARIABLE(a),
1480
+ variableValueTransformer: async (a) => {
1481
+ const l = a.map(async ({ key: u, variables: h }) => {
1482
+ const g = await i(u), { ui_template: x, color_variables: y } = Re(g);
1483
+ let E = JSON.stringify(x);
1484
+ return E = de({
1485
+ uiTemplateString: E,
1486
+ variables: s
1487
+ }), E = ue({
1488
+ theme: e,
1489
+ uiTemplateString: E,
1490
+ colorVariables: y
1491
+ }), E = ue({
1492
+ theme: e,
1493
+ uiTemplateString: E,
1494
+ colorVariables: o
1495
+ }), E = de({
1496
+ uiTemplateString: E,
1497
+ variables: h
1498
+ }), tt(E);
1499
+ }), c = await Promise.all(l);
1500
+ return JSON.stringify(c);
1501
+ }
1502
+ });
1503
+ }
1504
+ const cs = ({
1505
+ rawTemplate: e,
1506
+ aiAgentColorVariables: t,
1507
+ internalVariables: n,
1508
+ ...o
1509
+ }) => {
1510
+ const { ui_template: s, color_variables: i } = Re(e);
1511
+ let a = JSON.stringify(s);
1512
+ if (Object.keys(o.viewVariables ?? {}).length > 0) {
1513
+ const c = as({
1514
+ ...o,
1515
+ uiTemplateString: a,
1516
+ aiAgentColorVariables: t,
1517
+ internalVariables: n
1518
+ });
1519
+ if (c === null) return null;
1520
+ a = c;
1521
+ }
1522
+ return a = de({ ...o, uiTemplateString: a, variables: n }), a = ue({ ...o, uiTemplateString: a, colorVariables: i }), a = ue({ ...o, uiTemplateString: a, colorVariables: t }), a = de({ ...o, uiTemplateString: a }), tt(a);
1523
+ }, ds = async ({
1524
+ rawTemplate: e,
1525
+ aiAgentColorVariables: t,
1526
+ internalVariables: n,
1527
+ ...o
1528
+ }) => {
1529
+ const { ui_template: s, color_variables: i } = Re(e);
1530
+ let a = JSON.stringify(s);
1531
+ return Object.keys(o.viewVariables ?? {}).length > 0 && (a = await ls({
1532
+ ...o,
1533
+ uiTemplateString: a,
1534
+ aiAgentColorVariables: t,
1535
+ internalVariables: n
1536
+ })), a = de({ ...o, uiTemplateString: a, variables: n }), a = ue({ ...o, uiTemplateString: a, colorVariables: i }), a = ue({ ...o, uiTemplateString: a, colorVariables: t }), a = de({ ...o, uiTemplateString: a }), tt(a);
1537
+ }, us = (e) => {
1538
+ const { aiAgentColorVariables: t = {} } = e, { internalVariables: n } = Bn();
1539
+ return T(() => {
1540
+ const o = e.onGetCachedTemplate(e.templateKey);
1541
+ return o ? cs({
1542
+ ...e,
1543
+ rawTemplate: o,
1544
+ aiAgentColorVariables: t,
1545
+ internalVariables: n,
1546
+ onRequestTemplate: e.onGetCachedTemplate
1547
+ }) : null;
1548
+ });
1549
+ }, ms = (e) => {
1550
+ const [t] = us(e);
1551
+ if (t) return t;
1552
+ const { aiAgentColorVariables: n = {} } = e, { internalVariables: o, fetchTemplate: s, suspend: i } = Bn();
1553
+ return i(e.templateKey, async () => {
1554
+ const l = await s({ ...e, suspense: !0 });
1555
+ return await ds({
1556
+ ...e,
1557
+ rawTemplate: l,
1558
+ aiAgentColorVariables: n,
1559
+ internalVariables: o
1560
+ });
1561
+ }).value;
1562
+ }, hs = {
1563
+ required: "This question is required",
1564
+ minLength: (e) => `Minimum ${e} characters required`,
1565
+ maxLength: (e) => `Maximum ${e} characters allowed`,
1566
+ min: (e) => `Minimum value is ${e}`,
1567
+ max: (e) => `Maximum value is ${e}`,
1568
+ minSelect: (e) => `Select at least ${e} options`,
1569
+ maxSelect: (e) => `Select at most ${e} options`,
1570
+ regex: "Invalid format",
1571
+ invalidSelection: "Invalid selection"
1572
+ }, gs = {
1573
+ getValueOrDefault: (e) => e.value ?? e.default_value ?? null,
1574
+ validate: (e, t, n) => {
1575
+ const o = t;
1576
+ if (e.required && (!o || o.trim() === ""))
1577
+ return {
1578
+ isValid: !1,
1579
+ error: n.required
1580
+ };
1581
+ if (!o)
1582
+ return { isValid: !0 };
1583
+ const { rules: s } = e;
1584
+ if (s) {
1585
+ if (s.min_length !== void 0 && o.length < s.min_length)
1586
+ return {
1587
+ isValid: !1,
1588
+ error: typeof n.minLength == "function" ? n.minLength(s.min_length) : n.minLength
1589
+ };
1590
+ if (s.max_length !== void 0 && o.length > s.max_length)
1591
+ return {
1592
+ isValid: !1,
1593
+ error: typeof n.maxLength == "function" ? n.maxLength(s.max_length) : n.maxLength
1594
+ };
1595
+ if (s.regex && !new RegExp(s.regex).test(o))
1596
+ return {
1597
+ isValid: !1,
1598
+ error: n.regex
1599
+ };
1600
+ }
1601
+ return { isValid: !0 };
1602
+ }
1603
+ }, ps = {
1604
+ getValueOrDefault: (e) => e.value ?? e.default_value ?? null,
1605
+ validate: (e, t, n) => {
1606
+ const o = t;
1607
+ if (e.required && o === null)
1608
+ return {
1609
+ isValid: !1,
1610
+ error: n.required
1611
+ };
1612
+ if (o === null)
1613
+ return { isValid: !0 };
1614
+ const { rules: s } = e;
1615
+ if (s) {
1616
+ if (s.min !== void 0 && o < s.min)
1617
+ return {
1618
+ isValid: !1,
1619
+ error: typeof n.min == "function" ? n.min(s.min) : n.min
1620
+ };
1621
+ if (s.max !== void 0 && o > s.max)
1622
+ return {
1623
+ isValid: !1,
1624
+ error: typeof n.max == "function" ? n.max(s.max) : n.max
1625
+ };
1626
+ }
1627
+ return { isValid: !0 };
1628
+ }
1629
+ }, fs = {
1630
+ getValueOrDefault: (e) => e.value ?? e.default_value ?? null,
1631
+ validate: (e, t, n) => {
1632
+ const o = t;
1633
+ return e.required && !o ? {
1634
+ isValid: !1,
1635
+ error: n.required
1636
+ } : o && !e.options.includes(o) ? {
1637
+ isValid: !1,
1638
+ error: n.invalidSelection
1639
+ } : { isValid: !0 };
1640
+ }
1641
+ }, bs = {
1642
+ getValueOrDefault: (e) => e.values ?? e.default_values ?? null,
1643
+ validate: (e, t, n) => {
1644
+ const o = t;
1645
+ if (e.required && (!o || o.length === 0))
1646
+ return {
1647
+ isValid: !1,
1648
+ error: n.required
1649
+ };
1650
+ if (!o || o.length === 0)
1651
+ return { isValid: !0 };
1652
+ if (o.filter((a) => !e.options.includes(a)).length > 0)
1653
+ return {
1654
+ isValid: !1,
1655
+ error: n.invalidSelection
1656
+ };
1657
+ const { rules: i } = e;
1658
+ if (i) {
1659
+ if (i.min_select !== void 0 && o.length < i.min_select)
1660
+ return {
1661
+ isValid: !1,
1662
+ error: typeof n.minSelect == "function" ? n.minSelect(i.min_select) : n.minSelect
1663
+ };
1664
+ if (i.max_select !== void 0 && o.length > i.max_select)
1665
+ return {
1666
+ isValid: !1,
1667
+ error: typeof n.maxSelect == "function" ? n.maxSelect(i.max_select) : n.maxSelect
1668
+ };
1669
+ }
1670
+ return { isValid: !0 };
1671
+ }
1672
+ }, xs = {
1673
+ text: gs,
1674
+ number: ps,
1675
+ "single-select": fs,
1676
+ "multi-select": bs
1677
+ }, Es = {
1678
+ getValueOrDefault: () => null,
1679
+ validate: () => ({ isValid: !1 })
1680
+ };
1681
+ function Pn(e) {
1682
+ return xs[e.type] || Es;
1683
+ }
1684
+ function tn(e) {
1685
+ return Pn(e).getValueOrDefault(e);
1686
+ }
1687
+ function vs(e, t, n = {}) {
1688
+ const o = { ...hs, ...n };
1689
+ return Pn(e).validate(e, t, o);
1690
+ }
1691
+ const ys = (e, t = {}) => {
1692
+ const { labels: n = {}, onSubmit: o, onCancel: s } = t, [i, a] = T({}), [l, c] = T(() => {
1693
+ const b = {};
1694
+ return e.fields.forEach((p) => {
1695
+ b[p.key] = tn(p);
1696
+ }), b;
1697
+ }), u = ee(() => e.submitted_at ? "submitted" : e.canceled_at ? "canceled" : "draft", [e.submitted_at, e.canceled_at]);
1698
+ L(() => {
1699
+ if (u === "submitted" || u === "canceled") {
1700
+ const b = {};
1701
+ let p = !1;
1702
+ e.fields.forEach((f) => {
1703
+ const v = tn(f);
1704
+ JSON.stringify(l[f.key]) !== JSON.stringify(v) && (p = !0), b[f.key] = v;
1705
+ }), p && c(b);
1706
+ }
1707
+ }, [u]);
1708
+ const h = (b, p) => {
1709
+ c((f) => ({ ...f, [b]: p })), a((f) => ({ ...f, [b]: void 0 }));
1710
+ }, g = e.fields.map((b) => {
1711
+ var v, S, M;
1712
+ const p = l[b.key] ?? null, f = {
1713
+ key: b.key,
1714
+ label: b.label,
1715
+ error: i[b.key],
1716
+ required: b.required
1717
+ };
1718
+ return b.type === "text" ? {
1719
+ ...f,
1720
+ type: "text",
1721
+ layout: b.layout,
1722
+ value: p,
1723
+ ...b.placeholder && { placeholder: b.placeholder },
1724
+ ...((v = b.rules) == null ? void 0 : v.max_length) && { maxLength: b.rules.max_length }
1725
+ } : b.type === "number" ? {
1726
+ ...f,
1727
+ type: "number",
1728
+ layout: b.layout,
1729
+ value: p,
1730
+ ...b.placeholder && { placeholder: b.placeholder },
1731
+ ...((S = b.rules) == null ? void 0 : S.max) && { max: b.rules.max }
1732
+ } : b.type === "single-select" ? {
1733
+ ...f,
1734
+ type: "single-select",
1735
+ layout: b.layout,
1736
+ value: p,
1737
+ options: b.options
1738
+ } : b.type === "multi-select" ? {
1739
+ ...f,
1740
+ type: "multi-select",
1741
+ layout: b.layout,
1742
+ value: p,
1743
+ options: b.options,
1744
+ ...((M = b.rules) == null ? void 0 : M.max_select) && { maxSelect: b.rules.max_select }
1745
+ } : { ...f, type: "unknown", layout: "default", value: null };
1746
+ });
1747
+ return {
1748
+ state: u,
1749
+ fields: g,
1750
+ getField: (b) => g.find((p) => p.key === b),
1751
+ updateFieldValue: h,
1752
+ submit: async () => {
1753
+ const b = {};
1754
+ let p = !1;
1755
+ for (const f of e.fields) {
1756
+ const v = l[f.key] ?? null, S = vs(f, v, n);
1757
+ S.isValid || (b[f.key] = S.error, p = !0);
1758
+ }
1759
+ if (a(b), !p && o) {
1760
+ const f = {};
1761
+ e.fields.forEach((v) => {
1762
+ f[v.key] = l[v.key] ?? null;
1763
+ }), await o(f);
1764
+ }
1765
+ },
1766
+ cancel: async () => {
1767
+ await (s == null ? void 0 : s());
1768
+ }
1769
+ };
1770
+ }, Cs = '@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}', De = "en", _s = /* @__PURE__ */ new Set([
1771
+ De,
1772
+ "ko",
1773
+ "es",
1774
+ "pt",
1775
+ "fr",
1776
+ "hi",
1777
+ "it",
1778
+ "de",
1779
+ "tr",
1780
+ "ja"
1781
+ ]), Ss = (e, t, n) => {
1782
+ const o = e[t];
1783
+ return o ? typeof o == "function" ? o() : Promise.resolve(o) : new Promise((s, i) => {
1784
+ (typeof queueMicrotask == "function" ? queueMicrotask : setTimeout)(
1785
+ i.bind(
1786
+ null,
1787
+ new Error(
1788
+ "Unknown variable dynamic import: " + t + (t.split("/").length !== n ? ". Note that variables only represent file names one level deep." : "")
1789
+ )
1790
+ )
1791
+ );
1792
+ });
1793
+ }, Ts = Kr, ws = {
1794
+ // Channel - Common
1795
+ CHANNEL_FROZEN: "Channel frozen",
1796
+ PLACE_HOLDER__WRONG: "Something went wrong",
1797
+ PLACE_HOLDER__NO_MESSAGES: "No messages",
1798
+ UNKNOWN__UNKNOWN_MESSAGE_TYPE: "(Unknown message type)",
1799
+ // Channel - Header
1800
+ HEADER_BUTTON__AGENT_HANDOFF: "Connect with an agent",
1801
+ // Message Input
1802
+ MESSAGE_INPUT__PLACE_HOLDER: "Ask a question",
1803
+ MESSAGE_INPUT__PLACE_HOLDER__WAIT_AI_AGENT_RESPONSE: "Waiting for the agent’s reply…",
1804
+ MESSAGE_INPUT__PLACE_HOLDER__DISABLED: "Chat is unavailable in this channel",
1805
+ // Common UI
1806
+ BUTTON__CANCEL: "Cancel",
1807
+ BUTTON__SAVE: "Save",
1808
+ BUTTON__OK: "OK",
1809
+ BUTTON__SUBMIT: "Submit",
1810
+ NO_NAME: "(No name)",
1811
+ RETRY: "Retry",
1812
+ OPTIONAL: "optional",
1813
+ SUBMITTED: "Submitted",
1814
+ TRY_AGAIN: "Please try again.",
1815
+ // Date format
1816
+ DATE_FORMAT__MESSAGE_LIST__DATE_SEPARATOR: "MMMM dd, yyyy",
1817
+ DATE_FORMAT__MESSAGE_TIMESTAMP: "p",
1818
+ // File Upload
1819
+ FILE_UPLOAD_NOTIFICATION__COUNT_LIMIT: "You can't upload more than one image",
1820
+ FILE_UPLOAD_NOTIFICATION__SIZE_LIMIT: "The maximum size per file is %d MB.",
1821
+ // File Viewer
1822
+ FILE_VIEWER__UNSUPPORT: "Unsupported message",
1823
+ // CSAT
1824
+ CSAT_TITLE_UNSUBMITTED: "Your feedback matters to us",
1825
+ CSAT_TITLE_SUBMITTED: "Successfully submitted!",
1826
+ CSAT_CRE_TITLE: "Was your issue resolved?",
1827
+ CSAT_CRE_SOLVED: "Yes, thank you! 👍",
1828
+ CSAT_CRE_NOT_SOLVED: "No, that didn’t help.",
1829
+ CSAT_REASON_PLACEHOLDER: "Share your feedback",
1830
+ CSAT_RATING_TITLE: "How would you rate your experience?",
1831
+ CSAT5_RATING_SCORE_1: "Terrible",
1832
+ CSAT5_RATING_SCORE_2: "Bad",
1833
+ CSAT5_RATING_SCORE_3: "Okay",
1834
+ CSAT5_RATING_SCORE_4: "Good",
1835
+ CSAT5_RATING_SCORE_5: "Great",
1836
+ CSAT_SUBMIT_LABEL: "Submit",
1837
+ CSAT_SUBMISSION_EXPIRED: "We’re sorry, the survey period has ended.",
1838
+ POWERED_BY: "Powered by",
1839
+ // Conversation list
1840
+ CONVERSATION_CLOSED_FOOTER_LABEL: "Your conversation has ended",
1841
+ START_NEW_CONVERSATION: "💬 Start a new conversation",
1842
+ RETURN_TO_CONVERSATION: "💬 Return to conversation",
1843
+ CONVERSATION_LIST__HEADER_TITLE: "Conversation history",
1844
+ CONVERSATION_LIST__TOPICS_FALLBACK: "No category",
1845
+ CONVERSATION_LIST__NO_CONVERSATIONS: "No conversations yet",
1846
+ DATE_FORMAT__CONVERSATION_LIST__LIST_ITEM_TITLE: "MM/dd/yyyy",
1847
+ DATE_FORMAT__CONVERSATION_LIST__LIST_ITEM_TITLE_CAPTION: "h:mma",
1848
+ // Citation
1849
+ CITATION_SOURCE_TITLE: "Source",
1850
+ // Form
1851
+ FORM_PLACEHOLDER: "Please fill out the form to move forward.",
1852
+ FORM_UNAVAILABLE: "Form is no longer available.",
1853
+ FORM_NOT_SUPPORTED: "This form is not supported in the current version.",
1854
+ FORM_VALIDATION_REQUIRED: "This question is required",
1855
+ FORM_VALIDATION_MIN_LENGTH: (e) => `Minimum ${e} characters required`,
1856
+ FORM_VALIDATION_MAX_LENGTH: (e) => `Maximum ${e} characters allowed`,
1857
+ FORM_VALIDATION_MIN: (e) => `Minimum value is ${e}`,
1858
+ FORM_VALIDATION_MAX: (e) => `Maximum value is ${e}`,
1859
+ FORM_VALIDATION_MIN_SELECT: (e) => `Select at least ${e} options`,
1860
+ FORM_VALIDATION_MAX_SELECT: (e) => `Select at most ${e} options`,
1861
+ FORM_VALIDATION_REGEX_FAILED: "Invalid format"
1862
+ }, At = { language: "en", dateLocale: Ts, stringSet: ws }, As = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1863
+ __proto__: null,
1864
+ default: At
1865
+ }, Symbol.toStringTag, { value: "Module" })), Ze = /* @__PURE__ */ new Map([[De, At]]);
1866
+ async function ks(e) {
1867
+ if (Ze.has(e))
1868
+ return Ze.get(e);
1869
+ const t = _s.has(e) ? e : De;
1870
+ try {
1871
+ const { default: n } = await Ss(/* @__PURE__ */ Object.assign({ "./languages/de.ts": () => import("./qC-GIbc4.js"), "./languages/en.ts": () => Promise.resolve().then(() => As), "./languages/es.ts": () => import("./B7zUx3wi.js"), "./languages/fr.ts": () => import("./BOQBJafG.js"), "./languages/hi.ts": () => import("./BDu5g5oT.js"), "./languages/it.ts": () => import("./BgVN3jH0.js"), "./languages/ja.ts": () => import("./DGEcXOnE.js"), "./languages/ko.ts": () => import("./fgcpgo5V.js"), "./languages/pt.ts": () => import("./CGGa6Wi6.js"), "./languages/tr.ts": () => import("./B-Bit2rH.js") }), `./languages/${t}.ts`, 3);
1872
+ return Ze.set(e, n), n;
1873
+ } catch {
1874
+ return At;
1875
+ }
1876
+ }
1877
+ const {
1878
+ Provider: Is,
1879
+ useContext: R
1880
+ } = W("Localization");
1881
+ function $s(e) {
1882
+ var t;
1883
+ return ((t = e.split("-")) == null ? void 0 : t[0]) ?? De;
1884
+ }
1885
+ function Ms({
1886
+ language: e = navigator.language,
1887
+ logger: t,
1888
+ stringSet: n,
1889
+ children: o
1890
+ }) {
1891
+ const [s, i] = T(Ze.get(De));
1892
+ return L(() => {
1893
+ const a = $s(e);
1894
+ s.language !== a && (t == null || t.debug("localization.useEffect: update language", `${s.language} -> ${a}`), ks(a).then(i));
1895
+ }, [e]), /* @__PURE__ */ r.createElement(
1896
+ Is,
1897
+ {
1898
+ value: {
1899
+ language: s.language,
1900
+ stringSet: { ...s.stringSet, ...n },
1901
+ dateLocale: s.dateLocale,
1902
+ format: (a, l, c) => In(a, l, { locale: s.dateLocale, ...c })
1903
+ }
1904
+ },
1905
+ o
1906
+ );
1907
+ }
1908
+ const Ye = "data-sb-agent-theme", nn = (e) => (t, ...n) => {
1909
+ let o = "";
1910
+ return t.forEach((s, i) => {
1911
+ o += s + (n[i] ?? "");
1912
+ }), `[${Ye}='${e}'] & { ${o} }`;
1913
+ }, I = {
1914
+ light: nn("light"),
1915
+ dark: nn("dark")
1916
+ }, Os = _(({ theme: e }) => {
1917
+ const { palette: t } = e;
1918
+ return `
1919
+ :root,
1920
+ :host {
1921
+ --sendbird-primary-extra-dark: ${t.primary.extraDark};
1922
+ --sendbird-primary-dark: ${t.primary.dark};
1923
+ --sendbird-primary-main: ${t.primary.main};
1924
+ --sendbird-primary-light: ${t.primary.light};
1925
+ --sendbird-primary-extra-light: ${t.primary.extraLight};
1926
+
1927
+ --sendbird-secondary-extra-dark: ${t.secondary.extraDark};
1928
+ --sendbird-secondary-dark: ${t.secondary.dark};
1929
+ --sendbird-secondary-main: ${t.secondary.main};
1930
+ --sendbird-secondary-light: ${t.secondary.light};
1931
+ --sendbird-secondary-extra-light: ${t.secondary.extraLight};
1932
+
1933
+ --sendbird-information-extra-dark: ${t.information.extraDark};
1934
+ --sendbird-information-dark: ${t.information.dark};
1935
+ --sendbird-information-main: ${t.information.main};
1936
+ --sendbird-information-light: ${t.information.light};
1937
+ --sendbird-information-extra-light: ${t.information.extraLight};
1938
+
1939
+ --sendbird-error-extra-dark: ${t.error.extraDark};
1940
+ --sendbird-error-dark: ${t.error.dark};
1941
+ --sendbird-error-main: ${t.error.main};
1942
+ --sendbird-error-light: ${t.error.light};
1943
+ --sendbird-error-extra-light: ${t.error.extraLight};
1944
+
1945
+ --sendbird-background-700: ${t.background700};
1946
+ --sendbird-background-600: ${t.background600};
1947
+ --sendbird-background-500: ${t.background500};
1948
+ --sendbird-background-400: ${t.background400};
1949
+ --sendbird-background-300: ${t.background300};
1950
+ --sendbird-background-200: ${t.background200};
1951
+ --sendbird-background-100: ${t.background100};
1952
+ --sendbird-background-50: ${t.background50};
1953
+
1954
+ --sendbird-onlight-text-high-emphasis: ${t.onlight.textHighEmphasis};
1955
+ --sendbird-onlight-text-mid-emphasis: ${t.onlight.textMidEmphasis};
1956
+ --sendbird-onlight-text-low-emphasis: ${t.onlight.textLowEmphasis};
1957
+ --sendbird-onlight-text-disabled: ${t.onlight.textDisabled};
1958
+
1959
+ --sendbird-ondark-text-high-emphasis: ${t.ondark.textHighEmphasis};
1960
+ --sendbird-ondark-text-mid-emphasis: ${t.ondark.textMidEmphasis};
1961
+ --sendbird-ondark-text-low-emphasis: ${t.ondark.textLowEmphasis};
1962
+ --sendbird-ondark-text-disabled: ${t.ondark.textDisabled};
1963
+
1964
+ --sendbird-overlay-dark: ${t.overlay.dark};
1965
+ --sendbird-overlay-light: ${t.overlay.light};
1966
+ }
1967
+ `;
1968
+ }), Ls = _`[${Ye}='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);}[${Ye}='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);}`, d = {
1969
+ color: {
1970
+ primary: {
1971
+ dark: "var(--sendbird-primary-dark)",
1972
+ main: "var(--sendbird-primary-main)"
1973
+ },
1974
+ information: {
1975
+ main: "var(--sendbird-information-main)",
1976
+ light: "var(--sendbird-information-light)"
1977
+ },
1978
+ background700: "var(--sendbird-background-700)",
1979
+ background500: "var(--sendbird-background-500)",
1980
+ background400: "var(--sendbird-background-400)",
1981
+ background200: "var(--sendbird-background-200)",
1982
+ background100: "var(--sendbird-background-100)",
1983
+ background50: "var(--sendbird-background-50)",
1984
+ onlight: {
1985
+ textLowEmphasis: "var(--sendbird-onlight-text-low-emphasis)"
1986
+ },
1987
+ ondark: {
1988
+ textMidEmphasis: "var(--sendbird-ondark-text-mid-emphasis)",
1989
+ textLowEmphasis: "var(--sendbird-ondark-text-low-emphasis)",
1990
+ textDisabled: "var(--sendbird-ondark-text-disabled)"
1991
+ },
1992
+ overlay: {
1993
+ dark: "var(--sendbird-overlay-dark)"
1994
+ }
1995
+ },
1996
+ themedColor: {
1997
+ textHighEmphasis: "var(--sb-text-high-emphasis)",
1998
+ textMidEmphasis: "var(--sb-text-mid-emphasis)",
1999
+ textLowEmphasis: "var(--sb-text-low-emphasis)",
2000
+ textDisabled: "var(--sb-text-disabled)",
2001
+ textHighEmphasisInverse: "var(--sb-text-high-emphasis-inverse)",
2002
+ bg_50_600: "var(--sb-bg-50-600)",
2003
+ bg_100_500: "var(--sb-bg-100-500)",
2004
+ bg_200_400: "var(--sb-bg-200-400)",
2005
+ primary: "var(--sb-primary)",
2006
+ error: "var(--sb-error)"
2007
+ }
2008
+ }, {
2009
+ Provider: Rs,
2010
+ useContext: Un
2011
+ } = W("MessengerTheme");
2012
+ function Ds(e) {
2013
+ const { theme: t, appearance: n, logger: o } = e;
2014
+ return /* @__PURE__ */ r.createElement(
2015
+ Ro,
2016
+ {
2017
+ appearance: n,
2018
+ palette: t == null ? void 0 : t.palette,
2019
+ typography: t == null ? void 0 : t.typography,
2020
+ logger: o
2021
+ },
2022
+ /* @__PURE__ */ r.createElement(Ns, { ...e })
2023
+ );
2024
+ }
2025
+ function Ns({ rootElement: e = document.body, children: t }) {
2026
+ const { theme: n, updateTheme: o } = Tt();
2027
+ return pe(() => {
2028
+ e.setAttribute(Ye, n.selectedTheme);
2029
+ }, [e, n.selectedTheme]), /* @__PURE__ */ r.createElement(zr, { theme: n }, /* @__PURE__ */ r.createElement(Rs, { value: { theme: n, updateTheme: o, rootElement: e } }, t));
2030
+ }
2031
+ function fe(e, t) {
2032
+ const n = e.getRootNode({ composed: t });
2033
+ return n instanceof ShadowRoot || n instanceof Document ? n : document;
2034
+ }
2035
+ const Fs = (e, t) => {
2036
+ L(() => {
2037
+ const n = fe(t) instanceof ShadowRoot, o = fe(t, !0);
2038
+ if (!(n ? t : o).querySelector(`link[href*='${e}']`)) {
2039
+ const i = o.createElement("link");
2040
+ i.rel = "stylesheet", i.href = e, (n ? t : o.head).appendChild(i);
2041
+ }
2042
+ }, [e, t]);
2043
+ }, Bs = (e, t = document.body) => {
2044
+ L(() => {
2045
+ const n = fe(t), s = n instanceof ShadowRoot ? t : n.head;
2046
+ if (!s) return;
2047
+ const i = `sba-${btoa(e).slice(0, 10)}`;
2048
+ let a = s.querySelector(`style#${i}`);
2049
+ a ? a.textContent !== e && (a.textContent = e) : (a = s.ownerDocument.createElement("style"), a.id = i, a.textContent = e, s.appendChild(a));
2050
+ }, [e, t]);
2051
+ }, kt = /iPad|iPhone|iPod/.test(navigator.userAgent), Ps = /Android/.test(navigator.userAgent), Ne = (e) => kt || Ps, {
2052
+ Provider: Us,
2053
+ Consumer: Hn,
2054
+ useContext: H
2055
+ } = W("Messenger");
2056
+ function Hs({
2057
+ children: e,
2058
+ state: t,
2059
+ enableCloseConversationButton: n = !1,
2060
+ enableExpandButton: o = !0,
2061
+ enableAutoDisconnectInLauncher: s = !0,
2062
+ ...i
2063
+ }) {
2064
+ const [a, l] = T(!1), [c, u] = T(!1), h = {
2065
+ opened: (t == null ? void 0 : t.opened) ?? a,
2066
+ setOpened: (t == null ? void 0 : t.setOpened) ?? l,
2067
+ expanded: (t == null ? void 0 : t.expanded) ?? c,
2068
+ setExpanded: (t == null ? void 0 : t.setExpanded) ?? u
2069
+ };
2070
+ return /* @__PURE__ */ r.createElement(bo, { ...i }, (g) => /* @__PURE__ */ r.createElement(
2071
+ Us,
2072
+ {
2073
+ value: {
2074
+ ...i,
2075
+ ...g,
2076
+ state: h,
2077
+ enableCloseConversationButton: n,
2078
+ enableExpandButton: o,
2079
+ enableAutoDisconnectInLauncher: s
2080
+ }
2081
+ },
2082
+ e
2083
+ ));
2084
+ }
2085
+ const {
2086
+ Provider: Vs,
2087
+ useContext: V
2088
+ } = W("MessengerSession"), zs = Se(function({ children: e, ...t }, n) {
2089
+ return /* @__PURE__ */ r.createElement(qo, { ref: n, ...t }, (o) => /* @__PURE__ */ r.createElement(Ws, { ...o }, e));
2090
+ }), Ws = ({ children: e, ...t }) => {
2091
+ const { chatSDK: n, logger: o, appId: s, aiAgentId: i, agentPreviewConfigs: a, state: l } = H(), { userSessionInfo: c, authenticate: u, setActiveChannel: h, userSession: g, aiAgentInfo: x, launcherInfo: y } = t;
2092
+ return et(n, {
2093
+ async onUserJoined(E, b) {
2094
+ var f, v;
2095
+ if (E.conversation && E.conversation.type === Zr.PROACTIVE && b.userId === ((f = n.currentUser) == null ? void 0 : f.userId)) {
2096
+ o.info("messengerSession.onUserJoined: proactive channel joined", E.url);
2097
+ const S = ((v = E.conversation) == null ? void 0 : v.status) ?? z.OPEN;
2098
+ h({ url: E.url, status: S }), l.setOpened(!0), Gs({ sound: document.hidden || !l.opened });
2099
+ }
2100
+ }
2101
+ }), L(() => {
2102
+ u().then(({ launcher: E }) => {
2103
+ E.auto_open && !Ne() && setTimeout(() => l.setOpened(!0), 500);
2104
+ }).catch((E) => {
2105
+ o.error("messengerSession: failed to initialize", E);
2106
+ });
2107
+ }, [n, s, i, c == null ? void 0 : c.userId, c == null ? void 0 : c.authToken]), !g || !x || !y ? null : /* @__PURE__ */ r.createElement(
2108
+ Vs,
2109
+ {
2110
+ value: {
2111
+ ...t,
2112
+ userSession: g,
2113
+ aiAgentInfo: { ...x, ...a == null ? void 0 : a.bot },
2114
+ launcherInfo: { ...y, ...a == null ? void 0 : a.launcher }
2115
+ }
2116
+ },
2117
+ e
2118
+ );
2119
+ };
2120
+ function Gs({ sound: e }) {
2121
+ const t = "🔔You have received a new message", n = document.title, o = setInterval(() => {
2122
+ document.title = document.title === t ? n : t;
2123
+ }, 750);
2124
+ setTimeout(() => clearInterval(o), 5e3), e && import("./DP0MwObA.js").then((s) => {
2125
+ new Audio(s.default).play();
2126
+ });
2127
+ }
2128
+ const j = (e) => {
2129
+ const t = e;
2130
+ return typeof t == "number" ? `${t}px` : t;
2131
+ }, w = ({
2132
+ as: e,
2133
+ variant: t = "body1",
2134
+ color: n,
2135
+ className: o,
2136
+ ...s
2137
+ }) => /* @__PURE__ */ r.createElement(Ks, { as: e, $variant: t, className: o, $color: n, ...s }), rn = /* @__PURE__ */ new WeakMap(), js = (e, t) => {
2138
+ let n = rn.get(t);
2139
+ n || (n = /* @__PURE__ */ new Map(), rn.set(t, n));
2140
+ const o = n.get(e);
2141
+ if (o) return o;
2142
+ const s = t[e] ?? t.body1, i = _`font-size:${j(s.fontSize)};font-weight:${s.fontWeight};${s.fontFamily ? `font-family: ${s.fontFamily};` : ""}
2143
+ ${s.lineHeight ? `line-height: ${s.lineHeight};` : "line-height: 100%;"}
2144
+ `;
2145
+ return n.set(e, i), i;
2146
+ }, Ks = m.span`font-stretch:normal;letter-spacing:normal;${({ $variant: e, theme: t }) => js(e, t.typography)}color:${({ $color: e }) => e};`, re = "sb-agent", ie = {
2147
+ ENTRY: `${re}-entry`,
2148
+ MODAL_ROOT: `${re}-modal-root`,
2149
+ WINDOW: `${re}-window`,
2150
+ LAUNCHER: `${re}-launcher`
2151
+ }, Ve = 2147483647, xe = {
2152
+ MODAL: Ve - 1,
2153
+ // FIXME: need to cover the case where the tooltip is on the top of the modal
2154
+ TOOLTIP: Ve - 2,
2155
+ WINDOW: Ve - 3,
2156
+ LAUNCHER: Ve - 4
2157
+ }, Vn = {
2158
+ DEFAULT_PRIMARY: "#742ddd",
2159
+ WHITE: "#ffffff"
2160
+ }, zn = 36, qs = 100, Zs = 25 * 1024 * 1024, Wn = ["application/pdf", "image/jpeg", "image/jpg", "image/png"], It = "noopener noreferrer nofollow", be = 244, Gn = 640, Je = 26, jn = 4, ae = 12, Ae = 2, Ys = 16, le = `${re}-incoming-msg`, Js = `${re}-marked-text`;
2161
+ function $t(e) {
2162
+ switch (e) {
2163
+ case "top":
2164
+ case "middle":
2165
+ return Ae;
2166
+ default:
2167
+ return Ys;
2168
+ }
2169
+ }
2170
+ function Mt(e, t) {
2171
+ if (t) {
2172
+ const [, n] = t.split("/");
2173
+ if (n)
2174
+ return n.toUpperCase();
2175
+ }
2176
+ if (e && !e.startsWith(".")) {
2177
+ const n = e.split(".").pop();
2178
+ if (n && n !== e)
2179
+ return n.toUpperCase();
2180
+ }
2181
+ return "FILE";
2182
+ }
2183
+ function Kn(e) {
2184
+ return e.messageType === "file" ? e.message.length > 0 && e.file.name !== e.message : e.message.length > 0;
2185
+ }
2186
+ const Xs = /* @__PURE__ */ new Set(["send", "chat", "message", "chevron-right"]), Qs = {
2187
+ spinner: A(() => import("./BcUGcaq2.js")),
2188
+ chat: A(() => import("./DcFCGVBm.js")),
2189
+ message: A(() => import("./DsGXnanX.js")),
2190
+ error: A(() => import("./B6fvrWGq.js")),
2191
+ info: A(() => import("./CAIYsKDy.js")),
2192
+ refresh: A(() => import("./B6xd54zt.js")),
2193
+ "chevron-down": A(() => import("./BsimU71m.js")),
2194
+ "chevron-right": A(() => import("./NmJl7zv3.js")),
2195
+ done: A(() => import("./D_q6g3Dd.js")),
2196
+ user: A(() => import("./CvqfQEhO.js")),
2197
+ "file-document": A(() => import("./BAr50pfO.js")),
2198
+ download: A(() => import("./B2CtcWp3.js")),
2199
+ attach: A(() => import("./DY2ULcTX.js")),
2200
+ delete: A(() => import("./DMruRpOm.js")),
2201
+ close: A(() => import("./CuaBI7kd.js")),
2202
+ "close-filled": A(() => import("./CxQFWLnW.js")),
2203
+ send: A(() => import("./DZJyDpNp.js")),
2204
+ menu: A(() => import("./BUYabNz7.js")),
2205
+ expand: A(() => import("./wBtIAuNm.js")),
2206
+ collapse: A(() => import("./C0RFfifL.js")),
2207
+ agent: A(() => import("./Cc7XmLN1.js")),
2208
+ question: A(() => import("./dqwvRBog.js")),
2209
+ actionbook: A(() => import("./CrjNuryZ.js")),
2210
+ function: A(() => import("./CvdSjw1c.js")),
2211
+ "radio-on": A(() => import("./nmdo2Fbj.js")),
2212
+ "radio-off": A(() => import("./BnZcRFmS.js")),
2213
+ confluence: A(() => import("./BOnlh2zd.js")),
2214
+ zendesk: A(() => import("./BAJ6LEKc.js")),
2215
+ salesforce: A(() => import("./CT2kv4lr.js")),
2216
+ sprinklr: A(() => import("./m2INcyV2.js")),
2217
+ website: A(() => import("./BgGVGNdg.js")),
2218
+ snippet: A(() => import("./BFcXPuf5.js")),
2219
+ template: A(() => import("./awO7aBCv.js")),
2220
+ source: A(() => import("./_EVMCh6Y.js")),
2221
+ copy: A(() => import("./Y-x39_PW.js")),
2222
+ show: A(() => import("./oD5rM94o.js")),
2223
+ mute: A(() => import("./CBd3y0FA.js"))
2224
+ }, O = ({ type: e, size: t = 24, className: n, color: o }) => {
2225
+ const s = Qs[e];
2226
+ return /* @__PURE__ */ r.createElement(
2227
+ ti,
2228
+ {
2229
+ className: n,
2230
+ $rtlFlip: Xs.has(e),
2231
+ $size: t,
2232
+ $color: o ?? d.color.primary.main
2233
+ },
2234
+ /* @__PURE__ */ r.createElement(Oe, { fallback: null }, /* @__PURE__ */ r.createElement(s, null))
2235
+ );
2236
+ }, ei = _`[dir='rtl'] &{transform:scaleX(-1);}`, ti = m.div`width:${({ $size: e }) => j(e)};height:${({ $size: e }) => j(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};`;
2237
+ function Ot({
2238
+ name: e,
2239
+ type: t = "FILE",
2240
+ iconColor: n,
2241
+ iconBackgroundColor: o,
2242
+ onClick: s
2243
+ }) {
2244
+ const { colors: i } = St();
2245
+ return /* @__PURE__ */ r.createElement(ni, { onClick: s, $clickable: !!s }, /* @__PURE__ */ r.createElement(oi, { $bgColor: o ?? i.base.primary }, /* @__PURE__ */ r.createElement(O, { type: "file-document", size: 24, color: n ?? i.base.primaryContrastContent })), /* @__PURE__ */ r.createElement(si, null, /* @__PURE__ */ r.createElement(ii, { variant: "button", color: d.themedColor.textHighEmphasis }, e), /* @__PURE__ */ r.createElement(w, { color: d.themedColor.textMidEmphasis, variant: "caption3" }, t)));
2246
+ }
2247
+ const ni = m.div`border-radius:12px;gap:8px;width:${be}px;height:64px;display:flex;align-items:center;padding:12px;box-sizing:border-box;border:1px solid ${d.themedColor.textDisabled};background-color:${d.themedColor.bg_50_600};${({ $clickable: e }) => e && ri}`, ri = _`cursor:pointer;&:hover{background-color:${d.themedColor.bg_100_500};}`, oi = m.div`border-radius:8px;width:40px;height:40px;display:flex;align-items:center;justify-content:center;background-color:${({ $bgColor: e }) => e};`, si = m.div`display:flex;flex:1;flex-direction:column;gap:4px;min-width:0;`, ii = m(w)`text-overflow:ellipsis;white-space:nowrap;overflow:hidden;`;
2248
+ function ai({ file: e, children: t, onClickFile: n }) {
2249
+ return /* @__PURE__ */ r.createElement(li, null, /* @__PURE__ */ r.createElement(
2250
+ Ot,
2251
+ {
2252
+ name: e.name,
2253
+ type: Mt(e.name, e.type),
2254
+ onClick: n && (() => n == null ? void 0 : n(e))
2255
+ }
2256
+ ), t);
2257
+ }
2258
+ const li = m.div`display:flex;flex-direction:column;align-items:flex-start;gap:${Ae}px;`;
2259
+ function ci({ file: e, onClickMedia: t, children: n }) {
2260
+ const o = () => e.type.startsWith("image") ? /* @__PURE__ */ r.createElement(mi, { src: e.url, alt: "image-message" }) : e.type.startsWith("video") ? /* @__PURE__ */ r.createElement(hi, { controls: !0 }, /* @__PURE__ */ r.createElement("source", { src: e.url }), /* @__PURE__ */ r.createElement("track", { kind: "captions" })) : null;
2261
+ if (o) {
2262
+ const s = {
2263
+ id: `${le}-media-body`,
2264
+ onClick: () => t == null ? void 0 : t(e)
2265
+ };
2266
+ return /* @__PURE__ */ r.createElement(di, null, /* @__PURE__ */ r.createElement(ui, { ...s }, o()), n);
2267
+ }
2268
+ return null;
2269
+ }
2270
+ const di = m.div`display:flex;flex-direction:column;align-items:flex-start;gap:${Ae}px;`, ui = m.div`width:${be}px;height:160px;border-radius:12px;overflow:hidden;cursor:pointer;${I.light`
2271
+ background-color: ${d.color.background100};
2272
+ `}
2273
+ ${I.dark`
2274
+ background-color: ${d.color.background400};
2275
+ `}
2276
+ `, mi = m.img`width:100%;height:100%;object-fit:cover;`, hi = m.video`width:100%;height:100%;object-fit:cover;`, gi = "✱";
2277
+ function qn(e) {
2278
+ const t = new RegExp(`${gi}+`, "g");
2279
+ return e.replace(t, (n) => `<span id=${Js} aria-label="masked-text">${n}</span>`);
2280
+ }
2281
+ function pi(e) {
2282
+ return e.replace(/\*\*(.*?)\*\*/g, "<b>$1</b>");
2283
+ }
2284
+ function fi(e) {
2285
+ const t = /```(\w+)?\n([\s\S]*?)```/g, n = [];
2286
+ let o = 0;
2287
+ return e.replace(t, (s, ...i) => {
2288
+ const [a, l, c] = i;
2289
+ return o < c && n.push({
2290
+ type: "text",
2291
+ value: e.slice(o, c).trim()
2292
+ }), n.push({
2293
+ type: "code",
2294
+ value: l.trim(),
2295
+ language: a ? a.trim() : "plaintext"
2296
+ }), o = c + s.length, s;
2297
+ }), o < e.length && n.push({
2298
+ type: "text",
2299
+ value: e.slice(o).trim()
2300
+ }), n.map((s) => s.type !== "text" ? s : { ...s, value: qn(s.value) });
2301
+ }
2302
+ const bi = A(async () => ({ default: (await import("./DK3lW85j.js")).MarkdownText })), xi = A(async () => ({ default: (await import("./Ch_6OPTz.js")).CodeBlock }));
2303
+ function on(e) {
2304
+ var s, i;
2305
+ const t = e.maxBodyWidth ?? be, n = ee(() => fi(e.message), [e.message]), o = {
2306
+ id: `${le}-text-body`,
2307
+ $maxWidth: t,
2308
+ $color: (s = e.customStyle) == null ? void 0 : s.bubbleContentColor,
2309
+ $bgColor: (i = e.customStyle) == null ? void 0 : i.bubbleBackgroundColor
2310
+ };
2311
+ return n.length === 0 ? e.children ? /* @__PURE__ */ r.createElement(sn, { ...o }, e.children) : null : /* @__PURE__ */ r.createElement(sn, { ...o }, n.map((a, l) => a.type === "text" ? /* @__PURE__ */ r.createElement(an, { key: l, variant: "body3" }, /* @__PURE__ */ r.createElement(Oe, { fallback: a.value }, /* @__PURE__ */ r.createElement(bi, { onClickImage: (c) => {
2312
+ var u;
2313
+ return (u = e.onClickMedia) == null ? void 0 : u.call(e, { url: c, type: "image/*" });
2314
+ } }, a.value))) : a.type === "code" ? /* @__PURE__ */ r.createElement(Oe, { key: l, fallback: /* @__PURE__ */ r.createElement(an, { variant: "body3" }, a.value) }, /* @__PURE__ */ r.createElement(xi, { code: a.value, language: a.language })) : null), e.children);
2315
+ }
2316
+ const sn = m.div`display:flex;flex-direction:column;border-radius:12px;overflow:hidden;max-width:${({ $maxWidth: e }) => e}px;${({ theme: e, $color: t, $bgColor: n }) => _`
2317
+ color: ${t || e.colors.messageIncoming.text};
2318
+ background-color: ${n || e.colors.messageIncoming.background};
2319
+ `}
2320
+ padding: 12px 0;
2321
+ transition: max-width 0.3s;
2322
+ overflow-wrap: break-word;
2323
+ `, an = m(w)`align-items:flex-start;line-height:140%;white-space:pre-wrap;padding:0 12px;`;
2324
+ function Ei(e) {
2325
+ const { stringSet: t } = R(), n = Kn(e) ? /* @__PURE__ */ r.createElement(on, { ...e }) : null;
2326
+ if (e.messageType === "user")
2327
+ return n;
2328
+ if (e.messageType === "file") {
2329
+ const o = e.file;
2330
+ return o.type.startsWith("image") || o.type.startsWith("video") ? /* @__PURE__ */ r.createElement(ci, { ...e }, n) : /* @__PURE__ */ r.createElement(ai, { ...e }, n);
2331
+ }
2332
+ return /* @__PURE__ */ r.createElement(on, { ...e, message: t.UNKNOWN__UNKNOWN_MESSAGE_TYPE });
2333
+ }
2334
+ const Lt = (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" }));
2335
+ function Rt({ id: e, src: t, size: n = 56, onClick: o, style: s }) {
2336
+ return /* @__PURE__ */ r.createElement(vi, { id: e, tabIndex: 0, onClick: o, $size: j(n), style: s }, t ? /* @__PURE__ */ r.createElement(yi, { src: t }) : /* @__PURE__ */ r.createElement(O, { type: "user", size: n }));
2337
+ }
2338
+ const vi = m.div`border-radius:50%;display:inline-block;overflow:hidden;position:relative;flex-shrink:0;height:${(e) => e.$size};width:${(e) => e.$size};background-color:${d.themedColor.bg_100_500};&:focus{outline:none;}`, yi = m.img`object-fit:cover;width:100%;height:100%;position:absolute;`;
2339
+ function Ci({ sender: e, isBotMessage: t }) {
2340
+ const n = `${le}-sender-avatar`;
2341
+ return !e.profileUrl && t ? /* @__PURE__ */ r.createElement(_i, { id: n }, /* @__PURE__ */ r.createElement(Lt, null)) : /* @__PURE__ */ r.createElement(Rt, { id: n, size: Je, src: e.profileUrl });
2342
+ }
2343
+ const _i = m.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};}}`;
2344
+ function Si({ sender: e }) {
2345
+ return /* @__PURE__ */ r.createElement(Ti, { id: `${le}-sender-name`, variant: "caption1", color: d.themedColor.textMidEmphasis }, e.nickname);
2346
+ }
2347
+ const Ti = m(w)`text-align:start;width:100%;box-sizing:border-box;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;padding-block:5px;padding-inline:0 7px;`;
2348
+ function wi({ createdAt: e }) {
2349
+ const { stringSet: t, format: n } = R();
2350
+ return e ? /* @__PURE__ */ r.createElement(w, { id: `${le}-sent-time`, variant: "caption4", color: d.themedColor.textLowEmphasis }, n(e, t.DATE_FORMAT__MESSAGE_TIMESTAMP)) : null;
2351
+ }
2352
+ function Ai({ customStyle: e }) {
2353
+ return /* @__PURE__ */ r.createElement(ki, { $bgColor: e == null ? void 0 : e.bubbleBackgroundColor }, [0, 1, 2].map((t) => /* @__PURE__ */ r.createElement(Ii, { key: t, $color: e == null ? void 0 : e.bubbleContentColor })));
2354
+ }
2355
+ const ki = m.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};`, Ii = m.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;}`;
2356
+ function Le() {
2357
+ }
2358
+ async function Dt(e) {
2359
+ let t = e;
2360
+ t && (!t.startsWith("http://") && !t.startsWith("https://") && (t = "https://" + t), window.open(t, "_blank", "noopener,noreferrer"));
2361
+ }
2362
+ function Nt(e) {
2363
+ return !e || !e.conversation ? !1 : e.conversation.status === z.CLOSED;
2364
+ }
2365
+ function Zn(e) {
2366
+ return !e || !e.conversation ? !1 : e.conversation.status === z.OPEN;
2367
+ }
2368
+ function Ft(e) {
2369
+ var n;
2370
+ const t = (n = e == null ? void 0 : e.conversation) == null ? void 0 : n.handoff;
2371
+ return !!(t != null && t.timestamp);
2372
+ }
2373
+ function $i(e) {
2374
+ return Zn(e) && !Ft(e);
2375
+ }
2376
+ function Mi({
2377
+ extendedMessagePayload: e,
2378
+ onClickCTA: t = ({ url: n }) => Dt(n)
2379
+ }) {
2380
+ const n = e == null ? void 0 : e.cta_button;
2381
+ return n ? /* @__PURE__ */ r.createElement(Oi, { id: `${le}-ext-cta-button`, role: "button", onClick: () => t(n) }, /* @__PURE__ */ r.createElement(Li, { variant: "button" }, n.label)) : null;
2382
+ }
2383
+ const Oi = m.div`display:flex;align-items:center;justify-content:center;cursor:pointer;border-radius:6px;padding:8px;color:${d.themedColor.textHighEmphasis};background-color:${d.color.background50};${I.dark`
2384
+ background-color: ${d.color.ondark.textDisabled};
2385
+ `}
2386
+ `, Li = m(w)`overflow:hidden;text-overflow:ellipsis;white-space:nowrap;`;
2387
+ function Ri({
2388
+ extendedMessagePayload: e,
2389
+ onClickCitation: t = (n) => Dt(n.link)
2390
+ }) {
2391
+ const { stringSet: n } = R(), { theme: o } = Tt(), s = e == null ? void 0 : e.citations;
2392
+ return !s || s.length === 0 ? null : /* @__PURE__ */ r.createElement(Di, { id: `${le}-ext-citation` }, /* @__PURE__ */ r.createElement(Ni, { variant: "caption1", color: o.colors.messageIncoming.text }, n.CITATION_SOURCE_TITLE), /* @__PURE__ */ r.createElement(Fi, null, s.map((i, a) => /* @__PURE__ */ r.createElement(
2393
+ Pi,
2394
+ {
2395
+ key: `${i.embedding_id}-${a}`,
2396
+ role: "button",
2397
+ onClick: () => t(i)
2398
+ },
2399
+ /* @__PURE__ */ r.createElement(O, { type: "source", size: 16, color: o.colors.messageIncoming.text }),
2400
+ /* @__PURE__ */ r.createElement(Bi, { variant: "body3", color: o.colors.messageIncoming.text }, i.title)
2401
+ ))));
2402
+ }
2403
+ const Di = m.div`display:flex;flex-direction:column;gap:8px;border-radius:8px;padding:8px 12px 6px;`, Ni = m(w)`opacity:0.5;`, Fi = m.div`display:flex;flex-direction:column;gap:8px;`, Bi = m(w)`text-decoration:underline;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;`, Pi = m.div`display:flex;align-items:center;gap:4px;cursor:pointer;&:hover{opacity:0.5;}`, Yn = ({ rootElementId: e, visible: t, onClose: n, children: o }) => {
2404
+ if (!t) return null;
2405
+ const { rootElement: s } = Un(), i = fe(s), a = fe(s, !0);
2406
+ return eo(
2407
+ /* @__PURE__ */ r.createElement(Ui, { onClick: n }, /* @__PURE__ */ r.createElement(Hi, { onClick: (l) => l.stopPropagation() }, o)),
2408
+ i.getElementById(e) ?? i.getElementById(ie.MODAL_ROOT) ?? a.body
2409
+ );
2410
+ }, Ui = m.div`position:fixed;top:0;left:0;width:100%;height:100%;background:${d.color.overlay.dark};display:flex;justify-content:center;align-items:center;z-index:${xe.MODAL};`, Hi = m.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:${xe.MODAL};`, Jn = ({ visible: e, title: t, description: n, confirmText: o = "OK", onConfirm: s, onClose: i }) => {
2411
+ const a = () => {
2412
+ s == null || s(), i();
2413
+ };
2414
+ return /* @__PURE__ */ r.createElement(Yn, { rootElementId: ie.WINDOW, visible: e, onClose: i }, /* @__PURE__ */ r.createElement(Vi, null, /* @__PURE__ */ r.createElement(zi, null, t && /* @__PURE__ */ r.createElement(w, { variant: "h1", color: d.themedColor.textHighEmphasis }, t), n && /* @__PURE__ */ r.createElement(Wi, null, /* @__PURE__ */ r.createElement(w, { variant: "subtitle2", color: d.themedColor.textHighEmphasis }, n))), /* @__PURE__ */ r.createElement(Gi, null, /* @__PURE__ */ r.createElement(ji, { onClick: a }, /* @__PURE__ */ r.createElement(w, { variant: "button", color: d.themedColor.primary }, o)))));
2415
+ }, Vi = m.div`width:100%;height:auto;padding-block:24px 12px;padding-inline:24px;margin:0 auto;border-radius:4px;box-sizing:border-box;background-color:${({ theme: e }) => e.colors.base.modalContentBackground};`, zi = m.div`margin-bottom:16px;`, Wi = m.div`margin-top:8px;`, Gi = m.div`display:flex;flex-direction:row;justify-content:flex-end;`, ji = m.button`all:unset;display:flex;justify-content:center;align-items:center;border-radius:4px;cursor:pointer;background-color:transparent;padding:10px 16px;`, Bt = _`width:100%;height:36px;border-radius:6px;cursor:pointer;transition:all 0.2s ease;padding:0 12px;border:none;outline:none;display:flex;align-items:center;justify-content:center;&:disabled{cursor:not-allowed;}`, ln = m.button`${Bt};background-color:${d.themedColor.primary};color:${d.themedColor.textHighEmphasis};&:hover:not(:disabled){opacity:0.9;}`, Ki = m.button`${Bt};color:${d.themedColor.primary};${I.light`
2416
+ background-color: ${d.color.background50};
2417
+ `};
2418
+ ${I.dark`
2419
+ background-color: ${d.color.background700};
2420
+ `};
2421
+
2422
+ &:hover:not(:disabled) {
2423
+ opacity: 0.9;
2424
+ }
2425
+ `, qi = m.button`${Bt};background-color:transparent;color:${d.themedColor.textHighEmphasis};&:hover:not(:disabled){opacity:0.7;}`, Zi = (e) => {
2426
+ switch (e) {
2427
+ case "primary":
2428
+ return ln;
2429
+ case "secondary":
2430
+ return Ki;
2431
+ case "clear":
2432
+ return qi;
2433
+ default:
2434
+ return ln;
2435
+ }
2436
+ }, Yi = m.div`animation:1s infinite linear;animation-name:rotate;display:flex;align-items:center;justify-content:center;@keyframes rotate{from{transform:rotate(0);}to{transform:rotate(360deg);}}`, Ji = ({
2437
+ children: e,
2438
+ onClick: t,
2439
+ variant: n = "primary",
2440
+ disabled: o = !1,
2441
+ loading: s = !1,
2442
+ className: i
2443
+ }) => {
2444
+ const a = () => {
2445
+ switch (n) {
2446
+ case "primary":
2447
+ return d.themedColor.textHighEmphasisInverse;
2448
+ case "secondary":
2449
+ return d.themedColor.primary;
2450
+ case "clear":
2451
+ return d.themedColor.textHighEmphasis;
2452
+ default:
2453
+ return d.themedColor.textHighEmphasisInverse;
2454
+ }
2455
+ }, l = Zi(n);
2456
+ return /* @__PURE__ */ r.createElement(l, { onClick: t, disabled: o || s, className: i }, s ? /* @__PURE__ */ r.createElement(Yi, null, /* @__PURE__ */ r.createElement(O, { type: "spinner", size: 22, color: a() })) : /* @__PURE__ */ r.createElement(w, { variant: "button", color: a() }, e));
2457
+ }, Xi = ({ children: e, className: t, style: n }) => /* @__PURE__ */ r.createElement(w, { variant: "caption4", color: d.themedColor.error, className: t, style: n }, e), Qi = ({ children: e, className: t, style: n, required: o }) => {
2458
+ const { stringSet: s } = R();
2459
+ return /* @__PURE__ */ r.createElement(w, { variant: "caption3", color: d.themedColor.textMidEmphasis, className: t, style: n }, e, !o && /* @__PURE__ */ r.createElement("span", { style: { color: d.themedColor.textLowEmphasis } }, ` (${s.OPTIONAL})`));
2460
+ }, ea = ({
2461
+ value: e,
2462
+ onChange: t,
2463
+ placeholder: n,
2464
+ error: o = !1,
2465
+ submitted: s = !1,
2466
+ className: i,
2467
+ disabled: a = !1,
2468
+ max: l
2469
+ }) => {
2470
+ const c = (h) => {
2471
+ const x = h.target.value.replace(/[^0-9.-]/g, ""), y = x.split("."), b = y.length > 1 ? y[0] + "." + y.slice(1).join("").replace(/\./g, "") : x;
2472
+ if (h.target.value = b, b === "" || b === "-")
2473
+ t == null || t(null);
2474
+ else {
2475
+ const p = Number(b);
2476
+ if (!isNaN(p)) {
2477
+ if (l !== void 0 && p > l)
2478
+ return;
2479
+ t == null || t(p);
2480
+ }
2481
+ }
2482
+ }, u = e == null ? "" : String(e);
2483
+ return /* @__PURE__ */ r.createElement(
2484
+ sa,
2485
+ {
2486
+ type: "text",
2487
+ value: u,
2488
+ onChange: c,
2489
+ placeholder: n,
2490
+ className: i,
2491
+ disabled: a || s,
2492
+ inputMode: "decimal",
2493
+ $error: o,
2494
+ $submitted: s
2495
+ }
2496
+ );
2497
+ }, ta = _`width:100%;height:36px;padding:8px 12px;border-radius:6px;font-size:14px;font-weight:400;line-height:1.43;outline:none;transition:all 0.2s ease;&::placeholder{color:${d.themedColor.textLowEmphasis};}&::-webkit-inner-spin-button,&::-webkit-outer-spin-button{-webkit-appearance:none;margin:0;}`, na = _`color:${d.themedColor.textHighEmphasis};border:1px solid transparent;cursor:not-allowed;${I.light`
2498
+ background-color: ${d.color.ondark.textMidEmphasis};
2499
+ `}
2500
+ ${I.dark`
2501
+ background-color: ${d.color.onlight.textLowEmphasis};
2502
+ `}
2503
+
2504
+ &::placeholder {
2505
+ color: ${d.themedColor.textLowEmphasis};
2506
+ }
2507
+ `, ra = _`border:1px solid ${d.themedColor.error};color:${d.themedColor.textHighEmphasis};${I.light`
2508
+ background-color: ${d.color.background50};
2509
+ `}
2510
+ ${I.dark`
2511
+ background-color: ${d.color.onlight.textLowEmphasis};
2512
+ `}
2513
+ `, oa = _`border:1px solid ${d.themedColor.textDisabled};color:${d.themedColor.textHighEmphasis};${I.light`
2514
+ background-color: ${d.color.background50};
2515
+ `}
2516
+ ${I.dark`
2517
+ background-color: ${d.color.onlight.textLowEmphasis};
2518
+ `}
2519
+
2520
+ &:focus {
2521
+ border-color: ${d.themedColor.primary};
2522
+ }
2523
+ `, sa = m.input`${ta}${({ $error: e, $submitted: t }) => t ? na : e ? ra : oa}`, ia = (e) => {
2524
+ if (e.multiple) {
2525
+ const { value: t = [], onChange: n, maxSelect: o, submitted: s = !1 } = e;
2526
+ return {
2527
+ selectedValues: t,
2528
+ handleOptionClick: (a) => {
2529
+ if (s) return;
2530
+ if (t.includes(a)) {
2531
+ const c = t.filter((u) => u !== a);
2532
+ n == null || n(c);
2533
+ } else {
2534
+ if (o && t.length >= o)
2535
+ return;
2536
+ const c = [...t, a];
2537
+ n == null || n(c);
2538
+ }
2539
+ }
2540
+ };
2541
+ } else {
2542
+ const { value: t, onChange: n, submitted: o = !1 } = e;
2543
+ return {
2544
+ selectedValues: t ? [t] : [],
2545
+ handleOptionClick: (i) => {
2546
+ if (o) return;
2547
+ const a = t === i ? "" : i;
2548
+ n == null || n(a);
2549
+ }
2550
+ };
2551
+ }
2552
+ }, Xn = (e) => {
2553
+ const { options: t, submitted: n = !1, error: o = !1, className: s } = e, { selectedValues: i, handleOptionClick: a } = ia(e);
2554
+ return /* @__PURE__ */ r.createElement(la, { className: s }, t.map((l) => {
2555
+ const c = i.includes(l.value);
2556
+ return /* @__PURE__ */ r.createElement(
2557
+ pa,
2558
+ {
2559
+ key: l.value,
2560
+ $active: c,
2561
+ $submitted: n,
2562
+ $error: o,
2563
+ onClick: () => a(l.value)
2564
+ },
2565
+ /* @__PURE__ */ r.createElement(w, { variant: "caption1", color: aa(c, n) }, l.label)
2566
+ );
2567
+ }));
2568
+ }, aa = (e, t) => t ? e ? d.themedColor.textHighEmphasis : d.themedColor.textDisabled : e ? d.themedColor.primary : d.themedColor.textMidEmphasis, la = m.div`display:flex;flex-wrap:wrap;gap:4px 2px;`, ca = _`display:inline-flex;align-items:center;padding:8px 12px;border-radius:15px;transition:all 0.2s ease;`, da = _`cursor:default;background-color:${d.color.ondark.textMidEmphasis};color:${d.themedColor.textHighEmphasis};${I.dark`
2569
+ background-color: transparent;
2570
+ border: 1px solid white;
2571
+ color: white;
2572
+ `}
2573
+ `, ua = _`cursor:default;${I.light`
2574
+ background-color: ${d.color.ondark.textMidEmphasis};
2575
+ color: ${d.themedColor.textDisabled};
2576
+ `}
2577
+ ${I.dark`
2578
+ background-color: ${d.color.onlight.textLowEmphasis};
2579
+ border: 1px solid ${d.color.onlight.textLowEmphasis};
2580
+ color: ${d.themedColor.textDisabled};
2581
+ `}
2582
+ `, ma = _`cursor:pointer;border:1px solid ${d.themedColor.primary};${I.light`
2583
+ background-color: ${d.color.background50};
2584
+ color: ${d.themedColor.primary};
2585
+ `}
2586
+ ${I.dark`
2587
+ background-color: ${d.color.onlight.textLowEmphasis};
2588
+ color: ${d.themedColor.primary};
2589
+ `}
2590
+ `, ha = _`cursor:pointer;border:1px solid ${d.themedColor.textDisabled};${I.light`
2591
+ background-color: ${d.color.background50};
2592
+ color: ${d.themedColor.textMidEmphasis};
2593
+ `}
2594
+ ${I.dark`
2595
+ background-color: ${d.color.onlight.textLowEmphasis};
2596
+ color: ${d.themedColor.textMidEmphasis};
2597
+ `}
2598
+ `, ga = _`border-color:${d.themedColor.error}!important;`, pa = m.div`${ca}${({ $active: e, $submitted: t, $error: n }) => {
2599
+ if (t)
2600
+ return e ? da : ua;
2601
+ const o = e ? ma : ha;
2602
+ return n ? _`
2603
+ ${o} ${ga}
2604
+ ` : o;
2605
+ }}
2606
+ `, fa = (e) => /* @__PURE__ */ r.createElement(Xn, { ...e, multiple: !1 }), ba = (e) => /* @__PURE__ */ r.createElement(Xn, { ...e, multiple: !0 }), xa = m.div`width:100%;height:1px;background-color:${d.themedColor.textDisabled};`, Ea = ({ className: e }) => /* @__PURE__ */ r.createElement(xa, { className: e }), va = ({
2607
+ value: e = "",
2608
+ onChange: t,
2609
+ placeholder: n,
2610
+ variant: o = "single-line",
2611
+ error: s = !1,
2612
+ submitted: i = !1,
2613
+ className: a,
2614
+ disabled: l = !1,
2615
+ maxLength: c
2616
+ }) => {
2617
+ const h = {
2618
+ value: e,
2619
+ onChange: (g) => {
2620
+ const x = g.target.value;
2621
+ c && x.length > c || t == null || t(x);
2622
+ },
2623
+ placeholder: n,
2624
+ className: a,
2625
+ disabled: l || i,
2626
+ maxLength: c,
2627
+ $error: s,
2628
+ $submitted: i
2629
+ };
2630
+ return o === "multi-line" ? /* @__PURE__ */ r.createElement(Ca, { ...h, as: "textarea" }) : /* @__PURE__ */ r.createElement(ya, { ...h });
2631
+ }, Qn = _`width:100%;padding:8px 12px;border-radius:6px;font-size:14px;font-weight:400;line-height:1.43;outline:none;transition:all 0.2s ease;&::placeholder{color:${d.themedColor.textLowEmphasis};}`, er = _`color:${d.themedColor.textHighEmphasis};border:1px solid transparent;cursor:not-allowed;${I.light`
2632
+ background-color: ${d.color.ondark.textMidEmphasis};
2633
+ `}
2634
+ ${I.dark`
2635
+ background-color: ${d.color.onlight.textLowEmphasis};
2636
+ `}
2637
+
2638
+ &::placeholder {
2639
+ color: ${d.themedColor.textLowEmphasis};
2640
+ }
2641
+ `, tr = _`border:1px solid ${d.themedColor.error};color:${d.themedColor.textHighEmphasis};${I.light`
2642
+ background-color: ${d.color.background50};
2643
+ `}
2644
+ ${I.dark`
2645
+ background-color: ${d.color.onlight.textLowEmphasis};
2646
+ `}
2647
+ `, nr = _`border:1px solid ${d.themedColor.textDisabled};color:${d.themedColor.textHighEmphasis};${I.light`
2648
+ background-color: ${d.color.background50};
2649
+ `}
2650
+ ${I.dark`
2651
+ background-color: ${d.color.onlight.textLowEmphasis};
2652
+ `}
2653
+
2654
+ &:focus {
2655
+ border-color: ${d.themedColor.primary};
2656
+ }
2657
+ `, ya = m.input`${Qn}height:36px;${({ $error: e, $submitted: t }) => t ? er : e ? tr : nr}`, Ca = m.textarea`${Qn}height:96px;resize:vertical;font-family:inherit;${({ $error: e, $submitted: t }) => t ? er : e ? tr : nr}`, _a = ({ children: e, className: t, style: n }) => /* @__PURE__ */ r.createElement(w, { variant: "button", color: d.themedColor.textHighEmphasis, className: t, style: n }, e), Z = {
2658
+ Title: _a,
2659
+ Label: Qi,
2660
+ ErrorLabel: Xi,
2661
+ Separator: Ea,
2662
+ Button: Ji,
2663
+ TextInput: va,
2664
+ NumberInput: ea,
2665
+ SingleSelect: fa,
2666
+ MultiSelect: ba
2667
+ }, Sa = 1, Ta = /* @__PURE__ */ new Set(["text", "number", "single-select", "multi-select"]), wa = (e) => {
2668
+ var p;
2669
+ const t = (p = e.extendedMessagePayload) == null ? void 0 : p.form;
2670
+ if (!t) throw new Error("Form is not provided");
2671
+ const { stringSet: n } = R(), [o, s] = T({ submitting: !1, canceling: !1 }), [i, a] = T({
2672
+ visible: !1
2673
+ }), { state: l, fields: c, submit: u, cancel: h, updateFieldValue: g } = ys(t, {
2674
+ labels: {
2675
+ required: n.FORM_VALIDATION_REQUIRED,
2676
+ regex: n.FORM_VALIDATION_REGEX_FAILED,
2677
+ minLength: n.FORM_VALIDATION_MIN_LENGTH,
2678
+ maxLength: n.FORM_VALIDATION_MAX_LENGTH,
2679
+ min: n.FORM_VALIDATION_MIN,
2680
+ max: n.FORM_VALIDATION_MAX,
2681
+ minSelect: n.FORM_VALIDATION_MIN_SELECT,
2682
+ maxSelect: n.FORM_VALIDATION_MAX_SELECT
2683
+ },
2684
+ onSubmit: (f) => {
2685
+ var v;
2686
+ return (v = e.onSubmitForm) == null ? void 0 : v.call(e, { key: t.key, data: f });
2687
+ },
2688
+ onCancel: () => {
2689
+ var f;
2690
+ return (f = e.onCancelForm) == null ? void 0 : f.call(e, { key: t.key });
2691
+ }
2692
+ }), x = l === "submitted", y = async () => {
2693
+ s((f) => ({ ...f, submitting: !0 }));
2694
+ try {
2695
+ await u();
2696
+ } catch (f) {
2697
+ a({
2698
+ visible: !0,
2699
+ description: f instanceof Error ? f.message : n.TRY_AGAIN
2700
+ });
2701
+ } finally {
2702
+ s((f) => ({ ...f, submitting: !1 }));
2703
+ }
2704
+ }, E = async () => {
2705
+ s((f) => ({ ...f, canceling: !0 }));
2706
+ try {
2707
+ await h();
2708
+ } catch (f) {
2709
+ a({
2710
+ visible: !0,
2711
+ description: f instanceof Error ? f.message : n.TRY_AGAIN
2712
+ });
2713
+ } finally {
2714
+ s((f) => ({ ...f, canceling: !1 }));
2715
+ }
2716
+ }, b = ee(() => {
2717
+ const f = () => t.version > Sa, v = () => t.fields.some((S) => !Ta.has(S.type));
2718
+ return f() || v() ? { visible: !1, cancelable: !0, reason: n.FORM_NOT_SUPPORTED } : l === "draft" && (e.isHandedOff || e.isConversationClosed) ? { visible: !1, cancelable: !1, reason: n.FORM_UNAVAILABLE } : { visible: !0, cancelable: !0, reason: "" };
2719
+ }, [t.version, t.fields, l, e.isHandedOff, e.isConversationClosed]);
2720
+ return l === "canceled" ? null : b.visible ? /* @__PURE__ */ r.createElement(wn, null, /* @__PURE__ */ r.createElement(cn, { $maxWidth: e.maxBodyWidth ?? be }, /* @__PURE__ */ r.createElement(Z.Title, null, t.title), /* @__PURE__ */ r.createElement(Aa, null, c.map((f) => /* @__PURE__ */ r.createElement(ka, { key: f.key }, /* @__PURE__ */ r.createElement(Z.Label, { style: { marginBottom: "6px" }, required: f.required }, f.label), f.type === "text" && /* @__PURE__ */ r.createElement(
2721
+ Z.TextInput,
2722
+ {
2723
+ value: f.value || "",
2724
+ placeholder: f.placeholder,
2725
+ onChange: (v) => g(f.key, v),
2726
+ disabled: x,
2727
+ error: !!f.error,
2728
+ submitted: x,
2729
+ variant: f.layout === "multiline" ? "multi-line" : "single-line",
2730
+ maxLength: f.maxLength
2731
+ }
2732
+ ), f.type === "number" && /* @__PURE__ */ r.createElement(
2733
+ Z.NumberInput,
2734
+ {
2735
+ value: f.value || null,
2736
+ placeholder: f.placeholder,
2737
+ onChange: (v) => g(f.key, v),
2738
+ disabled: x,
2739
+ error: !!f.error,
2740
+ submitted: x,
2741
+ max: f.max
2742
+ }
2743
+ ), f.type === "single-select" && /* @__PURE__ */ r.createElement(
2744
+ Z.SingleSelect,
2745
+ {
2746
+ options: f.options.map((v) => ({ label: v, value: v })),
2747
+ value: f.value || "",
2748
+ onChange: (v) => g(f.key, v),
2749
+ submitted: x
2750
+ }
2751
+ ), f.type === "multi-select" && /* @__PURE__ */ r.createElement(
2752
+ Z.MultiSelect,
2753
+ {
2754
+ options: f.options.map((v) => ({ label: v, value: v })),
2755
+ value: f.value || [],
2756
+ onChange: (v) => g(f.key, v),
2757
+ submitted: x,
2758
+ maxSelect: f.maxSelect
2759
+ }
2760
+ ), f.error && /* @__PURE__ */ r.createElement(Z.ErrorLabel, { style: { marginTop: "4px" } }, f.error)))), /* @__PURE__ */ r.createElement(Z.Separator, null), /* @__PURE__ */ r.createElement(Ia, null, /* @__PURE__ */ r.createElement(
2761
+ Z.Button,
2762
+ {
2763
+ variant: x ? "clear" : "primary",
2764
+ onClick: y,
2765
+ disabled: x || o.canceling,
2766
+ loading: o.submitting
2767
+ },
2768
+ x ? n.SUBMITTED : n.BUTTON__SUBMIT
2769
+ ), l !== "submitted" && /* @__PURE__ */ r.createElement(
2770
+ Z.Button,
2771
+ {
2772
+ variant: "secondary",
2773
+ onClick: E,
2774
+ disabled: o.submitting,
2775
+ loading: o.canceling
2776
+ },
2777
+ n.BUTTON__CANCEL
2778
+ ))), /* @__PURE__ */ r.createElement(Jn, { ...i, onClose: () => a({ visible: !1, title: "" }) })) : /* @__PURE__ */ r.createElement(cn, { $maxWidth: e.maxBodyWidth ?? be }, /* @__PURE__ */ r.createElement(w, { variant: "body3" }, b.reason), b.cancelable && /* @__PURE__ */ r.createElement(Z.Button, { variant: "primary", onClick: E, loading: o.canceling }, n.BUTTON__CANCEL));
2779
+ }, cn = m.div`display:flex;flex-direction:column;gap:12px;border-radius:12px;overflow:hidden;max-width:${({ $maxWidth: e }) => e}px;${({ theme: e }) => _`
2780
+ color: ${e.colors.messageIncoming.text};
2781
+ background-color: ${e.colors.messageIncoming.background};
2782
+ `}
2783
+ padding: 16px 12px;
2784
+ transition: max-width 0.3s;
2785
+ overflow-wrap: break-word;
2786
+ `, Aa = m.div`display:flex;flex-direction:column;gap:12px;`, ka = m.div`display:flex;flex-direction:column;`, Ia = m.div`display:flex;flex-direction:column;gap:8px;`;
2787
+ function $a(e) {
2788
+ return /* @__PURE__ */ r.createElement(r.Fragment, null);
2789
+ }
2790
+ class Ma extends Lr {
2791
+ constructor(t) {
2792
+ super(t), this.state = {
2793
+ hasError: !1
2794
+ };
2795
+ }
2796
+ static getDerivedStateFromError() {
2797
+ return { hasError: !0 };
2798
+ }
2799
+ render() {
2800
+ return this.state.hasError ? this.props.errorFallback : /* @__PURE__ */ r.createElement(Oe, { fallback: this.props.loadingFallback }, this.props.children);
2801
+ }
2802
+ }
2803
+ const Oa = /* @__PURE__ */ new Set(["default"]), { MessageTemplate: La } = oo({
2804
+ parser: no,
2805
+ renderer: to,
2806
+ Container: (e) => /* @__PURE__ */ r.createElement("div", { ...e })
2807
+ });
2808
+ function Ra(e) {
2809
+ return /* @__PURE__ */ r.createElement(
2810
+ Ma,
2811
+ {
2812
+ errorFallback: e.messageTemplateErrorFallback,
2813
+ loadingFallback: e.messageTemplateLoadingFallback
2814
+ },
2815
+ /* @__PURE__ */ r.createElement(Da, { ...e })
2816
+ );
2817
+ }
2818
+ const Da = ({
2819
+ extendedMessagePayload: e,
2820
+ onGetCachedMessageTemplate: t = () => null,
2821
+ onRequestMessageTemplate: n,
2822
+ onHandleTemplateInternalAction: o = Le
2823
+ }) => {
2824
+ const s = e == null ? void 0 : e.message_template;
2825
+ if (!Oa.has((s == null ? void 0 : s.type) ?? "default")) throw new Error("Unsupported template type");
2826
+ if (!n) throw new Error("onRequestMessageTemplate is required");
2827
+ const { theme: a } = Un(), l = ms({
2828
+ onRequestTemplate: n,
2829
+ onGetCachedTemplate: t,
2830
+ theme: a.selectedTheme,
2831
+ templateKey: (s == null ? void 0 : s.key) ?? "invalid",
2832
+ variables: s == null ? void 0 : s.variables,
2833
+ viewVariables: s == null ? void 0 : s.view_variables,
2834
+ aiAgentColorVariables: a.aiAgentColorVariables
2835
+ });
2836
+ return /* @__PURE__ */ r.createElement(Na, { id: `${le}-ext-message-template` }, /* @__PURE__ */ r.createElement(
2837
+ ro,
2838
+ {
2839
+ handleInternalAction: (c, u) => {
2840
+ c.stopPropagation(), o == null || o(u);
2841
+ }
2842
+ },
2843
+ /* @__PURE__ */ r.createElement(La, { templateItems: l.body.items, templateVersion: l.version })
2844
+ ));
2845
+ }, Na = m.div`box-sizing:border-box;overflow:hidden;width:100%;`;
2846
+ function Fa({
2847
+ extendedMessagePayload: e,
2848
+ onClickSuggestedReply: t,
2849
+ suggestedRepliesDirection: n = "vertical"
2850
+ }) {
2851
+ const [o, s] = T(!1), i = (e == null ? void 0 : e.suggested_replies) ?? [];
2852
+ return i.length === 0 || o ? null : /* @__PURE__ */ r.createElement(Ba, { id: `${le}-ext-suggested-replies`, $type: n }, i.map((a, l) => /* @__PURE__ */ r.createElement(
2853
+ Pa,
2854
+ {
2855
+ key: l,
2856
+ $type: n,
2857
+ variant: "body3",
2858
+ onClick: () => {
2859
+ t && (t == null || t({ reply: a }), s(!0));
2860
+ }
2861
+ },
2862
+ a
2863
+ )));
2864
+ }
2865
+ const Ba = m.div`margin:16px 0;padding:0 ${ae}px;position:relative;display:flex;align-self:stretch;gap:8px;${({ $type: e }) => e === "vertical" ? Ua : Ha};`, Pa = m(w)`box-sizing:border-box;padding:8px 12px;display:flex;align-items:center;border-radius:20px / clamp(20px,5%,100px);cursor:pointer;word-break:break-word;color:${d.color.primary.main};border:1px solid ${d.color.primary.main};background-color:${d.themedColor.bg_50_600};&:hover{background-color:${d.themedColor.bg_100_500};}${({ $type: e, theme: t }) => _`
2866
+ ${e === "vertical" ? Va : za};
2867
+ &:active {
2868
+ background-color: ${t.colors.base.primary};
2869
+ color: ${t.colors.base.primaryContrastContent};
2870
+ }
2871
+ `}
2872
+ `, Ua = _`flex-direction:column;align-items:flex-end;`, Ha = _`flex-direction:row;overflow-x:scroll;-ms-overflow-style:none;scrollbar-width:none;&::-webkit-scrollbar{display:none;}`, Va = _`max-width:calc(100% - 70px);white-space:pre-wrap;`, za = _`white-space:nowrap;`, ye = Te({
2873
+ template: Wa,
2874
+ components: {
2875
+ SenderName: Si,
2876
+ SenderAvatar: Ci,
2877
+ SentTime: wi,
2878
+ MessageBody: Ei,
2879
+ TypingIndicator: Ai,
2880
+ SuggestedReplies: Fa,
2881
+ MessageTemplate: Ra,
2882
+ CTAButton: Mi,
2883
+ Citation: Ri,
2884
+ Form: wa,
2885
+ MessageLogs: $a
2886
+ }
2887
+ });
2888
+ function Wa(e) {
2889
+ return /* @__PURE__ */ r.createElement(rr, { ...e, testerMode: !1 });
2890
+ }
2891
+ function rr(e) {
2892
+ var x, y, E, b, p, f, v;
2893
+ const { components: t } = ye.useContext(), n = !!e.isTyping, o = e.testerMode, s = !!((x = e.extendedMessagePayload) != null && x.form) && !((y = e.extendedMessagePayload) != null && y.form.canceled_at), i = !!((E = e.extendedMessagePayload) != null && E.message_template), a = !!((b = e.extendedMessagePayload) != null && b.cta_button), l = !!((p = e.extendedMessagePayload) != null && p.citations) && e.extendedMessagePayload.citations.length > 0, c = !!e.createdAt, u = e.groupType === "top" || e.groupType === "single", h = e.groupType === "bottom" || e.groupType === "single", g = o ? 0 : Je;
2894
+ return /* @__PURE__ */ r.createElement(Ga, { $marginBottom: n ? 0 : $t(e.groupType) }, u && /* @__PURE__ */ r.createElement(ja, null, !o && /* @__PURE__ */ r.createElement(t.SenderAvatar, { ...e }), /* @__PURE__ */ r.createElement(t.SenderName, { ...e })), /* @__PURE__ */ r.createElement(qa, null, /* @__PURE__ */ r.createElement(ct, { $extraStartPadding: g }, n ? /* @__PURE__ */ r.createElement(t.TypingIndicator, { ...e }) : /* @__PURE__ */ r.createElement(t.MessageBody, { ...e }, a && /* @__PURE__ */ r.createElement("div", { style: { marginTop: 12, marginInline: 12 } }, /* @__PURE__ */ r.createElement(t.CTAButton, { ...e })), l && /* @__PURE__ */ r.createElement(t.Citation, { ...e }))), i && /* @__PURE__ */ r.createElement(dn, { $startPadding: 0, $endPadding: 0 }, /* @__PURE__ */ r.createElement(
2895
+ t.MessageTemplate,
2896
+ {
2897
+ ...e,
2898
+ messageTemplateErrorFallback: e.messageTemplateErrorFallback ?? /* @__PURE__ */ r.createElement(ct, { $extraStartPadding: g }, /* @__PURE__ */ r.createElement(
2899
+ t.MessageBody,
2900
+ {
2901
+ ...e,
2902
+ messageType: "user",
2903
+ message: ((v = (f = e.extendedMessagePayload) == null ? void 0 : f.message_template) == null ? void 0 : v.fallback_message) ?? "Cannot read this template."
2904
+ }
2905
+ )),
2906
+ messageTemplateLoadingFallback: e.messageTemplateLoadingFallback ?? /* @__PURE__ */ r.createElement(ct, { $extraStartPadding: g }, /* @__PURE__ */ r.createElement(t.TypingIndicator, { ...e }))
2907
+ }
2908
+ )), s && /* @__PURE__ */ r.createElement(dn, { $extraStartPadding: g }, /* @__PURE__ */ r.createElement(t.Form, { ...e }))), h && c && /* @__PURE__ */ r.createElement(Ka, { $extraStartPadding: g + 8 }, /* @__PURE__ */ r.createElement(t.SentTime, { ...e })), /* @__PURE__ */ r.createElement(wn, null, e.suggestedRepliesVisible && /* @__PURE__ */ r.createElement(t.SuggestedReplies, { ...e }), /* @__PURE__ */ r.createElement(t.MessageLogs, { ...e })));
2909
+ }
2910
+ const Ga = m.div`display:flex;flex-direction:column;align-items:flex-start;margin-bottom:${({ $marginBottom: e }) => `${e}px`};
2911
+ `, rt = m.div`display:flex;align-self:stretch;justify-content:flex-start;${({ $startPadding: e = ae, $endPadding: t = ae, $extraStartPadding: n = 0 }) => `
2912
+ padding-inline: ${e + n}px ${t}px;
2913
+ `}
2914
+ `, ja = m(rt)`display:flex;flex-direction:row;align-items:center;gap:8px;`, ct = m(rt)`display:flex;`, Ka = m(rt)`margin-top:${jn}px;display:flex;align-items:flex-start;justify-content:flex-start;`, dn = m(rt)`display:flex;${({ $startPadding: e = ae, $endPadding: t = ae, $extraStartPadding: n = 0 }) => `
2915
+ padding-inline: ${e + n}px ${t}px;
2916
+ `}
2917
+ `, qa = m.div`display:flex;flex-direction:column;gap:${Ae}px;`;
2918
+ function Za({ file: e, children: t, onClickFile: n }) {
2919
+ return /* @__PURE__ */ r.createElement(Ya, null, /* @__PURE__ */ r.createElement(
2920
+ Ot,
2921
+ {
2922
+ name: e.name,
2923
+ type: Mt(e.name, e.type),
2924
+ onClick: n && (() => n == null ? void 0 : n(e))
2925
+ }
2926
+ ), t);
2927
+ }
2928
+ const Ya = m.div`display:flex;flex-direction:column;align-items:flex-end;gap:${Ae}px;`, or = ({ className: e, children: t, size: n = 26 }) => /* @__PURE__ */ r.createElement(Ja, { className: e, $size: n }, t ?? /* @__PURE__ */ r.createElement(O, { type: "spinner", size: n })), Ja = m.div`display:flex;align-items:center;justify-content:center;width:${({ $size: e }) => j(e)};height:${({ $size: e }) => j(e)};animation:1s infinite linear;animation-name:rotate;@keyframes rotate{from{transform:rotate(0);}to{transform:rotate(360deg);}}`;
2929
+ function Xa({ file: e, metadata: t, onClickMedia: n, children: o }) {
2930
+ const { aspectRatio: s, localFile: i } = t, [a] = T(() => i instanceof File ? URL.createObjectURL(i) : e.url), [l, c] = T(!1), u = {
2931
+ onClick: () => n == null ? void 0 : n(e),
2932
+ $ratio: s
2933
+ };
2934
+ return /* @__PURE__ */ r.createElement(Qa, null, /* @__PURE__ */ r.createElement(el, { ...u }, !l && /* @__PURE__ */ r.createElement(or, { size: 26 }, /* @__PURE__ */ r.createElement(O, { type: "spinner", color: "textLowEmphasis", size: 26 })), /* @__PURE__ */ r.createElement(tl, { $loaded: l, src: a, alt: "image-message", onLoad: () => c(!0) })), o);
2935
+ }
2936
+ const Qa = m.div`display:flex;flex-direction:column;align-items:flex-end;gap:${Ae}px;`, el = m.div`width:${be}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;${I.light`
2937
+ background-color: ${d.color.background100};
2938
+ `}
2939
+ ${I.dark`
2940
+ background-color: ${d.color.background400};
2941
+ `}
2942
+ `, tl = m.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;`;
2943
+ function un(e) {
2944
+ var n, o;
2945
+ const t = ee(() => {
2946
+ const s = pi(qn(e.message));
2947
+ return Mn.sanitize(s);
2948
+ }, [e.message]);
2949
+ return /* @__PURE__ */ r.createElement(
2950
+ nl,
2951
+ {
2952
+ $maxWidth: e.maxBodyWidth ?? be,
2953
+ $color: (n = e.customStyle) == null ? void 0 : n.bubbleContentColor,
2954
+ $bgColor: (o = e.customStyle) == null ? void 0 : o.bubbleBackgroundColor
2955
+ },
2956
+ /* @__PURE__ */ r.createElement(rl, { variant: "body3", dangerouslySetInnerHTML: { __html: t } })
2957
+ );
2958
+ }
2959
+ const nl = m.div`display:flex;flex-direction:column;border-radius:12px;overflow:hidden;max-width:${({ $maxWidth: e }) => e}px;${({ theme: e, $color: t, $bgColor: n }) => _`
2960
+ color: ${t || e.colors.messageOutgoing.text};
2961
+ background-color: ${n || e.colors.messageOutgoing.background};
2962
+ `}
2963
+ padding: 12px 0;
2964
+ transition: max-width 0.3s;
2965
+ overflow-wrap: break-word;
2966
+ `, rl = m(w)`align-items:flex-start;line-height:140%;white-space:pre-wrap;padding:0 12px;`;
2967
+ function ol(e) {
2968
+ const { stringSet: t } = R(), n = Kn(e) ? /* @__PURE__ */ r.createElement(un, { ...e }) : null;
2969
+ return e.messageType === "user" ? n : e.messageType === "file" ? e.file.type.startsWith("image") ? /* @__PURE__ */ r.createElement(Xa, { ...e }, n) : /* @__PURE__ */ r.createElement(Za, { ...e }, n) : /* @__PURE__ */ r.createElement(un, { ...e, message: t.UNKNOWN__UNKNOWN_MESSAGE_TYPE });
2970
+ }
2971
+ function sl({ sendingStatus: e }) {
2972
+ const t = St();
2973
+ switch (e) {
2974
+ case "pending":
2975
+ return /* @__PURE__ */ r.createElement(il, { size: 16 }, /* @__PURE__ */ r.createElement(O, { type: "spinner", color: t.colors.messageOutgoing.background, size: 16 }));
2976
+ case "failed":
2977
+ return /* @__PURE__ */ r.createElement("div", { style: { marginBottom: 2 } }, /* @__PURE__ */ r.createElement(O, { type: "error", color: d.themedColor.error, size: 16 }));
2978
+ case "scheduled":
2979
+ case "canceled":
2980
+ return null;
2981
+ default:
2982
+ return /* @__PURE__ */ r.createElement("div", null, /* @__PURE__ */ r.createElement(O, { type: "chevron-down" }));
2983
+ }
2984
+ }
2985
+ const il = m(or)`margin-bottom:2px;width:16px;height:16px;`;
2986
+ function al({ createdAt: e }) {
2987
+ const { stringSet: t, format: n } = R();
2988
+ return e ? /* @__PURE__ */ r.createElement(w, { variant: "caption4", color: d.themedColor.textLowEmphasis }, n(e, t.DATE_FORMAT__MESSAGE_TIMESTAMP)) : null;
2989
+ }
2990
+ const Pt = Te({
2991
+ template: ll,
2992
+ components: {
2993
+ SendingStatus: sl,
2994
+ SentTime: al,
2995
+ MessageBody: ol
2996
+ }
2997
+ });
2998
+ function ll(e) {
2999
+ const { components: t } = Pt.useContext(), n = e.sendingStatus === "succeeded", o = e.groupType === "bottom" || e.groupType === "single";
3000
+ return /* @__PURE__ */ r.createElement(cl, { $marginBottom: $t(e.groupType) }, /* @__PURE__ */ r.createElement(dl, null, /* @__PURE__ */ r.createElement(t.MessageBody, { ...e })), o && /* @__PURE__ */ r.createElement(ul, { $extraEndPadding: 8 }, n ? /* @__PURE__ */ r.createElement(t.SentTime, { ...e }) : /* @__PURE__ */ r.createElement(t.SendingStatus, { ...e })));
3001
+ }
3002
+ const cl = m.div`display:flex;flex:1;flex-direction:column;align-items:flex-end;margin-bottom:${({ $marginBottom: e }) => `${e}px`};
3003
+ `, sr = m.div`display:flex;align-self:stretch;justify-content:flex-end;${({ $startPadding: e = ae, $endPadding: t = ae, $extraEndPadding: n = 0 }) => `padding-inline: ${e}px ${t + n}px;`};
3004
+ `, dl = m(sr)``, ul = m(sr)`margin-top:${jn}px;`;
3005
+ function ml(e) {
3006
+ return e.messageType !== "admin" ? null : /* @__PURE__ */ r.createElement(hl, null, /* @__PURE__ */ r.createElement(w, { variant: "caption2", color: d.themedColor.textMidEmphasis }, gl(Mn.sanitize(e.message))));
3007
+ }
3008
+ const hl = m.div`text-align:center;text-wrap:pretty;a{text-decoration:none;color:inherit;}`, gl = (e) => {
3009
+ const t = /\[([^\]]+)\]\((https?:\/\/[^\s]+)\)/g, n = [];
3010
+ let o = 0;
3011
+ return e.replace(t, (s, i, a, l) => (n.push(e.slice(o, l)), n.push(
3012
+ /* @__PURE__ */ r.createElement("a", { key: a, href: a, target: "_blank", rel: It }, i)
3013
+ ), o = l + s.length, s)), n.push(e.slice(o)), n;
3014
+ }, pl = ({ submitted: e, defaultValue: t, value: n, onChange: o }) => {
3015
+ const { stringSet: s } = R();
3016
+ return L(() => {
3017
+ typeof n > "u" && typeof t == "boolean" && (o == null || o(t));
3018
+ }, [n, t]), /* @__PURE__ */ r.createElement(fl, null, /* @__PURE__ */ r.createElement(w, { variant: "caption2", color: d.themedColor.textMidEmphasis }, s.CSAT_CRE_TITLE), /* @__PURE__ */ r.createElement("div", null, /* @__PURE__ */ r.createElement(
3019
+ mn,
3020
+ {
3021
+ checked: n === !0,
3022
+ label: s.CSAT_CRE_SOLVED,
3023
+ disabled: e,
3024
+ onClick: () => o == null ? void 0 : o(!0)
3025
+ }
3026
+ ), /* @__PURE__ */ r.createElement(
3027
+ mn,
3028
+ {
3029
+ checked: n === !1,
3030
+ label: s.CSAT_CRE_NOT_SOLVED,
3031
+ disabled: e,
3032
+ onClick: () => o == null ? void 0 : o(!1)
3033
+ }
3034
+ )));
3035
+ }, mn = ({ onClick: e, checked: t, label: n, disabled: o }) => {
3036
+ const s = t ? d.color.primary.main : o ? d.themedColor.textDisabled : d.themedColor.textLowEmphasis, i = t ? d.themedColor.textHighEmphasis : o ? d.themedColor.textLowEmphasis : d.themedColor.textHighEmphasis;
3037
+ return /* @__PURE__ */ r.createElement(bl, { onClick: e, disabled: o }, /* @__PURE__ */ r.createElement(O, { size: 24, type: t ? "radio-on" : "radio-off", color: s }), /* @__PURE__ */ r.createElement(w, { variant: "caption2", color: i }, n));
3038
+ }, fl = m.div`display:flex;flex-direction:column;gap:8px;`, bl = m.button`all:unset;display:flex;align-items:center;justify-content:flex-start;gap:2px;span{line-height:initial;}&:enabled{cursor:pointer;}`, xl = (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 })), El = (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" })))), vl = (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" })), yl = (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" })), Cl = (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" })), _l = (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" })), Sl = (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" })), Tl = (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" })), wl = (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" })), Al = (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: {
3039
+ maskType: "alpha"
3040
+ }, 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)" })))), kl = [
3041
+ {
3042
+ value: 1,
3043
+ Icon: {
3044
+ Active: El,
3045
+ Inactive: xl
3046
+ },
3047
+ isActive: (e) => e <= 1,
3048
+ getTooltip: (e) => e.CSAT5_RATING_SCORE_1
3049
+ },
3050
+ {
3051
+ value: 2,
3052
+ Icon: {
3053
+ Active: yl,
3054
+ Inactive: vl
3055
+ },
3056
+ isActive: (e) => e === 2,
3057
+ getTooltip: (e) => e.CSAT5_RATING_SCORE_2
3058
+ },
3059
+ {
3060
+ value: 3,
3061
+ Icon: {
3062
+ Active: _l,
3063
+ Inactive: Cl
3064
+ },
3065
+ isActive: (e) => e === 3,
3066
+ getTooltip: (e) => e.CSAT5_RATING_SCORE_3
3067
+ },
3068
+ {
3069
+ value: 4,
3070
+ Icon: {
3071
+ Active: Tl,
3072
+ Inactive: Sl
3073
+ },
3074
+ isActive: (e) => e === 4,
3075
+ getTooltip: (e) => e.CSAT5_RATING_SCORE_4
3076
+ },
3077
+ {
3078
+ value: 5,
3079
+ Icon: {
3080
+ Active: Al,
3081
+ Inactive: wl
3082
+ },
3083
+ isActive: (e) => 5 <= e,
3084
+ getTooltip: (e) => e.CSAT5_RATING_SCORE_5
3085
+ }
3086
+ ], Il = () => kl, ir = ({ label: e, children: t, position: n = "top", disabled: o }) => o ? t : /* @__PURE__ */ r.createElement(Et, null, t, /* @__PURE__ */ r.createElement(Ol, { $position: n }, /* @__PURE__ */ r.createElement(Ll, { variant: "caption1" }, e), /* @__PURE__ */ r.createElement($l, { $position: n }))), $l = ({ $position: e }) => /* @__PURE__ */ r.createElement(
3087
+ "svg",
3088
+ {
3089
+ style: { transform: e === "top" ? "rotate(0)" : "rotate(180deg)" },
3090
+ xmlns: "http://www.w3.org/2000/svg",
3091
+ width: "12",
3092
+ height: "6",
3093
+ viewBox: "0 0 12 6",
3094
+ fill: "none"
3095
+ },
3096
+ /* @__PURE__ */ r.createElement("path", { d: "M6 6L0 0h12L6 6Z", fill: d.themedColor.textHighEmphasis })
3097
+ ), Ml = {
3098
+ top: _`flex-direction:column;top:0;transform:translate(-50%,-100%);`,
3099
+ bottom: _`flex-direction:column-reverse;bottom:0;transform:translate(-50%,100%);`
3100
+ }, Et = m.div`position:relative;`, Ol = m.div`display:flex;align-items:center;position:absolute;left:50%;z-index:${xe.TOOLTIP};${({ $position: e }) => Ml[e]}opacity:0;transition:opacity 0.2s ease-in-out;pointer-events:none;${Et}:hover &,${Et}:focus-within &{opacity:1;}`, Ll = m(w)`padding:6px 8px;background:${d.themedColor.textHighEmphasis};color:${d.themedColor.textHighEmphasisInverse};border-radius:4px;font-size:12px;white-space:nowrap;`, Rl = ({ submitted: e, value: t, onChange: n }) => {
3101
+ const { stringSet: o } = R(), s = Il(), i = typeof t == "number";
3102
+ return /* @__PURE__ */ r.createElement(Dl, null, /* @__PURE__ */ r.createElement(w, { variant: "caption2", color: d.themedColor.textMidEmphasis }, o.CSAT_RATING_TITLE), /* @__PURE__ */ r.createElement(Nl, null, s.map((a) => /* @__PURE__ */ r.createElement(ir, { disabled: e, key: a.value, label: a.getTooltip(o) }, /* @__PURE__ */ r.createElement(
3103
+ Fl,
3104
+ {
3105
+ disabled: e,
3106
+ onClick: () => n(a.value),
3107
+ $inactive: i && !a.isActive(t)
3108
+ },
3109
+ i ? a.isActive(t) ? /* @__PURE__ */ r.createElement(a.Icon.Active, null) : /* @__PURE__ */ r.createElement(a.Icon.Inactive, null) : /* @__PURE__ */ r.createElement(a.Icon.Active, null)
3110
+ )))));
3111
+ }, Dl = m.div`display:flex;flex-direction:column;gap:8px;`, Nl = m.div`display:flex;justify-content:space-between;width:100%;max-width:320px;`, Fl = m.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:${d.color.background200};${I.dark`
3112
+ background-color: ${d.color.background500};
3113
+ `}
3114
+ }
3115
+
3116
+ ${({ $inactive: e, theme: t }) => e && t.selectedTheme === "dark" && Bl};
3117
+ `, Bl = _`[fill]{fill:white;fill-opacity:0.12;}[stroke]{stroke:white;stroke-opacity:0.12;}`, Pl = ({ submitted: e, value: t = "", onChange: n }) => {
3118
+ const { stringSet: o } = R();
3119
+ return e && !t ? null : /* @__PURE__ */ r.createElement(
3120
+ Ul,
3121
+ {
3122
+ disabled: e,
3123
+ maxLength: 255,
3124
+ value: t,
3125
+ onChange: (s) => n(s.target.value),
3126
+ placeholder: o.CSAT_REASON_PLACEHOLDER
3127
+ }
3128
+ );
3129
+ }, Ul = m.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:${d.themedColor.textHighEmphasis};&::placeholder{color:${d.themedColor.textLowEmphasis};}background-color:${d.color.background50};${I.dark`
3130
+ background-color: ${d.themedColor.textDisabled};
3131
+ `}
3132
+
3133
+ &:disabled {
3134
+ cursor: not-allowed;
3135
+ color: ${d.themedColor.textLowEmphasis};
3136
+ background-color: ${d.color.background200};
3137
+ ${I.dark`
3138
+ color: ${d.color.ondark.textDisabled};
3139
+ background-color: ${d.themedColor.textDisabled};
3140
+ `}
3141
+ }
3142
+ `, Hl = ({ submitted: e }) => {
3143
+ const { stringSet: t } = R();
3144
+ return e ? /* @__PURE__ */ r.createElement(w, { variant: "h2", color: d.themedColor.textHighEmphasis }, t.CSAT_TITLE_SUBMITTED) : /* @__PURE__ */ r.createElement(w, { variant: "h2", color: d.themedColor.textHighEmphasis }, t.CSAT_TITLE_UNSUBMITTED);
3145
+ };
3146
+ var oe = /* @__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.HELPDESK_CSAT_5 = "HELPDESK_CSAT_5", e))(oe || {});
3147
+ const Vl = (e) => Rr((t, n) => ({ ...t, ...n }), e), dt = ({
3148
+ type: e,
3149
+ renderSubmitButton: t,
3150
+ initialCsat: n,
3151
+ initialCsatReason: o,
3152
+ initialIsResolved: s
3153
+ }) => {
3154
+ const [i, a] = Vl({
3155
+ csatType: e,
3156
+ csat: n,
3157
+ csatReason: o,
3158
+ isResolved: s
3159
+ }), l = typeof n == "number" ? "submitted" : (e === oe.AI_AGENT_CSAT_5 || e === oe.HELPDESK_CSAT_5) && typeof i.csat == "number" || e === oe.AI_AGENT_CSAT_5_WITH_CRE && typeof i.csat == "number" && typeof i.isResolved == "boolean" ? "submittable" : "unsubmittable", c = { state: l, submitted: l === "submitted" };
3160
+ return /* @__PURE__ */ r.createElement(r.Fragment, null, /* @__PURE__ */ r.createElement(zl, null, /* @__PURE__ */ r.createElement(Hl, { ...c }), e === oe.AI_AGENT_CSAT_5_WITH_CRE && /* @__PURE__ */ r.createElement(
3161
+ pl,
3162
+ {
3163
+ ...c,
3164
+ defaultValue: s,
3165
+ value: i.isResolved,
3166
+ onChange: (u) => a({ isResolved: u })
3167
+ }
3168
+ ), /* @__PURE__ */ r.createElement(Rl, { ...c, value: i.csat, onChange: (u) => a({ csat: u }) }), i.csat && /* @__PURE__ */ r.createElement(
3169
+ Pl,
3170
+ {
3171
+ ...c,
3172
+ value: i.csatReason,
3173
+ onChange: (u) => a({ csatReason: u })
3174
+ }
3175
+ )), l !== "submitted" && t({ state: l, params: i }));
3176
+ }, zl = m.div`display:flex;flex-direction:column;gap:12px;`, Wl = () => {
3177
+ const { stringSet: e } = R();
3178
+ return /* @__PURE__ */ r.createElement(w, { variant: "body2", color: d.themedColor.textMidEmphasis, style: { textAlign: "center" } }, e.CSAT_SUBMISSION_EXPIRED);
3179
+ }, Gl = (e) => {
3180
+ if (e.messageType !== "admin.csat")
3181
+ throw new Error("Invalid message type");
3182
+ const t = Jr(), { stringSet: n } = R(), { extendedMessagePayload: o, csat: s, csatReason: i, csatExpireAt: a, isResolvedWhenDeterminedByUser: l, onSubmitCSAT: c } = e, { visibility: u, type: h } = (o == null ? void 0 : o.csat) ?? {};
3183
+ if (!u || !h || !oe[h]) return null;
3184
+ const g = h === oe.AI_AGENT_CSAT_5 || h === oe.AI_AGENT_CSAT_5_WITH_CRE || h === oe.HELPDESK_CSAT_5 ? dt : () => null, x = (y) => {
3185
+ y.csat && !hn(a) ? c({
3186
+ csatType: y.csatType,
3187
+ csat: y.csat,
3188
+ csatReason: y.csatReason,
3189
+ isResolved: y.isResolved
3190
+ }) : t();
3191
+ };
3192
+ return /* @__PURE__ */ r.createElement(jl, null, !s && hn(a) ? /* @__PURE__ */ r.createElement(Wl, null) : /* @__PURE__ */ r.createElement(
3193
+ g,
3194
+ {
3195
+ type: h,
3196
+ initialCsat: s,
3197
+ initialCsatReason: i,
3198
+ initialIsResolved: l,
3199
+ renderSubmitButton: ({ state: y, params: E }) => /* @__PURE__ */ r.createElement(Kl, { disabled: y !== "submittable", onClick: () => x(E) }, /* @__PURE__ */ r.createElement(w, { variant: "button" }, n.CSAT_SUBMIT_LABEL))
3200
+ }
3201
+ ));
3202
+ }, jl = m.div`display:flex;flex-direction:column;background-color:${({ theme: e }) => e.colors.csat.background};border-radius:16px;gap:16px;padding:24px;`, Kl = m.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:${d.color.primary.dark};}&:disabled{color:${d.color.ondark.textLowEmphasis};background-color:${d.themedColor.textDisabled};cursor:not-allowed;}`;
3203
+ function hn(e) {
3204
+ return !!e && e < Date.now();
3205
+ }
3206
+ function ar(e) {
3207
+ return e();
3208
+ }
3209
+ const Ut = Te({
3210
+ template: ql,
3211
+ components: {
3212
+ AdminMessage: ml,
3213
+ CSATMessage: Gl
3214
+ }
3215
+ });
3216
+ function ql(e) {
3217
+ const { components: t } = Ut.useContext(), n = ar(() => e.messageType === "admin" ? /* @__PURE__ */ r.createElement(t.AdminMessage, { ...e }) : e.messageType === "admin.csat" ? /* @__PURE__ */ r.createElement(t.CSATMessage, { ...e }) : null);
3218
+ return /* @__PURE__ */ r.createElement(Zl, { $marginBottom: $t(e.groupType) }, n);
3219
+ }
3220
+ const Zl = m.div`padding-inline:${ae}px;margin-bottom:${({ $marginBottom: e }) => e}px;`, gn = {
3221
+ file: "attach",
3222
+ snippet: "snippet",
3223
+ site: "website",
3224
+ sb_sprinklr: "sprinklr",
3225
+ sb_salesforce: "salesforce",
3226
+ sb_confluence: "confluence",
3227
+ sb_zendesk: "zendesk",
3228
+ sb_desk: "snippet"
3229
+ // TODO: request icon
3230
+ }, Yl = ({
3231
+ actionbook: e,
3232
+ functionCalls: t,
3233
+ groundedness: n,
3234
+ agentMessageTemplates: o,
3235
+ onClickActionbook: s,
3236
+ onClickFunctionCall: i,
3237
+ onClickFunctionCallDetail: a,
3238
+ onClickGroundedness: l,
3239
+ onClickAgentMessageTemplate: c,
3240
+ bottomContent: u,
3241
+ renderCustomGroundednessIcon: h = (x) => x.default,
3242
+ style: g = {}
3243
+ }) => {
3244
+ const {
3245
+ // Note: This component is used with the dashboard, so cssVars should not be used.
3246
+ iconColor: x = "#000000",
3247
+ textColor: y = "#000000",
3248
+ highlightColor: E = Vn.DEFAULT_PRIMARY
3249
+ } = g;
3250
+ return /* @__PURE__ */ r.createElement(pn, null, e && /* @__PURE__ */ r.createElement(pn, null, /* @__PURE__ */ r.createElement(Xe, null, /* @__PURE__ */ r.createElement(We, null, /* @__PURE__ */ r.createElement(O, { size: 16, type: "actionbook", color: x })), /* @__PURE__ */ r.createElement(
3251
+ ze,
3252
+ {
3253
+ $clickable: !!s,
3254
+ $highlightColor: E,
3255
+ variant: "body2",
3256
+ color: y,
3257
+ onClick: () => s == null ? void 0 : s(e)
3258
+ },
3259
+ e.name
3260
+ ))), t == null ? void 0 : t.map((b) => /* @__PURE__ */ r.createElement(ut, { key: b.key }, /* @__PURE__ */ r.createElement(We, null, /* @__PURE__ */ r.createElement(O, { size: 16, type: "function", color: x })), /* @__PURE__ */ r.createElement(Xe, null, /* @__PURE__ */ r.createElement(
3261
+ ze,
3262
+ {
3263
+ $clickable: !!i,
3264
+ $highlightColor: E,
3265
+ variant: "body2",
3266
+ color: y,
3267
+ onClick: () => i == null ? void 0 : i(b)
3268
+ },
3269
+ b.name
3270
+ ), a && /* @__PURE__ */ r.createElement(Xl, { role: "button", onClick: () => a == null ? void 0 : a(b) }, /* @__PURE__ */ r.createElement(w, { variant: "body2", color: E }, "View details"), /* @__PURE__ */ r.createElement(O, { type: "chevron-right", size: 16, color: E }))))), n == null ? void 0 : n.map((b) => /* @__PURE__ */ r.createElement(ut, { key: b.id }, /* @__PURE__ */ r.createElement(We, null, h({
3271
+ default: /* @__PURE__ */ r.createElement(O, { size: 16, type: gn[b.source_type] ?? gn.snippet, color: x }),
3272
+ sourceType: b.source_type
3273
+ })), /* @__PURE__ */ r.createElement(
3274
+ ze,
3275
+ {
3276
+ $clickable: !!l,
3277
+ $highlightColor: E,
3278
+ variant: "body2",
3279
+ color: y,
3280
+ onClick: () => l == null ? void 0 : l(b)
3281
+ },
3282
+ b.preview_title
3283
+ ))), o == null ? void 0 : o.map((b) => /* @__PURE__ */ r.createElement(ut, { key: b.key }, /* @__PURE__ */ r.createElement(We, null, /* @__PURE__ */ r.createElement(O, { size: 16, type: "template", color: x })), /* @__PURE__ */ r.createElement(
3284
+ ze,
3285
+ {
3286
+ $clickable: !!c,
3287
+ $highlightColor: E,
3288
+ variant: "body2",
3289
+ color: y,
3290
+ onClick: () => c == null ? void 0 : c(b)
3291
+ },
3292
+ b.name
3293
+ ))), u);
3294
+ }, Jl = m(w)`font-weight:400;`, ze = m(Jl)`${({ $clickable: e, $highlightColor: t }) => e && _`
3295
+ cursor: pointer;
3296
+ text-decoration: underline;
3297
+ &:hover {
3298
+ color: ${t};
3299
+ }
3300
+ `}
3301
+ `, We = m.div`display:flex;align-items:center;justify-content:center;flex-shrink:0;`, Xe = m.div`display:flex;gap:8px;align-items:center;`, Xl = m(Xe)`cursor:pointer;gap:4px;`, ut = m(Xe)`flex-direction:row;align-items:center;`, pn = m.div`display:flex;gap:4px;flex-direction:column;align-items:flex-start;`, lr = _e(null);
3302
+ function Ql({ testerType: e, children: t }) {
3303
+ return /* @__PURE__ */ r.createElement(
3304
+ lr.Provider,
3305
+ {
3306
+ value: { testerType: e, isActionbookTester: e === "actionbook" }
3307
+ },
3308
+ e && /* @__PURE__ */ r.createElement(ec, null),
3309
+ t
3310
+ );
3311
+ }
3312
+ const ke = () => {
3313
+ const e = se(lr);
3314
+ if (!e) throw new Error("_UNSAFE_INTERNAL_DashboardTesterProvider not found");
3315
+ return e;
3316
+ }, ec = () => {
3317
+ const { isActionbookTester: e } = ke();
3318
+ return /* @__PURE__ */ r.createElement(ye.Template, { template: e ? tc : void 0 }, /* @__PURE__ */ r.createElement(ye.MessageLogs, { component: nc }));
3319
+ }, tc = (e) => /* @__PURE__ */ r.createElement(rr, { ...e, testerMode: !0, maxBodyWidth: Gn }), nc = ({ extendedMessagePayload: e = {} }) => {
3320
+ const { handlers: t } = H(), { manual: n, groundedness: o, function_calls: s, agent_message_templates: i, is_thinking: a } = e;
3321
+ return a || !n && !(o != null && o.length) && !(s != null && s.length) && !(i != null && i.length) ? /* @__PURE__ */ r.createElement(r.Fragment, null) : /* @__PURE__ */ r.createElement(rc, null, /* @__PURE__ */ r.createElement(oc, { width: 4 }), /* @__PURE__ */ r.createElement(
3322
+ Yl,
3323
+ {
3324
+ actionbook: n,
3325
+ functionCalls: s,
3326
+ groundedness: o,
3327
+ agentMessageTemplates: i,
3328
+ onClickFunctionCallDetail: t == null ? void 0 : t.onFunctionCallDetailClick,
3329
+ style: {
3330
+ iconColor: d.themedColor.textHighEmphasis,
3331
+ textColor: d.themedColor.textHighEmphasis,
3332
+ barColor: d.themedColor.textDisabled
3333
+ },
3334
+ bottomContent: /* @__PURE__ */ r.createElement(sc, { variant: "caption2", color: d.themedColor.textLowEmphasis }, "Only visible in the tester")
3335
+ }
3336
+ ));
3337
+ }, rc = m.div`display:flex;gap:16px;margin:16px ${ae}px 0;align-self:stretch;`, oc = m.div`width:${({ width: e }) => e}px;background-color:${d.themedColor.textDisabled};border-radius:100px;flex-shrink:0;`, sc = m(w)`margin-top:5px;`, ic = ({ publishSynchronous: e = !1 }) => {
3338
+ const t = /* @__PURE__ */ new Set();
3339
+ return {
3340
+ publish: (n) => {
3341
+ t.forEach((o) => {
3342
+ e ? o(n) : setTimeout(() => o(n), 0);
3343
+ });
3344
+ },
3345
+ subscribe: (n) => (t.add(n), () => t.delete(n))
3346
+ };
3347
+ };
3348
+ function ac(e, t = []) {
3349
+ const n = F(null), o = F(0), s = F(0), [i] = T(() => ic({ publishSynchronous: !0 })), [a, l] = T(!0);
3350
+ return pe(() => {
3351
+ o.current = 0, s.current = 0, l(!0), n.current && (n.current.scrollTop = n.current.scrollHeight);
3352
+ }, t), pe(() => i.subscribe(({ type: c, data: u }) => {
3353
+ const { resolve: h, animated: g } = u ?? {};
3354
+ if (!n.current) return h == null ? void 0 : h();
3355
+ if (c === "scrollToBottom" && (n.current.scroll ? n.current.scroll({
3356
+ top: n.current.scrollHeight,
3357
+ behavior: fn(e, g)
3358
+ }) : n.current.scrollTop = n.current.scrollHeight, s.current = 0, l(!0), h == null || h()), c === "scroll") {
3359
+ const x = u == null ? void 0 : u.top, { scrollTop: y, scrollHeight: E, clientHeight: b } = n.current;
3360
+ n.current.scroll ? n.current.scroll({ top: x, behavior: fn(e, g) }) : typeof x == "number" && (n.current.scrollTop = x), s.current = Math.max(0, E - y - b), l(s.current === 0), h == null || h();
3361
+ }
3362
+ }), [e]), {
3363
+ scrollRef: n,
3364
+ scrollPubSub: i,
3365
+ isScrollBottomReached: a,
3366
+ setIsScrollBottomReached: l,
3367
+ scrollDistanceFromBottomRef: s,
3368
+ scrollPositionRef: o
3369
+ };
3370
+ }
3371
+ function fn(e, t) {
3372
+ return typeof t == "boolean" ? t ? "smooth" : "auto" : e;
3373
+ }
3374
+ function lc(e) {
3375
+ return "sendingStatus" in e ? e.sendingStatus === "succeeded" ? String(e.messageId) : e.reqId : String(e.messageId);
3376
+ }
3377
+ const cc = (e, t, n, o = !0) => {
3378
+ if (!o || !e.isUserMessage() && !e.isFileMessage())
3379
+ return "single";
3380
+ const s = () => {
3381
+ if (!t || !t.isUserMessage() && !t.isFileMessage()) return !1;
3382
+ const c = t.sender.userId === e.sender.userId, u = Zt(t.createdAt, e.createdAt);
3383
+ return c && u;
3384
+ }, i = () => {
3385
+ if (!n || !n.isUserMessage() && !n.isFileMessage()) return !1;
3386
+ const c = n.sender.userId === e.sender.userId, u = Zt(n.createdAt, e.createdAt);
3387
+ return c && u;
3388
+ }, a = s(), l = i();
3389
+ return a && l ? "middle" : a ? "bottom" : l ? "top" : "single";
3390
+ };
3391
+ function dc(e, t) {
3392
+ return e.filter((n) => we.isWelcomeMessage(n, t));
3393
+ }
3394
+ function Ht(e, t) {
3395
+ return uc(e) === t;
3396
+ }
3397
+ function uc(e) {
3398
+ var t;
3399
+ if (e)
3400
+ return e.isUserMessage() || e.isFileMessage() || e.isMultipleFilesMessage() ? e.sender.userId : ((t = e == null ? void 0 : e.sender) == null ? void 0 : t.userId) ?? void 0;
3401
+ }
3402
+ function mc(e) {
3403
+ return e.isAdminMessage() ? e.message === "The channel's custom_type was updated." : !1;
3404
+ }
3405
+ const vt = (e) => !!e && "sender" in e, cr = (e) => e.startsWith("image/"), dr = (e) => e.startsWith("video/"), bn = (e) => cr(e) || dr(e), Ge = {
3406
+ isAdmin: (e) => e.isAdminMessage(),
3407
+ isCSAT: (e) => {
3408
+ var t;
3409
+ return e.isAdminMessage() && !!((t = e.extendedMessagePayload) != null && t.csat);
3410
+ },
3411
+ isIncoming: (e, t) => vt(e) && e.sender.userId !== t,
3412
+ isOutgoing: (e, t) => vt(e) && (e.sender.userId === t || e.sendingStatus === mt.PENDING)
3413
+ }, hc = (e) => {
3414
+ const { chatSDK: t, handlers: n, logger: o } = H(), { aiAgentInfo: s } = V(), i = F(/* @__PURE__ */ new Set()), a = (h) => {
3415
+ if (!(n != null && n.onCustomEvent)) return;
3416
+ vt(h) && h.sender.userId === s.userId && !we.isStreaming(h) && !i.current.has(h.messageId) && (o.debug("useCustomEventForMessageReceive: bot-message-received", h), n.onCustomEvent({ type: "bot-message-received", data: { message: h } }), i.current.add(h.messageId));
3417
+ }, l = (h) => {
3418
+ if (n != null && n.onCustomEvent && h.isAdminMessage() && h.customType === "user_action_required" && !i.current.has(h.messageId)) {
3419
+ const g = gt(h.data);
3420
+ Array.isArray(g.history) && g.history.length === 0 && (o.debug("useCustomEventForMessageReceive: user_action_required", g), n.onCustomEvent({
3421
+ type: "user-action-requested",
3422
+ data: g
3423
+ }), i.current.add(h.messageId));
3424
+ }
3425
+ }, c = (h, g) => {
3426
+ h.url === e && (a(g), l(g));
3427
+ }, u = (h) => {
3428
+ l(h);
3429
+ };
3430
+ return et(t, {
3431
+ onMessageUpdated: c,
3432
+ onMessageReceived: c
3433
+ }), {
3434
+ checkForUserActionRequired: u
3435
+ };
3436
+ };
3437
+ function gc(e) {
3438
+ return new Promise((t) => {
3439
+ const n = new Image();
3440
+ n.onload = function() {
3441
+ const o = String(n.width), s = String(n.height);
3442
+ URL.revokeObjectURL(n.src), t({ width: o, height: s });
3443
+ }, n.src = URL.createObjectURL(e);
3444
+ });
3445
+ }
3446
+ async function pc(e) {
3447
+ if ("file" in e && e.file instanceof File && e.file.type.startsWith("image/")) {
3448
+ const { width: t, height: n } = await gc(e.file);
3449
+ return new so({
3450
+ key: ur,
3451
+ value: [t, n]
3452
+ });
3453
+ }
3454
+ }
3455
+ const ur = "KEY_IMG_ASPECT_RATIO", fc = ({ onScrollAfterSendMessage: e }) => {
3456
+ const { agentPreviewConfigs: t, handlers: n } = H(), o = F(t == null ? void 0 : t.agentAttributes);
3457
+ return o.current = t == null ? void 0 : t.agentAttributes, {
3458
+ onBeforeSendMessage: async (s) => {
3459
+ const i = await pc(s), a = {
3460
+ ...s,
3461
+ metaArrays: i ? [i] : void 0
3462
+ }, l = bc(o.current);
3463
+ return l ? { ...a, data: JSON.stringify(l) } : a;
3464
+ },
3465
+ onAfterSendMessage: (s) => {
3466
+ var i, a, l;
3467
+ e(), (i = n == null ? void 0 : n.onMessageSend) == null || i.call(n, s.message), s.sendingStatus === mt.SUCCEEDED ? (a = n == null ? void 0 : n.onCustomEvent) == null || a.call(n, { type: "message-sent-succeeded", data: { message: s } }) : s.sendingStatus === mt.PENDING && ((l = n == null ? void 0 : n.onCustomEvent) == null || l.call(n, { type: "message-sent-pending", data: { message: s } }));
3468
+ }
3469
+ };
3470
+ }, bc = (e) => {
3471
+ if (!e) return null;
3472
+ const t = {};
3473
+ 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;
3474
+ }, {
3475
+ Provider: xc,
3476
+ Context: xm,
3477
+ useContext: K
3478
+ } = W("Conversation"), Ec = ({ children: e }) => {
3479
+ var s;
3480
+ const { channelSource: t } = K(), n = (s = t.channel) == null ? void 0 : s.url, { checkForUserActionRequired: o } = hc(n);
3481
+ return L(() => {
3482
+ var a;
3483
+ const i = (a = t.channel) == null ? void 0 : a.lastMessage;
3484
+ i && o(i);
3485
+ }, [t.channel, o]), /* @__PURE__ */ r.createElement(r.Fragment, null, e);
3486
+ }, vc = ({
3487
+ closedChannelUrl: e,
3488
+ onClearClosedChannelUrl: t,
3489
+ onNavigateToConversationList: n,
3490
+ children: o
3491
+ }) => {
3492
+ const { aiAgentInfo: s, activeChannel: i, refreshActiveChannel: a } = V(), { testerType: l } = ke(), c = ac("smooth"), { onBeforeSendMessage: u, onAfterSendMessage: h } = fc({
3493
+ onScrollAfterSendMessage: () => {
3494
+ c.scrollPubSub.publish({ type: "scrollToBottom", data: { animated: !1 } });
3495
+ }
3496
+ }), g = e || (i == null ? void 0 : i.url), x = (E) => {
3497
+ const b = E[E.length - 1];
3498
+ b && we.shouldScrollToBottom(b, s.userId, !!l) && setTimeout(() => c.scrollPubSub.publish({ type: "scrollToBottom", data: { animated: !0 } }), 100);
3499
+ }, y = D(async () => {
3500
+ await a(), e && (t == null || t());
3501
+ }, [a, e, t]);
3502
+ return /* @__PURE__ */ r.createElement(
3503
+ Yo,
3504
+ {
3505
+ channelUrl: g,
3506
+ onBeforeSendMessage: u,
3507
+ onAfterSendMessage: h,
3508
+ onMessagesUpdated: x,
3509
+ onMessagesReceived: x,
3510
+ onChannelDeleted: y
3511
+ },
3512
+ (E) => /* @__PURE__ */ r.createElement(
3513
+ xc,
3514
+ {
3515
+ value: { ...E, scrollSource: c, goToActiveConversation: y, onNavigateToConversationList: n }
3516
+ },
3517
+ /* @__PURE__ */ r.createElement(Ec, null, o)
3518
+ )
3519
+ );
3520
+ }, Vt = _e({
3521
+ onDrop: Le,
3522
+ subscribe: () => Le
3523
+ }), yt = ({ children: e }) => {
3524
+ const t = F(/* @__PURE__ */ new Set());
3525
+ return /* @__PURE__ */ r.createElement(
3526
+ Vt.Provider,
3527
+ {
3528
+ value: {
3529
+ onDrop: (n) => {
3530
+ var o;
3531
+ if (n.preventDefault(), (o = n.dataTransfer) != null && o.files) {
3532
+ const s = Array.from(n.dataTransfer.files);
3533
+ s.length > 0 && t.current.forEach((i) => i(s));
3534
+ }
3535
+ },
3536
+ subscribe: (n) => (t.current.add(n), () => t.current.delete(n))
3537
+ }
3538
+ },
3539
+ e
3540
+ );
3541
+ }, yc = ({ onDropFiles: e }) => {
3542
+ const { subscribe: t } = se(Vt);
3543
+ L(() => t(e), [e]);
3544
+ };
3545
+ yt.Consumer = ({ children: e }) => {
3546
+ const { onDrop: t } = se(Vt);
3547
+ return e({ onDrop: t, onDragOver: (s) => s.preventDefault() });
3548
+ };
3549
+ const Em = ({ iconSize: e = 64, icon: t, className: n, label: o, children: s }) => /* @__PURE__ */ r.createElement(_c, { className: n }, /* @__PURE__ */ r.createElement(O, { type: t, size: e, color: d.themedColor.textLowEmphasis }), /* @__PURE__ */ r.createElement(w, { variant: "body1", color: d.themedColor.textMidEmphasis }, o), s), Cc = m.div`position:relative;display:flex;justify-content:center;align-items:center;width:100%;height:100%;`, _c = m.div`display:flex;flex-direction:column;min-height:104px;align-items:center;gap:20px;text-align:center;`, Sc = {
3550
+ loading: A(() => import("./C_zdaLEd.js")),
3551
+ error: A(() => import("./L8ixNvKX.js")),
3552
+ noChannels: A(() => import("./B9RZQBFg.js")),
3553
+ noMessages: A(() => import("./DJ2cswO9.js"))
3554
+ }, Ce = ({ className: e, type: t = "loading", ...n }) => {
3555
+ const o = Sc[t];
3556
+ return /* @__PURE__ */ r.createElement(Cc, { className: e }, /* @__PURE__ */ r.createElement(Oe, { fallback: null }, /* @__PURE__ */ r.createElement(o, { ...n })));
3557
+ }, Tc = m.div`flex-shrink:0;width:${({ $size: e }) => j(e)};height:${({ $size: e }) => j(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;}`, wc = m(Lt)`path{fill:${({ theme: e }) => e.colors.base.primaryContrastContent};}`;
3558
+ function mr({ size: e }) {
3559
+ const { aiAgentInfo: t } = V();
3560
+ return t.profileUrl ? /* @__PURE__ */ r.createElement(Rt, { size: e, src: t.profileUrl }) : /* @__PURE__ */ r.createElement(Tc, { $size: e }, /* @__PURE__ */ r.createElement(wc, null));
3561
+ }
3562
+ const Ac = m.div`width:100%;height:100%;position:fixed;top:0;left:0;outline:none;`, kc = m.div`height:64px;min-height:64px;box-sizing:border-box;display:flex;justify-content:space-between;border-bottom:1px solid ${d.themedColor.textDisabled};background-color:${d.themedColor.bg_50_600};@media screen and (max-width:768px){position:relative;}`, Ic = m.div`box-sizing:border-box;display:flex;flex-direction:row;align-items:center;height:64px;padding:16px 20px;width:calc(100% - 128px);`, $c = m.div`margin-inline-end:8px;`, Mc = m.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);}`, Oc = m.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;}`, Lc = m.div`display:flex;width:160px;justify-content:flex-end;`, Rc = m.div`inset-inline-end:0;display:flex;flex-direction:row;`, hr = m.div`width:64px;padding:21px;box-sizing:border-box;cursor:${(e) => e.disabled ? "not-allowed" : "pointer"};`, Dc = m(hr)`border-inline-start:1px solid ${d.themedColor.textDisabled};`, Nc = m.div`width:100%;height:100%;display:flex;align-items:center;justify-content:center;`, Fc = m.video`max-width:100%;max-height:100%;user-select:none;-webkit-user-drag:none;`, Bc = m.img`max-width:calc(90% - 60px);max-height:calc(90% - 60px);user-select:none;-webkit-user-drag:none;`, Pc = m.div`max-width:100%;max-height:100%;display:flex;justify-content:center;align-items:center;`, Uc = ({ file: e, sender: t = {}, onClose: n, onDownloadClick: o }) => {
3563
+ const { type: s, url: i, name: a = "" } = e, { profileUrl: l, nickname: c, userId: u } = t, { aiAgentInfo: h } = V();
3564
+ return /* @__PURE__ */ r.createElement(
3565
+ Vc,
3566
+ {
3567
+ profileUrl: l ?? "",
3568
+ nickname: c ?? "",
3569
+ type: s,
3570
+ url: i,
3571
+ name: a,
3572
+ onClose: n,
3573
+ isBotMessage: u === h.userId,
3574
+ onDownloadClick: o
3575
+ }
3576
+ );
3577
+ }, Hc = ({ profileUrl: e, isBotMessage: t }) => !e && t ? /* @__PURE__ */ r.createElement(mr, { size: 32 }) : /* @__PURE__ */ r.createElement(Rt, { size: 32, src: e }), Vc = ({
3578
+ profileUrl: e,
3579
+ isBotMessage: t,
3580
+ nickname: n,
3581
+ name: o,
3582
+ type: s,
3583
+ url: i,
3584
+ onClose: a,
3585
+ onDownloadClick: l
3586
+ }) => {
3587
+ const { stringSet: c } = R();
3588
+ return /* @__PURE__ */ r.createElement(Yn, { onClose: a, visible: !0, rootElementId: ie.MODAL_ROOT }, /* @__PURE__ */ r.createElement(Ac, null, /* @__PURE__ */ r.createElement(kc, null, /* @__PURE__ */ r.createElement(Ic, null, /* @__PURE__ */ r.createElement($c, null, /* @__PURE__ */ r.createElement(Hc, { profileUrl: e, isBotMessage: t })), /* @__PURE__ */ r.createElement(Mc, null, /* @__PURE__ */ r.createElement(w, { variant: "h2", color: d.themedColor.textHighEmphasis }, o)), /* @__PURE__ */ r.createElement(Oc, null, /* @__PURE__ */ r.createElement(w, { variant: "body1", color: d.color.ondark.textMidEmphasis }, n))), /* @__PURE__ */ r.createElement(Lc, null, bn(s) && /* @__PURE__ */ r.createElement(Rc, null, /* @__PURE__ */ r.createElement(hr, { as: "a", href: i, target: "_blank", rel: It, onClick: l }, /* @__PURE__ */ r.createElement(O, { type: "download", color: d.themedColor.textHighEmphasis, size: 24 }))), /* @__PURE__ */ r.createElement(Dc, { onClick: a }, /* @__PURE__ */ r.createElement(O, { type: "close", color: d.themedColor.textHighEmphasis, size: 24 })))), /* @__PURE__ */ r.createElement(Nc, { onClick: (u) => u.currentTarget === u.target && a() }, dr(s) && /* @__PURE__ */ r.createElement(Fc, { controls: !0 }, /* @__PURE__ */ r.createElement("source", { src: i, type: s })), cr(s) && /* @__PURE__ */ r.createElement(Bc, { src: i, alt: o }), !bn(s) && /* @__PURE__ */ r.createElement(Pc, null, /* @__PURE__ */ r.createElement(w, { variant: "h1", color: d.themedColor.textHighEmphasis }, c.FILE_VIEWER__UNSUPPORT)))));
3589
+ }, gr = ({
3590
+ className: e,
3591
+ locale: t,
3592
+ date: n = Date.now(),
3593
+ formatString: o = "MMMM dd, yyyy",
3594
+ style: s
3595
+ }) => /* @__PURE__ */ r.createElement(zc, { id: `${re}-date-separator`, style: s, className: e }, /* @__PURE__ */ r.createElement(w, { variant: "caption4", color: d.themedColor.textMidEmphasis }, In(n, o, { locale: t }))), zc = m.div`display:flex;justify-content:center;align-items:center;`, Wc = Se(function(t, n) {
3596
+ const {
3597
+ messages: o,
3598
+ renderMessage: s,
3599
+ messageTopArea: i,
3600
+ messageBottomArea: a,
3601
+ overlayArea: l,
3602
+ onLoadPrev: c,
3603
+ onLoadNext: u,
3604
+ loadThreshold: h = 0.05,
3605
+ onScrollPosition: g = Le,
3606
+ depsForResetScrollPositionToBottom: x,
3607
+ scrollPositionRef: y,
3608
+ scrollDistanceFromBottomRef: E,
3609
+ stackDirection: b = "top"
3610
+ } = t, p = n && "current" in n ? n : { current: null }, f = F(!1), v = F(void 0), S = F(0), M = F(0), P = F(0), $ = y ?? M, J = E ?? P;
3611
+ pe(() => {
3612
+ p.current && (p.current.scrollTop = p.current.scrollHeight);
3613
+ }, x), pe(() => {
3614
+ p.current && (v.current === "top" && (p.current.scrollTop = p.current.scrollHeight - $.current), v.current === "bottom" && (p.current.scrollTop = S.current), v.current = void 0);
3615
+ }, [p.current, o.length]);
3616
+ const G = async () => {
3617
+ if (!p.current) return;
3618
+ const C = p.current;
3619
+ if (g(Gc(C)), $.current = C.scrollHeight - C.scrollTop, J.current = $.current - C.clientHeight, S.current = C.scrollTop, f.current) return;
3620
+ const U = C.clientHeight * Math.min(Math.max(0, h), 1);
3621
+ C.scrollTop <= U ? (f.current = !0, v.current = "top", await c(), f.current = !1) : C.scrollHeight - C.scrollTop - C.clientHeight <= U ? (f.current = !0, v.current = "bottom", await u(), f.current = !1) : v.current = void 0;
3622
+ };
3623
+ return /* @__PURE__ */ r.createElement(jc, { id: "infinite-list-container" }, /* @__PURE__ */ r.createElement(Kc, { id: "infinite-list-inner", ref: p, onScroll: G }, b === "bottom" && /* @__PURE__ */ r.createElement("div", { style: { flexGrow: 1 } }), i, o.map((C, U) => s({ message: C, index: U })), a), /* @__PURE__ */ r.createElement(qc, { id: "infinite-list-overlay-container" }, /* @__PURE__ */ r.createElement(Zc, { id: "infinite-list-overlay" }, l)));
3624
+ }), xn = 50;
3625
+ function Gc(e) {
3626
+ return e.scrollTop <= xn ? "top" : e.scrollHeight - (e.scrollTop + e.clientHeight) <= xn ? "bottom" : "middle";
3627
+ }
3628
+ const jc = m.div`display:flex;position:relative;flex:1;overflow:hidden;`, Kc = m.div`display:flex;flex:1;flex-direction:column;overflow-y:auto;scrollbar-color:${d.themedColor.textLowEmphasis}transparent;&::-webkit-scrollbar-thumb:hover{background-color:transparent;}`, qc = m.div`position:absolute;top:0;bottom:0;left:0;right:0;pointer-events:none;`, Zc = m.div`pointer-events:auto;`, Yc = ({ className: e, onClick: t }) => /* @__PURE__ */ r.createElement(Jc, { className: e, onClick: t, tabIndex: 0 }, /* @__PURE__ */ r.createElement(O, { size: 24, type: "chevron-down", color: d.color.primary.main })), Jc = m.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);${I.light`
3629
+ background-color: ${d.color.background50};
3630
+ &:hover {
3631
+ background-color: ${d.color.background100};
3632
+ }
3633
+ &:active {
3634
+ background-color: ${d.color.background200};
3635
+ }
3636
+ `}
3637
+ ${I.dark`
3638
+ background-color: ${d.color.background400};
3639
+ &:hover {
3640
+ background-color: ${d.color.background500};
3641
+ }
3642
+ &:active {
3643
+ background-color: ${d.color.background700};
3644
+ }
3645
+ `}
3646
+
3647
+ &:focus {
3648
+ outline: none;
3649
+ }
3650
+ `, pr = () => {
3651
+ const { chatSDK: e } = H(), { channelSource: t } = K(), [n, o] = T([]);
3652
+ return et(e, {
3653
+ onTypingStatusUpdated(s) {
3654
+ var i;
3655
+ if (s.url === ((i = t.channel) == null ? void 0 : i.url)) {
3656
+ const a = s.getTypingUsers();
3657
+ o(a);
3658
+ }
3659
+ }
3660
+ }), n;
3661
+ }, Xc = () => {
3662
+ const { agentPreviewConfigs: e = {}, aiAgentId: t } = H(), { aiAgentInfo: n } = V(), { stringSet: o, dateLocale: s } = R(), { messageSource: i } = K(), { Template: a } = ye.useContext(), l = e.welcomeMessages ?? [], c = i.messages, u = dc(c, t), h = c[u.length + 1], g = u[0] ?? h;
3663
+ return {
3664
+ /**
3665
+ * Returns a list of messages filtered according to business requirements.
3666
+ */
3667
+ filteredMessages: c.filter((x) => mc(x) ? !1 : l.length > 0 ? !we.isWelcomeMessage(x, t) : !0),
3668
+ /**
3669
+ * Determines whether to display the DateSeparator in the data list by comparing it with the welcome messages from Bot Studio.
3670
+ */
3671
+ shouldShowOriginalDate: (x) => x > 0 || l.length === 0 ? !0 : h && !jr(h.createdAt, (g == null ? void 0 : g.createdAt) ?? 0),
3672
+ /**
3673
+ * Renders the list of welcome messages from Bot Studio.
3674
+ */
3675
+ renderAgentPreviewWelcomeMessages: () => l.length === 0 ? null : /* @__PURE__ */ r.createElement(r.Fragment, null, /* @__PURE__ */ r.createElement(
3676
+ gr,
3677
+ {
3678
+ style: { margin: "16px 0" },
3679
+ date: g == null ? void 0 : g.createdAt,
3680
+ locale: s,
3681
+ formatString: o.DATE_FORMAT__MESSAGE_LIST__DATE_SEPARATOR
3682
+ }
3683
+ ), l.map((x, y) => {
3684
+ const E = y === l.length - 1, b = u.length !== c.length, p = l.length === 1 ? "single" : y === 0 ? "top" : E || b ? "bottom" : "middle";
3685
+ return /* @__PURE__ */ r.createElement(
3686
+ a,
3687
+ {
3688
+ messageType: "user",
3689
+ message: x.message,
3690
+ sender: n,
3691
+ groupType: p,
3692
+ createdAt: (g == null ? void 0 : g.createdAt) ?? Date.now(),
3693
+ extendedMessagePayload: { suggested_replies: x.suggestedReplies },
3694
+ suggestedRepliesDirection: e.suggestedRepliesDirection,
3695
+ suggestedRepliesVisible: E && !b,
3696
+ isBotMessage: !0,
3697
+ onClickSuggestedReply: async ({ reply: f }) => {
3698
+ i.sendUserMessage({ message: f });
3699
+ }
3700
+ }
3701
+ );
3702
+ }))
3703
+ };
3704
+ }, Qc = (e) => m(e).withConfig({ shouldForwardProp: ao });
3705
+ function ed(e) {
3706
+ var o;
3707
+ const t = "remove_powered_by", n = (o = e == null ? void 0 : e.appInfo) == null ? void 0 : o.applicationAttributes;
3708
+ return Array.isArray(n) && n.includes(t);
3709
+ }
3710
+ const td = ({ style: e }) => {
3711
+ const { stringSet: t } = R(), { chatSDK: n } = H(), { isActionbookTester: o } = ke();
3712
+ return ed(n) || o ? null : /* @__PURE__ */ r.createElement(nd, { variant: "caption2", style: e }, t.POWERED_BY + " ", /* @__PURE__ */ r.createElement(
3713
+ rd,
3714
+ {
3715
+ variant: "caption2",
3716
+ as: "a",
3717
+ href: "https://sendbird.com?utm_medium=product&utm_source=aiagent&utm_campaign=fy26-glbl-ai-agent-poweredby",
3718
+ "aria-label": "Learn more about Sendbird",
3719
+ rel: It,
3720
+ target: "_blank"
3721
+ },
3722
+ "Sendbird"
3723
+ ));
3724
+ }, nd = m(w)`color:${d.themedColor.textLowEmphasis};text-align:center;`, rd = Qc(w)`
3725
+ color: ${d.themedColor.textLowEmphasis};
3726
+ cursor: pointer;
3727
+ text-decoration: none;
3728
+ `, od = () => {
3729
+ var c;
3730
+ const { stringSet: e } = R(), { activeChannel: t } = V(), { channelSource: n, goToActiveConversation: o, scrollSource: s } = K(), i = t && ((c = n.channel) == null ? void 0 : c.url) === (t == null ? void 0 : t.url), a = Nt(n.channel), l = F(a);
3731
+ return L(() => {
3732
+ !l.current && a && s.scrollPubSub.publish({ type: "scrollToBottom", data: { animated: !0 } }), l.current = a;
3733
+ }, [a, s]), a ? /* @__PURE__ */ r.createElement(sd, null, /* @__PURE__ */ r.createElement(
3734
+ id,
3735
+ {
3736
+ variant: "button",
3737
+ role: "button",
3738
+ color: d.themedColor.textHighEmphasis,
3739
+ onClick: () => o()
3740
+ },
3741
+ i ? e.START_NEW_CONVERSATION : e.RETURN_TO_CONVERSATION
3742
+ )) : null;
3743
+ }, sd = m.div`display:flex;justify-content:center;margin:16px 0;`, id = m(w)`border-radius:6px;box-sizing:border-box;padding:10px 20px;border:1px solid ${d.themedColor.textDisabled};cursor:pointer;user-select:none;`, ad = !0, ld = () => {
3744
+ const { Template: e } = Pt.useContext(), { Template: t } = ye.useContext(), { Template: n } = Ut.useContext(), [o, s] = T(null), { userSession: i, aiAgentInfo: a } = V(), { cache: l, agentPreviewConfigs: c, chatSDK: u, state: h } = H(), { stringSet: g, dateLocale: x } = R(), { conversation: y, channelSource: E, messageSource: b, scrollSource: p } = K(), { isActionbookTester: f } = ke(), { filteredMessages: v, shouldShowOriginalDate: S, renderAgentPreviewWelcomeMessages: M } = Xc(), P = pr(), $ = ar(() => {
3745
+ const C = P[0];
3746
+ if (!C) return null;
3747
+ const U = C.userId === a.userId;
3748
+ return { user: U ? a : C, isBot: U };
3749
+ });
3750
+ L(() => {
3751
+ $ && p.scrollPubSub.publish({ type: "scrollToBottom", data: { animated: !0 } });
3752
+ }, [!!$, p.scrollPubSub.publish]);
3753
+ const J = (C, U = !1) => {
3754
+ var te;
3755
+ return U ? a : ((te = E.channel) == null ? void 0 : te.members.find((X) => X.userId === C.sender.userId)) ?? C.sender;
3756
+ }, G = () => {
3757
+ if (!b.initialized)
3758
+ return /* @__PURE__ */ r.createElement(Ce, { type: "loading" });
3759
+ if (b.messages.length === 0) {
3760
+ const C = M();
3761
+ return C ? /* @__PURE__ */ r.createElement("div", { style: { width: "100%" } }, C) : /* @__PURE__ */ r.createElement(Ce, { type: "noMessages", label: g.PLACE_HOLDER__NO_MESSAGES });
3762
+ }
3763
+ return /* @__PURE__ */ r.createElement(
3764
+ Wc,
3765
+ {
3766
+ ref: p.scrollRef,
3767
+ scrollPositionRef: p.scrollPositionRef,
3768
+ scrollDistanceFromBottomRef: p.scrollDistanceFromBottomRef,
3769
+ onScrollPosition: (C) => p.setIsScrollBottomReached(C === "bottom"),
3770
+ stackDirection: c == null ? void 0 : c.messageStackDirection,
3771
+ messages: v,
3772
+ onLoadPrev: b.loadPrevious,
3773
+ onLoadNext: b.loadNext,
3774
+ depsForResetScrollPositionToBottom: [b.initialized, b.messages.length !== 0],
3775
+ messageTopArea: /* @__PURE__ */ r.createElement(r.Fragment, null, /* @__PURE__ */ r.createElement(td, { style: { marginTop: 16 } }), M()),
3776
+ messageBottomArea: /* @__PURE__ */ r.createElement(r.Fragment, null, $ && /* @__PURE__ */ r.createElement(
3777
+ t,
3778
+ {
3779
+ isTyping: !0,
3780
+ isBotMessage: $.isBot,
3781
+ sender: $.user,
3782
+ messageType: "user",
3783
+ groupType: "single",
3784
+ message: ""
3785
+ }
3786
+ ), /* @__PURE__ */ r.createElement(od, null)),
3787
+ overlayArea: /* @__PURE__ */ r.createElement(r.Fragment, null, !p.isScrollBottomReached && /* @__PURE__ */ r.createElement(dd, { onClick: () => p.scrollPubSub.publish({ type: "scrollToBottom" }) })),
3788
+ renderMessage: ({ message: C, index: U }) => {
3789
+ const te = lc(C), X = v[U - 1], Ie = v[U + 1], ot = v[v.length - 1], st = C === ot, k = cc(C, X, Ie, ad), N = !io((X == null ? void 0 : X.createdAt) ?? 0, C.createdAt) && S(U) && !f, q = (Pe) => {
3790
+ (C.isFileMessage() || C.isUserMessage()) && s({ file: Pe, sender: J(C, C.sender.userId === a.userId) });
3791
+ }, ne = () => {
3792
+ C.isFileMessage() && Dt(C.url);
3793
+ }, Ee = N ? /* @__PURE__ */ r.createElement(
3794
+ gr,
3795
+ {
3796
+ style: { margin: "16px 0" },
3797
+ date: C.createdAt,
3798
+ locale: x,
3799
+ formatString: g.DATE_FORMAT__MESSAGE_LIST__DATE_SEPARATOR
3800
+ }
3801
+ ) : null, Be = {
3802
+ maxBodyWidth: h.expanded ? Gn : void 0,
3803
+ extendedMessagePayload: C.extendedMessagePayload,
3804
+ createdAt: C.createdAt,
3805
+ groupType: k,
3806
+ onClickMedia: q,
3807
+ onClickFile: ne
3808
+ }, Mr = (() => {
3809
+ var Pe, Kt;
3810
+ if (Ge.isAdmin(C))
3811
+ return Ge.isCSAT(C) ? y ? /* @__PURE__ */ r.createElement(
3812
+ n,
3813
+ {
3814
+ ...Be,
3815
+ ...y,
3816
+ isResolvedWhenDeterminedByUser: ud(y),
3817
+ messageType: "admin.csat",
3818
+ onSubmitCSAT: ({ csat: ce, csatType: me, csatReason: B, isResolved: Q }) => {
3819
+ var he;
3820
+ ce && ((he = E.channel) == null || he.submitCSAT({ csat: ce, csatType: me, csatReason: B, isResolved: Q }));
3821
+ }
3822
+ }
3823
+ ) : null : /* @__PURE__ */ r.createElement(n, { ...Be, messageType: "admin", message: C.message });
3824
+ if (Ge.isOutgoing(C, i.userId)) {
3825
+ const ce = {
3826
+ ...Be,
3827
+ message: C.message,
3828
+ sender: J(C),
3829
+ sendingStatus: C.sendingStatus
3830
+ };
3831
+ if (C.isUserMessage())
3832
+ return /* @__PURE__ */ r.createElement(e, { messageType: "user", ...ce });
3833
+ if (C.isFileMessage()) {
3834
+ const [me, B] = ((Pe = C.metaArrays.find((Q) => Q.key === ur)) == null ? void 0 : Pe.value) ?? [];
3835
+ return /* @__PURE__ */ r.createElement(
3836
+ e,
3837
+ {
3838
+ messageType: "file",
3839
+ file: C,
3840
+ metadata: {
3841
+ aspectRatio: me && B ? `${me}/${B}` : "1/1",
3842
+ localFile: (Kt = C.messageParams) == null ? void 0 : Kt.file
3843
+ },
3844
+ ...ce
3845
+ }
3846
+ );
3847
+ }
3848
+ }
3849
+ if (Ge.isIncoming(C, i.userId)) {
3850
+ const ce = C.sender.userId === a.userId, me = {
3851
+ ...Be,
3852
+ sender: J(C, ce),
3853
+ message: C.message,
3854
+ suggestedRepliesVisible: st,
3855
+ suggestedRepliesDirection: c == null ? void 0 : c.suggestedRepliesDirection,
3856
+ isBotMessage: ce,
3857
+ isStreaming: we.isStreaming(C),
3858
+ isHandedOff: Ft(E.channel),
3859
+ isConversationClosed: Nt(E.channel),
3860
+ onClickSuggestedReply: async ({ reply: B }) => {
3861
+ b.sendUserMessage({ message: B });
3862
+ },
3863
+ onRequestMessageTemplate: async (B) => {
3864
+ const { template: Q } = await u.aiAgent.getMessageTemplate(B);
3865
+ return l.template.set(B, Q), Q;
3866
+ },
3867
+ onGetCachedMessageTemplate: (B) => l.template.get(B),
3868
+ onHandleTemplateInternalAction: (B) => {
3869
+ if (B.type === "internal" && B.internalData) {
3870
+ const { method: Q, payload: he } = B.internalData;
3871
+ Q === "message.send" && (he != null && he.message) && b.sendUserMessage({ message: he.message });
3872
+ }
3873
+ },
3874
+ onSubmitForm: ({ key: B, data: Q }) => u.aiAgent.submitForm({
3875
+ messageId: C.messageId,
3876
+ channelUrl: C.channelUrl,
3877
+ formKey: B,
3878
+ formData: Q
3879
+ }),
3880
+ onCancelForm: ({ key: B }) => u.aiAgent.cancelForm({
3881
+ messageId: C.messageId,
3882
+ channelUrl: C.channelUrl,
3883
+ formKey: B
3884
+ })
3885
+ };
3886
+ if (C.isUserMessage())
3887
+ return /* @__PURE__ */ r.createElement(t, { messageType: "user", ...me });
3888
+ if (C.isFileMessage())
3889
+ return /* @__PURE__ */ r.createElement(t, { messageType: "file", file: C, ...me });
3890
+ }
3891
+ })();
3892
+ return /* @__PURE__ */ r.createElement("div", { key: te, id: `${re}-message-item` }, Ee, Mr);
3893
+ }
3894
+ }
3895
+ );
3896
+ };
3897
+ return /* @__PURE__ */ r.createElement(cd, { id: `${re}-message-list` }, G(), o && /* @__PURE__ */ r.createElement(Uc, { onClose: () => s(null), sender: o.sender, file: o.file }));
3898
+ }, cd = m.div`overflow-y:hidden;display:flex;flex:1;position:relative;`, dd = m(Yc)`position:absolute;bottom:20px;inset-inline-end:20px;`;
3899
+ function ud(e) {
3900
+ var t;
3901
+ if (((t = e == null ? void 0 : e.resolution) == null ? void 0 : t.determinedBy) === "user")
3902
+ return e.resolution.isResolved;
3903
+ }
3904
+ const md = () => {
3905
+ const { stringSet: e } = R(), { connectionError: t } = V(), { channelSource: n } = K(), o = t || n.error;
3906
+ if (o) {
3907
+ const s = t ? void 0 : { label: e.RETRY, onClick: () => n.refetch() };
3908
+ return /* @__PURE__ */ r.createElement(Ce, { type: "error", label: o.message, action: s });
3909
+ }
3910
+ return n.channel ? /* @__PURE__ */ r.createElement(ld, null) : /* @__PURE__ */ r.createElement(Ce, { type: "loading" });
3911
+ }, hd = () => {
3912
+ var o;
3913
+ const { appId: e, aiAgentId: t } = Y(), { channelSource: n } = K();
3914
+ return (o = n.channel) != null && o.conversation ? /* @__PURE__ */ r.createElement(gd, null, /* @__PURE__ */ r.createElement(Ct, { style: { gap: 4 } }, /* @__PURE__ */ r.createElement(O, { color: d.themedColor.textLowEmphasis, size: 12, type: "show" }), /* @__PURE__ */ r.createElement(w, { as: "i", color: d.themedColor.textLowEmphasis, variant: "caption2" }, "Only visible in the tester")), /* @__PURE__ */ r.createElement(
3915
+ Ct,
3916
+ {
3917
+ role: "button",
3918
+ style: { gap: 4 },
3919
+ onClick: () => {
3920
+ var a, l;
3921
+ const s = (l = (a = n.channel) == null ? void 0 : a.conversation) == null ? void 0 : l.id, i = `${window.location.origin}/ai-agent/${e}/${t}/evaluate/conversations/${s}`;
3922
+ navigator.clipboard.writeText(i);
3923
+ }
3924
+ },
3925
+ /* @__PURE__ */ r.createElement(w, { variant: "body3", color: d.themedColor.textHighEmphasis }, "Copy ", /* @__PURE__ */ r.createElement("span", { style: { color: d.themedColor.primary } }, "conversation link")),
3926
+ /* @__PURE__ */ r.createElement(O, { color: d.themedColor.primary, size: 14, type: "copy" })
3927
+ )) : null;
3928
+ }, Ct = m.div`display:flex;justify-content:center;align-items:center;`, gd = m(Ct)`flex-direction:column;padding-block:16px;background-color:${d.themedColor.bg_100_500};gap:8px;`, fr = _e(void 0), pd = ({ children: e }) => {
3929
+ const { stringSet: t } = R(), { attachmentMode: n } = V(), { channelSource: o } = K(), [s, i] = T([]), [a, l] = T({
3930
+ visible: !1,
3931
+ title: ""
3932
+ }), c = Ft(o.channel), u = ee(() => {
3933
+ switch (n) {
3934
+ case qe.OFF:
3935
+ return !1;
3936
+ case qe.ALWAYS:
3937
+ return !0;
3938
+ case qe.HANDED_OFF_ONLY:
3939
+ return c;
3940
+ default:
3941
+ return c;
3942
+ }
3943
+ }, [n, c]), h = (y) => {
3944
+ if (!u) return;
3945
+ const E = y.filter((b) => Wn.includes(b.type));
3946
+ if (E.length !== 0) {
3947
+ if (E.some((b) => b.size > Zs)) {
3948
+ l({
3949
+ visible: !0,
3950
+ title: t.FILE_UPLOAD_NOTIFICATION__SIZE_LIMIT.replace("%d", "25")
3951
+ });
3952
+ return;
3953
+ }
3954
+ if (E.length > 1 || E.length > 0 && s.length > 0) {
3955
+ l({
3956
+ visible: !0,
3957
+ title: t.FILE_UPLOAD_NOTIFICATION__COUNT_LIMIT
3958
+ });
3959
+ return;
3960
+ }
3961
+ i((b) => [
3962
+ ...b,
3963
+ ...E.map((p) => ({
3964
+ file: p,
3965
+ preview: { url: URL.createObjectURL(p), type: p.type, name: p.name }
3966
+ }))
3967
+ ]);
3968
+ }
3969
+ }, g = (y) => {
3970
+ i((E) => {
3971
+ var p;
3972
+ const b = (p = E[y]) == null ? void 0 : p.preview;
3973
+ return b && URL.revokeObjectURL(b.url), E.filter((f, v) => v !== y);
3974
+ });
3975
+ }, x = () => {
3976
+ i((y) => (y.forEach((E) => URL.revokeObjectURL(E.preview.url)), []));
3977
+ };
3978
+ return /* @__PURE__ */ r.createElement(
3979
+ fr.Provider,
3980
+ {
3981
+ value: {
3982
+ files: s,
3983
+ addFiles: h,
3984
+ removeFile: g,
3985
+ clearFiles: x,
3986
+ isFileUploadEnabled: u
3987
+ }
3988
+ },
3989
+ e,
3990
+ /* @__PURE__ */ r.createElement(Jn, { ...a, onClose: () => l({ visible: !1, title: "" }) })
3991
+ );
3992
+ }, zt = () => {
3993
+ const e = se(fr);
3994
+ if (!e)
3995
+ throw new Error("useFileUpload must be used within FileUploadProvider");
3996
+ return e;
3997
+ };
3998
+ function fd({ blurred: e, elementRef: t, document: n = window.document }) {
3999
+ const o = F(!1);
4000
+ e && t.current && n.activeElement === t.current && (o.current = !0), pe(() => {
4001
+ var s;
4002
+ !e && o.current && ((s = t.current) == null || s.focus(), o.current = !1);
4003
+ }, [e]);
4004
+ }
4005
+ const bd = (e, t) => {
4006
+ L(() => {
4007
+ t ? e == null || e.startTyping() : e == null || e.endTyping();
4008
+ }, [e, t]);
4009
+ }, xd = m.div`&::-webkit-scrollbar{display:none;}overflow-x:auto;display:flex;flex-direction:row;gap:10px;padding:8px 16px;background-color:transparent;`, Ed = m.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;}`, vd = m.div`display:flex;align-items:center;justify-content:center;position:absolute;inset-inline-end:-8px;inset-block-start:-8px;cursor:pointer;border-radius:50%;${I.light`
4010
+ background-color: ${d.color.background50};
4011
+ `}
4012
+ ${I.dark`
4013
+ background-color: ${d.color.background500};
4014
+ `}
4015
+ path {
4016
+ fill: ${d.themedColor.textMidEmphasis};
4017
+ }
4018
+
4019
+ &:hover {
4020
+ path {
4021
+ fill: ${d.themedColor.textHighEmphasis};
4022
+ }
4023
+ }
4024
+
4025
+ circle {
4026
+ stroke: ${d.themedColor.bg_50_600};
4027
+ }
4028
+ `, yd = () => {
4029
+ const e = Ne(), [t, n] = T(), { files: o, removeFile: s, isFileUploadEnabled: i } = zt();
4030
+ return !i || o.length === 0 ? null : /* @__PURE__ */ r.createElement(xd, null, o.map(({ preview: { type: a, name: l, url: c } }, u) => /* @__PURE__ */ r.createElement(Ed, { key: c, onMouseOver: () => n(u), onMouseLeave: () => n(void 0) }, (e || t === u) && /* @__PURE__ */ r.createElement(vd, { title: "Remove file", onClick: () => s(u) }, /* @__PURE__ */ r.createElement(O, { type: "close-filled", color: d.themedColor.textMidEmphasis })), a.startsWith("image/") ? /* @__PURE__ */ r.createElement("img", { alt: "file-image", src: c }) : /* @__PURE__ */ r.createElement(Ot, { name: l, type: Mt(l, a) }))));
4031
+ }, Cd = ({ channel: e, messages: t }) => {
4032
+ const { stringSet: n } = R(), { aiAgentInfo: o, userSession: s } = V(), i = _d(), a = Sd({
4033
+ lastMessage: t[t.length - 1],
4034
+ aiAgentUserId: o.userId
4035
+ }), l = Ad({
4036
+ isDisabledWhileAIResponding: a,
4037
+ lastMessage: t[t.length - 1],
4038
+ currentUserId: s.userId
4039
+ });
4040
+ return !e || !i || Nt(e) ? [!0, n.MESSAGE_INPUT__PLACE_HOLDER__DISABLED] : Td(e) ? [!0, n.FORM_PLACEHOLDER] : a || l ? [!0, n.MESSAGE_INPUT__PLACE_HOLDER__WAIT_AI_AGENT_RESPONSE] : [!1, n.MESSAGE_INPUT__PLACE_HOLDER];
4041
+ }, _d = () => {
4042
+ const e = _t(), { chatSDK: t } = H(), [n, o] = T(!0);
4043
+ return L(() => {
4044
+ const s = new Qe({
4045
+ onDisconnected: () => o(!1),
4046
+ onConnected: () => o(!0),
4047
+ onReconnectSucceeded: () => o(!0)
4048
+ });
4049
+ return t.addConnectionHandler(e, s), () => {
4050
+ t.removeConnectionHandler(e);
4051
+ };
4052
+ }, [t]), n;
4053
+ }, Sd = ({
4054
+ lastMessage: e,
4055
+ aiAgentUserId: t
4056
+ }) => {
4057
+ const [n, o] = T(!1), s = pr();
4058
+ return L(() => {
4059
+ if (!e) return;
4060
+ const i = s.some((l) => l.userId === t), a = Ht(e, t) && we.isStreaming(e);
4061
+ o(!!(a || i));
4062
+ }, [s, e, t]), n;
4063
+ }, Td = (e) => {
4064
+ var a;
4065
+ const t = e == null ? void 0 : e.lastMessage;
4066
+ if (!t || !e) return !1;
4067
+ const n = t.extendedMessagePayload, o = n == null ? void 0 : n.form, s = o && !o.submitted_at && !o.canceled_at, i = e.isAIAgent && !!((a = e.conversation) != null && a.handedOverAt);
4068
+ return s && !i;
4069
+ }, wd = 3e4, Ad = ({
4070
+ lastMessage: e,
4071
+ isDisabledWhileAIResponding: t,
4072
+ currentUserId: n
4073
+ }) => {
4074
+ const [o, s] = T(!1), i = F(null), a = e && Ht(e, n) ? e.createdAt : 0;
4075
+ return L(() => {
4076
+ const l = () => {
4077
+ i.current && (clearTimeout(i.current), i.current = null), s(!1);
4078
+ }, c = (g) => {
4079
+ i.current && clearTimeout(i.current), s(!0), i.current = setTimeout(() => {
4080
+ s(!1), i.current = null;
4081
+ }, g);
4082
+ }, u = Date.now() - a, h = wd - u;
4083
+ return t || h <= 0 ? l() : c(h), () => {
4084
+ i.current && clearTimeout(i.current);
4085
+ };
4086
+ }, [t, a]), o;
4087
+ }, br = {
4088
+ textArea: _`min-height:40px;height:40px;font-size:16px;line-height:24px;`,
4089
+ attachIcon: _`margin-bottom:4px;`
4090
+ }, xr = m.button`all:unset;cursor:pointer;display:flex;align-items:center;justify-content:center;width:32px;height:32px;`, kd = m(xr)`flex-shrink:0;margin-inline-end:12px;margin-bottom:2px;&:disabled{cursor:not-allowed;}&:not(:disabled){&:hover{path{fill:${d.themedColor.textHighEmphasis};}}&:active{border-radius:4px;background-color:${d.themedColor.bg_200_400};}}${kt && br.attachIcon};`, Id = m.input`display:none;`, En = m.div`width:100%;position:relative;background-color:${d.themedColor.bg_100_500};border-radius:20px;`, vn = m.div`display:flex;flex-direction:row;align-items:flex-end;position:relative;`, yn = m.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:${d.themedColor.textHighEmphasis};resize:none;width:100%;height:${zn}px;overflow-wrap:break-word;white-space:pre-wrap;overflow-x:hidden;${kt && br.textArea};&::placeholder{color:${d.themedColor.textLowEmphasis};}&:disabled{cursor:not-allowed;&::placeholder{color:${d.themedColor.textDisabled};}}`, Cn = m.div`padding:12px 16px;position:relative;display:flex;align-items:center;`, _n = ({ disabled: e }) => {
4091
+ const t = F(null), { addFiles: n, clearFiles: o, files: s, isFileUploadEnabled: i } = zt();
4092
+ return !i || s.length > 0 ? null : /* @__PURE__ */ r.createElement(
4093
+ kd,
4094
+ {
4095
+ disabled: e,
4096
+ onClick: () => {
4097
+ var a;
4098
+ o(), (a = t.current) == null || a.click();
4099
+ }
4100
+ },
4101
+ /* @__PURE__ */ r.createElement(
4102
+ O,
4103
+ {
4104
+ type: "attach",
4105
+ color: e ? d.themedColor.textDisabled : d.themedColor.textMidEmphasis,
4106
+ size: 16
4107
+ }
4108
+ ),
4109
+ /* @__PURE__ */ r.createElement(
4110
+ Id,
4111
+ {
4112
+ type: "file",
4113
+ ref: t,
4114
+ onChange: (a) => {
4115
+ const l = a.currentTarget.files;
4116
+ l && n(Array.from(l)), a.target.value = "";
4117
+ },
4118
+ accept: Wn.join(",")
4119
+ }
4120
+ )
4121
+ );
4122
+ }, $d = () => {
4123
+ const e = F(null), [t, n] = T(""), { rootElement: o } = H(), { channelSource: s, messageSource: i } = K(), [a, l] = Cd({
4124
+ channel: s.channel,
4125
+ messages: i.messages
4126
+ }), { files: c, addFiles: u, clearFiles: h } = zt();
4127
+ yc({ onDropFiles: u }), fd({ blurred: a, elementRef: e, document: fe(o) }), bd(s.channel, t);
4128
+ const g = t.trim().length > 0, x = c.length > 0, y = !a && (g || x), E = () => {
4129
+ e.current && (e.current.value = "", e.current.style.height = ""), h(), n("");
4130
+ }, b = async () => {
4131
+ const S = t.trim(), M = { message: S };
4132
+ if (!(!S && !c.length)) {
4133
+ if (c.length > 0) {
4134
+ const P = c[0].file, $ = { ...M, file: P };
4135
+ i.sendFileMessage($), E();
4136
+ return;
4137
+ }
4138
+ i.sendUserMessage(M), E();
4139
+ }
4140
+ }, p = (S) => {
4141
+ const M = Array.from(S.clipboardData.files);
4142
+ M.length > 0 && (S.preventDefault(), u(M));
4143
+ }, f = (S) => {
4144
+ S.key !== "Enter" || S.nativeEvent.isComposing || S.shiftKey || (S.preventDefault(), b());
4145
+ }, v = (S) => {
4146
+ if (e.current) {
4147
+ e.current.style.height = "";
4148
+ const M = Math.min(qs, e.current.scrollHeight);
4149
+ zn < M && (e.current.style.height = `${M}px`);
4150
+ }
4151
+ n(S.target.value);
4152
+ };
4153
+ return a ? /* @__PURE__ */ r.createElement(Cn, null, /* @__PURE__ */ r.createElement(En, null, /* @__PURE__ */ r.createElement(vn, null, /* @__PURE__ */ r.createElement(yn, { disabled: !0, placeholder: l }), /* @__PURE__ */ r.createElement(_n, { disabled: !0 })))) : /* @__PURE__ */ r.createElement(Cn, null, /* @__PURE__ */ r.createElement(En, null, /* @__PURE__ */ r.createElement(yd, null), /* @__PURE__ */ r.createElement(vn, null, /* @__PURE__ */ r.createElement(
4154
+ yn,
4155
+ {
4156
+ ref: e,
4157
+ role: "textbox",
4158
+ "aria-label": "Text Input",
4159
+ placeholder: l,
4160
+ maxLength: 5e3,
4161
+ onKeyDown: f,
4162
+ onChange: v,
4163
+ onPaste: p
4164
+ }
4165
+ ), /* @__PURE__ */ r.createElement(_n, null))), y && /* @__PURE__ */ r.createElement(xr, { onClick: () => b() }, /* @__PURE__ */ r.createElement(O, { type: "send", color: d.color.primary.main, size: 20 })));
4166
+ }, Md = m.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:${d.themedColor.textLowEmphasis};&& a{font-weight:700;text-decoration:none;${I.light`
4167
+ color: ${d.color.information.light};
4168
+ `};
4169
+ ${I.dark`
4170
+ color: ${d.color.information.main};
4171
+ `};
4172
+ }
4173
+ `, Od = A(() => import("./DK3lW85j.js").then((e) => ({ default: e.MarkdownText }))), Ld = () => {
4174
+ const { aiAgentInfo: e } = V(), { messageSource: t } = K(), { userSession: n } = V();
4175
+ return !e.specialNoticeEnabled || !e.specialNotice || !(t.initialized && !t.messages.some((s) => Ht(s, n.userId))) ? null : /* @__PURE__ */ r.createElement(Md, null, /* @__PURE__ */ r.createElement(Od, null, e.specialNotice));
4176
+ }, Rd = () => /* @__PURE__ */ r.createElement(Dd, null, /* @__PURE__ */ r.createElement(Ld, null), /* @__PURE__ */ r.createElement(pd, null, /* @__PURE__ */ r.createElement($d, null))), Dd = m.div`z-index:0;border:none;width:100%;`, Nd = () => {
4177
+ var s, i;
4178
+ const { testerType: e } = ke(), { channelSource: t } = K(), n = ((i = (s = t.channel) == null ? void 0 : s.conversation) == null ? void 0 : i.status) === z.CLOSED, o = !!e;
4179
+ return n ? o ? /* @__PURE__ */ r.createElement(hd, null) : null : /* @__PURE__ */ r.createElement(Rd, null);
4180
+ }, Fd = () => {
4181
+ var v;
4182
+ const { state: e, logger: t, enableCloseConversationButton: n, enableExpandButton: o, dispatcher: s } = H(), { stringSet: i } = R(), { aiAgentInfo: a, activeChannel: l } = V(), { channelSource: c, onNavigateToConversationList: u } = K(), h = c.channel, x = Ne() ? 24 : 16, y = () => {
4183
+ e.setOpened(!1);
4184
+ }, E = async () => {
4185
+ try {
4186
+ const S = await (h == null ? void 0 : h.markConversationAsHandoff());
4187
+ t.info("conversation.handleAgentHandoff: success", S);
4188
+ } catch (S) {
4189
+ t.error("conversation.handleAgentHandoff: error", S);
4190
+ }
4191
+ }, b = async () => {
4192
+ h && await s.send(vo.CloseConversation({ channelUrl: h.url }));
4193
+ }, p = l && (h == null ? void 0 : h.url) === l.url, f = a.showHandoffButton && !!((v = h == null ? void 0 : h.conversation) != null && v.handoff) && p;
4194
+ return /* @__PURE__ */ r.createElement(Vd, null, /* @__PURE__ */ r.createElement(zd, null, u && /* @__PURE__ */ r.createElement(Fe, { onClick: () => u() }, /* @__PURE__ */ r.createElement(O, { type: "menu", size: 24, color: d.themedColor.textHighEmphasis })), p && /* @__PURE__ */ r.createElement(mr, { size: 34 }), /* @__PURE__ */ r.createElement(Gd, { variant: "h2", color: d.themedColor.textHighEmphasis }, a.nickname || (h == null ? void 0 : h.name))), /* @__PURE__ */ r.createElement(Wd, null, f && /* @__PURE__ */ r.createElement(
4195
+ Hd,
4196
+ {
4197
+ tooltipLabel: i.HEADER_BUTTON__AGENT_HANDOFF,
4198
+ disabled: !$i(h),
4199
+ size: x,
4200
+ onClick: E
4201
+ }
4202
+ ), n && /* @__PURE__ */ r.createElement(
4203
+ Ud,
4204
+ {
4205
+ disabled: !Zn(h),
4206
+ size: x,
4207
+ onClick: b
4208
+ }
4209
+ ), o && /* @__PURE__ */ r.createElement(Bd, { size: x }), /* @__PURE__ */ r.createElement(Pd, { size: x, onClick: y })));
4210
+ }, Bd = ({ size: e, disabled: t }) => {
4211
+ const { state: n } = H();
4212
+ return /* @__PURE__ */ r.createElement(Fe, { "aria-label": "expand", onClick: () => n.setExpanded(!n.expanded), disabled: t }, /* @__PURE__ */ r.createElement(O, { type: n.expanded ? "collapse" : "expand", size: e, color: d.themedColor.textHighEmphasis }));
4213
+ }, Pd = ({ size: e, disabled: t, onClick: n }) => /* @__PURE__ */ r.createElement(Fe, { "aria-label": "close messenger", onClick: n, disabled: t }, /* @__PURE__ */ r.createElement(O, { type: "close", size: e, color: d.themedColor.textHighEmphasis })), Ud = ({ size: e, disabled: t, onClick: n }) => /* @__PURE__ */ r.createElement(Fe, { "aria-label": "close conversation", onClick: n, disabled: t }, /* @__PURE__ */ r.createElement(
4214
+ O,
4215
+ {
4216
+ type: "mute",
4217
+ size: e,
4218
+ color: t ? d.themedColor.textDisabled : d.themedColor.textHighEmphasis
4219
+ }
4220
+ )), Hd = ({ size: e, onClick: t, disabled: n, tooltipLabel: o }) => /* @__PURE__ */ r.createElement(ir, { label: o, position: "bottom", disabled: n }, /* @__PURE__ */ r.createElement(Fe, { "aria-label": "agent", onClick: t, disabled: n }, /* @__PURE__ */ r.createElement(
4221
+ O,
4222
+ {
4223
+ type: "agent",
4224
+ size: e,
4225
+ color: n ? d.themedColor.textDisabled : d.themedColor.textHighEmphasis
4226
+ }
4227
+ ))), Vd = m.div`height:56px;box-sizing:border-box;display:flex;align-items:center;padding:11px 12px;border-bottom:1px solid ${d.themedColor.textDisabled};background-color:${({ theme: e }) => e.colors.base.headerBackground};`, zd = m.div`display:flex;flex:1;flex-direction:row;align-items:center;gap:6px;overflow:hidden;`, Wd = m.div`display:flex;gap:10px;align-items:center;justify-content:center;`, Gd = m(w)`text-overflow:ellipsis;overflow:hidden;white-space:nowrap;padding:2px 0;`, Fe = m.button`all:unset;padding:4px;cursor:pointer;display:flex;align-items:center;justify-content:center;&:disabled{cursor:not-allowed;}`, jd = () => {
4228
+ const { isActionbookTester: e } = ke();
4229
+ return e ? null : /* @__PURE__ */ r.createElement(Fd, null);
4230
+ }, Sn = ({
4231
+ children: e,
4232
+ onNavigateToConversationList: t,
4233
+ closedChannelUrl: n,
4234
+ onClearClosedChannelUrl: o
4235
+ }) => {
4236
+ const { Template: s } = Wt.useContext();
4237
+ return /* @__PURE__ */ r.createElement(
4238
+ vc,
4239
+ {
4240
+ onNavigateToConversationList: t,
4241
+ closedChannelUrl: n,
4242
+ onClearClosedChannelUrl: o
4243
+ },
4244
+ /* @__PURE__ */ r.createElement(yt, null, /* @__PURE__ */ r.createElement(yt.Consumer, null, (i) => /* @__PURE__ */ r.createElement(r.Fragment, null, /* @__PURE__ */ r.createElement(qd, { ...i }, /* @__PURE__ */ r.createElement(s, null)), e)))
4245
+ );
4246
+ }, Wt = Te({
4247
+ template: Kd,
4248
+ components: {
4249
+ Header: jd,
4250
+ Body: md,
4251
+ Footer: Nd
4252
+ }
4253
+ });
4254
+ function Kd() {
4255
+ const { components: e } = Wt.useContext();
4256
+ 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));
4257
+ }
4258
+ const qd = m.div`height:100%;width:100%;display:flex;flex-direction:column;flex:1;background-color:${({ theme: e }) => e.colors.base.background};`, {
4259
+ Provider: Zd,
4260
+ Context: vm,
4261
+ useContext: Er
4262
+ } = W("ConversationList");
4263
+ function Yd({
4264
+ conversationListLimit: e,
4265
+ conversationListFilter: t,
4266
+ onOpenConversationView: n = Le,
4267
+ children: o
4268
+ }) {
4269
+ return /* @__PURE__ */ r.createElement(
4270
+ rs,
4271
+ {
4272
+ conversationListLimit: e,
4273
+ conversationListFilter: t
4274
+ },
4275
+ (s) => /* @__PURE__ */ r.createElement(Zd, { value: { ...s, onOpenConversationView: n } }, o)
4276
+ );
4277
+ }
4278
+ const vr = Te({
4279
+ template: Jd,
4280
+ // Note: 리스트 변경되면 디자인 변경 가능성이 있어서 일단 컴포넌트는 비워둠
4281
+ components: {}
4282
+ });
4283
+ function Jd({
4284
+ title: e = "",
4285
+ lastMessageTimestamp: t = Date.now(),
4286
+ onClick: n
4287
+ }) {
4288
+ const { stringSet: o, format: s } = R();
4289
+ return /* @__PURE__ */ r.createElement(Xd, { role: "button", onClick: () => n == null ? void 0 : n() }, /* @__PURE__ */ r.createElement(eu, null, /* @__PURE__ */ r.createElement(tu, null, /* @__PURE__ */ r.createElement(w, { variant: "subtitle1", color: d.themedColor.textHighEmphasis }, s(t, o.DATE_FORMAT__CONVERSATION_LIST__LIST_ITEM_TITLE)), /* @__PURE__ */ r.createElement(w, { variant: "caption2", color: d.themedColor.textLowEmphasis }, s(t, o.DATE_FORMAT__CONVERSATION_LIST__LIST_ITEM_TITLE_CAPTION))), /* @__PURE__ */ r.createElement(w, { variant: "body3", color: d.themedColor.textMidEmphasis }, e || o.CONVERSATION_LIST__TOPICS_FALLBACK)), /* @__PURE__ */ r.createElement(O, { type: "chevron-right", size: 16, color: d.themedColor.textHighEmphasis }), /* @__PURE__ */ r.createElement(Qd, null));
4290
+ }
4291
+ const Xd = m.div`display:flex;flex-direction:row;align-items:center;position:relative;width:100%;padding:14px 16px;box-sizing:border-box;gap:4px;cursor:pointer;`, Qd = m.div`position:absolute;bottom:0;height:1px;width:calc(100% - 32px);background-color:${d.themedColor.textDisabled};`, eu = m.div`gap:4px;display:flex;flex-direction:column;flex:1;`, tu = m.div`display:flex;justify-content:flex-start;align-items:center;gap:6px;`, nu = ({ items: e, renderItem: t, onEndReached: n }) => {
4292
+ const o = (s) => {
4293
+ const i = s.target;
4294
+ i.scrollHeight - i.scrollTop === i.clientHeight && (n == null || n());
4295
+ };
4296
+ return /* @__PURE__ */ r.createElement(ru, { onScroll: (s) => o(s) }, e.map((s, i) => t(s, i)));
4297
+ }, ru = m.div`width:100%;height:100%;display:flex;flex-direction:column;flex:1;overflow:auto;`, ou = () => {
4298
+ const { stringSet: e } = R(), { listSource: t, onOpenConversationView: n } = Er(), { Template: o } = vr.useContext();
4299
+ return t.initialized ? t.channels.length === 0 ? /* @__PURE__ */ r.createElement(Ce, { type: "noChannels", label: e.CONVERSATION_LIST__NO_CONVERSATIONS }) : /* @__PURE__ */ r.createElement(
4300
+ nu,
4301
+ {
4302
+ items: t.channels,
4303
+ renderItem: (s) => {
4304
+ var i, a, l;
4305
+ return /* @__PURE__ */ r.createElement(
4306
+ o,
4307
+ {
4308
+ key: s.url,
4309
+ channelUrl: s.url,
4310
+ title: (a = (i = s.conversation) == null ? void 0 : i.topics) == null ? void 0 : a.join(", "),
4311
+ lastMessageTimestamp: (l = s.lastMessage) == null ? void 0 : l.createdAt,
4312
+ onClick: () => n(s.url, z.CLOSED),
4313
+ channel: s
4314
+ }
4315
+ );
4316
+ },
4317
+ onEndReached: () => {
4318
+ t.loadMore();
4319
+ }
4320
+ }
4321
+ ) : /* @__PURE__ */ r.createElement(Ce, { type: "loading" });
4322
+ }, su = () => {
4323
+ const { stringSet: e } = R(), { activeChannel: t } = V(), [n] = T(() => (t == null ? void 0 : t.status) === z.OPEN);
4324
+ return n ? e.RETURN_TO_CONVERSATION : e.START_NEW_CONVERSATION;
4325
+ }, iu = () => {
4326
+ const { refreshActiveChannel: e } = V(), { onOpenConversationView: t } = Er(), n = su();
4327
+ return /* @__PURE__ */ r.createElement(
4328
+ au,
4329
+ {
4330
+ role: "button",
4331
+ onClick: async () => {
4332
+ const o = await e();
4333
+ t(o, z.OPEN);
4334
+ }
4335
+ },
4336
+ /* @__PURE__ */ r.createElement(lu, { variant: "h1" }, n)
4337
+ );
4338
+ }, au = m.div`background-color:${({ theme: e }) => e.colors.base.primary};display:flex;align-items:center;justify-content:center;padding:16px;cursor:pointer;`, lu = m(w)`color:${({ theme: e }) => e.colors.base.primaryContrastContent};overflow:hidden;text-overflow:ellipsis;white-space:nowrap;`, cu = () => {
4339
+ const { stringSet: e } = R();
4340
+ return /* @__PURE__ */ r.createElement(du, null, /* @__PURE__ */ r.createElement(uu, { variant: "h2", color: d.themedColor.textHighEmphasis }, e.CONVERSATION_LIST__HEADER_TITLE), /* @__PURE__ */ r.createElement(mu, null));
4341
+ }, du = m.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};`, uu = m(w)`padding:0 12px;width:100%;box-sizing:border-box;text-overflow:ellipsis;overflow:hidden;white-space:nowrap;`, mu = m.div`position:absolute;bottom:0;width:100%;height:1px;background-color:${d.themedColor.textDisabled};`, hu = ({
4342
+ conversationListLimit: e,
4343
+ conversationListFilter: t,
4344
+ children: n,
4345
+ onOpenConversationView: o
4346
+ }) => {
4347
+ const { Template: s } = Gt.useContext();
4348
+ return /* @__PURE__ */ r.createElement(
4349
+ Yd,
4350
+ {
4351
+ conversationListLimit: e,
4352
+ conversationListFilter: t,
4353
+ onOpenConversationView: o
4354
+ },
4355
+ /* @__PURE__ */ r.createElement(pu, null, /* @__PURE__ */ r.createElement(s, null)),
4356
+ n
4357
+ );
4358
+ }, Gt = Te({
4359
+ template: gu,
4360
+ components: {
4361
+ Header: cu,
4362
+ Body: ou,
4363
+ Footer: iu
4364
+ }
4365
+ });
4366
+ function gu() {
4367
+ const { components: e } = Gt.useContext();
4368
+ 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));
4369
+ }
4370
+ const pu = m.div`height:100%;width:100%;display:flex;flex-direction:column;flex:1;background-color:${({ theme: e }) => e.colors.base.background};`, fu = _`:where(#${ie.ENTRY}) :not(code *){font-family:'Roboto',sans-serif;box-sizing:border-box;}`, bu = [fu, Os, Ls], xu = (e, ...t) => Wr(e, ...bu, ...t), Eu = xu``, vu = lo(
4371
+ Wt,
4372
+ ye,
4373
+ Pt,
4374
+ Ut,
4375
+ Gt,
4376
+ vr
4377
+ );
4378
+ function yu({
4379
+ appearance: e,
4380
+ rootElement: t,
4381
+ logger: n,
4382
+ language: o,
4383
+ stringSet: s,
4384
+ children: i,
4385
+ messageTemplate: a,
4386
+ theme: l
4387
+ }) {
4388
+ return Bs(Cs, t), /* @__PURE__ */ r.createElement(Gr, { target: t }, /* @__PURE__ */ r.createElement(Ds, { rootElement: t, logger: n, appearance: e, theme: l }, /* @__PURE__ */ r.createElement(is, { internalVariables: a == null ? void 0 : a.__internalVariables }, /* @__PURE__ */ r.createElement(Ms, { stringSet: s, logger: n, language: o }, /* @__PURE__ */ r.createElement(vu, null, i, /* @__PURE__ */ r.createElement(Eu, null))))));
4389
+ }
4390
+ const je = {}, Ke = {
4391
+ getItem: (e) => {
4392
+ try {
4393
+ return localStorage.getItem(e);
4394
+ } catch {
4395
+ return je[e] ?? null;
4396
+ }
4397
+ },
4398
+ setItem: (e, t) => {
4399
+ try {
4400
+ localStorage.setItem(e, t);
4401
+ } catch {
4402
+ je[e] = t;
4403
+ }
4404
+ },
4405
+ deleteItem: (e) => {
4406
+ try {
4407
+ localStorage.removeItem(e);
4408
+ } catch {
4409
+ delete je[e];
4410
+ }
4411
+ },
4412
+ getKeys: (e) => {
4413
+ try {
4414
+ const t = [];
4415
+ for (let n = 0; n < localStorage.length; n++) {
4416
+ const o = localStorage.key(n);
4417
+ o && o.startsWith(e) && t.push(o);
4418
+ }
4419
+ return t;
4420
+ } catch {
4421
+ return Object.keys(je).filter((t) => t.startsWith(e));
4422
+ }
4423
+ }
4424
+ }, yr = Se(function({
4425
+ rootElement: t = document.body,
4426
+ logLevel: n = An.WARN,
4427
+ language: o = navigator.language,
4428
+ userSessionInfo: s,
4429
+ children: i,
4430
+ ...a
4431
+ }, l) {
4432
+ var c, u;
4433
+ return $e.level !== n && ($e.level = n), Fs("https://fonts.googleapis.com/css2?family=Roboto&display=swap", t), /* @__PURE__ */ r.createElement("div", { id: ie.ENTRY, style: { width: "fit-content", height: "fit-content", ...a.entryStyle } }, /* @__PURE__ */ r.createElement(
4434
+ yu,
4435
+ {
4436
+ logger: $e,
4437
+ rootElement: t,
4438
+ appearance: (c = a.agentPreviewConfigs) == null ? void 0 : c.appearance,
4439
+ stringSet: a.stringSet,
4440
+ language: o,
4441
+ messageTemplate: a.messageTemplate,
4442
+ theme: a.theme
4443
+ },
4444
+ /* @__PURE__ */ r.createElement(
4445
+ Hs,
4446
+ {
4447
+ rootElement: t,
4448
+ keyValueStorage: {
4449
+ get: Ke.getItem,
4450
+ set: Ke.setItem,
4451
+ delete: Ke.deleteItem,
4452
+ getKeys: Ke.getKeys
4453
+ },
4454
+ language: o,
4455
+ logger: $e,
4456
+ dispatcher: Cu,
4457
+ chatParams: {
4458
+ ...a.chatParams,
4459
+ customApiHost: a.customApiHost,
4460
+ customWebSocketHost: a.customWebSocketHost
4461
+ },
4462
+ chatSDK: a.customChatSDK,
4463
+ ...a
4464
+ },
4465
+ /* @__PURE__ */ r.createElement(
4466
+ zs,
4467
+ {
4468
+ ref: l,
4469
+ userSessionInfo: s,
4470
+ forceCreateChannel: (u = a.agentPreviewConfigs) == null ? void 0 : u.forceCreateChannel
4471
+ },
4472
+ /* @__PURE__ */ r.createElement(Ql, { ...a._UNSAFE_INTERNAL_dashboardTester }, i, /* @__PURE__ */ r.createElement("div", { id: ie.MODAL_ROOT }))
4473
+ )
4474
+ )
4475
+ ));
4476
+ }), $e = new Rn(An.WARN), Cu = new On($e), Cr = ({ children: e, isOpened: t }) => {
4477
+ const { dir: n, rootElement: o } = H(), s = fe(o, !0);
4478
+ return L(() => {
4479
+ const i = "sb-agent-block-scroll";
4480
+ return t ? s.body.classList.add(i) : s.body.classList.remove(i), () => {
4481
+ s.body.classList.remove(i);
4482
+ };
4483
+ }, [s, t]), /* @__PURE__ */ r.createElement(_u, { dir: n, $visible: t }, e);
4484
+ }, _u = m.div`width:100%;height:100%;position:fixed;top:0;left:0;z-index:${xe.WINDOW};visibility:${({ $visible: e }) => e ? "visible" : "hidden"};`, Su = 48, Tu = 2 / 3;
4485
+ function wu({
4486
+ className: e,
4487
+ isOpened: t,
4488
+ onClick: n,
4489
+ type: o,
4490
+ imageUrl: s,
4491
+ dir: i,
4492
+ animated: a = !0,
4493
+ backgroundColor: l,
4494
+ size: c = Su
4495
+ }) {
4496
+ const u = bt(l), h = Math.round(c * Tu);
4497
+ return /* @__PURE__ */ r.createElement(
4498
+ Iu,
4499
+ {
4500
+ dir: i,
4501
+ id: ie.LAUNCHER,
4502
+ className: e,
4503
+ "aria-label": "Sendbird AIAgent Launcher",
4504
+ onClick: n,
4505
+ $animated: a,
4506
+ $backgroundColor: l,
4507
+ $size: c
4508
+ },
4509
+ /* @__PURE__ */ r.createElement($u, { $isOpened: t, $animated: a, $fillColor: u, $iconSize: h }, /* @__PURE__ */ r.createElement(Tn.Open, { url: s, isDefaultIcon: o === "default_icon" })),
4510
+ /* @__PURE__ */ r.createElement(Mu, { $isOpened: t, $animated: a, $fillColor: u, $iconSize: h }, /* @__PURE__ */ r.createElement(Tn.Close, { size: h }))
4511
+ );
4512
+ }
4513
+ const Au = _`&:hover{transition:transform 250ms cubic-bezier(0.33,0,0,1);transform:scale(1.1);}&:active{transform:scale(0.8);}`, ku = _`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:${({ $iconSize: e }) => e}px;height:${({ $iconSize: e }) => e}px;filter:${({ $fillColor: e }) => e === Vn.WHITE ? "grayscale(100%) brightness(2000%)" : "grayscale(100%) invert(100%) saturate(0%) brightness(0%) contrast(1000%)"};}}`, _r = _`svg{width:${({ $iconSize: e }) => e}px;height:${({ $iconSize: e }) => e}px;${({ $fillColor: e }) => _`
4514
+ path {
4515
+ fill: ${e};
4516
+ }
4517
+ [class*='fill'] {
4518
+ fill: ${e};
4519
+ }
4520
+ `}
4521
+ }
4522
+ `, Iu = m.button`position:relative;padding:0;width:${({ $size: e }) => e}px;height:${({ $size: e }) => e}px;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 && Au}`, Sr = m.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;`, $u = m(Sr)`opacity:${({ $isOpened: e }) => e ? 0 : 1};transform:${({ $animated: e, $isOpened: t }) => e && (t ? "rotate(-90deg) scale(0)" : "rotate(0deg)")};${ku}${_r}`, Mu = m(Sr)`scale:${({ $isOpened: e }) => e ? 1 : 0};transform:${({ $animated: e, $isOpened: t }) => e && (t ? "rotate(0deg)" : "rotate(-90deg)")};${_r}`, Tn = {
4523
+ Open: (e) => e.url ? /* @__PURE__ */ r.createElement("img", { src: e.url, alt: "launcher-img", "data-default-icon": e.isDefaultIcon }) : /* @__PURE__ */ r.createElement(Lt, null),
4524
+ Close: ({ size: e }) => /* @__PURE__ */ r.createElement(O, { size: e, type: "chevron-down" })
4525
+ };
4526
+ function Tr({ className: e, size: t }) {
4527
+ const { colors: n } = St(), { dir: o, state: s } = H(), { launcherInfo: i } = V();
4528
+ return Lu(), /* @__PURE__ */ r.createElement(
4529
+ wu,
4530
+ {
4531
+ dir: o,
4532
+ className: e,
4533
+ isOpened: s.opened,
4534
+ onClick: () => s.setOpened(!s.opened),
4535
+ type: i.type,
4536
+ imageUrl: i.imageUrl,
4537
+ backgroundColor: n.base.primary,
4538
+ size: t
4539
+ }
4540
+ );
4541
+ }
4542
+ const Ou = 1e3 * 60;
4543
+ function Lu() {
4544
+ const { chatSDK: e, state: t, logger: n, enableAutoDisconnectInLauncher: o } = H(), s = F(null);
4545
+ L(() => {
4546
+ if (!o) return;
4547
+ function i() {
4548
+ s.current && (clearTimeout(s.current), s.current = null);
4549
+ }
4550
+ function a() {
4551
+ e.connectionState === Vr.CLOSED && (e.reconnect(), n.debug("useSDKInactivityTimeout: reconnected")), i(), n.debug("useSDKInactivityTimeout: clear disconnect schedule");
4552
+ }
4553
+ function l() {
4554
+ i(), s.current = setTimeout(async () => {
4555
+ await e.disconnectWebSocket(), n.debug("useSDKInactivityTimeout: disconnected");
4556
+ }, Ou);
4557
+ }
4558
+ t.opened ? a() : (l(), n.debug("useSDKInactivityTimeout: schedule disconnect"));
4559
+ }, [o, e, t.opened]);
4560
+ }
4561
+ const wr = _e(null);
4562
+ function Ru() {
4563
+ const e = se(wr);
4564
+ if (!e)
4565
+ throw new Error("useNavigator() must be used within <Navigator />");
4566
+ return e;
4567
+ }
4568
+ function Ar({ children: e }) {
4569
+ const t = Ru();
4570
+ return typeof e == "function" ? e(t) : /* @__PURE__ */ r.createElement(r.Fragment, null, e);
4571
+ }
4572
+ const Du = kn`0%{transform:translateY(40px);opacity:0;}100%{transform:translateY(0px);opacity:1;}`, Nu = kn`0%{transform:translateY(0px);opacity:1;}100%{transform:translateY(40px);opacity:0;}`, Fu = _`animation-name:${Du};animation-duration:0.3s;animation-fill-mode:forwards;`, Bu = _``, Pu = _`animation-name:${Nu};animation-duration:0.3s;animation-fill-mode:forwards;`, Uu = _`visibility:hidden;`, Hu = m.div`position:absolute;top:0;left:0;width:100%;height:100%;${({ $transitionState: e }) => {
4573
+ switch (e) {
4574
+ case "entering":
4575
+ return Fu;
4576
+ case "entered":
4577
+ return Bu;
4578
+ case "exiting":
4579
+ return Pu;
4580
+ case "exited":
4581
+ return Uu;
4582
+ default:
4583
+ return "";
4584
+ }
4585
+ }}${({ $active: e }) => e ? _`
4586
+ z-index: 999;
4587
+ ` : _`z-index:1;pointer-events:none;`}
4588
+ `;
4589
+ function Me({ initialId: e, children: t }) {
4590
+ const n = D((p, f) => {
4591
+ c((v) => [...v, p]), h((v) => ({ ...v, [p]: !0 })), f != null && f.reset && E((v) => ({
4592
+ ...v,
4593
+ [p]: (v[p] || 0) + 1
4594
+ })), x((v) => ({
4595
+ ...v,
4596
+ [p]: "entering"
4597
+ })), setTimeout(() => {
4598
+ x((v) => ({
4599
+ ...v,
4600
+ [p]: "entered"
4601
+ }));
4602
+ }, 300);
4603
+ }, []), o = D(() => {
4604
+ c((p) => {
4605
+ if (p.length <= 1) return p;
4606
+ const f = p[p.length - 1];
4607
+ return x((v) => ({
4608
+ ...v,
4609
+ [f]: "exiting"
4610
+ })), setTimeout(() => {
4611
+ x((v) => ({
4612
+ ...v,
4613
+ [f]: "exited"
4614
+ })), c((v) => v.slice(0, -1));
4615
+ }, 300), p;
4616
+ });
4617
+ }, []), s = ee(() => ({
4618
+ navigation: {
4619
+ navigate: n,
4620
+ pop: o
4621
+ }
4622
+ }), [n, o]), i = ee(() => Dr.toArray(t).filter(
4623
+ (p) => p.type === Ar
4624
+ ), [t]), a = ee(() => {
4625
+ const p = {};
4626
+ return i.forEach((f) => {
4627
+ const { id: v, lazy: S, children: M } = f.props;
4628
+ p[v] = { lazy: S, element: typeof M == "function" ? M(s) : M };
4629
+ }), p;
4630
+ }, [i]), [l, c] = T([e]), [u, h] = T(() => {
4631
+ const p = {};
4632
+ return Object.entries(a).forEach(([f, { lazy: v }]) => {
4633
+ v === !1 && (p[f] = !0);
4634
+ }), p[e] = !0, p;
4635
+ }), [g, x] = T(() => {
4636
+ const p = {};
4637
+ return Object.keys(a).forEach((f) => {
4638
+ f === e ? p[f] = "entered" : p[f] = "exited";
4639
+ }), p;
4640
+ }), [y, E] = T({}), b = l[l.length - 1];
4641
+ return /* @__PURE__ */ r.createElement(wr.Provider, { value: s }, /* @__PURE__ */ r.createElement(Vu, null, Object.keys(a).map((p) => {
4642
+ var M;
4643
+ if (!u[p]) return null;
4644
+ const f = g[p] || "exited", v = p === b, S = `${p}-${y[p] || 0}`;
4645
+ return /* @__PURE__ */ r.createElement(Hu, { key: S, $transitionState: f, $active: v }, (M = a[p]) == null ? void 0 : M.element);
4646
+ })));
4647
+ }
4648
+ const Vu = m.div`position:relative;width:100%;height:100%;`;
4649
+ Me.Screen = Ar;
4650
+ const ge = {
4651
+ activeConv: "active-conv",
4652
+ closedConv: "closed-conv",
4653
+ convList: "conv-list"
4654
+ }, kr = ({ setClosedChannelUrl: e, closedChannelUrl: t }) => /* @__PURE__ */ r.createElement(Me, { initialId: ge.activeConv }, /* @__PURE__ */ r.createElement(Me.Screen, { id: ge.activeConv }, ({ navigation: n }) => /* @__PURE__ */ r.createElement(Sn, { onNavigateToConversationList: () => n.navigate(ge.convList, { reset: !0 }) })), /* @__PURE__ */ r.createElement(Me.Screen, { id: ge.closedConv }, ({ navigation: n }) => /* @__PURE__ */ r.createElement(
4655
+ Sn,
4656
+ {
4657
+ onNavigateToConversationList: () => n.pop(),
4658
+ closedChannelUrl: t,
4659
+ onClearClosedChannelUrl: () => e(void 0)
4660
+ }
4661
+ )), /* @__PURE__ */ r.createElement(Me.Screen, { id: ge.convList, lazy: !0 }, ({ navigation: n }) => /* @__PURE__ */ r.createElement(
4662
+ hu,
4663
+ {
4664
+ onOpenConversationView: (o, s) => {
4665
+ s === "closed" ? (e(o), n.navigate(ge.closedConv, { reset: !0 })) : n.navigate(ge.activeConv);
4666
+ }
4667
+ }
4668
+ )));
4669
+ function zu({ isExpanded: e, isOpened: t, children: n, launcher: o }) {
4670
+ const { dir: s } = H();
4671
+ return /* @__PURE__ */ r.createElement(Wu, null, /* @__PURE__ */ r.createElement(Gu, { dir: s, id: ie.WINDOW, $isExpanded: e, $isOpened: t }, n), o);
4672
+ }
4673
+ const Wu = m.div`display:flex;flex-direction:column;gap:8px;align-items:flex-end;`, Gu = m.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 && Ku};${({ $isExpanded: e }) => e && ju};`, ju = _`width:743px;height:723px;`, Ku = _`z-index:${xe.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;`, ym = Se(function({ children: e, ...t }, n) {
4674
+ const o = Ne(), [s, i] = T(), a = o ? Cr : zu;
4675
+ return /* @__PURE__ */ r.createElement(yr, { enableExpandButton: !o, ref: n, ...t }, /* @__PURE__ */ r.createElement(Hn, null, ({ state: l }) => /* @__PURE__ */ r.createElement(r.Fragment, null, /* @__PURE__ */ r.createElement(a, { isExpanded: l.expanded, isOpened: l.opened, launcher: /* @__PURE__ */ r.createElement(Tr, null) }, /* @__PURE__ */ r.createElement(
4676
+ kr,
4677
+ {
4678
+ closedChannelUrl: s,
4679
+ setClosedChannelUrl: i
4680
+ }
4681
+ )), e)));
4682
+ }), {
4683
+ Provider: qu,
4684
+ useContext: jt
4685
+ } = W("FixedMessengerStyle");
4686
+ function Ir(e, t, n, o = 0) {
4687
+ const { top: s, bottom: i, start: a, end: l } = n;
4688
+ let c = "", u = "";
4689
+ switch (e) {
4690
+ case "start":
4691
+ u = `inset-inline-start: ${j(a)}`;
4692
+ break;
4693
+ case "end":
4694
+ u = `inset-inline-end: ${j(l)}`;
4695
+ break;
4696
+ }
4697
+ switch (t) {
4698
+ case "top":
4699
+ c = `top: calc(${j(s)} + ${o}px)`;
4700
+ break;
4701
+ case "bottom":
4702
+ c = `bottom: calc(${j(i)} + ${o}px)`;
4703
+ break;
4704
+ }
4705
+ return _`${c};${u};`;
4706
+ }
4707
+ function Zu(e) {
4708
+ const { horizontal: t, vertical: n, margin: o, launcherSize: s } = jt();
4709
+ return /* @__PURE__ */ r.createElement(Yu, { ...e, size: s, $horizontal: t, $vertical: n, $margin: o });
4710
+ }
4711
+ const Yu = m(Tr)`position:fixed;z-index:${xe.LAUNCHER};${({ $horizontal: e, $vertical: t, $margin: n }) => Ir(e, t, n)};`;
4712
+ function Ju({ isExpanded: e, isOpened: t, children: n }) {
4713
+ const { dir: o } = H(), { horizontal: s, vertical: i, margin: a, launcherSize: l } = jt();
4714
+ return /* @__PURE__ */ r.createElement(
4715
+ Xu,
4716
+ {
4717
+ dir: o,
4718
+ id: ie.WINDOW,
4719
+ $isExpanded: e,
4720
+ $isOpened: t,
4721
+ $horizontal: s,
4722
+ $vertical: i,
4723
+ $margin: a,
4724
+ $launcherSize: l
4725
+ },
4726
+ n
4727
+ );
4728
+ }
4729
+ const Xu = m.div`background:${({ theme: e }) => e.colors.base.background};display:flex;overscroll-behavior:none;-webkit-overflow-scrolling:auto;position:fixed;${({ $horizontal: e, $vertical: t, $margin: n, $launcherSize: o }) => Ir(e, t, n, o + 12)};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:${({ $horizontal: e, $vertical: t }) => `${e === "start" ? "left" : "right"} ${t}`};
4730
+ [dir='rtl'] &:not([dir='ltr']),
4731
+ &[dir='rtl'] {
4732
+ transform-origin: ${({ $horizontal: e, $vertical: t }) => `${e === "start" ? "right" : "left"} ${t}`};
4733
+ }
4734
+
4735
+ ${({ $isOpened: e }) => e && em};
4736
+ ${({ $isExpanded: e }) => e && Qu};
4737
+ `, Qu = _`width:743px;height:723px;`, em = _`z-index:${xe.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;`, $r = { top: 24, bottom: 24, start: 24, end: 24 }, tm = Se(function({ children: e, ...t }, n) {
4738
+ const [o, s] = T(), [i, a] = T("end-bottom"), [l, c] = T($r), [u, h] = T(48), g = Ne(), x = g ? Cr : Ju, { horizontal: y, vertical: E } = ee(() => {
4739
+ const [b, p] = i.split("-");
4740
+ return { horizontal: b === "start" ? "start" : "end", vertical: p === "top" ? "top" : "bottom" };
4741
+ }, [i]);
4742
+ return /* @__PURE__ */ r.createElement(yr, { enableExpandButton: !g, ref: n, ...t }, /* @__PURE__ */ r.createElement(Hn, null, ({ state: b }) => /* @__PURE__ */ r.createElement(
4743
+ qu,
4744
+ {
4745
+ value: { horizontal: y, vertical: E, margin: l, launcherSize: u, setPosition: a, setMargin: c, setLauncherSize: h }
4746
+ },
4747
+ /* @__PURE__ */ r.createElement(x, { isExpanded: b.expanded, isOpened: b.opened }, /* @__PURE__ */ r.createElement(
4748
+ kr,
4749
+ {
4750
+ closedChannelUrl: o,
4751
+ setClosedChannelUrl: s
4752
+ }
4753
+ )),
4754
+ /* @__PURE__ */ r.createElement(Zu, null),
4755
+ e
4756
+ )));
4757
+ }), nm = (e) => {
4758
+ var s, i, a, l;
4759
+ const { setPosition: t, setMargin: n, setLauncherSize: o } = jt();
4760
+ return pe(() => {
4761
+ e.position && t(e.position), e.margin && n({ ...$r, ...e.margin }), e.launcherSize && o(e.launcherSize);
4762
+ }, [
4763
+ e.position,
4764
+ (s = e.margin) == null ? void 0 : s.top,
4765
+ (i = e.margin) == null ? void 0 : i.bottom,
4766
+ (a = e.margin) == null ? void 0 : a.start,
4767
+ (l = e.margin) == null ? void 0 : l.end,
4768
+ e.launcherSize
4769
+ ]), null;
4770
+ }, Cm = Object.assign(tm, {
4771
+ Style: nm
4772
+ });
4773
+ export {
4774
+ It as A,
4775
+ vo as C,
4776
+ ym as D,
4777
+ Cm as F,
4778
+ O as I,
4779
+ or as L,
4780
+ Yl as M,
4781
+ Pt as O,
4782
+ Em as P,
4783
+ Ut as S,
4784
+ w as a,
4785
+ yr as b,
4786
+ d as c,
4787
+ yu as d,
4788
+ V as e,
4789
+ R as f,
4790
+ wu as g,
4791
+ ye as h,
4792
+ oe as i,
4793
+ vr as j,
4794
+ Sn as k,
4795
+ Wt as l,
4796
+ Cu as m,
4797
+ xm as n,
4798
+ vc as o,
4799
+ K as p,
4800
+ hu as q,
4801
+ Gt as r,
4802
+ vm as s,
4803
+ Yd as t,
4804
+ H as u,
4805
+ Er as v,
4806
+ Ln as w,
4807
+ Fo as x,
4808
+ Qt as y
4809
+ };