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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/dist/cjs/BHzdI_Qt.cjs +1 -0
  2. package/dist/cjs/BJrc6-lv.cjs +1 -0
  3. package/dist/cjs/Bb0Nr21w.cjs +1 -0
  4. package/dist/cjs/{CuE-R-Ab.cjs → C5K5hHy4.cjs} +1 -1
  5. package/dist/cjs/C6S9YvOe.cjs +1 -0
  6. package/dist/cjs/CzB3EwDs.cjs +1 -0
  7. package/dist/cjs/{udFozCQd.cjs → D1cSvUyI.cjs} +1 -1
  8. package/dist/cjs/D6zoiaPq.cjs +1 -0
  9. package/dist/cjs/{D0K6vsP-.cjs → DCYbEbRy.cjs} +1 -1
  10. package/dist/cjs/{D7p9IHLh.cjs → DdDHgZcy.cjs} +1 -1
  11. package/dist/cjs/Df_7d5l_.cjs +1 -0
  12. package/dist/cjs/KtTuzALW.cjs +1 -0
  13. package/dist/cjs/QbzBXqp7.cjs +1 -0
  14. package/dist/cjs/erHZgq1d.cjs +309 -0
  15. package/dist/cjs/{Qn-Vab7D.cjs → kjUExkVf.cjs} +1 -1
  16. package/dist/es/{DYR8UT_l.js → B-Bit2rH.js} +21 -5
  17. package/dist/es/{BKSUGIyL.js → B7zUx3wi.js} +21 -5
  18. package/dist/es/{D0QwWNMF.js → BDu5g5oT.js} +21 -5
  19. package/dist/es/BFu7kfm0.js +4787 -0
  20. package/dist/es/{jtdZ66dz.js → BMpxfxq9.js} +1 -1
  21. package/dist/es/{B1s75De5.js → BOQBJafG.js} +21 -5
  22. package/dist/es/{CA1gVgSD.js → BgVN3jH0.js} +21 -5
  23. package/dist/es/{EylKxx4d.js → CGGa6Wi6.js} +21 -5
  24. package/dist/es/{D5uRw0Em.js → DAj-QM_C.js} +1 -1
  25. package/dist/es/{DcqbdvlW.js → DGEcXOnE.js} +21 -5
  26. package/dist/es/{kE3eGJ-O.js → DU-buYVt.js} +1 -1
  27. package/dist/es/{DhUBPQ6o.js → DxAEO4J0.js} +1 -1
  28. package/dist/es/{CVCUjr3Q.js → dnxo1nL1.js} +1 -1
  29. package/dist/es/{Dxrtj2R8.js → fgcpgo5V.js} +21 -5
  30. package/dist/es/{BAebVbLs.js → qC-GIbc4.js} +20 -4
  31. package/dist/index.cjs +1 -1
  32. package/dist/index.d.ts +173 -9
  33. package/dist/index.js +1 -1
  34. package/package.json +7 -7
  35. package/dist/cjs/6xTfJrmg.cjs +0 -1
  36. package/dist/cjs/B4mujFdj.cjs +0 -1
  37. package/dist/cjs/BIDOBNC3.cjs +0 -1
  38. package/dist/cjs/BlshmoPb.cjs +0 -207
  39. package/dist/cjs/BzMiZszH.cjs +0 -1
  40. package/dist/cjs/D5dT1ruo.cjs +0 -1
  41. package/dist/cjs/DdQV23MS.cjs +0 -1
  42. package/dist/cjs/VJMogId3.cjs +0 -1
  43. package/dist/cjs/eFpF2Osy.cjs +0 -1
  44. package/dist/cjs/kTWMrzTz.cjs +0 -1
  45. package/dist/es/DcGmTG3A.js +0 -4104
@@ -0,0 +1,4787 @@
1
+ import * as r from "react";
2
+ import { createContext as _e, useContext as se, useEffect as R, useState as T, useCallback as D, useMemo as Q, forwardRef as Se, useImperativeHandle as Or, useId as Ct, useRef as B, useLayoutEffect as de, Suspense as Me, lazy as A, Fragment as Tn, Component as Lr, useReducer as Rr, Children as Dr } from "react";
3
+ import Nr, { SendbirdChatOptions as Fr, SendbirdProduct as Br, DeviceOsPlatform as Kt, SendbirdPlatform as Pr, SessionHandler as Ur, ConnectionHandler as Qe, SendbirdError as Hr, LogLevel as wn, ConnectionState as Vr } from "@sendbird/chat";
4
+ import m, { css as _, ThemeProvider as zr, useTheme as _t, createGlobalStyle as Wr, StyleSheetManager as Gr, keyframes as An } from "styled-components";
5
+ import { format as kn, isSameMinute as qt, 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 In 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), b = {
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: b }, i);
43
+ }
44
+ function o({ template: i, children: a }) {
45
+ const { updateTemplate: l } = se(t);
46
+ return R(() => {
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 R(() => {
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}`, Zt = ({ 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 Mn {
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 On = /* @__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))(On || {});
216
+ class Ln {
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 Yt(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: ee
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: b,
272
+ dispatcher: g,
273
+ extensions: x = {
274
+ platform: Pr.JS,
275
+ deviceOSPlatform: co() ? Kt.MOBILE_WEB : Kt.WEB
276
+ }
277
+ }) {
278
+ const [y, E] = T(() => {
279
+ const f = b ?? new Ln(On.WARN), h = g ?? new Mn(f);
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: f,
289
+ dispatcher: h,
290
+ chatSDK: l ?? Yt(e, x, c),
291
+ cache: Zt({ appId: e, aiAgentId: t, storage: n })
292
+ };
293
+ });
294
+ return R(() => {
295
+ E((f) => {
296
+ let h = f.logger, p = f.dispatcher, v = f.chatSDK;
297
+ return b && b !== f.logger && (h = b), g && g !== f.dispatcher && (p = g), l && l !== f.chatSDK ? v = l : !l && f.chatSDK.appId !== e && (v = Yt(e, x, { newInstance: !0, ...c })), {
298
+ ...f,
299
+ appId: e,
300
+ aiAgentId: t,
301
+ keyValueStorage: n,
302
+ language: o,
303
+ countryCode: s,
304
+ context: i,
305
+ queryParams: a,
306
+ logger: h,
307
+ dispatcher: p,
308
+ chatSDK: v,
309
+ cache: Zt({ appId: e, aiAgentId: t, storage: n })
310
+ };
311
+ });
312
+ }, [e, t, o, s, i, b, g, l]), R(() => () => {
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 Rn(e) {
340
+ return e.length === 4 ? `#${[...e.slice(1)].map((t) => t + t).join("")}` : e;
341
+ }
342
+ function Co(e) {
343
+ const t = Rn(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(b, g, x) {
369
+ return x < 0 && (x += 1), x > 1 && (x -= 1), x < 0.16666666666666666 ? b + (g - b) * 6 * x : x < 0.5 ? g : x < 0.6666666666666666 ? b + (g - b) * (0.6666666666666666 - x) * 6 : b;
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)), b = Math.max(0, Math.min(1, l * n)), [g, x, y] = To(a, b, 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 = Rn(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 Jt(e) {
515
+ const t = $o(e), { colors: n, aiAgentColorVariables: o } = Io(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 $o({ 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 Io({ 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: St
572
+ } = W("AIAgentTheme");
573
+ function Ro({ logger: e, palette: t, typography: n, appearance: o, children: s }) {
574
+ const [i, a] = T(
575
+ () => Jt({
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 b = (o == null ? void 0 : o.theme) ?? c, g = u == null ? void 0 : u(b), 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 = Jt({ selectedTheme: b, palette: t, typography: n, ...x });
592
+ a(y), e == null || e.info("theme.update:", b);
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 R(() => {
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 Dn() {
601
+ const { chatSDK: e, logger: t } = ee();
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 } = ee(), 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 Xt {
647
+ }
648
+ const Bo = 24 * 60 * 60 * 1e3, Po = (e) => {
649
+ const { logger: t, cache: n } = ee(), 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 Xt)
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 Q(() => e instanceof Fo ? { type: "manual", userSessionCandidate: s() } : e instanceof Xt ? { 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: b, logger: g, cache: x } = ee(), { connect: y, disconnect: E } = Do(), { type: f, userSessionCandidate: h } = Po(e), p = Dn(), v = D(async () => {
681
+ var Y;
682
+ g.debug("useAuthentication.authenticate: start");
683
+ const M = (h == null ? void 0 : h.userId) && ((Y = x.messenger.getSettings(h.userId)) == null ? void 0 : Y.knownActiveChannelUrl), P = await p({
684
+ aiAgentId: l,
685
+ userId: h == null ? void 0 : h.userId,
686
+ language: c,
687
+ country: b,
688
+ context: u,
689
+ forceCreateChannel: a,
690
+ knownActiveChannelUrl: M
691
+ });
692
+ g.debug("useAuthentication.authenticate: messenger settings response", P);
693
+ let I = null;
694
+ if (P.auto_created_user)
695
+ if (f === "manual")
696
+ g.warn("Received auto created user info but current session is manual. Ignoring auto created user info."), I = { userId: h.userId, authToken: h.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 }), I = { userId: G, authToken: C };
700
+ }
701
+ else
702
+ I = {
703
+ userId: (h == null ? void 0 : h.userId) ?? "",
704
+ authToken: (h == null ? void 0 : h.authToken) ?? ""
705
+ };
706
+ x.messenger.setSettings(I.userId, {
707
+ knownActiveChannelUrl: P.active_channel.channel_url
708
+ });
709
+ try {
710
+ await t(P, I), await y(I, h == null ? void 0 : h.sessionHandler, s), await n(P, I);
711
+ } catch (G) {
712
+ G instanceof Error && (o(G), g.error("useAuthentication.authenticate: failed to connect", G));
713
+ }
714
+ return P;
715
+ }, [
716
+ p,
717
+ y,
718
+ f,
719
+ h == null ? void 0 : h.userId,
720
+ h == null ? void 0 : h.sessionHandler,
721
+ h == null ? void 0 : h.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: h
736
+ };
737
+ }
738
+ const Nn = (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
+ }, Le = (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 Tt({
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, Nn(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, Nn(l)), e);
785
+ }
786
+ const Wo = () => {
787
+ const { chatSDK: e, logger: t, cache: n } = ee(), 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 } = Le(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: b, logger: g } = ee(), { updateTheme: x } = St(), [y, E] = T(void 0), [f, h] = T(
822
+ void 0
823
+ ), [p, v] = T(null), [S, M] = T(null), [P, I] = T(null), [Y, G] = T(
824
+ "handed_off_only"
825
+ /* HANDED_OFF_ONLY */
826
+ ), { shouldSyncCachedTemplate: C, syncCachedTemplates: U } = Wo(), te = Dn(), { authenticate: J, deauthenticate: ke } = Uo({
827
+ userSessionInfo: e,
828
+ forceCreateChannel: t,
829
+ onPreAuth: D(($, N) => {
830
+ const K = $.appearance.selected_theme;
831
+ x(K, (ne) => {
832
+ const Ee = $.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: $.bot.bot_userid,
841
+ profileUrl: $.bot.bot_profile_url,
842
+ nickname: $.bot.bot_nickname,
843
+ replyToFile: $.bot.reply_to_file,
844
+ specialNotice: $.bot.special_notice,
845
+ specialNoticeEnabled: $.bot.is_special_notice_enabled,
846
+ showHandoffButton: $.bot.show_handoff_button ?? !0
847
+ }), I({
848
+ type: $.launcher.image_type || "default_icon",
849
+ imageUrl: $.launcher.image_url
850
+ }), G(
851
+ Go[$.active_channel.attachment_mode] ?? "handed_off_only"
852
+ /* HANDED_OFF_ONLY */
853
+ );
854
+ }, []),
855
+ onPostAuth: D(
856
+ async ($) => {
857
+ C() && await U(), h({ url: $.active_channel.channel_url, status: z.OPEN });
858
+ },
859
+ [C, U]
860
+ ),
861
+ onErrorAuth: D(($) => {
862
+ E($);
863
+ }, []),
864
+ onAuthTokenRefreshed: D(($) => {
865
+ v((N) => N ? { ...N, authToken: $ } : null);
866
+ }, []),
867
+ onPostDeauth: D(() => {
868
+ b.template.clear(), p != null && p.userId && b.messenger.clear(p.userId), h(void 0), v(null), M(null), I(null);
869
+ }, [b.template.clear, p])
870
+ }), ot = D(async () => {
871
+ var $;
872
+ if (p) {
873
+ g.debug("agentMessengerSession.refreshActiveChannel: try to refresh active channel"), h(void 0);
874
+ const N = await te({
875
+ aiAgentId: i,
876
+ userId: p.userId,
877
+ language: l,
878
+ country: c,
879
+ context: u,
880
+ forceCreateChannel: t,
881
+ knownActiveChannelUrl: ($ = b.messenger.getSettings(p.userId)) == null ? void 0 : $.knownActiveChannelUrl
882
+ });
883
+ return b.messenger.setSettings(p.userId, {
884
+ knownActiveChannelUrl: N.active_channel.channel_url
885
+ }), h({ 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
+ p == null ? void 0 : p.userId,
896
+ l,
897
+ c,
898
+ u,
899
+ t,
900
+ b.messenger.getSettings,
901
+ b.messenger.setSettings
902
+ ]), st = D(
903
+ async ($) => {
904
+ if (!(p != null && p.userId))
905
+ throw new Error("Current user is not authenticated. Please authenticate first.");
906
+ const K = (await te({
907
+ ...$,
908
+ userId: p.userId,
909
+ knownActiveChannelUrl: void 0
910
+ })).active_channel.channel_url;
911
+ return b.messenger.setSettings(p.userId, { knownActiveChannelUrl: K }), K;
912
+ },
913
+ [p == null ? void 0 : p.userId, te]
914
+ );
915
+ return et(a, {
916
+ onChannelChanged: ($) => {
917
+ var N;
918
+ $.isGroupChannel() && $.url === (f == null ? void 0 : f.url) && (g.info("agentMessengerSession.channelChanged: channel.conversation", $.conversation), h({ url: $.url, status: ((N = $.conversation) == null ? void 0 : N.status) ?? z.OPEN }));
919
+ }
920
+ }), Or(o, () => {
921
+ const $ = async () => {
922
+ if (!f) throw new Error("No active conversation. Please start a conversation first.");
923
+ return await a.groupChannel.getChannel(f.url);
924
+ };
925
+ return {
926
+ activeChannel: f,
927
+ chatSDK: a,
928
+ authenticate: J,
929
+ deauthenticate: ke,
930
+ updateContext: async (N) => {
931
+ const ne = await (await $()).updateContext(i, N);
932
+ return { ...ne, context: ne.context ?? {} };
933
+ },
934
+ patchContext: async (N) => {
935
+ const ne = await (await $()).patchContext(i, N);
936
+ return { ...ne, context: ne.context ?? {} };
937
+ },
938
+ getContextObject: async () => {
939
+ const K = await (await $()).getContextObject(i);
940
+ return { ...K, context: K.context ?? {} };
941
+ }
942
+ };
943
+ }, [J, ke, f, a, i, g]), /* @__PURE__ */ r.createElement(
944
+ jo,
945
+ {
946
+ value: {
947
+ userSessionInfo: e,
948
+ userSession: p,
949
+ activeChannel: f,
950
+ setActiveChannel: h,
951
+ refreshActiveChannel: ot,
952
+ createConversation: st,
953
+ connectionError: y,
954
+ aiAgentInfo: S,
955
+ launcherInfo: P,
956
+ authenticate: J,
957
+ deauthenticate: ke,
958
+ attachmentMode: Y
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 h;
978
+ const { chatSDK: c, logger: u, dispatcher: b } = ee(), { channel: g, channelFetchError: x, fetchChannel: y } = Jo(t), E = xo(c, g, {
979
+ shouldCountNewMessages: () => !1,
980
+ onChannelDeleted: n,
981
+ onMessagesReceived: (p) => o == null ? void 0 : o(p),
982
+ onMessagesUpdated: (p) => s == null ? void 0 : s(p),
983
+ logger: u
984
+ });
985
+ R(() => {
986
+ const p = 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 b.subscribe(pt.ConversationClose, p), () => {
991
+ b.unsubscribe(pt.ConversationClose, p);
992
+ };
993
+ }, [b, (h = g == null ? void 0 : g.conversation) == null ? void 0 : h.status, i]);
994
+ const f = {
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 (p) => {
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 && (p = await a(p));
1011
+ const v = await E.sendUserMessage(p, l);
1012
+ return l == null || l(v), v;
1013
+ },
1014
+ sendFileMessage: async (p) => {
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 && (p = await a(p));
1019
+ const v = await E.sendFileMessage(p, l);
1020
+ return l == null || l(v), v;
1021
+ }
1022
+ }
1023
+ };
1024
+ return /* @__PURE__ */ r.createElement(Zo, { value: f }, e);
1025
+ }
1026
+ function Jo(e) {
1027
+ const { chatSDK: t, logger: n } = ee(), [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), R(() => {
1039
+ l();
1040
+ }, [t, e]), {
1041
+ channel: o,
1042
+ channelFetchError: i,
1043
+ fetchChannel: l
1044
+ };
1045
+ }
1046
+ function Xo(e) {
1047
+ const { chatSDK: t } = ee(), { activeChannel: n, setActiveChannel: o } = Ko(), s = Ct();
1048
+ R(() => {
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 b = xt(this._pinnedChannels, c);
1143
+ b >= 0 ? (this._pinnedChannels.splice(b, 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 b = es(this._channels, a, this._order).place, g = b === this._channels.length;
1165
+ c ? g ? (n || !this.hasMore) && (this._channels.push(a), s.push(a)) : (this._channels.splice(b, 0, a), s.push(a)) : (this._channels.splice(b, 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, f;
1176
+ const o = new Set(((g = this.filter) == null ? void 0 : g.pinnedChannelUrls) ?? []), s = [], i = [];
1177
+ for (const h of t)
1178
+ o.has(h.url) ? s.push(h) : i.push(h);
1179
+ const a = this._upsertPinnedChannelsToArray(s), l = this._upsertRegularChannelsToArray(i, n), c = a.addedChannels.concat(l.addedChannels), u = a.updatedChannels.concat(l.updatedChannels), b = 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 && ((f = (E = this._collectionEventHandler) == null ? void 0 : E.onChannelsUpdated) == null || f.call(E, {}, u)), b.length > 0 && this._removeChannelsFromView(b);
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 = Qt(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: Qt(e[a], t, n) >= 0 ? a : a + 1, oldPosition: o };
1255
+ }
1256
+ return { place: e.length, oldPosition: -1 };
1257
+ }, Qt = (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, f, h, p, v, S, M, P;
1270
+ const n = Ct(), [o, s] = T(!1), [i, a] = T(null), [l, c] = T([]), [u, b] = T(null), g = B(!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 I = new Qo(e, t);
1276
+ I.setConversationListCollectionHandler({
1277
+ onChannelsAdded: () => {
1278
+ c(I.channels);
1279
+ },
1280
+ onChannelsUpdated: () => {
1281
+ c(I.channels);
1282
+ },
1283
+ onChannelsDeleted: () => {
1284
+ c(I.channels);
1285
+ }
1286
+ }), await I.loadMore(), b(I), a(null);
1287
+ } catch (I) {
1288
+ b(null), a(I);
1289
+ } finally {
1290
+ s(!0), g.current = !1;
1291
+ }
1292
+ }
1293
+ }, [
1294
+ e,
1295
+ (E = t.filter) == null ? void 0 : E.aiAgentChannelFilter,
1296
+ (h = (f = t.filter) == null ? void 0 : f.aiAgentConversationStatusFilter) == null ? void 0 : h.join(),
1297
+ (v = (p = t.filter) == null ? void 0 : p.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 (I) {
1306
+ a(I);
1307
+ }
1308
+ }, [u]);
1309
+ return R(() => (e.addConnectionHandler(n, new Qe({ onConnected: () => x() })), () => e.removeConnectionHandler(n)), [e, n, x]), R(() => {
1310
+ x();
1311
+ }, [x]), R(() => () => {
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 } = ee(), 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 }), b = {
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: b }, 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: Fn
1360
+ } = W("MessageTemplateFetching");
1361
+ function is({ children: e, internalVariables: t }) {
1362
+ const n = B({}), o = B({}), [s, i] = T({}), a = D((u, b) => {
1363
+ i((g) => ({
1364
+ ...g,
1365
+ [u]: { fetching: !1, error: !1, ...g[u], ...b }
1366
+ }));
1367
+ }, []), l = D(
1368
+ async ({
1369
+ onRequestTemplate: u,
1370
+ onGetCachedTemplate: b,
1371
+ templateKey: g,
1372
+ suspense: x = !1
1373
+ }) => {
1374
+ const y = b(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 f = u(g).catch((h) => {
1380
+ throw x || a(g, { error: !0 }), h;
1381
+ }).finally(() => {
1382
+ x || a(g, { fetching: !1 }), delete o.current[g];
1383
+ });
1384
+ return o.current[g] = f, f;
1385
+ },
1386
+ [a]
1387
+ ), c = {
1388
+ internalVariables: t,
1389
+ fetchTemplate: l,
1390
+ suspend: (u, b) => {
1391
+ if (n.current[u])
1392
+ return n.current[u];
1393
+ const g = os(b());
1394
+ return n.current[u] = g, g;
1395
+ },
1396
+ getIsFetching: (u) => {
1397
+ var b;
1398
+ return ((b = s[u]) == null ? void 0 : b.fetching) ?? !1;
1399
+ },
1400
+ getHasError: (u) => {
1401
+ var b;
1402
+ return ((b = s[u]) == null ? void 0 : b.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 ue({ uiTemplateString: e, variables: t = {} }) {
1412
+ const n = Vo(t);
1413
+ return Tt({
1414
+ template: e,
1415
+ variables: n,
1416
+ variableKeyPattern: (o) => nt.VARIABLE(o)
1417
+ });
1418
+ }
1419
+ function me({
1420
+ theme: e,
1421
+ uiTemplateString: t,
1422
+ colorVariables: n = {}
1423
+ }) {
1424
+ return Tt({
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 : Tt({
1441
+ template: t,
1442
+ variables: n,
1443
+ variableKeyPattern: (u) => nt.VIEW_VARIABLE(u),
1444
+ variableValueTransformer: (u) => {
1445
+ const b = u.map(({ key: g, variables: x }) => {
1446
+ const y = i(g), { ui_template: E, color_variables: f } = Le(y);
1447
+ let h = JSON.stringify(E);
1448
+ return h = ue({
1449
+ uiTemplateString: h,
1450
+ variables: s
1451
+ }), h = me({
1452
+ theme: e,
1453
+ uiTemplateString: h,
1454
+ colorVariables: f
1455
+ }), h = me({
1456
+ theme: e,
1457
+ uiTemplateString: h,
1458
+ colorVariables: o
1459
+ }), h = ue({
1460
+ uiTemplateString: h,
1461
+ variables: x
1462
+ }), tt(h);
1463
+ });
1464
+ return JSON.stringify(b);
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: b }) => {
1482
+ const g = await i(u), { ui_template: x, color_variables: y } = Le(g);
1483
+ let E = JSON.stringify(x);
1484
+ return E = ue({
1485
+ uiTemplateString: E,
1486
+ variables: s
1487
+ }), E = me({
1488
+ theme: e,
1489
+ uiTemplateString: E,
1490
+ colorVariables: y
1491
+ }), E = me({
1492
+ theme: e,
1493
+ uiTemplateString: E,
1494
+ colorVariables: o
1495
+ }), E = ue({
1496
+ uiTemplateString: E,
1497
+ variables: b
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 } = Le(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 = ue({ ...o, uiTemplateString: a, variables: n }), a = me({ ...o, uiTemplateString: a, colorVariables: i }), a = me({ ...o, uiTemplateString: a, colorVariables: t }), a = ue({ ...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 } = Le(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 = ue({ ...o, uiTemplateString: a, variables: n }), a = me({ ...o, uiTemplateString: a, colorVariables: i }), a = me({ ...o, uiTemplateString: a, colorVariables: t }), a = ue({ ...o, uiTemplateString: a }), tt(a);
1537
+ }, us = (e) => {
1538
+ const { aiAgentColorVariables: t = {} } = e, { internalVariables: n } = Fn();
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 } = Fn();
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 Bn(e) {
1682
+ return xs[e.type] || Es;
1683
+ }
1684
+ function en(e) {
1685
+ return Bn(e).getValueOrDefault(e);
1686
+ }
1687
+ function vs(e, t, n = {}) {
1688
+ const o = { ...hs, ...n };
1689
+ return Bn(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 f = {};
1694
+ return e.fields.forEach((h) => {
1695
+ f[h.key] = en(h);
1696
+ }), f;
1697
+ }), u = Q(() => e.submitted_at ? "submitted" : e.canceled_at ? "canceled" : "draft", [e.submitted_at, e.canceled_at]);
1698
+ R(() => {
1699
+ if (u === "submitted" || u === "canceled") {
1700
+ const f = {};
1701
+ let h = !1;
1702
+ e.fields.forEach((p) => {
1703
+ const v = en(p);
1704
+ JSON.stringify(l[p.key]) !== JSON.stringify(v) && (h = !0), f[p.key] = v;
1705
+ }), h && c(f);
1706
+ }
1707
+ }, [u]);
1708
+ const b = (f, h) => {
1709
+ c((p) => ({ ...p, [f]: h })), a((p) => ({ ...p, [f]: void 0 }));
1710
+ }, g = e.fields.map((f) => {
1711
+ var v, S, M;
1712
+ const h = l[f.key] ?? null, p = {
1713
+ key: f.key,
1714
+ label: f.label,
1715
+ error: i[f.key],
1716
+ required: f.required
1717
+ };
1718
+ return f.type === "text" ? {
1719
+ ...p,
1720
+ type: "text",
1721
+ layout: f.layout,
1722
+ value: h,
1723
+ ...f.placeholder && { placeholder: f.placeholder },
1724
+ ...((v = f.rules) == null ? void 0 : v.max_length) && { maxLength: f.rules.max_length }
1725
+ } : f.type === "number" ? {
1726
+ ...p,
1727
+ type: "number",
1728
+ layout: f.layout,
1729
+ value: h,
1730
+ ...f.placeholder && { placeholder: f.placeholder },
1731
+ ...((S = f.rules) == null ? void 0 : S.max) && { max: f.rules.max }
1732
+ } : f.type === "single-select" ? {
1733
+ ...p,
1734
+ type: "single-select",
1735
+ layout: f.layout,
1736
+ value: h,
1737
+ options: f.options
1738
+ } : f.type === "multi-select" ? {
1739
+ ...p,
1740
+ type: "multi-select",
1741
+ layout: f.layout,
1742
+ value: h,
1743
+ options: f.options,
1744
+ ...((M = f.rules) == null ? void 0 : M.max_select) && { maxSelect: f.rules.max_select }
1745
+ } : { ...p, type: "unknown", layout: "default", value: null };
1746
+ });
1747
+ return {
1748
+ state: u,
1749
+ fields: g,
1750
+ getField: (f) => g.find((h) => h.key === f),
1751
+ updateFieldValue: b,
1752
+ submit: async () => {
1753
+ const f = {};
1754
+ let h = !1;
1755
+ for (const p of e.fields) {
1756
+ const v = l[p.key] ?? null, S = vs(p, v, n);
1757
+ S.isValid || (f[p.key] = S.error, h = !0);
1758
+ }
1759
+ if (a(f), !h && o) {
1760
+ const p = {};
1761
+ e.fields.forEach((v) => {
1762
+ p[v.key] = l[v.key] ?? null;
1763
+ }), await o(p);
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}', Re = "en", _s = /* @__PURE__ */ new Set([
1771
+ Re,
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
+ }, wt = { language: "en", dateLocale: Ts, stringSet: ws }, As = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1863
+ __proto__: null,
1864
+ default: wt
1865
+ }, Symbol.toStringTag, { value: "Module" })), Ze = /* @__PURE__ */ new Map([[Re, wt]]);
1866
+ async function ks(e) {
1867
+ if (Ze.has(e))
1868
+ return Ze.get(e);
1869
+ const t = _s.has(e) ? e : Re;
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 wt;
1875
+ }
1876
+ }
1877
+ const {
1878
+ Provider: $s,
1879
+ useContext: L
1880
+ } = W("Localization");
1881
+ function Is(e) {
1882
+ var t;
1883
+ return ((t = e.split("-")) == null ? void 0 : t[0]) ?? Re;
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(Re));
1892
+ return R(() => {
1893
+ const a = Is(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
+ $s,
1897
+ {
1898
+ value: {
1899
+ language: s.language,
1900
+ stringSet: { ...s.stringSet, ...n },
1901
+ dateLocale: s.dateLocale,
1902
+ format: (a, l, c) => kn(a, l, { locale: s.dateLocale, ...c })
1903
+ }
1904
+ },
1905
+ o
1906
+ );
1907
+ }
1908
+ const Ye = "data-sb-agent-theme", tn = (e) => (t, ...n) => {
1909
+ let o = "";
1910
+ return t.forEach((s, i) => {
1911
+ o += s + (n[i] ?? "");
1912
+ }), `[${Ye}='${e}'] & { ${o} }`;
1913
+ }, k = {
1914
+ light: tn("light"),
1915
+ dark: tn("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: Pn
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 } = St();
2027
+ return de(() => {
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
+ R(() => {
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
+ R(() => {
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
+ }, At = /iPad|iPhone|iPod/.test(navigator.userAgent), Ps = /Android/.test(navigator.userAgent), De = (e) => At || Ps, {
2052
+ Provider: Us,
2053
+ Consumer: Un,
2054
+ useContext: V
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), b = {
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: b,
2077
+ enableCloseConversationButton: n,
2078
+ enableExpandButton: o,
2079
+ enableAutoDisconnectInLauncher: s
2080
+ }
2081
+ },
2082
+ e
2083
+ ));
2084
+ }
2085
+ const {
2086
+ Provider: Vs,
2087
+ useContext: H
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 } = V(), { userSessionInfo: c, authenticate: u, setActiveChannel: b, userSession: g, aiAgentInfo: x, launcherInfo: y } = t;
2092
+ return et(n, {
2093
+ async onUserJoined(E, f) {
2094
+ var p, v;
2095
+ if (E.conversation && E.conversation.type === Zr.PROACTIVE && f.userId === ((p = n.currentUser) == null ? void 0 : p.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
+ b({ url: E.url, status: S }), l.setOpened(!0), Gs({ sound: document.hidden || !l.opened });
2099
+ }
2100
+ }
2101
+ }), R(() => {
2102
+ u().then(({ launcher: E }) => {
2103
+ E.auto_open && !De() && 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 }), nn = /* @__PURE__ */ new WeakMap(), js = (e, t) => {
2138
+ let n = nn.get(t);
2139
+ n || (n = /* @__PURE__ */ new Map(), nn.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;font-style: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
+ }, Hn = {
2158
+ DEFAULT_PRIMARY: "#742ddd",
2159
+ WHITE: "#ffffff"
2160
+ }, Vn = 36, qs = 100, Zs = 25 * 1024 * 1024, zn = ["application/pdf", "image/jpeg", "image/jpg", "image/png"], kt = "noopener noreferrer nofollow", be = 244, Wn = 640, Je = 26, Gn = 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 It(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 jn(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
+ }, O = ({ type: e, size: t = 24, className: n, color: o }) => {
2222
+ const s = Qs[e];
2223
+ return /* @__PURE__ */ r.createElement(
2224
+ ti,
2225
+ {
2226
+ className: n,
2227
+ $rtlFlip: Xs.has(e),
2228
+ $size: t,
2229
+ $color: o ?? d.color.primary.main
2230
+ },
2231
+ /* @__PURE__ */ r.createElement(Me, { fallback: null }, /* @__PURE__ */ r.createElement(s, null))
2232
+ );
2233
+ }, 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};`;
2234
+ function Mt({
2235
+ name: e,
2236
+ type: t = "FILE",
2237
+ iconColor: n,
2238
+ iconBackgroundColor: o,
2239
+ onClick: s
2240
+ }) {
2241
+ const { colors: i } = _t();
2242
+ 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)));
2243
+ }
2244
+ 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;`;
2245
+ function ai({ file: e, children: t, onClickFile: n }) {
2246
+ return /* @__PURE__ */ r.createElement(li, null, /* @__PURE__ */ r.createElement(
2247
+ Mt,
2248
+ {
2249
+ name: e.name,
2250
+ type: It(e.name, e.type),
2251
+ onClick: n && (() => n == null ? void 0 : n(e))
2252
+ }
2253
+ ), t);
2254
+ }
2255
+ const li = m.div`display:flex;flex-direction:column;align-items:flex-start;gap:${Ae}px;`;
2256
+ function ci({ file: e, onClickMedia: t, children: n }) {
2257
+ 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;
2258
+ if (o) {
2259
+ const s = {
2260
+ id: `${le}-media-body`,
2261
+ onClick: () => t == null ? void 0 : t(e)
2262
+ };
2263
+ return /* @__PURE__ */ r.createElement(di, null, /* @__PURE__ */ r.createElement(ui, { ...s }, o()), n);
2264
+ }
2265
+ return null;
2266
+ }
2267
+ 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;${k.light`
2268
+ background-color: ${d.color.background100};
2269
+ `}
2270
+ ${k.dark`
2271
+ background-color: ${d.color.background400};
2272
+ `}
2273
+ `, mi = m.img`width:100%;height:100%;object-fit:cover;`, hi = m.video`width:100%;height:100%;object-fit:cover;`, gi = "✱";
2274
+ function Kn(e) {
2275
+ const t = new RegExp(`${gi}+`, "g");
2276
+ return e.replace(t, (n) => `<span id=${Js} aria-label="masked-text">${n}</span>`);
2277
+ }
2278
+ function pi(e) {
2279
+ return e.replace(/\*\*(.*?)\*\*/g, "<b>$1</b>");
2280
+ }
2281
+ function fi(e) {
2282
+ const t = /```(\w+)?\n([\s\S]*?)```/g, n = [];
2283
+ let o = 0;
2284
+ return e.replace(t, (s, ...i) => {
2285
+ const [a, l, c] = i;
2286
+ return o < c && n.push({
2287
+ type: "text",
2288
+ value: e.slice(o, c).trim()
2289
+ }), n.push({
2290
+ type: "code",
2291
+ value: l.trim(),
2292
+ language: a ? a.trim() : "plaintext"
2293
+ }), o = c + s.length, s;
2294
+ }), o < e.length && n.push({
2295
+ type: "text",
2296
+ value: e.slice(o).trim()
2297
+ }), n.map((s) => s.type !== "text" ? s : { ...s, value: Kn(s.value) });
2298
+ }
2299
+ const bi = A(async () => ({ default: (await import("./DAj-QM_C.js")).MarkdownText })), xi = A(async () => ({ default: (await import("./Ch_6OPTz.js")).CodeBlock }));
2300
+ function rn(e) {
2301
+ var s, i;
2302
+ const t = e.maxBodyWidth ?? be, n = Q(() => fi(e.message), [e.message]), o = {
2303
+ id: `${le}-text-body`,
2304
+ $maxWidth: t,
2305
+ $color: (s = e.customStyle) == null ? void 0 : s.bubbleContentColor,
2306
+ $bgColor: (i = e.customStyle) == null ? void 0 : i.bubbleBackgroundColor
2307
+ };
2308
+ return n.length === 0 ? e.children ? /* @__PURE__ */ r.createElement(on, { ...o }, e.children) : null : /* @__PURE__ */ r.createElement(on, { ...o }, n.map((a, l) => a.type === "text" ? /* @__PURE__ */ r.createElement(sn, { key: l, variant: "body3" }, /* @__PURE__ */ r.createElement(Me, { fallback: a.value }, /* @__PURE__ */ r.createElement(bi, { onClickImage: (c) => {
2309
+ var u;
2310
+ return (u = e.onClickMedia) == null ? void 0 : u.call(e, { url: c, type: "image/*" });
2311
+ } }, a.value))) : a.type === "code" ? /* @__PURE__ */ r.createElement(Me, { key: l, fallback: /* @__PURE__ */ r.createElement(sn, { variant: "body3" }, a.value) }, /* @__PURE__ */ r.createElement(xi, { code: a.value, language: a.language })) : null), e.children);
2312
+ }
2313
+ const on = m.div`display:flex;flex-direction:column;border-radius:12px;overflow:hidden;max-width:${({ $maxWidth: e }) => e}px;${({ theme: e, $color: t, $bgColor: n }) => _`
2314
+ color: ${t || e.colors.messageIncoming.text};
2315
+ background-color: ${n || e.colors.messageIncoming.background};
2316
+ `}
2317
+ padding: 12px 0;
2318
+ transition: max-width 0.3s;
2319
+ overflow-wrap: break-word;
2320
+ `, sn = m(w)`align-items:flex-start;line-height:140%;white-space:pre-wrap;padding:0 12px;`;
2321
+ function Ei(e) {
2322
+ const { stringSet: t } = L(), n = jn(e) ? /* @__PURE__ */ r.createElement(rn, { ...e }) : null;
2323
+ if (e.messageType === "user")
2324
+ return n;
2325
+ if (e.messageType === "file") {
2326
+ const o = e.file;
2327
+ return o.type.startsWith("image") || o.type.startsWith("video") ? /* @__PURE__ */ r.createElement(ci, { ...e }, n) : /* @__PURE__ */ r.createElement(ai, { ...e }, n);
2328
+ }
2329
+ return /* @__PURE__ */ r.createElement(rn, { ...e, message: t.UNKNOWN__UNKNOWN_MESSAGE_TYPE });
2330
+ }
2331
+ const Ot = (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" }));
2332
+ function Lt({ id: e, src: t, size: n = 56, onClick: o, style: s }) {
2333
+ 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 }));
2334
+ }
2335
+ 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;`;
2336
+ function Ci({ sender: e, isBotMessage: t }) {
2337
+ const n = `${le}-sender-avatar`;
2338
+ return !e.profileUrl && t ? /* @__PURE__ */ r.createElement(_i, { id: n }, /* @__PURE__ */ r.createElement(Ot, null)) : /* @__PURE__ */ r.createElement(Lt, { id: n, size: Je, src: e.profileUrl });
2339
+ }
2340
+ 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};}}`;
2341
+ function Si({ sender: e }) {
2342
+ return /* @__PURE__ */ r.createElement(Ti, { id: `${le}-sender-name`, variant: "caption1", color: d.themedColor.textMidEmphasis }, e.nickname);
2343
+ }
2344
+ 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;`;
2345
+ function wi({ createdAt: e }) {
2346
+ const { stringSet: t, format: n } = L();
2347
+ return e ? /* @__PURE__ */ r.createElement(w, { id: `${le}-sent-time`, variant: "caption4", color: d.themedColor.textLowEmphasis }, n(e, t.DATE_FORMAT__MESSAGE_TIMESTAMP)) : null;
2348
+ }
2349
+ function Ai({ customStyle: e }) {
2350
+ return /* @__PURE__ */ r.createElement(ki, { $bgColor: e == null ? void 0 : e.bubbleBackgroundColor }, [0, 1, 2].map((t) => /* @__PURE__ */ r.createElement($i, { key: t, $color: e == null ? void 0 : e.bubbleContentColor })));
2351
+ }
2352
+ 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};`, $i = 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;}`;
2353
+ function Oe() {
2354
+ }
2355
+ async function Rt(e) {
2356
+ let t = e;
2357
+ t && (!t.startsWith("http://") && !t.startsWith("https://") && (t = "https://" + t), window.open(t, "_blank", "noopener,noreferrer"));
2358
+ }
2359
+ function Dt(e) {
2360
+ return !e || !e.conversation ? !1 : e.conversation.status === z.CLOSED;
2361
+ }
2362
+ function qn(e) {
2363
+ return !e || !e.conversation ? !1 : e.conversation.status === z.OPEN;
2364
+ }
2365
+ function Nt(e) {
2366
+ var n;
2367
+ const t = (n = e == null ? void 0 : e.conversation) == null ? void 0 : n.handoff;
2368
+ return !!(t != null && t.timestamp);
2369
+ }
2370
+ function Ii(e) {
2371
+ return qn(e) && !Nt(e);
2372
+ }
2373
+ function Mi({
2374
+ extendedMessagePayload: e,
2375
+ onClickCTA: t = ({ url: n }) => Rt(n)
2376
+ }) {
2377
+ const n = e == null ? void 0 : e.cta_button;
2378
+ 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;
2379
+ }
2380
+ 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};${k.dark`
2381
+ background-color: ${d.color.ondark.textDisabled};
2382
+ `}
2383
+ `, Li = m(w)`overflow:hidden;text-overflow:ellipsis;white-space:nowrap;`;
2384
+ function Ri({
2385
+ extendedMessagePayload: e,
2386
+ onClickCitation: t = (n) => Rt(n.link)
2387
+ }) {
2388
+ const { stringSet: n } = L(), { theme: o } = St(), s = e == null ? void 0 : e.citations;
2389
+ 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(
2390
+ Pi,
2391
+ {
2392
+ key: `${i.embedding_id}-${a}`,
2393
+ role: "button",
2394
+ onClick: () => t(i)
2395
+ },
2396
+ /* @__PURE__ */ r.createElement(O, { type: "source", size: 16, color: o.colors.messageIncoming.text }),
2397
+ /* @__PURE__ */ r.createElement(Bi, { variant: "body3", color: o.colors.messageIncoming.text }, i.title)
2398
+ ))));
2399
+ }
2400
+ 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;}`, Zn = ({ rootElementId: e, visible: t, onClose: n, children: o }) => {
2401
+ if (!t) return null;
2402
+ const { rootElement: s } = Pn(), i = fe(s), a = fe(s, !0);
2403
+ return eo(
2404
+ /* @__PURE__ */ r.createElement(Ui, { onClick: n }, /* @__PURE__ */ r.createElement(Hi, { onClick: (l) => l.stopPropagation() }, o)),
2405
+ i.getElementById(e) ?? i.getElementById(ie.MODAL_ROOT) ?? a.body
2406
+ );
2407
+ }, 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};`, Yn = ({ visible: e, title: t, description: n, confirmText: o = "OK", onConfirm: s, onClose: i }) => {
2408
+ const a = () => {
2409
+ s == null || s(), i();
2410
+ };
2411
+ return /* @__PURE__ */ r.createElement(Zn, { 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)))));
2412
+ }, 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;`, Ft = _`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;}`, an = m.button`${Ft};background-color:${d.themedColor.primary};color:${d.themedColor.textHighEmphasis};&:hover:not(:disabled){opacity:0.9;}`, Ki = m.button`${Ft};color:${d.themedColor.primary};${k.light`
2413
+ background-color: ${d.color.background50};
2414
+ `};
2415
+ ${k.dark`
2416
+ background-color: ${d.color.background700};
2417
+ `};
2418
+
2419
+ &:hover:not(:disabled) {
2420
+ opacity: 0.9;
2421
+ }
2422
+ `, qi = m.button`${Ft};background-color:transparent;color:${d.themedColor.textHighEmphasis};&:hover:not(:disabled){opacity:0.7;}`, Zi = (e) => {
2423
+ switch (e) {
2424
+ case "primary":
2425
+ return an;
2426
+ case "secondary":
2427
+ return Ki;
2428
+ case "clear":
2429
+ return qi;
2430
+ default:
2431
+ return an;
2432
+ }
2433
+ }, 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 = ({
2434
+ children: e,
2435
+ onClick: t,
2436
+ variant: n = "primary",
2437
+ disabled: o = !1,
2438
+ loading: s = !1,
2439
+ className: i
2440
+ }) => {
2441
+ const a = () => {
2442
+ switch (n) {
2443
+ case "primary":
2444
+ return d.themedColor.textHighEmphasisInverse;
2445
+ case "secondary":
2446
+ return d.themedColor.primary;
2447
+ case "clear":
2448
+ return d.themedColor.textHighEmphasis;
2449
+ default:
2450
+ return d.themedColor.textHighEmphasisInverse;
2451
+ }
2452
+ }, l = Zi(n);
2453
+ 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));
2454
+ }, 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 }) => {
2455
+ const { stringSet: s } = L();
2456
+ 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})`));
2457
+ }, ea = ({
2458
+ value: e,
2459
+ onChange: t,
2460
+ placeholder: n,
2461
+ error: o = !1,
2462
+ submitted: s = !1,
2463
+ className: i,
2464
+ disabled: a = !1,
2465
+ max: l
2466
+ }) => {
2467
+ const c = (b) => {
2468
+ const x = b.target.value.replace(/[^0-9.-]/g, ""), y = x.split("."), f = y.length > 1 ? y[0] + "." + y.slice(1).join("").replace(/\./g, "") : x;
2469
+ if (b.target.value = f, f === "" || f === "-")
2470
+ t == null || t(null);
2471
+ else {
2472
+ const h = Number(f);
2473
+ if (!isNaN(h)) {
2474
+ if (l !== void 0 && h > l)
2475
+ return;
2476
+ t == null || t(h);
2477
+ }
2478
+ }
2479
+ }, u = e == null ? "" : String(e);
2480
+ return /* @__PURE__ */ r.createElement(
2481
+ sa,
2482
+ {
2483
+ type: "text",
2484
+ value: u,
2485
+ onChange: c,
2486
+ placeholder: n,
2487
+ className: i,
2488
+ disabled: a || s,
2489
+ inputMode: "decimal",
2490
+ $error: o,
2491
+ $submitted: s
2492
+ }
2493
+ );
2494
+ }, 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;${k.light`
2495
+ background-color: ${d.color.ondark.textMidEmphasis};
2496
+ `}
2497
+ ${k.dark`
2498
+ background-color: ${d.color.onlight.textLowEmphasis};
2499
+ `}
2500
+
2501
+ &::placeholder {
2502
+ color: ${d.themedColor.textLowEmphasis};
2503
+ }
2504
+ `, ra = _`border:1px solid ${d.themedColor.error};color:${d.themedColor.textHighEmphasis};${k.light`
2505
+ background-color: ${d.color.background50};
2506
+ `}
2507
+ ${k.dark`
2508
+ background-color: ${d.color.onlight.textLowEmphasis};
2509
+ `}
2510
+ `, oa = _`border:1px solid ${d.themedColor.textDisabled};color:${d.themedColor.textHighEmphasis};${k.light`
2511
+ background-color: ${d.color.background50};
2512
+ `}
2513
+ ${k.dark`
2514
+ background-color: ${d.color.onlight.textLowEmphasis};
2515
+ `}
2516
+
2517
+ &:focus {
2518
+ border-color: ${d.themedColor.primary};
2519
+ }
2520
+ `, sa = m.input`${ta}${({ $error: e, $submitted: t }) => t ? na : e ? ra : oa}`, ia = (e) => {
2521
+ if (e.multiple) {
2522
+ const { value: t = [], onChange: n, maxSelect: o, submitted: s = !1 } = e;
2523
+ return {
2524
+ selectedValues: t,
2525
+ handleOptionClick: (a) => {
2526
+ if (s) return;
2527
+ if (t.includes(a)) {
2528
+ const c = t.filter((u) => u !== a);
2529
+ n == null || n(c);
2530
+ } else {
2531
+ if (o && t.length >= o)
2532
+ return;
2533
+ const c = [...t, a];
2534
+ n == null || n(c);
2535
+ }
2536
+ }
2537
+ };
2538
+ } else {
2539
+ const { value: t, onChange: n, submitted: o = !1 } = e;
2540
+ return {
2541
+ selectedValues: t ? [t] : [],
2542
+ handleOptionClick: (i) => {
2543
+ if (o) return;
2544
+ const a = t === i ? "" : i;
2545
+ n == null || n(a);
2546
+ }
2547
+ };
2548
+ }
2549
+ }, Jn = (e) => {
2550
+ const { options: t, submitted: n = !1, error: o = !1, className: s } = e, { selectedValues: i, handleOptionClick: a } = ia(e);
2551
+ return /* @__PURE__ */ r.createElement(la, { className: s }, t.map((l) => {
2552
+ const c = i.includes(l.value);
2553
+ return /* @__PURE__ */ r.createElement(
2554
+ pa,
2555
+ {
2556
+ key: l.value,
2557
+ $active: c,
2558
+ $submitted: n,
2559
+ $error: o,
2560
+ onClick: () => a(l.value)
2561
+ },
2562
+ /* @__PURE__ */ r.createElement(w, { variant: "caption1", color: aa(c, n) }, l.label)
2563
+ );
2564
+ }));
2565
+ }, 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};${k.dark`
2566
+ background-color: transparent;
2567
+ border: 1px solid white;
2568
+ color: white;
2569
+ `}
2570
+ `, ua = _`cursor:default;${k.light`
2571
+ background-color: ${d.color.ondark.textMidEmphasis};
2572
+ color: ${d.themedColor.textDisabled};
2573
+ `}
2574
+ ${k.dark`
2575
+ background-color: ${d.color.onlight.textLowEmphasis};
2576
+ border: 1px solid ${d.color.onlight.textLowEmphasis};
2577
+ color: ${d.themedColor.textDisabled};
2578
+ `}
2579
+ `, ma = _`cursor:pointer;border:1px solid ${d.themedColor.primary};${k.light`
2580
+ background-color: ${d.color.background50};
2581
+ color: ${d.themedColor.primary};
2582
+ `}
2583
+ ${k.dark`
2584
+ background-color: ${d.color.onlight.textLowEmphasis};
2585
+ color: ${d.themedColor.primary};
2586
+ `}
2587
+ `, ha = _`cursor:pointer;border:1px solid ${d.themedColor.textDisabled};${k.light`
2588
+ background-color: ${d.color.background50};
2589
+ color: ${d.themedColor.textMidEmphasis};
2590
+ `}
2591
+ ${k.dark`
2592
+ background-color: ${d.color.onlight.textLowEmphasis};
2593
+ color: ${d.themedColor.textMidEmphasis};
2594
+ `}
2595
+ `, ga = _`border-color:${d.themedColor.error}!important;`, pa = m.div`${ca}${({ $active: e, $submitted: t, $error: n }) => {
2596
+ if (t)
2597
+ return e ? da : ua;
2598
+ const o = e ? ma : ha;
2599
+ return n ? _`
2600
+ ${o} ${ga}
2601
+ ` : o;
2602
+ }}
2603
+ `, fa = (e) => /* @__PURE__ */ r.createElement(Jn, { ...e, multiple: !1 }), ba = (e) => /* @__PURE__ */ r.createElement(Jn, { ...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 = ({
2604
+ value: e = "",
2605
+ onChange: t,
2606
+ placeholder: n,
2607
+ variant: o = "single-line",
2608
+ error: s = !1,
2609
+ submitted: i = !1,
2610
+ className: a,
2611
+ disabled: l = !1,
2612
+ maxLength: c
2613
+ }) => {
2614
+ const b = {
2615
+ value: e,
2616
+ onChange: (g) => {
2617
+ const x = g.target.value;
2618
+ c && x.length > c || t == null || t(x);
2619
+ },
2620
+ placeholder: n,
2621
+ className: a,
2622
+ disabled: l || i,
2623
+ maxLength: c,
2624
+ $error: s,
2625
+ $submitted: i
2626
+ };
2627
+ return o === "multi-line" ? /* @__PURE__ */ r.createElement(Ca, { ...b, as: "textarea" }) : /* @__PURE__ */ r.createElement(ya, { ...b });
2628
+ }, Xn = _`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};}`, Qn = _`color:${d.themedColor.textHighEmphasis};border:1px solid transparent;cursor:not-allowed;${k.light`
2629
+ background-color: ${d.color.ondark.textMidEmphasis};
2630
+ `}
2631
+ ${k.dark`
2632
+ background-color: ${d.color.onlight.textLowEmphasis};
2633
+ `}
2634
+
2635
+ &::placeholder {
2636
+ color: ${d.themedColor.textLowEmphasis};
2637
+ }
2638
+ `, er = _`border:1px solid ${d.themedColor.error};color:${d.themedColor.textHighEmphasis};${k.light`
2639
+ background-color: ${d.color.background50};
2640
+ `}
2641
+ ${k.dark`
2642
+ background-color: ${d.color.onlight.textLowEmphasis};
2643
+ `}
2644
+ `, tr = _`border:1px solid ${d.themedColor.textDisabled};color:${d.themedColor.textHighEmphasis};${k.light`
2645
+ background-color: ${d.color.background50};
2646
+ `}
2647
+ ${k.dark`
2648
+ background-color: ${d.color.onlight.textLowEmphasis};
2649
+ `}
2650
+
2651
+ &:focus {
2652
+ border-color: ${d.themedColor.primary};
2653
+ }
2654
+ `, ya = m.input`${Xn}height:36px;${({ $error: e, $submitted: t }) => t ? Qn : e ? er : tr}`, Ca = m.textarea`${Xn}height:96px;resize:vertical;font-family:inherit;${({ $error: e, $submitted: t }) => t ? Qn : e ? er : tr}`, _a = ({ children: e, className: t, style: n }) => /* @__PURE__ */ r.createElement(w, { variant: "button", color: d.themedColor.textHighEmphasis, className: t, style: n }, e), q = {
2655
+ Title: _a,
2656
+ Label: Qi,
2657
+ ErrorLabel: Xi,
2658
+ Separator: Ea,
2659
+ Button: Ji,
2660
+ TextInput: va,
2661
+ NumberInput: ea,
2662
+ SingleSelect: fa,
2663
+ MultiSelect: ba
2664
+ }, Sa = 1, Ta = /* @__PURE__ */ new Set(["text", "number", "single-select", "multi-select"]), wa = (e) => {
2665
+ var h;
2666
+ const t = (h = e.extendedMessagePayload) == null ? void 0 : h.form;
2667
+ if (!t) throw new Error("Form is not provided");
2668
+ const { stringSet: n } = L(), [o, s] = T({ submitting: !1, canceling: !1 }), [i, a] = T({
2669
+ visible: !1
2670
+ }), { state: l, fields: c, submit: u, cancel: b, updateFieldValue: g } = ys(t, {
2671
+ labels: {
2672
+ required: n.FORM_VALIDATION_REQUIRED,
2673
+ regex: n.FORM_VALIDATION_REGEX_FAILED,
2674
+ minLength: n.FORM_VALIDATION_MIN_LENGTH,
2675
+ maxLength: n.FORM_VALIDATION_MAX_LENGTH,
2676
+ min: n.FORM_VALIDATION_MIN,
2677
+ max: n.FORM_VALIDATION_MAX,
2678
+ minSelect: n.FORM_VALIDATION_MIN_SELECT,
2679
+ maxSelect: n.FORM_VALIDATION_MAX_SELECT
2680
+ },
2681
+ onSubmit: (p) => {
2682
+ var v;
2683
+ return (v = e.onSubmitForm) == null ? void 0 : v.call(e, { key: t.key, data: p });
2684
+ },
2685
+ onCancel: () => {
2686
+ var p;
2687
+ return (p = e.onCancelForm) == null ? void 0 : p.call(e, { key: t.key });
2688
+ }
2689
+ }), x = l === "submitted", y = async () => {
2690
+ s((p) => ({ ...p, submitting: !0 }));
2691
+ try {
2692
+ await u();
2693
+ } catch (p) {
2694
+ a({
2695
+ visible: !0,
2696
+ description: p instanceof Error ? p.message : n.TRY_AGAIN
2697
+ });
2698
+ } finally {
2699
+ s((p) => ({ ...p, submitting: !1 }));
2700
+ }
2701
+ }, E = async () => {
2702
+ s((p) => ({ ...p, canceling: !0 }));
2703
+ try {
2704
+ await b();
2705
+ } catch (p) {
2706
+ a({
2707
+ visible: !0,
2708
+ description: p instanceof Error ? p.message : n.TRY_AGAIN
2709
+ });
2710
+ } finally {
2711
+ s((p) => ({ ...p, canceling: !1 }));
2712
+ }
2713
+ }, f = Q(() => {
2714
+ const p = () => t.version > Sa, v = () => t.fields.some((S) => !Ta.has(S.type));
2715
+ return p() || 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: "" };
2716
+ }, [t.version, t.fields, l, e.isHandedOff, e.isConversationClosed]);
2717
+ return l === "canceled" ? null : f.visible ? /* @__PURE__ */ r.createElement(Tn, null, /* @__PURE__ */ r.createElement(ln, { $maxWidth: e.maxBodyWidth ?? be }, /* @__PURE__ */ r.createElement(q.Title, null, t.title), /* @__PURE__ */ r.createElement(Aa, null, c.map((p) => /* @__PURE__ */ r.createElement(ka, { key: p.key }, /* @__PURE__ */ r.createElement(q.Label, { style: { marginBottom: "6px" }, required: p.required }, p.label), p.type === "text" && /* @__PURE__ */ r.createElement(
2718
+ q.TextInput,
2719
+ {
2720
+ value: p.value || "",
2721
+ placeholder: p.placeholder,
2722
+ onChange: (v) => g(p.key, v),
2723
+ disabled: x,
2724
+ error: !!p.error,
2725
+ submitted: x,
2726
+ variant: p.layout === "multiline" ? "multi-line" : "single-line",
2727
+ maxLength: p.maxLength
2728
+ }
2729
+ ), p.type === "number" && /* @__PURE__ */ r.createElement(
2730
+ q.NumberInput,
2731
+ {
2732
+ value: p.value || null,
2733
+ placeholder: p.placeholder,
2734
+ onChange: (v) => g(p.key, v),
2735
+ disabled: x,
2736
+ error: !!p.error,
2737
+ submitted: x,
2738
+ max: p.max
2739
+ }
2740
+ ), p.type === "single-select" && /* @__PURE__ */ r.createElement(
2741
+ q.SingleSelect,
2742
+ {
2743
+ options: p.options.map((v) => ({ label: v, value: v })),
2744
+ value: p.value || "",
2745
+ onChange: (v) => g(p.key, v),
2746
+ submitted: x
2747
+ }
2748
+ ), p.type === "multi-select" && /* @__PURE__ */ r.createElement(
2749
+ q.MultiSelect,
2750
+ {
2751
+ options: p.options.map((v) => ({ label: v, value: v })),
2752
+ value: p.value || [],
2753
+ onChange: (v) => g(p.key, v),
2754
+ submitted: x,
2755
+ maxSelect: p.maxSelect
2756
+ }
2757
+ ), p.error && /* @__PURE__ */ r.createElement(q.ErrorLabel, { style: { marginTop: "4px" } }, p.error)))), /* @__PURE__ */ r.createElement(q.Separator, null), /* @__PURE__ */ r.createElement($a, null, /* @__PURE__ */ r.createElement(
2758
+ q.Button,
2759
+ {
2760
+ variant: x ? "clear" : "primary",
2761
+ onClick: y,
2762
+ disabled: x || o.canceling,
2763
+ loading: o.submitting
2764
+ },
2765
+ x ? n.SUBMITTED : n.BUTTON__SUBMIT
2766
+ ), l !== "submitted" && /* @__PURE__ */ r.createElement(
2767
+ q.Button,
2768
+ {
2769
+ variant: "secondary",
2770
+ onClick: E,
2771
+ disabled: o.submitting,
2772
+ loading: o.canceling
2773
+ },
2774
+ n.BUTTON__CANCEL
2775
+ ))), /* @__PURE__ */ r.createElement(Yn, { ...i, onClose: () => a({ visible: !1, title: "" }) })) : /* @__PURE__ */ r.createElement(ln, { $maxWidth: e.maxBodyWidth ?? be }, /* @__PURE__ */ r.createElement(w, { variant: "body3" }, f.reason), f.cancelable && /* @__PURE__ */ r.createElement(q.Button, { variant: "primary", onClick: E, loading: o.canceling }, n.BUTTON__CANCEL));
2776
+ }, ln = m.div`display:flex;flex-direction:column;gap:12px;border-radius:12px;overflow:hidden;max-width:${({ $maxWidth: e }) => e}px;${({ theme: e }) => _`
2777
+ color: ${e.colors.messageIncoming.text};
2778
+ background-color: ${e.colors.messageIncoming.background};
2779
+ `}
2780
+ padding: 16px 12px;
2781
+ transition: max-width 0.3s;
2782
+ overflow-wrap: break-word;
2783
+ `, Aa = m.div`display:flex;flex-direction:column;gap:12px;`, ka = m.div`display:flex;flex-direction:column;`, $a = m.div`display:flex;flex-direction:column;gap:8px;`;
2784
+ function Ia(e) {
2785
+ return /* @__PURE__ */ r.createElement(r.Fragment, null);
2786
+ }
2787
+ class Ma extends Lr {
2788
+ constructor(t) {
2789
+ super(t), this.state = {
2790
+ hasError: !1
2791
+ };
2792
+ }
2793
+ static getDerivedStateFromError() {
2794
+ return { hasError: !0 };
2795
+ }
2796
+ render() {
2797
+ return this.state.hasError ? this.props.errorFallback : /* @__PURE__ */ r.createElement(Me, { fallback: this.props.loadingFallback }, this.props.children);
2798
+ }
2799
+ }
2800
+ const Oa = /* @__PURE__ */ new Set(["default"]), { MessageTemplate: La } = oo({
2801
+ parser: no,
2802
+ renderer: to,
2803
+ Container: (e) => /* @__PURE__ */ r.createElement("div", { ...e })
2804
+ });
2805
+ function Ra(e) {
2806
+ return /* @__PURE__ */ r.createElement(
2807
+ Ma,
2808
+ {
2809
+ errorFallback: e.messageTemplateErrorFallback,
2810
+ loadingFallback: e.messageTemplateLoadingFallback
2811
+ },
2812
+ /* @__PURE__ */ r.createElement(Da, { ...e })
2813
+ );
2814
+ }
2815
+ const Da = ({
2816
+ extendedMessagePayload: e,
2817
+ onGetCachedMessageTemplate: t = () => null,
2818
+ onRequestMessageTemplate: n,
2819
+ onHandleTemplateInternalAction: o = Oe
2820
+ }) => {
2821
+ const s = e == null ? void 0 : e.message_template;
2822
+ if (!Oa.has((s == null ? void 0 : s.type) ?? "default")) throw new Error("Unsupported template type");
2823
+ if (!n) throw new Error("onRequestMessageTemplate is required");
2824
+ const { theme: a } = Pn(), l = ms({
2825
+ onRequestTemplate: n,
2826
+ onGetCachedTemplate: t,
2827
+ theme: a.selectedTheme,
2828
+ templateKey: (s == null ? void 0 : s.key) ?? "invalid",
2829
+ variables: s == null ? void 0 : s.variables,
2830
+ viewVariables: s == null ? void 0 : s.view_variables,
2831
+ aiAgentColorVariables: a.aiAgentColorVariables
2832
+ });
2833
+ return /* @__PURE__ */ r.createElement(Na, { id: `${le}-ext-message-template` }, /* @__PURE__ */ r.createElement(
2834
+ ro,
2835
+ {
2836
+ handleInternalAction: (c, u) => {
2837
+ c.stopPropagation(), o == null || o(u);
2838
+ }
2839
+ },
2840
+ /* @__PURE__ */ r.createElement(La, { templateItems: l.body.items, templateVersion: l.version })
2841
+ ));
2842
+ }, Na = m.div`box-sizing:border-box;overflow:hidden;width:100%;`;
2843
+ function Fa({
2844
+ extendedMessagePayload: e,
2845
+ onClickSuggestedReply: t,
2846
+ suggestedRepliesDirection: n = "vertical"
2847
+ }) {
2848
+ const [o, s] = T(!1), i = (e == null ? void 0 : e.suggested_replies) ?? [];
2849
+ return i.length === 0 || o ? null : /* @__PURE__ */ r.createElement(Ba, { id: `${le}-ext-suggested-replies`, $type: n }, i.map((a, l) => /* @__PURE__ */ r.createElement(
2850
+ Pa,
2851
+ {
2852
+ key: l,
2853
+ $type: n,
2854
+ variant: "body3",
2855
+ onClick: () => {
2856
+ t && (t == null || t({ reply: a }), s(!0));
2857
+ }
2858
+ },
2859
+ a
2860
+ )));
2861
+ }
2862
+ 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 }) => _`
2863
+ ${e === "vertical" ? Va : za};
2864
+ &:active {
2865
+ background-color: ${t.colors.base.primary};
2866
+ color: ${t.colors.base.primaryContrastContent};
2867
+ }
2868
+ `}
2869
+ `, 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({
2870
+ template: Wa,
2871
+ components: {
2872
+ SenderName: Si,
2873
+ SenderAvatar: Ci,
2874
+ SentTime: wi,
2875
+ MessageBody: Ei,
2876
+ TypingIndicator: Ai,
2877
+ SuggestedReplies: Fa,
2878
+ MessageTemplate: Ra,
2879
+ CTAButton: Mi,
2880
+ Citation: Ri,
2881
+ Form: wa,
2882
+ MessageLogs: Ia
2883
+ }
2884
+ });
2885
+ function Wa(e) {
2886
+ return /* @__PURE__ */ r.createElement(nr, { ...e, testerMode: !1 });
2887
+ }
2888
+ function nr(e) {
2889
+ var x, y, E, f, h, p, v;
2890
+ 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 = !!((f = e.extendedMessagePayload) != null && f.cta_button), l = !!((h = e.extendedMessagePayload) != null && h.citations) && e.extendedMessagePayload.citations.length > 0, c = !!e.createdAt, u = e.groupType === "top" || e.groupType === "single", b = e.groupType === "bottom" || e.groupType === "single", g = o ? 0 : Je;
2891
+ 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(cn, { $startPadding: 0, $endPadding: 0 }, /* @__PURE__ */ r.createElement(
2892
+ t.MessageTemplate,
2893
+ {
2894
+ ...e,
2895
+ messageTemplateErrorFallback: e.messageTemplateErrorFallback ?? /* @__PURE__ */ r.createElement(ct, { $extraStartPadding: g }, /* @__PURE__ */ r.createElement(
2896
+ t.MessageBody,
2897
+ {
2898
+ ...e,
2899
+ messageType: "user",
2900
+ message: ((v = (p = e.extendedMessagePayload) == null ? void 0 : p.message_template) == null ? void 0 : v.fallback_message) ?? "Cannot read this template."
2901
+ }
2902
+ )),
2903
+ messageTemplateLoadingFallback: e.messageTemplateLoadingFallback ?? /* @__PURE__ */ r.createElement(ct, { $extraStartPadding: g }, /* @__PURE__ */ r.createElement(t.TypingIndicator, { ...e }))
2904
+ }
2905
+ )), s && /* @__PURE__ */ r.createElement(cn, { $extraStartPadding: g }, /* @__PURE__ */ r.createElement(t.Form, { ...e }))), b && c && /* @__PURE__ */ r.createElement(Ka, { $extraStartPadding: g + 8 }, /* @__PURE__ */ r.createElement(t.SentTime, { ...e })), /* @__PURE__ */ r.createElement(Tn, null, e.suggestedRepliesVisible && /* @__PURE__ */ r.createElement(t.SuggestedReplies, { ...e }), /* @__PURE__ */ r.createElement(t.MessageLogs, { ...e })));
2906
+ }
2907
+ const Ga = m.div`display:flex;flex-direction:column;align-items:flex-start;margin-bottom:${({ $marginBottom: e }) => `${e}px`};
2908
+ `, rt = m.div`display:flex;align-self:stretch;justify-content:flex-start;${({ $startPadding: e = ae, $endPadding: t = ae, $extraStartPadding: n = 0 }) => `
2909
+ padding-inline: ${e + n}px ${t}px;
2910
+ `}
2911
+ `, ja = m(rt)`display:flex;flex-direction:row;align-items:center;gap:8px;`, ct = m(rt)`display:flex;`, Ka = m(rt)`margin-top:${Gn}px;display:flex;align-items:flex-start;justify-content:flex-start;`, cn = m(rt)`display:flex;${({ $startPadding: e = ae, $endPadding: t = ae, $extraStartPadding: n = 0 }) => `
2912
+ padding-inline: ${e + n}px ${t}px;
2913
+ `}
2914
+ `, qa = m.div`display:flex;flex-direction:column;gap:${Ae}px;`;
2915
+ function Za({ file: e, children: t, onClickFile: n }) {
2916
+ return /* @__PURE__ */ r.createElement(Ya, null, /* @__PURE__ */ r.createElement(
2917
+ Mt,
2918
+ {
2919
+ name: e.name,
2920
+ type: It(e.name, e.type),
2921
+ onClick: n && (() => n == null ? void 0 : n(e))
2922
+ }
2923
+ ), t);
2924
+ }
2925
+ const Ya = m.div`display:flex;flex-direction:column;align-items:flex-end;gap:${Ae}px;`, rr = ({ 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);}}`;
2926
+ function Xa({ file: e, metadata: t, onClickMedia: n, children: o }) {
2927
+ const { aspectRatio: s, localFile: i } = t, [a] = T(() => i instanceof File ? URL.createObjectURL(i) : e.url), [l, c] = T(!1), u = {
2928
+ onClick: () => n == null ? void 0 : n(e),
2929
+ $ratio: s
2930
+ };
2931
+ return /* @__PURE__ */ r.createElement(Qa, null, /* @__PURE__ */ r.createElement(el, { ...u }, !l && /* @__PURE__ */ r.createElement(rr, { 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);
2932
+ }
2933
+ 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;${k.light`
2934
+ background-color: ${d.color.background100};
2935
+ `}
2936
+ ${k.dark`
2937
+ background-color: ${d.color.background400};
2938
+ `}
2939
+ `, 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;`;
2940
+ function dn(e) {
2941
+ var n, o;
2942
+ const t = Q(() => {
2943
+ const s = pi(Kn(e.message));
2944
+ return In.sanitize(s);
2945
+ }, [e.message]);
2946
+ return /* @__PURE__ */ r.createElement(
2947
+ nl,
2948
+ {
2949
+ $maxWidth: e.maxBodyWidth ?? be,
2950
+ $color: (n = e.customStyle) == null ? void 0 : n.bubbleContentColor,
2951
+ $bgColor: (o = e.customStyle) == null ? void 0 : o.bubbleBackgroundColor
2952
+ },
2953
+ /* @__PURE__ */ r.createElement(rl, { variant: "body3", dangerouslySetInnerHTML: { __html: t } })
2954
+ );
2955
+ }
2956
+ 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 }) => _`
2957
+ color: ${t || e.colors.messageOutgoing.text};
2958
+ background-color: ${n || e.colors.messageOutgoing.background};
2959
+ `}
2960
+ padding: 12px 0;
2961
+ transition: max-width 0.3s;
2962
+ overflow-wrap: break-word;
2963
+ `, rl = m(w)`align-items:flex-start;line-height:140%;white-space:pre-wrap;padding:0 12px;`;
2964
+ function ol(e) {
2965
+ const { stringSet: t } = L(), n = jn(e) ? /* @__PURE__ */ r.createElement(dn, { ...e }) : null;
2966
+ 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(dn, { ...e, message: t.UNKNOWN__UNKNOWN_MESSAGE_TYPE });
2967
+ }
2968
+ function sl({ sendingStatus: e }) {
2969
+ const t = _t();
2970
+ switch (e) {
2971
+ case "pending":
2972
+ return /* @__PURE__ */ r.createElement(il, { size: 16 }, /* @__PURE__ */ r.createElement(O, { type: "spinner", color: t.colors.messageOutgoing.background, size: 16 }));
2973
+ case "failed":
2974
+ return /* @__PURE__ */ r.createElement("div", { style: { marginBottom: 2 } }, /* @__PURE__ */ r.createElement(O, { type: "error", color: d.themedColor.error, size: 16 }));
2975
+ case "scheduled":
2976
+ case "canceled":
2977
+ return null;
2978
+ default:
2979
+ return /* @__PURE__ */ r.createElement("div", null, /* @__PURE__ */ r.createElement(O, { type: "chevron-down" }));
2980
+ }
2981
+ }
2982
+ const il = m(rr)`margin-bottom:2px;width:16px;height:16px;`;
2983
+ function al({ createdAt: e }) {
2984
+ const { stringSet: t, format: n } = L();
2985
+ return e ? /* @__PURE__ */ r.createElement(w, { variant: "caption4", color: d.themedColor.textLowEmphasis }, n(e, t.DATE_FORMAT__MESSAGE_TIMESTAMP)) : null;
2986
+ }
2987
+ const Bt = Te({
2988
+ template: ll,
2989
+ components: {
2990
+ SendingStatus: sl,
2991
+ SentTime: al,
2992
+ MessageBody: ol
2993
+ }
2994
+ });
2995
+ function ll(e) {
2996
+ const { components: t } = Bt.useContext(), n = e.sendingStatus === "succeeded", o = e.groupType === "bottom" || e.groupType === "single";
2997
+ 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 })));
2998
+ }
2999
+ const cl = m.div`display:flex;flex:1;flex-direction:column;align-items:flex-end;margin-bottom:${({ $marginBottom: e }) => `${e}px`};
3000
+ `, or = 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;`};
3001
+ `, dl = m(or)``, ul = m(or)`margin-top:${Gn}px;`;
3002
+ function ml(e) {
3003
+ return e.messageType !== "admin" ? null : /* @__PURE__ */ r.createElement(hl, null, /* @__PURE__ */ r.createElement(w, { variant: "caption2", color: d.themedColor.textMidEmphasis }, gl(In.sanitize(e.message))));
3004
+ }
3005
+ const hl = m.div`text-align:center;text-wrap:pretty;a{text-decoration:none;color:inherit;}`, gl = (e) => {
3006
+ const t = /\[([^\]]+)\]\((https?:\/\/[^\s]+)\)/g, n = [];
3007
+ let o = 0;
3008
+ return e.replace(t, (s, i, a, l) => (n.push(e.slice(o, l)), n.push(
3009
+ /* @__PURE__ */ r.createElement("a", { key: a, href: a, target: "_blank", rel: kt }, i)
3010
+ ), o = l + s.length, s)), n.push(e.slice(o)), n;
3011
+ }, pl = ({ submitted: e, defaultValue: t, value: n, onChange: o }) => {
3012
+ const { stringSet: s } = L();
3013
+ return R(() => {
3014
+ typeof n > "u" && typeof t == "boolean" && (o == null || o(t));
3015
+ }, [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(
3016
+ un,
3017
+ {
3018
+ checked: n === !0,
3019
+ label: s.CSAT_CRE_SOLVED,
3020
+ disabled: e,
3021
+ onClick: () => o == null ? void 0 : o(!0)
3022
+ }
3023
+ ), /* @__PURE__ */ r.createElement(
3024
+ un,
3025
+ {
3026
+ checked: n === !1,
3027
+ label: s.CSAT_CRE_NOT_SOLVED,
3028
+ disabled: e,
3029
+ onClick: () => o == null ? void 0 : o(!1)
3030
+ }
3031
+ )));
3032
+ }, un = ({ onClick: e, checked: t, label: n, disabled: o }) => {
3033
+ 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;
3034
+ 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));
3035
+ }, 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: {
3036
+ maskType: "alpha"
3037
+ }, 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 = [
3038
+ {
3039
+ value: 1,
3040
+ Icon: {
3041
+ Active: El,
3042
+ Inactive: xl
3043
+ },
3044
+ isActive: (e) => e <= 1,
3045
+ getTooltip: (e) => e.CSAT5_RATING_SCORE_1
3046
+ },
3047
+ {
3048
+ value: 2,
3049
+ Icon: {
3050
+ Active: yl,
3051
+ Inactive: vl
3052
+ },
3053
+ isActive: (e) => e === 2,
3054
+ getTooltip: (e) => e.CSAT5_RATING_SCORE_2
3055
+ },
3056
+ {
3057
+ value: 3,
3058
+ Icon: {
3059
+ Active: _l,
3060
+ Inactive: Cl
3061
+ },
3062
+ isActive: (e) => e === 3,
3063
+ getTooltip: (e) => e.CSAT5_RATING_SCORE_3
3064
+ },
3065
+ {
3066
+ value: 4,
3067
+ Icon: {
3068
+ Active: Tl,
3069
+ Inactive: Sl
3070
+ },
3071
+ isActive: (e) => e === 4,
3072
+ getTooltip: (e) => e.CSAT5_RATING_SCORE_4
3073
+ },
3074
+ {
3075
+ value: 5,
3076
+ Icon: {
3077
+ Active: Al,
3078
+ Inactive: wl
3079
+ },
3080
+ isActive: (e) => 5 <= e,
3081
+ getTooltip: (e) => e.CSAT5_RATING_SCORE_5
3082
+ }
3083
+ ], $l = () => kl, sr = ({ 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(Il, { $position: n }))), Il = ({ $position: e }) => /* @__PURE__ */ r.createElement(
3084
+ "svg",
3085
+ {
3086
+ style: { transform: e === "top" ? "rotate(0)" : "rotate(180deg)" },
3087
+ xmlns: "http://www.w3.org/2000/svg",
3088
+ width: "12",
3089
+ height: "6",
3090
+ viewBox: "0 0 12 6",
3091
+ fill: "none"
3092
+ },
3093
+ /* @__PURE__ */ r.createElement("path", { d: "M6 6L0 0h12L6 6Z", fill: d.themedColor.textHighEmphasis })
3094
+ ), Ml = {
3095
+ top: _`flex-direction:column;top:0;transform:translate(-50%,-100%);`,
3096
+ bottom: _`flex-direction:column-reverse;bottom:0;transform:translate(-50%,100%);`
3097
+ }, 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 }) => {
3098
+ const { stringSet: o } = L(), s = $l(), i = typeof t == "number";
3099
+ 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(sr, { disabled: e, key: a.value, label: a.getTooltip(o) }, /* @__PURE__ */ r.createElement(
3100
+ Fl,
3101
+ {
3102
+ disabled: e,
3103
+ onClick: () => n(a.value),
3104
+ $inactive: i && !a.isActive(t)
3105
+ },
3106
+ 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)
3107
+ )))));
3108
+ }, 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};${k.dark`
3109
+ background-color: ${d.color.background500};
3110
+ `}
3111
+ }
3112
+
3113
+ ${({ $inactive: e, theme: t }) => e && t.selectedTheme === "dark" && Bl};
3114
+ `, Bl = _`[fill]{fill:white;fill-opacity:0.12;}[stroke]{stroke:white;stroke-opacity:0.12;}`, Pl = ({ submitted: e, value: t = "", onChange: n }) => {
3115
+ const { stringSet: o } = L();
3116
+ return e && !t ? null : /* @__PURE__ */ r.createElement(
3117
+ Ul,
3118
+ {
3119
+ disabled: e,
3120
+ maxLength: 255,
3121
+ value: t,
3122
+ onChange: (s) => n(s.target.value),
3123
+ placeholder: o.CSAT_REASON_PLACEHOLDER
3124
+ }
3125
+ );
3126
+ }, 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};${k.dark`
3127
+ background-color: ${d.themedColor.textDisabled};
3128
+ `}
3129
+
3130
+ &:disabled {
3131
+ cursor: not-allowed;
3132
+ color: ${d.themedColor.textLowEmphasis};
3133
+ background-color: ${d.color.background200};
3134
+ ${k.dark`
3135
+ color: ${d.color.ondark.textDisabled};
3136
+ background-color: ${d.themedColor.textDisabled};
3137
+ `}
3138
+ }
3139
+ `, Hl = ({ submitted: e }) => {
3140
+ const { stringSet: t } = L();
3141
+ 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);
3142
+ };
3143
+ 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 || {});
3144
+ const Vl = (e) => Rr((t, n) => ({ ...t, ...n }), e), dt = ({
3145
+ type: e,
3146
+ renderSubmitButton: t,
3147
+ initialCsat: n,
3148
+ initialCsatReason: o,
3149
+ initialIsResolved: s
3150
+ }) => {
3151
+ const [i, a] = Vl({
3152
+ csatType: e,
3153
+ csat: n,
3154
+ csatReason: o,
3155
+ isResolved: s
3156
+ }), 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" };
3157
+ 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(
3158
+ pl,
3159
+ {
3160
+ ...c,
3161
+ defaultValue: s,
3162
+ value: i.isResolved,
3163
+ onChange: (u) => a({ isResolved: u })
3164
+ }
3165
+ ), /* @__PURE__ */ r.createElement(Rl, { ...c, value: i.csat, onChange: (u) => a({ csat: u }) }), i.csat && /* @__PURE__ */ r.createElement(
3166
+ Pl,
3167
+ {
3168
+ ...c,
3169
+ value: i.csatReason,
3170
+ onChange: (u) => a({ csatReason: u })
3171
+ }
3172
+ )), l !== "submitted" && t({ state: l, params: i }));
3173
+ }, zl = m.div`display:flex;flex-direction:column;gap:12px;`, Wl = () => {
3174
+ const { stringSet: e } = L();
3175
+ return /* @__PURE__ */ r.createElement(w, { variant: "body2", color: d.themedColor.textMidEmphasis, style: { textAlign: "center" } }, e.CSAT_SUBMISSION_EXPIRED);
3176
+ }, Gl = (e) => {
3177
+ if (e.messageType !== "admin.csat")
3178
+ throw new Error("Invalid message type");
3179
+ const t = Jr(), { stringSet: n } = L(), { extendedMessagePayload: o, csat: s, csatReason: i, csatExpireAt: a, isResolvedWhenDeterminedByUser: l, onSubmitCSAT: c } = e, { visibility: u, type: b } = (o == null ? void 0 : o.csat) ?? {};
3180
+ if (!u || !b || !oe[b]) return null;
3181
+ const g = b === oe.AI_AGENT_CSAT_5 || b === oe.AI_AGENT_CSAT_5_WITH_CRE || b === oe.HELPDESK_CSAT_5 ? dt : () => null, x = (y) => {
3182
+ y.csat && !mn(a) ? c({
3183
+ csatType: y.csatType,
3184
+ csat: y.csat,
3185
+ csatReason: y.csatReason,
3186
+ isResolved: y.isResolved
3187
+ }) : t();
3188
+ };
3189
+ return /* @__PURE__ */ r.createElement(jl, null, !s && mn(a) ? /* @__PURE__ */ r.createElement(Wl, null) : /* @__PURE__ */ r.createElement(
3190
+ g,
3191
+ {
3192
+ type: b,
3193
+ initialCsat: s,
3194
+ initialCsatReason: i,
3195
+ initialIsResolved: l,
3196
+ 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))
3197
+ }
3198
+ ));
3199
+ }, 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;}`;
3200
+ function mn(e) {
3201
+ return !!e && e < Date.now();
3202
+ }
3203
+ function ir(e) {
3204
+ return e();
3205
+ }
3206
+ const Pt = Te({
3207
+ template: ql,
3208
+ components: {
3209
+ AdminMessage: ml,
3210
+ CSATMessage: Gl
3211
+ }
3212
+ });
3213
+ function ql(e) {
3214
+ const { components: t } = Pt.useContext(), n = ir(() => e.messageType === "admin" ? /* @__PURE__ */ r.createElement(t.AdminMessage, { ...e }) : e.messageType === "admin.csat" ? /* @__PURE__ */ r.createElement(t.CSATMessage, { ...e }) : null);
3215
+ return /* @__PURE__ */ r.createElement(Zl, { $marginBottom: $t(e.groupType) }, n);
3216
+ }
3217
+ const Zl = m.div`padding-inline:${ae}px;margin-bottom:${({ $marginBottom: e }) => e}px;`, hn = {
3218
+ file: "attach",
3219
+ snippet: "snippet",
3220
+ site: "website",
3221
+ sb_sprinklr: "sprinklr",
3222
+ sb_salesforce: "salesforce",
3223
+ sb_confluence: "confluence",
3224
+ sb_zendesk: "zendesk",
3225
+ sb_desk: "snippet"
3226
+ // TODO: request icon
3227
+ }, Yl = ({
3228
+ actionbook: e,
3229
+ functionCalls: t,
3230
+ groundedness: n,
3231
+ agentMessageTemplates: o,
3232
+ onClickActionbook: s,
3233
+ onClickFunctionCall: i,
3234
+ onClickFunctionCallDetail: a,
3235
+ onClickGroundedness: l,
3236
+ onClickAgentMessageTemplate: c,
3237
+ bottomContent: u,
3238
+ renderCustomGroundednessIcon: b = (x) => x.default,
3239
+ style: g = {}
3240
+ }) => {
3241
+ const {
3242
+ // Note: This component is used with the dashboard, so cssVars should not be used.
3243
+ iconColor: x = "#000000",
3244
+ textColor: y = "#000000",
3245
+ highlightColor: E = Hn.DEFAULT_PRIMARY
3246
+ } = g;
3247
+ return /* @__PURE__ */ r.createElement(gn, null, e && /* @__PURE__ */ r.createElement(gn, null, /* @__PURE__ */ r.createElement(Xe, null, /* @__PURE__ */ r.createElement(We, null, /* @__PURE__ */ r.createElement(O, { size: 16, type: "actionbook", color: x })), /* @__PURE__ */ r.createElement(
3248
+ ze,
3249
+ {
3250
+ $clickable: !!s,
3251
+ $highlightColor: E,
3252
+ variant: "body2",
3253
+ color: y,
3254
+ onClick: () => s == null ? void 0 : s(e)
3255
+ },
3256
+ e.name
3257
+ ))), t == null ? void 0 : t.map((f) => /* @__PURE__ */ r.createElement(ut, { key: f.key }, /* @__PURE__ */ r.createElement(We, null, /* @__PURE__ */ r.createElement(O, { size: 16, type: "function", color: x })), /* @__PURE__ */ r.createElement(Xe, null, /* @__PURE__ */ r.createElement(
3258
+ ze,
3259
+ {
3260
+ $clickable: !!i,
3261
+ $highlightColor: E,
3262
+ variant: "body2",
3263
+ color: y,
3264
+ onClick: () => i == null ? void 0 : i(f)
3265
+ },
3266
+ f.name
3267
+ ), a && /* @__PURE__ */ r.createElement(Xl, { role: "button", onClick: () => a == null ? void 0 : a(f) }, /* @__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((f) => /* @__PURE__ */ r.createElement(ut, { key: f.id }, /* @__PURE__ */ r.createElement(We, null, b({
3268
+ default: /* @__PURE__ */ r.createElement(O, { size: 16, type: hn[f.source_type] ?? hn.snippet, color: x }),
3269
+ sourceType: f.source_type
3270
+ })), /* @__PURE__ */ r.createElement(
3271
+ ze,
3272
+ {
3273
+ $clickable: !!l,
3274
+ $highlightColor: E,
3275
+ variant: "body2",
3276
+ color: y,
3277
+ onClick: () => l == null ? void 0 : l(f)
3278
+ },
3279
+ f.preview_title
3280
+ ))), o == null ? void 0 : o.map((f) => /* @__PURE__ */ r.createElement(ut, { key: f.key }, /* @__PURE__ */ r.createElement(We, null, /* @__PURE__ */ r.createElement(O, { size: 16, type: "template", color: x })), /* @__PURE__ */ r.createElement(
3281
+ ze,
3282
+ {
3283
+ $clickable: !!c,
3284
+ $highlightColor: E,
3285
+ variant: "body2",
3286
+ color: y,
3287
+ onClick: () => c == null ? void 0 : c(f)
3288
+ },
3289
+ f.name
3290
+ ))), u);
3291
+ }, Jl = m(w)`font-weight:400;`, ze = m(Jl)`${({ $clickable: e, $highlightColor: t }) => e && _`
3292
+ cursor: pointer;
3293
+ text-decoration: underline;
3294
+ &:hover {
3295
+ color: ${t};
3296
+ }
3297
+ `}
3298
+ `, 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;`, gn = m.div`display:flex;gap:4px;flex-direction:column;align-items:flex-start;`, ar = _e(null);
3299
+ function Ql({ testerType: e, children: t }) {
3300
+ return /* @__PURE__ */ r.createElement(
3301
+ ar.Provider,
3302
+ {
3303
+ value: { testerType: e, isActionbookTester: e === "actionbook" }
3304
+ },
3305
+ e && /* @__PURE__ */ r.createElement(ec, null),
3306
+ t
3307
+ );
3308
+ }
3309
+ const Ne = () => {
3310
+ const e = se(ar);
3311
+ if (!e) throw new Error("_UNSAFE_INTERNAL_DashboardTesterProvider not found");
3312
+ return e;
3313
+ }, ec = () => {
3314
+ const { isActionbookTester: e } = Ne();
3315
+ return /* @__PURE__ */ r.createElement(ye.Template, { template: e ? tc : void 0 }, /* @__PURE__ */ r.createElement(ye.MessageLogs, { component: nc }));
3316
+ }, tc = (e) => /* @__PURE__ */ r.createElement(nr, { ...e, testerMode: !0, maxBodyWidth: Wn }), nc = ({ extendedMessagePayload: e = {} }) => {
3317
+ const { handlers: t } = V(), { manual: n, groundedness: o, function_calls: s, agent_message_templates: i, is_thinking: a } = e;
3318
+ 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(
3319
+ Yl,
3320
+ {
3321
+ actionbook: n,
3322
+ functionCalls: s,
3323
+ groundedness: o,
3324
+ agentMessageTemplates: i,
3325
+ onClickFunctionCallDetail: t == null ? void 0 : t.onFunctionCallDetailClick,
3326
+ style: {
3327
+ iconColor: d.themedColor.textHighEmphasis,
3328
+ textColor: d.themedColor.textHighEmphasis,
3329
+ barColor: d.themedColor.textDisabled
3330
+ },
3331
+ bottomContent: /* @__PURE__ */ r.createElement(sc, { variant: "caption2", color: d.themedColor.textLowEmphasis }, "Only visible in the tester")
3332
+ }
3333
+ ));
3334
+ }, 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;`;
3335
+ function ic(e) {
3336
+ return "sendingStatus" in e ? e.sendingStatus === "succeeded" ? String(e.messageId) : e.reqId : String(e.messageId);
3337
+ }
3338
+ const ac = (e, t, n, o = !0) => {
3339
+ if (!o || !e.isUserMessage() && !e.isFileMessage())
3340
+ return "single";
3341
+ const s = () => {
3342
+ if (!t || !t.isUserMessage() && !t.isFileMessage()) return !1;
3343
+ const c = t.sender.userId === e.sender.userId, u = qt(t.createdAt, e.createdAt);
3344
+ return c && u;
3345
+ }, i = () => {
3346
+ if (!n || !n.isUserMessage() && !n.isFileMessage()) return !1;
3347
+ const c = n.sender.userId === e.sender.userId, u = qt(n.createdAt, e.createdAt);
3348
+ return c && u;
3349
+ }, a = s(), l = i();
3350
+ return a && l ? "middle" : a ? "bottom" : l ? "top" : "single";
3351
+ };
3352
+ function lc(e, t) {
3353
+ return e.filter((n) => we.isWelcomeMessage(n, t));
3354
+ }
3355
+ function Ut(e, t) {
3356
+ return cc(e) === t;
3357
+ }
3358
+ function cc(e) {
3359
+ var t;
3360
+ if (e)
3361
+ return e.isUserMessage() || e.isFileMessage() || e.isMultipleFilesMessage() ? e.sender.userId : ((t = e == null ? void 0 : e.sender) == null ? void 0 : t.userId) ?? void 0;
3362
+ }
3363
+ function dc(e) {
3364
+ return e.isAdminMessage() ? e.message === "The channel's custom_type was updated." : !1;
3365
+ }
3366
+ const vt = (e) => !!e && "sender" in e, lr = (e) => e.startsWith("image/"), cr = (e) => e.startsWith("video/"), pn = (e) => lr(e) || cr(e), Ge = {
3367
+ isAdmin: (e) => e.isAdminMessage(),
3368
+ isCSAT: (e) => {
3369
+ var t;
3370
+ return e.isAdminMessage() && !!((t = e.extendedMessagePayload) != null && t.csat);
3371
+ },
3372
+ isIncoming: (e, t) => vt(e) && e.sender.userId !== t,
3373
+ isOutgoing: (e, t) => vt(e) && (e.sender.userId === t || e.sendingStatus === mt.PENDING)
3374
+ }, uc = (e) => {
3375
+ const { chatSDK: t, handlers: n } = V(), { aiAgentInfo: o } = H(), s = B(/* @__PURE__ */ new Set()), i = (a, l) => {
3376
+ var c, u;
3377
+ if (a.url === e && (vt(l) && l.sender.userId === o.userId && !we.isStreaming(l) && !s.current.has(l.messageId) && ((c = n == null ? void 0 : n.onCustomEvent) == null || c.call(n, { type: "bot-message-received", data: { message: l } }), s.current.add(l.messageId)), l.isAdminMessage() && l.customType === "user_action_required" && !s.current.has(l.messageId))) {
3378
+ const x = gt(l.data);
3379
+ Array.isArray(x.histories) && x.histories.length === 0 && ((u = n == null ? void 0 : n.onCustomEvent) == null || u.call(n, {
3380
+ type: "user-action-requested",
3381
+ data: x
3382
+ }), s.current.add(l.messageId));
3383
+ }
3384
+ };
3385
+ et(t, {
3386
+ onMessageUpdated: i,
3387
+ onMessageReceived: i
3388
+ });
3389
+ }, mc = ({ publishSynchronous: e = !1 }) => {
3390
+ const t = /* @__PURE__ */ new Set();
3391
+ return {
3392
+ publish: (n) => {
3393
+ t.forEach((o) => {
3394
+ e ? o(n) : setTimeout(() => o(n), 0);
3395
+ });
3396
+ },
3397
+ subscribe: (n) => (t.add(n), () => t.delete(n))
3398
+ };
3399
+ };
3400
+ function hc(e, t = []) {
3401
+ const n = B(null), o = B(0), s = B(0), [i] = T(() => mc({ publishSynchronous: !0 })), [a, l] = T(!0);
3402
+ return de(() => {
3403
+ o.current = 0, s.current = 0, l(!0), n.current && (n.current.scrollTop = n.current.scrollHeight);
3404
+ }, t), de(() => i.subscribe(({ type: c, data: u }) => {
3405
+ const { resolve: b, animated: g } = u ?? {};
3406
+ if (!n.current) return b == null ? void 0 : b();
3407
+ if (c === "scrollToBottom" && (n.current.scroll ? n.current.scroll({
3408
+ top: n.current.scrollHeight,
3409
+ behavior: fn(e, g)
3410
+ }) : n.current.scrollTop = n.current.scrollHeight, s.current = 0, l(!0), b == null || b()), c === "scroll") {
3411
+ const x = u == null ? void 0 : u.top, { scrollTop: y, scrollHeight: E, clientHeight: f } = n.current;
3412
+ 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 - f), l(s.current === 0), b == null || b();
3413
+ }
3414
+ }), [e]), {
3415
+ scrollRef: n,
3416
+ scrollPubSub: i,
3417
+ isScrollBottomReached: a,
3418
+ setIsScrollBottomReached: l,
3419
+ scrollDistanceFromBottomRef: s,
3420
+ scrollPositionRef: o
3421
+ };
3422
+ }
3423
+ function fn(e, t) {
3424
+ return typeof t == "boolean" ? t ? "smooth" : "auto" : e;
3425
+ }
3426
+ function gc(e) {
3427
+ return new Promise((t) => {
3428
+ const n = new Image();
3429
+ n.onload = function() {
3430
+ const o = String(n.width), s = String(n.height);
3431
+ URL.revokeObjectURL(n.src), t({ width: o, height: s });
3432
+ }, n.src = URL.createObjectURL(e);
3433
+ });
3434
+ }
3435
+ async function pc(e) {
3436
+ if ("file" in e && e.file instanceof File && e.file.type.startsWith("image/")) {
3437
+ const { width: t, height: n } = await gc(e.file);
3438
+ return new so({
3439
+ key: dr,
3440
+ value: [t, n]
3441
+ });
3442
+ }
3443
+ }
3444
+ const dr = "KEY_IMG_ASPECT_RATIO", fc = ({ onScrollAfterSendMessage: e }) => {
3445
+ const { agentPreviewConfigs: t, handlers: n } = V(), o = B(t == null ? void 0 : t.agentAttributes);
3446
+ return o.current = t == null ? void 0 : t.agentAttributes, {
3447
+ onBeforeSendMessage: async (s) => {
3448
+ const i = await pc(s), a = {
3449
+ ...s,
3450
+ metaArrays: i ? [i] : void 0
3451
+ }, l = bc(o.current);
3452
+ return l ? { ...a, data: JSON.stringify(l) } : a;
3453
+ },
3454
+ onAfterSendMessage: (s) => {
3455
+ var i, a, l;
3456
+ 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 } }));
3457
+ }
3458
+ };
3459
+ }, bc = (e) => {
3460
+ if (!e) return null;
3461
+ const t = {};
3462
+ 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;
3463
+ }, {
3464
+ Provider: xc,
3465
+ Context: bm,
3466
+ useContext: Z
3467
+ } = W("Conversation"), Ec = ({
3468
+ closedChannelUrl: e,
3469
+ onClearClosedChannelUrl: t,
3470
+ onNavigateToConversationList: n,
3471
+ children: o
3472
+ }) => {
3473
+ const { aiAgentInfo: s, activeChannel: i, refreshActiveChannel: a } = H(), { testerType: l } = Ne(), c = hc("smooth"), { onBeforeSendMessage: u, onAfterSendMessage: b } = fc({
3474
+ onScrollAfterSendMessage: () => {
3475
+ c.scrollPubSub.publish({ type: "scrollToBottom", data: { animated: !1 } });
3476
+ }
3477
+ }), g = e || (i == null ? void 0 : i.url);
3478
+ uc(g);
3479
+ const x = (E) => {
3480
+ const f = E[E.length - 1];
3481
+ f && we.shouldScrollToBottom(f, s.userId, !!l) && setTimeout(() => c.scrollPubSub.publish({ type: "scrollToBottom", data: { animated: !0 } }), 100);
3482
+ }, y = D(async () => {
3483
+ await a(), e && (t == null || t());
3484
+ }, [a, e, t]);
3485
+ return /* @__PURE__ */ r.createElement(
3486
+ Yo,
3487
+ {
3488
+ channelUrl: g,
3489
+ onBeforeSendMessage: u,
3490
+ onAfterSendMessage: b,
3491
+ onMessagesUpdated: x,
3492
+ onMessagesReceived: x,
3493
+ onChannelDeleted: y,
3494
+ onConversationClosedViaDispatcher: y
3495
+ },
3496
+ (E) => /* @__PURE__ */ r.createElement(
3497
+ xc,
3498
+ {
3499
+ value: { ...E, scrollSource: c, goToActiveConversation: y, onNavigateToConversationList: n }
3500
+ },
3501
+ o
3502
+ )
3503
+ );
3504
+ }, Ht = _e({
3505
+ onDrop: Oe,
3506
+ subscribe: () => Oe
3507
+ }), yt = ({ children: e }) => {
3508
+ const t = B(/* @__PURE__ */ new Set());
3509
+ return /* @__PURE__ */ r.createElement(
3510
+ Ht.Provider,
3511
+ {
3512
+ value: {
3513
+ onDrop: (n) => {
3514
+ var o;
3515
+ if (n.preventDefault(), (o = n.dataTransfer) != null && o.files) {
3516
+ const s = Array.from(n.dataTransfer.files);
3517
+ s.length > 0 && t.current.forEach((i) => i(s));
3518
+ }
3519
+ },
3520
+ subscribe: (n) => (t.current.add(n), () => t.current.delete(n))
3521
+ }
3522
+ },
3523
+ e
3524
+ );
3525
+ }, vc = ({ onDropFiles: e }) => {
3526
+ const { subscribe: t } = se(Ht);
3527
+ R(() => t(e), [e]);
3528
+ };
3529
+ yt.Consumer = ({ children: e }) => {
3530
+ const { onDrop: t } = se(Ht);
3531
+ return e({ onDrop: t, onDragOver: (s) => s.preventDefault() });
3532
+ };
3533
+ const xm = ({ iconSize: e = 64, icon: t, className: n, label: o, children: s }) => /* @__PURE__ */ r.createElement(Cc, { 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), yc = m.div`position:relative;display:flex;justify-content:center;align-items:center;width:100%;height:100%;`, Cc = m.div`display:flex;flex-direction:column;min-height:104px;align-items:center;gap:20px;text-align:center;`, _c = {
3534
+ loading: A(() => import("./DxAEO4J0.js")),
3535
+ error: A(() => import("./dnxo1nL1.js")),
3536
+ noChannels: A(() => import("./DU-buYVt.js")),
3537
+ noMessages: A(() => import("./BMpxfxq9.js"))
3538
+ }, Ce = ({ className: e, type: t = "loading", ...n }) => {
3539
+ const o = _c[t];
3540
+ return /* @__PURE__ */ r.createElement(yc, { className: e }, /* @__PURE__ */ r.createElement(Me, { fallback: null }, /* @__PURE__ */ r.createElement(o, { ...n })));
3541
+ }, Sc = 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;}`, Tc = m(Ot)`path{fill:${({ theme: e }) => e.colors.base.primaryContrastContent};}`;
3542
+ function ur({ size: e }) {
3543
+ const { aiAgentInfo: t } = H();
3544
+ return t.profileUrl ? /* @__PURE__ */ r.createElement(Lt, { size: e, src: t.profileUrl }) : /* @__PURE__ */ r.createElement(Sc, { $size: e }, /* @__PURE__ */ r.createElement(Tc, null));
3545
+ }
3546
+ const wc = m.div`width:100%;height:100%;position:fixed;top:0;left:0;outline:none;`, Ac = 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;}`, kc = 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;`, Ic = 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);}`, Mc = 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;}`, Oc = m.div`display:flex;width:160px;justify-content:flex-end;`, Lc = m.div`inset-inline-end:0;display:flex;flex-direction:row;`, mr = m.div`width:64px;padding:21px;box-sizing:border-box;cursor:${(e) => e.disabled ? "not-allowed" : "pointer"};`, Rc = m(mr)`border-inline-start:1px solid ${d.themedColor.textDisabled};`, Dc = m.div`width:100%;height:100%;display:flex;align-items:center;justify-content:center;`, Nc = m.video`max-width:100%;max-height:100%;user-select:none;-webkit-user-drag:none;`, Fc = m.img`max-width:calc(90% - 60px);max-height:calc(90% - 60px);user-select:none;-webkit-user-drag:none;`, Bc = m.div`max-width:100%;max-height:100%;display:flex;justify-content:center;align-items:center;`, Pc = ({ file: e, sender: t = {}, onClose: n, onDownloadClick: o }) => {
3547
+ const { type: s, url: i, name: a = "" } = e, { profileUrl: l, nickname: c, userId: u } = t, { aiAgentInfo: b } = H();
3548
+ return /* @__PURE__ */ r.createElement(
3549
+ Hc,
3550
+ {
3551
+ profileUrl: l ?? "",
3552
+ nickname: c ?? "",
3553
+ type: s,
3554
+ url: i,
3555
+ name: a,
3556
+ onClose: n,
3557
+ isBotMessage: u === b.userId,
3558
+ onDownloadClick: o
3559
+ }
3560
+ );
3561
+ }, Uc = ({ profileUrl: e, isBotMessage: t }) => !e && t ? /* @__PURE__ */ r.createElement(ur, { size: 32 }) : /* @__PURE__ */ r.createElement(Lt, { size: 32, src: e }), Hc = ({
3562
+ profileUrl: e,
3563
+ isBotMessage: t,
3564
+ nickname: n,
3565
+ name: o,
3566
+ type: s,
3567
+ url: i,
3568
+ onClose: a,
3569
+ onDownloadClick: l
3570
+ }) => {
3571
+ const { stringSet: c } = L();
3572
+ return /* @__PURE__ */ r.createElement(Zn, { onClose: a, visible: !0, rootElementId: ie.MODAL_ROOT }, /* @__PURE__ */ r.createElement(wc, null, /* @__PURE__ */ r.createElement(Ac, null, /* @__PURE__ */ r.createElement(kc, null, /* @__PURE__ */ r.createElement($c, null, /* @__PURE__ */ r.createElement(Uc, { profileUrl: e, isBotMessage: t })), /* @__PURE__ */ r.createElement(Ic, null, /* @__PURE__ */ r.createElement(w, { variant: "h2", color: d.themedColor.textHighEmphasis }, o)), /* @__PURE__ */ r.createElement(Mc, null, /* @__PURE__ */ r.createElement(w, { variant: "body1", color: d.color.ondark.textMidEmphasis }, n))), /* @__PURE__ */ r.createElement(Oc, null, pn(s) && /* @__PURE__ */ r.createElement(Lc, null, /* @__PURE__ */ r.createElement(mr, { as: "a", href: i, target: "_blank", rel: kt, onClick: l }, /* @__PURE__ */ r.createElement(O, { type: "download", color: d.themedColor.textHighEmphasis, size: 24 }))), /* @__PURE__ */ r.createElement(Rc, { onClick: a }, /* @__PURE__ */ r.createElement(O, { type: "close", color: d.themedColor.textHighEmphasis, size: 24 })))), /* @__PURE__ */ r.createElement(Dc, { onClick: (u) => u.currentTarget === u.target && a() }, cr(s) && /* @__PURE__ */ r.createElement(Nc, { controls: !0 }, /* @__PURE__ */ r.createElement("source", { src: i, type: s })), lr(s) && /* @__PURE__ */ r.createElement(Fc, { src: i, alt: o }), !pn(s) && /* @__PURE__ */ r.createElement(Bc, null, /* @__PURE__ */ r.createElement(w, { variant: "h1", color: d.themedColor.textHighEmphasis }, c.FILE_VIEWER__UNSUPPORT)))));
3573
+ }, hr = ({
3574
+ className: e,
3575
+ locale: t,
3576
+ date: n = Date.now(),
3577
+ formatString: o = "MMMM dd, yyyy",
3578
+ style: s
3579
+ }) => /* @__PURE__ */ r.createElement(Vc, { id: `${re}-date-separator`, style: s, className: e }, /* @__PURE__ */ r.createElement(w, { variant: "caption4", color: d.themedColor.textMidEmphasis }, kn(n, o, { locale: t }))), Vc = m.div`display:flex;justify-content:center;align-items:center;`, zc = Se(function(t, n) {
3580
+ const {
3581
+ messages: o,
3582
+ renderMessage: s,
3583
+ messageTopArea: i,
3584
+ messageBottomArea: a,
3585
+ overlayArea: l,
3586
+ onLoadPrev: c,
3587
+ onLoadNext: u,
3588
+ loadThreshold: b = 0.05,
3589
+ onScrollPosition: g = Oe,
3590
+ depsForResetScrollPositionToBottom: x,
3591
+ scrollPositionRef: y,
3592
+ scrollDistanceFromBottomRef: E,
3593
+ stackDirection: f = "top"
3594
+ } = t, h = n && "current" in n ? n : { current: null }, p = B(!1), v = B(void 0), S = B(0), M = B(0), P = B(0), I = y ?? M, Y = E ?? P;
3595
+ de(() => {
3596
+ h.current && (h.current.scrollTop = h.current.scrollHeight);
3597
+ }, x), de(() => {
3598
+ h.current && (v.current === "top" && (h.current.scrollTop = h.current.scrollHeight - I.current), v.current === "bottom" && (h.current.scrollTop = S.current), v.current = void 0);
3599
+ }, [h.current, o.length]);
3600
+ const G = async () => {
3601
+ if (!h.current) return;
3602
+ const C = h.current;
3603
+ if (g(Wc(C)), I.current = C.scrollHeight - C.scrollTop, Y.current = I.current - C.clientHeight, S.current = C.scrollTop, p.current) return;
3604
+ const U = C.clientHeight * Math.min(Math.max(0, b), 1);
3605
+ C.scrollTop <= U ? (p.current = !0, v.current = "top", await c(), p.current = !1) : C.scrollHeight - C.scrollTop - C.clientHeight <= U ? (p.current = !0, v.current = "bottom", await u(), p.current = !1) : v.current = void 0;
3606
+ };
3607
+ return /* @__PURE__ */ r.createElement(Gc, { id: "infinite-list-container" }, /* @__PURE__ */ r.createElement(jc, { id: "infinite-list-inner", ref: h, onScroll: G }, f === "bottom" && /* @__PURE__ */ r.createElement("div", { style: { flexGrow: 1 } }), i, o.map((C, U) => s({ message: C, index: U })), a), /* @__PURE__ */ r.createElement(Kc, { id: "infinite-list-overlay-container" }, /* @__PURE__ */ r.createElement(qc, { id: "infinite-list-overlay" }, l)));
3608
+ }), bn = 50;
3609
+ function Wc(e) {
3610
+ return e.scrollTop <= bn ? "top" : e.scrollHeight - (e.scrollTop + e.clientHeight) <= bn ? "bottom" : "middle";
3611
+ }
3612
+ const Gc = m.div`display:flex;position:relative;flex:1;overflow:hidden;`, jc = 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;}`, Kc = m.div`position:absolute;top:0;bottom:0;left:0;right:0;pointer-events:none;`, qc = m.div`pointer-events:auto;`, Zc = ({ className: e, onClick: t }) => /* @__PURE__ */ r.createElement(Yc, { className: e, onClick: t, tabIndex: 0 }, /* @__PURE__ */ r.createElement(O, { size: 24, type: "chevron-down", color: d.color.primary.main })), Yc = 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);${k.light`
3613
+ background-color: ${d.color.background50};
3614
+ &:hover {
3615
+ background-color: ${d.color.background100};
3616
+ }
3617
+ &:active {
3618
+ background-color: ${d.color.background200};
3619
+ }
3620
+ `}
3621
+ ${k.dark`
3622
+ background-color: ${d.color.background400};
3623
+ &:hover {
3624
+ background-color: ${d.color.background500};
3625
+ }
3626
+ &:active {
3627
+ background-color: ${d.color.background700};
3628
+ }
3629
+ `}
3630
+
3631
+ &:focus {
3632
+ outline: none;
3633
+ }
3634
+ `, gr = () => {
3635
+ const { chatSDK: e } = V(), { channelSource: t } = Z(), [n, o] = T([]);
3636
+ return et(e, {
3637
+ onTypingStatusUpdated(s) {
3638
+ var i;
3639
+ if (s.url === ((i = t.channel) == null ? void 0 : i.url)) {
3640
+ const a = s.getTypingUsers();
3641
+ o(a);
3642
+ }
3643
+ }
3644
+ }), n;
3645
+ }, Jc = () => {
3646
+ const { agentPreviewConfigs: e = {}, aiAgentId: t } = V(), { aiAgentInfo: n } = H(), { stringSet: o, dateLocale: s } = L(), { messageSource: i } = Z(), { Template: a } = ye.useContext(), l = e.welcomeMessages ?? [], c = i.messages, u = lc(c, t), b = c[u.length + 1], g = u[0] ?? b;
3647
+ return {
3648
+ /**
3649
+ * Returns a list of messages filtered according to business requirements.
3650
+ */
3651
+ filteredMessages: c.filter((x) => dc(x) ? !1 : l.length > 0 ? !we.isWelcomeMessage(x, t) : !0),
3652
+ /**
3653
+ * Determines whether to display the DateSeparator in the data list by comparing it with the welcome messages from Bot Studio.
3654
+ */
3655
+ shouldShowOriginalDate: (x) => x > 0 || l.length === 0 ? !0 : b && !jr(b.createdAt, (g == null ? void 0 : g.createdAt) ?? 0),
3656
+ /**
3657
+ * Renders the list of welcome messages from Bot Studio.
3658
+ */
3659
+ renderAgentPreviewWelcomeMessages: () => l.length === 0 ? null : /* @__PURE__ */ r.createElement(r.Fragment, null, /* @__PURE__ */ r.createElement(
3660
+ hr,
3661
+ {
3662
+ style: { margin: "16px 0" },
3663
+ date: g == null ? void 0 : g.createdAt,
3664
+ locale: s,
3665
+ formatString: o.DATE_FORMAT__MESSAGE_LIST__DATE_SEPARATOR
3666
+ }
3667
+ ), l.map((x, y) => {
3668
+ const E = y === l.length - 1, f = u.length !== c.length, h = l.length === 1 ? "single" : y === 0 ? "top" : E || f ? "bottom" : "middle";
3669
+ return /* @__PURE__ */ r.createElement(
3670
+ a,
3671
+ {
3672
+ messageType: "user",
3673
+ message: x.message,
3674
+ sender: n,
3675
+ groupType: h,
3676
+ createdAt: (g == null ? void 0 : g.createdAt) ?? Date.now(),
3677
+ extendedMessagePayload: { suggested_replies: x.suggestedReplies },
3678
+ suggestedRepliesDirection: e.suggestedRepliesDirection,
3679
+ suggestedRepliesVisible: E && !f,
3680
+ isBotMessage: !0,
3681
+ onClickSuggestedReply: async ({ reply: p }) => {
3682
+ i.sendUserMessage({ message: p });
3683
+ }
3684
+ }
3685
+ );
3686
+ }))
3687
+ };
3688
+ }, Xc = (e) => m(e).withConfig({ shouldForwardProp: ao });
3689
+ function Qc(e) {
3690
+ var o;
3691
+ const t = "remove_powered_by", n = (o = e == null ? void 0 : e.appInfo) == null ? void 0 : o.applicationAttributes;
3692
+ return Array.isArray(n) && n.includes(t);
3693
+ }
3694
+ const ed = ({ style: e }) => {
3695
+ const { stringSet: t } = L(), { chatSDK: n } = V(), { isActionbookTester: o } = Ne();
3696
+ return Qc(n) || o ? null : /* @__PURE__ */ r.createElement(td, { variant: "caption2", style: e }, t.POWERED_BY + " ", /* @__PURE__ */ r.createElement(
3697
+ nd,
3698
+ {
3699
+ variant: "caption2",
3700
+ as: "a",
3701
+ href: "https://sendbird.com?utm_medium=product&utm_source=aiagent&utm_campaign=fy26-glbl-ai-agent-poweredby",
3702
+ "aria-label": "Learn more about Sendbird",
3703
+ rel: kt,
3704
+ target: "_blank"
3705
+ },
3706
+ "Sendbird"
3707
+ ));
3708
+ }, td = m(w)`color:${d.themedColor.textLowEmphasis};text-align:center;`, nd = Xc(w)`
3709
+ color: ${d.themedColor.textLowEmphasis};
3710
+ cursor: pointer;
3711
+ text-decoration: none;
3712
+ `, rd = () => {
3713
+ var c;
3714
+ const { stringSet: e } = L(), { activeChannel: t } = H(), { channelSource: n, goToActiveConversation: o, scrollSource: s } = Z(), i = Dt(n.channel), l = t && ((c = n.channel) == null ? void 0 : c.url) === (t == null ? void 0 : t.url) && i;
3715
+ return de(() => {
3716
+ l && s.scrollPubSub.publish({ type: "scrollToBottom", data: { animated: !0 } });
3717
+ }, [l]), l ? /* @__PURE__ */ r.createElement(od, null, /* @__PURE__ */ r.createElement(
3718
+ sd,
3719
+ {
3720
+ variant: "button",
3721
+ role: "button",
3722
+ color: d.themedColor.textHighEmphasis,
3723
+ onClick: () => o()
3724
+ },
3725
+ e.START_NEW_CONVERSATION
3726
+ )) : null;
3727
+ }, od = m.div`display:flex;justify-content:center;margin:16px 0;`, sd = m(w)`border-radius:6px;box-sizing:border-box;padding:10px 20px;border:1px solid ${d.themedColor.textDisabled};cursor:pointer;user-select:none;`, id = !0, ad = () => {
3728
+ const { Template: e } = Bt.useContext(), { Template: t } = ye.useContext(), { Template: n } = Pt.useContext(), [o, s] = T(null), { userSession: i, aiAgentInfo: a } = H(), { cache: l, agentPreviewConfigs: c, chatSDK: u, state: b } = V(), { stringSet: g, dateLocale: x } = L(), { conversation: y, channelSource: E, messageSource: f, scrollSource: h } = Z(), { isActionbookTester: p } = Ne(), { filteredMessages: v, shouldShowOriginalDate: S, renderAgentPreviewWelcomeMessages: M } = Jc(), P = gr(), I = ir(() => {
3729
+ const C = P[0];
3730
+ if (!C) return null;
3731
+ const U = C.userId === a.userId;
3732
+ return { user: U ? a : C, isBot: U };
3733
+ });
3734
+ R(() => {
3735
+ I && h.scrollPubSub.publish({ type: "scrollToBottom", data: { animated: !0 } });
3736
+ }, [!!I, h.scrollPubSub.publish]);
3737
+ const Y = (C, U = !1) => {
3738
+ var te;
3739
+ return U ? a : ((te = E.channel) == null ? void 0 : te.members.find((J) => J.userId === C.sender.userId)) ?? C.sender;
3740
+ }, G = () => {
3741
+ if (!f.initialized)
3742
+ return /* @__PURE__ */ r.createElement(Ce, { type: "loading" });
3743
+ if (f.messages.length === 0) {
3744
+ const C = M();
3745
+ return C ? /* @__PURE__ */ r.createElement("div", { style: { width: "100%" } }, C) : /* @__PURE__ */ r.createElement(Ce, { type: "noMessages", label: g.PLACE_HOLDER__NO_MESSAGES });
3746
+ }
3747
+ return /* @__PURE__ */ r.createElement(
3748
+ zc,
3749
+ {
3750
+ ref: h.scrollRef,
3751
+ scrollPositionRef: h.scrollPositionRef,
3752
+ scrollDistanceFromBottomRef: h.scrollDistanceFromBottomRef,
3753
+ onScrollPosition: (C) => h.setIsScrollBottomReached(C === "bottom"),
3754
+ stackDirection: c == null ? void 0 : c.messageStackDirection,
3755
+ messages: v,
3756
+ onLoadPrev: f.loadPrevious,
3757
+ onLoadNext: f.loadNext,
3758
+ depsForResetScrollPositionToBottom: [f.initialized, f.messages.length !== 0],
3759
+ messageTopArea: /* @__PURE__ */ r.createElement(r.Fragment, null, /* @__PURE__ */ r.createElement(ed, { style: { marginTop: 16 } }), M()),
3760
+ messageBottomArea: /* @__PURE__ */ r.createElement(r.Fragment, null, I && /* @__PURE__ */ r.createElement(
3761
+ t,
3762
+ {
3763
+ isTyping: !0,
3764
+ isBotMessage: I.isBot,
3765
+ sender: I.user,
3766
+ messageType: "user",
3767
+ groupType: "single",
3768
+ message: ""
3769
+ }
3770
+ ), /* @__PURE__ */ r.createElement(rd, null)),
3771
+ overlayArea: /* @__PURE__ */ r.createElement(r.Fragment, null, !h.isScrollBottomReached && /* @__PURE__ */ r.createElement(cd, { onClick: () => h.scrollPubSub.publish({ type: "scrollToBottom" }) })),
3772
+ renderMessage: ({ message: C, index: U }) => {
3773
+ const te = ic(C), J = v[U - 1], ke = v[U + 1], ot = v[v.length - 1], st = C === ot, $ = ac(C, J, ke, id), N = !io((J == null ? void 0 : J.createdAt) ?? 0, C.createdAt) && S(U) && !p, K = (Pe) => {
3774
+ (C.isFileMessage() || C.isUserMessage()) && s({ file: Pe, sender: Y(C, C.sender.userId === a.userId) });
3775
+ }, ne = () => {
3776
+ C.isFileMessage() && Rt(C.url);
3777
+ }, Ee = N ? /* @__PURE__ */ r.createElement(
3778
+ hr,
3779
+ {
3780
+ style: { margin: "16px 0" },
3781
+ date: C.createdAt,
3782
+ locale: x,
3783
+ formatString: g.DATE_FORMAT__MESSAGE_LIST__DATE_SEPARATOR
3784
+ }
3785
+ ) : null, Be = {
3786
+ maxBodyWidth: b.expanded ? Wn : void 0,
3787
+ extendedMessagePayload: C.extendedMessagePayload,
3788
+ createdAt: C.createdAt,
3789
+ groupType: $,
3790
+ onClickMedia: K,
3791
+ onClickFile: ne
3792
+ }, Mr = (() => {
3793
+ var Pe, jt;
3794
+ if (Ge.isAdmin(C))
3795
+ return Ge.isCSAT(C) ? y ? /* @__PURE__ */ r.createElement(
3796
+ n,
3797
+ {
3798
+ ...Be,
3799
+ ...y,
3800
+ isResolvedWhenDeterminedByUser: dd(y),
3801
+ messageType: "admin.csat",
3802
+ onSubmitCSAT: ({ csat: ce, csatType: he, csatReason: F, isResolved: X }) => {
3803
+ var ge;
3804
+ ce && ((ge = E.channel) == null || ge.submitCSAT({ csat: ce, csatType: he, csatReason: F, isResolved: X }));
3805
+ }
3806
+ }
3807
+ ) : null : /* @__PURE__ */ r.createElement(n, { ...Be, messageType: "admin", message: C.message });
3808
+ if (Ge.isOutgoing(C, i.userId)) {
3809
+ const ce = {
3810
+ ...Be,
3811
+ message: C.message,
3812
+ sender: Y(C),
3813
+ sendingStatus: C.sendingStatus
3814
+ };
3815
+ if (C.isUserMessage())
3816
+ return /* @__PURE__ */ r.createElement(e, { messageType: "user", ...ce });
3817
+ if (C.isFileMessage()) {
3818
+ const [he, F] = ((Pe = C.metaArrays.find((X) => X.key === dr)) == null ? void 0 : Pe.value) ?? [];
3819
+ return /* @__PURE__ */ r.createElement(
3820
+ e,
3821
+ {
3822
+ messageType: "file",
3823
+ file: C,
3824
+ metadata: {
3825
+ aspectRatio: he && F ? `${he}/${F}` : "1/1",
3826
+ localFile: (jt = C.messageParams) == null ? void 0 : jt.file
3827
+ },
3828
+ ...ce
3829
+ }
3830
+ );
3831
+ }
3832
+ }
3833
+ if (Ge.isIncoming(C, i.userId)) {
3834
+ const ce = C.sender.userId === a.userId, he = {
3835
+ ...Be,
3836
+ sender: Y(C, ce),
3837
+ message: C.message,
3838
+ suggestedRepliesVisible: st,
3839
+ suggestedRepliesDirection: c == null ? void 0 : c.suggestedRepliesDirection,
3840
+ isBotMessage: ce,
3841
+ isStreaming: we.isStreaming(C),
3842
+ isHandedOff: Nt(E.channel),
3843
+ isConversationClosed: Dt(E.channel),
3844
+ onClickSuggestedReply: async ({ reply: F }) => {
3845
+ f.sendUserMessage({ message: F });
3846
+ },
3847
+ onRequestMessageTemplate: async (F) => {
3848
+ const { template: X } = await u.aiAgent.getMessageTemplate(F);
3849
+ return l.template.set(F, X), X;
3850
+ },
3851
+ onGetCachedMessageTemplate: (F) => l.template.get(F),
3852
+ onHandleTemplateInternalAction: (F) => {
3853
+ if (F.type === "internal" && F.internalData) {
3854
+ const { method: X, payload: ge } = F.internalData;
3855
+ X === "message.send" && (ge != null && ge.message) && f.sendUserMessage({ message: ge.message });
3856
+ }
3857
+ },
3858
+ onSubmitForm: ({ key: F, data: X }) => u.aiAgent.submitForm({
3859
+ messageId: C.messageId,
3860
+ channelUrl: C.channelUrl,
3861
+ formKey: F,
3862
+ formData: X
3863
+ }),
3864
+ onCancelForm: ({ key: F }) => u.aiAgent.cancelForm({
3865
+ messageId: C.messageId,
3866
+ channelUrl: C.channelUrl,
3867
+ formKey: F
3868
+ })
3869
+ };
3870
+ if (C.isUserMessage())
3871
+ return /* @__PURE__ */ r.createElement(t, { messageType: "user", ...he });
3872
+ if (C.isFileMessage())
3873
+ return /* @__PURE__ */ r.createElement(t, { messageType: "file", file: C, ...he });
3874
+ }
3875
+ })();
3876
+ return /* @__PURE__ */ r.createElement("div", { key: te, id: `${re}-message-item` }, Ee, Mr);
3877
+ }
3878
+ }
3879
+ );
3880
+ };
3881
+ return /* @__PURE__ */ r.createElement(ld, { id: `${re}-message-list` }, G(), o && /* @__PURE__ */ r.createElement(Pc, { onClose: () => s(null), sender: o.sender, file: o.file }));
3882
+ }, ld = m.div`overflow-y:hidden;display:flex;flex:1;position:relative;`, cd = m(Zc)`position:absolute;bottom:20px;inset-inline-end:20px;`;
3883
+ function dd(e) {
3884
+ var t;
3885
+ if (((t = e == null ? void 0 : e.resolution) == null ? void 0 : t.determinedBy) === "user")
3886
+ return e.resolution.isResolved;
3887
+ }
3888
+ const ud = () => {
3889
+ const { stringSet: e } = L(), { connectionError: t } = H(), { channelSource: n } = Z(), o = t || n.error;
3890
+ if (o) {
3891
+ const s = t ? void 0 : { label: e.RETRY, onClick: () => n.refetch() };
3892
+ return /* @__PURE__ */ r.createElement(Ce, { type: "error", label: o.message, action: s });
3893
+ }
3894
+ return n.channel ? /* @__PURE__ */ r.createElement(ad, null) : /* @__PURE__ */ r.createElement(Ce, { type: "loading" });
3895
+ }, pr = () => {
3896
+ const { stringSet: e } = L(), { activeChannel: t } = H(), [n] = T(() => (t == null ? void 0 : t.status) === z.OPEN);
3897
+ return n ? e.RETURN_TO_CONVERSATION : e.START_NEW_CONVERSATION;
3898
+ }, md = () => {
3899
+ const { stringSet: e } = L(), { goToActiveConversation: t } = Z(), n = pr();
3900
+ return /* @__PURE__ */ r.createElement(hd, null, /* @__PURE__ */ r.createElement(w, { variant: "body1", color: d.themedColor.textMidEmphasis }, e.CONVERSATION_CLOSED_FOOTER_LABEL), /* @__PURE__ */ r.createElement(gd, { onClick: t }, /* @__PURE__ */ r.createElement(w, { variant: "button", color: d.themedColor.textHighEmphasis }, n)));
3901
+ }, hd = m.div`display:flex;flex-direction:column;align-items:center;justify-content:center;padding:32px 0;gap:14px;${k.light`
3902
+ background-color: ${d.color.background100};
3903
+ `}
3904
+ ${k.dark`
3905
+ background-color: ${d.color.background500};
3906
+ `}
3907
+ `, gd = m.button`all:unset;padding:10px 20px;border-radius:6px;border:1px solid ${d.themedColor.textDisabled};cursor:pointer;${k.light`
3908
+ background-color: ${d.color.background50};
3909
+ `}
3910
+ ${k.dark`
3911
+ background-color: ${d.color.background700};
3912
+ `}
3913
+ `, fr = _e(void 0), pd = ({ children: e }) => {
3914
+ const { stringSet: t } = L(), { attachmentMode: n } = H(), { channelSource: o } = Z(), [s, i] = T([]), [a, l] = T({
3915
+ visible: !1,
3916
+ title: ""
3917
+ }), c = Nt(o.channel), u = Q(() => {
3918
+ switch (n) {
3919
+ case qe.OFF:
3920
+ return !1;
3921
+ case qe.ALWAYS:
3922
+ return !0;
3923
+ case qe.HANDED_OFF_ONLY:
3924
+ return c;
3925
+ default:
3926
+ return c;
3927
+ }
3928
+ }, [n, c]), b = (y) => {
3929
+ if (!u) return;
3930
+ const E = y.filter((f) => zn.includes(f.type));
3931
+ if (E.length !== 0) {
3932
+ if (E.some((f) => f.size > Zs)) {
3933
+ l({
3934
+ visible: !0,
3935
+ title: t.FILE_UPLOAD_NOTIFICATION__SIZE_LIMIT.replace("%d", "25")
3936
+ });
3937
+ return;
3938
+ }
3939
+ if (E.length > 1 || E.length > 0 && s.length > 0) {
3940
+ l({
3941
+ visible: !0,
3942
+ title: t.FILE_UPLOAD_NOTIFICATION__COUNT_LIMIT
3943
+ });
3944
+ return;
3945
+ }
3946
+ i((f) => [
3947
+ ...f,
3948
+ ...E.map((h) => ({
3949
+ file: h,
3950
+ preview: { url: URL.createObjectURL(h), type: h.type, name: h.name }
3951
+ }))
3952
+ ]);
3953
+ }
3954
+ }, g = (y) => {
3955
+ i((E) => {
3956
+ var h;
3957
+ const f = (h = E[y]) == null ? void 0 : h.preview;
3958
+ return f && URL.revokeObjectURL(f.url), E.filter((p, v) => v !== y);
3959
+ });
3960
+ }, x = () => {
3961
+ i((y) => (y.forEach((E) => URL.revokeObjectURL(E.preview.url)), []));
3962
+ };
3963
+ return /* @__PURE__ */ r.createElement(
3964
+ fr.Provider,
3965
+ {
3966
+ value: {
3967
+ files: s,
3968
+ addFiles: b,
3969
+ removeFile: g,
3970
+ clearFiles: x,
3971
+ isFileUploadEnabled: u
3972
+ }
3973
+ },
3974
+ e,
3975
+ /* @__PURE__ */ r.createElement(Yn, { ...a, onClose: () => l({ visible: !1, title: "" }) })
3976
+ );
3977
+ }, Vt = () => {
3978
+ const e = se(fr);
3979
+ if (!e)
3980
+ throw new Error("useFileUpload must be used within FileUploadProvider");
3981
+ return e;
3982
+ };
3983
+ function fd({ blurred: e, elementRef: t, document: n = window.document }) {
3984
+ const o = B(!1);
3985
+ e && t.current && n.activeElement === t.current && (o.current = !0), de(() => {
3986
+ var s;
3987
+ !e && o.current && ((s = t.current) == null || s.focus(), o.current = !1);
3988
+ }, [e]);
3989
+ }
3990
+ const bd = (e, t) => {
3991
+ R(() => {
3992
+ t ? e == null || e.startTyping() : e == null || e.endTyping();
3993
+ }, [e, t]);
3994
+ }, 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%;${k.light`
3995
+ background-color: ${d.color.background50};
3996
+ `}
3997
+ ${k.dark`
3998
+ background-color: ${d.color.background500};
3999
+ `}
4000
+ path {
4001
+ fill: ${d.themedColor.textMidEmphasis};
4002
+ }
4003
+
4004
+ &:hover {
4005
+ path {
4006
+ fill: ${d.themedColor.textHighEmphasis};
4007
+ }
4008
+ }
4009
+
4010
+ circle {
4011
+ stroke: ${d.themedColor.bg_50_600};
4012
+ }
4013
+ `, yd = () => {
4014
+ const e = De(), [t, n] = T(), { files: o, removeFile: s, isFileUploadEnabled: i } = Vt();
4015
+ 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(Mt, { name: l, type: It(l, a) }))));
4016
+ }, Cd = ({ channel: e, messages: t }) => {
4017
+ const { stringSet: n } = L(), { aiAgentInfo: o, userSession: s } = H(), i = _d(), a = Sd({
4018
+ lastMessage: t[t.length - 1],
4019
+ aiAgentUserId: o.userId
4020
+ }), l = Ad({
4021
+ isDisabledWhileAIResponding: a,
4022
+ lastMessage: t[t.length - 1],
4023
+ currentUserId: s.userId
4024
+ });
4025
+ return !e || !i || Dt(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];
4026
+ }, _d = () => {
4027
+ const e = Ct(), { chatSDK: t } = V(), [n, o] = T(!0);
4028
+ return R(() => {
4029
+ const s = new Qe({
4030
+ onDisconnected: () => o(!1),
4031
+ onConnected: () => o(!0),
4032
+ onReconnectSucceeded: () => o(!0)
4033
+ });
4034
+ return t.addConnectionHandler(e, s), () => {
4035
+ t.removeConnectionHandler(e);
4036
+ };
4037
+ }, [t]), n;
4038
+ }, Sd = ({
4039
+ lastMessage: e,
4040
+ aiAgentUserId: t
4041
+ }) => {
4042
+ const [n, o] = T(!1), s = gr();
4043
+ return R(() => {
4044
+ if (!e) return;
4045
+ const i = s.some((l) => l.userId === t), a = Ut(e, t) && we.isStreaming(e);
4046
+ o(!!(a || i));
4047
+ }, [s, e, t]), n;
4048
+ }, Td = (e) => {
4049
+ var a;
4050
+ const t = e == null ? void 0 : e.lastMessage;
4051
+ if (!t || !e) return !1;
4052
+ 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);
4053
+ return s && !i;
4054
+ }, wd = 3e4, Ad = ({
4055
+ lastMessage: e,
4056
+ isDisabledWhileAIResponding: t,
4057
+ currentUserId: n
4058
+ }) => {
4059
+ const [o, s] = T(!1), i = B(null), a = e && Ut(e, n) ? e.createdAt : 0;
4060
+ return R(() => {
4061
+ const l = () => {
4062
+ i.current && (clearTimeout(i.current), i.current = null), s(!1);
4063
+ }, c = (g) => {
4064
+ i.current && clearTimeout(i.current), s(!0), i.current = setTimeout(() => {
4065
+ s(!1), i.current = null;
4066
+ }, g);
4067
+ }, u = Date.now() - a, b = wd - u;
4068
+ return t || b <= 0 ? l() : c(b), () => {
4069
+ i.current && clearTimeout(i.current);
4070
+ };
4071
+ }, [t, a]), o;
4072
+ }, br = {
4073
+ textArea: _`min-height:40px;height:40px;font-size:16px;line-height:24px;`,
4074
+ attachIcon: _`margin-bottom:4px;`
4075
+ }, 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};}}${At && br.attachIcon};`, $d = m.input`display:none;`, xn = m.div`width:100%;position:relative;background-color:${d.themedColor.bg_100_500};border-radius:20px;`, En = m.div`display:flex;flex-direction:row;align-items:flex-end;position:relative;`, vn = 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:${Vn}px;overflow-wrap:break-word;white-space:pre-wrap;overflow-x:hidden;${At && br.textArea};&::placeholder{color:${d.themedColor.textLowEmphasis};}&:disabled{cursor:not-allowed;&::placeholder{color:${d.themedColor.textDisabled};}}`, yn = m.div`padding:12px 16px;position:relative;display:flex;align-items:center;`, Cn = ({ disabled: e }) => {
4076
+ const t = B(null), { addFiles: n, clearFiles: o, files: s, isFileUploadEnabled: i } = Vt();
4077
+ return !i || s.length > 0 ? null : /* @__PURE__ */ r.createElement(
4078
+ kd,
4079
+ {
4080
+ disabled: e,
4081
+ onClick: () => {
4082
+ var a;
4083
+ o(), (a = t.current) == null || a.click();
4084
+ }
4085
+ },
4086
+ /* @__PURE__ */ r.createElement(
4087
+ O,
4088
+ {
4089
+ type: "attach",
4090
+ color: e ? d.themedColor.textDisabled : d.themedColor.textMidEmphasis,
4091
+ size: 16
4092
+ }
4093
+ ),
4094
+ /* @__PURE__ */ r.createElement(
4095
+ $d,
4096
+ {
4097
+ type: "file",
4098
+ ref: t,
4099
+ onChange: (a) => {
4100
+ const l = a.currentTarget.files;
4101
+ l && n(Array.from(l)), a.target.value = "";
4102
+ },
4103
+ accept: zn.join(",")
4104
+ }
4105
+ )
4106
+ );
4107
+ }, Id = () => {
4108
+ const e = B(null), [t, n] = T(""), { rootElement: o } = V(), { channelSource: s, messageSource: i } = Z(), [a, l] = Cd({
4109
+ channel: s.channel,
4110
+ messages: i.messages
4111
+ }), { files: c, addFiles: u, clearFiles: b } = Vt();
4112
+ vc({ onDropFiles: u }), fd({ blurred: a, elementRef: e, document: fe(o) }), bd(s.channel, t);
4113
+ const g = t.trim().length > 0, x = c.length > 0, y = !a && (g || x), E = () => {
4114
+ e.current && (e.current.value = "", e.current.style.height = ""), b(), n("");
4115
+ }, f = async () => {
4116
+ const S = t.trim(), M = { message: S };
4117
+ if (!(!S && !c.length)) {
4118
+ if (c.length > 0) {
4119
+ const P = c[0].file, I = { ...M, file: P };
4120
+ i.sendFileMessage(I), E();
4121
+ return;
4122
+ }
4123
+ i.sendUserMessage(M), E();
4124
+ }
4125
+ }, h = (S) => {
4126
+ const M = Array.from(S.clipboardData.files);
4127
+ M.length > 0 && (S.preventDefault(), u(M));
4128
+ }, p = (S) => {
4129
+ S.key !== "Enter" || S.nativeEvent.isComposing || S.shiftKey || (S.preventDefault(), f());
4130
+ }, v = (S) => {
4131
+ if (e.current) {
4132
+ e.current.style.height = "";
4133
+ const M = Math.min(qs, e.current.scrollHeight);
4134
+ Vn < M && (e.current.style.height = `${M}px`);
4135
+ }
4136
+ n(S.target.value);
4137
+ };
4138
+ return a ? /* @__PURE__ */ r.createElement(yn, null, /* @__PURE__ */ r.createElement(xn, null, /* @__PURE__ */ r.createElement(En, null, /* @__PURE__ */ r.createElement(vn, { disabled: !0, placeholder: l }), /* @__PURE__ */ r.createElement(Cn, { disabled: !0 })))) : /* @__PURE__ */ r.createElement(yn, null, /* @__PURE__ */ r.createElement(xn, null, /* @__PURE__ */ r.createElement(yd, null), /* @__PURE__ */ r.createElement(En, null, /* @__PURE__ */ r.createElement(
4139
+ vn,
4140
+ {
4141
+ ref: e,
4142
+ role: "textbox",
4143
+ "aria-label": "Text Input",
4144
+ placeholder: l,
4145
+ maxLength: 5e3,
4146
+ onKeyDown: p,
4147
+ onChange: v,
4148
+ onPaste: h
4149
+ }
4150
+ ), /* @__PURE__ */ r.createElement(Cn, null))), y && /* @__PURE__ */ r.createElement(xr, { onClick: () => f() }, /* @__PURE__ */ r.createElement(O, { type: "send", color: d.color.primary.main, size: 20 })));
4151
+ }, 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;${k.light`
4152
+ color: ${d.color.information.light};
4153
+ `};
4154
+ ${k.dark`
4155
+ color: ${d.color.information.main};
4156
+ `};
4157
+ }
4158
+ `, Od = A(() => import("./DAj-QM_C.js").then((e) => ({ default: e.MarkdownText }))), Ld = () => {
4159
+ const { aiAgentInfo: e } = H(), { messageSource: t } = Z(), { userSession: n } = H();
4160
+ return !e.specialNoticeEnabled || !e.specialNotice || !(t.initialized && !t.messages.some((s) => Ut(s, n.userId))) ? null : /* @__PURE__ */ r.createElement(Md, null, /* @__PURE__ */ r.createElement(Od, null, e.specialNotice));
4161
+ }, Rd = () => /* @__PURE__ */ r.createElement(Dd, null, /* @__PURE__ */ r.createElement(Ld, null), /* @__PURE__ */ r.createElement(pd, null, /* @__PURE__ */ r.createElement(Id, null))), Dd = m.div`z-index:0;border:none;width:100%;`, Nd = () => {
4162
+ var i, a, l;
4163
+ const { activeChannel: e } = H(), { channelSource: t } = Z(), n = ((a = (i = t.channel) == null ? void 0 : i.conversation) == null ? void 0 : a.status) === z.CLOSED;
4164
+ return !(((l = t.channel) == null ? void 0 : l.url) === (e == null ? void 0 : e.url)) && n ? /* @__PURE__ */ r.createElement(md, null) : /* @__PURE__ */ r.createElement(Rd, null);
4165
+ }, Fd = () => {
4166
+ var v;
4167
+ const { state: e, logger: t, enableCloseConversationButton: n, enableExpandButton: o, dispatcher: s } = V(), { stringSet: i } = L(), { aiAgentInfo: a, activeChannel: l } = H(), { channelSource: c, onNavigateToConversationList: u } = Z(), b = c.channel, x = De() ? 24 : 16, y = () => {
4168
+ e.setOpened(!1);
4169
+ }, E = async () => {
4170
+ try {
4171
+ const S = await (b == null ? void 0 : b.markConversationAsHandoff());
4172
+ t.info("conversation.handleAgentHandoff: success", S);
4173
+ } catch (S) {
4174
+ t.error("conversation.handleAgentHandoff: error", S);
4175
+ }
4176
+ }, f = async () => {
4177
+ b && await s.send(vo.CloseConversation({ channelUrl: b.url }));
4178
+ }, h = l && (b == null ? void 0 : b.url) === l.url, p = a.showHandoffButton && !!((v = b == null ? void 0 : b.conversation) != null && v.handoff) && h;
4179
+ 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 })), h && /* @__PURE__ */ r.createElement(ur, { size: 34 }), /* @__PURE__ */ r.createElement(Gd, { variant: "h2", color: d.themedColor.textHighEmphasis }, a.nickname || (b == null ? void 0 : b.name))), /* @__PURE__ */ r.createElement(Wd, null, p && /* @__PURE__ */ r.createElement(
4180
+ Hd,
4181
+ {
4182
+ tooltipLabel: i.HEADER_BUTTON__AGENT_HANDOFF,
4183
+ disabled: !Ii(b),
4184
+ size: x,
4185
+ onClick: E
4186
+ }
4187
+ ), n && /* @__PURE__ */ r.createElement(
4188
+ Ud,
4189
+ {
4190
+ disabled: !qn(b),
4191
+ size: x,
4192
+ onClick: f
4193
+ }
4194
+ ), o && /* @__PURE__ */ r.createElement(Bd, { size: x }), /* @__PURE__ */ r.createElement(Pd, { size: x, onClick: y })));
4195
+ }, Bd = ({ size: e, disabled: t }) => {
4196
+ const { state: n } = V();
4197
+ 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 }));
4198
+ }, 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(
4199
+ O,
4200
+ {
4201
+ type: "refresh",
4202
+ size: e,
4203
+ color: t ? d.themedColor.textDisabled : d.themedColor.textHighEmphasis
4204
+ }
4205
+ )), Hd = ({ size: e, onClick: t, disabled: n, tooltipLabel: o }) => /* @__PURE__ */ r.createElement(sr, { label: o, position: "bottom", disabled: n }, /* @__PURE__ */ r.createElement(Fe, { "aria-label": "agent", onClick: t, disabled: n }, /* @__PURE__ */ r.createElement(
4206
+ O,
4207
+ {
4208
+ type: "agent",
4209
+ size: e,
4210
+ color: n ? d.themedColor.textDisabled : d.themedColor.textHighEmphasis
4211
+ }
4212
+ ))), 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 = () => {
4213
+ const { isActionbookTester: e } = Ne();
4214
+ return e ? null : /* @__PURE__ */ r.createElement(Fd, null);
4215
+ }, _n = ({
4216
+ children: e,
4217
+ onNavigateToConversationList: t,
4218
+ closedChannelUrl: n,
4219
+ onClearClosedChannelUrl: o
4220
+ }) => {
4221
+ const { Template: s } = zt.useContext();
4222
+ return /* @__PURE__ */ r.createElement(
4223
+ Ec,
4224
+ {
4225
+ onNavigateToConversationList: t,
4226
+ closedChannelUrl: n,
4227
+ onClearClosedChannelUrl: o
4228
+ },
4229
+ /* @__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)))
4230
+ );
4231
+ }, zt = Te({
4232
+ template: Kd,
4233
+ components: {
4234
+ Header: jd,
4235
+ Body: ud,
4236
+ Footer: Nd
4237
+ }
4238
+ });
4239
+ function Kd() {
4240
+ const { components: e } = zt.useContext();
4241
+ 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));
4242
+ }
4243
+ const qd = m.div`height:100%;width:100%;display:flex;flex-direction:column;flex:1;background-color:${({ theme: e }) => e.colors.base.background};`, {
4244
+ Provider: Zd,
4245
+ Context: Em,
4246
+ useContext: Er
4247
+ } = W("ConversationList");
4248
+ function Yd({
4249
+ conversationListLimit: e,
4250
+ conversationListFilter: t,
4251
+ onOpenConversationView: n = Oe,
4252
+ children: o
4253
+ }) {
4254
+ return /* @__PURE__ */ r.createElement(
4255
+ rs,
4256
+ {
4257
+ conversationListLimit: e,
4258
+ conversationListFilter: t
4259
+ },
4260
+ (s) => /* @__PURE__ */ r.createElement(Zd, { value: { ...s, onOpenConversationView: n } }, o)
4261
+ );
4262
+ }
4263
+ const vr = Te({
4264
+ template: Jd,
4265
+ // Note: 리스트 변경되면 디자인 변경 가능성이 있어서 일단 컴포넌트는 비워둠
4266
+ components: {}
4267
+ });
4268
+ function Jd({
4269
+ title: e = "",
4270
+ lastMessageTimestamp: t = Date.now(),
4271
+ onClick: n
4272
+ }) {
4273
+ const { stringSet: o, format: s } = L();
4274
+ 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));
4275
+ }
4276
+ 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 }) => {
4277
+ const o = (s) => {
4278
+ const i = s.target;
4279
+ i.scrollHeight - i.scrollTop === i.clientHeight && (n == null || n());
4280
+ };
4281
+ return /* @__PURE__ */ r.createElement(ru, { onScroll: (s) => o(s) }, e.map((s, i) => t(s, i)));
4282
+ }, ru = m.div`width:100%;height:100%;display:flex;flex-direction:column;flex:1;overflow:auto;`, ou = () => {
4283
+ const { stringSet: e } = L(), { listSource: t, onOpenConversationView: n } = Er(), { Template: o } = vr.useContext();
4284
+ return t.initialized ? t.channels.length === 0 ? /* @__PURE__ */ r.createElement(Ce, { type: "noChannels", label: e.CONVERSATION_LIST__NO_CONVERSATIONS }) : /* @__PURE__ */ r.createElement(
4285
+ nu,
4286
+ {
4287
+ items: t.channels,
4288
+ renderItem: (s) => {
4289
+ var i, a, l;
4290
+ return /* @__PURE__ */ r.createElement(
4291
+ o,
4292
+ {
4293
+ key: s.url,
4294
+ channelUrl: s.url,
4295
+ title: (a = (i = s.conversation) == null ? void 0 : i.topics) == null ? void 0 : a.join(", "),
4296
+ lastMessageTimestamp: (l = s.lastMessage) == null ? void 0 : l.createdAt,
4297
+ onClick: () => n(s.url, z.CLOSED),
4298
+ channel: s
4299
+ }
4300
+ );
4301
+ },
4302
+ onEndReached: () => {
4303
+ t.loadMore();
4304
+ }
4305
+ }
4306
+ ) : /* @__PURE__ */ r.createElement(Ce, { type: "loading" });
4307
+ }, su = () => {
4308
+ const { refreshActiveChannel: e } = H(), { onOpenConversationView: t } = Er(), n = pr();
4309
+ return /* @__PURE__ */ r.createElement(
4310
+ iu,
4311
+ {
4312
+ role: "button",
4313
+ onClick: async () => {
4314
+ const o = await e();
4315
+ t(o, z.OPEN);
4316
+ }
4317
+ },
4318
+ /* @__PURE__ */ r.createElement(au, { variant: "h1" }, n)
4319
+ );
4320
+ }, iu = m.div`background-color:${({ theme: e }) => e.colors.base.primary};display:flex;align-items:center;justify-content:center;padding:16px;cursor:pointer;`, au = m(w)`color:${({ theme: e }) => e.colors.base.primaryContrastContent};overflow:hidden;text-overflow:ellipsis;white-space:nowrap;`, lu = () => {
4321
+ const { stringSet: e } = L();
4322
+ return /* @__PURE__ */ r.createElement(cu, null, /* @__PURE__ */ r.createElement(du, { variant: "h2", color: d.themedColor.textHighEmphasis }, e.CONVERSATION_LIST__HEADER_TITLE), /* @__PURE__ */ r.createElement(uu, null));
4323
+ }, cu = 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};`, du = m(w)`padding:0 12px;width:100%;box-sizing:border-box;text-overflow:ellipsis;overflow:hidden;white-space:nowrap;`, uu = m.div`position:absolute;bottom:0;width:100%;height:1px;background-color:${d.themedColor.textDisabled};`, mu = ({
4324
+ conversationListLimit: e,
4325
+ conversationListFilter: t,
4326
+ children: n,
4327
+ onOpenConversationView: o
4328
+ }) => {
4329
+ const { Template: s } = Wt.useContext();
4330
+ return /* @__PURE__ */ r.createElement(
4331
+ Yd,
4332
+ {
4333
+ conversationListLimit: e,
4334
+ conversationListFilter: t,
4335
+ onOpenConversationView: o
4336
+ },
4337
+ /* @__PURE__ */ r.createElement(gu, null, /* @__PURE__ */ r.createElement(s, null)),
4338
+ n
4339
+ );
4340
+ }, Wt = Te({
4341
+ template: hu,
4342
+ components: {
4343
+ Header: lu,
4344
+ Body: ou,
4345
+ Footer: su
4346
+ }
4347
+ });
4348
+ function hu() {
4349
+ const { components: e } = Wt.useContext();
4350
+ 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));
4351
+ }
4352
+ const gu = m.div`height:100%;width:100%;display:flex;flex-direction:column;flex:1;background-color:${({ theme: e }) => e.colors.base.background};`, pu = _`:where(#${ie.ENTRY}) :not(code *){font-family:'Roboto',sans-serif;box-sizing:border-box;}`, fu = [pu, Os, Ls], bu = (e, ...t) => Wr(e, ...fu, ...t), xu = bu``, Eu = lo(
4353
+ zt,
4354
+ ye,
4355
+ Bt,
4356
+ Pt,
4357
+ Wt,
4358
+ vr
4359
+ );
4360
+ function vu({
4361
+ appearance: e,
4362
+ rootElement: t,
4363
+ logger: n,
4364
+ language: o,
4365
+ stringSet: s,
4366
+ children: i,
4367
+ messageTemplate: a,
4368
+ theme: l
4369
+ }) {
4370
+ 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(Eu, null, i, /* @__PURE__ */ r.createElement(xu, null))))));
4371
+ }
4372
+ const je = {}, Ke = {
4373
+ getItem: (e) => {
4374
+ try {
4375
+ return localStorage.getItem(e);
4376
+ } catch {
4377
+ return je[e] ?? null;
4378
+ }
4379
+ },
4380
+ setItem: (e, t) => {
4381
+ try {
4382
+ localStorage.setItem(e, t);
4383
+ } catch {
4384
+ je[e] = t;
4385
+ }
4386
+ },
4387
+ deleteItem: (e) => {
4388
+ try {
4389
+ localStorage.removeItem(e);
4390
+ } catch {
4391
+ delete je[e];
4392
+ }
4393
+ },
4394
+ getKeys: (e) => {
4395
+ try {
4396
+ const t = [];
4397
+ for (let n = 0; n < localStorage.length; n++) {
4398
+ const o = localStorage.key(n);
4399
+ o && o.startsWith(e) && t.push(o);
4400
+ }
4401
+ return t;
4402
+ } catch {
4403
+ return Object.keys(je).filter((t) => t.startsWith(e));
4404
+ }
4405
+ }
4406
+ }, yr = Se(function({
4407
+ rootElement: t = document.body,
4408
+ logLevel: n = wn.WARN,
4409
+ language: o = navigator.language,
4410
+ userSessionInfo: s,
4411
+ children: i,
4412
+ ...a
4413
+ }, l) {
4414
+ var c, u;
4415
+ 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(
4416
+ vu,
4417
+ {
4418
+ logger: $e,
4419
+ rootElement: t,
4420
+ appearance: (c = a.agentPreviewConfigs) == null ? void 0 : c.appearance,
4421
+ stringSet: a.stringSet,
4422
+ language: o,
4423
+ messageTemplate: a.messageTemplate,
4424
+ theme: a.theme
4425
+ },
4426
+ /* @__PURE__ */ r.createElement(
4427
+ Hs,
4428
+ {
4429
+ rootElement: t,
4430
+ keyValueStorage: {
4431
+ get: Ke.getItem,
4432
+ set: Ke.setItem,
4433
+ delete: Ke.deleteItem,
4434
+ getKeys: Ke.getKeys
4435
+ },
4436
+ language: o,
4437
+ logger: $e,
4438
+ dispatcher: yu,
4439
+ chatParams: { customApiHost: a.customApiHost, customWebSocketHost: a.customWebSocketHost },
4440
+ chatSDK: a.customChatSDK,
4441
+ ...a
4442
+ },
4443
+ /* @__PURE__ */ r.createElement(
4444
+ zs,
4445
+ {
4446
+ ref: l,
4447
+ userSessionInfo: s,
4448
+ forceCreateChannel: (u = a.agentPreviewConfigs) == null ? void 0 : u.forceCreateChannel
4449
+ },
4450
+ /* @__PURE__ */ r.createElement(Ql, { ...a._UNSAFE_INTERNAL_dashboardTester }, i, /* @__PURE__ */ r.createElement("div", { id: ie.MODAL_ROOT }))
4451
+ )
4452
+ )
4453
+ ));
4454
+ }), $e = new Ln(wn.WARN), yu = new Mn($e), Cr = ({ children: e, isOpened: t }) => {
4455
+ const { dir: n, rootElement: o } = V(), s = fe(o, !0);
4456
+ return R(() => {
4457
+ const i = "sb-agent-block-scroll";
4458
+ return t ? s.body.classList.add(i) : s.body.classList.remove(i), () => {
4459
+ s.body.classList.remove(i);
4460
+ };
4461
+ }, [s, t]), /* @__PURE__ */ r.createElement(Cu, { dir: n, $visible: t }, e);
4462
+ }, Cu = m.div`width:100%;height:100%;position:fixed;top:0;left:0;z-index:${xe.WINDOW};visibility:${({ $visible: e }) => e ? "visible" : "hidden"};`, _u = 48, Su = 2 / 3;
4463
+ function Tu({
4464
+ className: e,
4465
+ isOpened: t,
4466
+ onClick: n,
4467
+ type: o,
4468
+ imageUrl: s,
4469
+ dir: i,
4470
+ animated: a = !0,
4471
+ backgroundColor: l,
4472
+ size: c = _u
4473
+ }) {
4474
+ const u = bt(l), b = Math.round(c * Su);
4475
+ return /* @__PURE__ */ r.createElement(
4476
+ ku,
4477
+ {
4478
+ dir: i,
4479
+ id: ie.LAUNCHER,
4480
+ className: e,
4481
+ "aria-label": "Sendbird AIAgent Launcher",
4482
+ onClick: n,
4483
+ $animated: a,
4484
+ $backgroundColor: l,
4485
+ $size: c
4486
+ },
4487
+ /* @__PURE__ */ r.createElement($u, { $isOpened: t, $animated: a, $fillColor: u, $iconSize: b }, /* @__PURE__ */ r.createElement(Sn.Open, { url: s, isDefaultIcon: o === "default_icon" })),
4488
+ /* @__PURE__ */ r.createElement(Iu, { $isOpened: t, $animated: a, $fillColor: u, $iconSize: b }, /* @__PURE__ */ r.createElement(Sn.Close, { size: b }))
4489
+ );
4490
+ }
4491
+ const wu = _`&:hover{transition:transform 250ms cubic-bezier(0.33,0,0,1);transform:scale(1.1);}&:active{transform:scale(0.8);}`, Au = _`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 === Hn.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 }) => _`
4492
+ path {
4493
+ fill: ${e};
4494
+ }
4495
+ [class*='fill'] {
4496
+ fill: ${e};
4497
+ }
4498
+ `}
4499
+ }
4500
+ `, ku = 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 && wu}`, 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)")};${Au}${_r}`, Iu = m(Sr)`scale:${({ $isOpened: e }) => e ? 1 : 0};transform:${({ $animated: e, $isOpened: t }) => e && (t ? "rotate(0deg)" : "rotate(-90deg)")};${_r}`, Sn = {
4501
+ Open: (e) => e.url ? /* @__PURE__ */ r.createElement("img", { src: e.url, alt: "launcher-img", "data-default-icon": e.isDefaultIcon }) : /* @__PURE__ */ r.createElement(Ot, null),
4502
+ Close: ({ size: e }) => /* @__PURE__ */ r.createElement(O, { size: e, type: "chevron-down" })
4503
+ };
4504
+ function Tr({ className: e, size: t }) {
4505
+ const { colors: n } = _t(), { dir: o, state: s } = V(), { launcherInfo: i } = H();
4506
+ return Ou(), /* @__PURE__ */ r.createElement(
4507
+ Tu,
4508
+ {
4509
+ dir: o,
4510
+ className: e,
4511
+ isOpened: s.opened,
4512
+ onClick: () => s.setOpened(!s.opened),
4513
+ type: i.type,
4514
+ imageUrl: i.imageUrl,
4515
+ backgroundColor: n.base.primary,
4516
+ size: t
4517
+ }
4518
+ );
4519
+ }
4520
+ const Mu = 1e3 * 60;
4521
+ function Ou() {
4522
+ const { chatSDK: e, state: t, logger: n, enableAutoDisconnectInLauncher: o } = V(), s = B(null);
4523
+ R(() => {
4524
+ if (!o) return;
4525
+ function i() {
4526
+ s.current && (clearTimeout(s.current), s.current = null);
4527
+ }
4528
+ function a() {
4529
+ e.connectionState === Vr.CLOSED && (e.reconnect(), n.debug("useSDKInactivityTimeout: reconnected")), i(), n.debug("useSDKInactivityTimeout: clear disconnect schedule");
4530
+ }
4531
+ function l() {
4532
+ i(), s.current = setTimeout(async () => {
4533
+ await e.disconnectWebSocket(), n.debug("useSDKInactivityTimeout: disconnected");
4534
+ }, Mu);
4535
+ }
4536
+ t.opened ? a() : (l(), n.debug("useSDKInactivityTimeout: schedule disconnect"));
4537
+ }, [o, e, t.opened]);
4538
+ }
4539
+ const wr = _e(null);
4540
+ function Lu() {
4541
+ const e = se(wr);
4542
+ if (!e)
4543
+ throw new Error("useNavigator() must be used within <Navigator />");
4544
+ return e;
4545
+ }
4546
+ function Ar({ children: e }) {
4547
+ const t = Lu();
4548
+ return typeof e == "function" ? e(t) : /* @__PURE__ */ r.createElement(r.Fragment, null, e);
4549
+ }
4550
+ const Ru = An`0%{transform:translateY(40px);opacity:0;}100%{transform:translateY(0px);opacity:1;}`, Du = An`0%{transform:translateY(0px);opacity:1;}100%{transform:translateY(40px);opacity:0;}`, Nu = _`animation-name:${Ru};animation-duration:0.3s;animation-fill-mode:forwards;`, Fu = _``, Bu = _`animation-name:${Du};animation-duration:0.3s;animation-fill-mode:forwards;`, Pu = _`visibility:hidden;`, Uu = m.div`position:absolute;top:0;left:0;width:100%;height:100%;${({ $transitionState: e }) => {
4551
+ switch (e) {
4552
+ case "entering":
4553
+ return Nu;
4554
+ case "entered":
4555
+ return Fu;
4556
+ case "exiting":
4557
+ return Bu;
4558
+ case "exited":
4559
+ return Pu;
4560
+ default:
4561
+ return "";
4562
+ }
4563
+ }}${({ $active: e }) => e ? _`
4564
+ z-index: 999;
4565
+ ` : _`z-index:1;pointer-events:none;`}
4566
+ `;
4567
+ function Ie({ initialId: e, children: t }) {
4568
+ const n = D((h, p) => {
4569
+ c((v) => [...v, h]), b((v) => ({ ...v, [h]: !0 })), p != null && p.reset && E((v) => ({
4570
+ ...v,
4571
+ [h]: (v[h] || 0) + 1
4572
+ })), x((v) => ({
4573
+ ...v,
4574
+ [h]: "entering"
4575
+ })), setTimeout(() => {
4576
+ x((v) => ({
4577
+ ...v,
4578
+ [h]: "entered"
4579
+ }));
4580
+ }, 300);
4581
+ }, []), o = D(() => {
4582
+ c((h) => {
4583
+ if (h.length <= 1) return h;
4584
+ const p = h[h.length - 1];
4585
+ return x((v) => ({
4586
+ ...v,
4587
+ [p]: "exiting"
4588
+ })), setTimeout(() => {
4589
+ x((v) => ({
4590
+ ...v,
4591
+ [p]: "exited"
4592
+ })), c((v) => v.slice(0, -1));
4593
+ }, 300), h;
4594
+ });
4595
+ }, []), s = Q(() => ({
4596
+ navigation: {
4597
+ navigate: n,
4598
+ pop: o
4599
+ }
4600
+ }), [n, o]), i = Q(() => Dr.toArray(t).filter(
4601
+ (h) => h.type === Ar
4602
+ ), [t]), a = Q(() => {
4603
+ const h = {};
4604
+ return i.forEach((p) => {
4605
+ const { id: v, lazy: S, children: M } = p.props;
4606
+ h[v] = { lazy: S, element: typeof M == "function" ? M(s) : M };
4607
+ }), h;
4608
+ }, [i]), [l, c] = T([e]), [u, b] = T(() => {
4609
+ const h = {};
4610
+ return Object.entries(a).forEach(([p, { lazy: v }]) => {
4611
+ v === !1 && (h[p] = !0);
4612
+ }), h[e] = !0, h;
4613
+ }), [g, x] = T(() => {
4614
+ const h = {};
4615
+ return Object.keys(a).forEach((p) => {
4616
+ p === e ? h[p] = "entered" : h[p] = "exited";
4617
+ }), h;
4618
+ }), [y, E] = T({}), f = l[l.length - 1];
4619
+ return /* @__PURE__ */ r.createElement(wr.Provider, { value: s }, /* @__PURE__ */ r.createElement(Hu, null, Object.keys(a).map((h) => {
4620
+ var M;
4621
+ if (!u[h]) return null;
4622
+ const p = g[h] || "exited", v = h === f, S = `${h}-${y[h] || 0}`;
4623
+ return /* @__PURE__ */ r.createElement(Uu, { key: S, $transitionState: p, $active: v }, (M = a[h]) == null ? void 0 : M.element);
4624
+ })));
4625
+ }
4626
+ const Hu = m.div`position:relative;width:100%;height:100%;`;
4627
+ Ie.Screen = Ar;
4628
+ const pe = {
4629
+ activeConv: "active-conv",
4630
+ closedConv: "closed-conv",
4631
+ convList: "conv-list"
4632
+ }, kr = ({ setClosedChannelUrl: e, closedChannelUrl: t }) => /* @__PURE__ */ r.createElement(Ie, { initialId: pe.activeConv }, /* @__PURE__ */ r.createElement(Ie.Screen, { id: pe.activeConv }, ({ navigation: n }) => /* @__PURE__ */ r.createElement(_n, { onNavigateToConversationList: () => n.navigate(pe.convList, { reset: !0 }) })), /* @__PURE__ */ r.createElement(Ie.Screen, { id: pe.closedConv }, ({ navigation: n }) => /* @__PURE__ */ r.createElement(
4633
+ _n,
4634
+ {
4635
+ onNavigateToConversationList: () => n.pop(),
4636
+ closedChannelUrl: t,
4637
+ onClearClosedChannelUrl: () => e(void 0)
4638
+ }
4639
+ )), /* @__PURE__ */ r.createElement(Ie.Screen, { id: pe.convList, lazy: !0 }, ({ navigation: n }) => /* @__PURE__ */ r.createElement(
4640
+ mu,
4641
+ {
4642
+ onOpenConversationView: (o, s) => {
4643
+ s === "closed" ? (e(o), n.navigate(pe.closedConv, { reset: !0 })) : n.navigate(pe.activeConv);
4644
+ }
4645
+ }
4646
+ )));
4647
+ function Vu({ isExpanded: e, isOpened: t, children: n, launcher: o }) {
4648
+ const { dir: s } = V();
4649
+ return /* @__PURE__ */ r.createElement(zu, null, /* @__PURE__ */ r.createElement(Wu, { dir: s, id: ie.WINDOW, $isExpanded: e, $isOpened: t }, n), o);
4650
+ }
4651
+ const zu = m.div`display:flex;flex-direction:column;gap:8px;align-items:flex-end;`, Wu = 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 && ju};${({ $isExpanded: e }) => e && Gu};`, Gu = _`width:743px;height:723px;`, ju = _`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;`, vm = Se(function({ children: e, ...t }, n) {
4652
+ const o = De(), [s, i] = T(), a = o ? Cr : Vu;
4653
+ return /* @__PURE__ */ r.createElement(yr, { enableExpandButton: !o, ref: n, ...t }, /* @__PURE__ */ r.createElement(Un, 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(
4654
+ kr,
4655
+ {
4656
+ closedChannelUrl: s,
4657
+ setClosedChannelUrl: i
4658
+ }
4659
+ )), e)));
4660
+ }), {
4661
+ Provider: Ku,
4662
+ useContext: Gt
4663
+ } = W("FixedMessengerStyle");
4664
+ function $r(e, t, n, o = 0) {
4665
+ const { top: s, bottom: i, start: a, end: l } = n;
4666
+ let c = "", u = "";
4667
+ switch (e) {
4668
+ case "start":
4669
+ u = `inset-inline-start: ${j(a)}`;
4670
+ break;
4671
+ case "end":
4672
+ u = `inset-inline-end: ${j(l)}`;
4673
+ break;
4674
+ }
4675
+ switch (t) {
4676
+ case "top":
4677
+ c = `top: calc(${j(s)} + ${o}px)`;
4678
+ break;
4679
+ case "bottom":
4680
+ c = `bottom: calc(${j(i)} + ${o}px)`;
4681
+ break;
4682
+ }
4683
+ return _`${c};${u};`;
4684
+ }
4685
+ function qu(e) {
4686
+ const { horizontal: t, vertical: n, margin: o, launcherSize: s } = Gt();
4687
+ return /* @__PURE__ */ r.createElement(Zu, { ...e, size: s, $horizontal: t, $vertical: n, $margin: o });
4688
+ }
4689
+ const Zu = m(Tr)`position:fixed;z-index:${xe.LAUNCHER};${({ $horizontal: e, $vertical: t, $margin: n }) => $r(e, t, n)};`;
4690
+ function Yu({ isExpanded: e, isOpened: t, children: n }) {
4691
+ const { dir: o } = V(), { horizontal: s, vertical: i, margin: a, launcherSize: l } = Gt();
4692
+ return /* @__PURE__ */ r.createElement(
4693
+ Ju,
4694
+ {
4695
+ dir: o,
4696
+ id: ie.WINDOW,
4697
+ $isExpanded: e,
4698
+ $isOpened: t,
4699
+ $horizontal: s,
4700
+ $vertical: i,
4701
+ $margin: a,
4702
+ $launcherSize: l
4703
+ },
4704
+ n
4705
+ );
4706
+ }
4707
+ const Ju = 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 }) => $r(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}`};
4708
+ [dir='rtl'] &:not([dir='ltr']),
4709
+ &[dir='rtl'] {
4710
+ transform-origin: ${({ $horizontal: e, $vertical: t }) => `${e === "start" ? "right" : "left"} ${t}`};
4711
+ }
4712
+
4713
+ ${({ $isOpened: e }) => e && Qu};
4714
+ ${({ $isExpanded: e }) => e && Xu};
4715
+ `, Xu = _`width:743px;height:723px;`, Qu = _`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;`, Ir = { top: 24, bottom: 24, start: 24, end: 24 }, em = Se(function({ children: e, ...t }, n) {
4716
+ const [o, s] = T(), [i, a] = T("end-bottom"), [l, c] = T(Ir), [u, b] = T(48), g = De(), x = g ? Cr : Yu, { horizontal: y, vertical: E } = Q(() => {
4717
+ const [f, h] = i.split("-");
4718
+ return { horizontal: f === "start" ? "start" : "end", vertical: h === "top" ? "top" : "bottom" };
4719
+ }, [i]);
4720
+ return /* @__PURE__ */ r.createElement(yr, { enableExpandButton: !g, ref: n, ...t }, /* @__PURE__ */ r.createElement(Un, null, ({ state: f }) => /* @__PURE__ */ r.createElement(
4721
+ Ku,
4722
+ {
4723
+ value: { horizontal: y, vertical: E, margin: l, launcherSize: u, setPosition: a, setMargin: c, setLauncherSize: b }
4724
+ },
4725
+ /* @__PURE__ */ r.createElement(x, { isExpanded: f.expanded, isOpened: f.opened }, /* @__PURE__ */ r.createElement(
4726
+ kr,
4727
+ {
4728
+ closedChannelUrl: o,
4729
+ setClosedChannelUrl: s
4730
+ }
4731
+ )),
4732
+ /* @__PURE__ */ r.createElement(qu, null),
4733
+ e
4734
+ )));
4735
+ }), tm = (e) => {
4736
+ var s, i, a, l;
4737
+ const { setPosition: t, setMargin: n, setLauncherSize: o } = Gt();
4738
+ return de(() => {
4739
+ e.position && t(e.position), e.margin && n({ ...Ir, ...e.margin }), e.launcherSize && o(e.launcherSize);
4740
+ }, [
4741
+ e.position,
4742
+ (s = e.margin) == null ? void 0 : s.top,
4743
+ (i = e.margin) == null ? void 0 : i.bottom,
4744
+ (a = e.margin) == null ? void 0 : a.start,
4745
+ (l = e.margin) == null ? void 0 : l.end,
4746
+ e.launcherSize
4747
+ ]), null;
4748
+ }, ym = Object.assign(em, {
4749
+ Style: tm
4750
+ });
4751
+ export {
4752
+ kt as A,
4753
+ vo as C,
4754
+ vm as D,
4755
+ ym as F,
4756
+ O as I,
4757
+ rr as L,
4758
+ Yl as M,
4759
+ Bt as O,
4760
+ xm as P,
4761
+ Pt as S,
4762
+ w as a,
4763
+ yr as b,
4764
+ d as c,
4765
+ vu as d,
4766
+ H as e,
4767
+ L as f,
4768
+ Tu as g,
4769
+ ye as h,
4770
+ oe as i,
4771
+ vr as j,
4772
+ _n as k,
4773
+ zt as l,
4774
+ yu as m,
4775
+ bm as n,
4776
+ Ec as o,
4777
+ Z as p,
4778
+ mu as q,
4779
+ Wt as r,
4780
+ Em as s,
4781
+ Yd as t,
4782
+ V as u,
4783
+ Er as v,
4784
+ On as w,
4785
+ Fo as x,
4786
+ Xt as y
4787
+ };